26#define RISCV_EXPAND_PSEUDO_NAME "RISCV pseudo instruction expansion pass"
27#define RISCV_PRERA_EXPAND_PSEUDO_NAME "RISCV Pre-RA pseudo instruction expansion pass"
64char RISCVExpandPseudo::ID = 0;
79 assert(OldSize >= NewSize);
103 switch (
MBBI->getOpcode()) {
104 case RISCV::PseudoCCMOVGPR:
105 case RISCV::PseudoCCADD:
106 case RISCV::PseudoCCSUB:
107 case RISCV::PseudoCCAND:
108 case RISCV::PseudoCCOR:
109 case RISCV::PseudoCCXOR:
110 case RISCV::PseudoCCADDW:
111 case RISCV::PseudoCCSUBW:
112 return expandCCOp(
MBB,
MBBI, NextMBBI);
113 case RISCV::PseudoVSETVLI:
114 case RISCV::PseudoVSETVLIX0:
115 case RISCV::PseudoVSETIVLI:
116 return expandVSetVL(
MBB,
MBBI);
117 case RISCV::PseudoVMCLR_M_B1:
118 case RISCV::PseudoVMCLR_M_B2:
119 case RISCV::PseudoVMCLR_M_B4:
120 case RISCV::PseudoVMCLR_M_B8:
121 case RISCV::PseudoVMCLR_M_B16:
122 case RISCV::PseudoVMCLR_M_B32:
123 case RISCV::PseudoVMCLR_M_B64:
125 return expandVMSET_VMCLR(
MBB,
MBBI, RISCV::VMXOR_MM);
126 case RISCV::PseudoVMSET_M_B1:
127 case RISCV::PseudoVMSET_M_B2:
128 case RISCV::PseudoVMSET_M_B4:
129 case RISCV::PseudoVMSET_M_B8:
130 case RISCV::PseudoVMSET_M_B16:
131 case RISCV::PseudoVMSET_M_B32:
132 case RISCV::PseudoVMSET_M_B64:
134 return expandVMSET_VMCLR(
MBB,
MBBI, RISCV::VMXNOR_MM);
167 assert(
MI.getOperand(4).getReg() == DestReg);
169 if (
MI.getOpcode() == RISCV::PseudoCCMOVGPR) {
172 .
add(
MI.getOperand(5))
176 switch (
MI.getOpcode()) {
179 case RISCV::PseudoCCADD: NewOpc = RISCV::ADD;
break;
180 case RISCV::PseudoCCSUB: NewOpc = RISCV::SUB;
break;
181 case RISCV::PseudoCCAND: NewOpc = RISCV::AND;
break;
182 case RISCV::PseudoCCOR: NewOpc = RISCV::OR;
break;
183 case RISCV::PseudoCCXOR: NewOpc = RISCV::XOR;
break;
184 case RISCV::PseudoCCADDW: NewOpc = RISCV::ADDW;
break;
185 case RISCV::PseudoCCSUBW: NewOpc = RISCV::SUBW;
break;
188 .
add(
MI.getOperand(5))
189 .
add(
MI.getOperand(6));
201 MI.eraseFromParent();
213 assert(
MBBI->getNumExplicitOperands() == 3 &&
MBBI->getNumOperands() >= 5 &&
214 "Unexpected instruction format");
218 assert((
MBBI->getOpcode() == RISCV::PseudoVSETVLI ||
219 MBBI->getOpcode() == RISCV::PseudoVSETVLIX0 ||
220 MBBI->getOpcode() == RISCV::PseudoVSETIVLI) &&
221 "Unexpected pseudo instruction");
223 if (
MBBI->getOpcode() == RISCV::PseudoVSETIVLI)
224 Opcode = RISCV::VSETIVLI;
226 Opcode = RISCV::VSETVLI;
231 bool DstIsDead =
MBBI->getOperand(0).isDead();
280 unsigned FlagsHi,
unsigned SecondOpcode);
304char RISCVPreRAExpandPseudo::ID = 0;
306bool RISCVPreRAExpandPseudo::runOnMachineFunction(
MachineFunction &MF) {
319 assert(OldSize >= NewSize);
341 switch (
MBBI->getOpcode()) {
342 case RISCV::PseudoLLA:
343 return expandLoadLocalAddress(
MBB,
MBBI, NextMBBI);
344 case RISCV::PseudoLA:
345 return expandLoadAddress(
MBB,
MBBI, NextMBBI);
346 case RISCV::PseudoLA_TLS_IE:
347 return expandLoadTLSIEAddress(
MBB,
MBBI, NextMBBI);
348 case RISCV::PseudoLA_TLS_GD:
349 return expandLoadTLSGDAddress(
MBB,
MBBI, NextMBBI);
354bool RISCVPreRAExpandPseudo::expandAuipcInstPair(
357 unsigned SecondOpcode) {
367 Symbol.setTargetFlags(FlagsHi);
379 if (
MI.hasOneMemOperand())
382 MI.eraseFromParent();
386bool RISCVPreRAExpandPseudo::expandLoadLocalAddress(
393bool RISCVPreRAExpandPseudo::expandLoadAddress(
404 unsigned SecondOpcode = STI.is64Bit() ? RISCV::LD : RISCV::LW;
409bool RISCVPreRAExpandPseudo::expandLoadTLSIEAddress(
415 unsigned SecondOpcode = STI.is64Bit() ? RISCV::LD : RISCV::LW;
420bool RISCVPreRAExpandPseudo::expandLoadTLSGDAddress(
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static Expected< BitVector > expand(StringRef S, StringRef Original)
const HexagonInstrInfo * TII
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
#define RISCV_PRERA_EXPAND_PSEUDO_NAME
#define RISCV_EXPAND_PSEUDO_NAME
riscv prera expand pseudo
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static unsigned getInstSizeInBytes(const MachineInstr &MI, const SystemZInstrInfo *TII)
Represent the analysis usage information of a pass.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
FunctionPass class - This class is used to implement most global optimizations.
A set of physical registers with utility functions to track liveness when walking backward/forward th...
MCSymbol * createNamedTempSymbol()
Create a temporary symbol with a unique name whose name cannot be omitted in the symbol table.
Describe properties that are true of each instruction in the target description file.
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
void transferSuccessors(MachineBasicBlock *FromMBB)
Transfers all the successors from MBB to this machine basic block (i.e., copies all the successors Fr...
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
void eraseFromParent()
This method unlinks 'this' from the containing function and deletes it.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
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...
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
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 LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
void insert(iterator MBBI, MachineBasicBlock *MBB)
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
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
Representation of each machine instruction.
void setPreInstrSymbol(MachineFunction &MF, MCSymbol *Symbol)
Set a symbol that will be emitted just prior to the instruction itself.
void addMemOperand(MachineFunction &MF, MachineMemOperand *MO)
Add a MachineMemOperand to the machine instruction.
MachineOperand class - Representation of each machine instruction operand.
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
Wrapper class representing virtual and physical registers.
StringRef - Represent a constant reference to a string, i.e.
bool isPositionIndependent() const
virtual const TargetInstrInfo * getInstrInfo() const
self_iterator getIterator()
#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.
CondCode getOppositeBranchCondition(CondCode)
@ Define
Register definition.
@ Undef
Value of the register doesn't matter.
This is an optimization pass for GlobalISel generic memory operations.
void initializeRISCVExpandPseudoPass(PassRegistry &)
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
unsigned getDeadRegState(bool B)
void computeAndAddLiveIns(LivePhysRegs &LiveRegs, MachineBasicBlock &MBB)
Convenience function combining computeLiveIns() and addLiveIns().
FunctionPass * createRISCVExpandPseudoPass()
FunctionPass * createRISCVPreRAExpandPseudoPass()
void initializeRISCVPreRAExpandPseudoPass(PassRegistry &)