34 #define GET_INSTRMAP_INFO 1 35 #include "WebAssemblyGenInstrInfo.inc" 41 cl::desc(
"WebAssembly: output stack registers in" 42 " instruction output for test purposes only."),
48 WebAssemblyMCInstLower::GetGlobalAddressSymbol(
const MachineOperand &MO)
const {
50 auto *WasmSym = cast<MCSymbolWasm>(Printer.
getSymbol(Global));
52 if (
const auto *FuncTy = dyn_cast<FunctionType>(Global->
getValueType())) {
62 WasmSym->setSignature(Signature.get());
70 MCSymbol *WebAssemblyMCInstLower::GetExternalSymbolSymbol(
80 if (strcmp(Name,
"__stack_pointer") == 0 || strcmp(Name,
"__tls_base") == 0 ||
81 strcmp(Name,
"__memory_base") == 0 || strcmp(Name,
"__table_base") == 0 ||
82 strcmp(Name,
"__tls_size") == 0 || strcmp(Name,
"__tls_align") == 0) {
84 strcmp(Name,
"__stack_pointer") == 0 || strcmp(Name,
"__tls_base") == 0;
95 if (strcmp(Name,
"__cpp_exception") == 0) {
99 WasmSym->setEventType(
104 WasmSym->setWeak(
true);
105 WasmSym->setExternal(
true);
118 std::make_unique<wasm::WasmSignature>(std::move(Returns), std::move(Params));
119 WasmSym->setSignature(Signature.get());
130 switch (TargetFlags) {
149 const auto *WasmSym = cast<MCSymbolWasm>(Sym);
152 if (WasmSym->isFunction())
154 if (WasmSym->isGlobal())
156 if (WasmSym->isEvent())
166 MCOperand WebAssemblyMCInstLower::lowerTypeIndexOperand(
169 auto Signature = std::make_unique<wasm::WasmSignature>(std::move(Returns),
172 auto *WasmSym = cast<MCSymbolWasm>(Sym);
173 WasmSym->setSignature(Signature.get());
183 if (RC == &WebAssembly::I32RegClass)
185 if (RC == &WebAssembly::I64RegClass)
187 if (RC == &WebAssembly::F32RegClass)
189 if (RC == &WebAssembly::F64RegClass)
191 if (RC == &WebAssembly::V128RegClass)
254 if (MI->
getOpcode() == WebAssembly::RET_CALL_INDIRECT)
257 MCOp = lowerTypeIndexOperand(std::move(Returns), std::move(Params));
265 MCOp = lowerTypeIndexOperand(std::move(Returns),
286 MCOp = lowerSymbolOperand(MO, GetGlobalAddressSymbol(MO));
292 "WebAssembly uses only symbol flags on ExternalSymbols");
293 MCOp = lowerSymbolOperand(MO, GetExternalSymbolSymbol(MO));
299 "WebAssembly does not use target flags on MCSymbol");
330 auto StackOpcode = WebAssembly::getStackOpcode(RegOpcode);
331 assert(StackOpcode != -1 &&
"Failed to stackify instruction");
unsigned getTargetFlags() const
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
bool isLabel() const
Returns true if the MachineInstr represents a label.
MCSymbol * GetExternalSymbolSymbol(StringRef Sym) const
Return the MCSymbol for the specified ExternalSymbol.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
const MachineFunction * getMF() const
Return the function that contains the basic block that this instruction belongs to.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
static MCOperand createExpr(const MCExpr *Val)
void push_back(const T &Elt)
Describe properties that are true of each instruction in the target description file.
This file declares the class to lower WebAssembly MachineInstrs to their corresponding MCInst records...
float convertToFloat() const
MachineBasicBlock reference.
void computeSignatureVTs(const FunctionType *Ty, const Function &F, const TargetMachine &TM, SmallVectorImpl< MVT > &Params, SmallVectorImpl< MVT > &Results)
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))
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
static void getFunctionReturns(const MachineInstr *MI, SmallVectorImpl< wasm::ValType > &Returns)
signature immediate for block/loop.
std::unique_ptr< wasm::WasmSignature > signatureFromMVTs(const SmallVectorImpl< MVT > &Results, const SmallVectorImpl< MVT > &Params)
static MCOperand createReg(unsigned Reg)
const ConstantFP * getFPImm() const
unsigned getNumOperands() const
Retuns the total number of operands.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Base class for the full range of assembler expressions which are needed for parsing.
Name of external global symbol.
static void removeRegisterOperands(const MachineInstr *MI, MCInst &OutMI)
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const char * getSymbolName() const
uint8_t OperandType
Information about the type of the operand.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
Type * getType() const
All values are typed, get the type of this value.
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Analysis containing CSE Info
Instances of this class represent a single low-level machine instruction.
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false)
unsigned short NumOperands
void getLibcallSignature(const WebAssemblySubtarget &Subtarget, RTLIB::Libcall LC, SmallVectorImpl< wasm::ValType > &Rets, SmallVectorImpl< wasm::ValType > &Params)
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
Address of a global value.
initializer< Ty > init(const Ty &Val)
Type * getReturnType() const
Returns the type of the ret val.
unsigned const MachineRegisterInfo * MRI
The instances of the Type class are immutable: once they are created, they are never changed...
This file provides signature information for runtime libcalls.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
const WebAssemblySubtarget & getSubtarget() const
This file contains the declarations for the subclasses of Constant, which represent the different fla...
const GlobalValue * getGlobal() const
ConstantFP - Floating Point Values [float, double].
This file provides WebAssembly-specific target descriptions.
double convertToDouble() const
iterator_range< mop_iterator > defs()
Returns a range over all explicit operands that are register definitions.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
unsigned getNumOperands() const
void print(raw_ostream &OS, bool IsStandalone=true, bool SkipOpers=false, bool SkipDebugLoc=false, bool AddNewLine=true, const TargetInstrInfo *TII=nullptr) const
Print this MI to OS.
type signature immediate for call_indirect.
static wasm::ValType getType(const TargetRegisterClass *RC)
bool isDebugInstr() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
iterator_range< mop_iterator > explicit_uses()
void addSignature(std::unique_ptr< wasm::WasmSignature > &&Sig)
const APFloat & getValueAPF() const
void setOpcode(unsigned Op)
MCSymbol * getSymbol(const GlobalValue *GV) const
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
const MCOperand & getOperand(unsigned i) const
static MCOperand createFPImm(double Val)
const Function & getFunction() const
Return the LLVM function that this machine code represents.
MCSymbol reference (for debug/eh info)
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Representation of each machine instruction.
This class is derived from MachineFunctionInfo and contains private WebAssembly-specific information ...
bool isCallIndirect(unsigned Opc)
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
int64_t getOffset() const
Return the offset from the symbol in this operand.
BlockType
Used as immediate MachineOperands for block signatures.
This file declares WebAssembly-specific per-machine-function information.
Type * getValueType() const
unsigned getWAReg(unsigned VReg) const
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
bool isReg() const
isReg - Tests if this is a MO_Register operand.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void valTypesFromMVTs(const ArrayRef< MVT > &In, SmallVectorImpl< wasm::ValType > &Out)
MCSymbol * getMCSymbol() const
void computeLegalValueVTs(const Function &F, const TargetMachine &TM, Type *Ty, SmallVectorImpl< MVT > &ValueVTs)
Floating-point immediate operand.
void lower(const MachineInstr *MI, MCInst &OutMI) const
const MCOperandInfo * OpInfo
Primary interface to the complete machine description for the target machine.
void addOperand(const MCOperand &Op)
Register getReg() const
getReg - Returns the register number.
This holds information about one operand of a machine instruction, indicating the register class for ...
unsigned getOpcode() const
const MachineOperand & getOperand(unsigned i) const
Instances of this class represent operands of the MCInst class.
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
MCSymbol * createTempSymbol(const Twine &Name) const
static MCOperand createImm(int64_t Val)