More changes to make PPC32 and X86 more similar

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15842 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2004-08-16 23:38:36 +00:00
parent 36aacdb974
commit 416ca3384a
2 changed files with 18 additions and 22 deletions

View File

@ -152,13 +152,16 @@ static void printAsCString(std::ostream &O, const ConstantArray *CVA) {
void PowerPCAsmPrinter::emitGlobalConstant(const Constant *CV) { void PowerPCAsmPrinter::emitGlobalConstant(const Constant *CV) {
const TargetData &TD = TM.getTargetData(); const TargetData &TD = TM.getTargetData();
if (const ConstantArray *CVA = dyn_cast<ConstantArray>(CV)) { if (CV->isNullValue()) {
if (isStringCompatible(CVA)) { O << "\t.space\t" << TD.getTypeSize(CV->getType()) << "\n";
O << "\t.ascii "; return;
} else if (const ConstantArray *CVA = dyn_cast<ConstantArray>(CV)) {
if (CVA->isString()) {
O << "\t.ascii\t";
printAsCString(O, CVA); printAsCString(O, CVA);
O << "\n"; O << "\n";
} else { // Not a string. Print the values in successive locations } else { // Not a string. Print the values in successive locations
for (unsigned i=0, e = CVA->getNumOperands(); i != e; i++) for (unsigned i = 0, e = CVA->getNumOperands(); i != e; ++i)
emitGlobalConstant(CVA->getOperand(i)); emitGlobalConstant(CVA->getOperand(i));
} }
return; return;
@ -166,7 +169,7 @@ void PowerPCAsmPrinter::emitGlobalConstant(const Constant *CV) {
// Print the fields in successive locations. Pad to align if needed! // Print the fields in successive locations. Pad to align if needed!
const StructLayout *cvsLayout = TD.getStructLayout(CVS->getType()); const StructLayout *cvsLayout = TD.getStructLayout(CVS->getType());
unsigned sizeSoFar = 0; unsigned sizeSoFar = 0;
for (unsigned i = 0, e = CVS->getNumOperands(); i != e; i++) { for (unsigned i = 0, e = CVS->getNumOperands(); i != e; ++i) {
const Constant* field = CVS->getOperand(i); const Constant* field = CVS->getOperand(i);
// Check if padding is needed and insert one or more 0s. // Check if padding is needed and insert one or more 0s.
@ -243,12 +246,7 @@ void PowerPCAsmPrinter::emitGlobalConstant(const Constant *CV) {
case Type::FloatTyID: case Type::DoubleTyID: case Type::FloatTyID: case Type::DoubleTyID:
assert (0 && "Should have already output floating point constant."); assert (0 && "Should have already output floating point constant.");
default: default:
if (CV == Constant::getNullValue(type)) { // Zero initializer? assert (0 && "Can't handle printing this type of thing");
O << ".space\t" << TD.getTypeSize(type) << "\n";
return;
}
std::cerr << "Can't handle printing: " << *CV;
abort();
break; break;
} }
O << "\t"; O << "\t";

View File

@ -152,13 +152,16 @@ static void printAsCString(std::ostream &O, const ConstantArray *CVA) {
void PowerPCAsmPrinter::emitGlobalConstant(const Constant *CV) { void PowerPCAsmPrinter::emitGlobalConstant(const Constant *CV) {
const TargetData &TD = TM.getTargetData(); const TargetData &TD = TM.getTargetData();
if (const ConstantArray *CVA = dyn_cast<ConstantArray>(CV)) { if (CV->isNullValue()) {
if (isStringCompatible(CVA)) { O << "\t.space\t" << TD.getTypeSize(CV->getType()) << "\n";
O << "\t.ascii "; return;
} else if (const ConstantArray *CVA = dyn_cast<ConstantArray>(CV)) {
if (CVA->isString()) {
O << "\t.ascii\t";
printAsCString(O, CVA); printAsCString(O, CVA);
O << "\n"; O << "\n";
} else { // Not a string. Print the values in successive locations } else { // Not a string. Print the values in successive locations
for (unsigned i=0, e = CVA->getNumOperands(); i != e; i++) for (unsigned i = 0, e = CVA->getNumOperands(); i != e; ++i)
emitGlobalConstant(CVA->getOperand(i)); emitGlobalConstant(CVA->getOperand(i));
} }
return; return;
@ -166,7 +169,7 @@ void PowerPCAsmPrinter::emitGlobalConstant(const Constant *CV) {
// Print the fields in successive locations. Pad to align if needed! // Print the fields in successive locations. Pad to align if needed!
const StructLayout *cvsLayout = TD.getStructLayout(CVS->getType()); const StructLayout *cvsLayout = TD.getStructLayout(CVS->getType());
unsigned sizeSoFar = 0; unsigned sizeSoFar = 0;
for (unsigned i = 0, e = CVS->getNumOperands(); i != e; i++) { for (unsigned i = 0, e = CVS->getNumOperands(); i != e; ++i) {
const Constant* field = CVS->getOperand(i); const Constant* field = CVS->getOperand(i);
// Check if padding is needed and insert one or more 0s. // Check if padding is needed and insert one or more 0s.
@ -243,12 +246,7 @@ void PowerPCAsmPrinter::emitGlobalConstant(const Constant *CV) {
case Type::FloatTyID: case Type::DoubleTyID: case Type::FloatTyID: case Type::DoubleTyID:
assert (0 && "Should have already output floating point constant."); assert (0 && "Should have already output floating point constant.");
default: default:
if (CV == Constant::getNullValue(type)) { // Zero initializer? assert (0 && "Can't handle printing this type of thing");
O << ".space\t" << TD.getTypeSize(type) << "\n";
return;
}
std::cerr << "Can't handle printing: " << *CV;
abort();
break; break;
} }
O << "\t"; O << "\t";