Compare commits

...

1 Commits

Author SHA1 Message Date
Thomas Preud'homme af43b01b92 Preliminary support of g++ 2012-02-21 17:18:53 +01:00
3 changed files with 206 additions and 9 deletions

View File

@ -21259,6 +21259,10 @@ cp_parser_omp_clause_name (cp_parser *parser)
if (!strcmp ("firstprivate", p))
result = PRAGMA_OMP_CLAUSE_FIRSTPRIVATE;
break;
case 'i':
if (!strcmp ("input", p))
result = PRAGMA_OMP_CLAUSE_INPUT;
break;
case 'l':
if (!strcmp ("lastprivate", p))
result = PRAGMA_OMP_CLAUSE_LASTPRIVATE;
@ -21272,6 +21276,8 @@ cp_parser_omp_clause_name (cp_parser *parser)
case 'o':
if (!strcmp ("ordered", p))
result = PRAGMA_OMP_CLAUSE_ORDERED;
else if (!strcmp ("output", p))
result = PRAGMA_OMP_CLAUSE_OUTPUT;
break;
case 'r':
if (!strcmp ("reduction", p))
@ -21392,6 +21398,152 @@ cp_parser_omp_var_list (cp_parser *parser, enum omp_clause_code kind, tree list)
return list;
}
/* OpenMP X.X:
stream-list:
identifier ************************
variable-list , identifier
KIND must be OMP_CLAUSE_INPUT or OMP_CLAUSE_OUTPUT. */
static bool
cp_parser_omp_stream_identifier (cp_parser *parser, location_t loc,
tree *id, tree *sub)
{
if (cp_lexer_next_token_is_not (parser->lexer, CPP_NAME))
cp_parser_error (parser, "expected stream or view identifier");
*id = lookup_name (cp_lexer_peek_token (parser->lexer)->u.value);
if (*id == NULL_TREE)
{
inform (loc, "OpenMP stream and view identifiers must"
" be declared before use in streaming clauses.");
cp_parser_name_lookup_error(
parser, cp_lexer_peek_token (parser->lexer)->u.value, *id, NULL,
cp_lexer_peek_token (parser->lexer)->location);
return false;
}
if (*id == error_mark_node)
return false;
cp_lexer_consume_token (parser->lexer);
/* If this is an array reference. */
if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_SQUARE))
{
cp_lexer_consume_token (parser->lexer);
*sub = cp_parser_expression (parser, false, NULL);
cp_parser_require (parser, CPP_CLOSE_SQUARE, "expected %<]%>");
}
else
*sub = NULL_TREE;
if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_SQUARE))
{
cp_parser_error (parser, "single dimension arrays"
" supported only in streaming clauses");
return false;
}
/* Next, we must either connect a view or have another stream use
separated by a comma, or the closing parenthesis. This test
prevents all other syntaxes that will be supported later (like
dot or deref ...) */
if (cp_lexer_next_token_is_not (parser->lexer, CPP_LSHIFT)
&& cp_lexer_next_token_is_not (parser->lexer, CPP_RSHIFT)
&& cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_PAREN)
&& cp_lexer_next_token_is_not (parser->lexer, CPP_COMMA))
{
cp_parser_error (parser, "wrong syntax on streaming clause");
return false;
}
return true;
}
static tree
cp_parser_omp_stream_clause (cp_parser *parser,
enum omp_clause_code kind,
tree list, location_t location)
{
gcc_assert (kind == OMP_CLAUSE_INPUT || kind == OMP_CLAUSE_OUTPUT);
if (!cp_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
return list;
/* Every stream clause must start with either a stream identifier or
a view identifier. */
while (true)
{
tree stream_id, stream_idx, view_id, view_idx;
tree omp_clause;
if (!cp_parser_omp_stream_identifier (parser, location,
&stream_id, &stream_idx))
break;
omp_clause = build_omp_clause (location, kind);
OMP_CLAUSE_STREAM_ID (omp_clause) = stream_id;
OMP_CLAUSE_STREAM_SUB (omp_clause) = stream_idx;
if (cp_lexer_next_token_is (parser->lexer, CPP_LSHIFT)
|| cp_lexer_next_token_is (parser->lexer, CPP_RSHIFT))
{
bool lshift_stream_operator_p =
cp_lexer_next_token_is (parser->lexer, CPP_LSHIFT);
cp_lexer_consume_token (parser->lexer);
if (!cp_parser_omp_stream_identifier (parser, location,
&view_id, &view_idx))
break;
/* If the clause is reversed ("view << >> stream" instead of
"stream << >> view"), swap the roles. */
if ((kind == OMP_CLAUSE_INPUT && lshift_stream_operator_p)
|| (kind == OMP_CLAUSE_OUTPUT && !lshift_stream_operator_p))
{
OMP_CLAUSE_STREAM_ID (omp_clause) = view_id;
view_id = stream_id;
OMP_CLAUSE_STREAM_SUB (omp_clause) = view_idx;
view_idx = stream_idx;
}
OMP_CLAUSE_VIEW_ID (omp_clause) = view_id;
OMP_CLAUSE_BURST_SIZE (omp_clause) = view_idx;
}
else
{
OMP_CLAUSE_VIEW_ID (omp_clause) = NULL_TREE;
OMP_CLAUSE_BURST_SIZE (omp_clause) = NULL_TREE;
}
OMP_CLAUSE_CHAIN (omp_clause) = list;
list = omp_clause;
/* TODO: TINO Check this */
/*if(OMP_CLAUSE_VIEW_ID (omp_clause) != NULL_TREE)
{
tree new_omp_clause = build_omp_clause (location, OMP_CLAUSE_PRIVATE);
OMP_CLAUSE_DECL (new_omp_clause) = OMP_CLAUSE_VIEW_ID (omp_clause);
OMP_CLAUSE_CHAIN (new_omp_clause) = list;
list = new_omp_clause;
}*/
if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA))
cp_lexer_consume_token (parser->lexer);
else if (cp_lexer_next_token_is (parser->lexer, CPP_CLOSE_PAREN))
break;
else
{
cp_parser_error (parser, "expected %<,%> or %<)%>");
break;
}
}
cp_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>");
return list;
}
/* OpenMP 3.0:
collapse ( constant-expression ) */
@ -21519,6 +21671,15 @@ cp_parser_omp_clause_if (cp_parser *parser, tree list, location_t location)
return c;
}
/* OpenMP X.X:
input ( expression ) */
static tree
cp_parser_omp_clause_input (cp_parser *parser, tree list, location_t location)
{
return cp_parser_omp_stream_clause (parser, OMP_CLAUSE_INPUT, list, location);
}
/* OpenMP 2.5:
nowait */
@ -21582,6 +21743,16 @@ cp_parser_omp_clause_ordered (cp_parser *parser ATTRIBUTE_UNUSED,
return c;
}
/* OpenMP X.X:
output ( expression ) */
static tree
cp_parser_omp_clause_output (cp_parser *parser, tree list, location_t location)
{
return cp_parser_omp_stream_clause (parser, OMP_CLAUSE_OUTPUT, list,
location);
}
/* OpenMP 2.5:
reduction ( reduction-operator : variable-list )
@ -21807,6 +21978,11 @@ cp_parser_omp_all_clauses (cp_parser *parser, unsigned int mask,
clauses = cp_parser_omp_clause_if (parser, clauses, token->location);
c_name = "if";
break;
case PRAGMA_OMP_CLAUSE_INPUT:
clauses = cp_parser_omp_clause_input (parser, clauses,
token->location);
c_name = "input";
break;
case PRAGMA_OMP_CLAUSE_LASTPRIVATE:
clauses = cp_parser_omp_var_list (parser, OMP_CLAUSE_LASTPRIVATE,
clauses);
@ -21826,6 +22002,11 @@ cp_parser_omp_all_clauses (cp_parser *parser, unsigned int mask,
token->location);
c_name = "ordered";
break;
case PRAGMA_OMP_CLAUSE_OUTPUT:
clauses = cp_parser_omp_clause_output (parser, clauses,
token->location);
c_name = "output";
break;
case PRAGMA_OMP_CLAUSE_PRIVATE:
clauses = cp_parser_omp_var_list (parser, OMP_CLAUSE_PRIVATE,
clauses);
@ -22861,8 +23042,10 @@ cp_parser_omp_single (cp_parser *parser, cp_token *pragma_tok)
#define OMP_TASK_CLAUSE_MASK \
( (1u << PRAGMA_OMP_CLAUSE_IF) \
| (1u << PRAGMA_OMP_CLAUSE_INPUT) \
| (1u << PRAGMA_OMP_CLAUSE_UNTIED) \
| (1u << PRAGMA_OMP_CLAUSE_DEFAULT) \
| (1u << PRAGMA_OMP_CLAUSE_OUTPUT) \
| (1u << PRAGMA_OMP_CLAUSE_PRIVATE) \
| (1u << PRAGMA_OMP_CLAUSE_FIRSTPRIVATE) \
| (1u << PRAGMA_OMP_CLAUSE_SHARED))

View File

@ -3787,8 +3787,10 @@ finish_omp_clauses (tree clauses)
}
break;
case OMP_CLAUSE_INPUT:
case OMP_CLAUSE_NOWAIT:
case OMP_CLAUSE_ORDERED:
case OMP_CLAUSE_OUTPUT:
case OMP_CLAUSE_DEFAULT:
case OMP_CLAUSE_UNTIED:
case OMP_CLAUSE_COLLAPSE:
@ -3839,6 +3841,18 @@ finish_omp_clauses (tree clauses)
need_copy_assignment = true;
need_implicitly_determined = true;
break;
case OMP_CLAUSE_INPUT:
name = "input";
need_complete_non_reference = true;
need_copy_ctor = true;
need_implicitly_determined = true;
break;
case OMP_CLAUSE_OUTPUT:
name = "output";
need_complete_non_reference = true;
need_copy_assignment = true;
need_implicitly_determined = true;
break;
case OMP_CLAUSE_REDUCTION:
name = "reduction";
need_implicitly_determined = true;

View File

@ -139,7 +139,7 @@ DEF_VEC_ALLOC_P(task_p,heap);
pass pointers to generated shared data between the enclosing
context to the tasks. This hashtab keeps the mapping between the
OMP directive and the decls of the variables. */
htab_t htab_omp_stmt;
htab_t htab_omp_stmt = NULL;
typedef struct omp_stmt
{
@ -188,8 +188,8 @@ lookup_omp_stmt (gimple stmt)
omp_stmt_t **slot, tmp;
if (!htab_omp_stmt)
htab_omp_stmt = htab_create_ggc (10, hash_omp_stmt,
eq_omp_stmt, NULL);
/* htab_omp_stmt = htab_create_ggc (10, hash_omp_stmt, eq_omp_stmt, NULL); */
htab_omp_stmt = htab_create_alloc (10, hash_omp_stmt, eq_omp_stmt, NULL, xcalloc, free); /* Allow memory leak to avoid GC */
tmp.stmt = stmt;
slot = (omp_stmt_p *) htab_find_slot (htab_omp_stmt, &tmp, INSERT);
@ -473,8 +473,8 @@ lookup_stream (tree var/*, omp_region_p region*/)
get_outermost_parallel_streamization_info (region);*/
if (!htab_stream)
htab_stream = htab_create_ggc (10, hash_stream,
eq_stream, NULL);
/* htab_stream = htab_create_ggc (10, hash_stream, eq_stream, NULL); */
htab_stream = htab_create_alloc(10, hash_stream, eq_stream, NULL, xcalloc, free); /* Allow memory leak to avoid GC */
tmp.var = var;
slot = (stream_p *) htab_find_slot (htab_stream, &tmp, INSERT);
@ -976,8 +976,8 @@ lookup_var_for_clause (tree clause)
tmp.clause = clause;
if (!htab_clause_to_var)
htab_clause_to_var = htab_create_ggc (10, hash_clause_to_var,
eq_clause_to_var, NULL);
/* htab_clause_to_var = htab_create_ggc (10, hash_clause_to_var, eq_clause_to_var, NULL); */
htab_clause_to_var = htab_create_alloc (10, hash_clause_to_var, eq_clause_to_var, NULL, xcalloc, free); /* Allow memory leak to avoid GC */
slot = (clause_to_var *) htab_find_slot (htab_clause_to_var, &tmp, INSERT);
@ -9593,8 +9593,8 @@ execute_lower_omp (void)
delete_omp_context);
if (!htab_stmt_loc)
htab_stmt_loc = htab_create_ggc (10, hash_stmt_loc,
eq_stmt_loc, NULL);
/* htab_stmt_loc = htab_create_ggc (10, hash_stmt_loc, eq_stmt_loc, NULL); */
htab_stmt_loc = htab_create_ggc (10, hash_stmt_loc, eq_stmt_loc, NULL); /* Allow memory leak to avoid GC */
body = gimple_body (current_function_decl);
scan_omp (body, NULL);