Go to the documentation of this file.
39 cl::desc(
"WebAssembly: output stack registers in"
40 " instruction output for test purposes only."),
46 WebAssemblyMCInstLower::GetGlobalAddressSymbol(
const MachineOperand &MO)
const {
48 if (!isa<Function>(Global)) {
49 auto *WasmSym = cast<MCSymbolWasm>(Printer.
getSymbol(Global));
54 !WasmSym->getType()) {
67 const auto *FuncTy = cast<FunctionType>(
Global->getValueType());
74 const auto *
const F = dyn_cast<Function>(Global);
78 bool InvokeDetected =
false;
81 Signature.get(), InvokeDetected);
88 MCSymbol *WebAssemblyMCInstLower::GetExternalSymbolSymbol(
98 switch (TargetFlags) {
123 const auto *WasmSym = cast<MCSymbolWasm>(Sym);
126 if (WasmSym->isFunction())
128 if (WasmSym->isGlobal())
130 if (WasmSym->isTag())
132 if (WasmSym->isTable())
142 MCOperand WebAssemblyMCInstLower::lowerTypeIndexOperand(
145 auto Signature = std::make_unique<wasm::WasmSignature>(
std::move(Returns),
148 auto *WasmSym = cast<MCSymbolWasm>(Sym);
149 WasmSym->setSignature(Signature.get());
159 if (RC == &WebAssembly::I32RegClass)
161 if (RC == &WebAssembly::I64RegClass)
163 if (RC == &WebAssembly::F32RegClass)
165 if (RC == &WebAssembly::F64RegClass)
167 if (RC == &WebAssembly::V128RegClass)
169 if (RC == &WebAssembly::EXTERNREFRegClass)
171 if (RC == &WebAssembly::FUNCREFRegClass)
180 Type *RetTy =
F.getReturnType();
191 unsigned NumVariadicDefs =
MI->getNumExplicitDefs() - Desc.
getNumDefs();
192 for (
unsigned I = 0,
E =
MI->getNumOperands();
I !=
E; ++
I) {
214 unsigned DescIndex =
I - NumVariadicDefs;
222 MI->getParent()->getParent()->getRegInfo();
236 if (
MI->getOpcode() == WebAssembly::RET_CALL_INDIRECT)
247 MCOp = lowerTypeIndexOperand(
std::move(Returns),
269 MCOp = lowerSymbolOperand(MO, GetGlobalAddressSymbol(MO));
272 MCOp = lowerSymbolOperand(MO, GetExternalSymbolSymbol(MO));
276 "WebAssembly does not use target flags on MCSymbol");
304 if (
MI->isDebugInstr() ||
MI->isLabel() ||
MI->isInlineAsm())
310 assert(StackOpcode != -1 &&
"Failed to stackify instruction");
unsigned getNumDefs() const
Return the number of MachineOperands that are register definitions.
@ MO_Immediate
Immediate operand.
This is an optimization pass for GlobalISel generic memory operations.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
static MCOperand createExpr(const MCExpr *Val)
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
const GlobalValue * getGlobal() const
MCSymbol * createTempSymbol(const Twine &Name) const
static MCOperand createImm(int64_t Val)
iterator insert(iterator I, const MCOperand &Op)
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
std::unique_ptr< wasm::WasmSignature > signatureFromMVTs(const SmallVectorImpl< MVT > &Results, const SmallVectorImpl< MVT > &Params)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
The instances of the Type class are immutable: once they are created, they are never changed.
const APFloat & getValueAPF() const
@ OPERAND_SIGNATURE
signature immediate for block/loop.
void wasmSymbolSetType(MCSymbolWasm *Sym, const Type *GlobalVT, const SmallVector< MVT, 1 > &VTs)
Sets a Wasm Symbol Type.
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
void setSignature(wasm::WasmSignature *Sig)
Instances of this class represent a single low-level machine instruction.
static wasm::ValType getType(const TargetRegisterClass *RC)
MCSymbol * getOrCreateWasmSymbol(StringRef Name)
int64_t getOffset() const
Return the offset from the symbol in this operand.
unsigned getNumOperands() const
static void removeRegisterOperands(const MachineInstr *MI, MCInst &OutMI)
MCSymbol * getMCSymbol() const
@ MO_Register
Register operand.
void setOpcode(unsigned Op)
This holds information about one operand of a machine instruction, indicating the register class for ...
void lower(const MachineInstr *MI, MCInst &OutMI) const
@ MO_GlobalAddress
Address of a global value.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static void getFunctionReturns(const MachineInstr *MI, SmallVectorImpl< wasm::ValType > &Returns)
void addSignature(std::unique_ptr< wasm::WasmSignature > &&Sig)
cl::opt< bool > WasmEnableEmSjLj
Describe properties that are true of each instruction in the target description file.
MachineOperand class - Representation of each machine instruction operand.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
uint64_t getZExtValue() const
Get zero extended value.
ConstantFP - Floating Point Values [float, double].
@ WASM_SYMBOL_TYPE_FUNCTION
Analysis containing CSE Info
APInt bitcastToAPInt() const
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
void addOperand(const MCOperand Op)
virtual void print(raw_ostream &OS, const Module *M) const
print - Print out the internal state of the pass.
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
unsigned short NumOperands
unsigned getTargetFlags() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Representation of each machine instruction.
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
void valTypesFromMVTs(const ArrayRef< MVT > &In, SmallVectorImpl< wasm::ValType > &Out)
cl::opt< bool > WasmKeepRegisters("wasm-keep-registers", cl::Hidden, cl::desc("WebAssembly: output stack registers in" " instruction output for test purposes only."), cl::init(false))
@ MO_MCSymbol
MCSymbol reference (for debug/eh info)
initializer< Ty > init(const Ty &Val)
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
unsigned getWAReg(unsigned VReg) const
const ConstantFP * getFPImm() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MCSymbol * getSymbol(const GlobalValue *GV) const
Primary interface to the complete machine description for the target machine.
bool isCallIndirect(unsigned Opc)
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
const MCOperandInfo * OpInfo
@ MO_FPImmediate
Floating-point immediate operand.
This class is derived from MachineFunctionInfo and contains private WebAssembly-specific information ...
Register getReg() const
getReg - Returns the register number.
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
void computeLegalValueVTs(const WebAssemblyTargetLowering &TLI, LLVMContext &Ctx, const DataLayout &DL, Type *Ty, SmallVectorImpl< MVT > &ValueVTs)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Type * getType() const
All values are typed, get the type of this value.
static MCOperand createReg(unsigned Reg)
@ MO_MachineBasicBlock
MachineBasicBlock reference.
bool variadicOpsAreDefs() const
Return true if variadic operands of this instruction are definitions.
const MachineBasicBlock * getParent() const
static MCOperand createSFPImm(uint32_t Val)
@ OPERAND_TYPEINDEX
type signature immediate for call_indirect.
static MCOperand createDFPImm(uint64_t Val)
unsigned const MachineRegisterInfo * MRI
void computeSignatureVTs(const FunctionType *Ty, const Function *TargetFunc, const Function &ContextFunc, const TargetMachine &TM, SmallVectorImpl< MVT > &Params, SmallVectorImpl< MVT > &Results)
Function & getFunction()
Return the LLVM function that this machine code represents.
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
@ MO_ExternalSymbol
Name of external global symbol.
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
unsigned getOpcode() const
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
MCSymbolWasm * getMCSymbolForFunction(const Function *F, bool EnableEmEH, wasm::WasmSignature *Sig, bool &InvokeDetected)
const char * getSymbolName() const
bool isWasmVarAddressSpace(unsigned AS)
const MCOperand & getOperand(unsigned i) const
BlockType
Used as immediate MachineOperands for block signatures.
const char LLVMTargetMachineRef TM
Instances of this class represent operands of the MCInst class.
Base class for the full range of assembler expressions which are needed for parsing.
cl::opt< bool > WasmEnableEmEH
int getStackOpcode(unsigned short Opcode)