Changeset View
Changeset View
Standalone View
Standalone View
lib/CodeGen/IslCodeGeneration.cpp
Show First 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | private: | ||||
// | // | ||||
// 2. OpenMP needs a loop invarient upper bound to calculate the number | // 2. OpenMP needs a loop invarient upper bound to calculate the number | ||||
// 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_give isl_ast_expr *getUpperBound(__isl_keep isl_ast_node *For, | ||||
CmpInst::Predicate &Predicate); | CmpInst::Predicate &Predicate); | ||||
unsigned getNumberOfIterations(__isl_keep isl_ast_node *For); | |||||
void createFor(__isl_take isl_ast_node *For); | void createFor(__isl_take isl_ast_node *For); | ||||
void createForVector(__isl_take isl_ast_node *For, int VectorWidth); | void createForVector(__isl_take isl_ast_node *For, int VectorWidth); | ||||
void createForSequential(__isl_take isl_ast_node *For); | void createForSequential(__isl_take isl_ast_node *For); | ||||
/// Generate LLVM-IR that computes the values of the original induction | /// Generate LLVM-IR that computes the values of the original induction | ||||
/// variables in function of the newly generated loop induction variables. | /// variables in function of the newly generated loop induction variables. | ||||
/// | /// | ||||
/// Example: | /// Example: | ||||
▲ Show 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | IslNodeBuilder::getUpperBound(__isl_keep isl_ast_node *For, | ||||
isl_ast_expr_free(Iterator); | isl_ast_expr_free(Iterator); | ||||
isl_ast_expr_free(Arg0); | isl_ast_expr_free(Arg0); | ||||
isl_id_free(IteratorID); | isl_id_free(IteratorID); | ||||
isl_id_free(UBID); | isl_id_free(UBID); | ||||
return UB; | return UB; | ||||
} | } | ||||
unsigned IslNodeBuilder::getNumberOfIterations(__isl_keep isl_ast_node *For) { | |||||
isl_union_map *Schedule = IslAstInfo::getSchedule(For); | |||||
isl_set *LoopDomain = isl_set_from_union_set(isl_union_map_range(Schedule)); | |||||
int NumberOfIterations = polly::getNumberOfIterations(LoopDomain); | |||||
if (NumberOfIterations == -1) | |||||
return -1; | |||||
return NumberOfIterations + 1; | |||||
} | |||||
void IslNodeBuilder::createUserVector(__isl_take isl_ast_node *User, | void IslNodeBuilder::createUserVector(__isl_take isl_ast_node *User, | ||||
std::vector<Value *> &IVS, | std::vector<Value *> &IVS, | ||||
__isl_take isl_id *IteratorID, | __isl_take isl_id *IteratorID, | ||||
__isl_take isl_union_map *Schedule) { | __isl_take isl_union_map *Schedule) { | ||||
isl_ast_expr *Expr = isl_ast_node_user_get_expr(User); | isl_ast_expr *Expr = isl_ast_node_user_get_expr(User); | ||||
isl_ast_expr *StmtExpr = isl_ast_expr_get_op_arg(Expr, 0); | isl_ast_expr *StmtExpr = isl_ast_expr_get_op_arg(Expr, 0); | ||||
isl_id *Id = isl_ast_expr_get_id(StmtExpr); | isl_id *Id = isl_ast_expr_get_id(StmtExpr); | ||||
isl_ast_expr_free(StmtExpr); | isl_ast_expr_free(StmtExpr); | ||||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | void IslNodeBuilder::createForSequential(__isl_take isl_ast_node *For) { | ||||
isl_id_free(IteratorID); | isl_id_free(IteratorID); | ||||
} | } | ||||
void IslNodeBuilder::createFor(__isl_take isl_ast_node *For) { | void IslNodeBuilder::createFor(__isl_take isl_ast_node *For) { | ||||
bool Vector = PollyVectorizerChoice != VECTORIZER_NONE; | bool Vector = PollyVectorizerChoice != VECTORIZER_NONE; | ||||
if (Vector && IslAstInfo::isInnermostParallel(For) && | if (Vector && IslAstInfo::isInnermostParallel(For) && | ||||
!IslAstInfo::isReductionParallel(For)) { | !IslAstInfo::isReductionParallel(For)) { | ||||
int VectorWidth = getNumberOfIterations(For); | int VectorWidth = IslAstInfo::getNumberOfIterationsAsInt(For); | ||||
if (1 < VectorWidth && VectorWidth <= 16) { | if (1 < VectorWidth && VectorWidth <= 16) { | ||||
createForVector(For, VectorWidth); | createForVector(For, VectorWidth); | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
createForSequential(For); | createForSequential(For); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 279 Lines • Show Last 20 Lines |