34 explicit WebAssemblyWasmObjectWriter(
bool Is64Bit,
bool IsEmscripten);
39 bool IsLocRel)
const override;
43WebAssemblyWasmObjectWriter::WebAssemblyWasmObjectWriter(
bool Is64Bit,
48 if (
auto SyExp = dyn_cast<MCSymbolRefExpr>(Expr)) {
49 if (SyExp->getSymbol().isInSection())
50 return &SyExp->getSymbol().getSection();
54 if (
auto BinOp = dyn_cast<MCBinaryExpr>(Expr)) {
57 return SectionLHS == SectionRHS ? nullptr : SectionLHS;
60 if (
auto UnOp = dyn_cast<MCUnaryExpr>(Expr))
66unsigned WebAssemblyWasmObjectWriter::getRelocType(
71 auto& SymA = cast<MCSymbolWasm>(RefA->
getSymbol());
78 return wasm::R_WASM_GLOBAL_INDEX_LEB;
81 return is64Bit() ? wasm::R_WASM_TABLE_INDEX_REL_SLEB64
82 : wasm::R_WASM_TABLE_INDEX_REL_SLEB;
84 return is64Bit() ? wasm::R_WASM_MEMORY_ADDR_TLS_SLEB64
85 : wasm::R_WASM_MEMORY_ADDR_TLS_SLEB;
88 return is64Bit() ? wasm::R_WASM_MEMORY_ADDR_REL_SLEB64
89 : wasm::R_WASM_MEMORY_ADDR_REL_SLEB;
91 return wasm::R_WASM_TYPE_INDEX_LEB;
95 return wasm::R_WASM_FUNCTION_INDEX_I32;
101 switch (
unsigned(
Fixup.getKind())) {
103 if (SymA.isFunction())
104 return wasm::R_WASM_TABLE_INDEX_SLEB;
105 return wasm::R_WASM_MEMORY_ADDR_SLEB;
107 if (SymA.isFunction())
108 return wasm::R_WASM_TABLE_INDEX_SLEB64;
109 return wasm::R_WASM_MEMORY_ADDR_SLEB64;
112 return wasm::R_WASM_GLOBAL_INDEX_LEB;
113 if (SymA.isFunction())
114 return wasm::R_WASM_FUNCTION_INDEX_LEB;
116 return wasm::R_WASM_TAG_INDEX_LEB;
118 return wasm::R_WASM_TABLE_NUMBER_LEB;
119 return wasm::R_WASM_MEMORY_ADDR_LEB;
122 return wasm::R_WASM_MEMORY_ADDR_LEB64;
124 if (SymA.isFunction()) {
126 return wasm::R_WASM_FUNCTION_OFFSET_I32;
128 return wasm::R_WASM_TABLE_INDEX_I32;
131 return wasm::R_WASM_GLOBAL_INDEX_I32;
135 return wasm::R_WASM_FUNCTION_OFFSET_I32;
136 else if (!
Section->isWasmData())
137 return wasm::R_WASM_SECTION_OFFSET_I32;
139 return IsLocRel ? wasm::R_WASM_MEMORY_ADDR_LOCREL_I32
140 : wasm::R_WASM_MEMORY_ADDR_I32;
142 if (SymA.isFunction()) {
144 return wasm::R_WASM_FUNCTION_OFFSET_I64;
145 return wasm::R_WASM_TABLE_INDEX_I64;
152 return wasm::R_WASM_FUNCTION_OFFSET_I64;
153 else if (!
Section->isWasmData())
157 return wasm::R_WASM_MEMORY_ADDR_I64;
163std::unique_ptr<MCObjectTargetWriter>
165 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.