llvm-6502/include/llvm/Support/IOManip.h
David Greene b71d1b2fe2 Add support for printing loop structure information in asm comments.
This definitely slows down asm output so put it under an -asm-exuberant
flag.

This information is useful when doing static analysis of performance
issues.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78567 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-10 16:38:07 +00:00

44 lines
1.2 KiB
C++

//===----------------- IOManip.h - iostream manipulators ---------*- C++ -*===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Manipulators to do special-purpose formatting.
//
//===----------------------------------------------------------------------===//
namespace llvm {
/// Indent - Insert spaces into the character output stream. The
/// "level" is multiplied by the "scale" to calculate the number of
/// spaces to insert. "level" can represent something like loop
/// nesting level, for example.
///
class Indent {
public:
explicit Indent(int lvl, int amt = 2)
: level(lvl), scale(amt) {}
template<typename OStream>
OStream &operator()(OStream &out) const {
for(int i = 0; i < level*scale; ++i) {
out << " ";
}
return out;
}
private:
int level;
int scale;
};
template<typename OStream>
OStream &operator<<(OStream &out, const Indent &indent)
{
return(indent(out));
}
}