llir-opt  0.0.1
Low-Level Post-Link Optimiser for OCaml and C
dedup_block.h
1 // This file if part of the llir-opt project.
2 // Licensing information can be found in the LICENSE file.
3 // (C) 2018 Nandor Licker. All rights reserved.
4 
5 #pragma once
6 
7 #include "core/pass.h"
8 
9 class Func;
10 
11 
12 
16 class DedupBlockPass final : public Pass {
17 public:
19  static const char *kPassID;
20 
22  DedupBlockPass(PassManager *passManager) : Pass(passManager) {}
23 
25  bool Run(Prog &prog) override;
26 
28  const char *GetPassName() const override;
29 
30 private:
32  bool Run(Func &func);
34  void DedupBlock(const Func *func, const Block *block);
35 
36  using InstMap = llvm::DenseMap<const Inst *, const Inst *>;
38  bool IsEqual(const Block *b1, const Block *b2);
40  bool IsEqual(const Inst *i1, const Inst *i2, InstMap &insts);
41 };
Inst
Definition: inst.h:53
Func
Definition: func.h:30
PassManager
Definition: pass_manager.h:74
Pass
Definition: pass.h:17
DedupBlockPass::Run
bool Run(Prog &prog) override
Runs the pass.
Definition: dedup_block.cpp:36
DedupBlockPass::GetPassName
const char * GetPassName() const override
Returns the name of the pass.
Definition: dedup_block.cpp:29
DedupBlockPass
Definition: dedup_block.h:16
Prog
Definition: prog.h:33
Block
Definition: block.h:29
DedupBlockPass::DedupBlockPass
DedupBlockPass(PassManager *passManager)
Initialises the pass.
Definition: dedup_block.h:22
DedupBlockPass::kPassID
static const char * kPassID
Pass identifier.
Definition: dedup_block.h:19