aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/CBackend/Writer.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-12-31 05:55:36 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-12-31 05:55:36 +0000
commit47857812e29324a9d1560796a05b53d3a9217fd9 (patch)
treedeefd24f91f82ea1f555fda5f53a3ab7d9599f0b /lib/Target/CBackend/Writer.cpp
parente49661bdf5b7a913d4e368cf511381e524ae403a (diff)
For 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32788 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/CBackend/Writer.cpp')
-rw-r--r--lib/Target/CBackend/Writer.cpp72
1 files changed, 16 insertions, 56 deletions
diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp
index af56e26f9e..bb9f801b8a 100644
--- a/lib/Target/CBackend/Writer.cpp
+++ b/lib/Target/CBackend/Writer.cpp
@@ -365,17 +365,13 @@ CWriter::printPrimitiveType(std::ostream &Out, const Type *Ty, bool isSigned,
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 @@ void CWriter::printConstantArray(ConstantArray *CPA) {
// 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 @@ void CWriter::printConstant(Constant *CPV) {
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::printFloatingPointConstants(Function &F) {
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 @@ void CWriter::visitBinaryOperator(Instruction &I) {
// 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 @@ void CWriter::visitFCmpInst(FCmpInst &I) {
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";
}
}