30 #define DEBUG_TYPE "mccodeemitter"
32 STATISTIC(MCNumEmitted,
"Number of MC instructions emitted.");
33 STATISTIC(MCNumFixups,
"Number of MC fixups created.");
40 uint64_t getBinaryCodeForInstr(
const MCInst &
MI,
49 explicit WebAssemblyMCCodeEmitter(
const MCInstrInfo &mcii) : MCII(mcii) {}
54 return new WebAssemblyMCCodeEmitter(MCII);
57 void WebAssemblyMCCodeEmitter::encodeInstruction(
60 uint64_t Start = OS.
tell();
62 uint64_t
Binary = getBinaryCodeForInstr(MI, Fixups, STI);
63 assert(Binary < UINT8_MAX &&
"Multi-byte opcodes not supported yet");
64 OS << uint8_t(Binary);
71 }
else if (MO.
isImm()) {
74 "WebAssembly non-variable_ops don't use TSFlags");
90 "Unexpected floating-point immediate as a non-fixed operand");
92 "WebAssembly variable_ops floating point ops don't use TSFlags");
111 : uint64_t(UINT32_MAX),
121 #include "WebAssemblyGenMCCodeEmitter.inc"
32-bit floating-point immediates.
void push_back(const T &Elt)
STATISTIC(NumFunctions,"Total number of functions")
32-bit integer immediates.
Describe properties that are true of each instruction in the target description file.
MachineInstrBuilder MachineInstrBuilder &DefMI const MCInstrDesc & Desc
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
uint64_t tell() const
tell - Return the current offset with the file.
bool isArch64Bit() const
Test whether the architecture is 64-bit.
uint8_t OperandType
Information about the type of the operand.
Instances of this class represent a single low-level machine instruction.
const MCExpr * getExpr() const
64-bit integer immediates.
MCCodeEmitter * createWebAssemblyMCCodeEmitter(const MCInstrInfo &MCII)
MCCodeEmitter - Generic instruction encoding interface.
This file provides WebAssembly-specific target descriptions.
Interface to description of machine instruction set.
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.
void encodeSLEB128(int64_t Value, raw_ostream &OS)
Utility function to encode a SLEB128 value to an output stream.
unsigned getOpcode() const
64-bit floating-point immediates.
unsigned getNumOperands() const
MCSubtargetInfo - Generic base class for all target subtargets.
const Triple & getTargetTriple() const
getTargetTriple - Return the target triple string.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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...
void encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned Padding=0)
Utility function to encode a ULEB128 value to an output stream.
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 MCOperand & getOperand(unsigned i) const