From 5eb0c8a2bd33a18f6c1e1560b134de14ad91f5d4 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 22 Jan 2010 07:06:15 +0000 Subject: [PATCH] pass "-fasm-verbose" into createAsmStreamer. llvm-svn: 94165 --- include/llvm/MC/MCStreamer.h | 1 + lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 18 ++++++++++++------ lib/MC/MCAsmStreamer.cpp | 17 +++++++++-------- tools/llvm-mc/llvm-mc.cpp | 2 +- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index acd84f61197..1afa6dcdf68 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -236,6 +236,7 @@ namespace llvm { /// assembler. MCStreamer *createAsmStreamer(MCContext &Ctx, raw_ostream &OS, const MCAsmInfo &MAI, bool isLittleEndian, + bool isVerboseAsm, MCInstPrinter *InstPrint = 0, MCCodeEmitter *CE = 0); diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 32e9036af94..d5ae71f8ea2 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -50,6 +50,15 @@ static cl::opt AsmVerbose("asm-verbose", cl::desc("Add comments to directives."), cl::init(cl::BOU_UNSET)); +static bool getVerboseAsm(bool VDef) { + switch (AsmVerbose) { + default: + case cl::BOU_UNSET: return VDef; + case cl::BOU_TRUE: return true; + case cl::BOU_FALSE: return false; + } +} + char AsmPrinter::ID = 0; AsmPrinter::AsmPrinter(formatted_raw_ostream &o, TargetMachine &tm, const MCAsmInfo *T, bool VDef) @@ -59,15 +68,12 @@ AsmPrinter::AsmPrinter(formatted_raw_ostream &o, TargetMachine &tm, OutContext(*new MCContext()), // FIXME: Pass instprinter to streamer. OutStreamer(*createAsmStreamer(OutContext, O, *T, - TM.getTargetData()->isLittleEndian(), 0)), + TM.getTargetData()->isLittleEndian(), + getVerboseAsm(VDef), 0)), LastMI(0), LastFn(0), Counter(~0U), PrevDLT(NULL) { DW = 0; MMI = 0; - switch (AsmVerbose) { - case cl::BOU_UNSET: VerboseAsm = VDef; break; - case cl::BOU_TRUE: VerboseAsm = true; break; - case cl::BOU_FALSE: VerboseAsm = false; break; - } + VerboseAsm = getVerboseAsm(VDef); } AsmPrinter::~AsmPrinter() { diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp index 9e5eacc7a18..79cb6474295 100644 --- a/lib/MC/MCAsmStreamer.cpp +++ b/lib/MC/MCAsmStreamer.cpp @@ -28,15 +28,15 @@ namespace { class MCAsmStreamer : public MCStreamer { raw_ostream &OS; const MCAsmInfo &MAI; - bool IsLittleEndian; + bool IsLittleEndian, IsVerboseAsm; MCInstPrinter *InstPrinter; MCCodeEmitter *Emitter; public: - MCAsmStreamer(MCContext &Context, raw_ostream &_OS, const MCAsmInfo &tai, - bool isLittleEndian, MCInstPrinter *_Printer, - MCCodeEmitter *_Emitter) - : MCStreamer(Context), OS(_OS), MAI(tai), IsLittleEndian(isLittleEndian), - InstPrinter(_Printer), Emitter(_Emitter) {} + MCAsmStreamer(MCContext &Context, raw_ostream &os, const MCAsmInfo &mai, + bool isLittleEndian, bool isVerboseAsm, MCInstPrinter *printer, + MCCodeEmitter *emitter) + : MCStreamer(Context), OS(os), MAI(mai), IsLittleEndian(isLittleEndian), + IsVerboseAsm(isVerboseAsm), InstPrinter(printer), Emitter(emitter) {} ~MCAsmStreamer() {} bool isLittleEndian() const { return IsLittleEndian; } @@ -351,7 +351,8 @@ void MCAsmStreamer::Finish() { MCStreamer *llvm::createAsmStreamer(MCContext &Context, raw_ostream &OS, const MCAsmInfo &MAI, bool isLittleEndian, - MCInstPrinter *IP, + bool isVerboseAsm, MCInstPrinter *IP, MCCodeEmitter *CE) { - return new MCAsmStreamer(Context, OS, MAI, isLittleEndian, IP, CE); + return new MCAsmStreamer(Context, OS, MAI, isLittleEndian, isVerboseAsm, + IP, CE); } diff --git a/tools/llvm-mc/llvm-mc.cpp b/tools/llvm-mc/llvm-mc.cpp index f49738bd0e8..342ae99b537 100644 --- a/tools/llvm-mc/llvm-mc.cpp +++ b/tools/llvm-mc/llvm-mc.cpp @@ -266,7 +266,7 @@ static int AssembleInput(const char *ProgName) { CE.reset(TheTarget->createCodeEmitter(*TM)); Str.reset(createAsmStreamer(Ctx, *Out, *MAI, TM->getTargetData()->isLittleEndian(), - IP.get(), CE.get())); + /*asmverbose*/true, IP.get(), CE.get())); } else { assert(FileType == OFT_ObjectFile && "Invalid file type!"); CE.reset(TheTarget->createCodeEmitter(*TM));