Various AsmWriter output cleanups. Use WriteAsOperand instead of

PrintUnmangledNameSafely.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78878 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2009-08-13 01:36:44 +00:00
parent 38cff389af
commit cf20ac4fd1
10 changed files with 76 additions and 106 deletions

View File

@ -339,8 +339,8 @@ void AsmPrinter::EmitConstantPool(MachineConstantPool *MCP) {
<< CPI << ':'; << CPI << ':';
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() << ' '; O << TAI->getCommentString() << " constant ";
WriteTypeSymbolic(O, CPE.getType(), 0); WriteTypeSymbolic(O, CPE.getType(), MF->getFunction()->getParent());
} }
O << '\n'; O << '\n';
if (CPE.isMachineConstantPoolEntry()) if (CPE.isMachineConstantPoolEntry())
@ -1024,7 +1024,7 @@ void AsmPrinter::EmitGlobalConstantFP(const ConstantFP *CFP,
O << TAI->getData64bitsDirective(AddrSpace) << i; O << TAI->getData64bitsDirective(AddrSpace) << i;
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() << " double value: " << Val; O << TAI->getCommentString() << " double " << Val;
} }
O << '\n'; O << '\n';
} else if (TD->isBigEndian()) { } else if (TD->isBigEndian()) {
@ -1032,14 +1032,14 @@ void AsmPrinter::EmitGlobalConstantFP(const ConstantFP *CFP,
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() O << TAI->getCommentString()
<< " double most significant word " << Val; << " most significant word of double " << Val;
} }
O << '\n'; O << '\n';
O << TAI->getData32bitsDirective(AddrSpace) << unsigned(i); O << TAI->getData32bitsDirective(AddrSpace) << unsigned(i);
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() O << TAI->getCommentString()
<< " double least significant word " << Val; << " least significant word of double " << Val;
} }
O << '\n'; O << '\n';
} else { } else {
@ -1047,14 +1047,14 @@ void AsmPrinter::EmitGlobalConstantFP(const ConstantFP *CFP,
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() O << TAI->getCommentString()
<< " double least significant word " << Val; << " least significant word of double " << Val;
} }
O << '\n'; O << '\n';
O << TAI->getData32bitsDirective(AddrSpace) << unsigned(i >> 32); O << TAI->getData32bitsDirective(AddrSpace) << unsigned(i >> 32);
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() O << TAI->getCommentString()
<< " double most significant word " << Val; << " most significant word of double " << Val;
} }
O << '\n'; O << '\n';
} }
@ -1084,33 +1084,33 @@ void AsmPrinter::EmitGlobalConstantFP(const ConstantFP *CFP,
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() O << TAI->getCommentString()
<< " long double most significant halfword of ~" << " most significant halfword of x86_fp80 ~"
<< DoubleVal.convertToDouble(); << DoubleVal.convertToDouble();
} }
O << '\n'; O << '\n';
O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 48); O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 48);
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() << " long double next halfword"; O << TAI->getCommentString() << " next halfword";
} }
O << '\n'; O << '\n';
O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 32); O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 32);
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() << " long double next halfword"; O << TAI->getCommentString() << " next halfword";
} }
O << '\n'; O << '\n';
O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 16); O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 16);
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() << " long double next halfword"; O << TAI->getCommentString() << " next halfword";
} }
O << '\n'; O << '\n';
O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0]); O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0]);
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() O << TAI->getCommentString()
<< " long double least significant halfword"; << " least significant halfword";
} }
O << '\n'; O << '\n';
} else { } else {
@ -1118,7 +1118,7 @@ void AsmPrinter::EmitGlobalConstantFP(const ConstantFP *CFP,
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() O << TAI->getCommentString()
<< " long double least significant halfword of ~" << " least significant halfword of x86_fp80 ~"
<< DoubleVal.convertToDouble(); << DoubleVal.convertToDouble();
} }
O << '\n'; O << '\n';
@ -1126,28 +1126,28 @@ void AsmPrinter::EmitGlobalConstantFP(const ConstantFP *CFP,
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() O << TAI->getCommentString()
<< " long double next halfword"; << " next halfword";
} }
O << '\n'; O << '\n';
O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 32); O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 32);
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() O << TAI->getCommentString()
<< " long double next halfword"; << " next halfword";
} }
O << '\n'; O << '\n';
O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 48); O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 48);
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() O << TAI->getCommentString()
<< " long double next halfword"; << " next halfword";
} }
O << '\n'; O << '\n';
O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[1]); O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[1]);
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() O << TAI->getCommentString()
<< " long double most significant halfword"; << " most significant halfword";
} }
O << '\n'; O << '\n';
} }
@ -1164,28 +1164,28 @@ void AsmPrinter::EmitGlobalConstantFP(const ConstantFP *CFP,
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() O << TAI->getCommentString()
<< " long double most significant word"; << " most significant word of ppc_fp128";
} }
O << '\n'; O << '\n';
O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0]); O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0]);
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() O << TAI->getCommentString()
<< " long double next word"; << " next word";
} }
O << '\n'; O << '\n';
O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1] >> 32); O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1] >> 32);
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() O << TAI->getCommentString()
<< " long double next word"; << " next word";
} }
O << '\n'; O << '\n';
O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1]); O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1]);
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() O << TAI->getCommentString()
<< " long double least significant word"; << " least significant word";
} }
O << '\n'; O << '\n';
} else { } else {
@ -1193,28 +1193,28 @@ void AsmPrinter::EmitGlobalConstantFP(const ConstantFP *CFP,
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() O << TAI->getCommentString()
<< " long double least significant word"; << " least significant word of ppc_fp128";
} }
O << '\n'; O << '\n';
O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1] >> 32); O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1] >> 32);
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() O << TAI->getCommentString()
<< " long double next word"; << " next word";
} }
O << '\n'; O << '\n';
O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0]); O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0]);
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() O << TAI->getCommentString()
<< " long double next word"; << " next word";
} }
O << '\n'; O << '\n';
O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0] >> 32); O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0] >> 32);
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() O << TAI->getCommentString()
<< " long double most significant word"; << " most significant word";
} }
O << '\n'; O << '\n';
} }
@ -1247,14 +1247,14 @@ void AsmPrinter::EmitGlobalConstantLargeInt(const ConstantInt *CI,
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() O << TAI->getCommentString()
<< " Double-word most significant word " << Val; << " most significant half of i64 " << Val;
} }
O << '\n'; O << '\n';
O << TAI->getData32bitsDirective(AddrSpace) << unsigned(Val); O << TAI->getData32bitsDirective(AddrSpace) << unsigned(Val);
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() O << TAI->getCommentString()
<< " Double-word least significant word " << Val; << " least significant half of i64 " << Val;
} }
O << '\n'; O << '\n';
} else { } else {
@ -1262,14 +1262,14 @@ void AsmPrinter::EmitGlobalConstantLargeInt(const ConstantInt *CI,
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() O << TAI->getCommentString()
<< " Double-word least significant word " << Val; << " least significant half of i64 " << Val;
} }
O << '\n'; O << '\n';
O << TAI->getData32bitsDirective(AddrSpace) << unsigned(Val >> 32); O << TAI->getData32bitsDirective(AddrSpace) << unsigned(Val >> 32);
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() O << TAI->getCommentString()
<< " Double-word most significant word " << Val; << " most significant half of i64 " << Val;
} }
O << '\n'; O << '\n';
} }

View File

@ -21,6 +21,7 @@
#include "ARMMachineFunctionInfo.h" #include "ARMMachineFunctionInfo.h"
#include "llvm/Constants.h" #include "llvm/Constants.h"
#include "llvm/Module.h" #include "llvm/Module.h"
#include "llvm/Assembly/Writer.h"
#include "llvm/CodeGen/AsmPrinter.h" #include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/CodeGen/DwarfWriter.h" #include "llvm/CodeGen/DwarfWriter.h"
#include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/CodeGen/MachineModuleInfo.h"
@ -1128,16 +1129,6 @@ bool ARMAsmPrinter::doInitialization(Module &M) {
return Result; return Result;
} }
/// PrintUnmangledNameSafely - Print out the printable characters in the name.
/// Don't print things like \\n or \\0.
static void PrintUnmangledNameSafely(const Value *V,
formatted_raw_ostream &OS) {
for (StringRef::iterator it = V->getName().begin(),
ie = V->getName().end(); it != ie; ++it)
if (isprint(*it))
OS << *it;
}
void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) { void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
const TargetData *TD = TM.getTargetData(); const TargetData *TD = TM.getTargetData();
@ -1204,7 +1195,7 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
O << name << ":"; O << name << ":";
if (VerboseAsm) { if (VerboseAsm) {
O << "\t\t\t\t" << TAI->getCommentString() << ' '; O << "\t\t\t\t" << TAI->getCommentString() << ' ';
PrintUnmangledNameSafely(GVar, O); WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
} }
O << '\n'; O << '\n';
EmitGlobalConstant(C); EmitGlobalConstant(C);
@ -1227,7 +1218,7 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
} }
if (VerboseAsm) { if (VerboseAsm) {
O << "\t\t" << TAI->getCommentString() << " "; O << "\t\t" << TAI->getCommentString() << " ";
PrintUnmangledNameSafely(GVar, O); WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
} }
O << "\n"; O << "\n";
return; return;
@ -1265,7 +1256,7 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
O << name << ":"; O << name << ":";
if (VerboseAsm) { if (VerboseAsm) {
O << "\t\t\t\t" << TAI->getCommentString() << " "; O << "\t\t\t\t" << TAI->getCommentString() << " ";
PrintUnmangledNameSafely(GVar, O); WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
} }
O << "\n"; O << "\n";
if (TAI->hasDotTypeDotSizeDirective()) if (TAI->hasDotTypeDotSizeDirective())

View File

@ -487,16 +487,6 @@ bool LinuxAsmPrinter::doInitialization(Module &M) {
return Result; return Result;
} }
/// PrintUnmangledNameSafely - Print out the printable characters in the name.
/// Don't print things like \\n or \\0.
static void PrintUnmangledNameSafely(const Value *V,
formatted_raw_ostream &OS) {
for (StringRef::iterator it = V->getName().begin(),
ie = V->getName().end(); it != ie; ++it)
if (isprint(*it))
OS << *it;
}
/*! /*!
Emit a global variable according to its section, alignment, etc. Emit a global variable according to its section, alignment, etc.
@ -541,7 +531,7 @@ void LinuxAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
O << ".comm " << name << ',' << Size; O << ".comm " << name << ',' << Size;
} }
O << "\t\t" << TAI->getCommentString() << " '"; O << "\t\t" << TAI->getCommentString() << " '";
PrintUnmangledNameSafely(GVar, O); WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
O << "'\n"; O << "'\n";
return; return;
} }
@ -575,7 +565,7 @@ void LinuxAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
EmitAlignment(Align, GVar); EmitAlignment(Align, GVar);
O << name << ":\t\t\t\t" << TAI->getCommentString() << " '"; O << name << ":\t\t\t\t" << TAI->getCommentString() << " '";
PrintUnmangledNameSafely(GVar, O); WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
O << "'\n"; O << "'\n";
EmitGlobalConstant(C); EmitGlobalConstant(C);

View File

@ -646,16 +646,6 @@ bool PPCLinuxAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
return false; return false;
} }
/// PrintUnmangledNameSafely - Print out the printable characters in the name.
/// Don't print things like \\n or \\0.
static void PrintUnmangledNameSafely(const Value *V,
formatted_raw_ostream &OS) {
for (StringRef::iterator it = V->getName().begin(),
ie = V->getName().end(); it != ie; ++it)
if (isprint(*it))
OS << *it;
}
void PPCLinuxAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) { void PPCLinuxAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
const TargetData *TD = TM.getTargetData(); const TargetData *TD = TM.getTargetData();
@ -695,7 +685,7 @@ void PPCLinuxAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
} }
if (VerboseAsm) { if (VerboseAsm) {
O << "\t\t" << TAI->getCommentString() << " '"; O << "\t\t" << TAI->getCommentString() << " '";
PrintUnmangledNameSafely(GVar, O); WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
O << "'"; O << "'";
} }
O << '\n'; O << '\n';
@ -732,7 +722,7 @@ void PPCLinuxAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
O << name << ":"; O << name << ":";
if (VerboseAsm) { if (VerboseAsm) {
O << "\t\t\t\t" << TAI->getCommentString() << " '"; O << "\t\t\t\t" << TAI->getCommentString() << " '";
PrintUnmangledNameSafely(GVar, O); WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
O << "'"; O << "'";
} }
O << '\n'; O << '\n';
@ -916,7 +906,7 @@ void PPCDarwinAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
O << name << ":"; O << name << ":";
if (VerboseAsm) { if (VerboseAsm) {
O << "\t\t\t\t" << TAI->getCommentString() << " "; O << "\t\t\t\t" << TAI->getCommentString() << " ";
PrintUnmangledNameSafely(GVar, O); WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
} }
O << '\n'; O << '\n';
EmitGlobalConstant(C); EmitGlobalConstant(C);
@ -929,7 +919,7 @@ void PPCDarwinAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
} }
if (VerboseAsm) { if (VerboseAsm) {
O << "\t\t" << TAI->getCommentString() << " '"; O << "\t\t" << TAI->getCommentString() << " '";
PrintUnmangledNameSafely(GVar, O); WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
O << "'"; O << "'";
} }
O << '\n'; O << '\n';
@ -964,7 +954,7 @@ void PPCDarwinAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
O << name << ":"; O << name << ":";
if (VerboseAsm) { if (VerboseAsm) {
O << "\t\t\t\t" << TAI->getCommentString() << " '"; O << "\t\t\t\t" << TAI->getCommentString() << " '";
PrintUnmangledNameSafely(GVar, O); WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
O << "'"; O << "'";
} }
O << '\n'; O << '\n';

View File

@ -19,6 +19,7 @@
#include "llvm/Constants.h" #include "llvm/Constants.h"
#include "llvm/DerivedTypes.h" #include "llvm/DerivedTypes.h"
#include "llvm/Module.h" #include "llvm/Module.h"
#include "llvm/Assembly/Writer.h"
#include "llvm/CodeGen/AsmPrinter.h" #include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/CodeGen/DwarfWriter.h" #include "llvm/CodeGen/DwarfWriter.h"
#include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/CodeGen/MachineModuleInfo.h"
@ -297,16 +298,6 @@ void SystemZAsmPrinter::printRRIAddrOperand(const MachineInstr *MI, int OpNum,
assert(!Index.getReg() && "Should allocate base register first!"); assert(!Index.getReg() && "Should allocate base register first!");
} }
/// PrintUnmangledNameSafely - Print out the printable characters in the name.
/// Don't print things like \\n or \\0.
static void PrintUnmangledNameSafely(const Value *V,
formatted_raw_ostream &OS) {
for (StringRef::iterator it = V->getName().begin(),
ie = V->getName().end(); it != ie; ++it)
if (isprint(*it))
OS << *it;
}
void SystemZAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) { void SystemZAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
const TargetData *TD = TM.getTargetData(); const TargetData *TD = TM.getTargetData();
@ -343,7 +334,7 @@ void SystemZAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
if (VerboseAsm) { if (VerboseAsm) {
O << "\t\t" << TAI->getCommentString() << ' '; O << "\t\t" << TAI->getCommentString() << ' ';
PrintUnmangledNameSafely(GVar, O); WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
} }
O << '\n'; O << '\n';
return; return;
@ -378,7 +369,7 @@ void SystemZAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
O << name << ":"; O << name << ":";
if (VerboseAsm) { if (VerboseAsm) {
O << "\t\t\t\t" << TAI->getCommentString() << ' '; O << "\t\t\t\t" << TAI->getCommentString() << ' ';
PrintUnmangledNameSafely(GVar, O); WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
} }
O << '\n'; O << '\n';
if (TAI->hasDotTypeDotSizeDirective()) if (TAI->hasDotTypeDotSizeDirective())

View File

@ -26,6 +26,7 @@
#include "llvm/Type.h" #include "llvm/Type.h"
#include "llvm/ADT/Statistic.h" #include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include "llvm/Assembly/Writer.h"
#include "llvm/MC/MCContext.h" #include "llvm/MC/MCContext.h"
#include "llvm/MC/MCInst.h" #include "llvm/MC/MCInst.h"
#include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCSectionMachO.h"
@ -59,16 +60,6 @@ void X86ATTAsmPrinter::PrintPICBaseSymbol() const {
llvm_unreachable("Don't know how to print PIC label!"); llvm_unreachable("Don't know how to print PIC label!");
} }
/// PrintUnmangledNameSafely - Print out the printable characters in the name.
/// Don't print things like \\n or \\0.
static void PrintUnmangledNameSafely(const Value *V,
formatted_raw_ostream &OS) {
for (StringRef::iterator it = V->getName().begin(),
ie = V->getName().end(); it != ie; ++it)
if (isprint(*it))
OS << *it;
}
static X86MachineFunctionInfo calculateFunctionInfo(const Function *F, static X86MachineFunctionInfo calculateFunctionInfo(const Function *F,
const TargetData *TD) { const TargetData *TD) {
X86MachineFunctionInfo Info; X86MachineFunctionInfo Info;
@ -208,7 +199,14 @@ void X86ATTAsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
<< ";\t.endef\n"; << ";\t.endef\n";
} }
O << CurrentFnName << ":\n"; O << CurrentFnName << ':';
if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() << ' ';
WriteAsOperand(O, F, /*PrintType=*/false, F->getParent());
}
O << '\n';
// Add some workaround for linkonce linkage on Cygwin\MinGW // Add some workaround for linkonce linkage on Cygwin\MinGW
if (Subtarget->isTargetCygMing() && if (Subtarget->isTargetCygMing() &&
(F->hasLinkOnceLinkage() || F->hasWeakLinkage())) (F->hasLinkOnceLinkage() || F->hasWeakLinkage()))
@ -403,7 +401,7 @@ void X86ATTAsmPrinter::print_pcrel_imm(const MachineInstr *MI, unsigned OpNo) {
O << MO.getImm(); O << MO.getImm();
return; return;
case MachineOperand::MO_MachineBasicBlock: case MachineOperand::MO_MachineBasicBlock:
printBasicBlockLabel(MO.getMBB(), false, false, VerboseAsm); printBasicBlockLabel(MO.getMBB(), false, false, false);
return; return;
case MachineOperand::MO_GlobalAddress: case MachineOperand::MO_GlobalAddress:
case MachineOperand::MO_ExternalSymbol: case MachineOperand::MO_ExternalSymbol:
@ -818,7 +816,7 @@ void X86ATTAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() << ' '; O << TAI->getCommentString() << ' ';
PrintUnmangledNameSafely(GVar, O); WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
} }
O << '\n'; O << '\n';
EmitGlobalConstant(C); EmitGlobalConstant(C);
@ -840,7 +838,7 @@ void X86ATTAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() << ' '; O << TAI->getCommentString() << ' ';
PrintUnmangledNameSafely(GVar, O); WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
} }
O << '\n'; O << '\n';
return; return;
@ -884,13 +882,14 @@ void X86ATTAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
if (VerboseAsm){ if (VerboseAsm){
O.PadToColumn(TAI->getCommentColumn(), 1); O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() << ' '; O << TAI->getCommentString() << ' ';
PrintUnmangledNameSafely(GVar, O); WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
} }
O << '\n'; O << '\n';
if (TAI->hasDotTypeDotSizeDirective())
O << "\t.size\t" << name << ", " << Size << '\n';
EmitGlobalConstant(C); EmitGlobalConstant(C);
if (TAI->hasDotTypeDotSizeDirective())
O << "\t.size\t" << name << ", " << Size << '\n';
} }
bool X86ATTAsmPrinter::doFinalization(Module &M) { bool X86ATTAsmPrinter::doFinalization(Module &M) {

View File

@ -273,7 +273,7 @@ void X86IntelAsmPrinter::print_pcrel_imm(const MachineInstr *MI, unsigned OpNo){
O << MO.getImm(); O << MO.getImm();
return; return;
case MachineOperand::MO_MachineBasicBlock: case MachineOperand::MO_MachineBasicBlock:
printBasicBlockLabel(MO.getMBB()); printBasicBlockLabel(MO.getMBB(), false, false, false);
return; return;
case MachineOperand::MO_GlobalAddress: { case MachineOperand::MO_GlobalAddress: {

View File

@ -1,12 +1,18 @@
; RUN: llvm-as < %s | llvm-dis ; RUN: llvm-as < %s | llvm-dis
%0 = type { %1, %2 } ; type %0 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
%1 = type { i32 } ; type %1
%2 = type { float, double } ; type %2 module asm "this is an inline asm block"
module asm "this is another inline asm block"
%0 = type { %1, %2 }
%1 = type { i32 }
%2 = type { float, double }
@0 = global i32 0 @0 = global i32 0
@1 = global float 3.0 @1 = global float 3.0
@2 = global i8* null @2 = global i8* null
@3 = global x86_fp80 0xK4001E000000000000000
define float @foo(%0* %p) nounwind { define float @foo(%0* %p) nounwind {
%t = load %0* %p ; <%0> [#uses=2] %t = load %0* %p ; <%0> [#uses=2]
@ -40,3 +46,6 @@ define float* @rrr() {
define i8** @sss() { define i8** @sss() {
ret i8** @2 ret i8** @2
} }
define x86_fp80* @nnn() {
ret x86_fp80* @3
}

View File

@ -1,7 +1,7 @@
; RUN: llvm-as < %s | llc | grep ly | count 2 ; RUN: llvm-as < %s | llc | grep ly | count 2
; RUN: llvm-as < %s | llc | grep sty | count 2 ; RUN: llvm-as < %s | llc | grep sty | count 2
; RUN: llvm-as < %s | llc | grep {l.%} | count 2 ; RUN: llvm-as < %s | llc | grep {l %} | count 2
; RUN: llvm-as < %s | llc | grep {st.%} | count 2 ; RUN: llvm-as < %s | llc | grep {st %} | count 2
target datalayout = "E-p:64:64:64-i8:8:16-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-a0:16:16" target datalayout = "E-p:64:64:64-i8:8:16-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-a0:16:16"
target triple = "s390x-linux" target triple = "s390x-linux"

View File

@ -75,9 +75,9 @@
; LINUX: .type G6,@object ; LINUX: .type G6,@object
; LINUX: .section .gnu.linkonce.r.G6,"a",@progbits ; LINUX: .section .gnu.linkonce.r.G6,"a",@progbits
; LINUX: .weak G6 ; LINUX: .weak G6
; LINUX: G6: # G6 ; LINUX: G6:
; LINUX: .size G6, 1
; LINUX: .ascii "\001" ; LINUX: .ascii "\001"
; LINUX: .size G6, 1
; DARWIN: .section __TEXT,__const_coal,coalesced ; DARWIN: .section __TEXT,__const_coal,coalesced
; DARWIN: .globl _G6 ; DARWIN: .globl _G6