32#define DEBUG_TYPE "mccodeemitter"
34STATISTIC(MCNumEmitted,
"Number of MC instructions emitted.");
35STATISTIC(MCNumFixups,
"Number of MC fixups created.");
51 WebAssemblyMCCodeEmitter(
const MCInstrInfo &MCII) : MCII(MCII) {}
56 return new WebAssemblyMCCodeEmitter(MCII);
59void WebAssemblyMCCodeEmitter::encodeInstruction(
64 uint64_t Binary = getBinaryCodeForInstr(
MI, Fixups, STI);
65 if (Binary < (1 << 8)) {
66 OS << uint8_t(Binary);
67 }
else if (Binary < (1 << 16)) {
68 OS << uint8_t(Binary >> 8);
70 }
else if (Binary < (1 << 24)) {
71 OS << uint8_t(Binary >> 16);
80 if (
MI.getOpcode() == WebAssembly::BR_TABLE_I32_S ||
81 MI.getOpcode() == WebAssembly::BR_TABLE_I64_S)
83 if (
MI.getOpcode() == WebAssembly::BR_TABLE_I32 ||
84 MI.getOpcode() == WebAssembly::BR_TABLE_I64)
88 for (
unsigned I = 0,
E =
MI.getNumOperands();
I <
E; ++
I) {
93 }
else if (MO.
isImm()) {
97 <<
int(
Info.OperandType) <<
"\n");
98 switch (
Info.OperandType) {
139 size_t PaddedSize = 5;
140 switch (
Info.OperandType) {
165 FixupKind,
MI.getLoc()));
176#include "WebAssemblyGenMCCodeEmitter.inc"
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.
virtual void encodeInstruction(const MCInst &Inst, raw_ostream &OS, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
EncodeInstruction - Encode the given Inst to bytes on the output stream OS.
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.
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
ArrayRef< MCOperandInfo > operands() const
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.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This class implements an extremely fast bulk output stream that can only output to a stream.
uint64_t tell() const
tell - Return the current offset with the file.
#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)
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.