[polly] r218045 - Allow the IslExprBuilder to build address of expressions
Johannes Doerfert
doerfert at cs.uni-saarland.de
Thu Sep 18 04:14:30 PDT 2014
Author: jdoerfert
Date: Thu Sep 18 06:14:30 2014
New Revision: 218045
URL: http://llvm.org/viewvc/llvm-project?rev=218045&view=rev
Log:
Allow the IslExprBuilder to build address of expressions
Modified:
polly/trunk/include/polly/CodeGen/IslExprBuilder.h
polly/trunk/lib/CodeGen/BlockGenerators.cpp
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=218045&r1=218044&r2=218045&view=diff
==============================================================================
--- polly/trunk/include/polly/CodeGen/IslExprBuilder.h (original)
+++ polly/trunk/include/polly/CodeGen/IslExprBuilder.h Thu Sep 18 06:14:30 2014
@@ -130,6 +130,8 @@ private:
llvm::Value *createOpBoolean(__isl_take isl_ast_expr *Expr);
llvm::Value *createId(__isl_take isl_ast_expr *Expr);
llvm::Value *createInt(__isl_take isl_ast_expr *Expr);
+ llvm::Value *createOpAddressOf(__isl_take isl_ast_expr *Expr);
+ llvm::Value *createAccessAddress(__isl_take isl_ast_expr *Expr);
};
}
Modified: polly/trunk/lib/CodeGen/BlockGenerators.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/BlockGenerators.cpp?rev=218045&r1=218044&r2=218045&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/BlockGenerators.cpp (original)
+++ polly/trunk/lib/CodeGen/BlockGenerators.cpp Thu Sep 18 06:14:30 2014
@@ -186,6 +186,7 @@ Value *BlockGenerator::getNewAccessOpera
PWAccRel = isl_pw_multi_aff_pullback_pw_multi_aff(PWAccRel, PWSchedule);
Expr = isl_ast_build_access_from_pw_multi_aff(Build, PWAccRel);
+ Expr = isl_ast_expr_address_of(Expr);
return ExprBuilder->create(Expr);
}
Modified: polly/trunk/lib/CodeGen/IslExprBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslExprBuilder.cpp?rev=218045&r1=218044&r2=218045&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/IslExprBuilder.cpp (original)
+++ polly/trunk/lib/CodeGen/IslExprBuilder.cpp Thu Sep 18 06:14:30 2014
@@ -91,7 +91,7 @@ Value *IslExprBuilder::createOpNAry(__is
return V;
}
-Value *IslExprBuilder::createOpAccess(isl_ast_expr *Expr) {
+Value *IslExprBuilder::createAccessAddress(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 &&
@@ -140,6 +140,12 @@ Value *IslExprBuilder::createOpAccess(is
return Access;
}
+Value *IslExprBuilder::createOpAccess(isl_ast_expr *Expr) {
+ Value *Addr = createAccessAddress(Expr);
+ assert(Addr && "Could not create op access address");
+ return Builder.CreateLoad(Addr, Addr->getName() + ".load");
+}
+
Value *IslExprBuilder::createOpBin(__isl_take isl_ast_expr *Expr) {
Value *LHS, *RHS, *Res;
Type *MaxType;
@@ -355,7 +361,6 @@ 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_address_of:
llvm_unreachable("Unsupported isl ast expression");
case isl_ast_op_access:
return createOpAccess(Expr);
@@ -383,11 +388,31 @@ Value *IslExprBuilder::createOp(__isl_ta
case isl_ast_op_ge:
case isl_ast_op_gt:
return createOpICmp(Expr);
+ case isl_ast_op_address_of:
+ return createOpAddressOf(Expr);
}
llvm_unreachable("Unsupported isl_ast_expr_op kind.");
}
+Value *IslExprBuilder::createOpAddressOf(__isl_take isl_ast_expr *Expr) {
+ assert(isl_ast_expr_get_type(Expr) == isl_ast_expr_op &&
+ "Expected an isl_ast_expr_op expression.");
+ assert(isl_ast_expr_get_op_n_arg(Expr) == 1 && "Address of should be unary.");
+
+ isl_ast_expr *Op = isl_ast_expr_get_op_arg(Expr, 0);
+ assert(isl_ast_expr_get_type(Op) == isl_ast_expr_op &&
+ "Expected address of operator to be an isl_ast_expr_op expression.");
+ assert(isl_ast_expr_get_op_type(Op) == isl_ast_op_access &&
+ "Expected address of operator to be an access expression.");
+
+ Value *V = createAccessAddress(Op);
+
+ isl_ast_expr_free(Expr);
+
+ return V;
+}
+
Value *IslExprBuilder::createId(__isl_take isl_ast_expr *Expr) {
assert(isl_ast_expr_get_type(Expr) == isl_ast_expr_id &&
"Expression not of type isl_ast_expr_ident");
More information about the llvm-commits
mailing list