LLVM 22.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 {
20
22public:
23 static char ID;
24
25private:
26 const WebAssemblySubtarget *Subtarget;
27 const MachineRegisterInfo *MRI;
29 bool signaturesEmitted = false;
30
31public:
33 std::unique_ptr<MCStreamer> Streamer)
34 : AsmPrinter(TM, std::move(Streamer), ID), Subtarget(nullptr),
35 MRI(nullptr), MFI(nullptr) {}
36
37 StringRef getPassName() const override {
38 return "WebAssembly Assembly Printer";
39 }
40
41 const WebAssemblySubtarget &getSubtarget() const { return *Subtarget; }
42
43 //===------------------------------------------------------------------===//
44 // MachineFunctionPass Implementation.
45 //===------------------------------------------------------------------===//
46
48 Subtarget = &MF.getSubtarget<WebAssemblySubtarget>();
49 MRI = &MF.getRegInfo();
50 MFI = MF.getInfo<WebAssemblyFunctionInfo>();
52 }
53
54 //===------------------------------------------------------------------===//
55 // AsmPrinter Implementation.
56 //===------------------------------------------------------------------===//
57
58 void emitEndOfAsmFile(Module &M) override;
59 void EmitProducerInfo(Module &M);
60 void EmitTargetFeatures(Module &M);
61 void EmitFunctionAttributes(Module &M);
62 void emitSymbolType(const MCSymbolWasm *Sym);
63 void emitGlobalVariable(const GlobalVariable *GV) override;
64 void emitJumpTableInfo() override;
65 void emitConstantPool() override;
66 void emitFunctionBodyStart() override;
67 void emitInstruction(const MachineInstr *MI) override;
68 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
69 const char *ExtraCode, raw_ostream &OS) override;
70 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
71 const char *ExtraCode, raw_ostream &OS) override;
72
73 MVT getRegType(unsigned RegNo) const;
74 std::string regToString(const MachineOperand &MO);
75 WebAssemblyTargetStreamer *getTargetStreamer();
76 MCSymbolWasm *getMCSymbolForFunction(const Function *F,
78 bool &InvokeDetected);
79 MCSymbol *getOrCreateWasmSymbol(StringRef Name);
80 void emitDecls(const Module &M);
81};
82
83} // end namespace llvm
84
85#endif
#define LLVM_LIBRARY_VISIBILITY
Definition Compiler.h:137
static void emitConstantPool(MCStreamer &Streamer, MCSection *Section, ConstantPool &CP)
IRTranslator LLVM IR MI
#define F(x, y, z)
Definition MD5.cpp:55
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:93
MachineFunction * MF
The current machine function.
Definition AsmPrinter.h:108
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:452
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
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
Primary interface to the complete machine description for the target machine.
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
This is an optimization pass for GlobalISel generic memory operations.
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:851