26 #define DEBUG_TYPE "wasm-instr-info" 28 #define GET_INSTRINFO_CTOR_DTOR 29 #include "WebAssemblyGenInstrInfo.inc" 33 WebAssembly::ADJCALLSTACKUP,
35 RI(STI.getTargetTriple()) {}
40 case WebAssembly::CONST_I32:
41 case WebAssembly::CONST_I64:
42 case WebAssembly::CONST_F32:
43 case WebAssembly::CONST_F64:
54 const DebugLoc &DL,
unsigned DestReg,
55 unsigned SrcReg,
bool KillSrc)
const {
61 ?
MRI.getRegClass(DestReg)
62 :
MRI.getTargetRegisterInfo()->getMinimalPhysRegClass(DestReg);
65 if (RC == &WebAssembly::I32RegClass)
66 CopyOpcode = WebAssembly::COPY_I32;
67 else if (RC == &WebAssembly::I64RegClass)
68 CopyOpcode = WebAssembly::COPY_I64;
69 else if (RC == &WebAssembly::F32RegClass)
70 CopyOpcode = WebAssembly::COPY_F32;
71 else if (RC == &WebAssembly::F64RegClass)
72 CopyOpcode = WebAssembly::COPY_F64;
73 else if (RC == &WebAssembly::V128RegClass)
74 CopyOpcode = WebAssembly::COPY_V128;
78 BuildMI(MBB, I, DL,
get(CopyOpcode), DestReg)
83 MachineInstr &
MI,
bool NewMI,
unsigned OpIdx1,
unsigned OpIdx2)
const {
101 bool HaveCond =
false;
103 switch (
MI.getOpcode()) {
107 case WebAssembly::BR_IF:
111 if (!
MI.getOperand(0).isMBB())
115 TBB =
MI.getOperand(0).getMBB();
118 case WebAssembly::BR_UNLESS:
122 if (!
MI.getOperand(0).isMBB())
126 TBB =
MI.getOperand(0).getMBB();
131 if (!
MI.getOperand(0).isMBB())
134 TBB =
MI.getOperand(0).getMBB();
136 FBB =
MI.getOperand(0).getMBB();
147 int *BytesRemoved)
const {
148 assert(!BytesRemoved &&
"code size not handled");
155 if (I->isDebugInstr())
157 if (!I->isTerminator())
160 I->eraseFromParent();
171 assert(!BytesAdded &&
"code size not handled");
181 assert(Cond.
size() == 2 &&
"Expected a flag and a successor block");
183 if (Cond[0].getImm()) {
197 assert(Cond.
size() == 2 &&
"Expected a flag and a successor block");
const MachineInstrBuilder & add(const MachineOperand &MO) const
instr_iterator instr_begin()
instr_iterator instr_end()
This class represents lattice values for constants.
bool isReallyTriviallyReMaterializable(const MachineInstr &MI, AliasAnalysis *AA) const override
void push_back(const T &Elt)
unsigned getReg() const
getReg - Returns the register number.
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
MachineInstr * commuteInstructionImpl(MachineInstr &MI, bool NewMI, unsigned OpIdx1, unsigned OpIdx2) const override
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
iterator_range< iterator > terminators()
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, bool KillSrc) const override
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
bool isVRegStackified(unsigned VReg) const
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
virtual MachineInstr * commuteInstructionImpl(MachineInstr &MI, bool NewMI, unsigned OpIdx1, unsigned OpIdx2) const
This method commutes the operands of the given machine instruction MI.
Control flow instructions. These all have token chains.
unsigned const MachineRegisterInfo * MRI
size_t size() const
size - Get the array size.
This file provides WebAssembly-specific target descriptions.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
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.
This file declares the WebAssembly-specific subclass of TargetSubtarget.
Iterator for intrusive lists based on ilist_node.
This file contains the WebAssembly implementation of the TargetInstrInfo class.
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
CATCHRET - Represents a return from a catch block funclet.
const MachineBasicBlock * getParent() const
Representation of each machine instruction.
This class is derived from MachineFunctionInfo and contains private WebAssembly-specific information ...
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
WebAssemblyInstrInfo(const WebAssemblySubtarget &STI)
static MachineOperand CreateImm(int64_t Val)
This file declares WebAssembly-specific per-machine-function information.
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0) const
const MachineOperand & getOperand(unsigned i) const
bool empty() const
empty - Check if the array is empty.