diff options
author | Chris Lattner <sabre@nondot.org> | 2002-05-06 16:15:30 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-05-06 16:15:30 +0000 |
commit | 9b625030c8427a3bc56f5993c0b5b214c393042f (patch) | |
tree | 40bf688c425d93346f3f3a1119f4a9049682724e /lib/Target | |
parent | d44023ecb7a699e52f119bec0eb86830989ff35a (diff) |
Replace all usages of Type::isPointerType with isa<PointerType>
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2486 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target')
-rw-r--r-- | lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp | 4 | ||||
-rw-r--r-- | lib/Target/SparcV9/SparcV9InstrInfo.cpp | 8 | ||||
-rw-r--r-- | lib/Target/SparcV9/SparcV9InstrSelection.cpp | 62 | ||||
-rw-r--r-- | lib/Target/TargetData.cpp | 6 |
4 files changed, 34 insertions, 46 deletions
diff --git a/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp b/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp index d06ac172db..8cf36f83ed 100644 --- a/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp +++ b/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp @@ -277,7 +277,7 @@ ChooseRegOrImmed(Value* val, // Otherwise it needs to be an integer or a NULL pointer if (! CPV->getType()->isIntegral() && - ! (CPV->getType()->isPointerType() && + ! (isa<PointerType>(CPV->getType()) && CPV->isNullValue())) return opType; @@ -287,7 +287,7 @@ ChooseRegOrImmed(Value* val, // unsigned constants to signed). // int64_t intValue; - if (CPV->getType()->isPointerType()) + if (isa<PointerType>(CPV->getType())) { intValue = 0; } diff --git a/lib/Target/SparcV9/SparcV9InstrInfo.cpp b/lib/Target/SparcV9/SparcV9InstrInfo.cpp index 71380ed92a..fd18841dc1 100644 --- a/lib/Target/SparcV9/SparcV9InstrInfo.cpp +++ b/lib/Target/SparcV9/SparcV9InstrInfo.cpp @@ -235,9 +235,9 @@ UltraSparcInstrInfo::CreateCodeToCopyIntToFloat(Function *F, std::vector<TmpInstruction*>& tempVec, TargetMachine& target) const { - assert((val->getType()->isIntegral() || val->getType()->isPointerType()) + assert((val->getType()->isIntegral() || isa<PointerType>(val->getType())) && "Source type must be integral"); - assert((dest->getType() == Type::FloatTy || dest->getType() == Type::DoubleTy) + assert(dest->getType()->isFloatingPoint() && "Dest type must be float/double"); MachineCodeForMethod& mcinfo = MachineCodeForMethod::get(F); @@ -279,9 +279,9 @@ UltraSparcInstrInfo::CreateCodeToCopyFloatToInt(Function *F, std::vector<TmpInstruction*>& tempVec, TargetMachine& target) const { - assert((val->getType() ==Type::FloatTy || val->getType() ==Type::DoubleTy) + assert(val->getType()->isFloatingPoint() && "Source type must be float/double"); - assert((dest->getType()->isIntegral() || dest->getType()->isPointerType()) + assert((dest->getType()->isIntegral() || isa<PointerType>(dest->getType())) && "Dest type must be integral"); MachineCodeForMethod& mcinfo = MachineCodeForMethod::get(F); diff --git a/lib/Target/SparcV9/SparcV9InstrSelection.cpp b/lib/Target/SparcV9/SparcV9InstrSelection.cpp index 7054ae9c44..7109ba4a35 100644 --- a/lib/Target/SparcV9/SparcV9InstrSelection.cpp +++ b/lib/Target/SparcV9/SparcV9InstrSelection.cpp @@ -176,9 +176,7 @@ ChooseBccInstruction(const InstructionNode* instrNode, BinaryOperator* setCCInstr = (BinaryOperator*) setCCNode->getInstruction(); const Type* setCCType = setCCInstr->getOperand(0)->getType(); - isFPBranch = (setCCType == Type::FloatTy || setCCType == Type::DoubleTy); - - if (isFPBranch) + if (setCCType->isFloatingPoint()) return ChooseBFpccInstruction(instrNode, setCCInstr); else return ChooseBpccInstruction(instrNode, setCCInstr); @@ -387,10 +385,8 @@ CreateAddConstInstruction(const InstructionNode* instrNode) // const Type* resultType = instrNode->getInstruction()->getType(); - if (resultType == Type::FloatTy || - resultType == Type::DoubleTy) - { - double dval = cast<ConstantFP>(constOp)->getValue(); + if (ConstantFP *FPC = dyn_cast<ConstantFP>(constOp)) { + double dval = FPC->getValue(); if (dval == 0.0) minstr = CreateMovFloatInstruction(instrNode, resultType); } @@ -404,8 +400,7 @@ ChooseSubInstructionByType(const Type* resultType) { MachineOpCode opCode = INVALID_OPCODE; - if (resultType->isIntegral() || - resultType->isPointerType()) + if (resultType->isIntegral() || isa<PointerType>(resultType)) { opCode = SUB; } @@ -435,13 +430,11 @@ CreateSubConstInstruction(const InstructionNode* instrNode) // const Type* resultType = instrNode->getInstruction()->getType(); - if (resultType == Type::FloatTy || - resultType == Type::DoubleTy) - { - double dval = cast<ConstantFP>(constOp)->getValue(); - if (dval == 0.0) - minstr = CreateMovFloatInstruction(instrNode, resultType); - } + if (ConstantFP *FPC = dyn_cast<ConstantFP>(constOp)) { + double dval = FPC->getValue(); + if (dval == 0.0) + minstr = CreateMovFloatInstruction(instrNode, resultType); + } return minstr; } @@ -537,7 +530,7 @@ CreateMulConstInstruction(const TargetMachine &target, // const Type* resultType = destVal->getType(); - if (resultType->isIntegral() || resultType->isPointerType()) + if (resultType->isIntegral() || isa<PointerType>(resultType)) { unsigned pow; bool isValidConst; @@ -583,10 +576,9 @@ CreateMulConstInstruction(const TargetMachine &target, } else { - if (resultType == Type::FloatTy || - resultType == Type::DoubleTy) + if (ConstantFP *FPC = dyn_cast<ConstantFP>(constOp)) { - double dval = cast<ConstantFP>(constOp)->getValue(); + double dval = FPC->getValue(); if (fabs(dval) == 1) { bool needNeg = (dval < 0); @@ -771,10 +763,9 @@ CreateDivConstInstruction(TargetMachine &target, } else { - if (resultType == Type::FloatTy || - resultType == Type::DoubleTy) + if (ConstantFP *FPC = dyn_cast<ConstantFP>(constOp)) { - double dval = cast<ConstantFP>(constOp)->getValue(); + double dval = FPC->getValue(); if (fabs(dval) == 1) { bool needNeg = (dval < 0); @@ -987,7 +978,7 @@ SetMemOperands_Internal(vector<MachineInstr*>& mvec, // This is a real structure reference if the ptr target is a // structure type, and the first offset is [0] (eliminate that offset). - if (firstIndexIsZero && ptrType->getElementType()->isStructType()) + if (firstIndexIsZero && isa<StructType>(ptrType->getElementType())) { // Compute the offset value using the index vector. Create a // virtual reg. for it since it may not fit in the immed field. @@ -1373,7 +1364,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot, bool isValidConst; if ((constVal->getType()->isIntegral() - || constVal->getType()->isPointerType()) + || isa<PointerType>(constVal->getType())) && GetConstantValueAsSignedInt(constVal, isValidConst) == 0 && isValidConst) { @@ -1519,7 +1510,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot, case 22: // reg: ToBoolTy(reg): { const Type* opType = subtreeRoot->leftChild()->getValue()->getType(); - assert(opType->isIntegral() || opType->isPointerType() + assert(opType->isIntegral() || isa<PointerType>(opType) || opType == Type::BoolTy); forwardOperandNum = 0; // forward first operand to user break; @@ -1532,7 +1523,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot, { const Type* opType = subtreeRoot->leftChild()->getValue()->getType(); assert(opType->isIntegral() || - opType->isPointerType() || + isa<PointerType>(opType) || opType == Type::BoolTy && "Cast is illegal for other types"); forwardOperandNum = 0; // forward first operand to user break; @@ -1545,7 +1536,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot, { const Type* opType = subtreeRoot->leftChild()->getValue()->getType(); if (opType->isIntegral() - || opType->isPointerType() + || isa<PointerType>(opType) || opType == Type::BoolTy) { forwardOperandNum = 0; // forward first operand to user @@ -1559,7 +1550,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot, Value* destForCast; vector<MachineInstr*> minstrVec; - if (opType == Type::FloatTy || opType == Type::DoubleTy) + if (opType->isFloatingPoint()) { // Create a temporary to represent the INT register // into which the FP value will be copied via memory. @@ -1629,7 +1620,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot, Instruction *dest = subtreeRoot->getInstruction(); Value* srcForCast; int n = 0; - if (opType != Type::FloatTy && opType != Type::DoubleTy) + if (opType->isFloatingPoint()) { // Create a temporary to represent the FP register // into which the integer will be copied via memory. @@ -1872,12 +1863,11 @@ GetInstructionsByRule(InstructionNode* subtreeRoot, // a FP condition code register. // Value* leftVal = subtreeRoot->leftChild()->getValue(); - bool isFPCompare = (leftVal->getType() == Type::FloatTy || - leftVal->getType() == Type::DoubleTy); + bool isFPCompare = leftVal->getType()->isFloatingPoint(); TmpInstruction* tmpForCC = GetTmpForCC(setCCInstr, setCCInstr->getParent()->getParent(), - isFPCompare? Type::FloatTy : Type::IntTy); + isFPCompare ? Type::FloatTy : Type::IntTy); MachineCodeForInstruction::get(setCCInstr).addTemp(tmpForCC); if (! isFPCompare) @@ -2104,8 +2094,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot, case 62: // reg: Shl(reg, reg) { const Type* opType = subtreeRoot->leftChild()->getValue()->getType(); assert(opType->isIntegral() - || opType == Type::BoolTy - || opType->isPointerType()&& "Shl unsupported for other types"); + || isa<PointerType>(opType)&& "Shl unsupported for other types"); mvec.push_back(new MachineInstr((opType == Type::LongTy)? SLLX : SLL)); Set3OperandsFromInstr(mvec.back(), subtreeRoot, target); break; @@ -2114,8 +2103,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot, case 63: // reg: Shr(reg, reg) { const Type* opType = subtreeRoot->leftChild()->getValue()->getType(); assert(opType->isIntegral() - || opType == Type::BoolTy - || opType->isPointerType() &&"Shr unsupported for other types"); + || isa<PointerType>(opType) &&"Shr unsupported for other types"); mvec.push_back(new MachineInstr((opType->isSigned() ? ((opType == Type::LongTy)? SRAX : SRA) : ((opType == Type::LongTy)? SRLX : SRL)))); diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp index 8479c6c8db..0df95209b5 100644 --- a/lib/Target/TargetData.cpp +++ b/lib/Target/TargetData.cpp @@ -61,10 +61,10 @@ Annotation *TargetData::TypeAnFactory(AnnotationID AID, const Annotable *T, void *D) { const TargetData &TD = *(const TargetData*)D; assert(AID == TD.AID && "Target data annotation ID mismatch!"); - const Type *Ty = cast<const Type>((const Value *)T); - assert(Ty->isStructType() && + const Type *Ty = cast<Type>((const Value *)T); + assert(isa<StructType>(Ty) && "Can only create StructLayout annotation on structs!"); - return new StructLayout((const StructType *)Ty, TD); + return new StructLayout(cast<StructType>(Ty), TD); } //===----------------------------------------------------------------------===// |