parent
							
								
									91c62bfc03
								
							
						
					
					
						commit
						55927aa400
					
				| 
						 | 
					@ -28,7 +28,7 @@ using namespace llvm;
 | 
				
			||||||
namespace polly {
 | 
					namespace polly {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// @brief The itertor transform the scalar expressions to the form of sum of
 | 
					/// @brief The itertor transform the scalar expressions to the form of sum of
 | 
				
			||||||
/// (constant * varialbe)s, and return the variable/constant pairs one by one
 | 
					/// (constant * variable)s, and return the variable/constant pairs one by one
 | 
				
			||||||
/// on the fly.
 | 
					/// on the fly.
 | 
				
			||||||
///
 | 
					///
 | 
				
			||||||
/// For example, we can write SCEV:
 | 
					/// For example, we can write SCEV:
 | 
				
			||||||
| 
						 | 
					@ -85,7 +85,7 @@ private:
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  value_type visitUnknown(const SCEVUnknown* S) {
 | 
					  value_type visitUnknown(const SCEVUnknown* S) {
 | 
				
			||||||
    const Type *AllocTy;
 | 
					    Type *AllocTy;
 | 
				
			||||||
    Constant *FieldNo;
 | 
					    Constant *FieldNo;
 | 
				
			||||||
    // We treat these as constant.
 | 
					    // We treat these as constant.
 | 
				
			||||||
    if (S->isSizeOf  (AllocTy) ||
 | 
					    if (S->isSizeOf  (AllocTy) ||
 | 
				
			||||||
| 
						 | 
					@ -235,7 +235,7 @@ public:
 | 
				
			||||||
    if (isa<SCEVCouldNotCompute>(S))
 | 
					    if (isa<SCEVCouldNotCompute>(S))
 | 
				
			||||||
      return;
 | 
					      return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const Type *Ty = S->getType();
 | 
					    Type *Ty = S->getType();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Init the constant component.
 | 
					    // Init the constant component.
 | 
				
			||||||
    visitStack.push_back(SE->getConstant(Ty, 0));
 | 
					    visitStack.push_back(SE->getConstant(Ty, 0));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -111,7 +111,7 @@ static void createLoop(IRBuilder<> *Builder, Value *LB, Value *UB, APInt Stride,
 | 
				
			||||||
  assert(LB->getType() == UB->getType()
 | 
					  assert(LB->getType() == UB->getType()
 | 
				
			||||||
         && "Different types for upper and lower bound.");
 | 
					         && "Different types for upper and lower bound.");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const IntegerType *LoopIVType = dyn_cast<IntegerType>(UB->getType());
 | 
					  IntegerType *LoopIVType = dyn_cast<IntegerType>(UB->getType());
 | 
				
			||||||
  assert(LoopIVType && "UB is not integer?");
 | 
					  assert(LoopIVType && "UB is not integer?");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // IV
 | 
					  // IV
 | 
				
			||||||
| 
						 | 
					@ -211,11 +211,11 @@ public:
 | 
				
			||||||
    return const_cast<Value*>(OldOperand);
 | 
					    return const_cast<Value*>(OldOperand);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const Type *getVectorPtrTy(const Value *V, int vectorWidth) {
 | 
					  Type *getVectorPtrTy(const Value *V, int vectorWidth) {
 | 
				
			||||||
    const PointerType *pointerType = dyn_cast<PointerType>(V->getType());
 | 
					    PointerType *pointerType = dyn_cast<PointerType>(V->getType());
 | 
				
			||||||
    assert(pointerType && "PointerType expected");
 | 
					    assert(pointerType && "PointerType expected");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const Type *scalarType = pointerType->getElementType();
 | 
					    Type *scalarType = pointerType->getElementType();
 | 
				
			||||||
    VectorType *vectorType = VectorType::get(scalarType, vectorWidth);
 | 
					    VectorType *vectorType = VectorType::get(scalarType, vectorWidth);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return PointerType::getUnqual(vectorType);
 | 
					    return PointerType::getUnqual(vectorType);
 | 
				
			||||||
| 
						 | 
					@ -232,7 +232,7 @@ public:
 | 
				
			||||||
  Value *generateStrideOneLoad(const LoadInst *load, ValueMapT &BBMap,
 | 
					  Value *generateStrideOneLoad(const LoadInst *load, ValueMapT &BBMap,
 | 
				
			||||||
                               int size) {
 | 
					                               int size) {
 | 
				
			||||||
    const Value *pointer = load->getPointerOperand();
 | 
					    const Value *pointer = load->getPointerOperand();
 | 
				
			||||||
    const Type *vectorPtrType = getVectorPtrTy(pointer, size);
 | 
					    Type *vectorPtrType = getVectorPtrTy(pointer, size);
 | 
				
			||||||
    Value *newPointer = getOperand(pointer, BBMap);
 | 
					    Value *newPointer = getOperand(pointer, BBMap);
 | 
				
			||||||
    Value *VectorPtr = Builder.CreateBitCast(newPointer, vectorPtrType,
 | 
					    Value *VectorPtr = Builder.CreateBitCast(newPointer, vectorPtrType,
 | 
				
			||||||
                                             "vector_ptr");
 | 
					                                             "vector_ptr");
 | 
				
			||||||
| 
						 | 
					@ -258,7 +258,7 @@ public:
 | 
				
			||||||
  Value *generateStrideZeroLoad(const LoadInst *load, ValueMapT &BBMap,
 | 
					  Value *generateStrideZeroLoad(const LoadInst *load, ValueMapT &BBMap,
 | 
				
			||||||
                                int size) {
 | 
					                                int size) {
 | 
				
			||||||
    const Value *pointer = load->getPointerOperand();
 | 
					    const Value *pointer = load->getPointerOperand();
 | 
				
			||||||
    const Type *vectorPtrType = getVectorPtrTy(pointer, 1);
 | 
					    Type *vectorPtrType = getVectorPtrTy(pointer, 1);
 | 
				
			||||||
    Value *newPointer = getOperand(pointer, BBMap);
 | 
					    Value *newPointer = getOperand(pointer, BBMap);
 | 
				
			||||||
    Value *vectorPtr = Builder.CreateBitCast(newPointer, vectorPtrType,
 | 
					    Value *vectorPtr = Builder.CreateBitCast(newPointer, vectorPtrType,
 | 
				
			||||||
                                             load->getNameStr() + "_p_vec_p");
 | 
					                                             load->getNameStr() + "_p_vec_p");
 | 
				
			||||||
| 
						 | 
					@ -417,7 +417,7 @@ public:
 | 
				
			||||||
        Value *vector = getOperand(store->getValueOperand(), BBMap, &vectorMap);
 | 
					        Value *vector = getOperand(store->getValueOperand(), BBMap, &vectorMap);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (Access.isStrideOne(scatteringDomain)) {
 | 
					        if (Access.isStrideOne(scatteringDomain)) {
 | 
				
			||||||
          const Type *vectorPtrType = getVectorPtrTy(pointer, vectorWidth);
 | 
					          Type *vectorPtrType = getVectorPtrTy(pointer, vectorWidth);
 | 
				
			||||||
          Value *newPointer = getOperand(pointer, BBMap, &vectorMap);
 | 
					          Value *newPointer = getOperand(pointer, BBMap, &vectorMap);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          Value *VectorPtr = Builder.CreateBitCast(newPointer, vectorPtrType,
 | 
					          Value *VectorPtr = Builder.CreateBitCast(newPointer, vectorPtrType,
 | 
				
			||||||
| 
						 | 
					@ -528,7 +528,7 @@ class ClastExpCodeGen {
 | 
				
			||||||
  IRBuilder<> &Builder;
 | 
					  IRBuilder<> &Builder;
 | 
				
			||||||
  const CharMapT *IVS;
 | 
					  const CharMapT *IVS;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Value *codegen(const clast_name *e, const Type *Ty) {
 | 
					  Value *codegen(const clast_name *e, Type *Ty) {
 | 
				
			||||||
    CharMapT::const_iterator I = IVS->find(e->name);
 | 
					    CharMapT::const_iterator I = IVS->find(e->name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (I != IVS->end())
 | 
					    if (I != IVS->end())
 | 
				
			||||||
| 
						 | 
					@ -537,7 +537,7 @@ class ClastExpCodeGen {
 | 
				
			||||||
      llvm_unreachable("Clast name not found");
 | 
					      llvm_unreachable("Clast name not found");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Value *codegen(const clast_term *e, const Type *Ty) {
 | 
					  Value *codegen(const clast_term *e, Type *Ty) {
 | 
				
			||||||
    APInt a = APInt_from_MPZ(e->val);
 | 
					    APInt a = APInt_from_MPZ(e->val);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Value *ConstOne = ConstantInt::get(Builder.getContext(), a);
 | 
					    Value *ConstOne = ConstantInt::get(Builder.getContext(), a);
 | 
				
			||||||
| 
						 | 
					@ -551,7 +551,7 @@ class ClastExpCodeGen {
 | 
				
			||||||
    return ConstOne;
 | 
					    return ConstOne;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Value *codegen(const clast_binary *e, const Type *Ty) {
 | 
					  Value *codegen(const clast_binary *e, Type *Ty) {
 | 
				
			||||||
    Value *LHS = codegen(e->LHS, Ty);
 | 
					    Value *LHS = codegen(e->LHS, Ty);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    APInt RHS_AP = APInt_from_MPZ(e->RHS);
 | 
					    APInt RHS_AP = APInt_from_MPZ(e->RHS);
 | 
				
			||||||
| 
						 | 
					@ -595,7 +595,7 @@ class ClastExpCodeGen {
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Value *codegen(const clast_reduction *r, const Type *Ty) {
 | 
					  Value *codegen(const clast_reduction *r, Type *Ty) {
 | 
				
			||||||
    assert((   r->type == clast_red_min
 | 
					    assert((   r->type == clast_red_min
 | 
				
			||||||
            || r->type == clast_red_max
 | 
					            || r->type == clast_red_max
 | 
				
			||||||
            || r->type == clast_red_sum)
 | 
					            || r->type == clast_red_sum)
 | 
				
			||||||
| 
						 | 
					@ -644,7 +644,7 @@ public:
 | 
				
			||||||
  //
 | 
					  //
 | 
				
			||||||
  // @param e The expression to calculate.
 | 
					  // @param e The expression to calculate.
 | 
				
			||||||
  // @return The Value that holds the result.
 | 
					  // @return The Value that holds the result.
 | 
				
			||||||
  Value *codegen(const clast_expr *e, const Type *Ty) {
 | 
					  Value *codegen(const clast_expr *e, Type *Ty) {
 | 
				
			||||||
    switch(e->type) {
 | 
					    switch(e->type) {
 | 
				
			||||||
      case clast_expr_name:
 | 
					      case clast_expr_name:
 | 
				
			||||||
	return codegen((const clast_name *)e, Ty);
 | 
						return codegen((const clast_name *)e, Ty);
 | 
				
			||||||
| 
						 | 
					@ -914,7 +914,7 @@ public:
 | 
				
			||||||
                                SetVector<Value*> OMPDataVals) {
 | 
					                                SetVector<Value*> OMPDataVals) {
 | 
				
			||||||
    Module *M = Builder.GetInsertBlock()->getParent()->getParent();
 | 
					    Module *M = Builder.GetInsertBlock()->getParent()->getParent();
 | 
				
			||||||
    LLVMContext &Context = FN->getContext();
 | 
					    LLVMContext &Context = FN->getContext();
 | 
				
			||||||
    const IntegerType *intPtrTy = TD->getIntPtrType(Context);
 | 
					    IntegerType *intPtrTy = TD->getIntPtrType(Context);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Store the previous basic block.
 | 
					    // Store the previous basic block.
 | 
				
			||||||
    BasicBlock *PrevBB = Builder.GetInsertBlock();
 | 
					    BasicBlock *PrevBB = Builder.GetInsertBlock();
 | 
				
			||||||
| 
						 | 
					@ -994,7 +994,7 @@ public:
 | 
				
			||||||
  /// statement.
 | 
					  /// statement.
 | 
				
			||||||
  void codegenForOpenMP(const clast_for *f) {
 | 
					  void codegenForOpenMP(const clast_for *f) {
 | 
				
			||||||
    Module *M = Builder.GetInsertBlock()->getParent()->getParent();
 | 
					    Module *M = Builder.GetInsertBlock()->getParent()->getParent();
 | 
				
			||||||
    const IntegerType *intPtrTy = TD->getIntPtrType(Builder.getContext());
 | 
					    IntegerType *intPtrTy = TD->getIntPtrType(Builder.getContext());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Function *SubFunction = addOpenMPSubfunction(M);
 | 
					    Function *SubFunction = addOpenMPSubfunction(M);
 | 
				
			||||||
    SetVector<Value*> OMPDataVals = createOpenMPStructValues();
 | 
					    SetVector<Value*> OMPDataVals = createOpenMPStructValues();
 | 
				
			||||||
| 
						 | 
					@ -1099,7 +1099,7 @@ public:
 | 
				
			||||||
      TD->getIntPtrType(Builder.getContext()));
 | 
					      TD->getIntPtrType(Builder.getContext()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    APInt Stride = APInt_from_MPZ(f->stride);
 | 
					    APInt Stride = APInt_from_MPZ(f->stride);
 | 
				
			||||||
    const IntegerType *LoopIVType = dyn_cast<IntegerType>(LB->getType());
 | 
					    IntegerType *LoopIVType = dyn_cast<IntegerType>(LB->getType());
 | 
				
			||||||
    Stride =  Stride.zext(LoopIVType->getBitWidth());
 | 
					    Stride =  Stride.zext(LoopIVType->getBitWidth());
 | 
				
			||||||
    Value *StrideValue = ConstantInt::get(LoopIVType, Stride);
 | 
					    Value *StrideValue = ConstantInt::get(LoopIVType, Stride);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1214,7 +1214,7 @@ public:
 | 
				
			||||||
      assert(i < names->nb_parameters && "Not enough parameter names");
 | 
					      assert(i < names->nb_parameters && "Not enough parameter names");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      const SCEV *Param = *PI;
 | 
					      const SCEV *Param = *PI;
 | 
				
			||||||
      const Type *Ty = Param->getType();
 | 
					      Type *Ty = Param->getType();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      Instruction *insertLocation = --(Builder.GetInsertBlock()->end());
 | 
					      Instruction *insertLocation = --(Builder.GetInsertBlock()->end());
 | 
				
			||||||
      Value *V = Rewriter.expandCodeFor(Param, Ty, insertLocation);
 | 
					      Value *V = Rewriter.expandCodeFor(Param, Ty, insertLocation);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue