1 //==-- WebAssemblyTargetStreamer.h - WebAssembly Target Streamer -*- C++ -*-==// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 /// 10 /// \file 11 /// \brief This file declares WebAssembly-specific target streamer classes. 12 /// These are for implementing support for target-specific assembly directives. 13 /// 14 //===----------------------------------------------------------------------===// 15 16 #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_MCTARGETDESC_WEBASSEMBLYTARGETSTREAMER_H 17 #define LLVM_LIB_TARGET_WEBASSEMBLY_MCTARGETDESC_WEBASSEMBLYTARGETSTREAMER_H 18 19 #include "llvm/CodeGen/MachineValueType.h" 20 #include "llvm/MC/MCStreamer.h" 21 22 namespace llvm { 23 24 class MCELFStreamer; 25 26 /// WebAssembly-specific streamer interface, to implement support 27 /// WebAssembly-specific assembly directives. 28 class WebAssemblyTargetStreamer : public MCTargetStreamer { 29 public: 30 explicit WebAssemblyTargetStreamer(MCStreamer &S); 31 32 /// .param 33 virtual void emitParam(ArrayRef<MVT> Types) = 0; 34 /// .result 35 virtual void emitResult(ArrayRef<MVT> Types) = 0; 36 /// .local 37 virtual void emitLocal(ArrayRef<MVT> Types) = 0; 38 /// .endfunc 39 virtual void emitEndFunc() = 0; 40 /// .functype emitIndirectFunctionType(StringRef name,SmallVectorImpl<MVT> & SignatureVTs,size_t NumResults)41 virtual void emitIndirectFunctionType(StringRef name, 42 SmallVectorImpl<MVT> &SignatureVTs, 43 size_t NumResults) { 44 llvm_unreachable("emitIndirectFunctionType not implemented"); 45 } 46 }; 47 48 /// This part is for ascii assembly output 49 class WebAssemblyTargetAsmStreamer final : public WebAssemblyTargetStreamer { 50 formatted_raw_ostream &OS; 51 52 public: 53 WebAssemblyTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS); 54 55 void emitParam(ArrayRef<MVT> Types) override; 56 void emitResult(ArrayRef<MVT> Types) override; 57 void emitLocal(ArrayRef<MVT> Types) override; 58 void emitEndFunc() override; 59 void emitIndirectFunctionType(StringRef name, 60 SmallVectorImpl<MVT> &SignatureVTs, 61 size_t NumResults) override; 62 }; 63 64 /// This part is for ELF object output 65 class WebAssemblyTargetELFStreamer final : public WebAssemblyTargetStreamer { 66 public: 67 explicit WebAssemblyTargetELFStreamer(MCStreamer &S); 68 69 void emitParam(ArrayRef<MVT> Types) override; 70 void emitResult(ArrayRef<MVT> Types) override; 71 void emitLocal(ArrayRef<MVT> Types) override; 72 void emitEndFunc() override; 73 }; 74 75 } // end namespace llvm 76 77 #endif 78