brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.4 KiB · d1eb6f6 Raw
116 lines · c
1//==-- WebAssemblyTargetStreamer.h - WebAssembly Target Streamer -*- C++ -*-==//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8///9/// \file10/// This file declares WebAssembly-specific target streamer classes.11/// These are for implementing support for target-specific assembly directives.12///13//===----------------------------------------------------------------------===//14 15#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_MCTARGETDESC_WEBASSEMBLYTARGETSTREAMER_H16#define LLVM_LIB_TARGET_WEBASSEMBLY_MCTARGETDESC_WEBASSEMBLYTARGETSTREAMER_H17 18#include "llvm/BinaryFormat/Wasm.h"19#include "llvm/CodeGenTypes/MachineValueType.h"20#include "llvm/MC/MCStreamer.h"21 22namespace llvm {23 24class MCSymbolWasm;25class formatted_raw_ostream;26 27/// WebAssembly-specific streamer interface, to implement support28/// WebAssembly-specific assembly directives.29class WebAssemblyTargetStreamer : public MCTargetStreamer {30public:31  explicit WebAssemblyTargetStreamer(MCStreamer &S);32 33  /// .local34  virtual void emitLocal(ArrayRef<wasm::ValType> Types) = 0;35  /// .functype36  virtual void emitFunctionType(const MCSymbolWasm *Sym) = 0;37  /// .indidx38  virtual void emitIndIdx(const MCExpr *Value) = 0;39  /// .globaltype40  virtual void emitGlobalType(const MCSymbolWasm *Sym) = 0;41  /// .tabletype42  virtual void emitTableType(const MCSymbolWasm *Sym) = 0;43  /// .tagtype44  virtual void emitTagType(const MCSymbolWasm *Sym) = 0;45  /// .import_module46  virtual void emitImportModule(const MCSymbolWasm *Sym,47                                StringRef ImportModule) = 0;48  /// .import_name49  virtual void emitImportName(const MCSymbolWasm *Sym,50                              StringRef ImportName) = 0;51  /// .export_name52  virtual void emitExportName(const MCSymbolWasm *Sym,53                              StringRef ExportName) = 0;54 55protected:56  void emitValueType(wasm::ValType Type);57};58 59/// This part is for ascii assembly output60class WebAssemblyTargetAsmStreamer final : public WebAssemblyTargetStreamer {61  formatted_raw_ostream &OS;62 63public:64  WebAssemblyTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS);65 66  void emitLocal(ArrayRef<wasm::ValType> Types) override;67  void emitFunctionType(const MCSymbolWasm *Sym) override;68  void emitIndIdx(const MCExpr *Value) override;69  void emitGlobalType(const MCSymbolWasm *Sym) override;70  void emitTableType(const MCSymbolWasm *Sym) override;71  void emitTagType(const MCSymbolWasm *Sym) override;72  void emitImportModule(const MCSymbolWasm *Sym, StringRef ImportModule) override;73  void emitImportName(const MCSymbolWasm *Sym, StringRef ImportName) override;74  void emitExportName(const MCSymbolWasm *Sym, StringRef ExportName) override;75};76 77/// This part is for Wasm object output78class WebAssemblyTargetWasmStreamer final : public WebAssemblyTargetStreamer {79public:80  explicit WebAssemblyTargetWasmStreamer(MCStreamer &S);81 82  void emitLocal(ArrayRef<wasm::ValType> Types) override;83  void emitFunctionType(const MCSymbolWasm *Sym) override {}84  void emitIndIdx(const MCExpr *Value) override;85  void emitGlobalType(const MCSymbolWasm *Sym) override {}86  void emitTableType(const MCSymbolWasm *Sym) override {}87  void emitTagType(const MCSymbolWasm *Sym) override {}88  void emitImportModule(const MCSymbolWasm *Sym,89                        StringRef ImportModule) override {}90  void emitImportName(const MCSymbolWasm *Sym,91                      StringRef ImportName) override {}92  void emitExportName(const MCSymbolWasm *Sym,93                      StringRef ExportName) override {}94};95 96/// This part is for null output97class WebAssemblyTargetNullStreamer final : public WebAssemblyTargetStreamer {98public:99  explicit WebAssemblyTargetNullStreamer(MCStreamer &S)100      : WebAssemblyTargetStreamer(S) {}101 102  void emitLocal(ArrayRef<wasm::ValType>) override {}103  void emitFunctionType(const MCSymbolWasm *) override {}104  void emitIndIdx(const MCExpr *) override {}105  void emitGlobalType(const MCSymbolWasm *) override {}106  void emitTableType(const MCSymbolWasm *) override {}107  void emitTagType(const MCSymbolWasm *) override {}108  void emitImportModule(const MCSymbolWasm *, StringRef) override {}109  void emitImportName(const MCSymbolWasm *, StringRef) override {}110  void emitExportName(const MCSymbolWasm *, StringRef) override {}111};112 113} // end namespace llvm114 115#endif116