[llvm-commits] [gcc-plugin] r83301 - in /gcc-plugin/trunk: llvm-abi.h llvm-backend.cpp llvm-convert.cpp llvm-types.cpp
Duncan Sands
baldrick at free.fr
Mon Oct 5 06:05:18 PDT 2009
Author: baldrick
Date: Mon Oct 5 08:05:17 2009
New Revision: 83301
URL: http://llvm.org/viewvc/llvm-project?rev=83301&view=rev
Log:
Use new predicates to test whether a type is void, float etc.
Modified:
gcc-plugin/trunk/llvm-abi.h
gcc-plugin/trunk/llvm-backend.cpp
gcc-plugin/trunk/llvm-convert.cpp
gcc-plugin/trunk/llvm-types.cpp
Modified: gcc-plugin/trunk/llvm-abi.h
URL: http://llvm.org/viewvc/llvm-project/gcc-plugin/trunk/llvm-abi.h?rev=83301&r1=83300&r2=83301&view=diff
==============================================================================
--- gcc-plugin/trunk/llvm-abi.h (original)
+++ gcc-plugin/trunk/llvm-abi.h Mon Oct 5 08:05:17 2009
@@ -391,7 +391,7 @@
C.HandleScalarShadowResult(PointerType::getUnqual(Ty), 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)) {
@@ -437,7 +437,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);
@@ -665,7 +665,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);
@@ -687,7 +687,7 @@
}
}
for (unsigned i = 0, e = Elts.size(); i != e; ++i) {
- if (OrigElts[i] != Type::getVoidTy(getGlobalContext())) {
+ if (!OrigElts[i]->isVoidTy()) {
C.EnterField(i, STy);
unsigned RealSize = 0;
if (LastEltSizeDiff && i == (e - 1))
@@ -747,7 +747,7 @@
C.HandleScalarShadowResult(PointerType::getUnqual(Ty), 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)) {
@@ -1110,7 +1110,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);
@@ -1132,7 +1132,7 @@
}
}
for (unsigned i = 0, e = Elts.size(); i != e; ++i) {
- if (OrigElts[i] != Type::getVoidTy(getGlobalContext())) {
+ if (!OrigElts[i]->isVoidTy()) {
C.EnterField(i, STy);
unsigned RealSize = 0;
if (LastEltSizeDiff && i == (e - 1))
Modified: gcc-plugin/trunk/llvm-backend.cpp
URL: http://llvm.org/viewvc/llvm-project/gcc-plugin/trunk/llvm-backend.cpp?rev=83301&r1=83300&r2=83301&view=diff
==============================================================================
--- gcc-plugin/trunk/llvm-backend.cpp (original)
+++ gcc-plugin/trunk/llvm-backend.cpp Mon Oct 5 08:05:17 2009
@@ -1409,7 +1409,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.empty()) { // Global has no name.
Modified: gcc-plugin/trunk/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/gcc-plugin/trunk/llvm-convert.cpp?rev=83301&r1=83300&r2=83301&view=diff
==============================================================================
--- gcc-plugin/trunk/llvm-convert.cpp (original)
+++ gcc-plugin/trunk/llvm-convert.cpp Mon Oct 5 08:05:17 2009
@@ -380,7 +380,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,
@@ -796,7 +796,7 @@
SmallVector <Value *, 4> RetVals;
// If the function returns a value, get it into a register and return it now.
- if (Fn->getReturnType() != Type::getVoidTy(Context)) {
+ if (!Fn->getReturnType()->isVoidTy()) {
if (!AGGREGATE_TYPE_P(TREE_TYPE(DECL_RESULT(FnDecl)))) {
// If the DECL_RESULT is a scalar type, just load out the return value
// and return it.
@@ -2920,7 +2920,7 @@
if (Client.isShadowReturn())
return Client.EmitShadowResult(gimple_call_return_type(stmt), DestLoc);
- if (Call->getType() == Type::getVoidTy(Context))
+ if (Call->getType()->isVoidTy())
return 0;
if (Client.isAggrReturn()) {
@@ -5014,7 +5014,7 @@
// FIXME: HACK: Just ignore these.
{
const Type *Ty = ConvertType(gimple_call_return_type(stmt));
- if (Ty != Type::getVoidTy(Context))
+ if (!Ty->isVoidTy())
Result = Constant::getNullValue(Ty);
return true;
}
@@ -6147,7 +6147,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 = PointerType::getUnqual(Ty);
unsigned Alignment = Ty->isSized() ? TD.getABITypeAlignment(Ty) : 1;
if (DECL_ALIGN(exp)) {
@@ -6987,7 +6987,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:
@@ -7013,9 +7013,8 @@
std::swap(UArr[0], UArr[1]);
return
- ConstantFP::get(Context, Ty==Type::getFloatTy(Context) ?
- APFloat((float)V) : APFloat(V));
- } else if (Ty==Type::getX86_FP80Ty(Context)) {
+ ConstantFP::get(Context, Ty->isFloatTy() ? APFloat((float)V) : APFloat(V));
+ } else if (Ty->isX86_FP80Ty()) {
long RealArr[4];
uint64_t UArr[2];
REAL_VALUE_TO_TARGET_LONG_DOUBLE(TREE_REAL_CST(exp), RealArr);
@@ -7023,7 +7022,7 @@
((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)) {
+ } else if (Ty->isPPC_FP128Ty()) {
long RealArr[4];
uint64_t UArr[2];
REAL_VALUE_TO_TARGET_LONG_DOUBLE(TREE_REAL_CST(exp), RealArr);
@@ -7887,7 +7886,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: gcc-plugin/trunk/llvm-types.cpp
URL: http://llvm.org/viewvc/llvm-project/gcc-plugin/trunk/llvm-types.cpp?rev=83301&r1=83300&r2=83301&view=diff
==============================================================================
--- gcc-plugin/trunk/llvm-types.cpp (original)
+++ gcc-plugin/trunk/llvm-types.cpp Mon Oct 5 08:05:17 2009
@@ -745,7 +745,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).
@@ -780,7 +780,7 @@
Ty = ConvertType(TREE_TYPE(type));
}
- if (Ty == Type::getVoidTy(Context))
+ if (Ty->isVoidTy())
Ty = Type::getInt8Ty(Context); // void* -> sbyte*
return TypeDB.setType(type, PointerType::getUnqual(Ty));
}
More information about the llvm-commits
mailing list