Implemented Cilk Plus Array Notation for C Compiler.
gcc/ChangeLog 2013-05-28 Balaji V. Iyer <balaji.v.iyer@intel.com> * doc/extend.texi (C Extensions): Added documentation about Cilk Plus array notation built-in reduction functions. * doc/passes.texi (Passes): Added documentation about changes done for Cilk Plus. * doc/invoke.texi (C Dialect Options): Added documentation about the -fcilkplus flag. * Makefile.in (C_COMMON_OBJS): Added c-family/array-notation-common.o. (BUILTINS_DEF): Depend on cilkplus.def. * builtins.def: Include cilkplus.def. Define DEF_CILKPLUS_BUILTIN. * builtin-types.def: Define BT_FN_INT_PTR_PTR_PTR. * cilkplus.def: New file. gcc/c-family/ChangeLog 2013-05-28 Balaji V. Iyer <balaji.v.iyer@intel.com> * c-common.c (c_define_builtins): When cilkplus is enabled, the function array_notation_init_builtins is called. (c_common_init_ts): Added ARRAY_NOTATION_REF as typed. * c-common.def (ARRAY_NOTATION_REF): New tree. * c-common.h (build_array_notation_expr): New function declaration. (build_array_notation_ref): Likewise. (extract_sec_implicit_index_arg): New extern declaration. (is_sec_implicit_index_fn): Likewise. (ARRAY_NOTATION_CHECK): New define. (ARRAY_NOTATION_ARRAY): Likewise. (ARRAY_NOTATION_START): Likewise. (ARRAY_NOTATION_LENGTH): Likewise. (ARRAY_NOTATION_STRIDE): Likewise. * c-pretty-print.c (pp_c_postifix_expression): Added a new case for ARRAY_NOTATION_REF. (pp_c_expression): Likewise. * c.opt (flag_enable_cilkplus): New flag. * array-notation-common.c: New file. gcc/c/ChangeLog 2013-05-28 Balaji V. Iyer <balaji.v.iyer@intel.com> * c-typeck.c (build_array_ref): Added a check to see if array's index is greater than one. If true, then emit an error. (build_function_call_vec): Exclude error reporting and checking for builtin array-notation functions. (convert_arguments): Likewise. (c_finish_return): Added a check for array notations as a return expression. If true, then emit an error. (c_finish_loop): Added a check for array notations in a loop condition. If true then emit an error. (lvalue_p): Added a ARRAY_NOTATION_REF case. (build_binary_op): Added a check for array notation expr inside op1 and op0. If present, we call another function to find correct type. * Make-lang.in (C_AND_OBJC_OBJS): Added c-array-notation.o. * c-parser.c (c_parser_compound_statement): Check if array notation code is used in tree, if so, then transform them into appropriate C code. (c_parser_expr_no_commas): Check if array notation is used in LHS or RHS, if so, then build array notation expression instead of regular modify. (c_parser_postfix_expression_after_primary): Added a check for colon(s) after square braces, if so then handle it like an array notation. Also, break up array notations in unary op if found. (c_parser_direct_declarator_inner): Added a check for array notation. (c_parser_compound_statement): Added a check for array notation in a stmt. If one is present, then expand array notation expr. (c_parser_if_statement): Likewise. (c_parser_switch_statement): Added a check for array notations in a switch statement's condition. If true, then output an error. (c_parser_while_statement): Similarly, but for a while. (c_parser_do_statement): Similarly, but for a do-while. (c_parser_for_statement): Similarly, but for a for-loop. (c_parser_unary_expression): Check if array notation is used in a pre-increment or pre-decrement expression. If true, then expand them. (c_parser_array_notation): New function. * c-array-notation.c: New file. * c-tree.h (is_cilkplus_reduce_builtin): Protoize. gcc/testsuite/ChangeLog 2013-05-28 Balaji V. Iyer <balaji.v.iyer@intel.com> * c-c++-common/cilk-plus/AN/array_test1.c: New test. * c-c++-common/cilk-plus/AN/array_test2.c: Likewise. * c-c++-common/cilk-plus/AN/array_test_ND.c: Likewise. * c-c++-common/cilk-plus/AN/builtin_func_double.c: Likewise. * c-c++-common/cilk-plus/AN/builtin_func_double2.c: Likewise. * c-c++-common/cilk-plus/AN/gather-scatter-errors.c: Likewise. * c-c++-common/cilk-plus/AN/if_test.c: Likewise. * c-c++-common/cilk-plus/AN/sec_implicit_ex.c: Likewise. * c-c++-common/cilk-plus/AN/decl-ptr-colon.c: Likewise. * c-c++-common/cilk-plus/AN/dimensionless-arrays.c: Likewise. * c-c++-common/cilk-plus/AN/fn_ptr.c: Likewise. * c-c++-common/cilk-plus/AN/fp_triplet_values.c: Likewise. * c-c++-common/cilk-plus/AN/gather-scatter.c: Likewise. * c-c++-common/cilk-plus/AN/misc.c: Likewise. * c-c++-common/cilk-plus/AN/parser_errors.c: Likewise. * c-c++-common/cilk-plus/AN/parser_errors2.c: Likewise. * c-c++-common/cilk-plus/AN/parser_errors3.c: Likewise. * c-c++-common/cilk-plus/AN/parser_errors4.c: Likewise. * c-c++-common/cilk-plus/AN/rank_mismatch.c: Likewise. * c-c++-common/cilk-plus/AN/rank_mismatch2.c: Likewise. * c-c++-common/cilk-plus/AN/rank_mismatch3.c: Likewise. * c-c++-common/cilk-plus/AN/sec_implicit.c: Likewise. * c-c++-common/cilk-plus/AN/sec_implicit2.c: Likewise. * c-c++-common/cilk-plus/AN/sec_reduce_max_min_ind.c: Likewise. * c-c++-common/cilk-plus/AN/tst_lngth.c: Likewise. * c-c++-common/cilk-plus/AN/vla.c: Likewise. * c-c++-common/cilk-plus/AN/an-if.c: Likewise. * c-c++-common/cilk-plus/AN/builtin_fn_custom.c: Likewise. * c-c++-common/cilk-plus/AN/builtin_fn_mutating.c: Likewise. * c-c++-common/cilk-plus/AN/comma_exp.c: Likewise. * c-c++-common/cilk-plus/AN/conditional.c: Likewise. * c-c++-common/cilk-plus/AN/exec-once.c: Likewise. * c-c++-common/cilk-plus/AN/exec-once2.c: Likewise. * c-c++-common/cilk-plus/AN/gather_scatter.c: Likewise. * c-c++-common/cilk-plus/AN/n-ptr-test.c: Likewise. * c-c++-common/cilk-plus/AN/side-effects-1.c: Likewise. * c-c++-common/cilk-plus/AN/test_builtin_return.c: Likewise. * c-c++-common/cilk-plus/AN/test_sec_limits.c: Likewise. * gcc.dg/cilk-plus/cilk-plus.exp: New script. From-SVN: r199389
This commit is contained in:
parent
6d2bee95d8
commit
36536d79af
61 changed files with 5618 additions and 28 deletions
|
@ -1,3 +1,17 @@
|
|||
2013-05-28 Balaji V. Iyer <balaji.v.iyer@intel.com>
|
||||
|
||||
* doc/extend.texi (C Extensions): Added documentation about Cilk Plus
|
||||
array notation built-in reduction functions.
|
||||
* doc/passes.texi (Passes): Added documentation about changes done
|
||||
for Cilk Plus.
|
||||
* doc/invoke.texi (C Dialect Options): Added documentation about
|
||||
the -fcilkplus flag.
|
||||
* Makefile.in (C_COMMON_OBJS): Added c-family/array-notation-common.o.
|
||||
(BUILTINS_DEF): Depend on cilkplus.def.
|
||||
* builtins.def: Include cilkplus.def. Define DEF_CILKPLUS_BUILTIN.
|
||||
* builtin-types.def: Define BT_FN_INT_PTR_PTR_PTR.
|
||||
* cilkplus.def: New file.
|
||||
|
||||
2013-05-28 Joern Rennecke <joern.rennecke@embecosm.com>
|
||||
|
||||
PR rtl-optimization/57439
|
||||
|
|
|
@ -869,7 +869,7 @@ RTL_ERROR_H = rtl-error.h $(RTL_H) $(DIAGNOSTIC_CORE_H)
|
|||
READ_MD_H = $(OBSTACK_H) $(HASHTAB_H) read-md.h
|
||||
PARAMS_H = params.h params.def
|
||||
BUILTINS_DEF = builtins.def sync-builtins.def omp-builtins.def \
|
||||
gtm-builtins.def sanitizer.def
|
||||
gtm-builtins.def sanitizer.def cilkplus.def
|
||||
INTERNAL_FN_DEF = internal-fn.def
|
||||
INTERNAL_FN_H = internal-fn.h $(INTERNAL_FN_DEF)
|
||||
TREE_H = coretypes.h tree.h all-tree.def tree.def c-family/c-common.def \
|
||||
|
@ -1149,7 +1149,8 @@ C_COMMON_OBJS = c-family/c-common.o c-family/c-cppbuiltin.o c-family/c-dump.o \
|
|||
c-family/c-format.o c-family/c-gimplify.o c-family/c-lex.o \
|
||||
c-family/c-omp.o c-family/c-opts.o c-family/c-pch.o \
|
||||
c-family/c-ppoutput.o c-family/c-pragma.o c-family/c-pretty-print.o \
|
||||
c-family/c-semantics.o c-family/c-ada-spec.o tree-mudflap.o
|
||||
c-family/c-semantics.o c-family/c-ada-spec.o tree-mudflap.o \
|
||||
c-family/array-notation-common.o
|
||||
|
||||
# Language-independent object files.
|
||||
# We put the insn-*.o files first so that a parallel make will build
|
||||
|
@ -2014,6 +2015,9 @@ c-family/c-ada-spec.o : c-family/c-ada-spec.c c-family/c-ada-spec.h \
|
|||
$(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(CPP_ID_DATA_H) $(TM_H) \
|
||||
coretypes.h tree-iterator.h $(DUMPFILE_H)
|
||||
|
||||
c-family/array-notation-common.o : c-family/array-notation-common.c $(TREE_H) \
|
||||
$(SYSTEM_H) $(TREE_H) coretypes.h tree-iterator.h $(DIAGNOSTIC_CORE_H)
|
||||
|
||||
c-family/stub-objc.o : c-family/stub-objc.c $(CONFIG_H) $(SYSTEM_H) \
|
||||
coretypes.h $(TREE_H) $(C_COMMON_H) c-family/c-objc.h
|
||||
|
||||
|
|
|
@ -368,6 +368,8 @@ DEF_FUNCTION_TYPE_3 (BT_FN_INT_CONST_STRING_CONST_STRING_VALIST_ARG,
|
|||
BT_INT, BT_CONST_STRING, BT_CONST_STRING, BT_VALIST_ARG)
|
||||
DEF_FUNCTION_TYPE_3 (BT_FN_INT_FILEPTR_CONST_STRING_VALIST_ARG,
|
||||
BT_INT, BT_FILEPTR, BT_CONST_STRING, BT_VALIST_ARG)
|
||||
DEF_FUNCTION_TYPE_3 (BT_FN_INT_PTR_PTR_PTR,
|
||||
BT_INT, BT_PTR, BT_PTR, BT_PTR)
|
||||
DEF_FUNCTION_TYPE_3 (BT_FN_STRING_CONST_STRING_CONST_STRING_INT,
|
||||
BT_STRING, BT_CONST_STRING, BT_CONST_STRING, BT_INT)
|
||||
DEF_FUNCTION_TYPE_3 (BT_FN_FLOAT_FLOAT_FLOAT_FLOAT,
|
||||
|
|
|
@ -157,6 +157,11 @@ along with GCC; see the file COPYING3. If not see
|
|||
true, true, true, ATTRS, true, \
|
||||
(flag_asan || flag_tsan))
|
||||
|
||||
#undef DEF_CILKPLUS_BUILTIN
|
||||
#define DEF_CILKPLUS_BUILTIN(ENUM, NAME, TYPE, ATTRS) \
|
||||
DEF_BUILTIN (ENUM, NAME, BUILT_IN_NORMAL, TYPE, TYPE, \
|
||||
false, false, true, ATTRS, false, flag_enable_cilkplus)
|
||||
|
||||
/* Define an attribute list for math functions that are normally
|
||||
"impure" because some of them may write into global memory for
|
||||
`errno'. If !flag_errno_math they are instead "const". */
|
||||
|
@ -837,3 +842,5 @@ DEF_GCC_BUILTIN (BUILT_IN_LINE, "LINE", BT_FN_INT, ATTR_NOTHROW_LEAF_LIST)
|
|||
/* Sanitizer builtins. */
|
||||
#include "sanitizer.def"
|
||||
|
||||
/* Cilk Plus builtins. */
|
||||
#include "cilkplus.def"
|
||||
|
|
|
@ -1,3 +1,24 @@
|
|||
2013-05-28 Balaji V. Iyer <balaji.v.iyer@intel.com>
|
||||
|
||||
* c-common.c (c_define_builtins): When cilkplus is enabled, the
|
||||
function array_notation_init_builtins is called.
|
||||
(c_common_init_ts): Added ARRAY_NOTATION_REF as typed.
|
||||
* c-common.def (ARRAY_NOTATION_REF): New tree.
|
||||
* c-common.h (build_array_notation_expr): New function declaration.
|
||||
(build_array_notation_ref): Likewise.
|
||||
(extract_sec_implicit_index_arg): New extern declaration.
|
||||
(is_sec_implicit_index_fn): Likewise.
|
||||
(ARRAY_NOTATION_CHECK): New define.
|
||||
(ARRAY_NOTATION_ARRAY): Likewise.
|
||||
(ARRAY_NOTATION_START): Likewise.
|
||||
(ARRAY_NOTATION_LENGTH): Likewise.
|
||||
(ARRAY_NOTATION_STRIDE): Likewise.
|
||||
* c-pretty-print.c (pp_c_postifix_expression): Added a new case for
|
||||
ARRAY_NOTATION_REF.
|
||||
(pp_c_expression): Likewise.
|
||||
* c.opt (flag_enable_cilkplus): New flag.
|
||||
* array-notation-common.c: New file.
|
||||
|
||||
2013-05-14 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c++/57274
|
||||
|
|
76
gcc/c-family/array-notation-common.c
Normal file
76
gcc/c-family/array-notation-common.c
Normal file
|
@ -0,0 +1,76 @@
|
|||
/* This file is part of the Intel(R) Cilk(TM) Plus support
|
||||
This file contains the builtin functions for Array
|
||||
notations.
|
||||
Copyright (C) 2013 Free Software Foundation, Inc.
|
||||
Contributed by Balaji V. Iyer <balaji.v.iyer@intel.com>,
|
||||
Intel Corporation
|
||||
|
||||
This file is part of GCC.
|
||||
|
||||
GCC is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
GCC is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GCC; see the file COPYING3. If not see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "config.h"
|
||||
#include "system.h"
|
||||
#include "coretypes.h"
|
||||
#include "tree.h"
|
||||
#include "langhooks.h"
|
||||
#include "tree-iterator.h"
|
||||
#include "diagnostic-core.h"
|
||||
|
||||
|
||||
/* Returns true if the function call in FNDECL is __sec_implicit_index. */
|
||||
|
||||
bool
|
||||
is_sec_implicit_index_fn (tree fndecl)
|
||||
{
|
||||
if (TREE_CODE (fndecl) == ADDR_EXPR)
|
||||
fndecl = TREE_OPERAND (fndecl, 0);
|
||||
|
||||
return
|
||||
(TREE_CODE (fndecl) == FUNCTION_DECL
|
||||
&& DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
|
||||
&& DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CILKPLUS_SEC_IMPLICIT_INDEX);
|
||||
}
|
||||
|
||||
/* Returns the first and only argument for FN, which should be a
|
||||
sec_implicit_index function. FN's location in the source file is as
|
||||
indicated by LOCATION. The argument to FN must be a constant integer
|
||||
expression, otherwise returns -1. */
|
||||
|
||||
HOST_WIDE_INT
|
||||
extract_sec_implicit_index_arg (location_t location, tree fn)
|
||||
{
|
||||
tree fn_arg;
|
||||
HOST_WIDE_INT return_int = 0;
|
||||
|
||||
if (TREE_CODE (fn) == CALL_EXPR)
|
||||
{
|
||||
fn_arg = CALL_EXPR_ARG (fn, 0);
|
||||
if (TREE_CODE (fn_arg) == INTEGER_CST)
|
||||
return_int = int_cst_value (fn_arg);
|
||||
else
|
||||
{
|
||||
/* If the location is unknown, and if fn has a location, then use that
|
||||
information so that the user has a better idea where the error
|
||||
could be. */
|
||||
if (location == UNKNOWN_LOCATION && EXPR_HAS_LOCATION (fn))
|
||||
location = EXPR_LOCATION (fn);
|
||||
error_at (location, "__sec_implicit_index parameter must be an "
|
||||
"integer constant expression");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return return_int;
|
||||
}
|
|
@ -11424,6 +11424,7 @@ c_common_init_ts (void)
|
|||
{
|
||||
MARK_TS_TYPED (C_MAYBE_CONST_EXPR);
|
||||
MARK_TS_TYPED (EXCESS_PRECISION_EXPR);
|
||||
MARK_TS_TYPED (ARRAY_NOTATION_REF);
|
||||
}
|
||||
|
||||
/* Build a user-defined numeric literal out of an integer constant type VALUE
|
||||
|
|
|
@ -55,6 +55,13 @@ DEFTREECODE (USERDEF_LITERAL, "userdef_literal", tcc_exceptional, 3)
|
|||
or for the purpose of -Wsizeof-pointer-memaccess warning. */
|
||||
DEFTREECODE (SIZEOF_EXPR, "sizeof_expr", tcc_expression, 1)
|
||||
|
||||
/* Array Notation expression.
|
||||
Operand 0 is the array.
|
||||
Operand 1 is the starting array index.
|
||||
Operand 2 contains the number of elements you need to access.
|
||||
Operand 3 is the stride. */
|
||||
DEFTREECODE (ARRAY_NOTATION_REF, "array_notation_ref", tcc_reference, 4)
|
||||
|
||||
/*
|
||||
Local variables:
|
||||
mode:c
|
||||
|
|
|
@ -538,6 +538,10 @@ extern tree pushdecl_top_level (tree);
|
|||
extern tree pushdecl (tree);
|
||||
extern tree build_modify_expr (location_t, tree, tree, enum tree_code,
|
||||
location_t, tree, tree);
|
||||
extern tree build_array_notation_expr (location_t, tree, tree, enum tree_code,
|
||||
location_t, tree, tree);
|
||||
extern tree build_array_notation_ref (location_t, tree, tree, tree, tree, tree);
|
||||
extern bool find_rank (location_t, tree, tree, bool, size_t *);
|
||||
extern tree build_indirect_ref (location_t, tree, ref_operator);
|
||||
|
||||
extern int field_decl_cmp (const void *, const void *);
|
||||
|
@ -1133,4 +1137,26 @@ enum stv_conv {
|
|||
extern enum stv_conv scalar_to_vector (location_t loc, enum tree_code code,
|
||||
tree op0, tree op1, bool);
|
||||
|
||||
/* These #defines allow users to access different operands of the
|
||||
array notation tree. */
|
||||
|
||||
#define ARRAY_NOTATION_CHECK(NODE) TREE_CHECK (NODE, ARRAY_NOTATION_REF)
|
||||
#define ARRAY_NOTATION_ARRAY(NODE) \
|
||||
TREE_OPERAND (ARRAY_NOTATION_CHECK (NODE), 0)
|
||||
#define ARRAY_NOTATION_START(NODE) \
|
||||
TREE_OPERAND (ARRAY_NOTATION_CHECK (NODE), 1)
|
||||
#define ARRAY_NOTATION_LENGTH(NODE) \
|
||||
TREE_OPERAND (ARRAY_NOTATION_CHECK (NODE), 2)
|
||||
#define ARRAY_NOTATION_STRIDE(NODE) \
|
||||
TREE_OPERAND (ARRAY_NOTATION_CHECK (NODE), 3)
|
||||
|
||||
extern int extract_sec_implicit_index_arg (location_t, tree);
|
||||
extern bool is_sec_implicit_index_fn (tree);
|
||||
extern void array_notation_init_builtins (void);
|
||||
extern struct c_expr fix_array_notation_expr (location_t, enum tree_code,
|
||||
struct c_expr);
|
||||
extern bool contains_array_notation_expr (tree);
|
||||
extern tree expand_array_notation_exprs (tree);
|
||||
extern tree fix_conditional_array_notations (tree);
|
||||
extern tree find_correct_array_notation_type (tree);
|
||||
#endif /* ! GCC_C_COMMON_H */
|
||||
|
|
|
@ -1476,6 +1476,17 @@ pp_c_postfix_expression (c_pretty_printer *pp, tree e)
|
|||
pp_c_right_bracket (pp);
|
||||
break;
|
||||
|
||||
case ARRAY_NOTATION_REF:
|
||||
pp_postfix_expression (pp, ARRAY_NOTATION_ARRAY (e));
|
||||
pp_c_left_bracket (pp);
|
||||
pp_expression (pp, ARRAY_NOTATION_START (e));
|
||||
pp_colon (pp);
|
||||
pp_expression (pp, ARRAY_NOTATION_LENGTH (e));
|
||||
pp_colon (pp);
|
||||
pp_expression (pp, ARRAY_NOTATION_STRIDE (e));
|
||||
pp_c_right_bracket (pp);
|
||||
break;
|
||||
|
||||
case CALL_EXPR:
|
||||
{
|
||||
call_expr_arg_iterator iter;
|
||||
|
@ -2150,6 +2161,7 @@ pp_c_expression (c_pretty_printer *pp, tree e)
|
|||
case POSTINCREMENT_EXPR:
|
||||
case POSTDECREMENT_EXPR:
|
||||
case ARRAY_REF:
|
||||
case ARRAY_NOTATION_REF:
|
||||
case CALL_EXPR:
|
||||
case COMPONENT_REF:
|
||||
case BIT_FIELD_REF:
|
||||
|
|
|
@ -843,6 +843,10 @@ fcanonical-system-headers
|
|||
C ObjC C++ ObjC++
|
||||
Where shorter, use canonicalized paths to systems headers.
|
||||
|
||||
fcilkplus
|
||||
C ObjC C++ ObjC++ LTO Report Var(flag_enable_cilkplus) Init(0)
|
||||
Enable Cilk Plus
|
||||
|
||||
fcheck-new
|
||||
C++ ObjC++ Var(flag_check_new)
|
||||
Check the return value of new
|
||||
|
|
|
@ -1,3 +1,45 @@
|
|||
2013-05-28 Balaji V. Iyer <balaji.v.iyer@intel.com>
|
||||
|
||||
* c-typeck.c (build_array_ref): Added a check to see if array's
|
||||
index is greater than one. If true, then emit an error.
|
||||
(build_function_call_vec): Exclude error reporting and checking
|
||||
for builtin array-notation functions.
|
||||
(convert_arguments): Likewise.
|
||||
(c_finish_return): Added a check for array notations as a return
|
||||
expression. If true, then emit an error.
|
||||
(c_finish_loop): Added a check for array notations in a loop
|
||||
condition. If true then emit an error.
|
||||
(lvalue_p): Added a ARRAY_NOTATION_REF case.
|
||||
(build_binary_op): Added a check for array notation expr inside
|
||||
op1 and op0. If present, we call another function to find correct
|
||||
type.
|
||||
* Make-lang.in (C_AND_OBJC_OBJS): Added c-array-notation.o.
|
||||
* c-parser.c (c_parser_compound_statement): Check if array
|
||||
notation code is used in tree, if so, then transform them into
|
||||
appropriate C code.
|
||||
(c_parser_expr_no_commas): Check if array notation is used in LHS
|
||||
or RHS, if so, then build array notation expression instead of
|
||||
regular modify.
|
||||
(c_parser_postfix_expression_after_primary): Added a check for
|
||||
colon(s) after square braces, if so then handle it like an array
|
||||
notation. Also, break up array notations in unary op if found.
|
||||
(c_parser_direct_declarator_inner): Added a check for array
|
||||
notation.
|
||||
(c_parser_compound_statement): Added a check for array notation in
|
||||
a stmt. If one is present, then expand array notation expr.
|
||||
(c_parser_if_statement): Likewise.
|
||||
(c_parser_switch_statement): Added a check for array notations in
|
||||
a switch statement's condition. If true, then output an error.
|
||||
(c_parser_while_statement): Similarly, but for a while.
|
||||
(c_parser_do_statement): Similarly, but for a do-while.
|
||||
(c_parser_for_statement): Similarly, but for a for-loop.
|
||||
(c_parser_unary_expression): Check if array notation is used in a
|
||||
pre-increment or pre-decrement expression. If true, then expand
|
||||
them.
|
||||
(c_parser_array_notation): New function.
|
||||
* c-array-notation.c: New file.
|
||||
* c-tree.h (is_cilkplus_reduce_builtin): Protoize.
|
||||
|
||||
2013-05-23 Mike Stump <mikestump@comcast.net>
|
||||
|
||||
* c-typeck.c (convert_for_assignment): Handle references to memory
|
||||
|
|
|
@ -56,7 +56,7 @@ c/gccspec.o: c/gccspec.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(GCC_H) \
|
|||
# Language-specific object files for C and Objective C.
|
||||
C_AND_OBJC_OBJS = attribs.o c/c-errors.o c/c-decl.o c/c-typeck.o \
|
||||
c/c-convert.o c/c-aux-info.o c/c-objc-common.o c/c-parser.o \
|
||||
$(C_COMMON_OBJS) $(C_TARGET_OBJS)
|
||||
c/c-array-notation.o $(C_COMMON_OBJS) $(C_TARGET_OBJS)
|
||||
|
||||
# Language-specific object files for C.
|
||||
C_OBJS = c/c-lang.o c-family/stub-objc.o $(C_AND_OBJC_OBJS)
|
||||
|
@ -192,3 +192,8 @@ c/c-typeck.o : c/c-typeck.c c/c-lang.h $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_
|
|||
langhooks.h tree-iterator.h $(BITMAP_H) $(GIMPLE_H) \
|
||||
c-family/c-objc.h c-family/c-common.h
|
||||
|
||||
c/c-array-notation.o: c/c-array-notation.c c/c-lang.h $(CONFIG_H) \
|
||||
$(SYSTEM_H) coretypes.h $(TREE_H) $(C_TREE_H) $(TARGET_H) \
|
||||
intl.h output.h $(EXPR_H) langhooks.h tree-iterator.h $(BITMAP_H) \
|
||||
$(GIMPLE_H) c-family/c-objc.h
|
||||
|
||||
|
|
2875
gcc/c/c-array-notation.c
Normal file
2875
gcc/c/c-array-notation.c
Normal file
File diff suppressed because it is too large
Load diff
327
gcc/c/c-parser.c
327
gcc/c/c-parser.c
|
@ -1216,6 +1216,8 @@ static void c_parser_objc_at_dynamic_declaration (c_parser *);
|
|||
static bool c_parser_objc_diagnose_bad_element_prefix
|
||||
(c_parser *, struct c_declspecs *);
|
||||
|
||||
static tree c_parser_array_notation (location_t, c_parser *, tree, tree);
|
||||
|
||||
/* Parse a translation unit (C90 6.7, C99 6.9).
|
||||
|
||||
translation-unit:
|
||||
|
@ -3067,6 +3069,15 @@ c_parser_direct_declarator_inner (c_parser *parser, bool id_present,
|
|||
dimen = NULL_TREE;
|
||||
star_seen = false;
|
||||
}
|
||||
else if (flag_enable_cilkplus
|
||||
&& c_parser_next_token_is (parser, CPP_COLON))
|
||||
{
|
||||
dimen = error_mark_node;
|
||||
star_seen = false;
|
||||
error_at (c_parser_peek_token (parser)->location,
|
||||
"array notations cannot be used in declaration");
|
||||
c_parser_consume_token (parser);
|
||||
}
|
||||
else if (c_parser_next_token_is (parser, CPP_MULT))
|
||||
{
|
||||
if (c_parser_peek_2nd_token (parser)->type == CPP_CLOSE_SQUARE)
|
||||
|
@ -3089,6 +3100,14 @@ c_parser_direct_declarator_inner (c_parser *parser, bool id_present,
|
|||
}
|
||||
if (c_parser_next_token_is (parser, CPP_CLOSE_SQUARE))
|
||||
c_parser_consume_token (parser);
|
||||
else if (flag_enable_cilkplus
|
||||
&& c_parser_next_token_is (parser, CPP_COLON))
|
||||
{
|
||||
error_at (c_parser_peek_token (parser)->location,
|
||||
"array notations cannot be used in declaration");
|
||||
c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE, NULL);
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE,
|
||||
|
@ -4071,6 +4090,10 @@ c_parser_compound_statement (c_parser *parser)
|
|||
}
|
||||
stmt = c_begin_compound_stmt (true);
|
||||
c_parser_compound_statement_nostart (parser);
|
||||
|
||||
/* If the compound stmt contains array notations, then we expand them. */
|
||||
if (flag_enable_cilkplus && contains_array_notation_expr (stmt))
|
||||
stmt = expand_array_notation_exprs (stmt);
|
||||
return c_end_compound_stmt (brace_loc, stmt, true);
|
||||
}
|
||||
|
||||
|
@ -4714,6 +4737,7 @@ c_parser_if_statement (c_parser *parser)
|
|||
bool first_if = false;
|
||||
tree first_body, second_body;
|
||||
bool in_if_block;
|
||||
tree if_stmt;
|
||||
|
||||
gcc_assert (c_parser_next_token_is_keyword (parser, RID_IF));
|
||||
c_parser_consume_token (parser);
|
||||
|
@ -4732,7 +4756,12 @@ c_parser_if_statement (c_parser *parser)
|
|||
else
|
||||
second_body = NULL_TREE;
|
||||
c_finish_if_stmt (loc, cond, first_body, second_body, first_if);
|
||||
add_stmt (c_end_compound_stmt (loc, block, flag_isoc99));
|
||||
if_stmt = c_end_compound_stmt (loc, block, flag_isoc99);
|
||||
|
||||
/* If the if statement contains array notations, then we expand them. */
|
||||
if (flag_enable_cilkplus && contains_array_notation_expr (if_stmt))
|
||||
if_stmt = fix_conditional_array_notations (if_stmt);
|
||||
add_stmt (if_stmt);
|
||||
}
|
||||
|
||||
/* Parse a switch statement (C90 6.6.4, C99 6.8.4).
|
||||
|
@ -4754,6 +4783,13 @@ c_parser_switch_statement (c_parser *parser)
|
|||
{
|
||||
switch_cond_loc = c_parser_peek_token (parser)->location;
|
||||
expr = c_parser_expression (parser).value;
|
||||
if (flag_enable_cilkplus && contains_array_notation_expr (expr))
|
||||
{
|
||||
error_at (switch_cond_loc,
|
||||
"array notations cannot be used as a condition for switch "
|
||||
"statement");
|
||||
expr = error_mark_node;
|
||||
}
|
||||
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>");
|
||||
}
|
||||
else
|
||||
|
@ -4793,6 +4829,12 @@ c_parser_while_statement (c_parser *parser)
|
|||
block = c_begin_compound_stmt (flag_isoc99);
|
||||
loc = c_parser_peek_token (parser)->location;
|
||||
cond = c_parser_paren_condition (parser);
|
||||
if (flag_enable_cilkplus && contains_array_notation_expr (cond))
|
||||
{
|
||||
error_at (loc, "array notations cannot be used as a condition for while "
|
||||
"statement");
|
||||
cond = error_mark_node;
|
||||
}
|
||||
save_break = c_break_label;
|
||||
c_break_label = NULL_TREE;
|
||||
save_cont = c_cont_label;
|
||||
|
@ -4834,6 +4876,13 @@ c_parser_do_statement (c_parser *parser)
|
|||
new_cont = c_cont_label;
|
||||
c_cont_label = save_cont;
|
||||
cond = c_parser_paren_condition (parser);
|
||||
if (flag_enable_cilkplus && contains_array_notation_expr (cond))
|
||||
{
|
||||
error_at (loc, "array notations cannot be used as a condition for a "
|
||||
"do-while statement");
|
||||
cond = error_mark_node;
|
||||
}
|
||||
|
||||
if (!c_parser_require (parser, CPP_SEMICOLON, "expected %<;%>"))
|
||||
c_parser_skip_to_end_of_block_or_statement (parser);
|
||||
c_finish_loop (loc, cond, NULL, body, new_break, new_cont, false);
|
||||
|
@ -5009,7 +5058,14 @@ c_parser_for_statement (c_parser *parser)
|
|||
else
|
||||
{
|
||||
cond = c_parser_condition (parser);
|
||||
c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
|
||||
if (flag_enable_cilkplus && contains_array_notation_expr (cond))
|
||||
{
|
||||
error_at (loc, "array notations cannot be used in a "
|
||||
"condition for a for-loop");
|
||||
cond = error_mark_node;
|
||||
}
|
||||
c_parser_skip_until_found (parser, CPP_SEMICOLON,
|
||||
"expected %<;%>");
|
||||
}
|
||||
}
|
||||
/* Parse the increment expression (the third expression in a
|
||||
|
@ -5388,9 +5444,21 @@ c_parser_expr_no_commas (c_parser *parser, struct c_expr *after)
|
|||
exp_location = c_parser_peek_token (parser)->location;
|
||||
rhs = c_parser_expr_no_commas (parser, NULL);
|
||||
rhs = default_function_array_read_conversion (exp_location, rhs);
|
||||
ret.value = build_modify_expr (op_location, lhs.value, lhs.original_type,
|
||||
code, exp_location, rhs.value,
|
||||
rhs.original_type);
|
||||
|
||||
/* The line below is where the statement has the form:
|
||||
A = B, where A and B contain array notation exprs. So this is where
|
||||
we handle those. */
|
||||
if (flag_enable_cilkplus
|
||||
&& (contains_array_notation_expr (lhs.value)
|
||||
|| contains_array_notation_expr (rhs.value)))
|
||||
ret.value = build_array_notation_expr (op_location, lhs.value,
|
||||
lhs.original_type, code,
|
||||
exp_location, rhs.value,
|
||||
rhs.original_type);
|
||||
else
|
||||
ret.value = build_modify_expr (op_location, lhs.value, lhs.original_type,
|
||||
code, exp_location, rhs.value,
|
||||
rhs.original_type);
|
||||
if (code == NOP_EXPR)
|
||||
ret.original_code = MODIFY_EXPR;
|
||||
else
|
||||
|
@ -5870,14 +5938,28 @@ c_parser_unary_expression (c_parser *parser)
|
|||
c_parser_consume_token (parser);
|
||||
exp_loc = c_parser_peek_token (parser)->location;
|
||||
op = c_parser_cast_expression (parser, NULL);
|
||||
op = default_function_array_read_conversion (exp_loc, op);
|
||||
return parser_build_unary_op (op_loc, PREINCREMENT_EXPR, op);
|
||||
|
||||
/* If there is array notations in op, we expand them. */
|
||||
if (flag_enable_cilkplus && TREE_CODE (op.value) == ARRAY_NOTATION_REF)
|
||||
return fix_array_notation_expr (exp_loc, PREINCREMENT_EXPR, op);
|
||||
else
|
||||
{
|
||||
op = default_function_array_read_conversion (exp_loc, op);
|
||||
return parser_build_unary_op (op_loc, PREINCREMENT_EXPR, op);
|
||||
}
|
||||
case CPP_MINUS_MINUS:
|
||||
c_parser_consume_token (parser);
|
||||
exp_loc = c_parser_peek_token (parser)->location;
|
||||
op = c_parser_cast_expression (parser, NULL);
|
||||
op = default_function_array_read_conversion (exp_loc, op);
|
||||
return parser_build_unary_op (op_loc, PREDECREMENT_EXPR, op);
|
||||
|
||||
/* If there is array notations in op, we expand them. */
|
||||
if (flag_enable_cilkplus && TREE_CODE (op.value) == ARRAY_NOTATION_REF)
|
||||
return fix_array_notation_expr (exp_loc, PREDECREMENT_EXPR, op);
|
||||
else
|
||||
{
|
||||
op = default_function_array_read_conversion (exp_loc, op);
|
||||
return parser_build_unary_op (op_loc, PREDECREMENT_EXPR, op);
|
||||
}
|
||||
case CPP_AND:
|
||||
c_parser_consume_token (parser);
|
||||
op = c_parser_cast_expression (parser, NULL);
|
||||
|
@ -6880,10 +6962,36 @@ c_parser_postfix_expression_after_primary (c_parser *parser,
|
|||
case CPP_OPEN_SQUARE:
|
||||
/* Array reference. */
|
||||
c_parser_consume_token (parser);
|
||||
idx = c_parser_expression (parser).value;
|
||||
c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE,
|
||||
"expected %<]%>");
|
||||
expr.value = build_array_ref (op_loc, expr.value, idx);
|
||||
if (flag_enable_cilkplus
|
||||
&& c_parser_peek_token (parser)->type == CPP_COLON)
|
||||
/* If we are here, then we have something like this:
|
||||
Array [ : ]
|
||||
*/
|
||||
expr.value = c_parser_array_notation (expr_loc, parser, NULL_TREE,
|
||||
expr.value);
|
||||
else
|
||||
{
|
||||
idx = c_parser_expression (parser).value;
|
||||
/* Here we have 3 options:
|
||||
1. Array [EXPR] -- Normal Array call.
|
||||
2. Array [EXPR : EXPR] -- Array notation without stride.
|
||||
3. Array [EXPR : EXPR : EXPR] -- Array notation with stride.
|
||||
|
||||
For 1, we just handle it just like a normal array expression.
|
||||
For 2 and 3 we handle it like we handle array notations. The
|
||||
idx value we have above becomes the initial/start index.
|
||||
*/
|
||||
if (flag_enable_cilkplus
|
||||
&& c_parser_peek_token (parser)->type == CPP_COLON)
|
||||
expr.value = c_parser_array_notation (expr_loc, parser, idx,
|
||||
expr.value);
|
||||
else
|
||||
{
|
||||
c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE,
|
||||
"expected %<]%>");
|
||||
expr.value = build_array_ref (op_loc, expr.value, idx);
|
||||
}
|
||||
}
|
||||
expr.original_code = ERROR_MARK;
|
||||
expr.original_type = NULL;
|
||||
break;
|
||||
|
@ -6991,18 +7099,32 @@ c_parser_postfix_expression_after_primary (c_parser *parser,
|
|||
case CPP_PLUS_PLUS:
|
||||
/* Postincrement. */
|
||||
c_parser_consume_token (parser);
|
||||
expr = default_function_array_read_conversion (expr_loc, expr);
|
||||
expr.value = build_unary_op (op_loc,
|
||||
POSTINCREMENT_EXPR, expr.value, 0);
|
||||
/* If the expressions have array notations, we expand them. */
|
||||
if (flag_enable_cilkplus
|
||||
&& TREE_CODE (expr.value) == ARRAY_NOTATION_REF)
|
||||
expr = fix_array_notation_expr (expr_loc, POSTINCREMENT_EXPR, expr);
|
||||
else
|
||||
{
|
||||
expr = default_function_array_read_conversion (expr_loc, expr);
|
||||
expr.value = build_unary_op (op_loc,
|
||||
POSTINCREMENT_EXPR, expr.value, 0);
|
||||
}
|
||||
expr.original_code = ERROR_MARK;
|
||||
expr.original_type = NULL;
|
||||
break;
|
||||
case CPP_MINUS_MINUS:
|
||||
/* Postdecrement. */
|
||||
c_parser_consume_token (parser);
|
||||
expr = default_function_array_read_conversion (expr_loc, expr);
|
||||
expr.value = build_unary_op (op_loc,
|
||||
POSTDECREMENT_EXPR, expr.value, 0);
|
||||
/* If the expressions have array notations, we expand them. */
|
||||
if (flag_enable_cilkplus
|
||||
&& TREE_CODE (expr.value) == ARRAY_NOTATION_REF)
|
||||
expr = fix_array_notation_expr (expr_loc, POSTDECREMENT_EXPR, expr);
|
||||
else
|
||||
{
|
||||
expr = default_function_array_read_conversion (expr_loc, expr);
|
||||
expr.value = build_unary_op (op_loc,
|
||||
POSTDECREMENT_EXPR, expr.value, 0);
|
||||
}
|
||||
expr.original_code = ERROR_MARK;
|
||||
expr.original_type = NULL;
|
||||
break;
|
||||
|
@ -10888,4 +11010,171 @@ c_parse_file (void)
|
|||
the_parser = NULL;
|
||||
}
|
||||
|
||||
/* This function parses Cilk Plus array notation. The starting index is
|
||||
passed in INITIAL_INDEX and the array name is passes in ARRAY_VALUE. The
|
||||
return value of this function is a tree_node called VALUE_TREE of type
|
||||
ARRAY_NOTATION_REF. */
|
||||
|
||||
static tree
|
||||
c_parser_array_notation (location_t loc, c_parser *parser, tree initial_index,
|
||||
tree array_value)
|
||||
{
|
||||
c_token *token = NULL;
|
||||
tree start_index = NULL_TREE, end_index = NULL_TREE, stride = NULL_TREE;
|
||||
tree value_tree = NULL_TREE, type = NULL_TREE, array_type = NULL_TREE;
|
||||
tree array_type_domain = NULL_TREE;
|
||||
|
||||
if (array_value == error_mark_node)
|
||||
{
|
||||
/* No need to continue. If either of these 2 were true, then an error
|
||||
must be emitted already. Thus, no need to emit them twice. */
|
||||
c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE, NULL);
|
||||
return error_mark_node;
|
||||
}
|
||||
|
||||
array_type = TREE_TYPE (array_value);
|
||||
gcc_assert (array_type);
|
||||
type = TREE_TYPE (array_type);
|
||||
token = c_parser_peek_token (parser);
|
||||
|
||||
if (token->type == CPP_EOF)
|
||||
{
|
||||
c_parser_error (parser, "expected %<:%> or numeral");
|
||||
return value_tree;
|
||||
}
|
||||
else if (token->type == CPP_COLON)
|
||||
{
|
||||
if (!initial_index)
|
||||
{
|
||||
/* If we are here, then we have a case like this A[:]. */
|
||||
c_parser_consume_token (parser);
|
||||
if (TREE_CODE (array_type) == POINTER_TYPE)
|
||||
{
|
||||
error_at (loc, "start-index and length fields necessary for "
|
||||
"using array notations in pointers");
|
||||
c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE, NULL);
|
||||
return error_mark_node;
|
||||
}
|
||||
if (TREE_CODE (array_type) == FUNCTION_TYPE)
|
||||
{
|
||||
error_at (loc, "array notations cannot be used with function "
|
||||
"type");
|
||||
c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE, NULL);
|
||||
return error_mark_node;
|
||||
}
|
||||
if (TREE_CODE (array_type) == ARRAY_TYPE)
|
||||
{
|
||||
tree subtype = TREE_TYPE (array_type);
|
||||
while (subtype && TREE_CODE (subtype) == POINTER_TYPE)
|
||||
{
|
||||
/* Now this could be a function pointer. Find them and
|
||||
give out an error. */
|
||||
subtype = TREE_TYPE (subtype);
|
||||
if (subtype && TREE_CODE (subtype) == FUNCTION_TYPE)
|
||||
{
|
||||
error_at (loc, "array notations cannot be used with "
|
||||
"function pointer arrays");
|
||||
c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE,
|
||||
NULL);
|
||||
return error_mark_node;
|
||||
}
|
||||
}
|
||||
}
|
||||
array_type_domain = TYPE_DOMAIN (array_type);
|
||||
|
||||
if (!array_type_domain)
|
||||
{
|
||||
error_at (loc, "start-index and length fields necessary for "
|
||||
"using array notations in dimensionless arrays");
|
||||
c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE, NULL);
|
||||
return error_mark_node;
|
||||
}
|
||||
|
||||
start_index = TYPE_MINVAL (array_type_domain);
|
||||
start_index = fold_build1 (CONVERT_EXPR, ptrdiff_type_node,
|
||||
start_index);
|
||||
if (!TYPE_MAXVAL (array_type_domain)
|
||||
|| !TREE_CONSTANT (TYPE_MAXVAL (array_type_domain)))
|
||||
{
|
||||
error_at (loc, "start-index and length fields necessary for "
|
||||
"using array notations in variable-length arrays");
|
||||
c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE, NULL);
|
||||
return error_mark_node;
|
||||
}
|
||||
end_index = TYPE_MAXVAL (array_type_domain);
|
||||
end_index = fold_build2 (PLUS_EXPR, TREE_TYPE (end_index),
|
||||
end_index, integer_one_node);
|
||||
end_index = fold_build1 (CONVERT_EXPR, ptrdiff_type_node, end_index);
|
||||
stride = build_int_cst (integer_type_node, 1);
|
||||
stride = fold_build1 (CONVERT_EXPR, ptrdiff_type_node, stride);
|
||||
}
|
||||
else if (initial_index != error_mark_node)
|
||||
{
|
||||
/* If we are here, then there should be 2 possibilities:
|
||||
1. Array [EXPR : EXPR]
|
||||
2. Array [EXPR : EXPR : EXPR]
|
||||
*/
|
||||
start_index = initial_index;
|
||||
|
||||
if (TREE_CODE (array_type) == FUNCTION_TYPE)
|
||||
{
|
||||
error_at (loc, "array notations cannot be used with function "
|
||||
"type");
|
||||
c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE, NULL);
|
||||
return error_mark_node;
|
||||
}
|
||||
if (TREE_CODE (array_type) == ARRAY_TYPE
|
||||
|| TREE_CODE (array_type) == POINTER_TYPE)
|
||||
{
|
||||
tree subtype = TREE_TYPE (array_type);
|
||||
while (subtype
|
||||
&& (TREE_CODE (subtype) == POINTER_TYPE
|
||||
|| TREE_CODE (subtype) == ARRAY_TYPE))
|
||||
{
|
||||
/* Now this could be a function pointer. Find them and
|
||||
give out an error. */
|
||||
subtype = TREE_TYPE (subtype);
|
||||
if (subtype && TREE_CODE (subtype) == FUNCTION_TYPE)
|
||||
{
|
||||
error_at (loc, "array notations cannot be used with "
|
||||
"function pointer arrays");
|
||||
c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE,
|
||||
NULL);
|
||||
return error_mark_node;
|
||||
}
|
||||
}
|
||||
}
|
||||
c_parser_consume_token (parser); /* consume the ':' */
|
||||
end_index = c_parser_expression (parser).value;
|
||||
if (!end_index || end_index == error_mark_node)
|
||||
{
|
||||
c_parser_skip_to_end_of_block_or_statement (parser);
|
||||
return error_mark_node;
|
||||
}
|
||||
if (c_parser_peek_token (parser)->type == CPP_COLON)
|
||||
{
|
||||
c_parser_consume_token (parser);
|
||||
stride = c_parser_expression (parser).value;
|
||||
if (!stride || stride == error_mark_node)
|
||||
{
|
||||
c_parser_skip_to_end_of_block_or_statement (parser);
|
||||
return error_mark_node;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
c_parser_error (parser, "expected array notation expression");
|
||||
}
|
||||
else
|
||||
c_parser_error (parser, "expected array notation expression");
|
||||
|
||||
c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE, "expected %<]%>");
|
||||
|
||||
value_tree = build_array_notation_ref (loc, array_value, start_index,
|
||||
end_index, stride, type);
|
||||
if (value_tree != error_mark_node)
|
||||
SET_EXPR_LOCATION (value_tree, loc);
|
||||
return value_tree;
|
||||
}
|
||||
|
||||
#include "gt-c-c-parser.h"
|
||||
|
|
|
@ -668,4 +668,7 @@ extern void c_write_global_declarations (void);
|
|||
extern void pedwarn_c90 (location_t, int opt, const char *, ...) ATTRIBUTE_GCC_DIAG(3,4);
|
||||
extern void pedwarn_c99 (location_t, int opt, const char *, ...) ATTRIBUTE_GCC_DIAG(3,4);
|
||||
|
||||
/* In c-array-notation.c */
|
||||
enum built_in_function is_cilkplus_reduce_builtin (tree);
|
||||
|
||||
#endif /* ! GCC_C_TREE_H */
|
||||
|
|
|
@ -2304,6 +2304,17 @@ build_array_ref (location_t loc, tree array, tree index)
|
|||
|| TREE_TYPE (index) == error_mark_node)
|
||||
return error_mark_node;
|
||||
|
||||
if (flag_enable_cilkplus && contains_array_notation_expr (index))
|
||||
{
|
||||
size_t rank = 0;
|
||||
if (!find_rank (loc, index, index, true, &rank))
|
||||
return error_mark_node;
|
||||
if (rank > 1)
|
||||
{
|
||||
error_at (loc, "rank of the array's index is greater than 1");
|
||||
return error_mark_node;
|
||||
}
|
||||
}
|
||||
if (TREE_CODE (TREE_TYPE (array)) != ARRAY_TYPE
|
||||
&& TREE_CODE (TREE_TYPE (array)) != POINTER_TYPE
|
||||
/* Allow vector[index] but not index[vector]. */
|
||||
|
@ -2722,6 +2733,10 @@ build_function_call_vec (location_t loc, tree function,
|
|||
often rewritten and don't match the original parameter list. */
|
||||
if (name && !strncmp (IDENTIFIER_POINTER (name), "__atomic_", 9))
|
||||
origtypes = NULL;
|
||||
|
||||
if (flag_enable_cilkplus
|
||||
&& is_cilkplus_reduce_builtin (function))
|
||||
origtypes = NULL;
|
||||
}
|
||||
if (TREE_CODE (TREE_TYPE (function)) == FUNCTION_TYPE)
|
||||
function = function_to_pointer_conversion (loc, function);
|
||||
|
@ -2944,6 +2959,17 @@ convert_arguments (tree typelist, vec<tree, va_gc> *values,
|
|||
bool npc;
|
||||
tree parmval;
|
||||
|
||||
// FIXME: I assume this code is here to handle the overloaded
|
||||
// behavior of the __sec_reduce* builtins, and avoid giving
|
||||
// argument mismatch warnings/errors. We should probably handle
|
||||
// this with the resolve_overloaded_builtin infrastructure.
|
||||
/* If the function call is a builtin function call, then we do not
|
||||
worry about it since we break them up into its equivalent later and
|
||||
we do the appropriate checks there. */
|
||||
if (flag_enable_cilkplus
|
||||
&& is_cilkplus_reduce_builtin (fundecl))
|
||||
continue;
|
||||
|
||||
if (type == void_type_node)
|
||||
{
|
||||
if (selector)
|
||||
|
@ -3181,10 +3207,16 @@ convert_arguments (tree typelist, vec<tree, va_gc> *values,
|
|||
|
||||
if (typetail != 0 && TREE_VALUE (typetail) != void_type_node)
|
||||
{
|
||||
error_at (input_location,
|
||||
"too few arguments to function %qE", function);
|
||||
inform_declaration (fundecl);
|
||||
return -1;
|
||||
/* If array notation is used and Cilk Plus is enabled, then we do not
|
||||
worry about this error now. We will handle them in a later place. */
|
||||
if (!flag_enable_cilkplus
|
||||
|| !is_cilkplus_reduce_builtin (fundecl))
|
||||
{
|
||||
error_at (input_location,
|
||||
"too few arguments to function %qE", function);
|
||||
inform_declaration (fundecl);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return error_args ? -1 : (int) parmnum;
|
||||
|
@ -3875,6 +3907,7 @@ lvalue_p (const_tree ref)
|
|||
|
||||
case INDIRECT_REF:
|
||||
case ARRAY_REF:
|
||||
case ARRAY_NOTATION_REF:
|
||||
case VAR_DECL:
|
||||
case PARM_DECL:
|
||||
case RESULT_DECL:
|
||||
|
@ -8640,11 +8673,25 @@ c_finish_return (location_t loc, tree retval, tree origtype)
|
|||
tree valtype = TREE_TYPE (TREE_TYPE (current_function_decl)), ret_stmt;
|
||||
bool no_warning = false;
|
||||
bool npc = false;
|
||||
size_t rank = 0;
|
||||
|
||||
if (TREE_THIS_VOLATILE (current_function_decl))
|
||||
warning_at (loc, 0,
|
||||
"function declared %<noreturn%> has a %<return%> statement");
|
||||
|
||||
if (flag_enable_cilkplus && contains_array_notation_expr (retval))
|
||||
{
|
||||
/* Array notations are allowed in a return statement if it is inside a
|
||||
built-in array notation reduction function. */
|
||||
if (!find_rank (loc, retval, retval, false, &rank))
|
||||
return error_mark_node;
|
||||
if (rank >= 1)
|
||||
{
|
||||
error_at (loc, "array notation expression cannot be used as a "
|
||||
"return value");
|
||||
return error_mark_node;
|
||||
}
|
||||
}
|
||||
if (retval)
|
||||
{
|
||||
tree semantic_type = NULL_TREE;
|
||||
|
@ -8987,6 +9034,13 @@ c_finish_loop (location_t start_locus, tree cond, tree incr, tree body,
|
|||
{
|
||||
tree entry = NULL, exit = NULL, t;
|
||||
|
||||
if (flag_enable_cilkplus && contains_array_notation_expr (cond))
|
||||
{
|
||||
error_at (start_locus, "array notation expression cannot be used in a "
|
||||
"loop%'s condition");
|
||||
return;
|
||||
}
|
||||
|
||||
/* If the condition is zero don't generate a loop construct. */
|
||||
if (cond && integer_zerop (cond))
|
||||
{
|
||||
|
@ -9493,8 +9547,18 @@ build_binary_op (location_t location, enum tree_code code,
|
|||
op1 = default_conversion (op1);
|
||||
}
|
||||
|
||||
orig_type0 = type0 = TREE_TYPE (op0);
|
||||
orig_type1 = type1 = TREE_TYPE (op1);
|
||||
/* When Cilk Plus is enabled and there are array notations inside op0, then
|
||||
we check to see if there are builtin array notation functions. If
|
||||
so, then we take on the type of the array notation inside it. */
|
||||
if (flag_enable_cilkplus && contains_array_notation_expr (op0))
|
||||
orig_type0 = type0 = find_correct_array_notation_type (op0);
|
||||
else
|
||||
orig_type0 = type0 = TREE_TYPE (op0);
|
||||
|
||||
if (flag_enable_cilkplus && contains_array_notation_expr (op1))
|
||||
orig_type1 = type1 = find_correct_array_notation_type (op1);
|
||||
else
|
||||
orig_type1 = type1 = TREE_TYPE (op1);
|
||||
|
||||
/* The expression codes of the data types of the arguments tell us
|
||||
whether the arguments are integers, floating, pointers, etc. */
|
||||
|
|
59
gcc/cilkplus.def
Normal file
59
gcc/cilkplus.def
Normal file
|
@ -0,0 +1,59 @@
|
|||
/* This file contains the definitions and documentation for the
|
||||
CilkPlus builtins used in the GNU compiler.
|
||||
Copyright (C) 2013 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GCC.
|
||||
|
||||
GCC is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free
|
||||
Software Foundation; either version 3, or (at your option) any later
|
||||
version.
|
||||
|
||||
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GCC; see the file COPYING3. If not see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Before including this file, you should define a macro:
|
||||
|
||||
DEF_CILKPLUS_BUILTIN (ENUM, NAME, TYPE, ATTRS)
|
||||
|
||||
See builtins.def for details. */
|
||||
|
||||
DEF_CILKPLUS_BUILTIN (BUILT_IN_CILKPLUS_SEC_REDUCE_ADD,
|
||||
"__sec_reduce_add", BT_FN_INT_PTR, ATTR_NULL)
|
||||
DEF_CILKPLUS_BUILTIN (BUILT_IN_CILKPLUS_SEC_REDUCE_MUL,
|
||||
"__sec_reduce_mul", BT_FN_INT_PTR, ATTR_NULL)
|
||||
DEF_CILKPLUS_BUILTIN (BUILT_IN_CILKPLUS_SEC_REDUCE_ALL_ZERO,
|
||||
"__sec_reduce_all_zero", BT_FN_INT_PTR, ATTR_NULL)
|
||||
DEF_CILKPLUS_BUILTIN (BUILT_IN_CILKPLUS_SEC_REDUCE_ANY_ZERO,
|
||||
"__sec_reduce_any_zero", BT_FN_INT_PTR, ATTR_NULL)
|
||||
DEF_CILKPLUS_BUILTIN (BUILT_IN_CILKPLUS_SEC_REDUCE_MAX,
|
||||
"__sec_reduce_max", BT_FN_INT_PTR, ATTR_NULL)
|
||||
DEF_CILKPLUS_BUILTIN (BUILT_IN_CILKPLUS_SEC_REDUCE_MIN,
|
||||
"__sec_reduce_min", BT_FN_INT_PTR, ATTR_NULL)
|
||||
DEF_CILKPLUS_BUILTIN (BUILT_IN_CILKPLUS_SEC_REDUCE_MIN_IND,
|
||||
"__sec_reduce_min_ind", BT_FN_INT_PTR, ATTR_NULL)
|
||||
DEF_CILKPLUS_BUILTIN (BUILT_IN_CILKPLUS_SEC_REDUCE_MAX_IND,
|
||||
"__sec_reduce_max_ind", BT_FN_INT_PTR, ATTR_NULL)
|
||||
DEF_CILKPLUS_BUILTIN (BUILT_IN_CILKPLUS_SEC_REDUCE_ANY_NONZERO,
|
||||
"__sec_reduce_any_nonzero", BT_FN_INT_PTR, ATTR_NULL)
|
||||
DEF_CILKPLUS_BUILTIN (BUILT_IN_CILKPLUS_SEC_REDUCE_ALL_NONZERO,
|
||||
"__sec_reduce_all_nonzero", BT_FN_INT_PTR, ATTR_NULL)
|
||||
DEF_CILKPLUS_BUILTIN (BUILT_IN_CILKPLUS_SEC_REDUCE,
|
||||
"__sec_reduce", BT_FN_INT_PTR_PTR_PTR, ATTR_NULL)
|
||||
DEF_CILKPLUS_BUILTIN (BUILT_IN_CILKPLUS_SEC_REDUCE_MUTATING,
|
||||
"__sec_reduce_mutating", BT_FN_INT_PTR_PTR_PTR, ATTR_NULL)
|
||||
// FIXME: This probably needs to be rewritten as a keyword.
|
||||
DEF_CILKPLUS_BUILTIN (BUILT_IN_CILKPLUS_SEC_IMPLICIT_INDEX,
|
||||
"__sec_implicit_index", BT_FN_INT_INT, ATTR_NULL)
|
||||
|
||||
/*
|
||||
Local variables:
|
||||
mode:c
|
||||
End:
|
||||
*/
|
|
@ -82,6 +82,7 @@ extensions, accepted by GCC in C90 mode and in C++.
|
|||
* x86 specific memory model extensions for transactional memory:: x86 memory models.
|
||||
* Object Size Checking:: Built-in functions for limited buffer overflow
|
||||
checking.
|
||||
* Cilk Plus Builtins:: Built-in functions for the Cilk Plus language extension.
|
||||
* Other Builtins:: Other built-in functions.
|
||||
* Target Builtins:: Built-in functions specific to particular targets.
|
||||
* Target Format Checks:: Format checks specific to particular targets.
|
||||
|
@ -8788,6 +8789,32 @@ Similar to @code{__builtin_bswap32}, except the argument and return types
|
|||
are 64 bit.
|
||||
@end deftypefn
|
||||
|
||||
@node Cilk Plus Builtins
|
||||
@section Cilk Plus C/C++ language extension Built-in Functions.
|
||||
|
||||
GCC provides support for the following built-in reduction funtions if Cilk Plus
|
||||
is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
|
||||
|
||||
@itemize @bullet
|
||||
@item __sec_implicit_index
|
||||
@item __sec_reduce
|
||||
@item __sec_reduce_add
|
||||
@item __sec_reduce_all_nonzero
|
||||
@item __sec_reduce_all_zero
|
||||
@item __sec_reduce_any_nonzero
|
||||
@item __sec_reduce_any_zero
|
||||
@item __sec_reduce_max
|
||||
@item __sec_reduce_min
|
||||
@item __sec_reduce_max_ind
|
||||
@item __sec_reduce_min_ind
|
||||
@item __sec_reduce_mul
|
||||
@item __sec_reduce_mutating
|
||||
@end itemize
|
||||
|
||||
Further details and examples about these built-in functions are described
|
||||
in the Cilk Plus language manual which can be found at
|
||||
@uref{http://www.cilkplus.org}.
|
||||
|
||||
@node Target Builtins
|
||||
@section Built-in Functions Specific to Particular Target Machines
|
||||
|
||||
|
|
|
@ -1799,6 +1799,17 @@ Program Interface v3.0 @w{@uref{http://www.openmp.org/}}. This option
|
|||
implies @option{-pthread}, and thus is only supported on targets that
|
||||
have support for @option{-pthread}.
|
||||
|
||||
@item -fcilkplus
|
||||
@opindex fcilkplus
|
||||
@cindex Enable Cilk Plus
|
||||
Enable the usage of Cilk Language extension features for C/C++. When the flag
|
||||
@option{-fcilkplus} is specified, all the Cilk Plus components are converted
|
||||
to the appropriate C/C++ code. The present implementation follows ABI version
|
||||
0.9. There are four major parts to Cilk Plus language
|
||||
extension: Array Notations, Cilk Keywords, SIMD annotations and elemental
|
||||
functions. Detailed information about Cilk Plus can be found at
|
||||
@w{@uref{http://www.cilkplus.org}}.
|
||||
|
||||
@item -fgnu-tm
|
||||
@opindex fgnu-tm
|
||||
When the option @option{-fgnu-tm} is specified, the compiler
|
||||
|
|
|
@ -17,6 +17,7 @@ where near complete.
|
|||
|
||||
@menu
|
||||
* Parsing pass:: The language front end turns text into bits.
|
||||
* Cilk Plus Transformation:: Transform Cilk Plus Code to equivalent C/C++.
|
||||
* Gimplification pass:: The bits are turned into something we can optimize.
|
||||
* Pass manager:: Sequencing the optimization passes.
|
||||
* Tree SSA passes:: Optimizations on a high-level representation.
|
||||
|
@ -101,6 +102,36 @@ that is more descriptive than "rest_of".
|
|||
The middle-end will, at its option, emit the function and data
|
||||
definitions immediately or queue them for later processing.
|
||||
|
||||
@node Cilk Plus Transformation
|
||||
@section Cilk Plus Transformation
|
||||
@cindex CILK_PLUS
|
||||
|
||||
If Cilk Plus generation (flag @option{-fcilkplus}) is enabled, all the Cilk
|
||||
Plus code is transformed into equivalent C and C++ functions. Majority of this
|
||||
transformation occurs toward the end of the parsing and right before the
|
||||
gimplification pass.
|
||||
|
||||
These are the major components to the Cilk Plus language extension:
|
||||
@itemize @bullet
|
||||
@item Array Notations:
|
||||
During parsing phase, all the array notation specific information is stored in
|
||||
@code{ARRAY_NOTATION_REF} tree using the function
|
||||
@code{c_parser_array_notation}. During the end of parsing, we check the entire
|
||||
function to see if there are any array notation specific code (using the
|
||||
function @code{contains_array_notation_expr}). If this function returns
|
||||
true, then we expand them using either @code{expand_array_notation_exprs} or
|
||||
@code{build_array_notation_expr}. For the cases where array notations are
|
||||
inside conditions, they are transformed using the function
|
||||
@code{fix_conditional_array_notations}. The C language-specific routines are
|
||||
located in @file{c/c-array-notation.c} and the equivalent C++ routines are in
|
||||
file @file{cp/cp-array-notation.c}. Common routines such as functions to
|
||||
initialize builtin functions are stored in @file{array-notation-common.c}.
|
||||
@end itemize
|
||||
|
||||
Detailed information about Cilk Plus and language specification is provided in
|
||||
@w{@uref{http://www.cilkplus.org/}}. It is worth mentioning that the current
|
||||
implementation follows ABI 0.9.
|
||||
|
||||
@node Gimplification pass
|
||||
@section Gimplification pass
|
||||
|
||||
|
|
|
@ -1,3 +1,45 @@
|
|||
2013-05-28 Balaji V. Iyer <balaji.v.iyer@intel.com>
|
||||
|
||||
* c-c++-common/cilk-plus/AN/array_test1.c: New test.
|
||||
* c-c++-common/cilk-plus/AN/array_test2.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/array_test_ND.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/builtin_func_double.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/builtin_func_double2.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/gather-scatter-errors.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/if_test.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/sec_implicit_ex.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/decl-ptr-colon.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/dimensionless-arrays.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/fn_ptr.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/fp_triplet_values.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/gather-scatter.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/misc.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/parser_errors.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/parser_errors2.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/parser_errors3.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/parser_errors4.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/rank_mismatch.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/rank_mismatch2.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/rank_mismatch3.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/sec_implicit.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/sec_implicit2.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/sec_reduce_max_min_ind.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/tst_lngth.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/vla.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/an-if.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/builtin_fn_custom.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/builtin_fn_mutating.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/comma_exp.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/conditional.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/exec-once.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/exec-once2.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/gather_scatter.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/n-ptr-test.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/side-effects-1.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/test_builtin_return.c: Likewise.
|
||||
* c-c++-common/cilk-plus/AN/test_sec_limits.c: Likewise.
|
||||
* gcc.dg/cilk-plus/cilk-plus.exp: New script.
|
||||
|
||||
2013-05-28 Tobias Burnus <burnus@net-b.de>
|
||||
|
||||
PR fortran/37336
|
||||
|
|
48
gcc/testsuite/c-c++-common/cilk-plus/AN/an-if.c
Normal file
48
gcc/testsuite/c-c++-common/cilk-plus/AN/an-if.c
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* { dg-do run } */
|
||||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
#if HAVE_IO
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#include <assert.h>
|
||||
|
||||
const int n = 8;
|
||||
|
||||
float x[8], y[8], z[8];
|
||||
|
||||
int main() {
|
||||
int i = 0;
|
||||
float x_sum =0;
|
||||
for(i=1; i<=5; i+=4 ) {
|
||||
x[0:n] = 3;
|
||||
y[0:n] = i;
|
||||
z[0:n] = 0;
|
||||
#if HAVE_IO
|
||||
printf("x\ty\tz\n");
|
||||
for( size_t k=0; k<n; ++k ) {
|
||||
printf("%g\t%g\t%g\n",x[k],y[k],z[k]);
|
||||
}
|
||||
x_sum = __sec_reduce_add (x[0:n]);
|
||||
printf("sec_reduce_add (x[0:n]) = %6.3f\n", x_sum);
|
||||
#endif
|
||||
assert( __sec_reduce_add(x[0:n])==3*n );
|
||||
assert( __sec_reduce_add(y[0:n])==i*n );
|
||||
assert( __sec_reduce_add(z[0:n])==0 );
|
||||
|
||||
if (x[0:n] >= y[0:n]) {
|
||||
z[0:n] = x[0:n] - y[0:n];
|
||||
} else {
|
||||
z[0:n] = x[0:n] + y[0:n];
|
||||
}
|
||||
#if HAVE_IO
|
||||
printf("x\ty\tz\n");
|
||||
for( size_t k=0; k<n; ++k ) {
|
||||
printf("%g\t%g\t%g\n",x[k],y[k],z[k]);
|
||||
}
|
||||
#endif
|
||||
assert( __sec_reduce_add(x[0:n])==3*n );
|
||||
assert( __sec_reduce_add(y[0:n])==i*n );
|
||||
assert( __sec_reduce_add(z[0:n])==(3>=i?3-i:3+i)*n );
|
||||
}
|
||||
return 0;
|
||||
}
|
90
gcc/testsuite/c-c++-common/cilk-plus/AN/array_test1.c
Normal file
90
gcc/testsuite/c-c++-common/cilk-plus/AN/array_test1.c
Normal file
|
@ -0,0 +1,90 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
int main2 (int argc, char **argv);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int x = 0;
|
||||
if (argc == 1)
|
||||
{
|
||||
const char *array[] = {"a.out", "5"};
|
||||
x = main2 (2, (char **)array);
|
||||
}
|
||||
else
|
||||
x = main2 (argc, argv);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
int main2 (int argc, char **argv)
|
||||
{
|
||||
int array[10], ii = 0, x = 2, z= 0 , y = 0 ;
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
array[ii] = 10;
|
||||
|
||||
array[0:10:1] = 15;
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
if (array[ii] != 15)
|
||||
return 5;
|
||||
array[0:5:2] = 20;
|
||||
|
||||
for (ii = 0; ii < 10; ii += 2)
|
||||
if (array[ii] != 20)
|
||||
return 4;
|
||||
|
||||
|
||||
x = atoi(argv[1]);
|
||||
z = (10-atoi(argv[1]))/atoi(argv[1]);
|
||||
|
||||
array[x:5:z] = 50;
|
||||
|
||||
for (ii = x; ii < 10; ii += z)
|
||||
if (array[ii] != 50)
|
||||
return 3;
|
||||
|
||||
x = atoi(argv[1]);
|
||||
z = (10-atoi(argv[1]))/atoi(argv[1]);
|
||||
y = 10-atoi(argv[1]);
|
||||
|
||||
array[x:y:z] = 505;
|
||||
for (ii = x; ii < 10; ii += z)
|
||||
if (array[ii] != 505)
|
||||
return 2;
|
||||
|
||||
x = atoi(argv[1]);
|
||||
z = (10-atoi(argv[1]))/atoi(argv[1]);
|
||||
y = 10-atoi(argv[1]);
|
||||
|
||||
array[x:y:((10-atoi(argv[1]))/atoi(argv[1]))] = 25;
|
||||
|
||||
for (ii = x; ii < 10; ii += z)
|
||||
if (array[ii] != 25)
|
||||
return 1;
|
||||
x = atoi(argv[1]);
|
||||
z = (10-atoi(argv[1]))/atoi(argv[1]);
|
||||
y = 10-atoi(argv[1]);
|
||||
|
||||
array[atoi(argv[1]):(10-atoi(argv[1])):((10-atoi(argv[1]))/atoi(argv[1]))] =
|
||||
1400;
|
||||
for (ii = x; ii < 10; ii += z)
|
||||
if (array[ii] != 1400)
|
||||
return 1;
|
||||
|
||||
|
||||
array[atoi("5"):5:1] = 5555;
|
||||
|
||||
for (ii = atoi ("5"); ii < 10; ii++)
|
||||
if (array[ii] != 5555)
|
||||
return 2;
|
||||
|
||||
|
||||
array[atoi("5"):atoi("5"):atoi("1")] = 9999;
|
||||
for (ii = atoi ("5"); ii < (atoi ("5") + atoi ("5")); ii += atoi ("1"))
|
||||
if (array[ii] != 9999)
|
||||
return 3;
|
||||
return 0;
|
||||
}
|
134
gcc/testsuite/c-c++-common/cilk-plus/AN/array_test2.c
Normal file
134
gcc/testsuite/c-c++-common/cilk-plus/AN/array_test2.c
Normal file
|
@ -0,0 +1,134 @@
|
|||
/* { dg-do run } */
|
||||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
#include <stdlib.h>
|
||||
int main2(int argc, char **argv);
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int x = 0;
|
||||
if (argc == 1)
|
||||
{
|
||||
const char *array[] = {"a.out", "5"};
|
||||
x = main2 (2, (char **)array);
|
||||
}
|
||||
else
|
||||
x = main2 (argc, argv);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
int main2(int argc, char **argv)
|
||||
{
|
||||
int array[10], array2[10], ii = 0, x = 2, z= 0 , y = 0 ;
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
{
|
||||
array[ii] = 10;
|
||||
array2[ii] = 5000000;
|
||||
}
|
||||
|
||||
array2[0:10:1] = array[0:10:1];
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
if (array2[ii] != array[ii])
|
||||
return 1;
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
{
|
||||
array[ii] = 10;
|
||||
array2[ii] = 5000000;
|
||||
}
|
||||
|
||||
array2[0:5:2] = array[0:5:2];
|
||||
|
||||
for (ii = 0; ii < 10; ii += 2)
|
||||
if (array[ii] != array2[ii])
|
||||
return 2;
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
{
|
||||
array[ii] = 10;
|
||||
array2[ii] = 5000000;
|
||||
}
|
||||
x = atoi(argv[1]);
|
||||
z = (10-atoi(argv[1]))/atoi(argv[1]);
|
||||
|
||||
array2[x:5:z] = array[x:5:z];
|
||||
|
||||
for (ii = x; ii < 5; ii += z)
|
||||
if (array2[ii] != array[ii])
|
||||
return 3;
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
{
|
||||
array[ii] = 500;
|
||||
array2[ii] = 1000000;
|
||||
}
|
||||
x = atoi(argv[1]);
|
||||
z = (10-atoi(argv[1]))/atoi(argv[1]);
|
||||
y = 10-atoi(argv[1]);
|
||||
|
||||
array2[x:y:z] = array[x:y:z];
|
||||
for (ii = x; ii < 10; ii = ii + z)
|
||||
if (array2[ii] != array[ii])
|
||||
return 4;
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
{
|
||||
array[ii] = 500;
|
||||
array2[ii] = 1000000;
|
||||
}
|
||||
x = atoi(argv[1]);
|
||||
z = (10-atoi(argv[1]))/atoi(argv[1]);
|
||||
y = 10-atoi(argv[1]);
|
||||
|
||||
array[x:y:((10-atoi(argv[1]))/atoi(argv[1]))] =
|
||||
array2[x:y:((10-atoi(argv[1]))/atoi(argv[1]))];
|
||||
|
||||
for (ii = x; ii < 10; ii += z)
|
||||
if (array[ii] != array2[ii])
|
||||
return 5;
|
||||
|
||||
|
||||
x = atoi(argv[1]);
|
||||
z = (10-atoi(argv[1]))/atoi(argv[1]);
|
||||
y = 10-atoi(argv[1]);
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
{
|
||||
array[ii] = 500;
|
||||
array2[ii] = 1000000;
|
||||
}
|
||||
|
||||
array[atoi(argv[1]):(10-atoi(argv[1])):((10-atoi(argv[1]))/atoi(argv[1]))] =
|
||||
array2[atoi(argv[1]):(10-atoi(argv[1])):((10-atoi(argv[1]))/atoi(argv[1]))];
|
||||
for (ii = x; ii < 10; ii += z)
|
||||
if (array[ii] != array2[ii])
|
||||
return 6;
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
{
|
||||
array[ii] = 4;
|
||||
array2[ii] = 2;
|
||||
}
|
||||
|
||||
array[atoi("5"):5:1] = array2[atoi("5"):5:1];
|
||||
|
||||
for (ii = atoi ("5"); ii < 10; ii++)
|
||||
if (array[ii] != array2[ii])
|
||||
return (7);
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
{
|
||||
array[ii] = 5;
|
||||
array2[ii] = 1;
|
||||
}
|
||||
array[atoi("5"):atoi("5"):atoi("1")] = array2[atoi("5"):atoi("5"):atoi("1")];
|
||||
|
||||
for (ii = 5; ii < 10; ii++)
|
||||
if (array2[ii] != array[ii])
|
||||
return 8;
|
||||
|
||||
return 0;
|
||||
}
|
109
gcc/testsuite/c-c++-common/cilk-plus/AN/array_test_ND.c
Normal file
109
gcc/testsuite/c-c++-common/cilk-plus/AN/array_test_ND.c
Normal file
|
@ -0,0 +1,109 @@
|
|||
/* { dg-do run } */
|
||||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
#include <stdlib.h>
|
||||
int main2(int argc, char **argv);
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int x = 0;
|
||||
if (argc == 1)
|
||||
{
|
||||
const char *array[] = {"a.out", "10", "15"};
|
||||
x = main2 (3, (char **)array);
|
||||
}
|
||||
else if (argc == 3)
|
||||
x = main2 (argc, argv);
|
||||
else
|
||||
return 1;
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
int main2(int argc, char **argv)
|
||||
{
|
||||
int array[10][15], ii = 0, jj = 0,x = 0, z= 1 , y = 10 ;
|
||||
int array_2[10][15];
|
||||
|
||||
|
||||
for (ii = 0; ii < 10; ii++) {
|
||||
for (jj = 0; jj< 15; jj++) {
|
||||
array[ii][jj] = ii+jj;
|
||||
array_2[ii][jj] = 0;
|
||||
}
|
||||
}
|
||||
array_2[0:5:2][0:5:3] = array[0:5:2][0:5:3] + 1 + 5 + array[0][5] + x;
|
||||
|
||||
for (ii = 0; ii < 10; ii += 2)
|
||||
{
|
||||
for (jj = 0; jj < 15; jj += 3)
|
||||
{
|
||||
if (array_2[ii][jj] != array[ii][jj] + 1 + 5 + array[0][5] + x)
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (ii = 0; ii < 10; ii++) {
|
||||
for (jj = 0; jj< 15; jj++) {
|
||||
array[ii][jj] = ii+jj;
|
||||
array_2[ii][jj] = 0;
|
||||
}
|
||||
}
|
||||
x = atoi(argv[1]);
|
||||
y = atoi(argv[2]);
|
||||
array_2[0:x:1][0:y:1] = array[0:x:1][0:y:1] + x + y + array[0:x:1][0:y:1];
|
||||
|
||||
for (ii = 0; ii < x; ii++)
|
||||
{
|
||||
for (jj = 0; jj < y; jj++)
|
||||
{
|
||||
if (array_2[ii][jj] != array[ii][jj] + x + y + array[ii][jj])
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
for (ii = 0; ii < 10; ii++) {
|
||||
for (jj = 0; jj< 15; jj++) {
|
||||
array[ii][jj] = ii+jj;
|
||||
array_2[ii][jj] = 0;
|
||||
}
|
||||
}
|
||||
x = atoi(argv[1]);
|
||||
y = atoi(argv[2]);
|
||||
z = (20- atoi (argv[1]))/atoi(argv[1]);
|
||||
/* (20-10)/10 evaluates to 1 all the time :-). */
|
||||
array_2[0:x:z][0:y:z] = array[0:x:z][0:y:z] + array[0:x:z][0:y:z] + y + z;
|
||||
|
||||
for (ii = 0; ii < x; ii += z)
|
||||
{
|
||||
for (jj = 0; jj < y; jj += z)
|
||||
{
|
||||
if (array_2[ii][jj] != array[ii][jj] + array[ii][jj] + y + z)
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (ii = 0; ii < 10; ii++) {
|
||||
for (jj = 0; jj< 15; jj++) {
|
||||
array[ii][jj] = ii+jj;
|
||||
array_2[ii][jj] = 0;
|
||||
}
|
||||
}
|
||||
x = argc-3;
|
||||
y = 20-atoi(argv[1]);
|
||||
z = (20- atoi (argv[1]))/atoi(argv[1]);
|
||||
/* (20-10)/10 evaluates to 1 all the time :-). */
|
||||
array_2[(argc-3):(20-atoi(argv[1])):(20-atoi(argv[1]))/atoi(argv[1])][(argc-3):(30-atoi(argv[2])): ((30-atoi(argv[2]))/atoi(argv[2]))] = array[(argc-3):20-atoi(argv[1]):(20-atoi(argv[1]))/atoi(argv[1])][(argc-3):(30-atoi(argv[2])): (30-atoi(argv[2]))/atoi(argv[2])] + array[(argc-3):20-atoi(argv[1]):(20-atoi(argv[1]))/atoi(argv[1])][(argc-3):(30-atoi(argv[2])): (30-atoi(argv[2]))/atoi(argv[2])] * array[(argc-3):20-atoi(argv[1]):(20-atoi(argv[1]))/atoi(argv[1])][(argc-3):(30-atoi(argv[2])): (30-atoi(argv[2]))/atoi(argv[2])];
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
{
|
||||
for (jj = 0; jj < 15; jj++)
|
||||
{
|
||||
if (array_2[ii][jj] != array[ii][jj] + array[ii][jj] * array[ii][jj])
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
68
gcc/testsuite/c-c++-common/cilk-plus/AN/builtin_fn_custom.c
Normal file
68
gcc/testsuite/c-c++-common/cilk-plus/AN/builtin_fn_custom.c
Normal file
|
@ -0,0 +1,68 @@
|
|||
/* { dg-do run } */
|
||||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
#if HAVE_IO
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
/* #include <stdlib.h> */
|
||||
|
||||
double my_func (double x, double y)
|
||||
{
|
||||
if (x > y)
|
||||
return x;
|
||||
else
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
/* char __sec_reduce_add (int *); */
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ii,array[10], y = 0, y_int = 0, array2[10];
|
||||
double x, yy, array3[10], array4[10];
|
||||
double max_value = 0.000, min_value = 0.000, add_value, mul_value = 1.00;
|
||||
int max_index = 0, min_index = 0;
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
{
|
||||
array[ii] = 1+ii;
|
||||
array2[ii]= 2;
|
||||
}
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
{
|
||||
if (ii%2 && ii)
|
||||
array3[ii] = (double)(1.0000/(double)ii);
|
||||
else
|
||||
array3[ii] = (double) ii + 0.10;
|
||||
array4[ii] = (double) (1.00000/ (double)(ii+1));
|
||||
}
|
||||
|
||||
/* array[:] = 5; */
|
||||
x = __sec_reduce (0, array3[:] * array4[:], my_func);
|
||||
y = __sec_reduce_max_ind ( array3[:] * array4[:]);
|
||||
|
||||
/* Initialize it to the first variable. */
|
||||
max_value = array3[0] * array4[0];
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
if (array3[ii] * array4[ii] > max_value) {
|
||||
max_value = array3[ii] * array4[ii];
|
||||
max_index = ii;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if HAVE_IO
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
printf("%5.3f ", array3[ii] * array4[ii]);
|
||||
printf("\n");
|
||||
printf("Max = %5.3f\t Max Index = %2d\n", x, y);
|
||||
#endif
|
||||
|
||||
if (x != max_value)
|
||||
return 1;
|
||||
|
||||
if (y != max_index)
|
||||
return 2;
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
/* { dg-do run } */
|
||||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
#if HAVE_IO
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
/* #include <stdlib.h> */
|
||||
|
||||
void my_func (double *x, double y)
|
||||
{
|
||||
if (*x < y)
|
||||
*x = y;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ii,array[10], y = 0, y_int = 0, array2[10];
|
||||
double x = 0.000, yy, array3[10], array4[10];
|
||||
double max_value = 0.000, min_value = 0.000, add_value, mul_value = 1.00;
|
||||
int max_index = 0, min_index = 0;
|
||||
#if 1
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
{
|
||||
array[ii] = 1+ii;
|
||||
array2[ii]= 2;
|
||||
}
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
{
|
||||
if (ii%2 && ii)
|
||||
array3[ii] = (double)(1.0000/(double)ii);
|
||||
else
|
||||
array3[ii] = (double) ii + 0.10;
|
||||
array4[ii] = (double) (1.00000/ (double)(ii+1));
|
||||
}
|
||||
#endif
|
||||
/* array[:] = 5; */
|
||||
__sec_reduce_mutating (&x, array3[:] * array4[:], my_func);
|
||||
#if 1
|
||||
y = __sec_reduce_max_ind ( array3[:] * array4[:]);
|
||||
|
||||
/* Initialize it to the first variable. */
|
||||
max_value = array3[0] * array4[0];
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
if (array3[ii] * array4[ii] > max_value) {
|
||||
max_value = array3[ii] * array4[ii];
|
||||
max_index = ii;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if HAVE_IO
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
printf("%5.3f ", array3[ii] * array4[ii]);
|
||||
printf("\n");
|
||||
printf("Max = %5.3f\t Max Index = %2d\n", x, y);
|
||||
printf("Max = %5.3f\t Max Index = %2d\n", max_value, max_index);
|
||||
#endif
|
||||
|
||||
if (x != max_value)
|
||||
return 1;
|
||||
|
||||
if (y != max_index)
|
||||
return 2;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
124
gcc/testsuite/c-c++-common/cilk-plus/AN/builtin_func_double.c
Normal file
124
gcc/testsuite/c-c++-common/cilk-plus/AN/builtin_func_double.c
Normal file
|
@ -0,0 +1,124 @@
|
|||
#if HAVE_IO
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
/* #include <stdlib.h> */
|
||||
|
||||
/* char __sec_reduce_add (int *); */
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ii,array[10], y = 0, y_int = 0, array2[10];
|
||||
double x, yy, array3[10], array4[10];
|
||||
double max_value = 0.000, min_value = 0.000, add_value, mul_value = 1.00;
|
||||
int max_index = 0, min_index = 0;
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
{
|
||||
array[ii] = 1+ii;
|
||||
array2[ii]= 2;
|
||||
}
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
{
|
||||
if (ii%2 && ii)
|
||||
array3[ii] = (double)(1.0000/(double)ii);
|
||||
else
|
||||
array3[ii] = (double) ii + 0.10;
|
||||
array4[ii] = (double) (1.00000/ (double)(ii+1));
|
||||
}
|
||||
|
||||
/* array[:] = 5; */
|
||||
x = __sec_reduce_max (array3[:] * array4[:]);
|
||||
y = __sec_reduce_max_ind ( array3[:] * array4[:]);
|
||||
|
||||
/* Initialize it to the first variable. */
|
||||
max_value = array3[0] * array4[0];
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
if (array3[ii] * array4[ii] > max_value) {
|
||||
max_value = array3[ii] * array4[ii];
|
||||
max_index = ii;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if HAVE_IO
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
printf("%5.3f ", array3[ii] * array4[ii]);
|
||||
printf("\n");
|
||||
printf("Max = %5.3f\t Max Index = %2d\n", x, y);
|
||||
#endif
|
||||
|
||||
if (x != max_value)
|
||||
return 1;
|
||||
|
||||
if (y != max_index)
|
||||
return 2;
|
||||
|
||||
x = __sec_reduce_min (array3[:] * array4[:]);
|
||||
y = __sec_reduce_min_ind ( array3[:] * array4[:]);
|
||||
#if HAVE_IO
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
printf("%5.3f ", array3[ii] * array4[ii]);
|
||||
printf("\n");
|
||||
printf("Min = %5.3f\t Min Index = %2d\n", x, y);
|
||||
#endif
|
||||
|
||||
/* Initialize it to the first variable. */
|
||||
min_value = array3[0] * array4[0];
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
if (array3[ii] * array4[ii] < min_value) {
|
||||
min_value = array3[ii] * array4[ii];
|
||||
min_index = ii;
|
||||
}
|
||||
|
||||
if (x != min_value)
|
||||
return 3;
|
||||
if (y != min_index)
|
||||
return 4;
|
||||
|
||||
x = __sec_reduce_add (array3[:] * array4[:]);
|
||||
yy = __sec_reduce_mul ( array3[:] * array4[:]);
|
||||
#if HAVE_IO
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
printf("%5.3f ", array3[ii] * array4[ii]);
|
||||
printf("\n");
|
||||
printf("Add = %5.3f\t Mul = %f\n", x, yy);
|
||||
#endif
|
||||
|
||||
/* Initialize it to the first variable. */
|
||||
add_value = 0.0000;
|
||||
mul_value = 1.0000;
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
{
|
||||
add_value += (array3[ii] * array4[ii]);
|
||||
mul_value *= (array3[ii] * array4[ii]);
|
||||
}
|
||||
|
||||
if (x != add_value)
|
||||
return 5;
|
||||
if (yy != mul_value)
|
||||
return 6;
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
{
|
||||
if (ii%2 && ii)
|
||||
array3[ii] = (double)(1.0000/(double)ii);
|
||||
else
|
||||
array3[ii] = (double) ii + 0.00;
|
||||
array4[ii] = (double) (1.00000/ (double)(ii+1));
|
||||
}
|
||||
y_int = __sec_reduce_any_zero (array3[:] * array4[:]);
|
||||
y = __sec_reduce_all_zero ( array3[:] * array4[:]);
|
||||
|
||||
if (y_int != 1)
|
||||
return 7;
|
||||
|
||||
if (y != 0)
|
||||
return 8;
|
||||
|
||||
#if HAVE_IO
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
printf("%5.3f ", array3[ii] * array4[ii]);
|
||||
printf("\n");
|
||||
printf("Any Zeros = %d\t All Zeros = %d\n", y_int, y);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/* { dg-do run } */
|
||||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
#if HAVE_IO
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ii,array[10], y = 0, y_int = 0, array2[10], y_int2=0, y2=0;
|
||||
double x, yy, array3[10], array4[10];
|
||||
int all_zero, all_nonzero, any_zero, any_nonzero;
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
{
|
||||
array[ii] = 0;
|
||||
array2[ii] = 5;
|
||||
if (ii%2 && ii)
|
||||
array3[ii] = (double)(1.0000/(double)ii);
|
||||
else
|
||||
array3[ii] = (double) ii + 0.00;
|
||||
array4[ii] = (double) (1.00000/ (double)(ii+1));
|
||||
}
|
||||
y_int = __sec_reduce_any_nonzero (array3[:] + array[4]);
|
||||
y_int2 = __sec_reduce_any_zero (array3[:] + array[4]);
|
||||
y = __sec_reduce_all_nonzero ((array3[:] + array4[:]) * (argc-1));
|
||||
y2 = __sec_reduce_all_zero ((array3[:] + array4[:]) * (argc-1));
|
||||
|
||||
any_zero = 0;
|
||||
any_nonzero = 0;
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
{
|
||||
if ((array3[ii] + array[4]) == 0)
|
||||
any_zero = 1;
|
||||
else
|
||||
any_nonzero = 1;
|
||||
}
|
||||
|
||||
if (any_nonzero != y_int)
|
||||
return 1;
|
||||
if (any_zero != y_int2)
|
||||
return 2;
|
||||
|
||||
|
||||
all_zero = 0;
|
||||
all_nonzero = 0;
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
{
|
||||
if (((array3[ii] + array4[ii]) * (argc-1)) == 0)
|
||||
all_zero = 1;
|
||||
else
|
||||
all_nonzero = 1;
|
||||
}
|
||||
|
||||
if (y != all_nonzero)
|
||||
return 3;
|
||||
if (all_zero != y2)
|
||||
return 4;
|
||||
|
||||
|
||||
#if HAVE_IO
|
||||
for (ii = 0; ii < 10; ii++) {
|
||||
printf("%5.3f ", array3[ii] +array4[ii]);
|
||||
}
|
||||
printf("\n");
|
||||
for (ii = 0; ii < 10; ii++) {
|
||||
printf("%5.3f ", (array3[ii] + array4[ii]) * (argc-1));
|
||||
}
|
||||
printf("\n");
|
||||
printf("Any Non-zeros (1st line) = %d\t All non-zeros (1st line) = %d\n",
|
||||
y_int, y);
|
||||
printf("Any zeros (2nd line) = %d\t All zeros (2nd line) = %d\n", y_int2, y2);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
60
gcc/testsuite/c-c++-common/cilk-plus/AN/comma_exp.c
Normal file
60
gcc/testsuite/c-c++-common/cilk-plus/AN/comma_exp.c
Normal file
|
@ -0,0 +1,60 @@
|
|||
/* { dg-do run } */
|
||||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
int main2 (int argc, char **argv);
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int x = 0;
|
||||
if (argc == 1)
|
||||
{
|
||||
const char *array[] = {"a.out", "5"};
|
||||
x = main2 (2, (char **)array);
|
||||
}
|
||||
else
|
||||
x = main2 (argc, argv);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
int main2 (int argc, char **argv)
|
||||
{
|
||||
int array[10], array2[10], ii = 0, x = 2, z= 0 , y = 0 ;
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
array[ii] = 10;
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
array2[ii] = 1;
|
||||
|
||||
array[0:10:1] = (array[:], 15);
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
if (array[ii] != 15)
|
||||
return 1;
|
||||
array[0:5:2] = (argc+2, 20);
|
||||
|
||||
for (ii = 0; ii < 10; ii += 2)
|
||||
if (array[ii] != 20)
|
||||
return 2;
|
||||
|
||||
|
||||
x = atoi(argv[1]);
|
||||
z = (10-atoi(argv[1]))/atoi(argv[1]);
|
||||
|
||||
array[x:5:z] = 50;
|
||||
|
||||
array[:] = (atoi(argv[1]), (array2[0:10]+5));
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
if (array[ii] != 6)
|
||||
return (3);
|
||||
|
||||
array[:] = (atoi(argv[1]), (array2[0:10]+array2[0:10]));
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
if (array[ii] != 2)
|
||||
return 4;
|
||||
|
||||
return 0;
|
||||
}
|
42
gcc/testsuite/c-c++-common/cilk-plus/AN/conditional.c
Normal file
42
gcc/testsuite/c-c++-common/cilk-plus/AN/conditional.c
Normal file
|
@ -0,0 +1,42 @@
|
|||
/* { dg-do run } */
|
||||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
#include <stdlib.h>
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
short array[1000], array2[1000], *array3, cond[1000], ii = 0;
|
||||
|
||||
for (ii = 0; ii < 1000; ii++) {
|
||||
cond[ii] = 1;
|
||||
array[ii] = 1000;
|
||||
array2[ii] = 2000;
|
||||
}
|
||||
array2[:] = cond[:] ? array[:] : array2[:];
|
||||
|
||||
for (ii = 0; ii < 1000; ii++) {
|
||||
if (array2[ii] != 1000)
|
||||
return 1;
|
||||
}
|
||||
|
||||
array2[0:500:2] = cond[0:500] ? array[0:500:1] : array2[0:500:2];
|
||||
|
||||
for (ii = 0; ii < 1000; ii++) {
|
||||
if (array2[ii] != 1000)
|
||||
return 2;
|
||||
}
|
||||
|
||||
for (ii = 0; ii < 1000; ii++) {
|
||||
cond[ii] = ii % 2; /* This should give 0, 1, 0, 1, 0, 1, 0,... */
|
||||
array2[ii] = 5;
|
||||
array[ii] = 3;
|
||||
}
|
||||
array3 = (short *) malloc (sizeof (short) * 1000);
|
||||
array3[0:1000:argc] = cond[:] ? array[0:(argc * 1000)] : array2[argc-1:1000];
|
||||
|
||||
for (ii = 0; ii < 1000; ii++) {
|
||||
if ((cond[ii] == 0 && array3[ii] != 5)
|
||||
|| (cond[ii] == 1 && array3[ii] != 3))
|
||||
return 3;
|
||||
}
|
||||
return 0;
|
||||
}
|
18
gcc/testsuite/c-c++-common/cilk-plus/AN/decl-ptr-colon.c
Normal file
18
gcc/testsuite/c-c++-common/cilk-plus/AN/decl-ptr-colon.c
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
int main(void)
|
||||
{
|
||||
extern int func(int);
|
||||
int array3[:], x, q; /* { dg-error "array notations cannot be used in declaration" } */
|
||||
int array3[1:2:x]; /* { dg-error "array notations cannot be used in declaration" } */
|
||||
extern char array3[1:func(x)]; /* { dg-error "array notations cannot be used in declaration" } */
|
||||
int *a, ***b;
|
||||
extern char *c;
|
||||
int array2[10];
|
||||
|
||||
a[:] = 5; /* { dg-error "start-index and length fields necessary for using array notations in pointers" } */
|
||||
c[1:2] = 3; /* This is OK. */
|
||||
(array2)[:] = 5; /* This is OK. */
|
||||
b[1:2][1:func(x)][:] = 3; /* { dg-error "start-index and length fields necessary for using array notations in pointers" } */
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
extern int a[];
|
||||
extern int *b;
|
||||
|
||||
void foo()
|
||||
{
|
||||
a[:] = 5; // { dg-error "start-index and length fields necessary for using array notations in dimensionless arrays" }
|
||||
b[:] = 5; // { dg-error "start-index and length fields necessary for using array notations in pointers" }
|
||||
}
|
44
gcc/testsuite/c-c++-common/cilk-plus/AN/exec-once.c
Normal file
44
gcc/testsuite/c-c++-common/cilk-plus/AN/exec-once.c
Normal file
|
@ -0,0 +1,44 @@
|
|||
/* { dg-do run } */
|
||||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
#define NUMBER 1000
|
||||
|
||||
#if HAVE_IO
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
int func (int *x)
|
||||
{
|
||||
int q = *x;
|
||||
q++;
|
||||
*x = q;
|
||||
#if HAVE_IO
|
||||
printf("%d\n", (q));
|
||||
#endif
|
||||
return *x;
|
||||
}
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
char array[NUMBER], array2[NUMBER];
|
||||
int ii, d = 2;
|
||||
#if 1
|
||||
for (ii = 0; ii < NUMBER; ii++) {
|
||||
array[ii] = 5;
|
||||
array2[ii]= 2;
|
||||
}
|
||||
#endif
|
||||
d = func (&d); /* d = 1 */
|
||||
array2[:] = d * array[:] + (char) func (&d); /* 3 * 5 + 4 */
|
||||
#if HAVE_IO
|
||||
for (ii = 0; ii < NUMBER; ii++)
|
||||
printf("array2[%d] = %d\n", ii, array2[ii]);
|
||||
#endif
|
||||
for (ii = 0; ii < NUMBER; ii++)
|
||||
if (array2[ii] != (3 * 5 + 4))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
85
gcc/testsuite/c-c++-common/cilk-plus/AN/exec-once2.c
Normal file
85
gcc/testsuite/c-c++-common/cilk-plus/AN/exec-once2.c
Normal file
|
@ -0,0 +1,85 @@
|
|||
/* { dg-do run } */
|
||||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
#ifdef HAVE_IO
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
|
||||
int func1(int x)
|
||||
{
|
||||
/* If x == 2 then it should return 0. */
|
||||
return (x - 2);
|
||||
}
|
||||
|
||||
int func2(int x)
|
||||
{
|
||||
/* If x == 2 then it should return 1000. */
|
||||
return (x * 500);
|
||||
}
|
||||
|
||||
int func3 (int x)
|
||||
{
|
||||
/* If x == 2 then it should return 1. */
|
||||
/* If x == 1 then it should return 0. */
|
||||
return (x-1);
|
||||
}
|
||||
|
||||
int func4(int x)
|
||||
{
|
||||
if (x > 0)
|
||||
return x;
|
||||
else
|
||||
return x--;
|
||||
}
|
||||
|
||||
|
||||
/* This program makes an assumption that argc == 1. */
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
|
||||
int array[2500];
|
||||
|
||||
/* This should set array[0->999] to 5. */
|
||||
array[argc-1:func2(++argc):1] = 5;
|
||||
array[1000:500:1] = 10; /* set all variables in array[1000-->1499] to 10. */
|
||||
array[1500:500:1] = 15; /* set all variables in array[1500-->1999] to 15. */
|
||||
array[2000:500:1] = 20; /* set all variables in array[2000-->2499] to 20. */
|
||||
array[2000:500:1] = 25; /* set all variables in array[2500-->2999] to 25. */
|
||||
array[2000:500:1] = 30; /* set all variables in array[3000-->3499] to 30. */
|
||||
|
||||
argc = func3 (argc); /* This will set argc back to 1. */
|
||||
#if HAVE_IO
|
||||
printf("argc = %d\n", argc);
|
||||
#endif
|
||||
/* If the parameters inside the function get evaluated only once, then this
|
||||
if statement must work fine, i.e. the triplet values will be 0, 1000, 1.
|
||||
|
||||
Otherwise, the program should crash or give some uneasy value. */
|
||||
|
||||
/* If done correctly, it should boil down to: array[0:1000:1]. */
|
||||
if (array[func3(argc):func2(++argc)] != 5) {
|
||||
#ifdef HAVE_IO
|
||||
printf ("Should not be there(1).\n");
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* If done correctly, it should boil down to: array[999:500:-1]. */
|
||||
if (func4(array[func2(argc)-1:func2(argc--):func1(argc)]) != 5) {
|
||||
#ifdef HAVE_IO
|
||||
printf ("Should not be there(2).\n");
|
||||
#endif
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* If done correctly, it should boil down to: array[1000:500:1]. */
|
||||
if (func4 (func4(array[func2(argc++):500: func1(argc--)])) != 5) {
|
||||
#ifdef HAVE_IO
|
||||
printf ("Should not be there(3).\n");
|
||||
#endif
|
||||
return 3;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
19
gcc/testsuite/c-c++-common/cilk-plus/AN/fn_ptr.c
Normal file
19
gcc/testsuite/c-c++-common/cilk-plus/AN/fn_ptr.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
typedef int (*foo)(int);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int array[10], array2[10][10];
|
||||
foo func_array[10];
|
||||
foo func_array2[10][10];
|
||||
foo ***func_array_ptr;
|
||||
|
||||
array[:] = func_array[:](10); /* { dg-error "array notations cannot be used with function pointer arrays" } */
|
||||
func_array[0:5](10); /* { dg-error "array notations cannot be used with function pointer arrays" } */
|
||||
func_array2[0:5][:](10); /* { dg-error "array notations cannot be used with function pointer arrays" } */
|
||||
array2[0:5][:] = func_array2[0:5][:](10); /* { dg-error "array notations cannot be used with function pointer arrays" } */
|
||||
func_array_ptr[0:5][0:4][0:argc:2](argc); /* { dg-error "array notations cannot be used with function pointer arrays" } */
|
||||
|
||||
return 0;
|
||||
}
|
43
gcc/testsuite/c-c++-common/cilk-plus/AN/fp_triplet_values.c
Normal file
43
gcc/testsuite/c-c++-common/cilk-plus/AN/fp_triplet_values.c
Normal file
|
@ -0,0 +1,43 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
float q;
|
||||
|
||||
int main2 (int argc, char **argv);
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
int x = 0;
|
||||
if (argc == 1)
|
||||
{
|
||||
const char *array[] = {"a.out", "5"};
|
||||
x = main2 (2, (char **)array);
|
||||
}
|
||||
else
|
||||
x = main2 (argc, argv);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
void func (int *x)
|
||||
{
|
||||
*x = 5;
|
||||
}
|
||||
|
||||
int main2 (int argc, char **argv)
|
||||
{
|
||||
int array[10], array2[10];
|
||||
array2[:] = array[1.5:2]; /* { dg-error "start-index of array notation triplet is not an integer" } */
|
||||
array2[:] = array[1:2.32333333333]; /* { dg-error "length of array notation triplet is not an integer" } */
|
||||
array2[1:2:1.5] = array[:]; /* { dg-error "stride of array notation triplet is not an integer" } */
|
||||
func (&array2[1:2.34:3]); /* { dg-error "length of array notation triplet is not an integer" } */
|
||||
array2[1.43:9]++; /* { dg-error "start-index of array notation triplet is not an integer" } */
|
||||
array2[1:9.3]++; /* { dg-error "length of array notation triplet is not an integer" } */
|
||||
array2[1:9:0.3]++; /* { dg-error "stride of array notation triplet is not an integer" } */
|
||||
|
||||
++array2[1:q:3]; /* { dg-error "length of array notation triplet is not an integer" } */
|
||||
array2[:] = array[q:1:3]; /* { dg-error "start-index of array notation triplet is not an integer" } */
|
||||
array2[:] = array[1:q:3]; /* { dg-error "length of array notation triplet is not an integer" } */
|
||||
array2[:] = array[1:3:q]; /* { dg-error "stride of array notation triplet is not an integer" } */
|
||||
func (&array2[1:q:3]); /* { dg-error "length of array notation triplet is not an integer" } */
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
extern int func (int);
|
||||
int array[10][10], array2[10];
|
||||
|
||||
array2[array[:][:]] = 5; /* { dg-error "rank of the array's index is greater than 1" } */
|
||||
|
||||
array2[array[:][:]] = 5; /* { dg-error "rank of the array's index is greater than 1" } */
|
||||
func (array2[array[:][:]]); /* { dg-error "rank of the array's index is greater than 1" } */
|
||||
func (array2[array[argc:func(5)][0:10:2]]); /* { dg-error "rank of the array's index is greater than 1" } */
|
||||
|
||||
array[array2[:]][array2[:]] = 5; /* This is OK. */
|
||||
array[array2[:]][array2[:]] = array2[array[:][:]]; /* { dg-error "rank of the array's index is greater than 1" } */
|
||||
array[array2[:]][array2[:]] = array2[array[0:10:1][:]]; /* { dg-error "rank of the array's index is greater than 1" } */
|
||||
array[array2[:]][array2[:]] = array2[array[:][argc:func (argc)]]; /* { dg-error "rank of the array's index is greater than 1" } */
|
||||
return 0;
|
||||
}
|
59
gcc/testsuite/c-c++-common/cilk-plus/AN/gather_scatter.c
Normal file
59
gcc/testsuite/c-c++-common/cilk-plus/AN/gather_scatter.c
Normal file
|
@ -0,0 +1,59 @@
|
|||
/* { dg-do run } */
|
||||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
#if HAVE_IO
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int array[10][10], array2[10], array3[10], x = 0, y;
|
||||
int x_correct, y_correct, ii, jj = 0;
|
||||
float array4[10][10][10][10];
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
{
|
||||
for (jj = 0; jj < 10; jj++)
|
||||
{
|
||||
array[ii][jj] = 1+ii;
|
||||
array2[ii]= 2;
|
||||
array3[ii]= 3;
|
||||
}
|
||||
}
|
||||
|
||||
array[array2[:]][array3[:]] = 1000;
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
if (array[array2[ii]][array3[ii]] != 1000)
|
||||
return 1;
|
||||
|
||||
#if HAVE_IO
|
||||
for (ii = 0; ii < 10; ii++) {
|
||||
for (jj = 0; jj < 10; jj++) {
|
||||
printf("%4d\t", array[ii][jj]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
array4[array2[:]][array3[0:10:1]][array2[0:10:1]][array3[0:10:1]] =
|
||||
(float)array[array2[:]][array3[:]];
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
if (array4[array2[ii]][array3[ii]][array2[ii]][array3[ii]] !=
|
||||
(float)array[array2[ii]][array3[ii]])
|
||||
return 2;
|
||||
|
||||
#if HAVE_IO
|
||||
for (ii = 0; ii < 10; ii++) {
|
||||
for (jj = 0; jj < 10; jj++) {
|
||||
for (kk = 0; kk < 10; kk++) {
|
||||
for (ll = 0; ll < 10; ll++) {
|
||||
printf("%4d\n", array4[ii][jj][kk][ll]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
250
gcc/testsuite/c-c++-common/cilk-plus/AN/if_test.c
Normal file
250
gcc/testsuite/c-c++-common/cilk-plus/AN/if_test.c
Normal file
|
@ -0,0 +1,250 @@
|
|||
/* { dg-do run } */
|
||||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
#include <stdlib.h>
|
||||
int main2 (int argc, char **argv);
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int x = 0;
|
||||
if (argc == 1)
|
||||
{
|
||||
const char *array[] = {"a.out", "10", "15"};
|
||||
x = main2 (3, (char **) array);
|
||||
}
|
||||
else if (argc == 3)
|
||||
x = main2 (argc, argv);
|
||||
else
|
||||
return 1;
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
int main2 (int argc, char **argv)
|
||||
{
|
||||
int x = 3, y, z, array[10], array2[10], TwodArray[10][10], jj,kk,ll ;
|
||||
int array2_check[10];
|
||||
int FourDArray[10][10][10][10];
|
||||
int ii = 0;
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
{
|
||||
array[ii] = argc%3;
|
||||
array2[ii]= 10;
|
||||
array2_check[ii] = 10;
|
||||
}
|
||||
|
||||
if (!array[:])
|
||||
array2[:] = 5;
|
||||
else
|
||||
array2[:] = 10;
|
||||
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
{
|
||||
if (!array[ii])
|
||||
array2_check[ii] = 5;
|
||||
else
|
||||
array2_check[ii] = 10;
|
||||
}
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
if (array2_check[ii] != array2[ii])
|
||||
return 2;
|
||||
|
||||
|
||||
|
||||
if (!(array[0:10:1] + array[0:10:1]))
|
||||
array2[:] = 5;
|
||||
else
|
||||
array2[:] = 10;
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
{
|
||||
if (!(array[ii]+ array[ii]))
|
||||
array2_check[ii] = 5;
|
||||
else
|
||||
array2_check[ii] = 10;
|
||||
}
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
if (array2_check[ii] != array2[ii])
|
||||
return 3;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
x = atoi (argv[1])-10;
|
||||
y = atoi (argv[1])/2;
|
||||
z = (atoi (argv[1]))/5;
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
{
|
||||
if (ii % 2)
|
||||
array[ii] = 0;
|
||||
else
|
||||
array[ii] = 1;
|
||||
}
|
||||
|
||||
/*printf("x = %2d y = %2d z = %2d\n", x, y, z); */
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
array[ii] = 10;
|
||||
|
||||
/* This if loop will change all the 10's to 5's */
|
||||
if (array[x:y:z] != 9)
|
||||
array2[:] = 5;
|
||||
else
|
||||
array2[:] = 10;
|
||||
|
||||
for (ii = x; ii < (x+y); ii += z)
|
||||
{
|
||||
if (array[ii] != 9)
|
||||
array2_check[ii] = 5;
|
||||
else
|
||||
array2_check[ii] = 10;
|
||||
}
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
if (array2_check[ii] != array2[ii])
|
||||
return 4;
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
array2[ii] = 10;
|
||||
|
||||
/* This if loop will change all the 10's to 5's */
|
||||
if (array[atoi(argv[1])-10:atoi(argv[1]): atoi(argv[1])/5])
|
||||
array2[:] = 5;
|
||||
else
|
||||
array2[:] = 10;
|
||||
|
||||
for (ii = atoi(argv[1])-10; ii < atoi(argv[1]) + (atoi (argv[1])-10);
|
||||
ii +=atoi(argv[1])/5)
|
||||
if (array[ii])
|
||||
array2_check[ii] = 5;
|
||||
else
|
||||
array2_check[ii] = 10;
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
if (array2_check[ii] != array2[ii])
|
||||
return 5;
|
||||
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
for (jj = 0; jj < 10; jj++)
|
||||
TwodArray[ii][jj] = atoi(argv[1]);
|
||||
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
{
|
||||
array2[ii] = 10;
|
||||
array2_check[ii] = 10;
|
||||
}
|
||||
|
||||
/* atoi(argv[1]) == 10, so it will convert all 10's to 5's */
|
||||
if (TwodArray[:][:] != 10)
|
||||
array2[:] = 10;
|
||||
else
|
||||
array2[:] = 5;
|
||||
|
||||
for (ii = 0; ii < 10; ii++) {
|
||||
for (jj = 0; jj < 10; jj++) {
|
||||
if (TwodArray[ii][jj] != 10)
|
||||
array2_check[ii] = 10;
|
||||
}
|
||||
}
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
{
|
||||
array2[ii] = 10;
|
||||
array2_check[ii] = 10;
|
||||
}
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
for (jj = 0; jj < 10; jj++)
|
||||
for (kk = 0; kk < 10; kk++)
|
||||
for (ll = 0; ll < 10; ll++)
|
||||
FourDArray[ii][jj][kk][ll] = atoi(argv[1]);
|
||||
|
||||
/* atoi(argv[1]) == 10, so it will convert all 10's to 5's */
|
||||
if (FourDArray[:][:][:][:] != 10)
|
||||
array2[:] = 10;
|
||||
else
|
||||
array2[:] = 5;
|
||||
|
||||
for (ii = 0; ii < 10; ii++) {
|
||||
for (jj = 0; jj < 10; jj++) {
|
||||
for (kk = 0; kk < 10; kk++) {
|
||||
for (ll = 0; ll < 10; ll++) {
|
||||
if (FourDArray[ii][jj][kk][ll] != 10)
|
||||
array2_check[ii] = 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
{
|
||||
array2[ii] = 10;
|
||||
array2_check[ii] = 10;
|
||||
}
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
for (jj = 0; jj < 10; jj++)
|
||||
for (kk = 0; kk < 10; kk++)
|
||||
for (ll = 0; ll < 10; ll++)
|
||||
FourDArray[ii][jj][kk][ll] = atoi(argv[1]);
|
||||
|
||||
/* atoi(argv[1]) == 10, so it will convert all 10's to 5's */
|
||||
if (FourDArray[0:10:1][0:5:2][9:10:-1][x:y:z] != 10)
|
||||
array2[:] = 10;
|
||||
else
|
||||
array2[:] = 5;
|
||||
|
||||
for (ii = 0; ii < 10; ii++) {
|
||||
for (jj = 0; jj < 10; jj += 2) {
|
||||
for (kk = 9; kk >= 0; kk--) {
|
||||
for (ll = x; ll < 10; ll = ll += z) {
|
||||
if (FourDArray[ii][jj][kk][ll] != 10)
|
||||
array2_check[ii] = 10;
|
||||
else
|
||||
array2_check[ii] = 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
{
|
||||
array2[ii] = 10;
|
||||
array2_check[ii] = 10;
|
||||
}
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
for (jj = 0; jj < 10; jj++)
|
||||
for (kk = 0; kk < 10; kk++)
|
||||
for (ll = 0; ll < 10; ll++)
|
||||
FourDArray[ii][jj][kk][ll] = atoi(argv[1]);
|
||||
|
||||
/* atoi(argv[1]) == 10, so it will convert all 10's to 5's */
|
||||
if (FourDArray[0:10:1][0:5:2][9:10:-1][x:y:z] +
|
||||
FourDArray[0:10:1][0:5:2][9:-10:1][x:y:z] != 20)
|
||||
array2[:] = 10;
|
||||
else
|
||||
array2[:] = 5;
|
||||
|
||||
for (ii = 0; ii < 10; ii++) {
|
||||
for (jj = 0; jj < 10; jj += 2) {
|
||||
for (kk = 9; kk >= 0; kk--) {
|
||||
for (ll = x; ll < 10; ll = ll += z) {
|
||||
if (FourDArray[ii][jj][kk][ll] != 10)
|
||||
array2_check[ii] = 10;
|
||||
else
|
||||
array2_check[ii] = 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
112
gcc/testsuite/c-c++-common/cilk-plus/AN/misc.c
Normal file
112
gcc/testsuite/c-c++-common/cilk-plus/AN/misc.c
Normal file
|
@ -0,0 +1,112 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
int array[10], array2[10][10];
|
||||
int x, ii, jj ;
|
||||
|
||||
switch (array[:]) { /* { dg-error "array notations cannot be used as a condition for switch statement" } */
|
||||
case 1:
|
||||
x = 5;
|
||||
break;
|
||||
case 2:
|
||||
x = 2;
|
||||
break;
|
||||
default:
|
||||
x = 9;
|
||||
}
|
||||
|
||||
switch (array2[:][:]) { /* { dg-error "array notations cannot be used as a condition for switch statement" } */
|
||||
case 1:
|
||||
x = 5;
|
||||
break;
|
||||
case 2:
|
||||
x = 2;
|
||||
break;
|
||||
default:
|
||||
x = 9;
|
||||
}
|
||||
|
||||
switch (array[:] + x) { /* { dg-error "array notations cannot be used as a condition for switch statement" } */
|
||||
case 1:
|
||||
x = 5;
|
||||
break;
|
||||
case 2:
|
||||
x = 2;
|
||||
break;
|
||||
default:
|
||||
x = 9;
|
||||
}
|
||||
|
||||
switch (array2[:][1:x:4] + x) { /* { dg-error "array notations cannot be used as a condition for switch statement" } */
|
||||
case 1:
|
||||
x = 5;
|
||||
break;
|
||||
case 2:
|
||||
x = 2;
|
||||
break;
|
||||
default:
|
||||
x = 9;
|
||||
}
|
||||
|
||||
for (ii = 0; ii < array[:]; ii++) /* { dg-error "array notations cannot be used in a condition for a for-loop" } */
|
||||
{
|
||||
x = 2;
|
||||
}
|
||||
|
||||
for (ii = 0; ii < array2[:][:]; ii++) /* { dg-error "array notations cannot be used in a condition for a for-loop" } */
|
||||
{
|
||||
x = 3;
|
||||
}
|
||||
|
||||
for (; array2[:][:] < 2;) /* { dg-error "array notations cannot be used in a condition for a for-loop" } */
|
||||
x = 4;
|
||||
|
||||
|
||||
while (array2[:][:]) /* { dg-error "array notations cannot be used as a condition for while statement" } */
|
||||
x = 3;
|
||||
|
||||
while (array[1:1:1]) /* { dg-error "array notations cannot be used as a condition for while statement" } */
|
||||
x = 1;
|
||||
|
||||
while (ii != array2[1:x:3][1:2:1]) /* { dg-error "array notations cannot be used as a condition for while statement" } */
|
||||
x = 2;
|
||||
|
||||
do { /* { dg-error "array notations cannot be used as a condition for a do-while statement" } */
|
||||
x = 3;
|
||||
} while (ii != array2[:][:]);
|
||||
|
||||
do { /* { dg-error "array notations cannot be used as a condition for a do-while statement" } */
|
||||
x = 2;
|
||||
} while (ii != (x + array2[:][1:x:2]) + 2);
|
||||
|
||||
do {
|
||||
x += 3;
|
||||
if (x == 5)
|
||||
return array2[:][:]; /* { dg-error "array notation expression cannot be used as a return value" } */
|
||||
} while (ii != 0);
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
if (ii % 2)
|
||||
return array[1:x:ii]; /* { dg-error "array notation expression cannot be used as a return value" } */
|
||||
|
||||
for (ii = 0; ii < x; ii++)
|
||||
if (ii)
|
||||
return array2[:][:]; /* { dg-error "array notation expression cannot be used as a return value" } */
|
||||
|
||||
for (array[:] = 0; ii < x; ii++) /* This should be OK. */
|
||||
x= 2;
|
||||
|
||||
for (ii = 0; ii < 10; array[:]++) /* This is OK. */
|
||||
x = 5;
|
||||
|
||||
for (jj = 0; jj < 10; array2[:][:]++) /* This is OK. */
|
||||
x = 3;
|
||||
|
||||
for (jj = 0; jj < 10; array2[:][1:x:4]++, jj++) /* This is OK. */
|
||||
x = 3;
|
||||
|
||||
return x;
|
||||
}
|
||||
|
48
gcc/testsuite/c-c++-common/cilk-plus/AN/n-ptr-test.c
Normal file
48
gcc/testsuite/c-c++-common/cilk-plus/AN/n-ptr-test.c
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* { dg-do run } */
|
||||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
#define NUMBER 10
|
||||
#include <stdlib.h>
|
||||
|
||||
int ***func2 (int ***a1, int ***a2, int size)
|
||||
{
|
||||
a1[0:size:1][0:size:1][0:size] += (a2[0:size][0:size][0:size:1] + size);
|
||||
return a1;
|
||||
}
|
||||
|
||||
int main (void)
|
||||
{
|
||||
int ii, jj, kk;
|
||||
int ***array3, ***array2 = NULL, ***array = NULL;
|
||||
|
||||
array = (int ***) malloc (sizeof (int **) * NUMBER);
|
||||
array2 = (int ***) malloc (sizeof (int **) * NUMBER);
|
||||
for (ii = 0; ii < NUMBER; ii++) {
|
||||
array[ii] = (int **) malloc (sizeof (int *) * NUMBER);
|
||||
array2[ii] = (int **) malloc (sizeof (int *) * NUMBER);
|
||||
for (jj = 0; jj < NUMBER; jj++) {
|
||||
array[ii][jj] = (int *) malloc (sizeof (int) * NUMBER);
|
||||
array2[ii][jj] = (int *) malloc (sizeof (int) * NUMBER);
|
||||
}
|
||||
}
|
||||
|
||||
for (ii = 0; ii < NUMBER; ii++) {
|
||||
for (jj = 0; jj < NUMBER; jj++) {
|
||||
for (kk = 0; kk < NUMBER; kk++) {
|
||||
array[ii][jj][kk] = 5;
|
||||
array2[ii][jj][kk]= 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
array3 = func2 ((int ***)array, (int ***)array2, NUMBER);
|
||||
|
||||
for (ii = 0; ii < NUMBER; ii++) {
|
||||
for (jj = 0; jj < NUMBER; jj++) {
|
||||
for (kk = 0; kk < NUMBER; kk++) {
|
||||
if (array3[ii][jj][kk] != (7 + NUMBER))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
11
gcc/testsuite/c-c++-common/cilk-plus/AN/parser_errors.c
Normal file
11
gcc/testsuite/c-c++-common/cilk-plus/AN/parser_errors.c
Normal file
|
@ -0,0 +1,11 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
int array[10][10], array2[10];
|
||||
|
||||
array2[:] = array2[: ; /* { dg-error "expected ']'" } */
|
||||
|
||||
return 0;
|
||||
} /* { dg-error "expected ';' before" } */
|
11
gcc/testsuite/c-c++-common/cilk-plus/AN/parser_errors2.c
Normal file
11
gcc/testsuite/c-c++-common/cilk-plus/AN/parser_errors2.c
Normal file
|
@ -0,0 +1,11 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
int array[10][10], array2[10];
|
||||
|
||||
array2[:] = array2[1:2:] ; /* { dg-error "expected expression before" } */
|
||||
|
||||
return 0; /* { dg-error "expected ';' before" } */
|
||||
}
|
11
gcc/testsuite/c-c++-common/cilk-plus/AN/parser_errors3.c
Normal file
11
gcc/testsuite/c-c++-common/cilk-plus/AN/parser_errors3.c
Normal file
|
@ -0,0 +1,11 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
int array[10][10], array2[10];
|
||||
|
||||
array2[:] = array2[1::] ; /* { dg-error "expected expression before" } */
|
||||
|
||||
return 0; /* { dg-error "expected ';' before" } */
|
||||
}
|
11
gcc/testsuite/c-c++-common/cilk-plus/AN/parser_errors4.c
Normal file
11
gcc/testsuite/c-c++-common/cilk-plus/AN/parser_errors4.c
Normal file
|
@ -0,0 +1,11 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
int array[10][10], array2[10];
|
||||
|
||||
array2[:] = array2[::] ; /* { dg-error " expected ']' before ':' token" } */
|
||||
|
||||
return 0;
|
||||
}
|
14
gcc/testsuite/c-c++-common/cilk-plus/AN/rank_mismatch.c
Normal file
14
gcc/testsuite/c-c++-common/cilk-plus/AN/rank_mismatch.c
Normal file
|
@ -0,0 +1,14 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
int x = 0;
|
||||
int array[10][10], array2[10];
|
||||
|
||||
array[:][:] = array[:]; /* { dg-error "rank mismatch between" } */
|
||||
|
||||
x = array2[:]; /* { dg-error "cannot be scalar when" } */
|
||||
|
||||
return 0;
|
||||
}
|
27
gcc/testsuite/c-c++-common/cilk-plus/AN/rank_mismatch2.c
Normal file
27
gcc/testsuite/c-c++-common/cilk-plus/AN/rank_mismatch2.c
Normal file
|
@ -0,0 +1,27 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
int function_call (int x);
|
||||
int function_call (int x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int array[100], array2[100][100];
|
||||
|
||||
array[:] = array[:] + array2[:][:]; /* { dg-error "rank mismatch between" } */
|
||||
|
||||
if (array[:] + array2[:][:]) /* { dg-error "rank mismatch between" } */
|
||||
return argc == 5;
|
||||
|
||||
argc += function_call (array[:] + array2[5:10:2][:]); /* { dg-error "rank mismatch between" } */
|
||||
|
||||
argc += function_call (function_call (array[:] + array2[5:10:2][:])); /* { dg-error "rank mismatch between" } */
|
||||
|
||||
argc += __sec_reduce_add (array[:], array2[:][:]); /* { dg-error "rank mismatch between" } */
|
||||
|
||||
argc += __sec_reduce_add (array2[:][:]) + argc; /* This is OK. */
|
||||
return argc;
|
||||
}
|
19
gcc/testsuite/c-c++-common/cilk-plus/AN/rank_mismatch3.c
Normal file
19
gcc/testsuite/c-c++-common/cilk-plus/AN/rank_mismatch3.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
int funct (int x, int y);
|
||||
void funct_void (int x, int y, int z);
|
||||
int main(void)
|
||||
{
|
||||
int y, array[100], array2[100], array3[100][100], array4[100];
|
||||
|
||||
array[:] = ((array2[:] + array[:]) * array4[:]) + array3[:][:]; /* { dg-error "rank mismatch between" } */
|
||||
array[:] = funct (array2[:], array3[:][:]); /* { dg-error "rank mismatch between" } */
|
||||
array[:] = array3[:][:]; /* { dg-error "rank mismatch between" } */
|
||||
array3[:][:] = array[:]; /* { dg-error "rank mismatch between" } */
|
||||
array3[:][:] = array[5]; /* This is OK! */
|
||||
funct_void (array2[:], array3[:][:], array[:]); /* { dg-error "rank mismatch between" } */
|
||||
funct_void (array2[:], array3[:][:], array[:]); /* { dg-error "rank mismatch between" } */
|
||||
funct_void (array3[:][:], array2[:], array[:]); /* { dg-error "rank mismatch between" } */
|
||||
funct_void (array2[:], array[:], array3[:][0:10:1]); /* { dg-error "rank mismatch between" } */
|
||||
return 0;
|
||||
}
|
26
gcc/testsuite/c-c++-common/cilk-plus/AN/sec_implicit.c
Normal file
26
gcc/testsuite/c-c++-common/cilk-plus/AN/sec_implicit.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
int main2 (int argc, char **argv);
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
int x = 0;
|
||||
if (argc == 1)
|
||||
{
|
||||
const char *array[] = {"a.out", "5"};
|
||||
x = main2 (2, (char **)array);
|
||||
}
|
||||
else
|
||||
x = main2 (argc, argv);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
int main2 (int argc, char **argv)
|
||||
{
|
||||
int array[10][10], array2[10];
|
||||
|
||||
array[:][:] = __sec_implicit_index(5) + array[:][:]; /* { dg-error "__sec_implicit_index argument" } */
|
||||
|
||||
return 0;
|
||||
}
|
25
gcc/testsuite/c-c++-common/cilk-plus/AN/sec_implicit2.c
Normal file
25
gcc/testsuite/c-c++-common/cilk-plus/AN/sec_implicit2.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
int main2 (int argc, char **argv);
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
int x = 0;
|
||||
if (argc == 1)
|
||||
{
|
||||
const char *array[] = {"a.out", "5"};
|
||||
x = main2 (2, (char**)array);
|
||||
}
|
||||
else
|
||||
x = main2 (argc, argv);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
int main2 (int argc, char **argv)
|
||||
{
|
||||
int array[10][10], array2[10];
|
||||
|
||||
array[:][:] = __sec_implicit_index(argc) + array[:][:]; /* { dg-error "__sec_implicit_index parameter" } */
|
||||
return 0;
|
||||
}
|
33
gcc/testsuite/c-c++-common/cilk-plus/AN/sec_implicit_ex.c
Normal file
33
gcc/testsuite/c-c++-common/cilk-plus/AN/sec_implicit_ex.c
Normal file
|
@ -0,0 +1,33 @@
|
|||
/* { dg-do run } */
|
||||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
void abort (void);
|
||||
void exit (int);
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int jj, kk, array_3C[10][10][10];
|
||||
int ii,array[10], y = 0, y_int = 0, array2[10], array_3[10][10][10];
|
||||
double x, yy, array3[10], array4[10];
|
||||
|
||||
array[:] = __sec_implicit_index (0);
|
||||
array_3[:][:][:] = __sec_implicit_index (1) + __sec_implicit_index(0) +
|
||||
__sec_implicit_index (2);
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
for (jj = 0; jj < 10; jj++)
|
||||
for (kk = 0; kk < 10; kk++)
|
||||
array_3C[ii][jj][kk] = ii+jj+kk;
|
||||
|
||||
for (ii = 0; ii < 10; ii++)
|
||||
for (jj = 0; jj < 10; jj++)
|
||||
for (kk = 0; kk < 10; kk++)
|
||||
if (array_3[ii][jj][kk] != array_3C[ii][jj][kk])
|
||||
abort ();
|
||||
|
||||
|
||||
exit (0);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
int main2 (int argc, char **argv);
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
int x = 0;
|
||||
if (argc == 1)
|
||||
{
|
||||
const char *array[] = {"a.out", "5"};
|
||||
x = main2 (2, (char **)array);
|
||||
}
|
||||
else
|
||||
x = main2 (argc, argv);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
int main2 (int argc, char **argv)
|
||||
{
|
||||
int array[10][10], array2[10];
|
||||
int x, y;
|
||||
x = __sec_reduce_max_ind (array[:][:]); /* { dg-error "cannot have arrays with dimension greater than" } */
|
||||
|
||||
y = __sec_reduce_max_ind (array2[:]); /* this should be OK. */
|
||||
|
||||
x = __sec_reduce_min_ind (array[:][:]); /* { dg-error "cannot have arrays with dimension greater than" } */
|
||||
|
||||
y = __sec_reduce_min_ind (array2[:]); /* this should be OK. */
|
||||
|
||||
return 0;
|
||||
}
|
27
gcc/testsuite/c-c++-common/cilk-plus/AN/sec_reduce_return.c
Normal file
27
gcc/testsuite/c-c++-common/cilk-plus/AN/sec_reduce_return.c
Normal file
|
@ -0,0 +1,27 @@
|
|||
/* { dg-do run } */
|
||||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
int add_all (int *my_array, int size)
|
||||
{
|
||||
return __sec_reduce_add (my_array[0:size]);
|
||||
}
|
||||
|
||||
int mult_all (int *my_array, int size)
|
||||
{
|
||||
return __sec_reduce_mul (my_array[0:size]);
|
||||
}
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
int array[10000];
|
||||
|
||||
array[:] = argc; /* All elements should be one. */
|
||||
|
||||
if (add_all (array, 10000) != 10000)
|
||||
return 1;
|
||||
|
||||
if (mult_all (array, 10000) != 1)
|
||||
return 2;
|
||||
|
||||
return 0;
|
||||
}
|
26
gcc/testsuite/c-c++-common/cilk-plus/AN/side-effects-1.c
Normal file
26
gcc/testsuite/c-c++-common/cilk-plus/AN/side-effects-1.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* { dg-do run } */
|
||||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
/* Test that the array index, limit, and stride are evaluated only
|
||||
once. */
|
||||
|
||||
int array[1000];
|
||||
|
||||
int func1_times = 0;
|
||||
int func2_times = 0;
|
||||
int func3_times = 0;
|
||||
int func1() { func1_times++; return 0; }
|
||||
int func2() { func2_times++; return 0; }
|
||||
int func3() { func3_times++; return 0; }
|
||||
|
||||
int main()
|
||||
{
|
||||
array[func1() + 11 : func2() + 22 : func3() + 33] = 666;
|
||||
|
||||
if (func1_times != 1
|
||||
|| func2_times != 1
|
||||
|| func3_times != 1)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/* { dg-options "-lm -fcilkplus" } */
|
||||
/* { dg-do run } */
|
||||
|
||||
#if HAVE_IO
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
#define NUMBER 5
|
||||
|
||||
int func1 (int *a1, int *a2)
|
||||
{
|
||||
return __sec_reduce_add (a1[0:NUMBER] * a2[0:NUMBER:1]);
|
||||
}
|
||||
|
||||
int func2 (int *a1, int *a2)
|
||||
{
|
||||
return (__sec_reduce_add (a1[0:NUMBER] * a2[0:NUMBER]) +
|
||||
__sec_reduce_mul (a1[0:NUMBER] + a2[0:NUMBER]));
|
||||
}
|
||||
|
||||
int func3 (int *a1, int *a2)
|
||||
{
|
||||
return (int) sqrt ((double)(__sec_reduce_add (a1[0:NUMBER] * a2[0:NUMBER]) +
|
||||
a2[0] + a2[1] + a2[3]));
|
||||
}
|
||||
|
||||
int func4 (int *a1, int *a2)
|
||||
{
|
||||
return a1[NUMBER-1] * (__sec_reduce_add (a1[0:NUMBER] * a2[0:NUMBER]) + a2[0] + a2[1] + a2[3])/a1[NUMBER-2];
|
||||
}
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int array[NUMBER], array2[NUMBER];
|
||||
int return_value = 0;
|
||||
int ii = 0;
|
||||
for (ii = 0; ii < NUMBER; ii++)
|
||||
{
|
||||
array[ii] = argc; /* This should calculate to 1. */
|
||||
array2[ii] = argc * argc + argc; /* This should calculate to 2. */
|
||||
}
|
||||
|
||||
return_value = func1 (array, array2);
|
||||
#if HAVE_IO
|
||||
printf("Return_value = %d\n", return_value);
|
||||
#endif
|
||||
if (return_value != (2+2+2+2+2))
|
||||
return 1;
|
||||
|
||||
return_value = func2 (array2, array);
|
||||
#if HAVE_IO
|
||||
printf("Return_value = %d\n", return_value);
|
||||
#endif
|
||||
if (return_value != (3*3*3*3*3) + (2+2+2+2+2))
|
||||
return 2;
|
||||
|
||||
return_value = func3 (array, array2);
|
||||
#if HAVE_IO
|
||||
printf("Return_value = %d\n", return_value);
|
||||
#endif
|
||||
if (return_value != 4)
|
||||
return 3;
|
||||
|
||||
return_value = func4 (array, array2);
|
||||
#if HAVE_IO
|
||||
printf("Return_value = %d\n", return_value);
|
||||
#endif
|
||||
if (return_value != 16)
|
||||
return 4;
|
||||
|
||||
return 0;
|
||||
}
|
18
gcc/testsuite/c-c++-common/cilk-plus/AN/test_sec_limits.c
Normal file
18
gcc/testsuite/c-c++-common/cilk-plus/AN/test_sec_limits.c
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* { dg-do run } */
|
||||
/* { dg-options "-fcilkplus" } */
|
||||
|
||||
#include <limits.h>
|
||||
int A[16];
|
||||
int a = 0;
|
||||
|
||||
int main () {
|
||||
if (__sec_reduce_max(A[0:0:2]) != INT_MIN)
|
||||
a++;
|
||||
|
||||
if (__sec_reduce_min(A[0:0:2]) != INT_MAX)
|
||||
a++;
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
|
19
gcc/testsuite/c-c++-common/cilk-plus/AN/tst_lngth.c
Normal file
19
gcc/testsuite/c-c++-common/cilk-plus/AN/tst_lngth.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options " -fcilkplus " } */
|
||||
|
||||
#if HAVE_IO
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#define N 256
|
||||
int A[N], B[N];
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
A[0:(N / 4)] = A[4]+ B[0:(N / 2):2]; /* { dg-error "length mismatch between" } */
|
||||
A[0:(N / 4)] = B[0:(N / 2):2] + N; /* { dg-error "length mismatch between" } */
|
||||
A[0:(N / 4)] = B[0:(N / 2):2] + A[4]; /* { dg-error "length mismatch between" } */
|
||||
return 0;
|
||||
}
|
||||
|
18
gcc/testsuite/c-c++-common/cilk-plus/AN/vla.c
Normal file
18
gcc/testsuite/c-c++-common/cilk-plus/AN/vla.c
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-fcilkplus -std=c99" } */
|
||||
|
||||
int func (int x)
|
||||
{
|
||||
return x++;
|
||||
}
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int array[argc];
|
||||
|
||||
array[:] = 5; /* { dg-error "start-index and length fields necessary for using array notations in variable-length arrays." } */
|
||||
array[0:argc] = 5; /* This is OK. */
|
||||
array[0:5:2] = 5; /* This is OK. */
|
||||
array[0:argc:2] = 5; /* This is OK. */
|
||||
array[0:argc:func (argc-2)] = 5; /* This is OK. */
|
||||
return 0;
|
||||
}
|
45
gcc/testsuite/gcc.dg/cilk-plus/cilk-plus.exp
Normal file
45
gcc/testsuite/gcc.dg/cilk-plus/cilk-plus.exp
Normal file
|
@ -0,0 +1,45 @@
|
|||
# Copyright (C) 2013 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with GCC; see the file COPYING3. If not see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Written by Balaji V. Iyer <balaji.v.iyer@intel.com>
|
||||
|
||||
|
||||
load_lib gcc-dg.exp
|
||||
|
||||
dg-init
|
||||
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -fcilkplus" " "
|
||||
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -O0 -fcilkplus" " "
|
||||
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -O1 -fcilkplus" " "
|
||||
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -O2 -ftree-vectorize -fcilkplus" " "
|
||||
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -O3 -fcilkplus" " "
|
||||
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -g -fcilkplus" " "
|
||||
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -g -O0 -fcilkplus" " "
|
||||
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -g -O1 -fcilkplus" " "
|
||||
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -g -O2 -ftree-vectorize -fcilkplus" " "
|
||||
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -g -O3 -fcilkplus" " "
|
||||
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -O3 -ftree-vectorize -fcilkplus -g" " "
|
||||
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -fcilkplus -std=c99" " "
|
||||
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -fcilkplus -O0 -std=c99" " "
|
||||
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -fcilkplus -O1 -std=c99" " "
|
||||
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -fcilkplus -O2 -ftree-vectorize -std=c99" " "
|
||||
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -fcilkplus -O3 -std=c99" " "
|
||||
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -fcilkplus -g -std=c99" " "
|
||||
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -fcilkplus -g -O0 -std=c99" " "
|
||||
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -fcilkplus -g -O1 -std=c99" " "
|
||||
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -fcilkplus -g -O2 -ftree-vectorize -std=c99" " "
|
||||
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -fcilkplus -g -O3 -std=c99" " "
|
||||
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -O3 -ftree-vectorize -std=c99 -g -fcilkplus" " "
|
||||
dg-finish
|
Loading…
Add table
Reference in a new issue