#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Allocator.h"
-#include "llvm/Support/Dump.h"
#include <cmath>
-#include <sstream>
namespace llvm {
/// FunctionSize - The number of instructions present in the function
uint64_t FunctionSize;
- typedef DenseMap<const MachineInstr*, unsigned> Mi2IndexMap;
+ typedef DenseMap<MachineInstr*, unsigned> Mi2IndexMap;
Mi2IndexMap mi2iMap_;
typedef std::vector<MachineInstr*> Index2MiMap;
}
/// getInstructionIndex - returns the base index of instr
- unsigned getInstructionIndex(const MachineInstr* instr) const {
+ unsigned getInstructionIndex(MachineInstr* instr) const {
Mi2IndexMap::const_iterator it = mi2iMap_.find(instr);
assert(it != mi2iMap_.end() && "Invalid instruction!");
return it->second;
void printRegName(unsigned reg) const;
};
- // IntervalPrefixPrinter - Print live interval indices before each
- // instruction.
- class IntervalPrefixPrinter : public PrefixPrinter {
- private:
- const LiveIntervals &liinfo;
-
- public:
- IntervalPrefixPrinter(const LiveIntervals &lii)
- : liinfo(lii) {};
-
- std::string operator()(const MachineBasicBlock &) const {
- return("");
- };
-
- std::string operator()(const MachineInstr &instr) const {
- std::stringstream out;
- out << liinfo.getInstructionIndex(&instr);
- return(out.str());
- };
- };
} // End llvm namespace
#endif
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/ADT/GraphTraits.h"
-#include "llvm/Support/Dump.h"
namespace llvm {
// Debugging methods.
void dump() const;
- void print(std::ostream &OS,
- const PrefixPrinter &prefix = PrefixPrinter()) const;
- void print(std::ostream *OS,
- const PrefixPrinter &prefix = PrefixPrinter()) const {
- if (OS) print(*OS, prefix);
- }
+ void print(std::ostream &OS) const;
+ void print(std::ostream *OS) const { if (OS) print(*OS); }
/// getNumber - MachineBasicBlocks are uniquely numbered at the function
/// level, unless they're not in a MachineFunction yet, in which case this
#include "llvm/ADT/ilist.h"
#include "llvm/Support/DebugLoc.h"
-#include "llvm/Support/Dump.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/Support/Annotation.h"
#include "llvm/Support/Allocator.h"
/// print - Print out the MachineFunction in a format suitable for debugging
/// to the specified stream.
///
- void print(std::ostream &OS,
- const PrefixPrinter &prefix = PrefixPrinter()) const;
- void print(std::ostream *OS,
- const PrefixPrinter &prefix = PrefixPrinter()) const {
- if (OS) print(*OS, prefix);
- }
+ void print(std::ostream &OS) const;
+ void print(std::ostream *OS) const { if (OS) print(*OS); }
/// viewCFG - This function is meant for use from the debugger. You can just
/// say 'call F->viewCFG()' and a ghostview window should pop up from the
+++ /dev/null
-//===- llvm/Support/Dump.h - Easy way to tailor dump output -----*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file provides the PrefixPrinter interface to pass to MachineFunction
-// and MachineBasicBlock print methods to output additional information before
-// blocks and instructions are printed.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_SUPPORT_DUMP_H
-#define LLVM_SUPPORT_DUMP_H
-
-namespace llvm {
-
-class MachineBasicBlock;
-class MachineInstr;
-
-// PrefixPrinter - Print some additional information before printing
-// basic blocks and instructions.
-class PrefixPrinter {
-public:
- virtual ~PrefixPrinter() {}
-
- virtual std::string operator()(const MachineBasicBlock &) const {
- return("");
- };
-
- virtual std::string operator()(const MachineInstr &) const {
- return("");
- };
-};
-
-} // End llvm namespace
-
-#endif
i2miMap_.resize(highestSlot + 1);
for (Mi2IndexMap::iterator MI = mi2iMap_.begin(), ME = mi2iMap_.end();
MI != ME; ++MI) {
- i2miMap_[MI->second] = const_cast<MachineInstr *>(MI->first);
+ i2miMap_[MI->second] = MI->first;
}
}
}
O << "********** MACHINEINSTRS **********\n";
- mf_->print(O, IntervalPrefixPrinter(*this));
+ for (MachineFunction::iterator mbbi = mf_->begin(), mbbe = mf_->end();
+ mbbi != mbbe; ++mbbi) {
+ O << ((Value*)mbbi->getBasicBlock())->getName() << ":\n";
+ for (MachineBasicBlock::iterator mii = mbbi->begin(),
+ mie = mbbi->end(); mii != mie; ++mii) {
+ O << getInstructionIndex(mii) << '\t' << *mii;
+ }
+ }
}
/// conflictsWithPhysRegDef - Returns true if the specified register
os << " %reg" << RegNo;
}
-void MachineBasicBlock::print(std::ostream &OS,
- const PrefixPrinter &prefix) const {
+void MachineBasicBlock::print(std::ostream &OS) const {
const MachineFunction *MF = getParent();
if(!MF) {
OS << "Can't print out MachineBasicBlock because parent MachineFunction"
}
for (const_iterator I = begin(); I != end(); ++I) {
- OS << prefix(*I);
OS << "\t";
I->print(OS, &getParent()->getTarget());
}
print(*cerr.stream());
}
-void MachineFunction::print(std::ostream &OS,
- const PrefixPrinter &prefix) const {
+void MachineFunction::print(std::ostream &OS) const {
OS << "# Machine code for " << Fn->getName () << "():\n";
// Print Frame Information
OS << "\n";
}
- for (const_iterator BB = begin(); BB != end(); ++BB) {
- OS << prefix(*BB);
- BB->print(OS, prefix);
- }
+ for (const_iterator BB = begin(); BB != end(); ++BB)
+ BB->print(OS);
OS << "\n# End machine code for " << Fn->getName () << "().\n\n";
}