31 #define DEBUG_TYPE "asm-printer"
33 #include "WebAssemblyGenAsmWriter.inc"
41 unsigned RegNo)
const {
61 (MI->
getOpcode() != WebAssembly::CALL_INDIRECT_VOID ||
76 case WebAssembly::LOOP: {
78 ControlFlowStack.
push_back(std::make_pair(ControlFlowCounter++,
true));
81 case WebAssembly::BLOCK:
82 ControlFlowStack.
push_back(std::make_pair(ControlFlowCounter++,
false));
84 case WebAssembly::END_LOOP:
97 if (!(
i < NumFixedOperands
103 if (!Printed.
insert(Depth).second)
105 const auto &Pair = ControlFlowStack.
rbegin()[
Depth];
107 " to label" +
utostr(Pair.first));
120 std::string(AI.
isNegative() ?
"-" :
"") +
"nan:0x" +
123 INT64_C(0x000fffffffffffff)),
128 static const size_t BufBytes = 128;
134 assert(Written < BufBytes);
144 "WebAssembly variable_ops register ops don't use TSFlags");
145 unsigned WAReg = Op.
getReg();
157 }
else if (Op.
isImm()) {
161 "WebAssemblyII::VariableOpIsImmediate should be set for "
162 "variable_ops immediate ops");
172 "Unexpected floating-point immediate as a non-fixed operand");
174 "WebAssembly variable_ops floating point ops don't use TSFlags");
188 "WebAssemblyII::VariableOpIsImmediate should be set for "
189 "variable_ops expr ops");
190 assert(Op.
isExpr() &&
"unknown operand kind in printOperand");
202 O <<
":p2align=" << Imm;
32-bit floating-point immediates.
void printWebAssemblySignatureOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void push_back(const T &Elt)
void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
const char * TypeToString(MVT Ty)
uint64_t getZExtValue() const
Get zero extended value.
This class prints an WebAssembly MCInst to wasm file syntax.
Describe properties that are true of each instruction in the target description file.
MachineInstrBuilder MachineInstrBuilder &DefMI const MCInstrDesc & Desc
void printWebAssemblyP2AlignOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printRegName(raw_ostream &OS, unsigned RegNo) const override
Print the assembler register name.
Basic block label in a branch construct.
bool isVariadic() const
Return true if this instruction can have a variable number of operands.
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)
bool isNegative() const
Determine sign of this APInt.
std::string toString(Error E)
Write all error messages (if any) in E to a string.
APInt bitcastToAPInt() const
ExprType
This is used to indicate block signatures.
uint8_t OperandType
Information about the type of the operand.
unsigned getReg() const
Returns the register number.
static std::string utostr(uint64_t X, bool isNeg=false)
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...
const MCExpr * getExpr() const
unsigned const MachineRegisterInfo * MRI
MVT - Machine Value Type.
bool bitwiseIsEqual(const APFloat &RHS) const
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.
Interface to description of machine instruction set.
unsigned getBitWidth() const
Return the number of bits in the APInt.
unsigned GetDefaultP2Align(unsigned Opcode)
Return the default p2align value for a load or store with the given opcode.
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
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
void printInst(const MCInst *MI, raw_ostream &OS, StringRef Annot, const MCSubtargetInfo &STI) override
Print the specified MCInst to the specified raw_ostream.
LLVM_NODISCARD T pop_back_val()
raw_ostream * CommentStream
A stream that comments can be emitted to if desired.
unsigned getOpcode() const
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...
unsigned getNumOperands() const
This file declares WebAssembly-specific per-machine-function information.
MCSubtargetInfo - Generic base class for all target subtargets.
void printInstruction(const MCInst *MI, raw_ostream &O)
static std::string utohexstr(uint64_t X, bool LowerCase=false)
void print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens=false) const
reverse_iterator rbegin()
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void printAnnotation(raw_ostream &OS, StringRef Annot)
Utility function for printing annotations.
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
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.
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.
const fltSemantics & getSemantics() const
static APFloat getQNaN(const fltSemantics &Sem, bool Negative=false, const APInt *payload=nullptr)
Factory for QNaN values.
const MCOperand & getOperand(unsigned i) const
static unsigned getWARegStackId(unsigned Reg)