LLVM 19.0.0git
WebAssemblyAsmPrinter.h
Go to the documentation of this file.
1// WebAssemblyAsmPrinter.h - WebAssembly implementation of AsmPrinter-*- 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-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYASMPRINTER_H
10#define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYASMPRINTER_H
11
15#include "llvm/MC/MCStreamer.h"
17
18namespace llvm {
19class WebAssemblyTargetStreamer;
20
22 const WebAssemblySubtarget *Subtarget;
25 bool signaturesEmitted = false;
26
27public:
29 std::unique_ptr<MCStreamer> Streamer)
30 : AsmPrinter(TM, std::move(Streamer)), Subtarget(nullptr), MRI(nullptr),
31 MFI(nullptr) {}
32
33 StringRef getPassName() const override {
34 return "WebAssembly Assembly Printer";
35 }
36
37 const WebAssemblySubtarget &getSubtarget() const { return *Subtarget; }
38
39 //===------------------------------------------------------------------===//
40 // MachineFunctionPass Implementation.
41 //===------------------------------------------------------------------===//
42
44 Subtarget = &MF.getSubtarget<WebAssemblySubtarget>();
45 MRI = &MF.getRegInfo();
47 return AsmPrinter::runOnMachineFunction(MF);
48 }
49
50 //===------------------------------------------------------------------===//
51 // AsmPrinter Implementation.
52 //===------------------------------------------------------------------===//
53
54 void emitEndOfAsmFile(Module &M) override;
55 void EmitProducerInfo(Module &M);
56 void EmitTargetFeatures(Module &M);
57 void EmitFunctionAttributes(Module &M);
58 void emitSymbolType(const MCSymbolWasm *Sym);
59 void emitGlobalVariable(const GlobalVariable *GV) override;
60 void emitJumpTableInfo() override;
61 void emitConstantPool() override;
62 void emitFunctionBodyStart() override;
63 void emitInstruction(const MachineInstr *MI) override;
64 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
65 const char *ExtraCode, raw_ostream &OS) override;
66 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
67 const char *ExtraCode, raw_ostream &OS) override;
68
69 MVT getRegType(unsigned RegNo) const;
70 std::string regToString(const MachineOperand &MO);
71 WebAssemblyTargetStreamer *getTargetStreamer();
72 MCSymbolWasm *getMCSymbolForFunction(const Function *F, bool EnableEmEH,
74 bool &InvokeDetected);
75 MCSymbol *getOrCreateWasmSymbol(StringRef Name);
76 void emitDecls(const Module &M);
77};
78
79} // end namespace llvm
80
81#endif
unsigned const MachineRegisterInfo * MRI
#define LLVM_LIBRARY_VISIBILITY
Definition: Compiler.h:131
static void emitConstantPool(MCStreamer &Streamer, MCSection *Section, ConstantPool &CP)
std::string Name
Symbol * Sym
Definition: ELF_riscv.cpp:479
IRTranslator LLVM IR MI
#define F(x, y, z)
Definition: MD5.cpp:55
const char LLVMTargetMachineRef TM
static yaml::StringValue regToString(Register Reg, const TargetRegisterInfo &TRI)
raw_pwrite_stream & OS
This file declares WebAssembly-specific per-machine-function information.
This file declares the WebAssembly-specific subclass of TargetSubtarget.
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:84
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:40
Machine Value Type.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
Representation of each machine instruction.
Definition: MachineInstr.h:69
MachineOperand class - Representation of each machine instruction operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:76
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.
const WebAssemblySubtarget & getSubtarget() const
WebAssemblyAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
bool runOnMachineFunction(MachineFunction &MF) override
Emit the specified function out to the OutStreamer.
This class is derived from MachineFunctionInfo and contains private WebAssembly-specific information ...
WebAssembly-specific streamer interface, to implement support WebAssembly-specific assembly directive...
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1849
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858