31 #define DEBUG_TYPE "asm-printer" 33 #include "WebAssemblyGenAsmWriter.inc" 41 unsigned RegNo)
const {
63 if (
I != 0 && ((MI->
getOpcode() != WebAssembly::CALL_INDIRECT_VOID &&
64 MI->
getOpcode() != WebAssembly::CALL_INDIRECT_VOID_S) ||
83 case WebAssembly::LOOP_S:
85 ControlFlowStack.
push_back(std::make_pair(ControlFlowCounter++,
true));
88 case WebAssembly::BLOCK:
89 case WebAssembly::BLOCK_S:
90 ControlFlowStack.
push_back(std::make_pair(ControlFlowCounter++,
false));
93 case WebAssembly::TRY:
94 case WebAssembly::TRY_S:
95 ControlFlowStack.
push_back(std::make_pair(ControlFlowCounter++,
false));
96 EHPadStack.
push_back(EHPadStackCounter++);
100 case WebAssembly::END_LOOP:
101 case WebAssembly::END_LOOP_S:
102 if (ControlFlowStack.
empty()) {
110 case WebAssembly::END_BLOCK_S:
111 if (ControlFlowStack.
empty()) {
119 case WebAssembly::END_TRY:
120 case WebAssembly::END_TRY_S:
121 if (ControlFlowStack.
empty()) {
126 LastSeenEHInst = END_TRY;
130 case WebAssembly::CATCH:
131 case WebAssembly::CATCH_S:
132 if (EHPadStack.
empty()) {
145 if (Opc == WebAssembly::RETHROW || Opc == WebAssembly::RETHROW_S) {
146 if (EHPadStack.
empty()) {
157 if (
I < NumFixedOperands) {
170 if (!Printed.
insert(Depth).second)
172 if (Depth >= ControlFlowStack.
size()) {
175 const auto &Pair = ControlFlowStack.
rbegin()[
Depth];
177 (Pair.second ?
"up" :
"down") +
" to label" +
191 return std::string(AI.
isNegative() ?
"-" :
"") +
"nan:0x" +
194 : INT64_C(0x000fffffffffffff)),
199 static const size_t BufBytes = 128;
205 assert(Written < BufBytes);
213 unsigned WAReg = Op.
getReg();
225 }
else if (Op.
isImm()) {
239 assert(Op.
isExpr() &&
"unknown operand kind in printOperand");
245 auto &Sym =
static_cast<const MCSymbolWasm &
>(SRE->getSymbol());
270 O <<
":p2align=" << Imm;
278 auto Imm =
static_cast<unsigned>(Op.
getImm());
282 auto Expr = cast<MCSymbolRefExpr>(Op.
getExpr());
283 auto *Sym = cast<MCSymbolWasm>(&Expr->getSymbol());
284 if (Sym->getSignature()) {
316 return "invalid_type";
326 for (
auto &Ty : List) {
327 if (&Ty != &List[0]) S +=
", ";
32-bit floating-point immediates.
void printWebAssemblySignatureOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
uint64_t getZExtValue() const
Get zero extended value.
void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
This class represents lattice values for constants.
void push_back(const T &Elt)
This class prints an WebAssembly MCInst to wasm file syntax.
Describe properties that are true of each instruction in the target description file.
void printWebAssemblyP2AlignOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
unsigned GetDefaultP2Align(unsigned Opc)
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O)
void printRegName(raw_ostream &OS, unsigned RegNo) const override
Print the assembler register name.
Basic block label in a branch construct.
const char * anyTypeToString(unsigned Ty)
const fltSemantics & getSemantics() const
This file contains the entry points for global functions defined in the LLVM WebAssembly back-end...
WebAssemblyInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)
unsigned getBitWidth() const
Return the number of bits in the APInt.
std::string toString(Error E)
Write all error messages (if any) in E to a string.
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
SmallVector< ValType, 1 > Returns
std::string signatureToString(const wasm::WasmSignature *Sig)
Represent a reference to a symbol from inside an expression.
unsigned getReg() const
Returns the register number.
SmallVector< ValType, 4 > Params
uint8_t OperandType
Information about the type of the operand.
void printBrList(const MCInst *MI, unsigned OpNo, raw_ostream &O)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
const MCExpr * getExpr() const
Analysis containing CSE Info
Instances of this class represent a single low-level machine instruction.
unsigned short NumOperands
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
This class is intended to be used as a base class for asm properties and features specific to the tar...
This file contains the declaration of the WebAssembly-specific utility functions. ...
bool isNegative() const
Determine sign of this APInt.
void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, const MCSubtargetInfo &STI, raw_ostream &OS) override
Print the specified MCInst to the specified raw_ostream.
void print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens=false) const
unsigned const MachineRegisterInfo * MRI
bool isVariadic() const
Return true if this instruction can have a variable number of operands.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
This file provides WebAssembly-specific target descriptions.
std::string typeListToString(ArrayRef< wasm::ValType > List)
Interface to description of machine instruction set.
unsigned getNumOperands() const
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
static const unsigned UnusedReg
const MCOperand & getOperand(unsigned i) const
LLVM_NODISCARD T pop_back_val()
raw_ostream * CommentStream
A stream that comments can be emitted to if desired.
std::string utostr(uint64_t X, bool isNeg=false)
Class for arbitrary precision integers.
64-bit floating-point immediates.
unsigned int convertToHexString(char *DST, unsigned int HexDigits, bool UpperCase, roundingMode RM) const
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
LLVM_NODISCARD bool empty() const
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
This file declares WebAssembly-specific per-machine-function information.
Generic base class for all target subtargets.
reverse_iterator rbegin()
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void printAnnotation(raw_ostream &OS, StringRef Annot)
Utility function for printing annotations.
bool bitwiseIsEqual(const APFloat &RHS) const
const MCOperandInfo * OpInfo
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.
APInt bitcastToAPInt() const
This holds information about one operand of a machine instruction, indicating the register class for ...
unsigned getOpcode() const
const char * typeToString(wasm::ValType Ty)
Instances of this class represent operands of the MCInst class.
static APFloat getQNaN(const fltSemantics &Sem, bool Negative=false, const APInt *payload=nullptr)
Factory for QNaN values.
std::string utohexstr(uint64_t X, bool LowerCase=false)
static unsigned getWARegStackId(unsigned Reg)