From 98efbf1e866bada0daf3b737eef457fec71eb9bb Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 15 Dec 2015 02:20:44 +0000 Subject: [PATCH] [WebAssembly] Remove .import printing. For now, LLVM doesn't know about wasm module imports, so it shouldn't emit .import directives. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255602 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../WebAssembly/WebAssemblyAsmPrinter.cpp | 58 ------------------- test/CodeGen/WebAssembly/import.ll | 32 ---------- 2 files changed, 90 deletions(-) delete mode 100644 test/CodeGen/WebAssembly/import.ll diff --git a/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp b/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp index fc2928079d2..c1403fb0c9e 100644 --- a/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp +++ b/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp @@ -71,7 +71,6 @@ private: void EmitConstantPool() override; void EmitFunctionBodyStart() override; void EmitInstruction(const MachineInstr *MI) override; - void EmitEndOfAsmFile(Module &M) override; bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode, raw_ostream &OS) override; @@ -213,63 +212,6 @@ void WebAssemblyAsmPrinter::EmitInstruction(const MachineInstr *MI) { } } -void WebAssemblyAsmPrinter::EmitEndOfAsmFile(Module &M) { - const DataLayout &DL = M.getDataLayout(); - - SmallString<128> Str; - raw_svector_ostream OS(Str); - for (const Function &F : M) - if (F.isDeclarationForLinker()) { - assert(F.hasName() && "imported functions must have a name"); - if (F.isIntrinsic()) - continue; - if (Str.empty()) - OS << "\t.imports\n"; - - MCSymbol *Sym = OutStreamer->getContext().getOrCreateSymbol(F.getName()); - OS << "\t.import " << *Sym << " \"\" " << *Sym; - - const WebAssemblyTargetLowering &TLI = - *TM.getSubtarget(F).getTargetLowering(); - - // If we need to legalize the return type, it'll get converted into - // passing a pointer. - bool SawParam = false; - SmallVector ResultVTs; - ComputeLegalValueVTs(F, TM, F.getReturnType(), ResultVTs); - if (ResultVTs.size() > 1) { - ResultVTs.clear(); - OS << " (param " << toString(TLI.getPointerTy(DL)); - SawParam = true; - } - - for (const Argument &A : F.args()) { - SmallVector ParamVTs; - ComputeLegalValueVTs(F, TM, A.getType(), ParamVTs); - for (MVT VT : ParamVTs) { - if (!SawParam) { - OS << " (param"; - SawParam = true; - } - OS << ' ' << toString(VT); - } - } - if (SawParam) - OS << ')'; - - for (MVT VT : ResultVTs) - OS << " (result " << toString(VT) << ')'; - - OS << '\n'; - } - - StringRef Text = OS.str(); - if (!Text.empty()) - OutStreamer->EmitRawText(Text.substr(0, Text.size() - 1)); - - AsmPrinter::EmitEndOfAsmFile(M); -} - bool WebAssemblyAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode, diff --git a/test/CodeGen/WebAssembly/import.ll b/test/CodeGen/WebAssembly/import.ll deleted file mode 100644 index 2547bae92ea..00000000000 --- a/test/CodeGen/WebAssembly/import.ll +++ /dev/null @@ -1,32 +0,0 @@ -; RUN: llc < %s -asm-verbose=false | FileCheck %s - -target datalayout = "e-p:32:32-i64:64-n32:64-S128" -target triple = "wasm32-unknown-unknown" - -; CHECK-LABEL: .text -; CHECK-LABEL: f: -define void @f(i32 %a, float %b, i128 %c, i1 %d) { - tail call i32 @printi(i32 %a) - tail call float @printf(float %b) - tail call void @printv() - tail call void @split_arg(i128 %c) - tail call void @expanded_arg(i1 %d) - tail call i1 @lowered_result() - ret void -} - -; CHECK-LABEL: .imports -; CHECK-NEXT: .import printi "" printi (param i32) (result i32){{$}} -; CHECK-NEXT: .import printf "" printf (param f32) (result f32){{$}} -; CHECK-NEXT: .import printv "" printv{{$}} -; CHECK-NEXT: .import add2 "" add2 (param i32 i32) (result i32){{$}} -; CHECK-NEXT: .import split_arg "" split_arg (param i64 i64){{$}} -; CHECK-NEXT: .import expanded_arg "" expanded_arg (param i32){{$}} -; CHECK-NEXT: .import lowered_result "" lowered_result (result i32){{$}} -declare i32 @printi(i32) -declare float @printf(float) -declare void @printv() -declare i32 @add2(i32, i32) -declare void @split_arg(i128) -declare void @expanded_arg(i1) -declare i1 @lowered_result() -- 2.34.1