summaryrefslogtreecommitdiff
path: root/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp')
-rw-r--r--lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp b/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
index 211358ad66cd..d19463ccb51f 100644
--- a/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
+++ b/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
@@ -90,10 +90,13 @@ void WebAssemblyAsmPrinter::EmitEndOfAsmFile(Module &M) {
}
for (const auto &G : M.globals()) {
if (!G.hasInitializer() && G.hasExternalLinkage()) {
- uint16_t Size = M.getDataLayout().getTypeAllocSize(G.getValueType());
- getTargetStreamer()->emitGlobalImport(G.getGlobalIdentifier());
- OutStreamer->emitELFSize(getSymbol(&G),
- MCConstantExpr::create(Size, OutContext));
+ if (G.getValueType()->isSized()) {
+ uint16_t Size = M.getDataLayout().getTypeAllocSize(G.getValueType());
+ if (TM.getTargetTriple().isOSBinFormatELF())
+ getTargetStreamer()->emitGlobalImport(G.getGlobalIdentifier());
+ OutStreamer->emitELFSize(getSymbol(&G),
+ MCConstantExpr::create(Size, OutContext));
+ }
}
}
}
@@ -111,7 +114,7 @@ void WebAssemblyAsmPrinter::EmitFunctionBodyStart() {
getTargetStreamer()->emitParam(CurrentFnSym, MFI->getParams());
SmallVector<MVT, 4> ResultVTs;
- const Function &F(*MF->getFunction());
+ const Function &F = MF->getFunction();
// Emit the function index.
if (MDNode *Idx = F.getMetadata("wasm.index")) {
@@ -267,12 +270,11 @@ bool WebAssemblyAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
if (AsmVariant != 0)
report_fatal_error("There are no defined alternate asm variants");
- if (!ExtraCode) {
- // TODO: For now, we just hard-code 0 as the constant offset; teach
- // SelectInlineAsmMemoryOperand how to do address mode matching.
- OS << "0(" + regToString(MI->getOperand(OpNo)) + ')';
- return false;
- }
+ // The current approach to inline asm is that "r" constraints are expressed
+ // as local indices, rather than values on the operand stack. This simplifies
+ // using "r" as it eliminates the need to push and pop the values in a
+ // particular order, however it also makes it impossible to have an "m"
+ // constraint. So we don't support it.
return AsmPrinter::PrintAsmMemoryOperand(MI, OpNo, AsmVariant, ExtraCode, OS);
}