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:
62 bool RenamableSrc)
const {
68 ?
MRI.getRegClass(DestReg)
69 :
MRI.getTargetRegisterInfo()->getMinimalPhysRegClass(DestReg);
78 MachineInstr &
MI,
bool NewMI,
unsigned OpIdx1,
unsigned OpIdx2)
const {
100 if (MFI.isCFGStackified())
103 bool HaveCond =
false;
105 switch (
MI.getOpcode()) {
109 case WebAssembly::BR_IF:
113 Cond.push_back(
MI.getOperand(1));
114 TBB =
MI.getOperand(0).getMBB();
117 case WebAssembly::BR_UNLESS:
121 Cond.push_back(
MI.getOperand(1));
122 TBB =
MI.getOperand(0).getMBB();
125 case WebAssembly::BR:
127 TBB =
MI.getOperand(0).getMBB();
129 FBB =
MI.getOperand(0).getMBB();
140 int *BytesRemoved)
const {
141 assert(!BytesRemoved &&
"code size not handled");
148 if (
I->isDebugInstr())
150 if (!
I->isTerminator())
153 I->eraseFromParent();
164 assert(!BytesAdded &&
"code size not handled");
174 assert(
Cond.size() == 2 &&
"Expected a flag and a successor block");
176 if (
Cond[0].getImm())
189 assert(
Cond.size() == 2 &&
"Expected a flag and a condition expression");
196 static const std::pair<int, const char *> TargetIndices[] = {
228 unsigned Opc =
MI.getOpcode();
231 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
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, bool KillSrc, bool RenamableDest=false, bool RenamableSrc=false) 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)