llir-opt  0.0.1
Low-Level Post-Link Optimiser for OCaml and C
peephole.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 #include "core/inst_visitor.h"
9 
10 class Func;
11 class MovInst;
12 
13 
14 
18 class PeepholePass final : public Pass, InstVisitor<bool> {
19 public:
21  static const char *kPassID;
22 
24  PeepholePass(PassManager *passManager) : Pass(passManager) {}
25 
27  bool Run(Prog &prog) override;
28 
30  const char *GetPassName() const override;
31 
32 private:
33  bool VisitInst(Inst &inst) override { return false; }
34  bool VisitAddInst(AddInst &inst) override;
35  bool VisitSubInst(SubInst &inst) override;
36  bool VisitStoreInst(StoreInst &inst) override;
37  bool VisitCmpInst(CmpInst &inst) override;
38 };
Inst
Definition: inst.h:53
Func
Definition: func.h:30
PassManager
Definition: pass_manager.h:74
Pass
Definition: pass.h:17
PeepholePass::GetPassName
const char * GetPassName() const override
Returns the name of the pass.
Definition: peephole.cpp:30
PeepholePass
Definition: peephole.h:18
PeepholePass::Run
bool Run(Prog &prog) override
Runs the pass.
Definition: peephole.cpp:36
PeepholePass::PeepholePass
PeepholePass(PassManager *passManager)
Initialises the pass.
Definition: peephole.h:24
MovInst
Definition: mov.h:17
PeepholePass::kPassID
static const char * kPassID
Pass identifier.
Definition: peephole.h:21
Prog
Definition: prog.h:33
InstVisitor
Definition: inst_visitor.h:15