diff options
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r-- | gcc/cp/parser.c | 186 |
1 files changed, 183 insertions, 3 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 0354029..169c17d 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -29064,7 +29064,9 @@ cp_parser_omp_clause_name (cp_parser *parser) { pragma_omp_clause result = PRAGMA_OMP_CLAUSE_NONE; - if (cp_lexer_next_token_is_keyword (parser->lexer, RID_IF)) + if (cp_lexer_next_token_is_keyword (parser->lexer, RID_AUTO)) + result = PRAGMA_OACC_CLAUSE_AUTO; + else if (cp_lexer_next_token_is_keyword (parser->lexer, RID_IF)) result = PRAGMA_OMP_CLAUSE_IF; else if (cp_lexer_next_token_is_keyword (parser->lexer, RID_DEFAULT)) result = PRAGMA_OMP_CLAUSE_DEFAULT; @@ -29122,7 +29124,9 @@ cp_parser_omp_clause_name (cp_parser *parser) result = PRAGMA_OMP_CLAUSE_FROM; break; case 'g': - if (!strcmp ("grainsize", p)) + if (!strcmp ("gang", p)) + result = PRAGMA_OACC_CLAUSE_GANG; + else if (!strcmp ("grainsize", p)) result = PRAGMA_OMP_CLAUSE_GRAINSIZE; break; case 'h': @@ -29212,6 +29216,8 @@ cp_parser_omp_clause_name (cp_parser *parser) result = PRAGMA_OMP_CLAUSE_SECTIONS; else if (!strcmp ("self", p)) result = PRAGMA_OACC_CLAUSE_SELF; + else if (!strcmp ("seq", p)) + result = PRAGMA_OACC_CLAUSE_SEQ; else if (!strcmp ("shared", p)) result = PRAGMA_OMP_CLAUSE_SHARED; else if (!strcmp ("simd", p)) @@ -29238,7 +29244,9 @@ cp_parser_omp_clause_name (cp_parser *parser) result = PRAGMA_OMP_CLAUSE_USE_DEVICE_PTR; break; case 'v': - if (!strcmp ("vector_length", p)) + if (!strcmp ("vector", p)) + result = PRAGMA_OACC_CLAUSE_VECTOR; + else if (!strcmp ("vector_length", p)) result = PRAGMA_OACC_CLAUSE_VECTOR_LENGTH; else if (flag_cilkplus && !strcmp ("vectorlength", p)) result = PRAGMA_CILK_CLAUSE_VECTORLENGTH; @@ -29246,6 +29254,8 @@ cp_parser_omp_clause_name (cp_parser *parser) case 'w': if (!strcmp ("wait", p)) result = PRAGMA_OACC_CLAUSE_WAIT; + else if (!strcmp ("worker", p)) + result = PRAGMA_OACC_CLAUSE_WORKER; break; } } @@ -29582,6 +29592,146 @@ cp_parser_oacc_data_clause_deviceptr (cp_parser *parser, tree list) return list; } +/* OpenACC 2.0: + auto + independent + nohost + seq */ + +static tree +cp_parser_oacc_simple_clause (cp_parser * /* parser */, + enum omp_clause_code code, + tree list, location_t location) +{ + check_no_duplicate_clause (list, code, omp_clause_code_name[code], location); + tree c = build_omp_clause (location, code); + OMP_CLAUSE_CHAIN (c) = list; + return c; +} + +/* OpenACC: + + gang [( gang-arg-list )] + worker [( [num:] int-expr )] + vector [( [length:] int-expr )] + + where gang-arg is one of: + + [num:] int-expr + static: size-expr + + and size-expr may be: + + * + int-expr +*/ + +static tree +cp_parser_oacc_shape_clause (cp_parser *parser, omp_clause_code kind, + const char *str, tree list) +{ + const char *id = "num"; + cp_lexer *lexer = parser->lexer; + tree ops[2] = { NULL_TREE, NULL_TREE }, c; + location_t loc = cp_lexer_peek_token (lexer)->location; + + if (kind == OMP_CLAUSE_VECTOR) + id = "length"; + + if (cp_lexer_next_token_is (lexer, CPP_OPEN_PAREN)) + { + cp_lexer_consume_token (lexer); + + do + { + cp_token *next = cp_lexer_peek_token (lexer); + int idx = 0; + + /* Gang static argument. */ + if (kind == OMP_CLAUSE_GANG + && cp_lexer_next_token_is_keyword (lexer, RID_STATIC)) + { + cp_lexer_consume_token (lexer); + + if (!cp_parser_require (parser, CPP_COLON, RT_COLON)) + goto cleanup_error; + + idx = 1; + if (ops[idx] != NULL) + { + cp_parser_error (parser, "too many %<static%> arguments"); + goto cleanup_error; + } + + /* Check for the '*' argument. */ + if (cp_lexer_next_token_is (lexer, CPP_MULT)) + { + cp_lexer_consume_token (lexer); + ops[idx] = integer_minus_one_node; + + if (cp_lexer_next_token_is (lexer, CPP_COMMA)) + { + cp_lexer_consume_token (lexer); + continue; + } + else break; + } + } + /* Worker num: argument and vector length: arguments. */ + else if (cp_lexer_next_token_is (lexer, CPP_NAME) + && strcmp (id, IDENTIFIER_POINTER (next->u.value)) == 0 + && cp_lexer_nth_token_is (lexer, 2, CPP_COLON)) + { + cp_lexer_consume_token (lexer); /* id */ + cp_lexer_consume_token (lexer); /* ':' */ + } + + /* Now collect the actual argument. */ + if (ops[idx] != NULL_TREE) + { + cp_parser_error (parser, "unexpected argument"); + goto cleanup_error; + } + + tree expr = cp_parser_assignment_expression (parser, NULL, false, + false); + if (expr == error_mark_node) + goto cleanup_error; + + mark_exp_read (expr); + ops[idx] = expr; + + if (kind == OMP_CLAUSE_GANG + && cp_lexer_next_token_is (lexer, CPP_COMMA)) + { + cp_lexer_consume_token (lexer); + continue; + } + break; + } + while (1); + + if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN)) + goto cleanup_error; + } + + check_no_duplicate_clause (list, kind, str, loc); + + c = build_omp_clause (loc, kind); + + if (ops[1]) + OMP_CLAUSE_OPERAND (c, 1) = ops[1]; + + OMP_CLAUSE_OPERAND (c, 0) = ops[0]; + OMP_CLAUSE_CHAIN (c) = list; + + return c; + + cleanup_error: + cp_parser_skip_to_closing_parenthesis (parser, false, false, true); + return list; +} + /* OpenACC: vector_length ( expression ) */ @@ -31306,6 +31456,11 @@ cp_parser_oacc_all_clauses (cp_parser *parser, omp_clause_mask mask, clauses = cp_parser_oacc_clause_async (parser, clauses); c_name = "async"; break; + case PRAGMA_OACC_CLAUSE_AUTO: + clauses = cp_parser_oacc_simple_clause (parser, OMP_CLAUSE_AUTO, + clauses, here); + c_name = "auto"; + break; case PRAGMA_OACC_CLAUSE_COLLAPSE: clauses = cp_parser_omp_clause_collapse (parser, clauses, here); c_name = "collapse"; @@ -31338,6 +31493,11 @@ cp_parser_oacc_all_clauses (cp_parser *parser, omp_clause_mask mask, clauses = cp_parser_oacc_data_clause_deviceptr (parser, clauses); c_name = "deviceptr"; break; + case PRAGMA_OACC_CLAUSE_GANG: + c_name = "gang"; + clauses = cp_parser_oacc_shape_clause (parser, OMP_CLAUSE_GANG, + c_name, clauses); + break; case PRAGMA_OACC_CLAUSE_HOST: clauses = cp_parser_oacc_data_clause (parser, c_kind, clauses); c_name = "host"; @@ -31382,6 +31542,16 @@ cp_parser_oacc_all_clauses (cp_parser *parser, omp_clause_mask mask, clauses = cp_parser_oacc_data_clause (parser, c_kind, clauses); c_name = "self"; break; + case PRAGMA_OACC_CLAUSE_SEQ: + clauses = cp_parser_oacc_simple_clause (parser, OMP_CLAUSE_SEQ, + clauses, here); + c_name = "seq"; + break; + case PRAGMA_OACC_CLAUSE_VECTOR: + c_name = "vector"; + clauses = cp_parser_oacc_shape_clause (parser, OMP_CLAUSE_VECTOR, + c_name, clauses); + break; case PRAGMA_OACC_CLAUSE_VECTOR_LENGTH: clauses = cp_parser_oacc_clause_vector_length (parser, clauses); c_name = "vector_length"; @@ -31390,6 +31560,11 @@ cp_parser_oacc_all_clauses (cp_parser *parser, omp_clause_mask mask, clauses = cp_parser_oacc_clause_wait (parser, clauses); c_name = "wait"; break; + case PRAGMA_OACC_CLAUSE_WORKER: + c_name = "worker"; + clauses = cp_parser_oacc_shape_clause (parser, OMP_CLAUSE_WORKER, + c_name, clauses); + break; default: cp_parser_error (parser, "expected %<#pragma acc%> clause"); goto saw_error; @@ -34303,6 +34478,11 @@ cp_parser_oacc_enter_exit_data (cp_parser *parser, cp_token *pragma_tok, #define OACC_LOOP_CLAUSE_MASK \ ( (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COLLAPSE) \ + | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_GANG) \ + | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_VECTOR) \ + | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_WORKER) \ + | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_AUTO) \ + | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_SEQ) \ | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_REDUCTION) ) static tree |