llvm.org GIT mirror llvm / 3380d5c
revert r76602, 76603, and r76615, pending design discussions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76646 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 11 years ago
7 changed file(s) with 19 addition(s) and 90 deletion(s). Raw diff Collapse all Expand all
2626 #include "llvm/ADT/SmallPtrSet.h"
2727 #include "llvm/ADT/SmallVector.h"
2828 #include "llvm/Support/Allocator.h"
29 #include "llvm/Support/Dump.h"
3029 #include
31 #include
3230
3331 namespace llvm {
3432
8078 /// FunctionSize - The number of instructions present in the function
8179 uint64_t FunctionSize;
8280
83 typedef DenseMap<const MachineInstr*, unsigned> Mi2IndexMap;
81 typedef DenseMap<MachineInstr*, unsigned> Mi2IndexMap;
8482 Mi2IndexMap mi2iMap_;
8583
8684 typedef std::vector Index2MiMap;
199197 }
200198
201199 /// getInstructionIndex - returns the base index of instr
202 unsigned getInstructionIndex(const MachineInstr* instr) const {
200 unsigned getInstructionIndex(MachineInstr* instr) const {
203201 Mi2IndexMap::const_iterator it = mi2iMap_.find(instr);
204202 assert(it != mi2iMap_.end() && "Invalid instruction!");
205203 return it->second;
539537 void printRegName(unsigned reg) const;
540538 };
541539
542 // IntervalPrefixPrinter - Print live interval indices before each
543 // instruction.
544 class IntervalPrefixPrinter : public PrefixPrinter {
545 private:
546 const LiveIntervals &liinfo;
547
548 public:
549 IntervalPrefixPrinter(const LiveIntervals &lii)
550 : liinfo(lii) {};
551
552 std::string operator()(const MachineBasicBlock &) const {
553 return("");
554 };
555
556 std::string operator()(const MachineInstr &instr) const {
557 std::stringstream out;
558 out << liinfo.getInstructionIndex(&instr);
559 return(out.str());
560 };
561 };
562540 } // End llvm namespace
563541
564542 #endif
1515
1616 #include "llvm/CodeGen/MachineInstr.h"
1717 #include "llvm/ADT/GraphTraits.h"
18 #include "llvm/Support/Dump.h"
1918
2019 namespace llvm {
2120
309308
310309 // Debugging methods.
311310 void dump() const;
312 void print(std::ostream &OS,
313 const PrefixPrinter &prefix = PrefixPrinter()) const;
314 void print(std::ostream *OS,
315 const PrefixPrinter &prefix = PrefixPrinter()) const {
316 if (OS) print(*OS, prefix);
317 }
311 void print(std::ostream &OS) const;
312 void print(std::ostream *OS) const { if (OS) print(*OS); }
318313
319314 /// getNumber - MachineBasicBlocks are uniquely numbered at the function
320315 /// level, unless they're not in a MachineFunction yet, in which case this
1919
2020 #include "llvm/ADT/ilist.h"
2121 #include "llvm/Support/DebugLoc.h"
22 #include "llvm/Support/Dump.h"
2322 #include "llvm/CodeGen/MachineBasicBlock.h"
2423 #include "llvm/Support/Annotation.h"
2524 #include "llvm/Support/Allocator.h"
207206 /// print - Print out the MachineFunction in a format suitable for debugging
208207 /// to the specified stream.
209208 ///
210 void print(std::ostream &OS,
211 const PrefixPrinter &prefix = PrefixPrinter()) const;
212 void print(std::ostream *OS,
213 const PrefixPrinter &prefix = PrefixPrinter()) const {
214 if (OS) print(*OS, prefix);
215 }
209 void print(std::ostream &OS) const;
210 void print(std::ostream *OS) const { if (OS) print(*OS); }
216211
217212 /// viewCFG - This function is meant for use from the debugger. You can just
218213 /// say 'call F->viewCFG()' and a ghostview window should pop up from the
+0
-41
include/llvm/Support/Dump.h less more
None //===- llvm/Support/Dump.h - Easy way to tailor dump output -----*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file provides the PrefixPrinter interface to pass to MachineFunction
10 // and MachineBasicBlock print methods to output additional information before
11 // blocks and instructions are printed.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_SUPPORT_DUMP_H
16 #define LLVM_SUPPORT_DUMP_H
17
18 namespace llvm {
19
20 class MachineBasicBlock;
21 class MachineInstr;
22
23 // PrefixPrinter - Print some additional information before printing
24 // basic blocks and instructions.
25 class PrefixPrinter {
26 public:
27 virtual ~PrefixPrinter() {}
28
29 virtual std::string operator()(const MachineBasicBlock &) const {
30 return("");
31 };
32
33 virtual std::string operator()(const MachineInstr &) const {
34 return("");
35 };
36 };
37
38 } // End llvm namespace
39
40 #endif
463463 i2miMap_.resize(highestSlot + 1);
464464 for (Mi2IndexMap::iterator MI = mi2iMap_.begin(), ME = mi2iMap_.end();
465465 MI != ME; ++MI) {
466 i2miMap_[MI->second] = const_cast(MI->first);
466 i2miMap_[MI->second] = MI->first;
467467 }
468468
469469 }
500500 }
501501
502502 O << "********** MACHINEINSTRS **********\n";
503 mf_->print(O, IntervalPrefixPrinter(*this));
503 for (MachineFunction::iterator mbbi = mf_->begin(), mbbe = mf_->end();
504 mbbi != mbbe; ++mbbi) {
505 O << ((Value*)mbbi->getBasicBlock())->getName() << ":\n";
506 for (MachineBasicBlock::iterator mii = mbbi->begin(),
507 mie = mbbi->end(); mii != mie; ++mii) {
508 O << getInstructionIndex(mii) << '\t' << *mii;
509 }
510 }
504511 }
505512
506513 /// conflictsWithPhysRegDef - Returns true if the specified register
147147 os << " %reg" << RegNo;
148148 }
149149
150 void MachineBasicBlock::print(std::ostream &OS,
151 const PrefixPrinter &prefix) const {
150 void MachineBasicBlock::print(std::ostream &OS) const {
152151 const MachineFunction *MF = getParent();
153152 if(!MF) {
154153 OS << "Can't print out MachineBasicBlock because parent MachineFunction"
181180 }
182181
183182 for (const_iterator I = begin(); I != end(); ++I) {
184 OS << prefix(*I);
185183 OS << "\t";
186184 I->print(OS, &getParent()->getTarget());
187185 }
251251 print(*cerr.stream());
252252 }
253253
254 void MachineFunction::print(std::ostream &OS,
255 const PrefixPrinter &prefix) const {
254 void MachineFunction::print(std::ostream &OS) const {
256255 OS << "# Machine code for " << Fn->getName () << "():\n";
257256
258257 // Print Frame Information
294293 OS << "\n";
295294 }
296295
297 for (const_iterator BB = begin(); BB != end(); ++BB) {
298 OS << prefix(*BB);
299 BB->print(OS, prefix);
300 }
296 for (const_iterator BB = begin(); BB != end(); ++BB)
297 BB->print(OS);
301298
302299 OS << "\n# End machine code for " << Fn->getName () << "().\n\n";
303300 }