33 explicit WebAssemblyWasmObjectWriter(
bool Is64Bit,
bool IsEmscripten);
38 bool IsLocRel)
const override;
42WebAssemblyWasmObjectWriter::WebAssemblyWasmObjectWriter(
bool Is64Bit,
47 if (
auto SyExp = dyn_cast<MCSymbolRefExpr>(Expr)) {
48 if (SyExp->getSymbol().isInSection())
49 return &SyExp->getSymbol().getSection();
53 if (
auto BinOp = dyn_cast<MCBinaryExpr>(Expr)) {
56 return SectionLHS == SectionRHS ? nullptr : SectionLHS;
59 if (
auto UnOp = dyn_cast<MCUnaryExpr>(Expr))
65unsigned WebAssemblyWasmObjectWriter::getRelocType(
70 auto& SymA = cast<MCSymbolWasm>(RefA->
getSymbol());
77 return wasm::R_WASM_GLOBAL_INDEX_LEB;
80 return is64Bit() ? wasm::R_WASM_TABLE_INDEX_REL_SLEB64
81 : wasm::R_WASM_TABLE_INDEX_REL_SLEB;
83 return is64Bit() ? wasm::R_WASM_MEMORY_ADDR_TLS_SLEB64
84 : wasm::R_WASM_MEMORY_ADDR_TLS_SLEB;
87 return is64Bit() ? wasm::R_WASM_MEMORY_ADDR_REL_SLEB64
88 : wasm::R_WASM_MEMORY_ADDR_REL_SLEB;
90 return wasm::R_WASM_TYPE_INDEX_LEB;
94 return wasm::R_WASM_FUNCTION_INDEX_I32;
100 switch (
unsigned(
Fixup.getKind())) {
102 if (SymA.isFunction())
103 return wasm::R_WASM_TABLE_INDEX_SLEB;
104 return wasm::R_WASM_MEMORY_ADDR_SLEB;
106 if (SymA.isFunction())
107 return wasm::R_WASM_TABLE_INDEX_SLEB64;
108 return wasm::R_WASM_MEMORY_ADDR_SLEB64;
111 return wasm::R_WASM_GLOBAL_INDEX_LEB;
112 if (SymA.isFunction())
113 return wasm::R_WASM_FUNCTION_INDEX_LEB;
115 return wasm::R_WASM_TAG_INDEX_LEB;
117 return wasm::R_WASM_TABLE_NUMBER_LEB;
118 return wasm::R_WASM_MEMORY_ADDR_LEB;
121 return wasm::R_WASM_MEMORY_ADDR_LEB64;
123 if (SymA.isFunction()) {
125 return wasm::R_WASM_FUNCTION_OFFSET_I32;
127 return wasm::R_WASM_TABLE_INDEX_I32;
130 return wasm::R_WASM_GLOBAL_INDEX_I32;
134 return wasm::R_WASM_FUNCTION_OFFSET_I32;
135 else if (!
Section->isWasmData())
136 return wasm::R_WASM_SECTION_OFFSET_I32;
138 return IsLocRel ? wasm::R_WASM_MEMORY_ADDR_LOCREL_I32
139 : wasm::R_WASM_MEMORY_ADDR_I32;
141 if (SymA.isFunction()) {
143 return wasm::R_WASM_FUNCTION_OFFSET_I64;
144 return wasm::R_WASM_TABLE_INDEX_I64;
151 return wasm::R_WASM_FUNCTION_OFFSET_I64;
152 else if (!
Section->isWasmData())
156 return wasm::R_WASM_MEMORY_ADDR_I64;
162std::unique_ptr<MCObjectTargetWriter>
164 return std::make_unique<WebAssemblyWasmObjectWriter>(Is64Bit, IsEmscripten);
PowerPC TLS Dynamic Call Fixup
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file provides WebAssembly-specific target descriptions.
static const MCSection * getTargetSection(const MCExpr *Expr)
static bool is64Bit(const char *name)
Base class for the full range of assembler expressions which are needed for parsing.
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
This represents a section on wasm.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Represent a reference to a symbol from inside an expression.
const MCSymbol & getSymbol() const
This represents an "assembler immediate".
virtual unsigned getRelocType(const MCValue &Target, const MCFixup &Fixup, const MCSectionWasm &FixupSection, bool IsLocRel) const =0
Target - Wrapper for Target specific information.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
std::unique_ptr< MCObjectTargetWriter > createWebAssemblyWasmObjectWriter(bool Is64Bit, bool IsEmscripten)
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
@ FK_Data_8
A eight-byte fixup.
@ FK_Data_4
A four-byte fixup.