Use HasDotTypeDotSizeDirective instead of forELF

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24481 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2005-11-21 23:06:54 +00:00
parent 291ca1c563
commit ac2902bcb5
4 changed files with 10 additions and 18 deletions

View File

@ -35,7 +35,7 @@ bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
SwitchSection("\t.text\n", MF.getFunction()); SwitchSection("\t.text\n", MF.getFunction());
EmitAlignment(4); // FIXME: This should be parameterized somewhere. EmitAlignment(4); // FIXME: This should be parameterized somewhere.
O << "\t.globl\t" << CurrentFnName << "\n"; O << "\t.globl\t" << CurrentFnName << "\n";
if (forELF) if (HasDotTypeDotSizeDirective)
O << "\t.type\t" << CurrentFnName << ", @function\n"; O << "\t.type\t" << CurrentFnName << ", @function\n";
O << CurrentFnName << ":\n"; O << CurrentFnName << ":\n";
@ -54,7 +54,7 @@ bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
printMachineInstruction(II); printMachineInstruction(II);
} }
} }
if (forELF) if (HasDotTypeDotSizeDirective)
O << "\t.size " << CurrentFnName << ", .-" << CurrentFnName << "\n"; O << "\t.size " << CurrentFnName << ", .-" << CurrentFnName << "\n";
// We didn't modify anything. // We didn't modify anything.

View File

@ -43,13 +43,9 @@ AsmWriterFlavor("x86-asm-syntax",
bool X86SharedAsmPrinter::doInitialization(Module &M) { bool X86SharedAsmPrinter::doInitialization(Module &M) {
const X86Subtarget *Subtarget = &TM.getSubtarget<X86Subtarget>(); const X86Subtarget *Subtarget = &TM.getSubtarget<X86Subtarget>();
forELF = false;
forDarwin = false; forDarwin = false;
switch (Subtarget->TargetType) { switch (Subtarget->TargetType) {
case X86Subtarget::isELF:
forELF = true;
break;
case X86Subtarget::isDarwin: case X86Subtarget::isDarwin:
AlignmentIsInBytes = false; AlignmentIsInBytes = false;
GlobalPrefix = "_"; GlobalPrefix = "_";
@ -59,14 +55,17 @@ bool X86SharedAsmPrinter::doInitialization(Module &M) {
ConstantPoolSection = "\t.const\n"; ConstantPoolSection = "\t.const\n";
LCOMMDirective = "\t.lcomm\t"; LCOMMDirective = "\t.lcomm\t";
COMMDirectiveTakesAlignment = false; COMMDirectiveTakesAlignment = false;
HasDotTypeDotSizeDirective = false;
forDarwin = true; forDarwin = true;
break; break;
case X86Subtarget::isCygwin: case X86Subtarget::isCygwin:
GlobalPrefix = "_"; GlobalPrefix = "_";
COMMDirectiveTakesAlignment = false; COMMDirectiveTakesAlignment = false;
HasDotTypeDotSizeDirective = false;
break; break;
case X86Subtarget::isWindows: case X86Subtarget::isWindows:
GlobalPrefix = "_"; GlobalPrefix = "_";
HasDotTypeDotSizeDirective = false;
break; break;
default: break; default: break;
} }
@ -96,9 +95,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
O << COMMDirective << name << "," << Size; O << COMMDirective << name << "," << Size;
if (COMMDirectiveTakesAlignment) if (COMMDirectiveTakesAlignment)
O << "," << (1 << Align); O << "," << (1 << Align);
O << "\t\t# "; O << "\t\t" << CommentString << " " << I->getName() << "\n";
WriteAsOperand(O, I, true, true, &M);
O << "\n";
continue; continue;
} }
@ -137,15 +134,11 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
} }
EmitAlignment(Align); EmitAlignment(Align);
if (forELF) { if (HasDotTypeDotSizeDirective) {
O << "\t.type " << name << ",@object\n"; O << "\t.type " << name << ",@object\n";
O << "\t.size " << name << "," << Size << "\n"; O << "\t.size " << name << "," << Size << "\n";
} }
O << name << ":\t\t\t\t# "; O << name << ":\t\t\t" << CommentString << ' ' << I->getName() << '\n';
WriteAsOperand(O, I, true, true, &M);
O << " = ";
WriteAsOperand(O, C, false, false, &M);
O << "\n";
EmitGlobalConstant(C); EmitGlobalConstant(C);
} }

View File

@ -29,12 +29,11 @@ extern Statistic<> EmittedInsts;
struct X86SharedAsmPrinter : public AsmPrinter { struct X86SharedAsmPrinter : public AsmPrinter {
X86SharedAsmPrinter(std::ostream &O, TargetMachine &TM) X86SharedAsmPrinter(std::ostream &O, TargetMachine &TM)
: AsmPrinter(O, TM), forELF(false), forDarwin(false) { } : AsmPrinter(O, TM), forDarwin(false) { }
bool doInitialization(Module &M); bool doInitialization(Module &M);
bool doFinalization(Module &M); bool doFinalization(Module &M);
bool forELF;
bool forDarwin; // FIXME: eliminate. bool forDarwin; // FIXME: eliminate.
// Necessary for Darwin to print out the apprioriate types of linker stubs // Necessary for Darwin to print out the apprioriate types of linker stubs

View File

@ -35,7 +35,7 @@ bool X86IntelAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
SwitchSection("\t.text\n", MF.getFunction()); SwitchSection("\t.text\n", MF.getFunction());
EmitAlignment(4); EmitAlignment(4);
O << "\t.globl\t" << CurrentFnName << "\n"; O << "\t.globl\t" << CurrentFnName << "\n";
if (forELF) if (HasDotTypeDotSizeDirective)
O << "\t.type\t" << CurrentFnName << ", @function\n"; O << "\t.type\t" << CurrentFnName << ", @function\n";
O << CurrentFnName << ":\n"; O << CurrentFnName << ":\n";