blob: 2e3e9bccdb1967d49fd1d3ad4118229e535aa7b4 [file] [log] [blame]
Dan Gohman3469ee12016-01-12 20:30:51 +00001//==-- 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 Gohman46350172016-01-12 20:56:01 +000019#include "llvm/CodeGen/MachineValueType.h"
Dan Gohman3469ee12016-01-12 20:30:51 +000020#include "llvm/MC/MCStreamer.h"
21
22namespace llvm {
23
24class MCELFStreamer;
25
26/// WebAssembly-specific streamer interface, to implement support
27/// WebAssembly-specific assembly directives.
28class WebAssemblyTargetStreamer : public MCTargetStreamer {
29public:
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 Schuff5859a9ed2016-06-03 18:34:36 +000040 /// .functype
41 virtual void emitIndirectFunctionType(StringRef name,
42 SmallVectorImpl<MVT> &SignatureVTs,
43 size_t NumResults) {
44 llvm_unreachable("emitIndirectFunctionType not implemented");
45 }
Derek Schuffc64d7652016-08-01 22:25:02 +000046 /// .indidx
47 virtual void emitIndIdx(const MCExpr *Value) = 0;
Dan Gohman3469ee12016-01-12 20:30:51 +000048};
49
50/// This part is for ascii assembly output
51class WebAssemblyTargetAsmStreamer final : public WebAssemblyTargetStreamer {
52 formatted_raw_ostream &OS;
53
54public:
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 Schuff5859a9ed2016-06-03 18:34:36 +000061 void emitIndirectFunctionType(StringRef name,
62 SmallVectorImpl<MVT> &SignatureVTs,
63 size_t NumResults) override;
Derek Schuffc64d7652016-08-01 22:25:02 +000064 void emitIndIdx(const MCExpr *Value) override;
Dan Gohman3469ee12016-01-12 20:30:51 +000065};
66
67/// This part is for ELF object output
68class WebAssemblyTargetELFStreamer final : public WebAssemblyTargetStreamer {
69public:
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 Schuffc64d7652016-08-01 22:25:02 +000076 void emitIndIdx(const MCExpr *Value) override;
Dan Gohman3469ee12016-01-12 20:30:51 +000077};
78
79} // end namespace llvm
80
81#endif