32#define DEBUG_TYPE "mccodeemitter"
34STATISTIC(MCNumEmitted,
"Number of MC instructions emitted.");
35STATISTIC(MCNumFixups,
"Number of MC fixups created.");
52 : MCII(MCII), Ctx{Ctx} {}
58 return new WebAssemblyMCCodeEmitter(MCII, Ctx);
61void WebAssemblyMCCodeEmitter::encodeInstruction(
67 uint64_t Binary = getBinaryCodeForInstr(
MI, Fixups, STI);
68 if (Binary < (1 << 8)) {
70 }
else if (Binary < (1 << 16)) {
71 OS << uint8_t(Binary >> 8);
73 }
else if (Binary < (1 << 24)) {
74 OS << uint8_t(Binary >> 16);
83 unsigned Opcode =
MI.getOpcode();
84 if (Opcode == WebAssembly::BR_TABLE_I32_S ||
85 Opcode == WebAssembly::BR_TABLE_I64_S)
87 if (Opcode == WebAssembly::BR_TABLE_I32 ||
88 Opcode == WebAssembly::BR_TABLE_I64)
91 const MCInstrDesc &
Desc = MCII.
get(Opcode);
92 for (
unsigned I = 0,
E =
MI.getNumOperands();
I <
E; ++
I) {
93 const MCOperand &MO =
MI.getOperand(
I);
97 }
else if (MO.
isImm()) {
98 if (
I <
Desc.getNumOperands()) {
99 const MCOperandInfo &
Info =
Desc.operands()[
I];
101 <<
int(
Info.OperandType) <<
"\n");
102 switch (
Info.OperandType) {
132 Twine(
"Wasm globals should only be accessed symbolically!"));
142 Opcode == WebAssembly::TRY_TABLE_S);
154 size_t PaddedSize = 5;
155 if (
I <
Desc.getNumOperands()) {
156 const MCOperandInfo &
Info =
Desc.operands()[
I];
157 switch (
Info.OperandType) {
183 assert(Opcode == WebAssembly::TRY_TABLE_S);
198#include "WebAssemblyGenMCCodeEmitter.inc"
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Analysis containing CSE Info
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
This file provides WebAssembly-specific target descriptions.
MCCodeEmitter - Generic instruction encoding interface.
Context object for machine code objects.
LLVM_ABI void reportError(SMLoc L, const Twine &Msg)
static MCFixup create(uint32_t Offset, const MCExpr *Value, MCFixupKind Kind, bool PCRel=false)
Consider bit fields if we need more flags.
Instances of this class represent a single low-level machine instruction.
Interface to description of machine instruction set.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode.
const MCExpr * getExpr() const
uint32_t getSFPImm() const
uint64_t getDFPImm() const
Generic base class for all target subtargets.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
A raw_ostream that writes to an SmallVector or SmallString.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool isBrTable(unsigned Opc)
@ OPERAND_GLOBAL
Global index.
@ OPERAND_OFFSET64
64-bit unsigned memory offsets.
@ OPERAND_I32IMM
32-bit integer immediates.
@ OPERAND_TABLE
32-bit unsigned table number.
@ OPERAND_VEC_I64IMM
64-bit vector lane immediate
@ OPERAND_VEC_I16IMM
16-bit vector lane immediate
@ OPERAND_TYPEINDEX
type signature immediate for call_indirect.
@ OPERAND_FUNCTION32
32-bit unsigned function indices.
@ OPERAND_VEC_I32IMM
32-bit vector lane immediate
@ OPERAND_VEC_I8IMM
8-bit vector lane immediate
@ OPERAND_SIGNATURE
signature immediate for block/loop.
@ OPERAND_I64IMM
64-bit integer immediates.
@ OPERAND_OFFSET32
32-bit unsigned memory offsets.
void write(void *memory, value_type value, endianness endian)
Write a value to memory with a particular endianness.
This is an optimization pass for GlobalISel generic memory operations.
MCCodeEmitter * createWebAssemblyMCCodeEmitter(const MCInstrInfo &MCII, MCContext &Ctx)
uint16_t MCFixupKind
Extensible enumeration to represent the type of a fixup.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
static Lanai::Fixups FixupKind(const MCExpr *Expr)
unsigned encodeSLEB128(int64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a SLEB128 value to an output stream.
unsigned encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a ULEB128 value to an output stream.