[PATCH] D26875: [WebAssembly] Emit .import_global assembler directives
Derek Schuff via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 30 16:21:26 PST 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288296: [WebAssembly] Emit .import_global assembler directives (authored by dschuff).
Changed prior to commit:
https://reviews.llvm.org/D26875?vs=78596&id=79838#toc
Repository:
rL LLVM
https://reviews.llvm.org/D26875
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/globl.ll
Index: llvm/trunk/test/CodeGen/WebAssembly/globl.ll
===================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/globl.ll
+++ llvm/trunk/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: llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp
===================================================================
--- llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp
+++ llvm/trunk/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
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
@@ -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: llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
===================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
+++ llvm/trunk/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() {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26875.79838.patch
Type: text/x-patch
Size: 2979 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161201/44e0f3f0/attachment.bin>
More information about the llvm-commits
mailing list