Dan Gohman | 3469ee1 | 2016-01-12 20:30:51 +0000 | [diff] [blame] | 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 | |
Dan Gohman | 4635017 | 2016-01-12 20:56:01 +0000 | [diff] [blame] | 19 | #include "llvm/CodeGen/MachineValueType.h" |
Dan Gohman | 3469ee1 | 2016-01-12 20:30:51 +0000 | [diff] [blame] | 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; |
Derek Schuff | 5859a9ed | 2016-06-03 18:34:36 +0000 | [diff] [blame] | 40 | /// .functype |
| 41 | virtual void emitIndirectFunctionType(StringRef name, |
| 42 | SmallVectorImpl<MVT> &SignatureVTs, |
| 43 | size_t NumResults) { |
| 44 | llvm_unreachable("emitIndirectFunctionType not implemented"); |
| 45 | } |
Derek Schuff | c64d765 | 2016-08-01 22:25:02 +0000 | [diff] [blame] | 46 | /// .indidx |
| 47 | virtual void emitIndIdx(const MCExpr *Value) = 0; |
Dan Gohman | 3469ee1 | 2016-01-12 20:30:51 +0000 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | /// This part is for ascii assembly output |
| 51 | class WebAssemblyTargetAsmStreamer final : public WebAssemblyTargetStreamer { |
| 52 | formatted_raw_ostream &OS; |
| 53 | |
| 54 | public: |
| 55 | WebAssemblyTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS); |
| 56 | |
| 57 | void emitParam(ArrayRef<MVT> Types) override; |
| 58 | void emitResult(ArrayRef<MVT> Types) override; |
| 59 | void emitLocal(ArrayRef<MVT> Types) override; |
| 60 | void emitEndFunc() override; |
Derek Schuff | 5859a9ed | 2016-06-03 18:34:36 +0000 | [diff] [blame] | 61 | void emitIndirectFunctionType(StringRef name, |
| 62 | SmallVectorImpl<MVT> &SignatureVTs, |
| 63 | size_t NumResults) override; |
Derek Schuff | c64d765 | 2016-08-01 22:25:02 +0000 | [diff] [blame] | 64 | void emitIndIdx(const MCExpr *Value) override; |
Dan Gohman | 3469ee1 | 2016-01-12 20:30:51 +0000 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | /// This part is for ELF object output |
| 68 | class WebAssemblyTargetELFStreamer final : public WebAssemblyTargetStreamer { |
| 69 | public: |
| 70 | explicit WebAssemblyTargetELFStreamer(MCStreamer &S); |
| 71 | |
| 72 | void emitParam(ArrayRef<MVT> Types) override; |
| 73 | void emitResult(ArrayRef<MVT> Types) override; |
| 74 | void emitLocal(ArrayRef<MVT> Types) override; |
| 75 | void emitEndFunc() override; |
Derek Schuff | c64d765 | 2016-08-01 22:25:02 +0000 | [diff] [blame] | 76 | void emitIndIdx(const MCExpr *Value) override; |
Dan Gohman | 3469ee1 | 2016-01-12 20:30:51 +0000 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | } // end namespace llvm |
| 80 | |
| 81 | #endif |