aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2025-12-06 19:56:45 +0000
committerDimitry Andric <dim@FreeBSD.org>2025-12-06 20:08:43 +0000
commit3f709e42e3be0f28a88ca3e77663a02b52c914f4 (patch)
tree948796bf3bf7e164373caf6c31f9f128ca85fd8c /llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
parent32a711e1c447004eb1fd015925f305ed1d8426de (diff)
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
index ded7052295ad..1bf070e9ec9c 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
@@ -14,14 +14,17 @@
//===----------------------------------------------------------------------===//
#include "WebAssemblyAsmPrinter.h"
+#include "MCTargetDesc/WebAssemblyMCAsmInfo.h"
#include "MCTargetDesc/WebAssemblyMCTargetDesc.h"
#include "MCTargetDesc/WebAssemblyTargetStreamer.h"
#include "TargetInfo/WebAssemblyTargetInfo.h"
#include "Utils/WebAssemblyTypeUtilities.h"
+#include "WebAssembly.h"
#include "WebAssemblyMCInstLower.h"
#include "WebAssemblyMachineFunctionInfo.h"
#include "WebAssemblyRegisterInfo.h"
#include "WebAssemblyRuntimeLibcallSignatures.h"
+#include "WebAssemblyTargetMachine.h"
#include "WebAssemblyUtilities.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/SmallSet.h"
@@ -44,6 +47,7 @@
#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCSymbolWasm.h"
#include "llvm/MC/TargetRegistry.h"
+#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
@@ -152,9 +156,11 @@ static std::string getEmscriptenInvokeSymbolName(wasm::WasmSignature *Sig) {
//===----------------------------------------------------------------------===//
MCSymbolWasm *WebAssemblyAsmPrinter::getMCSymbolForFunction(
- const Function *F, bool EnableEmEH, wasm::WasmSignature *Sig,
- bool &InvokeDetected) {
+ const Function *F, wasm::WasmSignature *Sig, bool &InvokeDetected) {
MCSymbolWasm *WasmSym = nullptr;
+
+ const bool EnableEmEH =
+ WebAssembly::WasmEnableEmEH || WebAssembly::WasmEnableEmSjLj;
if (EnableEmEH && isEmscriptenInvokeName(F->getName())) {
assert(Sig);
InvokeDetected = true;
@@ -341,9 +347,7 @@ void WebAssemblyAsmPrinter::emitDecls(const Module &M) {
// will discard it later if it turns out not to be necessary.
auto Signature = signatureFromMVTs(OutContext, Results, Params);
bool InvokeDetected = false;
- auto *Sym = getMCSymbolForFunction(
- &F, WebAssembly::WasmEnableEmEH || WebAssembly::WasmEnableEmSjLj,
- Signature, InvokeDetected);
+ auto *Sym = getMCSymbolForFunction(&F, Signature, InvokeDetected);
// Multiple functions can be mapped to the same invoke symbol. For
// example, two IR functions '__invoke_void_i8*' and '__invoke_void_i32'
@@ -401,7 +405,7 @@ void WebAssemblyAsmPrinter::emitEndOfAsmFile(Module &M) {
if (!F.isIntrinsic() && F.hasAddressTaken()) {
MCSymbolWasm *FunctionTable =
WebAssembly::getOrCreateFunctionTableSymbol(OutContext, Subtarget);
- OutStreamer->emitSymbolAttribute(FunctionTable, MCSA_NoDeadStrip);
+ OutStreamer->emitSymbolAttribute(FunctionTable, MCSA_NoDeadStrip);
break;
}
}
@@ -590,8 +594,7 @@ void WebAssemblyAsmPrinter::EmitFunctionAttributes(Module &M) {
for (auto &Sym : Symbols) {
OutStreamer->emitValue(
- MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_WASM_FUNCINDEX,
- OutContext),
+ MCSymbolRefExpr::create(Sym, WebAssembly::S_FUNCINDEX, OutContext),
4);
}
OutStreamer->popSection();
@@ -752,8 +755,14 @@ bool WebAssemblyAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
return AsmPrinter::PrintAsmMemoryOperand(MI, OpNo, ExtraCode, OS);
}
+char WebAssemblyAsmPrinter::ID = 0;
+
+INITIALIZE_PASS(WebAssemblyAsmPrinter, "webassembly-asm-printer",
+ "WebAssembly Assmebly Printer", false, false)
+
// Force static initialization.
-extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyAsmPrinter() {
+extern "C" LLVM_ABI LLVM_EXTERNAL_VISIBILITY void
+LLVMInitializeWebAssemblyAsmPrinter() {
RegisterAsmPrinter<WebAssemblyAsmPrinter> X(getTheWebAssemblyTarget32());
RegisterAsmPrinter<WebAssemblyAsmPrinter> Y(getTheWebAssemblyTarget64());
}