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/PowerPC/PPCInstrInfo.h>
17 #include <llvm/Target/PowerPC/PPCISelDAGToDAG.h>
18 #include <llvm/Target/PowerPC/PPCMachineFunctionInfo.h>
19 #include <llvm/Target/PowerPC/PPCRegisterInfo.h>
20 #include <llvm/Target/PowerPC/PPCSubtarget.h>
21 #include <llvm/Target/PowerPC/PPCTargetMachine.h>
23 #include "core/insts.h"
24 #include "emitter/isel.h"
25 #include "emitter/ppc/ppccall.h"
41 llvm::PPCTargetMachine &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::PPCTargetMachine &tm_;
72 llvm::PPCTargetMachine &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 PPC_LoadLinkInst *inst);
109 void LowerStoreCond(
const PPC_StoreCondInst *inst);
111 void LowerFence(
const PPC_FenceInst *inst);
113 void LowerIFence(
const PPC_IFenceInst *inst);
116 void LowerArguments(
bool hasVAStart)
override;
118 void LowerVASetup(
const PPCCall &ci);
120 llvm::SDValue StoreTOC(llvm::SDValue chain);
124 llvm::SelectionDAG &GetDAG()
const override {
return m_->GetDAG(); }
126 void PreprocessISelDAG()
override { m_->PreprocessISelDAG(); }
128 void PostprocessISelDAG()
override { m_->PostprocessISelDAG(); }
130 void Select(SDNode *node)
override { m_->Select(node); }
133 llvm::Register GetStackRegister()
const override {
return llvm::PPC::X1; }
139 std::pair<unsigned, llvm::SDValue> LowerCallee(
141 llvm::SDValue &chain,
145 void LowerCallSite(llvm::SDValue chain,
const CallSite *call)
override;
149 llvm::PPCTargetMachine &tm_;
151 std::unique_ptr<PPCMatcher> m_;
153 llvm::Function *trampoline_;