1//===- MIRPrinter.h - MIR serialization format printer ----------*- 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 file declares the functions that print out the LLVM IR and the machine
10// functions using the MIR serialization format.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CODEGEN_MIRPRINTER_H
15#define LLVM_CODEGEN_MIRPRINTER_H
16
17#include "llvm/CodeGen/MachinePassManager.h"
18#include "llvm/Support/raw_ostream.h"
19
20namespace llvm {
21
22class MachineBasicBlock;
23class MachineFunction;
24class Module;
25template <typename T> class SmallVectorImpl;
26
27class PrintMIRPreparePass : public MachinePassInfoMixin<PrintMIRPreparePass> {
28 raw_ostream &OS;
29
30public:
31 PrintMIRPreparePass(raw_ostream &OS = errs()) : OS(OS) {}
32 PreservedAnalyses run(Module &M, ModuleAnalysisManager &MFAM);
33};
34
35class PrintMIRPass : public MachinePassInfoMixin<PrintMIRPass> {
36 raw_ostream &OS;
37
38public:
39 PrintMIRPass(raw_ostream &OS = errs()) : OS(OS) {}
40 PreservedAnalyses run(MachineFunction &MF,
41 MachineFunctionAnalysisManager &MFAM);
42};
43
44/// Print LLVM IR using the MIR serialization format to the given output stream.
45void printMIR(raw_ostream &OS, const Module &M);
46
47/// Print a machine function using the MIR serialization format to the given
48/// output stream.
49void printMIR(raw_ostream &OS, const MachineFunction &MF);
50
51/// Determine a possible list of successors of a basic block based on the
52/// basic block machine operand being used inside the block. This should give
53/// you the correct list of successor blocks in most cases except for things
54/// like jump tables where the basic block references can't easily be found.
55/// The MIRPRinter will skip printing successors if they match the result of
56/// this function and the parser will use this function to construct a list if
57/// it is missing.
58void guessSuccessors(const MachineBasicBlock &MBB,
59 SmallVectorImpl<MachineBasicBlock*> &Result,
60 bool &IsFallthrough);
61
62} // end namespace llvm
63
64#endif
65

source code of llvm/include/llvm/CodeGen/MIRPrinter.h