aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2025-04-08 19:44:40 -0700
committerGitHub <noreply@github.com>2025-04-08 19:44:40 -0700
commit50428fb5e90b8318148abdf67eefe99bf8fd310b (patch)
treecb0d95bc0c46822a4082c2d145dc5913f7081e1d /llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
parenta1f1bbf0534f57990c13a0bf0e6645da011f1d9d (diff)
downloadllvm-50428fb5e90b8318148abdf67eefe99bf8fd310b.zip
llvm-50428fb5e90b8318148abdf67eefe99bf8fd310b.tar.gz
llvm-50428fb5e90b8318148abdf67eefe99bf8fd310b.tar.bz2
[WebAssembly] Add WebAssembly::Specifier
Move wasm-specific members outside of MCSymbolRefExpr::VariantKind (a legacy interface I am eliminating). Most changes are mechanic and similar to what I've done for many ELF targets (e.g. X86 #132149) Notes: * `fixSymbolsInTLSFixups` is replaced with `setTLS` in `WebAssemblyWasmObjectWriter::getRelocType`, similar to what I've done for many ELF targets. * `SymA->setUsedInGOT()` in `recordRelocation` is moved to `getRelocType`. While here, rename "Modifier' to "Specifier": > "Relocation modifier", though concise, suggests adjustments happen during the linker's relocation step rather than the assembler's expression evaluation. I landed on "relocation specifier" as the winner. It's clear, aligns with Arm and IBM’s usage, and fits the assembler's role seamlessly. Pull Request: https://github.com/llvm/llvm-project/pull/133116
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
index d78e755..8c86292 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
@@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//
#include "WebAssemblyMCInstLower.h"
+#include "MCTargetDesc/WebAssemblyMCExpr.h"
#include "MCTargetDesc/WebAssemblyMCTargetDesc.h"
#include "TargetInfo/WebAssemblyTargetInfo.h"
#include "Utils/WebAssemblyTypeUtilities.h"
@@ -91,32 +92,32 @@ MCSymbol *WebAssemblyMCInstLower::GetExternalSymbolSymbol(
MCOperand WebAssemblyMCInstLower::lowerSymbolOperand(const MachineOperand &MO,
MCSymbol *Sym) const {
- MCSymbolRefExpr::VariantKind Kind = MCSymbolRefExpr::VK_None;
+ auto Spec = WebAssembly::S_None;
unsigned TargetFlags = MO.getTargetFlags();
switch (TargetFlags) {
case WebAssemblyII::MO_NO_FLAG:
break;
case WebAssemblyII::MO_GOT_TLS:
- Kind = MCSymbolRefExpr::VK_WASM_GOT_TLS;
+ Spec = WebAssembly::S_GOT_TLS;
break;
case WebAssemblyII::MO_GOT:
- Kind = MCSymbolRefExpr::VK_GOT;
+ Spec = WebAssembly::S_GOT;
break;
case WebAssemblyII::MO_MEMORY_BASE_REL:
- Kind = MCSymbolRefExpr::VK_WASM_MBREL;
+ Spec = WebAssembly::S_MBREL;
break;
case WebAssemblyII::MO_TLS_BASE_REL:
- Kind = MCSymbolRefExpr::VK_WASM_TLSREL;
+ Spec = WebAssembly::S_TLSREL;
break;
case WebAssemblyII::MO_TABLE_BASE_REL:
- Kind = MCSymbolRefExpr::VK_WASM_TBREL;
+ Spec = WebAssembly::S_TBREL;
break;
default:
llvm_unreachable("Unknown target flag on GV operand");
}
- const MCExpr *Expr = MCSymbolRefExpr::create(Sym, Kind, Ctx);
+ const MCExpr *Expr = MCSymbolRefExpr::create(Sym, Spec, Ctx);
if (MO.getOffset() != 0) {
const auto *WasmSym = cast<MCSymbolWasm>(Sym);
@@ -149,7 +150,7 @@ MCOperand WebAssemblyMCInstLower::lowerTypeIndexOperand(
WasmSym->setSignature(Signature);
WasmSym->setType(wasm::WASM_SYMBOL_TYPE_FUNCTION);
const MCExpr *Expr =
- MCSymbolRefExpr::create(WasmSym, MCSymbolRefExpr::VK_WASM_TYPEINDEX, Ctx);
+ MCSymbolRefExpr::create(WasmSym, WebAssembly::S_TYPEINDEX, Ctx);
return MCOperand::createExpr(Expr);
}