File indexing completed on 2026-05-10 08:43:32
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef LLVM_CODEGEN_MIRFORMATTER_H
0014 #define LLVM_CODEGEN_MIRFORMATTER_H
0015
0016 #include "llvm/CodeGen/PseudoSourceValue.h"
0017 #include "llvm/Support/ErrorHandling.h"
0018 #include "llvm/Support/raw_ostream.h"
0019 #include <cstdint>
0020 #include <optional>
0021
0022 namespace llvm {
0023
0024 class MachineFunction;
0025 class MachineInstr;
0026 class ModuleSlotTracker;
0027 struct PerFunctionMIParsingState;
0028 class Twine;
0029 class Value;
0030
0031
0032 class MIRFormatter {
0033 public:
0034 typedef function_ref<bool(StringRef::iterator Loc, const Twine &)>
0035 ErrorCallbackType;
0036
0037 MIRFormatter() = default;
0038 virtual ~MIRFormatter() = default;
0039
0040
0041
0042
0043 virtual void printImm(raw_ostream &OS, const MachineInstr &MI,
0044 std::optional<unsigned> OpIdx, int64_t Imm) const {
0045 OS << Imm;
0046 }
0047
0048
0049
0050 virtual bool parseImmMnemonic(const unsigned OpCode, const unsigned OpIdx,
0051 StringRef Src, int64_t &Imm,
0052 ErrorCallbackType ErrorCallback) const {
0053 llvm_unreachable("target did not implement parsing MIR immediate mnemonic");
0054 }
0055
0056
0057
0058
0059 virtual void
0060 printCustomPseudoSourceValue(raw_ostream &OS, ModuleSlotTracker &MST,
0061 const PseudoSourceValue &PSV) const {
0062 PSV.printCustom(OS);
0063 }
0064
0065
0066 virtual bool parseCustomPseudoSourceValue(
0067 StringRef Src, MachineFunction &MF, PerFunctionMIParsingState &PFS,
0068 const PseudoSourceValue *&PSV, ErrorCallbackType ErrorCallback) const {
0069 llvm_unreachable(
0070 "target did not implement parsing MIR custom pseudo source value");
0071 }
0072
0073
0074
0075
0076 static void printIRValue(raw_ostream &OS, const Value &V,
0077 ModuleSlotTracker &MST);
0078
0079
0080
0081
0082 static bool parseIRValue(StringRef Src, MachineFunction &MF,
0083 PerFunctionMIParsingState &PFS, const Value *&V,
0084 ErrorCallbackType ErrorCallback);
0085 };
0086
0087 }
0088
0089 #endif