[llvm-commits] [llvm] r47804 - /llvm/trunk/lib/Target/CBackend/CBackend.cpp
Chris Lattner
sabre at nondot.org
Sat Mar 1 19:16:38 PST 2008
Author: lattner
Date: Sat Mar 1 21:16:38 2008
New Revision: 47804
URL: http://llvm.org/viewvc/llvm-project?rev=47804&view=rev
Log:
Print i32/i64 integer constants as 1u instead of ((unsigned int)1).
Use dyn_cast better.
Modified:
llvm/trunk/lib/Target/CBackend/CBackend.cpp
Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=47804&r1=47803&r2=47804&view=diff
==============================================================================
--- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original)
+++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Sat Mar 1 21:16:38 2008
@@ -133,8 +133,8 @@
bool IgnoreName = false,
const ParamAttrsList *PAL = 0);
std::ostream &printSimpleType(std::ostream &Out, const Type *Ty,
- bool isSigned,
- const std::string &NameSoFar = "");
+ bool isSigned,
+ const std::string &NameSoFar = "");
void printStructReturnPointerFunctionType(std::ostream &Out,
const ParamAttrsList *PAL,
@@ -888,7 +888,11 @@
if (ConstantInt *CI = dyn_cast<ConstantInt>(CPV)) {
const Type* Ty = CI->getType();
if (Ty == Type::Int1Ty)
- Out << (CI->getZExtValue() ? '1' : '0') ;
+ Out << (CI->getZExtValue() ? '1' : '0');
+ else if (Ty == Type::Int32Ty)
+ Out << CI->getZExtValue() << 'u';
+ else if (Ty->getPrimitiveSizeInBits() > 32)
+ Out << CI->getZExtValue() << "ull";
else {
Out << "((";
printSimpleType(Out, Ty, false) << ')';
@@ -896,9 +900,7 @@
Out << CI->getZExtValue() << 'u';
else
Out << CI->getSExtValue();
- if (Ty->getPrimitiveSizeInBits() > 32)
- Out << "ll";
- Out << ')';
+ Out << ')';
}
return;
}
@@ -970,7 +972,10 @@
}
case Type::ArrayTyID:
- if (isa<ConstantAggregateZero>(CPV) || isa<UndefValue>(CPV)) {
+ if (const ConstantArray *CA = cast<ConstantArray>(CPV)) {
+ printConstantVector(CA);
+ } else {
+ assert(isa<ConstantAggregateZero>(CPV) || isa<UndefValue>(CPV));
const ArrayType *AT = cast<ArrayType>(CPV->getType());
Out << '{';
if (AT->getNumElements()) {
@@ -983,27 +988,23 @@
}
}
Out << " }";
- } else {
- printConstantArray(cast<ConstantArray>(CPV));
}
break;
case Type::VectorTyID:
- if (isa<ConstantAggregateZero>(CPV) || isa<UndefValue>(CPV)) {
- const VectorType *AT = cast<VectorType>(CPV->getType());
- Out << '{';
- if (AT->getNumElements()) {
- Out << ' ';
- Constant *CZ = Constant::getNullValue(AT->getElementType());
+ if (const ConstantVector *CV = cast<ConstantVector>(CPV)) {
+ printConstantVector(CV);
+ } else {
+ assert(isa<ConstantAggregateZero>(CPV) || isa<UndefValue>(CPV));
+ const VectorType *VT = cast<VectorType>(CPV->getType());
+ Out << "{ ";
+ Constant *CZ = Constant::getNullValue(VT->getElementType());
+ printConstant(CZ);
+ for (unsigned i = 1, e = AT->getNumElements(); i != e; ++i) {
+ Out << ", ";
printConstant(CZ);
- for (unsigned i = 1, e = AT->getNumElements(); i != e; ++i) {
- Out << ", ";
- printConstant(CZ);
- }
}
Out << " }";
- } else {
- printConstantVector(cast<ConstantVector>(CPV));
}
break;
More information about the llvm-commits
mailing list