[polly] r214658 - Allow the IslExprBuilder to generate access operations
Johannes Doerfert
jdoerfert at codeaurora.org
Sat Aug 2 18:50:50 PDT 2014
Author: jdoerfert
Date: Sat Aug 2 20:50:50 2014
New Revision: 214658
URL: http://llvm.org/viewvc/llvm-project?rev=214658&view=rev
Log:
Allow the IslExprBuilder to generate access operations
Modified:
polly/trunk/include/polly/CodeGen/IslExprBuilder.h
polly/trunk/lib/CodeGen/IslExprBuilder.cpp
Modified: polly/trunk/include/polly/CodeGen/IslExprBuilder.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/CodeGen/IslExprBuilder.h?rev=214658&r1=214657&r2=214658&view=diff
==============================================================================
--- polly/trunk/include/polly/CodeGen/IslExprBuilder.h (original)
+++ polly/trunk/include/polly/CodeGen/IslExprBuilder.h Sat Aug 2 20:50:50 2014
@@ -120,6 +120,7 @@ private:
llvm::Value *createOp(__isl_take isl_ast_expr *Expr);
llvm::Value *createOpUnary(__isl_take isl_ast_expr *Expr);
+ llvm::Value *createOpAccess(__isl_take isl_ast_expr *Expr);
llvm::Value *createOpBin(__isl_take isl_ast_expr *Expr);
llvm::Value *createOpNAry(__isl_take isl_ast_expr *Expr);
llvm::Value *createOpSelect(__isl_take isl_ast_expr *Expr);
Modified: polly/trunk/lib/CodeGen/IslExprBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslExprBuilder.cpp?rev=214658&r1=214657&r2=214658&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/IslExprBuilder.cpp (original)
+++ polly/trunk/lib/CodeGen/IslExprBuilder.cpp Sat Aug 2 20:50:50 2014
@@ -91,6 +91,38 @@ Value *IslExprBuilder::createOpNAry(__is
return V;
}
+Value *IslExprBuilder::createOpAccess(isl_ast_expr *Expr) {
+ assert(isl_ast_expr_get_type(Expr) == isl_ast_expr_op &&
+ "isl ast expression not of type isl_ast_op");
+ assert(isl_ast_expr_get_op_type(Expr) == isl_ast_op_access &&
+ "not an access isl ast expression");
+ assert(isl_ast_expr_get_op_n_arg(Expr) >= 2 &&
+ "We need at least two operands to create a member access.");
+
+ // TODO: Support for multi-dimensional array.
+ assert(isl_ast_expr_get_op_n_arg(Expr) == 2 &&
+ "Multidimensional access functions are not supported yet");
+
+ Value *Base = create(isl_ast_expr_get_op_arg(Expr, 0));
+ assert(Base->getType()->isPointerTy() && "Access base should be a pointer");
+
+ Value *Index = create(isl_ast_expr_get_op_arg(Expr, 1));
+ assert(Index->getType()->isIntegerTy() &&
+ "Access index should be an integer");
+
+ // TODO: Change the type of base before we create the GEP.
+ Type *PtrElTy = Base->getType()->getPointerElementType();
+ assert((PtrElTy->isIntOrIntVectorTy() || PtrElTy->isFPOrFPVectorTy()) &&
+ "We do not yet change the type of the access base during code "
+ "generation.");
+
+ Twine Name = "polly.access." + Base->getName();
+ Value *Access = Builder.CreateGEP(Base, Index, Name);
+
+ isl_ast_expr_free(Expr);
+ return Access;
+}
+
Value *IslExprBuilder::createOpBin(__isl_take isl_ast_expr *Expr) {
Value *LHS, *RHS, *Res;
Type *MaxType;
@@ -303,8 +335,9 @@ Value *IslExprBuilder::createOp(__isl_ta
case isl_ast_op_or_else:
case isl_ast_op_call:
case isl_ast_op_member:
- case isl_ast_op_access:
llvm_unreachable("Unsupported isl ast expression");
+ case isl_ast_op_access:
+ return createOpAccess(Expr);
case isl_ast_op_max:
case isl_ast_op_min:
return createOpNAry(Expr);
More information about the llvm-commits
mailing list