llvm.org GIT mirror llvm / 6c76795
[WebAssembly] Add null streamer support Summary: Now `llc -filetype=null` works. Reviewers: eush Subscribers: dschuff, jgravelle-google, sbc100, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D54660 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@347155 91177308-0d34-0410-b5e6-96231b3b80d8 Heejin Ahn 11 months ago
3 changed file(s) with 42 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
8989 return new WebAssemblyTargetAsmStreamer(S, OS);
9090 }
9191
92 static MCTargetStreamer *createNullTargetStreamer(MCStreamer &S) {
93 return new WebAssemblyTargetNullStreamer(S);
94 }
95
9296 // Force static initialization.
9397 extern "C" void LLVMInitializeWebAssemblyTargetMC() {
9498 for (Target *T :
119123 createObjectTargetStreamer);
120124 // Register the asm target streamer.
121125 TargetRegistry::RegisterAsmTargetStreamer(*T, createAsmTargetStreamer);
126 // Register the null target streamer.
127 TargetRegistry::RegisterNullTargetStreamer(*T, createNullTargetStreamer);
122128 }
123129 }
124130
8787 void emitImportModule(MCSymbolWasm *Sym, StringRef ModuleName) override;
8888 };
8989
90 /// This part is for null output
91 class WebAssemblyTargetNullStreamer final : public WebAssemblyTargetStreamer {
92 public:
93 explicit WebAssemblyTargetNullStreamer(MCStreamer &S)
94 : WebAssemblyTargetStreamer(S) {}
95
96 void emitParam(MCSymbol *Symbol, ArrayRef Types) override {}
97 void emitResult(MCSymbol *Symbol, ArrayRef Types) override {}
98 void emitLocal(ArrayRef Types) override {}
99 void emitEndFunc() override {}
100 void emitIndirectFunctionType(MCSymbolWasm *Symbol) override {}
101 void emitIndIdx(const MCExpr *Value) override {}
102 void emitGlobalType(MCSymbolWasm *Sym) override {}
103 void emitEventType(MCSymbolWasm *Sym) override {}
104 void emitImportModule(MCSymbolWasm *Sym, StringRef ModuleName) override {}
105 };
106
90107 } // end namespace llvm
91108
92109 #endif
0 ; RUN: llc < %s -O0 -filetype=null -exception-model=wasm -mattr=+exception-handling
1 ; RUN: llc < %s -O0 -filetype=asm -asm-verbose=false -exception-model=wasm -mattr=+exception-handling | FileCheck %s
2
3 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
4 target triple = "wasm32-unknown-unknown"
5
6 declare void @llvm.wasm.throw(i32, i8*)
7 declare void @g()
8
9 define i32 @test(i8* %p) {
10 %n = alloca i32
11 call void @llvm.wasm.throw(i32 0, i8* %p)
12 call void @g()
13 ret i32 0
14 }
15
16 ; CHECK-DAG: .globaltype
17 ; CHECK-DAG: .eventtype
18 ; CHECK-DAG: .functype