llvm-6502/include/llvm/CodeGen/AsmFormatter.h
David Greene 62fe47a337 Make changes suggested by Chris and eliminate newly-added raw_ostream
hooks as they're no longer needed.

The major change with this patch is to make formatted_raw_ostream usable
by any client of raw_ostream.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75283 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-10 21:14:44 +00:00

66 lines
1.9 KiB
C++

//===-- llvm/CodeGen/AsmFormatter.h - Formatted asm framework ---*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains various I/O manipulators to pretty-print asm.
//
//===----------------------------------------------------------------------===//
#include "llvm/Support/FormattedStream.h"
#include "llvm/Target/TargetAsmInfo.h"
namespace llvm
{
/// AsmComment - An I/O manipulator to output an end-of-line comment
///
class AsmComment : public Column {
private:
/// CommentColumn - The column at which to output a comment
///
static const int CommentColumn = 60;
/// Text - The comment to output
///
std::string Text;
/// TAI - Target information from the code generator
///
const TargetAsmInfo &TAI;
public:
AsmComment(const TargetAsmInfo &T)
: Column(CommentColumn), Text(""), TAI(T) {}
AsmComment(const std::string &Cmnt,
const TargetAsmInfo &T)
: Column(CommentColumn), Text(Cmnt), TAI(T) {}
/// operator() - Store a comments tring for later processing.
///
AsmComment &operator()(const std::string &Cmnt) {
Text = Cmnt;
return *this;
}
/// operator() - Make Comment a functor invoktable by a stream
/// output operator. This intentially hides Column's operator().
///
formatted_raw_ostream &operator()(formatted_raw_ostream &Out) const {
Column::operator()(Out);
Out << TAI.getCommentString() << " " << Text;
return(Out);
}
};
/// operator<< - Support comment formatting in formatted streams.
///
inline formatted_raw_ostream &operator<<(formatted_raw_ostream &Out,
const AsmComment &Func)
{
return(Func(Out));
}
}