8 #include <unordered_map>
10 #include <llvm/ADT/DenseMap.h>
11 #include <llvm/Analysis/OptimizationRemarkEmitter.h>
12 #include <llvm/CodeGen/MachineBasicBlock.h>
13 #include <llvm/IR/Module.h>
14 #include <llvm/IR/Type.h>
15 #include <llvm/Pass.h>
16 #include <llvm/Target/AArch64/AArch64InstrInfo.h>
17 #include <llvm/Target/AArch64/AArch64ISelDAGToDAG.h>
18 #include <llvm/Target/AArch64/AArch64MachineFunctionInfo.h>
19 #include <llvm/Target/AArch64/AArch64RegisterInfo.h>
20 #include <llvm/Target/AArch64/AArch64Subtarget.h>
21 #include <llvm/Target/AArch64/AArch64TargetMachine.h>
23 #include "core/insts.h"
24 #include "emitter/isel.h"
25 #include "emitter/aarch64/aarch64call.h"
41 llvm::AArch64TargetMachine &tm,
42 llvm::CodeGenOpt::Level ol,
43 llvm::MachineFunction &mf
49 llvm::SelectionDAG &
GetDAG()
const {
return *CurDAG; }
53 return CurDAG->getMachineFunction().getSubtarget().getTargetLowering();
58 llvm::AArch64TargetMachine &tm_;
72 llvm::AArch64TargetMachine &tm,
73 llvm::TargetLibraryInfo &libInfo,
75 llvm::CodeGenOpt::Level ol,
81 void Lower(llvm::MachineFunction &mf)
override
87 SDValue GetRegArch(Register reg)
override;
90 void LowerArch(
const Inst *inst)
override;
93 void LowerSyscall(
const SyscallInst *inst)
override;
95 void LowerClone(
const CloneInst *inst)
override;
97 void LowerReturn(
const ReturnInst *inst)
override;
99 void LowerRaise(
const RaiseInst *inst)
override;
101 void LowerSpawn(
const SpawnInst *inst)
override;
103 void LowerLandingPad(
const LandingPadInst *inst)
override;
105 void LowerSet(
const SetInst *inst)
override;
107 void LowerLoadLink(
const AArch64_LoadLinkInst *inst);
109 void LowerStoreCond(
const AArch64_StoreCondInst *inst);
111 void LowerAsm(
const Inst *inst,
const char *code);
113 void LowerOut(
const AArch64_OutInst *inst);
116 void LowerArguments(
bool hasVAStart)
override;
122 llvm::SelectionDAG &GetDAG()
const override {
return m_->GetDAG(); }
124 void PreprocessISelDAG()
override { m_->PreprocessISelDAG(); }
126 void PostprocessISelDAG()
override { m_->PostprocessISelDAG(); }
128 void Select(SDNode *node)
override { m_->Select(node); }
131 llvm::Register GetStackRegister()
const override {
return llvm::AArch64::SP; }
135 void LowerSetSP(SDValue value);
137 void SaveVarArgRegisters(
const AArch64Call &ci,
bool isWin64);
141 void LowerCallSite(llvm::SDValue chain,
const CallSite *call)
override;
145 llvm::AArch64TargetMachine &tm_;
147 std::unique_ptr<AArch64Matcher> m_;
149 llvm::Function *trampoline_;