[PATCH] D54012: [WebAssembly] Added a .globaltype directive to .s output.
Wouter van Oortmerssen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 1 17:48:32 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345917: [WebAssembly] Added a .globaltype directive to .s output. (authored by aardappel, committed by ).
Repository:
rL LLVM
https://reviews.llvm.org/D54012
Files:
llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp
llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h
llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
llvm/trunk/test/CodeGen/WebAssembly/userstack.ll
Index: llvm/trunk/test/CodeGen/WebAssembly/userstack.ll
===================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/userstack.ll
+++ llvm/trunk/test/CodeGen/WebAssembly/userstack.ll
@@ -330,4 +330,6 @@
ret void
}
+; CHECK: .globaltype __stack_pointer, i32{{$}}
+
; TODO: test over-aligned alloca
Index: llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp
===================================================================
--- llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp
+++ llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp
@@ -99,8 +99,11 @@
OS << '\n';
}
-void WebAssemblyTargetAsmStreamer::emitGlobalImport(StringRef name) {
- OS << "\t.import_global\t" << name << '\n';
+void WebAssemblyTargetAsmStreamer::emitGlobalType(MCSymbolWasm *Sym) {
+ OS << "\t.globaltype\t" << Sym->getName() << ", " <<
+ WebAssembly::TypeToString(
+ static_cast<wasm::ValType>(Sym->getGlobalType().Type)) <<
+ '\n';
}
void WebAssemblyTargetAsmStreamer::emitImportModule(MCSymbolWasm *Sym,
@@ -152,8 +155,8 @@
Symbol->setType(wasm::WASM_SYMBOL_TYPE_FUNCTION);
}
-void WebAssemblyTargetWasmStreamer::emitGlobalImport(StringRef name) {
- llvm_unreachable(".global_import is not needed for direct wasm output");
+void WebAssemblyTargetWasmStreamer::emitGlobalType(MCSymbolWasm *Sym) {
+ // Not needed.
}
void WebAssemblyTargetWasmStreamer::emitImportModule(MCSymbolWasm *Sym,
Index: llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h
===================================================================
--- llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h
+++ llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h
@@ -43,8 +43,8 @@
virtual void emitIndirectFunctionType(MCSymbolWasm *Symbol) = 0;
/// .indidx
virtual void emitIndIdx(const MCExpr *Value) = 0;
- /// .import_global
- virtual void emitGlobalImport(StringRef name) = 0;
+ /// .globaltype
+ virtual void emitGlobalType(MCSymbolWasm *Sym) = 0;
/// .import_module
virtual void emitImportModule(MCSymbolWasm *Sym, StringRef ModuleName) = 0;
@@ -65,7 +65,7 @@
void emitEndFunc() override;
void emitIndirectFunctionType(MCSymbolWasm *Symbol) override;
void emitIndIdx(const MCExpr *Value) override;
- void emitGlobalImport(StringRef name) override;
+ void emitGlobalType(MCSymbolWasm *Sym) override;
void emitImportModule(MCSymbolWasm *Sym, StringRef ModuleName) override;
};
@@ -80,7 +80,7 @@
void emitEndFunc() override;
void emitIndirectFunctionType(MCSymbolWasm *Symbol) override;
void emitIndIdx(const MCExpr *Value) override;
- void emitGlobalImport(StringRef name) override;
+ void emitGlobalType(MCSymbolWasm *Sym) override;
void emitImportModule(MCSymbolWasm *Sym, StringRef ModuleName) override;
};
Index: llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
===================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
@@ -78,6 +78,14 @@
//===----------------------------------------------------------------------===//
void WebAssemblyAsmPrinter::EmitEndOfAsmFile(Module &M) {
+ for (auto &It : OutContext.getSymbols()) {
+ // Emit a .globaltype declaration.
+ auto Sym = cast<MCSymbolWasm>(It.getValue());
+ if (Sym->getType() == wasm::WASM_SYMBOL_TYPE_GLOBAL) {
+ getTargetStreamer()->emitGlobalType(Sym);
+ }
+ }
+
for (const auto &F : M) {
// Emit function type info for all undefined functions
if (F.isDeclarationForLinker() && !F.isIntrinsic()) {
@@ -105,6 +113,7 @@
}
}
}
+
for (const auto &G : M.globals()) {
if (!G.hasInitializer() && G.hasExternalLinkage()) {
if (G.getValueType()->isSized()) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54012.172288.patch
Type: text/x-patch
Size: 3972 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181102/fc213985/attachment.bin>
More information about the llvm-commits
mailing list