On Dec 15, 2006, at 3:31 PM, Bill Wendling wrote:

> That's reasonable. So then a better solution would be to keep
> everything in the .h file, but change operator<<(OStream&) to call
> the "print()" function directly. So something like this:
>
> #include <iosfwd>
>
> // ...
>
> OStream& operator<<(OStream &OS, const MachineBasicBlock &MBB) {
>    if (*OS.stream()) MBB->print(*OS.stream());
>    return OS;
> }
>
> I'm still working on a nice way of implementing something like this:
>
> template <typename StreamTy>
> class BaseStream {
>    StreamTy *stream;
> public:
>    operator StreamTy () { return *stream; }
> };
>
> but I'm having problems figuring out the "null" stream semantics
> (right now, it uses "stream = 0" as an indication that it's "null").
> But the above hack should suffice in the meantime.

This is better, nice catch Bill!

-Chris

>
> -bw
>
> On Dec 15, 2006, at 3:16 PM, Jeff Cohen wrote:
>
>> Chris asked me to not include <ostream> from header files, and to
>> move stuff out of the header files if possible to make it so.
>>
>> Bill Wendling wrote:
>>> Hold on. If you make these non-inlined, then the only chance for
>>> the compiler to remove potentially dead code (when o.stream() ==
>>> 0) is through link time optimizations. Because this is still
>>> compiled by GCC right now, this won't be done and debug outputs
>>> will still be in the code. That is, they won't output anything,
>>> but the call will still be there.
>>>
>>> -bw
>>>
>>> On Dec 15, 2006, at 2:57 PM, Jeff Cohen wrote:
>>>
>>>>
>>>>
>>>> Changes in directory llvm/lib/CodeGen:
>>>>
>>>> LiveInterval.cpp updated: 1.40 -> 1.41
>>>> MachineBasicBlock.cpp updated: 1.36 -> 1.37
>>>> MachineInstr.cpp updated: 1.138 -> 1.139
>>>> ---
>>>> Log message:
>>>>
>>>> An even better unbreakage...
>>>>
>>>> ---
>>>> Diffs of the changes:  (+24 -0)
>>>>
>>>>  LiveInterval.cpp      |    7 +++++++
>>>>  MachineBasicBlock.cpp |    5 +++++
>>>>  MachineInstr.cpp      |   12 ++++++++++++
>>>>  3 files changed, 24 insertions(+)
>>>>
>>>>
>>>> Index: llvm/lib/CodeGen/LiveInterval.cpp
>>>> diff -u llvm/lib/CodeGen/LiveInterval.cpp:1.40 llvm/lib/CodeGen/
>>>> LiveInterval.cpp:1.41
>>>> --- llvm/lib/CodeGen/LiveInterval.cpp:1.40    Wed Dec  6 19:30:31
>>>> 2006
>>>> +++ llvm/lib/CodeGen/LiveInterval.cpp    Fri Dec 15 16:57:14 2006
>>>> @@ -24,6 +24,7 @@
>>>>  #include "llvm/Target/MRegisterInfo.h"
>>>>  #include <algorithm>
>>>>  #include <map>
>>>> +#include <ostream>
>>>>  using namespace llvm;
>>>>
>>>>  // An example for liveAt():
>>>> @@ -509,3 +510,9 @@
>>>>  void LiveInterval::dump() const {
>>>>    cerr << *this << "\n";
>>>>  }
>>>> +
>>>> +
>>>> +OStream& llvm::operator<<(OStream& os, const LiveRange &LR) {
>>>> +  if (os.stream()) *os.stream() << LR;
>>>> +  return os;
>>>> +}
>>>>
>>>>
>>>> Index: llvm/lib/CodeGen/MachineBasicBlock.cpp
>>>> diff -u llvm/lib/CodeGen/MachineBasicBlock.cpp:1.36 llvm/lib/
>>>> CodeGen/MachineBasicBlock.cpp:1.37
>>>> --- llvm/lib/CodeGen/MachineBasicBlock.cpp:1.36    Thu Dec  7
>>>> 14:28:15 2006
>>>> +++ llvm/lib/CodeGen/MachineBasicBlock.cpp    Fri Dec 15 16:57:14
>>>> 2006
>>>> @@ -31,6 +31,11 @@
>>>>    return OS;
>>>>  }
>>>>
>>>> +OStream& llvm::operator<<(OStream &OS, const MachineBasicBlock
>>>> &MBB) {
>>>> +  if (OS.stream()) *OS.stream() << MBB;
>>>> +  return OS;
>>>> +}
>>>> +
>>>>  // MBBs start out as #-1. When a MBB is added to a
>>>> MachineFunction, it
>>>>  // gets the next available unique MBB number. If it is removed
>>>> from a
>>>>  // MachineFunction, it goes back to being #-1.
>>>>
>>>>
>>>> Index: llvm/lib/CodeGen/MachineInstr.cpp
>>>> diff -u llvm/lib/CodeGen/MachineInstr.cpp:1.138 llvm/lib/CodeGen/
>>>> MachineInstr.cpp:1.139
>>>> --- llvm/lib/CodeGen/MachineInstr.cpp:1.138    Wed Dec  6
>>>> 19:30:31 2006
>>>> +++ llvm/lib/CodeGen/MachineInstr.cpp    Fri Dec 15 16:57:14 2006
>>>> @@ -18,6 +18,7 @@
>>>>  #include "llvm/Target/MRegisterInfo.h"
>>>>  #include "llvm/Support/LeakDetector.h"
>>>>  #include "llvm/Support/Streams.h"
>>>> +#include <ostream>
>>>>  using namespace llvm;
>>>>
>>>>  /// MachineInstr ctor - This constructor creates a dummy
>>>> MachineInstr with
>>>> @@ -363,3 +364,14 @@
>>>>
>>>>    return OS;
>>>>  }
>>>> +
>>>> +OStream& llvm::operator<<(OStream& os, const MachineInstr&
>>>> minstr) {
>>>> +  if (os.stream()) *os.stream() << minstr;
>>>> +  return os;
>>>> +}
>>>> +
>>>> +OStream& llvm::operator<<(OStream& os, const MachineOperand&  
>>>> mop) {
>>>> +  if (os.stream()) *os.stream() << mop;
>>>> +  return os;
>>>> +}
>>>> +
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> llvm-commits mailing list
>>>> llvm-commits@cs.uiuc.edu
>>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>>
>>>
>>>
>>>
>>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits@cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

_______________________________________________
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to