pass "-fasm-verbose" into createAsmStreamer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94165 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-01-22 07:06:15 +00:00
parent e73a31f667
commit 07404415ab
4 changed files with 23 additions and 15 deletions

View File

@ -236,6 +236,7 @@ namespace llvm {
/// assembler. /// assembler.
MCStreamer *createAsmStreamer(MCContext &Ctx, raw_ostream &OS, MCStreamer *createAsmStreamer(MCContext &Ctx, raw_ostream &OS,
const MCAsmInfo &MAI, bool isLittleEndian, const MCAsmInfo &MAI, bool isLittleEndian,
bool isVerboseAsm,
MCInstPrinter *InstPrint = 0, MCInstPrinter *InstPrint = 0,
MCCodeEmitter *CE = 0); MCCodeEmitter *CE = 0);

View File

@ -50,6 +50,15 @@ static cl::opt<cl::boolOrDefault>
AsmVerbose("asm-verbose", cl::desc("Add comments to directives."), AsmVerbose("asm-verbose", cl::desc("Add comments to directives."),
cl::init(cl::BOU_UNSET)); 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; char AsmPrinter::ID = 0;
AsmPrinter::AsmPrinter(formatted_raw_ostream &o, TargetMachine &tm, AsmPrinter::AsmPrinter(formatted_raw_ostream &o, TargetMachine &tm,
const MCAsmInfo *T, bool VDef) const MCAsmInfo *T, bool VDef)
@ -59,15 +68,12 @@ AsmPrinter::AsmPrinter(formatted_raw_ostream &o, TargetMachine &tm,
OutContext(*new MCContext()), OutContext(*new MCContext()),
// FIXME: Pass instprinter to streamer. // FIXME: Pass instprinter to streamer.
OutStreamer(*createAsmStreamer(OutContext, O, *T, OutStreamer(*createAsmStreamer(OutContext, O, *T,
TM.getTargetData()->isLittleEndian(), 0)), TM.getTargetData()->isLittleEndian(),
getVerboseAsm(VDef), 0)),
LastMI(0), LastFn(0), Counter(~0U), PrevDLT(NULL) { LastMI(0), LastFn(0), Counter(~0U), PrevDLT(NULL) {
DW = 0; MMI = 0; DW = 0; MMI = 0;
switch (AsmVerbose) { VerboseAsm = getVerboseAsm(VDef);
case cl::BOU_UNSET: VerboseAsm = VDef; break;
case cl::BOU_TRUE: VerboseAsm = true; break;
case cl::BOU_FALSE: VerboseAsm = false; break;
}
} }
AsmPrinter::~AsmPrinter() { AsmPrinter::~AsmPrinter() {

View File

@ -28,15 +28,15 @@ namespace {
class MCAsmStreamer : public MCStreamer { class MCAsmStreamer : public MCStreamer {
raw_ostream &OS; raw_ostream &OS;
const MCAsmInfo &MAI; const MCAsmInfo &MAI;
bool IsLittleEndian; bool IsLittleEndian, IsVerboseAsm;
MCInstPrinter *InstPrinter; MCInstPrinter *InstPrinter;
MCCodeEmitter *Emitter; MCCodeEmitter *Emitter;
public: public:
MCAsmStreamer(MCContext &Context, raw_ostream &_OS, const MCAsmInfo &tai, MCAsmStreamer(MCContext &Context, raw_ostream &os, const MCAsmInfo &mai,
bool isLittleEndian, MCInstPrinter *_Printer, bool isLittleEndian, bool isVerboseAsm, MCInstPrinter *printer,
MCCodeEmitter *_Emitter) MCCodeEmitter *emitter)
: MCStreamer(Context), OS(_OS), MAI(tai), IsLittleEndian(isLittleEndian), : MCStreamer(Context), OS(os), MAI(mai), IsLittleEndian(isLittleEndian),
InstPrinter(_Printer), Emitter(_Emitter) {} IsVerboseAsm(isVerboseAsm), InstPrinter(printer), Emitter(emitter) {}
~MCAsmStreamer() {} ~MCAsmStreamer() {}
bool isLittleEndian() const { return IsLittleEndian; } bool isLittleEndian() const { return IsLittleEndian; }
@ -351,7 +351,8 @@ void MCAsmStreamer::Finish() {
MCStreamer *llvm::createAsmStreamer(MCContext &Context, raw_ostream &OS, MCStreamer *llvm::createAsmStreamer(MCContext &Context, raw_ostream &OS,
const MCAsmInfo &MAI, bool isLittleEndian, const MCAsmInfo &MAI, bool isLittleEndian,
MCInstPrinter *IP, bool isVerboseAsm, MCInstPrinter *IP,
MCCodeEmitter *CE) { MCCodeEmitter *CE) {
return new MCAsmStreamer(Context, OS, MAI, isLittleEndian, IP, CE); return new MCAsmStreamer(Context, OS, MAI, isLittleEndian, isVerboseAsm,
IP, CE);
} }

View File

@ -266,7 +266,7 @@ static int AssembleInput(const char *ProgName) {
CE.reset(TheTarget->createCodeEmitter(*TM)); CE.reset(TheTarget->createCodeEmitter(*TM));
Str.reset(createAsmStreamer(Ctx, *Out, *MAI, Str.reset(createAsmStreamer(Ctx, *Out, *MAI,
TM->getTargetData()->isLittleEndian(), TM->getTargetData()->isLittleEndian(),
IP.get(), CE.get())); /*asmverbose*/true, IP.get(), CE.get()));
} else { } else {
assert(FileType == OFT_ObjectFile && "Invalid file type!"); assert(FileType == OFT_ObjectFile && "Invalid file type!");
CE.reset(TheTarget->createCodeEmitter(*TM)); CE.reset(TheTarget->createCodeEmitter(*TM));