33 #define DEBUG_TYPE "mccodeemitter" 35 STATISTIC(MCNumEmitted,
"Number of MC instructions emitted.");
36 STATISTIC(MCNumFixups,
"Number of MC fixups created.");
43 uint64_t getBinaryCodeForInstr(
const MCInst &
MI,
52 WebAssemblyMCCodeEmitter(
const MCInstrInfo &mcii) : MCII(mcii) {}
57 return new WebAssemblyMCCodeEmitter(MCII);
60 void WebAssemblyMCCodeEmitter::encodeInstruction(
63 uint64_t Start = OS.
tell();
65 uint64_t Binary = getBinaryCodeForInstr(MI, Fixups, STI);
66 if (Binary <= UINT8_MAX) {
67 OS << uint8_t(Binary);
69 assert(Binary <= UINT16_MAX &&
"Several-byte opcodes not supported yet");
70 OS << uint8_t(Binary >> 8);
77 if (MI.
getOpcode() == WebAssembly::BR_TABLE_I32_S ||
78 MI.
getOpcode() == WebAssembly::BR_TABLE_I64_S)
80 if (MI.
getOpcode() == WebAssembly::BR_TABLE_I32 ||
81 MI.
getOpcode() == WebAssembly::BR_TABLE_I64)
90 }
else if (MO.
isImm()) {
106 OS << uint8_t(MO.
getImm());
145 size_t PaddedSize = 5;
176 #include "WebAssemblyGenMCCodeEmitter.inc" 32-bit floating-point immediates.
This class represents lattice values for constants.
32-bit integer immediates.
16-bit vector lane immediate
void push_back(const T &Elt)
Describe properties that are true of each instruction in the target description file.
32-bit unsigned memory offsets.
STATISTIC(NumFunctions, "Total number of functions")
static Lanai::Fixups FixupKind(const MCExpr *Expr)
8-bit vector lane immediate
signature immediate for block/loop.
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
uint8_t OperandType
Information about the type of the operand.
const MCExpr * getExpr() const
Analysis containing CSE Info
Instances of this class represent a single low-level machine instruction.
64-bit integer immediates.
64-bit vector lane immediate
MCCodeEmitter * createWebAssemblyMCCodeEmitter(const MCInstrInfo &MCII)
MCCodeEmitter - Generic instruction encoding interface.
This file provides WebAssembly-specific target descriptions.
Interface to description of machine instruction set.
MCFixupKind
Extensible enumeration to represent the type of a fixup.
void write< float >(raw_ostream &os, float value, endianness endian)
unsigned getNumOperands() const
type signature immediate for call_indirect.
static MCFixup create(uint32_t Offset, const MCExpr *Value, MCFixupKind Kind, SMLoc Loc=SMLoc())
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a ULEB128 value to an output stream.
unsigned encodeSLEB128(int64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a SLEB128 value to an output stream.
const MCOperand & getOperand(unsigned i) const
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
64-bit floating-point immediates.
32-bit unsigned function indices.
Generic base class for all target subtargets.
void write< double >(raw_ostream &os, double value, endianness endian)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const MCOperandInfo * OpInfo
uint64_t tell() const
tell - Return the current offset with the file.
This class implements an extremely fast bulk output stream that can only output to a stream...
This holds information about one operand of a machine instruction, indicating the register class for ...
unsigned getOpcode() const
Instances of this class represent operands of the MCInst class.
32-bit vector lane immediate