LCOV - code coverage report
Current view: top level - lib/CodeGen - MIRPrintingPass.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 17 19 89.5 %
Date: 2018-05-20 00:06:23 Functions: 7 10 70.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- MIRPrintingPass.cpp - Pass that prints out using the MIR format ----===//
       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 implements a pass that prints out the LLVM module using the MIR
      11             : // serialization format.
      12             : //
      13             : //===----------------------------------------------------------------------===//
      14             : 
      15             : #include "llvm/CodeGen/MIRPrinter.h"
      16             : 
      17             : #include "llvm/CodeGen/MachineFunctionPass.h"
      18             : #include "llvm/CodeGen/Passes.h"
      19             : #include "llvm/Support/Debug.h"
      20             : #include "llvm/Support/raw_ostream.h"
      21             : 
      22             : using namespace llvm;
      23             : 
      24             : namespace {
      25             : 
      26             : /// This pass prints out the LLVM IR to an output stream using the MIR
      27             : /// serialization format.
      28        3069 : struct MIRPrintingPass : public MachineFunctionPass {
      29             :   static char ID;
      30             :   raw_ostream &OS;
      31             :   std::string MachineFunctions;
      32             : 
      33           0 :   MIRPrintingPass() : MachineFunctionPass(ID), OS(dbgs()) {}
      34        1063 :   MIRPrintingPass(raw_ostream &OS) : MachineFunctionPass(ID), OS(OS) {}
      35             : 
      36           2 :   StringRef getPassName() const override { return "MIR Printing Pass"; }
      37             : 
      38        1063 :   void getAnalysisUsage(AnalysisUsage &AU) const override {
      39             :     AU.setPreservesAll();
      40        1063 :     MachineFunctionPass::getAnalysisUsage(AU);
      41        1063 :   }
      42             : 
      43        3879 :   bool runOnMachineFunction(MachineFunction &MF) override {
      44             :     std::string Str;
      45        3879 :     raw_string_ostream StrOS(Str);
      46        3879 :     printMIR(StrOS, MF);
      47        3879 :     MachineFunctions.append(StrOS.str());
      48        3879 :     return false;
      49             :   }
      50             : 
      51         908 :   bool doFinalization(Module &M) override {
      52         908 :     printMIR(OS, M);
      53         908 :     OS << MachineFunctions;
      54         908 :     return false;
      55             :   }
      56             : };
      57             : 
      58             : char MIRPrintingPass::ID = 0;
      59             : 
      60             : } // end anonymous namespace
      61             : 
      62             : char &llvm::MIRPrintingPassID = MIRPrintingPass::ID;
      63           0 : INITIALIZE_PASS(MIRPrintingPass, "mir-printer", "MIR Printer", false, false)
      64             : 
      65             : namespace llvm {
      66             : 
      67        1063 : MachineFunctionPass *createPrintMIRPass(raw_ostream &OS) {
      68        2126 :   return new MIRPrintingPass(OS);
      69             : }
      70             : 
      71             : } // end namespace llvm

Generated by: LCOV version 1.13