LLVM  8.0.1
WebAssemblyAsmPrinter.h
Go to the documentation of this file.
1 // WebAssemblyAsmPrinter.h - WebAssembly implementation of AsmPrinter-*- C++ -*-
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYASMPRINTER_H
11 #define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYASMPRINTER_H
12 
14 #include "WebAssemblySubtarget.h"
16 #include "llvm/MC/MCStreamer.h"
18 
19 namespace llvm {
20 class MCSymbol;
21 class WebAssemblyTargetStreamer;
22 class WebAssemblyMCInstLower;
23 
25  const WebAssemblySubtarget *Subtarget;
26  const MachineRegisterInfo *MRI;
28  // TODO: Do the uniquing of Signatures here instead of ObjectFileWriter?
29  std::vector<std::unique_ptr<wasm::WasmSignature>> Signatures;
30 
31 public:
33  std::unique_ptr<MCStreamer> Streamer)
34  : AsmPrinter(TM, std::move(Streamer)), Subtarget(nullptr), MRI(nullptr),
35  MFI(nullptr) {}
36 
37  StringRef getPassName() const override {
38  return "WebAssembly Assembly Printer";
39  }
40 
41  const WebAssemblySubtarget &getSubtarget() const { return *Subtarget; }
42  void addSignature(std::unique_ptr<wasm::WasmSignature> &&Sig) {
43  Signatures.push_back(std::move(Sig));
44  }
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 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:24
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:65
Definition: BitVector.h:938
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:36
WebAssemblyAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
bool runOnMachineFunction(MachineFunction &MF) override
Emit the specified function out to the OutStreamer.
Definition: AsmPrinter.h:296
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:42
const WebAssemblySubtarget & getSubtarget() const
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:79
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
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:64
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.
#define LLVM_LIBRARY_VISIBILITY
LLVM_LIBRARY_VISIBILITY - If a class marked with this attribute is linked into a shared library...
Definition: Compiler.h:108
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:46
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:59
IRTranslator LLVM IR MI
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49