36#define DEBUG_TYPE "ppc-tls-dynamic-call"
50 bool NeedFence =
true;
58 IsPCREL = isPCREL(
MI);
60 if (
MI.getOpcode() != PPC::ADDItlsgdLADDR &&
61 MI.getOpcode() != PPC::ADDItlsldLADDR &&
62 MI.getOpcode() != PPC::ADDItlsgdLADDR32 &&
63 MI.getOpcode() != PPC::ADDItlsldLADDR32 &&
64 MI.getOpcode() != PPC::TLSGDAIX &&
65 MI.getOpcode() != PPC::TLSGDAIX8 && !IsPCREL) {
70 if (
MI.getOpcode() == PPC::ADJCALLSTACKDOWN)
72 else if (
MI.getOpcode() == PPC::ADJCALLSTACKUP)
83 Register GPR3 = Is64Bit ? PPC::X3 : PPC::R3;
84 Register GPR4 = Is64Bit ? PPC::X4 : PPC::R4;
86 InReg =
MI.getOperand(1).getReg();
90 switch (
MI.getOpcode()) {
93 case PPC::ADDItlsgdLADDR:
94 Opc1 = PPC::ADDItlsgdL;
95 Opc2 = PPC::GETtlsADDR;
97 case PPC::ADDItlsldLADDR:
98 Opc1 = PPC::ADDItlsldL;
99 Opc2 = PPC::GETtlsldADDR;
101 case PPC::ADDItlsgdLADDR32:
102 Opc1 = PPC::ADDItlsgdL32;
103 Opc2 = PPC::GETtlsADDR32;
105 case PPC::ADDItlsldLADDR32:
106 Opc1 = PPC::ADDItlsldL32;
107 Opc2 = PPC::GETtlsldADDR32;
112 Opc2 = PPC::GETtlsADDR64AIX;
117 Opc2 = PPC::GETtlsADDR32AIX;
120 assert(IsPCREL &&
"Expecting General/Local Dynamic PCRel");
121 Opc1 = PPC::PADDI8pc;
122 Opc2 =
MI.getOperand(2).getTargetFlags() ==
124 ? PPC::GETtlsADDRPCREL
125 : PPC::GETtlsldADDRPCREL;
152 assert(InReg != PPC::NoRegister &&
"Operand must be a register");
161 Call->addOperand(
MI.getOperand(2));
163 Call->addOperand(
MI.getOperand(3));
173 MI.removeFromParent();
183 return (
MI.getOpcode() == PPC::PADDI8pc) &&
184 (
MI.getOperand(2).getTargetFlags() ==
186 MI.getOperand(2).getTargetFlags() ==
193 bool Changed =
false;
211 "PowerPC TLS Dynamic Call Fixup",
false,
false)
217char PPCTLSDynamicCall::
ID = 0;
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
const HexagonInstrInfo * TII
PowerPC TLS Dynamic Call Fixup
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
FunctionPass class - This class is used to implement most global optimizations.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
Representation of each machine instruction.
void addOperand(MachineFunction &MF, const MachineOperand &Op)
Add the specified operand to the instruction.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Wrapper class representing virtual and physical registers.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ MO_GOT_TLSLD_PCREL_FLAG
MO_GOT_TLSLD_PCREL_FLAG - A combintaion of flags, if these bits are set they should produce the reloc...
@ MO_GOT_TLSGD_PCREL_FLAG
MO_GOT_TLSGD_PCREL_FLAG - A combintaion of flags, if these bits are set they should produce the reloc...
This is an optimization pass for GlobalISel generic memory operations.
void initializePPCTLSDynamicCallPass(PassRegistry &)
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
FunctionPass * createPPCTLSDynamicCallPass()
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
@ Dynamic
Denotes mode unknown at compile time.