24#define RISCV_PRERA_EXPAND_PSEUDO_NAME \
25 "RISC-V Pre-RA pseudo instruction expansion pass"
35 unsigned SecondOpcode)
const;
60 return RISCVPreRAExpandPseudoImpl().run(MF);
78bool RISCVPreRAExpandPseudoImpl::expandMI(
82 switch (
MBBI->getOpcode()) {
83 case RISCV::PseudoLLA:
84 return expandLoadLocalAddress(
MBB,
MBBI);
85 case RISCV::PseudoLGA:
86 return expandLoadGlobalAddress(
MBB,
MBBI);
87 case RISCV::PseudoLA_TLS_IE:
88 return expandLoadTLSIEAddress(
MBB,
MBBI);
89 case RISCV::PseudoLA_TLS_GD:
90 return expandLoadTLSGDAddress(
MBB,
MBBI);
91 case RISCV::PseudoLA_TLSDESC:
92 return expandLoadTLSDescAddress(
MBB,
MBBI);
98bool RISCVPreRAExpandPseudoImpl::expandAuipcInstPair(
100 unsigned SecondOpcode)
const {
109 MachineOperand &
Symbol =
MI.getOperand(1);
110 Symbol.setTargetFlags(FlagsHi);
113 MachineInstr *MIAUIPC =
117 MachineInstr *SecondMI =
122 if (
MI.hasOneMemOperand())
125 MI.eraseFromParent();
129bool RISCVPreRAExpandPseudoImpl::expandLoadLocalAddress(
134bool RISCVPreRAExpandPseudoImpl::expandLoadGlobalAddress(
136 unsigned SecondOpcode = STI->is64Bit() ? RISCV::LD : RISCV::LW;
140bool RISCVPreRAExpandPseudoImpl::expandLoadTLSIEAddress(
142 unsigned SecondOpcode = STI->is64Bit() ? RISCV::LD : RISCV::LW;
146bool RISCVPreRAExpandPseudoImpl::expandLoadTLSGDAddress(
151bool RISCVPreRAExpandPseudoImpl::expandLoadTLSDescAddress(
158 unsigned SecondOpcode = STI.is64Bit() ? RISCV::LD : RISCV::LW;
160 Register FinalReg =
MI.getOperand(0).getReg();
166 MachineOperand &
Symbol =
MI.getOperand(1);
170 MachineInstr *MIAUIPC =
191 MI.eraseFromParent();
195char RISCVPreRAExpandPseudoLegacy::ID = 0;
201 return new RISCVPreRAExpandPseudoLegacy();
208 bool Changed = RISCVPreRAExpandPseudoImpl().run(MF);
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
const HexagonInstrInfo * TII
Promote Memory to Register
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
#define RISCV_PRERA_EXPAND_PSEUDO_NAME
Represent the analysis usage information of a pass.
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
Represents analyses that only rely on functions' control flow.
FunctionPass class - This class is used to implement most global optimizations.
LLVM_ABI MCSymbol * createNamedTempSymbol()
Create a temporary symbol with a unique name whose name cannot be omitted in the symbol table.
An RAII based helper class to modify MachineFunctionProperties when running pass.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
MachineInstrBundleIterator< MachineInstr > iterator
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.
Properties which a MachineFunction may have at a given point in time.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MCContext & getContext() const
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & add(const MachineOperand &MO) const
const MachineInstrBuilder & addSym(MCSymbol *Sym, unsigned char TargetFlags=0) const
LLVM_ABI void setPreInstrSymbol(MachineFunction &MF, MCSymbol *Symbol)
Set a symbol that will be emitted just prior to the instruction itself.
LLVM_ABI void addMemOperand(MachineFunction &MF, MachineMemOperand *MO)
Add a MachineMemOperand to the machine instruction.
LLVM_ABI Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Represent a constant reference to a string, i.e.
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
FunctionPass * createRISCVPreRAExpandPseudoLegacyPass()