34#define DEBUG_TYPE "mccodeemitter"
36STATISTIC(MCNumEmitted,
"Number of MC instructions emitted.");
37STATISTIC(MCNumFixups,
"Number of MC fixups created.");
54 : MCII(MCII), Ctx{Ctx} {}
60 return new WebAssemblyMCCodeEmitter(MCII, Ctx);
63void WebAssemblyMCCodeEmitter::encodeInstruction(
69 uint64_t Binary = getBinaryCodeForInstr(
MI, Fixups, STI);
70 if (Binary < (1 << 8)) {
71 OS << uint8_t(Binary);
72 }
else if (Binary < (1 << 16)) {
73 OS << uint8_t(Binary >> 8);
75 }
else if (Binary < (1 << 24)) {
76 OS << uint8_t(Binary >> 16);
85 if (
MI.getOpcode() == WebAssembly::BR_TABLE_I32_S ||
86 MI.getOpcode() == WebAssembly::BR_TABLE_I64_S)
88 if (
MI.getOpcode() == WebAssembly::BR_TABLE_I32 ||
89 MI.getOpcode() == WebAssembly::BR_TABLE_I64)
93 for (
unsigned I = 0, E =
MI.getNumOperands();
I < E; ++
I) {
98 }
else if (MO.
isImm()) {
99 if (
I <
Desc.getNumOperands()) {
102 <<
int(
Info.OperandType) <<
"\n");
103 switch (
Info.OperandType) {
115 support::endian::write<uint8_t>(
OS, MO.
getImm(),
119 support::endian::write<uint16_t>(
OS, MO.
getImm(),
123 support::endian::write<uint32_t>(
OS, MO.
getImm(),
127 support::endian::write<uint64_t>(
OS, MO.
getImm(),
133 Twine(
"Wasm globals should only be accessed symbolically!"));
151 size_t PaddedSize = 5;
152 switch (
Info.OperandType) {
177 FixupKind,
MI.getLoc()));
188#include "WebAssemblyGenMCCodeEmitter.inc"
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
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.
virtual void encodeInstruction(const MCInst &Inst, SmallVectorImpl< char > &CB, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const =0
Encode the given Inst to bytes and append to CB.
Context object for machine code objects.
static MCFixup create(uint32_t Offset, const MCExpr *Value, MCFixupKind Kind, SMLoc Loc=SMLoc())
Instances of this class represent a single low-level machine instruction.
Describe properties that are true of each instruction in the target description file.
Interface to description of machine instruction set.
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 MCExpr * getExpr() const
uint32_t getSFPImm() const
uint64_t getDFPImm() const
Generic base class for all target subtargets.
Represents a location in source code.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
uint64_t tell() const
tell - Return the current offset with the file.
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.
@ 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.
This is an optimization pass for GlobalISel generic memory operations.
MCCodeEmitter * createWebAssemblyMCCodeEmitter(const MCInstrInfo &MCII, MCContext &Ctx)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
MCFixupKind
Extensible enumeration to represent the type of a fixup.
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.
Description of the encoding of one expression Op.