llir-opt  0.0.1
Low-Level Post-Link Optimiser for OCaml and C
init.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/inst_visitor.h"
8 #include "core/target.h"
9 
10 
11 
12 namespace tags {
13 
14 class RegisterAnalysis;
15 class TaggedType;
16 
17 
18 
22 class Init : public InstVisitor<void> {
23 public:
24  Init(RegisterAnalysis &analysis, const Target *target)
25  : analysis_(analysis)
26  , target_(target)
27  {
28  }
29 
30  void VisitArgInst(ArgInst &i) override;
31  void VisitMovInst(MovInst &i) override;
32  void VisitNegInst(NegInst &i) override;
33  void VisitFrameInst(FrameInst &i) override;
34  void VisitAllocaInst(AllocaInst &i) override;
35  void VisitGetInst(GetInst &i) override;
36  void VisitUndefInst(UndefInst &i) override;
37  void VisitCopySignInst(CopySignInst &i) override;
38  void VisitFloatInst(FloatInst &i) override;
39  void VisitX86_RdTscInst(X86_RdTscInst &i) override;
40  void VisitLoadInst(LoadInst &i) override;
41  void VisitBitCountInst(BitCountInst &i) override;
42  void VisitRotateInst(RotateInst &i) override;
43  void VisitSyscallInst(SyscallInst &i) override;
44  void VisitCloneInst(CloneInst &i) override;
45  void VisitLandingPadInst(LandingPadInst &i) override;
46 
47  void VisitControlInst(ControlInst &i) override {}
48  void VisitBarrierInst(BarrierInst &i) override {}
49  void VisitX86_PauseInst(X86_PauseInst &i) override {}
50  void VisitX86_YieldInst(X86_YieldInst &i) override {}
51  void VisitX86_BarrierInst(X86_BarrierInst &i) override {}
52  void VisitX86_HltInst(X86_HltInst &i) override {}
53  void VisitX86_FnClExInst(X86_FnClExInst &i) override {}
54  void VisitX86_FPUControlInst(X86_FPUControlInst &i) override {}
55 
56  void VisitInst(Inst &i) override
57  {
58  for (auto v : i.operand_values()) {
59  if (v->Is(Value::Kind::INST)) {
60  return;
61  }
62  }
63  i.dump();
64  llvm_unreachable("instruction not handled");
65  }
66 
67 private:
68  TaggedType Infer(Type ty);
69 
70 private:
72  RegisterAnalysis &analysis_;
74  const Target *target_;
75 };
76 
77 } // end namespace
Inst
Definition: inst.h:53
Target
Definition: target.h:24
Inst::dump
void dump(llvm::raw_ostream &os=llvm::errs()) const
Dumps the textual representation of the instruction.
Definition: inst.cpp:81
MovInst
Definition: mov.h:17
tags::Init
Definition: init.h:22
tags::RegisterAnalysis
Definition: register_analysis.h:37
InstVisitor
Definition: inst_visitor.h:15
tags::TaggedType
Definition: tagged_type.h:17