forked from OSchip/llvm-project
[CodeGen] Convert IslNodeBuilder::getUpperBound to isl++. NFC.
llvm-svn: 338449
This commit is contained in:
parent
9fb2e3ceaa
commit
ade2242e7e
|
|
@ -248,8 +248,7 @@ protected:
|
||||||
// of loop iterations.
|
// of loop iterations.
|
||||||
//
|
//
|
||||||
// 3. With the existing code, upper bounds have been easier to implement.
|
// 3. With the existing code, upper bounds have been easier to implement.
|
||||||
__isl_give isl_ast_expr *getUpperBound(__isl_keep isl_ast_node *For,
|
isl::ast_expr getUpperBound(isl::ast_node For, CmpInst::Predicate &Predicate);
|
||||||
CmpInst::Predicate &Predicate);
|
|
||||||
|
|
||||||
/// Return non-negative number of iterations in case of the following form
|
/// Return non-negative number of iterations in case of the following form
|
||||||
/// of a loop and -1 otherwise.
|
/// of a loop and -1 otherwise.
|
||||||
|
|
|
||||||
|
|
@ -100,21 +100,16 @@ static cl::opt<int> PollyTargetFirstLevelCacheLineSize(
|
||||||
cl::desc("The size of the first level cache line size specified in bytes."),
|
cl::desc("The size of the first level cache line size specified in bytes."),
|
||||||
cl::Hidden, cl::init(64), cl::ZeroOrMore, cl::cat(PollyCategory));
|
cl::Hidden, cl::init(64), cl::ZeroOrMore, cl::cat(PollyCategory));
|
||||||
|
|
||||||
__isl_give isl_ast_expr *
|
isl::ast_expr IslNodeBuilder::getUpperBound(isl::ast_node For,
|
||||||
IslNodeBuilder::getUpperBound(__isl_keep isl_ast_node *For,
|
ICmpInst::Predicate &Predicate) {
|
||||||
ICmpInst::Predicate &Predicate) {
|
isl::ast_expr Cond = For.for_get_cond();
|
||||||
isl_id *UBID, *IteratorID;
|
isl::ast_expr Iterator = For.for_get_iterator();
|
||||||
isl_ast_expr *Cond, *Iterator, *UB, *Arg0;
|
assert(isl_ast_expr_get_type(Cond.get()) == isl_ast_expr_op &&
|
||||||
isl_ast_op_type Type;
|
|
||||||
|
|
||||||
Cond = isl_ast_node_for_get_cond(For);
|
|
||||||
Iterator = isl_ast_node_for_get_iterator(For);
|
|
||||||
assert(isl_ast_expr_get_type(Cond) == isl_ast_expr_op &&
|
|
||||||
"conditional expression is not an atomic upper bound");
|
"conditional expression is not an atomic upper bound");
|
||||||
|
|
||||||
Type = isl_ast_expr_get_op_type(Cond);
|
isl_ast_op_type OpType = isl_ast_expr_get_op_type(Cond.get());
|
||||||
|
|
||||||
switch (Type) {
|
switch (OpType) {
|
||||||
case isl_ast_op_le:
|
case isl_ast_op_le:
|
||||||
Predicate = ICmpInst::ICMP_SLE;
|
Predicate = ICmpInst::ICMP_SLE;
|
||||||
break;
|
break;
|
||||||
|
|
@ -125,30 +120,22 @@ IslNodeBuilder::getUpperBound(__isl_keep isl_ast_node *For,
|
||||||
llvm_unreachable("Unexpected comparison type in loop condition");
|
llvm_unreachable("Unexpected comparison type in loop condition");
|
||||||
}
|
}
|
||||||
|
|
||||||
Arg0 = isl_ast_expr_get_op_arg(Cond, 0);
|
isl::ast_expr Arg0 = Cond.get_op_arg(0);
|
||||||
|
|
||||||
assert(isl_ast_expr_get_type(Arg0) == isl_ast_expr_id &&
|
assert(isl_ast_expr_get_type(Arg0.get()) == isl_ast_expr_id &&
|
||||||
"conditional expression is not an atomic upper bound");
|
"conditional expression is not an atomic upper bound");
|
||||||
|
|
||||||
UBID = isl_ast_expr_get_id(Arg0);
|
isl::id UBID = Arg0.get_id();
|
||||||
|
|
||||||
assert(isl_ast_expr_get_type(Iterator) == isl_ast_expr_id &&
|
assert(isl_ast_expr_get_type(Iterator.get()) == isl_ast_expr_id &&
|
||||||
"Could not get the iterator");
|
"Could not get the iterator");
|
||||||
|
|
||||||
IteratorID = isl_ast_expr_get_id(Iterator);
|
isl::id IteratorID = Iterator.get_id();
|
||||||
|
|
||||||
assert(UBID == IteratorID &&
|
assert(UBID.get() == IteratorID.get() &&
|
||||||
"conditional expression is not an atomic upper bound");
|
"conditional expression is not an atomic upper bound");
|
||||||
|
|
||||||
UB = isl_ast_expr_get_op_arg(Cond, 1);
|
return Cond.get_op_arg(1);
|
||||||
|
|
||||||
isl_ast_expr_free(Cond);
|
|
||||||
isl_ast_expr_free(Iterator);
|
|
||||||
isl_ast_expr_free(Arg0);
|
|
||||||
isl_id_free(IteratorID);
|
|
||||||
isl_id_free(UBID);
|
|
||||||
|
|
||||||
return UB;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return true if a return value of Predicate is true for the value represented
|
/// Return true if a return value of Predicate is true for the value represented
|
||||||
|
|
@ -205,7 +192,7 @@ int IslNodeBuilder::getNumberOfIterations(__isl_keep isl_ast_node *For) {
|
||||||
if (!checkIslAstExprInt(Inc, isl_val_is_one))
|
if (!checkIslAstExprInt(Inc, isl_val_is_one))
|
||||||
return -1;
|
return -1;
|
||||||
CmpInst::Predicate Predicate;
|
CmpInst::Predicate Predicate;
|
||||||
auto UB = getUpperBound(For, Predicate);
|
auto UB = getUpperBound(isl::manage_copy(For), Predicate).release();
|
||||||
if (isl_ast_expr_get_type(UB) != isl_ast_expr_int) {
|
if (isl_ast_expr_get_type(UB) != isl_ast_expr_int) {
|
||||||
isl_ast_expr_free(UB);
|
isl_ast_expr_free(UB);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -553,7 +540,7 @@ void IslNodeBuilder::createForSequential(__isl_take isl_ast_node *For,
|
||||||
Inc = isl_ast_node_for_get_inc(For);
|
Inc = isl_ast_node_for_get_inc(For);
|
||||||
Iterator = isl_ast_node_for_get_iterator(For);
|
Iterator = isl_ast_node_for_get_iterator(For);
|
||||||
IteratorID = isl_ast_expr_get_id(Iterator);
|
IteratorID = isl_ast_expr_get_id(Iterator);
|
||||||
UB = getUpperBound(For, Predicate);
|
UB = getUpperBound(isl::manage_copy(For), Predicate).release();
|
||||||
|
|
||||||
ValueLB = ExprBuilder.create(Init);
|
ValueLB = ExprBuilder.create(Init);
|
||||||
ValueUB = ExprBuilder.create(UB);
|
ValueUB = ExprBuilder.create(UB);
|
||||||
|
|
@ -661,7 +648,7 @@ void IslNodeBuilder::createForParallel(__isl_take isl_ast_node *For) {
|
||||||
Inc = isl_ast_node_for_get_inc(For);
|
Inc = isl_ast_node_for_get_inc(For);
|
||||||
Iterator = isl_ast_node_for_get_iterator(For);
|
Iterator = isl_ast_node_for_get_iterator(For);
|
||||||
IteratorID = isl_ast_expr_get_id(Iterator);
|
IteratorID = isl_ast_expr_get_id(Iterator);
|
||||||
UB = getUpperBound(For, Predicate);
|
UB = getUpperBound(isl::manage_copy(For), Predicate).release();
|
||||||
|
|
||||||
ValueLB = ExprBuilder.create(Init);
|
ValueLB = ExprBuilder.create(Init);
|
||||||
ValueUB = ExprBuilder.create(UB);
|
ValueUB = ExprBuilder.create(UB);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue