From: Brian Gaeke Date: Thu, 19 Jun 2003 19:32:32 +0000 (+0000) Subject: Add Initialization and Finalization methods for the Printer pass, X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=9e474c4ec87de79df4a62927275b5b607457e37f;p=oota-llvm.git Add Initialization and Finalization methods for the Printer pass, to print various things on a module-by-module basis (currently, only the former is used). Don't print < > around names. The assembler can't take it. Print pseudoinstructions only as comments. The poor little assembler can't take that, either. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6789 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/X86/Printer.cpp b/lib/Target/X86/Printer.cpp index 4a739d740ee..0a5a33ca193 100644 --- a/lib/Target/X86/Printer.cpp +++ b/lib/Target/X86/Printer.cpp @@ -27,6 +27,10 @@ namespace { void printConstantPool(MachineConstantPool *MCP, const TargetData &TD); bool runOnMachineFunction(MachineFunction &F); + + bool doInitialization(Module &M); + bool doFinalization(Module &M); + }; } @@ -123,13 +127,13 @@ static void printOp(std::ostream &O, const MachineOperand &MO, O << (int)MO.getImmedValue(); return; case MachineOperand::MO_PCRelativeDisp: - O << "<" << MO.getVRegValue()->getName() << ">"; + O << MO.getVRegValue()->getName(); return; case MachineOperand::MO_GlobalAddress: - O << "<" << MO.getGlobal()->getName() << ">"; + O << MO.getGlobal()->getName(); return; case MachineOperand::MO_ExternalSymbol: - O << "<" << MO.getSymbolName() << ">"; + O << MO.getSymbolName(); return; default: O << ""; return; @@ -208,6 +212,10 @@ void X86InstrInfo::print(const MachineInstr *MI, std::ostream &O, switch (Desc.TSFlags & X86II::FormMask) { case X86II::Pseudo: + // Print pseudo-instructions as comments; either they should have been + // turned into real instructions by now, or they don't need to be + // seen by the assembler (e.g., IMPLICIT_USEs.) + O << "# "; if (Opcode == X86::PHI) { printOp(O, MI->getOperand(0), RI); O << " = phi "; @@ -457,3 +465,18 @@ void X86InstrInfo::print(const MachineInstr *MI, std::ostream &O, O << "\tUNKNOWN FORM:\t\t-"; MI->print(O, TM); break; } } + +bool Printer::doInitialization(Module &M) +{ + // Tell gas we are outputting Intel syntax (not AT&T syntax) assembly, + // with no % decorations on register names. + O << "\t.intel_syntax noprefix\n"; + return false; // success +} + +bool Printer::doFinalization(Module &M) +{ + // FIXME: We may have to print out constants here. + return false; // success +} + diff --git a/lib/Target/X86/X86AsmPrinter.cpp b/lib/Target/X86/X86AsmPrinter.cpp index 4a739d740ee..0a5a33ca193 100644 --- a/lib/Target/X86/X86AsmPrinter.cpp +++ b/lib/Target/X86/X86AsmPrinter.cpp @@ -27,6 +27,10 @@ namespace { void printConstantPool(MachineConstantPool *MCP, const TargetData &TD); bool runOnMachineFunction(MachineFunction &F); + + bool doInitialization(Module &M); + bool doFinalization(Module &M); + }; } @@ -123,13 +127,13 @@ static void printOp(std::ostream &O, const MachineOperand &MO, O << (int)MO.getImmedValue(); return; case MachineOperand::MO_PCRelativeDisp: - O << "<" << MO.getVRegValue()->getName() << ">"; + O << MO.getVRegValue()->getName(); return; case MachineOperand::MO_GlobalAddress: - O << "<" << MO.getGlobal()->getName() << ">"; + O << MO.getGlobal()->getName(); return; case MachineOperand::MO_ExternalSymbol: - O << "<" << MO.getSymbolName() << ">"; + O << MO.getSymbolName(); return; default: O << ""; return; @@ -208,6 +212,10 @@ void X86InstrInfo::print(const MachineInstr *MI, std::ostream &O, switch (Desc.TSFlags & X86II::FormMask) { case X86II::Pseudo: + // Print pseudo-instructions as comments; either they should have been + // turned into real instructions by now, or they don't need to be + // seen by the assembler (e.g., IMPLICIT_USEs.) + O << "# "; if (Opcode == X86::PHI) { printOp(O, MI->getOperand(0), RI); O << " = phi "; @@ -457,3 +465,18 @@ void X86InstrInfo::print(const MachineInstr *MI, std::ostream &O, O << "\tUNKNOWN FORM:\t\t-"; MI->print(O, TM); break; } } + +bool Printer::doInitialization(Module &M) +{ + // Tell gas we are outputting Intel syntax (not AT&T syntax) assembly, + // with no % decorations on register names. + O << "\t.intel_syntax noprefix\n"; + return false; // success +} + +bool Printer::doFinalization(Module &M) +{ + // FIXME: We may have to print out constants here. + return false; // success +} +