Replace large swaths of copy-n-paste code with obvious helper function...

- Which was already present in the module!

 - I skipped this xform for Alpha, since it runs an extra pass during assembly
   emission, but not when emitting assembly via the DumpAsm flag.

 - No functionality change.

--
ddunbar@giles:llvm$ svn diff | grep '^- ' | sort | uniq -c
  18 -      PM.add(AsmPrinterCtor(ferrs(), *this, true));
  18 -    assert(AsmPrinterCtor && "AsmPrinter was not linked in");
  18 -    if (AsmPrinterCtor)
  18 -  if (DumpAsm) {
  18 -  }
ddunbar@giles:llvm$ svn diff | grep '^+ ' | sort | uniq -c
  18 +    addAssemblyEmitter(PM, OptLevel, true, ferrs());
  18 +  if (DumpAsm)
--

llvm-svn: 75782
This commit is contained in:
Daniel Dunbar 2009-07-15 12:49:15 +00:00
parent cf5b0f4155
commit eb8c83b4c3
3 changed files with 36 additions and 90 deletions

View File

@ -155,11 +155,8 @@ bool ARMBaseTargetMachine::addCodeEmitter(PassManagerBase &PM,
// Machine code emitter pass for ARM.
PM.add(createARMCodeEmitterPass(*this, MCE));
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
if (DumpAsm)
addAssemblyEmitter(PM, OptLevel, true, ferrs());
return false;
}
@ -174,11 +171,8 @@ bool ARMBaseTargetMachine::addCodeEmitter(PassManagerBase &PM,
// Machine code emitter pass for ARM.
PM.add(createARMJITCodeEmitterPass(*this, JCE));
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
if (DumpAsm)
addAssemblyEmitter(PM, OptLevel, true, ferrs());
return false;
}
@ -193,11 +187,8 @@ bool ARMBaseTargetMachine::addCodeEmitter(PassManagerBase &PM,
// Machine code emitter pass for ARM.
PM.add(createARMObjectCodeEmitterPass(*this, OCE));
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
if (DumpAsm)
addAssemblyEmitter(PM, OptLevel, true, ferrs());
return false;
}
@ -208,11 +199,8 @@ bool ARMBaseTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM,
MachineCodeEmitter &MCE) {
// Machine code emitter pass for ARM.
PM.add(createARMCodeEmitterPass(*this, MCE));
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
if (DumpAsm)
addAssemblyEmitter(PM, OptLevel, true, ferrs());
return false;
}
@ -223,11 +211,8 @@ bool ARMBaseTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM,
JITCodeEmitter &JCE) {
// Machine code emitter pass for ARM.
PM.add(createARMJITCodeEmitterPass(*this, JCE));
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
if (DumpAsm)
addAssemblyEmitter(PM, OptLevel, true, ferrs());
return false;
}
@ -238,11 +223,8 @@ bool ARMBaseTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM,
ObjectCodeEmitter &OCE) {
// Machine code emitter pass for ARM.
PM.add(createARMObjectCodeEmitterPass(*this, OCE));
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
if (DumpAsm)
addAssemblyEmitter(PM, OptLevel, true, ferrs());
return false;
}

View File

@ -135,11 +135,8 @@ bool PPCTargetMachine::addCodeEmitter(PassManagerBase &PM,
// Machine code emitter pass for PowerPC.
PM.add(createPPCCodeEmitterPass(*this, MCE));
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
if (DumpAsm)
addAssemblyEmitter(PM, OptLevel, true, ferrs());
return false;
}
@ -167,11 +164,8 @@ bool PPCTargetMachine::addCodeEmitter(PassManagerBase &PM,
// Machine code emitter pass for PowerPC.
PM.add(createPPCJITCodeEmitterPass(*this, JCE));
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
if (DumpAsm)
addAssemblyEmitter(PM, OptLevel, true, ferrs());
return false;
}
@ -199,11 +193,8 @@ bool PPCTargetMachine::addCodeEmitter(PassManagerBase &PM,
// Machine code emitter pass for PowerPC.
PM.add(createPPCObjectCodeEmitterPass(*this, OCE));
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
if (DumpAsm)
addAssemblyEmitter(PM, OptLevel, true, ferrs());
return false;
}
@ -214,11 +205,8 @@ bool PPCTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM,
MachineCodeEmitter &MCE) {
// Machine code emitter pass for PowerPC.
PM.add(createPPCCodeEmitterPass(*this, MCE));
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
if (DumpAsm)
addAssemblyEmitter(PM, OptLevel, true, ferrs());
return false;
}
@ -229,11 +217,8 @@ bool PPCTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM,
JITCodeEmitter &JCE) {
// Machine code emitter pass for PowerPC.
PM.add(createPPCJITCodeEmitterPass(*this, JCE));
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
if (DumpAsm)
addAssemblyEmitter(PM, OptLevel, true, ferrs());
return false;
}
@ -244,11 +229,8 @@ bool PPCTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM,
ObjectCodeEmitter &OCE) {
// Machine code emitter pass for PowerPC.
PM.add(createPPCObjectCodeEmitterPass(*this, OCE));
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
if (DumpAsm)
addAssemblyEmitter(PM, OptLevel, true, ferrs());
return false;
}

View File

@ -217,11 +217,8 @@ bool X86TargetMachine::addCodeEmitter(PassManagerBase &PM,
}
PM.add(createX86CodeEmitterPass(*this, MCE));
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
if (DumpAsm)
addAssemblyEmitter(PM, OptLevel, true, ferrs());
return false;
}
@ -249,11 +246,8 @@ bool X86TargetMachine::addCodeEmitter(PassManagerBase &PM,
}
PM.add(createX86JITCodeEmitterPass(*this, JCE));
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
if (DumpAsm)
addAssemblyEmitter(PM, OptLevel, true, ferrs());
return false;
}
@ -263,11 +257,8 @@ bool X86TargetMachine::addCodeEmitter(PassManagerBase &PM,
bool DumpAsm,
ObjectCodeEmitter &OCE) {
PM.add(createX86ObjectCodeEmitterPass(*this, OCE));
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
if (DumpAsm)
addAssemblyEmitter(PM, OptLevel, true, ferrs());
return false;
}
@ -277,11 +268,8 @@ bool X86TargetMachine::addSimpleCodeEmitter(PassManagerBase &PM,
bool DumpAsm,
MachineCodeEmitter &MCE) {
PM.add(createX86CodeEmitterPass(*this, MCE));
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
if (DumpAsm)
addAssemblyEmitter(PM, OptLevel, true, ferrs());
return false;
}
@ -291,11 +279,8 @@ bool X86TargetMachine::addSimpleCodeEmitter(PassManagerBase &PM,
bool DumpAsm,
JITCodeEmitter &JCE) {
PM.add(createX86JITCodeEmitterPass(*this, JCE));
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
if (DumpAsm)
addAssemblyEmitter(PM, OptLevel, true, ferrs());
return false;
}
@ -305,11 +290,8 @@ bool X86TargetMachine::addSimpleCodeEmitter(PassManagerBase &PM,
bool DumpAsm,
ObjectCodeEmitter &OCE) {
PM.add(createX86ObjectCodeEmitterPass(*this, OCE));
if (DumpAsm) {
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
if (AsmPrinterCtor)
PM.add(AsmPrinterCtor(ferrs(), *this, true));
}
if (DumpAsm)
addAssemblyEmitter(PM, OptLevel, true, ferrs());
return false;
}