LLVM  13.0.0git
SystemZInstPrinter.h
Go to the documentation of this file.
1 //==- SystemZInstPrinter.h - Convert SystemZ MCInst to assembly --*- 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 // This class prints a SystemZ MCInst to a .s file.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_LIB_TARGET_SYSTEMZ_MCTARGETDESC_SYSTEMZINSTPRINTER_H
14 #define LLVM_LIB_TARGET_SYSTEMZ_MCTARGETDESC_SYSTEMZINSTPRINTER_H
15 
16 #include "SystemZMCAsmInfo.h"
17 #include "llvm/MC/MCInstPrinter.h"
18 #include <cstdint>
19 
20 namespace llvm {
21 
22 class MCOperand;
23 
25 public:
27  const MCRegisterInfo &MRI)
28  : MCInstPrinter(MAI, MII, MRI) {}
29 
30  // Automatically generated by tblgen.
31  std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
32  void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O);
33  static const char *getRegisterName(unsigned RegNo);
34 
35  // Print an address with the given base, displacement and index.
36  static void printAddress(const MCAsmInfo *MAI, unsigned Base, int64_t Disp,
37  unsigned Index, raw_ostream &O);
38 
39  // Print the given operand.
40  static void printOperand(const MCOperand &MO, const MCAsmInfo *MAI,
41  raw_ostream &O);
42 
43  static void printFormattedRegName(const MCAsmInfo *MAI, unsigned RegNo,
44  raw_ostream &O);
45 
46  // Override MCInstPrinter.
47  inline void printRegName(raw_ostream &O, unsigned RegNo) const override {
48  printFormattedRegName(&MAI, RegNo, O);
49  }
50 
51  void printInst(const MCInst *MI, uint64_t Address, StringRef Annot,
52  const MCSubtargetInfo &STI, raw_ostream &O) override;
53 
54 private:
55  // Print various types of operand.
56  void printOperand(const MCInst *MI, int OpNum, raw_ostream &O);
57  void printOperand(const MCInst *MI, uint64_t /*Address*/, unsigned OpNum,
58  raw_ostream &O) {
59  printOperand(MI, OpNum, O);
60  }
61  void printBDAddrOperand(const MCInst *MI, int OpNum, raw_ostream &O);
62  void printBDXAddrOperand(const MCInst *MI, int OpNum, raw_ostream &O);
63  void printBDLAddrOperand(const MCInst *MI, int OpNum, raw_ostream &O);
64  void printBDRAddrOperand(const MCInst *MI, int OpNum, raw_ostream &O);
65  void printBDVAddrOperand(const MCInst *MI, int OpNum, raw_ostream &O);
66  void printU1ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
67  void printU2ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
68  void printU3ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
69  void printU4ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
70  void printU6ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
71  void printS8ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
72  void printU8ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
73  void printU12ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
74  void printS16ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
75  void printU16ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
76  void printS32ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
77  void printU32ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
78  void printU48ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
79  void printPCRelOperand(const MCInst *MI, int OpNum, raw_ostream &O);
80  void printPCRelOperand(const MCInst *MI, uint64_t /*Address*/, int OpNum,
81  raw_ostream &O) {
82  printPCRelOperand(MI, OpNum, O);
83  }
84  void printPCRelTLSOperand(const MCInst *MI, uint64_t Address, int OpNum,
85  raw_ostream &O);
86 
87  // Print the mnemonic for a condition-code mask ("ne", "lh", etc.)
88  // This forms part of the instruction name rather than the operand list.
89  void printCond4Operand(const MCInst *MI, int OpNum, raw_ostream &O);
90 };
91 
92 } // end namespace llvm
93 
94 #endif // LLVM_LIB_TARGET_SYSTEMZ_MCTARGETDESC_SYSTEMZINSTPRINTER_H
llvm::SystemZInstPrinter::getMnemonic
std::pair< const char *, uint64_t > getMnemonic(const MCInst *MI) override
Returns a pair containing the mnemonic for MI and the number of bits left for further processing by p...
llvm::MCInstPrinter::MII
const MCInstrInfo & MII
Definition: MCInstPrinter.h:50
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:102
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::SystemZInstPrinter::printInst
void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, const MCSubtargetInfo &STI, raw_ostream &O) override
Print the specified MCInst to the specified raw_ostream.
Definition: SystemZInstPrinter.cpp:70
llvm::MCAsmInfo
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
llvm::SystemZInstPrinter::printAddress
static void printAddress(const MCAsmInfo *MAI, unsigned Base, int64_t Disp, unsigned Index, raw_ostream &O)
Definition: SystemZInstPrinter.cpp:26
llvm::SystemZInstPrinter::getRegisterName
static const char * getRegisterName(unsigned RegNo)
llvm::SystemZInstPrinter::SystemZInstPrinter
SystemZInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)
Definition: SystemZInstPrinter.h:26
llvm::MCInst
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:184
llvm::SystemZInstPrinter::printOperand
static void printOperand(const MCOperand &MO, const MCAsmInfo *MAI, raw_ostream &O)
Definition: SystemZInstPrinter.cpp:43
llvm::MCInstPrinter::MRI
const MCRegisterInfo & MRI
Definition: MCInstPrinter.h:51
llvm::SystemZInstPrinter
Definition: SystemZInstPrinter.h:24
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
MCInstPrinter.h
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:179
Index
uint32_t Index
Definition: ELFObjHandler.cpp:84
llvm::MCInstPrinter
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:43
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::SystemZInstPrinter::printInstruction
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O)
llvm::MCRegisterInfo
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Definition: MCRegisterInfo.h:135
llvm::MCInstrInfo
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:25
llvm::MCInstPrinter::MAI
const MCAsmInfo & MAI
Definition: MCInstPrinter.h:49
llvm::MCOperand
Instances of this class represent operands of the MCInst class.
Definition: MCInst.h:36
llvm::SystemZInstPrinter::printFormattedRegName
static void printFormattedRegName(const MCAsmInfo *MAI, unsigned RegNo, raw_ostream &O)
Definition: SystemZInstPrinter.cpp:59
llvm::SystemZInstPrinter::printRegName
void printRegName(raw_ostream &O, unsigned RegNo) const override
Print the assembler register name.
Definition: SystemZInstPrinter.h:47
llvm::MCSubtargetInfo
Generic base class for all target subtargets.
Definition: MCSubtargetInfo.h:75
llvm::sampleprof::Base
@ Base
Definition: Discriminator.h:58
SystemZMCAsmInfo.h