From 1658202529cf371e7e5f1a46d9ef80def5b3c3e0 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93986 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCStreamer.h | 2 +- lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 3 ++- lib/MC/MCAsmStreamer.cpp | 11 ++++++++--- tools/llvm-mc/llvm-mc.cpp | 5 ++++- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index f1680a94e36..acd84f61197 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/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/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index e230affbb21..d439fb6e3c1 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/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/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp index a126b527863..23489095893 100644 --- a/lib/MC/MCAsmStreamer.cpp +++ b/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/tools/llvm-mc/llvm-mc.cpp b/tools/llvm-mc/llvm-mc.cpp index 30cdfba57b5..c9d08ecb0c7 100644 --- a/tools/llvm-mc/llvm-mc.cpp +++ b/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));