32 class WebAssemblyAsmBackendELF final :
public MCAsmBackend {
36 explicit WebAssemblyAsmBackendELF(
bool Is64Bit)
38 ~WebAssemblyAsmBackendELF()
override {}
42 uint64_t
Value,
bool IsPCRel)
const override;
47 bool fixupNeedsRelaxation(
const MCFixup &Fixup, uint64_t
Value,
53 unsigned getNumFixupKinds()
const override {
59 bool mayNeedRelaxation(
const MCInst &Inst)
const override {
return false; }
62 MCInst &Res)
const override {}
64 bool writeNopData(uint64_t Count,
MCObjectWriter *OW)
const override;
67 class WebAssemblyAsmBackend final :
public MCAsmBackend {
71 explicit WebAssemblyAsmBackend(
bool Is64Bit)
73 ~WebAssemblyAsmBackend()
override {}
75 unsigned getNumFixupKinds()
const override {
83 uint64_t
Value,
bool IsPCRel)
const override;
88 bool fixupNeedsRelaxation(
const MCFixup &Fixup, uint64_t
Value,
94 bool mayNeedRelaxation(
const MCInst &Inst)
const override {
return false; }
97 MCInst &Res)
const override {}
99 bool writeNopData(uint64_t Count,
MCObjectWriter *OW)
const override;
102 bool WebAssemblyAsmBackendELF::writeNopData(uint64_t Count,
104 for (uint64_t i = 0; i < Count; ++i)
114 uint64_t
Value,
bool IsPCRel)
const {
116 assert(Info.
Flags == 0 &&
"WebAssembly does not use MCFixupKindInfo flags");
126 assert(Offset + NumBytes <= Data.
size() &&
"Invalid fixup offset!");
130 for (
unsigned i = 0; i != NumBytes; ++i)
131 Data[Offset + i] |= uint8_t((Value >> (i * 8)) & 0xff);
146 {
"fixup_code_sleb128_i32", 0, 5*8, 0 },
147 {
"fixup_code_sleb128_i64", 0, 10*8, 0 },
148 {
"fixup_code_uleb128_i32", 0, 5*8, 0 },
159 bool WebAssemblyAsmBackend::writeNopData(uint64_t Count,
164 for (uint64_t i = 0; i < Count; ++i)
170 void WebAssemblyAsmBackend::applyFixup(
const MCAssembler &Asm,
174 uint64_t Value,
bool IsPCRel)
const {
176 assert(Info.
Flags == 0 &&
"WebAssembly does not use MCFixupKindInfo flags");
186 assert(Offset + NumBytes <= Data.
size() &&
"Invalid fixup offset!");
190 for (
unsigned i = 0; i != NumBytes; ++i)
191 Data[Offset + i] |= uint8_t((Value >> (i * 8)) & 0xff);
202 return new WebAssemblyAsmBackendELF(TT.
isArch64Bit());
203 return new WebAssemblyAsmBackend(TT.
isArch64Bit());
MCObjectWriter * createWebAssemblyWasmObjectWriter(raw_pwrite_stream &OS, bool Is64Bit)
This represents an "assembler immediate".
uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
Defines the object file and target independent interfaces used by the assembler backend to write nati...
void write8(uint8_t Value)
unsigned TargetOffset
The bit offset to write the relocation into.
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Encapsulates the layout of an assembly file at a particular point in time.
bool isArch64Bit() const
Test whether the architecture is 64-bit.
uint32_t getOffset() const
size_t size() const
size - Get the array size.
Instances of this class represent a single low-level machine instruction.
A relaxable fragment holds on to its MCInst, since it may need to be relaxed during the assembler lay...
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
This file provides WebAssembly-specific target descriptions.
MCFixupKind
Extensible enumeration to represent the type of a fixup.
MCFixupKind getKind() const
Triple - Helper class for working with autoconf configuration names.
unsigned TargetSize
The number of bits written by this fixup.
MCAsmBackend * createWebAssemblyAsmBackend(const Triple &TT)
MCObjectWriter * createWebAssemblyELFObjectWriter(raw_pwrite_stream &OS, bool Is64Bit, uint8_t OSABI)
Target - Wrapper for Target specific information.
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
MCSubtargetInfo - Generic base class for all target subtargets.
Target independent information on a fixup kind.
An abstract base class for streams implementations that also support a pwrite operation.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
Generic interface to target specific assembler backends.
static const unsigned Nop
Instruction opcodes emitted via means other than CodeGen.
virtual const MCFixupKindInfo & getFixupKindInfo(MCFixupKind Kind) const
Get information on a fixup kind.
unsigned Flags
Flags describing additional information on this fixup kind.