aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/PIC16
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-04-04 08:18:47 +0000
committerChris Lattner <sabre@nondot.org>2010-04-04 08:18:47 +0000
commit3eac1ed5c28f6fd3b670f996e71709c6b16ab9d6 (patch)
tree7a1e02b4ab0f3430a5094b2a99982ba04ddb2194 /lib/Target/PIC16
parent2ef7d86653f6a913948b533c525e1e3098485ab4 (diff)
downloadexternal_llvm-3eac1ed5c28f6fd3b670f996e71709c6b16ab9d6.zip
external_llvm-3eac1ed5c28f6fd3b670f996e71709c6b16ab9d6.tar.gz
external_llvm-3eac1ed5c28f6fd3b670f996e71709c6b16ab9d6.tar.bz2
Momentous day: remove the "O" member from AsmPrinter. Now all
"asm printering" happens through MCStreamer. This also Streamerizes PIC16 debug info, which escaped my attention. This removes a leak from LLVMTargetMachine of the 'legacy' output stream. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100327 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PIC16')
-rw-r--r--lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp7
-rw-r--r--lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h3
-rw-r--r--lib/Target/PIC16/PIC16DebugInfo.cpp45
-rw-r--r--lib/Target/PIC16/PIC16DebugInfo.h9
4 files changed, 33 insertions, 31 deletions
diff --git a/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp b/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp
index 12372f9..f388d96 100644
--- a/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp
+++ b/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp
@@ -29,16 +29,15 @@
#include "llvm/Target/TargetRegistry.h"
#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/FormattedStream.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/SmallString.h"
#include <cstring>
using namespace llvm;
#include "PIC16GenAsmWriter.inc"
-PIC16AsmPrinter::PIC16AsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
- MCStreamer &Streamer)
-: AsmPrinter(O, TM, Streamer), DbgInfo(O, TM.getMCAsmInfo()) {
+PIC16AsmPrinter::PIC16AsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
+: AsmPrinter(TM, Streamer), DbgInfo(Streamer, TM.getMCAsmInfo()) {
PTLI = static_cast<PIC16TargetLowering*>(TM.getTargetLowering());
PMAI = static_cast<const PIC16MCAsmInfo*>(TM.getMCAsmInfo());
PTOF = (PIC16TargetObjectFile *)&PTLI->getObjFileLowering();
diff --git a/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h b/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h
index 312c54e..e27778f 100644
--- a/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h
+++ b/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h
@@ -31,8 +31,7 @@
namespace llvm {
class VISIBILITY_HIDDEN PIC16AsmPrinter : public AsmPrinter {
public:
- explicit PIC16AsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
- MCStreamer &Streamer);
+ explicit PIC16AsmPrinter(TargetMachine &TM, MCStreamer &Streamer);
private:
virtual const char *getPassName() const {
return "PIC16 Assembly Printer";
diff --git a/lib/Target/PIC16/PIC16DebugInfo.cpp b/lib/Target/PIC16/PIC16DebugInfo.cpp
index a223540..5d86329 100644
--- a/lib/Target/PIC16/PIC16DebugInfo.cpp
+++ b/lib/Target/PIC16/PIC16DebugInfo.cpp
@@ -18,10 +18,10 @@
#include "llvm/GlobalVariable.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/MC/MCAsmInfo.h"
+#include "llvm/MC/MCStreamer.h"
#include "llvm/Support/DebugLoc.h"
-#include "llvm/Support/FormattedStream.h"
#include "llvm/ADT/SmallString.h"
-
+#include "llvm/ADT/StringExtras.h"
using namespace llvm;
/// PopulateDebugInfo - Populate the TypeNo, Aux[] and TagName from Ty.
@@ -267,7 +267,8 @@ void PIC16DbgInfo::ChangeDebugLoc(const MachineFunction &MF,
///
void PIC16DbgInfo::SwitchToLine(unsigned Line, bool IsInBeginFunction) {
if (CurLine == Line) return;
- if (!IsInBeginFunction) O << "\n\t.line " << Line << "\n";
+ if (!IsInBeginFunction)
+ OS.EmitRawText("\n\t.line " + Twine(Line));
CurLine = Line;
}
@@ -286,7 +287,7 @@ void PIC16DbgInfo::EndFunction(const MachineFunction &MF) {
void PIC16DbgInfo::EndModule(Module &M) {
if (! EmitDebugDirectives) return;
EmitVarDebugInfo(M);
- if (CurFile != "") O << "\n\t.eof";
+ if (CurFile != "") OS.EmitRawText(StringRef("\n\t.eof"));
}
/// EmitCompositeTypeElements - Emit debug information for members of a
@@ -410,22 +411,26 @@ void PIC16DbgInfo::EmitFunctEndDI(const Function *F, unsigned Line) {
///
void PIC16DbgInfo::EmitAuxEntry(const std::string VarName, int Aux[], int Num,
std::string TagName) {
- O << "\n\t.dim " << VarName << ", 1" ;
+ std::string Tmp;
// TagName is emitted in case of structure/union objects.
- if (TagName != "")
- O << ", " << TagName;
+ if (!TagName.empty()) Tmp += ", " + TagName;
+
for (int i = 0; i<Num; i++)
- O << "," << (Aux[i] && 0xff);
+ Tmp += "," + utostr(Aux[i] && 0xff);
+
+ OS.EmitRawText("\n\t.dim " + Twine(VarName) + ", 1" + Tmp);
}
/// EmitSymbol - Emit .def for a symbol. Value is offset for the member.
///
-void PIC16DbgInfo::EmitSymbol(std::string Name, short Class, unsigned short
- Type, unsigned long Value) {
- O << "\n\t" << ".def "<< Name << ", type = " << Type << ", class = "
- << Class;
+void PIC16DbgInfo::EmitSymbol(std::string Name, short Class,
+ unsigned short Type, unsigned long Value) {
+ std::string Tmp;
if (Value > 0)
- O << ", value = " << Value;
+ Tmp = ", value = " + utostr(Value);
+
+ OS.EmitRawText("\n\t.def " + Twine(Name) + ", type = " + utostr(Type) +
+ ", class = " + utostr(Class) + Tmp);
}
/// EmitVarDebugInfo - Emit debug information for all variables.
@@ -447,14 +452,13 @@ void PIC16DbgInfo::EmitVarDebugInfo(Module &M) {
PopulateDebugInfo(Ty, TypeNo, HasAux, Aux, TagName);
// Emit debug info only if type information is availaible.
if (TypeNo != PIC16Dbg::T_NULL) {
- O << "\n\t.type " << VarName << ", " << TypeNo;
+ OS.EmitRawText("\t.type " + Twine(VarName) + ", " + Twine(TypeNo));
short ClassNo = getStorageClass(DIGV);
- O << "\n\t.class " << VarName << ", " << ClassNo;
- if (HasAux)
+ OS.EmitRawText("\t.class " + Twine(VarName) + ", " + Twine(ClassNo));
+ if (HasAux)
EmitAuxEntry(VarName, Aux, PIC16Dbg::AuxSize, TagName);
}
}
- O << "\n";
}
/// SwitchToCU - Switch to a new compilation unit.
@@ -470,8 +474,9 @@ void PIC16DbgInfo::SwitchToCU(MDNode *CU) {
if ( FilePath == CurFile ) return;
// Else, close the current one and start a new.
- if (CurFile != "") O << "\n\t.eof";
- O << "\n\t.file\t\"" << FilePath << "\"\n" ;
+ if (CurFile != "")
+ OS.EmitRawText(StringRef("\t.eof"));
+ OS.EmitRawText("\n\t.file\t\"" + Twine(FilePath) + "\"");
CurFile = FilePath;
CurLine = 0;
}
@@ -480,6 +485,6 @@ void PIC16DbgInfo::SwitchToCU(MDNode *CU) {
///
void PIC16DbgInfo::EmitEOF() {
if (CurFile != "")
- O << "\n\t.EOF";
+ OS.EmitRawText(StringRef("\t.EOF"));
}
diff --git a/lib/Target/PIC16/PIC16DebugInfo.h b/lib/Target/PIC16/PIC16DebugInfo.h
index 54e27c7..031dcf0 100644
--- a/lib/Target/PIC16/PIC16DebugInfo.h
+++ b/lib/Target/PIC16/PIC16DebugInfo.h
@@ -20,6 +20,8 @@
namespace llvm {
class MachineFunction;
class DebugLoc;
+ class MCStreamer;
+
namespace PIC16Dbg {
enum VarType {
T_NULL,
@@ -88,10 +90,8 @@ namespace llvm {
};
}
- class formatted_raw_ostream;
-
class PIC16DbgInfo {
- formatted_raw_ostream &O;
+ MCStreamer &OS;
const MCAsmInfo *MAI;
std::string CurFile;
unsigned CurLine;
@@ -101,8 +101,7 @@ namespace llvm {
bool EmitDebugDirectives;
public:
- PIC16DbgInfo(formatted_raw_ostream &o, const MCAsmInfo *T)
- : O(o), MAI(T) {
+ PIC16DbgInfo(MCStreamer &os, const MCAsmInfo *T) : OS(os), MAI(T) {
CurFile = "";
CurLine = 0;
EmitDebugDirectives = false;