From 38caaf14c11aaef054cd60687d92c0248f7768f5 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 20 Jan 2010 06:39:07 +0000 Subject: [PATCH] give createAsmStreamer an 'isLittleEndian' argument. llvm-svn: 93986 --- llvm/include/llvm/MC/MCStreamer.h | 2 +- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 3 ++- llvm/lib/MC/MCAsmStreamer.cpp | 11 ++++++++--- llvm/tools/llvm-mc/llvm-mc.cpp | 5 ++++- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/llvm/include/llvm/MC/MCStreamer.h b/llvm/include/llvm/MC/MCStreamer.h index f1680a94e364..acd84f611972 100644 --- a/llvm/include/llvm/MC/MCStreamer.h +++ b/llvm/include/llvm/MC/MCStreamer.h @@ -235,7 +235,7 @@ namespace llvm { /// assembly for the native target, suitable for compiling with a native /// assembler. MCStreamer *createAsmStreamer(MCContext &Ctx, raw_ostream &OS, - const MCAsmInfo &MAI, + const MCAsmInfo &MAI, bool isLittleEndian, MCInstPrinter *InstPrint = 0, MCCodeEmitter *CE = 0); diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index e230affbb215..d439fb6e3c1b 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -58,7 +58,8 @@ AsmPrinter::AsmPrinter(formatted_raw_ostream &o, TargetMachine &tm, OutContext(*new MCContext()), // FIXME: Pass instprinter to streamer. - OutStreamer(*createAsmStreamer(OutContext, O, *T, 0)), + OutStreamer(*createAsmStreamer(OutContext, O, *T, + TM.getTargetData()->isLittleEndian(), 0)), LastMI(0), LastFn(0), Counter(~0U), PrevDLT(NULL) { DW = 0; MMI = 0; diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp index a126b5278631..23489095893e 100644 --- a/llvm/lib/MC/MCAsmStreamer.cpp +++ b/llvm/lib/MC/MCAsmStreamer.cpp @@ -28,15 +28,19 @@ namespace { class MCAsmStreamer : public MCStreamer { raw_ostream &OS; const MCAsmInfo &MAI; + bool IsLittleEndian; MCInstPrinter *InstPrinter; MCCodeEmitter *Emitter; public: MCAsmStreamer(MCContext &Context, raw_ostream &_OS, const MCAsmInfo &tai, - MCInstPrinter *_Printer, MCCodeEmitter *_Emitter) + bool isLittleEndian, MCInstPrinter *_Printer, + MCCodeEmitter *_Emitter) : MCStreamer(Context), OS(_OS), MAI(tai), InstPrinter(_Printer), Emitter(_Emitter) {} ~MCAsmStreamer() {} + bool isLittleEndian() const { return IsLittleEndian; } + /// @name MCStreamer Interface /// @{ @@ -337,7 +341,8 @@ void MCAsmStreamer::Finish() { } MCStreamer *llvm::createAsmStreamer(MCContext &Context, raw_ostream &OS, - const MCAsmInfo &MAI, MCInstPrinter *IP, + const MCAsmInfo &MAI, bool isLittleEndian, + MCInstPrinter *IP, MCCodeEmitter *CE) { - return new MCAsmStreamer(Context, OS, MAI, IP, CE); + return new MCAsmStreamer(Context, OS, MAI, isLittleEndian, IP, CE); } diff --git a/llvm/tools/llvm-mc/llvm-mc.cpp b/llvm/tools/llvm-mc/llvm-mc.cpp index 30cdfba57b50..c9d08ecb0c7b 100644 --- a/llvm/tools/llvm-mc/llvm-mc.cpp +++ b/llvm/tools/llvm-mc/llvm-mc.cpp @@ -28,6 +28,7 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/System/Signals.h" #include "llvm/Target/TargetAsmParser.h" +#include "llvm/Target/TargetData.h" #include "llvm/Target/TargetRegistry.h" #include "llvm/Target/TargetMachine.h" // FIXME. #include "llvm/Target/TargetSelect.h" @@ -263,7 +264,9 @@ static int AssembleInput(const char *ProgName) { IP.reset(TheTarget->createMCInstPrinter(OutputAsmVariant, *MAI, *Out)); if (ShowEncoding) CE.reset(TheTarget->createCodeEmitter(*TM)); - Str.reset(createAsmStreamer(Ctx, *Out, *MAI, IP.get(), CE.get())); + Str.reset(createAsmStreamer(Ctx, *Out, *MAI, + TM->getTargetData()->isLittleEndian(), + IP.get(), CE.get())); } else { assert(FileType == OFT_ObjectFile && "Invalid file type!"); CE.reset(TheTarget->createCodeEmitter(*TM));