LLVM  10.0.0
MIRFormatter.h
Go to the documentation of this file.
1 //===-- llvm/CodeGen/MIRFormatter.h -----------------------------*- 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 // This file contains the declaration of the MIRFormatter class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CODEGEN_MIRFORMATTER_H
15 #define LLVM_CODEGEN_MIRFORMATTER_H
16 
19 
20 namespace llvm {
21 
22 struct PerFunctionMIParsingState;
23 struct SlotMapping;
24 
25 /// MIRFormater - Interface to format MIR operand based on target
26 class MIRFormatter {
27 public:
30 
32  virtual ~MIRFormatter() = default;
33 
34  /// Implement target specific printing for machine operand immediate value, so
35  /// that we can have more meaningful mnemonic than a 64-bit integer. Passing
36  /// None to OpIdx means the index is unknown.
37  virtual void printImm(raw_ostream &OS, const MachineInstr &MI,
38  Optional<unsigned> OpIdx, int64_t Imm) const {
39  OS << Imm;
40  }
41 
42  /// Implement target specific parsing of immediate mnemonics. The mnemonic is
43  /// dot seperated strings.
44  virtual bool parseImmMnemonic(const unsigned OpCode, const unsigned OpIdx,
45  StringRef Src, int64_t &Imm,
46  ErrorCallbackType ErrorCallback) const {
47  llvm_unreachable("target did not implement parsing MIR immediate mnemonic");
48  }
49 
50  /// Implement target specific printing of target custom pseudo source value.
51  /// Default implementation is not necessarily the correct MIR serialization
52  /// format.
53  virtual void
55  const PseudoSourceValue &PSV) const {
56  PSV.printCustom(OS);
57  }
58 
59  /// Implement target specific parsing of target custom pseudo source value.
62  const PseudoSourceValue *&PSV, ErrorCallbackType ErrorCallback) const {
64  "target did not implement parsing MIR custom pseudo source value");
65  }
66 
67  /// Helper functions to print IR value as MIR serialization format which will
68  /// be useful for target specific printer, e.g. for printing IR value in
69  /// custom pseudo source value.
70  static void printIRValue(raw_ostream &OS, const Value &V,
71  ModuleSlotTracker &MST);
72 
73  /// Helper functions to parse IR value from MIR serialization format which
74  /// will be useful for target specific parser, e.g. for parsing IR value for
75  /// custom pseudo source value.
76  static bool parseIRValue(StringRef Src, MachineFunction &MF,
77  PerFunctionMIParsingState &PFS, const Value *&V,
78  ErrorCallbackType ErrorCallback);
79 };
80 
81 } // end namespace llvm
82 
83 #endif
static bool parseIRValue(StringRef Src, MachineFunction &MF, PerFunctionMIParsingState &PFS, const Value *&V, ErrorCallbackType ErrorCallback)
Helper functions to parse IR value from MIR serialization format which will be useful for target spec...
Definition: MIParser.cpp:3203
This class represents lattice values for constants.
Definition: AllocatorList.h:23
virtual ~MIRFormatter()=default
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:99
virtual void printCustomPseudoSourceValue(raw_ostream &OS, ModuleSlotTracker &MST, const PseudoSourceValue &PSV) const
Implement target specific printing of target custom pseudo source value.
Definition: MIRFormatter.h:54
Manage lifetime of a slot tracker for printing IR.
MIRFormater - Interface to format MIR operand based on target.
Definition: MIRFormatter.h:26
virtual void printImm(raw_ostream &OS, const MachineInstr &MI, Optional< unsigned > OpIdx, int64_t Imm) const
Implement target specific printing for machine operand immediate value, so that we can have more mean...
Definition: MIRFormatter.h:37
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
virtual bool parseCustomPseudoSourceValue(StringRef Src, MachineFunction &MF, PerFunctionMIParsingState &PFS, const PseudoSourceValue *&PSV, ErrorCallbackType ErrorCallback) const
Implement target specific parsing of target custom pseudo source value.
Definition: MIRFormatter.h:60
Special value supplied for machine level alias analysis.
Representation of each machine instruction.
Definition: MachineInstr.h:63
static void printIRValue(raw_ostream &OS, const Value &V, ModuleSlotTracker &MST)
Helper functions to print IR value as MIR serialization format which will be useful for target specif...
Definition: MIRPrinter.cpp:877
virtual bool parseImmMnemonic(const unsigned OpCode, const unsigned OpIdx, StringRef Src, int64_t &Imm, ErrorCallbackType ErrorCallback) const
Implement target specific parsing of immediate mnemonics.
Definition: MIRFormatter.h:44
LLVM Value Representation.
Definition: Value.h:74
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46
IRTranslator LLVM IR MI
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:54
function_ref< bool(StringRef::iterator Loc, const Twine &)> ErrorCallbackType
Definition: MIRFormatter.h:29