mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-07-21 02:29:22 +00:00
Use more type helper functions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193109 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
599c0afb24
commit
244d245974
@ -3167,7 +3167,7 @@ const SCEV *ScalarEvolution::createNodeForGEP(GEPOperator *GEP) {
|
|||||||
Type *IntPtrTy = getEffectiveSCEVType(GEP->getType());
|
Type *IntPtrTy = getEffectiveSCEVType(GEP->getType());
|
||||||
Value *Base = GEP->getOperand(0);
|
Value *Base = GEP->getOperand(0);
|
||||||
// Don't attempt to analyze GEPs over unsized objects.
|
// Don't attempt to analyze GEPs over unsized objects.
|
||||||
if (!cast<PointerType>(Base->getType())->getElementType()->isSized())
|
if (!Base->getType()->getPointerElementType()->isSized())
|
||||||
return getUnknown(GEP);
|
return getUnknown(GEP);
|
||||||
|
|
||||||
// Don't blindly transfer the inbounds flag from the GEP instruction to the
|
// Don't blindly transfer the inbounds flag from the GEP instruction to the
|
||||||
|
@ -1175,8 +1175,7 @@ static Value *GetHeapSROAValue(Value *V, unsigned FieldNo,
|
|||||||
} else if (PHINode *PN = dyn_cast<PHINode>(V)) {
|
} else if (PHINode *PN = dyn_cast<PHINode>(V)) {
|
||||||
// PN's type is pointer to struct. Make a new PHI of pointer to struct
|
// PN's type is pointer to struct. Make a new PHI of pointer to struct
|
||||||
// field.
|
// field.
|
||||||
StructType *ST =
|
StructType *ST = cast<StructType>(PN->getType()->getPointerElementType());
|
||||||
cast<StructType>(cast<PointerType>(PN->getType())->getElementType());
|
|
||||||
|
|
||||||
PHINode *NewPN =
|
PHINode *NewPN =
|
||||||
PHINode::Create(PointerType::getUnqual(ST->getElementType(FieldNo)),
|
PHINode::Create(PointerType::getUnqual(ST->getElementType(FieldNo)),
|
||||||
@ -2013,8 +2012,7 @@ static GlobalVariable *InstallGlobalCtors(GlobalVariable *GCL,
|
|||||||
CSVals[1] = 0;
|
CSVals[1] = 0;
|
||||||
|
|
||||||
StructType *StructTy =
|
StructType *StructTy =
|
||||||
cast <StructType>(
|
cast<StructType>(GCL->getType()->getElementType()->getArrayElementType());
|
||||||
cast<ArrayType>(GCL->getType()->getElementType())->getElementType());
|
|
||||||
|
|
||||||
// Create the new init list.
|
// Create the new init list.
|
||||||
std::vector<Constant*> CAList;
|
std::vector<Constant*> CAList;
|
||||||
|
@ -1172,7 +1172,7 @@ static Value *GetLoadValueForLoad(LoadInst *SrcVal, unsigned Offset,
|
|||||||
Type *DestPTy =
|
Type *DestPTy =
|
||||||
IntegerType::get(LoadTy->getContext(), NewLoadSize*8);
|
IntegerType::get(LoadTy->getContext(), NewLoadSize*8);
|
||||||
DestPTy = PointerType::get(DestPTy,
|
DestPTy = PointerType::get(DestPTy,
|
||||||
cast<PointerType>(PtrVal->getType())->getAddressSpace());
|
PtrVal->getType()->getPointerAddressSpace());
|
||||||
Builder.SetCurrentDebugLocation(SrcVal->getDebugLoc());
|
Builder.SetCurrentDebugLocation(SrcVal->getDebugLoc());
|
||||||
PtrVal = Builder.CreateBitCast(PtrVal, DestPTy);
|
PtrVal = Builder.CreateBitCast(PtrVal, DestPTy);
|
||||||
LoadInst *NewLoad = Builder.CreateLoad(PtrVal);
|
LoadInst *NewLoad = Builder.CreateLoad(PtrVal);
|
||||||
|
@ -625,10 +625,10 @@ namespace {
|
|||||||
ConstantInt *IntOff = ConstOffSCEV->getValue();
|
ConstantInt *IntOff = ConstOffSCEV->getValue();
|
||||||
int64_t Offset = IntOff->getSExtValue();
|
int64_t Offset = IntOff->getSExtValue();
|
||||||
|
|
||||||
Type *VTy = cast<PointerType>(IPtr->getType())->getElementType();
|
Type *VTy = IPtr->getType()->getPointerElementType();
|
||||||
int64_t VTyTSS = (int64_t) TD->getTypeStoreSize(VTy);
|
int64_t VTyTSS = (int64_t) TD->getTypeStoreSize(VTy);
|
||||||
|
|
||||||
Type *VTy2 = cast<PointerType>(JPtr->getType())->getElementType();
|
Type *VTy2 = JPtr->getType()->getPointerElementType();
|
||||||
if (VTy != VTy2 && Offset < 0) {
|
if (VTy != VTy2 && Offset < 0) {
|
||||||
int64_t VTy2TSS = (int64_t) TD->getTypeStoreSize(VTy2);
|
int64_t VTy2TSS = (int64_t) TD->getTypeStoreSize(VTy2);
|
||||||
OffsetInElmts = Offset/VTy2TSS;
|
OffsetInElmts = Offset/VTy2TSS;
|
||||||
@ -2231,11 +2231,12 @@ namespace {
|
|||||||
// The pointer value is taken to be the one with the lowest offset.
|
// The pointer value is taken to be the one with the lowest offset.
|
||||||
Value *VPtr = IPtr;
|
Value *VPtr = IPtr;
|
||||||
|
|
||||||
Type *ArgTypeI = cast<PointerType>(IPtr->getType())->getElementType();
|
Type *ArgTypeI = IPtr->getType()->getPointerElementType();
|
||||||
Type *ArgTypeJ = cast<PointerType>(JPtr->getType())->getElementType();
|
Type *ArgTypeJ = JPtr->getType()->getPointerElementType();
|
||||||
Type *VArgType = getVecTypeForPair(ArgTypeI, ArgTypeJ);
|
Type *VArgType = getVecTypeForPair(ArgTypeI, ArgTypeJ);
|
||||||
Type *VArgPtrType = PointerType::get(VArgType,
|
Type *VArgPtrType
|
||||||
cast<PointerType>(IPtr->getType())->getAddressSpace());
|
= PointerType::get(VArgType,
|
||||||
|
IPtr->getType()->getPointerAddressSpace());
|
||||||
return new BitCastInst(VPtr, VArgPtrType, getReplacementName(I, true, o),
|
return new BitCastInst(VPtr, VArgPtrType, getReplacementName(I, true, o),
|
||||||
/* insert before */ I);
|
/* insert before */ I);
|
||||||
}
|
}
|
||||||
@ -2244,7 +2245,7 @@ namespace {
|
|||||||
unsigned MaskOffset, unsigned NumInElem,
|
unsigned MaskOffset, unsigned NumInElem,
|
||||||
unsigned NumInElem1, unsigned IdxOffset,
|
unsigned NumInElem1, unsigned IdxOffset,
|
||||||
std::vector<Constant*> &Mask) {
|
std::vector<Constant*> &Mask) {
|
||||||
unsigned NumElem1 = cast<VectorType>(J->getType())->getNumElements();
|
unsigned NumElem1 = J->getType()->getVectorNumElements();
|
||||||
for (unsigned v = 0; v < NumElem1; ++v) {
|
for (unsigned v = 0; v < NumElem1; ++v) {
|
||||||
int m = cast<ShuffleVectorInst>(J)->getMaskValue(v);
|
int m = cast<ShuffleVectorInst>(J)->getMaskValue(v);
|
||||||
if (m < 0) {
|
if (m < 0) {
|
||||||
@ -2271,18 +2272,18 @@ namespace {
|
|||||||
Type *ArgTypeJ = J->getType();
|
Type *ArgTypeJ = J->getType();
|
||||||
Type *VArgType = getVecTypeForPair(ArgTypeI, ArgTypeJ);
|
Type *VArgType = getVecTypeForPair(ArgTypeI, ArgTypeJ);
|
||||||
|
|
||||||
unsigned NumElemI = cast<VectorType>(ArgTypeI)->getNumElements();
|
unsigned NumElemI = ArgTypeI->getVectorNumElements();
|
||||||
|
|
||||||
// Get the total number of elements in the fused vector type.
|
// Get the total number of elements in the fused vector type.
|
||||||
// By definition, this must equal the number of elements in
|
// By definition, this must equal the number of elements in
|
||||||
// the final mask.
|
// the final mask.
|
||||||
unsigned NumElem = cast<VectorType>(VArgType)->getNumElements();
|
unsigned NumElem = VArgType->getVectorNumElements();
|
||||||
std::vector<Constant*> Mask(NumElem);
|
std::vector<Constant*> Mask(NumElem);
|
||||||
|
|
||||||
Type *OpTypeI = I->getOperand(0)->getType();
|
Type *OpTypeI = I->getOperand(0)->getType();
|
||||||
unsigned NumInElemI = cast<VectorType>(OpTypeI)->getNumElements();
|
unsigned NumInElemI = OpTypeI->getVectorNumElements();
|
||||||
Type *OpTypeJ = J->getOperand(0)->getType();
|
Type *OpTypeJ = J->getOperand(0)->getType();
|
||||||
unsigned NumInElemJ = cast<VectorType>(OpTypeJ)->getNumElements();
|
unsigned NumInElemJ = OpTypeJ->getVectorNumElements();
|
||||||
|
|
||||||
// The fused vector will be:
|
// The fused vector will be:
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
@ -2427,11 +2428,12 @@ namespace {
|
|||||||
|
|
||||||
if (CanUseInputs) {
|
if (CanUseInputs) {
|
||||||
unsigned LOpElem =
|
unsigned LOpElem =
|
||||||
cast<VectorType>(cast<Instruction>(LOp)->getOperand(0)->getType())
|
cast<Instruction>(LOp)->getOperand(0)->getType()
|
||||||
->getNumElements();
|
->getVectorNumElements();
|
||||||
|
|
||||||
unsigned HOpElem =
|
unsigned HOpElem =
|
||||||
cast<VectorType>(cast<Instruction>(HOp)->getOperand(0)->getType())
|
cast<Instruction>(HOp)->getOperand(0)->getType()
|
||||||
->getNumElements();
|
->getVectorNumElements();
|
||||||
|
|
||||||
// We have one or two input vectors. We need to map each index of the
|
// We have one or two input vectors. We need to map each index of the
|
||||||
// operands to the index of the original vector.
|
// operands to the index of the original vector.
|
||||||
@ -2647,14 +2649,14 @@ namespace {
|
|||||||
getReplacementName(IBeforeJ ? I : J,
|
getReplacementName(IBeforeJ ? I : J,
|
||||||
true, o, 1));
|
true, o, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
NHOp->insertBefore(IBeforeJ ? J : I);
|
NHOp->insertBefore(IBeforeJ ? J : I);
|
||||||
HOp = NHOp;
|
HOp = NHOp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ArgType->isVectorTy()) {
|
if (ArgType->isVectorTy()) {
|
||||||
unsigned numElem = cast<VectorType>(VArgType)->getNumElements();
|
unsigned numElem = VArgType->getVectorNumElements();
|
||||||
std::vector<Constant*> Mask(numElem);
|
std::vector<Constant*> Mask(numElem);
|
||||||
for (unsigned v = 0; v < numElem; ++v) {
|
for (unsigned v = 0; v < numElem; ++v) {
|
||||||
unsigned Idx = v;
|
unsigned Idx = v;
|
||||||
|
@ -1069,7 +1069,7 @@ Value *InnerLoopVectorizer::getConsecutiveVector(Value* Val, int StartIdx,
|
|||||||
int LoopVectorizationLegality::isConsecutivePtr(Value *Ptr) {
|
int LoopVectorizationLegality::isConsecutivePtr(Value *Ptr) {
|
||||||
assert(Ptr->getType()->isPointerTy() && "Unexpected non ptr");
|
assert(Ptr->getType()->isPointerTy() && "Unexpected non ptr");
|
||||||
// Make sure that the pointer does not point to structs.
|
// Make sure that the pointer does not point to structs.
|
||||||
if (cast<PointerType>(Ptr->getType())->getElementType()->isAggregateType())
|
if (Ptr->getType()->getPointerElementType()->isAggregateType())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// If this value is a pointer induction variable we know it is consecutive.
|
// If this value is a pointer induction variable we know it is consecutive.
|
||||||
|
Loading…
Reference in New Issue
Block a user