Go to the documentation of this file.
27 #define DEBUG_TYPE "wasm-instr-info"
29 #define GET_INSTRINFO_CTOR_DTOR
30 #include "WebAssemblyGenInstrInfo.inc"
33 #define GET_INSTRINFO_NAMED_OPS
34 #include "WebAssemblyGenInstrInfo.inc"
38 WebAssembly::ADJCALLSTACKUP,
40 RI(STI.getTargetTriple()) {}
44 switch (
MI.getOpcode()) {
45 case WebAssembly::CONST_I32:
46 case WebAssembly::CONST_I64:
47 case WebAssembly::CONST_F32:
48 case WebAssembly::CONST_F64:
70 if (RC == &WebAssembly::I32RegClass)
71 CopyOpcode = WebAssembly::COPY_I32;
72 else if (RC == &WebAssembly::I64RegClass)
73 CopyOpcode = WebAssembly::COPY_I64;
74 else if (RC == &WebAssembly::F32RegClass)
75 CopyOpcode = WebAssembly::COPY_F32;
76 else if (RC == &WebAssembly::F64RegClass)
77 CopyOpcode = WebAssembly::COPY_F64;
78 else if (RC == &WebAssembly::V128RegClass)
79 CopyOpcode = WebAssembly::COPY_V128;
80 else if (RC == &WebAssembly::FUNCREFRegClass)
81 CopyOpcode = WebAssembly::COPY_FUNCREF;
82 else if (RC == &WebAssembly::EXTERNREFRegClass)
83 CopyOpcode = WebAssembly::COPY_EXTERNREF;
92 MachineInstr &
MI,
bool NewMI,
unsigned OpIdx1,
unsigned OpIdx2)
const {
114 if (MFI.isCFGStackified())
117 bool HaveCond =
false;
119 switch (
MI.getOpcode()) {
123 case WebAssembly::BR_IF:
127 Cond.push_back(
MI.getOperand(1));
128 TBB =
MI.getOperand(0).getMBB();
131 case WebAssembly::BR_UNLESS:
135 Cond.push_back(
MI.getOperand(1));
136 TBB =
MI.getOperand(0).getMBB();
141 TBB =
MI.getOperand(0).getMBB();
143 FBB =
MI.getOperand(0).getMBB();
154 int *BytesRemoved)
const {
155 assert(!BytesRemoved &&
"code size not handled");
162 if (
I->isDebugInstr())
164 if (!
I->isTerminator())
167 I->eraseFromParent();
178 assert(!BytesAdded &&
"code size not handled");
188 assert(
Cond.size() == 2 &&
"Expected a flag and a successor block");
190 if (
Cond[0].getImm())
203 assert(
Cond.size() == 2 &&
"Expected a flag and a condition expression");
210 static const std::pair<int, const char *> TargetIndices[] = {
WebAssemblyInstrInfo(const WebAssemblySubtarget &STI)
const MachineOperand & getCalleeOp(const MachineInstr &MI)
Returns the operand number of a callee, assuming the argument is a call instruction.
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
This is an optimization pass for GlobalISel generic memory operations.
const MachineInstrBuilder & add(const MachineOperand &MO) const
MachineInstr * commuteInstructionImpl(MachineInstr &MI, bool NewMI, unsigned OpIdx1, unsigned OpIdx2) const override
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, bool KillSrc) const override
const TargetRegisterInfo * getTargetRegisterInfo() const
iterator_range< iterator > terminators()
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
virtual MachineInstr * commuteInstructionImpl(MachineInstr &MI, bool NewMI, unsigned OpIdx1, unsigned OpIdx2) const
This method commutes the operands of the given machine instruction MI.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
static MachineOperand CreateImm(int64_t Val)
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
@ CATCHRET
CATCHRET - Represents a return from a catch block funclet.
MachineOperand class - Representation of each machine instruction operand.
bool isReallyTriviallyReMaterializable(const MachineInstr &MI, AAResults *AA) const override
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
Representation of each machine instruction.
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
bool isVRegStackified(unsigned VReg) const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
This class is derived from MachineFunctionInfo and contains private WebAssembly-specific information ...
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineOperand & getCalleeOperand(const MachineInstr &MI) const override
instr_iterator instr_begin()
instr_iterator instr_end()
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
SmallVector< MachineOperand, 4 > Cond
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify=false) const override
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
ArrayRef< std::pair< int, const char * > > getSerializableTargetIndices() const override
unsigned const MachineRegisterInfo * MRI
Should compile to something r4 addze r3 instead we get
@ BR
Control flow instructions. These all have token chains.
Iterator for intrusive lists based on ilist_node.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
const TargetRegisterClass * getMinimalPhysRegClass(MCRegister Reg, MVT VT=MVT::Other) const
Returns the Register Class of a physical register of the given type, picking the most sub register cl...
@ Kill
The last use of a register.
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
Wrapper class representing physical registers. Should be passed by value.