Cilk Plus <#pragma simd> implementation on top of OMP_SIMD.
[official-gcc.git] / gcc / cp / cp-cilkplus.c
blobaa803438e5d6128db094b0f86351a8197daaf7a4
1 /* This file is part of the Intel(R) Cilk(TM) Plus support
2 This file contains routines to handle Cilk Plus specific
3 routines for the C++ Compiler.
4 Copyright (C) 2013 Free Software Foundation, Inc.
5 Contributed by Balaji V. Iyer <balaji.v.iyer@intel.com>,
6 Aldy Hernandez <aldyh@redhat.com>.
8 This file is part of GCC.
10 GCC is free software; you can redistribute it and/or modify it
11 under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3, or (at your option)
13 any later version.
15 GCC is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with GCC; see the file COPYING3. If not see
22 <http://www.gnu.org/licenses/>. */
24 #include "config.h"
25 #include "system.h"
26 #include "coretypes.h"
27 #include "cp-tree.h"
28 #include "diagnostic-core.h"
31 /* Callback for cp_walk_tree to validate the body of a pragma simd loop
32 or _cilk_for loop.
34 This function is passed in as a function pointer to walk_tree. *TP is
35 the current tree pointer, *WALK_SUBTREES is set to 0 by this function if
36 recursing into TP's subtrees is unnecessary. *DATA is a bool variable that
37 is set to false if an error has occured. */
39 static tree
40 cpp_validate_cilk_plus_loop_aux (tree *tp, int *walk_subtrees, void *data)
42 bool *valid = (bool *) data;
43 location_t loc = EXPR_HAS_LOCATION (*tp) ? EXPR_LOCATION (*tp) :
44 UNKNOWN_LOCATION;
46 if (!tp || !*tp)
47 return NULL_TREE;
49 if (TREE_CODE (*tp) == THROW_EXPR)
51 error_at (loc, "throw expressions are not allowed inside loops "
52 "marked with pragma simd");
53 *walk_subtrees = 0;
54 *valid = false;
56 else if (TREE_CODE (*tp) == TRY_BLOCK)
58 error_at (loc, "try statements are not allowed inside loops marked "
59 "with #pragma simd");
60 *valid = false;
61 *walk_subtrees = 0;
63 return NULL_TREE;
67 /* Walks through all the subtrees of BODY using walk_tree to make sure
68 invalid statements/expressions are not found inside BODY. Returns
69 false if any invalid statements are found. */
71 bool
72 cpp_validate_cilk_plus_loop (tree body)
74 bool valid = true;
75 cp_walk_tree (&body, cpp_validate_cilk_plus_loop_aux,
76 (void *) &valid, NULL);
77 return valid;