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,
39 WebAssembly::CATCHRET),
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:
66 ?
MRI.getRegClass(DestReg)
67 :
MRI.getTargetRegisterInfo()->getMinimalPhysRegClass(DestReg);
76 MachineInstr &
MI,
bool NewMI,
unsigned OpIdx1,
unsigned OpIdx2)
const {
98 if (MFI.isCFGStackified())
101 bool HaveCond =
false;
103 switch (
MI.getOpcode()) {
107 case WebAssembly::BR_IF:
111 Cond.push_back(
MI.getOperand(1));
112 TBB =
MI.getOperand(0).getMBB();
115 case WebAssembly::BR_UNLESS:
119 Cond.push_back(
MI.getOperand(1));
120 TBB =
MI.getOperand(0).getMBB();
123 case WebAssembly::BR:
125 TBB =
MI.getOperand(0).getMBB();
127 FBB =
MI.getOperand(0).getMBB();
138 int *BytesRemoved)
const {
139 assert(!BytesRemoved &&
"code size not handled");
146 if (
I->isDebugInstr())
148 if (!
I->isTerminator())
151 I->eraseFromParent();
162 assert(!BytesAdded &&
"code size not handled");
172 assert(
Cond.size() == 2 &&
"Expected a flag and a successor block");
174 if (
Cond[0].getImm())
187 assert(
Cond.size() == 2 &&
"Expected a flag and a condition expression");
194 static const std::pair<int, const char *> TargetIndices[] = {
226 unsigned Opc =
MI.getOpcode();
229 Offset =
MI.explicit_uses().begin()->getImm();
unsigned const MachineRegisterInfo * MRI
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
const SmallVectorImpl< MachineOperand > MachineBasicBlock * TBB
const SmallVectorImpl< MachineOperand > & Cond
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file contains the WebAssembly implementation of the TargetInstrInfo class.
This file provides WebAssembly-specific target descriptions.
This file declares WebAssembly-specific per-machine-function information.
This file declares the WebAssembly-specific subclass of TargetSubtarget.
This file contains the declaration of the WebAssembly-specific utility functions.
This file contains the entry points for global functions defined in the LLVM WebAssembly back-end.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Wrapper class representing physical registers. Should be passed by value.
instr_iterator instr_begin()
Instructions::iterator instr_iterator
instr_iterator instr_end()
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
iterator_range< iterator > terminators()
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
const MachineInstrBuilder & add(const MachineOperand &MO) 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.
MachineOperand class - Representation of each machine instruction operand.
static MachineOperand CreateImm(int64_t Val)
static constexpr bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
virtual bool isReallyTriviallyReMaterializable(const MachineInstr &MI) const
For instructions with opcodes for which the M_REMATERIALIZABLE flag is set, this hook lets the target...
virtual MachineInstr * commuteInstructionImpl(MachineInstr &MI, bool NewMI, unsigned OpIdx1, unsigned OpIdx2) const
This method commutes the operands of the given machine instruction MI.
This class is derived from MachineFunctionInfo and contains private WebAssembly-specific information ...
bool isVRegStackified(unsigned VReg) const
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
WebAssemblyInstrInfo(const WebAssemblySubtarget &STI)
bool isReallyTriviallyReMaterializable(const MachineInstr &MI) const override
const MachineOperand & getCalleeOperand(const MachineInstr &MI) const override
ArrayRef< std::pair< int, const char * > > getSerializableTargetIndices() const override
bool isExplicitTargetIndexDef(const MachineInstr &MI, int &Index, int64_t &Offset) const override
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, bool KillSrc) const override
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
MachineInstr * commuteInstructionImpl(MachineInstr &MI, bool NewMI, unsigned OpIdx1, unsigned OpIdx2) const override
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify=false) const override
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
@ Kill
The last use of a register.
bool isLocalTee(unsigned Opc)
unsigned getCopyOpcodeForRegClass(const TargetRegisterClass *RC)
Returns the appropriate copy opcode for the given register class.
const MachineOperand & getCalleeOp(const MachineInstr &MI)
Returns the operand number of a callee, assuming the argument is a call instruction.
bool isLocalSet(unsigned Opc)
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.
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)