| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
#ifndef LLVM_CODEGEN_MIRFORMATTER_H |
| 14 |
#define LLVM_CODEGEN_MIRFORMATTER_H |
| 15 |
|
| 16 |
#include "llvm/ADT/Optional.h" |
| 17 |
#include "llvm/CodeGen/PseudoSourceValue.h" |
| 18 |
#include "llvm/Support/raw_ostream.h" |
| 19 |
#include <cstdint> |
| 20 |
|
| 21 |
namespace llvm { |
| 22 |
|
| 23 |
class MachineFunction; |
| 24 |
class MachineInstr; |
| 25 |
struct PerFunctionMIParsingState; |
| 26 |
|
| 27 |
|
| 28 |
class MIRFormatter { |
| 29 |
public: |
| 30 |
typedef function_ref<bool(StringRef::iterator Loc, const Twine &)> |
| 31 |
ErrorCallbackType; |
| 32 |
|
| 33 |
MIRFormatter() = default; |
| 34 |
virtual ~MIRFormatter() = default; |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
virtual void printImm(raw_ostream &OS, const MachineInstr &MI, |
| 40 |
Optional<unsigned> OpIdx, int64_t Imm) const { |
| 41 |
OS << Imm; |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
virtual bool parseImmMnemonic(const unsigned OpCode, const unsigned OpIdx, |
| 47 |
StringRef Src, int64_t &Imm, |
| 48 |
ErrorCallbackType ErrorCallback) const { |
| 49 |
llvm_unreachable("target did not implement parsing MIR immediate mnemonic"); |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
virtual void |
| 56 |
printCustomPseudoSourceValue(raw_ostream &OS, ModuleSlotTracker &MST, |
| 57 |
const PseudoSourceValue &PSV) const { |
| 58 |
PSV.printCustom(OS); |
| 59 |
} |
| 60 |
|
| 61 |
|
| 62 |
virtual bool parseCustomPseudoSourceValue( |
| 63 |
StringRef Src, MachineFunction &MF, PerFunctionMIParsingState &PFS, |
| 64 |
const PseudoSourceValue *&PSV, ErrorCallbackType ErrorCallback) const { |
| 65 |
llvm_unreachable( |
| 66 |
"target did not implement parsing MIR custom pseudo source value"); |
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
static void printIRValue(raw_ostream &OS, const Value &V, |
| 73 |
ModuleSlotTracker &MST); |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
static bool parseIRValue(StringRef Src, MachineFunction &MF, |
| 79 |
PerFunctionMIParsingState &PFS, const Value *&V, |
| 80 |
ErrorCallbackType ErrorCallback); |
| 81 |
}; |
| 82 |
|
| 83 |
} |
| 84 |
|
| 85 |
#endif |