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 {
19class WebAssemblyTargetStreamer;
20
22public:
23 static char ID;
24
25private:
26 const WebAssemblySubtarget *Subtarget;
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();
51 return AsmPrinter::runOnMachineFunction(MF);
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
unsigned const MachineRegisterInfo * MRI
#define LLVM_LIBRARY_VISIBILITY
Definition: Compiler.h:137
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
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:90
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:42
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:72
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.
Definition: TargetMachine.h:83
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.
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:1886
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:856