Path: blob/main/contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.h
35294 views
// WebAssemblyAsmPrinter.h - WebAssembly implementation of AsmPrinter-*- 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//===----------------------------------------------------------------------===//78#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYASMPRINTER_H9#define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYASMPRINTER_H1011#include "WebAssemblyMachineFunctionInfo.h"12#include "WebAssemblySubtarget.h"13#include "llvm/CodeGen/AsmPrinter.h"14#include "llvm/MC/MCStreamer.h"15#include "llvm/Target/TargetMachine.h"1617namespace llvm {18class WebAssemblyTargetStreamer;1920class LLVM_LIBRARY_VISIBILITY WebAssemblyAsmPrinter final : public AsmPrinter {21const WebAssemblySubtarget *Subtarget;22const MachineRegisterInfo *MRI;23WebAssemblyFunctionInfo *MFI;24bool signaturesEmitted = false;2526public:27explicit WebAssemblyAsmPrinter(TargetMachine &TM,28std::unique_ptr<MCStreamer> Streamer)29: AsmPrinter(TM, std::move(Streamer)), Subtarget(nullptr), MRI(nullptr),30MFI(nullptr) {}3132StringRef getPassName() const override {33return "WebAssembly Assembly Printer";34}3536const WebAssemblySubtarget &getSubtarget() const { return *Subtarget; }3738//===------------------------------------------------------------------===//39// MachineFunctionPass Implementation.40//===------------------------------------------------------------------===//4142bool runOnMachineFunction(MachineFunction &MF) override {43Subtarget = &MF.getSubtarget<WebAssemblySubtarget>();44MRI = &MF.getRegInfo();45MFI = MF.getInfo<WebAssemblyFunctionInfo>();46return AsmPrinter::runOnMachineFunction(MF);47}4849//===------------------------------------------------------------------===//50// AsmPrinter Implementation.51//===------------------------------------------------------------------===//5253void emitEndOfAsmFile(Module &M) override;54void EmitProducerInfo(Module &M);55void EmitTargetFeatures(Module &M);56void EmitFunctionAttributes(Module &M);57void emitSymbolType(const MCSymbolWasm *Sym);58void emitGlobalVariable(const GlobalVariable *GV) override;59void emitJumpTableInfo() override;60void emitConstantPool() override;61void emitFunctionBodyStart() override;62void emitInstruction(const MachineInstr *MI) override;63bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,64const char *ExtraCode, raw_ostream &OS) override;65bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,66const char *ExtraCode, raw_ostream &OS) override;6768MVT getRegType(unsigned RegNo) const;69std::string regToString(const MachineOperand &MO);70WebAssemblyTargetStreamer *getTargetStreamer();71MCSymbolWasm *getMCSymbolForFunction(const Function *F, bool EnableEmEH,72wasm::WasmSignature *Sig,73bool &InvokeDetected);74MCSymbol *getOrCreateWasmSymbol(StringRef Name);75void emitDecls(const Module &M);76};7778} // end namespace llvm7980#endif818283