LLVM  9.0.0svn
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 
13 #include "WebAssemblySubtarget.h"
15 #include "llvm/MC/MCStreamer.h"
17 
18 namespace llvm {
19 class MCSymbol;
20 class WebAssemblyTargetStreamer;
21 class WebAssemblyMCInstLower;
22 
24  const WebAssemblySubtarget *Subtarget;
25  const MachineRegisterInfo *MRI;
27  // TODO: Do the uniquing of Signatures here instead of ObjectFileWriter?
28  std::vector<std::unique_ptr<wasm::WasmSignature>> Signatures;
29 
30 public:
32  std::unique_ptr<MCStreamer> Streamer)
33  : AsmPrinter(TM, std::move(Streamer)), Subtarget(nullptr), MRI(nullptr),
34  MFI(nullptr) {}
35 
36  StringRef getPassName() const override {
37  return "WebAssembly Assembly Printer";
38  }
39 
40  const WebAssemblySubtarget &getSubtarget() const { return *Subtarget; }
41  void addSignature(std::unique_ptr<wasm::WasmSignature> &&Sig) {
42  Signatures.push_back(std::move(Sig));
43  }
44 
45  //===------------------------------------------------------------------===//
46  // MachineFunctionPass Implementation.
47  //===------------------------------------------------------------------===//
48 
50  Subtarget = &MF.getSubtarget<WebAssemblySubtarget>();
51  MRI = &MF.getRegInfo();
52  MFI = MF.getInfo<WebAssemblyFunctionInfo>();
54  }
55 
56  //===------------------------------------------------------------------===//
57  // AsmPrinter Implementation.
58  //===------------------------------------------------------------------===//
59 
60  void EmitEndOfAsmFile(Module &M) override;
61  void EmitProducerInfo(Module &M);
62  void EmitJumpTableInfo() override;
63  void EmitConstantPool() override;
64  void EmitFunctionBodyStart() override;
65  void EmitInstruction(const MachineInstr *MI) override;
66  const MCExpr *lowerConstant(const Constant *CV) override;
67  bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
68  unsigned AsmVariant, const char *ExtraCode,
69  raw_ostream &OS) override;
70  bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
71  unsigned AsmVariant, const char *ExtraCode,
72  raw_ostream &OS) override;
73 
74  MVT getRegType(unsigned RegNo) const;
75  std::string regToString(const MachineOperand &MO);
76  WebAssemblyTargetStreamer *getTargetStreamer();
77 };
78 
79 } // end namespace llvm
80 
81 #endif
This class represents lattice values for constants.
Definition: AllocatorList.h:23
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:64
Definition: BitVector.h:937
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
WebAssemblyAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
bool runOnMachineFunction(MachineFunction &MF) override
Emit the specified function out to the OutStreamer.
Definition: AsmPrinter.h:298
WebAssembly-specific streamer interface, to implement support WebAssembly-specific assembly directive...
unsigned const MachineRegisterInfo * MRI
Machine Value Type.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
This is an important base class in LLVM.
Definition: Constant.h:41
const WebAssemblySubtarget & getSubtarget() const
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:78
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
#define LLVM_LIBRARY_VISIBILITY
LLVM_LIBRARY_VISIBILITY - If a class marked with this attribute is linked into a shared library...
Definition: Compiler.h:107
void addSignature(std::unique_ptr< wasm::WasmSignature > &&Sig)
This file declares the WebAssembly-specific subclass of TargetSubtarget.
MachineOperand class - Representation of each machine instruction operand.
bool runOnMachineFunction(MachineFunction &MF) override
Emit the specified function out to the OutStreamer.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Representation of each machine instruction.
Definition: MachineInstr.h:63
This class is derived from MachineFunctionInfo and contains private WebAssembly-specific information ...
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
This file declares WebAssembly-specific per-machine-function information.
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:58
IRTranslator LLVM IR MI
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48