36#define DEBUG_TYPE "ppc-tls-dynamic-call"
50 bool NeedFence =
true;
58 IsPCREL = isPCREL(
MI);
61 bool IsTLSTPRelMI =
MI.getOpcode() == PPC::GETtlsTpointer32AIX;
63 if (
MI.getOpcode() != PPC::ADDItlsgdLADDR &&
64 MI.getOpcode() != PPC::ADDItlsldLADDR &&
65 MI.getOpcode() != PPC::ADDItlsgdLADDR32 &&
66 MI.getOpcode() != PPC::ADDItlsldLADDR32 &&
67 MI.getOpcode() != PPC::TLSGDAIX &&
68 MI.getOpcode() != PPC::TLSGDAIX8 && !IsTLSTPRelMI && !IsPCREL) {
73 if (
MI.getOpcode() == PPC::ADJCALLSTACKDOWN)
75 else if (
MI.getOpcode() == PPC::ADJCALLSTACKUP)
86 Register GPR3 = Is64Bit ? PPC::X3 : PPC::R3;
87 Register GPR4 = Is64Bit ? PPC::X4 : PPC::R4;
88 if (!IsPCREL && !IsTLSTPRelMI)
89 InReg =
MI.getOperand(1).getReg();
93 switch (
MI.getOpcode()) {
96 case PPC::ADDItlsgdLADDR:
97 Opc1 = PPC::ADDItlsgdL;
98 Opc2 = PPC::GETtlsADDR;
100 case PPC::ADDItlsldLADDR:
101 Opc1 = PPC::ADDItlsldL;
102 Opc2 = PPC::GETtlsldADDR;
104 case PPC::ADDItlsgdLADDR32:
105 Opc1 = PPC::ADDItlsgdL32;
106 Opc2 = PPC::GETtlsADDR32;
108 case PPC::ADDItlsldLADDR32:
109 Opc1 = PPC::ADDItlsldL32;
110 Opc2 = PPC::GETtlsldADDR32;
115 Opc2 = PPC::GETtlsADDR64AIX;
120 Opc2 = PPC::GETtlsADDR32AIX;
122 case PPC::GETtlsTpointer32AIX:
126 Opc2 = PPC::GETtlsTpointer32AIX;
129 assert(IsPCREL &&
"Expecting General/Local Dynamic PCRel");
130 Opc1 = PPC::PADDI8pc;
131 Opc2 =
MI.getOperand(2).getTargetFlags() ==
133 ? PPC::GETtlsADDRPCREL
134 : PPC::GETtlsldADDRPCREL;
167 assert(InReg != PPC::NoRegister &&
"Operand must be a register");
176 Call->addOperand(
MI.getOperand(2));
178 Call->addOperand(
MI.getOperand(3));
188 MI.removeFromParent();
198 return (
MI.getOpcode() == PPC::PADDI8pc) &&
199 (
MI.getOperand(2).getTargetFlags() ==
201 MI.getOperand(2).getTargetFlags() ==
208 bool Changed =
false;
226 "PowerPC TLS Dynamic Call Fixup",
false,
false)
232char 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.