LLVM 24.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
16#include "llvm/IR/Analysis.h"
17#include "llvm/IR/PassManager.h"
18#include "llvm/MC/MCStreamer.h"
20
21namespace llvm {
23
25public:
26 static char ID;
27
28private:
29 const WebAssemblySubtarget *Subtarget;
30 const MachineRegisterInfo *MRI;
32 bool signaturesEmitted = false;
33
34public:
36 std::unique_ptr<MCStreamer> Streamer)
37 : AsmPrinter(TM, std::move(Streamer), ID), Subtarget(nullptr),
38 MRI(nullptr), MFI(nullptr) {}
39
40 StringRef getPassName() const override {
41 return "WebAssembly Assembly Printer";
42 }
43
44 const WebAssemblySubtarget &getSubtarget() const { return *Subtarget; }
45
46 //===------------------------------------------------------------------===//
47 // MachineFunctionPass Implementation.
48 //===------------------------------------------------------------------===//
49
51 Subtarget = &MF.getSubtarget<WebAssemblySubtarget>();
52 MRI = &MF.getRegInfo();
53 MFI = MF.getInfo<WebAssemblyFunctionInfo>();
55 }
56
57 //===------------------------------------------------------------------===//
58 // AsmPrinter Implementation.
59 //===------------------------------------------------------------------===//
60
61 void emitEndOfAsmFile(Module &M) override;
62 void EmitProducerInfo(Module &M);
63 void EmitTargetFeatures(Module &M);
64 void EmitFunctionAttributes(Module &M);
65 void emitSymbolType(const MCSymbolWasm *Sym);
66 void emitGlobalVariable(const GlobalVariable *GV) override;
67 void emitJumpTableInfo() override;
68 void emitConstantPool() override;
69 void emitFunctionBodyStart() override;
70 void emitInstruction(const MachineInstr *MI) override;
71 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
72 const char *ExtraCode, raw_ostream &OS) override;
73 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
74 const char *ExtraCode, raw_ostream &OS) override;
75
76 MVT getRegType(unsigned RegNo) const;
77 std::string regToString(const MachineOperand &MO);
78 WebAssemblyTargetStreamer *getTargetStreamer();
79 MCSymbolWasm *getMCSymbolForFunction(const Function *F,
81 bool &InvokeDetected);
82 MCSymbol *getOrCreateWasmSymbol(StringRef Name);
83 void emitDecls(const Module &M);
84};
85
87 : public RequiredPassInfoMixin<WebAssemblyAsmPrinterBeginPass> {
88public:
90};
91
93 : public RequiredPassInfoMixin<WebAssemblyAsmPrinterPass> {
94public:
97};
98
100 : public RequiredPassInfoMixin<WebAssemblyAsmPrinterEndPass> {
101public:
103};
104
105} // end namespace llvm
106
107#endif
#define LLVM_LIBRARY_VISIBILITY
Definition Compiler.h:137
static void emitConstantPool(MCStreamer &Streamer, MCSection *Section, ConstantPool &CP)
IRTranslator LLVM IR MI
This header defines various interfaces for pass management in LLVM.
#define F(x, y, z)
Definition MD5.cpp:54
ModuleAnalysisManager MAM
static yaml::StringValue regToString(Register Reg, const TargetRegisterInfo &TRI)
This file declares WebAssembly-specific per-machine-function information.
This file declares the WebAssembly-specific subclass of TargetSubtarget.
TargetMachine & TM
Target machine description.
Definition AsmPrinter.h:94
MachineFunction * MF
The current machine function.
Definition AsmPrinter.h:109
AsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer, char &ID=AsmPrinter::ID)
bool runOnMachineFunction(MachineFunction &MF) override
Emit the specified function out to the OutStreamer.
Definition AsmPrinter.h:453
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
Machine Value Type.
Representation of each machine instruction.
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:67
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Primary interface to the complete machine description for the target machine.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
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:53
Pass manager infrastructure for declaring and invalidating analyses.
This is an optimization pass for GlobalISel generic memory operations.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
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:1917
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Definition MIRParser.h:39
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:878
A CRTP mix-in for passes that should not be skipped.