[llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp
Reid Spencer
reid at x10sys.com
Sat Dec 30 21:56:09 PST 2006
Changes in directory llvm/lib/Target/CBackend:
Writer.cpp updated: 1.301 -> 1.302
---
Log message:
For PR950: http://llvm.org/PR950 :
Three changes:
1. Convert signed integer types to signless versions.
2. Implement the @sext and @zext parameter attributes. Previously the
type of an function parameter was used to determine whether it should
be sign extended or zero extended before the call. This information is
now communicated via the function type's parameter attributes.
3. The interface to LowerCallTo had to be changed in order to accommodate
the parameter attribute information. Although it would have been
convenient to pass in the FunctionType itself, there isn't always one
present in the caller. Consequently, a signedness indication for the
result type and for each parameter was provided for in the interface
to this method. All implementations were changed to make the adjustment
necessary.
---
Diffs of the changes: (+16 -56)
Writer.cpp | 72 +++++++++++++------------------------------------------------
1 files changed, 16 insertions(+), 56 deletions(-)
Index: llvm/lib/Target/CBackend/Writer.cpp
diff -u llvm/lib/Target/CBackend/Writer.cpp:1.301 llvm/lib/Target/CBackend/Writer.cpp:1.302
--- llvm/lib/Target/CBackend/Writer.cpp:1.301 Sat Dec 23 00:05:41 2006
+++ llvm/lib/Target/CBackend/Writer.cpp Sat Dec 30 23:55:36 2006
@@ -365,17 +365,13 @@
switch (Ty->getTypeID()) {
case Type::VoidTyID: return Out << "void " << NameSoFar;
case Type::BoolTyID: return Out << "bool " << NameSoFar;
- case Type::UByteTyID:
- case Type::SByteTyID:
+ case Type::Int8TyID:
return Out << (isSigned?"signed":"unsigned") << " char " << NameSoFar;
- case Type::UShortTyID:
- case Type::ShortTyID:
+ case Type::Int16TyID:
return Out << (isSigned?"signed":"unsigned") << " short " << NameSoFar;
- case Type::UIntTyID:
- case Type::IntTyID:
+ case Type::Int32TyID:
return Out << (isSigned?"signed":"unsigned") << " int " << NameSoFar;
- case Type::ULongTyID:
- case Type::LongTyID:
+ case Type::Int64TyID:
return Out << (isSigned?"signed":"unsigned") << " long long " << NameSoFar;
case Type::FloatTyID: return Out << "float " << NameSoFar;
case Type::DoubleTyID: return Out << "double " << NameSoFar;
@@ -488,7 +484,7 @@
// ubytes or an array of sbytes with positive values.
//
const Type *ETy = CPA->getType()->getElementType();
- bool isString = (ETy == Type::SByteTy || ETy == Type::UByteTy);
+ bool isString = (ETy == Type::Int8Ty || ETy == Type::Int8Ty);
// Make sure the last character is a null char, as automatically added by C
if (isString && (CPA->getNumOperands() == 0 ||
@@ -810,50 +806,19 @@
case Type::BoolTyID:
Out << (cast<ConstantBool>(CPV)->getValue() ? '1' : '0');
break;
- case Type::SByteTyID:
- case Type::UByteTyID:
+ case Type::Int8TyID:
Out << "((char)" << cast<ConstantInt>(CPV)->getSExtValue() << ")";
break;
- case Type::ShortTyID:
- case Type::UShortTyID:
+ case Type::Int16TyID:
Out << "((short)" << cast<ConstantInt>(CPV)->getSExtValue() << ")";
break;
- case Type::IntTyID:
- case Type::UIntTyID:
+ case Type::Int32TyID:
Out << "((int)" << cast<ConstantInt>(CPV)->getSExtValue() << ")";
break;
- case Type::LongTyID:
- case Type::ULongTyID:
+ case Type::Int64TyID:
Out << "((long long)" << cast<ConstantInt>(CPV)->getSExtValue() << "ll)";
break;
-#if 0
- case Type::IntTyID:
- if ((int)cast<ConstantInt>(CPV)->getSExtValue() == (int)0x80000000)
- Out << "((int)0x80000000U)"; // Handle MININT specially to avoid warning
- else
- Out << cast<ConstantInt>(CPV)->getSExtValue();
- break;
-
- case Type::LongTyID:
- if (cast<ConstantInt>(CPV)->isMinValue(true))
- Out << "(/*INT64_MIN*/(-9223372036854775807LL)-1)";
- else
- Out << cast<ConstantInt>(CPV)->getSExtValue() << "ll";
- break;
-
- case Type::UByteTyID:
- case Type::UShortTyID:
- Out << cast<ConstantInt>(CPV)->getZExtValue();
- break;
- case Type::UIntTyID:
- Out << cast<ConstantInt>(CPV)->getZExtValue() << 'u';
- break;
- case Type::ULongTyID:
- Out << cast<ConstantInt>(CPV)->getZExtValue() << "ull";
- break;
-#endif
-
case Type::FloatTyID:
case Type::DoubleTyID: {
ConstantFP *FPC = cast<ConstantFP>(CPV);
@@ -1627,10 +1592,8 @@
void CWriter::printModuleTypes(const SymbolTable &ST) {
Out << "/* Helper union for bitcasts */\n";
Out << "typedef union {\n";
- Out << " unsigned int UInt;\n";
- Out << " signed int SInt;\n";
- Out << " unsigned long long ULong;\n";
- Out << " signed long long SLong;\n";
+ Out << " unsigned int Int32;\n";
+ Out << " unsigned long long Int64;\n";
Out << " float Float;\n";
Out << " double Double;\n";
Out << "} llvmBitCastUnion;\n";
@@ -2060,8 +2023,7 @@
// We must cast the results of binary operations which might be promoted.
bool needsCast = false;
- if ((I.getType() == Type::UByteTy) || (I.getType() == Type::SByteTy)
- || (I.getType() == Type::UShortTy) || (I.getType() == Type::ShortTy)
+ if ((I.getType() == Type::Int8Ty) || (I.getType() == Type::Int16Ty)
|| (I.getType() == Type::FloatTy)) {
needsCast = true;
Out << "((";
@@ -2192,12 +2154,10 @@
static const char * getFloatBitCastField(const Type *Ty) {
switch (Ty->getTypeID()) {
default: assert(0 && "Invalid Type");
- case Type::FloatTyID: return "Float";
- case Type::UIntTyID: return "UInt";
- case Type::IntTyID: return "SInt";
- case Type::DoubleTyID:return "Double";
- case Type::ULongTyID: return "ULong";
- case Type::LongTyID: return "SLong";
+ case Type::FloatTyID: return "Float";
+ case Type::Int32TyID: return "Int32";
+ case Type::DoubleTyID: return "Double";
+ case Type::Int64TyID: return "Int64";
}
}
More information about the llvm-commits
mailing list