Path: blob/main/contrib/llvm-project/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h
35294 views
//==-- WebAssemblyTargetStreamer.h - WebAssembly Target Streamer -*- C++ -*-==//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7///8/// \file9/// This file declares WebAssembly-specific target streamer classes.10/// These are for implementing support for target-specific assembly directives.11///12//===----------------------------------------------------------------------===//1314#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_MCTARGETDESC_WEBASSEMBLYTARGETSTREAMER_H15#define LLVM_LIB_TARGET_WEBASSEMBLY_MCTARGETDESC_WEBASSEMBLYTARGETSTREAMER_H1617#include "llvm/BinaryFormat/Wasm.h"18#include "llvm/CodeGenTypes/MachineValueType.h"19#include "llvm/MC/MCStreamer.h"2021namespace llvm {2223class MCSymbolWasm;24class formatted_raw_ostream;2526/// WebAssembly-specific streamer interface, to implement support27/// WebAssembly-specific assembly directives.28class WebAssemblyTargetStreamer : public MCTargetStreamer {29public:30explicit WebAssemblyTargetStreamer(MCStreamer &S);3132/// .local33virtual void emitLocal(ArrayRef<wasm::ValType> Types) = 0;34/// .functype35virtual void emitFunctionType(const MCSymbolWasm *Sym) = 0;36/// .indidx37virtual void emitIndIdx(const MCExpr *Value) = 0;38/// .globaltype39virtual void emitGlobalType(const MCSymbolWasm *Sym) = 0;40/// .tabletype41virtual void emitTableType(const MCSymbolWasm *Sym) = 0;42/// .tagtype43virtual void emitTagType(const MCSymbolWasm *Sym) = 0;44/// .import_module45virtual void emitImportModule(const MCSymbolWasm *Sym,46StringRef ImportModule) = 0;47/// .import_name48virtual void emitImportName(const MCSymbolWasm *Sym,49StringRef ImportName) = 0;50/// .export_name51virtual void emitExportName(const MCSymbolWasm *Sym,52StringRef ExportName) = 0;5354protected:55void emitValueType(wasm::ValType Type);56};5758/// This part is for ascii assembly output59class WebAssemblyTargetAsmStreamer final : public WebAssemblyTargetStreamer {60formatted_raw_ostream &OS;6162public:63WebAssemblyTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS);6465void emitLocal(ArrayRef<wasm::ValType> Types) override;66void emitFunctionType(const MCSymbolWasm *Sym) override;67void emitIndIdx(const MCExpr *Value) override;68void emitGlobalType(const MCSymbolWasm *Sym) override;69void emitTableType(const MCSymbolWasm *Sym) override;70void emitTagType(const MCSymbolWasm *Sym) override;71void emitImportModule(const MCSymbolWasm *Sym, StringRef ImportModule) override;72void emitImportName(const MCSymbolWasm *Sym, StringRef ImportName) override;73void emitExportName(const MCSymbolWasm *Sym, StringRef ExportName) override;74};7576/// This part is for Wasm object output77class WebAssemblyTargetWasmStreamer final : public WebAssemblyTargetStreamer {78public:79explicit WebAssemblyTargetWasmStreamer(MCStreamer &S);8081void emitLocal(ArrayRef<wasm::ValType> Types) override;82void emitFunctionType(const MCSymbolWasm *Sym) override {}83void emitIndIdx(const MCExpr *Value) override;84void emitGlobalType(const MCSymbolWasm *Sym) override {}85void emitTableType(const MCSymbolWasm *Sym) override {}86void emitTagType(const MCSymbolWasm *Sym) override {}87void emitImportModule(const MCSymbolWasm *Sym,88StringRef ImportModule) override {}89void emitImportName(const MCSymbolWasm *Sym,90StringRef ImportName) override {}91void emitExportName(const MCSymbolWasm *Sym,92StringRef ExportName) override {}93};9495/// This part is for null output96class WebAssemblyTargetNullStreamer final : public WebAssemblyTargetStreamer {97public:98explicit WebAssemblyTargetNullStreamer(MCStreamer &S)99: WebAssemblyTargetStreamer(S) {}100101void emitLocal(ArrayRef<wasm::ValType>) override {}102void emitFunctionType(const MCSymbolWasm *) override {}103void emitIndIdx(const MCExpr *) override {}104void emitGlobalType(const MCSymbolWasm *) override {}105void emitTableType(const MCSymbolWasm *) override {}106void emitTagType(const MCSymbolWasm *) override {}107void emitImportModule(const MCSymbolWasm *, StringRef) override {}108void emitImportName(const MCSymbolWasm *, StringRef) override {}109void emitExportName(const MCSymbolWasm *, StringRef) override {}110};111112} // end namespace llvm113114#endif115116117