39 cl::desc(
"WebAssembly: output stack registers in"
40 " instruction output for test purposes only."),
46WebAssemblyMCInstLower::GetGlobalAddressSymbol(
const MachineOperand &MO)
const {
48 if (!isa<Function>(
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);
88MCSymbol *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())
142MCOperand WebAssemblyMCInstLower::lowerTypeIndexOperand(
145 auto Signature = std::make_unique<wasm::WasmSignature>(std::move(Returns),
148 auto *WasmSym = cast<MCSymbolWasm>(
Sym);
149 WasmSym->setSignature(Signature.get());
172 unsigned NumVariadicDefs =
MI->getNumExplicitDefs() - Desc.
getNumDefs();
173 for (
unsigned I = 0,
E =
MI->getNumOperands();
I !=
E; ++
I) {
195 unsigned DescIndex =
I - NumVariadicDefs;
203 MI->getParent()->getParent()->getRegInfo();
219 if (
MI->getOpcode() == WebAssembly::RET_CALL_INDIRECT)
222 MCOp = lowerTypeIndexOperand(std::move(Returns), std::move(Params));
230 MCOp = lowerTypeIndexOperand(std::move(Returns),
242 Imm->getValueAPF().bitcastToAPInt().getZExtValue();
243 if (Imm->getType()->isFloatTy())
245 else if (Imm->getType()->isDoubleTy())
252 MCOp = lowerSymbolOperand(MO, GetGlobalAddressSymbol(MO));
255 MCOp = lowerSymbolOperand(MO, GetExternalSymbolSymbol(MO));
259 "WebAssembly does not use target flags on MCSymbol");
287 if (
MI->isDebugInstr() ||
MI->isLabel() ||
MI->isInlineAsm())
293 assert(StackOpcode != -1 &&
"Failed to stackify instruction");
unsigned const MachineRegisterInfo * MRI
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Analysis containing CSE Info
This file contains the declarations for the subclasses of Constant, which represent the different fla...
const char LLVMTargetMachineRef TM
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
cl::opt< bool > WasmKeepRegisters
This file defines the interfaces that WebAssembly uses to lower LLVM code into a selection DAG.
static void removeRegisterOperands(const MachineInstr *MI, MCInst &OutMI)
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))
static void getFunctionReturns(const MachineInstr *MI, SmallVectorImpl< wasm::ValType > &Returns)
This file declares the class to lower WebAssembly MachineInstrs to their corresponding MCInst records...
This file declares WebAssembly-specific per-machine-function information.
This file registers the WebAssembly target.
This file contains the declaration of the WebAssembly-specific type parsing utility functions.
This file contains the declaration of the WebAssembly-specific utility functions.
MCSymbol * getSymbol(const GlobalValue *GV) const
MCSymbol * createTempSymbol(const Twine &Name) const
ConstantFP - Floating Point Values [float, double].
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Base class for the full range of assembler expressions which are needed for parsing.
Instances of this class represent a single low-level machine instruction.
unsigned getNumOperands() const
unsigned getOpcode() const
iterator insert(iterator I, const MCOperand &Op)
void addOperand(const MCOperand Op)
void setOpcode(unsigned Op)
const MCOperand & getOperand(unsigned i) const
Describe properties that are true of each instruction in the target description file.
ArrayRef< MCOperandInfo > operands() const
unsigned getNumDefs() const
Return the number of MachineOperands that are register definitions.
unsigned short NumOperands
bool variadicOpsAreDefs() const
Return true if variadic operands of this instruction are definitions.
This holds information about one operand of a machine instruction, indicating the register class for ...
Instances of this class represent operands of the MCInst class.
static MCOperand createReg(unsigned Reg)
static MCOperand createExpr(const MCExpr *Val)
static MCOperand createSFPImm(uint32_t Val)
static MCOperand createImm(int64_t Val)
static MCOperand createDFPImm(uint64_t Val)
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
void setSignature(wasm::WasmSignature *Sig)
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
Function & getFunction()
Return the LLVM function that this machine code represents.
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
Representation of each machine instruction.
const MachineBasicBlock * getParent() const
MachineOperand class - Representation of each machine instruction operand.
const GlobalValue * getGlobal() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
unsigned getTargetFlags() const
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
const char * getSymbolName() const
Register getReg() const
getReg - Returns the register number.
const ConstantFP * getFPImm() const
MCSymbol * getMCSymbol() const
@ MO_Immediate
Immediate operand.
@ MO_MCSymbol
MCSymbol reference (for debug/eh info)
@ MO_GlobalAddress
Address of a global value.
@ MO_MachineBasicBlock
MachineBasicBlock reference.
@ MO_Register
Register operand.
@ MO_ExternalSymbol
Name of external global symbol.
@ MO_FPImmediate
Floating-point immediate operand.
int64_t getOffset() const
Return the offset from the symbol in this operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
virtual void print(raw_ostream &OS, const Module *M) const
print - Print out the internal state of the pass.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Primary interface to the complete machine description for the target machine.
The instances of the Type class are immutable: once they are created, they are never changed.
MCSymbol * getOrCreateWasmSymbol(StringRef Name)
MCSymbolWasm * getMCSymbolForFunction(const Function *F, bool EnableEmEH, wasm::WasmSignature *Sig, bool &InvokeDetected)
void addSignature(std::unique_ptr< wasm::WasmSignature > &&Sig)
This class is derived from MachineFunctionInfo and contains private WebAssembly-specific information ...
unsigned getWAReg(unsigned VReg) const
void lower(const MachineInstr *MI, MCInst &OutMI) const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool isCallIndirect(unsigned Opc)
wasm::ValType regClassToValType(unsigned RC)
cl::opt< bool > WasmEnableEmEH
BlockType
Used as immediate MachineOperands for block signatures.
@ OPERAND_TYPEINDEX
type signature immediate for call_indirect.
@ OPERAND_SIGNATURE
signature immediate for block/loop.
cl::opt< bool > WasmEnableEmSjLj
void wasmSymbolSetType(MCSymbolWasm *Sym, const Type *GlobalVT, const ArrayRef< MVT > &VTs)
Sets a Wasm Symbol Type.
int getStackOpcode(unsigned short Opcode)
bool isWasmVarAddressSpace(unsigned AS)
initializer< Ty > init(const Ty &Val)
@ WASM_SYMBOL_TYPE_FUNCTION
This is an optimization pass for GlobalISel generic memory operations.
void computeSignatureVTs(const FunctionType *Ty, const Function *TargetFunc, const Function &ContextFunc, const TargetMachine &TM, SmallVectorImpl< MVT > &Params, SmallVectorImpl< MVT > &Results)
void valTypesFromMVTs(const ArrayRef< MVT > &In, SmallVectorImpl< wasm::ValType > &Out)
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
std::unique_ptr< wasm::WasmSignature > signatureFromMVTs(const SmallVectorImpl< MVT > &Results, const SmallVectorImpl< MVT > &Params)
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
@ Global
Append to llvm.global_dtors.
void computeLegalValueVTs(const WebAssemblyTargetLowering &TLI, LLVMContext &Ctx, const DataLayout &DL, Type *Ty, SmallVectorImpl< MVT > &ValueVTs)