[PATCH] D26875: [WebAssembly] Emit .import_global assembler directives
Jacob Gravelle via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 18 16:01:21 PST 2016
jgravelle-google created this revision.
jgravelle-google added reviewers: dschuff, sunfish.
jgravelle-google added a subscriber: llvm-commits.
Herald added a subscriber: jfb.
https://reviews.llvm.org/D26875
Files:
lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp
lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h
lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
test/CodeGen/WebAssembly/globl.ll
Index: test/CodeGen/WebAssembly/globl.ll
===================================================================
--- test/CodeGen/WebAssembly/globl.ll
+++ test/CodeGen/WebAssembly/globl.ll
@@ -8,3 +8,7 @@
define void @foo() {
ret void
}
+
+; Check import directives - must be at the end of the file
+; CHECK: .import_global bar{{$}}
+ at bar = external global i32
Index: lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
===================================================================
--- lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
+++ lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
@@ -133,6 +133,11 @@
Results);
}
}
+ for (const auto &G : M.globals()) {
+ if (!G.hasInitializer() && G.hasExternalLinkage()) {
+ getTargetStreamer()->emitGlobalImport(G.getGlobalIdentifier());
+ }
+ }
}
void WebAssemblyAsmPrinter::EmitConstantPool() {
Index: lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h
===================================================================
--- lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h
+++ lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h
@@ -45,6 +45,8 @@
}
/// .indidx
virtual void emitIndIdx(const MCExpr *Value) = 0;
+ /// .import_global
+ virtual void emitGlobalImport(StringRef name) = 0;
};
/// This part is for ascii assembly output
@@ -62,6 +64,7 @@
SmallVectorImpl<MVT> &Params,
SmallVectorImpl<MVT> &Results) override;
void emitIndIdx(const MCExpr *Value) override;
+ void emitGlobalImport(StringRef name) override;
};
/// This part is for ELF object output
@@ -77,6 +80,7 @@
SmallVectorImpl<MVT> &Params,
SmallVectorImpl<MVT> &Results) override;
void emitIndIdx(const MCExpr *Value) override;
+ void emitGlobalImport(StringRef name) override;
};
} // end namespace llvm
Index: lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp
===================================================================
--- lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp
+++ lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp
@@ -80,6 +80,10 @@
OS << '\n';
}
+void WebAssemblyTargetAsmStreamer::emitGlobalImport(StringRef name) {
+ OS << "\t.import_global\t" << name << '\n';
+}
+
void WebAssemblyTargetAsmStreamer::emitIndIdx(const MCExpr *Value) {
OS << "\t.indidx \t" << *Value << '\n';
}
@@ -111,3 +115,6 @@
// Nothing to emit here. TODO: Re-design how linking works and re-evaluate
// whether it's necessary for .o files to declare indirect function types.
}
+
+void WebAssemblyTargetELFStreamer::emitGlobalImport(StringRef name) {
+}
\ No newline at end of file
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26875.78596.patch
Type: text/x-patch
Size: 2847 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161119/3d1b2a87/attachment.bin>
More information about the llvm-commits
mailing list