[llvm-commits] [llvm-gcc-4.2] r83878 - in /llvm-gcc-4.2/trunk/gcc: config/i386/llvm-i386.cpp llvm-abi.h llvm-backend.cpp llvm-convert.cpp llvm-types.cpp
Duncan Sands
baldrick at free.fr
Mon Oct 12 12:37:58 PDT 2009
Author: baldrick
Date: Mon Oct 12 14:37:58 2009
New Revision: 83878
URL: http://llvm.org/viewvc/llvm-project?rev=83878&view=rev
Log:
Port of dragonegg commit 83301: Use new predicates to test whether
a type is void, float etc.
Modified:
llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp
llvm-gcc-4.2/trunk/gcc/llvm-abi.h
llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp?rev=83878&r1=83877&r2=83878&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Mon Oct 12 14:37:58 2009
@@ -672,8 +672,8 @@
// as loads and stores of it get only 10 bytes.
if (EltTy == Type::getInt32Ty(Context) ||
EltTy == Type::getInt64Ty(Context) ||
- EltTy == Type::getFloatTy(Context) ||
- EltTy == Type::getDoubleTy(Context) ||
+ EltTy->isFloatTy() ||
+ EltTy->isDoubleTy() ||
isa<PointerType>(EltTy)) {
Elts.push_back(EltTy);
continue;
@@ -702,8 +702,8 @@
// short in 32-bit.
const Type *EltTy = STy->getElementType(0);
return !((TARGET_64BIT && (EltTy->isInteger() ||
- EltTy == Type::getFloatTy(Context) ||
- EltTy == Type::getDoubleTy(Context))) ||
+ EltTy->isFloatTy() ||
+ EltTy->isDoubleTy())) ||
EltTy == Type::getInt16Ty(Context) ||
EltTy == Type::getInt8Ty(Context));
}
@@ -746,7 +746,7 @@
++NumXMMs;
} else if (Ty->isInteger() || isa<PointerType>(Ty)) {
++NumGPRs;
- } else if (Ty==Type::getVoidTy(Context)) {
+ } else if (Ty->isVoidTy()) {
// Padding bytes that are not passed anywhere
;
} else {
Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi.h?rev=83878&r1=83877&r2=83878&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Mon Oct 12 14:37:58 2009
@@ -393,7 +393,7 @@
C.HandleScalarShadowResult(Ty->getPointerTo(), false);
else
C.HandleScalarResult(Ty);
- } else if (Ty->isSingleValueType() || Ty == Type::getVoidTy(getGlobalContext())) {
+ } else if (Ty->isSingleValueType() || Ty->isVoidTy()) {
// Return scalar values normally.
C.HandleScalarResult(Ty);
} else if (doNotUseShadowReturn(type, fn)) {
@@ -439,7 +439,7 @@
// Figure out if this field is zero bits wide, e.g. {} or [0 x int]. Do
// not include variable sized fields here.
std::vector<const Type*> Elts;
- if (Ty == Type::getVoidTy(getGlobalContext())) {
+ if (Ty->isVoidTy()) {
// Handle void explicitly as an opaque type.
const Type *OpTy = OpaqueType::get(getGlobalContext());
C.HandleScalarArgument(OpTy, type);
@@ -667,7 +667,7 @@
const Type* wordType = getTargetData().getPointerSize() == 4 ?
Type::getInt32Ty(getGlobalContext()) : Type::getInt64Ty(getGlobalContext());
for (unsigned i=0, e=Elts.size(); i!=e; ++i)
- if (OrigElts[i]==Type::getVoidTy(getGlobalContext()))
+ if (OrigElts[i]->isVoidTy())
Elts[i] = wordType;
const StructType *STy = StructType::get(getGlobalContext(), Elts, false);
@@ -749,7 +749,7 @@
C.HandleScalarShadowResult(Ty->getPointerTo(), false);
else
C.HandleScalarResult(Ty);
- } else if (Ty->isSingleValueType() || Ty == Type::getVoidTy(getGlobalContext())) {
+ } else if (Ty->isSingleValueType() || Ty->isVoidTy()) {
// Return scalar values normally.
C.HandleScalarResult(Ty);
} else if (doNotUseShadowReturn(type, fn)) {
@@ -1112,7 +1112,7 @@
const Type* wordType = getTargetData().getPointerSize() == 4
? Type::getInt32Ty(getGlobalContext()) : Type::getInt64Ty(getGlobalContext());
for (unsigned i=0, e=Elts.size(); i!=e; ++i)
- if (OrigElts[i]==Type::getVoidTy(getGlobalContext()))
+ if (OrigElts[i]->isVoidTy())
Elts[i] = wordType;
const StructType *STy = StructType::get(getGlobalContext(), Elts, false);
Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=83878&r1=83877&r2=83878&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Mon Oct 12 14:37:58 2009
@@ -1622,7 +1622,7 @@
// If we have "extern void foo", make the global have type {} instead of
// type void.
- if (Ty == Type::getVoidTy(Context))
+ if (Ty->isVoidTy())
Ty = StructType::get(Context);
if (Name[0] == 0) { // Global has no name.
Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=83878&r1=83877&r2=83878&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Mon Oct 12 14:37:58 2009
@@ -329,7 +329,7 @@
// If this is GCC being sloppy about pointer types, insert a bitcast.
// See PR1083 for an example.
ArgVal = Builder.CreateBitCast(ArgVal, LLVMTy);
- } else if (ArgVal->getType() == Type::getDoubleTy(Context)) {
+ } else if (ArgVal->getType()->isDoubleTy()) {
// If this is a K&R float parameter, it got promoted to double. Insert
// the truncation to float now.
ArgVal = Builder.CreateFPTrunc(ArgVal, LLVMTy,
@@ -2811,7 +2811,7 @@
if (Client.isShadowReturn())
return Client.EmitShadowResult(TREE_TYPE(exp), DestLoc);
- if (Call->getType() == Type::getVoidTy(Context))
+ if (Call->getType()->isVoidTy())
return 0;
if (Client.isAggrReturn()) {
@@ -3072,7 +3072,7 @@
assert(!isAggregateTreeType(TREE_TYPE(Op))
&& "Aggregate to scalar nop_expr!");
Value *OpVal = Emit(Op, DestLoc);
- if (Ty == Type::getVoidTy(Context)) return 0;
+ if (Ty->isVoidTy()) return 0;
return CastToAnyType(OpVal, OpIsSigned, Ty, ExpIsSigned);
} else if (isAggregateTreeType(TREE_TYPE(Op))) {
// Aggregate to aggregate copy.
@@ -6827,7 +6827,7 @@
const Type *Ty = ConvertType(TREE_TYPE(exp));
// If we have "extern void foo", make the global have type {} instead of
// type void.
- if (Ty == Type::getVoidTy(Context)) Ty = StructType::get(Context);
+ if (Ty->isVoidTy()) Ty = StructType::get(Context);
const PointerType *PTy = Ty->getPointerTo();
unsigned Alignment = Ty->isSized() ? TD.getABITypeAlignment(Ty) : 1;
if (DECL_ALIGN(exp)) {
@@ -7046,7 +7046,7 @@
int UArr[2];
double V;
};
- if (Ty==Type::getFloatTy(Context) || Ty==Type::getDoubleTy(Context)) {
+ if (Ty->isFloatTy() || Ty->isDoubleTy()) {
REAL_VALUE_TO_TARGET_DOUBLE(TREE_REAL_CST(exp), RealArr);
// Here's how this works:
@@ -7072,9 +7072,9 @@
std::swap(UArr[0], UArr[1]);
return
- ConstantFP::get(Context, Ty==Type::getFloatTy(Context) ?
+ ConstantFP::get(Context, Ty->isFloatTy() ?
APFloat((float)V) : APFloat(V));
- } else if (Ty==Type::getX86_FP80Ty(Context)) {
+ } else if (Ty->isX86_FP80Ty()) {
long RealArr[4];
uint64_t UArr[2];
REAL_VALUE_TO_TARGET_LONG_DOUBLE(TREE_REAL_CST(exp), RealArr);
@@ -7082,8 +7082,8 @@
((uint64_t)((uint32_t)RealArr[1]) << 32);
UArr[1] = (uint16_t)RealArr[2];
return ConstantFP::get(Context, APFloat(APInt(80, 2, UArr)));
- } else if (Ty==Type::getPPC_FP128Ty(Context) ||
- Ty==Type::getFP128Ty(Context)) {
+ } else if (Ty->isPPC_FP128Ty() ||
+ Ty->isFP128Ty()) {
long RealArr[4];
uint64_t UArr[2];
REAL_VALUE_TO_TARGET_LONG_DOUBLE(TREE_REAL_CST(exp), RealArr);
@@ -7094,7 +7094,7 @@
((uint64_t)((uint32_t)RealArr[3]));
return ConstantFP::get(Context,
APFloat(APInt(128, 2, UArr),
- /*isIEEE*/ Ty==Type::getFP128Ty(Context)));
+ /*isIEEE*/ Ty->isFP128Ty()));
}
assert(0 && "Floating point type not handled yet");
return 0; // outwit compiler warning
@@ -7960,7 +7960,7 @@
// itself (allowed in GCC but not in LLVM) then the global is changed to have
// the type of the initializer. Correct for this now.
const Type *Ty = ConvertType(TREE_TYPE(exp));
- if (Ty == Type::getVoidTy(Context)) Ty = Type::getInt8Ty(Context); // void* -> i8*.
+ if (Ty->isVoidTy()) Ty = Type::getInt8Ty(Context); // void* -> i8*.
return TheFolder->CreateBitCast(Val, Ty->getPointerTo());
}
Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=83878&r1=83877&r2=83878&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Mon Oct 12 14:37:58 2009
@@ -804,7 +804,7 @@
// Restore ConvertingStruct for the caller.
ConvertingStruct = false;
- if (Actual == Type::getVoidTy(Context))
+ if (Actual->isVoidTy())
Actual = Type::getInt8Ty(Context); // void* -> sbyte*
// Update the type, potentially updating TYPE_LLVM(type).
@@ -838,7 +838,7 @@
Ty = ConvertType(TREE_TYPE(type));
}
- if (Ty == Type::getVoidTy(Context))
+ if (Ty->isVoidTy())
Ty = Type::getInt8Ty(Context); // void* -> sbyte*
return TypeDB.setType(type, Ty->getPointerTo());
}
More information about the llvm-commits
mailing list