[llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sat Feb 14 23:55:13 PST 2004
Changes in directory llvm/lib/Target/CBackend:
Writer.cpp updated: 1.160 -> 1.161
---
Log message:
Add support for the new ConstantAggregateZero class
---
Diffs of the changes: (+39 -11)
Index: llvm/lib/Target/CBackend/Writer.cpp
diff -u llvm/lib/Target/CBackend/Writer.cpp:1.160 llvm/lib/Target/CBackend/Writer.cpp:1.161
--- llvm/lib/Target/CBackend/Writer.cpp:1.160 Fri Feb 13 20:55:36 2004
+++ llvm/lib/Target/CBackend/Writer.cpp Sat Feb 14 23:54:27 2004
@@ -475,22 +475,50 @@
}
case Type::ArrayTyID:
- printConstantArray(cast<ConstantArray>(CPV));
+ if (isa<ConstantAggregateZero>(CPV)) {
+ const ArrayType *AT = cast<ArrayType>(CPV->getType());
+ Out << "{";
+ if (AT->getNumElements()) {
+ Out << " ";
+ Constant *CZ = Constant::getNullValue(AT->getElementType());
+ printConstant(CZ);
+ for (unsigned i = 1, e = AT->getNumElements(); i != e; ++i) {
+ Out << ", ";
+ printConstant(CZ);
+ }
+ }
+ Out << " }";
+ } else {
+ printConstantArray(cast<ConstantArray>(CPV));
+ }
break;
- case Type::StructTyID: {
- Out << "{";
- if (CPV->getNumOperands()) {
- Out << " ";
- printConstant(cast<Constant>(CPV->getOperand(0)));
- for (unsigned i = 1, e = CPV->getNumOperands(); i != e; ++i) {
- Out << ", ";
- printConstant(cast<Constant>(CPV->getOperand(i)));
+ case Type::StructTyID:
+ if (isa<ConstantAggregateZero>(CPV)) {
+ const StructType *ST = cast<StructType>(CPV->getType());
+ Out << "{";
+ if (ST->getNumElements()) {
+ Out << " ";
+ printConstant(Constant::getNullValue(ST->getElementType(0)));
+ for (unsigned i = 1, e = ST->getNumElements(); i != e; ++i) {
+ Out << ", ";
+ printConstant(Constant::getNullValue(ST->getElementType(i)));
+ }
+ }
+ Out << " }";
+ } else {
+ Out << "{";
+ if (CPV->getNumOperands()) {
+ Out << " ";
+ printConstant(cast<Constant>(CPV->getOperand(0)));
+ for (unsigned i = 1, e = CPV->getNumOperands(); i != e; ++i) {
+ Out << ", ";
+ printConstant(cast<Constant>(CPV->getOperand(i)));
+ }
}
+ Out << " }";
}
- Out << " }";
break;
- }
case Type::PointerTyID:
if (isa<ConstantPointerNull>(CPV)) {
More information about the llvm-commits
mailing list