diff --git a/ChangeLog b/ChangeLog index f7f7b5d3447d1..bdd1e5e342422 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2024-06-18 Kyrylo Tkachov + + * MAINTAINERS (aarch64 port): Update my email address. + (DCO section): Likewise. + +2024-06-11 Arthur Cohen + + * Makefile.tpl: Add CRAB1_LIBS variable. + * Makefile.in: Regenerate. + * configure: Regenerate. + * configure.ac: Check if -ldl and -lpthread are needed, and if so, add + them to CRAB1_LIBS. + 2024-05-31 Pengxuan Zheng * MAINTAINERS: Add myself to Write After Approval and DCO. diff --git a/MAINTAINERS b/MAINTAINERS index 6444e6ea2f1a4..41319595bb5c7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -52,14 +52,14 @@ docs, and the testsuite related to that. aarch64 port Richard Earnshaw aarch64 port Richard Sandiford aarch64 port Marcus Shawcroft -aarch64 port Kyrylo Tkachov +aarch64 port Kyrylo Tkachov alpha port Richard Henderson amdgcn port Julian Brown amdgcn port Andrew Stubbs arc port Claudiu Zissulescu arm port Nick Clifton arm port Richard Earnshaw -arm port Ramana Radhakrishnan +arm port Ramana Radhakrishnan avr port Denis Chertykov bfin port Jie Zhang bpf port Jose E. Marchesi @@ -776,6 +776,7 @@ Immad Mir Gaius Mulley Andrew Pinski Siddhesh Poyarekar +Ramana Radhakrishnan Navid Rahimi Rishi Raj Trevor Saunders @@ -784,7 +785,7 @@ Nathaniel Shead Nathan Sidwell Edward Smith-Rowland Fangrui Song -Kyrylo Tkachov +Kyrylo Tkachov Petter Tomner Martin Uecker Jonathan Wakely diff --git a/Makefile.in b/Makefile.in index db4fa6c62605c..34c5550beca26 100644 --- a/Makefile.in +++ b/Makefile.in @@ -197,6 +197,7 @@ HOST_EXPORTS = \ $(BASE_EXPORTS) \ CC="$(CC)"; export CC; \ ADA_CFLAGS="$(ADA_CFLAGS)"; export ADA_CFLAGS; \ + CRAB1_LIBS="$(CRAB1_LIBS)"; export CRAB1_LIBS; \ CFLAGS="$(CFLAGS)"; export CFLAGS; \ CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ CXX="$(CXX)"; export CXX; \ @@ -450,6 +451,8 @@ GOCFLAGS = $(CFLAGS) GDCFLAGS = @GDCFLAGS@ GM2FLAGS = $(CFLAGS) +CRAB1_LIBS = @CRAB1_LIBS@ + PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ GUILE = guile diff --git a/Makefile.tpl b/Makefile.tpl index 1d5813cd56957..8f4bf297918c2 100644 --- a/Makefile.tpl +++ b/Makefile.tpl @@ -200,6 +200,7 @@ HOST_EXPORTS = \ $(BASE_EXPORTS) \ CC="$(CC)"; export CC; \ ADA_CFLAGS="$(ADA_CFLAGS)"; export ADA_CFLAGS; \ + CRAB1_LIBS="$(CRAB1_LIBS)"; export CRAB1_LIBS; \ CFLAGS="$(CFLAGS)"; export CFLAGS; \ CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ CXX="$(CXX)"; export CXX; \ @@ -453,6 +454,8 @@ GOCFLAGS = $(CFLAGS) GDCFLAGS = @GDCFLAGS@ GM2FLAGS = $(CFLAGS) +CRAB1_LIBS = @CRAB1_LIBS@ + PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ GUILE = guile diff --git a/configure b/configure index 3b0abeb8b2e49..1469cd735392a 100755 --- a/configure +++ b/configure @@ -690,6 +690,7 @@ extra_host_zlib_configure_flags extra_host_libiberty_configure_flags stage1_languages host_libs_picflag +CRAB1_LIBS PICFLAG host_shared gcc_host_pie @@ -8875,6 +8876,139 @@ fi +# Rust requires -ldl and -lpthread if you are using an old glibc that does not include them by +# default, so we check for them here + +missing_rust_dynlibs=none + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5 +$as_echo_n "checking for library containing dlopen... " >&6; } +if ${ac_cv_search_dlopen+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +for ac_lib in '' dl; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_dlopen=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_dlopen+:} false; then : + break +fi +done +if ${ac_cv_search_dlopen+:} false; then : + +else + ac_cv_search_dlopen=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlopen" >&5 +$as_echo "$ac_cv_search_dlopen" >&6; } +ac_res=$ac_cv_search_dlopen +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_create" >&5 +$as_echo_n "checking for library containing pthread_create... " >&6; } +if ${ac_cv_search_pthread_create+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pthread_create (); +int +main () +{ +return pthread_create (); + ; + return 0; +} +_ACEOF +for ac_lib in '' pthread; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_pthread_create=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_pthread_create+:} false; then : + break +fi +done +if ${ac_cv_search_pthread_create+:} false; then : + +else + ac_cv_search_pthread_create=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_pthread_create" >&5 +$as_echo "$ac_cv_search_pthread_create" >&6; } +ac_res=$ac_cv_search_pthread_create +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + + +if test "$ac_cv_search_dlopen" = -ldl; then + CRAB1_LIBS="$CRAB1_LIBS -ldl" +elif test "$ac_cv_search_dlopen" = no; then + missing_rust_dynlibs="libdl" +fi + +if test "$ac_cv_search_pthread_create" = -lpthread; then + CRAB1_LIBS="$CRAB1_LIBS -lpthread" +elif test "$ac_cv_search_pthread_create" = no; then + missing_rust_dynlibs="$missing_rust_dynlibs, libpthread" +fi + +CRAB1_LIBS="$CRAB1_LIBS" + + # If we are building PIC/PIE host executables, and we are building dependent # libs (e.g. GMP) in-tree those libs need to be configured to generate PIC # code. @@ -9115,6 +9249,26 @@ $as_echo "$as_me: WARNING: GDC is required to build $language" >&2;} ;; esac + # Disable Rust if we are missing some required C libraries for the Rust runtime. + case ${add_this_lang}:${language}:${missing_rust_dynlibs} in + *:rust:none) + # Nothing to do - we're not missing any C libraries + ;; + yes:rust:*) + as_fn_error $? "some C libraries are required to build $language: $missing_rust_dynlibs" "$LINENO" 5 + add_this_lang=unsupported + ;; + all:rust:*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: some C libraries are required to build $language: $missing_rust_dynlibs" >&5 +$as_echo "$as_me: WARNING: some C libraries are required to build $language: $missing_rust_dynlibs" >&2;} + add_this_lang=unsupported + ;; + *:rust:*) + # Silently disable. + add_this_lang=unsupported + ;; + esac + # Disable jit if -enable-host-shared not specified # but not if building for Mingw. All code in Windows # is position independent code (PIC). @@ -19592,7 +19746,7 @@ config.status configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" -Copyright (C) 2012 Free Software Foundation, Inc. +Copyright (C) Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." diff --git a/configure.ac b/configure.ac index 042681c27be59..20457005e2993 100644 --- a/configure.ac +++ b/configure.ac @@ -2037,6 +2037,28 @@ fi AC_SUBST(PICFLAG) +# Rust requires -ldl and -lpthread if you are using an old glibc that does not include them by +# default, so we check for them here + +missing_rust_dynlibs=none + +AC_SEARCH_LIBS([dlopen], [dl]) +AC_SEARCH_LIBS([pthread_create], [pthread]) + +if test "$ac_cv_search_dlopen" = -ldl; then + CRAB1_LIBS="$CRAB1_LIBS -ldl" +elif test "$ac_cv_search_dlopen" = no; then + missing_rust_dynlibs="libdl" +fi + +if test "$ac_cv_search_pthread_create" = -lpthread; then + CRAB1_LIBS="$CRAB1_LIBS -lpthread" +elif test "$ac_cv_search_pthread_create" = no; then + missing_rust_dynlibs="$missing_rust_dynlibs, libpthread" +fi + +AC_SUBST(CRAB1_LIBS, "$CRAB1_LIBS") + # If we are building PIC/PIE host executables, and we are building dependent # libs (e.g. GMP) in-tree those libs need to be configured to generate PIC # code. @@ -2274,6 +2296,25 @@ if test -d ${srcdir}/gcc; then ;; esac + # Disable Rust if we are missing some required C libraries for the Rust runtime. + case ${add_this_lang}:${language}:${missing_rust_dynlibs} in + *:rust:none) + # Nothing to do - we're not missing any C libraries + ;; + yes:rust:*) + AC_MSG_ERROR([some C libraries are required to build $language: $missing_rust_dynlibs]) + add_this_lang=unsupported + ;; + all:rust:*) + AC_MSG_WARN([some C libraries are required to build $language: $missing_rust_dynlibs]) + add_this_lang=unsupported + ;; + *:rust:*) + # Silently disable. + add_this_lang=unsupported + ;; + esac + # Disable jit if -enable-host-shared not specified # but not if building for Mingw. All code in Windows # is position independent code (PIC). diff --git a/fixincludes/ChangeLog b/fixincludes/ChangeLog index 37403c66be076..cb7c7968d815e 100644 --- a/fixincludes/ChangeLog +++ b/fixincludes/ChangeLog @@ -1,3 +1,16 @@ +2024-06-11 Francois-Xavier Coudert + + * fixincl.x: Regenerate. + * inclhack.def (math_exception): Bypass on __cplusplus. + * tests/base/math.h: Regenerate. + +2024-06-07 Francois-Xavier Coudert + + * fixincl.x: Regenerate. + * inclhack.def (darwin_stdint_7, darwin_dispatch_object_1, + darwin_os_trace_2, darwin_os_base_1): Include bypasses + for recent headers, fixed by Apple. + 2024-05-07 Zac Walker * mkfixinc.sh: Extend for *-mingw32* targets. diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x index e52f11d8460f8..54a530b50ca98 100644 --- a/fixincludes/fixincl.x +++ b/fixincludes/fixincl.x @@ -2,11 +2,11 @@ * * DO NOT EDIT THIS FILE (fixincl.x) * - * It has been AutoGen-ed August 17, 2023 at 10:16:38 AM by AutoGen 5.18.12 + * It has been AutoGen-ed June 7, 2024 at 11:03:58 AM by AutoGen 5.18.16 * From the definitions inclhack.def * and the template file fixincl */ -/* DO NOT SVN-MERGE THIS FILE, EITHER Thu Aug 17 10:16:38 CEST 2023 +/* DO NOT SVN-MERGE THIS FILE, EITHER Fri Jun 7 11:03:58 CEST 2024 * * You must regenerate it. Use the ./genfixes script. * @@ -3070,8 +3070,15 @@ tSCC* apzDarwin_Os_Trace_2Machs[] = { tSCC zDarwin_Os_Trace_2Select0[] = "typedef.*\\^os_trace_payload_t.*"; -#define DARWIN_OS_TRACE_2_TEST_CT 1 +/* + * content bypass pattern - skip fix if pattern found + */ +tSCC zDarwin_Os_Trace_2Bypass0[] = + "#ifdef __BLOCKS__"; + +#define DARWIN_OS_TRACE_2_TEST_CT 2 static tTestDesc aDarwin_Os_Trace_2Tests[] = { + { TT_NEGREP, zDarwin_Os_Trace_2Bypass0, (regex_t*)NULL }, { TT_EGREP, zDarwin_Os_Trace_2Select0, (regex_t*)NULL }, }; /* @@ -3199,8 +3206,15 @@ tSCC zDarwin_Os_Base_1Select0[] = "#define __has_attribute.*\n\ #endif"; -#define DARWIN_OS_BASE_1_TEST_CT 1 +/* + * content bypass pattern - skip fix if pattern found + */ +tSCC zDarwin_Os_Base_1Bypass0[] = + "#define __has_extension"; + +#define DARWIN_OS_BASE_1_TEST_CT 2 static tTestDesc aDarwin_Os_Base_1Tests[] = { + { TT_NEGREP, zDarwin_Os_Base_1Bypass0, (regex_t*)NULL }, { TT_EGREP, zDarwin_Os_Base_1Select0, (regex_t*)NULL }, }; /* @@ -3239,8 +3253,15 @@ tSCC* apzDarwin_Dispatch_Object_1Machs[] = { tSCC zDarwin_Dispatch_Object_1Select0[] = "typedef void.*\\^dispatch_block_t.*"; -#define DARWIN_DISPATCH_OBJECT_1_TEST_CT 1 +/* + * content bypass pattern - skip fix if pattern found + */ +tSCC zDarwin_Dispatch_Object_1Bypass0[] = + "#ifdef __BLOCKS__"; + +#define DARWIN_DISPATCH_OBJECT_1_TEST_CT 2 static tTestDesc aDarwin_Dispatch_Object_1Tests[] = { + { TT_NEGREP, zDarwin_Dispatch_Object_1Bypass0, (regex_t*)NULL }, { TT_EGREP, zDarwin_Dispatch_Object_1Select0, (regex_t*)NULL }, }; /* @@ -3591,8 +3612,15 @@ tSCC zDarwin_Stdint_7Select0[] = "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n\ #define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)"; -#define DARWIN_STDINT_7_TEST_CT 1 +/* + * content bypass pattern - skip fix if pattern found + */ +tSCC zDarwin_Stdint_7Bypass0[] = + "#ifdef __LP64__"; + +#define DARWIN_STDINT_7_TEST_CT 2 static tTestDesc aDarwin_Stdint_7Tests[] = { + { TT_NEGREP, zDarwin_Stdint_7Bypass0, (regex_t*)NULL }, { TT_EGREP, zDarwin_Stdint_7Select0, (regex_t*)NULL }, }; /* @@ -6765,9 +6793,7 @@ tSCC zMath_ExceptionList[] = /* * Machine/OS name selection pattern */ -tSCC* apzMath_ExceptionMachs[] = { - "*-*-solaris2.1[0-9]*", - (const char*)NULL }; +#define apzMath_ExceptionMachs (const char**)NULL /* * content selection pattern - do fix if pattern found @@ -6779,7 +6805,7 @@ tSCC zMath_ExceptionSelect0[] = * content bypass pattern - skip fix if pattern found */ tSCC zMath_ExceptionBypass0[] = - "We have a problem when using C\\+\\+|for C\\+\\+, _[a-z0-9A-Z_]+_exception; for C, exception"; + "__cplusplus"; #define MATH_EXCEPTION_TEST_CT 2 static tTestDesc aMath_ExceptionTests[] = { @@ -11169,7 +11195,7 @@ static const char* apzX11_SprintfPatch[] = { * * List of all fixes */ -#define REGEX_COUNT 313 +#define REGEX_COUNT 317 #define MACH_LIST_SIZE_LIMIT 187 #define FIX_COUNT 274 @@ -12276,7 +12302,7 @@ tFixDesc fixDescList[ FIX_COUNT ] = { { zMath_ExceptionName, zMath_ExceptionList, apzMath_ExceptionMachs, - MATH_EXCEPTION_TEST_CT, FD_MACH_IFNOT | FD_SUBROUTINE, + MATH_EXCEPTION_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, aMath_ExceptionTests, apzMath_ExceptionPatch, 0 }, { zMath_Huge_Val_From_Dbl_MaxName, zMath_Huge_Val_From_Dbl_MaxList, diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def index 19e0ea2df6627..f7fc5cdbabdd3 100644 --- a/fixincludes/inclhack.def +++ b/fixincludes/inclhack.def @@ -1486,6 +1486,7 @@ fix = { mach = "*-*-darwin*"; files = os/trace.h; select = "typedef.*\\^os_trace_payload_t.*"; + bypass = "#ifdef __BLOCKS__"; c_fix = format; c_fix_arg = "#if __BLOCKS__\n%0\n#endif"; test_text = "typedef void (^os_trace_payload_t)(xpc_object_t xdict);"; @@ -1566,6 +1567,7 @@ fix = { #define __has_attribute.* #endif OS_BASE_1_SEL; + bypass = "#define __has_extension"; c_fix = format; c_fix_arg = <<- OS_BASE_1_FIX %0 @@ -1589,6 +1591,7 @@ fix = { mach = "*-*-darwin*"; files = dispatch/object.h; select = "typedef void.*\\^dispatch_block_t.*"; + bypass = "#ifdef __BLOCKS__"; c_fix = format; c_fix_arg = "#if __BLOCKS__\n%0\n#endif"; test_text = <<- DISPATCH_OBJECT_1_TEST @@ -1791,6 +1794,7 @@ fix = { "#endif"; select = "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n" "#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)"; + bypass = '#ifdef __LP64__'; test_text = "#define INTMAX_C(v) (v ## LL)\n" "#define UINTMAX_C(v) (v ## ULL)"; }; @@ -3408,17 +3412,7 @@ fix = { hackname = math_exception; files = math.h; select = "struct exception"; - /* - * This should be bypassed on __cplusplus, but some supposedly C++ - * aware headers, such as Solaris 8 and 9, don't wrap their struct - * exception either. So currently we bypass only for glibc, based on a - * comment in the fixed glibc header. Ick. - */ - bypass = 'We have a problem when using C\+\+|for C\+\+, ' - '_[a-z0-9A-Z_]+_exception; for C, exception'; - /* The Solaris 10 headers already get this right. */ - mach = '*-*-solaris2.1[0-9]*'; - not_machine = true; + bypass = '__cplusplus'; c_fix = wrap; c_fix_arg = "#ifdef __cplusplus\n" diff --git a/fixincludes/tests/base/math.h b/fixincludes/tests/base/math.h index 7b92f29a409f3..3c378c5df958d 100644 --- a/fixincludes/tests/base/math.h +++ b/fixincludes/tests/base/math.h @@ -7,12 +7,6 @@ This had to be done to correct non-standard usages in the original, manufacturer supplied header file. */ -#ifndef FIXINC_WRAP_MATH_H_MATH_EXCEPTION -#define FIXINC_WRAP_MATH_H_MATH_EXCEPTION 1 - -#ifdef __cplusplus -#define exception __math_exception -#endif #if defined( BROKEN_CABS_CHECK ) @@ -146,8 +140,3 @@ int foo; #endif /* _C99 */ #endif /* VXWORKS_MATH_H_FP_C99_CHECK */ -#ifdef __cplusplus -#undef exception -#endif - -#endif /* FIXINC_WRAP_MATH_H_MATH_EXCEPTION */ diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 33ddca9e30365..d64a751a55ea5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,1483 @@ +2024-06-18 Edwin Lu + Robin Dapp + + * config/riscv/riscv-v.cc: Move assert out of conditional block + +2024-06-18 Edwin Lu + Robin Dapp + + * config/riscv/autovec-opt.md: Fix mode mismatch + +2024-06-18 Andrew Pinski + + * config/aarch64/aarch64-cores.def: Add comment + saying thunderxt81/t83 are aliases of octeontx81/83. + +2024-06-18 Andrew Pinski + + * config/aarch64/aarch64-cores.def (thunderxt88p1): Make an alias of thunderxt88 and + move below thunderxt88. + * config/aarch64/aarch64-tune.md: Regenerate. + +2024-06-18 David Malcolm + + * Makefile.in (OBJS): Move selftest-diagnostic-path.o, + selftest-logical-location.o, and tree-diagnostic-path.o to... + (OBJS-libcommon): ...here, renaming tree-diagnostic-path.o to + diagnostic-path.o. + * tree-diagnostic-path.cc: Rename to... + * diagnostic-path.cc: ...this. Drop include of "tree.h". + (tree_diagnostic_path_cc_tests): Rename to... + (diagnostic_path_cc_tests): ...this. + * selftest-run-tests.cc (selftest::run_tests): Update for above + renaming. + * selftest.h (tree_diagnostic_path_cc_tests): Rename decl to... + (diagnostic_path_cc_tests): ...this. + +2024-06-18 David Malcolm + + * diagnostic-format-json.cc (diagnostic_output_format_init_json): + Replace clearing of diagnostic_context::m_print_path callback with + setting the path format to DPF_NONE. + * diagnostic-format-sarif.cc + (diagnostic_output_format_init_sarif): Likewise. + * diagnostic.cc (diagnostic_context::show_any_path): Replace call + to diagnostic_context::m_print_path callback with a direct call to + diagnostic_context::print_path. + * diagnostic.h (diagnostic_context::print_path): New decl. + (diagnostic_context::m_print_path): Delete callback. + * tree-diagnostic-path.cc (default_tree_diagnostic_path_printer): + Convert to... + (diagnostic_context::print_path): ...this. + * tree-diagnostic.cc (tree_diagnostics_defaults): Delete + initialization of m_print_path. + * tree-diagnostic.h (default_tree_diagnostic_path_printer): Delete + decl. + +2024-06-18 David Malcolm + + * diagnostic-macro-unwinding.cc: New file, with material taken + from tree-diagnostic.cc. + * diagnostic-macro-unwinding.h: New file, with material taken + from tree-diagnostic.h. + * tree-diagnostic-path.cc: Repalce include of "tree-diagnostic.h" + with "diagnostic-macro-unwinding.h". + * tree-diagnostic.cc (struct loc_map_pair): Move to + diagnostic-macro-unwinding.cc. + (maybe_unwind_expanded_macro_loc): Likewise. + (virt_loc_aware_diagnostic_finalizer): Likewise. + * tree-diagnostic.h (virt_loc_aware_diagnostic_finalizer): Move + decl to diagnostic-macro-unwinding.h. + (maybe_unwind_expanded_macro_loc): Likewise. + +2024-06-18 David Malcolm + + * Makefile.in (OBJS): Add diagnostic-macro-unwinding.o. + +2024-06-18 David Malcolm + + * diagnostic-format-json.cc: Include "diagnostic-path.h" and + "logical-location.h". + (make_json_for_path): Move tree-diagnostic-path.cc's + default_tree_make_json_for_path here, renaming it and making it + static. + (json_output_format::on_end_diagnostic): Replace call of + m_context's m_make_json_for_path callback with a direct call to + make_json_for_path. + * diagnostic.h (diagnostic_context::m_make_json_for_path): Drop + field. + * tree-diagnostic-path.cc: Drop include of "json.h". + (default_tree_make_json_for_path): Rename to make_json_for_path + and move to diagnostic-format-json.cc. + * tree-diagnostic.cc (tree_diagnostics_defaults): Drop + initialization of m_make_json_for_path. + * tree-diagnostic.h (default_tree_make_json_for): Delete decl. + +2024-06-18 David Malcolm + + * Makefile.in (OBJS): Add selftest-diagnostic-path.o and + selftest-logical-location.o. + * logical-location.h: Include "label-text.h". + (class logical_location): Update leading comment. + * selftest-diagnostic-path.cc: New file, adapted from + simple-diagnostic-path.cc and from material in + tree-diagnostic-path.cc. + * selftest-diagnostic-path.h: New file, adapted from + simple-diagnostic-path.h and from material in + tree-diagnostic-path.cc. + * selftest-logical-location.cc: New file. + * selftest-logical-location.h: New file. + * tree-diagnostic-path.cc: Remove includes of "tree-pretty-print.h", + "langhooks.h", and "simple-diagnostic-path.h". Add include of + "selftest-diagnostic-path.h". + (class test_diagnostic_path): Delete, in favor of new + implementation in selftest-diagnostic-path.{h,cc}, which is + directly derived from diagnostic_path, rather than from + simple_diagnostic_path. + (selftest::test_intraprocedural_path): Eliminate tree usage, + via change to test_diagnostic_path, using strings rather than + function_decls for identifying functions in the test. + (selftest::test_interprocedural_path_1): Likewise. + (selftest::test_interprocedural_path_2): Likewise. + (selftest::test_recursion): Likewise. + (selftest::test_control_flow_1): Likewise. + (selftest::test_control_flow_2): Likewise. + (selftest::test_control_flow_3): Likewise. + (selftest::assert_cfg_edge_path_streq): Likewise. + (selftest::test_control_flow_5): Likewise. + (selftest::test_control_flow_6): Likewise. + +2024-06-18 David Malcolm + + * diagnostic.cc: Include "logical-location.h". + (diagnostic_path::get_first_event_in_a_function): Fix typo in + leading comment. Rewrite to use logical_location rather than + tree. Drop test on stack depth. + (diagnostic_path::interprocedural_p): Rewrite to use + logical_location rather than tree. + (logical_location::function_p): New. + * diagnostic-path.h (diagnostic_event::get_fndecl): Eliminate + vfunc. + (diagnostic_path::same_function_p): New pure virtual func. + * logical-location.h (logical_location::get_name_for_path_output): + New pure virtual func. + * simple-diagnostic-path.cc + (simple_diagnostic_path::same_function_p): New. + (simple_diagnostic_event::simple_diagnostic_event): Initialize + m_logical_loc. + * simple-diagnostic-path.h: Include "tree-logical-location.h". + (simple_diagnostic_event::get_fndecl): Convert from a vfunc + implementation to an accessor. + (simple_diagnostic_event::get_logical_location): Use + m_logical_loc. + (simple_diagnostic_event::m_logical_loc): New field. + (simple_diagnostic_path::same_function_p): New decl. + * tree-diagnostic-path.cc: Move pragma disabling -Wformat-diag to + cover the whole file. + (can_consolidate_events): Add params "path", "ev1_idx", and + "ev2_idx". Rewrite to use diagnostic_path::same_function_p rather + than tree. + (per_thread_summary::per_thread_summary): Add "path" param + (per_thread_summary::m_path): New field. + (event_range::event_range): Update for conversion of m_fndecl to + m_logical_loc. + (event_range::maybe_add_event): Rename param "idx" to + "new_ev_idx". Update call to can_consolidate_events to pass in + "m_path", "m_start_idx", and "new_ev_idx". + (event_range::m_fndecl): Replace with... + (event_range::m_logical_loc): ...this. + (path_summary::get_or_create_events_for_thread_id): Pass "path" to + per_thread_summary ctor. + (per_thread_summary::interprocedural_p): Rewrite to use + diagnostic_path::same_function_p rather than tree. + (print_fndecl): Delete. + (thread_event_printer::print_swimlane_for_event_range): Update for + conversion from tree to logical_location. + (default_tree_diagnostic_path_printer): Likewise. + (default_tree_make_json_for_path): Likewise. + * tree-logical-location.cc: Include "intl.h". + (compiler_logical_location::get_name_for_tree_for_path_output): + New. + (tree_logical_location::get_name_for_path_output): New. + (current_fndecl_logical_location::get_name_for_path_output): New. + * tree-logical-location.h + (compiler_logical_location::get_name_for_tree_for_path_output): + New decl. + (tree_logical_location::get_name_for_path_output): New decl. + (current_fndecl_logical_location::get_name_for_path_output): New + decl. + +2024-06-18 David Malcolm + + * Makefile.in (OBJS): Add simple-diagnostic-path.o. + * diagnostic-path.h (class simple_diagnostic_event): Move to + simple-diagnostic-path.h. + (class simple_diagnostic_thread): Likewise. + (class simple_diagnostic_path): Likewise. + * diagnostic.cc (simple_diagnostic_path::simple_diagnostic_path): + Move to simple-diagnostic-path.cc. + (simple_diagnostic_path::num_events): Likewise. + (simple_diagnostic_path::get_event): Likewise. + (simple_diagnostic_path::num_threads): Likewise. + (simple_diagnostic_path::get_thread): Likewise. + (simple_diagnostic_path::add_thread): Likewise. + (simple_diagnostic_path::add_event): Likewise. + (simple_diagnostic_path::add_thread_event): Likewise. + (simple_diagnostic_path::connect_to_next_event): Likewise. + (simple_diagnostic_event::simple_diagnostic_event): Likewise. + (simple_diagnostic_event::~simple_diagnostic_event): Likewise. + * selftest-run-tests.cc (selftest::run_tests): Call + selftest::simple_diagnostic_path_cc_tests. + * selftest.h (selftest::simple_diagnostic_path_cc_tests): New + decl. + * simple-diagnostic-path.cc: New file, from the above material. + * simple-diagnostic-path.h: New file, from the above material + from diagnostic-path.h. + * tree-diagnostic-path.cc: Include "simple-diagnostic-path.h". + +2024-06-18 Pan Li + + * match.pd: Add form 7 and 8 for the unsigned .SAT_ADD match. + +2024-06-18 Pan Li + + * match.pd: Add form 11 match pattern for .SAT_SUB. + +2024-06-18 Richard Biener + + PR tree-optimization/115537 + * tree-vect-loop.cc (vectorizable_reduction): Also reject + SLP condition reductions of EXTRACT_LAST kind when multiple + statement copies are involved. + +2024-06-18 Jeff Law + + * config/riscv/bitmanip.md (bset splitters): New patterns for + generating bset when bit position is limited. + +2024-06-18 Richard Sandiford + + * config/aarch64/aarch64.cc (aarch64_addti_scratch_regs): Use + force_highpart_subreg instead of gen_highpart and simplify_gen_subreg. + (aarch64_subvti_scratch_regs): Likewise. + +2024-06-18 Richard Sandiford + + * explow.h (force_highpart_subreg): Declare. + * explow.cc (force_highpart_subreg): New function. + * builtins.cc (expand_builtin_issignaling): Use it. + * expmed.cc (emit_store_flag_1): Likewise. + +2024-06-18 Richard Sandiford + + * builtins.cc (expand_builtin_issignaling): Use force_lowpart_subreg + instead of simplify_gen_subreg and lowpart_subreg. + * expr.cc (convert_mode_scalar, expand_expr_real_2): Likewise. + * optabs.cc (expand_doubleword_mod): Likewise. + +2024-06-18 Richard Sandiford + + PR target/115464 + * config/aarch64/aarch64-builtins.cc (aarch64_expand_fcmla_builtin) + (aarch64_expand_rwsr_builtin): Use force_lowpart_subreg instead of + simplify_gen_subreg and lowpart_subreg. + * config/aarch64/aarch64-sve-builtins-base.cc + (svset_neonq_impl::expand): Likewise. + * config/aarch64/aarch64-sve-builtins-sme.cc + (add_load_store_slice_operand): Likewise. + * config/aarch64/aarch64.cc (aarch64_sve_reinterpret): Likewise. + (aarch64_addti_scratch_regs, aarch64_subvti_scratch_regs): Likewise. + +2024-06-18 Richard Sandiford + + * explow.h (force_lowpart_subreg): Declare. + * explow.cc (force_lowpart_subreg): New function. + * optabs.cc (lowpart_subreg_maybe_copy): Delete. + (expand_absneg_bit): Use force_lowpart_subreg instead of + lowpart_subreg_maybe_copy. + (expand_copysign_bit): Likewise. + +2024-06-18 Richard Sandiford + + * expmed.cc (store_bit_field_using_insv): Use force_subreg + instead of simplify_gen_subreg. + (store_bit_field_1): Likewise. + (extract_bit_field_as_subreg): Likewise. + (extract_integral_bit_field): Likewise. + (emit_store_flag_1): Likewise. + * expr.cc (convert_move): Likewise. + (convert_modes): Likewise. + (emit_group_load_1): Likewise. + (emit_group_store): Likewise. + (expand_assignment): Likewise. + +2024-06-18 Richard Sandiford + + * config/aarch64/aarch64-builtins.cc (aarch64_expand_fcmla_builtin): + Use force_subreg instead of simplify_gen_subreg. + * config/aarch64/aarch64-simd.md (ctz2): Likewise. + * config/aarch64/aarch64-sve-builtins-base.cc + (svget_impl::expand): Likewise. + (svget_neonq_impl::expand): Likewise. + * config/aarch64/aarch64-sve-builtins-functions.h + (multireg_permute::expand): Likewise. + +2024-06-18 Richard Sandiford + + * explow.cc (force_subreg): Emit no instructions on failure. + +2024-06-18 Jakub Jelinek + + PR target/115324 + * config/rs6000/rs6000-gen-builtins.cc (write_decls): Change + declaration of rs6000_init_generated_builtins from no arguments + to 4 pointer arguments. + (write_init_bif_table): Change rs6000_builtin_info_fntype to + builtin_info_fntype and rs6000_builtin_decls to builtin_decls. + (write_init_ovld_table): Change rs6000_instance_info_fntype to + instance_info_fntype, rs6000_builtin_decls to builtin_decls and + rs6000_overload_info to overload_info. + (write_init_file): Add __noipa__ attribute to + rs6000_init_generated_builtins for GCC 8.1+ and change the function + from no arguments to 4 pointer arguments. Change rs6000_builtin_decls + to builtin_decls. + * config/rs6000/rs6000-builtin.cc (rs6000_init_builtins): Adjust + rs6000_init_generated_builtins caller. + +2024-06-18 Richard Biener + + PR tree-optimization/115493 + * tree-vect-loop.cc (vect_create_epilog_for_reduction): Use + the first scalar result. + +2024-06-18 Richard Biener + + PR tree-optimization/111793 + * tree-ssa-alias.h (ref_can_have_store_data_races): Declare. + * tree-ssa-alias.cc (ref_can_have_store_data_races): New + function. + * tree-if-conv.cc (ifcvt_memrefs_wont_trap): Use + ref_can_have_store_data_races to allow more unconditional + stores. + * tree-ssa-loop-im.cc (execute_sm): Likewise. + * tree-ssa-phiopt.cc (cond_store_replacement): Likewise. + +2024-06-18 Hu, Lin1 + + * config/i386/avxintrin.h: Move cmp[p|s][s|d] to [e|x]mmintrin.h, + and move macros to xmmintrin.h + * config/i386/emmintrin.h: Add cmp[p|s]s intrins. + * config/i386/i386-builtin.def: Modify __builtin_ia32_cmp[p|s][s|d]. + * config/i386/i386-expand.cc + (ix86_expand_args_builtin): Raise error when imm is in range of + [8, 32] without avx. + * config/i386/predicates.md (cmpps_imm_operand): New predicate. + * config/i386/sse.md (avx_cmp3): Modefy define_insn. + (avx_vmcmp3): Ditto. + * config/i386/xmmintrin.h (_CMP_EQ_OQ): New macro for sse/sse2. + (_CMP_LT_OS): Ditto + (_CMP_LE_OS): Ditto + (_CMP_UNORD_Q): Ditto + (_CMP_NEQ_UQ): Ditto + (_CMP_NLT_US): Ditto + (_CMP_NLE_US): Ditto + (_CMP_ORD_Q): Ditto + (_mm_cmp_ps): Move intrin from avxintrin.h to xmmintrin.h + (_mm_cmp_ss): Ditto. + +2024-06-17 Jeff Law + + * config/riscv/bitmanip.md (bsetclr_zero_extract): New pattern. + +2024-06-17 Jakub Jelinek + + PR driver/115440 + * opts-common.cc (add_misspelling_candidates): If opt1 is non-NULL, + add a space and opt1 to the alternative suggestion text. + +2024-06-17 Patrick O'Neill + + * common/config/riscv/riscv-common.cc + (riscv_subset_list::to_string): Skip zaamo/zalrsc when not + supported by the assembler. + * config.in: Regenerate. + * configure: Regenerate. + * configure.ac: Add zaamo/zalrsc assmeber check. + +2024-06-17 Gerald Pfeifer + + * doc/install.texi (Configuration): Mark up __cxa_atexit as @code. + +2024-06-17 Peter Bergner + + PR target/115389 + * config/rs6000/rs6000-logue.cc (rs6000_stack_info): Compute + rop_hash_save_offset for non-Altivec compiles. + +2024-06-17 Jeff Law + + * config/riscv/bitmanip.md (bsetdi_2): New pattern. + +2024-06-17 Richard Biener + + PR tree-optimization/115508 + * tree-vect-slp.cc (vect_schedule_slp_node): Guard check on + representative. + +2024-06-17 Richard Biener + + Revert: + 2024-05-06 Richard Biener + + PR tree-optimization/100923 + * tree-ssa-sccvn.cc (ao_ref_init_from_vn_reference): Valueize + base SSA_NAME. + (vn_reference_lookup_3): Adjust vn_context_bb around calls + to ao_ref_init_from_vn_reference. + (vn_reference_lookup_pieces): Revert original PR100923 fix. + (vn_reference_lookup): Likewise. + +2024-06-17 Aldy Hernandez + + * data-streamer-in.cc (streamer_read_value_range): Rename + Value_Range to value_range. + * data-streamer.h (streamer_read_value_range): Same. + * gimple-pretty-print.cc (dump_ssaname_info): Same. + * gimple-range-cache.cc (ssa_block_ranges::dump): Same. + (ssa_lazy_cache::merge): Same. + (block_range_cache::dump): Same. + (ssa_cache::merge_range): Same. + (ssa_cache::dump): Same. + (ranger_cache::edge_range): Same. + (ranger_cache::propagate_cache): Same. + (ranger_cache::fill_block_cache): Same. + (ranger_cache::resolve_dom): Same. + (ranger_cache::range_from_dom): Same. + (ranger_cache::register_inferred_value): Same. + * gimple-range-fold.cc (op1_range): Same. + (op2_range): Same. + (fold_relations): Same. + (fold_using_range::range_of_range_op): Same. + (fold_using_range::range_of_phi): Same. + (fold_using_range::range_of_call): Same. + (fold_using_range::condexpr_adjust): Same. + (fold_using_range::range_of_cond_expr): Same. + (fur_source::register_outgoing_edges): Same. + * gimple-range-fold.h (gimple_range_type): Same. + (gimple_range_ssa_p): Same. + * gimple-range-gori.cc (gori_compute::compute_operand_range): Same. + (gori_compute::logical_combine): Same. + (gori_compute::refine_using_relation): Same. + (gori_compute::compute_operand1_range): Same. + (gori_compute::compute_operand2_range): Same. + (gori_compute::compute_operand1_and_operand2_range): Same. + (gori_calc_operands): Same. + (gori_name_helper): Same. + * gimple-range-infer.cc (gimple_infer_range::check_assume_func): Same. + (gimple_infer_range::gimple_infer_range): Same. + (infer_range_manager::maybe_adjust_range): Same. + (infer_range_manager::add_range): Same. + * gimple-range-infer.h: Same. + * gimple-range-op.cc + (gimple_range_op_handler::gimple_range_op_handler): Same. + (gimple_range_op_handler::calc_op1): Same. + (gimple_range_op_handler::calc_op2): Same. + (gimple_range_op_handler::maybe_builtin_call): Same. + * gimple-range-path.cc (path_range_query::internal_range_of_expr): Same. + (path_range_query::ssa_range_in_phi): Same. + (path_range_query::compute_ranges_in_phis): Same. + (path_range_query::compute_ranges_in_block): Same. + (path_range_query::add_to_exit_dependencies): Same. + * gimple-range-trace.cc (debug_seed_ranger): Same. + * gimple-range.cc (gimple_ranger::range_of_expr): Same. + (gimple_ranger::range_on_entry): Same. + (gimple_ranger::range_on_edge): Same. + (gimple_ranger::range_of_stmt): Same. + (gimple_ranger::prefill_stmt_dependencies): Same. + (gimple_ranger::register_inferred_ranges): Same. + (gimple_ranger::register_transitive_inferred_ranges): Same. + (gimple_ranger::export_global_ranges): Same. + (gimple_ranger::dump_bb): Same. + (assume_query::calculate_op): Same. + (assume_query::calculate_phi): Same. + (assume_query::dump): Same. + (dom_ranger::range_of_stmt): Same. + * ipa-cp.cc (ipcp_vr_lattice::meet_with_1): Same. + (ipa_vr_operation_and_type_effects): Same. + (ipa_value_range_from_jfunc): Same. + (propagate_bits_across_jump_function): Same. + (propagate_vr_across_jump_function): Same. + (ipcp_store_vr_results): Same. + * ipa-cp.h: Same. + * ipa-fnsummary.cc (evaluate_conditions_for_known_args): Same. + (evaluate_properties_for_edge): Same. + * ipa-prop.cc (struct ipa_vr_ggc_hash_traits): Same. + (ipa_vr::get_vrange): Same. + (ipa_vr::streamer_read): Same. + (ipa_vr::streamer_write): Same. + (ipa_vr::dump): Same. + (ipa_set_jfunc_vr): Same. + (ipa_compute_jump_functions_for_edge): Same. + (ipcp_get_parm_bits): Same. + (ipcp_update_vr): Same. + (ipa_record_return_value_range): Same. + (ipa_return_value_range): Same. + * ipa-prop.h (ipa_return_value_range): Same. + (ipa_record_return_value_range): Same. + * range-op.h (range_cast): Same. + * tree-ssa-dom.cc + (dom_opt_dom_walker::set_global_ranges_from_unreachable_edges): Same. + (cprop_operand): Same. + * tree-ssa-loop-ch.cc (loop_static_stmt_p): Same. + * tree-ssa-loop-niter.cc (record_nonwrapping_iv): Same. + * tree-ssa-loop-split.cc (split_at_bb_p): Same. + * tree-ssa-phiopt.cc (value_replacement): Same. + * tree-ssa-strlen.cc (get_range): Same. + * tree-ssa-threadedge.cc (hybrid_jt_simplifier::simplify): Same. + (hybrid_jt_simplifier::compute_exit_dependencies): Same. + * tree-ssanames.cc (set_range_info): Same. + (duplicate_ssa_name_range_info): Same. + * tree-vrp.cc (remove_unreachable::handle_early): Same. + (remove_unreachable::remove_and_update_globals): Same. + (execute_ranger_vrp): Same. + * value-query.cc (range_query::value_of_expr): Same. + (range_query::value_on_edge): Same. + (range_query::value_of_stmt): Same. + (range_query::value_on_entry): Same. + (range_query::value_on_exit): Same. + (range_query::get_tree_range): Same. + * value-range-storage.cc (vrange_storage::set_vrange): Same. + * value-range.cc (Value_Range::dump): Same. + (value_range::dump): Same. + (debug): Same. + * value-range.h (enum value_range_discriminator): Same. + (class vrange): Same. + (class Value_Range): Same. + (class value_range): Same. + (Value_Range::Value_Range): Same. + (value_range::value_range): Same. + (Value_Range::~Value_Range): Same. + (value_range::~value_range): Same. + (Value_Range::set_type): Same. + (value_range::set_type): Same. + (Value_Range::init): Same. + (value_range::init): Same. + (Value_Range::operator=): Same. + (value_range::operator=): Same. + (Value_Range::operator==): Same. + (value_range::operator==): Same. + (Value_Range::operator!=): Same. + (value_range::operator!=): Same. + (Value_Range::supports_type_p): Same. + (value_range::supports_type_p): Same. + * vr-values.cc (simplify_using_ranges::fold_cond_with_ops): Same. + (simplify_using_ranges::legacy_fold_cond): Same. + +2024-06-17 Hu, Lin1 + + PR target/115161 + * config/i386/i386-builtin.def: Change CODE_FOR_* for cvtt*'s builtins. + * config/i386/sse.md: + (unspec_avx512fp16_fix + _trunc2): + Use UNSPEC instead of FIX/UNSIGNED_FIX. + (unspec_avx512fp16_fix_trunc2): + Ditto. + (unspec_avx512fp16_fix_truncv2di2): Ditto. + (unspec_avx512fp16_fix_trunc2): + Ditto. + (unspec_sse_cvttps2pi): Ditto. + (unspec_sse_cvttss2si): Ditto. + (unspec_fix_truncv16sfv16si2): + Ditto. + (unspec_fix_truncv8sfv8si2): Ditto. + (unspec_fix_truncv4sfv4si2): Ditto. + (unspec_sse2_cvttpd2pi): Ditto. + (unspec_fixuns_truncv2dfv2si2): Ditto. + (unspec_avx512f_vcvttss2usi): + Ditto. + (unspec_avx512f_vcvttsd2usi): + Ditto. + (unspec_sse2_cvttsd2si): Ditto. + (unspec_fix_truncv8dfv8si2): + Ditto. + (*unspec_fixuns_truncv2dfv2si2): Ditto. + (unspec_fixuns_truncv2dfv2si2_mask): Ditto. + (unspec_fix_truncv4dfv4si2): Ditto. + (unspec_fixuns_truncv4dfv4si2): Ditto. + (unspec_fix + _trunc2): + Ditto. + (unspec_fix + _trunc2): + Ditto. + (unspec_avx512dq_fix_truncv2sfv2di2): + Ditto. + (unspec_fixuns_trunc2): + Ditto. + (unspec_sse2_cvttpd2dq): Ditto. + +2024-06-17 Levy Hsu + + * config/i386/i386-expand.cc + (ix86_vectorize_vec_perm_const): Convert BF to HI using subreg. + * config/i386/predicates.md + (vcvtne2ps2bf_parallel): New define_insn_and_split. + * config/i386/sse.md + (vpermt2_sepcial_bf16_shuffle_): New predicates matches odd increasing perm. + +2024-06-17 Stefan Schulze Frielinghaus + + * config/s390/vector.md (*vmrhf_half): New. + (extendv2sfv2df2): New. + +2024-06-17 Stefan Schulze Frielinghaus + + PR target/115261 + * config/s390/s390.md (any_extend,extend_insn,zero_extend): + New code attributes and code iterator. + * config/s390/vector.md (V_EXTEND): New mode iterator. + (2): New insn. + +2024-06-16 Andrew Pinski + + PR target/100211 + * config/aarch64/aarch64.h (machine_function): Fix the size + of reg_is_wrapped_separately. + +2024-06-16 Jeff Law + + * config/riscv/bitmanip.md ((1 << N) | C): New splitter for IOR/XOR + of a single bit an a DImode object. + +2024-06-16 Jeff Law + + * config/sh/sh.md (neg_zero_extract_4b): New pattern. + +2024-06-16 Peter Damianov + + * pretty-print.cc (mingw_ansi_fputs): Don't translate escape sequences if + the console has ENABLE_VIRTUAL_TERMINAL_PROCESSING. + +2024-06-16 Peter Damianov + + * diagnostic-color.cc (auto_enable_urls): Don't hardcode to return + false on mingw hosts. + (auto_enable_urls): Return true if console + supports ansi escape sequences. + +2024-06-16 Peter Damianov + + * diagnostic-color.cc (should_colorize): Enable processing of VT100 + escape sequences on windows consoles + +2024-06-15 Christoph Müllner + + * config/riscv/riscv-target-attr.cc (riscv_target_attr_parser::parse_arch): + Fix allocation size of buffer. + (riscv_process_one_target_attr): Likewise. + (riscv_process_target_attr): Likewise. + +2024-06-15 Gerald Pfeifer + + PR target/69374 + * doc/install.texi (Specific): Remove pointer to old versions + of binutils. + +2024-06-14 Andrew MacLeod + + * gimple-range-gori.cc (gori_calc_operands): Do not continue nor + add the range when VARYING is produced for an operand. + +2024-06-14 Andrew MacLeod + + * gimple-range-cache.cc (ssa_lazy_cache::merge): New. + * gimple-range-cache.h (ssa_lazy_cache::merge): New prototype. + +2024-06-14 Andrew MacLeod + + * gimple-range-fold.cc (fold_using_range::range_of_call): Ensure + LHS is an SSA_NAME before invoking gimple_range_global. + +2024-06-14 Pan Li + + * match.pd: Add more match for unsigned sat_sub. + * tree-ssa-math-opts.cc (match_unsigned_saturation_sub): Add new + func impl to match phi node for .SAT_SUB. + (math_opts_dom_walker::after_dom_children): Try match .SAT_SUB + for the phi node, MULT_EXPR, BIT_XOR_EXPR and BIT_AND_EXPR. + +2024-06-14 Jan Beulich + + * configure.ac: Drop ${objdir}/ from NM and AR. Move setting of + ld_ver out of conditional. + * configure: Re-generate. + +2024-06-14 Richard Biener + + * tree-vect-loop.cc (vectorizable_reduction): Allow + single-def-use cycles with SLP. + (vect_transform_reduction): Handle SLP single def-use cycles. + (vect_transform_cycle_phi): Likewise. + +2024-06-14 Gerald Pfeifer + + * doc/invoke.texi (x86 Options): Consolidate duplicate MOVBE + listings for haswell, broadwell, skylake, skylake-avx512, + cannonlake, icelake-client, icelake-server, cascadelake, + cooperlake, tigerlake, sapphirerapids, rocketlake, graniterapids, + and graniterapids-d options to -march. + +2024-06-14 Pan Li + + PR target/115456 + * config/riscv/vector-iterators.md: Leverage V_ZVFH instead of V + which contains the VF_ZVFHMIN for alignment. + +2024-06-14 Gerald Pfeifer + + PR target/69374 + * doc/install.texi (Specific): Remove stale reference to Interix. + +2024-06-14 Richard Biener + + * tree-vect-stmts.cc (get_group_load_store_type): Do not + re-use poly-int remain but re-compute with non-poly values. + Verify the shortened load is good enough to be covered with + a single scalar gap iteration before accepting it. + +2024-06-14 liuhongt + + * config/i386/i386.cc (ix86_rtx_costs): Adjust rtx_cost for + pternlog_operand under AVX512, also adjust VEC_DUPLICATE + according since vec_dup:mem can't be that cheap. + +2024-06-14 liuhongt + + * config/i386/x86-tune.def (X86_TUNE_ONE_IF_CONV_INSN): Remove + latest Intel processors. + Co-authored by: Lingling Kong + +2024-06-14 Roger Sayle + + * config/i386/i386-expand.cc (ix86_expand_ternlog): Try performing + logic operation in a different vector mode if that enables use of + a 32-bit or 64-bit broadcast addressing mode. + +2024-06-14 Andrew Pinski + + PR middle-end/113212 + * expr.h (const_seqpops): New typedef. + (expand_expr_real_2): Constify the first argument. + * optabs.cc (expand_widen_pattern_expr): Likewise. + * optabs.h (expand_widen_pattern_expr): Likewise. + * expr.cc (expand_expr_real_2): Likewise + (do_store_flag): Likewise. Remove incorrect store to ops->code. + +2024-06-13 Patrick O'Neill + + * config/riscv/sync-rvwmo.md: Add support for subword fenced + loads/stores. + * config/riscv/sync-ztso.md: Ditto. + * config/riscv/sync.md: Ditto. + +2024-06-13 Gerald Pfeifer + + * doc/extend.texi (AArch64 Function Attributes): Add + (AVR Variable Attributes): Ditto. + (Common Type Attributes): Ditto. + +2024-06-13 Hongyu Wang + + PR target/115370 + PR target/115463 + * target.def (have_ccmp): New target hook. + * targhooks.cc (default_have_ccmp): New function. + * targhooks.h (default_have_ccmp): New prototype. + * doc/tm.texi.in: Add TARGET_HAVE_CCMP. + * doc/tm.texi: Regenerate. + * cfgexpand.cc (expand_gimple_cond): Call targetm.have_ccmp + instead of checking if targetm.gen_ccmp_first exists. + * expr.cc (expand_expr_real_gassign): Likewise. + * config/i386/i386.cc (ix86_have_ccmp): New target hook to + check if APX_CCMP enabled. + (TARGET_HAVE_CCMP): Define. + +2024-06-13 Richard Sandiford + + PR target/115464 + * simplify-rtx.cc (simplify_context::simplify_subreg): Don't try + to fold two subregs together if their relationship isn't known + at compile time. + * explow.h (force_subreg): Declare. + * explow.cc (force_subreg): New function. + * config/aarch64/aarch64-sve-builtins-base.cc + (svset_neonq_impl::expand): Use it instead of simplify_gen_subreg. + +2024-06-13 Pan Li + + PR target/115456 + * config/riscv/autovec.md: Take ZVFH mode iterator instead of + the ZVFHMIN for the alignment. + * config/riscv/vector-iterators.md: Add 2 new iterator + V_VLS_ZVFH and VLS_ZVFH. + +2024-06-13 Hongyu Wang + + * config/i386/i386.md (@ccmp): Add new alternative + ,C and adjust output templates. Also adjust UNSPEC mode + to CCmode. + +2024-06-13 Gerald Pfeifer + + PR other/69374 + * doc/install.texi (Prerequisites): Simplify note on the C++ + compiler required. Drop requirements for versions of GCC prior + to 3.4. Fix grammar. + +2024-06-13 Richard Biener + + * tree-vect-stmts.cc (get_group_load_store_type): Consistently + use VMAT_STRIDED_SLP for strided SLP accesses and not + VMAT_ELEMENTWISE. + (vectorizable_store): Adjust VMAT_STRIDED_SLP handling to + allow not only half-size but also smaller accesses. + (vectorizable_load): Likewise. + +2024-06-13 Richard Biener + + PR tree-optimization/115385 + * tree-vect-stmts.cc (get_group_load_store_type): Peeling + of a single scalar iteration is sufficient if we can narrow + the access to the next power of two of the bits in the last + access. + (vectorizable_load): Ensure that the last access is narrowed. + +2024-06-13 Richard Biener + + PR tree-optimization/114107 + PR tree-optimization/110445 + * tree-vect-stmts.cc (get_group_load_store_type): Refactor + contiguous access case. Make sure peeling for gap constraints + are always tested and consistently relax when we know we can + avoid touching excess elements during code generation. But + rewrite the check poly-int aware. + +2024-06-13 Andi Kleen + + * doc/extend.texi: Use std::string_view in asm constexpr + example. + +2024-06-13 liuhongt + + PR target/115452 + * config/i386/i386-features.cc (scalar_chain::convert_op): Use + reg_or_subregno instead of REGNO to avoid ICE. + +2024-06-13 YunQiang Su + + * config/mips/mips-cpus.def: Use PROCESSOR_24KF1_1 for mips32; + Use PROCESSOR_5KF for mips64/mips64r2/mips64r3/mips64r5. + +2024-06-13 YunQiang Su + + * config/mips/mips-modes.def: New CC_MODE CCE. + * config/mips/mips-protos.h(mips_output_compare): New function. + * config/mips/mips.cc(mips_allocate_fcc): Set CCEmode count=1. + (mips_emit_compare): Use CCEmode for LTGT/LT/LE for pre-R6. + (mips_output_compare): New function. Convert lt/le to slt/sle + for R6; convert ueq to ngl for CCEmode. + (mips_hard_regno_mode_ok_uncached): Mention CCEmode. + * config/mips/mips.h: Mention CCEmode for LOAD_EXTEND_OP. + * config/mips/mips.md(FPCC): Add CCE. + (define_mode_iterator MOVECC): Mention CCE. + (define_mode_attr reg): Add CCE with "z". + (define_mode_attr fpcmp): Add CCE with "c". + (define_code_attr fcond): ltgt should use sne instead of ne. + (s__using_): call mips_output_compare. + +2024-06-13 Lingling Kong + + * config/i386/i386-opts.h (enum apx_features): Add apx_zu. + * config/i386/i386.h (TARGET_APX_ZU): Define. + * config/i386/i386.md (*imulhizu): New define_insn. + (*setcc__zu): Ditto. + * config/i386/i386.opt: Add enum value for zu. + +2024-06-12 David Malcolm + + PR bootstrap/115465 + * config/aarch64/aarch64-early-ra.cc (early_ra::process_block): + Update for fields of pretty_printer becoming private in + r15-1209-gc5e3be456888aa. + +2024-06-12 Andrew Pinski + + PR target/115176 + * config/aarch64/aarch64-simd.md (aarch64_rbit): Use + bitreverse instead of unspec. + * config/aarch64/aarch64-sve-builtins-base.cc (svrbit): Convert over to using + rtx_code_function instead of unspec_based_function. + * config/aarch64/aarch64-sve.md: Update comment where RBIT is included. + * config/aarch64/aarch64.cc (aarch64_rtx_costs): Handle BITREVERSE like BSWAP. + Remove UNSPEC_RBIT support. + * config/aarch64/aarch64.md (unspec): Remove UNSPEC_RBIT. + (aarch64_rbit): Use bitreverse instead of unspec. + * config/aarch64/iterators.md (SVE_INT_UNARY): Add bitreverse. + (optab): Likewise. + (sve_int_op): Likewise. + (SVE_INT_UNARY): Remove UNSPEC_RBIT. + (optab): Likewise. + (sve_int_op): Likewise. + (min_elem_bits): Likewise. + +2024-06-12 Andrew Pinski + + PR tree-optimization/115449 + * gimple-match-head.cc (gimple_maybe_truncate): New declaration. + (gimple_bitwise_equal_p): Match truncations that differ only + in types with the same precision. + (gimple_bitwise_inverted_equal_p): For matching after bit_not_with_nop + call gimple_bitwise_equal_p. + * match.pd (maybe_truncate): New match pattern. + +2024-06-12 Victor Do Nascimento + + PR tree-optimization/114061 + * tree-data-ref.cc (get_references_in_stmt): set + `clobbers_memory' to false for __builtin_prefetch. + * tree-vect-loop.cc (vect_transform_loop): Drop all + __builtin_prefetch calls from loops. + +2024-06-12 David Malcolm + + * dumpfile.cc (dump_pretty_printer::emit_items): Update for + changes to chunk_info. + * pretty-print.cc (chunk_info::append_formatted_chunk): New, based + on code in cp/error.cc's append_formatted_chunk. + (chunk_info::pop_from_output_buffer): New, based on code in + pp_output_formatted_text and dump_pretty_printer::emit_items. + (on_begin_quote): Convert to... + (chunk_info::on_begin_quote): ...this. + (on_end_quote): Convert to... + (chunk_info::on_end_quote): ...this. + (pretty_printer::format): Update for chunk_info becoming a class + and its fields gaining "m_" prefixes. Update for on_begin_quote + and on_end_quote moving to chunk_info. + (quoting_info::handle_phase_3): Update for changes to chunk_info. + (pp_output_formatted_text): Likewise. Move cleanup code to + chunk_info::pop_from_output_buffer. + * pretty-print.h (class output_buffer): New forward decl. + (class urlifier): New forward decl. + (struct chunk_info): Convert to... + (class chunk_info): ...this. Add friend class pretty_printer. + (chunk_info::get_args): New accessor. + (chunk_info::get_quoting_info): New accessor. + (chunk_info::append_formatted_chunk): New decl. + (chunk_info::pop_from_output_buffer): New decl. + (chunk_info::on_begin_quote): New decl. + (chunk_info::on_end_quote): New decl. + (chunk_info::prev): Rename to... + (chunk_info::m_prev): ...this. + (chunk_info::args): Rename to... + (chunk_info::m_args): ...this. + (output_buffer::cur_chunk_array): Drop "struct" from decl. + +2024-06-12 David Malcolm + + * diagnostic.cc (diagnostic_context::urls_init): Update for fields + of pretty_printer becoming private. + (diagnostic_context::print_any_cwe): Likewise. + (diagnostic_context::print_any_rules): Likewise. + (diagnostic_context::print_option_information): Likewise. + * diagnostic.h (diagnostic_format_decoder): Likewise. + (diagnostic_prefixing_rule): Likewise, fixing typo. + * digraph.cc (test_dump_to_dot): Likewise. + * digraph.h (digraph::dump_dot_to_file): Likewise. + * dumpfile.cc + (dump_pretty_printer::emit_any_pending_textual_chunks): Likewise. + * gimple-pretty-print.cc (print_gimple_stmt): Likewise. + (print_gimple_expr): Likewise. + (print_gimple_seq): Likewise. + (dump_ssaname_info_to_file): Likewise. + (gimple_dump_bb): Likewise. + * graph.cc (print_graph_cfg): Likewise. + (start_graph_dump): Likewise. + * langhooks.cc (lhd_print_error_function): Likewise. + * lto-wrapper.cc (print_lto_docs_link): Likewise. + * pretty-print.cc (pp_set_real_maximum_length): Convert to... + (pretty_printer::set_real_maximum_length): ...this. + (pp_clear_state): Convert to... + (pretty_printer::clear_state): ...this. + (pp_wrap_text): Update for pp_remaining_character_count_for_line + becoming a member function. + (urlify_quoted_string): Update for fields of pretty_printer becoming + private. + (pp_format): Convert to... + (pretty_printer::format): ...this. Reduce the scope of local + variables "old_line_length" and "old_wrapping_mode" and make + const. Reduce the scope of locals "args", "new_chunk_array", + "curarg", "any_unnumbered", and "any_numbered". + (pp_output_formatted_text): Update for fields of pretty_printer + becoming private. + (pp_flush): Likewise. + (pp_really_flush): Likewise. + (pp_set_line_maximum_length): Likewise. + (pp_set_prefix): Convert to... + (pretty_printer::set_prefix): ...this. + (pp_take_prefix): Update for fields of pretty_printer gaining + "m_" prefixes. + (pp_destroy_prefix): Likewise. + (pp_emit_prefix): Convert to... + (pretty_printer::emit_prefix): ...this. + (pretty_printer::pretty_printer): Update both ctors for fields + gaining "m_" prefixes. + (pretty_printer::~pretty_printer): Likewise for dtor. + (pp_append_text): Update for pp_emit_prefix becoming + pretty_printer::emit_prefix. + (pp_remaining_character_count_for_line): Convert to... + (pretty_printer::remaining_character_count_for_line): ...this. + (pp_character): Update for above change. + (pp_maybe_space): Convert to... + (pretty_printer::maybe_space): ...this. + (pp_begin_url): Convert to... + (pretty_printer::begin_url): ...this. + (get_end_url_string): Update for fields of pretty_printer + becoming private. + (pp_end_url): Convert to... + (pretty_printer::end_url): ...this. + (selftest::test_pretty_printer::test_pretty_printer): Update for + fields of pretty_printer becoming private. + (selftest::test_urls): Likewise. + (selftest::test_null_urls): Likewise. + (selftest::test_urlification): Likewise. + * pretty-print.h (pp_line_cutoff): Convert from macro to inline + function. + (pp_prefixing_rule): Likewise. + (pp_wrapping_mode): Likewise. + (pp_format_decoder): Likewise. + (pp_needs_newline): Likewise. + (pp_indentation): Likewise. + (pp_translate_identifiers): Likewise. + (pp_show_color): Likewise. + (pp_buffer): Likewise. + (pp_get_prefix): Add forward decl to allow friend decl. + (pp_take_prefix): Likewise. + (pp_destroy_prefix): Likewise. + (class pretty_printer): Fix typo in leading comment. Add + "friend" decls for the various new accessor functions that were + formerly macros and for pp_get_prefix, pp_take_prefix, and + pp_destroy_prefix. Make all fields private. + (pretty_printer::set_output_stream): New. + (pretty_printer::set_prefix): New decl. + (pretty_printer::emit_prefix): New decl. + (pretty_printer::format): New decl. + (pretty_printer::maybe_space): New decl. + (pretty_printer::supports_urls_p): New. + (pretty_printer::get_url_format): New. + (pretty_printer::set_url_format): New. + (pretty_printer::begin_url): New decl. + (pretty_printer::end_url): New decl. + (pretty_printer::set_verbatim_wrapping): New. + (pretty_printer::set_padding): New. + (pretty_printer::get_padding): New. + (pretty_printer::clear_state): New decl. + (pretty_printer::set_real_maximum_length): New decl. + (pretty_printer::remaining_character_count_for_line): New decl. + (pretty_printer::buffer): Rename to... + (pretty_printer::m_buffer): ...this. + (pretty_printer::prefix): Rename to... + (pretty_printer::m_prefix): ...this; + (pretty_printer::padding): Rename to... + (pretty_printer::m_padding): ...this; + (pretty_printer::maximum_length): Rename to... + (pretty_printer::m_maximum_length): ...this; + (pretty_printer::indent_skip): Rename to... + (pretty_printer::m_indent_skip): ...this; + (pretty_printer::wrapping): Rename to... + (pretty_printer::m_wrapping): ...this; + (pretty_printer::format_decoder): Rename to... + (pretty_printer::m_format_decoder): ...this; + (pretty_printer::emitted_prefix): Rename to... + (pretty_printer::m_emitted_prefix): ...this; + (pretty_printer::need_newline): Rename to... + (pretty_printer::m_need_newline): ...this; + (pretty_printer::translate_identifiers): Rename to... + (pretty_printer::m_translate_identifiers): ...this; + (pretty_printer::show_color): Rename to... + (pretty_printer::m_show_color): ...this; + (pretty_printer::url_format): Rename to... + (pretty_printer::m_url_format): ...this; + (pp_get_prefix): Reformat. + (pp_format_postprocessor): New inline function. + (pp_take_prefix): Move decl to before class pretty_printer. + (pp_destroy_prefix): Likewise. + (pp_set_prefix): Convert to inline function. + (pp_emit_prefix): Convert to inline function. + (pp_format): Convert to inline function. + (pp_maybe_space): Convert to inline function. + (pp_begin_url): Convert to inline function. + (pp_end_url): Convert to inline function. + (pp_set_verbatim_wrapping): Convert from macro to inline + function, renaming... + (pp_set_verbatim_wrapping_): ...this. + * print-rtl.cc (dump_value_slim): Update for fields of + pretty_printer becoming private. + (dump_insn_slim): Likewise. + (dump_rtl_slim): Likewise. + * print-tree.cc (print_node): Likewise. + * sched-rgn.cc (dump_rgn_dependencies_dot): Likewise. + * text-art/canvas.cc (canvas::print_to_pp): Likewise. + (canvas::debug): Likewise. + (selftest::test_canvas_urls): Likewise. + * text-art/dump.h (dump_to_file): Likewise. + * text-art/selftests.cc (selftest::assert_canvas_streq): Likewise. + * text-art/style.cc (style::print_changes): Likewise. + * text-art/styled-string.cc (styled_string::from_fmt_va): + Likewise. + * tree-diagnostic-path.cc (control_flow_tests): Update for + pp_show_color becoming an inline function. + * tree-loop-distribution.cc (dot_rdg_1): Update for fields of + pretty_printer becoming private. + * tree-pretty-print.cc (maybe_init_pretty_print): Likewise. + * value-range.cc (vrange::dump): Likewise. + (irange_bitmask::dump): Likewise. + +2024-06-12 David Malcolm + + * gimple-pretty-print.cc: Rename pretty_printer "buffer" to "pp" + throughout. + * print-tree.cc (print_node): Likewise. + * tree-loop-distribution.cc (dot_rdg_1): Likewise. + * tree-pretty-print.h (dump_location): Likewise. + * value-range.cc (vrange::dump): Likewise. + (irange_bitmask::dump): Likewise. + +2024-06-12 Xi Ruoyao + + * config/loongarch/predicates.md (high_bitmask_operand): New + predicate. + * config/loongarch/constraints.md (Yy): New constriant. + * config/loongarch/loongarch.md (and3_align): New + define_insn_and_split. + +2024-06-12 Xi Ruoyao + + * config/loongarch/loongarch.cc + (loongarch_expand_conditional_move): Compare mode size with + UNITS_PER_WORD instead of word_mode. + +2024-06-12 Torbjörn SVENSSON + Yvan ROUX + + PR target/115253 + * config/arm/arm.cc (cmse_nonsecure_call_inline_register_clear): + Sign extend for Thumb1. + (thumb1_expand_prologue): Add zero/sign extend. + +2024-06-12 Gerald Pfeifer + + PR target/69374 + * doc/install.texi (Specific) <*-*-cygwin>: Update web link. + +2024-06-12 Pan Li + + * tree-ssa-math-opts.cc (math_opts_dom_walker::after_dom_children): + Leverage gsi_after_labels instead of gsi_start_bb to skip the + leading labels of bb. + +2024-06-12 Gerald Pfeifer + + PR target/69374 + * doc/install.texi (Specific) <*-*-linux-gnu>: Do not list + glibc 2.1 and binutils 2.12 as minimum dependencies. + +2024-06-12 Alexandre Oliva + + PR tree-optimization/113681 + * tree-profile.cc (pass_ipa_tree_profile::gate): Skip if + seen_errors. + +2024-06-12 liuhongt + + PR target/115384 + * simplify-rtx.cc (simplify_context::simplify_binary_operation_1): + Only do the simplification of (AND (ASHIFTRT A imm) mask) + to (LSHIFTRT A imm) when the component of const_vector is + CONST_INT_P. + +2024-06-11 Joseph Myers + + * doc/cpp.texi (__STDC_VERSION__): Document C2Y handling. + * doc/invoke.texi (-Wc23-c2y-compat, -std=c2y, -std=gnu2y): + Document options. + (-std=gnu23): Update documentation. + * doc/standards.texi (C Language): Document C2Y. Update C23 + description. + * config/rl78/rl78.cc (rl78_option_override): Handle "GNU C2Y" + language name. + * dwarf2out.cc (highest_c_language, gen_compile_unit_die): + Likewise. + +2024-06-11 Gerald Pfeifer + + PR target/69374 + * doc/install.texi (Specific) : Remove + redundant introduction of x86-64. + +2024-06-11 Robin Dapp + + PR tree-optimization/115382 + * tree-vect-loop.cc (vectorize_fold_left_reduction): Use + prepare_vec_mask. + * tree-vect-stmts.cc (check_load_store_for_partial_vectors): + Remove static of prepare_vec_mask. + * tree-vectorizer.h (prepare_vec_mask): Export. + +2024-06-11 Patrick O'Neill + + * config/riscv/sync.md (atomic_): New expand pattern. + (amo_atomic_): Rename amo pattern. + (atomic_fetch_): New lrsc sequence pattern. + (lrsc_atomic_): New expand pattern. + (amo_atomic_fetch_): Rename amo pattern. + (lrsc_atomic_fetch_): New lrsc sequence pattern. + (atomic_exchange): New expand pattern. + (amo_atomic_exchange): Rename amo pattern. + (lrsc_atomic_exchange): New lrsc sequence pattern. + +2024-06-11 Patrick O'Neill + + * doc/sourcebuild.texi: Add docs for atomic extension testsuite infra. + +2024-06-11 Edwin Lu + Patrick O'Neill + + * common/config/riscv/riscv-common.cc: Add Zaamo and Zalrsc. + * config/riscv/arch-canonicalize: Make A imply Zaamo and Zalrsc. + * config/riscv/riscv.opt: Add Zaamo and Zalrsc + * config/riscv/sync.md: Convert TARGET_ATOMIC to TARGET_ZAAMO and + TARGET_ZALRSC. + +2024-06-11 Uros Bizjak + + PR target/112600 + * config/i386/i386.md (usadd3): Emit insn sequence + involving conditional move for TARGET_CMOVE targets. + (ussub3): Ditto. + +2024-06-11 Pengxuan Zheng + + * config/aarch64/aarch64-builtins.cc (VAR1): Remap float_truncate_lo_ + builtin codes to standard optab ones. + * config/aarch64/aarch64-simd.md (aarch64_float_truncate_lo_): + Rename to... + (trunc2): ... This. + +2024-06-11 Andi Kleen + + * doc/extend.texi: Document constexpr asm. + +2024-06-11 Andrew MacLeod + + * gimple-range-fold.cc (range_of_ssa_name_with_loop_info): Issue a + message if SCEV is not invoked due to a mismatch. + +2024-06-11 Roger Sayle + + PR target/115397 + * config/i386/i386-expand.cc (ix86_expand_ternlog): Move call to + ix86_broadcast_from_constant before call to validize_mem, but after + call to force_const_mem. + +2024-06-11 Pan Li + + * config/riscv/autovec.md (ussub3): Add new pattern impl + for the unsigned vector modes. + * config/riscv/riscv-protos.h (expand_vec_ussub): Add new func + decl to expand .SAT_SUB for vector mode. + * config/riscv/riscv-v.cc (emit_vec_saddu): Add new func impl + to expand .SAT_SUB for vector mode. + (emit_vec_binary_alu): Add new helper func to emit binary alu. + (expand_vec_ussub): Leverage above helper func. + +2024-06-10 Gerald Pfeifer + + * doc/gm2.texi (Documentation): Fix typos, grammar, and a link. + +2024-06-10 Andrew MacLeod + + * gimple-array-bounds.cc (array_bounds_checker::array_bounds_checker): + Always use current range_query. + (pass_data_array_bounds): New. + (pass_array_bounds): New. + (make_pass_array_bounds): New. + * gimple-array-bounds.h (array_bounds_checker): Adjust prototype. + * passes.def (pass_array_bounds): New. Add after VRP1. + * timevar.def (TV_TREE_ARRAY_BOUNDS): New timevar. + * tree-pass.h (make_pass_array_bounds): Add prototype. + * tree-vrp.cc (execute_ranger_vrp): Remove warning param and do + not invoke array bounds warning pass. + (pass_vrp::pass_vrp): Adjust params. + (pass_vrp::close): Adjust parameters. + (pass_vrp::warn_array_bounds_p): Remove. + (make_pass_vrp): Remove warning param. + (make_pass_early_vrp): Remove warning param. + (make_pass_fast_vrp): Remove warning param. + +2024-06-10 Raphael Zinsly + + * config/riscv/bitmanip.md (*bextdisi): New pattern. + +2024-06-10 Pan Li + + PR target/115387 + * tree-ssa-math-opts.cc (math_opts_dom_walker::after_dom_children): Take + the gsi of start_bb instead of last_bb. + +2024-06-10 Raphael Zinsly + + * config/riscv/bitmanip.md (*bextdisi): New pattern. + +2024-06-10 Richard Biener + + PR tree-optimization/115388 + * tree-ssa-dse.cc (dse_classify_store): Handle irreducible + regions. + (pass_dse::execute): Make sure to mark backedges. + +2024-06-10 Richard Biener + + PR tree-optimization/115395 + * tree-vect-loop.cc (vect_create_epilog_for_reduction): + Handle STMT_VINFO_REDUC_EPILOGUE_ADJUSTMENT also for SLP + reductions of group_size one. + +2024-06-10 Andreas Krebbel + + * config/s390/s390.cc (expand_perm_as_replicate): Handle memory + operands. + * config/s390/vx-builtins.md (vec_splats): Turn into parameterized expander. + (@vec_splats): New expander. + +2024-06-10 Richard Biener + + PR tree-optimization/115383 + * tree-vect-stmts.cc (vectorizable_condition): Handle + generating a chain of .FOLD_EXTRACT_LAST. + +2024-06-09 Andreas Tobler + + * config/freebsd-spec.h: Change fbsd-lib-spec for FreeBSD > 13, + do not link against profiled system libraries if -pg is invoked. + Add a define to note about this change. + * config/aarch64/aarch64-freebsd.h: Use the note to inform if + -pg is invoked on FreeBSD > 13. + * config/arm/freebsd.h: Likewise. + * config/i386/freebsd.h: Likewise. + * config/i386/freebsd64.h: Likewise. + * config/riscv/freebsd.h: Likewise. + * config/rs6000/freebsd64.h: Likewise. + * config/rs6000/sysv4.h: Likeise. + +2024-06-09 Jeff Law + + * config/riscv/riscv.cc (riscv_move_integer): Initialize "x". + +2024-06-09 Uros Bizjak + + PR target/112600 + * config/i386/i386.md (ussub3): New expander. + (sub_3): Ditto. + +2024-06-09 Gerald Pfeifer + + * doc/install.texi (avr): Remove link to www.amelek.gda.pl/avr/. + +2024-06-09 Roger Sayle + + * expmed.cc (expand_shift_1): Use add_optab instead of ior_optab + to generate PLUS instead or IOR when unioning disjoint bitfields. + * optabs.cc (expand_subword_shift): Likewise. + (expand_binop): Likewise for double-word rotate. + +2024-06-08 Peter Bergner + + * config/rs6000/rs6000-logue.cc (rs6000_stack_info): Update comment. + +2024-06-08 Uros Bizjak + + PR target/112600 + * config/i386/i386.md (usadd3): New expander. + (x86_movcc_0_m1_neg): Use SWI mode iterator. + +2024-06-08 Pan Li + + * config/riscv/riscv-protos.h (riscv_expand_ussub): Add new func + decl for ussub expanding. + * config/riscv/riscv.cc (riscv_expand_ussub): Ditto but for impl. + * config/riscv/riscv.md (ussub3): Add new pattern ussub + for scalar modes. + +2024-06-07 David Malcolm + + * doc/invoke.texi: Add -Wanalyzer-undefined-behavior-ptrdiff. + +2024-06-07 Jason Merrill + + * doc/invoke.texi (C++ Modules): Mention -include. + +2024-06-07 Roger Sayle + + PR target/115351 + * config/i386/i386.cc (ix86_rtx_costs): Provide estimates for + the *concatditi3 and *insvti_highpart patterns, about two insns. + +2024-06-07 Roger Sayle + Hongtao Liu + + * config/i386/i386-expand.cc (ix86_expand_args_builtin): Call + fixup_modeless_constant before testing predicates. Only call + copy_to_mode_reg on memory operands (after the first one). + (ix86_gen_bcst_mem): Helper function to convert a CONST_VECTOR + into a VEC_DUPLICATE if possible. + (ix86_ternlog_idx): Convert an RTX expression into a ternlog + index between 0 and 255, recording the operands in ARGS, if + possible or return -1 if this is not possible/valid. + (ix86_ternlog_leaf_p): Helper function to identify "leaves" + of a ternlog expression, e.g. REG_P, MEM_P, CONST_VECTOR, etc. + (ix86_ternlog_operand_p): Test whether a expression is suitable + for and prefered as an UNSPEC_TERNLOG. + (ix86_expand_ternlog_binop): Helper function to construct the + binary operation corresponding to a sufficiently simple ternlog. + (ix86_expand_ternlog_andnot): Helper function to construct a + ANDN operation corresponding to a sufficiently simple ternlog. + (ix86_expand_ternlog): Expand a 3-operand ternary logic + expression, constructing either an UNSPEC_TERNLOG or simpler + rtx expression. Called from builtin expanders and pre-reload + splitters. + * config/i386/i386-protos.h (ix86_ternlog_idx): Prototype here. + (ix86_ternlog_operand_p): Likewise. + (ix86_expand_ternlog): Likewise. + * config/i386/predicates.md (ternlog_operand): New predicate + that calls xi86_ternlog_operand_p. + * config/i386/sse.md (_vpternlog_0): New + define_insn_and_split that recognizes a SET_SRC of ternlog_operand + and expands it via ix86_expand_ternlog pre-reload. + (_vternlog_mask): Convert from define_insn to + define_expand. Use ix86_expand_ternlog if the mask operand is + ~0 (or 255 or -1). + (*_vternlog_mask): define_insn renamed from above. + +2024-06-07 Michal Jires + + * common.opt: Add cache partitioning. + * flag-types.h (enum lto_partition_model): Likewise. + +2024-06-07 Richard Biener + + * tree-vect-loop.cc (vectorize_fold_left_reduction): Fix + mask vector operand indexing. + +2024-06-07 Jakub Jelinek + + PR middle-end/115352 + * gimple-lower-bitint.cc (lower_addsub_overflow): Don't disable + single_comparison if cmp_code is GE_EXPR. + +2024-06-07 Alexandre Oliva + + * target.def (call_offset_return_label): New hook. + * doc/tm.texi.in (TARGET_CALL_OFFSET_RETURN_LABEL): Add + placeholder. + * doc/tm.texi: Rebuild. + * dwarf2out.cc (struct call_arg_loc_node): Record call_insn + instead of call_arg_loc_note. + (add_AT_lbl_id): Add optional offset argument. + (gen_call_site_die): Compute and pass on a return pc offset. + (gen_subprogram_die): Move call_arg_loc_note computation... + (dwarf2out_var_location): ... from here. Set call_insn. + 2024-06-06 Pan Li * doc/match-and-simplify.texi: Add doc for the matching flag '^'. diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index de43a34b9136f..6fe37f7c38677 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20240607 +20240619 diff --git a/gcc/Makefile.in b/gcc/Makefile.in index f5adb647d3fb6..638ea6b2307b6 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1700,6 +1700,7 @@ OBJS = \ ubsan.o \ sanopt.o \ sancov.o \ + simple-diagnostic-path.o \ tree-call-cdce.o \ tree-cfg.o \ tree-cfgcleanup.o \ @@ -1709,7 +1710,6 @@ OBJS = \ tree-dfa.o \ tree-diagnostic.o \ tree-diagnostic-client-data-hooks.o \ - tree-diagnostic-path.o \ tree-dump.o \ tree-eh.o \ tree-emutls.o \ @@ -1823,6 +1823,8 @@ OBJS = \ OBJS-libcommon = diagnostic-spec.o diagnostic.o diagnostic-color.o \ diagnostic-format-json.o \ diagnostic-format-sarif.o \ + diagnostic-macro-unwinding.o \ + diagnostic-path.o \ diagnostic-show-locus.o \ edit-context.o \ pretty-print.o intl.o \ @@ -1830,6 +1832,8 @@ OBJS-libcommon = diagnostic-spec.o diagnostic.o diagnostic-color.o \ sbitmap.o \ vec.o input.o hash-table.o ggc-none.o memory-block.o \ selftest.o selftest-diagnostic.o sort.o \ + selftest-diagnostic-path.o \ + selftest-logical-location.o \ text-art/box-drawing.o \ text-art/canvas.o \ text-art/ruler.o \ diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 5beaacb2f0d20..222b9cd9083f8 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,720 @@ +2024-06-14 Eric Botcazou + + * gcc-interface/Makefile.in (tmake_file): Remove all references. + +2024-06-14 Eric Botcazou + + * gcc-interface/decl.cc: Include function.h. + (gnat_to_gnu_param): Minor comment tweaks. + (gnat_to_gnu_subprog_type): Take into account the default for the + computation of the return mechanism. Give a warning if a by-copy + specified mechanism cannot be honored. + +2024-06-14 Yannick Moy + + * gcc-interface/trans.cc (elaborate_all_entities_for_package) + (process_freeze_entity): Skip entities of kind E_Subprogram_Body. + +2024-06-14 Eric Botcazou + + PR ada/109817 + * gcc-interface/trans.cc (maybe_make_gnu_thunk): Create an alias + instead of a null thunk. + +2024-06-14 Marc Poulhiès + + * gcc-interface/decl.cc (gnat_to_gnu_entity): Typo fix. + (gnat_to_gnu_component_type): Indent fix. + * gcc-interface/gigi.h (build_call_alloc_dealloc): Typo fix. + * gcc-interface/utils.cc (make_dummy_type): Typo fix. + * gcc-interface/utils2.cc (gnat_protect_expr): Indent fix. + +2024-06-14 Eric Botcazou + + * aspects.ads (Aspect_Id): Alphabetize, remove the GNAT tag from + Default_Initial_Condition and Object_Size, move No_Controlled_Parts + and No_Task_Parts to boolean subclass. + (Nonoverridable_Aspect_Id): Add missing Ada 2022 aspects. + (Implementation_Defined_Aspect): Add all missing aspects, remove + Max_Entry_Queue_Length and Object_Size + (Aspect_Argument): Remove specific entries for No_Controlled_Parts + and No_Task_Parts, list boolean aspects last. + (Is_Representation_Aspect ): Move boolean aspects last. + (Aspect_Names): Alphabetize. + * sem_ch13.adb (Analyze_Aspect_Disable_Controlled): Adjust. + (Analyze_Aspect_Specifications): Move around processing for + No_Controlled_Parts and No_Task_Parts. + (Check_Aspect_At_Freeze_Point): Remove specific entries for + No_Controlled_Parts and No_Task_Parts + +2024-06-14 Steve Baird + + * exp_attr.adb + (Expand_Loop_Entry_Attribute): + Ensure that Etype of the saved expression is set correctly. + +2024-06-14 Jerome Guitton + + * sysdep.c (S_dosFsLib_FILE_NOT_FOUND, S_nfsLib_NFSERR_NOENT): + New macros, falback to ENOENT when not already defined. + (__gnat_is_file_not_found_error): Use these new macros to remove + tests against VxWorks flavors. + +2024-06-14 Eric Botcazou + + * snames.ads-tmpl (Name_Present): Move to Repinfo section. + +2024-06-14 Justin Squirek + + * doc/gnat_rm/gnat_language_extensions.rst: Add documentation for + mutably tagged type feature. + * aspects.ads: Add registration for 'Size'Class. + * einfo.ads: Add documentation for new components + Class_Wide_Equivalent_Type and Is_Mutably_Tagged_Type. + * exp_aggr.adb (Gen_Assign): Assume associated mutably tagged type + when class-wide equivalent type is encountered. + (Contains_Mutably_Tagged_Type): New subprogram. + (Convert_To_Positional): Assume associated mutably tagged type + when class-wide equivalent type is encountered. + (Is_Static_Element): Assume associated mutably tagged type when + class-wide equivalent type is encountered. + (Expand_Array_Aggregate): Assume associated mutably tagged type + when class-wide equivalent type is encountered. + (Expand_Record_Aggregate): Force mutably tagged records to be + expanded into assignments. + * exp_ch3.adb (Build_Array_Init_Proc): Assume associated mutably + tagged type when class-wide equivalent type is encountered. + (Simple_Initialization_OK): Disallow simple initialization for + class-wide equivalent types. + (Build_Init_Statements): Assume associated mutably tagged type + when class-wide equivalent type is encountered. + (Expand_Freeze_Array_Type): Ignore building of record init procs + for mutably tagged types. + (Expand_N_Full_Type_Declaration): Replace mutably tagged type + declarations with their associated class-wide equivalent types. + (Default_Initialize_Object): Add special handling for mutably + tagged types. + * exp_ch4.adb (Expand_N_Allocator): Add initialization for mutably + tagged types. + (Expand_Record_Equality): Generate mutably tagged unchecked + conversions. + * exp_ch5.adb (Expand_N_Assignment_Statement): Generate a special + assignment case for class-wide equivalent types which does tag + assignments and ignores certain checks. + * exp_ch6.adb (Expand_Call_Helper): Propagate constrained extra + formal actuals for mutably tagged types. + * exp_ch7.adb (Make_Init_Call): Handle mutably tagged type + initialization. + * exp_util.adb (Make_CW_Equivalent_Type): Modify to handle mutably + tagged objects which contain no initialization expression. + (Make_Subtype_From_Expr): Modify call to Make_CW_Equivalent_Type. + * exp_util.ads (Make_CW_Equivalent_Type): Move declaration from + body to spec. + * freeze.adb (Size_Known): No longer return false automatically + when a class-wide type is encountered. + (Freeze_Entity): Ignore error messages about size not being known + for mutably tagged types. + * gen_il-fields.ads: Register new fields + Class_Wide_Equivalent_Type and Is_Mutably_Tagged_Type. + * gen_il-gen-gen_entities.adb: Register new fields + Class_Wide_Equivalent_Type and Is_Mutably_Tagged_Type for type + entities. + * mutably_tagged.adb, mutably_tagged.ads + (Corresponding_Mutably_Tagged_Type): New subprogram. + (Depends_On_Mutably_Tagged_Ext_Comp): New subprogram. + (Get_Corresponding_Mutably_Tagged_Type_If_Present): New + subprogram. + (Get_Corresponding_Tagged_Type_If_Present): New subprogram. + (Is_Mutably_Tagged_Conversion): New subprogram. + (Is_Mutably_Tagged_CW_Equivalent_Type): New subprogram. + (Make_Mutably_Tagged_Conversion): New subprogram. + (Make_CW_Size_Compile_Check): New subprogram. + (Make_Mutably_Tagged_CW_Check): New subprogram. + * sem_aggr.adb (Resolve_Array_Aggregate): Skip tag checks for + class-wide equivalent types. + (Resolve_Aggr_Expr): Assume associated mutably tagged type when + class-wide equivalent type is encountered. + * sem_attr.adb (Analyze_Attribute): Allow 'Tag on mutably tagged + types. + (Resolve_Attribute): Detect errors for dependence of mutably + tagged extension type component. + * sem_ch12.adb (Instantiate_Object): Detect errors for dependence + of mutably tagged extension type component. + * sem_ch13.adb (Analyze_One_Aspect): Propagate 'Size'Class to + class-wide type. + (Analyze_Attribute_Definition_Clause): Add handling of 'Size'Class + by generating class-wide equivalent types and checking for illegal + uses. + * sem_ch2.adb (Analyze_Identifier): Generate unchecked conversion + for class-wide equivalent types. + * sem_ch3.adb (Analyze_Component_Declaration): Avoid unconstrained + errors on mutably tagged types. + (Analyze_Object_Declaration): Rewrite declarations of mutably + tagged types to use class-wide equivalent types. + (Array_Type_Declaration): Modify arrays of mutably tagged types to + use their corresponding class-wide equivalent types. + (Derived_Type_Declaration): Add various checks for mutably tagged + derived types. + * sem_ch4.adb (Analyze_Allocator): Replace reference to mutably + tagged type with cooresponding tagged type. + (Process_Indexed_Component): Generate unchecked conversion for + class-wide equivalent type. + (Analyze_One_Call): Generate unchecked conversion for class-wide + equivalent types. + (Analyze_Selected_Component): Assume reference to class-wide + equivalent type is associated mutably tagged type. + (Analyze_Type_Conversion): Generate unchecked conversion for + class-wide equivalent type. + * sem_ch5.adb (Analyze_Assignment): Assume associated mutably + tagged type when class-wide equivalent type is encountered. + (Analyze_Iterator_Specification): Detect errors for dependence of + mutably tagged extension type component. + * sem_ch6.adb (Create_Extra_Formals): Add code to generate extra + formal for mutably tagged types to signal if they are constrained. + * sem_ch8.adb (Analyze_Object_Renaming): Detect error on renaming + of mutably tagged extension type component. + (Analyze_Renaming_Primitive_Operation): Detect error on renaming + of mutably tagged extension type component. + * sem_res.adb (Resolve_Actuals): Allow class-wide arguments on + class-wide equivalent types. + (Valid_Conversion): Assume associated mutably tagged type when + class-wide equivalent type is encountered. + * sem_util.adb (Is_Fully_Initialized_Type): Flag mutably tagged + types as fully initialized. + (Needs_Simple_Initalization): Flag class-wide equivalent types as + needing initialization. + * gnat_rm.texi: Regenerate. + * gcc-interface/Make-lang.in: Add entry for mutably_tagged.o. + +2024-06-14 Justin Squirek + + * accessibility.adb: + (Accessibility_Level): Replace call Get_Full_View with call to + Full_View since Get_Full_View only works with incomplete types. + +2024-06-14 Eric Botcazou + + * aspects.ads (Operational_Aspect): Alphabetize. + * sem_ch13.ads (Analyze_Aspects_At_Freeze_Point): Fix description. + * sem_ch13.adb (Analyze_Aspects_At_Freeze_Point) : Give + the error for array types here instead of... + (Analyze_Aspect_Specifications) : Adjust comment. + (Check_Aspect_At_Freeze_Point) : ...here. + +2024-06-14 Javier Miranda + + * exp_aggr.adb (Must_Slide): Add missing support for + multidimensional arrays. + +2024-06-14 Eric Botcazou + + * freeze.adb (Freeze_All): Call Check_Aspects_At_End_Of_Declarations + to perform the visibility check for aspects. + * sem_ch13.ads (Check_Aspects_At_End_Of_Declarations): Declare. + (Check_Aspect_At_Freeze_Point): Move to... + (Check_Aspect_At_End_Of_Declarations): Move to... + * sem_ch13.adb (Check_Aspect_At_Freeze_Point): ...here. + (Check_Aspect_At_End_Of_Declarations): ...here. + (Analyze_Aspect_Specifications): Remove peculiar processing for + Stable_Properties, Designated_Storage_Model, Storage_Model_Type + and Aggregate. Move that of Local_Restrictions around. Reset + Aitem at the beginning of the loop for each aspect. + (Check_Aspects_At_End_Of_Declarations): New procedure. + +2024-06-14 Justin Squirek + + * sem_attr.adb: + (Analyze_Attribute): Add check for dereference. + +2024-06-14 Eric Botcazou + + * snames.ads-tmpl (Name_Storage_Model): Delete. + +2024-06-14 Alexandre Oliva + + Revert: + 2024-06-12 Alexandre Oliva + + * gcc-interface/decl.cc (gnat_to_gnu_field): Use unpacked type + as the debug type for packed fields. + +2024-06-13 Steve Baird + + * exp_util.adb + (Insert_Actions): Code was relying on an incorrect assumption that an + N_Itype_Reference cannot occur in declaration list or a statement + list. Fix the code to handle this case. + +2024-06-13 Viljar Indus + + * debug.adb: Remove mentions of -gnatdJ. + * errout.adb: Remove printing subprogram names to JSON. + * erroutc.adb: Remove printing subprogram names in messages. + * erroutc.ads: Remove Node and Subprogram_Name_Ptr used for -gnatdJ. + * errutil.adb: Remove Node used for -gnatdJ + * gnat1drv.adb: Remove references of -gnatdJ and + Include_Subprgram_In_Messages. + * opt.ads: Remove Include_Subprgram_In_Messages + * par-util.adb: Remove behavior related to + Include_Subprgram_In_Messages. + * sem_util.adb: Remove Subprogram_Name used for -gnatdJ + +2024-06-13 Eric Botcazou + + * exp_ch7.adb (Attach_Object_To_Master_Node): Fix formatting. + (Build_Finalizer.Process_Object_Declaration): Synthesize a local + Finalize_Address primitive if the object's subtype is an array + that has a constrained first subtype and is not this first subtype. + * exp_util.adb (Find_Last_Init): Get again to the base type in the + indirect case. + +2024-06-13 Eric Botcazou + + * doc/gnat_rm/implementation_defined_attributes.rst (Iterable): + Delete entry. + * gnat_rm.texi: Regenerate. + * gnat_ugn.texi: Regenerate. + +2024-06-13 Yannick Moy + + * sem_util.adb (Check_Ambiguous_Aggregate): Fix test. + +2024-06-13 Javier Miranda + + * freeze.ads (Check_Condition_Entities): Complete documentation. + * freeze.adb (Check_Inherited_Conditions): Extend its functionality to + build two kind of wrappers: the existing LSP wrappers, and wrappers + required to handle postconditions of interface primitives implemented + by inherited primitives. + (Build_Inherited_Condition_Pragmas): Rename formal. + (Freeze_Record_Type): For derived tagged types, move call to + Check_Inherited_Conditions to subprogram Freeze_Entity_Checks; + done to improve the performance of Check_Inherited_Conditions since it + can rely on the internal entities that link interface primitives with + tagged type primitives that implement them. + (Check_Interface_Primitives_Strub_Mode): New subprogram. + * sem_ch13.adb (Freeze_Entity_Checks): Call Check_Inherited_Conditions. + Call Check_Inherited_Conditions with derived interface types to check + strub mode compatibility of their primitives. + * sem_disp.adb (Check_Dispatching_Operation): Adjust assertion to accept + wrappers of interface primitives that have classwide postconditions. + * exp_disp.adb (Write_DT): Adding text to identify wrappers. + +2024-06-13 Viljar Indus + + * sem_res.adb (Resolve_Call): add warning insertion + character into the info message. + +2024-06-13 Steve Baird + + * sem_util.adb + (New_Copy_Tree.Visit_Entity): Delete code that prevented copying some entities. + +2024-06-13 Bob Duff + + * sem_ch12.adb (Check_Fixed_Point_Actual): Minor rewording; it seems + more proper to say "operator" rather than "operation". + (Matching_Actual): Give an error for <> in positional notation. + This is a syntax error. Disable this for now. + (Analyze_Associations): Copy the use clause in all cases. + The "mustn't recopy" comment seems wrong, because New_Copy_Tree + preserves Slocs. + * libgnat/a-ticoau.ads: Fix violation of new postion-box error. + * libgnat/a-wtcoau.ads: Likewise. + * libgnat/a-ztcoau.ads: Likewise. + +2024-06-13 Viljar Indus + + * par-labl.adb (Rewrite_As_Loop): Remove info message + +2024-06-13 Viljar Indus + + * par-ch7.adb: Remove warning characters from info message + * par-endh.adb: Remove warning characters from info message + * sem_res.adb: Remove warning characters from info message + +2024-06-13 Viljar Indus + + * sem_ch13.adb (Check_Aspect_At_End_Of_Declarations): change the + info message to a continuation message. + +2024-06-13 Viljar Indus + + * inline.adb (Cannot_Inline): Simplify string handling logic. + +2024-06-13 Yannick Moy + + * exp_ch5.adb (Expand_Iterator_Loop_Over_Container): Skip entities + of kind E_Subprogram_Body. + * repinfo.adb (List_Entities): Remove special case for subprogram + bodies. + * sem_ch6.adb (Analyze_Subprogram_Body_Helper): List subprogram + body entities in the enclosing scope. + +2024-06-13 Javier Miranda + + * sem_ch4.adb (Traverse_Interfaces): Add missing support + for climbing to parents of interface types. + +2024-06-13 Steve Baird + + * doc/gnat_rm/implementation_defined_attributes.rst: + Update Super attribute documentation. + * gnat_rm.texi: Regenerate. + * gnat_ugn.texi: Regenerate. + +2024-06-13 Ronan Desplanques + + * exp_ch7.adb (Build_Cleanup_Statements): Adapt to changes + made to Build_Protected_Subprogram_Call_Cleanup. + * exp_ch9.adb (Make_Unlock_Statement, Wrap_Unprotected_Call): + New functions. + (Build_Protected_Subprogram_Body): Fix resource management in + generated code. + (Build_Protected_Subprogram_Call_Cleanup): Make use of newly + introduced Make_Unlock_Statement. + +2024-06-13 Eric Botcazou + + PR ada/114710 + * exp_util.adb (Find_Renamed_Object): Recurse for any renaming. + +2024-06-13 Piotr Trojanek + + * sem_prag.adb (Check_Mode_Restriction_In_Enclosing_Context): + Iterate over encapsulating abstract states. + +2024-06-13 Eric Botcazou + + * Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add s-imad32$(objext), + s-imad64$(objext) and s-imagea$(objext). + * exp_atag.ads (Build_Set_Size_Function): Replace Tag_Node parameter + with Typ parameter. + * exp_atag.adb: Add clauses for Sinfo.Utils. + (Build_Set_Size_Function): Retrieve the TSD object statically. + * exp_disp.adb: Add clauses for Ttypes. + (Make_DT): Call Address_Image{32,64] instead of Address_Image. + (Register_Primitive): Pass Tag_Typ to Build_Set_Size_Function. + * rtsfind.ads (RTU_Id): Remove System_Address_Image and add + System_Img_Address_{32;64}. + (RE_Id): Remove entry for RE_Address_Image and add entries for + RE_Address_Image{32,64}. + * rtsfind.adb (System_Descendant): Adjust to above changes. + * libgnat/a-tags.ads (Address_Array): Suppress initialization. + * libgnat/s-addima.adb (System.Address_Image): Call the appropriate + routine based on the address size. + * libgnat/s-imad32.ads: New file. + * libgnat/s-imad64.ads: Likewise. + * libgnat/s-imagea.ads: Likewise. + * libgnat/s-imagea.adb: Likewise. + * gcc-interface/Make-lang.in (GNAT_ADA_OBJS) [$(STAGE1)=False]: Add + ada/libgnat/s-imad32.o and ada/libgnat/s-imad64.o. + +2024-06-13 Yannick Moy + + * inline.adb (Can_Be_Inlined_In_GNATprove_Mode): Do not inline + when constant with address clause is found. + +2024-06-13 Ronan Desplanques + + * gnatlink.adb (Gnatlink): Fix incorrect lower bound assumption. + (Is_Prefix): New function. + +2024-06-13 Steve Baird + + * sem_ch7.adb + (Requires_Completion_In_Body): Modify the Comes_From_Source test so that + the implicit declaration of an inherited subprogram does not cause + an incorrect result of True. + +2024-06-13 Richard Kenner + + * exp_ch6.adb (Expand_Ctrl_Function_Call): Inline if -gnatn in + CCG mode even if -O0. + +2024-06-13 Eric Botcazou + + PR ada/114710 + * exp_util.adb (Find_Renamed_Object): Recurse if the renamed object + is itself a renaming. + +2024-06-13 Javier Miranda + + * sem_attr.adb (Analyze_Attribute): Enhance support for + using 'Old with a prefix that references an overloaded + function that has no parameters; add missing support + for the use of 'Old within qualified expressions. + * sem_util.ads (Preanalyze_And_Resolve_Without_Errors): + New subprogram. + * sem_util.adb (Preanalyze_And_Resolve_Without_Errors): + New subprogram. + +2024-06-13 Piotr Trojanek + + * layout.adb (Layout_Type): Use high-level wrapper routine. + * sem_ch13.adb (Inherit_Delayed_Rep_Aspects): Likewise. + * sem_ch3.adb (Analyze_Object_Declaration): Likewise. + +2024-06-13 Eric Botcazou + + * libgnat/s-tsmona__linux.adb (Get): Move down descriptive comment. + * libgnat/s-tsmona__mingw.adb: Add with clause and use clause for + System.Storage_Elements. + (Get): Pass GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT in the call + to GetModuleHandleEx and remove the subsequent call to FreeLibrary. + Upon success, set Load_Addr to the base address of the module. + * libgnat/s-win32.ads (GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS): Use + shorter literal. + (GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT): New constant. + +2024-06-13 Eric Botcazou + + PR ada/114710 + * exp_ch7.adb (Build_Finalizer.Process_Declarations): Remove dead + code dealing with renamings. + * exp_util.ads (Is_Finalizable_Transient): Rename Rel_Node to N. + * exp_util.adb (Is_Finalizable_Transient): Likewise. + (Is_Aliased): Remove obsolete code dealing wih EWA nodes and only + consider renamings present in N itself. + (Requires_Cleanup_Actions): Remove dead code dealing with renamings. + +2024-06-13 Javier Miranda + + * sem_ch13.adb (Analyze_One_Aspect): Set the applicable policy + of a type declaration when its aspect Dynamic_Predicate is + analyzed. + * sem_prag.adb (Handle_Dynamic_Predicate_Check): New subprogram + that enables or ignores dynamic predicate checks depending on + whether dynamic checks are enabled in the context where the + associated type declaration is defined; used in the analysis + of pragma check. In addition, for pragma Predicate, do not + disable it when the aspect was internally build as part of + processing a dynamic predicate aspect. + +2024-06-12 Alexandre Oliva + + * gcc-interface/decl.cc (gnat_to_gnu_field): Use unpacked type + as the debug type for packed fields. + +2024-06-10 Eric Botcazou + + * exp_ch4.adb (Expand_Nonbinary_Modular_Op): Create an explicit Mod + for additive operations if No_Implicit_Conditionals is in effect. + (Expand_Modular_Addition): Likewise. + (Expand_Modular_Subtraction): Likewise. + (Expand_Modular_Op): Always use an unsigned type obtained by calling + Small_Integer_Type_For on the required size. + +2024-06-10 Javier Miranda + + * sem_ch6.adb (Might_Need_BIP_Task_Actuals): Add support + for access-to-subprogram parameter types. + * exp_ch6.adb (Add_Task_Actuals_To_Build_In_Place_Call): + Add dummy BIP parameters to access-to-subprogram types + that may reference a function that has BIP parameters. + +2024-06-10 Gary Dismukes + + * sem_prag.adb (Set_Convention_From_Pragma): If the specified convention on + a record type is not C_Pass_By_Copy, then force the C_Pass_By_Copy flag to + False, to ensure that it's overridden. + +2024-06-10 Gary Dismukes + + * sem_aggr.adb (Resolve_Iterated_Association): Change "not Present" + to "No" in test of Add_Named_Subp. + +2024-06-10 Steve Baird + + * freeze.adb + (Should_Freeze_Type.Is_Dispatching_Call_Or_Aggregate): Treat an extension + aggregate or a delta aggregate like a regular aggregate. + +2024-06-10 Gary Dismukes + + * sem_aggr.adb (Resolve_Iterated_Association): In the case of + N_Iterated_Element_Associations that have a key expression, issue + an error if the aggregate type does not have an Add_Named + operation, and include a reference to RM22 4.3.5(24) in the error + message. In the case of an N_Component_Association with a + Defining_Identifer where the "choice" is given by a function call, + in the creation of the iterator_specification associate a copy of + Choice as its Name, and remove the call to + Analyze_Iterator_Specification, which was causing problems with + the reanalysis of function calls originally given in prefixed form + that were transformed into function calls in normal (infix) form. + The iterator_specification will be analyzed later in any case, so + that call should not be done here. Remove the with and use of + Sem_Ch5. + +2024-06-10 Justin Squirek + + * ali.adb (Get_Nat): Remove unnecessary parentheses. + * exp_ch11.adb (Expand_Local_Exception_Handlers): Remove + unnecessary parentheses. + * freeze.adb (Freeze_Entity): Remove unnecessary parentheses. + * lib-list.adb (List): Remove unnecessary parentheses. + * par-ch5.adb (P_Condition): Add extra parentheses checks on + condition operands. + * sem_ch3.adb (Add_Interface_Tag_Components): Remove unnecessary + parentheses. + (Check_Delta_Expression): Remove unnecessary parenthesis. + (Check_Digits_Expression): Remove unnecessary parentheses. + * sem_ch12.adb (Validate_Array_Type_Instance): Remove unnecessary + parentheses. + +2024-06-10 Justin Squirek + + * exp_ch5.adb (Expand_Formal_Container_Element_Loop): Add + expansion of filter condition. + (Expand_Formal_Container_Loop): Add expansion of filter condition. + +2024-06-10 Justin Squirek + + * accessibility.adb (Accessibility_Level): Use Get_Full_View to + avoid crashes when calculating scope. + +2024-06-10 Justin Squirek + + * sem_warn.adb (Warn_On_Unreferenced_Entity): Add a condition to + ignore warnings on unreferenced abstract subprogram. + +2024-06-10 Justin Squirek + + * sem_attr.adb (Analyze_Attribute): Add check for interface parent + types. + +2024-06-10 Piotr Trojanek + + * einfo.ads, exp_attr.adb, exp_ch4.adb, exp_ch7.adb, + lib-writ.adb, libgnat/a-stbuut.ads, sem_ch13.adb, sem_ch3.adb, + sem_ch7.adb: Use "RM" in comments. + +2024-06-10 Piotr Trojanek + + * sem_util.adb + (Immediate_Context_Implies_Is_Potentially_Unevaluated): Use + collective subtypes in membership tests. + (Is_Known_On_Entry): Require all alternatives in a case statement + to return; this change could prevent a recently fixed glitch, + where one of the alternatives relied on the return statement + afterwards (also, the new code is shorter). + * sem_util.ads (Is_Potentially_Unevaluated): Clarify that this + routine applies to Ada 2012. + +2024-06-10 Yannick Moy + + * libgnat/a-chtgfo.adb (Generic_Read, Generic_Write): Remove. + * libgnat/a-chtgfo.ads: Same. Remove dependency on Ada.Streams. + +2024-06-10 Ronan Desplanques + + * libgnarl/s-taprop__mingw.adb (Set_Task_Affinity): Fix usage of + SetThreadAffinityMask. + * libgnat/s-winext.ads (SetThreadAffinityMask): Fix binding + signature. + +2024-06-10 Ronan Desplanques + + * libgnarl/s-taprop__mingw.adb (Set_Task_Affinity): Fix usage + of SetThreadIdealProcessor. + +2024-06-10 Ronan Desplanques + + * libgnat/s-os_lib.adb (Normalize_Pathname): Remove incorrect + assert statement. + (Missed_Drive_Letter): Rename into... + (Drive_Letter_Omitted): This. + +2024-06-10 Ronan Desplanques + + * gnatlink.adb (Check_File_Name): Fix incorrect assumption. + +2024-06-10 Piotr Trojanek + + * exp_attr.adb (Expand_N_Attribute_Reference): Use constants + declared at the beginning of subprogram; tune layout. + * exp_ch3.adb (Predefined_Primitive_Bodies): Tune layout. + +2024-06-10 Piotr Trojanek + + * doc/gnat_rm/implementation_defined_pragmas.rst + (No_Tagged_Streams): Move documentation. + * doc/gnat_rm/standard_and_implementation_defined_restrictions.rst + (No_Streams): Likewise. + * exp_disp.adb (Make_DT): Extend comment. + * gnat_rm.texi: Regenerate. + * gnat_ugn.texi: Regenerate. + +2024-06-10 Piotr Trojanek + + * sem_attr.adb (Analyze_Attribute): Use fully qualified name + without a NUL, so that it doesn't need to be skipped afterwards. + +2024-06-10 Piotr Trojanek + + * exp_ch3.adb (Stream_Operation_OK): Check restriction + No_Default_Stream_Attributes before call to + Type_Without_Stream_Operation. + * sem_util.adb (Type_Without_Stream_Operation): Remove static + condition from recursive routine + +2024-06-10 Piotr Trojanek + + * inline.adb (Has_Single_Return_In_GNATprove_Mode): Remove. + (Process_Formals): When rewriting an occurrence of a formal + parameter, use location of the occurrence, not of the inlined + call. + +2024-06-10 Piotr Trojanek + + * debug.adb (d_k): Use first available debug switch. + * gnat1drv.adb (Adjust_Global_Switches): If new debug switch is + active then don't expand assertion expressions by default. + +2024-06-10 Piotr Trojanek + + * exp_ch6.adb (Install_Class_Preconditions_Check): Refactor + common code for checking if precondition fails, since the + difference is only in raising an exception or calling the + Raise_Assert_Failure procedure. + +2024-06-10 Piotr Trojanek + + * exp_ch6.adb (Build_Dynamic_Check_Helper_Call): Remove unused + iteration over formal parameters. + +2024-06-10 Piotr Trojanek + + * sem_ch13.adb (Check_Aspect_At_End_Of_Declarations): Make + discriminants visible when analyzing aspect Interrupt_Priority. + (Freeze_Entity_Checks): Likewise. + (Resolve_Aspect_Expressions): Likewise for both aspects CPU and + Interrupt_Priority. + +2024-06-10 Piotr Trojanek + + * sem_prag.adb (Report_Extra_Clauses): Remove redundant check + for empty list, because First works also for No_List. + +2024-06-10 Piotr Trojanek + + * sem_prag.adb (Check_Dependency_Clause, Check_Output_States, + Report_Extra_Clauses): Remove multiple checks for being inside + an instance. + (Analyze_Refined_Depends_In_Decl_Part): Add single check for + being inside an instance. + +2024-06-10 Piotr Trojanek + + * sem_prag.adb (Check_In_Out_States, Check_Input_States, + Check_Output_States, Check_Proof_In_States, + Check_Refined_Global_List, Report_Extra_Constituents, + Report_Missing_Items): Remove multiple checks for being inside + an instance. + (Analyze_Refined_Global_In_Decl_Part): Add single check for + being inside an instance. + 2024-06-05 Kewen Lin * gcc-interface/decl.cc (gnat_to_gnu_entity): Use TYPE_PRECISION of diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl index 0f5ebb87d7357..1512c01f3f8c7 100644 --- a/gcc/ada/Makefile.rtl +++ b/gcc/ada/Makefile.rtl @@ -611,6 +611,9 @@ GNATRTL_NONTASKING_OBJS= \ s-geveop$(objext) \ s-gloloc$(objext) \ s-htable$(objext) \ + s-imad32$(objext) \ + s-imad64$(objext) \ + s-imagea$(objext) \ s-imageb$(objext) \ s-imaged$(objext) \ s-imagef$(objext) \ diff --git a/gcc/ada/accessibility.adb b/gcc/ada/accessibility.adb index 33ce001718a2b..da4d1d9ce2e2c 100644 --- a/gcc/ada/accessibility.adb +++ b/gcc/ada/accessibility.adb @@ -2227,7 +2227,11 @@ package body Accessibility is -- that of the type. elsif Ekind (Def_Ent) = E_Discriminant then - return Scope_Depth (Scope (Def_Ent)); + return Scope_Depth + (if Present (Full_View (Scope (Def_Ent))) then + Full_View (Scope (Def_Ent)) + else + Scope (Def_Ent)); end if; end if; diff --git a/gcc/ada/ali.adb b/gcc/ada/ali.adb index 69a91bce5ab96..7c7f790325b95 100644 --- a/gcc/ada/ali.adb +++ b/gcc/ada/ali.adb @@ -1351,7 +1351,7 @@ package body ALI is -- Check if we are on a number. In the case of bad ALI files, this -- may not be true. - if not (Nextc in '0' .. '9') then + if Nextc not in '0' .. '9' then Fatal_Error; end if; diff --git a/gcc/ada/aspects.ads b/gcc/ada/aspects.ads index 3cc62de3411b5..202d42193d138 100644 --- a/gcc/ada/aspects.ads +++ b/gcc/ada/aspects.ads @@ -64,10 +64,14 @@ with Types; use Types; package Aspects is - -- Type defining recognized aspects + -- Type enumerating the recognized aspects. The GNAT tag must be in keeping + -- with the Implementation_Defined_Aspect array below. type Aspect_Id is (No_Aspect, -- Dummy entry for no aspect + + -- The following aspects do not have a (static) boolean value + Aspect_Abstract_State, -- GNAT Aspect_Address, Aspect_Aggregate, @@ -81,7 +85,7 @@ package Aspects is Aspect_Convention, Aspect_CPU, Aspect_Default_Component_Value, - Aspect_Default_Initial_Condition, -- GNAT + Aspect_Default_Initial_Condition, Aspect_Default_Iterator, Aspect_Default_Storage_Pool, Aspect_Default_Value, @@ -104,8 +108,8 @@ package Aspects is Aspect_Integer_Literal, Aspect_Interrupt_Priority, Aspect_Invariant, -- GNAT - Aspect_Iterator_Element, Aspect_Iterable, -- GNAT + Aspect_Iterator_Element, Aspect_Link_Name, Aspect_Linker_Section, -- GNAT Aspect_Local_Restrictions, -- GNAT @@ -113,9 +117,7 @@ package Aspects is Aspect_Max_Entry_Queue_Depth, -- GNAT Aspect_Max_Entry_Queue_Length, Aspect_Max_Queue_Length, -- GNAT - Aspect_No_Controlled_Parts, - Aspect_No_Task_Parts, -- GNAT - Aspect_Object_Size, -- GNAT + Aspect_Object_Size, Aspect_Obsolescent, -- GNAT Aspect_Output, Aspect_Part_Of, -- GNAT @@ -186,10 +188,10 @@ package Aspects is Aspect_Atomic, Aspect_Atomic_Components, Aspect_Constant_After_Elaboration, -- GNAT - Aspect_Disable_Controlled, -- GNAT - Aspect_Discard_Names, Aspect_CUDA_Device, -- GNAT Aspect_CUDA_Global, -- GNAT + Aspect_Disable_Controlled, -- GNAT + Aspect_Discard_Names, Aspect_Effective_Reads, -- GNAT Aspect_Effective_Writes, -- GNAT Aspect_Exclusive_Functions, @@ -206,9 +208,11 @@ package Aspects is Aspect_Interrupt_Handler, Aspect_Lock_Free, -- GNAT Aspect_No_Caching, -- GNAT + Aspect_No_Controlled_Parts, Aspect_No_Inline, -- GNAT Aspect_No_Return, Aspect_No_Tagged_Streams, -- GNAT + Aspect_No_Task_Parts, -- GNAT Aspect_Pack, Aspect_Persistent_BSS, -- GNAT Aspect_Preelaborable_Initialization, @@ -242,12 +246,13 @@ package Aspects is | Aspect_Constant_Indexing | Aspect_Default_Iterator | Aspect_Implicit_Dereference + | Aspect_Integer_Literal | Aspect_Iterator_Element | Aspect_Max_Entry_Queue_Length | Aspect_No_Controlled_Parts + | Aspect_Real_Literal + | Aspect_String_Literal | Aspect_Variable_Indexing; - -- ??? No_Controlled_Parts not yet in Aspect_Id enumeration see RM - -- 13.1.1(18.7). -- The following array indicates aspects that accept 'Class @@ -260,6 +265,7 @@ package Aspects is Aspect_Post => True, Aspect_Read => True, Aspect_Write => True, + Aspect_Size => True, Aspect_Stable_Properties => True, Aspect_Type_Invariant => True, others => False); @@ -274,9 +280,13 @@ package Aspects is Aspect_Async_Writers => True, Aspect_Constant_After_Elaboration => True, Aspect_Contract_Cases => True, + Aspect_CUDA_Device => True, + Aspect_CUDA_Global => True, Aspect_Depends => True, + Aspect_Designated_Storage_Model => True, Aspect_Dimension => True, Aspect_Dimension_System => True, + Aspect_Disable_Controlled => True, Aspect_Effective_Reads => True, Aspect_Effective_Writes => True, Aspect_Exceptional_Cases => True, @@ -286,16 +296,30 @@ package Aspects is Aspect_Ghost_Predicate => True, Aspect_Global => True, Aspect_GNAT_Annotate => True, + Aspect_Initial_Condition => True, + Aspect_Initializes => True, Aspect_Inline_Always => True, Aspect_Invariant => True, + Aspect_Iterable => True, + Aspect_Linker_Section => True, + Aspect_Local_Restrictions => True, Aspect_Lock_Free => True, Aspect_Max_Entry_Queue_Depth => True, - Aspect_Max_Entry_Queue_Length => True, Aspect_Max_Queue_Length => True, - Aspect_Object_Size => True, + Aspect_No_Caching => True, + Aspect_No_Elaboration_Code_All => True, + Aspect_No_Inline => True, + Aspect_No_Tagged_Streams => True, + Aspect_No_Task_Parts => True, + Aspect_Obsolescent => True, + Aspect_Part_Of => True, Aspect_Persistent_BSS => True, Aspect_Predicate => True, Aspect_Pure_Function => True, + Aspect_Refined_Depends => True, + Aspect_Refined_Global => True, + Aspect_Refined_Post => True, + Aspect_Refined_State => True, Aspect_Relaxed_Initialization => True, Aspect_Remote_Access_Type => True, Aspect_Scalar_Storage_Order => True, @@ -304,16 +328,21 @@ package Aspects is Aspect_Side_Effects => True, Aspect_Simple_Storage_Pool => True, Aspect_Simple_Storage_Pool_Type => True, + Aspect_SPARK_Mode => True, + Aspect_Storage_Model_Type => True, Aspect_Subprogram_Variant => True, Aspect_Suppress_Debug_Info => True, Aspect_Suppress_Initialization => True, Aspect_Thread_Local_Storage => True, Aspect_Test_Case => True, + Aspect_Unimplemented => True, Aspect_Universal_Aliasing => True, Aspect_Unmodified => True, Aspect_Unreferenced => True, Aspect_Unreferenced_Objects => True, + Aspect_User_Aspect => True, Aspect_Value_Size => True, + Aspect_Volatile_Full_Access => True, Aspect_Volatile_Function => True, Aspect_Warnings => True, others => False); @@ -325,12 +354,12 @@ package Aspects is -- List is currently incomplete ??? Operational_Aspect : constant array (Aspect_Id) of Boolean := - (Aspect_Constant_Indexing => True, + (Aspect_Aggregate => True, + Aspect_Constant_Indexing => True, Aspect_Default_Iterator => True, - Aspect_Iterator_Element => True, Aspect_Iterable => True, + Aspect_Iterator_Element => True, Aspect_Variable_Indexing => True, - Aspect_Aggregate => True, others => False); -- The following array indicates aspects for which multiple occurrences of @@ -424,8 +453,6 @@ package Aspects is Aspect_Max_Entry_Queue_Depth => Expression, Aspect_Max_Entry_Queue_Length => Expression, Aspect_Max_Queue_Length => Expression, - Aspect_No_Controlled_Parts => Optional_Expression, - Aspect_No_Task_Parts => Optional_Expression, Aspect_Object_Size => Expression, Aspect_Obsolescent => Optional_Expression, Aspect_Output => Name, @@ -472,8 +499,8 @@ package Aspects is Aspect_Warnings => Name, Aspect_Write => Name, - Boolean_Aspects => Optional_Expression, - Library_Unit_Aspects => Optional_Expression); + Library_Unit_Aspects => Optional_Expression, + Boolean_Aspects => Optional_Expression); -- The following array indicates what aspects are representation aspects @@ -483,20 +510,14 @@ package Aspects is Aspect_Address => True, Aspect_Aggregate => False, Aspect_Alignment => True, - Aspect_Always_Terminates => False, Aspect_Annotate => False, - Aspect_Async_Readers => False, - Aspect_Async_Writers => False, Aspect_Attach_Handler => False, Aspect_Bit_Order => True, Aspect_Component_Size => True, - Aspect_Constant_After_Elaboration => False, Aspect_Constant_Indexing => False, Aspect_Contract_Cases => False, Aspect_Convention => True, Aspect_CPU => False, - Aspect_CUDA_Device => False, - Aspect_CUDA_Global => False, Aspect_Default_Component_Value => True, Aspect_Default_Initial_Condition => False, Aspect_Default_Iterator => False, @@ -508,14 +529,10 @@ package Aspects is Aspect_Dimension_System => False, Aspect_Dispatching_Domain => False, Aspect_Dynamic_Predicate => False, - Aspect_Effective_Reads => False, - Aspect_Effective_Writes => False, Aspect_Exceptional_Cases => False, Aspect_Exclusive_Functions => False, - Aspect_Extensions_Visible => False, Aspect_External_Name => False, Aspect_External_Tag => False, - Aspect_Ghost => False, Aspect_Ghost_Predicate => False, Aspect_Global => False, Aspect_GNAT_Annotate => False, @@ -535,9 +552,6 @@ package Aspects is Aspect_Max_Entry_Queue_Depth => False, Aspect_Max_Entry_Queue_Length => False, Aspect_Max_Queue_Length => False, - Aspect_No_Caching => False, - Aspect_No_Controlled_Parts => False, - Aspect_No_Task_Parts => False, Aspect_Object_Size => True, Aspect_Obsolescent => False, Aspect_Output => False, @@ -560,7 +574,6 @@ package Aspects is Aspect_Relaxed_Initialization => False, Aspect_Scalar_Storage_Order => True, Aspect_Secondary_Stack_Size => True, - Aspect_Side_Effects => False, Aspect_Simple_Storage_Pool => True, Aspect_Size => True, Aspect_Small => True, @@ -582,36 +595,49 @@ package Aspects is Aspect_User_Aspect => False, Aspect_Value_Size => True, Aspect_Variable_Indexing => False, - Aspect_Volatile_Function => False, Aspect_Warnings => False, Aspect_Write => False, Library_Unit_Aspects => False, + Aspect_Always_Terminates => False, Aspect_Asynchronous => True, + Aspect_Async_Readers => False, + Aspect_Async_Writers => False, Aspect_Atomic => True, Aspect_Atomic_Components => True, + Aspect_Constant_After_Elaboration => False, + Aspect_CUDA_Device => False, + Aspect_CUDA_Global => False, Aspect_Disable_Controlled => False, Aspect_Discard_Names => True, + Aspect_Effective_Reads => False, + Aspect_Effective_Writes => False, Aspect_Export => True, + Aspect_Extensions_Visible => False, Aspect_Favor_Top_Level => False, Aspect_Full_Access_Only => True, + Aspect_Ghost => False, + Aspect_Import => True, Aspect_Independent => True, Aspect_Independent_Components => True, - Aspect_Import => True, Aspect_Inline => False, Aspect_Inline_Always => False, Aspect_Interrupt_Handler => False, Aspect_Lock_Free => False, + Aspect_No_Caching => False, + Aspect_No_Controlled_Parts => False, Aspect_No_Inline => False, Aspect_No_Return => False, Aspect_No_Tagged_Streams => False, + Aspect_No_Task_Parts => False, Aspect_Pack => True, Aspect_Persistent_BSS => True, Aspect_Preelaborable_Initialization => False, Aspect_Pure_Function => False, Aspect_Remote_Access_Type => False, Aspect_Shared => True, + Aspect_Side_Effects => False, Aspect_Simple_Storage_Pool_Type => True, Aspect_Static => False, Aspect_Suppress_Debug_Info => False, @@ -625,6 +651,7 @@ package Aspects is Aspect_Volatile => True, Aspect_Volatile_Components => True, Aspect_Volatile_Full_Access => True, + Aspect_Volatile_Function => False, Aspect_Yield => False); ----------------------------------------- @@ -698,8 +725,8 @@ package Aspects is Aspect_Interrupt_Handler => Name_Interrupt_Handler, Aspect_Interrupt_Priority => Name_Interrupt_Priority, Aspect_Invariant => Name_Invariant, - Aspect_Iterator_Element => Name_Iterator_Element, Aspect_Iterable => Name_Iterable, + Aspect_Iterator_Element => Name_Iterator_Element, Aspect_Link_Name => Name_Link_Name, Aspect_Linker_Section => Name_Linker_Section, Aspect_Lock_Free => Name_Lock_Free, diff --git a/gcc/ada/debug.adb b/gcc/ada/debug.adb index 18b4a5480b654..602a8fa0b635a 100644 --- a/gcc/ada/debug.adb +++ b/gcc/ada/debug.adb @@ -67,7 +67,6 @@ package body Debug is -- dG Generate all warnings including those normally suppressed -- dH Hold (kill) call to gigi -- dI Inhibit internal name numbering in gnatG listing - -- dJ Prepend subprogram name in messages -- dK Kill all error messages -- dL Ignore external calls from instances for elaboration -- dM Assume all variables are modified (no current values) @@ -148,7 +147,7 @@ package body Debug is -- d_h Disable the use of (perfect) hash functions for enumeration Value -- d_i Ignore activations and calls to instances for elaboration -- d_j Read JSON files and populate Repinfo tables (opposite of -gnatRjs) - -- d_k + -- d_k In CodePeer mode disable expansion of assertion checks -- d_l -- d_m -- d_n @@ -615,11 +614,6 @@ package body Debug is -- is used in the fixed bugs run to minimize system and version -- dependency in filed -gnatD or -gnatG output. - -- dJ Prepend the name of the enclosing subprogram in compiler messages - -- (errors, warnings, style checks). This is useful in particular to - -- integrate compiler warnings in static analysis tools such as - -- CodePeer. - -- dK Kill all error messages. This debug flag suppresses the output -- of all error messages. It is used in regression tests where the -- error messages are target dependent and irrelevant. @@ -990,6 +984,11 @@ package body Debug is -- compilation session if -gnatRjs was passed, in order to populate -- the internal tables of the Repinfo unit from them. + -- d_k In CodePeer mode assertion expressions are expanded by default + -- (regardless of the -gnata compiler switch); when this switch is + -- enabled, expansion of assertion expressions is controlled by + -- pragma Assertion_Policy. + -- d_p The compiler ignores calls to subprograms which verify the run-time -- semantics of invariants and postconditions in both the static and -- dynamic elaboration models. diff --git a/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst b/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst index c703e1c7e3fdd..cf1ad60f13cb1 100644 --- a/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst +++ b/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst @@ -496,3 +496,41 @@ case statement with composite selector type". Link to the original RFC: https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-pattern-matching.rst + +Mutably Tagged Types with Size'Class Aspect +------------------------------------------- + +The `Size'Class` aspect can be applied to a tagged type to specify a size +constraint for the type and its descendants. When this aspect is specified +on a tagged type, the class-wide type of that type is considered to be a +"mutably tagged" type - meaning that objects of the class-wide type can have +their tag changed by assignment from objects with a different tag. + +When the aspect is applied to a type, the size of each of its descendant types +must not exceed the size specified for the aspect. + +Example: + +.. code-block:: ada + + type Base is tagged null record + with Size'Class => 16 * 8; -- Size in bits (128 bits, or 16 bytes) + + type Derived_Type is new Base with record + Data_Field : Integer; + end record; -- ERROR if Derived_Type exceeds 16 bytes + +Class-wide types with a specified `Size'Class` can be used as the type of +array components, record components, and stand-alone objects. + +.. code-block:: ada + + Inst : Base'Class; + type Array_of_Base is array (Positive range <>) of Base'Class; + +Note: Legality of the `Size'Class` aspect is subject to certain restrictions on +the tagged type, such as being undiscriminated, having no dynamic composite +subcomponents, among others detailed in the RFC. + +Link to the original RFC: +https://github.com/AdaCore/ada-spark-rfcs/blob/topic/rfc-finally/considered/rfc-class-size.md diff --git a/gcc/ada/doc/gnat_rm/implementation_defined_attributes.rst b/gcc/ada/doc/gnat_rm/implementation_defined_attributes.rst index 728d63a8e9242..d5a55b920fee5 100644 --- a/gcc/ada/doc/gnat_rm/implementation_defined_attributes.rst +++ b/gcc/ada/doc/gnat_rm/implementation_defined_attributes.rst @@ -565,12 +565,6 @@ uninitialized value of the type if pragma Initialize_Scalars is used, including the ability to modify the value with the binder -Sxx flag and relevant environment variables at run time. -Attribute Iterable -================== -.. index:: Iterable - -Equivalent to Aspect Iterable. - Attribute Large =============== .. index:: Ada 83 attributes @@ -1239,7 +1233,7 @@ The ``Super`` attribute can be applied to objects of tagged types in order to obtain a view conversion to the most immediate specific parent type. It cannot be applied to objects of types without any ancestors, or types whose -immediate parent is abstract. +immediate parent is an interface type. .. code-block:: ada diff --git a/gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst b/gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst index 7e4dd9353426f..0661670e04751 100644 --- a/gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst +++ b/gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst @@ -4000,12 +4000,6 @@ applied to a tagged type its Expanded_Name and External_Tag are initialized with empty strings. This is useful to avoid exposing entity names at binary level but has a negative impact on the debuggability of tagged types. -Alternatively, when pragmas ``Discard_Names`` and ``Restrictions (No_Streams)`` -simultanously apply to a tagged type, its Expanded_Name and External_Tag are -also initialized with empty strings. In particular, both these pragmas can be -applied as configuration pragmas to avoid exposing entity names at binary -level for the entire parition. - Pragma Normalize_Scalars ======================== diff --git a/gcc/ada/doc/gnat_rm/standard_and_implementation_defined_restrictions.rst b/gcc/ada/doc/gnat_rm/standard_and_implementation_defined_restrictions.rst index 5c023239163cf..cf4657b7050f8 100644 --- a/gcc/ada/doc/gnat_rm/standard_and_implementation_defined_restrictions.rst +++ b/gcc/ada/doc/gnat_rm/standard_and_implementation_defined_restrictions.rst @@ -675,6 +675,12 @@ To take maximum advantage of this space-saving optimization, any unit declaring a tagged type should be compiled with the restriction, though this is not required. +When pragmas ``Discard_Names`` and ``Restrictions (No_Streams)`` simultaneously +apply to a tagged type, its Expanded_Name and External_Tag are also initialized +with empty strings. In particular, both these pragmas can be applied as +configuration pragmas to avoid exposing entity names at binary level for the +entire partition. + No_Tagged_Type_Registration --------------------------- .. index:: No_Tagged_Type_Registration diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads index e5110f516708e..8ee419b3e0717 100644 --- a/gcc/ada/einfo.ads +++ b/gcc/ada/einfo.ads @@ -633,6 +633,10 @@ package Einfo is -- the corresponding implicitly declared class-wide type. For a -- class-wide type, returns itself. Set to Empty for untagged types. +-- Class_Wide_Equivalent_Type +-- Defined in all type entities. Used to store an internally generated +-- class-wide equivalent type for an associated mutably tagged type. + -- Cloned_Subtype -- Defined in E_Record_Subtype and E_Class_Wide_Subtype entities. -- Each such entity can either have a Discriminant_Constraint, in @@ -2728,7 +2732,7 @@ package Einfo is -- Defined in all entities. Set for implicitly declared subprograms -- that require overriding or are null procedures, and are hidden by -- a non-fully conformant homograph with the same characteristics --- (Ada RM 8.3 12.3/2). +-- (RM 8.3(12.3/2)). -- Is_Hidden_Open_Scope -- Defined in all entities. Set for a scope that contains the @@ -2980,6 +2984,10 @@ package Einfo is -- Is_Modular_Integer_Type (synthesized) -- Applies to all entities. True if entity is a modular integer type +-- Is_Mutably_Tagged_Type +-- Defined in all type entities. Used to signify that a given type is a +-- "mutably tagged" class-wide type where 'Size'Class has been specified. + -- Is_Non_Static_Subtype -- Defined in all type and subtype entities. It is set in some (but not -- all) cases in which a subtype is known to be non-static. Before this diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb index 92c4f6a46350f..76c461a2fd7c1 100644 --- a/gcc/ada/errout.adb +++ b/gcc/ada/errout.adb @@ -100,8 +100,7 @@ package body Errout is (Msg : String; Span : Source_Span; Opan : Source_Span; - Msg_Cont : Boolean; - Node : Node_Id); + Msg_Cont : Boolean); -- This is the low-level routine used to post messages after dealing with -- the issue of messages placed on instantiations (which get broken up -- into separate calls in Error_Msg). Span is the location on which the @@ -112,9 +111,7 @@ package body Errout is -- copy. So typically we can see Opan pointing to the template location -- in an instantiation copy when Span points to the source location of -- the actual instantiation (i.e the line with the new). Msg_Cont is - -- set true if this is a continuation message. Node is the relevant - -- Node_Id for this message, to be used to compute the enclosing entity if - -- Opt.Include_Subprogram_In_Messages is set. + -- set true if this is a continuation message. function No_Warnings (N : Node_Or_Entity_Id) return Boolean; -- Determines if warnings should be suppressed for the given node @@ -475,7 +472,7 @@ package body Errout is -- Error_Msg_Internal to place the message in the requested location. if Instantiation (Sindex) = No_Location then - Error_Msg_Internal (Msg, Flag_Span, Flag_Span, False, N); + Error_Msg_Internal (Msg, Flag_Span, Flag_Span, False); return; end if; @@ -573,32 +570,28 @@ package body Errout is (Msg => "info: in inlined body #", Span => To_Span (Actual_Error_Loc), Opan => Flag_Span, - Msg_Cont => Msg_Cont_Status, - Node => N); + Msg_Cont => Msg_Cont_Status); elsif Is_Warning_Msg then Error_Msg_Internal (Msg => Warn_Insertion & "in inlined body #", Span => To_Span (Actual_Error_Loc), Opan => Flag_Span, - Msg_Cont => Msg_Cont_Status, - Node => N); + Msg_Cont => Msg_Cont_Status); elsif Is_Style_Msg then Error_Msg_Internal (Msg => "style: in inlined body #", Span => To_Span (Actual_Error_Loc), Opan => Flag_Span, - Msg_Cont => Msg_Cont_Status, - Node => N); + Msg_Cont => Msg_Cont_Status); else Error_Msg_Internal (Msg => "error in inlined body #", Span => To_Span (Actual_Error_Loc), Opan => Flag_Span, - Msg_Cont => Msg_Cont_Status, - Node => N); + Msg_Cont => Msg_Cont_Status); end if; -- Case of generic instantiation @@ -609,32 +602,28 @@ package body Errout is (Msg => "info: in instantiation #", Span => To_Span (Actual_Error_Loc), Opan => Flag_Span, - Msg_Cont => Msg_Cont_Status, - Node => N); + Msg_Cont => Msg_Cont_Status); elsif Is_Warning_Msg then Error_Msg_Internal (Msg => Warn_Insertion & "in instantiation #", Span => To_Span (Actual_Error_Loc), Opan => Flag_Span, - Msg_Cont => Msg_Cont_Status, - Node => N); + Msg_Cont => Msg_Cont_Status); elsif Is_Style_Msg then Error_Msg_Internal (Msg => "style: in instantiation #", Span => To_Span (Actual_Error_Loc), Opan => Flag_Span, - Msg_Cont => Msg_Cont_Status, - Node => N); + Msg_Cont => Msg_Cont_Status); else Error_Msg_Internal (Msg => "instantiation error #", Span => To_Span (Actual_Error_Loc), Opan => Flag_Span, - Msg_Cont => Msg_Cont_Status, - Node => N); + Msg_Cont => Msg_Cont_Status); end if; end if; end if; @@ -653,8 +642,7 @@ package body Errout is (Msg => Msg, Span => To_Span (Actual_Error_Loc), Opan => Flag_Span, - Msg_Cont => Msg_Cont_Status, - Node => N); + Msg_Cont => Msg_Cont_Status); end; end Error_Msg; @@ -944,8 +932,7 @@ package body Errout is (Msg : String; Span : Source_Span; Opan : Source_Span; - Msg_Cont : Boolean; - Node : Node_Id) + Msg_Cont : Boolean) is Sptr : constant Source_Ptr := Span.Ptr; Optr : constant Source_Ptr := Opan.Ptr; @@ -1247,8 +1234,7 @@ package body Errout is Serious => Is_Serious_Error, Uncond => Is_Unconditional_Msg, Msg_Cont => Continuation, - Deleted => False, - Node => Node)); + Deleted => False)); Cur_Msg := Errors.Last; -- Test if warning to be treated as error @@ -1471,8 +1457,7 @@ package body Errout is (Msg => Msg, Span => Span, Opan => Opan, - Msg_Cont => True, - Node => Node); + Msg_Cont => True); end; end if; end Error_Msg_Internal; @@ -2026,9 +2011,9 @@ package body Errout is -- Warn for unmatched Warnings (Off, ...) if SWE.Open then - Error_Msg_N + Error_Msg ("?.w?pragma Warnings Off with no matching Warnings On", - SWE.Node); + SWE.Start); -- Warn for ineffective Warnings (Off, ..) @@ -2041,9 +2026,9 @@ package body Errout is and then not (SWE.Msg'Length > 3 and then SWE.Msg (2 .. 3) = "-W") then - Error_Msg_N + Error_Msg ("?.w?no warning suppressed by this pragma", - SWE.Node); + SWE.Start); end if; end if; end; @@ -2394,9 +2379,6 @@ package body Errout is -- whose value is the JSON location of Error.Sptr.Ptr. If Sptr.First and -- Sptr.Last are different from Sptr.Ptr, they will be printed as JSON -- locations under the names "start" and "finish". - -- When Include_Subprogram_In_Messages is true (-gnatdJ) an additional, - -- non-standard, attribute named "subprogram" will be added, allowing - -- precisely identifying the subprogram surrounding the span. ----------------------- -- Is_Continuation -- @@ -2473,12 +2455,6 @@ package body Errout is Write_JSON_Location (Span.Last); end if; - if Include_Subprogram_In_Messages then - Write_Str (",""subprogram"":"""); - Write_JSON_Escaped_String (Subprogram_Name_Ptr (Error.Node)); - Write_Str (""""); - end if; - Write_Str ("}"); end Write_JSON_Span; diff --git a/gcc/ada/erroutc.adb b/gcc/ada/erroutc.adb index cef04d5daf293..f404018c44d9b 100644 --- a/gcc/ada/erroutc.adb +++ b/gcc/ada/erroutc.adb @@ -339,7 +339,6 @@ package body Erroutc is w (" Uncond = ", E.Uncond); w (" Msg_Cont = ", E.Msg_Cont); w (" Deleted = ", E.Deleted); - w (" Node = ", Int (E.Node)); Write_Eol; end dmsg; @@ -698,20 +697,7 @@ package body Erroutc is -- Postfix warning tag to message if needed if Tag /= "" and then Warning_Doc_Switch then - if Include_Subprogram_In_Messages then - Txt := - new String' - (Subprogram_Name_Ptr (E_Msg.Node) & - ": " & Text.all & ' ' & Tag); - else - Txt := new String'(Text.all & ' ' & Tag); - end if; - - elsif Include_Subprogram_In_Messages - and then (E_Msg.Warn or else E_Msg.Style) - then - Txt := - new String'(Subprogram_Name_Ptr (E_Msg.Node) & ": " & Text.all); + Txt := new String'(Text.all & ' ' & Tag); else Txt := Text; end if; @@ -744,8 +730,7 @@ package body Erroutc is elsif E_Msg.Warn then Txt := new String'(SGR_Warning & "warning: " & SGR_Reset & Txt.all); - -- No prefix needed for style message, "(style)" is there already, - -- although not necessarily in first position if -gnatdJ is used. + -- No prefix needed for style message, "(style)" is there already elsif E_Msg.Style then if Txt (Txt'First .. Txt'First + 6) = "(style)" then @@ -1674,7 +1659,6 @@ package body Erroutc is ((Start => Loc, Msg => new String'(Msg), Stop => Source_Last (Get_Source_File_Index (Loc)), - Node => Node, Reason => Reason, Open => True, Used => Used, diff --git a/gcc/ada/erroutc.ads b/gcc/ada/erroutc.ads index 1c43bce2b21cf..5d48d5b899f9e 100644 --- a/gcc/ada/erroutc.ads +++ b/gcc/ada/erroutc.ads @@ -149,11 +149,6 @@ package Erroutc is -- output. This is used for internal processing for the case of an -- illegal instantiation. See Error_Msg routine for further details. - type Subprogram_Name_Type is access function (N : Node_Id) return String; - Subprogram_Name_Ptr : Subprogram_Name_Type; - -- Indirect call to Sem_Util.Subprogram_Name to break circular - -- dependency with the static elaboration model. - ---------------------------- -- Message ID Definitions -- ---------------------------- @@ -276,11 +271,6 @@ package Erroutc is Deleted : Boolean; -- If this flag is set, the message is not printed. This is used -- in the circuit for deleting duplicate/redundant error messages. - - Node : Node_Id; - -- If set, points to the node relevant for this message which will be - -- used to compute the enclosing subprogram name if - -- Opt.Include_Subprogram_In_Messages is set. end record; package Errors is new Table.Table ( @@ -352,14 +342,6 @@ package Erroutc is -- Starting and ending source pointers for the range. These are always -- from the same source file. - Node : Node_Id; - -- Node for the pragma Warnings occurrence. We store it to compute the - -- enclosing subprogram if -gnatdJ is enabled and a message about this - -- clause needs to be emitted. Note that we cannot remove the Start - -- component above and use Sloc (Node) on message display instead - -- because -gnatD output can already have messed with slocs at the point - -- when warnings about ineffective clauses are emitted. - Reason : String_Id; -- Reason string from pragma Warnings, or null string if none diff --git a/gcc/ada/errutil.adb b/gcc/ada/errutil.adb index bac9d4b15f168..4f5aa21646194 100644 --- a/gcc/ada/errutil.adb +++ b/gcc/ada/errutil.adb @@ -223,8 +223,7 @@ package body Errutil is Serious => Is_Serious_Error, Uncond => Is_Unconditional_Msg, Msg_Cont => Continuation, - Deleted => False, - Node => Empty)); + Deleted => False)); Cur_Msg := Errors.Last; Prev_Msg := No_Error_Msg; diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 796b0f1e0de1e..d564fd4f75570 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -43,6 +43,7 @@ with Exp_Tss; use Exp_Tss; with Freeze; use Freeze; with Itypes; use Itypes; with Lib; use Lib; +with Mutably_Tagged; use Mutably_Tagged; with Namet; use Namet; with Nmake; use Nmake; with Nlists; use Nlists; @@ -154,8 +155,8 @@ package body Exp_Aggr is -- case the aggregate must slide, and we must introduce an intermediate -- temporary to hold it. -- - -- The same holds in an assignment to one-dimensional array of arrays, - -- when a component may be given with bounds that differ from those of the + -- The same holds in an assignment to multi-dimensional arrays, when + -- components may be given with bounds that differ from those of the -- component type. function Number_Of_Choices (N : Node_Id) return Nat; @@ -1370,8 +1371,8 @@ package body Exp_Aggr is Expr_Q := Unqualify (Expr); if Present (Etype (N)) and then Etype (N) /= Any_Composite then - Comp_Typ := Component_Type (Etype (N)); - pragma Assert (Comp_Typ = Ctype); -- AI-287 + Comp_Typ := Get_Corresponding_Mutably_Tagged_Type_If_Present + (Component_Type (Etype (N))); elsif Present (Next (First (New_Indexes))) then @@ -4474,7 +4475,8 @@ package body Exp_Aggr is Dims : constant Nat := Number_Dimensions (Typ); Max_Others_Replicate : constant Nat := Max_Aggregate_Size (N); - Static_Components : Boolean := True; + Ctyp : Entity_Id := Component_Type (Typ); + Static_Components : Boolean := True; procedure Check_Static_Components; -- Check whether all components of the aggregate are compile-time known @@ -4908,9 +4910,9 @@ package body Exp_Aggr is end if; end Is_Flat; - ------------------------- - -- Is_Static_Element -- - ------------------------- + ----------------------- + -- Is_Static_Element -- + ----------------------- function Is_Static_Element (N : Node_Id; Dims : Nat) return Boolean is Expr : constant Node_Id := Expression (N); @@ -4935,7 +4937,7 @@ package body Exp_Aggr is -- but only at the innermost level for a multidimensional array. elsif Dims = 1 then - Preanalyze_And_Resolve (Expr, Component_Type (Typ)); + Preanalyze_And_Resolve (Expr, Ctyp); return Compile_Time_Known_Value (Expr); else @@ -4986,6 +4988,10 @@ package body Exp_Aggr is return; end if; + -- Special handling for mutably taggeds + + Ctyp := Get_Corresponding_Mutably_Tagged_Type_If_Present (Ctyp); + Check_Static_Components; -- If the size is known, or all the components are static, try to @@ -5076,9 +5082,10 @@ package body Exp_Aggr is procedure Expand_Array_Aggregate (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); - Typ : constant Entity_Id := Etype (N); - Ctyp : constant Entity_Id := Component_Type (Typ); + Typ : constant Entity_Id := Etype (N); -- Typ is the correct constrained array subtype of the aggregate + + Ctyp : Entity_Id := Component_Type (Typ); -- Ctyp is the corresponding component type. Aggr_Dimension : constant Pos := Number_Dimensions (Typ); @@ -6027,6 +6034,10 @@ package body Exp_Aggr is pragma Assert (not Raises_Constraint_Error (N)); + -- Special handling for mutably taggeds + + Ctyp := Get_Corresponding_Mutably_Tagged_Type_If_Present (Ctyp); + -- STEP 1a -- Check that the index range defined by aggregate bounds is @@ -7931,6 +7942,10 @@ package body Exp_Aggr is -- NOTE: This sets the global Static_Components to False in most, but -- not all, cases when it returns False. + function Contains_Mutably_Tagged_Component + (Typ : Entity_Id) return Boolean; + -- Determine if some component of Typ is mutably tagged + function Has_Per_Object_Constraint (L : List_Id) return Boolean; -- Return True if any element of L has Has_Per_Object_Constraint set. -- L should be the Choices component of an N_Component_Association. @@ -8433,6 +8448,30 @@ package body Exp_Aggr is return True; end Component_OK_For_Backend; + --------------------------------------- + -- Contains_Mutably_Tagged_Component -- + --------------------------------------- + + function Contains_Mutably_Tagged_Component + (Typ : Entity_Id) return Boolean + is + Comp : Entity_Id; + begin + -- Move through Typ's components looking for mutably tagged ones + + Comp := First_Component (Typ); + while Present (Comp) loop + -- When we find one, return True + + if Is_Mutably_Tagged_CW_Equivalent_Type (Etype (Comp)) then + return True; + end if; + + Next_Component (Comp); + end loop; + return False; + end Contains_Mutably_Tagged_Component; + ------------------------------- -- Has_Per_Object_Constraint -- ------------------------------- @@ -8515,7 +8554,8 @@ package body Exp_Aggr is end if; -- If the pragma Aggregate_Individually_Assign is set, always convert to - -- assignments. + -- assignments so that proper tag assignments and conversions can be + -- generated. if Aggregate_Individually_Assign then Convert_To_Assignments (N, Typ); @@ -8554,6 +8594,12 @@ package body Exp_Aggr is Build_Back_End_Aggregate; end if; + -- When we have any components which are mutably tagged types then + -- special processing is required. + + elsif Contains_Mutably_Tagged_Component (Typ) then + Convert_To_Assignments (N, Typ); + -- Gigi doesn't properly handle temporaries of variable size so we -- generate it in the front-end @@ -9550,32 +9596,44 @@ package body Exp_Aggr is elsif Is_Others_Aggregate (Aggr) then return False; - else - -- Sliding can only occur along the first dimension - -- If any the bounds of non-static sliding is required - -- to force potential range checks. + -- Check if sliding is required + else declare - Bounds1 : constant Range_Nodes := - Get_Index_Bounds (First_Index (Typ)); - Bounds2 : constant Range_Nodes := - Get_Index_Bounds (First_Index (Obj_Type)); + Obj_Index : Node_Id := First_Index (Obj_Type); + Obj_Bounds : Range_Nodes; + Typ_Index : Node_Id := First_Index (Typ); + Typ_Bounds : Range_Nodes; begin - if not Is_OK_Static_Expression (Bounds1.First) or else - not Is_OK_Static_Expression (Bounds2.First) or else - not Is_OK_Static_Expression (Bounds1.Last) or else - not Is_OK_Static_Expression (Bounds2.Last) - then - return True; + while Present (Typ_Index) loop + pragma Assert (Present (Obj_Index)); - else - return Expr_Value (Bounds1.First) /= Expr_Value (Bounds2.First) - or else - Expr_Value (Bounds1.Last) /= Expr_Value (Bounds2.Last); - end if; + Typ_Bounds := Get_Index_Bounds (Typ_Index); + Obj_Bounds := Get_Index_Bounds (Obj_Index); + + if not Is_OK_Static_Expression (Typ_Bounds.First) or else + not Is_OK_Static_Expression (Obj_Bounds.First) or else + not Is_OK_Static_Expression (Typ_Bounds.Last) or else + not Is_OK_Static_Expression (Obj_Bounds.Last) + then + return True; + + elsif Expr_Value (Typ_Bounds.First) + /= Expr_Value (Obj_Bounds.First) + or else Expr_Value (Typ_Bounds.Last) + /= Expr_Value (Obj_Bounds.Last) + then + return True; + end if; + + Next_Index (Typ_Index); + Next_Index (Obj_Index); + end loop; end; end if; + + return False; end Must_Slide; --------------------- diff --git a/gcc/ada/exp_atag.adb b/gcc/ada/exp_atag.adb index 12c7d8c226bc1..70bdd16c3b9c2 100644 --- a/gcc/ada/exp_atag.adb +++ b/gcc/ada/exp_atag.adb @@ -36,6 +36,7 @@ with Opt; use Opt; with Rtsfind; use Rtsfind; with Sinfo; use Sinfo; with Sinfo.Nodes; use Sinfo.Nodes; +with Sinfo.Utils; use Sinfo.Utils; with Sem_Aux; use Sem_Aux; with Sem_Disp; use Sem_Disp; with Sem_Util; use Sem_Util; @@ -776,19 +777,45 @@ package body Exp_Atag is function Build_Set_Size_Function (Loc : Source_Ptr; - Tag_Node : Node_Id; - Size_Func : Entity_Id) return Node_Id is + Typ : Entity_Id; + Size_Func : Entity_Id) return Node_Id + is + F_Nod : constant Node_Id := Freeze_Node (Typ); + + Act : Node_Id; + begin pragma Assert (Chars (Size_Func) = Name_uSize - and then RTE_Record_Component_Available (RE_Size_Func)); + and then RTE_Record_Component_Available (RE_Size_Func) + and then Present (F_Nod)); + + -- Find the declaration of the TSD object in the freeze actions + + Act := First (Actions (F_Nod)); + while Present (Act) loop + if Nkind (Act) = N_Object_Declaration + and then Nkind (Object_Definition (Act)) = N_Subtype_Indication + and then Is_Entity_Name (Subtype_Mark (Object_Definition (Act))) + and then Is_RTE (Entity (Subtype_Mark (Object_Definition (Act))), + RE_Type_Specific_Data) + then + exit; + end if; + + Next (Act); + end loop; + + pragma Assert (Present (Act)); + + -- Generate: + -- TSD.Size_Func := Size_Ptr!(Size_Func'Unrestricted_Access); + return Make_Assignment_Statement (Loc, Name => Make_Selected_Component (Loc, - Prefix => - Make_Explicit_Dereference (Loc, - Build_TSD (Loc, - Unchecked_Convert_To (RTE (RE_Address), Tag_Node))), + Prefix => + New_Occurrence_Of (Defining_Identifier (Act), Loc), Selector_Name => New_Occurrence_Of (RTE_Record_Component (RE_Size_Func), Loc)), diff --git a/gcc/ada/exp_atag.ads b/gcc/ada/exp_atag.ads index 96cb5663e6877..7e987f110b783 100644 --- a/gcc/ada/exp_atag.ads +++ b/gcc/ada/exp_atag.ads @@ -162,9 +162,9 @@ package Exp_Atag is function Build_Set_Size_Function (Loc : Source_Ptr; - Tag_Node : Node_Id; + Typ : Entity_Id; Size_Func : Entity_Id) return Node_Id; - -- Build code that saves in the TSD the address of the function + -- Build code that saves in the TSD of Typ the address of the function -- calculating _size of the object. function Build_Set_Static_Offset_To_Top diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb index 69428142839c1..5c85b4912d27b 100644 --- a/gcc/ada/exp_attr.adb +++ b/gcc/ada/exp_attr.adb @@ -179,7 +179,6 @@ package body Exp_Attr is -- * Rec_Typ - the record type whose internals are to be validated function Default_Streaming_Unavailable (Typ : Entity_Id) return Boolean; - -- -- In most cases, references to unavailable streaming attributes -- are rejected at compile time. In some obscure cases involving -- generics and formal derived types, the problem is dealt with at runtime. @@ -1781,14 +1780,25 @@ package body Exp_Attr is begin Aux_Decl := Empty; - -- Generate a nominal type for the constant when the prefix is of - -- a constrained type. This is achieved by setting the Etype of - -- the relocated prefix to its base type. Since the prefix is now - -- the initialization expression of the constant, its freezing - -- will produce a proper nominal type. - Temp_Expr := Relocate_Node (Pref); - Set_Etype (Temp_Expr, Base_Typ); + + -- For Etype (Temp_Expr) in some cases we cannot use either + -- Etype (Pref) or Base_Typ. So we set Etype (Temp_Expr) to null + -- and mark Temp_Expr as requiring analysis. Rather than trying + -- to sort out exactly when this is needed, we do it + -- unconditionally. + -- One case where this is needed is when + -- 1) Pref is an N_Selected_Component name that + -- refers to a component which is subject to a + -- discriminant-dependent constraint; and + -- 2) The prefix of that N_Selected_Component refers to a + -- formal parameter with an unconstrained subtype; and + -- 3) Pref has only been preanalyzed (so that + -- Build_Actual_Subtype_Of_Component has not been called + -- and Etype (Pref) equals the Etype of the component). + + Set_Etype (Temp_Expr, Empty); + Set_Analyzed (Temp_Expr, False); -- Generate: -- Temp : constant Base_Typ := Pref; @@ -2174,8 +2184,8 @@ package body Exp_Attr is -- for the arguments of a 'Read attribute reference (since the -- scalar argument is an OUT scalar) and for the arguments of a -- 'Has_Same_Storage or 'Overlaps_Storage attribute reference (which not - -- considered to be reads of their prefixes and expressions, see Ada RM - -- 13.3(73.10/3)). + -- considered to be reads of their prefixes and expressions, see + -- RM 13.3(73.10/3)). if Validity_Checks_On and then Validity_Check_Operands and then Id /= Attribute_Asm_Output @@ -4091,10 +4101,8 @@ package body Exp_Attr is ---------------------- when Attribute_Has_Same_Storage => Has_Same_Storage : declare - Loc : constant Source_Ptr := Sloc (N); - - X : constant Node_Id := Prefix (N); - Y : constant Node_Id := First (Expressions (N)); + X : constant Node_Id := Pref; + Y : constant Node_Id := First (Exprs); -- The arguments X_Addr : Node_Id; @@ -4363,7 +4371,7 @@ package body Exp_Attr is if Restriction_Active (No_Streams) then Rewrite (N, - Make_Raise_Program_Error (Sloc (N), + Make_Raise_Program_Error (Loc, Reason => PE_Stream_Operation_Not_Allowed)); Set_Etype (N, B_Type); return; @@ -4415,7 +4423,7 @@ package body Exp_Attr is -- case where a No_Streams restriction is active. Rewrite (N, - Make_Raise_Program_Error (Sloc (N), + Make_Raise_Program_Error (Loc, Reason => PE_Stream_Operation_Not_Allowed)); Set_Etype (N, B_Type); return; @@ -5295,10 +5303,8 @@ package body Exp_Attr is ---------------------- when Attribute_Overlaps_Storage => Overlaps_Storage : declare - Loc : constant Source_Ptr := Sloc (N); - X : constant Node_Id := Prefix (N); - Y : constant Node_Id := First (Expressions (N)); - + X : constant Node_Id := Pref; + Y : constant Node_Id := First (Exprs); -- The arguments X_Addr, Y_Addr : Node_Id; @@ -5451,7 +5457,7 @@ package body Exp_Attr is if Restriction_Active (No_Streams) then Rewrite (N, - Make_Raise_Program_Error (Sloc (N), + Make_Raise_Program_Error (Loc, Reason => PE_Stream_Operation_Not_Allowed)); Set_Etype (N, Standard_Void_Type); return; @@ -5505,7 +5511,7 @@ package body Exp_Attr is -- case where a No_Streams restriction is active. Rewrite (N, - Make_Raise_Program_Error (Sloc (N), + Make_Raise_Program_Error (Loc, Reason => PE_Stream_Operation_Not_Allowed)); Set_Etype (N, Standard_Void_Type); return; @@ -6180,10 +6186,9 @@ package body Exp_Attr is when Attribute_Reduce => declare - Loc : constant Source_Ptr := Sloc (N); - E1 : constant Node_Id := First (Expressions (N)); - E2 : constant Node_Id := Next (E1); - Bnn : constant Entity_Id := Make_Temporary (Loc, 'B', N); + E1 : constant Node_Id := First (Exprs); + E2 : constant Node_Id := Next (E1); + Bnn : constant Entity_Id := Make_Temporary (Loc, 'B', N); Accum_Typ : Entity_Id := Empty; New_Loop : Node_Id; @@ -6381,7 +6386,7 @@ package body Exp_Attr is if Restriction_Active (No_Streams) then Rewrite (N, - Make_Raise_Program_Error (Sloc (N), + Make_Raise_Program_Error (Loc, Reason => PE_Stream_Operation_Not_Allowed)); Set_Etype (N, B_Type); return; @@ -6453,7 +6458,7 @@ package body Exp_Attr is -- case where a No_Streams restriction is active. Rewrite (N, - Make_Raise_Program_Error (Sloc (N), + Make_Raise_Program_Error (Loc, Reason => PE_Stream_Operation_Not_Allowed)); Set_Etype (N, B_Type); return; @@ -8096,7 +8101,7 @@ package body Exp_Attr is if Restriction_Active (No_Streams) then Rewrite (N, - Make_Raise_Program_Error (Sloc (N), + Make_Raise_Program_Error (Loc, Reason => PE_Stream_Operation_Not_Allowed)); Set_Etype (N, U_Type); return; @@ -8150,7 +8155,7 @@ package body Exp_Attr is -- case where a No_Streams restriction is active. Rewrite (N, - Make_Raise_Program_Error (Sloc (N), + Make_Raise_Program_Error (Loc, Reason => PE_Stream_Operation_Not_Allowed)); Set_Etype (N, U_Type); return; diff --git a/gcc/ada/exp_ch11.adb b/gcc/ada/exp_ch11.adb index 9a0f66ff44056..678d76cf3eb09 100644 --- a/gcc/ada/exp_ch11.adb +++ b/gcc/ada/exp_ch11.adb @@ -552,7 +552,7 @@ package body Exp_Ch11 is -- Nothing to do if no handlers requiring the goto transformation - if not (Local_Expansion_Required) then + if not Local_Expansion_Required then return; end if; diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb index 8ddae1eb1be31..3d8b80239887b 100644 --- a/gcc/ada/exp_ch3.adb +++ b/gcc/ada/exp_ch3.adb @@ -49,6 +49,7 @@ with Exp_Util; use Exp_Util; with Freeze; use Freeze; with Ghost; use Ghost; with Lib; use Lib; +with Mutably_Tagged; use Mutably_Tagged; with Namet; use Namet; with Nlists; use Nlists; with Nmake; use Nmake; @@ -631,8 +632,13 @@ package body Exp_Ch3 is --------------------------- procedure Build_Array_Init_Proc (A_Type : Entity_Id; Nod : Node_Id) is - Comp_Type : constant Entity_Id := Component_Type (A_Type); - Comp_Simple_Init : constant Boolean := + -- Obtain the corresponding mutably tagged type's parent subtype to + -- handle default initialization. + + Comp_Type : constant Entity_Id := + Get_Corresponding_Tagged_Type_If_Present (Component_Type (A_Type)); + + Comp_Simple_Init : constant Boolean := Needs_Simple_Initialization (Typ => Comp_Type, Consider_IS => @@ -1367,6 +1373,7 @@ package body Exp_Ch3 is return not (Present (Obj_Id) and then Is_Internal (Obj_Id)) + and then not Is_Mutably_Tagged_CW_Equivalent_Type (Typ) and then Needs_Simple_Initialization (Typ => Typ, @@ -3709,7 +3716,11 @@ package body Exp_Ch3 is (Subtype_Indication (Component_Definition (Decl)), Checks); Id := Defining_Identifier (Decl); - Typ := Etype (Id); + + -- Obtain the corresponding mutably tagged type's parent subtype + -- to handle default initialization. + + Typ := Get_Corresponding_Tagged_Type_If_Present (Etype (Id)); -- Leave any processing of component requiring late initialization -- for the second pass. @@ -4125,7 +4136,11 @@ package body Exp_Ch3 is while Present (Decl) loop Comp_Loc := Sloc (Decl); Id := Defining_Identifier (Decl); - Typ := Etype (Id); + + -- Obtain the corresponding mutably tagged type's parent + -- subtype to handle default initialization. + + Typ := Get_Corresponding_Tagged_Type_If_Present (Etype (Id)); if Initialization_Control.Requires_Late_Init (Decl, Rec_Type) then @@ -5407,7 +5422,12 @@ package body Exp_Ch3 is procedure Expand_Freeze_Array_Type (N : Node_Id) is Typ : constant Entity_Id := Entity (N); Base : constant Entity_Id := Base_Type (Typ); - Comp_Typ : constant Entity_Id := Component_Type (Typ); + + -- Obtain the corresponding mutably tagged type if necessary + + Comp_Typ : constant Entity_Id := + Get_Corresponding_Mutably_Tagged_Type_If_Present + (Component_Type (Typ)); begin if not Is_Bit_Packed_Array (Typ) then @@ -6436,7 +6456,9 @@ package body Exp_Ch3 is -- Do not need init for interfaces on virtual targets since they're -- abstract. - if Tagged_Type_Expansion or else not Is_Interface (Typ) then + if not Is_Mutably_Tagged_CW_Equivalent_Type (Typ) + and then (Tagged_Type_Expansion or else not Is_Interface (Typ)) + then Build_Record_Init_Proc (Typ_Decl, Typ); end if; @@ -6695,6 +6717,29 @@ package body Exp_Ch3 is end; end if; + -- Handle mutably tagged types by replacing their declarations with + -- their class-wide equivalent types. + + declare + Comp : Entity_Id; + begin + if Is_Array_Type (Def_Id) then + Comp := First_Entity (Component_Type (Def_Id)); + else + Comp := First_Entity (Def_Id); + end if; + + while Present (Comp) loop + if Ekind (Etype (Comp)) /= E_Void + and then Is_Mutably_Tagged_Type (Etype (Comp)) + then + Set_Etype + (Comp, Class_Wide_Equivalent_Type (Etype (Comp))); + end if; + Next_Entity (Comp); + end loop; + end; + Par_Id := Etype (B_Id); -- The parent type is private then we need to inherit any TSS operations @@ -7244,7 +7289,12 @@ package body Exp_Ch3 is -- Or else build the fully-fledged initialization if need be - Init_Stmts := Build_Default_Initialization (N, Typ, Def_Id); + if Is_Mutably_Tagged_Type (Typ) then + Init_Stmts := + Build_Default_Initialization (N, Etype (Typ), Def_Id); + else + Init_Stmts := Build_Default_Initialization (N, Typ, Def_Id); + end if; -- Insert the whole initialization sequence into the tree. If the -- object has a delayed freeze, as will be the case when it has @@ -12655,8 +12705,7 @@ package body Exp_Ch3 is and then Stream_Operation_OK (Tag_Typ, TSS_Stream_Input) and then No (TSS (Tag_Typ, TSS_Stream_Input)) then - Build_Record_Or_Elementary_Input_Function - (Tag_Typ, Decl, Ent); + Build_Record_Or_Elementary_Input_Function (Tag_Typ, Decl, Ent); Append_To (Res, Decl); end if; @@ -12912,7 +12961,9 @@ package body Exp_Ch3 is and then No (No_Tagged_Streams_Pragma (Typ)) and then not No_Run_Time_Mode and then RTE_Available (RE_Tag) - and then No (Type_Without_Stream_Operation (Typ)) + and then + (not Restriction_Active (No_Default_Stream_Attributes) + or else No (Type_Without_Stream_Operation (Typ))) and then RTE_Available (RE_Root_Stream_Type); end Stream_Operation_OK; diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 6ceffdf830206..7349dfc306fca 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -47,6 +47,7 @@ with Exp_Util; use Exp_Util; with Freeze; use Freeze; with Inline; use Inline; with Lib; use Lib; +with Mutably_Tagged; use Mutably_Tagged; with Namet; use Namet; with Nlists; use Nlists; with Nmake; use Nmake; @@ -139,9 +140,10 @@ package body Exp_Ch4 is -- case of array type arguments. procedure Expand_Nonbinary_Modular_Op (N : Node_Id); - -- When generating C code, convert nonbinary modular arithmetic operations - -- into code that relies on the front-end expansion of operator Mod. No - -- expansion is performed if N is not a nonbinary modular operand. + -- When generating C code or if restriction No_Implicit_Conditionals is in + -- effect, convert most nonbinary modular arithmetic operations into code + -- that relies on the expansion of an explicit Mod operator. No expansion + -- is performed if N is not a nonbinary modular operation. procedure Expand_Short_Circuit_Operator (N : Node_Id); -- Common expansion processing for short-circuit boolean operators @@ -3899,10 +3901,13 @@ package body Exp_Ch4 is procedure Expand_Modular_Addition is begin - -- If this is not the addition of a constant then compute it using - -- the general rule: (lhs + rhs) mod Modulus + -- If this is not the addition of a constant or else restriction + -- No_Implicit_Conditionals is in effect, then compute it using + -- the general rule: (lhs + rhs) mod Modulus. - if Nkind (Right_Opnd (N)) /= N_Integer_Literal then + if Nkind (Right_Opnd (N)) /= N_Integer_Literal + or else Restriction_Active (No_Implicit_Conditionals) + then Expand_Modular_Op; -- If this is an addition of a constant, convert it to a subtraction @@ -3921,6 +3926,7 @@ package body Exp_Ch4 is Cond_Expr : Node_Id; Then_Expr : Node_Id; Else_Expr : Node_Id; + begin -- To prevent spurious visibility issues, convert all -- operands to Standard.Unsigned. @@ -3966,12 +3972,12 @@ package body Exp_Ch4 is -- We will convert to another type (not a nonbinary-modulus modular -- type), evaluate the op in that representation, reduce the result, -- and convert back to the original type. This means that the - -- backend does not have to deal with nonbinary-modulus ops. - - Op_Expr : constant Node_Id := New_Op_Node (Nkind (N), Loc); - Mod_Expr : Node_Id; + -- back end does not have to deal with nonbinary-modulus ops. + Mod_Expr : Node_Id; + Op_Expr : Node_Id; Target_Type : Entity_Id; + begin -- Select a target type that is large enough to avoid spurious -- intermediate overflow on pre-reduction computation (for @@ -3979,22 +3985,15 @@ package body Exp_Ch4 is declare Required_Size : Uint := RM_Size (Etype (N)); - Use_Unsigned : Boolean := True; + begin case Nkind (N) is - when N_Op_Add => + when N_Op_Add | N_Op_Subtract => -- For example, if modulus is 255 then RM_Size will be 8 -- and the range of possible values (before reduction) will -- be 0 .. 508; that range requires 9 bits. Required_Size := Required_Size + 1; - when N_Op_Subtract => - -- For example, if modulus is 255 then RM_Size will be 8 - -- and the range of possible values (before reduction) will - -- be -254 .. 254; that range requires 9 bits, signed. - Use_Unsigned := False; - Required_Size := Required_Size + 1; - when N_Op_Multiply => -- For example, if modulus is 255 then RM_Size will be 8 -- and the range of possible values (before reduction) will @@ -4005,37 +4004,15 @@ package body Exp_Ch4 is null; end case; - if Use_Unsigned then - if Required_Size <= Standard_Short_Short_Integer_Size then - Target_Type := Standard_Short_Short_Unsigned; - elsif Required_Size <= Standard_Short_Integer_Size then - Target_Type := Standard_Short_Unsigned; - elsif Required_Size <= Standard_Integer_Size then - Target_Type := Standard_Unsigned; - else - pragma Assert (Required_Size <= 64); - Target_Type := Standard_Unsigned_64; - end if; - elsif Required_Size <= 8 then - Target_Type := Standard_Integer_8; - elsif Required_Size <= 16 then - Target_Type := Standard_Integer_16; - elsif Required_Size <= 32 then - Target_Type := Standard_Integer_32; - else - pragma Assert (Required_Size <= 64); - Target_Type := Standard_Integer_64; - end if; - + Target_Type := Small_Integer_Type_For (Required_Size, Uns => True); pragma Assert (Present (Target_Type)); end; + Op_Expr := New_Op_Node (Nkind (N), Loc); Set_Left_Opnd (Op_Expr, - Unchecked_Convert_To (Target_Type, - New_Copy_Tree (Left_Opnd (N)))); + Unchecked_Convert_To (Target_Type, New_Copy_Tree (Left_Opnd (N)))); Set_Right_Opnd (Op_Expr, - Unchecked_Convert_To (Target_Type, - New_Copy_Tree (Right_Opnd (N)))); + Unchecked_Convert_To (Target_Type, New_Copy_Tree (Right_Opnd (N)))); -- ??? Why do this stuff for some ops and not others? if Nkind (N) not in N_Op_And | N_Op_Or | N_Op_Xor then @@ -4064,13 +4041,24 @@ package body Exp_Ch4 is Force_Evaluation (Op_Expr, Mode => Strict); end if; + -- Unconditionally add the modulus to the result for a subtraction, + -- this gets rid of all its peculiarities by cancelling out the + -- addition of the binary modulus in the case where the subtraction + -- wraps around in Target_Type. + + if Nkind (N) = N_Op_Subtract then + Op_Expr := + Make_Op_Add (Loc, + Left_Opnd => Op_Expr, + Right_Opnd => Make_Integer_Literal (Loc, Modulus (Typ))); + end if; + Mod_Expr := Make_Op_Mod (Loc, Left_Opnd => Op_Expr, Right_Opnd => Make_Integer_Literal (Loc, Modulus (Typ))); - Rewrite (N, - Unchecked_Convert_To (Typ, Mod_Expr)); + Rewrite (N, Unchecked_Convert_To (Typ, Mod_Expr)); end Expand_Modular_Op; -------------------------------- @@ -4079,10 +4067,13 @@ package body Exp_Ch4 is procedure Expand_Modular_Subtraction is begin - -- If this is not the addition of a constant then compute it using - -- the general rule: (lhs + rhs) mod Modulus + -- If this is not the addition of a constant or else restriction + -- No_Implicit_Conditionals is in effect, then compute it using + -- the general rule: (lhs - rhs) mod Modulus. - if Nkind (Right_Opnd (N)) /= N_Integer_Literal then + if Nkind (Right_Opnd (N)) /= N_Integer_Literal + or else Restriction_Active (No_Implicit_Conditionals) + then Expand_Modular_Op; -- If this is an addition of a constant, convert it to a subtraction @@ -4101,6 +4092,7 @@ package body Exp_Ch4 is Cond_Expr : Node_Id; Then_Expr : Node_Id; Else_Expr : Node_Id; + begin Cond_Expr := Make_Op_Lt (Loc, @@ -4139,23 +4131,46 @@ package body Exp_Ch4 is -- Start of processing for Expand_Nonbinary_Modular_Op begin - -- No action needed if front-end expansion is not required or if we - -- have a binary modular operand. + -- No action needed if we have a binary modular operand - if not Expand_Nonbinary_Modular_Ops - or else not Non_Binary_Modulus (Typ) - then + if not Non_Binary_Modulus (Typ) then return; end if; case Nkind (N) is when N_Op_Add => + -- No action needed if front-end expansion is not required and + -- restriction No_Implicit_Conditionals is not in effect. + + if not Expand_Nonbinary_Modular_Ops + and then not Restriction_Active (No_Implicit_Conditionals) + then + return; + end if; + Expand_Modular_Addition; when N_Op_Subtract => + -- No action needed if front-end expansion is not required and + -- restriction No_Implicit_Conditionals is not in effect. + + if not Expand_Nonbinary_Modular_Ops + and then not Restriction_Active (No_Implicit_Conditionals) + then + return; + end if; + Expand_Modular_Subtraction; when N_Op_Minus => + -- No action needed if front-end expansion is not required and + -- restriction No_Implicit_Conditionals is not in effect. + + if not Expand_Nonbinary_Modular_Ops + and then not Restriction_Active (No_Implicit_Conditionals) + then + return; + end if; -- Expand -expr into (0 - expr) @@ -4166,6 +4181,14 @@ package body Exp_Ch4 is Analyze_And_Resolve (N, Typ); when others => + -- No action needed only if front-end expansion is not required + -- because we assume that logical and multiplicative operations + -- do not involve implicit conditionals. + + if not Expand_Nonbinary_Modular_Ops then + return; + end if; + Expand_Modular_Op; end case; @@ -4866,10 +4889,17 @@ package body Exp_Ch4 is Temp := Make_Temporary (Loc, 'P'); - Init_Stmts := - Build_Default_Initialization (N, Etyp, Temp, - For_CW => Is_Class_Wide_Type (Dtyp), - Target_Ref => Target_Ref); + if Is_Mutably_Tagged_Type (Dtyp) then + Init_Stmts := + Build_Default_Initialization (N, Etype (Etyp), Temp, + For_CW => False, + Target_Ref => Target_Ref); + else + Init_Stmts := + Build_Default_Initialization (N, Etyp, Temp, + For_CW => Is_Class_Wide_Type (Dtyp), + Target_Ref => Target_Ref); + end if; if Present (Init_Stmts) then -- We set the allocator as analyzed so that when we analyze @@ -8512,7 +8542,7 @@ package body Exp_Ch4 is -- For small negative exponents, we return the reciprocal of -- the folding of the exponentiation for the opposite (positive) - -- exponent, as required by Ada RM 4.5.6(11/3). + -- exponent, as required by RM 4.5.6(11/3). if abs Expv <= 4 then @@ -12721,6 +12751,9 @@ package body Exp_Ch4 is New_Lhs : Node_Id; New_Rhs : Node_Id; Check : Node_Id; + Lhs_Sel : Node_Id; + Rhs_Sel : Node_Id; + C_Typ : Entity_Id := Etype (C); begin if First_Time then @@ -12731,17 +12764,31 @@ package body Exp_Ch4 is New_Rhs := New_Copy_Tree (Rhs); end if; + Lhs_Sel := + Make_Selected_Component (Loc, + Prefix => New_Lhs, + Selector_Name => New_Occurrence_Of (C, Loc)); + Rhs_Sel := + Make_Selected_Component (Loc, + Prefix => New_Rhs, + Selector_Name => New_Occurrence_Of (C, Loc)); + + -- Generate mutably tagged conversions in case we encounter a + -- special class-wide equivalent type. + + if Is_Mutably_Tagged_CW_Equivalent_Type (Etype (C)) then + C_Typ := Corresponding_Mutably_Tagged_Type (Etype (C)); + Make_Mutably_Tagged_Conversion (Lhs_Sel, C_Typ); + Make_Mutably_Tagged_Conversion (Rhs_Sel, C_Typ); + end if; + Check := Expand_Composite_Equality - (Outer_Type => Typ, Nod => Nod, Comp_Type => Etype (C), - Lhs => - Make_Selected_Component (Loc, - Prefix => New_Lhs, - Selector_Name => New_Occurrence_Of (C, Loc)), - Rhs => - Make_Selected_Component (Loc, - Prefix => New_Rhs, - Selector_Name => New_Occurrence_Of (C, Loc))); + (Outer_Type => Typ, + Nod => Nod, + Comp_Type => C_Typ, + Lhs => Lhs_Sel, + Rhs => Rhs_Sel); -- If some (sub)component is an unchecked_union, the whole -- operation will raise program error. diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb index 2973658ce985b..35c2628fe25b7 100644 --- a/gcc/ada/exp_ch5.adb +++ b/gcc/ada/exp_ch5.adb @@ -41,6 +41,7 @@ with Exp_Pakd; use Exp_Pakd; with Exp_Tss; use Exp_Tss; with Exp_Util; use Exp_Util; with Inline; use Inline; +with Mutably_Tagged; use Mutably_Tagged; with Namet; use Namet; with Nlists; use Nlists; with Nmake; use Nmake; @@ -2398,8 +2399,14 @@ package body Exp_Ch5 is Lhs : constant Node_Id := Name (N); Loc : constant Source_Ptr := Sloc (N); Rhs : constant Node_Id := Expression (N); - Typ : constant Entity_Id := Underlying_Type (Etype (Lhs)); - Exp : Node_Id; + + -- Obtain the relevant corresponding mutably tagged type if necessary + + Typ : constant Entity_Id := + Get_Corresponding_Mutably_Tagged_Type_If_Present + (Underlying_Type (Etype (Lhs))); + + Exp : Node_Id; begin -- Special case to check right away, if the Componentwise_Assignment @@ -2776,7 +2783,9 @@ package body Exp_Ch5 is Apply_Discriminant_Check (Rhs, Typ, Lhs); end if; - elsif Is_Array_Type (Typ) and then Is_Constrained (Typ) then + elsif Is_Array_Type (Typ) and then + (Is_Constrained (Typ) or else Is_Mutably_Tagged_Conversion (Lhs)) + then Rewrite (Rhs, OK_Convert_To (Base_Type (Typ), Rhs)); Rewrite (Lhs, OK_Convert_To (Base_Type (Typ), Lhs)); if not Suppress_Assignment_Checks (N) then @@ -3072,13 +3081,64 @@ package body Exp_Ch5 is Attribute_Name => Name_Address))); end if; - Append_To (L, - Make_Raise_Constraint_Error (Loc, - Condition => - Make_Op_Ne (Loc, - Left_Opnd => Lhs_Tag, - Right_Opnd => Rhs_Tag), - Reason => CE_Tag_Check_Failed)); + -- Handle assignment to a mutably tagged type + + if Is_Mutably_Tagged_Conversion (Lhs) + or else Is_Mutably_Tagged_Type (Typ) + or else Is_Mutably_Tagged_Type (Etype (Lhs)) + then + -- Create a tag check when we have the extra + -- constrained formal and it is true (meaning we + -- are not dealing with a mutably tagged object). + + if Is_Entity_Name (Name (N)) + and then Is_Formal (Entity (Name (N))) + and then Present + (Extra_Constrained (Entity (Name (N)))) + then + Append_To (L, + Make_If_Statement (Loc, + Condition => + New_Occurrence_Of + (Extra_Constrained + (Entity (Name (N))), Loc), + Then_Statements => New_List ( + Make_Raise_Constraint_Error (Loc, + Condition => + Make_Op_Ne (Loc, + Left_Opnd => Lhs_Tag, + Right_Opnd => Rhs_Tag), + Reason => CE_Tag_Check_Failed)))); + end if; + + -- Generate a tag assignment before the actual + -- assignment so we dispatch to the proper + -- assign version. + + Append_To (L, + Make_Assignment_Statement (Loc, + Name => + Make_Selected_Component (Loc, + Prefix => Duplicate_Subexpr (Lhs), + Selector_Name => + Make_Identifier (Loc, Name_uTag)), + Expression => + Make_Selected_Component (Loc, + Prefix => Duplicate_Subexpr (Rhs), + Selector_Name => + Make_Identifier (Loc, Name_uTag)))); + + -- Otherwise generate a normal tag check + + else + Append_To (L, + Make_Raise_Constraint_Error (Loc, + Condition => + Make_Op_Ne (Loc, + Left_Opnd => Lhs_Tag, + Right_Opnd => Rhs_Tag), + Reason => CE_Tag_Check_Failed)); + end if; end; end if; @@ -4394,6 +4454,18 @@ package body Exp_Ch5 is Reinit_Field_To_Zero (Init_Name, F_SPARK_Pragma_Inherited); Mutate_Ekind (Init_Name, E_Loop_Parameter); + -- Wrap the block statements with the condition specified in the + -- iterator filter when one is present. + + if Present (Iterator_Filter (I_Spec)) then + pragma Assert (Ada_Version >= Ada_2022); + Set_Statements (Handled_Statement_Sequence (N), + New_List (Make_If_Statement (Loc, + Condition => Iterator_Filter (I_Spec), + Then_Statements => + Statements (Handled_Statement_Sequence (N))))); + end if; + -- The cursor was marked as a loop parameter to prevent user assignments -- to it, however this renders the advancement step illegal as it is not -- possible to change the value of a constant. Flag the advancement step @@ -4436,6 +4508,7 @@ package body Exp_Ch5 is Advance : Node_Id; Init : Node_Id; New_Loop : Node_Id; + Block : Node_Id; begin -- For an element iterator, the Element aspect must be present, @@ -4456,7 +4529,6 @@ package body Exp_Ch5 is Build_Formal_Container_Iteration (N, Container, Cursor, Init, Advance, New_Loop); - Append_To (Stats, Advance); Mutate_Ekind (Cursor, E_Variable); Insert_Action (N, Init); @@ -4481,13 +4553,30 @@ package body Exp_Ch5 is Convert_To_Iterable_Type (Container, Loc), New_Occurrence_Of (Cursor, Loc)))); - Set_Statements (New_Loop, - New_List - (Make_Block_Statement (Loc, - Declarations => New_List (Elmt_Decl), - Handled_Statement_Sequence => - Make_Handled_Sequence_Of_Statements (Loc, - Statements => Stats)))); + Block := + Make_Block_Statement (Loc, + Declarations => New_List (Elmt_Decl), + Handled_Statement_Sequence => + Make_Handled_Sequence_Of_Statements (Loc, + Statements => Stats)); + + -- Wrap the block statements with the condition specified in the + -- iterator filter when one is present. + + if Present (Iterator_Filter (I_Spec)) then + pragma Assert (Ada_Version >= Ada_2022); + Set_Statements (Handled_Statement_Sequence (Block), + New_List ( + Make_If_Statement (Loc, + Condition => Iterator_Filter (I_Spec), + Then_Statements => + Statements (Handled_Statement_Sequence (Block))), + Advance)); + else + Append_To (Stats, Advance); + end if; + + Set_Statements (New_Loop, New_List (Block)); -- The element is only modified in expanded code, so it appears as -- unassigned to the warning machinery. We must suppress this spurious @@ -5322,10 +5411,16 @@ package body Exp_Ch5 is Ent := First_Entity (Cont_Type_Pack); while Present (Ent) loop + + -- Ignore subprogram bodies + + if Ekind (Ent) = E_Subprogram_Body then + null; + -- Get_Element_Access function with one parameter called -- Position. - if Chars (Ent) = Name_Get_Element_Access + elsif Chars (Ent) = Name_Get_Element_Access and then Ekind (Ent) = E_Function and then Present (First_Formal (Ent)) and then Chars (First_Formal (Ent)) = Name_Position diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index a8a70a5759dce..da19c031c3dc3 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -642,15 +642,20 @@ package body Exp_Ch6 is Master_Formal : Node_Id; begin + pragma Assert (Ekind (Function_Id) in E_Function + | E_Subprogram_Type); + -- No such extra parameters are needed if there are no tasks if not Needs_BIP_Task_Actuals (Function_Id) then -- However we must add dummy extra actuals if the function is - -- a dispatching operation that inherited these extra formals. + -- a dispatching operation that inherited these extra formals + -- or an access-to-subprogram type that requires these extra + -- actuals. - if Is_Dispatching_Operation (Function_Id) - and then Has_BIP_Extra_Formal (Function_Id, BIP_Task_Master) + if Has_BIP_Extra_Formal (Function_Id, BIP_Task_Master, + Must_Be_Frozen => False) then Master_Formal := Build_In_Place_Formal (Function_Id, BIP_Task_Master); @@ -4219,8 +4224,10 @@ package body Exp_Ch6 is -- because the object has underlying discriminants with defaults. if Present (Extra_Constrained (Formal)) then - if Is_Private_Type (Etype (Prev)) - and then not Has_Discriminants (Base_Type (Etype (Prev))) + if Is_Mutably_Tagged_Type (Etype (Actual)) + or else (Is_Private_Type (Etype (Prev)) + and then not Has_Discriminants + (Base_Type (Etype (Prev)))) then Add_Extra_Actual (Expr => New_Occurrence_Of (Standard_False, Loc), @@ -5306,10 +5313,11 @@ package body Exp_Ch6 is then Expand_Inlined_Call (Call_Node, Subp, Orig_Subp); - -- Back-end inlining either if optimization is enabled or the call is - -- required to be inlined. + -- Back-end inlining either if optimization is enabled, we're + -- generating C, or the call is required to be inlined. elsif Optimization_Level > 0 + or else CCG_Mode or else Has_Pragma_Inline_Always (Subp) then Add_Inlined_Body (Subp, Call_Node); @@ -7635,7 +7643,6 @@ package body Exp_Ch6 is Dynamic_Call_Helper (CW_Subp); Actuals : constant List_Id := New_List; A : Node_Id := First_Actual (Call_Node); - F : Entity_Id := First_Formal (Helper_Id); begin while Present (A) loop @@ -7646,7 +7653,7 @@ package body Exp_Ch6 is Remove_Side_Effects (A); Append_To (Actuals, New_Copy_Tree (A)); - Next_Formal (F); + Next_Actual (A); end loop; @@ -7869,6 +7876,7 @@ package body Exp_Ch6 is Present (Controlling_Argument (Call_Node)); Class_Subp : Entity_Id; Cond : Node_Id; + Fail : Node_Id; Subp : Entity_Id; -- Start of processing for Install_Class_Preconditions_Check @@ -7914,30 +7922,29 @@ package body Exp_Ch6 is end if; if Exception_Locations_Suppressed then - Insert_Action (Call_Node, - Make_If_Statement (Loc, - Condition => Make_Op_Not (Loc, Cond), - Then_Statements => New_List ( - Make_Raise_Statement (Loc, - Name => - New_Occurrence_Of - (RTE (RE_Assert_Failure), Loc))))); + Fail := + Make_Raise_Statement (Loc, + Name => + New_Occurrence_Of + (RTE (RE_Assert_Failure), Loc)); -- Failed check with message indicating the failed precondition and the -- call that caused it. else - Insert_Action (Call_Node, - Make_If_Statement (Loc, - Condition => Make_Op_Not (Loc, Cond), - Then_Statements => New_List ( - Make_Procedure_Call_Statement (Loc, - Name => - New_Occurrence_Of - (RTE (RE_Raise_Assert_Failure), Loc), - Parameter_Associations => - New_List (Build_Error_Message (Subp)))))); + Fail := + Make_Procedure_Call_Statement (Loc, + Name => + New_Occurrence_Of + (RTE (RE_Raise_Assert_Failure), Loc), + Parameter_Associations => + New_List (Build_Error_Message (Subp))); end if; + + Insert_Action (Call_Node, + Make_If_Statement (Loc, + Condition => Make_Op_Not (Loc, Cond), + Then_Statements => New_List (Fail))); end Install_Class_Preconditions_Check; ------------------------------ diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb index 993c13c73187b..e3e9bac2b34a2 100644 --- a/gcc/ada/exp_ch7.adb +++ b/gcc/ada/exp_ch7.adb @@ -839,7 +839,7 @@ package body Exp_Ch7 is and then Needs_BIP_Collection (Func_Id) then declare - Ptr_Typ : constant Node_Id := Make_Temporary (Loc, 'P'); + Ptr_Typ : constant Node_Id := Make_Temporary (Loc, 'P'); Param : constant Entity_Id := Make_Defining_Identifier (Loc, Name_V); @@ -861,27 +861,26 @@ package body Exp_Ch7 is Fin_Body := Make_Subprogram_Body (Loc, Specification => - Make_Procedure_Specification (Loc, - Defining_Unit_Name => Fin_Id, - - Parameter_Specifications => New_List ( - Make_Parameter_Specification (Loc, - Defining_Identifier => Param, - Parameter_Type => - New_Occurrence_Of (RTE (RE_Address), Loc)))), - - Declarations => New_List ( - Make_Full_Type_Declaration (Loc, - Defining_Identifier => Ptr_Typ, - Type_Definition => - Make_Access_To_Object_Definition (Loc, - All_Present => True, - Subtype_Indication => - New_Occurrence_Of (Obj_Typ, Loc)))), + Make_Procedure_Specification (Loc, + Defining_Unit_Name => Fin_Id, + Parameter_Specifications => New_List ( + Make_Parameter_Specification (Loc, + Defining_Identifier => Param, + Parameter_Type => + New_Occurrence_Of (RTE (RE_Address), Loc)))), + + Declarations => New_List ( + Make_Full_Type_Declaration (Loc, + Defining_Identifier => Ptr_Typ, + Type_Definition => + Make_Access_To_Object_Definition (Loc, + All_Present => True, + Subtype_Indication => + New_Occurrence_Of (Obj_Typ, Loc)))), - Handled_Statement_Sequence => - Make_Handled_Sequence_Of_Statements (Loc, - Statements => Fin_Stmts)); + Handled_Statement_Sequence => + Make_Handled_Sequence_Of_Statements (Loc, + Statements => Fin_Stmts)); Insert_After_And_Analyze (Master_Node_Ins, Fin_Body, Suppress => All_Checks); @@ -1318,41 +1317,12 @@ package body Exp_Ch7 is Append_To (Stmts, Build_Runtime_Call (Loc, RE_Complete_Master)); end if; - -- Add statements to unlock the protected object parameter and to - -- undefer abort. If the context is a protected procedure and the object - -- has entries, call the entry service routine. - - -- NOTE: The generated code references _object, a parameter to the - -- procedure. + -- Add statements to undefer abort. elsif Is_Protected_Subp_Body then - declare - Spec : constant Node_Id := Parent (Corresponding_Spec (N)); - Conc_Typ : Entity_Id := Empty; - Param : Node_Id; - Param_Typ : Entity_Id; - - begin - -- Find the _object parameter representing the protected object - - Param := First (Parameter_Specifications (Spec)); - loop - Param_Typ := Etype (Parameter_Type (Param)); - - if Ekind (Param_Typ) = E_Record_Type then - Conc_Typ := Corresponding_Concurrent_Type (Param_Typ); - end if; - - exit when No (Param) or else Present (Conc_Typ); - Next (Param); - end loop; - - pragma Assert (Present (Param)); - pragma Assert (Present (Conc_Typ)); - - Build_Protected_Subprogram_Call_Cleanup - (Specification (N), Conc_Typ, Loc, Stmts); - end; + if Abort_Allowed then + Append_To (Stmts, Build_Runtime_Call (Loc, RE_Abort_Undefer)); + end if; -- Add a call to Expunge_Unactivated_Tasks for dynamically allocated -- tasks. Other unactivated tasks are completed by Complete_Task or @@ -2477,26 +2447,6 @@ package body Exp_Ch7 is Processing_Actions (Decl, Is_Protected => True); end if; - -- Specific cases of object renamings - - elsif Nkind (Decl) = N_Object_Renaming_Declaration then - Obj_Id := Defining_Identifier (Decl); - Obj_Typ := Base_Type (Etype (Obj_Id)); - - -- Bypass any form of processing for objects which have their - -- finalization disabled. This applies only to objects at the - -- library level. - - if For_Package and then Finalize_Storage_Only (Obj_Typ) then - null; - - -- Ignored Ghost object renamings do not need any cleanup - -- actions because they will not appear in the final tree. - - elsif Is_Ignored_Ghost_Entity (Obj_Id) then - null; - end if; - -- Inspect the freeze node of an access-to-controlled type and -- look for a delayed finalization collection. This case arises -- when the freeze actions are inserted at a later time than the @@ -2701,7 +2651,7 @@ package body Exp_Ch7 is -- Processing for simple protected objects. Such objects require -- manual finalization of their lock managers. Generate: - -- procedure obj_type_nnFD (v :system__address) is + -- procedure obj_typ_nnFD (v : system__address) is -- type Ptr_Typ is access all Obj_Typ; -- Rnn : Obj_Typ renames Ptr_Typ!(v).all; -- begin @@ -2710,7 +2660,7 @@ package body Exp_Ch7 is -- exception -- when others => -- null; - -- end obj_type_nnFD; + -- end obj_typ_nnFD; if Is_Protected or else (Has_Simple_Protected_Object (Obj_Typ) @@ -2807,6 +2757,76 @@ package body Exp_Ch7 is Master_Node_Ins := Fin_Body; end; + -- If the object's subtype is an array that has a constrained first + -- subtype and is not this first subtype, we need to build a special + -- Finalize_Address primitive for the object's subtype because the + -- Finalize_Address primitive of the base type has been tailored to + -- the first subtype (see Make_Finalize_Address_Stmts). Generate: + + -- procedure obj_typ_nnFD (v : system__address) is + -- type Ptr_Typ is access all Obj_Typ; + -- begin + -- obj_typBDF (Ptr_Typ!(v).all, f => true); + -- end obj_typ_nnFD; + + elsif Is_Array_Type (Etype (Obj_Id)) + and then Is_Constrained (First_Subtype (Etype (Obj_Id))) + and then Etype (Obj_Id) /= First_Subtype (Etype (Obj_Id)) + then + declare + Ptr_Typ : constant Node_Id := Make_Temporary (Loc, 'P'); + Param : constant Entity_Id := + Make_Defining_Identifier (Loc, Name_V); + + Fin_Body : Node_Id; + + begin + Obj_Typ := Etype (Obj_Id); + + Fin_Id := + Make_Defining_Identifier (Loc, + Make_TSS_Name_Local + (Obj_Typ, TSS_Finalize_Address)); + + Fin_Body := + Make_Subprogram_Body (Loc, + Specification => + Make_Procedure_Specification (Loc, + Defining_Unit_Name => Fin_Id, + Parameter_Specifications => New_List ( + Make_Parameter_Specification (Loc, + Defining_Identifier => Param, + Parameter_Type => + New_Occurrence_Of (RTE (RE_Address), Loc)))), + + Declarations => New_List ( + Make_Full_Type_Declaration (Loc, + Defining_Identifier => Ptr_Typ, + Type_Definition => + Make_Access_To_Object_Definition (Loc, + All_Present => True, + Subtype_Indication => + New_Occurrence_Of (Obj_Typ, Loc)))), + + Handled_Statement_Sequence => + Make_Handled_Sequence_Of_Statements (Loc, + Statements => New_List ( + Make_Final_Call ( + Obj_Ref => + Make_Explicit_Dereference (Loc, + Prefix => + Unchecked_Convert_To (Ptr_Typ, + Make_Identifier (Loc, Name_V))), + Typ => Obj_Typ)))); + + Push_Scope (Scope (Obj_Id)); + Insert_After_And_Analyze + (Master_Node_Ins, Fin_Body, Suppress => All_Checks); + Pop_Scope; + + Master_Node_Ins := Fin_Body; + end; + else Fin_Id := Finalize_Address (Obj_Typ); @@ -7419,7 +7439,7 @@ package body Exp_Ch7 is -- non-POC components are finalized before the -- non-POC extension components. This violates the -- usual "finalize in reverse declaration order" - -- principle, but that's ok (see Ada RM 7.6.1(9)). + -- principle, but that's ok (see RM 7.6.1(9)). -- -- Last_POC_Call should be non-empty if the extension -- has at least one POC. Interactions with variant @@ -8268,6 +8288,9 @@ package body Exp_Ch7 is if Has_Controlled_Component (Utyp) then Proc := TSS (Utyp, Deep_Name_Of (Initialize_Case)); + elsif Is_Mutably_Tagged_Type (Utyp) then + Proc := Find_Prim_Op (Etype (Utyp), Name_Of (Initialize_Case)); + Check_Visibly_Controlled (Initialize_Case, Etype (Typ), Proc, Ref); else Proc := Find_Prim_Op (Utyp, Name_Of (Initialize_Case)); Check_Visibly_Controlled (Initialize_Case, Typ, Proc, Ref); diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb index 4de253ab6e839..890bd038c5b95 100644 --- a/gcc/ada/exp_ch9.adb +++ b/gcc/ada/exp_ch9.adb @@ -442,6 +442,15 @@ package body Exp_Ch9 is -- Determine whether Id is a function or a procedure and is marked as a -- private primitive. + function Make_Unlock_Statement + (Prot_Type : E_Protected_Type_Id; + Op_Spec : N_Subprogram_Specification_Id; + Loc : Source_Ptr) return N_Procedure_Call_Statement_Id; + -- Build a statement that is suitable to unlock an object of type Prot_Type + -- after having performed a protected operation on it. Prot_Type and + -- Op_Spec are used to determine which unlocking subprogram to call, and + -- whether to serve entries before unlocking. + function Null_Statements (Stats : List_Id) return Boolean; -- Used to check DO-END sequence. Checks for equivalent of DO NULL; END. -- Allows labels, and pragma Warnings/Unreferenced in the sequence as well @@ -496,6 +505,18 @@ package body Exp_Ch9 is -- a rescheduling is required, so this optimization is not allowed. This -- function returns True if the optimization is permitted. + function Wrap_Unprotected_Call + (Call : Node_Id; + Prot_Type : E_Protected_Type_Id; + Op_Spec : N_Subprogram_Specification_Id; + Loc : Source_Ptr) return N_Block_Statement_Id; + -- Wrap Call into a block statement with a cleanup procedure set up to + -- release the lock on a protected object of type Prot_Type. Call must be + -- a statement that represents the inner and unprotected execution of the + -- body of a protected operation. Op_Spec must be the spec of that + -- protected operation. This is a subsidiary subprogram of + -- Build_Protected_Subprogram_Body. + ----------------------------- -- Actual_Index_Expression -- ----------------------------- @@ -3849,16 +3870,6 @@ package body Exp_Ch9 is Lock_Kind := RE_Lock; end if; - -- Wrap call in block that will be covered by an at_end handler - - if Might_Raise then - Unprot_Call := - Make_Block_Statement (Loc, - Handled_Statement_Sequence => - Make_Handled_Sequence_Of_Statements (Loc, - Statements => New_List (Unprot_Call))); - end if; - -- Make the protected subprogram body. This locks the protected -- object and calls the unprotected version of the subprogram. @@ -3889,18 +3900,24 @@ package body Exp_Ch9 is Name => Lock_Name, Parameter_Associations => New_List (Object_Parm)); - if Abort_Allowed then - Stmts := New_List ( - Build_Runtime_Call (Loc, RE_Abort_Defer), - Lock_Stmt); - - else - Stmts := New_List (Lock_Stmt); - end if; + Stmts := (if Abort_Allowed then + New_List (Build_Runtime_Call (Loc, RE_Abort_Defer)) + else + New_List); if Might_Raise then + Unprot_Call := Wrap_Unprotected_Call + (Unprot_Call, Pid, Op_Spec, Loc); + + Unprot_Call := + Make_Block_Statement (Loc, + Handled_Statement_Sequence => + Make_Handled_Sequence_Of_Statements (Loc, + Statements => New_List (Lock_Stmt, Unprot_Call))); + Append (Unprot_Call, Stmts); else + Append (Lock_Stmt, Stmts); if Nkind (Op_Spec) = N_Function_Specification then Pre_Stmts := Stmts; Stmts := Empty_List; @@ -4022,74 +4039,10 @@ package body Exp_Ch9 is Loc : Source_Ptr; Stmts : List_Id) is - Nam : Node_Id; - + Unlock_Stmt : constant N_Procedure_Call_Statement_Id := + Make_Unlock_Statement (Conc_Typ, Op_Spec, Loc); begin - -- If the associated protected object has entries, the expanded - -- exclusive protected operation has to service entry queues. In - -- this case generate: - - -- Service_Entries (_object._object'Access); - - if (Nkind (Op_Spec) = N_Procedure_Specification - or else - (Nkind (Op_Spec) = N_Function_Specification - and then - Has_Enabled_Aspect - (Conc_Typ, Aspect_Exclusive_Functions))) - and then Has_Entries (Conc_Typ) - then - case Corresponding_Runtime_Package (Conc_Typ) is - when System_Tasking_Protected_Objects_Entries => - Nam := New_Occurrence_Of (RTE (RE_Service_Entries), Loc); - - when System_Tasking_Protected_Objects_Single_Entry => - Nam := New_Occurrence_Of (RTE (RE_Service_Entry), Loc); - - when others => - raise Program_Error; - end case; - - Append_To (Stmts, - Make_Procedure_Call_Statement (Loc, - Name => Nam, - Parameter_Associations => New_List ( - Make_Attribute_Reference (Loc, - Prefix => - Make_Selected_Component (Loc, - Prefix => Make_Identifier (Loc, Name_uObject), - Selector_Name => Make_Identifier (Loc, Name_uObject)), - Attribute_Name => Name_Unchecked_Access)))); - - else - -- Generate: - -- Unlock (_object._object'Access); - - case Corresponding_Runtime_Package (Conc_Typ) is - when System_Tasking_Protected_Objects_Entries => - Nam := New_Occurrence_Of (RTE (RE_Unlock_Entries), Loc); - - when System_Tasking_Protected_Objects_Single_Entry => - Nam := New_Occurrence_Of (RTE (RE_Unlock_Entry), Loc); - - when System_Tasking_Protected_Objects => - Nam := New_Occurrence_Of (RTE (RE_Unlock), Loc); - - when others => - raise Program_Error; - end case; - - Append_To (Stmts, - Make_Procedure_Call_Statement (Loc, - Name => Nam, - Parameter_Associations => New_List ( - Make_Attribute_Reference (Loc, - Prefix => - Make_Selected_Component (Loc, - Prefix => Make_Identifier (Loc, Name_uObject), - Selector_Name => Make_Identifier (Loc, Name_uObject)), - Attribute_Name => Name_Unchecked_Access)))); - end if; + Append_To (Stmts, Unlock_Stmt); -- Generate: -- Abort_Undefer; @@ -14495,6 +14448,66 @@ package body Exp_Ch9 is Parameter_Associations => Args); end Make_Task_Create_Call; + --------------------------- + -- Make_Unlock_Statement -- + --------------------------- + + function Make_Unlock_Statement + (Prot_Type : E_Protected_Type_Id; + Op_Spec : N_Subprogram_Specification_Id; + Loc : Source_Ptr) return N_Procedure_Call_Statement_Id + is + Nam : constant N_Identifier_Id := + -- If the associated protected object has entries, the expanded + -- exclusive protected operation has to service entry queues. + + (if (Nkind (Op_Spec) = N_Procedure_Specification + or else + (Nkind (Op_Spec) = N_Function_Specification + and then + Has_Enabled_Aspect + (Prot_Type, Aspect_Exclusive_Functions))) + and then Has_Entries (Prot_Type) + then + (case Corresponding_Runtime_Package (Prot_Type) is + when System_Tasking_Protected_Objects_Entries => + New_Occurrence_Of (RTE (RE_Service_Entries), Loc), + + when System_Tasking_Protected_Objects_Single_Entry => + New_Occurrence_Of (RTE (RE_Service_Entry), Loc), + + when others => + raise Program_Error) + + -- Otherwise, unlocking the protected object is sufficient. + + else + (case Corresponding_Runtime_Package (Prot_Type) is + when System_Tasking_Protected_Objects_Entries => + New_Occurrence_Of (RTE (RE_Unlock_Entries), Loc), + + when System_Tasking_Protected_Objects_Single_Entry => + New_Occurrence_Of (RTE (RE_Unlock_Entry), Loc), + + when System_Tasking_Protected_Objects => + New_Occurrence_Of (RTE (RE_Unlock), Loc), + + when others => + raise Program_Error)); + begin + return Make_Procedure_Call_Statement + (Loc, + Name => Nam, + Parameter_Associations => + New_List ( + Make_Attribute_Reference (Loc, + Prefix => + Make_Selected_Component (Loc, + Prefix => Make_Identifier (Loc, Name_uObject), + Selector_Name => Make_Identifier (Loc, Name_uObject)), + Attribute_Name => Name_Unchecked_Access))); + end Make_Unlock_Statement; + ------------------------------ -- Next_Protected_Operation -- ------------------------------ @@ -14861,4 +14874,49 @@ package body Exp_Ch9 is end case; end Trivial_Accept_OK; + --------------------------- + -- Wrap_Unprotected_Call -- + --------------------------- + + function Wrap_Unprotected_Call + (Call : Node_Id; + Prot_Type : E_Protected_Type_Id; + Op_Spec : N_Subprogram_Specification_Id; + Loc : Source_Ptr) return N_Block_Statement_Id + is + Body_Id : constant N_Defining_Identifier_Id := + Make_Defining_Identifier (Loc, Name_Find ("_unlock")); + + Unlock_Body : constant N_Subprogram_Body_Id := + Make_Subprogram_Body + (Loc, + Specification => + Make_Procedure_Specification (Loc, Defining_Unit_Name => Body_Id), + Handled_Statement_Sequence => + Make_Handled_Sequence_Of_Statements + (Loc, Statements => New_List + (Make_Unlock_Statement (Prot_Type, Op_Spec, Loc)))); + + Decls : constant List_Id := New_List (Unlock_Body); + + HSS : constant N_Handled_Sequence_Of_Statements_Id := + Make_Handled_Sequence_Of_Statements + (Loc, Statements => New_List (Call), + At_End_Proc => New_Occurrence_Of (Body_Id, Loc)); + + Block_Statement : constant N_Block_Statement_Id := + Make_Block_Statement + (Loc, Declarations => Decls, + Handled_Statement_Sequence => + HSS); + + begin + if Debug_Generated_Code then + Set_Debug_Info_Needed (Body_Id); + end if; + + Set_Acts_As_Spec (Unlock_Body); + + return Block_Statement; + end Wrap_Unprotected_Call; end Exp_Ch9; diff --git a/gcc/ada/exp_disp.adb b/gcc/ada/exp_disp.adb index 66be77c9ffca4..77256ac5af1c7 100644 --- a/gcc/ada/exp_disp.adb +++ b/gcc/ada/exp_disp.adb @@ -70,6 +70,7 @@ with Stringt; use Stringt; with Strub; use Strub; with SCIL_LL; use SCIL_LL; with Tbuild; use Tbuild; +with Ttypes; use Ttypes; package body Exp_Disp is @@ -4598,6 +4599,10 @@ package body Exp_Disp is -- (2) External_Tag (combined with Internal_Tag) is used for object -- streaming and No_Tagged_Streams inhibits the generation of -- streams. + -- Instead of No_Tagged_Streams, which applies either to a single + -- type or to a declarative region, it is possible to use restriction + -- No_Streams, which prevents stream objects from being created in the + -- entire partition. Discard_Names : constant Boolean := (Present (No_Tagged_Streams_Pragma (Typ)) @@ -5213,8 +5218,10 @@ package body Exp_Disp is Chars => New_External_Name (Tname, 'A')); Full_Name : constant String_Id := Fully_Qualified_Name_String (First_Subtype (Typ)); - Str1_Id : String_Id; - Str2_Id : String_Id; + + Address_Image : RE_Id; + Str1_Id : String_Id; + Str2_Id : String_Id; begin -- Generate: @@ -5236,7 +5243,17 @@ package body Exp_Disp is -- Exname : constant String := -- Str1 & Address_Image (Tag) & Str2; - if RTE_Available (RE_Address_Image) then + -- We use Address_Image64 for Morello because Integer_Address + -- is 64-bit large even though Address is 128-bit large. + + case System_Address_Size is + when 32 => Address_Image := RE_Address_Image32; + when 64 => Address_Image := RE_Address_Image64; + when 128 => Address_Image := RE_Address_Image64; + when others => raise Program_Error; + end case; + + if RTE_Available (Address_Image) then Append_To (Result, Make_Object_Declaration (Loc, Defining_Identifier => Exname, @@ -5252,7 +5269,7 @@ package body Exp_Disp is Make_Function_Call (Loc, Name => New_Occurrence_Of - (RTE (RE_Address_Image), Loc), + (RTE (Address_Image), Loc), Parameter_Associations => New_List ( Unchecked_Convert_To (RTE (RE_Address), New_Occurrence_Of (DT_Ptr, Loc)))), @@ -7561,11 +7578,7 @@ package body Exp_Disp is if Chars (Prim) = Name_uSize and then RTE_Record_Component_Available (RE_Size_Func) then - DT_Ptr := Node (First_Elmt (Access_Disp_Table (Tag_Typ))); - Append_To (L, - Build_Set_Size_Function (Loc, - Tag_Node => New_Occurrence_Of (DT_Ptr, Loc), - Size_Func => Prim)); + Append_To (L, Build_Set_Size_Function (Loc, Tag_Typ, Prim)); end if; else @@ -8742,6 +8755,10 @@ package body Exp_Disp is Write_Str ("(predefined) "); end if; + if Is_Wrapper (Prim) then + Write_Str ("(wrapper) "); + end if; + -- Prefix the name of the primitive with its corresponding tagged -- type to facilitate seeing inherited primitives. diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index 654ea7d912458..528001ea70a00 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -181,22 +181,6 @@ package body Exp_Util is -- Determine whether pragma Default_Initial_Condition denoted by Prag has -- an assertion expression that should be verified at run time. - function Make_CW_Equivalent_Type - (T : Entity_Id; - E : Node_Id) return Entity_Id; - -- T is a class-wide type entity, E is the initial expression node that - -- constrains T in case such as: " X: T := E" or "new T'(E)". This function - -- returns the entity of the Equivalent type and inserts on the fly the - -- necessary declaration such as: - -- - -- type anon is record - -- _parent : Root_Type (T); constrained with E discriminants (if any) - -- Extension : String (1 .. expr to match size of E); - -- end record; - -- - -- This record is compatible with any object of the class of T thanks to - -- the first field and has the same size as E thanks to the second. - function Make_Literal_Range (Loc : Source_Ptr; Literal_Typ : Entity_Id) return Node_Id; @@ -6433,7 +6417,7 @@ package body Exp_Util is Obj_Typ := Base_Type (Etype (Obj_Id)); if Is_Access_Type (Obj_Typ) then - Obj_Typ := Available_View (Designated_Type (Obj_Typ)); + Obj_Typ := Base_Type (Available_View (Designated_Type (Obj_Typ))); end if; -- Handle the initialization type of the object declaration @@ -8101,6 +8085,10 @@ package body Exp_Util is | N_Task_Body | N_Task_Body_Stub + -- Other things that can occur in stmt or decl lists + + | N_Itype_Reference + -- Use clauses can appear in lists of declarations | N_Use_Package_Clause @@ -8370,7 +8358,6 @@ package body Exp_Util is | N_Integer_Literal | N_Iterator_Specification | N_Interpolated_String_Literal - | N_Itype_Reference | N_Label | N_Loop_Parameter_Specification | N_Mod_Clause @@ -8646,8 +8633,8 @@ package body Exp_Util is ------------------------------ function Is_Finalizable_Transient - (Decl : Node_Id; - Rel_Node : Node_Id) return Boolean + (Decl : Node_Id; + N : Node_Id) return Boolean is Obj_Id : constant Entity_Id := Defining_Identifier (Decl); Obj_Typ : constant Entity_Id := Base_Type (Etype (Obj_Id)); @@ -8808,9 +8795,10 @@ package body Exp_Util is First_Stmt : Node_Id) return Boolean is function Find_Renamed_Object (Ren_Decl : Node_Id) return Entity_Id; - -- Given an object renaming declaration, retrieve the entity of the - -- renamed name. Return Empty if the renamed name is anything other - -- than a variable or a constant. + -- Given an object renaming declaration, retrieve the entity within + -- the renamed name, recursively if this entity is itself a renaming. + -- Return Empty if the renamed name contains anything other than a + -- variable or a constant. ------------------------- -- Find_Renamed_Object -- @@ -8877,7 +8865,16 @@ package body Exp_Util is Search (Constant_Value (Ren_Obj)); end if; - return Ren_Obj; + -- Recurse if Ren_Obj is itself a renaming + + if Present (Ren_Obj) + and then Ekind (Ren_Obj) in E_Constant | E_Variable + and then Present (Renamed_Object (Ren_Obj)) + then + return Find_Renamed_Object (Declaration_Node (Ren_Obj)); + else + return Ren_Obj; + end if; end Find_Renamed_Object; -- Local variables @@ -8889,61 +8886,53 @@ package body Exp_Util is -- Start of processing for Is_Aliased begin - -- A controlled transient object is not considered aliased when it - -- appears inside an expression_with_actions node even when there are - -- explicit aliases of it: - - -- do - -- Trans_Id : Ctrl_Typ ...; -- transient object - -- Alias : ... := Trans_Id; -- object is aliased - -- Val : constant Boolean := - -- ... Alias ...; -- aliasing ends - -- -- object safe to finalize - -- in Val end; - - -- Expansion ensures that all aliases are encapsulated in the actions - -- list and do not leak to the expression by forcing the evaluation - -- of the expression. - - if Nkind (Rel_Node) = N_Expression_With_Actions then - return False; - - -- Otherwise examine the statements after the controlled transient - -- object and look for various forms of aliasing. - - else - Stmt := First_Stmt; - while Present (Stmt) loop - if Nkind (Stmt) = N_Object_Declaration then - Expr := Expression (Stmt); + -- Examine the statements following the controlled object and look + -- for various forms of aliasing. + + Stmt := First_Stmt; + while Present (Stmt) loop + -- Transient objects initialized by a reference are finalized + -- (see Initialized_By_Reference above), so we must make sure + -- not to finalize the referenced object twice. And we cannot + -- finalize it at all if it is referenced by the nontransient + -- object serviced by the transient scope. + + if Nkind (Stmt) = N_Object_Declaration then + Expr := Expression (Stmt); + + -- Aliasing of the form: + -- Obj : ... := Trans_Id'reference; + + if Present (Expr) + and then Nkind (Expr) = N_Reference + and then Is_Entity_Name (Prefix (Expr)) + and then Entity (Prefix (Expr)) = Trans_Id + then + return True; + end if; - -- Aliasing of the form: - -- Obj : ... := Trans_Id'reference; + -- (Transient) renamings are never finalized so we need not bother + -- about finalizing transient renamed objects twice. Therefore, we + -- we only need to look at the nontransient object serviced by the + -- transient scope, if it exists and is declared as a renaming. - if Present (Expr) - and then Nkind (Expr) = N_Reference - and then Nkind (Prefix (Expr)) = N_Identifier - and then Entity (Prefix (Expr)) = Trans_Id - then - return True; - end if; - - elsif Nkind (Stmt) = N_Object_Renaming_Declaration then - Ren_Obj := Find_Renamed_Object (Stmt); + elsif Nkind (Stmt) = N_Object_Renaming_Declaration + and then Stmt = N + then + Ren_Obj := Find_Renamed_Object (Stmt); - -- Aliasing of the form: - -- Obj : ... renames ... Trans_Id ...; + -- Aliasing of the form: + -- Obj : ... renames ... Trans_Id ...; - if Present (Ren_Obj) and then Ren_Obj = Trans_Id then - return True; - end if; + if Present (Ren_Obj) and then Ren_Obj = Trans_Id then + return True; end if; + end if; - Next (Stmt); - end loop; + Next (Stmt); + end loop; - return False; - end if; + return False; end Is_Aliased; -------------------------- @@ -9161,8 +9150,8 @@ package body Exp_Util is return Ekind (Obj_Id) in E_Constant | E_Variable and then Needs_Finalization (Desig) - and then Nkind (Rel_Node) /= N_Simple_Return_Statement - and then not Is_Part_Of_BIP_Return_Statement (Rel_Node) + and then Nkind (N) /= N_Simple_Return_Statement + and then not Is_Part_Of_BIP_Return_Statement (N) -- Do not consider a transient object that was already processed @@ -10155,13 +10144,13 @@ package body Exp_Util is -- representation of the extension part.) function Make_CW_Equivalent_Type - (T : Entity_Id; - E : Node_Id) return Entity_Id + (T : Entity_Id; + E : Node_Id; + List_Def : out List_Id) return Entity_Id is Loc : constant Source_Ptr := Sloc (E); Root_Typ : constant Entity_Id := Root_Type (T); Root_Utyp : constant Entity_Id := Underlying_Type (Root_Typ); - List_Def : constant List_Id := Empty_List; Comp_List : constant List_Id := New_List; Equiv_Type : Entity_Id; @@ -10172,6 +10161,8 @@ package body Exp_Util is Size_Expr : Node_Id; begin + List_Def := New_List; + -- If the root type is already constrained, there are no discriminants -- in the expression. @@ -10209,7 +10200,10 @@ package body Exp_Util is -- need to convert it first to the class-wide type to force a call to -- the _Size primitive operation. - if Has_Tag_Of_Type (E) then + if No (E) then + Size_Attr := Make_Integer_Literal (Loc, RM_Size (T)); + + elsif Has_Tag_Of_Type (E) then if not Has_Discriminants (Etype (E)) or else Is_Constrained (Etype (E)) then @@ -10232,7 +10226,7 @@ package body Exp_Util is Attribute_Name => Name_Size); end if; - if not Is_Interface (Root_Typ) then + if not Is_Interface (Root_Typ) and then Present (E) then -- subtype rg__xx is -- Storage_Offset range 1 .. (Exp'size - Typ'object_size) @@ -10312,11 +10306,15 @@ package body Exp_Util is Set_Is_Class_Wide_Equivalent_Type (Equiv_Type); - -- A class-wide equivalent type does not require initialization + -- A class-wide equivalent type does not require initialization unless + -- no expression is present - in which case initialization gets + -- generated as part of the mutably tagged type machinery. - Set_Suppress_Initialization (Equiv_Type); + if Present (E) then + Set_Suppress_Initialization (Equiv_Type); + end if; - if not Is_Interface (Root_Typ) then + if not Is_Interface (Root_Typ) and Present (E) then Append_To (Comp_List, Make_Component_Declaration (Loc, Defining_Identifier => @@ -10341,6 +10339,8 @@ package body Exp_Util is Aliased_Present => False, Subtype_Indication => New_Occurrence_Of (RTE (RE_Tag), Loc)))); + + Set_Is_Tag (Defining_Identifier (Last (Comp_List))); end if; Append_To (Comp_List, @@ -10361,17 +10361,6 @@ package body Exp_Util is Component_Items => Comp_List, Variant_Part => Empty)))); - -- Suppress all checks during the analysis of the expanded code to avoid - -- the generation of spurious warnings under ZFP run-time. - - Insert_Actions (E, List_Def, Suppress => All_Checks); - - -- In the case of an interface type mark the tag for First_Tag_Component - - if Is_Interface (Root_Typ) then - Set_Is_Tag (First_Entity (Equiv_Type)); - end if; - return Equiv_Type; end Make_CW_Equivalent_Type; @@ -10760,6 +10749,7 @@ package body Exp_Util is declare CW_Subtype : constant Entity_Id := New_Class_Wide_Subtype (Unc_Typ, E); + Equiv_Def : List_Id; begin -- A class-wide equivalent type is not needed on VM targets @@ -10783,7 +10773,14 @@ package body Exp_Util is end if; Set_Equivalent_Type - (CW_Subtype, Make_CW_Equivalent_Type (Unc_Typ, E)); + (CW_Subtype, Make_CW_Equivalent_Type (Unc_Typ, E, Equiv_Def)); + + -- Suppress all checks during the analysis of the expanded + -- code to avoid the generation of spurious warnings under + -- ZFP run-time. + + Insert_Actions + (E, Equiv_Def, Suppress => All_Checks); end if; Set_Cloned_Subtype (CW_Subtype, Base_Type (Unc_Typ)); @@ -13488,26 +13485,6 @@ package body Exp_Util is return True; end if; - -- Specific cases of object renamings - - elsif Nkind (Decl) = N_Object_Renaming_Declaration then - Obj_Id := Defining_Identifier (Decl); - Obj_Typ := Base_Type (Etype (Obj_Id)); - - -- Bypass any form of processing for objects which have their - -- finalization disabled. This applies only to objects at the - -- library level. - - if Lib_Level and then Finalize_Storage_Only (Obj_Typ) then - null; - - -- Ignored Ghost object renamings do not need any cleanup actions - -- because they will not appear in the final tree. - - elsif Is_Ignored_Ghost_Entity (Obj_Id) then - null; - end if; - -- Inspect the freeze node of an access-to-controlled type and look -- for a delayed finalization collection. This case arises when the -- freeze actions are inserted at a later time than the expansion of diff --git a/gcc/ada/exp_util.ads b/gcc/ada/exp_util.ads index 3c7e70ed13b70..16d8e14976ca9 100644 --- a/gcc/ada/exp_util.ads +++ b/gcc/ada/exp_util.ads @@ -764,12 +764,10 @@ package Exp_Util is -- Rnn.all function Is_Finalizable_Transient - (Decl : Node_Id; - Rel_Node : Node_Id) return Boolean; - -- Determine whether declaration Decl denotes a controlled transient which - -- should be finalized. Rel_Node is the related context. Even though some - -- transients are controlled, they may act as renamings of other objects or - -- function calls. + (Decl : Node_Id; + N : Node_Id) return Boolean; + -- Determine whether declaration Decl denotes a controlled transient object + -- that must be finalized. N is the node serviced by the transient context. function Is_Fully_Repped_Tagged_Type (T : Entity_Id) return Boolean; -- Tests given type T, and returns True if T is a non-discriminated tagged @@ -887,6 +885,26 @@ package Exp_Util is -- list. If Warn is True, a warning will be output at the start of N -- indicating the deletion of the code. + function Make_CW_Equivalent_Type + (T : Entity_Id; + E : Node_Id; + List_Def : out List_Id) return Entity_Id; + -- T is a class-wide type entity, and E is the initial expression node that + -- constrains T in cases such as: " X: T := E" or "new T'(E)". When there + -- is no E present then it is assumed that T is an unconstrained mutably + -- tagged class-wide type. + -- + -- This function returns the entity of the Equivalent type and inserts + -- on the fly the necessary declaration into List_Def such as: + -- + -- type anon is record + -- _parent : Root_Type (T); constrained with E discriminants (if any) + -- Extension : String (1 .. expr to match size of E); + -- end record; + -- + -- This record is compatible with any object of the class of T thanks to + -- the first field and has the same size as E thanks to the second. + function Make_Invariant_Call (Expr : Node_Id) return Node_Id; -- Generate a call to the Invariant_Procedure associated with the type of -- expression Expr. Expr is passed as an actual parameter in the call. diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index ea6106e6455a9..5dbf7198cb410 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -222,7 +222,9 @@ package body Freeze is = Scope (Typ) then return Abandon; - elsif Nkind (N) = N_Aggregate + elsif Nkind (N) in N_Aggregate + | N_Extension_Aggregate + | N_Delta_Aggregate and then Base_Type (Etype (N)) = Base_Type (Typ) then return Abandon; @@ -1010,15 +1012,10 @@ package body Freeze is elsif Is_Record_Type (T) then - -- A class-wide type is never considered to have a known size - - if Is_Class_Wide_Type (T) then - return False; - -- A subtype of a variant record must not have non-static -- discriminated components. - elsif T /= Base_Type (T) + if T /= Base_Type (T) and then not Static_Discriminated_Components (T) then return False; @@ -1518,7 +1515,17 @@ package body Freeze is Op_Node : Elmt_Id; Par_Prim : Entity_Id; Prim : Entity_Id; - Wrapper_Needed : Boolean; + + type Wrapper_Kind is (No_Wrapper, LSP_Wrapper, Postcond_Wrapper); + + Wrapper_Needed : Wrapper_Kind; + -- Kind of wrapper needed by a given inherited primitive of tagged + -- type R: + -- * No_Wrapper: No wrapper is needed. + -- * LSP_Wrapper: Wrapper that handles inherited class-wide pre/post + -- conditions that call overridden primitives. + -- * Postcond_Wrapper: Wrapper that handles postconditions of interface + -- primitives. function Build_DTW_Body (Loc : Source_Ptr; @@ -1534,8 +1541,8 @@ package body Freeze is -- Build the spec of the dispatch table wrapper procedure Build_Inherited_Condition_Pragmas - (Subp : Entity_Id; - Wrapper_Needed : out Boolean); + (Subp : Entity_Id; + LSP_Wrapper_Needed : out Boolean); -- Build corresponding pragmas for an operation whose ancestor has -- class-wide pre/postconditions. If the operation is inherited then -- Wrapper_Needed is returned True to force the creation of a wrapper @@ -1543,6 +1550,10 @@ package body Freeze is -- the pragmas are constructed only to verify their legality, in case -- they contain calls to other primitives that may have been overridden. + procedure Check_Interface_Primitives_Strub_Mode; + -- Called when R is an interface type to check strub mode compatibility + -- all its primitives. + function Needs_Wrapper (Class_Cond : Node_Id; Subp : Entity_Id; @@ -1636,7 +1647,6 @@ package body Freeze is -- Add minimal decoration of fields Mutate_Ekind (DTW_Id, Ekind (Par_Prim)); - Set_LSP_Subprogram (DTW_Id, Par_Prim); Set_Is_Dispatch_Table_Wrapper (DTW_Id); Set_Is_Wrapper (DTW_Id); @@ -1654,8 +1664,8 @@ package body Freeze is --------------------------------------- procedure Build_Inherited_Condition_Pragmas - (Subp : Entity_Id; - Wrapper_Needed : out Boolean) + (Subp : Entity_Id; + LSP_Wrapper_Needed : out Boolean) is Class_Pre : constant Node_Id := Class_Preconditions (Ultimate_Alias (Subp)); @@ -1664,7 +1674,7 @@ package body Freeze is New_Prag : Node_Id; begin - Wrapper_Needed := False; + LSP_Wrapper_Needed := False; if No (Class_Pre) and then No (Class_Post) then return; @@ -1677,7 +1687,7 @@ package body Freeze is if Present (Class_Pre) and then Needs_Wrapper (Class_Pre, Subp, Par_Prim) then - Wrapper_Needed := True; + LSP_Wrapper_Needed := True; end if; -- For class-wide postconditions we evaluate whether the wrapper is @@ -1687,7 +1697,7 @@ package body Freeze is if Present (Class_Post) and then Needs_Wrapper (Class_Post, Subp, Par_Prim) then - Wrapper_Needed := True; + LSP_Wrapper_Needed := True; -- Update the class-wide postcondition @@ -1730,6 +1740,101 @@ package body Freeze is end if; end Build_Inherited_Condition_Pragmas; + ------------------------------------------- + -- Check_Interface_Primitives_Strub_Mode -- + ------------------------------------------- + + procedure Check_Interface_Primitives_Strub_Mode is + Elmt : Elmt_Id; + Iface_Elmt : Elmt_Id; + Iface : Entity_Id; + Iface_Prim : Entity_Id; + Ifaces_List : Elist_Id; + Op_Node : Elmt_Id; + Prim : Entity_Id; + Prim_Iface : Entity_Id; + + begin + pragma Assert (Is_Interface (R)); + + -- Collect interfaces extended by interface type R + + Collect_Interfaces (R, Ifaces_List); + + Op_Node := First_Elmt (Prim_Ops); + while Present (Op_Node) loop + Prim := Node (Op_Node); + Prim_Iface := R; + Par_Prim := Overridden_Operation (Prim); + + -- We only need to check entities defined in the sources + + -- Check that overrider and overridden primitives have the same + -- strub mode. + + if Present (Par_Prim) then + Check_Same_Strub_Mode (Prim, Par_Prim); + + -- No need to check internally added predefined primitives since + -- they all have the same strub mode. + + elsif Is_Predefined_Dispatching_Operation (Prim) + and then not Comes_From_Source (Prim) + then + null; + + -- Check strub mode of matching primitives of all the interface + -- types, since several interface types may define primitives with + -- the same profile that will be implemented by a single primitive + -- of tagged types implementing R, and therefore must have the + -- same strub mode. + + else + -- If this interface primitive has been inherited this is an + -- internal entity we rely on its renamed entity (which is the + -- entity defined in the sources). + + if Present (Alias (Prim)) then + Prim := Ultimate_Alias (Prim); + Prim_Iface := Find_Dispatching_Type (Prim); + end if; + + -- Search for primitives conformant with this one in the other + -- interface types. + + Iface_Elmt := First_Elmt (Ifaces_List); + while Present (Iface_Elmt) loop + Iface := Node (Iface_Elmt); + + if Iface /= Prim_Iface then + Elmt := First_Elmt (Primitive_Operations (Iface)); + while Present (Elmt) loop + Iface_Prim := Node (Elmt); + + if Chars (Iface_Prim) = Chars (Prim) + and then Comes_From_Source (Iface_Prim) + and then Is_Interface_Conformant + (Prim_Iface, Iface_Prim, Prim) + then + -- Check the strub mode passing the original + -- primitive (instead of its alias); required + -- to report the error at the right location. + + Check_Same_Strub_Mode (Node (Op_Node), Iface_Prim); + end if; + + Next_Elmt (Elmt); + end loop; + end if; + + Next_Elmt (Iface_Elmt); + end loop; + end if; + + Next_Elmt (Op_Node); + end loop; + end Check_Interface_Primitives_Strub_Mode; + ------------------- -- Needs_Wrapper -- ------------------- @@ -1799,14 +1904,14 @@ package body Freeze is return Result; end Needs_Wrapper; - Ifaces_List : Elist_Id := No_Elist; - Ifaces_Listed : Boolean := False; - -- Cache the list of interface operations inherited by R - - Wrappers_List : Elist_Id := No_Elist; + Wrappers_List : Elist_Id := No_Elist; -- List containing identifiers of built wrappers. Used to defer building -- and analyzing their class-wide precondition subprograms. + Postcond_Candidates_List : Elist_Id := No_Elist; + -- List containing inherited primitives of tagged type R that implement + -- interface primitives that have postconditions. + -- Start of processing for Check_Inherited_Conditions begin @@ -1832,15 +1937,23 @@ package body Freeze is end loop; end if; + -- For interface types we only need to check strub mode compatibility + -- of their primitives (since they don't have wrappers). + + if Is_Interface (R) then + Check_Interface_Primitives_Strub_Mode; + return; + end if; + -- Perform validity checks on the inherited conditions of overriding -- operations, for conformance with LSP, and apply SPARK-specific -- restrictions on inherited conditions. Op_Node := First_Elmt (Prim_Ops); while Present (Op_Node) loop - Prim := Node (Op_Node); - + Prim := Node (Op_Node); Par_Prim := Overridden_Operation (Prim); + if Present (Par_Prim) and then Comes_From_Source (Prim) then @@ -1871,54 +1984,34 @@ package body Freeze is if GNATprove_Mode then Collect_Inherited_Class_Wide_Conditions (Prim); end if; - end if; - - -- Go over operations inherited from interfaces and check - -- them for strub mode compatibility as well. - - if Has_Interfaces (R) - and then Is_Dispatching_Operation (Prim) - and then Find_Dispatching_Type (Prim) = R - then - declare - Elmt : Elmt_Id; - Iface_Elmt : Elmt_Id; - Iface : Entity_Id; - Iface_Prim : Entity_Id; - begin - -- Collect the interfaces only once. We haven't - -- finished freezing yet, so we can't use the faster - -- search from Sem_Disp.Covered_Interface_Primitives. + -- Check strub mode compatibility of primitives that implement + -- interface primitives. - if not Ifaces_Listed then - Collect_Interfaces (R, Ifaces_List); - Ifaces_Listed := True; - end if; + elsif Present (Interface_Alias (Prim)) then + Check_Same_Strub_Mode (Alias (Prim), Interface_Alias (Prim)); + end if; - Iface_Elmt := First_Elmt (Ifaces_List); - while Present (Iface_Elmt) loop - Iface := Node (Iface_Elmt); + Next_Elmt (Op_Node); + end loop; - Elmt := First_Elmt (Primitive_Operations (Iface)); - while Present (Elmt) loop - Iface_Prim := Node (Elmt); + -- Collect inherited primitives that may need a wrapper to handle + -- postconditions of interface primitives; done to improve the + -- performance when checking if postcondition wrappers are needed. - if Iface_Prim /= Par_Prim - and then Chars (Iface_Prim) = Chars (Prim) - and then Comes_From_Source (Iface_Prim) - and then Is_Interface_Conformant - (R, Iface_Prim, Prim) - then - Check_Same_Strub_Mode (Prim, Iface_Prim); - end if; + Op_Node := First_Elmt (Prim_Ops); + while Present (Op_Node) loop + Prim := Node (Op_Node); - Next_Elmt (Elmt); - end loop; + if Present (Interface_Alias (Prim)) + and then not Comes_From_Source (Alias (Prim)) + and then Present (Class_Postconditions (Interface_Alias (Prim))) + then + if No (Postcond_Candidates_List) then + Postcond_Candidates_List := New_Elmt_List; + end if; - Next_Elmt (Iface_Elmt); - end loop; - end; + Append_Unique_Elmt (Alias (Prim), Postcond_Candidates_List); end if; Next_Elmt (Op_Node); @@ -1933,7 +2026,7 @@ package body Freeze is while Present (Op_Node) loop Decls := Empty_List; Prim := Node (Op_Node); - Wrapper_Needed := False; + Wrapper_Needed := No_Wrapper; -- Skip internal entities built for mapping interface primitives @@ -1953,16 +2046,80 @@ package body Freeze is end if; -- Analyze the contract items of the parent operation, and - -- determine whether a wrapper is needed. This is determined - -- when the condition is rewritten in sem_prag, using the - -- mapping between overridden and overriding operations built - -- in the loop above. + -- determine whether this inherited primitive needs a LSP + -- wrapper. This is determined when the condition is rewritten + -- in sem_prag, using the mapping between overridden and + -- overriding operations built in the loop above. - Analyze_Entry_Or_Subprogram_Contract (Par_Prim); - Build_Inherited_Condition_Pragmas (Prim, Wrapper_Needed); + declare + LSP_Wrapper_Needed : Boolean; + + begin + Analyze_Entry_Or_Subprogram_Contract (Par_Prim); + Build_Inherited_Condition_Pragmas (Prim, LSP_Wrapper_Needed); + + if LSP_Wrapper_Needed then + Wrapper_Needed := LSP_Wrapper; + end if; + end; + + -- If the LSP wrapper is not needed but the tagged type R + -- implements additional interface types, and this inherited + -- primitive covers an interface primitive of these additional + -- interface types that has class-wide postconditions, then it + -- requires a postconditions wrapper. + + if Wrapper_Needed = No_Wrapper + and then Present (Interfaces (R)) + and then Present (Postcond_Candidates_List) + and then Contains (Postcond_Candidates_List, Prim) + then + declare + Elmt : Elmt_Id; + Ent : Entity_Id; + Iface : Entity_Id; + Iface_Elmt : Elmt_Id; + + begin + Elmt := First_Elmt (Prim_Ops); + while Present (Elmt) loop + Ent := Node (Elmt); + + -- Perform the search relying on the internal entities + -- that link tagged type primitives with interface + -- primitives. + + if Present (Interface_Alias (Ent)) + and then (Alias (Ent)) = Prim + and then + Present (Class_Postconditions (Interface_Alias (Ent))) + then + Iface := Find_Dispatching_Type (Interface_Alias (Ent)); + + -- We only need to locate primitives of additional + -- interfaces implemented by tagged type R (since + -- inherited primitives of parent types that cover + -- primitives of inherited interface types don't + -- need a wrapper). + + Iface_Elmt := First_Elmt (Interfaces (R)); + while Present (Iface_Elmt) loop + if Node (Iface_Elmt) = Iface then + Wrapper_Needed := Postcond_Wrapper; + exit; + end if; + + Next_Elmt (Iface_Elmt); + end loop; + end if; + + Next_Elmt (Elmt); + end loop; + end; + end if; end if; - if Wrapper_Needed + if Wrapper_Needed /= No_Wrapper and then not Is_Abstract_Subprogram (Par_Prim) and then Expander_Active then @@ -2002,6 +2159,14 @@ package body Freeze is DTW_Decl := Make_Subprogram_Declaration (Loc, Specification => DTW_Spec); + -- LSP wrappers reference the parent primitive that has the + -- the class-wide pre/post condition that calls overridden + -- primitives. + + if Wrapper_Needed = LSP_Wrapper then + Set_LSP_Subprogram (DTW_Id, Par_Prim); + end if; + -- The spec of the wrapper has been built using the source -- location of its parent primitive; we must update it now -- (with the source location of the internal primitive built @@ -2475,22 +2640,7 @@ package body Freeze is -- for a description of how we handle aspect visibility). elsif Has_Delayed_Aspects (E) then - declare - Ritem : Node_Id; - - begin - Ritem := First_Rep_Item (E); - while Present (Ritem) loop - if Nkind (Ritem) = N_Aspect_Specification - and then Entity (Ritem) = E - and then Is_Delayed_Aspect (Ritem) - then - Check_Aspect_At_End_Of_Declarations (Ritem); - end if; - - Next_Rep_Item (Ritem); - end loop; - end; + Check_Aspects_At_End_Of_Declarations (E); end if; -- If an incomplete type is still not frozen, this may be a @@ -5808,13 +5958,6 @@ package body Freeze is end loop; end; end if; - - -- For a derived tagged type, check whether inherited primitives - -- might require a wrapper to handle class-wide conditions. - - if Is_Tagged_Type (Rec) and then Is_Derived_Type (Rec) then - Check_Inherited_Conditions (Rec); - end if; end Freeze_Record_Type; ------------------------------- @@ -6963,7 +7106,7 @@ package body Freeze is if Is_Type (Comp) then Freeze_And_Append (Comp, N, Result); - elsif (Ekind (Comp)) /= E_Function then + elsif Ekind (Comp) /= E_Function then -- The guard on the presence of the Etype seems to be needed -- for some CodePeer (-gnatcC) cases, but not clear why??? @@ -7671,6 +7814,7 @@ package body Freeze is if (Has_Size_Clause (E) or else Has_Object_Size_Clause (E)) and then not Size_Known_At_Compile_Time (E) + and then not Is_Mutably_Tagged_Type (E) then -- Suppress this message if errors posted on E, even if we are -- in all errors mode, since this is often a junk message diff --git a/gcc/ada/freeze.ads b/gcc/ada/freeze.ads index 066d8f054f6fd..4bc03c4ef5967 100644 --- a/gcc/ada/freeze.ads +++ b/gcc/ada/freeze.ads @@ -170,11 +170,14 @@ package Freeze is procedure Check_Inherited_Conditions (R : Entity_Id; Late_Overriding : Boolean := False); - -- For a tagged derived type R, create wrappers for inherited operations - -- that have class-wide conditions, so it can be properly rewritten if - -- it involves calls to other overriding primitives. Late_Overriding is - -- True when we are processing the body of a primitive with no previous - -- spec defined after R is frozen (see Check_Dispatching_Operation). + -- R is a derived tagged type or a derived interface type. For a derived + -- interface type R, check strub mode compatibility of its primitives; for + -- a tagged derived type R, in addition to check strub mode compatibility, + -- create wrappers for inherited operations that have class-wide conditions + -- so it can be properly rewritten if it involves calls to other overriding + -- primitives. Late_Overriding is True when we are processing the body of a + -- primitive with no previous spec defined after R is frozen (see procedure + -- Check_Dispatching_Operation). procedure Explode_Initialization_Compound_Statement (E : Entity_Id); -- If Initialization_Statements (E) is an N_Compound_Statement, insert its diff --git a/gcc/ada/gcc-interface/Make-lang.in b/gcc/ada/gcc-interface/Make-lang.in index 4f1b310fb8401..ebf1f70de7812 100644 --- a/gcc/ada/gcc-interface/Make-lang.in +++ b/gcc/ada/gcc-interface/Make-lang.in @@ -376,6 +376,7 @@ GNAT_ADA_OBJS = \ ada/namet.o \ ada/nlists.o \ ada/nmake.o \ + ada/mutably_tagged.o \ ada/opt.o \ ada/osint-c.o \ ada/osint.o \ @@ -528,6 +529,8 @@ GNAT_ADA_OBJS+= \ ada/libgnat/s-excmac.o \ ada/libgnat/s-exctab.o \ ada/libgnat/s-htable.o \ + ada/libgnat/s-imad32.o \ + ada/libgnat/s-imad64.o \ ada/libgnat/s-imgint.o \ ada/libgnat/s-mastop.o \ ada/libgnat/s-memory.o \ diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in index 0666fc00bb83b..29db89c6f52c6 100644 --- a/gcc/ada/gcc-interface/Makefile.in +++ b/gcc/ada/gcc-interface/Makefile.in @@ -148,7 +148,6 @@ host_vendor=@host_vendor@ host_os=@host_os@ target_cpu_default = @target_cpu_default@ xmake_file = @xmake_file@ -tmake_file = @tmake_file@ #version=`sed -e 's/.*\"\([^ \"]*\)[ \"].*/\1/' < $(srcdir)/version.c` #mainversion=`sed -e 's/.*\"\([0-9]*\.[0-9]*\).*/\1/' < $(srcdir)/version.c` @@ -209,11 +208,6 @@ all: all.indirect # This tells GNU Make version 3 not to put all variables in the environment. .NOEXPORT: -# target overrides -ifneq ($(tmake_file),) -include $(tmake_file) -endif - # host overrides ifneq ($(xmake_file),) include $(xmake_file) diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc index 8b72c96c4396a..aa31a888818f6 100644 --- a/gcc/ada/gcc-interface/decl.cc +++ b/gcc/ada/gcc-interface/decl.cc @@ -27,6 +27,7 @@ #include "system.h" #include "coretypes.h" #include "target.h" +#include "function.h" #include "tree.h" #include "gimple-expr.h" #include "stringpool.h" @@ -1384,7 +1385,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) volatile_flag = false; gnu_size = NULL_TREE; - /* In case this was a aliased object whose nominal subtype is + /* In case this was an aliased object whose nominal subtype is unconstrained, the pointer above will be a thin pointer and build_allocator will automatically make the template. @@ -2103,7 +2104,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) 1. the array type (suffix XUA) containing the actual data, - 2. the template type (suffix XUB) containng the bounds, + 2. the template type (suffix XUB) containing the bounds, 3. the fat pointer type (suffix XUP) representing a pointer or a reference to the unconstrained array type: @@ -5445,8 +5446,8 @@ gnat_to_gnu_component_type (Entity_Id gnat_array, bool definition, if (gnu_comp_align > TYPE_ALIGN (gnu_type)) gnu_comp_align = 0; } - else - gnu_comp_align = 0; + else + gnu_comp_align = 0; gnu_type = maybe_pad_type (gnu_type, gnu_comp_size, gnu_comp_align, gnat_array, true, definition, true); @@ -5703,6 +5704,7 @@ gnat_to_gnu_param (Entity_Id gnat_param, tree gnu_param_type, bool first, input_location = saved_location; + /* Warn if we are asked to pass by copy but cannot. */ if (mech == By_Copy && (by_ref || by_component_ptr)) post_error ("??cannot pass & by copy", gnat_param); @@ -5735,12 +5737,13 @@ gnat_to_gnu_param (Entity_Id gnat_param, tree gnu_param_type, bool first, DECL_RESTRICTED_ALIASING_P (gnu_param) = restricted_aliasing_p; Sloc_to_locus (Sloc (gnat_param), &DECL_SOURCE_LOCATION (gnu_param)); - /* If no Mechanism was specified, indicate what we're using, then - back-annotate it. */ + /* If no Mechanism was specified, indicate what we will use. */ if (mech == Default) mech = (by_ref || by_component_ptr) ? By_Reference : By_Copy; + /* Back-annotate the mechanism in all cases. */ Set_Mechanism (gnat_param, mech); + return gnu_param; } @@ -6129,11 +6132,6 @@ gnat_to_gnu_subprog_type (Entity_Id gnat_subprog, bool definition, associate_subprog_with_dummy_type (gnat_subprog, gnu_return_type); incomplete_profile_p = true; } - - if (kind == E_Function) - Set_Mechanism (gnat_subprog, return_by_direct_ref_p - || return_by_invisi_ref_p - ? By_Reference : By_Copy); } /* A procedure (something that doesn't return anything) shouldn't be @@ -6636,6 +6634,28 @@ gnat_to_gnu_subprog_type (Entity_Id gnat_subprog, bool definition, if (warn_shadow) post_error ("'G'C'C builtin not found for&!??", gnat_subprog); } + + /* Finally deal with the return mechanism for a function. */ + if (kind == E_Function) + { + /* We return by reference either if this is required by the semantics + of the language or if this is the default for the function. */ + const bool by_ref = return_by_direct_ref_p + || return_by_invisi_ref_p + || aggregate_value_p (gnu_return_type, gnu_type); + Mechanism_Type mech = Mechanism (gnat_subprog); + + /* Warn if we are asked to return by copy but cannot. */ + if (mech == By_Copy && by_ref) + post_error ("??cannot return from & by copy", gnat_subprog); + + /* If no mechanism was specified, indicate what we will use. */ + if (mech == Default) + mech = by_ref ? By_Reference : By_Copy; + + /* Back-annotate the mechanism in all cases. */ + Set_Mechanism (gnat_subprog, mech); + } } *param_list = gnu_param_list; diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h index f3205a8a25d9b..6ed74d6879eef 100644 --- a/gcc/ada/gcc-interface/gigi.h +++ b/gcc/ada/gcc-interface/gigi.h @@ -906,7 +906,7 @@ extern tree build_call_alloc_dealloc (tree gnu_obj, tree gnu_size, Entity_Id gnat_pool, Node_Id gnat_node); /* Build a GCC tree to correspond to allocating an object of TYPE whose - initial value if INIT, if INIT is nonzero. Convert the expression to + initial value is INIT, if INIT is nonzero. Convert the expression to RESULT_TYPE, which must be some type of pointer. Return the tree. GNAT_PROC and GNAT_POOL optionally give the procedure to call and diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc index 93978c0f0ba8f..e68fb3fd7769c 100644 --- a/gcc/ada/gcc-interface/trans.cc +++ b/gcc/ada/gcc-interface/trans.cc @@ -9321,6 +9321,10 @@ elaborate_all_entities_for_package (Entity_Id gnat_package) if (kind == E_Package_Body) continue; + /* Skip subprogram bodies. */ + if (kind == E_Subprogram_Body) + continue; + /* Skip limited views that point back to the main unit. */ if (IN (kind, Incomplete_Kind) && From_Limited_With (gnat_entity) @@ -9427,6 +9431,10 @@ process_freeze_entity (Node_Id gnat_node) if (Is_Subprogram (gnat_entity) && Present (Interface_Alias (gnat_entity))) return; + /* Skip subprogram bodies. */ + if (kind == E_Subprogram_Body) + return; + /* Check for an old definition if this isn't an object with address clause, since the saved GCC tree is the address expression in that case. */ gnu_old @@ -11093,6 +11101,16 @@ maybe_make_gnu_thunk (Entity_Id gnat_thunk, tree gnu_thunk) tree gnu_interface_offset = gnu_interface_tag ? byte_position (gnu_interface_tag) : NULL_TREE; + /* But we generate a call to the Thunk_Entity in the thunk. */ + tree gnu_target + = gnat_to_gnu_entity (Thunk_Entity (gnat_thunk), NULL_TREE, false); + + /* If the target is local, then thunk and target must have the same context + because cgraph_node::expand_thunk can only forward the static chain. */ + if (DECL_STATIC_CHAIN (gnu_target) + && DECL_CONTEXT (gnu_thunk) != DECL_CONTEXT (gnu_target)) + return false; + /* There are three ways to retrieve the offset between the interface view and the base object. Either the controlling type covers the interface type and the offset of the corresponding tag is fixed, in which case it @@ -11111,6 +11129,15 @@ maybe_make_gnu_thunk (Entity_Id gnat_thunk, tree gnu_thunk) virtual_value = 0; virtual_offset = NULL_TREE; indirect_offset = 0; + + /* Do not create a null thunk, instead make it an alias. */ + if (fixed_offset == 0) + { + SET_DECL_ASSEMBLER_NAME (gnu_thunk, DECL_ASSEMBLER_NAME (gnu_target)); + (void) cgraph_node::get_create (gnu_target); + (void) cgraph_node::create_alias (gnu_thunk, gnu_target); + return true; + } } else if (!gnu_interface_offset && !Is_Variable_Size_Record (gnat_controlling_type)) @@ -11132,16 +11159,6 @@ maybe_make_gnu_thunk (Entity_Id gnat_thunk, tree gnu_thunk) indirect_offset = (HOST_WIDE_INT) (POINTER_SIZE / BITS_PER_UNIT); } - /* But we generate a call to the Thunk_Entity in the thunk. */ - tree gnu_target - = gnat_to_gnu_entity (Thunk_Entity (gnat_thunk), NULL_TREE, false); - - /* If the target is local, then thunk and target must have the same context - because cgraph_node::expand_thunk can only forward the static chain. */ - if (DECL_STATIC_CHAIN (gnu_target) - && DECL_CONTEXT (gnu_thunk) != DECL_CONTEXT (gnu_target)) - return false; - /* If the target returns by invisible reference and is external, apply the same transformation as Subprogram_Body_to_gnu here. */ if (TREE_ADDRESSABLE (TREE_TYPE (gnu_target)) diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc index ae520542ace66..771cb1a17cadb 100644 --- a/gcc/ada/gcc-interface/utils.cc +++ b/gcc/ada/gcc-interface/utils.cc @@ -499,7 +499,7 @@ make_dummy_type (Entity_Id gnat_type) if (No (gnat_equiv)) gnat_equiv = gnat_type; - /* If it there already a dummy type, use that one. Else make one. */ + /* If there is already a dummy type, use that one. Else make one. */ if (PRESENT_DUMMY_NODE (gnat_equiv)) return GET_DUMMY_NODE (gnat_equiv); diff --git a/gcc/ada/gcc-interface/utils2.cc b/gcc/ada/gcc-interface/utils2.cc index 4b7e2739f6a21..70271cf283655 100644 --- a/gcc/ada/gcc-interface/utils2.cc +++ b/gcc/ada/gcc-interface/utils2.cc @@ -2884,7 +2884,7 @@ gnat_protect_expr (tree exp) if (code == NON_LVALUE_EXPR || CONVERT_EXPR_CODE_P (code) || code == VIEW_CONVERT_EXPR) - return build1 (code, type, gnat_protect_expr (TREE_OPERAND (exp, 0))); + return build1 (code, type, gnat_protect_expr (TREE_OPERAND (exp, 0))); /* If we're indirectly referencing something, we only need to protect the address since the data itself can't change in these situations. */ diff --git a/gcc/ada/gen_il-fields.ads b/gcc/ada/gen_il-fields.ads index 54a5703d1a544..5aa246d1fb6c4 100644 --- a/gcc/ada/gen_il-fields.ads +++ b/gcc/ada/gen_il-fields.ads @@ -460,6 +460,7 @@ package Gen_IL.Fields is Class_Postconditions, Class_Preconditions, Class_Preconditions_Subprogram, + Class_Wide_Equivalent_Type, Class_Wide_Type, Cloned_Subtype, Component_Alignment, @@ -744,6 +745,7 @@ package Gen_IL.Fields is Is_Local_Anonymous_Access, Is_Loop_Parameter, Is_Machine_Code_Subprogram, + Is_Mutably_Tagged_Type, Is_Non_Static_Subtype, Is_Null_Init_Proc, Is_Obsolescent, diff --git a/gcc/ada/gen_il-gen-gen_entities.adb b/gcc/ada/gen_il-gen-gen_entities.adb index f5b1b434e42ec..c3595bb3dd607 100644 --- a/gcc/ada/gen_il-gen-gen_entities.adb +++ b/gcc/ada/gen_il-gen-gen_entities.adb @@ -459,6 +459,7 @@ begin -- Gen_IL.Gen.Gen_Entities Sm (Associated_Node_For_Itype, Node_Id), Sm (Can_Use_Internal_Rep, Flag, Base_Type_Only, Pre => "Ekind (Base_Type (N)) in Access_Subprogram_Kind"), + Sm (Class_Wide_Equivalent_Type, Node_Id), Sm (Class_Wide_Type, Node_Id), Sm (Contract, Node_Id), Sm (Current_Use_Clause, Node_Id), @@ -504,6 +505,7 @@ begin -- Gen_IL.Gen.Gen_Entities Sm (Is_Fixed_Lower_Bound_Array_Subtype, Flag), Sm (Is_Fixed_Lower_Bound_Index_Subtype, Flag), Sm (Is_Generic_Actual_Type, Flag), + Sm (Is_Mutably_Tagged_Type, Flag), Sm (Is_Non_Static_Subtype, Flag), Sm (Is_Private_Composite, Flag), Sm (Is_RACW_Stub_Type, Flag), diff --git a/gcc/ada/gnat1drv.adb b/gcc/ada/gnat1drv.adb index 55b5d565536ce..754dab82862d1 100644 --- a/gcc/ada/gnat1drv.adb +++ b/gcc/ada/gnat1drv.adb @@ -207,13 +207,6 @@ procedure Gnat1drv is Error_To_Warning := True; end if; - -- -gnatdJ sets Include_Subprogram_In_Messages, adding the related - -- subprogram as part of the error and warning messages. - - if Debug_Flag_JJ then - Include_Subprogram_In_Messages := True; - end if; - -- Disable CodePeer_Mode in Check_Syntax, since we need front-end -- expansion. @@ -357,9 +350,13 @@ procedure Gnat1drv is Generate_SCIL := True; - -- Enable assertions, since they give CodePeer valuable extra info + -- Enable assertions, since they give CodePeer valuable extra info; + -- however, when switch -gnatd_k is active, then keep assertions + -- disabled by default and only enable them when explicitly + -- requested by pragma Assertion_Policy, just like in ordinary + -- compilation. - Assertions_Enabled := True; + Assertions_Enabled := not Debug_Flag_Underscore_K; -- Set normal RM validity checking and checking of copies (to catch -- e.g. wrong values used in unchecked conversions). diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi index 776dd4a4afcf0..4dfb896e42f85 100644 --- a/gcc/ada/gnat_rm.texi +++ b/gcc/ada/gnat_rm.texi @@ -19,7 +19,7 @@ @copying @quotation -GNAT Reference Manual , Apr 16, 2024 +GNAT Reference Manual , May 28, 2024 AdaCore @@ -406,7 +406,6 @@ Implementation Defined Attributes * Attribute Initialized:: * Attribute Integer_Value:: * Attribute Invalid_Value:: -* Attribute Iterable:: * Attribute Large:: * Attribute Library_Level:: * Attribute Loop_Entry:: @@ -905,6 +904,7 @@ Experimental Language Extensions * Pragma Storage_Model:: * Simpler accessibility model:: * Case pattern matching:: +* Mutably Tagged Types with Size’Class Aspect:: Security Hardening Features @@ -5535,12 +5535,6 @@ applied to a tagged type its Expanded_Name and External_Tag are initialized with empty strings. This is useful to avoid exposing entity names at binary level but has a negative impact on the debuggability of tagged types. -Alternatively, when pragmas @code{Discard_Names} and @code{Restrictions (No_Streams)} -simultanously apply to a tagged type, its Expanded_Name and External_Tag are -also initialized with empty strings. In particular, both these pragmas can be -applied as configuration pragmas to avoid exposing entity names at binary -level for the entire parition. - @node Pragma Normalize_Scalars,Pragma Obsolescent,Pragma No_Tagged_Streams,Implementation Defined Pragmas @anchor{gnat_rm/implementation_defined_pragmas pragma-normalize-scalars}@anchor{b0} @section Pragma Normalize_Scalars @@ -10256,7 +10250,6 @@ consideration, you should minimize the use of these attributes. * Attribute Initialized:: * Attribute Integer_Value:: * Attribute Invalid_Value:: -* Attribute Iterable:: * Attribute Large:: * Attribute Library_Level:: * Attribute Loop_Entry:: @@ -10935,7 +10928,7 @@ that there are full range checks, to ensure that the result is in range. This attribute is primarily intended for use in implementation of the standard input-output functions for fixed-point values. -@node Attribute Invalid_Value,Attribute Iterable,Attribute Integer_Value,Implementation Defined Attributes +@node Attribute Invalid_Value,Attribute Large,Attribute Integer_Value,Implementation Defined Attributes @anchor{gnat_rm/implementation_defined_attributes attribute-invalid-value}@anchor{194} @section Attribute Invalid_Value @@ -10949,17 +10942,8 @@ uninitialized value of the type if pragma Initialize_Scalars is used, including the ability to modify the value with the binder -Sxx flag and relevant environment variables at run time. -@node Attribute Iterable,Attribute Large,Attribute Invalid_Value,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-iterable}@anchor{195} -@section Attribute Iterable - - -@geindex Iterable - -Equivalent to Aspect Iterable. - -@node Attribute Large,Attribute Library_Level,Attribute Iterable,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-large}@anchor{196} +@node Attribute Large,Attribute Library_Level,Attribute Invalid_Value,Implementation Defined Attributes +@anchor{gnat_rm/implementation_defined_attributes attribute-large}@anchor{195} @section Attribute Large @@ -10972,7 +10956,7 @@ the Ada 83 reference manual for an exact description of the semantics of this attribute. @node Attribute Library_Level,Attribute Loop_Entry,Attribute Large,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-library-level}@anchor{197} +@anchor{gnat_rm/implementation_defined_attributes attribute-library-level}@anchor{196} @section Attribute Library_Level @@ -10998,7 +10982,7 @@ end Gen; @end example @node Attribute Loop_Entry,Attribute Machine_Size,Attribute Library_Level,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-loop-entry}@anchor{198} +@anchor{gnat_rm/implementation_defined_attributes attribute-loop-entry}@anchor{197} @section Attribute Loop_Entry @@ -11031,7 +11015,7 @@ entry. This copy is not performed if the loop is not entered, or if the corresponding pragmas are ignored or disabled. @node Attribute Machine_Size,Attribute Mantissa,Attribute Loop_Entry,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-machine-size}@anchor{199} +@anchor{gnat_rm/implementation_defined_attributes attribute-machine-size}@anchor{198} @section Attribute Machine_Size @@ -11041,7 +11025,7 @@ This attribute is identical to the @code{Object_Size} attribute. It is provided for compatibility with the DEC Ada 83 attribute of this name. @node Attribute Mantissa,Attribute Maximum_Alignment,Attribute Machine_Size,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-mantissa}@anchor{19a} +@anchor{gnat_rm/implementation_defined_attributes attribute-mantissa}@anchor{199} @section Attribute Mantissa @@ -11054,7 +11038,7 @@ the Ada 83 reference manual for an exact description of the semantics of this attribute. @node Attribute Maximum_Alignment,Attribute Max_Integer_Size,Attribute Mantissa,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-maximum-alignment}@anchor{19b}@anchor{gnat_rm/implementation_defined_attributes id2}@anchor{19c} +@anchor{gnat_rm/implementation_defined_attributes attribute-maximum-alignment}@anchor{19a}@anchor{gnat_rm/implementation_defined_attributes id2}@anchor{19b} @section Attribute Maximum_Alignment @@ -11070,7 +11054,7 @@ for an object, guaranteeing that it is properly aligned in all cases. @node Attribute Max_Integer_Size,Attribute Mechanism_Code,Attribute Maximum_Alignment,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-max-integer-size}@anchor{19d} +@anchor{gnat_rm/implementation_defined_attributes attribute-max-integer-size}@anchor{19c} @section Attribute Max_Integer_Size @@ -11081,7 +11065,7 @@ prefix) provides the size of the largest supported integer type for the target. The result is a static constant. @node Attribute Mechanism_Code,Attribute Null_Parameter,Attribute Max_Integer_Size,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-mechanism-code}@anchor{19e} +@anchor{gnat_rm/implementation_defined_attributes attribute-mechanism-code}@anchor{19d} @section Attribute Mechanism_Code @@ -11112,7 +11096,7 @@ by reference @end table @node Attribute Null_Parameter,Attribute Object_Size,Attribute Mechanism_Code,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-null-parameter}@anchor{19f} +@anchor{gnat_rm/implementation_defined_attributes attribute-null-parameter}@anchor{19e} @section Attribute Null_Parameter @@ -11137,7 +11121,7 @@ There is no way of indicating this without the @code{Null_Parameter} attribute. @node Attribute Object_Size,Attribute Old,Attribute Null_Parameter,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-object-size}@anchor{14e}@anchor{gnat_rm/implementation_defined_attributes id3}@anchor{1a0} +@anchor{gnat_rm/implementation_defined_attributes attribute-object-size}@anchor{14e}@anchor{gnat_rm/implementation_defined_attributes id3}@anchor{19f} @section Attribute Object_Size @@ -11207,7 +11191,7 @@ Similar additional checks are performed in other contexts requiring statically matching subtypes. @node Attribute Old,Attribute Passed_By_Reference,Attribute Object_Size,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-old}@anchor{1a1} +@anchor{gnat_rm/implementation_defined_attributes attribute-old}@anchor{1a0} @section Attribute Old @@ -11222,7 +11206,7 @@ definition are allowed under control of implementation defined pragma @code{Unevaluated_Use_Of_Old}. @node Attribute Passed_By_Reference,Attribute Pool_Address,Attribute Old,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-passed-by-reference}@anchor{1a2} +@anchor{gnat_rm/implementation_defined_attributes attribute-passed-by-reference}@anchor{1a1} @section Attribute Passed_By_Reference @@ -11238,7 +11222,7 @@ passed by copy in calls. For scalar types, the result is always @code{False} and is static. For non-scalar types, the result is nonstatic. @node Attribute Pool_Address,Attribute Range_Length,Attribute Passed_By_Reference,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-pool-address}@anchor{1a3} +@anchor{gnat_rm/implementation_defined_attributes attribute-pool-address}@anchor{1a2} @section Attribute Pool_Address @@ -11260,7 +11244,7 @@ For an object created by @code{new}, @code{Ptr.all'Pool_Address} is what is passed to @code{Allocate} and returned from @code{Deallocate}. @node Attribute Range_Length,Attribute Restriction_Set,Attribute Pool_Address,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-range-length}@anchor{1a4} +@anchor{gnat_rm/implementation_defined_attributes attribute-range-length}@anchor{1a3} @section Attribute Range_Length @@ -11273,7 +11257,7 @@ applied to the index subtype of a one dimensional array always gives the same result as @code{Length} applied to the array itself. @node Attribute Restriction_Set,Attribute Result,Attribute Range_Length,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-restriction-set}@anchor{1a5} +@anchor{gnat_rm/implementation_defined_attributes attribute-restriction-set}@anchor{1a4} @section Attribute Restriction_Set @@ -11343,7 +11327,7 @@ Restrictions pragma, they are not analyzed semantically, so they do not have a type. @node Attribute Result,Attribute Round,Attribute Restriction_Set,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-result}@anchor{1a6} +@anchor{gnat_rm/implementation_defined_attributes attribute-result}@anchor{1a5} @section Attribute Result @@ -11356,7 +11340,7 @@ For a further discussion of the use of this attribute and examples of its use, see the description of pragma Postcondition. @node Attribute Round,Attribute Safe_Emax,Attribute Result,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-round}@anchor{1a7} +@anchor{gnat_rm/implementation_defined_attributes attribute-round}@anchor{1a6} @section Attribute Round @@ -11367,7 +11351,7 @@ also permits the use of the @code{'Round} attribute for ordinary fixed point types. @node Attribute Safe_Emax,Attribute Safe_Large,Attribute Round,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-safe-emax}@anchor{1a8} +@anchor{gnat_rm/implementation_defined_attributes attribute-safe-emax}@anchor{1a7} @section Attribute Safe_Emax @@ -11380,7 +11364,7 @@ the Ada 83 reference manual for an exact description of the semantics of this attribute. @node Attribute Safe_Large,Attribute Safe_Small,Attribute Safe_Emax,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-safe-large}@anchor{1a9} +@anchor{gnat_rm/implementation_defined_attributes attribute-safe-large}@anchor{1a8} @section Attribute Safe_Large @@ -11393,7 +11377,7 @@ the Ada 83 reference manual for an exact description of the semantics of this attribute. @node Attribute Safe_Small,Attribute Scalar_Storage_Order,Attribute Safe_Large,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-safe-small}@anchor{1aa} +@anchor{gnat_rm/implementation_defined_attributes attribute-safe-small}@anchor{1a9} @section Attribute Safe_Small @@ -11406,7 +11390,7 @@ the Ada 83 reference manual for an exact description of the semantics of this attribute. @node Attribute Scalar_Storage_Order,Attribute Simple_Storage_Pool,Attribute Safe_Small,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-scalar-storage-order}@anchor{15c}@anchor{gnat_rm/implementation_defined_attributes id4}@anchor{1ab} +@anchor{gnat_rm/implementation_defined_attributes attribute-scalar-storage-order}@anchor{15c}@anchor{gnat_rm/implementation_defined_attributes id4}@anchor{1aa} @section Attribute Scalar_Storage_Order @@ -11569,7 +11553,7 @@ Note that debuggers may be unable to display the correct value of scalar components of a type for which the opposite storage order is specified. @node Attribute Simple_Storage_Pool,Attribute Small,Attribute Scalar_Storage_Order,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-simple-storage-pool}@anchor{ec}@anchor{gnat_rm/implementation_defined_attributes id5}@anchor{1ac} +@anchor{gnat_rm/implementation_defined_attributes attribute-simple-storage-pool}@anchor{ec}@anchor{gnat_rm/implementation_defined_attributes id5}@anchor{1ab} @section Attribute Simple_Storage_Pool @@ -11632,7 +11616,7 @@ as defined in section 13.11.2 of the Ada Reference Manual, except that the term `simple storage pool' is substituted for `storage pool'. @node Attribute Small,Attribute Small_Denominator,Attribute Simple_Storage_Pool,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-small}@anchor{1ad} +@anchor{gnat_rm/implementation_defined_attributes attribute-small}@anchor{1ac} @section Attribute Small @@ -11648,7 +11632,7 @@ the Ada 83 reference manual for an exact description of the semantics of this attribute when applied to floating-point types. @node Attribute Small_Denominator,Attribute Small_Numerator,Attribute Small,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-small-denominator}@anchor{1ae} +@anchor{gnat_rm/implementation_defined_attributes attribute-small-denominator}@anchor{1ad} @section Attribute Small_Denominator @@ -11661,7 +11645,7 @@ denominator in the representation of @code{typ'Small} as a rational number with coprime factors (i.e. as an irreducible fraction). @node Attribute Small_Numerator,Attribute Storage_Unit,Attribute Small_Denominator,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-small-numerator}@anchor{1af} +@anchor{gnat_rm/implementation_defined_attributes attribute-small-numerator}@anchor{1ae} @section Attribute Small_Numerator @@ -11674,7 +11658,7 @@ numerator in the representation of @code{typ'Small} as a rational number with coprime factors (i.e. as an irreducible fraction). @node Attribute Storage_Unit,Attribute Stub_Type,Attribute Small_Numerator,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-storage-unit}@anchor{1b0} +@anchor{gnat_rm/implementation_defined_attributes attribute-storage-unit}@anchor{1af} @section Attribute Storage_Unit @@ -11684,7 +11668,7 @@ with coprime factors (i.e. as an irreducible fraction). prefix) provides the same value as @code{System.Storage_Unit}. @node Attribute Stub_Type,Attribute Super,Attribute Storage_Unit,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-stub-type}@anchor{1b1} +@anchor{gnat_rm/implementation_defined_attributes attribute-stub-type}@anchor{1b0} @section Attribute Stub_Type @@ -11708,7 +11692,7 @@ unit @code{System.Partition_Interface}. Use of this attribute will create an implicit dependency on this unit. @node Attribute Super,Attribute System_Allocator_Alignment,Attribute Stub_Type,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-super}@anchor{1b2} +@anchor{gnat_rm/implementation_defined_attributes attribute-super}@anchor{1b1} @section Attribute Super @@ -11718,7 +11702,7 @@ The @code{Super} attribute can be applied to objects of tagged types in order to obtain a view conversion to the most immediate specific parent type. It cannot be applied to objects of types without any ancestors, or types whose -immediate parent is abstract. +immediate parent is an interface type. @example type T1 is tagged null record; @@ -11735,7 +11719,7 @@ end; @end example @node Attribute System_Allocator_Alignment,Attribute Target_Name,Attribute Super,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-system-allocator-alignment}@anchor{1b3} +@anchor{gnat_rm/implementation_defined_attributes attribute-system-allocator-alignment}@anchor{1b2} @section Attribute System_Allocator_Alignment @@ -11752,7 +11736,7 @@ with alignment too large or to enable a realignment circuitry if the alignment request is larger than this value. @node Attribute Target_Name,Attribute To_Address,Attribute System_Allocator_Alignment,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-target-name}@anchor{1b4} +@anchor{gnat_rm/implementation_defined_attributes attribute-target-name}@anchor{1b3} @section Attribute Target_Name @@ -11765,7 +11749,7 @@ standard gcc target name without the terminating slash (for example, GNAT 5.0 on windows yields “i586-pc-mingw32msv”). @node Attribute To_Address,Attribute To_Any,Attribute Target_Name,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-to-address}@anchor{1b5} +@anchor{gnat_rm/implementation_defined_attributes attribute-to-address}@anchor{1b4} @section Attribute To_Address @@ -11788,7 +11772,7 @@ modular manner (e.g., -1 means the same as 16#FFFF_FFFF# on a 32 bits machine). @node Attribute To_Any,Attribute Type_Class,Attribute To_Address,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-to-any}@anchor{1b6} +@anchor{gnat_rm/implementation_defined_attributes attribute-to-any}@anchor{1b5} @section Attribute To_Any @@ -11798,7 +11782,7 @@ This internal attribute is used for the generation of remote subprogram stubs in the context of the Distributed Systems Annex. @node Attribute Type_Class,Attribute Type_Key,Attribute To_Any,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-type-class}@anchor{1b7} +@anchor{gnat_rm/implementation_defined_attributes attribute-type-class}@anchor{1b6} @section Attribute Type_Class @@ -11828,7 +11812,7 @@ applies to all concurrent types. This attribute is designed to be compatible with the DEC Ada 83 attribute of the same name. @node Attribute Type_Key,Attribute TypeCode,Attribute Type_Class,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-type-key}@anchor{1b8} +@anchor{gnat_rm/implementation_defined_attributes attribute-type-key}@anchor{1b7} @section Attribute Type_Key @@ -11840,7 +11824,7 @@ about the type or subtype. This provides improved compatibility with other implementations that support this attribute. @node Attribute TypeCode,Attribute Unconstrained_Array,Attribute Type_Key,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-typecode}@anchor{1b9} +@anchor{gnat_rm/implementation_defined_attributes attribute-typecode}@anchor{1b8} @section Attribute TypeCode @@ -11850,7 +11834,7 @@ This internal attribute is used for the generation of remote subprogram stubs in the context of the Distributed Systems Annex. @node Attribute Unconstrained_Array,Attribute Universal_Literal_String,Attribute TypeCode,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-unconstrained-array}@anchor{1ba} +@anchor{gnat_rm/implementation_defined_attributes attribute-unconstrained-array}@anchor{1b9} @section Attribute Unconstrained_Array @@ -11864,7 +11848,7 @@ still static, and yields the result of applying this test to the generic actual. @node Attribute Universal_Literal_String,Attribute Unrestricted_Access,Attribute Unconstrained_Array,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-universal-literal-string}@anchor{1bb} +@anchor{gnat_rm/implementation_defined_attributes attribute-universal-literal-string}@anchor{1ba} @section Attribute Universal_Literal_String @@ -11892,7 +11876,7 @@ end; @end example @node Attribute Unrestricted_Access,Attribute Update,Attribute Universal_Literal_String,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-unrestricted-access}@anchor{1bc} +@anchor{gnat_rm/implementation_defined_attributes attribute-unrestricted-access}@anchor{1bb} @section Attribute Unrestricted_Access @@ -12079,7 +12063,7 @@ In general this is a risky approach. It may appear to “work” but such uses o of GNAT to another, so are best avoided if possible. @node Attribute Update,Attribute Valid_Value,Attribute Unrestricted_Access,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-update}@anchor{1bd} +@anchor{gnat_rm/implementation_defined_attributes attribute-update}@anchor{1bc} @section Attribute Update @@ -12160,7 +12144,7 @@ A := A'Update ((1, 2) => 20, (3, 4) => 30); which changes element (1,2) to 20 and (3,4) to 30. @node Attribute Valid_Value,Attribute Valid_Scalars,Attribute Update,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-valid-value}@anchor{1be} +@anchor{gnat_rm/implementation_defined_attributes attribute-valid-value}@anchor{1bd} @section Attribute Valid_Value @@ -12172,7 +12156,7 @@ a String, and returns Boolean. @code{T'Valid_Value (S)} returns True if and only if @code{T'Value (S)} would not raise Constraint_Error. @node Attribute Valid_Scalars,Attribute VADS_Size,Attribute Valid_Value,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-valid-scalars}@anchor{1bf} +@anchor{gnat_rm/implementation_defined_attributes attribute-valid-scalars}@anchor{1be} @section Attribute Valid_Scalars @@ -12206,7 +12190,7 @@ write a function with a single use of the attribute, and then call that function from multiple places. @node Attribute VADS_Size,Attribute Value_Size,Attribute Valid_Scalars,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-vads-size}@anchor{1c0} +@anchor{gnat_rm/implementation_defined_attributes attribute-vads-size}@anchor{1bf} @section Attribute VADS_Size @@ -12226,7 +12210,7 @@ gives the result that would be obtained by applying the attribute to the corresponding type. @node Attribute Value_Size,Attribute Wchar_T_Size,Attribute VADS_Size,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-value-size}@anchor{16c}@anchor{gnat_rm/implementation_defined_attributes id6}@anchor{1c1} +@anchor{gnat_rm/implementation_defined_attributes attribute-value-size}@anchor{16c}@anchor{gnat_rm/implementation_defined_attributes id6}@anchor{1c0} @section Attribute Value_Size @@ -12240,7 +12224,7 @@ a value of the given subtype. It is the same as @code{type'Size}, but, unlike @code{Size}, may be set for non-first subtypes. @node Attribute Wchar_T_Size,Attribute Word_Size,Attribute Value_Size,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-wchar-t-size}@anchor{1c2} +@anchor{gnat_rm/implementation_defined_attributes attribute-wchar-t-size}@anchor{1c1} @section Attribute Wchar_T_Size @@ -12252,7 +12236,7 @@ primarily for constructing the definition of this type in package @code{Interfaces.C}. The result is a static constant. @node Attribute Word_Size,,Attribute Wchar_T_Size,Implementation Defined Attributes -@anchor{gnat_rm/implementation_defined_attributes attribute-word-size}@anchor{1c3} +@anchor{gnat_rm/implementation_defined_attributes attribute-word-size}@anchor{1c2} @section Attribute Word_Size @@ -12263,7 +12247,7 @@ prefix) provides the value @code{System.Word_Size}. The result is a static constant. @node Standard and Implementation Defined Restrictions,Implementation Advice,Implementation Defined Attributes,Top -@anchor{gnat_rm/standard_and_implementation_defined_restrictions doc}@anchor{1c4}@anchor{gnat_rm/standard_and_implementation_defined_restrictions id1}@anchor{1c5}@anchor{gnat_rm/standard_and_implementation_defined_restrictions standard-and-implementation-defined-restrictions}@anchor{9} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions doc}@anchor{1c3}@anchor{gnat_rm/standard_and_implementation_defined_restrictions id1}@anchor{1c4}@anchor{gnat_rm/standard_and_implementation_defined_restrictions standard-and-implementation-defined-restrictions}@anchor{9} @chapter Standard and Implementation Defined Restrictions @@ -12292,7 +12276,7 @@ language defined or GNAT-specific, are listed in the following. @end menu @node Partition-Wide Restrictions,Program Unit Level Restrictions,,Standard and Implementation Defined Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions id2}@anchor{1c6}@anchor{gnat_rm/standard_and_implementation_defined_restrictions partition-wide-restrictions}@anchor{1c7} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions id2}@anchor{1c5}@anchor{gnat_rm/standard_and_implementation_defined_restrictions partition-wide-restrictions}@anchor{1c6} @section Partition-Wide Restrictions @@ -12385,7 +12369,7 @@ then all compilation units in the partition must obey the restriction). @end menu @node Immediate_Reclamation,Max_Asynchronous_Select_Nesting,,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions immediate-reclamation}@anchor{1c8} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions immediate-reclamation}@anchor{1c7} @subsection Immediate_Reclamation @@ -12397,7 +12381,7 @@ deallocation, any storage reserved at run time for an object is immediately reclaimed when the object no longer exists. @node Max_Asynchronous_Select_Nesting,Max_Entry_Queue_Length,Immediate_Reclamation,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions max-asynchronous-select-nesting}@anchor{1c9} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions max-asynchronous-select-nesting}@anchor{1c8} @subsection Max_Asynchronous_Select_Nesting @@ -12409,7 +12393,7 @@ detected at compile time. Violations of this restriction with values other than zero cause Storage_Error to be raised. @node Max_Entry_Queue_Length,Max_Protected_Entries,Max_Asynchronous_Select_Nesting,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions max-entry-queue-length}@anchor{1ca} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions max-entry-queue-length}@anchor{1c9} @subsection Max_Entry_Queue_Length @@ -12430,7 +12414,7 @@ compatibility purposes (and a warning will be generated for its use if warnings on obsolescent features are activated). @node Max_Protected_Entries,Max_Select_Alternatives,Max_Entry_Queue_Length,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions max-protected-entries}@anchor{1cb} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions max-protected-entries}@anchor{1ca} @subsection Max_Protected_Entries @@ -12441,7 +12425,7 @@ bounds of every entry family of a protected unit shall be static, or shall be defined by a discriminant of a subtype whose corresponding bound is static. @node Max_Select_Alternatives,Max_Storage_At_Blocking,Max_Protected_Entries,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions max-select-alternatives}@anchor{1cc} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions max-select-alternatives}@anchor{1cb} @subsection Max_Select_Alternatives @@ -12450,7 +12434,7 @@ defined by a discriminant of a subtype whose corresponding bound is static. [RM D.7] Specifies the maximum number of alternatives in a selective accept. @node Max_Storage_At_Blocking,Max_Task_Entries,Max_Select_Alternatives,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions max-storage-at-blocking}@anchor{1cd} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions max-storage-at-blocking}@anchor{1cc} @subsection Max_Storage_At_Blocking @@ -12461,7 +12445,7 @@ Storage_Size that can be retained by a blocked task. A violation of this restriction causes Storage_Error to be raised. @node Max_Task_Entries,Max_Tasks,Max_Storage_At_Blocking,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions max-task-entries}@anchor{1ce} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions max-task-entries}@anchor{1cd} @subsection Max_Task_Entries @@ -12474,7 +12458,7 @@ defined by a discriminant of a subtype whose corresponding bound is static. @node Max_Tasks,No_Abort_Statements,Max_Task_Entries,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions max-tasks}@anchor{1cf} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions max-tasks}@anchor{1ce} @subsection Max_Tasks @@ -12487,7 +12471,7 @@ time. Violations of this restriction with values other than zero cause Storage_Error to be raised. @node No_Abort_Statements,No_Access_Parameter_Allocators,Max_Tasks,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-abort-statements}@anchor{1d0} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-abort-statements}@anchor{1cf} @subsection No_Abort_Statements @@ -12497,7 +12481,7 @@ Storage_Error to be raised. no calls to Task_Identification.Abort_Task. @node No_Access_Parameter_Allocators,No_Access_Subprograms,No_Abort_Statements,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-access-parameter-allocators}@anchor{1d1} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-access-parameter-allocators}@anchor{1d0} @subsection No_Access_Parameter_Allocators @@ -12508,7 +12492,7 @@ occurrences of an allocator as the actual parameter to an access parameter. @node No_Access_Subprograms,No_Allocators,No_Access_Parameter_Allocators,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-access-subprograms}@anchor{1d2} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-access-subprograms}@anchor{1d1} @subsection No_Access_Subprograms @@ -12518,7 +12502,7 @@ parameter. declarations of access-to-subprogram types. @node No_Allocators,No_Anonymous_Allocators,No_Access_Subprograms,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-allocators}@anchor{1d3} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-allocators}@anchor{1d2} @subsection No_Allocators @@ -12528,7 +12512,7 @@ declarations of access-to-subprogram types. occurrences of an allocator. @node No_Anonymous_Allocators,No_Asynchronous_Control,No_Allocators,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-anonymous-allocators}@anchor{1d4} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-anonymous-allocators}@anchor{1d3} @subsection No_Anonymous_Allocators @@ -12538,7 +12522,7 @@ occurrences of an allocator. occurrences of an allocator of anonymous access type. @node No_Asynchronous_Control,No_Calendar,No_Anonymous_Allocators,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-asynchronous-control}@anchor{1d5} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-asynchronous-control}@anchor{1d4} @subsection No_Asynchronous_Control @@ -12548,7 +12532,7 @@ occurrences of an allocator of anonymous access type. dependences on the predefined package Asynchronous_Task_Control. @node No_Calendar,No_Coextensions,No_Asynchronous_Control,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-calendar}@anchor{1d6} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-calendar}@anchor{1d5} @subsection No_Calendar @@ -12558,7 +12542,7 @@ dependences on the predefined package Asynchronous_Task_Control. dependences on package Calendar. @node No_Coextensions,No_Default_Initialization,No_Calendar,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-coextensions}@anchor{1d7} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-coextensions}@anchor{1d6} @subsection No_Coextensions @@ -12568,7 +12552,7 @@ dependences on package Calendar. coextensions. See 3.10.2. @node No_Default_Initialization,No_Delay,No_Coextensions,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-default-initialization}@anchor{1d8} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-default-initialization}@anchor{1d7} @subsection No_Default_Initialization @@ -12585,7 +12569,7 @@ is to prohibit all cases of variables declared without a specific initializer (including the case of OUT scalar parameters). @node No_Delay,No_Dependence,No_Default_Initialization,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-delay}@anchor{1d9} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-delay}@anchor{1d8} @subsection No_Delay @@ -12595,7 +12579,7 @@ initializer (including the case of OUT scalar parameters). delay statements and no semantic dependences on package Calendar. @node No_Dependence,No_Direct_Boolean_Operators,No_Delay,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dependence}@anchor{1da} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dependence}@anchor{1d9} @subsection No_Dependence @@ -12638,7 +12622,7 @@ to support specific constructs of the language. Here are some examples: @end itemize @node No_Direct_Boolean_Operators,No_Dispatch,No_Dependence,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-direct-boolean-operators}@anchor{1db} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-direct-boolean-operators}@anchor{1da} @subsection No_Direct_Boolean_Operators @@ -12651,7 +12635,7 @@ protocol requires the use of short-circuit (and then, or else) forms for all composite boolean operations. @node No_Dispatch,No_Dispatching_Calls,No_Direct_Boolean_Operators,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dispatch}@anchor{1dc} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dispatch}@anchor{1db} @subsection No_Dispatch @@ -12661,7 +12645,7 @@ composite boolean operations. occurrences of @code{T'Class}, for any (tagged) subtype @code{T}. @node No_Dispatching_Calls,No_Dynamic_Attachment,No_Dispatch,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dispatching-calls}@anchor{1dd} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dispatching-calls}@anchor{1dc} @subsection No_Dispatching_Calls @@ -12722,7 +12706,7 @@ end Example; @end example @node No_Dynamic_Attachment,No_Dynamic_Priorities,No_Dispatching_Calls,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dynamic-attachment}@anchor{1de} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dynamic-attachment}@anchor{1dd} @subsection No_Dynamic_Attachment @@ -12741,7 +12725,7 @@ compatibility purposes (and a warning will be generated for its use if warnings on obsolescent features are activated). @node No_Dynamic_Priorities,No_Entry_Calls_In_Elaboration_Code,No_Dynamic_Attachment,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dynamic-priorities}@anchor{1df} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dynamic-priorities}@anchor{1de} @subsection No_Dynamic_Priorities @@ -12750,7 +12734,7 @@ warnings on obsolescent features are activated). [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities. @node No_Entry_Calls_In_Elaboration_Code,No_Enumeration_Maps,No_Dynamic_Priorities,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-entry-calls-in-elaboration-code}@anchor{1e0} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-entry-calls-in-elaboration-code}@anchor{1df} @subsection No_Entry_Calls_In_Elaboration_Code @@ -12762,7 +12746,7 @@ restriction, the compiler can assume that no code past an accept statement in a task can be executed at elaboration time. @node No_Enumeration_Maps,No_Exception_Handlers,No_Entry_Calls_In_Elaboration_Code,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-enumeration-maps}@anchor{1e1} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-enumeration-maps}@anchor{1e0} @subsection No_Enumeration_Maps @@ -12773,7 +12757,7 @@ enumeration maps are used (that is Image and Value attributes applied to enumeration types). @node No_Exception_Handlers,No_Exception_Propagation,No_Enumeration_Maps,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-exception-handlers}@anchor{1e2} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-exception-handlers}@anchor{1e1} @subsection No_Exception_Handlers @@ -12798,7 +12782,7 @@ statement generated by the compiler). The Line parameter when nonzero represents the line number in the source program where the raise occurs. @node No_Exception_Propagation,No_Exception_Registration,No_Exception_Handlers,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-exception-propagation}@anchor{1e3} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-exception-propagation}@anchor{1e2} @subsection No_Exception_Propagation @@ -12815,7 +12799,7 @@ the package GNAT.Current_Exception is not permitted, and reraise statements (raise with no operand) are not permitted. @node No_Exception_Registration,No_Exceptions,No_Exception_Propagation,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-exception-registration}@anchor{1e4} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-exception-registration}@anchor{1e3} @subsection No_Exception_Registration @@ -12829,7 +12813,7 @@ code is simplified by omitting the otherwise-required global registration of exceptions when they are declared. @node No_Exceptions,No_Finalization,No_Exception_Registration,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-exceptions}@anchor{1e5} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-exceptions}@anchor{1e4} @subsection No_Exceptions @@ -12840,7 +12824,7 @@ raise statements and no exception handlers and also suppresses the generation of language-defined run-time checks. @node No_Finalization,No_Fixed_Point,No_Exceptions,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-finalization}@anchor{1e6} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-finalization}@anchor{1e5} @subsection No_Finalization @@ -12881,7 +12865,7 @@ object or a nested component, either declared on the stack or on the heap. The deallocation of a controlled object no longer finalizes its contents. @node No_Fixed_Point,No_Floating_Point,No_Finalization,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-fixed-point}@anchor{1e7} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-fixed-point}@anchor{1e6} @subsection No_Fixed_Point @@ -12891,7 +12875,7 @@ deallocation of a controlled object no longer finalizes its contents. occurrences of fixed point types and operations. @node No_Floating_Point,No_Implicit_Conditionals,No_Fixed_Point,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-floating-point}@anchor{1e8} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-floating-point}@anchor{1e7} @subsection No_Floating_Point @@ -12901,7 +12885,7 @@ occurrences of fixed point types and operations. occurrences of floating point types and operations. @node No_Implicit_Conditionals,No_Implicit_Dynamic_Code,No_Floating_Point,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-conditionals}@anchor{1e9} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-conditionals}@anchor{1e8} @subsection No_Implicit_Conditionals @@ -12917,7 +12901,7 @@ normal manner. Constructs generating implicit conditionals include comparisons of composite objects and the Max/Min attributes. @node No_Implicit_Dynamic_Code,No_Implicit_Heap_Allocations,No_Implicit_Conditionals,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-dynamic-code}@anchor{1ea} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-dynamic-code}@anchor{1e9} @subsection No_Implicit_Dynamic_Code @@ -12947,7 +12931,7 @@ foreign-language convention; primitive operations of nested tagged types. @node No_Implicit_Heap_Allocations,No_Implicit_Protected_Object_Allocations,No_Implicit_Dynamic_Code,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-heap-allocations}@anchor{1eb} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-heap-allocations}@anchor{1ea} @subsection No_Implicit_Heap_Allocations @@ -12956,7 +12940,7 @@ types. [RM D.7] No constructs are allowed to cause implicit heap allocation. @node No_Implicit_Protected_Object_Allocations,No_Implicit_Task_Allocations,No_Implicit_Heap_Allocations,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-protected-object-allocations}@anchor{1ec} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-protected-object-allocations}@anchor{1eb} @subsection No_Implicit_Protected_Object_Allocations @@ -12966,7 +12950,7 @@ types. protected object. @node No_Implicit_Task_Allocations,No_Initialize_Scalars,No_Implicit_Protected_Object_Allocations,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-task-allocations}@anchor{1ed} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-task-allocations}@anchor{1ec} @subsection No_Implicit_Task_Allocations @@ -12975,7 +12959,7 @@ protected object. [GNAT] No constructs are allowed to cause implicit heap allocation of a task. @node No_Initialize_Scalars,No_IO,No_Implicit_Task_Allocations,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-initialize-scalars}@anchor{1ee} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-initialize-scalars}@anchor{1ed} @subsection No_Initialize_Scalars @@ -12987,7 +12971,7 @@ code, and in particular eliminates dummy null initialization routines that are otherwise generated for some record and array types. @node No_IO,No_Local_Allocators,No_Initialize_Scalars,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-io}@anchor{1ef} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-io}@anchor{1ee} @subsection No_IO @@ -12998,7 +12982,7 @@ dependences on any of the library units Sequential_IO, Direct_IO, Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO. @node No_Local_Allocators,No_Local_Protected_Objects,No_IO,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-local-allocators}@anchor{1f0} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-local-allocators}@anchor{1ef} @subsection No_Local_Allocators @@ -13009,7 +12993,7 @@ occurrences of an allocator in subprograms, generic subprograms, tasks, and entry bodies. @node No_Local_Protected_Objects,No_Local_Tagged_Types,No_Local_Allocators,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-local-protected-objects}@anchor{1f1} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-local-protected-objects}@anchor{1f0} @subsection No_Local_Protected_Objects @@ -13019,7 +13003,7 @@ and entry bodies. only declared at the library level. @node No_Local_Tagged_Types,No_Local_Timing_Events,No_Local_Protected_Objects,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-local-tagged-types}@anchor{1f2} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-local-tagged-types}@anchor{1f1} @subsection No_Local_Tagged_Types @@ -13029,7 +13013,7 @@ only declared at the library level. declared at the library level. @node No_Local_Timing_Events,No_Long_Long_Integers,No_Local_Tagged_Types,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-local-timing-events}@anchor{1f3} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-local-timing-events}@anchor{1f2} @subsection No_Local_Timing_Events @@ -13039,7 +13023,7 @@ declared at the library level. declared at the library level. @node No_Long_Long_Integers,No_Multiple_Elaboration,No_Local_Timing_Events,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-long-long-integers}@anchor{1f4} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-long-long-integers}@anchor{1f3} @subsection No_Long_Long_Integers @@ -13051,7 +13035,7 @@ implicit base type is Long_Long_Integer, and modular types whose size exceeds Long_Integer’Size. @node No_Multiple_Elaboration,No_Nested_Finalization,No_Long_Long_Integers,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-multiple-elaboration}@anchor{1f5} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-multiple-elaboration}@anchor{1f4} @subsection No_Multiple_Elaboration @@ -13067,7 +13051,7 @@ possible, including non-Ada main programs and Stand Alone libraries, are not permitted and will be diagnosed by the binder. @node No_Nested_Finalization,No_Protected_Type_Allocators,No_Multiple_Elaboration,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-nested-finalization}@anchor{1f6} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-nested-finalization}@anchor{1f5} @subsection No_Nested_Finalization @@ -13076,7 +13060,7 @@ permitted and will be diagnosed by the binder. [RM D.7] All objects requiring finalization are declared at the library level. @node No_Protected_Type_Allocators,No_Protected_Types,No_Nested_Finalization,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-protected-type-allocators}@anchor{1f7} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-protected-type-allocators}@anchor{1f6} @subsection No_Protected_Type_Allocators @@ -13086,7 +13070,7 @@ permitted and will be diagnosed by the binder. expressions that attempt to allocate protected objects. @node No_Protected_Types,No_Recursion,No_Protected_Type_Allocators,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-protected-types}@anchor{1f8} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-protected-types}@anchor{1f7} @subsection No_Protected_Types @@ -13096,7 +13080,7 @@ expressions that attempt to allocate protected objects. declarations of protected types or protected objects. @node No_Recursion,No_Reentrancy,No_Protected_Types,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-recursion}@anchor{1f9} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-recursion}@anchor{1f8} @subsection No_Recursion @@ -13106,7 +13090,7 @@ declarations of protected types or protected objects. part of its execution. @node No_Reentrancy,No_Relative_Delay,No_Recursion,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-reentrancy}@anchor{1fa} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-reentrancy}@anchor{1f9} @subsection No_Reentrancy @@ -13116,7 +13100,7 @@ part of its execution. two tasks at the same time. @node No_Relative_Delay,No_Requeue_Statements,No_Reentrancy,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-relative-delay}@anchor{1fb} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-relative-delay}@anchor{1fa} @subsection No_Relative_Delay @@ -13127,7 +13111,7 @@ relative statements and prevents expressions such as @code{delay 1.23;} from appearing in source code. @node No_Requeue_Statements,No_Secondary_Stack,No_Relative_Delay,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-requeue-statements}@anchor{1fc} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-requeue-statements}@anchor{1fb} @subsection No_Requeue_Statements @@ -13145,7 +13129,7 @@ compatibility purposes (and a warning will be generated for its use if warnings on oNobsolescent features are activated). @node No_Secondary_Stack,No_Select_Statements,No_Requeue_Statements,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-secondary-stack}@anchor{1fd} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-secondary-stack}@anchor{1fc} @subsection No_Secondary_Stack @@ -13158,7 +13142,7 @@ stack is used to implement functions returning unconstrained objects secondary stacks for tasks (excluding the environment task) at run time. @node No_Select_Statements,No_Specific_Termination_Handlers,No_Secondary_Stack,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-select-statements}@anchor{1fe} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-select-statements}@anchor{1fd} @subsection No_Select_Statements @@ -13168,7 +13152,7 @@ secondary stacks for tasks (excluding the environment task) at run time. kind are permitted, that is the keyword @code{select} may not appear. @node No_Specific_Termination_Handlers,No_Specification_of_Aspect,No_Select_Statements,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-specific-termination-handlers}@anchor{1ff} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-specific-termination-handlers}@anchor{1fe} @subsection No_Specific_Termination_Handlers @@ -13178,7 +13162,7 @@ kind are permitted, that is the keyword @code{select} may not appear. or to Ada.Task_Termination.Specific_Handler. @node No_Specification_of_Aspect,No_Standard_Allocators_After_Elaboration,No_Specific_Termination_Handlers,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-specification-of-aspect}@anchor{200} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-specification-of-aspect}@anchor{1ff} @subsection No_Specification_of_Aspect @@ -13189,7 +13173,7 @@ specification, attribute definition clause, or pragma is given for a given aspect. @node No_Standard_Allocators_After_Elaboration,No_Standard_Storage_Pools,No_Specification_of_Aspect,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-standard-allocators-after-elaboration}@anchor{201} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-standard-allocators-after-elaboration}@anchor{200} @subsection No_Standard_Allocators_After_Elaboration @@ -13201,7 +13185,7 @@ library items of the partition has completed. Otherwise, Storage_Error is raised. @node No_Standard_Storage_Pools,No_Stream_Optimizations,No_Standard_Allocators_After_Elaboration,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-standard-storage-pools}@anchor{202} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-standard-storage-pools}@anchor{201} @subsection No_Standard_Storage_Pools @@ -13213,7 +13197,7 @@ have an explicit Storage_Pool attribute defined specifying a user-defined storage pool. @node No_Stream_Optimizations,No_Streams,No_Standard_Storage_Pools,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-stream-optimizations}@anchor{203} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-stream-optimizations}@anchor{202} @subsection No_Stream_Optimizations @@ -13226,7 +13210,7 @@ due to their superior performance. When this restriction is in effect, the compiler performs all IO operations on a per-character basis. @node No_Streams,No_Tagged_Type_Registration,No_Stream_Optimizations,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-streams}@anchor{204} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-streams}@anchor{203} @subsection No_Streams @@ -13246,8 +13230,14 @@ To take maximum advantage of this space-saving optimization, any unit declaring a tagged type should be compiled with the restriction, though this is not required. +When pragmas @code{Discard_Names} and @code{Restrictions (No_Streams)} simultaneously +apply to a tagged type, its Expanded_Name and External_Tag are also initialized +with empty strings. In particular, both these pragmas can be applied as +configuration pragmas to avoid exposing entity names at binary level for the +entire partition. + @node No_Tagged_Type_Registration,No_Task_Allocators,No_Streams,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-tagged-type-registration}@anchor{205} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-tagged-type-registration}@anchor{204} @subsection No_Tagged_Type_Registration @@ -13262,7 +13252,7 @@ are declared. This restriction may be necessary in order to also apply the No_Elaboration_Code restriction. @node No_Task_Allocators,No_Task_At_Interrupt_Priority,No_Tagged_Type_Registration,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-allocators}@anchor{206} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-allocators}@anchor{205} @subsection No_Task_Allocators @@ -13272,7 +13262,7 @@ the No_Elaboration_Code restriction. or types containing task subcomponents. @node No_Task_At_Interrupt_Priority,No_Task_Attributes_Package,No_Task_Allocators,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-at-interrupt-priority}@anchor{207} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-at-interrupt-priority}@anchor{206} @subsection No_Task_At_Interrupt_Priority @@ -13284,7 +13274,7 @@ a consequence, the tasks are always created with a priority below that an interrupt priority. @node No_Task_Attributes_Package,No_Task_Hierarchy,No_Task_At_Interrupt_Priority,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-attributes-package}@anchor{208} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-attributes-package}@anchor{207} @subsection No_Task_Attributes_Package @@ -13301,7 +13291,7 @@ compatibility purposes (and a warning will be generated for its use if warnings on obsolescent features are activated). @node No_Task_Hierarchy,No_Task_Termination,No_Task_Attributes_Package,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-hierarchy}@anchor{209} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-hierarchy}@anchor{208} @subsection No_Task_Hierarchy @@ -13311,7 +13301,7 @@ warnings on obsolescent features are activated). directly on the environment task of the partition. @node No_Task_Termination,No_Tasking,No_Task_Hierarchy,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-termination}@anchor{20a} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-termination}@anchor{209} @subsection No_Task_Termination @@ -13320,7 +13310,7 @@ directly on the environment task of the partition. [RM D.7] Tasks that terminate are erroneous. @node No_Tasking,No_Terminate_Alternatives,No_Task_Termination,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-tasking}@anchor{20b} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-tasking}@anchor{20a} @subsection No_Tasking @@ -13333,7 +13323,7 @@ and cause an error message to be output either by the compiler or binder. @node No_Terminate_Alternatives,No_Unchecked_Access,No_Tasking,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-terminate-alternatives}@anchor{20c} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-terminate-alternatives}@anchor{20b} @subsection No_Terminate_Alternatives @@ -13342,7 +13332,7 @@ binder. [RM D.7] There are no selective accepts with terminate alternatives. @node No_Unchecked_Access,No_Unchecked_Conversion,No_Terminate_Alternatives,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-unchecked-access}@anchor{20d} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-unchecked-access}@anchor{20c} @subsection No_Unchecked_Access @@ -13352,7 +13342,7 @@ binder. occurrences of the Unchecked_Access attribute. @node No_Unchecked_Conversion,No_Unchecked_Deallocation,No_Unchecked_Access,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-unchecked-conversion}@anchor{20e} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-unchecked-conversion}@anchor{20d} @subsection No_Unchecked_Conversion @@ -13362,7 +13352,7 @@ occurrences of the Unchecked_Access attribute. dependences on the predefined generic function Unchecked_Conversion. @node No_Unchecked_Deallocation,No_Use_Of_Attribute,No_Unchecked_Conversion,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-unchecked-deallocation}@anchor{20f} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-unchecked-deallocation}@anchor{20e} @subsection No_Unchecked_Deallocation @@ -13372,7 +13362,7 @@ dependences on the predefined generic function Unchecked_Conversion. dependences on the predefined generic procedure Unchecked_Deallocation. @node No_Use_Of_Attribute,No_Use_Of_Entity,No_Unchecked_Deallocation,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-use-of-attribute}@anchor{210} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-use-of-attribute}@anchor{20f} @subsection No_Use_Of_Attribute @@ -13382,7 +13372,7 @@ dependences on the predefined generic procedure Unchecked_Deallocation. earlier versions of Ada. @node No_Use_Of_Entity,No_Use_Of_Pragma,No_Use_Of_Attribute,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-use-of-entity}@anchor{211} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-use-of-entity}@anchor{210} @subsection No_Use_Of_Entity @@ -13402,7 +13392,7 @@ No_Use_Of_Entity => Ada.Text_IO.Put_Line @end example @node No_Use_Of_Pragma,Pure_Barriers,No_Use_Of_Entity,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-use-of-pragma}@anchor{212} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-use-of-pragma}@anchor{211} @subsection No_Use_Of_Pragma @@ -13412,7 +13402,7 @@ No_Use_Of_Entity => Ada.Text_IO.Put_Line earlier versions of Ada. @node Pure_Barriers,Simple_Barriers,No_Use_Of_Pragma,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions pure-barriers}@anchor{213} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions pure-barriers}@anchor{212} @subsection Pure_Barriers @@ -13463,7 +13453,7 @@ but still ensures absence of side effects, exceptions, and recursion during the evaluation of the barriers. @node Simple_Barriers,Static_Priorities,Pure_Barriers,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions simple-barriers}@anchor{214} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions simple-barriers}@anchor{213} @subsection Simple_Barriers @@ -13482,7 +13472,7 @@ compatibility purposes (and a warning will be generated for its use if warnings on obsolescent features are activated). @node Static_Priorities,Static_Storage_Size,Simple_Barriers,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions static-priorities}@anchor{215} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions static-priorities}@anchor{214} @subsection Static_Priorities @@ -13493,7 +13483,7 @@ are static, and that there are no dependences on the package @code{Ada.Dynamic_Priorities}. @node Static_Storage_Size,,Static_Priorities,Partition-Wide Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions static-storage-size}@anchor{216} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions static-storage-size}@anchor{215} @subsection Static_Storage_Size @@ -13503,7 +13493,7 @@ are static, and that there are no dependences on the package in a Storage_Size pragma or attribute definition clause is static. @node Program Unit Level Restrictions,,Partition-Wide Restrictions,Standard and Implementation Defined Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions id3}@anchor{217}@anchor{gnat_rm/standard_and_implementation_defined_restrictions program-unit-level-restrictions}@anchor{218} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions id3}@anchor{216}@anchor{gnat_rm/standard_and_implementation_defined_restrictions program-unit-level-restrictions}@anchor{217} @section Program Unit Level Restrictions @@ -13534,7 +13524,7 @@ other compilation units in the partition. @end menu @node No_Elaboration_Code,No_Dynamic_Accessibility_Checks,,Program Unit Level Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-elaboration-code}@anchor{219} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-elaboration-code}@anchor{218} @subsection No_Elaboration_Code @@ -13590,7 +13580,7 @@ associated with the unit. This counter is typically used to check for access before elaboration and to control multiple elaboration attempts. @node No_Dynamic_Accessibility_Checks,No_Dynamic_Sized_Objects,No_Elaboration_Code,Program Unit Level Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dynamic-accessibility-checks}@anchor{21a} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dynamic-accessibility-checks}@anchor{219} @subsection No_Dynamic_Accessibility_Checks @@ -13639,7 +13629,7 @@ In all other cases, the level of T is as defined by the existing rules of Ada. @end itemize @node No_Dynamic_Sized_Objects,No_Entry_Queue,No_Dynamic_Accessibility_Checks,Program Unit Level Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dynamic-sized-objects}@anchor{21b} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dynamic-sized-objects}@anchor{21a} @subsection No_Dynamic_Sized_Objects @@ -13657,7 +13647,7 @@ access discriminants. It is often a good idea to combine this restriction with No_Secondary_Stack. @node No_Entry_Queue,No_Implementation_Aspect_Specifications,No_Dynamic_Sized_Objects,Program Unit Level Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-entry-queue}@anchor{21c} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-entry-queue}@anchor{21b} @subsection No_Entry_Queue @@ -13670,7 +13660,7 @@ checked at compile time. A program execution is erroneous if an attempt is made to queue a second task on such an entry. @node No_Implementation_Aspect_Specifications,No_Implementation_Attributes,No_Entry_Queue,Program Unit Level Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-aspect-specifications}@anchor{21d} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-aspect-specifications}@anchor{21c} @subsection No_Implementation_Aspect_Specifications @@ -13681,7 +13671,7 @@ GNAT-defined aspects are present. With this restriction, the only aspects that can be used are those defined in the Ada Reference Manual. @node No_Implementation_Attributes,No_Implementation_Identifiers,No_Implementation_Aspect_Specifications,Program Unit Level Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-attributes}@anchor{21e} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-attributes}@anchor{21d} @subsection No_Implementation_Attributes @@ -13693,7 +13683,7 @@ attributes that can be used are those defined in the Ada Reference Manual. @node No_Implementation_Identifiers,No_Implementation_Pragmas,No_Implementation_Attributes,Program Unit Level Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-identifiers}@anchor{21f} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-identifiers}@anchor{21e} @subsection No_Implementation_Identifiers @@ -13704,7 +13694,7 @@ implementation-defined identifiers (marked with pragma Implementation_Defined) occur within language-defined packages. @node No_Implementation_Pragmas,No_Implementation_Restrictions,No_Implementation_Identifiers,Program Unit Level Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-pragmas}@anchor{220} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-pragmas}@anchor{21f} @subsection No_Implementation_Pragmas @@ -13715,7 +13705,7 @@ GNAT-defined pragmas are present. With this restriction, the only pragmas that can be used are those defined in the Ada Reference Manual. @node No_Implementation_Restrictions,No_Implementation_Units,No_Implementation_Pragmas,Program Unit Level Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-restrictions}@anchor{221} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-restrictions}@anchor{220} @subsection No_Implementation_Restrictions @@ -13727,7 +13717,7 @@ are present. With this restriction, the only other restriction identifiers that can be used are those defined in the Ada Reference Manual. @node No_Implementation_Units,No_Implicit_Aliasing,No_Implementation_Restrictions,Program Unit Level Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-units}@anchor{222} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-units}@anchor{221} @subsection No_Implementation_Units @@ -13738,7 +13728,7 @@ mention in the context clause of any implementation-defined descendants of packages Ada, Interfaces, or System. @node No_Implicit_Aliasing,No_Implicit_Loops,No_Implementation_Units,Program Unit Level Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-aliasing}@anchor{223} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-aliasing}@anchor{222} @subsection No_Implicit_Aliasing @@ -13753,7 +13743,7 @@ to be aliased, and in such cases, it can always be replaced by the standard attribute Unchecked_Access which is preferable. @node No_Implicit_Loops,No_Obsolescent_Features,No_Implicit_Aliasing,Program Unit Level Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-loops}@anchor{224} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-loops}@anchor{223} @subsection No_Implicit_Loops @@ -13770,7 +13760,7 @@ arrays larger than about 5000 scalar components. Note that if this restriction is set in the spec of a package, it will not apply to its body. @node No_Obsolescent_Features,No_Wide_Characters,No_Implicit_Loops,Program Unit Level Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-obsolescent-features}@anchor{225} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-obsolescent-features}@anchor{224} @subsection No_Obsolescent_Features @@ -13780,7 +13770,7 @@ is set in the spec of a package, it will not apply to its body. features are used, as defined in Annex J of the Ada Reference Manual. @node No_Wide_Characters,Static_Dispatch_Tables,No_Obsolescent_Features,Program Unit Level Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-wide-characters}@anchor{226} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions no-wide-characters}@anchor{225} @subsection No_Wide_Characters @@ -13794,7 +13784,7 @@ appear in the program (that is literals representing characters not in type @code{Character}). @node Static_Dispatch_Tables,SPARK_05,No_Wide_Characters,Program Unit Level Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions static-dispatch-tables}@anchor{227} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions static-dispatch-tables}@anchor{226} @subsection Static_Dispatch_Tables @@ -13804,7 +13794,7 @@ type @code{Character}). associated with dispatch tables can be placed in read-only memory. @node SPARK_05,,Static_Dispatch_Tables,Program Unit Level Restrictions -@anchor{gnat_rm/standard_and_implementation_defined_restrictions spark-05}@anchor{228} +@anchor{gnat_rm/standard_and_implementation_defined_restrictions spark-05}@anchor{227} @subsection SPARK_05 @@ -13827,7 +13817,7 @@ gnatprove -P project.gpr --mode=check_all @end example @node Implementation Advice,Implementation Defined Characteristics,Standard and Implementation Defined Restrictions,Top -@anchor{gnat_rm/implementation_advice doc}@anchor{229}@anchor{gnat_rm/implementation_advice id1}@anchor{22a}@anchor{gnat_rm/implementation_advice implementation-advice}@anchor{a} +@anchor{gnat_rm/implementation_advice doc}@anchor{228}@anchor{gnat_rm/implementation_advice id1}@anchor{229}@anchor{gnat_rm/implementation_advice implementation-advice}@anchor{a} @chapter Implementation Advice @@ -13925,7 +13915,7 @@ case the text describes what GNAT does and why. @end menu @node RM 1 1 3 20 Error Detection,RM 1 1 3 31 Child Units,,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-1-1-3-20-error-detection}@anchor{22b} +@anchor{gnat_rm/implementation_advice rm-1-1-3-20-error-detection}@anchor{22a} @section RM 1.1.3(20): Error Detection @@ -13942,7 +13932,7 @@ or diagnosed at compile time. @geindex Child Units @node RM 1 1 3 31 Child Units,RM 1 1 5 12 Bounded Errors,RM 1 1 3 20 Error Detection,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-1-1-3-31-child-units}@anchor{22c} +@anchor{gnat_rm/implementation_advice rm-1-1-3-31-child-units}@anchor{22b} @section RM 1.1.3(31): Child Units @@ -13958,7 +13948,7 @@ Followed. @geindex Bounded errors @node RM 1 1 5 12 Bounded Errors,RM 2 8 16 Pragmas,RM 1 1 3 31 Child Units,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-1-1-5-12-bounded-errors}@anchor{22d} +@anchor{gnat_rm/implementation_advice rm-1-1-5-12-bounded-errors}@anchor{22c} @section RM 1.1.5(12): Bounded Errors @@ -13975,7 +13965,7 @@ runtime. @geindex Pragmas @node RM 2 8 16 Pragmas,RM 2 8 17-19 Pragmas,RM 1 1 5 12 Bounded Errors,Implementation Advice -@anchor{gnat_rm/implementation_advice id2}@anchor{22e}@anchor{gnat_rm/implementation_advice rm-2-8-16-pragmas}@anchor{22f} +@anchor{gnat_rm/implementation_advice id2}@anchor{22d}@anchor{gnat_rm/implementation_advice rm-2-8-16-pragmas}@anchor{22e} @section RM 2.8(16): Pragmas @@ -14088,7 +14078,7 @@ that this advice not be followed. For details see @ref{7,,Implementation Defined Pragmas}. @node RM 2 8 17-19 Pragmas,RM 3 5 2 5 Alternative Character Sets,RM 2 8 16 Pragmas,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-2-8-17-19-pragmas}@anchor{230} +@anchor{gnat_rm/implementation_advice rm-2-8-17-19-pragmas}@anchor{22f} @section RM 2.8(17-19): Pragmas @@ -14109,14 +14099,14 @@ replacing @code{library_items}.” @end itemize @end quotation -See @ref{22f,,RM 2.8(16); Pragmas}. +See @ref{22e,,RM 2.8(16); Pragmas}. @geindex Character Sets @geindex Alternative Character Sets @node RM 3 5 2 5 Alternative Character Sets,RM 3 5 4 28 Integer Types,RM 2 8 17-19 Pragmas,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-3-5-2-5-alternative-character-sets}@anchor{231} +@anchor{gnat_rm/implementation_advice rm-3-5-2-5-alternative-character-sets}@anchor{230} @section RM 3.5.2(5): Alternative Character Sets @@ -14144,7 +14134,7 @@ there is no such restriction. @geindex Integer types @node RM 3 5 4 28 Integer Types,RM 3 5 4 29 Integer Types,RM 3 5 2 5 Alternative Character Sets,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-3-5-4-28-integer-types}@anchor{232} +@anchor{gnat_rm/implementation_advice rm-3-5-4-28-integer-types}@anchor{231} @section RM 3.5.4(28): Integer Types @@ -14163,7 +14153,7 @@ are supported for convenient interface to C, and so that all hardware types of the machine are easily available. @node RM 3 5 4 29 Integer Types,RM 3 5 5 8 Enumeration Values,RM 3 5 4 28 Integer Types,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-3-5-4-29-integer-types}@anchor{233} +@anchor{gnat_rm/implementation_advice rm-3-5-4-29-integer-types}@anchor{232} @section RM 3.5.4(29): Integer Types @@ -14179,7 +14169,7 @@ Followed. @geindex Enumeration values @node RM 3 5 5 8 Enumeration Values,RM 3 5 7 17 Float Types,RM 3 5 4 29 Integer Types,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-3-5-5-8-enumeration-values}@anchor{234} +@anchor{gnat_rm/implementation_advice rm-3-5-5-8-enumeration-values}@anchor{233} @section RM 3.5.5(8): Enumeration Values @@ -14199,7 +14189,7 @@ Followed. @geindex Float types @node RM 3 5 7 17 Float Types,RM 3 6 2 11 Multidimensional Arrays,RM 3 5 5 8 Enumeration Values,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-3-5-7-17-float-types}@anchor{235} +@anchor{gnat_rm/implementation_advice rm-3-5-7-17-float-types}@anchor{234} @section RM 3.5.7(17): Float Types @@ -14229,7 +14219,7 @@ is a software rather than a hardware format. @geindex multidimensional @node RM 3 6 2 11 Multidimensional Arrays,RM 9 6 30-31 Duration’Small,RM 3 5 7 17 Float Types,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-3-6-2-11-multidimensional-arrays}@anchor{236} +@anchor{gnat_rm/implementation_advice rm-3-6-2-11-multidimensional-arrays}@anchor{235} @section RM 3.6.2(11): Multidimensional Arrays @@ -14247,7 +14237,7 @@ Followed. @geindex Duration'Small @node RM 9 6 30-31 Duration’Small,RM 10 2 1 12 Consistent Representation,RM 3 6 2 11 Multidimensional Arrays,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-9-6-30-31-duration-small}@anchor{237} +@anchor{gnat_rm/implementation_advice rm-9-6-30-31-duration-small}@anchor{236} @section RM 9.6(30-31): Duration’Small @@ -14268,7 +14258,7 @@ it need not be the same time base as used for @code{Calendar.Clock}.” Followed. @node RM 10 2 1 12 Consistent Representation,RM 11 4 1 19 Exception Information,RM 9 6 30-31 Duration’Small,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-10-2-1-12-consistent-representation}@anchor{238} +@anchor{gnat_rm/implementation_advice rm-10-2-1-12-consistent-representation}@anchor{237} @section RM 10.2.1(12): Consistent Representation @@ -14290,7 +14280,7 @@ advice without severely impacting efficiency of execution. @geindex Exception information @node RM 11 4 1 19 Exception Information,RM 11 5 28 Suppression of Checks,RM 10 2 1 12 Consistent Representation,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-11-4-1-19-exception-information}@anchor{239} +@anchor{gnat_rm/implementation_advice rm-11-4-1-19-exception-information}@anchor{238} @section RM 11.4.1(19): Exception Information @@ -14321,7 +14311,7 @@ Pragma @code{Discard_Names}. @geindex suppression of @node RM 11 5 28 Suppression of Checks,RM 13 1 21-24 Representation Clauses,RM 11 4 1 19 Exception Information,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-11-5-28-suppression-of-checks}@anchor{23a} +@anchor{gnat_rm/implementation_advice rm-11-5-28-suppression-of-checks}@anchor{239} @section RM 11.5(28): Suppression of Checks @@ -14336,7 +14326,7 @@ Followed. @geindex Representation clauses @node RM 13 1 21-24 Representation Clauses,RM 13 2 6-8 Packed Types,RM 11 5 28 Suppression of Checks,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-13-1-21-24-representation-clauses}@anchor{23b} +@anchor{gnat_rm/implementation_advice rm-13-1-21-24-representation-clauses}@anchor{23a} @section RM 13.1 (21-24): Representation Clauses @@ -14385,7 +14375,7 @@ Followed. @geindex Packed types @node RM 13 2 6-8 Packed Types,RM 13 3 14-19 Address Clauses,RM 13 1 21-24 Representation Clauses,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-13-2-6-8-packed-types}@anchor{23c} +@anchor{gnat_rm/implementation_advice rm-13-2-6-8-packed-types}@anchor{23b} @section RM 13.2(6-8): Packed Types @@ -14416,7 +14406,7 @@ subcomponent of the packed type. @geindex Address clauses @node RM 13 3 14-19 Address Clauses,RM 13 3 29-35 Alignment Clauses,RM 13 2 6-8 Packed Types,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-13-3-14-19-address-clauses}@anchor{23d} +@anchor{gnat_rm/implementation_advice rm-13-3-14-19-address-clauses}@anchor{23c} @section RM 13.3(14-19): Address Clauses @@ -14469,7 +14459,7 @@ Followed. @geindex Alignment clauses @node RM 13 3 29-35 Alignment Clauses,RM 13 3 42-43 Size Clauses,RM 13 3 14-19 Address Clauses,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-13-3-29-35-alignment-clauses}@anchor{23e} +@anchor{gnat_rm/implementation_advice rm-13-3-29-35-alignment-clauses}@anchor{23d} @section RM 13.3(29-35): Alignment Clauses @@ -14526,7 +14516,7 @@ Followed. @geindex Size clauses @node RM 13 3 42-43 Size Clauses,RM 13 3 50-56 Size Clauses,RM 13 3 29-35 Alignment Clauses,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-13-3-42-43-size-clauses}@anchor{23f} +@anchor{gnat_rm/implementation_advice rm-13-3-42-43-size-clauses}@anchor{23e} @section RM 13.3(42-43): Size Clauses @@ -14544,7 +14534,7 @@ object’s @code{Alignment} (if the @code{Alignment} is nonzero).” Followed. @node RM 13 3 50-56 Size Clauses,RM 13 3 71-73 Component Size Clauses,RM 13 3 42-43 Size Clauses,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-13-3-50-56-size-clauses}@anchor{240} +@anchor{gnat_rm/implementation_advice rm-13-3-50-56-size-clauses}@anchor{23f} @section RM 13.3(50-56): Size Clauses @@ -14595,7 +14585,7 @@ Followed. @geindex Component_Size clauses @node RM 13 3 71-73 Component Size Clauses,RM 13 4 9-10 Enumeration Representation Clauses,RM 13 3 50-56 Size Clauses,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-13-3-71-73-component-size-clauses}@anchor{241} +@anchor{gnat_rm/implementation_advice rm-13-3-71-73-component-size-clauses}@anchor{240} @section RM 13.3(71-73): Component Size Clauses @@ -14629,7 +14619,7 @@ Followed. @geindex enumeration @node RM 13 4 9-10 Enumeration Representation Clauses,RM 13 5 1 17-22 Record Representation Clauses,RM 13 3 71-73 Component Size Clauses,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-13-4-9-10-enumeration-representation-clauses}@anchor{242} +@anchor{gnat_rm/implementation_advice rm-13-4-9-10-enumeration-representation-clauses}@anchor{241} @section RM 13.4(9-10): Enumeration Representation Clauses @@ -14651,7 +14641,7 @@ Followed. @geindex records @node RM 13 5 1 17-22 Record Representation Clauses,RM 13 5 2 5 Storage Place Attributes,RM 13 4 9-10 Enumeration Representation Clauses,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-13-5-1-17-22-record-representation-clauses}@anchor{243} +@anchor{gnat_rm/implementation_advice rm-13-5-1-17-22-record-representation-clauses}@anchor{242} @section RM 13.5.1(17-22): Record Representation Clauses @@ -14711,7 +14701,7 @@ and all mentioned features are implemented. @geindex Storage place attributes @node RM 13 5 2 5 Storage Place Attributes,RM 13 5 3 7-8 Bit Ordering,RM 13 5 1 17-22 Record Representation Clauses,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-13-5-2-5-storage-place-attributes}@anchor{244} +@anchor{gnat_rm/implementation_advice rm-13-5-2-5-storage-place-attributes}@anchor{243} @section RM 13.5.2(5): Storage Place Attributes @@ -14731,7 +14721,7 @@ Followed. There are no such components in GNAT. @geindex Bit ordering @node RM 13 5 3 7-8 Bit Ordering,RM 13 7 37 Address as Private,RM 13 5 2 5 Storage Place Attributes,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-13-5-3-7-8-bit-ordering}@anchor{245} +@anchor{gnat_rm/implementation_advice rm-13-5-3-7-8-bit-ordering}@anchor{244} @section RM 13.5.3(7-8): Bit Ordering @@ -14751,7 +14741,7 @@ Thus non-default bit ordering is not supported. @geindex as private type @node RM 13 7 37 Address as Private,RM 13 7 1 16 Address Operations,RM 13 5 3 7-8 Bit Ordering,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-13-7-37-address-as-private}@anchor{246} +@anchor{gnat_rm/implementation_advice rm-13-7-37-address-as-private}@anchor{245} @section RM 13.7(37): Address as Private @@ -14769,7 +14759,7 @@ Followed. @geindex operations of @node RM 13 7 1 16 Address Operations,RM 13 9 14-17 Unchecked Conversion,RM 13 7 37 Address as Private,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-13-7-1-16-address-operations}@anchor{247} +@anchor{gnat_rm/implementation_advice rm-13-7-1-16-address-operations}@anchor{246} @section RM 13.7.1(16): Address Operations @@ -14787,7 +14777,7 @@ operation raises @code{Program_Error}, since all operations make sense. @geindex Unchecked conversion @node RM 13 9 14-17 Unchecked Conversion,RM 13 11 23-25 Implicit Heap Usage,RM 13 7 1 16 Address Operations,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-13-9-14-17-unchecked-conversion}@anchor{248} +@anchor{gnat_rm/implementation_advice rm-13-9-14-17-unchecked-conversion}@anchor{247} @section RM 13.9(14-17): Unchecked Conversion @@ -14831,7 +14821,7 @@ Followed. @geindex implicit @node RM 13 11 23-25 Implicit Heap Usage,RM 13 11 2 17 Unchecked Deallocation,RM 13 9 14-17 Unchecked Conversion,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-13-11-23-25-implicit-heap-usage}@anchor{249} +@anchor{gnat_rm/implementation_advice rm-13-11-23-25-implicit-heap-usage}@anchor{248} @section RM 13.11(23-25): Implicit Heap Usage @@ -14882,7 +14872,7 @@ Followed. @geindex Unchecked deallocation @node RM 13 11 2 17 Unchecked Deallocation,RM 13 13 2 1 6 Stream Oriented Attributes,RM 13 11 23-25 Implicit Heap Usage,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-13-11-2-17-unchecked-deallocation}@anchor{24a} +@anchor{gnat_rm/implementation_advice rm-13-11-2-17-unchecked-deallocation}@anchor{249} @section RM 13.11.2(17): Unchecked Deallocation @@ -14897,7 +14887,7 @@ Followed. @geindex Stream oriented attributes @node RM 13 13 2 1 6 Stream Oriented Attributes,RM A 1 52 Names of Predefined Numeric Types,RM 13 11 2 17 Unchecked Deallocation,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-13-13-2-1-6-stream-oriented-attributes}@anchor{24b} +@anchor{gnat_rm/implementation_advice rm-13-13-2-1-6-stream-oriented-attributes}@anchor{24a} @section RM 13.13.2(1.6): Stream Oriented Attributes @@ -14928,7 +14918,7 @@ scalar types. This XDR alternative can be enabled via the binder switch -xdr. @geindex Stream oriented attributes @node RM A 1 52 Names of Predefined Numeric Types,RM A 3 2 49 Ada Characters Handling,RM 13 13 2 1 6 Stream Oriented Attributes,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-a-1-52-names-of-predefined-numeric-types}@anchor{24c} +@anchor{gnat_rm/implementation_advice rm-a-1-52-names-of-predefined-numeric-types}@anchor{24b} @section RM A.1(52): Names of Predefined Numeric Types @@ -14946,7 +14936,7 @@ Followed. @geindex Ada.Characters.Handling @node RM A 3 2 49 Ada Characters Handling,RM A 4 4 106 Bounded-Length String Handling,RM A 1 52 Names of Predefined Numeric Types,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-a-3-2-49-ada-characters-handling}@anchor{24d} +@anchor{gnat_rm/implementation_advice rm-a-3-2-49-ada-characters-handling}@anchor{24c} @section RM A.3.2(49): @code{Ada.Characters.Handling} @@ -14963,7 +14953,7 @@ Followed. GNAT provides no such localized definitions. @geindex Bounded-length strings @node RM A 4 4 106 Bounded-Length String Handling,RM A 5 2 46-47 Random Number Generation,RM A 3 2 49 Ada Characters Handling,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-a-4-4-106-bounded-length-string-handling}@anchor{24e} +@anchor{gnat_rm/implementation_advice rm-a-4-4-106-bounded-length-string-handling}@anchor{24d} @section RM A.4.4(106): Bounded-Length String Handling @@ -14978,7 +14968,7 @@ Followed. No implicit pointers or dynamic allocation are used. @geindex Random number generation @node RM A 5 2 46-47 Random Number Generation,RM A 10 7 23 Get_Immediate,RM A 4 4 106 Bounded-Length String Handling,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-a-5-2-46-47-random-number-generation}@anchor{24f} +@anchor{gnat_rm/implementation_advice rm-a-5-2-46-47-random-number-generation}@anchor{24e} @section RM A.5.2(46-47): Random Number Generation @@ -15007,7 +14997,7 @@ condition here to hold true. @geindex Get_Immediate @node RM A 10 7 23 Get_Immediate,RM A 18 Containers,RM A 5 2 46-47 Random Number Generation,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-a-10-7-23-get-immediate}@anchor{250} +@anchor{gnat_rm/implementation_advice rm-a-10-7-23-get-immediate}@anchor{24f} @section RM A.10.7(23): @code{Get_Immediate} @@ -15031,7 +15021,7 @@ this functionality. @geindex Containers @node RM A 18 Containers,RM B 1 39-41 Pragma Export,RM A 10 7 23 Get_Immediate,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-a-18-containers}@anchor{251} +@anchor{gnat_rm/implementation_advice rm-a-18-containers}@anchor{250} @section RM A.18: @code{Containers} @@ -15052,7 +15042,7 @@ follow the implementation advice. @geindex Export @node RM B 1 39-41 Pragma Export,RM B 2 12-13 Package Interfaces,RM A 18 Containers,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-b-1-39-41-pragma-export}@anchor{252} +@anchor{gnat_rm/implementation_advice rm-b-1-39-41-pragma-export}@anchor{251} @section RM B.1(39-41): Pragma @code{Export} @@ -15100,7 +15090,7 @@ Followed. @geindex Interfaces @node RM B 2 12-13 Package Interfaces,RM B 3 63-71 Interfacing with C,RM B 1 39-41 Pragma Export,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-b-2-12-13-package-interfaces}@anchor{253} +@anchor{gnat_rm/implementation_advice rm-b-2-12-13-package-interfaces}@anchor{252} @section RM B.2(12-13): Package @code{Interfaces} @@ -15130,7 +15120,7 @@ Followed. GNAT provides all the packages described in this section. @geindex interfacing with @node RM B 3 63-71 Interfacing with C,RM B 4 95-98 Interfacing with COBOL,RM B 2 12-13 Package Interfaces,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-b-3-63-71-interfacing-with-c}@anchor{254} +@anchor{gnat_rm/implementation_advice rm-b-3-63-71-interfacing-with-c}@anchor{253} @section RM B.3(63-71): Interfacing with C @@ -15218,7 +15208,7 @@ Followed. @geindex interfacing with @node RM B 4 95-98 Interfacing with COBOL,RM B 5 22-26 Interfacing with Fortran,RM B 3 63-71 Interfacing with C,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-b-4-95-98-interfacing-with-cobol}@anchor{255} +@anchor{gnat_rm/implementation_advice rm-b-4-95-98-interfacing-with-cobol}@anchor{254} @section RM B.4(95-98): Interfacing with COBOL @@ -15259,7 +15249,7 @@ Followed. @geindex interfacing with @node RM B 5 22-26 Interfacing with Fortran,RM C 1 3-5 Access to Machine Operations,RM B 4 95-98 Interfacing with COBOL,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-b-5-22-26-interfacing-with-fortran}@anchor{256} +@anchor{gnat_rm/implementation_advice rm-b-5-22-26-interfacing-with-fortran}@anchor{255} @section RM B.5(22-26): Interfacing with Fortran @@ -15310,7 +15300,7 @@ Followed. @geindex Machine operations @node RM C 1 3-5 Access to Machine Operations,RM C 1 10-16 Access to Machine Operations,RM B 5 22-26 Interfacing with Fortran,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-c-1-3-5-access-to-machine-operations}@anchor{257} +@anchor{gnat_rm/implementation_advice rm-c-1-3-5-access-to-machine-operations}@anchor{256} @section RM C.1(3-5): Access to Machine Operations @@ -15345,7 +15335,7 @@ object that is specified as exported.” Followed. @node RM C 1 10-16 Access to Machine Operations,RM C 3 28 Interrupt Support,RM C 1 3-5 Access to Machine Operations,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-c-1-10-16-access-to-machine-operations}@anchor{258} +@anchor{gnat_rm/implementation_advice rm-c-1-10-16-access-to-machine-operations}@anchor{257} @section RM C.1(10-16): Access to Machine Operations @@ -15406,7 +15396,7 @@ Followed on any target supporting such operations. @geindex Interrupt support @node RM C 3 28 Interrupt Support,RM C 3 1 20-21 Protected Procedure Handlers,RM C 1 10-16 Access to Machine Operations,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-c-3-28-interrupt-support}@anchor{259} +@anchor{gnat_rm/implementation_advice rm-c-3-28-interrupt-support}@anchor{258} @section RM C.3(28): Interrupt Support @@ -15424,7 +15414,7 @@ of interrupt blocking. @geindex Protected procedure handlers @node RM C 3 1 20-21 Protected Procedure Handlers,RM C 3 2 25 Package Interrupts,RM C 3 28 Interrupt Support,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-c-3-1-20-21-protected-procedure-handlers}@anchor{25a} +@anchor{gnat_rm/implementation_advice rm-c-3-1-20-21-protected-procedure-handlers}@anchor{259} @section RM C.3.1(20-21): Protected Procedure Handlers @@ -15450,7 +15440,7 @@ Followed. Compile time warnings are given when possible. @geindex Interrupts @node RM C 3 2 25 Package Interrupts,RM C 4 14 Pre-elaboration Requirements,RM C 3 1 20-21 Protected Procedure Handlers,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-c-3-2-25-package-interrupts}@anchor{25b} +@anchor{gnat_rm/implementation_advice rm-c-3-2-25-package-interrupts}@anchor{25a} @section RM C.3.2(25): Package @code{Interrupts} @@ -15468,7 +15458,7 @@ Followed. @geindex Pre-elaboration requirements @node RM C 4 14 Pre-elaboration Requirements,RM C 5 8 Pragma Discard_Names,RM C 3 2 25 Package Interrupts,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-c-4-14-pre-elaboration-requirements}@anchor{25c} +@anchor{gnat_rm/implementation_advice rm-c-4-14-pre-elaboration-requirements}@anchor{25b} @section RM C.4(14): Pre-elaboration Requirements @@ -15484,7 +15474,7 @@ Followed. Executable code is generated in some cases, e.g., loops to initialize large arrays. @node RM C 5 8 Pragma Discard_Names,RM C 7 2 30 The Package Task_Attributes,RM C 4 14 Pre-elaboration Requirements,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-c-5-8-pragma-discard-names}@anchor{25d} +@anchor{gnat_rm/implementation_advice rm-c-5-8-pragma-discard-names}@anchor{25c} @section RM C.5(8): Pragma @code{Discard_Names} @@ -15502,7 +15492,7 @@ Followed. @geindex Task_Attributes @node RM C 7 2 30 The Package Task_Attributes,RM D 3 17 Locking Policies,RM C 5 8 Pragma Discard_Names,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-c-7-2-30-the-package-task-attributes}@anchor{25e} +@anchor{gnat_rm/implementation_advice rm-c-7-2-30-the-package-task-attributes}@anchor{25d} @section RM C.7.2(30): The Package Task_Attributes @@ -15523,7 +15513,7 @@ Not followed. This implementation is not targeted to such a domain. @geindex Locking Policies @node RM D 3 17 Locking Policies,RM D 4 16 Entry Queuing Policies,RM C 7 2 30 The Package Task_Attributes,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-d-3-17-locking-policies}@anchor{25f} +@anchor{gnat_rm/implementation_advice rm-d-3-17-locking-policies}@anchor{25e} @section RM D.3(17): Locking Policies @@ -15540,7 +15530,7 @@ whose names (@code{Inheritance_Locking} and @geindex Entry queuing policies @node RM D 4 16 Entry Queuing Policies,RM D 6 9-10 Preemptive Abort,RM D 3 17 Locking Policies,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-d-4-16-entry-queuing-policies}@anchor{260} +@anchor{gnat_rm/implementation_advice rm-d-4-16-entry-queuing-policies}@anchor{25f} @section RM D.4(16): Entry Queuing Policies @@ -15555,7 +15545,7 @@ Followed. No such implementation-defined queuing policies exist. @geindex Preemptive abort @node RM D 6 9-10 Preemptive Abort,RM D 7 21 Tasking Restrictions,RM D 4 16 Entry Queuing Policies,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-d-6-9-10-preemptive-abort}@anchor{261} +@anchor{gnat_rm/implementation_advice rm-d-6-9-10-preemptive-abort}@anchor{260} @section RM D.6(9-10): Preemptive Abort @@ -15581,7 +15571,7 @@ Followed. @geindex Tasking restrictions @node RM D 7 21 Tasking Restrictions,RM D 8 47-49 Monotonic Time,RM D 6 9-10 Preemptive Abort,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-d-7-21-tasking-restrictions}@anchor{262} +@anchor{gnat_rm/implementation_advice rm-d-7-21-tasking-restrictions}@anchor{261} @section RM D.7(21): Tasking Restrictions @@ -15600,7 +15590,7 @@ pragma @code{Profile (Restricted)} for more details. @geindex monotonic @node RM D 8 47-49 Monotonic Time,RM E 5 28-29 Partition Communication Subsystem,RM D 7 21 Tasking Restrictions,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-d-8-47-49-monotonic-time}@anchor{263} +@anchor{gnat_rm/implementation_advice rm-d-8-47-49-monotonic-time}@anchor{262} @section RM D.8(47-49): Monotonic Time @@ -15635,7 +15625,7 @@ Followed. @geindex PCS @node RM E 5 28-29 Partition Communication Subsystem,RM F 7 COBOL Support,RM D 8 47-49 Monotonic Time,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-e-5-28-29-partition-communication-subsystem}@anchor{264} +@anchor{gnat_rm/implementation_advice rm-e-5-28-29-partition-communication-subsystem}@anchor{263} @section RM E.5(28-29): Partition Communication Subsystem @@ -15663,7 +15653,7 @@ GNAT. @geindex COBOL support @node RM F 7 COBOL Support,RM F 1 2 Decimal Radix Support,RM E 5 28-29 Partition Communication Subsystem,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-f-7-cobol-support}@anchor{265} +@anchor{gnat_rm/implementation_advice rm-f-7-cobol-support}@anchor{264} @section RM F(7): COBOL Support @@ -15683,7 +15673,7 @@ Followed. @geindex Decimal radix support @node RM F 1 2 Decimal Radix Support,RM G Numerics,RM F 7 COBOL Support,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-f-1-2-decimal-radix-support}@anchor{266} +@anchor{gnat_rm/implementation_advice rm-f-1-2-decimal-radix-support}@anchor{265} @section RM F.1(2): Decimal Radix Support @@ -15699,7 +15689,7 @@ representations. @geindex Numerics @node RM G Numerics,RM G 1 1 56-58 Complex Types,RM F 1 2 Decimal Radix Support,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-g-numerics}@anchor{267} +@anchor{gnat_rm/implementation_advice rm-g-numerics}@anchor{266} @section RM G: Numerics @@ -15719,7 +15709,7 @@ Followed. @geindex Complex types @node RM G 1 1 56-58 Complex Types,RM G 1 2 49 Complex Elementary Functions,RM G Numerics,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-g-1-1-56-58-complex-types}@anchor{268} +@anchor{gnat_rm/implementation_advice rm-g-1-1-56-58-complex-types}@anchor{267} @section RM G.1.1(56-58): Complex Types @@ -15781,7 +15771,7 @@ Followed. @geindex Complex elementary functions @node RM G 1 2 49 Complex Elementary Functions,RM G 2 4 19 Accuracy Requirements,RM G 1 1 56-58 Complex Types,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-g-1-2-49-complex-elementary-functions}@anchor{269} +@anchor{gnat_rm/implementation_advice rm-g-1-2-49-complex-elementary-functions}@anchor{268} @section RM G.1.2(49): Complex Elementary Functions @@ -15803,7 +15793,7 @@ Followed. @geindex Accuracy requirements @node RM G 2 4 19 Accuracy Requirements,RM G 2 6 15 Complex Arithmetic Accuracy,RM G 1 2 49 Complex Elementary Functions,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-g-2-4-19-accuracy-requirements}@anchor{26a} +@anchor{gnat_rm/implementation_advice rm-g-2-4-19-accuracy-requirements}@anchor{269} @section RM G.2.4(19): Accuracy Requirements @@ -15827,7 +15817,7 @@ Followed. @geindex complex arithmetic @node RM G 2 6 15 Complex Arithmetic Accuracy,RM H 6 15/2 Pragma Partition_Elaboration_Policy,RM G 2 4 19 Accuracy Requirements,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-g-2-6-15-complex-arithmetic-accuracy}@anchor{26b} +@anchor{gnat_rm/implementation_advice rm-g-2-6-15-complex-arithmetic-accuracy}@anchor{26a} @section RM G.2.6(15): Complex Arithmetic Accuracy @@ -15845,7 +15835,7 @@ Followed. @geindex Sequential elaboration policy @node RM H 6 15/2 Pragma Partition_Elaboration_Policy,,RM G 2 6 15 Complex Arithmetic Accuracy,Implementation Advice -@anchor{gnat_rm/implementation_advice rm-h-6-15-2-pragma-partition-elaboration-policy}@anchor{26c} +@anchor{gnat_rm/implementation_advice rm-h-6-15-2-pragma-partition-elaboration-policy}@anchor{26b} @section RM H.6(15/2): Pragma Partition_Elaboration_Policy @@ -15860,7 +15850,7 @@ immediately terminated.” Not followed. @node Implementation Defined Characteristics,Intrinsic Subprograms,Implementation Advice,Top -@anchor{gnat_rm/implementation_defined_characteristics doc}@anchor{26d}@anchor{gnat_rm/implementation_defined_characteristics id1}@anchor{26e}@anchor{gnat_rm/implementation_defined_characteristics implementation-defined-characteristics}@anchor{b} +@anchor{gnat_rm/implementation_defined_characteristics doc}@anchor{26c}@anchor{gnat_rm/implementation_defined_characteristics id1}@anchor{26d}@anchor{gnat_rm/implementation_defined_characteristics implementation-defined-characteristics}@anchor{b} @chapter Implementation Defined Characteristics @@ -17155,7 +17145,7 @@ When the @code{Pattern} parameter is not the null string, it is interpreted according to the syntax of regular expressions as defined in the @code{GNAT.Regexp} package. -See @ref{26f,,GNAT.Regexp (g-regexp.ads)}. +See @ref{26e,,GNAT.Regexp (g-regexp.ads)}. @itemize * @@ -18253,7 +18243,7 @@ Information on those subjects is not yet available. Execution is erroneous in that case. @node Intrinsic Subprograms,Representation Clauses and Pragmas,Implementation Defined Characteristics,Top -@anchor{gnat_rm/intrinsic_subprograms doc}@anchor{270}@anchor{gnat_rm/intrinsic_subprograms id1}@anchor{271}@anchor{gnat_rm/intrinsic_subprograms intrinsic-subprograms}@anchor{c} +@anchor{gnat_rm/intrinsic_subprograms doc}@anchor{26f}@anchor{gnat_rm/intrinsic_subprograms id1}@anchor{270}@anchor{gnat_rm/intrinsic_subprograms intrinsic-subprograms}@anchor{c} @chapter Intrinsic Subprograms @@ -18291,7 +18281,7 @@ Ada standard does not require Ada compilers to implement this feature. @end menu @node Intrinsic Operators,Compilation_ISO_Date,,Intrinsic Subprograms -@anchor{gnat_rm/intrinsic_subprograms id2}@anchor{272}@anchor{gnat_rm/intrinsic_subprograms intrinsic-operators}@anchor{273} +@anchor{gnat_rm/intrinsic_subprograms id2}@anchor{271}@anchor{gnat_rm/intrinsic_subprograms intrinsic-operators}@anchor{272} @section Intrinsic Operators @@ -18322,7 +18312,7 @@ It is also possible to specify such operators for private types, if the full views are appropriate arithmetic types. @node Compilation_ISO_Date,Compilation_Date,Intrinsic Operators,Intrinsic Subprograms -@anchor{gnat_rm/intrinsic_subprograms compilation-iso-date}@anchor{274}@anchor{gnat_rm/intrinsic_subprograms id3}@anchor{275} +@anchor{gnat_rm/intrinsic_subprograms compilation-iso-date}@anchor{273}@anchor{gnat_rm/intrinsic_subprograms id3}@anchor{274} @section Compilation_ISO_Date @@ -18336,7 +18326,7 @@ application program should simply call the function the current compilation (in local time format YYYY-MM-DD). @node Compilation_Date,Compilation_Time,Compilation_ISO_Date,Intrinsic Subprograms -@anchor{gnat_rm/intrinsic_subprograms compilation-date}@anchor{276}@anchor{gnat_rm/intrinsic_subprograms id4}@anchor{277} +@anchor{gnat_rm/intrinsic_subprograms compilation-date}@anchor{275}@anchor{gnat_rm/intrinsic_subprograms id4}@anchor{276} @section Compilation_Date @@ -18346,7 +18336,7 @@ Same as Compilation_ISO_Date, except the string is in the form MMM DD YYYY. @node Compilation_Time,Enclosing_Entity,Compilation_Date,Intrinsic Subprograms -@anchor{gnat_rm/intrinsic_subprograms compilation-time}@anchor{278}@anchor{gnat_rm/intrinsic_subprograms id5}@anchor{279} +@anchor{gnat_rm/intrinsic_subprograms compilation-time}@anchor{277}@anchor{gnat_rm/intrinsic_subprograms id5}@anchor{278} @section Compilation_Time @@ -18360,7 +18350,7 @@ application program should simply call the function the current compilation (in local time format HH:MM:SS). @node Enclosing_Entity,Exception_Information,Compilation_Time,Intrinsic Subprograms -@anchor{gnat_rm/intrinsic_subprograms enclosing-entity}@anchor{27a}@anchor{gnat_rm/intrinsic_subprograms id6}@anchor{27b} +@anchor{gnat_rm/intrinsic_subprograms enclosing-entity}@anchor{279}@anchor{gnat_rm/intrinsic_subprograms id6}@anchor{27a} @section Enclosing_Entity @@ -18374,7 +18364,7 @@ application program should simply call the function the current subprogram, package, task, entry, or protected subprogram. @node Exception_Information,Exception_Message,Enclosing_Entity,Intrinsic Subprograms -@anchor{gnat_rm/intrinsic_subprograms exception-information}@anchor{27c}@anchor{gnat_rm/intrinsic_subprograms id7}@anchor{27d} +@anchor{gnat_rm/intrinsic_subprograms exception-information}@anchor{27b}@anchor{gnat_rm/intrinsic_subprograms id7}@anchor{27c} @section Exception_Information @@ -18388,7 +18378,7 @@ so an application program should simply call the function the exception information associated with the current exception. @node Exception_Message,Exception_Name,Exception_Information,Intrinsic Subprograms -@anchor{gnat_rm/intrinsic_subprograms exception-message}@anchor{27e}@anchor{gnat_rm/intrinsic_subprograms id8}@anchor{27f} +@anchor{gnat_rm/intrinsic_subprograms exception-message}@anchor{27d}@anchor{gnat_rm/intrinsic_subprograms id8}@anchor{27e} @section Exception_Message @@ -18402,7 +18392,7 @@ so an application program should simply call the function the message associated with the current exception. @node Exception_Name,File,Exception_Message,Intrinsic Subprograms -@anchor{gnat_rm/intrinsic_subprograms exception-name}@anchor{280}@anchor{gnat_rm/intrinsic_subprograms id9}@anchor{281} +@anchor{gnat_rm/intrinsic_subprograms exception-name}@anchor{27f}@anchor{gnat_rm/intrinsic_subprograms id9}@anchor{280} @section Exception_Name @@ -18416,7 +18406,7 @@ so an application program should simply call the function the name of the current exception. @node File,Line,Exception_Name,Intrinsic Subprograms -@anchor{gnat_rm/intrinsic_subprograms file}@anchor{282}@anchor{gnat_rm/intrinsic_subprograms id10}@anchor{283} +@anchor{gnat_rm/intrinsic_subprograms file}@anchor{281}@anchor{gnat_rm/intrinsic_subprograms id10}@anchor{282} @section File @@ -18430,7 +18420,7 @@ application program should simply call the function file. @node Line,Shifts and Rotates,File,Intrinsic Subprograms -@anchor{gnat_rm/intrinsic_subprograms id11}@anchor{284}@anchor{gnat_rm/intrinsic_subprograms line}@anchor{285} +@anchor{gnat_rm/intrinsic_subprograms id11}@anchor{283}@anchor{gnat_rm/intrinsic_subprograms line}@anchor{284} @section Line @@ -18444,7 +18434,7 @@ application program should simply call the function source line. @node Shifts and Rotates,Source_Location,Line,Intrinsic Subprograms -@anchor{gnat_rm/intrinsic_subprograms id12}@anchor{286}@anchor{gnat_rm/intrinsic_subprograms shifts-and-rotates}@anchor{287} +@anchor{gnat_rm/intrinsic_subprograms id12}@anchor{285}@anchor{gnat_rm/intrinsic_subprograms shifts-and-rotates}@anchor{286} @section Shifts and Rotates @@ -18487,7 +18477,7 @@ corresponding operator for modular type. In particular, shifting a negative number may change its sign bit to positive. @node Source_Location,,Shifts and Rotates,Intrinsic Subprograms -@anchor{gnat_rm/intrinsic_subprograms id13}@anchor{288}@anchor{gnat_rm/intrinsic_subprograms source-location}@anchor{289} +@anchor{gnat_rm/intrinsic_subprograms id13}@anchor{287}@anchor{gnat_rm/intrinsic_subprograms source-location}@anchor{288} @section Source_Location @@ -18501,7 +18491,7 @@ application program should simply call the function source file location. @node Representation Clauses and Pragmas,Standard Library Routines,Intrinsic Subprograms,Top -@anchor{gnat_rm/representation_clauses_and_pragmas doc}@anchor{28a}@anchor{gnat_rm/representation_clauses_and_pragmas id1}@anchor{28b}@anchor{gnat_rm/representation_clauses_and_pragmas representation-clauses-and-pragmas}@anchor{d} +@anchor{gnat_rm/representation_clauses_and_pragmas doc}@anchor{289}@anchor{gnat_rm/representation_clauses_and_pragmas id1}@anchor{28a}@anchor{gnat_rm/representation_clauses_and_pragmas representation-clauses-and-pragmas}@anchor{d} @chapter Representation Clauses and Pragmas @@ -18547,7 +18537,7 @@ and this section describes the additional capabilities provided. @end menu @node Alignment Clauses,Size Clauses,,Representation Clauses and Pragmas -@anchor{gnat_rm/representation_clauses_and_pragmas alignment-clauses}@anchor{28c}@anchor{gnat_rm/representation_clauses_and_pragmas id2}@anchor{28d} +@anchor{gnat_rm/representation_clauses_and_pragmas alignment-clauses}@anchor{28b}@anchor{gnat_rm/representation_clauses_and_pragmas id2}@anchor{28c} @section Alignment Clauses @@ -18569,7 +18559,7 @@ For elementary types, the alignment is the minimum of the actual size of objects of the type divided by @code{Storage_Unit}, and the maximum alignment supported by the target. (This maximum alignment is given by the GNAT-specific attribute -@code{Standard'Maximum_Alignment}; see @ref{19b,,Attribute Maximum_Alignment}.) +@code{Standard'Maximum_Alignment}; see @ref{19a,,Attribute Maximum_Alignment}.) @geindex Maximum_Alignment attribute @@ -18678,7 +18668,7 @@ assumption is non-portable, and other compilers may choose different alignments for the subtype @code{RS}. @node Size Clauses,Storage_Size Clauses,Alignment Clauses,Representation Clauses and Pragmas -@anchor{gnat_rm/representation_clauses_and_pragmas id3}@anchor{28e}@anchor{gnat_rm/representation_clauses_and_pragmas size-clauses}@anchor{28f} +@anchor{gnat_rm/representation_clauses_and_pragmas id3}@anchor{28d}@anchor{gnat_rm/representation_clauses_and_pragmas size-clauses}@anchor{28e} @section Size Clauses @@ -18755,7 +18745,7 @@ if it is known that a Size value can be accommodated in an object of type Integer. @node Storage_Size Clauses,Size of Variant Record Objects,Size Clauses,Representation Clauses and Pragmas -@anchor{gnat_rm/representation_clauses_and_pragmas id4}@anchor{290}@anchor{gnat_rm/representation_clauses_and_pragmas storage-size-clauses}@anchor{291} +@anchor{gnat_rm/representation_clauses_and_pragmas id4}@anchor{28f}@anchor{gnat_rm/representation_clauses_and_pragmas storage-size-clauses}@anchor{290} @section Storage_Size Clauses @@ -18828,7 +18818,7 @@ Of course in practice, there will not be any explicit allocators in the case of such an access declaration. @node Size of Variant Record Objects,Biased Representation,Storage_Size Clauses,Representation Clauses and Pragmas -@anchor{gnat_rm/representation_clauses_and_pragmas id5}@anchor{292}@anchor{gnat_rm/representation_clauses_and_pragmas size-of-variant-record-objects}@anchor{293} +@anchor{gnat_rm/representation_clauses_and_pragmas id5}@anchor{291}@anchor{gnat_rm/representation_clauses_and_pragmas size-of-variant-record-objects}@anchor{292} @section Size of Variant Record Objects @@ -18938,7 +18928,7 @@ the maximum size, regardless of the current variant value, the variant value. @node Biased Representation,Value_Size and Object_Size Clauses,Size of Variant Record Objects,Representation Clauses and Pragmas -@anchor{gnat_rm/representation_clauses_and_pragmas biased-representation}@anchor{294}@anchor{gnat_rm/representation_clauses_and_pragmas id6}@anchor{295} +@anchor{gnat_rm/representation_clauses_and_pragmas biased-representation}@anchor{293}@anchor{gnat_rm/representation_clauses_and_pragmas id6}@anchor{294} @section Biased Representation @@ -18976,7 +18966,7 @@ biased representation can be used for all discrete types except for enumeration types for which a representation clause is given. @node Value_Size and Object_Size Clauses,Component_Size Clauses,Biased Representation,Representation Clauses and Pragmas -@anchor{gnat_rm/representation_clauses_and_pragmas id7}@anchor{296}@anchor{gnat_rm/representation_clauses_and_pragmas value-size-and-object-size-clauses}@anchor{297} +@anchor{gnat_rm/representation_clauses_and_pragmas id7}@anchor{295}@anchor{gnat_rm/representation_clauses_and_pragmas value-size-and-object-size-clauses}@anchor{296} @section Value_Size and Object_Size Clauses @@ -19292,7 +19282,7 @@ definition clause forces biased representation. This warning can be turned off using @code{-gnatw.B}. @node Component_Size Clauses,Bit_Order Clauses,Value_Size and Object_Size Clauses,Representation Clauses and Pragmas -@anchor{gnat_rm/representation_clauses_and_pragmas component-size-clauses}@anchor{298}@anchor{gnat_rm/representation_clauses_and_pragmas id8}@anchor{299} +@anchor{gnat_rm/representation_clauses_and_pragmas component-size-clauses}@anchor{297}@anchor{gnat_rm/representation_clauses_and_pragmas id8}@anchor{298} @section Component_Size Clauses @@ -19340,7 +19330,7 @@ and a pragma Pack for the same array type. if such duplicate clauses are given, the pragma Pack will be ignored. @node Bit_Order Clauses,Effect of Bit_Order on Byte Ordering,Component_Size Clauses,Representation Clauses and Pragmas -@anchor{gnat_rm/representation_clauses_and_pragmas bit-order-clauses}@anchor{29a}@anchor{gnat_rm/representation_clauses_and_pragmas id9}@anchor{29b} +@anchor{gnat_rm/representation_clauses_and_pragmas bit-order-clauses}@anchor{299}@anchor{gnat_rm/representation_clauses_and_pragmas id9}@anchor{29a} @section Bit_Order Clauses @@ -19446,7 +19436,7 @@ if desired. The following section contains additional details regarding the issue of byte ordering. @node Effect of Bit_Order on Byte Ordering,Pragma Pack for Arrays,Bit_Order Clauses,Representation Clauses and Pragmas -@anchor{gnat_rm/representation_clauses_and_pragmas effect-of-bit-order-on-byte-ordering}@anchor{29c}@anchor{gnat_rm/representation_clauses_and_pragmas id10}@anchor{29d} +@anchor{gnat_rm/representation_clauses_and_pragmas effect-of-bit-order-on-byte-ordering}@anchor{29b}@anchor{gnat_rm/representation_clauses_and_pragmas id10}@anchor{29c} @section Effect of Bit_Order on Byte Ordering @@ -19703,7 +19693,7 @@ to set the boolean constant @code{Master_Byte_First} in an appropriate manner. @node Pragma Pack for Arrays,Pragma Pack for Records,Effect of Bit_Order on Byte Ordering,Representation Clauses and Pragmas -@anchor{gnat_rm/representation_clauses_and_pragmas id11}@anchor{29e}@anchor{gnat_rm/representation_clauses_and_pragmas pragma-pack-for-arrays}@anchor{29f} +@anchor{gnat_rm/representation_clauses_and_pragmas id11}@anchor{29d}@anchor{gnat_rm/representation_clauses_and_pragmas pragma-pack-for-arrays}@anchor{29e} @section Pragma Pack for Arrays @@ -19823,7 +19813,7 @@ Here 31-bit packing is achieved as required, and no warning is generated, since in this case the programmer intention is clear. @node Pragma Pack for Records,Record Representation Clauses,Pragma Pack for Arrays,Representation Clauses and Pragmas -@anchor{gnat_rm/representation_clauses_and_pragmas id12}@anchor{2a0}@anchor{gnat_rm/representation_clauses_and_pragmas pragma-pack-for-records}@anchor{2a1} +@anchor{gnat_rm/representation_clauses_and_pragmas id12}@anchor{29f}@anchor{gnat_rm/representation_clauses_and_pragmas pragma-pack-for-records}@anchor{2a0} @section Pragma Pack for Records @@ -19907,7 +19897,7 @@ array that is longer than 64 bits, so it is itself non-packable on boundary, and takes an integral number of bytes, i.e., 72 bits. @node Record Representation Clauses,Handling of Records with Holes,Pragma Pack for Records,Representation Clauses and Pragmas -@anchor{gnat_rm/representation_clauses_and_pragmas id13}@anchor{2a2}@anchor{gnat_rm/representation_clauses_and_pragmas record-representation-clauses}@anchor{2a3} +@anchor{gnat_rm/representation_clauses_and_pragmas id13}@anchor{2a1}@anchor{gnat_rm/representation_clauses_and_pragmas record-representation-clauses}@anchor{2a2} @section Record Representation Clauses @@ -19986,7 +19976,7 @@ end record; @end example @node Handling of Records with Holes,Enumeration Clauses,Record Representation Clauses,Representation Clauses and Pragmas -@anchor{gnat_rm/representation_clauses_and_pragmas handling-of-records-with-holes}@anchor{2a4}@anchor{gnat_rm/representation_clauses_and_pragmas id14}@anchor{2a5} +@anchor{gnat_rm/representation_clauses_and_pragmas handling-of-records-with-holes}@anchor{2a3}@anchor{gnat_rm/representation_clauses_and_pragmas id14}@anchor{2a4} @section Handling of Records with Holes @@ -20062,7 +20052,7 @@ for Hrec'Size use 64; @end example @node Enumeration Clauses,Address Clauses,Handling of Records with Holes,Representation Clauses and Pragmas -@anchor{gnat_rm/representation_clauses_and_pragmas enumeration-clauses}@anchor{2a6}@anchor{gnat_rm/representation_clauses_and_pragmas id15}@anchor{2a7} +@anchor{gnat_rm/representation_clauses_and_pragmas enumeration-clauses}@anchor{2a5}@anchor{gnat_rm/representation_clauses_and_pragmas id15}@anchor{2a6} @section Enumeration Clauses @@ -20105,7 +20095,7 @@ the overhead of converting representation values to the corresponding positional values, (i.e., the value delivered by the @code{Pos} attribute). @node Address Clauses,Use of Address Clauses for Memory-Mapped I/O,Enumeration Clauses,Representation Clauses and Pragmas -@anchor{gnat_rm/representation_clauses_and_pragmas address-clauses}@anchor{2a8}@anchor{gnat_rm/representation_clauses_and_pragmas id16}@anchor{2a9} +@anchor{gnat_rm/representation_clauses_and_pragmas address-clauses}@anchor{2a7}@anchor{gnat_rm/representation_clauses_and_pragmas id16}@anchor{2a8} @section Address Clauses @@ -20445,7 +20435,7 @@ then the program compiles without the warning and when run will generate the output @code{X was not clobbered}. @node Use of Address Clauses for Memory-Mapped I/O,Effect of Convention on Representation,Address Clauses,Representation Clauses and Pragmas -@anchor{gnat_rm/representation_clauses_and_pragmas id17}@anchor{2aa}@anchor{gnat_rm/representation_clauses_and_pragmas use-of-address-clauses-for-memory-mapped-i-o}@anchor{2ab} +@anchor{gnat_rm/representation_clauses_and_pragmas id17}@anchor{2a9}@anchor{gnat_rm/representation_clauses_and_pragmas use-of-address-clauses-for-memory-mapped-i-o}@anchor{2aa} @section Use of Address Clauses for Memory-Mapped I/O @@ -20503,7 +20493,7 @@ provides the pragma @code{Volatile_Full_Access} which can be used in lieu of pragma @code{Atomic} and will give the additional guarantee. @node Effect of Convention on Representation,Conventions and Anonymous Access Types,Use of Address Clauses for Memory-Mapped I/O,Representation Clauses and Pragmas -@anchor{gnat_rm/representation_clauses_and_pragmas effect-of-convention-on-representation}@anchor{2ac}@anchor{gnat_rm/representation_clauses_and_pragmas id18}@anchor{2ad} +@anchor{gnat_rm/representation_clauses_and_pragmas effect-of-convention-on-representation}@anchor{2ab}@anchor{gnat_rm/representation_clauses_and_pragmas id18}@anchor{2ac} @section Effect of Convention on Representation @@ -20581,7 +20571,7 @@ when one of these values is read, any nonzero value is treated as True. @end itemize @node Conventions and Anonymous Access Types,Determining the Representations chosen by GNAT,Effect of Convention on Representation,Representation Clauses and Pragmas -@anchor{gnat_rm/representation_clauses_and_pragmas conventions-and-anonymous-access-types}@anchor{2ae}@anchor{gnat_rm/representation_clauses_and_pragmas id19}@anchor{2af} +@anchor{gnat_rm/representation_clauses_and_pragmas conventions-and-anonymous-access-types}@anchor{2ad}@anchor{gnat_rm/representation_clauses_and_pragmas id19}@anchor{2ae} @section Conventions and Anonymous Access Types @@ -20657,7 +20647,7 @@ package ConvComp is @end example @node Determining the Representations chosen by GNAT,,Conventions and Anonymous Access Types,Representation Clauses and Pragmas -@anchor{gnat_rm/representation_clauses_and_pragmas determining-the-representations-chosen-by-gnat}@anchor{2b0}@anchor{gnat_rm/representation_clauses_and_pragmas id20}@anchor{2b1} +@anchor{gnat_rm/representation_clauses_and_pragmas determining-the-representations-chosen-by-gnat}@anchor{2af}@anchor{gnat_rm/representation_clauses_and_pragmas id20}@anchor{2b0} @section Determining the Representations chosen by GNAT @@ -20809,7 +20799,7 @@ generated by the compiler into the original source to fix and guarantee the actual representation to be used. @node Standard Library Routines,The Implementation of Standard I/O,Representation Clauses and Pragmas,Top -@anchor{gnat_rm/standard_library_routines doc}@anchor{2b2}@anchor{gnat_rm/standard_library_routines id1}@anchor{2b3}@anchor{gnat_rm/standard_library_routines standard-library-routines}@anchor{e} +@anchor{gnat_rm/standard_library_routines doc}@anchor{2b1}@anchor{gnat_rm/standard_library_routines id1}@anchor{2b2}@anchor{gnat_rm/standard_library_routines standard-library-routines}@anchor{e} @chapter Standard Library Routines @@ -21633,7 +21623,7 @@ For packages in Interfaces and System, all the RM defined packages are available in GNAT, see the Ada 2012 RM for full details. @node The Implementation of Standard I/O,The GNAT Library,Standard Library Routines,Top -@anchor{gnat_rm/the_implementation_of_standard_i_o doc}@anchor{2b4}@anchor{gnat_rm/the_implementation_of_standard_i_o id1}@anchor{2b5}@anchor{gnat_rm/the_implementation_of_standard_i_o the-implementation-of-standard-i-o}@anchor{f} +@anchor{gnat_rm/the_implementation_of_standard_i_o doc}@anchor{2b3}@anchor{gnat_rm/the_implementation_of_standard_i_o id1}@anchor{2b4}@anchor{gnat_rm/the_implementation_of_standard_i_o the-implementation-of-standard-i-o}@anchor{f} @chapter The Implementation of Standard I/O @@ -21685,7 +21675,7 @@ these additional facilities are also described in this chapter. @end menu @node Standard I/O Packages,FORM Strings,,The Implementation of Standard I/O -@anchor{gnat_rm/the_implementation_of_standard_i_o id2}@anchor{2b6}@anchor{gnat_rm/the_implementation_of_standard_i_o standard-i-o-packages}@anchor{2b7} +@anchor{gnat_rm/the_implementation_of_standard_i_o id2}@anchor{2b5}@anchor{gnat_rm/the_implementation_of_standard_i_o standard-i-o-packages}@anchor{2b6} @section Standard I/O Packages @@ -21756,7 +21746,7 @@ flush the common I/O streams and in particular Standard_Output before elaborating the Ada code. @node FORM Strings,Direct_IO,Standard I/O Packages,The Implementation of Standard I/O -@anchor{gnat_rm/the_implementation_of_standard_i_o form-strings}@anchor{2b8}@anchor{gnat_rm/the_implementation_of_standard_i_o id3}@anchor{2b9} +@anchor{gnat_rm/the_implementation_of_standard_i_o form-strings}@anchor{2b7}@anchor{gnat_rm/the_implementation_of_standard_i_o id3}@anchor{2b8} @section FORM Strings @@ -21782,7 +21772,7 @@ unrecognized keyword appears in a form string, it is silently ignored and not considered invalid. @node Direct_IO,Sequential_IO,FORM Strings,The Implementation of Standard I/O -@anchor{gnat_rm/the_implementation_of_standard_i_o direct-io}@anchor{2ba}@anchor{gnat_rm/the_implementation_of_standard_i_o id4}@anchor{2bb} +@anchor{gnat_rm/the_implementation_of_standard_i_o direct-io}@anchor{2b9}@anchor{gnat_rm/the_implementation_of_standard_i_o id4}@anchor{2ba} @section Direct_IO @@ -21801,7 +21791,7 @@ There is no limit on the size of Direct_IO files, they are expanded as necessary to accommodate whatever records are written to the file. @node Sequential_IO,Text_IO,Direct_IO,The Implementation of Standard I/O -@anchor{gnat_rm/the_implementation_of_standard_i_o id5}@anchor{2bc}@anchor{gnat_rm/the_implementation_of_standard_i_o sequential-io}@anchor{2bd} +@anchor{gnat_rm/the_implementation_of_standard_i_o id5}@anchor{2bb}@anchor{gnat_rm/the_implementation_of_standard_i_o sequential-io}@anchor{2bc} @section Sequential_IO @@ -21848,7 +21838,7 @@ using Stream_IO, and this is the preferred mechanism. In particular, the above program fragment rewritten to use Stream_IO will work correctly. @node Text_IO,Wide_Text_IO,Sequential_IO,The Implementation of Standard I/O -@anchor{gnat_rm/the_implementation_of_standard_i_o id6}@anchor{2be}@anchor{gnat_rm/the_implementation_of_standard_i_o text-io}@anchor{2bf} +@anchor{gnat_rm/the_implementation_of_standard_i_o id6}@anchor{2bd}@anchor{gnat_rm/the_implementation_of_standard_i_o text-io}@anchor{2be} @section Text_IO @@ -21931,7 +21921,7 @@ the file. @end menu @node Stream Pointer Positioning,Reading and Writing Non-Regular Files,,Text_IO -@anchor{gnat_rm/the_implementation_of_standard_i_o id7}@anchor{2c0}@anchor{gnat_rm/the_implementation_of_standard_i_o stream-pointer-positioning}@anchor{2c1} +@anchor{gnat_rm/the_implementation_of_standard_i_o id7}@anchor{2bf}@anchor{gnat_rm/the_implementation_of_standard_i_o stream-pointer-positioning}@anchor{2c0} @subsection Stream Pointer Positioning @@ -21967,7 +21957,7 @@ between two Ada files, then the difference may be observable in some situations. @node Reading and Writing Non-Regular Files,Get_Immediate,Stream Pointer Positioning,Text_IO -@anchor{gnat_rm/the_implementation_of_standard_i_o id8}@anchor{2c2}@anchor{gnat_rm/the_implementation_of_standard_i_o reading-and-writing-non-regular-files}@anchor{2c3} +@anchor{gnat_rm/the_implementation_of_standard_i_o id8}@anchor{2c1}@anchor{gnat_rm/the_implementation_of_standard_i_o reading-and-writing-non-regular-files}@anchor{2c2} @subsection Reading and Writing Non-Regular Files @@ -22018,7 +22008,7 @@ to read data past that end of file indication, until another end of file indication is entered. @node Get_Immediate,Treating Text_IO Files as Streams,Reading and Writing Non-Regular Files,Text_IO -@anchor{gnat_rm/the_implementation_of_standard_i_o get-immediate}@anchor{2c4}@anchor{gnat_rm/the_implementation_of_standard_i_o id9}@anchor{2c5} +@anchor{gnat_rm/the_implementation_of_standard_i_o get-immediate}@anchor{2c3}@anchor{gnat_rm/the_implementation_of_standard_i_o id9}@anchor{2c4} @subsection Get_Immediate @@ -22036,7 +22026,7 @@ possible), it is undefined whether the FF character will be treated as a page mark. @node Treating Text_IO Files as Streams,Text_IO Extensions,Get_Immediate,Text_IO -@anchor{gnat_rm/the_implementation_of_standard_i_o id10}@anchor{2c6}@anchor{gnat_rm/the_implementation_of_standard_i_o treating-text-io-files-as-streams}@anchor{2c7} +@anchor{gnat_rm/the_implementation_of_standard_i_o id10}@anchor{2c5}@anchor{gnat_rm/the_implementation_of_standard_i_o treating-text-io-files-as-streams}@anchor{2c6} @subsection Treating Text_IO Files as Streams @@ -22052,7 +22042,7 @@ skipped and the effect is similar to that described above for @code{Get_Immediate}. @node Text_IO Extensions,Text_IO Facilities for Unbounded Strings,Treating Text_IO Files as Streams,Text_IO -@anchor{gnat_rm/the_implementation_of_standard_i_o id11}@anchor{2c8}@anchor{gnat_rm/the_implementation_of_standard_i_o text-io-extensions}@anchor{2c9} +@anchor{gnat_rm/the_implementation_of_standard_i_o id11}@anchor{2c7}@anchor{gnat_rm/the_implementation_of_standard_i_o text-io-extensions}@anchor{2c8} @subsection Text_IO Extensions @@ -22080,7 +22070,7 @@ the string is to be read. @end itemize @node Text_IO Facilities for Unbounded Strings,,Text_IO Extensions,Text_IO -@anchor{gnat_rm/the_implementation_of_standard_i_o id12}@anchor{2ca}@anchor{gnat_rm/the_implementation_of_standard_i_o text-io-facilities-for-unbounded-strings}@anchor{2cb} +@anchor{gnat_rm/the_implementation_of_standard_i_o id12}@anchor{2c9}@anchor{gnat_rm/the_implementation_of_standard_i_o text-io-facilities-for-unbounded-strings}@anchor{2ca} @subsection Text_IO Facilities for Unbounded Strings @@ -22128,7 +22118,7 @@ files @code{a-szuzti.ads} and @code{a-szuzti.adb} provides similar extended @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings. @node Wide_Text_IO,Wide_Wide_Text_IO,Text_IO,The Implementation of Standard I/O -@anchor{gnat_rm/the_implementation_of_standard_i_o id13}@anchor{2cc}@anchor{gnat_rm/the_implementation_of_standard_i_o wide-text-io}@anchor{2cd} +@anchor{gnat_rm/the_implementation_of_standard_i_o id13}@anchor{2cb}@anchor{gnat_rm/the_implementation_of_standard_i_o wide-text-io}@anchor{2cc} @section Wide_Text_IO @@ -22375,12 +22365,12 @@ input also causes Constraint_Error to be raised. @end menu @node Stream Pointer Positioning<2>,Reading and Writing Non-Regular Files<2>,,Wide_Text_IO -@anchor{gnat_rm/the_implementation_of_standard_i_o id14}@anchor{2ce}@anchor{gnat_rm/the_implementation_of_standard_i_o stream-pointer-positioning-1}@anchor{2cf} +@anchor{gnat_rm/the_implementation_of_standard_i_o id14}@anchor{2cd}@anchor{gnat_rm/the_implementation_of_standard_i_o stream-pointer-positioning-1}@anchor{2ce} @subsection Stream Pointer Positioning @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling -of stream pointer positioning (@ref{2bf,,Text_IO}). There is one additional +of stream pointer positioning (@ref{2be,,Text_IO}). There is one additional case: If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the @@ -22399,7 +22389,7 @@ to a normal program using @code{Wide_Text_IO}. However, this discrepancy can be observed if the wide text file shares a stream with another file. @node Reading and Writing Non-Regular Files<2>,,Stream Pointer Positioning<2>,Wide_Text_IO -@anchor{gnat_rm/the_implementation_of_standard_i_o id15}@anchor{2d0}@anchor{gnat_rm/the_implementation_of_standard_i_o reading-and-writing-non-regular-files-1}@anchor{2d1} +@anchor{gnat_rm/the_implementation_of_standard_i_o id15}@anchor{2cf}@anchor{gnat_rm/the_implementation_of_standard_i_o reading-and-writing-non-regular-files-1}@anchor{2d0} @subsection Reading and Writing Non-Regular Files @@ -22410,7 +22400,7 @@ treated as data characters), and @code{End_Of_Page} always returns it is possible to read beyond an end of file. @node Wide_Wide_Text_IO,Stream_IO,Wide_Text_IO,The Implementation of Standard I/O -@anchor{gnat_rm/the_implementation_of_standard_i_o id16}@anchor{2d2}@anchor{gnat_rm/the_implementation_of_standard_i_o wide-wide-text-io}@anchor{2d3} +@anchor{gnat_rm/the_implementation_of_standard_i_o id16}@anchor{2d1}@anchor{gnat_rm/the_implementation_of_standard_i_o wide-wide-text-io}@anchor{2d2} @section Wide_Wide_Text_IO @@ -22579,12 +22569,12 @@ input also causes Constraint_Error to be raised. @end menu @node Stream Pointer Positioning<3>,Reading and Writing Non-Regular Files<3>,,Wide_Wide_Text_IO -@anchor{gnat_rm/the_implementation_of_standard_i_o id17}@anchor{2d4}@anchor{gnat_rm/the_implementation_of_standard_i_o stream-pointer-positioning-2}@anchor{2d5} +@anchor{gnat_rm/the_implementation_of_standard_i_o id17}@anchor{2d3}@anchor{gnat_rm/the_implementation_of_standard_i_o stream-pointer-positioning-2}@anchor{2d4} @subsection Stream Pointer Positioning @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling -of stream pointer positioning (@ref{2bf,,Text_IO}). There is one additional +of stream pointer positioning (@ref{2be,,Text_IO}). There is one additional case: If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the @@ -22603,7 +22593,7 @@ to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy can be observed if the wide text file shares a stream with another file. @node Reading and Writing Non-Regular Files<3>,,Stream Pointer Positioning<3>,Wide_Wide_Text_IO -@anchor{gnat_rm/the_implementation_of_standard_i_o id18}@anchor{2d6}@anchor{gnat_rm/the_implementation_of_standard_i_o reading-and-writing-non-regular-files-2}@anchor{2d7} +@anchor{gnat_rm/the_implementation_of_standard_i_o id18}@anchor{2d5}@anchor{gnat_rm/the_implementation_of_standard_i_o reading-and-writing-non-regular-files-2}@anchor{2d6} @subsection Reading and Writing Non-Regular Files @@ -22614,7 +22604,7 @@ treated as data characters), and @code{End_Of_Page} always returns it is possible to read beyond an end of file. @node Stream_IO,Text Translation,Wide_Wide_Text_IO,The Implementation of Standard I/O -@anchor{gnat_rm/the_implementation_of_standard_i_o id19}@anchor{2d8}@anchor{gnat_rm/the_implementation_of_standard_i_o stream-io}@anchor{2d9} +@anchor{gnat_rm/the_implementation_of_standard_i_o id19}@anchor{2d7}@anchor{gnat_rm/the_implementation_of_standard_i_o stream-io}@anchor{2d8} @section Stream_IO @@ -22636,7 +22626,7 @@ manner described for stream attributes. @end itemize @node Text Translation,Shared Files,Stream_IO,The Implementation of Standard I/O -@anchor{gnat_rm/the_implementation_of_standard_i_o id20}@anchor{2da}@anchor{gnat_rm/the_implementation_of_standard_i_o text-translation}@anchor{2db} +@anchor{gnat_rm/the_implementation_of_standard_i_o id20}@anchor{2d9}@anchor{gnat_rm/the_implementation_of_standard_i_o text-translation}@anchor{2da} @section Text Translation @@ -22670,7 +22660,7 @@ mode. (corresponds to_O_U16TEXT). @end itemize @node Shared Files,Filenames encoding,Text Translation,The Implementation of Standard I/O -@anchor{gnat_rm/the_implementation_of_standard_i_o id21}@anchor{2dc}@anchor{gnat_rm/the_implementation_of_standard_i_o shared-files}@anchor{2dd} +@anchor{gnat_rm/the_implementation_of_standard_i_o id21}@anchor{2db}@anchor{gnat_rm/the_implementation_of_standard_i_o shared-files}@anchor{2dc} @section Shared Files @@ -22733,7 +22723,7 @@ heterogeneous input-output. Although this approach will work in GNAT if for this purpose (using the stream attributes) @node Filenames encoding,File content encoding,Shared Files,The Implementation of Standard I/O -@anchor{gnat_rm/the_implementation_of_standard_i_o filenames-encoding}@anchor{2de}@anchor{gnat_rm/the_implementation_of_standard_i_o id22}@anchor{2df} +@anchor{gnat_rm/the_implementation_of_standard_i_o filenames-encoding}@anchor{2dd}@anchor{gnat_rm/the_implementation_of_standard_i_o id22}@anchor{2de} @section Filenames encoding @@ -22773,7 +22763,7 @@ platform. On the other Operating Systems the run-time is supporting UTF-8 natively. @node File content encoding,Open Modes,Filenames encoding,The Implementation of Standard I/O -@anchor{gnat_rm/the_implementation_of_standard_i_o file-content-encoding}@anchor{2e0}@anchor{gnat_rm/the_implementation_of_standard_i_o id23}@anchor{2e1} +@anchor{gnat_rm/the_implementation_of_standard_i_o file-content-encoding}@anchor{2df}@anchor{gnat_rm/the_implementation_of_standard_i_o id23}@anchor{2e0} @section File content encoding @@ -22806,7 +22796,7 @@ Unicode 8-bit encoding This encoding is only supported on the Windows platform. @node Open Modes,Operations on C Streams,File content encoding,The Implementation of Standard I/O -@anchor{gnat_rm/the_implementation_of_standard_i_o id24}@anchor{2e2}@anchor{gnat_rm/the_implementation_of_standard_i_o open-modes}@anchor{2e3} +@anchor{gnat_rm/the_implementation_of_standard_i_o id24}@anchor{2e1}@anchor{gnat_rm/the_implementation_of_standard_i_o open-modes}@anchor{2e2} @section Open Modes @@ -22909,7 +22899,7 @@ subsequently requires switching from reading to writing or vice-versa, then the file is reopened in @code{r+} mode to permit the required operation. @node Operations on C Streams,Interfacing to C Streams,Open Modes,The Implementation of Standard I/O -@anchor{gnat_rm/the_implementation_of_standard_i_o id25}@anchor{2e4}@anchor{gnat_rm/the_implementation_of_standard_i_o operations-on-c-streams}@anchor{2e5} +@anchor{gnat_rm/the_implementation_of_standard_i_o id25}@anchor{2e3}@anchor{gnat_rm/the_implementation_of_standard_i_o operations-on-c-streams}@anchor{2e4} @section Operations on C Streams @@ -23069,7 +23059,7 @@ end Interfaces.C_Streams; @end example @node Interfacing to C Streams,,Operations on C Streams,The Implementation of Standard I/O -@anchor{gnat_rm/the_implementation_of_standard_i_o id26}@anchor{2e6}@anchor{gnat_rm/the_implementation_of_standard_i_o interfacing-to-c-streams}@anchor{2e7} +@anchor{gnat_rm/the_implementation_of_standard_i_o id26}@anchor{2e5}@anchor{gnat_rm/the_implementation_of_standard_i_o interfacing-to-c-streams}@anchor{2e6} @section Interfacing to C Streams @@ -23162,7 +23152,7 @@ imported from a C program, allowing an Ada file to operate on an existing C file. @node The GNAT Library,Interfacing to Other Languages,The Implementation of Standard I/O,Top -@anchor{gnat_rm/the_gnat_library doc}@anchor{2e8}@anchor{gnat_rm/the_gnat_library id1}@anchor{2e9}@anchor{gnat_rm/the_gnat_library the-gnat-library}@anchor{10} +@anchor{gnat_rm/the_gnat_library doc}@anchor{2e7}@anchor{gnat_rm/the_gnat_library id1}@anchor{2e8}@anchor{gnat_rm/the_gnat_library the-gnat-library}@anchor{10} @chapter The GNAT Library @@ -23347,7 +23337,7 @@ of GNAT, and will generate a warning message. @end menu @node Ada Characters Latin_9 a-chlat9 ads,Ada Characters Wide_Latin_1 a-cwila1 ads,,The GNAT Library -@anchor{gnat_rm/the_gnat_library ada-characters-latin-9-a-chlat9-ads}@anchor{2ea}@anchor{gnat_rm/the_gnat_library id2}@anchor{2eb} +@anchor{gnat_rm/the_gnat_library ada-characters-latin-9-a-chlat9-ads}@anchor{2e9}@anchor{gnat_rm/the_gnat_library id2}@anchor{2ea} @section @code{Ada.Characters.Latin_9} (@code{a-chlat9.ads}) @@ -23364,7 +23354,7 @@ is specifically authorized by the Ada Reference Manual (RM A.3.3(27)). @node Ada Characters Wide_Latin_1 a-cwila1 ads,Ada Characters Wide_Latin_9 a-cwila9 ads,Ada Characters Latin_9 a-chlat9 ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library ada-characters-wide-latin-1-a-cwila1-ads}@anchor{2ec}@anchor{gnat_rm/the_gnat_library id3}@anchor{2ed} +@anchor{gnat_rm/the_gnat_library ada-characters-wide-latin-1-a-cwila1-ads}@anchor{2eb}@anchor{gnat_rm/the_gnat_library id3}@anchor{2ec} @section @code{Ada.Characters.Wide_Latin_1} (@code{a-cwila1.ads}) @@ -23381,7 +23371,7 @@ is specifically authorized by the Ada Reference Manual (RM A.3.3(27)). @node Ada Characters Wide_Latin_9 a-cwila9 ads,Ada Characters Wide_Wide_Latin_1 a-chzla1 ads,Ada Characters Wide_Latin_1 a-cwila1 ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library ada-characters-wide-latin-9-a-cwila9-ads}@anchor{2ee}@anchor{gnat_rm/the_gnat_library id4}@anchor{2ef} +@anchor{gnat_rm/the_gnat_library ada-characters-wide-latin-9-a-cwila9-ads}@anchor{2ed}@anchor{gnat_rm/the_gnat_library id4}@anchor{2ee} @section @code{Ada.Characters.Wide_Latin_9} (@code{a-cwila9.ads}) @@ -23398,7 +23388,7 @@ is specifically authorized by the Ada Reference Manual (RM A.3.3(27)). @node Ada Characters Wide_Wide_Latin_1 a-chzla1 ads,Ada Characters Wide_Wide_Latin_9 a-chzla9 ads,Ada Characters Wide_Latin_9 a-cwila9 ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library ada-characters-wide-wide-latin-1-a-chzla1-ads}@anchor{2f0}@anchor{gnat_rm/the_gnat_library id5}@anchor{2f1} +@anchor{gnat_rm/the_gnat_library ada-characters-wide-wide-latin-1-a-chzla1-ads}@anchor{2ef}@anchor{gnat_rm/the_gnat_library id5}@anchor{2f0} @section @code{Ada.Characters.Wide_Wide_Latin_1} (@code{a-chzla1.ads}) @@ -23415,7 +23405,7 @@ is specifically authorized by the Ada Reference Manual (RM A.3.3(27)). @node Ada Characters Wide_Wide_Latin_9 a-chzla9 ads,Ada Containers Bounded_Holders a-coboho ads,Ada Characters Wide_Wide_Latin_1 a-chzla1 ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library ada-characters-wide-wide-latin-9-a-chzla9-ads}@anchor{2f2}@anchor{gnat_rm/the_gnat_library id6}@anchor{2f3} +@anchor{gnat_rm/the_gnat_library ada-characters-wide-wide-latin-9-a-chzla9-ads}@anchor{2f1}@anchor{gnat_rm/the_gnat_library id6}@anchor{2f2} @section @code{Ada.Characters.Wide_Wide_Latin_9} (@code{a-chzla9.ads}) @@ -23432,7 +23422,7 @@ is specifically authorized by the Ada Reference Manual (RM A.3.3(27)). @node Ada Containers Bounded_Holders a-coboho ads,Ada Command_Line Environment a-colien ads,Ada Characters Wide_Wide_Latin_9 a-chzla9 ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library ada-containers-bounded-holders-a-coboho-ads}@anchor{2f4}@anchor{gnat_rm/the_gnat_library id7}@anchor{2f5} +@anchor{gnat_rm/the_gnat_library ada-containers-bounded-holders-a-coboho-ads}@anchor{2f3}@anchor{gnat_rm/the_gnat_library id7}@anchor{2f4} @section @code{Ada.Containers.Bounded_Holders} (@code{a-coboho.ads}) @@ -23444,7 +23434,7 @@ This child of @code{Ada.Containers} defines a modified version of Indefinite_Holders that avoids heap allocation. @node Ada Command_Line Environment a-colien ads,Ada Command_Line Remove a-colire ads,Ada Containers Bounded_Holders a-coboho ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library ada-command-line-environment-a-colien-ads}@anchor{2f6}@anchor{gnat_rm/the_gnat_library id8}@anchor{2f7} +@anchor{gnat_rm/the_gnat_library ada-command-line-environment-a-colien-ads}@anchor{2f5}@anchor{gnat_rm/the_gnat_library id8}@anchor{2f6} @section @code{Ada.Command_Line.Environment} (@code{a-colien.ads}) @@ -23457,7 +23447,7 @@ provides a mechanism for obtaining environment values on systems where this concept makes sense. @node Ada Command_Line Remove a-colire ads,Ada Command_Line Response_File a-clrefi ads,Ada Command_Line Environment a-colien ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library ada-command-line-remove-a-colire-ads}@anchor{2f8}@anchor{gnat_rm/the_gnat_library id9}@anchor{2f9} +@anchor{gnat_rm/the_gnat_library ada-command-line-remove-a-colire-ads}@anchor{2f7}@anchor{gnat_rm/the_gnat_library id9}@anchor{2f8} @section @code{Ada.Command_Line.Remove} (@code{a-colire.ads}) @@ -23475,7 +23465,7 @@ to further calls to the subprograms in @code{Ada.Command_Line}. These calls will not see the removed argument. @node Ada Command_Line Response_File a-clrefi ads,Ada Direct_IO C_Streams a-diocst ads,Ada Command_Line Remove a-colire ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library ada-command-line-response-file-a-clrefi-ads}@anchor{2fa}@anchor{gnat_rm/the_gnat_library id10}@anchor{2fb} +@anchor{gnat_rm/the_gnat_library ada-command-line-response-file-a-clrefi-ads}@anchor{2f9}@anchor{gnat_rm/the_gnat_library id10}@anchor{2fa} @section @code{Ada.Command_Line.Response_File} (@code{a-clrefi.ads}) @@ -23495,7 +23485,7 @@ Using a response file allow passing a set of arguments to an executable longer than the maximum allowed by the system on the command line. @node Ada Direct_IO C_Streams a-diocst ads,Ada Exceptions Is_Null_Occurrence a-einuoc ads,Ada Command_Line Response_File a-clrefi ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library ada-direct-io-c-streams-a-diocst-ads}@anchor{2fc}@anchor{gnat_rm/the_gnat_library id11}@anchor{2fd} +@anchor{gnat_rm/the_gnat_library ada-direct-io-c-streams-a-diocst-ads}@anchor{2fb}@anchor{gnat_rm/the_gnat_library id11}@anchor{2fc} @section @code{Ada.Direct_IO.C_Streams} (@code{a-diocst.ads}) @@ -23510,7 +23500,7 @@ extracted from a file opened on the Ada side, and an Ada file can be constructed from a stream opened on the C side. @node Ada Exceptions Is_Null_Occurrence a-einuoc ads,Ada Exceptions Last_Chance_Handler a-elchha ads,Ada Direct_IO C_Streams a-diocst ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library ada-exceptions-is-null-occurrence-a-einuoc-ads}@anchor{2fe}@anchor{gnat_rm/the_gnat_library id12}@anchor{2ff} +@anchor{gnat_rm/the_gnat_library ada-exceptions-is-null-occurrence-a-einuoc-ads}@anchor{2fd}@anchor{gnat_rm/the_gnat_library id12}@anchor{2fe} @section @code{Ada.Exceptions.Is_Null_Occurrence} (@code{a-einuoc.ads}) @@ -23524,7 +23514,7 @@ exception occurrence (@code{Null_Occurrence}) without raising an exception. @node Ada Exceptions Last_Chance_Handler a-elchha ads,Ada Exceptions Traceback a-exctra ads,Ada Exceptions Is_Null_Occurrence a-einuoc ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library ada-exceptions-last-chance-handler-a-elchha-ads}@anchor{300}@anchor{gnat_rm/the_gnat_library id13}@anchor{301} +@anchor{gnat_rm/the_gnat_library ada-exceptions-last-chance-handler-a-elchha-ads}@anchor{2ff}@anchor{gnat_rm/the_gnat_library id13}@anchor{300} @section @code{Ada.Exceptions.Last_Chance_Handler} (@code{a-elchha.ads}) @@ -23538,7 +23528,7 @@ exceptions (hence the name last chance), and perform clean ups before terminating the program. Note that this subprogram never returns. @node Ada Exceptions Traceback a-exctra ads,Ada Sequential_IO C_Streams a-siocst ads,Ada Exceptions Last_Chance_Handler a-elchha ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library ada-exceptions-traceback-a-exctra-ads}@anchor{302}@anchor{gnat_rm/the_gnat_library id14}@anchor{303} +@anchor{gnat_rm/the_gnat_library ada-exceptions-traceback-a-exctra-ads}@anchor{301}@anchor{gnat_rm/the_gnat_library id14}@anchor{302} @section @code{Ada.Exceptions.Traceback} (@code{a-exctra.ads}) @@ -23551,7 +23541,7 @@ give a traceback array of addresses based on an exception occurrence. @node Ada Sequential_IO C_Streams a-siocst ads,Ada Streams Stream_IO C_Streams a-ssicst ads,Ada Exceptions Traceback a-exctra ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library ada-sequential-io-c-streams-a-siocst-ads}@anchor{304}@anchor{gnat_rm/the_gnat_library id15}@anchor{305} +@anchor{gnat_rm/the_gnat_library ada-sequential-io-c-streams-a-siocst-ads}@anchor{303}@anchor{gnat_rm/the_gnat_library id15}@anchor{304} @section @code{Ada.Sequential_IO.C_Streams} (@code{a-siocst.ads}) @@ -23566,7 +23556,7 @@ extracted from a file opened on the Ada side, and an Ada file can be constructed from a stream opened on the C side. @node Ada Streams Stream_IO C_Streams a-ssicst ads,Ada Strings Unbounded Text_IO a-suteio ads,Ada Sequential_IO C_Streams a-siocst ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library ada-streams-stream-io-c-streams-a-ssicst-ads}@anchor{306}@anchor{gnat_rm/the_gnat_library id16}@anchor{307} +@anchor{gnat_rm/the_gnat_library ada-streams-stream-io-c-streams-a-ssicst-ads}@anchor{305}@anchor{gnat_rm/the_gnat_library id16}@anchor{306} @section @code{Ada.Streams.Stream_IO.C_Streams} (@code{a-ssicst.ads}) @@ -23581,7 +23571,7 @@ extracted from a file opened on the Ada side, and an Ada file can be constructed from a stream opened on the C side. @node Ada Strings Unbounded Text_IO a-suteio ads,Ada Strings Wide_Unbounded Wide_Text_IO a-swuwti ads,Ada Streams Stream_IO C_Streams a-ssicst ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library ada-strings-unbounded-text-io-a-suteio-ads}@anchor{308}@anchor{gnat_rm/the_gnat_library id17}@anchor{309} +@anchor{gnat_rm/the_gnat_library ada-strings-unbounded-text-io-a-suteio-ads}@anchor{307}@anchor{gnat_rm/the_gnat_library id17}@anchor{308} @section @code{Ada.Strings.Unbounded.Text_IO} (@code{a-suteio.ads}) @@ -23598,7 +23588,7 @@ strings, avoiding the necessity for an intermediate operation with ordinary strings. @node Ada Strings Wide_Unbounded Wide_Text_IO a-swuwti ads,Ada Strings Wide_Wide_Unbounded Wide_Wide_Text_IO a-szuzti ads,Ada Strings Unbounded Text_IO a-suteio ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library ada-strings-wide-unbounded-wide-text-io-a-swuwti-ads}@anchor{30a}@anchor{gnat_rm/the_gnat_library id18}@anchor{30b} +@anchor{gnat_rm/the_gnat_library ada-strings-wide-unbounded-wide-text-io-a-swuwti-ads}@anchor{309}@anchor{gnat_rm/the_gnat_library id18}@anchor{30a} @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@code{a-swuwti.ads}) @@ -23615,7 +23605,7 @@ wide strings, avoiding the necessity for an intermediate operation with ordinary wide strings. @node Ada Strings Wide_Wide_Unbounded Wide_Wide_Text_IO a-szuzti ads,Ada Task_Initialization a-tasini ads,Ada Strings Wide_Unbounded Wide_Text_IO a-swuwti ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library ada-strings-wide-wide-unbounded-wide-wide-text-io-a-szuzti-ads}@anchor{30c}@anchor{gnat_rm/the_gnat_library id19}@anchor{30d} +@anchor{gnat_rm/the_gnat_library ada-strings-wide-wide-unbounded-wide-wide-text-io-a-szuzti-ads}@anchor{30b}@anchor{gnat_rm/the_gnat_library id19}@anchor{30c} @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@code{a-szuzti.ads}) @@ -23632,7 +23622,7 @@ wide wide strings, avoiding the necessity for an intermediate operation with ordinary wide wide strings. @node Ada Task_Initialization a-tasini ads,Ada Text_IO C_Streams a-tiocst ads,Ada Strings Wide_Wide_Unbounded Wide_Wide_Text_IO a-szuzti ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library ada-task-initialization-a-tasini-ads}@anchor{30e}@anchor{gnat_rm/the_gnat_library id20}@anchor{30f} +@anchor{gnat_rm/the_gnat_library ada-task-initialization-a-tasini-ads}@anchor{30d}@anchor{gnat_rm/the_gnat_library id20}@anchor{30e} @section @code{Ada.Task_Initialization} (@code{a-tasini.ads}) @@ -23644,7 +23634,7 @@ parameterless procedures. Note that such a handler is only invoked for those tasks activated after the handler is set. @node Ada Text_IO C_Streams a-tiocst ads,Ada Text_IO Reset_Standard_Files a-tirsfi ads,Ada Task_Initialization a-tasini ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library ada-text-io-c-streams-a-tiocst-ads}@anchor{310}@anchor{gnat_rm/the_gnat_library id21}@anchor{311} +@anchor{gnat_rm/the_gnat_library ada-text-io-c-streams-a-tiocst-ads}@anchor{30f}@anchor{gnat_rm/the_gnat_library id21}@anchor{310} @section @code{Ada.Text_IO.C_Streams} (@code{a-tiocst.ads}) @@ -23659,7 +23649,7 @@ extracted from a file opened on the Ada side, and an Ada file can be constructed from a stream opened on the C side. @node Ada Text_IO Reset_Standard_Files a-tirsfi ads,Ada Wide_Characters Unicode a-wichun ads,Ada Text_IO C_Streams a-tiocst ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library ada-text-io-reset-standard-files-a-tirsfi-ads}@anchor{312}@anchor{gnat_rm/the_gnat_library id22}@anchor{313} +@anchor{gnat_rm/the_gnat_library ada-text-io-reset-standard-files-a-tirsfi-ads}@anchor{311}@anchor{gnat_rm/the_gnat_library id22}@anchor{312} @section @code{Ada.Text_IO.Reset_Standard_Files} (@code{a-tirsfi.ads}) @@ -23674,7 +23664,7 @@ execution (for example a standard input file may be redefined to be interactive). @node Ada Wide_Characters Unicode a-wichun ads,Ada Wide_Text_IO C_Streams a-wtcstr ads,Ada Text_IO Reset_Standard_Files a-tirsfi ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library ada-wide-characters-unicode-a-wichun-ads}@anchor{314}@anchor{gnat_rm/the_gnat_library id23}@anchor{315} +@anchor{gnat_rm/the_gnat_library ada-wide-characters-unicode-a-wichun-ads}@anchor{313}@anchor{gnat_rm/the_gnat_library id23}@anchor{314} @section @code{Ada.Wide_Characters.Unicode} (@code{a-wichun.ads}) @@ -23687,7 +23677,7 @@ This package provides subprograms that allow categorization of Wide_Character values according to Unicode categories. @node Ada Wide_Text_IO C_Streams a-wtcstr ads,Ada Wide_Text_IO Reset_Standard_Files a-wrstfi ads,Ada Wide_Characters Unicode a-wichun ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library ada-wide-text-io-c-streams-a-wtcstr-ads}@anchor{316}@anchor{gnat_rm/the_gnat_library id24}@anchor{317} +@anchor{gnat_rm/the_gnat_library ada-wide-text-io-c-streams-a-wtcstr-ads}@anchor{315}@anchor{gnat_rm/the_gnat_library id24}@anchor{316} @section @code{Ada.Wide_Text_IO.C_Streams} (@code{a-wtcstr.ads}) @@ -23702,7 +23692,7 @@ extracted from a file opened on the Ada side, and an Ada file can be constructed from a stream opened on the C side. @node Ada Wide_Text_IO Reset_Standard_Files a-wrstfi ads,Ada Wide_Wide_Characters Unicode a-zchuni ads,Ada Wide_Text_IO C_Streams a-wtcstr ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library ada-wide-text-io-reset-standard-files-a-wrstfi-ads}@anchor{318}@anchor{gnat_rm/the_gnat_library id25}@anchor{319} +@anchor{gnat_rm/the_gnat_library ada-wide-text-io-reset-standard-files-a-wrstfi-ads}@anchor{317}@anchor{gnat_rm/the_gnat_library id25}@anchor{318} @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@code{a-wrstfi.ads}) @@ -23717,7 +23707,7 @@ execution (for example a standard input file may be redefined to be interactive). @node Ada Wide_Wide_Characters Unicode a-zchuni ads,Ada Wide_Wide_Text_IO C_Streams a-ztcstr ads,Ada Wide_Text_IO Reset_Standard_Files a-wrstfi ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library ada-wide-wide-characters-unicode-a-zchuni-ads}@anchor{31a}@anchor{gnat_rm/the_gnat_library id26}@anchor{31b} +@anchor{gnat_rm/the_gnat_library ada-wide-wide-characters-unicode-a-zchuni-ads}@anchor{319}@anchor{gnat_rm/the_gnat_library id26}@anchor{31a} @section @code{Ada.Wide_Wide_Characters.Unicode} (@code{a-zchuni.ads}) @@ -23730,7 +23720,7 @@ This package provides subprograms that allow categorization of Wide_Wide_Character values according to Unicode categories. @node Ada Wide_Wide_Text_IO C_Streams a-ztcstr ads,Ada Wide_Wide_Text_IO Reset_Standard_Files a-zrstfi ads,Ada Wide_Wide_Characters Unicode a-zchuni ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library ada-wide-wide-text-io-c-streams-a-ztcstr-ads}@anchor{31c}@anchor{gnat_rm/the_gnat_library id27}@anchor{31d} +@anchor{gnat_rm/the_gnat_library ada-wide-wide-text-io-c-streams-a-ztcstr-ads}@anchor{31b}@anchor{gnat_rm/the_gnat_library id27}@anchor{31c} @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@code{a-ztcstr.ads}) @@ -23745,7 +23735,7 @@ extracted from a file opened on the Ada side, and an Ada file can be constructed from a stream opened on the C side. @node Ada Wide_Wide_Text_IO Reset_Standard_Files a-zrstfi ads,GNAT Altivec g-altive ads,Ada Wide_Wide_Text_IO C_Streams a-ztcstr ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library ada-wide-wide-text-io-reset-standard-files-a-zrstfi-ads}@anchor{31e}@anchor{gnat_rm/the_gnat_library id28}@anchor{31f} +@anchor{gnat_rm/the_gnat_library ada-wide-wide-text-io-reset-standard-files-a-zrstfi-ads}@anchor{31d}@anchor{gnat_rm/the_gnat_library id28}@anchor{31e} @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@code{a-zrstfi.ads}) @@ -23760,7 +23750,7 @@ change during execution (for example a standard input file may be redefined to be interactive). @node GNAT Altivec g-altive ads,GNAT Altivec Conversions g-altcon ads,Ada Wide_Wide_Text_IO Reset_Standard_Files a-zrstfi ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-altivec-g-altive-ads}@anchor{320}@anchor{gnat_rm/the_gnat_library id29}@anchor{321} +@anchor{gnat_rm/the_gnat_library gnat-altivec-g-altive-ads}@anchor{31f}@anchor{gnat_rm/the_gnat_library id29}@anchor{320} @section @code{GNAT.Altivec} (@code{g-altive.ads}) @@ -23773,7 +23763,7 @@ definitions of constants and types common to all the versions of the binding. @node GNAT Altivec Conversions g-altcon ads,GNAT Altivec Vector_Operations g-alveop ads,GNAT Altivec g-altive ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-altivec-conversions-g-altcon-ads}@anchor{322}@anchor{gnat_rm/the_gnat_library id30}@anchor{323} +@anchor{gnat_rm/the_gnat_library gnat-altivec-conversions-g-altcon-ads}@anchor{321}@anchor{gnat_rm/the_gnat_library id30}@anchor{322} @section @code{GNAT.Altivec.Conversions} (@code{g-altcon.ads}) @@ -23784,7 +23774,7 @@ binding. This package provides the Vector/View conversion routines. @node GNAT Altivec Vector_Operations g-alveop ads,GNAT Altivec Vector_Types g-alvety ads,GNAT Altivec Conversions g-altcon ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-altivec-vector-operations-g-alveop-ads}@anchor{324}@anchor{gnat_rm/the_gnat_library id31}@anchor{325} +@anchor{gnat_rm/the_gnat_library gnat-altivec-vector-operations-g-alveop-ads}@anchor{323}@anchor{gnat_rm/the_gnat_library id31}@anchor{324} @section @code{GNAT.Altivec.Vector_Operations} (@code{g-alveop.ads}) @@ -23798,7 +23788,7 @@ library. The hard binding is provided as a separate package. This unit is common to both bindings. @node GNAT Altivec Vector_Types g-alvety ads,GNAT Altivec Vector_Views g-alvevi ads,GNAT Altivec Vector_Operations g-alveop ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-altivec-vector-types-g-alvety-ads}@anchor{326}@anchor{gnat_rm/the_gnat_library id32}@anchor{327} +@anchor{gnat_rm/the_gnat_library gnat-altivec-vector-types-g-alvety-ads}@anchor{325}@anchor{gnat_rm/the_gnat_library id32}@anchor{326} @section @code{GNAT.Altivec.Vector_Types} (@code{g-alvety.ads}) @@ -23810,7 +23800,7 @@ This package exposes the various vector types part of the Ada binding to AltiVec facilities. @node GNAT Altivec Vector_Views g-alvevi ads,GNAT Array_Split g-arrspl ads,GNAT Altivec Vector_Types g-alvety ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-altivec-vector-views-g-alvevi-ads}@anchor{328}@anchor{gnat_rm/the_gnat_library id33}@anchor{329} +@anchor{gnat_rm/the_gnat_library gnat-altivec-vector-views-g-alvevi-ads}@anchor{327}@anchor{gnat_rm/the_gnat_library id33}@anchor{328} @section @code{GNAT.Altivec.Vector_Views} (@code{g-alvevi.ads}) @@ -23825,7 +23815,7 @@ vector elements and provides a simple way to initialize vector objects. @node GNAT Array_Split g-arrspl ads,GNAT AWK g-awk ads,GNAT Altivec Vector_Views g-alvevi ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-array-split-g-arrspl-ads}@anchor{32a}@anchor{gnat_rm/the_gnat_library id34}@anchor{32b} +@anchor{gnat_rm/the_gnat_library gnat-array-split-g-arrspl-ads}@anchor{329}@anchor{gnat_rm/the_gnat_library id34}@anchor{32a} @section @code{GNAT.Array_Split} (@code{g-arrspl.ads}) @@ -23838,7 +23828,7 @@ an array wherever the separators appear, and provide direct access to the resulting slices. @node GNAT AWK g-awk ads,GNAT Binary_Search g-binsea ads,GNAT Array_Split g-arrspl ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-awk-g-awk-ads}@anchor{32c}@anchor{gnat_rm/the_gnat_library id35}@anchor{32d} +@anchor{gnat_rm/the_gnat_library gnat-awk-g-awk-ads}@anchor{32b}@anchor{gnat_rm/the_gnat_library id35}@anchor{32c} @section @code{GNAT.AWK} (@code{g-awk.ads}) @@ -23853,7 +23843,7 @@ or more files containing formatted data. The file is viewed as a database where each record is a line and a field is a data element in this line. @node GNAT Binary_Search g-binsea ads,GNAT Bind_Environment g-binenv ads,GNAT AWK g-awk ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-binary-search-g-binsea-ads}@anchor{32e}@anchor{gnat_rm/the_gnat_library id36}@anchor{32f} +@anchor{gnat_rm/the_gnat_library gnat-binary-search-g-binsea-ads}@anchor{32d}@anchor{gnat_rm/the_gnat_library id36}@anchor{32e} @section @code{GNAT.Binary_Search} (@code{g-binsea.ads}) @@ -23865,7 +23855,7 @@ Allow binary search of a sorted array (or of an array-like container; the generic does not reference the array directly). @node GNAT Bind_Environment g-binenv ads,GNAT Branch_Prediction g-brapre ads,GNAT Binary_Search g-binsea ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-bind-environment-g-binenv-ads}@anchor{330}@anchor{gnat_rm/the_gnat_library id37}@anchor{331} +@anchor{gnat_rm/the_gnat_library gnat-bind-environment-g-binenv-ads}@anchor{32f}@anchor{gnat_rm/the_gnat_library id37}@anchor{330} @section @code{GNAT.Bind_Environment} (@code{g-binenv.ads}) @@ -23878,7 +23868,7 @@ These associations can be specified using the @code{-V} binder command line switch. @node GNAT Branch_Prediction g-brapre ads,GNAT Bounded_Buffers g-boubuf ads,GNAT Bind_Environment g-binenv ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-branch-prediction-g-brapre-ads}@anchor{332}@anchor{gnat_rm/the_gnat_library id38}@anchor{333} +@anchor{gnat_rm/the_gnat_library gnat-branch-prediction-g-brapre-ads}@anchor{331}@anchor{gnat_rm/the_gnat_library id38}@anchor{332} @section @code{GNAT.Branch_Prediction} (@code{g-brapre.ads}) @@ -23889,7 +23879,7 @@ line switch. Provides routines giving hints to the branch predictor of the code generator. @node GNAT Bounded_Buffers g-boubuf ads,GNAT Bounded_Mailboxes g-boumai ads,GNAT Branch_Prediction g-brapre ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-bounded-buffers-g-boubuf-ads}@anchor{334}@anchor{gnat_rm/the_gnat_library id39}@anchor{335} +@anchor{gnat_rm/the_gnat_library gnat-bounded-buffers-g-boubuf-ads}@anchor{333}@anchor{gnat_rm/the_gnat_library id39}@anchor{334} @section @code{GNAT.Bounded_Buffers} (@code{g-boubuf.ads}) @@ -23904,7 +23894,7 @@ useful directly or as parts of the implementations of other abstractions, such as mailboxes. @node GNAT Bounded_Mailboxes g-boumai ads,GNAT Bubble_Sort g-bubsor ads,GNAT Bounded_Buffers g-boubuf ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-bounded-mailboxes-g-boumai-ads}@anchor{336}@anchor{gnat_rm/the_gnat_library id40}@anchor{337} +@anchor{gnat_rm/the_gnat_library gnat-bounded-mailboxes-g-boumai-ads}@anchor{335}@anchor{gnat_rm/the_gnat_library id40}@anchor{336} @section @code{GNAT.Bounded_Mailboxes} (@code{g-boumai.ads}) @@ -23917,7 +23907,7 @@ such as mailboxes. Provides a thread-safe asynchronous intertask mailbox communication facility. @node GNAT Bubble_Sort g-bubsor ads,GNAT Bubble_Sort_A g-busora ads,GNAT Bounded_Mailboxes g-boumai ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-bubble-sort-g-bubsor-ads}@anchor{338}@anchor{gnat_rm/the_gnat_library id41}@anchor{339} +@anchor{gnat_rm/the_gnat_library gnat-bubble-sort-g-bubsor-ads}@anchor{337}@anchor{gnat_rm/the_gnat_library id41}@anchor{338} @section @code{GNAT.Bubble_Sort} (@code{g-bubsor.ads}) @@ -23932,7 +23922,7 @@ data items. Exchange and comparison procedures are provided by passing access-to-procedure values. @node GNAT Bubble_Sort_A g-busora ads,GNAT Bubble_Sort_G g-busorg ads,GNAT Bubble_Sort g-bubsor ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-bubble-sort-a-g-busora-ads}@anchor{33a}@anchor{gnat_rm/the_gnat_library id42}@anchor{33b} +@anchor{gnat_rm/the_gnat_library gnat-bubble-sort-a-g-busora-ads}@anchor{339}@anchor{gnat_rm/the_gnat_library id42}@anchor{33a} @section @code{GNAT.Bubble_Sort_A} (@code{g-busora.ads}) @@ -23948,7 +23938,7 @@ access-to-procedure values. This is an older version, retained for compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable. @node GNAT Bubble_Sort_G g-busorg ads,GNAT Byte_Order_Mark g-byorma ads,GNAT Bubble_Sort_A g-busora ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-bubble-sort-g-g-busorg-ads}@anchor{33c}@anchor{gnat_rm/the_gnat_library id43}@anchor{33d} +@anchor{gnat_rm/the_gnat_library gnat-bubble-sort-g-g-busorg-ads}@anchor{33b}@anchor{gnat_rm/the_gnat_library id43}@anchor{33c} @section @code{GNAT.Bubble_Sort_G} (@code{g-busorg.ads}) @@ -23964,7 +23954,7 @@ if the procedures can be inlined, at the expense of duplicating code for multiple instantiations. @node GNAT Byte_Order_Mark g-byorma ads,GNAT Byte_Swapping g-bytswa ads,GNAT Bubble_Sort_G g-busorg ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-byte-order-mark-g-byorma-ads}@anchor{33e}@anchor{gnat_rm/the_gnat_library id44}@anchor{33f} +@anchor{gnat_rm/the_gnat_library gnat-byte-order-mark-g-byorma-ads}@anchor{33d}@anchor{gnat_rm/the_gnat_library id44}@anchor{33e} @section @code{GNAT.Byte_Order_Mark} (@code{g-byorma.ads}) @@ -23980,7 +23970,7 @@ the encoding of the string. The routine includes detection of special XML sequences for various UCS input formats. @node GNAT Byte_Swapping g-bytswa ads,GNAT Calendar g-calend ads,GNAT Byte_Order_Mark g-byorma ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-byte-swapping-g-bytswa-ads}@anchor{340}@anchor{gnat_rm/the_gnat_library id45}@anchor{341} +@anchor{gnat_rm/the_gnat_library gnat-byte-swapping-g-bytswa-ads}@anchor{33f}@anchor{gnat_rm/the_gnat_library id45}@anchor{340} @section @code{GNAT.Byte_Swapping} (@code{g-bytswa.ads}) @@ -23994,7 +23984,7 @@ General routines for swapping the bytes in 2-, 4-, and 8-byte quantities. Machine-specific implementations are available in some cases. @node GNAT Calendar g-calend ads,GNAT Calendar Time_IO g-catiio ads,GNAT Byte_Swapping g-bytswa ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-calendar-g-calend-ads}@anchor{342}@anchor{gnat_rm/the_gnat_library id46}@anchor{343} +@anchor{gnat_rm/the_gnat_library gnat-calendar-g-calend-ads}@anchor{341}@anchor{gnat_rm/the_gnat_library id46}@anchor{342} @section @code{GNAT.Calendar} (@code{g-calend.ads}) @@ -24008,7 +23998,7 @@ Also provides conversion of @code{Ada.Calendar.Time} values to and from the C @code{timeval} format. @node GNAT Calendar Time_IO g-catiio ads,GNAT CRC32 g-crc32 ads,GNAT Calendar g-calend ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-calendar-time-io-g-catiio-ads}@anchor{344}@anchor{gnat_rm/the_gnat_library id47}@anchor{345} +@anchor{gnat_rm/the_gnat_library gnat-calendar-time-io-g-catiio-ads}@anchor{343}@anchor{gnat_rm/the_gnat_library id47}@anchor{344} @section @code{GNAT.Calendar.Time_IO} (@code{g-catiio.ads}) @@ -24019,7 +24009,7 @@ C @code{timeval} format. @geindex GNAT.Calendar.Time_IO (g-catiio.ads) @node GNAT CRC32 g-crc32 ads,GNAT Case_Util g-casuti ads,GNAT Calendar Time_IO g-catiio ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-crc32-g-crc32-ads}@anchor{346}@anchor{gnat_rm/the_gnat_library id48}@anchor{347} +@anchor{gnat_rm/the_gnat_library gnat-crc32-g-crc32-ads}@anchor{345}@anchor{gnat_rm/the_gnat_library id48}@anchor{346} @section @code{GNAT.CRC32} (@code{g-crc32.ads}) @@ -24036,7 +24026,7 @@ of this algorithm see Aug. 1988. Sarwate, D.V. @node GNAT Case_Util g-casuti ads,GNAT CGI g-cgi ads,GNAT CRC32 g-crc32 ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-case-util-g-casuti-ads}@anchor{348}@anchor{gnat_rm/the_gnat_library id49}@anchor{349} +@anchor{gnat_rm/the_gnat_library gnat-case-util-g-casuti-ads}@anchor{347}@anchor{gnat_rm/the_gnat_library id49}@anchor{348} @section @code{GNAT.Case_Util} (@code{g-casuti.ads}) @@ -24051,7 +24041,7 @@ without the overhead of the full casing tables in @code{Ada.Characters.Handling}. @node GNAT CGI g-cgi ads,GNAT CGI Cookie g-cgicoo ads,GNAT Case_Util g-casuti ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-cgi-g-cgi-ads}@anchor{34a}@anchor{gnat_rm/the_gnat_library id50}@anchor{34b} +@anchor{gnat_rm/the_gnat_library gnat-cgi-g-cgi-ads}@anchor{349}@anchor{gnat_rm/the_gnat_library id50}@anchor{34a} @section @code{GNAT.CGI} (@code{g-cgi.ads}) @@ -24066,7 +24056,7 @@ builds a table whose index is the key and provides some services to deal with this table. @node GNAT CGI Cookie g-cgicoo ads,GNAT CGI Debug g-cgideb ads,GNAT CGI g-cgi ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-cgi-cookie-g-cgicoo-ads}@anchor{34c}@anchor{gnat_rm/the_gnat_library id51}@anchor{34d} +@anchor{gnat_rm/the_gnat_library gnat-cgi-cookie-g-cgicoo-ads}@anchor{34b}@anchor{gnat_rm/the_gnat_library id51}@anchor{34c} @section @code{GNAT.CGI.Cookie} (@code{g-cgicoo.ads}) @@ -24081,7 +24071,7 @@ Common Gateway Interface (CGI). It exports services to deal with Web cookies (piece of information kept in the Web client software). @node GNAT CGI Debug g-cgideb ads,GNAT Command_Line g-comlin ads,GNAT CGI Cookie g-cgicoo ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-cgi-debug-g-cgideb-ads}@anchor{34e}@anchor{gnat_rm/the_gnat_library id52}@anchor{34f} +@anchor{gnat_rm/the_gnat_library gnat-cgi-debug-g-cgideb-ads}@anchor{34d}@anchor{gnat_rm/the_gnat_library id52}@anchor{34e} @section @code{GNAT.CGI.Debug} (@code{g-cgideb.ads}) @@ -24093,7 +24083,7 @@ This is a package to help debugging CGI (Common Gateway Interface) programs written in Ada. @node GNAT Command_Line g-comlin ads,GNAT Compiler_Version g-comver ads,GNAT CGI Debug g-cgideb ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-command-line-g-comlin-ads}@anchor{350}@anchor{gnat_rm/the_gnat_library id53}@anchor{351} +@anchor{gnat_rm/the_gnat_library gnat-command-line-g-comlin-ads}@anchor{34f}@anchor{gnat_rm/the_gnat_library id53}@anchor{350} @section @code{GNAT.Command_Line} (@code{g-comlin.ads}) @@ -24106,7 +24096,7 @@ including the ability to scan for named switches with optional parameters and expand file names using wildcard notations. @node GNAT Compiler_Version g-comver ads,GNAT Ctrl_C g-ctrl_c ads,GNAT Command_Line g-comlin ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-compiler-version-g-comver-ads}@anchor{352}@anchor{gnat_rm/the_gnat_library id54}@anchor{353} +@anchor{gnat_rm/the_gnat_library gnat-compiler-version-g-comver-ads}@anchor{351}@anchor{gnat_rm/the_gnat_library id54}@anchor{352} @section @code{GNAT.Compiler_Version} (@code{g-comver.ads}) @@ -24124,7 +24114,7 @@ of the compiler if a consistent tool set is used to compile all units of a partition). @node GNAT Ctrl_C g-ctrl_c ads,GNAT Current_Exception g-curexc ads,GNAT Compiler_Version g-comver ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-ctrl-c-g-ctrl-c-ads}@anchor{354}@anchor{gnat_rm/the_gnat_library id55}@anchor{355} +@anchor{gnat_rm/the_gnat_library gnat-ctrl-c-g-ctrl-c-ads}@anchor{353}@anchor{gnat_rm/the_gnat_library id55}@anchor{354} @section @code{GNAT.Ctrl_C} (@code{g-ctrl_c.ads}) @@ -24135,7 +24125,7 @@ of a partition). Provides a simple interface to handle Ctrl-C keyboard events. @node GNAT Current_Exception g-curexc ads,GNAT Debug_Pools g-debpoo ads,GNAT Ctrl_C g-ctrl_c ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-current-exception-g-curexc-ads}@anchor{356}@anchor{gnat_rm/the_gnat_library id56}@anchor{357} +@anchor{gnat_rm/the_gnat_library gnat-current-exception-g-curexc-ads}@anchor{355}@anchor{gnat_rm/the_gnat_library id56}@anchor{356} @section @code{GNAT.Current_Exception} (@code{g-curexc.ads}) @@ -24152,7 +24142,7 @@ This is particularly useful in simulating typical facilities for obtaining information about exceptions provided by Ada 83 compilers. @node GNAT Debug_Pools g-debpoo ads,GNAT Debug_Utilities g-debuti ads,GNAT Current_Exception g-curexc ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-debug-pools-g-debpoo-ads}@anchor{358}@anchor{gnat_rm/the_gnat_library id57}@anchor{359} +@anchor{gnat_rm/the_gnat_library gnat-debug-pools-g-debpoo-ads}@anchor{357}@anchor{gnat_rm/the_gnat_library id57}@anchor{358} @section @code{GNAT.Debug_Pools} (@code{g-debpoo.ads}) @@ -24169,7 +24159,7 @@ problems. See @code{The GNAT Debug_Pool Facility} section in the @cite{GNAT User’s Guide}. @node GNAT Debug_Utilities g-debuti ads,GNAT Decode_String g-decstr ads,GNAT Debug_Pools g-debpoo ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-debug-utilities-g-debuti-ads}@anchor{35a}@anchor{gnat_rm/the_gnat_library id58}@anchor{35b} +@anchor{gnat_rm/the_gnat_library gnat-debug-utilities-g-debuti-ads}@anchor{359}@anchor{gnat_rm/the_gnat_library id58}@anchor{35a} @section @code{GNAT.Debug_Utilities} (@code{g-debuti.ads}) @@ -24182,7 +24172,7 @@ to and from string images of address values. Supports both C and Ada formats for hexadecimal literals. @node GNAT Decode_String g-decstr ads,GNAT Decode_UTF8_String g-deutst ads,GNAT Debug_Utilities g-debuti ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-decode-string-g-decstr-ads}@anchor{35c}@anchor{gnat_rm/the_gnat_library id59}@anchor{35d} +@anchor{gnat_rm/the_gnat_library gnat-decode-string-g-decstr-ads}@anchor{35b}@anchor{gnat_rm/the_gnat_library id59}@anchor{35c} @section @code{GNAT.Decode_String} (@code{g-decstr.ads}) @@ -24206,7 +24196,7 @@ Useful in conjunction with Unicode character coding. Note there is a preinstantiation for UTF-8. See next entry. @node GNAT Decode_UTF8_String g-deutst ads,GNAT Directory_Operations g-dirope ads,GNAT Decode_String g-decstr ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-decode-utf8-string-g-deutst-ads}@anchor{35e}@anchor{gnat_rm/the_gnat_library id60}@anchor{35f} +@anchor{gnat_rm/the_gnat_library gnat-decode-utf8-string-g-deutst-ads}@anchor{35d}@anchor{gnat_rm/the_gnat_library id60}@anchor{35e} @section @code{GNAT.Decode_UTF8_String} (@code{g-deutst.ads}) @@ -24227,7 +24217,7 @@ preinstantiation for UTF-8. See next entry. A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding. @node GNAT Directory_Operations g-dirope ads,GNAT Directory_Operations Iteration g-diopit ads,GNAT Decode_UTF8_String g-deutst ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-directory-operations-g-dirope-ads}@anchor{360}@anchor{gnat_rm/the_gnat_library id61}@anchor{361} +@anchor{gnat_rm/the_gnat_library gnat-directory-operations-g-dirope-ads}@anchor{35f}@anchor{gnat_rm/the_gnat_library id61}@anchor{360} @section @code{GNAT.Directory_Operations} (@code{g-dirope.ads}) @@ -24240,7 +24230,7 @@ the current directory, making new directories, and scanning the files in a directory. @node GNAT Directory_Operations Iteration g-diopit ads,GNAT Dynamic_HTables g-dynhta ads,GNAT Directory_Operations g-dirope ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-directory-operations-iteration-g-diopit-ads}@anchor{362}@anchor{gnat_rm/the_gnat_library id62}@anchor{363} +@anchor{gnat_rm/the_gnat_library gnat-directory-operations-iteration-g-diopit-ads}@anchor{361}@anchor{gnat_rm/the_gnat_library id62}@anchor{362} @section @code{GNAT.Directory_Operations.Iteration} (@code{g-diopit.ads}) @@ -24252,7 +24242,7 @@ A child unit of GNAT.Directory_Operations providing additional operations for iterating through directories. @node GNAT Dynamic_HTables g-dynhta ads,GNAT Dynamic_Tables g-dyntab ads,GNAT Directory_Operations Iteration g-diopit ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-dynamic-htables-g-dynhta-ads}@anchor{364}@anchor{gnat_rm/the_gnat_library id63}@anchor{365} +@anchor{gnat_rm/the_gnat_library gnat-dynamic-htables-g-dynhta-ads}@anchor{363}@anchor{gnat_rm/the_gnat_library id63}@anchor{364} @section @code{GNAT.Dynamic_HTables} (@code{g-dynhta.ads}) @@ -24270,7 +24260,7 @@ dynamic instances of the hash table, while an instantiation of @code{GNAT.HTable} creates a single instance of the hash table. @node GNAT Dynamic_Tables g-dyntab ads,GNAT Encode_String g-encstr ads,GNAT Dynamic_HTables g-dynhta ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-dynamic-tables-g-dyntab-ads}@anchor{366}@anchor{gnat_rm/the_gnat_library id64}@anchor{367} +@anchor{gnat_rm/the_gnat_library gnat-dynamic-tables-g-dyntab-ads}@anchor{365}@anchor{gnat_rm/the_gnat_library id64}@anchor{366} @section @code{GNAT.Dynamic_Tables} (@code{g-dyntab.ads}) @@ -24290,7 +24280,7 @@ dynamic instances of the table, while an instantiation of @code{GNAT.Table} creates a single instance of the table type. @node GNAT Encode_String g-encstr ads,GNAT Encode_UTF8_String g-enutst ads,GNAT Dynamic_Tables g-dyntab ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-encode-string-g-encstr-ads}@anchor{368}@anchor{gnat_rm/the_gnat_library id65}@anchor{369} +@anchor{gnat_rm/the_gnat_library gnat-encode-string-g-encstr-ads}@anchor{367}@anchor{gnat_rm/the_gnat_library id65}@anchor{368} @section @code{GNAT.Encode_String} (@code{g-encstr.ads}) @@ -24312,7 +24302,7 @@ encoding method. Useful in conjunction with Unicode character coding. Note there is a preinstantiation for UTF-8. See next entry. @node GNAT Encode_UTF8_String g-enutst ads,GNAT Exception_Actions g-excact ads,GNAT Encode_String g-encstr ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-encode-utf8-string-g-enutst-ads}@anchor{36a}@anchor{gnat_rm/the_gnat_library id66}@anchor{36b} +@anchor{gnat_rm/the_gnat_library gnat-encode-utf8-string-g-enutst-ads}@anchor{369}@anchor{gnat_rm/the_gnat_library id66}@anchor{36a} @section @code{GNAT.Encode_UTF8_String} (@code{g-enutst.ads}) @@ -24333,7 +24323,7 @@ Note there is a preinstantiation for UTF-8. See next entry. A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding. @node GNAT Exception_Actions g-excact ads,GNAT Exception_Traces g-exctra ads,GNAT Encode_UTF8_String g-enutst ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-exception-actions-g-excact-ads}@anchor{36c}@anchor{gnat_rm/the_gnat_library id67}@anchor{36d} +@anchor{gnat_rm/the_gnat_library gnat-exception-actions-g-excact-ads}@anchor{36b}@anchor{gnat_rm/the_gnat_library id67}@anchor{36c} @section @code{GNAT.Exception_Actions} (@code{g-excact.ads}) @@ -24346,7 +24336,7 @@ for specific exceptions, or when any exception is raised. This can be used for instance to force a core dump to ease debugging. @node GNAT Exception_Traces g-exctra ads,GNAT Exceptions g-except ads,GNAT Exception_Actions g-excact ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-exception-traces-g-exctra-ads}@anchor{36e}@anchor{gnat_rm/the_gnat_library id68}@anchor{36f} +@anchor{gnat_rm/the_gnat_library gnat-exception-traces-g-exctra-ads}@anchor{36d}@anchor{gnat_rm/the_gnat_library id68}@anchor{36e} @section @code{GNAT.Exception_Traces} (@code{g-exctra.ads}) @@ -24360,7 +24350,7 @@ Provides an interface allowing to control automatic output upon exception occurrences. @node GNAT Exceptions g-except ads,GNAT Expect g-expect ads,GNAT Exception_Traces g-exctra ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-exceptions-g-except-ads}@anchor{370}@anchor{gnat_rm/the_gnat_library id69}@anchor{371} +@anchor{gnat_rm/the_gnat_library gnat-exceptions-g-except-ads}@anchor{36f}@anchor{gnat_rm/the_gnat_library id69}@anchor{370} @section @code{GNAT.Exceptions} (@code{g-except.ads}) @@ -24381,7 +24371,7 @@ predefined exceptions, and for example allows raising @code{Constraint_Error} with a message from a pure subprogram. @node GNAT Expect g-expect ads,GNAT Expect TTY g-exptty ads,GNAT Exceptions g-except ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-expect-g-expect-ads}@anchor{372}@anchor{gnat_rm/the_gnat_library id70}@anchor{373} +@anchor{gnat_rm/the_gnat_library gnat-expect-g-expect-ads}@anchor{371}@anchor{gnat_rm/the_gnat_library id70}@anchor{372} @section @code{GNAT.Expect} (@code{g-expect.ads}) @@ -24397,7 +24387,7 @@ It is not implemented for cross ports, and in particular is not implemented for VxWorks or LynxOS. @node GNAT Expect TTY g-exptty ads,GNAT Float_Control g-flocon ads,GNAT Expect g-expect ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-expect-tty-g-exptty-ads}@anchor{374}@anchor{gnat_rm/the_gnat_library id71}@anchor{375} +@anchor{gnat_rm/the_gnat_library gnat-expect-tty-g-exptty-ads}@anchor{373}@anchor{gnat_rm/the_gnat_library id71}@anchor{374} @section @code{GNAT.Expect.TTY} (@code{g-exptty.ads}) @@ -24409,7 +24399,7 @@ ports. It is not implemented for cross ports, and in particular is not implemented for VxWorks or LynxOS. @node GNAT Float_Control g-flocon ads,GNAT Formatted_String g-forstr ads,GNAT Expect TTY g-exptty ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-float-control-g-flocon-ads}@anchor{376}@anchor{gnat_rm/the_gnat_library id72}@anchor{377} +@anchor{gnat_rm/the_gnat_library gnat-float-control-g-flocon-ads}@anchor{375}@anchor{gnat_rm/the_gnat_library id72}@anchor{376} @section @code{GNAT.Float_Control} (@code{g-flocon.ads}) @@ -24423,7 +24413,7 @@ library calls may cause this mode to be modified, and the Reset procedure in this package can be used to reestablish the required mode. @node GNAT Formatted_String g-forstr ads,GNAT Generic_Fast_Math_Functions g-gfmafu ads,GNAT Float_Control g-flocon ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-formatted-string-g-forstr-ads}@anchor{378}@anchor{gnat_rm/the_gnat_library id73}@anchor{379} +@anchor{gnat_rm/the_gnat_library gnat-formatted-string-g-forstr-ads}@anchor{377}@anchor{gnat_rm/the_gnat_library id73}@anchor{378} @section @code{GNAT.Formatted_String} (@code{g-forstr.ads}) @@ -24438,7 +24428,7 @@ derived from Integer, Float or enumerations as values for the formatted string. @node GNAT Generic_Fast_Math_Functions g-gfmafu ads,GNAT Heap_Sort g-heasor ads,GNAT Formatted_String g-forstr ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-generic-fast-math-functions-g-gfmafu-ads}@anchor{37a}@anchor{gnat_rm/the_gnat_library id74}@anchor{37b} +@anchor{gnat_rm/the_gnat_library gnat-generic-fast-math-functions-g-gfmafu-ads}@anchor{379}@anchor{gnat_rm/the_gnat_library id74}@anchor{37a} @section @code{GNAT.Generic_Fast_Math_Functions} (@code{g-gfmafu.ads}) @@ -24456,7 +24446,7 @@ have a vector implementation that can be automatically used by the compiler when auto-vectorization is enabled. @node GNAT Heap_Sort g-heasor ads,GNAT Heap_Sort_A g-hesora ads,GNAT Generic_Fast_Math_Functions g-gfmafu ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-heap-sort-g-heasor-ads}@anchor{37c}@anchor{gnat_rm/the_gnat_library id75}@anchor{37d} +@anchor{gnat_rm/the_gnat_library gnat-heap-sort-g-heasor-ads}@anchor{37b}@anchor{gnat_rm/the_gnat_library id75}@anchor{37c} @section @code{GNAT.Heap_Sort} (@code{g-heasor.ads}) @@ -24470,7 +24460,7 @@ access-to-procedure values. The algorithm used is a modified heap sort that performs approximately N*log(N) comparisons in the worst case. @node GNAT Heap_Sort_A g-hesora ads,GNAT Heap_Sort_G g-hesorg ads,GNAT Heap_Sort g-heasor ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-heap-sort-a-g-hesora-ads}@anchor{37e}@anchor{gnat_rm/the_gnat_library id76}@anchor{37f} +@anchor{gnat_rm/the_gnat_library gnat-heap-sort-a-g-hesora-ads}@anchor{37d}@anchor{gnat_rm/the_gnat_library id76}@anchor{37e} @section @code{GNAT.Heap_Sort_A} (@code{g-hesora.ads}) @@ -24486,7 +24476,7 @@ This differs from @code{GNAT.Heap_Sort} in having a less convenient interface, but may be slightly more efficient. @node GNAT Heap_Sort_G g-hesorg ads,GNAT HTable g-htable ads,GNAT Heap_Sort_A g-hesora ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-heap-sort-g-g-hesorg-ads}@anchor{380}@anchor{gnat_rm/the_gnat_library id77}@anchor{381} +@anchor{gnat_rm/the_gnat_library gnat-heap-sort-g-g-hesorg-ads}@anchor{37f}@anchor{gnat_rm/the_gnat_library id77}@anchor{380} @section @code{GNAT.Heap_Sort_G} (@code{g-hesorg.ads}) @@ -24500,7 +24490,7 @@ if the procedures can be inlined, at the expense of duplicating code for multiple instantiations. @node GNAT HTable g-htable ads,GNAT IO g-io ads,GNAT Heap_Sort_G g-hesorg ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-htable-g-htable-ads}@anchor{382}@anchor{gnat_rm/the_gnat_library id78}@anchor{383} +@anchor{gnat_rm/the_gnat_library gnat-htable-g-htable-ads}@anchor{381}@anchor{gnat_rm/the_gnat_library id78}@anchor{382} @section @code{GNAT.HTable} (@code{g-htable.ads}) @@ -24513,7 +24503,7 @@ data. Provides two approaches, one a simple static approach, and the other allowing arbitrary dynamic hash tables. @node GNAT IO g-io ads,GNAT IO_Aux g-io_aux ads,GNAT HTable g-htable ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-io-g-io-ads}@anchor{384}@anchor{gnat_rm/the_gnat_library id79}@anchor{385} +@anchor{gnat_rm/the_gnat_library gnat-io-g-io-ads}@anchor{383}@anchor{gnat_rm/the_gnat_library id79}@anchor{384} @section @code{GNAT.IO} (@code{g-io.ads}) @@ -24529,7 +24519,7 @@ Standard_Input, and writing characters, strings and integers to either Standard_Output or Standard_Error. @node GNAT IO_Aux g-io_aux ads,GNAT Lock_Files g-locfil ads,GNAT IO g-io ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-io-aux-g-io-aux-ads}@anchor{386}@anchor{gnat_rm/the_gnat_library id80}@anchor{387} +@anchor{gnat_rm/the_gnat_library gnat-io-aux-g-io-aux-ads}@anchor{385}@anchor{gnat_rm/the_gnat_library id80}@anchor{386} @section @code{GNAT.IO_Aux} (@code{g-io_aux.ads}) @@ -24543,7 +24533,7 @@ Provides some auxiliary functions for use with Text_IO, including a test for whether a file exists, and functions for reading a line of text. @node GNAT Lock_Files g-locfil ads,GNAT MBBS_Discrete_Random g-mbdira ads,GNAT IO_Aux g-io_aux ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-lock-files-g-locfil-ads}@anchor{388}@anchor{gnat_rm/the_gnat_library id81}@anchor{389} +@anchor{gnat_rm/the_gnat_library gnat-lock-files-g-locfil-ads}@anchor{387}@anchor{gnat_rm/the_gnat_library id81}@anchor{388} @section @code{GNAT.Lock_Files} (@code{g-locfil.ads}) @@ -24557,7 +24547,7 @@ Provides a general interface for using files as locks. Can be used for providing program level synchronization. @node GNAT MBBS_Discrete_Random g-mbdira ads,GNAT MBBS_Float_Random g-mbflra ads,GNAT Lock_Files g-locfil ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-mbbs-discrete-random-g-mbdira-ads}@anchor{38a}@anchor{gnat_rm/the_gnat_library id82}@anchor{38b} +@anchor{gnat_rm/the_gnat_library gnat-mbbs-discrete-random-g-mbdira-ads}@anchor{389}@anchor{gnat_rm/the_gnat_library id82}@anchor{38a} @section @code{GNAT.MBBS_Discrete_Random} (@code{g-mbdira.ads}) @@ -24569,7 +24559,7 @@ The original implementation of @code{Ada.Numerics.Discrete_Random}. Uses a modified version of the Blum-Blum-Shub generator. @node GNAT MBBS_Float_Random g-mbflra ads,GNAT MD5 g-md5 ads,GNAT MBBS_Discrete_Random g-mbdira ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-mbbs-float-random-g-mbflra-ads}@anchor{38c}@anchor{gnat_rm/the_gnat_library id83}@anchor{38d} +@anchor{gnat_rm/the_gnat_library gnat-mbbs-float-random-g-mbflra-ads}@anchor{38b}@anchor{gnat_rm/the_gnat_library id83}@anchor{38c} @section @code{GNAT.MBBS_Float_Random} (@code{g-mbflra.ads}) @@ -24581,7 +24571,7 @@ The original implementation of @code{Ada.Numerics.Float_Random}. Uses a modified version of the Blum-Blum-Shub generator. @node GNAT MD5 g-md5 ads,GNAT Memory_Dump g-memdum ads,GNAT MBBS_Float_Random g-mbflra ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-md5-g-md5-ads}@anchor{38e}@anchor{gnat_rm/the_gnat_library id84}@anchor{38f} +@anchor{gnat_rm/the_gnat_library gnat-md5-g-md5-ads}@anchor{38d}@anchor{gnat_rm/the_gnat_library id84}@anchor{38e} @section @code{GNAT.MD5} (@code{g-md5.ads}) @@ -24594,7 +24584,7 @@ the HMAC-MD5 message authentication function as described in RFC 2104 and FIPS PUB 198. @node GNAT Memory_Dump g-memdum ads,GNAT Most_Recent_Exception g-moreex ads,GNAT MD5 g-md5 ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-memory-dump-g-memdum-ads}@anchor{390}@anchor{gnat_rm/the_gnat_library id85}@anchor{391} +@anchor{gnat_rm/the_gnat_library gnat-memory-dump-g-memdum-ads}@anchor{38f}@anchor{gnat_rm/the_gnat_library id85}@anchor{390} @section @code{GNAT.Memory_Dump} (@code{g-memdum.ads}) @@ -24607,7 +24597,7 @@ standard output or standard error files. Uses GNAT.IO for actual output. @node GNAT Most_Recent_Exception g-moreex ads,GNAT OS_Lib g-os_lib ads,GNAT Memory_Dump g-memdum ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-most-recent-exception-g-moreex-ads}@anchor{392}@anchor{gnat_rm/the_gnat_library id86}@anchor{393} +@anchor{gnat_rm/the_gnat_library gnat-most-recent-exception-g-moreex-ads}@anchor{391}@anchor{gnat_rm/the_gnat_library id86}@anchor{392} @section @code{GNAT.Most_Recent_Exception} (@code{g-moreex.ads}) @@ -24621,7 +24611,7 @@ various logging purposes, including duplicating functionality of some Ada 83 implementation dependent extensions. @node GNAT OS_Lib g-os_lib ads,GNAT Perfect_Hash_Generators g-pehage ads,GNAT Most_Recent_Exception g-moreex ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-os-lib-g-os-lib-ads}@anchor{394}@anchor{gnat_rm/the_gnat_library id87}@anchor{395} +@anchor{gnat_rm/the_gnat_library gnat-os-lib-g-os-lib-ads}@anchor{393}@anchor{gnat_rm/the_gnat_library id87}@anchor{394} @section @code{GNAT.OS_Lib} (@code{g-os_lib.ads}) @@ -24637,7 +24627,7 @@ including a portable spawn procedure, and access to environment variables and error return codes. @node GNAT Perfect_Hash_Generators g-pehage ads,GNAT Random_Numbers g-rannum ads,GNAT OS_Lib g-os_lib ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-perfect-hash-generators-g-pehage-ads}@anchor{396}@anchor{gnat_rm/the_gnat_library id88}@anchor{397} +@anchor{gnat_rm/the_gnat_library gnat-perfect-hash-generators-g-pehage-ads}@anchor{395}@anchor{gnat_rm/the_gnat_library id88}@anchor{396} @section @code{GNAT.Perfect_Hash_Generators} (@code{g-pehage.ads}) @@ -24655,7 +24645,7 @@ hashcode are in the same order. These hashing functions are very convenient for use with realtime applications. @node GNAT Random_Numbers g-rannum ads,GNAT Regexp g-regexp ads,GNAT Perfect_Hash_Generators g-pehage ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-random-numbers-g-rannum-ads}@anchor{398}@anchor{gnat_rm/the_gnat_library id89}@anchor{399} +@anchor{gnat_rm/the_gnat_library gnat-random-numbers-g-rannum-ads}@anchor{397}@anchor{gnat_rm/the_gnat_library id89}@anchor{398} @section @code{GNAT.Random_Numbers} (@code{g-rannum.ads}) @@ -24667,7 +24657,7 @@ Provides random number capabilities which extend those available in the standard Ada library and are more convenient to use. @node GNAT Regexp g-regexp ads,GNAT Registry g-regist ads,GNAT Random_Numbers g-rannum ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-regexp-g-regexp-ads}@anchor{26f}@anchor{gnat_rm/the_gnat_library id90}@anchor{39a} +@anchor{gnat_rm/the_gnat_library gnat-regexp-g-regexp-ads}@anchor{26e}@anchor{gnat_rm/the_gnat_library id90}@anchor{399} @section @code{GNAT.Regexp} (@code{g-regexp.ads}) @@ -24683,7 +24673,7 @@ simplest of the three pattern matching packages provided, and is particularly suitable for ‘file globbing’ applications. @node GNAT Registry g-regist ads,GNAT Regpat g-regpat ads,GNAT Regexp g-regexp ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-registry-g-regist-ads}@anchor{39b}@anchor{gnat_rm/the_gnat_library id91}@anchor{39c} +@anchor{gnat_rm/the_gnat_library gnat-registry-g-regist-ads}@anchor{39a}@anchor{gnat_rm/the_gnat_library id91}@anchor{39b} @section @code{GNAT.Registry} (@code{g-regist.ads}) @@ -24697,7 +24687,7 @@ registry API, but at a lower level of abstraction, refer to the Win32.Winreg package provided with the Win32Ada binding @node GNAT Regpat g-regpat ads,GNAT Rewrite_Data g-rewdat ads,GNAT Registry g-regist ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-regpat-g-regpat-ads}@anchor{39d}@anchor{gnat_rm/the_gnat_library id92}@anchor{39e} +@anchor{gnat_rm/the_gnat_library gnat-regpat-g-regpat-ads}@anchor{39c}@anchor{gnat_rm/the_gnat_library id92}@anchor{39d} @section @code{GNAT.Regpat} (@code{g-regpat.ads}) @@ -24712,7 +24702,7 @@ from the original V7 style regular expression library written in C by Henry Spencer (and binary compatible with this C library). @node GNAT Rewrite_Data g-rewdat ads,GNAT Secondary_Stack_Info g-sestin ads,GNAT Regpat g-regpat ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-rewrite-data-g-rewdat-ads}@anchor{39f}@anchor{gnat_rm/the_gnat_library id93}@anchor{3a0} +@anchor{gnat_rm/the_gnat_library gnat-rewrite-data-g-rewdat-ads}@anchor{39e}@anchor{gnat_rm/the_gnat_library id93}@anchor{39f} @section @code{GNAT.Rewrite_Data} (@code{g-rewdat.ads}) @@ -24726,7 +24716,7 @@ full content to be processed is not loaded into memory all at once. This makes this interface usable for large files or socket streams. @node GNAT Secondary_Stack_Info g-sestin ads,GNAT Semaphores g-semaph ads,GNAT Rewrite_Data g-rewdat ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-secondary-stack-info-g-sestin-ads}@anchor{3a1}@anchor{gnat_rm/the_gnat_library id94}@anchor{3a2} +@anchor{gnat_rm/the_gnat_library gnat-secondary-stack-info-g-sestin-ads}@anchor{3a0}@anchor{gnat_rm/the_gnat_library id94}@anchor{3a1} @section @code{GNAT.Secondary_Stack_Info} (@code{g-sestin.ads}) @@ -24738,7 +24728,7 @@ Provides the capability to query the high water mark of the current task’s secondary stack. @node GNAT Semaphores g-semaph ads,GNAT Serial_Communications g-sercom ads,GNAT Secondary_Stack_Info g-sestin ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-semaphores-g-semaph-ads}@anchor{3a3}@anchor{gnat_rm/the_gnat_library id95}@anchor{3a4} +@anchor{gnat_rm/the_gnat_library gnat-semaphores-g-semaph-ads}@anchor{3a2}@anchor{gnat_rm/the_gnat_library id95}@anchor{3a3} @section @code{GNAT.Semaphores} (@code{g-semaph.ads}) @@ -24749,7 +24739,7 @@ secondary stack. Provides classic counting and binary semaphores using protected types. @node GNAT Serial_Communications g-sercom ads,GNAT SHA1 g-sha1 ads,GNAT Semaphores g-semaph ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-serial-communications-g-sercom-ads}@anchor{3a5}@anchor{gnat_rm/the_gnat_library id96}@anchor{3a6} +@anchor{gnat_rm/the_gnat_library gnat-serial-communications-g-sercom-ads}@anchor{3a4}@anchor{gnat_rm/the_gnat_library id96}@anchor{3a5} @section @code{GNAT.Serial_Communications} (@code{g-sercom.ads}) @@ -24761,7 +24751,7 @@ Provides a simple interface to send and receive data over a serial port. This is only supported on GNU/Linux and Windows. @node GNAT SHA1 g-sha1 ads,GNAT SHA224 g-sha224 ads,GNAT Serial_Communications g-sercom ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-sha1-g-sha1-ads}@anchor{3a7}@anchor{gnat_rm/the_gnat_library id97}@anchor{3a8} +@anchor{gnat_rm/the_gnat_library gnat-sha1-g-sha1-ads}@anchor{3a6}@anchor{gnat_rm/the_gnat_library id97}@anchor{3a7} @section @code{GNAT.SHA1} (@code{g-sha1.ads}) @@ -24774,7 +24764,7 @@ and RFC 3174, and the HMAC-SHA1 message authentication function as described in RFC 2104 and FIPS PUB 198. @node GNAT SHA224 g-sha224 ads,GNAT SHA256 g-sha256 ads,GNAT SHA1 g-sha1 ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-sha224-g-sha224-ads}@anchor{3a9}@anchor{gnat_rm/the_gnat_library id98}@anchor{3aa} +@anchor{gnat_rm/the_gnat_library gnat-sha224-g-sha224-ads}@anchor{3a8}@anchor{gnat_rm/the_gnat_library id98}@anchor{3a9} @section @code{GNAT.SHA224} (@code{g-sha224.ads}) @@ -24787,7 +24777,7 @@ and the HMAC-SHA224 message authentication function as described in RFC 2104 and FIPS PUB 198. @node GNAT SHA256 g-sha256 ads,GNAT SHA384 g-sha384 ads,GNAT SHA224 g-sha224 ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-sha256-g-sha256-ads}@anchor{3ab}@anchor{gnat_rm/the_gnat_library id99}@anchor{3ac} +@anchor{gnat_rm/the_gnat_library gnat-sha256-g-sha256-ads}@anchor{3aa}@anchor{gnat_rm/the_gnat_library id99}@anchor{3ab} @section @code{GNAT.SHA256} (@code{g-sha256.ads}) @@ -24800,7 +24790,7 @@ and the HMAC-SHA256 message authentication function as described in RFC 2104 and FIPS PUB 198. @node GNAT SHA384 g-sha384 ads,GNAT SHA512 g-sha512 ads,GNAT SHA256 g-sha256 ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-sha384-g-sha384-ads}@anchor{3ad}@anchor{gnat_rm/the_gnat_library id100}@anchor{3ae} +@anchor{gnat_rm/the_gnat_library gnat-sha384-g-sha384-ads}@anchor{3ac}@anchor{gnat_rm/the_gnat_library id100}@anchor{3ad} @section @code{GNAT.SHA384} (@code{g-sha384.ads}) @@ -24813,7 +24803,7 @@ and the HMAC-SHA384 message authentication function as described in RFC 2104 and FIPS PUB 198. @node GNAT SHA512 g-sha512 ads,GNAT Signals g-signal ads,GNAT SHA384 g-sha384 ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-sha512-g-sha512-ads}@anchor{3af}@anchor{gnat_rm/the_gnat_library id101}@anchor{3b0} +@anchor{gnat_rm/the_gnat_library gnat-sha512-g-sha512-ads}@anchor{3ae}@anchor{gnat_rm/the_gnat_library id101}@anchor{3af} @section @code{GNAT.SHA512} (@code{g-sha512.ads}) @@ -24826,7 +24816,7 @@ and the HMAC-SHA512 message authentication function as described in RFC 2104 and FIPS PUB 198. @node GNAT Signals g-signal ads,GNAT Sockets g-socket ads,GNAT SHA512 g-sha512 ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-signals-g-signal-ads}@anchor{3b1}@anchor{gnat_rm/the_gnat_library id102}@anchor{3b2} +@anchor{gnat_rm/the_gnat_library gnat-signals-g-signal-ads}@anchor{3b0}@anchor{gnat_rm/the_gnat_library id102}@anchor{3b1} @section @code{GNAT.Signals} (@code{g-signal.ads}) @@ -24838,7 +24828,7 @@ Provides the ability to manipulate the blocked status of signals on supported targets. @node GNAT Sockets g-socket ads,GNAT Source_Info g-souinf ads,GNAT Signals g-signal ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-sockets-g-socket-ads}@anchor{3b3}@anchor{gnat_rm/the_gnat_library id103}@anchor{3b4} +@anchor{gnat_rm/the_gnat_library gnat-sockets-g-socket-ads}@anchor{3b2}@anchor{gnat_rm/the_gnat_library id103}@anchor{3b3} @section @code{GNAT.Sockets} (@code{g-socket.ads}) @@ -24853,7 +24843,7 @@ on all native GNAT ports and on VxWorks cross ports. It is not implemented for the LynxOS cross port. @node GNAT Source_Info g-souinf ads,GNAT Spelling_Checker g-speche ads,GNAT Sockets g-socket ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-source-info-g-souinf-ads}@anchor{3b5}@anchor{gnat_rm/the_gnat_library id104}@anchor{3b6} +@anchor{gnat_rm/the_gnat_library gnat-source-info-g-souinf-ads}@anchor{3b4}@anchor{gnat_rm/the_gnat_library id104}@anchor{3b5} @section @code{GNAT.Source_Info} (@code{g-souinf.ads}) @@ -24867,7 +24857,7 @@ subprograms yielding the date and time of the current compilation (like the C macros @code{__DATE__} and @code{__TIME__}) @node GNAT Spelling_Checker g-speche ads,GNAT Spelling_Checker_Generic g-spchge ads,GNAT Source_Info g-souinf ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-spelling-checker-g-speche-ads}@anchor{3b7}@anchor{gnat_rm/the_gnat_library id105}@anchor{3b8} +@anchor{gnat_rm/the_gnat_library gnat-spelling-checker-g-speche-ads}@anchor{3b6}@anchor{gnat_rm/the_gnat_library id105}@anchor{3b7} @section @code{GNAT.Spelling_Checker} (@code{g-speche.ads}) @@ -24879,7 +24869,7 @@ Provides a function for determining whether one string is a plausible near misspelling of another string. @node GNAT Spelling_Checker_Generic g-spchge ads,GNAT Spitbol Patterns g-spipat ads,GNAT Spelling_Checker g-speche ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-spelling-checker-generic-g-spchge-ads}@anchor{3b9}@anchor{gnat_rm/the_gnat_library id106}@anchor{3ba} +@anchor{gnat_rm/the_gnat_library gnat-spelling-checker-generic-g-spchge-ads}@anchor{3b8}@anchor{gnat_rm/the_gnat_library id106}@anchor{3b9} @section @code{GNAT.Spelling_Checker_Generic} (@code{g-spchge.ads}) @@ -24892,7 +24882,7 @@ determining whether one string is a plausible near misspelling of another string. @node GNAT Spitbol Patterns g-spipat ads,GNAT Spitbol g-spitbo ads,GNAT Spelling_Checker_Generic g-spchge ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-spitbol-patterns-g-spipat-ads}@anchor{3bb}@anchor{gnat_rm/the_gnat_library id107}@anchor{3bc} +@anchor{gnat_rm/the_gnat_library gnat-spitbol-patterns-g-spipat-ads}@anchor{3ba}@anchor{gnat_rm/the_gnat_library id107}@anchor{3bb} @section @code{GNAT.Spitbol.Patterns} (@code{g-spipat.ads}) @@ -24908,7 +24898,7 @@ the SNOBOL4 dynamic pattern construction and matching capabilities, using the efficient algorithm developed by Robert Dewar for the SPITBOL system. @node GNAT Spitbol g-spitbo ads,GNAT Spitbol Table_Boolean g-sptabo ads,GNAT Spitbol Patterns g-spipat ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-spitbol-g-spitbo-ads}@anchor{3bd}@anchor{gnat_rm/the_gnat_library id108}@anchor{3be} +@anchor{gnat_rm/the_gnat_library gnat-spitbol-g-spitbo-ads}@anchor{3bc}@anchor{gnat_rm/the_gnat_library id108}@anchor{3bd} @section @code{GNAT.Spitbol} (@code{g-spitbo.ads}) @@ -24923,7 +24913,7 @@ useful for constructing arbitrary mappings from strings in the style of the SNOBOL4 TABLE function. @node GNAT Spitbol Table_Boolean g-sptabo ads,GNAT Spitbol Table_Integer g-sptain ads,GNAT Spitbol g-spitbo ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-spitbol-table-boolean-g-sptabo-ads}@anchor{3bf}@anchor{gnat_rm/the_gnat_library id109}@anchor{3c0} +@anchor{gnat_rm/the_gnat_library gnat-spitbol-table-boolean-g-sptabo-ads}@anchor{3be}@anchor{gnat_rm/the_gnat_library id109}@anchor{3bf} @section @code{GNAT.Spitbol.Table_Boolean} (@code{g-sptabo.ads}) @@ -24938,7 +24928,7 @@ for type @code{Standard.Boolean}, giving an implementation of sets of string values. @node GNAT Spitbol Table_Integer g-sptain ads,GNAT Spitbol Table_VString g-sptavs ads,GNAT Spitbol Table_Boolean g-sptabo ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-spitbol-table-integer-g-sptain-ads}@anchor{3c1}@anchor{gnat_rm/the_gnat_library id110}@anchor{3c2} +@anchor{gnat_rm/the_gnat_library gnat-spitbol-table-integer-g-sptain-ads}@anchor{3c0}@anchor{gnat_rm/the_gnat_library id110}@anchor{3c1} @section @code{GNAT.Spitbol.Table_Integer} (@code{g-sptain.ads}) @@ -24955,7 +24945,7 @@ for type @code{Standard.Integer}, giving an implementation of maps from string to integer values. @node GNAT Spitbol Table_VString g-sptavs ads,GNAT SSE g-sse ads,GNAT Spitbol Table_Integer g-sptain ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-spitbol-table-vstring-g-sptavs-ads}@anchor{3c3}@anchor{gnat_rm/the_gnat_library id111}@anchor{3c4} +@anchor{gnat_rm/the_gnat_library gnat-spitbol-table-vstring-g-sptavs-ads}@anchor{3c2}@anchor{gnat_rm/the_gnat_library id111}@anchor{3c3} @section @code{GNAT.Spitbol.Table_VString} (@code{g-sptavs.ads}) @@ -24972,7 +24962,7 @@ a variable length string type, giving an implementation of general maps from strings to strings. @node GNAT SSE g-sse ads,GNAT SSE Vector_Types g-ssvety ads,GNAT Spitbol Table_VString g-sptavs ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-sse-g-sse-ads}@anchor{3c5}@anchor{gnat_rm/the_gnat_library id112}@anchor{3c6} +@anchor{gnat_rm/the_gnat_library gnat-sse-g-sse-ads}@anchor{3c4}@anchor{gnat_rm/the_gnat_library id112}@anchor{3c5} @section @code{GNAT.SSE} (@code{g-sse.ads}) @@ -24984,7 +24974,7 @@ targets. It exposes vector component types together with a general introduction to the binding contents and use. @node GNAT SSE Vector_Types g-ssvety ads,GNAT String_Hash g-strhas ads,GNAT SSE g-sse ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-sse-vector-types-g-ssvety-ads}@anchor{3c7}@anchor{gnat_rm/the_gnat_library id113}@anchor{3c8} +@anchor{gnat_rm/the_gnat_library gnat-sse-vector-types-g-ssvety-ads}@anchor{3c6}@anchor{gnat_rm/the_gnat_library id113}@anchor{3c7} @section @code{GNAT.SSE.Vector_Types} (@code{g-ssvety.ads}) @@ -24993,7 +24983,7 @@ introduction to the binding contents and use. SSE vector types for use with SSE related intrinsics. @node GNAT String_Hash g-strhas ads,GNAT Strings g-string ads,GNAT SSE Vector_Types g-ssvety ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-string-hash-g-strhas-ads}@anchor{3c9}@anchor{gnat_rm/the_gnat_library id114}@anchor{3ca} +@anchor{gnat_rm/the_gnat_library gnat-string-hash-g-strhas-ads}@anchor{3c8}@anchor{gnat_rm/the_gnat_library id114}@anchor{3c9} @section @code{GNAT.String_Hash} (@code{g-strhas.ads}) @@ -25005,7 +24995,7 @@ Provides a generic hash function working on arrays of scalars. Both the scalar type and the hash result type are parameters. @node GNAT Strings g-string ads,GNAT String_Split g-strspl ads,GNAT String_Hash g-strhas ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-strings-g-string-ads}@anchor{3cb}@anchor{gnat_rm/the_gnat_library id115}@anchor{3cc} +@anchor{gnat_rm/the_gnat_library gnat-strings-g-string-ads}@anchor{3ca}@anchor{gnat_rm/the_gnat_library id115}@anchor{3cb} @section @code{GNAT.Strings} (@code{g-string.ads}) @@ -25015,7 +25005,7 @@ Common String access types and related subprograms. Basically it defines a string access and an array of string access types. @node GNAT String_Split g-strspl ads,GNAT Table g-table ads,GNAT Strings g-string ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-string-split-g-strspl-ads}@anchor{3cd}@anchor{gnat_rm/the_gnat_library id116}@anchor{3ce} +@anchor{gnat_rm/the_gnat_library gnat-string-split-g-strspl-ads}@anchor{3cc}@anchor{gnat_rm/the_gnat_library id116}@anchor{3cd} @section @code{GNAT.String_Split} (@code{g-strspl.ads}) @@ -25029,7 +25019,7 @@ to the resulting slices. This package is instantiated from @code{GNAT.Array_Split}. @node GNAT Table g-table ads,GNAT Task_Lock g-tasloc ads,GNAT String_Split g-strspl ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-table-g-table-ads}@anchor{3cf}@anchor{gnat_rm/the_gnat_library id117}@anchor{3d0} +@anchor{gnat_rm/the_gnat_library gnat-table-g-table-ads}@anchor{3ce}@anchor{gnat_rm/the_gnat_library id117}@anchor{3cf} @section @code{GNAT.Table} (@code{g-table.ads}) @@ -25049,7 +25039,7 @@ while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be used to define dynamic instances of the table. @node GNAT Task_Lock g-tasloc ads,GNAT Time_Stamp g-timsta ads,GNAT Table g-table ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-task-lock-g-tasloc-ads}@anchor{3d1}@anchor{gnat_rm/the_gnat_library id118}@anchor{3d2} +@anchor{gnat_rm/the_gnat_library gnat-task-lock-g-tasloc-ads}@anchor{3d0}@anchor{gnat_rm/the_gnat_library id118}@anchor{3d1} @section @code{GNAT.Task_Lock} (@code{g-tasloc.ads}) @@ -25066,7 +25056,7 @@ single global task lock. Appropriate for use in situations where contention between tasks is very rarely expected. @node GNAT Time_Stamp g-timsta ads,GNAT Threads g-thread ads,GNAT Task_Lock g-tasloc ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-time-stamp-g-timsta-ads}@anchor{3d3}@anchor{gnat_rm/the_gnat_library id119}@anchor{3d4} +@anchor{gnat_rm/the_gnat_library gnat-time-stamp-g-timsta-ads}@anchor{3d2}@anchor{gnat_rm/the_gnat_library id119}@anchor{3d3} @section @code{GNAT.Time_Stamp} (@code{g-timsta.ads}) @@ -25081,7 +25071,7 @@ represents the current date and time in ISO 8601 format. This is a very simple routine with minimal code and there are no dependencies on any other unit. @node GNAT Threads g-thread ads,GNAT Traceback g-traceb ads,GNAT Time_Stamp g-timsta ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-threads-g-thread-ads}@anchor{3d5}@anchor{gnat_rm/the_gnat_library id120}@anchor{3d6} +@anchor{gnat_rm/the_gnat_library gnat-threads-g-thread-ads}@anchor{3d4}@anchor{gnat_rm/the_gnat_library id120}@anchor{3d5} @section @code{GNAT.Threads} (@code{g-thread.ads}) @@ -25098,7 +25088,7 @@ further details if your program has threads that are created by a non-Ada environment which then accesses Ada code. @node GNAT Traceback g-traceb ads,GNAT Traceback Symbolic g-trasym ads,GNAT Threads g-thread ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-traceback-g-traceb-ads}@anchor{3d7}@anchor{gnat_rm/the_gnat_library id121}@anchor{3d8} +@anchor{gnat_rm/the_gnat_library gnat-traceback-g-traceb-ads}@anchor{3d6}@anchor{gnat_rm/the_gnat_library id121}@anchor{3d7} @section @code{GNAT.Traceback} (@code{g-traceb.ads}) @@ -25110,7 +25100,7 @@ Provides a facility for obtaining non-symbolic traceback information, useful in various debugging situations. @node GNAT Traceback Symbolic g-trasym ads,GNAT UTF_32 g-utf_32 ads,GNAT Traceback g-traceb ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-traceback-symbolic-g-trasym-ads}@anchor{3d9}@anchor{gnat_rm/the_gnat_library id122}@anchor{3da} +@anchor{gnat_rm/the_gnat_library gnat-traceback-symbolic-g-trasym-ads}@anchor{3d8}@anchor{gnat_rm/the_gnat_library id122}@anchor{3d9} @section @code{GNAT.Traceback.Symbolic} (@code{g-trasym.ads}) @@ -25119,7 +25109,7 @@ in various debugging situations. @geindex Trace back facilities @node GNAT UTF_32 g-utf_32 ads,GNAT UTF_32_Spelling_Checker g-u3spch ads,GNAT Traceback Symbolic g-trasym ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-utf-32-g-utf-32-ads}@anchor{3db}@anchor{gnat_rm/the_gnat_library id123}@anchor{3dc} +@anchor{gnat_rm/the_gnat_library gnat-utf-32-g-utf-32-ads}@anchor{3da}@anchor{gnat_rm/the_gnat_library id123}@anchor{3db} @section @code{GNAT.UTF_32} (@code{g-utf_32.ads}) @@ -25138,7 +25128,7 @@ lower case to upper case fold routine corresponding to the Ada 2005 rules for identifier equivalence. @node GNAT UTF_32_Spelling_Checker g-u3spch ads,GNAT Wide_Spelling_Checker g-wispch ads,GNAT UTF_32 g-utf_32 ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-utf-32-spelling-checker-g-u3spch-ads}@anchor{3dd}@anchor{gnat_rm/the_gnat_library id124}@anchor{3de} +@anchor{gnat_rm/the_gnat_library gnat-utf-32-spelling-checker-g-u3spch-ads}@anchor{3dc}@anchor{gnat_rm/the_gnat_library id124}@anchor{3dd} @section @code{GNAT.UTF_32_Spelling_Checker} (@code{g-u3spch.ads}) @@ -25151,7 +25141,7 @@ near misspelling of another wide wide string, where the strings are represented using the UTF_32_String type defined in System.Wch_Cnv. @node GNAT Wide_Spelling_Checker g-wispch ads,GNAT Wide_String_Split g-wistsp ads,GNAT UTF_32_Spelling_Checker g-u3spch ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-wide-spelling-checker-g-wispch-ads}@anchor{3df}@anchor{gnat_rm/the_gnat_library id125}@anchor{3e0} +@anchor{gnat_rm/the_gnat_library gnat-wide-spelling-checker-g-wispch-ads}@anchor{3de}@anchor{gnat_rm/the_gnat_library id125}@anchor{3df} @section @code{GNAT.Wide_Spelling_Checker} (@code{g-wispch.ads}) @@ -25163,7 +25153,7 @@ Provides a function for determining whether one wide string is a plausible near misspelling of another wide string. @node GNAT Wide_String_Split g-wistsp ads,GNAT Wide_Wide_Spelling_Checker g-zspche ads,GNAT Wide_Spelling_Checker g-wispch ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-wide-string-split-g-wistsp-ads}@anchor{3e1}@anchor{gnat_rm/the_gnat_library id126}@anchor{3e2} +@anchor{gnat_rm/the_gnat_library gnat-wide-string-split-g-wistsp-ads}@anchor{3e0}@anchor{gnat_rm/the_gnat_library id126}@anchor{3e1} @section @code{GNAT.Wide_String_Split} (@code{g-wistsp.ads}) @@ -25177,7 +25167,7 @@ to the resulting slices. This package is instantiated from @code{GNAT.Array_Split}. @node GNAT Wide_Wide_Spelling_Checker g-zspche ads,GNAT Wide_Wide_String_Split g-zistsp ads,GNAT Wide_String_Split g-wistsp ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-wide-wide-spelling-checker-g-zspche-ads}@anchor{3e3}@anchor{gnat_rm/the_gnat_library id127}@anchor{3e4} +@anchor{gnat_rm/the_gnat_library gnat-wide-wide-spelling-checker-g-zspche-ads}@anchor{3e2}@anchor{gnat_rm/the_gnat_library id127}@anchor{3e3} @section @code{GNAT.Wide_Wide_Spelling_Checker} (@code{g-zspche.ads}) @@ -25189,7 +25179,7 @@ Provides a function for determining whether one wide wide string is a plausible near misspelling of another wide wide string. @node GNAT Wide_Wide_String_Split g-zistsp ads,Interfaces C Extensions i-cexten ads,GNAT Wide_Wide_Spelling_Checker g-zspche ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library gnat-wide-wide-string-split-g-zistsp-ads}@anchor{3e5}@anchor{gnat_rm/the_gnat_library id128}@anchor{3e6} +@anchor{gnat_rm/the_gnat_library gnat-wide-wide-string-split-g-zistsp-ads}@anchor{3e4}@anchor{gnat_rm/the_gnat_library id128}@anchor{3e5} @section @code{GNAT.Wide_Wide_String_Split} (@code{g-zistsp.ads}) @@ -25203,7 +25193,7 @@ to the resulting slices. This package is instantiated from @code{GNAT.Array_Split}. @node Interfaces C Extensions i-cexten ads,Interfaces C Streams i-cstrea ads,GNAT Wide_Wide_String_Split g-zistsp ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library id129}@anchor{3e7}@anchor{gnat_rm/the_gnat_library interfaces-c-extensions-i-cexten-ads}@anchor{3e8} +@anchor{gnat_rm/the_gnat_library id129}@anchor{3e6}@anchor{gnat_rm/the_gnat_library interfaces-c-extensions-i-cexten-ads}@anchor{3e7} @section @code{Interfaces.C.Extensions} (@code{i-cexten.ads}) @@ -25214,7 +25204,7 @@ for use with either manually or automatically generated bindings to C libraries. @node Interfaces C Streams i-cstrea ads,Interfaces Packed_Decimal i-pacdec ads,Interfaces C Extensions i-cexten ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library id130}@anchor{3e9}@anchor{gnat_rm/the_gnat_library interfaces-c-streams-i-cstrea-ads}@anchor{3ea} +@anchor{gnat_rm/the_gnat_library id130}@anchor{3e8}@anchor{gnat_rm/the_gnat_library interfaces-c-streams-i-cstrea-ads}@anchor{3e9} @section @code{Interfaces.C.Streams} (@code{i-cstrea.ads}) @@ -25227,7 +25217,7 @@ This package is a binding for the most commonly used operations on C streams. @node Interfaces Packed_Decimal i-pacdec ads,Interfaces VxWorks i-vxwork ads,Interfaces C Streams i-cstrea ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library id131}@anchor{3eb}@anchor{gnat_rm/the_gnat_library interfaces-packed-decimal-i-pacdec-ads}@anchor{3ec} +@anchor{gnat_rm/the_gnat_library id131}@anchor{3ea}@anchor{gnat_rm/the_gnat_library interfaces-packed-decimal-i-pacdec-ads}@anchor{3eb} @section @code{Interfaces.Packed_Decimal} (@code{i-pacdec.ads}) @@ -25242,7 +25232,7 @@ from a packed decimal format compatible with that used on IBM mainframes. @node Interfaces VxWorks i-vxwork ads,Interfaces VxWorks IO i-vxwoio ads,Interfaces Packed_Decimal i-pacdec ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library id132}@anchor{3ed}@anchor{gnat_rm/the_gnat_library interfaces-vxworks-i-vxwork-ads}@anchor{3ee} +@anchor{gnat_rm/the_gnat_library id132}@anchor{3ec}@anchor{gnat_rm/the_gnat_library interfaces-vxworks-i-vxwork-ads}@anchor{3ed} @section @code{Interfaces.VxWorks} (@code{i-vxwork.ads}) @@ -25256,7 +25246,7 @@ mainframes. This package provides a limited binding to the VxWorks API. @node Interfaces VxWorks IO i-vxwoio ads,System Address_Image s-addima ads,Interfaces VxWorks i-vxwork ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library id133}@anchor{3ef}@anchor{gnat_rm/the_gnat_library interfaces-vxworks-io-i-vxwoio-ads}@anchor{3f0} +@anchor{gnat_rm/the_gnat_library id133}@anchor{3ee}@anchor{gnat_rm/the_gnat_library interfaces-vxworks-io-i-vxwoio-ads}@anchor{3ef} @section @code{Interfaces.VxWorks.IO} (@code{i-vxwoio.ads}) @@ -25279,7 +25269,7 @@ function codes. A particular use of this package is to enable the use of Get_Immediate under VxWorks. @node System Address_Image s-addima ads,System Assertions s-assert ads,Interfaces VxWorks IO i-vxwoio ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library id134}@anchor{3f1}@anchor{gnat_rm/the_gnat_library system-address-image-s-addima-ads}@anchor{3f2} +@anchor{gnat_rm/the_gnat_library id134}@anchor{3f0}@anchor{gnat_rm/the_gnat_library system-address-image-s-addima-ads}@anchor{3f1} @section @code{System.Address_Image} (@code{s-addima.ads}) @@ -25295,7 +25285,7 @@ function that gives an (implementation dependent) string which identifies an address. @node System Assertions s-assert ads,System Atomic_Counters s-atocou ads,System Address_Image s-addima ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library id135}@anchor{3f3}@anchor{gnat_rm/the_gnat_library system-assertions-s-assert-ads}@anchor{3f4} +@anchor{gnat_rm/the_gnat_library id135}@anchor{3f2}@anchor{gnat_rm/the_gnat_library system-assertions-s-assert-ads}@anchor{3f3} @section @code{System.Assertions} (@code{s-assert.ads}) @@ -25311,7 +25301,7 @@ by an run-time assertion failure, as well as the routine that is used internally to raise this assertion. @node System Atomic_Counters s-atocou ads,System Memory s-memory ads,System Assertions s-assert ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library id136}@anchor{3f5}@anchor{gnat_rm/the_gnat_library system-atomic-counters-s-atocou-ads}@anchor{3f6} +@anchor{gnat_rm/the_gnat_library id136}@anchor{3f4}@anchor{gnat_rm/the_gnat_library system-atomic-counters-s-atocou-ads}@anchor{3f5} @section @code{System.Atomic_Counters} (@code{s-atocou.ads}) @@ -25325,7 +25315,7 @@ on most targets, including all Alpha, AARCH64, ARM, ia64, PowerPC, SPARC V9, x86, and x86_64 platforms. @node System Memory s-memory ads,System Multiprocessors s-multip ads,System Atomic_Counters s-atocou ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library id137}@anchor{3f7}@anchor{gnat_rm/the_gnat_library system-memory-s-memory-ads}@anchor{3f8} +@anchor{gnat_rm/the_gnat_library id137}@anchor{3f6}@anchor{gnat_rm/the_gnat_library system-memory-s-memory-ads}@anchor{3f7} @section @code{System.Memory} (@code{s-memory.ads}) @@ -25343,7 +25333,7 @@ calls to this unit may be made for low level allocation uses (for example see the body of @code{GNAT.Tables}). @node System Multiprocessors s-multip ads,System Multiprocessors Dispatching_Domains s-mudido ads,System Memory s-memory ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library id138}@anchor{3f9}@anchor{gnat_rm/the_gnat_library system-multiprocessors-s-multip-ads}@anchor{3fa} +@anchor{gnat_rm/the_gnat_library id138}@anchor{3f8}@anchor{gnat_rm/the_gnat_library system-multiprocessors-s-multip-ads}@anchor{3f9} @section @code{System.Multiprocessors} (@code{s-multip.ads}) @@ -25356,7 +25346,7 @@ in GNAT we also make it available in Ada 95 and Ada 2005 (where it is technically an implementation-defined addition). @node System Multiprocessors Dispatching_Domains s-mudido ads,System Partition_Interface s-parint ads,System Multiprocessors s-multip ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library id139}@anchor{3fb}@anchor{gnat_rm/the_gnat_library system-multiprocessors-dispatching-domains-s-mudido-ads}@anchor{3fc} +@anchor{gnat_rm/the_gnat_library id139}@anchor{3fa}@anchor{gnat_rm/the_gnat_library system-multiprocessors-dispatching-domains-s-mudido-ads}@anchor{3fb} @section @code{System.Multiprocessors.Dispatching_Domains} (@code{s-mudido.ads}) @@ -25369,7 +25359,7 @@ in GNAT we also make it available in Ada 95 and Ada 2005 (where it is technically an implementation-defined addition). @node System Partition_Interface s-parint ads,System Pool_Global s-pooglo ads,System Multiprocessors Dispatching_Domains s-mudido ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library id140}@anchor{3fd}@anchor{gnat_rm/the_gnat_library system-partition-interface-s-parint-ads}@anchor{3fe} +@anchor{gnat_rm/the_gnat_library id140}@anchor{3fc}@anchor{gnat_rm/the_gnat_library system-partition-interface-s-parint-ads}@anchor{3fd} @section @code{System.Partition_Interface} (@code{s-parint.ads}) @@ -25382,7 +25372,7 @@ is used primarily in a distribution context when using Annex E with @code{GLADE}. @node System Pool_Global s-pooglo ads,System Pool_Local s-pooloc ads,System Partition_Interface s-parint ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library id141}@anchor{3ff}@anchor{gnat_rm/the_gnat_library system-pool-global-s-pooglo-ads}@anchor{400} +@anchor{gnat_rm/the_gnat_library id141}@anchor{3fe}@anchor{gnat_rm/the_gnat_library system-pool-global-s-pooglo-ads}@anchor{3ff} @section @code{System.Pool_Global} (@code{s-pooglo.ads}) @@ -25399,7 +25389,7 @@ declared. It uses malloc/free to allocate/free and does not attempt to do any automatic reclamation. @node System Pool_Local s-pooloc ads,System Restrictions s-restri ads,System Pool_Global s-pooglo ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library id142}@anchor{401}@anchor{gnat_rm/the_gnat_library system-pool-local-s-pooloc-ads}@anchor{402} +@anchor{gnat_rm/the_gnat_library id142}@anchor{400}@anchor{gnat_rm/the_gnat_library system-pool-local-s-pooloc-ads}@anchor{401} @section @code{System.Pool_Local} (@code{s-pooloc.ads}) @@ -25416,7 +25406,7 @@ a list of allocated blocks, so that all storage allocated for the pool can be freed automatically when the pool is finalized. @node System Restrictions s-restri ads,System Rident s-rident ads,System Pool_Local s-pooloc ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library id143}@anchor{403}@anchor{gnat_rm/the_gnat_library system-restrictions-s-restri-ads}@anchor{404} +@anchor{gnat_rm/the_gnat_library id143}@anchor{402}@anchor{gnat_rm/the_gnat_library system-restrictions-s-restri-ads}@anchor{403} @section @code{System.Restrictions} (@code{s-restri.ads}) @@ -25432,7 +25422,7 @@ compiler determined information on which restrictions are violated by one or more packages in the partition. @node System Rident s-rident ads,System Strings Stream_Ops s-ststop ads,System Restrictions s-restri ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library id144}@anchor{405}@anchor{gnat_rm/the_gnat_library system-rident-s-rident-ads}@anchor{406} +@anchor{gnat_rm/the_gnat_library id144}@anchor{404}@anchor{gnat_rm/the_gnat_library system-rident-s-rident-ads}@anchor{405} @section @code{System.Rident} (@code{s-rident.ads}) @@ -25448,7 +25438,7 @@ since the necessary instantiation is included in package System.Restrictions. @node System Strings Stream_Ops s-ststop ads,System Unsigned_Types s-unstyp ads,System Rident s-rident ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library id145}@anchor{407}@anchor{gnat_rm/the_gnat_library system-strings-stream-ops-s-ststop-ads}@anchor{408} +@anchor{gnat_rm/the_gnat_library id145}@anchor{406}@anchor{gnat_rm/the_gnat_library system-strings-stream-ops-s-ststop-ads}@anchor{407} @section @code{System.Strings.Stream_Ops} (@code{s-ststop.ads}) @@ -25464,7 +25454,7 @@ stream attributes are applied to string types, but the subprograms in this package can be used directly by application programs. @node System Unsigned_Types s-unstyp ads,System Wch_Cnv s-wchcnv ads,System Strings Stream_Ops s-ststop ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library id146}@anchor{409}@anchor{gnat_rm/the_gnat_library system-unsigned-types-s-unstyp-ads}@anchor{40a} +@anchor{gnat_rm/the_gnat_library id146}@anchor{408}@anchor{gnat_rm/the_gnat_library system-unsigned-types-s-unstyp-ads}@anchor{409} @section @code{System.Unsigned_Types} (@code{s-unstyp.ads}) @@ -25477,7 +25467,7 @@ also contains some related definitions for other specialized types used by the compiler in connection with packed array types. @node System Wch_Cnv s-wchcnv ads,System Wch_Con s-wchcon ads,System Unsigned_Types s-unstyp ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library id147}@anchor{40b}@anchor{gnat_rm/the_gnat_library system-wch-cnv-s-wchcnv-ads}@anchor{40c} +@anchor{gnat_rm/the_gnat_library id147}@anchor{40a}@anchor{gnat_rm/the_gnat_library system-wch-cnv-s-wchcnv-ads}@anchor{40b} @section @code{System.Wch_Cnv} (@code{s-wchcnv.ads}) @@ -25498,7 +25488,7 @@ encoding method. It uses definitions in package @code{System.Wch_Con}. @node System Wch_Con s-wchcon ads,,System Wch_Cnv s-wchcnv ads,The GNAT Library -@anchor{gnat_rm/the_gnat_library id148}@anchor{40d}@anchor{gnat_rm/the_gnat_library system-wch-con-s-wchcon-ads}@anchor{40e} +@anchor{gnat_rm/the_gnat_library id148}@anchor{40c}@anchor{gnat_rm/the_gnat_library system-wch-con-s-wchcon-ads}@anchor{40d} @section @code{System.Wch_Con} (@code{s-wchcon.ads}) @@ -25510,7 +25500,7 @@ in ordinary strings. These definitions are used by the package @code{System.Wch_Cnv}. @node Interfacing to Other Languages,Specialized Needs Annexes,The GNAT Library,Top -@anchor{gnat_rm/interfacing_to_other_languages doc}@anchor{40f}@anchor{gnat_rm/interfacing_to_other_languages id1}@anchor{410}@anchor{gnat_rm/interfacing_to_other_languages interfacing-to-other-languages}@anchor{11} +@anchor{gnat_rm/interfacing_to_other_languages doc}@anchor{40e}@anchor{gnat_rm/interfacing_to_other_languages id1}@anchor{40f}@anchor{gnat_rm/interfacing_to_other_languages interfacing-to-other-languages}@anchor{11} @chapter Interfacing to Other Languages @@ -25528,7 +25518,7 @@ provided. @end menu @node Interfacing to C,Interfacing to C++,,Interfacing to Other Languages -@anchor{gnat_rm/interfacing_to_other_languages id2}@anchor{411}@anchor{gnat_rm/interfacing_to_other_languages interfacing-to-c}@anchor{412} +@anchor{gnat_rm/interfacing_to_other_languages id2}@anchor{410}@anchor{gnat_rm/interfacing_to_other_languages interfacing-to-c}@anchor{411} @section Interfacing to C @@ -25668,7 +25658,7 @@ of the length corresponding to the @code{type'Size} value in Ada. @end itemize @node Interfacing to C++,Interfacing to COBOL,Interfacing to C,Interfacing to Other Languages -@anchor{gnat_rm/interfacing_to_other_languages id3}@anchor{49}@anchor{gnat_rm/interfacing_to_other_languages id4}@anchor{413} +@anchor{gnat_rm/interfacing_to_other_languages id3}@anchor{49}@anchor{gnat_rm/interfacing_to_other_languages id4}@anchor{412} @section Interfacing to C++ @@ -25725,7 +25715,7 @@ The @code{External_Name} is the name of the C++ RTTI symbol. You can then cover a specific C++ exception in an exception handler. @node Interfacing to COBOL,Interfacing to Fortran,Interfacing to C++,Interfacing to Other Languages -@anchor{gnat_rm/interfacing_to_other_languages id5}@anchor{414}@anchor{gnat_rm/interfacing_to_other_languages interfacing-to-cobol}@anchor{415} +@anchor{gnat_rm/interfacing_to_other_languages id5}@anchor{413}@anchor{gnat_rm/interfacing_to_other_languages interfacing-to-cobol}@anchor{414} @section Interfacing to COBOL @@ -25733,7 +25723,7 @@ Interfacing to COBOL is achieved as described in section B.4 of the Ada Reference Manual. @node Interfacing to Fortran,Interfacing to non-GNAT Ada code,Interfacing to COBOL,Interfacing to Other Languages -@anchor{gnat_rm/interfacing_to_other_languages id6}@anchor{416}@anchor{gnat_rm/interfacing_to_other_languages interfacing-to-fortran}@anchor{417} +@anchor{gnat_rm/interfacing_to_other_languages id6}@anchor{415}@anchor{gnat_rm/interfacing_to_other_languages interfacing-to-fortran}@anchor{416} @section Interfacing to Fortran @@ -25743,7 +25733,7 @@ multi-dimensional array causes the array to be stored in column-major order as required for convenient interface to Fortran. @node Interfacing to non-GNAT Ada code,,Interfacing to Fortran,Interfacing to Other Languages -@anchor{gnat_rm/interfacing_to_other_languages id7}@anchor{418}@anchor{gnat_rm/interfacing_to_other_languages interfacing-to-non-gnat-ada-code}@anchor{419} +@anchor{gnat_rm/interfacing_to_other_languages id7}@anchor{417}@anchor{gnat_rm/interfacing_to_other_languages interfacing-to-non-gnat-ada-code}@anchor{418} @section Interfacing to non-GNAT Ada code @@ -25767,7 +25757,7 @@ values or simple record types without variants, or simple array types with fixed bounds. @node Specialized Needs Annexes,Implementation of Specific Ada Features,Interfacing to Other Languages,Top -@anchor{gnat_rm/specialized_needs_annexes doc}@anchor{41a}@anchor{gnat_rm/specialized_needs_annexes id1}@anchor{41b}@anchor{gnat_rm/specialized_needs_annexes specialized-needs-annexes}@anchor{12} +@anchor{gnat_rm/specialized_needs_annexes doc}@anchor{419}@anchor{gnat_rm/specialized_needs_annexes id1}@anchor{41a}@anchor{gnat_rm/specialized_needs_annexes specialized-needs-annexes}@anchor{12} @chapter Specialized Needs Annexes @@ -25808,7 +25798,7 @@ in Ada 2005) is fully implemented. @end table @node Implementation of Specific Ada Features,Implementation of Ada 2012 Features,Specialized Needs Annexes,Top -@anchor{gnat_rm/implementation_of_specific_ada_features doc}@anchor{41c}@anchor{gnat_rm/implementation_of_specific_ada_features id1}@anchor{41d}@anchor{gnat_rm/implementation_of_specific_ada_features implementation-of-specific-ada-features}@anchor{13} +@anchor{gnat_rm/implementation_of_specific_ada_features doc}@anchor{41b}@anchor{gnat_rm/implementation_of_specific_ada_features id1}@anchor{41c}@anchor{gnat_rm/implementation_of_specific_ada_features implementation-of-specific-ada-features}@anchor{13} @chapter Implementation of Specific Ada Features @@ -25827,7 +25817,7 @@ facilities. @end menu @node Machine Code Insertions,GNAT Implementation of Tasking,,Implementation of Specific Ada Features -@anchor{gnat_rm/implementation_of_specific_ada_features id2}@anchor{41e}@anchor{gnat_rm/implementation_of_specific_ada_features machine-code-insertions}@anchor{175} +@anchor{gnat_rm/implementation_of_specific_ada_features id2}@anchor{41d}@anchor{gnat_rm/implementation_of_specific_ada_features machine-code-insertions}@anchor{175} @section Machine Code Insertions @@ -25995,7 +25985,7 @@ according to normal visibility rules. In particular if there is no qualification is required. @node GNAT Implementation of Tasking,GNAT Implementation of Shared Passive Packages,Machine Code Insertions,Implementation of Specific Ada Features -@anchor{gnat_rm/implementation_of_specific_ada_features gnat-implementation-of-tasking}@anchor{41f}@anchor{gnat_rm/implementation_of_specific_ada_features id3}@anchor{420} +@anchor{gnat_rm/implementation_of_specific_ada_features gnat-implementation-of-tasking}@anchor{41e}@anchor{gnat_rm/implementation_of_specific_ada_features id3}@anchor{41f} @section GNAT Implementation of Tasking @@ -26011,7 +26001,7 @@ to compliance with the Real-Time Systems Annex. @end menu @node Mapping Ada Tasks onto the Underlying Kernel Threads,Ensuring Compliance with the Real-Time Annex,,GNAT Implementation of Tasking -@anchor{gnat_rm/implementation_of_specific_ada_features id4}@anchor{421}@anchor{gnat_rm/implementation_of_specific_ada_features mapping-ada-tasks-onto-the-underlying-kernel-threads}@anchor{422} +@anchor{gnat_rm/implementation_of_specific_ada_features id4}@anchor{420}@anchor{gnat_rm/implementation_of_specific_ada_features mapping-ada-tasks-onto-the-underlying-kernel-threads}@anchor{421} @subsection Mapping Ada Tasks onto the Underlying Kernel Threads @@ -26080,7 +26070,7 @@ support this functionality when the parent contains more than one task. @geindex Forking a new process @node Ensuring Compliance with the Real-Time Annex,Support for Locking Policies,Mapping Ada Tasks onto the Underlying Kernel Threads,GNAT Implementation of Tasking -@anchor{gnat_rm/implementation_of_specific_ada_features ensuring-compliance-with-the-real-time-annex}@anchor{423}@anchor{gnat_rm/implementation_of_specific_ada_features id5}@anchor{424} +@anchor{gnat_rm/implementation_of_specific_ada_features ensuring-compliance-with-the-real-time-annex}@anchor{422}@anchor{gnat_rm/implementation_of_specific_ada_features id5}@anchor{423} @subsection Ensuring Compliance with the Real-Time Annex @@ -26131,7 +26121,7 @@ placed at the end. @c Support_for_Locking_Policies @node Support for Locking Policies,,Ensuring Compliance with the Real-Time Annex,GNAT Implementation of Tasking -@anchor{gnat_rm/implementation_of_specific_ada_features support-for-locking-policies}@anchor{425} +@anchor{gnat_rm/implementation_of_specific_ada_features support-for-locking-policies}@anchor{424} @subsection Support for Locking Policies @@ -26165,7 +26155,7 @@ then ceiling locking is used. Otherwise, the @code{Ceiling_Locking} policy is ignored. @node GNAT Implementation of Shared Passive Packages,Code Generation for Array Aggregates,GNAT Implementation of Tasking,Implementation of Specific Ada Features -@anchor{gnat_rm/implementation_of_specific_ada_features gnat-implementation-of-shared-passive-packages}@anchor{426}@anchor{gnat_rm/implementation_of_specific_ada_features id6}@anchor{427} +@anchor{gnat_rm/implementation_of_specific_ada_features gnat-implementation-of-shared-passive-packages}@anchor{425}@anchor{gnat_rm/implementation_of_specific_ada_features id6}@anchor{426} @section GNAT Implementation of Shared Passive Packages @@ -26263,7 +26253,7 @@ This is used to provide the required locking semantics for proper protected object synchronization. @node Code Generation for Array Aggregates,The Size of Discriminated Records with Default Discriminants,GNAT Implementation of Shared Passive Packages,Implementation of Specific Ada Features -@anchor{gnat_rm/implementation_of_specific_ada_features code-generation-for-array-aggregates}@anchor{428}@anchor{gnat_rm/implementation_of_specific_ada_features id7}@anchor{429} +@anchor{gnat_rm/implementation_of_specific_ada_features code-generation-for-array-aggregates}@anchor{427}@anchor{gnat_rm/implementation_of_specific_ada_features id7}@anchor{428} @section Code Generation for Array Aggregates @@ -26294,7 +26284,7 @@ component values and static subtypes also lead to simpler code. @end menu @node Static constant aggregates with static bounds,Constant aggregates with unconstrained nominal types,,Code Generation for Array Aggregates -@anchor{gnat_rm/implementation_of_specific_ada_features id8}@anchor{42a}@anchor{gnat_rm/implementation_of_specific_ada_features static-constant-aggregates-with-static-bounds}@anchor{42b} +@anchor{gnat_rm/implementation_of_specific_ada_features id8}@anchor{429}@anchor{gnat_rm/implementation_of_specific_ada_features static-constant-aggregates-with-static-bounds}@anchor{42a} @subsection Static constant aggregates with static bounds @@ -26341,7 +26331,7 @@ Zero2: constant two_dim := (others => (others => 0)); @end example @node Constant aggregates with unconstrained nominal types,Aggregates with static bounds,Static constant aggregates with static bounds,Code Generation for Array Aggregates -@anchor{gnat_rm/implementation_of_specific_ada_features constant-aggregates-with-unconstrained-nominal-types}@anchor{42c}@anchor{gnat_rm/implementation_of_specific_ada_features id9}@anchor{42d} +@anchor{gnat_rm/implementation_of_specific_ada_features constant-aggregates-with-unconstrained-nominal-types}@anchor{42b}@anchor{gnat_rm/implementation_of_specific_ada_features id9}@anchor{42c} @subsection Constant aggregates with unconstrained nominal types @@ -26356,7 +26346,7 @@ Cr_Unc : constant One_Unc := (12,24,36); @end example @node Aggregates with static bounds,Aggregates with nonstatic bounds,Constant aggregates with unconstrained nominal types,Code Generation for Array Aggregates -@anchor{gnat_rm/implementation_of_specific_ada_features aggregates-with-static-bounds}@anchor{42e}@anchor{gnat_rm/implementation_of_specific_ada_features id10}@anchor{42f} +@anchor{gnat_rm/implementation_of_specific_ada_features aggregates-with-static-bounds}@anchor{42d}@anchor{gnat_rm/implementation_of_specific_ada_features id10}@anchor{42e} @subsection Aggregates with static bounds @@ -26384,7 +26374,7 @@ end loop; @end example @node Aggregates with nonstatic bounds,Aggregates in assignment statements,Aggregates with static bounds,Code Generation for Array Aggregates -@anchor{gnat_rm/implementation_of_specific_ada_features aggregates-with-nonstatic-bounds}@anchor{430}@anchor{gnat_rm/implementation_of_specific_ada_features id11}@anchor{431} +@anchor{gnat_rm/implementation_of_specific_ada_features aggregates-with-nonstatic-bounds}@anchor{42f}@anchor{gnat_rm/implementation_of_specific_ada_features id11}@anchor{430} @subsection Aggregates with nonstatic bounds @@ -26395,7 +26385,7 @@ have to be applied to sub-arrays individually, if they do not have statically compatible subtypes. @node Aggregates in assignment statements,,Aggregates with nonstatic bounds,Code Generation for Array Aggregates -@anchor{gnat_rm/implementation_of_specific_ada_features aggregates-in-assignment-statements}@anchor{432}@anchor{gnat_rm/implementation_of_specific_ada_features id12}@anchor{433} +@anchor{gnat_rm/implementation_of_specific_ada_features aggregates-in-assignment-statements}@anchor{431}@anchor{gnat_rm/implementation_of_specific_ada_features id12}@anchor{432} @subsection Aggregates in assignment statements @@ -26437,7 +26427,7 @@ a temporary (created either by the front-end or the code generator) and then that temporary will be copied onto the target. @node The Size of Discriminated Records with Default Discriminants,Image Values For Nonscalar Types,Code Generation for Array Aggregates,Implementation of Specific Ada Features -@anchor{gnat_rm/implementation_of_specific_ada_features id13}@anchor{434}@anchor{gnat_rm/implementation_of_specific_ada_features the-size-of-discriminated-records-with-default-discriminants}@anchor{435} +@anchor{gnat_rm/implementation_of_specific_ada_features id13}@anchor{433}@anchor{gnat_rm/implementation_of_specific_ada_features the-size-of-discriminated-records-with-default-discriminants}@anchor{434} @section The Size of Discriminated Records with Default Discriminants @@ -26517,7 +26507,7 @@ say) must be consistent, so it is imperative that the object, once created, remain invariant. @node Image Values For Nonscalar Types,Strict Conformance to the Ada Reference Manual,The Size of Discriminated Records with Default Discriminants,Implementation of Specific Ada Features -@anchor{gnat_rm/implementation_of_specific_ada_features id14}@anchor{436}@anchor{gnat_rm/implementation_of_specific_ada_features image-values-for-nonscalar-types}@anchor{437} +@anchor{gnat_rm/implementation_of_specific_ada_features id14}@anchor{435}@anchor{gnat_rm/implementation_of_specific_ada_features image-values-for-nonscalar-types}@anchor{436} @section Image Values For Nonscalar Types @@ -26537,7 +26527,7 @@ control of image text is required for some type T, then T’Put_Image should be explicitly specified. @node Strict Conformance to the Ada Reference Manual,,Image Values For Nonscalar Types,Implementation of Specific Ada Features -@anchor{gnat_rm/implementation_of_specific_ada_features id15}@anchor{438}@anchor{gnat_rm/implementation_of_specific_ada_features strict-conformance-to-the-ada-reference-manual}@anchor{439} +@anchor{gnat_rm/implementation_of_specific_ada_features id15}@anchor{437}@anchor{gnat_rm/implementation_of_specific_ada_features strict-conformance-to-the-ada-reference-manual}@anchor{438} @section Strict Conformance to the Ada Reference Manual @@ -26564,7 +26554,7 @@ behavior (although at the cost of a significant performance penalty), so infinite and NaN values are properly generated. @node Implementation of Ada 2012 Features,GNAT language extensions,Implementation of Specific Ada Features,Top -@anchor{gnat_rm/implementation_of_ada_2012_features doc}@anchor{43a}@anchor{gnat_rm/implementation_of_ada_2012_features id1}@anchor{43b}@anchor{gnat_rm/implementation_of_ada_2012_features implementation-of-ada-2012-features}@anchor{14} +@anchor{gnat_rm/implementation_of_ada_2012_features doc}@anchor{439}@anchor{gnat_rm/implementation_of_ada_2012_features id1}@anchor{43a}@anchor{gnat_rm/implementation_of_ada_2012_features implementation-of-ada-2012-features}@anchor{14} @chapter Implementation of Ada 2012 Features @@ -28730,7 +28720,7 @@ RM References: 4.03.01 (17) @end itemize @node GNAT language extensions,Security Hardening Features,Implementation of Ada 2012 Features,Top -@anchor{gnat_rm/gnat_language_extensions doc}@anchor{43c}@anchor{gnat_rm/gnat_language_extensions gnat-language-extensions}@anchor{43d}@anchor{gnat_rm/gnat_language_extensions id1}@anchor{43e} +@anchor{gnat_rm/gnat_language_extensions doc}@anchor{43b}@anchor{gnat_rm/gnat_language_extensions gnat-language-extensions}@anchor{43c}@anchor{gnat_rm/gnat_language_extensions id1}@anchor{43d} @chapter GNAT language extensions @@ -28761,7 +28751,7 @@ prototyping phase. @end menu @node How to activate the extended GNAT Ada superset,Curated Extensions,,GNAT language extensions -@anchor{gnat_rm/gnat_language_extensions how-to-activate-the-extended-gnat-ada-superset}@anchor{43f} +@anchor{gnat_rm/gnat_language_extensions how-to-activate-the-extended-gnat-ada-superset}@anchor{43e} @section How to activate the extended GNAT Ada superset @@ -28800,7 +28790,7 @@ for serious projects, and is only means as a playground/technology preview. @end cartouche @node Curated Extensions,Experimental Language Extensions,How to activate the extended GNAT Ada superset,GNAT language extensions -@anchor{gnat_rm/gnat_language_extensions curated-extensions}@anchor{440}@anchor{gnat_rm/gnat_language_extensions curated-language-extensions}@anchor{69} +@anchor{gnat_rm/gnat_language_extensions curated-extensions}@anchor{43f}@anchor{gnat_rm/gnat_language_extensions curated-language-extensions}@anchor{69} @section Curated Extensions @@ -28817,7 +28807,7 @@ for serious projects, and is only means as a playground/technology preview. @end menu @node Local Declarations Without Block,Conditional when constructs,,Curated Extensions -@anchor{gnat_rm/gnat_language_extensions local-declarations-without-block}@anchor{441} +@anchor{gnat_rm/gnat_language_extensions local-declarations-without-block}@anchor{440} @subsection Local Declarations Without Block @@ -28840,7 +28830,7 @@ end if; @end example @node Conditional when constructs,Fixed lower bounds for array types and subtypes,Local Declarations Without Block,Curated Extensions -@anchor{gnat_rm/gnat_language_extensions conditional-when-constructs}@anchor{442} +@anchor{gnat_rm/gnat_language_extensions conditional-when-constructs}@anchor{441} @subsection Conditional when constructs @@ -28912,7 +28902,7 @@ Link to the original RFC: @indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-conditional-when-constructs.rst} @node Fixed lower bounds for array types and subtypes,Prefixed-view notation for calls to primitive subprograms of untagged types,Conditional when constructs,Curated Extensions -@anchor{gnat_rm/gnat_language_extensions fixed-lower-bounds-for-array-types-and-subtypes}@anchor{443} +@anchor{gnat_rm/gnat_language_extensions fixed-lower-bounds-for-array-types-and-subtypes}@anchor{442} @subsection Fixed lower bounds for array types and subtypes @@ -28966,7 +28956,7 @@ Link to the original RFC: @indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-fixed-lower-bound.rst} @node Prefixed-view notation for calls to primitive subprograms of untagged types,Expression defaults for generic formal functions,Fixed lower bounds for array types and subtypes,Curated Extensions -@anchor{gnat_rm/gnat_language_extensions prefixed-view-notation-for-calls-to-primitive-subprograms-of-untagged-types}@anchor{444} +@anchor{gnat_rm/gnat_language_extensions prefixed-view-notation-for-calls-to-primitive-subprograms-of-untagged-types}@anchor{443} @subsection Prefixed-view notation for calls to primitive subprograms of untagged types @@ -29019,7 +29009,7 @@ Link to the original RFC: @indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-prefixed-untagged.rst} @node Expression defaults for generic formal functions,String interpolation,Prefixed-view notation for calls to primitive subprograms of untagged types,Curated Extensions -@anchor{gnat_rm/gnat_language_extensions expression-defaults-for-generic-formal-functions}@anchor{445} +@anchor{gnat_rm/gnat_language_extensions expression-defaults-for-generic-formal-functions}@anchor{444} @subsection Expression defaults for generic formal functions @@ -29048,7 +29038,7 @@ Link to the original RFC: @indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-expression-functions-as-default-for-generic-formal-function-parameters.rst} @node String interpolation,Constrained attribute for generic objects,Expression defaults for generic formal functions,Curated Extensions -@anchor{gnat_rm/gnat_language_extensions string-interpolation}@anchor{446} +@anchor{gnat_rm/gnat_language_extensions string-interpolation}@anchor{445} @subsection String interpolation @@ -29214,7 +29204,7 @@ Here is a link to the original RFC : @indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-string-interpolation.rst} @node Constrained attribute for generic objects,Static aspect on intrinsic functions,String interpolation,Curated Extensions -@anchor{gnat_rm/gnat_language_extensions constrained-attribute-for-generic-objects}@anchor{447} +@anchor{gnat_rm/gnat_language_extensions constrained-attribute-for-generic-objects}@anchor{446} @subsection Constrained attribute for generic objects @@ -29222,7 +29212,7 @@ The @code{Constrained} attribute is permitted for objects of generic types. The result indicates whether the corresponding actual is constrained. @node Static aspect on intrinsic functions,,Constrained attribute for generic objects,Curated Extensions -@anchor{gnat_rm/gnat_language_extensions static-aspect-on-intrinsic-functions}@anchor{448} +@anchor{gnat_rm/gnat_language_extensions static-aspect-on-intrinsic-functions}@anchor{447} @subsection @code{Static} aspect on intrinsic functions @@ -29231,7 +29221,7 @@ and the compiler will evaluate some of these intrinsics statically, in particular the @code{Shift_Left} and @code{Shift_Right} intrinsics. @node Experimental Language Extensions,,Curated Extensions,GNAT language extensions -@anchor{gnat_rm/gnat_language_extensions experimental-language-extensions}@anchor{6a}@anchor{gnat_rm/gnat_language_extensions id2}@anchor{449} +@anchor{gnat_rm/gnat_language_extensions experimental-language-extensions}@anchor{6a}@anchor{gnat_rm/gnat_language_extensions id2}@anchor{448} @section Experimental Language Extensions @@ -29239,11 +29229,12 @@ particular the @code{Shift_Left} and @code{Shift_Right} intrinsics. * Pragma Storage_Model:: * Simpler accessibility model:: * Case pattern matching:: +* Mutably Tagged Types with Size’Class Aspect:: @end menu @node Pragma Storage_Model,Simpler accessibility model,,Experimental Language Extensions -@anchor{gnat_rm/gnat_language_extensions pragma-storage-model}@anchor{44a} +@anchor{gnat_rm/gnat_language_extensions pragma-storage-model}@anchor{449} @subsection Pragma Storage_Model @@ -29258,7 +29249,7 @@ Here is a link to the full RFC: @indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-storage-model.rst} @node Simpler accessibility model,Case pattern matching,Pragma Storage_Model,Experimental Language Extensions -@anchor{gnat_rm/gnat_language_extensions simpler-accessibility-model}@anchor{44b} +@anchor{gnat_rm/gnat_language_extensions simpler-accessibility-model}@anchor{44a} @subsection Simpler accessibility model @@ -29270,8 +29261,8 @@ while removing dynamic accessibility checking. Here is a link to the full RFC: @indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-simpler-accessibility.md} -@node Case pattern matching,,Simpler accessibility model,Experimental Language Extensions -@anchor{gnat_rm/gnat_language_extensions case-pattern-matching}@anchor{44c} +@node Case pattern matching,Mutably Tagged Types with Size’Class Aspect,Simpler accessibility model,Experimental Language Extensions +@anchor{gnat_rm/gnat_language_extensions case-pattern-matching}@anchor{44b} @subsection Case pattern matching @@ -29402,6 +29393,46 @@ case statement with composite selector type”. Link to the original RFC: @indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-pattern-matching.rst} +@node Mutably Tagged Types with Size’Class Aspect,,Case pattern matching,Experimental Language Extensions +@anchor{gnat_rm/gnat_language_extensions mutably-tagged-types-with-size-class-aspect}@anchor{44c} +@subsection Mutably Tagged Types with Size’Class Aspect + + +The @cite{Size’Class} aspect can be applied to a tagged type to specify a size +constraint for the type and its descendants. When this aspect is specified +on a tagged type, the class-wide type of that type is considered to be a +“mutably tagged” type - meaning that objects of the class-wide type can have +their tag changed by assignment from objects with a different tag. + +When the aspect is applied to a type, the size of each of its descendant types +must not exceed the size specified for the aspect. + +Example: + +@example +type Base is tagged null record + with Size'Class => 16 * 8; -- Size in bits (128 bits, or 16 bytes) + +type Derived_Type is new Base with record + Data_Field : Integer; +end record; -- ERROR if Derived_Type exceeds 16 bytes +@end example + +Class-wide types with a specified @cite{Size’Class} can be used as the type of +array components, record components, and stand-alone objects. + +@example +Inst : Base'Class; +type Array_of_Base is array (Positive range <>) of Base'Class; +@end example + +Note: Legality of the @cite{Size’Class} aspect is subject to certain restrictions on +the tagged type, such as being undiscriminated, having no dynamic composite +subcomponents, among others detailed in the RFC. + +Link to the original RFC: +@indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/topic/rfc-finally/considered/rfc-class-size.md} + @node Security Hardening Features,Obsolescent Features,GNAT language extensions,Top @anchor{gnat_rm/security_hardening_features doc}@anchor{44d}@anchor{gnat_rm/security_hardening_features id1}@anchor{44e}@anchor{gnat_rm/security_hardening_features security-hardening-features}@anchor{15} @chapter Security Hardening Features diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi index 2df2a780ec79d..73f496fcdabc5 100644 --- a/gcc/ada/gnat_ugn.texi +++ b/gcc/ada/gnat_ugn.texi @@ -19,7 +19,7 @@ @copying @quotation -GNAT User's Guide for Native Platforms , Apr 16, 2024 +GNAT User's Guide for Native Platforms , May 28, 2024 AdaCore @@ -29645,8 +29645,8 @@ to permit their use in free software. @printindex ge -@anchor{d1}@w{ } @anchor{gnat_ugn/gnat_utility_programs switches-related-to-project-files}@w{ } +@anchor{d1}@w{ } @c %**end of body @bye diff --git a/gcc/ada/gnatlink.adb b/gcc/ada/gnatlink.adb index d00fd9e5af7de..db0fd144a13e4 100644 --- a/gcc/ada/gnatlink.adb +++ b/gcc/ada/gnatlink.adb @@ -42,6 +42,7 @@ with Types; with Ada.Command_Line; use Ada.Command_Line; with Ada.Exceptions; use Ada.Exceptions; +with Ada.Strings.Fixed; with System.OS_Lib; use System.OS_Lib; with System.CRTL; @@ -1697,15 +1698,13 @@ begin procedure Check_File_Name (S : String) is begin - for J in 1 .. FN'Length - (S'Length - 1) loop - if FN (J .. J + (S'Length - 1)) = S then - Error_Msg - ("warning: executable file name """ & Output_File_Name.all - & """ contains substring """ & S & '"'); - Error_Msg - ("admin privileges may be required to run this file"); - end if; - end loop; + if Ada.Strings.Fixed.Index (FN, S) /= 0 then + Error_Msg + ("warning: executable file name """ & Output_File_Name.all + & """ contains substring """ & S & '"'); + Error_Msg + ("admin privileges may be required to run this file"); + end if; end Check_File_Name; -- Start of processing for Bad_File_Names_On_Windows @@ -1886,6 +1885,24 @@ begin Shared_Libgcc_Seen : Boolean := False; Static_Libgcc_Seen : Boolean := False; + function Is_Prefix + (Complete_String : String; Prefix : String) return Boolean; + -- Returns whether Prefix is a prefix of Complete_String + + --------------- + -- Is_Prefix -- + --------------- + + function Is_Prefix + (Complete_String : String; Prefix : String) return Boolean + is + S : String renames Complete_String; + P : String renames Prefix; + begin + return P'Length <= S'Length + and then S (S'First .. S'First + P'Length - 1) = P; + end Is_Prefix; + begin J := Linker_Options.First; while J <= Linker_Options.Last loop @@ -1937,13 +1954,12 @@ begin -- Here we just check for a canonical form that matches the -- pragma Linker_Options set in the NT runtime. - if (Linker_Options.Table (J)'Length > 17 - and then Linker_Options.Table (J) (1 .. 17) = - "-Xlinker --stack=") - or else - (Linker_Options.Table (J)'Length > 12 - and then Linker_Options.Table (J) (1 .. 12) = - "-Wl,--stack=") + if Is_Prefix + (Complete_String => Linker_Options.Table (J).all, + Prefix => "-Xlinker --stack=") + or else Is_Prefix + (Complete_String => Linker_Options.Table (J).all, + Prefix => "-Wl,--stack=") then if Stack_Op then Linker_Options.Table (J .. Linker_Options.Last - 1) := diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb index 17b3099e6a65c..f5c5426351595 100644 --- a/gcc/ada/inline.adb +++ b/gcc/ada/inline.adb @@ -1090,19 +1090,10 @@ package body Inline is -- conflict with subsequent inlinings, so that it is unsafe to try to -- inline in such a case. - function Has_Single_Return_In_GNATprove_Mode return Boolean; - -- This function is called only in GNATprove mode, and it returns - -- True if the subprogram has no return statement or a single return - -- statement as last statement. It returns False for subprogram with - -- a single return as last statement inside one or more blocks, as - -- inlining would generate gotos in that case as well (although the - -- goto is useless in that case). - function Uses_Secondary_Stack (Bod : Node_Id) return Boolean; -- If the body of the subprogram includes a call that returns an -- unconstrained type, the secondary stack is involved, and it is -- not worth inlining. - ------------------------- -- Has_Extended_Return -- ------------------------- @@ -1173,64 +1164,6 @@ package body Inline is return False; end Has_Pending_Instantiation; - ----------------------------------------- - -- Has_Single_Return_In_GNATprove_Mode -- - ----------------------------------------- - - function Has_Single_Return_In_GNATprove_Mode return Boolean is - Body_To_Inline : constant Node_Id := N; - Last_Statement : Node_Id := Empty; - - function Check_Return (N : Node_Id) return Traverse_Result; - -- Returns OK on node N if this is not a return statement different - -- from the last statement in the subprogram. - - ------------------ - -- Check_Return -- - ------------------ - - function Check_Return (N : Node_Id) return Traverse_Result is - begin - case Nkind (N) is - when N_Extended_Return_Statement - | N_Simple_Return_Statement - => - if N = Last_Statement then - return OK; - else - return Abandon; - end if; - - -- Skip locally declared subprogram bodies inside the body to - -- inline, as the return statements inside those do not count. - - when N_Subprogram_Body => - if N = Body_To_Inline then - return OK; - else - return Skip; - end if; - - when others => - return OK; - end case; - end Check_Return; - - function Check_All_Returns is new Traverse_Func (Check_Return); - - -- Start of processing for Has_Single_Return_In_GNATprove_Mode - - begin - -- Retrieve the last statement - - Last_Statement := Last (Statements (Handled_Statement_Sequence (N))); - - -- Check that the last statement is the only possible return - -- statement in the subprogram. - - return Check_All_Returns (N) = OK; - end Has_Single_Return_In_GNATprove_Mode; - -------------------------- -- Uses_Secondary_Stack -- -------------------------- @@ -1275,16 +1208,6 @@ package body Inline is then return; - -- Subprograms that have return statements in the middle of the body are - -- inlined with gotos. GNATprove does not currently support gotos, so - -- we prevent such inlining. - - elsif GNATprove_Mode - and then not Has_Single_Return_In_GNATprove_Mode - then - Cannot_Inline ("cannot inline & (multiple returns)?", N, Spec_Id); - return; - -- Functions that return controlled types cannot currently be inlined -- because they require secondary stack handling; controlled actions -- may also interfere in complex ways with inlining. @@ -1538,6 +1461,14 @@ package body Inline is (Spec_Id : Entity_Id; Body_Id : Entity_Id) return Boolean is + function Has_Constant_With_Address_Clause + (Body_Node : Node_Id) + return Boolean; + -- Returns true if the subprogram contains a declaration of a constant + -- with an address clause, which could become illegal in SPARK after + -- inlining, if the address clause mentions a constant view of a mutable + -- object at call site. + function Has_Formal_Or_Result_Of_Deep_Type (Id : Entity_Id) return Boolean; -- Returns true if the subprogram has at least one formal parameter or @@ -1578,6 +1509,70 @@ package body Inline is -- knowledge of the SPARK boundary is needed to determine exactly -- traversal functions. + -------------------------------------- + -- Has_Constant_With_Address_Clause -- + -------------------------------------- + + function Has_Constant_With_Address_Clause + (Body_Node : Node_Id) + return Boolean + is + function Check_Constant_With_Addresss_Clause + (N : Node_Id) + return Traverse_Result; + -- Returns Abandon on node N if this is a declaration of a constant + -- object with an address clause. + + ----------------------------------------- + -- Check_Constant_With_Addresss_Clause -- + ----------------------------------------- + + function Check_Constant_With_Addresss_Clause + (N : Node_Id) + return Traverse_Result + is + begin + case Nkind (N) is + when N_Object_Declaration => + declare + Obj : constant Entity_Id := Defining_Entity (N); + begin + if Constant_Present (N) + and then + (Present (Address_Clause (Obj)) + or else Has_Aspect (Obj, Aspect_Address)) + then + return Abandon; + else + return OK; + end if; + end; + + -- Skip locally declared subprogram bodies inside the body to + -- inline, as the declarations inside those do not count. + + when N_Subprogram_Body => + if N = Body_Node then + return OK; + else + return Skip; + end if; + + when others => + return OK; + end case; + end Check_Constant_With_Addresss_Clause; + + function Check_All_Constants_With_Address_Clause is new + Traverse_Func (Check_Constant_With_Addresss_Clause); + + -- Start of processing for Has_Constant_With_Address_Clause + + begin + return Check_All_Constants_With_Address_Clause + (Body_Node) = Abandon; + end Has_Constant_With_Address_Clause; + --------------------------------------- -- Has_Formal_Or_Result_Of_Deep_Type -- --------------------------------------- @@ -2085,6 +2080,16 @@ package body Inline is elsif Has_Hide_Unhide_Annotation (Spec_Id, Body_Id) then return False; + -- Do not inline subprograms containing constant declarations with an + -- address clause, as inlining could lead to a spurious violation of + -- SPARK rules. + + elsif Present (Body_Id) + and then + Has_Constant_With_Address_Clause (Unit_Declaration_Node (Body_Id)) + then + return False; + -- Otherwise, this is a subprogram declared inside the private part of a -- package, or inside a package body, or locally in a subprogram, and it -- does not have any contract. Inline it. @@ -2105,6 +2110,11 @@ package body Inline is Is_Serious : Boolean := False; Suppress_Info : Boolean := False) is + Inline_Prefix : constant String := "cannot inline"; + + function Starts_With (S, Prefix : String) return Boolean is + (S (S'First .. S'First + Prefix'Length - 1) = Prefix); + begin -- In GNATprove mode, inlining is the technical means by which the -- higher-level goal of contextual analysis is reached, so issue @@ -2112,20 +2122,15 @@ package body Inline is -- subprogram, rather than failure to inline it. if GNATprove_Mode - and then Msg (Msg'First .. Msg'First + 12) = "cannot inline" + and then Starts_With (Msg, Inline_Prefix) then declare - Len1 : constant Positive := - String'("cannot inline")'Length; - Len2 : constant Positive := - String'("info: no contextual analysis of")'Length; - - New_Msg : String (1 .. Msg'Length + Len2 - Len1); + Msg_Txt : constant String := + Msg (Msg'First + Inline_Prefix'Length .. Msg'Last); + New_Msg : constant String := + "info: no contextual analysis of" & Msg_Txt; begin - New_Msg (1 .. Len2) := "info: no contextual analysis of"; - New_Msg (Len2 + 1 .. Msg'Length + Len2 - Len1) := - Msg (Msg'First + Len1 .. Msg'Last); Cannot_Inline (New_Msg, N, Subp, Is_Serious, Suppress_Info); return; end; @@ -3518,6 +3523,7 @@ package body Inline is --------------------- function Process_Formals (N : Node_Id) return Traverse_Result is + Loc : constant Source_Ptr := Sloc (N); A : Entity_Id; E : Entity_Id; Ret : Node_Id; @@ -3544,13 +3550,13 @@ package body Inline is if Is_Entity_Name (A) then Had_Private_View := Has_Private_View (N); - Rewrite (N, New_Occurrence_Of (Entity (A), Sloc (N))); + Rewrite (N, New_Occurrence_Of (Entity (A), Loc)); Set_Has_Private_View (N, Had_Private_View); Check_Private_View (N); elsif Nkind (A) = N_Defining_Identifier then Had_Private_View := Has_Private_View (N); - Rewrite (N, New_Occurrence_Of (A, Sloc (N))); + Rewrite (N, New_Occurrence_Of (A, Loc)); Set_Has_Private_View (N, Had_Private_View); Check_Private_View (N); @@ -3618,8 +3624,8 @@ package body Inline is or else Yields_Universal_Type (Expression (N)) then Ret := - Make_Qualified_Expression (Sloc (N), - Subtype_Mark => New_Occurrence_Of (Ret_Type, Sloc (N)), + Make_Qualified_Expression (Loc, + Subtype_Mark => New_Occurrence_Of (Ret_Type, Loc), Expression => Relocate_Node (Expression (N))); -- Use an unchecked type conversion between access types, for @@ -3635,8 +3641,8 @@ package body Inline is else Ret := - Make_Type_Conversion (Sloc (N), - Subtype_Mark => New_Occurrence_Of (Ret_Type, Sloc (N)), + Make_Type_Conversion (Loc, + Subtype_Mark => New_Occurrence_Of (Ret_Type, Loc), Expression => Relocate_Node (Expression (N))); end if; @@ -3715,7 +3721,7 @@ package body Inline is elsif Nkind (N) = N_Pragma and then Pragma_Name (N) = Name_Unreferenced then - Rewrite (N, Make_Null_Statement (Sloc (N))); + Rewrite (N, Make_Null_Statement (Loc)); return OK; else diff --git a/gcc/ada/layout.adb b/gcc/ada/layout.adb index e43e96905e9df..75635622c89d9 100644 --- a/gcc/ada/layout.adb +++ b/gcc/ada/layout.adb @@ -607,8 +607,8 @@ package body Layout is Error_Msg_Uint_1 := RM_Size (E); Error_Msg_F ("object size is too small, minimum allowed is ^", - Expression (Get_Attribute_Definition_Clause - (E, Attribute_Object_Size))); + Expression (Object_Size_Clause (E))); + end if; -- Adjust Esize up to RM_Size value diff --git a/gcc/ada/lib-list.adb b/gcc/ada/lib-list.adb index ecc29258e1301..210827abf8ecf 100644 --- a/gcc/ada/lib-list.adb +++ b/gcc/ada/lib-list.adb @@ -80,7 +80,7 @@ begin else Write_Unit_Name (Unit_Name (Sorted_Units (R))); - if Name_Len > (Unit_Length - 1) then + if Name_Len > Unit_Length - 1 then Write_Eol; Write_Str (Unit_Bln); else @@ -91,7 +91,7 @@ begin Write_Name (Full_File_Name (Source_Index (Sorted_Units (R)))); - if Name_Len > (File_Length - 1) then + if Name_Len > File_Length - 1 then Write_Eol; Write_Str (Unit_Bln); Write_Str (File_Bln); diff --git a/gcc/ada/lib-writ.adb b/gcc/ada/lib-writ.adb index 697b2f2b79730..0755b92e4dbd5 100644 --- a/gcc/ada/lib-writ.adb +++ b/gcc/ada/lib-writ.adb @@ -298,8 +298,7 @@ package body Lib.Writ is function Is_Implicit_With_Clause (Clause : Node_Id) return Boolean is begin -- With clauses created for ancestor units are marked as internal, - -- however, they emulate the semantics in Ada RM 10.1.2 (6/2), - -- where + -- however, they emulate the semantics in RM 10.1.2 (6/2), where -- -- with A.B; -- diff --git a/gcc/ada/libgnarl/s-taprop__mingw.adb b/gcc/ada/libgnarl/s-taprop__mingw.adb index 3a124ba78d094..f77d71970b8c2 100644 --- a/gcc/ada/libgnarl/s-taprop__mingw.adb +++ b/gcc/ada/libgnarl/s-taprop__mingw.adb @@ -1308,7 +1308,13 @@ package body System.Task_Primitives.Operations is Result := SetThreadIdealProcessor (T.Common.LL.Thread, ProcessorId (T.Common.Base_CPU) - 1); - pragma Assert (Result = 1); + + -- The documentation for SetThreadIdealProcessor states: + -- + -- If the function fails, the return value is (DWORD) - 1. + -- + -- That should map to DWORD'Last in Ada. + pragma Assert (Result /= DWORD'Last); -- Task_Info @@ -1317,7 +1323,10 @@ package body System.Task_Primitives.Operations is Result := SetThreadIdealProcessor (T.Common.LL.Thread, T.Common.Task_Info.CPU); - pragma Assert (Result = 1); + + -- See the comment above about the return value of + -- SetThreadIdealProcessor. + pragma Assert (Result /= DWORD'Last); end if; -- Dispatching domains @@ -1331,7 +1340,7 @@ package body System.Task_Primitives.Operations is then declare CPU_Set : DWORD := 0; - + Mask_Result : DWORD_PTR; begin for Proc in T.Common.Domain'Range loop if T.Common.Domain (Proc) then @@ -1343,8 +1352,8 @@ package body System.Task_Primitives.Operations is end if; end loop; - Result := SetThreadAffinityMask (T.Common.LL.Thread, CPU_Set); - pragma Assert (Result = 1); + Mask_Result := SetThreadAffinityMask (T.Common.LL.Thread, CPU_Set); + pragma Assert (Mask_Result /= 0); end; end if; end Set_Task_Affinity; diff --git a/gcc/ada/libgnat/a-chtgfo.adb b/gcc/ada/libgnat/a-chtgfo.adb index c3fff336e9d58..df7b554c050c4 100644 --- a/gcc/ada/libgnat/a-chtgfo.adb +++ b/gcc/ada/libgnat/a-chtgfo.adb @@ -359,74 +359,6 @@ package body Ada.Containers.Hash_Tables.Generic_Formal_Operations is end loop; end Generic_Iteration; - ------------------ - -- Generic_Read -- - ------------------ - - procedure Generic_Read - (Stream : not null access Root_Stream_Type'Class; - HT : out Hash_Table_Type) - is - N : Count_Type'Base; - - begin - Clear (HT); - - Count_Type'Base'Read (Stream, N); - - if Checks and then N < 0 then - raise Program_Error with "stream appears to be corrupt"; - end if; - - if N = 0 then - return; - end if; - - if Checks and then N > HT.Capacity then - raise Capacity_Error with "too many elements in stream"; - end if; - - for J in 1 .. N loop - declare - Node : constant Count_Type := New_Node (Stream); - Indx : constant Hash_Type := Index (HT, HT.Nodes (Node)); - B : Count_Type renames HT.Buckets (Indx); - begin - Set_Next (HT.Nodes (Node), Next => B); - B := Node; - end; - - HT.Length := HT.Length + 1; - end loop; - end Generic_Read; - - ------------------- - -- Generic_Write -- - ------------------- - - procedure Generic_Write - (Stream : not null access Root_Stream_Type'Class; - HT : Hash_Table_Type) - is - procedure Write (Node : Count_Type); - pragma Inline (Write); - - procedure Write is new Generic_Iteration (Write); - - ----------- - -- Write -- - ----------- - - procedure Write (Node : Count_Type) is - begin - Write (Stream, HT.Nodes (Node)); - end Write; - - begin - Count_Type'Base'Write (Stream, HT.Length); - Write (HT); - end Generic_Write; - ----------- -- Index -- ----------- diff --git a/gcc/ada/libgnat/a-chtgfo.ads b/gcc/ada/libgnat/a-chtgfo.ads index 76633d8da051f..f4471bec3d220 100644 --- a/gcc/ada/libgnat/a-chtgfo.ads +++ b/gcc/ada/libgnat/a-chtgfo.ads @@ -30,8 +30,6 @@ -- Hash_Table_Type is used to implement hashed containers. This package -- declares hash-table operations that do not depend on keys. -with Ada.Streams; - generic with package HT_Types is new Generic_Formal_Hash_Table_Types (<>); @@ -113,26 +111,4 @@ package Ada.Containers.Hash_Tables.Generic_Formal_Operations is procedure Generic_Iteration (HT : Hash_Table_Type); -- Calls Process for each node in hash table HT - generic - use Ada.Streams; - with procedure Write - (Stream : not null access Root_Stream_Type'Class; - Node : Node_Type); - procedure Generic_Write - (Stream : not null access Root_Stream_Type'Class; - HT : Hash_Table_Type); - -- Used to implement the streaming attribute for hashed containers. It - -- calls Write for each node to write its value into Stream. - - generic - use Ada.Streams; - with function New_Node (Stream : not null access Root_Stream_Type'Class) - return Count_Type; - procedure Generic_Read - (Stream : not null access Root_Stream_Type'Class; - HT : out Hash_Table_Type); - -- Used to implement the streaming attribute for hashed containers. It - -- first clears hash table HT, then populates the hash table by calling - -- New_Node for each item in Stream. - end Ada.Containers.Hash_Tables.Generic_Formal_Operations; diff --git a/gcc/ada/libgnat/a-stbuut.ads b/gcc/ada/libgnat/a-stbuut.ads index dadfe5f0010ae..2a8b08bca5728 100644 --- a/gcc/ada/libgnat/a-stbuut.ads +++ b/gcc/ada/libgnat/a-stbuut.ads @@ -33,7 +33,7 @@ with Ada.Strings.UTF_Encoding.Wide_Wide_Strings; package Ada.Strings.Text_Buffers.Utils with Pure is - -- Ada.Strings.Text_Buffers is a predefined unit (see Ada RM A.4.12). + -- Ada.Strings.Text_Buffers is a predefined unit (see RM A.4.12). -- This is a GNAT-defined child unit of that parent. subtype Character_7 is diff --git a/gcc/ada/libgnat/a-tags.ads b/gcc/ada/libgnat/a-tags.ads index a36d2df32c174..25a6f7ee599ba 100644 --- a/gcc/ada/libgnat/a-tags.ads +++ b/gcc/ada/libgnat/a-tags.ads @@ -260,6 +260,7 @@ private type Prim_Ptr is access procedure; type Address_Array is array (Positive range <>) of Prim_Ptr; + pragma Suppress_Initialization (Address_Array); subtype Dispatch_Table is Address_Array (1 .. 1); -- Used by GDB to identify the _tags and traverse the run-time structure diff --git a/gcc/ada/libgnat/a-ticoau.ads b/gcc/ada/libgnat/a-ticoau.ads index 223e823760457..58feea3af71c9 100644 --- a/gcc/ada/libgnat/a-ticoau.ads +++ b/gcc/ada/libgnat/a-ticoau.ads @@ -42,7 +42,7 @@ private generic type Num is digits <>; - with package Aux is new Ada.Text_IO.Float_Aux (Num, <>, <>); + with package Aux is new Ada.Text_IO.Float_Aux (Num, others => <>); package Ada.Text_IO.Complex_Aux is diff --git a/gcc/ada/libgnat/a-wtcoau.ads b/gcc/ada/libgnat/a-wtcoau.ads index 854b7b9fb60b8..781582dff9b4d 100644 --- a/gcc/ada/libgnat/a-wtcoau.ads +++ b/gcc/ada/libgnat/a-wtcoau.ads @@ -42,7 +42,7 @@ private generic type Num is digits <>; - with package Aux is new Ada.Wide_Text_IO.Float_Aux (Num, <>, <>); + with package Aux is new Ada.Wide_Text_IO.Float_Aux (Num, others => <>); package Ada.Wide_Text_IO.Complex_Aux is diff --git a/gcc/ada/libgnat/a-ztcoau.ads b/gcc/ada/libgnat/a-ztcoau.ads index 953ed5d9a1843..89f19e8e1d3f2 100644 --- a/gcc/ada/libgnat/a-ztcoau.ads +++ b/gcc/ada/libgnat/a-ztcoau.ads @@ -26,7 +26,7 @@ private generic type Num is digits <>; - with package Aux is new Ada.Wide_Wide_Text_IO.Float_Aux (Num, <>, <>); + with package Aux is new Ada.Wide_Wide_Text_IO.Float_Aux (Num, others => <>); package Ada.Wide_Wide_Text_IO.Complex_Aux is diff --git a/gcc/ada/libgnat/s-addima.adb b/gcc/ada/libgnat/s-addima.adb index 61933edeb97e4..f1488b6a87d38 100644 --- a/gcc/ada/libgnat/s-addima.adb +++ b/gcc/ada/libgnat/s-addima.adb @@ -29,44 +29,18 @@ -- -- ------------------------------------------------------------------------------ -with Ada.Unchecked_Conversion; +with System.Img_Address_32; +with System.Img_Address_64; function System.Address_Image (A : Address) return String is - - Result : String (1 .. 2 * Address'Size / Storage_Unit); - - type Byte is mod 2 ** 8; - for Byte'Size use 8; - - Hexdigs : - constant array (Byte range 0 .. 15) of Character := "0123456789ABCDEF"; - - type Bytes is array (1 .. Address'Size / Storage_Unit) of Byte; - for Bytes'Size use Address'Size; - - function To_Bytes is new Ada.Unchecked_Conversion (Address, Bytes); - - Byte_Sequence : constant Bytes := To_Bytes (A); - - LE : constant := Standard'Default_Bit_Order; - BE : constant := 1 - LE; - -- Set to 1/0 for True/False for Little-Endian/Big-Endian - - Start : constant Natural := BE * (1) + LE * (Bytes'Length); - Incr : constant Integer := BE * (1) + LE * (-1); - -- Start and increment for accessing characters of address string - - Ptr : Natural; - -- Scan address string - begin - Ptr := Start; - for N in Bytes'Range loop - Result (2 * N - 1) := Hexdigs (Byte_Sequence (Ptr) / 16); - Result (2 * N) := Hexdigs (Byte_Sequence (Ptr) mod 16); - Ptr := Ptr + Incr; - end loop; - - return Result; - + -- We use Address_Image64 for Morello because Integer_Address is 64-bit + -- large even though Address is 128-bit large. + + case Address'Size is + when 32 => return String (System.Img_Address_32.Address_Image32 (A)); + when 64 => return String (System.Img_Address_64.Address_Image64 (A)); + when 128 => return String (System.Img_Address_64.Address_Image64 (A)); + when others => raise Program_Error; + end case; end System.Address_Image; diff --git a/gcc/ada/libgnat/s-imad32.ads b/gcc/ada/libgnat/s-imad32.ads new file mode 100644 index 0000000000000..9130c3a48638c --- /dev/null +++ b/gcc/ada/libgnat/s-imad32.ads @@ -0,0 +1,43 @@ +------------------------------------------------------------------------------ +-- -- +-- GNAT RUN-TIME COMPONENTS -- +-- -- +-- S Y S T E M . I M G _ A D D R E S S _ 3 2 -- +-- -- +-- S p e c -- +-- -- +-- Copyright (C) 2024, Free Software Foundation, Inc. -- +-- -- +-- GNAT is free software; you can redistribute it and/or modify it under -- +-- terms of the GNU General Public License as published by the Free Soft- -- +-- ware Foundation; either version 3, or (at your option) any later ver- -- +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- +-- or FITNESS FOR A PARTICULAR PURPOSE. -- +-- -- +-- As a special exception under Section 7 of GPL version 3, you are granted -- +-- additional permissions described in the GCC Runtime Library Exception, -- +-- version 3.1, as published by the Free Software Foundation. -- +-- -- +-- You should have received a copy of the GNU General Public License and -- +-- a copy of the GCC Runtime Library Exception along with this program; -- +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- +-- . -- +-- -- +-- GNAT was originally developed by the GNAT team at New York University. -- +-- Extensive contributions were provided by Ada Core Technologies Inc. -- +-- -- +------------------------------------------------------------------------------ + +with Interfaces; +with System.Image_A; + +package System.Img_Address_32 is + pragma Pure; + + package Impl is new Image_A (Interfaces.Unsigned_32); + + function Address_Image32 (A : Address) return Impl.Address_String + renames Impl.Address_Image; + +end System.Img_Address_32; diff --git a/gcc/ada/libgnat/s-imad64.ads b/gcc/ada/libgnat/s-imad64.ads new file mode 100644 index 0000000000000..c8da3ee473f1c --- /dev/null +++ b/gcc/ada/libgnat/s-imad64.ads @@ -0,0 +1,43 @@ +------------------------------------------------------------------------------ +-- -- +-- GNAT RUN-TIME COMPONENTS -- +-- -- +-- S Y S T E M . I M G _ A D D R E S S _ 6 4 -- +-- -- +-- S p e c -- +-- -- +-- Copyright (C) 2024, Free Software Foundation, Inc. -- +-- -- +-- GNAT is free software; you can redistribute it and/or modify it under -- +-- terms of the GNU General Public License as published by the Free Soft- -- +-- ware Foundation; either version 3, or (at your option) any later ver- -- +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- +-- or FITNESS FOR A PARTICULAR PURPOSE. -- +-- -- +-- As a special exception under Section 7 of GPL version 3, you are granted -- +-- additional permissions described in the GCC Runtime Library Exception, -- +-- version 3.1, as published by the Free Software Foundation. -- +-- -- +-- You should have received a copy of the GNU General Public License and -- +-- a copy of the GCC Runtime Library Exception along with this program; -- +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- +-- . -- +-- -- +-- GNAT was originally developed by the GNAT team at New York University. -- +-- Extensive contributions were provided by Ada Core Technologies Inc. -- +-- -- +------------------------------------------------------------------------------ + +with Interfaces; +with System.Image_A; + +package System.Img_Address_64 is + pragma Pure; + + package Impl is new Image_A (Interfaces.Unsigned_64); + + function Address_Image64 (A : Address) return Impl.Address_String + renames Impl.Address_Image; + +end System.Img_Address_64; diff --git a/gcc/ada/libgnat/s-imagea.adb b/gcc/ada/libgnat/s-imagea.adb new file mode 100644 index 0000000000000..abcb883223a8a --- /dev/null +++ b/gcc/ada/libgnat/s-imagea.adb @@ -0,0 +1,80 @@ +------------------------------------------------------------------------------ +-- -- +-- GNAT RUN-TIME COMPONENTS -- +-- -- +-- S Y S T E M . I M A G E _ A -- +-- -- +-- B o d y -- +-- -- +-- Copyright (C) 2024, Free Software Foundation, Inc. -- +-- -- +-- GNAT is free software; you can redistribute it and/or modify it under -- +-- terms of the GNU General Public License as published by the Free Soft- -- +-- ware Foundation; either version 3, or (at your option) any later ver- -- +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- +-- or FITNESS FOR A PARTICULAR PURPOSE. -- +-- -- +-- As a special exception under Section 7 of GPL version 3, you are granted -- +-- additional permissions described in the GCC Runtime Library Exception, -- +-- version 3.1, as published by the Free Software Foundation. -- +-- -- +-- You should have received a copy of the GNU General Public License and -- +-- a copy of the GCC Runtime Library Exception along with this program; -- +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- +-- . -- +-- -- +-- GNAT was originally developed by the GNAT team at New York University. -- +-- Extensive contributions were provided by Ada Core Technologies Inc. -- +-- -- +------------------------------------------------------------------------------ + +with Ada.Unchecked_Conversion; + +with System.Storage_Elements; use System.Storage_Elements; + +package body System.Image_A is + + ------------------- + -- Address_Image -- + ------------------- + + function Address_Image (A : Address) return Address_String is + Result : Address_String; + + type Byte is mod 2 ** 8; + for Byte'Size use 8; + + Hexdigs : + constant array (Byte range 0 .. 15) of Character := "0123456789ABCDEF"; + + type Bytes is array (1 .. Uns'Size / Storage_Unit) of Byte; + + function To_Bytes is new Ada.Unchecked_Conversion (Uns, Bytes); + + Byte_Sequence : constant Bytes := To_Bytes (Uns (Integer_Address (A))); + + LE : constant := Standard'Default_Bit_Order; + BE : constant := 1 - LE; + -- Set to 1/0 for True/False for Little-Endian/Big-Endian + + Start : constant Natural := BE * (1) + LE * (Bytes'Length); + Incr : constant Integer := BE * (1) + LE * (-1); + -- Start and increment for accessing characters of address string + + Ptr : Natural; + -- Scan address string + + begin + Ptr := Start; + + for N in Bytes'Range loop + Result (2 * N - 1) := Hexdigs (Byte_Sequence (Ptr) / 16); + Result (2 * N) := Hexdigs (Byte_Sequence (Ptr) mod 16); + Ptr := Ptr + Incr; + end loop; + + return Result; + end Address_Image; + +end System.Image_A; diff --git a/gcc/ada/libgnat/s-imagea.ads b/gcc/ada/libgnat/s-imagea.ads new file mode 100644 index 0000000000000..56b42bccae124 --- /dev/null +++ b/gcc/ada/libgnat/s-imagea.ads @@ -0,0 +1,45 @@ +------------------------------------------------------------------------------ +-- -- +-- GNAT RUN-TIME COMPONENTS -- +-- -- +-- S Y S T E M . I M A G E _ A -- +-- -- +-- S p e c -- +-- -- +-- Copyright (C) 2024, Free Software Foundation, Inc. -- +-- -- +-- GNAT is free software; you can redistribute it and/or modify it under -- +-- terms of the GNU General Public License as published by the Free Soft- -- +-- ware Foundation; either version 3, or (at your option) any later ver- -- +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- +-- or FITNESS FOR A PARTICULAR PURPOSE. -- +-- -- +-- As a special exception under Section 7 of GPL version 3, you are granted -- +-- additional permissions described in the GCC Runtime Library Exception, -- +-- version 3.1, as published by the Free Software Foundation. -- +-- -- +-- You should have received a copy of the GNU General Public License and -- +-- a copy of the GCC Runtime Library Exception along with this program; -- +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- +-- . -- +-- -- +-- GNAT was originally developed by the GNAT team at New York University. -- +-- Extensive contributions were provided by Ada Core Technologies Inc. -- +-- -- +------------------------------------------------------------------------------ + +generic + + type Uns is mod <>; + +package System.Image_A is + pragma Pure; + + subtype Address_String is String (1 .. 2 * Uns'Size / Storage_Unit); + + function Address_Image (A : Address) return Address_String; + -- Return a string made up of hexadecimal digits with upper case letters + -- and without prefix representing the (lower part of) address A. + +end System.Image_A; diff --git a/gcc/ada/libgnat/s-os_lib.adb b/gcc/ada/libgnat/s-os_lib.adb index 20e109aaa0bae..dd2156e1dcb5f 100644 --- a/gcc/ada/libgnat/s-os_lib.adb +++ b/gcc/ada/libgnat/s-os_lib.adb @@ -2089,8 +2089,10 @@ package body System.OS_Lib is -- Returns True only if the Name is including a drive -- letter at start. - function Missed_Drive_Letter (Name : String) return Boolean; - -- Missed drive letter at start of the normalized pathname + function Drive_Letter_Omitted (Name : String) return Boolean; + -- Name must be an absolute path. Returns True if and only if + -- Name doesn't start with a drive letter and Name is not a + -- UNC path. ------------------- -- Is_With_Drive -- @@ -2104,11 +2106,11 @@ package body System.OS_Lib is or else Name (Name'First) in 'A' .. 'Z'); end Is_With_Drive; - ------------------------- - -- Missed_Drive_Letter -- - ------------------------- + -------------------------- + -- Drive_Letter_Omitted -- + -------------------------- - function Missed_Drive_Letter (Name : String) return Boolean is + function Drive_Letter_Omitted (Name : String) return Boolean is begin return On_Windows and then not Is_With_Drive (Name) @@ -2117,7 +2119,7 @@ package body System.OS_Lib is /= Directory_Separator or else Name (Name'First + 1) /= Directory_Separator); - end Missed_Drive_Letter; + end Drive_Letter_Omitted; ----------------- -- Final_Value -- @@ -2174,7 +2176,7 @@ package body System.OS_Lib is elsif Directory = "" or else not Is_Absolute_Path (Directory) - or else Missed_Drive_Letter (Directory) + or else Drive_Letter_Omitted (Directory) then -- Directory name not given or it is not absolute or without drive -- letter on Windows, get current directory. @@ -2251,7 +2253,7 @@ package body System.OS_Lib is end if; if Is_Absolute_Path (Name) then - if Missed_Drive_Letter (Name) then + if Drive_Letter_Omitted (Name) then Fill_Directory (Drive_Only => True); -- Take only drive letter part with colon @@ -2286,8 +2288,6 @@ package body System.OS_Lib is -- Ensure drive letter is upper-case - pragma Assert (Path_Buffer (2) = ':'); - if Path_Buffer (1) in 'a' .. 'z' then System.Case_Util.To_Upper (Path_Buffer (1 .. 1)); end if; diff --git a/gcc/ada/libgnat/s-tsmona__linux.adb b/gcc/ada/libgnat/s-tsmona__linux.adb index 417b57f454543..4545399017a7c 100644 --- a/gcc/ada/libgnat/s-tsmona__linux.adb +++ b/gcc/ada/libgnat/s-tsmona__linux.adb @@ -30,7 +30,8 @@ ------------------------------------------------------------------------------ -- This is the GNU/Linux specific version of this package -with Interfaces.C; use Interfaces.C; + +with Interfaces.C; use Interfaces.C; separate (System.Traceback.Symbolic) @@ -41,18 +42,6 @@ package body Module_Name is function Is_Shared_Lib (Base : Address) return Boolean; -- Returns True if a shared library - -- The principle is: - - -- 1. We get information about the module containing the address. - - -- 2. We check that the full pathname is pointing to a shared library. - - -- 3. for shared libraries, we return the non relocated address (so - -- the absolute address in the shared library). - - -- 4. we also return the full pathname of the module containing this - -- address. - ------------------- -- Is_Shared_Lib -- ------------------- @@ -139,11 +128,22 @@ package body Module_Name is -- Get -- --------- - function Get (Addr : System.Address; - Load_Addr : access System.Address) - return String - is + -- The principle is: + + -- 1. We get information about the module containing the address. + + -- 2. We check whether the module is a shared library. + -- 3. For shared libraries, we return the non-relocated address (so + -- the absolute address in the shared library). + + -- 4. We also return the full pathname of the module containing this + -- address. + + function Get + (Addr : System.Address; + Load_Addr : access System.Address) return String + is -- Dl_info record for Linux, used to get sym reloc offset type Dl_info is record diff --git a/gcc/ada/libgnat/s-tsmona__mingw.adb b/gcc/ada/libgnat/s-tsmona__mingw.adb index 3100db08bbd15..61264da7dfe5c 100644 --- a/gcc/ada/libgnat/s-tsmona__mingw.adb +++ b/gcc/ada/libgnat/s-tsmona__mingw.adb @@ -31,7 +31,8 @@ -- This is the Windows specific version of this package -with System.Win32; use System.Win32; +with System.Storage_Elements; use System.Storage_Elements; +with System.Win32; use System.Win32; separate (System.Traceback.Symbolic) @@ -50,27 +51,26 @@ package body Module_Name is -- Get -- --------- - function Get (Addr : System.Address; - Load_Addr : access System.Address) - return String + function Get + (Addr : System.Address; + Load_Addr : access System.Address) return String is Res : DWORD; hModule : aliased HANDLE; - Path : String (1 .. 1_024); + Path : String (1 .. 1024); begin Load_Addr.all := System.Null_Address; if GetModuleHandleEx - (GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, + (GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS + + GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, Addr, hModule'Access) = Win32.TRUE then - Res := GetModuleFileName (hModule, Path'Address, Path'Length); + Load_Addr.all := To_Address (Integer_Address (hModule)); - if FreeLibrary (hModule) = Win32.FALSE then - null; - end if; + Res := GetModuleFileName (hModule, Path'Address, Path'Length); if Res > 0 then return Path (1 .. Positive (Res)); diff --git a/gcc/ada/libgnat/s-win32.ads b/gcc/ada/libgnat/s-win32.ads index 6e8e246d903a0..963cb57b7f001 100644 --- a/gcc/ada/libgnat/s-win32.ads +++ b/gcc/ada/libgnat/s-win32.ads @@ -157,7 +157,8 @@ package System.Win32 is FILE_ATTRIBUTE_VALID_FLAGS : constant := 16#00007fb7#; FILE_ATTRIBUTE_VALID_SET_FLAGS : constant := 16#000031a7#; - GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS : constant := 16#00000004#; + GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS : constant := 16#04#; + GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT : constant := 16#02#; type OVERLAPPED is record Internal : access ULONG; diff --git a/gcc/ada/libgnat/s-winext.ads b/gcc/ada/libgnat/s-winext.ads index 3f14fc04e6049..b402a5615c93f 100644 --- a/gcc/ada/libgnat/s-winext.ads +++ b/gcc/ada/libgnat/s-winext.ads @@ -55,7 +55,7 @@ package System.Win32.Ext is function SetThreadAffinityMask (hThread : HANDLE; - dwThreadAffinityMask : DWORD) return DWORD; + dwThreadAffinityMask : DWORD) return DWORD_PTR; pragma Import (Stdcall, SetThreadAffinityMask, "SetThreadAffinityMask"); -------------- diff --git a/gcc/ada/mutably_tagged.adb b/gcc/ada/mutably_tagged.adb new file mode 100644 index 0000000000000..34b032f08c80c --- /dev/null +++ b/gcc/ada/mutably_tagged.adb @@ -0,0 +1,337 @@ +------------------------------------------------------------------------------ +-- -- +-- GNAT COMPILER COMPONENTS -- +-- -- +-- M U T A B L Y _ T A G G E D -- +-- -- +-- S p e c -- +-- -- +-- Copyright (C) 2024-2024, Free Software Foundation, Inc. -- +-- -- +-- GNAT is free software; you can redistribute it and/or modify it under -- +-- terms of the GNU General Public License as published by the Free Soft- -- +-- ware Foundation; either version 3, or (at your option) any later ver- -- +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- +-- OUT 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 distributed with GNAT; see file COPYING3. If not, go to -- +-- http://www.gnu.org/licenses for a complete copy of the license. -- +-- -- +-- GNAT was originally developed by the GNAT team at New York University. -- +-- Extensive contributions were provided by Ada Core Technologies Inc. -- +-- -- +------------------------------------------------------------------------------ + +with Atree; use Atree; +with Casing; use Casing; +with Einfo; use Einfo; +with Einfo.Entities; use Einfo.Entities; +with Einfo.Utils; use Einfo.Utils; +with Exp_Util; use Exp_Util; +with Namet; use Namet; +with Nlists; use Nlists; +with Nmake; use Nmake; +with Rtsfind; use Rtsfind; +with Snames; use Snames; +with Sem_Util; use Sem_Util; +with Sinfo; use Sinfo; +with Sinfo.Nodes; use Sinfo.Nodes; +with Sinfo.Utils; use Sinfo.Utils; +with Stringt; use Stringt; +with Tbuild; use Tbuild; + +package body Mutably_Tagged is + + --------------------------------------- + -- Corresponding_Mutably_Tagged_Type -- + --------------------------------------- + + function Corresponding_Mutably_Tagged_Type + (CW_Equiv_Typ : Entity_Id) return Entity_Id + is + begin + return Class_Wide_Type (Parent_Subtype (CW_Equiv_Typ)); + end Corresponding_Mutably_Tagged_Type; + + ---------------------------------------- + -- Depends_On_Mutably_Tagged_Ext_Comp -- + ---------------------------------------- + + function Depends_On_Mutably_Tagged_Ext_Comp (N : Node_Id) return Boolean is + Typ : Entity_Id; + Typ_Comp : Entity_Id; + Curr : Node_Id; + Prev : Node_Id; + begin + -- Move through each prefix until we hit a type conversion from a + -- mutably tagged type then check if the referenced component exists in + -- the root type or an extension. + + Curr := N; + while Has_Prefix (Curr) loop + Prev := Curr; + Curr := Prefix (Curr); + + -- Find a prefix which is a type conversion from a mutably tagged + -- type in some form - either class-wide equivalent type or + -- directly a mutably tagged type. + + if Nkind (Curr) in N_Unchecked_Type_Conversion + | N_Type_Conversion + and then (Is_Mutably_Tagged_CW_Equivalent_Type + (Etype (Expression (Curr))) + or else Is_Mutably_Tagged_Type + (Etype (Expression (Curr)))) + + -- Verify that the prefix references a component + + and then Is_Entity_Name (Selector_Name (Prev)) + and then Ekind (Entity (Selector_Name (Prev))) + = E_Component + then + -- Obtain the root type + + Typ := Etype (if Is_Mutably_Tagged_Type + (Etype (Expression (Curr))) + then + Etype (Expression (Curr)) + else + Corresponding_Mutably_Tagged_Type + (Etype (Expression (Curr)))); + + -- Move through the components of the root type looking for a + -- match to the reference component. + + Typ_Comp := First_Component (Typ); + while Present (Typ_Comp) loop + + -- When there is a match we know the component reference + -- doesn't depend on a type extension. + + if Chars (Typ_Comp) = Chars (Entity (Selector_Name (Prev))) then + return False; + end if; + + Next_Component (Typ_Comp); + end loop; + + -- Otherwise, the component must depend on an extension + + return True; + end if; + end loop; + + -- If we get here then we know we don't have any sort of relevant type + -- conversion from a mutably tagged object. + + return False; + end Depends_On_Mutably_Tagged_Ext_Comp; + + ------------------------------------------------------ + -- Get_Corresponding_Mutably_Tagged_Type_If_Present -- + ------------------------------------------------------ + + function Get_Corresponding_Mutably_Tagged_Type_If_Present + (Typ : Entity_Id) return Entity_Id + is + begin + if Is_Mutably_Tagged_CW_Equivalent_Type (Typ) then + return Corresponding_Mutably_Tagged_Type (Typ); + end if; + + return Typ; + end Get_Corresponding_Mutably_Tagged_Type_If_Present; + + ---------------------------------------------- + -- Get_Corresponding_Tagged_Type_If_Present -- + ---------------------------------------------- + + function Get_Corresponding_Tagged_Type_If_Present + (Typ : Entity_Id) return Entity_Id + is + begin + -- Obtain the related tagged type for the class-wide mutably + -- tagged type associated with the class-wide equivalent type. + + if Is_Mutably_Tagged_CW_Equivalent_Type (Typ) then + return Parent_Subtype (Typ); + end if; + + return Typ; + end Get_Corresponding_Tagged_Type_If_Present; + + ---------------------------------- + -- Is_Mutably_Tagged_Conversion -- + ---------------------------------- + + function Is_Mutably_Tagged_Conversion (N : Node_Id) return Boolean is + begin + return Nkind (N) = N_Unchecked_Type_Conversion + and then Is_Mutably_Tagged_CW_Equivalent_Type + (Etype (Expression (N))); + end Is_Mutably_Tagged_Conversion; + + ------------------------------------------ + -- Is_Mutably_Tagged_CW_Equivalent_Type -- + ------------------------------------------ + + function Is_Mutably_Tagged_CW_Equivalent_Type + (Typ : Entity_Id) return Boolean + is + begin + -- First assure Typ is OK to test since this function can be called in + -- a context where analysis failed. + + return Present (Typ) + and then not Error_Posted (Typ) + + -- Finally check Typ is a class-wide equivalent type which has an + -- associated mutably tagged class-wide type (e.g. it is a class-wide + -- type with a size clause). + + and then Is_Class_Wide_Equivalent_Type (Typ) + and then Present (Parent_Subtype (Typ)) + and then Present (Class_Wide_Type (Parent_Subtype (Typ))) + and then Has_Size_Clause (Corresponding_Mutably_Tagged_Type (Typ)); + end Is_Mutably_Tagged_CW_Equivalent_Type; + + -------------------------------- + -- Make_CW_Size_Compile_Check -- + -------------------------------- + + function Make_CW_Size_Compile_Check + (New_Typ : Entity_Id; + Mut_Tag_Typ : Entity_Id) return Node_Id + is + Loc : constant Source_Ptr := Sloc (New_Typ); + begin + -- Generate a string literal for New_Typ's name which is needed for + -- printing within the Compile_Time_Error. + + Get_Decoded_Name_String (Chars (New_Typ)); + Set_Casing (Mixed_Case); + + -- Build a pragma Compile_Time_Error to force the backend to + -- preform appropriate sizing checks. + + -- Generate: + -- pragma Compile_Time_Error + -- (New_Typ'Size < Mut_Tag_Typ'Size, + -- "class size for by-reference type ""New_Typ"" too small") + + return + Make_Pragma (Loc, + Chars => Name_Compile_Time_Error, + Pragma_Argument_Associations => New_List ( + Make_Pragma_Argument_Association (Loc, + Expression => ( + Make_Op_Gt (Loc, + Left_Opnd => + Make_Attribute_Reference (Loc, + Attribute_Name => Name_Size, + Prefix => + New_Occurrence_Of (New_Typ, Loc)), + Right_Opnd => + Make_Integer_Literal (Loc, + RM_Size (Mut_Tag_Typ))))), + Make_Pragma_Argument_Association (Loc, + Expression => + + -- Is it possible to print the size of New_Typ via + -- Validate_Compile_Time_Warning_Or_Error after the back-end + -- has run to generate the error message manually ??? + + Make_String_Literal (Loc, + "class size for by-reference type """ + & To_String (String_From_Name_Buffer) + & """ too small")))); + end Make_CW_Size_Compile_Check; + + ------------------------------------ + -- Make_Mutably_Tagged_Conversion -- + ------------------------------------ + + procedure Make_Mutably_Tagged_Conversion + (N : Node_Id; + Typ : Entity_Id := Empty; + Force : Boolean := False) + is + Conv_Typ : constant Entity_Id := + + -- When Typ is not present, we obtain it at this point + + (if Present (Typ) then + Typ + else + Corresponding_Mutably_Tagged_Type (Etype (N))); + + begin + -- Allow "forcing" the rewrite to an unchecked conversion + + if Force + + -- Otherwise, don't make the conversion when N is on the left-hand + -- side of the assignment, is already part of an unchecked conversion, + -- or is part of a renaming. + + or else (not Known_To_Be_Assigned (N, Only_LHS => True) + and then (No (Parent (N)) + or else Nkind (Parent (N)) + not in N_Selected_Component + | N_Unchecked_Type_Conversion + | N_Object_Renaming_Declaration)) + then + -- Exclude the case where we have a 'Size so that we get the proper + -- size of the class-wide equivalent type. Are there other cases ??? + + if Present (Parent (N)) + and then Nkind (Parent (N)) = N_Attribute_Reference + and then Attribute_Name (Parent (N)) in Name_Size + then + return; + end if; + + -- Create the conversion + + Rewrite (N, + Unchecked_Convert_To + (Conv_Typ, Relocate_Node (N))); + end if; + end Make_Mutably_Tagged_Conversion; + + ---------------------------------- + -- Make_Mutably_Tagged_CW_Check -- + ---------------------------------- + + function Make_Mutably_Tagged_CW_Check + (N : Node_Id; + Tag : Node_Id) return Node_Id + is + Loc : constant Source_Ptr := Sloc (N); + + -- Displace the pointer to the base of the objects applying 'Address, + -- which is later expanded into a call to RE_Base_Address. + + N_Tag : constant Node_Id := + Make_Explicit_Dereference (Loc, + Prefix => + Unchecked_Convert_To (RTE (RE_Tag_Ptr), + Make_Attribute_Reference (Loc, + Prefix => Duplicate_Subexpr (N), + Attribute_Name => Name_Address))); + begin + -- Generate the runtime call to test class-wide membership + + return + Make_Raise_Constraint_Error (Loc, + Reason => CE_Tag_Check_Failed, + Condition => + Make_Op_Not (Loc, + Make_Function_Call (Loc, + Parameter_Associations => New_List (N_Tag, Tag), + Name => + New_Occurrence_Of (RTE (RE_CW_Membership), Loc)))); + end Make_Mutably_Tagged_CW_Check; + +end Mutably_Tagged; diff --git a/gcc/ada/mutably_tagged.ads b/gcc/ada/mutably_tagged.ads new file mode 100644 index 0000000000000..b1e393f98ad01 --- /dev/null +++ b/gcc/ada/mutably_tagged.ads @@ -0,0 +1,120 @@ +------------------------------------------------------------------------------ +-- -- +-- GNAT COMPILER COMPONENTS -- +-- -- +-- M U T A B L Y _ T A G G E D -- +-- -- +-- S p e c -- +-- -- +-- Copyright (C) 2024-2024, Free Software Foundation, Inc. -- +-- -- +-- GNAT is free software; you can redistribute it and/or modify it under -- +-- terms of the GNU General Public License as published by the Free Soft- -- +-- ware Foundation; either version 3, or (at your option) any later ver- -- +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- +-- OUT 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 distributed with GNAT; see file COPYING3. If not, go to -- +-- http://www.gnu.org/licenses for a complete copy of the license. -- +-- -- +-- GNAT was originally developed by the GNAT team at New York University. -- +-- Extensive contributions were provided by Ada Core Technologies Inc. -- +-- -- +------------------------------------------------------------------------------ + +-- Semantic and expansion utility routines dealing with mutably tagged types + +with Types; use Types; + +package Mutably_Tagged is + + -------------------------------------------- + -- Implementation of Mutably Tagged Types -- + -------------------------------------------- + + -- This package implements mutably tagged types via the Size'class aspect + -- which enables the creation of class-wide types with a specific maximum + -- size. This allows such types to be used directly in record components, + -- in object declarations without an initial expression, and to be + -- assigned a value from any type in a mutably tagged type's hierarchy. + + -- For example, this structure allows Base_Type and its derivatives to be + -- treated as components with a predictable size: + + -- type Base_Type is tagged null record + -- with Size'Class => 128; + + -- type Container is record + -- Component : Base_Type'Class; + -- end record; + + -- The core of thier implementation involve creating an "equivalent" type + -- for each class-wide type that adheres to the Size'Class constraint. This + -- is achieved using the function Make_CW_Equivalent_Type, which + -- generates a type that is compatible in size and structure with any + -- derived type of the base class-wide type. + + -- Once the class-wide equivalent type is generated, all references to + -- mutably tagged typed object declarations get rewritten to be + -- declarations of said equivalent type. References to these objects also + -- then get wrapped in unchecked conversions to the proper mutably tagged + -- class-wide type. + + function Corresponding_Mutably_Tagged_Type + (CW_Equiv_Typ : Entity_Id) return Entity_Id; + -- Given a class-wide equivalent type obtain the related mutably tagged + -- class-wide type. + + function Depends_On_Mutably_Tagged_Ext_Comp (N : Node_Id) return Boolean; + -- Return true if the given node N contains a reference to a component + -- of a mutably tagged object which comes from a type extension. + + function Get_Corresponding_Mutably_Tagged_Type_If_Present + (Typ : Entity_Id) return Entity_Id; + -- Obtain the corresponding mutably tagged type associated with Typ when + -- Typ is a mutably tagged class-wide equivalent type. Otherwise, just + -- return Typ. + + function Get_Corresponding_Tagged_Type_If_Present + (Typ : Entity_Id) return Entity_Id; + -- Obtain the corresponding tag type associated with Typ when + -- Typ is a mutably tagged class-wide equivalent type. Otherwise, Just + -- return Typ. + + -- This function is mostly used when we need a concrete type to generate + -- initialization for mutably tagged types. + + function Is_Mutably_Tagged_Conversion (N : Node_Id) return Boolean; + -- Return True if expression N is an object of a mutably tagged class-wide + -- equivalent type which has been expanded into a type conversion to + -- its related mutably tagged class-wide type. + + function Is_Mutably_Tagged_CW_Equivalent_Type + (Typ : Entity_Id) return Boolean; + -- Determine if Typ is a class-wide equivalent type + + procedure Make_Mutably_Tagged_Conversion + (N : Node_Id; + Typ : Entity_Id := Empty; + Force : Boolean := False); + -- Expand a reference N to a given mutably tagged type Typ. When Typ is not + -- present the closest associated mutably tagged type in the hierarchy is + -- used. + + -- Force is used to ignore certain predicates which avoid generating the + -- conversion (e.g. when N is on the left-hand side of an assignment). + + function Make_CW_Size_Compile_Check + (New_Typ : Entity_Id; + Mut_Tag_Typ : Entity_Id) return Node_Id; + -- Generate a type size check on New_Typ based on the size set in + -- the mutably tagged type Mut_Tag_Typ. + + function Make_Mutably_Tagged_CW_Check + (N : Node_Id; + Tag : Node_Id) return Node_Id; + -- Generate class-wide membership test for a given expression N based on + -- Tag. + +end Mutably_Tagged; diff --git a/gcc/ada/opt.ads b/gcc/ada/opt.ads index 5f402cf5d6e91..d24b9b941ff3e 100644 --- a/gcc/ada/opt.ads +++ b/gcc/ada/opt.ads @@ -816,10 +816,6 @@ package Opt is -- cause implicit packing instead of generating an error message. Set by -- use of pragma Implicit_Packing. - Include_Subprogram_In_Messages : Boolean := False; - -- GNAT - -- Set True to include the enclosing subprogram in compiler messages. - Init_Or_Norm_Scalars : Boolean := False; -- GNAT, GNATBIND -- Set True if a pragma Initialize_Scalars applies to the current unit. diff --git a/gcc/ada/par-ch5.adb b/gcc/ada/par-ch5.adb index d72ddffdece21..68c3025e3a031 100644 --- a/gcc/ada/par-ch5.adb +++ b/gcc/ada/par-ch5.adb @@ -1360,6 +1360,31 @@ package body Ch5 is else if Style_Check then Style.Check_Xtra_Parens (Cond); + + -- When the condition is an operator then examine parentheses + -- surrounding the condition's operands - taking care to avoid + -- flagging operands which themselves are operators since they + -- may be required for resolution or precedence. + + if Nkind (Cond) in N_Op + | N_Membership_Test + | N_Short_Circuit + and then Nkind (Right_Opnd (Cond)) not in N_Op + | N_Membership_Test + | N_Short_Circuit + then + Style.Check_Xtra_Parens (Right_Opnd (Cond)); + end if; + + if Nkind (Cond) in N_Binary_Op + | N_Membership_Test + | N_Short_Circuit + and then Nkind (Left_Opnd (Cond)) not in N_Op + | N_Membership_Test + | N_Short_Circuit + then + Style.Check_Xtra_Parens (Left_Opnd (Cond)); + end if; end if; -- And return the result diff --git a/gcc/ada/par-ch7.adb b/gcc/ada/par-ch7.adb index cd535e56bc2e5..c71e25770f35a 100644 --- a/gcc/ada/par-ch7.adb +++ b/gcc/ada/par-ch7.adb @@ -233,7 +233,7 @@ package body Ch7 is if Aspect_Sloc /= No_Location and then not Aspect_Specifications_Present then - Error_Msg_SC ("info: aspect specifications belong here??"); + Error_Msg_SC ("info: aspect specifications belong here"); Move_Aspects (From => Dummy_Node, To => Package_Node); end if; diff --git a/gcc/ada/par-endh.adb b/gcc/ada/par-endh.adb index 0563051894d53..0345f8018ca0f 100644 --- a/gcc/ada/par-endh.adb +++ b/gcc/ada/par-endh.adb @@ -412,7 +412,7 @@ package body Endh is Error_Msg_SC ("misplaced aspects for package declaration"); Error_Msg - ("info: aspect specifications belong here??", Is_Loc); + ("info: aspect specifications belong here", Is_Loc); P_Aspect_Specifications (Empty, Semicolon => True); -- Other cases where aspect specifications are not allowed diff --git a/gcc/ada/par-labl.adb b/gcc/ada/par-labl.adb index 7b793c06ecd5f..7ef897f0b4819 100644 --- a/gcc/ada/par-labl.adb +++ b/gcc/ada/par-labl.adb @@ -356,9 +356,6 @@ procedure Labl is Remove (Loop_Header); Rewrite (Loop_End, Loop_Stmt); - Error_Msg_N - ("info: code between label and backwards goto rewritten as loop??", - Loop_End); end Rewrite_As_Loop; -------------- diff --git a/gcc/ada/par-util.adb b/gcc/ada/par-util.adb index 8ed5947f4a07e..f254026431f75 100644 --- a/gcc/ada/par-util.adb +++ b/gcc/ada/par-util.adb @@ -689,12 +689,6 @@ package body Util is pragma Assert (Scope.Last > 0); Scope.Decrement_Last; - if Include_Subprogram_In_Messages - and then Scopes (Scope.Last).Labl /= Error - then - Current_Node := Scopes (Scope.Last).Labl; - end if; - if Debug_Flag_P then Error_Msg_Uint_1 := UI_From_Int (Scope.Last); Error_Msg_SC ("decrement scope stack ptr, new value = ^!"); diff --git a/gcc/ada/repinfo.adb b/gcc/ada/repinfo.adb index 28e4a64276558..7dada5358f7a4 100644 --- a/gcc/ada/repinfo.adb +++ b/gcc/ada/repinfo.adb @@ -457,34 +457,7 @@ package body Repinfo is Bytes_Big_Endian : Boolean; In_Subprogram : Boolean := False) is - Body_E : Entity_Id; - E : Entity_Id; - - function Find_Declaration (E : Entity_Id) return Node_Id; - -- Utility to retrieve declaration node for entity in the - -- case of package bodies and subprograms. - - ---------------------- - -- Find_Declaration -- - ---------------------- - - function Find_Declaration (E : Entity_Id) return Node_Id is - Decl : Node_Id; - - begin - Decl := Parent (E); - while Present (Decl) - and then Nkind (Decl) /= N_Package_Body - and then Nkind (Decl) /= N_Subprogram_Declaration - and then Nkind (Decl) /= N_Subprogram_Body - loop - Decl := Parent (Decl); - end loop; - - return Decl; - end Find_Declaration; - - -- Start of processing for List_Entities + E : Entity_Id; begin -- List entity if we have one, and it is not a renaming declaration. @@ -609,34 +582,6 @@ package body Repinfo is Next_Entity (E); end loop; - - -- For a package body, the entities of the visible subprograms are - -- declared in the corresponding spec. Iterate over its entities in - -- order to handle properly the subprogram bodies. Skip bodies in - -- subunits, which are listed independently. - - if Ekind (Ent) = E_Package_Body - and then Present (Corresponding_Spec (Find_Declaration (Ent))) - then - E := First_Entity (Corresponding_Spec (Find_Declaration (Ent))); - while Present (E) loop - if Is_Subprogram (E) - and then - Nkind (Find_Declaration (E)) = N_Subprogram_Declaration - then - Body_E := Corresponding_Body (Find_Declaration (E)); - - if Present (Body_E) - and then - Nkind (Parent (Find_Declaration (Body_E))) /= N_Subunit - then - List_Entities (Body_E, Bytes_Big_Endian); - end if; - end if; - - Next_Entity (E); - end loop; - end if; end if; end List_Entities; diff --git a/gcc/ada/rtsfind.adb b/gcc/ada/rtsfind.adb index 7c9935e614c22..4cfd9fe4a119c 100644 --- a/gcc/ada/rtsfind.adb +++ b/gcc/ada/rtsfind.adb @@ -605,7 +605,7 @@ package body Rtsfind is range Interfaces_C_Strings .. Interfaces_C_Strings; subtype System_Descendant is RTU_Id - range System_Address_Image .. System_Tasking_Stages; + range System_Address_To_Access_Conversions .. System_Tasking_Stages; subtype System_Atomic_Operations_Descendant is System_Descendant range System_Atomic_Operations_Test_And_Set .. diff --git a/gcc/ada/rtsfind.ads b/gcc/ada/rtsfind.ads index 50c77867dcdc7..f4566b4846f15 100644 --- a/gcc/ada/rtsfind.ads +++ b/gcc/ada/rtsfind.ads @@ -199,7 +199,6 @@ package Rtsfind is -- Children of System - System_Address_Image, System_Address_To_Access_Conversions, System_Arith_64, System_Arith_128, @@ -263,6 +262,8 @@ package Rtsfind is System_Fore_Fixed_64, System_Fore_Fixed_128, System_Fore_Real, + System_Img_Address_32, + System_Img_Address_64, System_Img_Bool, System_Img_Char, System_Img_Decimal_32, @@ -756,7 +757,8 @@ package Rtsfind is RE_Null_Address, -- System RE_Priority, -- System - RE_Address_Image, -- System.Address_Image + RE_Address_Image32, -- System.Img_Address_32 + RE_Address_Image64, -- System.Img_Address_64 RE_Add_With_Ovflo_Check64, -- System.Arith_64 RE_Double_Divide64, -- System.Arith_64 @@ -2401,7 +2403,8 @@ package Rtsfind is RE_Null_Address => System, RE_Priority => System, - RE_Address_Image => System_Address_Image, + RE_Address_Image32 => System_Img_Address_32, + RE_Address_Image64 => System_Img_Address_64, RE_Add_With_Ovflo_Check64 => System_Arith_64, RE_Double_Divide64 => System_Arith_64, diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb index 60738550ec1fa..1dbde1fae31d5 100644 --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -37,6 +37,7 @@ with Freeze; use Freeze; with Itypes; use Itypes; with Lib; use Lib; with Lib.Xref; use Lib.Xref; +with Mutably_Tagged; use Mutably_Tagged; with Namet; use Namet; with Namet.Sp; use Namet.Sp; with Nmake; use Nmake; @@ -49,7 +50,6 @@ with Sem_Aux; use Sem_Aux; with Sem_Case; use Sem_Case; with Sem_Cat; use Sem_Cat; with Sem_Ch3; use Sem_Ch3; -with Sem_Ch5; use Sem_Ch5; with Sem_Ch8; use Sem_Ch8; with Sem_Ch13; use Sem_Ch13; with Sem_Dim; use Sem_Dim; @@ -2700,7 +2700,18 @@ package body Sem_Aggr is Full_Analysis := Save_Analysis; Expander_Mode_Restore; - if Is_Tagged_Type (Etype (Expr)) then + -- Skip tagged checking for mutably tagged CW equivalent + -- types. + + if Is_Tagged_Type (Etype (Expr)) + and then Is_Class_Wide_Equivalent_Type + (Component_Type (Etype (N))) + then + null; + + -- Otherwise perform the dynamic tag check + + elsif Is_Tagged_Type (Etype (Expr)) then Check_Dynamically_Tagged_Expression (Expr => Expr, Typ => Component_Type (Etype (N)), @@ -3381,7 +3392,15 @@ package body Sem_Aggr is Key_Expr := Key_Expression (Comp); if Present (Key_Expr) then - Preanalyze_And_Resolve (New_Copy_Tree (Key_Expr), Key_Type); + if No (Add_Named_Subp) then + Error_Msg_N + ("iterated_element_association with key_expression only " + & "allowed for container type with Add_Named operation " + & "(RM22 4.3.5(24))", + Comp); + else + Preanalyze_And_Resolve (New_Copy_Tree (Key_Expr), Key_Type); + end if; end if; End_Scope; @@ -3414,6 +3433,16 @@ package body Sem_Aggr is else Choice := First (Discrete_Choices (Comp)); + -- A copy of Choice is made before it's analyzed, to preserve + -- prefixed calls in their original form, because otherwise the + -- analysis of Choice can transform such calls to normal form, + -- and the later analysis of an iterator_specification created + -- below in the case of a function-call choice may trigger an + -- error on the call (in the case where the function is not + -- directly visible). + + Copy := Copy_Separate_Tree (Choice); + -- This is an N_Component_Association with a Defining_Identifier -- and Discrete_Choice_List, but the latter can only have a single -- choice, as it's a stand-in for a Loop_Parameter_Specification @@ -3437,7 +3466,7 @@ package body Sem_Aggr is Make_Iterator_Specification (Sloc (N), Defining_Identifier => Relocate_Node (Defining_Identifier (Comp)), - Name => New_Copy_Tree (Choice), + Name => Copy, Reverse_Present => False, Iterator_Filter => Empty, Subtype_Indication => Empty); @@ -3445,9 +3474,6 @@ package body Sem_Aggr is Set_Iterator_Specification (Comp, I_Spec); Set_Defining_Identifier (Comp, Empty); - Analyze_Iterator_Specification - (Iterator_Specification (Comp)); - Resolve_Iterated_Association (Comp, Key_Type, Elmt_Type); -- Recursive call to expand association as iterator_spec @@ -5330,6 +5356,12 @@ package body Sem_Aggr is Relocate := True; end if; + -- Obtain the corresponding mutably tagged types if we are looking + -- at a special internally generated class-wide equivalent type. + + Expr_Type := + Get_Corresponding_Mutably_Tagged_Type_If_Present (Expr_Type); + Analyze_And_Resolve (Expr, Expr_Type); Check_Expr_OK_In_Limited_Aggregate (Expr); Check_Non_Static_Context (Expr); @@ -5337,7 +5369,9 @@ package body Sem_Aggr is -- Check wrong use of class-wide types - if Is_Class_Wide_Type (Etype (Expr)) then + if Is_Class_Wide_Type (Etype (Expr)) + and then not Is_Mutably_Tagged_Type (Expr_Type) + then Error_Msg_N ("dynamically tagged expression not allowed", Expr); end if; diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index 403810c8b5ec0..9c3bc62d32137 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -46,6 +46,7 @@ with Gnatvsn; use Gnatvsn; with Itypes; use Itypes; with Lib; use Lib; with Lib.Xref; use Lib.Xref; +with Mutably_Tagged; use Mutably_Tagged; with Nlists; use Nlists; with Nmake; use Nmake; with Opt; use Opt; @@ -5534,7 +5535,42 @@ package body Sem_Attr is -- The prefix must be preanalyzed as the full analysis will take -- place during expansion. - Preanalyze_And_Resolve (P); + -- If the attribute reference has an expected type or shall resolve + -- to a given type, the same applies to the prefix; otherwise the + -- prefix shall be resolved independently of context (RM 6.1.1(8/5)). + + if Nkind (Parent (N)) = N_Qualified_Expression then + Preanalyze_And_Resolve (P, Etype (Parent (N))); + + -- An special case occurs when the prefix is an overloaded function + -- call without formals; in order to identify such case we preanalyze + -- a duplicate of the prefix ignoring errors. + + else + declare + P_Copy : constant Node_Id := New_Copy_Tree (P); + + begin + Set_Parent (P_Copy, Parent (P)); + + Preanalyze_And_Resolve_Without_Errors (P_Copy); + + -- In the special case of a call to an overloaded function + -- without extra formals we resolve it using its returned + -- type (which is the unique valid call); if this not the + -- case we will report the error later, as part of the + -- regular analysis of the full expression. + + if Nkind (P_Copy) = N_Function_Call + and then Is_Overloaded (Name (P_Copy)) + and then No (First_Formal (Entity (Name (P_Copy)))) + then + Preanalyze_And_Resolve (P, Etype (Name (P_Copy))); + else + Preanalyze_And_Resolve (P); + end if; + end; + end if; -- Ensure that the prefix does not contain attributes 'Old or 'Result @@ -6653,6 +6689,7 @@ package body Sem_Attr is Error_Msg_GNAT_Extension ("attribute %", Sloc (N)); Check_E0; + Check_Dereference; -- Verify that we are looking at a type with ancestors @@ -6683,6 +6720,12 @@ package body Sem_Attr is elsif Depends_On_Private (P_Type) then Error_Attr_P ("prefix type of % is a private extension"); + -- Disallow view conversions to interfaces in order to avoid + -- depending on whether an interface type is used as a parent + -- or progenitor type. + + elsif Is_Interface (Node (First_Elmt (Parents))) then + Error_Attr_P ("type of % cannot be an interface"); end if; -- Generate a view conversion and analyze it @@ -6711,7 +6754,10 @@ package body Sem_Attr is Check_E0; Check_Dereference; - if not Is_Tagged_Type (P_Type) then + if Is_Mutably_Tagged_CW_Equivalent_Type (P_Type) then + null; + + elsif not Is_Tagged_Type (P_Type) then Error_Attr_P ("prefix of % attribute must be tagged"); -- Next test does not apply to generated code why not, and what does @@ -6863,8 +6909,8 @@ package body Sem_Attr is -------------- when Attribute_Type_Key => Type_Key : declare - Full_Name : constant String_Id := - Fully_Qualified_Name_String (Entity (P)); + Full_Name : constant String_Id := + Fully_Qualified_Name_String (Entity (P), Append_NUL => False); CRC : CRC32; -- The computed signature for the type @@ -6997,9 +7043,9 @@ package body Sem_Attr is Start_String; Deref := False; - -- Copy all characters in Full_Name but the trailing NUL + -- Copy all characters in Full_Name - for J in 1 .. String_Length (Full_Name) - 1 loop + for J in 1 .. String_Length (Full_Name) loop Store_String_Char (Get_String_Char (Full_Name, Pos (J))); end loop; @@ -11743,6 +11789,10 @@ package body Sem_Attr is Error_Msg_F ("illegal attribute for discriminant-dependent component", P); + + elsif Depends_On_Mutably_Tagged_Ext_Comp (P) then + Error_Msg_F + ("illegal attribute for mutably tagged component", P); end if; -- Check static matching rule of 3.10.2(27). Nominal subtype diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index 9919cda6340cc..d05c7b6119464 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -40,6 +40,7 @@ with Itypes; use Itypes; with Lib; use Lib; with Lib.Load; use Lib.Load; with Lib.Xref; use Lib.Xref; +with Mutably_Tagged; use Mutably_Tagged; with Nlists; use Nlists; with Namet; use Namet; with Nmake; use Nmake; @@ -1402,8 +1403,8 @@ package body Sem_Ch12 is if No (Formal) then Error_Msg_Sloc := Sloc (Node (Elem)); Error_Msg_NE - ("?instance uses predefined operation, not primitive " - & "operation&#", Actual, Node (Elem)); + ("?instance uses predefined, not primitive, operator&#", + Actual, Node (Elem)); end if; end if; @@ -1490,6 +1491,16 @@ package body Sem_Ch12 is -- Case of positional parameter corresponding to current formal elsif No (Selector_Name (Actual)) then + -- A "<>" without "name =>" is illegal syntax + + if Box_Present (Actual) then + if False then -- ??? + -- Disable this for now, because we have various code that + -- needs to be updated. + Error_Msg_N ("box requires named notation", Actual); + end if; + end if; + Found_Assoc := Actual; Act := Explicit_Generic_Actual_Parameter (Actual); Num_Matched := Num_Matched + 1; @@ -2208,22 +2219,12 @@ package body Sem_Ch12 is end Explicit_Freeze_Check; end if; - -- For use type and use package appearing in the generic part, - -- we have already copied them, so we can just move them where - -- they belong (we mustn't recopy them since this would mess up - -- the Sloc values). + -- Copy use clauses to where they belong when N_Use_Package_Clause | N_Use_Type_Clause => - if Nkind (Original_Node (I_Node)) = - N_Formal_Package_Declaration - then - Append (New_Copy_Tree (Formal), Assoc_List); - else - Remove (Formal); - Append (Formal, Assoc_List); - end if; + Append (New_Copy_Tree (Formal), Assoc_List); when others => raise Program_Error; @@ -11497,6 +11498,10 @@ package body Sem_Ch12 is Error_Msg_N ("illegal discriminant-dependent component for in out parameter", Actual); + elsif Depends_On_Mutably_Tagged_Ext_Comp (Actual) then + Error_Msg_N + ("illegal mutably tagged component for in out parameter", + Actual); end if; -- The actual has to be resolved in order to check that it is a @@ -13228,7 +13233,7 @@ package body Sem_Ch12 is Abandon_Instantiation (Actual); elsif Nkind (Def) = N_Constrained_Array_Definition then - if not (Is_Constrained (Act_T)) then + if not Is_Constrained (Act_T) then Error_Msg_NE ("expect constrained array in instantiation of &", Actual, Gen_T); diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 4cf6fc9a64500..cd47f734462ab 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -43,6 +43,7 @@ with Freeze; use Freeze; with Ghost; use Ghost; with Lib; use Lib; with Lib.Xref; use Lib.Xref; +with Mutably_Tagged; use Mutably_Tagged; with Namet; use Namet; with Nlists; use Nlists; with Nmake; use Nmake; @@ -150,6 +151,15 @@ package body Sem_Ch13 is -- is inserted before the freeze node, and the body of the function is -- inserted after the freeze node. + procedure Check_Aspect_At_End_Of_Declarations (ASN : Node_Id); + -- Performs the processing of an aspect at the freeze all point and issues + -- appropriate error messages if the visibility has indeed changed. ASN is + -- the N_Aspect_Specification node for the aspect. + + procedure Check_Aspect_At_Freeze_Point (ASN : Node_Id); + -- Performs the processing of an aspect at the freeze point. ASN is the + -- N_Aspect_Specification node for the aspect. + procedure Check_Pool_Size_Clash (Ent : Entity_Id; SP, SS : Node_Id); -- Called if both Storage_Pool and Storage_Size attribute definition -- clauses (SP and SS) are present for entity Ent. Issue error message. @@ -1358,7 +1368,11 @@ package body Sem_Ch13 is Validate_Storage_Model_Type_Aspect (E, ASN); when Aspect_Aggregate => - null; + if Is_Array_Type (E) then + Error_Msg_N + ("aspect Aggregate may not be applied to array type", + ASN); + end if; when others => null; @@ -1375,7 +1389,7 @@ package body Sem_Ch13 is Next_Rep_Item (ASN); end loop; - -- Make a second pass for a Full_Access_Only entry + -- Make a second pass for a Full_Access_Only entry, see above why ASN := First_Rep_Item (E); while Present (ASN) loop @@ -1669,7 +1683,6 @@ package body Sem_Ch13 is -- Local variables Aspect : Node_Id; - Aitem : Node_Id := Empty; Ent : Node_Id; L : constant List_Id := Aspect_Specifications (N); @@ -1722,7 +1735,12 @@ package body Sem_Ch13 is Loc : constant Source_Ptr := Sloc (Aspect); Nam : constant Name_Id := Chars (Id); A_Id : constant Aspect_Id := Get_Aspect_Id (Nam); + + Aitem : Node_Id := Empty; + -- The associated N_Pragma or N_Attribute_Definition_Clause + Anod : Node_Id; + -- An auxiliary node Delay_Required : Boolean; -- Set False if delay is not required @@ -1851,6 +1869,8 @@ package body Sem_Ch13 is procedure Analyze_Aspect_Disable_Controlled is begin + Error_Msg_Name_1 := Nam; + -- The aspect applies only to controlled records if not (Ekind (E) = E_Record_Type @@ -2949,19 +2969,6 @@ package body Sem_Ch13 is end if; end case; - if Delay_Required - and then (A_Id = Aspect_Stable_Properties - or else A_Id = Aspect_Designated_Storage_Model - or else A_Id = Aspect_Storage_Model_Type - or else A_Id = Aspect_Aggregate) - -- ??? It seems like we should do this for all aspects, not - -- just these, but that causes as-yet-undiagnosed regressions. - - then - Set_Has_Delayed_Aspects (E); - Set_Is_Delayed_Aspect (Aspect); - end if; - -- Check 13.1(9.2/5): A representation aspect of a subtype or type -- shall not be specified (whether by a representation item or an -- aspect_specification) before the type is completely defined @@ -3065,6 +3072,15 @@ package body Sem_Ch13 is end if; end if; + -- Propagate the 'Size'Class aspect to the class-wide type + + if A_Id = Aspect_Size and then Class_Present (Aspect) then + Ent := + Make_Attribute_Reference (Loc, + Prefix => Ent, + Attribute_Name => Name_Class); + end if; + -- Construct the attribute_definition_clause. The expression -- in the aspect specification is simply shared with the -- constructed attribute, because it will be fully analyzed @@ -3194,6 +3210,22 @@ package body Sem_Ch13 is Set_Has_Static_Predicate_Aspect (E, False); + -- Query the applicable policy since it must rely on the + -- policy applicable in the context of the declaration of + -- entity E; it cannot be done when the built pragma is + -- analyzed because it will be analyzed when E is frozen, + -- and at that point the applicable policy may differ. + -- For example: + + -- pragma Assertion_Policy (Dynamic_Predicate => Check); + -- type T is ... with Dynamic_Predicate => ... + -- pragma Assertion_Policy (Dynamic_Predicate => Ignore); + -- X : T; -- freezes T + + Set_Predicates_Ignored (E, + Policy_In_Effect (Name_Dynamic_Predicate) + = Name_Ignore); + elsif A_Id = Aspect_Static_Predicate then Set_Has_Static_Predicate_Aspect (E); elsif A_Id = Aspect_Ghost_Predicate then @@ -3291,6 +3323,9 @@ package body Sem_Ch13 is -- External_Name, Link_Name + -- Only the legality checks are done during the analysis, thus + -- no delay is required. + when Aspect_External_Name | Aspect_Link_Name => @@ -3763,32 +3798,6 @@ package body Sem_Ch13 is Insert_Pragma (Aitem); goto Continue; - -- No_Controlled_Parts, No_Task_Parts - - when Aspect_No_Controlled_Parts | Aspect_No_Task_Parts => - - -- Check appropriate type argument - - if not Is_Type (E) then - Error_Msg_N - ("aspect % can only be applied to types", E); - end if; - - -- Disallow subtypes - - if Nkind (Declaration_Node (E)) = N_Subtype_Declaration then - Error_Msg_N - ("aspect % cannot be applied to subtypes", E); - end if; - - -- Resolve the expression to a boolean - - if Present (Expr) then - Check_Expr_Is_OK_Static_Expression (Expr, Any_Boolean); - end if; - - goto Continue; - -- Obsolescent when Aspect_Obsolescent => declare @@ -4110,30 +4119,20 @@ package body Sem_Ch13 is end if; end if; - Aitem := Empty; - when Aspect_Aggregate => - -- We will be checking that the aspect is not specified on a - -- non-array type in Check_Aspect_At_Freeze_Point + -- We will be checking that the aspect is not specified on + -- an array type in Analyze_Aspects_At_Freeze_Point. Validate_Aspect_Aggregate (Expr); - Record_Rep_Item (E, Aspect); - goto Continue; - - when Aspect_Local_Restrictions => - Validate_Aspect_Local_Restrictions (E, Expr); - Record_Rep_Item (E, Aspect); - goto Continue; when Aspect_Stable_Properties => Validate_Aspect_Stable_Properties (E, Expr, Class_Present => Class_Present (Aspect)); - Record_Rep_Item (E, Aspect); - goto Continue; when Aspect_Designated_Storage_Model => if not All_Extensions_Allowed then Error_Msg_GNAT_Extension ("aspect %", Loc); + goto Continue; elsif not Is_Type (E) or else Ekind (E) /= E_Access_Type @@ -4141,14 +4140,13 @@ package body Sem_Ch13 is Error_Msg_N ("can only be specified for pool-specific access type", Aspect); + goto Continue; end if; - Record_Rep_Item (E, Aspect); - goto Continue; - when Aspect_Storage_Model_Type => if not All_Extensions_Allowed then Error_Msg_GNAT_Extension ("aspect %", Loc); + goto Continue; elsif not Is_Type (E) or else not Is_Immutably_Limited_Type (E) @@ -4156,11 +4154,9 @@ package body Sem_Ch13 is Error_Msg_N ("can only be specified for immutably limited type", Aspect); + goto Continue; end if; - Record_Rep_Item (E, Aspect); - goto Continue; - when Aspect_Integer_Literal | Aspect_Real_Literal | Aspect_String_Literal @@ -4177,16 +4173,13 @@ package body Sem_Ch13 is (No_Implementation_Aspect_Specifications, N); end if; - Aitem := Empty; - -- Case 3b: The aspects listed below don't correspond to -- pragmas/attributes and don't need delayed analysis. -- Implicit_Dereference - -- For Implicit_Dereference, External_Name and Link_Name, only - -- the legality checks are done during the analysis, thus no - -- delay is required. + -- Only the legality checks are done during the analysis, thus + -- no delay is required. when Aspect_Implicit_Dereference => Analyze_Aspect_Implicit_Dereference; @@ -4204,6 +4197,11 @@ package body Sem_Ch13 is Analyze_Aspect_Dimension_System (N, Id, Expr); goto Continue; + when Aspect_Local_Restrictions => + Validate_Aspect_Local_Restrictions (E, Expr); + Record_Rep_Item (E, Aspect); + goto Continue; + -- Case 4: Aspects requiring special handling -- Pre/Post/Test_Case/Contract_Cases/Always_Terminates/ @@ -4481,6 +4479,45 @@ package body Sem_Ch13 is elsif A_Id = Aspect_Full_Access_Only then Error_Msg_Ada_2022_Feature ("aspect %", Loc); + -- No_Controlled_Parts, No_Task_Parts + + elsif A_Id in Aspect_No_Controlled_Parts + | Aspect_No_Task_Parts + then + Error_Msg_Name_1 := Nam; + + -- Disallow formal types + + if Nkind (Original_Node (N)) = N_Formal_Type_Declaration + then + Error_Msg_N + ("aspect % not allowed for formal type declaration", + Aspect); + + -- Disallow subtypes + + elsif Nkind (Original_Node (N)) = N_Subtype_Declaration + then + Error_Msg_N + ("aspect % not allowed for subtype declaration", + Aspect); + + -- Accept all other types + + elsif not Is_Type (E) then + Error_Msg_N + ("aspect % can only be specified for a type", + Aspect); + end if; + + -- Resolve the expression to a boolean + + if Present (Expr) then + Check_Expr_Is_OK_Static_Expression (Expr, Any_Boolean); + end if; + + goto Continue; + -- Ada 2022 (AI12-0075): static expression functions elsif A_Id = Aspect_Static then @@ -4790,6 +4827,7 @@ package body Sem_Ch13 is end if; end; end if; + exception when Aspect_Exit => null; end Analyze_One_Aspect; @@ -7324,6 +7362,70 @@ package body Sem_Ch13 is & "supported", N); end if; + -- Handle extension aspect 'Size'Class which allows for + -- "mutably tagged" types. + + if Ekind (Etyp) = E_Class_Wide_Type then + Error_Msg_GNAT_Extension + ("attribute size class", Sloc (N)); + + -- Check for various restrictions applied to mutably + -- tagged types. + + if Is_Derived_Type (Etype (Etyp)) then + Error_Msg_N + ("cannot be specified on derived types", Nam); + + elsif Ekind (Etype (Prefix (Nam))) = E_Record_Subtype then + Error_Msg_N + ("cannot be specified on a subtype", Nam); + + elsif Is_Interface (Etype (Etyp)) then + Error_Msg_N + ("cannot be specified on interface types", Nam); + + elsif Has_Discriminants (Etype (Etyp)) then + Error_Msg_N + ("cannot be specified on discriminated type", Nam); + + elsif Present (Incomplete_Or_Partial_View (Etype (Etyp))) + and then Is_Tagged_Type + (Incomplete_Or_Partial_View (Etype (Etyp))) + then + Error_Msg_N + ("cannot be specified on a type whose partial view" + & " is tagged", Nam); + + -- Otherwise, the declaration is valid + + else + declare + Actions : List_Id; + begin + -- Generate our class-wide equivalent type which + -- is sized according to the value specified by + -- 'Size'Class. + + Set_Class_Wide_Equivalent_Type (Etyp, + Make_CW_Equivalent_Type (Etyp, Empty, Actions)); + + -- Add a Compile_Time_Error sizing check as a hint + -- to the backend. + + Append_To (Actions, + Make_CW_Size_Compile_Check + (Etype (Etyp), U_Ent)); + + -- Set the expansion to occur during freezing when + -- everything is analyzed + + Append_Freeze_Actions (Etyp, Actions); + + Set_Is_Mutably_Tagged_Type (Etyp); + end; + end if; + end if; + Set_Has_Size_Clause (U_Ent); end; end if; @@ -11107,6 +11209,7 @@ package body Sem_Ch13 is elsif A_Id in Aspect_CPU | Aspect_Dynamic_Predicate | Aspect_Ghost_Predicate + | Aspect_Interrupt_Priority | Aspect_Predicate | Aspect_Priority | Aspect_Static_Predicate @@ -11133,12 +11236,35 @@ package body Sem_Ch13 is Error_Msg_NE ("!visibility of aspect for& changes after freeze point", ASN, Ent); + Error_Msg_Sloc := Sloc (Freeze_Node (Ent)); Error_Msg_NE - ("info: & is frozen here, (RM 13.1.1 (13/3))??", - Freeze_Node (Ent), Ent); + ("\& is frozen #, (RM 13.1.1 (13/3))", + ASN, Ent); end if; end Check_Aspect_At_End_Of_Declarations; + ------------------------------------------ + -- Check_Aspects_At_End_Of_Declarations -- + ------------------------------------------ + + procedure Check_Aspects_At_End_Of_Declarations (E : Entity_Id) is + ASN : Node_Id; + + begin + ASN := First_Rep_Item (E); + + while Present (ASN) loop + if Nkind (ASN) = N_Aspect_Specification + and then Entity (ASN) = E + and then Is_Delayed_Aspect (ASN) + then + Check_Aspect_At_End_Of_Declarations (ASN); + end if; + + Next_Rep_Item (ASN); + end loop; + end Check_Aspects_At_End_Of_Declarations; + ---------------------------------- -- Check_Aspect_At_Freeze_Point -- ---------------------------------- @@ -11345,11 +11471,6 @@ package body Sem_Ch13 is return; when Aspect_Aggregate => - if Is_Array_Type (Entity (ASN)) then - Error_Msg_N - ("aspect& can only be applied to non-array type", - Ident); - end if; Resolve_Aspect_Aggregate (Entity (ASN), Expression (ASN)); return; @@ -11433,8 +11554,6 @@ package body Sem_Ch13 is | Aspect_Max_Entry_Queue_Depth | Aspect_Max_Entry_Queue_Length | Aspect_Max_Queue_Length - | Aspect_No_Controlled_Parts - | Aspect_No_Task_Parts | Aspect_Obsolescent | Aspect_Part_Of | Aspect_Post @@ -12859,7 +12978,7 @@ package body Sem_Ch13 is procedure Hide_Non_Overridden_Subprograms (Typ : Entity_Id); -- Inspect the primitive operations of type Typ and hide all pairs of -- implicitly declared non-overridden non-fully conformant homographs - -- (Ada RM 8.3 12.3/2). + -- (RM 8.3(12.3/2)). ------------------------------------- -- Hide_Non_Overridden_Subprograms -- @@ -13009,8 +13128,6 @@ package body Sem_Ch13 is and then Nongeneric_Case and then Ekind (E) = E_Record_Type and then Is_Tagged_Type (E) - and then not Is_Interface (E) - and then Has_Interfaces (E) then -- This would be a good common place to call the routine that checks -- overriding of interface primitives (and thus factorize calls to @@ -13018,7 +13135,22 @@ package body Sem_Ch13 is -- compiler). However, this is not possible because it causes -- spurious errors in case of late overriding. - Add_Internal_Interface_Entities (E); + if Has_Interfaces (E) + and then not Is_Interface (E) + then + Add_Internal_Interface_Entities (E); + end if; + + -- For a derived tagged type, check strub mode compatibility of + -- its primitives and whether inherited primitives might require + -- a wrapper to handle class-wide conditions. For derived interface + -- check strub mode compatibility of its primitives. + + if Is_Derived_Type (E) + and then not In_Generic_Scope (E) + then + Check_Inherited_Conditions (E); + end if; end if; -- After all forms of overriding have been resolved, a tagged type may @@ -13027,7 +13159,7 @@ package body Sem_Ch13 is -- overriding. If this set contains fully conformant homographs, then -- one is chosen arbitrarily (already done during resolution), otherwise -- all remaining non-fully conformant homographs are hidden from - -- visibility (Ada RM 8.3 12.3/2). + -- visibility (RM 8.3(12.3/2)). if Is_Tagged_Type (E) then Hide_Non_Overridden_Subprograms (E); @@ -13366,6 +13498,7 @@ package body Sem_Ch13 is if Get_Aspect_Id (Ritem) in Aspect_CPU | Aspect_Dynamic_Predicate | Aspect_Ghost_Predicate + | Aspect_Interrupt_Priority | Aspect_Predicate | Aspect_Static_Predicate | Aspect_Priority @@ -14139,9 +14272,7 @@ package body Sem_Ch13 is | Aspect_Size => if not Has_Size_Clause (Typ) - and then - No (Get_Attribute_Definition_Clause - (Typ, Attribute_Object_Size)) + and then No (Object_Size_Clause (Typ)) then Set_Esize (Typ, Esize (P)); end if; @@ -15881,7 +16012,10 @@ package body Sem_Ch13 is Set_Must_Not_Freeze (Expr); Preanalyze_Spec_Expression (Expr, E); - when Aspect_Priority => + when Aspect_CPU + | Aspect_Interrupt_Priority + | Aspect_Priority + => Push_Type (E); Preanalyze_Spec_Expression (Expr, Any_Integer); Pop_Type (E); diff --git a/gcc/ada/sem_ch13.ads b/gcc/ada/sem_ch13.ads index 3c48a493c757d..aeacda833d1ed 100644 --- a/gcc/ada/sem_ch13.ads +++ b/gcc/ada/sem_ch13.ads @@ -312,18 +312,17 @@ package Sem_Ch13 is -- Quite an awkward approach, but this is an awkard requirement procedure Analyze_Aspects_At_Freeze_Point (E : Entity_Id); - -- Analyze all the delayed aspects for entity E at freezing point. This - -- includes dealing with inheriting delayed aspects from the parent type - -- in the case where a derived type is frozen. + -- Analyzes all the delayed aspects for entity E at the freeze point. Note + -- that this does not include dealing with inheriting delayed aspects from + -- the parent or base type in the case where a derived type or a subtype is + -- frozen. Callers should check that Has_Delayed_Aspects (E) is True before + -- calling this routine. - procedure Check_Aspect_At_Freeze_Point (ASN : Node_Id); - -- Performs the processing described above at the freeze point, ASN is the - -- N_Aspect_Specification node for the aspect. - - procedure Check_Aspect_At_End_Of_Declarations (ASN : Node_Id); + procedure Check_Aspects_At_End_Of_Declarations (E : Entity_Id); -- Performs the processing described above at the freeze all point, and -- issues appropriate error messages if the visibility has indeed changed. - -- Again, ASN is the N_Aspect_Specification node for the aspect. + -- Callers should check that Has_Delayed_Aspects (E) is True before calling + -- this routine. procedure Inherit_Aspects_At_Freeze_Point (Typ : Entity_Id); -- Given an entity Typ that denotes a derived type or a subtype, this diff --git a/gcc/ada/sem_ch2.adb b/gcc/ada/sem_ch2.adb index db17023db28f9..aae9990eb4d9b 100644 --- a/gcc/ada/sem_ch2.adb +++ b/gcc/ada/sem_ch2.adb @@ -27,6 +27,7 @@ with Atree; use Atree; with Einfo; use Einfo; with Einfo.Utils; use Einfo.Utils; with Ghost; use Ghost; +with Mutably_Tagged; use Mutably_Tagged; with Namet; use Namet; with Nlists; use Nlists; with Opt; use Opt; @@ -81,6 +82,12 @@ package body Sem_Ch2 is Find_Direct_Name (N); end if; + -- Generate a conversion when we see an expanded mutably tagged type + + if Is_Mutably_Tagged_CW_Equivalent_Type (Etype (N)) then + Make_Mutably_Tagged_Conversion (N); + end if; + -- A Ghost entity must appear in a specific context. Only do this -- checking on non-overloaded expressions, as otherwise we need to -- wait for resolution, and the checking is done in Resolve_Entity_Name. diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 263be607ec14b..76e5cdcbf5d02 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -48,6 +48,7 @@ with Itypes; use Itypes; with Layout; use Layout; with Lib; use Lib; with Lib.Xref; use Lib.Xref; +with Mutably_Tagged; use Mutably_Tagged; with Namet; use Namet; with Nlists; use Nlists; with Nmake; use Nmake; @@ -1616,7 +1617,7 @@ package body Sem_Ch3 is Last_Tag := Empty; - if not (Present (Component_List (Ext))) then + if not Present (Component_List (Ext)) then Set_Null_Present (Ext, False); L := New_List; Set_Component_List (Ext, @@ -2162,6 +2163,7 @@ package body Sem_Ch3 is -- and thus unconstrained. Regular components must be constrained. if not Is_Definite_Subtype (T) + and then not Is_Mutably_Tagged_Type (T) and then Chars (Id) /= Name_uParent then if Is_Class_Wide_Type (T) then @@ -4802,8 +4804,30 @@ package body Sem_Ch3 is null; elsif Is_Class_Wide_Type (T) then - Error_Msg_N - ("initialization required in class-wide declaration", N); + + -- Case of a mutably tagged type + + if Is_Mutably_Tagged_Type (T) then + Act_T := Class_Wide_Equivalent_Type (T); + + Rewrite (Object_Definition (N), + New_Occurrence_Of (Act_T, Loc)); + + Insert_After (N, + Make_Procedure_Call_Statement (Loc, + Name => New_Occurrence_Of (Init_Proc (Etype (T)), Loc), + Parameter_Associations => New_List ( + Unchecked_Convert_To + (Etype (T), New_Occurrence_Of (Id, Loc))))); + + Freeze_Before (N, Act_T); + + -- Otherwise an initial expression is required + + else + Error_Msg_N + ("initialization required in class-wide declaration", N); + end if; else Error_Msg_N @@ -4900,6 +4924,17 @@ package body Sem_Ch3 is goto Leave; end if; + -- Rewrite mutably tagged class-wide type declarations to be that + -- of the corresponding class-wide equivalent type. + + elsif Is_Mutably_Tagged_Type (T) then + Act_T := Class_Wide_Equivalent_Type (T); + + Rewrite (Object_Definition (N), + New_Occurrence_Of (Act_T, Loc)); + + Freeze_Before (N, Act_T); + else -- Ensure that the generated subtype has a unique external name -- when the related object is public. This guarantees that the @@ -5246,8 +5281,7 @@ package body Sem_Ch3 is E := First_Entity (Etype (Id)); while Present (E) loop if Ekind (E) = E_Entry - and then Present (Get_Attribute_Definition_Clause - (E, Attribute_Address)) + and then Present (Address_Clause (E)) then Error_Msg_Warn := SPARK_Mode /= On; Error_Msg_N @@ -6680,7 +6714,11 @@ package body Sem_Ch3 is -- that all the indexes are unconstrained but we still need to make sure -- that the element type is constrained. - if not Is_Definite_Subtype (Element_Type) then + if Is_Mutably_Tagged_Type (Element_Type) then + Set_Component_Type (T, + Class_Wide_Equivalent_Type (Element_Type)); + + elsif not Is_Definite_Subtype (Element_Type) then Error_Msg_N ("unconstrained element type in array declaration", Subtype_Indication (Component_Def)); @@ -12454,7 +12492,7 @@ package body Sem_Ch3 is procedure Check_Delta_Expression (E : Node_Id) is begin - if not (Is_Real_Type (Etype (E))) then + if not Is_Real_Type (Etype (E)) then Wrong_Type (E, Any_Real); elsif not Is_OK_Static_Expression (E) then @@ -12482,7 +12520,7 @@ package body Sem_Ch3 is procedure Check_Digits_Expression (E : Node_Id) is begin - if not (Is_Integer_Type (Etype (E))) then + if not Is_Integer_Type (Etype (E)) then Wrong_Type (E, Any_Integer); elsif not Is_OK_Static_Expression (E) then @@ -16553,7 +16591,7 @@ package body Sem_Ch3 is New_Overloaded_Entity (New_Subp, Derived_Type); - -- Ada RM 6.1.1 (15): If a subprogram inherits nonconforming class-wide + -- RM 6.1.1(15): If a subprogram inherits nonconforming class-wide -- preconditions and the derived type is abstract, the derived operation -- is abstract as well if parent subprogram is not abstract or null. @@ -17775,6 +17813,83 @@ package body Sem_Ch3 is Build_Derived_Type (N, Parent_Type, T, Is_Completion, Derive_Subps => not Is_Underlying_Record_View (T)); + -- Check for special mutably tagged type declarations + + if Is_Tagged_Type (Parent_Type) + and then not Error_Posted (T) + then + declare + Actions : List_Id; + CW_Typ : constant Entity_Id := Class_Wide_Type (T); + Root_Class_Typ : constant Entity_Id := + Class_Wide_Type (Root_Type (Parent_Type)); + begin + -- Perform various checks when we are indeed looking at a + -- mutably tagged declaration. + + if Present (Root_Class_Typ) + and then Is_Mutably_Tagged_Type (Root_Class_Typ) + then + -- Verify the level of the descendant's declaration is not + -- deeper than the root type since this could cause leaking + -- of the type. + + if Scope (Root_Class_Typ) /= Scope (T) + and then Deepest_Type_Access_Level (Root_Class_Typ) + < Deepest_Type_Access_Level (T) + then + Error_Msg_NE + ("descendant of mutably tagged type cannot be deeper than" + & " its root", N, Root_Type (T)); + + elsif Present (Incomplete_Or_Partial_View (T)) + and then Is_Tagged_Type (Incomplete_Or_Partial_View (T)) + then + Error_Msg_N + ("descendant of mutably tagged type cannot a have partial" + & " view which is tagged", N); + + -- Mutably tagged types cannot have discriminants + + elsif Present (Discriminant_Specifications (N)) then + Error_Msg_N + ("descendant of mutably tagged type cannot have" + & " discriminates", N); + + elsif Present (Interfaces (T)) + and then not Is_Empty_Elmt_List (Interfaces (T)) + then + Error_Msg_N + ("descendant of mutably tagged type cannot implement" + & " an interface", N); + + -- We have a valid descendant type + + else + -- Set inherited attributes + + Set_Has_Size_Clause (CW_Typ); + Set_RM_Size (CW_Typ, RM_Size (Root_Class_Typ)); + Set_Is_Mutably_Tagged_Type (CW_Typ); + + -- Generate a new class-wide equivalent type + + Set_Class_Wide_Equivalent_Type (CW_Typ, + Make_CW_Equivalent_Type (CW_Typ, Empty, Actions)); + + Insert_List_After_And_Analyze (N, Actions); + + -- Add a Compile_Time_Error sizing check as a hint + -- to the backend since we don't know the true size of + -- anything at this point. + + Insert_After_And_Analyze (N, + Make_CW_Size_Compile_Check (T, Root_Class_Typ)); + end if; + end if; + end; + end if; + -- AI-419: The parent type of an explicitly limited derived type must -- be a limited type or a limited interface. diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 03364dade9f63..e75f8dfb6bcb7 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -36,6 +36,7 @@ with Exp_Util; use Exp_Util; with Itypes; use Itypes; with Lib; use Lib; with Lib.Xref; use Lib.Xref; +with Mutably_Tagged; use Mutably_Tagged; with Namet; use Namet; with Namet.Sp; use Namet.Sp; with Nlists; use Nlists; @@ -623,6 +624,12 @@ package body Sem_Ch4 is Make_Index_Or_Discriminant_Constraint (Loc, Constraints => Constr))); end; + + -- Rewrite the mutably tagged type to a non-class-wide type for + -- proper initialization. + + elsif Is_Mutably_Tagged_Type (Type_Id) then + Rewrite (E, New_Occurrence_Of (Etype (Type_Id), Loc)); end if; end if; @@ -2885,6 +2892,12 @@ package body Sem_Ch4 is Set_Etype (N, Component_Type (Array_Type)); Check_Implicit_Dereference (N, Etype (N)); + -- Generate conversion to class-wide type + + if Is_Mutably_Tagged_CW_Equivalent_Type (Etype (N)) then + Make_Mutably_Tagged_Conversion (N); + end if; + if Present (Index) then Error_Msg_N ("too few subscripts in array reference", First (Exprs)); @@ -4069,6 +4082,17 @@ package body Sem_Ch4 is Next_Actual (Actual); Next_Formal (Formal); + -- Generate a class-wide type conversion for instances of + -- class-wide equivalent types to their corresponding + -- mutably tagged type. + + elsif Is_Mutably_Tagged_CW_Equivalent_Type (Etype (Actual)) + and then Etype (Formal) = Parent_Subtype (Etype (Actual)) + then + Make_Mutably_Tagged_Conversion (Actual); + Next_Actual (Actual); + Next_Formal (Formal); + -- Handle failed type check else @@ -5294,6 +5318,11 @@ package body Sem_Ch4 is Prefix_Type := Implicitly_Designated_Type (Prefix_Type); end if; + -- Handle mutably tagged types + + elsif Is_Class_Wide_Equivalent_Type (Prefix_Type) then + Prefix_Type := Parent_Subtype (Prefix_Type); + -- If we have an explicit dereference of a remote access-to-class-wide -- value, then issue an error (see RM-E.2.2(16/1)). However we first -- have to check for the case of a prefix that is a controlling operand @@ -5389,7 +5418,6 @@ package body Sem_Ch4 is Check_Implicit_Dereference (N, Etype (Comp)); elsif Is_Record_Type (Prefix_Type) then - -- Find a component with the given name. If the node is a prefixed -- call, do not examine components whose visibility may be -- accidental. @@ -5559,6 +5587,13 @@ package body Sem_Ch4 is Set_Etype (N, Etype (Comp)); end if; + -- Force the generation of a mutably tagged type conversion + -- when we encounter a special class-wide equivalent type. + + if Is_Mutably_Tagged_CW_Equivalent_Type (Etype (Name)) then + Make_Mutably_Tagged_Conversion (Name, Force => True); + end if; + Check_Implicit_Dereference (N, Etype (N)); return; end if; @@ -6328,6 +6363,30 @@ package body Sem_Ch4 is ("formal parameter cannot be converted to class-wide type when " & "Extensions_Visible is False", Expr); end if; + + -- Perform special checking for access to mutably tagged type since they + -- are not compatible with interfaces. + + if Is_Access_Type (Typ) + and then Is_Access_Type (Etype (Expr)) + and then not Error_Posted (N) + then + + if Is_Mutably_Tagged_Type (Directly_Designated_Type (Typ)) + and then Is_Interface (Directly_Designated_Type (Etype (Expr))) + then + Error_Msg_N + ("argument of conversion to mutably tagged access type cannot " + & "be access to interface", Expr); + + elsif Is_Mutably_Tagged_Type (Directly_Designated_Type (Etype (Expr))) + and then Is_Interface (Directly_Designated_Type (Typ)) + then + Error_Msg_N + ("argument of conversion to interface access type cannot " + & "be access to mutably tagged type", Expr); + end if; + end if; end Analyze_Type_Conversion; ---------------------- @@ -9805,11 +9864,23 @@ package body Sem_Ch4 is begin Error := False; + -- When climbing through the parents of an interface type, + -- look for acceptable class-wide homonyms associated with + -- the interface type. + + if Is_Interface (Anc_Type) then + Traverse_Homonyms (Anc_Type, Error); + + if Error then + return; + end if; + end if; + Intface := First (Intface_List); while Present (Intface) loop -- Look for acceptable class-wide homonyms associated with the - -- interface. + -- interface type. Traverse_Homonyms (Etype (Intface), Error); @@ -9828,6 +9899,15 @@ package body Sem_Ch4 is Next (Intface); end loop; + + -- For derived interface types continue the search climbing to + -- the parent type. + + if Is_Interface (Anc_Type) + and then Etype (Anc_Type) /= Anc_Type + then + Traverse_Interfaces (Etype (Anc_Type), Error); + end if; end Traverse_Interfaces; -- Start of processing for Try_Class_Wide_Operation diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb index 1e09e57919e1b..b92ceb17b1baa 100644 --- a/gcc/ada/sem_ch5.adb +++ b/gcc/ada/sem_ch5.adb @@ -39,6 +39,7 @@ with Freeze; use Freeze; with Ghost; use Ghost; with Lib; use Lib; with Lib.Xref; use Lib.Xref; +with Mutably_Tagged; use Mutably_Tagged; with Namet; use Namet; with Nlists; use Nlists; with Nmake; use Nmake; @@ -676,11 +677,17 @@ package body Sem_Ch5 is Set_Assignment_Type (Lhs, T1); - -- If the target of the assignment is an entity of a mutable type and - -- the expression is a conditional expression, its alternatives can be - -- of different subtypes of the nominal type of the LHS, so they must be - -- resolved with the base type, given that their subtype may differ from - -- that of the target mutable object. + -- When analyzing a mutably tagged class-wide equivalent type pretend we + -- are actually looking at the mutably tagged type itself for proper + -- analysis. + + T1 := Get_Corresponding_Mutably_Tagged_Type_If_Present (T1); + + -- If the target of the assignment is an entity of a mutably tagged type + -- and the expression is a conditional expression, its alternatives can + -- be of different subtypes of the nominal type of the LHS, so they must + -- be resolved with the base type, given that their subtype may differ + -- from that of the target mutable object. if Is_Entity_Name (Lhs) and then Is_Assignable (Entity (Lhs)) @@ -2500,6 +2507,13 @@ package body Sem_Ch5 is Error_Msg_N ("iterable name cannot be a discriminant-dependent " & "component of a mutable object", N); + + elsif Depends_On_Mutably_Tagged_Ext_Comp + (Original_Node (Iter_Name)) + then + Error_Msg_N + ("iterable name cannot depend on a mutably tagged component", + N); end if; Check_Subtype_Definition (Component_Type (Typ)); @@ -2630,6 +2644,13 @@ package body Sem_Ch5 is Error_Msg_N ("container cannot be a discriminant-dependent " & "component of a mutable object", N); + + elsif Depends_On_Mutably_Tagged_Ext_Comp + (Orig_Iter_Name) + then + Error_Msg_N + ("container cannot depend on a mutably tagged " + & "component", N); end if; end if; end; @@ -2716,6 +2737,11 @@ package body Sem_Ch5 is Error_Msg_N ("container cannot be a discriminant-dependent " & "component of a mutable object", N); + + elsif Depends_On_Mutably_Tagged_Ext_Comp (Obj) then + Error_Msg_N + ("container cannot depend on a mutably tagged" + & " component", N); end if; end; end if; diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index ca40b5479e092..e97afdaf12e7d 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -4083,6 +4083,15 @@ package body Sem_Ch6 is else Set_Corresponding_Spec (N, Spec_Id); + -- The body entity is not used for semantics or code generation, + -- but it is attached to the entity list of the enclosing scope + -- to allow listing its entities when outputting representation + -- information. + + if Scope (Spec_Id) /= Standard_Standard then + Append_Entity (Body_Id, Scope (Spec_Id)); + end if; + -- Ada 2005 (AI-345): If the operation is a primitive operation -- of a concurrent type, the type of the first parameter has been -- replaced with the corresponding record, which is the proper @@ -8663,9 +8672,12 @@ package body Sem_Ch6 is -- Determines if E has its extra formals function Might_Need_BIP_Task_Actuals (E : Entity_Id) return Boolean; - -- Determines if E is a dispatching primitive returning a limited tagged - -- type object since some descendant might return an object with tasks - -- (and therefore need the BIP task extra actuals). + -- Determines if E is a function or an access to a function returning a + -- limited tagged type object. On dispatching primitives this predicate + -- is used to determine if some descendant of the function might return + -- an object with tasks (and therefore need the BIP task extra actuals). + -- On access-to-subprogram types it is used to determine if the target + -- function might return an object with tasks. function Needs_Accessibility_Check_Extra (E : Entity_Id; @@ -8786,9 +8798,8 @@ package body Sem_Ch6 is Func_Typ := Root_Type (Underlying_Type (Etype (Subp_Id))); - return Ekind (Subp_Id) = E_Function + return Ekind (Subp_Id) in E_Function | E_Subprogram_Type and then not Has_Foreign_Convention (Func_Typ) - and then Is_Dispatching_Operation (Subp_Id) and then Is_Tagged_Type (Func_Typ) and then Is_Limited_Type (Func_Typ) and then not Has_Aspect (Func_Typ, Aspect_No_Task_Parts); @@ -9171,9 +9182,15 @@ package body Sem_Ch6 is -- If the type does not have a completion yet, treat as prior to -- Ada 2012 for consistency. - if Has_Discriminants (Formal_Type) + -- Note that we need also to handle mutably tagged types in the + -- same way as discriminated types since they can be constrained + -- or unconstrained as well. + + if (Has_Discriminants (Formal_Type) + or else Is_Mutably_Tagged_Type (Formal_Type)) and then not Is_Constrained (Formal_Type) - and then Is_Definite_Subtype (Formal_Type) + and then (Is_Definite_Subtype (Formal_Type) + or else Is_Mutably_Tagged_Type (Formal_Type)) and then (Ada_Version < Ada_2012 or else No (Underlying_Type (Formal_Type)) or else not diff --git a/gcc/ada/sem_ch7.adb b/gcc/ada/sem_ch7.adb index a70d72c94c1ee..0f0fc90ad6b73 100644 --- a/gcc/ada/sem_ch7.adb +++ b/gcc/ada/sem_ch7.adb @@ -2400,7 +2400,7 @@ package body Sem_Ch7 is -- Do not enter implicitly inherited non-overridden subprograms of -- a tagged type back into visibility if they have non-conformant - -- homographs (Ada RM 8.3 12.3/2). + -- homographs (RM 8.3(12.3/2)). elsif Is_Hidden_Non_Overridden_Subpgm (Id) then null; @@ -2827,13 +2827,14 @@ package body Sem_Ch7 is -- Otherwise test to see if entity requires a completion. Note that -- subprogram entities whose declaration does not come from source are -- ignored here on the basis that we assume the expander will provide an - -- implicit completion at some point. + -- implicit completion at some point. In particular, an inherited + -- subprogram of a derived type should not cause us to return True here. elsif (Is_Overloadable (Id) and then Ekind (Id) not in E_Enumeration_Literal | E_Operator and then not Is_Abstract_Subprogram (Id) and then not Has_Completion (Id) - and then Comes_From_Source (Parent (Id))) + and then Comes_From_Source (Id)) or else (Ekind (Id) = E_Package diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb index 125ccc6c433ad..d2752af320ea7 100644 --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -39,6 +39,7 @@ with Lib; use Lib; with Lib.Load; use Lib.Load; with Lib.Xref; use Lib.Xref; with Local_Restrict; +with Mutably_Tagged; use Mutably_Tagged; with Namet; use Namet; with Namet.Sp; use Namet.Sp; with Nlists; use Nlists; @@ -1511,6 +1512,10 @@ package body Sem_Ch8 is if Is_Dependent_Component_Of_Mutable_Object (Nam) then Error_Msg_N ("illegal renaming of discriminant-dependent component", Nam); + elsif Depends_On_Mutably_Tagged_Ext_Comp (Nam) then + Error_Msg_N + ("illegal renaming of mutably tagged dependent component", + Nam); end if; -- If the renaming comes from source and the renamed object is a @@ -2094,6 +2099,10 @@ package body Sem_Ch8 is Error_Msg_N ("illegal renaming of discriminant-dependent component", Nam); + elsif Depends_On_Mutably_Tagged_Ext_Comp (Nam) then + Error_Msg_N + ("illegal renaming of mutably tagged dependent component", + Nam); end if; else Error_Msg_N ("expect object name in renaming", Nam); diff --git a/gcc/ada/sem_disp.adb b/gcc/ada/sem_disp.adb index fd521a09bc0fd..9c498ee9a3f7e 100644 --- a/gcc/ada/sem_disp.adb +++ b/gcc/ada/sem_disp.adb @@ -1388,10 +1388,13 @@ package body Sem_Disp is -- 3. Subprograms associated with stream attributes (built by -- New_Stream_Subprogram) or with the Put_Image attribute. - -- 4. Wrappers built for inherited operations with inherited class- - -- wide conditions, where the conditions include calls to other - -- overridden primitives. The wrappers include checks on these - -- modified conditions. (AI12-195). + -- 4. Wrappers built for inherited operations. We have two kinds: + -- * Wrappers built for inherited operations with inherited class- + -- wide conditions, where the conditions include calls to other + -- overridden primitives. The wrappers include checks on these + -- modified conditions (AI12-195). + -- * Wrappers built for inherited operations that implement + -- interface primitives that have class-wide postconditions. -- 5. Declarations built for subprograms without separate specs that -- are eligible for inlining in GNATprove (inside @@ -1419,7 +1422,7 @@ package body Sem_Disp is or else (Is_Wrapper (Subp) - and then Present (LSP_Subprogram (Subp))) + and then Is_Dispatch_Table_Wrapper (Subp)) or else GNATprove_Mode); diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index a895fd2053ac2..d3b29089d772f 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -2966,16 +2966,18 @@ package body Sem_Prag is (Item : Node_Id; Item_Id : Entity_Id) is - Context : Entity_Id; - Dummy : Boolean; - Inputs : Elist_Id := No_Elist; - Outputs : Elist_Id := No_Elist; + Context : Entity_Id; + Dummy : Boolean; + Item_View : Entity_Id; + Inputs : Elist_Id := No_Elist; + Outputs : Elist_Id := No_Elist; begin -- Traverse the scope stack looking for enclosing subprograms or -- tasks subject to pragma [Refined_]Global. Context := Scope (Subp_Id); + Check_Context : while Present (Context) and then Context /= Standard_Standard loop -- For a single task type, retrieve the corresponding object to @@ -2997,35 +2999,64 @@ package body Sem_Prag is Subp_Outputs => Outputs, Global_Seen => Dummy); - -- The item is classified as In_Out or Output but appears as - -- an Input or a formal parameter of mode IN in an enclosing - -- subprogram or task unit (SPARK RM 6.1.4(13)). + -- If the item is a constituent, we must check not just the + -- item itself, but also its encapsulating abstract states. - if Appears_In (Inputs, Item_Id) - and then not Appears_In (Outputs, Item_Id) - then - SPARK_Msg_NE - ("global item & cannot have mode In_Out or Output", - Item, Item_Id); + Item_View := Item_Id; - if Is_Subprogram_Or_Entry (Context) then - SPARK_Msg_NE - (Fix_Msg (Subp_Id, "\item already appears as input " - & "of subprogram &"), Item, Context); - else - SPARK_Msg_NE - (Fix_Msg (Subp_Id, "\item already appears as input " - & "of task &"), Item, Context); + Check_View : loop + -- The item is classified as In_Out or Output but appears + -- as an Input or a formal parameter of mode IN in + -- an enclosing subprogram or task unit (SPARK RM + -- 6.1.4(13)). + + if Appears_In (Inputs, Item_View) + and then not Appears_In (Outputs, Item_View) + then + if Item_View = Item_Id then + SPARK_Msg_NE + ("global item & " & + "cannot have mode In_Out or Output", + Item, Item_Id); + else + Error_Msg_Node_2 := Item_View; + SPARK_Msg_NE + ("global constituent & of & " & + "cannot have mode In_Out or Output", + Item, Item_Id); + end if; + + if Is_Subprogram_Or_Entry (Context) then + SPARK_Msg_NE + (Fix_Msg (Subp_Id, "\item already appears " + & "as input of subprogram &"), Item, Context); + else + SPARK_Msg_NE + (Fix_Msg (Subp_Id, "\item already appears " + & "as input of task &"), Item, Context); + end if; + + -- Stop the traversal once an error has been detected + + exit Check_Context; end if; - -- Stop the traversal once an error has been detected + if Ekind (Item_View) in E_Abstract_State + | E_Constant + | E_Variable + then + Item_View := Encapsulating_State (Item_View); + + exit Check_View when No (Item_View); + else + exit Check_View; + end if; + end loop Check_View; - exit; - end if; end if; Context := Scope (Context); - end loop; + end loop Check_Context; end Check_Mode_Restriction_In_Enclosing_Context; ---------------------------------------- @@ -8498,6 +8529,15 @@ package body Sem_Prag is end if; end if; + -- If the convention of a record type is changed (such as to C), + -- this must override C_Pass_By_Copy if that flag was inherited + -- from a parent type where the latter convention was specified, + -- so we force the flag to False. + + if Cname /= Name_C_Pass_By_Copy and then Is_Record_Type (E) then + Set_C_Pass_By_Copy (Base_Type (E), False); + end if; + -- If the entity is a derived boolean type, check for the special -- case of convention C, C++, or Fortran, where we consider any -- nonzero value to represent true. @@ -12021,6 +12061,18 @@ package body Sem_Prag is Set_Is_Ignored (N, Is_Ignored (Original_Node (N))); Set_Is_Checked (N, Is_Checked (Original_Node (N))); + -- Skip querying the applicable policy at this point for dynamic + -- predicate checks since they rely on the policy applicable in + -- the context of their associated type declaration (and this + -- pragma check has been internally added by the frontend at the + -- point where the runtime check must be performed). + + elsif not Comes_From_Source (N) + and then Chars (Pragma_Identifier (N)) = Name_Check + and then Pname = Name_Dynamic_Predicate + then + null; + -- Otherwise query the applicable policy at this point else @@ -14411,6 +14463,62 @@ package body Sem_Prag is -- restore the Ghost mode. when Pragma_Check => Check : declare + + procedure Handle_Dynamic_Predicate_Check; + -- Enable or ignore the pragma depending on whether dynamic + -- checks are enabled in the context where the associated + -- type declaration is defined. + + ------------------------------------ + -- Handle_Dynamic_Predicate_Check -- + ------------------------------------ + + procedure Handle_Dynamic_Predicate_Check is + Func_Call : constant Node_Id := Expression (Arg2); + Func_Id : constant Entity_Id := Entity (Name (Func_Call)); + Typ : Entity_Id; + + begin + -- Locate the type declaration associated with this runtime + -- check. The 2nd parameter of this pragma is a call to an + -- internally built function that has a single parameter; + -- the type of that formal parameter is the type we are + -- searching for. + + pragma Assert (Is_Predicate_Function (Func_Id)); + Typ := Etype (First_Entity (Func_Id)); + + if not Has_Dynamic_Predicate_Aspect (Typ) + and then Is_Private_Type (Typ) + and then Present (Full_View (Typ)) + then + Typ := Full_View (Typ); + end if; + + pragma Assert (Has_Dynamic_Predicate_Aspect (Typ)); + + if not Predicates_Ignored (Typ) then + Set_Is_Checked (N, True); + Set_Is_Ignored (N, False); + + else + -- In CodePeer mode and GNATprove mode, we need to + -- consider all assertions, unless they are disabled, + -- because transformations of the AST may depend on + -- assertions being checked. + + if CodePeer_Mode or GNATprove_Mode then + Set_Is_Checked (N, True); + Set_Is_Ignored (N, False); + else + Set_Is_Checked (N, False); + Set_Is_Ignored (N, True); + end if; + end if; + end Handle_Dynamic_Predicate_Check; + + -- Local variables + Saved_GM : constant Ghost_Mode_Type := Ghost_Mode; Saved_IGR : constant Node_Id := Ignored_Ghost_Region; -- Save the Ghost-related attributes to restore on exit @@ -14421,6 +14529,8 @@ package body Sem_Prag is Str : Node_Id; pragma Warnings (Off, Str); + -- Start of processing for Pragma_Check + begin -- Pragma Check is Ghost when it applies to a Ghost entity. Set -- the mode now to ensure that any nodes generated during analysis @@ -14475,6 +14585,16 @@ package body Sem_Prag is Set_Is_Ignored (N, Is_Ignored (Original_Node (N))); Set_Is_Checked (N, Is_Checked (Original_Node (N))); + -- Internally added dynamic predicate checks require checking the + -- applicable policy at the point of the type declaration of their + -- corresponding entity. + + elsif not Comes_From_Source (N) + and then Chars (Pragma_Identifier (N)) = Name_Check + and then Pname = Name_Dynamic_Predicate + then + Handle_Dynamic_Predicate_Check; + -- Otherwise query the applicable policy at this point else @@ -22270,8 +22390,22 @@ package body Sem_Prag is Set_Has_Delayed_Aspects (Typ); Set_Has_Delayed_Freeze (Typ); - Set_Predicates_Ignored (Typ, - Policy_In_Effect (Name_Dynamic_Predicate) = Name_Ignore); + -- Mark this aspect as ignored if the policy in effect is Ignore. + + -- It is not done for the internally built pragma created as part + -- of processing aspect dynamic predicate because, in such case, + -- this was done when the aspect was processed (see subprogram + -- Analyze_One_Aspect). + + if From_Aspect_Specification (N) + and then Pname = Name_Dynamic_Predicate + then + null; + else + Set_Predicates_Ignored (Typ, + Policy_In_Effect (Name_Dynamic_Predicate) = Name_Ignore); + end if; + Discard := Rep_Item_Too_Late (Typ, N, FOnly => True); end Predicate; @@ -27650,13 +27784,6 @@ package body Sem_Prag is -- Start of processing for Check_Dependency_Clause begin - -- Do not perform this check in an instance because it was already - -- performed successfully in the generic template. - - if In_Instance then - return; - end if; - -- Examine all refinement clauses and compare them against the -- dependence clause. @@ -27910,16 +28037,10 @@ package body Sem_Prag is -- Start of processing for Check_Output_States begin - -- Do not perform this check in an instance because it was already - -- performed successfully in the generic template. - - if In_Instance then - null; - -- Inspect the outputs of pragma Depends looking for a state with a -- visible refinement. - elsif Present (Spec_Outputs) then + if Present (Spec_Outputs) then Item_Elmt := First_Elmt (Spec_Outputs); while Present (Item_Elmt) loop Item := Node (Item_Elmt); @@ -28261,22 +28382,13 @@ package body Sem_Prag is Clause : Node_Id; begin - -- Do not perform this check in an instance because it was already - -- performed successfully in the generic template. - - if In_Instance then - null; - - elsif Present (Clauses) then - Clause := First (Clauses); - while Present (Clause) loop - SPARK_Msg_N - ("unmatched or extra clause in dependence refinement", - Clause); + Clause := First (Clauses); + while Present (Clause) loop + SPARK_Msg_N + ("unmatched or extra clause in dependence refinement", Clause); - Next (Clause); - end loop; - end if; + Next (Clause); + end loop; end Report_Extra_Clauses; -- Local variables @@ -28369,6 +28481,13 @@ package body Sem_Prag is Analyze_Depends_In_Decl_Part (N); + -- Do not perform these checks in an instance because they were already + -- performed successfully in the generic template. + + if In_Instance then + goto Leave; + end if; + -- Do not match dependencies against refinements if Refined_Depends is -- illegal to avoid emitting misleading error. @@ -28712,16 +28831,10 @@ package body Sem_Prag is -- Start of processing for Check_In_Out_States begin - -- Do not perform this check in an instance because it was already - -- performed successfully in the generic template. - - if In_Instance then - null; - -- Inspect the In_Out items of the corresponding Global pragma -- looking for a state with a visible refinement. - elsif Has_In_Out_State and then Present (In_Out_Items) then + if Has_In_Out_State and then Present (In_Out_Items) then Item_Elmt := First_Elmt (In_Out_Items); while Present (Item_Elmt) loop Item_Id := Node (Item_Elmt); @@ -28821,16 +28934,10 @@ package body Sem_Prag is -- Start of processing for Check_Input_States begin - -- Do not perform this check in an instance because it was already - -- performed successfully in the generic template. - - if In_Instance then - null; - -- Inspect the Input items of the corresponding Global pragma looking -- for a state with a visible refinement. - elsif Has_In_State and then Present (In_Items) then + if Has_In_State and then Present (In_Items) then Item_Elmt := First_Elmt (In_Items); while Present (Item_Elmt) loop Item_Id := Node (Item_Elmt); @@ -28944,16 +29051,10 @@ package body Sem_Prag is -- Start of processing for Check_Output_States begin - -- Do not perform this check in an instance because it was already - -- performed successfully in the generic template. - - if In_Instance then - null; - -- Inspect the Output items of the corresponding Global pragma -- looking for a state with a visible refinement. - elsif Has_Out_State and then Present (Out_Items) then + if Has_Out_State and then Present (Out_Items) then Item_Elmt := First_Elmt (Out_Items); while Present (Item_Elmt) loop Item_Id := Node (Item_Elmt); @@ -29050,16 +29151,10 @@ package body Sem_Prag is -- Start of processing for Check_Proof_In_States begin - -- Do not perform this check in an instance because it was already - -- performed successfully in the generic template. - - if In_Instance then - null; - -- Inspect the Proof_In items of the corresponding Global pragma -- looking for a state with a visible refinement. - elsif Has_Proof_In_State and then Present (Proof_In_Items) then + if Has_Proof_In_State and then Present (Proof_In_Items) then Item_Elmt := First_Elmt (Proof_In_Items); while Present (Item_Elmt) loop Item_Id := Node (Item_Elmt); @@ -29214,13 +29309,7 @@ package body Sem_Prag is -- Start of processing for Check_Refined_Global_List begin - -- Do not perform this check in an instance because it was already - -- performed successfully in the generic template. - - if In_Instance then - null; - - elsif Nkind (List) = N_Null then + if Nkind (List) = N_Null then null; -- Single global item declaration @@ -29465,18 +29554,10 @@ package body Sem_Prag is -- Start of processing for Report_Extra_Constituents begin - -- Do not perform this check in an instance because it was already - -- performed successfully in the generic template. - - if In_Instance then - null; - - else - Report_Extra_Constituents_In_List (In_Constits); - Report_Extra_Constituents_In_List (In_Out_Constits); - Report_Extra_Constituents_In_List (Out_Constits); - Report_Extra_Constituents_In_List (Proof_In_Constits); - end if; + Report_Extra_Constituents_In_List (In_Constits); + Report_Extra_Constituents_In_List (In_Out_Constits); + Report_Extra_Constituents_In_List (Out_Constits); + Report_Extra_Constituents_In_List (Proof_In_Constits); end Report_Extra_Constituents; -------------------------- @@ -29488,21 +29569,13 @@ package body Sem_Prag is Item_Id : Entity_Id; begin - -- Do not perform this check in an instance because it was already - -- performed successfully in the generic template. - - if In_Instance then - null; - - else - if Present (Repeat_Items) then - Item_Elmt := First_Elmt (Repeat_Items); - while Present (Item_Elmt) loop - Item_Id := Node (Item_Elmt); - SPARK_Msg_NE ("missing global item &", N, Item_Id); - Next_Elmt (Item_Elmt); - end loop; - end if; + if Present (Repeat_Items) then + Item_Elmt := First_Elmt (Repeat_Items); + while Present (Item_Elmt) loop + Item_Id := Node (Item_Elmt); + SPARK_Msg_NE ("missing global item &", N, Item_Id); + Next_Elmt (Item_Elmt); + end loop; end if; end Report_Missing_Items; @@ -29603,6 +29676,13 @@ package body Sem_Prag is Analyze_Global_In_Decl_Part (N); + -- Do not perform these checks in an instance because they were already + -- performed successfully in the generic template. + + if In_Instance then + goto Leave; + end if; + -- Perform all refinement checks with respect to completeness and mode -- matching. @@ -29671,7 +29751,6 @@ package body Sem_Prag is -- in the generic template. if Serious_Errors_Detected = Errors - and then not In_Instance and then not Has_Null_State and then No_Constit then diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index d2eca7c545912..a0dd1f7962bdc 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -47,6 +47,7 @@ with Itypes; use Itypes; with Lib; use Lib; with Lib.Xref; use Lib.Xref; with Local_Restrict; +with Mutably_Tagged; use Mutably_Tagged; with Namet; use Namet; with Nmake; use Nmake; with Nlists; use Nlists; @@ -5034,12 +5035,21 @@ package body Sem_Res is -- Skip this check on helpers and indirect-call wrappers built to -- support class-wide preconditions. + -- We make special exception here for mutably tagged types and + -- related calls to their initialization procedures. + if (Is_Class_Wide_Type (A_Typ) or else Is_Dynamically_Tagged (A)) and then not Is_Class_Wide_Type (F_Typ) and then not Is_Controlling_Formal (F) and then not In_Instance and then (not Is_Subprogram (Nam) or else No (Class_Preconditions_Subprogram (Nam))) + + -- Ignore mutably tagged types and their use in calls to init + -- procs. + + and then not Is_Mutably_Tagged_CW_Equivalent_Type (A_Typ) + and then not Is_Init_Proc (Nam) then Error_Msg_N ("class-wide argument not allowed here!", A); @@ -14069,6 +14079,13 @@ package body Sem_Res is end; end if; + -- When we encounter a class-wide equivalent type used to represent + -- a fully sized mutably tagged type, pretend we are actually looking + -- at the class-wide mutably tagged type instead. + + Opnd_Type := + Get_Corresponding_Mutably_Tagged_Type_If_Present (Opnd_Type); + -- Deal with conversion of integer type to address if the pragma -- Allow_Integer_Address is in effect. We convert the conversion to -- an unchecked conversion in this case and we are all done. diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 15994b4d1e9c5..b1d47f2241609 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -30,7 +30,6 @@ with Debug; use Debug; with Einfo.Utils; use Einfo.Utils; with Elists; use Elists; with Errout; use Errout; -with Erroutc; use Erroutc; with Exp_Ch6; use Exp_Ch6; with Exp_Ch11; use Exp_Ch11; with Exp_Util; use Exp_Util; @@ -39,6 +38,7 @@ with Freeze; use Freeze; with Itypes; use Itypes; with Lib; use Lib; with Lib.Xref; use Lib.Xref; +with Mutably_Tagged; use Mutably_Tagged; with Namet.Sp; use Namet.Sp; with Nlists; use Nlists; with Nmake; use Nmake; @@ -171,12 +171,6 @@ package body Sem_Util is -- routine does not take simple flow diagnostics into account, it relies on -- static facts such as the presence of null exclusions. - function Subprogram_Name (N : Node_Id) return String; - -- Return the fully qualified name of the enclosing subprogram for the - -- given node N, with file:line:col information appended, e.g. - -- "subp:file:line:col", corresponding to the source location of the - -- body of the subprogram. - ----------------------------- -- Abstract_Interface_List -- ----------------------------- @@ -2387,7 +2381,7 @@ package body Sem_Util is Actual : Node_Id; begin - if All_Extensions_Allowed then + if Ada_Version >= Ada_2022 then Actual := First_Actual (Call); while Present (Actual) loop if Nkind (Actual) = N_Aggregate then @@ -17173,6 +17167,13 @@ package body Sem_Util is -- Record types elsif Is_Record_Type (Typ) then + -- Mutably tagged types get default initialized to their parent + -- subtype's default values. + + if Is_Mutably_Tagged_CW_Equivalent_Type (Typ) then + return True; + end if; + if Has_Defaulted_Discriminants (Typ) and then Is_Fully_Initialized_Variant (Typ) then @@ -19485,10 +19486,10 @@ package body Sem_Util is elsif Nkind (Par) = N_Case_Expression then return Expr /= Expression (Par); - elsif Nkind (Par) in N_And_Then | N_Or_Else then + elsif Nkind (Par) in N_Short_Circuit then return Expr = Right_Opnd (Par); - elsif Nkind (Par) in N_In | N_Not_In then + elsif Nkind (Par) in N_Membership_Test then -- If the membership includes several alternatives, only the first -- is definitely evaluated. @@ -22691,6 +22692,11 @@ package body Sem_Util is then return True; + -- Mutably tagged types require default initialization + + elsif Is_Mutably_Tagged_CW_Equivalent_Type (Typ) then + return True; + -- If Initialize/Normalize_Scalars is in effect, string objects also -- need initialization, unless they are created in the course of -- expanding an aggregate (since in the latter case they will be @@ -23907,27 +23913,6 @@ package body Sem_Util is elsif EWA_Inner_Scope_Level > 0 then return; - -- Nothing to do when the entity does not denote a construct that - -- may appear within an N_Expression_With_Actions node. Relaxing - -- this restriction leads to a performance penalty. - - -- ??? this list is flaky, and may hide dormant bugs - -- Should functions be included??? - - -- Quantified expressions contain an entity declaration that must - -- always be replaced when the expander is active, even if it has - -- not been analyzed yet like e.g. in predicates. - - elsif Ekind (Id) not in E_Block - | E_Constant - | E_Label - | E_Procedure - | E_Variable - and then not Is_Entity_Of_Quantified_Expression (Id) - and then not Is_Type (Id) - then - return; - -- Nothing to do when the entity was already visited elsif NCT_Tables_In_Use @@ -25790,6 +25775,18 @@ package body Sem_Util is return Kind; end Policy_In_Effect; + ------------------------------------------- + -- Preanalyze_And_Resolve_Without_Errors -- + ------------------------------------------- + + procedure Preanalyze_And_Resolve_Without_Errors (N : Node_Id) is + Status : constant Boolean := Get_Ignore_Errors; + begin + Set_Ignore_Errors (True); + Preanalyze_And_Resolve (N); + Set_Ignore_Errors (Status); + end Preanalyze_And_Resolve_Without_Errors; + ------------------------------- -- Preanalyze_Without_Errors -- ------------------------------- @@ -28083,113 +28080,6 @@ package body Sem_Util is and then Has_Loop_Entry_Attributes (Entity (Identifier (Stmt))); end Subject_To_Loop_Entry_Attributes; - --------------------- - -- Subprogram_Name -- - --------------------- - - function Subprogram_Name (N : Node_Id) return String is - Buf : Bounded_String; - Ent : Node_Id := N; - Nod : Node_Id; - - begin - while Present (Ent) loop - case Nkind (Ent) is - when N_Subprogram_Body => - Ent := Defining_Unit_Name (Specification (Ent)); - exit; - - when N_Subprogram_Declaration => - Nod := Corresponding_Body (Ent); - - if Present (Nod) then - Ent := Nod; - else - Ent := Defining_Unit_Name (Specification (Ent)); - end if; - - exit; - - when N_Subprogram_Instantiation - | N_Package_Body - | N_Package_Specification - => - Ent := Defining_Unit_Name (Ent); - exit; - - when N_Protected_Type_Declaration => - Ent := Corresponding_Body (Ent); - exit; - - when N_Protected_Body - | N_Task_Body - => - Ent := Defining_Identifier (Ent); - exit; - - when N_Entity => - exit; - - when others => - null; - end case; - - Ent := Parent (Ent); - end loop; - - if No (Ent) then - return "unknown subprogram:unknown file:0:0"; - end if; - - -- If the subprogram is a child unit, use its simple name to start the - -- construction of the fully qualified name. - - if Nkind (Ent) = N_Defining_Program_Unit_Name then - Ent := Defining_Identifier (Ent); - end if; - - Append_Entity_Name (Buf, Ent); - - -- Append homonym number if needed - - if Nkind (N) in N_Entity and then Has_Homonym (N) then - declare - H : Entity_Id := Homonym (N); - Nr : Nat := 1; - - begin - while Present (H) loop - if Scope (H) = Scope (N) then - Nr := Nr + 1; - end if; - - H := Homonym (H); - end loop; - - if Nr > 1 then - Append (Buf, '#'); - Append (Buf, Nr); - end if; - end; - end if; - - -- Append source location of Ent to Buf so that the string will - -- look like "subp:file:line:col". - - declare - Loc : constant Source_Ptr := Sloc (Ent); - begin - Append (Buf, ':'); - Append (Buf, Reference_Name (Get_Source_File_Index (Loc))); - Append (Buf, ':'); - Append (Buf, Nat (Get_Logical_Line_Number (Loc))); - Append (Buf, ':'); - Append (Buf, Nat (Get_Column_Number (Loc))); - end; - - return +Buf; - end Subprogram_Name; - ------------------------------- -- Support_Atomic_Primitives -- ------------------------------- @@ -28557,10 +28447,6 @@ package body Sem_Util is Op_Missing : Boolean; begin - if not Restriction_Active (No_Default_Stream_Attributes) then - return Empty; - end if; - if Is_Elementary_Type (T) then if Op = TSS_Null then Op_Missing := @@ -30884,10 +30770,8 @@ package body Sem_Util is return True; when others => - null; + return False; end case; - - return False; end Is_Known_On_Entry; end Conditional_Evaluation; @@ -31410,6 +31294,4 @@ package body Sem_Util is end Storage_Model_Support; -begin - Erroutc.Subprogram_Name_Ptr := Subprogram_Name'Access; end Sem_Util; diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads index 4fef89663805d..bda295f0a7f8d 100644 --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem_util.ads @@ -2219,7 +2219,7 @@ package Sem_Util is -- type be partially initialized. function Is_Potentially_Unevaluated (N : Node_Id) return Boolean; - -- Predicate to implement definition given in RM 6.1.1 (20/3) + -- Predicate to implement definition given in RM 2012 6.1.1 (20/3) function Is_Potentially_Persistent_Type (T : Entity_Id) return Boolean; -- Determines if type T is a potentially persistent type. A potentially @@ -3388,6 +3388,9 @@ package Sem_Util is function Yields_Universal_Type (N : Node_Id) return Boolean; -- Determine whether unanalyzed node N yields a universal type + procedure Preanalyze_And_Resolve_Without_Errors (N : Node_Id); + -- Preanalyze and resolve N without reporting errors + procedure Preanalyze_Without_Errors (N : Node_Id); -- Preanalyze N without reporting errors diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb index 2de3f8668b052..91a57d521d159 100644 --- a/gcc/ada/sem_warn.adb +++ b/gcc/ada/sem_warn.adb @@ -4452,12 +4452,16 @@ package body Sem_Warn is ("?u?literal & is not referenced!", E); when E_Function => - Error_Msg_N -- CODEFIX - ("?u?function & is not referenced!", E); + if not Is_Abstract_Subprogram (E) then + Error_Msg_N -- CODEFIX + ("?u?function & is not referenced!", E); + end if; when E_Procedure => - Error_Msg_N -- CODEFIX - ("?u?procedure & is not referenced!", E); + if not Is_Abstract_Subprogram (E) then + Error_Msg_N -- CODEFIX + ("?u?procedure & is not referenced!", E); + end if; when E_Package => Error_Msg_N -- CODEFIX diff --git a/gcc/ada/snames.ads-tmpl b/gcc/ada/snames.ads-tmpl index 6cc665669072e..d2f724f86cabd 100644 --- a/gcc/ada/snames.ads-tmpl +++ b/gcc/ada/snames.ads-tmpl @@ -165,7 +165,6 @@ package Snames is Name_Relaxed_Initialization : constant Name_Id := N + $; Name_Stable_Properties : constant Name_Id := N + $; Name_Static_Predicate : constant Name_Id := N + $; - Name_Storage_Model : constant Name_Id := N + $; Name_Storage_Model_Type : constant Name_Id := N + $; Name_String_Literal : constant Name_Id := N + $; Name_Synchronization : constant Name_Id := N + $; @@ -904,10 +903,6 @@ package Snames is Name_Warn : constant Name_Id := N + $; Name_Working_Storage : constant Name_Id := N + $; - -- used by Repinfo JSON I/O - - Name_Present : constant Name_Id := N + $; - -- Names of recognized attributes. The entries with the comment "Ada 83" -- are attributes that are defined in Ada 83, but not in Ada 95. These -- attributes are implemented in all Ada modes in GNAT. @@ -1373,6 +1368,7 @@ package Snames is Name_Discriminant : constant Name_Id := N + $; Name_Operands : constant Name_Id := N + $; + Name_Present : constant Name_Id := N + $; -- Other miscellaneous names used in front end -- Note that the UP_ prefix means use the rest of the name in uppercase, diff --git a/gcc/ada/sysdep.c b/gcc/ada/sysdep.c index 443b11f430236..254c736bec433 100644 --- a/gcc/ada/sysdep.c +++ b/gcc/ada/sysdep.c @@ -35,18 +35,35 @@ #ifdef __vxworks #include "vxWorks.h" #include "ioLib.h" -#if ! defined (VTHREADS) +/* VxWorks 5, 6 and 7 SR0540 expose error codes that need to be handled + as ENOENT. On later versions: + - either they are defined as ENOENT (vx7r2); + - or the corresponding system includes are not provided (Helix Cert). */ + +#if __has_include ("dosFsLib.h") +/* On helix-cert, this include is only provided for RTPs. */ #include "dosFsLib.h" #endif -#if ! defined (__RTP__) && (! defined (VTHREADS) || defined (__VXWORKSMILS__)) + +#ifndef S_dosFsLib_FILE_NOT_FOUND +#define S_dosFsLib_FILE_NOT_FOUND ENOENT +#endif + +#if __has_include ("nfsLib.h") +/* This include is not provided for RTPs or on helix-cert. */ # include "nfsLib.h" #endif + +#ifndef S_nfsLib_NFSERR_NOENT +#define S_nfsLib_NFSERR_NOENT ENOENT +#endif + #include "selectLib.h" #include "version.h" #if defined (__RTP__) # include "vwModNum.h" #endif /* __RTP__ */ -#endif +#endif /* __vxworks */ #ifdef __ANDROID__ #undef __linux__ @@ -912,14 +929,10 @@ __gnat_is_file_not_found_error (int errno_val) /* In the case of VxWorks, we also have to take into account various * filesystem-specific variants of this error. */ -#if ! defined (VTHREADS) && (_WRS_VXWORKS_MAJOR < 7) else if (errno_val == S_dosFsLib_FILE_NOT_FOUND) return 1; -#endif -#if ! defined (__RTP__) && (! defined (VTHREADS) || defined (__VXWORKSMILS__)) else if (errno_val == S_nfsLib_NFSERR_NOENT) return 1; -#endif #if defined (__RTP__) /* An RTP can return an NFS file not found, and the NFS bits must first be masked on to check the errno. */ diff --git a/gcc/analyzer/ChangeLog b/gcc/analyzer/ChangeLog index 50f20caeb32ca..c9e10c484e651 100644 --- a/gcc/analyzer/ChangeLog +++ b/gcc/analyzer/ChangeLog @@ -1,3 +1,158 @@ +2024-06-18 David Malcolm + + * checker-event.h (checker_event::fndecl): Drop "final" and + "override", converting from a vfunc implementation to a plain + accessor. + * checker-path.cc (checker_path::same_function_p): New. + * checker-path.h (checker_path::same_function_p): New decl. + +2024-06-18 David Malcolm + + * checker-path.h: Include "simple-diagnostic-path.h". + +2024-06-18 Jonathan Wakely + + * constraint-manager.cc (equiv_class::make_dump_widget): Change + return type to match return value and do not use std::move on + return value. + (bounded_ranges_constraint::make_dump_widget): Likewise. + (constraint_manager::make_dump_widget): Likewise. + * constraint-manager.h (equiv_class::make_dump_widget): Change + return type. + (bounded_ranges_constraint::make_dump_widget): Likewise. + (constraint_manager::make_dump_widget): Likewise. + * program-state.cc (sm_state_map::make_dump_widget): Likewise. + (program_state::make_dump_widget): Likewise. + * program-state.h (sm_state_map::make_dump_widget): Likewise. + (program_state::make_dump_widget): Likewise. + * region-model.cc (region_to_value_map::make_dump_widget): Likewise. + (region_model::make_dump_widget): Likewise. + * region-model.h (region_to_value_map::make_dump_widget): Likewise. + (region_model::make_dump_widget): Likewise. + * region.cc (region::make_dump_widget): Likewise. + * region.h (region::make_dump_widget): Likewise. + * store.cc (binding_cluster::make_dump_widget): Likewise. + (store::make_dump_widget): Likewise. + * store.h (binding_cluster::make_dump_widget): Likewise. + (store::make_dump_widget): Likewise. + * svalue.cc (svalue::make_dump_widget): Likewise. + * svalue.h (svalue::make_dump_widget): Likewise. + +2024-06-12 David Malcolm + + * access-diagram.cc (access_range::dump): Update for fields of + pretty_printer becoming private. + * call-details.cc (call_details::dump): Likewise. + * call-summary.cc (call_summary::dump): Likewise. + (call_summary_replay::dump): Likewise. + * checker-event.cc (checker_event::debug): Likewise. + * constraint-manager.cc (range::dump): Likewise. + (bounded_range::dump): Likewise. + (constraint_manager::dump): Likewise. + * engine.cc (exploded_node::dump): Likewise. + (exploded_path::dump): Likewise. + (exploded_path::dump_to_file): Likewise. + * feasible-graph.cc (feasible_graph::dump_feasible_path): Likewise. + * program-point.cc (program_point::dump): Likewise. + * program-state.cc (extrinsic_state::dump_to_file): Likewise. + (sm_state_map::dump): Likewise. + (program_state::dump_to_file): Likewise. + * ranges.cc (symbolic_byte_offset::dump): Likewise. + (symbolic_byte_range::dump): Likewise. + * record-layout.cc (record_layout::dump): Likewise. + * region-model-reachability.cc (reachable_regions::dump): Likewise. + * region-model.cc (region_to_value_map::dump): Likewise. + (region_model::dump): Likewise. + (model_merger::dump): Likewise. + * region-model.h (one_way_id_map::dump): Likewise. + * region.cc (region_offset::dump): Likewise. + (region::dump): Likewise. + * sm-malloc.cc (deallocator_set::dump): Likewise. + * store.cc (uncertainty_t::dump): Likewise. + (binding_key::dump): Likewise. + (bit_range::dump): Likewise. + (byte_range::dump): Likewise. + (binding_map::dump): Likewise. + (binding_cluster::dump): Likewise. + (store::dump): Likewise. + * supergraph.cc (supergraph::dump_dot_to_file): Likewise. + (superedge::dump): Likewise. + * svalue.cc (svalue::dump): Likewise. + +2024-06-08 Roger Sayle + + * constraint-manager.cc (equiv_class::make_dump_widget): Use + std::move to return a std::unique_ptr. + (bounded_ranges_constraint::make_dump_widget): Likewise. + (constraint_manager::make_dump_widget): Likewise. + * program-state.cc (sm_state_map::make_dump_widget): Likewise. + (program_state::make_dump_widget): Likewise. + * region-model.cc (region_to_value_map::make_dump_widget): Likewise. + (region_model::make_dump_widget): Likewise. + * region.cc (region::make_dump_widget): Likewise. + * store.cc (binding_cluster::make_dump_widget): Likewise. + (store::make_dump_widget): Likewise. + * svalue.cc (svalue::make_dump_widget): Likewise. + +2024-06-07 David Malcolm + + * engine.cc (impl_region_model_context::on_state_leak): Pass nullptr + to get_representative_path_var. + * region-model.cc (region_model::get_representative_path_var_1): + Add logger param and use it in both overloads. + (region_model::get_representative_path_var): Likewise. + (region_model::get_representative_tree): Likewise. + (selftest::test_get_representative_path_var): Pass nullptr to + get_representative_path_var. + * region-model.h (region_model::get_representative_tree): Add + optional logger param to both overloads. + (region_model::get_representative_path_var): Add logger param to + both overloads. + (region_model::get_representative_path_var_1): Likewise. + * store.cc (binding_cluster::get_representative_path_vars): Add + logger param and use it. + (store::get_representative_path_vars): Likewise. + * store.h (binding_cluster::get_representative_path_vars): Add + logger param. + (store::get_representative_path_vars): Likewise. + +2024-06-07 David Malcolm + + * call-summary.cc + (call_summary_replay::convert_region_from_summary_1): Update + for removal of cast_region::m_original_region. + * region-model-manager.cc + (region_model_manager::get_or_create_initial_value): Likewise. + * region-model.cc (region_model::get_store_value): Likewise. + * region.cc (region::get_base_region): Likewise. + (region::descendent_of_p): Likewise. + (region::maybe_get_frame_region): Likewise. + (region::get_memory_space): Likewise. + (region::calc_offset): Likewise. + (cast_region::accept): Delete. + (cast_region::dump_to_pp): Update for removal of + cast_region::m_original_region. + (cast_region::add_dump_widget_children): Delete. + * region.h (struct cast_region::key_t): Rename "original_region" + to "parent". + (cast_region::cast_region): Likewise. Update for removal of + cast_region::m_original_region. + (cast_region::accept): Delete. + (cast_region::add_dump_widget_children): Delete. + (cast_region::get_original_region): Delete. + (cast_region::m_original_region): Delete. + * sm-taint.cc (region_model::check_region_for_taint): Remove + special-casing for RK_CAST. + +2024-06-07 David Malcolm + + PR analyzer/105892 + * analyzer.opt (Wanalyzer-undefined-behavior-ptrdiff): New option. + * analyzer.opt.urls: Regenerate. + * region-model.cc (class undefined_ptrdiff_diagnostic): New. + (check_for_invalid_ptrdiff): New. + (region_model::get_gassign_result): Call it for POINTER_DIFF_EXPR. + 2024-06-01 David Malcolm PR analyzer/106203 diff --git a/gcc/analyzer/access-diagram.cc b/gcc/analyzer/access-diagram.cc index 8d7461fe381d6..cb5b656c164a4 100644 --- a/gcc/analyzer/access-diagram.cc +++ b/gcc/analyzer/access-diagram.cc @@ -547,7 +547,7 @@ access_range::dump (bool simple) const pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = stderr; + pp.set_output_stream (stderr); dump_to_pp (&pp, simple); pp_newline (&pp); pp_flush (&pp); diff --git a/gcc/analyzer/analyzer.opt b/gcc/analyzer/analyzer.opt index bbf2ba670d8ae..5335f7e1999e1 100644 --- a/gcc/analyzer/analyzer.opt +++ b/gcc/analyzer/analyzer.opt @@ -222,6 +222,10 @@ Wanalyzer-tainted-size Common Var(warn_analyzer_tainted_size) Init(1) Warning Warn about code paths in which an unsanitized value is used as a size. +Wanalyzer-undefined-behavior-ptrdiff +Common Var(warn_analyzer_undefined_behavior_ptrdiff) Init(1) Warning +Warn about code paths in which pointer subtraction involves undefined behavior. + Wanalyzer-undefined-behavior-strtok Common Var(warn_analyzer_undefined_behavior_strtok) Init(1) Warning Warn about code paths in which a call is made to strtok with undefined behavior. diff --git a/gcc/analyzer/analyzer.opt.urls b/gcc/analyzer/analyzer.opt.urls index 5fcab7205823c..18a0d6926de7f 100644 --- a/gcc/analyzer/analyzer.opt.urls +++ b/gcc/analyzer/analyzer.opt.urls @@ -114,6 +114,9 @@ UrlSuffix(gcc/Static-Analyzer-Options.html#index-Wanalyzer-tainted-offset) Wanalyzer-tainted-size UrlSuffix(gcc/Static-Analyzer-Options.html#index-Wanalyzer-tainted-size) +Wanalyzer-undefined-behavior-ptrdiff +UrlSuffix(gcc/Static-Analyzer-Options.html#index-Wanalyzer-undefined-behavior-ptrdiff) + Wanalyzer-undefined-behavior-strtok UrlSuffix(gcc/Static-Analyzer-Options.html#index-Wanalyzer-undefined-behavior-strtok) diff --git a/gcc/analyzer/call-details.cc b/gcc/analyzer/call-details.cc index fda925edb9683..116ab40afaf5a 100644 --- a/gcc/analyzer/call-details.cc +++ b/gcc/analyzer/call-details.cc @@ -366,7 +366,7 @@ call_details::dump (bool simple) const pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = stderr; + pp.set_output_stream (stderr); dump_to_pp (&pp, simple); pp_flush (&pp); } diff --git a/gcc/analyzer/call-summary.cc b/gcc/analyzer/call-summary.cc index 60ca78a334da6..ec36fdfd9f1a6 100644 --- a/gcc/analyzer/call-summary.cc +++ b/gcc/analyzer/call-summary.cc @@ -149,7 +149,7 @@ call_summary::dump (const extrinsic_state &ext_state, pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = fp; + pp.set_output_stream (fp); dump_to_pp (ext_state, &pp, simple); pp_flush (&pp); } @@ -726,13 +726,12 @@ call_summary_replay::convert_region_from_summary_1 (const region *summary_reg) { const cast_region *summary_cast_reg = as_a (summary_reg); - const region *summary_original_reg - = summary_cast_reg->get_original_region (); - const region *caller_original_reg - = convert_region_from_summary (summary_original_reg); - if (!caller_original_reg) + const region *summary_parent_reg = summary_reg->get_parent_region (); + const region *caller_parent_reg + = convert_region_from_summary (summary_parent_reg); + if (!caller_parent_reg) return NULL; - return mgr->get_cast_region (caller_original_reg, + return mgr->get_cast_region (caller_parent_reg, summary_reg->get_type ()); } break; @@ -891,7 +890,7 @@ call_summary_replay::dump (FILE *fp, bool simple) const pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = fp; + pp.set_output_stream (fp); dump_to_pp (&pp, simple); pp_flush (&pp); } diff --git a/gcc/analyzer/checker-event.cc b/gcc/analyzer/checker-event.cc index ee3ceb407ea16..593f364e1d665 100644 --- a/gcc/analyzer/checker-event.cc +++ b/gcc/analyzer/checker-event.cc @@ -199,7 +199,7 @@ checker_event::debug () const pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = stderr; + pp.set_output_stream (stderr); dump (&pp); pp_newline (&pp); pp_flush (&pp); diff --git a/gcc/analyzer/checker-event.h b/gcc/analyzer/checker-event.h index d0935aca9853e..4343641f441ce 100644 --- a/gcc/analyzer/checker-event.h +++ b/gcc/analyzer/checker-event.h @@ -91,7 +91,6 @@ class checker_event : public diagnostic_event /* Implementation of diagnostic_event. */ location_t get_location () const final override { return m_loc; } - tree get_fndecl () const final override { return m_effective_fndecl; } int get_stack_depth () const final override { return m_effective_depth; } const logical_location *get_logical_location () const final override { @@ -111,6 +110,7 @@ class checker_event : public diagnostic_event maybe_add_sarif_properties (sarif_object &thread_flow_loc_obj) const override; /* Additional functionality. */ + tree get_fndecl () const { return m_effective_fndecl; } int get_original_stack_depth () const { return m_original_depth; } diff --git a/gcc/analyzer/checker-path.cc b/gcc/analyzer/checker-path.cc index c8361915ad9c1..cfbbc0b25f358 100644 --- a/gcc/analyzer/checker-path.cc +++ b/gcc/analyzer/checker-path.cc @@ -63,6 +63,14 @@ along with GCC; see the file COPYING3. If not see namespace ana { +bool +checker_path::same_function_p (int event_idx_a, + int event_idx_b) const +{ + return (m_events[event_idx_a]->get_fndecl () + == m_events[event_idx_b]->get_fndecl ()); +} + /* Print a single-line representation of this path to PP. */ void diff --git a/gcc/analyzer/checker-path.h b/gcc/analyzer/checker-path.h index 6b3e8a34fe561..1aa56d27927e0 100644 --- a/gcc/analyzer/checker-path.h +++ b/gcc/analyzer/checker-path.h @@ -22,6 +22,7 @@ along with GCC; see the file COPYING3. If not see #define GCC_ANALYZER_CHECKER_PATH_H #include "analyzer/checker-event.h" +#include "simple-diagnostic-path.h" namespace ana { @@ -62,6 +63,10 @@ class checker_path : public diagnostic_path return m_events[idx]; } + bool + same_function_p (int event_idx_a, + int event_idx_b) const final override; + void dump (pretty_printer *pp) const; void debug () const; diff --git a/gcc/analyzer/constraint-manager.cc b/gcc/analyzer/constraint-manager.cc index 707385d3fa672..29539060ebdd5 100644 --- a/gcc/analyzer/constraint-manager.cc +++ b/gcc/analyzer/constraint-manager.cc @@ -185,7 +185,7 @@ range::dump () const pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = stderr; + pp.set_output_stream (stderr); dump_to_pp (&pp); pp_newline (&pp); pp_flush (&pp); @@ -448,7 +448,7 @@ bounded_range::dump (bool show_types) const pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = stderr; + pp.set_output_stream (stderr); dump_to_pp (&pp, show_types); pp_newline (&pp); pp_flush (&pp); @@ -721,7 +721,7 @@ bounded_ranges::dump (bool show_types) const pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = stderr; + pp.set_output_stream (stderr); dump_to_pp (&pp, show_types); pp_newline (&pp); pp_flush (&pp); @@ -1146,7 +1146,7 @@ equiv_class::to_json () const return ec_obj; } -std::unique_ptr +std::unique_ptr equiv_class::make_dump_widget (const text_art::dump_widget_info &dwi, unsigned id) const { @@ -1491,7 +1491,7 @@ bounded_ranges_constraint::to_json () const return con_obj; } -std::unique_ptr +std::unique_ptr bounded_ranges_constraint:: make_dump_widget (const text_art::dump_widget_info &dwi) const { @@ -1772,7 +1772,7 @@ constraint_manager::dump (FILE *fp) const pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = fp; + pp.set_output_stream (fp); dump_to_pp (&pp, true); pp_flush (&pp); } @@ -1829,7 +1829,7 @@ constraint_manager::to_json () const return cm_obj; } -std::unique_ptr +std::unique_ptr constraint_manager::make_dump_widget (const text_art::dump_widget_info &dwi) const { using text_art::tree_widget; diff --git a/gcc/analyzer/constraint-manager.h b/gcc/analyzer/constraint-manager.h index 31556aebc7a1c..81e9c7ec035c7 100644 --- a/gcc/analyzer/constraint-manager.h +++ b/gcc/analyzer/constraint-manager.h @@ -273,7 +273,7 @@ class equiv_class json::object *to_json () const; - std::unique_ptr + std::unique_ptr make_dump_widget (const text_art::dump_widget_info &dwi, unsigned id) const; @@ -408,7 +408,7 @@ class bounded_ranges_constraint void add_to_hash (inchash::hash *hstate) const; - std::unique_ptr + std::unique_ptr make_dump_widget (const text_art::dump_widget_info &dwi) const; equiv_class_id m_ec_id; @@ -444,7 +444,7 @@ class constraint_manager json::object *to_json () const; - std::unique_ptr + std::unique_ptr make_dump_widget (const text_art::dump_widget_info &dwi) const; const equiv_class &get_equiv_class_by_index (unsigned idx) const diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc index 8b3706cdfa87a..f5fad5b2e4704 100644 --- a/gcc/analyzer/engine.cc +++ b/gcc/analyzer/engine.cc @@ -903,7 +903,8 @@ impl_region_model_context::on_state_leak (const state_machine &sm, svalue_set visited; path_var leaked_pv = m_old_state->m_region_model->get_representative_path_var (sval, - &visited); + &visited, + nullptr); /* Strip off top-level casts */ if (leaked_pv.m_tree && TREE_CODE (leaked_pv.m_tree) == NOP_EXPR) @@ -1421,7 +1422,7 @@ exploded_node::dump (FILE *fp, pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = fp; + pp.set_output_stream (fp); dump_to_pp (&pp, ext_state); pp_flush (&pp); } @@ -4831,7 +4832,7 @@ exploded_path::dump (FILE *fp, const extrinsic_state *ext_state) const pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = fp; + pp.set_output_stream (fp); dump_to_pp (&pp, ext_state); pp_flush (&pp); } @@ -4855,7 +4856,7 @@ exploded_path::dump_to_file (const char *filename, return; pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; - pp.buffer->stream = fp; + pp.set_output_stream (fp); dump_to_pp (&pp, &ext_state); pp_flush (&pp); fclose (fp); diff --git a/gcc/analyzer/feasible-graph.cc b/gcc/analyzer/feasible-graph.cc index a1812231572c6..35b489fde3571 100644 --- a/gcc/analyzer/feasible-graph.cc +++ b/gcc/analyzer/feasible-graph.cc @@ -301,7 +301,7 @@ feasible_graph::dump_feasible_path (const feasible_node &dst_fnode, FILE *fp = fopen (filename, "w"); pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; - pp.buffer->stream = fp; + pp.set_output_stream (fp); dump_feasible_path (dst_fnode, &pp); pp_flush (&pp); fclose (fp); diff --git a/gcc/analyzer/program-point.cc b/gcc/analyzer/program-point.cc index 14ce5be4bcf98..ea15ccc91d272 100644 --- a/gcc/analyzer/program-point.cc +++ b/gcc/analyzer/program-point.cc @@ -302,7 +302,7 @@ program_point::dump () const { pretty_printer pp; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = stderr; + pp.set_output_stream (stderr); print (&pp, format (true)); pp_flush (&pp); } diff --git a/gcc/analyzer/program-state.cc b/gcc/analyzer/program-state.cc index dc2d4bdf7b0b9..c42fc752350ad 100644 --- a/gcc/analyzer/program-state.cc +++ b/gcc/analyzer/program-state.cc @@ -86,7 +86,7 @@ extrinsic_state::dump_to_file (FILE *outf) const pretty_printer pp; if (outf == stderr) pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = outf; + pp.set_output_stream (outf); dump_to_pp (&pp); pp_flush (&pp); } @@ -274,7 +274,7 @@ sm_state_map::dump (bool simple) const pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = stderr; + pp.set_output_stream (stderr); print (NULL, simple, true, &pp); pp_newline (&pp); pp_flush (&pp); @@ -309,7 +309,7 @@ sm_state_map::to_json () const /* Make a text_art::tree_widget describing this sm_state_map, using MODEL if non-null to describe svalues. */ -std::unique_ptr +std::unique_ptr sm_state_map::make_dump_widget (const text_art::dump_widget_info &dwi, const region_model *model) const { @@ -1169,7 +1169,7 @@ program_state::dump_to_file (const extrinsic_state &ext_state, pp_format_decoder (&pp) = default_tree_printer; if (outf == stderr) pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = outf; + pp.set_output_stream (outf); dump_to_pp (ext_state, summarize, multiline, &pp); pp_flush (&pp); } @@ -1229,7 +1229,7 @@ program_state::to_json (const extrinsic_state &ext_state) const } -std::unique_ptr +std::unique_ptr program_state::make_dump_widget (const text_art::dump_widget_info &dwi) const { using text_art::tree_widget; diff --git a/gcc/analyzer/program-state.h b/gcc/analyzer/program-state.h index 7e751386b21ed..322ca8d0f11a6 100644 --- a/gcc/analyzer/program-state.h +++ b/gcc/analyzer/program-state.h @@ -119,7 +119,7 @@ class sm_state_map json::object *to_json () const; - std::unique_ptr + std::unique_ptr make_dump_widget (const text_art::dump_widget_info &dwi, const region_model *model) const; @@ -233,7 +233,7 @@ class program_state json::object *to_json (const extrinsic_state &ext_state) const; - std::unique_ptr + std::unique_ptr make_dump_widget (const text_art::dump_widget_info &dwi) const; void push_frame (const extrinsic_state &ext_state, const function &fun); diff --git a/gcc/analyzer/ranges.cc b/gcc/analyzer/ranges.cc index f591efae43afb..17d6e6b2212dc 100644 --- a/gcc/analyzer/ranges.cc +++ b/gcc/analyzer/ranges.cc @@ -98,7 +98,7 @@ symbolic_byte_offset::dump (bool simple) const pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = stderr; + pp.set_output_stream (stderr); dump_to_pp (&pp, simple); pp_newline (&pp); pp_flush (&pp); @@ -157,7 +157,7 @@ symbolic_byte_range::dump (bool simple, region_model_manager &mgr) const pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = stderr; + pp.set_output_stream (stderr); dump_to_pp (&pp, simple, mgr); pp_newline (&pp); pp_flush (&pp); diff --git a/gcc/analyzer/record-layout.cc b/gcc/analyzer/record-layout.cc index af31155184897..59690a43b76e9 100644 --- a/gcc/analyzer/record-layout.cc +++ b/gcc/analyzer/record-layout.cc @@ -85,7 +85,7 @@ record_layout::dump () const { pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; - pp.buffer->stream = stderr; + pp.set_output_stream (stderr); dump_to_pp (&pp); pp_flush (&pp); } diff --git a/gcc/analyzer/region-model-manager.cc b/gcc/analyzer/region-model-manager.cc index b094b2f7e4345..8154d914e81cf 100644 --- a/gcc/analyzer/region-model-manager.cc +++ b/gcc/analyzer/region-model-manager.cc @@ -327,7 +327,7 @@ region_model_manager::get_or_create_initial_value (const region *reg, /* The initial value of a cast is a cast of the initial value. */ if (const cast_region *cast_reg = reg->dyn_cast_cast_region ()) { - const region *original_reg = cast_reg->get_original_region (); + const region *original_reg = cast_reg->get_parent_region (); return get_or_create_cast (cast_reg->get_type (), get_or_create_initial_value (original_reg)); } diff --git a/gcc/analyzer/region-model-reachability.cc b/gcc/analyzer/region-model-reachability.cc index b9887902980fa..828e3fcbadac2 100644 --- a/gcc/analyzer/region-model-reachability.cc +++ b/gcc/analyzer/region-model-reachability.cc @@ -350,7 +350,7 @@ reachable_regions::dump () const pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = stderr; + pp.set_output_stream (stderr); dump_to_pp (&pp); pp_flush (&pp); } diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc index d142d851a26fb..4d6e16cf0f4d3 100644 --- a/gcc/analyzer/region-model.cc +++ b/gcc/analyzer/region-model.cc @@ -226,7 +226,7 @@ region_to_value_map::dump (bool simple) const pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = stderr; + pp.set_output_stream (stderr); dump_to_pp (&pp, simple, true); pp_newline (&pp); pp_flush (&pp); @@ -258,7 +258,7 @@ region_to_value_map::to_json () const return map_obj; } -std::unique_ptr +std::unique_ptr region_to_value_map:: make_dump_widget (const text_art::dump_widget_info &dwi) const { @@ -486,7 +486,7 @@ region_model::dump (FILE *fp, bool simple, bool multiline) const pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = fp; + pp.set_output_stream (fp); dump_to_pp (&pp, simple, multiline); pp_newline (&pp); pp_flush (&pp); @@ -532,7 +532,7 @@ region_model::to_json () const return model_obj; } -std::unique_ptr +std::unique_ptr region_model::make_dump_widget (const text_art::dump_widget_info &dwi) const { using text_art::tree_widget; @@ -841,6 +841,144 @@ class shift_count_overflow_diagnostic tree m_count_cst; }; +/* A subclass of pending_diagnostic for complaining about pointer + subtractions involving unrelated buffers. */ + +class undefined_ptrdiff_diagnostic +: public pending_diagnostic_subclass +{ +public: + /* Region_creation_event subclass to give a custom wording when + talking about creation of buffers for LHS and RHS of the + subtraction. */ + class ptrdiff_region_creation_event : public region_creation_event + { + public: + ptrdiff_region_creation_event (const event_loc_info &loc_info, + bool is_lhs) + : region_creation_event (loc_info), + m_is_lhs (is_lhs) + { + } + + label_text get_desc (bool) const + { + if (m_is_lhs) + return label_text::borrow ("underlying object for left-hand side" + " of subtraction created here"); + else + return label_text::borrow ("underlying object for right-hand side" + " of subtraction created here"); + } + + private: + bool m_is_lhs; + }; + + undefined_ptrdiff_diagnostic (const gassign *assign, + const svalue *sval_a, + const svalue *sval_b, + const region *base_reg_a, + const region *base_reg_b) + : m_assign (assign), + m_sval_a (sval_a), + m_sval_b (sval_b), + m_base_reg_a (base_reg_a), + m_base_reg_b (base_reg_b) + { + gcc_assert (m_base_reg_a != m_base_reg_b); + } + + const char *get_kind () const final override + { + return "undefined_ptrdiff_diagnostic"; + } + + bool operator== (const undefined_ptrdiff_diagnostic &other) const + { + return (m_assign == other.m_assign + && m_sval_a == other.m_sval_a + && m_sval_b == other.m_sval_b + && m_base_reg_a == other.m_base_reg_a + && m_base_reg_b == other.m_base_reg_b); + } + + int get_controlling_option () const final override + { + return OPT_Wanalyzer_undefined_behavior_ptrdiff; + } + + bool emit (diagnostic_emission_context &ctxt) final override + { + /* CWE-469: Use of Pointer Subtraction to Determine Size. */ + ctxt.add_cwe (469); + return ctxt.warn ("undefined behavior when subtracting pointers"); + } + + void add_region_creation_events (const region *reg, + tree /*capacity*/, + const event_loc_info &loc_info, + checker_path &emission_path) final override + { + if (reg == m_base_reg_a) + emission_path.add_event + (make_unique (loc_info, true)); + else if (reg == m_base_reg_b) + emission_path.add_event + (make_unique (loc_info, false)); + } + + label_text describe_final_event (const evdesc::final_event &ev) final override + { + return ev.formatted_print + ("subtraction of pointers has undefined behavior if" + " they do not point into the same array object"); + } + + void mark_interesting_stuff (interesting_t *interesting) final override + { + interesting->add_region_creation (m_base_reg_a); + interesting->add_region_creation (m_base_reg_b); + } + +private: + const gassign *m_assign; + const svalue *m_sval_a; + const svalue *m_sval_b; + const region *m_base_reg_a; + const region *m_base_reg_b; +}; + +/* Check the pointer subtraction SVAL_A - SVAL_B at ASSIGN and add + a warning to CTXT if they're not within the same base region. */ + +static void +check_for_invalid_ptrdiff (const gassign *assign, + region_model_context &ctxt, + const svalue *sval_a, const svalue *sval_b) +{ + const region *base_reg_a = sval_a->maybe_get_deref_base_region (); + if (!base_reg_a) + return; + const region *base_reg_b = sval_b->maybe_get_deref_base_region (); + if (!base_reg_b) + return; + + if (base_reg_a == base_reg_b) + return; + + if (base_reg_a->get_kind () == RK_SYMBOLIC) + return; + if (base_reg_b->get_kind () == RK_SYMBOLIC) + return; + + ctxt.warn (make_unique (assign, + sval_a, + sval_b, + base_reg_a, + base_reg_b)); +} + /* If ASSIGN is a stmt that can be modelled via set_value (lhs_reg, SVALUE, CTXT) for some SVALUE, get the SVALUE. @@ -897,6 +1035,9 @@ region_model::get_gassign_result (const gassign *assign, // TODO: perhaps fold to zero if they're known to be equal? + if (ctxt) + check_for_invalid_ptrdiff (assign, *ctxt, rhs1_sval, rhs2_sval); + const svalue *sval_binop = m_mgr->get_or_create_binop (TREE_TYPE (lhs), op, rhs1_sval, rhs2_sval); @@ -2792,7 +2933,7 @@ region_model::get_store_value (const region *reg, /* Special-case: read the initial char of a STRING_CST. */ if (const cast_region *cast_reg = reg->dyn_cast_cast_region ()) if (const string_region *str_reg - = cast_reg->get_original_region ()->dyn_cast_string_region ()) + = cast_reg->get_parent_region ()->dyn_cast_string_region ()) { tree string_cst = str_reg->get_string_cst (); tree byte_offset_cst = integer_zero_node; @@ -5202,7 +5343,8 @@ region_model::eval_condition (tree lhs, path_var region_model::get_representative_path_var_1 (const svalue *sval, - svalue_set *visited) const + svalue_set *visited, + logger *logger) const { gcc_assert (sval); @@ -5219,7 +5361,8 @@ region_model::get_representative_path_var_1 (const svalue *sval, /* Handle casts by recursion into get_representative_path_var. */ if (const svalue *cast_sval = sval->maybe_undo_cast ()) { - path_var result = get_representative_path_var (cast_sval, visited); + path_var result = get_representative_path_var (cast_sval, visited, + logger); tree orig_type = sval->get_type (); /* If necessary, wrap the result in a cast. */ if (result.m_tree && orig_type) @@ -5228,7 +5371,7 @@ region_model::get_representative_path_var_1 (const svalue *sval, } auto_vec pvs; - m_store.get_representative_path_vars (this, visited, sval, &pvs); + m_store.get_representative_path_vars (this, visited, sval, logger, &pvs); if (tree cst = sval->maybe_get_constant ()) pvs.safe_push (path_var (cst, 0)); @@ -5237,7 +5380,7 @@ region_model::get_representative_path_var_1 (const svalue *sval, if (const region_svalue *ptr_sval = sval->dyn_cast_region_svalue ()) { const region *reg = ptr_sval->get_pointee (); - if (path_var pv = get_representative_path_var (reg, visited)) + if (path_var pv = get_representative_path_var (reg, visited, logger)) return path_var (build1 (ADDR_EXPR, sval->get_type (), pv.m_tree), @@ -5250,7 +5393,7 @@ region_model::get_representative_path_var_1 (const svalue *sval, const svalue *parent_sval = sub_sval->get_parent (); const region *subreg = sub_sval->get_subregion (); if (path_var parent_pv - = get_representative_path_var (parent_sval, visited)) + = get_representative_path_var (parent_sval, visited, logger)) if (const field_region *field_reg = subreg->dyn_cast_field_region ()) return path_var (build3 (COMPONENT_REF, sval->get_type (), @@ -5263,9 +5406,11 @@ region_model::get_representative_path_var_1 (const svalue *sval, /* Handle binops. */ if (const binop_svalue *binop_sval = sval->dyn_cast_binop_svalue ()) if (path_var lhs_pv - = get_representative_path_var (binop_sval->get_arg0 (), visited)) + = get_representative_path_var (binop_sval->get_arg0 (), visited, + logger)) if (path_var rhs_pv - = get_representative_path_var (binop_sval->get_arg1 (), visited)) + = get_representative_path_var (binop_sval->get_arg1 (), visited, + logger)) return path_var (build2 (binop_sval->get_op (), sval->get_type (), lhs_pv.m_tree, rhs_pv.m_tree), @@ -5288,19 +5433,42 @@ region_model::get_representative_path_var_1 (const svalue *sval, path_var region_model::get_representative_path_var (const svalue *sval, - svalue_set *visited) const + svalue_set *visited, + logger *logger) const { if (sval == NULL) return path_var (NULL_TREE, 0); + LOG_SCOPE (logger); + if (logger) + { + logger->start_log_line (); + logger->log_partial ("sval: "); + sval->dump_to_pp (logger->get_printer (), true); + logger->end_log_line (); + } + tree orig_type = sval->get_type (); - path_var result = get_representative_path_var_1 (sval, visited); + path_var result = get_representative_path_var_1 (sval, visited, logger); /* Verify that the result has the same type as SVAL, if any. */ if (result.m_tree && orig_type) gcc_assert (TREE_TYPE (result.m_tree) == orig_type); + if (logger) + { + logger->start_log_line (); + logger->log_partial ("sval: "); + sval->dump_to_pp (logger->get_printer (), true); + logger->end_log_line (); + + if (result.m_tree) + logger->log ("tree: %qE", result.m_tree); + else + logger->log ("tree: NULL"); + } + return result; } @@ -5311,10 +5479,10 @@ region_model::get_representative_path_var (const svalue *sval, from analyzer diagnostics. */ tree -region_model::get_representative_tree (const svalue *sval) const +region_model::get_representative_tree (const svalue *sval, logger *logger) const { svalue_set visited; - tree expr = get_representative_path_var (sval, &visited).m_tree; + tree expr = get_representative_path_var (sval, &visited, logger).m_tree; /* Strip off any top-level cast. */ if (expr && TREE_CODE (expr) == NOP_EXPR) @@ -5324,10 +5492,10 @@ region_model::get_representative_tree (const svalue *sval) const } tree -region_model::get_representative_tree (const region *reg) const +region_model::get_representative_tree (const region *reg, logger *logger) const { svalue_set visited; - tree expr = get_representative_path_var (reg, &visited).m_tree; + tree expr = get_representative_path_var (reg, &visited, logger).m_tree; /* Strip off any top-level cast. */ if (expr && TREE_CODE (expr) == NOP_EXPR) @@ -5347,7 +5515,8 @@ region_model::get_representative_tree (const region *reg) const path_var region_model::get_representative_path_var_1 (const region *reg, - svalue_set *visited) const + svalue_set *visited, + logger *logger) const { switch (reg->get_kind ()) { @@ -5381,7 +5550,8 @@ region_model::get_representative_path_var_1 (const region *reg, const symbolic_region *symbolic_reg = as_a (reg); const svalue *pointer = symbolic_reg->get_pointer (); - path_var pointer_pv = get_representative_path_var (pointer, visited); + path_var pointer_pv = get_representative_path_var (pointer, visited, + logger); if (!pointer_pv) return path_var (NULL_TREE, 0); tree offset = build_int_cst (pointer->get_type (), 0); @@ -5400,7 +5570,8 @@ region_model::get_representative_path_var_1 (const region *reg, { const field_region *field_reg = as_a (reg); path_var parent_pv - = get_representative_path_var (reg->get_parent_region (), visited); + = get_representative_path_var (reg->get_parent_region (), visited, + logger); if (!parent_pv) return path_var (NULL_TREE, 0); return path_var (build3 (COMPONENT_REF, @@ -5416,11 +5587,13 @@ region_model::get_representative_path_var_1 (const region *reg, const element_region *element_reg = as_a (reg); path_var parent_pv - = get_representative_path_var (reg->get_parent_region (), visited); + = get_representative_path_var (reg->get_parent_region (), visited, + logger); if (!parent_pv) return path_var (NULL_TREE, 0); path_var index_pv - = get_representative_path_var (element_reg->get_index (), visited); + = get_representative_path_var (element_reg->get_index (), visited, + logger); if (!index_pv) return path_var (NULL_TREE, 0); return path_var (build4 (ARRAY_REF, @@ -5435,12 +5608,13 @@ region_model::get_representative_path_var_1 (const region *reg, const offset_region *offset_reg = as_a (reg); path_var parent_pv - = get_representative_path_var (reg->get_parent_region (), visited); + = get_representative_path_var (reg->get_parent_region (), visited, + logger); if (!parent_pv) return path_var (NULL_TREE, 0); path_var offset_pv = get_representative_path_var (offset_reg->get_byte_offset (), - visited); + visited, logger); if (!offset_pv || TREE_CODE (offset_pv.m_tree) != INTEGER_CST) return path_var (NULL_TREE, 0); tree addr_parent = build1 (ADDR_EXPR, @@ -5459,7 +5633,8 @@ region_model::get_representative_path_var_1 (const region *reg, case RK_CAST: { path_var parent_pv - = get_representative_path_var (reg->get_parent_region (), visited); + = get_representative_path_var (reg->get_parent_region (), visited, + logger); if (!parent_pv) return path_var (NULL_TREE, 0); return path_var (build1 (NOP_EXPR, @@ -5500,14 +5675,37 @@ region_model::get_representative_path_var_1 (const region *reg, path_var region_model::get_representative_path_var (const region *reg, - svalue_set *visited) const + svalue_set *visited, + logger *logger) const { - path_var result = get_representative_path_var_1 (reg, visited); + LOG_SCOPE (logger); + if (logger) + { + logger->start_log_line (); + logger->log_partial ("reg: "); + reg->dump_to_pp (logger->get_printer (), true); + logger->end_log_line (); + } + + path_var result = get_representative_path_var_1 (reg, visited, logger); /* Verify that the result has the same type as REG, if any. */ if (result.m_tree && reg->get_type ()) gcc_assert (TREE_TYPE (result.m_tree) == reg->get_type ()); + if (logger) + { + logger->start_log_line (); + logger->log_partial ("reg: "); + reg->dump_to_pp (logger->get_printer (), true); + logger->end_log_line (); + + if (result.m_tree) + logger->log ("tree: %qE", result.m_tree); + else + logger->log ("tree: NULL"); + } + return result; } @@ -7202,7 +7400,7 @@ model_merger::dump (FILE *fp, bool simple) const pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = fp; + pp.set_output_stream (fp); dump_to_pp (&pp, simple); pp_flush (&pp); } @@ -8281,7 +8479,8 @@ test_get_representative_path_var () { svalue_set visited; ASSERT_EQ (model.get_representative_path_var (parm_regs[depth], - &visited), + &visited, + nullptr), path_var (n, depth + 1)); } /* ...and that we can lookup lvalues for locals for all frames, @@ -8292,7 +8491,8 @@ test_get_representative_path_var () { svalue_set visited; ASSERT_EQ (model.get_representative_path_var (parm_svals[depth], - &visited), + &visited, + nullptr), path_var (n, depth + 1)); } } diff --git a/gcc/analyzer/region-model.h b/gcc/analyzer/region-model.h index 1a0233f2e8ab5..4683c1a431490 100644 --- a/gcc/analyzer/region-model.h +++ b/gcc/analyzer/region-model.h @@ -123,7 +123,7 @@ DEBUG_FUNCTION inline void one_way_id_map::dump () const { pretty_printer pp; - pp.buffer->stream = stderr; + pp.set_output_stream (stderr); dump_to_pp (&pp); pp_flush (&pp); } @@ -179,7 +179,7 @@ class region_to_value_map json::object *to_json () const; - std::unique_ptr + std::unique_ptr make_dump_widget (const text_art::dump_widget_info &dwi) const; bool can_merge_with_p (const region_to_value_map &other, @@ -288,7 +288,7 @@ class region_model json::object *to_json () const; - std::unique_ptr + std::unique_ptr make_dump_widget (const text_art::dump_widget_info &dwi) const; void validate () const; @@ -435,14 +435,18 @@ class region_model region_model_context *ctxt); void get_referenced_base_regions (auto_bitmap &out_ids) const; - tree get_representative_tree (const svalue *sval) const; - tree get_representative_tree (const region *reg) const; + tree get_representative_tree (const svalue *sval, + logger *logger = nullptr) const; + tree get_representative_tree (const region *reg, + logger *logger = nullptr) const; path_var get_representative_path_var (const svalue *sval, - svalue_set *visited) const; + svalue_set *visited, + logger *logger) const; path_var get_representative_path_var (const region *reg, - svalue_set *visited) const; + svalue_set *visited, + logger *logger) const; /* For selftests. */ constraint_manager *get_constraints () @@ -585,10 +589,12 @@ class region_model path_var get_representative_path_var_1 (const svalue *sval, - svalue_set *visited) const; + svalue_set *visited, + logger *logger) const; path_var get_representative_path_var_1 (const region *reg, - svalue_set *visited) const; + svalue_set *visited, + logger *logger) const; const known_function *get_known_function (tree fndecl, const call_details &cd) const; diff --git a/gcc/analyzer/region.cc b/gcc/analyzer/region.cc index 71bae97b6f11e..d110b0eef357e 100644 --- a/gcc/analyzer/region.cc +++ b/gcc/analyzer/region.cc @@ -141,7 +141,7 @@ region_offset::dump (bool simple) const pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = stderr; + pp.set_output_stream (stderr); dump_to_pp (&pp, simple); pp_newline (&pp); pp_flush (&pp); @@ -425,10 +425,8 @@ region::get_base_region () const case RK_OFFSET: case RK_SIZED: case RK_BIT_RANGE: - iter = iter->get_parent_region (); - continue; case RK_CAST: - iter = iter->dyn_cast_cast_region ()->get_original_region (); + iter = iter->get_parent_region (); continue; default: return iter; @@ -468,10 +466,7 @@ region::descendent_of_p (const region *elder) const { if (iter == elder) return true; - if (iter->get_kind () == RK_CAST) - iter = iter->dyn_cast_cast_region ()->get_original_region (); - else - iter = iter->get_parent_region (); + iter = iter->get_parent_region (); } return false; } @@ -487,10 +482,7 @@ region::maybe_get_frame_region () const { if (const frame_region *frame_reg = iter->dyn_cast_frame_region ()) return frame_reg; - if (iter->get_kind () == RK_CAST) - iter = iter->dyn_cast_cast_region ()->get_original_region (); - else - iter = iter->get_parent_region (); + iter = iter->get_parent_region (); } return NULL; } @@ -525,10 +517,7 @@ region::get_memory_space () const case RK_PRIVATE: return MEMSPACE_PRIVATE; } - if (iter->get_kind () == RK_CAST) - iter = iter->dyn_cast_cast_region ()->get_original_region (); - else - iter = iter->get_parent_region (); + iter = iter->get_parent_region (); } return MEMSPACE_UNKNOWN; } @@ -958,15 +947,8 @@ region::calc_offset (region_model_manager *mgr) const } continue; case RK_SIZED: - iter_region = iter_region->get_parent_region (); - continue; - case RK_CAST: - { - const cast_region *cast_reg - = as_a (iter_region); - iter_region = cast_reg->get_original_region (); - } + iter_region = iter_region->get_parent_region (); continue; default: @@ -1036,7 +1018,7 @@ region::dump (bool simple) const pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = stderr; + pp.set_output_stream (stderr); dump_to_pp (&pp, simple); pp_newline (&pp); pp_flush (&pp); @@ -1094,7 +1076,7 @@ region::maybe_print_for_user (pretty_printer *pp, /* Use DWI to create a text_art::widget describing this region in a tree-like form, using PREFIX as a prefix (e.g. for field names). */ -std::unique_ptr +std::unique_ptr region::make_dump_widget (const text_art::dump_widget_info &dwi, const char *prefix) const { @@ -2276,15 +2258,6 @@ sized_region::get_bit_size_sval (region_model_manager *mgr) const /* class cast_region : public region. */ -/* Implementation of region::accept vfunc for cast_region. */ - -void -cast_region::accept (visitor *v) const -{ - region::accept (v); - m_original_region->accept (v); -} - /* Implementation of region::dump_to_pp vfunc for cast_region. */ void @@ -2295,13 +2268,13 @@ cast_region::dump_to_pp (pretty_printer *pp, bool simple) const pp_string (pp, "CAST_REG("); print_quoted_type (pp, get_type ()); pp_string (pp, ", "); - m_original_region->dump_to_pp (pp, simple); + get_parent_region ()->dump_to_pp (pp, simple); pp_string (pp, ")"); } else { pp_string (pp, "cast_region("); - m_original_region->dump_to_pp (pp, simple); + get_parent_region ()->dump_to_pp (pp, simple); pp_string (pp, ", "); print_quoted_type (pp, get_type ()); pp_printf (pp, ")"); @@ -2314,15 +2287,6 @@ cast_region::print_dump_widget_label (pretty_printer *pp) const pp_printf (pp, "cast_region"); } -void -cast_region:: -add_dump_widget_children (text_art::tree_widget &w, - const text_art::dump_widget_info &dwi) const -{ - w.add_child - (m_original_region->make_dump_widget (dwi, "m_original_region")); -} - /* Implementation of region::get_relative_concrete_offset vfunc for cast_region. */ diff --git a/gcc/analyzer/region.h b/gcc/analyzer/region.h index 5d58abc26938c..ffc05e034f1f0 100644 --- a/gcc/analyzer/region.h +++ b/gcc/analyzer/region.h @@ -182,7 +182,7 @@ class region : public symbol bool maybe_print_for_user (pretty_printer *pp, const region_model &model) const; - std::unique_ptr + std::unique_ptr make_dump_widget (const text_art::dump_widget_info &dwi, const char *prefix = nullptr) const; @@ -1170,65 +1170,54 @@ class cast_region : public region /* A support class for uniquifying instances of cast_region. */ struct key_t { - key_t (const region *original_region, tree type) - : m_original_region (original_region), m_type (type) + key_t (const region *parent, tree type) + : m_parent (parent), m_type (type) { - gcc_assert (original_region); + gcc_assert (parent); } hashval_t hash () const { inchash::hash hstate; - hstate.add_ptr (m_original_region); + hstate.add_ptr (m_parent); hstate.add_ptr (m_type); return hstate.end (); } bool operator== (const key_t &other) const { - return (m_original_region == other.m_original_region + return (m_parent == other.m_parent && m_type == other.m_type); } void mark_deleted () { - m_original_region = reinterpret_cast (1); + m_parent = reinterpret_cast (1); } - void mark_empty () { m_original_region = nullptr; } + void mark_empty () { m_parent = nullptr; } bool is_deleted () const { - return m_original_region == reinterpret_cast (1); + return m_parent == reinterpret_cast (1); } - bool is_empty () const { return m_original_region == nullptr; } + bool is_empty () const { return m_parent == nullptr; } - const region *m_original_region; + const region *m_parent; tree m_type; }; - cast_region (symbol::id_t id, const region *original_region, tree type) - : region (complexity (original_region), id, - original_region->get_parent_region (), type), - m_original_region (original_region) + cast_region (symbol::id_t id, const region *parent, tree type) + : region (complexity (parent), id, + parent, type) {} enum region_kind get_kind () const final override { return RK_CAST; } const cast_region * dyn_cast_cast_region () const final override { return this; } - void accept (visitor *v) const final override; void dump_to_pp (pretty_printer *pp, bool simple) const final override; void print_dump_widget_label (pretty_printer *pp) const final override; - void - add_dump_widget_children (text_art::tree_widget &, - const text_art::dump_widget_info &dwi) - const final override; bool get_relative_concrete_offset (bit_offset_t *out) const final override; - - const region *get_original_region () const { return m_original_region; } - -private: - const region *m_original_region; }; } // namespace ana diff --git a/gcc/analyzer/sm-malloc.cc b/gcc/analyzer/sm-malloc.cc index 8bdcb4bc33cd9..f1ec04d117d0a 100644 --- a/gcc/analyzer/sm-malloc.cc +++ b/gcc/analyzer/sm-malloc.cc @@ -586,7 +586,7 @@ deallocator_set::dump () const { pretty_printer pp; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = stderr; + pp.set_output_stream (stderr); dump_to_pp (&pp); pp_newline (&pp); pp_flush (&pp); diff --git a/gcc/analyzer/sm-taint.cc b/gcc/analyzer/sm-taint.cc index bd85f0d56113c..3bd050f963528 100644 --- a/gcc/analyzer/sm-taint.cc +++ b/gcc/analyzer/sm-taint.cc @@ -1625,14 +1625,6 @@ region_model::check_region_for_taint (const region *reg, } break; - case RK_CAST: - { - const cast_region *cast_reg - = as_a (iter_region); - iter_region = cast_reg->get_original_region (); - continue; - } - case RK_SIZED: { const sized_region *sized_reg diff --git a/gcc/analyzer/store.cc b/gcc/analyzer/store.cc index d14cfa329b8d0..284866c7effcf 100644 --- a/gcc/analyzer/store.cc +++ b/gcc/analyzer/store.cc @@ -110,7 +110,7 @@ uncertainty_t::dump (bool simple) const pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = stderr; + pp.set_output_stream (stderr); dump_to_pp (&pp, simple); pp_newline (&pp); pp_flush (&pp); @@ -147,7 +147,7 @@ binding_key::dump (bool simple) const pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = stderr; + pp.set_output_stream (stderr); dump_to_pp (&pp, simple); pp_newline (&pp); pp_flush (&pp); @@ -231,7 +231,7 @@ DEBUG_FUNCTION void bit_range::dump () const { pretty_printer pp; - pp.buffer->stream = stderr; + pp.set_output_stream (stderr); dump_to_pp (&pp); pp_newline (&pp); pp_flush (&pp); @@ -507,7 +507,7 @@ DEBUG_FUNCTION void byte_range::dump () const { pretty_printer pp; - pp.buffer->stream = stderr; + pp.set_output_stream (stderr); dump_to_pp (&pp); pp_newline (&pp); pp_flush (&pp); @@ -776,7 +776,7 @@ binding_map::dump (bool simple) const pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = stderr; + pp.set_output_stream (stderr); dump_to_pp (&pp, simple, true); pp_newline (&pp); pp_flush (&pp); @@ -1403,7 +1403,7 @@ binding_cluster::dump (bool simple) const pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = stderr; + pp.set_output_stream (stderr); pp_string (&pp, " cluster for: "); m_base_region->dump_to_pp (&pp, simple); pp_string (&pp, ": "); @@ -1451,7 +1451,7 @@ binding_cluster::to_json () const return cluster_obj; } -std::unique_ptr +std::unique_ptr binding_cluster::make_dump_widget (const text_art::dump_widget_info &dwi, store_manager *mgr) const { @@ -2281,6 +2281,7 @@ binding_cluster::get_representative_path_vars (const region_model *model, svalue_set *visited, const region *base_reg, const svalue *sval, + logger *logger, auto_vec *out_pvs) const { @@ -2308,7 +2309,8 @@ binding_cluster::get_representative_path_vars (const region_model *model, { if (path_var pv = model->get_representative_path_var (subregion, - visited)) + visited, + logger)) append_pathvar_with_type (pv, sval->get_type (), out_pvs); } } @@ -2317,7 +2319,8 @@ binding_cluster::get_representative_path_vars (const region_model *model, const symbolic_binding *skey = (const symbolic_binding *)key; if (path_var pv = model->get_representative_path_var (skey->get_region (), - visited)) + visited, + logger)) append_pathvar_with_type (pv, sval->get_type (), out_pvs); } } @@ -2636,7 +2639,7 @@ store::dump (bool simple) const pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = stderr; + pp.set_output_stream (stderr); dump_to_pp (&pp, simple, true, NULL); pp_newline (&pp); pp_flush (&pp); @@ -2707,7 +2710,7 @@ store::to_json () const return store_obj; } -std::unique_ptr +std::unique_ptr store::make_dump_widget (const text_art::dump_widget_info &dwi, store_manager *mgr) const { @@ -3282,6 +3285,7 @@ void store::get_representative_path_vars (const region_model *model, svalue_set *visited, const svalue *sval, + logger *logger, auto_vec *out_pvs) const { gcc_assert (sval); @@ -3293,6 +3297,7 @@ store::get_representative_path_vars (const region_model *model, const region *base_reg = (*iter).first; binding_cluster *cluster = (*iter).second; cluster->get_representative_path_vars (model, visited, base_reg, sval, + logger, out_pvs); } @@ -3300,7 +3305,8 @@ store::get_representative_path_vars (const region_model *model, { const region *reg = init_sval->get_region (); if (path_var pv = model->get_representative_path_var (reg, - visited)) + visited, + logger)) out_pvs->safe_push (pv); } } diff --git a/gcc/analyzer/store.h b/gcc/analyzer/store.h index 9be9df723794a..af9ea4172a2f9 100644 --- a/gcc/analyzer/store.h +++ b/gcc/analyzer/store.h @@ -617,7 +617,7 @@ class binding_cluster json::object *to_json () const; - std::unique_ptr + std::unique_ptr make_dump_widget (const text_art::dump_widget_info &dwi, store_manager *mgr) const; @@ -681,6 +681,7 @@ class binding_cluster svalue_set *visited, const region *base_reg, const svalue *sval, + logger *logger, auto_vec *out_pvs) const; const svalue *maybe_get_simple_value (store_manager *mgr) const; @@ -759,7 +760,7 @@ class store json::object *to_json () const; - std::unique_ptr + std::unique_ptr make_dump_widget (const text_art::dump_widget_info &dwi, store_manager *mgr) const; @@ -806,6 +807,7 @@ class store void get_representative_path_vars (const region_model *model, svalue_set *visited, const svalue *sval, + logger *logger, auto_vec *out_pvs) const; cluster_map_t::iterator begin () const { return m_cluster_map.begin (); } diff --git a/gcc/analyzer/supergraph.cc b/gcc/analyzer/supergraph.cc index adbf90f17ede3..4dc7942b26aaa 100644 --- a/gcc/analyzer/supergraph.cc +++ b/gcc/analyzer/supergraph.cc @@ -443,7 +443,7 @@ supergraph::dump_dot_to_file (FILE *fp, const dump_args_t &dump_args) const trying to prettify things by showing the underlying var. */ pp_format_decoder (pp) = default_tree_printer; - pp->buffer->stream = fp; + pp->set_output_stream (fp); dump_dot_to_pp (pp, dump_args); pp_flush (pp); delete pp; @@ -902,7 +902,7 @@ superedge::dump () const pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = stderr; + pp.set_output_stream (stderr); dump (&pp); pp_newline (&pp); pp_flush (&pp); diff --git a/gcc/analyzer/svalue.cc b/gcc/analyzer/svalue.cc index f1fd21e4cda9d..c82aa107b3caa 100644 --- a/gcc/analyzer/svalue.cc +++ b/gcc/analyzer/svalue.cc @@ -89,7 +89,7 @@ svalue::dump (bool simple) const pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = stderr; + pp.set_output_stream (stderr); dump_to_pp (&pp, simple); pp_newline (&pp); pp_flush (&pp); @@ -230,7 +230,7 @@ svalue::maybe_print_for_user (pretty_printer *pp, (a) print_dump_widget_label, to populate the text of a tree_widget, and (b) add_dump_widget_children, to add children to the tree_widget. */ -std::unique_ptr +std::unique_ptr svalue::make_dump_widget (const text_art::dump_widget_info &dwi, const char *prefix) const { diff --git a/gcc/analyzer/svalue.h b/gcc/analyzer/svalue.h index e5503a541779c..bc2374fe88922 100644 --- a/gcc/analyzer/svalue.h +++ b/gcc/analyzer/svalue.h @@ -107,7 +107,7 @@ class svalue : public symbol json::value *to_json () const; - std::unique_ptr + std::unique_ptr make_dump_widget (const dump_widget_info &dwi, const char *prefix = nullptr) const; diff --git a/gcc/builtins.cc b/gcc/builtins.cc index 5b5307c67b8ca..d467d1697b45b 100644 --- a/gcc/builtins.cc +++ b/gcc/builtins.cc @@ -2835,9 +2835,7 @@ expand_builtin_issignaling (tree exp, rtx target) it is, working on the DImode high part is usually better. */ if (!MEM_P (temp)) { - if (rtx t = simplify_gen_subreg (imode, temp, fmode, - subreg_highpart_offset (imode, - fmode))) + if (rtx t = force_highpart_subreg (imode, temp, fmode)) hi = t; else { @@ -2845,9 +2843,7 @@ expand_builtin_issignaling (tree exp, rtx target) if (int_mode_for_mode (fmode).exists (&imode2)) { rtx temp2 = gen_lowpart (imode2, temp); - poly_uint64 off = subreg_highpart_offset (imode, imode2); - if (rtx t = simplify_gen_subreg (imode, temp2, - imode2, off)) + if (rtx t = force_highpart_subreg (imode, temp2, imode2)) hi = t; } } @@ -2938,22 +2934,16 @@ expand_builtin_issignaling (tree exp, rtx target) it is, working on DImode parts is usually better. */ if (!MEM_P (temp)) { - hi = simplify_gen_subreg (imode, temp, fmode, - subreg_highpart_offset (imode, fmode)); - lo = simplify_gen_subreg (imode, temp, fmode, - subreg_lowpart_offset (imode, fmode)); + hi = force_highpart_subreg (imode, temp, fmode); + lo = force_lowpart_subreg (imode, temp, fmode); if (!hi || !lo) { scalar_int_mode imode2; if (int_mode_for_mode (fmode).exists (&imode2)) { rtx temp2 = gen_lowpart (imode2, temp); - hi = simplify_gen_subreg (imode, temp2, imode2, - subreg_highpart_offset (imode, - imode2)); - lo = simplify_gen_subreg (imode, temp2, imode2, - subreg_lowpart_offset (imode, - imode2)); + hi = force_highpart_subreg (imode, temp2, imode2); + lo = force_lowpart_subreg (imode, temp2, imode2); } } if (!hi || !lo) diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 2d75e6995ef04..8ddaf94bee3b3 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,54 @@ +2024-06-18 David Malcolm + + * c-opts.cc: Replace include of "tree-diagnostic.h" with + "diagnostic-macro-unwinding.h". + +2024-06-17 Eric Botcazou + + * c-ada-spec.cc (is_float16): New predicate. + (dump_ada_node) : Call it. + +2024-06-17 Joseph Myers + + * c-common.cc (c_sizeof_or_alignof_type): Allow alignof on an + incomplete array type for C2Y. + +2024-06-17 Jakub Jelinek + + PR c/115290 + * c-warn.cc (do_warn_array_compare): Use %E rather than %D for + printing op0 and op1; if those operands aren't decls, also print + parens around them. + +2024-06-12 David Malcolm + + * c-ada-spec.cc (dump_ads): Update for fields of pretty_printer + becoming private. + * c-pretty-print.cc: Likewise throughout. + +2024-06-12 David Malcolm + + * c-ada-spec.cc: Rename pretty_printer "buffer" to "pp" + throughout. + +2024-06-11 Joseph Myers + + * c-common.cc (flag_isoc2y): New. + (flag_isoc99, flag_isoc11, flag_isoc23): Update comments. + * c-common.h (flag_isoc2y): New. + (clk_c, flag_isoc23): Update comments. + * c-opts.cc (set_std_c2y): New. + (c_common_handle_option): Handle OPT_std_c2y and OPT_std_gnu2y. + (set_std_c89, set_std_c99, set_std_c11, set_std_c17, set_std_c23): + Set flag_isoc2y. + (set_std_c23): Update comment. + * c.opt (Wc23-c2y-compat, std=c2y, std=gnu2y): New. + * c.opt.urls: Regenerate. + +2024-06-11 Andi Kleen + + * c-cppbuiltin.cc (c_cpp_builtins): Define __GXX_CONSTEXPR_ASM__ + 2024-06-05 Jakub Jelinek Frederik Harwath Sandra Loosemore diff --git a/gcc/c-family/c-ada-spec.cc b/gcc/c-family/c-ada-spec.cc index 0bea923220bbe..e1b1b2a4b73f7 100644 --- a/gcc/c-family/c-ada-spec.cc +++ b/gcc/c-family/c-ada-spec.cc @@ -40,7 +40,7 @@ static void dump_ada_structure (pretty_printer *, tree, tree, bool, int); static char *to_ada_name (const char *, bool *); #define INDENT(SPACE) \ - do { int i; for (i = 0; i True, "); + pp_string (pp, "with Import => True, "); - newline_and_indent (buffer, spc + 5); + newline_and_indent (pp, spc + 5); if (is_stdcall) - pp_string (buffer, "Convention => Stdcall, "); + pp_string (pp, "Convention => Stdcall, "); else if (name[0] == '_' && name[1] == 'Z') - pp_string (buffer, "Convention => CPP, "); + pp_string (pp, "Convention => CPP, "); else - pp_string (buffer, "Convention => C, "); + pp_string (pp, "Convention => C, "); - newline_and_indent (buffer, spc + 5); + newline_and_indent (pp, spc + 5); tree sec = lookup_attribute ("section", DECL_ATTRIBUTES (t)); if (sec) { - pp_string (buffer, "Linker_Section => \""); - pp_string (buffer, TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (sec)))); - pp_string (buffer, "\", "); - newline_and_indent (buffer, spc + 5); + pp_string (pp, "Linker_Section => \""); + pp_string (pp, TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (sec)))); + pp_string (pp, "\", "); + newline_and_indent (pp, spc + 5); } - pp_string (buffer, "External_Name => \""); + pp_string (pp, "External_Name => \""); if (is_stdcall) - pp_string (buffer, IDENTIFIER_POINTER (DECL_NAME (t))); + pp_string (pp, IDENTIFIER_POINTER (DECL_NAME (t))); else - pp_asm_name (buffer, t); + pp_asm_name (pp, t); - pp_string (buffer, "\";"); + pp_string (pp, "\";"); } /* Check whether T and its type have different names, and append "the_" - otherwise in BUFFER. */ + otherwise in PP. */ static void -check_type_name_conflict (pretty_printer *buffer, tree t) +check_type_name_conflict (pretty_printer *pp, tree t) { tree tmp = TREE_TYPE (t); @@ -1626,18 +1626,18 @@ check_type_name_conflict (pretty_printer *buffer, tree t) s = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (tmp))); if (!strcasecmp (IDENTIFIER_POINTER (DECL_NAME (t)), s)) - pp_string (buffer, "the_"); + pp_string (pp, "the_"); } } -/* Dump in BUFFER a function declaration FUNC in Ada syntax. +/* Dump in PP a function declaration FUNC in Ada syntax. IS_METHOD indicates whether FUNC is a C++ method. IS_CONSTRUCTOR whether FUNC is a C++ constructor. IS_DESTRUCTOR whether FUNC is a C++ destructor. SPC is the current indentation level. */ static void -dump_ada_function_declaration (pretty_printer *buffer, tree func, +dump_ada_function_declaration (pretty_printer *pp, tree func, bool is_method, bool is_constructor, bool is_destructor, int spc) { @@ -1670,12 +1670,12 @@ dump_ada_function_declaration (pretty_printer *buffer, tree func, num_args = 1; if (num_args > 2) - newline_and_indent (buffer, spc + 1); + newline_and_indent (pp, spc + 1); if (num_args > 0) { - pp_space (buffer); - pp_left_paren (buffer); + pp_space (pp); + pp_left_paren (pp); } /* For a function, see if we have the corresponding arguments. */ @@ -1707,24 +1707,24 @@ dump_ada_function_declaration (pretty_printer *buffer, tree func, { if (DECL_NAME (arg)) { - check_type_name_conflict (buffer, arg); - pp_ada_tree_identifier (buffer, DECL_NAME (arg), NULL_TREE, + check_type_name_conflict (pp, arg); + pp_ada_tree_identifier (pp, DECL_NAME (arg), NULL_TREE, false); - pp_string (buffer, " : "); + pp_string (pp, " : "); } else { sprintf (buf, "arg%d : ", num); - pp_string (buffer, buf); + pp_string (pp, buf); } - dump_ada_node (buffer, TREE_TYPE (arg), type, spc, false, true); + dump_ada_node (pp, TREE_TYPE (arg), type, spc, false, true); } else { sprintf (buf, "arg%d : ", num); - pp_string (buffer, buf); - dump_ada_node (buffer, TREE_VALUE (arg), type, spc, false, true); + pp_string (pp, buf); + dump_ada_node (pp, TREE_VALUE (arg), type, spc, false, true); } /* If the type is a pointer to a tagged type, we need to differentiate @@ -1738,47 +1738,47 @@ dump_ada_function_declaration (pretty_printer *buffer, tree func, && POINTER_TYPE_P (TREE_TYPE (arg)) && is_tagged_type (TREE_TYPE (TREE_TYPE (arg))) && !(num == 1 && is_method && (DECL_VINDEX (func) || is_constructor))) - pp_string (buffer, "'Class"); + pp_string (pp, "'Class"); arg = TREE_CHAIN (arg); if (num < num_args) { - pp_semicolon (buffer); + pp_semicolon (pp); if (num_args > 2) - newline_and_indent (buffer, spc + INDENT_INCR); + newline_and_indent (pp, spc + INDENT_INCR); else - pp_space (buffer); + pp_space (pp); } } if (have_ellipsis) { - pp_string (buffer, " -- , ..."); - newline_and_indent (buffer, spc + INDENT_INCR); + pp_string (pp, " -- , ..."); + newline_and_indent (pp, spc + INDENT_INCR); } if (num_args > 0) - pp_right_paren (buffer); + pp_right_paren (pp); if (is_constructor || !VOID_TYPE_P (TREE_TYPE (type))) { - pp_string (buffer, " return "); + pp_string (pp, " return "); tree rtype = is_constructor ? DECL_CONTEXT (func) : TREE_TYPE (type); - dump_ada_node (buffer, rtype, rtype, spc, false, true); + dump_ada_node (pp, rtype, rtype, spc, false, true); } } -/* Dump in BUFFER all the domains associated with an array NODE, +/* Dump in PP all the domains associated with an array NODE, in Ada syntax. SPC is the current indentation level. */ static void -dump_ada_array_domains (pretty_printer *buffer, tree node, int spc) +dump_ada_array_domains (pretty_printer *pp, tree node, int spc) { bool first = true; - pp_left_paren (buffer); + pp_left_paren (pp); for (; TREE_CODE (node) == ARRAY_TYPE; node = TREE_TYPE (node)) { @@ -1790,33 +1790,33 @@ dump_ada_array_domains (pretty_printer *buffer, tree node, int spc) tree max = TYPE_MAX_VALUE (domain); if (!first) - pp_string (buffer, ", "); + pp_string (pp, ", "); first = false; if (min) - dump_ada_node (buffer, min, NULL_TREE, spc, false, true); - pp_string (buffer, " .. "); + dump_ada_node (pp, min, NULL_TREE, spc, false, true); + pp_string (pp, " .. "); /* If the upper bound is zero, gcc may generate a NULL_TREE for TYPE_MAX_VALUE rather than an integer_cst. */ if (max) - dump_ada_node (buffer, max, NULL_TREE, spc, false, true); + dump_ada_node (pp, max, NULL_TREE, spc, false, true); else - pp_string (buffer, "0"); + pp_string (pp, "0"); } else { - pp_string (buffer, "size_t"); + pp_string (pp, "size_t"); first = false; } } - pp_right_paren (buffer); + pp_right_paren (pp); } -/* Dump in BUFFER file:line information related to NODE. */ +/* Dump in PP file:line information related to NODE. */ static void -dump_sloc (pretty_printer *buffer, tree node) +dump_sloc (pretty_printer *pp, tree node) { expanded_location xloc; @@ -1829,9 +1829,9 @@ dump_sloc (pretty_printer *buffer, tree node) if (xloc.file) { - pp_string (buffer, xloc.file); - pp_colon (buffer); - pp_decimal_int (buffer, xloc.line); + pp_string (pp, xloc.file); + pp_colon (pp); + pp_decimal_int (pp, xloc.line); } } @@ -1845,68 +1845,68 @@ is_char_array (tree t) && id_equal (DECL_NAME (TYPE_NAME (TREE_TYPE (t))), "char"); } -/* Dump in BUFFER an array type NODE in Ada syntax. SPC is the indentation +/* Dump in PP an array type NODE in Ada syntax. SPC is the indentation level. */ static void -dump_ada_array_type (pretty_printer *buffer, tree node, int spc) +dump_ada_array_type (pretty_printer *pp, tree node, int spc) { const bool char_array = is_char_array (node); /* Special case char arrays. */ if (char_array) - pp_string (buffer, "Interfaces.C.char_array "); + pp_string (pp, "Interfaces.C.char_array "); else - pp_string (buffer, "array "); + pp_string (pp, "array "); /* Print the dimensions. */ - dump_ada_array_domains (buffer, node, spc); + dump_ada_array_domains (pp, node, spc); /* Print the component type. */ if (!char_array) { tree tmp = strip_array_types (node); - pp_string (buffer, " of "); + pp_string (pp, " of "); if (TREE_CODE (tmp) != POINTER_TYPE && !packed_layout) - pp_string (buffer, "aliased "); + pp_string (pp, "aliased "); if (TYPE_NAME (tmp) || (!RECORD_OR_UNION_TYPE_P (tmp) && TREE_CODE (tmp) != ENUMERAL_TYPE)) - dump_ada_node (buffer, tmp, node, spc, false, true); + dump_ada_node (pp, tmp, node, spc, false, true); else - dump_anonymous_type_name (buffer, tmp); + dump_anonymous_type_name (pp, tmp); } } -/* Dump in BUFFER type names associated with a template, each prepended with +/* Dump in PP type names associated with a template, each prepended with '_'. TYPES is the TREE_PURPOSE of a DECL_TEMPLATE_INSTANTIATIONS. SPC is the indentation level. */ static void -dump_template_types (pretty_printer *buffer, tree types, int spc) +dump_template_types (pretty_printer *pp, tree types, int spc) { for (int i = 0; i < TREE_VEC_LENGTH (types); i++) { tree elem = TREE_VEC_ELT (types, i); - pp_underscore (buffer); + pp_underscore (pp); - if (!dump_ada_node (buffer, elem, NULL_TREE, spc, false, true)) + if (!dump_ada_node (pp, elem, NULL_TREE, spc, false, true)) { - pp_string (buffer, "unknown"); - pp_scalar (buffer, HOST_SIZE_T_PRINT_UNSIGNED, + pp_string (pp, "unknown"); + pp_scalar (pp, HOST_SIZE_T_PRINT_UNSIGNED, (fmt_size_t) TREE_HASH (elem)); } } } -/* Dump in BUFFER the contents of all class instantiations associated with +/* Dump in PP the contents of all class instantiations associated with a given template T. SPC is the indentation level. */ static int -dump_ada_template (pretty_printer *buffer, tree t, int spc) +dump_ada_template (pretty_printer *pp, tree t, int spc) { /* DECL_SIZE_UNIT is DECL_TEMPLATE_INSTANTIATIONS in this context. */ tree inst = DECL_SIZE_UNIT (t); @@ -1945,39 +1945,39 @@ dump_ada_template (pretty_printer *buffer, tree t, int spc) num_inst++; INDENT (spc); - pp_string (buffer, "package "); + pp_string (pp, "package "); package_prefix = false; - dump_ada_node (buffer, instance, t, spc, false, true); - dump_template_types (buffer, types, spc); - pp_string (buffer, " is"); + dump_ada_node (pp, instance, t, spc, false, true); + dump_template_types (pp, types, spc); + pp_string (pp, " is"); spc += INDENT_INCR; - newline_and_indent (buffer, spc); + newline_and_indent (pp, spc); TREE_VISITED (get_underlying_decl (instance)) = 1; - pp_string (buffer, "type "); - dump_ada_node (buffer, instance, t, spc, false, true); + pp_string (pp, "type "); + dump_ada_node (pp, instance, t, spc, false, true); package_prefix = true; if (is_tagged_type (instance)) - pp_string (buffer, " is tagged limited "); + pp_string (pp, " is tagged limited "); else - pp_string (buffer, " is limited "); + pp_string (pp, " is limited "); - dump_ada_node (buffer, instance, t, spc, false, false); - pp_newline (buffer); + dump_ada_node (pp, instance, t, spc, false, false); + pp_newline (pp); spc -= INDENT_INCR; - newline_and_indent (buffer, spc); + newline_and_indent (pp, spc); - pp_string (buffer, "end;"); - newline_and_indent (buffer, spc); - pp_string (buffer, "use "); + pp_string (pp, "end;"); + newline_and_indent (pp, spc); + pp_string (pp, "use "); package_prefix = false; - dump_ada_node (buffer, instance, t, spc, false, true); - dump_template_types (buffer, types, spc); + dump_ada_node (pp, instance, t, spc, false, true); + dump_template_types (pp, types, spc); package_prefix = true; - pp_semicolon (buffer); - pp_newline (buffer); - pp_newline (buffer); + pp_semicolon (pp); + pp_newline (pp); + pp_newline (pp); } return num_inst > 0; @@ -2007,41 +2007,41 @@ is_simple_enum (tree node) return true; } -/* Dump in BUFFER the declaration of enumeral NODE of type TYPE in Ada syntax. +/* Dump in PP the declaration of enumeral NODE of type TYPE in Ada syntax. SPC is the indentation level. */ static void -dump_ada_enum_type (pretty_printer *buffer, tree node, tree type, int spc) +dump_ada_enum_type (pretty_printer *pp, tree node, tree type, int spc) { if (is_simple_enum (node)) { bool first = true; spc += INDENT_INCR; - newline_and_indent (buffer, spc - 1); - pp_left_paren (buffer); + newline_and_indent (pp, spc - 1); + pp_left_paren (pp); for (tree value = TYPE_VALUES (node); value; value = TREE_CHAIN (value)) { if (first) first = false; else { - pp_comma (buffer); - newline_and_indent (buffer, spc); + pp_comma (pp); + newline_and_indent (pp, spc); } - pp_ada_tree_identifier (buffer, TREE_PURPOSE (value), node, false); + pp_ada_tree_identifier (pp, TREE_PURPOSE (value), node, false); } - pp_string (buffer, ")"); + pp_string (pp, ")"); spc -= INDENT_INCR; - newline_and_indent (buffer, spc); - pp_string (buffer, "with Convention => C"); + newline_and_indent (pp, spc); + pp_string (pp, "with Convention => C"); } else { if (TYPE_UNSIGNED (node)) - pp_string (buffer, "unsigned"); + pp_string (pp, "unsigned"); else - pp_string (buffer, "int"); + pp_string (pp, "int"); for (tree value = TYPE_VALUES (node); value; value = TREE_CHAIN (value)) { @@ -2050,33 +2050,49 @@ dump_ada_enum_type (pretty_printer *buffer, tree node, tree type, int spc) if (TREE_CODE (int_val) != INTEGER_CST) int_val = DECL_INITIAL (int_val); - pp_semicolon (buffer); - newline_and_indent (buffer, spc); + pp_semicolon (pp); + newline_and_indent (pp, spc); if (TYPE_NAME (node)) - dump_ada_node (buffer, node, NULL_TREE, spc, false, true); + dump_ada_node (pp, node, NULL_TREE, spc, false, true); else if (type) - dump_ada_node (buffer, type, NULL_TREE, spc, false, true); + dump_ada_node (pp, type, NULL_TREE, spc, false, true); else - dump_anonymous_type_name (buffer, node); - pp_underscore (buffer); - pp_ada_tree_identifier (buffer, TREE_PURPOSE (value), node, false); + dump_anonymous_type_name (pp, node); + pp_underscore (pp); + pp_ada_tree_identifier (pp, TREE_PURPOSE (value), node, false); - pp_string (buffer, " : constant "); + pp_string (pp, " : constant "); if (TYPE_NAME (node)) - dump_ada_node (buffer, node, NULL_TREE, spc, false, true); + dump_ada_node (pp, node, NULL_TREE, spc, false, true); else if (type) - dump_ada_node (buffer, type, NULL_TREE, spc, false, true); + dump_ada_node (pp, type, NULL_TREE, spc, false, true); else - dump_anonymous_type_name (buffer, node); + dump_anonymous_type_name (pp, node); - pp_string (buffer, " := "); - dump_ada_node (buffer, int_val, node, spc, false, true); + pp_string (pp, " := "); + dump_ada_node (pp, int_val, node, spc, false, true); } } } +/* Return true if NODE is the __bf16 type. */ + +static bool +is_float16 (tree node) +{ + if (!TYPE_NAME (node) || TREE_CODE (TYPE_NAME (node)) != TYPE_DECL) + return false; + + tree name = DECL_NAME (TYPE_NAME (node)); + + if (IDENTIFIER_POINTER (name) [0] != '_') + return false; + + return id_equal (name, "__bf16"); +} + /* Return true if NODE is the _Float32/_Float32x type. */ static bool @@ -2127,13 +2143,13 @@ is_float128 (tree node) || id_equal (name, "_Float128x"); } -/* Recursively dump in BUFFER Ada declarations corresponding to NODE of type +/* Recursively dump in PP Ada declarations corresponding to NODE of type TYPE. SPC is the indentation level. LIMITED_ACCESS indicates whether NODE can be referenced via a "limited with" clause. NAME_ONLY indicates whether we should only dump the name of NODE, instead of its full declaration. */ static int -dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc, +dump_ada_node (pretty_printer *pp, tree node, tree type, int spc, bool limited_access, bool name_only) { if (node == NULL_TREE) @@ -2142,24 +2158,24 @@ dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc, switch (TREE_CODE (node)) { case ERROR_MARK: - pp_string (buffer, "<<< error >>>"); + pp_string (pp, "<<< error >>>"); return 0; case IDENTIFIER_NODE: - pp_ada_tree_identifier (buffer, node, type, limited_access); + pp_ada_tree_identifier (pp, node, type, limited_access); break; case TREE_LIST: - pp_string (buffer, "--- unexpected node: TREE_LIST"); + pp_string (pp, "--- unexpected node: TREE_LIST"); return 0; case TREE_BINFO: - dump_ada_node (buffer, BINFO_TYPE (node), type, spc, limited_access, + dump_ada_node (pp, BINFO_TYPE (node), type, spc, limited_access, name_only); return 0; case TREE_VEC: - pp_string (buffer, "--- unexpected node: TREE_VEC"); + pp_string (pp, "--- unexpected node: TREE_VEC"); return 0; case NULLPTR_TYPE: @@ -2167,63 +2183,68 @@ dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc, if (package_prefix) { append_withs ("System", false); - pp_string (buffer, "System.Address"); + pp_string (pp, "System.Address"); } else - pp_string (buffer, "address"); + pp_string (pp, "address"); break; case VECTOR_TYPE: - pp_string (buffer, ""); + pp_string (pp, ""); break; case COMPLEX_TYPE: if (is_float128 (TREE_TYPE (node))) { append_withs ("Interfaces.C.Extensions", false); - pp_string (buffer, "Extensions.CFloat_128"); + pp_string (pp, "Extensions.CFloat_128"); } else if (TREE_TYPE (node) == float_type_node) { append_withs ("Ada.Numerics.Complex_Types", false); - pp_string (buffer, "Ada.Numerics.Complex_Types.Complex"); + pp_string (pp, "Ada.Numerics.Complex_Types.Complex"); } else if (TREE_TYPE (node) == double_type_node) { append_withs ("Ada.Numerics.Long_Complex_Types", false); - pp_string (buffer, "Ada.Numerics.Long_Complex_Types.Complex"); + pp_string (pp, "Ada.Numerics.Long_Complex_Types.Complex"); } else if (TREE_TYPE (node) == long_double_type_node) { append_withs ("Ada.Numerics.Long_Long_Complex_Types", false); - pp_string (buffer, "Ada.Numerics.Long_Long_Complex_Types.Complex"); + pp_string (pp, "Ada.Numerics.Long_Long_Complex_Types.Complex"); } else - pp_string (buffer, ""); + pp_string (pp, ""); break; case ENUMERAL_TYPE: if (name_only) - dump_ada_node (buffer, TYPE_NAME (node), node, spc, false, true); + dump_ada_node (pp, TYPE_NAME (node), node, spc, false, true); else - dump_ada_enum_type (buffer, node, type, spc); + dump_ada_enum_type (pp, node, type, spc); break; case REAL_TYPE: - if (is_float32 (node)) + if (is_float16 (node)) + { + pp_string (pp, "Short_Float"); + break; + } + else if (is_float32 (node)) { - pp_string (buffer, "Float"); + pp_string (pp, "Float"); break; } else if (is_float64 (node)) { - pp_string (buffer, "Long_Float"); + pp_string (pp, "Long_Float"); break; } else if (is_float128 (node)) { append_withs ("Interfaces.C.Extensions", false); - pp_string (buffer, "Extensions.Float_128"); + pp_string (pp, "Extensions.Float_128"); break; } @@ -2238,13 +2259,13 @@ dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc, "__int128"))) { if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE) - pp_ada_tree_identifier (buffer, TYPE_NAME (node), node, + pp_ada_tree_identifier (pp, TYPE_NAME (node), node, limited_access); else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL && DECL_NAME (TYPE_NAME (node))) - dump_ada_decl_name (buffer, TYPE_NAME (node), limited_access); + dump_ada_decl_name (pp, TYPE_NAME (node), limited_access); else - pp_string (buffer, ""); + pp_string (pp, ""); } else if (TREE_CODE (node) == INTEGER_TYPE) { @@ -2252,41 +2273,41 @@ dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc, bitfield_used = true; if (TYPE_PRECISION (node) == 1) - pp_string (buffer, "Extensions.Unsigned_1"); + pp_string (pp, "Extensions.Unsigned_1"); else { - pp_string (buffer, TYPE_UNSIGNED (node) + pp_string (pp, TYPE_UNSIGNED (node) ? "Extensions.Unsigned_" : "Extensions.Signed_"); - pp_decimal_int (buffer, TYPE_PRECISION (node)); + pp_decimal_int (pp, TYPE_PRECISION (node)); } } else - pp_string (buffer, ""); + pp_string (pp, ""); break; case POINTER_TYPE: case REFERENCE_TYPE: if (name_only && TYPE_NAME (node)) - dump_ada_node (buffer, TYPE_NAME (node), node, spc, limited_access, + dump_ada_node (pp, TYPE_NAME (node), node, spc, limited_access, true); else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE) { if (VOID_TYPE_P (TREE_TYPE (TREE_TYPE (node)))) - pp_string (buffer, "access procedure"); + pp_string (pp, "access procedure"); else - pp_string (buffer, "access function"); + pp_string (pp, "access function"); - dump_ada_function_declaration (buffer, node, false, false, false, + dump_ada_function_declaration (pp, node, false, false, false, spc + INDENT_INCR); /* If we are dumping the full type, it means we are part of a type definition and need also a Convention C aspect. */ if (!name_only) { - newline_and_indent (buffer, spc); - pp_string (buffer, "with Convention => C"); + newline_and_indent (pp, spc); + pp_string (pp, "with Convention => C"); } } else @@ -2298,14 +2319,14 @@ dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc, if (VOID_TYPE_P (ref_type)) { if (!name_only) - pp_string (buffer, "new "); + pp_string (pp, "new "); if (package_prefix) { append_withs ("System", false); - pp_string (buffer, "System.Address"); + pp_string (pp, "System.Address"); } else - pp_string (buffer, "address"); + pp_string (pp, "address"); } else { @@ -2314,15 +2335,15 @@ dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc, && id_equal (DECL_NAME (TYPE_NAME (ref_type)), "char")) { if (!name_only) - pp_string (buffer, "new "); + pp_string (pp, "new "); if (package_prefix) { - pp_string (buffer, "Interfaces.C.Strings.chars_ptr"); + pp_string (pp, "Interfaces.C.Strings.chars_ptr"); append_withs ("Interfaces.C.Strings", false); } else - pp_string (buffer, "chars_ptr"); + pp_string (pp, "chars_ptr"); } else { @@ -2336,40 +2357,40 @@ dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc, { append_withs ("System", false); if (!name_only) - pp_string (buffer, "new "); - pp_string (buffer, "System.Address"); + pp_string (pp, "new "); + pp_string (pp, "System.Address"); } else - pp_string (buffer, "address"); + pp_string (pp, "address"); return spc; } if (!package_prefix) { is_access = false; - pp_string (buffer, "access"); + pp_string (pp, "access"); } else if (AGGREGATE_TYPE_P (ref_type)) { if (!type || TREE_CODE (type) != FUNCTION_DECL) { is_access = true; - pp_string (buffer, "access "); + pp_string (pp, "access "); if (quals & TYPE_QUAL_CONST) - pp_string (buffer, "constant "); + pp_string (pp, "constant "); else if (!name_only) - pp_string (buffer, "all "); + pp_string (pp, "all "); } else if (quals & TYPE_QUAL_CONST) { is_access = false; - pp_string (buffer, "in "); + pp_string (pp, "in "); } else { is_access = true; - pp_string (buffer, "access "); + pp_string (pp, "access "); } } else @@ -2377,10 +2398,10 @@ dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc, /* We want to use regular with clauses for scalar types, as they are not involved in circular declarations. */ is_access = false; - pp_string (buffer, "access "); + pp_string (pp, "access "); if (!name_only) - pp_string (buffer, "all "); + pp_string (pp, "all "); } /* If this is the anonymous original type of a typedef'ed @@ -2421,7 +2442,7 @@ dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc, break; } - dump_ada_node (buffer, ref_type, ref_type, spc, is_access, + dump_ada_node (pp, ref_type, ref_type, spc, is_access, true); } } @@ -2430,19 +2451,19 @@ dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc, case ARRAY_TYPE: if (name_only) - dump_ada_node (buffer, TYPE_NAME (node), node, spc, limited_access, + dump_ada_node (pp, TYPE_NAME (node), node, spc, limited_access, true); else - dump_ada_array_type (buffer, node, spc); + dump_ada_array_type (pp, node, spc); break; case RECORD_TYPE: case UNION_TYPE: if (name_only) - dump_ada_node (buffer, TYPE_NAME (node), node, spc, limited_access, + dump_ada_node (pp, TYPE_NAME (node), node, spc, limited_access, true); else - dump_ada_structure (buffer, node, type, false, spc); + dump_ada_structure (pp, node, type, false, spc); break; case INTEGER_CST: @@ -2452,25 +2473,25 @@ dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc, if (TREE_TYPE (node) == sizetype) node = fold_convert (ssizetype, node); if (tree_fits_shwi_p (node)) - pp_wide_integer (buffer, tree_to_shwi (node)); + pp_wide_integer (pp, tree_to_shwi (node)); else if (tree_fits_uhwi_p (node)) - pp_unsigned_wide_integer (buffer, tree_to_uhwi (node)); + pp_unsigned_wide_integer (pp, tree_to_uhwi (node)); else { wide_int val = wi::to_wide (node); int i; if (wi::neg_p (val)) { - pp_minus (buffer); + pp_minus (pp); val = -val; } - sprintf (pp_buffer (buffer)->digit_buffer, + sprintf (pp_buffer (pp)->digit_buffer, "16#%" HOST_WIDE_INT_PRINT "x", val.elt (val.get_len () - 1)); for (i = val.get_len () - 2; i >= 0; i--) - sprintf (pp_buffer (buffer)->digit_buffer, + sprintf (pp_buffer (pp)->digit_buffer, HOST_WIDE_INT_PRINT_PADDED_HEX, val.elt (i)); - pp_string (buffer, pp_buffer (buffer)->digit_buffer); + pp_string (pp, pp_buffer (pp)->digit_buffer); } break; @@ -2492,14 +2513,14 @@ dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc, if (package_prefix) { append_withs ("System", false); - pp_string (buffer, "System.Address"); + pp_string (pp, "System.Address"); } else - pp_string (buffer, "address"); + pp_string (pp, "address"); } } else if (name_only) - dump_ada_decl_name (buffer, node, limited_access); + dump_ada_decl_name (pp, node, limited_access); else { if (is_tagged_type (TREE_TYPE (node))) @@ -2515,23 +2536,23 @@ dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc, { if (first) { - pp_string (buffer, "limited new "); + pp_string (pp, "limited new "); first = false; } else - pp_string (buffer, " and "); + pp_string (pp, " and "); - dump_ada_decl_name (buffer, TYPE_NAME (TREE_TYPE (fld)), + dump_ada_decl_name (pp, TYPE_NAME (TREE_TYPE (fld)), false); } } - pp_string (buffer, first ? "tagged limited " : " with "); + pp_string (pp, first ? "tagged limited " : " with "); } else if (has_nontrivial_methods (TREE_TYPE (node))) - pp_string (buffer, "limited "); + pp_string (pp, "limited "); - dump_ada_node (buffer, TREE_TYPE (node), type, spc, false, false); + dump_ada_node (pp, TREE_TYPE (node), type, spc, false, false); } break; @@ -2541,7 +2562,7 @@ dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc, case PARM_DECL: case FIELD_DECL: case NAMESPACE_DECL: - dump_ada_decl_name (buffer, node, false); + dump_ada_decl_name (pp, node, false); break; default: @@ -2552,16 +2573,16 @@ dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc, return 1; } -/* Dump in BUFFER NODE's methods. SPC is the indentation level. Return 1 if +/* Dump in PP NODE's methods. SPC is the indentation level. Return 1 if methods were printed, 0 otherwise. */ static int -dump_ada_methods (pretty_printer *buffer, tree node, int spc) +dump_ada_methods (pretty_printer *pp, tree node, int spc) { if (!has_nontrivial_methods (node)) return 0; - pp_semicolon (buffer); + pp_semicolon (pp); int res = 1; for (tree fld = TYPE_FIELDS (node); fld; fld = DECL_CHAIN (fld)) @@ -2569,21 +2590,21 @@ dump_ada_methods (pretty_printer *buffer, tree node, int spc) { if (res) { - pp_newline (buffer); - pp_newline (buffer); + pp_newline (pp); + pp_newline (pp); } - res = dump_ada_declaration (buffer, fld, node, spc); + res = dump_ada_declaration (pp, fld, node, spc); } return 1; } -/* Dump in BUFFER a forward declaration for TYPE present inside T. +/* Dump in PP a forward declaration for TYPE present inside T. SPC is the indentation level. */ static void -dump_forward_type (pretty_printer *buffer, tree type, tree t, int spc) +dump_forward_type (pretty_printer *pp, tree type, tree t, int spc) { tree decl = get_underlying_decl (type); @@ -2591,14 +2612,14 @@ dump_forward_type (pretty_printer *buffer, tree type, tree t, int spc) if (!decl) { if (TREE_CODE (type) == POINTER_TYPE) - dump_forward_type (buffer, TREE_TYPE (type), t, spc); + dump_forward_type (pp, TREE_TYPE (type), t, spc); else if (TREE_CODE (type) == FUNCTION_TYPE) { function_args_iterator args_iter; tree arg; - dump_forward_type (buffer, TREE_TYPE (type), t, spc); + dump_forward_type (pp, TREE_TYPE (type), t, spc); FOREACH_FUNCTION_ARGS (type, arg, args_iter) - dump_forward_type (buffer, arg, t, spc); + dump_forward_type (pp, arg, t, spc); } return; } @@ -2614,10 +2635,10 @@ dump_forward_type (pretty_printer *buffer, tree type, tree t, int spc) return; /* Generate an incomplete type declaration. */ - pp_string (buffer, "type "); - dump_ada_node (buffer, decl, NULL_TREE, spc, false, true); - pp_semicolon (buffer); - newline_and_indent (buffer, spc); + pp_string (pp, "type "); + dump_ada_node (pp, decl, NULL_TREE, spc, false, true); + pp_semicolon (pp); + newline_and_indent (pp, spc); /* Only one incomplete declaration is legal for a given type. */ TREE_VISITED (decl) = 1; @@ -2630,7 +2651,7 @@ static bitmap dumped_anonymous_types; static void dump_nested_type (pretty_printer *, tree, tree, int); -/* Dump in BUFFER anonymous types nested inside T's definition. PARENT is the +/* Dump in PP anonymous types nested inside T's definition. PARENT is the parent node of T. DUMPED_TYPES is the bitmap of already dumped types. SPC is the indentation level. @@ -2644,7 +2665,7 @@ static void dump_nested_type (pretty_printer *, tree, tree, int); pass on the nested TYPE_DECLs and a second pass on the unnamed types. */ static void -dump_nested_types (pretty_printer *buffer, tree t, int spc) +dump_nested_types (pretty_printer *pp, tree t, int spc) { tree type, field; @@ -2658,18 +2679,18 @@ dump_nested_types (pretty_printer *buffer, tree t, int spc) && DECL_NAME (field) != DECL_NAME (t) && !DECL_ORIGINAL_TYPE (field) && TYPE_NAME (TREE_TYPE (field)) != TYPE_NAME (type)) - dump_nested_type (buffer, field, t, spc); + dump_nested_type (pp, field, t, spc); for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field)) if (TREE_CODE (field) == FIELD_DECL && !TYPE_NAME (TREE_TYPE (field))) - dump_nested_type (buffer, field, t, spc); + dump_nested_type (pp, field, t, spc); } -/* Dump in BUFFER the anonymous type of FIELD inside T. SPC is the indentation +/* Dump in PP the anonymous type of FIELD inside T. SPC is the indentation level. */ static void -dump_nested_type (pretty_printer *buffer, tree field, tree t, int spc) +dump_nested_type (pretty_printer *pp, tree field, tree t, int spc) { tree field_type = TREE_TYPE (field); tree decl, tmp; @@ -2678,7 +2699,7 @@ dump_nested_type (pretty_printer *buffer, tree field, tree t, int spc) { case POINTER_TYPE: tmp = TREE_TYPE (field_type); - dump_forward_type (buffer, tmp, t, spc); + dump_forward_type (pp, tmp, t, spc); break; case ARRAY_TYPE: @@ -2694,59 +2715,59 @@ dump_nested_type (pretty_printer *buffer, tree field, tree t, int spc) && !TREE_VISITED (decl)) { /* Generate full declaration. */ - dump_nested_type (buffer, decl, t, spc); + dump_nested_type (pp, decl, t, spc); TREE_VISITED (decl) = 1; } else if (!decl && TREE_CODE (tmp) == POINTER_TYPE) - dump_forward_type (buffer, TREE_TYPE (tmp), t, spc); + dump_forward_type (pp, TREE_TYPE (tmp), t, spc); /* Special case char arrays. */ if (is_char_array (field_type)) - pp_string (buffer, "subtype "); + pp_string (pp, "subtype "); else - pp_string (buffer, "type "); + pp_string (pp, "type "); - dump_anonymous_type_name (buffer, field_type); - pp_string (buffer, " is "); - dump_ada_array_type (buffer, field_type, spc); - pp_semicolon (buffer); - newline_and_indent (buffer, spc); + dump_anonymous_type_name (pp, field_type); + pp_string (pp, " is "); + dump_ada_array_type (pp, field_type, spc); + pp_semicolon (pp); + newline_and_indent (pp, spc); break; case ENUMERAL_TYPE: if (is_simple_enum (field_type)) - pp_string (buffer, "type "); + pp_string (pp, "type "); else - pp_string (buffer, "subtype "); + pp_string (pp, "subtype "); if (TYPE_NAME (field_type)) - dump_ada_node (buffer, field_type, NULL_TREE, spc, false, true); + dump_ada_node (pp, field_type, NULL_TREE, spc, false, true); else - dump_anonymous_type_name (buffer, field_type); - pp_string (buffer, " is "); - dump_ada_enum_type (buffer, field_type, NULL_TREE, spc); - pp_semicolon (buffer); - newline_and_indent (buffer, spc); + dump_anonymous_type_name (pp, field_type); + pp_string (pp, " is "); + dump_ada_enum_type (pp, field_type, NULL_TREE, spc); + pp_semicolon (pp); + newline_and_indent (pp, spc); break; case RECORD_TYPE: case UNION_TYPE: - dump_nested_types (buffer, field, spc); + dump_nested_types (pp, field, spc); - pp_string (buffer, "type "); + pp_string (pp, "type "); if (TYPE_NAME (field_type)) - dump_ada_node (buffer, field_type, NULL_TREE, spc, false, true); + dump_ada_node (pp, field_type, NULL_TREE, spc, false, true); else - dump_anonymous_type_name (buffer, field_type); + dump_anonymous_type_name (pp, field_type); if (TREE_CODE (field_type) == UNION_TYPE) - pp_string (buffer, " (discr : unsigned := 0)"); + pp_string (pp, " (discr : unsigned := 0)"); - pp_string (buffer, " is "); - dump_ada_structure (buffer, field_type, t, true, spc); - pp_semicolon (buffer); - newline_and_indent (buffer, spc); + pp_string (pp, " is "); + dump_ada_structure (pp, field_type, t, true, spc); + pp_semicolon (pp); + newline_and_indent (pp, spc); break; default: @@ -2831,39 +2852,39 @@ overloading_index (tree name) return h ? ++h->n : 0; } -/* Dump in BUFFER constructor spec corresponding to T for TYPE. */ +/* Dump in PP constructor spec corresponding to T for TYPE. */ static void -print_constructor (pretty_printer *buffer, tree t, tree type) +print_constructor (pretty_printer *pp, tree t, tree type) { tree decl_name = DECL_NAME (TYPE_NAME (type)); - pp_string (buffer, "New_"); - pp_ada_tree_identifier (buffer, decl_name, t, false); + pp_string (pp, "New_"); + pp_ada_tree_identifier (pp, decl_name, t, false); } -/* Dump in BUFFER destructor spec corresponding to T. */ +/* Dump in PP destructor spec corresponding to T. */ static void -print_destructor (pretty_printer *buffer, tree t, tree type) +print_destructor (pretty_printer *pp, tree t, tree type) { tree decl_name = DECL_NAME (TYPE_NAME (type)); - pp_string (buffer, "Delete_"); + pp_string (pp, "Delete_"); if (startswith (IDENTIFIER_POINTER (DECL_NAME (t)), "__dt_del")) - pp_string (buffer, "And_Free_"); - pp_ada_tree_identifier (buffer, decl_name, t, false); + pp_string (pp, "And_Free_"); + pp_ada_tree_identifier (pp, decl_name, t, false); } -/* Dump in BUFFER assignment operator spec corresponding to T. */ +/* Dump in PP assignment operator spec corresponding to T. */ static void -print_assignment_operator (pretty_printer *buffer, tree t, tree type) +print_assignment_operator (pretty_printer *pp, tree t, tree type) { tree decl_name = DECL_NAME (TYPE_NAME (type)); - pp_string (buffer, "Assign_"); - pp_ada_tree_identifier (buffer, decl_name, t, false); + pp_string (pp, "Assign_"); + pp_ada_tree_identifier (pp, decl_name, t, false); } /* Return the name of type T. */ @@ -2879,12 +2900,12 @@ type_name (tree t) return IDENTIFIER_POINTER (DECL_NAME (n)); } -/* Dump in BUFFER the declaration of object T of type TYPE in Ada syntax. +/* Dump in PP the declaration of object T of type TYPE in Ada syntax. SPC is the indentation level. Return 1 if a declaration was printed, 0 otherwise. */ static int -dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc) +dump_ada_declaration (pretty_printer *pp, tree t, tree type, int spc) { bool is_var = false; bool need_indent = false; @@ -2894,7 +2915,7 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc) tree orig = NULL_TREE; if (cpp_check && cpp_check (t, IS_TEMPLATE)) - return dump_ada_template (buffer, t, spc); + return dump_ada_template (pp, t, spc); /* Skip enumeral values: will be handled as part of the type itself. */ if (TREE_CODE (t) == CONST_DECL && TREE_CODE (TREE_TYPE (t)) == ENUMERAL_TYPE) @@ -2921,7 +2942,7 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc) if (RECORD_OR_UNION_TYPE_P (orig) && !TREE_VISITED (stub)) { INDENT (spc); - dump_forward_type (buffer, orig, t, 0); + dump_forward_type (pp, orig, t, 0); } TREE_VISITED (t) = 1; @@ -2931,14 +2952,14 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc) INDENT (spc); if (RECORD_OR_UNION_TYPE_P (orig) && !TREE_VISITED (stub)) - dump_forward_type (buffer, orig, t, spc); + dump_forward_type (pp, orig, t, spc); - pp_string (buffer, "subtype "); - dump_ada_node (buffer, t, type, spc, false, true); - pp_string (buffer, " is "); - dump_ada_node (buffer, orig, type, spc, false, true); - pp_string (buffer, "; -- "); - dump_sloc (buffer, t); + pp_string (pp, "subtype "); + dump_ada_node (pp, t, type, spc, false, true); + pp_string (pp, " is "); + dump_ada_node (pp, orig, type, spc, false, true); + pp_string (pp, "; -- "); + dump_sloc (pp, t); TREE_VISITED (t) = 1; return 1; @@ -2976,9 +2997,9 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc) case UNION_TYPE: if (!COMPLETE_TYPE_P (TREE_TYPE (t))) { - pp_string (buffer, "type "); - dump_ada_node (buffer, t, type, spc, false, true); - pp_string (buffer, " is null record; -- incomplete struct"); + pp_string (pp, "type "); + dump_ada_node (pp, t, type, spc, false, true); + pp_string (pp, " is null record; -- incomplete struct"); TREE_VISITED (t) = 1; return 1; } @@ -2987,63 +3008,63 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc) if (TYPE_PACKED (TREE_TYPE (t))) { warning_at (DECL_SOURCE_LOCATION (t), 0, "packed layout"); - pp_string (buffer, "pragma Compile_Time_Warning (True, "); - pp_string (buffer, "\"packed layout may be incorrect\");"); - newline_and_indent (buffer, spc); + pp_string (pp, "pragma Compile_Time_Warning (True, "); + pp_string (pp, "\"packed layout may be incorrect\");"); + newline_and_indent (pp, spc); packed_layout = true; } if (orig && TYPE_NAME (orig)) - pp_string (buffer, "subtype "); + pp_string (pp, "subtype "); else { if (separate_class_package (t)) { is_class = true; - pp_string (buffer, "package Class_"); - dump_ada_node (buffer, t, type, spc, false, true); - pp_string (buffer, " is"); + pp_string (pp, "package Class_"); + dump_ada_node (pp, t, type, spc, false, true); + pp_string (pp, " is"); spc += INDENT_INCR; - newline_and_indent (buffer, spc); + newline_and_indent (pp, spc); } - dump_nested_types (buffer, t, spc); + dump_nested_types (pp, t, spc); - pp_string (buffer, "type "); + pp_string (pp, "type "); } break; case POINTER_TYPE: case REFERENCE_TYPE: - dump_forward_type (buffer, TREE_TYPE (TREE_TYPE (t)), t, spc); + dump_forward_type (pp, TREE_TYPE (TREE_TYPE (t)), t, spc); if (orig && TYPE_NAME (orig)) - pp_string (buffer, "subtype "); + pp_string (pp, "subtype "); else - pp_string (buffer, "type "); + pp_string (pp, "type "); break; case ARRAY_TYPE: if ((orig && TYPE_NAME (orig)) || is_char_array (TREE_TYPE (t))) - pp_string (buffer, "subtype "); + pp_string (pp, "subtype "); else - pp_string (buffer, "type "); + pp_string (pp, "type "); break; case FUNCTION_TYPE: - pp_string (buffer, "-- skipped function type "); - dump_ada_node (buffer, t, type, spc, false, true); + pp_string (pp, "-- skipped function type "); + dump_ada_node (pp, t, type, spc, false, true); return 1; case ENUMERAL_TYPE: if ((orig && TYPE_NAME (orig) && orig != TREE_TYPE (t)) || !is_simple_enum (TREE_TYPE (t))) - pp_string (buffer, "subtype "); + pp_string (pp, "subtype "); else - pp_string (buffer, "type "); + pp_string (pp, "type "); break; default: - pp_string (buffer, "subtype "); + pp_string (pp, "subtype "); } TREE_VISITED (t) = 1; @@ -3065,34 +3086,34 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc) INDENT (spc); /* Print variable's name. */ - dump_ada_node (buffer, t, type, spc, false, true); + dump_ada_node (pp, t, type, spc, false, true); if (TREE_CODE (t) == TYPE_DECL) { - pp_string (buffer, " is "); + pp_string (pp, " is "); if (orig && TYPE_NAME (orig)) - dump_ada_node (buffer, TYPE_NAME (orig), type, spc, false, true); + dump_ada_node (pp, TYPE_NAME (orig), type, spc, false, true); else - dump_ada_array_type (buffer, TREE_TYPE (t), spc); + dump_ada_array_type (pp, TREE_TYPE (t), spc); } else { if (spc == INDENT_INCR || TREE_STATIC (t)) is_var = true; - pp_string (buffer, " : "); + pp_string (pp, " : "); if (TREE_CODE (TREE_TYPE (TREE_TYPE (t))) != POINTER_TYPE && !packed_layout) - pp_string (buffer, "aliased "); + pp_string (pp, "aliased "); if (TYPE_NAME (TREE_TYPE (t))) - dump_ada_node (buffer, TREE_TYPE (t), type, spc, false, true); + dump_ada_node (pp, TREE_TYPE (t), type, spc, false, true); else if (type) - dump_anonymous_type_name (buffer, TREE_TYPE (t)); + dump_anonymous_type_name (pp, TREE_TYPE (t)); else - dump_ada_array_type (buffer, TREE_TYPE (t), spc); + dump_ada_array_type (pp, TREE_TYPE (t), spc); } } else if (TREE_CODE (t) == FUNCTION_DECL) @@ -3149,36 +3170,36 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc) else if (!DECL_VINDEX (t) && *IDENTIFIER_POINTER (decl_name) == '_') { INDENT (spc); - pp_string (buffer, "-- skipped func "); - pp_string (buffer, IDENTIFIER_POINTER (decl_name)); + pp_string (pp, "-- skipped func "); + pp_string (pp, IDENTIFIER_POINTER (decl_name)); return 1; } INDENT (spc); - dump_forward_type (buffer, TREE_TYPE (t), t, spc); + dump_forward_type (pp, TREE_TYPE (t), t, spc); if (VOID_TYPE_P (TREE_TYPE (TREE_TYPE (t))) && !is_constructor) - pp_string (buffer, "procedure "); + pp_string (pp, "procedure "); else - pp_string (buffer, "function "); + pp_string (pp, "function "); if (is_constructor) - print_constructor (buffer, t, type); + print_constructor (pp, t, type); else if (is_destructor) - print_destructor (buffer, t, type); + print_destructor (pp, t, type); else if (is_assignment_operator) - print_assignment_operator (buffer, t, type); + print_assignment_operator (pp, t, type); else { const unsigned int suffix = overloading_index (decl_name); - pp_ada_tree_identifier (buffer, decl_name, t, false); + pp_ada_tree_identifier (pp, decl_name, t, false); if (suffix > 1) - pp_decimal_int (buffer, suffix); + pp_decimal_int (pp, suffix); } dump_ada_function_declaration - (buffer, t, is_method, is_constructor, is_destructor, spc); + (pp, t, is_method, is_constructor, is_destructor, spc); if (is_constructor && RECORD_OR_UNION_TYPE_P (type)) for (tree fld = TYPE_FIELDS (type); fld; fld = DECL_CHAIN (fld)) @@ -3189,34 +3210,34 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc) } if (is_abstract || is_abstract_class) - pp_string (buffer, " is abstract"); + pp_string (pp, " is abstract"); if (is_abstract || !DECL_ASSEMBLER_NAME (t)) { - pp_semicolon (buffer); - pp_string (buffer, " -- "); - dump_sloc (buffer, t); + pp_semicolon (pp); + pp_string (pp, " -- "); + dump_sloc (pp, t); } else if (is_constructor) { - pp_semicolon (buffer); - pp_string (buffer, " -- "); - dump_sloc (buffer, t); - - newline_and_indent (buffer, spc); - pp_string (buffer, "pragma CPP_Constructor ("); - print_constructor (buffer, t, type); - pp_string (buffer, ", \""); - pp_asm_name (buffer, t); - pp_string (buffer, "\");"); + pp_semicolon (pp); + pp_string (pp, " -- "); + dump_sloc (pp, t); + + newline_and_indent (pp, spc); + pp_string (pp, "pragma CPP_Constructor ("); + print_constructor (pp, t, type); + pp_string (pp, ", \""); + pp_asm_name (pp, t); + pp_string (pp, "\");"); } else { - pp_string (buffer, " -- "); - dump_sloc (buffer, t); + pp_string (pp, " -- "); + dump_sloc (pp, t); - newline_and_indent (buffer, spc); - dump_ada_import (buffer, t, spc); + newline_and_indent (pp, spc); + dump_ada_import (pp, t, spc); } return 1; @@ -3227,12 +3248,12 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc) bool is_abstract_record = false; /* Anonymous structs/unions. */ - dump_ada_node (buffer, TREE_TYPE (t), t, spc, false, true); + dump_ada_node (pp, TREE_TYPE (t), t, spc, false, true); if (TREE_CODE (TREE_TYPE (t)) == UNION_TYPE) - pp_string (buffer, " (discr : unsigned := 0)"); + pp_string (pp, " (discr : unsigned := 0)"); - pp_string (buffer, " is "); + pp_string (pp, " is "); /* Check whether we have an Ada interface compatible class. That is only have a vtable non-static data member and no @@ -3269,20 +3290,20 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc) TREE_VISITED (t) = 1; if (is_interface) { - pp_string (buffer, "limited interface -- "); - dump_sloc (buffer, t); - newline_and_indent (buffer, spc); - pp_string (buffer, "with Import => True,"); - newline_and_indent (buffer, spc + 5); - pp_string (buffer, "Convention => CPP"); - - dump_ada_methods (buffer, TREE_TYPE (t), spc); + pp_string (pp, "limited interface -- "); + dump_sloc (pp, t); + newline_and_indent (pp, spc); + pp_string (pp, "with Import => True,"); + newline_and_indent (pp, spc + 5); + pp_string (pp, "Convention => CPP"); + + dump_ada_methods (pp, TREE_TYPE (t), spc); } else { if (is_abstract_record) - pp_string (buffer, "abstract "); - dump_ada_node (buffer, t, t, spc, false, false); + pp_string (pp, "abstract "); + dump_ada_node (pp, t, t, spc, false, false); } } else @@ -3292,84 +3313,84 @@ dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc) if ((TREE_CODE (t) == FIELD_DECL || VAR_P (t)) && DECL_NAME (t)) - check_type_name_conflict (buffer, t); + check_type_name_conflict (pp, t); /* Print variable/type's name. */ - dump_ada_node (buffer, t, t, spc, false, true); + dump_ada_node (pp, t, t, spc, false, true); if (TREE_CODE (t) == TYPE_DECL) { const bool is_subtype = TYPE_NAME (orig); if (!is_subtype && TREE_CODE (TREE_TYPE (t)) == UNION_TYPE) - pp_string (buffer, " (discr : unsigned := 0)"); + pp_string (pp, " (discr : unsigned := 0)"); - pp_string (buffer, " is "); + pp_string (pp, " is "); - dump_ada_node (buffer, orig, t, spc, false, is_subtype); + dump_ada_node (pp, orig, t, spc, false, is_subtype); } else { if (spc == INDENT_INCR || TREE_STATIC (t)) is_var = true; - pp_string (buffer, " : "); + pp_string (pp, " : "); if (TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE && (TYPE_NAME (TREE_TYPE (t)) || (TREE_CODE (TREE_TYPE (t)) != INTEGER_TYPE && TREE_CODE (TREE_TYPE (t)) != ENUMERAL_TYPE)) && !packed_layout) - pp_string (buffer, "aliased "); + pp_string (pp, "aliased "); if (TREE_READONLY (t) && TREE_CODE (t) != FIELD_DECL) - pp_string (buffer, "constant "); + pp_string (pp, "constant "); if (TYPE_NAME (TREE_TYPE (t)) || (!RECORD_OR_UNION_TYPE_P (TREE_TYPE (t)) && TREE_CODE (TREE_TYPE (t)) != ENUMERAL_TYPE)) - dump_ada_node (buffer, TREE_TYPE (t), t, spc, false, true); + dump_ada_node (pp, TREE_TYPE (t), t, spc, false, true); else if (type) - dump_anonymous_type_name (buffer, TREE_TYPE (t)); + dump_anonymous_type_name (pp, TREE_TYPE (t)); } } if (is_class) { spc -= INDENT_INCR; - newline_and_indent (buffer, spc); - pp_string (buffer, "end;"); - newline_and_indent (buffer, spc); - pp_string (buffer, "use Class_"); - dump_ada_node (buffer, t, type, spc, false, true); - pp_semicolon (buffer); - pp_newline (buffer); + newline_and_indent (pp, spc); + pp_string (pp, "end;"); + newline_and_indent (pp, spc); + pp_string (pp, "use Class_"); + dump_ada_node (pp, t, type, spc, false, true); + pp_semicolon (pp); + pp_newline (pp); /* All needed indentation/newline performed already, so return 0. */ return 0; } else if (is_var) { - pp_string (buffer, " -- "); - dump_sloc (buffer, t); - newline_and_indent (buffer, spc); - dump_ada_import (buffer, t, spc); + pp_string (pp, " -- "); + dump_sloc (pp, t); + newline_and_indent (pp, spc); + dump_ada_import (pp, t, spc); } else { - pp_string (buffer, "; -- "); - dump_sloc (buffer, t); + pp_string (pp, "; -- "); + dump_sloc (pp, t); } return 1; } -/* Dump in BUFFER a structure NODE of type TYPE in Ada syntax. If NESTED is +/* Dump in PP a structure NODE of type TYPE in Ada syntax. If NESTED is true, it's an anonymous nested type. SPC is the indentation level. */ static void -dump_ada_structure (pretty_printer *buffer, tree node, tree type, bool nested, +dump_ada_structure (pretty_printer *pp, tree node, tree type, bool nested, int spc) { const bool is_union = (TREE_CODE (node) == UNION_TYPE); @@ -3381,16 +3402,16 @@ dump_ada_structure (pretty_printer *buffer, tree node, tree type, bool nested, bitfield_used = false; /* Print the contents of the structure. */ - pp_string (buffer, "record"); + pp_string (pp, "record"); if (is_union) { - newline_and_indent (buffer, spc + INDENT_INCR); - pp_string (buffer, "case discr is"); + newline_and_indent (pp, spc + INDENT_INCR); + pp_string (pp, "case discr is"); field_spc = spc + INDENT_INCR * 3; } - pp_newline (buffer); + pp_newline (pp); /* Print the non-static fields of the structure. */ for (tree tmp = TYPE_FIELDS (node); tmp; tmp = TREE_CHAIN (tmp)) @@ -3401,24 +3422,24 @@ dump_ada_structure (pretty_printer *buffer, tree node, tree type, bool nested, if (!is_tagged_type (TREE_TYPE (tmp))) { if (!TYPE_NAME (TREE_TYPE (tmp))) - dump_ada_declaration (buffer, tmp, type, field_spc); + dump_ada_declaration (pp, tmp, type, field_spc); else { INDENT (field_spc); if (field_num == 0) - pp_string (buffer, "parent : aliased "); + pp_string (pp, "parent : aliased "); else { sprintf (buf, "field_%d : aliased ", field_num + 1); - pp_string (buffer, buf); + pp_string (pp, buf); } - dump_ada_decl_name (buffer, TYPE_NAME (TREE_TYPE (tmp)), + dump_ada_decl_name (pp, TYPE_NAME (TREE_TYPE (tmp)), false); - pp_semicolon (buffer); + pp_semicolon (pp); } - pp_newline (buffer); + pp_newline (pp); field_num++; } } @@ -3437,13 +3458,13 @@ dump_ada_structure (pretty_printer *buffer, tree node, tree type, bool nested, sprintf (buf, "when others =>"); INDENT (spc + INDENT_INCR * 2); - pp_string (buffer, buf); - pp_newline (buffer); + pp_string (pp, buf); + pp_newline (pp); } - if (dump_ada_declaration (buffer, tmp, type, field_spc)) + if (dump_ada_declaration (pp, tmp, type, field_spc)) { - pp_newline (buffer); + pp_newline (pp); field_num++; } } @@ -3453,49 +3474,49 @@ dump_ada_structure (pretty_printer *buffer, tree node, tree type, bool nested, if (is_union) { INDENT (spc + INDENT_INCR); - pp_string (buffer, "end case;"); - pp_newline (buffer); + pp_string (pp, "end case;"); + pp_newline (pp); } if (field_num == 0) { INDENT (spc + INDENT_INCR); - pp_string (buffer, "null;"); - pp_newline (buffer); + pp_string (pp, "null;"); + pp_newline (pp); } INDENT (spc); - pp_string (buffer, "end record"); + pp_string (pp, "end record"); - newline_and_indent (buffer, spc); + newline_and_indent (pp, spc); /* We disregard the methods for anonymous nested types. */ if (has_nontrivial_methods (node) && !nested) { - pp_string (buffer, "with Import => True,"); - newline_and_indent (buffer, spc + 5); - pp_string (buffer, "Convention => CPP"); + pp_string (pp, "with Import => True,"); + newline_and_indent (pp, spc + 5); + pp_string (pp, "Convention => CPP"); } else - pp_string (buffer, "with Convention => C_Pass_By_Copy"); + pp_string (pp, "with Convention => C_Pass_By_Copy"); if (is_union) { - pp_comma (buffer); - newline_and_indent (buffer, spc + 5); - pp_string (buffer, "Unchecked_Union => True"); + pp_comma (pp); + newline_and_indent (pp, spc + 5); + pp_string (pp, "Unchecked_Union => True"); } if (bitfield_used || packed_layout) { char buf[32]; - pp_comma (buffer); - newline_and_indent (buffer, spc + 5); - pp_string (buffer, "Pack => True"); - pp_comma (buffer); - newline_and_indent (buffer, spc + 5); + pp_comma (pp); + newline_and_indent (pp, spc + 5); + pp_string (pp, "Pack => True"); + pp_comma (pp); + newline_and_indent (pp, spc + 5); sprintf (buf, "Alignment => %d", TYPE_ALIGN (node) / BITS_PER_UNIT); - pp_string (buffer, buf); + pp_string (pp, buf); bitfield_used = false; packed_layout = false; } @@ -3503,7 +3524,7 @@ dump_ada_structure (pretty_printer *buffer, tree node, tree type, bool nested, if (nested) return; - need_semicolon = !dump_ada_methods (buffer, node, spc); + need_semicolon = !dump_ada_methods (pp, node, spc); /* Print the static fields of the structure, if any. */ for (tree tmp = TYPE_FIELDS (node); tmp; tmp = TREE_CHAIN (tmp)) @@ -3513,11 +3534,11 @@ dump_ada_structure (pretty_printer *buffer, tree node, tree type, bool nested, if (need_semicolon) { need_semicolon = false; - pp_semicolon (buffer); + pp_semicolon (pp); } - pp_newline (buffer); - pp_newline (buffer); - dump_ada_declaration (buffer, tmp, type, spc); + pp_newline (pp); + pp_newline (pp); + dump_ada_declaration (pp, tmp, type, spc); } } } @@ -3556,7 +3577,7 @@ dump_ads (const char *source_file, pretty_printer pp; pp_needs_newline (&pp) = true; - pp.buffer->stream = f; + pp.set_output_stream (f); /* Dump all relevant macros. */ dump_ada_macros (&pp, source_file); diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc index 0341c44a2cd99..7d752acd430c4 100644 --- a/gcc/c-family/c-common.cc +++ b/gcc/c-family/c-common.cc @@ -216,18 +216,22 @@ int flag_cond_mismatch; int flag_isoc94; -/* Nonzero means use the ISO C99 (or C11) dialect of C. */ +/* Nonzero means use the ISO C99 (or later) dialect of C. */ int flag_isoc99; -/* Nonzero means use the ISO C11 dialect of C. */ +/* Nonzero means use the ISO C11 (or later) dialect of C. */ int flag_isoc11; -/* Nonzero means use the ISO C23 dialect of C. */ +/* Nonzero means use the ISO C23 (or later) dialect of C. */ int flag_isoc23; +/* Nonzero means use the ISO C2Y (or later) dialect of C. */ + +int flag_isoc2y; + /* Nonzero means that we have builtin functions, and main is an int. */ int flag_hosted = 1; @@ -3968,7 +3972,9 @@ c_sizeof_or_alignof_type (location_t loc, value = size_one_node; } else if (!COMPLETE_TYPE_P (type) - && (!c_dialect_cxx () || is_sizeof || type_code != ARRAY_TYPE)) + && ((!c_dialect_cxx () && !flag_isoc2y) + || is_sizeof + || type_code != ARRAY_TYPE)) { if (complain) error_at (loc, "invalid application of %qs to incomplete type %qT", diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index ae79912c89f66..48c89b603bcdc 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -531,7 +531,7 @@ extern GTY(()) tree c_global_trees[CTI_MAX]; enum c_language_kind { - clk_c = 0, /* C90, C94, C99, C11 or C23 */ + clk_c = 0, /* C without ObjC features. */ clk_objc = 1, /* clk_c with ObjC features. */ clk_cxx = 2, /* ANSI/ISO C++ */ clk_objcxx = 3 /* clk_cxx with ObjC features. */ @@ -676,10 +676,14 @@ extern int flag_isoc99; extern int flag_isoc11; -/* Nonzero means use the ISO C23 dialect of C. */ +/* Nonzero means use the ISO C23 (or later) dialect of C. */ extern int flag_isoc23; +/* Nonzero means use the ISO C2Y (or later) dialect of C. */ + +extern int flag_isoc2y; + /* Nonzero means that we have builtin functions, and main is an int. */ extern int flag_hosted; diff --git a/gcc/c-family/c-cppbuiltin.cc b/gcc/c-family/c-cppbuiltin.cc index d9b84a0f1b97f..dfd8f6f0c4855 100644 --- a/gcc/c-family/c-cppbuiltin.cc +++ b/gcc/c-family/c-cppbuiltin.cc @@ -954,7 +954,10 @@ c_cpp_builtins (cpp_reader *pfile) } if (cxx_dialect >= cxx11) - cpp_define (pfile, "__GXX_EXPERIMENTAL_CXX0X__"); + { + cpp_define (pfile, "__GXX_EXPERIMENTAL_CXX0X__"); + cpp_define (pfile, "__GXX_CONSTEXPR_ASM__"); + } /* Binary literals have been allowed in g++ before C++11 and were standardized for C++14. */ diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc index be3058dca6372..33114f13c8dbd 100644 --- a/gcc/c-family/c-opts.cc +++ b/gcc/c-family/c-opts.cc @@ -32,7 +32,7 @@ along with GCC; see the file COPYING3. If not see #include "flags.h" #include "toplev.h" #include "langhooks.h" -#include "tree-diagnostic.h" /* for virt_loc_aware_diagnostic_finalizer */ +#include "diagnostic-macro-unwinding.h" /* for virt_loc_aware_diagnostic_finalizer */ #include "intl.h" #include "cppdefault.h" #include "incpath.h" @@ -121,6 +121,7 @@ static void set_std_c99 (int); static void set_std_c11 (int); static void set_std_c17 (int); static void set_std_c23 (int); +static void set_std_c2y (int); static void check_deps_environment_vars (void); static void handle_deferred_opts (void); static void sanitize_cpp_opts (void); @@ -743,6 +744,16 @@ c_common_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value, set_std_c23 (false /* ISO */); break; + case OPT_std_c2y: + if (!preprocessing_asm_p) + set_std_c2y (true /* ISO */); + break; + + case OPT_std_gnu2y: + if (!preprocessing_asm_p) + set_std_c2y (false /* ISO */); + break; + case OPT_trigraphs: cpp_opts->trigraphs = 1; break; @@ -1782,6 +1793,7 @@ set_std_c89 (int c94, int iso) flag_isoc99 = 0; flag_isoc11 = 0; flag_isoc23 = 0; + flag_isoc2y = 0; lang_hooks.name = "GNU C89"; } @@ -1793,6 +1805,7 @@ set_std_c99 (int iso) flag_no_asm = iso; flag_no_nonansi_builtin = iso; flag_iso = iso; + flag_isoc2y = 0; flag_isoc23 = 0; flag_isoc11 = 0; flag_isoc99 = 1; @@ -1808,6 +1821,7 @@ set_std_c11 (int iso) flag_no_asm = iso; flag_no_nonansi_builtin = iso; flag_iso = iso; + flag_isoc2y = 0; flag_isoc23 = 0; flag_isoc11 = 1; flag_isoc99 = 1; @@ -1823,6 +1837,7 @@ set_std_c17 (int iso) flag_no_asm = iso; flag_no_nonansi_builtin = iso; flag_iso = iso; + flag_isoc2y = 0; flag_isoc23 = 0; flag_isoc11 = 1; flag_isoc99 = 1; @@ -1830,7 +1845,7 @@ set_std_c17 (int iso) lang_hooks.name = "GNU C17"; } -/* Set the C 2X standard (without GNU extensions if ISO). */ +/* Set the C 23 standard (without GNU extensions if ISO). */ static void set_std_c23 (int iso) { @@ -1838,6 +1853,7 @@ set_std_c23 (int iso) flag_no_asm = iso; flag_no_nonansi_builtin = iso; flag_iso = iso; + flag_isoc2y = 0; flag_isoc23 = 1; flag_isoc11 = 1; flag_isoc99 = 1; @@ -1845,6 +1861,22 @@ set_std_c23 (int iso) lang_hooks.name = "GNU C23"; } +/* Set the C 2Y standard (without GNU extensions if ISO). */ +static void +set_std_c2y (int iso) +{ + cpp_set_lang (parse_in, iso ? CLK_STDC23: CLK_GNUC23); + flag_no_asm = iso; + flag_no_nonansi_builtin = iso; + flag_iso = iso; + flag_isoc2y = 1; + flag_isoc23 = 1; + flag_isoc11 = 1; + flag_isoc99 = 1; + flag_isoc94 = 1; + lang_hooks.name = "GNU C2Y"; +} + /* Set the C++ 98 standard (without GNU extensions if ISO). */ static void diff --git a/gcc/c-family/c-pretty-print.cc b/gcc/c-family/c-pretty-print.cc index da7934d783a5c..dd7eba1239437 100644 --- a/gcc/c-family/c-pretty-print.cc +++ b/gcc/c-family/c-pretty-print.cc @@ -47,7 +47,7 @@ along with GCC; see the file COPYING3. If not see #define pp_c_maybe_whitespace(PP) \ do { \ - if ((PP)->padding == pp_before) \ + if ((PP)->get_padding () == pp_before) \ pp_c_whitespace (PP); \ } while (0) @@ -76,98 +76,98 @@ void pp_c_whitespace (c_pretty_printer *pp) { pp_space (pp); - pp->padding = pp_none; + pp->set_padding (pp_none); } void pp_c_left_paren (c_pretty_printer *pp) { pp_left_paren (pp); - pp->padding = pp_none; + pp->set_padding (pp_none); } void pp_c_right_paren (c_pretty_printer *pp) { pp_right_paren (pp); - pp->padding = pp_none; + pp->set_padding (pp_none); } void pp_c_left_brace (c_pretty_printer *pp) { pp_left_brace (pp); - pp->padding = pp_none; + pp->set_padding (pp_none); } void pp_c_right_brace (c_pretty_printer *pp) { pp_right_brace (pp); - pp->padding = pp_none; + pp->set_padding (pp_none); } void pp_c_left_bracket (c_pretty_printer *pp) { pp_left_bracket (pp); - pp->padding = pp_none; + pp->set_padding (pp_none); } void pp_c_right_bracket (c_pretty_printer *pp) { pp_right_bracket (pp); - pp->padding = pp_none; + pp->set_padding (pp_none); } void pp_c_dot (c_pretty_printer *pp) { pp_dot (pp); - pp->padding = pp_none; + pp->set_padding (pp_none); } void pp_c_ampersand (c_pretty_printer *pp) { pp_ampersand (pp); - pp->padding = pp_none; + pp->set_padding (pp_none); } void pp_c_star (c_pretty_printer *pp) { pp_star (pp); - pp->padding = pp_none; + pp->set_padding (pp_none); } void pp_c_arrow (c_pretty_printer *pp) { pp_arrow (pp); - pp->padding = pp_none; + pp->set_padding (pp_none); } void pp_c_semicolon (c_pretty_printer *pp) { pp_semicolon (pp); - pp->padding = pp_none; + pp->set_padding (pp_none); } void pp_c_complement (c_pretty_printer *pp) { pp_complement (pp); - pp->padding = pp_none; + pp->set_padding (pp_none); } void pp_c_exclamation (c_pretty_printer *pp) { pp_exclamation (pp); - pp->padding = pp_none; + pp->set_padding (pp_none); } /* Print out the external representation of QUALIFIERS. */ @@ -1307,7 +1307,7 @@ pp_c_ws_string (c_pretty_printer *pp, const char *str) { pp_c_maybe_whitespace (pp); pp_string (pp, str); - pp->padding = pp_before; + pp->set_padding (pp_before); } void @@ -1328,7 +1328,7 @@ pp_c_identifier (c_pretty_printer *pp, const char *id) { pp_c_maybe_whitespace (pp); pp_identifier (pp, id); - pp->padding = pp_before; + pp->set_padding (pp_before); } /* Pretty-print a C primary-expression. @@ -2985,7 +2985,7 @@ print_c_tree (FILE *file, tree t) c_pretty_printer pp; pp_needs_newline (&pp) = true; - pp.buffer->stream = file; + pp.set_output_stream (file); pp.statement (t); pp_newline_and_flush (&pp); } diff --git a/gcc/c-family/c-warn.cc b/gcc/c-family/c-warn.cc index 7ddf6ea2ad8e8..5e4fb7f0f0a94 100644 --- a/gcc/c-family/c-warn.cc +++ b/gcc/c-family/c-warn.cc @@ -3832,11 +3832,16 @@ do_warn_array_compare (location_t location, tree_code code, tree op0, tree op1) /* C doesn't allow +arr. */ if (c_dialect_cxx ()) inform (location, "use unary %<+%> which decays operands to pointers " - "or %<&%D[0] %s &%D[0]%> to compare the addresses", - op0, op_symbol_code (code), op1); + "or %<&%s%E%s[0] %s &%s%E%s[0]%> to compare the addresses", + DECL_P (op0) ? "" : "(", op0, DECL_P (op0) ? "" : ")", + op_symbol_code (code), + DECL_P (op1) ? "" : "(", op1, DECL_P (op1) ? "" : ")"); else - inform (location, "use %<&%D[0] %s &%D[0]%> to compare the addresses", - op0, op_symbol_code (code), op1); + inform (location, + "use %<&%s%E%s[0] %s &%s%E%s[0]%> to compare the addresses", + DECL_P (op0) ? "" : "(", op0, DECL_P (op0) ? "" : ")", + op_symbol_code (code), + DECL_P (op1) ? "" : "(", op1, DECL_P (op1) ? "" : ")"); } } diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index fb34c3b703196..b067369fa7ea3 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -441,6 +441,10 @@ Wc11-c2x-compat C ObjC Alias(Wc11-c23-compat) Deprecated in favor of -Wc11-c23-compat. +Wc23-c2y-compat +C ObjC Var(warn_c23_c2y_compat) Init(-1) Warning +Warn about features not present in ISO C23, but present in ISO C2Y. + Wc90-c99-compat C ObjC CPP(cpp_warn_c90_c99_compat) CppReason(CPP_W_C90_C99_COMPAT) Var(warn_c90_c99_compat) Init(-1) Warning Warn about features not present in ISO C90, but present in ISO C99. @@ -2515,6 +2519,10 @@ std=c2x C ObjC Alias(std=c23) Deprecated in favor of -std=c23. +std=c2y +C ObjC +Conform to the ISO 202Y C standard draft (experimental and incomplete support). + std=c89 C ObjC Alias(std=c90) Conform to the ISO 1990 C standard. @@ -2613,6 +2621,10 @@ std=gnu2x C ObjC Alias(std=gnu23) Deprecated in favor of -std=gnu23. +std=gnu2y +C ObjC +Conform to the ISO 202Y C standard draft with GNU extensions (experimental and incomplete support). + std=gnu89 C ObjC Alias(std=gnu90) Conform to the ISO 1990 C standard with GNU extensions. diff --git a/gcc/c-family/c.opt.urls b/gcc/c-family/c.opt.urls index dd455d7c0dc7c..31d9ffef578f9 100644 --- a/gcc/c-family/c.opt.urls +++ b/gcc/c-family/c.opt.urls @@ -160,6 +160,9 @@ UrlSuffix(gcc/Warning-Options.html#index-Wbuiltin-macro-redefined) Wc11-c23-compat UrlSuffix(gcc/Warning-Options.html#index-Wc11-c23-compat) +Wc23-c2y-compat +UrlSuffix(gcc/Warning-Options.html#index-Wc23-c2y-compat) + Wc90-c99-compat UrlSuffix(gcc/Warning-Options.html#index-Wc90-c99-compat) diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index c91f4927dd987..2835c2be5f1b0 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,32 @@ +2024-06-18 Martin Uecker + + PR c/115109 + * c-decl.cc (build_enumerator): When redeclaring an + enumerator convert value to previous type. For redeclared + enumerators use underlying type for computing the next value. + +2024-06-13 Joseph Myers + + * c-typeck.cc (build_unary_op): Use pedwarn_c23 for complex + increment and decrement. + +2024-06-12 David Malcolm + + * c-objc-common.cc (print_type): Update for fields of + pretty_printer becoming private. + (c_tree_printer): Likewise. + +2024-06-11 Joseph Myers + + * c-errors.cc (pedwarn_c23): New. + * c-parser.cc (disable_extension_diagnostics) + (restore_extension_diagnostics): Save and restore + warn_c23_c2y_compat. + (c_parser_generic_selection): Handle type name as controlling + operand. Allow incomplete and function types subject to + pedwarn_c23 calls. + * c-tree.h (pedwarn_c23): New. + 2024-06-06 Jakub Jelinek PR c/114493 diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc index 6c09eb731284d..01326570e2b21 100644 --- a/gcc/c/c-decl.cc +++ b/gcc/c/c-decl.cc @@ -10277,6 +10277,7 @@ build_enumerator (location_t decl_loc, location_t loc, struct c_enum_contents *the_enum, tree name, tree value) { tree decl; + tree old_decl; /* Validate and default VALUE. */ @@ -10336,6 +10337,23 @@ build_enumerator (location_t decl_loc, location_t loc, definition. */ value = convert (the_enum->enum_type, value); } + else if (flag_isoc23 + && (old_decl = lookup_name_in_scope (name, current_scope)) + && old_decl != error_mark_node + && TREE_TYPE (old_decl) + && TREE_TYPE (TREE_TYPE (old_decl)) + && TREE_CODE (old_decl) == CONST_DECL) + { + /* Enumeration constants in a redeclaration have the previous type. */ + tree previous_type = TREE_TYPE (DECL_INITIAL (old_decl)); + if (!int_fits_type_p (value, previous_type)) + { + error_at (loc, "value of redeclared enumerator outside the range " + "of %qT", previous_type); + locate_old_decl (old_decl); + } + value = convert (previous_type, value); + } else { /* Even though the underlying type of an enum is unspecified, the @@ -10402,9 +10420,14 @@ build_enumerator (location_t decl_loc, location_t loc, false); } else - the_enum->enum_next_value - = build_binary_op (EXPR_LOC_OR_LOC (value, input_location), - PLUS_EXPR, value, integer_one_node, false); + { + /* In a redeclaration the type can already be the enumeral type. */ + if (TREE_CODE (TREE_TYPE (value)) == ENUMERAL_TYPE) + value = convert (ENUM_UNDERLYING_TYPE (TREE_TYPE (value)), value); + the_enum->enum_next_value + = build_binary_op (EXPR_LOC_OR_LOC (value, input_location), + PLUS_EXPR, value, integer_one_node, false); + } the_enum->enum_overflow = tree_int_cst_lt (the_enum->enum_next_value, value); if (the_enum->enum_overflow && !ENUM_FIXED_UNDERLYING_TYPE_P (the_enum->enum_type)) diff --git a/gcc/c/c-errors.cc b/gcc/c/c-errors.cc index 7aa5e0db34e37..f36e7f9780a3f 100644 --- a/gcc/c/c-errors.cc +++ b/gcc/c/c-errors.cc @@ -25,6 +25,45 @@ along with GCC; see the file COPYING3. If not see #include "c-tree.h" #include "opts.h" +/* Issue an ISO C23 pedantic warning MSGID if -pedantic outside C2Y mode, + otherwise issue warning MSGID if -Wc23-c2y-compat is specified. + This function is supposed to be used for matters that are allowed in + ISO C2Y but not supported in ISO C23, thus we explicitly don't pedwarn + when C2Y is specified. */ + +bool +pedwarn_c23 (location_t location, int opt, const char *gmsgid, ...) +{ + diagnostic_info diagnostic; + va_list ap; + bool warned = false; + rich_location richloc (line_table, location); + + va_start (ap, gmsgid); + /* If desired, issue the C23/C2Y compat warning, which is more specific + than -pedantic. */ + if (warn_c23_c2y_compat > 0) + { + diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc, + (pedantic && !flag_isoc2y) + ? DK_PEDWARN : DK_WARNING); + diagnostic.option_index = OPT_Wc23_c2y_compat; + warned = diagnostic_report_diagnostic (global_dc, &diagnostic); + } + /* -Wno-c23-c2y-compat suppresses even the pedwarns. */ + else if (warn_c23_c2y_compat == 0) + ; + /* For -pedantic outside C2Y, issue a pedwarn. */ + else if (pedantic && !flag_isoc2y) + { + diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc, DK_PEDWARN); + diagnostic.option_index = opt; + warned = diagnostic_report_diagnostic (global_dc, &diagnostic); + } + va_end (ap); + return warned; +} + /* Issue an ISO C11 pedantic warning MSGID if -pedantic outside C23 mode, otherwise issue warning MSGID if -Wc11-c23-compat is specified. This function is supposed to be used for matters that are allowed in diff --git a/gcc/c/c-objc-common.cc b/gcc/c/c-objc-common.cc index 738e899a2a93a..1025e0e1c7b94 100644 --- a/gcc/c/c-objc-common.cc +++ b/gcc/c/c-objc-common.cc @@ -252,7 +252,7 @@ print_type (c_pretty_printer *cpp, tree t, bool *quoted) c_pretty_printer cpp2; /* Print the stripped version into a temporary printer. */ cpp2.type_id (aka_type); - struct obstack *ob2 = cpp2.buffer->obstack; + struct obstack *ob2 = pp_buffer (&cpp2)->obstack; /* Get the stripped version from the temporary printer. */ const char *aka = (char *) obstack_base (ob2); int aka_len = obstack_object_size (ob2); @@ -301,7 +301,7 @@ c_tree_printer (pretty_printer *pp, text_info *text, const char *spec, tree t = NULL_TREE; // FIXME: the next cast should be a dynamic_cast, when it is permitted. c_pretty_printer *cpp = (c_pretty_printer *) pp; - pp->padding = pp_none; + pp->set_padding (pp_none); if (precision != 0 || wide) return false; diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index 0c5018134ccd3..e83e9c683f757 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -1534,6 +1534,9 @@ disable_extension_diagnostics (void) /* Similarly for warn_c11_c23_compat. */ | ((warn_c11_c23_compat == 1) << 11) | ((warn_c11_c23_compat == -1) << 12) + /* Similarly for warn_c23_c2y_compat. */ + | ((warn_c23_c2y_compat == 1) << 13) + | ((warn_c23_c2y_compat == -1) << 14) ); cpp_opts->cpp_pedantic = pedantic = 0; warn_pointer_arith = 0; @@ -1545,6 +1548,7 @@ disable_extension_diagnostics (void) warn_c90_c99_compat = 0; warn_c99_c11_compat = 0; warn_c11_c23_compat = 0; + warn_c23_c2y_compat = 0; return ret; } @@ -1565,6 +1569,7 @@ restore_extension_diagnostics (int flags) warn_c90_c99_compat = (flags >> 7) & 1 ? 1 : ((flags >> 8) & 1 ? -1 : 0); warn_c99_c11_compat = (flags >> 9) & 1 ? 1 : ((flags >> 10) & 1 ? -1 : 0); warn_c11_c23_compat = (flags >> 11) & 1 ? 1 : ((flags >> 12) & 1 ? -1 : 0); + warn_c23_c2y_compat = (flags >> 13) & 1 ? 1 : ((flags >> 14) & 1 ? -1 : 0); } /* Helper data structure for parsing #pragma acc routine. */ @@ -10273,8 +10278,14 @@ struct c_generic_association /* Parse a generic-selection. (C11 6.5.1.1). generic-selection: - _Generic ( assignment-expression , generic-assoc-list ) - + _Generic ( generic-controlling-operand , generic-assoc-list ) + + generic-controlling-operand: + assignment-expression + type-name + + (The use of a type-name is new in C2Y.) + generic-assoc-list: generic-association generic-assoc-list , generic-association @@ -10314,30 +10325,43 @@ c_parser_generic_selection (c_parser *parser) if (!parens.require_open (parser)) return error_expr; - c_inhibit_evaluation_warnings++; selector_loc = c_parser_peek_token (parser)->location; - selector = c_parser_expr_no_commas (parser, NULL); - selector = default_function_array_conversion (selector_loc, selector); - c_inhibit_evaluation_warnings--; - - if (selector.value == error_mark_node) + if (c_parser_next_tokens_start_typename (parser, cla_prefer_id)) { - c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL); - return selector; - } - mark_exp_read (selector.value); - selector_type = TREE_TYPE (selector.value); - /* In ISO C terms, rvalues (including the controlling expression of - _Generic) do not have qualified types. */ - if (TREE_CODE (selector_type) != ARRAY_TYPE) - selector_type = TYPE_MAIN_VARIANT (selector_type); - /* In ISO C terms, _Noreturn is not part of the type of expressions - such as &abort, but in GCC it is represented internally as a type - qualifier. */ - if (FUNCTION_POINTER_TYPE_P (selector_type) - && TYPE_QUALS (TREE_TYPE (selector_type)) != TYPE_UNQUALIFIED) - selector_type - = build_pointer_type (TYPE_MAIN_VARIANT (TREE_TYPE (selector_type))); + c_inhibit_evaluation_warnings++; + pedwarn_c23 (selector_loc, OPT_Wpedantic, + "ISO C does not support use of type name as %<_Generic%> " + "controlling operand before C2Y"); + struct c_type_name *type = c_parser_type_name (parser); + selector_type = groktypename (type, NULL, NULL); + c_inhibit_evaluation_warnings--; + } + else + { + c_inhibit_evaluation_warnings++; + selector = c_parser_expr_no_commas (parser, NULL); + selector = default_function_array_conversion (selector_loc, selector); + c_inhibit_evaluation_warnings--; + + if (selector.value == error_mark_node) + { + c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL); + return selector; + } + mark_exp_read (selector.value); + selector_type = TREE_TYPE (selector.value); + /* In ISO C terms, rvalues (including the controlling expression + of _Generic) do not have qualified types. */ + if (TREE_CODE (selector_type) != ARRAY_TYPE) + selector_type = TYPE_MAIN_VARIANT (selector_type); + /* In ISO C terms, _Noreturn is not part of the type of expressions + such as &abort, but in GCC it is represented internally as a type + qualifier. */ + if (FUNCTION_POINTER_TYPE_P (selector_type) + && TYPE_QUALS (TREE_TYPE (selector_type)) != TYPE_UNQUALIFIED) + selector_type + = build_pointer_type (TYPE_MAIN_VARIANT (TREE_TYPE (selector_type))); + } if (!c_parser_require (parser, CPP_COMMA, "expected %<,%>")) { @@ -10376,11 +10400,13 @@ c_parser_generic_selection (c_parser *parser) } if (TREE_CODE (assoc.type) == FUNCTION_TYPE) - error_at (assoc.type_location, - "%<_Generic%> association has function type"); + pedwarn_c23 (assoc.type_location, OPT_Wpedantic, + "ISO C does not support %<_Generic%> association with " + "function type before C2Y"); else if (!COMPLETE_TYPE_P (assoc.type)) - error_at (assoc.type_location, - "%<_Generic%> association has incomplete type"); + pedwarn_c23 (assoc.type_location, OPT_Wpedantic, + "ISO C does not support %<_Generic%> association with " + "incomplete type before C2Y"); if (c_type_variably_modified_p (assoc.type)) error_at (assoc.type_location, diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h index 56a33b8156c60..15da875a02904 100644 --- a/gcc/c/c-tree.h +++ b/gcc/c/c-tree.h @@ -905,6 +905,8 @@ extern bool pedwarn_c99 (location_t, int opt, const char *, ...) ATTRIBUTE_GCC_DIAG(3,4); extern bool pedwarn_c11 (location_t, int opt, const char *, ...) ATTRIBUTE_GCC_DIAG(3,4); +extern bool pedwarn_c23 (location_t, int opt, const char *, ...) + ATTRIBUTE_GCC_DIAG(3,4); extern void set_c_expr_source_range (c_expr *expr, diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index a5ca9ea7db6ab..ffcab7df4d3b1 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -5079,8 +5079,9 @@ build_unary_op (location_t location, enum tree_code code, tree xarg, { tree real, imag; - pedwarn (location, OPT_Wpedantic, - "ISO C does not support %<++%> and %<--%> on complex types"); + pedwarn_c23 (location, OPT_Wpedantic, + "ISO C does not support %<++%> and %<--%> on complex " + "types before C2Y"); if (!atomic_op) { diff --git a/gcc/cfgexpand.cc b/gcc/cfgexpand.cc index 8de5f2ba58b7e..dad3ae1b7c6e1 100644 --- a/gcc/cfgexpand.cc +++ b/gcc/cfgexpand.cc @@ -2646,7 +2646,7 @@ expand_gimple_cond (basic_block bb, gcond *stmt) /* If jumps are cheap and the target does not support conditional compare, turn some more codes into jumpy sequences. */ else if (BRANCH_COST (optimize_insn_for_speed_p (), false) < 4 - && targetm.gen_ccmp_first == NULL) + && !targetm.have_ccmp ()) { if ((code2 == BIT_AND_EXPR && TYPE_PRECISION (TREE_TYPE (op0)) == 1 diff --git a/gcc/common.opt b/gcc/common.opt index 2c078fdd1f863..f2bc47fdc5e68 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -2233,6 +2233,9 @@ Enum(lto_partition_model) String(1to1) Value(LTO_PARTITION_1TO1) EnumValue Enum(lto_partition_model) String(max) Value(LTO_PARTITION_MAX) +EnumValue +Enum(lto_partition_model) String(cache) Value(LTO_PARTITION_CACHE) + flto-partition= Common Joined RejectNegative Enum(lto_partition_model) Var(flag_lto_partition) Init(LTO_PARTITION_BALANCED) Specify the algorithm to partition symbols and vars at linktime. diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc index 88204393fde09..1dc1d9904c7bd 100644 --- a/gcc/common/config/riscv/riscv-common.cc +++ b/gcc/common/config/riscv/riscv-common.cc @@ -79,6 +79,9 @@ static const riscv_implied_info_t riscv_implied_info[] = {"f", "zicsr"}, {"d", "zicsr"}, + {"a", "zaamo"}, + {"a", "zalrsc"}, + {"zdinx", "zfinx"}, {"zfinx", "zicsr"}, {"zdinx", "zicsr"}, @@ -255,6 +258,8 @@ static const struct riscv_ext_version riscv_ext_version_table[] = {"za64rs", ISA_SPEC_CLASS_NONE, 1, 0}, {"za128rs", ISA_SPEC_CLASS_NONE, 1, 0}, {"zawrs", ISA_SPEC_CLASS_NONE, 1, 0}, + {"zaamo", ISA_SPEC_CLASS_NONE, 1, 0}, + {"zalrsc", ISA_SPEC_CLASS_NONE, 1, 0}, {"zba", ISA_SPEC_CLASS_NONE, 1, 0}, {"zbb", ISA_SPEC_CLASS_NONE, 1, 0}, @@ -911,6 +916,7 @@ riscv_subset_list::to_string (bool version_p) const riscv_subset_t *subset; bool skip_zifencei = false; + bool skip_zaamo_zalrsc = false; bool skip_zicsr = false; bool i2p0 = false; @@ -938,6 +944,10 @@ riscv_subset_list::to_string (bool version_p) const a mistake in that binutils 2.35 supports zicsr but not zifencei. */ skip_zifencei = true; #endif +#ifndef HAVE_AS_MARCH_ZAAMO_ZALRSC + /* Skip since binutils 2.42 and earlier don't recognize zaamo/zalrsc. */ + skip_zaamo_zalrsc = true; +#endif for (subset = m_head; subset != NULL; subset = subset->next) { @@ -949,6 +959,12 @@ riscv_subset_list::to_string (bool version_p) const subset->name == "zicsr") continue; + if (skip_zaamo_zalrsc && subset->name == "zaamo") + continue; + + if (skip_zaamo_zalrsc && subset->name == "zalrsc") + continue; + /* For !version_p, we only separate extension with underline for multi-letter extension. */ if (!first && @@ -1616,9 +1632,11 @@ static const riscv_ext_flag_table_t riscv_ext_flag_table[] = {"zifencei", &gcc_options::x_riscv_zi_subext, MASK_ZIFENCEI}, {"zicond", &gcc_options::x_riscv_zi_subext, MASK_ZICOND}, - {"za64rs", &gcc_options::x_riscv_za_subext, MASK_ZA64RS}, + {"za64rs", &gcc_options::x_riscv_za_subext, MASK_ZA64RS}, {"za128rs", &gcc_options::x_riscv_za_subext, MASK_ZA128RS}, - {"zawrs", &gcc_options::x_riscv_za_subext, MASK_ZAWRS}, + {"zawrs", &gcc_options::x_riscv_za_subext, MASK_ZAWRS}, + {"zaamo", &gcc_options::x_riscv_za_subext, MASK_ZAAMO}, + {"zalrsc", &gcc_options::x_riscv_za_subext, MASK_ZALRSC}, {"zba", &gcc_options::x_riscv_zb_subext, MASK_ZBA}, {"zbb", &gcc_options::x_riscv_zb_subext, MASK_ZBB}, diff --git a/gcc/config.in b/gcc/config.in index e41b6dc97cdd6..acab3c0f1263a 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -629,6 +629,12 @@ #endif +/* Define if the assembler understands -march=rv*_zaamo_zalrsc. */ +#ifndef USED_FOR_TARGET +#undef HAVE_AS_MARCH_ZAAMO_ZALRSC +#endif + + /* Define if the assembler understands -march=rv*_zifencei. */ #ifndef USED_FOR_TARGET #undef HAVE_AS_MARCH_ZIFENCEI diff --git a/gcc/config/aarch64/aarch64-builtins.cc b/gcc/config/aarch64/aarch64-builtins.cc index 25189888d17dd..30669f8aa1823 100644 --- a/gcc/config/aarch64/aarch64-builtins.cc +++ b/gcc/config/aarch64/aarch64-builtins.cc @@ -543,6 +543,13 @@ BUILTIN_VDQ_BHSI (uhadd, uavg, _floor, 0) VAR1 (float_extend_lo_, extend, v2sf, v2df) VAR1 (float_extend_lo_, extend, v4hf, v4sf) +/* __builtin_aarch64_float_truncate_lo_ should be expanded through the + standard optabs CODE_FOR_trunc2. */ +constexpr insn_code CODE_FOR_aarch64_float_truncate_lo_v4hf + = CODE_FOR_truncv4sfv4hf2; +constexpr insn_code CODE_FOR_aarch64_float_truncate_lo_v2sf + = CODE_FOR_truncv2dfv2sf2; + #undef VAR1 #define VAR1(T, N, MAP, FLAG, A) \ {#N #A, UP (A), CF##MAP (N, A), 0, TYPES_##T, FLAG_##FLAG}, @@ -2572,8 +2579,7 @@ aarch64_expand_fcmla_builtin (tree exp, rtx target, int fcode) int lane = INTVAL (lane_idx); if (lane < nunits / 4) - op2 = simplify_gen_subreg (d->mode, op2, quadmode, - subreg_lowpart_offset (d->mode, quadmode)); + op2 = force_lowpart_subreg (d->mode, op2, quadmode); else { /* Select the upper 64 bits, either a V2SF or V4HF, this however @@ -2583,14 +2589,13 @@ aarch64_expand_fcmla_builtin (tree exp, rtx target, int fcode) gen_highpart_mode generates code that isn't optimal. */ rtx temp1 = gen_reg_rtx (d->mode); rtx temp2 = gen_reg_rtx (DImode); - temp1 = simplify_gen_subreg (d->mode, op2, quadmode, - subreg_lowpart_offset (d->mode, quadmode)); - temp1 = simplify_gen_subreg (V2DImode, temp1, d->mode, 0); + temp1 = force_lowpart_subreg (d->mode, op2, quadmode); + temp1 = force_subreg (V2DImode, temp1, d->mode, 0); if (BYTES_BIG_ENDIAN) emit_insn (gen_aarch64_get_lanev2di (temp2, temp1, const0_rtx)); else emit_insn (gen_aarch64_get_lanev2di (temp2, temp1, const1_rtx)); - op2 = simplify_gen_subreg (d->mode, temp2, GET_MODE (temp2), 0); + op2 = force_subreg (d->mode, temp2, GET_MODE (temp2), 0); /* And recalculate the index. */ lane -= nunits / 4; @@ -2829,7 +2834,7 @@ aarch64_expand_rwsr_builtin (tree exp, rtx target, int fcode) case AARCH64_WSR64: case AARCH64_WSRF64: case AARCH64_WSR128: - subreg = lowpart_subreg (sysreg_mode, input_val, mode); + subreg = force_lowpart_subreg (sysreg_mode, input_val, mode); break; case AARCH64_WSRF: subreg = gen_lowpart_SUBREG (SImode, input_val); @@ -2864,7 +2869,8 @@ aarch64_expand_rwsr_builtin (tree exp, rtx target, int fcode) case AARCH64_RSR64: case AARCH64_RSRF64: case AARCH64_RSR128: - return lowpart_subreg (TYPE_MODE (TREE_TYPE (exp)), target, sysreg_mode); + return force_lowpart_subreg (TYPE_MODE (TREE_TYPE (exp)), + target, sysreg_mode); case AARCH64_RSRF: subreg = gen_lowpart_SUBREG (SImode, target); return gen_lowpart_SUBREG (SFmode, subreg); diff --git a/gcc/config/aarch64/aarch64-cores.def b/gcc/config/aarch64/aarch64-cores.def index be60929e40007..0e05e81761cb1 100644 --- a/gcc/config/aarch64/aarch64-cores.def +++ b/gcc/config/aarch64/aarch64-cores.def @@ -58,16 +58,16 @@ AARCH64_CORE("cortex-a73", cortexa73, cortexa57, V8A, (CRC), cortexa73, 0x41, /* Cavium ('C') cores. */ AARCH64_CORE("thunderx", thunderx, thunderx, V8A, (CRC, CRYPTO), thunderx, 0x43, 0x0a0, -1) -/* Do not swap around "thunderxt88p1" and "thunderxt88", - this order is required to handle variant correctly. */ -AARCH64_CORE("thunderxt88p1", thunderxt88p1, thunderx, V8A, (CRC, CRYPTO), thunderxt88, 0x43, 0x0a1, 0) AARCH64_CORE("thunderxt88", thunderxt88, thunderx, V8A, (CRC, CRYPTO), thunderxt88, 0x43, 0x0a1, -1) +/* "thunderxt88p1 is just an alias for thunderxt88 now. */ +AARCH64_CORE("thunderxt88p1", thunderxt88p1, thunderx, V8A, (CRC, CRYPTO), thunderxt88, 0x43, 0x0a1, -1) /* OcteonTX is the official name for T81/T83. */ AARCH64_CORE("octeontx", octeontx, thunderx, V8A, (CRC, CRYPTO), thunderx, 0x43, 0x0a0, -1) AARCH64_CORE("octeontx81", octeontxt81, thunderx, V8A, (CRC, CRYPTO), thunderx, 0x43, 0x0a2, -1) AARCH64_CORE("octeontx83", octeontxt83, thunderx, V8A, (CRC, CRYPTO), thunderx, 0x43, 0x0a3, -1) +/* thunderxt81/83 are aliases for octeontxt81/83. */ AARCH64_CORE("thunderxt81", thunderxt81, thunderx, V8A, (CRC, CRYPTO), thunderx, 0x43, 0x0a2, -1) AARCH64_CORE("thunderxt83", thunderxt83, thunderx, V8A, (CRC, CRYPTO), thunderx, 0x43, 0x0a3, -1) diff --git a/gcc/config/aarch64/aarch64-early-ra.cc b/gcc/config/aarch64/aarch64-early-ra.cc index 1e2c823cb2eb4..99324423ee5aa 100644 --- a/gcc/config/aarch64/aarch64-early-ra.cc +++ b/gcc/config/aarch64/aarch64-early-ra.cc @@ -3446,7 +3446,7 @@ early_ra::process_block (basic_block bb, bool is_isolated) fprintf (dump_file, "\nBlock %d:\n", bb->index); fprintf (dump_file, "%6d:", m_current_point); pretty_printer rtl_slim_pp; - rtl_slim_pp.buffer->stream = dump_file; + rtl_slim_pp.set_output_stream (dump_file); print_insn (&rtl_slim_pp, insn, 1); pp_flush (&rtl_slim_pp); fprintf (dump_file, "\n"); diff --git a/gcc/config/aarch64/aarch64-freebsd.h b/gcc/config/aarch64/aarch64-freebsd.h index 53cc17a1caf05..e26d69ce46c73 100644 --- a/gcc/config/aarch64/aarch64-freebsd.h +++ b/gcc/config/aarch64/aarch64-freebsd.h @@ -35,6 +35,7 @@ #undef FBSD_TARGET_LINK_SPEC #define FBSD_TARGET_LINK_SPEC " \ %{p:%nconsider using `-pg' instead of `-p' with gprof (1)} \ + " FBSD_LINK_PG_NOTE " \ %{v:-V} \ %{assert*} %{R*} %{rpath*} %{defsym*} \ %{shared:-Bshareable %{h*} %{soname*}} \ diff --git a/gcc/config/aarch64/aarch64-simd.md b/gcc/config/aarch64/aarch64-simd.md index c5e2c9f00d024..01b084d8ccb53 100644 --- a/gcc/config/aarch64/aarch64-simd.md +++ b/gcc/config/aarch64/aarch64-simd.md @@ -377,8 +377,7 @@ (define_insn "aarch64_rbit" [(set (match_operand:VB 0 "register_operand" "=w") - (unspec:VB [(match_operand:VB 1 "register_operand" "w")] - UNSPEC_RBIT))] + (bitreverse:VB (match_operand:VB 1 "register_operand" "w")))] "TARGET_SIMD" "rbit\\t%0., %1." [(set_attr "type" "neon_rbit")] @@ -390,8 +389,8 @@ "TARGET_SIMD" { emit_insn (gen_bswap2 (operands[0], operands[1])); - rtx op0_castsi2qi = simplify_gen_subreg(mode, operands[0], - mode, 0); + rtx op0_castsi2qi = force_subreg (mode, operands[0], + mode, 0); emit_insn (gen_aarch64_rbit (op0_castsi2qi, op0_castsi2qi)); emit_insn (gen_clz2 (operands[0], operands[0])); DONE; @@ -3197,7 +3196,7 @@ } ) -(define_insn "aarch64_float_truncate_lo_" +(define_insn "trunc2" [(set (match_operand:VDF 0 "register_operand" "=w") (float_truncate:VDF (match_operand: 1 "register_operand" "w")))] @@ -3256,7 +3255,7 @@ int lo = BYTES_BIG_ENDIAN ? 2 : 1; int hi = BYTES_BIG_ENDIAN ? 1 : 2; - emit_insn (gen_aarch64_float_truncate_lo_v2sf (tmp, operands[lo])); + emit_insn (gen_truncv2dfv2sf2 (tmp, operands[lo])); emit_insn (gen_aarch64_float_truncate_hi_v4sf (operands[0], tmp, operands[hi])); DONE; @@ -3272,7 +3271,7 @@ { rtx tmp = gen_reg_rtx (V2SFmode); emit_insn (gen_aarch64_vec_concatdf (tmp, operands[1], operands[2])); - emit_insn (gen_aarch64_float_truncate_lo_v2sf (operands[0], tmp)); + emit_insn (gen_truncv2dfv2sf2 (operands[0], tmp)); DONE; } ) diff --git a/gcc/config/aarch64/aarch64-sve-builtins-base.cc b/gcc/config/aarch64/aarch64-sve-builtins-base.cc index 0d2edf3f19e16..aa26370d397f3 100644 --- a/gcc/config/aarch64/aarch64-sve-builtins-base.cc +++ b/gcc/config/aarch64/aarch64-sve-builtins-base.cc @@ -1121,9 +1121,8 @@ class svget_impl : public quiet expand (function_expander &e) const override { /* Fold the access into a subreg rvalue. */ - return simplify_gen_subreg (e.vector_mode (0), e.args[0], - GET_MODE (e.args[0]), - INTVAL (e.args[1]) * BYTES_PER_SVE_VECTOR); + return force_subreg (e.vector_mode (0), e.args[0], GET_MODE (e.args[0]), + INTVAL (e.args[1]) * BYTES_PER_SVE_VECTOR); } }; @@ -1157,8 +1156,7 @@ class svget_neonq_impl : public function_base e.add_fixed_operand (indices); return e.generate_insn (icode); } - return simplify_gen_subreg (e.result_mode (), e.args[0], - GET_MODE (e.args[0]), 0); + return force_subreg (e.result_mode (), e.args[0], GET_MODE (e.args[0]), 0); } }; @@ -1174,7 +1172,7 @@ class svset_neonq_impl : public function_base Advanced SIMD argument as an SVE vector. */ if (!BYTES_BIG_ENDIAN && is_undef (CALL_EXPR_ARG (e.call_expr, 0))) - return simplify_gen_subreg (mode, e.args[1], GET_MODE (e.args[1]), 0); + return force_subreg (mode, e.args[1], GET_MODE (e.args[1]), 0); rtx_vector_builder builder (VNx16BImode, 16, 2); for (unsigned int i = 0; i < 16; i++) @@ -1185,7 +1183,7 @@ class svset_neonq_impl : public function_base if (BYTES_BIG_ENDIAN) return e.use_exact_insn (code_for_aarch64_sve_set_neonq (mode)); insn_code icode = code_for_vcond_mask (mode, mode); - e.args[1] = lowpart_subreg (mode, e.args[1], GET_MODE (e.args[1])); + e.args[1] = force_lowpart_subreg (mode, e.args[1], GET_MODE (e.args[1])); e.add_output_operand (icode); e.add_input_operand (icode, e.args[1]); e.add_input_operand (icode, e.args[0]); @@ -3186,7 +3184,7 @@ FUNCTION (svqincp, svqdecp_svqincp_impl, (SS_PLUS, US_PLUS)) FUNCTION (svqincw, svqinc_bhwd_impl, (SImode)) FUNCTION (svqincw_pat, svqinc_bhwd_impl, (SImode)) FUNCTION (svqsub, rtx_code_function, (SS_MINUS, US_MINUS, -1)) -FUNCTION (svrbit, unspec_based_function, (UNSPEC_RBIT, UNSPEC_RBIT, -1)) +FUNCTION (svrbit, rtx_code_function, (BITREVERSE, BITREVERSE, -1)) FUNCTION (svrdffr, svrdffr_impl,) FUNCTION (svrecpe, unspec_based_function, (-1, UNSPEC_URECPE, UNSPEC_FRECPE)) FUNCTION (svrecps, unspec_based_function, (-1, -1, UNSPEC_FRECPS)) diff --git a/gcc/config/aarch64/aarch64-sve-builtins-functions.h b/gcc/config/aarch64/aarch64-sve-builtins-functions.h index 3b8e575e98e7b..7d06a57ff8345 100644 --- a/gcc/config/aarch64/aarch64-sve-builtins-functions.h +++ b/gcc/config/aarch64/aarch64-sve-builtins-functions.h @@ -639,9 +639,9 @@ class multireg_permute : public function_base { machine_mode elt_mode = e.vector_mode (0); rtx arg = e.args[0]; - e.args[0] = simplify_gen_subreg (elt_mode, arg, GET_MODE (arg), 0); - e.args.safe_push (simplify_gen_subreg (elt_mode, arg, GET_MODE (arg), - GET_MODE_SIZE (elt_mode))); + e.args[0] = force_subreg (elt_mode, arg, GET_MODE (arg), 0); + e.args.safe_push (force_subreg (elt_mode, arg, GET_MODE (arg), + GET_MODE_SIZE (elt_mode))); } return e.use_exact_insn (icode); } diff --git a/gcc/config/aarch64/aarch64-sve-builtins-sme.cc b/gcc/config/aarch64/aarch64-sve-builtins-sme.cc index f4c91bcbb95d2..b66b35ae60b7a 100644 --- a/gcc/config/aarch64/aarch64-sve-builtins-sme.cc +++ b/gcc/config/aarch64/aarch64-sve-builtins-sme.cc @@ -112,7 +112,7 @@ add_load_store_slice_operand (function_expander &e, insn_code icode, rtx base = e.args[argno]; if (e.mode_suffix_id == MODE_vnum) { - rtx vnum = lowpart_subreg (SImode, e.args[vnum_argno], DImode); + rtx vnum = force_lowpart_subreg (SImode, e.args[vnum_argno], DImode); base = simplify_gen_binary (PLUS, SImode, base, vnum); } e.add_input_operand (icode, base); diff --git a/gcc/config/aarch64/aarch64-sve.md b/gcc/config/aarch64/aarch64-sve.md index d69db34016a55..5331e7121d55e 100644 --- a/gcc/config/aarch64/aarch64-sve.md +++ b/gcc/config/aarch64/aarch64-sve.md @@ -3083,6 +3083,7 @@ ;; - CLS (= clrsb) ;; - CLZ ;; - CNT (= popcount) +;; - RBIT (= bitreverse) ;; - NEG ;; - NOT ;; ------------------------------------------------------------------------- @@ -3171,7 +3172,6 @@ ;; ---- [INT] General unary arithmetic corresponding to unspecs ;; ------------------------------------------------------------------------- ;; Includes -;; - RBIT ;; - REVB ;; - REVH ;; - REVW diff --git a/gcc/config/aarch64/aarch64-tune.md b/gcc/config/aarch64/aarch64-tune.md index ba940f1c89014..9b1f32a0330ab 100644 --- a/gcc/config/aarch64/aarch64-tune.md +++ b/gcc/config/aarch64/aarch64-tune.md @@ -1,5 +1,5 @@ ;; -*- buffer-read-only: t -*- ;; Generated automatically by gentune.sh from aarch64-cores.def (define_attr "tune" - "cortexa34,cortexa35,cortexa53,cortexa57,cortexa72,cortexa73,thunderx,thunderxt88p1,thunderxt88,octeontx,octeontxt81,octeontxt83,thunderxt81,thunderxt83,ampere1,ampere1a,ampere1b,emag,xgene1,falkor,qdf24xx,exynosm1,phecda,thunderx2t99p1,vulcan,thunderx2t99,cortexa55,cortexa75,cortexa76,cortexa76ae,cortexa77,cortexa78,cortexa78ae,cortexa78c,cortexa65,cortexa65ae,cortexx1,cortexx1c,neoversen1,ares,neoversee1,octeontx2,octeontx2t98,octeontx2t96,octeontx2t93,octeontx2f95,octeontx2f95n,octeontx2f95mm,a64fx,tsv110,thunderx3t110,neoversev1,zeus,neoverse512tvb,saphira,oryon1,cortexa57cortexa53,cortexa72cortexa53,cortexa73cortexa35,cortexa73cortexa53,cortexa75cortexa55,cortexa76cortexa55,cortexr82,cortexa510,cortexa520,cortexa710,cortexa715,cortexa720,cortexx2,cortexx3,cortexx4,neoversen2,cobalt100,neoversev2,demeter,generic,generic_armv8_a,generic_armv9_a" + "cortexa34,cortexa35,cortexa53,cortexa57,cortexa72,cortexa73,thunderx,thunderxt88,thunderxt88p1,octeontx,octeontxt81,octeontxt83,thunderxt81,thunderxt83,ampere1,ampere1a,ampere1b,emag,xgene1,falkor,qdf24xx,exynosm1,phecda,thunderx2t99p1,vulcan,thunderx2t99,cortexa55,cortexa75,cortexa76,cortexa76ae,cortexa77,cortexa78,cortexa78ae,cortexa78c,cortexa65,cortexa65ae,cortexx1,cortexx1c,neoversen1,ares,neoversee1,octeontx2,octeontx2t98,octeontx2t96,octeontx2t93,octeontx2f95,octeontx2f95n,octeontx2f95mm,a64fx,tsv110,thunderx3t110,neoversev1,zeus,neoverse512tvb,saphira,oryon1,cortexa57cortexa53,cortexa72cortexa53,cortexa73cortexa35,cortexa73cortexa53,cortexa75cortexa55,cortexa76cortexa55,cortexr82,cortexa510,cortexa520,cortexa710,cortexa715,cortexa720,cortexx2,cortexx3,cortexx4,neoversen2,cobalt100,neoversev2,demeter,generic,generic_armv8_a,generic_armv9_a" (const (symbol_ref "((enum attr_tune) aarch64_tune)"))) diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index 13191ec8e345b..c55d630f745a4 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -3288,7 +3288,7 @@ aarch64_sve_reinterpret (machine_mode mode, rtx x) /* can_change_mode_class must only return true if subregs and svreinterprets have the same semantics. */ if (targetm.can_change_mode_class (GET_MODE (x), mode, FP_REGS)) - return lowpart_subreg (mode, x, GET_MODE (x)); + return force_lowpart_subreg (mode, x, GET_MODE (x)); rtx res = gen_reg_rtx (mode); x = force_reg (GET_MODE (x), x); @@ -14690,6 +14690,7 @@ aarch64_rtx_costs (rtx x, machine_mode mode, int outer ATTRIBUTE_UNUSED, return true; } + case BITREVERSE: case BSWAP: *cost = COSTS_N_INSNS (1); @@ -15339,14 +15340,6 @@ aarch64_rtx_costs (rtx x, machine_mode mode, int outer ATTRIBUTE_UNUSED, return false; } - - if (XINT (x, 1) == UNSPEC_RBIT) - { - if (speed) - *cost += extra_cost->alu.rev; - - return false; - } break; case TRUNCATE: @@ -19757,28 +19750,43 @@ aarch64_parse_fmv_features (const char *str, aarch64_feature_flags *isa_flags, int num_features = ARRAY_SIZE (aarch64_fmv_feature_data); int i; - for (i = 0; i < num_features; i++) - { - if (strlen (aarch64_fmv_feature_data[i].name) == len - && strncmp (aarch64_fmv_feature_data[i].name, str, len) == 0) - { - if (isa_flags) - *isa_flags |= aarch64_fmv_feature_data[i].opt_flags; - if (feature_mask) - { - auto old_feature_mask = *feature_mask; - *feature_mask |= aarch64_fmv_feature_data[i].feature_mask; - if (*feature_mask == old_feature_mask) - { - /* Duplicate feature. */ - if (invalid_extension) - *invalid_extension = std::string (str, len); - return AARCH_PARSE_DUPLICATE_FEATURE; - } - } - break; - } - } + if (strstr(str, "arch=") != NULL) { + const char *archstr = strchr (str, '=') + 1; + if (aarch64_handle_attr_arch(archstr)) { + /* aarch64_handle_attr_arch handles the validation for the arch= argument (this method is called when using -march command option) + I have not figured out what to do from here and unfortunately its the final day! One thing to note, for some reason this is looping + past when it should, which I am not sure why but if you have a printf statement inside this if, you will see it is printed multiple times, so + that deserves further investigation */ + } + else { + /* When aarch64_handle_attr_arch returns false (on a bad arch= arg), it calls its own errors, so this if may be unnecessary as I believe + those errors will stop exectution. I will keep it here for easier testing and to avoid adding any more errors. */ + } + } + else { + for (i = 0; i < num_features; i++) + { + if (strlen (aarch64_fmv_feature_data[i].name) == len + && strncmp (aarch64_fmv_feature_data[i].name, str, len) == 0) + { + if (isa_flags) + *isa_flags |= aarch64_fmv_feature_data[i].opt_flags; + if (feature_mask) + { + auto old_feature_mask = *feature_mask; + *feature_mask |= aarch64_fmv_feature_data[i].feature_mask; + if (*feature_mask == old_feature_mask) + { + /* Duplicate feature. */ + if (invalid_extension) + *invalid_extension = std::string (str, len); + return AARCH_PARSE_DUPLICATE_FEATURE; + } + } + break; + } + } + } if (i == num_features) { @@ -26877,23 +26885,15 @@ aarch64_addti_scratch_regs (rtx op1, rtx op2, rtx *low_dest, rtx *high_in2) { *low_dest = gen_reg_rtx (DImode); - *low_in1 = gen_lowpart (DImode, op1); - *low_in2 = simplify_gen_subreg (DImode, op2, TImode, - subreg_lowpart_offset (DImode, TImode)); + *low_in1 = force_lowpart_subreg (DImode, op1, TImode); + *low_in2 = force_lowpart_subreg (DImode, op2, TImode); *high_dest = gen_reg_rtx (DImode); - *high_in1 = gen_highpart (DImode, op1); - *high_in2 = simplify_gen_subreg (DImode, op2, TImode, - subreg_highpart_offset (DImode, TImode)); + *high_in1 = force_highpart_subreg (DImode, op1, TImode); + *high_in2 = force_highpart_subreg (DImode, op2, TImode); } /* Generate DImode scratch registers for 128-bit (TImode) subtraction. - This function differs from 'arch64_addti_scratch_regs' in that - OP1 can be an immediate constant (zero). We must call - subreg_highpart_offset with DImode and TImode arguments, otherwise - VOIDmode will be used for the const_int which generates an internal - error from subreg_size_highpart_offset which does not expect a size of zero. - OP1 represents the TImode destination operand 1 OP2 represents the TImode destination operand 2 LOW_DEST represents the low half (DImode) of TImode operand 0 @@ -26911,17 +26911,12 @@ aarch64_subvti_scratch_regs (rtx op1, rtx op2, rtx *low_dest, rtx *high_in2) { *low_dest = gen_reg_rtx (DImode); - *low_in1 = simplify_gen_subreg (DImode, op1, TImode, - subreg_lowpart_offset (DImode, TImode)); - - *low_in2 = simplify_gen_subreg (DImode, op2, TImode, - subreg_lowpart_offset (DImode, TImode)); + *low_in1 = force_lowpart_subreg (DImode, op1, TImode); + *low_in2 = force_lowpart_subreg (DImode, op2, TImode); *high_dest = gen_reg_rtx (DImode); - *high_in1 = simplify_gen_subreg (DImode, op1, TImode, - subreg_highpart_offset (DImode, TImode)); - *high_in2 = simplify_gen_subreg (DImode, op2, TImode, - subreg_highpart_offset (DImode, TImode)); + *high_in1 = force_highpart_subreg (DImode, op1, TImode); + *high_in2 = force_highpart_subreg (DImode, op2, TImode); } /* Generate RTL for 128-bit (TImode) subtraction with overflow. diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h index 0997b82dbc0f2..2b89f6f88ef00 100644 --- a/gcc/config/aarch64/aarch64.h +++ b/gcc/config/aarch64/aarch64.h @@ -1059,7 +1059,7 @@ typedef struct GTY (()) machine_function { struct aarch64_frame frame; /* One entry for each hard register. */ - bool reg_is_wrapped_separately[LAST_SAVED_REGNUM]; + bool reg_is_wrapped_separately[LAST_SAVED_REGNUM + 1]; /* One entry for each general purpose register. */ rtx call_via[SP_REGNUM]; diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index 389a1906e2366..9de6235b1398f 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -259,7 +259,6 @@ UNSPEC_PACIBSP UNSPEC_PRLG_STK UNSPEC_REV - UNSPEC_RBIT UNSPEC_SADALP UNSPEC_SCVTF UNSPEC_SETMEM @@ -5368,7 +5367,7 @@ (define_insn "@aarch64_rbit" [(set (match_operand:GPI 0 "register_operand" "=r") - (unspec:GPI [(match_operand:GPI 1 "register_operand" "r")] UNSPEC_RBIT))] + (bitreverse:GPI (match_operand:GPI 1 "register_operand" "r")))] "" "rbit\\t%0, %1" [(set_attr "type" "rbit")] diff --git a/gcc/config/aarch64/iterators.md b/gcc/config/aarch64/iterators.md index 99cde46f1ba5a..f527b2cfeb817 100644 --- a/gcc/config/aarch64/iterators.md +++ b/gcc/config/aarch64/iterators.md @@ -2525,6 +2525,7 @@ ;; SVE integer unary operations. (define_code_iterator SVE_INT_UNARY [abs neg not clrsb clz popcount + bitreverse (ss_abs "TARGET_SVE2") (ss_neg "TARGET_SVE2")]) @@ -2573,6 +2574,7 @@ (clrsb "clrsb") (clz "clz") (popcount "popcount") + (bitreverse "rbit") (and "and") (ior "ior") (xor "xor") @@ -2785,6 +2787,7 @@ (clrsb "cls") (clz "clz") (popcount "cnt") + (bitreverse "rbit") (ss_plus "sqadd") (us_plus "uqadd") (ss_minus "sqsub") @@ -2990,7 +2993,7 @@ (define_int_iterator LAST [UNSPEC_LASTA UNSPEC_LASTB]) -(define_int_iterator SVE_INT_UNARY [UNSPEC_RBIT UNSPEC_REVB +(define_int_iterator SVE_INT_UNARY [UNSPEC_REVB UNSPEC_REVH UNSPEC_REVW]) (define_int_iterator SVE_FP_UNARY [UNSPEC_FRECPE UNSPEC_RSQRTE]) @@ -3568,7 +3571,6 @@ (UNSPEC_FRECPS "frecps") (UNSPEC_RSQRTE "frsqrte") (UNSPEC_RSQRTS "frsqrts") - (UNSPEC_RBIT "rbit") (UNSPEC_REVB "revb") (UNSPEC_REVD "revd") (UNSPEC_REVH "revh") @@ -4039,7 +4041,6 @@ (UNSPEC_PMULLT_PAIR "pmullt") (UNSPEC_RADDHNB "raddhnb") (UNSPEC_RADDHNT "raddhnt") - (UNSPEC_RBIT "rbit") (UNSPEC_REVB "revb") (UNSPEC_REVH "revh") (UNSPEC_REVW "revw") @@ -4416,8 +4417,7 @@ (UNSPEC_PFIRST "8") (UNSPEC_PNEXT "64")]) ;; The minimum number of element bits that an instruction can handle. -(define_int_attr min_elem_bits [(UNSPEC_RBIT "8") - (UNSPEC_REVB "16") +(define_int_attr min_elem_bits [(UNSPEC_REVB "16") (UNSPEC_REVH "32") (UNSPEC_REVW "64")]) diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index ea0c963a4d67e..b8c32db0a1d7f 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -19220,17 +19220,25 @@ cmse_nonsecure_call_inline_register_clear (void) || TREE_CODE (ret_type) == BOOLEAN_TYPE) && known_lt (GET_MODE_SIZE (TYPE_MODE (ret_type)), 4)) { - machine_mode ret_mode = TYPE_MODE (ret_type); + rtx ret_reg = gen_rtx_REG (TYPE_MODE (ret_type), R0_REGNUM); + rtx si_reg = gen_rtx_REG (SImode, R0_REGNUM); rtx extend; if (TYPE_UNSIGNED (ret_type)) - extend = gen_rtx_ZERO_EXTEND (SImode, - gen_rtx_REG (ret_mode, R0_REGNUM)); + extend = gen_rtx_SET (si_reg, gen_rtx_ZERO_EXTEND (SImode, + ret_reg)); else - extend = gen_rtx_SIGN_EXTEND (SImode, - gen_rtx_REG (ret_mode, R0_REGNUM)); - emit_insn_after (gen_rtx_SET (gen_rtx_REG (SImode, R0_REGNUM), - extend), insn); - + { + /* Signed-extension is a special case because of + thumb1_extendhisi2. */ + if (TARGET_THUMB1 + && known_eq (GET_MODE_SIZE (TYPE_MODE (ret_type)), 2)) + extend = gen_thumb1_extendhisi2 (si_reg, ret_reg); + else + extend = gen_rtx_SET (si_reg, + gen_rtx_SIGN_EXTEND (SImode, + ret_reg)); + } + emit_insn_after (extend, insn); } @@ -27250,6 +27258,58 @@ thumb1_expand_prologue (void) live_regs_mask = offsets->saved_regs_mask; lr_needs_saving = live_regs_mask & (1 << LR_REGNUM); + /* The AAPCS requires the callee to widen integral types narrower + than 32 bits to the full width of the register; but when handling + calls to non-secure space, we cannot trust the callee to have + correctly done so. So forcibly re-widen the result here. */ + if (IS_CMSE_ENTRY (func_type)) + { + function_args_iterator args_iter; + CUMULATIVE_ARGS args_so_far_v; + cumulative_args_t args_so_far; + bool first_param = true; + tree arg_type; + tree fndecl = current_function_decl; + tree fntype = TREE_TYPE (fndecl); + arm_init_cumulative_args (&args_so_far_v, fntype, NULL_RTX, fndecl); + args_so_far = pack_cumulative_args (&args_so_far_v); + FOREACH_FUNCTION_ARGS (fntype, arg_type, args_iter) + { + rtx arg_rtx; + + if (VOID_TYPE_P (arg_type)) + break; + + function_arg_info arg (arg_type, /*named=*/true); + if (!first_param) + /* We should advance after processing the argument and pass + the argument we're advancing past. */ + arm_function_arg_advance (args_so_far, arg); + first_param = false; + arg_rtx = arm_function_arg (args_so_far, arg); + gcc_assert (REG_P (arg_rtx)); + if ((TREE_CODE (arg_type) == INTEGER_TYPE + || TREE_CODE (arg_type) == ENUMERAL_TYPE + || TREE_CODE (arg_type) == BOOLEAN_TYPE) + && known_lt (GET_MODE_SIZE (GET_MODE (arg_rtx)), 4)) + { + rtx res_reg = gen_rtx_REG (SImode, REGNO (arg_rtx)); + if (TYPE_UNSIGNED (arg_type)) + emit_set_insn (res_reg, gen_rtx_ZERO_EXTEND (SImode, arg_rtx)); + else + { + /* Signed-extension is a special case because of + thumb1_extendhisi2. */ + if (known_eq (GET_MODE_SIZE (GET_MODE (arg_rtx)), 2)) + emit_insn (gen_thumb1_extendhisi2 (res_reg, arg_rtx)); + else + emit_set_insn (res_reg, + gen_rtx_SIGN_EXTEND (SImode, arg_rtx)); + } + } + } + } + /* Extract a mask of the ones we can give to the Thumb's push instruction. */ l_mask = live_regs_mask & 0x40ff; /* Then count how many other high registers will need to be pushed. */ diff --git a/gcc/config/arm/freebsd.h b/gcc/config/arm/freebsd.h index 9d0a5a842aba2..ee4860ae63756 100644 --- a/gcc/config/arm/freebsd.h +++ b/gcc/config/arm/freebsd.h @@ -47,6 +47,7 @@ #undef LINK_SPEC #define LINK_SPEC " \ %{p:%nconsider using `-pg' instead of `-p' with gprof (1)} \ + " FBSD_LINK_PG_NOTE " \ %{v:-V} \ %{assert*} %{R*} %{rpath*} %{defsym*} \ %{shared:-Bshareable %{h*} %{soname*}} \ diff --git a/gcc/config/freebsd-spec.h b/gcc/config/freebsd-spec.h index a6d1ad1280fe2..f43056bf2cf08 100644 --- a/gcc/config/freebsd-spec.h +++ b/gcc/config/freebsd-spec.h @@ -92,19 +92,29 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see libc, depending on whether we're doing profiling or need threads support. (similar to the default, except no -lg, and no -p). */ +#if FBSD_MAJOR < 14 +#define FBSD_LINK_PG_NOTHREADS "%{!pg: -lc} %{pg: -lc_p}" +#define FBSD_LINK_PG_THREADS "%{!pg: %{pthread:-lpthread} -lc} " \ + "%{pg: %{pthread:-lpthread} -lc_p}" +#define FBSD_LINK_PG_NOTE "" +#else +#define FBSD_LINK_PG_NOTHREADS "%{-lc} " +#define FBSD_LINK_PG_THREADS "%{pthread:-lpthread} -lc " +#define FBSD_LINK_PG_NOTE "%{pg:%nFreeBSD no longer provides profiled "\ + "system libraries}" +#endif + #ifdef FBSD_NO_THREADS #define FBSD_LIB_SPEC " \ %{pthread: %eThe -pthread option is only supported on FreeBSD when gcc \ is built with the --enable-threads configure-time option.} \ %{!shared: \ - %{!pg: -lc} \ - %{pg: -lc_p} \ + " FBSD_LINK_PG_NOTHREADS " \ }" #else #define FBSD_LIB_SPEC " \ %{!shared: \ - %{!pg: %{pthread:-lpthread} -lc} \ - %{pg: %{pthread:-lpthread_p} -lc_p} \ + " FBSD_LINK_PG_THREADS " \ } \ %{shared: \ %{pthread:-lpthread} -lc \ diff --git a/gcc/config/i386/avxintrin.h b/gcc/config/i386/avxintrin.h index 802145408881c..ec9b9905b5f6b 100644 --- a/gcc/config/i386/avxintrin.h +++ b/gcc/config/i386/avxintrin.h @@ -72,22 +72,6 @@ typedef double __m256d_u __attribute__ ((__vector_size__ (32), /* Compare predicates for scalar and packed compare intrinsics. */ -/* Equal (ordered, non-signaling) */ -#define _CMP_EQ_OQ 0x00 -/* Less-than (ordered, signaling) */ -#define _CMP_LT_OS 0x01 -/* Less-than-or-equal (ordered, signaling) */ -#define _CMP_LE_OS 0x02 -/* Unordered (non-signaling) */ -#define _CMP_UNORD_Q 0x03 -/* Not-equal (unordered, non-signaling) */ -#define _CMP_NEQ_UQ 0x04 -/* Not-less-than (unordered, signaling) */ -#define _CMP_NLT_US 0x05 -/* Not-less-than-or-equal (unordered, signaling) */ -#define _CMP_NLE_US 0x06 -/* Ordered (nonsignaling) */ -#define _CMP_ORD_Q 0x07 /* Equal (unordered, non-signaling) */ #define _CMP_EQ_UQ 0x08 /* Not-greater-than-or-equal (unordered, signaling) */ @@ -381,18 +365,6 @@ _mm256_xor_ps (__m256 __A, __m256 __B) } #ifdef __OPTIMIZE__ -extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__)) -_mm_cmp_pd (__m128d __X, __m128d __Y, const int __P) -{ - return (__m128d) __builtin_ia32_cmppd ((__v2df)__X, (__v2df)__Y, __P); -} - -extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) -_mm_cmp_ps (__m128 __X, __m128 __Y, const int __P) -{ - return (__m128) __builtin_ia32_cmpps ((__v4sf)__X, (__v4sf)__Y, __P); -} - extern __inline __m256d __attribute__((__gnu_inline__, __always_inline__, __artificial__)) _mm256_cmp_pd (__m256d __X, __m256d __Y, const int __P) { @@ -406,27 +378,7 @@ _mm256_cmp_ps (__m256 __X, __m256 __Y, const int __P) return (__m256) __builtin_ia32_cmpps256 ((__v8sf)__X, (__v8sf)__Y, __P); } - -extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__)) -_mm_cmp_sd (__m128d __X, __m128d __Y, const int __P) -{ - return (__m128d) __builtin_ia32_cmpsd ((__v2df)__X, (__v2df)__Y, __P); -} - -extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) -_mm_cmp_ss (__m128 __X, __m128 __Y, const int __P) -{ - return (__m128) __builtin_ia32_cmpss ((__v4sf)__X, (__v4sf)__Y, __P); -} #else -#define _mm_cmp_pd(X, Y, P) \ - ((__m128d) __builtin_ia32_cmppd ((__v2df)(__m128d)(X), \ - (__v2df)(__m128d)(Y), (int)(P))) - -#define _mm_cmp_ps(X, Y, P) \ - ((__m128) __builtin_ia32_cmpps ((__v4sf)(__m128)(X), \ - (__v4sf)(__m128)(Y), (int)(P))) - #define _mm256_cmp_pd(X, Y, P) \ ((__m256d) __builtin_ia32_cmppd256 ((__v4df)(__m256d)(X), \ (__v4df)(__m256d)(Y), (int)(P))) @@ -434,14 +386,6 @@ _mm_cmp_ss (__m128 __X, __m128 __Y, const int __P) #define _mm256_cmp_ps(X, Y, P) \ ((__m256) __builtin_ia32_cmpps256 ((__v8sf)(__m256)(X), \ (__v8sf)(__m256)(Y), (int)(P))) - -#define _mm_cmp_sd(X, Y, P) \ - ((__m128d) __builtin_ia32_cmpsd ((__v2df)(__m128d)(X), \ - (__v2df)(__m128d)(Y), (int)(P))) - -#define _mm_cmp_ss(X, Y, P) \ - ((__m128) __builtin_ia32_cmpss ((__v4sf)(__m128)(X), \ - (__v4sf)(__m128)(Y), (int)(P))) #endif extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) diff --git a/gcc/config/i386/emmintrin.h b/gcc/config/i386/emmintrin.h index 356ca218fcb52..d58030e5c4fe7 100644 --- a/gcc/config/i386/emmintrin.h +++ b/gcc/config/i386/emmintrin.h @@ -1390,6 +1390,28 @@ _mm_cmpgt_epi32 (__m128i __A, __m128i __B) return (__m128i) ((__v4si)__A > (__v4si)__B); } +#ifdef __OPTIMIZE__ +extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__)) +_mm_cmp_pd (__m128d __X, __m128d __Y, const int __P) +{ + return (__m128d) __builtin_ia32_cmppd ((__v2df)__X, (__v2df)__Y, __P); +} + +extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__)) +_mm_cmp_sd (__m128d __X, __m128d __Y, const int __P) +{ + return (__m128d) __builtin_ia32_cmpsd ((__v2df)__X, (__v2df)__Y, __P); +} +#else +#define _mm_cmp_pd(X, Y, P) \ + ((__m128d) __builtin_ia32_cmppd ((__v2df)(__m128d)(X), \ + (__v2df)(__m128d)(Y), (int)(P))) + +#define _mm_cmp_sd(X, Y, P) \ + ((__m128d) __builtin_ia32_cmpsd ((__v2df)(__m128d)(X), \ + (__v2df)(__m128d)(Y), (int)(P))) +#endif + #ifdef __OPTIMIZE__ extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) _mm_extract_epi16 (__m128i const __A, int const __N) diff --git a/gcc/config/i386/freebsd.h b/gcc/config/i386/freebsd.h index 3c57dc7cfae08..583c752bb7659 100644 --- a/gcc/config/i386/freebsd.h +++ b/gcc/config/i386/freebsd.h @@ -80,6 +80,7 @@ along with GCC; see the file COPYING3. If not see #undef LINK_SPEC #define LINK_SPEC "\ %{p:%nconsider using '-pg' instead of '-p' with gprof(1)} \ + " FBSD_LINK_PG_NOTE " \ %{v:-V} \ %{assert*} %{R*} %{rpath*} %{defsym*} \ %{shared:-Bshareable %{h*} %{soname*}} \ diff --git a/gcc/config/i386/freebsd64.h b/gcc/config/i386/freebsd64.h index af3fc3018b70f..12985e22ef9ec 100644 --- a/gcc/config/i386/freebsd64.h +++ b/gcc/config/i386/freebsd64.h @@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see #define LINK_SPEC "\ %{m32:-m elf_i386_fbsd}%{!m32:-m elf_x86_64_fbsd} \ %{p:%nconsider using '-pg' instead of '-p' with gprof(1)} \ + " FBSD_LINK_PG_NOTE " \ %{v:-V} \ %{assert*} %{R*} %{rpath*} %{defsym*} \ %{shared:-Bshareable %{h*} %{soname*}} \ diff --git a/gcc/config/i386/i386-builtin.def b/gcc/config/i386/i386-builtin.def index a28c48c756681..e876e7f5cbe84 100644 --- a/gcc/config/i386/i386-builtin.def +++ b/gcc/config/i386/i386-builtin.def @@ -635,9 +635,9 @@ BDESC (OPTION_MASK_ISA_SSE, 0, CODE_FOR_sse_rcpv4sf2, "__builtin_ia32_rcpps", IX BDESC (OPTION_MASK_ISA_SSE | OPTION_MASK_ISA_MMX, 0, CODE_FOR_sse_cvtps2pi, "__builtin_ia32_cvtps2pi", IX86_BUILTIN_CVTPS2PI, UNKNOWN, (int) V2SI_FTYPE_V4SF) BDESC (OPTION_MASK_ISA_SSE, 0, CODE_FOR_sse_cvtss2si, "__builtin_ia32_cvtss2si", IX86_BUILTIN_CVTSS2SI, UNKNOWN, (int) INT_FTYPE_V4SF) BDESC (OPTION_MASK_ISA_SSE | OPTION_MASK_ISA_64BIT, 0, CODE_FOR_sse_cvtss2siq, "__builtin_ia32_cvtss2si64", IX86_BUILTIN_CVTSS2SI64, UNKNOWN, (int) INT64_FTYPE_V4SF) -BDESC (OPTION_MASK_ISA_SSE | OPTION_MASK_ISA_MMX, 0, CODE_FOR_sse_cvttps2pi, "__builtin_ia32_cvttps2pi", IX86_BUILTIN_CVTTPS2PI, UNKNOWN, (int) V2SI_FTYPE_V4SF) -BDESC (OPTION_MASK_ISA_SSE, 0, CODE_FOR_sse_cvttss2si, "__builtin_ia32_cvttss2si", IX86_BUILTIN_CVTTSS2SI, UNKNOWN, (int) INT_FTYPE_V4SF) -BDESC (OPTION_MASK_ISA_SSE | OPTION_MASK_ISA_64BIT, 0, CODE_FOR_sse_cvttss2siq, "__builtin_ia32_cvttss2si64", IX86_BUILTIN_CVTTSS2SI64, UNKNOWN, (int) INT64_FTYPE_V4SF) +BDESC (OPTION_MASK_ISA_SSE | OPTION_MASK_ISA_MMX, 0, CODE_FOR_unspec_sse_cvttps2pi, "__builtin_ia32_cvttps2pi", IX86_BUILTIN_CVTTPS2PI, UNKNOWN, (int) V2SI_FTYPE_V4SF) +BDESC (OPTION_MASK_ISA_SSE, 0, CODE_FOR_unspec_sse_cvttss2si, "__builtin_ia32_cvttss2si", IX86_BUILTIN_CVTTSS2SI, UNKNOWN, (int) INT_FTYPE_V4SF) +BDESC (OPTION_MASK_ISA_SSE | OPTION_MASK_ISA_64BIT, 0, CODE_FOR_unspec_sse_cvttss2siq, "__builtin_ia32_cvttss2si64", IX86_BUILTIN_CVTTSS2SI64, UNKNOWN, (int) INT64_FTYPE_V4SF) BDESC (OPTION_MASK_ISA_SSE, 0, CODE_FOR_sse_shufps, "__builtin_ia32_shufps", IX86_BUILTIN_SHUFPS, UNKNOWN, (int) V4SF_FTYPE_V4SF_V4SF_INT) @@ -671,6 +671,9 @@ BDESC (OPTION_MASK_ISA_SSE, 0, CODE_FOR_sse_vmmaskcmpv4sf3, "__builtin_ia32_cmpn BDESC (OPTION_MASK_ISA_SSE, 0, CODE_FOR_sse_vmmaskcmpv4sf3, "__builtin_ia32_cmpnless", IX86_BUILTIN_CMPNLESS, UNGT, (int) V4SF_FTYPE_V4SF_V4SF) BDESC (OPTION_MASK_ISA_SSE, 0, CODE_FOR_sse_vmmaskcmpv4sf3, "__builtin_ia32_cmpordss", IX86_BUILTIN_CMPORDSS, ORDERED, (int) V4SF_FTYPE_V4SF_V4SF) +BDESC (OPTION_MASK_ISA_SSE, 0, CODE_FOR_avx_vmcmpv4sf3, "__builtin_ia32_cmpss", IX86_BUILTIN_CMPSS, UNKNOWN, (int) V4SF_FTYPE_V4SF_V4SF_INT) +BDESC (OPTION_MASK_ISA_SSE, 0, CODE_FOR_avx_cmpv4sf3, "__builtin_ia32_cmpps", IX86_BUILTIN_CMPPS, UNKNOWN, (int) V4SF_FTYPE_V4SF_V4SF_INT) + BDESC (OPTION_MASK_ISA_SSE, 0, CODE_FOR_sminv4sf3, "__builtin_ia32_minps", IX86_BUILTIN_MINPS, UNKNOWN, (int) V4SF_FTYPE_V4SF_V4SF) BDESC (OPTION_MASK_ISA_SSE, 0, CODE_FOR_smaxv4sf3, "__builtin_ia32_maxps", IX86_BUILTIN_MAXPS, UNKNOWN, (int) V4SF_FTYPE_V4SF_V4SF) BDESC (OPTION_MASK_ISA_SSE, 0, CODE_FOR_sse_vmsminv4sf3, "__builtin_ia32_minss", IX86_BUILTIN_MINSS, UNKNOWN, (int) V4SF_FTYPE_V4SF_V4SF) @@ -729,19 +732,19 @@ BDESC (OPTION_MASK_ISA_SSE2, 0, CODE_FOR_floatv4siv4sf2, "__builtin_ia32_cvtdq2p BDESC (OPTION_MASK_ISA_SSE2, 0, CODE_FOR_sse2_cvtpd2dq, "__builtin_ia32_cvtpd2dq", IX86_BUILTIN_CVTPD2DQ, UNKNOWN, (int) V4SI_FTYPE_V2DF) BDESC (OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_MMX, 0, CODE_FOR_sse2_cvtpd2pi, "__builtin_ia32_cvtpd2pi", IX86_BUILTIN_CVTPD2PI, UNKNOWN, (int) V2SI_FTYPE_V2DF) BDESC (OPTION_MASK_ISA_SSE2, 0, CODE_FOR_sse2_cvtpd2ps, "__builtin_ia32_cvtpd2ps", IX86_BUILTIN_CVTPD2PS, UNKNOWN, (int) V4SF_FTYPE_V2DF) -BDESC (OPTION_MASK_ISA_SSE2, 0, CODE_FOR_sse2_cvttpd2dq, "__builtin_ia32_cvttpd2dq", IX86_BUILTIN_CVTTPD2DQ, UNKNOWN, (int) V4SI_FTYPE_V2DF) -BDESC (OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_MMX, 0, CODE_FOR_sse2_cvttpd2pi, "__builtin_ia32_cvttpd2pi", IX86_BUILTIN_CVTTPD2PI, UNKNOWN, (int) V2SI_FTYPE_V2DF) +BDESC (OPTION_MASK_ISA_SSE2, 0, CODE_FOR_unspec_sse2_cvttpd2dq, "__builtin_ia32_cvttpd2dq", IX86_BUILTIN_CVTTPD2DQ, UNKNOWN, (int) V4SI_FTYPE_V2DF) +BDESC (OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_MMX, 0, CODE_FOR_unspec_sse2_cvttpd2pi, "__builtin_ia32_cvttpd2pi", IX86_BUILTIN_CVTTPD2PI, UNKNOWN, (int) V2SI_FTYPE_V2DF) BDESC (OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_MMX, 0, CODE_FOR_sse2_cvtpi2pd, "__builtin_ia32_cvtpi2pd", IX86_BUILTIN_CVTPI2PD, UNKNOWN, (int) V2DF_FTYPE_V2SI) BDESC (OPTION_MASK_ISA_SSE2, 0, CODE_FOR_sse2_cvtsd2si, "__builtin_ia32_cvtsd2si", IX86_BUILTIN_CVTSD2SI, UNKNOWN, (int) INT_FTYPE_V2DF) -BDESC (OPTION_MASK_ISA_SSE2, 0, CODE_FOR_sse2_cvttsd2si, "__builtin_ia32_cvttsd2si", IX86_BUILTIN_CVTTSD2SI, UNKNOWN, (int) INT_FTYPE_V2DF) +BDESC (OPTION_MASK_ISA_SSE2, 0, CODE_FOR_unspec_sse2_cvttsd2si, "__builtin_ia32_cvttsd2si", IX86_BUILTIN_CVTTSD2SI, UNKNOWN, (int) INT_FTYPE_V2DF) BDESC (OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_64BIT, 0, CODE_FOR_sse2_cvtsd2siq, "__builtin_ia32_cvtsd2si64", IX86_BUILTIN_CVTSD2SI64, UNKNOWN, (int) INT64_FTYPE_V2DF) -BDESC (OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_64BIT, 0, CODE_FOR_sse2_cvttsd2siq, "__builtin_ia32_cvttsd2si64", IX86_BUILTIN_CVTTSD2SI64, UNKNOWN, (int) INT64_FTYPE_V2DF) +BDESC (OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_64BIT, 0, CODE_FOR_unspec_sse2_cvttsd2siq, "__builtin_ia32_cvttsd2si64", IX86_BUILTIN_CVTTSD2SI64, UNKNOWN, (int) INT64_FTYPE_V2DF) BDESC (OPTION_MASK_ISA_SSE2, 0, CODE_FOR_sse2_fix_notruncv4sfv4si, "__builtin_ia32_cvtps2dq", IX86_BUILTIN_CVTPS2DQ, UNKNOWN, (int) V4SI_FTYPE_V4SF) BDESC (OPTION_MASK_ISA_SSE2, 0, CODE_FOR_sse2_cvtps2pd, "__builtin_ia32_cvtps2pd", IX86_BUILTIN_CVTPS2PD, UNKNOWN, (int) V2DF_FTYPE_V4SF) -BDESC (OPTION_MASK_ISA_SSE2, 0, CODE_FOR_fix_truncv4sfv4si2, "__builtin_ia32_cvttps2dq", IX86_BUILTIN_CVTTPS2DQ, UNKNOWN, (int) V4SI_FTYPE_V4SF) +BDESC (OPTION_MASK_ISA_SSE2, 0, CODE_FOR_unspec_fix_truncv4sfv4si2, "__builtin_ia32_cvttps2dq", IX86_BUILTIN_CVTTPS2DQ, UNKNOWN, (int) V4SI_FTYPE_V4SF) BDESC (OPTION_MASK_ISA_SSE2, 0, CODE_FOR_addv2df3, "__builtin_ia32_addpd", IX86_BUILTIN_ADDPD, UNKNOWN, (int) V2DF_FTYPE_V2DF_V2DF) BDESC (OPTION_MASK_ISA_SSE2, 0, CODE_FOR_subv2df3, "__builtin_ia32_subpd", IX86_BUILTIN_SUBPD, UNKNOWN, (int) V2DF_FTYPE_V2DF_V2DF) @@ -827,6 +830,9 @@ BDESC (OPTION_MASK_ISA_SSE2, 0, CODE_FOR_nothing, "__builtin_ia32_pcmpgtb128", I BDESC (OPTION_MASK_ISA_SSE2, 0, CODE_FOR_nothing, "__builtin_ia32_pcmpgtw128", IX86_BUILTIN_PCMPGTW128, UNKNOWN, (int) V8HI_FTYPE_V8HI_V8HI) BDESC (OPTION_MASK_ISA_SSE2, 0, CODE_FOR_nothing, "__builtin_ia32_pcmpgtd128", IX86_BUILTIN_PCMPGTD128, UNKNOWN, (int) V4SI_FTYPE_V4SI_V4SI ) +BDESC (OPTION_MASK_ISA_SSE2, 0, CODE_FOR_avx_vmcmpv2df3, "__builtin_ia32_cmpsd", IX86_BUILTIN_CMPSD, UNKNOWN, (int) V2DF_FTYPE_V2DF_V2DF_INT) +BDESC (OPTION_MASK_ISA_SSE2, 0, CODE_FOR_avx_cmpv2df3, "__builtin_ia32_cmppd", IX86_BUILTIN_CMPPD, UNKNOWN, (int) V2DF_FTYPE_V2DF_V2DF_INT) + BDESC (OPTION_MASK_ISA_SSE2, 0, CODE_FOR_umaxv16qi3, "__builtin_ia32_pmaxub128", IX86_BUILTIN_PMAXUB128, UNKNOWN, (int) V16QI_FTYPE_V16QI_V16QI) BDESC (OPTION_MASK_ISA_SSE2, 0, CODE_FOR_smaxv8hi3, "__builtin_ia32_pmaxsw128", IX86_BUILTIN_PMAXSW128, UNKNOWN, (int) V8HI_FTYPE_V8HI_V8HI) BDESC (OPTION_MASK_ISA_SSE2, 0, CODE_FOR_uminv16qi3, "__builtin_ia32_pminub128", IX86_BUILTIN_PMINUB128, UNKNOWN, (int) V16QI_FTYPE_V16QI_V16QI) @@ -1077,10 +1083,6 @@ BDESC (OPTION_MASK_ISA_AVX, 0, CODE_FOR_avx_blendvps256, "__builtin_ia32_blendvp BDESC (OPTION_MASK_ISA_AVX, 0, CODE_FOR_avx_dpps256, "__builtin_ia32_dpps256", IX86_BUILTIN_DPPS256, UNKNOWN, (int) V8SF_FTYPE_V8SF_V8SF_INT) BDESC (OPTION_MASK_ISA_AVX, 0, CODE_FOR_avx_shufpd256, "__builtin_ia32_shufpd256", IX86_BUILTIN_SHUFPD256, UNKNOWN, (int) V4DF_FTYPE_V4DF_V4DF_INT) BDESC (OPTION_MASK_ISA_AVX, 0, CODE_FOR_avx_shufps256, "__builtin_ia32_shufps256", IX86_BUILTIN_SHUFPS256, UNKNOWN, (int) V8SF_FTYPE_V8SF_V8SF_INT) -BDESC (OPTION_MASK_ISA_AVX, 0, CODE_FOR_avx_vmcmpv2df3, "__builtin_ia32_cmpsd", IX86_BUILTIN_CMPSD, UNKNOWN, (int) V2DF_FTYPE_V2DF_V2DF_INT) -BDESC (OPTION_MASK_ISA_AVX, 0, CODE_FOR_avx_vmcmpv4sf3, "__builtin_ia32_cmpss", IX86_BUILTIN_CMPSS, UNKNOWN, (int) V4SF_FTYPE_V4SF_V4SF_INT) -BDESC (OPTION_MASK_ISA_AVX, 0, CODE_FOR_avx_cmpv2df3, "__builtin_ia32_cmppd", IX86_BUILTIN_CMPPD, UNKNOWN, (int) V2DF_FTYPE_V2DF_V2DF_INT) -BDESC (OPTION_MASK_ISA_AVX, 0, CODE_FOR_avx_cmpv4sf3, "__builtin_ia32_cmpps", IX86_BUILTIN_CMPPS, UNKNOWN, (int) V4SF_FTYPE_V4SF_V4SF_INT) BDESC (OPTION_MASK_ISA_AVX, 0, CODE_FOR_avx_cmpv4df3, "__builtin_ia32_cmppd256", IX86_BUILTIN_CMPPD256, UNKNOWN, (int) V4DF_FTYPE_V4DF_V4DF_INT) BDESC (OPTION_MASK_ISA_AVX, 0, CODE_FOR_avx_cmpv8sf3, "__builtin_ia32_cmpps256", IX86_BUILTIN_CMPPS256, UNKNOWN, (int) V8SF_FTYPE_V8SF_V8SF_INT) BDESC (OPTION_MASK_ISA_AVX, 0, CODE_FOR_avx_vextractf128v4df, "__builtin_ia32_vextractf128_pd256", IX86_BUILTIN_EXTRACTF128PD256, UNKNOWN, (int) V2DF_FTYPE_V4DF_INT) @@ -1091,9 +1093,9 @@ BDESC (OPTION_MASK_ISA_AVX, 0, CODE_FOR_floatv8siv8sf2, "__builtin_ia32_cvtdq2ps BDESC (OPTION_MASK_ISA_AVX, 0, CODE_FOR_avx_cvtpd2ps256, "__builtin_ia32_cvtpd2ps256", IX86_BUILTIN_CVTPD2PS256, UNKNOWN, (int) V4SF_FTYPE_V4DF) BDESC (OPTION_MASK_ISA_AVX, 0, CODE_FOR_avx_fix_notruncv8sfv8si, "__builtin_ia32_cvtps2dq256", IX86_BUILTIN_CVTPS2DQ256, UNKNOWN, (int) V8SI_FTYPE_V8SF) BDESC (OPTION_MASK_ISA_AVX, 0, CODE_FOR_avx_cvtps2pd256, "__builtin_ia32_cvtps2pd256", IX86_BUILTIN_CVTPS2PD256, UNKNOWN, (int) V4DF_FTYPE_V4SF) -BDESC (OPTION_MASK_ISA_AVX, 0, CODE_FOR_fix_truncv4dfv4si2, "__builtin_ia32_cvttpd2dq256", IX86_BUILTIN_CVTTPD2DQ256, UNKNOWN, (int) V4SI_FTYPE_V4DF) +BDESC (OPTION_MASK_ISA_AVX, 0, CODE_FOR_unspec_fix_truncv4dfv4si2, "__builtin_ia32_cvttpd2dq256", IX86_BUILTIN_CVTTPD2DQ256, UNKNOWN, (int) V4SI_FTYPE_V4DF) BDESC (OPTION_MASK_ISA_AVX, 0, CODE_FOR_avx_cvtpd2dq256, "__builtin_ia32_cvtpd2dq256", IX86_BUILTIN_CVTPD2DQ256, UNKNOWN, (int) V4SI_FTYPE_V4DF) -BDESC (OPTION_MASK_ISA_AVX, 0, CODE_FOR_fix_truncv8sfv8si2, "__builtin_ia32_cvttps2dq256", IX86_BUILTIN_CVTTPS2DQ256, UNKNOWN, (int) V8SI_FTYPE_V8SF) +BDESC (OPTION_MASK_ISA_AVX, 0, CODE_FOR_unspec_fix_truncv8sfv8si2, "__builtin_ia32_cvttps2dq256", IX86_BUILTIN_CVTTPS2DQ256, UNKNOWN, (int) V8SI_FTYPE_V8SF) BDESC (OPTION_MASK_ISA_AVX, 0, CODE_FOR_avx_vperm2f128v4df3, "__builtin_ia32_vperm2f128_pd256", IX86_BUILTIN_VPERM2F128PD256, UNKNOWN, (int) V4DF_FTYPE_V4DF_V4DF_INT) BDESC (OPTION_MASK_ISA_AVX, 0, CODE_FOR_avx_vperm2f128v8sf3, "__builtin_ia32_vperm2f128_ps256", IX86_BUILTIN_VPERM2F128PS256, UNKNOWN, (int) V8SF_FTYPE_V8SF_V8SF_INT) BDESC (OPTION_MASK_ISA_AVX, 0, CODE_FOR_avx_vperm2f128v8si3, "__builtin_ia32_vperm2f128_si256", IX86_BUILTIN_VPERM2F128SI256, UNKNOWN, (int) V8SI_FTYPE_V8SI_V8SI_INT) @@ -1732,28 +1734,28 @@ BDESC (OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_avx512vl_vextractf128v8sf, "__built BDESC (OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_avx512vl_vextractf128v8si, "__builtin_ia32_extracti32x4_256_mask", IX86_BUILTIN_EXTRACTI32X4_256, UNKNOWN, (int) V4SI_FTYPE_V8SI_INT_V4SI_UQI) BDESC (OPTION_MASK_ISA_AVX512BW | OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_avx512bw_dbpsadbwv16hi_mask, "__builtin_ia32_dbpsadbw256_mask", IX86_BUILTIN_DBPSADBW256, UNKNOWN, (int) V16HI_FTYPE_V32QI_V32QI_INT_V16HI_UHI) BDESC (OPTION_MASK_ISA_AVX512BW | OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_avx512bw_dbpsadbwv8hi_mask, "__builtin_ia32_dbpsadbw128_mask", IX86_BUILTIN_DBPSADBW128, UNKNOWN, (int) V8HI_FTYPE_V16QI_V16QI_INT_V8HI_UQI) -BDESC (OPTION_MASK_ISA_AVX512DQ | OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_fix_truncv4dfv4di2_mask, "__builtin_ia32_cvttpd2qq256_mask", IX86_BUILTIN_CVTTPD2QQ256, UNKNOWN, (int) V4DI_FTYPE_V4DF_V4DI_UQI) -BDESC (OPTION_MASK_ISA_AVX512DQ | OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_fix_truncv2dfv2di2_mask, "__builtin_ia32_cvttpd2qq128_mask", IX86_BUILTIN_CVTTPD2QQ128, UNKNOWN, (int) V2DI_FTYPE_V2DF_V2DI_UQI) -BDESC (OPTION_MASK_ISA_AVX512DQ | OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_fixuns_truncv4dfv4di2_mask, "__builtin_ia32_cvttpd2uqq256_mask", IX86_BUILTIN_CVTTPD2UQQ256, UNKNOWN, (int) V4DI_FTYPE_V4DF_V4DI_UQI) -BDESC (OPTION_MASK_ISA_AVX512DQ | OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_fixuns_truncv2dfv2di2_mask, "__builtin_ia32_cvttpd2uqq128_mask", IX86_BUILTIN_CVTTPD2UQQ128, UNKNOWN, (int) V2DI_FTYPE_V2DF_V2DI_UQI) +BDESC (OPTION_MASK_ISA_AVX512DQ | OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_unspec_fix_truncv4dfv4di2_mask, "__builtin_ia32_cvttpd2qq256_mask", IX86_BUILTIN_CVTTPD2QQ256, UNKNOWN, (int) V4DI_FTYPE_V4DF_V4DI_UQI) +BDESC (OPTION_MASK_ISA_AVX512DQ | OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_unspec_fix_truncv2dfv2di2_mask, "__builtin_ia32_cvttpd2qq128_mask", IX86_BUILTIN_CVTTPD2QQ128, UNKNOWN, (int) V2DI_FTYPE_V2DF_V2DI_UQI) +BDESC (OPTION_MASK_ISA_AVX512DQ | OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_unspec_fixuns_truncv4dfv4di2_mask, "__builtin_ia32_cvttpd2uqq256_mask", IX86_BUILTIN_CVTTPD2UQQ256, UNKNOWN, (int) V4DI_FTYPE_V4DF_V4DI_UQI) +BDESC (OPTION_MASK_ISA_AVX512DQ | OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_unspec_fixuns_truncv2dfv2di2_mask, "__builtin_ia32_cvttpd2uqq128_mask", IX86_BUILTIN_CVTTPD2UQQ128, UNKNOWN, (int) V2DI_FTYPE_V2DF_V2DI_UQI) BDESC (OPTION_MASK_ISA_AVX512DQ | OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_fix_notruncv4dfv4di2_mask, "__builtin_ia32_cvtpd2qq256_mask", IX86_BUILTIN_CVTPD2QQ256, UNKNOWN, (int) V4DI_FTYPE_V4DF_V4DI_UQI) BDESC (OPTION_MASK_ISA_AVX512DQ | OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_fix_notruncv2dfv2di2_mask, "__builtin_ia32_cvtpd2qq128_mask", IX86_BUILTIN_CVTPD2QQ128, UNKNOWN, (int) V2DI_FTYPE_V2DF_V2DI_UQI) BDESC (OPTION_MASK_ISA_AVX512DQ | OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_fixuns_notruncv4dfv4di2_mask, "__builtin_ia32_cvtpd2uqq256_mask", IX86_BUILTIN_CVTPD2UQQ256, UNKNOWN, (int) V4DI_FTYPE_V4DF_V4DI_UQI) BDESC (OPTION_MASK_ISA_AVX512DQ | OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_fixuns_notruncv2dfv2di2_mask, "__builtin_ia32_cvtpd2uqq128_mask", IX86_BUILTIN_CVTPD2UQQ128, UNKNOWN, (int) V2DI_FTYPE_V2DF_V2DI_UQI) BDESC (OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_fixuns_notruncv4dfv4si2_mask, "__builtin_ia32_cvtpd2udq256_mask", IX86_BUILTIN_CVTPD2UDQ256_MASK, UNKNOWN, (int) V4SI_FTYPE_V4DF_V4SI_UQI) BDESC (OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_fixuns_notruncv2dfv2si2_mask, "__builtin_ia32_cvtpd2udq128_mask", IX86_BUILTIN_CVTPD2UDQ128_MASK, UNKNOWN, (int) V4SI_FTYPE_V2DF_V4SI_UQI) -BDESC (OPTION_MASK_ISA_AVX512DQ | OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_fix_truncv4sfv4di2_mask, "__builtin_ia32_cvttps2qq256_mask", IX86_BUILTIN_CVTTPS2QQ256, UNKNOWN, (int) V4DI_FTYPE_V4SF_V4DI_UQI) -BDESC (OPTION_MASK_ISA_AVX512DQ | OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_avx512dq_fix_truncv2sfv2di2_mask, "__builtin_ia32_cvttps2qq128_mask", IX86_BUILTIN_CVTTPS2QQ128, UNKNOWN, (int) V2DI_FTYPE_V4SF_V2DI_UQI) -BDESC (OPTION_MASK_ISA_AVX512DQ | OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_fixuns_truncv4sfv4di2_mask, "__builtin_ia32_cvttps2uqq256_mask", IX86_BUILTIN_CVTTPS2UQQ256, UNKNOWN, (int) V4DI_FTYPE_V4SF_V4DI_UQI) -BDESC (OPTION_MASK_ISA_AVX512DQ | OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_avx512dq_fixuns_truncv2sfv2di2_mask, "__builtin_ia32_cvttps2uqq128_mask", IX86_BUILTIN_CVTTPS2UQQ128, UNKNOWN, (int) V2DI_FTYPE_V4SF_V2DI_UQI) -BDESC (OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_fix_truncv8sfv8si2_mask, "__builtin_ia32_cvttps2dq256_mask", IX86_BUILTIN_CVTTPS2DQ256_MASK, UNKNOWN, (int) V8SI_FTYPE_V8SF_V8SI_UQI) -BDESC (OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_fix_truncv4sfv4si2_mask, "__builtin_ia32_cvttps2dq128_mask", IX86_BUILTIN_CVTTPS2DQ128_MASK, UNKNOWN, (int) V4SI_FTYPE_V4SF_V4SI_UQI) -BDESC (OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_fixuns_truncv8sfv8si2_mask, "__builtin_ia32_cvttps2udq256_mask", IX86_BUILTIN_CVTTPS2UDQ256, UNKNOWN, (int) V8SI_FTYPE_V8SF_V8SI_UQI) -BDESC (OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_fixuns_truncv4sfv4si2_mask, "__builtin_ia32_cvttps2udq128_mask", IX86_BUILTIN_CVTTPS2UDQ128, UNKNOWN, (int) V4SI_FTYPE_V4SF_V4SI_UQI) -BDESC (OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_fix_truncv4dfv4si2_mask, "__builtin_ia32_cvttpd2dq256_mask", IX86_BUILTIN_CVTTPD2DQ256_MASK, UNKNOWN, (int) V4SI_FTYPE_V4DF_V4SI_UQI) -BDESC (OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_sse2_cvttpd2dq_mask, "__builtin_ia32_cvttpd2dq128_mask", IX86_BUILTIN_CVTTPD2DQ128_MASK, UNKNOWN, (int) V4SI_FTYPE_V2DF_V4SI_UQI) -BDESC (OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_fixuns_truncv4dfv4si2_mask, "__builtin_ia32_cvttpd2udq256_mask", IX86_BUILTIN_CVTTPD2UDQ256_MASK, UNKNOWN, (int) V4SI_FTYPE_V4DF_V4SI_UQI) -BDESC (OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_fixuns_truncv2dfv2si2_mask, "__builtin_ia32_cvttpd2udq128_mask", IX86_BUILTIN_CVTTPD2UDQ128_MASK, UNKNOWN, (int) V4SI_FTYPE_V2DF_V4SI_UQI) +BDESC (OPTION_MASK_ISA_AVX512DQ | OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_unspec_fix_truncv4sfv4di2_mask, "__builtin_ia32_cvttps2qq256_mask", IX86_BUILTIN_CVTTPS2QQ256, UNKNOWN, (int) V4DI_FTYPE_V4SF_V4DI_UQI) +BDESC (OPTION_MASK_ISA_AVX512DQ | OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_unspec_avx512dq_fix_truncv2sfv2di2_mask, "__builtin_ia32_cvttps2qq128_mask", IX86_BUILTIN_CVTTPS2QQ128, UNKNOWN, (int) V2DI_FTYPE_V4SF_V2DI_UQI) +BDESC (OPTION_MASK_ISA_AVX512DQ | OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_unspec_fixuns_truncv4sfv4di2_mask, "__builtin_ia32_cvttps2uqq256_mask", IX86_BUILTIN_CVTTPS2UQQ256, UNKNOWN, (int) V4DI_FTYPE_V4SF_V4DI_UQI) +BDESC (OPTION_MASK_ISA_AVX512DQ | OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_unspec_avx512dq_fixuns_truncv2sfv2di2_mask, "__builtin_ia32_cvttps2uqq128_mask", IX86_BUILTIN_CVTTPS2UQQ128, UNKNOWN, (int) V2DI_FTYPE_V4SF_V2DI_UQI) +BDESC (OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_unspec_fix_truncv8sfv8si2_mask, "__builtin_ia32_cvttps2dq256_mask", IX86_BUILTIN_CVTTPS2DQ256_MASK, UNKNOWN, (int) V8SI_FTYPE_V8SF_V8SI_UQI) +BDESC (OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_unspec_fix_truncv4sfv4si2_mask, "__builtin_ia32_cvttps2dq128_mask", IX86_BUILTIN_CVTTPS2DQ128_MASK, UNKNOWN, (int) V4SI_FTYPE_V4SF_V4SI_UQI) +BDESC (OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_unspec_fixuns_truncv8sfv8si2_mask, "__builtin_ia32_cvttps2udq256_mask", IX86_BUILTIN_CVTTPS2UDQ256, UNKNOWN, (int) V8SI_FTYPE_V8SF_V8SI_UQI) +BDESC (OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_unspec_fixuns_truncv4sfv4si2_mask, "__builtin_ia32_cvttps2udq128_mask", IX86_BUILTIN_CVTTPS2UDQ128, UNKNOWN, (int) V4SI_FTYPE_V4SF_V4SI_UQI) +BDESC (OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_unspec_fix_truncv4dfv4si2_mask, "__builtin_ia32_cvttpd2dq256_mask", IX86_BUILTIN_CVTTPD2DQ256_MASK, UNKNOWN, (int) V4SI_FTYPE_V4DF_V4SI_UQI) +BDESC (OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_unspec_sse2_cvttpd2dq_mask, "__builtin_ia32_cvttpd2dq128_mask", IX86_BUILTIN_CVTTPD2DQ128_MASK, UNKNOWN, (int) V4SI_FTYPE_V2DF_V4SI_UQI) +BDESC (OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_unspec_fixuns_truncv4dfv4si2_mask, "__builtin_ia32_cvttpd2udq256_mask", IX86_BUILTIN_CVTTPD2UDQ256_MASK, UNKNOWN, (int) V4SI_FTYPE_V4DF_V4SI_UQI) +BDESC (OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_unspec_fixuns_truncv2dfv2si2_mask, "__builtin_ia32_cvttpd2udq128_mask", IX86_BUILTIN_CVTTPD2UDQ128_MASK, UNKNOWN, (int) V4SI_FTYPE_V2DF_V4SI_UQI) BDESC (OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_avx_cvtpd2dq256_mask, "__builtin_ia32_cvtpd2dq256_mask", IX86_BUILTIN_CVTPD2DQ256_MASK, UNKNOWN, (int) V4SI_FTYPE_V4DF_V4SI_UQI) BDESC (OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_sse2_cvtpd2dq_mask, "__builtin_ia32_cvtpd2dq128_mask", IX86_BUILTIN_CVTPD2DQ128_MASK, UNKNOWN, (int) V4SI_FTYPE_V2DF_V4SI_UQI) BDESC (OPTION_MASK_ISA_AVX512VL, 0, CODE_FOR_floatv4siv4df2_mask, "__builtin_ia32_cvtdq2pd256_mask", IX86_BUILTIN_CVTDQ2PD256_MASK, UNKNOWN, (int) V4DF_FTYPE_V4SI_V4DF_UQI) @@ -2917,26 +2919,26 @@ BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp1 BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_vcvtph2dq_v8si_mask, "__builtin_ia32_vcvtph2dq256_mask", IX86_BUILTIN_VCVTPH2DQ256_MASK, UNKNOWN, (int) V8SI_FTYPE_V8HF_V8SI_UQI) BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_vcvtph2udq_v4si_mask, "__builtin_ia32_vcvtph2udq128_mask", IX86_BUILTIN_VCVTPH2UDQ128_MASK, UNKNOWN, (int) V4SI_FTYPE_V8HF_V4SI_UQI) BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_vcvtph2udq_v8si_mask, "__builtin_ia32_vcvtph2udq256_mask", IX86_BUILTIN_VCVTPH2UDQ256_MASK, UNKNOWN, (int) V8SI_FTYPE_V8HF_V8SI_UQI) -BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_fix_truncv4si2_mask, "__builtin_ia32_vcvttph2dq128_mask", IX86_BUILTIN_VCVTTPH2DQ128_MASK, UNKNOWN, (int) V4SI_FTYPE_V8HF_V4SI_UQI) -BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_fix_truncv8si2_mask, "__builtin_ia32_vcvttph2dq256_mask", IX86_BUILTIN_VCVTTPH2DQ256_MASK, UNKNOWN, (int) V8SI_FTYPE_V8HF_V8SI_UQI) -BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_fixuns_truncv4si2_mask, "__builtin_ia32_vcvttph2udq128_mask", IX86_BUILTIN_VCVTTPH2UDQ128_MASK, UNKNOWN, (int) V4SI_FTYPE_V8HF_V4SI_UQI) -BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_fixuns_truncv8si2_mask, "__builtin_ia32_vcvttph2udq256_mask", IX86_BUILTIN_VCVTTPH2UDQ256_MASK, UNKNOWN, (int) V8SI_FTYPE_V8HF_V8SI_UQI) +BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_unspec_avx512fp16_fix_truncv4si2_mask, "__builtin_ia32_vcvttph2dq128_mask", IX86_BUILTIN_VCVTTPH2DQ128_MASK, UNKNOWN, (int) V4SI_FTYPE_V8HF_V4SI_UQI) +BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_unspec_avx512fp16_fix_truncv8si2_mask, "__builtin_ia32_vcvttph2dq256_mask", IX86_BUILTIN_VCVTTPH2DQ256_MASK, UNKNOWN, (int) V8SI_FTYPE_V8HF_V8SI_UQI) +BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_unspec_avx512fp16_fixuns_truncv4si2_mask, "__builtin_ia32_vcvttph2udq128_mask", IX86_BUILTIN_VCVTTPH2UDQ128_MASK, UNKNOWN, (int) V4SI_FTYPE_V8HF_V4SI_UQI) +BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_unspec_avx512fp16_fixuns_truncv8si2_mask, "__builtin_ia32_vcvttph2udq256_mask", IX86_BUILTIN_VCVTTPH2UDQ256_MASK, UNKNOWN, (int) V8SI_FTYPE_V8HF_V8SI_UQI) BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_vcvtph2qq_v2di_mask, "__builtin_ia32_vcvtph2qq128_mask", IX86_BUILTIN_VCVTPH2QQ128_MASK, UNKNOWN, (int) V2DI_FTYPE_V8HF_V2DI_UQI) BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_vcvtph2qq_v4di_mask, "__builtin_ia32_vcvtph2qq256_mask", IX86_BUILTIN_VCVTPH2QQ256_MASK, UNKNOWN, (int) V4DI_FTYPE_V8HF_V4DI_UQI) BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_vcvtph2uqq_v2di_mask, "__builtin_ia32_vcvtph2uqq128_mask", IX86_BUILTIN_VCVTPH2UQQ128_MASK, UNKNOWN, (int) V2DI_FTYPE_V8HF_V2DI_UQI) BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_vcvtph2uqq_v4di_mask, "__builtin_ia32_vcvtph2uqq256_mask", IX86_BUILTIN_VCVTPH2UQQ256_MASK, UNKNOWN, (int) V4DI_FTYPE_V8HF_V4DI_UQI) -BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_fix_truncv2di2_mask, "__builtin_ia32_vcvttph2qq128_mask", IX86_BUILTIN_VCVTTPH2QQ128_MASK, UNKNOWN, (int) V2DI_FTYPE_V8HF_V2DI_UQI) -BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_fix_truncv4di2_mask, "__builtin_ia32_vcvttph2qq256_mask", IX86_BUILTIN_VCVTTPH2QQ256_MASK, UNKNOWN, (int) V4DI_FTYPE_V8HF_V4DI_UQI) -BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_fixuns_truncv2di2_mask, "__builtin_ia32_vcvttph2uqq128_mask", IX86_BUILTIN_VCVTTPH2UQQ128_MASK, UNKNOWN, (int) V2DI_FTYPE_V8HF_V2DI_UQI) -BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_fixuns_truncv4di2_mask, "__builtin_ia32_vcvttph2uqq256_mask", IX86_BUILTIN_VCVTTPH2UQQ256_MASK, UNKNOWN, (int) V4DI_FTYPE_V8HF_V4DI_UQI) +BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_unspec_avx512fp16_fix_truncv2di2_mask, "__builtin_ia32_vcvttph2qq128_mask", IX86_BUILTIN_VCVTTPH2QQ128_MASK, UNKNOWN, (int) V2DI_FTYPE_V8HF_V2DI_UQI) +BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_unspec_avx512fp16_fix_truncv4di2_mask, "__builtin_ia32_vcvttph2qq256_mask", IX86_BUILTIN_VCVTTPH2QQ256_MASK, UNKNOWN, (int) V4DI_FTYPE_V8HF_V4DI_UQI) +BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_unspec_avx512fp16_fixuns_truncv2di2_mask, "__builtin_ia32_vcvttph2uqq128_mask", IX86_BUILTIN_VCVTTPH2UQQ128_MASK, UNKNOWN, (int) V2DI_FTYPE_V8HF_V2DI_UQI) +BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_unspec_avx512fp16_fixuns_truncv4di2_mask, "__builtin_ia32_vcvttph2uqq256_mask", IX86_BUILTIN_VCVTTPH2UQQ256_MASK, UNKNOWN, (int) V4DI_FTYPE_V8HF_V4DI_UQI) BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_vcvtph2w_v8hi_mask, "__builtin_ia32_vcvtph2w128_mask", IX86_BUILTIN_VCVTPH2W128_MASK, UNKNOWN, (int) V8HI_FTYPE_V8HF_V8HI_UQI) BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_vcvtph2w_v16hi_mask, "__builtin_ia32_vcvtph2w256_mask", IX86_BUILTIN_VCVTPH2W256_MASK, UNKNOWN, (int) V16HI_FTYPE_V16HF_V16HI_UHI) BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_vcvtph2uw_v8hi_mask, "__builtin_ia32_vcvtph2uw128_mask", IX86_BUILTIN_VCVTPH2UW128_MASK, UNKNOWN, (int) V8HI_FTYPE_V8HF_V8HI_UQI) BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_vcvtph2uw_v16hi_mask, "__builtin_ia32_vcvtph2uw256_mask", IX86_BUILTIN_VCVTPH2UW256_MASK, UNKNOWN, (int) V16HI_FTYPE_V16HF_V16HI_UHI) -BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_fix_truncv8hi2_mask, "__builtin_ia32_vcvttph2w128_mask", IX86_BUILTIN_VCVTTPH2W128_MASK, UNKNOWN, (int) V8HI_FTYPE_V8HF_V8HI_UQI) -BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_fix_truncv16hi2_mask, "__builtin_ia32_vcvttph2w256_mask", IX86_BUILTIN_VCVTTPH2W256_MASK, UNKNOWN, (int) V16HI_FTYPE_V16HF_V16HI_UHI) -BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_fixuns_truncv8hi2_mask, "__builtin_ia32_vcvttph2uw128_mask", IX86_BUILTIN_VCVTTPH2UW128_MASK, UNKNOWN, (int) V8HI_FTYPE_V8HF_V8HI_UQI) -BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_fixuns_truncv16hi2_mask, "__builtin_ia32_vcvttph2uw256_mask", IX86_BUILTIN_VCVTTPH2UW256_MASK, UNKNOWN, (int) V16HI_FTYPE_V16HF_V16HI_UHI) +BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_unspec_avx512fp16_fix_truncv8hi2_mask, "__builtin_ia32_vcvttph2w128_mask", IX86_BUILTIN_VCVTTPH2W128_MASK, UNKNOWN, (int) V8HI_FTYPE_V8HF_V8HI_UQI) +BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_unspec_avx512fp16_fix_truncv16hi2_mask, "__builtin_ia32_vcvttph2w256_mask", IX86_BUILTIN_VCVTTPH2W256_MASK, UNKNOWN, (int) V16HI_FTYPE_V16HF_V16HI_UHI) +BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_unspec_avx512fp16_fixuns_truncv8hi2_mask, "__builtin_ia32_vcvttph2uw128_mask", IX86_BUILTIN_VCVTTPH2UW128_MASK, UNKNOWN, (int) V8HI_FTYPE_V8HF_V8HI_UQI) +BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_unspec_avx512fp16_fixuns_truncv16hi2_mask, "__builtin_ia32_vcvttph2uw256_mask", IX86_BUILTIN_VCVTTPH2UW256_MASK, UNKNOWN, (int) V16HI_FTYPE_V16HF_V16HI_UHI) BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_vcvtw2ph_v8hi_mask, "__builtin_ia32_vcvtw2ph128_mask", IX86_BUILTIN_VCVTW2PH128_MASK, UNKNOWN, (int) V8HF_FTYPE_V8HI_V8HF_UQI) BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_vcvtw2ph_v16hi_mask, "__builtin_ia32_vcvtw2ph256_mask", IX86_BUILTIN_VCVTW2PH256_MASK, UNKNOWN, (int) V16HF_FTYPE_V16HI_V16HF_UHI) BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_vcvtuw2ph_v8hi_mask, "__builtin_ia32_vcvtuw2ph128_mask", IX86_BUILTIN_VCVTUW2PH128_MASK, UNKNOWN, (int) V8HF_FTYPE_V8HI_V8HF_UQI) @@ -3050,10 +3052,10 @@ BDESC (OPTION_MASK_ISA_AVX512F, 0, CODE_FOR_sse_cvtsi2ss_round, "__builtin_ia32_ BDESC (OPTION_MASK_ISA_AVX512F | OPTION_MASK_ISA_64BIT, 0, CODE_FOR_sse_cvtsi2ssq_round, "__builtin_ia32_cvtsi2ss64", IX86_BUILTIN_CVTSI2SS64, UNKNOWN, (int) V4SF_FTYPE_V4SF_INT64_INT) BDESC (OPTION_MASK_ISA_AVX512F, 0, CODE_FOR_sse2_cvtss2sd_round, "__builtin_ia32_cvtss2sd_round", IX86_BUILTIN_CVTSS2SD_ROUND, UNKNOWN, (int) V2DF_FTYPE_V2DF_V4SF_INT) BDESC (OPTION_MASK_ISA_AVX512F, 0, CODE_FOR_sse2_cvtss2sd_mask_round, "__builtin_ia32_cvtss2sd_mask_round", IX86_BUILTIN_CVTSS2SD_MASK_ROUND, UNKNOWN, (int) V2DF_FTYPE_V2DF_V4SF_V2DF_UQI_INT) -BDESC (OPTION_MASK_ISA_AVX512F, 0, CODE_FOR_fix_truncv8dfv8si2_mask_round, "__builtin_ia32_cvttpd2dq512_mask", IX86_BUILTIN_CVTTPD2DQ512, UNKNOWN, (int) V8SI_FTYPE_V8DF_V8SI_QI_INT) -BDESC (OPTION_MASK_ISA_AVX512F, 0, CODE_FOR_fixuns_truncv8dfv8si2_mask_round, "__builtin_ia32_cvttpd2udq512_mask", IX86_BUILTIN_CVTTPD2UDQ512, UNKNOWN, (int) V8SI_FTYPE_V8DF_V8SI_QI_INT) -BDESC (OPTION_MASK_ISA_AVX512F, 0, CODE_FOR_fix_truncv16sfv16si2_mask_round, "__builtin_ia32_cvttps2dq512_mask", IX86_BUILTIN_CVTTPS2DQ512, UNKNOWN, (int) V16SI_FTYPE_V16SF_V16SI_HI_INT) -BDESC (OPTION_MASK_ISA_AVX512F, 0, CODE_FOR_fixuns_truncv16sfv16si2_mask_round, "__builtin_ia32_cvttps2udq512_mask", IX86_BUILTIN_CVTTPS2UDQ512, UNKNOWN, (int) V16SI_FTYPE_V16SF_V16SI_HI_INT) +BDESC (OPTION_MASK_ISA_AVX512F, 0, CODE_FOR_unspec_fix_truncv8dfv8si2_mask_round, "__builtin_ia32_cvttpd2dq512_mask", IX86_BUILTIN_CVTTPD2DQ512, UNKNOWN, (int) V8SI_FTYPE_V8DF_V8SI_QI_INT) +BDESC (OPTION_MASK_ISA_AVX512F, 0, CODE_FOR_unspec_fixuns_truncv8dfv8si2_mask_round, "__builtin_ia32_cvttpd2udq512_mask", IX86_BUILTIN_CVTTPD2UDQ512, UNKNOWN, (int) V8SI_FTYPE_V8DF_V8SI_QI_INT) +BDESC (OPTION_MASK_ISA_AVX512F, 0, CODE_FOR_unspec_fix_truncv16sfv16si2_mask_round, "__builtin_ia32_cvttps2dq512_mask", IX86_BUILTIN_CVTTPS2DQ512, UNKNOWN, (int) V16SI_FTYPE_V16SF_V16SI_HI_INT) +BDESC (OPTION_MASK_ISA_AVX512F, 0, CODE_FOR_unspec_fixuns_truncv16sfv16si2_mask_round, "__builtin_ia32_cvttps2udq512_mask", IX86_BUILTIN_CVTTPS2UDQ512, UNKNOWN, (int) V16SI_FTYPE_V16SF_V16SI_HI_INT) BDESC (OPTION_MASK_ISA_AVX512F, 0, CODE_FOR_floatunsv16siv16sf2_mask_round, "__builtin_ia32_cvtudq2ps512_mask", IX86_BUILTIN_CVTUDQ2PS512, UNKNOWN, (int) V16SF_FTYPE_V16SI_V16SF_HI_INT) BDESC (OPTION_MASK_ISA_AVX512F | OPTION_MASK_ISA_64BIT, 0, CODE_FOR_cvtusi2sd64_round, "__builtin_ia32_cvtusi2sd64", IX86_BUILTIN_CVTUSI2SD64, UNKNOWN, (int) V2DF_FTYPE_V2DF_UINT64_INT) BDESC (OPTION_MASK_ISA_AVX512F, 0, CODE_FOR_cvtusi2ss32_round, "__builtin_ia32_cvtusi2ss32", IX86_BUILTIN_CVTUSI2SS32, UNKNOWN, (int) V4SF_FTYPE_V4SF_UINT_INT) @@ -3128,14 +3130,14 @@ BDESC (OPTION_MASK_ISA_AVX512F, 0, CODE_FOR_sse_cvtss2si_round, "__builtin_ia32_ BDESC (OPTION_MASK_ISA_AVX512F | OPTION_MASK_ISA_64BIT, 0, CODE_FOR_sse_cvtss2siq_round, "__builtin_ia32_vcvtss2si64", IX86_BUILTIN_VCVTSS2SI64, UNKNOWN, (int) INT64_FTYPE_V4SF_INT) BDESC (OPTION_MASK_ISA_AVX512F, 0, CODE_FOR_avx512f_vcvtss2usi_round, "__builtin_ia32_vcvtss2usi32", IX86_BUILTIN_VCVTSS2USI32, UNKNOWN, (int) UINT_FTYPE_V4SF_INT) BDESC (OPTION_MASK_ISA_AVX512F | OPTION_MASK_ISA_64BIT, 0, CODE_FOR_avx512f_vcvtss2usiq_round, "__builtin_ia32_vcvtss2usi64", IX86_BUILTIN_VCVTSS2USI64, UNKNOWN, (int) UINT64_FTYPE_V4SF_INT) -BDESC (OPTION_MASK_ISA_AVX512F, 0, CODE_FOR_sse2_cvttsd2si_round, "__builtin_ia32_vcvttsd2si32", IX86_BUILTIN_VCVTTSD2SI32, UNKNOWN, (int) INT_FTYPE_V2DF_INT) -BDESC (OPTION_MASK_ISA_AVX512F | OPTION_MASK_ISA_64BIT, 0, CODE_FOR_sse2_cvttsd2siq_round, "__builtin_ia32_vcvttsd2si64", IX86_BUILTIN_VCVTTSD2SI64, UNKNOWN, (int) INT64_FTYPE_V2DF_INT) -BDESC (OPTION_MASK_ISA_AVX512F, 0, CODE_FOR_avx512f_vcvttsd2usi_round, "__builtin_ia32_vcvttsd2usi32", IX86_BUILTIN_VCVTTSD2USI32, UNKNOWN, (int) UINT_FTYPE_V2DF_INT) -BDESC (OPTION_MASK_ISA_AVX512F | OPTION_MASK_ISA_64BIT, 0, CODE_FOR_avx512f_vcvttsd2usiq_round, "__builtin_ia32_vcvttsd2usi64", IX86_BUILTIN_VCVTTSD2USI64, UNKNOWN, (int) UINT64_FTYPE_V2DF_INT) -BDESC (OPTION_MASK_ISA_AVX512F, 0, CODE_FOR_sse_cvttss2si_round, "__builtin_ia32_vcvttss2si32", IX86_BUILTIN_VCVTTSS2SI32, UNKNOWN, (int) INT_FTYPE_V4SF_INT) -BDESC (OPTION_MASK_ISA_AVX512F | OPTION_MASK_ISA_64BIT, 0, CODE_FOR_sse_cvttss2siq_round, "__builtin_ia32_vcvttss2si64", IX86_BUILTIN_VCVTTSS2SI64, UNKNOWN, (int) INT64_FTYPE_V4SF_INT) -BDESC (OPTION_MASK_ISA_AVX512F, 0, CODE_FOR_avx512f_vcvttss2usi_round, "__builtin_ia32_vcvttss2usi32", IX86_BUILTIN_VCVTTSS2USI32, UNKNOWN, (int) UINT_FTYPE_V4SF_INT) -BDESC (OPTION_MASK_ISA_AVX512F | OPTION_MASK_ISA_64BIT, 0, CODE_FOR_avx512f_vcvttss2usiq_round, "__builtin_ia32_vcvttss2usi64", IX86_BUILTIN_VCVTTSS2USI64, UNKNOWN, (int) UINT64_FTYPE_V4SF_INT) +BDESC (OPTION_MASK_ISA_AVX512F, 0, CODE_FOR_unspec_sse2_cvttsd2si_round, "__builtin_ia32_vcvttsd2si32", IX86_BUILTIN_VCVTTSD2SI32, UNKNOWN, (int) INT_FTYPE_V2DF_INT) +BDESC (OPTION_MASK_ISA_AVX512F | OPTION_MASK_ISA_64BIT, 0, CODE_FOR_unspec_sse2_cvttsd2siq_round, "__builtin_ia32_vcvttsd2si64", IX86_BUILTIN_VCVTTSD2SI64, UNKNOWN, (int) INT64_FTYPE_V2DF_INT) +BDESC (OPTION_MASK_ISA_AVX512F, 0, CODE_FOR_unspec_avx512f_vcvttsd2usi_round, "__builtin_ia32_vcvttsd2usi32", IX86_BUILTIN_VCVTTSD2USI32, UNKNOWN, (int) UINT_FTYPE_V2DF_INT) +BDESC (OPTION_MASK_ISA_AVX512F | OPTION_MASK_ISA_64BIT, 0, CODE_FOR_unspec_avx512f_vcvttsd2usiq_round, "__builtin_ia32_vcvttsd2usi64", IX86_BUILTIN_VCVTTSD2USI64, UNKNOWN, (int) UINT64_FTYPE_V2DF_INT) +BDESC (OPTION_MASK_ISA_AVX512F, 0, CODE_FOR_unspec_sse_cvttss2si_round, "__builtin_ia32_vcvttss2si32", IX86_BUILTIN_VCVTTSS2SI32, UNKNOWN, (int) INT_FTYPE_V4SF_INT) +BDESC (OPTION_MASK_ISA_AVX512F | OPTION_MASK_ISA_64BIT, 0, CODE_FOR_unspec_sse_cvttss2siq_round, "__builtin_ia32_vcvttss2si64", IX86_BUILTIN_VCVTTSS2SI64, UNKNOWN, (int) INT64_FTYPE_V4SF_INT) +BDESC (OPTION_MASK_ISA_AVX512F, 0, CODE_FOR_unspec_avx512f_vcvttss2usi_round, "__builtin_ia32_vcvttss2usi32", IX86_BUILTIN_VCVTTSS2USI32, UNKNOWN, (int) UINT_FTYPE_V4SF_INT) +BDESC (OPTION_MASK_ISA_AVX512F | OPTION_MASK_ISA_64BIT, 0, CODE_FOR_unspec_avx512f_vcvttss2usiq_round, "__builtin_ia32_vcvttss2usi64", IX86_BUILTIN_VCVTTSS2USI64, UNKNOWN, (int) UINT64_FTYPE_V4SF_INT) BDESC (OPTION_MASK_ISA_AVX512F, OPTION_MASK_ISA2_EVEX512, CODE_FOR_avx512f_fmadd_v8df_mask_round, "__builtin_ia32_vfmaddpd512_mask", IX86_BUILTIN_VFMADDPD512_MASK, UNKNOWN, (int) V8DF_FTYPE_V8DF_V8DF_V8DF_UQI_INT) BDESC (OPTION_MASK_ISA_AVX512F, OPTION_MASK_ISA2_EVEX512, CODE_FOR_avx512f_fmadd_v8df_mask3_round, "__builtin_ia32_vfmaddpd512_mask3", IX86_BUILTIN_VFMADDPD512_MASK3, UNKNOWN, (int) V8DF_FTYPE_V8DF_V8DF_V8DF_UQI_INT) BDESC (OPTION_MASK_ISA_AVX512F, OPTION_MASK_ISA2_EVEX512, CODE_FOR_avx512f_fmadd_v8df_maskz_round, "__builtin_ia32_vfmaddpd512_maskz", IX86_BUILTIN_VFMADDPD512_MASKZ, UNKNOWN, (int) V8DF_FTYPE_V8DF_V8DF_V8DF_UQI_INT) @@ -3194,10 +3196,10 @@ BDESC (OPTION_MASK_ISA_AVX512DQ, OPTION_MASK_ISA2_EVEX512, CODE_FOR_floatv8div8s BDESC (OPTION_MASK_ISA_AVX512DQ, OPTION_MASK_ISA2_EVEX512, CODE_FOR_floatunsv8div8sf2_mask_round, "__builtin_ia32_cvtuqq2ps512_mask", IX86_BUILTIN_CVTUQQ2PS512, UNKNOWN, (int) V8SF_FTYPE_V8DI_V8SF_QI_INT) BDESC (OPTION_MASK_ISA_AVX512DQ, OPTION_MASK_ISA2_EVEX512, CODE_FOR_floatv8div8df2_mask_round, "__builtin_ia32_cvtqq2pd512_mask", IX86_BUILTIN_CVTQQ2PD512, UNKNOWN, (int) V8DF_FTYPE_V8DI_V8DF_QI_INT) BDESC (OPTION_MASK_ISA_AVX512DQ, OPTION_MASK_ISA2_EVEX512, CODE_FOR_floatunsv8div8df2_mask_round, "__builtin_ia32_cvtuqq2pd512_mask", IX86_BUILTIN_CVTUQQ2PD512, UNKNOWN, (int) V8DF_FTYPE_V8DI_V8DF_QI_INT) -BDESC (OPTION_MASK_ISA_AVX512DQ, OPTION_MASK_ISA2_EVEX512, CODE_FOR_fix_truncv8sfv8di2_mask_round, "__builtin_ia32_cvttps2qq512_mask", IX86_BUILTIN_CVTTPS2QQ512, UNKNOWN, (int) V8DI_FTYPE_V8SF_V8DI_QI_INT) -BDESC (OPTION_MASK_ISA_AVX512DQ, OPTION_MASK_ISA2_EVEX512, CODE_FOR_fixuns_truncv8sfv8di2_mask_round, "__builtin_ia32_cvttps2uqq512_mask", IX86_BUILTIN_CVTTPS2UQQ512, UNKNOWN, (int) V8DI_FTYPE_V8SF_V8DI_QI_INT) -BDESC (OPTION_MASK_ISA_AVX512DQ, OPTION_MASK_ISA2_EVEX512, CODE_FOR_fix_truncv8dfv8di2_mask_round, "__builtin_ia32_cvttpd2qq512_mask", IX86_BUILTIN_CVTTPD2QQ512, UNKNOWN, (int) V8DI_FTYPE_V8DF_V8DI_QI_INT) -BDESC (OPTION_MASK_ISA_AVX512DQ, OPTION_MASK_ISA2_EVEX512, CODE_FOR_fixuns_truncv8dfv8di2_mask_round, "__builtin_ia32_cvttpd2uqq512_mask", IX86_BUILTIN_CVTTPD2UQQ512, UNKNOWN, (int) V8DI_FTYPE_V8DF_V8DI_QI_INT) +BDESC (OPTION_MASK_ISA_AVX512DQ, OPTION_MASK_ISA2_EVEX512, CODE_FOR_unspec_fix_truncv8sfv8di2_mask_round, "__builtin_ia32_cvttps2qq512_mask", IX86_BUILTIN_CVTTPS2QQ512, UNKNOWN, (int) V8DI_FTYPE_V8SF_V8DI_QI_INT) +BDESC (OPTION_MASK_ISA_AVX512DQ, OPTION_MASK_ISA2_EVEX512, CODE_FOR_unspec_fixuns_truncv8sfv8di2_mask_round, "__builtin_ia32_cvttps2uqq512_mask", IX86_BUILTIN_CVTTPS2UQQ512, UNKNOWN, (int) V8DI_FTYPE_V8SF_V8DI_QI_INT) +BDESC (OPTION_MASK_ISA_AVX512DQ, OPTION_MASK_ISA2_EVEX512, CODE_FOR_unspec_fix_truncv8dfv8di2_mask_round, "__builtin_ia32_cvttpd2qq512_mask", IX86_BUILTIN_CVTTPD2QQ512, UNKNOWN, (int) V8DI_FTYPE_V8DF_V8DI_QI_INT) +BDESC (OPTION_MASK_ISA_AVX512DQ, OPTION_MASK_ISA2_EVEX512, CODE_FOR_unspec_fixuns_truncv8dfv8di2_mask_round, "__builtin_ia32_cvttpd2uqq512_mask", IX86_BUILTIN_CVTTPD2UQQ512, UNKNOWN, (int) V8DI_FTYPE_V8DF_V8DI_QI_INT) BDESC (OPTION_MASK_ISA_AVX512DQ, OPTION_MASK_ISA2_EVEX512, CODE_FOR_avx512dq_rangepv16sf_mask_round, "__builtin_ia32_rangeps512_mask", IX86_BUILTIN_RANGEPS512, UNKNOWN, (int) V16SF_FTYPE_V16SF_V16SF_INT_V16SF_HI_INT) BDESC (OPTION_MASK_ISA_AVX512DQ, OPTION_MASK_ISA2_EVEX512, CODE_FOR_avx512dq_rangepv8df_mask_round, "__builtin_ia32_rangepd512_mask", IX86_BUILTIN_RANGEPD512, UNKNOWN, (int) V8DF_FTYPE_V8DF_V8DF_INT_V8DF_QI_INT) @@ -3230,16 +3232,16 @@ BDESC (0, OPTION_MASK_ISA2_AVX512FP16 | OPTION_MASK_ISA2_EVEX512, CODE_FOR_avx51 BDESC (0, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512f_vgetmantv8hf_mask_round, "__builtin_ia32_getmantsh_mask_round", IX86_BUILTIN_GETMANTSH_MASK_ROUND, UNKNOWN, (int) V8HF_FTYPE_V8HF_V8HF_INT_V8HF_UQI_INT) BDESC (0, OPTION_MASK_ISA2_AVX512FP16 | OPTION_MASK_ISA2_EVEX512, CODE_FOR_avx512fp16_vcvtph2dq_v16si_mask_round, "__builtin_ia32_vcvtph2dq512_mask_round", IX86_BUILTIN_VCVTPH2DQ512_MASK_ROUND, UNKNOWN, (int) V16SI_FTYPE_V16HF_V16SI_UHI_INT) BDESC (0, OPTION_MASK_ISA2_AVX512FP16 | OPTION_MASK_ISA2_EVEX512, CODE_FOR_avx512fp16_vcvtph2udq_v16si_mask_round, "__builtin_ia32_vcvtph2udq512_mask_round", IX86_BUILTIN_VCVTPH2UDQ512_MASK_ROUND, UNKNOWN, (int) V16SI_FTYPE_V16HF_V16SI_UHI_INT) -BDESC (0, OPTION_MASK_ISA2_AVX512FP16 | OPTION_MASK_ISA2_EVEX512, CODE_FOR_avx512fp16_fix_truncv16si2_mask_round, "__builtin_ia32_vcvttph2dq512_mask_round", IX86_BUILTIN_VCVTTPH2DQ512_MASK_ROUND, UNKNOWN, (int) V16SI_FTYPE_V16HF_V16SI_UHI_INT) -BDESC (0, OPTION_MASK_ISA2_AVX512FP16 | OPTION_MASK_ISA2_EVEX512, CODE_FOR_avx512fp16_fixuns_truncv16si2_mask_round, "__builtin_ia32_vcvttph2udq512_mask_round", IX86_BUILTIN_VCVTTPH2UDQ512_MASK_ROUND, UNKNOWN, (int) V16SI_FTYPE_V16HF_V16SI_UHI_INT) +BDESC (0, OPTION_MASK_ISA2_AVX512FP16 | OPTION_MASK_ISA2_EVEX512, CODE_FOR_unspec_avx512fp16_fix_truncv16si2_mask_round, "__builtin_ia32_vcvttph2dq512_mask_round", IX86_BUILTIN_VCVTTPH2DQ512_MASK_ROUND, UNKNOWN, (int) V16SI_FTYPE_V16HF_V16SI_UHI_INT) +BDESC (0, OPTION_MASK_ISA2_AVX512FP16 | OPTION_MASK_ISA2_EVEX512, CODE_FOR_unspec_avx512fp16_fixuns_truncv16si2_mask_round, "__builtin_ia32_vcvttph2udq512_mask_round", IX86_BUILTIN_VCVTTPH2UDQ512_MASK_ROUND, UNKNOWN, (int) V16SI_FTYPE_V16HF_V16SI_UHI_INT) BDESC (0, OPTION_MASK_ISA2_AVX512FP16 | OPTION_MASK_ISA2_EVEX512, CODE_FOR_avx512fp16_vcvtph2qq_v8di_mask_round, "__builtin_ia32_vcvtph2qq512_mask_round", IX86_BUILTIN_VCVTPH2QQ512_MASK_ROUND, UNKNOWN, (int) V8DI_FTYPE_V8HF_V8DI_UQI_INT) BDESC (0, OPTION_MASK_ISA2_AVX512FP16 | OPTION_MASK_ISA2_EVEX512, CODE_FOR_avx512fp16_vcvtph2uqq_v8di_mask_round, "__builtin_ia32_vcvtph2uqq512_mask_round", IX86_BUILTIN_VCVTPH2UQQ512_MASK_ROUND, UNKNOWN, (int) V8DI_FTYPE_V8HF_V8DI_UQI_INT) -BDESC (0, OPTION_MASK_ISA2_AVX512FP16 | OPTION_MASK_ISA2_EVEX512, CODE_FOR_avx512fp16_fix_truncv8di2_mask_round, "__builtin_ia32_vcvttph2qq512_mask_round", IX86_BUILTIN_VCVTTPH2QQ512_MASK_ROUND, UNKNOWN, (int) V8DI_FTYPE_V8HF_V8DI_UQI_INT) -BDESC (0, OPTION_MASK_ISA2_AVX512FP16 | OPTION_MASK_ISA2_EVEX512, CODE_FOR_avx512fp16_fixuns_truncv8di2_mask_round, "__builtin_ia32_vcvttph2uqq512_mask_round", IX86_BUILTIN_VCVTTPH2UQQ512_MASK_ROUND, UNKNOWN, (int) V8DI_FTYPE_V8HF_V8DI_UQI_INT) +BDESC (0, OPTION_MASK_ISA2_AVX512FP16 | OPTION_MASK_ISA2_EVEX512, CODE_FOR_unspec_avx512fp16_fix_truncv8di2_mask_round, "__builtin_ia32_vcvttph2qq512_mask_round", IX86_BUILTIN_VCVTTPH2QQ512_MASK_ROUND, UNKNOWN, (int) V8DI_FTYPE_V8HF_V8DI_UQI_INT) +BDESC (0, OPTION_MASK_ISA2_AVX512FP16 | OPTION_MASK_ISA2_EVEX512, CODE_FOR_unspec_avx512fp16_fixuns_truncv8di2_mask_round, "__builtin_ia32_vcvttph2uqq512_mask_round", IX86_BUILTIN_VCVTTPH2UQQ512_MASK_ROUND, UNKNOWN, (int) V8DI_FTYPE_V8HF_V8DI_UQI_INT) BDESC (0, OPTION_MASK_ISA2_AVX512FP16 | OPTION_MASK_ISA2_EVEX512, CODE_FOR_avx512fp16_vcvtph2w_v32hi_mask_round, "__builtin_ia32_vcvtph2w512_mask_round", IX86_BUILTIN_VCVTPH2W512_MASK_ROUND, UNKNOWN, (int) V32HI_FTYPE_V32HF_V32HI_USI_INT) BDESC (0, OPTION_MASK_ISA2_AVX512FP16 | OPTION_MASK_ISA2_EVEX512, CODE_FOR_avx512fp16_vcvtph2uw_v32hi_mask_round, "__builtin_ia32_vcvtph2uw512_mask_round", IX86_BUILTIN_VCVTPH2UW512_MASK_ROUND, UNKNOWN, (int) V32HI_FTYPE_V32HF_V32HI_USI_INT) -BDESC (0, OPTION_MASK_ISA2_AVX512FP16 | OPTION_MASK_ISA2_EVEX512, CODE_FOR_avx512fp16_fix_truncv32hi2_mask_round, "__builtin_ia32_vcvttph2w512_mask_round", IX86_BUILTIN_VCVTTPH2W512_MASK_ROUND, UNKNOWN, (int) V32HI_FTYPE_V32HF_V32HI_USI_INT) -BDESC (0, OPTION_MASK_ISA2_AVX512FP16 | OPTION_MASK_ISA2_EVEX512, CODE_FOR_avx512fp16_fixuns_truncv32hi2_mask_round, "__builtin_ia32_vcvttph2uw512_mask_round", IX86_BUILTIN_VCVTTPH2UW512_MASK_ROUND, UNKNOWN, (int) V32HI_FTYPE_V32HF_V32HI_USI_INT) +BDESC (0, OPTION_MASK_ISA2_AVX512FP16 | OPTION_MASK_ISA2_EVEX512, CODE_FOR_unspec_avx512fp16_fix_truncv32hi2_mask_round, "__builtin_ia32_vcvttph2w512_mask_round", IX86_BUILTIN_VCVTTPH2W512_MASK_ROUND, UNKNOWN, (int) V32HI_FTYPE_V32HF_V32HI_USI_INT) +BDESC (0, OPTION_MASK_ISA2_AVX512FP16 | OPTION_MASK_ISA2_EVEX512, CODE_FOR_unspec_avx512fp16_fixuns_truncv32hi2_mask_round, "__builtin_ia32_vcvttph2uw512_mask_round", IX86_BUILTIN_VCVTTPH2UW512_MASK_ROUND, UNKNOWN, (int) V32HI_FTYPE_V32HF_V32HI_USI_INT) BDESC (0, OPTION_MASK_ISA2_AVX512FP16 | OPTION_MASK_ISA2_EVEX512, CODE_FOR_avx512fp16_vcvtw2ph_v32hi_mask_round, "__builtin_ia32_vcvtw2ph512_mask_round", IX86_BUILTIN_VCVTW2PH512_MASK_ROUND, UNKNOWN, (int) V32HF_FTYPE_V32HI_V32HF_USI_INT) BDESC (0, OPTION_MASK_ISA2_AVX512FP16 | OPTION_MASK_ISA2_EVEX512, CODE_FOR_avx512fp16_vcvtuw2ph_v32hi_mask_round, "__builtin_ia32_vcvtuw2ph512_mask_round", IX86_BUILTIN_VCVTUW2PH512_MASK_ROUND, UNKNOWN, (int) V32HF_FTYPE_V32HI_V32HF_USI_INT) BDESC (0, OPTION_MASK_ISA2_AVX512FP16 | OPTION_MASK_ISA2_EVEX512, CODE_FOR_avx512fp16_vcvtdq2ph_v16si_mask_round, "__builtin_ia32_vcvtdq2ph512_mask_round", IX86_BUILTIN_VCVTDQ2PH512_MASK_ROUND, UNKNOWN, (int) V16HF_FTYPE_V16SI_V16HF_UHI_INT) @@ -3250,10 +3252,10 @@ BDESC (0, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_vcvtsh2si_round, "__b BDESC (OPTION_MASK_ISA_64BIT, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_vcvtsh2siq_round, "__builtin_ia32_vcvtsh2si64_round", IX86_BUILTIN_VCVTSH2SI64_ROUND, UNKNOWN, (int) INT64_FTYPE_V8HF_INT) BDESC (0, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_vcvtsh2usi_round, "__builtin_ia32_vcvtsh2usi32_round", IX86_BUILTIN_VCVTSH2USI32_ROUND, UNKNOWN, (int) UINT_FTYPE_V8HF_INT) BDESC (OPTION_MASK_ISA_64BIT, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_vcvtsh2usiq_round, "__builtin_ia32_vcvtsh2usi64_round", IX86_BUILTIN_VCVTSH2USI64_ROUND, UNKNOWN, (int) UINT64_FTYPE_V8HF_INT) -BDESC (0, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_fix_truncsi2_round, "__builtin_ia32_vcvttsh2si32_round", IX86_BUILTIN_VCVTTSH2SI32_ROUND, UNKNOWN, (int) INT_FTYPE_V8HF_INT) -BDESC (OPTION_MASK_ISA_64BIT, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_fix_truncdi2_round, "__builtin_ia32_vcvttsh2si64_round", IX86_BUILTIN_VCVTTSH2SI64_ROUND, UNKNOWN, (int) INT64_FTYPE_V8HF_INT) -BDESC (0, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_fixuns_truncsi2_round, "__builtin_ia32_vcvttsh2usi32_round", IX86_BUILTIN_VCVTTSH2USI32_ROUND, UNKNOWN, (int) UINT_FTYPE_V8HF_INT) -BDESC (OPTION_MASK_ISA_64BIT, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_fixuns_truncdi2_round, "__builtin_ia32_vcvttsh2usi64_round", IX86_BUILTIN_VCVTTSH2USI64_ROUND, UNKNOWN, (int) UINT64_FTYPE_V8HF_INT) +BDESC (0, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_unspec_avx512fp16_fix_truncsi2_round, "__builtin_ia32_vcvttsh2si32_round", IX86_BUILTIN_VCVTTSH2SI32_ROUND, UNKNOWN, (int) INT_FTYPE_V8HF_INT) +BDESC (OPTION_MASK_ISA_64BIT, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_unspec_avx512fp16_fix_truncdi2_round, "__builtin_ia32_vcvttsh2si64_round", IX86_BUILTIN_VCVTTSH2SI64_ROUND, UNKNOWN, (int) INT64_FTYPE_V8HF_INT) +BDESC (0, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_unspec_avx512fp16_fixuns_truncsi2_round, "__builtin_ia32_vcvttsh2usi32_round", IX86_BUILTIN_VCVTTSH2USI32_ROUND, UNKNOWN, (int) UINT_FTYPE_V8HF_INT) +BDESC (OPTION_MASK_ISA_64BIT, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_unspec_avx512fp16_fixuns_truncdi2_round, "__builtin_ia32_vcvttsh2usi64_round", IX86_BUILTIN_VCVTTSH2USI64_ROUND, UNKNOWN, (int) UINT64_FTYPE_V8HF_INT) BDESC (0, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_vcvtsi2sh_round, "__builtin_ia32_vcvtsi2sh32_round", IX86_BUILTIN_VCVTSI2SH32_ROUND, UNKNOWN, (int) V8HF_FTYPE_V8HF_INT_INT) BDESC (OPTION_MASK_ISA_64BIT, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_vcvtsi2shq_round, "__builtin_ia32_vcvtsi2sh64_round", IX86_BUILTIN_VCVTSI2SH64_ROUND, UNKNOWN, (int) V8HF_FTYPE_V8HF_INT64_INT) BDESC (0, OPTION_MASK_ISA2_AVX512FP16, CODE_FOR_avx512fp16_vcvtusi2sh_round, "__builtin_ia32_vcvtusi2sh32_round", IX86_BUILTIN_VCVTUSI2SH32_ROUND, UNKNOWN, (int) V8HF_FTYPE_V8HF_UINT_INT) diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc index d1d396a871305..5c29ee1353f76 100644 --- a/gcc/config/i386/i386-expand.cc +++ b/gcc/config/i386/i386-expand.cc @@ -11707,6 +11707,8 @@ ix86_expand_args_builtin (const struct builtin_description *d, tree arg = CALL_EXPR_ARG (exp, i); rtx op = expand_normal (arg); machine_mode mode = insn_p->operand[i + 1].mode; + /* Need to fixup modeless constant before testing predicate. */ + op = fixup_modeless_constant (op, mode); bool match = insn_p->operand[i + 1].predicate (op, mode); if (second_arg_count && i == 1) @@ -11833,6 +11835,12 @@ ix86_expand_args_builtin (const struct builtin_description *d, case CODE_FOR_avx_vmcmpv4sf3: case CODE_FOR_avx_cmpv2df3: case CODE_FOR_avx_cmpv4sf3: + if (CONST_INT_P (op) && IN_RANGE (INTVAL (op), 8, 31)) + { + error ("'%s' needs isa option %s", d->name, "-mavx"); + return const0_rtx; + } + /* FALLTHRU */ case CODE_FOR_avx_cmpv4df3: case CODE_FOR_avx_cmpv8sf3: case CODE_FOR_avx512f_cmpv8df3_mask: @@ -11873,13 +11881,15 @@ ix86_expand_args_builtin (const struct builtin_description *d, /* If we aren't optimizing, only allow one memory operand to be generated. */ if (memory_operand (op, mode)) - num_memory++; - - op = fixup_modeless_constant (op, mode); + { + num_memory++; + if (!optimize && num_memory > 1) + op = copy_to_mode_reg (mode, op); + } if (GET_MODE (op) == mode || GET_MODE (op) == VOIDmode) { - if (optimize || !match || num_memory > 1) + if (!match) op = copy_to_mode_reg (mode, op); } else @@ -23653,8 +23663,8 @@ ix86_vectorize_vec_perm_const (machine_mode vmode, machine_mode op_mode, if (GET_MODE_SIZE (vmode) == 64 && !TARGET_EVEX512) return false; - /* For HF mode vector, convert it to HI using subreg. */ - if (GET_MODE_INNER (vmode) == HFmode) + /* For HF and BF mode vector, convert it to HI using subreg. */ + if (GET_MODE_INNER (vmode) == HFmode || GET_MODE_INNER (vmode) == BFmode) { machine_mode orig_mode = vmode; vmode = mode_for_vector (HImode, @@ -25516,4 +25526,614 @@ ix86_gen_ccmp_next (rtx_insn **prep_seq, rtx_insn **gen_seq, rtx prev, return gen_rtx_fmt_ee ((rtx_code) cmp_code, VOIDmode, target, const0_rtx); } +/* Attempt to convert a CONST_VECTOR into a bcst_mem_operand. + Returns NULL_RTX if X is cannot be expressed as a suitable + VEC_DUPLICATE in mode MODE. */ + +static rtx +ix86_gen_bcst_mem (machine_mode mode, rtx x) +{ + if (!TARGET_AVX512F + || GET_CODE (x) != CONST_VECTOR + || (!TARGET_AVX512VL + && (GET_MODE_SIZE (mode) != 64 || !TARGET_EVEX512)) + || !VALID_BCST_MODE_P (GET_MODE_INNER (mode)) + /* Disallow HFmode broadcast. */ + || GET_MODE_SIZE (GET_MODE_INNER (mode)) < 4) + return NULL_RTX; + + rtx cst = CONST_VECTOR_ELT (x, 0); + if (!CONST_SCALAR_INT_P (cst) + && !CONST_DOUBLE_P (cst) + && !CONST_FIXED_P (cst)) + return NULL_RTX; + + int n_elts = GET_MODE_NUNITS (mode); + if (CONST_VECTOR_NUNITS (x) != n_elts) + return NULL_RTX; + + for (int i = 1; i < n_elts; i++) + if (!rtx_equal_p (cst, CONST_VECTOR_ELT (x, i))) + return NULL_RTX; + + rtx mem = force_const_mem (GET_MODE_INNER (mode), cst); + return gen_rtx_VEC_DUPLICATE (mode, validize_mem (mem)); +} + +/* Determine the ternlog immediate index that implements 3-operand + ternary logic expression OP. This uses and modifies the 3 element + array ARGS to record and check the leaves, either 3 REGs, or 2 REGs + and MEM. Returns an index between 0 and 255 for a valid ternlog, + or -1 if the expression isn't suitable. */ + +int +ix86_ternlog_idx (rtx op, rtx *args) +{ + int idx0, idx1; + + if (!op) + return -1; + + switch (GET_CODE (op)) + { + case REG: + if (!args[0]) + { + args[0] = op; + return 0xf0; + } + if (REGNO (op) == REGNO (args[0])) + return 0xf0; + if (!args[1]) + { + args[1] = op; + return 0xcc; + } + if (REGNO (op) == REGNO (args[1])) + return 0xcc; + if (!args[2]) + { + args[2] = op; + return 0xaa; + } + if (REG_P (args[2]) && REGNO (op) == REGNO (args[2])) + return 0xaa; + return -1; + + case VEC_DUPLICATE: + if (!bcst_mem_operand (op, GET_MODE (op))) + return -1; + /* FALLTHRU */ + + case MEM: + if (!memory_operand (op, GET_MODE (op))) + return -1; + if (MEM_P (op) + && MEM_VOLATILE_P (op) + && !volatile_ok) + return -1; + /* FALLTHRU */ + + case CONST_VECTOR: + if (!args[2]) + { + args[2] = op; + return 0xaa; + } + /* Maximum of one volatile memory reference per expression. */ + if (side_effects_p (op) && side_effects_p (args[2])) + return -1; + if (rtx_equal_p (op, args[2])) + return 0xaa; + /* Check if one CONST_VECTOR is the ones-complement of the other. */ + if (GET_CODE (op) == CONST_VECTOR + && GET_CODE (args[2]) == CONST_VECTOR + && rtx_equal_p (simplify_const_unary_operation (NOT, GET_MODE (op), + op, GET_MODE (op)), + args[2])) + return 0x55; + return -1; + + case SUBREG: + if (GET_MODE_SIZE (GET_MODE (SUBREG_REG (op))) + != GET_MODE_SIZE (GET_MODE (op))) + return -1; + return ix86_ternlog_idx (SUBREG_REG (op), args); + + case NOT: + idx0 = ix86_ternlog_idx (XEXP (op, 0), args); + return (idx0 >= 0) ? idx0 ^ 0xff : -1; + + case AND: + idx0 = ix86_ternlog_idx (XEXP (op, 0), args); + if (idx0 < 0) + return -1; + idx1 = ix86_ternlog_idx (XEXP (op, 1), args); + return (idx1 >= 0) ? idx0 & idx1 : -1; + + case IOR: + idx0 = ix86_ternlog_idx (XEXP (op, 0), args); + if (idx0 < 0) + return -1; + idx1 = ix86_ternlog_idx (XEXP (op, 1), args); + return (idx1 >= 0) ? idx0 | idx1 : -1; + + case XOR: + idx0 = ix86_ternlog_idx (XEXP (op, 0), args); + if (idx0 < 0) + return -1; + if (vector_all_ones_operand (XEXP (op, 1), GET_MODE (op))) + return idx0 ^ 0xff; + idx1 = ix86_ternlog_idx (XEXP (op, 1), args); + return (idx1 >= 0) ? idx0 ^ idx1 : -1; + + case UNSPEC: + if (XINT (op, 1) != UNSPEC_VTERNLOG + || XVECLEN (op, 0) != 4 + || !CONST_INT_P (XVECEXP (op, 0, 3))) + return -1; + + /* TODO: Handle permuted operands. */ + if (ix86_ternlog_idx (XVECEXP (op, 0, 0), args) != 0xf0 + || ix86_ternlog_idx (XVECEXP (op, 0, 1), args) != 0xcc + || ix86_ternlog_idx (XVECEXP (op, 0, 2), args) != 0xaa) + return -1; + return INTVAL (XVECEXP (op, 0, 3)); + + default: + return -1; + } +} + +/* Return TRUE if OP (in mode MODE) is the leaf of a ternary logic + expression, such as a register or a memory reference. */ + +bool +ix86_ternlog_leaf_p (rtx op, machine_mode mode) +{ + /* We can't use memory_operand here, as it may return a different + value before and after reload (for volatile MEMs) which creates + problems splitting instructions. */ + return register_operand (op, mode) + || MEM_P (op) + || GET_CODE (op) == CONST_VECTOR + || bcst_mem_operand (op, mode); +} + +/* Test whether OP is a 3-operand ternary logic expression suitable + for use in a ternlog instruction. */ + +bool +ix86_ternlog_operand_p (rtx op) +{ + rtx op0, op1; + rtx args[3]; + + args[0] = NULL_RTX; + args[1] = NULL_RTX; + args[2] = NULL_RTX; + int idx = ix86_ternlog_idx (op, args); + if (idx < 0) + return false; + + /* Don't match simple (binary or unary) expressions. */ + machine_mode mode = GET_MODE (op); + switch (GET_CODE (op)) + { + case AND: + op0 = XEXP (op, 0); + op1 = XEXP (op, 1); + + /* Prefer pand. */ + if (ix86_ternlog_leaf_p (op0, mode) + && ix86_ternlog_leaf_p (op1, mode)) + return false; + /* Prefer pandn. */ + if (GET_CODE (op0) == NOT + && register_operand (XEXP (op0, 0), mode) + && ix86_ternlog_leaf_p (op1, mode)) + return false; + break; + + case IOR: + /* Prefer por. */ + if (ix86_ternlog_leaf_p (XEXP (op, 0), mode) + && ix86_ternlog_leaf_p (XEXP (op, 1), mode)) + return false; + break; + + case XOR: + op1 = XEXP (op, 1); + /* Prefer pxor, or one_cmpl2. */ + if (ix86_ternlog_leaf_p (XEXP (op, 0), mode) + && (ix86_ternlog_leaf_p (op1, mode) + || vector_all_ones_operand (op1, mode))) + return false; + break; + + default: + break; + } + return true; +} + +/* Helper function for ix86_expand_ternlog. */ +static rtx +ix86_expand_ternlog_binop (enum rtx_code code, machine_mode mode, + rtx op0, rtx op1, rtx target) +{ + if (GET_MODE (op0) != mode) + op0 = gen_lowpart (mode, op0); + if (GET_MODE (op1) != mode) + op1 = gen_lowpart (mode, op1); + + if (GET_CODE (op0) == CONST_VECTOR) + op0 = validize_mem (force_const_mem (mode, op0)); + if (GET_CODE (op1) == CONST_VECTOR) + op1 = validize_mem (force_const_mem (mode, op1)); + + if (memory_operand (op0, mode)) + { + if (memory_operand (op1, mode)) + op0 = force_reg (mode, op0); + else + std::swap (op0, op1); + } + rtx ops[3] = { target, op0, op1 }; + ix86_expand_vector_logical_operator (code, mode, ops); + return target; +} + + +/* Helper function for ix86_expand_ternlog. */ +static rtx +ix86_expand_ternlog_andnot (machine_mode mode, rtx op0, rtx op1, rtx target) +{ + if (GET_MODE (op0) != mode) + op0 = gen_lowpart (mode, op0); + op0 = gen_rtx_NOT (mode, op0); + if (GET_MODE (op1) != mode) + op1 = gen_lowpart (mode, op1); + emit_move_insn (target, gen_rtx_AND (mode, op0, op1)); + return target; +} + +/* Expand a 3-operand ternary logic expression. Return TARGET. */ +rtx +ix86_expand_ternlog (machine_mode mode, rtx op0, rtx op1, rtx op2, int idx, + rtx target) +{ + rtx tmp0, tmp1, tmp2; + + if (!target) + target = gen_reg_rtx (mode); + + /* Canonicalize ternlog index for degenerate (duplicated) operands. */ + if (rtx_equal_p (op0, op1) && rtx_equal_p (op0, op2)) + switch (idx & 0x81) + { + case 0x00: + idx = 0x00; + break; + case 0x01: + idx = 0x0f; + break; + case 0x80: + idx = 0xf0; + break; + case 0x81: + idx = 0xff; + break; + } + + switch (idx & 0xff) + { + case 0x00: + if ((!op0 || !side_effects_p (op0)) + && (!op1 || !side_effects_p (op1)) + && (!op2 || !side_effects_p (op2))) + { + emit_move_insn (target, CONST0_RTX (mode)); + return target; + } + break; + + case 0x0a: /* ~a&c */ + if ((!op1 || !side_effects_p (op1)) + && op0 && register_operand (op0, mode) + && op2 && register_operand (op2, mode)) + return ix86_expand_ternlog_andnot (mode, op0, op2, target); + break; + + case 0x0c: /* ~a&b */ + if ((!op2 || !side_effects_p (op2)) + && op0 && register_operand (op0, mode) + && op1 && register_operand (op1, mode)) + return ix86_expand_ternlog_andnot (mode, op0, op1, target); + break; + + case 0x0f: /* ~a */ + if ((!op1 || !side_effects_p (op1)) + && (!op2 || !side_effects_p (op2)) + && op0) + { + if (GET_MODE (op0) != mode) + op0 = gen_lowpart (mode, op0); + if (!TARGET_64BIT && !register_operand (op0, mode)) + op0 = force_reg (mode, op0); + emit_move_insn (target, gen_rtx_XOR (mode, op0, CONSTM1_RTX (mode))); + return target; + } + break; + + case 0x22: /* ~b&c */ + if ((!op0 || !side_effects_p (op0)) + && op1 && register_operand (op1, mode) + && op2 && register_operand (op2, mode)) + return ix86_expand_ternlog_andnot (mode, op1, op2, target); + break; + + case 0x30: /* ~b&a */ + if ((!op2 || !side_effects_p (op2)) + && op0 && register_operand (op0, mode) + && op1 && register_operand (op1, mode)) + return ix86_expand_ternlog_andnot (mode, op1, op0, target); + break; + + case 0x33: /* ~b */ + if ((!op0 || !side_effects_p (op0)) + && (!op2 || !side_effects_p (op2)) + && op1) + { + if (GET_MODE (op1) != mode) + op1 = gen_lowpart (mode, op1); + if (!TARGET_64BIT && !register_operand (op1, mode)) + op1 = force_reg (mode, op1); + emit_move_insn (target, gen_rtx_XOR (mode, op1, CONSTM1_RTX (mode))); + return target; + } + break; + + case 0x3c: /* a^b */ + if (op0 && op1 + && (!op2 || !side_effects_p (op2))) + return ix86_expand_ternlog_binop (XOR, mode, op0, op1, target); + break; + + case 0x44: /* ~c&b */ + if ((!op0 || !side_effects_p (op0)) + && op1 && register_operand (op1, mode) + && op2 && register_operand (op2, mode)) + return ix86_expand_ternlog_andnot (mode, op2, op1, target); + break; + + case 0x50: /* ~c&a */ + if ((!op1 || !side_effects_p (op1)) + && op0 && register_operand (op0, mode) + && op2 && register_operand (op2, mode)) + return ix86_expand_ternlog_andnot (mode, op2, op0, target); + break; + + case 0x55: /* ~c */ + if ((!op0 || !side_effects_p (op0)) + && (!op1 || !side_effects_p (op1)) + && op2) + { + if (GET_MODE (op2) != mode) + op2 = gen_lowpart (mode, op2); + if (!TARGET_64BIT && !register_operand (op2, mode)) + op2 = force_reg (mode, op2); + emit_move_insn (target, gen_rtx_XOR (mode, op2, CONSTM1_RTX (mode))); + return target; + } + break; + + case 0x5a: /* a^c */ + if (op0 && op2 + && (!op1 || !side_effects_p (op1))) + return ix86_expand_ternlog_binop (XOR, mode, op0, op2, target); + break; + + case 0x66: /* b^c */ + if ((!op0 || !side_effects_p (op0)) + && op1 && op2) + return ix86_expand_ternlog_binop (XOR, mode, op1, op2, target); + break; + + case 0x88: /* b&c */ + if ((!op0 || !side_effects_p (op0)) + && op1 && op2) + return ix86_expand_ternlog_binop (AND, mode, op1, op2, target); + break; + + case 0xa0: /* a&c */ + if ((!op1 || !side_effects_p (op1)) + && op0 && op2) + return ix86_expand_ternlog_binop (AND, mode, op0, op2, target); + break; + + case 0xaa: /* c */ + if ((!op0 || !side_effects_p (op0)) + && (!op1 || !side_effects_p (op1)) + && op2) + { + if (GET_MODE (op2) != mode) + op2 = gen_lowpart (mode, op2); + emit_move_insn (target, op2); + return target; + } + break; + + case 0xc0: /* a&b */ + if (op0 && op1 + && (!op2 || !side_effects_p (op2))) + return ix86_expand_ternlog_binop (AND, mode, op0, op1, target); + break; + + case 0xcc: /* b */ + if ((!op0 || !side_effects_p (op0)) + && op1 + && (!op2 || !side_effects_p (op2))) + { + if (GET_MODE (op1) != mode) + op1 = gen_lowpart (mode, op1); + emit_move_insn (target, op1); + return target; + } + break; + + case 0xee: /* b|c */ + if ((!op0 || !side_effects_p (op0)) + && op1 && op2) + return ix86_expand_ternlog_binop (IOR, mode, op1, op2, target); + break; + + case 0xf0: /* a */ + if (op0 + && (!op1 || !side_effects_p (op1)) + && (!op2 || !side_effects_p (op2))) + { + if (GET_MODE (op0) != mode) + op0 = gen_lowpart (mode, op0); + emit_move_insn (target, op0); + return target; + } + break; + + case 0xfa: /* a|c */ + if (op0 && op2 + && (!op1 || !side_effects_p (op1))) + return ix86_expand_ternlog_binop (IOR, mode, op0, op2, target); + break; + + case 0xfc: /* a|b */ + if (op0 && op1 + && (!op2 || !side_effects_p (op2))) + return ix86_expand_ternlog_binop (IOR, mode, op0, op1, target); + break; + + case 0xff: + if ((!op0 || !side_effects_p (op0)) + && (!op1 || !side_effects_p (op1)) + && (!op2 || !side_effects_p (op2))) + { + emit_move_insn (target, CONSTM1_RTX (mode)); + return target; + } + break; + } + + tmp0 = register_operand (op0, mode) ? op0 : force_reg (mode, op0); + if (GET_MODE (tmp0) != mode) + tmp0 = gen_lowpart (mode, tmp0); + + if (!op1 || rtx_equal_p (op0, op1)) + tmp1 = copy_rtx (tmp0); + else if (!register_operand (op1, mode)) + tmp1 = force_reg (mode, op1); + else + tmp1 = op1; + if (GET_MODE (tmp1) != mode) + tmp1 = gen_lowpart (mode, tmp1); + + if (!op2 || rtx_equal_p (op0, op2)) + tmp2 = copy_rtx (tmp0); + else if (rtx_equal_p (op1, op2)) + tmp2 = copy_rtx (tmp1); + else if (GET_CODE (op2) == CONST_VECTOR) + { + if (GET_MODE (op2) != mode) + op2 = gen_lowpart (mode, op2); + tmp2 = ix86_gen_bcst_mem (mode, op2); + if (!tmp2) + { + machine_mode bcst32_mode = mode; + machine_mode bcst64_mode = mode; + switch (mode) + { + case V1TImode: + case V4SImode: + case V4SFmode: + case V8HImode: + case V16QImode: + bcst32_mode = V4SImode; + bcst64_mode = V2DImode; + break; + + case V2TImode: + case V8SImode: + case V8SFmode: + case V16HImode: + case V32QImode: + bcst32_mode = V8SImode; + bcst64_mode = V4DImode; + break; + + case V4TImode: + case V16SImode: + case V16SFmode: + case V32HImode: + case V64QImode: + bcst32_mode = V16SImode; + bcst64_mode = V8DImode; + break; + + default: + break; + } + + if (bcst32_mode != mode) + { + tmp2 = gen_lowpart (bcst32_mode, op2); + if (ix86_gen_bcst_mem (bcst32_mode, tmp2)) + { + tmp2 = ix86_expand_ternlog (bcst32_mode, + gen_lowpart (bcst32_mode, tmp0), + gen_lowpart (bcst32_mode, tmp1), + tmp2, idx, NULL_RTX); + emit_move_insn (target, gen_lowpart (mode, tmp2)); + return target; + } + } + + if (bcst64_mode != mode) + { + tmp2 = gen_lowpart (bcst64_mode, op2); + if (ix86_gen_bcst_mem (bcst64_mode, tmp2)) + { + tmp2 = ix86_expand_ternlog (bcst64_mode, + gen_lowpart (bcst64_mode, tmp0), + gen_lowpart (bcst64_mode, tmp1), + tmp2, idx, NULL_RTX); + emit_move_insn (target, gen_lowpart (mode, tmp2)); + return target; + } + } + + tmp2 = force_const_mem (mode, op2); + rtx bcast = ix86_broadcast_from_constant (mode, tmp2); + tmp2 = validize_mem (tmp2); + if (bcast) + { + rtx reg2 = gen_reg_rtx (mode); + bool ok = ix86_expand_vector_init_duplicate (false, mode, + reg2, bcast); + if (ok) + tmp2 = reg2; + } + } + } + else + tmp2 = op2; + if (GET_MODE (tmp2) != mode) + tmp2 = gen_lowpart (mode, tmp2); + /* Some memory_operands are not vector_memory_operands. */ + if (!bcst_vector_operand (tmp2, mode)) + tmp2 = force_reg (mode, tmp2); + + rtvec vec = gen_rtvec (4, tmp0, tmp1, tmp2, GEN_INT (idx)); + emit_move_insn (target, gen_rtx_UNSPEC (mode, vec, UNSPEC_VTERNLOG)); + return target; +} + #include "gt-i386-expand.h" diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc index e3e004d55267f..607d19914606b 100644 --- a/gcc/config/i386/i386-features.cc +++ b/gcc/config/i386/i386-features.cc @@ -1054,7 +1054,7 @@ scalar_chain::convert_op (rtx *op, rtx_insn *insn) if (dump_file) fprintf (dump_file, " Preloading operand for insn %d into r%d\n", - INSN_UID (insn), REGNO (tmp)); + INSN_UID (insn), reg_or_subregno (tmp)); } else if (REG_P (*op)) *op = gen_rtx_SUBREG (vmode, *op, 0); diff --git a/gcc/config/i386/i386-opts.h b/gcc/config/i386/i386-opts.h index 5fcc492797897..c7ec0d9fd397a 100644 --- a/gcc/config/i386/i386-opts.h +++ b/gcc/config/i386/i386-opts.h @@ -142,8 +142,9 @@ enum apx_features { apx_ppx = 1 << 3, apx_nf = 1 << 4, apx_ccmp = 1 << 5, + apx_zu = 1 << 6, apx_all = apx_egpr | apx_push2pop2 | apx_ndd - | apx_ppx | apx_nf | apx_ccmp, + | apx_ppx | apx_nf | apx_ccmp | apx_zu, }; #endif diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h index aa50b897b2be9..f37d207ae64ff 100644 --- a/gcc/config/i386/i386-protos.h +++ b/gcc/config/i386/i386-protos.h @@ -251,6 +251,11 @@ extern int ix86_get_flags_cc (enum rtx_code); extern rtx ix86_memtag_untagged_pointer (rtx, rtx); extern bool ix86_memtag_can_tag_addresses (void); +extern int ix86_ternlog_idx (rtx op, rtx *args); +extern bool ix86_ternlog_operand_p (rtx op); +extern rtx ix86_expand_ternlog (machine_mode mode, rtx op0, rtx op1, rtx op2, + int idx, rtx target); + #ifdef TREE_CODE extern void init_cumulative_args (CUMULATIVE_ARGS *, tree, rtx, tree, int); #endif /* TREE_CODE */ diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index 4126ab24a79fe..d4ccc24be6ec2 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -21571,6 +21571,31 @@ ix86_rtx_costs (rtx x, machine_mode mode, int outer_code_i, int opno, = speed ? ix86_tune_cost : &ix86_size_cost; int src_cost; + /* Handling different vternlog variants. */ + if ((GET_MODE_SIZE (mode) == 64 + ? (TARGET_AVX512F && TARGET_EVEX512) + : (TARGET_AVX512VL + || (TARGET_AVX512F && TARGET_EVEX512 && !TARGET_PREFER_AVX256))) + && GET_MODE_SIZE (mode) >= 16 + && outer_code_i == SET + && ternlog_operand (x, mode)) + { + rtx args[3]; + + args[0] = NULL_RTX; + args[1] = NULL_RTX; + args[2] = NULL_RTX; + int idx = ix86_ternlog_idx (x, args); + gcc_assert (idx >= 0); + + *total = cost->sse_op; + for (int i = 0; i != 3; i++) + if (args[i]) + *total += rtx_cost (args[i], GET_MODE (args[i]), UNSPEC, i, speed); + return true; + } + + switch (code) { case SET: @@ -21912,6 +21937,49 @@ ix86_rtx_costs (rtx x, machine_mode mode, int outer_code_i, int opno, } *total = ix86_vec_cost (mode, cost->sse_op); } + else if (TARGET_64BIT + && mode == TImode + && GET_CODE (XEXP (x, 0)) == ASHIFT + && GET_CODE (XEXP (XEXP (x, 0), 0)) == ZERO_EXTEND + && GET_MODE (XEXP (XEXP (XEXP (x, 0), 0), 0)) == DImode + && CONST_INT_P (XEXP (XEXP (x, 0), 1)) + && INTVAL (XEXP (XEXP (x, 0), 1)) == 64 + && GET_CODE (XEXP (x, 1)) == ZERO_EXTEND + && GET_MODE (XEXP (XEXP (x, 1), 0)) == DImode) + { + /* *concatditi3 is cheap. */ + rtx op0 = XEXP (XEXP (XEXP (x, 0), 0), 0); + rtx op1 = XEXP (XEXP (x, 1), 0); + *total = (SUBREG_P (op0) && GET_MODE (SUBREG_REG (op0)) == DFmode) + ? COSTS_N_INSNS (1) /* movq. */ + : set_src_cost (op0, DImode, speed); + *total += (SUBREG_P (op1) && GET_MODE (SUBREG_REG (op1)) == DFmode) + ? COSTS_N_INSNS (1) /* movq. */ + : set_src_cost (op1, DImode, speed); + return true; + } + else if (TARGET_64BIT + && mode == TImode + && GET_CODE (XEXP (x, 0)) == AND + && REG_P (XEXP (XEXP (x, 0), 0)) + && CONST_WIDE_INT_P (XEXP (XEXP (x, 0), 1)) + && CONST_WIDE_INT_NUNITS (XEXP (XEXP (x, 0), 1)) == 2 + && CONST_WIDE_INT_ELT (XEXP (XEXP (x, 0), 1), 0) == -1 + && CONST_WIDE_INT_ELT (XEXP (XEXP (x, 0), 1), 1) == 0 + && GET_CODE (XEXP (x, 1)) == ASHIFT + && GET_CODE (XEXP (XEXP (x, 1), 0)) == ZERO_EXTEND + && GET_MODE (XEXP (XEXP (XEXP (x, 1), 0), 0)) == DImode + && CONST_INT_P (XEXP (XEXP (x, 1), 1)) + && INTVAL (XEXP (XEXP (x, 1), 1)) == 64) + { + /* *insvti_highpart is cheap. */ + rtx op = XEXP (XEXP (XEXP (x, 1), 0), 0); + *total = COSTS_N_INSNS (1) + 1; + *total += (SUBREG_P (op) && GET_MODE (SUBREG_REG (op)) == DFmode) + ? COSTS_N_INSNS (1) /* movq. */ + : set_src_cost (op, DImode, speed); + return true; + } else if (GET_MODE_SIZE (mode) > UNITS_PER_WORD) *total = cost->add * 2; else @@ -22190,6 +22258,9 @@ ix86_rtx_costs (rtx x, machine_mode mode, int outer_code_i, int opno, else if (XINT (x, 1) == UNSPEC_VTERNLOG) { *total = cost->sse_op; + *total += rtx_cost (XVECEXP (x, 0, 0), mode, code, 0, speed); + *total += rtx_cost (XVECEXP (x, 0, 1), mode, code, 1, speed); + *total += rtx_cost (XVECEXP (x, 0, 2), mode, code, 2, speed); return true; } else if (XINT (x, 1) == UNSPEC_PTEST) @@ -22217,12 +22288,21 @@ ix86_rtx_costs (rtx x, machine_mode mode, int outer_code_i, int opno, case VEC_SELECT: case VEC_CONCAT: - case VEC_DUPLICATE: /* ??? Assume all of these vector manipulation patterns are recognizable. In which case they all pretty much have the same cost. */ *total = cost->sse_op; return true; + case VEC_DUPLICATE: + *total = rtx_cost (XEXP (x, 0), + GET_MODE (XEXP (x, 0)), + VEC_DUPLICATE, 0, speed); + /* It's broadcast instruction, not embedded broadcasting. */ + if (outer_code == SET) + *total += cost->sse_op; + + return true; + case VEC_MERGE: mask = XEXP (x, 2); /* This is masked instruction, assume the same cost, @@ -26161,6 +26241,13 @@ ix86_memtag_add_tag (rtx base, poly_int64 offset, unsigned char tag_offset) return plus_constant (Pmode, tagged_addr, offset); } +/* Implement TARGET_HAVE_CCMP. */ +static bool +ix86_have_ccmp () +{ + return (bool) TARGET_APX_CCMP; +} + /* Target-specific selftests. */ #if CHECKING_P @@ -27000,6 +27087,8 @@ ix86_libgcc_floating_mode_supported_p #undef TARGET_GEN_CCMP_NEXT #define TARGET_GEN_CCMP_NEXT ix86_gen_ccmp_next +#undef TARGET_HAVE_CCMP +#define TARGET_HAVE_CCMP ix86_have_ccmp static bool ix86_libc_has_fast_function (int fcode ATTRIBUTE_UNUSED) diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index 7051c6c13e4c1..dc1a1f4432072 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -57,6 +57,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define TARGET_APX_PPX (ix86_apx_features & apx_ppx) #define TARGET_APX_NF (ix86_apx_features & apx_nf) #define TARGET_APX_CCMP (ix86_apx_features & apx_ccmp) +#define TARGET_APX_ZU (ix86_apx_features & apx_zu) #include "config/vxworks-dummy.h" diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index ffcf63e1cba54..fd48e76446951 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -1515,14 +1515,17 @@ (match_operator 1 "comparison_operator" [(reg:CC FLAGS_REG) (const_int 0)]) (compare:CC - (minus:SWI (match_operand:SWI 2 "nonimmediate_operand" "m,") - (match_operand:SWI 3 "" ",")) + (minus:SWI (match_operand:SWI 2 "nonimmediate_operand" ",m,") + (match_operand:SWI 3 "" "C,,")) (const_int 0)) - (unspec:SI + (unspec:CC [(match_operand:SI 4 "const_0_to_15_operand")] UNSPEC_APX_DFV)))] "TARGET_APX_CCMP" - "ccmp%C1{}\t%G4 {%3, %2|%2, %3}" + "@ + ctest%C1{}\t%G4 %2, %2 + ccmp%C1{}\t%G4 {%3, %2|%2, %3} + ccmp%C1{}\t%G4 {%3, %2|%2, %3}" [(set_attr "type" "icmp") (set_attr "mode" "") (set_attr "length_immediate" "1") @@ -8436,6 +8439,14 @@ "ix86_fixup_binary_operands_no_copy (MINUS, mode, operands, TARGET_APX_NDD);") +(define_expand "sub_3" + [(parallel [(set (reg:CC FLAGS_REG) + (compare:CC + (match_operand:SWI 1 "nonimmediate_operand") + (match_operand:SWI 2 ""))) + (set (match_operand:SWI 0 "register_operand") + (minus:SWI (match_dup 1) (match_dup 2)))])]) + (define_insn "*sub_3" [(set (reg FLAGS_REG) (compare (match_operand:SWI 1 "nonimmediate_operand" "0,0,rm,r") @@ -9870,6 +9881,91 @@ operands[1] = force_reg (mode, operands[1]); }) +(define_expand "usadd3" + [(set (match_operand:SWI 0 "register_operand") + (us_plus:SWI (match_operand:SWI 1 "register_operand") + (match_operand:SWI 2 "")))] + "" +{ + rtx res = gen_reg_rtx (mode); + rtx dst; + + emit_insn (gen_add3_cc_overflow_1 (res, operands[1], operands[2])); + + if (TARGET_CMOVE) + { + rtx cmp = gen_rtx_GEU (VOIDmode, gen_rtx_REG (CCCmode, FLAGS_REG), + const0_rtx); + + if ( < GET_MODE_SIZE (SImode)) + { + dst = force_reg (mode, operands[0]); + emit_insn (gen_movsicc (gen_lowpart (SImode, dst), cmp, + gen_lowpart (SImode, res), constm1_rtx)); + } + else + { + dst = operands[0]; + emit_insn (gen_movcc (dst, cmp, res, constm1_rtx)); + } + } + else + { + rtx msk = gen_reg_rtx (mode); + + emit_insn (gen_x86_movcc_0_m1_neg (msk)); + dst = expand_simple_binop (mode, IOR, res, msk, + operands[0], 1, OPTAB_WIDEN); + } + + if (!rtx_equal_p (dst, operands[0])) + emit_move_insn (operands[0], dst); + DONE; +}) + +(define_expand "ussub3" + [(set (match_operand:SWI 0 "register_operand") + (us_minus:SWI (match_operand:SWI 1 "register_operand") + (match_operand:SWI 2 "")))] + "" +{ + rtx res = gen_reg_rtx (mode); + rtx dst; + + emit_insn (gen_sub_3 (res, operands[1], operands[2])); + + if (TARGET_CMOVE) + { + rtx cmp = gen_rtx_GEU (VOIDmode, gen_rtx_REG (CCCmode, FLAGS_REG), + const0_rtx); + + if ( < GET_MODE_SIZE (SImode)) + { + dst = force_reg (mode, operands[0]); + emit_insn (gen_movsicc (gen_lowpart (SImode, dst), cmp, + gen_lowpart (SImode, res), const0_rtx)); + } + else + { + dst = operands[0]; + emit_insn (gen_movcc (dst, cmp, res, const0_rtx)); + } + } + else + { + rtx msk = gen_reg_rtx (mode); + + emit_insn (gen_x86_movcc_0_m1_neg (msk)); + msk = expand_simple_unop (mode, NOT, msk, NULL, 1); + dst = expand_simple_binop (mode, AND, res, msk, + operands[0], 1, OPTAB_WIDEN); + } + + if (!rtx_equal_p (dst, operands[0])) + emit_move_insn (operands[0], dst); + DONE; +}) + ;; The patterns that match these are at the end of this file. (define_expand "xf3" @@ -9967,6 +10063,19 @@ (const_string "direct"))) (set_attr "mode" "")]) +(define_insn "*imulhizu" + [(set (match_operand:SWI48x 0 "register_operand" "=r,r") + (zero_extend:SWI48x + (mult:HI (match_operand:HI 1 "nonimmediate_operand" "%rm,rm") + (match_operand:HI 2 "immediate_operand" "K,n")))) + (clobber (reg:CC FLAGS_REG))] + "TARGET_APX_ZU" + "@ + imulzu{w}\t{%2, %1, %w0|%w0, %1, %2} + imulzu{w}\t{%2, %1, %w0|%w0, %1, %2}" + [(set_attr "type" "imul") + (set_attr "mode" "HI")]) + (define_insn "*mulsi3_1_zext" [(set (match_operand:DI 0 "register_operand" "=r,r,r") (zero_extend:DI @@ -18354,11 +18463,19 @@ ;; For all sCOND expanders, also expand the compare or test insn that ;; generates cc0. Generate an equality comparison if `seq' or `sne'. +(define_insn "*setcc__zu" + [(set (match_operand:SWI248 0 "register_operand" "=r") + (match_operator:SWI248 1 "ix86_comparison_operator" + [(reg FLAGS_REG) (const_int 0)]))] + "TARGET_APX_ZU" + "setzu%C1\t%b0" + [(set_attr "type" "setcc")]) + (define_insn_and_split "*setcc_di_1" [(set (match_operand:DI 0 "register_operand" "=q") (match_operator:DI 1 "ix86_comparison_operator" [(reg FLAGS_REG) (const_int 0)]))] - "TARGET_64BIT && !TARGET_PARTIAL_REG_STALL" + "!TARGET_APX_ZU && TARGET_64BIT && !TARGET_PARTIAL_REG_STALL" "#" "&& reload_completed" [(set (match_dup 2) (match_dup 1)) @@ -18391,7 +18508,7 @@ [(set (match_operand:SWI24 0 "register_operand" "=q") (match_operator:SWI24 1 "ix86_comparison_operator" [(reg FLAGS_REG) (const_int 0)]))] - "!TARGET_PARTIAL_REG_STALL + "!TARGET_APX_ZU && !TARGET_PARTIAL_REG_STALL && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_function_for_size_p (cfun))" "#" "&& reload_completed" @@ -24945,8 +25062,8 @@ (define_expand "x86_movcc_0_m1_neg" [(parallel - [(set (match_operand:SWI48 0 "register_operand") - (neg:SWI48 (ltu:SWI48 (reg:CCC FLAGS_REG) (const_int 0)))) + [(set (match_operand:SWI 0 "register_operand") + (neg:SWI (ltu:SWI (reg:CCC FLAGS_REG) (const_int 0)))) (clobber (reg:CC FLAGS_REG))])]) (define_split diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt index 7017cc87cec39..353fffb234307 100644 --- a/gcc/config/i386/i386.opt +++ b/gcc/config/i386/i386.opt @@ -1342,6 +1342,9 @@ Enum(apx_features) String(nf) Value(apx_nf) Set(6) EnumValue Enum(apx_features) String(ccmp) Value(apx_ccmp) Set(7) +EnumValue +Enum(apx_features) String(zu) Value(apx_zu) Set(8) + EnumValue Enum(apx_features) String(all) Value(apx_all) Set(1) diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md index 2a97776fc3206..a894847adaf7c 100644 --- a/gcc/config/i386/predicates.md +++ b/gcc/config/i386/predicates.md @@ -1056,6 +1056,11 @@ (and (match_code "const_int") (match_test "IN_RANGE (INTVAL (op), 28, 31)"))) +(define_predicate "cmpps_imm_operand" + (ior (match_operand 0 "const_0_to_7_operand") + (and (match_test "TARGET_AVX") + (match_operand 0 "const_0_to_31_operand")))) + ;; True if this is a constant appropriate for an increment or decrement. (define_predicate "incdec_operand" (match_code "const_int") @@ -1098,6 +1103,11 @@ (and (match_code "not") (match_test "nonimmediate_operand (XEXP (op, 0), mode)")))) +;; True for expressions valid for 3-operand ternlog instructions. +(define_predicate "ternlog_operand" + (and (match_code "not,and,ior,xor") + (match_test "ix86_ternlog_operand_p (op)"))) + ;; True if OP is acceptable as operand of DImode shift expander. (define_predicate "shiftdi_operand" (if_then_else (match_test "TARGET_64BIT") @@ -2317,3 +2327,14 @@ return true; }) + +;; Check that each element is odd and incrementally increasing from 1 +(define_predicate "vcvtne2ps2bf_parallel" + (and (match_code "const_vector") + (match_code "const_int" "a")) +{ + for (int i = 0; i < XVECLEN (op, 0); ++i) + if (INTVAL (XVECEXP (op, 0, i)) != (2 * i + 1)) + return false; + return true; +}) diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index 4ad3917f5ce8c..0be2dcd88913b 100644 --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -98,6 +98,8 @@ UNSPEC_COMPRESS UNSPEC_COMPRESS_STORE UNSPEC_EXPAND + UNSPEC_VCVTT + UNSPEC_VCVTTU ;; Mask operations UNSPEC_MASKOP @@ -3732,18 +3734,21 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define_insn "avx_cmp3" - [(set (match_operand:VF_128_256 0 "register_operand" "=x") + [(set (match_operand:VF_128_256 0 "register_operand" "=x,x") (unspec:VF_128_256 - [(match_operand:VF_128_256 1 "register_operand" "x") - (match_operand:VF_128_256 2 "nonimmediate_operand" "xjm") - (match_operand:SI 3 "const_0_to_31_operand")] + [(match_operand:VF_128_256 1 "register_operand" "0,x") + (match_operand:VF_128_256 2 "nonimmediate_operand" "xm,xjm") + (match_operand:SI 3 "cmpps_imm_operand")] UNSPEC_PCMP))] - "TARGET_AVX" - "vcmp\t{%3, %2, %1, %0|%0, %1, %2, %3}" - [(set_attr "type" "ssecmp") - (set_attr "addr" "gpr16") + "TARGET_SSE" + "@ + cmp\t{%3, %2, %0|%0, %2, %3} + vcmp\t{%3, %2, %1, %0|%0, %1, %2, %3}" + [(set_attr "isa" "noavx,avx") + (set_attr "type" "ssecmp") + (set_attr "addr" "*,gpr16") (set_attr "length_immediate" "1") - (set_attr "prefix" "vex") + (set_attr "prefix" "orig,vex") (set_attr "mode" "")]) (define_insn_and_split "*avx_cmp3_1" @@ -3943,21 +3948,24 @@ }) (define_insn "avx_vmcmp3" - [(set (match_operand:VF_128 0 "register_operand" "=x") + [(set (match_operand:VF_128 0 "register_operand" "=x,x") (vec_merge:VF_128 (unspec:VF_128 - [(match_operand:VF_128 1 "register_operand" "x") - (match_operand:VF_128 2 "nonimmediate_operand" "xjm") - (match_operand:SI 3 "const_0_to_31_operand")] + [(match_operand:VF_128 1 "register_operand" "0,x") + (match_operand:VF_128 2 "nonimmediate_operand" "xm,xjm") + (match_operand:SI 3 "cmpps_imm_operand")] UNSPEC_PCMP) (match_dup 1) (const_int 1)))] - "TARGET_AVX" - "vcmp\t{%3, %2, %1, %0|%0, %1, %2, %3}" - [(set_attr "type" "ssecmp") - (set_attr "addr" "gpr16") + "TARGET_SSE" + "@ + cmp\t{%3, %2, %0|%0, %2, %3} + vcmp\t{%3, %2, %1, %0|%0, %1, %2, %3}" + [(set_attr "isa" "noavx,avx") + (set_attr "type" "ssecmp") + (set_attr "addr" "*,gpr16") (set_attr "length_immediate" "1") - (set_attr "prefix" "vex") + (set_attr "prefix" "orig,vex") (set_attr "mode" "")]) (define_insn "*_maskcmp3_comm" @@ -7303,6 +7311,16 @@ UNSPEC_FIX_NOTRUNC))] "TARGET_AVX512FP16") +(define_int_iterator UNSPEC_VCVTT_U + [UNSPEC_VCVTT + UNSPEC_VCVTTU]) + +(define_int_attr vcvtt_suffix + [(UNSPEC_VCVTT "") (UNSPEC_VCVTTU "u")]) + +(define_int_attr vcvtt_uns_suffix + [(UNSPEC_VCVTT "") (UNSPEC_VCVTTU "uns")]) + (define_insn "avx512fp16_vcvtph2_" [(set (match_operand:VI248_AVX512VL 0 "register_operand" "=v") (unspec:VI248_AVX512VL @@ -7528,6 +7546,17 @@ (match_operand: 1 "nonimmediate_operand")))] "TARGET_AVX512FP16") +(define_insn "unspec_avx512fp16_fix_trunc2" + [(set (match_operand:VI2H_AVX512VL 0 "register_operand" "=v") + (unspec:VI2H_AVX512VL + [(match_operand: 1 "" "")] + UNSPEC_VCVTT_U))] + "TARGET_AVX512FP16" + "vcvttph2\t{%1, %0|%0, %1}" + [(set_attr "type" "ssecvt") + (set_attr "prefix" "evex") + (set_attr "mode" "")]) + (define_insn "avx512fp16_fix_trunc2" [(set (match_operand:VI2H_AVX512VL 0 "register_operand" "=v") (any_fix:VI2H_AVX512VL @@ -7555,6 +7584,17 @@ } }) +(define_insn "unspec_avx512fp16_fix_trunc2" + [(set (match_operand:VI4_128_8_256 0 "register_operand" "=v") + (unspec:VI4_128_8_256 + [(match_operand:V8HF 1 "register_operand" "v")] + UNSPEC_VCVTT_U))] + "TARGET_AVX512FP16 && TARGET_AVX512VL" + "vcvttph2\t{%1, %0|%0, %1}" + [(set_attr "type" "ssecvt") + (set_attr "prefix" "evex") + (set_attr "mode" "")]) + (define_insn "avx512fp16_fix_trunc2" [(set (match_operand:VI4_128_8_256 0 "register_operand" "=v") (any_fix:VI4_128_8_256 @@ -7594,6 +7634,17 @@ } }) +(define_insn "unspec_avx512fp16_fix_truncv2di2" + [(set (match_operand:V2DI 0 "register_operand" "=v") + (unspec:V2DI + [(match_operand:V8HF 1 "nonimmediate_operand" "v")] + UNSPEC_VCVTT_U))] + "TARGET_AVX512FP16 && TARGET_AVX512VL" + "vcvttph2qq\t{%1, %0|%0, %1}" + [(set_attr "type" "ssecvt") + (set_attr "prefix" "evex") + (set_attr "mode" "TI")]) + (define_insn "avx512fp16_fix_truncv2di2" [(set (match_operand:V2DI 0 "register_operand" "=v") (any_fix:V2DI @@ -7616,6 +7667,17 @@ (set_attr "prefix" "evex") (set_attr "mode" "TI")]) +(define_insn "unspec_avx512fp16_fix_trunc2" + [(set (match_operand:SWI48 0 "register_operand" "=r") + (unspec:SWI48 + [(match_operand:V8HF 1 "register_operand" "v")] + UNSPEC_VCVTT_U))] + "TARGET_AVX512FP16" + "%vcvttsh2si\t{%1, %0|%0, %k1}" + [(set_attr "type" "sseicvt") + (set_attr "prefix" "evex") + (set_attr "mode" "")]) + (define_insn "avx512fp16_fix_trunc2" [(set (match_operand:SWI48 0 "register_operand" "=r") (any_fix:SWI48 @@ -8066,6 +8128,38 @@ (set_attr "unit" "mmx,*") (set_attr "mode" "DI")]) +(define_insn_and_split "unspec_sse_cvttps2pi" + [(set (match_operand:V2SI 0 "register_operand" "=y,Yv") + (unspec:V2SI + [(match_operand:V4SF 1 "nonimmediate_operand" "xm,YvBm")] + UNSPEC_VCVTT))] + "(TARGET_MMX || TARGET_MMX_WITH_SSE) && TARGET_SSE" + "@ + cvttps2pi\t{%1, %0|%0, %q1} + #" + "TARGET_SSE2 && reload_completed + && SSE_REG_P (operands[0])" + [(const_int 0)] +{ + rtx op1 = lowpart_subreg (V2SFmode, operands[1], + GET_MODE (operands[1])); + rtx tmp = lowpart_subreg (V4SFmode, operands[0], + GET_MODE (operands[0])); + + op1 = gen_rtx_VEC_CONCAT (V4SFmode, op1, CONST0_RTX (V2SFmode)); + emit_insn (gen_rtx_SET (tmp, op1)); + rtx dest = lowpart_subreg (V4SImode, operands[0], + GET_MODE (operands[0])); + emit_insn (gen_unspec_fix_truncv4sfv4si2 (dest, tmp)); + DONE; +} + [(set_attr "isa" "*,sse2") + (set_attr "mmx_isa" "native,*") + (set_attr "type" "ssecvt") + (set_attr "unit" "mmx,*") + (set_attr "prefix_rep" "0") + (set_attr "mode" "SF")]) + (define_insn_and_split "sse_cvttps2pi" [(set (match_operand:V2SI 0 "register_operand" "=y,Yv") (vec_select:V2SI @@ -8163,6 +8257,21 @@ (set_attr "prefix" "maybe_vex") (set_attr "mode" "")]) +(define_insn "unspec_sse_cvttss2si" + [(set (match_operand:SWI48 0 "register_operand" "=r,r") + (unspec:SWI48 + [(match_operand:V4SF 1 "" "v,")] + UNSPEC_VCVTT))] + "TARGET_SSE" + "%vcvttss2si\t{%1, %0|%0, %k1}" + [(set_attr "type" "sseicvt") + (set_attr "athlon_decode" "double,vector") + (set_attr "amdfam10_decode" "double,double") + (set_attr "bdver1_decode" "double,double") + (set_attr "prefix_rep" "1") + (set_attr "prefix" "maybe_vex") + (set_attr "mode" "")]) + (define_insn "sse_cvttss2si" [(set (match_operand:SWI48 0 "register_operand" "=r,r") (fix:SWI48 @@ -8332,6 +8441,17 @@ (set_attr "prefix" "evex") (set_attr "mode" "TI")]) +(define_insn "unspec_fix_truncv16sfv16si2" + [(set (match_operand:V16SI 0 "register_operand" "=v") + (unspec:V16SI + [(match_operand:V16SF 1 "" "")] + UNSPEC_VCVTT_U))] + "TARGET_AVX512F && TARGET_EVEX512" + "vcvttps2dq\t{%1, %0|%0, %1}" + [(set_attr "type" "ssecvt") + (set_attr "prefix" "evex") + (set_attr "mode" "XI")]) + (define_insn "fix_truncv16sfv16si2" [(set (match_operand:V16SI 0 "register_operand" "=v") (any_fix:V16SI @@ -8342,6 +8462,16 @@ (set_attr "prefix" "evex") (set_attr "mode" "XI")]) +(define_insn "unspec_fix_truncv8sfv8si2" + [(set (match_operand:V8SI 0 "register_operand" "=v") + (unspec:V8SI [(match_operand:V8SF 1 "nonimmediate_operand" "vm")] + UNSPEC_VCVTT))] + "TARGET_AVX && " + "vcvttps2dq\t{%1, %0|%0, %1}" + [(set_attr "type" "ssecvt") + (set_attr "prefix" "") + (set_attr "mode" "OI")]) + (define_insn "fix_truncv8sfv8si2" [(set (match_operand:V8SI 0 "register_operand" "=v") (fix:V8SI (match_operand:V8SF 1 "nonimmediate_operand" "vm")))] @@ -8351,6 +8481,27 @@ (set_attr "prefix" "") (set_attr "mode" "OI")]) +(define_insn "unspec_fix_truncv4sfv4si2" + [(set (match_operand:V4SI 0 "register_operand" "=v") + (unspec:V4SI [(match_operand:V4SF 1 "vector_operand" "vBm")] + UNSPEC_VCVTT))] + "TARGET_SSE2 && " + "%vcvttps2dq\t{%1, %0|%0, %1}" + [(set_attr "type" "ssecvt") + (set (attr "prefix_rep") + (if_then_else + (match_test "TARGET_AVX") + (const_string "*") + (const_string "1"))) + (set (attr "prefix_data16") + (if_then_else + (match_test "TARGET_AVX") + (const_string "*") + (const_string "0"))) + (set_attr "prefix_data16" "0") + (set_attr "prefix" "") + (set_attr "mode" "TI")]) + (define_insn "fix_truncv4sfv4si2" [(set (match_operand:V4SI 0 "register_operand" "=v") (fix:V4SI (match_operand:V4SF 1 "vector_operand" "vBm")))] @@ -8442,6 +8593,24 @@ (set_attr "prefix" "maybe_vex,*") (set_attr "mode" "TI")]) +(define_insn "unspec_sse2_cvttpd2pi" + [(set (match_operand:V2SI 0 "register_operand" "=v,?!y") + (unspec:V2SI [(match_operand:V2DF 1 "vector_operand" "vBm,xBm")] + UNSPEC_VCVTT))] + "TARGET_SSE2" + "@ + * return TARGET_AVX ? \"vcvttpd2dq{x}\t{%1, %0|%0, %1}\" : \"cvttpd2dq\t{%1, %0|%0, %1}\"; + cvttpd2pi\t{%1, %0|%0, %1}" + [(set_attr "mmx_isa" "*,native") + (set_attr "type" "ssecvt") + (set_attr "unit" "*,mmx") + (set_attr "amdfam10_decode" "double") + (set_attr "athlon_decode" "vector") + (set_attr "bdver1_decode" "double") + (set_attr "prefix_data16" "*,1") + (set_attr "prefix" "maybe_vex,*") + (set_attr "mode" "TI")]) + (define_insn "sse2_cvttpd2pi" [(set (match_operand:V2SI 0 "register_operand" "=v,?!y") (fix:V2SI (match_operand:V2DF 1 "vector_operand" "vBm,xBm")))] @@ -8464,6 +8633,17 @@ (fix:V2SI (match_operand:V2DF 1 "vector_operand")))] "TARGET_MMX_WITH_SSE") +(define_insn "unspec_fixuns_truncv2dfv2si2" + [(set (match_operand:V2SI 0 "register_operand" "=v") + (unspec:V2SI + [(match_operand:V2DF 1 "nonimmediate_operand" "vm")] + UNSPEC_VCVTTU))] + "TARGET_MMX_WITH_SSE && TARGET_AVX512VL" + "vcvttpd2udq{x}\t{%1, %0|%0, %1}" + [(set_attr "type" "ssecvt") + (set_attr "prefix" "evex") + (set_attr "mode" "TI")]) + (define_insn "fixuns_truncv2dfv2si2" [(set (match_operand:V2SI 0 "register_operand" "=v") (unsigned_fix:V2SI @@ -8531,6 +8711,17 @@ (set_attr "prefix" "evex") (set_attr "mode" "")]) +(define_insn "unspec_avx512f_vcvttss2usi" + [(set (match_operand:SWI48 0 "register_operand" "=r") + (unspec:SWI48 + [(match_operand:V4SF 1 "" "")] + UNSPEC_VCVTTU))] + "TARGET_AVX512F" + "vcvttss2usi\t{%1, %0|%0, %k1}" + [(set_attr "type" "sseicvt") + (set_attr "prefix" "evex") + (set_attr "mode" "")]) + (define_insn "avx512f_vcvttss2usi" [(set (match_operand:SWI48 0 "register_operand" "=r") (unsigned_fix:SWI48 @@ -8556,6 +8747,17 @@ (set_attr "prefix" "evex") (set_attr "mode" "")]) +(define_insn "unspec_avx512f_vcvttsd2usi" + [(set (match_operand:SWI48 0 "register_operand" "=r") + (unspec:SWI48 + [(match_operand:V2DF 1 "" "")] + UNSPEC_VCVTTU))] + "TARGET_AVX512F" + "vcvttsd2usi\t{%1, %0|%0, %q1}" + [(set_attr "type" "sseicvt") + (set_attr "prefix" "evex") + (set_attr "mode" "")]) + (define_insn "avx512f_vcvttsd2usi" [(set (match_operand:SWI48 0 "register_operand" "=r") (unsigned_fix:SWI48 @@ -8599,6 +8801,22 @@ (set_attr "prefix" "maybe_vex") (set_attr "mode" "")]) +(define_insn "unspec_sse2_cvttsd2si" + [(set (match_operand:SWI48 0 "register_operand" "=r,r") + (unspec:SWI48 + [(match_operand:V2DF 1 "" "v,")] + UNSPEC_VCVTT))] + "TARGET_SSE2" + "%vcvttsd2si\t{%1, %0|%0, %q1}" + [(set_attr "type" "sseicvt") + (set_attr "athlon_decode" "double,vector") + (set_attr "amdfam10_decode" "double,double") + (set_attr "bdver1_decode" "double,double") + (set_attr "btver2_decode" "double,double") + (set_attr "prefix_rep" "1") + (set_attr "prefix" "maybe_vex") + (set_attr "mode" "")]) + (define_insn "sse2_cvttsd2si" [(set (match_operand:SWI48 0 "register_operand" "=r,r") (fix:SWI48 @@ -9026,6 +9244,17 @@ (set_attr "prefix" "evex") (set_attr "mode" "TI")]) +(define_insn "unspec_fix_truncv8dfv8si2" + [(set (match_operand:V8SI 0 "register_operand" "=v") + (unspec:V8SI + [(match_operand:V8DF 1 "" "")] + UNSPEC_VCVTT_U))] + "TARGET_AVX512F && TARGET_EVEX512" + "vcvttpd2dq\t{%1, %0|%0, %1}" + [(set_attr "type" "ssecvt") + (set_attr "prefix" "evex") + (set_attr "mode" "OI")]) + (define_insn "fix_truncv8dfv8si2" [(set (match_operand:V8SI 0 "register_operand" "=v") (any_fix:V8SI @@ -9036,6 +9265,18 @@ (set_attr "prefix" "evex") (set_attr "mode" "OI")]) +(define_insn "*unspec_fixuns_truncv2dfv2si2" + [(set (match_operand:V4SI 0 "register_operand" "=v") + (vec_concat:V4SI + (unspec:V2SI [(match_operand:V2DF 1 "nonimmediate_operand" "vm")] + UNSPEC_VCVTTU) + (const_vector:V2SI [(const_int 0) (const_int 0)])))] + "TARGET_AVX512VL" + "vcvttpd2udq{x}\t{%1, %0|%0, %1}" + [(set_attr "type" "ssecvt") + (set_attr "prefix" "evex") + (set_attr "mode" "TI")]) + (define_insn "*fixuns_truncv2dfv2si2" [(set (match_operand:V4SI 0 "register_operand" "=v") (vec_concat:V4SI @@ -9047,6 +9288,23 @@ (set_attr "prefix" "evex") (set_attr "mode" "TI")]) +(define_insn "unspec_fixuns_truncv2dfv2si2_mask" + [(set (match_operand:V4SI 0 "register_operand" "=v") + (vec_concat:V4SI + (vec_merge:V2SI + (unspec:V2SI [(match_operand:V2DF 1 "nonimmediate_operand" "vm")] + UNSPEC_VCVTTU) + (vec_select:V2SI + (match_operand:V4SI 2 "nonimm_or_0_operand" "0C") + (parallel [(const_int 0) (const_int 1)])) + (match_operand:QI 3 "register_operand" "Yk")) + (const_vector:V2SI [(const_int 0) (const_int 0)])))] + "TARGET_AVX512VL" + "vcvttpd2udq{x}\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}" + [(set_attr "type" "ssecvt") + (set_attr "prefix" "evex") + (set_attr "mode" "TI")]) + (define_insn "fixuns_truncv2dfv2si2_mask" [(set (match_operand:V4SI 0 "register_operand" "=v") (vec_concat:V4SI @@ -9077,6 +9335,16 @@ (set_attr "prefix" "evex") (set_attr "mode" "TI")]) +(define_insn "unspec_fix_truncv4dfv4si2" + [(set (match_operand:V4SI 0 "register_operand" "=v") + (unspec:V4SI [(match_operand:V4DF 1 "nonimmediate_operand" "vm")] + UNSPEC_VCVTT))] + "TARGET_AVX || (TARGET_AVX512VL && TARGET_AVX512F)" + "vcvttpd2dq{y}\t{%1, %0|%0, %1}" + [(set_attr "type" "ssecvt") + (set_attr "prefix" "maybe_evex") + (set_attr "mode" "OI")]) + (define_insn "fix_truncv4dfv4si2" [(set (match_operand:V4SI 0 "register_operand" "=v") (fix:V4SI (match_operand:V4DF 1 "nonimmediate_operand" "vm")))] @@ -9086,6 +9354,16 @@ (set_attr "prefix" "maybe_evex") (set_attr "mode" "OI")]) +(define_insn "unspec_fixuns_truncv4dfv4si2" + [(set (match_operand:V4SI 0 "register_operand" "=v") + (unspec:V4SI [(match_operand:V4DF 1 "nonimmediate_operand" "vm")] + UNSPEC_VCVTTU))] + "TARGET_AVX512VL && TARGET_AVX512F" + "vcvttpd2udq{y}\t{%1, %0|%0, %1}" + [(set_attr "type" "ssecvt") + (set_attr "prefix" "maybe_evex") + (set_attr "mode" "OI")]) + (define_insn "fixuns_truncv4dfv4si2" [(set (match_operand:V4SI 0 "register_operand" "=v") (unsigned_fix:V4SI (match_operand:V4DF 1 "nonimmediate_operand" "vm")))] @@ -9095,6 +9373,17 @@ (set_attr "prefix" "maybe_evex") (set_attr "mode" "OI")]) +(define_insn "unspec_fix_trunc2" + [(set (match_operand: 0 "register_operand" "=v") + (unspec: + [(match_operand:VF2_AVX512VL 1 "" "")] + UNSPEC_VCVTT_U))] + "TARGET_AVX512DQ && " + "vcvttpd2qq\t{%1, %0|%0, %1}" + [(set_attr "type" "ssecvt") + (set_attr "prefix" "evex") + (set_attr "mode" "")]) + (define_insn "fix_trunc2" [(set (match_operand: 0 "register_operand" "=v") (any_fix: @@ -9127,6 +9416,17 @@ (set_attr "prefix" "evex") (set_attr "mode" "")]) +(define_insn "unspec_fix_trunc2" + [(set (match_operand: 0 "register_operand" "=v") + (unspec: + [(match_operand:VF1_128_256VL 1 "" "")] + UNSPEC_VCVTT_U))] + "TARGET_AVX512DQ && " + "vcvttps2qq\t{%1, %0|%0, %1}" + [(set_attr "type" "ssecvt") + (set_attr "prefix" "evex") + (set_attr "mode" "")]) + (define_insn "fix_trunc2" [(set (match_operand: 0 "register_operand" "=v") (any_fix: @@ -9137,6 +9437,17 @@ (set_attr "prefix" "evex") (set_attr "mode" "")]) +(define_insn "unspec_avx512dq_fix_truncv2sfv2di2" + [(set (match_operand:V2DI 0 "register_operand" "=v") + (unspec:V2DI + [(match_operand:V4SF 1 "nonimmediate_operand" "vm")] + UNSPEC_VCVTT_U))] + "TARGET_AVX512DQ && TARGET_AVX512VL" + "vcvttps2qq\t{%1, %0|%0, %q1}" + [(set_attr "type" "ssecvt") + (set_attr "prefix" "evex") + (set_attr "mode" "TI")]) + (define_insn "avx512dq_fix_truncv2sfv2di2" [(set (match_operand:V2DI 0 "register_operand" "=v") (any_fix:V2DI @@ -9276,6 +9587,17 @@ DONE; }) +(define_insn "unspec_fixuns_trunc2" + [(set (match_operand: 0 "register_operand" "=v") + (unspec: + [(match_operand:VF1_128_256 1 "nonimmediate_operand" "vm")] + UNSPEC_VCVTTU))] + "TARGET_AVX512VL" + "vcvttps2udq\t{%1, %0|%0, %1}" + [(set_attr "type" "ssecvt") + (set_attr "prefix" "evex") + (set_attr "mode" "")]) + (define_insn "fixuns_trunc2" [(set (match_operand: 0 "register_operand" "=v") (unsigned_fix: @@ -9294,6 +9616,25 @@ "TARGET_AVX" "operands[2] = CONST0_RTX (V4SImode);") +(define_insn "unspec_sse2_cvttpd2dq" + [(set (match_operand:V4SI 0 "register_operand" "=v") + (unspec:V4SI + [(match_operand:V2DF 1 "vector_operand" "vBm")] + UNSPEC_VCVTT))] + "TARGET_SSE2 && " +{ + if (TARGET_AVX) + return "vcvttpd2dq{x}\t{%1, %0|%0, %1}"; + else + return "cvttpd2dq\t{%1, %0|%0, %1}"; +} + [(set_attr "type" "ssecvt") + (set_attr "amdfam10_decode" "double") + (set_attr "athlon_decode" "vector") + (set_attr "bdver1_decode" "double") + (set_attr "prefix" "maybe_vex") + (set_attr "mode" "TI")]) + (define_insn "sse2_cvttpd2dq" [(set (match_operand:V4SI 0 "register_operand" "=v") (vec_concat:V4SI @@ -13032,6 +13373,26 @@ ;; ;; and so on. +(define_insn_and_split "*_vpternlog_0" + [(set (match_operand:V 0 "register_operand") + (match_operand:V 1 "ternlog_operand"))] + "( == 64 || TARGET_AVX512VL + || (TARGET_AVX512F && TARGET_EVEX512 && !TARGET_PREFER_AVX256)) + && ix86_pre_reload_split ()" + "#" + "&& 1" + [(const_int 0)] +{ + rtx args[3]; + args[0] = NULL_RTX; + args[1] = NULL_RTX; + args[2] = NULL_RTX; + int idx = ix86_ternlog_idx (operands[1], args); + ix86_expand_ternlog (mode, args[0], args[1], args[2], idx, + operands[0]); + DONE; +}) + (define_code_iterator any_logic1 [and ior xor]) (define_code_iterator any_logic2 [and ior xor]) (define_code_attr logic_op [(and "&") (ior "|") (xor "^")]) @@ -13252,7 +13613,33 @@ }) -(define_insn "_vternlog_mask" +(define_expand "_vternlog_mask" + [(set (match_operand:VI48_AVX512VL 0 "register_operand") + (vec_merge:VI48_AVX512VL + (unspec:VI48_AVX512VL + [(match_operand:VI48_AVX512VL 1 "register_operand") + (match_operand:VI48_AVX512VL 2 "register_operand") + (match_operand:VI48_AVX512VL 3 "bcst_vector_operand") + (match_operand:SI 4 "const_0_to_255_operand")] + UNSPEC_VTERNLOG) + (match_dup 1) + (match_operand: 5 "general_operand")))] + "TARGET_AVX512F" +{ + unsigned HOST_WIDE_INT mode_mask = GET_MODE_MASK (mode); + if (CONST_INT_P (operands[5]) + && (UINTVAL (operands[5]) & mode_mask) == mode_mask) + { + ix86_expand_ternlog (mode, operands[1], operands[2], + operands[3], INTVAL (operands[4]), + operands[0]); + DONE; + } + if (!register_operand (operands[5], mode)) + operands[5] = force_reg (mode, operands[5]); +}) + +(define_insn "*_vternlog_mask" [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v") (vec_merge:VI48_AVX512VL (unspec:VI48_AVX512VL @@ -30652,3 +31039,38 @@ "TARGET_AVXVNNIINT16" "vpdp\t{%3, %2, %0|%0, %2, %3}" [(set_attr "prefix" "vex")]) + +(define_mode_attr hi_cvt_bf + [(V8HI "v8bf") (V16HI "v16bf") (V32HI "v32bf")]) + +(define_mode_attr HI_CVT_BF + [(V8HI "V8BF") (V16HI "V16BF") (V32HI "V32BF")]) + +(define_insn_and_split "vpermt2_sepcial_bf16_shuffle_" + [(set (match_operand:VI2_AVX512F 0 "register_operand") + (unspec:VI2_AVX512F + [(match_operand:VI2_AVX512F 1 "vcvtne2ps2bf_parallel") + (match_operand:VI2_AVX512F 2 "register_operand") + (match_operand:VI2_AVX512F 3 "nonimmediate_operand")] + UNSPEC_VPERMT2))] + "TARGET_AVX512VL && TARGET_AVX512BF16 && ix86_pre_reload_split ()" + "#" + "&& 1" + [(const_int 0)] +{ + rtx op0 = gen_reg_rtx (mode); + operands[2] = lowpart_subreg (mode, + force_reg (mode, operands[2]), + mode); + operands[3] = lowpart_subreg (mode, + force_reg (mode, operands[3]), + mode); + + emit_insn (gen_avx512f_cvtne2ps2bf16_(op0, + operands[3], + operands[2])); + emit_move_insn (operands[0], lowpart_subreg (mode, op0, + mode)); + DONE; +} +[(set_attr "mode" "")]) diff --git a/gcc/config/i386/x86-tune.def b/gcc/config/i386/x86-tune.def index 0fa1484b48d92..66512992b7b5b 100644 --- a/gcc/config/i386/x86-tune.def +++ b/gcc/config/i386/x86-tune.def @@ -346,8 +346,8 @@ DEF_TUNE (X86_TUNE_ADJUST_UNROLL, "adjust_unroll_factor", m_BDVER3 | m_BDVER4) /* X86_TUNE_ONE_IF_CONV_INSNS: Restrict a number of cmov insns in if-converted sequence to one. */ DEF_TUNE (X86_TUNE_ONE_IF_CONV_INSN, "one_if_conv_insn", - m_SILVERMONT | m_INTEL | m_CORE_ALL | m_GOLDMONT | m_GOLDMONT_PLUS - | m_TREMONT | m_CORE_HYBRID | m_CORE_ATOM | m_ZHAOXIN | m_GENERIC) + m_SILVERMONT | m_HASWELL | m_SKYLAKE | m_GOLDMONT | m_GOLDMONT_PLUS + | m_TREMONT | m_ZHAOXIN) /* X86_TUNE_AVOID_MFENCE: Use lock prefixed instructions instead of mfence. */ DEF_TUNE (X86_TUNE_AVOID_MFENCE, "avoid_mfence", diff --git a/gcc/config/i386/xmmintrin.h b/gcc/config/i386/xmmintrin.h index c90fc71331a30..37e5a94cf1012 100644 --- a/gcc/config/i386/xmmintrin.h +++ b/gcc/config/i386/xmmintrin.h @@ -108,6 +108,25 @@ typedef float __v4sf __attribute__ ((__vector_size__ (16))); #define _MM_FLUSH_ZERO_ON 0x8000 #define _MM_FLUSH_ZERO_OFF 0x0000 +/* Compare predicates for scalar and packed compare intrinsics. */ + +/* Equal (ordered, non-signaling) */ +#define _CMP_EQ_OQ 0x00 +/* Less-than (ordered, signaling) */ +#define _CMP_LT_OS 0x01 +/* Less-than-or-equal (ordered, signaling) */ +#define _CMP_LE_OS 0x02 +/* Unordered (non-signaling) */ +#define _CMP_UNORD_Q 0x03 +/* Not-equal (unordered, non-signaling) */ +#define _CMP_NEQ_UQ 0x04 +/* Not-less-than (unordered, signaling) */ +#define _CMP_NLT_US 0x05 +/* Not-less-than-or-equal (unordered, signaling) */ +#define _CMP_NLE_US 0x06 +/* Ordered (nonsignaling) */ +#define _CMP_ORD_Q 0x07 + /* Create an undefined vector. */ extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) _mm_undefined_ps (void) @@ -434,6 +453,28 @@ _mm_cmpunord_ps (__m128 __A, __m128 __B) return (__m128) __builtin_ia32_cmpunordps ((__v4sf)__A, (__v4sf)__B); } +#ifdef __OPTIMIZE__ +extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) +_mm_cmp_ps (__m128 __X, __m128 __Y, const int __P) +{ + return (__m128) __builtin_ia32_cmpps ((__v4sf)__X, (__v4sf)__Y, __P); +} + +extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) +_mm_cmp_ss (__m128 __X, __m128 __Y, const int __P) +{ + return (__m128) __builtin_ia32_cmpss ((__v4sf)__X, (__v4sf)__Y, __P); +} +#else +#define _mm_cmp_ps(X, Y, P) \ + ((__m128) __builtin_ia32_cmpps ((__v4sf)(__m128)(X), \ + (__v4sf)(__m128)(Y), (int)(P))) + +#define _mm_cmp_ss(X, Y, P) \ + ((__m128) __builtin_ia32_cmpss ((__v4sf)(__m128)(X), \ + (__v4sf)(__m128)(Y), (int)(P))) +#endif + /* Compare the lower SPFP values of A and B and return 1 if true and 0 if false. */ diff --git a/gcc/config/loongarch/constraints.md b/gcc/config/loongarch/constraints.md index f07d31650d29d..12cf5e2924a3a 100644 --- a/gcc/config/loongarch/constraints.md +++ b/gcc/config/loongarch/constraints.md @@ -94,6 +94,7 @@ ;; "A constant @code{move_operand} that can be safely loaded using ;; @code{la}." ;; "Yx" +;; "Yy" ;; "Z" - ;; "ZC" ;; "A memory operand whose address is formed by a base register and offset @@ -291,6 +292,10 @@ "@internal" (match_operand 0 "low_bitmask_operand")) +(define_constraint "Yy" + "@internal" + (match_operand 0 "high_bitmask_operand")) + (define_constraint "YI" "@internal A replicated vector const in which the replicated value is in the range diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc index 1b6df6a436503..6ec3ee6250262 100644 --- a/gcc/config/loongarch/loongarch.cc +++ b/gcc/config/loongarch/loongarch.cc @@ -5352,7 +5352,7 @@ loongarch_expand_conditional_move (rtx *operands) loongarch_emit_float_compare (&code, &op0, &op1); else { - if (GET_MODE_SIZE (GET_MODE (op0)) < word_mode) + if (GET_MODE_SIZE (GET_MODE (op0)) < UNITS_PER_WORD) { promote_op[0] = (REG_P (op0) && REG_P (operands[2]) && REGNO (op0) == REGNO (operands[2])); diff --git a/gcc/config/loongarch/loongarch.md b/gcc/config/loongarch/loongarch.md index 5c80c169cbf12..25c1d323ba0f2 100644 --- a/gcc/config/loongarch/loongarch.md +++ b/gcc/config/loongarch/loongarch.md @@ -1542,6 +1542,23 @@ [(set_attr "move_type" "pick_ins") (set_attr "mode" "")]) +(define_insn_and_split "and3_align" + [(set (match_operand:GPR 0 "register_operand" "=r") + (and:GPR (match_operand:GPR 1 "register_operand" "r") + (match_operand:GPR 2 "high_bitmask_operand" "Yy")))] + "" + "#" + "" + [(set (match_dup 0) (match_dup 1)) + (set (zero_extract:GPR (match_dup 0) (match_dup 2) (const_int 0)) + (const_int 0))] +{ + int len; + + len = low_bitmask_len (mode, ~INTVAL (operands[2])); + operands[2] = GEN_INT (len); +}) + (define_insn_and_split "*bstrins__for_mask" [(set (match_operand:GPR 0 "register_operand" "=r") (and:GPR (match_operand:GPR 1 "register_operand" "r") diff --git a/gcc/config/loongarch/predicates.md b/gcc/config/loongarch/predicates.md index eba7f246c84d7..58e406ea522b9 100644 --- a/gcc/config/loongarch/predicates.md +++ b/gcc/config/loongarch/predicates.md @@ -293,6 +293,10 @@ (and (match_code "const_int") (match_test "low_bitmask_len (mode, INTVAL (op)) > 12"))) +(define_predicate "high_bitmask_operand" + (and (match_code "const_int") + (match_test "low_bitmask_len (mode, ~INTVAL (op)) > 0"))) + (define_predicate "d_operand" (and (match_code "reg") (match_test "GP_REG_P (REGNO (op))"))) diff --git a/gcc/config/mips/mips-cpus.def b/gcc/config/mips/mips-cpus.def index 490195406e782..17bbba42bd627 100644 --- a/gcc/config/mips/mips-cpus.def +++ b/gcc/config/mips/mips-cpus.def @@ -42,17 +42,17 @@ MIPS_CPU ("mips4", PROCESSOR_R10000, MIPS_ISA_MIPS4, PTF_AVOID_BRANCHLIKELY_SIZE in revisions 2 and earlier, but revision 3 is likely to downgrade that to a recommendation to avoid the instructions in code that isn't tuned to a specific processor. */ -MIPS_CPU ("mips32", PROCESSOR_4KC, MIPS_ISA_MIPS32, PTF_AVOID_BRANCHLIKELY_ALWAYS) +MIPS_CPU ("mips32", PROCESSOR_24KF1_1, MIPS_ISA_MIPS32, PTF_AVOID_BRANCHLIKELY_ALWAYS) MIPS_CPU ("mips32r2", PROCESSOR_74KF2_1, MIPS_ISA_MIPS32R2, PTF_AVOID_BRANCHLIKELY_ALWAYS) /* mips32r3 is micromips hense why it uses the M4K processor. */ MIPS_CPU ("mips32r3", PROCESSOR_M4K, MIPS_ISA_MIPS32R3, PTF_AVOID_BRANCHLIKELY_ALWAYS) MIPS_CPU ("mips32r5", PROCESSOR_P5600, MIPS_ISA_MIPS32R5, PTF_AVOID_BRANCHLIKELY_ALWAYS) MIPS_CPU ("mips32r6", PROCESSOR_I6400, MIPS_ISA_MIPS32R6, 0) -MIPS_CPU ("mips64", PROCESSOR_5KC, MIPS_ISA_MIPS64, PTF_AVOID_BRANCHLIKELY_ALWAYS) +MIPS_CPU ("mips64", PROCESSOR_5KF, MIPS_ISA_MIPS64, PTF_AVOID_BRANCHLIKELY_ALWAYS) /* ??? For now just tune the generic MIPS64r2 and above for 5KC as well. */ -MIPS_CPU ("mips64r2", PROCESSOR_5KC, MIPS_ISA_MIPS64R2, PTF_AVOID_BRANCHLIKELY_ALWAYS) -MIPS_CPU ("mips64r3", PROCESSOR_5KC, MIPS_ISA_MIPS64R3, PTF_AVOID_BRANCHLIKELY_ALWAYS) -MIPS_CPU ("mips64r5", PROCESSOR_5KC, MIPS_ISA_MIPS64R5, PTF_AVOID_BRANCHLIKELY_ALWAYS) +MIPS_CPU ("mips64r2", PROCESSOR_5KF, MIPS_ISA_MIPS64R2, PTF_AVOID_BRANCHLIKELY_ALWAYS) +MIPS_CPU ("mips64r3", PROCESSOR_5KF, MIPS_ISA_MIPS64R3, PTF_AVOID_BRANCHLIKELY_ALWAYS) +MIPS_CPU ("mips64r5", PROCESSOR_5KF, MIPS_ISA_MIPS64R5, PTF_AVOID_BRANCHLIKELY_ALWAYS) MIPS_CPU ("mips64r6", PROCESSOR_I6400, MIPS_ISA_MIPS64R6, 0) /* MIPS I processors. */ diff --git a/gcc/config/mips/mips-modes.def b/gcc/config/mips/mips-modes.def index 323570928fcd0..21f50a2254697 100644 --- a/gcc/config/mips/mips-modes.def +++ b/gcc/config/mips/mips-modes.def @@ -54,4 +54,5 @@ ADJUST_ALIGNMENT (CCV4, 16); CC_MODE (CCDSP); /* For floating point conditions in FP registers. */ +CC_MODE (CCE); CC_MODE (CCF); diff --git a/gcc/config/mips/mips-protos.h b/gcc/config/mips/mips-protos.h index 835f42128b914..fcc0a0ae663fa 100644 --- a/gcc/config/mips/mips-protos.h +++ b/gcc/config/mips/mips-protos.h @@ -394,4 +394,6 @@ extern bool mips_bit_clear_p (enum machine_mode, unsigned HOST_WIDE_INT); extern void mips_bit_clear_info (enum machine_mode, unsigned HOST_WIDE_INT, int *, int *); +extern const char *mips_output_compare (const char *fpcmp, const char *fcond, + const char *fmt, const char *fpcc_mode, bool swap); #endif /* ! GCC_MIPS_PROTOS_H */ diff --git a/gcc/config/mips/mips.cc b/gcc/config/mips/mips.cc index 278d94464826f..b7acf04190354 100644 --- a/gcc/config/mips/mips.cc +++ b/gcc/config/mips/mips.cc @@ -5659,7 +5659,7 @@ mips_allocate_fcc (machine_mode mode) gcc_assert (TARGET_HARD_FLOAT && ISA_HAS_8CC); - if (mode == CCmode) + if (mode == CCmode || mode == CCEmode) count = 1; else if (mode == CCV2mode) count = 2; @@ -5788,17 +5788,57 @@ mips_emit_compare (enum rtx_code *code, rtx *op0, rtx *op1, bool need_eq_ne_p) /* Three FP conditions cannot be implemented by reversing the operands for C.cond.fmt, instead a reversed condition code is required and a test for false. */ + machine_mode ccmode = CCmode; + switch (*code) + { + case LTGT: + case LT: + case LE: + ccmode = CCEmode; + break; + default: + break; + } *code = mips_reversed_fp_cond (&cmp_code) ? EQ : NE; if (ISA_HAS_8CC) - *op0 = mips_allocate_fcc (CCmode); + *op0 = mips_allocate_fcc (ccmode); else - *op0 = gen_rtx_REG (CCmode, FPSW_REGNUM); + *op0 = gen_rtx_REG (ccmode, FPSW_REGNUM); } *op1 = const0_rtx; mips_emit_binary (cmp_code, *op0, cmp_op0, cmp_op1); } } + + +const char * +mips_output_compare (const char *fpcmp, const char *fcond, + const char *fmt, const char *fpcc_mode, bool swap) +{ + const char *fc = fcond; + + if (ISA_HAS_CCF) + { + /* c.lt.fmt is signaling, while cmp.lt.fmt is quiet. */ + if (strcmp (fcond, "lt") == 0) + fc = "slt"; + else if (strcmp (fcond, "le") == 0) + fc = "sle"; + } + else if (strcmp (fpcc_mode, "cce") == 0) + { + /* It was LTGT, while we have only inverse one. It was then converted + to UNEQ by mips_reversed_fp_cond, and we used CCEmode to mark it. + Lets convert it back to ngl now. */ + if (strcmp (fcond, "ueq") == 0) + fc = "ngl"; + } + if (swap) + return concat(fpcmp, ".", fc, ".", fmt, "\t%Z0%2,%1", NULL); + return concat(fpcmp, ".", fc, ".", fmt, "\t%Z0%1,%2", NULL); +} + /* Try performing the comparison in OPERANDS[1], whose arms are OPERANDS[2] and OPERAND[3]. Store the result in OPERANDS[0]. @@ -13142,7 +13182,7 @@ mips_hard_regno_mode_ok_uncached (unsigned int regno, machine_mode mode) && ST_REG_P (regno) && (regno - ST_REG_FIRST) % 4 == 0); - if (mode == CCmode) + if (mode == CCmode || mode == CCEmode) return ISA_HAS_8CC ? ST_REG_P (regno) : regno == FPSW_REGNUM; size = GET_MODE_SIZE (mode); diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h index 9d965966f2fa9..d18ca7dad8a9a 100644 --- a/gcc/config/mips/mips.h +++ b/gcc/config/mips/mips.h @@ -1771,7 +1771,7 @@ FP_ASM_SPEC "\ /* When in 64-bit mode, move insns will sign extend SImode and CCmode moves. All other references are zero extended. */ #define LOAD_EXTEND_OP(MODE) \ - (TARGET_64BIT && ((MODE) == SImode || (MODE) == CCmode) \ + (TARGET_64BIT && ((MODE) == SImode || (MODE) == CCmode || (MODE) == CCEmode) \ ? SIGN_EXTEND : ZERO_EXTEND) /* Define this macro if it is advisable to hold scalars in registers diff --git a/gcc/config/mips/mips.md b/gcc/config/mips/mips.md index 7de85123e7c23..806fd29cf97fb 100644 --- a/gcc/config/mips/mips.md +++ b/gcc/config/mips/mips.md @@ -831,12 +831,15 @@ ;; conditional-move-type condition is needed. (define_mode_iterator MOVECC [SI (DI "TARGET_64BIT") (CC "TARGET_HARD_FLOAT + && !TARGET_LOONGSON_2EF + && !TARGET_MIPS5900") + (CCE "TARGET_HARD_FLOAT && !TARGET_LOONGSON_2EF && !TARGET_MIPS5900")]) ;; This mode iterator allows :FPCC to be used anywhere that an FP condition ;; is needed. -(define_mode_iterator FPCC [(CC "!ISA_HAS_CCF") +(define_mode_iterator FPCC [(CC "!ISA_HAS_CCF") (CCE "!ISA_HAS_CCF") (CCF "ISA_HAS_CCF")]) ;; 32-bit integer moves for which we provide move patterns. @@ -928,7 +931,7 @@ ;; This attribute gives the best constraint to use for registers of ;; a given mode. -(define_mode_attr reg [(SI "d") (DI "d") (CC "z") (CCF "f")]) +(define_mode_attr reg [(SI "d") (DI "d") (CC "z") (CCE "z") (CCF "f")]) ;; This attribute gives the format suffix for floating-point operations. (define_mode_attr fmt [(SF "s") (DF "d") (V2SF "ps")]) @@ -976,7 +979,7 @@ [(SF "!ISA_MIPS1") (DF "!ISA_MIPS1") (V2SF "TARGET_SB1")]) ;; This attribute provides the correct mnemonic for each FP condition mode. -(define_mode_attr fpcmp [(CC "c") (CCF "cmp")]) +(define_mode_attr fpcmp [(CC "c") (CCE "c") (CCF "cmp")]) ;; This code iterator allows signed and unsigned widening multiplications ;; to use the same template. @@ -1082,7 +1085,7 @@ (lt "lt") (le "le") (ordered "or") - (ltgt "ne") + (ltgt "sne") (ne "une")]) ;; Similar, but for swapped conditions. @@ -6410,7 +6413,9 @@ (fcond:FPCC (match_operand:SCALARF 1 "register_operand" "f") (match_operand:SCALARF 2 "register_operand" "f")))] "" - "..\t%Z0%1,%2" + { + return mips_output_compare ("", "", "", "", false); + } [(set_attr "type" "fcmp") (set_attr "mode" "FPSW")]) @@ -6419,7 +6424,9 @@ (swapped_fcond:FPCC (match_operand:SCALARF 1 "register_operand" "f") (match_operand:SCALARF 2 "register_operand" "f")))] "" - "..\t%Z0%2,%1" + { + return mips_output_compare ("", "", "", "", true); + } [(set_attr "type" "fcmp") (set_attr "mode" "FPSW")]) diff --git a/gcc/config/riscv/arch-canonicalize b/gcc/config/riscv/arch-canonicalize index 8f7d040cdeb97..6c10d1aa81b5b 100755 --- a/gcc/config/riscv/arch-canonicalize +++ b/gcc/config/riscv/arch-canonicalize @@ -40,6 +40,7 @@ LONG_EXT_PREFIXES = ['z', 's', 'h', 'x'] # IMPLIED_EXT = { "d" : ["f", "zicsr"], + "a" : ["zaamo", "zalrsc"], "f" : ["zicsr"], "zdinx" : ["zfinx", "zicsr"], "zfinx" : ["zicsr"], diff --git a/gcc/config/riscv/autovec-opt.md b/gcc/config/riscv/autovec-opt.md index 6a2eabbd85445..d7a3cfd4602b6 100644 --- a/gcc/config/riscv/autovec-opt.md +++ b/gcc/config/riscv/autovec-opt.md @@ -1517,8 +1517,7 @@ "&& 1" [(const_int 0)] { - if (GET_CODE (operands[2]) == SUBREG) - operands[2] = SUBREG_REG (operands[2]); + operands[2] = gen_lowpart (Pmode, operands[2]); insn_code icode = code_for_pred_vwsll_scalar (mode); riscv_vector::emit_vlmax_insn (icode, riscv_vector::BINARY_OP, operands); DONE; @@ -1584,8 +1583,7 @@ "&& 1" [(const_int 0)] { - if (GET_CODE (operands[2]) == SUBREG) - operands[2] = SUBREG_REG (operands[2]); + operands[2] = gen_lowpart (Pmode, operands[2]); insn_code icode = code_for_pred_vwsll_scalar (mode); riscv_vector::emit_vlmax_insn (icode, riscv_vector::BINARY_OP, operands); DONE; diff --git a/gcc/config/riscv/autovec.md b/gcc/config/riscv/autovec.md index 15db26d52c6ae..66d70f678a617 100644 --- a/gcc/config/riscv/autovec.md +++ b/gcc/config/riscv/autovec.md @@ -1383,7 +1383,7 @@ (define_expand "vec_extract" [(set (match_operand: 0 "register_operand") (vec_select: - (match_operand:V_VLS 1 "register_operand") + (match_operand:V_VLS_ZVFH 1 "register_operand") (parallel [(match_operand 2 "nonmemory_operand")])))] "TARGET_VECTOR" @@ -2644,6 +2644,7 @@ ;; ========================================================================= ;; Includes: ;; - add +;; - sub ;; ========================================================================= (define_expand "usadd3" [(match_operand:V_VLSI 0 "register_operand") @@ -2656,6 +2657,17 @@ } ) +(define_expand "ussub3" + [(match_operand:V_VLSI 0 "register_operand") + (match_operand:V_VLSI 1 "register_operand") + (match_operand:V_VLSI 2 "register_operand")] + "TARGET_VECTOR" + { + riscv_vector::expand_vec_ussub (operands[0], operands[1], operands[2], mode); + DONE; + } +) + ;; ========================================================================= ;; == Early break auto-vectorization patterns ;; ========================================================================= diff --git a/gcc/config/riscv/bitmanip.md b/gcc/config/riscv/bitmanip.md index 8769a6b818b7f..ae5e7e510c0e0 100644 --- a/gcc/config/riscv/bitmanip.md +++ b/gcc/config/riscv/bitmanip.md @@ -597,6 +597,54 @@ "bset\t%0,x0,%1" [(set_attr "type" "bitmanip")]) +;; The result will always have bits 32..63 clear, so the zero-extend +;; is redundant. We could split it to bset_1, but it seems +;; unnecessary. +(define_insn "*bsetdi_2" + [(set (match_operand:DI 0 "register_operand" "=r") + (zero_extend:DI + (ashift:SI (const_int 1) + (match_operand:QI 1 "register_operand" "r"))))] + "TARGET_64BIT && TARGET_ZBS" + "bset\t%0,x0,%1" + [(set_attr "type" "bitmanip")]) + +;; These two splitters take advantage of the limited range of the +;; shift constant. With the limited range we know the SImode sign +;; bit is never set, thus we can treat this as zero extending and +;; generate the bsetdi_2 pattern. +(define_split + [(set (match_operand:DI 0 "register_operand") + (any_extend:DI + (ashift:SI (const_int 1) + (subreg:QI + (and:DI (not:DI (match_operand:DI 1 "register_operand")) + (match_operand 2 "const_int_operand")) 0)))) + (clobber (match_operand:DI 3 "register_operand"))] + "TARGET_64BIT + && TARGET_ZBS + && (TARGET_ZBB || TARGET_ZBKB) + && (INTVAL (operands[2]) & 0x1f) != 0x1f" + [(set (match_dup 0) (and:DI (not:DI (match_dup 1)) (match_dup 2))) + (set (match_dup 0) (zero_extend:DI (ashift:SI + (const_int 1) + (subreg:QI (match_dup 0) 0))))]) + +(define_split + [(set (match_operand:DI 0 "register_operand") + (any_extend:DI + (ashift:SI (const_int 1) + (subreg:QI + (and:DI (match_operand:DI 1 "register_operand") + (match_operand 2 "const_int_operand")) 0))))] + "TARGET_64BIT + && TARGET_ZBS + && (INTVAL (operands[2]) & 0x1f) != 0x1f" + [(set (match_dup 0) (and:DI (match_dup 1) (match_dup 2))) + (set (match_dup 0) (zero_extend:DI (ashift:SI + (const_int 1) + (subreg:QI (match_dup 0) 0))))]) + (define_insn "*bset_1_mask" [(set (match_operand:X 0 "register_operand" "=r") (ashift:X (const_int 1) @@ -627,6 +675,38 @@ "bseti\t%0,%1,%S2" [(set_attr "type" "bitmanip")]) +;; We can easily handle zero extensions +(define_split + [(set (match_operand:DI 0 "register_operand") + (any_or:DI (zero_extend:DI + (ashift:SI (const_int 1) + (match_operand:QI 1 "register_operand"))) + (match_operand:DI 2 "single_bit_mask_operand"))) + (clobber (match_operand:DI 3 "register_operand"))] + "TARGET_64BIT && TARGET_ZBS" + [(set (match_dup 3) + (match_dup 2)) + (set (match_dup 0) + (any_or:DI (ashift:DI (const_int 1) (match_dup 1)) + (match_dup 3)))]) + +;; Yet another form of a bset/bclr that can be created by combine. +(define_insn "*bsetclr_zero_extract" + [(set (zero_extract:X (match_operand:X 0 "register_operand" "+r") + (const_int 1) + (zero_extend:X + (match_operand:QI 1 "register_operand" "r"))) + (match_operand 2 "immediate_operand" "n"))] + "TARGET_ZBS + && (operands[2] == CONST0_RTX (mode) + || operands[2] == CONST1_RTX (mode))" + { + return (operands[2] == CONST0_RTX (mode) + ? "bclr\t%0,%0,%1" + : "bset\t%0,%0,%1"); + } + [(set_attr "type" "bitmanip")]) + (define_insn "*bclr" [(set (match_operand:X 0 "register_operand" "=r") (and:X (rotate:X (const_int -2) @@ -684,6 +764,23 @@ } [(set_attr "type" "bitmanip")]) +;; An outer AND with a constant where bits 31..63 are 0 can be seen as +;; a virtual zero extension from 31 to 64 bits. +(define_split + [(set (match_operand:DI 0 "register_operand") + (and:DI (not:DI (subreg:DI + (ashift:SI (const_int 1) + (match_operand:QI 1 "register_operand")) 0)) + (match_operand:DI 2 "arith_operand"))) + (clobber (match_operand:DI 3 "register_operand"))] + "TARGET_64BIT && TARGET_ZBS + && clz_hwi (INTVAL (operands[2])) >= 33" + [(set (match_dup 3) + (match_dup 2)) + (set (match_dup 0) + (and:DI (rotate:DI (const_int -2) (match_dup 1)) + (match_dup 3)))]) + (define_insn "*binv" [(set (match_operand:X 0 "register_operand" "=r") (xor:X (ashift:X (const_int 1) @@ -754,6 +851,18 @@ "operands[1] = gen_lowpart (word_mode, operands[1]);" [(set_attr "type" "bitmanip")]) +;; The logical-and against 0x1 implicitly extends the result. So we can treat +;; an SImode bext as-if it's DImode without any explicit extension. +(define_insn "*bextdisi" + [(set (match_operand:DI 0 "register_operand" "=r") + (and:DI (subreg:DI (lshiftrt:SI + (match_operand:SI 1 "register_operand" "r") + (match_operand:QI 2 "register_operand" "r")) 0) + (const_int 1)))] + "TARGET_64BIT && TARGET_ZBS" + "bext\t%0,%1,%2" + [(set_attr "type" "bitmanip")]) + ;; When performing `(a & (1UL << bitno)) ? 0 : -1` the combiner ;; usually has the `bitno` typed as X-mode (i.e. no further ;; zero-extension is performed around the bitno). diff --git a/gcc/config/riscv/freebsd.h b/gcc/config/riscv/freebsd.h index 5dd4d51c42bc7..6063861e7045e 100644 --- a/gcc/config/riscv/freebsd.h +++ b/gcc/config/riscv/freebsd.h @@ -42,6 +42,7 @@ along with GCC; see the file COPYING3. If not see #define LINK_SPEC " \ -melf" XLEN_SPEC DEFAULT_ENDIAN_SPEC "riscv \ %{p:%nconsider using `-pg' instead of `-p' with gprof (1)} \ + " FBSD_LINK_PG_NOTES " \ %{v:-V} \ %{assert*} %{R*} %{rpath*} %{defsym*} \ -X \ diff --git a/gcc/config/riscv/riscv-protos.h b/gcc/config/riscv/riscv-protos.h index 0704968561bb5..d6473d0cd8554 100644 --- a/gcc/config/riscv/riscv-protos.h +++ b/gcc/config/riscv/riscv-protos.h @@ -134,6 +134,7 @@ extern bool riscv_zcmp_valid_stack_adj_bytes_p (HOST_WIDE_INT, int); extern void riscv_legitimize_poly_move (machine_mode, rtx, rtx, rtx); extern void riscv_expand_usadd (rtx, rtx, rtx); +extern void riscv_expand_ussub (rtx, rtx, rtx); #ifdef RTX_CODE extern void riscv_expand_int_scc (rtx, enum rtx_code, rtx, rtx, bool *invert_ptr = 0); @@ -637,6 +638,7 @@ void expand_vec_lround (rtx, rtx, machine_mode, machine_mode, machine_mode); void expand_vec_lceil (rtx, rtx, machine_mode, machine_mode); void expand_vec_lfloor (rtx, rtx, machine_mode, machine_mode); void expand_vec_usadd (rtx, rtx, rtx, machine_mode); +void expand_vec_ussub (rtx, rtx, rtx, machine_mode); #endif bool sew64_scalar_helper (rtx *, rtx *, rtx, machine_mode, bool, void (*)(rtx *, rtx), enum avl_type); diff --git a/gcc/config/riscv/riscv-target-attr.cc b/gcc/config/riscv/riscv-target-attr.cc index 1a73d69bf50d3..19eb7b06d5481 100644 --- a/gcc/config/riscv/riscv-target-attr.cc +++ b/gcc/config/riscv/riscv-target-attr.cc @@ -109,7 +109,7 @@ riscv_target_attr_parser::parse_arch (const char *str) { /* Parsing the extension list like "+[,+]*". */ size_t len = strlen (str); - std::unique_ptr buf (new char[len]); + std::unique_ptr buf (new char[len+1]); char *str_to_check = buf.get (); strcpy (str_to_check, str); const char *token = strtok_r (str_to_check, ",", &str_to_check); @@ -247,7 +247,7 @@ riscv_process_one_target_attr (char *arg_str, return false; } - std::unique_ptr buf (new char[len]); + std::unique_ptr buf (new char[len+1]); char *str_to_check = buf.get(); strcpy (str_to_check, arg_str); @@ -334,7 +334,7 @@ riscv_process_target_attr (tree fndecl, tree args, location_t loc, return false; } - std::unique_ptr buf (new char[len]); + std::unique_ptr buf (new char[len+1]); char *str_to_check = buf.get (); strcpy (str_to_check, TREE_STRING_POINTER (args)); diff --git a/gcc/config/riscv/riscv-v.cc b/gcc/config/riscv/riscv-v.cc index 948aaf7d8dd4a..5306711c1b738 100644 --- a/gcc/config/riscv/riscv-v.cc +++ b/gcc/config/riscv/riscv-v.cc @@ -50,6 +50,7 @@ #include "rtx-vector-builder.h" #include "targhooks.h" #include "predict.h" +#include "errors.h" using namespace riscv_vector; @@ -290,11 +291,17 @@ template class insn_expander always Pmode. */ if (mode == VOIDmode) mode = Pmode; - else - /* Early assertion ensures same mode since maybe_legitimize_operand - will check this. */ - gcc_assert (GET_MODE (ops[opno]) == VOIDmode - || GET_MODE (ops[opno]) == mode); + + /* Early assertion ensures same mode since maybe_legitimize_operand + will check this. */ + machine_mode required_mode = GET_MODE (ops[opno]); + if (required_mode != VOIDmode && required_mode != mode) + internal_error ("expected mode %s for operand %d of " + "insn %s but got mode %s.\n", + GET_MODE_NAME (mode), + opno, + insn_data[(int) icode].name, + GET_MODE_NAME (required_mode)); add_input_operand (ops[opno], mode); } @@ -346,7 +353,13 @@ template class insn_expander else if (m_insn_flags & VXRM_RDN_P) add_rounding_mode_operand (VXRM_RDN); - gcc_assert (insn_data[(int) icode].n_operands == m_opno); + + if (insn_data[(int) icode].n_operands != m_opno) + internal_error ("invalid number of operands for insn %s, " + "expected %d but got %d.\n", + insn_data[(int) icode].name, + insn_data[(int) icode].n_operands, m_opno); + expand (icode, any_mem_p); } @@ -4634,13 +4647,13 @@ emit_vec_cvt_x_f_rtz (rtx op_dest, rtx op_src, rtx mask, } static void -emit_vec_saddu (rtx op_dest, rtx op_1, rtx op_2, insn_type type, - machine_mode vec_mode) +emit_vec_binary_alu (rtx op_dest, rtx op_1, rtx op_2, enum rtx_code rcode, + machine_mode vec_mode) { rtx ops[] = {op_dest, op_1, op_2}; - insn_code icode = code_for_pred (US_PLUS, vec_mode); + insn_code icode = code_for_pred (rcode, vec_mode); - emit_vlmax_insn (icode, type, ops); + emit_vlmax_insn (icode, BINARY_OP, ops); } void @@ -4876,7 +4889,16 @@ expand_vec_lfloor (rtx op_0, rtx op_1, machine_mode vec_fp_mode, void expand_vec_usadd (rtx op_0, rtx op_1, rtx op_2, machine_mode vec_mode) { - emit_vec_saddu (op_0, op_1, op_2, BINARY_OP, vec_mode); + emit_vec_binary_alu (op_0, op_1, op_2, US_PLUS, vec_mode); +} + +/* Expand the standard name usadd3 for vector mode, we can leverage + the vector fixed point vector single-width saturating add directly. */ + +void +expand_vec_ussub (rtx op_0, rtx op_1, rtx op_2, machine_mode vec_mode) +{ + emit_vec_binary_alu (op_0, op_1, op_2, US_MINUS, vec_mode); } /* Vectorize popcount by the Wilkes-Wheeler-Gill algorithm that libgcc uses as diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 9704ff9c6a024..c17141d909aeb 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -2720,7 +2720,7 @@ riscv_move_integer (rtx temp, rtx dest, HOST_WIDE_INT value, struct riscv_integer_op codes[RISCV_MAX_INTEGER_OPS]; machine_mode mode; int i, num_ops; - rtx x; + rtx x = NULL_RTX; mode = GET_MODE (dest); /* We use the original mode for the riscv_build_integer call, because HImode @@ -11612,6 +11612,41 @@ riscv_expand_usadd (rtx dest, rtx x, rtx y) emit_move_insn (dest, gen_lowpart (mode, xmode_dest)); } +/* Implements the unsigned saturation sub standard name usadd for int mode. + + z = SAT_SUB(x, y). + => + 1. minus = x - y. + 2. lt = x < y. + 3. lt = lt - 1. + 4. z = minus & lt. */ + +void +riscv_expand_ussub (rtx dest, rtx x, rtx y) +{ + machine_mode mode = GET_MODE (dest); + rtx pmode_x = gen_lowpart (Pmode, x); + rtx pmode_y = gen_lowpart (Pmode, y); + rtx pmode_lt = gen_reg_rtx (Pmode); + rtx pmode_minus = gen_reg_rtx (Pmode); + rtx pmode_dest = gen_reg_rtx (Pmode); + + /* Step-1: minus = x - y */ + riscv_emit_binary (MINUS, pmode_minus, pmode_x, pmode_y); + + /* Step-2: lt = x < y */ + riscv_emit_binary (LTU, pmode_lt, pmode_x, pmode_y); + + /* Step-3: lt = lt - 1 (lt + (-1)) */ + riscv_emit_binary (PLUS, pmode_lt, pmode_lt, CONSTM1_RTX (Pmode)); + + /* Step-4: pmode_dest = minus & lt */ + riscv_emit_binary (AND, pmode_dest, pmode_lt, pmode_minus); + + /* Step-5: dest = pmode_dest */ + emit_move_insn (dest, gen_lowpart (mode, pmode_dest)); +} + /* Initialize the GCC target structure. */ #undef TARGET_ASM_ALIGNED_HI_OP #define TARGET_ASM_ALIGNED_HI_OP "\t.half\t" diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md index e57bfcf616aed..7a9454de4307f 100644 --- a/gcc/config/riscv/riscv.md +++ b/gcc/config/riscv/riscv.md @@ -4228,6 +4228,17 @@ } ) +(define_expand "ussub3" + [(match_operand:ANYI 0 "register_operand") + (match_operand:ANYI 1 "register_operand") + (match_operand:ANYI 2 "register_operand")] + "" + { + riscv_expand_ussub (operands[0], operands[1], operands[2]); + DONE; + } +) + ;; These are forms of (x << C1) + C2, potentially canonicalized from ;; ((x + C2') << C1. Depending on the cost to load C2 vs C2' we may ;; want to go ahead and recognize this form as C2 may be cheaper to diff --git a/gcc/config/riscv/riscv.opt b/gcc/config/riscv/riscv.opt index 78cb1c37e69fa..b13e993c47a21 100644 --- a/gcc/config/riscv/riscv.opt +++ b/gcc/config/riscv/riscv.opt @@ -256,7 +256,11 @@ Mask(ZICCRSE) Var(riscv_zi_subext) TargetVariable int riscv_za_subext -Mask(ZAWRS) Var(riscv_za_subext) +Mask(ZAWRS) Var(riscv_za_subext) + +Mask(ZAAMO) Var(riscv_za_subext) + +Mask(ZALRSC) Var(riscv_za_subext) Mask(ZA64RS) Var(riscv_za_subext) diff --git a/gcc/config/riscv/sync-rvwmo.md b/gcc/config/riscv/sync-rvwmo.md index e639a1e23924d..5db94c8c27fa2 100644 --- a/gcc/config/riscv/sync-rvwmo.md +++ b/gcc/config/riscv/sync-rvwmo.md @@ -47,9 +47,9 @@ ;; Atomic memory operations. (define_insn "atomic_load_rvwmo" - [(set (match_operand:GPR 0 "register_operand" "=r") - (unspec_volatile:GPR - [(match_operand:GPR 1 "memory_operand" "A") + [(set (match_operand:ANYI 0 "register_operand" "=r") + (unspec_volatile:ANYI + [(match_operand:ANYI 1 "memory_operand" "A") (match_operand:SI 2 "const_int_operand")] ;; model UNSPEC_ATOMIC_LOAD))] "!TARGET_ZTSO" @@ -59,13 +59,13 @@ if (model == MEMMODEL_SEQ_CST) return "fence\trw,rw\;" - "l\t%0,%1\;" + "\t%0,%1\;" "fence\tr,rw"; if (model == MEMMODEL_ACQUIRE) - return "l\t%0,%1\;" + return "\t%0,%1\;" "fence\tr,rw"; else - return "l\t%0,%1"; + return "\t%0,%1"; } [(set_attr "type" "multi") (set (attr "length") (const_int 12))]) @@ -73,9 +73,9 @@ ;; Implement atomic stores with conservative fences. ;; This allows us to be compatible with the ISA manual Table A.6 and Table A.7. (define_insn "atomic_store_rvwmo" - [(set (match_operand:GPR 0 "memory_operand" "=A") - (unspec_volatile:GPR - [(match_operand:GPR 1 "reg_or_0_operand" "rJ") + [(set (match_operand:ANYI 0 "memory_operand" "=A") + (unspec_volatile:ANYI + [(match_operand:ANYI 1 "reg_or_0_operand" "rJ") (match_operand:SI 2 "const_int_operand")] ;; model UNSPEC_ATOMIC_STORE))] "!TARGET_ZTSO" @@ -85,13 +85,13 @@ if (model == MEMMODEL_SEQ_CST) return "fence\trw,w\;" - "s\t%z1,%0\;" + "\t%z1,%0\;" "fence\trw,rw"; if (model == MEMMODEL_RELEASE) return "fence\trw,w\;" - "s\t%z1,%0"; + "\t%z1,%0"; else - return "s\t%z1,%0"; + return "\t%z1,%0"; } [(set_attr "type" "multi") (set (attr "length") (const_int 12))]) diff --git a/gcc/config/riscv/sync-ztso.md b/gcc/config/riscv/sync-ztso.md index 0a866d2906bdb..f99a21b45ca41 100644 --- a/gcc/config/riscv/sync-ztso.md +++ b/gcc/config/riscv/sync-ztso.md @@ -41,9 +41,9 @@ ;; Atomic memory operations. (define_insn "atomic_load_ztso" - [(set (match_operand:GPR 0 "register_operand" "=r") - (unspec_volatile:GPR - [(match_operand:GPR 1 "memory_operand" "A") + [(set (match_operand:ANYI 0 "register_operand" "=r") + (unspec_volatile:ANYI + [(match_operand:ANYI 1 "memory_operand" "A") (match_operand:SI 2 "const_int_operand")] ;; model UNSPEC_ATOMIC_LOAD))] "TARGET_ZTSO" @@ -53,17 +53,17 @@ if (model == MEMMODEL_SEQ_CST) return "fence\trw,rw\;" - "l\t%0,%1"; + "\t%0,%1"; else - return "l\t%0,%1"; + return "\t%0,%1"; } [(set_attr "type" "multi") (set (attr "length") (const_int 12))]) (define_insn "atomic_store_ztso" - [(set (match_operand:GPR 0 "memory_operand" "=A") - (unspec_volatile:GPR - [(match_operand:GPR 1 "reg_or_0_operand" "rJ") + [(set (match_operand:ANYI 0 "memory_operand" "=A") + (unspec_volatile:ANYI + [(match_operand:ANYI 1 "reg_or_0_operand" "rJ") (match_operand:SI 2 "const_int_operand")] ;; model UNSPEC_ATOMIC_STORE))] "TARGET_ZTSO" @@ -72,10 +72,10 @@ model = memmodel_base (model); if (model == MEMMODEL_SEQ_CST) - return "s\t%z1,%0\;" + return "\t%z1,%0\;" "fence\trw,rw"; else - return "s\t%z1,%0"; + return "\t%z1,%0"; } [(set_attr "type" "multi") (set (attr "length") (const_int 8))]) diff --git a/gcc/config/riscv/sync.md b/gcc/config/riscv/sync.md index 6f0b5aae08dcb..4784375449f02 100644 --- a/gcc/config/riscv/sync.md +++ b/gcc/config/riscv/sync.md @@ -57,8 +57,8 @@ ;; Atomic memory operations. (define_expand "atomic_load" - [(match_operand:GPR 0 "register_operand") - (match_operand:GPR 1 "memory_operand") + [(match_operand:ANYI 0 "register_operand") + (match_operand:ANYI 1 "memory_operand") (match_operand:SI 2 "const_int_operand")] ;; model "" { @@ -72,8 +72,8 @@ }) (define_expand "atomic_store" - [(match_operand:GPR 0 "memory_operand") - (match_operand:GPR 1 "reg_or_0_operand") + [(match_operand:ANYI 0 "memory_operand") + (match_operand:ANYI 1 "reg_or_0_operand") (match_operand:SI 2 "const_int_operand")] ;; model "" { @@ -86,19 +86,73 @@ DONE; }) -(define_insn "atomic_" +;; AMO ops + +(define_expand "atomic_" + [(any_atomic:GPR (match_operand:GPR 0 "memory_operand") ;; mem location + (match_operand:GPR 1 "reg_or_0_operand")) ;; value for op + (match_operand:SI 2 "const_int_operand")] ;; model + "TARGET_ZAAMO || TARGET_ZALRSC" +{ + if (TARGET_ZAAMO) + emit_insn (gen_amo_atomic_ (operands[0], operands[1], + operands[2])); + else + emit_insn (gen_lrsc_atomic_ (operands[0], operands[1], + operands[2])); + DONE; +}) + +(define_insn "amo_atomic_" [(set (match_operand:GPR 0 "memory_operand" "+A") (unspec_volatile:GPR [(any_atomic:GPR (match_dup 0) (match_operand:GPR 1 "reg_or_0_operand" "rJ")) (match_operand:SI 2 "const_int_operand")] ;; model UNSPEC_SYNC_OLD_OP))] - "TARGET_ATOMIC" + "TARGET_ZAAMO" "amo.%A2\tzero,%z1,%0" [(set_attr "type" "atomic") (set (attr "length") (const_int 4))]) -(define_insn "atomic_fetch_" +(define_insn "lrsc_atomic_" + [(set (match_operand:GPR 0 "memory_operand" "+A") + (unspec_volatile:GPR + [(any_atomic:GPR (match_dup 0) + (match_operand:GPR 1 "reg_or_0_operand" "rJ")) + (match_operand:SI 2 "const_int_operand")] ;; model + UNSPEC_SYNC_OLD_OP)) + (clobber (match_scratch:GPR 3 "=&r"))] ;; tmp_1 + "!TARGET_ZAAMO && TARGET_ZALRSC" + { + return "1:\;" + "lr.%I2\t%3, %0\;" + "\t%3, %3, %1\;" + "sc.%J2\t%3, %3, %0\;" + "bnez\t%3, 1b"; + } + [(set_attr "type" "atomic") + (set (attr "length") (const_int 16))]) + +;; AMO fetch ops + +(define_expand "atomic_fetch_" + [(match_operand:GPR 0 "register_operand") ;; old value at mem + (any_atomic:GPR (match_operand:GPR 1 "memory_operand") ;; mem location + (match_operand:GPR 2 "reg_or_0_operand")) ;; value for op + (match_operand:SI 3 "const_int_operand")] ;; model + "TARGET_ZAAMO || TARGET_ZALRSC" + { + if (TARGET_ZAAMO) + emit_insn (gen_amo_atomic_fetch_ (operands[0], operands[1], + operands[2], operands[3])); + else + emit_insn (gen_lrsc_atomic_fetch_ (operands[0], operands[1], + operands[2], operands[3])); + DONE; + }) + +(define_insn "amo_atomic_fetch_" [(set (match_operand:GPR 0 "register_operand" "=&r") (match_operand:GPR 1 "memory_operand" "+A")) (set (match_dup 1) @@ -107,11 +161,32 @@ (match_operand:GPR 2 "reg_or_0_operand" "rJ")) (match_operand:SI 3 "const_int_operand")] ;; model UNSPEC_SYNC_OLD_OP))] - "TARGET_ATOMIC" + "TARGET_ZAAMO" "amo.%A3\t%0,%z2,%1" [(set_attr "type" "atomic") (set (attr "length") (const_int 4))]) +(define_insn "lrsc_atomic_fetch_" + [(set (match_operand:GPR 0 "register_operand" "=&r") + (match_operand:GPR 1 "memory_operand" "+A")) + (set (match_dup 1) + (unspec_volatile:GPR + [(any_atomic:GPR (match_dup 1) + (match_operand:GPR 2 "reg_or_0_operand" "rJ")) + (match_operand:SI 3 "const_int_operand")] ;; model + UNSPEC_SYNC_OLD_OP)) + (clobber (match_scratch:GPR 4 "=&r"))] ;; tmp_1 + "!TARGET_ZAAMO && TARGET_ZALRSC" + { + return "1:\;" + "lr.%I3\t%0, %1\;" + "\t%4, %0, %2\;" + "sc.%J3\t%4, %4, %1\;" + "bnez\t%4, 1b"; + } + [(set_attr "type" "atomic") + (set (attr "length") (const_int 20))]) + (define_insn "subword_atomic_fetch_strong_" [(set (match_operand:SI 0 "register_operand" "=&r") ;; old value at mem (match_operand:SI 1 "memory_operand" "+A")) ;; mem location @@ -125,7 +200,7 @@ (match_operand:SI 5 "register_operand" "rI") ;; not_mask (clobber (match_scratch:SI 6 "=&r")) ;; tmp_1 (clobber (match_scratch:SI 7 "=&r"))] ;; tmp_2 - "TARGET_ATOMIC && TARGET_INLINE_SUBWORD_ATOMIC" + "TARGET_ZALRSC && TARGET_INLINE_SUBWORD_ATOMIC" { return "1:\;" "lr.w%I3\t%0, %1\;" @@ -144,7 +219,7 @@ (not:SHORT (and:SHORT (match_operand:SHORT 1 "memory_operand") ;; mem location (match_operand:SHORT 2 "reg_or_0_operand"))) ;; value for op (match_operand:SI 3 "const_int_operand")] ;; model - "TARGET_ATOMIC && TARGET_INLINE_SUBWORD_ATOMIC" + "TARGET_ZALRSC && TARGET_INLINE_SUBWORD_ATOMIC" { /* We have no QImode/HImode atomics, so form a mask, then use subword_atomic_fetch_strong_nand to implement a LR/SC version of the @@ -192,7 +267,7 @@ (match_operand:SI 5 "register_operand" "rI") ;; not_mask (clobber (match_scratch:SI 6 "=&r")) ;; tmp_1 (clobber (match_scratch:SI 7 "=&r"))] ;; tmp_2 - "TARGET_ATOMIC && TARGET_INLINE_SUBWORD_ATOMIC" + "TARGET_ZALRSC && TARGET_INLINE_SUBWORD_ATOMIC" { return "1:\;" "lr.w%I3\t%0, %1\;" @@ -212,7 +287,7 @@ (any_atomic:SHORT (match_operand:SHORT 1 "memory_operand") ;; mem location (match_operand:SHORT 2 "reg_or_0_operand")) ;; value for op (match_operand:SI 3 "const_int_operand")] ;; model - "TARGET_ATOMIC && TARGET_INLINE_SUBWORD_ATOMIC" + "TARGET_ZALRSC && TARGET_INLINE_SUBWORD_ATOMIC" { /* We have no QImode/HImode atomics, so form a mask, then use subword_atomic_fetch_strong_ to implement a LR/SC version of the @@ -248,7 +323,23 @@ DONE; }) -(define_insn "atomic_exchange" +(define_expand "atomic_exchange" + [(match_operand:GPR 0 "register_operand") ;; old value at mem + (match_operand:GPR 1 "memory_operand") ;; mem location + (match_operand:GPR 2 "register_operand") ;; value for op + (match_operand:SI 3 "const_int_operand")] ;; model + "TARGET_ZAAMO || TARGET_ZALRSC" + { + if (TARGET_ZAAMO) + emit_insn (gen_amo_atomic_exchange (operands[0], operands[1], + operands[2], operands[3])); + else + emit_insn (gen_lrsc_atomic_exchange (operands[0], operands[1], + operands[2], operands[3])); + DONE; + }) + +(define_insn "amo_atomic_exchange" [(set (match_operand:GPR 0 "register_operand" "=&r") (unspec_volatile:GPR [(match_operand:GPR 1 "memory_operand" "+A") @@ -256,17 +347,37 @@ UNSPEC_SYNC_EXCHANGE)) (set (match_dup 1) (match_operand:GPR 2 "register_operand" "0"))] - "TARGET_ATOMIC" + "TARGET_ZAAMO" "amoswap.%A3\t%0,%z2,%1" [(set_attr "type" "atomic") (set (attr "length") (const_int 4))]) +(define_insn "lrsc_atomic_exchange" + [(set (match_operand:GPR 0 "register_operand" "=&r") + (unspec_volatile:GPR + [(match_operand:GPR 1 "memory_operand" "+A") + (match_operand:SI 3 "const_int_operand")] ;; model + UNSPEC_SYNC_EXCHANGE)) + (set (match_dup 1) + (match_operand:GPR 2 "register_operand" "0")) + (clobber (match_scratch:GPR 4 "=&r"))] ;; tmp_1 + "!TARGET_ZAAMO && TARGET_ZALRSC" + { + return "1:\;" + "lr.%I3\t%4, %1\;" + "sc.%J3\t%0, %0, %1\;" + "bnez\t%0, 1b\;" + "mv\t%0, %4"; + } + [(set_attr "type" "atomic") + (set (attr "length") (const_int 20))]) + (define_expand "atomic_exchange" [(match_operand:SHORT 0 "register_operand") ;; old value at mem (match_operand:SHORT 1 "memory_operand") ;; mem location (match_operand:SHORT 2 "register_operand") ;; value (match_operand:SI 3 "const_int_operand")] ;; model - "TARGET_ATOMIC && TARGET_INLINE_SUBWORD_ATOMIC" + "TARGET_ZALRSC && TARGET_INLINE_SUBWORD_ATOMIC" { rtx old = gen_reg_rtx (SImode); rtx mem = operands[1]; @@ -303,7 +414,7 @@ UNSPEC_SYNC_EXCHANGE_SUBWORD)) (match_operand:SI 4 "reg_or_0_operand" "rI") ;; not_mask (clobber (match_scratch:SI 5 "=&r"))] ;; tmp_1 - "TARGET_ATOMIC && TARGET_INLINE_SUBWORD_ATOMIC" + "TARGET_ZALRSC && TARGET_INLINE_SUBWORD_ATOMIC" { return "1:\;" "lr.w%I3\t%0, %1\;" @@ -325,7 +436,7 @@ (match_operand:SI 5 "const_int_operand")] ;; mod_f UNSPEC_COMPARE_AND_SWAP)) (clobber (match_scratch:GPR 6 "=&r"))] - "TARGET_ATOMIC" + "TARGET_ZALRSC" { enum memmodel model_success = (enum memmodel) INTVAL (operands[4]); enum memmodel model_failure = (enum memmodel) INTVAL (operands[5]); @@ -351,7 +462,7 @@ (match_operand:SI 5 "const_int_operand" "") ;; is_weak (match_operand:SI 6 "const_int_operand" "") ;; mod_s (match_operand:SI 7 "const_int_operand" "")] ;; mod_f - "TARGET_ATOMIC" + "TARGET_ZALRSC" { if (word_mode != mode && operands[3] != const0_rtx) { @@ -394,7 +505,7 @@ (match_operand:SI 5 "const_int_operand") ;; is_weak (match_operand:SI 6 "const_int_operand") ;; mod_s (match_operand:SI 7 "const_int_operand")] ;; mod_f - "TARGET_ATOMIC && TARGET_INLINE_SUBWORD_ATOMIC" + "TARGET_ZALRSC && TARGET_INLINE_SUBWORD_ATOMIC" { emit_insn (gen_atomic_cas_value_strong (operands[1], operands[2], operands[3], operands[4], @@ -439,7 +550,7 @@ (match_operand:SI 4 "const_int_operand") ;; mod_s (match_operand:SI 5 "const_int_operand") ;; mod_f (match_scratch:SHORT 6)] - "TARGET_ATOMIC && TARGET_INLINE_SUBWORD_ATOMIC" + "TARGET_ZALRSC && TARGET_INLINE_SUBWORD_ATOMIC" { /* We have no QImode/HImode atomics, so form a mask, then use subword_atomic_cas_strong to implement a LR/SC version of the @@ -497,7 +608,7 @@ (match_operand:SI 5 "register_operand" "rI") ;; mask (match_operand:SI 6 "register_operand" "rI") ;; not_mask (clobber (match_scratch:SI 7 "=&r"))] ;; tmp_1 - "TARGET_ATOMIC && TARGET_INLINE_SUBWORD_ATOMIC" + "TARGET_ZALRSC && TARGET_INLINE_SUBWORD_ATOMIC" { return "1:\;" "lr.w%I4\t%0, %1\;" @@ -516,7 +627,7 @@ [(match_operand:QI 0 "register_operand" "") ;; bool output (match_operand:QI 1 "memory_operand" "+A") ;; memory (match_operand:SI 2 "const_int_operand" "")] ;; model - "TARGET_ATOMIC" + "TARGET_ZAAMO || TARGET_ZALRSC" { /* We have no QImode atomics, so use the address LSBs to form a mask, then use an aligned SImode atomic. */ @@ -537,7 +648,10 @@ rtx shifted_set = gen_reg_rtx (SImode); riscv_lshift_subword (QImode, set, shift, &shifted_set); - emit_insn (gen_atomic_fetch_orsi (old, aligned_mem, shifted_set, model)); + if (TARGET_ZAAMO) + emit_insn (gen_amo_atomic_fetch_orsi (old, aligned_mem, shifted_set, model)); + else if (TARGET_ZALRSC) + emit_insn (gen_lrsc_atomic_fetch_orsi (old, aligned_mem, shifted_set, model)); emit_move_insn (old, gen_rtx_ASHIFTRT (SImode, old, gen_lowpart (QImode, shift))); diff --git a/gcc/config/riscv/vector-iterators.md b/gcc/config/riscv/vector-iterators.md index 76c27035a7351..43137a2a379b8 100644 --- a/gcc/config/riscv/vector-iterators.md +++ b/gcc/config/riscv/vector-iterators.md @@ -1574,10 +1574,16 @@ (define_mode_iterator VLS [VLSI VLSF_ZVFHMIN]) +(define_mode_iterator VLS_ZVFH [VLSI VLSF]) + (define_mode_iterator V [VI VF_ZVFHMIN]) +(define_mode_iterator V_ZVFH [VI VF]) + (define_mode_iterator V_VLS [V VLS]) +(define_mode_iterator V_VLS_ZVFH [V_ZVFH VLS_ZVFH]) + (define_mode_iterator V_VLSI [VI VLSI]) (define_mode_iterator V_VLSF [VF VLSF]) diff --git a/gcc/config/rl78/rl78.cc b/gcc/config/rl78/rl78.cc index e5345bfa9dd9b..b4bb145b5a690 100644 --- a/gcc/config/rl78/rl78.cc +++ b/gcc/config/rl78/rl78.cc @@ -367,6 +367,7 @@ rl78_option_override (void) && strcmp (lang_hooks.name, "GNU C11") && strcmp (lang_hooks.name, "GNU C17") && strcmp (lang_hooks.name, "GNU C23") + && strcmp (lang_hooks.name, "GNU C2Y") && strcmp (lang_hooks.name, "GNU C89") && strcmp (lang_hooks.name, "GNU C99") /* Compiling with -flto results in a language of GNU GIMPLE being used... */ diff --git a/gcc/config/rs6000/freebsd64.h b/gcc/config/rs6000/freebsd64.h index 55e75cfb66a3e..6740170d3cc82 100644 --- a/gcc/config/rs6000/freebsd64.h +++ b/gcc/config/rs6000/freebsd64.h @@ -112,6 +112,7 @@ extern int dot_symbols; #define LINK_OS_FREEBSD_SPEC_DEF "\ %{p:%nconsider using `-pg' instead of `-p' with gprof(1)} \ + " FBSD_LINK_PG_NOTE " \ %{v:-V} \ %{assert*} %{R*} %{rpath*} %{defsym*} \ %{shared:-Bshareable %{h*} %{soname*}} \ diff --git a/gcc/config/rs6000/rs6000-builtin.cc b/gcc/config/rs6000/rs6000-builtin.cc index e96d5157e4ddd..bb9da68edc733 100644 --- a/gcc/config/rs6000/rs6000-builtin.cc +++ b/gcc/config/rs6000/rs6000-builtin.cc @@ -835,7 +835,10 @@ rs6000_init_builtins (void) TYPE_QUAL_CONST)); /* Execute the autogenerated initialization code for builtins. */ - rs6000_init_generated_builtins (); + rs6000_init_generated_builtins (rs6000_builtin_info_fntype, + rs6000_instance_info_fntype, + rs6000_overload_info, + rs6000_builtin_decls); if (TARGET_DEBUG_BUILTIN) { diff --git a/gcc/config/rs6000/rs6000-gen-builtins.cc b/gcc/config/rs6000/rs6000-gen-builtins.cc index 7ae932220bb80..9af92cc5185d1 100644 --- a/gcc/config/rs6000/rs6000-gen-builtins.cc +++ b/gcc/config/rs6000/rs6000-gen-builtins.cc @@ -2376,7 +2376,10 @@ write_decls (void) "rs6000_instance_info_fntype[RS6000_INST_MAX];\n"); fprintf (header_file, "extern ovldrecord rs6000_overload_info[];\n\n"); - fprintf (header_file, "extern void rs6000_init_generated_builtins ();\n\n"); + fprintf (header_file, + "extern void rs6000_init_generated_builtins (tree *, tree *,\n"); + fprintf (header_file, + "\t\t\t\t\t ovldrecord *, tree *);\n\n"); fprintf (header_file, "extern bool rs6000_builtin_is_supported (rs6000_gen_builtins);\n"); fprintf (header_file, @@ -2651,7 +2654,7 @@ write_init_bif_table (void) for (int i = 0; i <= curr_bif; i++) { fprintf (init_file, - " rs6000_builtin_info_fntype[RS6000_BIF_%s]" + " builtin_info_fntype[RS6000_BIF_%s]" "\n = %s;\n", bifs[i].idname, bifs[i].fndecl); @@ -2678,7 +2681,7 @@ write_init_bif_table (void) } fprintf (init_file, - " rs6000_builtin_decls[(int)RS6000_BIF_%s] = t\n", + " builtin_decls[(int)RS6000_BIF_%s] = t\n", bifs[i].idname); fprintf (init_file, " = add_builtin_function (\"%s\",\n", @@ -2719,7 +2722,7 @@ write_init_bif_table (void) fprintf (init_file, " }\n"); fprintf (init_file, " else\n"); fprintf (init_file, " {\n"); - fprintf (init_file, " rs6000_builtin_decls" + fprintf (init_file, " builtin_decls" "[(int)RS6000_BIF_%s] = NULL_TREE;\n", bifs[i].idname); fprintf (init_file, " }\n"); } @@ -2740,7 +2743,7 @@ write_init_ovld_table (void) for (int i = 0; i <= curr_ovld; i++) { fprintf (init_file, - " rs6000_instance_info_fntype[RS6000_INST_%s]" + " instance_info_fntype[RS6000_INST_%s]" "\n = %s;\n", ovlds[i].ovld_id_name, ovlds[i].fndecl); @@ -2772,7 +2775,7 @@ write_init_ovld_table (void) } fprintf (init_file, - " rs6000_builtin_decls[(int)RS6000_OVLD_%s] = t\n", + " builtin_decls[(int)RS6000_OVLD_%s] = t\n", stanza->stanza_id); fprintf (init_file, " = add_builtin_function (\"%s\",\n", @@ -2793,7 +2796,7 @@ write_init_ovld_table (void) fprintf (init_file, "\n"); fprintf (init_file, - " rs6000_overload_info[RS6000_OVLD_%s - base]" + " overload_info[RS6000_OVLD_%s - base]" ".first_instance\n", stanza->stanza_id); fprintf (init_file, @@ -2826,19 +2829,30 @@ write_init_file (void) write_bif_static_init (); write_ovld_static_init (); + /* The reason to pass pointers to the function instead of accessing + the rs6000_{{builtin,instance}_info_fntype,overload_info,builtin_decls} + arrays directly is to decrease size of the already large function and + noipa prevents the compiler with LTO to undo that optimization. */ + fprintf (init_file, "#if GCC_VERSION >= 8001\n"); + fprintf (init_file, "__attribute__((__noipa__))\n"); + fprintf (init_file, "#endif\n"); fprintf (init_file, "void\n"); - fprintf (init_file, "rs6000_init_generated_builtins ()\n"); + fprintf (init_file, + "rs6000_init_generated_builtins (tree *builtin_info_fntype,\n"); + fprintf (init_file, "\t\t\t\ttree *instance_info_fntype,\n"); + fprintf (init_file, "\t\t\t\tovldrecord *overload_info,\n"); + fprintf (init_file, "\t\t\t\ttree *builtin_decls)\n"); fprintf (init_file, "{\n"); fprintf (init_file, " tree t;\n"); rbt_inorder_callback (&fntype_rbt, fntype_rbt.rbt_root, write_fntype_init); fprintf (init_file, "\n"); fprintf (init_file, - " rs6000_builtin_decls[RS6000_BIF_NONE] = NULL_TREE;\n"); + " builtin_decls[RS6000_BIF_NONE] = NULL_TREE;\n"); fprintf (init_file, - " rs6000_builtin_decls[RS6000_BIF_MAX] = NULL_TREE;\n"); + " builtin_decls[RS6000_BIF_MAX] = NULL_TREE;\n"); fprintf (init_file, - " rs6000_builtin_decls[RS6000_OVLD_NONE] = NULL_TREE;\n\n"); + " builtin_decls[RS6000_OVLD_NONE] = NULL_TREE;\n\n"); write_init_bif_table (); write_init_ovld_table (); diff --git a/gcc/config/rs6000/rs6000-logue.cc b/gcc/config/rs6000/rs6000-logue.cc index bd5d56ba002c8..193e2122c0f9b 100644 --- a/gcc/config/rs6000/rs6000-logue.cc +++ b/gcc/config/rs6000/rs6000-logue.cc @@ -591,21 +591,21 @@ rs6000_savres_strategy (rs6000_stack_t *info, +---------------------------------------+ | Parameter save area (+padding*) (P) | 32 +---------------------------------------+ - | Optional ROP hash slot (R) | 32+P + | Alloca space (A) | 32+P +---------------------------------------+ - | Alloca space (A) | 32+P+R + | Local variable space (L) | 32+P+A +---------------------------------------+ - | Local variable space (L) | 32+P+R+A + | Optional ROP hash slot (R) | 32+P+A+L +---------------------------------------+ - | Save area for AltiVec registers (W) | 32+P+R+A+L + | Save area for AltiVec registers (W) | 32+P+A+L+R +---------------------------------------+ - | AltiVec alignment padding (Y) | 32+P+R+A+L+W + | AltiVec alignment padding (Y) | 32+P+A+L+R+W +---------------------------------------+ - | Save area for GP registers (G) | 32+P+R+A+L+W+Y + | Save area for GP registers (G) | 32+P+A+L+R+W+Y +---------------------------------------+ - | Save area for FP registers (F) | 32+P+R+A+L+W+Y+G + | Save area for FP registers (F) | 32+P+A+L+R+W+Y+G +---------------------------------------+ - old SP->| back chain to caller's caller | 32+P+R+A+L+W+Y+G+F + old SP->| back chain to caller's caller | 32+P+A+L+R+W+Y+G+F +---------------------------------------+ * If the alloca area is present, the parameter save area is @@ -817,17 +817,16 @@ rs6000_stack_info (void) gcc_assert (info->altivec_size == 0 || info->altivec_save_offset % 16 == 0); - /* Adjust for AltiVec case. */ - info->ehrd_offset = info->altivec_save_offset - ehrd_size; - /* Adjust for ROP protection. */ info->rop_hash_save_offset = info->altivec_save_offset - info->rop_hash_size; - info->ehrd_offset -= info->rop_hash_size; } else - info->ehrd_offset = info->gp_save_offset - ehrd_size; + /* Adjust for ROP protection. */ + info->rop_hash_save_offset + = info->gp_save_offset - info->rop_hash_size; + info->ehrd_offset = info->rop_hash_save_offset - ehrd_size; info->ehcr_offset = info->ehrd_offset - ehcr_size; info->cr_save_offset = reg_size; /* first word when 64-bit. */ info->lr_save_offset = 2*reg_size; diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h index bcafa9d0cf432..e997dd77e5eb6 100644 --- a/gcc/config/rs6000/sysv4.h +++ b/gcc/config/rs6000/sysv4.h @@ -748,6 +748,7 @@ GNU_USER_TARGET_CC1_SPEC #define LINK_OS_FREEBSD_SPEC "\ %{p:%nconsider using '-pg' instead of '-p' with gprof(1)} \ + " FBSD_LINK_PG_NOTE " \ %{v:-V} \ %{assert*} %{R*} %{rpath*} %{defsym*} \ %{shared:-Bshareable %{h*} %{soname*}} \ diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index fa517bd3e77a7..ec836ec3cd4af 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -17940,7 +17940,8 @@ expand_perm_as_replicate (const struct expand_vec_perm_d &d) unsigned char i; unsigned char elem; rtx base = d.op0; - rtx insn; + rtx insn = NULL_RTX; + /* Needed to silence maybe-uninitialized warning. */ gcc_assert (d.nelt > 0); elem = d.perm[0]; @@ -17954,7 +17955,19 @@ expand_perm_as_replicate (const struct expand_vec_perm_d &d) base = d.op1; elem -= d.nelt; } - insn = maybe_gen_vec_splat (d.vmode, d.target, base, GEN_INT (elem)); + if (memory_operand (base, d.vmode)) + { + /* Try to use vector load and replicate. */ + rtx new_base = adjust_address (base, GET_MODE_INNER (d.vmode), + elem * GET_MODE_UNIT_SIZE (d.vmode)); + insn = maybe_gen_vec_splats (d.vmode, d.target, new_base); + } + if (insn == NULL_RTX) + { + base = force_reg (d.vmode, base); + insn = maybe_gen_vec_splat (d.vmode, d.target, base, GEN_INT (elem)); + } + if (insn == NULL_RTX) return false; emit_insn (insn); diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md index c607dce3cf0fd..1311a5f01cf37 100644 --- a/gcc/config/s390/s390.md +++ b/gcc/config/s390/s390.md @@ -602,6 +602,10 @@ (define_attr "relative_long" "no,yes" (const_string "no")) +(define_code_attr extend_insn [(sign_extend "extend") (zero_extend "zero_extend")]) +(define_code_attr zero_extend [(sign_extend "") (zero_extend "l")]) +(define_code_iterator any_extend [sign_extend zero_extend]) + ;; Pipeline description for z900. (include "2064.md") diff --git a/gcc/config/s390/vector.md b/gcc/config/s390/vector.md index ed4742d93c91f..40de0c75a7cf3 100644 --- a/gcc/config/s390/vector.md +++ b/gcc/config/s390/vector.md @@ -87,6 +87,8 @@ ; 32 bit int<->fp vector conversion instructions are available since VXE2 (z15). (define_mode_iterator VX_VEC_CONV_BFP [V2DF (V4SF "TARGET_VXE2")]) +(define_mode_iterator VI_EXTEND [V2QI V2HI V2SI V4QI V4HI]) + ; Empty string for all but TImode. This is used to hide the TImode ; expander name in case it is defined already. See addti3 for an ; example. @@ -195,13 +197,20 @@ (V1DF "V2DF") (V2DF "V4DF")]) ; Vector with widened element size and the same number of elements. -(define_mode_attr vec_2x_wide [(V1QI "V1HI") (V2QI "V2HI") (V4QI "V4HI") (V8QI "V8HI") (V16QI "V16HI") +(define_mode_attr VEC_2X_WIDE [(V1QI "V1HI") (V2QI "V2HI") (V4QI "V4HI") (V8QI "V8HI") (V16QI "V16HI") (V1HI "V1SI") (V2HI "V2SI") (V4HI "V4SI") (V8HI "V8SI") (V1SI "V1DI") (V2SI "V2DI") (V4SI "V4DI") (V1DI "V1TI") (V2DI "V2TI") (V1SF "V1DF") (V2SF "V2DF") (V4SF "V4DF") (V1DF "V1TF") (V2DF "V2TF")]) +(define_mode_attr vec_2x_wide [(V1QI "v1hi") (V2QI "v2hi") (V4QI "v4hi") (V8QI "v8hi") (V16QI "v16hi") + (V1HI "v1si") (V2HI "v2si") (V4HI "v4si") (V8HI "v8si") + (V1SI "v1di") (V2SI "v2di") (V4SI "v4di") + (V1DI "v1ti") (V2DI "v2ti") + (V1SF "v1df") (V2SF "v2df") (V4SF "v4df") + (V1DF "v1tf") (V2DF "v2tf")]) + ; Vector with half the element size AND half the number of elements. (define_mode_attr vec_halfhalf [(V2HI "V2QI") (V4HI "V4QI") (V8HI "V8QI") @@ -886,6 +895,17 @@ "vmrhf\t%0,%1,%2"; [(set_attr "op_type" "VRR")]) +(define_insn "*vmrhf_half" + [(set (match_operand:V_HW_4 0 "register_operand" "=v") + (vec_select:V_HW_4 + (vec_concat:V_HW_4 (match_operand: 1 "register_operand" "v") + (match_operand: 2 "register_operand" "v")) + (parallel [(const_int 0) (const_int 2) + (const_int 1) (const_int 3)])))] + "TARGET_VX" + "vmrhf\t%0,%1,%2"; + [(set_attr "op_type" "VRR")]) + (define_insn "*vmrlf" [(set (match_operand:V_HW_4 0 "register_operand" "=v") (vec_select:V_HW_4 @@ -1604,7 +1624,7 @@ UNSPEC_VEC_UMULT_ODD)) (set (match_operand: 0 "register_operand" "") (vec_select: - (vec_concat: (match_dup 3) (match_dup 4)) + (vec_concat: (match_dup 3) (match_dup 4)) (match_dup 5)))] "TARGET_VX" { @@ -1623,7 +1643,7 @@ UNSPEC_VEC_UMULT_ODD)) (set (match_operand: 0 "register_operand" "") (vec_select: - (vec_concat: (match_dup 3) (match_dup 4)) + (vec_concat: (match_dup 3) (match_dup 4)) (match_dup 5)))] "TARGET_VX" { @@ -1642,7 +1662,7 @@ UNSPEC_VEC_SMULT_ODD)) (set (match_operand: 0 "register_operand" "") (vec_select: - (vec_concat: (match_dup 3) (match_dup 4)) + (vec_concat: (match_dup 3) (match_dup 4)) (match_dup 5)))] "TARGET_VX" { @@ -1661,7 +1681,7 @@ UNSPEC_VEC_SMULT_ODD)) (set (match_operand: 0 "register_operand" "") (vec_select: - (vec_concat: (match_dup 3) (match_dup 4)) + (vec_concat: (match_dup 3) (match_dup 4)) (match_dup 5)))] "TARGET_VX" { @@ -2375,6 +2395,33 @@ "vpkls\t%0,%1,%2" [(set_attr "op_type" "VRR")]) +;; vector unpack / extend + +(define_insn "2" + [(set (match_operand: 0 "register_operand" "=v") + (any_extend: + (match_operand:VI_EXTEND 1 "register_operand" "v")))] + "TARGET_VX" + "vuph\t%0,%1" + [(set_attr "op_type" "VRR")]) + +(define_expand "extendv2sfv2df2" + [(set (match_dup 2) + (vec_select:V4SF + (vec_concat:V4SF (match_operand:V2SF 1 "register_operand") + (match_dup 1)) + (parallel [(const_int 0) (const_int 2) + (const_int 1) (const_int 3)]))) + (set (match_operand:V2DF 0 "register_operand") + (float_extend:V2DF + (vec_select:V2SF + (match_dup 2) + (parallel [(const_int 0) (const_int 2)]))))] + "TARGET_VX" +{ + operands[2] = gen_reg_rtx (V4SFmode); +}) + ;; vector unpack v16qi ; signed diff --git a/gcc/config/s390/vx-builtins.md b/gcc/config/s390/vx-builtins.md index 93c0d408a43ee..bb271c09a7d77 100644 --- a/gcc/config/s390/vx-builtins.md +++ b/gcc/config/s390/vx-builtins.md @@ -145,7 +145,7 @@ DONE; }) -(define_expand "vec_splats" +(define_expand "@vec_splats" [(set (match_operand:VEC_HW 0 "register_operand" "") (vec_duplicate:VEC_HW (match_operand: 1 "general_operand" "")))] "TARGET_VX") diff --git a/gcc/config/sh/sh.md b/gcc/config/sh/sh.md index 19481c07db6a4..92a1efeb811f8 100644 --- a/gcc/config/sh/sh.md +++ b/gcc/config/sh/sh.md @@ -10093,6 +10093,25 @@ [(set (reg:SI T_REG) (zero_extract:SI (xor:SI (match_dup 0) (match_dup 1)) (const_int 1) (match_dup 2)))]) +;; Same thing, but when we use a PLUS rather than IOR/XOR for the rotation +;; which causes things to simplify somewhat differently. +(define_insn_and_split "*neg_zero_extract_4b" + [(set (reg:SI T_REG) + (and:SI (not:SI (plus:SI + (lshiftrt:SI (match_operand:SI 0 "arith_reg_operand") + (match_operand 1 "const_int_operand")) + (ashift:SI (match_operand:SI 2 "arith_reg_operand") + (match_operand 3 "const_int_operand")))) + (const_int 1)))] + "TARGET_SH1 && can_create_pseudo_p () + && INTVAL (operands[3]) > 0 + && INTVAL (operands[1]) + INTVAL (operands[3]) == 32" + "#" + "&& 1" + [(set (reg:SI T_REG) (zero_extract:SI (xor:SI (match_dup 0) (match_dup 4)) + (const_int 1) (match_dup 1)))] + { operands[4] = GEN_INT (1 << INTVAL (operands[1])); }) + (define_insn_and_split "*neg_zero_extract_5" [(set (reg:SI T_REG) (and:SI (not:SI (subreg:SI diff --git a/gcc/config/xtensa/xtensa-protos.h b/gcc/config/xtensa/xtensa-protos.h index 77553b0453f14..8f645e87de968 100644 --- a/gcc/config/xtensa/xtensa-protos.h +++ b/gcc/config/xtensa/xtensa-protos.h @@ -44,7 +44,7 @@ extern int xtensa_expand_scc (rtx *, machine_mode); extern int xtensa_expand_block_move (rtx *); extern int xtensa_expand_block_set (rtx *); extern void xtensa_split_operand_pair (rtx *, machine_mode); -extern int xtensa_constantsynth (rtx, HOST_WIDE_INT); +extern int xtensa_constantsynth (rtx, rtx); extern int xtensa_emit_move_sequence (rtx *, machine_mode); extern rtx xtensa_copy_incoming_a7 (rtx); extern void xtensa_expand_nonlocal_goto (rtx *); diff --git a/gcc/config/xtensa/xtensa.cc b/gcc/config/xtensa/xtensa.cc index 45dc1be3ff52f..bc127997ac6cb 100644 --- a/gcc/config/xtensa/xtensa.cc +++ b/gcc/config/xtensa/xtensa.cc @@ -58,6 +58,8 @@ along with GCC; see the file COPYING3. If not see #include "insn-attr.h" #include "tree-pass.h" #include "print-rtl.h" +#include "context.h" +#include "pass_manager.h" #include /* This file should be included last. */ @@ -107,6 +109,7 @@ struct GTY(()) machine_function bool inhibit_logues_a1_adjusts; rtx last_logues_a9_content; HARD_REG_SET eliminated_callee_saved; + hash_map *litpool_usage; }; static void xtensa_option_override (void); @@ -1104,7 +1107,7 @@ xtensa_split_operand_pair (rtx operands[4], machine_mode mode) } -/* Try to emit insns to load srcval (that cannot fit into signed 12-bit) +/* Try to emit insns to load src (either naked or pooled SI/SF constant) into dst with synthesizing a such constant value from a sequence of load-immediate / arithmetic ones, instead of a L32R instruction (plus a constant in litpool). */ @@ -1190,11 +1193,67 @@ xtensa_constantsynth_rtx_ADDSUBX (rtx reg, HOST_WIDE_INT imm) } int -xtensa_constantsynth (rtx dst, HOST_WIDE_INT srcval) +xtensa_constantsynth (rtx dst, rtx src) { + HOST_WIDE_INT srcval; + static opt_pass *pass_rtl_split2; + int *pv; + + /* Derefer if src is litpool entry, and get integer constant value. */ + src = avoid_constant_pool_reference (src); + if (CONST_INT_P (src)) + srcval = INTVAL (src); + else if (CONST_DOUBLE_P (src) && GET_MODE (src) == SFmode) + { + long l; + + REAL_VALUE_TO_TARGET_SINGLE (*CONST_DOUBLE_REAL_VALUE (src), l); + srcval = (int32_t)l, src = GEN_INT (srcval); + } + else + return 0; + + /* Force dst as SImode. */ + gcc_assert (REG_P (dst)); + if (GET_MODE (dst) != SImode) + dst = gen_rtx_REG (SImode, REGNO (dst)); + + if (optimize_size) + { + /* During the first split pass after register allocation (rtl-split2), + record the occurrence of integer src value and do nothing. */ + if (!pass_rtl_split2) + pass_rtl_split2 = g->get_passes ()->get_pass_by_name ("rtl-split2"); + if (current_pass == pass_rtl_split2) + { + if (!cfun->machine->litpool_usage) + cfun->machine->litpool_usage = hash_map::create_ggc (); + if ((pv = cfun->machine->litpool_usage->get (src))) + ++*pv; + else + cfun->machine->litpool_usage->put (src, 1); + return 0; + } + + /* If two or more identical integer constants appear in the function, + the code size can be reduced by re-emitting a "move" (load from an + either litpool entry or relaxed immediate) instruction in SImode + to increase the chances that the litpool entry will be shared. */ + if (cfun->machine->litpool_usage + && (pv = cfun->machine->litpool_usage->get (src)) + && *pv > 1) + { + emit_move_insn (dst, src); + return 1; + } + } + /* No need for synthesizing for what fits into MOVI instruction. */ if (xtensa_simm12b (srcval)) - return 0; + { + emit_move_insn (dst, src); + return 1; + } /* 2-insns substitution. */ if ((optimize_size || (optimize && xtensa_extra_l32r_costs >= 1)) @@ -1240,9 +1299,6 @@ xtensa_constantsynth (rtx dst, HOST_WIDE_INT srcval) emit_insn (gen_rotlsi3 (dst, dst, GEN_INT (shift))); return 1; } - } - for (shift = 1; shift < 12; ++shift) - { v = (int32_t)(((uint32_t)srcval << shift) | ((uint32_t)srcval >> (32 - shift))); if (xtensa_simm12b(v)) @@ -1255,7 +1311,12 @@ xtensa_constantsynth (rtx dst, HOST_WIDE_INT srcval) } } - return 0; + /* If cannot synthesize the value and also cannot fit into MOVI instruc- + tion, re-emit a "move" (load from an either litpool entry or relaxed + immediate) instruction in SImode in order to increase the chances that + the litpool entry will be shared. */ + emit_move_insn (dst, src); + return 1; } diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md index ef826b63e441f..8709ef6d7a7dc 100644 --- a/gcc/config/xtensa/xtensa.md +++ b/gcc/config/xtensa/xtensa.md @@ -1285,17 +1285,25 @@ (define_split [(set (match_operand:SHI 0 "register_operand") (match_operand:SHI 1 "constantpool_operand"))] - "! optimize_debug && reload_completed" + "!optimize_debug && reload_completed" [(const_int 0)] { - rtx x = avoid_constant_pool_reference (operands[1]), dst = operands[0]; - if (! CONST_INT_P (x)) - FAIL; - if (mode == HImode) - dst = gen_rtx_REG (SImode, REGNO (dst)); - if (! xtensa_constantsynth (dst, INTVAL (x))) - emit_move_insn (dst, x); - DONE; + if (xtensa_constantsynth (operands[0], operands[1])) + DONE; + FAIL; +}) + +(define_split + [(set (match_operand:SHI 0 "register_operand") + (match_operand:SHI 1 "const_int_operand"))] + "!optimize_debug && reload_completed + && !TARGET_CONST16 && TARGET_AUTO_LITPOOLS + && ! xtensa_simm12b (INTVAL (operands[1]))" + [(const_int 0)] +{ + if (xtensa_constantsynth (operands[0], operands[1])) + DONE; + FAIL; }) ;; 16-bit Integer moves @@ -1503,21 +1511,25 @@ (define_split [(set (match_operand:SF 0 "register_operand") - (match_operand:SF 1 "constantpool_operand"))] - "! optimize_debug && reload_completed" + (match_operand 1 "constantpool_operand"))] + "!optimize_debug && reload_completed" [(const_int 0)] { - rtx x = avoid_constant_pool_reference (operands[1]); - long l; - HOST_WIDE_INT value; - if (! CONST_DOUBLE_P (x) || GET_MODE (x) != SFmode) - FAIL; - REAL_VALUE_TO_TARGET_SINGLE (*CONST_DOUBLE_REAL_VALUE (x), l); - x = gen_rtx_REG (SImode, REGNO (operands[0])); - value = (int32_t)l; - if (! xtensa_constantsynth (x, value)) - emit_move_insn (x, GEN_INT (value)); - DONE; + if (xtensa_constantsynth (operands[0], operands[1])) + DONE; + FAIL; +}) + +(define_split + [(set (match_operand:SF 0 "register_operand") + (match_operand 1 "const_double_operand"))] + "!optimize_debug && reload_completed + && !TARGET_CONST16 && TARGET_AUTO_LITPOOLS" + [(const_int 0)] +{ + if (xtensa_constantsynth (operands[0], operands[1])) + DONE; + FAIL; }) ;; 64-bit floating point moves diff --git a/gcc/configure b/gcc/configure index aaf5899cc039f..b536af664d3de 100755 --- a/gcc/configure +++ b/gcc/configure @@ -9066,7 +9066,7 @@ fi # NM if test x${build} = x${host} && test -f $srcdir/../binutils/nm.c \ && test -d ../binutils ; then - NM='${objdir}/../binutils/nm-new' + NM='../binutils/nm-new' else # Extract the first word of "nm", so it can be a program name with args. set dummy nm; ac_word=$2 @@ -9111,7 +9111,7 @@ fi # AR if test x${build} = x${host} && test -f $srcdir/../binutils/ar.c \ && test -d ../binutils ; then - AR='${objdir}/../binutils/ar' + AR='../binutils/ar' else # Extract the first word of "ar", so it can be a program name with args. set dummy ar; ac_word=$2 @@ -25919,8 +25919,8 @@ _ACEOF +ld_ver=`$gcc_cv_ld --version 2>/dev/null | sed 1q` if test $in_tree_ld != yes ; then - ld_ver=`$gcc_cv_ld --version 2>/dev/null | sed 1q` if echo "$ld_ver" | grep GNU > /dev/null; then if test x"$ld_is_gold" = xyes; then # GNU gold --version looks like this: @@ -30239,7 +30239,7 @@ else fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_mips_explicit_relocs_pcrel" >&5 $as_echo "$gcc_cv_as_mips_explicit_relocs_pcrel" >&6; } -if test $gcc_cv_as_mips_explicit_relocs_pcrel = yes; then +if test "x$gcc_cv_as_mips_explicit_relocs_pcrel" = "xyes"; then $as_echo "#define MIPS_EXPLICIT_RELOCS MIPS_EXPLICIT_RELOCS_PCREL" >>confdefs.h @@ -30820,6 +30820,37 @@ if test $gcc_cv_as_riscv_march_zifencei = yes; then $as_echo "#define HAVE_AS_MARCH_ZIFENCEI 1" >>confdefs.h +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for -march=rv32i_zaamo_zalrsc support" >&5 +$as_echo_n "checking assembler for -march=rv32i_zaamo_zalrsc support... " >&6; } +if ${gcc_cv_as_riscv_march_zaamo_zalrsc+:} false; then : + $as_echo_n "(cached) " >&6 +else + gcc_cv_as_riscv_march_zaamo_zalrsc=no + if test x$gcc_cv_as != x; then + $as_echo '' > conftest.s + if { ac_try='$gcc_cv_as $gcc_cv_as_flags -march=rv32i_zaamo_zalrsc -o conftest.o conftest.s >&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } + then + gcc_cv_as_riscv_march_zaamo_zalrsc=yes + else + echo "configure: failed program was" >&5 + cat conftest.s >&5 + fi + rm -f conftest.o conftest.s + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_riscv_march_zaamo_zalrsc" >&5 +$as_echo "$gcc_cv_as_riscv_march_zaamo_zalrsc" >&6; } +if test $gcc_cv_as_riscv_march_zaamo_zalrsc = yes; then + +$as_echo "#define HAVE_AS_MARCH_ZAAMO_ZALRSC 1" >>confdefs.h + fi ;; diff --git a/gcc/configure.ac b/gcc/configure.ac index f8d67efeb9886..1501bf89c89da 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -1320,7 +1320,7 @@ AC_SUBST(HAVE_PYTHON) # NM if test x${build} = x${host} && test -f $srcdir/../binutils/nm.c \ && test -d ../binutils ; then - NM='${objdir}/../binutils/nm-new' + NM='../binutils/nm-new' else AC_CHECK_PROG(NM, nm, nm, ${CONFIG_SHELL-/bin/sh} ${srcdir}/../missing nm) fi @@ -1328,7 +1328,7 @@ fi # AR if test x${build} = x${host} && test -f $srcdir/../binutils/ar.c \ && test -d ../binutils ; then - AR='${objdir}/../binutils/ar' + AR='../binutils/ar' else AC_CHECK_PROG(AR, ar, ar, ${CONFIG_SHELL-/bin/sh} ${srcdir}/../missing ar) fi @@ -3108,8 +3108,8 @@ AC_DEFINE_UNQUOTED(HAVE_GNU_INDIRECT_FUNCTION, $gif, changequote(,)dnl +ld_ver=`$gcc_cv_ld --version 2>/dev/null | sed 1q` if test $in_tree_ld != yes ; then - ld_ver=`$gcc_cv_ld --version 2>/dev/null | sed 1q` if echo "$ld_ver" | grep GNU > /dev/null; then if test x"$ld_is_gold" = xyes; then # GNU gold --version looks like this: @@ -5317,7 +5317,7 @@ x: AC_MSG_CHECKING(assembler and linker for explicit JALR relocation) gcc_cv_as_ld_jalr_reloc=no - if test $gcc_cv_as_mips_explicit_relocs = yes; then + if test "x$gcc_cv_as_mips_explicit_relocs" = "xyes"; then if test $in_tree_ld = yes ; then if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 20 -o "$gcc_cv_gld_major_version" -gt 2 \ && test $in_tree_ld_is_elf = yes; then @@ -5452,6 +5452,11 @@ configured with --enable-newlib-nano-formatted-io.]) [-march=rv32i_zifencei2p0],,, [AC_DEFINE(HAVE_AS_MARCH_ZIFENCEI, 1, [Define if the assembler understands -march=rv*_zifencei.])]) + gcc_GAS_CHECK_FEATURE([-march=rv32i_zaamo_zalrsc support], + gcc_cv_as_riscv_march_zaamo_zalrsc, + [-march=rv32i_zaamo_zalrsc],,, + [AC_DEFINE(HAVE_AS_MARCH_ZAAMO_ZALRSC, 1, + [Define if the assembler understands -march=rv*_zaamo_zalrsc.])]) ;; loongarch*-*-*) gcc_GAS_CHECK_FEATURE([.dtprelword support], diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4a389e22881ac..006a0ed32ca0d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,132 @@ +2024-06-17 Jakub Jelinek + + PR target/111343 + PR c++/115511 + * typeck.cc (cp_compare_floating_point_conversion_ranks): If an + extended floating point type mv1 has same set of values as more + than one standard floating point type and mv2 is float, return 2. + +2024-06-13 Jason Merrill + + PR c++/114683 + * name-lookup.cc (do_nonmember_using_decl): Allow exporting + a newly inserted decl. + +2024-06-13 Jason Merrill + + PR c++/115194 + * name-lookup.cc (name_lookup::process_module_binding): Strip an + OVERLOAD from a non-function. + +2024-06-13 Jason Merrill + + * module.cc (depset::hash::add_binding_entity): Adjust comment. + +2024-06-13 Patrick Palka + + PR c++/99678 + * parser.cc (cp_parser_constraint_primary_expression): Diagnose + a bare unresolved unqualified-id. + +2024-06-13 Patrick Palka + + PR c++/115239 + * call.cc (tourney): Don't consider a non-strictly viable + candidate as the champ if there was ambiguity between two + strictly viable candidates. + +2024-06-13 Andi Kleen + + * parser.cc (cp_parser_asm_string_expression): Use correct error + message. + +2024-06-13 Andi Kleen + + * parser.cc (cp_parser_asm_string_expression): Parse close + parent when constexpr extraction fails. + +2024-06-13 Andi Kleen + + * parser.cc (cp_parser_asm_string_expression): Remove support + for const char * for asm constexpr. + +2024-06-13 Patrick Palka + + PR c++/115283 + * decl2.cc (min_vis_expr_r) : Ignore + concepts. + +2024-06-12 Jason Merrill + + * tree.cc (lookup_maybe_add): Use ovl_make when setting OVL_USING_P. + +2024-06-12 Jason Merrill + + * module.cc (depset::hash::add_binding_entity): Set + DECL_MODULE_PURVIEW_P instead of asserting. + +2024-06-12 Andi Kleen + + * cp-tree.h (extract): Add new overload to return tree. + * parser.cc (cp_parser_asm_string_expression): Use tree extract. + * semantics.cc (cexpr_str::extract): Add new overload to return + tree. + +2024-06-12 David Malcolm + + * error.cc (append_formatted_chunk): Move part of body into + chunk_info::append_formatted_chunk. + +2024-06-12 David Malcolm + + * cxx-pretty-print.cc: Update throughout for fields of + pretty_printer becoming private. + * error.cc: Likewise. + +2024-06-11 Andi Kleen + + * parser.cc (cp_parser_asm_string_expression): New function + to handle constexpr strings for asm. + (cp_parser_asm_definition): Use cp_parser_asm_string_expression. + (cp_parser_yield_expression): Dito. + (cp_parser_asm_specification_opt): Dito. + (cp_parser_asm_operand_list): Dito. + (cp_parser_asm_clobber_list): Dito. + +2024-06-11 Andi Kleen + + * cp-tree.h (class cexpr_str): Add. + * semantics.cc (finish_static_assert): Convert to use cexpr_str. + (cexpr_str::type_check): Extract constexpr string code to here. + (cexpr_str::extract): ... and here. + +2024-06-08 Simon Martin + + PR c++/108438 + * parser.cc (cp_parser_postfix_expression): Use + cp_parser_require_end_of_template_parameter_list to skip to the closing + '>' upon error parsing the target type of *_cast<*> expressions. + +2024-06-07 Simon Martin + + PR c++/107575 + * decl.cc (duplicate_decls): Check for error_mark_node + DECL_LOCAL_DECL_ALIAS. + +2024-06-07 Jason Merrill + + * module.cc (maybe_translate_include): Allow before the main file. + +2024-06-07 Patrick Palka + + PR c++/115378 + * lambda.cc (lambda_capture_field_type): Set + TEMPLATE_TYPE_PARAMETER_PACK on the auto type of an init-capture + pack expansion. + * pt.cc (find_parameter_packs_r) : + Restrict TEMPLATE_TYPE_PARAMETER_PACK promotion with + flag_concepts_ts. + 2024-06-05 Jakub Jelinek Frederik Harwath Sandra Loosemore diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc index 85536fc25ff29..7bbc1fb0c7898 100644 --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -13490,7 +13490,8 @@ tourney (struct z_candidate *candidates, tsubst_flags_t complain) { previous_worse_champ = nullptr; champ = &(*challenger)->next; - if (!*champ || !(*champ)->viable) + if (!*champ || !(*champ)->viable + || (*champ)->viable < (*challenger)->viable) { champ = nullptr; break; diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 1ac31d073d184..416c60b7311e0 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -9015,6 +9015,25 @@ struct push_access_scope_guard } }; +/* Extracting strings from constexpr. */ + +class cexpr_str +{ +public: + cexpr_str (tree message) : message (message) {} + cexpr_str (const cexpr_str &) = delete; + ~cexpr_str () { XDELETEVEC (buf); } + + bool type_check (location_t location); + bool extract (location_t location, const char * & msg, int &len); + bool extract (location_t location, tree &str); + tree message; +private: + tree message_data = NULL_TREE; + tree message_sz = NULL_TREE; + char *buf = nullptr; +}; + /* True if TYPE is an extended floating-point type. */ inline bool diff --git a/gcc/cp/cxx-pretty-print.cc b/gcc/cp/cxx-pretty-print.cc index c6d8cc84132b8..806aebff174b6 100644 --- a/gcc/cp/cxx-pretty-print.cc +++ b/gcc/cp/cxx-pretty-print.cc @@ -49,7 +49,7 @@ pp_cxx_nonconsecutive_character (cxx_pretty_printer *pp, int c) if (p != NULL && *p == c) pp_cxx_whitespace (pp); pp_character (pp, c); - pp->padding = pp_none; + pp->set_padding (pp_none); } #define pp_cxx_expression_list(PP, T) \ @@ -65,7 +65,7 @@ void pp_cxx_colon_colon (cxx_pretty_printer *pp) { pp_colon_colon (pp); - pp->padding = pp_none; + pp->set_padding (pp_none); } void @@ -84,7 +84,7 @@ void pp_cxx_separate_with (cxx_pretty_printer *pp, int c) { pp_separate_with (pp, c); - pp->padding = pp_none; + pp->set_padding (pp_none); } /* Expressions. */ @@ -1702,7 +1702,7 @@ cxx_pretty_printer::direct_declarator (tree t) if (DECL_IOBJ_MEMBER_FUNCTION_P (t)) { - padding = pp_before; + set_padding (pp_before); pp_cxx_cv_qualifier_seq (this, pp_cxx_implicit_parameter_type (t)); } @@ -1859,7 +1859,7 @@ cxx_pretty_printer::direct_abstract_declarator (tree t) direct_abstract_declarator (TREE_TYPE (t)); if (TREE_CODE (t) == METHOD_TYPE) { - padding = pp_before; + set_padding (pp_before); pp_cxx_cv_qualifier_seq (this, class_of_this_parm (t)); } pp_cxx_exception_specification (this, t); @@ -2685,7 +2685,7 @@ pp_cxx_requires_clause (cxx_pretty_printer *pp, tree t) { if (!t) return; - pp->padding = pp_before; + pp->set_padding (pp_before); pp_cxx_ws_string (pp, "requires"); pp_space (pp); pp->expression (t); diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index d481e1ec074bc..03deb1493a43b 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -2792,10 +2792,13 @@ duplicate_decls (tree newdecl, tree olddecl, bool hiding, bool was_hidden) retrofit_lang_decl (newdecl); tree alias = DECL_LOCAL_DECL_ALIAS (newdecl) = DECL_LOCAL_DECL_ALIAS (olddecl); - DECL_ATTRIBUTES (alias) - = (*targetm.merge_decl_attributes) (alias, newdecl); - if (TREE_CODE (newdecl) == FUNCTION_DECL) - merge_attribute_bits (newdecl, alias); + if (alias != error_mark_node) + { + DECL_ATTRIBUTES (alias) + = (*targetm.merge_decl_attributes) (alias, newdecl); + if (TREE_CODE (newdecl) == FUNCTION_DECL) + merge_attribute_bits (newdecl, alias); + } } } diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc index 7baff46a1921f..6c3ef60d51f8c 100644 --- a/gcc/cp/decl2.cc +++ b/gcc/cp/decl2.cc @@ -2723,9 +2723,10 @@ min_vis_expr_r (tree *tp, int */*walk_subtrees*/, void *data) break; case TEMPLATE_DECL: - if (DECL_ALIAS_TEMPLATE_P (t)) + if (DECL_ALIAS_TEMPLATE_P (t) || standard_concept_p (t)) /* FIXME: We don't maintain TREE_PUBLIC / DECL_VISIBILITY for - alias templates so we can't trust it here (PR107906). */ + alias templates so we can't trust it here (PR107906). Ditto + for concepts. */ break; t = DECL_TEMPLATE_RESULT (t); /* Fall through. */ diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc index 0ff7f9d4c468e..171a352c85fd6 100644 --- a/gcc/cp/error.cc +++ b/gcc/cp/error.cc @@ -180,7 +180,7 @@ cxx_initialize_diagnostics (diagnostic_context *context) diagnostic_starter (context) = cp_diagnostic_starter; /* diagnostic_finalizer is already c_diagnostic_finalizer. */ diagnostic_format_decoder (context) = cp_printer; - pp->m_format_postprocessor = new cxx_format_postprocessor (); + pp_format_postprocessor (pp) = new cxx_format_postprocessor (); } /* Dump an '@module' name suffix for DECL, if any. */ @@ -210,7 +210,7 @@ dump_module_suffix (cxx_pretty_printer *pp, tree decl) if (const char *n = module_name (m, false)) { pp_character (pp, '@'); - pp->padding = pp_none; + pp->set_padding (pp_none); pp_string (pp, n); } } @@ -921,7 +921,7 @@ dump_type_prefix (cxx_pretty_printer *pp, tree t, int flags) else pp_ampersand (pp); } - pp->padding = pp_before; + pp->set_padding (pp_before); pp_cxx_cv_qualifier_seq (pp, t); } break; @@ -939,7 +939,7 @@ dump_type_prefix (cxx_pretty_printer *pp, tree t, int flags) } pp_cxx_star (pp); pp_cxx_cv_qualifier_seq (pp, t); - pp->padding = pp_before; + pp->set_padding (pp_before); break; /* This can be reached without a pointer when dealing with @@ -986,7 +986,7 @@ dump_type_prefix (cxx_pretty_printer *pp, tree t, int flags) case FIXED_POINT_TYPE: case NULLPTR_TYPE: dump_type (pp, t, flags); - pp->padding = pp_before; + pp->set_padding (pp_before); break; default: @@ -1035,7 +1035,7 @@ dump_type_suffix (cxx_pretty_printer *pp, tree t, int flags) anyway; they may in g++, but we'll just pretend otherwise. */ dump_parameters (pp, arg, flags & ~TFF_FUNCTION_DEFAULT_ARGUMENTS); - pp->padding = pp_before; + pp->set_padding (pp_before); pp_cxx_cv_qualifiers (pp, type_memfn_quals (t), TREE_CODE (t) == FUNCTION_TYPE && (flags & TFF_POINTER)); @@ -1049,7 +1049,7 @@ dump_type_suffix (cxx_pretty_printer *pp, tree t, int flags) { pp_space (pp); pp_c_attributes_display (pp, TYPE_ATTRIBUTES (t)); - pp->padding = pp_before; + pp->set_padding (pp_before); } dump_type_suffix (pp, TREE_TYPE (t), flags); break; @@ -1720,13 +1720,13 @@ dump_lambda_function (cxx_pretty_printer *pp, /* Early escape. */; else if (TREE_CODE (TREE_TYPE (fn)) == FUNCTION_TYPE) { - pp->padding = pp_before; + pp->set_padding (pp_before); pp_c_ws_string (pp, "static"); } else if (!(TYPE_QUALS (class_of_this_parm (TREE_TYPE (fn))) & TYPE_QUAL_CONST)) { - pp->padding = pp_before; + pp->set_padding (pp_before); pp_c_ws_string (pp, "mutable"); } dump_substitution (pp, fn, template_parms, template_args, flags); @@ -1845,20 +1845,20 @@ dump_function_decl (cxx_pretty_printer *pp, tree t, int flags) if (TREE_CODE (fntype) == METHOD_TYPE) { - pp->padding = pp_before; + pp->set_padding (pp_before); pp_cxx_cv_qualifier_seq (pp, class_of_this_parm (fntype)); dump_ref_qualifier (pp, fntype, flags); } if (tx_safe_fn_type_p (fntype)) { - pp->padding = pp_before; + pp->set_padding (pp_before); pp_cxx_ws_string (pp, "transaction_safe"); } if (flags & TFF_EXCEPTION_SPECIFICATION) { - pp->padding = pp_before; + pp->set_padding (pp_before); dump_exception_spec (pp, exceptions, flags); } @@ -1952,7 +1952,7 @@ dump_ref_qualifier (cxx_pretty_printer *pp, tree t, int flags ATTRIBUTE_UNUSED) { if (FUNCTION_REF_QUALIFIED (t)) { - pp->padding = pp_before; + pp->set_padding (pp_before); if (FUNCTION_RVALUE_QUALIFIED (t)) pp_cxx_ws_string (pp, "&&"); else @@ -3156,7 +3156,7 @@ static void reinit_cxx_pp (void) { pp_clear_output_area (cxx_pp); - cxx_pp->padding = pp_none; + cxx_pp->set_padding (pp_none); pp_indentation (cxx_pp) = 0; pp_needs_newline (cxx_pp) = false; pp_show_color (cxx_pp) = false; @@ -3537,7 +3537,7 @@ static const char * cv_to_string (tree p, int v) { reinit_cxx_pp (); - cxx_pp->padding = v ? pp_before : pp_none; + cxx_pp->set_padding (v ? pp_before : pp_none); pp_cxx_cv_qualifier_seq (cxx_pp, p); return pp_ggc_formatted_text (cxx_pp); } @@ -3682,8 +3682,7 @@ cp_print_error_function (diagnostic_context *context, pp_newline (context->printer); diagnostic_set_last_function (context, diagnostic); - pp_destroy_prefix (context->printer); - context->printer->prefix = old_prefix; + context->printer->set_prefix (old_prefix); } } @@ -4308,14 +4307,8 @@ static void append_formatted_chunk (pretty_printer *pp, const char *content) { output_buffer *buffer = pp_buffer (pp); - struct chunk_info *chunk_array = buffer->cur_chunk_array; - const char **args = chunk_array->args; - - unsigned int chunk_idx; - for (chunk_idx = 0; args[chunk_idx]; chunk_idx++) - ; - args[chunk_idx++] = content; - args[chunk_idx] = NULL; + chunk_info *chunk_array = buffer->cur_chunk_array; + chunk_array->append_formatted_chunk (content); } /* Create a copy of CONTENT, with quotes added, and, @@ -4470,9 +4463,9 @@ cp_printer (pretty_printer *pp, text_info *text, const char *spec, int precision, bool wide, bool set_locus, bool verbose, bool *quoted, const char **buffer_ptr) { - gcc_assert (pp->m_format_postprocessor); + gcc_assert (pp_format_postprocessor (pp)); cxx_format_postprocessor *postprocessor - = static_cast (pp->m_format_postprocessor); + = static_cast (pp_format_postprocessor (pp)); const char *result; tree t = NULL; diff --git a/gcc/cp/lambda.cc b/gcc/cp/lambda.cc index 630cc4eade144..0770417810e97 100644 --- a/gcc/cp/lambda.cc +++ b/gcc/cp/lambda.cc @@ -223,7 +223,8 @@ lambda_capture_field_type (tree expr, bool explicit_init_p, outermost CV qualifiers of EXPR. */ type = build_reference_type (type); if (uses_parameter_packs (expr)) - /* Stick with 'auto' even if the type could be deduced. */; + /* Stick with 'auto' even if the type could be deduced. */ + TEMPLATE_TYPE_PARAMETER_PACK (auto_node) = true; else type = do_auto_deduction (type, expr, auto_node); } diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index ed24814b601d2..ea7ad0c1f2915 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -13253,8 +13253,12 @@ depset::hash::add_binding_entity (tree decl, WMB_Flags flags, void *data_) data->met_namespace = true; if (data->hash->add_namespace_entities (decl, data->partitions)) { - /* It contains an exported thing, so it is exported. */ - gcc_checking_assert (DECL_MODULE_PURVIEW_P (decl)); + /* It contains an exported thing, so it is exported. + + FIXME we have to set DECL_MODULE_PURVIEW_P instead of asserting + that it is already set because of the c++/114683 issue with + exported using-declarations; see do_nonmember_using_decl. */ + DECL_MODULE_PURVIEW_P (decl) = true; DECL_MODULE_EXPORT_P (decl) = true; } @@ -19976,10 +19980,6 @@ maybe_translate_include (cpp_reader *reader, line_maps *lmaps, location_t loc, return nullptr; } - if (!spans.init_p ()) - /* Before the main file, don't divert. */ - return nullptr; - dump.push (NULL); dump () && dump ("Checking include translation '%s'", path); diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc index 3d3e20f48cbde..b57893116ebc5 100644 --- a/gcc/cp/name-lookup.cc +++ b/gcc/cp/name-lookup.cc @@ -827,6 +827,17 @@ name_lookup::process_module_binding (tree new_val, tree new_type, marker |= 2; } + /* add_binding_entity wraps decls brought in by 'using' in an OVERLOAD even + for non-functions; strip it now. + ??? Why isn't it represented with a USING_DECL? Or do we want to use + OVERLOAD for using more widely to address 114683? */ + if (new_val && TREE_CODE (new_val) == OVERLOAD + && !DECL_DECLARES_FUNCTION_P (OVL_FUNCTION (new_val))) + { + gcc_checking_assert (OVL_USING_P (new_val) && !OVL_CHAIN (new_val)); + new_val = OVL_FUNCTION (new_val); + } + if (new_type || new_val) marker |= process_binding (new_val, new_type); @@ -5305,14 +5316,13 @@ do_nonmember_using_decl (name_lookup &lookup, bool fn_scope_p, /* FIXME: Handle exporting declarations from a different scope without also marking those declarations as exported. This will require not just binding directly to the underlying - value; see c++/114863 and c++/114865. We allow this for purview - declarations for now as this doesn't (currently) cause ICEs + value; see c++/114683 and c++/114685. We allow the extra exports + for now as this doesn't (currently) cause ICEs later down the line, but this should be revisited. */ if (revealing_p) { if (module_exporting_p () && check_can_export_using_decl (lookup.value) - && lookup.value == value && !DECL_MODULE_EXPORT_P (lookup.value)) { /* We're redeclaring the same value, but this time as diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index bc4a23591539f..e7409b856f112 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -7569,7 +7569,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, NULL); parser->in_type_id_in_expr_p = saved_in_type_id_in_expr_p; /* Look for the closing `>'. */ - cp_parser_require (parser, CPP_GREATER, RT_GREATER); + cp_parser_require_end_of_template_parameter_list (parser); /* Restore the old message. */ parser->type_definition_forbidden_message = saved_message; @@ -22833,6 +22833,42 @@ cp_parser_using_directive (cp_parser* parser) cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON); } +/* Parse a string literal or constant expression yielding a string. + The constant expression uses extra parens to avoid ambiguity with "x" (expr). + + asm-string-expr: + string-literal + ( constant-expr ) */ + +static tree +cp_parser_asm_string_expression (cp_parser *parser) +{ + cp_token *tok = cp_lexer_peek_token (parser->lexer); + + if (tok->type == CPP_OPEN_PAREN) + { + matching_parens parens; + parens.consume_open (parser); + tree string = cp_parser_constant_expression (parser); + if (string != error_mark_node) + string = cxx_constant_value (string, tf_error); + cexpr_str cstr (string); + if (!cstr.type_check (tok->location)) + return error_mark_node; + if (!cstr.extract (tok->location, string)) + string = error_mark_node; + parens.require_close (parser); + return string; + } + else if (!cp_parser_is_string_literal (tok)) + { + error_at (tok->location, + "expected string-literal or constexpr in parentheses"); + return error_mark_node; + } + return cp_parser_string_literal (parser, false, false); +} + /* Parse an asm-definition. asm-qualifier: @@ -22845,19 +22881,19 @@ cp_parser_using_directive (cp_parser* parser) asm-qualifier-list asm-qualifier asm-definition: - asm ( string-literal ) ; + asm ( constant-expr ) ; GNU Extension: asm-definition: - asm asm-qualifier-list [opt] ( string-literal ) ; - asm asm-qualifier-list [opt] ( string-literal : asm-operand-list [opt] ) ; - asm asm-qualifier-list [opt] ( string-literal : asm-operand-list [opt] + asm asm-qualifier-list [opt] ( asm-string-expr ) ; + asm asm-qualifier-list [opt] ( asm-string-expr : asm-operand-list [opt] ) ; + asm asm-qualifier-list [opt] ( asm-string-expr : asm-operand-list [opt] : asm-operand-list [opt] ) ; - asm asm-qualifier-list [opt] ( string-literal : asm-operand-list [opt] + asm asm-qualifier-list [opt] ( asm-string-expr : asm-operand-list [opt] : asm-operand-list [opt] : asm-clobber-list [opt] ) ; - asm asm-qualifier-list [opt] ( string-literal : : asm-operand-list [opt] + asm asm-qualifier-list [opt] ( asm-string-expr : : asm-operand-list [opt] : asm-clobber-list [opt] : asm-goto-list ) ; @@ -22976,8 +23012,7 @@ cp_parser_asm_definition (cp_parser* parser) if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN)) return; /* Look for the string. */ - tree string = cp_parser_string_literal (parser, /*translate=*/false, - /*wide_ok=*/false); + tree string = cp_parser_asm_string_expression (parser); if (string == error_mark_node) { cp_parser_skip_to_closing_parenthesis (parser, true, false, @@ -29647,7 +29682,7 @@ cp_parser_yield_expression (cp_parser* parser) /* Parse an (optional) asm-specification. asm-specification: - asm ( string-literal ) + asm ( asm-string-expr ) If the asm-specification is present, returns a STRING_CST corresponding to the string-literal. Otherwise, returns @@ -29670,9 +29705,7 @@ cp_parser_asm_specification_opt (cp_parser* parser) parens.require_open (parser); /* Look for the string-literal. */ - tree asm_specification = cp_parser_string_literal (parser, - /*translate=*/false, - /*wide_ok=*/false); + tree asm_specification = cp_parser_asm_string_expression (parser); /* Look for the `)'. */ parens.require_close (parser); @@ -29687,8 +29720,8 @@ cp_parser_asm_specification_opt (cp_parser* parser) asm-operand-list , asm-operand asm-operand: - string-literal ( expression ) - [ string-literal ] string-literal ( expression ) + asm-string-expr ( expression ) + [ asm-string-expr ] asm-string-expr ( expression ) Returns a TREE_LIST representing the operands. The TREE_VALUE of each node is the expression. The TREE_PURPOSE is itself a @@ -29721,10 +29754,8 @@ cp_parser_asm_operand_list (cp_parser* parser) } else name = NULL_TREE; - /* Look for the string-literal. */ - tree string_literal = cp_parser_string_literal (parser, - /*translate=*/false, - /*wide_ok=*/false); + /* Look for the string. */ + tree string_literal = cp_parser_asm_string_expression (parser); /* Look for the `('. */ matching_parens parens; @@ -29757,8 +29788,8 @@ cp_parser_asm_operand_list (cp_parser* parser) /* Parse an asm-clobber-list. asm-clobber-list: - string-literal - asm-clobber-list , string-literal + const-expression + asm-clobber-list , const-expression Returns a TREE_LIST, indicating the clobbers in the order that they appeared. The TREE_VALUE of each node is a STRING_CST. */ @@ -29771,9 +29802,7 @@ cp_parser_asm_clobber_list (cp_parser* parser) while (true) { /* Look for the string literal. */ - tree string_literal = cp_parser_string_literal (parser, - /*translate=*/false, - /*wide_ok=*/false); + tree string_literal = cp_parser_asm_string_expression (parser); /* Add it to the list. */ clobbers = tree_cons (NULL_TREE, string_literal, clobbers); /* If the next token is not a `,', then the list is @@ -31496,6 +31525,8 @@ cp_parser_constraint_primary_expression (cp_parser *parser, bool lambda_p) } if (pce == pce_ok) { + if (idk == CP_ID_KIND_UNQUALIFIED && identifier_p (expr)) + expr = unqualified_name_lookup_error (expr); cp_lexer_commit_tokens (parser->lexer); return finish_constraint_primary_expr (expr); } diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index abbba7c6746e7..607753ae6b7f4 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -3940,7 +3940,7 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data) parameter pack (14.6.3), or the type-specifier-seq of a type-id that is a pack expansion, the invented template parameter is a template parameter pack. */ - if (ppd->type_pack_expansion_p && is_auto (t) + if (flag_concepts_ts && ppd->type_pack_expansion_p && is_auto (t) && TEMPLATE_TYPE_LEVEL (t) != 0) TEMPLATE_TYPE_PARAMETER_PACK (t) = true; if (TEMPLATE_TYPE_PARAMETER_PACK (t)) diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index 44cc4289f39c1..08f5f245e7d11 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -11667,28 +11667,18 @@ init_cp_semantics (void) } -/* Build a STATIC_ASSERT for a static assertion with the condition - CONDITION and the message text MESSAGE. LOCATION is the location - of the static assertion in the source code. When MEMBER_P, this - static assertion is a member of a class. If SHOW_EXPR_P is true, - print the condition (because it was instantiation-dependent). */ +/* Get constant string at LOCATION. Returns true if successful, + otherwise false. */ -void -finish_static_assert (tree condition, tree message, location_t location, - bool member_p, bool show_expr_p) +bool +cexpr_str::type_check (location_t location) { tsubst_flags_t complain = tf_warning_or_error; - tree message_sz = NULL_TREE, message_data = NULL_TREE; if (message == NULL_TREE || message == error_mark_node - || condition == NULL_TREE - || condition == error_mark_node) - return; - - if (check_for_bare_parameter_packs (condition) || check_for_bare_parameter_packs (message)) - return; + return false; if (TREE_CODE (message) != STRING_CST && !type_dependent_expression_p (message)) @@ -11704,10 +11694,10 @@ finish_static_assert (tree condition, tree message, location_t location, false, complain); if (message_sz == error_mark_node || message_data == error_mark_node) { - error_at (location, "% message must be a string " - "literal or object with % and " - "% members"); - return; + error_at (location, "constexpr string must be a string " + "literal or object with % and " + "% members"); + return false; } releasing_vec size_args, data_args; message_sz = finish_call_expr (message_sz, &size_args, false, false, @@ -11715,26 +11705,158 @@ finish_static_assert (tree condition, tree message, location_t location, message_data = finish_call_expr (message_data, &data_args, false, false, complain); if (message_sz == error_mark_node || message_data == error_mark_node) - return; + return false; message_sz = build_converted_constant_expr (size_type_node, message_sz, - complain); + complain); if (message_sz == error_mark_node) { - error_at (location, "% message % " - "must be implicitly convertible to " - "%"); - return; + error_at (location, "constexpr string % " + "must be implicitly convertible to " + "%"); + return false; } message_data = build_converted_constant_expr (const_string_type_node, - message_data, complain); + message_data, complain); if (message_data == error_mark_node) { - error_at (location, "% message % " - "must be implicitly convertible to " - "%"); - return; + error_at (location, "constexpr string % " + "must be implicitly convertible to " + "%"); + return false; + } + } + return true; +} + +/* Extract constant string at LOCATON into output string STR. + Returns true if successful, otherwise false. */ + +bool +cexpr_str::extract (location_t location, tree &str) +{ + const char *msg; + int len; + if (!extract (location, msg, len)) + return false; + str = build_string (len, msg); + return true; +} + +/* Extract constant string at LOCATION into output string MSG with LEN. + Returns true if successful, otherwise false. */ + +bool +cexpr_str::extract (location_t location, const char * & msg, int &len) +{ + tsubst_flags_t complain = tf_warning_or_error; + + msg = NULL; + if (message_sz && message_data) + { + tree msz = cxx_constant_value (message_sz, NULL_TREE, complain); + if (!tree_fits_uhwi_p (msz)) + { + error_at (location, + "constexpr string % " + "must be a constant expression"); + return false; + } + else if ((unsigned HOST_WIDE_INT) (int) tree_to_uhwi (msz) + != tree_to_uhwi (msz)) + { + error_at (location, + "constexpr string message % " + "%qE too large", msz); + return false; + } + len = tree_to_uhwi (msz); + tree data = maybe_constant_value (message_data, NULL_TREE, + mce_true); + if (!reduced_constant_expression_p (data)) + data = NULL_TREE; + if (len) + { + if (data) + msg = c_getstr (data); + if (msg == NULL) + buf = XNEWVEC (char, len); + for (int i = 0; i < len; ++i) + { + tree t = message_data; + if (i) + t = build2 (POINTER_PLUS_EXPR, + TREE_TYPE (message_data), message_data, + size_int (i)); + t = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (t)), t); + tree t2 = cxx_constant_value (t, NULL_TREE, complain); + if (!tree_fits_shwi_p (t2)) + { + error_at (location, + "constexpr string % " + "must be a constant expression", i); + return false; + } + if (msg == NULL) + buf[i] = tree_to_shwi (t2); + /* If c_getstr worked, just verify the first and + last characters using constant evaluation. */ + else if (len > 2 && i == 0) + i = len - 2; + } + if (msg == NULL) + msg = buf; + } + else if (!data) + { + /* We don't have any function to test whether some + expression is a core constant expression. So, instead + test whether (message.data (), 0) is a constant + expression. */ + data = build2 (COMPOUND_EXPR, integer_type_node, + message_data, integer_zero_node); + tree t = cxx_constant_value (data, NULL_TREE, complain); + if (!integer_zerop (t)) + { + error_at (location, + "constexpr string % " + "must be a core constant expression"); + return false; + } } } + else + { + tree eltype = TREE_TYPE (TREE_TYPE (message)); + int sz = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (eltype)); + msg = TREE_STRING_POINTER (message); + len = TREE_STRING_LENGTH (message) / sz - 1; + } + + return true; +} + +/* Build a STATIC_ASSERT for a static assertion with the condition + CONDITION and the message text MESSAGE. LOCATION is the location + of the static assertion in the source code. When MEMBER_P, this + static assertion is a member of a class. If SHOW_EXPR_P is true, + print the condition (because it was instantiation-dependent). */ + +void +finish_static_assert (tree condition, tree message, location_t location, + bool member_p, bool show_expr_p) +{ + tsubst_flags_t complain = tf_warning_or_error; + + if (condition == NULL_TREE + || condition == error_mark_node) + return; + + if (check_for_bare_parameter_packs (condition)) + return; + + cexpr_str cstr(message); + if (!cstr.type_check (location)) + return; /* Save the condition in case it was a concept check. */ tree orig_condition = condition; @@ -11747,7 +11869,7 @@ finish_static_assert (tree condition, tree message, location_t location, defer: tree assertion = make_node (STATIC_ASSERT); STATIC_ASSERT_CONDITION (assertion) = orig_condition; - STATIC_ASSERT_MESSAGE (assertion) = message; + STATIC_ASSERT_MESSAGE (assertion) = cstr.message; STATIC_ASSERT_SOURCE_LOCATION (assertion) = location; if (member_p) @@ -11780,88 +11902,8 @@ finish_static_assert (tree condition, tree message, location_t location, int len; const char *msg = NULL; - char *buf = NULL; - if (message_sz && message_data) - { - tree msz = cxx_constant_value (message_sz, NULL_TREE, complain); - if (!tree_fits_uhwi_p (msz)) - { - error_at (location, - "% message % " - "must be a constant expression"); - return; - } - else if ((unsigned HOST_WIDE_INT) (int) tree_to_uhwi (msz) - != tree_to_uhwi (msz)) - { - error_at (location, - "% message % " - "%qE too large", msz); - return; - } - len = tree_to_uhwi (msz); - tree data = maybe_constant_value (message_data, NULL_TREE, - mce_true); - if (!reduced_constant_expression_p (data)) - data = NULL_TREE; - if (len) - { - if (data) - msg = c_getstr (data); - if (msg == NULL) - buf = XNEWVEC (char, len); - for (int i = 0; i < len; ++i) - { - tree t = message_data; - if (i) - t = build2 (POINTER_PLUS_EXPR, - TREE_TYPE (message_data), message_data, - size_int (i)); - t = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (t)), t); - tree t2 = cxx_constant_value (t, NULL_TREE, complain); - if (!tree_fits_shwi_p (t2)) - { - error_at (location, - "% message % " - "must be a constant expression", i); - XDELETEVEC (buf); - return; - } - if (msg == NULL) - buf[i] = tree_to_shwi (t2); - /* If c_getstr worked, just verify the first and - last characters using constant evaluation. */ - else if (len > 2 && i == 0) - i = len - 2; - } - if (msg == NULL) - msg = buf; - } - else if (!data) - { - /* We don't have any function to test whether some - expression is a core constant expression. So, instead - test whether (message.data (), 0) is a constant - expression. */ - data = build2 (COMPOUND_EXPR, integer_type_node, - message_data, integer_zero_node); - tree t = cxx_constant_value (data, NULL_TREE, complain); - if (!integer_zerop (t)) - { - error_at (location, - "% message % " - "must be a core constant expression"); - return; - } - } - } - else - { - tree eltype = TREE_TYPE (TREE_TYPE (message)); - int sz = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (eltype)); - msg = TREE_STRING_POINTER (message); - len = TREE_STRING_LENGTH (message) / sz - 1; - } + if (!cstr.extract (location, msg, len)) + return; /* See if we can find which clause was failing (for logical AND). */ tree bad = find_failing_clause (NULL, orig_condition); @@ -11877,8 +11919,6 @@ finish_static_assert (tree condition, tree message, location_t location, else error_at (cloc, "static assertion failed: %.*s", len, msg); - XDELETEVEC (buf); - diagnose_failing_condition (bad, cloc, show_expr_p); } else if (condition && condition != error_mark_node) diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc index d2a8f79ffab46..28648c14c6da0 100644 --- a/gcc/cp/tree.cc +++ b/gcc/cp/tree.cc @@ -2526,11 +2526,15 @@ lookup_maybe_add (tree fns, tree lookup, bool deduping) predecessors onto the lookup. */ for (; fns != probe; fns = OVL_CHAIN (fns)) { - lookup = lookup_add (OVL_FUNCTION (fns), lookup); /* Propagate OVL_USING, but OVL_HIDDEN & OVL_DEDUP_P don't matter. */ if (OVL_USING_P (fns)) - OVL_USING_P (lookup) = true; + { + lookup = ovl_make (OVL_FUNCTION (fns), lookup); + OVL_USING_P (lookup) = true; + } + else + lookup = lookup_add (OVL_FUNCTION (fns), lookup); } /* And now skip this function. */ diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc index 5970ac3d39898..717eb63eb9850 100644 --- a/gcc/cp/typeck.cc +++ b/gcc/cp/typeck.cc @@ -393,6 +393,9 @@ cp_compare_floating_point_conversion_ranks (tree t1, tree t2) has higher rank. */ if (cnt > 1 && mv2 == long_double_type_node) return -2; + /* And similarly if t2 is float, t2 has lower rank. */ + if (cnt > 1 && mv2 == float_type_node) + return 2; /* Otherwise, they have equal rank, but extended types (other than std::bfloat16_t) have higher subrank. std::bfloat16_t shouldn't have equal rank to any standard diff --git a/gcc/data-streamer-in.cc b/gcc/data-streamer-in.cc index 12cb10e42c034..7dce2928ef034 100644 --- a/gcc/data-streamer-in.cc +++ b/gcc/data-streamer-in.cc @@ -219,14 +219,14 @@ streamer_read_real_value (class lto_input_block *ib, REAL_VALUE_TYPE *r) void streamer_read_value_range (class lto_input_block *ib, data_in *data_in, - Value_Range &vr) + value_range &vr) { // Read the common fields to all vranges. value_range_kind kind = streamer_read_enum (ib, value_range_kind, VR_LAST); gcc_checking_assert (kind != VR_UNDEFINED); tree type = stream_read_tree (ib, data_in); - // Initialize the Value_Range to the correct type. + // Initialize the value_range to the correct type. vr.set_type (type); if (is_a (vr)) diff --git a/gcc/data-streamer.h b/gcc/data-streamer.h index 88f8ed5231dd1..6a2596134ceb3 100644 --- a/gcc/data-streamer.h +++ b/gcc/data-streamer.h @@ -93,7 +93,7 @@ gcov_type streamer_read_gcov_count (class lto_input_block *); wide_int streamer_read_wide_int (class lto_input_block *); widest_int streamer_read_widest_int (class lto_input_block *); void streamer_read_value_range (class lto_input_block *, class data_in *, - class Value_Range &); + class value_range &); /* Returns a new bit-packing context for bit-packing into S. */ inline struct bitpack_d diff --git a/gcc/diagnostic-color.cc b/gcc/diagnostic-color.cc index cbe57ce763f2a..184419cea367c 100644 --- a/gcc/diagnostic-color.cc +++ b/gcc/diagnostic-color.cc @@ -300,12 +300,23 @@ should_colorize (void) pp_write_text_to_stream() in pretty-print.cc calls fputs() on that stream. However, the code below for non-Windows doesn't seem to care about it either... */ - HANDLE h; - DWORD m; + HANDLE handle; + DWORD mode; + BOOL isconsole = false; - h = GetStdHandle (STD_ERROR_HANDLE); - return (h != INVALID_HANDLE_VALUE) && (h != NULL) - && GetConsoleMode (h, &m); + handle = GetStdHandle (STD_ERROR_HANDLE); + + if ((handle != INVALID_HANDLE_VALUE) && (handle != NULL)) + isconsole = GetConsoleMode (handle, &mode); + + if (isconsole) + { + /* Try to enable processing of VT100 escape sequences */ + mode |= ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING; + SetConsoleMode (handle, mode); + } + + return isconsole; #else char const *t = getenv ("TERM"); /* emacs M-x shell sets TERM="dumb". */ @@ -373,9 +384,6 @@ parse_env_vars_for_urls () static bool auto_enable_urls () { -#ifdef __MINGW32__ - return false; -#else const char *term, *colorterm; /* First check the terminal is capable of printing color escapes, @@ -383,6 +391,21 @@ auto_enable_urls () if (!should_colorize ()) return false; +#ifdef __MINGW32__ + HANDLE handle; + DWORD mode; + + handle = GetStdHandle (STD_ERROR_HANDLE); + if ((handle == INVALID_HANDLE_VALUE) || (handle == NULL)) + return false; + + /* If ansi escape sequences aren't supported by the console, then URLs will + print mangled from mingw_ansi_fputs's console API translation. It wouldn't + be useful even if this weren't the case. */ + if (GetConsoleMode (handle, &mode) && !(mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING)) + return false; +#endif + /* xfce4-terminal is known to not implement URLs at this time. Recently new installations (0.8) will safely ignore the URL escape sequences, but a large number of legacy installations (0.6.3) print @@ -417,7 +440,6 @@ auto_enable_urls () return false; return true; -#endif } /* Determine if URLs should be enabled, based on RULE, diff --git a/gcc/diagnostic-format-json.cc b/gcc/diagnostic-format-json.cc index 0782ae831ebaa..ec03ac15aebab 100644 --- a/gcc/diagnostic-format-json.cc +++ b/gcc/diagnostic-format-json.cc @@ -25,8 +25,10 @@ along with GCC; see the file COPYING3. If not see #include "diagnostic.h" #include "selftest-diagnostic.h" #include "diagnostic-metadata.h" +#include "diagnostic-path.h" #include "json.h" #include "selftest.h" +#include "logical-location.h" /* Subclass of diagnostic_output_format for JSON output. */ @@ -187,6 +189,36 @@ json_from_metadata (const diagnostic_metadata *metadata) return metadata_obj; } +/* Make a JSON value for PATH. */ + +static json::value * +make_json_for_path (diagnostic_context *context, + const diagnostic_path *path) +{ + json::array *path_array = new json::array (); + for (unsigned i = 0; i < path->num_events (); i++) + { + const diagnostic_event &event = path->get_event (i); + + json::object *event_obj = new json::object (); + if (event.get_location ()) + event_obj->set ("location", + json_from_expanded_location (context, + event.get_location ())); + label_text event_text (event.get_desc (false)); + event_obj->set_string ("description", event_text.get ()); + if (const logical_location *logical_loc = event.get_logical_location ()) + { + label_text name (logical_loc->get_name_for_path_output ()); + event_obj->set_string ("function", name.get ()); + } + event_obj->set_integer ("depth", event.get_stack_depth ()); + path_array->append (event_obj); + } + return path_array; +} + + /* Implementation of "on_end_diagnostic" vfunc for JSON output. Generate a JSON object for DIAGNOSTIC, and store for output within current diagnostic group. */ @@ -291,10 +323,9 @@ json_output_format::on_end_diagnostic (const diagnostic_info &diagnostic, } const diagnostic_path *path = richloc->get_path (); - if (path && m_context.m_make_json_for_path) + if (path) { - json::value *path_value - = m_context.m_make_json_for_path (&m_context, path); + json::value *path_value = make_json_for_path (&m_context, path); diag_obj->set ("path", path_value); } @@ -364,8 +395,8 @@ class json_file_output_format : public json_output_format static void diagnostic_output_format_init_json (diagnostic_context *context) { - /* Override callbacks. */ - context->m_print_path = nullptr; /* handled in json_end_diagnostic. */ + /* Suppress normal textual path output. */ + context->set_path_format (DPF_NONE); /* The metadata is handled in JSON format, rather than as text. */ context->set_show_cwe (false); diff --git a/gcc/diagnostic-format-sarif.cc b/gcc/diagnostic-format-sarif.cc index 79116f051bc12..5f438dd38a886 100644 --- a/gcc/diagnostic-format-sarif.cc +++ b/gcc/diagnostic-format-sarif.cc @@ -1991,8 +1991,10 @@ class sarif_file_output_format : public sarif_output_format static void diagnostic_output_format_init_sarif (diagnostic_context *context) { + /* Suppress normal textual path output. */ + context->set_path_format (DPF_NONE); + /* Override callbacks. */ - context->m_print_path = nullptr; /* handled in sarif_end_diagnostic. */ context->set_ice_handler_callback (sarif_ice_handler); /* The metadata is handled in SARIF format, rather than as text. */ diff --git a/gcc/diagnostic-macro-unwinding.cc b/gcc/diagnostic-macro-unwinding.cc new file mode 100644 index 0000000000000..3056d8c8afb12 --- /dev/null +++ b/gcc/diagnostic-macro-unwinding.cc @@ -0,0 +1,221 @@ +/* Code for unwinding macro expansions in diagnostics. + Copyright (C) 1999-2024 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 +. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tree.h" +#include "diagnostic.h" +#include "diagnostic-macro-unwinding.h" +#include "intl.h" + +/* This is a pair made of a location and the line map it originated + from. It's used in the maybe_unwind_expanded_macro_loc function + below. */ +struct loc_map_pair +{ + const line_map_macro *map; + location_t where; +}; + + +/* Unwind the different macro expansions that lead to the token which + location is WHERE and emit diagnostics showing the resulting + unwound macro expansion trace. Let's look at an example to see how + the trace looks like. Suppose we have this piece of code, + artificially annotated with the line numbers to increase + legibility: + + $ cat -n test.c + 1 #define OPERATE(OPRD1, OPRT, OPRD2) \ + 2 OPRD1 OPRT OPRD2; + 3 + 4 #define SHIFTL(A,B) \ + 5 OPERATE (A,<<,B) + 6 + 7 #define MULT(A) \ + 8 SHIFTL (A,1) + 9 + 10 void + 11 g () + 12 { + 13 MULT (1.0);// 1.0 << 1; <-- so this is an error. + 14 } + + Here is the diagnostic that we want the compiler to generate: + + test.c: In function ‘g’: + test.c:5:14: error: invalid operands to binary << (have ‘double’ and ‘int’) + test.c:2:9: note: in definition of macro 'OPERATE' + test.c:8:3: note: in expansion of macro 'SHIFTL' + test.c:13:3: note: in expansion of macro 'MULT' + + The part that goes from the third to the fifth line of this + diagnostic (the lines containing the 'note:' string) is called the + unwound macro expansion trace. That's the part generated by this + function. */ + +void +maybe_unwind_expanded_macro_loc (diagnostic_context *context, + location_t where) +{ + const struct line_map *map; + auto_vec loc_vec; + unsigned ix; + loc_map_pair loc, *iter; + + const location_t original_loc = where; + + map = linemap_lookup (line_table, where); + if (!linemap_macro_expansion_map_p (map)) + return; + + /* Let's unwind the macros that got expanded and led to the token + which location is WHERE. We are going to store these macros into + LOC_VEC, so that we can later walk it at our convenience to + display a somewhat meaningful trace of the macro expansion + history to the user. Note that the first macro of the trace + (which is OPERATE in the example above) is going to be stored at + the beginning of LOC_VEC. */ + + do + { + loc.where = where; + loc.map = linemap_check_macro (map); + + loc_vec.safe_push (loc); + + /* WHERE is the location of a token inside the expansion of a + macro. MAP is the map holding the locations of that macro + expansion. Let's get the location of the token inside the + context that triggered the expansion of this macro. + This is basically how we go "down" in the trace of macro + expansions that led to WHERE. */ + where = linemap_unwind_toward_expansion (line_table, where, &map); + } while (linemap_macro_expansion_map_p (map)); + + /* Now map is set to the map of the location in the source that + first triggered the macro expansion. This must be an ordinary map. */ + const line_map_ordinary *ord_map = linemap_check_ordinary (map); + + /* Walk LOC_VEC and print the macro expansion trace, unless the + first macro which expansion triggered this trace was expanded + inside a system header. */ + int saved_location_line = + expand_location_to_spelling_point (original_loc).line; + + if (!LINEMAP_SYSP (ord_map)) + FOR_EACH_VEC_ELT (loc_vec, ix, iter) + { + /* Sometimes, in the unwound macro expansion trace, we want to + print a part of the context that shows where, in the + definition of the relevant macro, is the token (we are + looking at) used. That is the case in the introductory + comment of this function, where we print: + + test.c:2:9: note: in definition of macro 'OPERATE'. + + We print that "macro definition context" because the + diagnostic line (emitted by the call to + pp_ouput_formatted_text in diagnostic_report_diagnostic): + + test.c:5:14: error: invalid operands to binary << (have ‘double’ and ‘int’) + + does not point into the definition of the macro where the + token '<<' (that is an argument to the function-like macro + OPERATE) is used. So we must "display" the line of that + macro definition context to the user somehow. + + A contrario, when the first interesting diagnostic line + points into the definition of the macro, we don't need to + display any line for that macro definition in the trace + anymore, otherwise it'd be redundant. */ + + /* Okay, now here is what we want. For each token resulting + from macro expansion we want to show: 1/ where in the + definition of the macro the token comes from; 2/ where the + macro got expanded. */ + + /* Resolve the location iter->where into the locus 1/ of the + comment above. */ + location_t resolved_def_loc = + linemap_resolve_location (line_table, iter->where, + LRK_MACRO_DEFINITION_LOCATION, NULL); + + /* Don't print trace for locations that are reserved or from + within a system header. */ + const line_map_ordinary *m = NULL; + location_t l = + linemap_resolve_location (line_table, resolved_def_loc, + LRK_SPELLING_LOCATION, &m); + location_t l0 = l; + if (IS_ADHOC_LOC (l0)) + l0 = get_location_from_adhoc_loc (line_table, l0); + if (l0 < RESERVED_LOCATION_COUNT || LINEMAP_SYSP (m)) + continue; + + /* We need to print the context of the macro definition only + when the locus of the first displayed diagnostic (displayed + before this trace) was inside the definition of the + macro. */ + const int resolved_def_loc_line = SOURCE_LINE (m, l0); + if (ix == 0 && saved_location_line != resolved_def_loc_line) + { + diagnostic_append_note (context, resolved_def_loc, + "in definition of macro %qs", + linemap_map_get_macro_name (iter->map)); + /* At this step, as we've printed the context of the macro + definition, we don't want to print the context of its + expansion, otherwise, it'd be redundant. */ + continue; + } + + /* Resolve the location of the expansion point of the macro + which expansion gave the token represented by def_loc. + This is the locus 2/ of the earlier comment. */ + location_t resolved_exp_loc = + linemap_resolve_location (line_table, + iter->map->get_expansion_point_location (), + LRK_MACRO_DEFINITION_LOCATION, NULL); + + diagnostic_append_note (context, resolved_exp_loc, + "in expansion of macro %qs", + linemap_map_get_macro_name (iter->map)); + } +} + +/* This is a diagnostic finalizer implementation that is aware of + virtual locations produced by libcpp. + + It has to be called by the diagnostic finalizer of front ends that + uses libcpp and wish to get diagnostics involving tokens resulting + from macro expansion. + + For a given location, if said location belongs to a token + resulting from a macro expansion, this starter prints the context + of the token. E.g, for multiply nested macro expansion, it + unwinds the nested macro expansions and prints them in a manner + that is similar to what is done for function call stacks, or + template instantiation contexts. */ +void +virt_loc_aware_diagnostic_finalizer (diagnostic_context *context, + const diagnostic_info *diagnostic) +{ + maybe_unwind_expanded_macro_loc (context, diagnostic_location (diagnostic)); +} diff --git a/gcc/diagnostic-macro-unwinding.h b/gcc/diagnostic-macro-unwinding.h new file mode 100644 index 0000000000000..74083cd56ded5 --- /dev/null +++ b/gcc/diagnostic-macro-unwinding.h @@ -0,0 +1,29 @@ +/* Code for unwinding macro expansions in diagnostics. + Copyright (C) 2000-2024 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 +. */ + +#ifndef GCC_DIAGNOSTIC_MACRO_UNWINDING_H +#define GCC_DIAGNOSTIC_MACRO_UNWINDING_H + +void virt_loc_aware_diagnostic_finalizer (diagnostic_context *, + const diagnostic_info *); + +extern void maybe_unwind_expanded_macro_loc (diagnostic_context *context, + location_t where); + +#endif /* ! GCC_DIAGNOSTIC_MACRO_UNWINDING_H */ diff --git a/gcc/tree-diagnostic-path.cc b/gcc/diagnostic-path.cc similarity index 89% rename from gcc/tree-diagnostic-path.cc rename to gcc/diagnostic-path.cc index 0ad6c5beb81c1..882dc1c5805fd 100644 --- a/gcc/tree-diagnostic-path.cc +++ b/gcc/diagnostic-path.cc @@ -25,23 +25,26 @@ along with GCC; see the file COPYING3. If not see #define INCLUDE_VECTOR #include "system.h" #include "coretypes.h" -#include "tree.h" #include "diagnostic.h" -#include "tree-pretty-print.h" -#include "gimple-pretty-print.h" -#include "tree-diagnostic.h" -#include "langhooks.h" +#include "diagnostic-macro-unwinding.h" #include "intl.h" #include "diagnostic-path.h" -#include "json.h" #include "gcc-rich-location.h" #include "diagnostic-color.h" #include "diagnostic-event-id.h" #include "diagnostic-label-effects.h" #include "selftest.h" #include "selftest-diagnostic.h" +#include "selftest-diagnostic-path.h" #include "text-art/theme.h" +/* Disable warnings about missing quoting in GCC diagnostics for the print + calls below. */ +#if __GNUC__ >= 10 +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wformat-diag" +#endif + /* Anonymous namespace for path-printing code. */ namespace { @@ -152,14 +155,17 @@ class path_label : public range_label when printing a diagnostic_path. */ static bool -can_consolidate_events (const diagnostic_event &e1, +can_consolidate_events (const diagnostic_path &path, + const diagnostic_event &e1, + unsigned ev1_idx, const diagnostic_event &e2, + unsigned ev2_idx, bool check_locations) { if (e1.get_thread_id () != e2.get_thread_id ()) return false; - if (e1.get_fndecl () != e2.get_fndecl ()) + if (!path.same_function_p (ev1_idx, ev2_idx)) return false; if (e1.get_stack_depth () != e2.get_stack_depth ()) @@ -195,8 +201,10 @@ class thread_event_printer; class per_thread_summary { public: - per_thread_summary (label_text name, unsigned swimlane_idx) - : m_name (std::move (name)), + per_thread_summary (const diagnostic_path &path, + label_text name, unsigned swimlane_idx) + : m_path (path), + m_name (std::move (name)), m_swimlane_idx (swimlane_idx), m_last_event (nullptr), m_min_depth (INT_MAX), @@ -221,6 +229,8 @@ class per_thread_summary friend class thread_event_printer; friend struct event_range; + const diagnostic_path &m_path; + const label_text m_name; /* The "swimlane index" is the order in which this per_thread_summary @@ -332,7 +342,7 @@ struct event_range bool show_event_links) : m_path (path), m_initial_event (initial_event), - m_fndecl (initial_event.get_fndecl ()), + m_logical_loc (initial_event.get_logical_location ()), m_stack_depth (initial_event.get_stack_depth ()), m_start_idx (start_idx), m_end_idx (start_idx), m_path_label (path, start_idx), @@ -372,10 +382,13 @@ struct event_range return result; } - bool maybe_add_event (const diagnostic_event &new_ev, unsigned idx, + bool maybe_add_event (const diagnostic_event &new_ev, + unsigned new_ev_idx, bool check_rich_locations) { - if (!can_consolidate_events (m_initial_event, new_ev, + if (!can_consolidate_events (*m_path, + m_initial_event, m_start_idx, + new_ev, new_ev_idx, check_rich_locations)) return false; @@ -387,8 +400,8 @@ struct event_range per_source_line_info &source_line_info = get_per_source_line_info (exploc.line); const diagnostic_event *prev_event = nullptr; - if (idx > 0) - prev_event = &m_path->get_event (idx - 1); + if (new_ev_idx > 0) + prev_event = &m_path->get_event (new_ev_idx - 1); const bool has_in_edge = (prev_event ? prev_event->connect_to_next_event_p () : false); @@ -405,7 +418,7 @@ struct event_range false, &m_path_label)) return false; - m_end_idx = idx; + m_end_idx = new_ev_idx; m_per_thread_summary.m_last_event = &new_ev; if (m_show_event_links) @@ -469,7 +482,7 @@ struct event_range const diagnostic_path *m_path; const diagnostic_event &m_initial_event; - tree m_fndecl; + const logical_location *m_logical_loc; int m_stack_depth; unsigned m_start_idx; unsigned m_end_idx; @@ -517,8 +530,10 @@ struct path_summary return **slot; const diagnostic_thread &thread = path.get_thread (tid); - per_thread_summary *pts = new per_thread_summary (thread.get_name (false), - m_per_thread_summary.length ()); + per_thread_summary *pts + = new per_thread_summary (path, + thread.get_name (false), + m_per_thread_summary.length ()); m_thread_id_to_events.put (tid, pts); m_per_thread_summary.safe_push (pts); return *pts; @@ -533,12 +548,12 @@ per_thread_summary::interprocedural_p () const { if (m_event_ranges.is_empty ()) return false; - tree first_fndecl = m_event_ranges[0]->m_fndecl; int first_stack_depth = m_event_ranges[0]->m_stack_depth; for (auto range : m_event_ranges) { - if (range->m_fndecl != first_fndecl) - return true; + if (!m_path.same_function_p (m_event_ranges[0]->m_start_idx, + range->m_start_idx)) + return true; if (range->m_stack_depth != first_stack_depth) return true; } @@ -584,23 +599,6 @@ write_indent (pretty_printer *pp, int spaces) pp_space (pp); } -/* Print FNDDECL to PP, quoting it if QUOTED is true. - - We can't use "%qE" here since we can't guarantee the capabilities - of PP. */ - -static void -print_fndecl (pretty_printer *pp, tree fndecl, bool quoted) -{ - const char *n = DECL_NAME (fndecl) - ? identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)) - : _(""); - if (quoted) - pp_printf (pp, "%qs", n); - else - pp_string (pp, n); -} - static const int base_indent = 2; static const int per_frame_indent = 2; @@ -683,10 +681,10 @@ class thread_event_printer m_cur_indent += 5; } } - if (range->m_fndecl) + if (const logical_location *logical_loc = range->m_logical_loc) { - print_fndecl (pp, range->m_fndecl, true); - pp_string (pp, ": "); + label_text name (logical_loc->get_name_for_path_output ()); + pp_printf (pp, "%qs: ", name.get ()); } if (range->m_start_idx == range->m_end_idx) pp_printf (pp, "event %i", @@ -885,17 +883,16 @@ print_path_summary_as_text (const path_summary *ps, diagnostic_context *dc, } /* end of anonymous namespace for path-printing code. */ -/* Print PATH to CONTEXT, according to CONTEXT's path_format. */ +/* Print PATH according to this context's path_format. */ void -default_tree_diagnostic_path_printer (diagnostic_context *context, - const diagnostic_path *path) +diagnostic_context::print_path (const diagnostic_path *path) { gcc_assert (path); const unsigned num_events = path->num_events (); - switch (context->get_path_format ()) + switch (get_path_format ()) { case DPF_NONE: /* Do nothing. */ @@ -910,18 +907,21 @@ default_tree_diagnostic_path_printer (diagnostic_context *context, label_text event_text (event.get_desc (false)); gcc_assert (event_text.get ()); diagnostic_event_id_t event_id (i); - if (context->show_path_depths_p ()) + if (this->show_path_depths_p ()) { int stack_depth = event.get_stack_depth (); - tree fndecl = event.get_fndecl (); /* -fdiagnostics-path-format=separate-events doesn't print fndecl information, so with -fdiagnostics-show-path-depths print the fndecls too, if any. */ - if (fndecl) - inform (event.get_location (), - "%@ %s (fndecl %qD, depth %i)", - &event_id, event_text.get (), - fndecl, stack_depth); + if (const logical_location *logical_loc + = event.get_logical_location ()) + { + label_text name (logical_loc->get_name_for_path_output ()); + inform (event.get_location (), + "%@ %s (fndecl %qs, depth %i)", + &event_id, event_text.get (), + name.get (), stack_depth); + } else inform (event.get_location (), "%@ %s (depth %i)", @@ -939,59 +939,20 @@ default_tree_diagnostic_path_printer (diagnostic_context *context, { /* Consolidate related events. */ path_summary summary (*path, true, - context->m_source_printing.show_event_links_p); - char *saved_prefix = pp_take_prefix (context->printer); - pp_set_prefix (context->printer, NULL); - print_path_summary_as_text (&summary, context, - context->show_path_depths_p ()); - pp_flush (context->printer); - pp_set_prefix (context->printer, saved_prefix); + m_source_printing.show_event_links_p); + char *saved_prefix = pp_take_prefix (this->printer); + pp_set_prefix (this->printer, NULL); + print_path_summary_as_text (&summary, this, + show_path_depths_p ()); + pp_flush (this->printer); + pp_set_prefix (this->printer, saved_prefix); } break; } } -/* This has to be here, rather than diagnostic-format-json.cc, - since diagnostic-format-json.o is within OBJS-libcommon and thus - doesn't have access to trees (for m_fndecl). */ - -json::value * -default_tree_make_json_for_path (diagnostic_context *context, - const diagnostic_path *path) -{ - json::array *path_array = new json::array (); - for (unsigned i = 0; i < path->num_events (); i++) - { - const diagnostic_event &event = path->get_event (i); - - json::object *event_obj = new json::object (); - if (event.get_location ()) - event_obj->set ("location", - json_from_expanded_location (context, - event.get_location ())); - label_text event_text (event.get_desc (false)); - event_obj->set_string ("description", event_text.get ()); - if (tree fndecl = event.get_fndecl ()) - { - const char *function - = identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)); - event_obj->set_string ("function", function); - } - event_obj->set_integer ("depth", event.get_stack_depth ()); - path_array->append (event_obj); - } - return path_array; -} - #if CHECKING_P -/* Disable warnings about missing quoting in GCC diagnostics for the print - calls in the tests below. */ -#if __GNUC__ >= 10 -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wformat-diag" -#endif - namespace selftest { /* Return true iff all events in PATH have locations for which column data @@ -1015,38 +976,6 @@ path_events_have_column_data_p (const diagnostic_path &path) return true; } -/* A subclass of simple_diagnostic_path that adds member functions - for adding test events and suppresses translation of these events. */ - -class test_diagnostic_path : public simple_diagnostic_path -{ - public: - test_diagnostic_path (pretty_printer *event_pp) - : simple_diagnostic_path (event_pp) - { - disable_event_localization (); - } - - void add_entry (tree fndecl, int stack_depth) - { - add_event (UNKNOWN_LOCATION, fndecl, stack_depth, - "entering %qE", fndecl); - } - - void add_return (tree fndecl, int stack_depth) - { - add_event (UNKNOWN_LOCATION, fndecl, stack_depth, - "returning to %qE", fndecl); - } - - void add_call (tree caller, int caller_stack_depth, tree callee) - { - add_event (UNKNOWN_LOCATION, caller, caller_stack_depth, - "calling %qE", callee); - add_entry (callee, caller_stack_depth + 1); - } -}; - /* Verify that empty paths are handled gracefully. */ static void @@ -1069,13 +998,10 @@ test_empty_path (pretty_printer *event_pp) static void test_intraprocedural_path (pretty_printer *event_pp) { - tree fntype_void_void - = build_function_type_array (void_type_node, 0, NULL); - tree fndecl_foo = build_fn_decl ("foo", fntype_void_void); - test_diagnostic_path path (event_pp); - path.add_event (UNKNOWN_LOCATION, fndecl_foo, 0, "first %qs", "free"); - path.add_event (UNKNOWN_LOCATION, fndecl_foo, 0, "double %qs", "free"); + const char *const funcname = "foo"; + path.add_event (UNKNOWN_LOCATION, funcname, 0, "first %qs", "free"); + path.add_event (UNKNOWN_LOCATION, funcname, 0, "double %qs", "free"); ASSERT_FALSE (path.interprocedural_p ()); @@ -1095,33 +1021,20 @@ test_intraprocedural_path (pretty_printer *event_pp) static void test_interprocedural_path_1 (pretty_printer *event_pp) { - /* Build fndecls. The types aren't quite right, but that - doesn't matter for the purposes of this test. */ - tree fntype_void_void - = build_function_type_array (void_type_node, 0, NULL); - tree fndecl_test = build_fn_decl ("test", fntype_void_void); - tree fndecl_make_boxed_int - = build_fn_decl ("make_boxed_int", fntype_void_void); - tree fndecl_wrapped_malloc - = build_fn_decl ("wrapped_malloc", fntype_void_void); - tree fndecl_free_boxed_int - = build_fn_decl ("free_boxed_int", fntype_void_void); - tree fndecl_wrapped_free - = build_fn_decl ("wrapped_free", fntype_void_void); - test_diagnostic_path path (event_pp); - path.add_entry (fndecl_test, 0); - path.add_call (fndecl_test, 0, fndecl_make_boxed_int); - path.add_call (fndecl_make_boxed_int, 1, fndecl_wrapped_malloc); - path.add_event (UNKNOWN_LOCATION, fndecl_wrapped_malloc, 2, "calling malloc"); - path.add_return (fndecl_test, 0); - path.add_call (fndecl_test, 0, fndecl_free_boxed_int); - path.add_call (fndecl_free_boxed_int, 1, fndecl_wrapped_free); - path.add_event (UNKNOWN_LOCATION, fndecl_wrapped_free, 2, "calling free"); - path.add_return (fndecl_test, 0); - path.add_call (fndecl_test, 0, fndecl_free_boxed_int); - path.add_call (fndecl_free_boxed_int, 1, fndecl_wrapped_free); - path.add_event (UNKNOWN_LOCATION, fndecl_wrapped_free, 2, "calling free"); + path.add_entry ("test", 0); + path.add_call ("test", 0, "make_boxed_int"); + path.add_call ("make_boxed_int", 1, "wrapped_malloc"); + path.add_event (UNKNOWN_LOCATION, + "wrapped_malloc", 2, "calling malloc"); + path.add_return ("test", 0); + path.add_call ("test", 0, "free_boxed_int"); + path.add_call ("free_boxed_int", 1, "wrapped_free"); + path.add_event (UNKNOWN_LOCATION, "wrapped_free", 2, "calling free"); + path.add_return ("test", 0); + path.add_call ("test", 0, "free_boxed_int"); + path.add_call ("free_boxed_int", 1, "wrapped_free"); + path.add_event (UNKNOWN_LOCATION, "wrapped_free", 2, "calling free"); ASSERT_EQ (path.num_events (), 18); ASSERT_TRUE (path.interprocedural_p ()); @@ -1250,20 +1163,12 @@ test_interprocedural_path_1 (pretty_printer *event_pp) static void test_interprocedural_path_2 (pretty_printer *event_pp) { - /* Build fndecls. The types aren't quite right, but that - doesn't matter for the purposes of this test. */ - tree fntype_void_void - = build_function_type_array (void_type_node, 0, NULL); - tree fndecl_foo = build_fn_decl ("foo", fntype_void_void); - tree fndecl_bar = build_fn_decl ("bar", fntype_void_void); - tree fndecl_baz = build_fn_decl ("baz", fntype_void_void); - test_diagnostic_path path (event_pp); - path.add_entry (fndecl_foo, 0); - path.add_call (fndecl_foo, 0, fndecl_bar); - path.add_call (fndecl_bar, 1, fndecl_baz); - path.add_return (fndecl_bar, 1); - path.add_call (fndecl_bar, 1, fndecl_baz); + path.add_entry ("foo", 0); + path.add_call ("foo", 0, "bar"); + path.add_call ("bar", 1, "baz"); + path.add_return ("bar", 1); + path.add_call ("bar", 1, "baz"); ASSERT_EQ (path.num_events (), 8); ASSERT_TRUE (path.interprocedural_p ()); @@ -1343,14 +1248,10 @@ test_interprocedural_path_2 (pretty_printer *event_pp) static void test_recursion (pretty_printer *event_pp) { - tree fntype_void_void - = build_function_type_array (void_type_node, 0, NULL); - tree fndecl_factorial = build_fn_decl ("factorial", fntype_void_void); - test_diagnostic_path path (event_pp); - path.add_entry (fndecl_factorial, 0); + path.add_entry ("factorial", 0); for (int depth = 0; depth < 3; depth++) - path.add_call (fndecl_factorial, depth, fndecl_factorial); + path.add_call ("factorial", depth, "factorial"); ASSERT_EQ (path.num_events (), 7); ASSERT_TRUE (path.interprocedural_p ()); @@ -1487,14 +1388,14 @@ test_control_flow_1 (const line_table_case &case_, const location_t cfg_dest = t.get_line_and_column (5, 10); test_diagnostic_path path (event_pp); - path.add_event (conditional, NULL_TREE, 0, + path.add_event (conditional, nullptr, 0, "following %qs branch (when %qs is NULL)...", "false", "p"); path.connect_to_next_event (); - path.add_event (cfg_dest, NULL_TREE, 0, + path.add_event (cfg_dest, nullptr, 0, "...to here"); - path.add_event (cfg_dest, NULL_TREE, 0, + path.add_event (cfg_dest, nullptr, 0, "dereference of NULL %qs", "p"); @@ -1667,17 +1568,17 @@ test_control_flow_2 (const line_table_case &case_, const location_t loop_body_end = t.get_line_and_columns (5, 5, 9, 17); test_diagnostic_path path (event_pp); - path.add_event (iter_test, NULL_TREE, 0, "infinite loop here"); + path.add_event (iter_test, nullptr, 0, "infinite loop here"); - path.add_event (iter_test, NULL_TREE, 0, "looping from here..."); + path.add_event (iter_test, nullptr, 0, "looping from here..."); path.connect_to_next_event (); - path.add_event (loop_body_start, NULL_TREE, 0, "...to here"); + path.add_event (loop_body_start, nullptr, 0, "...to here"); - path.add_event (loop_body_end, NULL_TREE, 0, "looping back..."); + path.add_event (loop_body_end, nullptr, 0, "looping back..."); path.connect_to_next_event (); - path.add_event (iter_test, NULL_TREE, 0, "...to here"); + path.add_event (iter_test, nullptr, 0, "...to here"); if (!path_events_have_column_data_p (path)) return; @@ -1753,17 +1654,17 @@ test_control_flow_3 (const line_table_case &case_, const location_t iter_next = t.get_line_and_columns (3, 22, 24); test_diagnostic_path path (event_pp); - path.add_event (iter_test, NULL_TREE, 0, "infinite loop here"); + path.add_event (iter_test, nullptr, 0, "infinite loop here"); - path.add_event (iter_test, NULL_TREE, 0, "looping from here..."); + path.add_event (iter_test, nullptr, 0, "looping from here..."); path.connect_to_next_event (); - path.add_event (iter_next, NULL_TREE, 0, "...to here"); + path.add_event (iter_next, nullptr, 0, "...to here"); - path.add_event (iter_next, NULL_TREE, 0, "looping back..."); + path.add_event (iter_next, nullptr, 0, "looping back..."); path.connect_to_next_event (); - path.add_event (iter_test, NULL_TREE, 0, "...to here"); + path.add_event (iter_test, nullptr, 0, "...to here"); if (!path_events_have_column_data_p (path)) return; @@ -1818,10 +1719,10 @@ assert_cfg_edge_path_streq (const location &loc, const char *expected_str) { test_diagnostic_path path (event_pp); - path.add_event (src_loc, NULL_TREE, 0, "from here..."); + path.add_event (src_loc, nullptr, 0, "from here..."); path.connect_to_next_event (); - path.add_event (dst_loc, NULL_TREE, 0, "...to here"); + path.add_event (dst_loc, nullptr, 0, "...to here"); if (!path_events_have_column_data_p (path)) return; @@ -2122,27 +2023,27 @@ test_control_flow_5 (const line_table_case &case_, test_diagnostic_path path (event_pp); /* (1) */ - path.add_event (t.get_line_and_column (1, 6), NULL_TREE, 0, + path.add_event (t.get_line_and_column (1, 6), nullptr, 0, "following %qs branch (when %qs is non-NULL)...", "false", "arr"); path.connect_to_next_event (); /* (2) */ - path.add_event (t.get_line_and_columns (4, 8, 10, 12), NULL_TREE, 0, + path.add_event (t.get_line_and_columns (4, 8, 10, 12), nullptr, 0, "...to here"); /* (3) */ - path.add_event (t.get_line_and_columns (4, 15, 17, 19), NULL_TREE, 0, + path.add_event (t.get_line_and_columns (4, 15, 17, 19), nullptr, 0, "following %qs branch (when %qs)...", "true", "i < n"); path.connect_to_next_event (); /* (4) */ - path.add_event (t.get_line_and_column (5, 13), NULL_TREE, 0, + path.add_event (t.get_line_and_column (5, 13), nullptr, 0, "...to here"); /* (5) */ - path.add_event (t.get_line_and_columns (5, 33, 58), NULL_TREE, 0, + path.add_event (t.get_line_and_columns (5, 33, 58), nullptr, 0, "allocated here"); if (!path_events_have_column_data_p (path)) @@ -2210,27 +2111,27 @@ test_control_flow_6 (const line_table_case &case_, test_diagnostic_path path (event_pp); /* (1) */ - path.add_event (t.get_line_and_columns (6, 25, 35), NULL_TREE, 0, + path.add_event (t.get_line_and_columns (6, 25, 35), nullptr, 0, "allocated here"); /* (2) */ - path.add_event (t.get_line_and_columns (8, 13, 14, 17), NULL_TREE, 0, + path.add_event (t.get_line_and_columns (8, 13, 14, 17), nullptr, 0, "following %qs branch (when %qs)...", "true", "i <= 254"); path.connect_to_next_event (); /* (3) */ - path.add_event (t.get_line_and_columns (9, 5, 15, 17), NULL_TREE, 0, + path.add_event (t.get_line_and_columns (9, 5, 15, 17), nullptr, 0, "...to here"); /* (4) */ - path.add_event (t.get_line_and_columns (8, 13, 14, 17), NULL_TREE, 0, + path.add_event (t.get_line_and_columns (8, 13, 14, 17), nullptr, 0, "following %qs branch (when %qs)...", "true", "i <= 254"); path.connect_to_next_event (); /* (5) */ - path.add_event (t.get_line_and_columns (9, 5, 15, 17), NULL_TREE, 0, + path.add_event (t.get_line_and_columns (9, 5, 15, 17), nullptr, 0, "...to here"); if (!path_events_have_column_data_p (path)) @@ -2284,7 +2185,7 @@ control_flow_tests (const line_table_case &case_) { std::unique_ptr event_pp = std::unique_ptr (global_dc->printer->clone ()); - pp_show_color (event_pp) = 0; + pp_show_color (event_pp.get ()) = false; test_control_flow_1 (case_, event_pp.get ()); test_control_flow_2 (case_, event_pp.get ()); @@ -2297,7 +2198,7 @@ control_flow_tests (const line_table_case &case_) /* Run all of the selftests within this file. */ void -tree_diagnostic_path_cc_tests () +diagnostic_path_cc_tests () { /* In a few places we use the global dc's printer to determine colorization so ensure this off during the tests. */ diff --git a/gcc/diagnostic-path.h b/gcc/diagnostic-path.h index 938bd583a3da5..7497b0a7199df 100644 --- a/gcc/diagnostic-path.h +++ b/gcc/diagnostic-path.h @@ -142,8 +142,6 @@ class diagnostic_event virtual location_t get_location () const = 0; - virtual tree get_fndecl () const = 0; - /* Stack depth, so that consumers can visualize the interprocedural calls, returns, and frame nesting. */ virtual int get_stack_depth () const = 0; @@ -151,7 +149,7 @@ class diagnostic_event /* Get a localized (and possibly colorized) description of this event. */ virtual label_text get_desc (bool can_colorize) const = 0; - /* Get a logical_location for this event, or NULL. */ + /* Get a logical_location for this event, or nullptr if there is none. */ virtual const logical_location *get_logical_location () const = 0; virtual meaning get_meaning () const = 0; @@ -194,6 +192,12 @@ class diagnostic_path virtual const diagnostic_thread & get_thread (diagnostic_thread_id_t) const = 0; + /* Return true iff the two events are both within the same function, + or both outside of any function. */ + virtual bool + same_function_p (int event_idx_a, + int event_idx_b) const = 0; + bool interprocedural_p () const; bool multithreaded_p () const; @@ -201,108 +205,8 @@ class diagnostic_path bool get_first_event_in_a_function (unsigned *out_idx) const; }; -/* Concrete subclasses. */ - -/* A simple implementation of diagnostic_event. */ - -class simple_diagnostic_event : public diagnostic_event -{ - public: - simple_diagnostic_event (location_t loc, tree fndecl, int depth, - const char *desc, - diagnostic_thread_id_t thread_id = 0); - ~simple_diagnostic_event (); - - location_t get_location () const final override { return m_loc; } - tree get_fndecl () const final override { return m_fndecl; } - int get_stack_depth () const final override { return m_depth; } - label_text get_desc (bool) const final override - { - return label_text::borrow (m_desc); - } - const logical_location *get_logical_location () const final override - { - return NULL; - } - meaning get_meaning () const final override - { - return meaning (); - } - bool connect_to_next_event_p () const final override - { - return m_connected_to_next_event; - } - diagnostic_thread_id_t get_thread_id () const final override - { - return m_thread_id; - } - - void connect_to_next_event () - { - m_connected_to_next_event = true; - } - - private: - location_t m_loc; - tree m_fndecl; - int m_depth; - char *m_desc; // has been i18n-ed and formatted - bool m_connected_to_next_event; - diagnostic_thread_id_t m_thread_id; -}; - -/* A simple implementation of diagnostic_thread. */ - -class simple_diagnostic_thread : public diagnostic_thread -{ -public: - simple_diagnostic_thread (const char *name) : m_name (name) {} - label_text get_name (bool) const final override - { - return label_text::borrow (m_name); - } - -private: - const char *m_name; // has been i18n-ed and formatted -}; - -/* A simple implementation of diagnostic_path, as a vector of - simple_diagnostic_event instances. */ - -class simple_diagnostic_path : public diagnostic_path -{ - public: - simple_diagnostic_path (pretty_printer *event_pp); - - unsigned num_events () const final override; - const diagnostic_event & get_event (int idx) const final override; - unsigned num_threads () const final override; - const diagnostic_thread & - get_thread (diagnostic_thread_id_t) const final override; - - diagnostic_thread_id_t add_thread (const char *name); - - diagnostic_event_id_t add_event (location_t loc, tree fndecl, int depth, - const char *fmt, ...) - ATTRIBUTE_GCC_DIAG(5,6); - diagnostic_event_id_t - add_thread_event (diagnostic_thread_id_t thread_id, - location_t loc, tree fndecl, int depth, - const char *fmt, ...) - ATTRIBUTE_GCC_DIAG(6,7); - - void connect_to_next_event (); - - void disable_event_localization () { m_localize_events = false; } - - private: - auto_delete_vec m_threads; - auto_delete_vec m_events; - - /* (for use by add_event). */ - pretty_printer *m_event_pp; - bool m_localize_events; -}; +/* Concrete subclasses of the above can be found in + simple-diagnostic-path.h. */ extern void debug (diagnostic_path *path); diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc index 1b4def06f7262..471135f16dece 100644 --- a/gcc/diagnostic.cc +++ b/gcc/diagnostic.cc @@ -44,6 +44,7 @@ along with GCC; see the file COPYING3. If not see #include "cpplib.h" #include "text-art/theme.h" #include "pretty-print-urlifier.h" +#include "logical-location.h" #ifdef HAVE_TERMIOS_H # include @@ -342,8 +343,8 @@ diagnostic_context::urls_init (int value) value = DIAGNOSTICS_URLS_DEFAULT; } - this->printer->url_format - = determine_url_format ((diagnostic_url_rule_t) value); + this->printer->set_url_format + (determine_url_format ((diagnostic_url_rule_t) value)); } /* Create the file_cache, if not already created, and tell it how to @@ -914,8 +915,7 @@ diagnostic_context::show_any_path (const diagnostic_info &diagnostic) if (!path) return; - if (m_print_path) - m_print_path (this, path); + print_path (path); } /* class diagnostic_event. */ @@ -1028,9 +1028,9 @@ diagnostic_event::meaning::maybe_get_property_str (enum property p) /* class diagnostic_path. */ -/* Subroutint of diagnostic_path::interprocedural_p. +/* Subroutine of diagnostic_path::interprocedural_p. Look for the first event in this path that is within a function - i.e. has a non-NULL fndecl, and a non-zero stack depth. + i.e. has a non-null logical location for which function_p is true. If found, write its index to *OUT_IDX and return true. Otherwise return false. */ @@ -1040,12 +1040,13 @@ diagnostic_path::get_first_event_in_a_function (unsigned *out_idx) const const unsigned num = num_events (); for (unsigned i = 0; i < num; i++) { - if (!(get_event (i).get_fndecl () == NULL - && get_event (i).get_stack_depth () == 0)) - { - *out_idx = i; - return true; - } + const diagnostic_event &event = get_event (i); + if (const logical_location *logical_loc = event.get_logical_location ()) + if (logical_loc->function_p ()) + { + *out_idx = i; + return true; + } } return false; } @@ -1062,13 +1063,12 @@ diagnostic_path::interprocedural_p () const return false; const diagnostic_event &first_fn_event = get_event (first_fn_event_idx); - tree first_fndecl = first_fn_event.get_fndecl (); int first_fn_stack_depth = first_fn_event.get_stack_depth (); const unsigned num = num_events (); for (unsigned i = first_fn_event_idx + 1; i < num; i++) { - if (get_event (i).get_fndecl () != first_fndecl) + if (!same_function_p (first_fn_event_idx, i)) return true; if (get_event (i).get_stack_depth () != first_fn_stack_depth) return true; @@ -1076,6 +1076,32 @@ diagnostic_path::interprocedural_p () const return false; } +/* class logical_location. */ + +/* Return true iff this is a function or method. */ + +bool +logical_location::function_p () const +{ + switch (get_kind ()) + { + default: + gcc_unreachable (); + case LOGICAL_LOCATION_KIND_UNKNOWN: + case LOGICAL_LOCATION_KIND_MODULE: + case LOGICAL_LOCATION_KIND_NAMESPACE: + case LOGICAL_LOCATION_KIND_TYPE: + case LOGICAL_LOCATION_KIND_RETURN_TYPE: + case LOGICAL_LOCATION_KIND_PARAMETER: + case LOGICAL_LOCATION_KIND_VARIABLE: + return false; + + case LOGICAL_LOCATION_KIND_FUNCTION: + case LOGICAL_LOCATION_KIND_MEMBER: + return true; + } +} + void default_diagnostic_starter (diagnostic_context *context, const diagnostic_info *diagnostic) @@ -1354,7 +1380,7 @@ diagnostic_context::print_any_cwe (const diagnostic_info &diagnostic) pp_string (pp, " ["); pp_string (pp, colorize_start (pp_show_color (pp), diagnostic_kind_color[diagnostic.kind])); - if (pp->url_format != URL_FORMAT_NONE) + if (pp->supports_urls_p ()) { char *cwe_url = get_cwe_url (cwe); pp_begin_url (pp, cwe_url); @@ -1362,7 +1388,7 @@ diagnostic_context::print_any_cwe (const diagnostic_info &diagnostic) } pp_printf (pp, "CWE-%i", cwe); pp_set_prefix (pp, saved_prefix); - if (pp->url_format != URL_FORMAT_NONE) + if (pp->supports_urls_p ()) pp_end_url (pp); pp_string (pp, colorize_stop (pp_show_color (pp))); pp_character (pp, ']'); @@ -1394,7 +1420,7 @@ diagnostic_context::print_any_rules (const diagnostic_info &diagnostic) colorize_start (pp_show_color (pp), diagnostic_kind_color[diagnostic.kind])); char *url = NULL; - if (pp->url_format != URL_FORMAT_NONE) + if (pp->supports_urls_p ()) { url = rule.make_url (); if (url) @@ -1402,7 +1428,7 @@ diagnostic_context::print_any_rules (const diagnostic_info &diagnostic) } pp_string (pp, desc); pp_set_prefix (pp, saved_prefix); - if (pp->url_format != URL_FORMAT_NONE) + if (pp->supports_urls_p ()) if (url) pp_end_url (pp); free (url); @@ -1425,7 +1451,7 @@ diagnostic_context::print_option_information (const diagnostic_info &diagnostic, orig_diag_kind, diagnostic.kind)) { char *option_url = nullptr; - if (this->printer->url_format != URL_FORMAT_NONE) + if (this->printer->supports_urls_p ()) option_url = make_option_url (diagnostic.option_index); pretty_printer * const pp = this->printer; pp_string (pp, " ["); @@ -2517,155 +2543,6 @@ set_text_art_charset (enum diagnostic_text_art_charset charset) } } -/* class simple_diagnostic_path : public diagnostic_path. */ - -simple_diagnostic_path::simple_diagnostic_path (pretty_printer *event_pp) -: m_event_pp (event_pp), - m_localize_events (true) -{ - add_thread ("main"); -} - -/* Implementation of diagnostic_path::num_events vfunc for - simple_diagnostic_path: simply get the number of events in the vec. */ - -unsigned -simple_diagnostic_path::num_events () const -{ - return m_events.length (); -} - -/* Implementation of diagnostic_path::get_event vfunc for - simple_diagnostic_path: simply return the event in the vec. */ - -const diagnostic_event & -simple_diagnostic_path::get_event (int idx) const -{ - return *m_events[idx]; -} - -unsigned -simple_diagnostic_path::num_threads () const -{ - return m_threads.length (); -} - -const diagnostic_thread & -simple_diagnostic_path::get_thread (diagnostic_thread_id_t idx) const -{ - return *m_threads[idx]; -} - -diagnostic_thread_id_t -simple_diagnostic_path::add_thread (const char *name) -{ - m_threads.safe_push (new simple_diagnostic_thread (name)); - return m_threads.length () - 1; -} - -/* Add an event to this path at LOC within function FNDECL at - stack depth DEPTH. - - Use m_context's printer to format FMT, as the text of the new - event. Localize FMT iff m_localize_events is set. - - Return the id of the new event. */ - -diagnostic_event_id_t -simple_diagnostic_path::add_event (location_t loc, tree fndecl, int depth, - const char *fmt, ...) -{ - pretty_printer *pp = m_event_pp; - pp_clear_output_area (pp); - - rich_location rich_loc (line_table, UNKNOWN_LOCATION); - - va_list ap; - - va_start (ap, fmt); - - text_info ti (m_localize_events ? _(fmt) : fmt, - &ap, 0, nullptr, &rich_loc); - pp_format (pp, &ti); - pp_output_formatted_text (pp); - - va_end (ap); - - simple_diagnostic_event *new_event - = new simple_diagnostic_event (loc, fndecl, depth, pp_formatted_text (pp)); - m_events.safe_push (new_event); - - pp_clear_output_area (pp); - - return diagnostic_event_id_t (m_events.length () - 1); -} - -diagnostic_event_id_t -simple_diagnostic_path::add_thread_event (diagnostic_thread_id_t thread_id, - location_t loc, - tree fndecl, - int depth, - const char *fmt, ...) -{ - pretty_printer *pp = m_event_pp; - pp_clear_output_area (pp); - - rich_location rich_loc (line_table, UNKNOWN_LOCATION); - - va_list ap; - - va_start (ap, fmt); - - text_info ti (_(fmt), &ap, 0, nullptr, &rich_loc); - - pp_format (pp, &ti); - pp_output_formatted_text (pp); - - va_end (ap); - - simple_diagnostic_event *new_event - = new simple_diagnostic_event (loc, fndecl, depth, pp_formatted_text (pp), - thread_id); - m_events.safe_push (new_event); - - pp_clear_output_area (pp); - - return diagnostic_event_id_t (m_events.length () - 1); -} - -/* Mark the most recent event on this path (which must exist) as being - connected to the next one to be added. */ - -void -simple_diagnostic_path::connect_to_next_event () -{ - gcc_assert (m_events.length () > 0); - m_events[m_events.length () - 1]->connect_to_next_event (); -} - -/* struct simple_diagnostic_event. */ - -/* simple_diagnostic_event's ctor. */ - -simple_diagnostic_event:: -simple_diagnostic_event (location_t loc, - tree fndecl, - int depth, - const char *desc, - diagnostic_thread_id_t thread_id) -: m_loc (loc), m_fndecl (fndecl), m_depth (depth), m_desc (xstrdup (desc)), - m_connected_to_next_event (false), - m_thread_id (thread_id) -{ -} - -/* simple_diagnostic_event's dtor. */ - -simple_diagnostic_event::~simple_diagnostic_event () -{ - free (m_desc); -} - /* Print PATH by emitting a dummy "note" associated with it. */ DEBUG_FUNCTION diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h index 4632aac73c6b5..c6846525da312 100644 --- a/gcc/diagnostic.h +++ b/gcc/diagnostic.h @@ -583,6 +583,8 @@ class diagnostic_context pretty_printer *pp, diagnostic_source_effect_info *effect_info); + void print_path (const diagnostic_path *path); + /* Data members. Ideally, all of these would be private and have "m_" prefixes. */ @@ -712,10 +714,6 @@ class diagnostic_context urlifier *m_urlifier; public: - void (*m_print_path) (diagnostic_context *, const diagnostic_path *); - json::value *(*m_make_json_for_path) (diagnostic_context *, - const diagnostic_path *); - /* Auxiliary data for client. */ void *m_client_aux_data; @@ -842,10 +840,10 @@ diagnostic_finalizer (diagnostic_context *context) #define diagnostic_info_auxiliary_data(DI) (DI)->x_data /* Same as pp_format_decoder. Works on 'diagnostic_context *'. */ -#define diagnostic_format_decoder(DC) ((DC)->printer->format_decoder) +#define diagnostic_format_decoder(DC) pp_format_decoder ((DC)->printer) -/* Same as output_prefixing_rule. Works on 'diagnostic_context *'. */ -#define diagnostic_prefixing_rule(DC) ((DC)->printer->wrapping.rule) +/* Same as pp_prefixing_rule. Works on 'diagnostic_context *'. */ +#define diagnostic_prefixing_rule(DC) pp_prefixing_rule ((DC)->printer) /* Raise SIGABRT on any diagnostic of severity DK_ERROR or higher. */ inline void diff --git a/gcc/digraph.cc b/gcc/digraph.cc index 64497f8d92918..b323764a93cde 100644 --- a/gcc/digraph.cc +++ b/gcc/digraph.cc @@ -108,7 +108,7 @@ test_dump_to_dot () g.add_test_edge (a, b); pretty_printer pp; - pp.buffer->stream = NULL; + pp.set_output_stream (nullptr); test_dump_args_t dump_args; g.dump_dot_to_pp (&pp, NULL, dump_args); diff --git a/gcc/digraph.h b/gcc/digraph.h index 33a5055cd9cdd..4894d3987ccfe 100644 --- a/gcc/digraph.h +++ b/gcc/digraph.h @@ -201,7 +201,7 @@ digraph::dump_dot_to_file (FILE *fp, pretty_printer pp; // TODO: pp_format_decoder (&pp) = default_tree_printer; - pp.buffer->stream = fp; + pp.set_output_stream (fp); dump_dot_to_pp (&pp, root_cluster, args); pp_flush (&pp); } diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi index 3f38ca37feaf0..a99c8dfdbe33a 100644 --- a/gcc/doc/cpp.texi +++ b/gcc/doc/cpp.texi @@ -1887,7 +1887,9 @@ signifies the 2011 revision of the C standard; the value @code{201710L} signifies the 2017 revision of the C standard (which is otherwise identical to the 2011 version apart from correction of defects). The value @code{202311L} is used for the experimental -@option{-std=c23} and @option{-std=gnu23} modes. +@option{-std=c23} and @option{-std=gnu23} modes. An unspecified value +larger than @code{202311L} is used for the experimental +@option{-std=c2y} and @option{-std=gnu2y} modes. This macro is not defined if the @option{-traditional-cpp} option is used, nor when compiling C++ or Objective-C@. diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 799a36586dc9a..173cdef013160 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -4627,14 +4627,14 @@ the same behavior as that of the command-line option Indicates that the workaround for the Cortex-A53 erratum 835769 should be applied to this function. To explicitly disable the workaround for this function specify the negated form: @code{no-fix-cortex-a53-835769}. -This corresponds to the behavior of the command line options +This corresponds to the behavior of the command-line options @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}. @cindex @code{cmodel=} function attribute, AArch64 @item cmodel= Indicates that code should be generated for a particular code model for this function. The behavior and permissible arguments are the same as -for the command line option @option{-mcmodel=}. +for the command-line option @option{-mcmodel=}. @cindex @code{strict-align} function attribute, AArch64 @item strict-align @@ -4694,7 +4694,7 @@ behavior and permissible arguments are the same as for the command-line option @cindex @code{outline-atomics} function attribute, AArch64 @item outline-atomics Enable or disable calls to out-of-line helpers to implement atomic operations. -This corresponds to the behavior of the command line options +This corresponds to the behavior of the command-line options @option{-moutline-atomics} and @option{-mno-outline-atomics}. @end table @@ -8456,7 +8456,7 @@ volatile int porta __attribute__((address (0x600))); This attribute can also be used to define symbols in C/C++ code which otherwise would require assembly, a linker description file -or command line options like @code{-Wl,--defsym,a_symbol=@var{value}}. +or command-line options like @code{-Wl,--defsym,a_symbol=@var{value}}. For example, @smallexample int a_symbol __attribute__((weak, address (1234))); @@ -9473,7 +9473,7 @@ bat (void) @end example @cindex strub eligibility and viability -Some @option{-fstrub=*} command line options enable @code{strub} modes +Some @option{-fstrub=*} command-line options enable @code{strub} modes implicitly where viable. A @code{strub} mode is only viable for a function if the function is eligible for that mode, and if other conditions, detailed below, are satisfied. If it's not eligible for a @@ -10700,14 +10700,31 @@ contain any instructions recognized by the assembler, including directives. GCC does not parse the assembler instructions themselves and does not know what they mean or even whether they are valid assembler input. -You may place multiple assembler instructions together in a single @code{asm} -string, separated by the characters normally used in assembly code for the -system. A combination that works in most places is a newline to break the +You may place multiple assembler instructions together in a single @code{asm} +string, separated by the characters normally used in assembly code for the +system. A combination that works in most places is a newline to break the line, plus a tab character (written as @samp{\n\t}). -Some assemblers allow semicolons as a line separator. However, -note that some assembler dialects use semicolons to start a comment. +Some assemblers allow semicolons as a line separator. However, +note that some assembler dialects use semicolons to start a comment. @end table +@node asm constexprs +With gnu++11 or later the string can also be a compile time constant expression +inside parens. The constant expression can return a string or a container +with data and size members, following similar rules as C++26 @code{static_assert} +message. Any string is converted to the character set of the source code. +When this feature is available the @code{__GXX_CONSTEXPR_ASM__} cpp symbol is defined. + +@example +#include +constexpr std::string_view genfoo() @{ return "foo"; @} + +void function() +@{ + asm((genfoo())); +@} +@end example + @subsubheading Remarks Using extended @code{asm} (@pxref{Extended Asm}) typically produces smaller, safer, and more efficient code, and in most cases it is a @@ -10850,20 +10867,27 @@ perform a jump to one of the labels listed in the @var{GotoLabels}. @item AssemblerTemplate This is a literal string that is the template for the assembler code. It is a combination of fixed text and tokens that refer to the input, output, -and goto parameters. @xref{AssemblerTemplate}. +and goto parameters. @xref{AssemblerTemplate}. With gnu++11 or later it can +also be a constant expression inside parens (see @ref{asm constexprs}). @item OutputOperands A comma-separated list of the C variables modified by the instructions in the @var{AssemblerTemplate}. An empty list is permitted. @xref{OutputOperands}. +With gnu++11 or later the strings can also be constant expressions inside parens +(see @ref{asm constexprs}) @item InputOperands A comma-separated list of C expressions read by the instructions in the @var{AssemblerTemplate}. An empty list is permitted. @xref{InputOperands}. +With gnu++11 or later the strings can also be constant expressions inside parens +(see @ref{asm constexprs}) @item Clobbers A comma-separated list of registers or other values changed by the @var{AssemblerTemplate}, beyond those listed as outputs. An empty list is permitted. @xref{Clobbers and Scratch Registers}. +With gnu++11 or later the strings can also be constant expressions inside parens +(see @ref{asm constexprs}) @item GotoLabels When you are using the @code{goto} form of @code{asm}, this section contains diff --git a/gcc/doc/gm2.texi b/gcc/doc/gm2.texi index 8661fcb87281d..c532339fbb840 100644 --- a/gcc/doc/gm2.texi +++ b/gcc/doc/gm2.texi @@ -2935,9 +2935,9 @@ you wish to see something different please email @node Documentation, Regression tests, Release map, Using @section Documentation -The GNU Modula-2 documentation is available on line -@url{https://gcc.gnu.org/onlinedocs} -or in the pdf, info, html file format. +The GNU Modula-2 documentation is available online at +@url{https://gcc.gnu.org/onlinedocs/} +in the PDF, info, and HTML file formats. @node Regression tests, Limitations, Documentation, Using @section Regression tests for gm2 in the repository diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi index 906c78aaca554..1774a010889aa 100644 --- a/gcc/doc/install.texi +++ b/gcc/doc/install.texi @@ -224,13 +224,11 @@ described below. @table @asis @item ISO C++11 compiler Necessary to bootstrap GCC. GCC 4.8.3 or newer has sufficient -support for used C++11 features, with earlier GCC versions you -might run into implementation bugs. +support for used C++11 features. Versions of GCC prior to 11 also allow bootstrapping with an ISO C++98 -compiler, versions of GCC prior to 4.8 also allow bootstrapping with a -ISO C89 compiler, and versions of GCC prior to 3.4 also allow -bootstrapping with a traditional (K&R) C compiler. +compiler, and versions of GCC prior to 4.8 also allow bootstrapping with +an ISO C89 compiler. To build all languages in a cross-compiler or other configuration where 3-stage bootstrap is not performed, you need to start with an existing @@ -1781,12 +1779,12 @@ Produce code conforming to version 20191213. In the absence of this configuration option the default version is 20191213. @item --enable-__cxa_atexit -Define if you want to use __cxa_atexit, rather than atexit, to +Define if you want to use @code{__cxa_atexit}, rather than atexit, to register C++ destructors for local statics and global objects. This is essential for fully standards-compliant handling of -destructors, but requires __cxa_atexit in libc. This option is currently -only available on systems with GNU libc. When enabled, this will cause -@option{-fuse-cxa-atexit} to be passed by default. +destructors, but requires @code{__cxa_atexit} in libc. This option is +currently only available on systems with GNU libc. When enabled, this +will cause @option{-fuse-cxa-atexit} to be passed by default. @item --enable-gnu-indirect-function Define if you want to enable the @code{ifunc} attribute. This option is @@ -4016,8 +4014,6 @@ can also be obtained from: @itemize @bullet @item @uref{http://www.nongnu.org/avr/,,http://www.nongnu.org/avr/} -@item -@uref{http://www.amelek.gda.pl/avr/,,http://www.amelek.gda.pl/avr/} @end itemize The following error: @@ -4268,9 +4264,6 @@ supported, so @option{--enable-threads=dce} does not work. @end html @anchor{x-x-linux-gnu} @heading *-*-linux-gnu -The @code{.init_array} and @code{.fini_array} sections are enabled -unconditionally which requires at least glibc 2.1 and binutils 2.12. - Versions of libstdc++-v3 starting with 3.2.1 require bug fixes present in glibc 2.2.5 and later. More information is available in the libstdc++-v3 documentation. @@ -5106,8 +5099,6 @@ both 64-bit x86-64 and 32-bit x86 code (via the @option{-m32} switch). @end html @anchor{x86-64-x-solaris2} @heading x86_64-*-solaris2* -GCC also supports the x86-64 architecture implemented by the AMD64 -processor (@samp{amd64-*-*} is an alias for @samp{x86_64-*-*}). Unlike other systems, without special options a bi-arch compiler is built which generates 32-bit code by default, but can generate 64-bit x86-64 code with the @option{-m64} switch. Since @@ -5187,8 +5178,7 @@ SuperH (sh-wince-pe), and MIPS (mips-wince-pe). @subheading Other Windows Platforms GCC no longer supports Windows NT on the Alpha or PowerPC. -GCC no longer supports the Windows POSIX subsystem. However, it does -support the Interix subsystem. See above. +GCC no longer supports the Windows POSIX subsystem. Old target names including *-*-winnt and *-*-windowsnt are no longer used. @@ -5200,7 +5190,7 @@ UWIN support has been removed due to a lack of maintenance. @anchor{x-x-cygwin} @heading *-*-cygwin Ports of GCC are included with the -@uref{http://www.cygwin.com/,,Cygwin environment}. +@uref{https://cygwin.com,,Cygwin environment}. GCC will build under Cygwin without modification; it does not build with Microsoft's C++ compiler and there are no plans to make it do so. @@ -5261,10 +5251,6 @@ version before they were removed), patches likely to be accepted, since they should not affect the support for more modern targets. -For some systems, old versions of GNU binutils may also be useful, -and are available from @file{pub/binutils/old-releases} on -@uref{https://sourceware.org/mirrors.html,,sourceware.org mirror sites}. - Some of the information on specific systems above relates to such older systems, but much of the information about GCC on such systems (which may no longer be applicable to diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index e5a5d1d9335b4..5d7a87fde86c4 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -340,7 +340,7 @@ Objective-C and Objective-C++ Dialects}. -Wbool-compare -Wbool-operation -Wno-builtin-declaration-mismatch -Wno-builtin-macro-redefined -Wc90-c99-compat -Wc99-c11-compat --Wc11-c23-compat +-Wc11-c23-compat -Wc23-c2y-compat -Wc++-compat -Wc++11-compat -Wc++14-compat -Wc++17-compat -Wc++20-compat -Wno-c++11-extensions -Wno-c++14-extensions -Wno-c++17-extensions @@ -496,6 +496,7 @@ Objective-C and Objective-C++ Dialects}. -Wno-analyzer-tainted-size -Wanalyzer-symbol-too-complex -Wanalyzer-too-complex +-Wno-analyzer-undefined-behavior-ptrdiff -Wno-analyzer-undefined-behavior-strtok -Wno-analyzer-unsafe-call-within-signal-handler -Wno-analyzer-use-after-free @@ -2471,6 +2472,10 @@ ISO C23, the 2023 revision of the ISO C standard (expected to be published in 2024). The support for this version is experimental and incomplete. The name @samp{c2x} is deprecated. +@item c2y +The next version of the ISO C standard, still under development. The +support for this version is experimental and incomplete. + @item gnu90 @itemx gnu89 GNU dialect of ISO C90 (including some C99 features). @@ -2490,6 +2495,10 @@ GNU dialect of ISO C17. This is the default for C code. @item gnu23 @itemx gnu2x +GNU dialect of ISO C23. The support for this version is experimental +and incomplete. The name @samp{gnu2x} is deprecated. + +@item gnu2y The next version of the ISO C standard, still under development, plus GNU extensions. The support for this version is experimental and incomplete. The name @samp{gnu2x} is deprecated. @@ -9325,6 +9334,19 @@ deprecated. When not compiling in C23 mode, these warnings are upgraded to errors by @option{-pedantic-errors}. +@opindex Wc23-c2y-compat +@opindex Wno-c23-c2y-compat +@item -Wc23-c2y-compat @r{(C and Objective-C only)} +@itemx -Wc23-c2y-compat @r{(C and Objective-C only)} +Warn about features not present in ISO C23, but present in ISO C2Y. +For instance, warn about @code{_Generic} selecting with a type name +instead of an expression. This option is independent of the standards +mode. Warnings are disabled in the expression that follows +@code{__extension__}. + +When not compiling in C2Y mode, these warnings are upgraded to errors +by @option{-pedantic-errors}. + @opindex Wc++-compat @opindex Wno-c++-compat @item -Wc++-compat @r{(C and Objective-C only)} @@ -10766,6 +10788,7 @@ Enabling this option effectively enables the following warnings: -Wanalyzer-tainted-divisor -Wanalyzer-tainted-offset -Wanalyzer-tainted-size +-Wanalyzer-undefined-behavior-ptrdiff -Wanalyzer-undefined-behavior-strtok -Wanalyzer-unsafe-call-within-signal-handler -Wanalyzer-use-after-free @@ -11416,6 +11439,20 @@ attacker could inject an out-of-bounds access. See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}. +@opindex Wanalyzer-undefined-behavior-ptrdiff +@opindex Wno-analyzer-undefined-behavior-ptrdiff +@item -Wno-analyzer-undefined-behavior-ptrdiff +This warning requires @option{-fanalyzer}, which enables it; use +@option{-Wno-analyzer-undefined-behavior-ptrdiff} to disable it. + +This diagnostic warns for paths through the code in which a pointer +subtraction occurs where the pointers refer to different chunks of +memory. Such code relies on undefined behavior, as pointer subtraction +is only defined for cases where both pointers point to within (or just +after) the same array. + +See @uref{https://cwe.mitre.org/data/definitions/469.html, CWE-469: Use of Pointer Subtraction to Determine Size}. + @opindex Wanalyzer-undefined-behavior-strtok @opindex Wno-analyzer-undefined-behavior-strtok @item -Wno-analyzer-undefined-behavior-strtok @@ -34439,18 +34476,18 @@ SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND and F16C instruction set support. @item haswell -Intel Haswell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, +Intel Haswell CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE and HLE instruction set support. @item broadwell -Intel Broadwell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, +Intel Broadwell CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX and PREFETCHW instruction set support. @item skylake -Intel Skylake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, +Intel Skylake CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES and SGX instruction set support. @@ -34511,14 +34548,14 @@ ENQCMD, UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512, SM3, SM4, USER_MSR and PREFETCHI instruction set support. @item skylake-avx512 -Intel Skylake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, +Intel Skylake Server CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ and AVX512CD instruction set support. @item cannonlake -Intel Cannonlake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, +Intel Cannonlake Server CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, @@ -34526,7 +34563,7 @@ AVX512DQ, AVX512CD, PKU, AVX512VBMI, AVX512IFMA and SHA instruction set support. @item icelake-client -Intel Icelake Client CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, +Intel Icelake Client CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, @@ -34534,7 +34571,7 @@ AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2 , VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support. @item icelake-server -Intel Icelake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, +Intel Icelake Server CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, @@ -34543,21 +34580,21 @@ AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2 instruction set support. @item cascadelake -Intel Cascadelake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, +Intel Cascadelake CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ, AVX512CD and AVX512VNNI instruction set support. @item cooperlake -Intel cooperlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, +Intel cooperlake CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ, AVX512CD, AVX512VNNI and AVX512BF16 instruction set support. @item tigerlake -Intel Tigerlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, +Intel Tigerlake CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD @@ -34566,7 +34603,7 @@ VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, MOVDIRI, MOVDIR64B, CLWB, AVX512VP2INTERSECT and KEYLOCKER instruction set support. @item sapphirerapids -Intel sapphirerapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, +Intel sapphirerapids CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, @@ -34585,7 +34622,7 @@ VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL and AVX-VNNI instruction set support. @item rocketlake -Intel Rocketlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3 +Intel Rocketlake CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3 , SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD @@ -34593,7 +34630,7 @@ PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support. @item graniterapids -Intel graniterapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, +Intel graniterapids CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, @@ -34604,7 +34641,7 @@ UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16, AVX512BF16, AMX-FP16 and PREFETCHI instruction set support. @item graniterapids-d -Intel graniterapids D CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, +Intel graniterapids D CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, @@ -37764,6 +37801,23 @@ installed. Specifying the language as one of these variants also inhibits output of the object file, as header files have no associated object file. +Header units can be used in much the same way as precompiled headers +(@pxref{Precompiled Headers}), but with fewer restrictions: an +#include that is translated to a header unit import can appear at any +point in the source file, and multiple header units can be used +together. In particular, the @option{-include} strategy works: with +the bits/stdc++.h header used for libstdc++ precompiled headers you +can + +@smallexample +g++ -fmodules-ts -x c++-system-header -c bits/stdc++.h +g++ -fmodules-ts -include bits/stdc++.h mycode.C +@end smallexample + +and any standard library #includes in mycode.C will be skipped, +because the import brought in the whole library. This can be a simple +way to use modules to speed up compilation without any code changes. + The @option{-fmodule-only} option disables generation of the associated object file for compiling a module interface. Only the CMI is generated. This option is implied when using the diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index e997dbec3334b..e37fb85f3b316 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -2513,8 +2513,17 @@ Test system has an integer register width of 32 bits. @item rv64 Test system has an integer register width of 64 bits. -@item cv_bi -Test system has support for the CORE-V BI extension. +@item riscv_a +Test target architecture has support for the A extension. + +@item riscv_zaamo +Test target architecture has support for the zaamo extension. + +@item riscv_zlrsc +Test target architecture has support for the zalrsc extension. + +@item riscv_ztso +Test target architecture has support for the ztso extension. @end table @@ -2534,6 +2543,9 @@ Test system has support for the CORE-V ELW extension. @item cv_simd Test system has support for the CORE-V SIMD extension. +@item cv_bi +Test system has support for the CORE-V BI extension. + @end table @subsubsection Other hardware attributes diff --git a/gcc/doc/standards.texi b/gcc/doc/standards.texi index 586835b28f31c..484fbb10352de 100644 --- a/gcc/doc/standards.texi +++ b/gcc/doc/standards.texi @@ -42,6 +42,8 @@ with some exceptions, and possibly with some extensions. @cindex C23 @cindex ISO C2X @cindex C2X +@cindex ISO C2Y +@cindex C2Y @cindex Technical Corrigenda @cindex TC1 @cindex Technical Corrigendum 1 @@ -113,12 +115,16 @@ known as @dfn{C17} and is supported with @option{-std=c17} or @option{-std=c11}, and the only difference between the options is the value of @code{__STDC_VERSION__}. -A further version of the C standard, known as @dfn{C23}, is under +A fifth version of the C standard, known as @dfn{C23}, is under development and expected to be published in 2024 as ISO/IEC 9899:2024. (While in development, drafts of this standard version were referred to as @dfn{C2X}.) Experimental and incomplete support for this is enabled with @option{-std=c23} or @option{-std=iso9899:2024}. +A further version of the C standard, known as @dfn{C2Y}, is under +development; experimental and incomplete support for this is enabled +with @option{-std=c2y}. + By default, GCC provides some extensions to the C language that, on rare occasions conflict with the C standard. @xref{C Extensions,,Extensions to the C Language Family}. diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 8a7aa70d605ba..be5543b72f85f 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -12354,6 +12354,13 @@ This function prepares to emit a conditional comparison within a sequence @var{bit_code} is @code{AND} or @code{IOR}, which is the op on the compares. @end deftypefn +@deftypefn {Target Hook} bool TARGET_HAVE_CCMP (void) +This target hook returns true if the target supports conditional compare. +This target hook is required only when the ccmp support is conditionally +enabled, such as in response to command-line flags. The default implementation +returns true iff @code{TARGET_GEN_CCMP_FIRST} is defined. +@end deftypefn + @deftypefn {Target Hook} unsigned TARGET_LOOP_UNROLL_ADJUST (unsigned @var{nunroll}, class loop *@var{loop}) This target hook returns a new value for the number of times @var{loop} should be unrolled. The parameter @var{nunroll} is the number of times diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 9e0830758aeea..87a7f8951741a 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -7923,6 +7923,8 @@ lists. @hook TARGET_GEN_CCMP_NEXT +@hook TARGET_HAVE_CCMP + @hook TARGET_LOOP_UNROLL_ADJUST @defmac POWI_MAX_MULTS diff --git a/gcc/dumpfile.cc b/gcc/dumpfile.cc index 1ec44cb58fb77..82bd8b06bebf6 100644 --- a/gcc/dumpfile.cc +++ b/gcc/dumpfile.cc @@ -819,8 +819,8 @@ void dump_pretty_printer::emit_items (optinfo *dest) { output_buffer *buffer = pp_buffer (this); - struct chunk_info *chunk_array = buffer->cur_chunk_array; - const char **args = chunk_array->args; + chunk_info *chunk_array = buffer->cur_chunk_array; + const char * const *args = chunk_array->get_args (); gcc_assert (buffer->obstack == &buffer->formatted_obstack); gcc_assert (buffer->line_length == 0); @@ -847,10 +847,7 @@ dump_pretty_printer::emit_items (optinfo *dest) /* Ensure that we consumed all of stashed_items. */ gcc_assert (stashed_item_idx == m_stashed_items.length ()); - /* Deallocate the chunk structure and everything after it (i.e. the - associated series of formatted strings). */ - buffer->cur_chunk_array = chunk_array->prev; - obstack_free (&buffer->chunk_obstack, chunk_array); + chunk_array->pop_from_output_buffer (*buffer); } /* Subroutine of dump_pretty_printer::emit_items @@ -860,6 +857,7 @@ dump_pretty_printer::emit_items (optinfo *dest) void dump_pretty_printer::emit_any_pending_textual_chunks (optinfo *dest) { + output_buffer *const buffer = pp_buffer (this); gcc_assert (buffer->obstack == &buffer->formatted_obstack); /* Don't emit an item if the pending text is empty. */ diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc index f90f7b1cfef27..18256843a4c51 100644 --- a/gcc/dwarf2out.cc +++ b/gcc/dwarf2out.cc @@ -25281,6 +25281,8 @@ highest_c_language (const char *lang1, const char *lang2) if (strcmp ("GNU C++98", lang1) == 0 || strcmp ("GNU C++98", lang2) == 0) return "GNU C++98"; + if (strcmp ("GNU C2Y", lang1) == 0 || strcmp ("GNU C2Y", lang2) == 0) + return "GNU C2Y"; if (strcmp ("GNU C23", lang1) == 0 || strcmp ("GNU C23", lang2) == 0) return "GNU C23"; if (strcmp ("GNU C17", lang1) == 0 || strcmp ("GNU C17", lang2) == 0) @@ -25363,7 +25365,8 @@ gen_compile_unit_die (const char *filename) if (dwarf_version >= 5 /* || !dwarf_strict */) if (strcmp (language_string, "GNU C11") == 0 || strcmp (language_string, "GNU C17") == 0 - || strcmp (language_string, "GNU C23") == 0) + || strcmp (language_string, "GNU C23") == 0 + || strcmp (language_string, "GNU C2Y") == 0) language = DW_LANG_C11; } } diff --git a/gcc/explow.cc b/gcc/explow.cc index 8e5f6b8e68044..b4a0df89bc366 100644 --- a/gcc/explow.cc +++ b/gcc/explow.cc @@ -745,6 +745,53 @@ force_reg (machine_mode mode, rtx x) return temp; } +/* Like simplify_gen_subreg, but force OP into a new register if the + subreg cannot be formed directly. */ + +rtx +force_subreg (machine_mode outermode, rtx op, + machine_mode innermode, poly_uint64 byte) +{ + rtx x = simplify_gen_subreg (outermode, op, innermode, byte); + if (x) + return x; + + auto *start = get_last_insn (); + op = copy_to_mode_reg (innermode, op); + rtx res = simplify_gen_subreg (outermode, op, innermode, byte); + if (!res) + delete_insns_since (start); + return res; +} + +/* Try to return an rvalue expression for the OUTERMODE lowpart of OP, + which has mode INNERMODE. Allow OP to be forced into a new register + if necessary. + + Return null on failure. */ + +rtx +force_lowpart_subreg (machine_mode outermode, rtx op, + machine_mode innermode) +{ + auto byte = subreg_lowpart_offset (outermode, innermode); + return force_subreg (outermode, op, innermode, byte); +} + +/* Try to return an rvalue expression for the OUTERMODE highpart of OP, + which has mode INNERMODE. Allow OP to be forced into a new register + if necessary. + + Return null on failure. */ + +rtx +force_highpart_subreg (machine_mode outermode, rtx op, + machine_mode innermode) +{ + auto byte = subreg_highpart_offset (outermode, innermode); + return force_subreg (outermode, op, innermode, byte); +} + /* If X is a memory ref, copy its contents to a new temp reg and return that reg. Otherwise, return X. */ diff --git a/gcc/explow.h b/gcc/explow.h index 16aa02cfb689e..de89e9e2933ed 100644 --- a/gcc/explow.h +++ b/gcc/explow.h @@ -42,6 +42,10 @@ extern rtx copy_to_suggested_reg (rtx, rtx, machine_mode); Args are mode (in case value is a constant) and the value. */ extern rtx force_reg (machine_mode, rtx); +extern rtx force_subreg (machine_mode, rtx, machine_mode, poly_uint64); +extern rtx force_lowpart_subreg (machine_mode, rtx, machine_mode); +extern rtx force_highpart_subreg (machine_mode, rtx, machine_mode); + /* Return given rtx, copied into a new temp reg if it was in memory. */ extern rtx force_not_mem (rtx); diff --git a/gcc/expmed.cc b/gcc/expmed.cc index 50d22762cae03..3b9475f5aa0be 100644 --- a/gcc/expmed.cc +++ b/gcc/expmed.cc @@ -695,13 +695,7 @@ store_bit_field_using_insv (const extraction_insn *insv, rtx op0, if we must narrow it, be sure we do it correctly. */ if (GET_MODE_SIZE (value_mode) < GET_MODE_SIZE (op_mode)) - { - tmp = simplify_subreg (op_mode, value1, value_mode, 0); - if (! tmp) - tmp = simplify_gen_subreg (op_mode, - force_reg (value_mode, value1), - value_mode, 0); - } + tmp = force_subreg (op_mode, value1, value_mode, 0); else { if (targetm.mode_rep_extended (op_mode, value_mode) != UNKNOWN) @@ -806,7 +800,7 @@ store_bit_field_1 (rtx str_rtx, poly_uint64 bitsize, poly_uint64 bitnum, if (known_eq (bitnum, 0U) && known_eq (bitsize, GET_MODE_BITSIZE (GET_MODE (op0)))) { - sub = simplify_gen_subreg (GET_MODE (op0), value, fieldmode, 0); + sub = force_subreg (GET_MODE (op0), value, fieldmode, 0); if (sub) { if (reverse) @@ -1633,7 +1627,7 @@ extract_bit_field_as_subreg (machine_mode mode, rtx op0, && known_eq (bitsize, GET_MODE_BITSIZE (mode)) && lowpart_bit_field_p (bitnum, bitsize, op0_mode) && TRULY_NOOP_TRUNCATION_MODES_P (mode, op0_mode)) - return simplify_gen_subreg (mode, op0, op0_mode, bytenum); + return force_subreg (mode, op0, op0_mode, bytenum); return NULL_RTX; } @@ -2000,11 +1994,11 @@ extract_integral_bit_field (rtx op0, opt_scalar_int_mode op0_mode, return convert_extracted_bit_field (target, mode, tmode, unsignedp); } /* If OP0 is a hard register, copy it to a pseudo before calling - simplify_gen_subreg. */ + force_subreg. */ if (REG_P (op0) && HARD_REGISTER_P (op0)) op0 = copy_to_reg (op0); - op0 = simplify_gen_subreg (word_mode, op0, op0_mode.require (), - bitnum / BITS_PER_WORD * UNITS_PER_WORD); + op0 = force_subreg (word_mode, op0, op0_mode.require (), + bitnum / BITS_PER_WORD * UNITS_PER_WORD); op0_mode = word_mode; bitnum %= BITS_PER_WORD; } @@ -2616,10 +2610,11 @@ expand_shift_1 (enum tree_code code, machine_mode mode, rtx shifted, else if (methods == OPTAB_LIB_WIDEN) { /* If we have been unable to open-code this by a rotation, - do it as the IOR of two shifts. I.e., to rotate A - by N bits, compute + do it as the IOR or PLUS of two shifts. I.e., to rotate + A by N bits, compute (A << N) | ((unsigned) A >> ((-N) & (C - 1))) - where C is the bitsize of A. + where C is the bitsize of A. If N cannot be zero, + use PLUS instead of IOR. It is theoretically possible that the target machine might not be able to perform either shift and hence we would @@ -2656,8 +2651,9 @@ expand_shift_1 (enum tree_code code, machine_mode mode, rtx shifted, temp1 = expand_shift_1 (left ? RSHIFT_EXPR : LSHIFT_EXPR, mode, shifted, other_amount, subtarget, 1); - return expand_binop (mode, ior_optab, temp, temp1, target, - unsignedp, methods); + return expand_binop (mode, + CONST_INT_P (op1) ? add_optab : ior_optab, + temp, temp1, target, unsignedp, methods); } temp = expand_binop (mode, @@ -5772,8 +5768,8 @@ emit_store_flag_1 (rtx target, enum rtx_code code, rtx op0, rtx op1, /* Do a logical OR or AND of the two words and compare the result. */ - op00 = simplify_gen_subreg (word_mode, op0, int_mode, 0); - op01 = simplify_gen_subreg (word_mode, op0, int_mode, UNITS_PER_WORD); + op00 = force_subreg (word_mode, op0, int_mode, 0); + op01 = force_subreg (word_mode, op0, int_mode, UNITS_PER_WORD); tem = expand_binop (word_mode, op1 == const0_rtx ? ior_optab : and_optab, op00, op01, NULL_RTX, unsignedp, @@ -5788,9 +5784,7 @@ emit_store_flag_1 (rtx target, enum rtx_code code, rtx op0, rtx op1, rtx op0h; /* If testing the sign bit, can just test on high word. */ - op0h = simplify_gen_subreg (word_mode, op0, int_mode, - subreg_highpart_offset (word_mode, - int_mode)); + op0h = force_highpart_subreg (word_mode, op0, int_mode); tem = emit_store_flag (NULL_RTX, code, op0h, op1, word_mode, unsignedp, normalizep); } diff --git a/gcc/expr.cc b/gcc/expr.cc index 1baa39b98eba3..ffbac51369230 100644 --- a/gcc/expr.cc +++ b/gcc/expr.cc @@ -94,7 +94,7 @@ static unsigned HOST_WIDE_INT highest_pow2_factor_for_target (const_tree, const_ static bool is_aligning_offset (const_tree, const_tree); static rtx reduce_to_bit_field_precision (rtx, rtx, tree); -static rtx do_store_flag (sepops, rtx, machine_mode); +static rtx do_store_flag (const_sepops, rtx, machine_mode); #ifdef PUSH_ROUNDING static void emit_single_push_insn (machine_mode, rtx, tree); #endif @@ -301,7 +301,7 @@ convert_move (rtx to, rtx from, int unsignedp) GET_MODE_BITSIZE (to_mode))); if (VECTOR_MODE_P (to_mode)) - from = simplify_gen_subreg (to_mode, from, GET_MODE (from), 0); + from = force_subreg (to_mode, from, GET_MODE (from), 0); else to = simplify_gen_subreg (from_mode, to, GET_MODE (to), 0); @@ -423,7 +423,8 @@ convert_mode_scalar (rtx to, rtx from, int unsignedp) 0).exists (&toi_mode)) { start_sequence (); - rtx fromi = lowpart_subreg (fromi_mode, from, from_mode); + rtx fromi = force_lowpart_subreg (fromi_mode, from, + from_mode); rtx tof = NULL_RTX; if (fromi) { @@ -443,7 +444,7 @@ convert_mode_scalar (rtx to, rtx from, int unsignedp) NULL_RTX, 1); if (toi) { - tof = lowpart_subreg (to_mode, toi, toi_mode); + tof = force_lowpart_subreg (to_mode, toi, toi_mode); if (tof) emit_move_insn (to, tof); } @@ -475,7 +476,7 @@ convert_mode_scalar (rtx to, rtx from, int unsignedp) 0).exists (&toi_mode)) { start_sequence (); - rtx fromi = lowpart_subreg (fromi_mode, from, from_mode); + rtx fromi = force_lowpart_subreg (fromi_mode, from, from_mode); rtx tof = NULL_RTX; do { @@ -510,11 +511,11 @@ convert_mode_scalar (rtx to, rtx from, int unsignedp) temp4, shift, NULL_RTX, 1); if (!temp5) break; - rtx temp6 = lowpart_subreg (toi_mode, temp5, fromi_mode); + rtx temp6 = force_lowpart_subreg (toi_mode, temp5, + fromi_mode); if (!temp6) break; - tof = lowpart_subreg (to_mode, force_reg (toi_mode, temp6), - toi_mode); + tof = force_lowpart_subreg (to_mode, temp6, toi_mode); if (tof) emit_move_insn (to, tof); } @@ -935,7 +936,7 @@ convert_modes (machine_mode mode, machine_mode oldmode, rtx x, int unsignedp) { gcc_assert (known_eq (GET_MODE_BITSIZE (mode), GET_MODE_BITSIZE (oldmode))); - return simplify_gen_subreg (mode, x, oldmode, 0); + return force_subreg (mode, x, oldmode, 0); } temp = gen_reg_rtx (mode); @@ -3072,8 +3073,8 @@ emit_group_load_1 (rtx *tmps, rtx dst, rtx orig_src, tree type, } } else if (CONSTANT_P (src) && GET_MODE (dst) != BLKmode - && XVECLEN (dst, 0) > 1) - tmps[i] = simplify_gen_subreg (mode, src, GET_MODE (dst), bytepos); + && XVECLEN (dst, 0) > 1) + tmps[i] = force_subreg (mode, src, GET_MODE (dst), bytepos); else if (CONSTANT_P (src)) { if (known_eq (bytelen, ssize)) @@ -3297,7 +3298,7 @@ emit_group_store (rtx orig_dst, rtx src, tree type ATTRIBUTE_UNUSED, if (known_eq (rtx_to_poly_int64 (XEXP (XVECEXP (src, 0, start), 1)), bytepos)) { - temp = simplify_gen_subreg (outer, tmps[start], inner, 0); + temp = force_subreg (outer, tmps[start], inner, 0); if (temp) { emit_move_insn (dst, temp); @@ -3317,7 +3318,7 @@ emit_group_store (rtx orig_dst, rtx src, tree type ATTRIBUTE_UNUSED, finish - 1), 1)), bytepos)) { - temp = simplify_gen_subreg (outer, tmps[finish - 1], inner, 0); + temp = force_subreg (outer, tmps[finish - 1], inner, 0); if (temp) { emit_move_insn (dst, temp); @@ -6191,11 +6192,9 @@ expand_assignment (tree to, tree from, bool nontemporal) to_mode = GET_MODE_INNER (to_mode); machine_mode from_mode = GET_MODE_INNER (GET_MODE (result)); rtx from_real - = simplify_gen_subreg (to_mode, XEXP (result, 0), - from_mode, 0); + = force_subreg (to_mode, XEXP (result, 0), from_mode, 0); rtx from_imag - = simplify_gen_subreg (to_mode, XEXP (result, 1), - from_mode, 0); + = force_subreg (to_mode, XEXP (result, 1), from_mode, 0); if (!from_real || !from_imag) goto concat_store_slow; emit_move_insn (XEXP (to_rtx, 0), from_real); @@ -6211,8 +6210,7 @@ expand_assignment (tree to, tree from, bool nontemporal) if (MEM_P (result)) from_rtx = change_address (result, to_mode, NULL_RTX); else - from_rtx - = simplify_gen_subreg (to_mode, result, from_mode, 0); + from_rtx = force_subreg (to_mode, result, from_mode, 0); if (from_rtx) { emit_move_insn (XEXP (to_rtx, 0), @@ -6224,10 +6222,10 @@ expand_assignment (tree to, tree from, bool nontemporal) { to_mode = GET_MODE_INNER (to_mode); rtx from_real - = simplify_gen_subreg (to_mode, result, from_mode, 0); + = force_subreg (to_mode, result, from_mode, 0); rtx from_imag - = simplify_gen_subreg (to_mode, result, from_mode, - GET_MODE_SIZE (to_mode)); + = force_subreg (to_mode, result, from_mode, + GET_MODE_SIZE (to_mode)); if (!from_real || !from_imag) goto concat_store_slow; emit_move_insn (XEXP (to_rtx, 0), from_real); @@ -9643,7 +9641,7 @@ expand_expr_divmod (tree_code code, machine_mode mode, tree treeop0, } rtx -expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode, +expand_expr_real_2 (const_sepops ops, rtx target, machine_mode tmode, enum expand_modifier modifier) { rtx op0, op1, op2, temp; @@ -9787,9 +9785,9 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode, inner_mode = TYPE_MODE (inner_type); if (modifier == EXPAND_INITIALIZER) - op0 = lowpart_subreg (mode, op0, inner_mode); + op0 = force_lowpart_subreg (mode, op0, inner_mode); else - op0= convert_modes (mode, inner_mode, op0, + op0 = convert_modes (mode, inner_mode, op0, TYPE_UNSIGNED (inner_type)); } @@ -11089,7 +11087,7 @@ expand_expr_real_gassign (gassign *g, rtx target, machine_mode tmode, ops.op1 = gimple_assign_rhs2 (g); /* Try to expand conditonal compare. */ - if (targetm.gen_ccmp_first) + if (targetm.have_ccmp ()) { gcc_checking_assert (targetm.gen_ccmp_next != NULL); r = expand_ccmp_expr (g, TYPE_MODE (ops.type)); @@ -13504,7 +13502,7 @@ expand_single_bit_test (location_t loc, enum tree_code code, set/jump/set sequence. */ static rtx -do_store_flag (sepops ops, rtx target, machine_mode mode) +do_store_flag (const_sepops ops, rtx target, machine_mode mode) { enum rtx_code code; tree arg0, arg1, type; @@ -13566,7 +13564,7 @@ do_store_flag (sepops ops, rtx target, machine_mode mode) if (new_code != ops->code) { struct separate_ops nops = *ops; - nops.code = ops->code = new_code; + nops.code = new_code; nops.op0 = arg0; nops.op1 = arg1; nops.type = TREE_TYPE (arg0); diff --git a/gcc/expr.h b/gcc/expr.h index 751815841083b..533ae0af3871a 100644 --- a/gcc/expr.h +++ b/gcc/expr.h @@ -53,6 +53,8 @@ typedef struct separate_ops tree type; tree op0, op1, op2; } *sepops; + +typedef const struct separate_ops *const_sepops; /* This is run during target initialization to set up which modes can be used directly in memory and to initialize the block move optab. */ @@ -305,7 +307,7 @@ extern rtx expand_expr_real (tree, rtx, machine_mode, enum expand_modifier, rtx *, bool); extern rtx expand_expr_real_1 (tree, rtx, machine_mode, enum expand_modifier, rtx *, bool); -extern rtx expand_expr_real_2 (sepops, rtx, machine_mode, +extern rtx expand_expr_real_2 (const_sepops, rtx, machine_mode, enum expand_modifier); extern rtx expand_expr_real_gassign (gassign *, rtx, machine_mode, enum expand_modifier modifier, diff --git a/gcc/flag-types.h b/gcc/flag-types.h index 5a2b461fa75f2..1e497f0bb9134 100644 --- a/gcc/flag-types.h +++ b/gcc/flag-types.h @@ -396,7 +396,8 @@ enum lto_partition_model { LTO_PARTITION_ONE = 1, LTO_PARTITION_BALANCED = 2, LTO_PARTITION_1TO1 = 3, - LTO_PARTITION_MAX = 4 + LTO_PARTITION_MAX = 4, + LTO_PARTITION_CACHE = 5 }; /* flag_lto_linker_output initialization values. */ diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 4ef3e119f5d7d..a2275728a46b9 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,35 @@ +2024-06-17 Andre Vehreschild + + * trans.cc (gfc_deallocate_with_status): Check that object to deref + is an array, before applying array deref. + +2024-06-12 David Malcolm + + * error.cc (gfc_clear_pp_buffer): Likewise. + (gfc_warning): Likewise. + (gfc_warning_check): Likewise. + (gfc_error_opt): Likewise. + (gfc_error_check): Likewise. + +2024-06-07 Andre Vehreschild + + PR fortran/90068 + * trans-array.cc (gfc_trans_array_ctor_element): Eval non- + variable expressions once only. + (gfc_trans_array_constructor_value): Add statements of + final block. + (trans_array_constructor): Detect when final block is required. + +2024-06-07 Andre Vehreschild + + PR fortran/90072 + * expr.cc (gfc_is_alloc_class_scalar_function): Detect + allocatable class return types also for user-defined + functions. + * trans-expr.cc (gfc_conv_procedure_call): Same. + (trans_class_vptr_len_assignment): Compute vptr len + assignment correctly for user-defined functions. + 2024-06-05 Jakub Jelinek Frederik Harwath Sandra Loosemore diff --git a/gcc/fortran/error.cc b/gcc/fortran/error.cc index 65e38b0e8667b..a0e1a1c368441 100644 --- a/gcc/fortran/error.cc +++ b/gcc/fortran/error.cc @@ -924,10 +924,10 @@ static void gfc_clear_pp_buffer (output_buffer *this_buffer) { pretty_printer *pp = global_dc->printer; - output_buffer *tmp_buffer = pp->buffer; - pp->buffer = this_buffer; + output_buffer *tmp_buffer = pp_buffer (pp); + pp_buffer (pp) = this_buffer; pp_clear_output_area (pp); - pp->buffer = tmp_buffer; + pp_buffer (pp) = tmp_buffer; /* We need to reset last_location, otherwise we may skip caret lines when we actually give a diagnostic. */ global_dc->m_last_location = UNKNOWN_LOCATION; @@ -964,13 +964,13 @@ gfc_warning (int opt, const char *gmsgid, va_list ap) rich_location rich_loc (line_table, UNKNOWN_LOCATION); bool fatal_errors = global_dc->m_fatal_errors; pretty_printer *pp = global_dc->printer; - output_buffer *tmp_buffer = pp->buffer; + output_buffer *tmp_buffer = pp_buffer (pp); gfc_clear_pp_buffer (pp_warning_buffer); if (buffered_p) { - pp->buffer = pp_warning_buffer; + pp_buffer (pp) = pp_warning_buffer; global_dc->m_fatal_errors = false; /* To prevent -fmax-errors= triggering. */ --werrorcount; @@ -983,7 +983,7 @@ gfc_warning (int opt, const char *gmsgid, va_list ap) if (buffered_p) { - pp->buffer = tmp_buffer; + pp_buffer (pp) = tmp_buffer; global_dc->m_fatal_errors = fatal_errors; warningcount_buffered = 0; @@ -1461,13 +1461,13 @@ gfc_warning_check (void) if (! gfc_output_buffer_empty_p (pp_warning_buffer)) { pretty_printer *pp = global_dc->printer; - output_buffer *tmp_buffer = pp->buffer; - pp->buffer = pp_warning_buffer; + output_buffer *tmp_buffer = pp_buffer (pp); + pp_buffer (pp) = pp_warning_buffer; pp_really_flush (pp); warningcount += warningcount_buffered; werrorcount += werrorcount_buffered; gcc_assert (warningcount_buffered + werrorcount_buffered == 1); - pp->buffer = tmp_buffer; + pp_buffer (pp) = tmp_buffer; diagnostic_action_after_output (global_dc, warningcount_buffered ? DK_WARNING : DK_ERROR); @@ -1502,7 +1502,7 @@ gfc_error_opt (int opt, const char *gmsgid, va_list ap) rich_location richloc (line_table, UNKNOWN_LOCATION); bool fatal_errors = global_dc->m_fatal_errors; pretty_printer *pp = global_dc->printer; - output_buffer *tmp_buffer = pp->buffer; + output_buffer *tmp_buffer = pp_buffer (pp); gfc_clear_pp_buffer (pp_error_buffer); @@ -1512,7 +1512,7 @@ gfc_error_opt (int opt, const char *gmsgid, va_list ap) save abort_on_error and restore it below. */ saved_abort_on_error = global_dc->m_abort_on_error; global_dc->m_abort_on_error = false; - pp->buffer = pp_error_buffer; + pp_buffer (pp) = pp_error_buffer; global_dc->m_fatal_errors = false; /* To prevent -fmax-errors= triggering, we decrease it before report_diagnostic increases it. */ @@ -1524,7 +1524,7 @@ gfc_error_opt (int opt, const char *gmsgid, va_list ap) if (buffered_p) { - pp->buffer = tmp_buffer; + pp_buffer (pp) = tmp_buffer; global_dc->m_fatal_errors = fatal_errors; global_dc->m_abort_on_error = saved_abort_on_error; @@ -1609,12 +1609,12 @@ gfc_error_check (void) { error_buffer.flag = false; pretty_printer *pp = global_dc->printer; - output_buffer *tmp_buffer = pp->buffer; - pp->buffer = pp_error_buffer; + output_buffer *tmp_buffer = pp_buffer (pp); + pp_buffer (pp) = pp_error_buffer; pp_really_flush (pp); ++errorcount; gcc_assert (gfc_output_buffer_empty_p (pp_error_buffer)); - pp->buffer = tmp_buffer; + pp_buffer (pp) = tmp_buffer; diagnostic_action_after_output (global_dc, DK_ERROR); diagnostic_check_max_errors (global_dc, true); return true; diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc index a162744c71934..be138d196a23e 100644 --- a/gcc/fortran/expr.cc +++ b/gcc/fortran/expr.cc @@ -5573,11 +5573,14 @@ bool gfc_is_alloc_class_scalar_function (gfc_expr *expr) { if (expr->expr_type == EXPR_FUNCTION - && expr->value.function.esym - && expr->value.function.esym->result - && expr->value.function.esym->result->ts.type == BT_CLASS - && !CLASS_DATA (expr->value.function.esym->result)->attr.dimension - && CLASS_DATA (expr->value.function.esym->result)->attr.allocatable) + && ((expr->value.function.esym + && expr->value.function.esym->result + && expr->value.function.esym->result->ts.type == BT_CLASS + && !CLASS_DATA (expr->value.function.esym->result)->attr.dimension + && CLASS_DATA (expr->value.function.esym->result)->attr.allocatable) + || (expr->ts.type == BT_CLASS + && CLASS_DATA (expr)->attr.allocatable + && !CLASS_DATA (expr)->attr.dimension))) return true; return false; diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index eec62c296ff50..cc50b961a9790 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -1885,6 +1885,16 @@ gfc_trans_array_ctor_element (stmtblock_t * pblock, tree desc, gfc_conv_descriptor_data_get (desc)); tmp = gfc_build_array_ref (tmp, offset, NULL); + if (expr->expr_type == EXPR_FUNCTION && expr->ts.type == BT_DERIVED + && expr->ts.u.derived->attr.alloc_comp) + { + if (!VAR_P (se->expr)) + se->expr = gfc_evaluate_now (se->expr, &se->pre); + gfc_add_expr_to_block (&se->finalblock, + gfc_deallocate_alloc_comp_no_caf ( + expr->ts.u.derived, se->expr, expr->rank, true)); + } + if (expr->ts.type == BT_CHARACTER) { int i = gfc_validate_kind (BT_CHARACTER, expr->ts.kind, false); @@ -2147,6 +2157,8 @@ gfc_trans_array_constructor_value (stmtblock_t * pblock, *poffset = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type, *poffset, gfc_index_one_node); + if (finalblock) + gfc_add_block_to_block (finalblock, &se.finalblock); } else { @@ -2795,6 +2807,7 @@ trans_array_constructor (gfc_ss * ss, locus * where) tree neg_len; char *msg; stmtblock_t finalblock; + bool finalize_required; /* Save the old values for nested checking. */ old_first_len = first_len; @@ -2973,8 +2986,11 @@ trans_array_constructor (gfc_ss * ss, locus * where) TREE_USED (offsetvar) = 0; gfc_init_block (&finalblock); + finalize_required = expr->must_finalize; + if (expr->ts.type == BT_DERIVED && expr->ts.u.derived->attr.alloc_comp) + finalize_required = true; gfc_trans_array_constructor_value (&outer_loop->pre, - expr->must_finalize ? &finalblock : NULL, + finalize_required ? &finalblock : NULL, type, desc, c, &offset, &offsetvar, dynamic); diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc index dca7779528bb5..88538713a02b4 100644 --- a/gcc/fortran/trans-decl.cc +++ b/gcc/fortran/trans-decl.cc @@ -7926,11 +7926,12 @@ gfc_generate_function_code (gfc_namespace * ns) && CLASS_DATA (sym)->attr.dimension == 0 && sym->result == sym) { - tmp = CLASS_DATA (sym)->backend_decl; - tmp = fold_build3_loc (input_location, COMPONENT_REF, - TREE_TYPE (tmp), result, tmp, NULL_TREE); - gfc_add_modify (&init, tmp, fold_convert (TREE_TYPE (tmp), - null_pointer_node)); + tmp = gfc_class_data_get (result); + gfc_add_modify (&init, tmp, + fold_convert (TREE_TYPE (tmp), + null_pointer_node)); + gfc_reset_vptr (&init, nullptr, result, + CLASS_DATA (sym->result)->ts.u.derived); } else if (sym->ts.type == BT_DERIVED && !sym->attr.allocatable) diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index 9f6cc8f871e24..558a738051696 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -530,13 +530,14 @@ gfc_find_and_cut_at_last_class_ref (gfc_expr *e, bool is_mold, return base_expr; } - /* Reset the vptr to the declared type, e.g. after deallocation. Use the variable in CLASS_CONTAINER if available. Otherwise, recreate - one with E. The generated assignment code is added at the end of BLOCK. */ + one with e or derived. At least one of the two has to be set. The generated + assignment code is added at the end of BLOCK. */ void -gfc_reset_vptr (stmtblock_t *block, gfc_expr *e, tree class_container) +gfc_reset_vptr (stmtblock_t *block, gfc_expr *e, tree class_container, + gfc_symbol *derived) { tree vptr = NULL_TREE; @@ -546,6 +547,7 @@ gfc_reset_vptr (stmtblock_t *block, gfc_expr *e, tree class_container) if (vptr == NULL_TREE) { gfc_se se; + gcc_assert (e); /* Evaluate the expression and obtain the vptr from it. */ gfc_init_se (&se, NULL); @@ -570,7 +572,7 @@ gfc_reset_vptr (stmtblock_t *block, gfc_expr *e, tree class_container) tree vtable; /* Return the vptr to the address of the declared type. */ - vtab = gfc_find_derived_vtab (e->ts.u.derived); + vtab = gfc_find_derived_vtab (derived ? derived : e->ts.u.derived); vtable = vtab->backend_decl; if (vtable == NULL_TREE) vtable = gfc_get_symbol_decl (vtab); @@ -8301,7 +8303,9 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, } /* Finalize the result, if necessary. */ - attr = CLASS_DATA (expr->value.function.esym->result)->attr; + attr = expr->value.function.esym + ? CLASS_DATA (expr->value.function.esym->result)->attr + : CLASS_DATA (expr)->attr; if (!((gfc_is_class_array_function (expr) || gfc_is_alloc_class_scalar_function (expr)) && attr.pointer)) @@ -10085,27 +10089,26 @@ trans_class_vptr_len_assignment (stmtblock_t *block, gfc_expr * le, if (re->expr_type != EXPR_VARIABLE && re->expr_type != EXPR_NULL && rse->expr != NULL_TREE) { - if (re->ts.type == BT_CLASS && !GFC_CLASS_TYPE_P (TREE_TYPE (rse->expr))) - class_expr = gfc_get_class_from_expr (rse->expr); + if (!DECL_P (rse->expr)) + { + if (re->ts.type == BT_CLASS && !GFC_CLASS_TYPE_P (TREE_TYPE (rse->expr))) + class_expr = gfc_get_class_from_expr (rse->expr); - if (rse->loop) - pre = &rse->loop->pre; - else - pre = &rse->pre; + if (rse->loop) + pre = &rse->loop->pre; + else + pre = &rse->pre; - if (class_expr != NULL_TREE && UNLIMITED_POLY (re)) - { - tmp = TREE_OPERAND (rse->expr, 0); - tmp = gfc_create_var (TREE_TYPE (tmp), "rhs"); - gfc_add_modify (&rse->pre, tmp, TREE_OPERAND (rse->expr, 0)); + if (class_expr != NULL_TREE && UNLIMITED_POLY (re)) + tmp = gfc_evaluate_now (TREE_OPERAND (rse->expr, 0), &rse->pre); + else + tmp = gfc_evaluate_now (rse->expr, &rse->pre); + + rse->expr = tmp; } else - { - tmp = gfc_create_var (TREE_TYPE (rse->expr), "rhs"); - gfc_add_modify (&rse->pre, tmp, rse->expr); - } + pre = &rse->pre; - rse->expr = tmp; temp_rhs = true; } diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc index a208afe90ab0c..1335b8cc48bb2 100644 --- a/gcc/fortran/trans.cc +++ b/gcc/fortran/trans.cc @@ -1838,7 +1838,8 @@ gfc_deallocate_with_status (tree pointer, tree status, tree errmsg, else caf_dereg_type = (enum gfc_coarray_deregtype) coarray_dealloc_mode; } - else if (flag_coarray == GFC_FCOARRAY_SINGLE) + else if (flag_coarray == GFC_FCOARRAY_SINGLE + && GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (pointer))) pointer = gfc_conv_descriptor_data_get (pointer); } else if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (pointer))) diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h index f94fa60140048..5e064af5ccbde 100644 --- a/gcc/fortran/trans.h +++ b/gcc/fortran/trans.h @@ -451,7 +451,9 @@ tree gfc_vptr_def_init_get (tree); tree gfc_vptr_copy_get (tree); tree gfc_vptr_final_get (tree); tree gfc_vptr_deallocate_get (tree); -void gfc_reset_vptr (stmtblock_t *, gfc_expr *, tree = NULL_TREE); +void +gfc_reset_vptr (stmtblock_t *, gfc_expr *, tree = NULL_TREE, + gfc_symbol * = nullptr); void gfc_reset_len (stmtblock_t *, gfc_expr *); tree gfc_get_class_from_gfc_expr (gfc_expr *); tree gfc_get_class_from_expr (tree); diff --git a/gcc/gimple-array-bounds.cc b/gcc/gimple-array-bounds.cc index 2fa3d18d2952e..1637a2fc4f490 100644 --- a/gcc/gimple-array-bounds.cc +++ b/gcc/gimple-array-bounds.cc @@ -38,10 +38,12 @@ along with GCC; see the file COPYING3. If not see #include "domwalk.h" #include "tree-cfg.h" #include "attribs.h" +#include "tree-pass.h" +#include "gimple-range.h" -array_bounds_checker::array_bounds_checker (struct function *func, - range_query *qry) - : fun (func), m_ptr_qry (qry) +// Always use the current range query for the bounds checker. +array_bounds_checker::array_bounds_checker (struct function *func) + : fun (func), m_ptr_qry (get_range_query (func)) { /* No-op. */ } @@ -838,11 +840,7 @@ class check_array_bounds_dom_walker : public dom_walker { public: check_array_bounds_dom_walker (array_bounds_checker *checker) - : dom_walker (CDI_DOMINATORS, - /* Discover non-executable edges, preserving EDGE_EXECUTABLE - flags, so that we can merge in information on - non-executable edges from vrp_folder . */ - REACHABLE_BLOCKS_PRESERVING_FLAGS), + : dom_walker (CDI_DOMINATORS, REACHABLE_BLOCKS), checker (checker) { } ~check_array_bounds_dom_walker () {} @@ -888,3 +886,52 @@ array_bounds_checker::check () check_array_bounds_dom_walker w (this); w.walk (ENTRY_BLOCK_PTR_FOR_FN (fun)); } + +const pass_data pass_data_array_bounds = +{ + GIMPLE_PASS, /* type */ + "bounds", /* name */ + OPTGROUP_NONE, /* optinfo_flags */ + TV_TREE_ARRAY_BOUNDS, /* tv_id */ + PROP_ssa, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + ( 0 ), /* No TODOs */ +}; + +class pass_array_bounds : public gimple_opt_pass +{ +public: + pass_array_bounds (gcc::context *ctxt, const pass_data &data_) + : gimple_opt_pass (data_, ctxt), data (data_) + { } + + /* opt_pass methods: */ + opt_pass * clone () final override + { return new pass_array_bounds (m_ctxt, data); } + bool gate (function *) final override + { + // Gate on the VRP pass to preserve previous behavior. + return flag_tree_vrp && (warn_array_bounds || warn_strict_flex_arrays); + } + unsigned int execute (function *fun) final override + { + calculate_dominance_info (CDI_DOMINATORS); + // Enable ranger as the current range query. + enable_ranger (fun, false); + array_bounds_checker array_checker (fun); + array_checker.check (); + disable_ranger (fun); + return 0; + } + + private: + const pass_data &data; +}; // class pass_array_bounds + +gimple_opt_pass * +make_pass_array_bounds (gcc::context *ctxt) +{ + return new pass_array_bounds (ctxt, pass_data_array_bounds); +} diff --git a/gcc/gimple-array-bounds.h b/gcc/gimple-array-bounds.h index 3e077d0178ff3..aa7ca8e9730fa 100644 --- a/gcc/gimple-array-bounds.h +++ b/gcc/gimple-array-bounds.h @@ -27,7 +27,7 @@ class array_bounds_checker friend class check_array_bounds_dom_walker; public: - array_bounds_checker (struct function *, range_query *); + array_bounds_checker (struct function *); void check (); private: diff --git a/gcc/gimple-lower-bitint.cc b/gcc/gimple-lower-bitint.cc index 7e8b6e3c51a06..56e5f826a8d9f 100644 --- a/gcc/gimple-lower-bitint.cc +++ b/gcc/gimple-lower-bitint.cc @@ -4286,11 +4286,7 @@ bitint_large_huge::lower_addsub_overflow (tree obj, gimple *stmt) bool single_comparison = (startlimb + 2 >= fin || (startlimb & 1) != (i & 1)); if (!single_comparison) - { - cmp_code = GE_EXPR; - if (!check_zero && (start % limb_prec) == 0) - single_comparison = true; - } + cmp_code = GE_EXPR; else if ((startlimb & 1) == (i & 1)) cmp_code = EQ_EXPR; else diff --git a/gcc/gimple-match-head.cc b/gcc/gimple-match-head.cc index e26fa0860ee99..924d3f1e7103c 100644 --- a/gcc/gimple-match-head.cc +++ b/gcc/gimple-match-head.cc @@ -243,6 +243,7 @@ optimize_successive_divisions_p (tree divisor, tree inner_div) gimple_bitwise_equal_p (expr1, expr2, valueize) bool gimple_nop_convert (tree, tree *, tree (*) (tree)); +bool gimple_maybe_truncate (tree, tree *, tree (*) (tree)); /* Helper function for bitwise_equal_p macro. */ @@ -271,6 +272,10 @@ gimple_bitwise_equal_p (tree expr1, tree expr2, tree (*valueize) (tree)) } if (expr2 != expr4 && operand_equal_p (expr1, expr4, 0)) return true; + if (gimple_maybe_truncate (expr3, &expr3, valueize) + && gimple_maybe_truncate (expr4, &expr4, valueize) + && operand_equal_p (expr3, expr4, 0)) + return true; return false; } @@ -318,21 +323,13 @@ gimple_bitwise_inverted_equal_p (tree expr1, tree expr2, bool &wascmp, tree (*va /* Try if EXPR1 was defined as ~EXPR2. */ if (gimple_bit_not_with_nop (expr1, &other, valueize)) { - if (operand_equal_p (other, expr2, 0)) - return true; - tree expr4; - if (gimple_nop_convert (expr2, &expr4, valueize) - && operand_equal_p (other, expr4, 0)) + if (gimple_bitwise_equal_p (other, expr2, valueize)) return true; } /* Try if EXPR2 was defined as ~EXPR1. */ if (gimple_bit_not_with_nop (expr2, &other, valueize)) { - if (operand_equal_p (other, expr1, 0)) - return true; - tree expr3; - if (gimple_nop_convert (expr1, &expr3, valueize) - && operand_equal_p (other, expr3, 0)) + if (gimple_bitwise_equal_p (other, expr1, valueize)) return true; } diff --git a/gcc/gimple-pretty-print.cc b/gcc/gimple-pretty-print.cc index a71e1e0efc77e..08b823c84efff 100644 --- a/gcc/gimple-pretty-print.cc +++ b/gcc/gimple-pretty-print.cc @@ -53,27 +53,27 @@ along with GCC; see the file COPYING3. If not see #endif #define INDENT(SPACE) \ - do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0) + do { int i; for (i = 0; i < SPACE; i++) pp_space (pp); } while (0) -#define GIMPLE_NIY do_niy (buffer,gs) +#define GIMPLE_NIY do_niy (pp,gs) -/* Try to print on BUFFER a default message for the unrecognized +/* Try to print on PP a default message for the unrecognized gimple statement GS. */ static void -do_niy (pretty_printer *buffer, const gimple *gs) +do_niy (pretty_printer *pp, const gimple *gs) { - pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n", + pp_printf (pp, "<<< Unknown GIMPLE statement: %s >>>\n", gimple_code_name[(int) gimple_code (gs)]); } -/* Emit a newline and SPC indentation spaces to BUFFER. */ +/* Emit a newline and SPC indentation spaces to PP. */ static void -newline_and_indent (pretty_printer *buffer, int spc) +newline_and_indent (pretty_printer *pp, int spc) { - pp_newline (buffer); + pp_newline (pp); INDENT (spc); } @@ -139,12 +139,12 @@ dump_probability (profile_probability probability) return ret; } -/* Dump E probability to BUFFER. */ +/* Dump E probability to PP. */ static void -dump_edge_probability (pretty_printer *buffer, edge e) +dump_edge_probability (pretty_printer *pp, edge e) { - pp_scalar (buffer, " %s", dump_probability (e->probability)); + pp_scalar (pp, " %s", dump_probability (e->probability)); } /* Print GIMPLE statement G to FILE using SPC indentation spaces and @@ -153,11 +153,11 @@ dump_edge_probability (pretty_printer *buffer, edge e) void print_gimple_stmt (FILE *file, gimple *g, int spc, dump_flags_t flags) { - pretty_printer buffer; - pp_needs_newline (&buffer) = true; - buffer.buffer->stream = file; - pp_gimple_stmt_1 (&buffer, g, spc, flags); - pp_newline_and_flush (&buffer); + pretty_printer pp; + pp_needs_newline (&pp) = true; + pp.set_output_stream (file); + pp_gimple_stmt_1 (&pp, g, spc, flags); + pp_newline_and_flush (&pp); } DEBUG_FUNCTION void @@ -184,21 +184,21 @@ void print_gimple_expr (FILE *file, gimple *g, int spc, dump_flags_t flags) { flags |= TDF_RHS_ONLY; - pretty_printer buffer; - pp_needs_newline (&buffer) = true; - buffer.buffer->stream = file; - pp_gimple_stmt_1 (&buffer, g, spc, flags); - pp_flush (&buffer); + pretty_printer pp; + pp_needs_newline (&pp) = true; + pp.set_output_stream (file); + pp_gimple_stmt_1 (&pp, g, spc, flags); + pp_flush (&pp); } -/* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation +/* Print the GIMPLE sequence SEQ on PP using SPC indentation spaces and FLAGS as in pp_gimple_stmt_1. - The caller is responsible for calling pp_flush on BUFFER to finalize + The caller is responsible for calling pp_flush on PP to finalize the pretty printer. */ static void -dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, +dump_gimple_seq (pretty_printer *pp, gimple_seq seq, int spc, dump_flags_t flags) { gimple_stmt_iterator i; @@ -207,9 +207,9 @@ dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, { gimple *gs = gsi_stmt (i); INDENT (spc); - pp_gimple_stmt_1 (buffer, gs, spc, flags); + pp_gimple_stmt_1 (pp, gs, spc, flags); if (!gsi_one_before_end_p (i)) - pp_newline (buffer); + pp_newline (pp); } } @@ -220,11 +220,11 @@ dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, void print_gimple_seq (FILE *file, gimple_seq seq, int spc, dump_flags_t flags) { - pretty_printer buffer; - pp_needs_newline (&buffer) = true; - buffer.buffer->stream = file; - dump_gimple_seq (&buffer, seq, spc, flags); - pp_newline_and_flush (&buffer); + pretty_printer pp; + pp_needs_newline (&pp) = true; + pp.set_output_stream (file); + dump_gimple_seq (&pp, seq, spc, flags); + pp_newline_and_flush (&pp); } @@ -250,7 +250,7 @@ debug_gimple_seq (gimple_seq seq) '-' - decreases indent by 2 then outputs a newline. */ static void -dump_gimple_fmt (pretty_printer *buffer, int spc, dump_flags_t flags, +dump_gimple_fmt (pretty_printer *pp, int spc, dump_flags_t flags, const char *fmt, ...) { va_list args; @@ -270,48 +270,48 @@ dump_gimple_fmt (pretty_printer *buffer, int spc, dump_flags_t flags, case 'G': g = va_arg (args, gimple *); tmp = gimple_code_name[gimple_code (g)]; - pp_string (buffer, tmp); + pp_string (pp, tmp); break; case 'S': seq = va_arg (args, gimple_seq); - pp_newline (buffer); - dump_gimple_seq (buffer, seq, spc + 2, flags); - newline_and_indent (buffer, spc); + pp_newline (pp); + dump_gimple_seq (pp, seq, spc + 2, flags); + newline_and_indent (pp, spc); break; case 'T': t = va_arg (args, tree); if (t == NULL_TREE) - pp_string (buffer, "NULL"); + pp_string (pp, "NULL"); else - dump_generic_node (buffer, t, spc, flags, false); + dump_generic_node (pp, t, spc, flags, false); break; case 'd': - pp_decimal_int (buffer, va_arg (args, int)); + pp_decimal_int (pp, va_arg (args, int)); break; case 's': - pp_string (buffer, va_arg (args, char *)); + pp_string (pp, va_arg (args, char *)); break; case 'n': - newline_and_indent (buffer, spc); + newline_and_indent (pp, spc); break; case 'x': - pp_scalar (buffer, "%x", va_arg (args, int)); + pp_scalar (pp, "%x", va_arg (args, int)); break; case '+': spc += 2; - newline_and_indent (buffer, spc); + newline_and_indent (pp, spc); break; case '-': spc -= 2; - newline_and_indent (buffer, spc); + newline_and_indent (pp, spc); break; default: @@ -319,17 +319,17 @@ dump_gimple_fmt (pretty_printer *buffer, int spc, dump_flags_t flags, } } else - pp_character (buffer, *c); + pp_character (pp, *c); } va_end (args); } /* Helper for dump_gimple_assign. Print the unary RHS of the - assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */ + assignment GS. PP, SPC and FLAGS are as in pp_gimple_stmt_1. */ static void -dump_unary_rhs (pretty_printer *buffer, const gassign *gs, int spc, +dump_unary_rhs (pretty_printer *pp, const gassign *gs, int spc, dump_flags_t flags) { enum tree_code rhs_code = gimple_assign_rhs_code (gs); @@ -339,7 +339,7 @@ dump_unary_rhs (pretty_printer *buffer, const gassign *gs, int spc, switch (rhs_code) { case VIEW_CONVERT_EXPR: - dump_generic_node (buffer, rhs, spc, flags, false); + dump_generic_node (pp, rhs, spc, flags, false); break; case FIXED_CONVERT_EXPR: @@ -347,39 +347,39 @@ dump_unary_rhs (pretty_printer *buffer, const gassign *gs, int spc, case FIX_TRUNC_EXPR: case FLOAT_EXPR: CASE_CONVERT: - pp_left_paren (buffer); - dump_generic_node (buffer, TREE_TYPE (lhs), spc, flags, false); - pp_string (buffer, ") "); + pp_left_paren (pp); + dump_generic_node (pp, TREE_TYPE (lhs), spc, flags, false); + pp_string (pp, ") "); if (op_prio (rhs) < op_code_prio (rhs_code)) { - pp_left_paren (buffer); - dump_generic_node (buffer, rhs, spc, flags, false); - pp_right_paren (buffer); + pp_left_paren (pp); + dump_generic_node (pp, rhs, spc, flags, false); + pp_right_paren (pp); } else - dump_generic_node (buffer, rhs, spc, flags, false); + dump_generic_node (pp, rhs, spc, flags, false); break; case PAREN_EXPR: - pp_string (buffer, "(("); - dump_generic_node (buffer, rhs, spc, flags, false); - pp_string (buffer, "))"); + pp_string (pp, "(("); + dump_generic_node (pp, rhs, spc, flags, false); + pp_string (pp, "))"); break; case ABS_EXPR: case ABSU_EXPR: if (flags & TDF_GIMPLE) { - pp_string (buffer, + pp_string (pp, rhs_code == ABS_EXPR ? "__ABS " : "__ABSU "); - dump_generic_node (buffer, rhs, spc, flags, false); + dump_generic_node (pp, rhs, spc, flags, false); } else { - pp_string (buffer, + pp_string (pp, rhs_code == ABS_EXPR ? "ABS_EXPR <" : "ABSU_EXPR <"); - dump_generic_node (buffer, rhs, spc, flags, false); - pp_greater (buffer); + dump_generic_node (pp, rhs, spc, flags, false); + pp_greater (pp); } break; @@ -391,40 +391,40 @@ dump_unary_rhs (pretty_printer *buffer, const gassign *gs, int spc, || rhs_code == ADDR_EXPR || rhs_code == CONSTRUCTOR) { - dump_generic_node (buffer, rhs, spc, flags, false); + dump_generic_node (pp, rhs, spc, flags, false); break; } else if (rhs_code == BIT_NOT_EXPR) - pp_complement (buffer); + pp_complement (pp); else if (rhs_code == TRUTH_NOT_EXPR) - pp_exclamation (buffer); + pp_exclamation (pp); else if (rhs_code == NEGATE_EXPR) - pp_minus (buffer); + pp_minus (pp); else { - pp_left_bracket (buffer); - pp_string (buffer, get_tree_code_name (rhs_code)); - pp_string (buffer, "] "); + pp_left_bracket (pp); + pp_string (pp, get_tree_code_name (rhs_code)); + pp_string (pp, "] "); } if (op_prio (rhs) < op_code_prio (rhs_code)) { - pp_left_paren (buffer); - dump_generic_node (buffer, rhs, spc, flags, false); - pp_right_paren (buffer); + pp_left_paren (pp); + dump_generic_node (pp, rhs, spc, flags, false); + pp_right_paren (pp); } else - dump_generic_node (buffer, rhs, spc, flags, false); + dump_generic_node (pp, rhs, spc, flags, false); break; } } /* Helper for dump_gimple_assign. Print the binary RHS of the - assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */ + assignment GS. PP, SPC and FLAGS are as in pp_gimple_stmt_1. */ static void -dump_binary_rhs (pretty_printer *buffer, const gassign *gs, int spc, +dump_binary_rhs (pretty_printer *pp, const gassign *gs, int spc, dump_flags_t flags) { const char *p; @@ -435,13 +435,13 @@ dump_binary_rhs (pretty_printer *buffer, const gassign *gs, int spc, case MAX_EXPR: if (flags & TDF_GIMPLE) { - pp_string (buffer, code == MIN_EXPR ? "__MIN (" : "__MAX ("); - dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, + pp_string (pp, code == MIN_EXPR ? "__MIN (" : "__MAX ("); + dump_generic_node (pp, gimple_assign_rhs1 (gs), spc, flags, false); - pp_string (buffer, ", "); - dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, + pp_string (pp, ", "); + dump_generic_node (pp, gimple_assign_rhs2 (gs), spc, flags, false); - pp_string (buffer, ")"); + pp_string (pp, ")"); break; } else @@ -461,44 +461,44 @@ dump_binary_rhs (pretty_printer *buffer, const gassign *gs, int spc, case VEC_WIDEN_LSHIFT_LO_EXPR: case VEC_SERIES_EXPR: for (p = get_tree_code_name (code); *p; p++) - pp_character (buffer, TOUPPER (*p)); - pp_string (buffer, " <"); - dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); - pp_string (buffer, ", "); - dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); - pp_greater (buffer); + pp_character (pp, TOUPPER (*p)); + pp_string (pp, " <"); + dump_generic_node (pp, gimple_assign_rhs1 (gs), spc, flags, false); + pp_string (pp, ", "); + dump_generic_node (pp, gimple_assign_rhs2 (gs), spc, flags, false); + pp_greater (pp); break; default: if (op_prio (gimple_assign_rhs1 (gs)) <= op_code_prio (code)) { - pp_left_paren (buffer); - dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, + pp_left_paren (pp); + dump_generic_node (pp, gimple_assign_rhs1 (gs), spc, flags, false); - pp_right_paren (buffer); + pp_right_paren (pp); } else - dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); - pp_space (buffer); - pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs), flags)); - pp_space (buffer); + dump_generic_node (pp, gimple_assign_rhs1 (gs), spc, flags, false); + pp_space (pp); + pp_string (pp, op_symbol_code (gimple_assign_rhs_code (gs), flags)); + pp_space (pp); if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code)) { - pp_left_paren (buffer); - dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, + pp_left_paren (pp); + dump_generic_node (pp, gimple_assign_rhs2 (gs), spc, flags, false); - pp_right_paren (buffer); + pp_right_paren (pp); } else - dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); + dump_generic_node (pp, gimple_assign_rhs2 (gs), spc, flags, false); } } /* Helper for dump_gimple_assign. Print the ternary RHS of the - assignment GS. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. */ + assignment GS. PP, SPC and FLAGS are as in pp_gimple_stmt_1. */ static void -dump_ternary_rhs (pretty_printer *buffer, const gassign *gs, int spc, +dump_ternary_rhs (pretty_printer *pp, const gassign *gs, int spc, dump_flags_t flags) { const char *p; @@ -508,113 +508,113 @@ dump_ternary_rhs (pretty_printer *buffer, const gassign *gs, int spc, case WIDEN_MULT_PLUS_EXPR: case WIDEN_MULT_MINUS_EXPR: for (p = get_tree_code_name (code); *p; p++) - pp_character (buffer, TOUPPER (*p)); - pp_string (buffer, " <"); - dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); - pp_string (buffer, ", "); - dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); - pp_string (buffer, ", "); - dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false); - pp_greater (buffer); + pp_character (pp, TOUPPER (*p)); + pp_string (pp, " <"); + dump_generic_node (pp, gimple_assign_rhs1 (gs), spc, flags, false); + pp_string (pp, ", "); + dump_generic_node (pp, gimple_assign_rhs2 (gs), spc, flags, false); + pp_string (pp, ", "); + dump_generic_node (pp, gimple_assign_rhs3 (gs), spc, flags, false); + pp_greater (pp); break; case DOT_PROD_EXPR: - pp_string (buffer, "DOT_PROD_EXPR <"); - dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); - pp_string (buffer, ", "); - dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); - pp_string (buffer, ", "); - dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false); - pp_greater (buffer); + pp_string (pp, "DOT_PROD_EXPR <"); + dump_generic_node (pp, gimple_assign_rhs1 (gs), spc, flags, false); + pp_string (pp, ", "); + dump_generic_node (pp, gimple_assign_rhs2 (gs), spc, flags, false); + pp_string (pp, ", "); + dump_generic_node (pp, gimple_assign_rhs3 (gs), spc, flags, false); + pp_greater (pp); break; case SAD_EXPR: - pp_string (buffer, "SAD_EXPR <"); - dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); - pp_string (buffer, ", "); - dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); - pp_string (buffer, ", "); - dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false); - pp_greater (buffer); + pp_string (pp, "SAD_EXPR <"); + dump_generic_node (pp, gimple_assign_rhs1 (gs), spc, flags, false); + pp_string (pp, ", "); + dump_generic_node (pp, gimple_assign_rhs2 (gs), spc, flags, false); + pp_string (pp, ", "); + dump_generic_node (pp, gimple_assign_rhs3 (gs), spc, flags, false); + pp_greater (pp); break; case VEC_PERM_EXPR: if (flags & TDF_GIMPLE) - pp_string (buffer, "__VEC_PERM ("); + pp_string (pp, "__VEC_PERM ("); else - pp_string (buffer, "VEC_PERM_EXPR <"); - dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); - pp_string (buffer, ", "); - dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); - pp_string (buffer, ", "); - dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false); + pp_string (pp, "VEC_PERM_EXPR <"); + dump_generic_node (pp, gimple_assign_rhs1 (gs), spc, flags, false); + pp_string (pp, ", "); + dump_generic_node (pp, gimple_assign_rhs2 (gs), spc, flags, false); + pp_string (pp, ", "); + dump_generic_node (pp, gimple_assign_rhs3 (gs), spc, flags, false); if (flags & TDF_GIMPLE) - pp_right_paren (buffer); + pp_right_paren (pp); else - pp_greater (buffer); + pp_greater (pp); break; case REALIGN_LOAD_EXPR: - pp_string (buffer, "REALIGN_LOAD <"); - dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); - pp_string (buffer, ", "); - dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); - pp_string (buffer, ", "); - dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false); - pp_greater (buffer); + pp_string (pp, "REALIGN_LOAD <"); + dump_generic_node (pp, gimple_assign_rhs1 (gs), spc, flags, false); + pp_string (pp, ", "); + dump_generic_node (pp, gimple_assign_rhs2 (gs), spc, flags, false); + pp_string (pp, ", "); + dump_generic_node (pp, gimple_assign_rhs3 (gs), spc, flags, false); + pp_greater (pp); break; case COND_EXPR: - dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); - pp_string (buffer, " ? "); - dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); - pp_string (buffer, " : "); - dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false); + dump_generic_node (pp, gimple_assign_rhs1 (gs), spc, flags, false); + pp_string (pp, " ? "); + dump_generic_node (pp, gimple_assign_rhs2 (gs), spc, flags, false); + pp_string (pp, " : "); + dump_generic_node (pp, gimple_assign_rhs3 (gs), spc, flags, false); break; case VEC_COND_EXPR: - pp_string (buffer, "VEC_COND_EXPR <"); - dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); - pp_string (buffer, ", "); - dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false); - pp_string (buffer, ", "); - dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false); - pp_greater (buffer); + pp_string (pp, "VEC_COND_EXPR <"); + dump_generic_node (pp, gimple_assign_rhs1 (gs), spc, flags, false); + pp_string (pp, ", "); + dump_generic_node (pp, gimple_assign_rhs2 (gs), spc, flags, false); + pp_string (pp, ", "); + dump_generic_node (pp, gimple_assign_rhs3 (gs), spc, flags, false); + pp_greater (pp); break; case BIT_INSERT_EXPR: if (flags & TDF_GIMPLE) { - pp_string (buffer, "__BIT_INSERT ("); - dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, + pp_string (pp, "__BIT_INSERT ("); + dump_generic_node (pp, gimple_assign_rhs1 (gs), spc, flags | TDF_SLIM, false); - pp_string (buffer, ", "); - dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, + pp_string (pp, ", "); + dump_generic_node (pp, gimple_assign_rhs2 (gs), spc, flags | TDF_SLIM, false); - pp_string (buffer, ", "); - dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, + pp_string (pp, ", "); + dump_generic_node (pp, gimple_assign_rhs3 (gs), spc, flags | TDF_SLIM, false); - pp_right_paren (buffer); + pp_right_paren (pp); } else { - pp_string (buffer, "BIT_INSERT_EXPR <"); - dump_generic_node (buffer, gimple_assign_rhs1 (gs), + pp_string (pp, "BIT_INSERT_EXPR <"); + dump_generic_node (pp, gimple_assign_rhs1 (gs), spc, flags, false); - pp_string (buffer, ", "); - dump_generic_node (buffer, gimple_assign_rhs2 (gs), + pp_string (pp, ", "); + dump_generic_node (pp, gimple_assign_rhs2 (gs), spc, flags, false); - pp_string (buffer, ", "); - dump_generic_node (buffer, gimple_assign_rhs3 (gs), + pp_string (pp, ", "); + dump_generic_node (pp, gimple_assign_rhs3 (gs), spc, flags, false); if (INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_rhs2 (gs)))) { - pp_string (buffer, " ("); - pp_decimal_int (buffer, TYPE_PRECISION + pp_string (pp, " ("); + pp_decimal_int (pp, TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs2 (gs)))); - pp_string (buffer, " bits)"); + pp_string (pp, " bits)"); } - pp_greater (buffer); + pp_greater (pp); } break; @@ -624,11 +624,11 @@ dump_ternary_rhs (pretty_printer *buffer, const gassign *gs, int spc, } -/* Dump the gimple assignment GS. BUFFER, SPC and FLAGS are as in +/* Dump the gimple assignment GS. PP, SPC and FLAGS are as in pp_gimple_stmt_1. */ static void -dump_gimple_assign (pretty_printer *buffer, const gassign *gs, int spc, +dump_gimple_assign (pretty_printer *pp, const gassign *gs, int spc, dump_flags_t flags) { if (flags & TDF_RAW) @@ -651,7 +651,7 @@ dump_gimple_assign (pretty_printer *buffer, const gassign *gs, int spc, gcc_unreachable (); } - dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs, + dump_gimple_fmt (pp, spc, flags, "%G <%s, %T, %T, %T, %T>", gs, get_tree_code_name (gimple_assign_rhs_code (gs)), gimple_assign_lhs (gs), arg1, arg2, arg3); } @@ -659,70 +659,70 @@ dump_gimple_assign (pretty_printer *buffer, const gassign *gs, int spc, { if (!(flags & TDF_RHS_ONLY)) { - dump_generic_node (buffer, gimple_assign_lhs (gs), spc, flags, false); - pp_space (buffer); - pp_equal (buffer); + dump_generic_node (pp, gimple_assign_lhs (gs), spc, flags, false); + pp_space (pp); + pp_equal (pp); if (gimple_assign_nontemporal_move_p (gs)) - pp_string (buffer, "{nt}"); + pp_string (pp, "{nt}"); if (gimple_has_volatile_ops (gs)) - pp_string (buffer, "{v}"); + pp_string (pp, "{v}"); - pp_space (buffer); + pp_space (pp); } if (gimple_num_ops (gs) == 2) - dump_unary_rhs (buffer, gs, spc, + dump_unary_rhs (pp, gs, spc, ((flags & TDF_GIMPLE) && gimple_assign_rhs_class (gs) != GIMPLE_SINGLE_RHS) ? (flags | TDF_GIMPLE_VAL) : flags); else if (gimple_num_ops (gs) == 3) - dump_binary_rhs (buffer, gs, spc, + dump_binary_rhs (pp, gs, spc, (flags & TDF_GIMPLE) ? (flags | TDF_GIMPLE_VAL) : flags); else if (gimple_num_ops (gs) == 4) - dump_ternary_rhs (buffer, gs, spc, + dump_ternary_rhs (pp, gs, spc, (flags & TDF_GIMPLE) ? (flags | TDF_GIMPLE_VAL) : flags); else gcc_unreachable (); if (!(flags & TDF_RHS_ONLY)) - pp_semicolon (buffer); + pp_semicolon (pp); } } -/* Dump the return statement GS. BUFFER, SPC and FLAGS are as in +/* Dump the return statement GS. PP, SPC and FLAGS are as in pp_gimple_stmt_1. */ static void -dump_gimple_return (pretty_printer *buffer, const greturn *gs, int spc, +dump_gimple_return (pretty_printer *pp, const greturn *gs, int spc, dump_flags_t flags) { tree t; t = gimple_return_retval (gs); if (flags & TDF_RAW) - dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, t); + dump_gimple_fmt (pp, spc, flags, "%G <%T>", gs, t); else { - pp_string (buffer, "return"); + pp_string (pp, "return"); if (t) { - pp_space (buffer); - dump_generic_node (buffer, t, spc, flags, false); + pp_space (pp); + dump_generic_node (pp, t, spc, flags, false); } - pp_semicolon (buffer); + pp_semicolon (pp); } } -/* Dump the call arguments for a gimple call. BUFFER, FLAGS are as in +/* Dump the call arguments for a gimple call. PP, FLAGS are as in dump_gimple_call. */ static void -dump_gimple_call_args (pretty_printer *buffer, const gcall *gs, +dump_gimple_call_args (pretty_printer *pp, const gcall *gs, dump_flags_t flags) { size_t i = 0; @@ -783,7 +783,7 @@ dump_gimple_call_args (pretty_printer *buffer, const gcall *gs, && (v = tree_to_shwi (arg0)) >= 0 && v < limit) { i++; - pp_string (buffer, enums[v]); + pp_string (pp, enums[v]); } } } @@ -791,52 +791,52 @@ dump_gimple_call_args (pretty_printer *buffer, const gcall *gs, for (; i < gimple_call_num_args (gs); i++) { if (i) - pp_string (buffer, ", "); - dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false); + pp_string (pp, ", "); + dump_generic_node (pp, gimple_call_arg (gs, i), 0, flags, false); } if (gimple_call_va_arg_pack_p (gs)) { if (i) - pp_string (buffer, ", "); + pp_string (pp, ", "); - pp_string (buffer, "__builtin_va_arg_pack ()"); + pp_string (pp, "__builtin_va_arg_pack ()"); } } -/* Dump the points-to solution *PT to BUFFER. */ +/* Dump the points-to solution *PT to PP. */ static void -pp_points_to_solution (pretty_printer *buffer, const pt_solution *pt) +pp_points_to_solution (pretty_printer *pp, const pt_solution *pt) { if (pt->anything) { - pp_string (buffer, "anything "); + pp_string (pp, "anything "); return; } if (pt->nonlocal) - pp_string (buffer, "nonlocal "); + pp_string (pp, "nonlocal "); if (pt->escaped) - pp_string (buffer, "escaped "); + pp_string (pp, "escaped "); if (pt->ipa_escaped) - pp_string (buffer, "unit-escaped "); + pp_string (pp, "unit-escaped "); if (pt->null) - pp_string (buffer, "null "); + pp_string (pp, "null "); if (pt->const_pool) - pp_string (buffer, "const-pool "); + pp_string (pp, "const-pool "); if (pt->vars && !bitmap_empty_p (pt->vars)) { bitmap_iterator bi; unsigned i; - pp_string (buffer, "{ "); + pp_string (pp, "{ "); EXECUTE_IF_SET_IN_BITMAP (pt->vars, 0, i, bi) { - pp_string (buffer, "D."); - pp_decimal_int (buffer, i); - pp_space (buffer); + pp_string (pp, "D."); + pp_decimal_int (pp, i); + pp_space (pp); } - pp_right_brace (buffer); + pp_right_brace (pp); if (pt->vars_contains_nonlocal || pt->vars_contains_escaped || pt->vars_contains_escaped_heap @@ -844,46 +844,46 @@ pp_points_to_solution (pretty_printer *buffer, const pt_solution *pt) || pt->vars_contains_interposable) { const char *comma = ""; - pp_string (buffer, " ("); + pp_string (pp, " ("); if (pt->vars_contains_nonlocal) { - pp_string (buffer, "nonlocal"); + pp_string (pp, "nonlocal"); comma = ", "; } if (pt->vars_contains_escaped) { - pp_string (buffer, comma); - pp_string (buffer, "escaped"); + pp_string (pp, comma); + pp_string (pp, "escaped"); comma = ", "; } if (pt->vars_contains_escaped_heap) { - pp_string (buffer, comma); - pp_string (buffer, "escaped heap"); + pp_string (pp, comma); + pp_string (pp, "escaped heap"); comma = ", "; } if (pt->vars_contains_restrict) { - pp_string (buffer, comma); - pp_string (buffer, "restrict"); + pp_string (pp, comma); + pp_string (pp, "restrict"); comma = ", "; } if (pt->vars_contains_interposable) { - pp_string (buffer, comma); - pp_string (buffer, "interposable"); + pp_string (pp, comma); + pp_string (pp, "interposable"); } - pp_string (buffer, ")"); + pp_string (pp, ")"); } } } -/* Dump the call statement GS. BUFFER, SPC and FLAGS are as in +/* Dump the call statement GS. PP, SPC and FLAGS are as in pp_gimple_stmt_1. */ static void -dump_gimple_call (pretty_printer *buffer, const gcall *gs, int spc, +dump_gimple_call (pretty_printer *pp, const gcall *gs, int spc, dump_flags_t flags) { tree lhs = gimple_call_lhs (gs); @@ -895,72 +895,72 @@ dump_gimple_call (pretty_printer *buffer, const gcall *gs, int spc, pt = gimple_call_use_set (gs); if (!pt_solution_empty_p (pt)) { - pp_string (buffer, "# USE = "); - pp_points_to_solution (buffer, pt); - newline_and_indent (buffer, spc); + pp_string (pp, "# USE = "); + pp_points_to_solution (pp, pt); + newline_and_indent (pp, spc); } pt = gimple_call_clobber_set (gs); if (!pt_solution_empty_p (pt)) { - pp_string (buffer, "# CLB = "); - pp_points_to_solution (buffer, pt); - newline_and_indent (buffer, spc); + pp_string (pp, "# CLB = "); + pp_points_to_solution (pp, pt); + newline_and_indent (pp, spc); } } if (flags & TDF_RAW) { if (gimple_call_internal_p (gs)) - dump_gimple_fmt (buffer, spc, flags, "%G <.%s, %T", gs, + dump_gimple_fmt (pp, spc, flags, "%G <.%s, %T", gs, internal_fn_name (gimple_call_internal_fn (gs)), lhs); else - dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs); + dump_gimple_fmt (pp, spc, flags, "%G <%T, %T", gs, fn, lhs); if (gimple_call_num_args (gs) > 0) { - pp_string (buffer, ", "); - dump_gimple_call_args (buffer, gs, flags); + pp_string (pp, ", "); + dump_gimple_call_args (pp, gs, flags); } - pp_greater (buffer); + pp_greater (pp); } else { if (lhs && !(flags & TDF_RHS_ONLY)) { - dump_generic_node (buffer, lhs, spc, flags, false); - pp_string (buffer, " ="); + dump_generic_node (pp, lhs, spc, flags, false); + pp_string (pp, " ="); if (gimple_has_volatile_ops (gs)) - pp_string (buffer, "{v}"); + pp_string (pp, "{v}"); - pp_space (buffer); + pp_space (pp); } if (gimple_call_internal_p (gs)) { - pp_dot (buffer); - pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs))); + pp_dot (pp); + pp_string (pp, internal_fn_name (gimple_call_internal_fn (gs))); } else - print_call_name (buffer, fn, flags); - pp_string (buffer, " ("); - dump_gimple_call_args (buffer, gs, flags); - pp_right_paren (buffer); + print_call_name (pp, fn, flags); + pp_string (pp, " ("); + dump_gimple_call_args (pp, gs, flags); + pp_right_paren (pp); if (!(flags & TDF_RHS_ONLY)) - pp_semicolon (buffer); + pp_semicolon (pp); } if (gimple_call_chain (gs)) { - pp_string (buffer, " [static-chain: "); - dump_generic_node (buffer, gimple_call_chain (gs), spc, flags, false); - pp_right_bracket (buffer); + pp_string (pp, " [static-chain: "); + dump_generic_node (pp, gimple_call_chain (gs), spc, flags, false); + pp_right_bracket (pp); } if (gimple_call_return_slot_opt_p (gs)) - pp_string (buffer, " [return slot optimization]"); + pp_string (pp, " [return slot optimization]"); if (gimple_call_tail_p (gs)) - pp_string (buffer, " [tail call]"); + pp_string (pp, " [tail call]"); if (gimple_call_must_tail_p (gs)) - pp_string (buffer, " [must tail call]"); + pp_string (pp, " [must tail call]"); if (fn == NULL) return; @@ -969,7 +969,7 @@ dump_gimple_call (pretty_printer *buffer, const gcall *gs, int spc, if (TREE_CODE (fn) == ADDR_EXPR) fn = TREE_OPERAND (fn, 0); if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn)) - pp_string (buffer, " [tm-clone]"); + pp_string (pp, " [tm-clone]"); if (TREE_CODE (fn) == FUNCTION_DECL && fndecl_built_in_p (fn, BUILT_IN_TM_START) && gimple_call_num_args (gs) > 0) @@ -978,76 +978,76 @@ dump_gimple_call (pretty_printer *buffer, const gcall *gs, int spc, unsigned HOST_WIDE_INT props; gcc_assert (TREE_CODE (t) == INTEGER_CST); - pp_string (buffer, " [ "); + pp_string (pp, " [ "); /* Get the transaction code properties. */ props = TREE_INT_CST_LOW (t); if (props & PR_INSTRUMENTEDCODE) - pp_string (buffer, "instrumentedCode "); + pp_string (pp, "instrumentedCode "); if (props & PR_UNINSTRUMENTEDCODE) - pp_string (buffer, "uninstrumentedCode "); + pp_string (pp, "uninstrumentedCode "); if (props & PR_HASNOXMMUPDATE) - pp_string (buffer, "hasNoXMMUpdate "); + pp_string (pp, "hasNoXMMUpdate "); if (props & PR_HASNOABORT) - pp_string (buffer, "hasNoAbort "); + pp_string (pp, "hasNoAbort "); if (props & PR_HASNOIRREVOCABLE) - pp_string (buffer, "hasNoIrrevocable "); + pp_string (pp, "hasNoIrrevocable "); if (props & PR_DOESGOIRREVOCABLE) - pp_string (buffer, "doesGoIrrevocable "); + pp_string (pp, "doesGoIrrevocable "); if (props & PR_HASNOSIMPLEREADS) - pp_string (buffer, "hasNoSimpleReads "); + pp_string (pp, "hasNoSimpleReads "); if (props & PR_AWBARRIERSOMITTED) - pp_string (buffer, "awBarriersOmitted "); + pp_string (pp, "awBarriersOmitted "); if (props & PR_RARBARRIERSOMITTED) - pp_string (buffer, "RaRBarriersOmitted "); + pp_string (pp, "RaRBarriersOmitted "); if (props & PR_UNDOLOGCODE) - pp_string (buffer, "undoLogCode "); + pp_string (pp, "undoLogCode "); if (props & PR_PREFERUNINSTRUMENTED) - pp_string (buffer, "preferUninstrumented "); + pp_string (pp, "preferUninstrumented "); if (props & PR_EXCEPTIONBLOCK) - pp_string (buffer, "exceptionBlock "); + pp_string (pp, "exceptionBlock "); if (props & PR_HASELSE) - pp_string (buffer, "hasElse "); + pp_string (pp, "hasElse "); if (props & PR_READONLY) - pp_string (buffer, "readOnly "); + pp_string (pp, "readOnly "); - pp_right_bracket (buffer); + pp_right_bracket (pp); } } -/* Dump the switch statement GS. BUFFER, SPC and FLAGS are as in +/* Dump the switch statement GS. PP, SPC and FLAGS are as in pp_gimple_stmt_1. */ static void -dump_gimple_switch (pretty_printer *buffer, const gswitch *gs, int spc, +dump_gimple_switch (pretty_printer *pp, const gswitch *gs, int spc, dump_flags_t flags) { unsigned int i; GIMPLE_CHECK (gs, GIMPLE_SWITCH); if (flags & TDF_RAW) - dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", gs, + dump_gimple_fmt (pp, spc, flags, "%G <%T, ", gs, gimple_switch_index (gs)); else { - pp_string (buffer, "switch ("); - dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true); + pp_string (pp, "switch ("); + dump_generic_node (pp, gimple_switch_index (gs), spc, flags, true); if (flags & TDF_GIMPLE) - pp_string (buffer, ") {"); + pp_string (pp, ") {"); else - pp_string (buffer, ") <"); + pp_string (pp, ") <"); } for (i = 0; i < gimple_switch_num_labels (gs); i++) { tree case_label = gimple_switch_label (gs, i); gcc_checking_assert (case_label != NULL_TREE); - dump_generic_node (buffer, case_label, spc, flags, false); - pp_space (buffer); + dump_generic_node (pp, case_label, spc, flags, false); + pp_space (pp); tree label = CASE_LABEL (case_label); - dump_generic_node (buffer, label, spc, flags, false); + dump_generic_node (pp, label, spc, flags, false); if (cfun && cfun->cfg) { @@ -1056,48 +1056,48 @@ dump_gimple_switch (pretty_printer *buffer, const gswitch *gs, int spc, { edge label_edge = find_edge (gimple_bb (gs), dest); if (label_edge && !(flags & TDF_GIMPLE)) - dump_edge_probability (buffer, label_edge); + dump_edge_probability (pp, label_edge); } } if (i < gimple_switch_num_labels (gs) - 1) { if (flags & TDF_GIMPLE) - pp_string (buffer, "; "); + pp_string (pp, "; "); else - pp_string (buffer, ", "); + pp_string (pp, ", "); } } if (flags & TDF_GIMPLE) - pp_string (buffer, "; }"); + pp_string (pp, "; }"); else - pp_greater (buffer); + pp_greater (pp); } -/* Dump the gimple conditional GS. BUFFER, SPC and FLAGS are as in +/* Dump the gimple conditional GS. PP, SPC and FLAGS are as in pp_gimple_stmt_1. */ static void -dump_gimple_cond (pretty_printer *buffer, const gcond *gs, int spc, +dump_gimple_cond (pretty_printer *pp, const gcond *gs, int spc, dump_flags_t flags) { if (flags & TDF_RAW) - dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs, + dump_gimple_fmt (pp, spc, flags, "%G <%s, %T, %T, %T, %T>", gs, get_tree_code_name (gimple_cond_code (gs)), gimple_cond_lhs (gs), gimple_cond_rhs (gs), gimple_cond_true_label (gs), gimple_cond_false_label (gs)); else { if (!(flags & TDF_RHS_ONLY)) - pp_string (buffer, "if ("); - dump_generic_node (buffer, gimple_cond_lhs (gs), spc, + pp_string (pp, "if ("); + dump_generic_node (pp, gimple_cond_lhs (gs), spc, flags | ((flags & TDF_GIMPLE) ? TDF_GIMPLE_VAL : TDF_NONE), false); - pp_space (buffer); - pp_string (buffer, op_symbol_code (gimple_cond_code (gs), flags)); - pp_space (buffer); - dump_generic_node (buffer, gimple_cond_rhs (gs), spc, + pp_space (pp); + pp_string (pp, op_symbol_code (gimple_cond_code (gs), flags)); + pp_space (pp); + dump_generic_node (pp, gimple_cond_rhs (gs), spc, flags | ((flags & TDF_GIMPLE) ? TDF_GIMPLE_VAL : TDF_NONE), false); if (!(flags & TDF_RHS_ONLY)) @@ -1119,112 +1119,112 @@ dump_gimple_cond (pretty_printer *buffer, const gcond *gs, int spc, bool has_edge_info = true_edge != NULL && false_edge != NULL; - pp_right_paren (buffer); + pp_right_paren (pp); if (gimple_cond_true_label (gs)) { - pp_string (buffer, " goto "); - dump_generic_node (buffer, gimple_cond_true_label (gs), + pp_string (pp, " goto "); + dump_generic_node (pp, gimple_cond_true_label (gs), spc, flags, false); if (has_edge_info && !(flags & TDF_GIMPLE)) - dump_edge_probability (buffer, true_edge); - pp_semicolon (buffer); + dump_edge_probability (pp, true_edge); + pp_semicolon (pp); } if (gimple_cond_false_label (gs)) { - pp_string (buffer, " else goto "); - dump_generic_node (buffer, gimple_cond_false_label (gs), + pp_string (pp, " else goto "); + dump_generic_node (pp, gimple_cond_false_label (gs), spc, flags, false); if (has_edge_info && !(flags & TDF_GIMPLE)) - dump_edge_probability (buffer, false_edge); + dump_edge_probability (pp, false_edge); - pp_semicolon (buffer); + pp_semicolon (pp); } } } } -/* Dump a GIMPLE_LABEL tuple on the pretty_printer BUFFER, SPC +/* Dump a GIMPLE_LABEL tuple on the pretty_printer PP, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in dumpfils.h). */ static void -dump_gimple_label (pretty_printer *buffer, const glabel *gs, int spc, +dump_gimple_label (pretty_printer *pp, const glabel *gs, int spc, dump_flags_t flags) { tree label = gimple_label_label (gs); if (flags & TDF_RAW) - dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label); + dump_gimple_fmt (pp, spc, flags, "%G <%T>", gs, label); else { - dump_generic_node (buffer, label, spc, flags, false); - pp_colon (buffer); + dump_generic_node (pp, label, spc, flags, false); + pp_colon (pp); } if (flags & TDF_GIMPLE) return; if (DECL_NONLOCAL (label)) - pp_string (buffer, " [non-local]"); + pp_string (pp, " [non-local]"); if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label)) - pp_printf (buffer, " [LP %d]", EH_LANDING_PAD_NR (label)); + pp_printf (pp, " [LP %d]", EH_LANDING_PAD_NR (label)); } -/* Dump a GIMPLE_GOTO tuple on the pretty_printer BUFFER, SPC +/* Dump a GIMPLE_GOTO tuple on the pretty_printer PP, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in dumpfile.h). */ static void -dump_gimple_goto (pretty_printer *buffer, const ggoto *gs, int spc, +dump_gimple_goto (pretty_printer *pp, const ggoto *gs, int spc, dump_flags_t flags) { tree label = gimple_goto_dest (gs); if (flags & TDF_RAW) - dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label); + dump_gimple_fmt (pp, spc, flags, "%G <%T>", gs, label); else - dump_gimple_fmt (buffer, spc, flags, "goto %T;", label); + dump_gimple_fmt (pp, spc, flags, "goto %T;", label); } -/* Dump a GIMPLE_BIND tuple on the pretty_printer BUFFER, SPC +/* Dump a GIMPLE_BIND tuple on the pretty_printer PP, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in dumpfile.h). */ static void -dump_gimple_bind (pretty_printer *buffer, const gbind *gs, int spc, +dump_gimple_bind (pretty_printer *pp, const gbind *gs, int spc, dump_flags_t flags) { if (flags & TDF_RAW) - dump_gimple_fmt (buffer, spc, flags, "%G <", gs); + dump_gimple_fmt (pp, spc, flags, "%G <", gs); else - pp_left_brace (buffer); + pp_left_brace (pp); if (!(flags & TDF_SLIM)) { tree var; for (var = gimple_bind_vars (gs); var; var = DECL_CHAIN (var)) { - newline_and_indent (buffer, 2); - print_declaration (buffer, var, spc, flags); + newline_and_indent (pp, 2); + print_declaration (pp, var, spc, flags); } if (gimple_bind_vars (gs)) - pp_newline (buffer); + pp_newline (pp); } - pp_newline (buffer); - dump_gimple_seq (buffer, gimple_bind_body (gs), spc + 2, flags); - newline_and_indent (buffer, spc); + pp_newline (pp); + dump_gimple_seq (pp, gimple_bind_body (gs), spc + 2, flags); + newline_and_indent (pp, spc); if (flags & TDF_RAW) - pp_greater (buffer); + pp_greater (pp); else - pp_right_brace (buffer); + pp_right_brace (pp); } -/* Dump a GIMPLE_TRY tuple on the pretty_printer BUFFER, SPC spaces of +/* Dump a GIMPLE_TRY tuple on the pretty_printer PP, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in dumpfile.h). */ static void -dump_gimple_try (pretty_printer *buffer, const gtry *gs, int spc, +dump_gimple_try (pretty_printer *pp, const gtry *gs, int spc, dump_flags_t flags) { if (flags & TDF_RAW) @@ -1236,95 +1236,95 @@ dump_gimple_try (pretty_printer *buffer, const gtry *gs, int spc, type = "GIMPLE_TRY_FINALLY"; else type = "UNKNOWN GIMPLE_TRY"; - dump_gimple_fmt (buffer, spc, flags, + dump_gimple_fmt (pp, spc, flags, "%G <%s,%+EVAL <%S>%nCLEANUP <%S>%->", gs, type, gimple_try_eval (gs), gimple_try_cleanup (gs)); } else { - pp_string (buffer, "try"); - newline_and_indent (buffer, spc + 2); - pp_left_brace (buffer); - pp_newline (buffer); + pp_string (pp, "try"); + newline_and_indent (pp, spc + 2); + pp_left_brace (pp); + pp_newline (pp); - dump_gimple_seq (buffer, gimple_try_eval (gs), spc + 4, flags); - newline_and_indent (buffer, spc + 2); - pp_right_brace (buffer); + dump_gimple_seq (pp, gimple_try_eval (gs), spc + 4, flags); + newline_and_indent (pp, spc + 2); + pp_right_brace (pp); gimple_seq seq = gimple_try_cleanup (gs); if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH) { - newline_and_indent (buffer, spc); - pp_string (buffer, "catch"); - newline_and_indent (buffer, spc + 2); - pp_left_brace (buffer); + newline_and_indent (pp, spc); + pp_string (pp, "catch"); + newline_and_indent (pp, spc + 2); + pp_left_brace (pp); } else if (gimple_try_kind (gs) == GIMPLE_TRY_FINALLY) { - newline_and_indent (buffer, spc); - pp_string (buffer, "finally"); - newline_and_indent (buffer, spc + 2); - pp_left_brace (buffer); + newline_and_indent (pp, spc); + pp_string (pp, "finally"); + newline_and_indent (pp, spc + 2); + pp_left_brace (pp); if (seq && is_a (gimple_seq_first_stmt (seq)) && gimple_seq_nondebug_singleton_p (seq)) { geh_else *stmt = as_a (gimple_seq_first_stmt (seq)); seq = gimple_eh_else_n_body (stmt); - pp_newline (buffer); - dump_gimple_seq (buffer, seq, spc + 4, flags); - newline_and_indent (buffer, spc + 2); - pp_right_brace (buffer); + pp_newline (pp); + dump_gimple_seq (pp, seq, spc + 4, flags); + newline_and_indent (pp, spc + 2); + pp_right_brace (pp); seq = gimple_eh_else_e_body (stmt); - newline_and_indent (buffer, spc); - pp_string (buffer, "else"); - newline_and_indent (buffer, spc + 2); - pp_left_brace (buffer); + newline_and_indent (pp, spc); + pp_string (pp, "else"); + newline_and_indent (pp, spc + 2); + pp_left_brace (pp); } } else - pp_string (buffer, " {"); + pp_string (pp, " {"); - pp_newline (buffer); - dump_gimple_seq (buffer, seq, spc + 4, flags); - newline_and_indent (buffer, spc + 2); - pp_right_brace (buffer); + pp_newline (pp); + dump_gimple_seq (pp, seq, spc + 4, flags); + newline_and_indent (pp, spc + 2); + pp_right_brace (pp); } } -/* Dump a GIMPLE_CATCH tuple on the pretty_printer BUFFER, SPC spaces of +/* Dump a GIMPLE_CATCH tuple on the pretty_printer PP, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in dumpfile.h). */ static void -dump_gimple_catch (pretty_printer *buffer, const gcatch *gs, int spc, +dump_gimple_catch (pretty_printer *pp, const gcatch *gs, int spc, dump_flags_t flags) { if (flags & TDF_RAW) - dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs, + dump_gimple_fmt (pp, spc, flags, "%G <%T, %+CATCH <%S>%->", gs, gimple_catch_types (gs), gimple_catch_handler (gs)); else - dump_gimple_fmt (buffer, spc, flags, "catch (%T)%+{%S}", + dump_gimple_fmt (pp, spc, flags, "catch (%T)%+{%S}", gimple_catch_types (gs), gimple_catch_handler (gs)); } -/* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer BUFFER, SPC spaces of +/* Dump a GIMPLE_EH_FILTER tuple on the pretty_printer PP, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in dumpfile.h). */ static void -dump_gimple_eh_filter (pretty_printer *buffer, const geh_filter *gs, int spc, +dump_gimple_eh_filter (pretty_printer *pp, const geh_filter *gs, int spc, dump_flags_t flags) { if (flags & TDF_RAW) - dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs, + dump_gimple_fmt (pp, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs, gimple_eh_filter_types (gs), gimple_eh_filter_failure (gs)); else - dump_gimple_fmt (buffer, spc, flags, "<<>>%+{%+%S%-}", + dump_gimple_fmt (pp, spc, flags, "<<>>%+{%+%S%-}", gimple_eh_filter_types (gs), gimple_eh_filter_failure (gs)); } @@ -1333,113 +1333,113 @@ dump_gimple_eh_filter (pretty_printer *buffer, const geh_filter *gs, int spc, /* Dump a GIMPLE_EH_MUST_NOT_THROW tuple. */ static void -dump_gimple_eh_must_not_throw (pretty_printer *buffer, +dump_gimple_eh_must_not_throw (pretty_printer *pp, const geh_mnt *gs, int spc, dump_flags_t flags) { if (flags & TDF_RAW) - dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, + dump_gimple_fmt (pp, spc, flags, "%G <%T>", gs, gimple_eh_must_not_throw_fndecl (gs)); else - dump_gimple_fmt (buffer, spc, flags, "<<>>", + dump_gimple_fmt (pp, spc, flags, "<<>>", gimple_eh_must_not_throw_fndecl (gs)); } -/* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer BUFFER, SPC spaces of +/* Dump a GIMPLE_EH_ELSE tuple on the pretty_printer PP, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in dumpfile.h). */ static void -dump_gimple_eh_else (pretty_printer *buffer, const geh_else *gs, int spc, +dump_gimple_eh_else (pretty_printer *pp, const geh_else *gs, int spc, dump_flags_t flags) { if (flags & TDF_RAW) - dump_gimple_fmt (buffer, spc, flags, + dump_gimple_fmt (pp, spc, flags, "%G <%+N_BODY <%S>%nE_BODY <%S>%->", gs, gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs)); else - dump_gimple_fmt (buffer, spc, flags, + dump_gimple_fmt (pp, spc, flags, "<<>>%+{%S}%-<<>>%+{%S}", gimple_eh_else_n_body (gs), gimple_eh_else_e_body (gs)); } -/* Dump a GIMPLE_RESX tuple on the pretty_printer BUFFER, SPC spaces of +/* Dump a GIMPLE_RESX tuple on the pretty_printer PP, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in dumpfile.h). */ static void -dump_gimple_resx (pretty_printer *buffer, const gresx *gs, int spc, +dump_gimple_resx (pretty_printer *pp, const gresx *gs, int spc, dump_flags_t flags) { if (flags & TDF_RAW) - dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs, + dump_gimple_fmt (pp, spc, flags, "%G <%d>", gs, gimple_resx_region (gs)); else - dump_gimple_fmt (buffer, spc, flags, "resx %d", gimple_resx_region (gs)); + dump_gimple_fmt (pp, spc, flags, "resx %d", gimple_resx_region (gs)); } -/* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER. */ +/* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer PP. */ static void -dump_gimple_eh_dispatch (pretty_printer *buffer, const geh_dispatch *gs, +dump_gimple_eh_dispatch (pretty_printer *pp, const geh_dispatch *gs, int spc, dump_flags_t flags) { if (flags & TDF_RAW) - dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs, + dump_gimple_fmt (pp, spc, flags, "%G <%d>", gs, gimple_eh_dispatch_region (gs)); else - dump_gimple_fmt (buffer, spc, flags, "eh_dispatch %d", + dump_gimple_fmt (pp, spc, flags, "eh_dispatch %d", gimple_eh_dispatch_region (gs)); } -/* Dump a GIMPLE_DEBUG tuple on the pretty_printer BUFFER, SPC spaces +/* Dump a GIMPLE_DEBUG tuple on the pretty_printer PP, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in dumpfile.h). */ static void -dump_gimple_debug (pretty_printer *buffer, const gdebug *gs, int spc, +dump_gimple_debug (pretty_printer *pp, const gdebug *gs, int spc, dump_flags_t flags) { switch (gs->subcode) { case GIMPLE_DEBUG_BIND: if (flags & TDF_RAW) - dump_gimple_fmt (buffer, spc, flags, "%G BIND <%T, %T>", gs, + dump_gimple_fmt (pp, spc, flags, "%G BIND <%T, %T>", gs, gimple_debug_bind_get_var (gs), gimple_debug_bind_get_value (gs)); else - dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T => %T", + dump_gimple_fmt (pp, spc, flags, "# DEBUG %T => %T", gimple_debug_bind_get_var (gs), gimple_debug_bind_get_value (gs)); break; case GIMPLE_DEBUG_SOURCE_BIND: if (flags & TDF_RAW) - dump_gimple_fmt (buffer, spc, flags, "%G SRCBIND <%T, %T>", gs, + dump_gimple_fmt (pp, spc, flags, "%G SRCBIND <%T, %T>", gs, gimple_debug_source_bind_get_var (gs), gimple_debug_source_bind_get_value (gs)); else - dump_gimple_fmt (buffer, spc, flags, "# DEBUG %T s=> %T", + dump_gimple_fmt (pp, spc, flags, "# DEBUG %T s=> %T", gimple_debug_source_bind_get_var (gs), gimple_debug_source_bind_get_value (gs)); break; case GIMPLE_DEBUG_BEGIN_STMT: if (flags & TDF_RAW) - dump_gimple_fmt (buffer, spc, flags, "%G BEGIN_STMT", gs); + dump_gimple_fmt (pp, spc, flags, "%G BEGIN_STMT", gs); else - dump_gimple_fmt (buffer, spc, flags, "# DEBUG BEGIN_STMT"); + dump_gimple_fmt (pp, spc, flags, "# DEBUG BEGIN_STMT"); break; case GIMPLE_DEBUG_INLINE_ENTRY: if (flags & TDF_RAW) - dump_gimple_fmt (buffer, spc, flags, "%G INLINE_ENTRY %T", gs, + dump_gimple_fmt (pp, spc, flags, "%G INLINE_ENTRY %T", gs, gimple_block (gs) ? block_ultimate_origin (gimple_block (gs)) : NULL_TREE); else - dump_gimple_fmt (buffer, spc, flags, "# DEBUG INLINE_ENTRY %T", + dump_gimple_fmt (pp, spc, flags, "# DEBUG INLINE_ENTRY %T", gimple_block (gs) ? block_ultimate_origin (gimple_block (gs)) : NULL_TREE); @@ -1450,9 +1450,9 @@ dump_gimple_debug (pretty_printer *buffer, const gdebug *gs, int spc, } } -/* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER. */ +/* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer PP. */ static void -dump_gimple_omp_for (pretty_printer *buffer, const gomp_for *gs, int spc, +dump_gimple_omp_for (pretty_printer *pp, const gomp_for *gs, int spc, dump_flags_t flags) { size_t i; @@ -1480,19 +1480,19 @@ dump_gimple_omp_for (pretty_printer *buffer, const gomp_for *gs, int spc, default: gcc_unreachable (); } - dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs, + dump_gimple_fmt (pp, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs, kind, gimple_omp_body (gs)); - dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags); - dump_gimple_fmt (buffer, spc, flags, " >,"); + dump_omp_clauses (pp, gimple_omp_for_clauses (gs), spc, flags); + dump_gimple_fmt (pp, spc, flags, " >,"); for (i = 0; i < gimple_omp_for_collapse (gs); i++) - dump_gimple_fmt (buffer, spc, flags, + dump_gimple_fmt (pp, spc, flags, "%+%T, %T, %T, %s, %T,%n", gimple_omp_for_index (gs, i), gimple_omp_for_initial (gs, i), gimple_omp_for_final (gs, i), get_tree_code_name (gimple_omp_for_cond (gs, i)), gimple_omp_for_incr (gs, i)); - dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->", + dump_gimple_fmt (pp, spc, flags, "PRE_BODY <%S>%->", gimple_omp_for_pre_body (gs)); } else @@ -1500,236 +1500,236 @@ dump_gimple_omp_for (pretty_printer *buffer, const gomp_for *gs, int spc, switch (gimple_omp_for_kind (gs)) { case GF_OMP_FOR_KIND_FOR: - pp_string (buffer, "#pragma omp for"); + pp_string (pp, "#pragma omp for"); break; case GF_OMP_FOR_KIND_DISTRIBUTE: - pp_string (buffer, "#pragma omp distribute"); + pp_string (pp, "#pragma omp distribute"); break; case GF_OMP_FOR_KIND_TASKLOOP: - pp_string (buffer, "#pragma omp taskloop"); + pp_string (pp, "#pragma omp taskloop"); break; case GF_OMP_FOR_KIND_OACC_LOOP: - pp_string (buffer, "#pragma acc loop"); + pp_string (pp, "#pragma acc loop"); break; case GF_OMP_FOR_KIND_SIMD: - pp_string (buffer, "#pragma omp simd"); + pp_string (pp, "#pragma omp simd"); break; default: gcc_unreachable (); } - dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags); + dump_omp_clauses (pp, gimple_omp_for_clauses (gs), spc, flags); for (i = 0; i < gimple_omp_for_collapse (gs); i++) { if (i) spc += 2; - newline_and_indent (buffer, spc); - pp_string (buffer, "for ("); - dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc, + newline_and_indent (pp, spc); + pp_string (pp, "for ("); + dump_generic_node (pp, gimple_omp_for_index (gs, i), spc, flags, false); - pp_string (buffer, " = "); + pp_string (pp, " = "); tree init = gimple_omp_for_initial (gs, i); if (TREE_CODE (init) != TREE_VEC) - dump_generic_node (buffer, init, spc, flags, false); + dump_generic_node (pp, init, spc, flags, false); else - dump_omp_loop_non_rect_expr (buffer, init, spc, flags); - pp_string (buffer, "; "); + dump_omp_loop_non_rect_expr (pp, init, spc, flags); + pp_string (pp, "; "); - dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc, + dump_generic_node (pp, gimple_omp_for_index (gs, i), spc, flags, false); - pp_space (buffer); + pp_space (pp); switch (gimple_omp_for_cond (gs, i)) { case LT_EXPR: - pp_less (buffer); + pp_less (pp); break; case GT_EXPR: - pp_greater (buffer); + pp_greater (pp); break; case LE_EXPR: - pp_less_equal (buffer); + pp_less_equal (pp); break; case GE_EXPR: - pp_greater_equal (buffer); + pp_greater_equal (pp); break; case NE_EXPR: - pp_string (buffer, "!="); + pp_string (pp, "!="); break; default: gcc_unreachable (); } - pp_space (buffer); + pp_space (pp); tree cond = gimple_omp_for_final (gs, i); if (TREE_CODE (cond) != TREE_VEC) - dump_generic_node (buffer, cond, spc, flags, false); + dump_generic_node (pp, cond, spc, flags, false); else - dump_omp_loop_non_rect_expr (buffer, cond, spc, flags); - pp_string (buffer, "; "); + dump_omp_loop_non_rect_expr (pp, cond, spc, flags); + pp_string (pp, "; "); - dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc, + dump_generic_node (pp, gimple_omp_for_index (gs, i), spc, flags, false); - pp_string (buffer, " = "); - dump_generic_node (buffer, gimple_omp_for_incr (gs, i), spc, + pp_string (pp, " = "); + dump_generic_node (pp, gimple_omp_for_incr (gs, i), spc, flags, false); - pp_right_paren (buffer); + pp_right_paren (pp); } if (!gimple_seq_empty_p (gimple_omp_body (gs))) { - newline_and_indent (buffer, spc + 2); - pp_left_brace (buffer); - pp_newline (buffer); - dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags); - newline_and_indent (buffer, spc + 2); - pp_right_brace (buffer); + newline_and_indent (pp, spc + 2); + pp_left_brace (pp); + pp_newline (pp); + dump_gimple_seq (pp, gimple_omp_body (gs), spc + 4, flags); + newline_and_indent (pp, spc + 2); + pp_right_brace (pp); } } } -/* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER. */ +/* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer PP. */ static void -dump_gimple_omp_continue (pretty_printer *buffer, const gomp_continue *gs, +dump_gimple_omp_continue (pretty_printer *pp, const gomp_continue *gs, int spc, dump_flags_t flags) { if (flags & TDF_RAW) { - dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs, + dump_gimple_fmt (pp, spc, flags, "%G <%T, %T>", gs, gimple_omp_continue_control_def (gs), gimple_omp_continue_control_use (gs)); } else { - pp_string (buffer, "#pragma omp continue ("); - dump_generic_node (buffer, gimple_omp_continue_control_def (gs), + pp_string (pp, "#pragma omp continue ("); + dump_generic_node (pp, gimple_omp_continue_control_def (gs), spc, flags, false); - pp_comma (buffer); - pp_space (buffer); - dump_generic_node (buffer, gimple_omp_continue_control_use (gs), + pp_comma (pp); + pp_space (pp); + dump_generic_node (pp, gimple_omp_continue_control_use (gs), spc, flags, false); - pp_right_paren (buffer); + pp_right_paren (pp); } } -/* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER. */ +/* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer PP. */ static void -dump_gimple_omp_single (pretty_printer *buffer, const gomp_single *gs, +dump_gimple_omp_single (pretty_printer *pp, const gomp_single *gs, int spc, dump_flags_t flags) { if (flags & TDF_RAW) { - dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, + dump_gimple_fmt (pp, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, gimple_omp_body (gs)); - dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags); - dump_gimple_fmt (buffer, spc, flags, " >"); + dump_omp_clauses (pp, gimple_omp_single_clauses (gs), spc, flags); + dump_gimple_fmt (pp, spc, flags, " >"); } else { - pp_string (buffer, "#pragma omp single"); - dump_omp_clauses (buffer, gimple_omp_single_clauses (gs), spc, flags); + pp_string (pp, "#pragma omp single"); + dump_omp_clauses (pp, gimple_omp_single_clauses (gs), spc, flags); if (!gimple_seq_empty_p (gimple_omp_body (gs))) { - newline_and_indent (buffer, spc + 2); - pp_left_brace (buffer); - pp_newline (buffer); - dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags); - newline_and_indent (buffer, spc + 2); - pp_right_brace (buffer); + newline_and_indent (pp, spc + 2); + pp_left_brace (pp); + pp_newline (pp); + dump_gimple_seq (pp, gimple_omp_body (gs), spc + 4, flags); + newline_and_indent (pp, spc + 2); + pp_right_brace (pp); } } } -/* Dump a GIMPLE_OMP_TASKGROUP tuple on the pretty_printer BUFFER. */ +/* Dump a GIMPLE_OMP_TASKGROUP tuple on the pretty_printer PP. */ static void -dump_gimple_omp_taskgroup (pretty_printer *buffer, const gimple *gs, +dump_gimple_omp_taskgroup (pretty_printer *pp, const gimple *gs, int spc, dump_flags_t flags) { if (flags & TDF_RAW) { - dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, + dump_gimple_fmt (pp, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, gimple_omp_body (gs)); - dump_omp_clauses (buffer, gimple_omp_taskgroup_clauses (gs), spc, flags); - dump_gimple_fmt (buffer, spc, flags, " >"); + dump_omp_clauses (pp, gimple_omp_taskgroup_clauses (gs), spc, flags); + dump_gimple_fmt (pp, spc, flags, " >"); } else { - pp_string (buffer, "#pragma omp taskgroup"); - dump_omp_clauses (buffer, gimple_omp_taskgroup_clauses (gs), spc, flags); + pp_string (pp, "#pragma omp taskgroup"); + dump_omp_clauses (pp, gimple_omp_taskgroup_clauses (gs), spc, flags); if (!gimple_seq_empty_p (gimple_omp_body (gs))) { - newline_and_indent (buffer, spc + 2); - pp_left_brace (buffer); - pp_newline (buffer); - dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags); - newline_and_indent (buffer, spc + 2); - pp_right_brace (buffer); + newline_and_indent (pp, spc + 2); + pp_left_brace (pp); + pp_newline (pp); + dump_gimple_seq (pp, gimple_omp_body (gs), spc + 4, flags); + newline_and_indent (pp, spc + 2); + pp_right_brace (pp); } } } -/* Dump a GIMPLE_OMP_MASKED tuple on the pretty_printer BUFFER. */ +/* Dump a GIMPLE_OMP_MASKED tuple on the pretty_printer PP. */ static void -dump_gimple_omp_masked (pretty_printer *buffer, const gimple *gs, +dump_gimple_omp_masked (pretty_printer *pp, const gimple *gs, int spc, dump_flags_t flags) { if (flags & TDF_RAW) { - dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, + dump_gimple_fmt (pp, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, gimple_omp_body (gs)); - dump_omp_clauses (buffer, gimple_omp_masked_clauses (gs), spc, flags); - dump_gimple_fmt (buffer, spc, flags, " >"); + dump_omp_clauses (pp, gimple_omp_masked_clauses (gs), spc, flags); + dump_gimple_fmt (pp, spc, flags, " >"); } else { - pp_string (buffer, "#pragma omp masked"); - dump_omp_clauses (buffer, gimple_omp_masked_clauses (gs), spc, flags); + pp_string (pp, "#pragma omp masked"); + dump_omp_clauses (pp, gimple_omp_masked_clauses (gs), spc, flags); if (!gimple_seq_empty_p (gimple_omp_body (gs))) { - newline_and_indent (buffer, spc + 2); - pp_left_brace (buffer); - pp_newline (buffer); - dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags); - newline_and_indent (buffer, spc + 2); - pp_right_brace (buffer); + newline_and_indent (pp, spc + 2); + pp_left_brace (pp); + pp_newline (pp); + dump_gimple_seq (pp, gimple_omp_body (gs), spc + 4, flags); + newline_and_indent (pp, spc + 2); + pp_right_brace (pp); } } } -/* Dump a GIMPLE_OMP_SCOPE tuple on the pretty_printer BUFFER. */ +/* Dump a GIMPLE_OMP_SCOPE tuple on the pretty_printer PP. */ static void -dump_gimple_omp_scope (pretty_printer *buffer, const gimple *gs, +dump_gimple_omp_scope (pretty_printer *pp, const gimple *gs, int spc, dump_flags_t flags) { if (flags & TDF_RAW) { - dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, + dump_gimple_fmt (pp, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, gimple_omp_body (gs)); - dump_omp_clauses (buffer, gimple_omp_scope_clauses (gs), spc, flags); - dump_gimple_fmt (buffer, spc, flags, " >"); + dump_omp_clauses (pp, gimple_omp_scope_clauses (gs), spc, flags); + dump_gimple_fmt (pp, spc, flags, " >"); } else { - pp_string (buffer, "#pragma omp scope"); - dump_omp_clauses (buffer, gimple_omp_scope_clauses (gs), spc, flags); + pp_string (pp, "#pragma omp scope"); + dump_omp_clauses (pp, gimple_omp_scope_clauses (gs), spc, flags); if (!gimple_seq_empty_p (gimple_omp_body (gs))) { - newline_and_indent (buffer, spc + 2); - pp_left_brace (buffer); - pp_newline (buffer); - dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags); - newline_and_indent (buffer, spc + 2); - pp_right_brace (buffer); + newline_and_indent (pp, spc + 2); + pp_left_brace (pp); + pp_newline (pp); + dump_gimple_seq (pp, gimple_omp_body (gs), spc + 4, flags); + newline_and_indent (pp, spc + 2); + pp_right_brace (pp); } } } -/* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER. */ +/* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer PP. */ static void -dump_gimple_omp_target (pretty_printer *buffer, const gomp_target *gs, +dump_gimple_omp_target (pretty_printer *pp, const gomp_target *gs, int spc, dump_flags_t flags) { const char *kind; @@ -1791,304 +1791,304 @@ dump_gimple_omp_target (pretty_printer *buffer, const gomp_target *gs, } if (flags & TDF_RAW) { - dump_gimple_fmt (buffer, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs, + dump_gimple_fmt (pp, spc, flags, "%G%s <%+BODY <%S>%nCLAUSES <", gs, kind, gimple_omp_body (gs)); - dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags); - dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>", + dump_omp_clauses (pp, gimple_omp_target_clauses (gs), spc, flags); + dump_gimple_fmt (pp, spc, flags, " >, %T, %T%n>", gimple_omp_target_child_fn (gs), gimple_omp_target_data_arg (gs)); } else { - pp_string (buffer, "#pragma omp target"); - pp_string (buffer, kind); - dump_omp_clauses (buffer, gimple_omp_target_clauses (gs), spc, flags); + pp_string (pp, "#pragma omp target"); + pp_string (pp, kind); + dump_omp_clauses (pp, gimple_omp_target_clauses (gs), spc, flags); if (gimple_omp_target_child_fn (gs)) { - pp_string (buffer, " [child fn: "); - dump_generic_node (buffer, gimple_omp_target_child_fn (gs), + pp_string (pp, " [child fn: "); + dump_generic_node (pp, gimple_omp_target_child_fn (gs), spc, flags, false); - pp_string (buffer, " ("); + pp_string (pp, " ("); if (gimple_omp_target_data_arg (gs)) - dump_generic_node (buffer, gimple_omp_target_data_arg (gs), + dump_generic_node (pp, gimple_omp_target_data_arg (gs), spc, flags, false); else - pp_string (buffer, "???"); - pp_string (buffer, ")]"); + pp_string (pp, "???"); + pp_string (pp, ")]"); } gimple_seq body = gimple_omp_body (gs); if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND) { - newline_and_indent (buffer, spc + 2); - pp_left_brace (buffer); - pp_newline (buffer); - dump_gimple_seq (buffer, body, spc + 4, flags); - newline_and_indent (buffer, spc + 2); - pp_right_brace (buffer); + newline_and_indent (pp, spc + 2); + pp_left_brace (pp); + pp_newline (pp); + dump_gimple_seq (pp, body, spc + 4, flags); + newline_and_indent (pp, spc + 2); + pp_right_brace (pp); } else if (body) { - pp_newline (buffer); - dump_gimple_seq (buffer, body, spc + 2, flags); + pp_newline (pp); + dump_gimple_seq (pp, body, spc + 2, flags); } } } -/* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER. */ +/* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer PP. */ static void -dump_gimple_omp_teams (pretty_printer *buffer, const gomp_teams *gs, int spc, +dump_gimple_omp_teams (pretty_printer *pp, const gomp_teams *gs, int spc, dump_flags_t flags) { if (flags & TDF_RAW) { - dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, + dump_gimple_fmt (pp, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, gimple_omp_body (gs)); - dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags); - dump_gimple_fmt (buffer, spc, flags, " >"); + dump_omp_clauses (pp, gimple_omp_teams_clauses (gs), spc, flags); + dump_gimple_fmt (pp, spc, flags, " >"); } else { - pp_string (buffer, "#pragma omp teams"); - dump_omp_clauses (buffer, gimple_omp_teams_clauses (gs), spc, flags); + pp_string (pp, "#pragma omp teams"); + dump_omp_clauses (pp, gimple_omp_teams_clauses (gs), spc, flags); if (!gimple_seq_empty_p (gimple_omp_body (gs))) { - newline_and_indent (buffer, spc + 2); - pp_character (buffer, '{'); - pp_newline (buffer); - dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags); - newline_and_indent (buffer, spc + 2); - pp_character (buffer, '}'); + newline_and_indent (pp, spc + 2); + pp_character (pp, '{'); + pp_newline (pp); + dump_gimple_seq (pp, gimple_omp_body (gs), spc + 4, flags); + newline_and_indent (pp, spc + 2); + pp_character (pp, '}'); } } } -/* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER. */ +/* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer PP. */ static void -dump_gimple_omp_sections (pretty_printer *buffer, const gomp_sections *gs, +dump_gimple_omp_sections (pretty_printer *pp, const gomp_sections *gs, int spc, dump_flags_t flags) { if (flags & TDF_RAW) { - dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, + dump_gimple_fmt (pp, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, gimple_omp_body (gs)); - dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags); - dump_gimple_fmt (buffer, spc, flags, " >"); + dump_omp_clauses (pp, gimple_omp_sections_clauses (gs), spc, flags); + dump_gimple_fmt (pp, spc, flags, " >"); } else { - pp_string (buffer, "#pragma omp sections"); + pp_string (pp, "#pragma omp sections"); if (gimple_omp_sections_control (gs)) { - pp_string (buffer, " <"); - dump_generic_node (buffer, gimple_omp_sections_control (gs), spc, + pp_string (pp, " <"); + dump_generic_node (pp, gimple_omp_sections_control (gs), spc, flags, false); - pp_greater (buffer); + pp_greater (pp); } - dump_omp_clauses (buffer, gimple_omp_sections_clauses (gs), spc, flags); + dump_omp_clauses (pp, gimple_omp_sections_clauses (gs), spc, flags); if (!gimple_seq_empty_p (gimple_omp_body (gs))) { - newline_and_indent (buffer, spc + 2); - pp_left_brace (buffer); - pp_newline (buffer); - dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags); - newline_and_indent (buffer, spc + 2); - pp_right_brace (buffer); + newline_and_indent (pp, spc + 2); + pp_left_brace (pp); + pp_newline (pp); + dump_gimple_seq (pp, gimple_omp_body (gs), spc + 4, flags); + newline_and_indent (pp, spc + 2); + pp_right_brace (pp); } } } /* Dump a GIMPLE_OMP_{MASTER,ORDERED,SECTION,STRUCTURED_BLOCK} tuple on the - pretty_printer BUFFER. */ + pretty_printer PP. */ static void -dump_gimple_omp_block (pretty_printer *buffer, const gimple *gs, int spc, +dump_gimple_omp_block (pretty_printer *pp, const gimple *gs, int spc, dump_flags_t flags) { if (flags & TDF_RAW) - dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs, + dump_gimple_fmt (pp, spc, flags, "%G <%+BODY <%S> >", gs, gimple_omp_body (gs)); else { switch (gimple_code (gs)) { case GIMPLE_OMP_MASTER: - pp_string (buffer, "#pragma omp master"); + pp_string (pp, "#pragma omp master"); break; case GIMPLE_OMP_SECTION: - pp_string (buffer, "#pragma omp section"); + pp_string (pp, "#pragma omp section"); break; case GIMPLE_OMP_STRUCTURED_BLOCK: - pp_string (buffer, "#pragma omp __structured_block"); + pp_string (pp, "#pragma omp __structured_block"); break; default: gcc_unreachable (); } if (!gimple_seq_empty_p (gimple_omp_body (gs))) { - newline_and_indent (buffer, spc + 2); - pp_left_brace (buffer); - pp_newline (buffer); - dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags); - newline_and_indent (buffer, spc + 2); - pp_right_brace (buffer); + newline_and_indent (pp, spc + 2); + pp_left_brace (pp); + pp_newline (pp); + dump_gimple_seq (pp, gimple_omp_body (gs), spc + 4, flags); + newline_and_indent (pp, spc + 2); + pp_right_brace (pp); } } } -/* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER. */ +/* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer PP. */ static void -dump_gimple_omp_critical (pretty_printer *buffer, const gomp_critical *gs, +dump_gimple_omp_critical (pretty_printer *pp, const gomp_critical *gs, int spc, dump_flags_t flags) { if (flags & TDF_RAW) - dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs, + dump_gimple_fmt (pp, spc, flags, "%G <%+BODY <%S> >", gs, gimple_omp_body (gs)); else { - pp_string (buffer, "#pragma omp critical"); + pp_string (pp, "#pragma omp critical"); if (gimple_omp_critical_name (gs)) { - pp_string (buffer, " ("); - dump_generic_node (buffer, gimple_omp_critical_name (gs), spc, + pp_string (pp, " ("); + dump_generic_node (pp, gimple_omp_critical_name (gs), spc, flags, false); - pp_right_paren (buffer); + pp_right_paren (pp); } - dump_omp_clauses (buffer, gimple_omp_critical_clauses (gs), spc, flags); + dump_omp_clauses (pp, gimple_omp_critical_clauses (gs), spc, flags); if (!gimple_seq_empty_p (gimple_omp_body (gs))) { - newline_and_indent (buffer, spc + 2); - pp_left_brace (buffer); - pp_newline (buffer); - dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags); - newline_and_indent (buffer, spc + 2); - pp_right_brace (buffer); + newline_and_indent (pp, spc + 2); + pp_left_brace (pp); + pp_newline (pp); + dump_gimple_seq (pp, gimple_omp_body (gs), spc + 4, flags); + newline_and_indent (pp, spc + 2); + pp_right_brace (pp); } } } -/* Dump a GIMPLE_OMP_ORDERED tuple on the pretty_printer BUFFER. */ +/* Dump a GIMPLE_OMP_ORDERED tuple on the pretty_printer PP. */ static void -dump_gimple_omp_ordered (pretty_printer *buffer, const gomp_ordered *gs, +dump_gimple_omp_ordered (pretty_printer *pp, const gomp_ordered *gs, int spc, dump_flags_t flags) { if (flags & TDF_RAW) - dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs, + dump_gimple_fmt (pp, spc, flags, "%G <%+BODY <%S> >", gs, gimple_omp_body (gs)); else { - pp_string (buffer, "#pragma omp ordered"); - dump_omp_clauses (buffer, gimple_omp_ordered_clauses (gs), spc, flags); + pp_string (pp, "#pragma omp ordered"); + dump_omp_clauses (pp, gimple_omp_ordered_clauses (gs), spc, flags); if (!gimple_seq_empty_p (gimple_omp_body (gs))) { - newline_and_indent (buffer, spc + 2); - pp_left_brace (buffer); - pp_newline (buffer); - dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags); - newline_and_indent (buffer, spc + 2); - pp_right_brace (buffer); + newline_and_indent (pp, spc + 2); + pp_left_brace (pp); + pp_newline (pp); + dump_gimple_seq (pp, gimple_omp_body (gs), spc + 4, flags); + newline_and_indent (pp, spc + 2); + pp_right_brace (pp); } } } -/* Dump a GIMPLE_OMP_SCAN tuple on the pretty_printer BUFFER. */ +/* Dump a GIMPLE_OMP_SCAN tuple on the pretty_printer PP. */ static void -dump_gimple_omp_scan (pretty_printer *buffer, const gomp_scan *gs, +dump_gimple_omp_scan (pretty_printer *pp, const gomp_scan *gs, int spc, dump_flags_t flags) { if (flags & TDF_RAW) - dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs, + dump_gimple_fmt (pp, spc, flags, "%G <%+BODY <%S> >", gs, gimple_omp_body (gs)); else { if (gimple_omp_scan_clauses (gs)) { - pp_string (buffer, "#pragma omp scan"); - dump_omp_clauses (buffer, gimple_omp_scan_clauses (gs), spc, flags); + pp_string (pp, "#pragma omp scan"); + dump_omp_clauses (pp, gimple_omp_scan_clauses (gs), spc, flags); } if (!gimple_seq_empty_p (gimple_omp_body (gs))) { - newline_and_indent (buffer, spc + 2); - pp_left_brace (buffer); - pp_newline (buffer); - dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags); - newline_and_indent (buffer, spc + 2); - pp_right_brace (buffer); + newline_and_indent (pp, spc + 2); + pp_left_brace (pp); + pp_newline (pp); + dump_gimple_seq (pp, gimple_omp_body (gs), spc + 4, flags); + newline_and_indent (pp, spc + 2); + pp_right_brace (pp); } } } -/* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER. */ +/* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer PP. */ static void -dump_gimple_omp_return (pretty_printer *buffer, const gimple *gs, int spc, +dump_gimple_omp_return (pretty_printer *pp, const gimple *gs, int spc, dump_flags_t flags) { if (flags & TDF_RAW) { - dump_gimple_fmt (buffer, spc, flags, "%G ", + dump_gimple_fmt (pp, spc, flags, ", lhs=%T>", gimple_omp_return_lhs (gs)); else - dump_gimple_fmt (buffer, spc, flags, ">"); + dump_gimple_fmt (pp, spc, flags, ">"); } else { - pp_string (buffer, "#pragma omp return"); + pp_string (pp, "#pragma omp return"); if (gimple_omp_return_nowait_p (gs)) - pp_string (buffer, "(nowait)"); + pp_string (pp, "(nowait)"); if (gimple_omp_return_lhs (gs)) { - pp_string (buffer, " (set "); - dump_generic_node (buffer, gimple_omp_return_lhs (gs), + pp_string (pp, " (set "); + dump_generic_node (pp, gimple_omp_return_lhs (gs), spc, flags, false); - pp_character (buffer, ')'); + pp_character (pp, ')'); } } } -/* Dump a GIMPLE_ASSUME tuple on the pretty_printer BUFFER. */ +/* Dump a GIMPLE_ASSUME tuple on the pretty_printer PP. */ static void -dump_gimple_assume (pretty_printer *buffer, const gimple *gs, +dump_gimple_assume (pretty_printer *pp, const gimple *gs, int spc, dump_flags_t flags) { if (flags & TDF_RAW) - dump_gimple_fmt (buffer, spc, flags, + dump_gimple_fmt (pp, spc, flags, "%G [GUARD=%T] <%+BODY <%S> >", gs, gimple_assume_guard (gs), gimple_assume_body (gs)); else { - pp_string (buffer, "[[assume ("); - dump_generic_node (buffer, gimple_assume_guard (gs), spc, flags, false); - pp_string (buffer, ")]]"); - newline_and_indent (buffer, spc + 2); - pp_left_brace (buffer); - pp_newline (buffer); - dump_gimple_seq (buffer, gimple_assume_body (gs), spc + 4, flags); - newline_and_indent (buffer, spc + 2); - pp_right_brace (buffer); + pp_string (pp, "[[assume ("); + dump_generic_node (pp, gimple_assume_guard (gs), spc, flags, false); + pp_string (pp, ")]]"); + newline_and_indent (pp, spc + 2); + pp_left_brace (pp); + pp_newline (pp); + dump_gimple_seq (pp, gimple_assume_body (gs), spc + 4, flags); + newline_and_indent (pp, spc + 2); + pp_right_brace (pp); } } -/* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER. */ +/* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer PP. */ static void -dump_gimple_transaction (pretty_printer *buffer, const gtransaction *gs, +dump_gimple_transaction (pretty_printer *pp, const gtransaction *gs, int spc, dump_flags_t flags) { unsigned subcode = gimple_transaction_subcode (gs); if (flags & TDF_RAW) { - dump_gimple_fmt (buffer, spc, flags, + dump_gimple_fmt (pp, spc, flags, "%G [SUBCODE=%x,NORM=%T,UNINST=%T,OVER=%T] " "<%+BODY <%S> >", gs, subcode, gimple_transaction_label_norm (gs), @@ -2099,171 +2099,171 @@ dump_gimple_transaction (pretty_printer *buffer, const gtransaction *gs, else { if (subcode & GTMA_IS_OUTER) - pp_string (buffer, "__transaction_atomic [[outer]]"); + pp_string (pp, "__transaction_atomic [[outer]]"); else if (subcode & GTMA_IS_RELAXED) - pp_string (buffer, "__transaction_relaxed"); + pp_string (pp, "__transaction_relaxed"); else - pp_string (buffer, "__transaction_atomic"); + pp_string (pp, "__transaction_atomic"); subcode &= ~GTMA_DECLARATION_MASK; if (gimple_transaction_body (gs)) { - newline_and_indent (buffer, spc + 2); - pp_left_brace (buffer); - pp_newline (buffer); - dump_gimple_seq (buffer, gimple_transaction_body (gs), + newline_and_indent (pp, spc + 2); + pp_left_brace (pp); + pp_newline (pp); + dump_gimple_seq (pp, gimple_transaction_body (gs), spc + 4, flags); - newline_and_indent (buffer, spc + 2); - pp_right_brace (buffer); + newline_and_indent (pp, spc + 2); + pp_right_brace (pp); } else { - pp_string (buffer, " //"); + pp_string (pp, " //"); if (gimple_transaction_label_norm (gs)) { - pp_string (buffer, " NORM="); - dump_generic_node (buffer, gimple_transaction_label_norm (gs), + pp_string (pp, " NORM="); + dump_generic_node (pp, gimple_transaction_label_norm (gs), spc, flags, false); } if (gimple_transaction_label_uninst (gs)) { - pp_string (buffer, " UNINST="); - dump_generic_node (buffer, gimple_transaction_label_uninst (gs), + pp_string (pp, " UNINST="); + dump_generic_node (pp, gimple_transaction_label_uninst (gs), spc, flags, false); } if (gimple_transaction_label_over (gs)) { - pp_string (buffer, " OVER="); - dump_generic_node (buffer, gimple_transaction_label_over (gs), + pp_string (pp, " OVER="); + dump_generic_node (pp, gimple_transaction_label_over (gs), spc, flags, false); } if (subcode) { - pp_string (buffer, " SUBCODE=[ "); + pp_string (pp, " SUBCODE=[ "); if (subcode & GTMA_HAVE_ABORT) { - pp_string (buffer, "GTMA_HAVE_ABORT "); + pp_string (pp, "GTMA_HAVE_ABORT "); subcode &= ~GTMA_HAVE_ABORT; } if (subcode & GTMA_HAVE_LOAD) { - pp_string (buffer, "GTMA_HAVE_LOAD "); + pp_string (pp, "GTMA_HAVE_LOAD "); subcode &= ~GTMA_HAVE_LOAD; } if (subcode & GTMA_HAVE_STORE) { - pp_string (buffer, "GTMA_HAVE_STORE "); + pp_string (pp, "GTMA_HAVE_STORE "); subcode &= ~GTMA_HAVE_STORE; } if (subcode & GTMA_MAY_ENTER_IRREVOCABLE) { - pp_string (buffer, "GTMA_MAY_ENTER_IRREVOCABLE "); + pp_string (pp, "GTMA_MAY_ENTER_IRREVOCABLE "); subcode &= ~GTMA_MAY_ENTER_IRREVOCABLE; } if (subcode & GTMA_DOES_GO_IRREVOCABLE) { - pp_string (buffer, "GTMA_DOES_GO_IRREVOCABLE "); + pp_string (pp, "GTMA_DOES_GO_IRREVOCABLE "); subcode &= ~GTMA_DOES_GO_IRREVOCABLE; } if (subcode & GTMA_HAS_NO_INSTRUMENTATION) { - pp_string (buffer, "GTMA_HAS_NO_INSTRUMENTATION "); + pp_string (pp, "GTMA_HAS_NO_INSTRUMENTATION "); subcode &= ~GTMA_HAS_NO_INSTRUMENTATION; } if (subcode) - pp_printf (buffer, "0x%x ", subcode); - pp_right_bracket (buffer); + pp_printf (pp, "0x%x ", subcode); + pp_right_bracket (pp); } } } } -/* Dump a GIMPLE_ASM tuple on the pretty_printer BUFFER, SPC spaces of +/* Dump a GIMPLE_ASM tuple on the pretty_printer PP, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in dumpfile.h). */ static void -dump_gimple_asm (pretty_printer *buffer, const gasm *gs, int spc, +dump_gimple_asm (pretty_printer *pp, const gasm *gs, int spc, dump_flags_t flags) { unsigned int i, n, f, fields; if (flags & TDF_RAW) { - dump_gimple_fmt (buffer, spc, flags, "%G <%+STRING <%n%s%n>", gs, + dump_gimple_fmt (pp, spc, flags, "%G <%+STRING <%n%s%n>", gs, gimple_asm_string (gs)); n = gimple_asm_noutputs (gs); if (n) { - newline_and_indent (buffer, spc + 2); - pp_string (buffer, "OUTPUT: "); + newline_and_indent (pp, spc + 2); + pp_string (pp, "OUTPUT: "); for (i = 0; i < n; i++) { - dump_generic_node (buffer, gimple_asm_output_op (gs, i), + dump_generic_node (pp, gimple_asm_output_op (gs, i), spc, flags, false); if (i < n - 1) - pp_string (buffer, ", "); + pp_string (pp, ", "); } } n = gimple_asm_ninputs (gs); if (n) { - newline_and_indent (buffer, spc + 2); - pp_string (buffer, "INPUT: "); + newline_and_indent (pp, spc + 2); + pp_string (pp, "INPUT: "); for (i = 0; i < n; i++) { - dump_generic_node (buffer, gimple_asm_input_op (gs, i), + dump_generic_node (pp, gimple_asm_input_op (gs, i), spc, flags, false); if (i < n - 1) - pp_string (buffer, ", "); + pp_string (pp, ", "); } } n = gimple_asm_nclobbers (gs); if (n) { - newline_and_indent (buffer, spc + 2); - pp_string (buffer, "CLOBBER: "); + newline_and_indent (pp, spc + 2); + pp_string (pp, "CLOBBER: "); for (i = 0; i < n; i++) { - dump_generic_node (buffer, gimple_asm_clobber_op (gs, i), + dump_generic_node (pp, gimple_asm_clobber_op (gs, i), spc, flags, false); if (i < n - 1) - pp_string (buffer, ", "); + pp_string (pp, ", "); } } n = gimple_asm_nlabels (gs); if (n) { - newline_and_indent (buffer, spc + 2); - pp_string (buffer, "LABEL: "); + newline_and_indent (pp, spc + 2); + pp_string (pp, "LABEL: "); for (i = 0; i < n; i++) { - dump_generic_node (buffer, gimple_asm_label_op (gs, i), + dump_generic_node (pp, gimple_asm_label_op (gs, i), spc, flags, false); if (i < n - 1) - pp_string (buffer, ", "); + pp_string (pp, ", "); } } - newline_and_indent (buffer, spc); - pp_greater (buffer); + newline_and_indent (pp, spc); + pp_greater (pp); } else { - pp_string (buffer, "__asm__"); + pp_string (pp, "__asm__"); if (gimple_asm_volatile_p (gs)) - pp_string (buffer, " __volatile__"); + pp_string (pp, " __volatile__"); if (gimple_asm_inline_p (gs)) - pp_string (buffer, " __inline__"); + pp_string (pp, " __inline__"); if (gimple_asm_nlabels (gs)) - pp_string (buffer, " goto"); - pp_string (buffer, "(\""); - pp_string (buffer, gimple_asm_string (gs)); - pp_string (buffer, "\""); + pp_string (pp, " goto"); + pp_string (pp, "(\""); + pp_string (pp, gimple_asm_string (gs)); + pp_string (pp, "\""); if (gimple_asm_nlabels (gs)) fields = 4; @@ -2278,7 +2278,7 @@ dump_gimple_asm (pretty_printer *buffer, const gasm *gs, int spc, for (f = 0; f < fields; ++f) { - pp_string (buffer, " : "); + pp_string (pp, " : "); switch (f) { @@ -2286,10 +2286,10 @@ dump_gimple_asm (pretty_printer *buffer, const gasm *gs, int spc, n = gimple_asm_noutputs (gs); for (i = 0; i < n; i++) { - dump_generic_node (buffer, gimple_asm_output_op (gs, i), + dump_generic_node (pp, gimple_asm_output_op (gs, i), spc, flags, false); if (i < n - 1) - pp_string (buffer, ", "); + pp_string (pp, ", "); } break; @@ -2297,10 +2297,10 @@ dump_gimple_asm (pretty_printer *buffer, const gasm *gs, int spc, n = gimple_asm_ninputs (gs); for (i = 0; i < n; i++) { - dump_generic_node (buffer, gimple_asm_input_op (gs, i), + dump_generic_node (pp, gimple_asm_input_op (gs, i), spc, flags, false); if (i < n - 1) - pp_string (buffer, ", "); + pp_string (pp, ", "); } break; @@ -2308,10 +2308,10 @@ dump_gimple_asm (pretty_printer *buffer, const gasm *gs, int spc, n = gimple_asm_nclobbers (gs); for (i = 0; i < n; i++) { - dump_generic_node (buffer, gimple_asm_clobber_op (gs, i), + dump_generic_node (pp, gimple_asm_clobber_op (gs, i), spc, flags, false); if (i < n - 1) - pp_string (buffer, ", "); + pp_string (pp, ", "); } break; @@ -2319,10 +2319,10 @@ dump_gimple_asm (pretty_printer *buffer, const gasm *gs, int spc, n = gimple_asm_nlabels (gs); for (i = 0; i < n; i++) { - dump_generic_node (buffer, gimple_asm_label_op (gs, i), + dump_generic_node (pp, gimple_asm_label_op (gs, i), spc, flags, false); if (i < n - 1) - pp_string (buffer, ", "); + pp_string (pp, ", "); } break; @@ -2331,15 +2331,15 @@ dump_gimple_asm (pretty_printer *buffer, const gasm *gs, int spc, } } - pp_string (buffer, ");"); + pp_string (pp, ");"); } } -/* Dump ptr_info and range_info for NODE on pretty_printer BUFFER with +/* Dump ptr_info and range_info for NODE on pretty_printer PP with SPC spaces of indent. */ static void -dump_ssaname_info (pretty_printer *buffer, tree node, int spc) +dump_ssaname_info (pretty_printer *pp, tree node, int spc) { if (TREE_CODE (node) != SSA_NAME) return; @@ -2349,24 +2349,24 @@ dump_ssaname_info (pretty_printer *buffer, tree node, int spc) { unsigned int align, misalign; struct ptr_info_def *pi = SSA_NAME_PTR_INFO (node); - pp_string (buffer, "# PT = "); - pp_points_to_solution (buffer, &pi->pt); - newline_and_indent (buffer, spc); + pp_string (pp, "# PT = "); + pp_points_to_solution (pp, &pi->pt); + newline_and_indent (pp, spc); if (get_ptr_info_alignment (pi, &align, &misalign)) { - pp_printf (buffer, "# ALIGN = %u, MISALIGN = %u", align, misalign); - newline_and_indent (buffer, spc); + pp_printf (pp, "# ALIGN = %u, MISALIGN = %u", align, misalign); + newline_and_indent (pp, spc); } } if (!POINTER_TYPE_P (TREE_TYPE (node)) && SSA_NAME_RANGE_INFO (node)) { - Value_Range r (TREE_TYPE (node)); + value_range r (TREE_TYPE (node)); get_global_range_query ()->range_of_expr (r, node); - pp_string (buffer, "# RANGE "); - pp_vrange (buffer, &r); - newline_and_indent (buffer, spc); + pp_string (pp, "# RANGE "); + pp_vrange (pp, &r); + newline_and_indent (pp, spc); } } @@ -2375,138 +2375,138 @@ dump_ssaname_info (pretty_printer *buffer, tree node, int spc) void dump_ssaname_info_to_file (FILE *file, tree node, int spc) { - pretty_printer buffer; - pp_needs_newline (&buffer) = true; - buffer.buffer->stream = file; - dump_ssaname_info (&buffer, node, spc); - pp_flush (&buffer); + pretty_printer pp; + pp_needs_newline (&pp) = true; + pp.set_output_stream (file); + dump_ssaname_info (&pp, node, spc); + pp_flush (&pp); } -/* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1. - The caller is responsible for calling pp_flush on BUFFER to finalize +/* Dump a PHI node PHI. PP, SPC and FLAGS are as in pp_gimple_stmt_1. + The caller is responsible for calling pp_flush on PP to finalize pretty printer. If COMMENT is true, print this after #. */ static void -dump_gimple_phi (pretty_printer *buffer, const gphi *phi, int spc, bool comment, +dump_gimple_phi (pretty_printer *pp, const gphi *phi, int spc, bool comment, dump_flags_t flags) { size_t i; tree lhs = gimple_phi_result (phi); if (flags & TDF_ALIAS) - dump_ssaname_info (buffer, lhs, spc); + dump_ssaname_info (pp, lhs, spc); if (comment) - pp_string (buffer, "# "); + pp_string (pp, "# "); if (flags & TDF_RAW) - dump_gimple_fmt (buffer, spc, flags, "%G <%T, ", phi, + dump_gimple_fmt (pp, spc, flags, "%G <%T, ", phi, gimple_phi_result (phi)); else { - dump_generic_node (buffer, lhs, spc, flags, false); + dump_generic_node (pp, lhs, spc, flags, false); if (flags & TDF_GIMPLE) - pp_string (buffer, " = __PHI ("); + pp_string (pp, " = __PHI ("); else - pp_string (buffer, " = PHI <"); + pp_string (pp, " = PHI <"); } for (i = 0; i < gimple_phi_num_args (phi); i++) { if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i)) - dump_location (buffer, gimple_phi_arg_location (phi, i)); + dump_location (pp, gimple_phi_arg_location (phi, i)); basic_block src = gimple_phi_arg_edge (phi, i)->src; if (flags & TDF_GIMPLE) { - pp_string (buffer, "__BB"); - pp_decimal_int (buffer, src->index); - pp_string (buffer, ": "); + pp_string (pp, "__BB"); + pp_decimal_int (pp, src->index); + pp_string (pp, ": "); } - dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags, + dump_generic_node (pp, gimple_phi_arg_def (phi, i), spc, flags, false); if (! (flags & TDF_GIMPLE)) { - pp_left_paren (buffer); - pp_decimal_int (buffer, src->index); - pp_right_paren (buffer); + pp_left_paren (pp); + pp_decimal_int (pp, src->index); + pp_right_paren (pp); } if (i < gimple_phi_num_args (phi) - 1) - pp_string (buffer, ", "); + pp_string (pp, ", "); } if (flags & TDF_GIMPLE) - pp_string (buffer, ");"); + pp_string (pp, ");"); else - pp_greater (buffer); + pp_greater (pp); } -/* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer BUFFER, SPC spaces +/* Dump a GIMPLE_OMP_PARALLEL tuple on the pretty_printer PP, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in dumpfile.h). */ static void -dump_gimple_omp_parallel (pretty_printer *buffer, const gomp_parallel *gs, +dump_gimple_omp_parallel (pretty_printer *pp, const gomp_parallel *gs, int spc, dump_flags_t flags) { if (flags & TDF_RAW) { - dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, + dump_gimple_fmt (pp, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, gimple_omp_body (gs)); - dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags); - dump_gimple_fmt (buffer, spc, flags, " >, %T, %T%n>", + dump_omp_clauses (pp, gimple_omp_parallel_clauses (gs), spc, flags); + dump_gimple_fmt (pp, spc, flags, " >, %T, %T%n>", gimple_omp_parallel_child_fn (gs), gimple_omp_parallel_data_arg (gs)); } else { gimple_seq body; - pp_string (buffer, "#pragma omp parallel"); - dump_omp_clauses (buffer, gimple_omp_parallel_clauses (gs), spc, flags); + pp_string (pp, "#pragma omp parallel"); + dump_omp_clauses (pp, gimple_omp_parallel_clauses (gs), spc, flags); if (gimple_omp_parallel_child_fn (gs)) { - pp_string (buffer, " [child fn: "); - dump_generic_node (buffer, gimple_omp_parallel_child_fn (gs), + pp_string (pp, " [child fn: "); + dump_generic_node (pp, gimple_omp_parallel_child_fn (gs), spc, flags, false); - pp_string (buffer, " ("); + pp_string (pp, " ("); if (gimple_omp_parallel_data_arg (gs)) - dump_generic_node (buffer, gimple_omp_parallel_data_arg (gs), + dump_generic_node (pp, gimple_omp_parallel_data_arg (gs), spc, flags, false); else - pp_string (buffer, "???"); - pp_string (buffer, ")]"); + pp_string (pp, "???"); + pp_string (pp, ")]"); } body = gimple_omp_body (gs); if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND) { - newline_and_indent (buffer, spc + 2); - pp_left_brace (buffer); - pp_newline (buffer); - dump_gimple_seq (buffer, body, spc + 4, flags); - newline_and_indent (buffer, spc + 2); - pp_right_brace (buffer); + newline_and_indent (pp, spc + 2); + pp_left_brace (pp); + pp_newline (pp); + dump_gimple_seq (pp, body, spc + 4, flags); + newline_and_indent (pp, spc + 2); + pp_right_brace (pp); } else if (body) { - pp_newline (buffer); - dump_gimple_seq (buffer, body, spc + 2, flags); + pp_newline (pp); + dump_gimple_seq (pp, body, spc + 2, flags); } } } -/* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer BUFFER, SPC spaces +/* Dump a GIMPLE_OMP_TASK tuple on the pretty_printer PP, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in dumpfile.h). */ static void -dump_gimple_omp_task (pretty_printer *buffer, const gomp_task *gs, int spc, +dump_gimple_omp_task (pretty_printer *pp, const gomp_task *gs, int spc, dump_flags_t flags) { if (flags & TDF_RAW) { - dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, + dump_gimple_fmt (pp, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs, gimple_omp_body (gs)); - dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags); - dump_gimple_fmt (buffer, spc, flags, " >, %T, %T, %T, %T, %T%n>", + dump_omp_clauses (pp, gimple_omp_task_clauses (gs), spc, flags); + dump_gimple_fmt (pp, spc, flags, " >, %T, %T, %T, %T, %T%n>", gimple_omp_task_child_fn (gs), gimple_omp_task_data_arg (gs), gimple_omp_task_copy_fn (gs), @@ -2517,116 +2517,116 @@ dump_gimple_omp_task (pretty_printer *buffer, const gomp_task *gs, int spc, { gimple_seq body; if (gimple_omp_task_taskloop_p (gs)) - pp_string (buffer, "#pragma omp taskloop"); + pp_string (pp, "#pragma omp taskloop"); else if (gimple_omp_task_taskwait_p (gs)) - pp_string (buffer, "#pragma omp taskwait"); + pp_string (pp, "#pragma omp taskwait"); else - pp_string (buffer, "#pragma omp task"); - dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags); + pp_string (pp, "#pragma omp task"); + dump_omp_clauses (pp, gimple_omp_task_clauses (gs), spc, flags); if (gimple_omp_task_child_fn (gs)) { - pp_string (buffer, " [child fn: "); - dump_generic_node (buffer, gimple_omp_task_child_fn (gs), + pp_string (pp, " [child fn: "); + dump_generic_node (pp, gimple_omp_task_child_fn (gs), spc, flags, false); - pp_string (buffer, " ("); + pp_string (pp, " ("); if (gimple_omp_task_data_arg (gs)) - dump_generic_node (buffer, gimple_omp_task_data_arg (gs), + dump_generic_node (pp, gimple_omp_task_data_arg (gs), spc, flags, false); else - pp_string (buffer, "???"); - pp_string (buffer, ")]"); + pp_string (pp, "???"); + pp_string (pp, ")]"); } body = gimple_omp_body (gs); if (body && gimple_code (gimple_seq_first_stmt (body)) != GIMPLE_BIND) { - newline_and_indent (buffer, spc + 2); - pp_left_brace (buffer); - pp_newline (buffer); - dump_gimple_seq (buffer, body, spc + 4, flags); - newline_and_indent (buffer, spc + 2); - pp_right_brace (buffer); + newline_and_indent (pp, spc + 2); + pp_left_brace (pp); + pp_newline (pp); + dump_gimple_seq (pp, body, spc + 4, flags); + newline_and_indent (pp, spc + 2); + pp_right_brace (pp); } else if (body) { - pp_newline (buffer); - dump_gimple_seq (buffer, body, spc + 2, flags); + pp_newline (pp); + dump_gimple_seq (pp, body, spc + 2, flags); } } } -/* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer BUFFER, SPC +/* Dump a GIMPLE_OMP_ATOMIC_LOAD tuple on the pretty_printer PP, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in dumpfile.h). */ static void -dump_gimple_omp_atomic_load (pretty_printer *buffer, const gomp_atomic_load *gs, +dump_gimple_omp_atomic_load (pretty_printer *pp, const gomp_atomic_load *gs, int spc, dump_flags_t flags) { if (flags & TDF_RAW) { - dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T>", gs, + dump_gimple_fmt (pp, spc, flags, "%G <%T, %T>", gs, gimple_omp_atomic_load_lhs (gs), gimple_omp_atomic_load_rhs (gs)); } else { - pp_string (buffer, "#pragma omp atomic_load"); - dump_omp_atomic_memory_order (buffer, + pp_string (pp, "#pragma omp atomic_load"); + dump_omp_atomic_memory_order (pp, gimple_omp_atomic_memory_order (gs)); if (gimple_omp_atomic_need_value_p (gs)) - pp_string (buffer, " [needed]"); + pp_string (pp, " [needed]"); if (gimple_omp_atomic_weak_p (gs)) - pp_string (buffer, " [weak]"); - newline_and_indent (buffer, spc + 2); - dump_generic_node (buffer, gimple_omp_atomic_load_lhs (gs), + pp_string (pp, " [weak]"); + newline_and_indent (pp, spc + 2); + dump_generic_node (pp, gimple_omp_atomic_load_lhs (gs), spc, flags, false); - pp_space (buffer); - pp_equal (buffer); - pp_space (buffer); - pp_star (buffer); - dump_generic_node (buffer, gimple_omp_atomic_load_rhs (gs), + pp_space (pp); + pp_equal (pp); + pp_space (pp); + pp_star (pp); + dump_generic_node (pp, gimple_omp_atomic_load_rhs (gs), spc, flags, false); } } -/* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer BUFFER, SPC +/* Dump a GIMPLE_OMP_ATOMIC_STORE tuple on the pretty_printer PP, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in dumpfile.h). */ static void -dump_gimple_omp_atomic_store (pretty_printer *buffer, +dump_gimple_omp_atomic_store (pretty_printer *pp, const gomp_atomic_store *gs, int spc, dump_flags_t flags) { if (flags & TDF_RAW) { - dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, + dump_gimple_fmt (pp, spc, flags, "%G <%T>", gs, gimple_omp_atomic_store_val (gs)); } else { - pp_string (buffer, "#pragma omp atomic_store"); - dump_omp_atomic_memory_order (buffer, + pp_string (pp, "#pragma omp atomic_store"); + dump_omp_atomic_memory_order (pp, gimple_omp_atomic_memory_order (gs)); - pp_space (buffer); + pp_space (pp); if (gimple_omp_atomic_need_value_p (gs)) - pp_string (buffer, "[needed] "); + pp_string (pp, "[needed] "); if (gimple_omp_atomic_weak_p (gs)) - pp_string (buffer, "[weak] "); - pp_left_paren (buffer); - dump_generic_node (buffer, gimple_omp_atomic_store_val (gs), + pp_string (pp, "[weak] "); + pp_left_paren (pp); + dump_generic_node (pp, gimple_omp_atomic_store_val (gs), spc, flags, false); - pp_right_paren (buffer); + pp_right_paren (pp); } } -/* Dump all the memory operands for statement GS. BUFFER, SPC and +/* Dump all the memory operands for statement GS. PP, SPC and FLAGS are as in pp_gimple_stmt_1. */ static void -dump_gimple_mem_ops (pretty_printer *buffer, const gimple *gs, int spc, +dump_gimple_mem_ops (pretty_printer *pp, const gimple *gs, int spc, dump_flags_t flags) { tree vdef = gimple_vdef (gs); @@ -2634,246 +2634,246 @@ dump_gimple_mem_ops (pretty_printer *buffer, const gimple *gs, int spc, if (vdef != NULL_TREE) { - pp_string (buffer, "# "); - dump_generic_node (buffer, vdef, spc + 2, flags, false); - pp_string (buffer, " = VDEF <"); - dump_generic_node (buffer, vuse, spc + 2, flags, false); - pp_greater (buffer); - newline_and_indent (buffer, spc); + pp_string (pp, "# "); + dump_generic_node (pp, vdef, spc + 2, flags, false); + pp_string (pp, " = VDEF <"); + dump_generic_node (pp, vuse, spc + 2, flags, false); + pp_greater (pp); + newline_and_indent (pp, spc); } else if (vuse != NULL_TREE) { - pp_string (buffer, "# VUSE <"); - dump_generic_node (buffer, vuse, spc + 2, flags, false); - pp_greater (buffer); - newline_and_indent (buffer, spc); + pp_string (pp, "# VUSE <"); + dump_generic_node (pp, vuse, spc + 2, flags, false); + pp_greater (pp); + newline_and_indent (pp, spc); } } -/* Print the gimple statement GS on the pretty printer BUFFER, SPC +/* Print the gimple statement GS on the pretty printer PP, SPC spaces of indent. FLAGS specifies details to show in the dump (see TDF_* in dumpfile.h). The caller is responsible for calling - pp_flush on BUFFER to finalize the pretty printer. */ + pp_flush on PP to finalize the pretty printer. */ void -pp_gimple_stmt_1 (pretty_printer *buffer, const gimple *gs, int spc, +pp_gimple_stmt_1 (pretty_printer *pp, const gimple *gs, int spc, dump_flags_t flags) { if (!gs) return; if (flags & TDF_STMTADDR) - pp_printf (buffer, "<&%p> ", (const void *) gs); + pp_printf (pp, "<&%p> ", (const void *) gs); if ((flags & TDF_LINENO) && gimple_has_location (gs)) - dump_location (buffer, gimple_location (gs)); + dump_location (pp, gimple_location (gs)); if (flags & TDF_EH) { int lp_nr = lookup_stmt_eh_lp (gs); if (lp_nr > 0) - pp_printf (buffer, "[LP %d] ", lp_nr); + pp_printf (pp, "[LP %d] ", lp_nr); else if (lp_nr < 0) - pp_printf (buffer, "[MNT %d] ", -lp_nr); + pp_printf (pp, "[MNT %d] ", -lp_nr); } if ((flags & (TDF_VOPS|TDF_MEMSYMS)) && gimple_has_mem_ops (gs)) - dump_gimple_mem_ops (buffer, gs, spc, flags); + dump_gimple_mem_ops (pp, gs, spc, flags); if (gimple_has_lhs (gs) && (flags & TDF_ALIAS)) - dump_ssaname_info (buffer, gimple_get_lhs (gs), spc); + dump_ssaname_info (pp, gimple_get_lhs (gs), spc); switch (gimple_code (gs)) { case GIMPLE_ASM: - dump_gimple_asm (buffer, as_a (gs), spc, flags); + dump_gimple_asm (pp, as_a (gs), spc, flags); break; case GIMPLE_ASSIGN: - dump_gimple_assign (buffer, as_a (gs), spc, flags); + dump_gimple_assign (pp, as_a (gs), spc, flags); break; case GIMPLE_BIND: - dump_gimple_bind (buffer, as_a (gs), spc, flags); + dump_gimple_bind (pp, as_a (gs), spc, flags); break; case GIMPLE_CALL: - dump_gimple_call (buffer, as_a (gs), spc, flags); + dump_gimple_call (pp, as_a (gs), spc, flags); break; case GIMPLE_COND: - dump_gimple_cond (buffer, as_a (gs), spc, flags); + dump_gimple_cond (pp, as_a (gs), spc, flags); break; case GIMPLE_LABEL: - dump_gimple_label (buffer, as_a (gs), spc, flags); + dump_gimple_label (pp, as_a (gs), spc, flags); break; case GIMPLE_GOTO: - dump_gimple_goto (buffer, as_a (gs), spc, flags); + dump_gimple_goto (pp, as_a (gs), spc, flags); break; case GIMPLE_NOP: - pp_string (buffer, "GIMPLE_NOP"); + pp_string (pp, "GIMPLE_NOP"); break; case GIMPLE_RETURN: - dump_gimple_return (buffer, as_a (gs), spc, flags); + dump_gimple_return (pp, as_a (gs), spc, flags); break; case GIMPLE_SWITCH: - dump_gimple_switch (buffer, as_a (gs), spc, flags); + dump_gimple_switch (pp, as_a (gs), spc, flags); break; case GIMPLE_TRY: - dump_gimple_try (buffer, as_a (gs), spc, flags); + dump_gimple_try (pp, as_a (gs), spc, flags); break; case GIMPLE_PHI: - dump_gimple_phi (buffer, as_a (gs), spc, false, flags); + dump_gimple_phi (pp, as_a (gs), spc, false, flags); break; case GIMPLE_OMP_PARALLEL: - dump_gimple_omp_parallel (buffer, as_a (gs), spc, + dump_gimple_omp_parallel (pp, as_a (gs), spc, flags); break; case GIMPLE_OMP_TASK: - dump_gimple_omp_task (buffer, as_a (gs), spc, flags); + dump_gimple_omp_task (pp, as_a (gs), spc, flags); break; case GIMPLE_OMP_ATOMIC_LOAD: - dump_gimple_omp_atomic_load (buffer, as_a (gs), + dump_gimple_omp_atomic_load (pp, as_a (gs), spc, flags); break; case GIMPLE_OMP_ATOMIC_STORE: - dump_gimple_omp_atomic_store (buffer, + dump_gimple_omp_atomic_store (pp, as_a (gs), spc, flags); break; case GIMPLE_OMP_FOR: - dump_gimple_omp_for (buffer, as_a (gs), spc, flags); + dump_gimple_omp_for (pp, as_a (gs), spc, flags); break; case GIMPLE_OMP_CONTINUE: - dump_gimple_omp_continue (buffer, as_a (gs), spc, + dump_gimple_omp_continue (pp, as_a (gs), spc, flags); break; case GIMPLE_OMP_SINGLE: - dump_gimple_omp_single (buffer, as_a (gs), spc, + dump_gimple_omp_single (pp, as_a (gs), spc, flags); break; case GIMPLE_OMP_TARGET: - dump_gimple_omp_target (buffer, as_a (gs), spc, + dump_gimple_omp_target (pp, as_a (gs), spc, flags); break; case GIMPLE_OMP_TEAMS: - dump_gimple_omp_teams (buffer, as_a (gs), spc, + dump_gimple_omp_teams (pp, as_a (gs), spc, flags); break; case GIMPLE_OMP_RETURN: - dump_gimple_omp_return (buffer, gs, spc, flags); + dump_gimple_omp_return (pp, gs, spc, flags); break; case GIMPLE_OMP_SECTIONS: - dump_gimple_omp_sections (buffer, as_a (gs), + dump_gimple_omp_sections (pp, as_a (gs), spc, flags); break; case GIMPLE_OMP_SECTIONS_SWITCH: - pp_string (buffer, "GIMPLE_SECTIONS_SWITCH"); + pp_string (pp, "GIMPLE_SECTIONS_SWITCH"); break; case GIMPLE_OMP_TASKGROUP: - dump_gimple_omp_taskgroup (buffer, gs, spc, flags); + dump_gimple_omp_taskgroup (pp, gs, spc, flags); break; case GIMPLE_OMP_MASKED: - dump_gimple_omp_masked (buffer, gs, spc, flags); + dump_gimple_omp_masked (pp, gs, spc, flags); break; case GIMPLE_OMP_SCOPE: - dump_gimple_omp_scope (buffer, gs, spc, flags); + dump_gimple_omp_scope (pp, gs, spc, flags); break; case GIMPLE_OMP_MASTER: case GIMPLE_OMP_SECTION: case GIMPLE_OMP_STRUCTURED_BLOCK: - dump_gimple_omp_block (buffer, gs, spc, flags); + dump_gimple_omp_block (pp, gs, spc, flags); break; case GIMPLE_OMP_ORDERED: - dump_gimple_omp_ordered (buffer, as_a (gs), spc, + dump_gimple_omp_ordered (pp, as_a (gs), spc, flags); break; case GIMPLE_OMP_SCAN: - dump_gimple_omp_scan (buffer, as_a (gs), spc, + dump_gimple_omp_scan (pp, as_a (gs), spc, flags); break; case GIMPLE_OMP_CRITICAL: - dump_gimple_omp_critical (buffer, as_a (gs), spc, + dump_gimple_omp_critical (pp, as_a (gs), spc, flags); break; case GIMPLE_CATCH: - dump_gimple_catch (buffer, as_a (gs), spc, flags); + dump_gimple_catch (pp, as_a (gs), spc, flags); break; case GIMPLE_EH_FILTER: - dump_gimple_eh_filter (buffer, as_a (gs), spc, + dump_gimple_eh_filter (pp, as_a (gs), spc, flags); break; case GIMPLE_EH_MUST_NOT_THROW: - dump_gimple_eh_must_not_throw (buffer, + dump_gimple_eh_must_not_throw (pp, as_a (gs), spc, flags); break; case GIMPLE_EH_ELSE: - dump_gimple_eh_else (buffer, as_a (gs), spc, flags); + dump_gimple_eh_else (pp, as_a (gs), spc, flags); break; case GIMPLE_RESX: - dump_gimple_resx (buffer, as_a (gs), spc, flags); + dump_gimple_resx (pp, as_a (gs), spc, flags); break; case GIMPLE_EH_DISPATCH: - dump_gimple_eh_dispatch (buffer, as_a (gs), spc, + dump_gimple_eh_dispatch (pp, as_a (gs), spc, flags); break; case GIMPLE_DEBUG: - dump_gimple_debug (buffer, as_a (gs), spc, flags); + dump_gimple_debug (pp, as_a (gs), spc, flags); break; case GIMPLE_PREDICT: - pp_string (buffer, "// predicted "); + pp_string (pp, "// predicted "); if (gimple_predict_outcome (gs)) - pp_string (buffer, "likely by "); + pp_string (pp, "likely by "); else - pp_string (buffer, "unlikely by "); - pp_string (buffer, predictor_name (gimple_predict_predictor (gs))); - pp_string (buffer, " predictor."); + pp_string (pp, "unlikely by "); + pp_string (pp, predictor_name (gimple_predict_predictor (gs))); + pp_string (pp, " predictor."); break; case GIMPLE_ASSUME: - dump_gimple_assume (buffer, gs, spc, flags); + dump_gimple_assume (pp, gs, spc, flags); break; case GIMPLE_TRANSACTION: - dump_gimple_transaction (buffer, as_a (gs), spc, + dump_gimple_transaction (pp, as_a (gs), spc, flags); break; @@ -2929,7 +2929,7 @@ dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, } -/* Dumps end of basic block BB to buffer BUFFER indented by INDENT +/* Dumps end of basic block BB to PP indented by INDENT spaces. */ static void @@ -2943,11 +2943,11 @@ dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED, } -/* Dump PHI nodes of basic block BB to BUFFER with details described +/* Dump PHI nodes of basic block BB to PP with details described by FLAGS and indented by INDENT spaces. */ static void -dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, +dump_phi_nodes (pretty_printer *pp, basic_block bb, int indent, dump_flags_t flags) { gphi_iterator i; @@ -2958,52 +2958,52 @@ dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS)) { INDENT (indent); - dump_gimple_phi (buffer, phi, indent, + dump_gimple_phi (pp, phi, indent, (flags & TDF_GIMPLE) ? false : true, flags); - pp_newline (buffer); + pp_newline (pp); } } } /* Dump jump to basic block BB that is represented implicitly in the cfg - to BUFFER. */ + to PP. */ static void -pp_cfg_jump (pretty_printer *buffer, edge e, dump_flags_t flags) +pp_cfg_jump (pretty_printer *pp, edge e, dump_flags_t flags) { if (flags & TDF_GIMPLE) { - pp_string (buffer, "goto __BB"); - pp_decimal_int (buffer, e->dest->index); + pp_string (pp, "goto __BB"); + pp_decimal_int (pp, e->dest->index); if (e->probability.initialized_p ()) { - pp_string (buffer, "("); - pp_string (buffer, + pp_string (pp, "("); + pp_string (pp, profile_quality_as_string (e->probability.quality ())); - pp_string (buffer, "("); - pp_decimal_int (buffer, e->probability.value ()); - pp_string (buffer, "))"); + pp_string (pp, "("); + pp_decimal_int (pp, e->probability.value ()); + pp_string (pp, "))"); } - pp_semicolon (buffer); + pp_semicolon (pp); } else { - pp_string (buffer, "goto dest->index); - pp_greater (buffer); - pp_semicolon (buffer); + pp_string (pp, "goto dest->index); + pp_greater (pp); + pp_semicolon (pp); - dump_edge_probability (buffer, e); + dump_edge_probability (pp, e); } } -/* Dump edges represented implicitly in basic block BB to BUFFER, indented +/* Dump edges represented implicitly in basic block BB to PP, indented by INDENT spaces, with details given by FLAGS. */ static void -dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent, +dump_implicit_edges (pretty_printer *pp, basic_block bb, int indent, dump_flags_t flags) { edge e; @@ -3020,12 +3020,12 @@ dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent, extract_true_false_edges_from_block (bb, &true_edge, &false_edge); INDENT (indent + 2); - pp_cfg_jump (buffer, true_edge, flags); - newline_and_indent (buffer, indent); - pp_string (buffer, "else"); - newline_and_indent (buffer, indent + 2); - pp_cfg_jump (buffer, false_edge, flags); - pp_newline (buffer); + pp_cfg_jump (pp, true_edge, flags); + newline_and_indent (pp, indent); + pp_string (pp, "else"); + newline_and_indent (pp, indent + 2); + pp_cfg_jump (pp, false_edge, flags); + pp_newline (pp); return; } @@ -3039,19 +3039,19 @@ dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent, if ((flags & TDF_LINENO) && e->goto_locus != UNKNOWN_LOCATION) - dump_location (buffer, e->goto_locus); + dump_location (pp, e->goto_locus); - pp_cfg_jump (buffer, e, flags); - pp_newline (buffer); + pp_cfg_jump (pp, e, flags); + pp_newline (pp); } } -/* Dumps basic block BB to buffer BUFFER with details described by FLAGS and +/* Dumps basic block BB to PP with details described by FLAGS and indented by INDENT spaces. */ static void -gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent, +gimple_dump_bb_buff (pretty_printer *pp, basic_block bb, int indent, dump_flags_t flags) { gimple_stmt_iterator gsi; @@ -3061,7 +3061,7 @@ gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent, if (label_indent < 0) label_indent = 0; - dump_phi_nodes (buffer, bb, indent, flags); + dump_phi_nodes (pp, bb, indent, flags); for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { @@ -3072,15 +3072,15 @@ gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent, curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent; INDENT (curr_indent); - pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags); - pp_newline_and_flush (buffer); + pp_gimple_stmt_1 (pp, stmt, curr_indent, flags); + pp_newline_and_flush (pp); gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl)); dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl), - pp_buffer (buffer)->stream, stmt); + pp_buffer (pp)->stream, stmt); } - dump_implicit_edges (buffer, bb, indent, flags); - pp_flush (buffer); + dump_implicit_edges (pp, bb, indent, flags); + pp_flush (pp); } @@ -3093,10 +3093,10 @@ gimple_dump_bb (FILE *file, basic_block bb, int indent, dump_flags_t flags) dump_gimple_bb_header (file, bb, indent, flags); if (bb->index >= NUM_FIXED_BLOCKS) { - pretty_printer buffer; - pp_needs_newline (&buffer) = true; - buffer.buffer->stream = file; - gimple_dump_bb_buff (&buffer, bb, indent, flags); + pretty_printer pp; + pp_needs_newline (&pp) = true; + pp.set_output_stream (file); + gimple_dump_bb_buff (&pp, bb, indent, flags); } dump_gimple_bb_footer (file, bb, indent, flags); } diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc index a511a2c3a4c27..d84fd1ca0e8c5 100644 --- a/gcc/gimple-range-cache.cc +++ b/gcc/gimple-range-cache.cc @@ -61,7 +61,7 @@ void ssa_block_ranges::dump (FILE *f) { basic_block bb; - Value_Range r (m_type); + value_range r (m_type); FOR_EACH_BB_FN (bb, cfun) if (get_bb_range (r, bb)) @@ -493,7 +493,7 @@ block_range_cache::dump (FILE *f, basic_block bb, bool print_varying) if (!gimple_range_ssa_p (ssa_name (x))) continue; - Value_Range r (TREE_TYPE (ssa_name (x))); + value_range r (TREE_TYPE (ssa_name (x))); if (m_ssa_ranges[x]->get_bb_range (r, bb)) { if (!print_varying && r.varying_p ()) @@ -519,7 +519,7 @@ block_range_cache::dump (FILE *f, basic_block bb, bool print_varying) if (!gimple_range_ssa_p (ssa_name (x))) continue; - Value_Range r (TREE_TYPE (ssa_name (x))); + value_range r (TREE_TYPE (ssa_name (x))); if (m_ssa_ranges[x]->get_bb_range (r, bb)) { if (r.varying_p ()) @@ -627,7 +627,7 @@ ssa_cache::merge_range (tree name, const vrange &r) m_tab[v] = m_range_allocator->clone (r); else { - Value_Range curr (TREE_TYPE (name)); + value_range curr (TREE_TYPE (name)); m->get_vrange (curr, TREE_TYPE (name)); // If there is no change, return false. if (!curr.intersect (r)) @@ -670,7 +670,7 @@ ssa_cache::dump (FILE *f) { if (!gimple_range_ssa_p (ssa_name (x))) continue; - Value_Range r (TREE_TYPE (ssa_name (x))); + value_range r (TREE_TYPE (ssa_name (x))); // Dump all non-varying ranges. if (get_range (r, ssa_name (x)) && !r.varying_p ()) { @@ -729,6 +729,24 @@ ssa_lazy_cache::merge_range (tree name, const vrange &r) return true; } +// Merge all elements of CACHE with this cache. +// Any names in CACHE that are not in this one are added. +// Any names in both are merged via merge_range.. + +void +ssa_lazy_cache::merge (const ssa_lazy_cache &cache) +{ + unsigned x; + bitmap_iterator bi; + EXECUTE_IF_SET_IN_BITMAP (cache.active_p, 0, x, bi) + { + tree name = ssa_name (x); + value_range r(TREE_TYPE (name)); + cache.get_range (r, name); + merge_range (ssa_name (x), r); + } +} + // Return TRUE if NAME has a range, and return it in R. bool @@ -1177,7 +1195,7 @@ ranger_cache::edge_range (vrange &r, edge e, tree name, enum rfd_mode mode) // If this is not an abnormal edge, check for inferred ranges on exit. if ((e->flags & (EDGE_EH | EDGE_ABNORMAL)) == 0) infer_oracle ().maybe_adjust_range (r, name, e->src); - Value_Range er (TREE_TYPE (name)); + value_range er (TREE_TYPE (name)); if (gori ().edge_range_p (er, e, name, *this)) r.intersect (er); return true; @@ -1269,9 +1287,9 @@ ranger_cache::propagate_cache (tree name) edge_iterator ei; edge e; tree type = TREE_TYPE (name); - Value_Range new_range (type); - Value_Range current_range (type); - Value_Range e_range (type); + value_range new_range (type); + value_range current_range (type); + value_range e_range (type); // Process each block by seeing if its calculated range on entry is // the same as its cached value. If there is a difference, update @@ -1407,8 +1425,8 @@ ranger_cache::fill_block_cache (tree name, basic_block bb, basic_block def_bb) edge_iterator ei; edge e; tree type = TREE_TYPE (name); - Value_Range block_result (type); - Value_Range undefined (type); + value_range block_result (type); + value_range undefined (type); // At this point we shouldn't be looking at the def, entry block. gcc_checking_assert (bb != def_bb && bb != ENTRY_BLOCK_PTR_FOR_FN (cfun)); @@ -1468,7 +1486,7 @@ ranger_cache::fill_block_cache (tree name, basic_block bb, basic_block def_bb) print_generic_expr (dump_file, equiv_name, TDF_SLIM); fprintf (dump_file, "\n"); } - Value_Range equiv_range (TREE_TYPE (equiv_name)); + value_range equiv_range (TREE_TYPE (equiv_name)); if (range_from_dom (equiv_range, equiv_name, bb, RFD_READ_ONLY)) { if (rel != VREL_EQ) @@ -1521,7 +1539,7 @@ ranger_cache::fill_block_cache (tree name, basic_block bb, basic_block def_bb) FOR_EACH_EDGE (e, ei, node->preds) { basic_block pred = e->src; - Value_Range r (TREE_TYPE (name)); + value_range r (TREE_TYPE (name)); if (DEBUG_RANGE_CACHE) fprintf (dump_file, " %d->%d ",e->src->index, e->dest->index); @@ -1613,7 +1631,7 @@ ranger_cache::resolve_dom (vrange &r, tree name, basic_block bb) r.set_undefined (); edge e; edge_iterator ei; - Value_Range er (TREE_TYPE (name)); + value_range er (TREE_TYPE (name)); FOR_EACH_EDGE (e, ei, bb->preds) { // If the predecessor is dominated by this block, then there is a back @@ -1647,7 +1665,7 @@ ranger_cache::range_from_dom (vrange &r, tree name, basic_block start_bb, basic_block prev_bb = start_bb; // Track any inferred ranges seen. - Value_Range infer (TREE_TYPE (name)); + value_range infer (TREE_TYPE (name)); infer.set_varying (TREE_TYPE (name)); // Range on entry to the DEF block should not be queried. @@ -1722,7 +1740,7 @@ ranger_cache::range_from_dom (vrange &r, tree name, basic_block start_bb, // Now process any blocks wit incoming edges that nay have adjustments. while (m_workback.length () > start_limit) { - Value_Range er (TREE_TYPE (name)); + value_range er (TREE_TYPE (name)); prev_bb = m_workback.pop (); if (!single_pred_p (prev_bb)) { @@ -1775,7 +1793,7 @@ void ranger_cache::register_inferred_value (const vrange &ir, tree name, basic_block bb) { - Value_Range r (TREE_TYPE (name)); + value_range r (TREE_TYPE (name)); if (!m_on_entry.get_bb_range (r, name, bb)) exit_range (r, name, bb, RFD_READ_ONLY); if (r.intersect (ir)) diff --git a/gcc/gimple-range-cache.h b/gcc/gimple-range-cache.h index c7499f928a941..63410d5437e60 100644 --- a/gcc/gimple-range-cache.h +++ b/gcc/gimple-range-cache.h @@ -87,6 +87,7 @@ class ssa_lazy_cache : public ssa_cache virtual bool get_range (vrange &r, tree name) const; virtual void clear_range (tree name); virtual void clear (); + void merge (const ssa_lazy_cache &); protected: bitmap active_p; }; diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc index 98a4877ba18f9..65d31adde54c4 100644 --- a/gcc/gimple-range-fold.cc +++ b/gcc/gimple-range-fold.cc @@ -343,7 +343,7 @@ op1_range (vrange &r, gimple *s, const vrange &lhs, range_query *q) if (!op2_expr) return handler.calc_op1 (r, lhs); - Value_Range op2 (TREE_TYPE (op2_expr)); + value_range op2 (TREE_TYPE (op2_expr)); if (!src.get_operand (op2, op2_expr)) return false; @@ -359,7 +359,7 @@ op1_range (vrange &r, gimple *s, range_query *q) tree lhs_type = gimple_range_type (s); if (!lhs_type) return false; - Value_Range lhs_range; + value_range lhs_range; lhs_range.set_varying (lhs_type); return op1_range (r, s, lhs_range, q); } @@ -377,7 +377,7 @@ op2_range (vrange &r, gimple *s, const vrange &lhs, range_query *q) fur_stmt src (s, q); - Value_Range op1 (TREE_TYPE (handler.operand1 ())); + value_range op1 (TREE_TYPE (handler.operand1 ())); if (!src.get_operand (op1, handler.operand1 ())) return false; @@ -393,7 +393,7 @@ op2_range (vrange &r, gimple *s, range_query *q) tree lhs_type = gimple_range_type (s); if (!lhs_type) return false; - Value_Range lhs_range; + value_range lhs_range; lhs_range.set_varying (lhs_type); return op2_range (r, s, lhs_range, q); } @@ -493,7 +493,7 @@ fold_relations (gimple *s, range_query *q) tree lhs = gimple_range_ssa_p (gimple_get_lhs (s)); if (lhs) { - Value_Range vr(TREE_TYPE (lhs)); + value_range vr(TREE_TYPE (lhs)); if (f.fold_stmt (vr, s, src)) return src.trio (); } @@ -725,21 +725,21 @@ fold_using_range::range_of_range_op (vrange &r, // Certain types of builtin functions may have no arguments. if (!op1) { - Value_Range r1 (type); + value_range r1 (type); if (!handler.fold_range (r, type, r1, r1)) r.set_varying (type); return true; } - Value_Range range1 (TREE_TYPE (op1)); - Value_Range range2 (op2 ? TREE_TYPE (op2) : TREE_TYPE (op1)); + value_range range1 (TREE_TYPE (op1)); + value_range range2 (op2 ? TREE_TYPE (op2) : TREE_TYPE (op1)); if (src.get_operand (range1, op1)) { if (!op2) { // Fold range, and register any dependency if available. - Value_Range r2 (type); + value_range r2 (type); r2.set_varying (type); if (!handler.fold_range (r, type, range1, r2)) r.set_varying (type); @@ -913,8 +913,8 @@ fold_using_range::range_of_phi (vrange &r, gphi *phi, fur_source &src) { tree phi_def = gimple_phi_result (phi); tree type = gimple_range_type (phi); - Value_Range arg_range (type); - Value_Range equiv_range (type); + value_range arg_range (type); + value_range equiv_range (type); unsigned x; if (!type) @@ -1042,7 +1042,7 @@ fold_using_range::range_of_phi (vrange &r, gphi *phi, fur_source &src) class loop *l = loop_containing_stmt (phi); if (l && loop_outer (l)) { - Value_Range loop_range (type); + value_range loop_range (type); range_of_ssa_name_with_loop_info (loop_range, phi_def, l, phi, src); if (!loop_range.varying_p ()) { @@ -1089,7 +1089,7 @@ fold_using_range::range_of_call (vrange &r, gcall *call, fur_source &) if (callee && useless_type_conversion_p (TREE_TYPE (TREE_TYPE (callee)), type)) { - Value_Range val; + value_range val; if (ipa_return_value_range (val, callee)) { r.intersect (val); @@ -1105,9 +1105,9 @@ fold_using_range::range_of_call (vrange &r, gcall *call, fur_source &) } // If there is an LHS, intersect that with what is known. - if (lhs) + if (gimple_range_ssa_p (lhs)) { - Value_Range def (TREE_TYPE (lhs)); + value_range def (TREE_TYPE (lhs)); gimple_range_global (def, lhs); r.intersect (def); } @@ -1155,8 +1155,8 @@ fold_using_range::condexpr_adjust (vrange &r1, vrange &r2, gimple *, tree cond, // Pick up the current values of each part of the condition. tree rhs1 = gimple_assign_rhs1 (cond_def); tree rhs2 = gimple_assign_rhs2 (cond_def); - Value_Range cl (TREE_TYPE (rhs1)); - Value_Range cr (TREE_TYPE (rhs2)); + value_range cl (TREE_TYPE (rhs1)); + value_range cr (TREE_TYPE (rhs2)); src.get_operand (cl, rhs1); src.get_operand (cr, rhs2); @@ -1165,7 +1165,7 @@ fold_using_range::condexpr_adjust (vrange &r1, vrange &r2, gimple *, tree cond, // Evaluate the value of COND_NAME on the true and false edges, using either // the op1 or op2 routines based on its location. - Value_Range cond_true (type), cond_false (type); + value_range cond_true (type), cond_false (type); if (c1) { if (!hand.op1_range (cond_false, type, range_false (), cr)) @@ -1188,14 +1188,14 @@ fold_using_range::condexpr_adjust (vrange &r1, vrange &r2, gimple *, tree cond, // Now solve for SSA1 or SSA2 if they are in the dependency chain. if (ssa1 && src.gori_ssa()->in_chain_p (ssa1, cond_name)) { - Value_Range tmp1 (TREE_TYPE (ssa1)); + value_range tmp1 (TREE_TYPE (ssa1)); if (src.gori ()->compute_operand_range (tmp1, def_stmt, cond_true, ssa1, src)) r1.intersect (tmp1); } if (ssa2 && src.gori_ssa ()->in_chain_p (ssa2, cond_name)) { - Value_Range tmp2 (TREE_TYPE (ssa2)); + value_range tmp2 (TREE_TYPE (ssa2)); if (src.gori ()->compute_operand_range (tmp2, def_stmt, cond_false, ssa2, src)) r2.intersect (tmp2); @@ -1217,9 +1217,9 @@ fold_using_range::range_of_cond_expr (vrange &r, gassign *s, fur_source &src) if (!type) return false; - Value_Range range1 (TREE_TYPE (op1)); - Value_Range range2 (TREE_TYPE (op2)); - Value_Range cond_range (TREE_TYPE (cond)); + value_range range1 (TREE_TYPE (op1)); + value_range range2 (TREE_TYPE (op2)); + value_range cond_range (TREE_TYPE (cond)); gcc_checking_assert (gimple_assign_rhs_code (s) == COND_EXPR); gcc_checking_assert (range_compatible_p (TREE_TYPE (op1), TREE_TYPE (op2))); src.get_operand (cond_range, cond); @@ -1267,9 +1267,18 @@ fold_using_range::range_of_ssa_name_with_loop_info (vrange &r, tree name, // SCEV currently invokes get_range_query () for values. If the query // being passed in is not the same SCEV will use, do not invoke SCEV. // This can be remove if/when SCEV uses a passed in range-query. - if (src.query () != get_range_query (cfun) - || !range_of_var_in_loop (r, name, l, phi, src.query ())) - r.set_varying (TREE_TYPE (name)); + if (src.query () != get_range_query (cfun)) + { + r.set_varying (TREE_TYPE (name)); + // Report the msmatch if SRC is not the global query. The cache + // uses a global query and would provide numerous false positives. + if (dump_file && (dump_flags & TDF_DETAILS) + && src.query () != get_global_range_query ()) + fprintf (dump_file, + "fold_using-range:: SCEV not invoked due to mismatched queries\n"); + } + else if (!range_of_var_in_loop (r, name, l, phi, src.query ())) + r.set_varying (TREE_TYPE (name)); } // ----------------------------------------------------------------------- @@ -1417,7 +1426,7 @@ fur_source::register_outgoing_edges (gcond *s, irange &lhs_range, // if (a_2 < b_5) tree ssa1 = gimple_range_ssa_p (handler.operand1 ()); tree ssa2 = gimple_range_ssa_p (handler.operand2 ()); - Value_Range r1,r2; + value_range r1,r2; if (ssa1 && ssa2) { r1.set_varying (TREE_TYPE (ssa1)); @@ -1454,7 +1463,7 @@ fur_source::register_outgoing_edges (gcond *s, irange &lhs_range, continue; tree ssa1 = gimple_range_ssa_p (handler.operand1 ()); tree ssa2 = gimple_range_ssa_p (handler.operand2 ()); - Value_Range r (TREE_TYPE (name)); + value_range r (TREE_TYPE (name)); if (ssa1 && ssa2) { r1.set_varying (TREE_TYPE (ssa1)); diff --git a/gcc/gimple-range-fold.h b/gcc/gimple-range-fold.h index 491d57386f332..37c49596c3320 100644 --- a/gcc/gimple-range-fold.h +++ b/gcc/gimple-range-fold.h @@ -78,7 +78,7 @@ gimple_range_type (const gimple *s) type = TREE_TYPE (type); } } - if (type && Value_Range::supports_type_p (type)) + if (type && value_range::supports_type_p (type)) return type; return NULL_TREE; } @@ -91,7 +91,7 @@ gimple_range_ssa_p (tree exp) if (exp && TREE_CODE (exp) == SSA_NAME && !SSA_NAME_IS_VIRTUAL_OPERAND (exp) && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (exp) && - Value_Range::supports_type_p (TREE_TYPE (exp))) + value_range::supports_type_p (TREE_TYPE (exp))) return exp; return NULL_TREE; } diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc index d489aef312ce8..275283a424f09 100644 --- a/gcc/gimple-range-gori.cc +++ b/gcc/gimple-range-gori.cc @@ -632,7 +632,7 @@ gori_compute::compute_operand_range (vrange &r, gimple *stmt, // likely to be more applicable. if (op1 && op2) { - Value_Range r1, r2; + value_range r1, r2; r1.set_varying (TREE_TYPE (op1)); r2.set_varying (TREE_TYPE (op2)); relation_kind k = handler.op1_op2_relation (lhs, r1, r2); @@ -719,8 +719,8 @@ gori_compute::compute_operand_range (vrange &r, gimple *stmt, } tree type = TREE_TYPE (name); - Value_Range op1_trange (type), op1_frange (type); - Value_Range op2_trange (type), op2_frange (type); + value_range op1_trange (type), op1_frange (type); + value_range op2_trange (type), op2_frange (type); compute_logical_operands (op1_trange, op1_frange, handler, as_a (lhs), name, src, op1, op1_in_chain); @@ -739,7 +739,7 @@ gori_compute::compute_operand_range (vrange &r, gimple *stmt, if (op1_in_chain && op2_in_chain) return compute_operand1_and_operand2_range (r, handler, lhs, name, src, vrel_ptr); - Value_Range vr; + value_range vr; gimple *src_stmt; if (op1_in_chain) { @@ -864,7 +864,7 @@ gori_compute::logical_combine (vrange &r, enum tree_code code, if (!range_is_either_true_or_false (lhs)) { bool res; - Value_Range r1 (r); + value_range r1 (r); if (logical_combine (r1, code, m_bool_zero, op1_true, op1_false, op2_true, op2_false) && logical_combine (r, code, m_bool_one, op1_true, op1_false, @@ -899,11 +899,11 @@ gori_compute::logical_combine (vrange &r, enum tree_code code, else { // The FALSE side is the union of the other 3 cases. - Value_Range ff (op1_false); + value_range ff (op1_false); ff.intersect (op2_false); - Value_Range tf (op1_true); + value_range tf (op1_true); tf.intersect (op2_false); - Value_Range ft (op1_false); + value_range ft (op1_false); ft.intersect (op2_true); r = ff; r.union_ (tf); @@ -926,11 +926,11 @@ gori_compute::logical_combine (vrange &r, enum tree_code code, { // The TRUE side of an OR operation will be the union of // the other three combinations. - Value_Range tt (op1_true); + value_range tt (op1_true); tt.intersect (op2_true); - Value_Range tf (op1_true); + value_range tf (op1_true); tf.intersect (op2_false); - Value_Range ft (op1_false); + value_range ft (op1_false); ft.intersect (op2_true); r = tt; r.union_ (tf); @@ -1051,12 +1051,12 @@ gori_compute::refine_using_relation (tree op1, vrange &op1_range, if (def_op1 == use_op) { // def_stmt has op1 in the 1st operand position. - Value_Range other_op (TREE_TYPE (def_op2)); + value_range other_op (TREE_TYPE (def_op2)); src.get_operand (other_op, def_op2); // Using op1_range as the LHS, and relation REL, evaluate op2. tree type = TREE_TYPE (def_op1); - Value_Range new_result (type); + value_range new_result (type); if (!op_handler.op1_range (new_result, type, op1_def_p ? op1_range : op2_range, other_op, relation_trio::lhs_op1 (k))) @@ -1083,12 +1083,12 @@ gori_compute::refine_using_relation (tree op1, vrange &op1_range, else if (def_op2 == use_op) { // def_stmt has op1 in the 1st operand position. - Value_Range other_op (TREE_TYPE (def_op1)); + value_range other_op (TREE_TYPE (def_op1)); src.get_operand (other_op, def_op1); // Using op1_range as the LHS, and relation REL, evaluate op2. tree type = TREE_TYPE (def_op2); - Value_Range new_result (type); + value_range new_result (type); if (!op_handler.op2_range (new_result, type, op1_def_p ? op1_range : op2_range, other_op, relation_trio::lhs_op2 (k))) @@ -1134,8 +1134,8 @@ gori_compute::compute_operand1_range (vrange &r, if (rel) trio = rel->create_trio (lhs_name, op1, op2); - Value_Range op1_range (TREE_TYPE (op1)); - Value_Range op2_range (op2 ? TREE_TYPE (op2) : TREE_TYPE (op1)); + value_range op1_range (TREE_TYPE (op1)); + value_range op2_range (op2 ? TREE_TYPE (op2) : TREE_TYPE (op1)); // Fetch the known range for op1 in this block. src.get_operand (op1_range, op1); @@ -1211,8 +1211,8 @@ gori_compute::compute_operand2_range (vrange &r, tree op2 = handler.operand2 (); tree lhs_name = gimple_get_lhs (stmt); - Value_Range op1_range (TREE_TYPE (op1)); - Value_Range op2_range (TREE_TYPE (op2)); + value_range op1_range (TREE_TYPE (op1)); + value_range op2_range (TREE_TYPE (op2)); src.get_operand (op1_range, op1); src.get_operand (op2_range, op2); @@ -1276,9 +1276,9 @@ gori_compute::compute_operand1_and_operand2_range (vrange &r, fur_source &src, value_relation *rel) { - Value_Range op_range (TREE_TYPE (name)); + value_range op_range (TREE_TYPE (name)); - Value_Range vr (TREE_TYPE (handler.operand2 ())); + value_range vr (TREE_TYPE (handler.operand2 ())); // Calculate a good a range through op2. if (!compute_operand2_range (vr, handler, lhs, src, rel)) return false; @@ -1509,8 +1509,8 @@ class gori_stmt_info : public gimple_range_op_handler { public: gori_stmt_info (vrange &lhs, gimple *stmt, range_query *q); - Value_Range op1_range; - Value_Range op2_range; + value_range op1_range; + value_range op2_range; tree ssa1; tree ssa2; }; @@ -1597,7 +1597,7 @@ gori_calc_operands (vrange &lhs, gimple *stmt, ssa_cache &r, range_query *q) if (!si) return; - Value_Range tmp; + value_range tmp; // Now evaluate operand ranges, and set them in the edge cache. // If there was already a range, leave it and do no further evaluation. if (si.ssa1 && !r.has_range (si.ssa1)) @@ -1605,11 +1605,14 @@ gori_calc_operands (vrange &lhs, gimple *stmt, ssa_cache &r, range_query *q) tmp.set_type (TREE_TYPE (si.ssa1)); if (si.calc_op1 (tmp, lhs, si.op2_range)) si.op1_range.intersect (tmp); - r.set_range (si.ssa1, si.op1_range); - gimple *src = SSA_NAME_DEF_STMT (si.ssa1); - // If defintion is in the same basic lock, evaluate it. - if (src && gimple_bb (src) == gimple_bb (stmt)) - gori_calc_operands (si.op1_range, src, r, q); + if (!si.op1_range.varying_p ()) + { + r.set_range (si.ssa1, si.op1_range); + gimple *src = SSA_NAME_DEF_STMT (si.ssa1); + // If defintion is in the same basic lock, evaluate it. + if (src && gimple_bb (src) == gimple_bb (stmt)) + gori_calc_operands (si.op1_range, src, r, q); + } } if (si.ssa2 && !r.has_range (si.ssa2)) @@ -1617,10 +1620,13 @@ gori_calc_operands (vrange &lhs, gimple *stmt, ssa_cache &r, range_query *q) tmp.set_type (TREE_TYPE (si.ssa2)); if (si.calc_op2 (tmp, lhs, si.op1_range)) si.op2_range.intersect (tmp); - r.set_range (si.ssa2, si.op2_range); - gimple *src = SSA_NAME_DEF_STMT (si.ssa2); - if (src && gimple_bb (src) == gimple_bb (stmt)) - gori_calc_operands (si.op2_range, src, r, q); + if (!si.op2_range.varying_p ()) + { + r.set_range (si.ssa2, si.op2_range); + gimple *src = SSA_NAME_DEF_STMT (si.ssa2); + if (src && gimple_bb (src) == gimple_bb (stmt)) + gori_calc_operands (si.op2_range, src, r, q); + } } } @@ -1663,7 +1669,7 @@ gori_name_helper (vrange &r, tree name, vrange &lhs, gimple *stmt, if (si.ssa2 == name) return si.calc_op2 (r, lhs, si.op1_range); - Value_Range tmp; + value_range tmp; // Now evaluate operand ranges, and set them in the edge cache. // If there was already a range, leave it and do no further evaluation. if (si.ssa1) diff --git a/gcc/gimple-range-infer.cc b/gcc/gimple-range-infer.cc index 2571a4d127f18..98642e2438fc6 100644 --- a/gcc/gimple-range-infer.cc +++ b/gcc/gimple-range-infer.cc @@ -96,13 +96,13 @@ gimple_infer_range::check_assume_func (gcall *call) { tree op = gimple_call_arg (call, i); tree type = TREE_TYPE (op); - if (gimple_range_ssa_p (op) && Value_Range::supports_type_p (type)) + if (gimple_range_ssa_p (op) && value_range::supports_type_p (type)) { tree default_def = ssa_default_def (fun, arg); if (!default_def || type != TREE_TYPE (default_def)) continue; // Query the global range of the default def in the assume function. - Value_Range assume_range (type); + value_range assume_range (type); gimple_range_global (assume_range, default_def, fun); // If there is a non-varying result, add it as an inferred range. if (!assume_range.varying_p ()) @@ -218,14 +218,14 @@ gimple_infer_range::gimple_infer_range (gimple *s, bool use_rangeops) // query to pick up any other values. if (ssa1) { - Value_Range op1 (TREE_TYPE (ssa1)); + value_range op1 (TREE_TYPE (ssa1)); if (op1_range (op1, s, get_global_range_query ()) && !op1.varying_p ()) add_range (ssa1, op1); } else { gcc_checking_assert (ssa2); - Value_Range op2 (TREE_TYPE (ssa2)); + value_range op2 (TREE_TYPE (ssa2)); if (op2_range (op2, s, get_global_range_query ()) && !op2.varying_p ()) add_range (ssa2, op2); } @@ -355,7 +355,7 @@ infer_range_manager::maybe_adjust_range (vrange &r, tree name, basic_block bb) gcc_checking_assert (ptr); // Return true if this exit range changes R, otherwise false. tree type = TREE_TYPE (name); - Value_Range tmp (type); + value_range tmp (type); ptr->range->get_vrange (tmp, type); return r.intersect (tmp); } @@ -398,7 +398,7 @@ infer_range_manager::add_range (tree name, gimple *s, const vrange &r) if (ptr) { tree type = TREE_TYPE (name); - Value_Range cur (r), name_range (type); + value_range cur (r), name_range (type); ptr->range->get_vrange (name_range, type); // If no new info is added, just return. if (!cur.intersect (name_range)) diff --git a/gcc/gimple-range-infer.h b/gcc/gimple-range-infer.h index d2c151c4b9d0a..b11d28352adf9 100644 --- a/gcc/gimple-range-infer.h +++ b/gcc/gimple-range-infer.h @@ -45,7 +45,7 @@ class gimple_infer_range unsigned num_args; static const int size_limit = 10; tree m_names[size_limit]; - Value_Range m_ranges[size_limit]; + value_range m_ranges[size_limit]; inline void bump_index () { if (num_args < size_limit - 1) num_args++; } friend class non_null_wrapper; }; diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc index 1b9a84708b94e..a80b93cf06315 100644 --- a/gcc/gimple-range-op.cc +++ b/gcc/gimple-range-op.cc @@ -133,7 +133,7 @@ gimple_range_op_handler::gimple_range_op_handler (gimple *s) m_op1 = gimple_cond_lhs (m_stmt); m_op2 = gimple_cond_rhs (m_stmt); // Check that operands are supported types. One check is enough. - if (Value_Range::supports_type_p (TREE_TYPE (m_op1))) + if (value_range::supports_type_p (TREE_TYPE (m_op1))) m_operator = oper.range_op (); gcc_checking_assert (m_operator); return; @@ -153,7 +153,7 @@ gimple_range_op_handler::gimple_range_op_handler (gimple *s) if (gimple_num_ops (m_stmt) >= 3) m_op2 = gimple_assign_rhs2 (m_stmt); // Check that operands are supported types. One check is enough. - if ((m_op1 && !Value_Range::supports_type_p (TREE_TYPE (m_op1)))) + if ((m_op1 && !value_range::supports_type_p (TREE_TYPE (m_op1)))) return; m_operator = oper.range_op (); gcc_checking_assert (m_operator); @@ -185,7 +185,7 @@ gimple_range_op_handler::calc_op1 (vrange &r, const vrange &lhs_range) // Unary operations require the type of the first operand in the // second range position. tree type = TREE_TYPE (operand1 ()); - Value_Range type_range (type); + value_range type_range (type); type_range.set_varying (type); return op1_range (r, type, lhs_range, type_range); } @@ -218,7 +218,7 @@ gimple_range_op_handler::calc_op1 (vrange &r, const vrange &lhs_range, op2_type = TREE_TYPE (operand2 ()); else op2_type = TREE_TYPE (operand1 ()); - Value_Range trange (op2_type); + value_range trange (op2_type); trange.set_varying (op2_type); return op1_range (r, type, lhs_range, trange, k); } @@ -243,7 +243,7 @@ gimple_range_op_handler::calc_op2 (vrange &r, const vrange &lhs_range, if (op1_range.undefined_p ()) { tree op1_type = TREE_TYPE (operand1 ()); - Value_Range trange (op1_type); + value_range trange (op1_type); trange.set_varying (op1_type); return op2_range (r, type, lhs_range, trange, k); } @@ -1228,7 +1228,7 @@ gimple_range_op_handler::maybe_builtin_call () tree type = gimple_range_type (call); if (!type) return; - if (!Value_Range::supports_type_p (type)) + if (!value_range::supports_type_p (type)) return; switch (func) diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc index ef125a908822b..f64a7a5e8caee 100644 --- a/gcc/gimple-range-path.cc +++ b/gcc/gimple-range-path.cc @@ -161,7 +161,7 @@ path_range_query::internal_range_of_expr (vrange &r, tree name, gimple *stmt) { if (TREE_CODE (name) == SSA_NAME) { - Value_Range glob (TREE_TYPE (name)); + value_range glob (TREE_TYPE (name)); gimple_range_global (glob, name); r.intersect (glob); } @@ -237,7 +237,7 @@ path_range_query::ssa_range_in_phi (vrange &r, gphi *phi) // This will get things like PHI <5(99), 6(88)>. We do this by // calling range_of_expr with no context. unsigned nargs = gimple_phi_num_args (phi); - Value_Range arg_range (TREE_TYPE (name)); + value_range arg_range (TREE_TYPE (name)); r.set_undefined (); for (size_t i = 0; i < nargs; ++i) { @@ -263,7 +263,7 @@ path_range_query::ssa_range_in_phi (vrange &r, gphi *phi) { if (m_resolve) { - Value_Range tmp (TREE_TYPE (name)); + value_range tmp (TREE_TYPE (name)); // Using both the range on entry to the path, and the // range on this edge yields significantly better // results. @@ -339,7 +339,7 @@ path_range_query::compute_ranges_in_phis (basic_block bb) if (!exit_dependency_p (name)) continue; - Value_Range r (TREE_TYPE (name)); + value_range r (TREE_TYPE (name)); if (range_defined_in_block (r, name, bb)) m_cache.set_range (name, r); } @@ -385,7 +385,7 @@ path_range_query::compute_ranges_in_block (basic_block bb) EXECUTE_IF_SET_IN_BITMAP (m_exit_dependencies, 0, i, bi) { tree name = ssa_name (i); - Value_Range r (TREE_TYPE (name)); + value_range r (TREE_TYPE (name)); if (gimple_code (SSA_NAME_DEF_STMT (name)) != GIMPLE_PHI && range_defined_in_block (r, name, bb)) @@ -417,10 +417,10 @@ path_range_query::compute_ranges_in_block (basic_block bb) EXECUTE_IF_AND_IN_BITMAP (m_exit_dependencies, exports, 0, i, bi) { tree name = ssa_name (i); - Value_Range r (TREE_TYPE (name)); + value_range r (TREE_TYPE (name)); if (gori ().edge_range_p (r, e, name, *this)) { - Value_Range cached_range (TREE_TYPE (name)); + value_range cached_range (TREE_TYPE (name)); if (get_cache (cached_range, name)) r.intersect (cached_range); @@ -477,7 +477,7 @@ bool path_range_query::add_to_exit_dependencies (tree name, bitmap dependencies) { if (TREE_CODE (name) == SSA_NAME - && Value_Range::supports_type_p (TREE_TYPE (name))) + && value_range::supports_type_p (TREE_TYPE (name))) return bitmap_set_bit (dependencies, SSA_NAME_VERSION (name)); return false; } diff --git a/gcc/gimple-range-trace.cc b/gcc/gimple-range-trace.cc index 4c3d79c544828..e1679a1bfc9fa 100644 --- a/gcc/gimple-range-trace.cc +++ b/gcc/gimple-range-trace.cc @@ -152,7 +152,7 @@ debug_seed_ranger (gimple_ranger &ranger) if (tree type = gimple_range_type (stmt)) { - Value_Range r (type); + value_range r (type); ranger.range_of_stmt (r, stmt); } } diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc index be22bb4aa185e..f3e4ec2d249e7 100644 --- a/gcc/gimple-range.cc +++ b/gcc/gimple-range.cc @@ -101,7 +101,7 @@ gimple_ranger::range_of_expr (vrange &r, tree expr, gimple *stmt) // If there is no statement, just get the global value. if (!stmt) { - Value_Range tmp (TREE_TYPE (expr)); + value_range tmp (TREE_TYPE (expr)); // If there is no global range for EXPR yet, try to evaluate it. // This call sets R to a global range regardless. if (!m_cache.get_global_range (r, expr)) @@ -158,7 +158,7 @@ gimple_ranger::range_on_entry (vrange &r, basic_block bb, tree name) if (!gimple_range_ssa_p (name)) return get_tree_range (r, name, NULL, bb, NULL); - Value_Range entry_range (TREE_TYPE (name)); + value_range entry_range (TREE_TYPE (name)); unsigned idx; if ((idx = tracer.header ("range_on_entry ("))) @@ -219,7 +219,7 @@ gimple_ranger::range_on_exit (vrange &r, basic_block bb, tree name) bool gimple_ranger::range_on_edge (vrange &r, edge e, tree name) { - Value_Range edge_range (TREE_TYPE (name)); + value_range edge_range (TREE_TYPE (name)); if (!r.supports_type_p (TREE_TYPE (name))) return false; @@ -334,7 +334,7 @@ gimple_ranger::range_of_stmt (vrange &r, gimple *s, tree name) prefill_stmt_dependencies (name); // Calculate a new value. - Value_Range tmp (TREE_TYPE (name)); + value_range tmp (TREE_TYPE (name)); fold_range_internal (tmp, s, name); // Combine the new value with the old value. This is required because @@ -412,10 +412,10 @@ gimple_ranger::prefill_stmt_dependencies (tree ssa) { // Fold and save the value for NAME. stmt = SSA_NAME_DEF_STMT (name); - Value_Range r (TREE_TYPE (name)); + value_range r (TREE_TYPE (name)); fold_range_internal (r, stmt, name); // Make sure we don't lose any current global info. - Value_Range tmp (TREE_TYPE (name)); + value_range tmp (TREE_TYPE (name)); m_cache.get_global_range (tmp, name); bool changed = tmp.intersect (r); m_cache.set_global_range (name, tmp, changed); @@ -439,7 +439,7 @@ gimple_ranger::prefill_stmt_dependencies (tree ssa) gphi *phi = dyn_cast (stmt); if (phi) { - Value_Range r (TREE_TYPE (gimple_phi_result (phi))); + value_range r (TREE_TYPE (gimple_phi_result (phi))); for (unsigned x = 0; x < gimple_phi_num_args (phi); x++) prefill_name (r, gimple_phi_arg_def (phi, x)); } @@ -451,13 +451,13 @@ gimple_ranger::prefill_stmt_dependencies (tree ssa) tree op = handler.operand2 (); if (op) { - Value_Range r (TREE_TYPE (op)); + value_range r (TREE_TYPE (op)); prefill_name (r, op); } op = handler.operand1 (); if (op) { - Value_Range r (TREE_TYPE (op)); + value_range r (TREE_TYPE (op)); prefill_name (r, op); } } @@ -494,7 +494,7 @@ gimple_ranger::register_inferred_ranges (gimple *s) tree lhs = gimple_get_lhs (s); if (lhs) { - Value_Range tmp (TREE_TYPE (lhs)); + value_range tmp (TREE_TYPE (lhs)); if (range_of_stmt (tmp, s, lhs) && !tmp.varying_p () && set_range_info (lhs, tmp) && dump_file) { @@ -532,13 +532,13 @@ gimple_ranger::register_transitive_inferred_ranges (basic_block bb) if (!gimple_range_ssa_p (lhs) || infer_oracle ().has_range_p (bb, lhs)) continue; // Pick up global value. - Value_Range g (TREE_TYPE (lhs)); + value_range g (TREE_TYPE (lhs)); range_of_expr (g, lhs); // If either dependency has an inferred range, check if recalculating // the LHS is different than the global value. If so, register it as // an inferred range as well. - Value_Range r (TREE_TYPE (lhs)); + value_range r (TREE_TYPE (lhs)); r.set_undefined (); tree name1 = gori_ssa ()->depend1 (lhs); tree name2 = gori_ssa ()->depend2 (lhs); @@ -569,7 +569,7 @@ gimple_ranger::export_global_ranges () tree name = ssa_name (x); if (!name) continue; - Value_Range r (TREE_TYPE (name)); + value_range r (TREE_TYPE (name)); if (name && !SSA_NAME_IN_FREE_LIST (name) && gimple_range_ssa_p (name) && m_cache.get_global_range (r, name) @@ -615,7 +615,7 @@ gimple_ranger::dump_bb (FILE *f, basic_block bb) tree name = ssa_name (x); if (!gimple_range_ssa_p (name) || !SSA_NAME_DEF_STMT (name)) continue; - Value_Range range (TREE_TYPE (name)); + value_range range (TREE_TYPE (name)); if (gimple_bb (SSA_NAME_DEF_STMT (name)) == bb && m_cache.get_global_range (range, name)) { @@ -639,11 +639,11 @@ gimple_ranger::dump_bb (FILE *f, basic_block bb) if (!name || !gori ().has_edge_range_p (name, e)) continue; - Value_Range range (TREE_TYPE (name)); + value_range range (TREE_TYPE (name)); if (m_cache.range_on_edge (range, e, name)) { gimple *s = SSA_NAME_DEF_STMT (name); - Value_Range tmp_range (TREE_TYPE (name)); + value_range tmp_range (TREE_TYPE (name)); // Only print the range if this is the def block, or // the on entry cache for either end of the edge is // set. @@ -797,7 +797,7 @@ assume_query::~assume_query () void assume_query::calculate_op (tree op, gimple *s, vrange &lhs, fur_source &src) { - Value_Range op_range (TREE_TYPE (op)); + value_range op_range (TREE_TYPE (op)); if (gori ().compute_operand_range (op_range, s, lhs, op, src) && !op_range.varying_p ()) { @@ -819,7 +819,7 @@ assume_query::calculate_phi (gphi *phi, vrange &lhs_range, fur_source &src) for (unsigned x= 0; x < gimple_phi_num_args (phi); x++) { tree arg = gimple_phi_arg_def (phi, x); - Value_Range arg_range (TREE_TYPE (arg)); + value_range arg_range (TREE_TYPE (arg)); if (gimple_range_ssa_p (arg)) { // A symbol arg will be the LHS value. @@ -902,10 +902,10 @@ assume_query::dump (FILE *f) if (!name || !gimple_range_ssa_p (name)) continue; tree type = TREE_TYPE (name); - if (!Value_Range::supports_type_p (type)) + if (!value_range::supports_type_p (type)) continue; - Value_Range assume_range (type); + value_range assume_range (type); if (assume_range_p (assume_range, name)) { print_generic_expr (f, name, TDF_SLIM); @@ -1106,7 +1106,7 @@ dom_ranger::range_of_stmt (vrange &r, gimple *s, tree name) } basic_block bb = gimple_bb (s); unsigned bbi = bb->index; - Value_Range vr (TREE_TYPE (name)); + value_range vr (TREE_TYPE (name)); // If there is a range on edge 0, update it. if (m_e0[bbi] && m_e0[bbi]->has_range (name)) { diff --git a/gcc/go/ChangeLog b/gcc/go/ChangeLog index b255ae98160e1..810b2fa0e7ab9 100644 --- a/gcc/go/ChangeLog +++ b/gcc/go/ChangeLog @@ -1,3 +1,8 @@ +2024-06-07 Rainer Orth + + * gospec.cc (lang_specific_driver) [TARGET_SOLARIS !USE_GLD]: Only + add -t if linking. + 2024-05-26 Gerald Pfeifer * gccgo.texi (Top): Move a web reference from golang.org to go.dev. diff --git a/gcc/go/gospec.cc b/gcc/go/gospec.cc index b866d47a942fe..a3da23dfa3a7a 100644 --- a/gcc/go/gospec.cc +++ b/gcc/go/gospec.cc @@ -443,8 +443,11 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, using the GNU linker, the Solaris linker needs an option to not warn about this. Everything works without this option, but you get unsightly warnings at link time. */ - generate_option (OPT_Wl_, "-t", 1, CL_DRIVER, &new_decoded_options[j]); - j++; + if (library > 0) + { + generate_option (OPT_Wl_, "-t", 1, CL_DRIVER, &new_decoded_options[j]); + j++; + } #endif *in_decoded_options_count = j; diff --git a/gcc/graph.cc b/gcc/graph.cc index 5689a64b20b44..07da0798f51d0 100644 --- a/gcc/graph.cc +++ b/gcc/graph.cc @@ -310,7 +310,7 @@ void DEBUG_FUNCTION print_graph_cfg (FILE *fp, struct function *fun) { pretty_printer graph_slim_pp; - graph_slim_pp.buffer->stream = fp; + graph_slim_pp.set_output_stream (fp); pretty_printer *const pp = &graph_slim_pp; const char *funcname = function_name (fun); pp_printf (pp, "subgraph \"cluster_%s\" {\n" @@ -354,7 +354,7 @@ static void start_graph_dump (FILE *fp, const char *base) { pretty_printer graph_slim_pp; - graph_slim_pp.buffer->stream = fp; + graph_slim_pp.set_output_stream (fp); pretty_printer *const pp = &graph_slim_pp; pp_string (pp, "digraph \""); pp_write_text_to_stream (pp); diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc index 408166b8044b2..56468dc40ee4f 100644 --- a/gcc/ipa-cp.cc +++ b/gcc/ipa-cp.cc @@ -775,7 +775,7 @@ ipcp_vr_lattice::meet_with_1 (const vrange &other_vr) bool res; if (flag_checking) { - Value_Range save (m_vr); + value_range save (m_vr); res = m_vr.union_ (other_vr); gcc_assert (res == (m_vr != save)); } @@ -1656,7 +1656,7 @@ ipa_vr_operation_and_type_effects (vrange &dst_vr, if (!handler) return false; - Value_Range varying (dst_type); + value_range varying (dst_type); varying.set_varying (dst_type); return (handler.operand_check_p (dst_type, src_type, dst_type) @@ -1674,7 +1674,7 @@ ipa_vr_operation_and_type_effects (vrange &dst_vr, enum tree_code operation, tree dst_type, tree src_type) { - Value_Range tmp; + value_range tmp; src_vr.get_vrange (tmp); return ipa_vr_operation_and_type_effects (dst_vr, tmp, operation, dst_type, src_type); @@ -1713,14 +1713,14 @@ ipa_value_range_from_jfunc (vrange &vr, if (!(*sum->m_vr)[idx].known_p ()) return; tree vr_type = ipa_get_type (info, idx); - Value_Range srcvr; + value_range srcvr; (*sum->m_vr)[idx].get_vrange (srcvr); enum tree_code operation = ipa_get_jf_pass_through_operation (jfunc); if (TREE_CODE_CLASS (operation) == tcc_unary) { - Value_Range res (parm_type); + value_range res (parm_type); if (ipa_vr_operation_and_type_effects (res, srcvr, @@ -1730,10 +1730,10 @@ ipa_value_range_from_jfunc (vrange &vr, } else { - Value_Range op_res (vr_type); - Value_Range res (vr_type); + value_range op_res (vr_type); + value_range res (vr_type); tree op = ipa_get_jf_pass_through_operand (jfunc); - Value_Range op_vr (TREE_TYPE (op)); + value_range op_vr (TREE_TYPE (op)); range_op_handler handler (operation); ipa_range_set_and_normalize (op_vr, op); @@ -2486,7 +2486,7 @@ propagate_bits_across_jump_function (cgraph_edge *cs, int idx, } } - Value_Range vr (parm_type); + value_range vr (parm_type); if (jfunc->m_vr) { jfunc->m_vr->get_vrange (vr); @@ -2534,7 +2534,7 @@ propagate_vr_across_jump_function (cgraph_edge *cs, ipa_jump_func *jfunc, if (src_lats->m_value_range.bottom_p ()) return dest_lat->set_to_bottom (); - Value_Range vr (param_type); + value_range vr (param_type); if (TREE_CODE_CLASS (operation) == tcc_unary) ipa_vr_operation_and_type_effects (vr, src_lats->m_value_range.m_vr, @@ -2546,8 +2546,8 @@ propagate_vr_across_jump_function (cgraph_edge *cs, ipa_jump_func *jfunc, else if (!ipa_edge_within_scc (cs)) { tree op = ipa_get_jf_pass_through_operand (jfunc); - Value_Range op_vr (TREE_TYPE (op)); - Value_Range op_res (param_type); + value_range op_vr (TREE_TYPE (op)); + value_range op_res (param_type); range_op_handler handler (operation); ipa_range_set_and_normalize (op_vr, op); @@ -2576,7 +2576,7 @@ propagate_vr_across_jump_function (cgraph_edge *cs, ipa_jump_func *jfunc, { if (jfunc->m_vr) { - Value_Range jvr (param_type); + value_range jvr (param_type); if (ipa_vr_operation_and_type_effects (jvr, *jfunc->m_vr, NOP_EXPR, param_type, @@ -2595,12 +2595,12 @@ propagate_vr_across_jump_function (cgraph_edge *cs, ipa_jump_func *jfunc, if (TREE_OVERFLOW_P (val)) val = drop_tree_overflow (val); - Value_Range tmpvr (val, val); + value_range tmpvr (val, val); return dest_lat->meet_with (tmpvr); } } - Value_Range vr (param_type); + value_range vr (param_type); if (jfunc->m_vr && ipa_vr_operation_and_type_effects (vr, *jfunc->m_vr, NOP_EXPR, param_type, @@ -6359,7 +6359,7 @@ ipcp_store_vr_results (void) { if (bits) { - Value_Range tmp = plats->m_value_range.m_vr; + value_range tmp = plats->m_value_range.m_vr; tree type = ipa_get_type (info, i); irange_bitmask bm (wide_int::from (bits->get_value (), TYPE_PRECISION (type), @@ -6380,7 +6380,7 @@ ipcp_store_vr_results (void) else if (bits) { tree type = ipa_get_type (info, i); - Value_Range tmp; + value_range tmp; tmp.set_varying (type); irange_bitmask bm (wide_int::from (bits->get_value (), TYPE_PRECISION (type), diff --git a/gcc/ipa-cp.h b/gcc/ipa-cp.h index e62a09f38af6d..4616c61625ab4 100644 --- a/gcc/ipa-cp.h +++ b/gcc/ipa-cp.h @@ -230,7 +230,7 @@ class ipcp_bits_lattice class ipcp_vr_lattice { public: - Value_Range m_vr; + value_range m_vr; inline bool bottom_p () const; inline bool top_p () const; diff --git a/gcc/ipa-fnsummary.cc b/gcc/ipa-fnsummary.cc index 2faf238929711..b382478340659 100644 --- a/gcc/ipa-fnsummary.cc +++ b/gcc/ipa-fnsummary.cc @@ -489,7 +489,7 @@ evaluate_conditions_for_known_args (struct cgraph_node *node, && !c->agg_contents && (!val || TREE_CODE (val) != INTEGER_CST)) { - Value_Range vr (avals->m_known_value_ranges[c->operand_num]); + value_range vr (avals->m_known_value_ranges[c->operand_num]); if (!vr.undefined_p () && !vr.varying_p () && (TYPE_SIZE (c->type) == TYPE_SIZE (vr.type ()))) @@ -502,10 +502,10 @@ evaluate_conditions_for_known_args (struct cgraph_node *node, if (vr.varying_p () || vr.undefined_p ()) break; - Value_Range res (op->type); + value_range res (op->type); if (!op->val[0]) { - Value_Range varying (op->type); + value_range varying (op->type); varying.set_varying (op->type); range_op_handler handler (op->code); if (!handler @@ -515,7 +515,7 @@ evaluate_conditions_for_known_args (struct cgraph_node *node, } else if (!op->val[1]) { - Value_Range op0 (TREE_TYPE (op->val[0])); + value_range op0 (TREE_TYPE (op->val[0])); range_op_handler handler (op->code); ipa_range_set_and_normalize (op0, op->val[0]); @@ -534,7 +534,7 @@ evaluate_conditions_for_known_args (struct cgraph_node *node, if (!vr.varying_p () && !vr.undefined_p ()) { int_range<2> res; - Value_Range val_vr (TREE_TYPE (c->val)); + value_range val_vr (TREE_TYPE (c->val)); range_op_handler handler (c->code); ipa_range_set_and_normalize (val_vr, c->val); @@ -675,7 +675,7 @@ evaluate_properties_for_edge (struct cgraph_edge *e, bool inline_p, && vrp_will_run_p (caller) && ipa_is_param_used_by_ipa_predicates (callee_pi, i)) { - Value_Range vr (type); + value_range vr (type); ipa_value_range_from_jfunc (vr, caller_parms_info, e, jf, type); if (!vr.undefined_p () && !vr.varying_p ()) diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc index 2d5c51298f2b4..7d7cb3835d2b8 100644 --- a/gcc/ipa-prop.cc +++ b/gcc/ipa-prop.cc @@ -80,7 +80,7 @@ struct ipa_vr_ggc_hash_traits : public ggc_cache_remove // This never get called, except in the verification code, as // ipa_get_value_range() calculates the hash itself. This // function is mostly here for completness' sake. - Value_Range vr; + value_range vr; p->get_vrange (vr); inchash::hash hstate; add_vrange (vr, hstate); @@ -165,13 +165,13 @@ ipa_vr::equal_p (const ipa_vr &o) const if (!types_compatible_p (m_type, o.m_type)) return false; - Value_Range r; + value_range r; o.get_vrange (r); return m_storage->equal_p (r); } void -ipa_vr::get_vrange (Value_Range &r) const +ipa_vr::get_vrange (value_range &r) const { r.set_type (m_type); m_storage->get_vrange (r, m_type); @@ -193,7 +193,7 @@ ipa_vr::streamer_read (lto_input_block *ib, data_in *data_in) bool known = bp_unpack_value (&bp, 1); if (known) { - Value_Range vr; + value_range vr; streamer_read_value_range (ib, data_in, vr); if (!m_storage || !m_storage->fits_p (vr)) { @@ -219,7 +219,7 @@ ipa_vr::streamer_write (output_block *ob) const streamer_write_bitpack (&bp); if (m_storage) { - Value_Range vr (m_type); + value_range vr (m_type); m_storage->get_vrange (vr, m_type); streamer_write_vrange (ob, vr); } @@ -230,7 +230,7 @@ ipa_vr::dump (FILE *out) const { if (known_p ()) { - Value_Range vr (m_type); + value_range vr (m_type); m_storage->get_vrange (vr, m_type); vr.dump (out); } @@ -2299,7 +2299,7 @@ ipa_set_jfunc_vr (ipa_jump_func *jf, const vrange &tmp) static void ipa_set_jfunc_vr (ipa_jump_func *jf, const ipa_vr &vr) { - Value_Range tmp; + value_range tmp; vr.get_vrange (tmp); ipa_set_jfunc_vr (jf, tmp); } @@ -2347,7 +2347,7 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi, useful_context = true; } - Value_Range vr (TREE_TYPE (arg)); + value_range vr (TREE_TYPE (arg)); if (POINTER_TYPE_P (TREE_TYPE (arg))) { bool addr_nonzero = false; @@ -2397,7 +2397,7 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi, && get_range_query (cfun)->range_of_expr (vr, arg, cs->call_stmt) && !vr.undefined_p ()) { - Value_Range resvr (vr); + value_range resvr (vr); range_cast (resvr, param_type); if (!resvr.undefined_p () && !resvr.varying_p ()) ipa_set_jfunc_vr (jfunc, resvr); @@ -5778,7 +5778,7 @@ ipcp_get_parm_bits (tree parm, tree *value, widest_int *mask) vec &vr = *ts->m_vr; if (!vr[i].known_p ()) return false; - Value_Range tmp; + value_range tmp; vr[i].get_vrange (tmp); if (tmp.undefined_p () || tmp.varying_p ()) return false; @@ -5837,7 +5837,7 @@ ipcp_update_vr (struct cgraph_node *node, ipcp_transformation *ts) if (vr[i].known_p ()) { - Value_Range tmp; + value_range tmp; vr[i].get_vrange (tmp); if (!tmp.undefined_p () && !tmp.varying_p ()) @@ -6007,7 +6007,7 @@ ipcp_transform_function (struct cgraph_node *node) /* Record that current function return value range is VAL. */ void -ipa_record_return_value_range (Value_Range val) +ipa_record_return_value_range (value_range val) { cgraph_node *n = cgraph_node::get (current_function_decl); if (!ipa_return_value_sum) @@ -6030,7 +6030,7 @@ ipa_record_return_value_range (Value_Range val) /* Return true if value range of DECL is known and if so initialize RANGE. */ bool -ipa_return_value_range (Value_Range &range, tree decl) +ipa_return_value_range (value_range &range, tree decl) { cgraph_node *n = cgraph_node::get (decl); if (!n || !ipa_return_value_sum) diff --git a/gcc/ipa-prop.h b/gcc/ipa-prop.h index 93d1b87b1f7f0..7a05c169c421d 100644 --- a/gcc/ipa-prop.h +++ b/gcc/ipa-prop.h @@ -306,7 +306,7 @@ class GTY(()) ipa_vr void set_unknown (); bool known_p () const { return m_storage != NULL; } tree type () const { return m_type; } - void get_vrange (Value_Range &) const; + void get_vrange (value_range &) const; bool equal_p (const vrange &) const; bool equal_p (const ipa_vr &) const; const vrange_storage *storage () const { return m_storage; } @@ -521,7 +521,7 @@ class ipa_auto_call_arg_values auto_vec m_known_aggs; /* Vector describing known value ranges of arguments. */ - auto_vec m_known_value_ranges; + auto_vec m_known_value_ranges; }; inline @@ -573,7 +573,7 @@ class ipa_call_arg_values vec m_known_aggs = vNULL; /* Vector describing known value ranges of arguments. */ - vec m_known_value_ranges = vNULL; + vec m_known_value_ranges = vNULL; }; inline @@ -1277,8 +1277,8 @@ ipa_range_set_and_normalize (vrange &r, tree val) r.set (val, val); } -bool ipa_return_value_range (Value_Range &range, tree decl); -void ipa_record_return_value_range (Value_Range val); +bool ipa_return_value_range (value_range &range, tree decl); +void ipa_record_return_value_range (value_range val); bool ipa_jump_functions_equivalent_p (ipa_jump_func *jf1, ipa_jump_func *jf2); diff --git a/gcc/jit/ChangeLog b/gcc/jit/ChangeLog index d9cfc6ab4c672..8cddec52462ee 100644 --- a/gcc/jit/ChangeLog +++ b/gcc/jit/ChangeLog @@ -1,3 +1,14 @@ +2024-06-12 David Malcolm + + * jit-recording.cc (recording::function::dump_to_dot): Update for + fields of pretty_printer becoming private. + +2024-06-11 Andrew Pinski + + PR jit/115442 + * jit-recording.cc: Define INCLUDE_SSTREAM before including + system.h and don't directly incldue sstream. + 2024-04-09 Jakub Jelinek * docs/topics/expressions.rst (Constructor expressions): Fix diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc index 68a2e860c1fbf..8a1ec2d980631 100644 --- a/gcc/jit/jit-recording.cc +++ b/gcc/jit/jit-recording.cc @@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see . */ #include "config.h" +#define INCLUDE_SSTREAM #include "system.h" #include "coretypes.h" #include "tm.h" @@ -29,7 +30,6 @@ along with GCC; see the file COPYING3. If not see #include "jit-builtins.h" #include "jit-recording.h" #include "jit-playback.h" -#include namespace gcc { namespace jit { @@ -4410,7 +4410,7 @@ recording::function::dump_to_dot (const char *path) return; pretty_printer the_pp; - the_pp.buffer->stream = fp; + the_pp.set_output_stream (fp); pretty_printer *pp = &the_pp; diff --git a/gcc/langhooks.cc b/gcc/langhooks.cc index 94d1f4e5a2c60..61f2b67625655 100644 --- a/gcc/langhooks.cc +++ b/gcc/langhooks.cc @@ -466,8 +466,7 @@ lhd_print_error_function (diagnostic_context *context, const char *file, diagnostic_set_last_function (context, diagnostic); pp_newline_and_flush (context->printer); - context->printer->prefix = old_prefix; - free ((char*) new_prefix); + context->printer->set_prefix (old_prefix); } } diff --git a/gcc/logical-location.h b/gcc/logical-location.h index abe2c3a648ef8..bba2108778629 100644 --- a/gcc/logical-location.h +++ b/gcc/logical-location.h @@ -21,6 +21,8 @@ along with GCC; see the file COPYING3. If not see #ifndef GCC_LOGICAL_LOCATION_H #define GCC_LOGICAL_LOCATION_H +#include "label-text.h" + /* An enum for discriminating between different kinds of logical location for a diagnostic. @@ -46,7 +48,8 @@ enum logical_location_kind - "within function 'foo'", or - "within method 'bar'", but *without* requiring knowledge of trees - (see tree-logical-location.h for subclasses relating to trees). */ + (see tree-logical-location.h for concrete subclasses relating to trees, + and selftest-logical-location.h for a concrete subclass for selftests). */ class logical_location { @@ -67,6 +70,11 @@ class logical_location /* Get what kind of SARIF logicalLocation this is (if any). */ virtual enum logical_location_kind get_kind () const = 0; + + /* Get a string for this location in a form suitable for path output. */ + virtual label_text get_name_for_path_output () const = 0; + + bool function_p () const; }; #endif /* GCC_LOGICAL_LOCATION_H. */ diff --git a/gcc/lto-wrapper.cc b/gcc/lto-wrapper.cc index 6dcf8b469a3cf..84835a888ef14 100644 --- a/gcc/lto-wrapper.cc +++ b/gcc/lto-wrapper.cc @@ -1361,11 +1361,11 @@ init_num_threads (void) void print_lto_docs_link () { - bool print_url = global_dc->printer->url_format != URL_FORMAT_NONE; + bool print_url = global_dc->printer->supports_urls_p (); const char *url = global_dc->make_option_url (OPT_flto); pretty_printer pp; - pp.url_format = URL_FORMAT_DEFAULT; + pp.set_url_format (URL_FORMAT_DEFAULT); pp_string (&pp, "see the "); if (print_url) pp_begin_url (&pp, url); diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index 89b9fceb2764f..718c556bbda37 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -1,3 +1,28 @@ +2024-06-07 Simon Martin + + * lto-partition.cc: Define INCLUDE_VECTOR to avoid running into + poisoned identifiers. + +2024-06-07 Michal Jires + + * lto-partition.cc (new_partition): Use new_partition_no_push. + (new_partition_no_push): New. + (free_ltrans_partition): New. + (free_ltrans_partitions): Use free_ltrans_partition. + (join_partitions): New. + (split_partition_into_nodes): New. + (is_partition_reorder): New. + (class partition_set): New. + (distribute_n_partitions): New. + (partition_over_target_split): New. + (partition_binary_split): New. + (partition_fixed_split): New. + (class partitioner_base): New. + (class partitioner_default): New. + (lto_cache_map): New. + * lto-partition.h (lto_cache_map): New. + * lto.cc (do_whole_program_analysis): Use lto_cache_map. + 2024-06-06 Michal Jires * lto-common.cc (lto_section_with_id): Dont load suffix during LTRANS. diff --git a/gcc/lto/lto-partition.cc b/gcc/lto/lto-partition.cc index 19f91e5d6607b..2238650fa0eb0 100644 --- a/gcc/lto/lto-partition.cc +++ b/gcc/lto/lto-partition.cc @@ -18,6 +18,7 @@ along with GCC; see the file COPYING3. If not see . */ #include "config.h" +#define INCLUDE_VECTOR #include "system.h" #include "coretypes.h" #include "target.h" @@ -37,6 +38,8 @@ along with GCC; see the file COPYING3. If not see #include "ipa-fnsummary.h" #include "lto-partition.h" +#include + vec ltrans_partitions; static void add_symbol_to_partition (ltrans_partition part, symtab_node *node); @@ -60,20 +63,41 @@ cmp_partitions_order (const void *a, const void *b) return orderb - ordera; } -/* Create new partition with name NAME. */ - +/* Create new partition with name NAME. + Does not push into ltrans_partitions. */ static ltrans_partition -new_partition (const char *name) +new_partition_no_push (const char *name) { ltrans_partition part = XCNEW (struct ltrans_partition_def); part->encoder = lto_symtab_encoder_new (false); part->name = name; part->insns = 0; part->symbols = 0; + return part; +} + +/* Create new partition with name NAME. */ + +static ltrans_partition +new_partition (const char *name) +{ + ltrans_partition part = new_partition_no_push (name); ltrans_partitions.safe_push (part); return part; } +/* Free memory used by ltrans partition. + Encoder can be kept to be freed after streaming. */ +static void +free_ltrans_partition (ltrans_partition part, bool delete_encoder) +{ + if (part->initializers_visited) + delete part->initializers_visited; + if (delete_encoder) + lto_symtab_encoder_delete (part->encoder); + free (part); +} + /* Free memory used by ltrans datastructures. */ void @@ -82,12 +106,7 @@ free_ltrans_partitions (void) unsigned int idx; ltrans_partition part; for (idx = 0; ltrans_partitions.iterate (idx, &part); idx++) - { - if (part->initializers_visited) - delete part->initializers_visited; - /* Symtab encoder is freed after streaming. */ - free (part); - } + free_ltrans_partition (part, false); ltrans_partitions.release (); } @@ -428,6 +447,574 @@ account_reference_p (symtab_node *n1, symtab_node *n2) return true; } +/* Joins two partitions into one. + NULL partitions are equivalent to empty partition. + If both partition are non-null, symbols from FROM are added into INTO. */ +static ltrans_partition +join_partitions (ltrans_partition into, ltrans_partition from) +{ + if (!into) + return from; + if (!from) + return into; + + lto_symtab_encoder_iterator lsei; + lto_symtab_encoder_t encoder = from->encoder; + + /* If aux is non zero, it will not be added to the new partition. Since + adding symbols is recursive, it is safer to reduce aux of all symbols + before adding any symbols to other partition. */ + for (lsei = lsei_start (encoder); !lsei_end_p (lsei); lsei_next (&lsei)) + { + symtab_node *node = lsei_node (lsei); + node->aux = (void *)((size_t)node->aux - 1); + } + + for (lsei = lsei_start (encoder); !lsei_end_p (lsei); lsei_next (&lsei)) + { + symtab_node *node = lsei_node (lsei); + + if (symbol_partitioned_p (node)) + continue; + + add_symbol_to_partition (into, node); + } + + free_ltrans_partition (from, true); + + return into; +} + +/* Takes symbols from given partitions and splits them into N partitions where + each partitions contains one symbol and its requirements. */ +static std::vector +split_partition_into_nodes (ltrans_partition part) +{ + std::vector partitions; + + lto_symtab_encoder_iterator lsei; + lto_symtab_encoder_t encoder = part->encoder; + + for (lsei = lsei_start (encoder); !lsei_end_p (lsei); lsei_next (&lsei)) + { + symtab_node *node = lsei_node (lsei); + node->aux = (void *)((size_t)node->aux - 1); + } + + for (lsei = lsei_start (encoder); !lsei_end_p (lsei); lsei_next (&lsei)) + { + symtab_node *node = lsei_node (lsei); + + if (node->get_partitioning_class () != SYMBOL_PARTITION + || symbol_partitioned_p (node)) + continue; + + ltrans_partition new_part = new_partition_no_push (part->name); + add_symbol_to_partition (new_part, node); + partitions.push_back (new_part); + } + + return partitions; +} + +/* Returns whether partition contains symbols that cannot be reordered. */ +static bool +is_partition_reorder (ltrans_partition part) +{ + lto_symtab_encoder_iterator lsei; + lto_symtab_encoder_t encoder = part->encoder; + + for (lsei = lsei_start (encoder); !lsei_end_p (lsei); lsei_next (&lsei)) + { + symtab_node *node = lsei_node (lsei); + if (node->no_reorder) + return false; + } + return true; +} + +/* Represents groups of symbols, that should be partitioned into n_partitions + partitions. */ +class partition_set +{ +public: + /* Metadata to easily pass copy to new partition_set. */ + class metadata + { + public: + /* Partitions can be reordered. */ + bool reorder; + /* Partitions can be split into individual symbols. */ + bool splitable; + + metadata (bool reorder, bool splitable): + reorder (reorder), splitable (splitable) + {} + }; + metadata data; + + /* Symbol groups. Use push (g) to insert symbols. */ + std::vector sym_groups; + /* Number of partitions these symbols should be partitioned into. */ + size_t n_partitions; + /* Total number of instructions of all symbols. */ + int64_t insns; + + /* Constructor. Symbols and n_partitions can be added later. */ + partition_set (metadata data, std::vector sym_groups = {}, + size_t n_partitions = 0) + : data (data), sym_groups (std::move (sym_groups)), + n_partitions (n_partitions), insns (0) + { + for (ltrans_partition g: this->sym_groups) + insns += g->insns; + } + + /* Adds symbol group and updates total insns. */ + void + push (ltrans_partition g) + { + sym_groups.push_back (g); + insns += g->insns; + } + + /* Returns whether any symbols group is contained. */ + bool + empty () + { + return sym_groups.empty (); + } +}; + +/* Distributes total n_partitions among partition_sets. + Aims to be as fair as possible. */ +static void +distribute_n_partitions (std::vector& ps, size_t n_partitions) +{ + gcc_assert (ps.size ()); + gcc_assert (ps.size () <= n_partitions); + + int64_t total_size = 0; + + for (partition_set& p: ps) + { + total_size += p.insns; + p.n_partitions = 0; + } + + if (total_size <= 0) + total_size = 1; + + size_t n_partitions_allocated = 0; + + /* First we allocate largest amount of partitions so that target_sizes are + larger than target size of total (insns/total_size). + All partition_set must have n_partitions at least one. */ + for (partition_set& p: ps) + { + p.n_partitions = n_partitions * p.insns / total_size; + if (p.n_partitions == 0 && p.sym_groups.size ()) + p.n_partitions = 1; + if (!p.data.splitable) + p.n_partitions = std::min (p.n_partitions, p.sym_groups.size ()); + + n_partitions_allocated += p.n_partitions; + } + + /* Rare special case, with a lot of initially 0 sized splits. */ + while (n_partitions_allocated > n_partitions) + { + size_t idx = 0; + int64_t min = std::numeric_limits::max (); + + for (size_t i = 0; i < ps.size (); ++i) + { + if (ps[i].n_partitions <= 1) + continue; + + int64_t target_size = ps[i].insns / ps[i].n_partitions; + if (min > target_size) + { + min = target_size; + idx = i; + } + } + + ps[idx].n_partitions--; + n_partitions_allocated--; + } + + /* Typical case where with any increase of n_partitions target size will cross + total target size. We optimize for minimal: + (old_target_size - total_target_size) + - (total_target_size - new_target_size). */ + while (n_partitions_allocated < n_partitions) + { + size_t idx = 0; + int64_t max = 0; + + for (size_t i = 0; i < ps.size (); ++i) + { + if (ps[i].sym_groups.size () <= 1 && !ps[i].data.splitable) + continue; + + int64_t target_size = ps[i].insns / ps[i].n_partitions; + int64_t new_target_size = ps[i].insns / (ps[i].n_partitions + 1); + + int64_t positive_change = target_size + new_target_size; + + if (max < positive_change) + { + max = positive_change; + idx = i; + } + } + + ps[idx].n_partitions++; + n_partitions_allocated++; + } +} + +/* Splits off symbol groups that are larger than target size. + n_partitions are then distributed between individual + split off symbol groups, and everything else as a whole. + + Split off symbol groups with n_partitions > 1, are + then split into individual symbols. + + Order is not conserved. This pass is ignored if reorder is not allowed. */ +static std::vector +partition_over_target_split (partition_set& p) +{ + gcc_assert (p.n_partitions >= 1); + + std::vector all; + partition_set small (p.data); + + int64_t target_size = p.insns / p.n_partitions; + + for (ltrans_partition g: p.sym_groups) + { + if (g->insns > target_size + && (p.data.reorder || is_partition_reorder (g))) + all.push_back (partition_set (p.data, {g})); + else + small.push (g); + } + + if (all.empty ()) + return {}; + + if (small.sym_groups.size ()) + { + /* Handles special case where n_partitions might be smaller than + all.size (). Which can happen as result of interger division or with + 0 sized partition_sets. Then also prevents too small symbol group. + This should also be a special case; more common one, + but with no correctness problems. */ + if (all.size () && ( + small.insns < (int64_t) p.n_partitions + || small.insns < target_size * 0.6 + || small.insns < param_min_partition_size)) + { + size_t idx = 0; + int64_t min_insns = std::numeric_limits::max (); + for (size_t i = 0; i < all.size (); ++i) + { + if (all[i].insns < min_insns) + { + min_insns = all[i].insns; + idx = i; + } + } + + gcc_assert (all[idx].sym_groups.size () == 1); + + ltrans_partition& into = all[idx].sym_groups[0]; + for (ltrans_partition g: small.sym_groups) + into = join_partitions (into, g); + + all[idx].insns = into->insns; + } + else + { + gcc_assert (all.size () < p.n_partitions); + all.push_back (std::move (small)); + } + } + + distribute_n_partitions (all, p.n_partitions); + + for (partition_set& p: all) + { + gcc_assert (p.sym_groups.size ()); + + /* Handles large symbol groups (large files) that will be + further divided. */ + if (p.sym_groups.size () == 1 && p.n_partitions > 1) + { + p.sym_groups = split_partition_into_nodes (p.sym_groups[0]); + p.data.reorder = false; + p.data.splitable = false; + } + } + + return all; +} + +/* Splits partition_set into two partition_sets with + equal or off by one n_partitions. + Order is conserved. */ +static std::vector +partition_binary_split (partition_set& p) +{ + gcc_assert (p.n_partitions > 1); + + if (p.sym_groups.size () < 2) + return {}; + + int64_t target_size = p.insns / p.n_partitions; + + + std::vector result (2, partition_set (p.data)); + partition_set& first = result[0]; + partition_set& second = result[1]; + + first.n_partitions = p.n_partitions/2; + second.n_partitions = p.n_partitions - first.n_partitions; + + int64_t first_target_size = first.n_partitions * target_size; + + int64_t insns = 0; + for (ltrans_partition g: p.sym_groups) + { + /* We want at least one symbol in first partition. */ + if (first.empty ()) + first.push (g); + else if (insns < first_target_size) + { + if (insns + g->insns < first_target_size) + first.push (g); + else + { + /* Target splitting point is in this symbol group. */ + int64_t diff_first = first_target_size - insns; + int64_t diff_second = (insns + g->insns) - first_target_size; + + if (diff_first * second.n_partitions + > diff_second * first.n_partitions) + first.push (g); + else + second.push (g); + } + } + else + second.push (g); + + insns += g->insns; + } + + return result; +} + +/* Split partition_set into 'into' partition_sets with equal or off by one + number of symbol groups. Sizes of symbol groups are ignored for deciding + where to split. n_partitions is then distributed among new partition_sets + based on their sizes. + Order in conserved. */ +static std::vector +partition_fixed_split (partition_set& p, size_t into) +{ + gcc_assert (into < p.n_partitions); + + std::vector result; + + for (size_t i = 0; i < into; ++i) + { + size_t begin = i * p.sym_groups.size () / into; + size_t end = (i + 1) * p.sym_groups.size () / into; + + auto it = p.sym_groups.begin (); + result.push_back (partition_set (p.data, {it + begin, it + end})); + } + + distribute_n_partitions (result, p.n_partitions); + + return result; +} + + +/* Base implementation to inherit from for all Partitioners. */ +class partitioner_base { +public: + /* Partitions sym_groups into n_partitions partitions inserted into + ltrans_partitions. */ + void + apply (std::vector& sym_groups, int n_partitions) + { + partition_set p (partition_set::metadata (true, true), + std::move (sym_groups), n_partitions); + split (p, 0); + } + +protected: + partitioner_base (int64_t min_partition_size, int64_t max_partition_size): + min_partition_size (min_partition_size), + max_partition_size (max_partition_size) + { + gcc_assert (min_partition_size != 0); + gcc_assert (max_partition_size != 0); + } + virtual ~partitioner_base () + {} + + /* Joins all symbol groups into one finalized partition. */ + void + finalize (partition_set& p) + { + ltrans_partition joined = NULL; + + for (ltrans_partition g: p.sym_groups) + joined = join_partitions (joined, g); + + if (joined) + ltrans_partitions.safe_push (joined); + } + + /* Splits all partition_sets. */ + void + split_list (std::vector& ps, uintptr_t state) + { + for (partition_set& p: ps) + split (p, state); + } + + /* Handles common cases: + too large or small n_partitions, or n_partitions = 1. + And then calls split_state. */ + void + split (partition_set& p, uintptr_t state) + { + size_t min_partitions = p.insns / max_partition_size + 1; + size_t max_partitions = p.insns / min_partition_size; + if (!p.data.splitable) + max_partitions = std::min (max_partitions, p.sym_groups.size ()); + + p.n_partitions = std::max (p.n_partitions, min_partitions); + p.n_partitions = std::min (p.n_partitions, max_partitions); + + if (p.n_partitions <= 1) + return finalize (p); + + split_state (p, state); + } + + /* State machine for specific partitioner implementation. */ + virtual void + split_state (partition_set& p, uintptr_t state) = 0; + + int64_t min_partition_size, max_partition_size; +}; + + +/* Partitioner combining fixed, over_target, and binary partitionings. */ +class partitioner_default: public partitioner_base +{ +public: + partitioner_default (int64_t min_partition_size, int64_t max_partition_size): + partitioner_base (min_partition_size, max_partition_size) + {} + +private: + virtual void + split_state (partition_set& p, uintptr_t state) + { + const uintptr_t FIXED = 0; + const uintptr_t OVER_TARGET = 1; + const uintptr_t BINARY = 2; + + std::vector ps; + + switch (state) + { + case FIXED: + if (p.n_partitions > 64 && p.sym_groups.size () >= 4) + { + ps = partition_fixed_split (p, 4); + split_list (ps, OVER_TARGET); + break; + } + + /* FALLTHROUGH */ + case OVER_TARGET: + ps = partition_over_target_split (p); + if (!ps.empty ()) + { + split_list (ps, BINARY); + break; + } + + /* FALLTHROUGH */ + case BINARY: + ps = partition_binary_split (p); + if (!ps.empty ()) + { + split_list (ps, OVER_TARGET); + break; + } + + /* FALLTHROUGH */ + default: + finalize (p); + } + } +}; + +/* Group cgraph nodes into equally-sized partitions. + It tries to keep symbols from single source file together to minimize + propagation of divergence. + + It starts with symbols already grouped by source files. If reasonably + possible it only either combines several files into one final partition, + or, if a file is large, split the file into several final partitions. + + Intermediate representation is partition_set which contains set of + groups of symbols (each group corresponding to original source file) and + number of final partitions this partition_set should split into. + + First partition_fixed_split splits partition_set into constant number of + partition_sets with equal number of symbols groups. If for example there + are 39 source files, the resulting partition_sets will contain 10, 10, + 10, and 9 source files. This splitting intentionally ignores estimated + instruction counts to minimize propagation of divergence. + + Second partition_over_target_split separates too large files and splits + them into individual symbols to be combined back into several smaller + files in next step. + + Third partition_binary_split splits partition_set into two halves until + it should be split into only one final partition, at which point the + remaining symbols are joined into one final partition. +*/ + +void +lto_cache_map (int n_lto_partitions, int max_partition_size) +{ + lto_1_to_1_map (); + + std::vector partitions; + for (unsigned i = 0; i < ltrans_partitions.length (); ++i) + { + ltrans_partition part = ltrans_partitions[i]; + partitions.push_back (part); + } + ltrans_partitions.truncate (0); + + partitioner_default partitioner = partitioner_default + (param_min_partition_size, max_partition_size); + + partitioner.apply (partitions, n_lto_partitions); +} /* Group cgraph nodes into equally-sized partitions. diff --git a/gcc/lto/lto-partition.h b/gcc/lto/lto-partition.h index 8ac7c36757786..c139dee0e0d72 100644 --- a/gcc/lto/lto-partition.h +++ b/gcc/lto/lto-partition.h @@ -35,6 +35,7 @@ extern vec ltrans_partitions; void lto_1_to_1_map (void); void lto_max_map (void); +void lto_cache_map (int, int); void lto_balanced_map (int, int); void lto_promote_cross_file_statics (void); void free_ltrans_partitions (void); diff --git a/gcc/lto/lto.cc b/gcc/lto/lto.cc index 91aa2fbddb4e6..58ff0c45f577f 100644 --- a/gcc/lto/lto.cc +++ b/gcc/lto/lto.cc @@ -554,6 +554,8 @@ do_whole_program_analysis (void) else if (flag_lto_partition == LTO_PARTITION_BALANCED) lto_balanced_map (param_lto_partitions, param_max_partition_size); + else if (flag_lto_partition == LTO_PARTITION_CACHE) + lto_cache_map (param_lto_partitions, param_max_partition_size); else gcc_unreachable (); diff --git a/gcc/m2/ChangeLog b/gcc/m2/ChangeLog index 73f4efa0e4905..58aa35f1ab82c 100644 --- a/gcc/m2/ChangeLog +++ b/gcc/m2/ChangeLog @@ -1,3 +1,277 @@ +2024-06-17 Kewen Lin + + * gm2-gcc/m2type.cc (build_m2_short_real_node): Adjust assertion with + TYPE_SIZE check. + (build_m2_real_node): Likewise. + (build_m2_long_real_node): Add assertion with TYPE_SIZE check. + +2024-06-11 Gaius Mulley + + PR modula2/114529 + * Make-lang.in (MC_EXTENDED_OPAQUE): Assign to nothing. + * Make-maintainer.in (mc-basetest): New rule. + (mc-devel-basetest): New rule. + (mc-clean): Remove mc. + (m2/mc-boot-gen/$(SRC_PREFIX)decl.cc): Replace --extended-opaque + with $(EXTENDED_OPAQUE). + (PG-SRC): Move define before generic rules. + (PGE-DEF): Ditto. + (m2/gm2-ppg-boot/$(SRC_PREFIX)%.h): New rule. + (m2/gm2-ppg-boot/$(SRC_PREFIX)libc.o): Ditto. + (m2/gm2-ppg-boot/$(SRC_PREFIX)mcrts.o): Ditto. + (m2/gm2-ppg-boot/$(SRC_PREFIX)UnixArgs.o): Ditto. + (m2/gm2-ppg-boot/$(SRC_PREFIX)Selective.o): Ditto. + (m2/gm2-ppg-boot/$(SRC_PREFIX)termios.o): Ditto. + (m2/gm2-ppg-boot/$(SRC_PREFIX)SysExceptions.o): Ditto. + (m2/gm2-ppg-boot/$(SRC_PREFIX)ldtoa.o): Ditto. + (m2/gm2-ppg-boot/$(SRC_PREFIX)wrapc.o): Ditto. + (m2/gm2-ppg-boot/$(SRC_PREFIX)SYSTEM.o): Ditto. + (m2/gm2-ppg-boot/$(SRC_PREFIX)errno.o): Ditto. + (m2/gm2-ppg-boot/$(SRC_PREFIX)M2RTS.o): Ditto. + (m2/gm2-ppg-boot/$(SRC_PREFIX)SymbolKey.h): Ditto. + (m2/gm2-ppg-boot/$(SRC_PREFIX)SymbolKey.o): Ditto. + (m2/gm2-ppg-boot/$(SRC_PREFIX)NameKey.h): Ditto. + (m2/gm2-ppg-boot/$(SRC_PREFIX)NameKey.o): Ditto. + (m2/gm2-ppg-boot/$(SRC_PREFIX)Lists.h): Ditto. + (m2/gm2-ppg-boot/$(SRC_PREFIX)Lists.o): Ditto. + (m2/gm2-ppg-boot/$(SRC_PREFIX)Output.h): Ditto. + (m2/gm2-ppg-boot/$(SRC_PREFIX)bnflex.h): Ditto. + (m2/gm2-ppg-boot/$(SRC_PREFIX)bnflex.o): Ditto. + (m2/gm2-ppg-boot/$(SRC_PREFIX)RTco.h): Ditto. + (m2/gm2-ppg-boot/$(SRC_PREFIX)RTentity.h): Ditto. + (m2/gm2-ppg-boot/$(SRC_PREFIX)RTco.o): Ditto. + (m2/gm2-ppg-boot/$(SRC_PREFIX)RTentity.o): Ditto. + (m2/gm2-ppg-boot/$(SRC_PREFIX)%.o): Ditto. + (m2/ppg$(exeext)): Ditto. + (m2/gm2-ppg-boot/main.o): Ditto. + (m2/gm2-auto): Ditto. + (c-family/m2pp.o): Ditto. + (BUILD-BOOT-PG-H): Correct macro definition. + (m2/gm2-pg-boot/$(SRC_PREFIX)%.h): New rule. + (m2/gm2-pg-boot/$(SRC_PREFIX)NameKey.h): Ditto. + (m2/gm2-pg-boot/$(SRC_PREFIX)NameKey.o): Ditto. + (m2/gm2-pg-boot/$(SRC_PREFIX)Lists.h): Ditto. + (m2/gm2-pg-boot/$(SRC_PREFIX)Lists.o): Ditto. + (m2/gm2-pg-boot/$(SRC_PREFIX)Output.h): Ditto. + (m2/gm2-pg-boot/$(SRC_PREFIX)Output.o): Ditto. + (m2/gm2-pg-boot/$(SRC_PREFIX)bnflex.h): Ditto. + (m2/gm2-pg-boot/$(SRC_PREFIX)bnflex.o): Ditto. + (m2/gm2-pg-boot/$(SRC_PREFIX)RTco.h): Ditto. + (m2/gm2-pg-boot/$(SRC_PREFIX)RTentity.h): Ditto. + (m2/gm2-pg-boot/$(SRC_PREFIX)RTco.o): Ditto. + (m2/gm2-pg-boot/$(SRC_PREFIX)RTentity.o): Ditto. + (BUILD-BOOT-PGE-H): Correct macro definition. + (m2/gm2-pge-boot/$(SRC_PREFIX)SymbolKey.h): Ditto. + (m2/gm2-pge-boot/$(SRC_PREFIX)SymbolKey.o): Ditto. + (m2/gm2-pge-boot/$(SRC_PREFIX)NameKey.h): Ditto. + (m2/gm2-pge-boot/$(SRC_PREFIX)NameKey.o): Ditto. + (m2/gm2-pge-boot/$(SRC_PREFIX)Lists.h): Ditto. + (m2/gm2-pge-boot/$(SRC_PREFIX)Lists.o): Ditto. + (m2/gm2-pge-boot/$(SRC_PREFIX)Output.h): Ditto. + (m2/gm2-pge-boot/$(SRC_PREFIX)Output.o): Ditto. + (m2/gm2-pge-boot/$(SRC_PREFIX)bnflex.h): Ditto. + (m2/gm2-pge-boot/$(SRC_PREFIX)bnflex.o): Ditto. + (m2/gm2-pge-boot/$(SRC_PREFIX)RTco.h): Ditto. + (m2/gm2-pge-boot/$(SRC_PREFIX)RTentity.h): Ditto. + (m2/gm2-pge-boot/$(SRC_PREFIX)RTco.o): Ditto. + (m2/gm2-pge-boot/$(SRC_PREFIX)RTentity.o): Ditto. + (mc-basetest): Ditto. + (mc-devel-basetest): Ditto. + * gm2-compiler/M2Options.def (SetM2Dump): Add BOOLEAN return. + * gm2-compiler/M2Quads.def (BuildAlignment): Add tokno parameter. + (BuildBitLength): Ditto. + * gm2-compiler/P3Build.bnf (ByteAlignment): Move tokpos assignment + to the start of the block. + * gm2-compiler/PCBuild.bnf (ConstSetOrQualidentOrFunction): Ditto. + (SetOrDesignatorOrFunction): Ditto. + * gm2-compiler/PHBuild.bnf (ConstSetOrQualidentOrFunction): Ditto. + (SetOrDesignatorOrFunction): Ditto. + (ByteAlignment): Ditto. + * gm2-libs/dtoa.def (dtoa): Change mode to INTEGER. + * gm2-libs/ldtoa.def (ldtoa): Ditto. + * mc-boot-ch/GSYSTEM.c (_M2_SYSTEM_init): Correct parameter list. + (_M2_SYSTEM_fini): Ditto. + * mc-boot-ch/Gdtoa.cc (dtoa_calcsign): Return bool. + (dtoa_dtoa): Return void * and use bool in the fifth parameter. + (_M2_dtoa_init): Correct parameter list. + (_M2_dtoa_fini): Ditto. + * mc-boot-ch/Gerrno.cc (_M2_errno_init): Ditto. + (_M2_errno_fini): Ditto. + * mc-boot-ch/Gldtoa.cc (dtoa_calcsign): Return bool. + (ldtoa_ldtoa): Return void * and use bool in the fifth parameter. + (_M2_ldtoa_init): Correct parameter list. + (_M2_ldtoa_fini): Ditto. + * mc-boot-ch/Glibc.c (tracedb_zresult): New function. + (libc_read): Return size_t and use size_t in parameter three. + (libc_write): Return size_t and use size_t in parameter three. + (libc_printf): Add const to the format specifier. + Change declaration of c to use const. + (libc_snprintf): Add const to the format specifier. + Change declaration of c to use const. + (libc_malloc): Use size_t. + (libc_memcpy): Ditto. + * mc-boot/GASCII.cc: Regenerate. + * mc-boot/GArgs.cc: Ditto. + * mc-boot/GAssertion.cc: Ditto. + * mc-boot/GBreak.cc: Ditto. + * mc-boot/GCmdArgs.cc: Ditto. + * mc-boot/GDebug.cc: Ditto. + * mc-boot/GDynamicStrings.cc: Ditto. + * mc-boot/GEnvironment.cc: Ditto. + * mc-boot/GFIO.cc: Ditto. + * mc-boot/GFormatStrings.cc: Ditto. + * mc-boot/GFpuIO.cc: Ditto. + * mc-boot/GIO.cc: Ditto. + * mc-boot/GIndexing.cc: Ditto. + * mc-boot/GM2Dependent.cc: Ditto. + * mc-boot/GM2EXCEPTION.cc: Ditto. + * mc-boot/GM2RTS.cc: Ditto. + * mc-boot/GMemUtils.cc: Ditto. + * mc-boot/GNumberIO.cc: Ditto. + * mc-boot/GPushBackInput.cc: Ditto. + * mc-boot/GRTExceptions.cc: Ditto. + * mc-boot/GRTint.cc: Ditto. + * mc-boot/GSArgs.cc: Ditto. + * mc-boot/GSFIO.cc: Ditto. + * mc-boot/GStdIO.cc: Ditto. + * mc-boot/GStorage.cc: Ditto. + * mc-boot/GStrCase.cc: Ditto. + * mc-boot/GStrIO.cc: Ditto. + * mc-boot/GStrLib.cc: Ditto. + * mc-boot/GStringConvert.cc: Ditto. + * mc-boot/GSysStorage.cc: Ditto. + * mc-boot/GTimeString.cc: Ditto. + * mc-boot/Galists.cc: Ditto. + * mc-boot/Gdecl.cc: Ditto. + * mc-boot/Gkeyc.cc: Ditto. + * mc-boot/Glists.cc: Ditto. + * mc-boot/GmcComment.cc: Ditto. + * mc-boot/GmcComp.cc: Ditto. + * mc-boot/GmcDebug.cc: Ditto. + * mc-boot/GmcError.cc: Ditto. + * mc-boot/GmcFileName.cc: Ditto. + * mc-boot/GmcLexBuf.cc: Ditto. + * mc-boot/GmcMetaError.cc: Ditto. + * mc-boot/GmcOptions.cc: Ditto. + * mc-boot/GmcPreprocess.cc: Ditto. + * mc-boot/GmcPretty.cc: Ditto. + * mc-boot/GmcPrintf.cc: Ditto. + * mc-boot/GmcQuiet.cc: Ditto. + * mc-boot/GmcReserved.cc: Ditto. + * mc-boot/GmcSearch.cc: Ditto. + * mc-boot/GmcStack.cc: Ditto. + * mc-boot/GmcStream.cc: Ditto. + * mc-boot/Gmcp1.cc: Ditto. + * mc-boot/Gmcp2.cc: Ditto. + * mc-boot/Gmcp3.cc: Ditto. + * mc-boot/Gmcp4.cc: Ditto. + * mc-boot/Gmcp5.cc: Ditto. + * mc-boot/GnameKey.cc: Ditto. + * mc-boot/GsymbolKey.cc: Ditto. + * mc-boot/Gvarargs.cc: Ditto. + * mc-boot/Gwlists.cc: Ditto. + * mc-boot/Gdecl.h: Ditto. + * mc-boot/Gldtoa.h: Ditto. + * mc-boot/Glibc.h: Ditto. + * mc/decl.def (putTypeOpaque): New procedure. + (isTypeOpaque): New procedure function. + * mc/decl.mod (debugOpaque): New constant. + (nodeT): New enumeration field opaquecast. + (node): New record field opaquecastF. + (opaqueCastState): New record. + (opaquecastT): New record. + (typeT): New field isOpaque. + (varT): New field opaqueState. + (arrayT): Ditto. + (varparamT): Ditto. + (paramT): Ditto. + (pointerT): Ditto. + (recordfieldT): Ditto. + (componentrefT): Ditto. + (pointerrefT): Ditto. + (arrayrefT): Ditto. + (procedureT): Ditto. + (proctypeT): Ditto. + (makeType): Initialize field isOpaque. + (makeTypeImp): Initialize field isOpaque. + (putVar): Call initNodeOpaqueCastState. + (putReturnType): Ditto. + (makeProcType): Ditto. + (putProcTypeReturn): Ditto. + (makeVarParameter): Ditto. + (makeNonVarParameter): Ditto. + (makeFuncCall): Ditto. + (putTypeOpaque): New procedure. + (isTypeOpaque): New procedure function. + (doMakeComponentRef): Call initNodeOpaqueCastState. + (makePointerRef): Call initNodeOpaqueCastState. + (doGetFuncType): Call initNodeOpaqueCastState. + (doBinary): Add FALSE parameter to doExprCup. + (doDeRefC): Rewrite. + (doComponentRefC): Call flushOpaque. + (doPointerRefC): Call flushOpaque. + (doArrayRefC): Add const_cast for unbounded array. + (doExprCup): Rewrite. + (doTypeAliasC): Remove. + (isDeclType): New procedure function. + (doEnumerationC): New procedure function. + (doParamTypeEmit): Ditto. + (doParamTypeNameModifier): Ditto. + (initOpaqueCastState): Ditto. + (initNodeOpaqueCastState): Ditto. + (setOpaqueCastState): Ditto. + (setNodeOpaqueVoidStar): Ditto. + (nodeUsesOpaque): Ditto. + (getNodeOpaqueVoidStar): Ditto. + (getOpaqueFlushNecessary): Ditto. + (makeOpaqueCast): Ditto. + (flushOpaque): Ditto. + (castOpaque): Ditto. + (isTypeOpaqueDefImp): Ditto. + (isParamVoidStar): Ditto. + (isRefVoidStar): Ditto. + (isReturnVoidStar): Ditto. + (isVarVoidStar): Ditto. + (initNodeOpaqueState): Ditto. + (assignNodeOpaqueCastState): Ditto. + (assignNodeOpaqueCastFalse): Ditto. + (dumpOpaqueState): Ditto. + (doProcTypeC): Rewrite. + (isDeclInImp): New procedure function. + (doTypeNameModifier): Ditto. + (doTypeC): Emit typedef if enum is declared in this module. + (doCompletePartialProcType): Rewrite. + (outputCompletePartialProcType): New procedure. + (doOpaqueModifier): Ditto. + (doVarC): Ditto. + (doProcedureHeadingC): Add opaque modifier to return type if + necessary. + (doReturnC): Cast opaque type for return if necessary. + (forceCastOpaque): New procedure. + (forceReintCastOpaque): New procedure. + (doUnConstCastUnbounded): New procedure. + (doAssignmentC): Cast opaque for both des and expr if necessary. + (doAdrExprC): Use static_cast for void * casting. + (doFuncVarParam): New procedure. + (doFuncParamC): Rewrite. + (doAdrArgC): Rewrite. + (getFunction): New procedure function. + (stop): Rename to ... + (localstop): ... this. + (dupFunccall): Call assignNodeOpaqueCastState. + (dbg): Rewrite. + (addDone): Rewrite. + (addDoneDef): Do not add opaque types to the doneQ when declared in + the definition module. + * mc/mc.flex (openSource): Return bool. + (_M2_mcflex_init): Correct parameter list. + (_M2_mcflex_fini): Ditto. + * mc/mcComment.h (stdbool.h): Include. + (mcComment_initComment): Change unsigned int to bool. + * mc/mcOptions.mod (handleOption): Disable --extended-opaque + and issue warning. + * mc/mcp1.bnf (DefTypeDeclaration): Call putTypeOpaque. + 2024-06-06 Gaius Mulley Kewen.Lin diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in index 83d592f35d8d1..daa7ef6747a59 100644 --- a/gcc/m2/Make-lang.in +++ b/gcc/m2/Make-lang.in @@ -505,7 +505,7 @@ MC_ARGS= --olang=c++ \ $(MC_COPYRIGHT) \ --gcc-config-system -MC_EXTENDED_OPAQUE=--extended-opaque +MC_EXTENDED_OPAQUE= MCDEPS=m2/boot-bin/mc$(exeext) MC=m2/boot-bin/mc$(exeext) $(MC_ARGS) diff --git a/gcc/m2/Make-maintainer.in b/gcc/m2/Make-maintainer.in index 52f35f30e5a3b..6fa58975c58d5 100644 --- a/gcc/m2/Make-maintainer.in +++ b/gcc/m2/Make-maintainer.in @@ -77,90 +77,14 @@ PPG-LIB-MODS = ASCII.mod \ PPG-SRC = ppg.mod -BUILD-PPG-O = $(PPG-INTERFACE-C:%.c=m2/gm2-ppg-boot/$(SRC_PREFIX)%.o) \ - $(PPG-INTERFACE-CC:%.cc=m2/gm2-ppg-boot/$(SRC_PREFIX)%.o) \ - $(PPG-MODS:%.mod=m2/gm2-ppg-boot/$(SRC_PREFIX)%.o) \ - $(PPG-LIB-MODS:%.mod=m2/gm2-ppg-boot/$(SRC_PREFIX)%.o) \ - $(PPG-SRC:%.mod=m2/gm2-ppg-boot/$(SRC_PREFIX)%.o) - -MCC_ARGS= --olang=c++ \ - --quiet \ - --h-file-prefix=$(SRC_PREFIX) \ - -I$(srcdir)/m2/gm2-libs \ - -I$(srcdir)/m2/gm2-compiler \ - -I$(srcdir)/m2/gm2-libiberty \ - -I$(srcdir)/m2/gm2-gcc - -MCC=m2/boot-bin/mc$(exeext) $(MCC_ARGS) - -BUILD-PPG-LIBS-H = $(PPG-LIB-DEFS:%.def=m2/gm2-ppg-boot/$(SRC_PREFIX)%.h) - -BUILD-PPG-H = m2/boot-bin/mc$(exeext) $(BUILD-PPG-LIBS-H) - -BUILD-BOOT-PPG-H: $(BUILD-BOOT-H) \ - m2/gm2-ppg-boot/$(SRC_PREFIX)M2RTS.h \ - m2/gm2-ppg-boot/$(SRC_PREFIX)M2Dependent.h \ - $(PPG-DEFS:%.def=m2/gm2-ppg-boot/$(SRC_PREFIX)%.h) - -m2/gm2-ppg-boot/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-libs/%.def $(MCDEPS) - -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot - $(MCC) -o=$@ $(srcdir)/m2/gm2-libs/$*.def - -m2/gm2-ppg-boot/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.c m2/gm2-libs/gm2-libs-host.h $(BUILD-BOOT-PPG-H) - -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot - $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs $(INCLUDES) -g -c $< -o $@ - -m2/gm2-ppg-boot/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.cc m2/gm2-libs/gm2-libs-host.h $(BUILD-BOOT-PPG-H) - -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot - $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs $(INCLUDES) -g -c $< -o $@ - -m2/gm2-ppg-boot/$(SRC_PREFIX)M2RTS.o: $(srcdir)/m2/gm2-libs/M2RTS.mod $(MCDEPS) $(BUILD-BOOT-PPG-H) - -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot - $(MCC) --suppress-noreturn -o=m2/gm2-ppg-boot/$(SRC_PREFIX)M2RTS.cc $(srcdir)/m2/gm2-libs/M2RTS.mod - $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) \ - -Im2/gm2-ppg-boot -I$(srcdir)/m2/mc-boot -Im2/gm2-libs-boot \ - -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) -g -c m2/gm2-ppg-boot/$(SRC_PREFIX)M2RTS.cc -o $@ - -m2/gm2-ppg-boot/$(SRC_PREFIX)%.o: $(srcdir)/m2/gm2-libs/%.mod $(MCDEPS) $(BUILD-BOOT-PPG-H) - -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot - $(MCC) -o=m2/gm2-ppg-boot/$(SRC_PREFIX)$*.cc $(srcdir)/m2/gm2-libs/$*.mod - $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) \ - -Im2/gm2-ppg-boot -I$(srcdir)/m2/mc-boot -Im2/gm2-libs-boot \ - -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) -g -c m2/gm2-ppg-boot/$(SRC_PREFIX)$*.cc -o $@ - -m2/gm2-ppg-boot/$(SRC_PREFIX)%.o: $(srcdir)/m2/gm2-compiler/%.mod $(MCDEPS) $(BUILD-BOOT-PPG-H) - -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot - $(MCC) -o=m2/gm2-ppg-boot/$(SRC_PREFIX)$*.cc $(srcdir)/m2/gm2-compiler/$*.mod - $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) \ - -Im2/mc-boot -Im2/gm2-compiler-boot -Im2/gm2-libs-boot \ - -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) -g -c m2/gm2-ppg-boot/$(SRC_PREFIX)$*.cc -o $@ - -m2/ppg$(exeext): m2/boot-bin/mc $(BUILD-PPG-O) $(BUILD-MC-INTERFACE-O) m2/gm2-ppg-boot/main.o \ - m2/gm2-libs-boot/RTcodummy.o m2/mc-boot-ch/$(SRC_PREFIX)abort.o - -test -d m2 || $(mkinstalldirs) m2 - +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(BUILD-PPG-O) m2/gm2-ppg-boot/main.o \ - m2/gm2-libs-boot/RTcodummy.o m2/mc-boot-ch/$(SRC_PREFIX)abort.o -lm - -m2/gm2-ppg-boot/main.o: $(M2LINK) $(srcdir)/m2/init/mcinit - -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot - unset CC ; $(M2LINK) -s --langc++ --exit --name mainppginit.cc $(srcdir)/m2/init/ppginit - mv mainppginit.cc m2/gm2-ppg-boot/main.cc - $(CXX) $(INCLUDES) -g -c -o $@ m2/gm2-ppg-boot/main.cc - -m2/gm2-auto: - -test -d $@ || $(mkinstalldirs) $@ - -c-family/m2pp.o : $(srcdir)/m2/m2pp.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2) - $(COMPILER) -c -g $(ALL_COMPILERFLAGS) \ - $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION) - -# m2/pg$(exext) is the 2nd generation parser generator built from ebnf -# without error recovery +# m2/pg$(exext) is the 2nd generation parser generator built from the +# ebnf src without error recovery PG-SRC = pg.mod PGE-DEF = ASCII.def \ Args.def \ Assertion.def \ + bnflex.def \ Break.def \ COROUTINES.def \ CmdArgs.def \ @@ -176,6 +100,7 @@ PGE-DEF = ASCII.def \ M2RTS.def \ MemUtils.def \ NumberIO.def \ + Output.def \ PushBackInput.def \ RTExceptions.def \ RTco.def \ @@ -191,6 +116,7 @@ PGE-DEF = ASCII.def \ StrIO.def \ StrLib.def \ StringConvert.def \ + SymbolKey.def \ SysExceptions.def \ SysStorage.def \ TimeString.def \ @@ -260,6 +186,9 @@ PGE-DEPS = Gabort.cc \ GPushBackInput.cc \ GPushBackInput.h \ GRTco.cc \ + GRTco.h \ + GRTentity.cc \ + GRTentity.h \ GRTExceptions.cc \ GRTExceptions.h \ GSArgs.h \ @@ -295,19 +224,320 @@ PGE-DEPS = Gabort.cc \ Gwrapc.cc \ Gwrapc.h +BUILD-PPG-O = $(PPG-INTERFACE-C:%.c=m2/gm2-ppg-boot/$(SRC_PREFIX)%.o) \ + $(PPG-INTERFACE-CC:%.cc=m2/gm2-ppg-boot/$(SRC_PREFIX)%.o) \ + $(PPG-MODS:%.mod=m2/gm2-ppg-boot/$(SRC_PREFIX)%.o) \ + $(PPG-LIB-MODS:%.mod=m2/gm2-ppg-boot/$(SRC_PREFIX)%.o) \ + $(PPG-SRC:%.mod=m2/gm2-ppg-boot/$(SRC_PREFIX)%.o) + +MCC_ARGS= --olang=c++ \ + --quiet \ + --h-file-prefix=$(SRC_PREFIX) \ + -I$(srcdir)/m2/gm2-libs \ + -I$(srcdir)/m2/gm2-compiler \ + -I$(srcdir)/m2/gm2-libiberty \ + -I$(srcdir)/m2/gm2-gcc + +MCC=m2/boot-bin/mc$(exeext) $(MCC_ARGS) + +BUILD-PPG-LIBS-H = $(PPG-LIB-DEFS:%.def=m2/gm2-ppg-boot/$(SRC_PREFIX)%.h) + +BUILD-PPG-H = m2/boot-bin/mc$(exeext) $(BUILD-PPG-LIBS-H) + +BUILD-BOOT-PPG-H = $(BUILD-BOOT-H) \ + m2/gm2-ppg-boot/$(SRC_PREFIX)M2RTS.h \ + m2/gm2-ppg-boot/$(SRC_PREFIX)M2Dependent.h \ + $(PGE-DEF:%.def=m2/gm2-ppg-boot/$(SRC_PREFIX)%.h) \ + $(PPG-DEFS:%.def=m2/gm2-ppg-boot/$(SRC_PREFIX)%.h) \ + $(PPG-LIB-DEFS:%.def=m2/gm2-ppg-boot/$(SRC_PREFIX)%.h) + +# BUILD-BOOT-PPG-H = $(BUILD-BOOT-H) $(PGE-DEF:%.def=m2/gm2-ppg-boot/$(SRC_PREFIX)%.h) + +m2/gm2-ppg-boot/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-libs/%.def $(MCDEPS) + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + $(MCC) -o=$@ $(srcdir)/m2/gm2-libs/$*.def + +m2/gm2-ppg-boot/$(SRC_PREFIX)libc.o: $(srcdir)/m2/mc-boot-ch/Glibc.c m2/gm2-libs/gm2-libs-host.h + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs -g -c $< -o $@ + +m2/gm2-ppg-boot/$(SRC_PREFIX)mcrts.o: $(srcdir)/m2/mc-boot-ch/Gmcrts.c m2/gm2-libs/gm2-libs-host.h + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs -g -c $< -o $@ + +m2/gm2-ppg-boot/$(SRC_PREFIX)UnixArgs.o: $(srcdir)/m2/mc-boot-ch/GUnixArgs.cc + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) -g -c $< -o $@ + +m2/gm2-ppg-boot/$(SRC_PREFIX)Selective.o: $(srcdir)/m2/mc-boot-ch/GSelective.c m2/gm2-libs/gm2-libs-host.h + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) -Im2/gm2-libs -g -c $< -o $@ + +m2/gm2-ppg-boot/$(SRC_PREFIX)termios.o: $(srcdir)/m2/mc-boot-ch/Gtermios.cc m2/gm2-libs/gm2-libs-host.h + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs $(INCLUDES) -g -c $< -o $@ + +m2/gm2-ppg-boot/$(SRC_PREFIX)SysExceptions.o: $(srcdir)/m2/mc-boot-ch/GSysExceptions.c m2/gm2-libs/gm2-libs-host.h + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs $(INCLUDES) -g -c $< -o $@ + +m2/gm2-ppg-boot/$(SRC_PREFIX)ldtoa.o: $(srcdir)/m2/mc-boot-ch/Gldtoa.cc m2/gm2-libs/gm2-libs-host.h + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs $(INCLUDES) -g -c $< -o $@ + +m2/gm2-ppg-boot/$(SRC_PREFIX)dtoa.o: $(srcdir)/m2/mc-boot-ch/Gdtoa.cc m2/gm2-libs/gm2-libs-host.h + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs $(INCLUDES) -g -c $< -o $@ + +m2/gm2-ppg-boot/$(SRC_PREFIX)wrapc.o: $(srcdir)/m2/mc-boot-ch/Gwrapc.c m2/gm2-libs/gm2-libs-host.h + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs $(INCLUDES) -g -c $< -o $@ + +m2/gm2-ppg-boot/$(SRC_PREFIX)SYSTEM.o: $(srcdir)/m2/mc-boot-ch/GSYSTEM.c $(BUILD-BOOT-PPG-H) + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) -g -c $< -o $@ + +m2/gm2-ppg-boot/$(SRC_PREFIX)errno.o: $(srcdir)/m2/mc-boot-ch/Gerrno.cc + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) -g -c $< -o $@ + +m2/gm2-ppg-boot/$(SRC_PREFIX)M2RTS.o: $(srcdir)/m2/gm2-libs/M2RTS.mod $(MCDEPS) $(BUILD-BOOT-PPG-H) + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + $(MCC) --suppress-noreturn -o=m2/gm2-ppg-boot/$(SRC_PREFIX)M2RTS.cc $(srcdir)/m2/gm2-libs/M2RTS.mod + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-ppg-boot -I$(srcdir)/m2/mc-boot \ + -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ + $(INCLUDES) -g -c m2/gm2-ppg-boot/$(SRC_PREFIX)M2RTS.cc -o $@ + +m2/gm2-ppg-boot/$(SRC_PREFIX)SymbolKey.h: $(srcdir)/m2/gm2-compiler/SymbolKey.def $(MCDEPS) + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + $(MCC) -o=$@ $(srcdir)/m2/gm2-compiler/SymbolKey.def + +m2/gm2-ppg-boot/$(SRC_PREFIX)SymbolKey.o: $(srcdir)/m2/gm2-compiler/SymbolKey.mod \ + $(MCDEPS) $(BUILD-BOOT-PPG-H) \ + m2/gm2-ppg-boot/$(SRC_PREFIX)SymbolKey.h + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + $(MCC) --suppress-noreturn -o=m2/gm2-ppg-boot/$(SRC_PREFIX)SymbolKey.cc $(srcdir)/m2/gm2-compiler/SymbolKey.mod + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-ppg-boot -I$(srcdir)/m2/mc-boot \ + -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ + $(INCLUDES) -g -c m2/gm2-ppg-boot/$(SRC_PREFIX)SymbolKey.cc -o $@ + +m2/gm2-ppg-boot/$(SRC_PREFIX)NameKey.h: $(srcdir)/m2/gm2-compiler/NameKey.def $(MCDEPS) + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + $(MCC) -o=$@ $(srcdir)/m2/gm2-compiler/NameKey.def + +m2/gm2-ppg-boot/$(SRC_PREFIX)NameKey.o: $(srcdir)/m2/gm2-compiler/NameKey.mod \ + $(MCDEPS) $(BUILD-BOOT-PPG-H) \ + m2/gm2-ppg-boot/$(SRC_PREFIX)NameKey.h + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + $(MCC) --suppress-noreturn -o=m2/gm2-ppg-boot/$(SRC_PREFIX)NameKey.cc $(srcdir)/m2/gm2-compiler/NameKey.mod + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-ppg-boot -I$(srcdir)/m2/mc-boot \ + -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ + $(INCLUDES) -g -c m2/gm2-ppg-boot/$(SRC_PREFIX)NameKey.cc -o $@ + +m2/gm2-ppg-boot/$(SRC_PREFIX)Lists.h: $(srcdir)/m2/gm2-compiler/Lists.def $(MCDEPS) + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + $(MCC) -o=$@ $(srcdir)/m2/gm2-compiler/Lists.def + +m2/gm2-ppg-boot/$(SRC_PREFIX)Lists.o: $(srcdir)/m2/gm2-compiler/Lists.mod \ + $(MCDEPS) $(BUILD-BOOT-PPG-H) \ + m2/gm2-ppg-boot/$(SRC_PREFIX)Lists.h + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + $(MCC) --suppress-noreturn -o=m2/gm2-ppg-boot/$(SRC_PREFIX)Lists.cc $(srcdir)/m2/gm2-compiler/Lists.mod + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-ppg-boot -I$(srcdir)/m2/mc-boot \ + -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ + $(INCLUDES) -g -c m2/gm2-ppg-boot/$(SRC_PREFIX)Lists.cc -o $@ + +m2/gm2-ppg-boot/$(SRC_PREFIX)Output.h: $(srcdir)/m2/gm2-compiler/Output.def $(MCDEPS) + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + $(MCC) -o=$@ $(srcdir)/m2/gm2-compiler/Output.def + +m2/gm2-ppg-boot/$(SRC_PREFIX)Output.o: $(srcdir)/m2/gm2-compiler/Output.mod \ + $(MCDEPS) $(BUILD-BOOT-PPG-H) \ + m2/gm2-ppg-boot/$(SRC_PREFIX)Output.h + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + $(MCC) --suppress-noreturn -o=m2/gm2-ppg-boot/$(SRC_PREFIX)Output.cc $(srcdir)/m2/gm2-compiler/Output.mod + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-ppg-boot -I$(srcdir)/m2/mc-boot \ + -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ + $(INCLUDES) -g -c m2/gm2-ppg-boot/$(SRC_PREFIX)Output.cc -o $@ + +m2/gm2-ppg-boot/$(SRC_PREFIX)bnflex.h: $(srcdir)/m2/gm2-compiler/bnflex.def $(MCDEPS) + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + $(MCC) -o=$@ $(srcdir)/m2/gm2-compiler/bnflex.def + +m2/gm2-ppg-boot/$(SRC_PREFIX)bnflex.o: $(srcdir)/m2/gm2-compiler/bnflex.mod \ + $(MCDEPS) $(BUILD-BOOT-PPG-H) \ + m2/gm2-ppg-boot/$(SRC_PREFIX)bnflex.h + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + $(MCC) --suppress-noreturn -o=m2/gm2-ppg-boot/$(SRC_PREFIX)bnflex.cc $(srcdir)/m2/gm2-compiler/bnflex.mod + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-ppg-boot -I$(srcdir)/m2/mc-boot \ + -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ + $(INCLUDES) -g -c m2/gm2-ppg-boot/$(SRC_PREFIX)bnflex.cc -o $@ + +m2/gm2-ppg-boot/$(SRC_PREFIX)RTco.h: $(srcdir)/m2/gm2-libs-iso/RTco.def $(MCDEPS) + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + $(MCC) -o=$@ -I$(srcdir)/m2/gm2-libs-iso -I$(srcdir)/m2/gm2-libs $(srcdir)/m2/gm2-libs-iso/RTco.def + +m2/gm2-ppg-boot/$(SRC_PREFIX)RTentity.h: $(srcdir)/m2/gm2-libs-iso/RTentity.def $(MCDEPS) + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + $(MCC) -o=$@ -I$(srcdir)/m2/gm2-libs-iso -I$(srcdir)/m2/gm2-libs $(srcdir)/m2/gm2-libs-iso/RTentity.def + +m2/gm2-ppg-boot/$(SRC_PREFIX)RTco.o: $(srcdir)/m2/gm2-libs-iso/RTcodummy.c + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-ppg-boot -I$(srcdir)/m2/mc-boot \ + -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ + $(INCLUDES) -g -c $< -o $@ + +m2/gm2-ppg-boot/$(SRC_PREFIX)RTentity.o: $(srcdir)/m2/gm2-libs-iso/RTentity.mod \ + $(MCDEPS) $(BUILD-BOOT-PPG-H) \ + m2/gm2-ppg-boot/$(SRC_PREFIX)RTentity.h + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + $(MCC) --suppress-noreturn -o=m2/gm2-ppg-boot/$(SRC_PREFIX)RTentity.cc $(srcdir)/m2/gm2-libs-iso/RTentity.mod + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-ppg-boot -I$(srcdir)/m2/mc-boot \ + -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ + $(INCLUDES) -g -c m2/gm2-ppg-boot/$(SRC_PREFIX)RTentity.cc -o $@ + +m2/gm2-ppg-boot/$(SRC_PREFIX)%.o: $(srcdir)/m2/gm2-libs/%.mod $(MCDEPS) $(BUILD-BOOT-PPG-H) + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + $(MCC) -o=m2/gm2-ppg-boot/$(SRC_PREFIX)$*.cc $(srcdir)/m2/gm2-libs/$*.mod + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-ppg-boot -I$(srcdir)/m2/mc-boot \ + -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ + $(INCLUDES) -g -c m2/gm2-ppg-boot/$(SRC_PREFIX)$*.cc -o $@ + +m2/gm2-ppg-boot/$(SRC_PREFIX)%.o: $(srcdir)/m2/gm2-compiler/%.mod $(MCDEPS) $(BUILD-BOOT-PPG-H) + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + $(MCC) -o=m2/gm2-ppg-boot/$(SRC_PREFIX)$*.cc $(srcdir)/m2/gm2-compiler/$*.mod + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot -Im2/gm2-compiler-boot \ + -Im2/gm2-libs-boot -Im2/gm2-ppg-boot \ + -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) -g -c m2/gm2-ppg-boot/$(SRC_PREFIX)$*.cc -o $@ + +m2/ppg$(exeext): m2/boot-bin/mc $(BUILD-PPG-O) $(BUILD-MC-INTERFACE-O) m2/gm2-ppg-boot/main.o \ + m2/gm2-libs-boot/RTcodummy.o m2/mc-boot-ch/$(SRC_PREFIX)abort.o + -test -d m2 || $(mkinstalldirs) m2 + +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(BUILD-PPG-O) m2/gm2-ppg-boot/main.o \ + m2/gm2-libs-boot/RTcodummy.o m2/mc-boot-ch/$(SRC_PREFIX)abort.o -lm + +m2/gm2-ppg-boot/main.o: $(M2LINK) $(srcdir)/m2/init/mcinit + -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot + unset CC ; $(M2LINK) -s --langc++ --exit --name mainppginit.cc $(srcdir)/m2/init/ppginit + mv mainppginit.cc m2/gm2-ppg-boot/main.cc + $(CXX) $(INCLUDES) -g -c -o $@ m2/gm2-ppg-boot/main.cc + +m2/gm2-auto: + -test -d $@ || $(mkinstalldirs) $@ + +c-family/m2pp.o : $(srcdir)/m2/m2pp.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2) + $(COMPILER) -c -g $(ALL_COMPILERFLAGS) \ + $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION) + + BUILD-PG-O = $(PPG-INTERFACE-C:%.c=m2/gm2-pg-boot/$(SRC_PREFIX)%.o) \ $(PPG-INTERFACE-CC:%.cc=m2/gm2-pg-boot/$(SRC_PREFIX)%.o) \ $(PPG-MODS:%.mod=m2/gm2-pg-boot/$(SRC_PREFIX)%.o) \ $(PPG-LIB-MODS:%.mod=m2/gm2-pg-boot/$(SRC_PREFIX)%.o) \ $(PG-SRC:%.mod=m2/gm2-pg-boot/$(SRC_PREFIX)%.o) -BUILD-BOOT-PG-H: $(BUILD-BOOT-H) \ +BUILD-BOOT-PG-H = $(BUILD-BOOT-H) \ m2/gm2-pg-boot/$(SRC_PREFIX)M2RTS.h \ - m2/gm2-pg-boot/$(SRC_PREFIX)M2Dependent.h + m2/gm2-pg-boot/$(SRC_PREFIX)M2Dependent.h \ + $(PGE-DEF:%.def=m2/gm2-pg-boot/$(SRC_PREFIX)%.h) \ + $(PPG-DEFS:%.def=m2/gm2-pg-boot/$(SRC_PREFIX)%.h) \ + $(PPG-LIB-DEFS:%.def=m2/gm2-pg-boot/$(SRC_PREFIX)%.h) m2/gm2-pg-boot/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-libs/%.def $(MCDEPS) -test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot - $(MCC) -o=$@ $(srcdir)/m2/gm2-libs/$*.def + $(MCC) -o=$@ $(srcdir)/m2/gm2-libs/$*.def $< + +m2/gm2-pg-boot/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-compiler/%.def $(MCDEPS) + -test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot + $(MCC) -o=$@ -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-compiler $< + +m2/gm2-pg-boot/$(SRC_PREFIX)SymbolKey.h: $(srcdir)/m2/gm2-compiler/SymbolKey.def $(MCDEPS) + -test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot + $(MCC) -o=$@ $(srcdir)/m2/gm2-compiler/SymbolKey.def + +m2/gm2-pg-boot/$(SRC_PREFIX)SymbolKey.o: $(srcdir)/m2/gm2-compiler/SymbolKey.mod \ + $(MCDEPS) $(BUILD-BOOT-PG-H) \ + m2/gm2-pg-boot/$(SRC_PREFIX)SymbolKey.h + -test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot + $(MCC) --suppress-noreturn -o=m2/gm2-pg-boot/$(SRC_PREFIX)SymbolKey.cc $(srcdir)/m2/gm2-compiler/SymbolKey.mod + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-pg-boot -I$(srcdir)/m2/mc-boot \ + -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ + $(INCLUDES) -g -c m2/gm2-pg-boot/$(SRC_PREFIX)SymbolKey.cc -o $@ + +m2/gm2-pg-boot/$(SRC_PREFIX)NameKey.h: $(srcdir)/m2/gm2-compiler/NameKey.def $(MCDEPS) + -test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot + $(MCC) -o=$@ $(srcdir)/m2/gm2-compiler/NameKey.def + +m2/gm2-pg-boot/$(SRC_PREFIX)NameKey.o: $(srcdir)/m2/gm2-compiler/NameKey.mod \ + $(MCDEPS) $(BUILD-BOOT-PG-H) \ + m2/gm2-pg-boot/$(SRC_PREFIX)NameKey.h + -test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot + $(MCC) --suppress-noreturn -o=m2/gm2-pg-boot/$(SRC_PREFIX)NameKey.cc $(srcdir)/m2/gm2-compiler/NameKey.mod + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-pg-boot -I$(srcdir)/m2/mc-boot \ + -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ + $(INCLUDES) -g -c m2/gm2-pg-boot/$(SRC_PREFIX)NameKey.cc -o $@ + +m2/gm2-pg-boot/$(SRC_PREFIX)Lists.h: $(srcdir)/m2/gm2-compiler/Lists.def $(MCDEPS) + -test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot + $(MCC) -o=$@ $(srcdir)/m2/gm2-compiler/Lists.def + +m2/gm2-pg-boot/$(SRC_PREFIX)Lists.o: $(srcdir)/m2/gm2-compiler/Lists.mod \ + $(MCDEPS) $(BUILD-BOOT-PG-H) \ + m2/gm2-pg-boot/$(SRC_PREFIX)Lists.h + -test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot + $(MCC) --suppress-noreturn -o=m2/gm2-pg-boot/$(SRC_PREFIX)Lists.cc $(srcdir)/m2/gm2-compiler/Lists.mod + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-pg-boot -I$(srcdir)/m2/mc-boot \ + -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ + $(INCLUDES) -g -c m2/gm2-pg-boot/$(SRC_PREFIX)Lists.cc -o $@ + +m2/gm2-pg-boot/$(SRC_PREFIX)Output.h: $(srcdir)/m2/gm2-compiler/Output.def $(MCDEPS) + -test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot + $(MCC) -o=$@ $(srcdir)/m2/gm2-compiler/Output.def + +m2/gm2-pg-boot/$(SRC_PREFIX)Output.o: $(srcdir)/m2/gm2-compiler/Output.mod \ + $(MCDEPS) $(BUILD-BOOT-PG-H) \ + m2/gm2-pg-boot/$(SRC_PREFIX)Output.h + -test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot + $(MCC) --suppress-noreturn -o=m2/gm2-pg-boot/$(SRC_PREFIX)Output.cc $(srcdir)/m2/gm2-compiler/Output.mod + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-pg-boot -I$(srcdir)/m2/mc-boot \ + -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ + $(INCLUDES) -g -c m2/gm2-pg-boot/$(SRC_PREFIX)Output.cc -o $@ + +m2/gm2-pg-boot/$(SRC_PREFIX)bnflex.h: $(srcdir)/m2/gm2-compiler/bnflex.def $(MCDEPS) + -test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot + $(MCC) -o=$@ $(srcdir)/m2/gm2-compiler/bnflex.def + +m2/gm2-pg-boot/$(SRC_PREFIX)bnflex.o: $(srcdir)/m2/gm2-compiler/bnflex.mod \ + $(MCDEPS) $(BUILD-BOOT-PG-H) \ + m2/gm2-pg-boot/$(SRC_PREFIX)bnflex.h + -test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot + $(MCC) --suppress-noreturn -o=m2/gm2-pg-boot/$(SRC_PREFIX)bnflex.cc $(srcdir)/m2/gm2-compiler/bnflex.mod + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-pg-boot -I$(srcdir)/m2/mc-boot \ + -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ + $(INCLUDES) -g -c m2/gm2-pg-boot/$(SRC_PREFIX)bnflex.cc -o $@ + +m2/gm2-pg-boot/$(SRC_PREFIX)RTco.h: $(srcdir)/m2/gm2-libs-iso/RTco.def $(MCDEPS) + -test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot + $(MCC) -o=$@ -I$(srcdir)/m2/gm2-libs-iso -I$(srcdir)/m2/gm2-libs $(srcdir)/m2/gm2-libs-iso/RTco.def + +m2/gm2-pg-boot/$(SRC_PREFIX)RTentity.h: $(srcdir)/m2/gm2-libs-iso/RTentity.def $(MCDEPS) + -test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot + $(MCC) -o=$@ -I$(srcdir)/m2/gm2-libs-iso -I$(srcdir)/m2/gm2-libs $(srcdir)/m2/gm2-libs-iso/RTentity.def + +m2/gm2-pg-boot/$(SRC_PREFIX)RTco.o: $(srcdir)/m2/gm2-libs-iso/RTcodummy.c + -test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-pg-boot -I$(srcdir)/m2/mc-boot \ + -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ + $(INCLUDES) -g -c $< -o $@ + +m2/gm2-pg-boot/$(SRC_PREFIX)RTentity.o: $(srcdir)/m2/gm2-libs-iso/RTentity.mod \ + $(MCDEPS) $(BUILD-BOOT-PG-H) \ + m2/gm2-pg-boot/$(SRC_PREFIX)RTentity.h + -test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot + $(MCC) --suppress-noreturn -o=m2/gm2-pg-boot/$(SRC_PREFIX)RTentity.cc $(srcdir)/m2/gm2-libs-iso/RTentity.mod + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-pg-boot -I$(srcdir)/m2/mc-boot \ + -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ + $(INCLUDES) -g -c m2/gm2-pg-boot/$(SRC_PREFIX)RTentity.cc -o $@ m2/gm2-pg-boot/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.c m2/gm2-libs/gm2-libs-host.h $(BUILD-BOOT-PG-H) -test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot @@ -319,16 +549,15 @@ m2/gm2-pg-boot/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.cc m2/gm2-libs/gm2 m2/gm2-pg-boot/$(SRC_PREFIX)M2RTS.o: $(srcdir)/m2/gm2-libs/M2RTS.mod $(MCDEPS) $(BUILD-BOOT-PG-H) -test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot - $(MCC) --suppress-noreturn -o=m2/gm2-pg-boot/$(SRC_PREFIX)M2RTS.c $(srcdir)/m2/gm2-libs/M2RTS.mod - $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -Im2/gm2-pg-boot -I$(srcdir)/m2/mc-boot \ - -I$(srcdir)/m2/mc-boot-ch \ - -Im2/gm2-libs-boot $(INCLUDES) \ - -g -c m2/gm2-pg-boot/$(SRC_PREFIX)M2RTS.c -o $@ + $(MCC) --suppress-noreturn -o=m2/gm2-pg-boot/$(SRC_PREFIX)M2RTS.cc $(srcdir)/m2/gm2-libs/M2RTS.mod + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-pg-boot -I$(srcdir)/m2/mc-boot \ + -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ + $(INCLUDES) -g -c m2/gm2-pg-boot/$(SRC_PREFIX)M2RTS.cc -o $@ m2/gm2-pg-boot/$(SRC_PREFIX)%.o: $(srcdir)/m2/gm2-libs/%.mod $(MCDEPS) $(BUILD-BOOT-PG-H) -test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot $(MCC) -o=m2/gm2-pg-boot/$(SRC_PREFIX)$*.c $(srcdir)/m2/gm2-libs/$*.mod - $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -Im2/gm2-pg-boot -I$(srcdir)/m2/mc-boot \ + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -Im2/gm2-pg-boot -I$(srcdir)/m2/mc-boot \ -I$(srcdir)/m2/mc-boot-ch \ -Im2/gm2-libs-boot $(INCLUDES) \ -g -c m2/gm2-pg-boot/$(SRC_PREFIX)$*.c -o $@ @@ -390,8 +619,7 @@ BUILD-PGE-O = $(PPG-INTERFACE-C:%.c=m2/gm2-pge-boot/$(SRC_PREFIX)%.o) \ $(PPG-LIB-MODS:%.mod=m2/gm2-pge-boot/$(SRC_PREFIX)%.o) \ $(PGE-SRC:%.mod=m2/gm2-pge-boot/$(SRC_PREFIX)%.o) -BUILD-BOOT-PGE-H: $(BUILD-BOOT-H) $(PGE-DEF:%.def=m2/gm2-pge-boot/$(SRC_PREFIX)%.h) \ - m2/gm2-pge-boot/GM2RTS.h m2/gm2-pge-boot/GM2Dependent.h +BUILD-BOOT-PGE-H = $(BUILD-BOOT-H) $(PGE-DEF:%.def=m2/gm2-pge-boot/$(SRC_PREFIX)%.h) m2/gm2-auto/pge.mod: m2/pg$(exeext) -test -d m2/gm2-auto || $(mkinstalldirs) m2/gm2-auto @@ -453,6 +681,94 @@ m2/gm2-pge-boot/$(SRC_PREFIX)M2RTS.o: $(srcdir)/m2/gm2-libs/M2RTS.mod $(MCDEPS) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)M2RTS.cc -o $@ +m2/gm2-pge-boot/$(SRC_PREFIX)SymbolKey.h: $(srcdir)/m2/gm2-compiler/SymbolKey.def $(MCDEPS) + -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot + $(MCC) -o=$@ $(srcdir)/m2/gm2-compiler/SymbolKey.def + +m2/gm2-pge-boot/$(SRC_PREFIX)SymbolKey.o: $(srcdir)/m2/gm2-compiler/SymbolKey.mod \ + $(MCDEPS) $(BUILD-BOOT-PGE-H) \ + m2/gm2-pge-boot/$(SRC_PREFIX)SymbolKey.h + -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot + $(MCC) --suppress-noreturn -o=m2/gm2-pge-boot/$(SRC_PREFIX)SymbolKey.cc $(srcdir)/m2/gm2-compiler/SymbolKey.mod + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-pge-boot -I$(srcdir)/m2/mc-boot \ + -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ + $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)SymbolKey.cc -o $@ + +m2/gm2-pge-boot/$(SRC_PREFIX)NameKey.h: $(srcdir)/m2/gm2-compiler/NameKey.def $(MCDEPS) + -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot + $(MCC) -o=$@ $(srcdir)/m2/gm2-compiler/NameKey.def + +m2/gm2-pge-boot/$(SRC_PREFIX)NameKey.o: $(srcdir)/m2/gm2-compiler/NameKey.mod \ + $(MCDEPS) $(BUILD-BOOT-PGE-H) \ + m2/gm2-pge-boot/$(SRC_PREFIX)NameKey.h + -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot + $(MCC) --suppress-noreturn -o=m2/gm2-pge-boot/$(SRC_PREFIX)NameKey.cc $(srcdir)/m2/gm2-compiler/NameKey.mod + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-pge-boot -I$(srcdir)/m2/mc-boot \ + -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ + $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)NameKey.cc -o $@ + +m2/gm2-pge-boot/$(SRC_PREFIX)Lists.h: $(srcdir)/m2/gm2-compiler/Lists.def $(MCDEPS) + -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot + $(MCC) -o=$@ $(srcdir)/m2/gm2-compiler/Lists.def + +m2/gm2-pge-boot/$(SRC_PREFIX)Lists.o: $(srcdir)/m2/gm2-compiler/Lists.mod \ + $(MCDEPS) $(BUILD-BOOT-PGE-H) \ + m2/gm2-pge-boot/$(SRC_PREFIX)Lists.h + -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot + $(MCC) --suppress-noreturn -o=m2/gm2-pge-boot/$(SRC_PREFIX)Lists.cc $(srcdir)/m2/gm2-compiler/Lists.mod + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-pge-boot -I$(srcdir)/m2/mc-boot \ + -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ + $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)Lists.cc -o $@ + +m2/gm2-pge-boot/$(SRC_PREFIX)Output.h: $(srcdir)/m2/gm2-compiler/Output.def $(MCDEPS) + -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot + $(MCC) -o=$@ $(srcdir)/m2/gm2-compiler/Output.def + +m2/gm2-pge-boot/$(SRC_PREFIX)Output.o: $(srcdir)/m2/gm2-compiler/Output.mod \ + $(MCDEPS) $(BUILD-BOOT-PGE-H) \ + m2/gm2-pge-boot/$(SRC_PREFIX)Output.h + -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot + $(MCC) --suppress-noreturn -o=m2/gm2-pge-boot/$(SRC_PREFIX)Output.cc $(srcdir)/m2/gm2-compiler/Output.mod + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-pge-boot -I$(srcdir)/m2/mc-boot \ + -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ + $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)Output.cc -o $@ + +m2/gm2-pge-boot/$(SRC_PREFIX)bnflex.h: $(srcdir)/m2/gm2-compiler/bnflex.def $(MCDEPS) + -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot + $(MCC) -o=$@ $(srcdir)/m2/gm2-compiler/bnflex.def + +m2/gm2-pge-boot/$(SRC_PREFIX)bnflex.o: $(srcdir)/m2/gm2-compiler/bnflex.mod \ + $(MCDEPS) $(BUILD-BOOT-PGE-H) \ + m2/gm2-pge-boot/$(SRC_PREFIX)bnflex.h + -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot + $(MCC) --suppress-noreturn -o=m2/gm2-pge-boot/$(SRC_PREFIX)bnflex.cc $(srcdir)/m2/gm2-compiler/bnflex.mod + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-pge-boot -I$(srcdir)/m2/mc-boot \ + -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ + $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)bnflex.cc -o $@ + +m2/gm2-pge-boot/$(SRC_PREFIX)RTco.h: $(srcdir)/m2/gm2-libs-iso/RTco.def $(MCDEPS) + -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot + $(MCC) -o=$@ -I$(srcdir)/m2/gm2-libs-iso -I$(srcdir)/m2/gm2-libs $(srcdir)/m2/gm2-libs-iso/RTco.def + +m2/gm2-pge-boot/$(SRC_PREFIX)RTentity.h: $(srcdir)/m2/gm2-libs-iso/RTentity.def $(MCDEPS) + -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot + $(MCC) -o=$@ -I$(srcdir)/m2/gm2-libs-iso -I$(srcdir)/m2/gm2-libs $(srcdir)/m2/gm2-libs-iso/RTentity.def + +m2/gm2-pge-boot/$(SRC_PREFIX)RTco.o: $(srcdir)/m2/gm2-libs-iso/RTcodummy.c + -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-pge-boot -I$(srcdir)/m2/mc-boot \ + -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ + $(INCLUDES) -g -c $< -o $@ + +m2/gm2-pge-boot/$(SRC_PREFIX)RTentity.o: $(srcdir)/m2/gm2-libs-iso/RTentity.mod \ + $(MCDEPS) $(BUILD-BOOT-PGE-H) \ + m2/gm2-pge-boot/$(SRC_PREFIX)RTentity.h + -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot + $(MCC) --suppress-noreturn -o=m2/gm2-pge-boot/$(SRC_PREFIX)RTentity.cc $(srcdir)/m2/gm2-libs-iso/RTentity.mod + $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/gm2-pge-boot -I$(srcdir)/m2/mc-boot \ + -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \ + $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)RTentity.cc -o $@ + m2/gm2-pge-boot/$(SRC_PREFIX)%.o: $(srcdir)/m2/gm2-libs/%.mod $(MCDEPS) $(BUILD-BOOT-PGE-H) -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot $(MCC) -o=m2/gm2-pge-boot/$(SRC_PREFIX)$*.cc $(srcdir)/m2/gm2-libs/$*.mod @@ -586,7 +902,6 @@ MCLINK=-g # use -g -fmodules -c if you are debugging and wish to see missing # This is only needed in maintainer mode by 'make mc-maintainer' when regenerating the C # version of mc. We need a working Modula-2 compiler to run mc-maintainer. -# GM2SYS=${HOME}/opt/lib/gcc/x86_64-pc-linux-gnu/13.0.0/m2/m2pim GM2PATH=-I$(srcdir)/m2/mc \ -I$(srcdir)/m2 -Im2/gm2-auto \ -fm2-pathname=m2pim -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-libs-ch \ @@ -594,12 +909,18 @@ GM2PATH=-I$(srcdir)/m2/mc \ mc: mc-clean mc-devel +mc-basetest: force + $(SHELL) $(srcdir)/testsuite/gm2/base-lang/pass/base-lang-test.sh ./mc $(srcdir) `pwd` $(COMPILER) + +mc-devel-basetest: force + $(SHELL) $(srcdir)/testsuite/gm2/base-lang/pass/base-lang-test.sh m2/boot-bin/mc-devel$(exeext) $(srcdir) `pwd` $(COMPILER) + mc-push: force cp -p m2/mc-boot-gen/*.cc $(srcdir)/m2/mc-boot/ cp -p m2/mc-boot-gen/*.h $(srcdir)/m2/mc-boot/ mc-clean: force m2/mc-obj - $(RM) m2/mc-boot-gen/*.{cc,h} m2/boot-bin/* m2/mc-boot/* m2/mc-boot-ch/* + $(RM) m2/mc-boot-gen/*.{cc,h} m2/boot-bin/* m2/mc-boot/* m2/mc-boot-ch/* mc mc-maintainer: mc-clean mc-autogen mc-push mc-clean mc-bootstrap @@ -765,7 +1086,7 @@ m2/mc-boot-gen/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-libs/%.def m2/mc-boot-gen/$(SRC_PREFIX)decl.cc: $(srcdir)/m2/mc/decl.mod -test -d m2/mc-boot-gen || $(mkinstalldirs) m2/mc-boot-gen - ./mc $(MC_OPTIONS) --extended-opaque -I$(srcdir)/m2/mc -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-libs-iso --h-file-prefix=$(SRC_PREFIX) -o=$@ $< + ./mc $(MC_OPTIONS) $(EXTENDED_OPAQUE) -I$(srcdir)/m2/mc -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-libs-iso --h-file-prefix=$(SRC_PREFIX) -o=$@ $< m2/mc-boot-gen/$(SRC_PREFIX)%.cc: $(srcdir)/m2/mc/%.mod -test -d m2/mc-boot-gen || $(mkinstalldirs) m2/mc-boot-gen diff --git a/gcc/m2/gm2-compiler/M2Options.def b/gcc/m2/gm2-compiler/M2Options.def index a3d112c0cdf36..d2d7e68fc353b 100644 --- a/gcc/m2/gm2-compiler/M2Options.def +++ b/gcc/m2/gm2-compiler/M2Options.def @@ -1061,7 +1061,7 @@ PROCEDURE GetM2DumpFilter () : ADDRESS ; SetM2Dump - sets the dump via a comma separated list: quad,decl,gimple,all. *) -PROCEDURE SetM2Dump (value: BOOLEAN; filter: ADDRESS) ; +PROCEDURE SetM2Dump (value: BOOLEAN; filter: ADDRESS) : BOOLEAN ; (* diff --git a/gcc/m2/gm2-compiler/M2Quads.def b/gcc/m2/gm2-compiler/M2Quads.def index 6175d8d1cb27c..304c8dd6eabb1 100644 --- a/gcc/m2/gm2-compiler/M2Quads.def +++ b/gcc/m2/gm2-compiler/M2Quads.def @@ -1012,7 +1012,7 @@ PROCEDURE BuildAssignConstant (equalsTokNo: CARDINAL) ; |---------------| empty *) -PROCEDURE BuildAlignment ; +PROCEDURE BuildAlignment (tokno: CARDINAL) ; (* @@ -1030,7 +1030,7 @@ PROCEDURE BuildAlignment ; |------------| empty *) -PROCEDURE BuildBitLength ; +PROCEDURE BuildBitLength (tokno: CARDINAL) ; (* diff --git a/gcc/m2/gm2-compiler/P3Build.bnf b/gcc/m2/gm2-compiler/P3Build.bnf index d5eddc7e98e6f..643309424a7d5 100644 --- a/gcc/m2/gm2-compiler/P3Build.bnf +++ b/gcc/m2/gm2-compiler/P3Build.bnf @@ -790,8 +790,10 @@ ConstAttributeExpression := ">" =: -ByteAlignment := '<*' % PushAutoOn % - AttributeExpression % BuildAlignment % +ByteAlignment := % VAR tokpos: CARDINAL ; % + '<*' % PushAutoOn % + % tokpos := GetTokenNo () % + AttributeExpression % BuildAlignment (tokpos) % '*>' % PopAuto % =: diff --git a/gcc/m2/gm2-compiler/PCBuild.bnf b/gcc/m2/gm2-compiler/PCBuild.bnf index b983cc8b8520f..46f46af73ffe3 100644 --- a/gcc/m2/gm2-compiler/PCBuild.bnf +++ b/gcc/m2/gm2-compiler/PCBuild.bnf @@ -704,7 +704,8 @@ ConstructorOrConstActualParameters := Constructor | ConstActualParameters % Pus ConstSetOrQualidentOrFunction := % PushAutoOff % % VAR tokpos: CARDINAL ; % - ( % tokpos := GetTokenNo () % + % tokpos := GetTokenNo () % + ( PushQualident ( ConstructorOrConstActualParameters | % PushConstType % % PopNothing % @@ -1008,8 +1009,8 @@ ConstructorOrSimpleDes := Constructor | % Pop SetOrDesignatorOrFunction := % PushAutoOff % % VAR tokpos: CARDINAL ; % - - ( % tokpos := GetTokenNo () % + % tokpos := GetTokenNo () % + ( PushQualident ( ConstructorOrSimpleDes | % PopNothing % ) diff --git a/gcc/m2/gm2-compiler/PHBuild.bnf b/gcc/m2/gm2-compiler/PHBuild.bnf index 52214894d0acd..776601d3b1c3b 100644 --- a/gcc/m2/gm2-compiler/PHBuild.bnf +++ b/gcc/m2/gm2-compiler/PHBuild.bnf @@ -664,7 +664,8 @@ Constructor := % VAR ConstSetOrQualidentOrFunction := % PushAutoOn % % VAR tokpos: CARDINAL ; % - ( % tokpos := GetTokenNo () % + % tokpos := GetTokenNo () % + ( Qualident [ Constructor | ConstActualParameters % BuildConstFunctionCall % @@ -678,8 +679,10 @@ ConstAttribute := "__ATTRIBUTE__" "__BUILTIN__" "(" "(" ConstAttributeExpression ConstAttributeExpression := Ident | "<" Qualident ',' Ident ">" =: -ByteAlignment := '<*' % PushAutoOn % - AttributeExpression % BuildAlignment % +ByteAlignment := % VAR tokpos: CARDINAL ; % + '<*' % PushAutoOn % + % tokpos := GetTokenNo () % + AttributeExpression % BuildAlignment (tokpos) % '*>' % PopAuto % =: diff --git a/gcc/m2/gm2-gcc/m2type.cc b/gcc/m2/gm2-gcc/m2type.cc index 5773a5cbd1907..7ed184518cb19 100644 --- a/gcc/m2/gm2-gcc/m2type.cc +++ b/gcc/m2/gm2-gcc/m2type.cc @@ -1416,7 +1416,7 @@ static tree build_m2_short_real_node (void) { /* Define `SHORTREAL'. */ - ASSERT_CONDITION (TYPE_PRECISION (float_type_node) == FLOAT_TYPE_SIZE); + ASSERT_CONDITION (TYPE_SIZE (float_type_node)); return float_type_node; } @@ -1424,7 +1424,7 @@ static tree build_m2_real_node (void) { /* Define `REAL'. */ - ASSERT_CONDITION (TYPE_PRECISION (double_type_node) == DOUBLE_TYPE_SIZE); + ASSERT_CONDITION (TYPE_SIZE (double_type_node)); return double_type_node; } @@ -1432,12 +1432,13 @@ static tree build_m2_long_real_node (void) { tree longreal; - + /* Define `LONGREAL'. */ if (M2Options_GetIEEELongDouble ()) longreal = float128_type_node; else longreal = long_double_type_node; + ASSERT_CONDITION (TYPE_SIZE (longreal)); return longreal; } diff --git a/gcc/m2/gm2-libs/dtoa.def b/gcc/m2/gm2-libs/dtoa.def index 0d19bc3d5930a..a8f6509526c8f 100644 --- a/gcc/m2/gm2-libs/dtoa.def +++ b/gcc/m2/gm2-libs/dtoa.def @@ -50,7 +50,7 @@ PROCEDURE strtod (s: ADDRESS; VAR error: BOOLEAN) : REAL ; *) PROCEDURE dtoa (d : REAL; - mode : Mode; + mode : INTEGER; ndigits : INTEGER; VAR decpt: INTEGER; VAR sign : BOOLEAN) : ADDRESS ; diff --git a/gcc/m2/gm2-libs/ldtoa.def b/gcc/m2/gm2-libs/ldtoa.def index 7e712f37b8597..4a0f1dfacd224 100644 --- a/gcc/m2/gm2-libs/ldtoa.def +++ b/gcc/m2/gm2-libs/ldtoa.def @@ -50,7 +50,7 @@ PROCEDURE strtold (s: ADDRESS; VAR error: BOOLEAN) : LONGREAL ; *) PROCEDURE ldtoa (d : LONGREAL; - mode : Mode; + mode : INTEGER; ndigits : INTEGER; VAR decpt: INTEGER; VAR sign : BOOLEAN) : ADDRESS ; diff --git a/gcc/m2/mc-boot-ch/GSYSTEM.c b/gcc/m2/mc-boot-ch/GSYSTEM.c index 0492483ee0987..46340a565582c 100644 --- a/gcc/m2/mc-boot-ch/GSYSTEM.c +++ b/gcc/m2/mc-boot-ch/GSYSTEM.c @@ -27,12 +27,12 @@ along with GNU Modula-2; see the file COPYING3. If not see EXTERN void -_M2_SYSTEM_init (int argc, char *p) +_M2_SYSTEM_init (int argc, char *argv[], char *envp[]) { } EXTERN void -_M2_SYSTEM_fini (int argc, char *p) +_M2_SYSTEM_fini (int argc, char *argv[], char *envp[]) { } diff --git a/gcc/m2/mc-boot-ch/Gdtoa.cc b/gcc/m2/mc-boot-ch/Gdtoa.cc index 94f4488c13f45..b608c6b79ddc2 100644 --- a/gcc/m2/mc-boot-ch/Gdtoa.cc +++ b/gcc/m2/mc-boot-ch/Gdtoa.cc @@ -123,21 +123,21 @@ dtoa_calcdecimal (char *p, int str_size, int ndigits) } -int +bool dtoa_calcsign (char *p, int str_size) { if (p[0] == '-') { memmove (p, p + 1, str_size - 1); - return TRUE; + return true; } else - return FALSE; + return false; } -char * -dtoa_dtoa (double d, int mode, int ndigits, int *decpt, int *sign) +void * +dtoa_dtoa (double d, int mode, int ndigits, int *decpt, bool *sign) { char format[50]; char *p; @@ -169,12 +169,12 @@ dtoa_dtoa (double d, int mode, int ndigits, int *decpt, int *sign) /* GNU Modula-2 hooks */ void -_M2_dtoa_init (void) +_M2_dtoa_init (int argc, char *argv[], char *envp[]) { } void -_M2_dtoa_fini (void) +_M2_dtoa_fini (int argc, char *argv[], char *envp[]) { } #endif diff --git a/gcc/m2/mc-boot-ch/Gerrno.cc b/gcc/m2/mc-boot-ch/Gerrno.cc index 4b507288852c9..af46002ed7849 100644 --- a/gcc/m2/mc-boot-ch/Gerrno.cc +++ b/gcc/m2/mc-boot-ch/Gerrno.cc @@ -38,14 +38,14 @@ errno_geterrno (void) /* init constructor for the module. */ void -_M2_errno_init (int argc, char *p) +_M2_errno_init (int argc, char *argv[], char *envp[]) { } /* finish deconstructor for the module. */ void -_M2_errno_fini (int argc, char *p) +_M2_errno_fini (int argc, char *argv[], char *envp[]) { } diff --git a/gcc/m2/mc-boot-ch/Gldtoa.cc b/gcc/m2/mc-boot-ch/Gldtoa.cc index 2a266cf21082f..1e7acb7ad40f8 100644 --- a/gcc/m2/mc-boot-ch/Gldtoa.cc +++ b/gcc/m2/mc-boot-ch/Gldtoa.cc @@ -34,7 +34,7 @@ typedef enum Mode { maxsignicant, decimaldigits } Mode; extern int dtoa_calcmaxsig (char *p, int ndigits); extern int dtoa_calcdecimal (char *p, int str_size, int ndigits); -extern int dtoa_calcsign (char *p, int str_size); +extern bool dtoa_calcsign (char *p, int str_size); /* maxsignicant: return a string containing max(1,ndigits) significant digits. The return string contains the string @@ -62,8 +62,8 @@ ldtoa_strtold (const char *s, int *error) return d; } -char * -ldtoa_ldtoa (long double d, int mode, int ndigits, int *decpt, int *sign) +void * +ldtoa_ldtoa (long double d, int mode, int ndigits, int *decpt, bool *sign) { char format[50]; char *p; @@ -94,12 +94,12 @@ ldtoa_ldtoa (long double d, int mode, int ndigits, int *decpt, int *sign) /* GNU Modula-2 hooks */ void -_M2_ldtoa_init (void) +_M2_ldtoa_init (int argc, char *argv[], char *envp[]) { } void -_M2_ldtoa_fini (void) +_M2_ldtoa_fini (int argc, char *argv[], char *envp[]) { } # ifdef __cplusplus diff --git a/gcc/m2/mc-boot-ch/Glibc.c b/gcc/m2/mc-boot-ch/Glibc.c index 23a490571ff90..e53a76a0f13c3 100644 --- a/gcc/m2/mc-boot-ch/Glibc.c +++ b/gcc/m2/mc-boot-ch/Glibc.c @@ -110,23 +110,35 @@ tracedb_result (int result) #endif } +static +void +tracedb_zresult (size_t result) +{ +#if defined(BUILD_MC_LIBC_TRACE) + tracedb (" result = %zd", result); + if (result == -1) + tracedb (", errno = %s", strerror (errno)); + tracedb ("\n"); +#endif +} + EXTERN -int -libc_read (int fd, void *a, int nbytes) +size_t +libc_read (int fd, void *a, size_t nbytes) { - tracedb ("libc_read (%d, %p, %d)\n", fd, a, nbytes); - int result = read (fd, a, nbytes); - tracedb_result (result); + tracedb ("libc_read (%d, %p, %zd)\n", fd, a, nbytes); + size_t result = read (fd, a, nbytes); + tracedb_zresult (result); return result; } EXTERN -int -libc_write (int fd, void *a, int nbytes) +size_t +libc_write (int fd, void *a, size_t nbytes) { - tracedb ("libc_write (%d, %p, %d)\n", fd, a, nbytes); - int result = write (fd, a, nbytes); - tracedb_result (result); + tracedb ("libc_write (%d, %p, %zd)\n", fd, a, nbytes); + size_t result = write (fd, a, nbytes); + tracedb_zresult (result); return result; } @@ -162,7 +174,7 @@ libc_abort () } EXTERN -int +size_t libc_strlen (char *s) { return strlen (s); @@ -184,14 +196,14 @@ libc_localtime (time_t *epochtime) EXTERN int -libc_printf (char *_format, unsigned int _format_high, ...) +libc_printf (const char *_format, unsigned int _format_high, ...) { va_list arg; int done; char format[_format_high + 1]; unsigned int i = 0; unsigned int j = 0; - char *c; + const char *c; do { @@ -221,14 +233,14 @@ libc_printf (char *_format, unsigned int _format_high, ...) EXTERN int -libc_snprintf (char *dest, size_t length, char *_format, unsigned int _format_high, ...) +libc_snprintf (char *dest, size_t length, const char *_format, unsigned int _format_high, ...) { va_list arg; int done; char format[_format_high + 1]; unsigned int i = 0; unsigned int j = 0; - char *c; + const char *c; do { @@ -258,7 +270,7 @@ libc_snprintf (char *dest, size_t length, char *_format, unsigned int _format_hi EXTERN void * -libc_malloc (unsigned int size) +libc_malloc (size_t size) { return malloc (size); } @@ -300,7 +312,7 @@ libc_system (char *command) EXTERN void * -libc_memcpy (void *dest, void *src, int n) +libc_memcpy (void *dest, void *src, size_t n) { return memcpy (dest, src, n); } diff --git a/gcc/m2/mc-boot/GASCII.cc b/gcc/m2/mc-boot/GASCII.cc index 83c586666701d..a5c59fd3c4b82 100644 --- a/gcc/m2/mc-boot/GASCII.cc +++ b/gcc/m2/mc-boot/GASCII.cc @@ -34,9 +34,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see typedef struct { PROC_t proc; } PROC; # endif -#define _ASCII_H #define _ASCII_C +#include "GASCII.h" # define ASCII_nul (char) 000 # define ASCII_soh (char) 001 @@ -78,10 +78,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see # define ASCII_del (char) 0177 # define ASCII_EOL ASCII_nl -extern "C" void _M2_ASCII_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_ASCII_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_ASCII_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_ASCII_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GArgs.cc b/gcc/m2/mc-boot/GArgs.cc index c6a2bcab65a21..182def800ea0a 100644 --- a/gcc/m2/mc-boot/GArgs.cc +++ b/gcc/m2/mc-boot/GArgs.cc @@ -34,9 +34,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see typedef struct { PROC_t proc; } PROC; # endif -#define _Args_H #define _Args_C +#include "GArgs.h" # include "GUnixArgs.h" # include "GASCII.h" @@ -86,13 +86,13 @@ extern "C" bool Args_GetArg (char *a, unsigned int _a_high, unsigned int n) Source = static_cast (UnixArgs_GetArgV ()); while ((j < High) && ((*(*Source).array[i]).array[j] != ASCII_nul)) { - a[j] = (*(*Source).array[i]).array[j]; + const_cast(a)[j] = (*(*Source).array[i]).array[j]; j += 1; } } if (j <= High) { - a[j] = ASCII_nul; + const_cast(a)[j] = ASCII_nul; } return i < (UnixArgs_GetArgC ()); /* static analysis guarentees a RETURN statement will be used before here. */ @@ -112,10 +112,10 @@ extern "C" unsigned int Args_Narg (void) __builtin_unreachable (); } -extern "C" void _M2_Args_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_Args_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_Args_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_Args_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GAssertion.cc b/gcc/m2/mc-boot/GAssertion.cc index fdebf020b6137..b6b47952108b1 100644 --- a/gcc/m2/mc-boot/GAssertion.cc +++ b/gcc/m2/mc-boot/GAssertion.cc @@ -34,9 +34,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see typedef struct { PROC_t proc; } PROC; # endif -#define _Assertion_H #define _Assertion_C +#include "GAssertion.h" # include "GStrIO.h" # include "GM2RTS.h" @@ -63,10 +63,10 @@ extern "C" void Assertion_Assert (bool Condition) } } -extern "C" void _M2_Assertion_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_Assertion_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_Assertion_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_Assertion_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GBreak.cc b/gcc/m2/mc-boot/GBreak.cc index 23104d66ba079..4fea839214bd2 100644 --- a/gcc/m2/mc-boot/GBreak.cc +++ b/gcc/m2/mc-boot/GBreak.cc @@ -34,15 +34,15 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see typedef struct { PROC_t proc; } PROC; # endif -#define _Break_H #define _Break_C +#include "GBreak.h" -extern "C" void _M2_Break_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_Break_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_Break_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_Break_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GCmdArgs.cc b/gcc/m2/mc-boot/GCmdArgs.cc index 0b7d587e1eb1d..cb8fa8ace5873 100644 --- a/gcc/m2/mc-boot/GCmdArgs.cc +++ b/gcc/m2/mc-boot/GCmdArgs.cc @@ -34,9 +34,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see typedef struct { PROC_t proc; } PROC; # endif -#define _CmdArgs_H #define _CmdArgs_C +#include "GCmdArgs.h" # include "GASCII.h" # include "GStrLib.h" @@ -149,7 +149,7 @@ static bool GetNextArg (const char *CmdLine_, unsigned int _CmdLine_high, unsign } if (ArgIndex < HighA) { - Arg[ArgIndex] = ASCII_nul; + const_cast(Arg)[ArgIndex] = ASCII_nul; } return (*CmdIndex) < HighC; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -216,7 +216,7 @@ static void CopyChar (const char *From_, unsigned int _From_high, unsigned int * if ((*FromIndex) < FromHigh) { /* Copy Normal Character */ - To[(*ToIndex)] = From[(*FromIndex)]; + const_cast(To)[(*ToIndex)] = From[(*FromIndex)]; (*ToIndex) += 1; (*FromIndex) += 1; } @@ -314,10 +314,10 @@ extern "C" unsigned int CmdArgs_Narg (const char *CmdLine_, unsigned int _CmdLin __builtin_unreachable (); } -extern "C" void _M2_CmdArgs_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_CmdArgs_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_CmdArgs_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_CmdArgs_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GDebug.cc b/gcc/m2/mc-boot/GDebug.cc index c1daa670b885f..3f0ec51507e43 100644 --- a/gcc/m2/mc-boot/GDebug.cc +++ b/gcc/m2/mc-boot/GDebug.cc @@ -34,9 +34,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see typedef struct { PROC_t proc; } PROC; # endif -#define _Debug_H #define _Debug_C +#include "GDebug.h" # include "GASCII.h" # include "GNumberIO.h" # include "GStdIO.h" @@ -165,10 +165,10 @@ extern "C" void Debug_DebugString (const char *a_, unsigned int _a_high) } } -extern "C" void _M2_Debug_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_Debug_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_Debug_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_Debug_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GDynamicStrings.cc b/gcc/m2/mc-boot/GDynamicStrings.cc index a1cb88c03b76d..329696929851a 100644 --- a/gcc/m2/mc-boot/GDynamicStrings.cc +++ b/gcc/m2/mc-boot/GDynamicStrings.cc @@ -47,9 +47,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see # undef NULL # define NULL 0 #endif -#define _DynamicStrings_H #define _DynamicStrings_C +#include "GDynamicStrings.h" # include "Glibc.h" # include "GStrLib.h" # include "GStorage.h" @@ -81,27 +81,27 @@ typedef struct DynamicStrings__T3_a DynamicStrings__T3; typedef enum {DynamicStrings_inuse, DynamicStrings_marked, DynamicStrings_onlist, DynamicStrings_poisoned} DynamicStrings_desState; -typedef DynamicStrings_stringRecord *DynamicStrings_String; +typedef DynamicStrings_stringRecord *DynamicStrings_String__opaque; struct DynamicStrings_DebugInfo_r { - DynamicStrings_String next; - void *file; + DynamicStrings_String__opaque next; + void * file; unsigned int line; - void *proc; + void * proc; }; struct DynamicStrings_descriptor_r { bool charStarUsed; - void *charStar; + void * charStar; unsigned int charStarSize; bool charStarValid; DynamicStrings_desState state; - DynamicStrings_String garbage; + DynamicStrings_String__opaque garbage; }; struct DynamicStrings_frameRec_r { - DynamicStrings_String alloc; - DynamicStrings_String dealloc; + DynamicStrings_String__opaque alloc; + DynamicStrings_String__opaque dealloc; DynamicStrings_frame next; }; @@ -109,7 +109,7 @@ struct DynamicStrings__T3_a { char array[(MaxBuf-1)+1]; }; struct DynamicStrings_Contents_r { DynamicStrings__T3 buf; unsigned int len; - DynamicStrings_String next; + DynamicStrings_String__opaque next; }; struct DynamicStrings_stringRecord_r { @@ -120,7 +120,7 @@ struct DynamicStrings_stringRecord_r { static bool Initialized; static DynamicStrings_frame frameHead; -static DynamicStrings_String captured; +static DynamicStrings_String__opaque captured; /* InitString - creates and returns a String type object. @@ -400,7 +400,7 @@ extern "C" DynamicStrings_String DynamicStrings_PopAllocationExemption (bool hal /* writeStringDesc write out debugging information about string, s. */ -static void writeStringDesc (DynamicStrings_String s); +static void writeStringDesc (DynamicStrings_String__opaque s); /* writeNspace - @@ -412,7 +412,7 @@ static void writeNspace (unsigned int n); DumpStringInfo - */ -static void DumpStringInfo (DynamicStrings_String s, unsigned int i); +static void DumpStringInfo (DynamicStrings_String__opaque s, unsigned int i); /* DumpStringInfo - @@ -430,7 +430,7 @@ static void doDSdbEnter (void); doDSdbExit - */ -static void doDSdbExit (DynamicStrings_String s); +static void doDSdbExit (DynamicStrings_String__opaque s); /* DSdbEnter - @@ -442,8 +442,8 @@ static void DSdbEnter (void); DSdbExit - */ -static void DSdbExit (DynamicStrings_String s); -static unsigned int Capture (DynamicStrings_String s); +static void DSdbExit (DynamicStrings_String__opaque s); +static unsigned int Capture (DynamicStrings_String__opaque s); /* Min - @@ -497,73 +497,73 @@ static void writeLn (void); AssignDebug - assigns, file, and, line, information to string, s. */ -static DynamicStrings_String AssignDebug (DynamicStrings_String s, const char *file_, unsigned int _file_high, unsigned int line, const char *proc_, unsigned int _proc_high); +static DynamicStrings_String__opaque AssignDebug (DynamicStrings_String__opaque s, const char *file_, unsigned int _file_high, unsigned int line, const char *proc_, unsigned int _proc_high); /* IsOn - returns TRUE if, s, is on one of the debug lists. */ -static bool IsOn (DynamicStrings_String list, DynamicStrings_String s); +static bool IsOn (DynamicStrings_String__opaque list, DynamicStrings_String__opaque s); /* AddTo - adds string, s, to, list. */ -static void AddTo (DynamicStrings_String *list, DynamicStrings_String s); +static void AddTo (DynamicStrings_String__opaque *list, DynamicStrings_String__opaque s); /* SubFrom - removes string, s, from, list. */ -static void SubFrom (DynamicStrings_String *list, DynamicStrings_String s); +static void SubFrom (DynamicStrings_String__opaque *list, DynamicStrings_String__opaque s); /* AddAllocated - adds string, s, to the head of the allocated list. */ -static void AddAllocated (DynamicStrings_String s); +static void AddAllocated (DynamicStrings_String__opaque s); /* AddDeallocated - adds string, s, to the head of the deallocated list. */ -static void AddDeallocated (DynamicStrings_String s); +static void AddDeallocated (DynamicStrings_String__opaque s); /* IsOnAllocated - returns TRUE if the string, s, has ever been allocated. */ -static bool IsOnAllocated (DynamicStrings_String s); +static bool IsOnAllocated (DynamicStrings_String__opaque s); /* IsOnDeallocated - returns TRUE if the string, s, has ever been deallocated. */ -static bool IsOnDeallocated (DynamicStrings_String s); +static bool IsOnDeallocated (DynamicStrings_String__opaque s); /* SubAllocated - removes string, s, from the list of allocated strings. */ -static void SubAllocated (DynamicStrings_String s); +static void SubAllocated (DynamicStrings_String__opaque s); /* SubDeallocated - removes string, s, from the list of deallocated strings. */ -static void SubDeallocated (DynamicStrings_String s); +static void SubDeallocated (DynamicStrings_String__opaque s); /* SubDebugInfo - removes string, s, from the list of allocated strings. */ -static void SubDebugInfo (DynamicStrings_String s); +static void SubDebugInfo (DynamicStrings_String__opaque s); /* AddDebugInfo - adds string, s, to the list of allocated strings. */ -static void AddDebugInfo (DynamicStrings_String s); +static void AddDebugInfo (DynamicStrings_String__opaque s); /* ConcatContents - add the contents of string, a, where, h, is the @@ -576,19 +576,19 @@ static void ConcatContents (DynamicStrings_Contents *c, const char *a_, unsigned DeallocateCharStar - deallocates any charStar. */ -static void DeallocateCharStar (DynamicStrings_String s); +static void DeallocateCharStar (DynamicStrings_String__opaque s); /* CheckPoisoned - checks for a poisoned string, s. */ -static DynamicStrings_String CheckPoisoned (DynamicStrings_String s); +static DynamicStrings_String__opaque CheckPoisoned (DynamicStrings_String__opaque s); /* MarkInvalid - marks the char * version of String, s, as invalid. */ -static void MarkInvalid (DynamicStrings_String s); +static void MarkInvalid (DynamicStrings_String__opaque s); /* ConcatContentsAddress - concatenate the string, a, where, h, is the @@ -603,13 +603,13 @@ static void ConcatContentsAddress (DynamicStrings_Contents *c, void * a, unsigne onlist. String, a, is returned. */ -static DynamicStrings_String AddToGarbage (DynamicStrings_String a, DynamicStrings_String b); +static DynamicStrings_String__opaque AddToGarbage (DynamicStrings_String__opaque a, DynamicStrings_String__opaque b); /* IsOnGarbage - returns TRUE if, s, is on string, e, garbage list. */ -static bool IsOnGarbage (DynamicStrings_String e, DynamicStrings_String s); +static bool IsOnGarbage (DynamicStrings_String__opaque e, DynamicStrings_String__opaque s); /* IsWhite - returns TRUE if, ch, is a space or a tab. @@ -621,19 +621,19 @@ static bool IsWhite (char ch); DumpState - */ -static void DumpState (DynamicStrings_String s); +static void DumpState (DynamicStrings_String__opaque s); /* DumpStringSynopsis - */ -static void DumpStringSynopsis (DynamicStrings_String s); +static void DumpStringSynopsis (DynamicStrings_String__opaque s); /* DumpString - displays the contents of string, s. */ -static void DumpString (DynamicStrings_String s); +static void DumpString (DynamicStrings_String__opaque s); /* Init - initialize the module. @@ -645,7 +645,7 @@ static void Init (void); /* writeStringDesc write out debugging information about string, s. */ -static void writeStringDesc (DynamicStrings_String s) +static void writeStringDesc (DynamicStrings_String__opaque s) { writeCstring (s->debug.file); writeString ((const char *) ":", 1); @@ -701,7 +701,7 @@ static void writeNspace (unsigned int n) DumpStringInfo - */ -static void DumpStringInfo (DynamicStrings_String s, unsigned int i) +static void DumpStringInfo (DynamicStrings_String__opaque s, unsigned int i) { if (s != NULL) { @@ -749,11 +749,11 @@ static void doDSdbEnter (void) doDSdbExit - */ -static void doDSdbExit (DynamicStrings_String s) +static void doDSdbExit (DynamicStrings_String__opaque s) { if (CheckOn) { - s = DynamicStrings_PopAllocationExemption (true, s); + s = static_cast (DynamicStrings_PopAllocationExemption (true, static_cast (s))); } } @@ -771,11 +771,11 @@ static void DSdbEnter (void) DSdbExit - */ -static void DSdbExit (DynamicStrings_String s) +static void DSdbExit (DynamicStrings_String__opaque s) { } -static unsigned int Capture (DynamicStrings_String s) +static unsigned int Capture (DynamicStrings_String__opaque s) { /* * #undef GM2_DEBUG_DYNAMICSTINGS @@ -843,7 +843,7 @@ static void writeString (const char *a_, unsigned int _a_high) /* make a local copy of each unbounded array. */ memcpy (a, a_, _a_high+1); - i = static_cast (libc_write (1, &a, static_cast (StrLib_StrLen ((const char *) a, _a_high)))); + i = static_cast (libc_write (1, const_cast (static_cast(a)), static_cast (StrLib_StrLen ((const char *) a, _a_high)))); } @@ -951,7 +951,7 @@ static void writeLn (void) AssignDebug - assigns, file, and, line, information to string, s. */ -static DynamicStrings_String AssignDebug (DynamicStrings_String s, const char *file_, unsigned int _file_high, unsigned int line, const char *proc_, unsigned int _proc_high) +static DynamicStrings_String__opaque AssignDebug (DynamicStrings_String__opaque s, const char *file_, unsigned int _file_high, unsigned int line, const char *proc_, unsigned int _proc_high) { void * f; void * p; @@ -962,8 +962,8 @@ static DynamicStrings_String AssignDebug (DynamicStrings_String s, const char *f memcpy (file, file_, _file_high+1); memcpy (proc, proc_, _proc_high+1); - f = &file; - p = &proc; + f = const_cast (static_cast(file)); + p = const_cast (static_cast(proc)); Storage_ALLOCATE (&s->debug.file, (StrLib_StrLen ((const char *) file, _file_high))+1); if ((libc_strncpy (s->debug.file, f, (StrLib_StrLen ((const char *) file, _file_high))+1)) == NULL) {} /* empty. */ @@ -981,7 +981,7 @@ static DynamicStrings_String AssignDebug (DynamicStrings_String s, const char *f IsOn - returns TRUE if, s, is on one of the debug lists. */ -static bool IsOn (DynamicStrings_String list, DynamicStrings_String s) +static bool IsOn (DynamicStrings_String__opaque list, DynamicStrings_String__opaque s) { while ((list != s) && (list != NULL)) { @@ -997,12 +997,12 @@ static bool IsOn (DynamicStrings_String list, DynamicStrings_String s) AddTo - adds string, s, to, list. */ -static void AddTo (DynamicStrings_String *list, DynamicStrings_String s) +static void AddTo (DynamicStrings_String__opaque *list, DynamicStrings_String__opaque s) { if ((*list) == NULL) { (*list) = s; - s->debug.next = NULL; + s->debug.next = static_cast (NULL); } else { @@ -1016,9 +1016,9 @@ static void AddTo (DynamicStrings_String *list, DynamicStrings_String s) SubFrom - removes string, s, from, list. */ -static void SubFrom (DynamicStrings_String *list, DynamicStrings_String s) +static void SubFrom (DynamicStrings_String__opaque *list, DynamicStrings_String__opaque s) { - DynamicStrings_String p; + DynamicStrings_String__opaque p; if ((*list) == s) { @@ -1038,10 +1038,10 @@ static void SubFrom (DynamicStrings_String *list, DynamicStrings_String s) else { /* not found, quit */ - return ; + return; } } - s->debug.next = NULL; + s->debug.next = static_cast (NULL); } @@ -1049,7 +1049,7 @@ static void SubFrom (DynamicStrings_String *list, DynamicStrings_String s) AddAllocated - adds string, s, to the head of the allocated list. */ -static void AddAllocated (DynamicStrings_String s) +static void AddAllocated (DynamicStrings_String__opaque s) { Init (); AddTo (&frameHead->alloc, s); @@ -1060,7 +1060,7 @@ static void AddAllocated (DynamicStrings_String s) AddDeallocated - adds string, s, to the head of the deallocated list. */ -static void AddDeallocated (DynamicStrings_String s) +static void AddDeallocated (DynamicStrings_String__opaque s) { Init (); AddTo (&frameHead->dealloc, s); @@ -1071,7 +1071,7 @@ static void AddDeallocated (DynamicStrings_String s) IsOnAllocated - returns TRUE if the string, s, has ever been allocated. */ -static bool IsOnAllocated (DynamicStrings_String s) +static bool IsOnAllocated (DynamicStrings_String__opaque s) { DynamicStrings_frame f; @@ -1097,7 +1097,7 @@ static bool IsOnAllocated (DynamicStrings_String s) IsOnDeallocated - returns TRUE if the string, s, has ever been deallocated. */ -static bool IsOnDeallocated (DynamicStrings_String s) +static bool IsOnDeallocated (DynamicStrings_String__opaque s) { DynamicStrings_frame f; @@ -1123,7 +1123,7 @@ static bool IsOnDeallocated (DynamicStrings_String s) SubAllocated - removes string, s, from the list of allocated strings. */ -static void SubAllocated (DynamicStrings_String s) +static void SubAllocated (DynamicStrings_String__opaque s) { DynamicStrings_frame f; @@ -1133,7 +1133,7 @@ static void SubAllocated (DynamicStrings_String s) if (IsOn (f->alloc, s)) { SubFrom (&f->alloc, s); - return ; + return; } else { @@ -1147,7 +1147,7 @@ static void SubAllocated (DynamicStrings_String s) SubDeallocated - removes string, s, from the list of deallocated strings. */ -static void SubDeallocated (DynamicStrings_String s) +static void SubDeallocated (DynamicStrings_String__opaque s) { DynamicStrings_frame f; @@ -1157,7 +1157,7 @@ static void SubDeallocated (DynamicStrings_String s) if (IsOn (f->dealloc, s)) { SubFrom (&f->dealloc, s); - return ; + return; } else { @@ -1171,13 +1171,13 @@ static void SubDeallocated (DynamicStrings_String s) SubDebugInfo - removes string, s, from the list of allocated strings. */ -static void SubDebugInfo (DynamicStrings_String s) +static void SubDebugInfo (DynamicStrings_String__opaque s) { if (IsOnDeallocated (s)) { Assertion_Assert (! DebugOn); /* string has already been deallocated */ - return ; + return; } if (IsOnAllocated (s)) { @@ -1196,9 +1196,9 @@ static void SubDebugInfo (DynamicStrings_String s) AddDebugInfo - adds string, s, to the list of allocated strings. */ -static void AddDebugInfo (DynamicStrings_String s) +static void AddDebugInfo (DynamicStrings_String__opaque s) { - s->debug.next = NULL; + s->debug.next = static_cast (NULL); s->debug.file = NULL; s->debug.line = 0; s->debug.proc = NULL; @@ -1235,7 +1235,7 @@ static void ConcatContents (DynamicStrings_Contents *c, const char *a_, unsigned Storage_ALLOCATE ((void **) &(*c).next, sizeof (DynamicStrings_stringRecord)); (*c).next->head = NULL; (*c).next->contents.len = 0; - (*c).next->contents.next = NULL; + (*c).next->contents.next = static_cast (NULL); ConcatContents (&(*c).next->contents, (const char *) a, _a_high, h, o); AddDebugInfo ((*c).next); (*c).next = AssignDebug ((*c).next, (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 722, (const char *) "ConcatContents", 14); @@ -1251,7 +1251,7 @@ static void ConcatContents (DynamicStrings_Contents *c, const char *a_, unsigned DeallocateCharStar - deallocates any charStar. */ -static void DeallocateCharStar (DynamicStrings_String s) +static void DeallocateCharStar (DynamicStrings_String__opaque s) { if ((s != NULL) && (s->head != NULL)) { @@ -1271,7 +1271,7 @@ static void DeallocateCharStar (DynamicStrings_String s) CheckPoisoned - checks for a poisoned string, s. */ -static DynamicStrings_String CheckPoisoned (DynamicStrings_String s) +static DynamicStrings_String__opaque CheckPoisoned (DynamicStrings_String__opaque s) { if (((PoisonOn && (s != NULL)) && (s->head != NULL)) && (s->head->state == DynamicStrings_poisoned)) { @@ -1288,7 +1288,7 @@ static DynamicStrings_String CheckPoisoned (DynamicStrings_String s) MarkInvalid - marks the char * version of String, s, as invalid. */ -static void MarkInvalid (DynamicStrings_String s) +static void MarkInvalid (DynamicStrings_String__opaque s) { if (PoisonOn) { @@ -1331,7 +1331,7 @@ static void ConcatContentsAddress (DynamicStrings_Contents *c, void * a, unsigne Storage_ALLOCATE ((void **) &(*c).next, sizeof (DynamicStrings_stringRecord)); (*c).next->head = NULL; (*c).next->contents.len = 0; - (*c).next->contents.next = NULL; + (*c).next->contents.next = static_cast (NULL); ConcatContentsAddress (&(*c).next->contents, reinterpret_cast (p), h-j); AddDebugInfo ((*c).next); if (TraceOn) @@ -1342,7 +1342,7 @@ static void ConcatContentsAddress (DynamicStrings_Contents *c, void * a, unsigne else { (*c).len = i; - (*c).next = NULL; + (*c).next = static_cast (NULL); } } @@ -1353,9 +1353,9 @@ static void ConcatContentsAddress (DynamicStrings_Contents *c, void * a, unsigne onlist. String, a, is returned. */ -static DynamicStrings_String AddToGarbage (DynamicStrings_String a, DynamicStrings_String b) +static DynamicStrings_String__opaque AddToGarbage (DynamicStrings_String__opaque a, DynamicStrings_String__opaque b) { - DynamicStrings_String c; + DynamicStrings_String__opaque c; if (PoisonOn) { @@ -1392,7 +1392,7 @@ static DynamicStrings_String AddToGarbage (DynamicStrings_String a, DynamicStrin IsOnGarbage - returns TRUE if, s, is on string, e, garbage list. */ -static bool IsOnGarbage (DynamicStrings_String e, DynamicStrings_String s) +static bool IsOnGarbage (DynamicStrings_String__opaque e, DynamicStrings_String__opaque s) { if ((e != NULL) && (s != NULL)) { @@ -1430,7 +1430,7 @@ static bool IsWhite (char ch) DumpState - */ -static void DumpState (DynamicStrings_String s) +static void DumpState (DynamicStrings_String__opaque s) { switch (s->head->state) { @@ -1464,7 +1464,7 @@ static void DumpState (DynamicStrings_String s) DumpStringSynopsis - */ -static void DumpStringSynopsis (DynamicStrings_String s) +static void DumpStringSynopsis (DynamicStrings_String__opaque s) { writeCstring (s->debug.file); writeString ((const char *) ":", 1); @@ -1497,9 +1497,9 @@ static void DumpStringSynopsis (DynamicStrings_String s) DumpString - displays the contents of string, s. */ -static void DumpString (DynamicStrings_String s) +static void DumpString (DynamicStrings_String__opaque s) { - DynamicStrings_String t; + DynamicStrings_String__opaque t; if (s != NULL) { @@ -1541,7 +1541,7 @@ static void Init (void) extern "C" DynamicStrings_String DynamicStrings_InitString (const char *a_, unsigned int _a_high) { - DynamicStrings_String s; + DynamicStrings_String__opaque s; char a[_a_high+1]; /* make a local copy of each unbounded array. */ @@ -1549,21 +1549,21 @@ extern "C" DynamicStrings_String DynamicStrings_InitString (const char *a_, unsi Storage_ALLOCATE ((void **) &s, sizeof (DynamicStrings_stringRecord)); s->contents.len = 0; - s->contents.next = NULL; + s->contents.next = static_cast (NULL); ConcatContents (&s->contents, (const char *) a, _a_high, StrLib_StrLen ((const char *) a, _a_high), 0); Storage_ALLOCATE ((void **) &s->head, sizeof (DynamicStrings_descriptor)); s->head->charStarUsed = false; s->head->charStar = NULL; s->head->charStarSize = 0; s->head->charStarValid = false; - s->head->garbage = NULL; + s->head->garbage = static_cast (NULL); s->head->state = DynamicStrings_inuse; AddDebugInfo (s); if (TraceOn) { s = AssignDebug (s, (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 758, (const char *) "InitString", 10); } - return s; + return static_cast (s); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -1576,48 +1576,48 @@ extern "C" DynamicStrings_String DynamicStrings_InitString (const char *a_, unsi extern "C" DynamicStrings_String DynamicStrings_KillString (DynamicStrings_String s) { - DynamicStrings_String t; + DynamicStrings_String__opaque t; if (PoisonOn) { - s = CheckPoisoned (s); + s = static_cast (CheckPoisoned (static_cast (s))); } if (s != NULL) { if (CheckOn) { /* avoid gcc warning by using compound statement even if not strictly necessary. */ - if (IsOnAllocated (s)) + if (IsOnAllocated (static_cast (s))) { - SubAllocated (s); + SubAllocated (static_cast (s)); } - else if (IsOnDeallocated (s)) + else if (IsOnDeallocated (static_cast (s))) { /* avoid dangling else. */ - SubDeallocated (s); + SubDeallocated (static_cast (s)); } } - if (s->head != NULL) + if (static_cast (s)->head != NULL) { - s->head->state = DynamicStrings_poisoned; - s->head->garbage = DynamicStrings_KillString (s->head->garbage); + static_cast (s)->head->state = DynamicStrings_poisoned; + static_cast (s)->head->garbage = static_cast (DynamicStrings_KillString (static_cast (static_cast (s)->head->garbage))); if (! PoisonOn) { - DeallocateCharStar (s); + DeallocateCharStar (static_cast (s)); } if (! PoisonOn) { - Storage_DEALLOCATE ((void **) &s->head, sizeof (DynamicStrings_descriptor)); - s->head = NULL; + Storage_DEALLOCATE ((void **) &static_cast (s)->head, sizeof (DynamicStrings_descriptor)); + static_cast (s)->head = NULL; } } - t = DynamicStrings_KillString (s->contents.next); + t = static_cast (DynamicStrings_KillString (static_cast (static_cast (s)->contents.next))); if (! PoisonOn) { Storage_DEALLOCATE ((void **) &s, sizeof (DynamicStrings_stringRecord)); } } - return NULL; + return static_cast (NULL); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -1645,11 +1645,11 @@ extern "C" void DynamicStrings_Fin (DynamicStrings_String s) extern "C" DynamicStrings_String DynamicStrings_InitStringCharStar (void * a) { - DynamicStrings_String s; + DynamicStrings_String__opaque s; Storage_ALLOCATE ((void **) &s, sizeof (DynamicStrings_stringRecord)); s->contents.len = 0; - s->contents.next = NULL; + s->contents.next = static_cast (NULL); if (a != NULL) { ConcatContentsAddress (&s->contents, a, static_cast (libc_strlen (a))); @@ -1659,14 +1659,14 @@ extern "C" DynamicStrings_String DynamicStrings_InitStringCharStar (void * a) s->head->charStar = NULL; s->head->charStarSize = 0; s->head->charStarValid = false; - s->head->garbage = NULL; + s->head->garbage = static_cast (NULL); s->head->state = DynamicStrings_inuse; AddDebugInfo (s); if (TraceOn) { s = AssignDebug (s, (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 957, (const char *) "InitStringCharStar", 18); } - return s; + return static_cast (s); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -1682,16 +1682,16 @@ extern "C" DynamicStrings_String DynamicStrings_InitStringChar (char ch) struct InitStringChar__T5_a { char array[1+1]; }; InitStringChar__T5 a; - DynamicStrings_String s; + DynamicStrings_String__opaque s; a.array[0] = ch; a.array[1] = ASCII_nul; - s = DynamicStrings_InitString ((const char *) &a.array[0], 1); + s = static_cast (DynamicStrings_InitString ((const char *) &a.array[0], 1)); if (TraceOn) { s = AssignDebug (s, (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 977, (const char *) "InitStringChar", 14); } - return s; + return static_cast (s); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -1705,11 +1705,11 @@ extern "C" DynamicStrings_String DynamicStrings_Mark (DynamicStrings_String s) { if (PoisonOn) { - s = CheckPoisoned (s); + s = static_cast (CheckPoisoned (static_cast (s))); } - if ((s != NULL) && (s->head->state == DynamicStrings_inuse)) + if ((s != NULL) && (static_cast (s)->head->state == DynamicStrings_inuse)) { - s->head->state = DynamicStrings_marked; + static_cast (s)->head->state = DynamicStrings_marked; } return s; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -1729,7 +1729,7 @@ extern "C" unsigned int DynamicStrings_Length (DynamicStrings_String s) } else { - return s->contents.len+(DynamicStrings_Length (s->contents.next)); + return static_cast (s)->contents.len+(DynamicStrings_Length (static_cast (static_cast (s)->contents.next))); } /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -1742,12 +1742,12 @@ extern "C" unsigned int DynamicStrings_Length (DynamicStrings_String s) extern "C" DynamicStrings_String DynamicStrings_ConCat (DynamicStrings_String a, DynamicStrings_String b) { - DynamicStrings_String t; + DynamicStrings_String__opaque t; if (PoisonOn) { - a = CheckPoisoned (a); - b = CheckPoisoned (b); + a = static_cast (CheckPoisoned (static_cast (a))); + b = static_cast (CheckPoisoned (static_cast (b))); } if (a == b) { @@ -1756,17 +1756,17 @@ extern "C" DynamicStrings_String DynamicStrings_ConCat (DynamicStrings_String a, else if (a != NULL) { /* avoid dangling else. */ - a = AddToGarbage (a, b); - MarkInvalid (a); - t = a; + a = static_cast (AddToGarbage (static_cast (a), static_cast (b))); + MarkInvalid (static_cast (a)); + t = static_cast (a); while (b != NULL) { while ((t->contents.len == MaxBuf) && (t->contents.next != NULL)) { t = t->contents.next; } - ConcatContents (&t->contents, (const char *) &b->contents.buf.array[0], (MaxBuf-1), b->contents.len, 0); - b = b->contents.next; + ConcatContents (&t->contents, (const char *) &static_cast (b)->contents.buf.array[0], (MaxBuf-1), static_cast (b)->contents.len, 0); + b = static_cast (static_cast (b)->contents.next); } } if ((a == NULL) && (b != NULL)) @@ -1790,16 +1790,16 @@ extern "C" DynamicStrings_String DynamicStrings_ConCatChar (DynamicStrings_Strin struct ConCatChar__T6_a { char array[1+1]; }; ConCatChar__T6 b; - DynamicStrings_String t; + DynamicStrings_String__opaque t; if (PoisonOn) { - a = CheckPoisoned (a); + a = static_cast (CheckPoisoned (static_cast (a))); } b.array[0] = ch; b.array[1] = ASCII_nul; - t = a; - MarkInvalid (a); + t = static_cast (a); + MarkInvalid (static_cast (a)); while ((t->contents.len == MaxBuf) && (t->contents.next != NULL)) { t = t->contents.next; @@ -1820,13 +1820,13 @@ extern "C" DynamicStrings_String DynamicStrings_Assign (DynamicStrings_String a, { if (PoisonOn) { - a = CheckPoisoned (a); - b = CheckPoisoned (b); + a = static_cast (CheckPoisoned (static_cast (a))); + b = static_cast (CheckPoisoned (static_cast (b))); } if ((a != NULL) && (b != NULL)) { - a->contents.next = DynamicStrings_KillString (a->contents.next); - a->contents.len = 0; + static_cast (a)->contents.next = static_cast (DynamicStrings_KillString (static_cast (static_cast (a)->contents.next))); + static_cast (a)->contents.len = 0; } return DynamicStrings_ConCat (a, b); /* static analysis guarentees a RETURN statement will be used before here. */ @@ -1840,10 +1840,10 @@ extern "C" DynamicStrings_String DynamicStrings_Assign (DynamicStrings_String a, extern "C" DynamicStrings_String DynamicStrings_ReplaceChar (DynamicStrings_String s, char from, char to) { - DynamicStrings_String t; + DynamicStrings_String__opaque t; unsigned int i; - t = s; + t = static_cast (s); while (t != NULL) { i = 0; @@ -1871,12 +1871,12 @@ extern "C" DynamicStrings_String DynamicStrings_Dup (DynamicStrings_String s) { if (PoisonOn) { - s = CheckPoisoned (s); + s = static_cast (CheckPoisoned (static_cast (s))); } s = DynamicStrings_Assign (DynamicStrings_InitString ((const char *) "", 0), s); if (TraceOn) { - s = AssignDebug (s, (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1198, (const char *) "Dup", 3); + s = static_cast (AssignDebug (static_cast (s), (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1198, (const char *) "Dup", 3)); } return s; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -1892,13 +1892,13 @@ extern "C" DynamicStrings_String DynamicStrings_Add (DynamicStrings_String a, Dy { if (PoisonOn) { - a = CheckPoisoned (a); - b = CheckPoisoned (b); + a = static_cast (CheckPoisoned (static_cast (a))); + b = static_cast (CheckPoisoned (static_cast (b))); } a = DynamicStrings_ConCat (DynamicStrings_ConCat (DynamicStrings_InitString ((const char *) "", 0), a), b); if (TraceOn) { - a = AssignDebug (a, (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1218, (const char *) "Add", 3); + a = static_cast (AssignDebug (static_cast (a), (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1218, (const char *) "Add", 3)); } return a; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -1916,25 +1916,25 @@ extern "C" bool DynamicStrings_Equal (DynamicStrings_String a, DynamicStrings_St if (PoisonOn) { - a = CheckPoisoned (a); - b = CheckPoisoned (b); + a = static_cast (CheckPoisoned (static_cast (a))); + b = static_cast (CheckPoisoned (static_cast (b))); } if ((DynamicStrings_Length (a)) == (DynamicStrings_Length (b))) { while ((a != NULL) && (b != NULL)) { i = 0; - Assertion_Assert (a->contents.len == b->contents.len); - while (i < a->contents.len) + Assertion_Assert (static_cast (a)->contents.len == static_cast (b)->contents.len); + while (i < static_cast (a)->contents.len) { - if (a->contents.buf.array[i] != b->contents.buf.array[i]) + if (static_cast (a)->contents.buf.array[i] != static_cast (b)->contents.buf.array[i]) { return false; } i += 1; } - a = a->contents.next; - b = b->contents.next; + a = static_cast (static_cast (a)->contents.next); + b = static_cast (static_cast (b)->contents.next); } return true; } @@ -1954,26 +1954,26 @@ extern "C" bool DynamicStrings_Equal (DynamicStrings_String a, DynamicStrings_St extern "C" bool DynamicStrings_EqualCharStar (DynamicStrings_String s, void * a) { - DynamicStrings_String t; + DynamicStrings_String__opaque t; if (PoisonOn) { - s = CheckPoisoned (s); + s = static_cast (CheckPoisoned (static_cast (s))); } - t = DynamicStrings_InitStringCharStar (a); + t = static_cast (DynamicStrings_InitStringCharStar (a)); if (TraceOn) { t = AssignDebug (t, (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1275, (const char *) "EqualCharStar", 13); } - t = AddToGarbage (t, s); - if (DynamicStrings_Equal (t, s)) + t = AddToGarbage (t, static_cast (s)); + if (DynamicStrings_Equal (static_cast (t), s)) { - t = DynamicStrings_KillString (t); + t = static_cast (DynamicStrings_KillString (static_cast (t))); return true; } else { - t = DynamicStrings_KillString (t); + t = static_cast (DynamicStrings_KillString (static_cast (t))); return false; } /* static analysis guarentees a RETURN statement will be used before here. */ @@ -1988,7 +1988,7 @@ extern "C" bool DynamicStrings_EqualCharStar (DynamicStrings_String s, void * a) extern "C" bool DynamicStrings_EqualArray (DynamicStrings_String s, const char *a_, unsigned int _a_high) { - DynamicStrings_String t; + DynamicStrings_String__opaque t; char a[_a_high+1]; /* make a local copy of each unbounded array. */ @@ -1996,22 +1996,22 @@ extern "C" bool DynamicStrings_EqualArray (DynamicStrings_String s, const char * if (PoisonOn) { - s = CheckPoisoned (s); + s = static_cast (CheckPoisoned (static_cast (s))); } - t = DynamicStrings_InitString ((const char *) a, _a_high); + t = static_cast (DynamicStrings_InitString ((const char *) a, _a_high)); if (TraceOn) { t = AssignDebug (t, (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1305, (const char *) "EqualArray", 10); } - t = AddToGarbage (t, s); - if (DynamicStrings_Equal (t, s)) + t = AddToGarbage (t, static_cast (s)); + if (DynamicStrings_Equal (static_cast (t), s)) { - t = DynamicStrings_KillString (t); + t = static_cast (DynamicStrings_KillString (static_cast (t))); return true; } else { - t = DynamicStrings_KillString (t); + t = static_cast (DynamicStrings_KillString (static_cast (t))); return false; } /* static analysis guarentees a RETURN statement will be used before here. */ @@ -2027,11 +2027,11 @@ extern "C" DynamicStrings_String DynamicStrings_Mult (DynamicStrings_String s, u { if (PoisonOn) { - s = CheckPoisoned (s); + s = static_cast (CheckPoisoned (static_cast (s))); } if (n <= 0) { - s = AddToGarbage (DynamicStrings_InitString ((const char *) "", 0), s); + s = static_cast (AddToGarbage (static_cast (DynamicStrings_InitString ((const char *) "", 0)), static_cast (s))); } else { @@ -2039,7 +2039,7 @@ extern "C" DynamicStrings_String DynamicStrings_Mult (DynamicStrings_String s, u } if (TraceOn) { - s = AssignDebug (s, (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1337, (const char *) "Mult", 4); + s = static_cast (AssignDebug (static_cast (s), (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1337, (const char *) "Mult", 4)); } return s; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -2061,15 +2061,15 @@ extern "C" DynamicStrings_String DynamicStrings_Mult (DynamicStrings_String s, u extern "C" DynamicStrings_String DynamicStrings_Slice (DynamicStrings_String s, int low, int high) { - DynamicStrings_String d; - DynamicStrings_String t; + DynamicStrings_String__opaque d; + DynamicStrings_String__opaque t; int start; int end; int o; if (PoisonOn) { - s = CheckPoisoned (s); + s = static_cast (CheckPoisoned (static_cast (s))); } if (low < 0) { @@ -2084,17 +2084,17 @@ extern "C" DynamicStrings_String DynamicStrings_Slice (DynamicStrings_String s, /* make sure high is <= Length (s) */ high = Min (DynamicStrings_Length (s), static_cast (high)); } - d = DynamicStrings_InitString ((const char *) "", 0); - d = AddToGarbage (d, s); + d = static_cast (DynamicStrings_InitString ((const char *) "", 0)); + d = AddToGarbage (d, static_cast (s)); o = 0; t = d; while (s != NULL) { - if (low < (o+((int ) (s->contents.len)))) + if (low < (o+((int ) (static_cast (s)->contents.len)))) { if (o > high) { - s = NULL; + s = static_cast (NULL); } else { @@ -2123,22 +2123,22 @@ extern "C" DynamicStrings_String DynamicStrings_Slice (DynamicStrings_String s, } t = t->contents.next; } - ConcatContentsAddress (&t->contents, &s->contents.buf.array[start], static_cast (end-start)); - o += s->contents.len; - s = s->contents.next; + ConcatContentsAddress (&t->contents, &static_cast (s)->contents.buf.array[start], static_cast (end-start)); + o += static_cast (s)->contents.len; + s = static_cast (static_cast (s)->contents.next); } } else { - o += s->contents.len; - s = s->contents.next; + o += static_cast (s)->contents.len; + s = static_cast (static_cast (s)->contents.next); } } if (TraceOn) { d = AssignDebug (d, (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1422, (const char *) "Slice", 5); } - return d; + return static_cast (d); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -2157,21 +2157,21 @@ extern "C" int DynamicStrings_Index (DynamicStrings_String s, char ch, unsigned if (PoisonOn) { - s = CheckPoisoned (s); + s = static_cast (CheckPoisoned (static_cast (s))); } k = 0; while (s != NULL) { - if ((k+s->contents.len) < o) + if ((k+static_cast (s)->contents.len) < o) { - k += s->contents.len; + k += static_cast (s)->contents.len; } else { i = o-k; - while (i < s->contents.len) + while (i < static_cast (s)->contents.len) { - if (s->contents.buf.array[i] == ch) + if (static_cast (s)->contents.buf.array[i] == ch) { return k+i; } @@ -2180,7 +2180,7 @@ extern "C" int DynamicStrings_Index (DynamicStrings_String s, char ch, unsigned k += i; o = k; } - s = s->contents.next; + s = static_cast (static_cast (s)->contents.next); } return -1; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -2203,15 +2203,15 @@ extern "C" int DynamicStrings_RIndex (DynamicStrings_String s, char ch, unsigned if (PoisonOn) { - s = CheckPoisoned (s); + s = static_cast (CheckPoisoned (static_cast (s))); } j = -1; k = 0; while (s != NULL) { - if ((k+s->contents.len) < o) + if ((k+static_cast (s)->contents.len) < o) { - k += s->contents.len; + k += static_cast (s)->contents.len; } else { @@ -2223,9 +2223,9 @@ extern "C" int DynamicStrings_RIndex (DynamicStrings_String s, char ch, unsigned { i = o-k; } - while (i < s->contents.len) + while (i < static_cast (s)->contents.len) { - if (s->contents.buf.array[i] == ch) + if (static_cast (s)->contents.buf.array[i] == ch) { j = k; } @@ -2233,7 +2233,7 @@ extern "C" int DynamicStrings_RIndex (DynamicStrings_String s, char ch, unsigned i += 1; } } - s = s->contents.next; + s = static_cast (static_cast (s)->contents.next); } return j; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -2257,7 +2257,7 @@ extern "C" int DynamicStrings_ReverseIndex (DynamicStrings_String s, char ch, in if (PoisonOn) { - s = CheckPoisoned (s); + s = static_cast (CheckPoisoned (static_cast (s))); } if (o < 0) { @@ -2311,7 +2311,7 @@ extern "C" DynamicStrings_String DynamicStrings_RemoveComment (DynamicStrings_St } if (TraceOn) { - s = AssignDebug (s, (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1576, (const char *) "RemoveComment", 13); + s = static_cast (AssignDebug (static_cast (s), (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1576, (const char *) "RemoveComment", 13)); } return s; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -2336,7 +2336,7 @@ extern "C" DynamicStrings_String DynamicStrings_RemoveWhitePrefix (DynamicString s = DynamicStrings_Slice (s, (int ) (i), 0); if (TraceOn) { - s = AssignDebug (s, (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1688, (const char *) "RemoveWhitePrefix", 17); + s = static_cast (AssignDebug (static_cast (s), (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1688, (const char *) "RemoveWhitePrefix", 17)); } return s; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -2361,7 +2361,7 @@ extern "C" DynamicStrings_String DynamicStrings_RemoveWhitePostfix (DynamicStrin s = DynamicStrings_Slice (s, 0, i+1); if (TraceOn) { - s = AssignDebug (s, (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1710, (const char *) "RemoveWhitePostfix", 18); + s = static_cast (AssignDebug (static_cast (s), (const char *) "../../gcc/m2/gm2-libs/DynamicStrings.mod", 40, 1710, (const char *) "RemoveWhitePostfix", 18)); } return s; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -2379,12 +2379,12 @@ extern "C" DynamicStrings_String DynamicStrings_ToUpper (DynamicStrings_String s { char ch; unsigned int i; - DynamicStrings_String t; + DynamicStrings_String__opaque t; if (s != NULL) { - MarkInvalid (s); - t = s; + MarkInvalid (static_cast (s)); + t = static_cast (s); while (t != NULL) { i = 0; @@ -2416,12 +2416,12 @@ extern "C" DynamicStrings_String DynamicStrings_ToLower (DynamicStrings_String s { char ch; unsigned int i; - DynamicStrings_String t; + DynamicStrings_String__opaque t; if (s != NULL) { - MarkInvalid (s); - t = s; + MarkInvalid (static_cast (s)); + t = static_cast (s); while (t != NULL) { i = 0; @@ -2456,12 +2456,12 @@ extern "C" void DynamicStrings_CopyOut (char *a, unsigned int _a_high, DynamicSt i = 0; while (i < l) { - a[i] = DynamicStrings_char (s, static_cast (i)); + const_cast(a)[i] = DynamicStrings_char (s, static_cast (i)); i += 1; } if (i <= _a_high) { - a[i] = ASCII_nul; + const_cast(a)[i] = ASCII_nul; } } @@ -2476,7 +2476,7 @@ extern "C" char DynamicStrings_char (DynamicStrings_String s, int i) if (PoisonOn) { - s = CheckPoisoned (s); + s = static_cast (CheckPoisoned (static_cast (s))); } if (i < 0) { @@ -2486,18 +2486,18 @@ extern "C" char DynamicStrings_char (DynamicStrings_String s, int i) { c = i; } - while ((s != NULL) && (c >= s->contents.len)) + while ((s != NULL) && (c >= static_cast (s)->contents.len)) { - c -= s->contents.len; - s = s->contents.next; + c -= static_cast (s)->contents.len; + s = static_cast (static_cast (s)->contents.next); } - if ((s == NULL) || (c >= s->contents.len)) + if ((s == NULL) || (c >= static_cast (s)->contents.len)) { return ASCII_nul; } else { - return s->contents.buf.array[c]; + return static_cast (s)->contents.buf.array[c]; } /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -2512,14 +2512,14 @@ extern "C" void * DynamicStrings_string (DynamicStrings_String s) { typedef char *string__T2; - DynamicStrings_String a; + DynamicStrings_String__opaque a; unsigned int l; unsigned int i; string__T2 p; if (PoisonOn) { - s = CheckPoisoned (s); + s = static_cast (CheckPoisoned (static_cast (s))); } if (s == NULL) { @@ -2527,18 +2527,18 @@ extern "C" void * DynamicStrings_string (DynamicStrings_String s) } else { - if (! s->head->charStarValid) + if (! static_cast (s)->head->charStarValid) { l = DynamicStrings_Length (s); - if (! (s->head->charStarUsed && (s->head->charStarSize > l))) + if (! (static_cast (s)->head->charStarUsed && (static_cast (s)->head->charStarSize > l))) { - DeallocateCharStar (s); - Storage_ALLOCATE (&s->head->charStar, l+1); - s->head->charStarSize = l+1; - s->head->charStarUsed = true; + DeallocateCharStar (static_cast (s)); + Storage_ALLOCATE (&static_cast (s)->head->charStar, l+1); + static_cast (s)->head->charStarSize = l+1; + static_cast (s)->head->charStarUsed = true; } - p = static_cast (s->head->charStar); - a = s; + p = static_cast (static_cast (s)->head->charStar); + a = static_cast (s); while (a != NULL) { i = 0; @@ -2551,9 +2551,9 @@ extern "C" void * DynamicStrings_string (DynamicStrings_String s) a = a->contents.next; } (*p) = ASCII_nul; - s->head->charStarValid = true; + static_cast (s)->head->charStarValid = true; } - return s->head->charStar; + return static_cast (s)->head->charStar; } /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -2573,7 +2573,7 @@ extern "C" DynamicStrings_String DynamicStrings_InitStringDB (const char *a_, un memcpy (a, a_, _a_high+1); memcpy (file, file_, _file_high+1); - return AssignDebug (DynamicStrings_InitString ((const char *) a, _a_high), (const char *) file, _file_high, line, (const char *) "InitString", 10); + return static_cast (AssignDebug (static_cast (DynamicStrings_InitString ((const char *) a, _a_high)), (const char *) file, _file_high, line, (const char *) "InitString", 10)); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -2590,7 +2590,7 @@ extern "C" DynamicStrings_String DynamicStrings_InitStringCharStarDB (void * a, /* make a local copy of each unbounded array. */ memcpy (file, file_, _file_high+1); - return AssignDebug (DynamicStrings_InitStringCharStar (a), (const char *) file, _file_high, line, (const char *) "InitStringCharStar", 18); + return static_cast (AssignDebug (static_cast (DynamicStrings_InitStringCharStar (a)), (const char *) file, _file_high, line, (const char *) "InitStringCharStar", 18)); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -2607,7 +2607,7 @@ extern "C" DynamicStrings_String DynamicStrings_InitStringCharDB (char ch, const /* make a local copy of each unbounded array. */ memcpy (file, file_, _file_high+1); - return AssignDebug (DynamicStrings_InitStringChar (ch), (const char *) file, _file_high, line, (const char *) "InitStringChar", 14); + return static_cast (AssignDebug (static_cast (DynamicStrings_InitStringChar (ch)), (const char *) file, _file_high, line, (const char *) "InitStringChar", 14)); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -2624,7 +2624,7 @@ extern "C" DynamicStrings_String DynamicStrings_MultDB (DynamicStrings_String s, /* make a local copy of each unbounded array. */ memcpy (file, file_, _file_high+1); - return AssignDebug (DynamicStrings_Mult (s, n), (const char *) file, _file_high, line, (const char *) "Mult", 4); + return static_cast (AssignDebug (static_cast (DynamicStrings_Mult (s, n)), (const char *) file, _file_high, line, (const char *) "Mult", 4)); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -2641,7 +2641,7 @@ extern "C" DynamicStrings_String DynamicStrings_DupDB (DynamicStrings_String s, /* make a local copy of each unbounded array. */ memcpy (file, file_, _file_high+1); - return AssignDebug (DynamicStrings_Dup (s), (const char *) file, _file_high, line, (const char *) "Dup", 3); + return static_cast (AssignDebug (static_cast (DynamicStrings_Dup (s)), (const char *) file, _file_high, line, (const char *) "Dup", 3)); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -2659,8 +2659,8 @@ extern "C" DynamicStrings_String DynamicStrings_SliceDB (DynamicStrings_String s memcpy (file, file_, _file_high+1); DSdbEnter (); - s = AssignDebug (DynamicStrings_Slice (s, low, high), (const char *) file, _file_high, line, (const char *) "Slice", 5); - DSdbExit (s); + s = static_cast (AssignDebug (static_cast (DynamicStrings_Slice (s, low, high)), (const char *) file, _file_high, line, (const char *) "Slice", 5)); + DSdbExit (static_cast (s)); return s; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -2680,8 +2680,8 @@ extern "C" void DynamicStrings_PushAllocation (void) Init (); Storage_ALLOCATE ((void **) &f, sizeof (DynamicStrings_frameRec)); f->next = frameHead; - f->alloc = NULL; - f->dealloc = NULL; + f->alloc = static_cast (NULL); + f->dealloc = static_cast (NULL); frameHead = f; } } @@ -2700,7 +2700,7 @@ extern "C" void DynamicStrings_PopAllocation (bool halt) { if (CheckOn) { - if ((DynamicStrings_PopAllocationExemption (halt, NULL)) == NULL) + if ((DynamicStrings_PopAllocationExemption (halt, static_cast (NULL))) == NULL) {} /* empty. */ } } @@ -2718,7 +2718,7 @@ extern "C" void DynamicStrings_PopAllocation (bool halt) extern "C" DynamicStrings_String DynamicStrings_PopAllocationExemption (bool halt, DynamicStrings_String e) { - DynamicStrings_String s; + DynamicStrings_String__opaque s; bool b; Init (); @@ -2739,7 +2739,7 @@ extern "C" DynamicStrings_String DynamicStrings_PopAllocationExemption (bool hal s = frameHead->alloc; while (s != NULL) { - if (! (((e == s) || (IsOnGarbage (e, s))) || (IsOnGarbage (s, e)))) + if (! (((e == s) || (IsOnGarbage (static_cast (e), s))) || (IsOnGarbage (s, static_cast (e))))) { if (! b) { @@ -2764,12 +2764,12 @@ extern "C" DynamicStrings_String DynamicStrings_PopAllocationExemption (bool hal __builtin_unreachable (); } -extern "C" void _M2_DynamicStrings_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_DynamicStrings_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { Initialized = false; Init (); } -extern "C" void _M2_DynamicStrings_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_DynamicStrings_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GEnvironment.cc b/gcc/m2/mc-boot/GEnvironment.cc index 3916428a10823..aad1bb46c010e 100644 --- a/gcc/m2/mc-boot/GEnvironment.cc +++ b/gcc/m2/mc-boot/GEnvironment.cc @@ -38,9 +38,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see # undef NULL # define NULL 0 #endif -#define _Environment_H #define _Environment_C +#include "GEnvironment.h" # include "GSYSTEM.h" # include "Glibc.h" # include "GASCII.h" @@ -86,16 +86,16 @@ extern "C" bool Environment_GetEnvironment (const char *Env_, unsigned int _Env_ i = 0; High = _dest_high; - Addr = static_cast (libc_getenv (&Env)); + Addr = static_cast (libc_getenv (const_cast (static_cast(Env)))); while (((i < High) && (Addr != NULL)) && ((*Addr) != ASCII_nul)) { - dest[i] = (*Addr); + const_cast(dest)[i] = (*Addr); Addr += 1; i += 1; } if (i < High) { - dest[i] = ASCII_nul; + const_cast(dest)[i] = ASCII_nul; } return Addr != NULL; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -116,15 +116,15 @@ extern "C" bool Environment_PutEnvironment (const char *EnvDef_, unsigned int _E /* make a local copy of each unbounded array. */ memcpy (EnvDef, EnvDef_, _EnvDef_high+1); - return (libc_putenv (&EnvDef)) == 0; + return (libc_putenv (const_cast (static_cast(EnvDef)))) == 0; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } -extern "C" void _M2_Environment_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_Environment_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_Environment_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_Environment_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GFIO.cc b/gcc/m2/mc-boot/GFIO.cc index 3f05b35e6e219..229dc175e75b0 100644 --- a/gcc/m2/mc-boot/GFIO.cc +++ b/gcc/m2/mc-boot/GFIO.cc @@ -48,9 +48,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see # undef NULL # define NULL 0 #endif -#define _FIO_H #define _FIO_C +#include "GFIO.h" # include "GSYSTEM.h" # include "GASCII.h" # include "GStrLib.h" @@ -63,9 +63,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see typedef unsigned int FIO_File; -FIO_File FIO_StdErr; -FIO_File FIO_StdOut; -FIO_File FIO_StdIn; # define MaxBufferLength (1024*16) # define MaxErrorString (1024*8) # define CreatePermissions 0666 @@ -88,7 +85,7 @@ typedef enum {FIO_successful, FIO_outofmemory, FIO_toomanyfilesopen, FIO_failed, typedef enum {FIO_unused, FIO_openedforread, FIO_openedforwrite, FIO_openedforrandom} FIO_FileUsage; struct FIO_NameInfo_r { - void *address; + void * address; unsigned int size; }; @@ -96,11 +93,11 @@ struct FIO_buf_r { bool valid; long int bufstart; unsigned int position; - void *address; + void * address; unsigned int filled; unsigned int size; unsigned int left; - FIO__T7 *contents; + FIO__T7 * contents; }; struct FIO__T7_a { char array[MaxBufferLength+1]; }; @@ -639,7 +636,7 @@ static FIO_File InitializeFile (FIO_File f, void * fname, unsigned int flength, { fd->buffer->left = 0; } - fd->buffer->contents = reinterpret_cast (fd->buffer->address); /* provides easy access for reading characters */ + fd->buffer->contents = static_cast (fd->buffer->address); /* provides easy access for reading characters */ fd->state = fstate; /* provides easy access for reading characters */ } } @@ -913,7 +910,7 @@ static void HandleEscape (char *dest, unsigned int _dest_high, const char *src_, if (src[(*i)+1] == 'n') { /* requires a newline */ - dest[(*j)] = ASCII_nl; + const_cast(dest)[(*j)] = ASCII_nl; (*j) += 1; (*i) += 2; } @@ -921,7 +918,7 @@ static void HandleEscape (char *dest, unsigned int _dest_high, const char *src_, { /* avoid dangling else. */ /* requires a tab (yuck) tempted to fake this but I better not.. */ - dest[(*j)] = ASCII_tab; + const_cast(dest)[(*j)] = ASCII_tab; (*j) += 1; (*i) += 2; } @@ -930,7 +927,7 @@ static void HandleEscape (char *dest, unsigned int _dest_high, const char *src_, /* avoid dangling else. */ /* copy escaped character */ (*i) += 1; - dest[(*j)] = src[(*i)]; + const_cast(dest)[(*j)] = src[(*i)]; (*j) += 1; (*i) += 1; } @@ -954,7 +951,7 @@ static void Cast (unsigned char *a, unsigned int _a_high, const unsigned char *b { for (i=0; i<=_a_high; i++) { - a[i] = b[i]; + const_cast(a)[i] = b[i]; } } else @@ -1004,7 +1001,7 @@ static void StringFormat1 (char *dest, unsigned int _dest_high, const char *src_ } else { - dest[j] = src[i]; + const_cast(dest)[j] = src[i]; i += 1; j += 1; } @@ -1017,13 +1014,13 @@ static void StringFormat1 (char *dest, unsigned int _dest_high, const char *src_ Cast ((unsigned char *) &p, (sizeof (p)-1), (const unsigned char *) w, _w_high); while ((j < HighDest) && ((*p) != ASCII_nul)) { - dest[j] = (*p); + const_cast(dest)[j] = (*p); j += 1; p += 1; } if (j < HighDest) { - dest[j] = ASCII_nul; + const_cast(dest)[j] = ASCII_nul; } j = StrLib_StrLen ((const char *) dest, _dest_high); i += 2; @@ -1031,7 +1028,7 @@ static void StringFormat1 (char *dest, unsigned int _dest_high, const char *src_ else if (src[i+1] == 'd') { /* avoid dangling else. */ - dest[j] = ASCII_nul; + const_cast(dest)[j] = ASCII_nul; Cast ((unsigned char *) &c, (sizeof (c)-1), (const unsigned char *) w, _w_high); NumberIO_CardToStr (c, 0, (char *) &str.array[0], MaxErrorString); StrLib_StrConCat ((const char *) dest, _dest_high, (const char *) &str.array[0], MaxErrorString, (char *) dest, _dest_high); @@ -1041,7 +1038,7 @@ static void StringFormat1 (char *dest, unsigned int _dest_high, const char *src_ else { /* avoid dangling else. */ - dest[j] = src[i]; + const_cast(dest)[j] = src[i]; i += 1; j += 1; } @@ -1055,14 +1052,14 @@ static void StringFormat1 (char *dest, unsigned int _dest_high, const char *src_ } else { - dest[j] = src[i]; + const_cast(dest)[j] = src[i]; i += 1; j += 1; } } if (j < HighDest) { - dest[j] = ASCII_nul; + const_cast(dest)[j] = ASCII_nul; } } @@ -1312,7 +1309,7 @@ static void PreInitialize (FIO_File f, const char *fname_, unsigned int _fname_h /* make a local copy of each unbounded array. */ memcpy (fname, fname_, _fname_high+1); - if ((InitializeFile (f, &fname, StrLib_StrLen ((const char *) fname, _fname_high), state, use, towrite, bufsize)) == f) + if ((InitializeFile (f, const_cast (static_cast(fname)), StrLib_StrLen ((const char *) fname, _fname_high), state, use, towrite, bufsize)) == f) { fd = static_cast (Indexing_GetIndice (FileInfo, f)); if (f == Error) @@ -1414,7 +1411,7 @@ extern "C" bool FIO_Exists (const char *fname_, unsigned int _fname_high) /* The following functions are wrappers for the above. */ - return FIO_exists (&fname, StrLib_StrLen ((const char *) fname, _fname_high)); + return FIO_exists (const_cast (static_cast(fname)), StrLib_StrLen ((const char *) fname, _fname_high)); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -1426,7 +1423,7 @@ extern "C" FIO_File FIO_OpenToRead (const char *fname_, unsigned int _fname_high /* make a local copy of each unbounded array. */ memcpy (fname, fname_, _fname_high+1); - return FIO_openToRead (&fname, StrLib_StrLen ((const char *) fname, _fname_high)); + return FIO_openToRead (const_cast (static_cast(fname)), StrLib_StrLen ((const char *) fname, _fname_high)); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -1438,7 +1435,7 @@ extern "C" FIO_File FIO_OpenToWrite (const char *fname_, unsigned int _fname_hig /* make a local copy of each unbounded array. */ memcpy (fname, fname_, _fname_high+1); - return FIO_openToWrite (&fname, StrLib_StrLen ((const char *) fname, _fname_high)); + return FIO_openToWrite (const_cast (static_cast(fname)), StrLib_StrLen ((const char *) fname, _fname_high)); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -1450,7 +1447,7 @@ extern "C" FIO_File FIO_OpenForRandom (const char *fname_, unsigned int _fname_h /* make a local copy of each unbounded array. */ memcpy (fname, fname_, _fname_high+1); - return FIO_openForRandom (&fname, StrLib_StrLen ((const char *) fname, _fname_high), towrite, newfile); + return FIO_openForRandom (const_cast (static_cast(fname)), StrLib_StrLen ((const char *) fname, _fname_high), towrite, newfile); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -1966,7 +1963,7 @@ extern "C" void FIO_WriteString (FIO_File f, const char *a_, unsigned int _a_hig memcpy (a, a_, _a_high+1); l = StrLib_StrLen ((const char *) a, _a_high); - if ((FIO_WriteNBytes (f, l, &a)) != l) + if ((FIO_WriteNBytes (f, l, const_cast (static_cast(a)))) != l) {} /* empty. */ } @@ -1993,12 +1990,12 @@ extern "C" void FIO_ReadString (FIO_File f, char *a, unsigned int _a_high) /* avoid gcc warning by using compound statement even if not strictly necessary. */ if (((ch == ASCII_nl) || (! (FIO_IsNoError (f)))) || (FIO_EOF (f))) { - a[i] = ASCII_nul; + const_cast(a)[i] = ASCII_nul; i += 1; } else { - a[i] = ch; + const_cast(a)[i] = ch; i += 1; } } @@ -2222,7 +2219,7 @@ extern "C" void FIO_GetFileName (FIO_File f, char *a, unsigned int _a_high) i = 0; while (((*p) != ASCII_nul) && (i <= _a_high)) { - a[i] = (*p); + const_cast(a)[i] = (*p); p += 1; i += 1; } @@ -2307,12 +2304,12 @@ extern "C" void FIO_FlushOutErr (void) } } -extern "C" void _M2_FIO_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_FIO_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { Init (); } -extern "C" void _M2_FIO_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_FIO_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { FIO_FlushOutErr (); } diff --git a/gcc/m2/mc-boot/GFormatStrings.cc b/gcc/m2/mc-boot/GFormatStrings.cc index 6966ac6c635b8..d3acec3bc6c2a 100644 --- a/gcc/m2/mc-boot/GFormatStrings.cc +++ b/gcc/m2/mc-boot/GFormatStrings.cc @@ -46,9 +46,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see # undef NULL # define NULL 0 #endif -#define _FormatStrings_H #define _FormatStrings_C +#include "GFormatStrings.h" # include "GDynamicStrings.h" # include "GStringConvert.h" # include "GSYSTEM.h" @@ -254,7 +254,7 @@ static void Cast (unsigned char *a, unsigned int _a_high, const unsigned char *b { for (i=0; i<=_a_high; i++) { - a[i] = b[i]; + const_cast(a)[i] = b[i]; } } else @@ -835,10 +835,10 @@ extern "C" DynamicStrings_String FormatStrings_HandleEscape (DynamicStrings_Stri __builtin_unreachable (); } -extern "C" void _M2_FormatStrings_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_FormatStrings_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_FormatStrings_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_FormatStrings_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GFpuIO.cc b/gcc/m2/mc-boot/GFpuIO.cc index 97d64254dae7a..09fd4fb95cdff 100644 --- a/gcc/m2/mc-boot/GFpuIO.cc +++ b/gcc/m2/mc-boot/GFpuIO.cc @@ -42,9 +42,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see # define FALSE (1==0) # endif -#define _FpuIO_H #define _FpuIO_C +#include "GFpuIO.h" # include "GStrIO.h" # include "GStrLib.h" # include "GASCII.h" @@ -328,10 +328,10 @@ extern "C" void FpuIO_LongIntToStr (long int x, unsigned int n, char *a, unsigne s = DynamicStrings_KillString (s); } -extern "C" void _M2_FpuIO_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_FpuIO_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_FpuIO_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_FpuIO_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GIO.cc b/gcc/m2/mc-boot/GIO.cc index 0699c4cb0d73e..4b76ed6bc80cd 100644 --- a/gcc/m2/mc-boot/GIO.cc +++ b/gcc/m2/mc-boot/GIO.cc @@ -42,9 +42,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see # define FALSE (1==0) # endif -#define _IO_H #define _IO_C +#include "GIO.h" # include "GStrLib.h" # include "GSYSTEM.h" # include "Glibc.h" @@ -177,7 +177,7 @@ static void doWrite (int fd, FIO_File f, char ch) r = static_cast (libc_write (FIO_GetUnixFileDescriptor (f), &ch, static_cast (1))); if (r == 1) { - return ; + return; } else if (r == -1) { @@ -186,7 +186,7 @@ static void doWrite (int fd, FIO_File f, char ch) if ((r != errno_EAGAIN) && (r != errno_EINTR)) { fdState.array[fd].IsEof = true; - return ; + return; } } } @@ -319,7 +319,7 @@ extern "C" void IO_Read (char *ch) r = static_cast (libc_read (FIO_GetUnixFileDescriptor (FIO_StdIn), ch, static_cast (1))); if (r == 1) { - return ; + return; } else if (r == -1) { @@ -329,7 +329,7 @@ extern "C" void IO_Read (char *ch) { fdState.array[0].IsEof = true; (*ch) = ASCII_eof; - return ; + return; } } } @@ -471,11 +471,11 @@ extern "C" void IO_EchoOff (int fd, bool input) term = termios_KillTermios (term); } -extern "C" void _M2_IO_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_IO_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { Init (); } -extern "C" void _M2_IO_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_IO_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GIndexing.cc b/gcc/m2/mc-boot/GIndexing.cc index 894b8cbea1fc0..3da42f68d716d 100644 --- a/gcc/m2/mc-boot/GIndexing.cc +++ b/gcc/m2/mc-boot/GIndexing.cc @@ -42,9 +42,9 @@ Boston, MA 02110-1301, USA. */ # undef NULL # define NULL 0 #endif -#define _Indexing_H #define _Indexing_C +#include "GIndexing.h" # include "Glibc.h" # include "GStorage.h" # include "GSYSTEM.h" @@ -58,15 +58,12 @@ typedef struct Indexing__T2_r Indexing__T2; typedef void * *Indexing_PtrToAddress; -typedef Indexing__T2 *Indexing_Index; +typedef Indexing__T2 *Indexing_Index__opaque; typedef unsigned char *Indexing_PtrToByte; -typedef void (*Indexing_IndexProcedure_t) (void *); -struct Indexing_IndexProcedure_p { Indexing_IndexProcedure_t proc; }; - struct Indexing__T2_r { - void *ArrayStart; + void * ArrayStart; unsigned int ArraySize; unsigned int Used; unsigned int Low; @@ -163,7 +160,7 @@ extern "C" void Indexing_ForeachIndiceInIndexDo (Indexing_Index i, Indexing_Inde extern "C" Indexing_Index Indexing_InitIndex (unsigned int low) { - Indexing_Index i; + Indexing_Index__opaque i; Storage_ALLOCATE ((void **) &i, sizeof (Indexing__T2)); i->Low = low; @@ -174,7 +171,7 @@ extern "C" Indexing_Index Indexing_InitIndex (unsigned int low) i->Debug = false; i->Used = 0; i->Map = (unsigned int) 0; - return i; + return static_cast (i); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -186,9 +183,9 @@ extern "C" Indexing_Index Indexing_InitIndex (unsigned int low) extern "C" Indexing_Index Indexing_KillIndex (Indexing_Index i) { - Storage_DEALLOCATE (&i->ArrayStart, i->ArraySize); + Storage_DEALLOCATE (&static_cast (i)->ArrayStart, static_cast (i)->ArraySize); Storage_DEALLOCATE ((void **) &i, sizeof (Indexing__T2)); - return NULL; + return static_cast (NULL); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -200,7 +197,7 @@ extern "C" Indexing_Index Indexing_KillIndex (Indexing_Index i) extern "C" Indexing_Index Indexing_DebugIndex (Indexing_Index i) { - i->Debug = true; + static_cast (i)->Debug = true; return i; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -221,7 +218,7 @@ extern "C" bool Indexing_InBounds (Indexing_Index i, unsigned int n) } else { - return (n >= i->Low) && (n <= i->High); + return (n >= static_cast (i)->Low) && (n <= static_cast (i)->High); } ReturnException ("../../gcc/m2/mc/Indexing.def", 20, 1); __builtin_unreachable (); @@ -241,7 +238,7 @@ extern "C" unsigned int Indexing_HighIndice (Indexing_Index i) } else { - return i->High; + return static_cast (i)->High; } ReturnException ("../../gcc/m2/mc/Indexing.def", 20, 1); __builtin_unreachable (); @@ -261,7 +258,7 @@ extern "C" unsigned int Indexing_LowIndice (Indexing_Index i) } else { - return i->Low; + return static_cast (i)->Low; } ReturnException ("../../gcc/m2/mc/Indexing.def", 20, 1); __builtin_unreachable (); @@ -283,19 +280,19 @@ extern "C" void Indexing_PutIndice (Indexing_Index i, unsigned int n, void * a) if (! (Indexing_InBounds (i, n))) { /* avoid gcc warning by using compound statement even if not strictly necessary. */ - if (n < i->Low) + if (n < static_cast (i)->Low) { M2RTS_HALT (-1); __builtin_unreachable (); } else { - oldSize = i->ArraySize; - while (((n-i->Low)*sizeof (void *)) >= i->ArraySize) + oldSize = static_cast (i)->ArraySize; + while (((n-static_cast (i)->Low)*sizeof (void *)) >= static_cast (i)->ArraySize) { - i->ArraySize = i->ArraySize*2; + static_cast (i)->ArraySize = static_cast (i)->ArraySize*2; } - if (oldSize != i->ArraySize) + if (oldSize != static_cast (i)->ArraySize) { /* IF Debug @@ -305,25 +302,25 @@ extern "C" void Indexing_PutIndice (Indexing_Index i, unsigned int n, void * a) oldSize, ArraySize) END ; */ - Storage_REALLOCATE (&i->ArrayStart, i->ArraySize); + Storage_REALLOCATE (&static_cast (i)->ArrayStart, static_cast (i)->ArraySize); /* and initialize the remainder of the array to NIL */ - b = i->ArrayStart; + b = static_cast (i)->ArrayStart; b = reinterpret_cast (reinterpret_cast (b)+oldSize); - b = libc_memset (b, 0, static_cast (i->ArraySize-oldSize)); + b = libc_memset (b, 0, static_cast (static_cast (i)->ArraySize-oldSize)); } - i->High = n; + static_cast (i)->High = n; } } - b = i->ArrayStart; - b = reinterpret_cast (reinterpret_cast (b)+(n-i->Low)*sizeof (void *)); + b = static_cast (i)->ArrayStart; + b = reinterpret_cast (reinterpret_cast (b)+(n-static_cast (i)->Low)*sizeof (void *)); p = static_cast (b); - (*p) = reinterpret_cast (a); - i->Used += 1; - if (i->Debug) + (*p) = static_cast (a); + static_cast (i)->Used += 1; + if (static_cast (i)->Debug) { if (n < 32) { - i->Map |= (1 << (n )); + static_cast (i)->Map |= (1 << (n )); } } } @@ -343,12 +340,12 @@ extern "C" void * Indexing_GetIndice (Indexing_Index i, unsigned int n) M2RTS_HALT (-1); __builtin_unreachable (); } - b = static_cast (i->ArrayStart); - b += (n-i->Low)*sizeof (void *); + b = static_cast (static_cast (i)->ArrayStart); + b += (n-static_cast (i)->Low)*sizeof (void *); p = (Indexing_PtrToAddress) (b); - if (i->Debug) + if (static_cast (i)->Debug) { - if (((n < 32) && (! ((((1 << (n)) & (i->Map)) != 0)))) && ((*p) != NULL)) + if (((n < 32) && (! ((((1 << (n)) & (static_cast (i)->Map)) != 0)))) && ((*p) != NULL)) { M2RTS_HALT (-1); __builtin_unreachable (); @@ -370,9 +367,9 @@ extern "C" bool Indexing_IsIndiceInIndex (Indexing_Index i, void * a) Indexing_PtrToByte b; Indexing_PtrToAddress p; - j = i->Low; - b = static_cast (i->ArrayStart); - while (j <= i->High) + j = static_cast (i)->Low; + b = static_cast (static_cast (i)->ArrayStart); + while (j <= static_cast (i)->High) { p = (Indexing_PtrToAddress) (b); if ((*p) == a) @@ -400,9 +397,9 @@ extern "C" void Indexing_RemoveIndiceFromIndex (Indexing_Index i, void * a) Indexing_PtrToAddress p; Indexing_PtrToByte b; - j = i->Low; - b = static_cast (i->ArrayStart); - while (j <= i->High) + j = static_cast (i)->Low; + b = static_cast (static_cast (i)->ArrayStart); + while (j <= static_cast (i)->High) { p = (Indexing_PtrToAddress) (b); b += sizeof (void *); @@ -426,13 +423,13 @@ extern "C" void Indexing_DeleteIndice (Indexing_Index i, unsigned int j) if (Indexing_InBounds (i, j)) { - b = static_cast (i->ArrayStart); - b += sizeof (void *)*(j-i->Low); + b = static_cast (static_cast (i)->ArrayStart); + b += sizeof (void *)*(j-static_cast (i)->Low); p = (Indexing_PtrToAddress) (b); b += sizeof (void *); - p = static_cast (libc_memmove (reinterpret_cast (p), reinterpret_cast (b), static_cast ((i->High-j)*sizeof (void *)))); - i->High -= 1; - i->Used -= 1; + p = static_cast (libc_memmove (reinterpret_cast (p), reinterpret_cast (b), static_cast ((static_cast (i)->High-j)*sizeof (void *)))); + static_cast (i)->High -= 1; + static_cast (i)->Used -= 1; } else { @@ -452,7 +449,7 @@ extern "C" void Indexing_IncludeIndiceIntoIndex (Indexing_Index i, void * a) if (! (Indexing_IsIndiceInIndex (i, a))) { /* avoid gcc warning by using compound statement even if not strictly necessary. */ - if (i->Used == 0) + if (static_cast (i)->Used == 0) { Indexing_PutIndice (i, Indexing_LowIndice (i), a); } @@ -483,10 +480,10 @@ extern "C" void Indexing_ForeachIndiceInIndexDo (Indexing_Index i, Indexing_Inde } } -extern "C" void _M2_Indexing_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_Indexing_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_Indexing_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_Indexing_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GM2Dependent.cc b/gcc/m2/mc-boot/GM2Dependent.cc index bf0daab4563d7..25b47b35e2177 100644 --- a/gcc/m2/mc-boot/GM2Dependent.cc +++ b/gcc/m2/mc-boot/GM2Dependent.cc @@ -47,9 +47,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see # undef NULL # define NULL 0 #endif -#define _M2Dependent_H #define _M2Dependent_C +#include "GM2Dependent.h" # include "Glibc.h" # include "GASCII.h" # include "GSYSTEM.h" @@ -76,9 +76,6 @@ typedef struct M2Dependent__T4_a M2Dependent__T4; typedef enum {M2Dependent_unregistered, M2Dependent_unordered, M2Dependent_started, M2Dependent_ordered, M2Dependent_user} M2Dependent_DependencyState; -typedef void (*M2Dependent_ArgCVEnvP_t) (int, void *, void *); -struct M2Dependent_ArgCVEnvP_p { M2Dependent_ArgCVEnvP_t proc; }; - struct M2Dependent_DependencyList_r { PROC proc; bool forced; @@ -100,8 +97,8 @@ struct M2Dependent__T3_r { struct M2Dependent__T4_a { M2Dependent_ModuleChain array[M2Dependent_user-M2Dependent_unregistered+1]; }; struct M2Dependent__T2_r { - void *name; - void *libname; + void * name; + void * libname; M2Dependent_ArgCVEnvP init; M2Dependent_ArgCVEnvP fini; M2Dependent_DependencyList dependency; @@ -638,11 +635,11 @@ static void toCString (char *str, unsigned int _str_high) { if (str[i+1] == 'n') { - str[i] = ASCII_nl; + const_cast(str)[i] = ASCII_nl; j = i+1; while (j < high) { - str[j] = str[j+1]; + const_cast(str)[j] = str[j+1]; j += 1; } } @@ -962,7 +959,7 @@ static void DisplayModuleInfo (M2Dependent_DependencyState state, const char *de if (Modules.array[state-M2Dependent_unregistered] != NULL) { - libc_printf ((const char *) "%s modules\\n", 12, &desc); + libc_printf ((const char *) "%s modules\\n", 12, const_cast (static_cast(desc))); mptr = Modules.array[state-M2Dependent_unregistered]; count = 0; do { @@ -1211,7 +1208,7 @@ static bool equal (void * cstr, const char *str_, unsigned int _str_high) /* make a local copy of each unbounded array. */ memcpy (str, str_, _str_high+1); - return (strncmp (reinterpret_cast (cstr), reinterpret_cast (&str), StrLib_StrLen ((const char *) str, _str_high))) == 0; + return (strncmp (reinterpret_cast (cstr), reinterpret_cast (const_cast (static_cast(str))), StrLib_StrLen ((const char *) str, _str_high))) == 0; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -1249,7 +1246,7 @@ static void SetupDebugFlags (void) ForceTrace = false; HexTrace = false; WarningTrace = false; - pc = static_cast (libc_getenv (const_cast (reinterpret_cast("GCC_M2LINK_RTFLAG")))); + pc = static_cast (libc_getenv (const_cast (static_cast("GCC_M2LINK_RTFLAG")))); while ((pc != NULL) && ((*pc) != ASCII_nul)) { if (equal (reinterpret_cast (pc), (const char *) "all", 3)) @@ -1586,11 +1583,11 @@ extern "C" void M2Dependent_ExecuteTerminationProcedures (void) ExecuteReverse (TerminateProc.tail); } -extern "C" void _M2_M2Dependent_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_M2Dependent_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { CheckInitialized (); } -extern "C" void _M2_M2Dependent_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_M2Dependent_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GM2EXCEPTION.cc b/gcc/m2/mc-boot/GM2EXCEPTION.cc index 2e268317765ff..97417cf6c82ae 100644 --- a/gcc/m2/mc-boot/GM2EXCEPTION.cc +++ b/gcc/m2/mc-boot/GM2EXCEPTION.cc @@ -35,14 +35,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see # endif # include "Gmcrts.h" -#define _M2EXCEPTION_H #define _M2EXCEPTION_C +#include "GM2EXCEPTION.h" # include "GSYSTEM.h" # include "GRTExceptions.h" -typedef enum {M2EXCEPTION_indexException, M2EXCEPTION_rangeException, M2EXCEPTION_caseSelectException, M2EXCEPTION_invalidLocation, M2EXCEPTION_functionException, M2EXCEPTION_wholeValueException, M2EXCEPTION_wholeDivException, M2EXCEPTION_realValueException, M2EXCEPTION_realDivException, M2EXCEPTION_complexValueException, M2EXCEPTION_complexDivException, M2EXCEPTION_protException, M2EXCEPTION_sysException, M2EXCEPTION_coException, M2EXCEPTION_exException} M2EXCEPTION_M2Exceptions; - extern "C" M2EXCEPTION_M2Exceptions M2EXCEPTION_M2Exception (void); extern "C" bool M2EXCEPTION_IsM2Exception (void); @@ -58,7 +56,7 @@ extern "C" M2EXCEPTION_M2Exceptions M2EXCEPTION_M2Exception (void) n = RTExceptions_GetNumber (e); if (n == (UINT_MAX)) { - RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_exException)), const_cast (reinterpret_cast("../../gcc/m2/gm2-libs/M2EXCEPTION.mod")), 47, 6, const_cast (reinterpret_cast("M2Exception")), const_cast (reinterpret_cast("current coroutine is not in the exceptional execution state"))); + RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_exException)), const_cast (static_cast("../../gcc/m2/gm2-libs/M2EXCEPTION.mod")), 47, 6, const_cast (static_cast("M2Exception")), const_cast (static_cast("current coroutine is not in the exceptional execution state"))); } else { @@ -80,11 +78,11 @@ extern "C" bool M2EXCEPTION_IsM2Exception (void) __builtin_unreachable (); } -extern "C" void _M2_M2EXCEPTION_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_M2EXCEPTION_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { RTExceptions_SetExceptionBlock (RTExceptions_InitExceptionBlock ()); } -extern "C" void _M2_M2EXCEPTION_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_M2EXCEPTION_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GM2RTS.cc b/gcc/m2/mc-boot/GM2RTS.cc index d529a7880077a..ef5f7cf5ce1ed 100644 --- a/gcc/m2/mc-boot/GM2RTS.cc +++ b/gcc/m2/mc-boot/GM2RTS.cc @@ -42,9 +42,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see # define FALSE (1==0) # endif -#define _M2RTS_H #define _M2RTS_C +#include "GM2RTS.h" # include "Glibc.h" # include "GNumberIO.h" # include "GStrLib.h" @@ -60,9 +60,6 @@ typedef struct M2RTS_ArgCVEnvP_p M2RTS_ArgCVEnvP; # define stderrFd 2 typedef char *M2RTS_PtrToChar; -typedef void (*M2RTS_ArgCVEnvP_t) (int, void *, void *); -struct M2RTS_ArgCVEnvP_p { M2RTS_ArgCVEnvP_t proc; }; - static int ExitValue; static bool isHalting; static bool CallExit; @@ -257,7 +254,7 @@ static void ErrorString (const char *a_, unsigned int _a_high) /* make a local copy of each unbounded array. */ memcpy (a, a_, _a_high+1); - n = static_cast (libc_write (stderrFd, &a, static_cast (StrLib_StrLen ((const char *) a, _a_high)))); + n = static_cast (libc_write (stderrFd, const_cast (static_cast(a)), static_cast (StrLib_StrLen ((const char *) a, _a_high)))); } @@ -712,11 +709,11 @@ extern "C" void M2RTS_NoException (void * filename, unsigned int line, unsigned RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_exException)), filename, line, column, scope, message); } -extern "C" void _M2_M2RTS_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_M2RTS_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { CheckInitialized (); } -extern "C" void _M2_M2RTS_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_M2RTS_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GMemUtils.cc b/gcc/m2/mc-boot/GMemUtils.cc index 19b5b42f85ead..1d9feed27d605 100644 --- a/gcc/m2/mc-boot/GMemUtils.cc +++ b/gcc/m2/mc-boot/GMemUtils.cc @@ -34,9 +34,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see typedef struct { PROC_t proc; } PROC; # endif -#define _MemUtils_H #define _MemUtils_C +#include "GMemUtils.h" # include "GSYSTEM.h" @@ -118,10 +118,10 @@ extern "C" void MemUtils_MemZero (void * a, unsigned int length) } } -extern "C" void _M2_MemUtils_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_MemUtils_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_MemUtils_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_MemUtils_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GNumberIO.cc b/gcc/m2/mc-boot/GNumberIO.cc index 366d30e121b0f..75720dd85e6e3 100644 --- a/gcc/m2/mc-boot/GNumberIO.cc +++ b/gcc/m2/mc-boot/GNumberIO.cc @@ -42,9 +42,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see # define FALSE (1==0) # endif -#define _NumberIO_H #define _NumberIO_C +#include "GNumberIO.h" # include "GASCII.h" # include "GStrIO.h" # include "GStrLib.h" @@ -172,19 +172,19 @@ extern "C" void NumberIO_CardToStr (unsigned int x, unsigned int n, char *a, uns Higha = _a_high; while ((n > i) && (j <= Higha)) { - a[j] = ' '; + const_cast(a)[j] = ' '; j += 1; n -= 1; } while ((i > 0) && (j <= Higha)) { - a[j] = ((char) (buf.array[i-1]+ ((unsigned int) ('0')))); + const_cast(a)[j] = ((char) (buf.array[i-1]+ ((unsigned int) ('0')))); j += 1; i -= 1; } if (j <= Higha) { - a[j] = ASCII_nul; + const_cast(a)[j] = ASCII_nul; } } @@ -270,7 +270,7 @@ extern "C" void NumberIO_HexToStr (unsigned int x, unsigned int n, char *a, unsi Higha = _a_high; while ((n > i) && (j <= Higha)) { - a[j] = '0'; + const_cast(a)[j] = '0'; j += 1; n -= 1; } @@ -278,18 +278,18 @@ extern "C" void NumberIO_HexToStr (unsigned int x, unsigned int n, char *a, unsi { if (buf.array[i-1] < 10) { - a[j] = ((char) (buf.array[i-1]+ ((unsigned int) ('0')))); + const_cast(a)[j] = ((char) (buf.array[i-1]+ ((unsigned int) ('0')))); } else { - a[j] = ((char) ((buf.array[i-1]+ ((unsigned int) ('A')))-10)); + const_cast(a)[j] = ((char) ((buf.array[i-1]+ ((unsigned int) ('A')))-10)); } j += 1; i -= 1; } if (j <= Higha) { - a[j] = ASCII_nul; + const_cast(a)[j] = ASCII_nul; } } @@ -349,24 +349,24 @@ extern "C" void NumberIO_IntToStr (int x, unsigned int n, char *a, unsigned int Higha = _a_high; while ((n > i) && (j <= Higha)) { - a[j] = ' '; + const_cast(a)[j] = ' '; j += 1; n -= 1; } if (Negative) { - a[j] = '-'; + const_cast(a)[j] = '-'; j += 1; } while ((i != 0) && (j <= Higha)) { - a[j] = ((char) (buf.array[i-1]+ ((unsigned int) ('0')))); + const_cast(a)[j] = ((char) (buf.array[i-1]+ ((unsigned int) ('0')))); j += 1; i -= 1; } if (j <= Higha) { - a[j] = ASCII_nul; + const_cast(a)[j] = ASCII_nul; } } @@ -490,19 +490,19 @@ extern "C" void NumberIO_OctToStr (unsigned int x, unsigned int n, char *a, unsi Higha = _a_high; while ((n > i) && (j <= Higha)) { - a[j] = ' '; + const_cast(a)[j] = ' '; j += 1; n -= 1; } while ((i > 0) && (j <= Higha)) { - a[j] = ((char) (buf.array[i-1]+ ((unsigned int) ('0')))); + const_cast(a)[j] = ((char) (buf.array[i-1]+ ((unsigned int) ('0')))); j += 1; i -= 1; } if (j <= Higha) { - a[j] = ASCII_nul; + const_cast(a)[j] = ASCII_nul; } } @@ -567,19 +567,19 @@ extern "C" void NumberIO_BinToStr (unsigned int x, unsigned int n, char *a, unsi Higha = _a_high; while ((n > i) && (j <= Higha)) { - a[j] = ' '; + const_cast(a)[j] = ' '; j += 1; n -= 1; } while ((i > 0) && (j <= Higha)) { - a[j] = ((char) (buf.array[i-1]+ ((unsigned int) ('0')))); + const_cast(a)[j] = ((char) (buf.array[i-1]+ ((unsigned int) ('0')))); j += 1; i -= 1; } if (j <= Higha) { - a[j] = ASCII_nul; + const_cast(a)[j] = ASCII_nul; } } @@ -768,10 +768,10 @@ extern "C" void NumberIO_StrToOctInt (const char *a_, unsigned int _a_high, int } } -extern "C" void _M2_NumberIO_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_NumberIO_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_NumberIO_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_NumberIO_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GPushBackInput.cc b/gcc/m2/mc-boot/GPushBackInput.cc index 4e0b41e491ed5..9bc2a83abd452 100644 --- a/gcc/m2/mc-boot/GPushBackInput.cc +++ b/gcc/m2/mc-boot/GPushBackInput.cc @@ -42,9 +42,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see # undef NULL # define NULL 0 #endif -#define _PushBackInput_H #define _PushBackInput_C +#include "GPushBackInput.h" # include "GFIO.h" # include "GDynamicStrings.h" # include "GASCII.h" @@ -478,12 +478,12 @@ extern "C" unsigned int PushBackInput_GetCurrentLine (void) __builtin_unreachable (); } -extern "C" void _M2_PushBackInput_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_PushBackInput_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { PushBackInput_SetDebug (false); Init (); } -extern "C" void _M2_PushBackInput_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_PushBackInput_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GRTExceptions.cc b/gcc/m2/mc-boot/GRTExceptions.cc index e7b35cfeed8a3..a0eff3ecc8af6 100644 --- a/gcc/m2/mc-boot/GRTExceptions.cc +++ b/gcc/m2/mc-boot/GRTExceptions.cc @@ -47,9 +47,9 @@ extern void throw (unsigned int); # undef NULL # define NULL 0 #endif -#define _RTExceptions_H #define _RTExceptions_C +#include "GRTExceptions.h" # include "GASCII.h" # include "GStrLib.h" # include "GStorage.h" @@ -72,17 +72,14 @@ typedef struct RTExceptions__T3_r RTExceptions__T3; typedef RTExceptions__T3 *RTExceptions_Handler; -typedef RTExceptions__T1 *RTExceptions_EHBlock; - -typedef void (*RTExceptions_ProcedureHandler_t) (void); -struct RTExceptions_ProcedureHandler_p { RTExceptions_ProcedureHandler_t proc; }; +typedef RTExceptions__T1 *RTExceptions_EHBlock__opaque; struct RTExceptions__T2_a { char array[MaxBuffer+1]; }; struct RTExceptions__T1_r { RTExceptions__T2 buffer; unsigned int number; RTExceptions_Handler handlers; - RTExceptions_EHBlock right; + RTExceptions_EHBlock__opaque right; }; struct RTExceptions__T3_r { @@ -95,8 +92,8 @@ struct RTExceptions__T3_r { static bool inException; static RTExceptions_Handler freeHandler; -static RTExceptions_EHBlock freeEHB; -static RTExceptions_EHBlock currentEHB; +static RTExceptions_EHBlock__opaque freeEHB; +static RTExceptions_EHBlock__opaque currentEHB; static void * currentSource; /* @@ -233,7 +230,7 @@ static void ErrorString (const char *a_, unsigned int _a_high); findHandler - */ -static RTExceptions_Handler findHandler (RTExceptions_EHBlock e, unsigned int number); +static RTExceptions_Handler findHandler (RTExceptions_EHBlock__opaque e, unsigned int number); /* InvokeHandler - invokes the associated handler for the current @@ -286,7 +283,7 @@ static void addNum (unsigned int n, unsigned int *i); New - returns a new EHBlock. */ -static RTExceptions_EHBlock New (void); +static RTExceptions_EHBlock__opaque New (void); /* NewHandler - returns a new handler. @@ -322,7 +319,7 @@ static void SubHandler (RTExceptions_Handler h); AddHandler - add, e, to the end of the list of handlers. */ -static void AddHandler (RTExceptions_EHBlock e, RTExceptions_Handler h); +static void AddHandler (RTExceptions_EHBlock__opaque e, RTExceptions_Handler h); /* indexf - raise an index out of bounds exception. @@ -439,7 +436,7 @@ static void ErrorString (const char *a_, unsigned int _a_high) /* make a local copy of each unbounded array. */ memcpy (a, a_, _a_high+1); - n = static_cast (libc_write (2, &a, static_cast (StrLib_StrLen ((const char *) a, _a_high)))); + n = static_cast (libc_write (2, const_cast (static_cast(a)), static_cast (StrLib_StrLen ((const char *) a, _a_high)))); } @@ -447,7 +444,7 @@ static void ErrorString (const char *a_, unsigned int _a_high) findHandler - */ -static RTExceptions_Handler findHandler (RTExceptions_EHBlock e, unsigned int number) +static RTExceptions_Handler findHandler (RTExceptions_EHBlock__opaque e, unsigned int number) { RTExceptions_Handler h; @@ -540,7 +537,7 @@ static void * stripPath (void * s) p += 1; } } - return reinterpret_cast (f); + return static_cast (f); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -605,9 +602,9 @@ static void addNum (unsigned int n, unsigned int *i) New - returns a new EHBlock. */ -static RTExceptions_EHBlock New (void) +static RTExceptions_EHBlock__opaque New (void) { - RTExceptions_EHBlock e; + RTExceptions_EHBlock__opaque e; if (freeEHB == NULL) { @@ -707,7 +704,7 @@ static void SubHandler (RTExceptions_Handler h) AddHandler - add, e, to the end of the list of handlers. */ -static void AddHandler (RTExceptions_EHBlock e, RTExceptions_Handler h) +static void AddHandler (RTExceptions_EHBlock__opaque e, RTExceptions_Handler h) { h->right = e->handlers; h->left = e->handlers->left; @@ -722,7 +719,7 @@ static void AddHandler (RTExceptions_EHBlock e, RTExceptions_Handler h) static void indexf (void * a) { - RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_indexException)), const_cast (reinterpret_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 614, 9, const_cast (reinterpret_cast("indexf")), const_cast (reinterpret_cast("array index out of bounds"))); + RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_indexException)), const_cast (static_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 614, 9, const_cast (static_cast("indexf")), const_cast (static_cast("array index out of bounds"))); } @@ -732,7 +729,7 @@ static void indexf (void * a) static void range (void * a) { - RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_rangeException)), const_cast (reinterpret_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 626, 9, const_cast (reinterpret_cast("range")), const_cast (reinterpret_cast("assignment out of range"))); + RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_rangeException)), const_cast (static_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 626, 9, const_cast (static_cast("range")), const_cast (static_cast("assignment out of range"))); } @@ -742,7 +739,7 @@ static void range (void * a) static void casef (void * a) { - RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_caseSelectException)), const_cast (reinterpret_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 638, 9, const_cast (reinterpret_cast("casef")), const_cast (reinterpret_cast("case selector out of range"))); + RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_caseSelectException)), const_cast (static_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 638, 9, const_cast (static_cast("casef")), const_cast (static_cast("case selector out of range"))); } @@ -752,7 +749,7 @@ static void casef (void * a) static void invalidloc (void * a) { - RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_invalidLocation)), const_cast (reinterpret_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 650, 9, const_cast (reinterpret_cast("invalidloc")), const_cast (reinterpret_cast("invalid address referenced"))); + RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_invalidLocation)), const_cast (static_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 650, 9, const_cast (static_cast("invalidloc")), const_cast (static_cast("invalid address referenced"))); } @@ -762,7 +759,7 @@ static void invalidloc (void * a) static void function (void * a) { - RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_functionException)), const_cast (reinterpret_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 662, 9, const_cast (reinterpret_cast("function")), const_cast (reinterpret_cast("... function ... "))); /* --fixme-- what has happened ? */ + RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_functionException)), const_cast (static_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 662, 9, const_cast (static_cast("function")), const_cast (static_cast("... function ... "))); /* --fixme-- what has happened ? */ } @@ -772,7 +769,7 @@ static void function (void * a) static void wholevalue (void * a) { - RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_wholeValueException)), const_cast (reinterpret_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 674, 9, const_cast (reinterpret_cast("wholevalue")), const_cast (reinterpret_cast("illegal whole value exception"))); + RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_wholeValueException)), const_cast (static_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 674, 9, const_cast (static_cast("wholevalue")), const_cast (static_cast("illegal whole value exception"))); } @@ -782,7 +779,7 @@ static void wholevalue (void * a) static void wholediv (void * a) { - RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_wholeDivException)), const_cast (reinterpret_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 686, 9, const_cast (reinterpret_cast("wholediv")), const_cast (reinterpret_cast("illegal whole value exception"))); + RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_wholeDivException)), const_cast (static_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 686, 9, const_cast (static_cast("wholediv")), const_cast (static_cast("illegal whole value exception"))); } @@ -792,7 +789,7 @@ static void wholediv (void * a) static void realvalue (void * a) { - RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_realValueException)), const_cast (reinterpret_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 698, 9, const_cast (reinterpret_cast("realvalue")), const_cast (reinterpret_cast("illegal real value exception"))); + RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_realValueException)), const_cast (static_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 698, 9, const_cast (static_cast("realvalue")), const_cast (static_cast("illegal real value exception"))); } @@ -802,7 +799,7 @@ static void realvalue (void * a) static void realdiv (void * a) { - RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_realDivException)), const_cast (reinterpret_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 710, 9, const_cast (reinterpret_cast("realdiv")), const_cast (reinterpret_cast("real number division by zero exception"))); + RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_realDivException)), const_cast (static_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 710, 9, const_cast (static_cast("realdiv")), const_cast (static_cast("real number division by zero exception"))); } @@ -812,7 +809,7 @@ static void realdiv (void * a) static void complexvalue (void * a) { - RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_complexValueException)), const_cast (reinterpret_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 722, 9, const_cast (reinterpret_cast("complexvalue")), const_cast (reinterpret_cast("illegal complex value exception"))); + RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_complexValueException)), const_cast (static_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 722, 9, const_cast (static_cast("complexvalue")), const_cast (static_cast("illegal complex value exception"))); } @@ -822,7 +819,7 @@ static void complexvalue (void * a) static void complexdiv (void * a) { - RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_complexDivException)), const_cast (reinterpret_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 734, 9, const_cast (reinterpret_cast("complexdiv")), const_cast (reinterpret_cast("complex number division by zero exception"))); + RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_complexDivException)), const_cast (static_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 734, 9, const_cast (static_cast("complexdiv")), const_cast (static_cast("complex number division by zero exception"))); } @@ -832,7 +829,7 @@ static void complexdiv (void * a) static void protection (void * a) { - RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_protException)), const_cast (reinterpret_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 746, 9, const_cast (reinterpret_cast("protection")), const_cast (reinterpret_cast("protection exception"))); + RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_protException)), const_cast (static_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 746, 9, const_cast (static_cast("protection")), const_cast (static_cast("protection exception"))); } @@ -842,7 +839,7 @@ static void protection (void * a) static void systemf (void * a) { - RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_sysException)), const_cast (reinterpret_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 758, 9, const_cast (reinterpret_cast("systemf")), const_cast (reinterpret_cast("system exception"))); + RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_sysException)), const_cast (static_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 758, 9, const_cast (static_cast("systemf")), const_cast (static_cast("system exception"))); } @@ -852,7 +849,7 @@ static void systemf (void * a) static void coroutine (void * a) { - RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_coException)), const_cast (reinterpret_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 770, 9, const_cast (reinterpret_cast("coroutine")), const_cast (reinterpret_cast("coroutine exception"))); + RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_coException)), const_cast (static_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 770, 9, const_cast (static_cast("coroutine")), const_cast (static_cast("coroutine exception"))); } @@ -862,7 +859,7 @@ static void coroutine (void * a) static void exception (void * a) { - RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_exException)), const_cast (reinterpret_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 782, 9, const_cast (reinterpret_cast("exception")), const_cast (reinterpret_cast("exception exception"))); + RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_exException)), const_cast (static_cast("../../gcc/m2/gm2-libs/RTExceptions.mod")), 782, 9, const_cast (static_cast("exception")), const_cast (static_cast("exception exception"))); } @@ -874,8 +871,8 @@ static void Init (void) { inException = false; freeHandler = NULL; - freeEHB = NULL; - currentEHB = RTExceptions_InitExceptionBlock (); + freeEHB = static_cast (NULL); + currentEHB = static_cast (RTExceptions_InitExceptionBlock ()); currentSource = NULL; RTExceptions_BaseExceptionsThrow (); SysExceptions_InitExceptionHandlers ((SysExceptions_PROCEXCEPTION) {(SysExceptions_PROCEXCEPTION_t) indexf}, (SysExceptions_PROCEXCEPTION) {(SysExceptions_PROCEXCEPTION_t) range}, (SysExceptions_PROCEXCEPTION) {(SysExceptions_PROCEXCEPTION_t) casef}, (SysExceptions_PROCEXCEPTION) {(SysExceptions_PROCEXCEPTION_t) invalidloc}, (SysExceptions_PROCEXCEPTION) {(SysExceptions_PROCEXCEPTION_t) function}, (SysExceptions_PROCEXCEPTION) {(SysExceptions_PROCEXCEPTION_t) wholevalue}, (SysExceptions_PROCEXCEPTION) {(SysExceptions_PROCEXCEPTION_t) wholediv}, (SysExceptions_PROCEXCEPTION) {(SysExceptions_PROCEXCEPTION_t) realvalue}, (SysExceptions_PROCEXCEPTION) {(SysExceptions_PROCEXCEPTION_t) realdiv}, (SysExceptions_PROCEXCEPTION) {(SysExceptions_PROCEXCEPTION_t) complexvalue}, (SysExceptions_PROCEXCEPTION) {(SysExceptions_PROCEXCEPTION_t) complexdiv}, (SysExceptions_PROCEXCEPTION) {(SysExceptions_PROCEXCEPTION_t) protection}, (SysExceptions_PROCEXCEPTION) {(SysExceptions_PROCEXCEPTION_t) systemf}, (SysExceptions_PROCEXCEPTION) {(SysExceptions_PROCEXCEPTION_t) coroutine}, (SysExceptions_PROCEXCEPTION) {(SysExceptions_PROCEXCEPTION_t) exception}); @@ -889,11 +886,11 @@ static void Init (void) static void TidyUp (void) { RTExceptions_Handler f; - RTExceptions_EHBlock e; + RTExceptions_EHBlock__opaque e; if (currentEHB != NULL) { - currentEHB = RTExceptions_KillExceptionBlock (currentEHB); + currentEHB = static_cast (RTExceptions_KillExceptionBlock (static_cast (currentEHB))); } while (freeHandler != NULL) { @@ -953,7 +950,7 @@ extern "C" void RTExceptions_Raise (unsigned int number, void * file, unsigned i extern "C" void RTExceptions_SetExceptionBlock (RTExceptions_EHBlock source) { - currentEHB = source; + currentEHB = static_cast (source); } @@ -963,7 +960,7 @@ extern "C" void RTExceptions_SetExceptionBlock (RTExceptions_EHBlock source) extern "C" RTExceptions_EHBlock RTExceptions_GetExceptionBlock (void) { - return currentEHB; + return static_cast (currentEHB); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -975,7 +972,7 @@ extern "C" RTExceptions_EHBlock RTExceptions_GetExceptionBlock (void) extern "C" void * RTExceptions_GetTextBuffer (RTExceptions_EHBlock e) { - return &e->buffer; + return &static_cast (e)->buffer; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -987,7 +984,7 @@ extern "C" void * RTExceptions_GetTextBuffer (RTExceptions_EHBlock e) extern "C" unsigned int RTExceptions_GetTextBufferSize (RTExceptions_EHBlock e) { - return sizeof (e->buffer); + return sizeof (static_cast (e)->buffer); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -1000,7 +997,7 @@ extern "C" unsigned int RTExceptions_GetTextBufferSize (RTExceptions_EHBlock e) extern "C" unsigned int RTExceptions_GetNumber (RTExceptions_EHBlock source) { - return source->number; + return static_cast (source)->number; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -1012,7 +1009,7 @@ extern "C" unsigned int RTExceptions_GetNumber (RTExceptions_EHBlock source) extern "C" RTExceptions_EHBlock RTExceptions_InitExceptionBlock (void) { - RTExceptions_EHBlock e; + RTExceptions_EHBlock__opaque e; e = New (); e->number = UINT_MAX; @@ -1020,7 +1017,7 @@ extern "C" RTExceptions_EHBlock RTExceptions_InitExceptionBlock (void) e->handlers->right = e->handlers; /* add the dummy onto the head */ e->handlers->left = e->handlers; e->right = e; - return e; + return static_cast (e); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -1032,10 +1029,10 @@ extern "C" RTExceptions_EHBlock RTExceptions_InitExceptionBlock (void) extern "C" RTExceptions_EHBlock RTExceptions_KillExceptionBlock (RTExceptions_EHBlock e) { - e->handlers = KillHandlers (e->handlers); - e->right = freeEHB; - freeEHB = e; - return NULL; + static_cast (e)->handlers = KillHandlers (static_cast (e)->handlers); + static_cast (e)->right = freeEHB; + freeEHB = static_cast (e); + return static_cast (NULL); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -1050,7 +1047,7 @@ extern "C" void RTExceptions_PushHandler (RTExceptions_EHBlock e, unsigned int n RTExceptions_Handler h; RTExceptions_Handler i; - h = findHandler (e, number); + h = findHandler (static_cast (e), number); if (h == NULL) { i = InitHandler (NewHandler (), NULL, NULL, NULL, number, p); @@ -1063,7 +1060,7 @@ extern "C" void RTExceptions_PushHandler (RTExceptions_EHBlock e, unsigned int n i = InitHandler (NewHandler (), NULL, NULL, h, number, p); } /* add new handler */ - AddHandler (e, i); + AddHandler (static_cast (e), i); } @@ -1076,14 +1073,14 @@ extern "C" void RTExceptions_PopHandler (RTExceptions_EHBlock e, unsigned int nu { RTExceptions_Handler h; - h = findHandler (e, number); + h = findHandler (static_cast (e), number); if (h != NULL) { /* remove, h, */ SubHandler (h); if (h->stack != NULL) { - AddHandler (e, h->stack); + AddHandler (static_cast (e), h->stack); } h = KillHandler (h); } @@ -1098,11 +1095,11 @@ extern "C" void RTExceptions_PopHandler (RTExceptions_EHBlock e, unsigned int nu extern "C" void RTExceptions_DefaultErrorCatch (void) { - RTExceptions_EHBlock e; + RTExceptions_EHBlock__opaque e; int n; - e = RTExceptions_GetExceptionBlock (); - n = static_cast (libc_write (2, RTExceptions_GetTextBuffer (e), libc_strlen (RTExceptions_GetTextBuffer (e)))); + e = static_cast (RTExceptions_GetExceptionBlock ()); + n = static_cast (libc_write (2, RTExceptions_GetTextBuffer (static_cast (e)), libc_strlen (RTExceptions_GetTextBuffer (static_cast (e))))); M2RTS_HALT (-1); __builtin_unreachable (); } @@ -1184,7 +1181,7 @@ extern "C" RTExceptions_EHBlock RTExceptions_GetBaseExceptionBlock (void) } else { - return currentEHB; + return static_cast (currentEHB); } ReturnException ("../../gcc/m2/gm2-libs/RTExceptions.def", 25, 1); __builtin_unreachable (); @@ -1212,12 +1209,12 @@ extern "C" void * RTExceptions_GetExceptionSource (void) __builtin_unreachable (); } -extern "C" void _M2_RTExceptions_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_RTExceptions_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { Init (); } -extern "C" void _M2_RTExceptions_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_RTExceptions_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { TidyUp (); } diff --git a/gcc/m2/mc-boot/GRTint.cc b/gcc/m2/mc-boot/GRTint.cc index 236dbf4af651c..11b4228074a4b 100644 --- a/gcc/m2/mc-boot/GRTint.cc +++ b/gcc/m2/mc-boot/GRTint.cc @@ -48,9 +48,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see # undef NULL # define NULL 0 #endif -#define _RTint_H #define _RTint_C +#include "GRTint.h" # include "GM2RTS.h" # include "GStorage.h" # include "GRTco.h" @@ -72,13 +72,10 @@ typedef struct RTint__T2_a RTint__T2; typedef enum {RTint_input, RTint_output, RTint_time} RTint_VectorType; -typedef void (*RTint_DispatchVector_t) (unsigned int, unsigned int, void *); -struct RTint_DispatchVector_p { RTint_DispatchVector_t proc; }; - struct RTint__T1_r { RTint_VectorType type; unsigned int priority; - void *arg; + void * arg; RTint_Vector pending; RTint_Vector exists; unsigned int no; @@ -354,7 +351,7 @@ static void AddFd (Selective_SetOfFd *set, int *max, int fd) { if (fd < 0) { - return ; + return; } (*max) = Max (fd, (*max)); if ((*set) == NULL) @@ -1011,7 +1008,7 @@ extern "C" void RTint_Listen (bool untilInterrupt, RTint_DispatchVector call, un /* no file descriptors to be selected upon. */ timeval = Selective_KillTime (timeval); RTco_signal (lock); - return ; + return; } else { @@ -1140,11 +1137,11 @@ extern "C" void RTint_Init (void) } } -extern "C" void _M2_RTint_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_RTint_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { RTint_Init (); } -extern "C" void _M2_RTint_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_RTint_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GSArgs.cc b/gcc/m2/mc-boot/GSArgs.cc index 3424fbcc9988c..042dbe3fb3f19 100644 --- a/gcc/m2/mc-boot/GSArgs.cc +++ b/gcc/m2/mc-boot/GSArgs.cc @@ -46,9 +46,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see # undef NULL # define NULL 0 #endif -#define _SArgs_H #define _SArgs_C +#include "GSArgs.h" # include "GSYSTEM.h" # include "GUnixArgs.h" # include "GDynamicStrings.h" @@ -119,10 +119,10 @@ extern "C" unsigned int SArgs_Narg (void) __builtin_unreachable (); } -extern "C" void _M2_SArgs_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_SArgs_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_SArgs_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_SArgs_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GSFIO.cc b/gcc/m2/mc-boot/GSFIO.cc index 3c59d50f0d3ed..b568cce23ebf3 100644 --- a/gcc/m2/mc-boot/GSFIO.cc +++ b/gcc/m2/mc-boot/GSFIO.cc @@ -38,9 +38,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see # undef NULL # define NULL 0 #endif -#define _SFIO_H #define _SFIO_C +#include "GSFIO.h" # include "GASCII.h" # include "GDynamicStrings.h" # include "GFIO.h" @@ -207,10 +207,10 @@ extern "C" DynamicStrings_String SFIO_ReadS (FIO_File file) __builtin_unreachable (); } -extern "C" void _M2_SFIO_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_SFIO_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_SFIO_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_SFIO_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GStdIO.cc b/gcc/m2/mc-boot/GStdIO.cc index bf25ba25ee35c..c9d3774ec0615 100644 --- a/gcc/m2/mc-boot/GStdIO.cc +++ b/gcc/m2/mc-boot/GStdIO.cc @@ -35,9 +35,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see # endif # include "Gmcrts.h" -#define _StdIO_H #define _StdIO_C +#include "GStdIO.h" # include "GIO.h" # include "GM2RTS.h" @@ -50,12 +50,6 @@ typedef struct StdIO__T1_a StdIO__T1; typedef struct StdIO__T2_a StdIO__T2; -typedef void (*StdIO_ProcWrite_t) (char); -struct StdIO_ProcWrite_p { StdIO_ProcWrite_t proc; }; - -typedef void (*StdIO_ProcRead_t) (char *); -struct StdIO_ProcRead_p { StdIO_ProcRead_t proc; }; - struct StdIO__T1_a { StdIO_ProcWrite array[MaxStack+1]; }; struct StdIO__T2_a { StdIO_ProcRead array[MaxStack+1]; }; static StdIO__T1 StackW; @@ -257,7 +251,7 @@ extern "C" StdIO_ProcRead StdIO_GetCurrentInput (void) __builtin_unreachable (); } -extern "C" void _M2_StdIO_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_StdIO_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { StackWPtr = 0; StackRPtr = 0; @@ -265,6 +259,6 @@ extern "C" void _M2_StdIO_init (__attribute__((unused)) int argc,__attribute__(( StdIO_PushInput ((StdIO_ProcRead) {(StdIO_ProcRead_t) IO_Read}); } -extern "C" void _M2_StdIO_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_StdIO_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GStorage.cc b/gcc/m2/mc-boot/GStorage.cc index c5657cf5a070a..67e7a8b7274ba 100644 --- a/gcc/m2/mc-boot/GStorage.cc +++ b/gcc/m2/mc-boot/GStorage.cc @@ -34,9 +34,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see typedef struct { PROC_t proc; } PROC; # endif -#define _Storage_H #define _Storage_C +#include "GStorage.h" # include "GSysStorage.h" extern "C" void Storage_ALLOCATE (void * *a, unsigned int Size); @@ -66,10 +66,10 @@ extern "C" bool Storage_Available (unsigned int Size) __builtin_unreachable (); } -extern "C" void _M2_Storage_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_Storage_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_Storage_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_Storage_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GStrCase.cc b/gcc/m2/mc-boot/GStrCase.cc index 5e756b1e0e4e9..9492774596ba4 100644 --- a/gcc/m2/mc-boot/GStrCase.cc +++ b/gcc/m2/mc-boot/GStrCase.cc @@ -34,9 +34,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see typedef struct { PROC_t proc; } PROC; # endif -#define _StrCase_H #define _StrCase_C +#include "GStrCase.h" # include "GASCII.h" # include "GStrLib.h" @@ -92,12 +92,12 @@ extern "C" void StrCase_StrToUpperCase (const char *a_, unsigned int _a_high, ch i = 0; while (((i < higha) && (a[i] != ASCII_nul)) && (i < highb)) { - b[i] = StrCase_Cap (a[i]); + const_cast(b)[i] = StrCase_Cap (a[i]); i += 1; } if (i < highb) { - b[i] = ASCII_nul; + const_cast(b)[i] = ASCII_nul; } } @@ -122,12 +122,12 @@ extern "C" void StrCase_StrToLowerCase (const char *a_, unsigned int _a_high, ch i = 0; while (((i < higha) && (a[i] != ASCII_nul)) && (i < highb)) { - b[i] = StrCase_Lower (a[i]); + const_cast(b)[i] = StrCase_Lower (a[i]); i += 1; } if (i < highb) { - b[i] = ASCII_nul; + const_cast(b)[i] = ASCII_nul; } } @@ -167,10 +167,10 @@ extern "C" char StrCase_Lower (char ch) __builtin_unreachable (); } -extern "C" void _M2_StrCase_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_StrCase_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_StrCase_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_StrCase_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GStrIO.cc b/gcc/m2/mc-boot/GStrIO.cc index 46e433349bb1a..d0c6e2085cd11 100644 --- a/gcc/m2/mc-boot/GStrIO.cc +++ b/gcc/m2/mc-boot/GStrIO.cc @@ -38,9 +38,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see # define FALSE (1==0) # endif -#define _StrIO_H #define _StrIO_C +#include "GStrIO.h" # include "GASCII.h" # include "GStdIO.h" # include "Glibc.h" @@ -204,16 +204,16 @@ extern "C" void StrIO_ReadString (char *a, unsigned int _a_high) /* avoid dangling else. */ if ((ch == ASCII_cr) || (ch == ASCII_lf)) { - a[n] = ASCII_nul; + const_cast(a)[n] = ASCII_nul; n += 1; } else if (ch == ASCII_ff) { /* avoid dangling else. */ - a[0] = ch; + const_cast(a)[0] = ch; if (high > 0) { - a[1] = ASCII_nul; + const_cast(a)[1] = ASCII_nul; } ch = ASCII_cr; } @@ -221,18 +221,18 @@ extern "C" void StrIO_ReadString (char *a, unsigned int _a_high) { /* avoid dangling else. */ Echo (ch); - a[n] = ch; + const_cast(a)[n] = ch; n += 1; } else if (ch == ASCII_eof) { /* avoid dangling else. */ - a[n] = ch; + const_cast(a)[n] = ch; n += 1; ch = ASCII_cr; if (n <= high) { - a[n] = ASCII_nul; + const_cast(a)[n] = ASCII_nul; } } } @@ -267,12 +267,12 @@ extern "C" void StrIO_WriteString (const char *a_, unsigned int _a_high) } } -extern "C" void _M2_StrIO_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_StrIO_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { /* IsATTY := isatty() */ IsATTY = false; } -extern "C" void _M2_StrIO_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_StrIO_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GStrLib.cc b/gcc/m2/mc-boot/GStrLib.cc index 8e976b9056d99..dc6d0ff2aa071 100644 --- a/gcc/m2/mc-boot/GStrLib.cc +++ b/gcc/m2/mc-boot/GStrLib.cc @@ -42,9 +42,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see # define FALSE (1==0) # endif -#define _StrLib_H #define _StrLib_C +#include "GStrLib.h" # include "GASCII.h" @@ -127,13 +127,13 @@ extern "C" void StrLib_StrConCat (const char *a_, unsigned int _a_high, const ch j = 0; while ((j < Highb) && (i <= Highc)) { - c[i] = b[j]; + const_cast(c)[i] = b[j]; i += 1; j += 1; } if (i <= Highc) { - c[i] = ASCII_nul; + const_cast(c)[i] = ASCII_nul; } } @@ -247,12 +247,12 @@ extern "C" void StrLib_StrCopy (const char *src_, unsigned int _src_high, char * HighDest = _dest_high; while ((n < HighSrc) && (n <= HighDest)) { - dest[n] = src[n]; + const_cast(dest)[n] = src[n]; n += 1; } if (n <= HighDest) { - dest[n] = ASCII_nul; + const_cast(dest)[n] = ASCII_nul; } } @@ -328,20 +328,20 @@ extern "C" void StrLib_StrRemoveWhitePrefix (const char *a_, unsigned int _a_hig } while ((i < higha) && (j <= highb)) { - b[j] = a[i]; + const_cast(b)[j] = a[i]; i += 1; j += 1; } if (j <= highb) { - b[j] = ASCII_nul; + const_cast(b)[j] = ASCII_nul; } } -extern "C" void _M2_StrLib_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_StrLib_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_StrLib_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_StrLib_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GStringConvert.cc b/gcc/m2/mc-boot/GStringConvert.cc index 5d07bd133bab3..5ab4b00a2b78c 100644 --- a/gcc/m2/mc-boot/GStringConvert.cc +++ b/gcc/m2/mc-boot/GStringConvert.cc @@ -46,9 +46,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see # undef NULL # define NULL 0 #endif -#define _StringConvert_H #define _StringConvert_C +#include "GStringConvert.h" # include "GSYSTEM.h" # include "Glibc.h" # include "Glibm.h" @@ -1995,10 +1995,10 @@ extern "C" DynamicStrings_String StringConvert_ToDecimalPlaces (DynamicStrings_S __builtin_unreachable (); } -extern "C" void _M2_StringConvert_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_StringConvert_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_StringConvert_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_StringConvert_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GSysStorage.cc b/gcc/m2/mc-boot/GSysStorage.cc index d1d958df7792d..1ef723074d464 100644 --- a/gcc/m2/mc-boot/GSysStorage.cc +++ b/gcc/m2/mc-boot/GSysStorage.cc @@ -46,9 +46,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see # undef NULL # define NULL 0 #endif -#define _SysStorage_H #define _SysStorage_C +#include "GSysStorage.h" # include "Glibc.h" # include "GDebug.h" # include "GSYSTEM.h" @@ -224,12 +224,12 @@ extern "C" void SysStorage_Init (void) { } -extern "C" void _M2_SysStorage_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_SysStorage_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { callno = 0; if (enableTrace) { - trace = (libc_getenv (const_cast (reinterpret_cast("M2DEBUG_SYSSTORAGE_trace")))) != NULL; + trace = (libc_getenv (const_cast (static_cast("M2DEBUG_SYSSTORAGE_trace")))) != NULL; } else { @@ -237,7 +237,7 @@ extern "C" void _M2_SysStorage_init (__attribute__((unused)) int argc,__attribut } if (enableZero) { - zero = (libc_getenv (const_cast (reinterpret_cast("M2DEBUG_SYSSTORAGE_zero")))) != NULL; + zero = (libc_getenv (const_cast (static_cast("M2DEBUG_SYSSTORAGE_zero")))) != NULL; } else { @@ -245,6 +245,6 @@ extern "C" void _M2_SysStorage_init (__attribute__((unused)) int argc,__attribut } } -extern "C" void _M2_SysStorage_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_SysStorage_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GTimeString.cc b/gcc/m2/mc-boot/GTimeString.cc index 66b15233df93f..af7b7e40814e5 100644 --- a/gcc/m2/mc-boot/GTimeString.cc +++ b/gcc/m2/mc-boot/GTimeString.cc @@ -38,9 +38,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see # undef NULL # define NULL 0 #endif -#define _TimeString_H #define _TimeString_C +#include "GTimeString.h" # include "Gwrapc.h" # include "GASCII.h" # include "GSYSTEM.h" @@ -72,21 +72,21 @@ extern "C" void TimeString_GetTimeString (char *a, unsigned int _a_high) { while ((i < _a_high) && ((*Addr) != ASCII_nul)) { - a[i] = (*Addr); + const_cast(a)[i] = (*Addr); i += 1; Addr += 1; } } if (i < _a_high) { - a[i] = ASCII_nul; + const_cast(a)[i] = ASCII_nul; } } -extern "C" void _M2_TimeString_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_TimeString_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_TimeString_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_TimeString_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/Galists.cc b/gcc/m2/mc-boot/Galists.cc index 238bcc87d5075..ca582f3ce43a9 100644 --- a/gcc/m2/mc-boot/Galists.cc +++ b/gcc/m2/mc-boot/Galists.cc @@ -42,9 +42,9 @@ along with GNU Modula-2; see the file COPYING3. If not see # undef NULL # define NULL 0 #endif -#define _alists_H #define _alists_C +#include "Galists.h" # include "GStorage.h" typedef struct alists_performOperation_p alists_performOperation; @@ -54,16 +54,13 @@ typedef struct alists__T1_r alists__T1; typedef struct alists__T2_a alists__T2; -typedef alists__T1 *alists_alist; - -typedef void (*alists_performOperation_t) (void *); -struct alists_performOperation_p { alists_performOperation_t proc; }; +typedef alists__T1 *alists_alist__opaque; struct alists__T2_a { void * array[MaxnoOfelements-1+1]; }; struct alists__T1_r { unsigned int noOfelements; alists__T2 elements; - alists_alist next; + alists_alist__opaque next; }; @@ -147,14 +144,14 @@ extern "C" bool alists_equalList (alists_alist left, alists_alist right); removeItem - remove an element at index, i, from the alist data type. */ -static void removeItem (alists_alist p, alists_alist l, unsigned int i); +static void removeItem (alists_alist__opaque p, alists_alist__opaque l, unsigned int i); /* removeItem - remove an element at index, i, from the alist data type. */ -static void removeItem (alists_alist p, alists_alist l, unsigned int i) +static void removeItem (alists_alist__opaque p, alists_alist__opaque l, unsigned int i) { l->noOfelements -= 1; while (i <= l->noOfelements) @@ -176,12 +173,12 @@ static void removeItem (alists_alist p, alists_alist l, unsigned int i) extern "C" alists_alist alists_initList (void) { - alists_alist l; + alists_alist__opaque l; Storage_ALLOCATE ((void **) &l, sizeof (alists__T1)); l->noOfelements = 0; - l->next = NULL; - return l; + l->next = static_cast (NULL); + return static_cast (l); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -195,9 +192,9 @@ extern "C" void alists_killList (alists_alist *l) { if ((*l) != NULL) { - if ((*l)->next != NULL) + if (static_cast ((*l))->next != NULL) { - alists_killList (&(*l)->next); + alists_killList (reinterpret_cast (&static_cast ((*l))->next)); } Storage_DEALLOCATE ((void **) &(*l), sizeof (alists__T1)); } @@ -210,21 +207,21 @@ extern "C" void alists_killList (alists_alist *l) extern "C" void alists_putItemIntoList (alists_alist l, void * c) { - if (l->noOfelements < MaxnoOfelements) + if (static_cast (l)->noOfelements < MaxnoOfelements) { - l->noOfelements += 1; - l->elements.array[l->noOfelements-1] = c; + static_cast (l)->noOfelements += 1; + static_cast (l)->elements.array[static_cast (l)->noOfelements-1] = c; } - else if (l->next != NULL) + else if (static_cast (l)->next != NULL) { /* avoid dangling else. */ - alists_putItemIntoList (l->next, c); + alists_putItemIntoList (static_cast (static_cast (l)->next), c); } else { /* avoid dangling else. */ - l->next = alists_initList (); - alists_putItemIntoList (l->next, c); + static_cast (l)->next = static_cast (alists_initList ()); + alists_putItemIntoList (static_cast (static_cast (l)->next), c); } } @@ -237,17 +234,17 @@ extern "C" void * alists_getItemFromList (alists_alist l, unsigned int n) { while (l != NULL) { - if (n <= l->noOfelements) + if (n <= static_cast (l)->noOfelements) { - return l->elements.array[n-1]; + return static_cast (l)->elements.array[n-1]; } else { - n -= l->noOfelements; + n -= static_cast (l)->noOfelements; } - l = l->next; + l = static_cast (static_cast (l)->next); } - return reinterpret_cast (0); + return static_cast (0); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -270,9 +267,9 @@ extern "C" unsigned int alists_getIndexOfList (alists_alist l, void * c) else { i = 1; - while (i <= l->noOfelements) + while (i <= static_cast (l)->noOfelements) { - if (l->elements.array[i-1] == c) + if (static_cast (l)->elements.array[i-1] == c) { return i; } @@ -281,7 +278,7 @@ extern "C" unsigned int alists_getIndexOfList (alists_alist l, void * c) i += 1; } } - return l->noOfelements+(alists_getIndexOfList (l->next, c)); + return static_cast (l)->noOfelements+(alists_getIndexOfList (static_cast (static_cast (l)->next), c)); } /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -304,8 +301,8 @@ extern "C" unsigned int alists_noOfItemsInList (alists_alist l) { t = 0; do { - t += l->noOfelements; - l = l->next; + t += static_cast (l)->noOfelements; + l = static_cast (static_cast (l)->next); } while (! (l == NULL)); return t; } @@ -335,33 +332,33 @@ extern "C" void alists_includeItemIntoList (alists_alist l, void * c) extern "C" void alists_removeItemFromList (alists_alist l, void * c) { - alists_alist p; + alists_alist__opaque p; unsigned int i; bool found; if (l != NULL) { found = false; - p = NULL; + p = static_cast (NULL); do { i = 1; - while ((i <= l->noOfelements) && (l->elements.array[i-1] != c)) + while ((i <= static_cast (l)->noOfelements) && (static_cast (l)->elements.array[i-1] != c)) { i += 1; } - if ((i <= l->noOfelements) && (l->elements.array[i-1] == c)) + if ((i <= static_cast (l)->noOfelements) && (static_cast (l)->elements.array[i-1] == c)) { found = true; } else { - p = l; - l = l->next; + p = static_cast (l); + l = static_cast (static_cast (l)->next); } } while (! ((l == NULL) || found)); if (found) { - removeItem (p, l, i); + removeItem (p, static_cast (l), i); } } } @@ -377,9 +374,9 @@ extern "C" bool alists_isItemInList (alists_alist l, void * c) do { i = 1; - while (i <= l->noOfelements) + while (i <= static_cast (l)->noOfelements) { - if (l->elements.array[i-1] == c) + if (static_cast (l)->elements.array[i-1] == c) { return true; } @@ -388,7 +385,7 @@ extern "C" bool alists_isItemInList (alists_alist l, void * c) i += 1; } } - l = l->next; + l = static_cast (static_cast (l)->next); } while (! (l == NULL)); return false; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -421,19 +418,19 @@ extern "C" void alists_foreachItemInListDo (alists_alist l, alists_performOperat extern "C" alists_alist alists_duplicateList (alists_alist l) { - alists_alist m; + alists_alist__opaque m; unsigned int n; unsigned int i; - m = alists_initList (); + m = static_cast (alists_initList ()); n = alists_noOfItemsInList (l); i = 1; while (i <= n) { - alists_putItemIntoList (m, alists_getItemFromList (l, i)); + alists_putItemIntoList (static_cast (m), alists_getItemFromList (l, i)); i += 1; } - return m; + return static_cast (m); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -475,10 +472,10 @@ extern "C" bool alists_equalList (alists_alist left, alists_alist right) __builtin_unreachable (); } -extern "C" void _M2_alists_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_alists_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_alists_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_alists_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/Gdecl.cc b/gcc/m2/mc-boot/Gdecl.cc index bd43faebeac94..183d671c8b35d 100644 --- a/gcc/m2/mc-boot/Gdecl.cc +++ b/gcc/m2/mc-boot/Gdecl.cc @@ -43,99 +43,36 @@ along with GNU Modula-2; see the file COPYING3. If not see # undef NULL # define NULL 0 #endif -typedef unsigned int nameKey_Name; +#define _decl_C -# define nameKey_NulName 0 -typedef struct symbolKey__T8_r symbolKey__T8; - -typedef symbolKey__T8 *symbolKey_symbolTree; - -typedef struct mcPretty_writeProc_p mcPretty_writeProc; - -typedef struct mcPretty_writeLnProc_p mcPretty_writeLnProc; - -typedef unsigned int FIO_File; - -extern FIO_File FIO_StdOut; -# define symbolKey_NulKey NULL -typedef struct symbolKey_performOperation_p symbolKey_performOperation; - -# define ASCII_tab ASCII_ht -# define ASCII_ht (char) 011 -# define ASCII_lf ASCII_nl -# define ASCII_nl (char) 012 -typedef struct Indexing_IndexProcedure_p Indexing_IndexProcedure; +#include "Gdecl.h" +# include "GASCII.h" +# include "GsymbolKey.h" +# include "GmcDebug.h" +# include "GStorage.h" +# include "GnameKey.h" +# include "GSFIO.h" +# include "GFIO.h" +# include "GDynamicStrings.h" +# include "GStringConvert.h" +# include "GmcOptions.h" +# include "GFormatStrings.h" +# include "Glibc.h" +# include "GmcMetaError.h" +# include "GmcError.h" +# include "GmcLexBuf.h" +# include "GmcComment.h" +# include "GStrLib.h" +# include "GmcPretty.h" +# include "GIndexing.h" +# include "Galists.h" +# include "Gwlists.h" +# include "Gkeyc.h" +# include "GmcStream.h" +# include "GM2RTS.h" typedef struct decl_isNodeF_p decl_isNodeF; -# define SYSTEM_BITSPERBYTE 8 -# define SYSTEM_BYTESPERWORD 4 -typedef struct M2RTS_ArgCVEnvP_p M2RTS_ArgCVEnvP; - -typedef struct symbolKey_isSymbol_p symbolKey_isSymbol; - -# define ASCII_nul (char) 000 -# define ASCII_soh (char) 001 -# define ASCII_stx (char) 002 -# define ASCII_etx (char) 003 -# define ASCII_eot (char) 004 -# define ASCII_enq (char) 005 -# define ASCII_ack (char) 006 -# define ASCII_bel (char) 007 -# define ASCII_bs (char) 010 -# define ASCII_vt (char) 013 -# define ASCII_np (char) 014 -# define ASCII_cr (char) 015 -# define ASCII_so (char) 016 -# define ASCII_si (char) 017 -# define ASCII_dle (char) 020 -# define ASCII_dc1 (char) 021 -# define ASCII_dc2 (char) 022 -# define ASCII_dc3 (char) 023 -# define ASCII_dc4 (char) 024 -# define ASCII_nak (char) 025 -# define ASCII_syn (char) 026 -# define ASCII_etb (char) 027 -# define ASCII_can (char) 030 -# define ASCII_em (char) 031 -# define ASCII_sub (char) 032 -# define ASCII_esc (char) 033 -# define ASCII_fs (char) 034 -# define ASCII_gs (char) 035 -# define ASCII_rs (char) 036 -# define ASCII_us (char) 037 -# define ASCII_sp (char) 040 -# define ASCII_ff ASCII_np -# define ASCII_eof ASCII_eot -# define ASCII_del (char) 0177 -# define ASCII_EOL ASCII_nl -extern FIO_File FIO_StdErr; -extern FIO_File FIO_StdIn; -typedef long int libc_time_t; - -typedef struct libc_tm_r libc_tm; - -typedef libc_tm *libc_ptrToTM; - -typedef struct libc_timeb_r libc_timeb; - -typedef struct libc_exitP_p libc_exitP; - -typedef struct mcError__T11_r mcError__T11; - -typedef mcError__T11 *mcError_error; - -extern int mcLexBuf_currentinteger; -extern unsigned int mcLexBuf_currentcolumn; -extern void * mcLexBuf_currentstring; -typedef struct alists_performOperation_p alists_performOperation; - -typedef struct wlists_performOperation_p wlists_performOperation; - -typedef struct StdIO_ProcWrite_p StdIO_ProcWrite; - -typedef struct StdIO_ProcRead_p StdIO_ProcRead; - # define indentation 3 # define indentationC 2 # define debugScopes false @@ -146,8 +83,13 @@ typedef struct StdIO_ProcRead_p StdIO_ProcRead; # define enableDefForCStrings false # define enableMemsetOnAllocation true # define forceQualified true +# define debugOpaque false typedef struct decl_nodeRec_r decl_nodeRec; +typedef struct decl_opaqueCastState_r decl_opaqueCastState; + +typedef struct decl_opaquecastT_r decl_opaquecastT; + typedef struct decl_intrinsicT_r decl_intrinsicT; typedef struct decl_fixupInfo_r decl_fixupInfo; @@ -264,136 +206,24 @@ typedef struct decl_nodeProcedure_p decl_nodeProcedure; typedef struct decl_cnameT_r decl_cnameT; -typedef struct decl__T15_r decl__T15; +typedef struct decl__T1_r decl__T1; -typedef decl__T15 *decl_group; +typedef decl__T1 *decl_group; -# define MaxBuf 127 -# define maxNoOfElements 5 -typedef enum {decl_explist, decl_funccall, decl_exit, decl_return, decl_stmtseq, decl_comment, decl_halt, decl_new, decl_dispose, decl_inc, decl_dec, decl_incl, decl_excl, decl_length, decl_nil, decl_true, decl_false, decl_address, decl_loc, decl_byte, decl_word, decl_csizet, decl_cssizet, decl_char, decl_cardinal, decl_longcard, decl_shortcard, decl_integer, decl_longint, decl_shortint, decl_real, decl_longreal, decl_shortreal, decl_bitset, decl_boolean, decl_proc, decl_ztype, decl_rtype, decl_complex, decl_longcomplex, decl_shortcomplex, decl_type, decl_record, decl_varient, decl_var, decl_enumeration, decl_subrange, decl_array, decl_subscript, decl_string, decl_const, decl_literal, decl_varparam, decl_param, decl_varargs, decl_optarg, decl_pointer, decl_recordfield, decl_varientfield, decl_enumerationfield, decl_set, decl_proctype, decl_procedure, decl_def, decl_imp, decl_module, decl_loop, decl_while, decl_for, decl_repeat, decl_case, decl_caselabellist, decl_caselist, decl_range, decl_assignment, decl_if, decl_elsif, decl_constexp, decl_neg, decl_cast, decl_val, decl_plus, decl_sub, decl_div, decl_mod, decl_mult, decl_divide, decl_in, decl_adr, decl_size, decl_tsize, decl_ord, decl_float, decl_trunc, decl_chr, decl_abs, decl_cap, decl_high, decl_throw, decl_unreachable, decl_cmplx, decl_re, decl_im, decl_min, decl_max, decl_componentref, decl_pointerref, decl_arrayref, decl_deref, decl_equal, decl_notequal, decl_less, decl_greater, decl_greequal, decl_lessequal, decl_lsl, decl_lsr, decl_lor, decl_land, decl_lnot, decl_lxor, decl_and, decl_or, decl_not, decl_identlist, decl_vardecl, decl_setvalue} decl_nodeT; +typedef enum {decl_explist, decl_funccall, decl_exit, decl_return, decl_stmtseq, decl_comment, decl_halt, decl_new, decl_dispose, decl_inc, decl_dec, decl_incl, decl_excl, decl_length, decl_nil, decl_true, decl_false, decl_address, decl_loc, decl_byte, decl_word, decl_csizet, decl_cssizet, decl_char, decl_cardinal, decl_longcard, decl_shortcard, decl_integer, decl_longint, decl_shortint, decl_real, decl_longreal, decl_shortreal, decl_bitset, decl_boolean, decl_proc, decl_ztype, decl_rtype, decl_complex, decl_longcomplex, decl_shortcomplex, decl_type, decl_record, decl_varient, decl_var, decl_enumeration, decl_subrange, decl_array, decl_subscript, decl_string, decl_const, decl_literal, decl_varparam, decl_param, decl_varargs, decl_optarg, decl_pointer, decl_recordfield, decl_varientfield, decl_enumerationfield, decl_set, decl_proctype, decl_procedure, decl_def, decl_imp, decl_module, decl_loop, decl_while, decl_for, decl_repeat, decl_case, decl_caselabellist, decl_caselist, decl_range, decl_assignment, decl_if, decl_elsif, decl_constexp, decl_neg, decl_cast, decl_val, decl_plus, decl_sub, decl_div, decl_mod, decl_mult, decl_divide, decl_in, decl_adr, decl_size, decl_tsize, decl_ord, decl_float, decl_trunc, decl_chr, decl_abs, decl_cap, decl_high, decl_throw, decl_unreachable, decl_cmplx, decl_re, decl_im, decl_min, decl_max, decl_componentref, decl_pointerref, decl_arrayref, decl_deref, decl_equal, decl_notequal, decl_less, decl_greater, decl_greequal, decl_lessequal, decl_lsl, decl_lsr, decl_lor, decl_land, decl_lnot, decl_lxor, decl_and, decl_or, decl_not, decl_identlist, decl_vardecl, decl_setvalue, decl_opaquecast} decl_nodeT; -# define MaxnoOfelements 5 -typedef enum {mcReserved_eoftok, mcReserved_plustok, mcReserved_minustok, mcReserved_timestok, mcReserved_dividetok, mcReserved_becomestok, mcReserved_ambersandtok, mcReserved_periodtok, mcReserved_commatok, mcReserved_semicolontok, mcReserved_lparatok, mcReserved_rparatok, mcReserved_lsbratok, mcReserved_rsbratok, mcReserved_lcbratok, mcReserved_rcbratok, mcReserved_uparrowtok, mcReserved_singlequotetok, mcReserved_equaltok, mcReserved_hashtok, mcReserved_lesstok, mcReserved_greatertok, mcReserved_lessgreatertok, mcReserved_lessequaltok, mcReserved_greaterequaltok, mcReserved_ldirectivetok, mcReserved_rdirectivetok, mcReserved_periodperiodtok, mcReserved_colontok, mcReserved_doublequotestok, mcReserved_bartok, mcReserved_andtok, mcReserved_arraytok, mcReserved_begintok, mcReserved_bytok, mcReserved_casetok, mcReserved_consttok, mcReserved_definitiontok, mcReserved_divtok, mcReserved_dotok, mcReserved_elsetok, mcReserved_elsiftok, mcReserved_endtok, mcReserved_excepttok, mcReserved_exittok, mcReserved_exporttok, mcReserved_finallytok, mcReserved_fortok, mcReserved_fromtok, mcReserved_iftok, mcReserved_implementationtok, mcReserved_importtok, mcReserved_intok, mcReserved_looptok, mcReserved_modtok, mcReserved_moduletok, mcReserved_nottok, mcReserved_oftok, mcReserved_ortok, mcReserved_packedsettok, mcReserved_pointertok, mcReserved_proceduretok, mcReserved_qualifiedtok, mcReserved_unqualifiedtok, mcReserved_recordtok, mcReserved_remtok, mcReserved_repeattok, mcReserved_retrytok, mcReserved_returntok, mcReserved_settok, mcReserved_thentok, mcReserved_totok, mcReserved_typetok, mcReserved_untiltok, mcReserved_vartok, mcReserved_whiletok, mcReserved_withtok, mcReserved_asmtok, mcReserved_volatiletok, mcReserved_periodperiodperiodtok, mcReserved_datetok, mcReserved_linetok, mcReserved_filetok, mcReserved_attributetok, mcReserved_builtintok, mcReserved_inlinetok, mcReserved_integertok, mcReserved_identtok, mcReserved_realtok, mcReserved_stringtok, mcReserved_commenttok} mcReserved_toktype; - -extern mcReserved_toktype mcLexBuf_currenttoken; typedef enum {decl_ansiC, decl_ansiCP, decl_pim4} decl_language; typedef enum {decl_completed, decl_blocked, decl_partial, decl_recursive} decl_dependentState; typedef enum {decl_text, decl_punct, decl_space} decl_outputStates; -typedef decl_nodeRec *decl_node; - -typedef struct Indexing__T5_r Indexing__T5; - -typedef struct mcComment__T6_r mcComment__T6; - -typedef enum {mcComment_unknown, mcComment_procedureHeading, mcComment_inBody, mcComment_afterStatement} mcComment_commentType; - -typedef struct DynamicStrings_stringRecord_r DynamicStrings_stringRecord; - -typedef struct DynamicStrings_Contents_r DynamicStrings_Contents; - -typedef struct wlists__T9_r wlists__T9; - -typedef struct alists__T13_r alists__T13; - -typedef struct mcPretty__T12_r mcPretty__T12; - -typedef struct wlists__T10_a wlists__T10; - -typedef Indexing__T5 *Indexing_Index; - -typedef struct DynamicStrings__T7_a DynamicStrings__T7; - -typedef struct alists__T14_a alists__T14; - -typedef mcComment__T6 *mcComment_commentDesc; - -extern mcComment_commentDesc mcLexBuf_currentcomment; -extern mcComment_commentDesc mcLexBuf_lastcomment; -typedef DynamicStrings_stringRecord *DynamicStrings_String; - -typedef wlists__T9 *wlists_wlist; - -typedef alists__T13 *alists_alist; - -typedef mcPretty__T12 *mcPretty_pretty; - -struct symbolKey__T8_r { - nameKey_Name name; - void *key; - symbolKey_symbolTree left; - symbolKey_symbolTree right; - }; - -typedef void (*mcPretty_writeProc_t) (char); -struct mcPretty_writeProc_p { mcPretty_writeProc_t proc; }; - -typedef void (*mcPretty_writeLnProc_t) (void); -struct mcPretty_writeLnProc_p { mcPretty_writeLnProc_t proc; }; - -typedef void (*symbolKey_performOperation_t) (void *); -struct symbolKey_performOperation_p { symbolKey_performOperation_t proc; }; - -typedef void (*Indexing_IndexProcedure_t) (void *); -struct Indexing_IndexProcedure_p { Indexing_IndexProcedure_t proc; }; - -typedef bool (*decl_isNodeF_t) (decl_node); -struct decl_isNodeF_p { decl_isNodeF_t proc; }; - -typedef void (*M2RTS_ArgCVEnvP_t) (int, void *, void *); -struct M2RTS_ArgCVEnvP_p { M2RTS_ArgCVEnvP_t proc; }; - -typedef bool (*symbolKey_isSymbol_t) (void *); -struct symbolKey_isSymbol_p { symbolKey_isSymbol_t proc; }; - -struct libc_tm_r { - int tm_sec; - int tm_min; - int tm_hour; - int tm_mday; - int tm_mon; - int tm_year; - int tm_wday; - int tm_yday; - int tm_isdst; - long int tm_gmtoff; - void *tm_zone; - }; - -struct libc_timeb_r { - libc_time_t time_; - short unsigned int millitm; - short unsigned int timezone; - short unsigned int dstflag; - }; - -typedef int (*libc_exitP_t) (void); -typedef libc_exitP_t libc_exitP_C; - -struct libc_exitP_p { libc_exitP_t proc; }; - -struct mcError__T11_r { - mcError_error parent; - mcError_error child; - mcError_error next; - bool fatal; - DynamicStrings_String s; - unsigned int token; - }; - -typedef void (*alists_performOperation_t) (void *); -struct alists_performOperation_p { alists_performOperation_t proc; }; - -typedef void (*wlists_performOperation_t) (unsigned int); -struct wlists_performOperation_p { wlists_performOperation_t proc; }; - -typedef void (*StdIO_ProcWrite_t) (char); -struct StdIO_ProcWrite_p { StdIO_ProcWrite_t proc; }; +typedef decl_nodeRec *decl_node__opaque; -typedef void (*StdIO_ProcRead_t) (char *); -struct StdIO_ProcRead_p { StdIO_ProcRead_t proc; }; +struct decl_opaqueCastState_r { + bool opaque; + bool voidStar; + }; struct decl_fixupInfo_r { unsigned int count; @@ -405,7 +235,7 @@ struct decl_explistT_r { }; struct decl_setvalueT_r { - decl_node type; + decl_node__opaque type; Indexing_Index values; }; @@ -423,19 +253,20 @@ struct decl_stmtT_r { }; struct decl_exitT_r { - decl_node loop; + decl_node__opaque loop; }; struct decl_vardeclT_r { wlists_wlist names; - decl_node type; - decl_node scope; + decl_node__opaque type; + decl_node__opaque scope; }; struct decl_typeT_r { nameKey_Name name; - decl_node type; - decl_node scope; + decl_node__opaque type; + decl_node__opaque scope; + bool isOpaque; bool isHidden; bool isInternal; }; @@ -443,44 +274,37 @@ struct decl_typeT_r { struct decl_recordT_r { symbolKey_symbolTree localSymbols; Indexing_Index listOfSons; - decl_node scope; + decl_node__opaque scope; }; struct decl_varientT_r { Indexing_Index listOfSons; - decl_node varient; - decl_node tag; - decl_node scope; + decl_node__opaque varient; + decl_node__opaque tag; + decl_node__opaque scope; }; struct decl_enumerationT_r { unsigned int noOfElements; symbolKey_symbolTree localSymbols; Indexing_Index listOfSons; - decl_node low; - decl_node high; - decl_node scope; + decl_node__opaque low; + decl_node__opaque high; + decl_node__opaque scope; }; struct decl_subrangeT_r { - decl_node low; - decl_node high; - decl_node type; - decl_node scope; + decl_node__opaque low; + decl_node__opaque high; + decl_node__opaque type; + decl_node__opaque scope; }; struct decl_subscriptT_r { - decl_node type; - decl_node expr; + decl_node__opaque type; + decl_node__opaque expr; }; -struct decl_arrayT_r { - decl_node subr; - decl_node type; - decl_node scope; - bool isUnbounded; - }; - struct decl_stringT_r { nameKey_Name name; unsigned int length; @@ -492,101 +316,60 @@ struct decl_stringT_r { struct decl_literalT_r { nameKey_Name name; - decl_node type; + decl_node__opaque type; }; struct decl_constT_r { nameKey_Name name; - decl_node type; - decl_node value; - decl_node scope; - }; - -struct decl_varparamT_r { - decl_node namelist; - decl_node type; - decl_node scope; - bool isUnbounded; - bool isForC; - bool isUsed; - }; - -struct decl_paramT_r { - decl_node namelist; - decl_node type; - decl_node scope; - bool isUnbounded; - bool isForC; - bool isUsed; + decl_node__opaque type; + decl_node__opaque value; + decl_node__opaque scope; }; struct decl_varargsT_r { - decl_node scope; + decl_node__opaque scope; }; struct decl_optargT_r { - decl_node namelist; - decl_node type; - decl_node scope; - decl_node init; + decl_node__opaque namelist; + decl_node__opaque type; + decl_node__opaque scope; + decl_node__opaque init; }; -struct decl_pointerT_r { - decl_node type; - decl_node scope; - }; - struct decl_varientfieldT_r { nameKey_Name name; - decl_node parent; - decl_node varient; + decl_node__opaque parent; + decl_node__opaque varient; bool simple; Indexing_Index listOfSons; - decl_node scope; + decl_node__opaque scope; }; struct decl_setT_r { - decl_node type; - decl_node scope; + decl_node__opaque type; + decl_node__opaque scope; }; -struct decl_componentrefT_r { - decl_node rec; - decl_node field; - decl_node resultType; - }; - -struct decl_pointerrefT_r { - decl_node ptr; - decl_node field; - decl_node resultType; - }; - -struct decl_arrayrefT_r { - decl_node array; - decl_node index; - decl_node resultType; - }; - struct decl_commentPair_r { - decl_node after; - decl_node body; + decl_node__opaque after; + decl_node__opaque body; }; struct decl_loopT_r { - decl_node statements; + decl_node__opaque statements; unsigned int labelno; }; struct decl_caseT_r { - decl_node expression; + decl_node__opaque expression; Indexing_Index caseLabelList; - decl_node else_; + decl_node__opaque else_; }; struct decl_caselabellistT_r { - decl_node caseList; - decl_node statements; + decl_node__opaque caseList; + decl_node__opaque statements; }; struct decl_caselistT_r { @@ -594,16 +377,16 @@ struct decl_caselistT_r { }; struct decl_rangeT_r { - decl_node lo; - decl_node hi; + decl_node__opaque lo; + decl_node__opaque hi; }; struct decl_forT_r { - decl_node des; - decl_node start; - decl_node end; - decl_node increment; - decl_node statements; + decl_node__opaque des; + decl_node__opaque start; + decl_node__opaque end; + decl_node__opaque increment; + decl_node__opaque statements; }; struct decl_statementT_r { @@ -618,24 +401,15 @@ struct decl_scopeT_r { Indexing_Index variables; }; -struct decl_proctypeT_r { - Indexing_Index parameters; - bool returnopt; - bool vararg; - decl_node optarg_; - decl_node scope; - decl_node returnType; - }; - struct decl_binaryT_r { - decl_node left; - decl_node right; - decl_node resultType; + decl_node__opaque left; + decl_node__opaque right; + decl_node__opaque resultType; }; struct decl_unaryT_r { - decl_node arg; - decl_node resultType; + decl_node__opaque arg; + decl_node__opaque resultType; }; struct decl_where_r { @@ -652,118 +426,161 @@ struct decl_cnameT_r { bool init; }; -struct decl__T15_r { - alists_alist todoQ; - alists_alist partialQ; - alists_alist doneQ; - decl_group next; - }; - -struct Indexing__T5_r { - void *ArrayStart; - unsigned int ArraySize; - unsigned int Used; - unsigned int Low; - unsigned int High; - bool Debug; - unsigned int Map; - }; +struct decl__T1_r { + alists_alist todoQ; + alists_alist partialQ; + alists_alist doneQ; + decl_group next; + }; -struct mcComment__T6_r { - mcComment_commentType type; - DynamicStrings_String content; - nameKey_Name procName; - bool used; - }; +struct decl_opaquecastT_r { + decl_node__opaque exp; + decl_opaqueCastState opaqueState; + }; -struct wlists__T10_a { unsigned int array[maxNoOfElements-1+1]; }; -struct DynamicStrings__T7_a { char array[(MaxBuf-1)+1]; }; -struct alists__T14_a { void * array[MaxnoOfelements-1+1]; }; struct decl_intrinsicT_r { - decl_node args; + decl_node__opaque args; unsigned int noArgs; - decl_node type; + decl_node__opaque type; decl_commentPair intrinsicComment; bool postUnreachable; }; struct decl_funccallT_r { - decl_node function; - decl_node args; - decl_node type; + decl_node__opaque function; + decl_node__opaque args; + decl_node__opaque type; decl_commentPair funccallComment; + decl_opaqueCastState opaqueState; }; struct decl_returnT_r { - decl_node exp; - decl_node scope; + decl_node__opaque exp; + decl_node__opaque scope; decl_commentPair returnComment; }; struct decl_varT_r { nameKey_Name name; - decl_node type; - decl_node decl; - decl_node scope; + decl_node__opaque type; + decl_node__opaque decl; + decl_node__opaque scope; bool isInitialised; bool isParameter; bool isVarParameter; bool isUsed; decl_cnameT cname; + decl_opaqueCastState opaqueState; }; +struct decl_arrayT_r { + decl_node__opaque subr; + decl_node__opaque type; + decl_node__opaque scope; + bool isUnbounded; + decl_opaqueCastState opaqueState; + }; + +struct decl_varparamT_r { + decl_node__opaque namelist; + decl_node__opaque type; + decl_node__opaque scope; + bool isUnbounded; + bool isForC; + bool isUsed; + decl_opaqueCastState opaqueState; + }; + +struct decl_paramT_r { + decl_node__opaque namelist; + decl_node__opaque type; + decl_node__opaque scope; + bool isUnbounded; + bool isForC; + bool isUsed; + decl_opaqueCastState opaqueState; + }; + +struct decl_pointerT_r { + decl_node__opaque type; + decl_node__opaque scope; + decl_opaqueCastState opaqueState; + }; + struct decl_recordfieldT_r { nameKey_Name name; - decl_node type; + decl_node__opaque type; bool tag; - decl_node parent; - decl_node varient; - decl_node scope; + decl_node__opaque parent; + decl_node__opaque varient; + decl_node__opaque scope; decl_cnameT cname; + decl_opaqueCastState opaqueState; }; struct decl_enumerationfieldT_r { nameKey_Name name; - decl_node type; - decl_node scope; + decl_node__opaque type; + decl_node__opaque scope; unsigned int value; decl_cnameT cname; }; +struct decl_componentrefT_r { + decl_node__opaque rec; + decl_node__opaque field; + decl_node__opaque resultType; + decl_opaqueCastState opaqueState; + }; + +struct decl_pointerrefT_r { + decl_node__opaque ptr; + decl_node__opaque field; + decl_node__opaque resultType; + decl_opaqueCastState opaqueState; + }; + +struct decl_arrayrefT_r { + decl_node__opaque array; + decl_node__opaque index; + decl_node__opaque resultType; + decl_opaqueCastState opaqueState; + }; + struct decl_assignmentT_r { - decl_node des; - decl_node expr; + decl_node__opaque des; + decl_node__opaque expr; decl_commentPair assignComment; }; struct decl_ifT_r { - decl_node expr; - decl_node elsif; - decl_node then; - decl_node else_; + decl_node__opaque expr; + decl_node__opaque elsif; + decl_node__opaque then; + decl_node__opaque else_; decl_commentPair ifComment; decl_commentPair elseComment; decl_commentPair endComment; }; struct decl_elsifT_r { - decl_node expr; - decl_node elsif; - decl_node then; - decl_node else_; + decl_node__opaque expr; + decl_node__opaque elsif; + decl_node__opaque then; + decl_node__opaque else_; decl_commentPair elseComment; }; struct decl_whileT_r { - decl_node expr; - decl_node statements; + decl_node__opaque expr; + decl_node__opaque statements; decl_commentPair doComment; decl_commentPair endComment; }; struct decl_repeatT_r { - decl_node expr; - decl_node statements; + decl_node__opaque expr; + decl_node__opaque statements; decl_commentPair repeatComment; decl_commentPair untilComment; }; @@ -771,7 +588,7 @@ struct decl_repeatT_r { struct decl_procedureT_r { nameKey_Name name; decl_scopeT decls; - decl_node scope; + decl_node__opaque scope; Indexing_Index parameters; bool isForC; bool built; @@ -781,14 +598,25 @@ struct decl_procedureT_r { bool noreturnused; bool noreturn; unsigned int paramcount; - decl_node optarg_; - decl_node returnType; - decl_node beginStatements; + decl_node__opaque optarg_; + decl_node__opaque returnType; + decl_node__opaque beginStatements; decl_cnameT cname; mcComment_commentDesc defComment; mcComment_commentDesc modComment; + decl_opaqueCastState opaqueState; }; +struct decl_proctypeT_r { + Indexing_Index parameters; + bool returnopt; + bool vararg; + decl_node__opaque optarg_; + decl_node__opaque scope; + decl_node__opaque returnType; + decl_opaqueCastState opaqueState; + }; + struct decl_moduleT_r { nameKey_Name name; nameKey_Name source; @@ -796,8 +624,8 @@ struct decl_moduleT_r { decl_fixupInfo constFixup; decl_fixupInfo enumFixup; decl_scopeT decls; - decl_node beginStatements; - decl_node finallyStatements; + decl_node__opaque beginStatements; + decl_node__opaque finallyStatements; bool enumsComplete; bool constsComplete; bool visited; @@ -826,9 +654,9 @@ struct decl_impT_r { Indexing_Index importedModules; decl_fixupInfo constFixup; decl_fixupInfo enumFixup; - decl_node beginStatements; - decl_node finallyStatements; - decl_node definitionModule; + decl_node__opaque beginStatements; + decl_node__opaque finallyStatements; + decl_node__opaque definitionModule; decl_scopeT decls; bool enumsComplete; bool constsComplete; @@ -836,60 +664,6 @@ struct decl_impT_r { decl_commentPair com; }; -struct DynamicStrings_Contents_r { - DynamicStrings__T7 buf; - unsigned int len; - DynamicStrings_String next; - }; - -struct wlists__T9_r { - unsigned int noOfElements; - wlists__T10 elements; - wlists_wlist next; - }; - -struct alists__T13_r { - unsigned int noOfelements; - alists__T14 elements; - alists_alist next; - }; - -struct mcPretty__T12_r { - mcPretty_writeProc write_; - mcPretty_writeLnProc writeln; - bool needsSpace; - bool needsIndent; - unsigned int seekPos; - unsigned int curLine; - unsigned int curPos; - unsigned int indent; - mcPretty_pretty stacked; - }; - -typedef struct DynamicStrings_descriptor_r DynamicStrings_descriptor; - -typedef DynamicStrings_descriptor *DynamicStrings_Descriptor; - -typedef struct DynamicStrings_DebugInfo_r DynamicStrings_DebugInfo; - -typedef enum {DynamicStrings_inuse, DynamicStrings_marked, DynamicStrings_onlist, DynamicStrings_poisoned} DynamicStrings_desState; - -struct DynamicStrings_descriptor_r { - bool charStarUsed; - void *charStar; - unsigned int charStarSize; - bool charStarValid; - DynamicStrings_desState state; - DynamicStrings_String garbage; - }; - -struct DynamicStrings_DebugInfo_r { - DynamicStrings_String next; - void *file; - unsigned int line; - void *proc; - }; - struct decl_nodeRec_r { decl_nodeT kind; /* case tag */ union { @@ -944,82 +718,77 @@ struct decl_nodeRec_r { decl_vardeclT vardeclF; decl_funccallT funccallF; decl_setvalueT setvalueF; + decl_opaquecastT opaquecastF; }; decl_where at; }; -struct DynamicStrings_stringRecord_r { - DynamicStrings_Contents contents; - DynamicStrings_Descriptor head; - DynamicStrings_DebugInfo debug; - }; - static decl_group freeGroup; static decl_group globalGroup; static FIO_File outputFile; static decl_language lang; -static decl_node bitsperunitN; -static decl_node bitsperwordN; -static decl_node bitspercharN; -static decl_node unitsperwordN; -static decl_node mainModule; -static decl_node currentModule; -static decl_node defModule; -static decl_node systemN; -static decl_node addressN; -static decl_node locN; -static decl_node byteN; -static decl_node wordN; -static decl_node csizetN; -static decl_node cssizetN; -static decl_node adrN; -static decl_node sizeN; -static decl_node tsizeN; -static decl_node newN; -static decl_node disposeN; -static decl_node lengthN; -static decl_node incN; -static decl_node decN; -static decl_node inclN; -static decl_node exclN; -static decl_node highN; -static decl_node m2rtsN; -static decl_node haltN; -static decl_node throwN; -static decl_node chrN; -static decl_node capN; -static decl_node absN; -static decl_node floatN; -static decl_node truncN; -static decl_node ordN; -static decl_node valN; -static decl_node minN; -static decl_node maxN; -static decl_node booleanN; -static decl_node procN; -static decl_node charN; -static decl_node integerN; -static decl_node cardinalN; -static decl_node longcardN; -static decl_node shortcardN; -static decl_node longintN; -static decl_node shortintN; -static decl_node bitsetN; -static decl_node bitnumN; -static decl_node ztypeN; -static decl_node rtypeN; -static decl_node complexN; -static decl_node longcomplexN; -static decl_node shortcomplexN; -static decl_node cmplxN; -static decl_node reN; -static decl_node imN; -static decl_node realN; -static decl_node longrealN; -static decl_node shortrealN; -static decl_node nilN; -static decl_node trueN; -static decl_node falseN; +static decl_node__opaque bitsperunitN; +static decl_node__opaque bitsperwordN; +static decl_node__opaque bitspercharN; +static decl_node__opaque unitsperwordN; +static decl_node__opaque mainModule; +static decl_node__opaque currentModule; +static decl_node__opaque defModule; +static decl_node__opaque systemN; +static decl_node__opaque addressN; +static decl_node__opaque locN; +static decl_node__opaque byteN; +static decl_node__opaque wordN; +static decl_node__opaque csizetN; +static decl_node__opaque cssizetN; +static decl_node__opaque adrN; +static decl_node__opaque sizeN; +static decl_node__opaque tsizeN; +static decl_node__opaque newN; +static decl_node__opaque disposeN; +static decl_node__opaque lengthN; +static decl_node__opaque incN; +static decl_node__opaque decN; +static decl_node__opaque inclN; +static decl_node__opaque exclN; +static decl_node__opaque highN; +static decl_node__opaque m2rtsN; +static decl_node__opaque haltN; +static decl_node__opaque throwN; +static decl_node__opaque chrN; +static decl_node__opaque capN; +static decl_node__opaque absN; +static decl_node__opaque floatN; +static decl_node__opaque truncN; +static decl_node__opaque ordN; +static decl_node__opaque valN; +static decl_node__opaque minN; +static decl_node__opaque maxN; +static decl_node__opaque booleanN; +static decl_node__opaque procN; +static decl_node__opaque charN; +static decl_node__opaque integerN; +static decl_node__opaque cardinalN; +static decl_node__opaque longcardN; +static decl_node__opaque shortcardN; +static decl_node__opaque longintN; +static decl_node__opaque shortintN; +static decl_node__opaque bitsetN; +static decl_node__opaque bitnumN; +static decl_node__opaque ztypeN; +static decl_node__opaque rtypeN; +static decl_node__opaque complexN; +static decl_node__opaque longcomplexN; +static decl_node__opaque shortcomplexN; +static decl_node__opaque cmplxN; +static decl_node__opaque reN; +static decl_node__opaque imN; +static decl_node__opaque realN; +static decl_node__opaque longrealN; +static decl_node__opaque shortrealN; +static decl_node__opaque nilN; +static decl_node__opaque trueN; +static decl_node__opaque falseN; static Indexing_Index scopeStack; static Indexing_Index defUniverseI; static Indexing_Index modUniverseI; @@ -1031,52 +800,7 @@ static mcPretty_pretty doP; static bool mustVisitScope; static bool simplified; static unsigned int tempCount; -static decl_node globalNode; -extern "C" void SYSTEM_ShiftVal (unsigned int *s, unsigned int _s_high, unsigned int *d, unsigned int _d_high, unsigned int SetSizeInBits, int ShiftCount); -extern "C" void SYSTEM_ShiftLeft (unsigned int *s, unsigned int _s_high, unsigned int *d, unsigned int _d_high, unsigned int SetSizeInBits, unsigned int ShiftCount); -extern "C" void SYSTEM_ShiftRight (unsigned int *s, unsigned int _s_high, unsigned int *d, unsigned int _d_high, unsigned int SetSizeInBits, unsigned int ShiftCount); -extern "C" void SYSTEM_RotateVal (unsigned int *s, unsigned int _s_high, unsigned int *d, unsigned int _d_high, unsigned int SetSizeInBits, int RotateCount); -extern "C" void SYSTEM_RotateLeft (unsigned int *s, unsigned int _s_high, unsigned int *d, unsigned int _d_high, unsigned int SetSizeInBits, unsigned int RotateCount); -extern "C" void SYSTEM_RotateRight (unsigned int *s, unsigned int _s_high, unsigned int *d, unsigned int _d_high, unsigned int SetSizeInBits, unsigned int RotateCount); -extern "C" void M2RTS_ConstructModules (void * applicationmodule, void * libname, void * overrideliborder, int argc, void * argv, void * envp); -extern "C" void M2RTS_DeconstructModules (void * applicationmodule, void * libname, int argc, void * argv, void * envp); -extern "C" void M2RTS_RegisterModule (void * name, void * libname, M2RTS_ArgCVEnvP init, M2RTS_ArgCVEnvP fini, PROC dependencies); -extern "C" void M2RTS_RequestDependant (void * modulename, void * libname, void * dependantmodule, void * dependantlibname); -extern "C" bool M2RTS_InstallTerminationProcedure (PROC p); -extern "C" void M2RTS_ExecuteInitialProcedures (void); -extern "C" bool M2RTS_InstallInitialProcedure (PROC p); -extern "C" void M2RTS_ExecuteTerminationProcedures (void); -extern "C" void M2RTS_Terminate (void) __attribute__ ((noreturn)); -extern "C" void M2RTS_HALT (int exitcode) __attribute__ ((noreturn)); -extern "C" void M2RTS_Halt (const char *description_, unsigned int _description_high, const char *filename_, unsigned int _filename_high, const char *function_, unsigned int _function_high, unsigned int line) __attribute__ ((noreturn)); -extern "C" void M2RTS_HaltC (void * description, void * filename, void * function, unsigned int line) __attribute__ ((noreturn)); -extern "C" void M2RTS_ExitOnHalt (int e); -extern "C" void M2RTS_ErrorMessage (const char *message_, unsigned int _message_high, const char *filename_, unsigned int _filename_high, unsigned int line, const char *function_, unsigned int _function_high) __attribute__ ((noreturn)); -extern "C" unsigned int M2RTS_Length (const char *a_, unsigned int _a_high); -extern "C" void M2RTS_AssignmentException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn)); -extern "C" void M2RTS_ReturnException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn)); -extern "C" void M2RTS_IncException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn)); -extern "C" void M2RTS_DecException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn)); -extern "C" void M2RTS_InclException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn)); -extern "C" void M2RTS_ExclException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn)); -extern "C" void M2RTS_ShiftException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn)); -extern "C" void M2RTS_RotateException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn)); -extern "C" void M2RTS_StaticArraySubscriptException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn)); -extern "C" void M2RTS_DynamicArraySubscriptException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn)); -extern "C" void M2RTS_ForLoopBeginException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn)); -extern "C" void M2RTS_ForLoopToException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn)); -extern "C" void M2RTS_ForLoopEndException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn)); -extern "C" void M2RTS_PointerNilException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn)); -extern "C" void M2RTS_NoReturnException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn)); -extern "C" void M2RTS_CaseException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn)); -extern "C" void M2RTS_WholeNonPosDivException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn)); -extern "C" void M2RTS_WholeNonPosModException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn)); -extern "C" void M2RTS_WholeZeroDivException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn)); -extern "C" void M2RTS_WholeZeroRemException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn)); -extern "C" void M2RTS_WholeValueException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn)); -extern "C" void M2RTS_RealValueException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn)); -extern "C" void M2RTS_ParameterException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn)); -extern "C" void M2RTS_NoException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn)); +static decl_node__opaque globalNode; /* getDeclaredMod - returns the token number associated with the nodes declaration @@ -1266,6 +990,19 @@ extern "C" bool decl_isTypeHidden (decl_node n); extern "C" bool decl_hasHidden (decl_node n); +/* + putTypeOpaque - marks type, des, as being an opaque type. + TYPE des ; +*/ + +extern "C" void decl_putTypeOpaque (decl_node des); + +/* + isTypeOpaque - returns TRUE if type, n, is an opaque type. +*/ + +extern "C" bool decl_isTypeOpaque (decl_node n); + /* isVar - returns TRUE if node, n, is a type. */ @@ -1681,7 +1418,7 @@ extern "C" void decl_putCommentModProcedure (decl_node n); extern "C" decl_node decl_makeProcType (void); /* - putReturnType - sets the return type of procedure or proctype, proc, to, type. + putReturnType - sets the return type of procedure or proctype proc to type. */ extern "C" void decl_putReturnType (decl_node proc, decl_node type); @@ -2295,5261 +2032,5457 @@ extern "C" void decl_setLangM2 (void); */ extern "C" void decl_out (void); -extern "C" nameKey_Name nameKey_makeKey (const char *a_, unsigned int _a_high); -extern "C" nameKey_Name nameKey_makekey (void * a); -extern "C" void nameKey_getKey (nameKey_Name key, char *a, unsigned int _a_high); -extern "C" unsigned int nameKey_lengthKey (nameKey_Name key); -extern "C" bool nameKey_isKey (const char *a_, unsigned int _a_high); -extern "C" void nameKey_writeKey (nameKey_Name key); -extern "C" bool nameKey_isSameExcludingCase (nameKey_Name key1, nameKey_Name key2); -extern "C" void * nameKey_keyToCharStar (nameKey_Name key); -extern "C" symbolKey_symbolTree symbolKey_initTree (void); -extern "C" void symbolKey_killTree (symbolKey_symbolTree *t); -extern "C" void * symbolKey_getSymKey (symbolKey_symbolTree t, nameKey_Name name); -extern "C" void symbolKey_putSymKey (symbolKey_symbolTree t, nameKey_Name name, void * key); /* - delSymKey - deletes an entry in the binary tree. - - NB in order for this to work we must ensure that the InitTree sets - both left and right to NIL. + newNode - create and return a new node of kind k. */ -extern "C" void symbolKey_delSymKey (symbolKey_symbolTree t, nameKey_Name name); +static decl_node__opaque newNode (decl_nodeT k); /* - isEmptyTree - returns true if symbolTree, t, is empty. + disposeNode - dispose node, n. */ -extern "C" bool symbolKey_isEmptyTree (symbolKey_symbolTree t); +static void disposeNode (decl_node__opaque *n); /* - doesTreeContainAny - returns true if symbolTree, t, contains any - symbols which in turn return true when procedure, - p, is called with a symbol as its parameter. - The symbolTree root is empty apart from the field, - left, hence we need two procedures. + newGroup - */ -extern "C" bool symbolKey_doesTreeContainAny (symbolKey_symbolTree t, symbolKey_isSymbol p); +static void newGroup (decl_group *g); /* - foreachNodeDo - for each node in symbolTree, t, a procedure, p, - is called with the node symbol as its parameter. - The tree root node only contains a legal left pointer, - therefore we need two procedures to examine this tree. + initGroup - returns a group which with all lists initialized. */ -extern "C" void symbolKey_foreachNodeDo (symbolKey_symbolTree t, symbolKey_performOperation p); +static decl_group initGroup (void); /* - initComment - the start of a new comment has been seen by the lexical analyser. - A new comment block is created and all addText contents are placed - in this block. onlySpaces indicates whether we have only seen - spaces on this line. + killGroup - deallocate the group and place the group record into the freeGroup list. */ -extern "C" mcComment_commentDesc mcComment_initComment (bool onlySpaces); +static void killGroup (decl_group *g); /* - addText - cs is a C string (null terminated) which contains comment text. - This is appended to the comment, cd. + dupGroup - If g is not NIL then destroy g. + Return a duplicate of GlobalGroup (not g). */ -extern "C" void mcComment_addText (mcComment_commentDesc cd, void * cs); +static decl_group dupGroup (decl_group g); /* - getContent - returns the content of comment, cd. + equalGroup - return TRUE if group left = right. */ -extern "C" DynamicStrings_String mcComment_getContent (mcComment_commentDesc cd); +static bool equalGroup (decl_group left, decl_group right); /* - getCommentCharStar - returns the C string content of comment, cd. + isLocal - returns TRUE if symbol, n, is locally declared in a procedure. */ -extern "C" void * mcComment_getCommentCharStar (mcComment_commentDesc cd); +static bool isLocal (decl_node__opaque n); /* - setProcedureComment - changes the type of comment, cd, to a - procedure heading comment, - providing it has the procname as the first word. + importEnumFields - if, n, is an enumeration type import the all fields into module, m. */ -extern "C" void mcComment_setProcedureComment (mcComment_commentDesc cd, nameKey_Name procname); +static void importEnumFields (decl_node__opaque m, decl_node__opaque n); /* - getProcedureComment - returns the current procedure comment if available. + isComplex - returns TRUE if, n, is the complex type. */ -extern "C" DynamicStrings_String mcComment_getProcedureComment (mcComment_commentDesc cd); +static bool isComplex (decl_node__opaque n); /* - getAfterStatementComment - returns the current statement after comment if available. + isLongComplex - returns TRUE if, n, is the longcomplex type. */ -extern "C" DynamicStrings_String mcComment_getAfterStatementComment (mcComment_commentDesc cd); +static bool isLongComplex (decl_node__opaque n); /* - getInbodyStatementComment - returns the current statement after comment if available. + isShortComplex - returns TRUE if, n, is the shortcomplex type. */ -extern "C" DynamicStrings_String mcComment_getInbodyStatementComment (mcComment_commentDesc cd); +static bool isShortComplex (decl_node__opaque n); /* - isProcedureComment - returns TRUE if, cd, is a procedure comment. + isAProcType - returns TRUE if, n, is a proctype or proc node. */ -extern "C" bool mcComment_isProcedureComment (mcComment_commentDesc cd); +static bool isAProcType (decl_node__opaque n); /* - isBodyComment - returns TRUE if, cd, is a body comment. + initFixupInfo - initialize the fixupInfo record. */ -extern "C" bool mcComment_isBodyComment (mcComment_commentDesc cd); +static decl_fixupInfo initFixupInfo (void); /* - isAfterComment - returns TRUE if, cd, is an after comment. + makeDef - returns a definition module node named, n. */ -extern "C" bool mcComment_isAfterComment (mcComment_commentDesc cd); -extern "C" void mcDebug_assert (bool q); -extern "C" void mcDebug_writeDebug (const char *a_, unsigned int _a_high); -extern "C" void Storage_ALLOCATE (void * *a, unsigned int Size); -extern "C" void Storage_DEALLOCATE (void * *a, unsigned int Size); -extern "C" void Storage_REALLOCATE (void * *a, unsigned int Size); -extern "C" bool Storage_Available (unsigned int Size); -extern "C" bool SFIO_Exists (DynamicStrings_String fname); -extern "C" FIO_File SFIO_OpenToRead (DynamicStrings_String fname); -extern "C" FIO_File SFIO_OpenToWrite (DynamicStrings_String fname); -extern "C" FIO_File SFIO_OpenForRandom (DynamicStrings_String fname, bool towrite, bool newfile); -extern "C" DynamicStrings_String SFIO_WriteS (FIO_File file, DynamicStrings_String s); -extern "C" DynamicStrings_String SFIO_ReadS (FIO_File file); -extern "C" bool FIO_IsNoError (FIO_File f); -extern "C" bool FIO_IsActive (FIO_File f); -extern "C" bool FIO_Exists (const char *fname_, unsigned int _fname_high); -extern "C" FIO_File FIO_OpenToRead (const char *fname_, unsigned int _fname_high); -extern "C" FIO_File FIO_OpenToWrite (const char *fname_, unsigned int _fname_high); -extern "C" FIO_File FIO_OpenForRandom (const char *fname_, unsigned int _fname_high, bool towrite, bool newfile); -extern "C" void FIO_Close (FIO_File f); -extern "C" bool FIO_exists (void * fname, unsigned int flength); -extern "C" FIO_File FIO_openToRead (void * fname, unsigned int flength); -extern "C" FIO_File FIO_openToWrite (void * fname, unsigned int flength); -extern "C" FIO_File FIO_openForRandom (void * fname, unsigned int flength, bool towrite, bool newfile); -extern "C" void FIO_FlushBuffer (FIO_File f); -extern "C" unsigned int FIO_ReadNBytes (FIO_File f, unsigned int nBytes, void * dest); -extern "C" void FIO_ReadAny (FIO_File f, unsigned char *a, unsigned int _a_high); -extern "C" unsigned int FIO_WriteNBytes (FIO_File f, unsigned int nBytes, void * src); -extern "C" void FIO_WriteAny (FIO_File f, unsigned char *a, unsigned int _a_high); -extern "C" void FIO_WriteChar (FIO_File f, char ch); -extern "C" bool FIO_EOF (FIO_File f); -extern "C" bool FIO_EOLN (FIO_File f); -extern "C" bool FIO_WasEOLN (FIO_File f); -extern "C" char FIO_ReadChar (FIO_File f); -extern "C" void FIO_UnReadChar (FIO_File f, char ch); -extern "C" void FIO_WriteLine (FIO_File f); -extern "C" void FIO_WriteString (FIO_File f, const char *a_, unsigned int _a_high); -extern "C" void FIO_ReadString (FIO_File f, char *a, unsigned int _a_high); -extern "C" void FIO_WriteCardinal (FIO_File f, unsigned int c); -extern "C" unsigned int FIO_ReadCardinal (FIO_File f); -extern "C" int FIO_GetUnixFileDescriptor (FIO_File f); -extern "C" void FIO_SetPositionFromBeginning (FIO_File f, long int pos); -extern "C" void FIO_SetPositionFromEnd (FIO_File f, long int pos); -extern "C" long int FIO_FindPosition (FIO_File f); -extern "C" void FIO_GetFileName (FIO_File f, char *a, unsigned int _a_high); -extern "C" void * FIO_getFileName (FIO_File f); -extern "C" unsigned int FIO_getFileNameLength (FIO_File f); -extern "C" void FIO_FlushOutErr (void); +static decl_node__opaque makeDef (nameKey_Name n); /* - InitString - creates and returns a String type object. - Initial contents are, a. + makeImp - returns an implementation module node named, n. */ -extern "C" DynamicStrings_String DynamicStrings_InitString (const char *a_, unsigned int _a_high); +static decl_node__opaque makeImp (nameKey_Name n); /* - KillString - frees String, s, and its contents. - NIL is returned. + makeModule - returns a module node named, n. */ -extern "C" DynamicStrings_String DynamicStrings_KillString (DynamicStrings_String s); +static decl_node__opaque makeModule (nameKey_Name n); /* - Fin - finishes with a string, it calls KillString with, s. - The purpose of the procedure is to provide a short cut - to calling KillString and then testing the return result. + isDefForC - returns TRUE if the definition module was defined FOR "C". */ -extern "C" void DynamicStrings_Fin (DynamicStrings_String s); +static bool isDefForC (decl_node__opaque n); /* - InitStringCharStar - initializes and returns a String to contain the C string. + initDecls - initialize the decls, scopeT. */ -extern "C" DynamicStrings_String DynamicStrings_InitStringCharStar (void * a); +static void initDecls (decl_scopeT *decls); /* - InitStringChar - initializes and returns a String to contain the single character, ch. + addTo - adds node, d, to scope decls and returns, d. + It stores, d, in the symbols tree associated with decls. */ -extern "C" DynamicStrings_String DynamicStrings_InitStringChar (char ch); +static decl_node__opaque addTo (decl_scopeT *decls, decl_node__opaque d); /* - Mark - marks String, s, ready for garbage collection. + export - export node, n, from definition module, d. */ -extern "C" DynamicStrings_String DynamicStrings_Mark (DynamicStrings_String s); +static void export_ (decl_node__opaque d, decl_node__opaque n); /* - Length - returns the length of the String, s. + addToScope - adds node, n, to the current scope and returns, n. */ -extern "C" unsigned int DynamicStrings_Length (DynamicStrings_String s); +static decl_node__opaque addToScope (decl_node__opaque n); /* - ConCat - returns String, a, after the contents of, b, have been appended. + addModuleToScope - adds module, i, to module, m, scope. */ -extern "C" DynamicStrings_String DynamicStrings_ConCat (DynamicStrings_String a, DynamicStrings_String b); +static void addModuleToScope (decl_node__opaque m, decl_node__opaque i); /* - ConCatChar - returns String, a, after character, ch, has been appended. + completedEnum - assign boolean enumsComplete to TRUE if a definition, + implementation or module symbol. */ -extern "C" DynamicStrings_String DynamicStrings_ConCatChar (DynamicStrings_String a, char ch); +static void completedEnum (decl_node__opaque n); /* - Assign - assigns the contents of, b, into, a. - String, a, is returned. + setUnary - sets a unary node to contain, arg, a, and type, t. */ -extern "C" DynamicStrings_String DynamicStrings_Assign (DynamicStrings_String a, DynamicStrings_String b); +static void setUnary (decl_node__opaque u, decl_nodeT k, decl_node__opaque a, decl_node__opaque t); /* - ReplaceChar - returns string s after it has changed all occurances of from to to. + putVarBool - assigns the four booleans associated with a variable. */ -extern "C" DynamicStrings_String DynamicStrings_ReplaceChar (DynamicStrings_String s, char from, char to); +static void putVarBool (decl_node__opaque v, bool init, bool param, bool isvar, bool isused); /* - Dup - duplicate a String, s, returning the copy of s. + checkPtr - in C++ we need to create a typedef for a pointer + in case we need to use reinterpret_cast. */ -extern "C" DynamicStrings_String DynamicStrings_Dup (DynamicStrings_String s); +static decl_node__opaque checkPtr (decl_node__opaque n); /* - Add - returns a new String which contains the contents of a and b. + isVarDecl - returns TRUE if, n, is a vardecl node. */ -extern "C" DynamicStrings_String DynamicStrings_Add (DynamicStrings_String a, DynamicStrings_String b); +static bool isVarDecl (decl_node__opaque n); /* - Equal - returns TRUE if String, a, and, b, are equal. + makeVariablesFromParameters - creates variables which are really parameters. */ -extern "C" bool DynamicStrings_Equal (DynamicStrings_String a, DynamicStrings_String b); +static void makeVariablesFromParameters (decl_node__opaque proc, decl_node__opaque id, decl_node__opaque type, bool isvar, bool isused); /* - EqualCharStar - returns TRUE if contents of String, s, is the same as the - string, a. + addProcedureToScope - add a procedure name n and node d to the + current scope. */ -extern "C" bool DynamicStrings_EqualCharStar (DynamicStrings_String s, void * a); +static decl_node__opaque addProcedureToScope (decl_node__opaque d, nameKey_Name n); /* - EqualArray - returns TRUE if contents of String, s, is the same as the - string, a. + putProcTypeReturn - sets the return type of, proc, to, type. */ -extern "C" bool DynamicStrings_EqualArray (DynamicStrings_String s, const char *a_, unsigned int _a_high); +static void putProcTypeReturn (decl_node__opaque proc, decl_node__opaque type); /* - Mult - returns a new string which is n concatenations of String, s. + putProcTypeOptReturn - sets, proc, to have an optional return type. */ -extern "C" DynamicStrings_String DynamicStrings_Mult (DynamicStrings_String s, unsigned int n); +static void putProcTypeOptReturn (decl_node__opaque proc); /* - Slice - returns a new string which contains the elements - low..high-1 - - strings start at element 0 - Slice(s, 0, 2) will return elements 0, 1 but not 2 - Slice(s, 1, 3) will return elements 1, 2 but not 3 - Slice(s, 2, 0) will return elements 2..max - Slice(s, 3, -1) will return elements 3..max-1 - Slice(s, 4, -2) will return elements 4..max-2 + makeOptParameter - creates and returns an optarg. */ -extern "C" DynamicStrings_String DynamicStrings_Slice (DynamicStrings_String s, int low, int high); +static decl_node__opaque makeOptParameter (decl_node__opaque l, decl_node__opaque type, decl_node__opaque init); /* - Index - returns the indice of the first occurance of, ch, in - String, s. -1 is returned if, ch, does not exist. - The search starts at position, o. + setwatch - assign the globalNode to n. */ -extern "C" int DynamicStrings_Index (DynamicStrings_String s, char ch, unsigned int o); +static bool setwatch (decl_node__opaque n); /* - RIndex - returns the indice of the last occurance of, ch, - in String, s. The search starts at position, o. - -1 is returned if, ch, is not found. The search - is performed left to right. + runwatch - set the globalNode to an identlist. */ -extern "C" int DynamicStrings_RIndex (DynamicStrings_String s, char ch, unsigned int o); +static bool runwatch (void); /* - ReverseIndex - returns the indice of the last occurance of ch - in String s. The search starts at position o - and searches from right to left. The start position - may be indexed negatively from the right (-1 is the - last index). - The return value if ch is found will always be positive. - -1 is returned if ch is not found. + isIdentList - returns TRUE if, n, is an identlist. */ -extern "C" int DynamicStrings_ReverseIndex (DynamicStrings_String s, char ch, int o); +static bool isIdentList (decl_node__opaque n); /* - RemoveComment - assuming that, comment, is a comment delimiter - which indicates anything to its right is a comment - then strip off the comment and also any white space - on the remaining right hand side. - It leaves any white space on the left hand side alone. + identListLen - returns the length of identlist. */ -extern "C" DynamicStrings_String DynamicStrings_RemoveComment (DynamicStrings_String s, char comment); +static unsigned int identListLen (decl_node__opaque n); /* - RemoveWhitePrefix - removes any leading white space from String, s. - A new string is returned. + checkParameters - placeholder for future parameter checking. */ -extern "C" DynamicStrings_String DynamicStrings_RemoveWhitePrefix (DynamicStrings_String s); +static void checkParameters (decl_node__opaque p, decl_node__opaque i, decl_node__opaque type, bool isvar, bool isused); /* - RemoveWhitePostfix - removes any leading white space from String, s. - A new string is returned. + checkMakeVariables - create shadow local variables for parameters providing that + procedure n has not already been built and we are compiling + a module or an implementation module. */ -extern "C" DynamicStrings_String DynamicStrings_RemoveWhitePostfix (DynamicStrings_String s); +static void checkMakeVariables (decl_node__opaque n, decl_node__opaque i, decl_node__opaque type, bool isvar, bool isused); /* - ToUpper - returns string, s, after it has had its lower case characters - replaced by upper case characters. - The string, s, is not duplicated. + makeVarientField - create a varient field within varient, v, + The new varient field is returned. */ -extern "C" DynamicStrings_String DynamicStrings_ToUpper (DynamicStrings_String s); +static decl_node__opaque makeVarientField (decl_node__opaque v, decl_node__opaque p); /* - ToLower - returns string, s, after it has had its upper case characters - replaced by lower case characters. - The string, s, is not duplicated. + putFieldVarient - places the field varient, f, as a brother to, the + varient symbol, v, and also tells, f, that its varient + parent is, v. */ -extern "C" DynamicStrings_String DynamicStrings_ToLower (DynamicStrings_String s); +static void putFieldVarient (decl_node__opaque f, decl_node__opaque v); /* - CopyOut - copies string, s, to a. + putFieldRecord - create a new recordfield and place it into record r. + The new field has a tagname and type and can have a + variant field v. */ -extern "C" void DynamicStrings_CopyOut (char *a, unsigned int _a_high, DynamicStrings_String s); +static decl_node__opaque putFieldRecord (decl_node__opaque r, nameKey_Name tag, decl_node__opaque type, decl_node__opaque v); /* - char - returns the character, ch, at position, i, in String, s. + ensureOrder - ensures that, a, and, b, exist in, i, and also + ensure that, a, is before, b. */ -extern "C" char DynamicStrings_char (DynamicStrings_String s, int i); +static void ensureOrder (Indexing_Index i, decl_node__opaque a, decl_node__opaque b); /* - string - returns the C style char * of String, s. + putVarientTag - places tag into variant v. */ -extern "C" void * DynamicStrings_string (DynamicStrings_String s); +static void putVarientTag (decl_node__opaque v, decl_node__opaque tag); /* - InitStringDB - the debug version of InitString. + getParent - returns the parent field of recordfield or varientfield symbol, n. */ -extern "C" DynamicStrings_String DynamicStrings_InitStringDB (const char *a_, unsigned int _a_high, const char *file_, unsigned int _file_high, unsigned int line); +static decl_node__opaque getParent (decl_node__opaque n); /* - InitStringCharStarDB - the debug version of InitStringCharStar. + getRecord - returns the record associated with node, n. + (Parental record). */ -extern "C" DynamicStrings_String DynamicStrings_InitStringCharStarDB (void * a, const char *file_, unsigned int _file_high, unsigned int line); +static decl_node__opaque getRecord (decl_node__opaque n); /* - InitStringCharDB - the debug version of InitStringChar. + isConstExp - return TRUE if the node kind is a constexp. */ -extern "C" DynamicStrings_String DynamicStrings_InitStringCharDB (char ch, const char *file_, unsigned int _file_high, unsigned int line); +static bool isConstExp (decl_node__opaque c); /* - MultDB - the debug version of MultDB. + addEnumToModule - adds enumeration type, e, into the list of enums + in module, m. */ -extern "C" DynamicStrings_String DynamicStrings_MultDB (DynamicStrings_String s, unsigned int n, const char *file_, unsigned int _file_high, unsigned int line); +static void addEnumToModule (decl_node__opaque m, decl_node__opaque e); /* - DupDB - the debug version of Dup. + getNextFixup - return the next fixup from from f. */ -extern "C" DynamicStrings_String DynamicStrings_DupDB (DynamicStrings_String s, const char *file_, unsigned int _file_high, unsigned int line); +static decl_node__opaque getNextFixup (decl_fixupInfo *f); /* - SliceDB - debug version of Slice. + doMakeEnum - create an enumeration type and add it to the current module. */ -extern "C" DynamicStrings_String DynamicStrings_SliceDB (DynamicStrings_String s, int low, int high, const char *file_, unsigned int _file_high, unsigned int line); +static decl_node__opaque doMakeEnum (void); /* - PushAllocation - pushes the current allocation/deallocation lists. + doMakeEnumField - create an enumeration field name and add it to enumeration e. + Return the new field. */ -extern "C" void DynamicStrings_PushAllocation (void); +static decl_node__opaque doMakeEnumField (decl_node__opaque e, nameKey_Name n); /* - PopAllocation - test to see that all strings are deallocated since - the last push. Then it pops to the previous - allocation/deallocation lists. - - If halt is true then the application terminates - with an exit code of 1. + getExpList - returns the, n, th argument in an explist. */ -extern "C" void DynamicStrings_PopAllocation (bool halt); +static decl_node__opaque getExpList (decl_node__opaque p, unsigned int n); /* - PopAllocationExemption - test to see that all strings are deallocated, except - string e since the last push. - Post-condition: it pops to the previous allocation/deallocation - lists. - - If halt is true then the application terminates - with an exit code of 1. + expListLen - returns the length of explist, p. */ -extern "C" DynamicStrings_String DynamicStrings_PopAllocationExemption (bool halt, DynamicStrings_String e); -extern "C" DynamicStrings_String StringConvert_IntegerToString (int i, unsigned int width, char padding, bool sign, unsigned int base, bool lower); -extern "C" DynamicStrings_String StringConvert_CardinalToString (unsigned int c, unsigned int width, char padding, unsigned int base, bool lower); -extern "C" int StringConvert_StringToInteger (DynamicStrings_String s, unsigned int base, bool *found); -extern "C" unsigned int StringConvert_StringToCardinal (DynamicStrings_String s, unsigned int base, bool *found); -extern "C" DynamicStrings_String StringConvert_LongIntegerToString (long int i, unsigned int width, char padding, bool sign, unsigned int base, bool lower); -extern "C" long int StringConvert_StringToLongInteger (DynamicStrings_String s, unsigned int base, bool *found); -extern "C" DynamicStrings_String StringConvert_LongCardinalToString (long unsigned int c, unsigned int width, char padding, unsigned int base, bool lower); -extern "C" long unsigned int StringConvert_StringToLongCardinal (DynamicStrings_String s, unsigned int base, bool *found); -extern "C" DynamicStrings_String StringConvert_ShortCardinalToString (short unsigned int c, unsigned int width, char padding, unsigned int base, bool lower); -extern "C" short unsigned int StringConvert_StringToShortCardinal (DynamicStrings_String s, unsigned int base, bool *found); -extern "C" int StringConvert_stoi (DynamicStrings_String s); -extern "C" DynamicStrings_String StringConvert_itos (int i, unsigned int width, char padding, bool sign); -extern "C" DynamicStrings_String StringConvert_ctos (unsigned int c, unsigned int width, char padding); -extern "C" unsigned int StringConvert_stoc (DynamicStrings_String s); -extern "C" int StringConvert_hstoi (DynamicStrings_String s); -extern "C" int StringConvert_ostoi (DynamicStrings_String s); -extern "C" int StringConvert_bstoi (DynamicStrings_String s); -extern "C" unsigned int StringConvert_hstoc (DynamicStrings_String s); -extern "C" unsigned int StringConvert_ostoc (DynamicStrings_String s); -extern "C" unsigned int StringConvert_bstoc (DynamicStrings_String s); -extern "C" long double StringConvert_StringToLongreal (DynamicStrings_String s, bool *found); -extern "C" DynamicStrings_String StringConvert_LongrealToString (long double x, unsigned int TotalWidth, unsigned int FractionWidth); -extern "C" double StringConvert_stor (DynamicStrings_String s); -extern "C" long double StringConvert_stolr (DynamicStrings_String s); -extern "C" DynamicStrings_String StringConvert_ToSigFig (DynamicStrings_String s, unsigned int n); -extern "C" DynamicStrings_String StringConvert_ToDecimalPlaces (DynamicStrings_String s, unsigned int n); -extern "C" DynamicStrings_String mcOptions_handleOptions (void); -extern "C" bool mcOptions_getQuiet (void); -extern "C" bool mcOptions_getVerbose (void); -extern "C" bool mcOptions_getInternalDebugging (void); -extern "C" DynamicStrings_String mcOptions_getCppCommandLine (void); -extern "C" DynamicStrings_String mcOptions_getOutputFile (void); -extern "C" bool mcOptions_getExtendedOpaque (void); -extern "C" void mcOptions_setDebugTopological (bool value); -extern "C" bool mcOptions_getDebugTopological (void); -extern "C" DynamicStrings_String mcOptions_getHPrefix (void); -extern "C" bool mcOptions_getIgnoreFQ (void); -extern "C" bool mcOptions_getGccConfigSystem (void); -extern "C" bool mcOptions_getScaffoldDynamic (void); -extern "C" bool mcOptions_getScaffoldMain (void); -extern "C" void mcOptions_writeGPLheader (FIO_File f); -extern "C" void mcOptions_setSuppressNoReturn (bool value); -extern "C" bool mcOptions_getSuppressNoReturn (void); -extern "C" bool mcOptions_useBool (void); -extern "C" DynamicStrings_String mcOptions_getCRealType (void); -extern "C" DynamicStrings_String mcOptions_getCLongRealType (void); -extern "C" DynamicStrings_String mcOptions_getCShortRealType (void); -extern "C" DynamicStrings_String FormatStrings_Sprintf0 (DynamicStrings_String fmt); -extern "C" DynamicStrings_String FormatStrings_Sprintf1 (DynamicStrings_String fmt, const unsigned char *w_, unsigned int _w_high); -extern "C" DynamicStrings_String FormatStrings_Sprintf2 (DynamicStrings_String fmt, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high); -extern "C" DynamicStrings_String FormatStrings_Sprintf3 (DynamicStrings_String fmt, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high); -extern "C" DynamicStrings_String FormatStrings_Sprintf4 (DynamicStrings_String fmt, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high, const unsigned char *w4_, unsigned int _w4_high); -extern "C" DynamicStrings_String FormatStrings_HandleEscape (DynamicStrings_String s); -extern "C" ssize_t libc_write (int d, void * buf, size_t nbytes); -extern "C" ssize_t libc_read (int d, void * buf, size_t nbytes); -extern "C" int libc_system (void * a); -extern "C" void libc_abort (void) __attribute__ ((noreturn)); -extern "C" void * libc_malloc (size_t size); -extern "C" void libc_free (void * ptr); -extern "C" void * libc_realloc (void * ptr, size_t size); -extern "C" int libc_isatty (int fd); -extern "C" void libc_exit (int r) __attribute__ ((noreturn)); -extern "C" void * libc_getenv (void * s); -extern "C" int libc_putenv (void * s); -extern "C" int libc_getpid (void); -extern "C" int libc_dup (int d); -extern "C" int libc_close (int d); -extern "C" int libc_open (void * filename, int oflag, ...); -extern "C" int libc_creat (void * filename, unsigned int mode); -extern "C" ssize_t libc_lseek (int fd, ssize_t offset, int whence); -extern "C" void libc_perror (const char *string_, unsigned int _string_high); -extern "C" int libc_readv (int fd, void * v, int n); -extern "C" int libc_writev (int fd, void * v, int n); -extern "C" void * libc_getcwd (void * buf, size_t size); -extern "C" int libc_chown (void * filename, int uid, int gid); -extern "C" size_t libc_strlen (void * a); -extern "C" void * libc_strcpy (void * dest, void * src); -extern "C" void * libc_strncpy (void * dest, void * src, unsigned int n); -extern "C" int libc_unlink (void * file); -extern "C" void * libc_memcpy (void * dest, void * src, size_t size); -extern "C" void * libc_memset (void * s, int c, size_t size); -extern "C" void * libc_memmove (void * dest, void * src, size_t size); -extern "C" int libc_printf (const char *format_, unsigned int _format_high, ...); -extern "C" int libc_snprintf (void * dest, size_t size, const char *format_, unsigned int _format_high, ...); -extern "C" int libc_setenv (void * name, void * value, int overwrite); -extern "C" void libc_srand (int seed); -extern "C" int libc_rand (void); -extern "C" libc_time_t libc_time (void * a); -extern "C" void * libc_localtime (libc_time_t *t); -extern "C" int libc_ftime (libc_timeb *t); -extern "C" int libc_shutdown (int s, int how); -extern "C" int libc_rename (void * oldpath, void * newpath); -extern "C" int libc_setjmp (void * env); -extern "C" void libc_longjmp (void * env, int val); -extern "C" int libc_atexit (libc_exitP_C proc); -extern "C" void * libc_ttyname (int filedes); -extern "C" unsigned int libc_sleep (unsigned int seconds); -extern "C" int libc_execv (void * pathname, void * argv); -extern "C" void mcMetaError_metaError1 (const char *m_, unsigned int _m_high, const unsigned char *s_, unsigned int _s_high); -extern "C" void mcMetaError_metaError2 (const char *m_, unsigned int _m_high, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high); -extern "C" void mcMetaError_metaError3 (const char *m_, unsigned int _m_high, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high, const unsigned char *s3_, unsigned int _s3_high); -extern "C" void mcMetaError_metaError4 (const char *m_, unsigned int _m_high, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high, const unsigned char *s3_, unsigned int _s3_high, const unsigned char *s4_, unsigned int _s4_high); -extern "C" void mcMetaError_metaErrors1 (const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, const unsigned char *s_, unsigned int _s_high); -extern "C" void mcMetaError_metaErrors2 (const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high); -extern "C" void mcMetaError_metaErrors3 (const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high, const unsigned char *s3_, unsigned int _s3_high); -extern "C" void mcMetaError_metaErrors4 (const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high, const unsigned char *s3_, unsigned int _s3_high, const unsigned char *s4_, unsigned int _s4_high); -extern "C" void mcMetaError_metaErrorT1 (unsigned int tok, const char *m_, unsigned int _m_high, const unsigned char *s_, unsigned int _s_high); -extern "C" void mcMetaError_metaErrorT2 (unsigned int tok, const char *m_, unsigned int _m_high, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high); -extern "C" void mcMetaError_metaErrorT3 (unsigned int tok, const char *m_, unsigned int _m_high, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high, const unsigned char *s3_, unsigned int _s3_high); -extern "C" void mcMetaError_metaErrorT4 (unsigned int tok, const char *m_, unsigned int _m_high, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high, const unsigned char *s3_, unsigned int _s3_high, const unsigned char *s4_, unsigned int _s4_high); -extern "C" void mcMetaError_metaErrorsT1 (unsigned int tok, const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, const unsigned char *s_, unsigned int _s_high); -extern "C" void mcMetaError_metaErrorsT2 (unsigned int tok, const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high); -extern "C" void mcMetaError_metaErrorsT3 (unsigned int tok, const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high, const unsigned char *s3_, unsigned int _s3_high); -extern "C" void mcMetaError_metaErrorsT4 (unsigned int tok, const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high, const unsigned char *s3_, unsigned int _s3_high, const unsigned char *s4_, unsigned int _s4_high); -extern "C" void mcMetaError_metaErrorString1 (DynamicStrings_String m, const unsigned char *s_, unsigned int _s_high); -extern "C" void mcMetaError_metaErrorString2 (DynamicStrings_String m, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high); -extern "C" void mcMetaError_metaErrorString3 (DynamicStrings_String m, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high, const unsigned char *s3_, unsigned int _s3_high); -extern "C" void mcMetaError_metaErrorString4 (DynamicStrings_String m, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high, const unsigned char *s3_, unsigned int _s3_high, const unsigned char *s4_, unsigned int _s4_high); -extern "C" void mcMetaError_metaErrorStringT1 (unsigned int tok, DynamicStrings_String m, const unsigned char *s_, unsigned int _s_high); -extern "C" void mcMetaError_metaErrorStringT2 (unsigned int tok, DynamicStrings_String m, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high); -extern "C" void mcMetaError_metaErrorStringT3 (unsigned int tok, DynamicStrings_String m, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high, const unsigned char *s3_, unsigned int _s3_high); -extern "C" void mcMetaError_metaErrorStringT4 (unsigned int tok, DynamicStrings_String m, const unsigned char *s1_, unsigned int _s1_high, const unsigned char *s2_, unsigned int _s2_high, const unsigned char *s3_, unsigned int _s3_high, const unsigned char *s4_, unsigned int _s4_high); +static unsigned int expListLen (decl_node__opaque p); /* - internalError - displays an internal error message together with the compiler source - file and line number. - This function is not buffered and is used when the compiler is about - to give up. + getConstExpComplete - gets the field from the def or imp or module, n. */ -extern "C" void mcError_internalError (const char *a_, unsigned int _a_high, const char *file_, unsigned int _file_high, unsigned int line); +static bool getConstExpComplete (decl_node__opaque n); /* - writeFormat0 - displays the source module and line together - with the encapsulated format string. - Used for simple error messages tied to the current token. + addConstToModule - adds const exp, e, into the list of constant + expressions in module, m. */ -extern "C" void mcError_writeFormat0 (const char *a_, unsigned int _a_high); +static void addConstToModule (decl_node__opaque m, decl_node__opaque e); /* - writeFormat1 - displays the source module and line together - with the encapsulated format string. - Used for simple error messages tied to the current token. + doMakeConstExp - create a constexp node and add it to the current module. */ -extern "C" void mcError_writeFormat1 (const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high); +static decl_node__opaque doMakeConstExp (void); /* - writeFormat2 - displays the module and line together with the encapsulated - format strings. - Used for simple error messages tied to the current token. + isAnyType - return TRUE if node n is any type kind. */ -extern "C" void mcError_writeFormat2 (const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high); +static bool isAnyType (decl_node__opaque n); /* - writeFormat3 - displays the module and line together with the encapsulated - format strings. - Used for simple error messages tied to the current token. + makeVal - creates a VAL (type, expression) node. */ -extern "C" void mcError_writeFormat3 (const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high); +static decl_node__opaque makeVal (decl_node__opaque params); /* - newError - creates and returns a new error handle. + makeCast - creates a cast node TYPENAME (expr). */ -extern "C" mcError_error mcError_newError (unsigned int atTokenNo); +static decl_node__opaque makeCast (decl_node__opaque c, decl_node__opaque p); +static decl_node__opaque makeIntrinsicProc (decl_nodeT k, unsigned int noArgs, decl_node__opaque p); /* - newWarning - creates and returns a new error handle suitable for a warning. - A warning will not stop compilation. + makeIntrinsicUnaryType - create an intrisic unary type. */ -extern "C" mcError_error mcError_newWarning (unsigned int atTokenNo); +static decl_node__opaque makeIntrinsicUnaryType (decl_nodeT k, decl_node__opaque paramList, decl_node__opaque returnType); /* - chainError - creates and returns a new error handle, this new error - is associated with, e, and is chained onto the end of, e. - If, e, is NIL then the result to NewError is returned. + makeIntrinsicBinaryType - create an intrisic binary type. */ -extern "C" mcError_error mcError_chainError (unsigned int atTokenNo, mcError_error e); -extern "C" void mcError_errorFormat0 (mcError_error e, const char *a_, unsigned int _a_high); -extern "C" void mcError_errorFormat1 (mcError_error e, const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high); -extern "C" void mcError_errorFormat2 (mcError_error e, const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high); -extern "C" void mcError_errorFormat3 (mcError_error e, const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high); -extern "C" void mcError_errorString (mcError_error e, DynamicStrings_String str); +static decl_node__opaque makeIntrinsicBinaryType (decl_nodeT k, decl_node__opaque paramList, decl_node__opaque returnType); /* - errorStringAt - given an error string, s, it places this - string at token position, tok. - The string is consumed. + checkIntrinsic - checks to see if the function call to, c, with + parameter list, n, is really an intrinic. If it + is an intrinic then an intrinic node is created + and returned. Otherwise NIL is returned. */ -extern "C" void mcError_errorStringAt (DynamicStrings_String s, unsigned int tok); +static decl_node__opaque checkIntrinsic (decl_node__opaque c, decl_node__opaque n); /* - errorStringAt2 - given an error string, s, it places this - string at token positions, tok1 and tok2, respectively. - The string is consumed. + checkCHeaders - check to see if the function is a C system function and + requires a header file included. */ -extern "C" void mcError_errorStringAt2 (DynamicStrings_String s, unsigned int tok1, unsigned int tok2); +static void checkCHeaders (decl_node__opaque c); /* - errorStringsAt2 - given error strings, s1, and, s2, it places these - strings at token positions, tok1 and tok2, respectively. - Both strings are consumed. + isFuncCall - returns TRUE if, n, is a function/procedure call. */ -extern "C" void mcError_errorStringsAt2 (DynamicStrings_String s1, DynamicStrings_String s2, unsigned int tok1, unsigned int tok2); +static bool isFuncCall (decl_node__opaque n); /* - warnStringAt - given an error string, s, it places this - string at token position, tok. - The string is consumed. + putTypeInternal - marks type, des, as being an internally generated type. */ -extern "C" void mcError_warnStringAt (DynamicStrings_String s, unsigned int tok); +static void putTypeInternal (decl_node__opaque des); /* - warnStringAt2 - given an warning string, s, it places this - string at token positions, tok1 and tok2, respectively. - The string is consumed. + isTypeInternal - returns TRUE if type, n, is internal. */ -extern "C" void mcError_warnStringAt2 (DynamicStrings_String s, unsigned int tok1, unsigned int tok2); +static bool isTypeInternal (decl_node__opaque n); /* - warnStringsAt2 - given warning strings, s1, and, s2, it places these - strings at token positions, tok1 and tok2, respectively. - Both strings are consumed. + lookupBase - return node named n from the base symbol scope. */ -extern "C" void mcError_warnStringsAt2 (DynamicStrings_String s1, DynamicStrings_String s2, unsigned int tok1, unsigned int tok2); -extern "C" void mcError_warnFormat0 (const char *a_, unsigned int _a_high); +static decl_node__opaque lookupBase (nameKey_Name n); /* - warnFormat1 - displays the source module and line together - with the encapsulated format string. - Used for simple warning messages tied to the current token. + dumpScopes - display the names of all the scopes stacked. */ -extern "C" void mcError_warnFormat1 (const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high); +static void dumpScopes (void); /* - flushErrors - switches the output channel to the error channel - and then writes out all errors. + out0 - write string a to StdOut. */ -extern "C" void mcError_flushErrors (void); +static void out0 (const char *a_, unsigned int _a_high); /* - flushWarnings - switches the output channel to the error channel - and then writes out all warnings. - If an error is present the compilation is terminated, - if warnings only were emitted then compilation will - continue. + out1 - write string a to StdOut using format specifier a. */ -extern "C" void mcError_flushWarnings (void); +static void out1 (const char *a_, unsigned int _a_high, decl_node__opaque s); /* - errorAbort0 - aborts compiling, it flushes all warnings and errors before aborting. + out2 - write string a to StdOut using format specifier a. */ -extern "C" void mcError_errorAbort0 (const char *a_, unsigned int _a_high); -extern "C" mcComment_commentDesc mcLexBuf_getProcedureComment (void); -extern "C" mcComment_commentDesc mcLexBuf_getBodyComment (void); -extern "C" mcComment_commentDesc mcLexBuf_getAfterComment (void); -extern "C" bool mcLexBuf_openSource (DynamicStrings_String s); -extern "C" void mcLexBuf_closeSource (void); -extern "C" void mcLexBuf_reInitialize (void); -extern "C" void mcLexBuf_resetForNewPass (void); -extern "C" void mcLexBuf_getToken (void); -extern "C" void mcLexBuf_insertToken (mcReserved_toktype token); -extern "C" void mcLexBuf_insertTokenAndRewind (mcReserved_toktype token); -extern "C" unsigned int mcLexBuf_getPreviousTokenLineNo (void); -extern "C" unsigned int mcLexBuf_getLineNo (void); -extern "C" unsigned int mcLexBuf_getTokenNo (void); -extern "C" unsigned int mcLexBuf_tokenToLineNo (unsigned int tokenNo, unsigned int depth); -extern "C" unsigned int mcLexBuf_getColumnNo (void); -extern "C" unsigned int mcLexBuf_tokenToColumnNo (unsigned int tokenNo, unsigned int depth); -extern "C" DynamicStrings_String mcLexBuf_findFileNameFromToken (unsigned int tokenNo, unsigned int depth); -extern "C" DynamicStrings_String mcLexBuf_getFileName (void); -extern "C" void mcLexBuf_addTok (mcReserved_toktype t); -extern "C" void mcLexBuf_addTokCharStar (mcReserved_toktype t, void * s); -extern "C" void mcLexBuf_addTokInteger (mcReserved_toktype t, int i); -extern "C" void mcLexBuf_addTokComment (mcReserved_toktype t, mcComment_commentDesc com); -extern "C" void mcLexBuf_setFile (void * filename); -extern "C" void mcLexBuf_pushFile (void * filename); -extern "C" void mcLexBuf_popFile (void * filename); -extern "C" void StrLib_StrConCat (const char *a_, unsigned int _a_high, const char *b_, unsigned int _b_high, char *c, unsigned int _c_high); -extern "C" bool StrLib_StrLess (const char *a_, unsigned int _a_high, const char *b_, unsigned int _b_high); -extern "C" bool StrLib_StrEqual (const char *a_, unsigned int _a_high, const char *b_, unsigned int _b_high); -extern "C" unsigned int StrLib_StrLen (const char *a_, unsigned int _a_high); -extern "C" void StrLib_StrCopy (const char *src_, unsigned int _src_high, char *dest, unsigned int _dest_high); -extern "C" bool StrLib_IsSubString (const char *a_, unsigned int _a_high, const char *b_, unsigned int _b_high); -extern "C" void StrLib_StrRemoveWhitePrefix (const char *a_, unsigned int _a_high, char *b, unsigned int _b_high); +static void out2 (const char *a_, unsigned int _a_high, unsigned int c, decl_node__opaque s); /* - initPretty - initialise a pretty print data structure. + out3 - write string a to StdOut using format specifier a. */ -extern "C" mcPretty_pretty mcPretty_initPretty (mcPretty_writeProc w, mcPretty_writeLnProc l); +static void out3 (const char *a_, unsigned int _a_high, unsigned int l, nameKey_Name n, decl_node__opaque s); /* - dupPretty - duplicate a pretty print data structure. + isUnary - returns TRUE if, n, is an unary node. */ -extern "C" mcPretty_pretty mcPretty_dupPretty (mcPretty_pretty p); +static bool isUnary (decl_node__opaque n); /* - killPretty - destroy a pretty print data structure. - Post condition: p is assigned to NIL. + isBinary - returns TRUE if, n, is an binary node. */ -extern "C" void mcPretty_killPretty (mcPretty_pretty *p); +static bool isBinary (decl_node__opaque n); /* - pushPretty - duplicate, p. Push, p, and return the duplicate. + makeUnary - create a unary expression node with, e, as the argument + and res as the return type. */ -extern "C" mcPretty_pretty mcPretty_pushPretty (mcPretty_pretty p); +static decl_node__opaque makeUnary (decl_nodeT k, decl_node__opaque e, decl_node__opaque res); /* - popPretty - pops the pretty object from the stack. + isLeafString - returns TRUE if n is a leaf node which is a string constant. */ -extern "C" mcPretty_pretty mcPretty_popPretty (mcPretty_pretty p); +static bool isLeafString (decl_node__opaque n); /* - getindent - returns the current indent value. + getLiteralStringContents - return the contents of a literal node as a string. */ -extern "C" unsigned int mcPretty_getindent (mcPretty_pretty p); +static DynamicStrings_String getLiteralStringContents (decl_node__opaque n); /* - setindent - sets the current indent to, n. + getStringContents - return the string contents of a constant, literal, + string or a constexp node. */ -extern "C" void mcPretty_setindent (mcPretty_pretty p, unsigned int n); +static DynamicStrings_String getStringContents (decl_node__opaque n); /* - getcurpos - returns the current cursor position. + addNames - */ -extern "C" unsigned int mcPretty_getcurpos (mcPretty_pretty s); +static nameKey_Name addNames (decl_node__opaque a, decl_node__opaque b); /* - getseekpos - returns the seek position. + resolveString - */ -extern "C" unsigned int mcPretty_getseekpos (mcPretty_pretty s); +static decl_node__opaque resolveString (decl_node__opaque n); /* - getcurline - returns the current line number. + foldBinary - */ -extern "C" unsigned int mcPretty_getcurline (mcPretty_pretty s); -extern "C" void mcPretty_setNeedSpace (mcPretty_pretty s); +static decl_node__opaque foldBinary (decl_nodeT k, decl_node__opaque l, decl_node__opaque r, decl_node__opaque res); /* - noSpace - unset needsSpace. + makeBinary - create a binary node with left/right/result type: l, r and resultType. */ -extern "C" void mcPretty_noSpace (mcPretty_pretty s); +static decl_node__opaque makeBinary (decl_nodeT k, decl_node__opaque l, decl_node__opaque r, decl_node__opaque resultType); /* - print - print a string using, p. + doMakeBinary - returns a binary node containing left/right/result values + l, r, res, with a node operator, k. */ -extern "C" void mcPretty_print (mcPretty_pretty p, const char *a_, unsigned int _a_high); +static decl_node__opaque doMakeBinary (decl_nodeT k, decl_node__opaque l, decl_node__opaque r, decl_node__opaque res); /* - prints - print a string using, p. + doMakeComponentRef - */ -extern "C" void mcPretty_prints (mcPretty_pretty p, DynamicStrings_String s); +static decl_node__opaque doMakeComponentRef (decl_node__opaque rec, decl_node__opaque field); /* - raw - print out string, s, without any translation of - escape sequences. + isComponentRef - */ -extern "C" void mcPretty_raw (mcPretty_pretty p, DynamicStrings_String s); +static bool isComponentRef (decl_node__opaque n); /* - InitIndex - creates and returns an Index. + isArrayRef - returns TRUE if the node was an arrayref. */ -extern "C" Indexing_Index Indexing_InitIndex (unsigned int low); +static bool isArrayRef (decl_node__opaque n); /* - KillIndex - returns Index to free storage. + isDeref - returns TRUE if, n, is a deref node. */ -extern "C" Indexing_Index Indexing_KillIndex (Indexing_Index i); +static bool isDeref (decl_node__opaque n); /* - DebugIndex - turns on debugging within an index. + makeBase - create a base type or constant. + It only supports the base types and constants + enumerated below. */ -extern "C" Indexing_Index Indexing_DebugIndex (Indexing_Index i); +static decl_node__opaque makeBase (decl_nodeT k); /* - InBounds - returns TRUE if indice, n, is within the bounds - of the dynamic array. + isOrdinal - returns TRUE if, n, is an ordinal type. */ -extern "C" bool Indexing_InBounds (Indexing_Index i, unsigned int n); +static bool isOrdinal (decl_node__opaque n); /* - HighIndice - returns the last legally accessible indice of this array. + mixTypes - */ -extern "C" unsigned int Indexing_HighIndice (Indexing_Index i); +static decl_node__opaque mixTypes (decl_node__opaque a, decl_node__opaque b); /* - LowIndice - returns the first legally accessible indice of this array. + doSetExprType - */ -extern "C" unsigned int Indexing_LowIndice (Indexing_Index i); +static decl_node__opaque doSetExprType (decl_node__opaque *t, decl_node__opaque n); /* - PutIndice - places, a, into the dynamic array at position i[n] + getMaxMinType - */ -extern "C" void Indexing_PutIndice (Indexing_Index i, unsigned int n, void * a); +static decl_node__opaque getMaxMinType (decl_node__opaque n); /* - GetIndice - retrieves, element i[n] from the dynamic array. + doGetFuncType - */ -extern "C" void * Indexing_GetIndice (Indexing_Index i, unsigned int n); +static decl_node__opaque doGetFuncType (decl_node__opaque n); /* - IsIndiceInIndex - returns TRUE if, a, is in the index, i. + doGetExprType - works out the type which is associated with node, n. */ -extern "C" bool Indexing_IsIndiceInIndex (Indexing_Index i, void * a); +static decl_node__opaque doGetExprType (decl_node__opaque n); /* - RemoveIndiceFromIndex - removes, a, from Index, i. + getExprType - return the expression type. */ -extern "C" void Indexing_RemoveIndiceFromIndex (Indexing_Index i, void * a); +static decl_node__opaque getExprType (decl_node__opaque n); /* - DeleteIndice - delete i[j] from the array. + openOutput - */ -extern "C" void Indexing_DeleteIndice (Indexing_Index i, unsigned int j); +static void openOutput (void); /* - IncludeIndiceIntoIndex - if the indice is not in the index, then - add it at the end. + closeOutput - */ -extern "C" void Indexing_IncludeIndiceIntoIndex (Indexing_Index i, void * a); +static void closeOutput (void); /* - ForeachIndiceInIndexDo - for each j indice of i, call procedure p(i[j]) + write - outputs a single char, ch. */ -extern "C" void Indexing_ForeachIndiceInIndexDo (Indexing_Index i, Indexing_IndexProcedure p); +static void write_ (char ch); /* - initList - creates a new alist, l. + writeln - */ -extern "C" alists_alist alists_initList (void); +static void writeln (void); /* - killList - deletes the complete alist, l. + doIncludeC - include header file for definition module, n. */ -extern "C" void alists_killList (alists_alist *l); +static void doIncludeC (decl_node__opaque n); /* - putItemIntoList - places an ADDRESS, c, into alist, l. + getSymScope - returns the scope where node, n, was declared. */ -extern "C" void alists_putItemIntoList (alists_alist l, void * c); +static decl_node__opaque getSymScope (decl_node__opaque n); /* - getItemFromList - retrieves the nth WORD from alist, l. + isQualifiedForced - should the node be written with a module prefix? */ -extern "C" void * alists_getItemFromList (alists_alist l, unsigned int n); +static bool isQualifiedForced (decl_node__opaque n); /* - getIndexOfList - returns the index for WORD, c, in alist, l. - If more than one WORD, c, exists the index - for the first is returned. + getFQstring - */ -extern "C" unsigned int alists_getIndexOfList (alists_alist l, void * c); +static DynamicStrings_String getFQstring (decl_node__opaque n); /* - noOfItemsInList - returns the number of items in alist, l. + getFQDstring - */ -extern "C" unsigned int alists_noOfItemsInList (alists_alist l); +static DynamicStrings_String getFQDstring (decl_node__opaque n, bool scopes); /* - includeItemIntoList - adds an ADDRESS, c, into a alist providing - the value does not already exist. + getString - returns the name as a string. */ -extern "C" void alists_includeItemIntoList (alists_alist l, void * c); +static DynamicStrings_String getString (decl_node__opaque n); /* - removeItemFromList - removes a ADDRESS, c, from a alist. - It assumes that this value only appears once. + doNone - call HALT. */ -extern "C" void alists_removeItemFromList (alists_alist l, void * c); +static void doNone (decl_node__opaque n); /* - isItemInList - returns true if a ADDRESS, c, was found in alist, l. + doNothing - does nothing! */ -extern "C" bool alists_isItemInList (alists_alist l, void * c); +static void doNothing (decl_node__opaque n); /* - foreachItemInListDo - calls procedure, P, foreach item in alist, l. + doConstC - */ -extern "C" void alists_foreachItemInListDo (alists_alist l, alists_performOperation p); +static void doConstC (decl_node__opaque n); /* - duplicateList - returns a duplicate alist derived from, l. + needsParen - returns TRUE if expression, n, needs to be enclosed in (). */ -extern "C" alists_alist alists_duplicateList (alists_alist l); +static bool needsParen (decl_node__opaque n); /* - equalList - returns TRUE if left contains the same information as right. + doUnary - */ -extern "C" bool alists_equalList (alists_alist left, alists_alist right); +static void doUnary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node__opaque expr, decl_node__opaque type, bool l, bool r); /* - initList - creates a new wlist, l. + doSetSub - perform l & (~ r) */ -extern "C" wlists_wlist wlists_initList (void); +static void doSetSub (mcPretty_pretty p, decl_node__opaque left, decl_node__opaque right); /* - killList - deletes the complete wlist, l. + doPolyBinary - */ -extern "C" void wlists_killList (wlists_wlist *l); +static void doPolyBinary (mcPretty_pretty p, decl_nodeT op, decl_node__opaque left, decl_node__opaque right, bool l, bool r); /* - putItemIntoList - places an WORD, c, into wlist, l. + doBinary - */ -extern "C" void wlists_putItemIntoList (wlists_wlist l, unsigned int c); +static void doBinary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node__opaque left, decl_node__opaque right, bool l, bool r, bool unpackProc); /* - getItemFromList - retrieves the nth WORD from wlist, l. + doPostUnary - */ -extern "C" unsigned int wlists_getItemFromList (wlists_wlist l, unsigned int n); +static void doPostUnary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node__opaque expr); /* - getIndexOfList - returns the index for WORD, c, in wlist, l. - If more than one WORD, c, exists the index - for the first is returned. + doDeRefC - */ -extern "C" unsigned int wlists_getIndexOfList (wlists_wlist l, unsigned int c); +static decl_node__opaque doDeRefC (mcPretty_pretty p, decl_node__opaque expr); /* - noOfItemsInList - returns the number of items in wlist, l. + doGetLastOp - returns, a, if b is a terminal otherwise walk right. */ -extern "C" unsigned int wlists_noOfItemsInList (wlists_wlist l); +static decl_node__opaque doGetLastOp (decl_node__opaque a, decl_node__opaque b); /* - includeItemIntoList - adds an WORD, c, into a wlist providing - the value does not already exist. + doComponentRefC - */ -extern "C" void wlists_includeItemIntoList (wlists_wlist l, unsigned int c); +static void doComponentRefC (mcPretty_pretty p, decl_node__opaque l, decl_node__opaque r); /* - removeItemFromList - removes a WORD, c, from a wlist. - It assumes that this value only appears once. + doPointerRefC - */ -extern "C" void wlists_removeItemFromList (wlists_wlist l, unsigned int c); +static void doPointerRefC (mcPretty_pretty p, decl_node__opaque l, decl_node__opaque r); /* - replaceItemInList - replace the nth WORD in wlist, l. - The first item in a wlists is at index, 1. - If the index, n, is out of range nothing is changed. + doPreBinary - */ -extern "C" void wlists_replaceItemInList (wlists_wlist l, unsigned int n, unsigned int w); +static void doPreBinary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node__opaque left, decl_node__opaque right, bool l, bool r); /* - isItemInList - returns true if a WORD, c, was found in wlist, l. + doConstExpr - */ -extern "C" bool wlists_isItemInList (wlists_wlist l, unsigned int c); +static void doConstExpr (mcPretty_pretty p, decl_node__opaque n); /* - foreachItemInListDo - calls procedure, P, foreach item in wlist, l. + doEnumerationField - */ -extern "C" void wlists_foreachItemInListDo (wlists_wlist l, wlists_performOperation p); +static void doEnumerationField (mcPretty_pretty p, decl_node__opaque n); /* - duplicateList - returns a duplicate wlist derived from, l. + isZero - returns TRUE if node, n, is zero. */ -extern "C" wlists_wlist wlists_duplicateList (wlists_wlist l); -extern "C" void keyc_useUnistd (void); -extern "C" void keyc_useThrow (void); -extern "C" void keyc_useStorage (void); -extern "C" void keyc_useFree (void); -extern "C" void keyc_useMalloc (void); -extern "C" void keyc_useProc (void); -extern "C" void keyc_useTrue (void); -extern "C" void keyc_useFalse (void); -extern "C" void keyc_useNull (void); -extern "C" void keyc_useMemcpy (void); -extern "C" void keyc_useIntMin (void); -extern "C" void keyc_useUIntMin (void); -extern "C" void keyc_useLongMin (void); -extern "C" void keyc_useULongMin (void); -extern "C" void keyc_useCharMin (void); -extern "C" void keyc_useUCharMin (void); -extern "C" void keyc_useIntMax (void); -extern "C" void keyc_useUIntMax (void); -extern "C" void keyc_useLongMax (void); -extern "C" void keyc_useULongMax (void); -extern "C" void keyc_useCharMax (void); -extern "C" void keyc_useUCharMax (void); -extern "C" void keyc_useSize_t (void); -extern "C" void keyc_useSSize_t (void); -extern "C" void keyc_useLabs (void); -extern "C" void keyc_useAbs (void); -extern "C" void keyc_useFabs (void); -extern "C" void keyc_useFabsl (void); -extern "C" void keyc_useException (void); -extern "C" void keyc_useComplex (void); -extern "C" void keyc_useM2RTS (void); -extern "C" void keyc_useStrlen (void); -extern "C" void keyc_useCtype (void); -extern "C" void keyc_genDefs (mcPretty_pretty p); -extern "C" void keyc_genConfigSystem (mcPretty_pretty p); -extern "C" void keyc_enterScope (decl_node n); -extern "C" void keyc_leaveScope (decl_node n); -extern "C" DynamicStrings_String keyc_cname (nameKey_Name n, bool scopes); -extern "C" nameKey_Name keyc_cnamen (nameKey_Name n, bool scopes); -extern "C" void keyc_cp (void); -extern "C" FIO_File mcStream_openFrag (unsigned int id); -extern "C" void mcStream_setDest (FIO_File f); -extern "C" FIO_File mcStream_combine (void); -extern "C" void mcStream_removeFiles (void); -extern "C" void StrIO_WriteLn (void); -extern "C" void StrIO_ReadString (char *a, unsigned int _a_high); -extern "C" void StrIO_WriteString (const char *a_, unsigned int _a_high); -extern "C" void NumberIO_ReadCard (unsigned int *x); -extern "C" void NumberIO_WriteCard (unsigned int x, unsigned int n); -extern "C" void NumberIO_ReadHex (unsigned int *x); -extern "C" void NumberIO_WriteHex (unsigned int x, unsigned int n); -extern "C" void NumberIO_ReadInt (int *x); -extern "C" void NumberIO_WriteInt (int x, unsigned int n); -extern "C" void NumberIO_CardToStr (unsigned int x, unsigned int n, char *a, unsigned int _a_high); -extern "C" void NumberIO_StrToCard (const char *a_, unsigned int _a_high, unsigned int *x); -extern "C" void NumberIO_HexToStr (unsigned int x, unsigned int n, char *a, unsigned int _a_high); -extern "C" void NumberIO_StrToHex (const char *a_, unsigned int _a_high, unsigned int *x); -extern "C" void NumberIO_IntToStr (int x, unsigned int n, char *a, unsigned int _a_high); -extern "C" void NumberIO_StrToInt (const char *a_, unsigned int _a_high, int *x); -extern "C" void NumberIO_ReadOct (unsigned int *x); -extern "C" void NumberIO_WriteOct (unsigned int x, unsigned int n); -extern "C" void NumberIO_OctToStr (unsigned int x, unsigned int n, char *a, unsigned int _a_high); -extern "C" void NumberIO_StrToOct (const char *a_, unsigned int _a_high, unsigned int *x); -extern "C" void NumberIO_ReadBin (unsigned int *x); -extern "C" void NumberIO_WriteBin (unsigned int x, unsigned int n); -extern "C" void NumberIO_BinToStr (unsigned int x, unsigned int n, char *a, unsigned int _a_high); -extern "C" void NumberIO_StrToBin (const char *a_, unsigned int _a_high, unsigned int *x); -extern "C" void NumberIO_StrToBinInt (const char *a_, unsigned int _a_high, int *x); -extern "C" void NumberIO_StrToHexInt (const char *a_, unsigned int _a_high, int *x); -extern "C" void NumberIO_StrToOctInt (const char *a_, unsigned int _a_high, int *x); -extern "C" void Debug_Halt (const char *Message_, unsigned int _Message_high, const char *Module_, unsigned int _Module_high, const char *Function_, unsigned int _Function_high, unsigned int LineNo); -extern "C" void Debug_DebugString (const char *a_, unsigned int _a_high); -extern "C" void Assertion_Assert (bool Condition); -extern "C" void StdIO_Read (char *ch); -extern "C" void StdIO_Write (char ch); -extern "C" void StdIO_PushOutput (StdIO_ProcWrite p); -extern "C" void StdIO_PopOutput (void); -extern "C" StdIO_ProcWrite StdIO_GetCurrentOutput (void); -extern "C" void StdIO_PushInput (StdIO_ProcRead p); -extern "C" void StdIO_PopInput (void); -extern "C" StdIO_ProcRead StdIO_GetCurrentInput (void); -extern "C" void mcPrintf_printf0 (const char *a_, unsigned int _a_high); -extern "C" void mcPrintf_printf1 (const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high); -extern "C" void mcPrintf_printf2 (const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high); -extern "C" void mcPrintf_printf3 (const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high); -extern "C" void mcPrintf_printf4 (const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high, const unsigned char *w4_, unsigned int _w4_high); -extern "C" void mcPrintf_fprintf0 (FIO_File file, const char *a_, unsigned int _a_high); -extern "C" void mcPrintf_fprintf1 (FIO_File file, const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high); -extern "C" void mcPrintf_fprintf2 (FIO_File file, const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high); -extern "C" void mcPrintf_fprintf3 (FIO_File file, const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high); -extern "C" void mcPrintf_fprintf4 (FIO_File file, const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high, const unsigned char *w4_, unsigned int _w4_high); +static bool isZero (decl_node__opaque n); /* - newNode - create and return a new node of kind k. + doArrayRef - perform an array reference. If constCast + then an unbounded array access will be const_cast + (the constCast should be TRUE if an assignment to + the array is required). */ -static decl_node newNode (decl_nodeT k); +static void doArrayRef (mcPretty_pretty p, decl_node__opaque n, bool constCast); /* - disposeNode - dispose node, n. + doProcedure - */ -static void disposeNode (decl_node *n); +static void doProcedure (mcPretty_pretty p, decl_node__opaque n); /* - newGroup - + doRecordfield - */ -static void newGroup (decl_group *g); +static void doRecordfield (mcPretty_pretty p, decl_node__opaque n); /* - initGroup - returns a group which with all lists initialized. + doCastC - */ -static decl_group initGroup (void); +static void doCastC (mcPretty_pretty p, decl_node__opaque t, decl_node__opaque e); /* - killGroup - deallocate the group and place the group record into the freeGroup list. + doSetValueC - */ -static void killGroup (decl_group *g); +static void doSetValueC (mcPretty_pretty p, decl_node__opaque n); /* - dupGroup - If g is not NIL then destroy g. - Return a duplicate of GlobalGroup (not g). + getSetLow - returns the low value of the set type from + expression, n. */ -static decl_group dupGroup (decl_group g); +static decl_node__opaque getSetLow (decl_node__opaque n); /* - equalGroup - return TRUE if group left = right. + doInC - performs (((1 << (l)) & (r)) != 0) */ -static bool equalGroup (decl_group left, decl_group right); +static void doInC (mcPretty_pretty p, decl_node__opaque l, decl_node__opaque r); /* - isLocal - returns TRUE if symbol, n, is locally declared in a procedure. + doThrowC - */ -static bool isLocal (decl_node n); +static void doThrowC (mcPretty_pretty p, decl_node__opaque n); /* - importEnumFields - if, n, is an enumeration type import the all fields into module, m. + doUnreachableC - */ -static void importEnumFields (decl_node m, decl_node n); +static void doUnreachableC (mcPretty_pretty p, decl_node__opaque n); /* - isComplex - returns TRUE if, n, is the complex type. + outNull - */ -static bool isComplex (decl_node n); +static void outNull (mcPretty_pretty p); /* - isLongComplex - returns TRUE if, n, is the longcomplex type. + outTrue - */ -static bool isLongComplex (decl_node n); +static void outTrue (mcPretty_pretty p); /* - isShortComplex - returns TRUE if, n, is the shortcomplex type. + outFalse - */ -static bool isShortComplex (decl_node n); +static void outFalse (mcPretty_pretty p); /* - isAProcType - returns TRUE if, n, is a proctype or proc node. + doExprC - */ -static bool isAProcType (decl_node n); +static void doExprC (mcPretty_pretty p, decl_node__opaque n); /* - initFixupInfo - initialize the fixupInfo record. + doExprCup - */ -static decl_fixupInfo initFixupInfo (void); +static decl_node__opaque doExprCup (mcPretty_pretty p, decl_node__opaque n, bool unpackProc, bool uncastConst); /* - makeDef - returns a definition module node named, n. + doExprM2 - */ -static decl_node makeDef (nameKey_Name n); +static void doExprM2 (mcPretty_pretty p, decl_node__opaque n); /* - makeImp - returns an implementation module node named, n. + doVar - */ -static decl_node makeImp (nameKey_Name n); +static void doVar (mcPretty_pretty p, decl_node__opaque n); /* - makeModule - returns a module node named, n. + doLiteralC - */ -static decl_node makeModule (nameKey_Name n); +static void doLiteralC (mcPretty_pretty p, decl_node__opaque n); /* - isDefForC - returns TRUE if the definition module was defined FOR "C". + doLiteral - */ -static bool isDefForC (decl_node n); +static void doLiteral (mcPretty_pretty p, decl_node__opaque n); /* - initDecls - initialize the decls, scopeT. + isString - returns TRUE if node, n, is a string. */ -static void initDecls (decl_scopeT *decls); +static bool isString (decl_node__opaque n); /* - addTo - adds node, d, to scope decls and returns, d. - It stores, d, in the symbols tree associated with decls. + doString - */ -static decl_node addTo (decl_scopeT *decls, decl_node d); +static void doString (mcPretty_pretty p, decl_node__opaque n); /* - export - export node, n, from definition module, d. + replaceChar - replace every occurance of, ch, by, a and return modified string, s. */ -static void export_ (decl_node d, decl_node n); +static DynamicStrings_String replaceChar (DynamicStrings_String s, char ch, const char *a_, unsigned int _a_high); /* - addToScope - adds node, n, to the current scope and returns, n. + toCstring - translates string, n, into a C string + and returns the new String. */ -static decl_node addToScope (decl_node n); +static DynamicStrings_String toCstring (nameKey_Name n); /* - addModuleToScope - adds module, i, to module, m, scope. + toCchar - */ -static void addModuleToScope (decl_node m, decl_node i); +static DynamicStrings_String toCchar (nameKey_Name n); /* - completedEnum - assign boolean enumsComplete to TRUE if a definition, - implementation or module symbol. + countChar - */ -static void completedEnum (decl_node n); +static unsigned int countChar (DynamicStrings_String s, char ch); /* - setUnary - sets a unary node to contain, arg, a, and type, t. + lenCstring - */ -static void setUnary (decl_node u, decl_nodeT k, decl_node a, decl_node t); +static unsigned int lenCstring (DynamicStrings_String s); /* - putVarBool - assigns the four booleans associated with a variable. + outCstring - */ -static void putVarBool (decl_node v, bool init, bool param, bool isvar, bool isused); +static void outCstring (mcPretty_pretty p, decl_node__opaque s, bool aString); /* - checkPtr - in C++ we need to create a typedef for a pointer - in case we need to use reinterpret_cast. + doStringC - */ -static decl_node checkPtr (decl_node n); +static void doStringC (mcPretty_pretty p, decl_node__opaque n); /* - isVarDecl - returns TRUE if, n, is a vardecl node. + isPunct - */ -static bool isVarDecl (decl_node n); +static bool isPunct (char ch); /* - makeVariablesFromParameters - creates variables which are really parameters. + isWhite - */ -static void makeVariablesFromParameters (decl_node proc, decl_node id, decl_node type, bool isvar, bool isused); +static bool isWhite (char ch); /* - addProcedureToScope - add a procedure name n and node d to the - current scope. + outText - */ -static decl_node addProcedureToScope (decl_node d, nameKey_Name n); +static void outText (mcPretty_pretty p, const char *a_, unsigned int _a_high); /* - putProcTypeReturn - sets the return type of, proc, to, type. + outRawS - */ -static void putProcTypeReturn (decl_node proc, decl_node type); +static void outRawS (mcPretty_pretty p, DynamicStrings_String s); /* - putProcTypeOptReturn - sets, proc, to have an optional return type. + outKm2 - */ -static void putProcTypeOptReturn (decl_node proc); +static mcPretty_pretty outKm2 (mcPretty_pretty p, const char *a_, unsigned int _a_high); /* - makeOptParameter - creates and returns an optarg. + outKc - */ -static decl_node makeOptParameter (decl_node l, decl_node type, decl_node init); +static mcPretty_pretty outKc (mcPretty_pretty p, const char *a_, unsigned int _a_high); /* - setwatch - assign the globalNode to n. + outTextS - */ -static bool setwatch (decl_node n); +static void outTextS (mcPretty_pretty p, DynamicStrings_String s); /* - runwatch - set the globalNode to an identlist. + outCard - */ -static bool runwatch (void); +static void outCard (mcPretty_pretty p, unsigned int c); /* - isIdentList - returns TRUE if, n, is an identlist. + outTextN - */ -static bool isIdentList (decl_node n); +static void outTextN (mcPretty_pretty p, nameKey_Name n); /* - identListLen - returns the length of identlist. + outputEnumerationC - */ -static unsigned int identListLen (decl_node n); +static void outputEnumerationC (mcPretty_pretty p, decl_node__opaque n); /* - checkParameters - placeholder for future parameter checking. + isDeclType - return TRUE if the current module should declare type. */ -static void checkParameters (decl_node p, decl_node i, decl_node type, bool isvar, bool isused); +static bool isDeclType (decl_node__opaque type); /* - checkMakeVariables - create shadow local variables for parameters providing that - procedure n has not already been built and we are compiling - a module or an implementation module. + doEnumerationC - */ -static void checkMakeVariables (decl_node n, decl_node i, decl_node type, bool isvar, bool isused); +static void doEnumerationC (mcPretty_pretty p, decl_node__opaque n); /* - makeVarientField - create a varient field within varient, v, - The new varient field is returned. + doNamesC - */ -static decl_node makeVarientField (decl_node v, decl_node p); +static void doNamesC (mcPretty_pretty p, nameKey_Name n); /* - putFieldVarient - places the field varient, f, as a brother to, the - varient symbol, v, and also tells, f, that its varient - parent is, v. + doNameC - */ -static void putFieldVarient (decl_node f, decl_node v); +static void doNameC (mcPretty_pretty p, decl_node__opaque n); /* - putFieldRecord - create a new recordfield and place it into record r. - The new field has a tagname and type and can have a - variant field v. + initCname - */ -static decl_node putFieldRecord (decl_node r, nameKey_Name tag, decl_node type, decl_node v); +static void initCname (decl_cnameT *c); /* - ensureOrder - ensures that, a, and, b, exist in, i, and also - ensure that, a, is before, b. + doCname - */ -static void ensureOrder (Indexing_Index i, decl_node a, decl_node b); +static nameKey_Name doCname (nameKey_Name n, decl_cnameT *c, bool scopes); /* - putVarientTag - places tag into variant v. + getDName - */ -static void putVarientTag (decl_node v, decl_node tag); +static nameKey_Name getDName (decl_node__opaque n, bool scopes); /* - getParent - returns the parent field of recordfield or varientfield symbol, n. + doDNameC - */ -static decl_node getParent (decl_node n); +static void doDNameC (mcPretty_pretty p, decl_node__opaque n, bool scopes); /* - getRecord - returns the record associated with node, n. - (Parental record). + doFQDNameC - */ -static decl_node getRecord (decl_node n); +static void doFQDNameC (mcPretty_pretty p, decl_node__opaque n, bool scopes); /* - isConstExp - return TRUE if the node kind is a constexp. + doFQNameC - */ -static bool isConstExp (decl_node c); +static void doFQNameC (mcPretty_pretty p, decl_node__opaque n); /* - addEnumToModule - adds enumeration type, e, into the list of enums - in module, m. + doNameM2 - */ -static void addEnumToModule (decl_node m, decl_node e); +static void doNameM2 (mcPretty_pretty p, decl_node__opaque n); /* - getNextFixup - return the next fixup from from f. + doUsed - */ -static decl_node getNextFixup (decl_fixupInfo *f); +static void doUsed (mcPretty_pretty p, bool used); /* - doMakeEnum - create an enumeration type and add it to the current module. + doHighC - */ -static decl_node doMakeEnum (void); +static void doHighC (mcPretty_pretty p, decl_node__opaque a, nameKey_Name n, bool isused); /* - doMakeEnumField - create an enumeration field name and add it to enumeration e. - Return the new field. + doParamConstCast - */ -static decl_node doMakeEnumField (decl_node e, nameKey_Name n); +static void doParamConstCast (mcPretty_pretty p, decl_node__opaque n); /* - getExpList - returns the, n, th argument in an explist. + getParameterVariable - returns the variable which shadows the parameter + named, m, in parameter block, n. */ -static decl_node getExpList (decl_node p, unsigned int n); +static decl_node__opaque getParameterVariable (decl_node__opaque n, nameKey_Name m); /* - expListLen - returns the length of explist, p. + doParamTypeEmit - emit parameter type for C/C++. It checks to see if the + parameter type is a procedure type and if it were declared + in a definition module for "C" and if so it uses the "C" + definition for a procedure type, rather than the mc + C++ version. */ -static unsigned int expListLen (decl_node p); +static void doParamTypeEmit (mcPretty_pretty p, decl_node__opaque paramnode, decl_node__opaque paramtype); /* - getConstExpComplete - gets the field from the def or imp or module, n. + doParamTypeNameModifier - Add an _ to an unbounded parameter which is non var. */ -static bool getConstExpComplete (decl_node n); +static void doParamTypeNameModifier (mcPretty_pretty p, decl_node__opaque ptype, bool varparam); /* - addConstToModule - adds const exp, e, into the list of constant - expressions in module, m. + initOpaqueCastState - assign fields opaque and voidstar in opaquestate. */ -static void addConstToModule (decl_node m, decl_node e); +static void initOpaqueCastState (decl_opaqueCastState *opaquestate, bool opaque, bool voidstar); /* - doMakeConstExp - create a constexp node and add it to the current module. + initNodeOpaqueCastState - assign opaque and currentvoidstar */ -static decl_node doMakeConstExp (void); +static void initNodeOpaqueCastState (decl_node__opaque n, bool opaque, bool voidstar); /* - isAnyType - return TRUE if node n is any type kind. + setOpaqueCastState - set the voidStar field in opaquestate. */ -static bool isAnyType (decl_node n); +static void setOpaqueCastState (decl_opaqueCastState *opaquestate, bool voidstar); /* - makeVal - creates a VAL (type, expression) node. + setNodeOpaqueVoidStar - sets the voidStar field in node to voidstar. */ -static decl_node makeVal (decl_node params); +static void setNodeOpaqueVoidStar (decl_node__opaque n, bool voidstar); /* - makeCast - creates a cast node TYPENAME (expr). + nodeUsesOpaque - return TRUE if node n uses an opaque type. */ -static decl_node makeCast (decl_node c, decl_node p); -static decl_node makeIntrinsicProc (decl_nodeT k, unsigned int noArgs, decl_node p); +static bool nodeUsesOpaque (decl_node__opaque n); /* - makeIntrinsicUnaryType - create an intrisic unary type. + getNodeOpaqueVoidStar - return TRUE if the opaque type used by node n is a void *. */ -static decl_node makeIntrinsicUnaryType (decl_nodeT k, decl_node paramList, decl_node returnType); +static bool getNodeOpaqueVoidStar (decl_node__opaque n); /* - makeIntrinsicBinaryType - create an intrisic binary type. + getOpaqueFlushNecessary - return TRUE if the value next differs from the opaque state. */ -static decl_node makeIntrinsicBinaryType (decl_nodeT k, decl_node paramList, decl_node returnType); +static bool getOpaqueFlushNecessary (decl_opaqueCastState state, bool next); /* - checkIntrinsic - checks to see if the function call to, c, with - parameter list, n, is really an intrinic. If it - is an intrinic then an intrinic node is created - and returned. Otherwise NIL is returned. + getNodeOpaqueFlushNecessary - return TRUE if the value of next requires a cast. */ -static decl_node checkIntrinsic (decl_node c, decl_node n); +static bool getNodeOpaqueFlushNecessary (decl_node__opaque n, bool next); /* - checkCHeaders - check to see if the function is a C system function and - requires a header file included. + makeOpaqueCast - wrap node n with an opaquecast node and assign + voidstar into the new opaque state. */ -static void checkCHeaders (decl_node c); +static decl_node__opaque makeOpaqueCast (decl_node__opaque n, bool voidstar); /* - isFuncCall - returns TRUE if, n, is a function/procedure call. + flushOpaque - perform a cast to voidstar (if necessary) and ignore the new + node which could be created. */ -static bool isFuncCall (decl_node n); +static void flushOpaque (mcPretty_pretty p, decl_node__opaque n, bool toVoidStar); /* - putTypeInternal - marks type, des, as being an internally generated type. + castOpaque - flushes the opaque type casts if necessary and changes the + voidstar boolean value. If necessary it creates a opaquecast + and returns the new node otherwise return n. */ -static void putTypeInternal (decl_node des); +static decl_node__opaque castOpaque (mcPretty_pretty p, decl_node__opaque n, bool toVoidStar); /* - isTypeInternal - returns TRUE if type, n, is internal. + isTypeOpaqueDefImp - returns TRUE if type is an opaque type by checking + the def/imp pair of modules or fall back to the + definition module. */ -static bool isTypeInternal (decl_node n); +static bool isTypeOpaqueDefImp (decl_node__opaque type); /* - lookupBase - return node named n from the base symbol scope. + isParamVoidStar - return TRUE if the procedure or proctype opaque type + parameter should be implemented as a (void * ). */ -static decl_node lookupBase (nameKey_Name n); +static bool isParamVoidStar (decl_node__opaque n); /* - dumpScopes - display the names of all the scopes stacked. + isRefVoidStar - returns TRUE if the ref node uses an opaque type which + is represented as a (void * ). */ -static void dumpScopes (void); +static bool isRefVoidStar (decl_node__opaque n); /* - out0 - write string a to StdOut. + isReturnVoidStar - return TRUE if the procedure or proctype opaque type + return type should be implemented as a (void * ). */ -static void out0 (const char *a_, unsigned int _a_high); +static bool isReturnVoidStar (decl_node__opaque proc, decl_node__opaque type); /* - out1 - write string a to StdOut using format specifier a. + isVarVoidStar - return TRUE if the variable using an opaque type should + be implemented as a (void * ). */ -static void out1 (const char *a_, unsigned int _a_high, decl_node s); +static bool isVarVoidStar (decl_node__opaque n); /* - out2 - write string a to StdOut using format specifier a. + initNodeOpaqueState - initialize the node opaque state. */ -static void out2 (const char *a_, unsigned int _a_high, unsigned int c, decl_node s); +static void initNodeOpaqueState (decl_node__opaque n); /* - out3 - write string a to StdOut using format specifier a. + assignNodeOpaqueCastState - copy the opaqueCastState from src into dest. */ -static void out3 (const char *a_, unsigned int _a_high, unsigned int l, nameKey_Name n, decl_node s); +static void assignNodeOpaqueCastState (decl_node__opaque dest, decl_node__opaque src); /* - isUnary - returns TRUE if, n, is an unary node. + assignNodeOpaqueCastFalse - assign the voidstar field of dest to false. + It assigns the opaque field of dest to the value + of the src opaque field. */ -static bool isUnary (decl_node n); +static void assignNodeOpaqueCastFalse (decl_node__opaque dest, decl_node__opaque src); /* - isBinary - returns TRUE if, n, is an binary node. + dumpOpaqueState - */ -static bool isBinary (decl_node n); +static void dumpOpaqueState (decl_node__opaque n); /* - makeUnary - create a unary expression node with, e, as the argument - and res as the return type. + doParamC - emit parameter for C/C++. */ -static decl_node makeUnary (decl_nodeT k, decl_node e, decl_node res); +static void doParamC (mcPretty_pretty p, decl_node__opaque n); /* - isLeafString - returns TRUE if n is a leaf node which is a string constant. + doVarParamC - emit a VAR parameter for C/C++. */ -static bool isLeafString (decl_node n); +static void doVarParamC (mcPretty_pretty p, decl_node__opaque n); /* - getLiteralStringContents - return the contents of a literal node as a string. + doOptargC - */ -static DynamicStrings_String getLiteralStringContents (decl_node n); +static void doOptargC (mcPretty_pretty p, decl_node__opaque n); /* - getStringContents - return the string contents of a constant, literal, - string or a constexp node. + doParameterC - */ -static DynamicStrings_String getStringContents (decl_node n); +static void doParameterC (mcPretty_pretty p, decl_node__opaque n); /* - addNames - + doProcTypeC - */ -static nameKey_Name addNames (decl_node a, decl_node b); +static void doProcTypeC (mcPretty_pretty p, decl_node__opaque t, decl_node__opaque n); /* - resolveString - + isDeclInImp - returns TRUE if node type is declared as an opaque and + is declared fully in the current implementation module. + This should only be called if isType (type). Its purpose + is specific to a type checking whether it is an opaque type + declared in the .def/.mod pair of the current imp module. */ -static decl_node resolveString (decl_node n); +static bool isDeclInImp (decl_node__opaque type); /* - foldBinary - + doTypeNameModifier - adds the __opaque modifier to the type n provided + it is an opaque type which is being declared in the + implementation module. */ -static decl_node foldBinary (decl_nodeT k, decl_node l, decl_node r, decl_node res); +static void doTypeNameModifier (mcPretty_pretty p, decl_node__opaque n); /* - makeBinary - create a binary node with left/right/result type: l, r and resultType. + doTypesC - */ -static decl_node makeBinary (decl_nodeT k, decl_node l, decl_node r, decl_node resultType); +static void doTypesC (decl_node__opaque n); /* - doMakeBinary - returns a binary node containing left/right/result values - l, r, res, with a node operator, k. + doCompletePartialC - */ -static decl_node doMakeBinary (decl_nodeT k, decl_node l, decl_node r, decl_node res); +static void doCompletePartialC (decl_node__opaque n); /* - doMakeComponentRef - + doCompletePartialRecord - */ -static decl_node doMakeComponentRef (decl_node rec, decl_node field); +static void doCompletePartialRecord (mcPretty_pretty p, decl_node__opaque t, decl_node__opaque r); /* - isComponentRef - + doCompletePartialArray - */ -static bool isComponentRef (decl_node n); +static void doCompletePartialArray (mcPretty_pretty p, decl_node__opaque t, decl_node__opaque r); /* - isArrayRef - returns TRUE if the node was an arrayref. + lookupConst - */ -static bool isArrayRef (decl_node n); +static decl_node__opaque lookupConst (decl_node__opaque type, nameKey_Name n); /* - isDeref - returns TRUE if, n, is a deref node. + doMin - */ -static bool isDeref (decl_node n); +static decl_node__opaque doMin (decl_node__opaque n); /* - makeBase - create a base type or constant. - It only supports the base types and constants - enumerated below. + doMax - */ -static decl_node makeBase (decl_nodeT k); +static decl_node__opaque doMax (decl_node__opaque n); /* - isOrdinal - returns TRUE if, n, is an ordinal type. + getMax - */ -static bool isOrdinal (decl_node n); +static decl_node__opaque getMax (decl_node__opaque n); /* - mixTypes - + getMin - */ -static decl_node mixTypes (decl_node a, decl_node b); +static decl_node__opaque getMin (decl_node__opaque n); /* - doSetExprType - + doSubtractC - */ -static decl_node doSetExprType (decl_node *t, decl_node n); +static void doSubtractC (mcPretty_pretty p, decl_node__opaque s); /* - getMaxMinType - + doSubrC - */ -static decl_node getMaxMinType (decl_node n); +static void doSubrC (mcPretty_pretty p, decl_node__opaque s); /* - doGetFuncType - + doCompletePartialProcType - */ -static decl_node doGetFuncType (decl_node n); +static void doCompletePartialProcType (mcPretty_pretty p, decl_node__opaque t, decl_node__opaque n); /* - doGetExprType - works out the type which is associated with node, n. + outputCompletePartialProcType - */ -static decl_node doGetExprType (decl_node n); +static void outputCompletePartialProcType (mcPretty_pretty p, decl_node__opaque t, decl_node__opaque n); /* - getExprType - return the expression type. + isBase - */ -static decl_node getExprType (decl_node n); +static bool isBase (decl_node__opaque n); /* - openOutput - + doBoolC - */ -static void openOutput (void); +static void doBoolC (mcPretty_pretty p); /* - closeOutput - + doBaseC - */ -static void closeOutput (void); +static void doBaseC (mcPretty_pretty p, decl_node__opaque n); /* - write - outputs a single char, ch. + isSystem - */ -static void write_ (char ch); +static bool isSystem (decl_node__opaque n); /* - writeln - + doSystemC - */ -static void writeln (void); +static void doSystemC (mcPretty_pretty p, decl_node__opaque n); /* - doIncludeC - include header file for definition module, n. + doArrayC - */ -static void doIncludeC (decl_node n); +static void doArrayC (mcPretty_pretty p, decl_node__opaque n); /* - getSymScope - returns the scope where node, n, was declared. + doPointerC - */ -static decl_node getSymScope (decl_node n); +static void doPointerC (mcPretty_pretty p, decl_node__opaque n, decl_node__opaque *m); /* - isQualifiedForced - should the node be written with a module prefix? + doRecordFieldC - */ -static bool isQualifiedForced (decl_node n); +static void doRecordFieldC (mcPretty_pretty p, decl_node__opaque f); /* - getFQstring - + doVarientFieldC - */ -static DynamicStrings_String getFQstring (decl_node n); +static void doVarientFieldC (mcPretty_pretty p, decl_node__opaque n); /* - getFQDstring - + doVarientC - */ -static DynamicStrings_String getFQDstring (decl_node n, bool scopes); +static void doVarientC (mcPretty_pretty p, decl_node__opaque n); /* - getString - returns the name as a string. + doRecordC - */ -static DynamicStrings_String getString (decl_node n); +static void doRecordC (mcPretty_pretty p, decl_node__opaque n, decl_node__opaque *m); /* - doNone - call HALT. + isBitset - */ -static void doNone (decl_node n); +static bool isBitset (decl_node__opaque n); /* - doNothing - does nothing! + isNegative - returns TRUE if expression, n, is negative. */ -static void doNothing (decl_node n); +static bool isNegative (decl_node__opaque n); /* - doConstC - + doSubrangeC - */ -static void doConstC (decl_node n); +static void doSubrangeC (mcPretty_pretty p, decl_node__opaque n); /* - needsParen - returns TRUE if expression, n, needs to be enclosed in (). + doSetC - generates a C type which holds the set. + Currently we only support sets of size WORD. */ -static bool needsParen (decl_node n); +static void doSetC (mcPretty_pretty p, decl_node__opaque n); /* - doUnary - + doTypeC - */ -static void doUnary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node expr, decl_node type, bool l, bool r); +static void doTypeC (mcPretty_pretty p, decl_node__opaque n, decl_node__opaque *m); /* - doSetSub - perform l & (~ r) + doArrayNameC - it displays the array declaration (it might be an unbounded). */ -static void doSetSub (mcPretty_pretty p, decl_node left, decl_node right); +static void doArrayNameC (mcPretty_pretty p, decl_node__opaque n); /* - doPolyBinary - + doRecordNameC - emit the C/C++ record name "_r". */ -static void doPolyBinary (mcPretty_pretty p, decl_nodeT op, decl_node left, decl_node right, bool l, bool r); +static void doRecordNameC (mcPretty_pretty p, decl_node__opaque n); /* - doBinary - + doPointerNameC - emit the C/C++ pointer type *. */ -static void doBinary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node left, decl_node right, bool l, bool r, bool unpackProc); +static void doPointerNameC (mcPretty_pretty p, decl_node__opaque n); /* - doPostUnary - + doTypeNameC - */ -static void doPostUnary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node expr); +static void doTypeNameC (mcPretty_pretty p, decl_node__opaque n); /* - doDeRefC - + isExternal - returns TRUE if symbol, n, was declared in another module. */ -static void doDeRefC (mcPretty_pretty p, decl_node expr); +static bool isExternal (decl_node__opaque n); /* - doGetLastOp - returns, a, if b is a terminal otherwise walk right. + doOpaqueModifier - adds postfix __opaque providing n uses an opaque type which is + not represented by ( void * ). n is a non type node which might + be using an opaque type. For example a var or param node. */ -static decl_node doGetLastOp (decl_node a, decl_node b); +static void doOpaqueModifier (mcPretty_pretty p, decl_node__opaque n); /* - doComponentRefC - + doDeclareVarC - */ -static void doComponentRefC (mcPretty_pretty p, decl_node l, decl_node r); +static void doDeclareVarC (decl_node__opaque n); /* - doPointerRefC - + doVarC - output a variable declaration. Note that we do not generate + a declaration if we are translating the implementation module + and a variable is exported as the variable will be in the .h + file to avoid all -Wodr issues. */ -static void doPointerRefC (mcPretty_pretty p, decl_node l, decl_node r); +static void doVarC (decl_node__opaque n); /* - doPreBinary - + doExternCP - */ -static void doPreBinary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node left, decl_node right, bool l, bool r); +static void doExternCP (mcPretty_pretty p); /* - doConstExpr - + doProcedureCommentText - */ -static void doConstExpr (mcPretty_pretty p, decl_node n); +static void doProcedureCommentText (mcPretty_pretty p, DynamicStrings_String s); /* - doEnumerationField - + doProcedureComment - */ -static void doEnumerationField (mcPretty_pretty p, decl_node n); +static void doProcedureComment (mcPretty_pretty p, DynamicStrings_String s); /* - isZero - returns TRUE if node, n, is zero. + doProcedureHeadingC - */ -static bool isZero (decl_node n); +static void doProcedureHeadingC (decl_node__opaque n, bool prototype); /* - doArrayRef - + checkDeclareUnboundedParamCopyC - */ -static void doArrayRef (mcPretty_pretty p, decl_node n); +static bool checkDeclareUnboundedParamCopyC (mcPretty_pretty p, decl_node__opaque n); /* - doProcedure - + checkUnboundedParamCopyC - */ -static void doProcedure (mcPretty_pretty p, decl_node n); +static void checkUnboundedParamCopyC (mcPretty_pretty p, decl_node__opaque n); /* - doRecordfield - + doUnboundedParamCopyC - */ -static void doRecordfield (mcPretty_pretty p, decl_node n); +static void doUnboundedParamCopyC (mcPretty_pretty p, decl_node__opaque n); /* - doCastC - + doPrototypeC - */ -static void doCastC (mcPretty_pretty p, decl_node t, decl_node e); +static void doPrototypeC (decl_node__opaque n); /* - doSetValueC - + addTodo - adds, n, to the todo list. */ -static void doSetValueC (mcPretty_pretty p, decl_node n); +static void addTodo (decl_node__opaque n); /* - getSetLow - returns the low value of the set type from - expression, n. + addVariablesTodo - */ -static decl_node getSetLow (decl_node n); +static void addVariablesTodo (decl_node__opaque n); /* - doInC - performs (((1 << (l)) & (r)) != 0) + addTypesTodo - */ -static void doInC (mcPretty_pretty p, decl_node l, decl_node r); +static void addTypesTodo (decl_node__opaque n); /* - doThrowC - + tempName - */ -static void doThrowC (mcPretty_pretty p, decl_node n); +static DynamicStrings_String tempName (void); /* - doUnreachableC - + makeIntermediateType - */ -static void doUnreachableC (mcPretty_pretty p, decl_node n); +static decl_node__opaque makeIntermediateType (DynamicStrings_String s, decl_node__opaque p); /* - outNull - + simplifyType - */ -static void outNull (mcPretty_pretty p); +static void simplifyType (alists_alist l, decl_node__opaque *p); /* - outTrue - + simplifyVar - */ -static void outTrue (mcPretty_pretty p); +static void simplifyVar (alists_alist l, decl_node__opaque n); /* - outFalse - + simplifyRecord - */ -static void outFalse (mcPretty_pretty p); +static void simplifyRecord (alists_alist l, decl_node__opaque n); /* - doExprC - + simplifyVarient - */ -static void doExprC (mcPretty_pretty p, decl_node n); +static void simplifyVarient (alists_alist l, decl_node__opaque n); /* - doExprCup - + simplifyVarientField - */ -static void doExprCup (mcPretty_pretty p, decl_node n, bool unpackProc); +static void simplifyVarientField (alists_alist l, decl_node__opaque n); /* - doExprM2 - + doSimplifyNode - */ -static void doExprM2 (mcPretty_pretty p, decl_node n); +static void doSimplifyNode (alists_alist l, decl_node__opaque n); /* - doVar - + simplifyNode - */ -static void doVar (mcPretty_pretty p, decl_node n); +static void simplifyNode (alists_alist l, decl_node__opaque n); /* - doLiteralC - + doSimplify - */ -static void doLiteralC (mcPretty_pretty p, decl_node n); +static void doSimplify (decl_node__opaque n); /* - doLiteral - + simplifyTypes - */ -static void doLiteral (mcPretty_pretty p, decl_node n); +static void simplifyTypes (decl_scopeT s); /* - isString - returns TRUE if node, n, is a string. + outDeclsDefC - */ -static bool isString (decl_node n); +static void outDeclsDefC (mcPretty_pretty p, decl_node__opaque n); /* - doString - + includeConstType - */ -static void doString (mcPretty_pretty p, decl_node n); +static void includeConstType (decl_scopeT s); /* - replaceChar - replace every occurance of, ch, by, a and return modified string, s. + includeVarProcedure - */ -static DynamicStrings_String replaceChar (DynamicStrings_String s, char ch, const char *a_, unsigned int _a_high); +static void includeVarProcedure (decl_scopeT s); /* - toCstring - translates string, n, into a C string - and returns the new String. + includeVar - */ -static DynamicStrings_String toCstring (nameKey_Name n); +static void includeVar (decl_scopeT s); /* - toCchar - + includeExternals - */ -static DynamicStrings_String toCchar (nameKey_Name n); +static void includeExternals (decl_node__opaque n); /* - countChar - + checkSystemInclude - */ -static unsigned int countChar (DynamicStrings_String s, char ch); +static void checkSystemInclude (decl_node__opaque n); /* - lenCstring - + addExported - */ -static unsigned int lenCstring (DynamicStrings_String s); +static void addExported (decl_node__opaque n); /* - outCstring - + addExternal - only adds, n, if this symbol is external to the + implementation module and is not a hidden type. */ -static void outCstring (mcPretty_pretty p, decl_node s, bool aString); +static void addExternal (decl_node__opaque n); /* - doStringC - + includeDefConstType - */ -static void doStringC (mcPretty_pretty p, decl_node n); +static void includeDefConstType (decl_node__opaque n); /* - isPunct - + runIncludeDefConstType - */ -static bool isPunct (char ch); +static void runIncludeDefConstType (decl_node__opaque n); /* - isWhite - + joinProcedures - copies procedures from definition module, + d, into implementation module, i. */ -static bool isWhite (char ch); +static void joinProcedures (decl_node__opaque i, decl_node__opaque d); /* - outText - + includeDefVarProcedure - */ -static void outText (mcPretty_pretty p, const char *a_, unsigned int _a_high); +static void includeDefVarProcedure (decl_node__opaque n); /* - outRawS - + foreachModuleDo - */ -static void outRawS (mcPretty_pretty p, DynamicStrings_String s); +static void foreachModuleDo (decl_node__opaque n, symbolKey_performOperation p); /* - outKm2 - + outDeclsImpC - */ -static mcPretty_pretty outKm2 (mcPretty_pretty p, const char *a_, unsigned int _a_high); +static void outDeclsImpC (mcPretty_pretty p, decl_scopeT s); /* - outKc - + doStatementSequenceC - */ -static mcPretty_pretty outKc (mcPretty_pretty p, const char *a_, unsigned int _a_high); +static void doStatementSequenceC (mcPretty_pretty p, decl_node__opaque s); /* - outTextS - + isStatementSequenceEmpty - */ -static void outTextS (mcPretty_pretty p, DynamicStrings_String s); +static bool isStatementSequenceEmpty (decl_node__opaque s); /* - outCard - + isSingleStatement - returns TRUE if the statement sequence, s, has + only one statement. */ -static void outCard (mcPretty_pretty p, unsigned int c); +static bool isSingleStatement (decl_node__opaque s); /* - outTextN - + doCommentC - */ -static void outTextN (mcPretty_pretty p, nameKey_Name n); +static void doCommentC (mcPretty_pretty p, decl_node__opaque s); /* - doTypeAliasC - + doAfterCommentC - emit an after comment, c, or a newline if, c, is empty. */ -static void doTypeAliasC (mcPretty_pretty p, decl_node n, decl_node *m); +static void doAfterCommentC (mcPretty_pretty p, decl_node__opaque c); /* - doEnumerationC - + doReturnC - issue a return statement and also place in an after comment if one exists. */ -static void doEnumerationC (mcPretty_pretty p, decl_node n); +static void doReturnC (mcPretty_pretty p, decl_node__opaque s); /* - doNamesC - + isZtypeEquivalent - */ -static void doNamesC (mcPretty_pretty p, nameKey_Name n); +static bool isZtypeEquivalent (decl_node__opaque type); /* - doNameC - + isEquivalentType - returns TRUE if type1 and type2 are equivalent. */ -static void doNameC (mcPretty_pretty p, decl_node n); +static bool isEquivalentType (decl_node__opaque type1, decl_node__opaque type2); /* - initCname - + doExprCastC - build a cast if necessary. */ -static void initCname (decl_cnameT *c); +static void doExprCastC (mcPretty_pretty p, decl_node__opaque e, decl_node__opaque type); /* - doCname - + requiresUnpackProc - returns TRUE if either the expr is a procedure or the proctypes differ. */ -static nameKey_Name doCname (nameKey_Name n, decl_cnameT *c, bool scopes); +static bool requiresUnpackProc (decl_node__opaque s); /* - getDName - + forceCastOpaque - */ -static nameKey_Name getDName (decl_node n, bool scopes); +static void forceCastOpaque (mcPretty_pretty p, decl_node__opaque des, decl_node__opaque expr, bool toVoidStar); /* - doDNameC - + forceReintCastOpaque - */ -static void doDNameC (mcPretty_pretty p, decl_node n, bool scopes); +static void forceReintCastOpaque (mcPretty_pretty p, decl_node__opaque des, decl_node__opaque expr, bool toVoidStar); /* - doFQDNameC - + doUnConstCastUnbounded - if node n type is an unbounded array then + use const_cast to remove the const parameter + to allow the unbounded array to be modified. */ -static void doFQDNameC (mcPretty_pretty p, decl_node n, bool scopes); +static void doUnConstCastUnbounded (mcPretty_pretty p, decl_node__opaque n); /* - doFQNameC - + doAssignmentC - */ -static void doFQNameC (mcPretty_pretty p, decl_node n); +static void doAssignmentC (mcPretty_pretty p, decl_node__opaque s); /* - doNameM2 - + containsStatement - */ -static void doNameM2 (mcPretty_pretty p, decl_node n); +static bool containsStatement (decl_node__opaque s); /* - doUsed - + doCompoundStmt - */ -static void doUsed (mcPretty_pretty p, bool used); +static void doCompoundStmt (mcPretty_pretty p, decl_node__opaque s); /* - doHighC - + doElsifC - */ -static void doHighC (mcPretty_pretty p, decl_node a, nameKey_Name n, bool isused); +static void doElsifC (mcPretty_pretty p, decl_node__opaque s); /* - doParamConstCast - + noIfElse - */ -static void doParamConstCast (mcPretty_pretty p, decl_node n); +static bool noIfElse (decl_node__opaque n); /* - getParameterVariable - returns the variable which shadows the parameter - named, m, in parameter block, n. + noIfElseChained - returns TRUE if, n, is an IF statement which + has no associated ELSE statement. An IF with an + ELSIF is also checked for no ELSE and will result + in a return value of TRUE. */ -static decl_node getParameterVariable (decl_node n, nameKey_Name m); +static bool noIfElseChained (decl_node__opaque n); /* - doParamTypeEmit - emit parameter type for C/C++. It checks to see if the - parameter type is a procedure type and if it were declared - in a definition module for "C" and if so it uses the "C" - definition for a procedure type, rather than the mc - C++ version. + hasIfElse - */ -static void doParamTypeEmit (mcPretty_pretty p, decl_node paramnode, decl_node paramtype); +static bool hasIfElse (decl_node__opaque n); /* - doParamC - emit parameter for C/C++. + isIfElse - */ -static void doParamC (mcPretty_pretty p, decl_node n); +static bool isIfElse (decl_node__opaque n); /* - doVarParamC - emit a VAR parameter for C/C++. + hasIfAndNoElse - returns TRUE if statement, n, is a single statement + which is an IF and it has no else statement. */ -static void doVarParamC (mcPretty_pretty p, decl_node n); +static bool hasIfAndNoElse (decl_node__opaque n); /* - doOptargC - + doIfC - issue an if statement and also place in an after comment if one exists. + The if statement might contain an else or elsif which are also handled. */ -static void doOptargC (mcPretty_pretty p, decl_node n); +static void doIfC (mcPretty_pretty p, decl_node__opaque s); /* - doParameterC - + doForIncCP - */ -static void doParameterC (mcPretty_pretty p, decl_node n); +static void doForIncCP (mcPretty_pretty p, decl_node__opaque s); /* - doProcTypeC - + doForIncC - */ -static void doProcTypeC (mcPretty_pretty p, decl_node t, decl_node n); +static void doForIncC (mcPretty_pretty p, decl_node__opaque s); /* - doTypesC - + doForInc - */ -static void doTypesC (decl_node n); +static void doForInc (mcPretty_pretty p, decl_node__opaque s); /* - doCompletePartialC - + doForC - */ -static void doCompletePartialC (decl_node n); +static void doForC (mcPretty_pretty p, decl_node__opaque s); /* - doCompletePartialRecord - + doRepeatC - */ -static void doCompletePartialRecord (mcPretty_pretty p, decl_node t, decl_node r); +static void doRepeatC (mcPretty_pretty p, decl_node__opaque s); /* - doCompletePartialArray - + doWhileC - */ -static void doCompletePartialArray (mcPretty_pretty p, decl_node t, decl_node r); +static void doWhileC (mcPretty_pretty p, decl_node__opaque s); /* - lookupConst - + doFuncHighC - */ -static decl_node lookupConst (decl_node type, nameKey_Name n); +static void doFuncHighC (mcPretty_pretty p, decl_node__opaque a); /* - doMin - + doMultiplyBySize - */ -static decl_node doMin (decl_node n); +static void doMultiplyBySize (mcPretty_pretty p, decl_node__opaque a); /* - doMax - + doTotype - */ -static decl_node doMax (decl_node n); +static void doTotype (mcPretty_pretty p, decl_node__opaque a, decl_node__opaque t); /* - getMax - + doFuncUnbounded - */ -static decl_node getMax (decl_node n); +static void doFuncUnbounded (mcPretty_pretty p, decl_node__opaque actual, decl_node__opaque formalParam, decl_node__opaque formal, decl_node__opaque func); /* - getMin - + doProcedureParamC - */ -static decl_node getMin (decl_node n); +static void doProcedureParamC (mcPretty_pretty p, decl_node__opaque actual, decl_node__opaque formal); /* - doSubtractC - + doAdrExprC - */ -static void doSubtractC (mcPretty_pretty p, decl_node s); +static void doAdrExprC (mcPretty_pretty p, decl_node__opaque n); /* - doSubrC - + typePair - */ -static void doSubrC (mcPretty_pretty p, decl_node s); +static bool typePair (decl_node__opaque a, decl_node__opaque b, decl_node__opaque x, decl_node__opaque y); /* - doCompletePartialProcType - + needsCast - return TRUE if the actual type parameter needs to be cast to + the formal type. */ -static void doCompletePartialProcType (mcPretty_pretty p, decl_node t, decl_node n); +static bool needsCast (decl_node__opaque at, decl_node__opaque ft); /* - isBase - + checkSystemCast - checks to see if we are passing to/from + a system generic type (WORD, BYTE, ADDRESS) + and if so emit a cast. It returns the number of + open parenthesis. */ -static bool isBase (decl_node n); +static unsigned int checkSystemCast (mcPretty_pretty p, decl_node__opaque actual, decl_node__opaque formal); /* - doBoolC - + emitN - */ -static void doBoolC (mcPretty_pretty p); +static void emitN (mcPretty_pretty p, const char *a_, unsigned int _a_high, unsigned int n); /* - doBaseC - + isForC - return true if node n is a varparam, param or procedure + which was declared inside a definition module for "C". */ -static void doBaseC (mcPretty_pretty p, decl_node n); +static bool isForC (decl_node__opaque n); /* - isSystem - + isDefForCNode - return TRUE if node n was declared inside a definition module for "C". */ -static bool isSystem (decl_node n); +static bool isDefForCNode (decl_node__opaque n); /* - doSystemC - + doFuncVarParam - detect whether the formal uses an opaque and ensure that the address of + the actual parameter is cast to the formal type. */ -static void doSystemC (mcPretty_pretty p, decl_node n); +static void doFuncVarParam (mcPretty_pretty p, decl_node__opaque actual, decl_node__opaque formal); /* - doArrayC - + doFuncParamC - */ -static void doArrayC (mcPretty_pretty p, decl_node n); +static void doFuncParamC (mcPretty_pretty p, decl_node__opaque actual, decl_node__opaque formal, decl_node__opaque func); /* - doPointerC - + getNthParamType - return the type of parameter, i, in list, l. + If the parameter is a vararg NIL is returned. */ -static void doPointerC (mcPretty_pretty p, decl_node n, decl_node *m); +static decl_node__opaque getNthParamType (Indexing_Index l, unsigned int i); /* - doRecordFieldC - + getNthParam - return the parameter, i, in list, l. + If the parameter is a vararg NIL is returned. */ -static void doRecordFieldC (mcPretty_pretty p, decl_node f); +static decl_node__opaque getNthParam (Indexing_Index l, unsigned int i); /* - doVarientFieldC - + doFuncArgsC - */ -static void doVarientFieldC (mcPretty_pretty p, decl_node n); +static void doFuncArgsC (mcPretty_pretty p, decl_node__opaque s, Indexing_Index l, bool needParen); /* - doVarientC - + doProcTypeArgsC - */ -static void doVarientC (mcPretty_pretty p, decl_node n); +static void doProcTypeArgsC (mcPretty_pretty p, decl_node__opaque s, Indexing_Index args, bool needParen); /* - doRecordC - + doAdrArgC - */ -static void doRecordC (mcPretty_pretty p, decl_node n, decl_node *m); +static void doAdrArgC (mcPretty_pretty p, decl_node__opaque n); /* - isBitset - + doAdrC - */ -static bool isBitset (decl_node n); +static void doAdrC (mcPretty_pretty p, decl_node__opaque n); /* - isNegative - returns TRUE if expression, n, is negative. + doInc - */ -static bool isNegative (decl_node n); +static void doInc (mcPretty_pretty p, decl_node__opaque n); /* - doSubrangeC - + doDec - */ -static void doSubrangeC (mcPretty_pretty p, decl_node n); +static void doDec (mcPretty_pretty p, decl_node__opaque n); /* - doSetC - generates a C type which holds the set. - Currently we only support sets of size WORD. + doIncDecC - */ -static void doSetC (mcPretty_pretty p, decl_node n); +static void doIncDecC (mcPretty_pretty p, decl_node__opaque n, const char *op_, unsigned int _op_high); /* - doTypeC - + doIncDecCP - */ -static void doTypeC (mcPretty_pretty p, decl_node n, decl_node *m); +static void doIncDecCP (mcPretty_pretty p, decl_node__opaque n, const char *op_, unsigned int _op_high); /* - doArrayNameC - it displays the array declaration (it might be an unbounded). + doInclC - */ -static void doArrayNameC (mcPretty_pretty p, decl_node n); +static void doInclC (mcPretty_pretty p, decl_node__opaque n); /* - doRecordNameC - emit the C/C++ record name "_r". + doExclC - */ -static void doRecordNameC (mcPretty_pretty p, decl_node n); +static void doExclC (mcPretty_pretty p, decl_node__opaque n); /* - doPointerNameC - emit the C/C++ pointer type *. + doNewC - */ -static void doPointerNameC (mcPretty_pretty p, decl_node n); +static void doNewC (mcPretty_pretty p, decl_node__opaque n); /* - doTypeNameC - + doDisposeC - */ -static void doTypeNameC (mcPretty_pretty p, decl_node n); +static void doDisposeC (mcPretty_pretty p, decl_node__opaque n); /* - isExternal - returns TRUE if symbol, n, was declared in another module. + doCapC - */ -static bool isExternal (decl_node n); +static void doCapC (mcPretty_pretty p, decl_node__opaque n); /* - doVarC - + doLengthC - */ -static void doVarC (decl_node n); +static void doLengthC (mcPretty_pretty p, decl_node__opaque n); /* - doExternCP - + doAbsC - */ -static void doExternCP (mcPretty_pretty p); +static void doAbsC (mcPretty_pretty p, decl_node__opaque n); /* - doProcedureCommentText - + doValC - */ -static void doProcedureCommentText (mcPretty_pretty p, DynamicStrings_String s); +static void doValC (mcPretty_pretty p, decl_node__opaque n); /* - doProcedureComment - + doMinC - */ -static void doProcedureComment (mcPretty_pretty p, DynamicStrings_String s); +static void doMinC (mcPretty_pretty p, decl_node__opaque n); /* - doProcedureHeadingC - + doMaxC - */ -static void doProcedureHeadingC (decl_node n, bool prototype); +static void doMaxC (mcPretty_pretty p, decl_node__opaque n); /* - checkDeclareUnboundedParamCopyC - + isIntrinsic - returns if, n, is an intrinsic procedure. + The intrinsic functions are represented as unary and binary nodes. */ -static bool checkDeclareUnboundedParamCopyC (mcPretty_pretty p, decl_node n); +static bool isIntrinsic (decl_node__opaque n); /* - checkUnboundedParamCopyC - + doHalt - */ -static void checkUnboundedParamCopyC (mcPretty_pretty p, decl_node n); +static void doHalt (mcPretty_pretty p, decl_node__opaque n); /* - doUnboundedParamCopyC - + doCreal - emit the appropriate creal function. */ -static void doUnboundedParamCopyC (mcPretty_pretty p, decl_node n); +static void doCreal (mcPretty_pretty p, decl_node__opaque t); /* - doPrototypeC - + doCimag - emit the appropriate cimag function. */ -static void doPrototypeC (decl_node n); +static void doCimag (mcPretty_pretty p, decl_node__opaque t); /* - addTodo - adds, n, to the todo list. + doReC - */ -static void addTodo (decl_node n); +static void doReC (mcPretty_pretty p, decl_node__opaque n); /* - addVariablesTodo - + doImC - */ -static void addVariablesTodo (decl_node n); +static void doImC (mcPretty_pretty p, decl_node__opaque n); /* - addTypesTodo - + doCmplx - */ -static void addTypesTodo (decl_node n); +static void doCmplx (mcPretty_pretty p, decl_node__opaque n); /* - tempName - + doIntrinsicC - */ -static DynamicStrings_String tempName (void); +static void doIntrinsicC (mcPretty_pretty p, decl_node__opaque n); /* - makeIntermediateType - + isIntrinsicFunction - returns true if, n, is an instrinsic function. */ -static decl_node makeIntermediateType (DynamicStrings_String s, decl_node p); +static bool isIntrinsicFunction (decl_node__opaque n); /* - simplifyType - + doSizeC - */ -static void simplifyType (alists_alist l, decl_node *p); +static void doSizeC (mcPretty_pretty p, decl_node__opaque n); /* - simplifyVar - + doConvertC - */ -static void simplifyVar (alists_alist l, decl_node n); +static void doConvertC (mcPretty_pretty p, decl_node__opaque n, const char *conversion_, unsigned int _conversion_high); /* - simplifyRecord - + doConvertSC - */ -static void simplifyRecord (alists_alist l, decl_node n); +static void doConvertSC (mcPretty_pretty p, decl_node__opaque n, DynamicStrings_String conversion); /* - simplifyVarient - + getFunction - return the function associate with funccall node n. */ -static void simplifyVarient (alists_alist l, decl_node n); +static decl_node__opaque getFunction (decl_node__opaque n); /* - simplifyVarientField - + getFuncFromExpr - */ -static void simplifyVarientField (alists_alist l, decl_node n); +static decl_node__opaque getFuncFromExpr (decl_node__opaque n); /* - doSimplifyNode - + doFuncExprC - */ -static void doSimplifyNode (alists_alist l, decl_node n); +static void doFuncExprC (mcPretty_pretty p, decl_node__opaque n); /* - simplifyNode - + doFuncCallC - */ -static void simplifyNode (alists_alist l, decl_node n); +static void doFuncCallC (mcPretty_pretty p, decl_node__opaque n); /* - doSimplify - + doCaseStatementC - */ -static void doSimplify (decl_node n); +static void doCaseStatementC (mcPretty_pretty p, decl_node__opaque n, bool needBreak); /* - simplifyTypes - + doExceptionC - */ -static void simplifyTypes (decl_scopeT s); +static void doExceptionC (mcPretty_pretty p, const char *a_, unsigned int _a_high, decl_node__opaque n); /* - outDeclsDefC - + doExceptionCP - */ -static void outDeclsDefC (mcPretty_pretty p, decl_node n); +static void doExceptionCP (mcPretty_pretty p, const char *a_, unsigned int _a_high, decl_node__opaque n); /* - includeConstType - + doException - */ -static void includeConstType (decl_scopeT s); +static void doException (mcPretty_pretty p, const char *a_, unsigned int _a_high, decl_node__opaque n); /* - includeVarProcedure - + doRangeListC - */ -static void includeVarProcedure (decl_scopeT s); +static void doRangeListC (mcPretty_pretty p, decl_node__opaque c); /* - includeVar - + doRangeIfListC - */ -static void includeVar (decl_scopeT s); +static void doRangeIfListC (mcPretty_pretty p, decl_node__opaque e, decl_node__opaque c); /* - includeExternals - + doCaseLabels - */ -static void includeExternals (decl_node n); +static void doCaseLabels (mcPretty_pretty p, decl_node__opaque n, bool needBreak); /* - checkSystemInclude - + doCaseLabelListC - */ -static void checkSystemInclude (decl_node n); +static void doCaseLabelListC (mcPretty_pretty p, decl_node__opaque n, bool haveElse); /* - addExported - + doCaseIfLabels - */ -static void addExported (decl_node n); +static void doCaseIfLabels (mcPretty_pretty p, decl_node__opaque e, decl_node__opaque n, unsigned int i, unsigned int h); /* - addExternal - only adds, n, if this symbol is external to the - implementation module and is not a hidden type. + doCaseIfLabelListC - */ -static void addExternal (decl_node n); +static void doCaseIfLabelListC (mcPretty_pretty p, decl_node__opaque n); /* - includeDefConstType - + doCaseElseC - */ -static void includeDefConstType (decl_node n); +static void doCaseElseC (mcPretty_pretty p, decl_node__opaque n); /* - runIncludeDefConstType - + doCaseIfElseC - */ -static void runIncludeDefConstType (decl_node n); +static void doCaseIfElseC (mcPretty_pretty p, decl_node__opaque n); /* - joinProcedures - copies procedures from definition module, - d, into implementation module, i. + canUseSwitchCaseLabels - returns TRUE if all the case labels are + single values and not ranges. */ -static void joinProcedures (decl_node i, decl_node d); +static bool canUseSwitchCaseLabels (decl_node__opaque n); /* - includeDefVarProcedure - + canUseSwitch - returns TRUE if the case statement can be implement + by a switch statement. This will be TRUE if all case + selectors are single values rather than ranges. */ -static void includeDefVarProcedure (decl_node n); +static bool canUseSwitch (decl_node__opaque n); /* - foreachModuleDo - + doCaseC - */ -static void foreachModuleDo (decl_node n, symbolKey_performOperation p); +static void doCaseC (mcPretty_pretty p, decl_node__opaque n); /* - outDeclsImpC - + doLoopC - */ -static void outDeclsImpC (mcPretty_pretty p, decl_scopeT s); +static void doLoopC (mcPretty_pretty p, decl_node__opaque s); /* - doStatementSequenceC - + doExitC - */ -static void doStatementSequenceC (mcPretty_pretty p, decl_node s); +static void doExitC (mcPretty_pretty p, decl_node__opaque s); /* - isStatementSequenceEmpty - + doStatementsC - */ -static bool isStatementSequenceEmpty (decl_node s); +static void doStatementsC (mcPretty_pretty p, decl_node__opaque s); +static void localstop (void); /* - isSingleStatement - returns TRUE if the statement sequence, s, has - only one statement. + doLocalVarC - */ -static bool isSingleStatement (decl_node s); +static void doLocalVarC (mcPretty_pretty p, decl_scopeT s); /* - doCommentC - + doLocalConstTypesC - */ -static void doCommentC (mcPretty_pretty p, decl_node s); +static void doLocalConstTypesC (mcPretty_pretty p, decl_scopeT s); /* - doAfterCommentC - emit an after comment, c, or a newline if, c, is empty. + addParamDone - */ -static void doAfterCommentC (mcPretty_pretty p, decl_node c); +static void addParamDone (decl_node__opaque n); /* - doReturnC - issue a return statement and also place in an after comment if one exists. + includeParameters - */ -static void doReturnC (mcPretty_pretty p, decl_node s); +static void includeParameters (decl_node__opaque n); /* - isZtypeEquivalent - + isHalt - */ -static bool isZtypeEquivalent (decl_node type); +static bool isHalt (decl_node__opaque n); /* - isEquivalentType - returns TRUE if type1 and type2 are equivalent. + isReturnOrHalt - */ -static bool isEquivalentType (decl_node type1, decl_node type2); +static bool isReturnOrHalt (decl_node__opaque n); /* - doExprCastC - build a cast if necessary. + isLastStatementReturn - */ -static void doExprCastC (mcPretty_pretty p, decl_node e, decl_node type); +static bool isLastStatementReturn (decl_node__opaque n); /* - requiresUnpackProc - returns TRUE if either the expr is a procedure or the proctypes differ. + isLastStatementSequence - */ -static bool requiresUnpackProc (decl_node s); +static bool isLastStatementSequence (decl_node__opaque n, decl_isNodeF q); /* - doAssignmentC - + isLastStatementIf - */ -static void doAssignmentC (mcPretty_pretty p, decl_node s); +static bool isLastStatementIf (decl_node__opaque n, decl_isNodeF q); /* - containsStatement - + isLastStatementElsif - */ -static bool containsStatement (decl_node s); +static bool isLastStatementElsif (decl_node__opaque n, decl_isNodeF q); /* - doCompoundStmt - + isLastStatementCase - */ -static void doCompoundStmt (mcPretty_pretty p, decl_node s); +static bool isLastStatementCase (decl_node__opaque n, decl_isNodeF q); /* - doElsifC - + isLastStatement - returns TRUE if the last statement in, n, is, q. */ -static void doElsifC (mcPretty_pretty p, decl_node s); +static bool isLastStatement (decl_node__opaque n, decl_isNodeF q); /* - noIfElse - + doProcedureC - */ -static bool noIfElse (decl_node n); +static void doProcedureC (decl_node__opaque n); /* - noIfElseChained - returns TRUE if, n, is an IF statement which - has no associated ELSE statement. An IF with an - ELSIF is also checked for no ELSE and will result - in a return value of TRUE. + outProceduresC - */ -static bool noIfElseChained (decl_node n); +static void outProceduresC (mcPretty_pretty p, decl_scopeT s); /* - hasIfElse - + output - */ -static bool hasIfElse (decl_node n); +static void output (decl_node__opaque n, decl_nodeProcedure c, decl_nodeProcedure t, decl_nodeProcedure v); /* - isIfElse - + allDependants - */ -static bool isIfElse (decl_node n); +static decl_dependentState allDependants (decl_node__opaque n); /* - hasIfAndNoElse - returns TRUE if statement, n, is a single statement - which is an IF and it has no else statement. + walkDependants - */ -static bool hasIfAndNoElse (decl_node n); +static decl_dependentState walkDependants (alists_alist l, decl_node__opaque n); /* - doIfC - issue an if statement and also place in an after comment if one exists. - The if statement might contain an else or elsif which are also handled. + walkType - */ -static void doIfC (mcPretty_pretty p, decl_node s); +static decl_dependentState walkType (alists_alist l, decl_node__opaque n); /* - doForIncCP - + db - */ -static void doForIncCP (mcPretty_pretty p, decl_node s); +static void db (const char *a_, unsigned int _a_high, decl_node__opaque n); /* - doForIncC - + dbt - */ -static void doForIncC (mcPretty_pretty p, decl_node s); +static void dbt (const char *a_, unsigned int _a_high); /* - doForInc - + dbs - */ -static void doForInc (mcPretty_pretty p, decl_node s); +static void dbs (decl_dependentState s, decl_node__opaque n); /* - doForC - + dbq - */ -static void doForC (mcPretty_pretty p, decl_node s); +static void dbq (decl_node__opaque n); /* - doRepeatC - + walkRecord - */ -static void doRepeatC (mcPretty_pretty p, decl_node s); +static decl_dependentState walkRecord (alists_alist l, decl_node__opaque n); /* - doWhileC - + walkVarient - */ -static void doWhileC (mcPretty_pretty p, decl_node s); +static decl_dependentState walkVarient (alists_alist l, decl_node__opaque n); /* - doFuncHighC - + queueBlocked - */ -static void doFuncHighC (mcPretty_pretty p, decl_node a); +static void queueBlocked (decl_node__opaque n); /* - doMultiplyBySize - + walkVar - */ -static void doMultiplyBySize (mcPretty_pretty p, decl_node a); +static decl_dependentState walkVar (alists_alist l, decl_node__opaque n); /* - doTotype - + walkEnumeration - */ -static void doTotype (mcPretty_pretty p, decl_node a, decl_node t); +static decl_dependentState walkEnumeration (alists_alist l, decl_node__opaque n); /* - doFuncUnbounded - + walkSubrange - */ -static void doFuncUnbounded (mcPretty_pretty p, decl_node actual, decl_node formalParam, decl_node formal, decl_node func); +static decl_dependentState walkSubrange (alists_alist l, decl_node__opaque n); /* - doProcedureParamC - + walkSubscript - */ -static void doProcedureParamC (mcPretty_pretty p, decl_node actual, decl_node formal); +static decl_dependentState walkSubscript (alists_alist l, decl_node__opaque n); /* - doAdrExprC - + walkPointer - */ -static void doAdrExprC (mcPretty_pretty p, decl_node n); +static decl_dependentState walkPointer (alists_alist l, decl_node__opaque n); /* - typePair - + walkArray - */ -static bool typePair (decl_node a, decl_node b, decl_node x, decl_node y); +static decl_dependentState walkArray (alists_alist l, decl_node__opaque n); /* - needsCast - return TRUE if the actual type parameter needs to be cast to - the formal type. + walkConst - */ -static bool needsCast (decl_node at, decl_node ft); +static decl_dependentState walkConst (alists_alist l, decl_node__opaque n); /* - checkSystemCast - checks to see if we are passing to/from - a system generic type (WORD, BYTE, ADDRESS) - and if so emit a cast. It returns the number of - open parenthesis. + walkVarParam - */ -static unsigned int checkSystemCast (mcPretty_pretty p, decl_node actual, decl_node formal); +static decl_dependentState walkVarParam (alists_alist l, decl_node__opaque n); /* - emitN - + walkParam - */ -static void emitN (mcPretty_pretty p, const char *a_, unsigned int _a_high, unsigned int n); +static decl_dependentState walkParam (alists_alist l, decl_node__opaque n); /* - isForC - return true if node n is a varparam, param or procedure - which was declared inside a definition module for "C". + walkOptarg - */ -static bool isForC (decl_node n); +static decl_dependentState walkOptarg (alists_alist l, decl_node__opaque n); /* - isDefForCNode - return TRUE if node n was declared inside a definition module for "C". + walkRecordField - */ -static bool isDefForCNode (decl_node n); +static decl_dependentState walkRecordField (alists_alist l, decl_node__opaque n); /* - doFuncParamC - + walkVarientField - */ -static void doFuncParamC (mcPretty_pretty p, decl_node actual, decl_node formal, decl_node func); +static decl_dependentState walkVarientField (alists_alist l, decl_node__opaque n); /* - getNthParamType - return the type of parameter, i, in list, l. - If the parameter is a vararg NIL is returned. + walkEnumerationField - */ -static decl_node getNthParamType (Indexing_Index l, unsigned int i); +static decl_dependentState walkEnumerationField (alists_alist l, decl_node__opaque n); /* - getNthParam - return the parameter, i, in list, l. - If the parameter is a vararg NIL is returned. + walkSet - */ -static decl_node getNthParam (Indexing_Index l, unsigned int i); +static decl_dependentState walkSet (alists_alist l, decl_node__opaque n); /* - doFuncArgsC - + walkProcType - */ -static void doFuncArgsC (mcPretty_pretty p, decl_node s, Indexing_Index l, bool needParen); +static decl_dependentState walkProcType (alists_alist l, decl_node__opaque n); /* - doProcTypeArgsC - + walkProcedure - */ -static void doProcTypeArgsC (mcPretty_pretty p, decl_node s, Indexing_Index args, bool needParen); +static decl_dependentState walkProcedure (alists_alist l, decl_node__opaque n); /* - doAdrArgC - + walkParameters - */ -static void doAdrArgC (mcPretty_pretty p, decl_node n); +static decl_dependentState walkParameters (alists_alist l, Indexing_Index p); /* - doAdrC - + walkFuncCall - */ -static void doAdrC (mcPretty_pretty p, decl_node n); +static decl_dependentState walkFuncCall (alists_alist l, decl_node__opaque n); /* - doInc - + walkUnary - */ -static void doInc (mcPretty_pretty p, decl_node n); +static decl_dependentState walkUnary (alists_alist l, decl_node__opaque n); /* - doDec - + walkBinary - */ -static void doDec (mcPretty_pretty p, decl_node n); +static decl_dependentState walkBinary (alists_alist l, decl_node__opaque n); /* - doIncDecC - + walkComponentRef - */ -static void doIncDecC (mcPretty_pretty p, decl_node n, const char *op_, unsigned int _op_high); +static decl_dependentState walkComponentRef (alists_alist l, decl_node__opaque n); /* - doIncDecCP - + walkPointerRef - */ -static void doIncDecCP (mcPretty_pretty p, decl_node n, const char *op_, unsigned int _op_high); +static decl_dependentState walkPointerRef (alists_alist l, decl_node__opaque n); /* - doInclC - + walkSetValue - */ -static void doInclC (mcPretty_pretty p, decl_node n); +static decl_dependentState walkSetValue (alists_alist l, decl_node__opaque n); /* - doExclC - + doDependants - return the dependentState depending upon whether + all dependants have been declared. */ -static void doExclC (mcPretty_pretty p, decl_node n); +static decl_dependentState doDependants (alists_alist l, decl_node__opaque n); /* - doNewC - + tryComplete - returns TRUE if node, n, can be and was completed. */ -static void doNewC (mcPretty_pretty p, decl_node n); +static bool tryComplete (decl_node__opaque n, decl_nodeProcedure c, decl_nodeProcedure t, decl_nodeProcedure v); /* - doDisposeC - + tryCompleteFromPartial - */ -static void doDisposeC (mcPretty_pretty p, decl_node n); +static bool tryCompleteFromPartial (decl_node__opaque n, decl_nodeProcedure t); /* - doCapC - + visitIntrinsicFunction - */ -static void doCapC (mcPretty_pretty p, decl_node n); +static void visitIntrinsicFunction (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doLengthC - + visitUnary - */ -static void doLengthC (mcPretty_pretty p, decl_node n); +static void visitUnary (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doAbsC - + visitBinary - */ -static void doAbsC (mcPretty_pretty p, decl_node n); +static void visitBinary (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doValC - + visitBoolean - */ -static void doValC (mcPretty_pretty p, decl_node n); +static void visitBoolean (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doMinC - + visitScope - */ -static void doMinC (mcPretty_pretty p, decl_node n); +static void visitScope (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doMaxC - + visitType - */ -static void doMaxC (mcPretty_pretty p, decl_node n); +static void visitType (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - isIntrinsic - returns if, n, is an intrinsic procedure. - The intrinsic functions are represented as unary and binary nodes. + visitIndex - */ -static bool isIntrinsic (decl_node n); +static void visitIndex (alists_alist v, Indexing_Index i, decl_nodeProcedure p); /* - doHalt - + visitRecord - */ -static void doHalt (mcPretty_pretty p, decl_node n); +static void visitRecord (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doCreal - emit the appropriate creal function. + visitVarient - */ -static void doCreal (mcPretty_pretty p, decl_node t); +static void visitVarient (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doCimag - emit the appropriate cimag function. + visitVar - */ -static void doCimag (mcPretty_pretty p, decl_node t); +static void visitVar (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doReC - + visitEnumeration - */ -static void doReC (mcPretty_pretty p, decl_node n); +static void visitEnumeration (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doImC - + visitSubrange - */ -static void doImC (mcPretty_pretty p, decl_node n); +static void visitSubrange (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doCmplx - + visitPointer - */ -static void doCmplx (mcPretty_pretty p, decl_node n); +static void visitPointer (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doIntrinsicC - + visitArray - */ -static void doIntrinsicC (mcPretty_pretty p, decl_node n); +static void visitArray (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - isIntrinsicFunction - returns true if, n, is an instrinsic function. + visitConst - */ -static bool isIntrinsicFunction (decl_node n); +static void visitConst (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doSizeC - + visitVarParam - */ -static void doSizeC (mcPretty_pretty p, decl_node n); +static void visitVarParam (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doConvertC - + visitParam - */ -static void doConvertC (mcPretty_pretty p, decl_node n, const char *conversion_, unsigned int _conversion_high); +static void visitParam (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doConvertSC - + visitOptarg - */ -static void doConvertSC (mcPretty_pretty p, decl_node n, DynamicStrings_String conversion); +static void visitOptarg (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - getFuncFromExpr - + visitRecordField - */ -static decl_node getFuncFromExpr (decl_node n); +static void visitRecordField (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doFuncExprC - + visitVarientField - */ -static void doFuncExprC (mcPretty_pretty p, decl_node n); +static void visitVarientField (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doFuncCallC - + visitEnumerationField - */ -static void doFuncCallC (mcPretty_pretty p, decl_node n); +static void visitEnumerationField (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doCaseStatementC - + visitSet - */ -static void doCaseStatementC (mcPretty_pretty p, decl_node n, bool needBreak); +static void visitSet (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doExceptionC - + visitProcType - */ -static void doExceptionC (mcPretty_pretty p, const char *a_, unsigned int _a_high, decl_node n); +static void visitProcType (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doExceptionCP - + visitSubscript - */ -static void doExceptionCP (mcPretty_pretty p, const char *a_, unsigned int _a_high, decl_node n); +static void visitSubscript (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doException - + visitDecls - */ -static void doException (mcPretty_pretty p, const char *a_, unsigned int _a_high, decl_node n); +static void visitDecls (alists_alist v, decl_scopeT s, decl_nodeProcedure p); /* - doRangeListC - + visitProcedure - */ -static void doRangeListC (mcPretty_pretty p, decl_node c); +static void visitProcedure (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doRangeIfListC - + visitDef - */ -static void doRangeIfListC (mcPretty_pretty p, decl_node e, decl_node c); +static void visitDef (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doCaseLabels - + visitImp - */ -static void doCaseLabels (mcPretty_pretty p, decl_node n, bool needBreak); +static void visitImp (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doCaseLabelListC - + visitModule - */ -static void doCaseLabelListC (mcPretty_pretty p, decl_node n, bool haveElse); +static void visitModule (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doCaseIfLabels - + visitLoop - */ -static void doCaseIfLabels (mcPretty_pretty p, decl_node e, decl_node n, unsigned int i, unsigned int h); +static void visitLoop (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doCaseIfLabelListC - + visitWhile - */ -static void doCaseIfLabelListC (mcPretty_pretty p, decl_node n); +static void visitWhile (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doCaseElseC - + visitRepeat - */ -static void doCaseElseC (mcPretty_pretty p, decl_node n); +static void visitRepeat (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doCaseIfElseC - + visitCase - */ -static void doCaseIfElseC (mcPretty_pretty p, decl_node n); +static void visitCase (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - canUseSwitchCaseLabels - returns TRUE if all the case labels are - single values and not ranges. + visitCaseLabelList - */ -static bool canUseSwitchCaseLabels (decl_node n); +static void visitCaseLabelList (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - canUseSwitch - returns TRUE if the case statement can be implement - by a switch statement. This will be TRUE if all case - selectors are single values rather than ranges. + visitCaseList - */ -static bool canUseSwitch (decl_node n); +static void visitCaseList (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doCaseC - + visitRange - */ -static void doCaseC (mcPretty_pretty p, decl_node n); +static void visitRange (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doLoopC - + visitIf - */ -static void doLoopC (mcPretty_pretty p, decl_node s); +static void visitIf (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doExitC - + visitElsif - */ -static void doExitC (mcPretty_pretty p, decl_node s); +static void visitElsif (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doStatementsC - + visitFor - */ -static void doStatementsC (mcPretty_pretty p, decl_node s); -static void stop (void); +static void visitFor (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doLocalVarC - + visitAssignment - */ -static void doLocalVarC (mcPretty_pretty p, decl_scopeT s); +static void visitAssignment (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doLocalConstTypesC - + visitComponentRef - */ -static void doLocalConstTypesC (mcPretty_pretty p, decl_scopeT s); +static void visitComponentRef (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - addParamDone - + visitPointerRef - */ -static void addParamDone (decl_node n); +static void visitPointerRef (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - includeParameters - + visitArrayRef - */ -static void includeParameters (decl_node n); +static void visitArrayRef (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - isHalt - + visitFunccall - */ -static bool isHalt (decl_node n); +static void visitFunccall (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - isReturnOrHalt - + visitVarDecl - */ -static bool isReturnOrHalt (decl_node n); +static void visitVarDecl (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - isLastStatementReturn - + visitExplist - */ -static bool isLastStatementReturn (decl_node n); +static void visitExplist (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - isLastStatementSequence - + visitExit - */ -static bool isLastStatementSequence (decl_node n, decl_isNodeF q); +static void visitExit (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - isLastStatementIf - + visitReturn - */ -static bool isLastStatementIf (decl_node n, decl_isNodeF q); +static void visitReturn (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - isLastStatementElsif - + visitStmtSeq - */ -static bool isLastStatementElsif (decl_node n, decl_isNodeF q); +static void visitStmtSeq (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - isLastStatementCase - + visitVarargs - */ -static bool isLastStatementCase (decl_node n, decl_isNodeF q); +static void visitVarargs (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - isLastStatement - returns TRUE if the last statement in, n, is, q. + visitSetValue - */ -static bool isLastStatement (decl_node n, decl_isNodeF q); +static void visitSetValue (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - doProcedureC - + visitIntrinsic - */ -static void doProcedureC (decl_node n); +static void visitIntrinsic (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - outProceduresC - + visitDependants - helper procedure function called from visitNode. + node n has just been visited, this procedure will + visit node, n, dependants. */ -static void outProceduresC (mcPretty_pretty p, decl_scopeT s); +static void visitDependants (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - output - + visitNode - visits node, n, if it is not already in the alist, v. + It calls p(n) if the node is unvisited. */ -static void output (decl_node n, decl_nodeProcedure c, decl_nodeProcedure t, decl_nodeProcedure v); +static void visitNode (alists_alist v, decl_node__opaque n, decl_nodeProcedure p); /* - allDependants - + genKind - returns a string depending upon the kind of node, n. */ -static decl_dependentState allDependants (decl_node n); +static DynamicStrings_String genKind (decl_node__opaque n); /* - walkDependants - + gen - generate a small string describing node, n. */ -static decl_dependentState walkDependants (alists_alist l, decl_node n); +static DynamicStrings_String gen (decl_node__opaque n); /* - walkType - + dumpQ - */ -static decl_dependentState walkType (alists_alist l, decl_node n); +static void dumpQ (const char *q_, unsigned int _q_high, alists_alist l); /* - db - + dumpLists - */ -static void db (const char *a_, unsigned int _a_high, decl_node n); +static void dumpLists (void); /* - dbt - + outputHidden - */ -static void dbt (const char *a_, unsigned int _a_high); +static void outputHidden (decl_node__opaque n); /* - dbs - + outputHiddenComplete - */ -static void dbs (decl_dependentState s, decl_node n); +static void outputHiddenComplete (decl_node__opaque n); /* - dbq - + tryPartial - */ -static void dbq (decl_node n); +static bool tryPartial (decl_node__opaque n, decl_nodeProcedure pt); /* - walkRecord - + outputPartialRecordArrayProcType - */ -static decl_dependentState walkRecord (alists_alist l, decl_node n); +static void outputPartialRecordArrayProcType (decl_node__opaque n, decl_node__opaque q, unsigned int indirection); /* - walkVarient - + outputPartial - */ -static decl_dependentState walkVarient (alists_alist l, decl_node n); +static void outputPartial (decl_node__opaque n); /* - queueBlocked - + tryOutputTodo - */ -static void queueBlocked (decl_node n); +static void tryOutputTodo (decl_nodeProcedure c, decl_nodeProcedure t, decl_nodeProcedure v, decl_nodeProcedure pt); /* - walkVar - + tryOutputPartial - */ -static decl_dependentState walkVar (alists_alist l, decl_node n); +static void tryOutputPartial (decl_nodeProcedure t); /* - walkEnumeration - + debugList - */ -static decl_dependentState walkEnumeration (alists_alist l, decl_node n); +static void debugList (const char *listName_, unsigned int _listName_high, const char *symName_, unsigned int _symName_high, alists_alist l); /* - walkSubrange - + debugLists - */ -static decl_dependentState walkSubrange (alists_alist l, decl_node n); +static void debugLists (void); /* - walkSubscript - + addEnumConst - */ -static decl_dependentState walkSubscript (alists_alist l, decl_node n); +static void addEnumConst (decl_node__opaque n); /* - walkPointer - + populateTodo - */ -static decl_dependentState walkPointer (alists_alist l, decl_node n); +static void populateTodo (decl_nodeProcedure p); /* - walkArray - + topologicallyOut - keep trying to resolve the todoQ and partialQ + until there is no change from the global group. */ -static decl_dependentState walkArray (alists_alist l, decl_node n); +static void topologicallyOut (decl_nodeProcedure c, decl_nodeProcedure t, decl_nodeProcedure v, decl_nodeProcedure tp, decl_nodeProcedure pc, decl_nodeProcedure pt, decl_nodeProcedure pv); /* - walkConst - + scaffoldStatic - */ -static decl_dependentState walkConst (alists_alist l, decl_node n); +static void scaffoldStatic (mcPretty_pretty p, decl_node__opaque n); /* - walkVarParam - + emitCtor - */ -static decl_dependentState walkVarParam (alists_alist l, decl_node n); +static void emitCtor (mcPretty_pretty p, decl_node__opaque n); /* - walkParam - + scaffoldDynamic - */ -static decl_dependentState walkParam (alists_alist l, decl_node n); +static void scaffoldDynamic (mcPretty_pretty p, decl_node__opaque n); /* - walkOptarg - + scaffoldMain - */ -static decl_dependentState walkOptarg (alists_alist l, decl_node n); +static void scaffoldMain (mcPretty_pretty p, decl_node__opaque n); /* - walkRecordField - + outImpInitC - emit the init/fini functions and main function if required. */ -static decl_dependentState walkRecordField (alists_alist l, decl_node n); +static void outImpInitC (mcPretty_pretty p, decl_node__opaque n); /* - walkVarientField - + runSimplifyTypes - */ -static decl_dependentState walkVarientField (alists_alist l, decl_node n); +static void runSimplifyTypes (decl_node__opaque n); /* - walkEnumerationField - + outDefC - */ -static decl_dependentState walkEnumerationField (alists_alist l, decl_node n); +static void outDefC (mcPretty_pretty p, decl_node__opaque n); /* - walkSet - + runPrototypeExported - */ -static decl_dependentState walkSet (alists_alist l, decl_node n); +static void runPrototypeExported (decl_node__opaque n); /* - walkProcType - + runPrototypeDefC - */ -static decl_dependentState walkProcType (alists_alist l, decl_node n); +static void runPrototypeDefC (decl_node__opaque n); /* - walkProcedure - + outImpC - */ -static decl_dependentState walkProcedure (alists_alist l, decl_node n); +static void outImpC (mcPretty_pretty p, decl_node__opaque n); /* - walkParameters - + outDeclsModuleC - */ -static decl_dependentState walkParameters (alists_alist l, Indexing_Index p); +static void outDeclsModuleC (mcPretty_pretty p, decl_scopeT s); /* - walkFuncCall - + outModuleInitC - */ -static decl_dependentState walkFuncCall (alists_alist l, decl_node n); +static void outModuleInitC (mcPretty_pretty p, decl_node__opaque n); /* - walkUnary - + outModuleC - */ -static decl_dependentState walkUnary (alists_alist l, decl_node n); +static void outModuleC (mcPretty_pretty p, decl_node__opaque n); /* - walkBinary - + outC - */ -static decl_dependentState walkBinary (alists_alist l, decl_node n); +static void outC (mcPretty_pretty p, decl_node__opaque n); /* - walkComponentRef - + doIncludeM2 - include modules in module, n. */ -static decl_dependentState walkComponentRef (alists_alist l, decl_node n); +static void doIncludeM2 (decl_node__opaque n); /* - walkPointerRef - + doConstM2 - */ -static decl_dependentState walkPointerRef (alists_alist l, decl_node n); +static void doConstM2 (decl_node__opaque n); /* - walkSetValue - + doProcTypeM2 - */ -static decl_dependentState walkSetValue (alists_alist l, decl_node n); +static void doProcTypeM2 (mcPretty_pretty p, decl_node__opaque n); /* - doDependants - return the dependentState depending upon whether - all dependants have been declared. + doRecordFieldM2 - */ -static decl_dependentState doDependants (alists_alist l, decl_node n); +static void doRecordFieldM2 (mcPretty_pretty p, decl_node__opaque f); /* - tryComplete - returns TRUE if node, n, can be and was completed. + doVarientFieldM2 - */ -static bool tryComplete (decl_node n, decl_nodeProcedure c, decl_nodeProcedure t, decl_nodeProcedure v); +static void doVarientFieldM2 (mcPretty_pretty p, decl_node__opaque n); /* - tryCompleteFromPartial - + doVarientM2 - */ -static bool tryCompleteFromPartial (decl_node n, decl_nodeProcedure t); +static void doVarientM2 (mcPretty_pretty p, decl_node__opaque n); /* - visitIntrinsicFunction - + doRecordM2 - */ -static void visitIntrinsicFunction (alists_alist v, decl_node n, decl_nodeProcedure p); +static void doRecordM2 (mcPretty_pretty p, decl_node__opaque n); /* - visitUnary - + doPointerM2 - */ -static void visitUnary (alists_alist v, decl_node n, decl_nodeProcedure p); +static void doPointerM2 (mcPretty_pretty p, decl_node__opaque n); /* - visitBinary - + doTypeAliasM2 - */ -static void visitBinary (alists_alist v, decl_node n, decl_nodeProcedure p); +static void doTypeAliasM2 (mcPretty_pretty p, decl_node__opaque n); /* - visitBoolean - + doEnumerationM2 - */ -static void visitBoolean (alists_alist v, decl_node n, decl_nodeProcedure p); +static void doEnumerationM2 (mcPretty_pretty p, decl_node__opaque n); /* - visitScope - + doBaseM2 - */ -static void visitScope (alists_alist v, decl_node n, decl_nodeProcedure p); +static void doBaseM2 (mcPretty_pretty p, decl_node__opaque n); /* - visitType - + doSystemM2 - */ -static void visitType (alists_alist v, decl_node n, decl_nodeProcedure p); +static void doSystemM2 (mcPretty_pretty p, decl_node__opaque n); /* - visitIndex - + doTypeM2 - */ -static void visitIndex (alists_alist v, Indexing_Index i, decl_nodeProcedure p); +static void doTypeM2 (mcPretty_pretty p, decl_node__opaque n); /* - visitRecord - + doTypesM2 - */ -static void visitRecord (alists_alist v, decl_node n, decl_nodeProcedure p); +static void doTypesM2 (decl_node__opaque n); /* - visitVarient - + doVarM2 - */ -static void visitVarient (alists_alist v, decl_node n, decl_nodeProcedure p); +static void doVarM2 (decl_node__opaque n); /* - visitVar - + doVarsM2 - */ -static void visitVar (alists_alist v, decl_node n, decl_nodeProcedure p); +static void doVarsM2 (decl_node__opaque n); /* - visitEnumeration - + doTypeNameM2 - */ -static void visitEnumeration (alists_alist v, decl_node n, decl_nodeProcedure p); +static void doTypeNameM2 (mcPretty_pretty p, decl_node__opaque n); /* - visitSubrange - + doParamM2 - */ -static void visitSubrange (alists_alist v, decl_node n, decl_nodeProcedure p); +static void doParamM2 (mcPretty_pretty p, decl_node__opaque n); /* - visitPointer - + doVarParamM2 - */ -static void visitPointer (alists_alist v, decl_node n, decl_nodeProcedure p); +static void doVarParamM2 (mcPretty_pretty p, decl_node__opaque n); /* - visitArray - + doParameterM2 - */ -static void visitArray (alists_alist v, decl_node n, decl_nodeProcedure p); +static void doParameterM2 (mcPretty_pretty p, decl_node__opaque n); /* - visitConst - + doPrototypeM2 - */ -static void visitConst (alists_alist v, decl_node n, decl_nodeProcedure p); +static void doPrototypeM2 (decl_node__opaque n); /* - visitVarParam - + outputPartialM2 - just writes out record, array, and proctypes. + No need for forward declarations in Modula-2 + but we need to keep topological sort happy. + So when asked to output partial we emit the + full type for these types and then do nothing + when trying to complete partial to full. */ -static void visitVarParam (alists_alist v, decl_node n, decl_nodeProcedure p); +static void outputPartialM2 (decl_node__opaque n); /* - visitParam - + outDeclsDefM2 - */ -static void visitParam (alists_alist v, decl_node n, decl_nodeProcedure p); +static void outDeclsDefM2 (mcPretty_pretty p, decl_scopeT s); /* - visitOptarg - + outDefM2 - */ -static void visitOptarg (alists_alist v, decl_node n, decl_nodeProcedure p); +static void outDefM2 (mcPretty_pretty p, decl_node__opaque n); /* - visitRecordField - + outDeclsImpM2 - */ -static void visitRecordField (alists_alist v, decl_node n, decl_nodeProcedure p); +static void outDeclsImpM2 (mcPretty_pretty p, decl_scopeT s); /* - visitVarientField - + outImpM2 - */ -static void visitVarientField (alists_alist v, decl_node n, decl_nodeProcedure p); +static void outImpM2 (mcPretty_pretty p, decl_node__opaque n); /* - visitEnumerationField - + outModuleM2 - */ -static void visitEnumerationField (alists_alist v, decl_node n, decl_nodeProcedure p); +static void outModuleM2 (mcPretty_pretty p, decl_node__opaque n); /* - visitSet - + outM2 - */ -static void visitSet (alists_alist v, decl_node n, decl_nodeProcedure p); +static void outM2 (mcPretty_pretty p, decl_node__opaque n); /* - visitProcType - + addDone - adds node, n, to the doneQ. */ -static void visitProcType (alists_alist v, decl_node n, decl_nodeProcedure p); +static void addDone (decl_node__opaque n); /* - visitSubscript - + addDoneDef - adds node, n, to the doneQ providing + it is not an opaque of the main module we are compiling. */ -static void visitSubscript (alists_alist v, decl_node n, decl_nodeProcedure p); +static void addDoneDef (decl_node__opaque n); /* - visitDecls - + dbgAdd - */ -static void visitDecls (alists_alist v, decl_scopeT s, decl_nodeProcedure p); +static decl_node__opaque dbgAdd (alists_alist l, decl_node__opaque n); /* - visitProcedure - + dbgType - */ -static void visitProcedure (alists_alist v, decl_node n, decl_nodeProcedure p); +static void dbgType (alists_alist l, decl_node__opaque n); /* - visitDef - + dbgPointer - */ -static void visitDef (alists_alist v, decl_node n, decl_nodeProcedure p); +static void dbgPointer (alists_alist l, decl_node__opaque n); /* - visitImp - + dbgRecord - */ -static void visitImp (alists_alist v, decl_node n, decl_nodeProcedure p); +static void dbgRecord (alists_alist l, decl_node__opaque n); /* - visitModule - + dbgVarient - */ -static void visitModule (alists_alist v, decl_node n, decl_nodeProcedure p); +static void dbgVarient (alists_alist l, decl_node__opaque n); /* - visitLoop - + dbgEnumeration - */ -static void visitLoop (alists_alist v, decl_node n, decl_nodeProcedure p); +static void dbgEnumeration (alists_alist l, decl_node__opaque n); /* - visitWhile - + dbgVar - */ -static void visitWhile (alists_alist v, decl_node n, decl_nodeProcedure p); +static void dbgVar (alists_alist l, decl_node__opaque n); /* - visitRepeat - + dbgSubrange - */ -static void visitRepeat (alists_alist v, decl_node n, decl_nodeProcedure p); +static void dbgSubrange (alists_alist l, decl_node__opaque n); /* - visitCase - + dbgArray - */ -static void visitCase (alists_alist v, decl_node n, decl_nodeProcedure p); +static void dbgArray (alists_alist l, decl_node__opaque n); /* - visitCaseLabelList - + doDbg - */ -static void visitCaseLabelList (alists_alist v, decl_node n, decl_nodeProcedure p); +static void doDbg (alists_alist l, decl_node__opaque n); /* - visitCaseList - + dbg - */ -static void visitCaseList (alists_alist v, decl_node n, decl_nodeProcedure p); +static void dbg (const char *listName_, unsigned int _listName_high, const char *symName_, unsigned int _symName_high, decl_node__opaque n); /* - visitRange - + addGenericBody - adds comment node to funccall, return, assignment + nodes. */ -static void visitRange (alists_alist v, decl_node n, decl_nodeProcedure p); +static void addGenericBody (decl_node__opaque n, decl_node__opaque c); /* - visitIf - + addGenericAfter - adds comment node to funccall, return, assignment + nodes. */ -static void visitIf (alists_alist v, decl_node n, decl_nodeProcedure p); +static void addGenericAfter (decl_node__opaque n, decl_node__opaque c); /* - visitElsif - + isAssignment - */ -static void visitElsif (alists_alist v, decl_node n, decl_nodeProcedure p); +static bool isAssignment (decl_node__opaque n); /* - visitFor - + isComment - returns TRUE if node, n, is a comment. */ -static void visitFor (alists_alist v, decl_node n, decl_nodeProcedure p); +static bool isComment (decl_node__opaque n); /* - visitAssignment - + initPair - initialise the commentPair, c. */ -static void visitAssignment (alists_alist v, decl_node n, decl_nodeProcedure p); +static void initPair (decl_commentPair *c); /* - visitComponentRef - + dupExplist - */ -static void visitComponentRef (alists_alist v, decl_node n, decl_nodeProcedure p); +static decl_node__opaque dupExplist (decl_node__opaque n); /* - visitPointerRef - + dupArrayref - */ -static void visitPointerRef (alists_alist v, decl_node n, decl_nodeProcedure p); +static decl_node__opaque dupArrayref (decl_node__opaque n); /* - visitArrayRef - + dupPointerref - */ -static void visitArrayRef (alists_alist v, decl_node n, decl_nodeProcedure p); +static decl_node__opaque dupPointerref (decl_node__opaque n); /* - visitFunccall - + dupComponentref - */ -static void visitFunccall (alists_alist v, decl_node n, decl_nodeProcedure p); +static decl_node__opaque dupComponentref (decl_node__opaque n); /* - visitVarDecl - + dupBinary - */ -static void visitVarDecl (alists_alist v, decl_node n, decl_nodeProcedure p); +static decl_node__opaque dupBinary (decl_node__opaque n); /* - visitExplist - + dupUnary - */ -static void visitExplist (alists_alist v, decl_node n, decl_nodeProcedure p); +static decl_node__opaque dupUnary (decl_node__opaque n); /* - visitExit - + dupFunccall - */ -static void visitExit (alists_alist v, decl_node n, decl_nodeProcedure p); +static decl_node__opaque dupFunccall (decl_node__opaque n); /* - visitReturn - + dupSetValue - */ -static void visitReturn (alists_alist v, decl_node n, decl_nodeProcedure p); +static decl_node__opaque dupSetValue (decl_node__opaque n); /* - visitStmtSeq - + doDupExpr - */ -static void visitStmtSeq (alists_alist v, decl_node n, decl_nodeProcedure p); +static decl_node__opaque doDupExpr (decl_node__opaque n); /* - visitVarargs - + makeSystem - */ -static void visitVarargs (alists_alist v, decl_node n, decl_nodeProcedure p); +static void makeSystem (void); /* - visitSetValue - + makeM2rts - */ -static void visitSetValue (alists_alist v, decl_node n, decl_nodeProcedure p); +static void makeM2rts (void); /* - visitIntrinsic - + makeBitnum - */ -static void visitIntrinsic (alists_alist v, decl_node n, decl_nodeProcedure p); +static decl_node__opaque makeBitnum (void); /* - visitDependants - helper procedure function called from visitNode. - node n has just been visited, this procedure will - visit node, n, dependants. + makeBaseSymbols - */ -static void visitDependants (alists_alist v, decl_node n, decl_nodeProcedure p); +static void makeBaseSymbols (void); /* - visitNode - visits node, n, if it is not already in the alist, v. - It calls p(n) if the node is unvisited. + makeBuiltins - */ -static void visitNode (alists_alist v, decl_node n, decl_nodeProcedure p); +static void makeBuiltins (void); /* - genKind - returns a string depending upon the kind of node, n. + init - */ -static DynamicStrings_String genKind (decl_node n); - -/* - gen - generate a small string describing node, n. -*/ +static void init (void); -static DynamicStrings_String gen (decl_node n); /* - dumpQ - + newNode - create and return a new node of kind k. */ -static void dumpQ (const char *q_, unsigned int _q_high, alists_alist l); +static decl_node__opaque newNode (decl_nodeT k) +{ + decl_node__opaque d; -/* - dumpLists - -*/ + Storage_ALLOCATE ((void **) &d, sizeof (decl_nodeRec)); + if (enableMemsetOnAllocation) + { + d = static_cast (libc_memset (reinterpret_cast (d), 0, static_cast (sizeof ((*d))))); + } + if (d == NULL) + { + M2RTS_HALT (-1); + __builtin_unreachable (); + } + else + { + d->kind = k; + d->at.defDeclared = 0; + d->at.modDeclared = 0; + d->at.firstUsed = 0; + return d; + } + ReturnException ("../../gcc/m2/mc/decl.def", 20, 1); + __builtin_unreachable (); +} -static void dumpLists (void); /* - outputHidden - + disposeNode - dispose node, n. */ -static void outputHidden (decl_node n); - -/* - outputHiddenComplete - -*/ +static void disposeNode (decl_node__opaque *n) +{ + Storage_DEALLOCATE ((void **) &(*n), sizeof (decl_nodeRec)); + (*n) = static_cast (NULL); +} -static void outputHiddenComplete (decl_node n); /* - tryPartial - + newGroup - */ -static bool tryPartial (decl_node n, decl_nodeProcedure pt); +static void newGroup (decl_group *g) +{ + if (freeGroup == NULL) + { + Storage_ALLOCATE ((void **) &(*g), sizeof (decl__T1)); + } + else + { + (*g) = freeGroup; + freeGroup = freeGroup->next; + } +} + /* - outputPartialRecordArrayProcType - + initGroup - returns a group which with all lists initialized. */ -static void outputPartialRecordArrayProcType (decl_node n, decl_node q, unsigned int indirection); +static decl_group initGroup (void) +{ + decl_group g; -/* - outputPartial - -*/ + newGroup (&g); + g->todoQ = alists_initList (); + g->partialQ = alists_initList (); + g->doneQ = alists_initList (); + g->next = NULL; + return g; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} -static void outputPartial (decl_node n); /* - tryOutputTodo - + killGroup - deallocate the group and place the group record into the freeGroup list. */ -static void tryOutputTodo (decl_nodeProcedure c, decl_nodeProcedure t, decl_nodeProcedure v, decl_nodeProcedure pt); +static void killGroup (decl_group *g) +{ + alists_killList (&(*g)->todoQ); + alists_killList (&(*g)->partialQ); + alists_killList (&(*g)->doneQ); + (*g)->next = freeGroup; + freeGroup = (*g); +} + /* - tryOutputPartial - + dupGroup - If g is not NIL then destroy g. + Return a duplicate of GlobalGroup (not g). */ -static void tryOutputPartial (decl_nodeProcedure t); +static decl_group dupGroup (decl_group g) +{ + if (g != NULL) + { + /* Kill old group. */ + killGroup (&g); + } + newGroup (&g); + /* Copy all lists. */ + g->todoQ = alists_duplicateList (globalGroup->todoQ); + g->partialQ = alists_duplicateList (globalGroup->partialQ); + g->doneQ = alists_duplicateList (globalGroup->doneQ); + g->next = NULL; + return g; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} + /* - debugList - + equalGroup - return TRUE if group left = right. */ -static void debugList (const char *a_, unsigned int _a_high, alists_alist l); +static bool equalGroup (decl_group left, decl_group right) +{ + return (left == right) || (((alists_equalList (left->todoQ, right->todoQ)) && (alists_equalList (left->partialQ, right->partialQ))) && (alists_equalList (left->doneQ, right->doneQ))); + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} + /* - debugLists - + isLocal - returns TRUE if symbol, n, is locally declared in a procedure. */ -static void debugLists (void); +static bool isLocal (decl_node__opaque n) +{ + decl_node__opaque s; -/* - addEnumConst - -*/ + s = static_cast (decl_getScope (static_cast (n))); + if (s != NULL) + { + return decl_isProcedure (static_cast (s)); + } + return false; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} -static void addEnumConst (decl_node n); /* - populateTodo - + importEnumFields - if, n, is an enumeration type import the all fields into module, m. */ -static void populateTodo (decl_nodeProcedure p); +static void importEnumFields (decl_node__opaque m, decl_node__opaque n) +{ + decl_node__opaque r; + decl_node__opaque e; + unsigned int i; + unsigned int h; -/* - topologicallyOut - keep trying to resolve the todoQ and partialQ - until there is no change from the global group. -*/ + mcDebug_assert (((decl_isDef (static_cast (m))) || (decl_isModule (static_cast (m)))) || (decl_isImp (static_cast (m)))); + n = static_cast (decl_skipType (static_cast (n))); + if ((n != NULL) && (decl_isEnumeration (static_cast (n)))) + { + i = Indexing_LowIndice (n->enumerationF.listOfSons); + h = Indexing_HighIndice (n->enumerationF.listOfSons); + while (i <= h) + { + e = static_cast (Indexing_GetIndice (n->enumerationF.listOfSons, i)); + r = static_cast (decl_import (static_cast (m), static_cast (e))); + if (e != r) + { + mcMetaError_metaError2 ((const char *) "enumeration field {%1ad} cannot be imported implicitly into {%2d} due to a name clash", 85, (const unsigned char *) &e, (sizeof (e)-1), (const unsigned char *) &m, (sizeof (m)-1)); + } + i += 1; + } + } +} -static void topologicallyOut (decl_nodeProcedure c, decl_nodeProcedure t, decl_nodeProcedure v, decl_nodeProcedure tp, decl_nodeProcedure pc, decl_nodeProcedure pt, decl_nodeProcedure pv); /* - scaffoldStatic - + isComplex - returns TRUE if, n, is the complex type. */ -static void scaffoldStatic (mcPretty_pretty p, decl_node n); +static bool isComplex (decl_node__opaque n) +{ + return n == complexN; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} + /* - emitCtor - + isLongComplex - returns TRUE if, n, is the longcomplex type. */ -static void emitCtor (mcPretty_pretty p, decl_node n); +static bool isLongComplex (decl_node__opaque n) +{ + return n == longcomplexN; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} + /* - scaffoldDynamic - + isShortComplex - returns TRUE if, n, is the shortcomplex type. */ -static void scaffoldDynamic (mcPretty_pretty p, decl_node n); - -/* - scaffoldMain - -*/ +static bool isShortComplex (decl_node__opaque n) +{ + return n == shortcomplexN; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} -static void scaffoldMain (mcPretty_pretty p, decl_node n); /* - outImpInitC - emit the init/fini functions and main function if required. + isAProcType - returns TRUE if, n, is a proctype or proc node. */ -static void outImpInitC (mcPretty_pretty p, decl_node n); - -/* - runSimplifyTypes - -*/ +static bool isAProcType (decl_node__opaque n) +{ + mcDebug_assert (n != NULL); + return (decl_isProcType (static_cast (n))) || (n == procN); + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} -static void runSimplifyTypes (decl_node n); /* - outDefC - + initFixupInfo - initialize the fixupInfo record. */ -static void outDefC (mcPretty_pretty p, decl_node n); +static decl_fixupInfo initFixupInfo (void) +{ + decl_fixupInfo f; -/* - runPrototypeExported - -*/ + f.count = 0; + f.info = Indexing_InitIndex (1); + return f; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} -static void runPrototypeExported (decl_node n); /* - runPrototypeDefC - + makeDef - returns a definition module node named, n. */ -static void runPrototypeDefC (decl_node n); +static decl_node__opaque makeDef (nameKey_Name n) +{ + decl_node__opaque d; -/* - outImpC - -*/ + d = newNode (decl_def); + d->defF.name = n; + d->defF.source = nameKey_NulName; + d->defF.hasHidden = false; + d->defF.forC = false; + d->defF.exported = Indexing_InitIndex (1); + d->defF.importedModules = Indexing_InitIndex (1); + d->defF.constFixup = initFixupInfo (); + d->defF.enumFixup = initFixupInfo (); + initDecls (&d->defF.decls); + d->defF.enumsComplete = false; + d->defF.constsComplete = false; + d->defF.visited = false; + initPair (&d->defF.com); + return d; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} -static void outImpC (mcPretty_pretty p, decl_node n); /* - outDeclsModuleC - + makeImp - returns an implementation module node named, n. */ -static void outDeclsModuleC (mcPretty_pretty p, decl_scopeT s); +static decl_node__opaque makeImp (nameKey_Name n) +{ + decl_node__opaque d; -/* - outModuleInitC - -*/ + d = newNode (decl_imp); + d->impF.name = n; + d->impF.source = nameKey_NulName; + d->impF.importedModules = Indexing_InitIndex (1); + d->impF.constFixup = initFixupInfo (); + d->impF.enumFixup = initFixupInfo (); + initDecls (&d->impF.decls); + d->impF.beginStatements = static_cast (NULL); + d->impF.finallyStatements = static_cast (NULL); + d->impF.definitionModule = static_cast (NULL); + d->impF.enumsComplete = false; + d->impF.constsComplete = false; + d->impF.visited = false; + initPair (&d->impF.com); + return d; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} -static void outModuleInitC (mcPretty_pretty p, decl_node n); /* - outModuleC - + makeModule - returns a module node named, n. */ -static void outModuleC (mcPretty_pretty p, decl_node n); +static decl_node__opaque makeModule (nameKey_Name n) +{ + decl_node__opaque d; -/* - outC - -*/ + d = newNode (decl_module); + d->moduleF.name = n; + d->moduleF.source = nameKey_NulName; + d->moduleF.importedModules = Indexing_InitIndex (1); + d->moduleF.constFixup = initFixupInfo (); + d->moduleF.enumFixup = initFixupInfo (); + initDecls (&d->moduleF.decls); + d->moduleF.beginStatements = static_cast (NULL); + d->moduleF.finallyStatements = static_cast (NULL); + d->moduleF.enumsComplete = false; + d->moduleF.constsComplete = false; + d->moduleF.visited = false; + initPair (&d->moduleF.com); + return d; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} -static void outC (mcPretty_pretty p, decl_node n); /* - doIncludeM2 - include modules in module, n. + isDefForC - returns TRUE if the definition module was defined FOR "C". */ -static void doIncludeM2 (decl_node n); - -/* - doConstM2 - -*/ +static bool isDefForC (decl_node__opaque n) +{ + return (decl_isDef (static_cast (n))) && n->defF.forC; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} -static void doConstM2 (decl_node n); /* - doProcTypeM2 - + initDecls - initialize the decls, scopeT. */ -static void doProcTypeM2 (mcPretty_pretty p, decl_node n); - -/* - doRecordFieldM2 - -*/ +static void initDecls (decl_scopeT *decls) +{ + (*decls).symbols = symbolKey_initTree (); + (*decls).constants = Indexing_InitIndex (1); + (*decls).types = Indexing_InitIndex (1); + (*decls).procedures = Indexing_InitIndex (1); + (*decls).variables = Indexing_InitIndex (1); +} -static void doRecordFieldM2 (mcPretty_pretty p, decl_node f); /* - doVarientFieldM2 - + addTo - adds node, d, to scope decls and returns, d. + It stores, d, in the symbols tree associated with decls. */ -static void doVarientFieldM2 (mcPretty_pretty p, decl_node n); +static decl_node__opaque addTo (decl_scopeT *decls, decl_node__opaque d) +{ + nameKey_Name n; -/* - doVarientM2 - -*/ + n = decl_getSymName (static_cast (d)); + if (n != nameKey_NulName) + { + /* avoid gcc warning by using compound statement even if not strictly necessary. */ + if ((symbolKey_getSymKey ((*decls).symbols, n)) == NULL) + { + symbolKey_putSymKey ((*decls).symbols, n, reinterpret_cast (d)); + } + else + { + mcMetaError_metaError1 ((const char *) "{%1DMad} was declared", 21, (const unsigned char *) &d, (sizeof (d)-1)); + mcMetaError_metaError1 ((const char *) "{%1k} and is being declared again", 33, (const unsigned char *) &n, (sizeof (n)-1)); + } + } + if (decl_isConst (static_cast (d))) + { + Indexing_IncludeIndiceIntoIndex ((*decls).constants, reinterpret_cast (d)); + } + else if (decl_isVar (static_cast (d))) + { + /* avoid dangling else. */ + Indexing_IncludeIndiceIntoIndex ((*decls).variables, reinterpret_cast (d)); + } + else if (decl_isType (static_cast (d))) + { + /* avoid dangling else. */ + Indexing_IncludeIndiceIntoIndex ((*decls).types, reinterpret_cast (d)); + } + else if (decl_isProcedure (static_cast (d))) + { + /* avoid dangling else. */ + Indexing_IncludeIndiceIntoIndex ((*decls).procedures, reinterpret_cast (d)); + if (debugDecl) + { + libc_printf ((const char *) "%d procedures on the dynamic array\\n", 36, Indexing_HighIndice ((*decls).procedures)); + } + } + return d; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} -static void doVarientM2 (mcPretty_pretty p, decl_node n); /* - doRecordM2 - + export - export node, n, from definition module, d. */ -static void doRecordM2 (mcPretty_pretty p, decl_node n); +static void export_ (decl_node__opaque d, decl_node__opaque n) +{ + mcDebug_assert (decl_isDef (static_cast (d))); + Indexing_IncludeIndiceIntoIndex (d->defF.exported, reinterpret_cast (n)); +} + /* - doPointerM2 - + addToScope - adds node, n, to the current scope and returns, n. */ -static void doPointerM2 (mcPretty_pretty p, decl_node n); +static decl_node__opaque addToScope (decl_node__opaque n) +{ + decl_node__opaque s; + unsigned int i; -/* - doTypeAliasM2 - -*/ + i = Indexing_HighIndice (scopeStack); + s = static_cast (Indexing_GetIndice (scopeStack, i)); + if (decl_isProcedure (static_cast (s))) + { + if (debugDecl) + { + outText (doP, (const char *) "adding ", 7); + doNameC (doP, n); + outText (doP, (const char *) " to procedure\\n", 15); + } + return addTo (&s->procedureF.decls, n); + } + else if (decl_isModule (static_cast (s))) + { + /* avoid dangling else. */ + if (debugDecl) + { + outText (doP, (const char *) "adding ", 7); + doNameC (doP, n); + outText (doP, (const char *) " to module\\n", 12); + } + return addTo (&s->moduleF.decls, n); + } + else if (decl_isDef (static_cast (s))) + { + /* avoid dangling else. */ + if (debugDecl) + { + outText (doP, (const char *) "adding ", 7); + doNameC (doP, n); + outText (doP, (const char *) " to definition module\\n", 23); + } + export_ (s, n); + return addTo (&s->defF.decls, n); + } + else if (decl_isImp (static_cast (s))) + { + /* avoid dangling else. */ + if (debugDecl) + { + outText (doP, (const char *) "adding ", 7); + doNameC (doP, n); + outText (doP, (const char *) " to implementation module\\n", 27); + } + return addTo (&s->impF.decls, n); + } + M2RTS_HALT (-1); + __builtin_unreachable (); + ReturnException ("../../gcc/m2/mc/decl.def", 20, 1); + __builtin_unreachable (); +} -static void doTypeAliasM2 (mcPretty_pretty p, decl_node n); /* - doEnumerationM2 - + addModuleToScope - adds module, i, to module, m, scope. */ -static void doEnumerationM2 (mcPretty_pretty p, decl_node n); +static void addModuleToScope (decl_node__opaque m, decl_node__opaque i) +{ + mcDebug_assert ((decl_getDeclScope ()) == m); + if ((decl_lookupSym (decl_getSymName (static_cast (i)))) == NULL) + { + i = addToScope (i); + } +} + /* - doBaseM2 - + completedEnum - assign boolean enumsComplete to TRUE if a definition, + implementation or module symbol. */ -static void doBaseM2 (mcPretty_pretty p, decl_node n); +static void completedEnum (decl_node__opaque n) +{ + mcDebug_assert (((decl_isDef (static_cast (n))) || (decl_isImp (static_cast (n)))) || (decl_isModule (static_cast (n)))); + if (decl_isDef (static_cast (n))) + { + n->defF.enumsComplete = true; + } + else if (decl_isImp (static_cast (n))) + { + /* avoid dangling else. */ + n->impF.enumsComplete = true; + } + else if (decl_isModule (static_cast (n))) + { + /* avoid dangling else. */ + n->moduleF.enumsComplete = true; + } +} + /* - doSystemM2 - + setUnary - sets a unary node to contain, arg, a, and type, t. */ -static void doSystemM2 (mcPretty_pretty p, decl_node n); - -/* - doTypeM2 - -*/ +static void setUnary (decl_node__opaque u, decl_nodeT k, decl_node__opaque a, decl_node__opaque t) +{ + switch (k) + { + case decl_constexp: + case decl_deref: + case decl_chr: + case decl_cap: + case decl_abs: + case decl_float: + case decl_trunc: + case decl_ord: + case decl_high: + case decl_throw: + case decl_re: + case decl_im: + case decl_not: + case decl_neg: + case decl_adr: + case decl_size: + case decl_tsize: + case decl_min: + case decl_max: + u->kind = k; + u->unaryF.arg = a; + u->unaryF.resultType = t; + break; -static void doTypeM2 (mcPretty_pretty p, decl_node n); -/* - doTypesM2 - -*/ + default: + CaseException ("../../gcc/m2/mc/decl.def", 20, 1); + __builtin_unreachable (); + } +} -static void doTypesM2 (decl_node n); /* - doVarM2 - + putVarBool - assigns the four booleans associated with a variable. */ -static void doVarM2 (decl_node n); - -/* - doVarsM2 - -*/ +static void putVarBool (decl_node__opaque v, bool init, bool param, bool isvar, bool isused) +{ + mcDebug_assert (decl_isVar (static_cast (v))); + v->varF.isInitialised = init; + v->varF.isParameter = param; + v->varF.isVarParameter = isvar; + v->varF.isUsed = isused; +} -static void doVarsM2 (decl_node n); /* - doTypeNameM2 - + checkPtr - in C++ we need to create a typedef for a pointer + in case we need to use reinterpret_cast. */ -static void doTypeNameM2 (mcPretty_pretty p, decl_node n); +static decl_node__opaque checkPtr (decl_node__opaque n) +{ + DynamicStrings_String s; + decl_node__opaque p; -/* - doParamM2 - -*/ + if (lang == decl_ansiCP) + { + if (decl_isPointer (static_cast (n))) + { + s = tempName (); + p = static_cast (decl_makeType (nameKey_makekey (DynamicStrings_string (s)))); + decl_putType (static_cast (p), static_cast (n)); + s = DynamicStrings_KillString (s); + return p; + } + } + return n; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} -static void doParamM2 (mcPretty_pretty p, decl_node n); /* - doVarParamM2 - + isVarDecl - returns TRUE if, n, is a vardecl node. */ -static void doVarParamM2 (mcPretty_pretty p, decl_node n); - -/* - doParameterM2 - -*/ +static bool isVarDecl (decl_node__opaque n) +{ + return n->kind == decl_vardecl; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} -static void doParameterM2 (mcPretty_pretty p, decl_node n); /* - doPrototypeM2 - + makeVariablesFromParameters - creates variables which are really parameters. */ -static void doPrototypeM2 (decl_node n); +static void makeVariablesFromParameters (decl_node__opaque proc, decl_node__opaque id, decl_node__opaque type, bool isvar, bool isused) +{ + decl_node__opaque v; + unsigned int i; + unsigned int n; + nameKey_Name m; + DynamicStrings_String s; -/* - outputPartialM2 - just writes out record, array, and proctypes. - No need for forward declarations in Modula-2 - but we need to keep topological sort happy. - So when asked to output partial we emit the - full type for these types and then do nothing - when trying to complete partial to full. -*/ + mcDebug_assert (decl_isProcedure (static_cast (proc))); + mcDebug_assert (isIdentList (id)); + i = 1; + n = wlists_noOfItemsInList (id->identlistF.names); + while (i <= n) + { + m = static_cast (wlists_getItemFromList (id->identlistF.names, i)); + v = static_cast (decl_makeVar (m)); + decl_putVar (static_cast (v), static_cast (type), static_cast (NULL)); + putVarBool (v, true, true, isvar, isused); + if (debugScopes) + { + libc_printf ((const char *) "adding parameter variable into top scope\\n", 42); + dumpScopes (); + libc_printf ((const char *) " variable name is: ", 19); + s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (m)); + if ((DynamicStrings_KillString (SFIO_WriteS (FIO_StdOut, s))) == NULL) + {} /* empty. */ + libc_printf ((const char *) "\\n", 2); + } + i += 1; + } +} -static void outputPartialM2 (decl_node n); /* - outDeclsDefM2 - + addProcedureToScope - add a procedure name n and node d to the + current scope. */ -static void outDeclsDefM2 (mcPretty_pretty p, decl_scopeT s); +static decl_node__opaque addProcedureToScope (decl_node__opaque d, nameKey_Name n) +{ + decl_node__opaque m; + unsigned int i; -/* - outDefM2 - -*/ + i = Indexing_HighIndice (scopeStack); + m = static_cast (Indexing_GetIndice (scopeStack, i)); + if (((decl_isDef (static_cast (m))) && ((decl_getSymName (static_cast (m))) == (nameKey_makeKey ((const char *) "M2RTS", 5)))) && ((decl_getSymName (static_cast (d))) == (nameKey_makeKey ((const char *) "HALT", 4)))) + { + haltN = d; + symbolKey_putSymKey (baseSymbols, n, reinterpret_cast (haltN)); + } + return addToScope (d); + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} -static void outDefM2 (mcPretty_pretty p, decl_node n); /* - outDeclsImpM2 - + putProcTypeReturn - sets the return type of, proc, to, type. */ -static void outDeclsImpM2 (mcPretty_pretty p, decl_scopeT s); - -/* - outImpM2 - -*/ +static void putProcTypeReturn (decl_node__opaque proc, decl_node__opaque type) +{ + mcDebug_assert (decl_isProcType (static_cast (proc))); + proc->proctypeF.returnType = type; + initNodeOpaqueState (proc); +} -static void outImpM2 (mcPretty_pretty p, decl_node n); /* - outModuleM2 - + putProcTypeOptReturn - sets, proc, to have an optional return type. */ -static void outModuleM2 (mcPretty_pretty p, decl_node n); - -/* - outM2 - -*/ +static void putProcTypeOptReturn (decl_node__opaque proc) +{ + mcDebug_assert (decl_isProcType (static_cast (proc))); + proc->proctypeF.returnopt = true; +} -static void outM2 (mcPretty_pretty p, decl_node n); /* - addDone - adds node, n, to the doneQ. + makeOptParameter - creates and returns an optarg. */ -static void addDone (decl_node n); +static decl_node__opaque makeOptParameter (decl_node__opaque l, decl_node__opaque type, decl_node__opaque init) +{ + decl_node__opaque n; -/* - addDoneDef - adds node, n, to the doneQ providing - it is not an opaque of the main module we are compiling. -*/ + n = newNode (decl_optarg); + n->optargF.namelist = l; + n->optargF.type = type; + n->optargF.init = init; + n->optargF.scope = static_cast (NULL); + return n; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} -static void addDoneDef (decl_node n); /* - dbgAdd - + setwatch - assign the globalNode to n. */ -static decl_node dbgAdd (alists_alist l, decl_node n); - -/* - dbgType - -*/ +static bool setwatch (decl_node__opaque n) +{ + globalNode = n; + return true; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} -static void dbgType (alists_alist l, decl_node n); /* - dbgPointer - + runwatch - set the globalNode to an identlist. */ -static void dbgPointer (alists_alist l, decl_node n); - -/* - dbgRecord - -*/ +static bool runwatch (void) +{ + return globalNode->kind == decl_identlist; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} -static void dbgRecord (alists_alist l, decl_node n); /* - dbgVarient - + isIdentList - returns TRUE if, n, is an identlist. */ -static void dbgVarient (alists_alist l, decl_node n); +static bool isIdentList (decl_node__opaque n) +{ + return n->kind == decl_identlist; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} + /* - dbgEnumeration - + identListLen - returns the length of identlist. */ -static void dbgEnumeration (alists_alist l, decl_node n); +static unsigned int identListLen (decl_node__opaque n) +{ + if (n == NULL) + { + return 0; + } + else + { + mcDebug_assert (isIdentList (n)); + return wlists_noOfItemsInList (n->identlistF.names); + } + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} + /* - dbgVar - + checkParameters - placeholder for future parameter checking. */ -static void dbgVar (alists_alist l, decl_node n); +static void checkParameters (decl_node__opaque p, decl_node__opaque i, decl_node__opaque type, bool isvar, bool isused) +{ + /* do check. */ + disposeNode (&i); +} + /* - dbgSubrange - + checkMakeVariables - create shadow local variables for parameters providing that + procedure n has not already been built and we are compiling + a module or an implementation module. */ -static void dbgSubrange (alists_alist l, decl_node n); +static void checkMakeVariables (decl_node__opaque n, decl_node__opaque i, decl_node__opaque type, bool isvar, bool isused) +{ + if (((decl_isImp (static_cast (currentModule))) || (decl_isModule (static_cast (currentModule)))) && ! n->procedureF.built) + { + makeVariablesFromParameters (n, i, type, isvar, isused); + } +} + /* - dbgArray - + makeVarientField - create a varient field within varient, v, + The new varient field is returned. */ -static void dbgArray (alists_alist l, decl_node n); +static decl_node__opaque makeVarientField (decl_node__opaque v, decl_node__opaque p) +{ + decl_node__opaque n; -/* - doDbg - -*/ + n = newNode (decl_varientfield); + n->varientfieldF.name = nameKey_NulName; + n->varientfieldF.parent = p; + n->varientfieldF.varient = v; + n->varientfieldF.simple = false; + n->varientfieldF.listOfSons = Indexing_InitIndex (1); + n->varientfieldF.scope = static_cast (decl_getDeclScope ()); + return n; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} -static void doDbg (alists_alist l, decl_node n); /* - dbg - + putFieldVarient - places the field varient, f, as a brother to, the + varient symbol, v, and also tells, f, that its varient + parent is, v. */ -static void dbg (decl_node n); - -/* - addGenericBody - adds comment node to funccall, return, assignment - nodes. -*/ - -static void addGenericBody (decl_node n, decl_node c); - -/* - addGenericAfter - adds comment node to funccall, return, assignment - nodes. -*/ +static void putFieldVarient (decl_node__opaque f, decl_node__opaque v) +{ + mcDebug_assert (decl_isVarient (static_cast (v))); + mcDebug_assert (decl_isVarientField (static_cast (f))); + switch (v->kind) + { + case decl_varient: + Indexing_IncludeIndiceIntoIndex (v->varientF.listOfSons, reinterpret_cast (f)); + break; -static void addGenericAfter (decl_node n, decl_node c); -/* - isAssignment - -*/ + default: + CaseException ("../../gcc/m2/mc/decl.def", 20, 1); + __builtin_unreachable (); + } + switch (f->kind) + { + case decl_varientfield: + f->varientfieldF.varient = v; + break; -static bool isAssignment (decl_node n); -/* - isComment - returns TRUE if node, n, is a comment. -*/ + default: + CaseException ("../../gcc/m2/mc/decl.def", 20, 1); + __builtin_unreachable (); + } +} -static bool isComment (decl_node n); /* - initPair - initialise the commentPair, c. + putFieldRecord - create a new recordfield and place it into record r. + The new field has a tagname and type and can have a + variant field v. */ -static void initPair (decl_commentPair *c); - -/* - dupExplist - -*/ +static decl_node__opaque putFieldRecord (decl_node__opaque r, nameKey_Name tag, decl_node__opaque type, decl_node__opaque v) +{ + decl_node__opaque f; + decl_node__opaque n; + decl_node__opaque p; -static decl_node dupExplist (decl_node n); + n = newNode (decl_recordfield); + switch (r->kind) + { + case decl_record: + Indexing_IncludeIndiceIntoIndex (r->recordF.listOfSons, reinterpret_cast (n)); + /* ensure that field, n, is in the parents Local Symbols. */ + if (tag != nameKey_NulName) + { + /* avoid gcc warning by using compound statement even if not strictly necessary. */ + if ((symbolKey_getSymKey (r->recordF.localSymbols, tag)) == symbolKey_NulKey) + { + symbolKey_putSymKey (r->recordF.localSymbols, tag, reinterpret_cast (n)); + } + else + { + f = static_cast (symbolKey_getSymKey (r->recordF.localSymbols, tag)); + mcMetaError_metaErrors1 ((const char *) "field record {%1Dad} has already been declared", 46, (const char *) "field record duplicate", 22, (const unsigned char *) &f, (sizeof (f)-1)); + } + } + break; -/* - dupArrayref - -*/ + case decl_varientfield: + Indexing_IncludeIndiceIntoIndex (r->varientfieldF.listOfSons, reinterpret_cast (n)); + p = getParent (r); + mcDebug_assert (p->kind == decl_record); + if (tag != nameKey_NulName) + { + symbolKey_putSymKey (p->recordF.localSymbols, tag, reinterpret_cast (n)); + } + break; -static decl_node dupArrayref (decl_node n); -/* - dupPointerref - -*/ + default: + CaseException ("../../gcc/m2/mc/decl.def", 20, 1); + __builtin_unreachable (); + } + /* fill in, n. */ + n->recordfieldF.type = type; + n->recordfieldF.name = tag; + n->recordfieldF.parent = r; + n->recordfieldF.varient = v; + n->recordfieldF.tag = false; + n->recordfieldF.scope = static_cast (NULL); + initCname (&n->recordfieldF.cname); + /* + IF r^.kind=record + THEN + doRecordM2 (doP, r) + END ; + */ + return n; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} -static decl_node dupPointerref (decl_node n); /* - dupComponentref - + ensureOrder - ensures that, a, and, b, exist in, i, and also + ensure that, a, is before, b. */ -static decl_node dupComponentref (decl_node n); - -/* - dupBinary - -*/ +static void ensureOrder (Indexing_Index i, decl_node__opaque a, decl_node__opaque b) +{ + mcDebug_assert (Indexing_IsIndiceInIndex (i, reinterpret_cast (a))); + mcDebug_assert (Indexing_IsIndiceInIndex (i, reinterpret_cast (b))); + Indexing_RemoveIndiceFromIndex (i, reinterpret_cast (a)); + Indexing_RemoveIndiceFromIndex (i, reinterpret_cast (b)); + Indexing_IncludeIndiceIntoIndex (i, reinterpret_cast (a)); + Indexing_IncludeIndiceIntoIndex (i, reinterpret_cast (b)); + mcDebug_assert (Indexing_IsIndiceInIndex (i, reinterpret_cast (a))); + mcDebug_assert (Indexing_IsIndiceInIndex (i, reinterpret_cast (b))); +} -static decl_node dupBinary (decl_node n); /* - dupUnary - + putVarientTag - places tag into variant v. */ -static decl_node dupUnary (decl_node n); +static void putVarientTag (decl_node__opaque v, decl_node__opaque tag) +{ + decl_node__opaque p; -/* - dupFunccall - -*/ + mcDebug_assert (decl_isVarient (static_cast (v))); + switch (v->kind) + { + case decl_varient: + v->varientF.tag = tag; + break; -static decl_node dupFunccall (decl_node n); -/* - dupSetValue - -*/ + default: + CaseException ("../../gcc/m2/mc/decl.def", 20, 1); + __builtin_unreachable (); + } +} -static decl_node dupSetValue (decl_node n); /* - doDupExpr - + getParent - returns the parent field of recordfield or varientfield symbol, n. */ -static decl_node doDupExpr (decl_node n); +static decl_node__opaque getParent (decl_node__opaque n) +{ + switch (n->kind) + { + case decl_recordfield: + return n->recordfieldF.parent; + break; -/* - makeSystem - -*/ + case decl_varientfield: + return n->varientfieldF.parent; + break; -static void makeSystem (void); -/* - makeM2rts - -*/ + default: + CaseException ("../../gcc/m2/mc/decl.def", 20, 1); + __builtin_unreachable (); + } + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} -static void makeM2rts (void); /* - makeBitnum - + getRecord - returns the record associated with node, n. + (Parental record). */ -static decl_node makeBitnum (void); +static decl_node__opaque getRecord (decl_node__opaque n) +{ + mcDebug_assert (n->kind != decl_varient); /* if this fails then we need to add parent field to varient. */ + switch (n->kind) + { + case decl_record: + return n; /* if this fails then we need to add parent field to varient. */ + break; -/* - makeBaseSymbols - -*/ + case decl_varientfield: + return getRecord (getParent (n)); + break; -static void makeBaseSymbols (void); -/* - makeBuiltins - -*/ + default: + CaseException ("../../gcc/m2/mc/decl.def", 20, 1); + __builtin_unreachable (); + } + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} -static void makeBuiltins (void); /* - init - + isConstExp - return TRUE if the node kind is a constexp. */ -static void init (void); +static bool isConstExp (decl_node__opaque c) +{ + mcDebug_assert (c != NULL); + return c->kind == decl_constexp; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} /* - newNode - create and return a new node of kind k. + addEnumToModule - adds enumeration type, e, into the list of enums + in module, m. */ -static decl_node newNode (decl_nodeT k) +static void addEnumToModule (decl_node__opaque m, decl_node__opaque e) { - decl_node d; - - Storage_ALLOCATE ((void **) &d, sizeof (decl_nodeRec)); - if (enableMemsetOnAllocation) + mcDebug_assert ((decl_isEnumeration (static_cast (e))) || (decl_isEnumerationField (static_cast (e)))); + mcDebug_assert (((decl_isModule (static_cast (m))) || (decl_isDef (static_cast (m)))) || (decl_isImp (static_cast (m)))); + if (decl_isModule (static_cast (m))) { - d = static_cast (libc_memset (reinterpret_cast (d), 0, static_cast (sizeof ((*d))))); + Indexing_IncludeIndiceIntoIndex (m->moduleF.enumFixup.info, reinterpret_cast (e)); } - if (d == NULL) + else if (decl_isDef (static_cast (m))) { - M2RTS_HALT (-1); - __builtin_unreachable (); + /* avoid dangling else. */ + Indexing_IncludeIndiceIntoIndex (m->defF.enumFixup.info, reinterpret_cast (e)); } - else + else if (decl_isImp (static_cast (m))) { - d->kind = k; - d->at.defDeclared = 0; - d->at.modDeclared = 0; - d->at.firstUsed = 0; - return d; + /* avoid dangling else. */ + Indexing_IncludeIndiceIntoIndex (m->impF.enumFixup.info, reinterpret_cast (e)); } - ReturnException ("../../gcc/m2/mc/decl.def", 20, 1); - __builtin_unreachable (); } /* - disposeNode - dispose node, n. + getNextFixup - return the next fixup from from f. */ -static void disposeNode (decl_node *n) +static decl_node__opaque getNextFixup (decl_fixupInfo *f) { - Storage_DEALLOCATE ((void **) &(*n), sizeof (decl_nodeRec)); - (*n) = NULL; + (*f).count += 1; + return static_cast (Indexing_GetIndice ((*f).info, (*f).count)); + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); } /* - newGroup - + doMakeEnum - create an enumeration type and add it to the current module. */ -static void newGroup (decl_group *g) +static decl_node__opaque doMakeEnum (void) { - if (freeGroup == NULL) - { - Storage_ALLOCATE ((void **) &(*g), sizeof (decl__T15)); - } - else - { - (*g) = freeGroup; - freeGroup = freeGroup->next; - } + decl_node__opaque e; + + e = newNode (decl_enumeration); + e->enumerationF.noOfElements = 0; + e->enumerationF.localSymbols = symbolKey_initTree (); + e->enumerationF.scope = static_cast (decl_getDeclScope ()); + e->enumerationF.listOfSons = Indexing_InitIndex (1); + e->enumerationF.low = static_cast (NULL); + e->enumerationF.high = static_cast (NULL); + addEnumToModule (currentModule, e); + return e; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); } /* - initGroup - returns a group which with all lists initialized. + doMakeEnumField - create an enumeration field name and add it to enumeration e. + Return the new field. */ -static decl_group initGroup (void) +static decl_node__opaque doMakeEnumField (decl_node__opaque e, nameKey_Name n) { - decl_group g; + decl_node__opaque f; - newGroup (&g); - g->todoQ = alists_initList (); - g->partialQ = alists_initList (); - g->doneQ = alists_initList (); - g->next = NULL; - return g; + mcDebug_assert (decl_isEnumeration (static_cast (e))); + f = static_cast (decl_lookupSym (n)); + if (f == NULL) + { + f = newNode (decl_enumerationfield); + symbolKey_putSymKey (e->enumerationF.localSymbols, n, reinterpret_cast (f)); + Indexing_IncludeIndiceIntoIndex (e->enumerationF.listOfSons, reinterpret_cast (f)); + f->enumerationfieldF.name = n; + f->enumerationfieldF.type = e; + f->enumerationfieldF.scope = static_cast (decl_getDeclScope ()); + f->enumerationfieldF.value = e->enumerationF.noOfElements; + initCname (&f->enumerationfieldF.cname); + e->enumerationF.noOfElements += 1; + mcDebug_assert ((Indexing_GetIndice (e->enumerationF.listOfSons, e->enumerationF.noOfElements)) == f); + addEnumToModule (currentModule, f); + if (e->enumerationF.low == NULL) + { + e->enumerationF.low = f; + } + e->enumerationF.high = f; + return addToScope (f); + } + else + { + mcMetaError_metaErrors2 ((const char *) "cannot create enumeration field {%1k} as the name is already in use", 67, (const char *) "{%2DMad} was declared elsewhere", 31, (const unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) &f, (sizeof (f)-1)); + } + return f; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - killGroup - deallocate the group and place the group record into the freeGroup list. + getExpList - returns the, n, th argument in an explist. */ -static void killGroup (decl_group *g) +static decl_node__opaque getExpList (decl_node__opaque p, unsigned int n) { - alists_killList (&(*g)->todoQ); - alists_killList (&(*g)->partialQ); - alists_killList (&(*g)->doneQ); - (*g)->next = freeGroup; - freeGroup = (*g); + mcDebug_assert (p != NULL); + mcDebug_assert (decl_isExpList (static_cast (p))); + mcDebug_assert (n <= (Indexing_HighIndice (p->explistF.exp))); + return static_cast (Indexing_GetIndice (p->explistF.exp, n)); + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); } /* - dupGroup - If g is not NIL then destroy g. - Return a duplicate of GlobalGroup (not g). + expListLen - returns the length of explist, p. */ -static decl_group dupGroup (decl_group g) +static unsigned int expListLen (decl_node__opaque p) { - if (g != NULL) + if (p == NULL) { - /* Kill old group. */ - killGroup (&g); + return 0; + } + else + { + mcDebug_assert (decl_isExpList (static_cast (p))); + return Indexing_HighIndice (p->explistF.exp); } - newGroup (&g); - /* Copy all lists. */ - g->todoQ = alists_duplicateList (globalGroup->todoQ); - g->partialQ = alists_duplicateList (globalGroup->partialQ); - g->doneQ = alists_duplicateList (globalGroup->doneQ); - g->next = NULL; - return g; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - equalGroup - return TRUE if group left = right. + getConstExpComplete - gets the field from the def or imp or module, n. */ -static bool equalGroup (decl_group left, decl_group right) +static bool getConstExpComplete (decl_node__opaque n) { - return (left == right) || (((alists_equalList (left->todoQ, right->todoQ)) && (alists_equalList (left->partialQ, right->partialQ))) && (alists_equalList (left->doneQ, right->doneQ))); - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); -} + switch (n->kind) + { + case decl_def: + return n->defF.constsComplete; + break; + case decl_imp: + return n->impF.constsComplete; + break; -/* - isLocal - returns TRUE if symbol, n, is locally declared in a procedure. -*/ + case decl_module: + return n->moduleF.constsComplete; + break; -static bool isLocal (decl_node n) -{ - decl_node s; - s = decl_getScope (n); - if (s != NULL) - { - return decl_isProcedure (s); + default: + CaseException ("../../gcc/m2/mc/decl.def", 20, 1); + __builtin_unreachable (); } - return false; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - importEnumFields - if, n, is an enumeration type import the all fields into module, m. + addConstToModule - adds const exp, e, into the list of constant + expressions in module, m. */ -static void importEnumFields (decl_node m, decl_node n) +static void addConstToModule (decl_node__opaque m, decl_node__opaque e) { - decl_node r; - decl_node e; - unsigned int i; - unsigned int h; - - mcDebug_assert (((decl_isDef (m)) || (decl_isModule (m))) || (decl_isImp (m))); - n = decl_skipType (n); - if ((n != NULL) && (decl_isEnumeration (n))) + mcDebug_assert (((decl_isModule (static_cast (m))) || (decl_isDef (static_cast (m)))) || (decl_isImp (static_cast (m)))); + if (decl_isModule (static_cast (m))) { - i = Indexing_LowIndice (n->enumerationF.listOfSons); - h = Indexing_HighIndice (n->enumerationF.listOfSons); - while (i <= h) - { - e = static_cast (Indexing_GetIndice (n->enumerationF.listOfSons, i)); - r = decl_import (m, e); - if (e != r) - { - mcMetaError_metaError2 ((const char *) "enumeration field {%1ad} cannot be imported implicitly into {%2d} due to a name clash", 85, (const unsigned char *) &e, (sizeof (e)-1), (const unsigned char *) &m, (sizeof (m)-1)); - } - i += 1; - } + Indexing_IncludeIndiceIntoIndex (m->moduleF.constFixup.info, reinterpret_cast (e)); + } + else if (decl_isDef (static_cast (m))) + { + /* avoid dangling else. */ + Indexing_IncludeIndiceIntoIndex (m->defF.constFixup.info, reinterpret_cast (e)); + } + else if (decl_isImp (static_cast (m))) + { + /* avoid dangling else. */ + Indexing_IncludeIndiceIntoIndex (m->impF.constFixup.info, reinterpret_cast (e)); } } /* - isComplex - returns TRUE if, n, is the complex type. + doMakeConstExp - create a constexp node and add it to the current module. */ -static bool isComplex (decl_node n) +static decl_node__opaque doMakeConstExp (void) { - return n == complexN; + decl_node__opaque c; + + c = makeUnary (decl_constexp, static_cast (NULL), static_cast (NULL)); + addConstToModule (currentModule, c); + return c; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - isLongComplex - returns TRUE if, n, is the longcomplex type. + isAnyType - return TRUE if node n is any type kind. */ -static bool isLongComplex (decl_node n) +static bool isAnyType (decl_node__opaque n) { - return n == longcomplexN; - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); -} - + mcDebug_assert (n != NULL); + switch (n->kind) + { + case decl_address: + case decl_loc: + case decl_byte: + case decl_word: + case decl_char: + case decl_cardinal: + case decl_longcard: + case decl_shortcard: + case decl_integer: + case decl_longint: + case decl_shortint: + case decl_complex: + case decl_longcomplex: + case decl_shortcomplex: + case decl_bitset: + case decl_boolean: + case decl_proc: + case decl_type: + return true; + break; -/* - isShortComplex - returns TRUE if, n, is the shortcomplex type. -*/ -static bool isShortComplex (decl_node n) -{ - return n == shortcomplexN; + default: + return false; + break; + } /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - isAProcType - returns TRUE if, n, is a proctype or proc node. + makeVal - creates a VAL (type, expression) node. */ -static bool isAProcType (decl_node n) +static decl_node__opaque makeVal (decl_node__opaque params) { - mcDebug_assert (n != NULL); - return (decl_isProcType (n)) || (n == procN); - /* static analysis guarentees a RETURN statement will be used before here. */ + mcDebug_assert (decl_isExpList (static_cast (params))); + if ((expListLen (params)) == 2) + { + return makeBinary (decl_val, getExpList (params, 1), getExpList (params, 2), getExpList (params, 1)); + } + else + { + M2RTS_HALT (-1); + __builtin_unreachable (); + } + ReturnException ("../../gcc/m2/mc/decl.def", 20, 1); __builtin_unreachable (); } /* - initFixupInfo - initialize the fixupInfo record. + makeCast - creates a cast node TYPENAME (expr). */ -static decl_fixupInfo initFixupInfo (void) +static decl_node__opaque makeCast (decl_node__opaque c, decl_node__opaque p) { - decl_fixupInfo f; - - f.count = 0; - f.info = Indexing_InitIndex (1); - return f; - /* static analysis guarentees a RETURN statement will be used before here. */ + mcDebug_assert (decl_isExpList (static_cast (p))); + if ((expListLen (p)) == 1) + { + return makeBinary (decl_cast, c, getExpList (p, 1), c); + } + else + { + M2RTS_HALT (-1); + __builtin_unreachable (); + } + ReturnException ("../../gcc/m2/mc/decl.def", 20, 1); __builtin_unreachable (); } - -/* - makeDef - returns a definition module node named, n. -*/ - -static decl_node makeDef (nameKey_Name n) +static decl_node__opaque makeIntrinsicProc (decl_nodeT k, unsigned int noArgs, decl_node__opaque p) { - decl_node d; + decl_node__opaque f; - d = newNode (decl_def); - d->defF.name = n; - d->defF.source = nameKey_NulName; - d->defF.hasHidden = false; - d->defF.forC = false; - d->defF.exported = Indexing_InitIndex (1); - d->defF.importedModules = Indexing_InitIndex (1); - d->defF.constFixup = initFixupInfo (); - d->defF.enumFixup = initFixupInfo (); - initDecls (&d->defF.decls); - d->defF.enumsComplete = false; - d->defF.constsComplete = false; - d->defF.visited = false; - initPair (&d->defF.com); - return d; + /* + makeIntrisicProc - create an intrinsic node. + */ + f = newNode (k); + f->intrinsicF.args = p; + f->intrinsicF.noArgs = noArgs; + f->intrinsicF.type = static_cast (NULL); + f->intrinsicF.postUnreachable = k == decl_halt; + initPair (&f->intrinsicF.intrinsicComment); + return f; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - makeImp - returns an implementation module node named, n. + makeIntrinsicUnaryType - create an intrisic unary type. */ -static decl_node makeImp (nameKey_Name n) +static decl_node__opaque makeIntrinsicUnaryType (decl_nodeT k, decl_node__opaque paramList, decl_node__opaque returnType) { - decl_node d; - - d = newNode (decl_imp); - d->impF.name = n; - d->impF.source = nameKey_NulName; - d->impF.importedModules = Indexing_InitIndex (1); - d->impF.constFixup = initFixupInfo (); - d->impF.enumFixup = initFixupInfo (); - initDecls (&d->impF.decls); - d->impF.beginStatements = NULL; - d->impF.finallyStatements = NULL; - d->impF.definitionModule = NULL; - d->impF.enumsComplete = false; - d->impF.constsComplete = false; - d->impF.visited = false; - initPair (&d->impF.com); - return d; + return makeUnary (k, getExpList (paramList, 1), returnType); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - makeModule - returns a module node named, n. + makeIntrinsicBinaryType - create an intrisic binary type. */ -static decl_node makeModule (nameKey_Name n) +static decl_node__opaque makeIntrinsicBinaryType (decl_nodeT k, decl_node__opaque paramList, decl_node__opaque returnType) { - decl_node d; - - d = newNode (decl_module); - d->moduleF.name = n; - d->moduleF.source = nameKey_NulName; - d->moduleF.importedModules = Indexing_InitIndex (1); - d->moduleF.constFixup = initFixupInfo (); - d->moduleF.enumFixup = initFixupInfo (); - initDecls (&d->moduleF.decls); - d->moduleF.beginStatements = NULL; - d->moduleF.finallyStatements = NULL; - d->moduleF.enumsComplete = false; - d->moduleF.constsComplete = false; - d->moduleF.visited = false; - initPair (&d->moduleF.com); - return d; + return makeBinary (k, getExpList (paramList, 1), getExpList (paramList, 2), returnType); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - isDefForC - returns TRUE if the definition module was defined FOR "C". + checkIntrinsic - checks to see if the function call to, c, with + parameter list, n, is really an intrinic. If it + is an intrinic then an intrinic node is created + and returned. Otherwise NIL is returned. */ -static bool isDefForC (decl_node n) +static decl_node__opaque checkIntrinsic (decl_node__opaque c, decl_node__opaque n) { - return (decl_isDef (n)) && n->defF.forC; - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); -} - - -/* - initDecls - initialize the decls, scopeT. -*/ - -static void initDecls (decl_scopeT *decls) -{ - (*decls).symbols = symbolKey_initTree (); - (*decls).constants = Indexing_InitIndex (1); - (*decls).types = Indexing_InitIndex (1); - (*decls).procedures = Indexing_InitIndex (1); - (*decls).variables = Indexing_InitIndex (1); -} - - -/* - addTo - adds node, d, to scope decls and returns, d. - It stores, d, in the symbols tree associated with decls. -*/ - -static decl_node addTo (decl_scopeT *decls, decl_node d) -{ - nameKey_Name n; - - n = decl_getSymName (d); - if (n != nameKey_NulName) + if (isAnyType (c)) { - /* avoid gcc warning by using compound statement even if not strictly necessary. */ - if ((symbolKey_getSymKey ((*decls).symbols, n)) == NULL) - { - symbolKey_putSymKey ((*decls).symbols, n, reinterpret_cast (d)); - } - else - { - mcMetaError_metaError1 ((const char *) "{%1DMad} was declared", 21, (const unsigned char *) &d, (sizeof (d)-1)); - mcMetaError_metaError1 ((const char *) "{%1k} and is being declared again", 33, (const unsigned char *) &n, (sizeof (n)-1)); - } + return makeCast (c, n); } - if (decl_isConst (d)) + else if (c == maxN) { - Indexing_IncludeIndiceIntoIndex ((*decls).constants, reinterpret_cast (d)); + /* avoid dangling else. */ + return makeIntrinsicUnaryType (decl_max, n, static_cast (NULL)); } - else if (decl_isVar (d)) + else if (c == minN) { /* avoid dangling else. */ - Indexing_IncludeIndiceIntoIndex ((*decls).variables, reinterpret_cast (d)); + return makeIntrinsicUnaryType (decl_min, n, static_cast (NULL)); } - else if (decl_isType (d)) + else if (c == haltN) { /* avoid dangling else. */ - Indexing_IncludeIndiceIntoIndex ((*decls).types, reinterpret_cast (d)); + return makeIntrinsicProc (decl_halt, expListLen (n), n); } - else if (decl_isProcedure (d)) + else if (c == valN) { /* avoid dangling else. */ - Indexing_IncludeIndiceIntoIndex ((*decls).procedures, reinterpret_cast (d)); - if (debugDecl) - { - libc_printf ((const char *) "%d procedures on the dynamic array\\n", 36, Indexing_HighIndice ((*decls).procedures)); - } + return makeVal (n); } - return d; + else if (c == adrN) + { + /* avoid dangling else. */ + return makeIntrinsicUnaryType (decl_adr, n, addressN); + } + else if (c == sizeN) + { + /* avoid dangling else. */ + return makeIntrinsicUnaryType (decl_size, n, cardinalN); + } + else if (c == tsizeN) + { + /* avoid dangling else. */ + return makeIntrinsicUnaryType (decl_tsize, n, cardinalN); + } + else if (c == floatN) + { + /* avoid dangling else. */ + return makeIntrinsicUnaryType (decl_float, n, realN); + } + else if (c == truncN) + { + /* avoid dangling else. */ + return makeIntrinsicUnaryType (decl_trunc, n, integerN); + } + else if (c == ordN) + { + /* avoid dangling else. */ + return makeIntrinsicUnaryType (decl_ord, n, cardinalN); + } + else if (c == chrN) + { + /* avoid dangling else. */ + return makeIntrinsicUnaryType (decl_chr, n, charN); + } + else if (c == capN) + { + /* avoid dangling else. */ + return makeIntrinsicUnaryType (decl_cap, n, charN); + } + else if (c == absN) + { + /* avoid dangling else. */ + return makeIntrinsicUnaryType (decl_abs, n, static_cast (NULL)); + } + else if (c == imN) + { + /* avoid dangling else. */ + return makeIntrinsicUnaryType (decl_im, n, static_cast (NULL)); + } + else if (c == reN) + { + /* avoid dangling else. */ + return makeIntrinsicUnaryType (decl_re, n, static_cast (NULL)); + } + else if (c == cmplxN) + { + /* avoid dangling else. */ + return makeIntrinsicBinaryType (decl_cmplx, n, static_cast (NULL)); + } + else if (c == highN) + { + /* avoid dangling else. */ + return makeIntrinsicUnaryType (decl_high, n, cardinalN); + } + else if (c == incN) + { + /* avoid dangling else. */ + return makeIntrinsicProc (decl_inc, expListLen (n), n); + } + else if (c == decN) + { + /* avoid dangling else. */ + return makeIntrinsicProc (decl_dec, expListLen (n), n); + } + else if (c == inclN) + { + /* avoid dangling else. */ + return makeIntrinsicProc (decl_incl, expListLen (n), n); + } + else if (c == exclN) + { + /* avoid dangling else. */ + return makeIntrinsicProc (decl_excl, expListLen (n), n); + } + else if (c == newN) + { + /* avoid dangling else. */ + return makeIntrinsicProc (decl_new, 1, n); + } + else if (c == disposeN) + { + /* avoid dangling else. */ + return makeIntrinsicProc (decl_dispose, 1, n); + } + else if (c == lengthN) + { + /* avoid dangling else. */ + return makeIntrinsicUnaryType (decl_length, n, cardinalN); + } + else if (c == throwN) + { + /* avoid dangling else. */ + keyc_useThrow (); + return makeIntrinsicProc (decl_throw, 1, n); + } + return static_cast (NULL); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - export - export node, n, from definition module, d. + checkCHeaders - check to see if the function is a C system function and + requires a header file included. */ -static void export_ (decl_node d, decl_node n) +static void checkCHeaders (decl_node__opaque c) { - mcDebug_assert (decl_isDef (d)); - Indexing_IncludeIndiceIntoIndex (d->defF.exported, reinterpret_cast (n)); + nameKey_Name name; + decl_node__opaque s; + + if (decl_isProcedure (static_cast (c))) + { + s = static_cast (decl_getScope (static_cast (c))); + if ((decl_getSymName (static_cast (s))) == (nameKey_makeKey ((const char *) "libc", 4))) + { + name = decl_getSymName (static_cast (c)); + if ((((name == (nameKey_makeKey ((const char *) "read", 4))) || (name == (nameKey_makeKey ((const char *) "write", 5)))) || (name == (nameKey_makeKey ((const char *) "open", 4)))) || (name == (nameKey_makeKey ((const char *) "close", 5)))) + { + keyc_useUnistd (); + } + } + } } /* - addToScope - adds node, n, to the current scope and returns, n. + isFuncCall - returns TRUE if, n, is a function/procedure call. */ -static decl_node addToScope (decl_node n) +static bool isFuncCall (decl_node__opaque n) { - decl_node s; - unsigned int i; - - i = Indexing_HighIndice (scopeStack); - s = static_cast (Indexing_GetIndice (scopeStack, i)); - if (decl_isProcedure (s)) - { - if (debugDecl) - { - outText (doP, (const char *) "adding ", 7); - doNameC (doP, n); - outText (doP, (const char *) " to procedure\\n", 15); - } - return addTo (&s->procedureF.decls, n); - } - else if (decl_isModule (s)) - { - /* avoid dangling else. */ - if (debugDecl) - { - outText (doP, (const char *) "adding ", 7); - doNameC (doP, n); - outText (doP, (const char *) " to module\\n", 12); - } - return addTo (&s->moduleF.decls, n); - } - else if (decl_isDef (s)) - { - /* avoid dangling else. */ - if (debugDecl) - { - outText (doP, (const char *) "adding ", 7); - doNameC (doP, n); - outText (doP, (const char *) " to definition module\\n", 23); - } - export_ (s, n); - return addTo (&s->defF.decls, n); - } - else if (decl_isImp (s)) - { - /* avoid dangling else. */ - if (debugDecl) - { - outText (doP, (const char *) "adding ", 7); - doNameC (doP, n); - outText (doP, (const char *) " to implementation module\\n", 27); - } - return addTo (&s->impF.decls, n); - } - M2RTS_HALT (-1); - __builtin_unreachable (); - ReturnException ("../../gcc/m2/mc/decl.def", 20, 1); + mcDebug_assert (n != NULL); + return n->kind == decl_funccall; + /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - addModuleToScope - adds module, i, to module, m, scope. + putTypeInternal - marks type, des, as being an internally generated type. */ -static void addModuleToScope (decl_node m, decl_node i) +static void putTypeInternal (decl_node__opaque des) { - mcDebug_assert ((decl_getDeclScope ()) == m); - if ((decl_lookupSym (decl_getSymName (i))) == NULL) - { - i = addToScope (i); - } + mcDebug_assert (des != NULL); + mcDebug_assert (decl_isType (static_cast (des))); + des->typeF.isInternal = true; } /* - completedEnum - assign boolean enumsComplete to TRUE if a definition, - implementation or module symbol. + isTypeInternal - returns TRUE if type, n, is internal. */ -static void completedEnum (decl_node n) +static bool isTypeInternal (decl_node__opaque n) { - mcDebug_assert (((decl_isDef (n)) || (decl_isImp (n))) || (decl_isModule (n))); - if (decl_isDef (n)) - { - n->defF.enumsComplete = true; - } - else if (decl_isImp (n)) - { - /* avoid dangling else. */ - n->impF.enumsComplete = true; - } - else if (decl_isModule (n)) - { - /* avoid dangling else. */ - n->moduleF.enumsComplete = true; - } + mcDebug_assert (n != NULL); + mcDebug_assert (decl_isType (static_cast (n))); + return n->typeF.isInternal; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); } /* - setUnary - sets a unary node to contain, arg, a, and type, t. + lookupBase - return node named n from the base symbol scope. */ -static void setUnary (decl_node u, decl_nodeT k, decl_node a, decl_node t) +static decl_node__opaque lookupBase (nameKey_Name n) { - switch (k) - { - case decl_constexp: - case decl_deref: - case decl_chr: - case decl_cap: - case decl_abs: - case decl_float: - case decl_trunc: - case decl_ord: - case decl_high: - case decl_throw: - case decl_re: - case decl_im: - case decl_not: - case decl_neg: - case decl_adr: - case decl_size: - case decl_tsize: - case decl_min: - case decl_max: - u->kind = k; - u->unaryF.arg = a; - u->unaryF.resultType = t; - break; + decl_node__opaque m; - - default: - CaseException ("../../gcc/m2/mc/decl.def", 20, 1); - __builtin_unreachable (); + m = static_cast (symbolKey_getSymKey (baseSymbols, n)); + if (m == procN) + { + keyc_useProc (); } -} - - -/* - putVarBool - assigns the four booleans associated with a variable. -*/ - -static void putVarBool (decl_node v, bool init, bool param, bool isvar, bool isused) -{ - mcDebug_assert (decl_isVar (v)); - v->varF.isInitialised = init; - v->varF.isParameter = param; - v->varF.isVarParameter = isvar; - v->varF.isUsed = isused; -} - - -/* - checkPtr - in C++ we need to create a typedef for a pointer - in case we need to use reinterpret_cast. -*/ - -static decl_node checkPtr (decl_node n) -{ - DynamicStrings_String s; - decl_node p; - - if (lang == decl_ansiCP) + else if (((m == complexN) || (m == longcomplexN)) || (m == shortcomplexN)) { - if (decl_isPointer (n)) - { - s = tempName (); - p = decl_makeType (nameKey_makekey (DynamicStrings_string (s))); - decl_putType (p, n); - s = DynamicStrings_KillString (s); - return p; - } + /* avoid dangling else. */ + keyc_useComplex (); } - return n; + return m; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - isVarDecl - returns TRUE if, n, is a vardecl node. + dumpScopes - display the names of all the scopes stacked. */ -static bool isVarDecl (decl_node n) +static void dumpScopes (void) { - return n->kind == decl_vardecl; - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); + unsigned int h; + decl_node__opaque s; + + h = Indexing_HighIndice (scopeStack); + libc_printf ((const char *) "total scopes stacked %d\\n", 25, h); + while (h >= 1) + { + s = static_cast (Indexing_GetIndice (scopeStack, h)); + out2 ((const char *) " scope [%d] is %s\\n", 19, h, s); + h -= 1; + } } /* - makeVariablesFromParameters - creates variables which are really parameters. + out0 - write string a to StdOut. */ -static void makeVariablesFromParameters (decl_node proc, decl_node id, decl_node type, bool isvar, bool isused) +static void out0 (const char *a_, unsigned int _a_high) { - decl_node v; - unsigned int i; - unsigned int n; - nameKey_Name m; - DynamicStrings_String s; + DynamicStrings_String m; + char a[_a_high+1]; - mcDebug_assert (decl_isProcedure (proc)); - mcDebug_assert (isIdentList (id)); - i = 1; - n = wlists_noOfItemsInList (id->identlistF.names); - while (i <= n) - { - m = static_cast (wlists_getItemFromList (id->identlistF.names, i)); - v = decl_makeVar (m); - decl_putVar (v, type, NULL); - putVarBool (v, true, true, isvar, isused); - if (debugScopes) - { - libc_printf ((const char *) "adding parameter variable into top scope\\n", 42); - dumpScopes (); - libc_printf ((const char *) " variable name is: ", 19); - s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (m)); - if ((DynamicStrings_KillString (SFIO_WriteS (FIO_StdOut, s))) == NULL) - {} /* empty. */ - libc_printf ((const char *) "\\n", 2); - } - i += 1; - } + /* make a local copy of each unbounded array. */ + memcpy (a, a_, _a_high+1); + + m = FormatStrings_Sprintf0 (DynamicStrings_InitString ((const char *) a, _a_high)); + m = DynamicStrings_KillString (SFIO_WriteS (FIO_StdOut, m)); } /* - addProcedureToScope - add a procedure name n and node d to the - current scope. + out1 - write string a to StdOut using format specifier a. */ -static decl_node addProcedureToScope (decl_node d, nameKey_Name n) +static void out1 (const char *a_, unsigned int _a_high, decl_node__opaque s) { - decl_node m; - unsigned int i; + DynamicStrings_String m; + unsigned int d; + char a[_a_high+1]; - i = Indexing_HighIndice (scopeStack); - m = static_cast (Indexing_GetIndice (scopeStack, i)); - if (((decl_isDef (m)) && ((decl_getSymName (m)) == (nameKey_makeKey ((const char *) "M2RTS", 5)))) && ((decl_getSymName (d)) == (nameKey_makeKey ((const char *) "HALT", 4)))) + /* make a local copy of each unbounded array. */ + memcpy (a, a_, _a_high+1); + + m = getFQstring (s); + if (DynamicStrings_EqualArray (m, (const char *) "", 0)) { - haltN = d; - symbolKey_putSymKey (baseSymbols, n, reinterpret_cast (haltN)); + d = (unsigned int ) ((long unsigned int ) (s)); + m = DynamicStrings_KillString (m); + m = FormatStrings_Sprintf1 (DynamicStrings_InitString ((const char *) "[%d]", 4), (const unsigned char *) &d, (sizeof (d)-1)); } - return addToScope (d); - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); + m = FormatStrings_Sprintf1 (DynamicStrings_InitString ((const char *) a, _a_high), (const unsigned char *) &m, (sizeof (m)-1)); + m = DynamicStrings_KillString (SFIO_WriteS (FIO_StdOut, m)); } /* - putProcTypeReturn - sets the return type of, proc, to, type. + out2 - write string a to StdOut using format specifier a. */ -static void putProcTypeReturn (decl_node proc, decl_node type) +static void out2 (const char *a_, unsigned int _a_high, unsigned int c, decl_node__opaque s) { - mcDebug_assert (decl_isProcType (proc)); - proc->proctypeF.returnType = type; -} - + DynamicStrings_String m; + DynamicStrings_String m1; + char a[_a_high+1]; -/* - putProcTypeOptReturn - sets, proc, to have an optional return type. -*/ + /* make a local copy of each unbounded array. */ + memcpy (a, a_, _a_high+1); -static void putProcTypeOptReturn (decl_node proc) -{ - mcDebug_assert (decl_isProcType (proc)); - proc->proctypeF.returnopt = true; + m1 = getString (s); + m = FormatStrings_Sprintf2 (DynamicStrings_InitString ((const char *) a, _a_high), (const unsigned char *) &c, (sizeof (c)-1), (const unsigned char *) &m1, (sizeof (m1)-1)); + m = DynamicStrings_KillString (SFIO_WriteS (FIO_StdOut, m)); + m1 = DynamicStrings_KillString (m1); } /* - makeOptParameter - creates and returns an optarg. + out3 - write string a to StdOut using format specifier a. */ -static decl_node makeOptParameter (decl_node l, decl_node type, decl_node init) +static void out3 (const char *a_, unsigned int _a_high, unsigned int l, nameKey_Name n, decl_node__opaque s) { - decl_node n; + DynamicStrings_String m; + DynamicStrings_String m1; + DynamicStrings_String m2; + char a[_a_high+1]; - n = newNode (decl_optarg); - n->optargF.namelist = l; - n->optargF.type = type; - n->optargF.init = init; - n->optargF.scope = NULL; - return n; - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); + /* make a local copy of each unbounded array. */ + memcpy (a, a_, _a_high+1); + + m1 = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (n)); + m2 = getString (s); + m = FormatStrings_Sprintf3 (DynamicStrings_InitString ((const char *) a, _a_high), (const unsigned char *) &l, (sizeof (l)-1), (const unsigned char *) &m1, (sizeof (m1)-1), (const unsigned char *) &m2, (sizeof (m2)-1)); + m = DynamicStrings_KillString (SFIO_WriteS (FIO_StdOut, m)); + m1 = DynamicStrings_KillString (m1); + m2 = DynamicStrings_KillString (m2); } /* - setwatch - assign the globalNode to n. + isUnary - returns TRUE if, n, is an unary node. */ -static bool setwatch (decl_node n) +static bool isUnary (decl_node__opaque n) { - globalNode = n; - return true; - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); -} - + mcDebug_assert (n != NULL); + switch (n->kind) + { + case decl_length: + case decl_re: + case decl_im: + case decl_deref: + case decl_high: + case decl_chr: + case decl_cap: + case decl_abs: + case decl_ord: + case decl_float: + case decl_trunc: + case decl_constexp: + case decl_not: + case decl_neg: + case decl_adr: + case decl_size: + case decl_tsize: + case decl_min: + case decl_max: + return true; + break; -/* - runwatch - set the globalNode to an identlist. -*/ -static bool runwatch (void) -{ - return globalNode->kind == decl_identlist; + default: + return false; + break; + } /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - isIdentList - returns TRUE if, n, is an identlist. + isBinary - returns TRUE if, n, is an binary node. */ -static bool isIdentList (decl_node n) +static bool isBinary (decl_node__opaque n) { - return n->kind == decl_identlist; + mcDebug_assert (n != NULL); + switch (n->kind) + { + case decl_cmplx: + case decl_and: + case decl_or: + case decl_equal: + case decl_notequal: + case decl_less: + case decl_greater: + case decl_greequal: + case decl_lessequal: + case decl_val: + case decl_cast: + case decl_plus: + case decl_sub: + case decl_div: + case decl_mod: + case decl_mult: + case decl_divide: + case decl_in: + return true; + break; + + + default: + return false; + break; + } /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - identListLen - returns the length of identlist. + makeUnary - create a unary expression node with, e, as the argument + and res as the return type. */ -static unsigned int identListLen (decl_node n) +static decl_node__opaque makeUnary (decl_nodeT k, decl_node__opaque e, decl_node__opaque res) { - if (n == NULL) + decl_node__opaque n; + + if (k == decl_plus) { - return 0; + return e; } else { - mcDebug_assert (isIdentList (n)); - return wlists_noOfItemsInList (n->identlistF.names); + n = newNode (k); + switch (n->kind) + { + case decl_min: + case decl_max: + case decl_throw: + case decl_re: + case decl_im: + case decl_deref: + case decl_high: + case decl_chr: + case decl_cap: + case decl_abs: + case decl_ord: + case decl_float: + case decl_trunc: + case decl_length: + case decl_constexp: + case decl_not: + case decl_neg: + case decl_adr: + case decl_size: + case decl_tsize: + n->unaryF.arg = e; + n->unaryF.resultType = res; + break; + + + default: + CaseException ("../../gcc/m2/mc/decl.def", 20, 1); + __builtin_unreachable (); + } } + return n; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - checkParameters - placeholder for future parameter checking. + isLeafString - returns TRUE if n is a leaf node which is a string constant. */ -static void checkParameters (decl_node p, decl_node i, decl_node type, bool isvar, bool isused) +static bool isLeafString (decl_node__opaque n) { - /* do check. */ - disposeNode (&i); + return ((isString (n)) || ((decl_isLiteral (static_cast (n))) && ((decl_getType (static_cast (n))) == charN))) || ((decl_isConst (static_cast (n))) && ((getExprType (n)) == charN)); + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); } /* - checkMakeVariables - create shadow local variables for parameters providing that - procedure n has not already been built and we are compiling - a module or an implementation module. + getLiteralStringContents - return the contents of a literal node as a string. */ -static void checkMakeVariables (decl_node n, decl_node i, decl_node type, bool isvar, bool isused) +static DynamicStrings_String getLiteralStringContents (decl_node__opaque n) { - if (((decl_isImp (currentModule)) || (decl_isModule (currentModule))) && ! n->procedureF.built) + DynamicStrings_String number; + DynamicStrings_String content; + DynamicStrings_String s; + + mcDebug_assert (n->kind == decl_literal); + s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (n->literalF.name)); + content = static_cast (NULL); + if (n->literalF.type == charN) { - makeVariablesFromParameters (n, i, type, isvar, isused); + if ((DynamicStrings_char (s, -1)) == 'C') + { + if ((DynamicStrings_Length (s)) > 1) + { + number = DynamicStrings_Slice (s, 0, -1); + content = DynamicStrings_InitStringChar ((char ) (StringConvert_ostoc (number))); + number = DynamicStrings_KillString (number); + } + else + { + content = DynamicStrings_InitStringChar ('C'); + } + } + else + { + content = DynamicStrings_Dup (s); + } + } + else + { + mcMetaError_metaError1 ((const char *) "cannot obtain string contents from {%1k}", 40, (const unsigned char *) &n->literalF.name, (sizeof (n->literalF.name)-1)); } + s = DynamicStrings_KillString (s); + return content; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); } /* - makeVarientField - create a varient field within varient, v, - The new varient field is returned. + getStringContents - return the string contents of a constant, literal, + string or a constexp node. +*/ + +static DynamicStrings_String getStringContents (decl_node__opaque n) +{ + if (decl_isConst (static_cast (n))) + { + return getStringContents (n->constF.value); + } + else if (decl_isLiteral (static_cast (n))) + { + /* avoid dangling else. */ + return getLiteralStringContents (n); + } + else if (isString (n)) + { + /* avoid dangling else. */ + return getString (n); + } + else if (isConstExp (n)) + { + /* avoid dangling else. */ + return getStringContents (n->unaryF.arg); + } + M2RTS_HALT (-1); + __builtin_unreachable (); + ReturnException ("../../gcc/m2/mc/decl.def", 20, 1); + __builtin_unreachable (); +} + + +/* + addNames - */ -static decl_node makeVarientField (decl_node v, decl_node p) +static nameKey_Name addNames (decl_node__opaque a, decl_node__opaque b) { - decl_node n; + DynamicStrings_String sa; + DynamicStrings_String sb; + nameKey_Name n; - n = newNode (decl_varientfield); - n->varientfieldF.name = nameKey_NulName; - n->varientfieldF.parent = p; - n->varientfieldF.varient = v; - n->varientfieldF.simple = false; - n->varientfieldF.listOfSons = Indexing_InitIndex (1); - n->varientfieldF.scope = decl_getDeclScope (); + sa = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast (a)))); + sb = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast (b)))); + sa = DynamicStrings_ConCat (sa, sb); + n = nameKey_makekey (DynamicStrings_string (sa)); + sa = DynamicStrings_KillString (sa); + sb = DynamicStrings_KillString (sb); return n; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -7557,102 +7490,52 @@ static decl_node makeVarientField (decl_node v, decl_node p) /* - putFieldVarient - places the field varient, f, as a brother to, the - varient symbol, v, and also tells, f, that its varient - parent is, v. + resolveString - */ -static void putFieldVarient (decl_node f, decl_node v) +static decl_node__opaque resolveString (decl_node__opaque n) { - mcDebug_assert (decl_isVarient (v)); - mcDebug_assert (decl_isVarientField (f)); - switch (v->kind) + while ((decl_isConst (static_cast (n))) || (isConstExp (n))) { - case decl_varient: - Indexing_IncludeIndiceIntoIndex (v->varientF.listOfSons, reinterpret_cast (f)); - break; - - - default: - CaseException ("../../gcc/m2/mc/decl.def", 20, 1); - __builtin_unreachable (); + if (decl_isConst (static_cast (n))) + { + n = n->constF.value; + } + else + { + n = n->unaryF.arg; + } } - switch (f->kind) + if (n->kind == decl_plus) { - case decl_varientfield: - f->varientfieldF.varient = v; - break; - - - default: - CaseException ("../../gcc/m2/mc/decl.def", 20, 1); - __builtin_unreachable (); + n = static_cast (decl_makeString (addNames (resolveString (n->binaryF.left), resolveString (n->binaryF.right)))); } + return n; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); } /* - putFieldRecord - create a new recordfield and place it into record r. - The new field has a tagname and type and can have a - variant field v. + foldBinary - */ -static decl_node putFieldRecord (decl_node r, nameKey_Name tag, decl_node type, decl_node v) +static decl_node__opaque foldBinary (decl_nodeT k, decl_node__opaque l, decl_node__opaque r, decl_node__opaque res) { - decl_node f; - decl_node n; - decl_node p; + decl_node__opaque n; + DynamicStrings_String ls; + DynamicStrings_String rs; - n = newNode (decl_recordfield); - switch (r->kind) + n = static_cast (NULL); + if (((k == decl_plus) && (isLeafString (l))) && (isLeafString (r))) { - case decl_record: - Indexing_IncludeIndiceIntoIndex (r->recordF.listOfSons, reinterpret_cast (n)); - /* ensure that field, n, is in the parents Local Symbols. */ - if (tag != nameKey_NulName) - { - /* avoid gcc warning by using compound statement even if not strictly necessary. */ - if ((symbolKey_getSymKey (r->recordF.localSymbols, tag)) == symbolKey_NulKey) - { - symbolKey_putSymKey (r->recordF.localSymbols, tag, reinterpret_cast (n)); - } - else - { - f = static_cast (symbolKey_getSymKey (r->recordF.localSymbols, tag)); - mcMetaError_metaErrors1 ((const char *) "field record {%1Dad} has already been declared", 46, (const char *) "field record duplicate", 22, (const unsigned char *) &f, (sizeof (f)-1)); - } - } - break; - - case decl_varientfield: - Indexing_IncludeIndiceIntoIndex (r->varientfieldF.listOfSons, reinterpret_cast (n)); - p = getParent (r); - mcDebug_assert (p->kind == decl_record); - if (tag != nameKey_NulName) - { - symbolKey_putSymKey (p->recordF.localSymbols, tag, reinterpret_cast (n)); - } - break; - - - default: - CaseException ("../../gcc/m2/mc/decl.def", 20, 1); - __builtin_unreachable (); + ls = getStringContents (l); + rs = getStringContents (r); + ls = DynamicStrings_Add (ls, rs); + n = static_cast (decl_makeString (nameKey_makekey (DynamicStrings_string (ls)))); + ls = DynamicStrings_KillString (ls); + rs = DynamicStrings_KillString (rs); } - /* fill in, n. */ - n->recordfieldF.type = type; - n->recordfieldF.name = tag; - n->recordfieldF.parent = r; - n->recordfieldF.varient = v; - n->recordfieldF.tag = false; - n->recordfieldF.scope = NULL; - initCname (&n->recordfieldF.cname); - /* - IF r^.kind=record - THEN - doRecordM2 (doP, r) - END ; - */ return n; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -7660,60 +7543,57 @@ static decl_node putFieldRecord (decl_node r, nameKey_Name tag, decl_node type, /* - ensureOrder - ensures that, a, and, b, exist in, i, and also - ensure that, a, is before, b. + makeBinary - create a binary node with left/right/result type: l, r and resultType. */ -static void ensureOrder (Indexing_Index i, decl_node a, decl_node b) +static decl_node__opaque makeBinary (decl_nodeT k, decl_node__opaque l, decl_node__opaque r, decl_node__opaque resultType) { - mcDebug_assert (Indexing_IsIndiceInIndex (i, reinterpret_cast (a))); - mcDebug_assert (Indexing_IsIndiceInIndex (i, reinterpret_cast (b))); - Indexing_RemoveIndiceFromIndex (i, reinterpret_cast (a)); - Indexing_RemoveIndiceFromIndex (i, reinterpret_cast (b)); - Indexing_IncludeIndiceIntoIndex (i, reinterpret_cast (a)); - Indexing_IncludeIndiceIntoIndex (i, reinterpret_cast (b)); - mcDebug_assert (Indexing_IsIndiceInIndex (i, reinterpret_cast (a))); - mcDebug_assert (Indexing_IsIndiceInIndex (i, reinterpret_cast (b))); + decl_node__opaque n; + + n = foldBinary (k, l, r, resultType); + if (n == NULL) + { + n = doMakeBinary (k, l, r, resultType); + } + return n; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); } /* - putVarientTag - places tag into variant v. + doMakeBinary - returns a binary node containing left/right/result values + l, r, res, with a node operator, k. */ -static void putVarientTag (decl_node v, decl_node tag) +static decl_node__opaque doMakeBinary (decl_nodeT k, decl_node__opaque l, decl_node__opaque r, decl_node__opaque res) { - decl_node p; + decl_node__opaque n; - mcDebug_assert (decl_isVarient (v)); - switch (v->kind) + n = newNode (k); + switch (n->kind) { - case decl_varient: - v->varientF.tag = tag; - break; - - - default: - CaseException ("../../gcc/m2/mc/decl.def", 20, 1); - __builtin_unreachable (); - } -} - - -/* - getParent - returns the parent field of recordfield or varientfield symbol, n. -*/ - -static decl_node getParent (decl_node n) -{ - switch (n->kind) - { - case decl_recordfield: - return n->recordfieldF.parent; - break; - - case decl_varientfield: - return n->varientfieldF.parent; + case decl_cmplx: + case decl_equal: + case decl_notequal: + case decl_less: + case decl_greater: + case decl_greequal: + case decl_lessequal: + case decl_and: + case decl_or: + case decl_cast: + case decl_val: + case decl_plus: + case decl_sub: + case decl_div: + case decl_mod: + case decl_mult: + case decl_divide: + case decl_in: + n->binaryF.left = l; + n->binaryF.right = r; + n->binaryF.resultType = res; break; @@ -7721,1673 +7601,1481 @@ static decl_node getParent (decl_node n) CaseException ("../../gcc/m2/mc/decl.def", 20, 1); __builtin_unreachable (); } + return n; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - getRecord - returns the record associated with node, n. - (Parental record). + doMakeComponentRef - */ -static decl_node getRecord (decl_node n) +static decl_node__opaque doMakeComponentRef (decl_node__opaque rec, decl_node__opaque field) { - mcDebug_assert (n->kind != decl_varient); /* if this fails then we need to add parent field to varient. */ - switch (n->kind) - { - case decl_record: - return n; /* if this fails then we need to add parent field to varient. */ - break; - - case decl_varientfield: - return getRecord (getParent (n)); - break; - + decl_node__opaque n; - default: - CaseException ("../../gcc/m2/mc/decl.def", 20, 1); - __builtin_unreachable (); - } + n = newNode (decl_componentref); + n->componentrefF.rec = rec; + n->componentrefF.field = field; + n->componentrefF.resultType = static_cast (decl_getType (static_cast (field))); + initNodeOpaqueState (n); + return n; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - isConstExp - return TRUE if the node kind is a constexp. + isComponentRef - */ -static bool isConstExp (decl_node c) +static bool isComponentRef (decl_node__opaque n) { - mcDebug_assert (c != NULL); - return c->kind == decl_constexp; + mcDebug_assert (n != NULL); + return n->kind == decl_componentref; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - addEnumToModule - adds enumeration type, e, into the list of enums - in module, m. -*/ - -static void addEnumToModule (decl_node m, decl_node e) -{ - mcDebug_assert ((decl_isEnumeration (e)) || (decl_isEnumerationField (e))); - mcDebug_assert (((decl_isModule (m)) || (decl_isDef (m))) || (decl_isImp (m))); - if (decl_isModule (m)) - { - Indexing_IncludeIndiceIntoIndex (m->moduleF.enumFixup.info, reinterpret_cast (e)); - } - else if (decl_isDef (m)) - { - /* avoid dangling else. */ - Indexing_IncludeIndiceIntoIndex (m->defF.enumFixup.info, reinterpret_cast (e)); - } - else if (decl_isImp (m)) - { - /* avoid dangling else. */ - Indexing_IncludeIndiceIntoIndex (m->impF.enumFixup.info, reinterpret_cast (e)); - } -} - - -/* - getNextFixup - return the next fixup from from f. + isArrayRef - returns TRUE if the node was an arrayref. */ -static decl_node getNextFixup (decl_fixupInfo *f) +static bool isArrayRef (decl_node__opaque n) { - (*f).count += 1; - return static_cast (Indexing_GetIndice ((*f).info, (*f).count)); + mcDebug_assert (n != NULL); + return n->kind == decl_arrayref; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - doMakeEnum - create an enumeration type and add it to the current module. + isDeref - returns TRUE if, n, is a deref node. */ -static decl_node doMakeEnum (void) +static bool isDeref (decl_node__opaque n) { - decl_node e; - - e = newNode (decl_enumeration); - e->enumerationF.noOfElements = 0; - e->enumerationF.localSymbols = symbolKey_initTree (); - e->enumerationF.scope = decl_getDeclScope (); - e->enumerationF.listOfSons = Indexing_InitIndex (1); - e->enumerationF.low = NULL; - e->enumerationF.high = NULL; - addEnumToModule (currentModule, e); - return e; + mcDebug_assert (n != NULL); + return n->kind == decl_deref; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - doMakeEnumField - create an enumeration field name and add it to enumeration e. - Return the new field. + makeBase - create a base type or constant. + It only supports the base types and constants + enumerated below. */ -static decl_node doMakeEnumField (decl_node e, nameKey_Name n) +static decl_node__opaque makeBase (decl_nodeT k) { - decl_node f; + decl_node__opaque n; - mcDebug_assert (decl_isEnumeration (e)); - f = decl_lookupSym (n); - if (f == NULL) - { - f = newNode (decl_enumerationfield); - symbolKey_putSymKey (e->enumerationF.localSymbols, n, reinterpret_cast (f)); - Indexing_IncludeIndiceIntoIndex (e->enumerationF.listOfSons, reinterpret_cast (f)); - f->enumerationfieldF.name = n; - f->enumerationfieldF.type = e; - f->enumerationfieldF.scope = decl_getDeclScope (); - f->enumerationfieldF.value = e->enumerationF.noOfElements; - initCname (&f->enumerationfieldF.cname); - e->enumerationF.noOfElements += 1; - mcDebug_assert ((Indexing_GetIndice (e->enumerationF.listOfSons, e->enumerationF.noOfElements)) == f); - addEnumToModule (currentModule, f); - if (e->enumerationF.low == NULL) - { - e->enumerationF.low = f; - } - e->enumerationF.high = f; - return addToScope (f); - } - else + n = newNode (k); + switch (k) { - mcMetaError_metaErrors2 ((const char *) "cannot create enumeration field {%1k} as the name is already in use", 67, (const char *) "{%2DMad} was declared elsewhere", 31, (const unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) &f, (sizeof (f)-1)); + case decl_new: + case decl_dispose: + case decl_length: + case decl_inc: + case decl_dec: + case decl_incl: + case decl_excl: + case decl_nil: + case decl_true: + case decl_false: + case decl_address: + case decl_loc: + case decl_byte: + case decl_word: + case decl_csizet: + case decl_cssizet: + case decl_char: + case decl_cardinal: + case decl_longcard: + case decl_shortcard: + case decl_integer: + case decl_longint: + case decl_shortint: + case decl_real: + case decl_longreal: + case decl_shortreal: + case decl_bitset: + case decl_boolean: + case decl_proc: + case decl_ztype: + case decl_rtype: + case decl_complex: + case decl_longcomplex: + case decl_shortcomplex: + case decl_adr: + case decl_chr: + case decl_cap: + case decl_abs: + case decl_float: + case decl_trunc: + case decl_ord: + case decl_high: + case decl_throw: + case decl_re: + case decl_im: + case decl_cmplx: + case decl_size: + case decl_tsize: + case decl_val: + case decl_min: + case decl_max: + break; + + + default: + M2RTS_HALT (-1); /* legal kind. */ + __builtin_unreachable (); + break; } - return f; + return n; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - getExpList - returns the, n, th argument in an explist. + isOrdinal - returns TRUE if, n, is an ordinal type. */ -static decl_node getExpList (decl_node p, unsigned int n) +static bool isOrdinal (decl_node__opaque n) { - mcDebug_assert (p != NULL); - mcDebug_assert (decl_isExpList (p)); - mcDebug_assert (n <= (Indexing_HighIndice (p->explistF.exp))); - return static_cast (Indexing_GetIndice (p->explistF.exp, n)); + switch (n->kind) + { + case decl_address: + case decl_loc: + case decl_byte: + case decl_word: + case decl_csizet: + case decl_cssizet: + case decl_char: + case decl_integer: + case decl_longint: + case decl_shortint: + case decl_cardinal: + case decl_longcard: + case decl_shortcard: + case decl_bitset: + return true; + break; + + + default: + return false; + break; + } /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - expListLen - returns the length of explist, p. + mixTypes - */ -static unsigned int expListLen (decl_node p) +static decl_node__opaque mixTypes (decl_node__opaque a, decl_node__opaque b) { - if (p == NULL) - { - return 0; - } - else + if ((a == addressN) || (b == addressN)) { - mcDebug_assert (decl_isExpList (p)); - return Indexing_HighIndice (p->explistF.exp); + return addressN; } + return a; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - getConstExpComplete - gets the field from the def or imp or module, n. + doSetExprType - */ -static bool getConstExpComplete (decl_node n) +static decl_node__opaque doSetExprType (decl_node__opaque *t, decl_node__opaque n) { - switch (n->kind) + if ((*t) == NULL) { - case decl_def: - return n->defF.constsComplete; - break; - - case decl_imp: - return n->impF.constsComplete; - break; - - case decl_module: - return n->moduleF.constsComplete; - break; - - - default: - CaseException ("../../gcc/m2/mc/decl.def", 20, 1); - __builtin_unreachable (); + (*t) = n; } + return (*t); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - addConstToModule - adds const exp, e, into the list of constant - expressions in module, m. + getMaxMinType - */ -static void addConstToModule (decl_node m, decl_node e) +static decl_node__opaque getMaxMinType (decl_node__opaque n) { - mcDebug_assert (((decl_isModule (m)) || (decl_isDef (m))) || (decl_isImp (m))); - if (decl_isModule (m)) + if ((decl_isVar (static_cast (n))) || (decl_isConst (static_cast (n)))) { - Indexing_IncludeIndiceIntoIndex (m->moduleF.constFixup.info, reinterpret_cast (e)); + return static_cast (decl_getType (static_cast (n))); } - else if (decl_isDef (m)) + else if (isConstExp (n)) { /* avoid dangling else. */ - Indexing_IncludeIndiceIntoIndex (m->defF.constFixup.info, reinterpret_cast (e)); + n = getExprType (n->unaryF.arg); + if (n == bitsetN) + { + return ztypeN; + } + else + { + return n; + } } - else if (decl_isImp (m)) + else { /* avoid dangling else. */ - Indexing_IncludeIndiceIntoIndex (m->impF.constFixup.info, reinterpret_cast (e)); + return n; } + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); } /* - doMakeConstExp - create a constexp node and add it to the current module. + doGetFuncType - */ -static decl_node doMakeConstExp (void) +static decl_node__opaque doGetFuncType (decl_node__opaque n) { - decl_node c; + decl_node__opaque result; - c = makeUnary (decl_constexp, NULL, NULL); - addConstToModule (currentModule, c); - return c; + mcDebug_assert (isFuncCall (n)); + result = doSetExprType (&n->funccallF.type, static_cast (decl_getType (static_cast (n->funccallF.function)))); + initNodeOpaqueState (n); /* Update now that the return type is known. */ + return result; /* Update now that the return type is known. */ /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - isAnyType - return TRUE if node n is any type kind. + doGetExprType - works out the type which is associated with node, n. */ -static bool isAnyType (decl_node n) +static decl_node__opaque doGetExprType (decl_node__opaque n) { - mcDebug_assert (n != NULL); switch (n->kind) { + case decl_max: + case decl_min: + return getMaxMinType (n->unaryF.arg); + break; + + case decl_cast: + case decl_val: + return doSetExprType (&n->binaryF.resultType, n->binaryF.left); + break; + + case decl_halt: + case decl_new: + case decl_dispose: + return static_cast (NULL); + break; + + case decl_inc: + case decl_dec: + case decl_incl: + case decl_excl: + return static_cast (NULL); + break; + + case decl_nil: + return addressN; + break; + + case decl_true: + case decl_false: + return booleanN; + break; + case decl_address: + return n; + break; + case decl_loc: + return n; + break; + case decl_byte: + return n; + break; + case decl_word: + return n; + break; + + case decl_csizet: + return n; + break; + + case decl_cssizet: + return n; + break; + + case decl_boolean: + /* base types. */ + return n; + break; + + case decl_proc: + return n; + break; + case decl_char: + return n; + break; + case decl_cardinal: + return n; + break; + case decl_longcard: + return n; + break; + case decl_shortcard: + return n; + break; + case decl_integer: + return n; + break; + case decl_longint: + return n; + break; + case decl_shortint: - case decl_complex: - case decl_longcomplex: - case decl_shortcomplex: + return n; + break; + + case decl_real: + return n; + break; + + case decl_longreal: + return n; + break; + + case decl_shortreal: + return n; + break; + case decl_bitset: - case decl_boolean: - case decl_proc: - case decl_type: - return true; + return n; break; + case decl_ztype: + return n; + break; - default: - return false; + case decl_rtype: + return n; break; - } - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); -} + case decl_complex: + return n; + break; -/* - makeVal - creates a VAL (type, expression) node. -*/ + case decl_longcomplex: + return n; + break; -static decl_node makeVal (decl_node params) -{ - mcDebug_assert (decl_isExpList (params)); - if ((expListLen (params)) == 2) - { - return makeBinary (decl_val, getExpList (params, 1), getExpList (params, 2), getExpList (params, 1)); - } - else - { - M2RTS_HALT (-1); - __builtin_unreachable (); - } - ReturnException ("../../gcc/m2/mc/decl.def", 20, 1); - __builtin_unreachable (); -} + case decl_shortcomplex: + return n; + break; + case decl_type: + /* language features and compound type attributes. */ + return n->typeF.type; + break; -/* - makeCast - creates a cast node TYPENAME (expr). -*/ + case decl_record: + return n; + break; -static decl_node makeCast (decl_node c, decl_node p) -{ - mcDebug_assert (decl_isExpList (p)); - if ((expListLen (p)) == 1) - { - return makeBinary (decl_cast, c, getExpList (p, 1), c); - } - else - { - M2RTS_HALT (-1); - __builtin_unreachable (); - } - ReturnException ("../../gcc/m2/mc/decl.def", 20, 1); - __builtin_unreachable (); -} + case decl_varient: + return n; + break; -static decl_node makeIntrinsicProc (decl_nodeT k, unsigned int noArgs, decl_node p) -{ - decl_node f; + case decl_var: + return n->varF.type; + break; - /* - makeIntrisicProc - create an intrinsic node. - */ - f = newNode (k); - f->intrinsicF.args = p; - f->intrinsicF.noArgs = noArgs; - f->intrinsicF.type = NULL; - f->intrinsicF.postUnreachable = k == decl_halt; - initPair (&f->intrinsicF.intrinsicComment); - return f; - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); -} + case decl_enumeration: + return n; + break; + case decl_subrange: + return n->subrangeF.type; + break; -/* - makeIntrinsicUnaryType - create an intrisic unary type. -*/ + case decl_array: + return n->arrayF.type; + break; -static decl_node makeIntrinsicUnaryType (decl_nodeT k, decl_node paramList, decl_node returnType) -{ - return makeUnary (k, getExpList (paramList, 1), returnType); - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); -} + case decl_string: + return charN; + break; + case decl_const: + return doSetExprType (&n->constF.type, getExprType (n->constF.value)); + break; -/* - makeIntrinsicBinaryType - create an intrisic binary type. -*/ + case decl_literal: + return n->literalF.type; + break; -static decl_node makeIntrinsicBinaryType (decl_nodeT k, decl_node paramList, decl_node returnType) -{ - return makeBinary (k, getExpList (paramList, 1), getExpList (paramList, 2), returnType); - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); -} + case decl_varparam: + return n->varparamF.type; + break; + case decl_param: + return n->paramF.type; + break; -/* - checkIntrinsic - checks to see if the function call to, c, with - parameter list, n, is really an intrinic. If it - is an intrinic then an intrinic node is created - and returned. Otherwise NIL is returned. -*/ + case decl_optarg: + return n->optargF.type; + break; -static decl_node checkIntrinsic (decl_node c, decl_node n) -{ - if (isAnyType (c)) - { - return makeCast (c, n); - } - else if (c == maxN) - { - /* avoid dangling else. */ - return makeIntrinsicUnaryType (decl_max, n, NULL); - } - else if (c == minN) - { - /* avoid dangling else. */ - return makeIntrinsicUnaryType (decl_min, n, NULL); - } - else if (c == haltN) - { - /* avoid dangling else. */ - return makeIntrinsicProc (decl_halt, expListLen (n), n); - } - else if (c == valN) - { - /* avoid dangling else. */ - return makeVal (n); - } - else if (c == adrN) - { - /* avoid dangling else. */ - return makeIntrinsicUnaryType (decl_adr, n, addressN); - } - else if (c == sizeN) - { - /* avoid dangling else. */ - return makeIntrinsicUnaryType (decl_size, n, cardinalN); - } - else if (c == tsizeN) - { - /* avoid dangling else. */ - return makeIntrinsicUnaryType (decl_tsize, n, cardinalN); - } - else if (c == floatN) - { - /* avoid dangling else. */ - return makeIntrinsicUnaryType (decl_float, n, realN); - } - else if (c == truncN) - { - /* avoid dangling else. */ - return makeIntrinsicUnaryType (decl_trunc, n, integerN); - } - else if (c == ordN) - { - /* avoid dangling else. */ - return makeIntrinsicUnaryType (decl_ord, n, cardinalN); - } - else if (c == chrN) - { - /* avoid dangling else. */ - return makeIntrinsicUnaryType (decl_chr, n, charN); - } - else if (c == capN) - { - /* avoid dangling else. */ - return makeIntrinsicUnaryType (decl_cap, n, charN); - } - else if (c == absN) - { - /* avoid dangling else. */ - return makeIntrinsicUnaryType (decl_abs, n, NULL); - } - else if (c == imN) - { - /* avoid dangling else. */ - return makeIntrinsicUnaryType (decl_im, n, NULL); - } - else if (c == reN) - { - /* avoid dangling else. */ - return makeIntrinsicUnaryType (decl_re, n, NULL); - } - else if (c == cmplxN) - { - /* avoid dangling else. */ - return makeIntrinsicBinaryType (decl_cmplx, n, NULL); - } - else if (c == highN) - { - /* avoid dangling else. */ - return makeIntrinsicUnaryType (decl_high, n, cardinalN); - } - else if (c == incN) - { - /* avoid dangling else. */ - return makeIntrinsicProc (decl_inc, expListLen (n), n); - } - else if (c == decN) - { - /* avoid dangling else. */ - return makeIntrinsicProc (decl_dec, expListLen (n), n); - } - else if (c == inclN) - { - /* avoid dangling else. */ - return makeIntrinsicProc (decl_incl, expListLen (n), n); - } - else if (c == exclN) - { - /* avoid dangling else. */ - return makeIntrinsicProc (decl_excl, expListLen (n), n); - } - else if (c == newN) - { - /* avoid dangling else. */ - return makeIntrinsicProc (decl_new, 1, n); - } - else if (c == disposeN) - { - /* avoid dangling else. */ - return makeIntrinsicProc (decl_dispose, 1, n); - } - else if (c == lengthN) - { - /* avoid dangling else. */ - return makeIntrinsicUnaryType (decl_length, n, cardinalN); - } - else if (c == throwN) - { - /* avoid dangling else. */ - keyc_useThrow (); - return makeIntrinsicProc (decl_throw, 1, n); - } - return NULL; - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); -} - - -/* - checkCHeaders - check to see if the function is a C system function and - requires a header file included. -*/ - -static void checkCHeaders (decl_node c) -{ - nameKey_Name name; - decl_node s; - - if (decl_isProcedure (c)) - { - s = decl_getScope (c); - if ((decl_getSymName (s)) == (nameKey_makeKey ((const char *) "libc", 4))) - { - name = decl_getSymName (c); - if ((((name == (nameKey_makeKey ((const char *) "read", 4))) || (name == (nameKey_makeKey ((const char *) "write", 5)))) || (name == (nameKey_makeKey ((const char *) "open", 4)))) || (name == (nameKey_makeKey ((const char *) "close", 5)))) - { - keyc_useUnistd (); - } - } - } -} - - -/* - isFuncCall - returns TRUE if, n, is a function/procedure call. -*/ - -static bool isFuncCall (decl_node n) -{ - mcDebug_assert (n != NULL); - return n->kind == decl_funccall; - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); -} - - -/* - putTypeInternal - marks type, des, as being an internally generated type. -*/ - -static void putTypeInternal (decl_node des) -{ - mcDebug_assert (des != NULL); - mcDebug_assert (decl_isType (des)); - des->typeF.isInternal = true; -} - - -/* - isTypeInternal - returns TRUE if type, n, is internal. -*/ - -static bool isTypeInternal (decl_node n) -{ - mcDebug_assert (n != NULL); - mcDebug_assert (decl_isType (n)); - return n->typeF.isInternal; - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); -} - - -/* - lookupBase - return node named n from the base symbol scope. -*/ - -static decl_node lookupBase (nameKey_Name n) -{ - decl_node m; - - m = static_cast (symbolKey_getSymKey (baseSymbols, n)); - if (m == procN) - { - keyc_useProc (); - } - else if (((m == complexN) || (m == longcomplexN)) || (m == shortcomplexN)) - { - /* avoid dangling else. */ - keyc_useComplex (); - } - return m; - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); -} - - -/* - dumpScopes - display the names of all the scopes stacked. -*/ - -static void dumpScopes (void) -{ - unsigned int h; - decl_node s; - - h = Indexing_HighIndice (scopeStack); - libc_printf ((const char *) "total scopes stacked %d\\n", 25, h); - while (h >= 1) - { - s = static_cast (Indexing_GetIndice (scopeStack, h)); - out2 ((const char *) " scope [%d] is %s\\n", 19, h, s); - h -= 1; - } -} - - -/* - out0 - write string a to StdOut. -*/ - -static void out0 (const char *a_, unsigned int _a_high) -{ - DynamicStrings_String m; - char a[_a_high+1]; + case decl_pointer: + return n->pointerF.type; + break; - /* make a local copy of each unbounded array. */ - memcpy (a, a_, _a_high+1); + case decl_recordfield: + return n->recordfieldF.type; + break; - m = FormatStrings_Sprintf0 (DynamicStrings_InitString ((const char *) a, _a_high)); - m = DynamicStrings_KillString (SFIO_WriteS (FIO_StdOut, m)); -} + case decl_varientfield: + return n; + break; + case decl_enumerationfield: + return n->enumerationfieldF.type; + break; -/* - out1 - write string a to StdOut using format specifier a. -*/ + case decl_set: + return n->setF.type; + break; -static void out1 (const char *a_, unsigned int _a_high, decl_node s) -{ - DynamicStrings_String m; - unsigned int d; - char a[_a_high+1]; + case decl_proctype: + return n->proctypeF.returnType; + break; - /* make a local copy of each unbounded array. */ - memcpy (a, a_, _a_high+1); + case decl_subscript: + return n->subscriptF.type; + break; - m = getFQstring (s); - if (DynamicStrings_EqualArray (m, (const char *) "", 0)) - { - d = (unsigned int ) ((long unsigned int ) (s)); - m = DynamicStrings_KillString (m); - m = FormatStrings_Sprintf1 (DynamicStrings_InitString ((const char *) "[%d]", 4), (const unsigned char *) &d, (sizeof (d)-1)); - } - m = FormatStrings_Sprintf1 (DynamicStrings_InitString ((const char *) a, _a_high), (const unsigned char *) &m, (sizeof (m)-1)); - m = DynamicStrings_KillString (SFIO_WriteS (FIO_StdOut, m)); -} + case decl_procedure: + /* blocks. */ + return n->procedureF.returnType; + break; + case decl_throw: + return static_cast (NULL); + break; -/* - out2 - write string a to StdOut using format specifier a. -*/ + case decl_unreachable: + return static_cast (NULL); + break; -static void out2 (const char *a_, unsigned int _a_high, unsigned int c, decl_node s) -{ - DynamicStrings_String m; - DynamicStrings_String m1; - char a[_a_high+1]; + case decl_def: + case decl_imp: + case decl_module: + case decl_loop: + case decl_while: + case decl_for: + case decl_repeat: + case decl_if: + case decl_elsif: + case decl_assignment: + /* statements. */ + M2RTS_HALT (-1); + __builtin_unreachable (); + break; - /* make a local copy of each unbounded array. */ - memcpy (a, a_, _a_high+1); + case decl_plus: + case decl_sub: + case decl_div: + case decl_mod: + case decl_mult: + case decl_divide: + /* expressions. */ + return doSetExprType (&n->binaryF.resultType, mixTypes (getExprType (n->binaryF.left), getExprType (n->binaryF.right))); + break; - m1 = getString (s); - m = FormatStrings_Sprintf2 (DynamicStrings_InitString ((const char *) a, _a_high), (const unsigned char *) &c, (sizeof (c)-1), (const unsigned char *) &m1, (sizeof (m1)-1)); - m = DynamicStrings_KillString (SFIO_WriteS (FIO_StdOut, m)); - m1 = DynamicStrings_KillString (m1); -} + case decl_in: + case decl_and: + case decl_or: + case decl_equal: + case decl_notequal: + case decl_less: + case decl_greater: + case decl_greequal: + case decl_lessequal: + return doSetExprType (&n->binaryF.resultType, booleanN); + break; + case decl_cmplx: + return doSetExprType (&n->binaryF.resultType, complexN); + break; -/* - out3 - write string a to StdOut using format specifier a. -*/ + case decl_abs: + case decl_constexp: + case decl_deref: + case decl_neg: + return doSetExprType (&n->unaryF.resultType, getExprType (n->unaryF.arg)); + break; -static void out3 (const char *a_, unsigned int _a_high, unsigned int l, nameKey_Name n, decl_node s) -{ - DynamicStrings_String m; - DynamicStrings_String m1; - DynamicStrings_String m2; - char a[_a_high+1]; + case decl_adr: + return doSetExprType (&n->unaryF.resultType, addressN); + break; - /* make a local copy of each unbounded array. */ - memcpy (a, a_, _a_high+1); + case decl_size: + case decl_tsize: + return doSetExprType (&n->unaryF.resultType, cardinalN); + break; - m1 = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (n)); - m2 = getString (s); - m = FormatStrings_Sprintf3 (DynamicStrings_InitString ((const char *) a, _a_high), (const unsigned char *) &l, (sizeof (l)-1), (const unsigned char *) &m1, (sizeof (m1)-1), (const unsigned char *) &m2, (sizeof (m2)-1)); - m = DynamicStrings_KillString (SFIO_WriteS (FIO_StdOut, m)); - m1 = DynamicStrings_KillString (m1); - m2 = DynamicStrings_KillString (m2); -} + case decl_high: + case decl_ord: + return doSetExprType (&n->unaryF.resultType, cardinalN); + break; + case decl_float: + return doSetExprType (&n->unaryF.resultType, realN); + break; -/* - isUnary - returns TRUE if, n, is an unary node. -*/ + case decl_trunc: + return doSetExprType (&n->unaryF.resultType, integerN); + break; -static bool isUnary (decl_node n) -{ - mcDebug_assert (n != NULL); - switch (n->kind) - { - case decl_length: - case decl_re: - case decl_im: - case decl_deref: - case decl_high: case decl_chr: + return doSetExprType (&n->unaryF.resultType, charN); + break; + case decl_cap: - case decl_abs: - case decl_ord: - case decl_float: - case decl_trunc: - case decl_constexp: + return doSetExprType (&n->unaryF.resultType, charN); + break; + case decl_not: - case decl_neg: - case decl_adr: - case decl_size: - case decl_tsize: - case decl_min: - case decl_max: - return true; + return doSetExprType (&n->unaryF.resultType, booleanN); break; + case decl_re: + return doSetExprType (&n->unaryF.resultType, realN); + break; - default: - return false; + case decl_im: + return doSetExprType (&n->unaryF.resultType, realN); break; - } - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); -} + case decl_arrayref: + return n->arrayrefF.resultType; + break; -/* - isBinary - returns TRUE if, n, is an binary node. -*/ + case decl_componentref: + return n->componentrefF.resultType; + break; -static bool isBinary (decl_node n) -{ - mcDebug_assert (n != NULL); - switch (n->kind) - { - case decl_cmplx: - case decl_and: - case decl_or: - case decl_equal: - case decl_notequal: - case decl_less: - case decl_greater: - case decl_greequal: - case decl_lessequal: - case decl_val: - case decl_cast: - case decl_plus: - case decl_sub: - case decl_div: - case decl_mod: - case decl_mult: - case decl_divide: - case decl_in: - return true; + case decl_pointerref: + return n->pointerrefF.resultType; break; + case decl_funccall: + return doSetExprType (&n->funccallF.type, doGetFuncType (n)); + break; - default: - return false; + case decl_setvalue: + return n->setvalueF.type; break; + + + default: + CaseException ("../../gcc/m2/mc/decl.def", 20, 1); + __builtin_unreachable (); } - /* static analysis guarentees a RETURN statement will be used before here. */ + M2RTS_HALT (-1); + __builtin_unreachable (); + ReturnException ("../../gcc/m2/mc/decl.def", 20, 1); __builtin_unreachable (); } /* - makeUnary - create a unary expression node with, e, as the argument - and res as the return type. + getExprType - return the expression type. */ -static decl_node makeUnary (decl_nodeT k, decl_node e, decl_node res) +static decl_node__opaque getExprType (decl_node__opaque n) { - decl_node n; + decl_node__opaque t; - if (k == decl_plus) + if (((isFuncCall (n)) && ((decl_getType (static_cast (n))) != NULL)) && (decl_isProcType (decl_skipType (decl_getType (static_cast (n)))))) { - return e; + return static_cast (decl_getType (decl_skipType (decl_getType (static_cast (n))))); } - else + t = static_cast (decl_getType (static_cast (n))); + if (t == NULL) { - n = newNode (k); - switch (n->kind) - { - case decl_min: - case decl_max: - case decl_throw: - case decl_re: - case decl_im: - case decl_deref: - case decl_high: - case decl_chr: - case decl_cap: - case decl_abs: - case decl_ord: - case decl_float: - case decl_trunc: - case decl_length: - case decl_constexp: - case decl_not: - case decl_neg: - case decl_adr: - case decl_size: - case decl_tsize: - n->unaryF.arg = e; - n->unaryF.resultType = res; - break; - - - default: - CaseException ("../../gcc/m2/mc/decl.def", 20, 1); - __builtin_unreachable (); - } + t = doGetExprType (n); } - return n; - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); -} - - -/* - isLeafString - returns TRUE if n is a leaf node which is a string constant. -*/ - -static bool isLeafString (decl_node n) -{ - return ((isString (n)) || ((decl_isLiteral (n)) && ((decl_getType (n)) == charN))) || ((decl_isConst (n)) && ((getExprType (n)) == charN)); + return t; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - getLiteralStringContents - return the contents of a literal node as a string. + openOutput - */ -static DynamicStrings_String getLiteralStringContents (decl_node n) +static void openOutput (void) { - DynamicStrings_String number; - DynamicStrings_String content; DynamicStrings_String s; - mcDebug_assert (n->kind == decl_literal); - s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (n->literalF.name)); - content = NULL; - if (n->literalF.type == charN) + s = mcOptions_getOutputFile (); + if (DynamicStrings_EqualArray (s, (const char *) "-", 1)) { - if ((DynamicStrings_char (s, -1)) == 'C') - { - if ((DynamicStrings_Length (s)) > 1) - { - number = DynamicStrings_Slice (s, 0, -1); - content = DynamicStrings_InitStringChar ((char ) (StringConvert_ostoc (number))); - number = DynamicStrings_KillString (number); - } - else - { - content = DynamicStrings_InitStringChar ('C'); - } - } - else - { - content = DynamicStrings_Dup (s); - } + outputFile = FIO_StdOut; } else { - mcMetaError_metaError1 ((const char *) "cannot obtain string contents from {%1k}", 40, (const unsigned char *) &n->literalF.name, (sizeof (n->literalF.name)-1)); + outputFile = SFIO_OpenToWrite (s); } - s = DynamicStrings_KillString (s); - return content; - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); + mcStream_setDest (outputFile); } /* - getStringContents - return the string contents of a constant, literal, - string or a constexp node. + closeOutput - */ -static DynamicStrings_String getStringContents (decl_node n) +static void closeOutput (void) { - if (decl_isConst (n)) - { - return getStringContents (n->constF.value); - } - else if (decl_isLiteral (n)) - { - /* avoid dangling else. */ - return getLiteralStringContents (n); - } - else if (isString (n)) - { - /* avoid dangling else. */ - return getString (n); - } - else if (isConstExp (n)) + DynamicStrings_String s; + + s = mcOptions_getOutputFile (); + outputFile = mcStream_combine (); + if (! (DynamicStrings_EqualArray (s, (const char *) "-", 1))) { - /* avoid dangling else. */ - return getStringContents (n->unaryF.arg); + FIO_Close (outputFile); } - M2RTS_HALT (-1); - __builtin_unreachable (); - ReturnException ("../../gcc/m2/mc/decl.def", 20, 1); - __builtin_unreachable (); } /* - addNames - + write - outputs a single char, ch. */ -static nameKey_Name addNames (decl_node a, decl_node b) +static void write_ (char ch) { - DynamicStrings_String sa; - DynamicStrings_String sb; - nameKey_Name n; - - sa = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (a))); - sb = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (b))); - sa = DynamicStrings_ConCat (sa, sb); - n = nameKey_makekey (DynamicStrings_string (sa)); - sa = DynamicStrings_KillString (sa); - sb = DynamicStrings_KillString (sb); - return n; - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); + FIO_WriteChar (outputFile, ch); + FIO_FlushBuffer (outputFile); } /* - resolveString - + writeln - */ -static decl_node resolveString (decl_node n) +static void writeln (void) { - while ((decl_isConst (n)) || (isConstExp (n))) - { - if (decl_isConst (n)) - { - n = n->constF.value; - } - else - { - n = n->unaryF.arg; - } - } - if (n->kind == decl_plus) - { - n = decl_makeString (addNames (resolveString (n->binaryF.left), resolveString (n->binaryF.right))); - } - return n; - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); + FIO_WriteLine (outputFile); + FIO_FlushBuffer (outputFile); } /* - foldBinary - + doIncludeC - include header file for definition module, n. */ -static decl_node foldBinary (decl_nodeT k, decl_node l, decl_node r, decl_node res) +static void doIncludeC (decl_node__opaque n) { - decl_node n; - DynamicStrings_String ls; - DynamicStrings_String rs; + DynamicStrings_String s; - n = NULL; - if (((k == decl_plus) && (isLeafString (l))) && (isLeafString (r))) + s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast (n)))); + if (mcOptions_getExtendedOpaque ()) + {} /* empty. */ + /* no include in this case. */ + else if (decl_isDef (static_cast (n))) { - ls = getStringContents (l); - rs = getStringContents (r); - ls = DynamicStrings_Add (ls, rs); - n = decl_makeString (nameKey_makekey (DynamicStrings_string (ls))); - ls = DynamicStrings_KillString (ls); - rs = DynamicStrings_KillString (rs); + /* avoid dangling else. */ + mcPretty_print (doP, (const char *) "# include \"", 13); + mcPretty_prints (doP, mcOptions_getHPrefix ()); + mcPretty_prints (doP, s); + mcPretty_print (doP, (const char *) ".h\"\\n", 5); + symbolKey_foreachNodeDo (n->defF.decls.symbols, (symbolKey_performOperation) {(symbolKey_performOperation_t) addDoneDef}); } - return n; - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); + s = DynamicStrings_KillString (s); } /* - makeBinary - create a binary node with left/right/result type: l, r and resultType. + getSymScope - returns the scope where node, n, was declared. */ -static decl_node makeBinary (decl_nodeT k, decl_node l, decl_node r, decl_node resultType) +static decl_node__opaque getSymScope (decl_node__opaque n) { - decl_node n; - - n = foldBinary (k, l, r, resultType); - if (n == NULL) + switch (n->kind) { - n = doMakeBinary (k, l, r, resultType); + case decl_const: + return n->constF.scope; + break; + + case decl_type: + return n->typeF.scope; + break; + + case decl_var: + return n->varF.scope; + break; + + case decl_procedure: + return n->procedureF.scope; + break; + + + default: + CaseException ("../../gcc/m2/mc/decl.def", 20, 1); + __builtin_unreachable (); } - return n; - /* static analysis guarentees a RETURN statement will be used before here. */ + M2RTS_HALT (-1); + __builtin_unreachable (); + ReturnException ("../../gcc/m2/mc/decl.def", 20, 1); __builtin_unreachable (); } /* - doMakeBinary - returns a binary node containing left/right/result values - l, r, res, with a node operator, k. + isQualifiedForced - should the node be written with a module prefix? */ -static decl_node doMakeBinary (decl_nodeT k, decl_node l, decl_node r, decl_node res) +static bool isQualifiedForced (decl_node__opaque n) { - decl_node n; - - n = newNode (k); - switch (n->kind) - { - case decl_cmplx: - case decl_equal: - case decl_notequal: - case decl_less: - case decl_greater: - case decl_greequal: - case decl_lessequal: - case decl_and: - case decl_or: - case decl_cast: - case decl_val: - case decl_plus: - case decl_sub: - case decl_div: - case decl_mod: - case decl_mult: - case decl_divide: - case decl_in: - n->binaryF.left = l; - n->binaryF.right = r; - n->binaryF.resultType = res; - break; + return forceQualified && (((((decl_isType (static_cast (n))) || (decl_isRecord (static_cast (n)))) || (decl_isArray (static_cast (n)))) || (decl_isEnumeration (static_cast (n)))) || (decl_isEnumerationField (static_cast (n)))); + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} - default: - CaseException ("../../gcc/m2/mc/decl.def", 20, 1); - __builtin_unreachable (); +/* + getFQstring - +*/ + +static DynamicStrings_String getFQstring (decl_node__opaque n) +{ + DynamicStrings_String i; + DynamicStrings_String s; + + if ((decl_getScope (static_cast (n))) == NULL) + { + return DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast (n)))); + } + else if (isQualifiedForced (n)) + { + /* avoid dangling else. */ + i = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast (n)))); + s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (decl_getScope (static_cast (n))))); + return FormatStrings_Sprintf2 (DynamicStrings_InitString ((const char *) "%s_%s", 5), (const unsigned char *) &s, (sizeof (s)-1), (const unsigned char *) &i, (sizeof (i)-1)); + } + else if ((! (decl_isExported (static_cast (n)))) || (mcOptions_getIgnoreFQ ())) + { + /* avoid dangling else. */ + return DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast (n)))); + } + else + { + /* avoid dangling else. */ + i = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast (n)))); + s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (decl_getScope (static_cast (n))))); + return FormatStrings_Sprintf2 (DynamicStrings_InitString ((const char *) "%s_%s", 5), (const unsigned char *) &s, (sizeof (s)-1), (const unsigned char *) &i, (sizeof (i)-1)); } - return n; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - doMakeComponentRef - + getFQDstring - */ -static decl_node doMakeComponentRef (decl_node rec, decl_node field) +static DynamicStrings_String getFQDstring (decl_node__opaque n, bool scopes) { - decl_node n; + DynamicStrings_String i; + DynamicStrings_String s; - n = newNode (decl_componentref); - n->componentrefF.rec = rec; - n->componentrefF.field = field; - n->componentrefF.resultType = decl_getType (field); - return n; + if ((decl_getScope (static_cast (n))) == NULL) + { + return DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (getDName (n, scopes))); + } + else if (isQualifiedForced (n)) + { + /* avoid dangling else. */ + /* we assume a qualified name will never conflict. */ + i = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast (n)))); + s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (decl_getScope (static_cast (n))))); + return FormatStrings_Sprintf2 (DynamicStrings_InitString ((const char *) "%s_%s", 5), (const unsigned char *) &s, (sizeof (s)-1), (const unsigned char *) &i, (sizeof (i)-1)); + } + else if ((! (decl_isExported (static_cast (n)))) || (mcOptions_getIgnoreFQ ())) + { + /* avoid dangling else. */ + return DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (getDName (n, scopes))); + } + else + { + /* avoid dangling else. */ + /* we assume a qualified name will never conflict. */ + i = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast (n)))); + s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (decl_getScope (static_cast (n))))); + return FormatStrings_Sprintf2 (DynamicStrings_InitString ((const char *) "%s_%s", 5), (const unsigned char *) &s, (sizeof (s)-1), (const unsigned char *) &i, (sizeof (i)-1)); + } /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - isComponentRef - + getString - returns the name as a string. */ -static bool isComponentRef (decl_node n) +static DynamicStrings_String getString (decl_node__opaque n) { - mcDebug_assert (n != NULL); - return n->kind == decl_componentref; + if ((decl_getSymName (static_cast (n))) == nameKey_NulName) + { + return DynamicStrings_InitString ((const char *) "", 0); + } + else + { + return DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast (n)))); + } /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - isArrayRef - returns TRUE if the node was an arrayref. + doNone - call HALT. */ -static bool isArrayRef (decl_node n) +static void doNone (decl_node__opaque n) { - mcDebug_assert (n != NULL); - return n->kind == decl_arrayref; - /* static analysis guarentees a RETURN statement will be used before here. */ + M2RTS_HALT (-1); __builtin_unreachable (); } /* - isDeref - returns TRUE if, n, is a deref node. + doNothing - does nothing! */ -static bool isDeref (decl_node n) +static void doNothing (decl_node__opaque n) { - mcDebug_assert (n != NULL); - return n->kind == decl_deref; - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); } /* - makeBase - create a base type or constant. - It only supports the base types and constants - enumerated below. + doConstC - */ -static decl_node makeBase (decl_nodeT k) +static void doConstC (decl_node__opaque n) { - decl_node n; + if (! (alists_isItemInList (globalGroup->doneQ, reinterpret_cast (n)))) + { + mcPretty_print (doP, (const char *) "# define ", 11); + doFQNameC (doP, n); + mcPretty_setNeedSpace (doP); + doExprC (doP, n->constF.value); + mcPretty_print (doP, (const char *) "\\n", 2); + alists_includeItemIntoList (globalGroup->doneQ, reinterpret_cast (n)); + } +} - n = newNode (k); - switch (k) + +/* + needsParen - returns TRUE if expression, n, needs to be enclosed in (). +*/ + +static bool needsParen (decl_node__opaque n) +{ + mcDebug_assert (n != NULL); + switch (n->kind) { - case decl_new: - case decl_dispose: - case decl_length: - case decl_inc: - case decl_dec: - case decl_incl: - case decl_excl: case decl_nil: case decl_true: case decl_false: - case decl_address: - case decl_loc: - case decl_byte: - case decl_word: - case decl_csizet: - case decl_cssizet: - case decl_char: - case decl_cardinal: - case decl_longcard: - case decl_shortcard: - case decl_integer: - case decl_longint: - case decl_shortint: - case decl_real: - case decl_longreal: - case decl_shortreal: - case decl_bitset: - case decl_boolean: - case decl_proc: - case decl_ztype: - case decl_rtype: - case decl_complex: - case decl_longcomplex: - case decl_shortcomplex: + return false; + break; + + case decl_constexp: + return needsParen (n->unaryF.arg); + break; + + case decl_neg: + return needsParen (n->unaryF.arg); + break; + + case decl_not: + return needsParen (n->unaryF.arg); + break; + case decl_adr: - case decl_chr: - case decl_cap: - case decl_abs: + case decl_size: + case decl_tsize: + case decl_ord: case decl_float: case decl_trunc: - case decl_ord: + case decl_chr: + case decl_cap: case decl_high: - case decl_throw: - case decl_re: - case decl_im: - case decl_cmplx: - case decl_size: - case decl_tsize: + return false; + break; + + case decl_deref: + return false; + break; + + case decl_equal: + case decl_notequal: + case decl_less: + case decl_greater: + case decl_greequal: + case decl_lessequal: + return true; + break; + + case decl_componentref: + return false; + break; + + case decl_pointerref: + return false; + break; + + case decl_cast: + return true; + break; + case decl_val: - case decl_min: + return true; + break; + + case decl_abs: + return false; + break; + + case decl_plus: + case decl_sub: + case decl_div: + case decl_mod: + case decl_mult: + case decl_divide: + case decl_in: + return true; + break; + + case decl_literal: + case decl_const: + case decl_enumerationfield: + case decl_string: + return false; + break; + case decl_max: + return true; break; + case decl_min: + return true; + break; - default: - M2RTS_HALT (-1); /* legal kind. */ - __builtin_unreachable (); + case decl_var: + return false; break; - } - return n; - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); -} + case decl_arrayref: + return false; + break; -/* - isOrdinal - returns TRUE if, n, is an ordinal type. -*/ + case decl_and: + case decl_or: + return true; + break; + + case decl_funccall: + return true; + break; + + case decl_recordfield: + return false; + break; -static bool isOrdinal (decl_node n) -{ - switch (n->kind) - { - case decl_address: case decl_loc: case decl_byte: case decl_word: - case decl_csizet: - case decl_cssizet: - case decl_char: - case decl_integer: - case decl_longint: - case decl_shortint: + case decl_type: + case decl_char: case decl_cardinal: case decl_longcard: case decl_shortcard: + case decl_integer: + case decl_longint: + case decl_shortint: + case decl_real: + case decl_longreal: + case decl_shortreal: + case decl_complex: + case decl_longcomplex: + case decl_shortcomplex: case decl_bitset: - return true; + case decl_boolean: + case decl_proc: + return false; + break; + + case decl_setvalue: + return false; break; + case decl_address: + return true; + break; - default: + case decl_procedure: return false; break; - } - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); -} + case decl_length: + case decl_cmplx: + case decl_re: + case decl_im: + return true; + break; -/* - mixTypes - -*/ -static decl_node mixTypes (decl_node a, decl_node b) -{ - if ((a == addressN) || (b == addressN)) - { - return addressN; + default: + CaseException ("../../gcc/m2/mc/decl.def", 20, 1); + __builtin_unreachable (); } - return a; + return true; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - doSetExprType - + doUnary - */ -static decl_node doSetExprType (decl_node *t, decl_node n) +static void doUnary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node__opaque expr, decl_node__opaque type, bool l, bool r) { - if ((*t) == NULL) + char op[_op_high+1]; + + /* make a local copy of each unbounded array. */ + memcpy (op, op_, _op_high+1); + + if (l) { - (*t) = n; + mcPretty_setNeedSpace (p); + } + mcPretty_print (p, (const char *) op, _op_high); + if (r) + { + mcPretty_setNeedSpace (p); + } + if (needsParen (expr)) + { + outText (p, (const char *) "(", 1); + doExprC (p, expr); + outText (p, (const char *) ")", 1); + } + else + { + doExprC (p, expr); } - return (*t); - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); } /* - getMaxMinType - + doSetSub - perform l & (~ r) */ -static decl_node getMaxMinType (decl_node n) +static void doSetSub (mcPretty_pretty p, decl_node__opaque left, decl_node__opaque right) { - if ((decl_isVar (n)) || (decl_isConst (n))) + if (needsParen (left)) { - return decl_getType (n); + outText (p, (const char *) "(", 1); + doExprC (p, left); + outText (p, (const char *) ")", 1); } - else if (isConstExp (n)) + else { - /* avoid dangling else. */ - n = getExprType (n->unaryF.arg); - if (n == bitsetN) - { - return ztypeN; - } - else - { - return n; - } + doExprC (p, left); + } + mcPretty_setNeedSpace (p); + outText (p, (const char *) "&", 1); + mcPretty_setNeedSpace (p); + if (needsParen (right)) + { + outText (p, (const char *) "(~(", 3); + doExprC (p, right); + outText (p, (const char *) "))", 2); } else { - /* avoid dangling else. */ - return n; + outText (p, (const char *) "(~", 2); + doExprC (p, right); + outText (p, (const char *) ")", 1); } - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); } /* - doGetFuncType - + doPolyBinary - */ -static decl_node doGetFuncType (decl_node n) +static void doPolyBinary (mcPretty_pretty p, decl_nodeT op, decl_node__opaque left, decl_node__opaque right, bool l, bool r) { - mcDebug_assert (isFuncCall (n)); - return doSetExprType (&n->funccallF.type, decl_getType (n->funccallF.function)); - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); -} - - -/* - doGetExprType - works out the type which is associated with node, n. -*/ + decl_node__opaque lt; + decl_node__opaque rt; -static decl_node doGetExprType (decl_node n) -{ - switch (n->kind) + lt = static_cast (decl_skipType (static_cast (getExprType (left)))); + rt = static_cast (decl_skipType (static_cast (getExprType (right)))); + if (((lt != NULL) && ((decl_isSet (static_cast (lt))) || (isBitset (lt)))) || ((rt != NULL) && ((decl_isSet (static_cast (rt))) || (isBitset (rt))))) { - case decl_max: - case decl_min: - return getMaxMinType (n->unaryF.arg); - break; - - case decl_cast: - case decl_val: - return doSetExprType (&n->binaryF.resultType, n->binaryF.left); - break; + switch (op) + { + case decl_plus: + doBinary (p, (const char *) "|", 1, left, right, l, r, false); + break; - case decl_halt: - case decl_new: - case decl_dispose: - return NULL; - break; + case decl_sub: + doSetSub (p, left, right); + break; - case decl_inc: - case decl_dec: - case decl_incl: - case decl_excl: - return NULL; - break; + case decl_mult: + doBinary (p, (const char *) "&", 1, left, right, l, r, false); + break; - case decl_nil: - return addressN; - break; + case decl_divide: + doBinary (p, (const char *) "^", 1, left, right, l, r, false); + break; - case decl_true: - case decl_false: - return booleanN; - break; - case decl_address: - return n; - break; + default: + CaseException ("../../gcc/m2/mc/decl.def", 20, 1); + __builtin_unreachable (); + } + } + else + { + switch (op) + { + case decl_plus: + doBinary (p, (const char *) "+", 1, left, right, l, r, false); + break; - case decl_loc: - return n; - break; + case decl_sub: + doBinary (p, (const char *) "-", 1, left, right, l, r, false); + break; - case decl_byte: - return n; - break; + case decl_mult: + doBinary (p, (const char *) "*", 1, left, right, l, r, false); + break; - case decl_word: - return n; - break; + case decl_divide: + doBinary (p, (const char *) "/", 1, left, right, l, r, false); + break; - case decl_csizet: - return n; - break; - case decl_cssizet: - return n; - break; + default: + CaseException ("../../gcc/m2/mc/decl.def", 20, 1); + __builtin_unreachable (); + } + } +} - case decl_boolean: - /* base types. */ - return n; - break; - case decl_proc: - return n; - break; +/* + doBinary - +*/ - case decl_char: - return n; - break; +static void doBinary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node__opaque left, decl_node__opaque right, bool l, bool r, bool unpackProc) +{ + char op[_op_high+1]; - case decl_cardinal: - return n; - break; + /* make a local copy of each unbounded array. */ + memcpy (op, op_, _op_high+1); - case decl_longcard: - return n; - break; + if (needsParen (left)) + { + outText (p, (const char *) "(", 1); + left = doExprCup (p, left, unpackProc, false); + outText (p, (const char *) ")", 1); + } + else + { + left = doExprCup (p, left, unpackProc, false); + } + if (l) + { + mcPretty_setNeedSpace (p); + } + outText (p, (const char *) op, _op_high); + if (r) + { + mcPretty_setNeedSpace (p); + } + if (needsParen (right)) + { + outText (p, (const char *) "(", 1); + right = doExprCup (p, right, unpackProc, false); + outText (p, (const char *) ")", 1); + } + else + { + right = doExprCup (p, right, unpackProc, false); + } +} - case decl_shortcard: - return n; - break; - case decl_integer: - return n; - break; +/* + doPostUnary - +*/ - case decl_longint: - return n; - break; +static void doPostUnary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node__opaque expr) +{ + char op[_op_high+1]; - case decl_shortint: - return n; - break; + /* make a local copy of each unbounded array. */ + memcpy (op, op_, _op_high+1); - case decl_real: - return n; - break; + doExprC (p, expr); + outText (p, (const char *) op, _op_high); +} - case decl_longreal: - return n; - break; - case decl_shortreal: - return n; - break; +/* + doDeRefC - +*/ - case decl_bitset: - return n; - break; +static decl_node__opaque doDeRefC (mcPretty_pretty p, decl_node__opaque expr) +{ + outText (p, (const char *) "(*", 2); + expr = castOpaque (p, expr, false); + outText (p, (const char *) ")", 1); + return expr; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} - case decl_ztype: - return n; - break; - case decl_rtype: - return n; - break; +/* + doGetLastOp - returns, a, if b is a terminal otherwise walk right. +*/ - case decl_complex: - return n; +static decl_node__opaque doGetLastOp (decl_node__opaque a, decl_node__opaque b) +{ + switch (b->kind) + { + case decl_nil: + return a; break; - case decl_longcomplex: - return n; + case decl_true: + return a; break; - case decl_shortcomplex: - return n; + case decl_false: + return a; break; - case decl_type: - /* language features and compound type attributes. */ - return n->typeF.type; + case decl_constexp: + return doGetLastOp (b, b->unaryF.arg); break; - case decl_record: - return n; + case decl_neg: + return doGetLastOp (b, b->unaryF.arg); break; - case decl_varient: - return n; + case decl_not: + return doGetLastOp (b, b->unaryF.arg); break; - case decl_var: - return n->varF.type; + case decl_adr: + return doGetLastOp (b, b->unaryF.arg); break; - case decl_enumeration: - return n; + case decl_size: + return doGetLastOp (b, b->unaryF.arg); break; - case decl_subrange: - return n->subrangeF.type; + case decl_tsize: + return doGetLastOp (b, b->unaryF.arg); break; - case decl_array: - return n->arrayF.type; + case decl_ord: + return doGetLastOp (b, b->unaryF.arg); break; - case decl_string: - return charN; + case decl_float: + case decl_trunc: + return doGetLastOp (b, b->unaryF.arg); break; - case decl_const: - return doSetExprType (&n->constF.type, getExprType (n->constF.value)); + case decl_chr: + return doGetLastOp (b, b->unaryF.arg); break; - case decl_literal: - return n->literalF.type; + case decl_cap: + return doGetLastOp (b, b->unaryF.arg); break; - case decl_varparam: - return n->varparamF.type; + case decl_high: + return doGetLastOp (b, b->unaryF.arg); break; - case decl_param: - return n->paramF.type; + case decl_deref: + return doGetLastOp (b, b->unaryF.arg); break; - case decl_optarg: - return n->optargF.type; + case decl_re: + case decl_im: + return doGetLastOp (b, b->unaryF.arg); break; - case decl_pointer: - return n->pointerF.type; + case decl_equal: + return doGetLastOp (b, b->binaryF.right); break; - case decl_recordfield: - return n->recordfieldF.type; + case decl_notequal: + return doGetLastOp (b, b->binaryF.right); break; - case decl_varientfield: - return n; + case decl_less: + return doGetLastOp (b, b->binaryF.right); break; - case decl_enumerationfield: - return n->enumerationfieldF.type; + case decl_greater: + return doGetLastOp (b, b->binaryF.right); break; - case decl_set: - return n->setF.type; + case decl_greequal: + return doGetLastOp (b, b->binaryF.right); break; - case decl_proctype: - return n->proctypeF.returnType; + case decl_lessequal: + return doGetLastOp (b, b->binaryF.right); break; - case decl_subscript: - return n->subscriptF.type; + case decl_componentref: + return doGetLastOp (b, b->componentrefF.field); break; - case decl_procedure: - /* blocks. */ - return n->procedureF.returnType; + case decl_pointerref: + return doGetLastOp (b, b->pointerrefF.field); break; - case decl_throw: - return NULL; + case decl_cast: + return doGetLastOp (b, b->binaryF.right); break; - case decl_unreachable: - return NULL; + case decl_val: + return doGetLastOp (b, b->binaryF.right); break; - case decl_def: - case decl_imp: - case decl_module: - case decl_loop: - case decl_while: - case decl_for: - case decl_repeat: - case decl_if: - case decl_elsif: - case decl_assignment: - /* statements. */ - M2RTS_HALT (-1); - __builtin_unreachable (); + case decl_plus: + return doGetLastOp (b, b->binaryF.right); break; - case decl_plus: case decl_sub: - case decl_div: - case decl_mod: - case decl_mult: - case decl_divide: - /* expressions. */ - return doSetExprType (&n->binaryF.resultType, mixTypes (getExprType (n->binaryF.left), getExprType (n->binaryF.right))); + return doGetLastOp (b, b->binaryF.right); break; - case decl_in: - case decl_and: - case decl_or: - case decl_equal: - case decl_notequal: - case decl_less: - case decl_greater: - case decl_greequal: - case decl_lessequal: - return doSetExprType (&n->binaryF.resultType, booleanN); + case decl_div: + return doGetLastOp (b, b->binaryF.right); break; - case decl_cmplx: - return doSetExprType (&n->binaryF.resultType, complexN); + case decl_mod: + return doGetLastOp (b, b->binaryF.right); break; - case decl_abs: - case decl_constexp: - case decl_deref: - case decl_neg: - return doSetExprType (&n->unaryF.resultType, getExprType (n->unaryF.arg)); + case decl_mult: + return doGetLastOp (b, b->binaryF.right); break; - case decl_adr: - return doSetExprType (&n->unaryF.resultType, addressN); + case decl_divide: + return doGetLastOp (b, b->binaryF.right); break; - case decl_size: - case decl_tsize: - return doSetExprType (&n->unaryF.resultType, cardinalN); + case decl_in: + return doGetLastOp (b, b->binaryF.right); break; - case decl_high: - case decl_ord: - return doSetExprType (&n->unaryF.resultType, cardinalN); + case decl_and: + return doGetLastOp (b, b->binaryF.right); break; - case decl_float: - return doSetExprType (&n->unaryF.resultType, realN); + case decl_or: + return doGetLastOp (b, b->binaryF.right); break; - case decl_trunc: - return doSetExprType (&n->unaryF.resultType, integerN); + case decl_cmplx: + return doGetLastOp (b, b->binaryF.right); break; - case decl_chr: - return doSetExprType (&n->unaryF.resultType, charN); + case decl_literal: + return a; break; - case decl_cap: - return doSetExprType (&n->unaryF.resultType, charN); + case decl_const: + return a; break; - case decl_not: - return doSetExprType (&n->unaryF.resultType, booleanN); + case decl_enumerationfield: + return a; break; - case decl_re: - return doSetExprType (&n->unaryF.resultType, realN); + case decl_string: + return a; break; - case decl_im: - return doSetExprType (&n->unaryF.resultType, realN); + case decl_max: + return doGetLastOp (b, b->unaryF.arg); break; - case decl_arrayref: - return n->arrayrefF.resultType; + case decl_min: + return doGetLastOp (b, b->unaryF.arg); break; - case decl_componentref: - return n->componentrefF.resultType; + case decl_var: + return a; break; - case decl_pointerref: - return n->pointerrefF.resultType; + case decl_arrayref: + return a; break; case decl_funccall: - return doSetExprType (&n->funccallF.type, doGetFuncType (n)); + return a; break; - case decl_setvalue: - return n->setvalueF.type; + case decl_procedure: + return a; + break; + + case decl_recordfield: + return a; break; @@ -9395,424 +9083,635 @@ static decl_node doGetExprType (decl_node n) CaseException ("../../gcc/m2/mc/decl.def", 20, 1); __builtin_unreachable (); } - M2RTS_HALT (-1); - __builtin_unreachable (); - ReturnException ("../../gcc/m2/mc/decl.def", 20, 1); + /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - getExprType - return the expression type. + doComponentRefC - +*/ + +static void doComponentRefC (mcPretty_pretty p, decl_node__opaque l, decl_node__opaque r) +{ + flushOpaque (p, l, false); + outText (p, (const char *) ".", 1); + doExprC (p, r); +} + + +/* + doPointerRefC - +*/ + +static void doPointerRefC (mcPretty_pretty p, decl_node__opaque l, decl_node__opaque r) +{ + flushOpaque (p, l, false); + outText (p, (const char *) "->", 2); + doExprC (p, r); +} + + +/* + doPreBinary - */ -static decl_node getExprType (decl_node n) +static void doPreBinary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node__opaque left, decl_node__opaque right, bool l, bool r) { - decl_node t; + char op[_op_high+1]; + + /* make a local copy of each unbounded array. */ + memcpy (op, op_, _op_high+1); - if (((isFuncCall (n)) && ((decl_getType (n)) != NULL)) && (decl_isProcType (decl_skipType (decl_getType (n))))) + if (l) { - return decl_getType (decl_skipType (decl_getType (n))); + mcPretty_setNeedSpace (p); } - t = decl_getType (n); - if (t == NULL) + outText (p, (const char *) op, _op_high); + if (r) { - t = doGetExprType (n); + mcPretty_setNeedSpace (p); } - return t; - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); + outText (p, (const char *) "(", 1); + doExprC (p, left); + outText (p, (const char *) ",", 1); + mcPretty_setNeedSpace (p); + doExprC (p, right); + outText (p, (const char *) ")", 1); } /* - openOutput - + doConstExpr - */ -static void openOutput (void) +static void doConstExpr (mcPretty_pretty p, decl_node__opaque n) { - DynamicStrings_String s; + doFQNameC (p, n); +} - s = mcOptions_getOutputFile (); - if (DynamicStrings_EqualArray (s, (const char *) "-", 1)) - { - outputFile = FIO_StdOut; - } - else + +/* + doEnumerationField - +*/ + +static void doEnumerationField (mcPretty_pretty p, decl_node__opaque n) +{ + doFQDNameC (p, n, false); +} + + +/* + isZero - returns TRUE if node, n, is zero. +*/ + +static bool isZero (decl_node__opaque n) +{ + if (isConstExp (n)) { - outputFile = SFIO_OpenToWrite (s); + return isZero (n->unaryF.arg); } - mcStream_setDest (outputFile); + return (decl_getSymName (static_cast (n))) == (nameKey_makeKey ((const char *) "0", 1)); + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); } /* - closeOutput - + doArrayRef - perform an array reference. If constCast + then an unbounded array access will be const_cast + (the constCast should be TRUE if an assignment to + the array is required). */ -static void closeOutput (void) +static void doArrayRef (mcPretty_pretty p, decl_node__opaque n, bool constCast) { - DynamicStrings_String s; + decl_node__opaque type; + decl_node__opaque v; + unsigned int i; + unsigned int c; - s = mcOptions_getOutputFile (); - outputFile = mcStream_combine (); - if (! (DynamicStrings_EqualArray (s, (const char *) "-", 1))) + mcDebug_assert (n != NULL); + mcDebug_assert (isArrayRef (n)); + type = static_cast (decl_skipType (decl_getType (static_cast (n->arrayrefF.array)))); + if (decl_isUnbounded (static_cast (type))) { - FIO_Close (outputFile); + v = n->arrayrefF.array; + if ((constCast && (decl_isVar (static_cast (n->arrayrefF.array)))) && (v->varF.isParameter || v->varF.isVarParameter)) + { + outText (p, (const char *) "const_cast<", 11); + doTypeNameC (p, static_cast (decl_getType (static_cast (v)))); + outText (p, (const char *) ">(", 2); + outTextN (p, decl_getSymName (static_cast (n->arrayrefF.array))); + outText (p, (const char *) ")", 1); + } + else + { + outTextN (p, decl_getSymName (static_cast (n->arrayrefF.array))); + } + } + else + { + doExprC (p, n->arrayrefF.array); + mcDebug_assert (decl_isArray (static_cast (type))); + outText (p, (const char *) ".array", 6); + } + outText (p, (const char *) "[", 1); + i = 1; + c = expListLen (n->arrayrefF.index); + while (i <= c) + { + doExprC (p, getExpList (n->arrayrefF.index, i)); + if (decl_isUnbounded (static_cast (type))) + { + mcDebug_assert (c == 1); + } + else + { + doSubtractC (p, getMin (type->arrayF.subr)); + if (i < c) + { + mcDebug_assert (decl_isArray (static_cast (type))); + outText (p, (const char *) "].array[", 8); + type = static_cast (decl_skipType (decl_getType (static_cast (type)))); + } + } + i += 1; } + outText (p, (const char *) "]", 1); } /* - write - outputs a single char, ch. + doProcedure - */ -static void write_ (char ch) +static void doProcedure (mcPretty_pretty p, decl_node__opaque n) { - FIO_WriteChar (outputFile, ch); - FIO_FlushBuffer (outputFile); + mcDebug_assert (decl_isProcedure (static_cast (n))); + doFQDNameC (p, n, true); } /* - writeln - + doRecordfield - */ -static void writeln (void) +static void doRecordfield (mcPretty_pretty p, decl_node__opaque n) { - FIO_WriteLine (outputFile); - FIO_FlushBuffer (outputFile); + doDNameC (p, n, false); } /* - doIncludeC - include header file for definition module, n. + doCastC - */ -static void doIncludeC (decl_node n) +static void doCastC (mcPretty_pretty p, decl_node__opaque t, decl_node__opaque e) { - DynamicStrings_String s; + decl_node__opaque et; - s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n))); - if (mcOptions_getExtendedOpaque ()) - {} /* empty. */ - /* no include in this case. */ - else if (decl_isDef (n)) + outText (p, (const char *) "(", 1); + doTypeNameC (p, t); + outText (p, (const char *) ")", 1); + mcPretty_setNeedSpace (p); + et = static_cast (decl_skipType (decl_getType (static_cast (e)))); + if (((et != NULL) && (isAProcType (et))) && (isAProcType (static_cast (decl_skipType (static_cast (t)))))) { - /* avoid dangling else. */ - mcPretty_print (doP, (const char *) "# include \"", 13); - mcPretty_prints (doP, mcOptions_getHPrefix ()); - mcPretty_prints (doP, s); - mcPretty_print (doP, (const char *) ".h\"\\n", 5); - symbolKey_foreachNodeDo (n->defF.decls.symbols, (symbolKey_performOperation) {(symbolKey_performOperation_t) addDoneDef}); + outText (p, (const char *) "{(", 2); + doFQNameC (p, t); + outText (p, (const char *) "_t)", 3); + mcPretty_setNeedSpace (p); + doExprC (p, e); + outText (p, (const char *) ".proc}", 6); + } + else + { + outText (p, (const char *) "(", 1); + doExprC (p, e); + outText (p, (const char *) ")", 1); } - s = DynamicStrings_KillString (s); } /* - getSymScope - returns the scope where node, n, was declared. + doSetValueC - */ -static decl_node getSymScope (decl_node n) +static void doSetValueC (mcPretty_pretty p, decl_node__opaque n) { - switch (n->kind) - { - case decl_const: - return n->constF.scope; - break; - - case decl_type: - return n->typeF.scope; - break; - - case decl_var: - return n->varF.scope; - break; - - case decl_procedure: - return n->procedureF.scope; - break; - + decl_node__opaque lo; + unsigned int i; + unsigned int h; - default: - CaseException ("../../gcc/m2/mc/decl.def", 20, 1); - __builtin_unreachable (); + mcDebug_assert (decl_isSetValue (static_cast (n))); + lo = getSetLow (n); + if (n->setvalueF.type != NULL) + { + outText (p, (const char *) "(", 1); + doTypeNameC (p, n->setvalueF.type); + mcPretty_noSpace (p); + outText (p, (const char *) ")", 1); + mcPretty_setNeedSpace (p); + } + if ((Indexing_HighIndice (n->setvalueF.values)) == 0) + { + outText (p, (const char *) "0", 1); + } + else + { + i = Indexing_LowIndice (n->setvalueF.values); + h = Indexing_HighIndice (n->setvalueF.values); + outText (p, (const char *) "(", 1); + while (i <= h) + { + outText (p, (const char *) "(1", 2); + mcPretty_setNeedSpace (p); + outText (p, (const char *) "<<", 2); + mcPretty_setNeedSpace (p); + outText (p, (const char *) "(", 1); + doExprC (p, static_cast (Indexing_GetIndice (n->setvalueF.values, i))); + doSubtractC (p, lo); + outText (p, (const char *) ")", 1); + outText (p, (const char *) ")", 1); + if (i < h) + { + mcPretty_setNeedSpace (p); + outText (p, (const char *) "|", 1); + mcPretty_setNeedSpace (p); + } + i += 1; + } + outText (p, (const char *) ")", 1); } - M2RTS_HALT (-1); - __builtin_unreachable (); - ReturnException ("../../gcc/m2/mc/decl.def", 20, 1); - __builtin_unreachable (); } /* - isQualifiedForced - should the node be written with a module prefix? + getSetLow - returns the low value of the set type from + expression, n. */ -static bool isQualifiedForced (decl_node n) +static decl_node__opaque getSetLow (decl_node__opaque n) { - return forceQualified && (((((decl_isType (n)) || (decl_isRecord (n))) || (decl_isArray (n))) || (decl_isEnumeration (n))) || (decl_isEnumerationField (n))); + decl_node__opaque type; + + if ((decl_getType (static_cast (n))) == NULL) + { + return static_cast (decl_makeLiteralInt (nameKey_makeKey ((const char *) "0", 1))); + } + else + { + type = static_cast (decl_skipType (decl_getType (static_cast (n)))); + if (decl_isSet (static_cast (type))) + { + return getMin (static_cast (decl_skipType (decl_getType (static_cast (type))))); + } + else + { + return static_cast (decl_makeLiteralInt (nameKey_makeKey ((const char *) "0", 1))); + } + } /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - getFQstring - + doInC - performs (((1 << (l)) & (r)) != 0) */ -static DynamicStrings_String getFQstring (decl_node n) +static void doInC (mcPretty_pretty p, decl_node__opaque l, decl_node__opaque r) { - DynamicStrings_String i; - DynamicStrings_String s; + decl_node__opaque lo; - if ((decl_getScope (n)) == NULL) - { - return DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n))); - } - else if (isQualifiedForced (n)) - { - /* avoid dangling else. */ - i = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n))); - s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (decl_getScope (n)))); - return FormatStrings_Sprintf2 (DynamicStrings_InitString ((const char *) "%s_%s", 5), (const unsigned char *) &s, (sizeof (s)-1), (const unsigned char *) &i, (sizeof (i)-1)); - } - else if ((! (decl_isExported (n))) || (mcOptions_getIgnoreFQ ())) - { - /* avoid dangling else. */ - return DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n))); - } - else - { - /* avoid dangling else. */ - i = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n))); - s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (decl_getScope (n)))); - return FormatStrings_Sprintf2 (DynamicStrings_InitString ((const char *) "%s_%s", 5), (const unsigned char *) &s, (sizeof (s)-1), (const unsigned char *) &i, (sizeof (i)-1)); - } - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); + lo = getSetLow (r); + outText (p, (const char *) "(((1", 4); + mcPretty_setNeedSpace (p); + outText (p, (const char *) "<<", 2); + mcPretty_setNeedSpace (p); + outText (p, (const char *) "(", 1); + doExprC (p, l); + doSubtractC (p, lo); + outText (p, (const char *) "))", 2); + mcPretty_setNeedSpace (p); + outText (p, (const char *) "&", 1); + mcPretty_setNeedSpace (p); + outText (p, (const char *) "(", 1); + doExprC (p, r); + outText (p, (const char *) "))", 2); + mcPretty_setNeedSpace (p); + outText (p, (const char *) "!=", 2); + mcPretty_setNeedSpace (p); + outText (p, (const char *) "0)", 2); } /* - getFQDstring - + doThrowC - */ -static DynamicStrings_String getFQDstring (decl_node n, bool scopes) +static void doThrowC (mcPretty_pretty p, decl_node__opaque n) { - DynamicStrings_String i; - DynamicStrings_String s; - - if ((decl_getScope (n)) == NULL) - { - return DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (getDName (n, scopes))); - } - else if (isQualifiedForced (n)) - { - /* avoid dangling else. */ - /* we assume a qualified name will never conflict. */ - i = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n))); - s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (decl_getScope (n)))); - return FormatStrings_Sprintf2 (DynamicStrings_InitString ((const char *) "%s_%s", 5), (const unsigned char *) &s, (sizeof (s)-1), (const unsigned char *) &i, (sizeof (i)-1)); - } - else if ((! (decl_isExported (n))) || (mcOptions_getIgnoreFQ ())) - { - /* avoid dangling else. */ - return DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (getDName (n, scopes))); - } - else + mcDebug_assert (isIntrinsic (n)); + outText (p, (const char *) "throw", 5); + mcPretty_setNeedSpace (p); + outText (p, (const char *) "(", 1); + if ((expListLen (n->intrinsicF.args)) == 1) { - /* avoid dangling else. */ - /* we assume a qualified name will never conflict. */ - i = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n))); - s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (decl_getScope (n)))); - return FormatStrings_Sprintf2 (DynamicStrings_InitString ((const char *) "%s_%s", 5), (const unsigned char *) &s, (sizeof (s)-1), (const unsigned char *) &i, (sizeof (i)-1)); + doExprC (p, getExpList (n->intrinsicF.args, 1)); } - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); + outText (p, (const char *) ")", 1); } /* - getString - returns the name as a string. + doUnreachableC - */ -static DynamicStrings_String getString (decl_node n) +static void doUnreachableC (mcPretty_pretty p, decl_node__opaque n) { - if ((decl_getSymName (n)) == nameKey_NulName) - { - return DynamicStrings_InitString ((const char *) "", 0); - } - else - { - return DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n))); - } - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); + mcDebug_assert (isIntrinsic (n)); + outText (p, (const char *) "__builtin_unreachable", 21); + mcPretty_setNeedSpace (p); + outText (p, (const char *) "(", 1); + mcDebug_assert ((expListLen (n->intrinsicF.args)) == 0); + outText (p, (const char *) ")", 1); } /* - doNone - call HALT. + outNull - */ -static void doNone (decl_node n) +static void outNull (mcPretty_pretty p) { - M2RTS_HALT (-1); - __builtin_unreachable (); + keyc_useNull (); + outText (p, (const char *) "NULL", 4); } /* - doNothing - does nothing! + outTrue - */ -static void doNothing (decl_node n) +static void outTrue (mcPretty_pretty p) { + keyc_useTrue (); + if ((mcOptions_useBool ()) && (lang == decl_ansiCP)) + { + outText (p, (const char *) "true", 4); + } + else + { + outText (p, (const char *) "TRUE", 4); + } } /* - doConstC - + outFalse - */ -static void doConstC (decl_node n) +static void outFalse (mcPretty_pretty p) { - if (! (alists_isItemInList (globalGroup->doneQ, reinterpret_cast (n)))) + keyc_useFalse (); + if ((mcOptions_useBool ()) && (lang == decl_ansiCP)) { - mcPretty_print (doP, (const char *) "# define ", 11); - doFQNameC (doP, n); - mcPretty_setNeedSpace (doP); - doExprC (doP, n->constF.value); - mcPretty_print (doP, (const char *) "\\n", 2); - alists_includeItemIntoList (globalGroup->doneQ, reinterpret_cast (n)); + outText (p, (const char *) "false", 5); + } + else + { + outText (p, (const char *) "FALSE", 5); } } /* - needsParen - returns TRUE if expression, n, needs to be enclosed in (). + doExprC - */ -static bool needsParen (decl_node n) +static void doExprC (mcPretty_pretty p, decl_node__opaque n) { + decl_node__opaque t; + mcDebug_assert (n != NULL); + t = getExprType (n); switch (n->kind) { case decl_nil: + outNull (p); + break; + case decl_true: + outTrue (p); + break; + case decl_false: - return false; + outFalse (p); break; case decl_constexp: - return needsParen (n->unaryF.arg); + doUnary (p, (const char *) "", 0, n->unaryF.arg, n->unaryF.resultType, false, false); break; case decl_neg: - return needsParen (n->unaryF.arg); + doUnary (p, (const char *) "-", 1, n->unaryF.arg, n->unaryF.resultType, false, false); break; case decl_not: - return needsParen (n->unaryF.arg); + doUnary (p, (const char *) "!", 1, n->unaryF.arg, n->unaryF.resultType, false, true); + break; + + case decl_val: + doValC (p, n); break; case decl_adr: + doAdrC (p, n); + break; + case decl_size: case decl_tsize: - case decl_ord: + doSizeC (p, n); + break; + case decl_float: + doConvertSC (p, n, mcOptions_getCRealType ()); + break; + case decl_trunc: + doConvertC (p, n, (const char *) "int", 3); + break; + + case decl_ord: + doConvertC (p, n, (const char *) "unsigned int", 12); + break; + case decl_chr: + doConvertC (p, n, (const char *) "char", 4); + break; + case decl_cap: + doCapC (p, n); + break; + + case decl_abs: + doAbsC (p, n); + break; + case decl_high: - return false; + doFuncHighC (p, n->unaryF.arg); + break; + + case decl_length: + doLengthC (p, n); + break; + + case decl_min: + doMinC (p, n); + break; + + case decl_max: + doMaxC (p, n); + break; + + case decl_throw: + doThrowC (p, n); + break; + + case decl_unreachable: + doUnreachableC (p, n); + break; + + case decl_re: + doReC (p, n); + break; + + case decl_im: + doImC (p, n); + break; + + case decl_cmplx: + doCmplx (p, n); break; case decl_deref: - return false; + n->unaryF.arg = doDeRefC (p, n->unaryF.arg); break; case decl_equal: + doBinary (p, (const char *) "==", 2, n->binaryF.left, n->binaryF.right, true, true, true); + break; + case decl_notequal: + doBinary (p, (const char *) "!=", 2, n->binaryF.left, n->binaryF.right, true, true, true); + break; + case decl_less: + doBinary (p, (const char *) "<", 1, n->binaryF.left, n->binaryF.right, true, true, false); + break; + case decl_greater: + doBinary (p, (const char *) ">", 1, n->binaryF.left, n->binaryF.right, true, true, false); + break; + case decl_greequal: + doBinary (p, (const char *) ">=", 2, n->binaryF.left, n->binaryF.right, true, true, false); + break; + case decl_lessequal: - return true; + doBinary (p, (const char *) "<=", 2, n->binaryF.left, n->binaryF.right, true, true, false); break; case decl_componentref: - return false; + doComponentRefC (p, n->componentrefF.rec, n->componentrefF.field); break; case decl_pointerref: - return false; + doPointerRefC (p, n->pointerrefF.ptr, n->pointerrefF.field); + break; + + case decl_cast: + doCastC (p, n->binaryF.left, n->binaryF.right); + break; + + case decl_plus: + doPolyBinary (p, decl_plus, n->binaryF.left, n->binaryF.right, false, false); + break; + + case decl_sub: + doPolyBinary (p, decl_sub, n->binaryF.left, n->binaryF.right, false, false); + break; + + case decl_div: + doBinary (p, (const char *) "/", 1, n->binaryF.left, n->binaryF.right, true, true, false); + break; + + case decl_mod: + doBinary (p, (const char *) "%", 1, n->binaryF.left, n->binaryF.right, true, true, false); + break; + + case decl_mult: + doPolyBinary (p, decl_mult, n->binaryF.left, n->binaryF.right, false, false); + break; + + case decl_divide: + doPolyBinary (p, decl_divide, n->binaryF.left, n->binaryF.right, false, false); break; - case decl_cast: - return true; + case decl_in: + doInC (p, n->binaryF.left, n->binaryF.right); break; - case decl_val: - return true; + case decl_and: + doBinary (p, (const char *) "&&", 2, n->binaryF.left, n->binaryF.right, true, true, false); break; - case decl_abs: - return false; + case decl_or: + doBinary (p, (const char *) "||", 2, n->binaryF.left, n->binaryF.right, true, true, false); break; - case decl_plus: - case decl_sub: - case decl_div: - case decl_mod: - case decl_mult: - case decl_divide: - case decl_in: - return true; + case decl_literal: + doLiteralC (p, n); break; - case decl_literal: case decl_const: - case decl_enumerationfield: - case decl_string: - return false; + doConstExpr (p, n); break; - case decl_max: - return true; + case decl_enumerationfield: + doEnumerationField (p, n); break; - case decl_min: - return true; + case decl_string: + doStringC (p, n); break; case decl_var: - return false; + doVar (p, n); break; case decl_arrayref: - return false; + doArrayRef (p, n, false); break; - case decl_and: - case decl_or: - return true; + case decl_funccall: + doFuncExprC (p, n); break; - case decl_funccall: - return true; + case decl_procedure: + doProcedure (p, n); break; case decl_recordfield: - return false; + doRecordfield (p, n); + break; + + case decl_setvalue: + doSetValueC (p, n); break; - case decl_loc: - case decl_byte: - case decl_word: - case decl_type: case decl_char: case decl_cardinal: case decl_longcard: @@ -9820,448 +9719,248 @@ static bool needsParen (decl_node n) case decl_integer: case decl_longint: case decl_shortint: - case decl_real: - case decl_longreal: - case decl_shortreal: case decl_complex: case decl_longcomplex: case decl_shortcomplex: + case decl_real: + case decl_longreal: + case decl_shortreal: case decl_bitset: case decl_boolean: case decl_proc: - return false; - break; - - case decl_setvalue: - return false; + doBaseC (p, n); break; case decl_address: - return true; - break; - - case decl_procedure: - return false; - break; - - case decl_length: - case decl_cmplx: - case decl_re: - case decl_im: - return true; - break; - - - default: - CaseException ("../../gcc/m2/mc/decl.def", 20, 1); - __builtin_unreachable (); - } - return true; - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); -} - - -/* - doUnary - -*/ - -static void doUnary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node expr, decl_node type, bool l, bool r) -{ - char op[_op_high+1]; - - /* make a local copy of each unbounded array. */ - memcpy (op, op_, _op_high+1); - - if (l) - { - mcPretty_setNeedSpace (p); - } - mcPretty_print (p, (const char *) op, _op_high); - if (r) - { - mcPretty_setNeedSpace (p); - } - if (needsParen (expr)) - { - outText (p, (const char *) "(", 1); - doExprC (p, expr); - outText (p, (const char *) ")", 1); - } - else - { - doExprC (p, expr); - } -} - - -/* - doSetSub - perform l & (~ r) -*/ - -static void doSetSub (mcPretty_pretty p, decl_node left, decl_node right) -{ - if (needsParen (left)) - { - outText (p, (const char *) "(", 1); - doExprC (p, left); - outText (p, (const char *) ")", 1); - } - else - { - doExprC (p, left); - } - mcPretty_setNeedSpace (p); - outText (p, (const char *) "&", 1); - mcPretty_setNeedSpace (p); - if (needsParen (right)) - { - outText (p, (const char *) "(~(", 3); - doExprC (p, right); - outText (p, (const char *) "))", 2); - } - else - { - outText (p, (const char *) "(~", 2); - doExprC (p, right); - outText (p, (const char *) ")", 1); - } -} - - -/* - doPolyBinary - -*/ - -static void doPolyBinary (mcPretty_pretty p, decl_nodeT op, decl_node left, decl_node right, bool l, bool r) -{ - decl_node lt; - decl_node rt; - - lt = decl_skipType (getExprType (left)); - rt = decl_skipType (getExprType (right)); - if (((lt != NULL) && ((decl_isSet (lt)) || (isBitset (lt)))) || ((rt != NULL) && ((decl_isSet (rt)) || (isBitset (rt))))) - { - switch (op) - { - case decl_plus: - doBinary (p, (const char *) "|", 1, left, right, l, r, false); - break; - - case decl_sub: - doSetSub (p, left, right); - break; - - case decl_mult: - doBinary (p, (const char *) "&", 1, left, right, l, r, false); - break; - - case decl_divide: - doBinary (p, (const char *) "^", 1, left, right, l, r, false); - break; - - - default: - CaseException ("../../gcc/m2/mc/decl.def", 20, 1); - __builtin_unreachable (); - } - } - else - { - switch (op) - { - case decl_plus: - doBinary (p, (const char *) "+", 1, left, right, l, r, false); - break; - - case decl_sub: - doBinary (p, (const char *) "-", 1, left, right, l, r, false); - break; - - case decl_mult: - doBinary (p, (const char *) "*", 1, left, right, l, r, false); - break; - - case decl_divide: - doBinary (p, (const char *) "/", 1, left, right, l, r, false); - break; - - - default: - CaseException ("../../gcc/m2/mc/decl.def", 20, 1); - __builtin_unreachable (); - } - } -} - - -/* - doBinary - -*/ - -static void doBinary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node left, decl_node right, bool l, bool r, bool unpackProc) -{ - char op[_op_high+1]; - - /* make a local copy of each unbounded array. */ - memcpy (op, op_, _op_high+1); - - if (needsParen (left)) - { - outText (p, (const char *) "(", 1); - doExprCup (p, left, unpackProc); - outText (p, (const char *) ")", 1); - } - else - { - doExprCup (p, left, unpackProc); - } - if (l) - { - mcPretty_setNeedSpace (p); - } - outText (p, (const char *) op, _op_high); - if (r) - { - mcPretty_setNeedSpace (p); - } - if (needsParen (right)) - { - outText (p, (const char *) "(", 1); - doExprCup (p, right, unpackProc); - outText (p, (const char *) ")", 1); - } - else - { - doExprCup (p, right, unpackProc); - } -} - + case decl_loc: + case decl_byte: + case decl_word: + case decl_csizet: + case decl_cssizet: + doSystemC (p, n); + break; -/* - doPostUnary - -*/ + case decl_type: + doTypeNameC (p, n); + break; -static void doPostUnary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node expr) -{ - char op[_op_high+1]; + case decl_pointer: + doTypeNameC (p, n); + break; - /* make a local copy of each unbounded array. */ - memcpy (op, op_, _op_high+1); - doExprC (p, expr); - outText (p, (const char *) op, _op_high); + default: + CaseException ("../../gcc/m2/mc/decl.def", 20, 1); + __builtin_unreachable (); + } } /* - doDeRefC - + doExprCup - */ -static void doDeRefC (mcPretty_pretty p, decl_node expr) +static decl_node__opaque doExprCup (mcPretty_pretty p, decl_node__opaque n, bool unpackProc, bool uncastConst) { - outText (p, (const char *) "(*", 2); - doExprC (p, expr); - outText (p, (const char *) ")", 1); + decl_node__opaque type; + + if (uncastConst && (isArrayRef (n))) + { + doArrayRef (p, n, true); + } + else + { + doExprC (p, n); + if (unpackProc) + { + type = static_cast (decl_skipType (static_cast (getExprType (n)))); + if ((type != NULL) && (isAProcType (type))) + { + outText (p, (const char *) ".proc", 5); + } + } + } + return n; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); } /* - doGetLastOp - returns, a, if b is a terminal otherwise walk right. + doExprM2 - */ -static decl_node doGetLastOp (decl_node a, decl_node b) +static void doExprM2 (mcPretty_pretty p, decl_node__opaque n) { - switch (b->kind) + mcDebug_assert (n != NULL); + switch (n->kind) { case decl_nil: - return a; + outText (p, (const char *) "NIL", 3); break; case decl_true: - return a; + outText (p, (const char *) "TRUE", 4); break; case decl_false: - return a; + outText (p, (const char *) "FALSE", 5); break; case decl_constexp: - return doGetLastOp (b, b->unaryF.arg); + doUnary (p, (const char *) "", 0, n->unaryF.arg, n->unaryF.resultType, false, false); break; case decl_neg: - return doGetLastOp (b, b->unaryF.arg); + doUnary (p, (const char *) "-", 1, n->unaryF.arg, n->unaryF.resultType, false, false); break; case decl_not: - return doGetLastOp (b, b->unaryF.arg); + doUnary (p, (const char *) "NOT", 3, n->unaryF.arg, n->unaryF.resultType, true, true); break; case decl_adr: - return doGetLastOp (b, b->unaryF.arg); + doUnary (p, (const char *) "ADR", 3, n->unaryF.arg, n->unaryF.resultType, true, true); break; case decl_size: - return doGetLastOp (b, b->unaryF.arg); + doUnary (p, (const char *) "SIZE", 4, n->unaryF.arg, n->unaryF.resultType, true, true); break; case decl_tsize: - return doGetLastOp (b, b->unaryF.arg); + doUnary (p, (const char *) "TSIZE", 5, n->unaryF.arg, n->unaryF.resultType, true, true); break; - case decl_ord: - return doGetLastOp (b, b->unaryF.arg); + case decl_float: + doUnary (p, (const char *) "FLOAT", 5, n->unaryF.arg, n->unaryF.resultType, true, true); break; - case decl_float: case decl_trunc: - return doGetLastOp (b, b->unaryF.arg); + doUnary (p, (const char *) "TRUNC", 5, n->unaryF.arg, n->unaryF.resultType, true, true); + break; + + case decl_ord: + doUnary (p, (const char *) "ORD", 3, n->unaryF.arg, n->unaryF.resultType, true, true); break; case decl_chr: - return doGetLastOp (b, b->unaryF.arg); + doUnary (p, (const char *) "CHR", 3, n->unaryF.arg, n->unaryF.resultType, true, true); break; case decl_cap: - return doGetLastOp (b, b->unaryF.arg); + doUnary (p, (const char *) "CAP", 3, n->unaryF.arg, n->unaryF.resultType, true, true); break; case decl_high: - return doGetLastOp (b, b->unaryF.arg); + doUnary (p, (const char *) "HIGH", 4, n->unaryF.arg, n->unaryF.resultType, true, true); break; - case decl_deref: - return doGetLastOp (b, b->unaryF.arg); + case decl_re: + doUnary (p, (const char *) "RE", 2, n->unaryF.arg, n->unaryF.resultType, true, true); break; - case decl_re: case decl_im: - return doGetLastOp (b, b->unaryF.arg); + doUnary (p, (const char *) "IM", 2, n->unaryF.arg, n->unaryF.resultType, true, true); + break; + + case decl_deref: + doPostUnary (p, (const char *) "^", 1, n->unaryF.arg); break; case decl_equal: - return doGetLastOp (b, b->binaryF.right); + doBinary (p, (const char *) "=", 1, n->binaryF.left, n->binaryF.right, true, true, false); break; case decl_notequal: - return doGetLastOp (b, b->binaryF.right); + doBinary (p, (const char *) "#", 1, n->binaryF.left, n->binaryF.right, true, true, false); break; case decl_less: - return doGetLastOp (b, b->binaryF.right); + doBinary (p, (const char *) "<", 1, n->binaryF.left, n->binaryF.right, true, true, false); break; case decl_greater: - return doGetLastOp (b, b->binaryF.right); + doBinary (p, (const char *) ">", 1, n->binaryF.left, n->binaryF.right, true, true, false); break; case decl_greequal: - return doGetLastOp (b, b->binaryF.right); + doBinary (p, (const char *) ">=", 2, n->binaryF.left, n->binaryF.right, true, true, false); break; case decl_lessequal: - return doGetLastOp (b, b->binaryF.right); + doBinary (p, (const char *) "<=", 2, n->binaryF.left, n->binaryF.right, true, true, false); break; case decl_componentref: - return doGetLastOp (b, b->componentrefF.field); + doBinary (p, (const char *) ".", 1, n->componentrefF.rec, n->componentrefF.field, false, false, false); break; case decl_pointerref: - return doGetLastOp (b, b->pointerrefF.field); + doBinary (p, (const char *) "^.", 2, n->pointerrefF.ptr, n->pointerrefF.field, false, false, false); break; case decl_cast: - return doGetLastOp (b, b->binaryF.right); + doPreBinary (p, (const char *) "CAST", 4, n->binaryF.left, n->binaryF.right, true, true); break; case decl_val: - return doGetLastOp (b, b->binaryF.right); + doPreBinary (p, (const char *) "VAL", 3, n->binaryF.left, n->binaryF.right, true, true); + break; + + case decl_cmplx: + doPreBinary (p, (const char *) "CMPLX", 5, n->binaryF.left, n->binaryF.right, true, true); break; case decl_plus: - return doGetLastOp (b, b->binaryF.right); + doBinary (p, (const char *) "+", 1, n->binaryF.left, n->binaryF.right, false, false, false); break; case decl_sub: - return doGetLastOp (b, b->binaryF.right); + doBinary (p, (const char *) "-", 1, n->binaryF.left, n->binaryF.right, false, false, false); break; case decl_div: - return doGetLastOp (b, b->binaryF.right); + doBinary (p, (const char *) "DIV", 3, n->binaryF.left, n->binaryF.right, true, true, false); break; case decl_mod: - return doGetLastOp (b, b->binaryF.right); + doBinary (p, (const char *) "MOD", 3, n->binaryF.left, n->binaryF.right, true, true, false); break; case decl_mult: - return doGetLastOp (b, b->binaryF.right); + doBinary (p, (const char *) "*", 1, n->binaryF.left, n->binaryF.right, false, false, false); break; case decl_divide: - return doGetLastOp (b, b->binaryF.right); - break; - - case decl_in: - return doGetLastOp (b, b->binaryF.right); - break; - - case decl_and: - return doGetLastOp (b, b->binaryF.right); - break; - - case decl_or: - return doGetLastOp (b, b->binaryF.right); - break; - - case decl_cmplx: - return doGetLastOp (b, b->binaryF.right); + doBinary (p, (const char *) "/", 1, n->binaryF.left, n->binaryF.right, false, false, false); break; case decl_literal: - return a; + doLiteral (p, n); break; case decl_const: - return a; + doConstExpr (p, n); break; case decl_enumerationfield: - return a; + doEnumerationField (p, n); break; case decl_string: - return a; + doString (p, n); break; case decl_max: - return doGetLastOp (b, b->unaryF.arg); + doUnary (p, (const char *) "MAX", 3, n->unaryF.arg, n->unaryF.resultType, true, true); break; case decl_min: - return doGetLastOp (b, b->unaryF.arg); + doUnary (p, (const char *) "MIN", 3, n->unaryF.arg, n->unaryF.resultType, true, true); break; case decl_var: - return a; - break; - - case decl_arrayref: - return a; - break; - - case decl_funccall: - return a; - break; - - case decl_procedure: - return a; - break; - - case decl_recordfield: - return a; + doVar (p, n); break; @@ -10269,1478 +9968,1460 @@ static decl_node doGetLastOp (decl_node a, decl_node b) CaseException ("../../gcc/m2/mc/decl.def", 20, 1); __builtin_unreachable (); } - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); -} - - -/* - doComponentRefC - -*/ - -static void doComponentRefC (mcPretty_pretty p, decl_node l, decl_node r) -{ - doExprC (p, l); - outText (p, (const char *) ".", 1); - doExprC (p, r); -} - - -/* - doPointerRefC - -*/ - -static void doPointerRefC (mcPretty_pretty p, decl_node l, decl_node r) -{ - doExprC (p, l); - outText (p, (const char *) "->", 2); - doExprC (p, r); } /* - doPreBinary - + doVar - */ -static void doPreBinary (mcPretty_pretty p, const char *op_, unsigned int _op_high, decl_node left, decl_node right, bool l, bool r) +static void doVar (mcPretty_pretty p, decl_node__opaque n) { - char op[_op_high+1]; - - /* make a local copy of each unbounded array. */ - memcpy (op, op_, _op_high+1); - - if (l) - { - mcPretty_setNeedSpace (p); - } - outText (p, (const char *) op, _op_high); - if (r) + mcDebug_assert (decl_isVar (static_cast (n))); + if (n->varF.isVarParameter) { - mcPretty_setNeedSpace (p); + outText (p, (const char *) "(*", 2); + doFQDNameC (p, n, true); + outText (p, (const char *) ")", 1); } - outText (p, (const char *) "(", 1); - doExprC (p, left); - outText (p, (const char *) ",", 1); - mcPretty_setNeedSpace (p); - doExprC (p, right); - outText (p, (const char *) ")", 1); -} - - -/* - doConstExpr - -*/ - -static void doConstExpr (mcPretty_pretty p, decl_node n) -{ - doFQNameC (p, n); -} - - -/* - doEnumerationField - -*/ - -static void doEnumerationField (mcPretty_pretty p, decl_node n) -{ - doFQDNameC (p, n, false); -} - - -/* - isZero - returns TRUE if node, n, is zero. -*/ - -static bool isZero (decl_node n) -{ - if (isConstExp (n)) + else { - return isZero (n->unaryF.arg); + doFQDNameC (p, n, true); } - return (decl_getSymName (n)) == (nameKey_makeKey ((const char *) "0", 1)); - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); } /* - doArrayRef - + doLiteralC - */ -static void doArrayRef (mcPretty_pretty p, decl_node n) +static void doLiteralC (mcPretty_pretty p, decl_node__opaque n) { - decl_node t; - unsigned int i; - unsigned int c; + DynamicStrings_String s; - mcDebug_assert (n != NULL); - mcDebug_assert (isArrayRef (n)); - t = decl_skipType (decl_getType (n->arrayrefF.array)); - if (decl_isUnbounded (t)) + mcDebug_assert (decl_isLiteral (static_cast (n))); + s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast (n)))); + if (n->literalF.type == charN) { - outTextN (p, decl_getSymName (n->arrayrefF.array)); + if ((DynamicStrings_char (s, -1)) == 'C') + { + s = DynamicStrings_Slice (DynamicStrings_Mark (s), 0, -1); + if ((DynamicStrings_char (s, 0)) != '0') + { + s = DynamicStrings_ConCat (DynamicStrings_InitString ((const char *) "0", 1), DynamicStrings_Mark (s)); + } + } + outText (p, (const char *) "(char)", 6); + mcPretty_setNeedSpace (p); } - else + else if ((DynamicStrings_char (s, -1)) == 'H') { - doExprC (p, n->arrayrefF.array); - mcDebug_assert (decl_isArray (t)); - outText (p, (const char *) ".array", 6); + /* avoid dangling else. */ + outText (p, (const char *) "0x", 2); + s = DynamicStrings_Slice (DynamicStrings_Mark (s), 0, -1); } - outText (p, (const char *) "[", 1); - i = 1; - c = expListLen (n->arrayrefF.index); - while (i <= c) + else if ((DynamicStrings_char (s, -1)) == 'B') { - doExprC (p, getExpList (n->arrayrefF.index, i)); - if (decl_isUnbounded (t)) - { - mcDebug_assert (c == 1); - } - else + /* avoid dangling else. */ + outText (p, (const char *) "0", 1); + s = DynamicStrings_Slice (DynamicStrings_Mark (s), 0, -1); + } + outTextS (p, s); + s = DynamicStrings_KillString (s); +} + + +/* + doLiteral - +*/ + +static void doLiteral (mcPretty_pretty p, decl_node__opaque n) +{ + DynamicStrings_String s; + + mcDebug_assert (decl_isLiteral (static_cast (n))); + s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast (n)))); + if (n->literalF.type == charN) + { + if ((DynamicStrings_char (s, -1)) == 'C') { - doSubtractC (p, getMin (t->arrayF.subr)); - if (i < c) + s = DynamicStrings_Slice (DynamicStrings_Mark (s), 0, -1); + if ((DynamicStrings_char (s, 0)) != '0') { - mcDebug_assert (decl_isArray (t)); - outText (p, (const char *) "].array[", 8); - t = decl_skipType (decl_getType (t)); + s = DynamicStrings_ConCat (DynamicStrings_InitString ((const char *) "0", 1), DynamicStrings_Mark (s)); } } - i += 1; + outText (p, (const char *) "(char)", 6); + mcPretty_setNeedSpace (p); } - outText (p, (const char *) "]", 1); + outTextS (p, s); + s = DynamicStrings_KillString (s); } /* - doProcedure - + isString - returns TRUE if node, n, is a string. */ -static void doProcedure (mcPretty_pretty p, decl_node n) +static bool isString (decl_node__opaque n) { - mcDebug_assert (decl_isProcedure (n)); - doFQDNameC (p, n, true); + mcDebug_assert (n != NULL); + return n->kind == decl_string; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); } /* - doRecordfield - + doString - */ -static void doRecordfield (mcPretty_pretty p, decl_node n) +static void doString (mcPretty_pretty p, decl_node__opaque n) { - doDNameC (p, n, false); + DynamicStrings_String s; + + mcDebug_assert (isString (n)); + s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast (n)))); + outTextS (p, s); + s = DynamicStrings_KillString (s); + /* + IF DynamicStrings.Index (s, '"', 0)=-1 + THEN + outText (p, '"') ; + outTextS (p, s) ; + outText (p, '"') + ELSIF DynamicStrings.Index (s, "'", 0)=-1 + THEN + outText (p, '"') ; + outTextS (p, s) ; + outText (p, '"') + ELSE + metaError1 ('illegal string {%1k}', n) + END + */ + M2RTS_HALT (-1); + __builtin_unreachable (); } /* - doCastC - + replaceChar - replace every occurance of, ch, by, a and return modified string, s. */ -static void doCastC (mcPretty_pretty p, decl_node t, decl_node e) +static DynamicStrings_String replaceChar (DynamicStrings_String s, char ch, const char *a_, unsigned int _a_high) { - decl_node et; + int i; + char a[_a_high+1]; - outText (p, (const char *) "(", 1); - doTypeNameC (p, t); - outText (p, (const char *) ")", 1); - mcPretty_setNeedSpace (p); - et = decl_skipType (decl_getType (e)); - if (((et != NULL) && (isAProcType (et))) && (isAProcType (decl_skipType (t)))) - { - outText (p, (const char *) "{(", 2); - doFQNameC (p, t); - outText (p, (const char *) "_t)", 3); - mcPretty_setNeedSpace (p); - doExprC (p, e); - outText (p, (const char *) ".proc}", 6); - } - else - { - outText (p, (const char *) "(", 1); - doExprC (p, e); - outText (p, (const char *) ")", 1); - } + /* make a local copy of each unbounded array. */ + memcpy (a, a_, _a_high+1); + + i = 0; + for (;;) + { + i = DynamicStrings_Index (s, ch, static_cast (i)); + if (i == 0) + { + s = DynamicStrings_ConCat (DynamicStrings_InitString ((const char *) a, _a_high), DynamicStrings_Slice (s, 1, 0)); + i = StrLib_StrLen ((const char *) a, _a_high); + } + else if (i > 0) + { + /* avoid dangling else. */ + s = DynamicStrings_ConCat (DynamicStrings_ConCat (DynamicStrings_Slice (s, 0, i), DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high))), DynamicStrings_Slice (s, i+1, 0)); + i += StrLib_StrLen ((const char *) a, _a_high); + } + else + { + /* avoid dangling else. */ + return s; + } + } + ReturnException ("../../gcc/m2/mc/decl.def", 20, 1); + __builtin_unreachable (); } /* - doSetValueC - + toCstring - translates string, n, into a C string + and returns the new String. */ -static void doSetValueC (mcPretty_pretty p, decl_node n) +static DynamicStrings_String toCstring (nameKey_Name n) { - decl_node lo; - unsigned int i; - unsigned int h; + DynamicStrings_String s; - mcDebug_assert (decl_isSetValue (n)); - lo = getSetLow (n); - if (n->setvalueF.type != NULL) - { - outText (p, (const char *) "(", 1); - doTypeNameC (p, n->setvalueF.type); - mcPretty_noSpace (p); - outText (p, (const char *) ")", 1); - mcPretty_setNeedSpace (p); - } - if ((Indexing_HighIndice (n->setvalueF.values)) == 0) - { - outText (p, (const char *) "0", 1); - } - else - { - i = Indexing_LowIndice (n->setvalueF.values); - h = Indexing_HighIndice (n->setvalueF.values); - outText (p, (const char *) "(", 1); - while (i <= h) - { - outText (p, (const char *) "(1", 2); - mcPretty_setNeedSpace (p); - outText (p, (const char *) "<<", 2); - mcPretty_setNeedSpace (p); - outText (p, (const char *) "(", 1); - doExprC (p, reinterpret_cast (Indexing_GetIndice (n->setvalueF.values, i))); - doSubtractC (p, lo); - outText (p, (const char *) ")", 1); - outText (p, (const char *) ")", 1); - if (i < h) - { - mcPretty_setNeedSpace (p); - outText (p, (const char *) "|", 1); - mcPretty_setNeedSpace (p); - } - i += 1; - } - outText (p, (const char *) ")", 1); - } + s = DynamicStrings_Slice (DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (n)), 1, -1); + return replaceChar (replaceChar (s, '\\', (const char *) "\\\\", 2), '"', (const char *) "\\\"", 2); + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); } /* - getSetLow - returns the low value of the set type from - expression, n. + toCchar - */ -static decl_node getSetLow (decl_node n) +static DynamicStrings_String toCchar (nameKey_Name n) { - decl_node type; + DynamicStrings_String s; - if ((decl_getType (n)) == NULL) - { - return decl_makeLiteralInt (nameKey_makeKey ((const char *) "0", 1)); - } - else - { - type = decl_skipType (decl_getType (n)); - if (decl_isSet (type)) - { - return getMin (decl_skipType (decl_getType (type))); - } - else - { - return decl_makeLiteralInt (nameKey_makeKey ((const char *) "0", 1)); - } - } + s = DynamicStrings_Slice (DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (n)), 1, -1); + return replaceChar (replaceChar (s, '\\', (const char *) "\\\\", 2), '\'', (const char *) "\\'", 2); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - doInC - performs (((1 << (l)) & (r)) != 0) + countChar - */ -static void doInC (mcPretty_pretty p, decl_node l, decl_node r) +static unsigned int countChar (DynamicStrings_String s, char ch) { - decl_node lo; + int i; + unsigned int c; - lo = getSetLow (r); - outText (p, (const char *) "(((1", 4); - mcPretty_setNeedSpace (p); - outText (p, (const char *) "<<", 2); - mcPretty_setNeedSpace (p); - outText (p, (const char *) "(", 1); - doExprC (p, l); - doSubtractC (p, lo); - outText (p, (const char *) "))", 2); - mcPretty_setNeedSpace (p); - outText (p, (const char *) "&", 1); - mcPretty_setNeedSpace (p); - outText (p, (const char *) "(", 1); - doExprC (p, r); - outText (p, (const char *) "))", 2); - mcPretty_setNeedSpace (p); - outText (p, (const char *) "!=", 2); - mcPretty_setNeedSpace (p); - outText (p, (const char *) "0)", 2); + c = 0; + i = 0; + for (;;) + { + i = DynamicStrings_Index (s, ch, static_cast (i)); + if (i >= 0) + { + i += 1; + c += 1; + } + else + { + return c; + } + } + ReturnException ("../../gcc/m2/mc/decl.def", 20, 1); + __builtin_unreachable (); } /* - doThrowC - + lenCstring - */ -static void doThrowC (mcPretty_pretty p, decl_node n) +static unsigned int lenCstring (DynamicStrings_String s) { - mcDebug_assert (isIntrinsic (n)); - outText (p, (const char *) "throw", 5); - mcPretty_setNeedSpace (p); - outText (p, (const char *) "(", 1); - if ((expListLen (n->intrinsicF.args)) == 1) - { - doExprC (p, getExpList (n->intrinsicF.args, 1)); - } - outText (p, (const char *) ")", 1); + return (DynamicStrings_Length (s))-(countChar (s, '\\')); + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); } /* - doUnreachableC - + outCstring - */ -static void doUnreachableC (mcPretty_pretty p, decl_node n) +static void outCstring (mcPretty_pretty p, decl_node__opaque s, bool aString) { - mcDebug_assert (isIntrinsic (n)); - outText (p, (const char *) "__builtin_unreachable", 21); - mcPretty_setNeedSpace (p); - outText (p, (const char *) "(", 1); - mcDebug_assert ((expListLen (n->intrinsicF.args)) == 0); - outText (p, (const char *) ")", 1); + if (aString) + { + outText (p, (const char *) "\"", 1); + outRawS (p, s->stringF.cstring); + outText (p, (const char *) "\"", 1); + } + else + { + outText (p, (const char *) "'", 1); + outRawS (p, s->stringF.cchar); + outText (p, (const char *) "'", 1); + } } /* - outNull - + doStringC - */ -static void outNull (mcPretty_pretty p) +static void doStringC (mcPretty_pretty p, decl_node__opaque n) { - keyc_useNull (); - outText (p, (const char *) "NULL", 4); + DynamicStrings_String s; + + mcDebug_assert (isString (n)); + /* + s := InitStringCharStar (keyToCharStar (getSymName (n))) ; + IF DynamicStrings.Length (s)>3 + THEN + IF DynamicStrings.Index (s, '"', 0)=-1 + THEN + s := DynamicStrings.Slice (s, 1, -1) ; + outText (p, '"') ; + outCstring (p, s) ; + outText (p, '"') + ELSIF DynamicStrings.Index (s, "'", 0)=-1 + THEN + s := DynamicStrings.Slice (s, 1, -1) ; + outText (p, '"') ; + outCstring (p, s) ; + outText (p, '"') + ELSE + metaError1 ('illegal string {%1k}', n) + END + ELSIF DynamicStrings.Length (s) = 3 + THEN + s := DynamicStrings.Slice (s, 1, -1) ; + outText (p, "'") ; + IF DynamicStrings.char (s, 0) = "'" + THEN + outText (p, "\'") + ELSIF DynamicStrings.char (s, 0) = "\" + THEN + outText (p, "\\") + ELSE + outTextS (p, s) + END ; + outText (p, "'") + ELSE + outText (p, "'\0'") + END ; + s := KillString (s) + */ + outCstring (p, n, ! n->stringF.isCharCompatible); } /* - outTrue - + isPunct - */ -static void outTrue (mcPretty_pretty p) +static bool isPunct (char ch) { - keyc_useTrue (); - if ((mcOptions_useBool ()) && (lang == decl_ansiCP)) - { - outText (p, (const char *) "true", 4); - } - else - { - outText (p, (const char *) "TRUE", 4); - } + return (((((((((ch == '.') || (ch == '(')) || (ch == ')')) || (ch == '^')) || (ch == ':')) || (ch == ';')) || (ch == '{')) || (ch == '}')) || (ch == ',')) || (ch == '*'); + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); } /* - outFalse - + isWhite - */ -static void outFalse (mcPretty_pretty p) +static bool isWhite (char ch) { - keyc_useFalse (); - if ((mcOptions_useBool ()) && (lang == decl_ansiCP)) - { - outText (p, (const char *) "false", 5); - } - else - { - outText (p, (const char *) "FALSE", 5); - } + return ((ch == ' ') || (ch == ASCII_tab)) || (ch == ASCII_lf); + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); } /* - doExprC - + outText - */ -static void doExprC (mcPretty_pretty p, decl_node n) +static void outText (mcPretty_pretty p, const char *a_, unsigned int _a_high) { - decl_node t; - - mcDebug_assert (n != NULL); - t = getExprType (n); - switch (n->kind) - { - case decl_nil: - outNull (p); - break; - - case decl_true: - outTrue (p); - break; + DynamicStrings_String s; + char a[_a_high+1]; - case decl_false: - outFalse (p); - break; + /* make a local copy of each unbounded array. */ + memcpy (a, a_, _a_high+1); - case decl_constexp: - doUnary (p, (const char *) "", 0, n->unaryF.arg, n->unaryF.resultType, false, false); - break; + s = DynamicStrings_InitString ((const char *) a, _a_high); + outTextS (p, s); + s = DynamicStrings_KillString (s); +} - case decl_neg: - doUnary (p, (const char *) "-", 1, n->unaryF.arg, n->unaryF.resultType, false, false); - break; - case decl_not: - doUnary (p, (const char *) "!", 1, n->unaryF.arg, n->unaryF.resultType, false, true); - break; +/* + outRawS - +*/ - case decl_val: - doValC (p, n); - break; +static void outRawS (mcPretty_pretty p, DynamicStrings_String s) +{ + mcPretty_raw (p, s); +} - case decl_adr: - doAdrC (p, n); - break; - case decl_size: - case decl_tsize: - doSizeC (p, n); - break; +/* + outKm2 - +*/ - case decl_float: - doConvertSC (p, n, mcOptions_getCRealType ()); - break; +static mcPretty_pretty outKm2 (mcPretty_pretty p, const char *a_, unsigned int _a_high) +{ + unsigned int i; + DynamicStrings_String s; + char a[_a_high+1]; - case decl_trunc: - doConvertC (p, n, (const char *) "int", 3); - break; + /* make a local copy of each unbounded array. */ + memcpy (a, a_, _a_high+1); - case decl_ord: - doConvertC (p, n, (const char *) "unsigned int", 12); - break; + if (StrLib_StrEqual ((const char *) a, _a_high, (const char *) "RECORD", 6)) + { + p = mcPretty_pushPretty (p); + i = mcPretty_getcurpos (p); + mcPretty_setindent (p, i); + outText (p, (const char *) a, _a_high); + p = mcPretty_pushPretty (p); + mcPretty_setindent (p, i+indentation); + } + else if (StrLib_StrEqual ((const char *) a, _a_high, (const char *) "END", 3)) + { + /* avoid dangling else. */ + p = mcPretty_popPretty (p); + outText (p, (const char *) a, _a_high); + p = mcPretty_popPretty (p); + } + return p; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} - case decl_chr: - doConvertC (p, n, (const char *) "char", 4); - break; - case decl_cap: - doCapC (p, n); - break; +/* + outKc - +*/ - case decl_abs: - doAbsC (p, n); - break; +static mcPretty_pretty outKc (mcPretty_pretty p, const char *a_, unsigned int _a_high) +{ + int i; + unsigned int c; + DynamicStrings_String s; + DynamicStrings_String t; + char a[_a_high+1]; - case decl_high: - doFuncHighC (p, n->unaryF.arg); - break; + /* make a local copy of each unbounded array. */ + memcpy (a, a_, _a_high+1); - case decl_length: - doLengthC (p, n); - break; + s = DynamicStrings_InitString ((const char *) a, _a_high); + i = DynamicStrings_Index (s, '\\', 0); + if (i == -1) + { + t = static_cast (NULL); + } + else + { + t = DynamicStrings_Slice (s, i, 0); + s = DynamicStrings_Slice (DynamicStrings_Mark (s), 0, i); + } + if ((DynamicStrings_char (s, 0)) == '{') + { + p = mcPretty_pushPretty (p); + c = mcPretty_getcurpos (p); + mcPretty_setindent (p, c); + outTextS (p, s); + p = mcPretty_pushPretty (p); + mcPretty_setindent (p, c+indentationC); + } + else if ((DynamicStrings_char (s, 0)) == '}') + { + /* avoid dangling else. */ + p = mcPretty_popPretty (p); + outTextS (p, s); + p = mcPretty_popPretty (p); + } + outTextS (p, t); + t = DynamicStrings_KillString (t); + s = DynamicStrings_KillString (s); + return p; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} - case decl_min: - doMinC (p, n); - break; - case decl_max: - doMaxC (p, n); - break; +/* + outTextS - +*/ - case decl_throw: - doThrowC (p, n); - break; +static void outTextS (mcPretty_pretty p, DynamicStrings_String s) +{ + if (s != NULL) + { + mcPretty_prints (p, s); + } +} - case decl_unreachable: - doUnreachableC (p, n); - break; - case decl_re: - doReC (p, n); - break; +/* + outCard - +*/ - case decl_im: - doImC (p, n); - break; +static void outCard (mcPretty_pretty p, unsigned int c) +{ + DynamicStrings_String s; - case decl_cmplx: - doCmplx (p, n); - break; + s = StringConvert_CardinalToString (c, 0, ' ', 10, false); + outTextS (p, s); + s = DynamicStrings_KillString (s); +} - case decl_deref: - doDeRefC (p, n->unaryF.arg); - break; - case decl_equal: - doBinary (p, (const char *) "==", 2, n->binaryF.left, n->binaryF.right, true, true, true); - break; +/* + outTextN - +*/ - case decl_notequal: - doBinary (p, (const char *) "!=", 2, n->binaryF.left, n->binaryF.right, true, true, true); - break; +static void outTextN (mcPretty_pretty p, nameKey_Name n) +{ + DynamicStrings_String s; - case decl_less: - doBinary (p, (const char *) "<", 1, n->binaryF.left, n->binaryF.right, true, true, false); - break; + s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (n)); + mcPretty_prints (p, s); + s = DynamicStrings_KillString (s); +} - case decl_greater: - doBinary (p, (const char *) ">", 1, n->binaryF.left, n->binaryF.right, true, true, false); - break; - case decl_greequal: - doBinary (p, (const char *) ">=", 2, n->binaryF.left, n->binaryF.right, true, true, false); - break; +/* + outputEnumerationC - +*/ - case decl_lessequal: - doBinary (p, (const char *) "<=", 2, n->binaryF.left, n->binaryF.right, true, true, false); - break; +static void outputEnumerationC (mcPretty_pretty p, decl_node__opaque n) +{ + unsigned int i; + unsigned int h; + decl_node__opaque s; + DynamicStrings_String t; - case decl_componentref: - doComponentRefC (p, n->componentrefF.rec, n->componentrefF.field); - break; + outText (p, (const char *) "enum {", 6); + i = Indexing_LowIndice (n->enumerationF.listOfSons); + h = Indexing_HighIndice (n->enumerationF.listOfSons); + while (i <= h) + { + s = static_cast (Indexing_GetIndice (n->enumerationF.listOfSons, i)); + doFQDNameC (p, s, false); + if (i < h) + { + outText (p, (const char *) ",", 1); + mcPretty_setNeedSpace (p); + } + i += 1; + } + outText (p, (const char *) "}", 1); +} - case decl_pointerref: - doPointerRefC (p, n->pointerrefF.ptr, n->pointerrefF.field); - break; - case decl_cast: - doCastC (p, n->binaryF.left, n->binaryF.right); - break; +/* + isDeclType - return TRUE if the current module should declare type. +*/ - case decl_plus: - doPolyBinary (p, decl_plus, n->binaryF.left, n->binaryF.right, false, false); - break; +static bool isDeclType (decl_node__opaque type) +{ + decl_node__opaque n; + decl_node__opaque def; + nameKey_Name name; - case decl_sub: - doPolyBinary (p, decl_sub, n->binaryF.left, n->binaryF.right, false, false); - break; + if (decl_isImp (static_cast (currentModule))) + { + name = decl_getSymName (static_cast (type)); + if (name != nameKey_NulName) + { + /* Lookup the matching .def module. */ + def = static_cast (decl_lookupDef (decl_getSymName (static_cast (currentModule)))); + if (def != NULL) + { + /* Return TRUE if the symbol has not already been declared in the .def. */ + return (decl_lookupExported (static_cast (def), name)) == NULL; + } + } + } + return true; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} - case decl_div: - doBinary (p, (const char *) "/", 1, n->binaryF.left, n->binaryF.right, true, true, false); - break; - case decl_mod: - doBinary (p, (const char *) "%", 1, n->binaryF.left, n->binaryF.right, true, true, false); - break; +/* + doEnumerationC - +*/ - case decl_mult: - doPolyBinary (p, decl_mult, n->binaryF.left, n->binaryF.right, false, false); - break; +static void doEnumerationC (mcPretty_pretty p, decl_node__opaque n) +{ + if (isDeclType (n)) + { + outputEnumerationC (p, n); + } +} - case decl_divide: - doPolyBinary (p, decl_divide, n->binaryF.left, n->binaryF.right, false, false); - break; - case decl_in: - doInC (p, n->binaryF.left, n->binaryF.right); - break; +/* + doNamesC - +*/ - case decl_and: - doBinary (p, (const char *) "&&", 2, n->binaryF.left, n->binaryF.right, true, true, false); - break; +static void doNamesC (mcPretty_pretty p, nameKey_Name n) +{ + DynamicStrings_String s; - case decl_or: - doBinary (p, (const char *) "||", 2, n->binaryF.left, n->binaryF.right, true, true, false); - break; + s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (n)); + outTextS (p, s); + s = DynamicStrings_KillString (s); +} - case decl_literal: - doLiteralC (p, n); - break; - case decl_const: - doConstExpr (p, n); - break; +/* + doNameC - +*/ - case decl_enumerationfield: - doEnumerationField (p, n); - break; +static void doNameC (mcPretty_pretty p, decl_node__opaque n) +{ + if ((n != NULL) && ((decl_getSymName (static_cast (n))) != nameKey_NulName)) + { + doNamesC (p, decl_getSymName (static_cast (n))); + } +} - case decl_string: - doStringC (p, n); - break; - case decl_var: - doVar (p, n); - break; +/* + initCname - +*/ - case decl_arrayref: - doArrayRef (p, n); - break; +static void initCname (decl_cnameT *c) +{ + (*c).init = false; +} - case decl_funccall: - doFuncExprC (p, n); - break; - case decl_procedure: - doProcedure (p, n); - break; +/* + doCname - +*/ - case decl_recordfield: - doRecordfield (p, n); - break; +static nameKey_Name doCname (nameKey_Name n, decl_cnameT *c, bool scopes) +{ + DynamicStrings_String s; - case decl_setvalue: - doSetValueC (p, n); - break; + if ((*c).init) + { + return (*c).name; + } + else + { + (*c).init = true; + s = keyc_cname (n, scopes); + if (s == NULL) + { + (*c).name = n; + } + else + { + (*c).name = nameKey_makekey (DynamicStrings_string (s)); + s = DynamicStrings_KillString (s); + } + return (*c).name; + } + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} - case decl_char: - case decl_cardinal: - case decl_longcard: - case decl_shortcard: - case decl_integer: - case decl_longint: - case decl_shortint: - case decl_complex: - case decl_longcomplex: - case decl_shortcomplex: - case decl_real: - case decl_longreal: - case decl_shortreal: - case decl_bitset: - case decl_boolean: - case decl_proc: - doBaseC (p, n); + +/* + getDName - +*/ + +static nameKey_Name getDName (decl_node__opaque n, bool scopes) +{ + nameKey_Name m; + + m = decl_getSymName (static_cast (n)); + switch (n->kind) + { + case decl_procedure: + return doCname (m, &n->procedureF.cname, scopes); break; - case decl_address: - case decl_loc: - case decl_byte: - case decl_word: - case decl_csizet: - case decl_cssizet: - doSystemC (p, n); + case decl_var: + return doCname (m, &n->varF.cname, scopes); break; - case decl_type: - doTypeNameC (p, n); + case decl_recordfield: + return doCname (m, &n->recordfieldF.cname, scopes); break; - case decl_pointer: - doTypeNameC (p, n); + case decl_enumerationfield: + return doCname (m, &n->enumerationfieldF.cname, scopes); break; default: - CaseException ("../../gcc/m2/mc/decl.def", 20, 1); - __builtin_unreachable (); + break; } + return m; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); } /* - doExprCup - + doDNameC - */ -static void doExprCup (mcPretty_pretty p, decl_node n, bool unpackProc) +static void doDNameC (mcPretty_pretty p, decl_node__opaque n, bool scopes) { - decl_node t; - - doExprC (p, n); - if (unpackProc) + if ((n != NULL) && ((decl_getSymName (static_cast (n))) != nameKey_NulName)) { - t = decl_skipType (getExprType (n)); - if ((t != NULL) && (isAProcType (t))) - { - outText (p, (const char *) ".proc", 5); - } + doNamesC (p, getDName (n, scopes)); } } /* - doExprM2 - + doFQDNameC - */ -static void doExprM2 (mcPretty_pretty p, decl_node n) +static void doFQDNameC (mcPretty_pretty p, decl_node__opaque n, bool scopes) { - mcDebug_assert (n != NULL); - switch (n->kind) - { - case decl_nil: - outText (p, (const char *) "NIL", 3); - break; + DynamicStrings_String s; - case decl_true: - outText (p, (const char *) "TRUE", 4); - break; + s = getFQDstring (n, scopes); + outTextS (p, s); + s = DynamicStrings_KillString (s); +} - case decl_false: - outText (p, (const char *) "FALSE", 5); - break; - case decl_constexp: - doUnary (p, (const char *) "", 0, n->unaryF.arg, n->unaryF.resultType, false, false); - break; +/* + doFQNameC - +*/ - case decl_neg: - doUnary (p, (const char *) "-", 1, n->unaryF.arg, n->unaryF.resultType, false, false); - break; +static void doFQNameC (mcPretty_pretty p, decl_node__opaque n) +{ + DynamicStrings_String s; - case decl_not: - doUnary (p, (const char *) "NOT", 3, n->unaryF.arg, n->unaryF.resultType, true, true); - break; + s = getFQstring (n); + outTextS (p, s); + s = DynamicStrings_KillString (s); +} - case decl_adr: - doUnary (p, (const char *) "ADR", 3, n->unaryF.arg, n->unaryF.resultType, true, true); - break; - case decl_size: - doUnary (p, (const char *) "SIZE", 4, n->unaryF.arg, n->unaryF.resultType, true, true); - break; +/* + doNameM2 - +*/ - case decl_tsize: - doUnary (p, (const char *) "TSIZE", 5, n->unaryF.arg, n->unaryF.resultType, true, true); - break; +static void doNameM2 (mcPretty_pretty p, decl_node__opaque n) +{ + doNameC (p, n); +} - case decl_float: - doUnary (p, (const char *) "FLOAT", 5, n->unaryF.arg, n->unaryF.resultType, true, true); - break; - case decl_trunc: - doUnary (p, (const char *) "TRUNC", 5, n->unaryF.arg, n->unaryF.resultType, true, true); - break; +/* + doUsed - +*/ - case decl_ord: - doUnary (p, (const char *) "ORD", 3, n->unaryF.arg, n->unaryF.resultType, true, true); - break; +static void doUsed (mcPretty_pretty p, bool used) +{ + if (! used) + { + mcPretty_setNeedSpace (p); + outText (p, (const char *) "__attribute__((unused))", 23); + } +} - case decl_chr: - doUnary (p, (const char *) "CHR", 3, n->unaryF.arg, n->unaryF.resultType, true, true); - break; - case decl_cap: - doUnary (p, (const char *) "CAP", 3, n->unaryF.arg, n->unaryF.resultType, true, true); - break; +/* + doHighC - +*/ - case decl_high: - doUnary (p, (const char *) "HIGH", 4, n->unaryF.arg, n->unaryF.resultType, true, true); - break; +static void doHighC (mcPretty_pretty p, decl_node__opaque a, nameKey_Name n, bool isused) +{ + if ((decl_isArray (static_cast (a))) && (decl_isUnbounded (static_cast (a)))) + { + /* need to display high. */ + mcPretty_print (p, (const char *) ",", 1); + mcPretty_setNeedSpace (p); + doTypeNameC (p, cardinalN); + mcPretty_setNeedSpace (p); + mcPretty_print (p, (const char *) "_", 1); + outTextN (p, n); + mcPretty_print (p, (const char *) "_high", 5); + doUsed (p, isused); + } +} - case decl_re: - doUnary (p, (const char *) "RE", 2, n->unaryF.arg, n->unaryF.resultType, true, true); - break; - case decl_im: - doUnary (p, (const char *) "IM", 2, n->unaryF.arg, n->unaryF.resultType, true, true); - break; +/* + doParamConstCast - +*/ - case decl_deref: - doPostUnary (p, (const char *) "^", 1, n->unaryF.arg); - break; +static void doParamConstCast (mcPretty_pretty p, decl_node__opaque n) +{ + decl_node__opaque ptype; - case decl_equal: - doBinary (p, (const char *) "=", 1, n->binaryF.left, n->binaryF.right, true, true, false); - break; + ptype = static_cast (decl_getType (static_cast (n))); + if (((decl_isArray (static_cast (ptype))) && (decl_isUnbounded (static_cast (ptype)))) && (lang == decl_ansiCP)) + { + outText (p, (const char *) "const", 5); + mcPretty_setNeedSpace (p); + } +} - case decl_notequal: - doBinary (p, (const char *) "#", 1, n->binaryF.left, n->binaryF.right, true, true, false); - break; - case decl_less: - doBinary (p, (const char *) "<", 1, n->binaryF.left, n->binaryF.right, true, true, false); - break; +/* + getParameterVariable - returns the variable which shadows the parameter + named, m, in parameter block, n. +*/ - case decl_greater: - doBinary (p, (const char *) ">", 1, n->binaryF.left, n->binaryF.right, true, true, false); - break; +static decl_node__opaque getParameterVariable (decl_node__opaque n, nameKey_Name m) +{ + decl_node__opaque p; - case decl_greequal: - doBinary (p, (const char *) ">=", 2, n->binaryF.left, n->binaryF.right, true, true, false); - break; + mcDebug_assert ((decl_isParam (static_cast (n))) || (decl_isVarParam (static_cast (n)))); + if (decl_isParam (static_cast (n))) + { + p = n->paramF.scope; + } + else + { + p = n->varparamF.scope; + } + mcDebug_assert (decl_isProcedure (static_cast (p))); + return static_cast (decl_lookupInScope (static_cast (p), m)); + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} - case decl_lessequal: - doBinary (p, (const char *) "<=", 2, n->binaryF.left, n->binaryF.right, true, true, false); - break; - case decl_componentref: - doBinary (p, (const char *) ".", 1, n->componentrefF.rec, n->componentrefF.field, false, false, false); - break; +/* + doParamTypeEmit - emit parameter type for C/C++. It checks to see if the + parameter type is a procedure type and if it were declared + in a definition module for "C" and if so it uses the "C" + definition for a procedure type, rather than the mc + C++ version. +*/ - case decl_pointerref: - doBinary (p, (const char *) "^.", 2, n->pointerrefF.ptr, n->pointerrefF.field, false, false, false); - break; +static void doParamTypeEmit (mcPretty_pretty p, decl_node__opaque paramnode, decl_node__opaque paramtype) +{ + mcDebug_assert ((decl_isParam (static_cast (paramnode))) || (decl_isVarParam (static_cast (paramnode)))); + if ((isForC (paramnode)) && (decl_isProcType (decl_skipType (static_cast (paramtype))))) + { + doFQNameC (p, paramtype); + outText (p, (const char *) "_C", 2); + } + else + { + doTypeNameC (p, paramtype); + doOpaqueModifier (p, paramnode); + } + /* + IF nodeUsesOpaque (paramnode) AND (NOT getNodeOpaqueVoidStar (paramnode)) + THEN + outText (p, '__opaque') + END + */ +} - case decl_cast: - doPreBinary (p, (const char *) "CAST", 4, n->binaryF.left, n->binaryF.right, true, true); - break; - case decl_val: - doPreBinary (p, (const char *) "VAL", 3, n->binaryF.left, n->binaryF.right, true, true); - break; +/* + doParamTypeNameModifier - Add an _ to an unbounded parameter which is non var. +*/ - case decl_cmplx: - doPreBinary (p, (const char *) "CMPLX", 5, n->binaryF.left, n->binaryF.right, true, true); - break; +static void doParamTypeNameModifier (mcPretty_pretty p, decl_node__opaque ptype, bool varparam) +{ + if ((! varparam && (decl_isArray (static_cast (ptype)))) && (decl_isUnbounded (static_cast (ptype)))) + { + outText (p, (const char *) "_", 1); + } +} - case decl_plus: - doBinary (p, (const char *) "+", 1, n->binaryF.left, n->binaryF.right, false, false, false); + +/* + initOpaqueCastState - assign fields opaque and voidstar in opaquestate. +*/ + +static void initOpaqueCastState (decl_opaqueCastState *opaquestate, bool opaque, bool voidstar) +{ + (*opaquestate).opaque = opaque; + (*opaquestate).voidStar = voidstar; +} + + +/* + initNodeOpaqueCastState - assign opaque and currentvoidstar +*/ + +static void initNodeOpaqueCastState (decl_node__opaque n, bool opaque, bool voidstar) +{ + switch (n->kind) + { + case decl_opaquecast: + initOpaqueCastState (&n->opaquecastF.opaqueState, opaque, voidstar); break; - case decl_sub: - doBinary (p, (const char *) "-", 1, n->binaryF.left, n->binaryF.right, false, false, false); + case decl_funccall: + initOpaqueCastState (&n->funccallF.opaqueState, opaque, voidstar); break; - case decl_div: - doBinary (p, (const char *) "DIV", 3, n->binaryF.left, n->binaryF.right, true, true, false); + case decl_var: + initOpaqueCastState (&n->varF.opaqueState, opaque, voidstar); break; - case decl_mod: - doBinary (p, (const char *) "MOD", 3, n->binaryF.left, n->binaryF.right, true, true, false); + case decl_array: + initOpaqueCastState (&n->arrayF.opaqueState, opaque, voidstar); break; - case decl_mult: - doBinary (p, (const char *) "*", 1, n->binaryF.left, n->binaryF.right, false, false, false); + case decl_varparam: + initOpaqueCastState (&n->varparamF.opaqueState, opaque, voidstar); break; - case decl_divide: - doBinary (p, (const char *) "/", 1, n->binaryF.left, n->binaryF.right, false, false, false); + case decl_param: + initOpaqueCastState (&n->paramF.opaqueState, opaque, voidstar); break; - case decl_literal: - doLiteral (p, n); + case decl_pointer: + initOpaqueCastState (&n->pointerF.opaqueState, opaque, voidstar); break; - case decl_const: - doConstExpr (p, n); + case decl_recordfield: + initOpaqueCastState (&n->recordfieldF.opaqueState, opaque, voidstar); break; - case decl_enumerationfield: - doEnumerationField (p, n); + case decl_componentref: + initOpaqueCastState (&n->componentrefF.opaqueState, opaque, voidstar); break; - case decl_string: - doString (p, n); + case decl_pointerref: + initOpaqueCastState (&n->pointerrefF.opaqueState, opaque, voidstar); break; - case decl_max: - doUnary (p, (const char *) "MAX", 3, n->unaryF.arg, n->unaryF.resultType, true, true); + case decl_arrayref: + initOpaqueCastState (&n->arrayrefF.opaqueState, opaque, voidstar); break; - case decl_min: - doUnary (p, (const char *) "MIN", 3, n->unaryF.arg, n->unaryF.resultType, true, true); + case decl_procedure: + initOpaqueCastState (&n->procedureF.opaqueState, opaque, voidstar); break; - case decl_var: - doVar (p, n); + case decl_proctype: + initOpaqueCastState (&n->proctypeF.opaqueState, opaque, voidstar); break; default: - CaseException ("../../gcc/m2/mc/decl.def", 20, 1); + M2RTS_HALT (-1); __builtin_unreachable (); + break; } } /* - doVar - + setOpaqueCastState - set the voidStar field in opaquestate. */ -static void doVar (mcPretty_pretty p, decl_node n) +static void setOpaqueCastState (decl_opaqueCastState *opaquestate, bool voidstar) { - mcDebug_assert (decl_isVar (n)); - if (n->varF.isVarParameter) - { - outText (p, (const char *) "(*", 2); - doFQDNameC (p, n, true); - outText (p, (const char *) ")", 1); - } - else - { - doFQDNameC (p, n, true); - } + (*opaquestate).voidStar = voidstar; } /* - doLiteralC - + setNodeOpaqueVoidStar - sets the voidStar field in node to voidstar. */ -static void doLiteralC (mcPretty_pretty p, decl_node n) +static void setNodeOpaqueVoidStar (decl_node__opaque n, bool voidstar) { - DynamicStrings_String s; - - mcDebug_assert (decl_isLiteral (n)); - s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n))); - if (n->literalF.type == charN) - { - if ((DynamicStrings_char (s, -1)) == 'C') - { - s = DynamicStrings_Slice (DynamicStrings_Mark (s), 0, -1); - if ((DynamicStrings_char (s, 0)) != '0') - { - s = DynamicStrings_ConCat (DynamicStrings_InitString ((const char *) "0", 1), DynamicStrings_Mark (s)); - } - } - outText (p, (const char *) "(char)", 6); - mcPretty_setNeedSpace (p); - } - else if ((DynamicStrings_char (s, -1)) == 'H') - { - /* avoid dangling else. */ - outText (p, (const char *) "0x", 2); - s = DynamicStrings_Slice (DynamicStrings_Mark (s), 0, -1); - } - else if ((DynamicStrings_char (s, -1)) == 'B') + mcDebug_assert (nodeUsesOpaque (n)); + switch (n->kind) { - /* avoid dangling else. */ - outText (p, (const char *) "0", 1); - s = DynamicStrings_Slice (DynamicStrings_Mark (s), 0, -1); - } - outTextS (p, s); - s = DynamicStrings_KillString (s); -} - - -/* - doLiteral - -*/ + case decl_opaquecast: + setOpaqueCastState (&n->opaquecastF.opaqueState, voidstar); + break; -static void doLiteral (mcPretty_pretty p, decl_node n) -{ - DynamicStrings_String s; + case decl_funccall: + setOpaqueCastState (&n->funccallF.opaqueState, voidstar); + break; - mcDebug_assert (decl_isLiteral (n)); - s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n))); - if (n->literalF.type == charN) - { - if ((DynamicStrings_char (s, -1)) == 'C') - { - s = DynamicStrings_Slice (DynamicStrings_Mark (s), 0, -1); - if ((DynamicStrings_char (s, 0)) != '0') - { - s = DynamicStrings_ConCat (DynamicStrings_InitString ((const char *) "0", 1), DynamicStrings_Mark (s)); - } - } - outText (p, (const char *) "(char)", 6); - mcPretty_setNeedSpace (p); - } - outTextS (p, s); - s = DynamicStrings_KillString (s); -} + case decl_var: + setOpaqueCastState (&n->varF.opaqueState, voidstar); + break; + case decl_array: + setOpaqueCastState (&n->arrayF.opaqueState, voidstar); + break; -/* - isString - returns TRUE if node, n, is a string. -*/ + case decl_varparam: + setOpaqueCastState (&n->varparamF.opaqueState, voidstar); + break; -static bool isString (decl_node n) -{ - mcDebug_assert (n != NULL); - return n->kind == decl_string; - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); -} + case decl_param: + setOpaqueCastState (&n->paramF.opaqueState, voidstar); + break; + case decl_pointer: + setOpaqueCastState (&n->pointerF.opaqueState, voidstar); + break; -/* - doString - -*/ + case decl_recordfield: + setOpaqueCastState (&n->recordfieldF.opaqueState, voidstar); + break; -static void doString (mcPretty_pretty p, decl_node n) -{ - DynamicStrings_String s; + case decl_componentref: + mcDebug_assert (! voidstar); + setOpaqueCastState (&n->componentrefF.opaqueState, voidstar); + break; - mcDebug_assert (isString (n)); - s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n))); - outTextS (p, s); - s = DynamicStrings_KillString (s); - /* - IF DynamicStrings.Index (s, '"', 0)=-1 - THEN - outText (p, '"') ; - outTextS (p, s) ; - outText (p, '"') - ELSIF DynamicStrings.Index (s, "'", 0)=-1 - THEN - outText (p, '"') ; - outTextS (p, s) ; - outText (p, '"') - ELSE - metaError1 ('illegal string {%1k}', n) - END - */ - M2RTS_HALT (-1); - __builtin_unreachable (); -} + case decl_pointerref: + mcDebug_assert (! voidstar); + setOpaqueCastState (&n->pointerrefF.opaqueState, voidstar); + break; + case decl_arrayref: + setOpaqueCastState (&n->arrayrefF.opaqueState, voidstar); + break; -/* - replaceChar - replace every occurance of, ch, by, a and return modified string, s. -*/ + case decl_procedure: + setOpaqueCastState (&n->procedureF.opaqueState, voidstar); + break; -static DynamicStrings_String replaceChar (DynamicStrings_String s, char ch, const char *a_, unsigned int _a_high) -{ - int i; - char a[_a_high+1]; + case decl_proctype: + setOpaqueCastState (&n->proctypeF.opaqueState, voidstar); + break; - /* make a local copy of each unbounded array. */ - memcpy (a, a_, _a_high+1); - i = 0; - for (;;) - { - i = DynamicStrings_Index (s, ch, static_cast (i)); - if (i == 0) - { - s = DynamicStrings_ConCat (DynamicStrings_InitString ((const char *) a, _a_high), DynamicStrings_Slice (s, 1, 0)); - i = StrLib_StrLen ((const char *) a, _a_high); - } - else if (i > 0) - { - /* avoid dangling else. */ - s = DynamicStrings_ConCat (DynamicStrings_ConCat (DynamicStrings_Slice (s, 0, i), DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high))), DynamicStrings_Slice (s, i+1, 0)); - i += StrLib_StrLen ((const char *) a, _a_high); - } - else - { - /* avoid dangling else. */ - return s; - } - } - ReturnException ("../../gcc/m2/mc/decl.def", 20, 1); - __builtin_unreachable (); + default: + M2RTS_HALT (-1); + __builtin_unreachable (); + break; + } } /* - toCstring - translates string, n, into a C string - and returns the new String. + nodeUsesOpaque - return TRUE if node n uses an opaque type. */ -static DynamicStrings_String toCstring (nameKey_Name n) +static bool nodeUsesOpaque (decl_node__opaque n) { - DynamicStrings_String s; - - s = DynamicStrings_Slice (DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (n)), 1, -1); - return replaceChar (replaceChar (s, '\\', (const char *) "\\\\", 2), '"', (const char *) "\\\"", 2); - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); -} - + switch (n->kind) + { + case decl_opaquecast: + return n->opaquecastF.opaqueState.opaque; + break; -/* - toCchar - -*/ + case decl_funccall: + return n->funccallF.opaqueState.opaque; + break; -static DynamicStrings_String toCchar (nameKey_Name n) -{ - DynamicStrings_String s; + case decl_var: + return n->varF.opaqueState.opaque; + break; - s = DynamicStrings_Slice (DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (n)), 1, -1); - return replaceChar (replaceChar (s, '\\', (const char *) "\\\\", 2), '\'', (const char *) "\\'", 2); - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); -} + case decl_array: + return n->arrayF.opaqueState.opaque; + break; + case decl_varparam: + return n->varparamF.opaqueState.opaque; + break; -/* - countChar - -*/ + case decl_param: + return n->paramF.opaqueState.opaque; + break; -static unsigned int countChar (DynamicStrings_String s, char ch) -{ - int i; - unsigned int c; + case decl_pointer: + return n->pointerF.opaqueState.opaque; + break; - c = 0; - i = 0; - for (;;) - { - i = DynamicStrings_Index (s, ch, static_cast (i)); - if (i >= 0) - { - i += 1; - c += 1; - } - else - { - return c; - } - } - ReturnException ("../../gcc/m2/mc/decl.def", 20, 1); - __builtin_unreachable (); -} + case decl_recordfield: + return n->recordfieldF.opaqueState.opaque; + break; + case decl_componentref: + return n->componentrefF.opaqueState.opaque; + break; -/* - lenCstring - -*/ + case decl_pointerref: + return n->pointerrefF.opaqueState.opaque; + break; -static unsigned int lenCstring (DynamicStrings_String s) -{ - return (DynamicStrings_Length (s))-(countChar (s, '\\')); + case decl_arrayref: + return n->arrayrefF.opaqueState.opaque; + break; + + case decl_procedure: + return n->procedureF.opaqueState.opaque; + break; + + case decl_proctype: + return n->proctypeF.opaqueState.opaque; + break; + + case decl_deref: + return nodeUsesOpaque (n->unaryF.arg); + break; + + + default: + return false; + break; + } /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - outCstring - + getNodeOpaqueVoidStar - return TRUE if the opaque type used by node n is a void *. */ -static void outCstring (mcPretty_pretty p, decl_node s, bool aString) +static bool getNodeOpaqueVoidStar (decl_node__opaque n) { - if (aString) - { - outText (p, (const char *) "\"", 1); - outRawS (p, s->stringF.cstring); - outText (p, (const char *) "\"", 1); - } - else + mcDebug_assert (nodeUsesOpaque (n)); + switch (n->kind) { - outText (p, (const char *) "'", 1); - outRawS (p, s->stringF.cchar); - outText (p, (const char *) "'", 1); - } -} + case decl_opaquecast: + return n->opaquecastF.opaqueState.voidStar; + break; + case decl_funccall: + return n->funccallF.opaqueState.voidStar; + break; -/* - doStringC - -*/ + case decl_var: + return n->varF.opaqueState.voidStar; + break; -static void doStringC (mcPretty_pretty p, decl_node n) -{ - DynamicStrings_String s; + case decl_array: + return n->arrayF.opaqueState.voidStar; + break; - mcDebug_assert (isString (n)); - /* - s := InitStringCharStar (keyToCharStar (getSymName (n))) ; - IF DynamicStrings.Length (s)>3 - THEN - IF DynamicStrings.Index (s, '"', 0)=-1 - THEN - s := DynamicStrings.Slice (s, 1, -1) ; - outText (p, '"') ; - outCstring (p, s) ; - outText (p, '"') - ELSIF DynamicStrings.Index (s, "'", 0)=-1 - THEN - s := DynamicStrings.Slice (s, 1, -1) ; - outText (p, '"') ; - outCstring (p, s) ; - outText (p, '"') - ELSE - metaError1 ('illegal string {%1k}', n) - END - ELSIF DynamicStrings.Length (s) = 3 - THEN - s := DynamicStrings.Slice (s, 1, -1) ; - outText (p, "'") ; - IF DynamicStrings.char (s, 0) = "'" - THEN - outText (p, "\'") - ELSIF DynamicStrings.char (s, 0) = "\" - THEN - outText (p, "\\") - ELSE - outTextS (p, s) - END ; - outText (p, "'") - ELSE - outText (p, "'\0'") - END ; - s := KillString (s) - */ - outCstring (p, n, ! n->stringF.isCharCompatible); -} + case decl_varparam: + return n->varparamF.opaqueState.voidStar; + break; + case decl_param: + return n->paramF.opaqueState.voidStar; + break; -/* - isPunct - -*/ + case decl_pointer: + return n->pointerF.opaqueState.voidStar; + break; -static bool isPunct (char ch) -{ - return (((((((((ch == '.') || (ch == '(')) || (ch == ')')) || (ch == '^')) || (ch == ':')) || (ch == ';')) || (ch == '{')) || (ch == '}')) || (ch == ',')) || (ch == '*'); - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); -} + case decl_recordfield: + return n->recordfieldF.opaqueState.voidStar; + break; + case decl_componentref: + return n->componentrefF.opaqueState.voidStar; + break; -/* - isWhite - -*/ + case decl_pointerref: + return n->pointerrefF.opaqueState.voidStar; + break; -static bool isWhite (char ch) -{ - return ((ch == ' ') || (ch == ASCII_tab)) || (ch == ASCII_lf); - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); -} + case decl_arrayref: + return n->arrayrefF.opaqueState.voidStar; + break; + case decl_procedure: + return n->procedureF.opaqueState.voidStar; + break; -/* - outText - -*/ + case decl_proctype: + return n->proctypeF.opaqueState.voidStar; + break; -static void outText (mcPretty_pretty p, const char *a_, unsigned int _a_high) -{ - DynamicStrings_String s; - char a[_a_high+1]; + case decl_deref: + return false; + break; - /* make a local copy of each unbounded array. */ - memcpy (a, a_, _a_high+1); - s = DynamicStrings_InitString ((const char *) a, _a_high); - outTextS (p, s); - s = DynamicStrings_KillString (s); + default: + M2RTS_HALT (-1); + __builtin_unreachable (); + break; + } + ReturnException ("../../gcc/m2/mc/decl.def", 20, 1); + __builtin_unreachable (); } /* - outRawS - + getOpaqueFlushNecessary - return TRUE if the value next differs from the opaque state. */ -static void outRawS (mcPretty_pretty p, DynamicStrings_String s) +static bool getOpaqueFlushNecessary (decl_opaqueCastState state, bool next) { - mcPretty_raw (p, s); + return state.opaque && (state.voidStar != next); + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); } /* - outKm2 - + getNodeOpaqueFlushNecessary - return TRUE if the value of next requires a cast. */ -static mcPretty_pretty outKm2 (mcPretty_pretty p, const char *a_, unsigned int _a_high) +static bool getNodeOpaqueFlushNecessary (decl_node__opaque n, bool next) { - unsigned int i; - DynamicStrings_String s; - char a[_a_high+1]; + switch (n->kind) + { + case decl_opaquecast: + return getOpaqueFlushNecessary (n->opaquecastF.opaqueState, next); + break; - /* make a local copy of each unbounded array. */ - memcpy (a, a_, _a_high+1); + case decl_funccall: + return getOpaqueFlushNecessary (n->funccallF.opaqueState, next); + break; - if (StrLib_StrEqual ((const char *) a, _a_high, (const char *) "RECORD", 6)) - { - p = mcPretty_pushPretty (p); - i = mcPretty_getcurpos (p); - mcPretty_setindent (p, i); - outText (p, (const char *) a, _a_high); - p = mcPretty_pushPretty (p); - mcPretty_setindent (p, i+indentation); - } - else if (StrLib_StrEqual ((const char *) a, _a_high, (const char *) "END", 3)) - { - /* avoid dangling else. */ - p = mcPretty_popPretty (p); - outText (p, (const char *) a, _a_high); - p = mcPretty_popPretty (p); - } - return p; - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); -} + case decl_var: + return getOpaqueFlushNecessary (n->varF.opaqueState, next); + break; + case decl_array: + return getOpaqueFlushNecessary (n->arrayF.opaqueState, next); + break; -/* - outKc - -*/ + case decl_varparam: + return getOpaqueFlushNecessary (n->varparamF.opaqueState, next); + break; -static mcPretty_pretty outKc (mcPretty_pretty p, const char *a_, unsigned int _a_high) -{ - int i; - unsigned int c; - DynamicStrings_String s; - DynamicStrings_String t; - char a[_a_high+1]; + case decl_param: + return getOpaqueFlushNecessary (n->paramF.opaqueState, next); + break; - /* make a local copy of each unbounded array. */ - memcpy (a, a_, _a_high+1); + case decl_pointer: + return getOpaqueFlushNecessary (n->pointerF.opaqueState, next); + break; - s = DynamicStrings_InitString ((const char *) a, _a_high); - i = DynamicStrings_Index (s, '\\', 0); - if (i == -1) - { - t = NULL; - } - else - { - t = DynamicStrings_Slice (s, i, 0); - s = DynamicStrings_Slice (DynamicStrings_Mark (s), 0, i); - } - if ((DynamicStrings_char (s, 0)) == '{') - { - p = mcPretty_pushPretty (p); - c = mcPretty_getcurpos (p); - mcPretty_setindent (p, c); - outTextS (p, s); - p = mcPretty_pushPretty (p); - mcPretty_setindent (p, c+indentationC); - } - else if ((DynamicStrings_char (s, 0)) == '}') - { - /* avoid dangling else. */ - p = mcPretty_popPretty (p); - outTextS (p, s); - p = mcPretty_popPretty (p); - } - outTextS (p, t); - t = DynamicStrings_KillString (t); - s = DynamicStrings_KillString (s); - return p; - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); -} + case decl_recordfield: + return getOpaqueFlushNecessary (n->recordfieldF.opaqueState, next); + break; + + case decl_componentref: + return getOpaqueFlushNecessary (n->componentrefF.opaqueState, next); + break; + + case decl_pointerref: + return getOpaqueFlushNecessary (n->pointerrefF.opaqueState, next); + break; + + case decl_arrayref: + return getOpaqueFlushNecessary (n->arrayrefF.opaqueState, next); + break; + case decl_procedure: + return getOpaqueFlushNecessary (n->procedureF.opaqueState, next); + break; -/* - outTextS - -*/ + case decl_proctype: + return getOpaqueFlushNecessary (n->proctypeF.opaqueState, next); + break; -static void outTextS (mcPretty_pretty p, DynamicStrings_String s) -{ - if (s != NULL) - { - mcPretty_prints (p, s); + + default: + return false; + break; } + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); } /* - outCard - + makeOpaqueCast - wrap node n with an opaquecast node and assign + voidstar into the new opaque state. */ -static void outCard (mcPretty_pretty p, unsigned int c) +static decl_node__opaque makeOpaqueCast (decl_node__opaque n, bool voidstar) { - DynamicStrings_String s; + decl_node__opaque o; - s = StringConvert_CardinalToString (c, 0, ' ', 10, false); - outTextS (p, s); - s = DynamicStrings_KillString (s); + o = newNode (decl_opaquecast); + o->opaquecastF.exp = n; + initOpaqueCastState (&o->opaquecastF.opaqueState, true, voidstar); + return o; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); } /* - outTextN - + flushOpaque - perform a cast to voidstar (if necessary) and ignore the new + node which could be created. */ -static void outTextN (mcPretty_pretty p, nameKey_Name n) +static void flushOpaque (mcPretty_pretty p, decl_node__opaque n, bool toVoidStar) { - DynamicStrings_String s; + decl_node__opaque o; - s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (n)); - mcPretty_prints (p, s); - s = DynamicStrings_KillString (s); + o = castOpaque (p, n, toVoidStar); } /* - doTypeAliasC - + castOpaque - flushes the opaque type casts if necessary and changes the + voidstar boolean value. If necessary it creates a opaquecast + and returns the new node otherwise return n. */ -static void doTypeAliasC (mcPretty_pretty p, decl_node n, decl_node *m) +static decl_node__opaque castOpaque (mcPretty_pretty p, decl_node__opaque n, bool toVoidStar) { - mcPretty_print (p, (const char *) "typedef", 7); - mcPretty_setNeedSpace (p); - if ((decl_isTypeHidden (n)) && ((decl_isDef (decl_getMainModule ())) || ((decl_getScope (n)) != (decl_getMainModule ())))) + decl_node__opaque type; + + if (getNodeOpaqueFlushNecessary (n, toVoidStar)) { - outText (p, (const char *) "void *", 6); + type = static_cast (decl_getType (static_cast (n))); + if (toVoidStar) + { + /* next is true cast to void * opaque type. */ + outText (p, (const char *) "static_cast<", 12); + doTypeNameC (p, type); + mcPretty_noSpace (p); + outText (p, (const char *) "> (", 3); + doExprC (p, n); + outText (p, (const char *) ")", 1); + return makeOpaqueCast (n, true); + } + else + { + /* next is false cast to __opaque opaque type. */ + outText (p, (const char *) "static_cast<", 12); + doTypeNameC (p, type); + outText (p, (const char *) "__opaque", 8); + mcPretty_noSpace (p); + outText (p, (const char *) "> (", 3); + doExprC (p, n); + outText (p, (const char *) ")", 1); + return makeOpaqueCast (n, false); + } } else { - doTypeC (p, decl_getType (n), m); - } - if ((*m) != NULL) - { - doFQNameC (p, (*m)); + if (debugOpaque) + { + doP = p; + dumpOpaqueState (n); + if (nodeUsesOpaque (n)) + { + outText (p, (const char *) " /* no difference seen */ ", 26); + } + else + { + outText (p, (const char *) " /* no opaque used */ ", 22); + } + } + doExprC (p, n); } - mcPretty_print (p, (const char *) ";\\n\\n", 5); + return n; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); } /* - doEnumerationC - + isTypeOpaqueDefImp - returns TRUE if type is an opaque type by checking + the def/imp pair of modules or fall back to the + definition module. */ -static void doEnumerationC (mcPretty_pretty p, decl_node n) +static bool isTypeOpaqueDefImp (decl_node__opaque type) { - unsigned int i; - unsigned int h; - decl_node s; - DynamicStrings_String t; + decl_node__opaque scope; + decl_node__opaque def; + decl_node__opaque opaque; - outText (p, (const char *) "enum {", 6); - i = Indexing_LowIndice (n->enumerationF.listOfSons); - h = Indexing_HighIndice (n->enumerationF.listOfSons); - while (i <= h) + if (type == NULL) { - s = static_cast (Indexing_GetIndice (n->enumerationF.listOfSons, i)); - doFQDNameC (p, s, false); - if (i < h) + return false; + } + else if (decl_isType (static_cast (type))) + { + /* avoid dangling else. */ + scope = static_cast (decl_getScope (static_cast (type))); + if (decl_isImp (static_cast (scope))) { - outText (p, (const char *) ",", 1); - mcPretty_setNeedSpace (p); + /* avoid dangling else. */ + def = static_cast (decl_lookupDef (decl_getSymName (static_cast (scope)))); + if (def != NULL) + { + /* Lookup the type name in the matching definition module. */ + opaque = static_cast (decl_lookupExported (static_cast (def), decl_getSymName (static_cast (type)))); + return ((opaque != NULL) && (decl_isType (static_cast (opaque)))) && (decl_isTypeOpaque (static_cast (opaque))); + } + } + else + { + /* Otherwise just check the definition module. */ + return decl_isTypeOpaque (static_cast (type)); } - i += 1; } - outText (p, (const char *) "}", 1); + return false; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); } /* - doNamesC - + isParamVoidStar - return TRUE if the procedure or proctype opaque type + parameter should be implemented as a (void * ). */ -static void doNamesC (mcPretty_pretty p, nameKey_Name n) +static bool isParamVoidStar (decl_node__opaque n) { - DynamicStrings_String s; + decl_node__opaque proc; + decl_node__opaque type; - s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (n)); - outTextS (p, s); - s = DynamicStrings_KillString (s); + proc = static_cast (decl_getScope (static_cast (n))); + mcDebug_assert ((decl_isProcedure (static_cast (proc))) || (decl_isProcType (static_cast (proc)))); + type = static_cast (decl_getType (static_cast (n))); + return isReturnVoidStar (proc, type); + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); } /* - doNameC - + isRefVoidStar - returns TRUE if the ref node uses an opaque type which + is represented as a (void * ). */ -static void doNameC (mcPretty_pretty p, decl_node n) +static bool isRefVoidStar (decl_node__opaque n) { - if ((n != NULL) && ((decl_getSymName (n)) != nameKey_NulName)) + decl_node__opaque type; + + type = static_cast (decl_getType (static_cast (n))); + if ((! (decl_isType (static_cast (type)))) || (! (decl_isTypeOpaque (static_cast (type))))) { - doNamesC (p, decl_getSymName (n)); + /* We should finish the procedure as the ref does not use an opaque. */ + return true; } + else + { + /* We check whether the opaque type was declared in the implementation + module. If it is declared in the implementation module then we + return FALSE. */ + return ! (isDeclInImp (type)); + } + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); } /* - initCname - -*/ - -static void initCname (decl_cnameT *c) -{ - (*c).init = false; -} - - -/* - doCname - + isReturnVoidStar - return TRUE if the procedure or proctype opaque type + return type should be implemented as a (void * ). */ -static nameKey_Name doCname (nameKey_Name n, decl_cnameT *c, bool scopes) +static bool isReturnVoidStar (decl_node__opaque proc, decl_node__opaque type) { - DynamicStrings_String s; + decl_node__opaque def; - if ((*c).init) + mcDebug_assert ((decl_isProcedure (static_cast (proc))) || (decl_isProcType (static_cast (proc)))); + if (decl_isExported (static_cast (proc))) { - return (*c).name; + return true; } else { - (*c).init = true; - s = keyc_cname (n, scopes); - if (s == NULL) + /* Not exported therefore local, we check whether the opaque type + was declared in the implementation module. */ + if (decl_isImp (static_cast (currentModule))) { - (*c).name = n; + if (decl_isType (static_cast (type))) + { + return ! (isDeclInImp (type)); + } + else + { + return false; + } } else { - (*c).name = nameKey_makekey (DynamicStrings_string (s)); - s = DynamicStrings_KillString (s); + /* Always use void * in .def modules. */ + return true; } - return (*c).name; } /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -11748,189 +11429,266 @@ static nameKey_Name doCname (nameKey_Name n, decl_cnameT *c, bool scopes) /* - getDName - + isVarVoidStar - return TRUE if the variable using an opaque type should + be implemented as a (void * ). */ -static nameKey_Name getDName (decl_node n, bool scopes) +static bool isVarVoidStar (decl_node__opaque n) { - nameKey_Name m; + decl_node__opaque type; - m = decl_getSymName (n); - switch (n->kind) + mcDebug_assert (decl_isVar (static_cast (n))); + type = static_cast (decl_getType (static_cast (n))); + if ((! (decl_isType (static_cast (type)))) || (! (decl_isTypeOpaque (static_cast (type))))) { - case decl_procedure: - return doCname (m, &n->procedureF.cname, scopes); - break; - - case decl_var: - return doCname (m, &n->varF.cname, scopes); - break; - - case decl_recordfield: - return doCname (m, &n->recordfieldF.cname, scopes); - break; - - case decl_enumerationfield: - return doCname (m, &n->enumerationfieldF.cname, scopes); - break; - - - default: - break; + /* We should finish the procedure as the variable does not use an opaque. */ + return true; } - return m; - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); -} - - -/* - doDNameC - -*/ - -static void doDNameC (mcPretty_pretty p, decl_node n, bool scopes) -{ - if ((n != NULL) && ((decl_getSymName (n)) != nameKey_NulName)) + else if (decl_isExported (static_cast (n))) { - doNamesC (p, getDName (n, scopes)); + /* avoid dangling else. */ + /* Exported variables using an opaque type will always be implemented + with a (void * ). */ + return true; + } + else + { + /* avoid dangling else. */ + /* Not exported therefore static to the module (local or global non exported + variable), we check whether the opaque type was declared in the + implementation module. If it is declared in the implementation module + then we return FALSE. */ + return ! (isDeclInImp (type)); } + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); } /* - doFQDNameC - + initNodeOpaqueState - initialize the node opaque state. */ -static void doFQDNameC (mcPretty_pretty p, decl_node n, bool scopes) +static void initNodeOpaqueState (decl_node__opaque n) { - DynamicStrings_String s; - - s = getFQDstring (n, scopes); - outTextS (p, s); - s = DynamicStrings_KillString (s); -} + decl_node__opaque type; + switch (n->kind) + { + case decl_opaquecast: + break; -/* - doFQNameC - -*/ - -static void doFQNameC (mcPretty_pretty p, decl_node n) -{ - DynamicStrings_String s; + case decl_funccall: + assignNodeOpaqueCastState (n, getFunction (n)); /* This must be done when the cast direction is known. */ + break; - s = getFQstring (n); - outTextS (p, s); - s = DynamicStrings_KillString (s); -} + case decl_var: + type = static_cast (decl_getType (static_cast (n))); + if (n->varF.isParameter || n->varF.isVarParameter) + { + /* If the variable is really a parameter then it uses + the state of the parameter. */ + initNodeOpaqueCastState (n, isTypeOpaqueDefImp (type), isParamVoidStar (n)); + } + else + { + initNodeOpaqueCastState (n, isTypeOpaqueDefImp (type), isVarVoidStar (n)); + } + break; + case decl_array: + type = static_cast (decl_getType (static_cast (n))); + initNodeOpaqueCastState (n, isTypeOpaqueDefImp (type), decl_isExported (static_cast (n))); + break; -/* - doNameM2 - -*/ + case decl_varparam: + case decl_param: + mcDebug_assert ((decl_isProcedure (decl_getScope (static_cast (n)))) || (decl_isProcType (decl_getScope (static_cast (n))))); + type = static_cast (decl_getType (static_cast (n))); + initNodeOpaqueCastState (n, isTypeOpaqueDefImp (type), isParamVoidStar (n)); + break; -static void doNameM2 (mcPretty_pretty p, decl_node n) -{ - doNameC (p, n); -} + case decl_componentref: + case decl_pointerref: + case decl_pointer: + case decl_recordfield: + case decl_arrayref: + type = static_cast (decl_getType (static_cast (n))); + /* In the future this should be revisited. */ + initNodeOpaqueCastState (n, isTypeOpaqueDefImp (type), isRefVoidStar (n)); + break; + case decl_proctype: + case decl_procedure: + type = static_cast (decl_getType (static_cast (n))); /* We only consider the return type for a procedure or proctype. + The parameters and local vars are handled separately (see + above). */ + if (type == NULL) + { + /* No return type, therefore no opaque type used. */ + initNodeOpaqueCastState (n, false, false); + } + else + { + /* Init state from the return type. Is type an opaque type? + Is the opaque type declared in this module? */ + initNodeOpaqueCastState (n, isTypeOpaqueDefImp (type), isReturnVoidStar (n, type)); + } + break; -/* - doUsed - -*/ -static void doUsed (mcPretty_pretty p, bool used) -{ - if (! used) - { - mcPretty_setNeedSpace (p); - outText (p, (const char *) "__attribute__((unused))", 23); + default: + break; } -} - - -/* - doHighC - -*/ - -static void doHighC (mcPretty_pretty p, decl_node a, nameKey_Name n, bool isused) -{ - if ((decl_isArray (a)) && (decl_isUnbounded (a))) - { - /* need to display high. */ - mcPretty_print (p, (const char *) ",", 1); - mcPretty_setNeedSpace (p); - doTypeNameC (p, cardinalN); - mcPretty_setNeedSpace (p); - mcPretty_print (p, (const char *) "_", 1); - outTextN (p, n); - mcPretty_print (p, (const char *) "_high", 5); - doUsed (p, isused); + if (debugOpaque) + { + dumpOpaqueState (n); } } /* - doParamConstCast - + assignNodeOpaqueCastState - copy the opaqueCastState from src into dest. */ -static void doParamConstCast (mcPretty_pretty p, decl_node n) +static void assignNodeOpaqueCastState (decl_node__opaque dest, decl_node__opaque src) { - decl_node ptype; - - ptype = decl_getType (n); - if (((decl_isArray (ptype)) && (decl_isUnbounded (ptype))) && (lang == decl_ansiCP)) + if (nodeUsesOpaque (src)) { - outText (p, (const char *) "const", 5); - mcPretty_setNeedSpace (p); + initNodeOpaqueCastState (dest, true, getNodeOpaqueVoidStar (src)); + } + else + { + initNodeOpaqueCastState (dest, false, false); } } /* - getParameterVariable - returns the variable which shadows the parameter - named, m, in parameter block, n. + assignNodeOpaqueCastFalse - assign the voidstar field of dest to false. + It assigns the opaque field of dest to the value + of the src opaque field. */ -static decl_node getParameterVariable (decl_node n, nameKey_Name m) +static void assignNodeOpaqueCastFalse (decl_node__opaque dest, decl_node__opaque src) { - decl_node p; - - mcDebug_assert ((decl_isParam (n)) || (decl_isVarParam (n))); - if (decl_isParam (n)) + if (nodeUsesOpaque (src)) { - p = n->paramF.scope; + initNodeOpaqueCastState (dest, true, false); } else { - p = n->varparamF.scope; + initNodeOpaqueCastState (dest, false, false); } - mcDebug_assert (decl_isProcedure (p)); - return decl_lookupInScope (p, m); - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); } /* - doParamTypeEmit - emit parameter type for C/C++. It checks to see if the - parameter type is a procedure type and if it were declared - in a definition module for "C" and if so it uses the "C" - definition for a procedure type, rather than the mc - C++ version. + dumpOpaqueState - */ -static void doParamTypeEmit (mcPretty_pretty p, decl_node paramnode, decl_node paramtype) +static void dumpOpaqueState (decl_node__opaque n) { - mcDebug_assert ((decl_isParam (paramnode)) || (decl_isVarParam (paramnode))); - if ((isForC (paramnode)) && (decl_isProcType (decl_skipType (paramtype)))) + decl_node__opaque o; + + switch (n->kind) { - doFQNameC (p, paramtype); - outText (p, (const char *) "_C", 2); + case decl_opaquecast: + case decl_funccall: + case decl_var: + case decl_array: + case decl_varparam: + case decl_param: + case decl_pointer: + case decl_recordfield: + case decl_componentref: + case decl_arrayref: + case decl_procedure: + case decl_proctype: + o = n; + break; + + + default: + o = static_cast (NULL); + break; } - else + if (o != NULL) { - doTypeNameC (p, paramtype); + outText (doP, (const char *) "/* ", 3); + doNameC (doP, o); + outText (doP, (const char *) " ", 2); + switch (o->kind) + { + case decl_opaquecast: + outText (doP, (const char *) "opaquecast", 10); + break; + + case decl_funccall: + outText (doP, (const char *) "funccall", 8); + break; + + case decl_var: + outText (doP, (const char *) "var", 3); + break; + + case decl_array: + outText (doP, (const char *) "array", 5); + break; + + case decl_varparam: + outText (doP, (const char *) "varparam", 8); + break; + + case decl_param: + outText (doP, (const char *) "param", 5); + break; + + case decl_pointer: + outText (doP, (const char *) "pointer", 7); + break; + + case decl_recordfield: + outText (doP, (const char *) "recordfield", 11); + break; + + case decl_componentref: + outText (doP, (const char *) "componentref", 12); + break; + + case decl_pointerref: + outText (doP, (const char *) "pointerref", 10); + break; + + case decl_arrayref: + outText (doP, (const char *) "arrayref", 8); + break; + + case decl_procedure: + outText (doP, (const char *) "procedure", 9); + break; + + case decl_proctype: + outText (doP, (const char *) "proctype", 8); + break; + + + default: + break; + } + if (nodeUsesOpaque (o)) + { + /* avoid gcc warning by using compound statement even if not strictly necessary. */ + if (getNodeOpaqueVoidStar (o)) + { + outText (doP, (const char *) " uses (void *) opaque", 21); + } + else + { + outText (doP, (const char *) " uses opaque__full", 18); + } + } + outText (doP, (const char *) " */ \\n", 6); } } @@ -11939,24 +11697,24 @@ static void doParamTypeEmit (mcPretty_pretty p, decl_node paramnode, decl_node p doParamC - emit parameter for C/C++. */ -static void doParamC (mcPretty_pretty p, decl_node n) +static void doParamC (mcPretty_pretty p, decl_node__opaque n) { - decl_node v; - decl_node ptype; + decl_node__opaque v; + decl_node__opaque ptype; nameKey_Name i; unsigned int c; unsigned int t; wlists_wlist l; - mcDebug_assert (decl_isParam (n)); - ptype = decl_getType (n); + mcDebug_assert (decl_isParam (static_cast (n))); + ptype = static_cast (decl_getType (static_cast (n))); if (n->paramF.namelist == NULL) { /* avoid dangling else. */ doParamConstCast (p, n); doTypeNameC (p, ptype); doUsed (p, n->paramF.isUsed); - if ((decl_isArray (ptype)) && (decl_isUnbounded (ptype))) + if ((decl_isArray (static_cast (ptype))) && (decl_isUnbounded (static_cast (ptype)))) { outText (p, (const char *) ",", 1); mcPretty_setNeedSpace (p); @@ -11972,7 +11730,7 @@ static void doParamC (mcPretty_pretty p, decl_node n) /* avoid dangling else. */ doParamConstCast (p, n); doParamTypeEmit (p, n, ptype); - if ((decl_isArray (ptype)) && (decl_isUnbounded (ptype))) + if ((decl_isArray (static_cast (ptype))) && (decl_isUnbounded (static_cast (ptype)))) { doUsed (p, n->paramF.isUsed); outText (p, (const char *) ",", 1); @@ -11989,7 +11747,7 @@ static void doParamC (mcPretty_pretty p, decl_node n) doParamConstCast (p, n); doParamTypeEmit (p, n, ptype); i = static_cast (wlists_getItemFromList (l, c)); - if ((decl_isArray (ptype)) && (decl_isUnbounded (ptype))) + if ((decl_isArray (static_cast (ptype))) && (decl_isUnbounded (static_cast (ptype)))) { mcPretty_noSpace (p); } @@ -12006,10 +11764,7 @@ static void doParamC (mcPretty_pretty p, decl_node n) { doFQDNameC (p, v, true); } - if ((decl_isArray (ptype)) && (decl_isUnbounded (ptype))) - { - outText (p, (const char *) "_", 1); - } + doParamTypeNameModifier (p, ptype, false); doUsed (p, n->paramF.isUsed); doHighC (p, ptype, i, n->paramF.isUsed); if (c < t) @@ -12028,29 +11783,29 @@ static void doParamC (mcPretty_pretty p, decl_node n) doVarParamC - emit a VAR parameter for C/C++. */ -static void doVarParamC (mcPretty_pretty p, decl_node n) +static void doVarParamC (mcPretty_pretty p, decl_node__opaque n) { - decl_node v; - decl_node ptype; + decl_node__opaque v; + decl_node__opaque ptype; nameKey_Name i; unsigned int c; unsigned int t; wlists_wlist l; - mcDebug_assert (decl_isVarParam (n)); - ptype = decl_getType (n); + mcDebug_assert (decl_isVarParam (static_cast (n))); + ptype = static_cast (decl_getType (static_cast (n))); if (n->varparamF.namelist == NULL) { /* avoid dangling else. */ doTypeNameC (p, ptype); /* doTypeC (p, ptype, n) ; */ - if (! (decl_isArray (ptype))) + if (! (decl_isArray (static_cast (ptype)))) { mcPretty_setNeedSpace (p); outText (p, (const char *) "*", 1); } doUsed (p, n->varparamF.isUsed); - if ((decl_isArray (ptype)) && (decl_isUnbounded (ptype))) + if ((decl_isArray (static_cast (ptype))) && (decl_isUnbounded (static_cast (ptype)))) { outText (p, (const char *) ",", 1); mcPretty_setNeedSpace (p); @@ -12073,7 +11828,7 @@ static void doVarParamC (mcPretty_pretty p, decl_node n) while (c <= t) { doParamTypeEmit (p, n, ptype); - if (! (decl_isArray (ptype))) + if (! (decl_isArray (static_cast (ptype)))) { mcPretty_setNeedSpace (p); outText (p, (const char *) "*", 1); @@ -12088,6 +11843,7 @@ static void doVarParamC (mcPretty_pretty p, decl_node n) { doFQDNameC (p, v, true); } + doParamTypeNameModifier (p, ptype, true); doUsed (p, n->varparamF.isUsed); doHighC (p, ptype, i, n->varparamF.isUsed); if (c < t) @@ -12106,15 +11862,15 @@ static void doVarParamC (mcPretty_pretty p, decl_node n) doOptargC - */ -static void doOptargC (mcPretty_pretty p, decl_node n) +static void doOptargC (mcPretty_pretty p, decl_node__opaque n) { - decl_node ptype; + decl_node__opaque ptype; nameKey_Name i; unsigned int t; wlists_wlist l; - mcDebug_assert (decl_isOptarg (n)); - ptype = decl_getType (n); + mcDebug_assert (decl_isOptarg (static_cast (n))); + ptype = static_cast (decl_getType (static_cast (n))); mcDebug_assert (n->optargF.namelist != NULL); mcDebug_assert (isIdentList (n->paramF.namelist)); l = n->paramF.namelist->identlistF.names; @@ -12132,23 +11888,23 @@ static void doOptargC (mcPretty_pretty p, decl_node n) doParameterC - */ -static void doParameterC (mcPretty_pretty p, decl_node n) +static void doParameterC (mcPretty_pretty p, decl_node__opaque n) { - if (decl_isParam (n)) + if (decl_isParam (static_cast (n))) { doParamC (p, n); } - else if (decl_isVarParam (n)) + else if (decl_isVarParam (static_cast (n))) { /* avoid dangling else. */ doVarParamC (p, n); } - else if (decl_isVarargs (n)) + else if (decl_isVarargs (static_cast (n))) { /* avoid dangling else. */ mcPretty_print (p, (const char *) "...", 3); } - else if (decl_isOptarg (n)) + else if (decl_isOptarg (static_cast (n))) { /* avoid dangling else. */ doOptargC (p, n); @@ -12160,11 +11916,65 @@ static void doParameterC (mcPretty_pretty p, decl_node n) doProcTypeC - */ -static void doProcTypeC (mcPretty_pretty p, decl_node t, decl_node n) +static void doProcTypeC (mcPretty_pretty p, decl_node__opaque t, decl_node__opaque n) +{ + mcDebug_assert (decl_isType (static_cast (t))); + if ((isDeclType (t)) && (isDeclType (n))) + { + outputPartial (t); + doCompletePartialProcType (p, t, n); + } +} + + +/* + isDeclInImp - returns TRUE if node type is declared as an opaque and + is declared fully in the current implementation module. + This should only be called if isType (type). Its purpose + is specific to a type checking whether it is an opaque type + declared in the .def/.mod pair of the current imp module. +*/ + +static bool isDeclInImp (decl_node__opaque type) +{ + decl_node__opaque scope; + decl_node__opaque def; + nameKey_Name name; + + mcDebug_assert (decl_isType (static_cast (type))); + scope = static_cast (decl_getScope (static_cast (type))); + if ((isTypeOpaqueDefImp (type)) && (decl_isImp (static_cast (currentModule)))) + { + name = decl_getSymName (static_cast (type)); + if (name != nameKey_NulName) + { + /* Lookup the matching .def module. */ + def = static_cast (decl_lookupDef (decl_getSymName (static_cast (currentModule)))); + if ((def != NULL) && ((def == scope) || (currentModule == scope))) + { + /* Return TRUE if the symbol has already been declared in the .def. */ + return (decl_lookupExported (static_cast (def), name)) != NULL; + } + } + } + return false; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} + + +/* + doTypeNameModifier - adds the __opaque modifier to the type n provided + it is an opaque type which is being declared in the + implementation module. +*/ + +static void doTypeNameModifier (mcPretty_pretty p, decl_node__opaque n) { - mcDebug_assert (decl_isType (t)); - outputPartial (t); - doCompletePartialProcType (p, t, n); + if ((isTypeOpaqueDefImp (n)) && (decl_isImp (static_cast (currentModule)))) + { + outText (p, (const char *) "__opaque", 8); + } } @@ -12172,39 +11982,43 @@ static void doProcTypeC (mcPretty_pretty p, decl_node t, decl_node n) doTypesC - */ -static void doTypesC (decl_node n) +static void doTypesC (decl_node__opaque n) { - decl_node m; + decl_node__opaque m; - if (decl_isType (n)) + if (decl_isType (static_cast (n))) { - m = decl_getType (n); - if (decl_isProcType (m)) + m = static_cast (decl_getType (static_cast (n))); + if (decl_isProcType (static_cast (m))) { doProcTypeC (doP, n, m); } - else if ((decl_isType (m)) || (decl_isPointer (m))) + else if ((decl_isType (static_cast (m))) || (decl_isPointer (static_cast (m)))) { /* avoid dangling else. */ outText (doP, (const char *) "typedef", 7); mcPretty_setNeedSpace (doP); doTypeC (doP, m, &m); - if (decl_isType (m)) + if (decl_isType (static_cast (m))) { mcPretty_setNeedSpace (doP); } doTypeNameC (doP, n); + doTypeNameModifier (doP, n); outText (doP, (const char *) ";\\n\\n", 5); } - else if (decl_isEnumeration (m)) + else if (decl_isEnumeration (static_cast (m))) { /* avoid dangling else. */ - outText (doP, (const char *) "typedef", 7); - mcPretty_setNeedSpace (doP); - doTypeC (doP, m, &m); - mcPretty_setNeedSpace (doP); - doTypeNameC (doP, n); - outText (doP, (const char *) ";\\n\\n", 5); + if (isDeclType (n)) + { + outText (doP, (const char *) "typedef", 7); + mcPretty_setNeedSpace (doP); + doTypeC (doP, m, &m); + mcPretty_setNeedSpace (doP); + doTypeNameC (doP, n); + outText (doP, (const char *) ";\\n\\n", 5); + } } else { @@ -12212,11 +12026,12 @@ static void doTypesC (decl_node n) outText (doP, (const char *) "typedef", 7); mcPretty_setNeedSpace (doP); doTypeC (doP, m, &m); - if (decl_isType (m)) + if (decl_isType (static_cast (m))) { mcPretty_setNeedSpace (doP); } doTypeNameC (doP, n); + doTypeNameModifier (doP, n); outText (doP, (const char *) ";\\n\\n", 5); } } @@ -12227,23 +12042,23 @@ static void doTypesC (decl_node n) doCompletePartialC - */ -static void doCompletePartialC (decl_node n) +static void doCompletePartialC (decl_node__opaque n) { - decl_node m; + decl_node__opaque m; - if (decl_isType (n)) + if (decl_isType (static_cast (n))) { - m = decl_getType (n); - if (decl_isRecord (m)) + m = static_cast (decl_getType (static_cast (n))); + if (decl_isRecord (static_cast (m))) { doCompletePartialRecord (doP, n, m); } - else if (decl_isArray (m)) + else if (decl_isArray (static_cast (m))) { /* avoid dangling else. */ doCompletePartialArray (doP, n, m); } - else if (decl_isProcType (m)) + else if (decl_isProcType (static_cast (m))) { /* avoid dangling else. */ doCompletePartialProcType (doP, n, m); @@ -12256,14 +12071,14 @@ static void doCompletePartialC (decl_node n) doCompletePartialRecord - */ -static void doCompletePartialRecord (mcPretty_pretty p, decl_node t, decl_node r) +static void doCompletePartialRecord (mcPretty_pretty p, decl_node__opaque t, decl_node__opaque r) { unsigned int i; unsigned int h; - decl_node f; + decl_node__opaque f; - mcDebug_assert (decl_isRecord (r)); - mcDebug_assert (decl_isType (t)); + mcDebug_assert (decl_isRecord (static_cast (r))); + mcDebug_assert (decl_isType (static_cast (t))); outText (p, (const char *) "struct", 6); mcPretty_setNeedSpace (p); doFQNameC (p, t); @@ -12274,24 +12089,23 @@ static void doCompletePartialRecord (mcPretty_pretty p, decl_node t, decl_node r h = Indexing_HighIndice (r->recordF.listOfSons); while (i <= h) { - f = static_cast (Indexing_GetIndice (r->recordF.listOfSons, i)); - if (decl_isRecordField (f)) + f = static_cast (Indexing_GetIndice (r->recordF.listOfSons, i)); + if (decl_isRecordField (static_cast (f))) { /* avoid dangling else. */ if (! f->recordfieldF.tag) { - mcPretty_setNeedSpace (p); doRecordFieldC (p, f); outText (p, (const char *) ";\\n", 3); } } - else if (decl_isVarient (f)) + else if (decl_isVarient (static_cast (f))) { /* avoid dangling else. */ doVarientC (p, f); outText (p, (const char *) ";\\n", 3); } - else if (decl_isVarientField (f)) + else if (decl_isVarientField (static_cast (f))) { /* avoid dangling else. */ doVarientFieldC (p, f); @@ -12306,14 +12120,14 @@ static void doCompletePartialRecord (mcPretty_pretty p, decl_node t, decl_node r doCompletePartialArray - */ -static void doCompletePartialArray (mcPretty_pretty p, decl_node t, decl_node r) +static void doCompletePartialArray (mcPretty_pretty p, decl_node__opaque t, decl_node__opaque r) { - decl_node type; - decl_node s; + decl_node__opaque type; + decl_node__opaque s; - mcDebug_assert (decl_isArray (r)); + mcDebug_assert (decl_isArray (static_cast (r))); type = r->arrayF.type; - s = NULL; + s = static_cast (NULL); outText (p, (const char *) "struct", 6); mcPretty_setNeedSpace (p); doFQNameC (p, t); @@ -12333,9 +12147,9 @@ static void doCompletePartialArray (mcPretty_pretty p, decl_node t, decl_node r) lookupConst - */ -static decl_node lookupConst (decl_node type, nameKey_Name n) +static decl_node__opaque lookupConst (decl_node__opaque type, nameKey_Name n) { - return decl_makeLiteralInt (n); + return static_cast (decl_makeLiteralInt (n)); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -12345,7 +12159,7 @@ static decl_node lookupConst (decl_node type, nameKey_Name n) doMin - */ -static decl_node doMin (decl_node n) +static decl_node__opaque doMin (decl_node__opaque n) { if (n == booleanN) { @@ -12384,7 +12198,7 @@ static decl_node doMin (decl_node n) else if (n == bitsetN) { /* avoid dangling else. */ - mcDebug_assert (decl_isSubrange (bitnumN)); + mcDebug_assert (decl_isSubrange (static_cast (bitnumN))); return bitnumN->subrangeF.low; } else if (n == locN) @@ -12425,7 +12239,7 @@ static decl_node doMin (decl_node n) doMax - */ -static decl_node doMax (decl_node n) +static decl_node__opaque doMax (decl_node__opaque n) { if (n == booleanN) { @@ -12464,7 +12278,7 @@ static decl_node doMax (decl_node n) else if (n == bitsetN) { /* avoid dangling else. */ - mcDebug_assert (decl_isSubrange (bitnumN)); + mcDebug_assert (decl_isSubrange (static_cast (bitnumN))); return bitnumN->subrangeF.high; } else if (n == locN) @@ -12489,7 +12303,7 @@ static decl_node doMax (decl_node n) { /* avoid dangling else. */ mcMetaError_metaError1 ((const char *) "trying to obtain MAX ({%1ad}) is illegal", 40, (const unsigned char *) &n, (sizeof (n)-1)); - return NULL; + return static_cast (NULL); } else { @@ -12506,14 +12320,14 @@ static decl_node doMax (decl_node n) getMax - */ -static decl_node getMax (decl_node n) +static decl_node__opaque getMax (decl_node__opaque n) { - n = decl_skipType (n); - if (decl_isSubrange (n)) + n = static_cast (decl_skipType (static_cast (n))); + if (decl_isSubrange (static_cast (n))) { return n->subrangeF.high; } - else if (decl_isEnumeration (n)) + else if (decl_isEnumeration (static_cast (n))) { /* avoid dangling else. */ return n->enumerationF.high; @@ -12533,14 +12347,14 @@ static decl_node getMax (decl_node n) getMin - */ -static decl_node getMin (decl_node n) +static decl_node__opaque getMin (decl_node__opaque n) { - n = decl_skipType (n); - if (decl_isSubrange (n)) + n = static_cast (decl_skipType (static_cast (n))); + if (decl_isSubrange (static_cast (n))) { return n->subrangeF.low; } - else if (decl_isEnumeration (n)) + else if (decl_isEnumeration (static_cast (n))) { /* avoid dangling else. */ return n->enumerationF.low; @@ -12560,7 +12374,7 @@ static decl_node getMin (decl_node n) doSubtractC - */ -static void doSubtractC (mcPretty_pretty p, decl_node s) +static void doSubtractC (mcPretty_pretty p, decl_node__opaque s) { if (! (isZero (s))) { @@ -12574,12 +12388,12 @@ static void doSubtractC (mcPretty_pretty p, decl_node s) doSubrC - */ -static void doSubrC (mcPretty_pretty p, decl_node s) +static void doSubrC (mcPretty_pretty p, decl_node__opaque s) { - decl_node low; - decl_node high; + decl_node__opaque low; + decl_node__opaque high; - s = decl_skipType (s); + s = static_cast (decl_skipType (static_cast (s))); if (isOrdinal (s)) { low = getMin (s); @@ -12588,7 +12402,7 @@ static void doSubrC (mcPretty_pretty p, decl_node s) doSubtractC (p, low); outText (p, (const char *) "+1", 2); } - else if (decl_isEnumeration (s)) + else if (decl_isEnumeration (static_cast (s))) { /* avoid dangling else. */ low = getMin (s); @@ -12600,10 +12414,10 @@ static void doSubrC (mcPretty_pretty p, decl_node s) else { /* avoid dangling else. */ - mcDebug_assert (decl_isSubrange (s)); + mcDebug_assert (decl_isSubrange (static_cast (s))); if ((s->subrangeF.high == NULL) || (s->subrangeF.low == NULL)) { - doSubrC (p, decl_getType (s)); + doSubrC (p, static_cast (decl_getType (static_cast (s)))); } else { @@ -12619,18 +12433,32 @@ static void doSubrC (mcPretty_pretty p, decl_node s) doCompletePartialProcType - */ -static void doCompletePartialProcType (mcPretty_pretty p, decl_node t, decl_node n) +static void doCompletePartialProcType (mcPretty_pretty p, decl_node__opaque t, decl_node__opaque n) +{ + if ((isDeclType (t)) && (isDeclType (n))) + { + outputCompletePartialProcType (p, t, n); + } +} + + +/* + outputCompletePartialProcType - +*/ + +static void outputCompletePartialProcType (mcPretty_pretty p, decl_node__opaque t, decl_node__opaque n) { unsigned int i; unsigned int h; - decl_node v; - decl_node u; + decl_node__opaque v; + decl_node__opaque u; - mcDebug_assert (decl_isProcType (n)); - u = NULL; + mcDebug_assert (decl_isProcType (static_cast (n))); + u = static_cast (NULL); outText (p, (const char *) "typedef", 7); mcPretty_setNeedSpace (p); doTypeC (p, n->proctypeF.returnType, &u); + doOpaqueModifier (p, n); mcPretty_setNeedSpace (p); outText (p, (const char *) "(*", 2); doFQNameC (p, t); @@ -12639,7 +12467,7 @@ static void doCompletePartialProcType (mcPretty_pretty p, decl_node t, decl_node h = Indexing_HighIndice (n->proctypeF.parameters); while (i <= h) { - v = static_cast (Indexing_GetIndice (n->proctypeF.parameters, i)); + v = static_cast (Indexing_GetIndice (n->proctypeF.parameters, i)); doParameterC (p, v); mcPretty_noSpace (p); if (i < h) @@ -12679,7 +12507,7 @@ static void doCompletePartialProcType (mcPretty_pretty p, decl_node t, decl_node isBase - */ -static bool isBase (decl_node n) +static bool isBase (decl_node__opaque n) { switch (n->kind) { @@ -12733,7 +12561,7 @@ static void doBoolC (mcPretty_pretty p) doBaseC - */ -static void doBaseC (mcPretty_pretty p, decl_node n) +static void doBaseC (mcPretty_pretty p, decl_node__opaque n) { switch (n->kind) { @@ -12814,7 +12642,7 @@ static void doBaseC (mcPretty_pretty p, decl_node n) isSystem - */ -static bool isSystem (decl_node n) +static bool isSystem (decl_node__opaque n) { switch (n->kind) { @@ -12856,7 +12684,7 @@ static bool isSystem (decl_node n) doSystemC - */ -static void doSystemC (mcPretty_pretty p, decl_node n) +static void doSystemC (mcPretty_pretty p, decl_node__opaque n) { switch (n->kind) { @@ -12903,16 +12731,16 @@ static void doSystemC (mcPretty_pretty p, decl_node n) doArrayC - */ -static void doArrayC (mcPretty_pretty p, decl_node n) +static void doArrayC (mcPretty_pretty p, decl_node__opaque n) { - decl_node t; - decl_node s; - decl_node u; + decl_node__opaque t; + decl_node__opaque s; + decl_node__opaque u; - mcDebug_assert (decl_isArray (n)); + mcDebug_assert (decl_isArray (static_cast (n))); t = n->arrayF.type; s = n->arrayF.subr; - u = NULL; + u = static_cast (NULL); if (s == NULL) { doTypeC (p, t, &u); @@ -12949,13 +12777,13 @@ static void doArrayC (mcPretty_pretty p, decl_node n) doPointerC - */ -static void doPointerC (mcPretty_pretty p, decl_node n, decl_node *m) +static void doPointerC (mcPretty_pretty p, decl_node__opaque n, decl_node__opaque *m) { - decl_node t; - decl_node s; + decl_node__opaque t; + decl_node__opaque s; t = n->pointerF.type; - s = NULL; + s = static_cast (NULL); doTypeC (p, t, &s); mcPretty_setNeedSpace (p); outText (p, (const char *) "*", 1); @@ -12966,13 +12794,18 @@ static void doPointerC (mcPretty_pretty p, decl_node n, decl_node *m) doRecordFieldC - */ -static void doRecordFieldC (mcPretty_pretty p, decl_node f) +static void doRecordFieldC (mcPretty_pretty p, decl_node__opaque f) { - decl_node m; + decl_node__opaque m; - m = NULL; + m = static_cast (NULL); mcPretty_setNeedSpace (p); doTypeC (p, f->recordfieldF.type, &m); + if ((decl_isType (static_cast (f->recordfieldF.type))) && (isDeclInImp (f->recordfieldF.type))) + { + outText (p, (const char *) "__opaque", 8); + } + mcPretty_setNeedSpace (p); doDNameC (p, f, false); } @@ -12981,13 +12814,13 @@ static void doRecordFieldC (mcPretty_pretty p, decl_node f) doVarientFieldC - */ -static void doVarientFieldC (mcPretty_pretty p, decl_node n) +static void doVarientFieldC (mcPretty_pretty p, decl_node__opaque n) { unsigned int i; unsigned int t; - decl_node q; + decl_node__opaque q; - mcDebug_assert (decl_isVarientField (n)); + mcDebug_assert (decl_isVarientField (static_cast (n))); if (! n->varientfieldF.simple) { outText (p, (const char *) "struct", 6); @@ -12998,8 +12831,8 @@ static void doVarientFieldC (mcPretty_pretty p, decl_node n) t = Indexing_HighIndice (n->varientfieldF.listOfSons); while (i <= t) { - q = static_cast (Indexing_GetIndice (n->varientfieldF.listOfSons, i)); - if (decl_isRecordField (q)) + q = static_cast (Indexing_GetIndice (n->varientfieldF.listOfSons, i)); + if (decl_isRecordField (static_cast (q))) { /* avoid dangling else. */ if (! q->recordfieldF.tag) @@ -13008,7 +12841,7 @@ static void doVarientFieldC (mcPretty_pretty p, decl_node n) outText (p, (const char *) ";\\n", 3); } } - else if (decl_isVarient (q)) + else if (decl_isVarient (static_cast (q))) { /* avoid dangling else. */ doVarientC (p, q); @@ -13033,22 +12866,22 @@ static void doVarientFieldC (mcPretty_pretty p, decl_node n) doVarientC - */ -static void doVarientC (mcPretty_pretty p, decl_node n) +static void doVarientC (mcPretty_pretty p, decl_node__opaque n) { unsigned int i; unsigned int t; - decl_node q; + decl_node__opaque q; - mcDebug_assert (decl_isVarient (n)); + mcDebug_assert (decl_isVarient (static_cast (n))); if (n->varientF.tag != NULL) { /* avoid gcc warning by using compound statement even if not strictly necessary. */ - if (decl_isRecordField (n->varientF.tag)) + if (decl_isRecordField (static_cast (n->varientF.tag))) { doRecordFieldC (p, n->varientF.tag); outText (p, (const char *) "; /* case tag */\\n", 19); } - else if (decl_isVarientField (n->varientF.tag)) + else if (decl_isVarientField (static_cast (n->varientF.tag))) { /* avoid dangling else. */ /* doVarientFieldC (p, n^.varientF.tag) */ @@ -13069,8 +12902,8 @@ static void doVarientC (mcPretty_pretty p, decl_node n) t = Indexing_HighIndice (n->varientF.listOfSons); while (i <= t) { - q = static_cast (Indexing_GetIndice (n->varientF.listOfSons, i)); - if (decl_isRecordField (q)) + q = static_cast (Indexing_GetIndice (n->varientF.listOfSons, i)); + if (decl_isRecordField (static_cast (q))) { /* avoid dangling else. */ if (! q->recordfieldF.tag) @@ -13079,7 +12912,7 @@ static void doVarientC (mcPretty_pretty p, decl_node n) outText (p, (const char *) ";\\n", 3); } } - else if (decl_isVarientField (q)) + else if (decl_isVarientField (static_cast (q))) { /* avoid dangling else. */ doVarientFieldC (p, q); @@ -13100,13 +12933,13 @@ static void doVarientC (mcPretty_pretty p, decl_node n) doRecordC - */ -static void doRecordC (mcPretty_pretty p, decl_node n, decl_node *m) +static void doRecordC (mcPretty_pretty p, decl_node__opaque n, decl_node__opaque *m) { unsigned int i; unsigned int h; - decl_node f; + decl_node__opaque f; - mcDebug_assert (decl_isRecord (n)); + mcDebug_assert (decl_isRecord (static_cast (n))); outText (p, (const char *) "struct", 6); mcPretty_setNeedSpace (p); p = outKc (p, (const char *) "{", 1); @@ -13116,8 +12949,8 @@ static void doRecordC (mcPretty_pretty p, decl_node n, decl_node *m) outText (p, (const char *) "\\n", 2); while (i <= h) { - f = static_cast (Indexing_GetIndice (n->recordF.listOfSons, i)); - if (decl_isRecordField (f)) + f = static_cast (Indexing_GetIndice (n->recordF.listOfSons, i)); + if (decl_isRecordField (static_cast (f))) { /* avoid dangling else. */ if (! f->recordfieldF.tag) @@ -13126,13 +12959,13 @@ static void doRecordC (mcPretty_pretty p, decl_node n, decl_node *m) outText (p, (const char *) ";\\n", 3); } } - else if (decl_isVarient (f)) + else if (decl_isVarient (static_cast (f))) { /* avoid dangling else. */ doVarientC (p, f); outText (p, (const char *) ";\\n", 3); } - else if (decl_isVarientField (f)) + else if (decl_isVarientField (static_cast (f))) { /* avoid dangling else. */ doVarientFieldC (p, f); @@ -13148,7 +12981,7 @@ static void doRecordC (mcPretty_pretty p, decl_node n, decl_node *m) isBitset - */ -static bool isBitset (decl_node n) +static bool isBitset (decl_node__opaque n) { return n == bitsetN; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -13160,7 +12993,7 @@ static bool isBitset (decl_node n) isNegative - returns TRUE if expression, n, is negative. */ -static bool isNegative (decl_node n) +static bool isNegative (decl_node__opaque n) { /* --fixme-- needs to be completed. */ return false; @@ -13173,9 +13006,9 @@ static bool isNegative (decl_node n) doSubrangeC - */ -static void doSubrangeC (mcPretty_pretty p, decl_node n) +static void doSubrangeC (mcPretty_pretty p, decl_node__opaque n) { - mcDebug_assert (decl_isSubrange (n)); + mcDebug_assert (decl_isSubrange (static_cast (n))); if (isNegative (n->subrangeF.low)) { outText (p, (const char *) "int", 3); @@ -13194,9 +13027,9 @@ static void doSubrangeC (mcPretty_pretty p, decl_node n) Currently we only support sets of size WORD. */ -static void doSetC (mcPretty_pretty p, decl_node n) +static void doSetC (mcPretty_pretty p, decl_node__opaque n) { - mcDebug_assert (decl_isSet (n)); + mcDebug_assert (decl_isSet (static_cast (n))); outText (p, (const char *) "unsigned int", 12); mcPretty_setNeedSpace (p); } @@ -13206,7 +13039,7 @@ static void doSetC (mcPretty_pretty p, decl_node n) doTypeC - */ -static void doTypeC (mcPretty_pretty p, decl_node n, decl_node *m) +static void doTypeC (mcPretty_pretty p, decl_node__opaque n, decl_node__opaque *m) { if (n == NULL) { @@ -13222,48 +13055,42 @@ static void doTypeC (mcPretty_pretty p, decl_node n, decl_node *m) /* avoid dangling else. */ doSystemC (p, n); } - else if (decl_isEnumeration (n)) + else if (decl_isEnumeration (static_cast (n))) { /* avoid dangling else. */ doEnumerationC (p, n); } - else if (decl_isType (n)) + else if (decl_isType (static_cast (n))) { /* avoid dangling else. */ doFQNameC (p, n); - /* - ELSIF isProcType (n) OR isArray (n) OR isRecord (n) - THEN - HALT n should have been simplified. - */ - mcPretty_setNeedSpace (p); } - else if (decl_isProcType (n)) + else if (decl_isProcType (static_cast (n))) { /* avoid dangling else. */ doProcTypeC (p, n, (*m)); } - else if (decl_isArray (n)) + else if (decl_isArray (static_cast (n))) { /* avoid dangling else. */ doArrayC (p, n); } - else if (decl_isRecord (n)) + else if (decl_isRecord (static_cast (n))) { /* avoid dangling else. */ doRecordC (p, n, m); } - else if (decl_isPointer (n)) + else if (decl_isPointer (static_cast (n))) { /* avoid dangling else. */ doPointerC (p, n, m); } - else if (decl_isSubrange (n)) + else if (decl_isSubrange (static_cast (n))) { /* avoid dangling else. */ doSubrangeC (p, n); } - else if (decl_isSet (n)) + else if (decl_isSet (static_cast (n))) { /* avoid dangling else. */ doSetC (p, n); @@ -13285,9 +13112,9 @@ static void doTypeC (mcPretty_pretty p, decl_node n, decl_node *m) doArrayNameC - it displays the array declaration (it might be an unbounded). */ -static void doArrayNameC (mcPretty_pretty p, decl_node n) +static void doArrayNameC (mcPretty_pretty p, decl_node__opaque n) { - doTypeNameC (p, decl_getType (n)); + doTypeNameC (p, static_cast (decl_getType (static_cast (n)))); mcPretty_setNeedSpace (p); outText (p, (const char *) "*", 1); } @@ -13297,7 +13124,7 @@ static void doArrayNameC (mcPretty_pretty p, decl_node n) doRecordNameC - emit the C/C++ record name "_r". */ -static void doRecordNameC (mcPretty_pretty p, decl_node n) +static void doRecordNameC (mcPretty_pretty p, decl_node__opaque n) { DynamicStrings_String s; @@ -13312,9 +13139,9 @@ static void doRecordNameC (mcPretty_pretty p, decl_node n) doPointerNameC - emit the C/C++ pointer type *. */ -static void doPointerNameC (mcPretty_pretty p, decl_node n) +static void doPointerNameC (mcPretty_pretty p, decl_node__opaque n) { - doTypeNameC (p, decl_getType (n)); + doTypeNameC (p, static_cast (decl_getType (static_cast (n)))); mcPretty_setNeedSpace (p); outText (p, (const char *) "*", 1); } @@ -13324,7 +13151,7 @@ static void doPointerNameC (mcPretty_pretty p, decl_node n) doTypeNameC - */ -static void doTypeNameC (mcPretty_pretty p, decl_node n) +static void doTypeNameC (mcPretty_pretty p, decl_node__opaque n) { DynamicStrings_String t; @@ -13343,38 +13170,38 @@ static void doTypeNameC (mcPretty_pretty p, decl_node n) /* avoid dangling else. */ doSystemC (p, n); } - else if (decl_isEnumeration (n)) + else if (decl_isEnumeration (static_cast (n))) { /* avoid dangling else. */ mcPretty_print (p, (const char *) "is enumeration type name required\\n", 35); } - else if (decl_isType (n)) + else if (decl_isType (static_cast (n))) { /* avoid dangling else. */ doFQNameC (p, n); } - else if (decl_isProcType (n)) + else if (decl_isProcType (static_cast (n))) { /* avoid dangling else. */ doFQNameC (p, n); outText (p, (const char *) "_t", 2); } - else if (decl_isArray (n)) + else if (decl_isArray (static_cast (n))) { /* avoid dangling else. */ doArrayNameC (p, n); } - else if (decl_isRecord (n)) + else if (decl_isRecord (static_cast (n))) { /* avoid dangling else. */ doRecordNameC (p, n); } - else if (decl_isPointer (n)) + else if (decl_isPointer (static_cast (n))) { /* avoid dangling else. */ doPointerNameC (p, n); } - else if (decl_isSubrange (n)) + else if (decl_isSubrange (static_cast (n))) { /* avoid dangling else. */ doSubrangeC (p, n); @@ -13383,7 +13210,6 @@ static void doTypeNameC (mcPretty_pretty p, decl_node n) { /* avoid dangling else. */ mcPretty_print (p, (const char *) "is type unknown required\\n", 26); - stop (); } } @@ -13392,51 +13218,91 @@ static void doTypeNameC (mcPretty_pretty p, decl_node n) isExternal - returns TRUE if symbol, n, was declared in another module. */ -static bool isExternal (decl_node n) +static bool isExternal (decl_node__opaque n) { - decl_node s; + decl_node__opaque s; - s = decl_getScope (n); - return ((s != NULL) && (decl_isDef (s))) && (((decl_isImp (decl_getMainModule ())) && (s != (decl_lookupDef (decl_getSymName (decl_getMainModule ()))))) || (decl_isModule (decl_getMainModule ()))); + s = static_cast (decl_getScope (static_cast (n))); + return ((s != NULL) && (decl_isDef (static_cast (s)))) && (((decl_isImp (decl_getMainModule ())) && (s != (decl_lookupDef (decl_getSymName (decl_getMainModule ()))))) || (decl_isModule (decl_getMainModule ()))); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - doVarC - + doOpaqueModifier - adds postfix __opaque providing n uses an opaque type which is + not represented by ( void * ). n is a non type node which might + be using an opaque type. For example a var or param node. +*/ + +static void doOpaqueModifier (mcPretty_pretty p, decl_node__opaque n) +{ + mcDebug_assert (! (decl_isType (static_cast (n)))); + if (((decl_isImp (decl_getCurrentModule ())) && (nodeUsesOpaque (n))) && (! (getNodeOpaqueVoidStar (n)))) + { + outText (doP, (const char *) "__opaque", 8); + } +} + + +/* + doDeclareVarC - */ -static void doVarC (decl_node n) +static void doDeclareVarC (decl_node__opaque n) { - decl_node s; + decl_node__opaque type; + decl_node__opaque s; + + s = static_cast (NULL); + type = static_cast (decl_getType (static_cast (n))); + doTypeC (doP, type, &s); + doOpaqueModifier (doP, n); + mcPretty_setNeedSpace (doP); + doFQDNameC (doP, n, false); + mcPretty_print (doP, (const char *) ";\\n", 3); +} + +/* + doVarC - output a variable declaration. Note that we do not generate + a declaration if we are translating the implementation module + and a variable is exported as the variable will be in the .h + file to avoid all -Wodr issues. +*/ + +static void doVarC (decl_node__opaque n) +{ if (decl_isDef (decl_getMainModule ())) { mcPretty_print (doP, (const char *) "EXTERN", 6); mcPretty_setNeedSpace (doP); + doDeclareVarC (n); } - else if ((! (decl_isExported (n))) && (! (isLocal (n)))) + else if ((! (decl_isExported (static_cast (n)))) && (! (isLocal (n)))) { /* avoid dangling else. */ mcPretty_print (doP, (const char *) "static", 6); mcPretty_setNeedSpace (doP); + doDeclareVarC (n); } else if (mcOptions_getExtendedOpaque ()) { /* avoid dangling else. */ + /* --fixme-- need to revisit extended opaque. */ if (isExternal (n)) { /* different module declared this variable, therefore it is extern. */ mcPretty_print (doP, (const char *) "extern", 6); mcPretty_setNeedSpace (doP); } + doDeclareVarC (n); + } + else if (isLocal (n)) + { + /* avoid dangling else. */ + doDeclareVarC (n); } - s = NULL; - doTypeC (doP, decl_getType (n), &s); - mcPretty_setNeedSpace (doP); - doFQDNameC (doP, n, false); - mcPretty_print (doP, (const char *) ";\\n", 3); } @@ -13489,14 +13355,21 @@ static void doProcedureComment (mcPretty_pretty p, DynamicStrings_String s) doProcedureHeadingC - */ -static void doProcedureHeadingC (decl_node n, bool prototype) +static void doProcedureHeadingC (decl_node__opaque n, bool prototype) { + DynamicStrings_String s; unsigned int i; unsigned int h; - decl_node p; - decl_node q; + decl_node__opaque p; + decl_node__opaque q; - mcDebug_assert (decl_isProcedure (n)); + mcDebug_assert (decl_isProcedure (static_cast (n))); + s = getFQstring (n); + if (DynamicStrings_EqualArray (s, (const char *) "M2Quads_BuildAssignment", 23)) + { + localstop (); + } + s = DynamicStrings_KillString (s); mcPretty_noSpace (doP); if (decl_isDef (decl_getMainModule ())) { @@ -13504,7 +13377,7 @@ static void doProcedureHeadingC (decl_node n, bool prototype) outText (doP, (const char *) "EXTERN", 6); mcPretty_setNeedSpace (doP); } - else if (decl_isExported (n)) + else if (decl_isExported (static_cast (n))) { /* avoid dangling else. */ doProcedureComment (doP, mcComment_getContent (n->procedureF.modComment)); @@ -13517,8 +13390,15 @@ static void doProcedureHeadingC (decl_node n, bool prototype) outText (doP, (const char *) "static", 6); mcPretty_setNeedSpace (doP); } - q = NULL; + q = static_cast (NULL); doTypeC (doP, n->procedureF.returnType, &q); + /* + IF NOT isExported (n) + THEN + doTypeNameModifier (doP, n^.procedureF.returnType) + END ; + */ + doOpaqueModifier (doP, n); mcPretty_setNeedSpace (doP); doFQDNameC (doP, n, false); mcPretty_setNeedSpace (doP); @@ -13527,7 +13407,7 @@ static void doProcedureHeadingC (decl_node n, bool prototype) h = Indexing_HighIndice (n->procedureF.parameters); while (i <= h) { - p = static_cast (Indexing_GetIndice (n->procedureF.parameters, i)); + p = static_cast (Indexing_GetIndice (n->procedureF.parameters, i)); doParameterC (doP, p); mcPretty_noSpace (doP); if (i < h) @@ -13554,20 +13434,20 @@ static void doProcedureHeadingC (decl_node n, bool prototype) checkDeclareUnboundedParamCopyC - */ -static bool checkDeclareUnboundedParamCopyC (mcPretty_pretty p, decl_node n) +static bool checkDeclareUnboundedParamCopyC (mcPretty_pretty p, decl_node__opaque n) { - decl_node t; + decl_node__opaque t; unsigned int i; unsigned int c; wlists_wlist l; bool seen; seen = false; - t = decl_getType (n); + t = static_cast (decl_getType (static_cast (n))); l = n->paramF.namelist->identlistF.names; - if (((decl_isArray (t)) && (decl_isUnbounded (t))) && (l != NULL)) + if (((decl_isArray (static_cast (t))) && (decl_isUnbounded (static_cast (t)))) && (l != NULL)) { - t = decl_getType (t); + t = static_cast (decl_getType (static_cast (t))); c = wlists_noOfItemsInList (l); i = 1; while (i <= c) @@ -13592,22 +13472,22 @@ static bool checkDeclareUnboundedParamCopyC (mcPretty_pretty p, decl_node n) checkUnboundedParamCopyC - */ -static void checkUnboundedParamCopyC (mcPretty_pretty p, decl_node n) +static void checkUnboundedParamCopyC (mcPretty_pretty p, decl_node__opaque n) { - decl_node t; - decl_node s; + decl_node__opaque t; + decl_node__opaque s; unsigned int i; unsigned int c; wlists_wlist l; - t = decl_getType (n); + t = static_cast (decl_getType (static_cast (n))); l = n->paramF.namelist->identlistF.names; - if (((decl_isArray (t)) && (decl_isUnbounded (t))) && (l != NULL)) + if (((decl_isArray (static_cast (t))) && (decl_isUnbounded (static_cast (t)))) && (l != NULL)) { c = wlists_noOfItemsInList (l); i = 1; - t = decl_getType (t); - s = decl_skipType (t); + t = static_cast (decl_getType (static_cast (t))); + s = static_cast (decl_skipType (static_cast (t))); while (i <= c) { keyc_useMemcpy (); @@ -13642,21 +13522,21 @@ static void checkUnboundedParamCopyC (mcPretty_pretty p, decl_node n) doUnboundedParamCopyC - */ -static void doUnboundedParamCopyC (mcPretty_pretty p, decl_node n) +static void doUnboundedParamCopyC (mcPretty_pretty p, decl_node__opaque n) { unsigned int i; unsigned int h; - decl_node q; + decl_node__opaque q; bool seen; - mcDebug_assert (decl_isProcedure (n)); + mcDebug_assert (decl_isProcedure (static_cast (n))); i = Indexing_LowIndice (n->procedureF.parameters); h = Indexing_HighIndice (n->procedureF.parameters); seen = false; while (i <= h) { - q = static_cast (Indexing_GetIndice (n->procedureF.parameters, i)); - if (decl_isParam (q)) + q = static_cast (Indexing_GetIndice (n->procedureF.parameters, i)); + if (decl_isParam (static_cast (q))) { seen = (checkDeclareUnboundedParamCopyC (p, q)) || seen; } @@ -13669,8 +13549,8 @@ static void doUnboundedParamCopyC (mcPretty_pretty p, decl_node n) i = Indexing_LowIndice (n->procedureF.parameters); while (i <= h) { - q = static_cast (Indexing_GetIndice (n->procedureF.parameters, i)); - if (decl_isParam (q)) + q = static_cast (Indexing_GetIndice (n->procedureF.parameters, i)); + if (decl_isParam (static_cast (q))) { checkUnboundedParamCopyC (p, q); } @@ -13684,14 +13564,14 @@ static void doUnboundedParamCopyC (mcPretty_pretty p, decl_node n) doPrototypeC - */ -static void doPrototypeC (decl_node n) +static void doPrototypeC (decl_node__opaque n) { - if (! (decl_isExported (n))) + if (! (decl_isExported (static_cast (n)))) { - keyc_enterScope (n); + keyc_enterScope (static_cast (n)); doProcedureHeadingC (n, true); mcPretty_print (doP, (const char *) ";\\n", 3); - keyc_leaveScope (n); + keyc_leaveScope (static_cast (n)); } } @@ -13700,13 +13580,13 @@ static void doPrototypeC (decl_node n) addTodo - adds, n, to the todo list. */ -static void addTodo (decl_node n) +static void addTodo (decl_node__opaque n) { if (((n != NULL) && (! (alists_isItemInList (globalGroup->partialQ, reinterpret_cast (n))))) && (! (alists_isItemInList (globalGroup->doneQ, reinterpret_cast (n))))) { - mcDebug_assert (! (decl_isVarient (n))); - mcDebug_assert (! (decl_isVarientField (n))); - mcDebug_assert (! (decl_isDef (n))); + mcDebug_assert (! (decl_isVarient (static_cast (n)))); + mcDebug_assert (! (decl_isVarientField (static_cast (n)))); + mcDebug_assert (! (decl_isDef (static_cast (n)))); alists_includeItemIntoList (globalGroup->todoQ, reinterpret_cast (n)); } } @@ -13716,15 +13596,15 @@ static void addTodo (decl_node n) addVariablesTodo - */ -static void addVariablesTodo (decl_node n) +static void addVariablesTodo (decl_node__opaque n) { - if (decl_isVar (n)) + if (decl_isVar (static_cast (n))) { /* avoid gcc warning by using compound statement even if not strictly necessary. */ if (n->varF.isParameter || n->varF.isVarParameter) { addDone (n); - addTodo (decl_getType (n)); + addTodo (static_cast (decl_getType (static_cast (n)))); } else { @@ -13738,9 +13618,9 @@ static void addVariablesTodo (decl_node n) addTypesTodo - */ -static void addTypesTodo (decl_node n) +static void addTypesTodo (decl_node__opaque n) { - if (decl_isUnbounded (n)) + if (decl_isUnbounded (static_cast (n))) { addDone (n); } @@ -13768,16 +13648,16 @@ static DynamicStrings_String tempName (void) makeIntermediateType - */ -static decl_node makeIntermediateType (DynamicStrings_String s, decl_node p) +static decl_node__opaque makeIntermediateType (DynamicStrings_String s, decl_node__opaque p) { nameKey_Name n; - decl_node o; + decl_node__opaque o; n = nameKey_makekey (DynamicStrings_string (s)); - decl_enterScope (decl_getScope (p)); + decl_enterScope (decl_getScope (static_cast (p))); o = p; - p = decl_makeType (nameKey_makekey (DynamicStrings_string (s))); - decl_putType (p, o); + p = static_cast (decl_makeType (nameKey_makekey (DynamicStrings_string (s)))); + decl_putType (static_cast (p), static_cast (o)); putTypeInternal (p); decl_leaveScope (); return p; @@ -13790,11 +13670,11 @@ static decl_node makeIntermediateType (DynamicStrings_String s, decl_node p) simplifyType - */ -static void simplifyType (alists_alist l, decl_node *p) +static void simplifyType (alists_alist l, decl_node__opaque *p) { DynamicStrings_String s; - if ((((*p) != NULL) && (((decl_isRecord ((*p))) || (decl_isArray ((*p)))) || (decl_isProcType ((*p))))) && (! (decl_isUnbounded ((*p))))) + if ((((*p) != NULL) && (((decl_isRecord (static_cast ((*p)))) || (decl_isArray (static_cast ((*p))))) || (decl_isProcType (static_cast ((*p)))))) && (! (decl_isUnbounded (static_cast ((*p)))))) { s = tempName (); (*p) = makeIntermediateType (s, (*p)); @@ -13809,15 +13689,15 @@ static void simplifyType (alists_alist l, decl_node *p) simplifyVar - */ -static void simplifyVar (alists_alist l, decl_node n) +static void simplifyVar (alists_alist l, decl_node__opaque n) { unsigned int i; unsigned int t; - decl_node v; - decl_node d; - decl_node o; + decl_node__opaque v; + decl_node__opaque d; + decl_node__opaque o; - mcDebug_assert (decl_isVar (n)); + mcDebug_assert (decl_isVar (static_cast (n))); o = n->varF.type; simplifyType (l, &n->varF.type); if (o != n->varF.type) @@ -13830,8 +13710,8 @@ static void simplifyVar (alists_alist l, decl_node n) i = 1; while (i <= t) { - v = decl_lookupInScope (n->varF.scope, wlists_getItemFromList (d->vardeclF.names, i)); - mcDebug_assert (decl_isVar (v)); + v = static_cast (decl_lookupInScope (static_cast (n->varF.scope), wlists_getItemFromList (d->vardeclF.names, i))); + mcDebug_assert (decl_isVar (static_cast (v))); v->varF.type = n->varF.type; i += 1; } @@ -13843,17 +13723,17 @@ static void simplifyVar (alists_alist l, decl_node n) simplifyRecord - */ -static void simplifyRecord (alists_alist l, decl_node n) +static void simplifyRecord (alists_alist l, decl_node__opaque n) { unsigned int i; unsigned int t; - decl_node q; + decl_node__opaque q; i = Indexing_LowIndice (n->recordF.listOfSons); t = Indexing_HighIndice (n->recordF.listOfSons); while (i <= t) { - q = static_cast (Indexing_GetIndice (n->recordF.listOfSons, i)); + q = static_cast (Indexing_GetIndice (n->recordF.listOfSons, i)); simplifyNode (l, q); i += 1; } @@ -13864,18 +13744,18 @@ static void simplifyRecord (alists_alist l, decl_node n) simplifyVarient - */ -static void simplifyVarient (alists_alist l, decl_node n) +static void simplifyVarient (alists_alist l, decl_node__opaque n) { unsigned int i; unsigned int t; - decl_node q; + decl_node__opaque q; simplifyNode (l, n->varientF.tag); i = Indexing_LowIndice (n->varientF.listOfSons); t = Indexing_HighIndice (n->varientF.listOfSons); while (i <= t) { - q = static_cast (Indexing_GetIndice (n->varientF.listOfSons, i)); + q = static_cast (Indexing_GetIndice (n->varientF.listOfSons, i)); simplifyNode (l, q); i += 1; } @@ -13886,17 +13766,17 @@ static void simplifyVarient (alists_alist l, decl_node n) simplifyVarientField - */ -static void simplifyVarientField (alists_alist l, decl_node n) +static void simplifyVarientField (alists_alist l, decl_node__opaque n) { unsigned int i; unsigned int t; - decl_node q; + decl_node__opaque q; i = Indexing_LowIndice (n->varientfieldF.listOfSons); t = Indexing_HighIndice (n->varientfieldF.listOfSons); while (i <= t) { - q = static_cast (Indexing_GetIndice (n->varientfieldF.listOfSons, i)); + q = static_cast (Indexing_GetIndice (n->varientfieldF.listOfSons, i)); simplifyNode (l, q); i += 1; } @@ -13907,47 +13787,47 @@ static void simplifyVarientField (alists_alist l, decl_node n) doSimplifyNode - */ -static void doSimplifyNode (alists_alist l, decl_node n) +static void doSimplifyNode (alists_alist l, decl_node__opaque n) { if (n == NULL) {} /* empty. */ - else if (decl_isType (n)) + else if (decl_isType (static_cast (n))) { /* avoid dangling else. */ /* no need to simplify a type. */ - simplifyNode (l, decl_getType (n)); + simplifyNode (l, static_cast (decl_getType (static_cast (n)))); } - else if (decl_isVar (n)) + else if (decl_isVar (static_cast (n))) { /* avoid dangling else. */ simplifyVar (l, n); } - else if (decl_isRecord (n)) + else if (decl_isRecord (static_cast (n))) { /* avoid dangling else. */ simplifyRecord (l, n); } - else if (decl_isRecordField (n)) + else if (decl_isRecordField (static_cast (n))) { /* avoid dangling else. */ simplifyType (l, &n->recordfieldF.type); } - else if (decl_isArray (n)) + else if (decl_isArray (static_cast (n))) { /* avoid dangling else. */ simplifyType (l, &n->arrayF.type); } - else if (decl_isVarient (n)) + else if (decl_isVarient (static_cast (n))) { /* avoid dangling else. */ simplifyVarient (l, n); } - else if (decl_isVarientField (n)) + else if (decl_isVarientField (static_cast (n))) { /* avoid dangling else. */ simplifyVarientField (l, n); } - else if (decl_isPointer (n)) + else if (decl_isPointer (static_cast (n))) { /* avoid dangling else. */ simplifyType (l, &n->pointerF.type); @@ -13959,7 +13839,7 @@ static void doSimplifyNode (alists_alist l, decl_node n) simplifyNode - */ -static void simplifyNode (alists_alist l, decl_node n) +static void simplifyNode (alists_alist l, decl_node__opaque n) { if (! (alists_isItemInList (l, reinterpret_cast (n)))) { @@ -13973,7 +13853,7 @@ static void simplifyNode (alists_alist l, decl_node n) doSimplify - */ -static void doSimplify (decl_node n) +static void doSimplify (decl_node__opaque n) { alists_alist l; @@ -14001,7 +13881,7 @@ static void simplifyTypes (decl_scopeT s) outDeclsDefC - */ -static void outDeclsDefC (mcPretty_pretty p, decl_node n) +static void outDeclsDefC (mcPretty_pretty p, decl_node__opaque n) { decl_scopeT s; @@ -14053,7 +13933,7 @@ static void includeVar (decl_scopeT s) includeExternals - */ -static void includeExternals (decl_node n) +static void includeExternals (decl_node__opaque n) { alists_alist l; @@ -14067,7 +13947,7 @@ static void includeExternals (decl_node n) checkSystemInclude - */ -static void checkSystemInclude (decl_node n) +static void checkSystemInclude (decl_node__opaque n) { } @@ -14076,14 +13956,14 @@ static void checkSystemInclude (decl_node n) addExported - */ -static void addExported (decl_node n) +static void addExported (decl_node__opaque n) { - decl_node s; + decl_node__opaque s; - s = decl_getScope (n); - if (((s != NULL) && (decl_isDef (s))) && (s != defModule)) + s = static_cast (decl_getScope (static_cast (n))); + if (((s != NULL) && (decl_isDef (static_cast (s)))) && (s != defModule)) { - if (((decl_isType (n)) || (decl_isVar (n))) || (decl_isConst (n))) + if (((decl_isType (static_cast (n))) || (decl_isVar (static_cast (n)))) || (decl_isConst (static_cast (n)))) { addTodo (n); } @@ -14096,12 +13976,12 @@ static void addExported (decl_node n) implementation module and is not a hidden type. */ -static void addExternal (decl_node n) +static void addExternal (decl_node__opaque n) { - if (((((decl_getScope (n)) == defModule) && (decl_isType (n))) && (decl_isTypeHidden (n))) && (! (mcOptions_getExtendedOpaque ()))) + if (((((decl_getScope (static_cast (n))) == defModule) && (decl_isType (static_cast (n)))) && (decl_isTypeHidden (static_cast (n)))) && (! (mcOptions_getExtendedOpaque ()))) {} /* empty. */ /* do nothing. */ - else if (! (decl_isDef (n))) + else if (! (decl_isDef (static_cast (n)))) { /* avoid dangling else. */ addTodo (n); @@ -14113,13 +13993,13 @@ static void addExternal (decl_node n) includeDefConstType - */ -static void includeDefConstType (decl_node n) +static void includeDefConstType (decl_node__opaque n) { - decl_node d; + decl_node__opaque d; - if (decl_isImp (n)) + if (decl_isImp (static_cast (n))) { - defModule = decl_lookupDef (decl_getSymName (n)); + defModule = static_cast (decl_lookupDef (decl_getSymName (static_cast (n)))); if (defModule != NULL) { simplifyTypes (defModule->defF.decls); @@ -14134,11 +14014,11 @@ static void includeDefConstType (decl_node n) runIncludeDefConstType - */ -static void runIncludeDefConstType (decl_node n) +static void runIncludeDefConstType (decl_node__opaque n) { - decl_node d; + decl_node__opaque d; - if (decl_isDef (n)) + if (decl_isDef (static_cast (n))) { simplifyTypes (n->defF.decls); includeConstType (n->defF.decls); @@ -14152,13 +14032,13 @@ static void runIncludeDefConstType (decl_node n) d, into implementation module, i. */ -static void joinProcedures (decl_node i, decl_node d) +static void joinProcedures (decl_node__opaque i, decl_node__opaque d) { unsigned int h; unsigned int j; - mcDebug_assert (decl_isDef (d)); - mcDebug_assert (decl_isImp (i)); + mcDebug_assert (decl_isDef (static_cast (d))); + mcDebug_assert (decl_isImp (static_cast (i))); j = 1; h = Indexing_HighIndice (d->defF.decls.procedures); while (j <= h) @@ -14173,14 +14053,14 @@ static void joinProcedures (decl_node i, decl_node d) includeDefVarProcedure - */ -static void includeDefVarProcedure (decl_node n) +static void includeDefVarProcedure (decl_node__opaque n) { - decl_node d; + decl_node__opaque d; - if (decl_isImp (n)) + if (decl_isImp (static_cast (n))) { /* avoid dangling else. */ - defModule = decl_lookupDef (decl_getSymName (n)); + defModule = static_cast (decl_lookupDef (decl_getSymName (static_cast (n)))); if (defModule != NULL) { /* @@ -14190,7 +14070,7 @@ static void includeDefVarProcedure (decl_node n) joinProcedures (n, defModule); } } - else if (decl_isDef (n)) + else if (decl_isDef (static_cast (n))) { /* avoid dangling else. */ includeVar (n->defF.decls); @@ -14203,7 +14083,7 @@ static void includeDefVarProcedure (decl_node n) foreachModuleDo - */ -static void foreachModuleDo (decl_node n, symbolKey_performOperation p) +static void foreachModuleDo (decl_node__opaque n, symbolKey_performOperation p) { decl_foreachDefModuleDo (p); decl_foreachModModuleDo (p); @@ -14230,17 +14110,17 @@ static void outDeclsImpC (mcPretty_pretty p, decl_scopeT s) doStatementSequenceC - */ -static void doStatementSequenceC (mcPretty_pretty p, decl_node s) +static void doStatementSequenceC (mcPretty_pretty p, decl_node__opaque s) { unsigned int i; unsigned int h; - mcDebug_assert (decl_isStatementSequence (s)); + mcDebug_assert (decl_isStatementSequence (static_cast (s))); h = Indexing_HighIndice (s->stmtF.statements); i = 1; while (i <= h) { - doStatementsC (p, reinterpret_cast (Indexing_GetIndice (s->stmtF.statements, i))); + doStatementsC (p, static_cast (Indexing_GetIndice (s->stmtF.statements, i))); i += 1; } } @@ -14250,9 +14130,9 @@ static void doStatementSequenceC (mcPretty_pretty p, decl_node s) isStatementSequenceEmpty - */ -static bool isStatementSequenceEmpty (decl_node s) +static bool isStatementSequenceEmpty (decl_node__opaque s) { - mcDebug_assert (decl_isStatementSequence (s)); + mcDebug_assert (decl_isStatementSequence (static_cast (s))); return (Indexing_HighIndice (s->stmtF.statements)) == 0; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -14264,18 +14144,18 @@ static bool isStatementSequenceEmpty (decl_node s) only one statement. */ -static bool isSingleStatement (decl_node s) +static bool isSingleStatement (decl_node__opaque s) { unsigned int h; - mcDebug_assert (decl_isStatementSequence (s)); + mcDebug_assert (decl_isStatementSequence (static_cast (s))); h = Indexing_HighIndice (s->stmtF.statements); if ((h == 0) || (h > 1)) { return false; } - s = static_cast (Indexing_GetIndice (s->stmtF.statements, 1)); - return (! (decl_isStatementSequence (s))) || (isSingleStatement (s)); + s = static_cast (Indexing_GetIndice (s->stmtF.statements, 1)); + return (! (decl_isStatementSequence (static_cast (s)))) || (isSingleStatement (s)); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -14285,7 +14165,7 @@ static bool isSingleStatement (decl_node s) doCommentC - */ -static void doCommentC (mcPretty_pretty p, decl_node s) +static void doCommentC (mcPretty_pretty p, decl_node__opaque s) { DynamicStrings_String c; @@ -14316,7 +14196,7 @@ static void doCommentC (mcPretty_pretty p, decl_node s) doAfterCommentC - emit an after comment, c, or a newline if, c, is empty. */ -static void doAfterCommentC (mcPretty_pretty p, decl_node c) +static void doAfterCommentC (mcPretty_pretty p, decl_node__opaque c) { if (c == NULL) { @@ -14333,21 +14213,30 @@ static void doAfterCommentC (mcPretty_pretty p, decl_node c) doReturnC - issue a return statement and also place in an after comment if one exists. */ -static void doReturnC (mcPretty_pretty p, decl_node s) +static void doReturnC (mcPretty_pretty p, decl_node__opaque s) { - mcDebug_assert (decl_isReturn (s)); + decl_node__opaque type; + + mcDebug_assert (decl_isReturn (static_cast (s))); doCommentC (p, s->returnF.returnComment.body); outText (p, (const char *) "return", 6); - if (s->returnF.scope != NULL) + if ((s->returnF.scope != NULL) && (s->returnF.exp != NULL)) { mcPretty_setNeedSpace (p); - if ((! (decl_isProcedure (s->returnF.scope))) || ((decl_getType (s->returnF.scope)) == NULL)) + if ((! (decl_isProcedure (static_cast (s->returnF.scope)))) || ((decl_getType (static_cast (s->returnF.scope))) == NULL)) { mcMetaError_metaError1 ((const char *) "{%1DMad} has no return type", 27, (const unsigned char *) &s->returnF.scope, (sizeof (s->returnF.scope)-1)); } else { - doExprCastC (p, s->returnF.exp, decl_getType (s->returnF.scope)); + if ((decl_isProcedure (static_cast (s->returnF.scope))) && (nodeUsesOpaque (s->returnF.scope))) + { + forceCastOpaque (p, s->returnF.scope, s->returnF.exp, getNodeOpaqueVoidStar (s->returnF.scope)); + } + else + { + doExprCastC (p, s->returnF.exp, static_cast (decl_getType (static_cast (s->returnF.scope)))); + } } } outText (p, (const char *) ";", 1); @@ -14359,7 +14248,7 @@ static void doReturnC (mcPretty_pretty p, decl_node s) isZtypeEquivalent - */ -static bool isZtypeEquivalent (decl_node type) +static bool isZtypeEquivalent (decl_node__opaque type) { switch (type->kind) { @@ -14387,10 +14276,10 @@ static bool isZtypeEquivalent (decl_node type) isEquivalentType - returns TRUE if type1 and type2 are equivalent. */ -static bool isEquivalentType (decl_node type1, decl_node type2) +static bool isEquivalentType (decl_node__opaque type1, decl_node__opaque type2) { - type1 = decl_skipType (type1); - type2 = decl_skipType (type2); + type1 = static_cast (decl_skipType (static_cast (type1))); + type2 = static_cast (decl_skipType (static_cast (type2))); return (type1 == type2) || ((isZtypeEquivalent (type1)) && (isZtypeEquivalent (type2))); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -14401,31 +14290,31 @@ static bool isEquivalentType (decl_node type1, decl_node type2) doExprCastC - build a cast if necessary. */ -static void doExprCastC (mcPretty_pretty p, decl_node e, decl_node type) +static void doExprCastC (mcPretty_pretty p, decl_node__opaque e, decl_node__opaque type) { - decl_node stype; + decl_node__opaque stype; - stype = decl_skipType (type); - if ((! (isEquivalentType (type, getExprType (e)))) && (! ((e->kind == decl_nil) && ((decl_isPointer (stype)) || (stype->kind == decl_address))))) + stype = static_cast (decl_skipType (static_cast (type))); + if ((! (isEquivalentType (type, getExprType (e)))) && (! ((e->kind == decl_nil) && ((decl_isPointer (static_cast (stype))) || (stype->kind == decl_address))))) { if (lang == decl_ansiCP) { /* avoid gcc warning by using compound statement even if not strictly necessary. */ /* potentially a cast is required. */ - if ((decl_isPointer (type)) || (type == addressN)) + if ((decl_isPointer (static_cast (type))) || (type == addressN)) { - outText (p, (const char *) "reinterpret_cast<", 17); + outText (p, (const char *) "static_cast<", 12); doTypeNameC (p, type); mcPretty_noSpace (p); outText (p, (const char *) "> (", 3); doExprC (p, e); outText (p, (const char *) ")", 1); - return ; + return; } else { outText (p, (const char *) "static_cast<", 12); - if (decl_isProcType (decl_skipType (type))) + if (decl_isProcType (decl_skipType (static_cast (type)))) { doTypeNameC (p, type); outText (p, (const char *) "_t", 2); @@ -14438,7 +14327,7 @@ static void doExprCastC (mcPretty_pretty p, decl_node e, decl_node type) outText (p, (const char *) "> (", 3); doExprC (p, e); outText (p, (const char *) ")", 1); - return ; + return; } } } @@ -14450,28 +14339,130 @@ static void doExprCastC (mcPretty_pretty p, decl_node e, decl_node type) requiresUnpackProc - returns TRUE if either the expr is a procedure or the proctypes differ. */ -static bool requiresUnpackProc (decl_node s) +static bool requiresUnpackProc (decl_node__opaque s) { mcDebug_assert (isAssignment (s)); - return (decl_isProcedure (s->assignmentF.expr)) || ((decl_skipType (decl_getType (s->assignmentF.des))) != (decl_skipType (decl_getType (s->assignmentF.expr)))); + return (decl_isProcedure (static_cast (s->assignmentF.expr))) || ((decl_skipType (decl_getType (static_cast (s->assignmentF.des)))) != (decl_skipType (decl_getType (static_cast (s->assignmentF.expr))))); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } +/* + forceCastOpaque - +*/ + +static void forceCastOpaque (mcPretty_pretty p, decl_node__opaque des, decl_node__opaque expr, bool toVoidStar) +{ + if (nodeUsesOpaque (expr)) + { + flushOpaque (p, expr, getNodeOpaqueVoidStar (des)); + } + else + { + forceReintCastOpaque (p, des, expr, toVoidStar); + } +} + + +/* + forceReintCastOpaque - +*/ + +static void forceReintCastOpaque (mcPretty_pretty p, decl_node__opaque des, decl_node__opaque expr, bool toVoidStar) +{ + decl_node__opaque type; + + type = static_cast (decl_getType (static_cast (des))); + if (toVoidStar) + { + /* next is true cast to void * opaque type. */ + outText (p, (const char *) "static_cast<", 12); + doTypeNameC (p, type); + mcPretty_noSpace (p); + outText (p, (const char *) "> (", 3); + doExprC (p, expr); + outText (p, (const char *) ")", 1); + } + else + { + /* next is false cast to __opaque opaque type. */ + outText (p, (const char *) "static_cast<", 12); + doTypeNameC (p, type); + outText (p, (const char *) "__opaque", 8); + mcPretty_noSpace (p); + outText (p, (const char *) "> (", 3); + doExprC (p, expr); + outText (p, (const char *) ")", 1); + } +} + + +/* + doUnConstCastUnbounded - if node n type is an unbounded array then + use const_cast to remove the const parameter + to allow the unbounded array to be modified. +*/ + +static void doUnConstCastUnbounded (mcPretty_pretty p, decl_node__opaque n) +{ + decl_node__opaque type; + decl_node__opaque v; + + if (isArrayRef (n)) + { + if (decl_isVar (static_cast (n->arrayrefF.array))) + { + v = n->arrayrefF.array; + if ((v->varF.isParameter || v->varF.isVarParameter) && (decl_isUnbounded (decl_getType (static_cast (v))))) + { + type = static_cast (decl_getType (static_cast (v))); + outText (p, (const char *) " /* const_cast<", 15); + doTypeNameC (p, type); + outText (p, (const char *) "> is needed */ ", 15); + } + } + } +} + + /* doAssignmentC - */ -static void doAssignmentC (mcPretty_pretty p, decl_node s) +static void doAssignmentC (mcPretty_pretty p, decl_node__opaque s) { mcDebug_assert (isAssignment (s)); doCommentC (p, s->assignmentF.assignComment.body); - doExprCup (p, s->assignmentF.des, requiresUnpackProc (s)); + if (debugOpaque) + { + outText (p, (const char *) " /* des: */ ", 12); + dumpOpaqueState (s->assignmentF.des); + outText (p, (const char *) " /* expr: */ ", 13); + dumpOpaqueState (s->assignmentF.expr); + } + s->assignmentF.des = doExprCup (p, s->assignmentF.des, requiresUnpackProc (s), true); + if (debugOpaque) + { + outText (p, (const char *) "\\n /* after doExprCup des: */ ", 30); + dumpOpaqueState (s->assignmentF.des); + outText (p, (const char *) "\\n", 2); + } mcPretty_setNeedSpace (p); outText (p, (const char *) "=", 1); mcPretty_setNeedSpace (p); - doExprCastC (p, s->assignmentF.expr, decl_getType (s->assignmentF.des)); + if (nodeUsesOpaque (s->assignmentF.des)) + { + forceCastOpaque (p, s->assignmentF.des, s->assignmentF.expr, getNodeOpaqueVoidStar (s->assignmentF.des)); + } + else + { + if (debugOpaque) + { + outText (p, (const char *) " /* no opaque des seen */ ", 26); + } + doExprCastC (p, s->assignmentF.expr, static_cast (decl_getType (static_cast (s->assignmentF.des)))); + } outText (p, (const char *) ";", 1); doAfterCommentC (p, s->assignmentF.assignComment.after); } @@ -14481,9 +14472,9 @@ static void doAssignmentC (mcPretty_pretty p, decl_node s) containsStatement - */ -static bool containsStatement (decl_node s) +static bool containsStatement (decl_node__opaque s) { - return ((s != NULL) && (decl_isStatementSequence (s))) && (! (isStatementSequenceEmpty (s))); + return ((s != NULL) && (decl_isStatementSequence (static_cast (s)))) && (! (isStatementSequenceEmpty (s))); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -14493,16 +14484,16 @@ static bool containsStatement (decl_node s) doCompoundStmt - */ -static void doCompoundStmt (mcPretty_pretty p, decl_node s) +static void doCompoundStmt (mcPretty_pretty p, decl_node__opaque s) { - if ((s == NULL) || ((decl_isStatementSequence (s)) && (isStatementSequenceEmpty (s)))) + if ((s == NULL) || ((decl_isStatementSequence (static_cast (s))) && (isStatementSequenceEmpty (s)))) { p = mcPretty_pushPretty (p); mcPretty_setindent (p, (mcPretty_getindent (p))+indentationC); outText (p, (const char *) "{} /* empty. */\\n", 19); p = mcPretty_popPretty (p); } - else if (((decl_isStatementSequence (s)) && (isSingleStatement (s))) && ! forceCompoundStatement) + else if (((decl_isStatementSequence (static_cast (s))) && (isSingleStatement (s))) && ! forceCompoundStatement) { /* avoid dangling else. */ p = mcPretty_pushPretty (p); @@ -14530,9 +14521,9 @@ static void doCompoundStmt (mcPretty_pretty p, decl_node s) doElsifC - */ -static void doElsifC (mcPretty_pretty p, decl_node s) +static void doElsifC (mcPretty_pretty p, decl_node__opaque s) { - mcDebug_assert (decl_isElsif (s)); + mcDebug_assert (decl_isElsif (static_cast (s))); outText (p, (const char *) "else if", 7); mcPretty_setNeedSpace (p); outText (p, (const char *) "(", 1); @@ -14579,7 +14570,7 @@ static void doElsifC (mcPretty_pretty p, decl_node s) doCompoundStmt (p, s->elsifF.else_); } } - else if ((s->elsifF.elsif != NULL) && (decl_isElsif (s->elsifF.elsif))) + else if ((s->elsifF.elsif != NULL) && (decl_isElsif (static_cast (s->elsifF.elsif)))) { /* avoid dangling else. */ doElsifC (p, s->elsifF.elsif); @@ -14591,9 +14582,9 @@ static void doElsifC (mcPretty_pretty p, decl_node s) noIfElse - */ -static bool noIfElse (decl_node n) +static bool noIfElse (decl_node__opaque n) { - return (((n != NULL) && (decl_isIf (n))) && (n->ifF.else_ == NULL)) && (n->ifF.elsif == NULL); + return (((n != NULL) && (decl_isIf (static_cast (n)))) && (n->ifF.else_ == NULL)) && (n->ifF.elsif == NULL); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -14606,14 +14597,14 @@ static bool noIfElse (decl_node n) in a return value of TRUE. */ -static bool noIfElseChained (decl_node n) +static bool noIfElseChained (decl_node__opaque n) { - decl_node e; + decl_node__opaque e; if (n != NULL) { /* avoid gcc warning by using compound statement even if not strictly necessary. */ - if (decl_isIf (n)) + if (decl_isIf (static_cast (n))) { if (n->ifF.else_ != NULL) { @@ -14631,11 +14622,11 @@ static bool noIfElseChained (decl_node n) /* avoid dangling else. */ /* test elsif for lack of else. */ e = n->ifF.elsif; - mcDebug_assert (decl_isElsif (e)); + mcDebug_assert (decl_isElsif (static_cast (e))); return noIfElseChained (e); } } - else if (decl_isElsif (n)) + else if (decl_isElsif (static_cast (n))) { /* avoid dangling else. */ if (n->elsifF.else_ != NULL) @@ -14654,7 +14645,7 @@ static bool noIfElseChained (decl_node n) /* avoid dangling else. */ /* test elsif for lack of else. */ e = n->elsifF.elsif; - mcDebug_assert (decl_isElsif (e)); + mcDebug_assert (decl_isElsif (static_cast (e))); return noIfElseChained (e); } } @@ -14669,11 +14660,11 @@ static bool noIfElseChained (decl_node n) hasIfElse - */ -static bool hasIfElse (decl_node n) +static bool hasIfElse (decl_node__opaque n) { if (n != NULL) { - if (decl_isStatementSequence (n)) + if (decl_isStatementSequence (static_cast (n))) { /* avoid gcc warning by using compound statement even if not strictly necessary. */ if (isStatementSequenceEmpty (n)) @@ -14683,7 +14674,7 @@ static bool hasIfElse (decl_node n) else if (isSingleStatement (n)) { /* avoid dangling else. */ - n = static_cast (Indexing_GetIndice (n->stmtF.statements, 1)); + n = static_cast (Indexing_GetIndice (n->stmtF.statements, 1)); return isIfElse (n); } } @@ -14698,9 +14689,9 @@ static bool hasIfElse (decl_node n) isIfElse - */ -static bool isIfElse (decl_node n) +static bool isIfElse (decl_node__opaque n) { - return ((n != NULL) && (decl_isIf (n))) && ((n->ifF.else_ != NULL) || (n->ifF.elsif != NULL)); + return ((n != NULL) && (decl_isIf (static_cast (n)))) && ((n->ifF.else_ != NULL) || (n->ifF.elsif != NULL)); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -14711,12 +14702,12 @@ static bool isIfElse (decl_node n) which is an IF and it has no else statement. */ -static bool hasIfAndNoElse (decl_node n) +static bool hasIfAndNoElse (decl_node__opaque n) { if (n != NULL) { /* avoid gcc warning by using compound statement even if not strictly necessary. */ - if (decl_isStatementSequence (n)) + if (decl_isStatementSequence (static_cast (n))) { if (isStatementSequenceEmpty (n)) { @@ -14725,17 +14716,17 @@ static bool hasIfAndNoElse (decl_node n) else if (isSingleStatement (n)) { /* avoid dangling else. */ - n = static_cast (Indexing_GetIndice (n->stmtF.statements, 1)); + n = static_cast (Indexing_GetIndice (n->stmtF.statements, 1)); return hasIfAndNoElse (n); } else { /* avoid dangling else. */ - n = static_cast (Indexing_GetIndice (n->stmtF.statements, Indexing_HighIndice (n->stmtF.statements))); + n = static_cast (Indexing_GetIndice (n->stmtF.statements, Indexing_HighIndice (n->stmtF.statements))); return hasIfAndNoElse (n); } } - else if ((decl_isElsif (n)) || (decl_isIf (n))) + else if ((decl_isElsif (static_cast (n))) || (decl_isIf (static_cast (n)))) { /* avoid dangling else. */ return noIfElseChained (n); @@ -14752,9 +14743,9 @@ static bool hasIfAndNoElse (decl_node n) The if statement might contain an else or elsif which are also handled. */ -static void doIfC (mcPretty_pretty p, decl_node s) +static void doIfC (mcPretty_pretty p, decl_node__opaque s) { - mcDebug_assert (decl_isIf (s)); + mcDebug_assert (decl_isIf (static_cast (s))); doCommentC (p, s->ifF.ifComment.body); outText (p, (const char *) "if", 2); mcPretty_setNeedSpace (p); @@ -14805,7 +14796,7 @@ static void doIfC (mcPretty_pretty p, decl_node s) doAfterCommentC (p, s->ifF.elseComment.after); doCompoundStmt (p, s->ifF.else_); } - else if ((s->ifF.elsif != NULL) && (decl_isElsif (s->ifF.elsif))) + else if ((s->ifF.elsif != NULL) && (decl_isElsif (static_cast (s->ifF.elsif)))) { /* avoid dangling else. */ doCommentC (p, s->ifF.elseComment.body); @@ -14821,19 +14812,19 @@ static void doIfC (mcPretty_pretty p, decl_node s) doForIncCP - */ -static void doForIncCP (mcPretty_pretty p, decl_node s) +static void doForIncCP (mcPretty_pretty p, decl_node__opaque s) { - decl_node t; + decl_node__opaque t; - mcDebug_assert (decl_isFor (s)); - t = decl_skipType (decl_getType (s->forF.des)); - if (decl_isEnumeration (t)) + mcDebug_assert (decl_isFor (static_cast (s))); + t = static_cast (decl_skipType (decl_getType (static_cast (s->forF.des)))); + if (decl_isEnumeration (static_cast (t))) { if (s->forF.increment == NULL) { doExprC (p, s->forF.des); outText (p, (const char *) "= static_cast<", 14); - doTypeNameC (p, decl_getType (s->forF.des)); + doTypeNameC (p, static_cast (decl_getType (static_cast (s->forF.des)))); mcPretty_noSpace (p); outText (p, (const char *) ">(static_cast(", 19); doExprC (p, s->forF.des); @@ -14843,7 +14834,7 @@ static void doForIncCP (mcPretty_pretty p, decl_node s) { doExprC (p, s->forF.des); outText (p, (const char *) "= static_cast<", 14); - doTypeNameC (p, decl_getType (s->forF.des)); + doTypeNameC (p, static_cast (decl_getType (static_cast (s->forF.des)))); mcPretty_noSpace (p); outText (p, (const char *) ">(static_cast(", 19); doExprC (p, s->forF.des); @@ -14863,7 +14854,7 @@ static void doForIncCP (mcPretty_pretty p, decl_node s) doForIncC - */ -static void doForIncC (mcPretty_pretty p, decl_node s) +static void doForIncC (mcPretty_pretty p, decl_node__opaque s) { if (s->forF.increment == NULL) { @@ -14885,7 +14876,7 @@ static void doForIncC (mcPretty_pretty p, decl_node s) doForInc - */ -static void doForInc (mcPretty_pretty p, decl_node s) +static void doForInc (mcPretty_pretty p, decl_node__opaque s) { if (lang == decl_ansiCP) { @@ -14902,9 +14893,9 @@ static void doForInc (mcPretty_pretty p, decl_node s) doForC - */ -static void doForC (mcPretty_pretty p, decl_node s) +static void doForC (mcPretty_pretty p, decl_node__opaque s) { - mcDebug_assert (decl_isFor (s)); + mcDebug_assert (decl_isFor (static_cast (s))); outText (p, (const char *) "for (", 5); doExprC (p, s->forF.des); outText (p, (const char *) "=", 1); @@ -14926,9 +14917,9 @@ static void doForC (mcPretty_pretty p, decl_node s) doRepeatC - */ -static void doRepeatC (mcPretty_pretty p, decl_node s) +static void doRepeatC (mcPretty_pretty p, decl_node__opaque s) { - mcDebug_assert (decl_isRepeat (s)); + mcDebug_assert (decl_isRepeat (static_cast (s))); doCommentC (p, s->repeatF.repeatComment.body); outText (p, (const char *) "do {", 4); doAfterCommentC (p, s->repeatF.repeatComment.after); @@ -14948,9 +14939,9 @@ static void doRepeatC (mcPretty_pretty p, decl_node s) doWhileC - */ -static void doWhileC (mcPretty_pretty p, decl_node s) +static void doWhileC (mcPretty_pretty p, decl_node__opaque s) { - mcDebug_assert (decl_isWhile (s)); + mcDebug_assert (decl_isWhile (static_cast (s))); doCommentC (p, s->whileF.doComment.body); outText (p, (const char *) "while (", 7); doExprC (p, s->whileF.expr); @@ -14966,12 +14957,12 @@ static void doWhileC (mcPretty_pretty p, decl_node s) doFuncHighC - */ -static void doFuncHighC (mcPretty_pretty p, decl_node a) +static void doFuncHighC (mcPretty_pretty p, decl_node__opaque a) { - decl_node s; - decl_node n; + decl_node__opaque s; + decl_node__opaque n; - if ((decl_isLiteral (a)) && ((decl_getType (a)) == charN)) + if ((decl_isLiteral (static_cast (a))) && ((decl_getType (static_cast (a))) == charN)) { outCard (p, 0); } @@ -14980,22 +14971,22 @@ static void doFuncHighC (mcPretty_pretty p, decl_node a) /* avoid dangling else. */ outCard (p, a->stringF.length-2); } - else if ((decl_isConst (a)) && (isString (a->constF.value))) + else if ((decl_isConst (static_cast (a))) && (isString (a->constF.value))) { /* avoid dangling else. */ doFuncHighC (p, a->constF.value); } - else if (decl_isUnbounded (decl_getType (a))) + else if (decl_isUnbounded (decl_getType (static_cast (a)))) { /* avoid dangling else. */ outText (p, (const char *) "_", 1); - outTextN (p, decl_getSymName (a)); + outTextN (p, decl_getSymName (static_cast (a))); outText (p, (const char *) "_high", 5); } - else if (decl_isArray (decl_skipType (decl_getType (a)))) + else if (decl_isArray (decl_skipType (decl_getType (static_cast (a))))) { /* avoid dangling else. */ - n = decl_skipType (decl_getType (a)); + n = static_cast (decl_skipType (decl_getType (static_cast (a)))); s = n->arrayF.subr; if (isZero (getMin (s))) { @@ -15026,7 +15017,7 @@ static void doFuncHighC (mcPretty_pretty p, decl_node a) doMultiplyBySize - */ -static void doMultiplyBySize (mcPretty_pretty p, decl_node a) +static void doMultiplyBySize (mcPretty_pretty p, decl_node__opaque a) { if (((a != charN) && (a != byteN)) && (a != locN)) { @@ -15043,21 +15034,21 @@ static void doMultiplyBySize (mcPretty_pretty p, decl_node a) doTotype - */ -static void doTotype (mcPretty_pretty p, decl_node a, decl_node t) +static void doTotype (mcPretty_pretty p, decl_node__opaque a, decl_node__opaque t) { - if ((! (isString (a))) && (! (decl_isLiteral (a)))) + if ((! (isString (a))) && (! (decl_isLiteral (static_cast (a))))) { - if (decl_isVar (a)) + if (decl_isVar (static_cast (a))) { - if (((a->varF.isParameter || a->varF.isVarParameter) && (decl_isUnbounded (decl_getType (a)))) && ((decl_skipType (decl_getType (decl_getType (a)))) == (decl_skipType (decl_getType (t))))) + if (((a->varF.isParameter || a->varF.isVarParameter) && (decl_isUnbounded (decl_getType (static_cast (a))))) && ((decl_skipType (decl_getType (decl_getType (static_cast (a))))) == (decl_skipType (decl_getType (static_cast (t)))))) { /* do not multiply by size as the existing high value is correct. */ - return ; + return; } - a = decl_getType (a); - if (decl_isArray (a)) + a = static_cast (decl_getType (static_cast (a))); + if (decl_isArray (static_cast (a))) { - doMultiplyBySize (p, decl_skipType (decl_getType (a))); + doMultiplyBySize (p, static_cast (decl_skipType (decl_getType (static_cast (a))))); } } } @@ -15076,23 +15067,23 @@ static void doTotype (mcPretty_pretty p, decl_node a, decl_node t) doFuncUnbounded - */ -static void doFuncUnbounded (mcPretty_pretty p, decl_node actual, decl_node formalParam, decl_node formal, decl_node func) +static void doFuncUnbounded (mcPretty_pretty p, decl_node__opaque actual, decl_node__opaque formalParam, decl_node__opaque formal, decl_node__opaque func) { - decl_node h; + decl_node__opaque h; DynamicStrings_String s; - mcDebug_assert (decl_isUnbounded (formal)); + mcDebug_assert (decl_isUnbounded (static_cast (formal))); outText (p, (const char *) "(", 1); - if ((lang == decl_ansiCP) && (decl_isParam (formalParam))) + if ((lang == decl_ansiCP) && (decl_isParam (static_cast (formalParam)))) { outText (p, (const char *) "const", 5); mcPretty_setNeedSpace (p); } - doTypeC (p, decl_getType (formal), &formal); + doTypeC (p, static_cast (decl_getType (static_cast (formal))), &formal); mcPretty_setNeedSpace (p); outText (p, (const char *) "*)", 2); mcPretty_setNeedSpace (p); - if ((decl_isLiteral (actual)) && ((decl_getType (actual)) == charN)) + if ((decl_isLiteral (static_cast (actual))) && ((decl_getType (static_cast (actual))) == charN)) { outText (p, (const char *) "\"\\0", 3); s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (actual->literalF.name)); @@ -15106,7 +15097,7 @@ static void doFuncUnbounded (mcPretty_pretty p, decl_node actual, decl_node form /* avoid dangling else. */ outCstring (p, actual, true); } - else if (decl_isConst (actual)) + else if (decl_isConst (static_cast (actual))) { /* avoid dangling else. */ actual = resolveString (actual); @@ -15126,7 +15117,7 @@ static void doFuncUnbounded (mcPretty_pretty p, decl_node actual, decl_node form doExprC (p, actual); } } - else if (decl_isUnbounded (decl_getType (actual))) + else if (decl_isUnbounded (decl_getType (static_cast (actual)))) { /* avoid dangling else. */ /* doExprC (p, actual). */ @@ -15137,12 +15128,12 @@ static void doFuncUnbounded (mcPretty_pretty p, decl_node actual, decl_node form /* avoid dangling else. */ outText (p, (const char *) "&", 1); doExprC (p, actual); - if (decl_isArray (decl_skipType (decl_getType (actual)))) + if (decl_isArray (decl_skipType (decl_getType (static_cast (actual))))) { outText (p, (const char *) ".array[0]", 9); } } - if (! (enableDefForCStrings && (isDefForC (decl_getScope (func))))) + if (! (enableDefForCStrings && (isDefForC (static_cast (decl_getScope (static_cast (func))))))) { outText (p, (const char *) ",", 1); mcPretty_setNeedSpace (p); @@ -15156,12 +15147,12 @@ static void doFuncUnbounded (mcPretty_pretty p, decl_node actual, decl_node form doProcedureParamC - */ -static void doProcedureParamC (mcPretty_pretty p, decl_node actual, decl_node formal) +static void doProcedureParamC (mcPretty_pretty p, decl_node__opaque actual, decl_node__opaque formal) { if (isForC (formal)) { outText (p, (const char *) "(", 1); - doFQNameC (p, decl_getType (formal)); + doFQNameC (p, static_cast (decl_getType (static_cast (formal)))); outText (p, (const char *) "_C", 2); outText (p, (const char *) ")", 1); mcPretty_setNeedSpace (p); @@ -15170,12 +15161,12 @@ static void doProcedureParamC (mcPretty_pretty p, decl_node actual, decl_node fo else { outText (p, (const char *) "(", 1); - doTypeNameC (p, decl_getType (formal)); + doTypeNameC (p, static_cast (decl_getType (static_cast (formal)))); outText (p, (const char *) ")", 1); mcPretty_setNeedSpace (p); outText (p, (const char *) "{", 1); outText (p, (const char *) "(", 1); - doFQNameC (p, decl_getType (formal)); + doFQNameC (p, static_cast (decl_getType (static_cast (formal)))); outText (p, (const char *) "_t)", 3); mcPretty_setNeedSpace (p); doExprC (p, actual); @@ -15188,17 +15179,17 @@ static void doProcedureParamC (mcPretty_pretty p, decl_node actual, decl_node fo doAdrExprC - */ -static void doAdrExprC (mcPretty_pretty p, decl_node n) +static void doAdrExprC (mcPretty_pretty p, decl_node__opaque n) { if (isDeref (n)) { - /* no point in issuing & ( * n ) */ + /* No point in issuing & ( * n ). */ doExprC (p, n->unaryF.arg); } - else if ((decl_isVar (n)) && n->varF.isVarParameter) + else if ((decl_isVar (static_cast (n))) && n->varF.isVarParameter) { /* avoid dangling else. */ - /* no point in issuing & ( * n ) */ + /* No point in issuing & ( * n ). */ doFQNameC (p, n); } else @@ -15214,7 +15205,7 @@ static void doAdrExprC (mcPretty_pretty p, decl_node n) typePair - */ -static bool typePair (decl_node a, decl_node b, decl_node x, decl_node y) +static bool typePair (decl_node__opaque a, decl_node__opaque b, decl_node__opaque x, decl_node__opaque y) { return ((a == x) && (b == y)) || ((a == y) && (b == x)); /* static analysis guarentees a RETURN statement will be used before here. */ @@ -15227,10 +15218,10 @@ static bool typePair (decl_node a, decl_node b, decl_node x, decl_node y) the formal type. */ -static bool needsCast (decl_node at, decl_node ft) +static bool needsCast (decl_node__opaque at, decl_node__opaque ft) { - at = decl_skipType (at); - ft = decl_skipType (ft); + at = static_cast (decl_skipType (static_cast (at))); + ft = static_cast (decl_skipType (static_cast (ft))); if (((((((((((((at == nilN) || (at->kind == decl_nil)) || (at == ft)) || (typePair (at, ft, cardinalN, wordN))) || (typePair (at, ft, cardinalN, ztypeN))) || (typePair (at, ft, integerN, ztypeN))) || (typePair (at, ft, longcardN, ztypeN))) || (typePair (at, ft, shortcardN, ztypeN))) || (typePair (at, ft, longintN, ztypeN))) || (typePair (at, ft, shortintN, ztypeN))) || (typePair (at, ft, realN, rtypeN))) || (typePair (at, ft, longrealN, rtypeN))) || (typePair (at, ft, shortrealN, rtypeN))) { return false; @@ -15251,29 +15242,29 @@ static bool needsCast (decl_node at, decl_node ft) open parenthesis. */ -static unsigned int checkSystemCast (mcPretty_pretty p, decl_node actual, decl_node formal) +static unsigned int checkSystemCast (mcPretty_pretty p, decl_node__opaque actual, decl_node__opaque formal) { - decl_node at; - decl_node ft; + decl_node__opaque at; + decl_node__opaque ft; at = getExprType (actual); - ft = decl_getType (formal); + ft = static_cast (decl_getType (static_cast (formal))); if (needsCast (at, ft)) { /* avoid gcc warning by using compound statement even if not strictly necessary. */ if (lang == decl_ansiCP) { - if ((isString (actual)) && ((decl_skipType (ft)) == addressN)) + if ((isString (actual)) && ((decl_skipType (static_cast (ft))) == addressN)) { - outText (p, (const char *) "const_cast (reinterpret_cast (", 50); + outText (p, (const char *) "const_cast (static_cast (", 45); return 2; } - else if ((decl_isPointer (decl_skipType (ft))) || ((decl_skipType (ft)) == addressN)) + else if ((decl_isPointer (decl_skipType (static_cast (ft)))) || ((decl_skipType (static_cast (ft))) == addressN)) { /* avoid dangling else. */ if (actual == nilN) { - if (decl_isVarParam (formal)) + if (decl_isVarParam (static_cast (formal))) { mcMetaError_metaError1 ((const char *) "NIL is being passed to a VAR parameter {%1DMad}", 47, (const unsigned char *) &formal, (sizeof (formal)-1)); } @@ -15284,7 +15275,7 @@ static unsigned int checkSystemCast (mcPretty_pretty p, decl_node actual, decl_n { outText (p, (const char *) "reinterpret_cast<", 17); doTypeNameC (p, ft); - if (decl_isVarParam (formal)) + if (decl_isVarParam (static_cast (formal))) { outText (p, (const char *) "*", 1); } @@ -15297,7 +15288,7 @@ static unsigned int checkSystemCast (mcPretty_pretty p, decl_node actual, decl_n /* avoid dangling else. */ outText (p, (const char *) "static_cast<", 12); doTypeNameC (p, ft); - if (decl_isVarParam (formal)) + if (decl_isVarParam (static_cast (formal))) { outText (p, (const char *) "*", 1); } @@ -15310,7 +15301,7 @@ static unsigned int checkSystemCast (mcPretty_pretty p, decl_node actual, decl_n { outText (p, (const char *) "(", 1); doTypeNameC (p, ft); - if (decl_isVarParam (formal)) + if (decl_isVarParam (static_cast (formal))) { outText (p, (const char *) "*", 1); } @@ -15349,48 +15340,87 @@ static void emitN (mcPretty_pretty p, const char *a_, unsigned int _a_high, unsi which was declared inside a definition module for "C". */ -static bool isForC (decl_node n) +static bool isForC (decl_node__opaque n) { - if (decl_isVarParam (n)) + if (decl_isVarParam (static_cast (n))) { return n->varparamF.isForC; } - else if (decl_isParam (n)) + else if (decl_isParam (static_cast (n))) { /* avoid dangling else. */ return n->paramF.isForC; } - else if (decl_isProcedure (n)) + else if (decl_isProcedure (static_cast (n))) { /* avoid dangling else. */ return n->procedureF.isForC; } - return false; + return false; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} + + +/* + isDefForCNode - return TRUE if node n was declared inside a definition module for "C". +*/ + +static bool isDefForCNode (decl_node__opaque n) +{ + nameKey_Name name; + + while ((n != NULL) && (! (((decl_isImp (static_cast (n))) || (decl_isDef (static_cast (n)))) || (decl_isModule (static_cast (n)))))) + { + n = static_cast (decl_getScope (static_cast (n))); + } + if ((n != NULL) && (decl_isImp (static_cast (n)))) + { + name = decl_getSymName (static_cast (n)); + n = static_cast (decl_lookupDef (name)); + } + return ((n != NULL) && (decl_isDef (static_cast (n)))) && (isDefForC (n)); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - isDefForCNode - return TRUE if node n was declared inside a definition module for "C". + doFuncVarParam - detect whether the formal uses an opaque and ensure that the address of + the actual parameter is cast to the formal type. */ -static bool isDefForCNode (decl_node n) +static void doFuncVarParam (mcPretty_pretty p, decl_node__opaque actual, decl_node__opaque formal) { - nameKey_Name name; + decl_node__opaque type; - while ((n != NULL) && (! (((decl_isImp (n)) || (decl_isDef (n))) || (decl_isModule (n))))) + if ((nodeUsesOpaque (formal)) && (getNodeOpaqueFlushNecessary (actual, getNodeOpaqueVoidStar (formal)))) { - n = decl_getScope (n); + type = static_cast (decl_getType (static_cast (formal))); + outText (p, (const char *) "reinterpret_cast<", 17); + if (getNodeOpaqueVoidStar (formal)) + { + doTypeNameC (p, type); + mcPretty_setNeedSpace (p); + outText (p, (const char *) "*> (&", 5); + doExprC (p, actual); + outText (p, (const char *) ")", 1); + actual = makeOpaqueCast (actual, true); + } + else + { + doTypeNameC (p, type); + mcPretty_noSpace (p); + outText (p, (const char *) "__opaque *> (&", 14); + doExprC (p, actual); + outText (p, (const char *) ")", 1); + actual = makeOpaqueCast (actual, false); + } } - if ((n != NULL) && (decl_isImp (n))) + else { - name = decl_getSymName (n); - n = decl_lookupDef (name); + doAdrExprC (p, actual); } - return ((n != NULL) && (decl_isDef (n))) && (isDefForC (n)); - /* static analysis guarentees a RETURN statement will be used before here. */ - __builtin_unreachable (); } @@ -15398,10 +15428,10 @@ static bool isDefForCNode (decl_node n) doFuncParamC - */ -static void doFuncParamC (mcPretty_pretty p, decl_node actual, decl_node formal, decl_node func) +static void doFuncParamC (mcPretty_pretty p, decl_node__opaque actual, decl_node__opaque formal, decl_node__opaque func) { - decl_node ft; - decl_node at; + decl_node__opaque ft; + decl_node__opaque at; unsigned int lbr; if (formal == NULL) @@ -15410,16 +15440,16 @@ static void doFuncParamC (mcPretty_pretty p, decl_node actual, decl_node formal, } else { - ft = decl_skipType (decl_getType (formal)); - if (decl_isUnbounded (ft)) + ft = static_cast (decl_skipType (decl_getType (static_cast (formal)))); + if (decl_isUnbounded (static_cast (ft))) { doFuncUnbounded (p, actual, formal, ft, func); } else { - if ((isAProcType (ft)) && (decl_isProcedure (actual))) + if ((isAProcType (ft)) && (decl_isProcedure (static_cast (actual)))) { - if (decl_isVarParam (formal)) + if (decl_isVarParam (static_cast (formal))) { mcMetaError_metaError1 ((const char *) "{%1MDad} cannot be passed as a VAR parameter", 44, (const unsigned char *) &actual, (sizeof (actual)-1)); } @@ -15428,17 +15458,17 @@ static void doFuncParamC (mcPretty_pretty p, decl_node actual, decl_node formal, doProcedureParamC (p, actual, formal); } } - else if (((((decl_getType (actual)) != NULL) && (decl_isProcType (decl_skipType (decl_getType (actual))))) && (isAProcType (ft))) && (isForC (formal))) + else if (((((decl_getType (static_cast (actual))) != NULL) && (decl_isProcType (decl_skipType (decl_getType (static_cast (actual)))))) && (isAProcType (ft))) && (isForC (formal))) { /* avoid dangling else. */ - if (decl_isVarParam (formal)) + if (decl_isVarParam (static_cast (formal))) { mcMetaError_metaError2 ((const char *) "{%1MDad} cannot be passed as a VAR parameter to the definition for C module as the parameter requires a cast to the formal type {%2MDtad}", 137, (const unsigned char *) &actual, (sizeof (actual)-1), (const unsigned char *) &formal, (sizeof (formal)-1)); } else { outText (p, (const char *) "(", 1); - doFQNameC (p, decl_getType (formal)); + doFQNameC (p, static_cast (decl_getType (static_cast (formal)))); outText (p, (const char *) "_C", 2); outText (p, (const char *) ")", 1); mcPretty_setNeedSpace (p); @@ -15446,31 +15476,40 @@ static void doFuncParamC (mcPretty_pretty p, decl_node actual, decl_node formal, outText (p, (const char *) ".proc", 5); } } - else if ((((decl_getType (actual)) != NULL) && (decl_isProcType (decl_skipType (decl_getType (actual))))) && ((decl_getType (actual)) != (decl_getType (formal)))) + else if ((((decl_getType (static_cast (actual))) != NULL) && (decl_isProcType (decl_skipType (decl_getType (static_cast (actual)))))) && ((decl_getType (static_cast (actual))) != (decl_getType (static_cast (formal))))) { /* avoid dangling else. */ - if (decl_isVarParam (formal)) + if (decl_isVarParam (static_cast (formal))) { mcMetaError_metaError2 ((const char *) "{%1MDad} cannot be passed as a VAR parameter as the parameter requires a cast to the formal type {%2MDtad}", 106, (const unsigned char *) &actual, (sizeof (actual)-1), (const unsigned char *) &formal, (sizeof (formal)-1)); } else { - doCastC (p, decl_getType (formal), actual); + doCastC (p, static_cast (decl_getType (static_cast (formal))), actual); } } else { /* avoid dangling else. */ - lbr = checkSystemCast (p, actual, formal); - if (decl_isVarParam (formal)) + if (decl_isVarParam (static_cast (formal))) { - doAdrExprC (p, actual); + lbr = checkSystemCast (p, actual, formal); + doFuncVarParam (p, actual, formal); + emitN (p, (const char *) ")", 1, lbr); } else { - doExprC (p, actual); + if (nodeUsesOpaque (formal)) + { + forceCastOpaque (p, formal, actual, getNodeOpaqueVoidStar (formal)); + } + else + { + lbr = checkSystemCast (p, actual, formal); + doExprC (p, actual); + emitN (p, (const char *) ")", 1, lbr); + } } - emitN (p, (const char *) ")", 1, lbr); } } } @@ -15482,16 +15521,16 @@ static void doFuncParamC (mcPretty_pretty p, decl_node actual, decl_node formal, If the parameter is a vararg NIL is returned. */ -static decl_node getNthParamType (Indexing_Index l, unsigned int i) +static decl_node__opaque getNthParamType (Indexing_Index l, unsigned int i) { - decl_node p; + decl_node__opaque p; p = getNthParam (l, i); if (p != NULL) { - return decl_getType (p); + return static_cast (decl_getType (static_cast (p))); } - return NULL; + return static_cast (NULL); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -15502,9 +15541,9 @@ static decl_node getNthParamType (Indexing_Index l, unsigned int i) If the parameter is a vararg NIL is returned. */ -static decl_node getNthParam (Indexing_Index l, unsigned int i) +static decl_node__opaque getNthParam (Indexing_Index l, unsigned int i) { - decl_node p; + decl_node__opaque p; unsigned int j; unsigned int k; unsigned int h; @@ -15515,12 +15554,12 @@ static decl_node getNthParam (Indexing_Index l, unsigned int i) h = Indexing_HighIndice (l); while (j <= h) { - p = static_cast (Indexing_GetIndice (l, j)); - if (decl_isParam (p)) + p = static_cast (Indexing_GetIndice (l, j)); + if (decl_isParam (static_cast (p))) { k = identListLen (p->paramF.namelist); } - else if (decl_isVarParam (p)) + else if (decl_isVarParam (static_cast (p))) { /* avoid dangling else. */ k = identListLen (p->varparamF.namelist); @@ -15528,8 +15567,8 @@ static decl_node getNthParam (Indexing_Index l, unsigned int i) else { /* avoid dangling else. */ - mcDebug_assert (decl_isVarargs (p)); - return NULL; + mcDebug_assert (decl_isVarargs (static_cast (p))); + return static_cast (NULL); } if (i <= k) { @@ -15542,7 +15581,7 @@ static decl_node getNthParam (Indexing_Index l, unsigned int i) } } } - return NULL; + return static_cast (NULL); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -15552,10 +15591,10 @@ static decl_node getNthParam (Indexing_Index l, unsigned int i) doFuncArgsC - */ -static void doFuncArgsC (mcPretty_pretty p, decl_node s, Indexing_Index l, bool needParen) +static void doFuncArgsC (mcPretty_pretty p, decl_node__opaque s, Indexing_Index l, bool needParen) { - decl_node actual; - decl_node formal; + decl_node__opaque actual; + decl_node__opaque formal; unsigned int i; unsigned int n; @@ -15592,10 +15631,10 @@ static void doFuncArgsC (mcPretty_pretty p, decl_node s, Indexing_Index l, bool doProcTypeArgsC - */ -static void doProcTypeArgsC (mcPretty_pretty p, decl_node s, Indexing_Index args, bool needParen) +static void doProcTypeArgsC (mcPretty_pretty p, decl_node__opaque s, Indexing_Index args, bool needParen) { - decl_node a; - decl_node b; + decl_node__opaque a; + decl_node__opaque b; unsigned int i; unsigned int n; @@ -15610,7 +15649,7 @@ static void doProcTypeArgsC (mcPretty_pretty p, decl_node s, Indexing_Index args while (i <= n) { a = getExpList (s->funccallF.args, i); - b = static_cast (Indexing_GetIndice (args, i)); + b = static_cast (Indexing_GetIndice (args, i)); doFuncParamC (p, a, b, s->funccallF.function); if (i < n) { @@ -15632,41 +15671,39 @@ static void doProcTypeArgsC (mcPretty_pretty p, decl_node s, Indexing_Index args doAdrArgC - */ -static void doAdrArgC (mcPretty_pretty p, decl_node n) +static void doAdrArgC (mcPretty_pretty p, decl_node__opaque n) { if (isDeref (n)) { /* & and * cancel each other out. */ doExprC (p, n->unaryF.arg); } - else if ((decl_isVar (n)) && n->varF.isVarParameter) + else if ((decl_isVar (static_cast (n))) && n->varF.isVarParameter) { /* avoid dangling else. */ - outTextN (p, decl_getSymName (n)); /* --fixme-- does the caller need to cast it? */ + outTextN (p, decl_getSymName (static_cast (n))); /* --fixme-- does the caller need to cast it? */ } - else + else if ((isString (n)) || ((decl_isArray (decl_getType (static_cast (n)))) && (decl_isUnbounded (decl_getType (static_cast (n)))))) { /* avoid dangling else. */ - if (isString (n)) + if (lang == decl_ansiCP) { - if (lang == decl_ansiCP) - { - outText (p, (const char *) "const_cast (reinterpret_cast", 48); - outText (p, (const char *) "(", 1); - doExprC (p, n); - outText (p, (const char *) "))", 2); - } - else - { - doExprC (p, n); - } + outText (p, (const char *) "const_cast (static_cast", 43); + outText (p, (const char *) "(", 1); + doExprC (p, n); + outText (p, (const char *) "))", 2); } else { - outText (p, (const char *) "&", 1); doExprC (p, n); } } + else + { + /* avoid dangling else. */ + outText (p, (const char *) "&", 1); + doExprC (p, n); + } } @@ -15674,7 +15711,7 @@ static void doAdrArgC (mcPretty_pretty p, decl_node n) doAdrC - */ -static void doAdrC (mcPretty_pretty p, decl_node n) +static void doAdrC (mcPretty_pretty p, decl_node__opaque n) { mcDebug_assert (isUnary (n)); doAdrArgC (p, n->unaryF.arg); @@ -15685,7 +15722,7 @@ static void doAdrC (mcPretty_pretty p, decl_node n) doInc - */ -static void doInc (mcPretty_pretty p, decl_node n) +static void doInc (mcPretty_pretty p, decl_node__opaque n) { mcDebug_assert (isIntrinsic (n)); if (lang == decl_ansiCP) @@ -15703,7 +15740,7 @@ static void doInc (mcPretty_pretty p, decl_node n) doDec - */ -static void doDec (mcPretty_pretty p, decl_node n) +static void doDec (mcPretty_pretty p, decl_node__opaque n) { mcDebug_assert (isIntrinsic (n)); if (lang == decl_ansiCP) @@ -15721,7 +15758,7 @@ static void doDec (mcPretty_pretty p, decl_node n) doIncDecC - */ -static void doIncDecC (mcPretty_pretty p, decl_node n, const char *op_, unsigned int _op_high) +static void doIncDecC (mcPretty_pretty p, decl_node__opaque n, const char *op_, unsigned int _op_high) { char op[_op_high+1]; @@ -15751,10 +15788,10 @@ static void doIncDecC (mcPretty_pretty p, decl_node n, const char *op_, unsigned doIncDecCP - */ -static void doIncDecCP (mcPretty_pretty p, decl_node n, const char *op_, unsigned int _op_high) +static void doIncDecCP (mcPretty_pretty p, decl_node__opaque n, const char *op_, unsigned int _op_high) { - decl_node lhs; - decl_node type; + decl_node__opaque lhs; + decl_node__opaque type; char op[_op_high+1]; /* make a local copy of each unbounded array. */ @@ -15766,8 +15803,8 @@ static void doIncDecCP (mcPretty_pretty p, decl_node n, const char *op_, unsigne lhs = getExpList (n->intrinsicF.args, 1); doExprC (p, lhs); mcPretty_setNeedSpace (p); - type = decl_getType (lhs); - if ((decl_isPointer (type)) || (type == addressN)) + type = static_cast (decl_getType (static_cast (lhs))); + if ((decl_isPointer (static_cast (type))) || (type == addressN)) { /* cast to (char * ) and then back again after the arithmetic is complete. */ outText (p, (const char *) "=", 1); @@ -15790,7 +15827,7 @@ static void doIncDecCP (mcPretty_pretty p, decl_node n, const char *op_, unsigne } outText (p, (const char *) ")", 1); } - else if (decl_isEnumeration (decl_skipType (type))) + else if (decl_isEnumeration (decl_skipType (static_cast (type)))) { /* avoid dangling else. */ outText (p, (const char *) "= static_cast<", 14); @@ -15833,9 +15870,9 @@ static void doIncDecCP (mcPretty_pretty p, decl_node n, const char *op_, unsigne doInclC - */ -static void doInclC (mcPretty_pretty p, decl_node n) +static void doInclC (mcPretty_pretty p, decl_node__opaque n) { - decl_node lo; + decl_node__opaque lo; mcDebug_assert (isIntrinsic (n)); if (n->intrinsicF.args != NULL) @@ -15871,9 +15908,9 @@ static void doInclC (mcPretty_pretty p, decl_node n) doExclC - */ -static void doExclC (mcPretty_pretty p, decl_node n) +static void doExclC (mcPretty_pretty p, decl_node__opaque n) { - decl_node lo; + decl_node__opaque lo; mcDebug_assert (isIntrinsic (n)); if (n->intrinsicF.args != NULL) @@ -15909,9 +15946,9 @@ static void doExclC (mcPretty_pretty p, decl_node n) doNewC - */ -static void doNewC (mcPretty_pretty p, decl_node n) +static void doNewC (mcPretty_pretty p, decl_node__opaque n) { - decl_node t; + decl_node__opaque t; mcDebug_assert (isIntrinsic (n)); if (n->intrinsicF.args == NULL) @@ -15932,10 +15969,10 @@ static void doNewC (mcPretty_pretty p, decl_node n) doExprC (p, getExpList (n->intrinsicF.args, 1)); outText (p, (const char *) ",", 1); mcPretty_setNeedSpace (p); - t = decl_skipType (decl_getType (getExpList (n->intrinsicF.args, 1))); - if (decl_isPointer (t)) + t = static_cast (decl_skipType (decl_getType (static_cast (getExpList (n->intrinsicF.args, 1))))); + if (decl_isPointer (static_cast (t))) { - t = decl_getType (t); + t = static_cast (decl_getType (static_cast (t))); outText (p, (const char *) "sizeof", 6); mcPretty_setNeedSpace (p); outText (p, (const char *) "(", 1); @@ -15956,9 +15993,9 @@ static void doNewC (mcPretty_pretty p, decl_node n) doDisposeC - */ -static void doDisposeC (mcPretty_pretty p, decl_node n) +static void doDisposeC (mcPretty_pretty p, decl_node__opaque n) { - decl_node t; + decl_node__opaque t; mcDebug_assert (isIntrinsic (n)); if (n->intrinsicF.args == NULL) @@ -15979,10 +16016,10 @@ static void doDisposeC (mcPretty_pretty p, decl_node n) doExprC (p, getExpList (n->intrinsicF.args, 1)); outText (p, (const char *) ",", 1); mcPretty_setNeedSpace (p); - t = decl_skipType (decl_getType (getExpList (n->intrinsicF.args, 1))); - if (decl_isPointer (t)) + t = static_cast (decl_skipType (decl_getType (static_cast (getExpList (n->intrinsicF.args, 1))))); + if (decl_isPointer (static_cast (t))) { - t = decl_getType (t); + t = static_cast (decl_getType (static_cast (t))); outText (p, (const char *) "sizeof", 6); mcPretty_setNeedSpace (p); outText (p, (const char *) "(", 1); @@ -16008,7 +16045,7 @@ static void doDisposeC (mcPretty_pretty p, decl_node n) doCapC - */ -static void doCapC (mcPretty_pretty p, decl_node n) +static void doCapC (mcPretty_pretty p, decl_node__opaque n) { mcDebug_assert (isUnary (n)); if (n->unaryF.arg == NULL) @@ -16039,7 +16076,7 @@ static void doCapC (mcPretty_pretty p, decl_node n) doLengthC - */ -static void doLengthC (mcPretty_pretty p, decl_node n) +static void doLengthC (mcPretty_pretty p, decl_node__opaque n) { mcDebug_assert (isUnary (n)); if (n->unaryF.arg == NULL) @@ -16066,9 +16103,9 @@ static void doLengthC (mcPretty_pretty p, decl_node n) doAbsC - */ -static void doAbsC (mcPretty_pretty p, decl_node n) +static void doAbsC (mcPretty_pretty p, decl_node__opaque n) { - decl_node t; + decl_node__opaque t; mcDebug_assert (isUnary (n)); if (n->unaryF.arg == NULL) @@ -16125,7 +16162,7 @@ static void doAbsC (mcPretty_pretty p, decl_node n) doValC - */ -static void doValC (mcPretty_pretty p, decl_node n) +static void doValC (mcPretty_pretty p, decl_node__opaque n) { mcDebug_assert (isBinary (n)); outText (p, (const char *) "(", 1); @@ -16142,9 +16179,9 @@ static void doValC (mcPretty_pretty p, decl_node n) doMinC - */ -static void doMinC (mcPretty_pretty p, decl_node n) +static void doMinC (mcPretty_pretty p, decl_node__opaque n) { - decl_node t; + decl_node__opaque t; mcDebug_assert (isUnary (n)); t = getExprType (n->unaryF.arg); @@ -16156,9 +16193,9 @@ static void doMinC (mcPretty_pretty p, decl_node n) doMaxC - */ -static void doMaxC (mcPretty_pretty p, decl_node n) +static void doMaxC (mcPretty_pretty p, decl_node__opaque n) { - decl_node t; + decl_node__opaque t; mcDebug_assert (isUnary (n)); t = getExprType (n->unaryF.arg); @@ -16171,7 +16208,7 @@ static void doMaxC (mcPretty_pretty p, decl_node n) The intrinsic functions are represented as unary and binary nodes. */ -static bool isIntrinsic (decl_node n) +static bool isIntrinsic (decl_node__opaque n) { switch (n->kind) { @@ -16201,7 +16238,7 @@ static bool isIntrinsic (decl_node n) doHalt - */ -static void doHalt (mcPretty_pretty p, decl_node n) +static void doHalt (mcPretty_pretty p, decl_node__opaque n) { mcDebug_assert (n->kind == decl_halt); if ((n->intrinsicF.args == NULL) || ((expListLen (n->intrinsicF.args)) == 0)) @@ -16226,7 +16263,7 @@ static void doHalt (mcPretty_pretty p, decl_node n) doCreal - emit the appropriate creal function. */ -static void doCreal (mcPretty_pretty p, decl_node t) +static void doCreal (mcPretty_pretty p, decl_node__opaque t) { switch (t->kind) { @@ -16257,7 +16294,7 @@ static void doCreal (mcPretty_pretty p, decl_node t) doCimag - emit the appropriate cimag function. */ -static void doCimag (mcPretty_pretty p, decl_node t) +static void doCimag (mcPretty_pretty p, decl_node__opaque t) { switch (t->kind) { @@ -16288,9 +16325,9 @@ static void doCimag (mcPretty_pretty p, decl_node t) doReC - */ -static void doReC (mcPretty_pretty p, decl_node n) +static void doReC (mcPretty_pretty p, decl_node__opaque n) { - decl_node t; + decl_node__opaque t; mcDebug_assert (n->kind == decl_re); if (n->unaryF.arg != NULL) @@ -16314,9 +16351,9 @@ static void doReC (mcPretty_pretty p, decl_node n) doImC - */ -static void doImC (mcPretty_pretty p, decl_node n) +static void doImC (mcPretty_pretty p, decl_node__opaque n) { - decl_node t; + decl_node__opaque t; mcDebug_assert (n->kind == decl_im); if (n->unaryF.arg != NULL) @@ -16340,7 +16377,7 @@ static void doImC (mcPretty_pretty p, decl_node n) doCmplx - */ -static void doCmplx (mcPretty_pretty p, decl_node n) +static void doCmplx (mcPretty_pretty p, decl_node__opaque n) { mcDebug_assert (isBinary (n)); keyc_useComplex (); @@ -16365,7 +16402,7 @@ static void doCmplx (mcPretty_pretty p, decl_node n) doIntrinsicC - */ -static void doIntrinsicC (mcPretty_pretty p, decl_node n) +static void doIntrinsicC (mcPretty_pretty p, decl_node__opaque n) { mcDebug_assert (isIntrinsic (n)); doCommentC (p, n->intrinsicF.intrinsicComment.body); @@ -16421,7 +16458,7 @@ static void doIntrinsicC (mcPretty_pretty p, decl_node n) isIntrinsicFunction - returns true if, n, is an instrinsic function. */ -static bool isIntrinsicFunction (decl_node n) +static bool isIntrinsicFunction (decl_node__opaque n) { switch (n->kind) { @@ -16459,7 +16496,7 @@ static bool isIntrinsicFunction (decl_node n) doSizeC - */ -static void doSizeC (mcPretty_pretty p, decl_node n) +static void doSizeC (mcPretty_pretty p, decl_node__opaque n) { mcDebug_assert (isUnary (n)); outText (p, (const char *) "sizeof (", 8); @@ -16472,7 +16509,7 @@ static void doSizeC (mcPretty_pretty p, decl_node n) doConvertC - */ -static void doConvertC (mcPretty_pretty p, decl_node n, const char *conversion_, unsigned int _conversion_high) +static void doConvertC (mcPretty_pretty p, decl_node__opaque n, const char *conversion_, unsigned int _conversion_high) { DynamicStrings_String s; char conversion[_conversion_high+1]; @@ -16490,7 +16527,7 @@ static void doConvertC (mcPretty_pretty p, decl_node n, const char *conversion_, doConvertSC - */ -static void doConvertSC (mcPretty_pretty p, decl_node n, DynamicStrings_String conversion) +static void doConvertSC (mcPretty_pretty p, decl_node__opaque n, DynamicStrings_String conversion) { mcDebug_assert (isUnary (n)); mcPretty_setNeedSpace (p); @@ -16504,16 +16541,40 @@ static void doConvertSC (mcPretty_pretty p, decl_node n, DynamicStrings_String c } +/* + getFunction - return the function associate with funccall node n. +*/ + +static decl_node__opaque getFunction (decl_node__opaque n) +{ + mcDebug_assert (isFuncCall (n)); + switch (n->kind) + { + case decl_funccall: + return n->funccallF.function; + break; + + + default: + M2RTS_HALT (-1); + __builtin_unreachable (); + break; + } + ReturnException ("../../gcc/m2/mc/decl.def", 20, 1); + __builtin_unreachable (); +} + + /* getFuncFromExpr - */ -static decl_node getFuncFromExpr (decl_node n) +static decl_node__opaque getFuncFromExpr (decl_node__opaque n) { - n = decl_skipType (decl_getType (n)); - while ((n != procN) && (! (decl_isProcType (n)))) + n = static_cast (decl_skipType (decl_getType (static_cast (n)))); + while ((n != procN) && (! (decl_isProcType (static_cast (n))))) { - n = decl_skipType (decl_getType (n)); + n = static_cast (decl_skipType (decl_getType (static_cast (n)))); } return n; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -16525,12 +16586,12 @@ static decl_node getFuncFromExpr (decl_node n) doFuncExprC - */ -static void doFuncExprC (mcPretty_pretty p, decl_node n) +static void doFuncExprC (mcPretty_pretty p, decl_node__opaque n) { - decl_node t; + decl_node__opaque t; mcDebug_assert (isFuncCall (n)); - if (decl_isProcedure (n->funccallF.function)) + if (decl_isProcedure (static_cast (n->funccallF.function))) { doFQDNameC (p, n->funccallF.function, true); mcPretty_setNeedSpace (p); @@ -16546,11 +16607,11 @@ static void doFuncExprC (mcPretty_pretty p, decl_node n) mcPretty_setNeedSpace (p); if (t == procN) { - doProcTypeArgsC (p, n, NULL, true); + doProcTypeArgsC (p, n, static_cast (NULL), true); } else { - mcDebug_assert (decl_isProcType (t)); + mcDebug_assert (decl_isProcType (static_cast (t))); doProcTypeArgsC (p, n, t->proctypeF.parameters, true); } } @@ -16561,7 +16622,7 @@ static void doFuncExprC (mcPretty_pretty p, decl_node n) doFuncCallC - */ -static void doFuncCallC (mcPretty_pretty p, decl_node n) +static void doFuncCallC (mcPretty_pretty p, decl_node__opaque n) { doCommentC (p, n->funccallF.funccallComment.body); doFuncExprC (p, n); @@ -16574,7 +16635,7 @@ static void doFuncCallC (mcPretty_pretty p, decl_node n) doCaseStatementC - */ -static void doCaseStatementC (mcPretty_pretty p, decl_node n, bool needBreak) +static void doCaseStatementC (mcPretty_pretty p, decl_node__opaque n, bool needBreak) { p = mcPretty_pushPretty (p); mcPretty_setindent (p, (mcPretty_getindent (p))+indentationC); @@ -16591,7 +16652,7 @@ static void doCaseStatementC (mcPretty_pretty p, decl_node n, bool needBreak) doExceptionC - */ -static void doExceptionC (mcPretty_pretty p, const char *a_, unsigned int _a_high, decl_node n) +static void doExceptionC (mcPretty_pretty p, const char *a_, unsigned int _a_high, decl_node__opaque n) { unsigned int w; char a[_a_high+1]; @@ -16599,7 +16660,7 @@ static void doExceptionC (mcPretty_pretty p, const char *a_, unsigned int _a_hig /* make a local copy of each unbounded array. */ memcpy (a, a_, _a_high+1); - w = decl_getDeclaredMod (n); + w = decl_getDeclaredMod (static_cast (n)); outText (p, (const char *) a, _a_high); mcPretty_setNeedSpace (p); outText (p, (const char *) "(\"", 2); @@ -16619,7 +16680,7 @@ static void doExceptionC (mcPretty_pretty p, const char *a_, unsigned int _a_hig doExceptionCP - */ -static void doExceptionCP (mcPretty_pretty p, const char *a_, unsigned int _a_high, decl_node n) +static void doExceptionCP (mcPretty_pretty p, const char *a_, unsigned int _a_high, decl_node__opaque n) { unsigned int w; char a[_a_high+1]; @@ -16627,7 +16688,7 @@ static void doExceptionCP (mcPretty_pretty p, const char *a_, unsigned int _a_hi /* make a local copy of each unbounded array. */ memcpy (a, a_, _a_high+1); - w = decl_getDeclaredMod (n); + w = decl_getDeclaredMod (static_cast (n)); outText (p, (const char *) a, _a_high); mcPretty_setNeedSpace (p); outText (p, (const char *) "(\"", 2); @@ -16647,7 +16708,7 @@ static void doExceptionCP (mcPretty_pretty p, const char *a_, unsigned int _a_hi doException - */ -static void doException (mcPretty_pretty p, const char *a_, unsigned int _a_high, decl_node n) +static void doException (mcPretty_pretty p, const char *a_, unsigned int _a_high, decl_node__opaque n) { char a[_a_high+1]; @@ -16670,18 +16731,18 @@ static void doException (mcPretty_pretty p, const char *a_, unsigned int _a_high doRangeListC - */ -static void doRangeListC (mcPretty_pretty p, decl_node c) +static void doRangeListC (mcPretty_pretty p, decl_node__opaque c) { - decl_node r; + decl_node__opaque r; unsigned int i; unsigned int h; - mcDebug_assert (decl_isCaseList (c)); + mcDebug_assert (decl_isCaseList (static_cast (c))); i = 1; h = Indexing_HighIndice (c->caselistF.rangePairs); while (i <= h) { - r = static_cast (Indexing_GetIndice (c->caselistF.rangePairs, i)); + r = static_cast (Indexing_GetIndice (c->caselistF.rangePairs, i)); mcDebug_assert ((r->rangeF.hi == NULL) || (r->rangeF.lo == r->rangeF.hi)); outText (p, (const char *) "case", 4); mcPretty_setNeedSpace (p); @@ -16696,18 +16757,18 @@ static void doRangeListC (mcPretty_pretty p, decl_node c) doRangeIfListC - */ -static void doRangeIfListC (mcPretty_pretty p, decl_node e, decl_node c) +static void doRangeIfListC (mcPretty_pretty p, decl_node__opaque e, decl_node__opaque c) { - decl_node r; + decl_node__opaque r; unsigned int i; unsigned int h; - mcDebug_assert (decl_isCaseList (c)); + mcDebug_assert (decl_isCaseList (static_cast (c))); i = 1; h = Indexing_HighIndice (c->caselistF.rangePairs); while (i <= h) { - r = static_cast (Indexing_GetIndice (c->caselistF.rangePairs, i)); + r = static_cast (Indexing_GetIndice (c->caselistF.rangePairs, i)); if ((r->rangeF.lo != r->rangeF.hi) && (r->rangeF.hi != NULL)) { outText (p, (const char *) "((", 2); @@ -16756,9 +16817,9 @@ static void doRangeIfListC (mcPretty_pretty p, decl_node e, decl_node c) doCaseLabels - */ -static void doCaseLabels (mcPretty_pretty p, decl_node n, bool needBreak) +static void doCaseLabels (mcPretty_pretty p, decl_node__opaque n, bool needBreak) { - mcDebug_assert (decl_isCaseLabelList (n)); + mcDebug_assert (decl_isCaseLabelList (static_cast (n))); doRangeListC (p, n->caselabellistF.caseList); p = mcPretty_pushPretty (p); mcPretty_setindent (p, (mcPretty_getindent (p))+indentationC); @@ -16775,18 +16836,18 @@ static void doCaseLabels (mcPretty_pretty p, decl_node n, bool needBreak) doCaseLabelListC - */ -static void doCaseLabelListC (mcPretty_pretty p, decl_node n, bool haveElse) +static void doCaseLabelListC (mcPretty_pretty p, decl_node__opaque n, bool haveElse) { unsigned int i; unsigned int h; - decl_node c; + decl_node__opaque c; - mcDebug_assert (decl_isCase (n)); + mcDebug_assert (decl_isCase (static_cast (n))); i = 1; h = Indexing_HighIndice (n->caseF.caseLabelList); while (i <= h) { - c = static_cast (Indexing_GetIndice (n->caseF.caseLabelList, i)); + c = static_cast (Indexing_GetIndice (n->caseF.caseLabelList, i)); doCaseLabels (p, c, ((i < h) || haveElse) || caseException); i += 1; } @@ -16797,9 +16858,9 @@ static void doCaseLabelListC (mcPretty_pretty p, decl_node n, bool haveElse) doCaseIfLabels - */ -static void doCaseIfLabels (mcPretty_pretty p, decl_node e, decl_node n, unsigned int i, unsigned int h) +static void doCaseIfLabels (mcPretty_pretty p, decl_node__opaque e, decl_node__opaque n, unsigned int i, unsigned int h) { - mcDebug_assert (decl_isCaseLabelList (n)); + mcDebug_assert (decl_isCaseLabelList (static_cast (n))); if (i > 1) { outText (p, (const char *) "else", 4); @@ -16827,18 +16888,18 @@ static void doCaseIfLabels (mcPretty_pretty p, decl_node e, decl_node n, unsigne doCaseIfLabelListC - */ -static void doCaseIfLabelListC (mcPretty_pretty p, decl_node n) +static void doCaseIfLabelListC (mcPretty_pretty p, decl_node__opaque n) { unsigned int i; unsigned int h; - decl_node c; + decl_node__opaque c; - mcDebug_assert (decl_isCase (n)); + mcDebug_assert (decl_isCase (static_cast (n))); i = 1; h = Indexing_HighIndice (n->caseF.caseLabelList); while (i <= h) { - c = static_cast (Indexing_GetIndice (n->caseF.caseLabelList, i)); + c = static_cast (Indexing_GetIndice (n->caseF.caseLabelList, i)); doCaseIfLabels (p, n->caseF.expression, c, i, h); i += 1; } @@ -16849,9 +16910,9 @@ static void doCaseIfLabelListC (mcPretty_pretty p, decl_node n) doCaseElseC - */ -static void doCaseElseC (mcPretty_pretty p, decl_node n) +static void doCaseElseC (mcPretty_pretty p, decl_node__opaque n) { - mcDebug_assert (decl_isCase (n)); + mcDebug_assert (decl_isCase (static_cast (n))); if (n->caseF.else_ == NULL) { /* avoid dangling else. */ @@ -16876,9 +16937,9 @@ static void doCaseElseC (mcPretty_pretty p, decl_node n) doCaseIfElseC - */ -static void doCaseIfElseC (mcPretty_pretty p, decl_node n) +static void doCaseIfElseC (mcPretty_pretty p, decl_node__opaque n) { - mcDebug_assert (decl_isCase (n)); + mcDebug_assert (decl_isCase (static_cast (n))); if (n->caseF.else_ == NULL) { /* avoid dangling else. */ @@ -16908,20 +16969,20 @@ static void doCaseIfElseC (mcPretty_pretty p, decl_node n) single values and not ranges. */ -static bool canUseSwitchCaseLabels (decl_node n) +static bool canUseSwitchCaseLabels (decl_node__opaque n) { unsigned int i; unsigned int h; - decl_node r; - decl_node l; + decl_node__opaque r; + decl_node__opaque l; - mcDebug_assert (decl_isCaseLabelList (n)); + mcDebug_assert (decl_isCaseLabelList (static_cast (n))); l = n->caselabellistF.caseList; i = 1; h = Indexing_HighIndice (l->caselistF.rangePairs); while (i <= h) { - r = static_cast (Indexing_GetIndice (l->caselistF.rangePairs, i)); + r = static_cast (Indexing_GetIndice (l->caselistF.rangePairs, i)); if ((r->rangeF.hi != NULL) && (r->rangeF.lo != r->rangeF.hi)) { return false; @@ -16940,18 +17001,18 @@ static bool canUseSwitchCaseLabels (decl_node n) selectors are single values rather than ranges. */ -static bool canUseSwitch (decl_node n) +static bool canUseSwitch (decl_node__opaque n) { unsigned int i; unsigned int h; - decl_node c; + decl_node__opaque c; - mcDebug_assert (decl_isCase (n)); + mcDebug_assert (decl_isCase (static_cast (n))); i = 1; h = Indexing_HighIndice (n->caseF.caseLabelList); while (i <= h) { - c = static_cast (Indexing_GetIndice (n->caseF.caseLabelList, i)); + c = static_cast (Indexing_GetIndice (n->caseF.caseLabelList, i)); if (! (canUseSwitchCaseLabels (c))) { return false; @@ -16968,11 +17029,11 @@ static bool canUseSwitch (decl_node n) doCaseC - */ -static void doCaseC (mcPretty_pretty p, decl_node n) +static void doCaseC (mcPretty_pretty p, decl_node__opaque n) { unsigned int i; - mcDebug_assert (decl_isCase (n)); + mcDebug_assert (decl_isCase (static_cast (n))); if (canUseSwitch (n)) { i = mcPretty_getindent (p); @@ -17004,9 +17065,9 @@ static void doCaseC (mcPretty_pretty p, decl_node n) doLoopC - */ -static void doLoopC (mcPretty_pretty p, decl_node s) +static void doLoopC (mcPretty_pretty p, decl_node__opaque s) { - mcDebug_assert (decl_isLoop (s)); + mcDebug_assert (decl_isLoop (static_cast (s))); outText (p, (const char *) "for (;;)\\n", 10); outText (p, (const char *) "{\\n", 3); p = mcPretty_pushPretty (p); @@ -17021,9 +17082,9 @@ static void doLoopC (mcPretty_pretty p, decl_node s) doExitC - */ -static void doExitC (mcPretty_pretty p, decl_node s) +static void doExitC (mcPretty_pretty p, decl_node__opaque s) { - mcDebug_assert (decl_isExit (s)); + mcDebug_assert (decl_isExit (static_cast (s))); outText (p, (const char *) "/* exit. */\\n", 14); } @@ -17032,11 +17093,11 @@ static void doExitC (mcPretty_pretty p, decl_node s) doStatementsC - */ -static void doStatementsC (mcPretty_pretty p, decl_node s) +static void doStatementsC (mcPretty_pretty p, decl_node__opaque s) { if (s == NULL) {} /* empty. */ - else if (decl_isStatementSequence (s)) + else if (decl_isStatementSequence (static_cast (s))) { /* avoid dangling else. */ doStatementSequenceC (p, s); @@ -17046,12 +17107,12 @@ static void doStatementsC (mcPretty_pretty p, decl_node s) /* avoid dangling else. */ doCommentC (p, s); } - else if (decl_isExit (s)) + else if (decl_isExit (static_cast (s))) { /* avoid dangling else. */ doExitC (p, s); } - else if (decl_isReturn (s)) + else if (decl_isReturn (static_cast (s))) { /* avoid dangling else. */ doReturnC (p, s); @@ -17061,22 +17122,22 @@ static void doStatementsC (mcPretty_pretty p, decl_node s) /* avoid dangling else. */ doAssignmentC (p, s); } - else if (decl_isIf (s)) + else if (decl_isIf (static_cast (s))) { /* avoid dangling else. */ doIfC (p, s); } - else if (decl_isFor (s)) + else if (decl_isFor (static_cast (s))) { /* avoid dangling else. */ doForC (p, s); } - else if (decl_isRepeat (s)) + else if (decl_isRepeat (static_cast (s))) { /* avoid dangling else. */ doRepeatC (p, s); } - else if (decl_isWhile (s)) + else if (decl_isWhile (static_cast (s))) { /* avoid dangling else. */ doWhileC (p, s); @@ -17091,17 +17152,17 @@ static void doStatementsC (mcPretty_pretty p, decl_node s) /* avoid dangling else. */ doFuncCallC (p, s); } - else if (decl_isCase (s)) + else if (decl_isCase (static_cast (s))) { /* avoid dangling else. */ doCaseC (p, s); } - else if (decl_isLoop (s)) + else if (decl_isLoop (static_cast (s))) { /* avoid dangling else. */ doLoopC (p, s); } - else if (decl_isExit (s)) + else if (decl_isExit (static_cast (s))) { /* avoid dangling else. */ doExitC (p, s); @@ -17114,7 +17175,7 @@ static void doStatementsC (mcPretty_pretty p, decl_node s) } } -static void stop (void) +static void localstop (void) { } @@ -17148,12 +17209,12 @@ static void doLocalConstTypesC (mcPretty_pretty p, decl_scopeT s) addParamDone - */ -static void addParamDone (decl_node n) +static void addParamDone (decl_node__opaque n) { - if ((decl_isVar (n)) && n->varF.isParameter) + if ((decl_isVar (static_cast (n))) && n->varF.isParameter) { addDone (n); - addDone (decl_getType (n)); + addDone (static_cast (decl_getType (static_cast (n)))); } } @@ -17162,9 +17223,9 @@ static void addParamDone (decl_node n) includeParameters - */ -static void includeParameters (decl_node n) +static void includeParameters (decl_node__opaque n) { - mcDebug_assert (decl_isProcedure (n)); + mcDebug_assert (decl_isProcedure (static_cast (n))); Indexing_ForeachIndiceInIndexDo (n->procedureF.decls.variables, (Indexing_IndexProcedure) {(Indexing_IndexProcedure_t) addParamDone}); } @@ -17173,7 +17234,7 @@ static void includeParameters (decl_node n) isHalt - */ -static bool isHalt (decl_node n) +static bool isHalt (decl_node__opaque n) { return n->kind == decl_halt; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -17185,9 +17246,9 @@ static bool isHalt (decl_node n) isReturnOrHalt - */ -static bool isReturnOrHalt (decl_node n) +static bool isReturnOrHalt (decl_node__opaque n) { - return (isHalt (n)) || (decl_isReturn (n)); + return (isHalt (n)) || (decl_isReturn (static_cast (n))); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -17197,7 +17258,7 @@ static bool isReturnOrHalt (decl_node n) isLastStatementReturn - */ -static bool isLastStatementReturn (decl_node n) +static bool isLastStatementReturn (decl_node__opaque n) { return isLastStatement (n, (decl_isNodeF) {(decl_isNodeF_t) isReturnOrHalt}); /* static analysis guarentees a RETURN statement will be used before here. */ @@ -17209,15 +17270,15 @@ static bool isLastStatementReturn (decl_node n) isLastStatementSequence - */ -static bool isLastStatementSequence (decl_node n, decl_isNodeF q) +static bool isLastStatementSequence (decl_node__opaque n, decl_isNodeF q) { unsigned int h; - mcDebug_assert (decl_isStatementSequence (n)); + mcDebug_assert (decl_isStatementSequence (static_cast (n))); h = Indexing_HighIndice (n->stmtF.statements); if (h > 0) { - return isLastStatement (reinterpret_cast (Indexing_GetIndice (n->stmtF.statements, h)), q); + return isLastStatement (static_cast (Indexing_GetIndice (n->stmtF.statements, h)), q); } return false; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -17229,11 +17290,11 @@ static bool isLastStatementSequence (decl_node n, decl_isNodeF q) isLastStatementIf - */ -static bool isLastStatementIf (decl_node n, decl_isNodeF q) +static bool isLastStatementIf (decl_node__opaque n, decl_isNodeF q) { bool ret; - mcDebug_assert (decl_isIf (n)); + mcDebug_assert (decl_isIf (static_cast (n))); ret = true; if ((n->ifF.elsif != NULL) && ret) { @@ -17257,11 +17318,11 @@ static bool isLastStatementIf (decl_node n, decl_isNodeF q) isLastStatementElsif - */ -static bool isLastStatementElsif (decl_node n, decl_isNodeF q) +static bool isLastStatementElsif (decl_node__opaque n, decl_isNodeF q) { bool ret; - mcDebug_assert (decl_isElsif (n)); + mcDebug_assert (decl_isElsif (static_cast (n))); ret = true; if ((n->elsifF.elsif != NULL) && ret) { @@ -17285,21 +17346,21 @@ static bool isLastStatementElsif (decl_node n, decl_isNodeF q) isLastStatementCase - */ -static bool isLastStatementCase (decl_node n, decl_isNodeF q) +static bool isLastStatementCase (decl_node__opaque n, decl_isNodeF q) { bool ret; unsigned int i; unsigned int h; - decl_node c; + decl_node__opaque c; ret = true; - mcDebug_assert (decl_isCase (n)); + mcDebug_assert (decl_isCase (static_cast (n))); i = 1; h = Indexing_HighIndice (n->caseF.caseLabelList); while (i <= h) { - c = static_cast (Indexing_GetIndice (n->caseF.caseLabelList, i)); - mcDebug_assert (decl_isCaseLabelList (c)); + c = static_cast (Indexing_GetIndice (n->caseF.caseLabelList, i)); + mcDebug_assert (decl_isCaseLabelList (static_cast (c))); ret = ret && (isLastStatement (c->caselabellistF.statements, q)); i += 1; } @@ -17317,7 +17378,7 @@ static bool isLastStatementCase (decl_node n, decl_isNodeF q) isLastStatement - returns TRUE if the last statement in, n, is, q. */ -static bool isLastStatement (decl_node n, decl_isNodeF q) +static bool isLastStatement (decl_node__opaque n, decl_isNodeF q) { bool ret; @@ -17325,33 +17386,33 @@ static bool isLastStatement (decl_node n, decl_isNodeF q) { return false; } - else if (decl_isStatementSequence (n)) + else if (decl_isStatementSequence (static_cast (n))) { /* avoid dangling else. */ return isLastStatementSequence (n, q); } - else if (decl_isProcedure (n)) + else if (decl_isProcedure (static_cast (n))) { /* avoid dangling else. */ - mcDebug_assert (decl_isProcedure (n)); + mcDebug_assert (decl_isProcedure (static_cast (n))); return isLastStatement (n->procedureF.beginStatements, q); } - else if (decl_isIf (n)) + else if (decl_isIf (static_cast (n))) { /* avoid dangling else. */ return isLastStatementIf (n, q); } - else if (decl_isElsif (n)) + else if (decl_isElsif (static_cast (n))) { /* avoid dangling else. */ return isLastStatementElsif (n, q); } - else if (decl_isCase (n)) + else if (decl_isCase (static_cast (n))) { /* avoid dangling else. */ return isLastStatementCase (n, q); } - else if ((*q.proc) (n)) + else if ((*q.proc) (static_cast (n))) { /* avoid dangling else. */ return true; @@ -17366,13 +17427,13 @@ static bool isLastStatement (decl_node n, decl_isNodeF q) doProcedureC - */ -static void doProcedureC (decl_node n) +static void doProcedureC (decl_node__opaque n) { unsigned int s; outText (doP, (const char *) "\\n", 2); includeParameters (n); - keyc_enterScope (n); + keyc_enterScope (static_cast (n)); doProcedureHeadingC (n, false); outText (doP, (const char *) "\\n", 2); doP = outKc (doP, (const char *) "{\\n", 3); @@ -17402,7 +17463,7 @@ static void doProcedureC (decl_node n) } } doP = outKc (doP, (const char *) "}\\n", 3); - keyc_leaveScope (n); + keyc_leaveScope (static_cast (n)); } @@ -17425,13 +17486,13 @@ static void outProceduresC (mcPretty_pretty p, decl_scopeT s) output - */ -static void output (decl_node n, decl_nodeProcedure c, decl_nodeProcedure t, decl_nodeProcedure v) +static void output (decl_node__opaque n, decl_nodeProcedure c, decl_nodeProcedure t, decl_nodeProcedure v) { - if (decl_isConst (n)) + if (decl_isConst (static_cast (n))) { (*c.proc) (n); } - else if (decl_isVar (n)) + else if (decl_isVar (static_cast (n))) { /* avoid dangling else. */ (*v.proc) (n); @@ -17448,7 +17509,7 @@ static void output (decl_node n, decl_nodeProcedure c, decl_nodeProcedure t, dec allDependants - */ -static decl_dependentState allDependants (decl_node n) +static decl_dependentState allDependants (decl_node__opaque n) { alists_alist l; decl_dependentState s; @@ -17466,7 +17527,7 @@ static decl_dependentState allDependants (decl_node n) walkDependants - */ -static decl_dependentState walkDependants (alists_alist l, decl_node n) +static decl_dependentState walkDependants (alists_alist l, decl_node__opaque n) { if ((n == NULL) || (alists_isItemInList (globalGroup->doneQ, reinterpret_cast (n)))) { @@ -17492,11 +17553,11 @@ static decl_dependentState walkDependants (alists_alist l, decl_node n) walkType - */ -static decl_dependentState walkType (alists_alist l, decl_node n) +static decl_dependentState walkType (alists_alist l, decl_node__opaque n) { - decl_node t; + decl_node__opaque t; - t = decl_getType (n); + t = static_cast (decl_getType (static_cast (n))); if (alists_isItemInList (globalGroup->doneQ, reinterpret_cast (t))) { return decl_completed; @@ -17521,7 +17582,7 @@ static decl_dependentState walkType (alists_alist l, decl_node n) db - */ -static void db (const char *a_, unsigned int _a_high, decl_node n) +static void db (const char *a_, unsigned int _a_high, decl_node__opaque n) { char a[_a_high+1]; @@ -17561,7 +17622,7 @@ static void dbt (const char *a_, unsigned int _a_high) dbs - */ -static void dbs (decl_dependentState s, decl_node n) +static void dbs (decl_dependentState s, decl_node__opaque n) { if (mcOptions_getDebugTopological ()) { @@ -17601,7 +17662,7 @@ static void dbs (decl_dependentState s, decl_node n) dbq - */ -static void dbq (decl_node n) +static void dbq (decl_node__opaque n) { if (mcOptions_getDebugTopological ()) { @@ -17631,13 +17692,13 @@ static void dbq (decl_node n) walkRecord - */ -static decl_dependentState walkRecord (alists_alist l, decl_node n) +static decl_dependentState walkRecord (alists_alist l, decl_node__opaque n) { decl_dependentState s; unsigned int o; unsigned int i; unsigned int t; - decl_node q; + decl_node__opaque q; i = Indexing_LowIndice (n->recordF.listOfSons); t = Indexing_HighIndice (n->recordF.listOfSons); @@ -17647,9 +17708,9 @@ static decl_dependentState walkRecord (alists_alist l, decl_node n) dbq (n); while (i <= t) { - q = static_cast (Indexing_GetIndice (n->recordF.listOfSons, i)); + q = static_cast (Indexing_GetIndice (n->recordF.listOfSons, i)); db ((const char *) "", 0, q); - if ((decl_isRecordField (q)) && q->recordfieldF.tag) + if ((decl_isRecordField (static_cast (q))) && q->recordfieldF.tag) {} /* empty. */ else { @@ -17660,7 +17721,7 @@ static decl_dependentState walkRecord (alists_alist l, decl_node n) dbs (s, q); addTodo (n); dbq (n); - db ((const char *) "\\n", 2, NULL); + db ((const char *) "\\n", 2, static_cast (NULL)); mcPretty_setindent (doP, o); return s; } @@ -17680,12 +17741,12 @@ static decl_dependentState walkRecord (alists_alist l, decl_node n) walkVarient - */ -static decl_dependentState walkVarient (alists_alist l, decl_node n) +static decl_dependentState walkVarient (alists_alist l, decl_node__opaque n) { decl_dependentState s; unsigned int i; unsigned int t; - decl_node q; + decl_node__opaque q; db ((const char *) "\\nwalking", 9, n); s = walkDependants (l, n->varientF.tag); @@ -17693,20 +17754,20 @@ static decl_dependentState walkVarient (alists_alist l, decl_node n) { dbs (s, n->varientF.tag); dbq (n->varientF.tag); - db ((const char *) "\\n", 2, NULL); + db ((const char *) "\\n", 2, static_cast (NULL)); return s; } i = Indexing_LowIndice (n->varientF.listOfSons); t = Indexing_HighIndice (n->varientF.listOfSons); while (i <= t) { - q = static_cast (Indexing_GetIndice (n->varientF.listOfSons, i)); + q = static_cast (Indexing_GetIndice (n->varientF.listOfSons, i)); db ((const char *) "", 0, q); s = walkDependants (l, q); if (s != decl_completed) { dbs (s, q); - db ((const char *) "\\n", 2, NULL); + db ((const char *) "\\n", 2, static_cast (NULL)); return s; } i += 1; @@ -17723,7 +17784,7 @@ static decl_dependentState walkVarient (alists_alist l, decl_node n) queueBlocked - */ -static void queueBlocked (decl_node n) +static void queueBlocked (decl_node__opaque n) { if (! ((alists_isItemInList (globalGroup->doneQ, reinterpret_cast (n))) || (alists_isItemInList (globalGroup->partialQ, reinterpret_cast (n))))) { @@ -17736,11 +17797,11 @@ static void queueBlocked (decl_node n) walkVar - */ -static decl_dependentState walkVar (alists_alist l, decl_node n) +static decl_dependentState walkVar (alists_alist l, decl_node__opaque n) { - decl_node t; + decl_node__opaque t; - t = decl_getType (n); + t = static_cast (decl_getType (static_cast (n))); if (alists_isItemInList (globalGroup->doneQ, reinterpret_cast (t))) { return decl_completed; @@ -17759,19 +17820,19 @@ static decl_dependentState walkVar (alists_alist l, decl_node n) walkEnumeration - */ -static decl_dependentState walkEnumeration (alists_alist l, decl_node n) +static decl_dependentState walkEnumeration (alists_alist l, decl_node__opaque n) { decl_dependentState s; unsigned int i; unsigned int t; - decl_node q; + decl_node__opaque q; i = Indexing_LowIndice (n->enumerationF.listOfSons); t = Indexing_HighIndice (n->enumerationF.listOfSons); s = decl_completed; while (i <= t) { - q = static_cast (Indexing_GetIndice (n->enumerationF.listOfSons, i)); + q = static_cast (Indexing_GetIndice (n->enumerationF.listOfSons, i)); s = walkDependants (l, q); if (s != decl_completed) { @@ -17789,7 +17850,7 @@ static decl_dependentState walkEnumeration (alists_alist l, decl_node n) walkSubrange - */ -static decl_dependentState walkSubrange (alists_alist l, decl_node n) +static decl_dependentState walkSubrange (alists_alist l, decl_node__opaque n) { decl_dependentState s; @@ -17818,7 +17879,7 @@ static decl_dependentState walkSubrange (alists_alist l, decl_node n) walkSubscript - */ -static decl_dependentState walkSubscript (alists_alist l, decl_node n) +static decl_dependentState walkSubscript (alists_alist l, decl_node__opaque n) { decl_dependentState s; @@ -17842,12 +17903,12 @@ static decl_dependentState walkSubscript (alists_alist l, decl_node n) walkPointer - */ -static decl_dependentState walkPointer (alists_alist l, decl_node n) +static decl_dependentState walkPointer (alists_alist l, decl_node__opaque n) { - decl_node t; + decl_node__opaque t; /* if the type of, n, is done or partial then we can output pointer. */ - t = decl_getType (n); + t = static_cast (decl_getType (static_cast (n))); if ((alists_isItemInList (globalGroup->partialQ, reinterpret_cast (t))) || (alists_isItemInList (globalGroup->doneQ, reinterpret_cast (t)))) { /* pointer to partial can always generate a complete type. */ @@ -17863,7 +17924,7 @@ static decl_dependentState walkPointer (alists_alist l, decl_node n) walkArray - */ -static decl_dependentState walkArray (alists_alist l, decl_node n) +static decl_dependentState walkArray (alists_alist l, decl_node__opaque n) { decl_dependentState s; @@ -17892,7 +17953,7 @@ static decl_dependentState walkArray (alists_alist l, decl_node n) walkConst - */ -static decl_dependentState walkConst (alists_alist l, decl_node n) +static decl_dependentState walkConst (alists_alist l, decl_node__opaque n) { decl_dependentState s; @@ -17916,11 +17977,11 @@ static decl_dependentState walkConst (alists_alist l, decl_node n) walkVarParam - */ -static decl_dependentState walkVarParam (alists_alist l, decl_node n) +static decl_dependentState walkVarParam (alists_alist l, decl_node__opaque n) { - decl_node t; + decl_node__opaque t; - t = decl_getType (n); + t = static_cast (decl_getType (static_cast (n))); if (alists_isItemInList (globalGroup->partialQ, reinterpret_cast (t))) { /* parameter can be issued from a partial. */ @@ -17936,11 +17997,11 @@ static decl_dependentState walkVarParam (alists_alist l, decl_node n) walkParam - */ -static decl_dependentState walkParam (alists_alist l, decl_node n) +static decl_dependentState walkParam (alists_alist l, decl_node__opaque n) { - decl_node t; + decl_node__opaque t; - t = decl_getType (n); + t = static_cast (decl_getType (static_cast (n))); if (alists_isItemInList (globalGroup->partialQ, reinterpret_cast (t))) { /* parameter can be issued from a partial. */ @@ -17956,11 +18017,11 @@ static decl_dependentState walkParam (alists_alist l, decl_node n) walkOptarg - */ -static decl_dependentState walkOptarg (alists_alist l, decl_node n) +static decl_dependentState walkOptarg (alists_alist l, decl_node__opaque n) { - decl_node t; + decl_node__opaque t; - t = decl_getType (n); + t = static_cast (decl_getType (static_cast (n))); if (alists_isItemInList (globalGroup->partialQ, reinterpret_cast (t))) { /* parameter can be issued from a partial. */ @@ -17976,13 +18037,13 @@ static decl_dependentState walkOptarg (alists_alist l, decl_node n) walkRecordField - */ -static decl_dependentState walkRecordField (alists_alist l, decl_node n) +static decl_dependentState walkRecordField (alists_alist l, decl_node__opaque n) { - decl_node t; + decl_node__opaque t; decl_dependentState s; - mcDebug_assert (decl_isRecordField (n)); - t = decl_getType (n); + mcDebug_assert (decl_isRecordField (static_cast (n))); + t = static_cast (decl_getType (static_cast (n))); if (alists_isItemInList (globalGroup->partialQ, reinterpret_cast (t))) { dbs (decl_partial, n); @@ -18013,19 +18074,19 @@ static decl_dependentState walkRecordField (alists_alist l, decl_node n) walkVarientField - */ -static decl_dependentState walkVarientField (alists_alist l, decl_node n) +static decl_dependentState walkVarientField (alists_alist l, decl_node__opaque n) { decl_dependentState s; unsigned int i; unsigned int t; - decl_node q; + decl_node__opaque q; i = Indexing_LowIndice (n->varientfieldF.listOfSons); t = Indexing_HighIndice (n->varientfieldF.listOfSons); s = decl_completed; while (i <= t) { - q = static_cast (Indexing_GetIndice (n->varientfieldF.listOfSons, i)); + q = static_cast (Indexing_GetIndice (n->varientfieldF.listOfSons, i)); s = walkDependants (l, q); if (s != decl_completed) { @@ -18046,7 +18107,7 @@ static decl_dependentState walkVarientField (alists_alist l, decl_node n) walkEnumerationField - */ -static decl_dependentState walkEnumerationField (alists_alist l, decl_node n) +static decl_dependentState walkEnumerationField (alists_alist l, decl_node__opaque n) { return decl_completed; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -18058,9 +18119,9 @@ static decl_dependentState walkEnumerationField (alists_alist l, decl_node n) walkSet - */ -static decl_dependentState walkSet (alists_alist l, decl_node n) +static decl_dependentState walkSet (alists_alist l, decl_node__opaque n) { - return walkDependants (l, decl_getType (n)); + return walkDependants (l, static_cast (decl_getType (static_cast (n)))); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -18070,12 +18131,12 @@ static decl_dependentState walkSet (alists_alist l, decl_node n) walkProcType - */ -static decl_dependentState walkProcType (alists_alist l, decl_node n) +static decl_dependentState walkProcType (alists_alist l, decl_node__opaque n) { decl_dependentState s; - decl_node t; + decl_node__opaque t; - t = decl_getType (n); + t = static_cast (decl_getType (static_cast (n))); if (alists_isItemInList (globalGroup->partialQ, reinterpret_cast (t))) {} /* empty. */ else @@ -18097,11 +18158,11 @@ static decl_dependentState walkProcType (alists_alist l, decl_node n) walkProcedure - */ -static decl_dependentState walkProcedure (alists_alist l, decl_node n) +static decl_dependentState walkProcedure (alists_alist l, decl_node__opaque n) { decl_dependentState s; - s = walkDependants (l, decl_getType (n)); + s = walkDependants (l, static_cast (decl_getType (static_cast (n)))); if (s != decl_completed) { return s; @@ -18121,13 +18182,13 @@ static decl_dependentState walkParameters (alists_alist l, Indexing_Index p) decl_dependentState s; unsigned int i; unsigned int h; - decl_node q; + decl_node__opaque q; i = Indexing_LowIndice (p); h = Indexing_HighIndice (p); while (i <= h) { - q = static_cast (Indexing_GetIndice (p, i)); + q = static_cast (Indexing_GetIndice (p, i)); s = walkDependants (l, q); if (s != decl_completed) { @@ -18145,7 +18206,7 @@ static decl_dependentState walkParameters (alists_alist l, Indexing_Index p) walkFuncCall - */ -static decl_dependentState walkFuncCall (alists_alist l, decl_node n) +static decl_dependentState walkFuncCall (alists_alist l, decl_node__opaque n) { return decl_completed; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -18157,7 +18218,7 @@ static decl_dependentState walkFuncCall (alists_alist l, decl_node n) walkUnary - */ -static decl_dependentState walkUnary (alists_alist l, decl_node n) +static decl_dependentState walkUnary (alists_alist l, decl_node__opaque n) { decl_dependentState s; @@ -18176,7 +18237,7 @@ static decl_dependentState walkUnary (alists_alist l, decl_node n) walkBinary - */ -static decl_dependentState walkBinary (alists_alist l, decl_node n) +static decl_dependentState walkBinary (alists_alist l, decl_node__opaque n) { decl_dependentState s; @@ -18200,7 +18261,7 @@ static decl_dependentState walkBinary (alists_alist l, decl_node n) walkComponentRef - */ -static decl_dependentState walkComponentRef (alists_alist l, decl_node n) +static decl_dependentState walkComponentRef (alists_alist l, decl_node__opaque n) { decl_dependentState s; @@ -18224,7 +18285,7 @@ static decl_dependentState walkComponentRef (alists_alist l, decl_node n) walkPointerRef - */ -static decl_dependentState walkPointerRef (alists_alist l, decl_node n) +static decl_dependentState walkPointerRef (alists_alist l, decl_node__opaque n) { decl_dependentState s; @@ -18248,13 +18309,13 @@ static decl_dependentState walkPointerRef (alists_alist l, decl_node n) walkSetValue - */ -static decl_dependentState walkSetValue (alists_alist l, decl_node n) +static decl_dependentState walkSetValue (alists_alist l, decl_node__opaque n) { decl_dependentState s; unsigned int i; unsigned int j; - mcDebug_assert (decl_isSetValue (n)); + mcDebug_assert (decl_isSetValue (static_cast (n))); s = walkDependants (l, n->setvalueF.type); if (s != decl_completed) { @@ -18264,7 +18325,7 @@ static decl_dependentState walkSetValue (alists_alist l, decl_node n) j = Indexing_HighIndice (n->setvalueF.values); while (i <= j) { - s = walkDependants (l, reinterpret_cast (Indexing_GetIndice (n->setvalueF.values, i))); + s = walkDependants (l, static_cast (Indexing_GetIndice (n->setvalueF.values, i))); if (s != decl_completed) { return s; @@ -18282,7 +18343,7 @@ static decl_dependentState walkSetValue (alists_alist l, decl_node n) all dependants have been declared. */ -static decl_dependentState doDependants (alists_alist l, decl_node n) +static decl_dependentState doDependants (alists_alist l, decl_node__opaque n) { switch (n->kind) { @@ -18490,15 +18551,15 @@ static decl_dependentState doDependants (alists_alist l, decl_node n) tryComplete - returns TRUE if node, n, can be and was completed. */ -static bool tryComplete (decl_node n, decl_nodeProcedure c, decl_nodeProcedure t, decl_nodeProcedure v) +static bool tryComplete (decl_node__opaque n, decl_nodeProcedure c, decl_nodeProcedure t, decl_nodeProcedure v) { - if (decl_isEnumeration (n)) + if (decl_isEnumeration (static_cast (n))) { /* can always emit enumerated types. */ output (n, c, t, v); return true; } - else if (((decl_isType (n)) && (decl_isTypeHidden (n))) && ((decl_getType (n)) == NULL)) + else if (((decl_isType (static_cast (n))) && (decl_isTypeHidden (static_cast (n)))) && ((decl_getType (static_cast (n))) == NULL)) { /* avoid dangling else. */ /* can always emit hidden types. */ @@ -18521,9 +18582,9 @@ static bool tryComplete (decl_node n, decl_nodeProcedure c, decl_nodeProcedure t tryCompleteFromPartial - */ -static bool tryCompleteFromPartial (decl_node n, decl_nodeProcedure t) +static bool tryCompleteFromPartial (decl_node__opaque n, decl_nodeProcedure t) { - if ((((decl_isType (n)) && ((decl_getType (n)) != NULL)) && (decl_isPointer (decl_getType (n)))) && ((allDependants (decl_getType (n))) == decl_completed)) + if ((((decl_isType (static_cast (n))) && ((decl_getType (static_cast (n))) != NULL)) && (decl_isPointer (decl_getType (static_cast (n))))) && ((allDependants (static_cast (decl_getType (static_cast (n))))) == decl_completed)) { /* alists.includeItemIntoList (globalGroup^.partialQ, getType (n)) ; */ outputHiddenComplete (n); @@ -18545,7 +18606,7 @@ static bool tryCompleteFromPartial (decl_node n, decl_nodeProcedure t) visitIntrinsicFunction - */ -static void visitIntrinsicFunction (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitIntrinsicFunction (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { mcDebug_assert (isIntrinsicFunction (n)); switch (n->kind) @@ -18588,7 +18649,7 @@ static void visitIntrinsicFunction (alists_alist v, decl_node n, decl_nodeProced visitUnary - */ -static void visitUnary (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitUnary (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { mcDebug_assert (isUnary (n)); visitNode (v, n->unaryF.arg, p); @@ -18600,7 +18661,7 @@ static void visitUnary (alists_alist v, decl_node n, decl_nodeProcedure p) visitBinary - */ -static void visitBinary (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitBinary (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { visitNode (v, n->binaryF.left, p); visitNode (v, n->binaryF.right, p); @@ -18612,7 +18673,7 @@ static void visitBinary (alists_alist v, decl_node n, decl_nodeProcedure p) visitBoolean - */ -static void visitBoolean (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitBoolean (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { visitNode (v, falseN, p); visitNode (v, trueN, p); @@ -18623,7 +18684,7 @@ static void visitBoolean (alists_alist v, decl_node n, decl_nodeProcedure p) visitScope - */ -static void visitScope (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitScope (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { if (mustVisitScope) { @@ -18636,9 +18697,9 @@ static void visitScope (alists_alist v, decl_node n, decl_nodeProcedure p) visitType - */ -static void visitType (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitType (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isType (n)); + mcDebug_assert (decl_isType (static_cast (n))); visitNode (v, n->typeF.type, p); visitScope (v, n->typeF.scope, p); } @@ -18657,7 +18718,7 @@ static void visitIndex (alists_alist v, Indexing_Index i, decl_nodeProcedure p) h = Indexing_HighIndice (i); while (j <= h) { - visitNode (v, reinterpret_cast (Indexing_GetIndice (i, j)), p); + visitNode (v, static_cast (Indexing_GetIndice (i, j)), p); j += 1; } } @@ -18667,9 +18728,9 @@ static void visitIndex (alists_alist v, Indexing_Index i, decl_nodeProcedure p) visitRecord - */ -static void visitRecord (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitRecord (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isRecord (n)); + mcDebug_assert (decl_isRecord (static_cast (n))); visitScope (v, n->recordF.scope, p); visitIndex (v, n->recordF.listOfSons, p); } @@ -18679,9 +18740,9 @@ static void visitRecord (alists_alist v, decl_node n, decl_nodeProcedure p) visitVarient - */ -static void visitVarient (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitVarient (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isVarient (n)); + mcDebug_assert (decl_isVarient (static_cast (n))); visitIndex (v, n->varientF.listOfSons, p); visitNode (v, n->varientF.varient, p); visitNode (v, n->varientF.tag, p); @@ -18693,9 +18754,9 @@ static void visitVarient (alists_alist v, decl_node n, decl_nodeProcedure p) visitVar - */ -static void visitVar (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitVar (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isVar (n)); + mcDebug_assert (decl_isVar (static_cast (n))); visitNode (v, n->varF.type, p); visitNode (v, n->varF.decl, p); visitScope (v, n->varF.scope, p); @@ -18706,9 +18767,9 @@ static void visitVar (alists_alist v, decl_node n, decl_nodeProcedure p) visitEnumeration - */ -static void visitEnumeration (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitEnumeration (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isEnumeration (n)); + mcDebug_assert (decl_isEnumeration (static_cast (n))); visitIndex (v, n->enumerationF.listOfSons, p); visitScope (v, n->enumerationF.scope, p); } @@ -18718,9 +18779,9 @@ static void visitEnumeration (alists_alist v, decl_node n, decl_nodeProcedure p) visitSubrange - */ -static void visitSubrange (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitSubrange (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isSubrange (n)); + mcDebug_assert (decl_isSubrange (static_cast (n))); visitNode (v, n->subrangeF.low, p); visitNode (v, n->subrangeF.high, p); visitNode (v, n->subrangeF.type, p); @@ -18732,9 +18793,9 @@ static void visitSubrange (alists_alist v, decl_node n, decl_nodeProcedure p) visitPointer - */ -static void visitPointer (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitPointer (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isPointer (n)); + mcDebug_assert (decl_isPointer (static_cast (n))); visitNode (v, n->pointerF.type, p); visitScope (v, n->pointerF.scope, p); } @@ -18744,9 +18805,9 @@ static void visitPointer (alists_alist v, decl_node n, decl_nodeProcedure p) visitArray - */ -static void visitArray (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitArray (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isArray (n)); + mcDebug_assert (decl_isArray (static_cast (n))); visitNode (v, n->arrayF.subr, p); visitNode (v, n->arrayF.type, p); visitScope (v, n->arrayF.scope, p); @@ -18757,9 +18818,9 @@ static void visitArray (alists_alist v, decl_node n, decl_nodeProcedure p) visitConst - */ -static void visitConst (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitConst (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isConst (n)); + mcDebug_assert (decl_isConst (static_cast (n))); visitNode (v, n->constF.type, p); visitNode (v, n->constF.value, p); visitScope (v, n->constF.scope, p); @@ -18770,9 +18831,9 @@ static void visitConst (alists_alist v, decl_node n, decl_nodeProcedure p) visitVarParam - */ -static void visitVarParam (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitVarParam (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isVarParam (n)); + mcDebug_assert (decl_isVarParam (static_cast (n))); visitNode (v, n->varparamF.namelist, p); visitNode (v, n->varparamF.type, p); visitScope (v, n->varparamF.scope, p); @@ -18783,9 +18844,9 @@ static void visitVarParam (alists_alist v, decl_node n, decl_nodeProcedure p) visitParam - */ -static void visitParam (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitParam (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isParam (n)); + mcDebug_assert (decl_isParam (static_cast (n))); visitNode (v, n->paramF.namelist, p); visitNode (v, n->paramF.type, p); visitScope (v, n->paramF.scope, p); @@ -18796,9 +18857,9 @@ static void visitParam (alists_alist v, decl_node n, decl_nodeProcedure p) visitOptarg - */ -static void visitOptarg (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitOptarg (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isOptarg (n)); + mcDebug_assert (decl_isOptarg (static_cast (n))); visitNode (v, n->optargF.namelist, p); visitNode (v, n->optargF.type, p); visitNode (v, n->optargF.init, p); @@ -18810,9 +18871,9 @@ static void visitOptarg (alists_alist v, decl_node n, decl_nodeProcedure p) visitRecordField - */ -static void visitRecordField (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitRecordField (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isRecordField (n)); + mcDebug_assert (decl_isRecordField (static_cast (n))); visitNode (v, n->recordfieldF.type, p); visitNode (v, n->recordfieldF.parent, p); visitNode (v, n->recordfieldF.varient, p); @@ -18824,9 +18885,9 @@ static void visitRecordField (alists_alist v, decl_node n, decl_nodeProcedure p) visitVarientField - */ -static void visitVarientField (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitVarientField (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isVarientField (n)); + mcDebug_assert (decl_isVarientField (static_cast (n))); visitNode (v, n->varientfieldF.parent, p); visitNode (v, n->varientfieldF.varient, p); visitIndex (v, n->varientfieldF.listOfSons, p); @@ -18838,9 +18899,9 @@ static void visitVarientField (alists_alist v, decl_node n, decl_nodeProcedure p visitEnumerationField - */ -static void visitEnumerationField (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitEnumerationField (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isEnumerationField (n)); + mcDebug_assert (decl_isEnumerationField (static_cast (n))); visitNode (v, n->enumerationfieldF.type, p); visitScope (v, n->enumerationfieldF.scope, p); } @@ -18850,9 +18911,9 @@ static void visitEnumerationField (alists_alist v, decl_node n, decl_nodeProcedu visitSet - */ -static void visitSet (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitSet (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isSet (n)); + mcDebug_assert (decl_isSet (static_cast (n))); visitNode (v, n->setF.type, p); visitScope (v, n->setF.scope, p); } @@ -18862,9 +18923,9 @@ static void visitSet (alists_alist v, decl_node n, decl_nodeProcedure p) visitProcType - */ -static void visitProcType (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitProcType (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isProcType (n)); + mcDebug_assert (decl_isProcType (static_cast (n))); visitIndex (v, n->proctypeF.parameters, p); visitNode (v, n->proctypeF.optarg_, p); visitNode (v, n->proctypeF.returnType, p); @@ -18876,7 +18937,7 @@ static void visitProcType (alists_alist v, decl_node n, decl_nodeProcedure p) visitSubscript - */ -static void visitSubscript (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitSubscript (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { } @@ -18898,9 +18959,9 @@ static void visitDecls (alists_alist v, decl_scopeT s, decl_nodeProcedure p) visitProcedure - */ -static void visitProcedure (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitProcedure (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isProcedure (n)); + mcDebug_assert (decl_isProcedure (static_cast (n))); visitDecls (v, n->procedureF.decls, p); visitScope (v, n->procedureF.scope, p); visitIndex (v, n->procedureF.parameters, p); @@ -18914,9 +18975,9 @@ static void visitProcedure (alists_alist v, decl_node n, decl_nodeProcedure p) visitDef - */ -static void visitDef (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitDef (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isDef (n)); + mcDebug_assert (decl_isDef (static_cast (n))); visitDecls (v, n->defF.decls, p); } @@ -18925,9 +18986,9 @@ static void visitDef (alists_alist v, decl_node n, decl_nodeProcedure p) visitImp - */ -static void visitImp (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitImp (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isImp (n)); + mcDebug_assert (decl_isImp (static_cast (n))); visitDecls (v, n->impF.decls, p); visitNode (v, n->impF.beginStatements, p); /* --fixme-- do we need to visit definitionModule? */ @@ -18939,9 +19000,9 @@ static void visitImp (alists_alist v, decl_node n, decl_nodeProcedure p) visitModule - */ -static void visitModule (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitModule (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isModule (n)); + mcDebug_assert (decl_isModule (static_cast (n))); visitDecls (v, n->moduleF.decls, p); visitNode (v, n->moduleF.beginStatements, p); visitNode (v, n->moduleF.finallyStatements, p); @@ -18952,9 +19013,9 @@ static void visitModule (alists_alist v, decl_node n, decl_nodeProcedure p) visitLoop - */ -static void visitLoop (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitLoop (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isLoop (n)); + mcDebug_assert (decl_isLoop (static_cast (n))); visitNode (v, n->loopF.statements, p); } @@ -18963,9 +19024,9 @@ static void visitLoop (alists_alist v, decl_node n, decl_nodeProcedure p) visitWhile - */ -static void visitWhile (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitWhile (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isWhile (n)); + mcDebug_assert (decl_isWhile (static_cast (n))); visitNode (v, n->whileF.expr, p); visitNode (v, n->whileF.statements, p); } @@ -18975,9 +19036,9 @@ static void visitWhile (alists_alist v, decl_node n, decl_nodeProcedure p) visitRepeat - */ -static void visitRepeat (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitRepeat (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isRepeat (n)); + mcDebug_assert (decl_isRepeat (static_cast (n))); visitNode (v, n->repeatF.expr, p); visitNode (v, n->repeatF.statements, p); } @@ -18987,9 +19048,9 @@ static void visitRepeat (alists_alist v, decl_node n, decl_nodeProcedure p) visitCase - */ -static void visitCase (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitCase (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isCase (n)); + mcDebug_assert (decl_isCase (static_cast (n))); visitNode (v, n->caseF.expression, p); visitIndex (v, n->caseF.caseLabelList, p); visitNode (v, n->caseF.else_, p); @@ -19000,9 +19061,9 @@ static void visitCase (alists_alist v, decl_node n, decl_nodeProcedure p) visitCaseLabelList - */ -static void visitCaseLabelList (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitCaseLabelList (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isCaseLabelList (n)); + mcDebug_assert (decl_isCaseLabelList (static_cast (n))); visitNode (v, n->caselabellistF.caseList, p); visitNode (v, n->caselabellistF.statements, p); } @@ -19012,9 +19073,9 @@ static void visitCaseLabelList (alists_alist v, decl_node n, decl_nodeProcedure visitCaseList - */ -static void visitCaseList (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitCaseList (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isCaseList (n)); + mcDebug_assert (decl_isCaseList (static_cast (n))); visitIndex (v, n->caselistF.rangePairs, p); } @@ -19023,9 +19084,9 @@ static void visitCaseList (alists_alist v, decl_node n, decl_nodeProcedure p) visitRange - */ -static void visitRange (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitRange (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isRange (n)); + mcDebug_assert (decl_isRange (static_cast (n))); visitNode (v, n->rangeF.lo, p); visitNode (v, n->rangeF.hi, p); } @@ -19035,9 +19096,9 @@ static void visitRange (alists_alist v, decl_node n, decl_nodeProcedure p) visitIf - */ -static void visitIf (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitIf (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isIf (n)); + mcDebug_assert (decl_isIf (static_cast (n))); visitNode (v, n->ifF.expr, p); visitNode (v, n->ifF.elsif, p); visitNode (v, n->ifF.then, p); @@ -19049,9 +19110,9 @@ static void visitIf (alists_alist v, decl_node n, decl_nodeProcedure p) visitElsif - */ -static void visitElsif (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitElsif (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isElsif (n)); + mcDebug_assert (decl_isElsif (static_cast (n))); visitNode (v, n->elsifF.expr, p); visitNode (v, n->elsifF.elsif, p); visitNode (v, n->elsifF.then, p); @@ -19063,9 +19124,9 @@ static void visitElsif (alists_alist v, decl_node n, decl_nodeProcedure p) visitFor - */ -static void visitFor (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitFor (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isFor (n)); + mcDebug_assert (decl_isFor (static_cast (n))); visitNode (v, n->forF.des, p); visitNode (v, n->forF.start, p); visitNode (v, n->forF.end, p); @@ -19078,7 +19139,7 @@ static void visitFor (alists_alist v, decl_node n, decl_nodeProcedure p) visitAssignment - */ -static void visitAssignment (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitAssignment (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { mcDebug_assert (isAssignment (n)); visitNode (v, n->assignmentF.des, p); @@ -19090,7 +19151,7 @@ static void visitAssignment (alists_alist v, decl_node n, decl_nodeProcedure p) visitComponentRef - */ -static void visitComponentRef (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitComponentRef (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { mcDebug_assert (isComponentRef (n)); visitNode (v, n->componentrefF.rec, p); @@ -19103,9 +19164,9 @@ static void visitComponentRef (alists_alist v, decl_node n, decl_nodeProcedure p visitPointerRef - */ -static void visitPointerRef (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitPointerRef (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isPointerRef (n)); + mcDebug_assert (decl_isPointerRef (static_cast (n))); visitNode (v, n->pointerrefF.ptr, p); visitNode (v, n->pointerrefF.field, p); visitNode (v, n->pointerrefF.resultType, p); @@ -19116,7 +19177,7 @@ static void visitPointerRef (alists_alist v, decl_node n, decl_nodeProcedure p) visitArrayRef - */ -static void visitArrayRef (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitArrayRef (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { mcDebug_assert (isArrayRef (n)); visitNode (v, n->arrayrefF.array, p); @@ -19129,7 +19190,7 @@ static void visitArrayRef (alists_alist v, decl_node n, decl_nodeProcedure p) visitFunccall - */ -static void visitFunccall (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitFunccall (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { mcDebug_assert (isFuncCall (n)); visitNode (v, n->funccallF.function, p); @@ -19142,7 +19203,7 @@ static void visitFunccall (alists_alist v, decl_node n, decl_nodeProcedure p) visitVarDecl - */ -static void visitVarDecl (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitVarDecl (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { mcDebug_assert (isVarDecl (n)); visitNode (v, n->vardeclF.type, p); @@ -19154,9 +19215,9 @@ static void visitVarDecl (alists_alist v, decl_node n, decl_nodeProcedure p) visitExplist - */ -static void visitExplist (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitExplist (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isExpList (n)); + mcDebug_assert (decl_isExpList (static_cast (n))); visitIndex (v, n->explistF.exp, p); } @@ -19165,9 +19226,9 @@ static void visitExplist (alists_alist v, decl_node n, decl_nodeProcedure p) visitExit - */ -static void visitExit (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitExit (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isExit (n)); + mcDebug_assert (decl_isExit (static_cast (n))); visitNode (v, n->exitF.loop, p); } @@ -19176,9 +19237,9 @@ static void visitExit (alists_alist v, decl_node n, decl_nodeProcedure p) visitReturn - */ -static void visitReturn (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitReturn (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isReturn (n)); + mcDebug_assert (decl_isReturn (static_cast (n))); visitNode (v, n->returnF.exp, p); } @@ -19187,9 +19248,9 @@ static void visitReturn (alists_alist v, decl_node n, decl_nodeProcedure p) visitStmtSeq - */ -static void visitStmtSeq (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitStmtSeq (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isStatementSequence (n)); + mcDebug_assert (decl_isStatementSequence (static_cast (n))); visitIndex (v, n->stmtF.statements, p); } @@ -19198,9 +19259,9 @@ static void visitStmtSeq (alists_alist v, decl_node n, decl_nodeProcedure p) visitVarargs - */ -static void visitVarargs (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitVarargs (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isVarargs (n)); + mcDebug_assert (decl_isVarargs (static_cast (n))); visitScope (v, n->varargsF.scope, p); } @@ -19209,9 +19270,9 @@ static void visitVarargs (alists_alist v, decl_node n, decl_nodeProcedure p) visitSetValue - */ -static void visitSetValue (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitSetValue (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { - mcDebug_assert (decl_isSetValue (n)); + mcDebug_assert (decl_isSetValue (static_cast (n))); visitNode (v, n->setvalueF.type, p); visitIndex (v, n->setvalueF.values, p); } @@ -19221,7 +19282,7 @@ static void visitSetValue (alists_alist v, decl_node n, decl_nodeProcedure p) visitIntrinsic - */ -static void visitIntrinsic (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitIntrinsic (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { mcDebug_assert (isIntrinsic (n)); visitNode (v, n->intrinsicF.args, p); @@ -19234,7 +19295,7 @@ static void visitIntrinsic (alists_alist v, decl_node n, decl_nodeProcedure p) visit node, n, dependants. */ -static void visitDependants (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitDependants (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { mcDebug_assert (n != NULL); mcDebug_assert (alists_isItemInList (v, reinterpret_cast (n))); @@ -19588,7 +19649,7 @@ static void visitDependants (alists_alist v, decl_node n, decl_nodeProcedure p) It calls p(n) if the node is unvisited. */ -static void visitNode (alists_alist v, decl_node n, decl_nodeProcedure p) +static void visitNode (alists_alist v, decl_node__opaque n, decl_nodeProcedure p) { if ((n != NULL) && (! (alists_isItemInList (v, reinterpret_cast (n))))) { @@ -19603,7 +19664,7 @@ static void visitNode (alists_alist v, decl_node n, decl_nodeProcedure p) genKind - returns a string depending upon the kind of node, n. */ -static DynamicStrings_String genKind (decl_node n) +static DynamicStrings_String genKind (decl_node__opaque n) { switch (n->kind) { @@ -19635,7 +19696,7 @@ static DynamicStrings_String genKind (decl_node n) case decl_longcomplex: case decl_shortcomplex: /* types, no need to generate a kind string as it it contained in the name. */ - return NULL; + return static_cast (NULL); break; case decl_type: @@ -19938,7 +19999,7 @@ static DynamicStrings_String genKind (decl_node n) gen - generate a small string describing node, n. */ -static DynamicStrings_String gen (decl_node n) +static DynamicStrings_String gen (decl_node__opaque n) { DynamicStrings_String s; unsigned int d; @@ -19962,7 +20023,7 @@ static DynamicStrings_String gen (decl_node n) static void dumpQ (const char *q_, unsigned int _q_high, alists_alist l) { DynamicStrings_String m; - decl_node n; + decl_node__opaque n; unsigned int d; unsigned int h; unsigned int i; @@ -19981,7 +20042,7 @@ static void dumpQ (const char *q_, unsigned int _q_high, alists_alist l) h = alists_noOfItemsInList (l); while (i <= h) { - n = static_cast (alists_getItemFromList (l, i)); + n = static_cast (alists_getItemFromList (l, i)); m = DynamicStrings_KillString (SFIO_WriteS (FIO_StdOut, gen (n))); i += 1; } @@ -19996,12 +20057,8 @@ static void dumpQ (const char *q_, unsigned int _q_high, alists_alist l) static void dumpLists (void) { - DynamicStrings_String m; - - if (mcOptions_getDebugTopological ()) + if ((mcOptions_getDebugTopological ()) && false) { - m = FormatStrings_Sprintf0 (DynamicStrings_InitString ((const char *) "\\n", 2)); - m = DynamicStrings_KillString (SFIO_WriteS (FIO_StdOut, m)); dumpQ ((const char *) "todo", 4, globalGroup->todoQ); dumpQ ((const char *) "partial", 7, globalGroup->partialQ); dumpQ ((const char *) "done", 4, globalGroup->doneQ); @@ -20013,7 +20070,7 @@ static void dumpLists (void) outputHidden - */ -static void outputHidden (decl_node n) +static void outputHidden (decl_node__opaque n) { outText (doP, (const char *) "#if !defined (", 14); doFQNameC (doP, n); @@ -20032,18 +20089,18 @@ static void outputHidden (decl_node n) outputHiddenComplete - */ -static void outputHiddenComplete (decl_node n) +static void outputHiddenComplete (decl_node__opaque n) { - decl_node t; + decl_node__opaque t; - mcDebug_assert (decl_isType (n)); - t = decl_getType (n); - mcDebug_assert (decl_isPointer (t)); + mcDebug_assert (decl_isType (static_cast (n))); + t = static_cast (decl_getType (static_cast (n))); + mcDebug_assert (decl_isPointer (static_cast (t))); outText (doP, (const char *) "#define ", 8); doFQNameC (doP, n); outText (doP, (const char *) "_D\\n", 4); outText (doP, (const char *) "typedef ", 8); - doTypeNameC (doP, decl_getType (t)); + doTypeNameC (doP, static_cast (decl_getType (static_cast (t)))); mcPretty_setNeedSpace (doP); outText (doP, (const char *) "*", 1); doFQNameC (doP, n); @@ -20055,27 +20112,27 @@ static void outputHiddenComplete (decl_node n) tryPartial - */ -static bool tryPartial (decl_node n, decl_nodeProcedure pt) +static bool tryPartial (decl_node__opaque n, decl_nodeProcedure pt) { - decl_node q; + decl_node__opaque q; - if ((n != NULL) && (decl_isType (n))) + if ((n != NULL) && (decl_isType (static_cast (n)))) { - q = decl_getType (n); - while (decl_isPointer (q)) + q = static_cast (decl_getType (static_cast (n))); + while (decl_isPointer (static_cast (q))) { - q = decl_getType (q); + q = static_cast (decl_getType (static_cast (q))); } if (q != NULL) { /* avoid gcc warning by using compound statement even if not strictly necessary. */ - if ((decl_isRecord (q)) || (decl_isProcType (q))) + if ((decl_isRecord (static_cast (q))) || (decl_isProcType (static_cast (q)))) { (*pt.proc) (n); addTodo (q); return true; } - else if (decl_isArray (q)) + else if (decl_isArray (static_cast (q))) { /* avoid dangling else. */ (*pt.proc) (n); @@ -20094,23 +20151,23 @@ static bool tryPartial (decl_node n, decl_nodeProcedure pt) outputPartialRecordArrayProcType - */ -static void outputPartialRecordArrayProcType (decl_node n, decl_node q, unsigned int indirection) +static void outputPartialRecordArrayProcType (decl_node__opaque n, decl_node__opaque q, unsigned int indirection) { DynamicStrings_String s; outText (doP, (const char *) "typedef struct", 14); mcPretty_setNeedSpace (doP); s = getFQstring (n); - if (decl_isRecord (q)) + if (decl_isRecord (static_cast (q))) { s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "_r", 2))); } - else if (decl_isArray (q)) + else if (decl_isArray (static_cast (q))) { /* avoid dangling else. */ s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "_a", 2))); } - else if (decl_isProcType (q)) + else if (decl_isProcType (static_cast (q))) { /* avoid dangling else. */ s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "_p", 2))); @@ -20132,16 +20189,16 @@ static void outputPartialRecordArrayProcType (decl_node n, decl_node q, unsigned outputPartial - */ -static void outputPartial (decl_node n) +static void outputPartial (decl_node__opaque n) { - decl_node q; + decl_node__opaque q; unsigned int indirection; - q = decl_getType (n); + q = static_cast (decl_getType (static_cast (n))); indirection = 0; - while (decl_isPointer (q)) + while (decl_isPointer (static_cast (q))) { - q = decl_getType (q); + q = static_cast (decl_getType (static_cast (q))); indirection += 1; } outputPartialRecordArrayProcType (n, q, indirection); @@ -20156,17 +20213,17 @@ static void tryOutputTodo (decl_nodeProcedure c, decl_nodeProcedure t, decl_node { unsigned int i; unsigned int n; - decl_node d; + decl_node__opaque d; i = 1; n = alists_noOfItemsInList (globalGroup->todoQ); while (i <= n) { - d = static_cast (alists_getItemFromList (globalGroup->todoQ, i)); + d = static_cast (alists_getItemFromList (globalGroup->todoQ, i)); if (tryComplete (d, c, t, v)) { alists_removeItemFromList (globalGroup->todoQ, reinterpret_cast (d)); - alists_includeItemIntoList (globalGroup->doneQ, reinterpret_cast (d)); + addDone (d); i = 1; } else if (tryPartial (d, pt)) @@ -20194,17 +20251,17 @@ static void tryOutputPartial (decl_nodeProcedure t) { unsigned int i; unsigned int n; - decl_node d; + decl_node__opaque d; i = 1; n = alists_noOfItemsInList (globalGroup->partialQ); while (i <= n) { - d = static_cast (alists_getItemFromList (globalGroup->partialQ, i)); + d = static_cast (alists_getItemFromList (globalGroup->partialQ, i)); if (tryCompleteFromPartial (d, t)) { alists_removeItemFromList (globalGroup->partialQ, reinterpret_cast (d)); - alists_includeItemIntoList (globalGroup->doneQ, reinterpret_cast (d)); + addDone (d); i = 1; n -= 1; } @@ -20220,25 +20277,25 @@ static void tryOutputPartial (decl_nodeProcedure t) debugList - */ -static void debugList (const char *a_, unsigned int _a_high, alists_alist l) +static void debugList (const char *listName_, unsigned int _listName_high, const char *symName_, unsigned int _symName_high, alists_alist l) { unsigned int i; unsigned int h; - decl_node n; - char a[_a_high+1]; + decl_node__opaque n; + char listName[_listName_high+1]; + char symName[_symName_high+1]; /* make a local copy of each unbounded array. */ - memcpy (a, a_, _a_high+1); + memcpy (listName, listName_, _listName_high+1); + memcpy (symName, symName_, _symName_high+1); h = alists_noOfItemsInList (l); if (h > 0) { - outText (doP, (const char *) a, _a_high); - outText (doP, (const char *) " still contains node(s)\\n", 25); i = 1; do { - n = static_cast (alists_getItemFromList (l, i)); - dbg (n); + n = static_cast (alists_getItemFromList (l, i)); + dbg ((const char *) listName, _listName_high, (const char *) symName, _symName_high, n); i += 1; } while (! (i > h)); } @@ -20253,8 +20310,9 @@ static void debugLists (void) { if (mcOptions_getDebugTopological ()) { - debugList ((const char *) "todo", 4, globalGroup->todoQ); - debugList ((const char *) "partial", 7, globalGroup->partialQ); + debugList ((const char *) "todo", 4, (const char *) "decl_node", 9, globalGroup->todoQ); + debugList ((const char *) "partial", 7, (const char *) "decl_node", 9, globalGroup->partialQ); + debugList ((const char *) "done", 4, (const char *) "decl_node", 9, globalGroup->doneQ); } } @@ -20263,11 +20321,11 @@ static void debugLists (void) addEnumConst - */ -static void addEnumConst (decl_node n) +static void addEnumConst (decl_node__opaque n) { DynamicStrings_String s; - if ((decl_isConst (n)) || (decl_isEnumeration (n))) + if ((decl_isConst (static_cast (n))) || (decl_isEnumeration (static_cast (n)))) { addTodo (n); } @@ -20280,7 +20338,7 @@ static void addEnumConst (decl_node n) static void populateTodo (decl_nodeProcedure p) { - decl_node n; + decl_node__opaque n; unsigned int i; unsigned int h; alists_alist l; @@ -20289,7 +20347,7 @@ static void populateTodo (decl_nodeProcedure p) i = 1; while (i <= h) { - n = static_cast (alists_getItemFromList (globalGroup->todoQ, i)); + n = static_cast (alists_getItemFromList (globalGroup->todoQ, i)); l = alists_initList (); visitNode (l, n, p); alists_killList (&l); @@ -20327,7 +20385,7 @@ static void topologicallyOut (decl_nodeProcedure c, decl_nodeProcedure t, decl_n scaffoldStatic - */ -static void scaffoldStatic (mcPretty_pretty p, decl_node n) +static void scaffoldStatic (mcPretty_pretty p, decl_node__opaque n) { outText (p, (const char *) "\\n", 2); doExternCP (p); @@ -20337,9 +20395,11 @@ static void scaffoldStatic (mcPretty_pretty p, decl_node n) doFQNameC (p, n); outText (p, (const char *) "_init", 5); mcPretty_setNeedSpace (p); - outText (p, (const char *) "(__attribute__((unused)) int argc", 33); - outText (p, (const char *) ",__attribute__((unused)) char *argv[]", 37); - outText (p, (const char *) ",__attribute__((unused)) char *envp[])\\n", 40); + outText (p, (const char *) "(__attribute__((unused)) int argc,", 34); + mcPretty_setNeedSpace (p); + outText (p, (const char *) "__attribute__((unused)) char *argv[],", 37); + mcPretty_setNeedSpace (p); + outText (p, (const char *) "__attribute__((unused)) char *envp[])\\n", 39); p = outKc (p, (const char *) "{\\n", 3); doStatementsC (p, n->impF.beginStatements); p = outKc (p, (const char *) "}\\n", 3); @@ -20351,9 +20411,11 @@ static void scaffoldStatic (mcPretty_pretty p, decl_node n) doFQNameC (p, n); outText (p, (const char *) "_fini", 5); mcPretty_setNeedSpace (p); - outText (p, (const char *) "(__attribute__((unused)) int argc", 33); - outText (p, (const char *) ",__attribute__((unused)) char *argv[]", 37); - outText (p, (const char *) ",__attribute__((unused)) char *envp[])\\n", 40); + outText (p, (const char *) "(__attribute__((unused)) int argc,", 34); + mcPretty_setNeedSpace (p); + outText (p, (const char *) "__attribute__((unused)) char *argv[],", 37); + mcPretty_setNeedSpace (p); + outText (p, (const char *) "__attribute__((unused)) char *envp[])\\n", 39); p = outKc (p, (const char *) "{\\n", 3); doStatementsC (p, n->impF.finallyStatements); p = outKc (p, (const char *) "}\\n", 3); @@ -20364,7 +20426,7 @@ static void scaffoldStatic (mcPretty_pretty p, decl_node n) emitCtor - */ -static void emitCtor (mcPretty_pretty p, decl_node n) +static void emitCtor (mcPretty_pretty p, decl_node__opaque n) { DynamicStrings_String s; @@ -20375,7 +20437,7 @@ static void emitCtor (mcPretty_pretty p, decl_node n) doFQNameC (p, n); p = outKc (p, (const char *) "{\\n", 3); outText (p, (const char *) "M2RTS_RegisterModule (\"", 23); - s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n))); + s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast (n)))); mcPretty_prints (p, s); outText (p, (const char *) "\",\\n", 4); outText (p, (const char *) "init, fini, dependencies);\\n", 28); @@ -20412,7 +20474,7 @@ static void emitCtor (mcPretty_pretty p, decl_node n) scaffoldDynamic - */ -static void scaffoldDynamic (mcPretty_pretty p, decl_node n) +static void scaffoldDynamic (mcPretty_pretty p, decl_node__opaque n) { outText (p, (const char *) "\\n", 2); doExternCP (p); @@ -20423,8 +20485,10 @@ static void scaffoldDynamic (mcPretty_pretty p, decl_node n) outText (p, (const char *) "_init", 5); mcPretty_setNeedSpace (p); outText (p, (const char *) "(__attribute__((unused)) int argc,", 34); - outText (p, (const char *) " __attribute__((unused)) char *argv[]", 37); - outText (p, (const char *) " __attribute__((unused)) char *envp[])\\n", 40); + mcPretty_setNeedSpace (p); + outText (p, (const char *) "__attribute__((unused)) char *argv[],", 37); + mcPretty_setNeedSpace (p); + outText (p, (const char *) "__attribute__((unused)) char *envp[])\\n", 39); p = outKc (p, (const char *) "{\\n", 3); doStatementsC (p, n->impF.beginStatements); p = outKc (p, (const char *) "}\\n", 3); @@ -20437,8 +20501,10 @@ static void scaffoldDynamic (mcPretty_pretty p, decl_node n) outText (p, (const char *) "_fini", 5); mcPretty_setNeedSpace (p); outText (p, (const char *) "(__attribute__((unused)) int argc,", 34); - outText (p, (const char *) " __attribute__((unused)) char *argv[]", 37); - outText (p, (const char *) " __attribute__((unused)) char *envp[])\\n", 40); + mcPretty_setNeedSpace (p); + outText (p, (const char *) "__attribute__((unused)) char *argv[],", 37); + mcPretty_setNeedSpace (p); + outText (p, (const char *) "__attribute__((unused)) char *envp[])\\n", 39); p = outKc (p, (const char *) "{\\n", 3); doStatementsC (p, n->impF.finallyStatements); p = outKc (p, (const char *) "}\\n", 3); @@ -20450,7 +20516,7 @@ static void scaffoldDynamic (mcPretty_pretty p, decl_node n) scaffoldMain - */ -static void scaffoldMain (mcPretty_pretty p, decl_node n) +static void scaffoldMain (mcPretty_pretty p, decl_node__opaque n) { DynamicStrings_String s; @@ -20460,7 +20526,7 @@ static void scaffoldMain (mcPretty_pretty p, decl_node n) outText (p, (const char *) "(int argc, char *argv[], char *envp[])\\n", 40); p = outKc (p, (const char *) "{\\n", 3); outText (p, (const char *) "M2RTS_ConstructModules (", 24); - s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n))); + s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast (n)))); mcPretty_prints (p, s); outText (p, (const char *) ", argc, argv, envp);\\n", 22); outText (p, (const char *) "M2RTS_DeconstructModules (", 26); @@ -20476,7 +20542,7 @@ static void scaffoldMain (mcPretty_pretty p, decl_node n) outImpInitC - emit the init/fini functions and main function if required. */ -static void outImpInitC (mcPretty_pretty p, decl_node n) +static void outImpInitC (mcPretty_pretty p, decl_node__opaque n) { if (mcOptions_getScaffoldDynamic ()) { @@ -20497,18 +20563,18 @@ static void outImpInitC (mcPretty_pretty p, decl_node n) runSimplifyTypes - */ -static void runSimplifyTypes (decl_node n) +static void runSimplifyTypes (decl_node__opaque n) { - if (decl_isImp (n)) + if (decl_isImp (static_cast (n))) { simplifyTypes (n->impF.decls); } - else if (decl_isModule (n)) + else if (decl_isModule (static_cast (n))) { /* avoid dangling else. */ simplifyTypes (n->moduleF.decls); } - else if (decl_isDef (n)) + else if (decl_isDef (static_cast (n))) { /* avoid dangling else. */ simplifyTypes (n->defF.decls); @@ -20520,13 +20586,13 @@ static void runSimplifyTypes (decl_node n) outDefC - */ -static void outDefC (mcPretty_pretty p, decl_node n) +static void outDefC (mcPretty_pretty p, decl_node__opaque n) { DynamicStrings_String s; - mcDebug_assert (decl_isDef (n)); + mcDebug_assert (decl_isDef (static_cast (n))); outputFile = mcStream_openFrag (1); /* first fragment. */ - s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n))); /* first fragment. */ + s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast (n)))); /* first fragment. */ mcPretty_print (p, (const char *) "/* do not edit automatically generated by mc from ", 50); mcPretty_prints (p, s); mcPretty_print (p, (const char *) ". */\\n", 7); @@ -20571,14 +20637,14 @@ static void outDefC (mcPretty_pretty p, decl_node n) runPrototypeExported - */ -static void runPrototypeExported (decl_node n) +static void runPrototypeExported (decl_node__opaque n) { - if (decl_isExported (n)) + if (decl_isExported (static_cast (n))) { - keyc_enterScope (n); + keyc_enterScope (static_cast (n)); doProcedureHeadingC (n, true); mcPretty_print (doP, (const char *) ";\\n", 3); - keyc_leaveScope (n); + keyc_leaveScope (static_cast (n)); } } @@ -20587,9 +20653,9 @@ static void runPrototypeExported (decl_node n) runPrototypeDefC - */ -static void runPrototypeDefC (decl_node n) +static void runPrototypeDefC (decl_node__opaque n) { - if (decl_isDef (n)) + if (decl_isDef (static_cast (n))) { Indexing_ForeachIndiceInIndexDo (n->defF.decls.procedures, (Indexing_IndexProcedure) {(Indexing_IndexProcedure_t) runPrototypeExported}); } @@ -20600,14 +20666,14 @@ static void runPrototypeDefC (decl_node n) outImpC - */ -static void outImpC (mcPretty_pretty p, decl_node n) +static void outImpC (mcPretty_pretty p, decl_node__opaque n) { DynamicStrings_String s; - decl_node defModule; + decl_node__opaque defModule; - mcDebug_assert (decl_isImp (n)); + mcDebug_assert (decl_isImp (static_cast (n))); outputFile = mcStream_openFrag (1); /* first fragment. */ - s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n))); /* first fragment. */ + s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast (n)))); /* first fragment. */ mcPretty_print (p, (const char *) "/* do not edit automatically generated by mc from ", 50); mcPretty_prints (p, s); mcPretty_print (p, (const char *) ". */\\n", 7); @@ -20629,14 +20695,16 @@ static void outImpC (mcPretty_pretty p, decl_node n) } else { - s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n))); - /* we don't want to include the .h file for this implementation module. */ - mcPretty_print (p, (const char *) "#define _", 9); - mcPretty_prints (p, s); - mcPretty_print (p, (const char *) "_H\\n", 4); + s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast (n)))); + /* Inform the source that this code belongs to the implementation module. */ mcPretty_print (p, (const char *) "#define _", 9); mcPretty_prints (p, s); mcPretty_print (p, (const char *) "_C\\n\\n", 6); + /* Include the definition module for any opaque types. */ + mcPretty_print (doP, (const char *) "#include \"", 10); + mcPretty_prints (p, mcOptions_getHPrefix ()); + mcPretty_prints (p, s); + mcPretty_print (p, (const char *) ".h\"\\n", 5); s = DynamicStrings_KillString (s); doP = p; Indexing_ForeachIndiceInIndexDo (n->impF.importedModules, (Indexing_IndexProcedure) {(Indexing_IndexProcedure_t) doIncludeC}); @@ -20644,7 +20712,7 @@ static void outImpC (mcPretty_pretty p, decl_node n) includeDefConstType (n); includeDefVarProcedure (n); outDeclsImpC (p, n->impF.decls); - defModule = decl_lookupDef (decl_getSymName (n)); + defModule = static_cast (decl_lookupDef (decl_getSymName (static_cast (n)))); if (defModule != NULL) { runPrototypeDefC (defModule); @@ -20680,7 +20748,7 @@ static void outDeclsModuleC (mcPretty_pretty p, decl_scopeT s) outModuleInitC - */ -static void outModuleInitC (mcPretty_pretty p, decl_node n) +static void outModuleInitC (mcPretty_pretty p, decl_node__opaque n) { outText (p, (const char *) "\\n", 2); doExternCP (p); @@ -20717,13 +20785,13 @@ static void outModuleInitC (mcPretty_pretty p, decl_node n) outModuleC - */ -static void outModuleC (mcPretty_pretty p, decl_node n) +static void outModuleC (mcPretty_pretty p, decl_node__opaque n) { DynamicStrings_String s; - mcDebug_assert (decl_isModule (n)); + mcDebug_assert (decl_isModule (static_cast (n))); outputFile = mcStream_openFrag (1); /* first fragment. */ - s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n))); /* first fragment. */ + s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast (n)))); /* first fragment. */ mcPretty_print (p, (const char *) "/* do not edit automatically generated by mc from ", 50); mcPretty_prints (p, s); mcPretty_print (p, (const char *) ". */\\n", 7); @@ -20761,19 +20829,19 @@ static void outModuleC (mcPretty_pretty p, decl_node n) outC - */ -static void outC (mcPretty_pretty p, decl_node n) +static void outC (mcPretty_pretty p, decl_node__opaque n) { - keyc_enterScope (n); - if (decl_isDef (n)) + keyc_enterScope (static_cast (n)); + if (decl_isDef (static_cast (n))) { outDefC (p, n); } - else if (decl_isImp (n)) + else if (decl_isImp (static_cast (n))) { /* avoid dangling else. */ outImpC (p, n); } - else if (decl_isModule (n)) + else if (decl_isModule (static_cast (n))) { /* avoid dangling else. */ outModuleC (p, n); @@ -20784,7 +20852,7 @@ static void outC (mcPretty_pretty p, decl_node n) M2RTS_HALT (-1); __builtin_unreachable (); } - keyc_leaveScope (n); + keyc_leaveScope (static_cast (n)); } @@ -20792,25 +20860,25 @@ static void outC (mcPretty_pretty p, decl_node n) doIncludeM2 - include modules in module, n. */ -static void doIncludeM2 (decl_node n) +static void doIncludeM2 (decl_node__opaque n) { DynamicStrings_String s; - s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n))); + s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast (n)))); mcPretty_print (doP, (const char *) "IMPORT ", 7); mcPretty_prints (doP, s); mcPretty_print (doP, (const char *) " ;\\n", 4); s = DynamicStrings_KillString (s); - if (decl_isDef (n)) + if (decl_isDef (static_cast (n))) { symbolKey_foreachNodeDo (n->defF.decls.symbols, (symbolKey_performOperation) {(symbolKey_performOperation_t) addDone}); } - else if (decl_isImp (n)) + else if (decl_isImp (static_cast (n))) { /* avoid dangling else. */ symbolKey_foreachNodeDo (n->impF.decls.symbols, (symbolKey_performOperation) {(symbolKey_performOperation_t) addDone}); } - else if (decl_isModule (n)) + else if (decl_isModule (static_cast (n))) { /* avoid dangling else. */ symbolKey_foreachNodeDo (n->moduleF.decls.symbols, (symbolKey_performOperation) {(symbolKey_performOperation_t) addDone}); @@ -20822,7 +20890,7 @@ static void doIncludeM2 (decl_node n) doConstM2 - */ -static void doConstM2 (decl_node n) +static void doConstM2 (decl_node__opaque n) { mcPretty_print (doP, (const char *) "CONST\\n", 7); doFQNameC (doP, n); @@ -20836,7 +20904,7 @@ static void doConstM2 (decl_node n) doProcTypeM2 - */ -static void doProcTypeM2 (mcPretty_pretty p, decl_node n) +static void doProcTypeM2 (mcPretty_pretty p, decl_node__opaque n) { outText (p, (const char *) "proc type to do..", 17); } @@ -20846,12 +20914,12 @@ static void doProcTypeM2 (mcPretty_pretty p, decl_node n) doRecordFieldM2 - */ -static void doRecordFieldM2 (mcPretty_pretty p, decl_node f) +static void doRecordFieldM2 (mcPretty_pretty p, decl_node__opaque f) { doNameM2 (p, f); outText (p, (const char *) ":", 1); mcPretty_setNeedSpace (p); - doTypeM2 (p, decl_getType (f)); + doTypeM2 (p, static_cast (decl_getType (static_cast (f)))); mcPretty_setNeedSpace (p); } @@ -20860,13 +20928,13 @@ static void doRecordFieldM2 (mcPretty_pretty p, decl_node f) doVarientFieldM2 - */ -static void doVarientFieldM2 (mcPretty_pretty p, decl_node n) +static void doVarientFieldM2 (mcPretty_pretty p, decl_node__opaque n) { unsigned int i; unsigned int t; - decl_node q; + decl_node__opaque q; - mcDebug_assert (decl_isVarientField (n)); + mcDebug_assert (decl_isVarientField (static_cast (n))); doNameM2 (p, n); outText (p, (const char *) ":", 1); mcPretty_setNeedSpace (p); @@ -20874,13 +20942,13 @@ static void doVarientFieldM2 (mcPretty_pretty p, decl_node n) t = Indexing_HighIndice (n->varientfieldF.listOfSons); while (i <= t) { - q = static_cast (Indexing_GetIndice (n->varientfieldF.listOfSons, i)); - if (decl_isRecordField (q)) + q = static_cast (Indexing_GetIndice (n->varientfieldF.listOfSons, i)); + if (decl_isRecordField (static_cast (q))) { doRecordFieldM2 (p, q); outText (p, (const char *) ";\\n", 3); } - else if (decl_isVarient (q)) + else if (decl_isVarient (static_cast (q))) { /* avoid dangling else. */ doVarientM2 (p, q); @@ -20901,23 +20969,23 @@ static void doVarientFieldM2 (mcPretty_pretty p, decl_node n) doVarientM2 - */ -static void doVarientM2 (mcPretty_pretty p, decl_node n) +static void doVarientM2 (mcPretty_pretty p, decl_node__opaque n) { unsigned int i; unsigned int t; - decl_node q; + decl_node__opaque q; - mcDebug_assert (decl_isVarient (n)); + mcDebug_assert (decl_isVarient (static_cast (n))); outText (p, (const char *) "CASE", 4); mcPretty_setNeedSpace (p); if (n->varientF.tag != NULL) { /* avoid gcc warning by using compound statement even if not strictly necessary. */ - if (decl_isRecordField (n->varientF.tag)) + if (decl_isRecordField (static_cast (n->varientF.tag))) { doRecordFieldM2 (p, n->varientF.tag); } - else if (decl_isVarientField (n->varientF.tag)) + else if (decl_isVarientField (static_cast (n->varientF.tag))) { /* avoid dangling else. */ doVarientFieldM2 (p, n->varientF.tag); @@ -20935,8 +21003,8 @@ static void doVarientM2 (mcPretty_pretty p, decl_node n) t = Indexing_HighIndice (n->varientF.listOfSons); while (i <= t) { - q = static_cast (Indexing_GetIndice (n->varientF.listOfSons, i)); - if (decl_isRecordField (q)) + q = static_cast (Indexing_GetIndice (n->varientF.listOfSons, i)); + if (decl_isRecordField (static_cast (q))) { /* avoid dangling else. */ if (! q->recordfieldF.tag) @@ -20945,7 +21013,7 @@ static void doVarientM2 (mcPretty_pretty p, decl_node n) outText (p, (const char *) ";\\n", 3); } } - else if (decl_isVarientField (q)) + else if (decl_isVarientField (static_cast (q))) { /* avoid dangling else. */ doVarientFieldM2 (p, q); @@ -20967,21 +21035,21 @@ static void doVarientM2 (mcPretty_pretty p, decl_node n) doRecordM2 - */ -static void doRecordM2 (mcPretty_pretty p, decl_node n) +static void doRecordM2 (mcPretty_pretty p, decl_node__opaque n) { unsigned int i; unsigned int h; - decl_node f; + decl_node__opaque f; - mcDebug_assert (decl_isRecord (n)); + mcDebug_assert (decl_isRecord (static_cast (n))); p = outKm2 (p, (const char *) "RECORD", 6); i = Indexing_LowIndice (n->recordF.listOfSons); h = Indexing_HighIndice (n->recordF.listOfSons); outText (p, (const char *) "\\n", 2); while (i <= h) { - f = static_cast (Indexing_GetIndice (n->recordF.listOfSons, i)); - if (decl_isRecordField (f)) + f = static_cast (Indexing_GetIndice (n->recordF.listOfSons, i)); + if (decl_isRecordField (static_cast (f))) { /* avoid dangling else. */ if (! f->recordfieldF.tag) @@ -20990,13 +21058,13 @@ static void doRecordM2 (mcPretty_pretty p, decl_node n) outText (p, (const char *) ";\\n", 3); } } - else if (decl_isVarient (f)) + else if (decl_isVarient (static_cast (f))) { /* avoid dangling else. */ doVarientM2 (p, f); outText (p, (const char *) ";\\n", 3); } - else if (decl_isVarientField (f)) + else if (decl_isVarientField (static_cast (f))) { /* avoid dangling else. */ doVarientFieldM2 (p, f); @@ -21012,11 +21080,11 @@ static void doRecordM2 (mcPretty_pretty p, decl_node n) doPointerM2 - */ -static void doPointerM2 (mcPretty_pretty p, decl_node n) +static void doPointerM2 (mcPretty_pretty p, decl_node__opaque n) { outText (p, (const char *) "POINTER TO", 10); mcPretty_setNeedSpace (doP); - doTypeM2 (p, decl_getType (n)); + doTypeM2 (p, static_cast (decl_getType (static_cast (n)))); mcPretty_setNeedSpace (p); outText (p, (const char *) ";\\n", 3); } @@ -21026,13 +21094,13 @@ static void doPointerM2 (mcPretty_pretty p, decl_node n) doTypeAliasM2 - */ -static void doTypeAliasM2 (mcPretty_pretty p, decl_node n) +static void doTypeAliasM2 (mcPretty_pretty p, decl_node__opaque n) { doTypeNameC (p, n); mcPretty_setNeedSpace (p); outText (doP, (const char *) "=", 1); mcPretty_setNeedSpace (p); - doTypeM2 (p, decl_getType (n)); + doTypeM2 (p, static_cast (decl_getType (static_cast (n)))); mcPretty_setNeedSpace (p); outText (p, (const char *) "\\n", 2); } @@ -21042,11 +21110,11 @@ static void doTypeAliasM2 (mcPretty_pretty p, decl_node n) doEnumerationM2 - */ -static void doEnumerationM2 (mcPretty_pretty p, decl_node n) +static void doEnumerationM2 (mcPretty_pretty p, decl_node__opaque n) { unsigned int i; unsigned int h; - decl_node s; + decl_node__opaque s; DynamicStrings_String t; outText (p, (const char *) "(", 1); @@ -21054,7 +21122,7 @@ static void doEnumerationM2 (mcPretty_pretty p, decl_node n) h = Indexing_HighIndice (n->enumerationF.listOfSons); while (i <= h) { - s = static_cast (Indexing_GetIndice (n->enumerationF.listOfSons, i)); + s = static_cast (Indexing_GetIndice (n->enumerationF.listOfSons, i)); doFQNameC (p, s); if (i < h) { @@ -21071,7 +21139,7 @@ static void doEnumerationM2 (mcPretty_pretty p, decl_node n) doBaseM2 - */ -static void doBaseM2 (mcPretty_pretty p, decl_node n) +static void doBaseM2 (mcPretty_pretty p, decl_node__opaque n) { switch (n->kind) { @@ -21107,7 +21175,7 @@ static void doBaseM2 (mcPretty_pretty p, decl_node n) doSystemM2 - */ -static void doSystemM2 (mcPretty_pretty p, decl_node n) +static void doSystemM2 (mcPretty_pretty p, decl_node__opaque n) { switch (n->kind) { @@ -21132,7 +21200,7 @@ static void doSystemM2 (mcPretty_pretty p, decl_node n) doTypeM2 - */ -static void doTypeM2 (mcPretty_pretty p, decl_node n) +static void doTypeM2 (mcPretty_pretty p, decl_node__opaque n) { if (isBase (n)) { @@ -21143,27 +21211,27 @@ static void doTypeM2 (mcPretty_pretty p, decl_node n) /* avoid dangling else. */ doSystemM2 (p, n); } - else if (decl_isType (n)) + else if (decl_isType (static_cast (n))) { /* avoid dangling else. */ doTypeAliasM2 (p, n); } - else if (decl_isProcType (n)) + else if (decl_isProcType (static_cast (n))) { /* avoid dangling else. */ doProcTypeM2 (p, n); } - else if (decl_isPointer (n)) + else if (decl_isPointer (static_cast (n))) { /* avoid dangling else. */ doPointerM2 (p, n); } - else if (decl_isEnumeration (n)) + else if (decl_isEnumeration (static_cast (n))) { /* avoid dangling else. */ doEnumerationM2 (p, n); } - else if (decl_isRecord (n)) + else if (decl_isRecord (static_cast (n))) { /* avoid dangling else. */ doRecordM2 (p, n); @@ -21175,9 +21243,9 @@ static void doTypeM2 (mcPretty_pretty p, decl_node n) doTypesM2 - */ -static void doTypesM2 (decl_node n) +static void doTypesM2 (decl_node__opaque n) { - decl_node m; + decl_node__opaque m; outText (doP, (const char *) "TYPE\\n", 6); doTypeM2 (doP, n); @@ -21188,13 +21256,13 @@ static void doTypesM2 (decl_node n) doVarM2 - */ -static void doVarM2 (decl_node n) +static void doVarM2 (decl_node__opaque n) { - mcDebug_assert (decl_isVar (n)); + mcDebug_assert (decl_isVar (static_cast (n))); doNameC (doP, n); outText (doP, (const char *) ":", 1); mcPretty_setNeedSpace (doP); - doTypeM2 (doP, decl_getType (n)); + doTypeM2 (doP, static_cast (decl_getType (static_cast (n)))); mcPretty_setNeedSpace (doP); outText (doP, (const char *) ";\\n", 3); } @@ -21204,9 +21272,9 @@ static void doVarM2 (decl_node n) doVarsM2 - */ -static void doVarsM2 (decl_node n) +static void doVarsM2 (decl_node__opaque n) { - decl_node m; + decl_node__opaque m; outText (doP, (const char *) "VAR\\n", 5); doVarM2 (n); @@ -21217,7 +21285,7 @@ static void doVarsM2 (decl_node n) doTypeNameM2 - */ -static void doTypeNameM2 (mcPretty_pretty p, decl_node n) +static void doTypeNameM2 (mcPretty_pretty p, decl_node__opaque n) { doNameM2 (p, n); } @@ -21227,16 +21295,16 @@ static void doTypeNameM2 (mcPretty_pretty p, decl_node n) doParamM2 - */ -static void doParamM2 (mcPretty_pretty p, decl_node n) +static void doParamM2 (mcPretty_pretty p, decl_node__opaque n) { - decl_node ptype; + decl_node__opaque ptype; nameKey_Name i; unsigned int c; unsigned int t; wlists_wlist l; - mcDebug_assert (decl_isParam (n)); - ptype = decl_getType (n); + mcDebug_assert (decl_isParam (static_cast (n))); + ptype = static_cast (decl_getType (static_cast (n))); if (n->paramF.namelist == NULL) { doTypeNameM2 (p, ptype); @@ -21277,18 +21345,18 @@ static void doParamM2 (mcPretty_pretty p, decl_node n) doVarParamM2 - */ -static void doVarParamM2 (mcPretty_pretty p, decl_node n) +static void doVarParamM2 (mcPretty_pretty p, decl_node__opaque n) { - decl_node ptype; + decl_node__opaque ptype; nameKey_Name i; unsigned int c; unsigned int t; wlists_wlist l; - mcDebug_assert (decl_isVarParam (n)); + mcDebug_assert (decl_isVarParam (static_cast (n))); outText (p, (const char *) "VAR", 3); mcPretty_setNeedSpace (p); - ptype = decl_getType (n); + ptype = static_cast (decl_getType (static_cast (n))); if (n->varparamF.namelist == NULL) { doTypeNameM2 (p, ptype); @@ -21329,18 +21397,18 @@ static void doVarParamM2 (mcPretty_pretty p, decl_node n) doParameterM2 - */ -static void doParameterM2 (mcPretty_pretty p, decl_node n) +static void doParameterM2 (mcPretty_pretty p, decl_node__opaque n) { - if (decl_isParam (n)) + if (decl_isParam (static_cast (n))) { doParamM2 (p, n); } - else if (decl_isVarParam (n)) + else if (decl_isVarParam (static_cast (n))) { /* avoid dangling else. */ doVarParamM2 (p, n); } - else if (decl_isVarargs (n)) + else if (decl_isVarargs (static_cast (n))) { /* avoid dangling else. */ mcPretty_print (p, (const char *) "...", 3); @@ -21352,13 +21420,13 @@ static void doParameterM2 (mcPretty_pretty p, decl_node n) doPrototypeM2 - */ -static void doPrototypeM2 (decl_node n) +static void doPrototypeM2 (decl_node__opaque n) { unsigned int i; unsigned int h; - decl_node p; + decl_node__opaque p; - mcDebug_assert (decl_isProcedure (n)); + mcDebug_assert (decl_isProcedure (static_cast (n))); mcPretty_noSpace (doP); doNameM2 (doP, n); mcPretty_setNeedSpace (doP); @@ -21367,7 +21435,7 @@ static void doPrototypeM2 (decl_node n) h = Indexing_HighIndice (n->procedureF.parameters); while (i <= h) { - p = static_cast (Indexing_GetIndice (n->procedureF.parameters, i)); + p = static_cast (Indexing_GetIndice (n->procedureF.parameters, i)); doParameterM2 (doP, p); mcPretty_noSpace (doP); if (i < h) @@ -21398,21 +21466,21 @@ static void doPrototypeM2 (decl_node n) when trying to complete partial to full. */ -static void outputPartialM2 (decl_node n) +static void outputPartialM2 (decl_node__opaque n) { - decl_node q; + decl_node__opaque q; - q = decl_getType (n); - if (decl_isRecord (q)) + q = static_cast (decl_getType (static_cast (n))); + if (decl_isRecord (static_cast (q))) { doTypeM2 (doP, n); } - else if (decl_isArray (q)) + else if (decl_isArray (static_cast (q))) { /* avoid dangling else. */ doTypeM2 (doP, n); } - else if (decl_isProcType (q)) + else if (decl_isProcType (static_cast (q))) { /* avoid dangling else. */ doTypeM2 (doP, n); @@ -21440,16 +21508,16 @@ static void outDeclsDefM2 (mcPretty_pretty p, decl_scopeT s) outDefM2 - */ -static void outDefM2 (mcPretty_pretty p, decl_node n) +static void outDefM2 (mcPretty_pretty p, decl_node__opaque n) { DynamicStrings_String s; - s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSource (n))); + s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSource (static_cast (n)))); mcPretty_print (p, (const char *) "(* automatically created by mc from ", 36); mcPretty_prints (p, s); mcPretty_print (p, (const char *) ". *)\\n\\n", 9); s = DynamicStrings_KillString (s); - s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (n))); + s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSymName (static_cast (n)))); mcPretty_print (p, (const char *) "DEFINITION MODULE ", 18); mcPretty_prints (p, s); mcPretty_print (p, (const char *) " ;\\n\\n", 6); @@ -21486,11 +21554,11 @@ static void outDeclsImpM2 (mcPretty_pretty p, decl_scopeT s) outImpM2 - */ -static void outImpM2 (mcPretty_pretty p, decl_node n) +static void outImpM2 (mcPretty_pretty p, decl_node__opaque n) { DynamicStrings_String s; - s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSource (n))); + s = DynamicStrings_InitStringCharStar (nameKey_keyToCharStar (decl_getSource (static_cast (n)))); mcPretty_print (p, (const char *) "(* automatically created by mc from ", 36); mcPretty_prints (p, s); mcPretty_print (p, (const char *) ". *)\\n\\n", 9); @@ -21514,7 +21582,7 @@ static void outImpM2 (mcPretty_pretty p, decl_node n) outModuleM2 - */ -static void outModuleM2 (mcPretty_pretty p, decl_node n) +static void outModuleM2 (mcPretty_pretty p, decl_node__opaque n) { } @@ -21523,18 +21591,18 @@ static void outModuleM2 (mcPretty_pretty p, decl_node n) outM2 - */ -static void outM2 (mcPretty_pretty p, decl_node n) +static void outM2 (mcPretty_pretty p, decl_node__opaque n) { - if (decl_isDef (n)) + if (decl_isDef (static_cast (n))) { outDefM2 (p, n); } - else if (decl_isImp (n)) + else if (decl_isImp (static_cast (n))) { /* avoid dangling else. */ outImpM2 (p, n); } - else if (decl_isModule (n)) + else if (decl_isModule (static_cast (n))) { /* avoid dangling else. */ outModuleM2 (p, n); @@ -21552,9 +21620,16 @@ static void outM2 (mcPretty_pretty p, decl_node n) addDone - adds node, n, to the doneQ. */ -static void addDone (decl_node n) +static void addDone (decl_node__opaque n) { + DynamicStrings_String s; + alists_includeItemIntoList (globalGroup->doneQ, reinterpret_cast (n)); + if ((decl_isVar (static_cast (n))) || (decl_isParameter (static_cast (n)))) + { + initNodeOpaqueState (n); + } + debugLists (); } @@ -21563,21 +21638,29 @@ static void addDone (decl_node n) it is not an opaque of the main module we are compiling. */ -static void addDoneDef (decl_node n) +static void addDoneDef (decl_node__opaque n) { - if (decl_isDef (n)) + if (decl_isDef (static_cast (n))) { addDone (n); - return ; + return; } - if (false && ((decl_lookupImp (decl_getSymName (decl_getScope (n)))) == (decl_getMainModule ()))) + if (false && ((decl_lookupImp (decl_getSymName (decl_getScope (static_cast (n))))) == (decl_getMainModule ()))) { mcMetaError_metaError1 ((const char *) "cyclic dependancy found between another module using {%1ad} from the definition module of the implementation main being compiled, use the --extended-opaque option to compile", 173, (const unsigned char *) &n, (sizeof (n)-1)); mcError_flushErrors (); mcError_errorAbort0 ((const char *) "terminating compilation", 23); } + else if ((decl_isType (static_cast (n))) && (isDeclInImp (n))) + { + /* avoid dangling else. */ + } else { + /* avoid dangling else. */ + /* Ignore an opaque type which is declared in this implementation module as it + will be fully declared in C/C++ with the __opaque postfix. Whereas the + void * non prefixed typedef will be declared in the .h file. */ addDone (n); } } @@ -21587,7 +21670,7 @@ static void addDoneDef (decl_node n) dbgAdd - */ -static decl_node dbgAdd (alists_alist l, decl_node n) +static decl_node__opaque dbgAdd (alists_alist l, decl_node__opaque n) { if (n != NULL) { @@ -21603,11 +21686,11 @@ static decl_node dbgAdd (alists_alist l, decl_node n) dbgType - */ -static void dbgType (alists_alist l, decl_node n) +static void dbgType (alists_alist l, decl_node__opaque n) { - decl_node t; + decl_node__opaque t; - t = dbgAdd (l, decl_getType (n)); + t = dbgAdd (l, static_cast (decl_getType (static_cast (n)))); out1 ((const char *) "<%s type", 8, n); if (t == NULL) { @@ -21624,11 +21707,11 @@ static void dbgType (alists_alist l, decl_node n) dbgPointer - */ -static void dbgPointer (alists_alist l, decl_node n) +static void dbgPointer (alists_alist l, decl_node__opaque n) { - decl_node t; + decl_node__opaque t; - t = dbgAdd (l, decl_getType (n)); + t = dbgAdd (l, static_cast (decl_getType (static_cast (n)))); out1 ((const char *) "<%s pointer", 11, n); out1 ((const char *) " to %s>\\n", 9, t); } @@ -21638,28 +21721,28 @@ static void dbgPointer (alists_alist l, decl_node n) dbgRecord - */ -static void dbgRecord (alists_alist l, decl_node n) +static void dbgRecord (alists_alist l, decl_node__opaque n) { unsigned int i; unsigned int t; - decl_node q; + decl_node__opaque q; out1 ((const char *) "<%s record:\\n", 13, n); i = Indexing_LowIndice (n->recordF.listOfSons); t = Indexing_HighIndice (n->recordF.listOfSons); while (i <= t) { - q = static_cast (Indexing_GetIndice (n->recordF.listOfSons, i)); - if (decl_isRecordField (q)) + q = static_cast (Indexing_GetIndice (n->recordF.listOfSons, i)); + if (decl_isRecordField (static_cast (q))) { out1 ((const char *) " (q))) { /* avoid dangling else. */ out1 ((const char *) " (q))) { /* avoid dangling else. */ out1 ((const char *) " (decl_getType (static_cast (q)))); out1 ((const char *) ": %s>\\n", 7, q); i += 1; } @@ -21682,15 +21765,15 @@ static void dbgRecord (alists_alist l, decl_node n) dbgVarient - */ -static void dbgVarient (alists_alist l, decl_node n) +static void dbgVarient (alists_alist l, decl_node__opaque n) { unsigned int i; unsigned int t; - decl_node q; + decl_node__opaque q; out1 ((const char *) "<%s varient: ", 13, n); out1 ((const char *) "tag %s", 6, n->varientF.tag); - q = decl_getType (n->varientF.tag); + q = static_cast (decl_getType (static_cast (n->varientF.tag))); if (q == NULL) { outText (doP, (const char *) "\\n", 2); @@ -21704,17 +21787,17 @@ static void dbgVarient (alists_alist l, decl_node n) t = Indexing_HighIndice (n->varientF.listOfSons); while (i <= t) { - q = static_cast (Indexing_GetIndice (n->varientF.listOfSons, i)); - if (decl_isRecordField (q)) + q = static_cast (Indexing_GetIndice (n->varientF.listOfSons, i)); + if (decl_isRecordField (static_cast (q))) { out1 ((const char *) " (q))) { /* avoid dangling else. */ out1 ((const char *) " (q))) { /* avoid dangling else. */ out1 ((const char *) " (decl_getType (static_cast (q)))); out1 ((const char *) ": %s>\\n", 7, q); i += 1; } @@ -21737,9 +21820,9 @@ static void dbgVarient (alists_alist l, decl_node n) dbgEnumeration - */ -static void dbgEnumeration (alists_alist l, decl_node n) +static void dbgEnumeration (alists_alist l, decl_node__opaque n) { - decl_node e; + decl_node__opaque e; unsigned int i; unsigned int h; @@ -21748,7 +21831,7 @@ static void dbgEnumeration (alists_alist l, decl_node n) h = Indexing_HighIndice (n->enumerationF.listOfSons); while (i <= h) { - e = static_cast (Indexing_GetIndice (n->enumerationF.listOfSons, i)); + e = static_cast (Indexing_GetIndice (n->enumerationF.listOfSons, i)); out1 ((const char *) "%s, ", 4, e); i += 1; } @@ -21760,11 +21843,11 @@ static void dbgEnumeration (alists_alist l, decl_node n) dbgVar - */ -static void dbgVar (alists_alist l, decl_node n) +static void dbgVar (alists_alist l, decl_node__opaque n) { - decl_node t; + decl_node__opaque t; - t = dbgAdd (l, decl_getType (n)); + t = dbgAdd (l, static_cast (decl_getType (static_cast (n)))); out1 ((const char *) "<%s var", 7, n); out1 ((const char *) ", type = %s>\\n", 14, t); } @@ -21774,7 +21857,7 @@ static void dbgVar (alists_alist l, decl_node n) dbgSubrange - */ -static void dbgSubrange (alists_alist l, decl_node n) +static void dbgSubrange (alists_alist l, decl_node__opaque n) { if (n->subrangeF.low == NULL) { @@ -21792,11 +21875,11 @@ static void dbgSubrange (alists_alist l, decl_node n) dbgArray - */ -static void dbgArray (alists_alist l, decl_node n) +static void dbgArray (alists_alist l, decl_node__opaque n) { - decl_node t; + decl_node__opaque t; - t = dbgAdd (l, decl_getType (n)); + t = dbgAdd (l, static_cast (decl_getType (static_cast (n)))); out1 ((const char *) "<%s array ", 10, n); if (n->arrayF.subr != NULL) { @@ -21810,46 +21893,46 @@ static void dbgArray (alists_alist l, decl_node n) doDbg - */ -static void doDbg (alists_alist l, decl_node n) +static void doDbg (alists_alist l, decl_node__opaque n) { if (n == NULL) {} /* empty. */ - else if (decl_isSubrange (n)) + else if (decl_isSubrange (static_cast (n))) { /* avoid dangling else. */ dbgSubrange (l, n); } - else if (decl_isType (n)) + else if (decl_isType (static_cast (n))) { /* avoid dangling else. */ dbgType (l, n); } - else if (decl_isRecord (n)) + else if (decl_isRecord (static_cast (n))) { /* avoid dangling else. */ dbgRecord (l, n); } - else if (decl_isVarient (n)) + else if (decl_isVarient (static_cast (n))) { /* avoid dangling else. */ dbgVarient (l, n); } - else if (decl_isEnumeration (n)) + else if (decl_isEnumeration (static_cast (n))) { /* avoid dangling else. */ dbgEnumeration (l, n); } - else if (decl_isPointer (n)) + else if (decl_isPointer (static_cast (n))) { /* avoid dangling else. */ dbgPointer (l, n); } - else if (decl_isArray (n)) + else if (decl_isArray (static_cast (n))) { /* avoid dangling else. */ dbgArray (l, n); } - else if (decl_isVar (n)) + else if (decl_isVar (static_cast (n))) { /* avoid dangling else. */ dbgVar (l, n); @@ -21861,13 +21944,19 @@ static void doDbg (alists_alist l, decl_node n) dbg - */ -static void dbg (decl_node n) +static void dbg (const char *listName_, unsigned int _listName_high, const char *symName_, unsigned int _symName_high, decl_node__opaque n) { alists_alist l; mcPretty_pretty o; FIO_File f; DynamicStrings_String s; unsigned int i; + char listName[_listName_high+1]; + char symName[_symName_high+1]; + + /* make a local copy of each unbounded array. */ + memcpy (listName, listName_, _listName_high+1); + memcpy (symName, symName_, _symName_high+1); o = doP; f = outputFile; @@ -21876,10 +21965,20 @@ static void dbg (decl_node n) l = alists_initList (); alists_includeItemIntoList (l, reinterpret_cast (n)); i = 1; - out1 ((const char *) "dbg (%s)\\n", 10, n); do { - n = static_cast (alists_getItemFromList (l, i)); - doDbg (l, n); + n = static_cast (alists_getItemFromList (l, i)); + if (decl_isType (static_cast (n))) + { + s = getFQstring (n); + if (DynamicStrings_EqualArray (s, (const char *) symName, _symName_high)) + { + out0 ((const char *) "list ", 5); + out0 ((const char *) listName, _listName_high); + out0 ((const char *) ": ", 2); + doDbg (l, n); + } + s = DynamicStrings_KillString (s); + } i += 1; } while (! (i > (alists_noOfItemsInList (l)))); doP = o; @@ -21892,7 +21991,7 @@ static void dbg (decl_node n) nodes. */ -static void addGenericBody (decl_node n, decl_node c) +static void addGenericBody (decl_node__opaque n, decl_node__opaque c) { switch (n->kind) { @@ -21944,7 +22043,7 @@ static void addGenericBody (decl_node n, decl_node c) nodes. */ -static void addGenericAfter (decl_node n, decl_node c) +static void addGenericAfter (decl_node__opaque n, decl_node__opaque c) { switch (n->kind) { @@ -21995,7 +22094,7 @@ static void addGenericAfter (decl_node n, decl_node c) isAssignment - */ -static bool isAssignment (decl_node n) +static bool isAssignment (decl_node__opaque n) { return n->kind == decl_assignment; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -22007,7 +22106,7 @@ static bool isAssignment (decl_node n) isComment - returns TRUE if node, n, is a comment. */ -static bool isComment (decl_node n) +static bool isComment (decl_node__opaque n) { mcDebug_assert (n != NULL); return n->kind == decl_comment; @@ -22022,8 +22121,8 @@ static bool isComment (decl_node n) static void initPair (decl_commentPair *c) { - (*c).after = NULL; - (*c).body = NULL; + (*c).after = static_cast (NULL); + (*c).body = static_cast (NULL); } @@ -22031,17 +22130,17 @@ static void initPair (decl_commentPair *c) dupExplist - */ -static decl_node dupExplist (decl_node n) +static decl_node__opaque dupExplist (decl_node__opaque n) { - decl_node m; + decl_node__opaque m; unsigned int i; - mcDebug_assert (decl_isExpList (n)); - m = decl_makeExpList (); + mcDebug_assert (decl_isExpList (static_cast (n))); + m = static_cast (decl_makeExpList ()); i = Indexing_LowIndice (n->explistF.exp); while (i <= (Indexing_HighIndice (n->explistF.exp))) { - decl_putExpList (m, decl_dupExpr (reinterpret_cast (Indexing_GetIndice (n->explistF.exp, i)))); + decl_putExpList (static_cast (m), decl_dupExpr (static_cast (Indexing_GetIndice (n->explistF.exp, i)))); i += 1; } return m; @@ -22054,10 +22153,10 @@ static decl_node dupExplist (decl_node n) dupArrayref - */ -static decl_node dupArrayref (decl_node n) +static decl_node__opaque dupArrayref (decl_node__opaque n) { mcDebug_assert (isArrayRef (n)); - return decl_makeArrayRef (decl_dupExpr (n->arrayrefF.array), decl_dupExpr (n->arrayrefF.index)); + return static_cast (decl_makeArrayRef (decl_dupExpr (static_cast (n->arrayrefF.array)), decl_dupExpr (static_cast (n->arrayrefF.index)))); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -22067,10 +22166,10 @@ static decl_node dupArrayref (decl_node n) dupPointerref - */ -static decl_node dupPointerref (decl_node n) +static decl_node__opaque dupPointerref (decl_node__opaque n) { - mcDebug_assert (decl_isPointerRef (n)); - return decl_makePointerRef (decl_dupExpr (n->pointerrefF.ptr), decl_dupExpr (n->pointerrefF.field)); + mcDebug_assert (decl_isPointerRef (static_cast (n))); + return static_cast (decl_makePointerRef (decl_dupExpr (static_cast (n->pointerrefF.ptr)), decl_dupExpr (static_cast (n->pointerrefF.field)))); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -22080,10 +22179,10 @@ static decl_node dupPointerref (decl_node n) dupComponentref - */ -static decl_node dupComponentref (decl_node n) +static decl_node__opaque dupComponentref (decl_node__opaque n) { mcDebug_assert (isComponentRef (n)); - return doMakeComponentRef (decl_dupExpr (n->componentrefF.rec), decl_dupExpr (n->componentrefF.field)); + return doMakeComponentRef (static_cast (decl_dupExpr (static_cast (n->componentrefF.rec))), static_cast (decl_dupExpr (static_cast (n->componentrefF.field)))); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -22093,10 +22192,10 @@ static decl_node dupComponentref (decl_node n) dupBinary - */ -static decl_node dupBinary (decl_node n) +static decl_node__opaque dupBinary (decl_node__opaque n) { /* assert (isBinary (n)) ; */ - return makeBinary (n->kind, decl_dupExpr (n->binaryF.left), decl_dupExpr (n->binaryF.right), n->binaryF.resultType); + return makeBinary (n->kind, static_cast (decl_dupExpr (static_cast (n->binaryF.left))), static_cast (decl_dupExpr (static_cast (n->binaryF.right))), n->binaryF.resultType); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -22106,10 +22205,10 @@ static decl_node dupBinary (decl_node n) dupUnary - */ -static decl_node dupUnary (decl_node n) +static decl_node__opaque dupUnary (decl_node__opaque n) { /* assert (isUnary (n)) ; */ - return makeUnary (n->kind, decl_dupExpr (n->unaryF.arg), n->unaryF.resultType); + return makeUnary (n->kind, static_cast (decl_dupExpr (static_cast (n->unaryF.arg))), n->unaryF.resultType); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -22119,13 +22218,14 @@ static decl_node dupUnary (decl_node n) dupFunccall - */ -static decl_node dupFunccall (decl_node n) +static decl_node__opaque dupFunccall (decl_node__opaque n) { - decl_node m; + decl_node__opaque m; mcDebug_assert (isFuncCall (n)); - m = decl_makeFuncCall (decl_dupExpr (n->funccallF.function), decl_dupExpr (n->funccallF.args)); + m = static_cast (decl_makeFuncCall (decl_dupExpr (static_cast (n->funccallF.function)), decl_dupExpr (static_cast (n->funccallF.args)))); m->funccallF.type = n->funccallF.type; + assignNodeOpaqueCastState (m, n); return m; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -22136,9 +22236,9 @@ static decl_node dupFunccall (decl_node n) dupSetValue - */ -static decl_node dupSetValue (decl_node n) +static decl_node__opaque dupSetValue (decl_node__opaque n) { - decl_node m; + decl_node__opaque m; unsigned int i; m = newNode (decl_setvalue); @@ -22146,7 +22246,7 @@ static decl_node dupSetValue (decl_node n) i = Indexing_LowIndice (n->setvalueF.values); while (i <= (Indexing_HighIndice (n->setvalueF.values))) { - m = decl_putSetValue (m, decl_dupExpr (reinterpret_cast (Indexing_GetIndice (n->setvalueF.values, i)))); + m = static_cast (decl_putSetValue (static_cast (m), decl_dupExpr (static_cast (Indexing_GetIndice (n->setvalueF.values, i))))); i += 1; } return m; @@ -22159,7 +22259,7 @@ static decl_node dupSetValue (decl_node n) doDupExpr - */ -static decl_node doDupExpr (decl_node n) +static decl_node__opaque doDupExpr (decl_node__opaque n) { mcDebug_assert (n != NULL); switch (n->kind) @@ -22347,7 +22447,7 @@ static decl_node doDupExpr (decl_node n) static void makeSystem (void) { - systemN = decl_lookupDef (nameKey_makeKey ((const char *) "SYSTEM", 6)); + systemN = static_cast (decl_lookupDef (nameKey_makeKey ((const char *) "SYSTEM", 6))); addressN = makeBase (decl_address); locN = makeBase (decl_loc); byteN = makeBase (decl_byte); @@ -22357,7 +22457,7 @@ static void makeSystem (void) adrN = makeBase (decl_adr); tsizeN = makeBase (decl_tsize); throwN = makeBase (decl_throw); - decl_enterScope (systemN); + decl_enterScope (static_cast (systemN)); addressN = addToScope (addressN); locN = addToScope (locN); byteN = addToScope (byteN); @@ -22385,7 +22485,7 @@ static void makeSystem (void) static void makeM2rts (void) { - m2rtsN = decl_lookupDef (nameKey_makeKey ((const char *) "M2RTS", 5)); + m2rtsN = static_cast (decl_lookupDef (nameKey_makeKey ((const char *) "M2RTS", 5))); } @@ -22393,13 +22493,13 @@ static void makeM2rts (void) makeBitnum - */ -static decl_node makeBitnum (void) +static decl_node__opaque makeBitnum (void) { - decl_node b; + decl_node__opaque b; b = newNode (decl_subrange); - b->subrangeF.type = NULL; - b->subrangeF.scope = NULL; + b->subrangeF.type = static_cast (NULL); + b->subrangeF.scope = static_cast (NULL); b->subrangeF.low = lookupConst (b, nameKey_makeKey ((const char *) "0", 1)); b->subrangeF.high = lookupConst (b, nameKey_makeKey ((const char *) "31", 2)); return b; @@ -22529,10 +22629,10 @@ static void makeBaseSymbols (void) static void makeBuiltins (void) { - bitsperunitN = decl_makeLiteralInt (nameKey_makeKey ((const char *) "8", 1)); - bitsperwordN = decl_makeLiteralInt (nameKey_makeKey ((const char *) "32", 2)); - bitspercharN = decl_makeLiteralInt (nameKey_makeKey ((const char *) "8", 1)); - unitsperwordN = decl_makeLiteralInt (nameKey_makeKey ((const char *) "4", 1)); + bitsperunitN = static_cast (decl_makeLiteralInt (nameKey_makeKey ((const char *) "8", 1))); + bitsperwordN = static_cast (decl_makeLiteralInt (nameKey_makeKey ((const char *) "32", 2))); + bitspercharN = static_cast (decl_makeLiteralInt (nameKey_makeKey ((const char *) "8", 1))); + unitsperwordN = static_cast (decl_makeLiteralInt (nameKey_makeKey ((const char *) "4", 1))); addDone (bitsperunitN); addDone (bitsperwordN); addDone (bitspercharN); @@ -22573,7 +22673,7 @@ static void init (void) extern "C" unsigned int decl_getDeclaredMod (decl_node n) { - return n->at.modDeclared; + return static_cast (n)->at.modDeclared; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -22586,7 +22686,7 @@ extern "C" unsigned int decl_getDeclaredMod (decl_node n) extern "C" unsigned int decl_getDeclaredDef (decl_node n) { - return n->at.defDeclared; + return static_cast (n)->at.defDeclared; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -22599,7 +22699,7 @@ extern "C" unsigned int decl_getDeclaredDef (decl_node n) extern "C" unsigned int decl_getFirstUsed (decl_node n) { - return n->at.firstUsed; + return static_cast (n)->at.firstUsed; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -22612,7 +22712,7 @@ extern "C" unsigned int decl_getFirstUsed (decl_node n) extern "C" bool decl_isDef (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_def; + return static_cast (n)->kind == decl_def; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -22625,7 +22725,7 @@ extern "C" bool decl_isDef (decl_node n) extern "C" bool decl_isImp (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_imp; + return static_cast (n)->kind == decl_imp; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -22649,18 +22749,18 @@ extern "C" bool decl_isImpOrModule (decl_node n) extern "C" bool decl_isVisited (decl_node n) { - switch (n->kind) + switch (static_cast (n)->kind) { case decl_def: - return n->defF.visited; + return static_cast (n)->defF.visited; break; case decl_imp: - return n->impF.visited; + return static_cast (n)->impF.visited; break; case decl_module: - return n->moduleF.visited; + return static_cast (n)->moduleF.visited; break; @@ -22679,18 +22779,18 @@ extern "C" bool decl_isVisited (decl_node n) extern "C" void decl_unsetVisited (decl_node n) { - switch (n->kind) + switch (static_cast (n)->kind) { case decl_def: - n->defF.visited = false; + static_cast (n)->defF.visited = false; break; case decl_imp: - n->impF.visited = false; + static_cast (n)->impF.visited = false; break; case decl_module: - n->moduleF.visited = false; + static_cast (n)->moduleF.visited = false; break; @@ -22707,18 +22807,18 @@ extern "C" void decl_unsetVisited (decl_node n) extern "C" void decl_setVisited (decl_node n) { - switch (n->kind) + switch (static_cast (n)->kind) { case decl_def: - n->defF.visited = true; + static_cast (n)->defF.visited = true; break; case decl_imp: - n->impF.visited = true; + static_cast (n)->impF.visited = true; break; case decl_module: - n->moduleF.visited = true; + static_cast (n)->moduleF.visited = true; break; @@ -22735,18 +22835,18 @@ extern "C" void decl_setVisited (decl_node n) extern "C" void decl_setEnumsComplete (decl_node n) { - switch (n->kind) + switch (static_cast (n)->kind) { case decl_def: - n->defF.enumsComplete = true; + static_cast (n)->defF.enumsComplete = true; break; case decl_imp: - n->impF.enumsComplete = true; + static_cast (n)->impF.enumsComplete = true; break; case decl_module: - n->moduleF.enumsComplete = true; + static_cast (n)->moduleF.enumsComplete = true; break; @@ -22763,18 +22863,18 @@ extern "C" void decl_setEnumsComplete (decl_node n) extern "C" bool decl_getEnumsComplete (decl_node n) { - switch (n->kind) + switch (static_cast (n)->kind) { case decl_def: - return n->defF.enumsComplete; + return static_cast (n)->defF.enumsComplete; break; case decl_imp: - return n->impF.enumsComplete; + return static_cast (n)->impF.enumsComplete; break; case decl_module: - return n->moduleF.enumsComplete; + return static_cast (n)->moduleF.enumsComplete; break; @@ -22797,17 +22897,17 @@ extern "C" void decl_resetEnumPos (decl_node n) mcDebug_assert (((decl_isDef (n)) || (decl_isImp (n))) || (decl_isModule (n))); if (decl_isDef (n)) { - n->defF.enumFixup.count = 0; + static_cast (n)->defF.enumFixup.count = 0; } else if (decl_isImp (n)) { /* avoid dangling else. */ - n->impF.enumFixup.count = 0; + static_cast (n)->impF.enumFixup.count = 0; } else if (decl_isModule (n)) { /* avoid dangling else. */ - n->moduleF.enumFixup.count = 0; + static_cast (n)->moduleF.enumFixup.count = 0; } } @@ -22818,27 +22918,27 @@ extern "C" void decl_resetEnumPos (decl_node n) extern "C" decl_node decl_getNextEnum (void) { - decl_node n; + decl_node__opaque n; - n = NULL; - mcDebug_assert (((decl_isDef (currentModule)) || (decl_isImp (currentModule))) || (decl_isModule (currentModule))); - if (decl_isDef (currentModule)) + n = static_cast (NULL); + mcDebug_assert (((decl_isDef (static_cast (currentModule))) || (decl_isImp (static_cast (currentModule)))) || (decl_isModule (static_cast (currentModule)))); + if (decl_isDef (static_cast (currentModule))) { n = getNextFixup (¤tModule->defF.enumFixup); } - else if (decl_isImp (currentModule)) + else if (decl_isImp (static_cast (currentModule))) { /* avoid dangling else. */ n = getNextFixup (¤tModule->impF.enumFixup); } - else if (decl_isModule (currentModule)) + else if (decl_isModule (static_cast (currentModule))) { /* avoid dangling else. */ n = getNextFixup (¤tModule->moduleF.enumFixup); } mcDebug_assert (n != NULL); - mcDebug_assert ((decl_isEnumeration (n)) || (decl_isEnumerationField (n))); - return n; + mcDebug_assert ((decl_isEnumeration (static_cast (n))) || (decl_isEnumerationField (static_cast (n)))); + return static_cast (n); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -22851,7 +22951,7 @@ extern "C" decl_node decl_getNextEnum (void) extern "C" bool decl_isModule (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_module; + return static_cast (n)->kind == decl_module; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -22879,7 +22979,7 @@ extern "C" bool decl_isMainModule (decl_node n) extern "C" void decl_setMainModule (decl_node n) { mcDebug_assert (n != NULL); - mainModule = n; + mainModule = static_cast (n); } @@ -22890,7 +22990,7 @@ extern "C" void decl_setMainModule (decl_node n) extern "C" void decl_setCurrentModule (decl_node n) { mcDebug_assert (n != NULL); - currentModule = n; + currentModule = static_cast (n); } @@ -22900,16 +23000,16 @@ extern "C" void decl_setCurrentModule (decl_node n) extern "C" decl_node decl_lookupDef (nameKey_Name n) { - decl_node d; + decl_node__opaque d; - d = static_cast (symbolKey_getSymKey (defUniverse, n)); + d = static_cast (symbolKey_getSymKey (defUniverse, n)); if (d == NULL) { d = makeDef (n); symbolKey_putSymKey (defUniverse, n, reinterpret_cast (d)); Indexing_IncludeIndiceIntoIndex (defUniverseI, reinterpret_cast (d)); } - return d; + return static_cast (d); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -22921,17 +23021,17 @@ extern "C" decl_node decl_lookupDef (nameKey_Name n) extern "C" decl_node decl_lookupImp (nameKey_Name n) { - decl_node m; + decl_node__opaque m; - m = static_cast (symbolKey_getSymKey (modUniverse, n)); + m = static_cast (symbolKey_getSymKey (modUniverse, n)); if (m == NULL) { m = makeImp (n); symbolKey_putSymKey (modUniverse, n, reinterpret_cast (m)); Indexing_IncludeIndiceIntoIndex (modUniverseI, reinterpret_cast (m)); } - mcDebug_assert (! (decl_isModule (m))); - return m; + mcDebug_assert (! (decl_isModule (static_cast (m)))); + return static_cast (m); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -22943,17 +23043,17 @@ extern "C" decl_node decl_lookupImp (nameKey_Name n) extern "C" decl_node decl_lookupModule (nameKey_Name n) { - decl_node m; + decl_node__opaque m; - m = static_cast (symbolKey_getSymKey (modUniverse, n)); + m = static_cast (symbolKey_getSymKey (modUniverse, n)); if (m == NULL) { m = makeModule (n); symbolKey_putSymKey (modUniverse, n, reinterpret_cast (m)); Indexing_IncludeIndiceIntoIndex (modUniverseI, reinterpret_cast (m)); } - mcDebug_assert (! (decl_isImp (m))); - return m; + mcDebug_assert (! (decl_isImp (static_cast (m)))); + return static_cast (m); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -22966,7 +23066,7 @@ extern "C" decl_node decl_lookupModule (nameKey_Name n) extern "C" void decl_putDefForC (decl_node n) { mcDebug_assert (decl_isDef (n)); - n->defF.forC = true; + static_cast (n)->defF.forC = true; } @@ -22976,26 +23076,26 @@ extern "C" void decl_putDefForC (decl_node n) extern "C" decl_node decl_lookupInScope (decl_node scope, nameKey_Name n) { - switch (scope->kind) + switch (static_cast (scope)->kind) { case decl_def: - return static_cast (symbolKey_getSymKey (scope->defF.decls.symbols, n)); + return static_cast (symbolKey_getSymKey (static_cast (scope)->defF.decls.symbols, n)); break; case decl_module: - return static_cast (symbolKey_getSymKey (scope->moduleF.decls.symbols, n)); + return static_cast (symbolKey_getSymKey (static_cast (scope)->moduleF.decls.symbols, n)); break; case decl_imp: - return static_cast (symbolKey_getSymKey (scope->impF.decls.symbols, n)); + return static_cast (symbolKey_getSymKey (static_cast (scope)->impF.decls.symbols, n)); break; case decl_procedure: - return static_cast (symbolKey_getSymKey (scope->procedureF.decls.symbols, n)); + return static_cast (symbolKey_getSymKey (static_cast (scope)->procedureF.decls.symbols, n)); break; case decl_record: - return static_cast (symbolKey_getSymKey (scope->recordF.localSymbols, n)); + return static_cast (symbolKey_getSymKey (static_cast (scope)->recordF.localSymbols, n)); break; @@ -23015,7 +23115,7 @@ extern "C" decl_node decl_lookupInScope (decl_node scope, nameKey_Name n) extern "C" bool decl_isConst (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_const; + return static_cast (n)->kind == decl_const; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -23028,7 +23128,7 @@ extern "C" bool decl_isConst (decl_node n) extern "C" bool decl_isType (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_type; + return static_cast (n)->kind == decl_type; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -23043,7 +23143,7 @@ extern "C" void decl_putType (decl_node des, decl_node exp) { mcDebug_assert (des != NULL); mcDebug_assert (decl_isType (des)); - des->typeF.type = exp; + static_cast (des)->typeF.type = static_cast (exp); } @@ -23053,31 +23153,31 @@ extern "C" void decl_putType (decl_node des, decl_node exp) extern "C" decl_node decl_getType (decl_node n) { - switch (n->kind) + switch (static_cast (n)->kind) { case decl_new: case decl_dispose: - return NULL; + return static_cast (NULL); break; case decl_length: - return cardinalN; + return static_cast (cardinalN); break; case decl_inc: case decl_dec: case decl_incl: case decl_excl: - return NULL; + return static_cast (NULL); break; case decl_nil: - return addressN; + return static_cast (addressN); break; case decl_true: case decl_false: - return booleanN; + return static_cast (booleanN); break; case decl_address: @@ -23179,7 +23279,7 @@ extern "C" decl_node decl_getType (decl_node n) case decl_type: /* language features and compound type attributes. */ - return n->typeF.type; + return static_cast (static_cast (n)->typeF.type); break; case decl_record: @@ -23191,7 +23291,7 @@ extern "C" decl_node decl_getType (decl_node n) break; case decl_var: - return n->varF.type; + return static_cast (static_cast (n)->varF.type); break; case decl_enumeration: @@ -23199,43 +23299,43 @@ extern "C" decl_node decl_getType (decl_node n) break; case decl_subrange: - return n->subrangeF.type; + return static_cast (static_cast (n)->subrangeF.type); break; case decl_array: - return n->arrayF.type; + return static_cast (static_cast (n)->arrayF.type); break; case decl_string: - return charN; + return static_cast (charN); break; case decl_const: - return n->constF.type; + return static_cast (static_cast (n)->constF.type); break; case decl_literal: - return n->literalF.type; + return static_cast (static_cast (n)->literalF.type); break; case decl_varparam: - return n->varparamF.type; + return static_cast (static_cast (n)->varparamF.type); break; case decl_param: - return n->paramF.type; + return static_cast (static_cast (n)->paramF.type); break; case decl_optarg: - return n->optargF.type; + return static_cast (static_cast (n)->optargF.type); break; case decl_pointer: - return n->pointerF.type; + return static_cast (static_cast (n)->pointerF.type); break; case decl_recordfield: - return n->recordfieldF.type; + return static_cast (static_cast (n)->recordfieldF.type); break; case decl_varientfield: @@ -23243,32 +23343,32 @@ extern "C" decl_node decl_getType (decl_node n) break; case decl_enumerationfield: - return n->enumerationfieldF.type; + return static_cast (static_cast (n)->enumerationfieldF.type); break; case decl_set: - return n->setF.type; + return static_cast (static_cast (n)->setF.type); break; case decl_proctype: - return n->proctypeF.returnType; + return static_cast (static_cast (n)->proctypeF.returnType); break; case decl_subscript: - return n->subscriptF.type; + return static_cast (static_cast (n)->subscriptF.type); break; case decl_procedure: /* blocks. */ - return n->procedureF.returnType; + return static_cast (static_cast (n)->procedureF.returnType); break; case decl_throw: - return NULL; + return static_cast (NULL); break; case decl_unreachable: - return NULL; + return static_cast (NULL); break; case decl_def: @@ -23296,11 +23396,11 @@ extern "C" decl_node decl_getType (decl_node n) case decl_mult: case decl_divide: /* expressions. */ - return n->binaryF.resultType; + return static_cast (static_cast (n)->binaryF.resultType); break; case decl_in: - return booleanN; + return static_cast (booleanN); break; case decl_max: @@ -23314,7 +23414,7 @@ extern "C" decl_node decl_getType (decl_node n) case decl_adr: case decl_size: case decl_tsize: - return n->unaryF.resultType; + return static_cast (static_cast (n)->unaryF.resultType); break; case decl_and: @@ -23326,51 +23426,51 @@ extern "C" decl_node decl_getType (decl_node n) case decl_greater: case decl_greequal: case decl_lessequal: - return booleanN; + return static_cast (booleanN); break; case decl_trunc: - return integerN; + return static_cast (integerN); break; case decl_float: - return realN; + return static_cast (realN); break; case decl_high: - return cardinalN; + return static_cast (cardinalN); break; case decl_ord: - return cardinalN; + return static_cast (cardinalN); break; case decl_chr: - return charN; + return static_cast (charN); break; case decl_cap: - return charN; + return static_cast (charN); break; case decl_arrayref: - return n->arrayrefF.resultType; + return static_cast (static_cast (n)->arrayrefF.resultType); break; case decl_componentref: - return n->componentrefF.resultType; + return static_cast (static_cast (n)->componentrefF.resultType); break; case decl_pointerref: - return n->pointerrefF.resultType; + return static_cast (static_cast (n)->pointerrefF.resultType); break; case decl_funccall: - return n->funccallF.type; + return static_cast (static_cast (n)->funccallF.type); break; case decl_setvalue: - return n->setvalueF.type; + return static_cast (static_cast (n)->setvalueF.type); break; @@ -23413,13 +23513,13 @@ extern "C" decl_node decl_skipType (decl_node n) extern "C" void decl_putTypeHidden (decl_node des) { - decl_node s; + decl_node__opaque s; mcDebug_assert (des != NULL); mcDebug_assert (decl_isType (des)); - des->typeF.isHidden = true; - s = decl_getScope (des); - mcDebug_assert (decl_isDef (s)); + static_cast (des)->typeF.isHidden = true; + s = static_cast (decl_getScope (des)); + mcDebug_assert (decl_isDef (static_cast (s))); s->defF.hasHidden = true; } @@ -23432,7 +23532,7 @@ extern "C" bool decl_isTypeHidden (decl_node n) { mcDebug_assert (n != NULL); mcDebug_assert (decl_isType (n)); - return n->typeF.isHidden; + return static_cast (n)->typeF.isHidden; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -23445,7 +23545,36 @@ extern "C" bool decl_isTypeHidden (decl_node n) extern "C" bool decl_hasHidden (decl_node n) { mcDebug_assert (decl_isDef (n)); - return n->defF.hasHidden; + return static_cast (n)->defF.hasHidden; + /* static analysis guarentees a RETURN statement will be used before here. */ + __builtin_unreachable (); +} + + +/* + putTypeOpaque - marks type, des, as being an opaque type. + TYPE des ; +*/ + +extern "C" void decl_putTypeOpaque (decl_node des) +{ + decl_node__opaque s; + + mcDebug_assert (des != NULL); + mcDebug_assert (decl_isType (des)); + static_cast (des)->typeF.isOpaque = true; +} + + +/* + isTypeOpaque - returns TRUE if type, n, is an opaque type. +*/ + +extern "C" bool decl_isTypeOpaque (decl_node n) +{ + mcDebug_assert (n != NULL); + mcDebug_assert (decl_isType (n)); + return static_cast (n)->typeF.isOpaque; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -23458,7 +23587,7 @@ extern "C" bool decl_hasHidden (decl_node n) extern "C" bool decl_isVar (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_var; + return static_cast (n)->kind == decl_var; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -23483,9 +23612,9 @@ extern "C" bool decl_isTemporary (decl_node n) extern "C" bool decl_isExported (decl_node n) { - decl_node s; + decl_node__opaque s; - s = decl_getScope (n); + s = static_cast (decl_getScope (n)); if (s != NULL) { switch (s->kind) @@ -23528,7 +23657,7 @@ extern "C" decl_node decl_getDeclScope (void) extern "C" decl_node decl_getScope (decl_node n) { - switch (n->kind) + switch (static_cast (n)->kind) { case decl_stmtseq: case decl_exit: @@ -23547,7 +23676,7 @@ extern "C" decl_node decl_getScope (decl_node n) case decl_nil: case decl_true: case decl_false: - return NULL; + return static_cast (NULL); break; case decl_address: @@ -23556,7 +23685,7 @@ extern "C" decl_node decl_getScope (decl_node n) case decl_word: case decl_csizet: case decl_cssizet: - return systemN; + return static_cast (systemN); break; case decl_boolean: @@ -23578,93 +23707,93 @@ extern "C" decl_node decl_getScope (decl_node n) case decl_longcomplex: case decl_shortcomplex: /* base types. */ - return NULL; + return static_cast (NULL); break; case decl_type: /* language features and compound type attributes. */ - return n->typeF.scope; + return static_cast (static_cast (n)->typeF.scope); break; case decl_record: - return n->recordF.scope; + return static_cast (static_cast (n)->recordF.scope); break; case decl_varient: - return n->varientF.scope; + return static_cast (static_cast (n)->varientF.scope); break; case decl_var: - return n->varF.scope; + return static_cast (static_cast (n)->varF.scope); break; case decl_enumeration: - return n->enumerationF.scope; + return static_cast (static_cast (n)->enumerationF.scope); break; case decl_subrange: - return n->subrangeF.scope; + return static_cast (static_cast (n)->subrangeF.scope); break; case decl_array: - return n->arrayF.scope; + return static_cast (static_cast (n)->arrayF.scope); break; case decl_string: - return NULL; + return static_cast (NULL); break; case decl_const: - return n->constF.scope; + return static_cast (static_cast (n)->constF.scope); break; case decl_literal: - return NULL; + return static_cast (NULL); break; case decl_varparam: - return n->varparamF.scope; + return static_cast (static_cast (n)->varparamF.scope); break; case decl_param: - return n->paramF.scope; + return static_cast (static_cast (n)->paramF.scope); break; case decl_optarg: - return n->optargF.scope; + return static_cast (static_cast (n)->optargF.scope); break; case decl_pointer: - return n->pointerF.scope; + return static_cast (static_cast (n)->pointerF.scope); break; case decl_recordfield: - return n->recordfieldF.scope; + return static_cast (static_cast (n)->recordfieldF.scope); break; case decl_varientfield: - return n->varientfieldF.scope; + return static_cast (static_cast (n)->varientfieldF.scope); break; case decl_enumerationfield: - return n->enumerationfieldF.scope; + return static_cast (static_cast (n)->enumerationfieldF.scope); break; case decl_set: - return n->setF.scope; + return static_cast (static_cast (n)->setF.scope); break; case decl_proctype: - return n->proctypeF.scope; + return static_cast (static_cast (n)->proctypeF.scope); break; case decl_subscript: - return NULL; + return static_cast (NULL); break; case decl_procedure: /* blocks. */ - return n->procedureF.scope; + return static_cast (static_cast (n)->procedureF.scope); break; case decl_def: @@ -23679,7 +23808,7 @@ extern "C" decl_node decl_getScope (decl_node n) case decl_elsif: case decl_assignment: /* statements. */ - return NULL; + return static_cast (NULL); break; case decl_componentref: @@ -23701,11 +23830,11 @@ extern "C" decl_node decl_getScope (decl_node n) case decl_divide: case decl_in: /* expressions. */ - return NULL; + return static_cast (NULL); break; case decl_neg: - return NULL; + return static_cast (NULL); break; case decl_lsl: @@ -23725,14 +23854,14 @@ extern "C" decl_node decl_getScope (decl_node n) case decl_greater: case decl_greequal: case decl_lessequal: - return NULL; + return static_cast (NULL); break; case decl_adr: case decl_size: case decl_tsize: case decl_throw: - return systemN; + return static_cast (systemN); break; case decl_unreachable: @@ -23741,35 +23870,35 @@ extern "C" decl_node decl_getScope (decl_node n) case decl_im: case decl_min: case decl_max: - return NULL; + return static_cast (NULL); break; case decl_vardecl: - return n->vardeclF.scope; + return static_cast (static_cast (n)->vardeclF.scope); break; case decl_funccall: - return NULL; + return static_cast (NULL); break; case decl_explist: - return NULL; + return static_cast (NULL); break; case decl_caselabellist: - return NULL; + return static_cast (NULL); break; case decl_caselist: - return NULL; + return static_cast (NULL); break; case decl_range: - return NULL; + return static_cast (NULL); break; case decl_varargs: - return n->varargsF.scope; + return static_cast (static_cast (n)->varargsF.scope); break; @@ -23789,7 +23918,7 @@ extern "C" decl_node decl_getScope (decl_node n) extern "C" bool decl_isLiteral (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_literal; + return static_cast (n)->kind == decl_literal; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -23819,7 +23948,7 @@ extern "C" bool decl_isConstSet (decl_node n) extern "C" bool decl_isEnumerationField (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_enumerationfield; + return static_cast (n)->kind == decl_enumerationfield; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -23832,7 +23961,7 @@ extern "C" bool decl_isEnumerationField (decl_node n) extern "C" bool decl_isEnumeration (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_enumeration; + return static_cast (n)->kind == decl_enumeration; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -23845,7 +23974,7 @@ extern "C" bool decl_isEnumeration (decl_node n) extern "C" bool decl_isUnbounded (decl_node n) { mcDebug_assert (n != NULL); - return (n->kind == decl_array) && n->arrayF.isUnbounded; + return (static_cast (n)->kind == decl_array) && static_cast (n)->arrayF.isUnbounded; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -23858,7 +23987,7 @@ extern "C" bool decl_isUnbounded (decl_node n) extern "C" bool decl_isParameter (decl_node n) { mcDebug_assert (n != NULL); - return (n->kind == decl_param) || (n->kind == decl_varparam); + return (static_cast (n)->kind == decl_param) || (static_cast (n)->kind == decl_varparam); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -23871,7 +24000,7 @@ extern "C" bool decl_isParameter (decl_node n) extern "C" bool decl_isVarParam (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_varparam; + return static_cast (n)->kind == decl_varparam; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -23884,7 +24013,7 @@ extern "C" bool decl_isVarParam (decl_node n) extern "C" bool decl_isParam (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_param; + return static_cast (n)->kind == decl_param; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -23910,19 +24039,19 @@ extern "C" bool decl_isNonVarParam (decl_node n) extern "C" decl_node decl_addOptParameter (decl_node proc, nameKey_Name id, decl_node type, decl_node init) { - decl_node p; - decl_node l; + decl_node__opaque p; + decl_node__opaque l; mcDebug_assert (decl_isProcedure (proc)); - l = decl_makeIdentList (); - mcDebug_assert (decl_putIdent (l, id)); - checkMakeVariables (proc, l, type, false, true); - if (! proc->procedureF.checking) + l = static_cast (decl_makeIdentList ()); + mcDebug_assert (decl_putIdent (static_cast (l), id)); + checkMakeVariables (static_cast (proc), l, static_cast (type), false, true); + if (! static_cast (proc)->procedureF.checking) { - p = makeOptParameter (l, type, init); - decl_addParameter (proc, p); + p = makeOptParameter (l, static_cast (type), static_cast (init)); + decl_addParameter (proc, static_cast (p)); } - return p; + return static_cast (p); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -23934,7 +24063,7 @@ extern "C" decl_node decl_addOptParameter (decl_node proc, nameKey_Name id, decl extern "C" bool decl_isOptarg (decl_node n) { - return n->kind == decl_optarg; + return static_cast (n)->kind == decl_optarg; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -23947,7 +24076,7 @@ extern "C" bool decl_isOptarg (decl_node n) extern "C" bool decl_isRecord (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_record; + return static_cast (n)->kind == decl_record; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -23960,7 +24089,7 @@ extern "C" bool decl_isRecord (decl_node n) extern "C" bool decl_isRecordField (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_recordfield; + return static_cast (n)->kind == decl_recordfield; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -23973,7 +24102,7 @@ extern "C" bool decl_isRecordField (decl_node n) extern "C" bool decl_isVarientField (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_varientfield; + return static_cast (n)->kind == decl_varientfield; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -23986,7 +24115,7 @@ extern "C" bool decl_isVarientField (decl_node n) extern "C" bool decl_isArray (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_array; + return static_cast (n)->kind == decl_array; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -23999,7 +24128,7 @@ extern "C" bool decl_isArray (decl_node n) extern "C" bool decl_isProcType (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_proctype; + return static_cast (n)->kind == decl_proctype; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -24012,7 +24141,7 @@ extern "C" bool decl_isProcType (decl_node n) extern "C" bool decl_isPointer (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_pointer; + return static_cast (n)->kind == decl_pointer; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -24025,7 +24154,7 @@ extern "C" bool decl_isPointer (decl_node n) extern "C" bool decl_isProcedure (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_procedure; + return static_cast (n)->kind == decl_procedure; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -24038,7 +24167,7 @@ extern "C" bool decl_isProcedure (decl_node n) extern "C" bool decl_isVarient (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_varient; + return static_cast (n)->kind == decl_varient; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -24051,7 +24180,7 @@ extern "C" bool decl_isVarient (decl_node n) extern "C" bool decl_isSet (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_set; + return static_cast (n)->kind == decl_set; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -24064,7 +24193,7 @@ extern "C" bool decl_isSet (decl_node n) extern "C" bool decl_isSubrange (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_subrange; + return static_cast (n)->kind == decl_subrange; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -24100,14 +24229,14 @@ extern "C" bool decl_isRtype (decl_node n) extern "C" decl_node decl_makeConst (nameKey_Name n) { - decl_node d; + decl_node__opaque d; d = newNode (decl_const); d->constF.name = n; - d->constF.type = NULL; - d->constF.scope = decl_getDeclScope (); - d->constF.value = NULL; - return addToScope (d); + d->constF.type = static_cast (NULL); + d->constF.scope = static_cast (decl_getDeclScope ()); + d->constF.value = static_cast (NULL); + return static_cast (addToScope (d)); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -24120,7 +24249,7 @@ extern "C" decl_node decl_makeConst (nameKey_Name n) extern "C" void decl_putConst (decl_node n, decl_node v) { mcDebug_assert (decl_isConst (n)); - n->constF.value = v; + static_cast (n)->constF.value = static_cast (v); } @@ -24130,15 +24259,16 @@ extern "C" void decl_putConst (decl_node n, decl_node v) extern "C" decl_node decl_makeType (nameKey_Name n) { - decl_node d; + decl_node__opaque d; d = newNode (decl_type); d->typeF.name = n; - d->typeF.type = NULL; - d->typeF.scope = decl_getDeclScope (); + d->typeF.type = static_cast (NULL); + d->typeF.scope = static_cast (decl_getDeclScope ()); + d->typeF.isOpaque = false; d->typeF.isHidden = false; d->typeF.isInternal = false; - return addToScope (d); + return static_cast (addToScope (d)); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -24151,22 +24281,23 @@ extern "C" decl_node decl_makeType (nameKey_Name n) extern "C" decl_node decl_makeTypeImp (nameKey_Name n) { - decl_node d; + decl_node__opaque d; - d = decl_lookupSym (n); + d = static_cast (decl_lookupSym (n)); if (d != NULL) { d->typeF.isHidden = false; - return addToScope (d); + return static_cast (addToScope (d)); } else { d = newNode (decl_type); d->typeF.name = n; - d->typeF.type = NULL; - d->typeF.scope = decl_getDeclScope (); + d->typeF.type = static_cast (NULL); + d->typeF.scope = static_cast (decl_getDeclScope ()); + d->typeF.isOpaque = false; d->typeF.isHidden = false; - return addToScope (d); + return static_cast (addToScope (d)); } /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -24179,18 +24310,18 @@ extern "C" decl_node decl_makeTypeImp (nameKey_Name n) extern "C" decl_node decl_makeVar (nameKey_Name n) { - decl_node d; + decl_node__opaque d; d = newNode (decl_var); d->varF.name = n; - d->varF.type = NULL; - d->varF.decl = NULL; - d->varF.scope = decl_getDeclScope (); + d->varF.type = static_cast (NULL); + d->varF.decl = static_cast (NULL); + d->varF.scope = static_cast (decl_getDeclScope ()); d->varF.isInitialised = false; d->varF.isParameter = false; d->varF.isVarParameter = false; initCname (&d->varF.cname); - return addToScope (d); + return static_cast (addToScope (d)); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -24204,8 +24335,9 @@ extern "C" void decl_putVar (decl_node var, decl_node type, decl_node decl) { mcDebug_assert (var != NULL); mcDebug_assert (decl_isVar (var)); - var->varF.type = type; - var->varF.decl = decl; + static_cast (var)->varF.type = static_cast (type); + static_cast (var)->varF.decl = static_cast (decl); + initNodeOpaqueState (static_cast (var)); } @@ -24216,26 +24348,26 @@ extern "C" void decl_putVar (decl_node var, decl_node type, decl_node decl) extern "C" decl_node decl_makeVarDecl (decl_node i, decl_node type) { - decl_node d; - decl_node v; + decl_node__opaque d; + decl_node__opaque v; unsigned int j; unsigned int n; - type = checkPtr (type); + type = static_cast (checkPtr (static_cast (type))); d = newNode (decl_vardecl); - d->vardeclF.names = i->identlistF.names; - d->vardeclF.type = type; - d->vardeclF.scope = decl_getDeclScope (); + d->vardeclF.names = static_cast (i)->identlistF.names; + d->vardeclF.type = static_cast (type); + d->vardeclF.scope = static_cast (decl_getDeclScope ()); n = wlists_noOfItemsInList (d->vardeclF.names); j = 1; while (j <= n) { - v = decl_lookupSym (wlists_getItemFromList (d->vardeclF.names, j)); - mcDebug_assert (decl_isVar (v)); - decl_putVar (v, type, d); + v = static_cast (decl_lookupSym (wlists_getItemFromList (d->vardeclF.names, j))); + mcDebug_assert (decl_isVar (static_cast (v))); + decl_putVar (static_cast (v), type, static_cast (d)); j += 1; } - return d; + return static_cast (d); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -24247,13 +24379,13 @@ extern "C" decl_node decl_makeVarDecl (decl_node i, decl_node type) extern "C" decl_node decl_makeEnum (void) { - if ((currentModule != NULL) && (decl_getEnumsComplete (currentModule))) + if ((currentModule != NULL) && (decl_getEnumsComplete (static_cast (currentModule)))) { return decl_getNextEnum (); } else { - return doMakeEnum (); + return static_cast (doMakeEnum ()); } /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -24266,13 +24398,13 @@ extern "C" decl_node decl_makeEnum (void) extern "C" decl_node decl_makeEnumField (decl_node e, nameKey_Name n) { - if ((currentModule != NULL) && (decl_getEnumsComplete (currentModule))) + if ((currentModule != NULL) && (decl_getEnumsComplete (static_cast (currentModule)))) { return decl_getNextEnum (); } else { - return doMakeEnumField (e, n); + return static_cast (doMakeEnumField (static_cast (e), n)); } /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -24285,14 +24417,14 @@ extern "C" decl_node decl_makeEnumField (decl_node e, nameKey_Name n) extern "C" decl_node decl_makeSubrange (decl_node low, decl_node high) { - decl_node n; + decl_node__opaque n; n = newNode (decl_subrange); - n->subrangeF.low = low; - n->subrangeF.high = high; - n->subrangeF.type = NULL; - n->subrangeF.scope = decl_getDeclScope (); - return n; + n->subrangeF.low = static_cast (low); + n->subrangeF.high = static_cast (high); + n->subrangeF.type = static_cast (NULL); + n->subrangeF.scope = static_cast (decl_getDeclScope ()); + return static_cast (n); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -24305,7 +24437,7 @@ extern "C" decl_node decl_makeSubrange (decl_node low, decl_node high) extern "C" void decl_putSubrangeType (decl_node sub, decl_node type) { mcDebug_assert (decl_isSubrange (sub)); - sub->subrangeF.type = type; + static_cast (sub)->subrangeF.type = static_cast (type); } @@ -24315,12 +24447,12 @@ extern "C" void decl_putSubrangeType (decl_node sub, decl_node type) extern "C" decl_node decl_makePointer (decl_node type) { - decl_node n; + decl_node__opaque n; n = newNode (decl_pointer); - n->pointerF.type = type; - n->pointerF.scope = decl_getDeclScope (); - return n; + n->pointerF.type = static_cast (type); + n->pointerF.scope = static_cast (decl_getDeclScope ()); + return static_cast (n); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -24332,12 +24464,12 @@ extern "C" decl_node decl_makePointer (decl_node type) extern "C" decl_node decl_makeSet (decl_node type) { - decl_node n; + decl_node__opaque n; n = newNode (decl_set); - n->setF.type = type; - n->setF.scope = decl_getDeclScope (); - return n; + n->setF.type = static_cast (type); + n->setF.scope = static_cast (decl_getDeclScope ()); + return static_cast (n); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -24349,17 +24481,17 @@ extern "C" decl_node decl_makeSet (decl_node type) extern "C" decl_node decl_makeArray (decl_node subr, decl_node type) { - decl_node n; - decl_node s; + decl_node__opaque n; + decl_node__opaque s; - s = decl_skipType (subr); - mcDebug_assert (((decl_isSubrange (s)) || (isOrdinal (s))) || (decl_isEnumeration (s))); + s = static_cast (decl_skipType (subr)); + mcDebug_assert (((decl_isSubrange (static_cast (s))) || (isOrdinal (s))) || (decl_isEnumeration (static_cast (s)))); n = newNode (decl_array); - n->arrayF.subr = subr; - n->arrayF.type = type; - n->arrayF.scope = decl_getDeclScope (); + n->arrayF.subr = static_cast (subr); + n->arrayF.type = static_cast (type); + n->arrayF.scope = static_cast (decl_getDeclScope ()); n->arrayF.isUnbounded = false; - return n; + return static_cast (n); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -24371,8 +24503,8 @@ extern "C" decl_node decl_makeArray (decl_node subr, decl_node type) extern "C" void decl_putUnbounded (decl_node n) { - mcDebug_assert (n->kind == decl_array); - n->arrayF.isUnbounded = true; + mcDebug_assert (static_cast (n)->kind == decl_array); + static_cast (n)->arrayF.isUnbounded = true; } @@ -24382,13 +24514,13 @@ extern "C" void decl_putUnbounded (decl_node n) extern "C" decl_node decl_makeRecord (void) { - decl_node n; + decl_node__opaque n; n = newNode (decl_record); n->recordF.localSymbols = symbolKey_initTree (); n->recordF.listOfSons = Indexing_InitIndex (1); - n->recordF.scope = decl_getDeclScope (); - return n; + n->recordF.scope = static_cast (decl_getDeclScope ()); + return static_cast (n); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -24401,30 +24533,30 @@ extern "C" decl_node decl_makeRecord (void) extern "C" decl_node decl_makeVarient (decl_node r) { - decl_node n; + decl_node__opaque n; n = newNode (decl_varient); n->varientF.listOfSons = Indexing_InitIndex (1); /* if so use this n^.varientF.parent := r */ if (decl_isRecord (r)) { - n->varientF.varient = NULL; + n->varientF.varient = static_cast (NULL); } else { - n->varientF.varient = r; + n->varientF.varient = static_cast (r); } - n->varientF.tag = NULL; - n->varientF.scope = decl_getDeclScope (); - switch (r->kind) + n->varientF.tag = static_cast (NULL); + n->varientF.scope = static_cast (decl_getDeclScope ()); + switch (static_cast (r)->kind) { case decl_record: /* now add, n, to the record/varient, r, field list */ - Indexing_IncludeIndiceIntoIndex (r->recordF.listOfSons, reinterpret_cast (n)); + Indexing_IncludeIndiceIntoIndex (static_cast (r)->recordF.listOfSons, reinterpret_cast (n)); break; case decl_varientfield: - Indexing_IncludeIndiceIntoIndex (r->varientfieldF.listOfSons, reinterpret_cast (n)); + Indexing_IncludeIndiceIntoIndex (static_cast (r)->varientfieldF.listOfSons, reinterpret_cast (n)); break; @@ -24432,7 +24564,7 @@ extern "C" decl_node decl_makeVarient (decl_node r) CaseException ("../../gcc/m2/mc/decl.def", 20, 1); __builtin_unreachable (); } - return n; + return static_cast (n); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -24445,33 +24577,33 @@ extern "C" decl_node decl_makeVarient (decl_node r) extern "C" decl_node decl_addFieldsToRecord (decl_node r, decl_node v, decl_node i, decl_node t) { - decl_node p; - decl_node fj; + decl_node__opaque p; + decl_node__opaque fj; unsigned int j; unsigned int n; nameKey_Name fn; if (decl_isRecord (r)) { - p = r; - v = NULL; + p = static_cast (r); + v = static_cast (NULL); } else { - p = getRecord (getParent (r)); + p = getRecord (getParent (static_cast (r))); mcDebug_assert (decl_isVarientField (r)); mcDebug_assert (decl_isVarient (v)); - putFieldVarient (r, v); + putFieldVarient (static_cast (r), static_cast (v)); } - n = wlists_noOfItemsInList (i->identlistF.names); + n = wlists_noOfItemsInList (static_cast (i)->identlistF.names); j = 1; while (j <= n) { - fn = static_cast (wlists_getItemFromList (i->identlistF.names, j)); - fj = static_cast (symbolKey_getSymKey (p->recordF.localSymbols, n)); + fn = static_cast (wlists_getItemFromList (static_cast (i)->identlistF.names, j)); + fj = static_cast (symbolKey_getSymKey (p->recordF.localSymbols, n)); if (fj == NULL) { - fj = putFieldRecord (r, fn, t, v); + fj = putFieldRecord (static_cast (r), fn, static_cast (t), static_cast (v)); } else { @@ -24493,7 +24625,7 @@ extern "C" decl_node decl_addFieldsToRecord (decl_node r, decl_node v, decl_node extern "C" void decl_buildVarientSelector (decl_node r, decl_node v, nameKey_Name tag, decl_node type) { - decl_node f; + decl_node__opaque f; mcDebug_assert ((decl_isRecord (r)) || (decl_isVarientField (r))); if ((decl_isRecord (r)) || (decl_isVarientField (r))) @@ -24506,16 +24638,16 @@ extern "C" void decl_buildVarientSelector (decl_node r, decl_node v, nameKey_Nam else if (type == NULL) { /* avoid dangling else. */ - f = decl_lookupSym (tag); - putVarientTag (v, f); + f = static_cast (decl_lookupSym (tag)); + putVarientTag (static_cast (v), f); } else { /* avoid dangling else. */ - f = putFieldRecord (r, tag, type, v); - mcDebug_assert (decl_isRecordField (f)); + f = putFieldRecord (static_cast (r), tag, static_cast (type), static_cast (v)); + mcDebug_assert (decl_isRecordField (static_cast (f))); f->recordfieldF.tag = true; - putVarientTag (v, f); + putVarientTag (static_cast (v), f); } } } @@ -24528,13 +24660,13 @@ extern "C" void decl_buildVarientSelector (decl_node r, decl_node v, nameKey_Nam extern "C" decl_node decl_buildVarientFieldRecord (decl_node v, decl_node p) { - decl_node f; + decl_node__opaque f; mcDebug_assert (decl_isVarient (v)); - f = makeVarientField (v, p); - mcDebug_assert (decl_isVarientField (f)); - putFieldVarient (f, v); - return f; + f = makeVarientField (static_cast (v), static_cast (p)); + mcDebug_assert (decl_isVarientField (static_cast (f))); + putFieldVarient (f, static_cast (v)); + return static_cast (f); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -24546,7 +24678,7 @@ extern "C" decl_node decl_buildVarientFieldRecord (decl_node v, decl_node p) extern "C" nameKey_Name decl_getSymName (decl_node n) { - switch (n->kind) + switch (static_cast (n)->kind) { case decl_new: return nameKey_makeKey ((const char *) "NEW", 3); @@ -24687,7 +24819,7 @@ extern "C" nameKey_Name decl_getSymName (decl_node n) case decl_type: /* language features and compound type attributes. */ - return n->typeF.name; + return static_cast (n)->typeF.name; break; case decl_record: @@ -24699,7 +24831,7 @@ extern "C" nameKey_Name decl_getSymName (decl_node n) break; case decl_var: - return n->varF.name; + return static_cast (n)->varF.name; break; case decl_enumeration: @@ -24719,15 +24851,15 @@ extern "C" nameKey_Name decl_getSymName (decl_node n) break; case decl_string: - return n->stringF.name; + return static_cast (n)->stringF.name; break; case decl_const: - return n->constF.name; + return static_cast (n)->constF.name; break; case decl_literal: - return n->literalF.name; + return static_cast (n)->literalF.name; break; case decl_varparam: @@ -24743,15 +24875,15 @@ extern "C" nameKey_Name decl_getSymName (decl_node n) break; case decl_recordfield: - return n->recordfieldF.name; + return static_cast (n)->recordfieldF.name; break; case decl_varientfield: - return n->varientfieldF.name; + return static_cast (n)->varientfieldF.name; break; case decl_enumerationfield: - return n->enumerationfieldF.name; + return static_cast (n)->enumerationfieldF.name; break; case decl_set: @@ -24768,19 +24900,19 @@ extern "C" nameKey_Name decl_getSymName (decl_node n) case decl_procedure: /* blocks. */ - return n->procedureF.name; + return static_cast (n)->procedureF.name; break; case decl_def: - return n->defF.name; + return static_cast (n)->defF.name; break; case decl_imp: - return n->impF.name; + return static_cast (n)->impF.name; break; case decl_module: - return n->moduleF.name; + return static_cast (n)->moduleF.name; break; case decl_loop: @@ -24915,25 +25047,25 @@ extern "C" nameKey_Name decl_getSymName (decl_node n) extern "C" decl_node decl_import (decl_node m, decl_node n) { nameKey_Name name; - decl_node r; + decl_node__opaque r; mcDebug_assert (((decl_isDef (m)) || (decl_isModule (m))) || (decl_isImp (m))); name = decl_getSymName (n); - r = decl_lookupInScope (m, name); + r = static_cast (decl_lookupInScope (m, name)); if (r == NULL) { - switch (m->kind) + switch (static_cast (m)->kind) { case decl_def: - symbolKey_putSymKey (m->defF.decls.symbols, name, reinterpret_cast (n)); + symbolKey_putSymKey (static_cast (m)->defF.decls.symbols, name, reinterpret_cast (n)); break; case decl_imp: - symbolKey_putSymKey (m->impF.decls.symbols, name, reinterpret_cast (n)); + symbolKey_putSymKey (static_cast (m)->impF.decls.symbols, name, reinterpret_cast (n)); break; case decl_module: - symbolKey_putSymKey (m->moduleF.decls.symbols, name, reinterpret_cast (n)); + symbolKey_putSymKey (static_cast (m)->moduleF.decls.symbols, name, reinterpret_cast (n)); break; @@ -24941,10 +25073,10 @@ extern "C" decl_node decl_import (decl_node m, decl_node n) CaseException ("../../gcc/m2/mc/decl.def", 20, 1); __builtin_unreachable (); } - importEnumFields (m, n); + importEnumFields (static_cast (m), static_cast (n)); return n; } - return r; + return static_cast (r); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -24958,15 +25090,15 @@ extern "C" decl_node decl_import (decl_node m, decl_node n) extern "C" decl_node decl_lookupExported (decl_node n, nameKey_Name i) { - decl_node r; + decl_node__opaque r; mcDebug_assert (decl_isDef (n)); - r = static_cast (symbolKey_getSymKey (n->defF.decls.symbols, i)); - if ((r != NULL) && (decl_isExported (r))) + r = static_cast (symbolKey_getSymKey (static_cast (n)->defF.decls.symbols, i)); + if ((r != NULL) && (decl_isExported (static_cast (r)))) { - return r; + return static_cast (r); } - return NULL; + return static_cast (NULL); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -24978,8 +25110,8 @@ extern "C" decl_node decl_lookupExported (decl_node n, nameKey_Name i) extern "C" decl_node decl_lookupSym (nameKey_Name n) { - decl_node s; - decl_node m; + decl_node__opaque s; + decl_node__opaque m; unsigned int l; unsigned int h; @@ -24987,8 +25119,8 @@ extern "C" decl_node decl_lookupSym (nameKey_Name n) h = Indexing_HighIndice (scopeStack); while (h >= l) { - s = static_cast (Indexing_GetIndice (scopeStack, h)); - m = decl_lookupInScope (s, n); + s = static_cast (Indexing_GetIndice (scopeStack, h)); + m = static_cast (decl_lookupInScope (static_cast (s), n)); if (debugScopes && (m == NULL)) { out3 ((const char *) " [%d] search for symbol name %s in scope %s\\n", 45, h, n, s); @@ -24999,11 +25131,11 @@ extern "C" decl_node decl_lookupSym (nameKey_Name n) { out3 ((const char *) " [%d] search for symbol name %s in scope %s (found)\\n", 53, h, n, s); } - return m; + return static_cast (m); } h -= 1; } - return lookupBase (n); + return static_cast (lookupBase (n)); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -25020,17 +25152,17 @@ extern "C" void decl_addImportedModule (decl_node m, decl_node i, bool scoped) mcDebug_assert ((decl_isDef (i)) || (decl_isModule (i))); if (decl_isDef (m)) { - Indexing_IncludeIndiceIntoIndex (m->defF.importedModules, reinterpret_cast (i)); + Indexing_IncludeIndiceIntoIndex (static_cast (m)->defF.importedModules, reinterpret_cast (i)); } else if (decl_isImp (m)) { /* avoid dangling else. */ - Indexing_IncludeIndiceIntoIndex (m->impF.importedModules, reinterpret_cast (i)); + Indexing_IncludeIndiceIntoIndex (static_cast (m)->impF.importedModules, reinterpret_cast (i)); } else if (decl_isModule (m)) { /* avoid dangling else. */ - Indexing_IncludeIndiceIntoIndex (m->moduleF.importedModules, reinterpret_cast (i)); + Indexing_IncludeIndiceIntoIndex (static_cast (m)->moduleF.importedModules, reinterpret_cast (i)); } else { @@ -25040,7 +25172,7 @@ extern "C" void decl_addImportedModule (decl_node m, decl_node i, bool scoped) } if (scoped) { - addModuleToScope (m, i); + addModuleToScope (static_cast (m), static_cast (i)); } } @@ -25051,18 +25183,18 @@ extern "C" void decl_addImportedModule (decl_node m, decl_node i, bool scoped) extern "C" void decl_setSource (decl_node n, nameKey_Name s) { - switch (n->kind) + switch (static_cast (n)->kind) { case decl_def: - n->defF.source = s; + static_cast (n)->defF.source = s; break; case decl_module: - n->moduleF.source = s; + static_cast (n)->moduleF.source = s; break; case decl_imp: - n->impF.source = s; + static_cast (n)->impF.source = s; break; @@ -25079,18 +25211,18 @@ extern "C" void decl_setSource (decl_node n, nameKey_Name s) extern "C" nameKey_Name decl_getSource (decl_node n) { - switch (n->kind) + switch (static_cast (n)->kind) { case decl_def: - return n->defF.source; + return static_cast (n)->defF.source; break; case decl_module: - return n->moduleF.source; + return static_cast (n)->moduleF.source; break; case decl_imp: - return n->impF.source; + return static_cast (n)->impF.source; break; @@ -25109,7 +25241,7 @@ extern "C" nameKey_Name decl_getSource (decl_node n) extern "C" decl_node decl_getMainModule (void) { - return mainModule; + return static_cast (mainModule); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -25121,7 +25253,7 @@ extern "C" decl_node decl_getMainModule (void) extern "C" decl_node decl_getCurrentModule (void) { - return currentModule; + return static_cast (currentModule); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -25179,10 +25311,10 @@ extern "C" void decl_enterScope (decl_node n) extern "C" void decl_leaveScope (void) { unsigned int i; - decl_node n; + decl_node__opaque n; i = Indexing_HighIndice (scopeStack); - n = static_cast (Indexing_GetIndice (scopeStack, i)); + n = static_cast (Indexing_GetIndice (scopeStack, i)); Indexing_RemoveIndiceFromIndex (scopeStack, reinterpret_cast (n)); if (debugScopes) { @@ -25198,32 +25330,32 @@ extern "C" void decl_leaveScope (void) extern "C" decl_node decl_makeProcedure (nameKey_Name n) { - decl_node d; + decl_node__opaque d; - d = decl_lookupSym (n); + d = static_cast (decl_lookupSym (n)); if (d == NULL) { d = newNode (decl_procedure); d->procedureF.name = n; initDecls (&d->procedureF.decls); - d->procedureF.scope = decl_getDeclScope (); + d->procedureF.scope = static_cast (decl_getDeclScope ()); d->procedureF.parameters = Indexing_InitIndex (1); - d->procedureF.isForC = isDefForCNode (decl_getDeclScope ()); + d->procedureF.isForC = isDefForCNode (static_cast (decl_getDeclScope ())); d->procedureF.built = false; d->procedureF.returnopt = false; - d->procedureF.optarg_ = NULL; + d->procedureF.optarg_ = static_cast (NULL); d->procedureF.noreturnused = false; d->procedureF.noreturn = false; d->procedureF.vararg = false; d->procedureF.checking = false; d->procedureF.paramcount = 0; - d->procedureF.returnType = NULL; - d->procedureF.beginStatements = NULL; + d->procedureF.returnType = static_cast (NULL); + d->procedureF.beginStatements = static_cast (NULL); initCname (&d->procedureF.cname); - d->procedureF.defComment = NULL; - d->procedureF.modComment = NULL; + d->procedureF.defComment = static_cast (NULL); + d->procedureF.modComment = static_cast (NULL); } - return addProcedureToScope (d, n); + return static_cast (addProcedureToScope (d, n)); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -25240,7 +25372,7 @@ extern "C" void decl_putCommentDefProcedure (decl_node n) mcDebug_assert (decl_isProcedure (n)); if (mcComment_isProcedureComment (mcLexBuf_lastcomment)) { - n->procedureF.defComment = mcLexBuf_lastcomment; + static_cast (n)->procedureF.defComment = mcLexBuf_lastcomment; } } @@ -25256,7 +25388,7 @@ extern "C" void decl_putCommentModProcedure (decl_node n) mcDebug_assert (decl_isProcedure (n)); if (mcComment_isProcedureComment (mcLexBuf_lastcomment)) { - n->procedureF.modComment = mcLexBuf_lastcomment; + static_cast (n)->procedureF.modComment = mcLexBuf_lastcomment; } } @@ -25267,23 +25399,24 @@ extern "C" void decl_putCommentModProcedure (decl_node n) extern "C" decl_node decl_makeProcType (void) { - decl_node d; + decl_node__opaque d; d = newNode (decl_proctype); - d->proctypeF.scope = decl_getDeclScope (); + d->proctypeF.scope = static_cast (decl_getDeclScope ()); d->proctypeF.parameters = Indexing_InitIndex (1); d->proctypeF.returnopt = false; - d->proctypeF.optarg_ = NULL; + d->proctypeF.optarg_ = static_cast (NULL); d->proctypeF.vararg = false; - d->proctypeF.returnType = NULL; - return d; + d->proctypeF.returnType = static_cast (NULL); + initNodeOpaqueState (d); + return static_cast (d); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } /* - putReturnType - sets the return type of procedure or proctype, proc, to, type. + putReturnType - sets the return type of procedure or proctype proc to type. */ extern "C" void decl_putReturnType (decl_node proc, decl_node type) @@ -25291,12 +25424,13 @@ extern "C" void decl_putReturnType (decl_node proc, decl_node type) mcDebug_assert ((decl_isProcedure (proc)) || (decl_isProcType (proc))); if (decl_isProcedure (proc)) { - proc->procedureF.returnType = type; + static_cast (proc)->procedureF.returnType = static_cast (type); } else { - proc->proctypeF.returnType = type; + static_cast (proc)->proctypeF.returnType = static_cast (type); } + initNodeOpaqueState (static_cast (proc)); } @@ -25309,11 +25443,11 @@ extern "C" void decl_putOptReturn (decl_node proc) mcDebug_assert ((decl_isProcedure (proc)) || (decl_isProcType (proc))); if (decl_isProcedure (proc)) { - proc->procedureF.returnopt = true; + static_cast (proc)->procedureF.returnopt = true; } else { - proc->proctypeF.returnopt = true; + static_cast (proc)->proctypeF.returnopt = true; } } @@ -25324,17 +25458,18 @@ extern "C" void decl_putOptReturn (decl_node proc) extern "C" decl_node decl_makeVarParameter (decl_node l, decl_node type, decl_node proc, bool isused) { - decl_node d; + decl_node__opaque d; - mcDebug_assert ((l == NULL) || (isIdentList (l))); + mcDebug_assert ((l == NULL) || (isIdentList (static_cast (l)))); d = newNode (decl_varparam); - d->varparamF.namelist = l; - d->varparamF.type = type; - d->varparamF.scope = proc; + d->varparamF.namelist = static_cast (l); + d->varparamF.type = static_cast (type); + d->varparamF.scope = static_cast (proc); d->varparamF.isUnbounded = false; - d->varparamF.isForC = isDefForCNode (proc); + d->varparamF.isForC = isDefForCNode (static_cast (proc)); d->varparamF.isUsed = isused; - return d; + initNodeOpaqueState (d); + return static_cast (d); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -25346,17 +25481,18 @@ extern "C" decl_node decl_makeVarParameter (decl_node l, decl_node type, decl_no extern "C" decl_node decl_makeNonVarParameter (decl_node l, decl_node type, decl_node proc, bool isused) { - decl_node d; + decl_node__opaque d; - mcDebug_assert ((l == NULL) || (isIdentList (l))); + mcDebug_assert ((l == NULL) || (isIdentList (static_cast (l)))); d = newNode (decl_param); - d->paramF.namelist = l; - d->paramF.type = type; - d->paramF.scope = proc; + d->paramF.namelist = static_cast (l); + d->paramF.type = static_cast (type); + d->paramF.scope = static_cast (proc); d->paramF.isUnbounded = false; - d->paramF.isForC = isDefForCNode (proc); + d->paramF.isForC = isDefForCNode (static_cast (proc)); d->paramF.isUsed = isused; - return d; + initNodeOpaqueState (d); + return static_cast (d); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -25369,7 +25505,7 @@ extern "C" decl_node decl_makeNonVarParameter (decl_node l, decl_node type, decl extern "C" void decl_paramEnter (decl_node n) { mcDebug_assert (decl_isProcedure (n)); - n->procedureF.paramcount = 0; + static_cast (n)->procedureF.paramcount = 0; } @@ -25380,10 +25516,10 @@ extern "C" void decl_paramEnter (decl_node n) extern "C" void decl_paramLeave (decl_node n) { mcDebug_assert (decl_isProcedure (n)); - n->procedureF.checking = true; - if ((decl_isImp (currentModule)) || (decl_isModule (currentModule))) + static_cast (n)->procedureF.checking = true; + if ((decl_isImp (static_cast (currentModule))) || (decl_isModule (static_cast (currentModule)))) { - n->procedureF.built = true; + static_cast (n)->procedureF.built = true; } } @@ -25394,12 +25530,12 @@ extern "C" void decl_paramLeave (decl_node n) extern "C" decl_node decl_makeIdentList (void) { - decl_node n; + decl_node__opaque n; n = newNode (decl_identlist); n->identlistF.names = wlists_initList (); n->identlistF.cnamed = false; - return n; + return static_cast (n); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -25412,14 +25548,14 @@ extern "C" decl_node decl_makeIdentList (void) extern "C" bool decl_putIdent (decl_node n, nameKey_Name i) { - mcDebug_assert (isIdentList (n)); - if (wlists_isItemInList (n->identlistF.names, i)) + mcDebug_assert (isIdentList (static_cast (n))); + if (wlists_isItemInList (static_cast (n)->identlistF.names, i)) { return false; } else { - wlists_putItemIntoList (n->identlistF.names, i); + wlists_putItemIntoList (static_cast (n)->identlistF.names, i); return true; } /* static analysis guarentees a RETURN statement will be used before here. */ @@ -25434,19 +25570,19 @@ extern "C" bool decl_putIdent (decl_node n, nameKey_Name i) extern "C" void decl_addVarParameters (decl_node n, decl_node i, decl_node type, bool isused) { - decl_node p; + decl_node__opaque p; - mcDebug_assert (isIdentList (i)); + mcDebug_assert (isIdentList (static_cast (i))); mcDebug_assert (decl_isProcedure (n)); - checkMakeVariables (n, i, type, true, isused); - if (n->procedureF.checking) + checkMakeVariables (static_cast (n), static_cast (i), static_cast (type), true, isused); + if (static_cast (n)->procedureF.checking) { - checkParameters (n, i, type, true, isused); /* will destroy, i. */ + checkParameters (static_cast (n), static_cast (i), static_cast (type), true, isused); /* will destroy, i. */ } else { - p = decl_makeVarParameter (i, type, n, isused); - Indexing_IncludeIndiceIntoIndex (n->procedureF.parameters, reinterpret_cast (p)); + p = static_cast (decl_makeVarParameter (i, type, n, isused)); + Indexing_IncludeIndiceIntoIndex (static_cast (n)->procedureF.parameters, reinterpret_cast (p)); } } @@ -25458,19 +25594,19 @@ extern "C" void decl_addVarParameters (decl_node n, decl_node i, decl_node type, extern "C" void decl_addNonVarParameters (decl_node n, decl_node i, decl_node type, bool isused) { - decl_node p; + decl_node__opaque p; - mcDebug_assert (isIdentList (i)); + mcDebug_assert (isIdentList (static_cast (i))); mcDebug_assert (decl_isProcedure (n)); - checkMakeVariables (n, i, type, false, isused); - if (n->procedureF.checking) + checkMakeVariables (static_cast (n), static_cast (i), static_cast (type), false, isused); + if (static_cast (n)->procedureF.checking) { - checkParameters (n, i, type, false, isused); /* will destroy, i. */ + checkParameters (static_cast (n), static_cast (i), static_cast (type), false, isused); /* will destroy, i. */ } else { - p = decl_makeNonVarParameter (i, type, n, isused); - Indexing_IncludeIndiceIntoIndex (n->procedureF.parameters, reinterpret_cast (p)); + p = static_cast (decl_makeNonVarParameter (i, type, n, isused)); + Indexing_IncludeIndiceIntoIndex (static_cast (n)->procedureF.parameters, reinterpret_cast (p)); } } @@ -25481,11 +25617,11 @@ extern "C" void decl_addNonVarParameters (decl_node n, decl_node i, decl_node ty extern "C" decl_node decl_makeVarargs (void) { - decl_node d; + decl_node__opaque d; d = newNode (decl_varargs); - d->varargsF.scope = NULL; - return d; + d->varargsF.scope = static_cast (NULL); + return static_cast (d); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -25497,7 +25633,7 @@ extern "C" decl_node decl_makeVarargs (void) extern "C" bool decl_isVarargs (decl_node n) { - return n->kind == decl_varargs; + return static_cast (n)->kind == decl_varargs; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -25510,29 +25646,29 @@ extern "C" bool decl_isVarargs (decl_node n) extern "C" void decl_addParameter (decl_node proc, decl_node param) { mcDebug_assert ((((decl_isVarargs (param)) || (decl_isParam (param))) || (decl_isVarParam (param))) || (decl_isOptarg (param))); - switch (proc->kind) + switch (static_cast (proc)->kind) { case decl_procedure: - Indexing_IncludeIndiceIntoIndex (proc->procedureF.parameters, reinterpret_cast (param)); + Indexing_IncludeIndiceIntoIndex (static_cast (proc)->procedureF.parameters, reinterpret_cast (param)); if (decl_isVarargs (param)) { - proc->procedureF.vararg = true; + static_cast (proc)->procedureF.vararg = true; } if (decl_isOptarg (param)) { - proc->procedureF.optarg_ = param; + static_cast (proc)->procedureF.optarg_ = static_cast (param); } break; case decl_proctype: - Indexing_IncludeIndiceIntoIndex (proc->proctypeF.parameters, reinterpret_cast (param)); + Indexing_IncludeIndiceIntoIndex (static_cast (proc)->proctypeF.parameters, reinterpret_cast (param)); if (decl_isVarargs (param)) { - proc->proctypeF.vararg = true; + static_cast (proc)->proctypeF.vararg = true; } if (decl_isOptarg (param)) { - proc->proctypeF.optarg_ = param; + static_cast (proc)->proctypeF.optarg_ = static_cast (param); } break; @@ -25553,77 +25689,77 @@ extern "C" decl_node decl_makeBinaryTok (mcReserved_toktype op, decl_node l, dec { if (op == mcReserved_equaltok) { - return makeBinary (decl_equal, l, r, booleanN); + return static_cast (makeBinary (decl_equal, static_cast (l), static_cast (r), booleanN)); } else if ((op == mcReserved_hashtok) || (op == mcReserved_lessgreatertok)) { /* avoid dangling else. */ - return makeBinary (decl_notequal, l, r, booleanN); + return static_cast (makeBinary (decl_notequal, static_cast (l), static_cast (r), booleanN)); } else if (op == mcReserved_lesstok) { /* avoid dangling else. */ - return makeBinary (decl_less, l, r, booleanN); + return static_cast (makeBinary (decl_less, static_cast (l), static_cast (r), booleanN)); } else if (op == mcReserved_greatertok) { /* avoid dangling else. */ - return makeBinary (decl_greater, l, r, booleanN); + return static_cast (makeBinary (decl_greater, static_cast (l), static_cast (r), booleanN)); } else if (op == mcReserved_greaterequaltok) { /* avoid dangling else. */ - return makeBinary (decl_greequal, l, r, booleanN); + return static_cast (makeBinary (decl_greequal, static_cast (l), static_cast (r), booleanN)); } else if (op == mcReserved_lessequaltok) { /* avoid dangling else. */ - return makeBinary (decl_lessequal, l, r, booleanN); + return static_cast (makeBinary (decl_lessequal, static_cast (l), static_cast (r), booleanN)); } else if (op == mcReserved_andtok) { /* avoid dangling else. */ - return makeBinary (decl_and, l, r, booleanN); + return static_cast (makeBinary (decl_and, static_cast (l), static_cast (r), booleanN)); } else if (op == mcReserved_ortok) { /* avoid dangling else. */ - return makeBinary (decl_or, l, r, booleanN); + return static_cast (makeBinary (decl_or, static_cast (l), static_cast (r), booleanN)); } else if (op == mcReserved_plustok) { /* avoid dangling else. */ - return makeBinary (decl_plus, l, r, NULL); + return static_cast (makeBinary (decl_plus, static_cast (l), static_cast (r), static_cast (NULL))); } else if (op == mcReserved_minustok) { /* avoid dangling else. */ - return makeBinary (decl_sub, l, r, NULL); + return static_cast (makeBinary (decl_sub, static_cast (l), static_cast (r), static_cast (NULL))); } else if (op == mcReserved_divtok) { /* avoid dangling else. */ - return makeBinary (decl_div, l, r, NULL); + return static_cast (makeBinary (decl_div, static_cast (l), static_cast (r), static_cast (NULL))); } else if (op == mcReserved_timestok) { /* avoid dangling else. */ - return makeBinary (decl_mult, l, r, NULL); + return static_cast (makeBinary (decl_mult, static_cast (l), static_cast (r), static_cast (NULL))); } else if (op == mcReserved_modtok) { /* avoid dangling else. */ - return makeBinary (decl_mod, l, r, NULL); + return static_cast (makeBinary (decl_mod, static_cast (l), static_cast (r), static_cast (NULL))); } else if (op == mcReserved_intok) { /* avoid dangling else. */ - return makeBinary (decl_in, l, r, NULL); + return static_cast (makeBinary (decl_in, static_cast (l), static_cast (r), static_cast (NULL))); } else if (op == mcReserved_dividetok) { /* avoid dangling else. */ - return makeBinary (decl_divide, l, r, NULL); + return static_cast (makeBinary (decl_divide, static_cast (l), static_cast (r), static_cast (NULL))); } else { @@ -25645,17 +25781,17 @@ extern "C" decl_node decl_makeUnaryTok (mcReserved_toktype op, decl_node e) { if (op == mcReserved_nottok) { - return makeUnary (decl_not, e, booleanN); + return static_cast (makeUnary (decl_not, static_cast (e), booleanN)); } else if (op == mcReserved_plustok) { /* avoid dangling else. */ - return makeUnary (decl_plus, e, NULL); + return static_cast (makeUnary (decl_plus, static_cast (e), static_cast (NULL))); } else if (op == mcReserved_minustok) { /* avoid dangling else. */ - return makeUnary (decl_neg, e, NULL); + return static_cast (makeUnary (decl_neg, static_cast (e), static_cast (NULL))); } else { @@ -25675,8 +25811,8 @@ extern "C" decl_node decl_makeUnaryTok (mcReserved_toktype op, decl_node e) extern "C" decl_node decl_makeComponentRef (decl_node rec, decl_node field) { - decl_node n; - decl_node a; + decl_node__opaque n; + decl_node__opaque a; /* n := getLastOp (rec) ; @@ -25693,18 +25829,19 @@ extern "C" decl_node decl_makeComponentRef (decl_node rec, decl_node field) RETURN doMakeComponentRef (rec, field) END */ - if (isDeref (rec)) - { - a = rec->unaryF.arg; - rec->kind = decl_pointerref; - rec->pointerrefF.ptr = a; - rec->pointerrefF.field = field; - rec->pointerrefF.resultType = decl_getType (field); + if (isDeref (static_cast (rec))) + { + a = static_cast (rec)->unaryF.arg; + static_cast (rec)->kind = decl_pointerref; + static_cast (rec)->pointerrefF.ptr = a; + static_cast (rec)->pointerrefF.field = static_cast (field); + static_cast (rec)->pointerrefF.resultType = static_cast (decl_getType (field)); + initNodeOpaqueState (static_cast (rec)); return rec; } else { - return doMakeComponentRef (rec, field); + return static_cast (doMakeComponentRef (static_cast (rec), static_cast (field))); } /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -25718,13 +25855,14 @@ extern "C" decl_node decl_makeComponentRef (decl_node rec, decl_node field) extern "C" decl_node decl_makePointerRef (decl_node ptr, decl_node field) { - decl_node n; + decl_node__opaque n; n = newNode (decl_pointerref); - n->pointerrefF.ptr = ptr; - n->pointerrefF.field = field; - n->pointerrefF.resultType = decl_getType (field); - return n; + n->pointerrefF.ptr = static_cast (ptr); + n->pointerrefF.field = static_cast (field); + n->pointerrefF.resultType = static_cast (decl_getType (field)); + initNodeOpaqueState (n); + return static_cast (n); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -25737,7 +25875,7 @@ extern "C" decl_node decl_makePointerRef (decl_node ptr, decl_node field) extern "C" bool decl_isPointerRef (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_pointerref; + return static_cast (n)->kind == decl_pointerref; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -25749,11 +25887,11 @@ extern "C" bool decl_isPointerRef (decl_node n) extern "C" decl_node decl_makeDeRef (decl_node n) { - decl_node t; + decl_node__opaque t; - t = decl_skipType (decl_getType (n)); - mcDebug_assert (decl_isPointer (t)); - return makeUnary (decl_deref, n, decl_getType (t)); + t = static_cast (decl_skipType (decl_getType (n))); + mcDebug_assert (decl_isPointer (static_cast (t))); + return static_cast (makeUnary (decl_deref, static_cast (n), static_cast (decl_getType (static_cast (t))))); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -25767,22 +25905,22 @@ extern "C" decl_node decl_makeDeRef (decl_node n) extern "C" decl_node decl_makeArrayRef (decl_node array, decl_node index) { - decl_node n; - decl_node t; + decl_node__opaque n; + decl_node__opaque t; unsigned int i; unsigned int j; n = newNode (decl_arrayref); - n->arrayrefF.array = array; - n->arrayrefF.index = index; - t = array; - j = expListLen (index); + n->arrayrefF.array = static_cast (array); + n->arrayrefF.index = static_cast (index); + t = static_cast (array); + j = expListLen (static_cast (index)); i = 1; - t = decl_skipType (decl_getType (t)); + t = static_cast (decl_skipType (decl_getType (static_cast (t)))); do { - if (decl_isArray (t)) + if (decl_isArray (static_cast (t))) { - t = decl_skipType (decl_getType (t)); + t = static_cast (decl_skipType (decl_getType (static_cast (t)))); } else { @@ -25791,7 +25929,7 @@ extern "C" decl_node decl_makeArrayRef (decl_node array, decl_node index) i += 1; } while (! (i > j)); n->arrayrefF.resultType = t; - return n; + return static_cast (n); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -25803,7 +25941,7 @@ extern "C" decl_node decl_makeArrayRef (decl_node array, decl_node index) extern "C" decl_node decl_getLastOp (decl_node n) { - return doGetLastOp (n, n); + return static_cast (doGetLastOp (static_cast (n), static_cast (n))); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -25815,7 +25953,7 @@ extern "C" decl_node decl_getLastOp (decl_node n) extern "C" decl_node decl_getCardinal (void) { - return cardinalN; + return static_cast (cardinalN); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -25827,7 +25965,7 @@ extern "C" decl_node decl_getCardinal (void) extern "C" decl_node decl_makeLiteralInt (nameKey_Name n) { - decl_node m; + decl_node__opaque m; DynamicStrings_String s; m = newNode (decl_literal); @@ -25842,7 +25980,7 @@ extern "C" decl_node decl_makeLiteralInt (nameKey_Name n) m->literalF.type = ztypeN; } s = DynamicStrings_KillString (s); - return m; + return static_cast (m); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -25854,12 +25992,12 @@ extern "C" decl_node decl_makeLiteralInt (nameKey_Name n) extern "C" decl_node decl_makeLiteralReal (nameKey_Name n) { - decl_node m; + decl_node__opaque m; m = newNode (decl_literal); m->literalF.name = n; m->literalF.type = rtypeN; - return m; + return static_cast (m); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -25871,7 +26009,7 @@ extern "C" decl_node decl_makeLiteralReal (nameKey_Name n) extern "C" decl_node decl_makeString (nameKey_Name n) { - decl_node m; + decl_node__opaque m; m = newNode (decl_string); m->stringF.name = n; @@ -25885,9 +26023,9 @@ extern "C" decl_node decl_makeString (nameKey_Name n) } else { - m->stringF.cchar = NULL; + m->stringF.cchar = static_cast (NULL); } - return m; + return static_cast (m); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -25899,12 +26037,12 @@ extern "C" decl_node decl_makeString (nameKey_Name n) extern "C" decl_node decl_makeSetValue (void) { - decl_node n; + decl_node__opaque n; n = newNode (decl_setvalue); n->setvalueF.type = bitsetN; n->setvalueF.values = Indexing_InitIndex (1); - return n; + return static_cast (n); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -25917,7 +26055,7 @@ extern "C" decl_node decl_makeSetValue (void) extern "C" bool decl_isSetValue (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_setvalue; + return static_cast (n)->kind == decl_setvalue; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -25931,7 +26069,7 @@ extern "C" bool decl_isSetValue (decl_node n) extern "C" decl_node decl_putSetValue (decl_node n, decl_node t) { mcDebug_assert (decl_isSetValue (n)); - n->setvalueF.type = t; + static_cast (n)->setvalueF.type = static_cast (t); return n; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -25948,7 +26086,7 @@ extern "C" decl_node decl_putSetValue (decl_node n, decl_node t) extern "C" decl_node decl_includeSetValue (decl_node n, decl_node l, decl_node h) { mcDebug_assert (decl_isSetValue (n)); - Indexing_IncludeIndiceIntoIndex (n->setvalueF.values, reinterpret_cast (l)); + Indexing_IncludeIndiceIntoIndex (static_cast (n)->setvalueF.values, reinterpret_cast (l)); return n; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -25963,27 +26101,27 @@ extern "C" decl_node decl_getBuiltinConst (nameKey_Name n) { if (n == (nameKey_makeKey ((const char *) "BITS_PER_UNIT", 13))) { - return bitsperunitN; + return static_cast (bitsperunitN); } else if (n == (nameKey_makeKey ((const char *) "BITS_PER_WORD", 13))) { /* avoid dangling else. */ - return bitsperwordN; + return static_cast (bitsperwordN); } else if (n == (nameKey_makeKey ((const char *) "BITS_PER_CHAR", 13))) { /* avoid dangling else. */ - return bitspercharN; + return static_cast (bitspercharN); } else if (n == (nameKey_makeKey ((const char *) "UNITS_PER_WORD", 14))) { /* avoid dangling else. */ - return unitsperwordN; + return static_cast (unitsperwordN); } else { /* avoid dangling else. */ - return NULL; + return static_cast (NULL); } /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -25996,11 +26134,11 @@ extern "C" decl_node decl_getBuiltinConst (nameKey_Name n) extern "C" decl_node decl_makeExpList (void) { - decl_node n; + decl_node__opaque n; n = newNode (decl_explist); n->explistF.exp = Indexing_InitIndex (1); - return n; + return static_cast (n); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -26013,7 +26151,7 @@ extern "C" decl_node decl_makeExpList (void) extern "C" bool decl_isExpList (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_explist; + return static_cast (n)->kind == decl_explist; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -26027,7 +26165,7 @@ extern "C" void decl_putExpList (decl_node n, decl_node e) { mcDebug_assert (n != NULL); mcDebug_assert (decl_isExpList (n)); - Indexing_PutIndice (n->explistF.exp, (Indexing_HighIndice (n->explistF.exp))+1, reinterpret_cast (e)); + Indexing_PutIndice (static_cast (n)->explistF.exp, (Indexing_HighIndice (static_cast (n)->explistF.exp))+1, reinterpret_cast (e)); } @@ -26043,7 +26181,7 @@ extern "C" decl_node decl_makeConstExp (void) } else { - return doMakeConstExp (); + return static_cast (doMakeConstExp ()); } /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -26056,24 +26194,24 @@ extern "C" decl_node decl_makeConstExp (void) extern "C" decl_node decl_getNextConstExp (void) { - decl_node n; + decl_node__opaque n; - mcDebug_assert (((decl_isDef (currentModule)) || (decl_isImp (currentModule))) || (decl_isModule (currentModule))); - if (decl_isDef (currentModule)) + mcDebug_assert (((decl_isDef (static_cast (currentModule))) || (decl_isImp (static_cast (currentModule)))) || (decl_isModule (static_cast (currentModule)))); + if (decl_isDef (static_cast (currentModule))) { - return getNextFixup (¤tModule->defF.constFixup); + return static_cast (getNextFixup (¤tModule->defF.constFixup)); } - else if (decl_isImp (currentModule)) + else if (decl_isImp (static_cast (currentModule))) { /* avoid dangling else. */ - return getNextFixup (¤tModule->impF.constFixup); + return static_cast (getNextFixup (¤tModule->impF.constFixup)); } - else if (decl_isModule (currentModule)) + else if (decl_isModule (static_cast (currentModule))) { /* avoid dangling else. */ - return getNextFixup (¤tModule->moduleF.constFixup); + return static_cast (getNextFixup (¤tModule->moduleF.constFixup)); } - return n; + return static_cast (n); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -26085,18 +26223,18 @@ extern "C" decl_node decl_getNextConstExp (void) extern "C" void decl_setConstExpComplete (decl_node n) { - switch (n->kind) + switch (static_cast (n)->kind) { case decl_def: - n->defF.constsComplete = true; + static_cast (n)->defF.constsComplete = true; break; case decl_imp: - n->impF.constsComplete = true; + static_cast (n)->impF.constsComplete = true; break; case decl_module: - n->moduleF.constsComplete = true; + static_cast (n)->moduleF.constsComplete = true; break; @@ -26113,8 +26251,8 @@ extern "C" void decl_setConstExpComplete (decl_node n) extern "C" decl_node decl_fixupConstExp (decl_node c, decl_node e) { - mcDebug_assert (isConstExp (c)); - c->unaryF.arg = e; + mcDebug_assert (isConstExp (static_cast (c))); + static_cast (c)->unaryF.arg = static_cast (e); return c; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -26131,17 +26269,17 @@ extern "C" void decl_resetConstExpPos (decl_node n) mcDebug_assert (((decl_isDef (n)) || (decl_isImp (n))) || (decl_isModule (n))); if (decl_isDef (n)) { - n->defF.constFixup.count = 0; + static_cast (n)->defF.constFixup.count = 0; } else if (decl_isImp (n)) { /* avoid dangling else. */ - n->impF.constFixup.count = 0; + static_cast (n)->impF.constFixup.count = 0; } else if (decl_isModule (n)) { /* avoid dangling else. */ - n->moduleF.constFixup.count = 0; + static_cast (n)->moduleF.constFixup.count = 0; } } @@ -26152,24 +26290,25 @@ extern "C" void decl_resetConstExpPos (decl_node n) extern "C" decl_node decl_makeFuncCall (decl_node c, decl_node n) { - decl_node f; + decl_node__opaque f; mcDebug_assert ((n == NULL) || (decl_isExpList (n))); if (((c == haltN) && ((decl_getMainModule ()) != (decl_lookupDef (nameKey_makeKey ((const char *) "M2RTS", 5))))) && ((decl_getMainModule ()) != (decl_lookupImp (nameKey_makeKey ((const char *) "M2RTS", 5))))) { decl_addImportedModule (decl_getMainModule (), decl_lookupDef (nameKey_makeKey ((const char *) "M2RTS", 5)), false); } - f = checkIntrinsic (c, n); - checkCHeaders (c); + f = checkIntrinsic (static_cast (c), static_cast (n)); + checkCHeaders (static_cast (c)); if (f == NULL) { f = newNode (decl_funccall); - f->funccallF.function = c; - f->funccallF.args = n; - f->funccallF.type = NULL; + f->funccallF.function = static_cast (c); + f->funccallF.args = static_cast (n); + f->funccallF.type = static_cast (decl_getType (c)); initPair (&f->funccallF.funccallComment); + initNodeOpaqueState (f); } - return f; + return static_cast (f); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -26181,11 +26320,11 @@ extern "C" decl_node decl_makeFuncCall (decl_node c, decl_node n) extern "C" decl_node decl_makeStatementSequence (void) { - decl_node n; + decl_node__opaque n; n = newNode (decl_stmtseq); n->stmtF.statements = Indexing_InitIndex (1); - return n; + return static_cast (n); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -26197,7 +26336,7 @@ extern "C" decl_node decl_makeStatementSequence (void) extern "C" bool decl_isStatementSequence (decl_node n) { - return n->kind == decl_stmtseq; + return static_cast (n)->kind == decl_stmtseq; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -26212,11 +26351,11 @@ extern "C" void decl_addStatement (decl_node s, decl_node n) if (n != NULL) { mcDebug_assert (decl_isStatementSequence (s)); - Indexing_PutIndice (s->stmtF.statements, (Indexing_HighIndice (s->stmtF.statements))+1, reinterpret_cast (n)); - if ((isIntrinsic (n)) && n->intrinsicF.postUnreachable) + Indexing_PutIndice (static_cast (s)->stmtF.statements, (Indexing_HighIndice (static_cast (s)->stmtF.statements))+1, reinterpret_cast (n)); + if ((isIntrinsic (static_cast (n))) && static_cast (n)->intrinsicF.postUnreachable) { - n->intrinsicF.postUnreachable = false; - decl_addStatement (s, makeIntrinsicProc (decl_unreachable, 0, NULL)); + static_cast (n)->intrinsicF.postUnreachable = false; + decl_addStatement (s, static_cast (makeIntrinsicProc (decl_unreachable, 0, static_cast (NULL)))); } } } @@ -26235,7 +26374,7 @@ extern "C" void decl_addCommentBody (decl_node n) b = mcLexBuf_getBodyComment (); if (b != NULL) { - addGenericBody (n, decl_makeCommentS (b)); + addGenericBody (static_cast (n), static_cast (decl_makeCommentS (b))); } } } @@ -26254,7 +26393,7 @@ extern "C" void decl_addCommentAfter (decl_node n) a = mcLexBuf_getAfterComment (); if (a != NULL) { - addGenericAfter (n, decl_makeCommentS (a)); + addGenericAfter (static_cast (n), static_cast (decl_makeCommentS (a))); } } } @@ -26267,8 +26406,8 @@ extern "C" void decl_addCommentAfter (decl_node n) extern "C" void decl_addIfComments (decl_node n, decl_node body, decl_node after) { mcDebug_assert (decl_isIf (n)); - n->ifF.ifComment.after = after; - n->ifF.ifComment.body = body; + static_cast (n)->ifF.ifComment.after = static_cast (after); + static_cast (n)->ifF.ifComment.body = static_cast (body); } @@ -26281,13 +26420,13 @@ extern "C" void decl_addElseComments (decl_node n, decl_node body, decl_node aft mcDebug_assert ((decl_isIf (n)) || (decl_isElsif (n))); if (decl_isIf (n)) { - n->ifF.elseComment.after = after; - n->ifF.elseComment.body = body; + static_cast (n)->ifF.elseComment.after = static_cast (after); + static_cast (n)->ifF.elseComment.body = static_cast (body); } else { - n->elsifF.elseComment.after = after; - n->elsifF.elseComment.body = body; + static_cast (n)->elsifF.elseComment.after = static_cast (after); + static_cast (n)->elsifF.elseComment.body = static_cast (body); } } @@ -26299,8 +26438,8 @@ extern "C" void decl_addElseComments (decl_node n, decl_node body, decl_node aft extern "C" void decl_addIfEndComments (decl_node n, decl_node body, decl_node after) { mcDebug_assert (decl_isIf (n)); - n->ifF.endComment.after = after; - n->ifF.endComment.body = body; + static_cast (n)->ifF.endComment.after = static_cast (after); + static_cast (n)->ifF.endComment.body = static_cast (body); } @@ -26310,21 +26449,21 @@ extern "C" void decl_addIfEndComments (decl_node n, decl_node body, decl_node af extern "C" decl_node decl_makeReturn (void) { - decl_node type; - decl_node n; + decl_node__opaque type; + decl_node__opaque n; n = newNode (decl_return); - n->returnF.exp = NULL; + n->returnF.exp = static_cast (NULL); if (decl_isProcedure (decl_getDeclScope ())) { - n->returnF.scope = decl_getDeclScope (); + n->returnF.scope = static_cast (decl_getDeclScope ()); } else { - n->returnF.scope = NULL; + n->returnF.scope = static_cast (NULL); } initPair (&n->returnF.returnComment); - return n; + return static_cast (n); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -26337,7 +26476,7 @@ extern "C" decl_node decl_makeReturn (void) extern "C" bool decl_isReturn (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_return; + return static_cast (n)->kind == decl_return; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -26350,7 +26489,7 @@ extern "C" bool decl_isReturn (decl_node n) extern "C" void decl_putReturn (decl_node n, decl_node e) { mcDebug_assert (decl_isReturn (n)); - n->returnF.exp = e; + static_cast (n)->returnF.exp = static_cast (e); } @@ -26360,14 +26499,14 @@ extern "C" void decl_putReturn (decl_node n, decl_node e) extern "C" decl_node decl_makeWhile (void) { - decl_node n; + decl_node__opaque n; n = newNode (decl_while); - n->whileF.expr = NULL; - n->whileF.statements = NULL; + n->whileF.expr = static_cast (NULL); + n->whileF.statements = static_cast (NULL); initPair (&n->whileF.doComment); initPair (&n->whileF.endComment); - return n; + return static_cast (n); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -26381,8 +26520,8 @@ extern "C" decl_node decl_makeWhile (void) extern "C" void decl_putWhile (decl_node n, decl_node e, decl_node s) { mcDebug_assert (decl_isWhile (n)); - n->whileF.expr = e; - n->whileF.statements = s; + static_cast (n)->whileF.expr = static_cast (e); + static_cast (n)->whileF.statements = static_cast (s); } @@ -26392,7 +26531,7 @@ extern "C" void decl_putWhile (decl_node n, decl_node e, decl_node s) extern "C" bool decl_isWhile (decl_node n) { - return n->kind == decl_while; + return static_cast (n)->kind == decl_while; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -26405,8 +26544,8 @@ extern "C" bool decl_isWhile (decl_node n) extern "C" void decl_addWhileDoComment (decl_node w, decl_node body, decl_node after) { mcDebug_assert (decl_isWhile (w)); - w->whileF.doComment.after = after; - w->whileF.doComment.body = body; + static_cast (w)->whileF.doComment.after = static_cast (after); + static_cast (w)->whileF.doComment.body = static_cast (body); } @@ -26417,8 +26556,8 @@ extern "C" void decl_addWhileDoComment (decl_node w, decl_node body, decl_node a extern "C" void decl_addWhileEndComment (decl_node w, decl_node body, decl_node after) { mcDebug_assert (decl_isWhile (w)); - w->whileF.endComment.after = after; - w->whileF.endComment.body = body; + static_cast (w)->whileF.endComment.after = static_cast (after); + static_cast (w)->whileF.endComment.body = static_cast (body); } @@ -26429,13 +26568,13 @@ extern "C" void decl_addWhileEndComment (decl_node w, decl_node body, decl_node extern "C" decl_node decl_makeAssignment (decl_node d, decl_node e) { - decl_node n; + decl_node__opaque n; n = newNode (decl_assignment); - n->assignmentF.des = d; - n->assignmentF.expr = e; + n->assignmentF.des = static_cast (d); + n->assignmentF.expr = static_cast (e); initPair (&n->assignmentF.assignComment); - return n; + return static_cast (n); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -26450,18 +26589,18 @@ extern "C" decl_node decl_makeAssignment (decl_node d, decl_node e) extern "C" void decl_putBegin (decl_node b, decl_node s) { mcDebug_assert (((decl_isImp (b)) || (decl_isProcedure (b))) || (decl_isModule (b))); - switch (b->kind) + switch (static_cast (b)->kind) { case decl_imp: - b->impF.beginStatements = s; + static_cast (b)->impF.beginStatements = static_cast (s); break; case decl_module: - b->moduleF.beginStatements = s; + static_cast (b)->moduleF.beginStatements = static_cast (s); break; case decl_procedure: - b->procedureF.beginStatements = s; + static_cast (b)->procedureF.beginStatements = static_cast (s); break; @@ -26481,14 +26620,14 @@ extern "C" void decl_putBegin (decl_node b, decl_node s) extern "C" void decl_putFinally (decl_node b, decl_node s) { mcDebug_assert (((decl_isImp (b)) || (decl_isProcedure (b))) || (decl_isModule (b))); - switch (b->kind) + switch (static_cast (b)->kind) { case decl_imp: - b->impF.finallyStatements = s; + static_cast (b)->impF.finallyStatements = static_cast (s); break; case decl_module: - b->moduleF.finallyStatements = s; + static_cast (b)->moduleF.finallyStatements = static_cast (s); break; @@ -26505,13 +26644,13 @@ extern "C" void decl_putFinally (decl_node b, decl_node s) extern "C" decl_node decl_makeExit (decl_node l, unsigned int n) { - decl_node e; + decl_node__opaque e; mcDebug_assert (decl_isLoop (l)); e = newNode (decl_exit); - e->exitF.loop = l; - l->loopF.labelno = n; - return e; + e->exitF.loop = static_cast (l); + static_cast (l)->loopF.labelno = n; + return static_cast (e); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -26524,7 +26663,7 @@ extern "C" decl_node decl_makeExit (decl_node l, unsigned int n) extern "C" bool decl_isExit (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_exit; + return static_cast (n)->kind == decl_exit; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -26536,12 +26675,12 @@ extern "C" bool decl_isExit (decl_node n) extern "C" decl_node decl_makeLoop (void) { - decl_node l; + decl_node__opaque l; l = newNode (decl_loop); - l->loopF.statements = NULL; + l->loopF.statements = static_cast (NULL); l->loopF.labelno = 0; - return l; + return static_cast (l); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -26554,7 +26693,7 @@ extern "C" decl_node decl_makeLoop (void) extern "C" bool decl_isLoop (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_loop; + return static_cast (n)->kind == decl_loop; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -26567,7 +26706,7 @@ extern "C" bool decl_isLoop (decl_node n) extern "C" void decl_putLoop (decl_node l, decl_node s) { mcDebug_assert (decl_isLoop (l)); - l->loopF.statements = s; + static_cast (l)->loopF.statements = static_cast (s); } @@ -26600,17 +26739,17 @@ extern "C" decl_node decl_makeComment (const char *a_, unsigned int _a_high) extern "C" decl_node decl_makeCommentS (mcComment_commentDesc c) { - decl_node n; + decl_node__opaque n; if (c == NULL) { - return NULL; + return static_cast (NULL); } else { n = newNode (decl_comment); n->commentF.content = c; - return n; + return static_cast (n); } /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -26625,17 +26764,17 @@ extern "C" decl_node decl_makeCommentS (mcComment_commentDesc c) extern "C" decl_node decl_makeIf (decl_node e, decl_node s) { - decl_node n; + decl_node__opaque n; n = newNode (decl_if); - n->ifF.expr = e; - n->ifF.then = s; - n->ifF.else_ = NULL; - n->ifF.elsif = NULL; + n->ifF.expr = static_cast (e); + n->ifF.then = static_cast (s); + n->ifF.else_ = static_cast (NULL); + n->ifF.elsif = static_cast (NULL); initPair (&n->ifF.ifComment); initPair (&n->ifF.elseComment); initPair (&n->ifF.endComment); - return n; + return static_cast (n); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -26647,7 +26786,7 @@ extern "C" decl_node decl_makeIf (decl_node e, decl_node s) extern "C" bool decl_isIf (decl_node n) { - return n->kind == decl_if; + return static_cast (n)->kind == decl_if; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -26661,26 +26800,26 @@ extern "C" bool decl_isIf (decl_node n) extern "C" decl_node decl_makeElsif (decl_node i, decl_node e, decl_node s) { - decl_node n; + decl_node__opaque n; n = newNode (decl_elsif); - n->elsifF.expr = e; - n->elsifF.then = s; - n->elsifF.elsif = NULL; - n->elsifF.else_ = NULL; + n->elsifF.expr = static_cast (e); + n->elsifF.then = static_cast (s); + n->elsifF.elsif = static_cast (NULL); + n->elsifF.else_ = static_cast (NULL); initPair (&n->elsifF.elseComment); mcDebug_assert ((decl_isIf (i)) || (decl_isElsif (i))); if (decl_isIf (i)) { - i->ifF.elsif = n; - mcDebug_assert (i->ifF.else_ == NULL); + static_cast (i)->ifF.elsif = n; + mcDebug_assert (static_cast (i)->ifF.else_ == NULL); } else { - i->elsifF.elsif = n; - mcDebug_assert (i->elsifF.else_ == NULL); + static_cast (i)->elsifF.elsif = n; + mcDebug_assert (static_cast (i)->elsifF.else_ == NULL); } - return n; + return static_cast (n); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -26692,7 +26831,7 @@ extern "C" decl_node decl_makeElsif (decl_node i, decl_node e, decl_node s) extern "C" bool decl_isElsif (decl_node n) { - return n->kind == decl_elsif; + return static_cast (n)->kind == decl_elsif; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -26708,15 +26847,15 @@ extern "C" void decl_putElse (decl_node i, decl_node s) mcDebug_assert ((decl_isIf (i)) || (decl_isElsif (i))); if (decl_isIf (i)) { - mcDebug_assert (i->ifF.elsif == NULL); - mcDebug_assert (i->ifF.else_ == NULL); - i->ifF.else_ = s; + mcDebug_assert (static_cast (i)->ifF.elsif == NULL); + mcDebug_assert (static_cast (i)->ifF.else_ == NULL); + static_cast (i)->ifF.else_ = static_cast (s); } else { - mcDebug_assert (i->elsifF.elsif == NULL); - mcDebug_assert (i->elsifF.else_ == NULL); - i->elsifF.else_ = s; + mcDebug_assert (static_cast (i)->elsifF.elsif == NULL); + mcDebug_assert (static_cast (i)->elsifF.else_ == NULL); + static_cast (i)->elsifF.else_ = static_cast (s); } } @@ -26727,15 +26866,15 @@ extern "C" void decl_putElse (decl_node i, decl_node s) extern "C" decl_node decl_makeFor (void) { - decl_node n; + decl_node__opaque n; n = newNode (decl_for); - n->forF.des = NULL; - n->forF.start = NULL; - n->forF.end = NULL; - n->forF.increment = NULL; - n->forF.statements = NULL; - return n; + n->forF.des = static_cast (NULL); + n->forF.start = static_cast (NULL); + n->forF.end = static_cast (NULL); + n->forF.increment = static_cast (NULL); + n->forF.statements = static_cast (NULL); + return static_cast (n); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -26748,7 +26887,7 @@ extern "C" decl_node decl_makeFor (void) extern "C" bool decl_isFor (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_for; + return static_cast (n)->kind == decl_for; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -26766,11 +26905,11 @@ extern "C" bool decl_isFor (decl_node n) extern "C" void decl_putFor (decl_node f, decl_node i, decl_node s, decl_node e, decl_node b, decl_node sq) { mcDebug_assert (decl_isFor (f)); - f->forF.des = i; - f->forF.start = s; - f->forF.end = e; - f->forF.increment = b; - f->forF.statements = sq; + static_cast (f)->forF.des = static_cast (i); + static_cast (f)->forF.start = static_cast (s); + static_cast (f)->forF.end = static_cast (e); + static_cast (f)->forF.increment = static_cast (b); + static_cast (f)->forF.statements = static_cast (sq); } @@ -26780,14 +26919,14 @@ extern "C" void decl_putFor (decl_node f, decl_node i, decl_node s, decl_node e, extern "C" decl_node decl_makeRepeat (void) { - decl_node n; + decl_node__opaque n; n = newNode (decl_repeat); - n->repeatF.expr = NULL; - n->repeatF.statements = NULL; + n->repeatF.expr = static_cast (NULL); + n->repeatF.statements = static_cast (NULL); initPair (&n->repeatF.repeatComment); initPair (&n->repeatF.untilComment); - return n; + return static_cast (n); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -26800,7 +26939,7 @@ extern "C" decl_node decl_makeRepeat (void) extern "C" bool decl_isRepeat (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_repeat; + return static_cast (n)->kind == decl_repeat; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -26813,8 +26952,8 @@ extern "C" bool decl_isRepeat (decl_node n) extern "C" void decl_putRepeat (decl_node n, decl_node s, decl_node e) { - n->repeatF.expr = e; - n->repeatF.statements = s; + static_cast (n)->repeatF.expr = static_cast (e); + static_cast (n)->repeatF.statements = static_cast (s); } @@ -26825,8 +26964,8 @@ extern "C" void decl_putRepeat (decl_node n, decl_node s, decl_node e) extern "C" void decl_addRepeatComment (decl_node r, decl_node body, decl_node after) { mcDebug_assert (decl_isRepeat (r)); - r->repeatF.repeatComment.after = after; - r->repeatF.repeatComment.body = body; + static_cast (r)->repeatF.repeatComment.after = static_cast (after); + static_cast (r)->repeatF.repeatComment.body = static_cast (body); } @@ -26837,8 +26976,8 @@ extern "C" void decl_addRepeatComment (decl_node r, decl_node body, decl_node af extern "C" void decl_addUntilComment (decl_node r, decl_node body, decl_node after) { mcDebug_assert (decl_isRepeat (r)); - r->repeatF.untilComment.after = after; - r->repeatF.untilComment.body = body; + static_cast (r)->repeatF.untilComment.after = static_cast (after); + static_cast (r)->repeatF.untilComment.body = static_cast (body); } @@ -26848,13 +26987,13 @@ extern "C" void decl_addUntilComment (decl_node r, decl_node body, decl_node aft extern "C" decl_node decl_makeCase (void) { - decl_node n; + decl_node__opaque n; n = newNode (decl_case); - n->caseF.expression = NULL; + n->caseF.expression = static_cast (NULL); n->caseF.caseLabelList = Indexing_InitIndex (1); - n->caseF.else_ = NULL; - return n; + n->caseF.else_ = static_cast (NULL); + return static_cast (n); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -26867,7 +27006,7 @@ extern "C" decl_node decl_makeCase (void) extern "C" bool decl_isCase (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_case; + return static_cast (n)->kind == decl_case; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -26881,7 +27020,7 @@ extern "C" bool decl_isCase (decl_node n) extern "C" decl_node decl_putCaseExpression (decl_node n, decl_node e) { mcDebug_assert (decl_isCase (n)); - n->caseF.expression = e; + static_cast (n)->caseF.expression = static_cast (e); return n; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -26896,7 +27035,7 @@ extern "C" decl_node decl_putCaseExpression (decl_node n, decl_node e) extern "C" decl_node decl_putCaseElse (decl_node n, decl_node e) { mcDebug_assert (decl_isCase (n)); - n->caseF.else_ = e; + static_cast (n)->caseF.else_ = static_cast (e); return n; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -26913,7 +27052,7 @@ extern "C" decl_node decl_putCaseStatement (decl_node n, decl_node l, decl_node { mcDebug_assert (decl_isCase (n)); mcDebug_assert (decl_isCaseList (l)); - Indexing_IncludeIndiceIntoIndex (n->caseF.caseLabelList, reinterpret_cast (decl_makeCaseLabelList (l, s))); + Indexing_IncludeIndiceIntoIndex (static_cast (n)->caseF.caseLabelList, reinterpret_cast (decl_makeCaseLabelList (l, s))); return n; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -26926,12 +27065,12 @@ extern "C" decl_node decl_putCaseStatement (decl_node n, decl_node l, decl_node extern "C" decl_node decl_makeCaseLabelList (decl_node l, decl_node s) { - decl_node n; + decl_node__opaque n; n = newNode (decl_caselabellist); - n->caselabellistF.caseList = l; - n->caselabellistF.statements = s; - return n; + n->caselabellistF.caseList = static_cast (l); + n->caselabellistF.statements = static_cast (s); + return static_cast (n); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -26944,7 +27083,7 @@ extern "C" decl_node decl_makeCaseLabelList (decl_node l, decl_node s) extern "C" bool decl_isCaseLabelList (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_caselabellist; + return static_cast (n)->kind == decl_caselabellist; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -26956,11 +27095,11 @@ extern "C" bool decl_isCaseLabelList (decl_node n) extern "C" decl_node decl_makeCaseList (void) { - decl_node n; + decl_node__opaque n; n = newNode (decl_caselist); n->caselistF.rangePairs = Indexing_InitIndex (1); - return n; + return static_cast (n); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -26973,7 +27112,7 @@ extern "C" decl_node decl_makeCaseList (void) extern "C" bool decl_isCaseList (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_caselist; + return static_cast (n)->kind == decl_caselist; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -26986,7 +27125,7 @@ extern "C" bool decl_isCaseList (decl_node n) extern "C" decl_node decl_putCaseRange (decl_node n, decl_node lo, decl_node hi) { mcDebug_assert (decl_isCaseList (n)); - Indexing_IncludeIndiceIntoIndex (n->caselistF.rangePairs, reinterpret_cast (decl_makeRange (lo, hi))); + Indexing_IncludeIndiceIntoIndex (static_cast (n)->caselistF.rangePairs, reinterpret_cast (decl_makeRange (lo, hi))); return n; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -26999,12 +27138,12 @@ extern "C" decl_node decl_putCaseRange (decl_node n, decl_node lo, decl_node hi) extern "C" decl_node decl_makeRange (decl_node lo, decl_node hi) { - decl_node n; + decl_node__opaque n; n = newNode (decl_range); - n->rangeF.lo = lo; - n->rangeF.hi = hi; - return n; + n->rangeF.lo = static_cast (lo); + n->rangeF.hi = static_cast (hi); + return static_cast (n); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -27017,7 +27156,7 @@ extern "C" decl_node decl_makeRange (decl_node lo, decl_node hi) extern "C" bool decl_isRange (decl_node n) { mcDebug_assert (n != NULL); - return n->kind == decl_range; + return static_cast (n)->kind == decl_range; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -27031,12 +27170,12 @@ extern "C" void decl_setNoReturn (decl_node n, bool value) { mcDebug_assert (n != NULL); mcDebug_assert (decl_isProcedure (n)); - if (n->procedureF.noreturnused && (n->procedureF.noreturn != value)) + if (static_cast (n)->procedureF.noreturnused && (static_cast (n)->procedureF.noreturn != value)) { mcMetaError_metaError1 ((const char *) "{%1DMad} definition module and implementation module have different <* noreturn *> attributes", 93, (const unsigned char *) &n, (sizeof (n)-1)); } - n->procedureF.noreturn = value; - n->procedureF.noreturnused = true; + static_cast (n)->procedureF.noreturn = value; + static_cast (n)->procedureF.noreturnused = true; } @@ -27050,11 +27189,11 @@ extern "C" decl_node decl_dupExpr (decl_node n) { if (n == NULL) { - return NULL; + return static_cast (NULL); } else { - return doDupExpr (n); + return static_cast (doDupExpr (static_cast (n))); } /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -27108,15 +27247,15 @@ extern "C" void decl_out (void) switch (lang) { case decl_ansiC: - outC (p, decl_getMainModule ()); + outC (p, static_cast (decl_getMainModule ())); break; case decl_ansiCP: - outC (p, decl_getMainModule ()); + outC (p, static_cast (decl_getMainModule ())); break; case decl_pim4: - outM2 (p, decl_getMainModule ()); + outM2 (p, static_cast (decl_getMainModule ())); break; @@ -27127,11 +27266,11 @@ extern "C" void decl_out (void) closeOutput (); } -extern "C" void _M2_decl_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_decl_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { init (); } -extern "C" void _M2_decl_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_decl_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/Gdecl.h b/gcc/m2/mc-boot/Gdecl.h index 67cd5b2e4d2b4..a237a25a3f6c2 100644 --- a/gcc/m2/mc-boot/Gdecl.h +++ b/gcc/m2/mc-boot/Gdecl.h @@ -246,6 +246,19 @@ EXTERN bool decl_isTypeHidden (decl_node n); EXTERN bool decl_hasHidden (decl_node n); +/* + putTypeOpaque - marks type, des, as being an opaque type. + TYPE des ; +*/ + +EXTERN void decl_putTypeOpaque (decl_node des); + +/* + isTypeOpaque - returns TRUE if type, n, is an opaque type. +*/ + +EXTERN bool decl_isTypeOpaque (decl_node n); + /* isVar - returns TRUE if node, n, is a type. */ diff --git a/gcc/m2/mc-boot/Gkeyc.cc b/gcc/m2/mc-boot/Gkeyc.cc index 0deb633d6b44f..4a15f7b73719f 100644 --- a/gcc/m2/mc-boot/Gkeyc.cc +++ b/gcc/m2/mc-boot/Gkeyc.cc @@ -42,9 +42,9 @@ Boston, MA 02110-1301, USA. */ # undef NULL # define NULL 0 #endif -#define _keyc_H #define _keyc_C +#include "Gkeyc.h" # include "GmcPretty.h" # include "GStorage.h" # include "GDynamicStrings.h" @@ -1630,11 +1630,11 @@ extern "C" void keyc_cp (void) } } -extern "C" void _M2_keyc_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_keyc_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { init (); } -extern "C" void _M2_keyc_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_keyc_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/Gldtoa.h b/gcc/m2/mc-boot/Gldtoa.h index df1f791b3bb39..c4b4d904fb0c5 100644 --- a/gcc/m2/mc-boot/Gldtoa.h +++ b/gcc/m2/mc-boot/Gldtoa.h @@ -68,7 +68,7 @@ EXTERN long double ldtoa_strtold (void * s, bool *error); sign does the string have a sign? */ -EXTERN void * ldtoa_ldtoa (long double d, ldtoa_Mode mode, int ndigits, int *decpt, bool *sign); +EXTERN void * ldtoa_ldtoa (long double d, int mode, int ndigits, int *decpt, bool *sign); # ifdef __cplusplus } # endif diff --git a/gcc/m2/mc-boot/Glibc.h b/gcc/m2/mc-boot/Glibc.h index 382b737e4b8ff..2f7fac46d7710 100644 --- a/gcc/m2/mc-boot/Glibc.h +++ b/gcc/m2/mc-boot/Glibc.h @@ -70,7 +70,7 @@ struct libc_tm_r { int tm_yday; int tm_isdst; long int tm_gmtoff; - void *tm_zone; + void * tm_zone; }; struct libc_timeb_r { diff --git a/gcc/m2/mc-boot/Glists.cc b/gcc/m2/mc-boot/Glists.cc index 4bfc310e8ce26..dbbcd0eeb6658 100644 --- a/gcc/m2/mc-boot/Glists.cc +++ b/gcc/m2/mc-boot/Glists.cc @@ -41,9 +41,9 @@ Boston, MA 02110-1301, USA. */ # undef NULL # define NULL 0 #endif -#define _lists_H #define _lists_C +#include "Glists.h" # include "GStorage.h" typedef struct symbolKey_performOperation_p symbolKey_performOperation; @@ -53,16 +53,13 @@ typedef struct lists__T1_r lists__T1; typedef struct lists__T2_a lists__T2; -typedef lists__T1 *lists_list; - -typedef void (*symbolKey_performOperation_t) (void *); -struct symbolKey_performOperation_p { symbolKey_performOperation_t proc; }; +typedef lists__T1 *lists_list__opaque; struct lists__T2_a { void * array[MaxnoOfelements-1+1]; }; struct lists__T1_r { unsigned int noOfelements; lists__T2 elements; - lists_list next; + lists_list__opaque next; }; @@ -140,14 +137,14 @@ extern "C" lists_list lists_duplicateList (lists_list l); removeItem - remove an element at index, i, from the list data type. */ -static void removeItem (lists_list p, lists_list l, unsigned int i); +static void removeItem (lists_list__opaque p, lists_list__opaque l, unsigned int i); /* removeItem - remove an element at index, i, from the list data type. */ -static void removeItem (lists_list p, lists_list l, unsigned int i) +static void removeItem (lists_list__opaque p, lists_list__opaque l, unsigned int i) { l->noOfelements -= 1; while (i <= l->noOfelements) @@ -169,12 +166,12 @@ static void removeItem (lists_list p, lists_list l, unsigned int i) extern "C" lists_list lists_initList (void) { - lists_list l; + lists_list__opaque l; Storage_ALLOCATE ((void **) &l, sizeof (lists__T1)); l->noOfelements = 0; - l->next = NULL; - return l; + l->next = static_cast (NULL); + return static_cast (l); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -188,9 +185,9 @@ extern "C" void lists_killList (lists_list *l) { if ((*l) != NULL) { - if ((*l)->next != NULL) + if (static_cast ((*l))->next != NULL) { - lists_killList (&(*l)->next); + lists_killList (reinterpret_cast (&static_cast ((*l))->next)); } Storage_DEALLOCATE ((void **) &(*l), sizeof (lists__T1)); } @@ -203,21 +200,21 @@ extern "C" void lists_killList (lists_list *l) extern "C" void lists_putItemIntoList (lists_list l, void * c) { - if (l->noOfelements < MaxnoOfelements) + if (static_cast (l)->noOfelements < MaxnoOfelements) { - l->noOfelements += 1; - l->elements.array[l->noOfelements-1] = c; + static_cast (l)->noOfelements += 1; + static_cast (l)->elements.array[static_cast (l)->noOfelements-1] = c; } - else if (l->next != NULL) + else if (static_cast (l)->next != NULL) { /* avoid dangling else. */ - lists_putItemIntoList (l->next, c); + lists_putItemIntoList (static_cast (static_cast (l)->next), c); } else { /* avoid dangling else. */ - l->next = lists_initList (); - lists_putItemIntoList (l->next, c); + static_cast (l)->next = static_cast (lists_initList ()); + lists_putItemIntoList (static_cast (static_cast (l)->next), c); } } @@ -230,17 +227,17 @@ extern "C" void * lists_getItemFromList (lists_list l, unsigned int n) { while (l != NULL) { - if (n <= l->noOfelements) + if (n <= static_cast (l)->noOfelements) { - return l->elements.array[n-1]; + return static_cast (l)->elements.array[n-1]; } else { - n -= l->noOfelements; + n -= static_cast (l)->noOfelements; } - l = l->next; + l = static_cast (static_cast (l)->next); } - return reinterpret_cast (0); + return static_cast (0); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -263,9 +260,9 @@ extern "C" unsigned int lists_getIndexOfList (lists_list l, void * c) else { i = 1; - while (i <= l->noOfelements) + while (i <= static_cast (l)->noOfelements) { - if (l->elements.array[i-1] == c) + if (static_cast (l)->elements.array[i-1] == c) { return i; } @@ -274,7 +271,7 @@ extern "C" unsigned int lists_getIndexOfList (lists_list l, void * c) i += 1; } } - return l->noOfelements+(lists_getIndexOfList (l->next, c)); + return static_cast (l)->noOfelements+(lists_getIndexOfList (static_cast (static_cast (l)->next), c)); } /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -297,8 +294,8 @@ extern "C" unsigned int lists_noOfItemsInList (lists_list l) { t = 0; do { - t += l->noOfelements; - l = l->next; + t += static_cast (l)->noOfelements; + l = static_cast (static_cast (l)->next); } while (! (l == NULL)); return t; } @@ -328,33 +325,33 @@ extern "C" void lists_includeItemIntoList (lists_list l, void * c) extern "C" void lists_removeItemFromList (lists_list l, void * c) { - lists_list p; + lists_list__opaque p; unsigned int i; bool found; if (l != NULL) { found = false; - p = NULL; + p = static_cast (NULL); do { i = 1; - while ((i <= l->noOfelements) && (l->elements.array[i-1] != c)) + while ((i <= static_cast (l)->noOfelements) && (static_cast (l)->elements.array[i-1] != c)) { i += 1; } - if ((i <= l->noOfelements) && (l->elements.array[i-1] == c)) + if ((i <= static_cast (l)->noOfelements) && (static_cast (l)->elements.array[i-1] == c)) { found = true; } else { - p = l; - l = l->next; + p = static_cast (l); + l = static_cast (static_cast (l)->next); } } while (! ((l == NULL) || found)); if (found) { - removeItem (p, l, i); + removeItem (p, static_cast (l), i); } } } @@ -370,9 +367,9 @@ extern "C" bool lists_isItemInList (lists_list l, void * c) do { i = 1; - while (i <= l->noOfelements) + while (i <= static_cast (l)->noOfelements) { - if (l->elements.array[i-1] == c) + if (static_cast (l)->elements.array[i-1] == c) { return true; } @@ -381,7 +378,7 @@ extern "C" bool lists_isItemInList (lists_list l, void * c) i += 1; } } - l = l->next; + l = static_cast (static_cast (l)->next); } while (! (l == NULL)); return false; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -414,27 +411,27 @@ extern "C" void lists_foreachItemInListDo (lists_list l, symbolKey_performOperat extern "C" lists_list lists_duplicateList (lists_list l) { - lists_list m; + lists_list__opaque m; unsigned int n; unsigned int i; - m = lists_initList (); + m = static_cast (lists_initList ()); n = lists_noOfItemsInList (l); i = 1; while (i <= n) { - lists_putItemIntoList (m, lists_getItemFromList (l, i)); + lists_putItemIntoList (static_cast (m), lists_getItemFromList (l, i)); i += 1; } - return m; + return static_cast (m); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } -extern "C" void _M2_lists_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_lists_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_lists_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_lists_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GmcComment.cc b/gcc/m2/mc-boot/GmcComment.cc index f17fb19a8e659..4c7650283ec22 100644 --- a/gcc/m2/mc-boot/GmcComment.cc +++ b/gcc/m2/mc-boot/GmcComment.cc @@ -43,9 +43,9 @@ along with GNU Modula-2; see the file COPYING3. If not see # undef NULL # define NULL 0 #endif -#define _mcComment_H #define _mcComment_C +#include "GmcComment.h" # include "GDynamicStrings.h" # include "GStorage.h" # include "GnameKey.h" @@ -57,7 +57,7 @@ typedef struct mcComment__T1_r mcComment__T1; typedef enum {mcComment_unknown, mcComment_procedureHeading, mcComment_inBody, mcComment_afterStatement} mcComment_commentType; -typedef mcComment__T1 *mcComment_commentDesc; +typedef mcComment__T1 *mcComment_commentDesc__opaque; struct mcComment__T1_r { mcComment_commentType type; @@ -156,13 +156,13 @@ static DynamicStrings_String RemoveNewlines (DynamicStrings_String s); in the comment. */ -static bool seenProcedure (mcComment_commentDesc cd, nameKey_Name procName); +static bool seenProcedure (mcComment_commentDesc__opaque cd, nameKey_Name procName); /* dumpComment - */ -static void dumpComment (mcComment_commentDesc cd); +static void dumpComment (mcComment_commentDesc__opaque cd); /* @@ -212,7 +212,7 @@ static DynamicStrings_String RemoveNewlines (DynamicStrings_String s) in the comment. */ -static bool seenProcedure (mcComment_commentDesc cd, nameKey_Name procName) +static bool seenProcedure (mcComment_commentDesc__opaque cd, nameKey_Name procName) { DynamicStrings_String s; void * a; @@ -235,7 +235,7 @@ static bool seenProcedure (mcComment_commentDesc cd, nameKey_Name procName) dumpComment - */ -static void dumpComment (mcComment_commentDesc cd) +static void dumpComment (mcComment_commentDesc__opaque cd) { libc_printf ((const char *) "comment : ", 10); switch (cd->type) @@ -282,7 +282,7 @@ static void dumpComment (mcComment_commentDesc cd) extern "C" mcComment_commentDesc mcComment_initComment (bool onlySpaces) { - mcComment_commentDesc cd; + mcComment_commentDesc__opaque cd; Storage_ALLOCATE ((void **) &cd, sizeof (mcComment__T1)); mcDebug_assert (cd != NULL); @@ -297,7 +297,7 @@ extern "C" mcComment_commentDesc mcComment_initComment (bool onlySpaces) cd->content = DynamicStrings_InitString ((const char *) "", 0); cd->procName = nameKey_NulName; cd->used = false; - return cd; + return static_cast (cd); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -312,7 +312,7 @@ extern "C" void mcComment_addText (mcComment_commentDesc cd, void * cs) { if (cd != NULL) { - cd->content = DynamicStrings_ConCat (cd->content, DynamicStrings_InitStringCharStar (cs)); + static_cast (cd)->content = DynamicStrings_ConCat (static_cast (cd)->content, DynamicStrings_InitStringCharStar (cs)); } } @@ -325,7 +325,7 @@ extern "C" DynamicStrings_String mcComment_getContent (mcComment_commentDesc cd) { if (cd != NULL) { - return cd->content; + return static_cast (cd)->content; } return static_cast (NULL); /* static analysis guarentees a RETURN statement will be used before here. */ @@ -365,10 +365,10 @@ extern "C" void mcComment_setProcedureComment (mcComment_commentDesc cd, nameKey { if (cd != NULL) { - if (seenProcedure (cd, procname)) + if (seenProcedure (static_cast (cd), procname)) { - cd->type = mcComment_procedureHeading; - cd->procName = procname; + static_cast (cd)->type = mcComment_procedureHeading; + static_cast (cd)->procName = procname; } } } @@ -380,10 +380,10 @@ extern "C" void mcComment_setProcedureComment (mcComment_commentDesc cd, nameKey extern "C" DynamicStrings_String mcComment_getProcedureComment (mcComment_commentDesc cd) { - if ((cd->type == mcComment_procedureHeading) && ! cd->used) + if ((static_cast (cd)->type == mcComment_procedureHeading) && ! static_cast (cd)->used) { - cd->used = true; - return cd->content; + static_cast (cd)->used = true; + return static_cast (cd)->content; } return static_cast (NULL); /* static analysis guarentees a RETURN statement will be used before here. */ @@ -397,10 +397,10 @@ extern "C" DynamicStrings_String mcComment_getProcedureComment (mcComment_commen extern "C" DynamicStrings_String mcComment_getAfterStatementComment (mcComment_commentDesc cd) { - if ((cd->type == mcComment_afterStatement) && ! cd->used) + if ((static_cast (cd)->type == mcComment_afterStatement) && ! static_cast (cd)->used) { - cd->used = true; - return cd->content; + static_cast (cd)->used = true; + return static_cast (cd)->content; } return static_cast (NULL); /* static analysis guarentees a RETURN statement will be used before here. */ @@ -414,10 +414,10 @@ extern "C" DynamicStrings_String mcComment_getAfterStatementComment (mcComment_c extern "C" DynamicStrings_String mcComment_getInbodyStatementComment (mcComment_commentDesc cd) { - if ((cd->type == mcComment_inBody) && ! cd->used) + if ((static_cast (cd)->type == mcComment_inBody) && ! static_cast (cd)->used) { - cd->used = true; - return cd->content; + static_cast (cd)->used = true; + return static_cast (cd)->content; } return static_cast (NULL); /* static analysis guarentees a RETURN statement will be used before here. */ @@ -431,7 +431,7 @@ extern "C" DynamicStrings_String mcComment_getInbodyStatementComment (mcComment_ extern "C" bool mcComment_isProcedureComment (mcComment_commentDesc cd) { - return (cd != NULL) && (cd->type == mcComment_procedureHeading); + return (cd != NULL) && (static_cast (cd)->type == mcComment_procedureHeading); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -443,7 +443,7 @@ extern "C" bool mcComment_isProcedureComment (mcComment_commentDesc cd) extern "C" bool mcComment_isBodyComment (mcComment_commentDesc cd) { - return (cd != NULL) && (cd->type == mcComment_inBody); + return (cd != NULL) && (static_cast (cd)->type == mcComment_inBody); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -455,15 +455,15 @@ extern "C" bool mcComment_isBodyComment (mcComment_commentDesc cd) extern "C" bool mcComment_isAfterComment (mcComment_commentDesc cd) { - return (cd != NULL) && (cd->type == mcComment_afterStatement); + return (cd != NULL) && (static_cast (cd)->type == mcComment_afterStatement); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } -extern "C" void _M2_mcComment_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcComment_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_mcComment_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcComment_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GmcComp.cc b/gcc/m2/mc-boot/GmcComp.cc index 33c8201d8ad44..02877639ad73f 100644 --- a/gcc/m2/mc-boot/GmcComp.cc +++ b/gcc/m2/mc-boot/GmcComp.cc @@ -38,9 +38,9 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ # undef NULL # define NULL 0 #endif -#define _mcComp_H #define _mcComp_C +#include "GmcComp.h" # include "GFIO.h" # include "Glibc.h" # include "Gdecl.h" @@ -562,7 +562,7 @@ static void pass (unsigned int no, decl_node n, mcComp_parserFunction f, decl_is { mcError_writeFormat0 ((const char *) "compilation failed", 18); mcLexBuf_closeSource (); - return ; + return; } mcLexBuf_closeSource (); } @@ -651,11 +651,11 @@ extern "C" unsigned int mcComp_getPassNo (void) __builtin_unreachable (); } -extern "C" void _M2_mcComp_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcComp_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { init (); } -extern "C" void _M2_mcComp_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcComp_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GmcDebug.cc b/gcc/m2/mc-boot/GmcDebug.cc index f891959319938..154ae6926c1d6 100644 --- a/gcc/m2/mc-boot/GmcDebug.cc +++ b/gcc/m2/mc-boot/GmcDebug.cc @@ -24,9 +24,9 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ typedef struct { PROC_t proc; } PROC; # endif -#define _mcDebug_H #define _mcDebug_C +#include "GmcDebug.h" # include "GStrIO.h" # include "GmcOptions.h" # include "GmcError.h" @@ -78,10 +78,10 @@ extern "C" void mcDebug_writeDebug (const char *a_, unsigned int _a_high) } } -extern "C" void _M2_mcDebug_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcDebug_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_mcDebug_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcDebug_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GmcError.cc b/gcc/m2/mc-boot/GmcError.cc index 7a17119f6f347..5893201913fed 100644 --- a/gcc/m2/mc-boot/GmcError.cc +++ b/gcc/m2/mc-boot/GmcError.cc @@ -42,9 +42,9 @@ along with GNU Modula-2; see the file COPYING3. If not see # undef NULL # define NULL 0 #endif -#define _mcError_H #define _mcError_C +#include "GmcError.h" # include "GASCII.h" # include "GDynamicStrings.h" # include "GFIO.h" @@ -63,18 +63,18 @@ along with GNU Modula-2; see the file COPYING3. If not see # define Xcode true typedef struct mcError__T2_r mcError__T2; -typedef mcError__T2 *mcError_error; +typedef mcError__T2 *mcError_error__opaque; struct mcError__T2_r { - mcError_error parent; - mcError_error child; - mcError_error next; + mcError_error__opaque parent; + mcError_error__opaque child; + mcError_error__opaque next; bool fatal; DynamicStrings_String s; unsigned int token; }; -static mcError_error head; +static mcError_error__opaque head; static bool inInternal; /* @@ -282,7 +282,7 @@ static void checkIncludes (unsigned int token, unsigned int depth); flushAll - flushes all errors in list, e. */ -static bool flushAll (mcError_error e, bool FatalStatus); +static bool flushAll (mcError_error__opaque e, bool FatalStatus); /* @@ -301,7 +301,7 @@ static void cast (unsigned char *a, unsigned int _a_high, const unsigned char *b { for (i=0; i<=_a_high; i++) { - a[i] = b[i]; + const_cast(a)[i] = b[i]; } } } @@ -326,7 +326,7 @@ static bool translateNameToCharStar (char *a, unsigned int _a_high, unsigned int { if ((a[i+1] == 'a') && (argno == n)) { - a[i+1] = 's'; + const_cast(a)[i+1] = 's'; return true; } argno += 1; @@ -600,7 +600,7 @@ static DynamicStrings_String doFormat3 (const char *a_, unsigned int _a_high, co static void init (void) { - head = NULL; + head = static_cast (NULL); inInternal = false; } @@ -656,9 +656,9 @@ static void checkIncludes (unsigned int token, unsigned int depth) flushAll - flushes all errors in list, e. */ -static bool flushAll (mcError_error e, bool FatalStatus) +static bool flushAll (mcError_error__opaque e, bool FatalStatus) { - mcError_error f; + mcError_error__opaque f; bool written; written = false; @@ -734,13 +734,13 @@ extern "C" void mcError_internalError (const char *a_, unsigned int _a_high, con extern "C" void mcError_writeFormat0 (const char *a_, unsigned int _a_high) { - mcError_error e; + mcError_error__opaque e; char a[_a_high+1]; /* make a local copy of each unbounded array. */ memcpy (a, a_, _a_high+1); - e = mcError_newError (mcLexBuf_getTokenNo ()); + e = static_cast (mcError_newError (mcLexBuf_getTokenNo ())); e->s = FormatStrings_Sprintf0 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high))); } @@ -753,7 +753,7 @@ extern "C" void mcError_writeFormat0 (const char *a_, unsigned int _a_high) extern "C" void mcError_writeFormat1 (const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high) { - mcError_error e; + mcError_error__opaque e; char a[_a_high+1]; unsigned char w[_w_high+1]; @@ -761,7 +761,7 @@ extern "C" void mcError_writeFormat1 (const char *a_, unsigned int _a_high, cons memcpy (a, a_, _a_high+1); memcpy (w, w_, _w_high+1); - e = mcError_newError (mcLexBuf_getTokenNo ()); + e = static_cast (mcError_newError (mcLexBuf_getTokenNo ())); e->s = doFormat1 ((const char *) a, _a_high, (const unsigned char *) w, _w_high); } @@ -774,7 +774,7 @@ extern "C" void mcError_writeFormat1 (const char *a_, unsigned int _a_high, cons extern "C" void mcError_writeFormat2 (const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high) { - mcError_error e; + mcError_error__opaque e; char a[_a_high+1]; unsigned char w1[_w1_high+1]; unsigned char w2[_w2_high+1]; @@ -784,7 +784,7 @@ extern "C" void mcError_writeFormat2 (const char *a_, unsigned int _a_high, cons memcpy (w1, w1_, _w1_high+1); memcpy (w2, w2_, _w2_high+1); - e = mcError_newError (mcLexBuf_getTokenNo ()); + e = static_cast (mcError_newError (mcLexBuf_getTokenNo ())); e->s = doFormat2 ((const char *) a, _a_high, (const unsigned char *) w1, _w1_high, (const unsigned char *) w2, _w2_high); } @@ -797,7 +797,7 @@ extern "C" void mcError_writeFormat2 (const char *a_, unsigned int _a_high, cons extern "C" void mcError_writeFormat3 (const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high) { - mcError_error e; + mcError_error__opaque e; char a[_a_high+1]; unsigned char w1[_w1_high+1]; unsigned char w2[_w2_high+1]; @@ -809,7 +809,7 @@ extern "C" void mcError_writeFormat3 (const char *a_, unsigned int _a_high, cons memcpy (w2, w2_, _w2_high+1); memcpy (w3, w3_, _w3_high+1); - e = mcError_newError (mcLexBuf_getTokenNo ()); + e = static_cast (mcError_newError (mcLexBuf_getTokenNo ())); e->s = doFormat3 ((const char *) a, _a_high, (const unsigned char *) w1, _w1_high, (const unsigned char *) w2, _w2_high, (const unsigned char *) w3, _w3_high); } @@ -820,15 +820,15 @@ extern "C" void mcError_writeFormat3 (const char *a_, unsigned int _a_high, cons extern "C" mcError_error mcError_newError (unsigned int atTokenNo) { - mcError_error e; - mcError_error f; + mcError_error__opaque e; + mcError_error__opaque f; Storage_ALLOCATE ((void **) &e, sizeof (mcError__T2)); e->s = static_cast (NULL); e->token = atTokenNo; - e->next = NULL; - e->parent = NULL; - e->child = NULL; + e->next = static_cast (NULL); + e->parent = static_cast (NULL); + e->child = static_cast (NULL); e->fatal = true; if ((head == NULL) || (head->token > atTokenNo)) { @@ -845,7 +845,7 @@ extern "C" mcError_error mcError_newError (unsigned int atTokenNo) e->next = f->next; f->next = e; } - return e; + return static_cast (e); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -858,11 +858,11 @@ extern "C" mcError_error mcError_newError (unsigned int atTokenNo) extern "C" mcError_error mcError_newWarning (unsigned int atTokenNo) { - mcError_error e; + mcError_error__opaque e; - e = mcError_newError (atTokenNo); + e = static_cast (mcError_newError (atTokenNo)); e->fatal = false; - return e; + return static_cast (e); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -876,7 +876,7 @@ extern "C" mcError_error mcError_newWarning (unsigned int atTokenNo) extern "C" mcError_error mcError_chainError (unsigned int atTokenNo, mcError_error e) { - mcError_error f; + mcError_error__opaque f; if (e == NULL) { @@ -887,13 +887,13 @@ extern "C" mcError_error mcError_chainError (unsigned int atTokenNo, mcError_err Storage_ALLOCATE ((void **) &f, sizeof (mcError__T2)); f->s = static_cast (NULL); f->token = atTokenNo; - f->next = e->child; - f->parent = e; - f->child = NULL; - f->fatal = e->fatal; - e->child = f; + f->next = static_cast (e)->child; + f->parent = static_cast (e); + f->child = static_cast (NULL); + f->fatal = static_cast (e)->fatal; + static_cast (e)->child = f; } - return f; + return static_cast (f); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -908,13 +908,13 @@ extern "C" void mcError_errorFormat0 (mcError_error e, const char *a_, unsigned /* errorFormat routines provide a printf capability for the error handle. */ - if (e->s == NULL) + if (static_cast (e)->s == NULL) { - e->s = FormatStrings_Sprintf0 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high))); + static_cast (e)->s = FormatStrings_Sprintf0 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high))); } else { - e->s = DynamicStrings_ConCat (e->s, DynamicStrings_Mark (FormatStrings_Sprintf0 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high))))); + static_cast (e)->s = DynamicStrings_ConCat (static_cast (e)->s, DynamicStrings_Mark (FormatStrings_Sprintf0 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high))))); } } @@ -929,13 +929,13 @@ extern "C" void mcError_errorFormat1 (mcError_error e, const char *a_, unsigned memcpy (w, w_, _w_high+1); s1 = doFormat1 ((const char *) a, _a_high, (const unsigned char *) w, _w_high); - if (e->s == NULL) + if (static_cast (e)->s == NULL) { - e->s = s1; + static_cast (e)->s = s1; } else { - e->s = DynamicStrings_ConCat (e->s, DynamicStrings_Mark (s1)); + static_cast (e)->s = DynamicStrings_ConCat (static_cast (e)->s, DynamicStrings_Mark (s1)); } } @@ -952,13 +952,13 @@ extern "C" void mcError_errorFormat2 (mcError_error e, const char *a_, unsigned memcpy (w2, w2_, _w2_high+1); s1 = doFormat2 ((const char *) a, _a_high, (const unsigned char *) w1, _w1_high, (const unsigned char *) w2, _w2_high); - if (e->s == NULL) + if (static_cast (e)->s == NULL) { - e->s = s1; + static_cast (e)->s = s1; } else { - e->s = DynamicStrings_ConCat (e->s, DynamicStrings_Mark (s1)); + static_cast (e)->s = DynamicStrings_ConCat (static_cast (e)->s, DynamicStrings_Mark (s1)); } } @@ -977,19 +977,19 @@ extern "C" void mcError_errorFormat3 (mcError_error e, const char *a_, unsigned memcpy (w3, w3_, _w3_high+1); s1 = doFormat3 ((const char *) a, _a_high, (const unsigned char *) w1, _w1_high, (const unsigned char *) w2, _w2_high, (const unsigned char *) w3, _w3_high); - if (e->s == NULL) + if (static_cast (e)->s == NULL) { - e->s = s1; + static_cast (e)->s = s1; } else { - e->s = DynamicStrings_ConCat (e->s, DynamicStrings_Mark (s1)); + static_cast (e)->s = DynamicStrings_ConCat (static_cast (e)->s, DynamicStrings_Mark (s1)); } } extern "C" void mcError_errorString (mcError_error e, DynamicStrings_String str) { - e->s = str; + static_cast (e)->s = str; } @@ -1001,10 +1001,10 @@ extern "C" void mcError_errorString (mcError_error e, DynamicStrings_String str) extern "C" void mcError_errorStringAt (DynamicStrings_String s, unsigned int tok) { - mcError_error e; + mcError_error__opaque e; - e = mcError_newError (tok); - mcError_errorString (e, s); + e = static_cast (mcError_newError (tok)); + mcError_errorString (static_cast (e), s); } @@ -1028,15 +1028,15 @@ extern "C" void mcError_errorStringAt2 (DynamicStrings_String s, unsigned int to extern "C" void mcError_errorStringsAt2 (DynamicStrings_String s1, DynamicStrings_String s2, unsigned int tok1, unsigned int tok2) { - mcError_error e; + mcError_error__opaque e; if (s1 == s2) { s2 = DynamicStrings_Dup (s1); } - e = mcError_newError (tok1); - mcError_errorString (e, s1); - mcError_errorString (mcError_chainError (tok2, e), s2); + e = static_cast (mcError_newError (tok1)); + mcError_errorString (static_cast (e), s1); + mcError_errorString (mcError_chainError (tok2, static_cast (e)), s2); } @@ -1048,10 +1048,10 @@ extern "C" void mcError_errorStringsAt2 (DynamicStrings_String s1, DynamicString extern "C" void mcError_warnStringAt (DynamicStrings_String s, unsigned int tok) { - mcError_error e; + mcError_error__opaque e; - e = mcError_newWarning (tok); - mcError_errorString (e, s); + e = static_cast (mcError_newWarning (tok)); + mcError_errorString (static_cast (e), s); } @@ -1075,20 +1075,20 @@ extern "C" void mcError_warnStringAt2 (DynamicStrings_String s, unsigned int tok extern "C" void mcError_warnStringsAt2 (DynamicStrings_String s1, DynamicStrings_String s2, unsigned int tok1, unsigned int tok2) { - mcError_error e; + mcError_error__opaque e; if (s1 == s2) { s2 = DynamicStrings_Dup (s1); } - e = mcError_newWarning (tok1); - mcError_errorString (e, s1); - mcError_errorString (mcError_chainError (tok2, e), s2); + e = static_cast (mcError_newWarning (tok1)); + mcError_errorString (static_cast (e), s1); + mcError_errorString (mcError_chainError (tok2, static_cast (e)), s2); } extern "C" void mcError_warnFormat0 (const char *a_, unsigned int _a_high) { - mcError_error e; + mcError_error__opaque e; char a[_a_high+1]; /* make a local copy of each unbounded array. */ @@ -1099,7 +1099,7 @@ extern "C" void mcError_warnFormat0 (const char *a_, unsigned int _a_high) with the encapsulated format string. Used for simple warning messages tied to the current token. */ - e = mcError_newWarning (mcLexBuf_getTokenNo ()); + e = static_cast (mcError_newWarning (mcLexBuf_getTokenNo ())); e->s = FormatStrings_Sprintf0 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high))); } @@ -1112,7 +1112,7 @@ extern "C" void mcError_warnFormat0 (const char *a_, unsigned int _a_high) extern "C" void mcError_warnFormat1 (const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high) { - mcError_error e; + mcError_error__opaque e; char a[_a_high+1]; unsigned char w[_w_high+1]; @@ -1120,7 +1120,7 @@ extern "C" void mcError_warnFormat1 (const char *a_, unsigned int _a_high, const memcpy (a, a_, _a_high+1); memcpy (w, w_, _w_high+1); - e = mcError_newWarning (mcLexBuf_getTokenNo ()); + e = static_cast (mcError_newWarning (mcLexBuf_getTokenNo ())); e->s = doFormat1 ((const char *) a, _a_high, (const unsigned char *) w, _w_high); } @@ -1188,11 +1188,11 @@ extern "C" void mcError_errorAbort0 (const char *a_, unsigned int _a_high) __builtin_unreachable (); } -extern "C" void _M2_mcError_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcError_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { init (); } -extern "C" void _M2_mcError_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcError_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GmcFileName.cc b/gcc/m2/mc-boot/GmcFileName.cc index c2c23941287d8..6999113a85ef5 100644 --- a/gcc/m2/mc-boot/GmcFileName.cc +++ b/gcc/m2/mc-boot/GmcFileName.cc @@ -24,9 +24,9 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ typedef struct { PROC_t proc; } PROC; # endif -#define _mcFileName_H #define _mcFileName_C +#include "GmcFileName.h" # include "GASCII.h" # include "GDynamicStrings.h" @@ -144,10 +144,10 @@ extern "C" DynamicStrings_String mcFileName_extractModule (DynamicStrings_String __builtin_unreachable (); } -extern "C" void _M2_mcFileName_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcFileName_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_mcFileName_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcFileName_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GmcLexBuf.cc b/gcc/m2/mc-boot/GmcLexBuf.cc index d84440be51d72..bd6d45738dfa4 100644 --- a/gcc/m2/mc-boot/GmcLexBuf.cc +++ b/gcc/m2/mc-boot/GmcLexBuf.cc @@ -42,9 +42,9 @@ along with GNU Modula-2; see the file COPYING3. If not see # undef NULL # define NULL 0 #endif -#define _mcLexBuf_H #define _mcLexBuf_C +#include "GmcLexBuf.h" # include "Gmcflex.h" # include "Glibc.h" # include "GSYSTEM.h" @@ -58,12 +58,6 @@ along with GNU Modula-2; see the file COPYING3. If not see # include "GmcDebug.h" # include "GM2RTS.h" -mcComment_commentDesc mcLexBuf_currentcomment; -mcComment_commentDesc mcLexBuf_lastcomment; -int mcLexBuf_currentinteger; -unsigned int mcLexBuf_currentcolumn; -void * mcLexBuf_currentstring; -mcReserved_toktype mcLexBuf_currenttoken; # define MaxBucketSize 100 # define Debugging false typedef struct mcLexBuf_tokenDesc_r mcLexBuf_tokenDesc; @@ -1152,7 +1146,7 @@ static void doGetToken (void) /* call the lexical phase to place a new token into the last bucket. */ a = mcflex_getToken (); mcLexBuf_getToken (); /* and call ourselves again to collect the token from bucket. */ - return ; /* and call ourselves again to collect the token from bucket. */ + return; /* and call ourselves again to collect the token from bucket. */ } } else @@ -1840,11 +1834,11 @@ extern "C" void mcLexBuf_popFile (void * filename) /* source file list is empty, cannot pop an include.. */ } -extern "C" void _M2_mcLexBuf_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcLexBuf_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { init (); } -extern "C" void _M2_mcLexBuf_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcLexBuf_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GmcMetaError.cc b/gcc/m2/mc-boot/GmcMetaError.cc index b4f483bdb187a..d3b0fab9cbc07 100644 --- a/gcc/m2/mc-boot/GmcMetaError.cc +++ b/gcc/m2/mc-boot/GmcMetaError.cc @@ -36,9 +36,9 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ # undef NULL # define NULL 0 #endif -#define _mcMetaError_H #define _mcMetaError_C +#include "GmcMetaError.h" # include "GnameKey.h" # include "GStrLib.h" # include "GmcLexBuf.h" @@ -1270,7 +1270,7 @@ static void ebnf (mcError_error *e, mcMetaError_errorType *t, DynamicStrings_Str break; case '}': - return ; + return; break; @@ -1872,10 +1872,10 @@ extern "C" void mcMetaError_metaErrorStringT4 (unsigned int tok, DynamicStrings_ varargs_end (&sym); } -extern "C" void _M2_mcMetaError_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcMetaError_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_mcMetaError_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcMetaError_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GmcOptions.cc b/gcc/m2/mc-boot/GmcOptions.cc index 23d2a39ccda9c..99e7fb9700ac7 100644 --- a/gcc/m2/mc-boot/GmcOptions.cc +++ b/gcc/m2/mc-boot/GmcOptions.cc @@ -37,9 +37,9 @@ Boston, MA 02110-1301, USA. */ # undef NULL # define NULL 0 #endif -#define _mcOptions_H #define _mcOptions_C +#include "GmcOptions.h" # include "GSArgs.h" # include "GmcSearch.h" # include "Glibc.h" @@ -885,7 +885,8 @@ static void handleOption (DynamicStrings_String arg) else if (optionIs ((const char *) "--extended-opaque", 17, arg)) { /* avoid dangling else. */ - setExtendedOpaque (true); + /* setExtendedOpaque (TRUE) */ + mcPrintf_printf0 ((const char *) "IGNORING --extended-opaque - this option is no longer implemented - please adjust the call to mc\\n", 98); } else if (optionIs ((const char *) "--debug-top", 11, arg)) { @@ -1258,7 +1259,7 @@ extern "C" DynamicStrings_String mcOptions_getCShortRealType (void) __builtin_unreachable (); } -extern "C" void _M2_mcOptions_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcOptions_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { langC = true; langCPP = false; @@ -1293,6 +1294,6 @@ extern "C" void _M2_mcOptions_init (__attribute__((unused)) int argc,__attribute CShortReal = DynamicStrings_InitString ((const char *) "float", 5); } -extern "C" void _M2_mcOptions_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcOptions_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GmcPreprocess.cc b/gcc/m2/mc-boot/GmcPreprocess.cc index 74add0c4392e1..6f7679ef3231b 100644 --- a/gcc/m2/mc-boot/GmcPreprocess.cc +++ b/gcc/m2/mc-boot/GmcPreprocess.cc @@ -24,9 +24,9 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ typedef struct { PROC_t proc; } PROC; # endif -#define _mcPreprocess_H #define _mcPreprocess_C +#include "GmcPreprocess.h" # include "GSYSTEM.h" # include "GDynamicStrings.h" # include "Glibc.h" @@ -167,7 +167,7 @@ extern "C" DynamicStrings_String mcPreprocess_preprocessModule (DynamicStrings_S __builtin_unreachable (); } -extern "C" void _M2_mcPreprocess_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcPreprocess_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { listOfFiles = alists_initList (); if (! (M2RTS_InstallTerminationProcedure ((PROC ) {(PROC_t) removeFiles}))) @@ -177,6 +177,6 @@ extern "C" void _M2_mcPreprocess_init (__attribute__((unused)) int argc,__attrib } } -extern "C" void _M2_mcPreprocess_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcPreprocess_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GmcPretty.cc b/gcc/m2/mc-boot/GmcPretty.cc index cd48032564538..10b262b89792c 100644 --- a/gcc/m2/mc-boot/GmcPretty.cc +++ b/gcc/m2/mc-boot/GmcPretty.cc @@ -38,9 +38,9 @@ Boston, MA 02110-1301, USA. */ # undef NULL # define NULL 0 #endif -#define _mcPretty_H #define _mcPretty_C +#include "GmcPretty.h" # include "GDynamicStrings.h" # include "GStorage.h" @@ -50,13 +50,7 @@ typedef struct mcPretty_writeLnProc_p mcPretty_writeLnProc; typedef struct mcPretty__T1_r mcPretty__T1; -typedef mcPretty__T1 *mcPretty_pretty; - -typedef void (*mcPretty_writeProc_t) (char); -struct mcPretty_writeProc_p { mcPretty_writeProc_t proc; }; - -typedef void (*mcPretty_writeLnProc_t) (void); -struct mcPretty_writeLnProc_p { mcPretty_writeLnProc_t proc; }; +typedef mcPretty__T1 *mcPretty_pretty__opaque; struct mcPretty__T1_r { mcPretty_writeProc write_; @@ -67,7 +61,7 @@ struct mcPretty__T1_r { unsigned int curLine; unsigned int curPos; unsigned int indent; - mcPretty_pretty stacked; + mcPretty_pretty__opaque stacked; }; @@ -162,20 +156,20 @@ extern "C" void mcPretty_raw (mcPretty_pretty p, DynamicStrings_String s); flushSpace - */ -static void flushSpace (mcPretty_pretty p); +static void flushSpace (mcPretty_pretty__opaque p); /* flushIndent - */ -static void flushIndent (mcPretty_pretty p); +static void flushIndent (mcPretty_pretty__opaque p); /* flushSpace - */ -static void flushSpace (mcPretty_pretty p) +static void flushSpace (mcPretty_pretty__opaque p) { if (p->needsSpace) { @@ -191,7 +185,7 @@ static void flushSpace (mcPretty_pretty p) flushIndent - */ -static void flushIndent (mcPretty_pretty p) +static void flushIndent (mcPretty_pretty__opaque p) { unsigned int i; @@ -215,7 +209,7 @@ static void flushIndent (mcPretty_pretty p) extern "C" mcPretty_pretty mcPretty_initPretty (mcPretty_writeProc w, mcPretty_writeLnProc l) { - mcPretty_pretty p; + mcPretty_pretty__opaque p; Storage_ALLOCATE ((void **) &p, sizeof (mcPretty__T1)); p->write_ = w; @@ -226,8 +220,8 @@ extern "C" mcPretty_pretty mcPretty_initPretty (mcPretty_writeProc w, mcPretty_w p->curLine = 0; p->seekPos = 0; p->indent = 0; - p->stacked = NULL; - return p; + p->stacked = static_cast (NULL); + return static_cast (p); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -239,11 +233,11 @@ extern "C" mcPretty_pretty mcPretty_initPretty (mcPretty_writeProc w, mcPretty_w extern "C" mcPretty_pretty mcPretty_dupPretty (mcPretty_pretty p) { - mcPretty_pretty q; + mcPretty_pretty__opaque q; Storage_ALLOCATE ((void **) &q, sizeof (mcPretty__T1)); - (*q) = (*p); - return q; + (*q) = (*static_cast (p)); + return static_cast (q); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -256,10 +250,10 @@ extern "C" mcPretty_pretty mcPretty_dupPretty (mcPretty_pretty p) extern "C" void mcPretty_killPretty (mcPretty_pretty *p) { - (*p) = NULL; - return ; + (*p) = static_cast (NULL); + return; Storage_DEALLOCATE ((void **) &(*p), sizeof (mcPretty__T1)); - (*p) = NULL; + (*p) = static_cast (NULL); } @@ -269,11 +263,11 @@ extern "C" void mcPretty_killPretty (mcPretty_pretty *p) extern "C" mcPretty_pretty mcPretty_pushPretty (mcPretty_pretty p) { - mcPretty_pretty q; + mcPretty_pretty__opaque q; - q = mcPretty_dupPretty (p); - q->stacked = p; - return q; + q = static_cast (mcPretty_dupPretty (p)); + q->stacked = static_cast (p); + return static_cast (q); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -285,16 +279,16 @@ extern "C" mcPretty_pretty mcPretty_pushPretty (mcPretty_pretty p) extern "C" mcPretty_pretty mcPretty_popPretty (mcPretty_pretty p) { - mcPretty_pretty q; - - q = p->stacked; - q->needsIndent = p->needsIndent; - q->needsSpace = p->needsSpace; - q->curPos = p->curPos; - q->seekPos = p->seekPos; - q->curLine = p->curLine; + mcPretty_pretty__opaque q; + + q = static_cast (p)->stacked; + q->needsIndent = static_cast (p)->needsIndent; + q->needsSpace = static_cast (p)->needsSpace; + q->curPos = static_cast (p)->curPos; + q->seekPos = static_cast (p)->seekPos; + q->curLine = static_cast (p)->curLine; mcPretty_killPretty (&p); - return q; + return static_cast (q); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -306,7 +300,7 @@ extern "C" mcPretty_pretty mcPretty_popPretty (mcPretty_pretty p) extern "C" unsigned int mcPretty_getindent (mcPretty_pretty p) { - return p->indent; + return static_cast (p)->indent; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -318,7 +312,7 @@ extern "C" unsigned int mcPretty_getindent (mcPretty_pretty p) extern "C" void mcPretty_setindent (mcPretty_pretty p, unsigned int n) { - p->indent = n; + static_cast (p)->indent = n; } @@ -328,13 +322,13 @@ extern "C" void mcPretty_setindent (mcPretty_pretty p, unsigned int n) extern "C" unsigned int mcPretty_getcurpos (mcPretty_pretty s) { - if (s->needsSpace) + if (static_cast (s)->needsSpace) { - return s->curPos+1; + return static_cast (s)->curPos+1; } else { - return s->curPos; + return static_cast (s)->curPos; } /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -347,7 +341,7 @@ extern "C" unsigned int mcPretty_getcurpos (mcPretty_pretty s) extern "C" unsigned int mcPretty_getseekpos (mcPretty_pretty s) { - return s->seekPos; + return static_cast (s)->seekPos; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -359,7 +353,7 @@ extern "C" unsigned int mcPretty_getseekpos (mcPretty_pretty s) extern "C" unsigned int mcPretty_getcurline (mcPretty_pretty s) { - return s->curLine; + return static_cast (s)->curLine; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -369,7 +363,7 @@ extern "C" void mcPretty_setNeedSpace (mcPretty_pretty s) /* setneedSpace - sets needSpace flag to TRUE. */ - s->needsSpace = true; + static_cast (s)->needsSpace = true; } @@ -379,7 +373,7 @@ extern "C" void mcPretty_setNeedSpace (mcPretty_pretty s) extern "C" void mcPretty_noSpace (mcPretty_pretty s) { - s->needsSpace = false; + static_cast (s)->needsSpace = false; } @@ -412,25 +406,25 @@ extern "C" void mcPretty_prints (mcPretty_pretty p, DynamicStrings_String s) l = DynamicStrings_Length (s); i = 0; - flushSpace (p); + flushSpace (static_cast (p)); while (i < l) { if ((((i+2) <= l) && ((DynamicStrings_char (s, static_cast (i))) == '\\')) && ((DynamicStrings_char (s, static_cast (i+1))) == 'n')) { - p->needsIndent = true; - p->needsSpace = false; - p->curPos = 0; - (*p->writeln.proc) (); - p->seekPos += 1; - p->curLine += 1; + static_cast (p)->needsIndent = true; + static_cast (p)->needsSpace = false; + static_cast (p)->curPos = 0; + (*static_cast (p)->writeln.proc) (); + static_cast (p)->seekPos += 1; + static_cast (p)->curLine += 1; i += 1; } else { - flushIndent (p); - (*p->write_.proc) (DynamicStrings_char (s, static_cast (i))); - p->curPos += 1; - p->seekPos += 1; + flushIndent (static_cast (p)); + (*static_cast (p)->write_.proc) (DynamicStrings_char (s, static_cast (i))); + static_cast (p)->curPos += 1; + static_cast (p)->seekPos += 1; } i += 1; } @@ -449,21 +443,21 @@ extern "C" void mcPretty_raw (mcPretty_pretty p, DynamicStrings_String s) l = DynamicStrings_Length (s); i = 0; - flushSpace (p); - flushIndent (p); + flushSpace (static_cast (p)); + flushIndent (static_cast (p)); while (i < l) { - (*p->write_.proc) (DynamicStrings_char (s, static_cast (i))); - p->curPos += 1; - p->seekPos += 1; + (*static_cast (p)->write_.proc) (DynamicStrings_char (s, static_cast (i))); + static_cast (p)->curPos += 1; + static_cast (p)->seekPos += 1; i += 1; } } -extern "C" void _M2_mcPretty_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcPretty_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_mcPretty_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcPretty_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GmcPrintf.cc b/gcc/m2/mc-boot/GmcPrintf.cc index 3fd4117c92a42..f95ee136e5fb4 100644 --- a/gcc/m2/mc-boot/GmcPrintf.cc +++ b/gcc/m2/mc-boot/GmcPrintf.cc @@ -36,9 +36,9 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ # undef NULL # define NULL 0 #endif -#define _mcPrintf_H #define _mcPrintf_C +#include "GmcPrintf.h" # include "GSFIO.h" # include "GFIO.h" # include "GDynamicStrings.h" @@ -167,7 +167,7 @@ static void cast (unsigned char *a, unsigned int _a_high, const unsigned char *b { for (i=0; i<=_a_high; i++) { - a[i] = b[i]; + const_cast(a)[i] = b[i]; } } else @@ -199,7 +199,7 @@ static bool TranslateNameToCharStar (char *a, unsigned int _a_high, unsigned int { if ((a[i+1] == 'a') && (argno == n)) { - a[i+1] = 's'; + const_cast(a)[i+1] = 's'; return true; } argno += 1; @@ -647,10 +647,10 @@ extern "C" void mcPrintf_fprintf4 (FIO_File file, const char *a_, unsigned int _ {} /* empty. */ } -extern "C" void _M2_mcPrintf_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcPrintf_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_mcPrintf_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcPrintf_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GmcQuiet.cc b/gcc/m2/mc-boot/GmcQuiet.cc index ccff3b64b5a15..b9d4e22110a88 100644 --- a/gcc/m2/mc-boot/GmcQuiet.cc +++ b/gcc/m2/mc-boot/GmcQuiet.cc @@ -24,9 +24,9 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ typedef struct { PROC_t proc; } PROC; # endif -#define _mcQuiet_H #define _mcQuiet_C +#include "GmcQuiet.h" # include "GmcOptions.h" # include "GmcPrintf.h" @@ -121,10 +121,10 @@ extern "C" void mcQuiet_qprintf4 (const char *a_, unsigned int _a_high, const un } } -extern "C" void _M2_mcQuiet_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcQuiet_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_mcQuiet_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcQuiet_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GmcReserved.cc b/gcc/m2/mc-boot/GmcReserved.cc index 9e3519b018451..af7363a0aa651 100644 --- a/gcc/m2/mc-boot/GmcReserved.cc +++ b/gcc/m2/mc-boot/GmcReserved.cc @@ -25,17 +25,15 @@ Boston, MA 02110-1301, USA. */ typedef struct { PROC_t proc; } PROC; # endif -#define _mcReserved_H #define _mcReserved_C +#include "GmcReserved.h" -typedef enum {mcReserved_eoftok, mcReserved_plustok, mcReserved_minustok, mcReserved_timestok, mcReserved_dividetok, mcReserved_becomestok, mcReserved_ambersandtok, mcReserved_periodtok, mcReserved_commatok, mcReserved_semicolontok, mcReserved_lparatok, mcReserved_rparatok, mcReserved_lsbratok, mcReserved_rsbratok, mcReserved_lcbratok, mcReserved_rcbratok, mcReserved_uparrowtok, mcReserved_singlequotetok, mcReserved_equaltok, mcReserved_hashtok, mcReserved_lesstok, mcReserved_greatertok, mcReserved_lessgreatertok, mcReserved_lessequaltok, mcReserved_greaterequaltok, mcReserved_ldirectivetok, mcReserved_rdirectivetok, mcReserved_periodperiodtok, mcReserved_colontok, mcReserved_doublequotestok, mcReserved_bartok, mcReserved_andtok, mcReserved_arraytok, mcReserved_begintok, mcReserved_bytok, mcReserved_casetok, mcReserved_consttok, mcReserved_definitiontok, mcReserved_divtok, mcReserved_dotok, mcReserved_elsetok, mcReserved_elsiftok, mcReserved_endtok, mcReserved_excepttok, mcReserved_exittok, mcReserved_exporttok, mcReserved_finallytok, mcReserved_fortok, mcReserved_fromtok, mcReserved_iftok, mcReserved_implementationtok, mcReserved_importtok, mcReserved_intok, mcReserved_looptok, mcReserved_modtok, mcReserved_moduletok, mcReserved_nottok, mcReserved_oftok, mcReserved_ortok, mcReserved_packedsettok, mcReserved_pointertok, mcReserved_proceduretok, mcReserved_qualifiedtok, mcReserved_unqualifiedtok, mcReserved_recordtok, mcReserved_remtok, mcReserved_repeattok, mcReserved_retrytok, mcReserved_returntok, mcReserved_settok, mcReserved_thentok, mcReserved_totok, mcReserved_typetok, mcReserved_untiltok, mcReserved_vartok, mcReserved_whiletok, mcReserved_withtok, mcReserved_asmtok, mcReserved_volatiletok, mcReserved_periodperiodperiodtok, mcReserved_datetok, mcReserved_linetok, mcReserved_filetok, mcReserved_attributetok, mcReserved_builtintok, mcReserved_inlinetok, mcReserved_integertok, mcReserved_identtok, mcReserved_realtok, mcReserved_stringtok, mcReserved_commenttok} mcReserved_toktype; - -extern "C" void _M2_mcReserved_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcReserved_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_mcReserved_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcReserved_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GmcSearch.cc b/gcc/m2/mc-boot/GmcSearch.cc index add9b820b33bc..7ebe597d67aef 100644 --- a/gcc/m2/mc-boot/GmcSearch.cc +++ b/gcc/m2/mc-boot/GmcSearch.cc @@ -36,9 +36,9 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ # undef NULL # define NULL 0 #endif -#define _mcSearch_H #define _mcSearch_C +#include "GmcSearch.h" # include "GSFIO.h" # include "GmcFileName.h" # include "GDynamicStrings.h" @@ -399,11 +399,11 @@ extern "C" void mcSearch_setModExtension (DynamicStrings_String ext) Mod = DynamicStrings_Dup (ext); } -extern "C" void _M2_mcSearch_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcSearch_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { Init (); } -extern "C" void _M2_mcSearch_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcSearch_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GmcStack.cc b/gcc/m2/mc-boot/GmcStack.cc index c35fef32f1126..11ff03e407fb3 100644 --- a/gcc/m2/mc-boot/GmcStack.cc +++ b/gcc/m2/mc-boot/GmcStack.cc @@ -31,16 +31,16 @@ Boston, MA 02110-1301, USA. */ # undef NULL # define NULL 0 #endif -#define _mcStack_H #define _mcStack_C +#include "GmcStack.h" # include "GStorage.h" # include "GIndexing.h" # include "GM2RTS.h" typedef struct mcStack__T1_r mcStack__T1; -typedef mcStack__T1 *mcStack_stack; +typedef mcStack__T1 *mcStack_stack__opaque; struct mcStack__T1_r { Indexing_Index list; @@ -101,12 +101,12 @@ extern "C" void * mcStack_access (mcStack_stack s, unsigned int i); extern "C" mcStack_stack mcStack_init (void) { - mcStack_stack s; + mcStack_stack__opaque s; Storage_ALLOCATE ((void **) &s, sizeof (mcStack__T1)); s->list = Indexing_InitIndex (1); s->count = 0; - return s; + return static_cast (s); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -118,9 +118,9 @@ extern "C" mcStack_stack mcStack_init (void) extern "C" void mcStack_kill (mcStack_stack *s) { - (*s)->list = Indexing_KillIndex ((*s)->list); + static_cast ((*s))->list = Indexing_KillIndex (static_cast ((*s))->list); Storage_DEALLOCATE ((void **) &(*s), sizeof (mcStack__T1)); - (*s) = NULL; + (*s) = static_cast (NULL); } @@ -131,15 +131,15 @@ extern "C" void mcStack_kill (mcStack_stack *s) extern "C" void * mcStack_push (mcStack_stack s, void * a) { - if (s->count == 0) + if (static_cast (s)->count == 0) { - Indexing_PutIndice (s->list, Indexing_LowIndice (s->list), a); + Indexing_PutIndice (static_cast (s)->list, Indexing_LowIndice (static_cast (s)->list), a); } else { - Indexing_PutIndice (s->list, (Indexing_HighIndice (s->list))+1, a); + Indexing_PutIndice (static_cast (s)->list, (Indexing_HighIndice (static_cast (s)->list))+1, a); } - s->count += 1; + static_cast (s)->count += 1; return a; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -154,16 +154,16 @@ extern "C" void * mcStack_pop (mcStack_stack s) { void * a; - if (s->count == 0) + if (static_cast (s)->count == 0) { M2RTS_HALT (-1); __builtin_unreachable (); } else { - s->count -= 1; - a = Indexing_GetIndice (s->list, Indexing_HighIndice (s->list)); - Indexing_DeleteIndice (s->list, Indexing_HighIndice (s->list)); + static_cast (s)->count -= 1; + a = Indexing_GetIndice (static_cast (s)->list, Indexing_HighIndice (static_cast (s)->list)); + Indexing_DeleteIndice (static_cast (s)->list, Indexing_HighIndice (static_cast (s)->list)); return a; } ReturnException ("../../gcc/m2/mc/mcStack.def", 20, 1); @@ -192,7 +192,7 @@ extern "C" void * mcStack_replace (mcStack_stack s, void * a) extern "C" unsigned int mcStack_depth (mcStack_stack s) { - return s->count; + return static_cast (s)->count; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -207,23 +207,23 @@ extern "C" unsigned int mcStack_depth (mcStack_stack s) extern "C" void * mcStack_access (mcStack_stack s, unsigned int i) { - if ((i > s->count) || (i == 0)) + if ((i > static_cast (s)->count) || (i == 0)) { M2RTS_HALT (-1); __builtin_unreachable (); } else { - return Indexing_GetIndice (s->list, i); + return Indexing_GetIndice (static_cast (s)->list, i); } ReturnException ("../../gcc/m2/mc/mcStack.def", 20, 1); __builtin_unreachable (); } -extern "C" void _M2_mcStack_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcStack_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_mcStack_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcStack_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GmcStream.cc b/gcc/m2/mc-boot/GmcStream.cc index baf301aff61d3..3d8d01da46501 100644 --- a/gcc/m2/mc-boot/GmcStream.cc +++ b/gcc/m2/mc-boot/GmcStream.cc @@ -42,9 +42,9 @@ along with GNU Modula-2; see the file COPYING3. If not see # undef NULL # define NULL 0 #endif -#define _mcStream_H #define _mcStream_C +#include "GmcStream.h" # include "GFIO.h" # include "Glibc.h" # include "GIndexing.h" @@ -264,13 +264,13 @@ extern "C" void mcStream_removeFiles (void) listOfFiles = alists_initList (); } -extern "C" void _M2_mcStream_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcStream_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { listOfFiles = alists_initList (); seenDest = false; frag = Indexing_InitIndex (1); } -extern "C" void _M2_mcStream_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcStream_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/Gmcp1.cc b/gcc/m2/mc-boot/Gmcp1.cc index c005fcbb7a306..b6b0f87a43af5 100644 --- a/gcc/m2/mc-boot/Gmcp1.cc +++ b/gcc/m2/mc-boot/Gmcp1.cc @@ -41,9 +41,9 @@ see . */ # undef NULL # define NULL 0 #endif -#define _mcp1_H #define _mcp1_C +#include "Gmcp1.h" # include "GDynamicStrings.h" # include "GmcError.h" # include "GnameKey.h" @@ -1831,7 +1831,8 @@ static void DefinitionModule (mcp1_SetOfStop0 stopset0, mcp1_SetOfStop1 stopset1 % n := makeType (curident) % ( ';' - % putTypeHidden (n) % + % putTypeHidden (n) ; + putTypeOpaque (n) % | '=' Type Alignment ';' ) } @@ -6955,7 +6956,8 @@ static void DefinitionModule (mcp1_SetOfStop0 stopset0, mcp1_SetOfStop1 stopset1 % n := makeType (curident) % ( ';' - % putTypeHidden (n) % + % putTypeHidden (n) ; + putTypeOpaque (n) % | '=' Type Alignment ';' ) } @@ -6976,6 +6978,7 @@ static void DefTypeDeclaration (mcp1_SetOfStop0 stopset0, mcp1_SetOfStop1 stopse { Expect (mcReserved_semicolontok, stopset0, stopset1, stopset2|(mcp1_SetOfStop2) ((1 << (mcReserved_identtok-mcReserved_recordtok)))); decl_putTypeHidden (n); + decl_putTypeOpaque (n); } else if (mcLexBuf_currenttoken == mcReserved_equaltok) { @@ -7257,10 +7260,10 @@ extern "C" bool mcp1_CompilationUnit (void) __builtin_unreachable (); } -extern "C" void _M2_mcp1_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcp1_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_mcp1_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcp1_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/Gmcp2.cc b/gcc/m2/mc-boot/Gmcp2.cc index c5f32c1395e56..f61e42220d415 100644 --- a/gcc/m2/mc-boot/Gmcp2.cc +++ b/gcc/m2/mc-boot/Gmcp2.cc @@ -41,9 +41,9 @@ see . */ # undef NULL # define NULL 0 #endif -#define _mcp2_H #define _mcp2_C +#include "Gmcp2.h" # include "GDynamicStrings.h" # include "GmcError.h" # include "GnameKey.h" @@ -7629,10 +7629,10 @@ extern "C" bool mcp2_CompilationUnit (void) __builtin_unreachable (); } -extern "C" void _M2_mcp2_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcp2_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_mcp2_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcp2_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/Gmcp3.cc b/gcc/m2/mc-boot/Gmcp3.cc index 096cdafbc64ca..e327d366b560f 100644 --- a/gcc/m2/mc-boot/Gmcp3.cc +++ b/gcc/m2/mc-boot/Gmcp3.cc @@ -41,9 +41,9 @@ see . */ # undef NULL # define NULL 0 #endif -#define _mcp3_H #define _mcp3_C +#include "Gmcp3.h" # include "GDynamicStrings.h" # include "GmcError.h" # include "GnameKey.h" @@ -7846,10 +7846,10 @@ extern "C" bool mcp3_CompilationUnit (void) __builtin_unreachable (); } -extern "C" void _M2_mcp3_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcp3_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_mcp3_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcp3_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/Gmcp4.cc b/gcc/m2/mc-boot/Gmcp4.cc index 0cfbe9b243a1b..2fdd0ae25232b 100644 --- a/gcc/m2/mc-boot/Gmcp4.cc +++ b/gcc/m2/mc-boot/Gmcp4.cc @@ -41,9 +41,9 @@ see . */ # undef NULL # define NULL 0 #endif -#define _mcp4_H #define _mcp4_C +#include "Gmcp4.h" # include "GDynamicStrings.h" # include "GmcError.h" # include "GnameKey.h" @@ -7709,10 +7709,10 @@ extern "C" bool mcp4_CompilationUnit (void) __builtin_unreachable (); } -extern "C" void _M2_mcp4_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcp4_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_mcp4_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcp4_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/Gmcp5.cc b/gcc/m2/mc-boot/Gmcp5.cc index 08de65334e8a4..d1e1fe984fa4c 100644 --- a/gcc/m2/mc-boot/Gmcp5.cc +++ b/gcc/m2/mc-boot/Gmcp5.cc @@ -41,9 +41,9 @@ see . */ # undef NULL # define NULL 0 #endif -#define _mcp5_H #define _mcp5_C +#include "Gmcp5.h" # include "GDynamicStrings.h" # include "GmcError.h" # include "GnameKey.h" @@ -5553,7 +5553,7 @@ static void SubDesignator (mcp5_SetOfStop0 stopset0, mcp5_SetOfStop1 stopset1, m { ErrorArray ((const char *) "no expression found", 19); mcError_flushErrors (); - return ; + return; } type = decl_skipType (decl_getType (n)); if (mcLexBuf_currenttoken == mcReserved_periodtok) @@ -8568,10 +8568,10 @@ extern "C" bool mcp5_CompilationUnit (void) __builtin_unreachable (); } -extern "C" void _M2_mcp5_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcp5_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_mcp5_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_mcp5_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GnameKey.cc b/gcc/m2/mc-boot/GnameKey.cc index 2b236667ea1bb..ba9eaa026c03c 100644 --- a/gcc/m2/mc-boot/GnameKey.cc +++ b/gcc/m2/mc-boot/GnameKey.cc @@ -43,9 +43,9 @@ along with GNU Modula-2; see the file COPYING3. If not see # undef NULL # define NULL 0 #endif -#define _nameKey_H #define _nameKey_C +#include "GnameKey.h" # include "GSYSTEM.h" # include "GStorage.h" # include "GIndexing.h" @@ -394,13 +394,13 @@ extern "C" void nameKey_getKey (nameKey_Name key, char *a, unsigned int _a_high) higha = _a_high; while (((p != NULL) && (i <= higha)) && ((*p) != ASCII_nul)) { - a[i] = (*p); + const_cast(a)[i] = (*p); p += 1; i += 1; } if (i <= higha) { - a[i] = ASCII_nul; + const_cast(a)[i] = ASCII_nul; } } @@ -572,7 +572,7 @@ extern "C" void * nameKey_keyToCharStar (nameKey_Name key) __builtin_unreachable (); } -extern "C" void _M2_nameKey_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_nameKey_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { lastIndice = 0; keyIndex = Indexing_InitIndex (1); @@ -580,6 +580,6 @@ extern "C" void _M2_nameKey_init (__attribute__((unused)) int argc,__attribute__ binaryTree->left = NULL; } -extern "C" void _M2_nameKey_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_nameKey_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/GsymbolKey.cc b/gcc/m2/mc-boot/GsymbolKey.cc index 8a396ef1bac03..17072597304b2 100644 --- a/gcc/m2/mc-boot/GsymbolKey.cc +++ b/gcc/m2/mc-boot/GsymbolKey.cc @@ -38,9 +38,9 @@ along with GNU Modula-2; see the file COPYING3. If not see # undef NULL # define NULL 0 #endif -#define _symbolKey_H #define _symbolKey_C +#include "GsymbolKey.h" # include "GStorage.h" # include "GStrIO.h" # include "GNumberIO.h" @@ -54,19 +54,13 @@ typedef struct symbolKey_performOperation_p symbolKey_performOperation; typedef struct symbolKey__T1_r symbolKey__T1; -typedef symbolKey__T1 *symbolKey_symbolTree; - -typedef bool (*symbolKey_isSymbol_t) (void *); -struct symbolKey_isSymbol_p { symbolKey_isSymbol_t proc; }; - -typedef void (*symbolKey_performOperation_t) (void *); -struct symbolKey_performOperation_p { symbolKey_performOperation_t proc; }; +typedef symbolKey__T1 *symbolKey_symbolTree__opaque; struct symbolKey__T1_r { nameKey_Name name; - void *key; - symbolKey_symbolTree left; - symbolKey_symbolTree right; + void * key; + symbolKey_symbolTree__opaque left; + symbolKey_symbolTree__opaque right; }; extern "C" symbolKey_symbolTree symbolKey_initTree (void); @@ -113,7 +107,7 @@ extern "C" void symbolKey_foreachNodeDo (symbolKey_symbolTree t, symbolKey_perfo if an entry is found, father is set to the node above child. */ -static void findNodeAndParentInTree (symbolKey_symbolTree t, nameKey_Name n, symbolKey_symbolTree *child, symbolKey_symbolTree *father); +static void findNodeAndParentInTree (symbolKey_symbolTree__opaque t, nameKey_Name n, symbolKey_symbolTree__opaque *child, symbolKey_symbolTree__opaque *father); /* searchForAny - performs the search required for doesTreeContainAny. @@ -121,7 +115,7 @@ static void findNodeAndParentInTree (symbolKey_symbolTree t, nameKey_Name n, sym therefore we must skip over it. */ -static bool searchForAny (symbolKey_symbolTree t, symbolKey_isSymbol p); +static bool searchForAny (symbolKey_symbolTree__opaque t, symbolKey_isSymbol p); /* searchAndDo - searches all the nodes in symbolTree, t, and @@ -129,7 +123,7 @@ static bool searchForAny (symbolKey_symbolTree t, symbolKey_isSymbol p); It traverse the tree in order. */ -static void searchAndDo (symbolKey_symbolTree t, symbolKey_performOperation p); +static void searchAndDo (symbolKey_symbolTree__opaque t, symbolKey_performOperation p); /* @@ -137,7 +131,7 @@ static void searchAndDo (symbolKey_symbolTree t, symbolKey_performOperation p); if an entry is found, father is set to the node above child. */ -static void findNodeAndParentInTree (symbolKey_symbolTree t, nameKey_Name n, symbolKey_symbolTree *child, symbolKey_symbolTree *father) +static void findNodeAndParentInTree (symbolKey_symbolTree__opaque t, nameKey_Name n, symbolKey_symbolTree__opaque *child, symbolKey_symbolTree__opaque *father) { /* remember to skip the sentinal value and assign father and child */ (*father) = t; @@ -171,7 +165,7 @@ static void findNodeAndParentInTree (symbolKey_symbolTree t, nameKey_Name n, sym therefore we must skip over it. */ -static bool searchForAny (symbolKey_symbolTree t, symbolKey_isSymbol p) +static bool searchForAny (symbolKey_symbolTree__opaque t, symbolKey_isSymbol p) { if (t == NULL) { @@ -192,7 +186,7 @@ static bool searchForAny (symbolKey_symbolTree t, symbolKey_isSymbol p) It traverse the tree in order. */ -static void searchAndDo (symbolKey_symbolTree t, symbolKey_performOperation p) +static void searchAndDo (symbolKey_symbolTree__opaque t, symbolKey_performOperation p) { if (t != NULL) { @@ -204,12 +198,12 @@ static void searchAndDo (symbolKey_symbolTree t, symbolKey_performOperation p) extern "C" symbolKey_symbolTree symbolKey_initTree (void) { - symbolKey_symbolTree t; + symbolKey_symbolTree__opaque t; Storage_ALLOCATE ((void **) &t, sizeof (symbolKey__T1)); /* The value entity */ - t->left = NULL; - t->right = NULL; - return t; + t->left = static_cast (NULL); + t->right = static_cast (NULL); + return static_cast (t); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -218,17 +212,17 @@ extern "C" void symbolKey_killTree (symbolKey_symbolTree *t) { if ((*t) != NULL) { - symbolKey_killTree (&(*t)->left); - symbolKey_killTree (&(*t)->right); + symbolKey_killTree (reinterpret_cast (&static_cast ((*t))->left)); + symbolKey_killTree (reinterpret_cast (&static_cast ((*t))->right)); Storage_DEALLOCATE ((void **) &(*t), sizeof (symbolKey__T1)); - (*t) = NULL; + (*t) = static_cast (NULL); } } extern "C" void * symbolKey_getSymKey (symbolKey_symbolTree t, nameKey_Name name) { - symbolKey_symbolTree father; - symbolKey_symbolTree child; + symbolKey_symbolTree__opaque father; + symbolKey_symbolTree__opaque child; if (t == NULL) { @@ -236,7 +230,7 @@ extern "C" void * symbolKey_getSymKey (symbolKey_symbolTree t, nameKey_Name name } else { - findNodeAndParentInTree (t, name, &child, &father); + findNodeAndParentInTree (static_cast (t), name, &child, &father); if (child == NULL) { return symbolKey_NulKey; @@ -252,10 +246,10 @@ extern "C" void * symbolKey_getSymKey (symbolKey_symbolTree t, nameKey_Name name extern "C" void symbolKey_putSymKey (symbolKey_symbolTree t, nameKey_Name name, void * key) { - symbolKey_symbolTree father; - symbolKey_symbolTree child; + symbolKey_symbolTree__opaque father; + symbolKey_symbolTree__opaque child; - findNodeAndParentInTree (t, name, &child, &father); + findNodeAndParentInTree (static_cast (t), name, &child, &father); if (child == NULL) { /* no child found, now is name less than father or greater? */ @@ -279,8 +273,8 @@ extern "C" void symbolKey_putSymKey (symbolKey_symbolTree t, nameKey_Name name, father->right = child; } } - child->right = NULL; - child->left = NULL; + child->right = static_cast (NULL); + child->left = static_cast (NULL); child->key = key; child->name = name; } @@ -300,11 +294,11 @@ extern "C" void symbolKey_putSymKey (symbolKey_symbolTree t, nameKey_Name name, extern "C" void symbolKey_delSymKey (symbolKey_symbolTree t, nameKey_Name name) { - symbolKey_symbolTree i; - symbolKey_symbolTree child; - symbolKey_symbolTree father; + symbolKey_symbolTree__opaque i; + symbolKey_symbolTree__opaque child; + symbolKey_symbolTree__opaque father; - findNodeAndParentInTree (t, name, &child, &father); /* find father and child of the node */ + findNodeAndParentInTree (static_cast (t), name, &child, &father); /* find father and child of the node */ if ((child != NULL) && (child->name == name)) { /* Have found the node to be deleted */ @@ -364,7 +358,7 @@ extern "C" void symbolKey_delSymKey (symbolKey_symbolTree t, nameKey_Name name) extern "C" bool symbolKey_isEmptyTree (symbolKey_symbolTree t) { - return t->left == NULL; + return static_cast (t)->left == NULL; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -380,7 +374,7 @@ extern "C" bool symbolKey_isEmptyTree (symbolKey_symbolTree t) extern "C" bool symbolKey_doesTreeContainAny (symbolKey_symbolTree t, symbolKey_isSymbol p) { - return searchForAny (t->left, p); + return searchForAny (static_cast (t)->left, p); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -395,13 +389,13 @@ extern "C" bool symbolKey_doesTreeContainAny (symbolKey_symbolTree t, symbolKey_ extern "C" void symbolKey_foreachNodeDo (symbolKey_symbolTree t, symbolKey_performOperation p) { - searchAndDo (t->left, p); + searchAndDo (static_cast (t)->left, p); } -extern "C" void _M2_symbolKey_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_symbolKey_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_symbolKey_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_symbolKey_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/Gvarargs.cc b/gcc/m2/mc-boot/Gvarargs.cc index 23bd7cd1644bd..5c8abd9940b85 100644 --- a/gcc/m2/mc-boot/Gvarargs.cc +++ b/gcc/m2/mc-boot/Gvarargs.cc @@ -34,9 +34,9 @@ along with GNU Modula-2; see the file COPYING3. If not see # undef NULL # define NULL 0 #endif -#define _varargs_H #define _varargs_C +#include "Gvarargs.h" # include "GStorage.h" # include "Glibc.h" # include "GSYSTEM.h" @@ -51,10 +51,10 @@ typedef unsigned char *varargs_ptrToByte; typedef struct varargs__T7_a varargs__T7; -typedef varargs__T6 *varargs_vararg; +typedef varargs__T6 *varargs_vararg__opaque; struct varargs_argDesc_r { - void *ptr; + void * ptr; unsigned int len; }; @@ -62,7 +62,7 @@ struct varargs__T7_a { varargs_argDesc array[MaxArg+1]; }; struct varargs__T6_r { unsigned int nArgs; unsigned int i; - void *contents; + void * contents; unsigned int size; varargs__T7 arg; }; @@ -138,7 +138,7 @@ extern "C" varargs_vararg varargs_start4 (const unsigned char *a_, unsigned int extern "C" unsigned int varargs_nargs (varargs_vararg v) { - return v->nArgs; + return static_cast (v)->nArgs; /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -156,20 +156,20 @@ extern "C" void varargs_arg (varargs_vararg v, unsigned char *a, unsigned int _a arg__T1 p; unsigned int j; - if (v->i == v->nArgs) + if (static_cast (v)->i == static_cast (v)->nArgs) { M2RTS_HALT (-1); /* too many calls to arg. */ __builtin_unreachable (); } else { - if ((_a_high+1) == v->arg.array[v->i].len) + if ((_a_high+1) == static_cast (v)->arg.array[static_cast (v)->i].len) { - p = static_cast (v->arg.array[v->i].ptr); + p = static_cast (static_cast (v)->arg.array[static_cast (v)->i].ptr); j = 0; while (j <= _a_high) { - a[j] = (*p); + const_cast(a)[j] = (*p); p += 1; j += 1; } @@ -179,7 +179,7 @@ extern "C" void varargs_arg (varargs_vararg v, unsigned char *a, unsigned int _a M2RTS_HALT (-1); /* parameter mismatch. */ __builtin_unreachable (); } - v->i += 1; + static_cast (v)->i += 1; } } @@ -190,7 +190,7 @@ extern "C" void varargs_arg (varargs_vararg v, unsigned char *a, unsigned int _a extern "C" void varargs_next (varargs_vararg v, unsigned int i) { - v->i = i; + static_cast (v)->i = i; } @@ -200,24 +200,24 @@ extern "C" void varargs_next (varargs_vararg v, unsigned int i) extern "C" varargs_vararg varargs_copy (varargs_vararg v) { - varargs_vararg c; + varargs_vararg__opaque c; unsigned int j; unsigned int offset; Storage_ALLOCATE ((void **) &c, sizeof (varargs__T6)); - c->i = v->i; - c->nArgs = v->nArgs; - c->size = v->size; + c->i = static_cast (v)->i; + c->nArgs = static_cast (v)->nArgs; + c->size = static_cast (v)->size; Storage_ALLOCATE (&c->contents, c->size); - c->contents = libc_memcpy (c->contents, v->contents, static_cast (c->size)); + c->contents = libc_memcpy (c->contents, static_cast (v)->contents, static_cast (c->size)); for (j=0; j<=c->nArgs; j++) { - offset = (unsigned int ) (((varargs_ptrToByte) (v->contents))-((varargs_ptrToByte) (v->arg.array[j].ptr))); - c->arg.array[j].ptr = reinterpret_cast ((varargs_ptrToByte) (c->contents)); + offset = (unsigned int ) (((varargs_ptrToByte) (static_cast (v)->contents))-((varargs_ptrToByte) (static_cast (v)->arg.array[j].ptr))); + c->arg.array[j].ptr = static_cast ((varargs_ptrToByte) (c->contents)); c->arg.array[j].ptr = reinterpret_cast (reinterpret_cast (c->arg.array[j].ptr)+offset); - c->arg.array[j].len = v->arg.array[j].len; + c->arg.array[j].len = static_cast (v)->arg.array[j].len; } - return c; + return static_cast (c); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -236,16 +236,16 @@ extern "C" void varargs_replace (varargs_vararg v, unsigned char *a, unsigned in replace__T2 p; unsigned int j; - if (v->i == v->nArgs) + if (static_cast (v)->i == static_cast (v)->nArgs) { M2RTS_HALT (-1); /* too many calls to arg. */ __builtin_unreachable (); } else { - if ((_a_high+1) == v->arg.array[v->i].len) + if ((_a_high+1) == static_cast (v)->arg.array[static_cast (v)->i].len) { - p = static_cast (v->arg.array[v->i].ptr); + p = static_cast (static_cast (v)->arg.array[static_cast (v)->i].ptr); j = 0; while (j <= _a_high) { @@ -271,7 +271,7 @@ extern "C" void varargs_end (varargs_vararg *v) { if ((*v) != NULL) { - Storage_DEALLOCATE (&(*v)->contents, sizeof (varargs_vararg)); + Storage_DEALLOCATE (&static_cast ((*v))->contents, sizeof (varargs_vararg)); Storage_DEALLOCATE ((void **) &(*v), sizeof (varargs__T6)); } } @@ -283,7 +283,7 @@ extern "C" void varargs_end (varargs_vararg *v) extern "C" varargs_vararg varargs_start1 (const unsigned char *a_, unsigned int _a_high) { - varargs_vararg v; + varargs_vararg__opaque v; unsigned char a[_a_high+1]; /* make a local copy of each unbounded array. */ @@ -294,10 +294,10 @@ extern "C" varargs_vararg varargs_start1 (const unsigned char *a_, unsigned int v->nArgs = 1; v->size = _a_high+1; Storage_ALLOCATE (&v->contents, v->size); - v->contents = libc_memcpy (v->contents, &a, static_cast (v->size)); + v->contents = libc_memcpy (v->contents, const_cast (static_cast(a)), static_cast (v->size)); v->arg.array[0].ptr = v->contents; v->arg.array[0].len = v->size; - return v; + return static_cast (v); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -311,7 +311,7 @@ extern "C" varargs_vararg varargs_start2 (const unsigned char *a_, unsigned int { typedef unsigned char *start2__T3; - varargs_vararg v; + varargs_vararg__opaque v; start2__T3 p; unsigned char a[_a_high+1]; unsigned char b[_b_high+1]; @@ -325,14 +325,14 @@ extern "C" varargs_vararg varargs_start2 (const unsigned char *a_, unsigned int v->nArgs = 2; v->size = (_a_high+_b_high)+2; Storage_ALLOCATE (&v->contents, v->size); - p = static_cast (libc_memcpy (v->contents, &a, static_cast (_a_high+1))); - v->arg.array[0].ptr = reinterpret_cast (p); + p = static_cast (libc_memcpy (v->contents, const_cast (static_cast(a)), static_cast (_a_high+1))); + v->arg.array[0].ptr = static_cast (p); v->arg.array[0].len = _a_high+1; p += v->arg.array[0].len; - p = static_cast (libc_memcpy (reinterpret_cast (p), &b, static_cast (_b_high+1))); - v->arg.array[1].ptr = reinterpret_cast (p); + p = static_cast (libc_memcpy (reinterpret_cast (p), const_cast (static_cast(b)), static_cast (_b_high+1))); + v->arg.array[1].ptr = static_cast (p); v->arg.array[1].len = _b_high+1; - return v; + return static_cast (v); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -346,7 +346,7 @@ extern "C" varargs_vararg varargs_start3 (const unsigned char *a_, unsigned int { typedef unsigned char *start3__T4; - varargs_vararg v; + varargs_vararg__opaque v; start3__T4 p; unsigned char a[_a_high+1]; unsigned char b[_b_high+1]; @@ -362,18 +362,18 @@ extern "C" varargs_vararg varargs_start3 (const unsigned char *a_, unsigned int v->nArgs = 3; v->size = ((_a_high+_b_high)+_c_high)+3; Storage_ALLOCATE (&v->contents, v->size); - p = static_cast (libc_memcpy (v->contents, &a, static_cast (_a_high+1))); - v->arg.array[0].ptr = reinterpret_cast (p); + p = static_cast (libc_memcpy (v->contents, const_cast (static_cast(a)), static_cast (_a_high+1))); + v->arg.array[0].ptr = static_cast (p); v->arg.array[0].len = _a_high+1; p += v->arg.array[0].len; - p = static_cast (libc_memcpy (reinterpret_cast (p), &b, static_cast (_b_high+1))); - v->arg.array[1].ptr = reinterpret_cast (p); + p = static_cast (libc_memcpy (reinterpret_cast (p), const_cast (static_cast(b)), static_cast (_b_high+1))); + v->arg.array[1].ptr = static_cast (p); v->arg.array[1].len = _b_high+1; p += v->arg.array[1].len; - p = static_cast (libc_memcpy (reinterpret_cast (p), &c, static_cast (_c_high+1))); - v->arg.array[2].ptr = reinterpret_cast (p); + p = static_cast (libc_memcpy (reinterpret_cast (p), const_cast (static_cast(c)), static_cast (_c_high+1))); + v->arg.array[2].ptr = static_cast (p); v->arg.array[2].len = _c_high+1; - return v; + return static_cast (v); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -387,7 +387,7 @@ extern "C" varargs_vararg varargs_start4 (const unsigned char *a_, unsigned int { typedef unsigned char *start4__T5; - varargs_vararg v; + varargs_vararg__opaque v; start4__T5 p; unsigned char a[_a_high+1]; unsigned char b[_b_high+1]; @@ -405,29 +405,29 @@ extern "C" varargs_vararg varargs_start4 (const unsigned char *a_, unsigned int v->nArgs = 4; v->size = (((_a_high+_b_high)+_c_high)+_d_high)+4; Storage_ALLOCATE (&v->contents, v->size); - p = static_cast (libc_memcpy (v->contents, &a, static_cast (_a_high+1))); + p = static_cast (libc_memcpy (v->contents, const_cast (static_cast(a)), static_cast (_a_high+1))); v->arg.array[0].len = _a_high+1; p += v->arg.array[0].len; - p = static_cast (libc_memcpy (reinterpret_cast (p), &b, static_cast (_b_high+1))); - v->arg.array[1].ptr = reinterpret_cast (p); + p = static_cast (libc_memcpy (reinterpret_cast (p), const_cast (static_cast(b)), static_cast (_b_high+1))); + v->arg.array[1].ptr = static_cast (p); v->arg.array[1].len = _b_high+1; p += v->arg.array[1].len; - p = static_cast (libc_memcpy (reinterpret_cast (p), &c, static_cast (_c_high+1))); - v->arg.array[2].ptr = reinterpret_cast (p); + p = static_cast (libc_memcpy (reinterpret_cast (p), const_cast (static_cast(c)), static_cast (_c_high+1))); + v->arg.array[2].ptr = static_cast (p); v->arg.array[2].len = _c_high+1; p += v->arg.array[2].len; - p = static_cast (libc_memcpy (reinterpret_cast (p), &c, static_cast (_c_high+1))); - v->arg.array[3].ptr = reinterpret_cast (p); + p = static_cast (libc_memcpy (reinterpret_cast (p), const_cast (static_cast(c)), static_cast (_c_high+1))); + v->arg.array[3].ptr = static_cast (p); v->arg.array[3].len = _c_high+1; - return v; + return static_cast (v); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } -extern "C" void _M2_varargs_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_varargs_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_varargs_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_varargs_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc-boot/Gwlists.cc b/gcc/m2/mc-boot/Gwlists.cc index fa3f73ac212ff..87daa42c3efd5 100644 --- a/gcc/m2/mc-boot/Gwlists.cc +++ b/gcc/m2/mc-boot/Gwlists.cc @@ -42,9 +42,9 @@ along with GNU Modula-2; see the file COPYING3. If not see # undef NULL # define NULL 0 #endif -#define _wlists_H #define _wlists_C +#include "Gwlists.h" # include "GStorage.h" typedef struct wlists_performOperation_p wlists_performOperation; @@ -54,16 +54,13 @@ typedef struct wlists__T1_r wlists__T1; typedef struct wlists__T2_a wlists__T2; -typedef wlists__T1 *wlists_wlist; - -typedef void (*wlists_performOperation_t) (unsigned int); -struct wlists_performOperation_p { wlists_performOperation_t proc; }; +typedef wlists__T1 *wlists_wlist__opaque; struct wlists__T2_a { unsigned int array[maxNoOfElements-1+1]; }; struct wlists__T1_r { unsigned int noOfElements; wlists__T2 elements; - wlists_wlist next; + wlists_wlist__opaque next; }; @@ -149,14 +146,14 @@ extern "C" wlists_wlist wlists_duplicateList (wlists_wlist l); removeItem - remove an element at index, i, from the wlist data type. */ -static void removeItem (wlists_wlist p, wlists_wlist l, unsigned int i); +static void removeItem (wlists_wlist__opaque p, wlists_wlist__opaque l, unsigned int i); /* removeItem - remove an element at index, i, from the wlist data type. */ -static void removeItem (wlists_wlist p, wlists_wlist l, unsigned int i) +static void removeItem (wlists_wlist__opaque p, wlists_wlist__opaque l, unsigned int i) { l->noOfElements -= 1; while (i <= l->noOfElements) @@ -178,12 +175,12 @@ static void removeItem (wlists_wlist p, wlists_wlist l, unsigned int i) extern "C" wlists_wlist wlists_initList (void) { - wlists_wlist l; + wlists_wlist__opaque l; Storage_ALLOCATE ((void **) &l, sizeof (wlists__T1)); l->noOfElements = 0; - l->next = NULL; - return l; + l->next = static_cast (NULL); + return static_cast (l); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } @@ -197,9 +194,9 @@ extern "C" void wlists_killList (wlists_wlist *l) { if ((*l) != NULL) { - if ((*l)->next != NULL) + if (static_cast ((*l))->next != NULL) { - wlists_killList (&(*l)->next); + wlists_killList (reinterpret_cast (&static_cast ((*l))->next)); } Storage_DEALLOCATE ((void **) &(*l), sizeof (wlists__T1)); } @@ -212,21 +209,21 @@ extern "C" void wlists_killList (wlists_wlist *l) extern "C" void wlists_putItemIntoList (wlists_wlist l, unsigned int c) { - if (l->noOfElements < maxNoOfElements) + if (static_cast (l)->noOfElements < maxNoOfElements) { - l->noOfElements += 1; - l->elements.array[l->noOfElements-1] = c; + static_cast (l)->noOfElements += 1; + static_cast (l)->elements.array[static_cast (l)->noOfElements-1] = c; } - else if (l->next != NULL) + else if (static_cast (l)->next != NULL) { /* avoid dangling else. */ - wlists_putItemIntoList (l->next, c); + wlists_putItemIntoList (static_cast (static_cast (l)->next), c); } else { /* avoid dangling else. */ - l->next = wlists_initList (); - wlists_putItemIntoList (l->next, c); + static_cast (l)->next = static_cast (wlists_initList ()); + wlists_putItemIntoList (static_cast (static_cast (l)->next), c); } } @@ -239,15 +236,15 @@ extern "C" unsigned int wlists_getItemFromList (wlists_wlist l, unsigned int n) { while (l != NULL) { - if (n <= l->noOfElements) + if (n <= static_cast (l)->noOfElements) { - return l->elements.array[n-1]; + return static_cast (l)->elements.array[n-1]; } else { - n -= l->noOfElements; + n -= static_cast (l)->noOfElements; } - l = l->next; + l = static_cast (static_cast (l)->next); } return static_cast (0); /* static analysis guarentees a RETURN statement will be used before here. */ @@ -272,9 +269,9 @@ extern "C" unsigned int wlists_getIndexOfList (wlists_wlist l, unsigned int c) else { i = 1; - while (i <= l->noOfElements) + while (i <= static_cast (l)->noOfElements) { - if (l->elements.array[i-1] == c) + if (static_cast (l)->elements.array[i-1] == c) { return i; } @@ -283,7 +280,7 @@ extern "C" unsigned int wlists_getIndexOfList (wlists_wlist l, unsigned int c) i += 1; } } - return l->noOfElements+(wlists_getIndexOfList (l->next, c)); + return static_cast (l)->noOfElements+(wlists_getIndexOfList (static_cast (static_cast (l)->next), c)); } /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); @@ -306,8 +303,8 @@ extern "C" unsigned int wlists_noOfItemsInList (wlists_wlist l) { t = 0; do { - t += l->noOfElements; - l = l->next; + t += static_cast (l)->noOfElements; + l = static_cast (static_cast (l)->next); } while (! (l == NULL)); return t; } @@ -337,33 +334,33 @@ extern "C" void wlists_includeItemIntoList (wlists_wlist l, unsigned int c) extern "C" void wlists_removeItemFromList (wlists_wlist l, unsigned int c) { - wlists_wlist p; + wlists_wlist__opaque p; unsigned int i; bool found; if (l != NULL) { found = false; - p = NULL; + p = static_cast (NULL); do { i = 1; - while ((i <= l->noOfElements) && (l->elements.array[i-1] != c)) + while ((i <= static_cast (l)->noOfElements) && (static_cast (l)->elements.array[i-1] != c)) { i += 1; } - if ((i <= l->noOfElements) && (l->elements.array[i-1] == c)) + if ((i <= static_cast (l)->noOfElements) && (static_cast (l)->elements.array[i-1] == c)) { found = true; } else { - p = l; - l = l->next; + p = static_cast (l); + l = static_cast (static_cast (l)->next); } } while (! ((l == NULL) || found)); if (found) { - removeItem (p, l, i); + removeItem (p, static_cast (l), i); } } } @@ -379,15 +376,15 @@ extern "C" void wlists_replaceItemInList (wlists_wlist l, unsigned int n, unsign { while (l != NULL) { - if (n <= l->noOfElements) + if (n <= static_cast (l)->noOfElements) { - l->elements.array[n-1] = w; + static_cast (l)->elements.array[n-1] = w; } else { - n -= l->noOfElements; + n -= static_cast (l)->noOfElements; } - l = l->next; + l = static_cast (static_cast (l)->next); } } @@ -402,9 +399,9 @@ extern "C" bool wlists_isItemInList (wlists_wlist l, unsigned int c) do { i = 1; - while (i <= l->noOfElements) + while (i <= static_cast (l)->noOfElements) { - if (l->elements.array[i-1] == c) + if (static_cast (l)->elements.array[i-1] == c) { return true; } @@ -413,7 +410,7 @@ extern "C" bool wlists_isItemInList (wlists_wlist l, unsigned int c) i += 1; } } - l = l->next; + l = static_cast (static_cast (l)->next); } while (! (l == NULL)); return false; /* static analysis guarentees a RETURN statement will be used before here. */ @@ -446,27 +443,27 @@ extern "C" void wlists_foreachItemInListDo (wlists_wlist l, wlists_performOperat extern "C" wlists_wlist wlists_duplicateList (wlists_wlist l) { - wlists_wlist m; + wlists_wlist__opaque m; unsigned int n; unsigned int i; - m = wlists_initList (); + m = static_cast (wlists_initList ()); n = wlists_noOfItemsInList (l); i = 1; while (i <= n) { - wlists_putItemIntoList (m, wlists_getItemFromList (l, i)); + wlists_putItemIntoList (static_cast (m), wlists_getItemFromList (l, i)); i += 1; } - return m; + return static_cast (m); /* static analysis guarentees a RETURN statement will be used before here. */ __builtin_unreachable (); } -extern "C" void _M2_wlists_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_wlists_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } -extern "C" void _M2_wlists_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) +extern "C" void _M2_wlists_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[]) { } diff --git a/gcc/m2/mc/decl.def b/gcc/m2/mc/decl.def index 0cd8d7151f75e..8f12f010850c3 100644 --- a/gcc/m2/mc/decl.def +++ b/gcc/m2/mc/decl.def @@ -249,6 +249,21 @@ PROCEDURE isTypeHidden (n: node) : BOOLEAN ; PROCEDURE hasHidden (n: node) : BOOLEAN ; +(* + putTypeOpaque - marks type, des, as being an opaque type. + TYPE des ; +*) + +PROCEDURE putTypeOpaque (des: node) ; + + +(* + isTypeOpaque - returns TRUE if type, n, is an opaque type. +*) + +PROCEDURE isTypeOpaque (n: node) : BOOLEAN ; + + (* isVar - returns TRUE if node, n, is a type. *) diff --git a/gcc/m2/mc/decl.mod b/gcc/m2/mc/decl.mod index c3ee646caaf30..37fc3962695a7 100644 --- a/gcc/m2/mc/decl.mod +++ b/gcc/m2/mc/decl.mod @@ -81,6 +81,7 @@ CONST enableDefForCStrings = FALSE ; (* currently disabled. *) enableMemsetOnAllocation = TRUE ; (* Should we memset (..., 0, ...) the allocated mem? *) forceQualified = TRUE ; + debugOpaque = FALSE ; TYPE language = (ansiC, ansiCP, pim4) ; @@ -127,7 +128,7 @@ TYPE componentref, pointerref, arrayref, deref, equal, notequal, less, greater, greequal, lessequal, lsl, lsr, lor, land, lnot, lxor, - and, or, not, identlist, vardecl, setvalue) ; + and, or, not, identlist, vardecl, setvalue, opaquecast) ; node = POINTER TO nodeRec ; @@ -260,12 +261,24 @@ TYPE identlist : identlistF : identlistT | vardecl : vardeclF : vardeclT | funccall : funccallF : funccallT | - setvalue : setvalueF : setvalueT + setvalue : setvalueF : setvalueT | + opaquecast : opaquecastF : opaquecastT END ; at: where ; END ; + opaqueCastState = RECORD + opaque, + voidStar: BOOLEAN ; + END ; + + opaquecastT = RECORD + (* Describes the cast of the opaque. *) + exp : node ; + opaqueState: opaqueCastState ; + END ; + intrinsicT = RECORD args : node ; noArgs : CARDINAL ; @@ -298,6 +311,7 @@ TYPE args : node ; type : node ; funccallComment: commentPair ; + opaqueState : opaqueCastState ; END ; commentT = RECORD @@ -328,6 +342,7 @@ TYPE name : Name ; type : node ; scope : node ; + isOpaque, isHidden, isInternal: BOOLEAN ; END ; @@ -355,6 +370,7 @@ TYPE isVarParameter, isUsed : BOOLEAN ; cname : cnameT ; + opaqueState : opaqueCastState ; END ; enumerationT = RECORD @@ -382,6 +398,7 @@ TYPE type, scope : node ; isUnbounded: BOOLEAN ; + opaqueState: opaqueCastState ; END ; stringT = RECORD @@ -412,6 +429,7 @@ TYPE isUnbounded: BOOLEAN ; isForC : BOOLEAN ; isUsed : BOOLEAN ; + opaqueState: opaqueCastState ; END ; paramT = RECORD @@ -421,6 +439,7 @@ TYPE isUnbounded: BOOLEAN ; isForC : BOOLEAN ; isUsed : BOOLEAN ; + opaqueState: opaqueCastState ; END ; varargsT = RECORD @@ -435,18 +454,20 @@ TYPE END ; pointerT = RECORD - type : node ; - scope: node ; + type : node ; + scope : node ; + opaqueState: opaqueCastState ; END ; recordfieldT = RECORD - name : Name ; - type : node ; - tag : BOOLEAN ; - parent : node ; - varient: node ; - scope : node ; - cname : cnameT ; + name : Name ; + type : node ; + tag : BOOLEAN ; + parent : node ; + varient : node ; + scope : node ; + cname : cnameT ; + opaqueState: opaqueCastState ; END ; varientfieldT = RECORD @@ -472,21 +493,24 @@ TYPE END ; componentrefT = RECORD - rec : node ; - field : node ; - resultType: node ; + rec : node ; + field : node ; + resultType : node ; + opaqueState: opaqueCastState ; END ; pointerrefT = RECORD - ptr : node ; - field : node ; - resultType: node ; + ptr : node ; + field : node ; + resultType : node ; + opaqueState: opaqueCastState ; END ; arrayrefT = RECORD - array : node ; - index : node ; - resultType: node ; + array : node ; + index : node ; + resultType : node ; + opaqueState: opaqueCastState ; END ; commentPair = RECORD @@ -596,15 +620,17 @@ TYPE cname : cnameT ; defComment, modComment : commentDesc ; + opaqueState : opaqueCastState ; END ; proctypeT = RECORD - parameters: Index ; + parameters : Index ; returnopt, - vararg : BOOLEAN ; - optarg : node ; - scope : node ; - returnType: node ; + vararg : BOOLEAN ; + optarg : node ; + scope : node ; + returnType : node ; + opaqueState: opaqueCastState ; END ; binaryT = RECORD @@ -2025,6 +2051,7 @@ BEGIN typeF.name := n ; typeF.type := NIL ; typeF.scope := getDeclScope () ; + typeF.isOpaque := FALSE ; typeF.isHidden := FALSE ; typeF.isInternal := FALSE END ; @@ -2052,6 +2079,7 @@ BEGIN typeF.name := n ; typeF.type := NIL ; typeF.scope := getDeclScope () ; + typeF.isOpaque := FALSE ; typeF.isHidden := FALSE END ; RETURN addToScope (d) @@ -2091,7 +2119,8 @@ BEGIN assert (var#NIL) ; assert (isVar (var)) ; var^.varF.type := type ; - var^.varF.decl := decl + var^.varF.decl := decl ; + initNodeOpaqueState (var) ; END putVar ; @@ -2328,7 +2357,7 @@ END paramLeave ; (* - putReturnType - sets the return type of procedure or proctype, proc, to, type. + putReturnType - sets the return type of procedure or proctype proc to type. *) PROCEDURE putReturnType (proc, type: node) ; @@ -2339,7 +2368,8 @@ BEGIN proc^.procedureF.returnType := type ELSE proc^.proctypeF.returnType := type - END + END ; + initNodeOpaqueState (proc) END putReturnType ; @@ -2374,8 +2404,9 @@ BEGIN proctypeF.returnopt := FALSE ; proctypeF.optarg := NIL ; proctypeF.vararg := FALSE ; - proctypeF.returnType := NIL + proctypeF.returnType := NIL ; END ; + initNodeOpaqueState (d) ; RETURN d END makeProcType ; @@ -2387,7 +2418,8 @@ END makeProcType ; PROCEDURE putProcTypeReturn (proc, type: node) ; BEGIN assert (isProcType (proc)) ; - proc^.proctypeF.returnType := type + proc^.proctypeF.returnType := type ; + initNodeOpaqueState (proc) END putProcTypeReturn ; @@ -2418,6 +2450,7 @@ BEGIN d^.paramF.isUnbounded := FALSE ; d^.paramF.isForC := isDefForCNode (proc) ; d^.paramF.isUsed := isused ; + initNodeOpaqueState (d) ; RETURN d END makeNonVarParameter ; @@ -2438,6 +2471,7 @@ BEGIN d^.varparamF.isUnbounded := FALSE ; d^.varparamF.isForC := isDefForCNode (proc) ; d^.varparamF.isUsed := isused ; + initNodeOpaqueState (d) ; RETURN d END makeVarParameter ; @@ -3864,8 +3898,9 @@ BEGIN f := newNode (funccall) ; f^.funccallF.function := c ; f^.funccallF.args := n ; - f^.funccallF.type := NIL ; - initPair (f^.funccallF.funccallComment) + f^.funccallF.type := getType (c) ; + initPair (f^.funccallF.funccallComment) ; + initNodeOpaqueState (f) END ; RETURN f END makeFuncCall ; @@ -3936,6 +3971,33 @@ BEGIN END hasHidden ; +(* + putTypeOpaque - marks type, des, as being an opaque type. + TYPE des ; +*) + +PROCEDURE putTypeOpaque (des: node) ; +VAR + s: node ; +BEGIN + assert (des#NIL) ; + assert (isType (des)) ; + des^.typeF.isOpaque := TRUE +END putTypeOpaque ; + + +(* + isTypeOpaque - returns TRUE if type, n, is an opaque type. +*) + +PROCEDURE isTypeOpaque (n: node) : BOOLEAN ; +BEGIN + assert (n#NIL) ; + assert (isType (n)) ; + RETURN n^.typeF.isOpaque +END isTypeOpaque ; + + (* putTypeInternal - marks type, des, as being an internally generated type. *) @@ -4673,6 +4735,7 @@ BEGIN n^.componentrefF.rec := rec ; n^.componentrefF.field := field ; n^.componentrefF.resultType := getType (field) ; + initNodeOpaqueState (n) ; RETURN n END doMakeComponentRef ; @@ -4708,6 +4771,7 @@ BEGIN rec^.pointerrefF.ptr := a ; rec^.pointerrefF.field := field ; rec^.pointerrefF.resultType := getType (field) ; + initNodeOpaqueState (rec) ; RETURN rec ELSE RETURN doMakeComponentRef (rec, field) @@ -4739,6 +4803,7 @@ BEGIN n^.pointerrefF.ptr := ptr ; n^.pointerrefF.field := field ; n^.pointerrefF.resultType := getType (field) ; + initNodeOpaqueState (n) ; RETURN n END makePointerRef ; @@ -5192,9 +5257,13 @@ END getMaxMinType ; *) PROCEDURE doGetFuncType (n: node) : node ; +VAR + result: node ; BEGIN assert (isFuncCall (n)) ; - RETURN doSetExprType (n^.funccallF.type, getType (n^.funccallF.function)) + result := doSetExprType (n^.funccallF.type, getType (n^.funccallF.function)) ; + initNodeOpaqueState (n) ; (* Update now that the return type is known. *) + RETURN result END doGetFuncType ; @@ -5951,10 +6020,10 @@ BEGIN IF needsParen (left) THEN outText (p, '(') ; - doExprCup (p, left, unpackProc) ; + left := doExprCup (p, left, unpackProc, FALSE) ; outText (p, ')') ELSE - doExprCup (p, left, unpackProc) + left := doExprCup (p, left, unpackProc, FALSE) END ; IF l THEN @@ -5968,10 +6037,10 @@ BEGIN IF needsParen (right) THEN outText (p, '(') ; - doExprCup (p, right, unpackProc) ; + right := doExprCup (p, right, unpackProc, FALSE) ; outText (p, ')') ELSE - doExprCup (p, right, unpackProc) + right := doExprCup (p, right, unpackProc, FALSE) END END doBinary ; @@ -5991,11 +6060,12 @@ END doPostUnary ; doDeRefC - *) -PROCEDURE doDeRefC (p: pretty; expr: node) ; +PROCEDURE doDeRefC (p: pretty; expr: node) : node ; BEGIN outText (p, '(*') ; - doExprC (p, expr) ; - outText (p, ')') + expr := castOpaque (p, expr, FALSE) ; + outText (p, ')') ; + RETURN expr END doDeRefC ; @@ -6079,7 +6149,7 @@ END getLastOp ; PROCEDURE doComponentRefC (p: pretty; l, r: node) ; BEGIN - doExprC (p, l) ; + flushOpaque (p, l, FALSE) ; outText (p, '.') ; doExprC (p, r) END doComponentRefC ; @@ -6091,7 +6161,7 @@ END doComponentRefC ; PROCEDURE doPointerRefC (p: pretty; l, r: node) ; BEGIN - doExprC (p, l) ; + flushOpaque (p, l, FALSE) ; outText (p, '->') ; doExprC (p, r) END doPointerRefC ; @@ -6156,23 +6226,38 @@ END isZero ; (* - doArrayRef - + doArrayRef - perform an array reference. If constCast + then an unbounded array access will be const_cast + (the constCast should be TRUE if an assignment to + the array is required). *) -PROCEDURE doArrayRef (p: pretty; n: node) ; +PROCEDURE doArrayRef (p: pretty; n: node; constCast: BOOLEAN) ; VAR - t : node ; + type, + v : node ; i, c: CARDINAL ; BEGIN assert (n # NIL) ; assert (isArrayRef (n)) ; - t := skipType (getType (n^.arrayrefF.array)) ; - IF isUnbounded (t) + type := skipType (getType (n^.arrayrefF.array)) ; + IF isUnbounded (type) THEN - outTextN (p, getSymName (n^.arrayrefF.array)) + v := n^.arrayrefF.array ; + IF constCast AND isVar (n^.arrayrefF.array) AND + (v^.varF.isParameter OR v^.varF.isVarParameter) + THEN + outText (p, "const_cast<") ; + doTypeNameC (p, getType (v)) ; + outText (p, ">(") ; + outTextN (p, getSymName (n^.arrayrefF.array)) ; + outText (p, ")") + ELSE + outTextN (p, getSymName (n^.arrayrefF.array)) + END ELSE doExprC (p, n^.arrayrefF.array) ; - assert (isArray (t)) ; + assert (isArray (type)) ; outText (p, '.array') END ; outText (p, '[') ; @@ -6180,16 +6265,16 @@ BEGIN c := expListLen (n^.arrayrefF.index) ; WHILE i<=c DO doExprC (p, getExpList (n^.arrayrefF.index, i)) ; - IF isUnbounded (t) + IF isUnbounded (type) THEN assert (c = 1) ELSE - doSubtractC (p, getMin (t^.arrayF.subr)) ; + doSubtractC (p, getMin (type^.arrayF.subr)) ; IF i (') ; + doExprC (p, n) ; + outText (p, ')') ; + RETURN makeOpaqueCast (n, TRUE) + ELSE + (* next is false cast to __opaque opaque type. *) + outText (p, 'static_cast<') ; + doTypeNameC (p, type) ; + outText (p, '__opaque') ; + noSpace (p) ; + outText (p, '> (') ; + doExprC (p, n) ; + outText (p, ')') ; + RETURN makeOpaqueCast (n, FALSE) + END + ELSE + IF debugOpaque + THEN + doP := p ; + dumpOpaqueState (n) ; + IF nodeUsesOpaque (n) + THEN + outText (p, ' /* no difference seen */ ') + ELSE + outText (p, ' /* no opaque used */ ') + END + END ; + doExprC (p, n) + END ; + RETURN n +END castOpaque ; + + +(* + isTypeOpaqueDefImp - returns TRUE if type is an opaque type by checking + the def/imp pair of modules or fall back to the + definition module. +*) + +PROCEDURE isTypeOpaqueDefImp (type: node) : BOOLEAN ; +VAR + scope, + def, + opaque: node ; +BEGIN + IF type = NIL + THEN + RETURN FALSE + ELSIF isType (type) + THEN + scope := getScope (type) ; + IF isImp (scope) + THEN + def := lookupDef (getSymName (scope)) ; + IF def # NIL + THEN + (* Lookup the type name in the matching definition module. *) + opaque := lookupExported (def, getSymName (type)) ; + RETURN (opaque # NIL) AND isType (opaque) AND isTypeOpaque (opaque) + END + ELSE + (* Otherwise just check the definition module. *) + RETURN isTypeOpaque (type) + END + END ; + RETURN FALSE +END isTypeOpaqueDefImp ; + + +(* + isParamVoidStar - return TRUE if the procedure or proctype opaque type + parameter should be implemented as a (void * ). +*) + +PROCEDURE isParamVoidStar (n: node) : BOOLEAN ; +VAR + proc, + type: node ; +BEGIN + proc := getScope (n) ; + assert (isProcedure (proc) OR isProcType (proc)) ; + type := getType (n) ; + RETURN isReturnVoidStar (proc, type) +END isParamVoidStar ; + + +(* + isRefVoidStar - returns TRUE if the ref node uses an opaque type which + is represented as a (void * ). +*) + +PROCEDURE isRefVoidStar (n: node) : BOOLEAN ; +VAR + type: node ; +BEGIN + type := getType (n) ; + IF (NOT isType (type)) OR (NOT isTypeOpaque (type)) + THEN + (* We should finish the procedure as the ref does not use an opaque. *) + RETURN TRUE + ELSE + (* We check whether the opaque type was declared in the implementation + module. If it is declared in the implementation module then we + return FALSE. *) + RETURN NOT isDeclInImp (type) + END +END isRefVoidStar ; + + +(* + isReturnVoidStar - return TRUE if the procedure or proctype opaque type + return type should be implemented as a (void * ). +*) + +PROCEDURE isReturnVoidStar (proc, type: node) : BOOLEAN ; +VAR + def : node ; +BEGIN + assert (isProcedure (proc) OR isProcType (proc)) ; + IF isExported (proc) + THEN + RETURN TRUE + ELSE + (* Not exported therefore local, we check whether the opaque type + was declared in the implementation module. *) + IF isImp (currentModule) + THEN + IF isType (type) + THEN + RETURN NOT isDeclInImp (type) + ELSE + RETURN FALSE + END + ELSE + (* Always use void * in .def modules. *) + RETURN TRUE + END + END +END isReturnVoidStar ; + + +(* + isVarVoidStar - return TRUE if the variable using an opaque type should + be implemented as a (void * ). +*) + +PROCEDURE isVarVoidStar (n: node) : BOOLEAN ; +VAR + type: node ; +BEGIN + assert (isVar (n)) ; + type := getType (n) ; + IF (NOT isType (type)) OR (NOT isTypeOpaque (type)) + THEN + (* We should finish the procedure as the variable does not use an opaque. *) + RETURN TRUE + ELSIF isExported (n) + THEN + (* Exported variables using an opaque type will always be implemented + with a (void * ). *) + RETURN TRUE + ELSE + (* Not exported therefore static to the module (local or global non exported + variable), we check whether the opaque type was declared in the + implementation module. If it is declared in the implementation module + then we return FALSE. *) + RETURN NOT isDeclInImp (type) + END +END isVarVoidStar ; + + +(* + initNodeOpaqueState - initialize the node opaque state. +*) + +PROCEDURE initNodeOpaqueState (n: node) ; +VAR + type: node ; +BEGIN + CASE n^.kind OF + + opaquecast : | (* This must be done when the cast direction is known. *) + funccall : assignNodeOpaqueCastState (n, getFunction (n)) | + var : type := getType (n) ; + IF n^.varF.isParameter OR n^.varF.isVarParameter + THEN + (* If the variable is really a parameter then it uses + the state of the parameter. *) + initNodeOpaqueCastState (n, isTypeOpaqueDefImp (type), + isParamVoidStar (n)) + ELSE + initNodeOpaqueCastState (n, isTypeOpaqueDefImp (type), + isVarVoidStar (n)) + END | + array : type := getType (n) ; + initNodeOpaqueCastState (n, isTypeOpaqueDefImp (type), + isExported (n)) | + varparam, + param : assert (isProcedure (getScope (n)) OR isProcType (getScope (n))) ; + type := getType (n) ; + initNodeOpaqueCastState (n, isTypeOpaqueDefImp (type), + isParamVoidStar (n)) | + componentref, + pointerref, + pointer, + recordfield, + arrayref : type := getType (n) ; + (* In the future this should be revisited. *) + initNodeOpaqueCastState (n, isTypeOpaqueDefImp (type), + isRefVoidStar (n)) | + (* For the moment treat as never exported. *) + proctype, + procedure : (* We only consider the return type for a procedure or proctype. + The parameters and local vars are handled separately (see + above). *) + type := getType (n) ; + IF type = NIL + THEN + (* No return type, therefore no opaque type used. *) + initNodeOpaqueCastState (n, FALSE, FALSE) + ELSE + (* Init state from the return type. Is type an opaque type? + Is the opaque type declared in this module? *) + initNodeOpaqueCastState (n, isTypeOpaqueDefImp (type), + isReturnVoidStar (n, type)) + END | + + ELSE + END ; + IF debugOpaque + THEN + dumpOpaqueState (n) + END +END initNodeOpaqueState ; + + +(* + assignNodeOpaqueCastState - copy the opaqueCastState from src into dest. +*) + +PROCEDURE assignNodeOpaqueCastState (dest, src: node) ; +BEGIN + IF nodeUsesOpaque (src) + THEN + initNodeOpaqueCastState (dest, TRUE, getNodeOpaqueVoidStar (src)) + ELSE + initNodeOpaqueCastState (dest, FALSE, FALSE) + END +END assignNodeOpaqueCastState ; + + +(* + assignNodeOpaqueCastFalse - assign the voidstar field of dest to false. + It assigns the opaque field of dest to the value + of the src opaque field. +*) + +PROCEDURE assignNodeOpaqueCastFalse (dest, src: node) ; +BEGIN + IF nodeUsesOpaque (src) + THEN + initNodeOpaqueCastState (dest, TRUE, FALSE) + ELSE + initNodeOpaqueCastState (dest, FALSE, FALSE) + END +END assignNodeOpaqueCastFalse ; + + +(* + dumpOpaqueState - +*) + +PROCEDURE dumpOpaqueState (n: node) ; +VAR + o: node ; +BEGIN + CASE n^.kind OF + + opaquecast, + funccall, + var, + array, + varparam, + param, + pointer, + recordfield, + componentref, + arrayref, + procedure, + proctype : o := n + ELSE - doTypeNameC (p, paramtype) + o := NIL + END ; + IF o # NIL + THEN + outText (doP, "/* ") ; + doNameC (doP, o) ; + outText (doP, " ") ; + CASE o^.kind OF + + opaquecast : outText (doP, "opaquecast") | + funccall : outText (doP, "funccall") | + var : outText (doP, "var") | + array : outText (doP, "array") | + varparam : outText (doP, "varparam") | + param : outText (doP, "param") | + pointer : outText (doP, "pointer") | + recordfield : outText (doP, "recordfield") | + componentref: outText (doP, "componentref") | + pointerref : outText (doP, "pointerref") | + arrayref : outText (doP, "arrayref") | + procedure : outText (doP, "procedure") | + proctype : outText (doP, "proctype") + + ELSE + END ; + IF nodeUsesOpaque (o) + THEN + IF getNodeOpaqueVoidStar (o) + THEN + outText (doP, " uses (void *) opaque") + ELSE + outText (doP, " uses opaque__full") + END ; + END ; + outText (doP, " */ \n") END -END doParamTypeEmit ; +END dumpOpaqueState ; (* @@ -7369,10 +8059,7 @@ BEGIN ELSE doFQDNameC (p, v, TRUE) END ; - IF isArray (ptype) AND isUnbounded (ptype) - THEN - outText (p, '_') - END ; + doParamTypeNameModifier (p, ptype, FALSE) ; doUsed (p, n^.paramF.isUsed) ; doHighC (p, ptype, i, n^.paramF.isUsed) ; IF c (') ; @@ -9412,6 +10229,80 @@ BEGIN END requiresUnpackProc ; +(* + forceCastOpaque - +*) + +PROCEDURE forceCastOpaque (p: pretty; des, expr: node; toVoidStar: BOOLEAN) ; +BEGIN + IF nodeUsesOpaque (expr) + THEN + flushOpaque (p, expr, getNodeOpaqueVoidStar (des)) + ELSE + forceReintCastOpaque (p, des, expr, toVoidStar) + END +END forceCastOpaque ; + + +(* + forceReintCastOpaque - +*) + +PROCEDURE forceReintCastOpaque (p: pretty; des, expr: node; toVoidStar: BOOLEAN) ; +VAR + type: node ; +BEGIN + type := getType (des) ; + IF toVoidStar + THEN + (* next is true cast to void * opaque type. *) + outText (p, 'static_cast<') ; + doTypeNameC (p, type) ; + noSpace (p) ; + outText (p, '> (') ; + doExprC (p, expr) ; + outText (p, ')') + ELSE + (* next is false cast to __opaque opaque type. *) + outText (p, 'static_cast<') ; + doTypeNameC (p, type) ; + outText (p, '__opaque') ; + noSpace (p) ; + outText (p, '> (') ; + doExprC (p, expr) ; + outText (p, ')') ; + END +END forceReintCastOpaque ; + + +(* + doUnConstCastUnbounded - if node n type is an unbounded array then + use const_cast to remove the const parameter + to allow the unbounded array to be modified. +*) + +PROCEDURE doUnConstCastUnbounded (p: pretty; n: node) ; +VAR + type, v: node ; +BEGIN + IF isArrayRef (n) + THEN + IF isVar (n^.arrayrefF.array) + THEN + v := n^.arrayrefF.array ; + IF (v^.varF.isParameter OR v^.varF.isVarParameter) AND + isUnbounded (getType (v)) + THEN + type := getType (v) ; + outText (p, " /* const_cast<") ; + doTypeNameC (p, type) ; + outText (p, "> is needed */ ") ; + END + END + END +END doUnConstCastUnbounded ; + + (* doAssignmentC - *) @@ -9420,11 +10311,35 @@ PROCEDURE doAssignmentC (p: pretty; s: node) ; BEGIN assert (isAssignment (s)) ; doCommentC (p, s^.assignmentF.assignComment.body) ; - doExprCup (p, s^.assignmentF.des, requiresUnpackProc (s)) ; + IF debugOpaque + THEN + outText (p, " /* des: */ ") ; + dumpOpaqueState (s^.assignmentF.des) ; + outText (p, " /* expr: */ ") ; + dumpOpaqueState (s^.assignmentF.expr) + END ; + s^.assignmentF.des := doExprCup (p, s^.assignmentF.des, + requiresUnpackProc (s), TRUE) ; + IF debugOpaque + THEN + outText (p, "\n /* after doExprCup des: */ ") ; + dumpOpaqueState (s^.assignmentF.des) ; + outText (p, "\n") + END ; setNeedSpace (p) ; outText (p, "=") ; setNeedSpace (p) ; - doExprCastC (p, s^.assignmentF.expr, getType (s^.assignmentF.des)) ; + IF nodeUsesOpaque (s^.assignmentF.des) + THEN + forceCastOpaque (p, s^.assignmentF.des, s^.assignmentF.expr, + getNodeOpaqueVoidStar (s^.assignmentF.des)) + ELSE + IF debugOpaque + THEN + outText (p, " /* no opaque des seen */ ") + END ; + doExprCastC (p, s^.assignmentF.expr, getType (s^.assignmentF.des)) + END ; outText (p, ";") ; doAfterCommentC (p, s^.assignmentF.assignComment.after) END doAssignmentC ; @@ -10058,11 +10973,11 @@ PROCEDURE doAdrExprC (p: pretty; n: node) ; BEGIN IF isDeref (n) THEN - (* (* no point in issuing & ( * n ) *) *) + (* No point in issuing & ( * n ). *) doExprC (p, n^.unaryF.arg) ELSIF isVar (n) AND n^.varF.isVarParameter THEN - (* (* no point in issuing & ( * n ) *) *) + (* No point in issuing & ( * n ). *) doFQNameC (p, n) ELSE outText (p, '&') ; @@ -10129,7 +11044,7 @@ BEGIN THEN IF isString (actual) AND (skipType (ft) = addressN) THEN - outText (p, "const_cast (reinterpret_cast (") ; + outText (p, "const_cast (static_cast (") ; RETURN 2 ELSIF isPointer (skipType (ft)) OR (skipType (ft) = addressN) THEN @@ -10232,6 +11147,42 @@ BEGIN END isDefForCNode ; +(* + doFuncVarParam - detect whether the formal uses an opaque and ensure that the address of + the actual parameter is cast to the formal type. +*) + +PROCEDURE doFuncVarParam (p: pretty; actual, formal: node) ; +VAR + type: node ; +BEGIN + IF nodeUsesOpaque (formal) AND + getNodeOpaqueFlushNecessary (actual, getNodeOpaqueVoidStar (formal)) + THEN + type := getType (formal) ; + outText (p, 'reinterpret_cast<') ; + IF getNodeOpaqueVoidStar (formal) + THEN + doTypeNameC (p, type) ; + setNeedSpace (p) ; + outText (p, '*> (&') ; + doExprC (p, actual) ; + outText (p, ')') ; + actual := makeOpaqueCast (actual, TRUE) + ELSE + doTypeNameC (p, type) ; + noSpace (p) ; + outText (p, '__opaque *> (&') ; + doExprC (p, actual) ; + outText (p, ')') ; + actual := makeOpaqueCast (actual, FALSE) + END + ELSE + doAdrExprC (p, actual) + END +END doFuncVarParam ; + + (* doFuncParamC - *) @@ -10283,14 +11234,22 @@ BEGIN doCastC (p, getType (formal), actual) END ELSE - lbr := checkSystemCast (p, actual, formal) ; IF isVarParam (formal) THEN - doAdrExprC (p, actual) + lbr := checkSystemCast (p, actual, formal) ; + doFuncVarParam (p, actual, formal) ; + emitN (p, ")", lbr) ELSE - doExprC (p, actual) - END ; - emitN (p, ")", lbr) + IF nodeUsesOpaque (formal) + THEN + forceCastOpaque (p, formal, actual, + getNodeOpaqueVoidStar (formal)) + ELSE + lbr := checkSystemCast (p, actual, formal) ; + doExprC (p, actual) ; + emitN (p, ")", lbr) + END + END END END END @@ -10442,22 +11401,20 @@ BEGIN THEN (* & and * cancel each other out. *) outTextN (p, getSymName (n)) (* --fixme-- does the caller need to cast it? *) - ELSE - IF isString (n) + ELSIF isString (n) OR (isArray (getType (n)) AND isUnbounded (getType (n))) + THEN + IF lang = ansiCP THEN - IF lang = ansiCP - THEN - outText (p, "const_cast (reinterpret_cast") ; - outText (p, "(") ; - doExprC (p, n) ; - outText (p, "))") - ELSE - doExprC (p, n) - END + outText (p, "const_cast (static_cast") ; + outText (p, "(") ; + doExprC (p, n) ; + outText (p, "))") ELSE - outText (p, "&") ; doExprC (p, n) END + ELSE + outText (p, "&") ; + doExprC (p, n) END END doAdrArgC ; @@ -11170,6 +12127,23 @@ END doConvertSC ; *) +(* + getFunction - return the function associate with funccall node n. +*) + +PROCEDURE getFunction (n: node) : node ; +BEGIN + assert (isFuncCall (n)) ; + CASE n^.kind OF + + funccall: RETURN n^.funccallF.function + + ELSE + HALT + END +END getFunction ; + + (* getFuncFromExpr - *) @@ -11701,7 +12675,9 @@ BEGIN END doStatementsC ; -PROCEDURE stop ; END stop ; +PROCEDURE localstop ; +END localstop ; + (* doLocalVarC - @@ -11711,7 +12687,6 @@ PROCEDURE doLocalVarC (p: pretty; s: scopeT) ; BEGIN includeVarProcedure (s) ; debugLists ; - topologicallyOut (doConstC, doTypesC, doVarC, outputPartial, doNone, doCompletePartialC, doNone) @@ -13912,13 +14887,9 @@ END dumpQ ; *) PROCEDURE dumpLists ; -VAR - m: String ; BEGIN - IF getDebugTopological () + IF getDebugTopological () AND FALSE THEN - m := Sprintf0 (InitString ('\n')) ; - m := KillString (WriteS (StdOut, m)) ; dumpQ ('todo', globalGroup^.todoQ) ; dumpQ ('partial', globalGroup^.partialQ) ; dumpQ ('done', globalGroup^.doneQ) @@ -14099,7 +15070,7 @@ BEGIN IF tryComplete (d, c, t, v) THEN alists.removeItemFromList (globalGroup^.todoQ, d) ; - alists.includeItemIntoList (globalGroup^.doneQ, d) ; + addDone (d) ; i := 1 ELSIF tryPartial (d, pt) THEN @@ -14130,7 +15101,7 @@ BEGIN IF tryCompleteFromPartial (d, t) THEN alists.removeItemFromList (globalGroup^.partialQ, d) ; - alists.includeItemIntoList (globalGroup^.doneQ, d) ; + addDone (d) ; i := 1 ; DEC (n) ELSE @@ -14144,7 +15115,7 @@ END tryOutputPartial ; debugList - *) -PROCEDURE debugList (a: ARRAY OF CHAR; l: alist) ; +PROCEDURE debugList (listName, symName: ARRAY OF CHAR; l: alist) ; VAR i, h: CARDINAL ; n : node ; @@ -14152,12 +15123,10 @@ BEGIN h := alists.noOfItemsInList (l) ; IF h>0 THEN - outText (doP, a) ; - outText (doP, ' still contains node(s)\n') ; i := 1 ; REPEAT n := alists.getItemFromList (l, i) ; - dbg (n) ; + dbg (listName, symName, n) ; INC (i) UNTIL i > h END @@ -14172,8 +15141,9 @@ PROCEDURE debugLists ; BEGIN IF getDebugTopological () THEN - debugList ('todo', globalGroup^.todoQ) ; - debugList ('partial', globalGroup^.partialQ) + debugList ('todo', 'decl_node', globalGroup^.todoQ) ; + debugList ('partial', 'decl_node', globalGroup^.partialQ) ; + debugList ('done', 'decl_node', globalGroup^.doneQ) END END debugLists ; @@ -14255,9 +15225,11 @@ BEGIN doFQNameC (p, n) ; outText (p, "_init") ; setNeedSpace (p) ; - outText (p, "(__attribute__((unused)) int argc") ; - outText (p, ",__attribute__((unused)) char *argv[]") ; - outText (p, ",__attribute__((unused)) char *envp[])\n"); + outText (p, "(__attribute__((unused)) int argc,") ; + setNeedSpace (p) ; + outText (p, "__attribute__((unused)) char *argv[],") ; + setNeedSpace (p) ; + outText (p, "__attribute__((unused)) char *envp[])\n"); p := outKc (p, "{\n") ; doStatementsC (p, n^.impF.beginStatements) ; p := outKc (p, "}\n") ; @@ -14269,9 +15241,11 @@ BEGIN doFQNameC (p, n) ; outText (p, "_fini") ; setNeedSpace (p) ; - outText (p, "(__attribute__((unused)) int argc") ; - outText (p, ",__attribute__((unused)) char *argv[]") ; - outText (p, ",__attribute__((unused)) char *envp[])\n"); + outText (p, "(__attribute__((unused)) int argc,") ; + setNeedSpace (p) ; + outText (p, "__attribute__((unused)) char *argv[],") ; + setNeedSpace (p) ; + outText (p, "__attribute__((unused)) char *envp[])\n"); p := outKc (p, "{\n") ; doStatementsC (p, n^.impF.finallyStatements) ; p := outKc (p, "}\n") @@ -14341,8 +15315,10 @@ BEGIN outText (p, "_init") ; setNeedSpace (p) ; outText (p, "(__attribute__((unused)) int argc,") ; - outText (p, " __attribute__((unused)) char *argv[]") ; - outText (p, " __attribute__((unused)) char *envp[])\n") ; + setNeedSpace (p) ; + outText (p, "__attribute__((unused)) char *argv[],") ; + setNeedSpace (p) ; + outText (p, "__attribute__((unused)) char *envp[])\n") ; p := outKc (p, "{\n") ; doStatementsC (p, n^.impF.beginStatements) ; p := outKc (p, "}\n") ; @@ -14355,8 +15331,10 @@ BEGIN outText (p, "_fini") ; setNeedSpace (p) ; outText (p, "(__attribute__((unused)) int argc,") ; - outText (p, " __attribute__((unused)) char *argv[]") ; - outText (p, " __attribute__((unused)) char *envp[])\n") ; + setNeedSpace (p) ; + outText (p, "__attribute__((unused)) char *argv[],") ; + setNeedSpace (p) ; + outText (p, "__attribute__((unused)) char *envp[])\n") ; p := outKc (p, "{\n") ; doStatementsC (p, n^.impF.finallyStatements) ; p := outKc (p, "}\n") ; @@ -14543,9 +15521,13 @@ BEGIN foreachDefModuleDo (runPrototypeDefC) ELSE s := InitStringCharStar (keyToCharStar (getSymName (n))) ; - (* we don't want to include the .h file for this implementation module. *) - print (p, "#define _") ; prints (p, s) ; print (p, "_H\n") ; + (* Inform the source that this code belongs to the implementation module. *) print (p, "#define _") ; prints (p, s) ; print (p, "_C\n\n") ; + (* Include the definition module for any opaque types. *) + print (doP, '#include "') ; + prints (p, getHPrefix ()) ; + prints (p, s) ; + print (p, '.h"\n') ; s := KillString (s) ; doP := p ; @@ -15442,8 +16424,15 @@ END setLangM2 ; *) PROCEDURE addDone (n: node) ; +VAR + s: String ; BEGIN - alists.includeItemIntoList (globalGroup^.doneQ, n) + alists.includeItemIntoList (globalGroup^.doneQ, n) ; + IF isVar (n) OR isParameter (n) + THEN + initNodeOpaqueState (n) + END ; + debugLists END addDone ; @@ -15464,6 +16453,11 @@ BEGIN metaError1 ('cyclic dependancy found between another module using {%1ad} from the definition module of the implementation main being compiled, use the --extended-opaque option to compile', n) ; flushErrors ; errorAbort0 ('terminating compilation') + ELSIF isType (n) AND isDeclInImp (n) + THEN + (* Ignore an opaque type which is declared in this implementation module as it + will be fully declared in C/C++ with the __opaque postfix. Whereas the + void * non prefixed typedef will be declared in the .h file. *) ELSE addDone (n) END @@ -15704,7 +16698,7 @@ END doDbg ; dbg - *) -PROCEDURE dbg (n: node) ; +PROCEDURE dbg (listName, symName: ARRAY OF CHAR; n: node) ; VAR l: alist ; o: pretty ; @@ -15720,10 +16714,20 @@ BEGIN l := alists.initList () ; alists.includeItemIntoList (l, n) ; i := 1 ; - out1 ("dbg (%s)\n", n) ; REPEAT n := alists.getItemFromList (l, i) ; - doDbg (l, n) ; + IF isType (n) + THEN + s := getFQstring (n) ; + IF EqualArray (s, symName) + THEN + out0 ("list ") ; + out0 (listName) ; + out0 (": ") ; + doDbg (l, n) + END ; + s := KillString (s) + END ; INC (i) UNTIL i>alists.noOfItemsInList (l) ; doP := o ; @@ -16658,6 +17662,7 @@ BEGIN assert (isFuncCall (n)) ; m := makeFuncCall (dupExpr (n^.funccallF.function), dupExpr (n^.funccallF.args)) ; m^.funccallF.type := n^.funccallF.type ; + assignNodeOpaqueCastState (m, n) ; RETURN m END dupFunccall ; diff --git a/gcc/m2/mc/mc.flex b/gcc/m2/mc/mc.flex index 7c841bf8d63ea..26139516dfd64 100644 --- a/gcc/m2/mc/mc.flex +++ b/gcc/m2/mc/mc.flex @@ -27,6 +27,7 @@ along with GNU Modula-2; see the file COPYING3. If not see #include #include +#include #ifndef alloca #ifdef __GNUC__ @@ -101,11 +102,11 @@ static void pushFunction (char *function, int module); static void popFunction (void); static void checkFunction (void); int mcflex_getColumnNo (void); - int mcflex_openSource (char *s); + bool mcflex_openSource (char *s); int mcflex_getLineNo (void); void mcflex_closeSource (void); char *mcflex_getToken (void); - void _M2_mcflex_init (void); + void _M2_mcflex_init (int argc, char *argv[], char *envp[]); int mcflex_getTotalLines (void); extern void yylex (void); @@ -659,13 +660,13 @@ mcflex_closeSource (void) /* openSource returns TRUE if file s can be opened and all tokens are taken from this file. */ -int +bool mcflex_openSource (char *s) { FILE *newInputFile = fopen (s, "r"); if (newInputFile == NULL) - return FALSE; + return false; else { isDefinitionModule = FALSE; @@ -687,7 +688,7 @@ mcflex_openSource (char *s) if (currentLine != NULL) currentLine->actualline = lineno; START_FILE (filename, lineno); - return TRUE; + return true; } } @@ -734,12 +735,12 @@ yywrap (void) } void -_M2_mcflex_init (void) +_M2_mcflex_init (int argc, char *argv[], char *envp[]) { } void -_M2_mcflex_fini (void) +_M2_mcflex_fini (int argc, char *argv[], char *envp[]) { } diff --git a/gcc/m2/mc/mcComment.h b/gcc/m2/mc/mcComment.h index 31f412fcf8af3..9e75ca5e42a31 100644 --- a/gcc/m2/mc/mcComment.h +++ b/gcc/m2/mc/mcComment.h @@ -22,6 +22,8 @@ along with GNU Modula-2; see the file COPYING3. If not see #ifndef mcCommentH #define mcCommentH +#include + /* addText the text cs is appended to the current comment. */ extern void mcComment_addText (void *cd, char *cs); @@ -34,7 +36,7 @@ extern void mcComment_addText (void *cd, char *cs); If onlySpaces is TRUE then an inbody comment is created. If onlySpaces is FALSE then an after statement comment is created. */ -extern void *mcComment_initComment (unsigned int onlySpaces); +extern void *mcComment_initComment (bool onlySpaces); #endif diff --git a/gcc/m2/mc/mcOptions.mod b/gcc/m2/mc/mcOptions.mod index 7b81222f356fb..cdea1f466bf64 100644 --- a/gcc/m2/mc/mcOptions.mod +++ b/gcc/m2/mc/mcOptions.mod @@ -752,7 +752,8 @@ BEGIN setOutputFile (Slice (arg, 3, 0)) ELSIF optionIs ("--extended-opaque", arg) THEN - setExtendedOpaque (TRUE) + (* setExtendedOpaque (TRUE) *) + printf0 ("IGNORING --extended-opaque - this option is no longer implemented - please adjust the call to mc\n") ELSIF optionIs ("--debug-top", arg) THEN setDebugTopological (TRUE) diff --git a/gcc/m2/mc/mcp1.bnf b/gcc/m2/mc/mcp1.bnf index 5c1460b5517e8..5b9661b4c2328 100644 --- a/gcc/m2/mc/mcp1.bnf +++ b/gcc/m2/mc/mcp1.bnf @@ -59,7 +59,7 @@ FROM mcLexBuf IMPORT currentstring, currenttoken, getToken, insertToken, FROM decl IMPORT node, lookupDef, lookupImp, lookupModule, getSymName, lookupSym, putDefForC, makeProcedure, makeType, makeTypeImp, makeVar, makeConst, - enterScope, leaveScope, putTypeHidden, + enterScope, leaveScope, putTypeHidden, putTypeOpaque, addImportedModule, getCurrentModule, putCommentDefProcedure, putCommentModProcedure ; @@ -1064,7 +1064,8 @@ DefinitionModule := % VAR c: DefTypeDeclaration := { Ident % VAR n: node ; % % n := makeType (curident) % - ( ";" % putTypeHidden (n) % + ( ";" % putTypeHidden (n) ; + putTypeOpaque (n) % | "=" Type Alignment ";" ) } =: diff --git a/gcc/match.pd b/gcc/match.pd index 5cfe81e80b311..3d0689c9312dc 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -200,6 +200,13 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (match (maybe_bit_not @0) (bit_xor_cst@0 @1 @2)) +#if GIMPLE +(match (maybe_truncate @0) + (convert @0) + (if (INTEGRAL_TYPE_P (type) + && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (@0))))) +#endif + /* Transform likes of (char) ABS_EXPR <(int) x> into (char) ABSU_EXPR ABSU_EXPR returns unsigned absolute value of the operand and the operand of the ABSU_EXPR will have the corresponding signed type. */ @@ -3137,17 +3144,27 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (cond^ (ne (imagpart (IFN_ADD_OVERFLOW:c @0 @1)) integer_zerop) integer_minus_onep (usadd_left_part_2 @0 @1))) +/* Unsigned saturation add, case 7 (branch with le): + SAT_ADD = x <= (X + Y) ? (X + Y) : -1. */ +(match (unsigned_integer_sat_add @0 @1) + (cond^ (le @0 (usadd_left_part_1@2 @0 @1)) @2 integer_minus_onep)) + +/* Unsigned saturation add, case 8 (branch with gt): + SAT_ADD = x > (X + Y) ? -1 : (X + Y). */ +(match (unsigned_integer_sat_add @0 @1) + (cond^ (gt @0 (usadd_left_part_1@2 @0 @1)) integer_minus_onep @2)) + /* Unsigned saturation sub, case 1 (branch with gt): SAT_U_SUB = X > Y ? X - Y : 0 */ (match (unsigned_integer_sat_sub @0 @1) - (cond (gt @0 @1) (minus @0 @1) integer_zerop) + (cond^ (gt @0 @1) (minus @0 @1) integer_zerop) (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) && types_match (type, @0, @1)))) /* Unsigned saturation sub, case 2 (branch with ge): SAT_U_SUB = X >= Y ? X - Y : 0. */ (match (unsigned_integer_sat_sub @0 @1) - (cond (ge @0 @1) (minus @0 @1) integer_zerop) + (cond^ (ge @0 @1) (minus @0 @1) integer_zerop) (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) && types_match (type, @0, @1)))) @@ -3165,6 +3182,34 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) && types_match (type, @0, @1)))) +/* Unsigned saturation sub, case 5 (branchless bit_and with .SUB_OVERFLOW). */ +(match (unsigned_integer_sat_sub @0 @1) + (bit_and:c (realpart (IFN_SUB_OVERFLOW@2 @0 @1)) + (plus (imagpart @2) integer_minus_onep)) + (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) + && types_match (type, @0, @1)))) + +/* Unsigned saturation sub, case 6 (branchless mult with .SUB_OVERFLOW). */ +(match (unsigned_integer_sat_sub @0 @1) + (mult:c (realpart (IFN_SUB_OVERFLOW@2 @0 @1)) + (bit_xor (imagpart @2) integer_onep)) + (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) + && types_match (type, @0, @1)))) + +/* Unsigned saturation sub, case 7 (branch eq with .SUB_OVERFLOW). */ +(match (unsigned_integer_sat_sub @0 @1) + (cond^ (eq (imagpart (IFN_SUB_OVERFLOW@2 @0 @1)) integer_zerop) + (realpart @2) integer_zerop) + (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) + && types_match (type, @0, @1)))) + +/* Unsigned saturation sub, case 8 (branch ne with .SUB_OVERFLOW). */ +(match (unsigned_integer_sat_sub @0 @1) + (cond^ (ne (imagpart (IFN_SUB_OVERFLOW@2 @0 @1)) integer_zerop) + integer_zerop (realpart @2)) + (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) + && types_match (type, @0, @1)))) + /* x > y && x != XXX_MIN --> x > y x > y && x == XXX_MIN --> false . */ (for eqne (eq ne) diff --git a/gcc/optabs.cc b/gcc/optabs.cc index e791388456713..185c5b1a70535 100644 --- a/gcc/optabs.cc +++ b/gcc/optabs.cc @@ -253,7 +253,7 @@ widen_operand (rtx op, machine_mode mode, machine_mode oldmode, type-promotion (vec-unpack) 1 oprnd0 - - */ rtx -expand_widen_pattern_expr (sepops ops, rtx op0, rtx op1, rtx wide_op, +expand_widen_pattern_expr (const_sepops ops, rtx op0, rtx op1, rtx wide_op, rtx target, int unsignedp) { class expand_operand eops[4]; @@ -566,8 +566,8 @@ expand_subword_shift (scalar_int_mode op1_mode, optab binoptab, if (tmp == 0) return false; - /* Now OR in the bits carried over from OUTOF_INPUT. */ - if (!force_expand_binop (word_mode, ior_optab, tmp, carries, + /* Now OR/PLUS in the bits carried over from OUTOF_INPUT. */ + if (!force_expand_binop (word_mode, add_optab, tmp, carries, into_target, unsignedp, methods)) return false; } @@ -1085,7 +1085,7 @@ expand_doubleword_mod (machine_mode mode, rtx op0, rtx op1, bool unsignedp) NULL_RTX, 1, OPTAB_DIRECT); if (v == NULL_RTX) return NULL_RTX; - v = lowpart_subreg (word_mode, v, mode); + v = force_lowpart_subreg (word_mode, v, mode); if (v == NULL_RTX) return NULL_RTX; if (i != count - 1) @@ -1937,7 +1937,7 @@ expand_binop (machine_mode mode, optab binoptab, rtx op0, rtx op1, NULL_RTX, unsignedp, next_methods); if (into_temp1 != 0 && into_temp2 != 0) - inter = expand_binop (word_mode, ior_optab, into_temp1, into_temp2, + inter = expand_binop (word_mode, add_optab, into_temp1, into_temp2, into_target, unsignedp, next_methods); else inter = 0; @@ -1953,7 +1953,7 @@ expand_binop (machine_mode mode, optab binoptab, rtx op0, rtx op1, NULL_RTX, unsignedp, next_methods); if (inter != 0 && outof_temp1 != 0 && outof_temp2 != 0) - inter = expand_binop (word_mode, ior_optab, + inter = expand_binop (word_mode, add_optab, outof_temp1, outof_temp2, outof_target, unsignedp, next_methods); @@ -3096,26 +3096,6 @@ expand_ffs (scalar_int_mode mode, rtx op0, rtx target) return 0; } -/* Extract the OMODE lowpart from VAL, which has IMODE. Under certain - conditions, VAL may already be a SUBREG against which we cannot generate - a further SUBREG. In this case, we expect forcing the value into a - register will work around the situation. */ - -static rtx -lowpart_subreg_maybe_copy (machine_mode omode, rtx val, - machine_mode imode) -{ - rtx ret; - ret = lowpart_subreg (omode, val, imode); - if (ret == NULL) - { - val = force_reg (imode, val); - ret = lowpart_subreg (omode, val, imode); - gcc_assert (ret != NULL); - } - return ret; -} - /* Expand a floating point absolute value or negation operation via a logical operation on the sign bit. */ @@ -3204,7 +3184,7 @@ expand_absneg_bit (enum rtx_code code, scalar_float_mode mode, gen_lowpart (imode, op0), immed_wide_int_const (mask, imode), gen_lowpart (imode, target), 1, OPTAB_LIB_WIDEN); - target = lowpart_subreg_maybe_copy (mode, temp, imode); + target = force_lowpart_subreg (mode, temp, imode); set_dst_reg_note (get_last_insn (), REG_EQUAL, gen_rtx_fmt_e (code, mode, copy_rtx (op0)), @@ -4043,7 +4023,7 @@ expand_copysign_bit (scalar_float_mode mode, rtx op0, rtx op1, rtx target, temp = expand_binop (imode, ior_optab, op0, op1, gen_lowpart (imode, target), 1, OPTAB_LIB_WIDEN); - target = lowpart_subreg_maybe_copy (mode, temp, imode); + target = force_lowpart_subreg (mode, temp, imode); } return target; diff --git a/gcc/optabs.h b/gcc/optabs.h index c0b8df5268f6e..301847e2186d7 100644 --- a/gcc/optabs.h +++ b/gcc/optabs.h @@ -182,7 +182,7 @@ enum optab_methods OPTAB_MUST_WIDEN }; -extern rtx expand_widen_pattern_expr (struct separate_ops *, rtx , rtx , rtx, +extern rtx expand_widen_pattern_expr (const struct separate_ops *, rtx , rtx , rtx, rtx, int); extern rtx expand_ternary_op (machine_mode mode, optab ternary_optab, rtx op0, rtx op1, rtx op2, rtx target, diff --git a/gcc/opts-common.cc b/gcc/opts-common.cc index 14084d08b05a0..fcabc27dd542e 100644 --- a/gcc/opts-common.cc +++ b/gcc/opts-common.cc @@ -524,6 +524,7 @@ add_misspelling_candidates (auto_vec *candidates, for (unsigned i = 0; i < ARRAY_SIZE (option_map); i++) { const char *opt0 = option_map[i].opt0; + const char *opt1 = option_map[i].opt1; const char *new_prefix = option_map[i].new_prefix; size_t new_prefix_len = strlen (new_prefix); @@ -532,8 +533,9 @@ add_misspelling_candidates (auto_vec *candidates, if (strncmp (opt_text, new_prefix, new_prefix_len) == 0) { - char *alternative = concat (opt0 + 1, opt_text + new_prefix_len, - NULL); + char *alternative + = concat (opt0 + 1, opt1 ? " " : "", opt1 ? opt1 : "", + opt_text + new_prefix_len, NULL); candidates->safe_push (alternative); } } diff --git a/gcc/passes.def b/gcc/passes.def index 1cbbd41309708..041229e47a68e 100644 --- a/gcc/passes.def +++ b/gcc/passes.def @@ -226,6 +226,7 @@ along with GCC; see the file COPYING3. If not see NEXT_PASS (pass_merge_phi); NEXT_PASS (pass_thread_jumps_full, /*first=*/true); NEXT_PASS (pass_vrp, false /* final_p*/); + NEXT_PASS (pass_array_bounds); NEXT_PASS (pass_dse); NEXT_PASS (pass_dce); /* pass_stdarg is always run and at this point we execute diff --git a/gcc/pretty-print.cc b/gcc/pretty-print.cc index eb59bf424b7c6..ec44172f24df5 100644 --- a/gcc/pretty-print.cc +++ b/gcc/pretty-print.cc @@ -674,8 +674,9 @@ mingw_ansi_fputs (const char *str, FILE *fp) /* Don't mess up stdio functions with Windows APIs. */ fflush (fp); - if (GetConsoleMode (h, &mode)) - /* If it is a console, translate ANSI escape codes as needed. */ + if (GetConsoleMode (h, &mode) && !(mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING)) + /* If it is a console, and doesn't support ANSI escape codes, translate + them as needed. */ for (;;) { if ((esc_code = find_esc_head (&prefix_len, &esc_head, read)) == 0) @@ -814,34 +815,35 @@ output_buffer::~output_buffer () /* Subroutine of pp_set_maximum_length. Set up PRETTY-PRINTER's internal maximum characters per line. */ -static void -pp_set_real_maximum_length (pretty_printer *pp) + +void +pretty_printer::set_real_maximum_length () { /* If we're told not to wrap lines then do the obvious thing. In case we'll emit prefix only once per message, it is appropriate not to increase unnecessarily the line-length cut-off. */ - if (!pp_is_wrapping_line (pp) - || pp_prefixing_rule (pp) == DIAGNOSTICS_SHOW_PREFIX_ONCE - || pp_prefixing_rule (pp) == DIAGNOSTICS_SHOW_PREFIX_NEVER) - pp->maximum_length = pp_line_cutoff (pp); + if (!pp_is_wrapping_line (this) + || pp_prefixing_rule (this) == DIAGNOSTICS_SHOW_PREFIX_ONCE + || pp_prefixing_rule (this) == DIAGNOSTICS_SHOW_PREFIX_NEVER) + m_maximum_length = pp_line_cutoff (this); else { - int prefix_length = pp->prefix ? strlen (pp->prefix) : 0; + int prefix_length = m_prefix ? strlen (m_prefix) : 0; /* If the prefix is ridiculously too long, output at least 32 characters. */ - if (pp_line_cutoff (pp) - prefix_length < 32) - pp->maximum_length = pp_line_cutoff (pp) + 32; + if (pp_line_cutoff (this) - prefix_length < 32) + m_maximum_length = pp_line_cutoff (this) + 32; else - pp->maximum_length = pp_line_cutoff (pp); + m_maximum_length = pp_line_cutoff (this); } } -/* Clear PRETTY-PRINTER's output state. */ -static inline void -pp_clear_state (pretty_printer *pp) +/* Clear this pretty_printer's output state. */ +inline void +pretty_printer::clear_state () { - pp->emitted_prefix = false; - pp_indentation (pp) = 0; + m_emitted_prefix = false; + pp_indentation (this) = 0; } /* Print X to PP in decimal. */ @@ -1006,7 +1008,7 @@ pp_wrap_text (pretty_printer *pp, const char *start, const char *end) while (p != end && !ISBLANK (*p) && *p != '\n') ++p; if (wrapping_line - && p - start >= pp_remaining_character_count_for_line (pp)) + && p - start >= pp->remaining_character_count_for_line ()) pp_newline (pp); pp_append_text (pp, start, p); start = p; @@ -1101,7 +1103,7 @@ urlify_quoted_string (pretty_printer *pp, size_t quoted_text_start_idx, size_t quoted_text_end_idx) { - if (pp->url_format == URL_FORMAT_NONE) + if (!pp->supports_urls_p ()) return quoted_text_end_idx; if (!urlifier) return quoted_text_end_idx; @@ -1125,7 +1127,7 @@ urlify_quoted_string (pretty_printer *pp, /* ...with URLified version of the text. */ /* Begin URL. */ - switch (pp->url_format) + switch (pp->get_url_format ()) { default: case URL_FORMAT_NONE: @@ -1238,29 +1240,53 @@ class quoting_info std::vector m_phase_3_quotes; }; -static void -on_begin_quote (const output_buffer &buf, - unsigned chunk_idx, - const urlifier *urlifier) +/* Adds a chunk to the end of formatted output, so that it + will be printed by pp_output_formatted_text. */ + +void +chunk_info::append_formatted_chunk (const char *content) +{ + unsigned int chunk_idx; + for (chunk_idx = 0; m_args[chunk_idx]; chunk_idx++) + ; + m_args[chunk_idx++] = content; + m_args[chunk_idx] = nullptr; +} + +/* Deallocate the current chunk structure and everything after it (i.e. the + associated series of formatted strings). */ + +void +chunk_info::pop_from_output_buffer (output_buffer &buf) +{ + delete m_quotes; + buf.cur_chunk_array = m_prev; + obstack_free (&buf.chunk_obstack, this); +} + +void +chunk_info::on_begin_quote (const output_buffer &buf, + unsigned chunk_idx, + const urlifier *urlifier) { if (!urlifier) return; - if (!buf.cur_chunk_array->m_quotes) - buf.cur_chunk_array->m_quotes = new quoting_info (); - buf.cur_chunk_array->m_quotes->on_begin_quote (buf, chunk_idx); + if (!m_quotes) + m_quotes = new quoting_info (); + m_quotes->on_begin_quote (buf, chunk_idx); } -static void -on_end_quote (pretty_printer *pp, - output_buffer &buf, - unsigned chunk_idx, - const urlifier *urlifier) +void +chunk_info::on_end_quote (pretty_printer *pp, + output_buffer &buf, + unsigned chunk_idx, + const urlifier *urlifier) { if (!urlifier) return; - if (!buf.cur_chunk_array->m_quotes) - buf.cur_chunk_array->m_quotes = new quoting_info (); - buf.cur_chunk_array->m_quotes->on_end_quote (pp, buf, chunk_idx, *urlifier); + if (!m_quotes) + m_quotes = new quoting_info (); + m_quotes->on_end_quote (pp, buf, chunk_idx, *urlifier); } /* The following format specifiers are recognized as being client independent: @@ -1305,7 +1331,8 @@ on_end_quote (pretty_printer *pp, 1 up to highest argument; each argument may only be used once. A format string can have at most 30 arguments. */ -/* Formatting phases 1 and 2: render TEXT->format_spec plus +/* Implementation of pp_format. + Formatting phases 1 and 2: render TEXT->format_spec plus text->m_args_ptr into a series of chunks in pp_buffer (PP)->args[]. Phase 3 is in pp_output_formatted_text. @@ -1322,27 +1349,21 @@ on_end_quote (pretty_printer *pp, are stashed into the output_buffer's m_quotes for use in phase 3. */ void -pp_format (pretty_printer *pp, - text_info *text, - const urlifier *urlifier) +pretty_printer::format (text_info *text, + const urlifier *urlifier) { - output_buffer * const buffer = pp_buffer (pp); - const char *p; - const char **args; - struct chunk_info *new_chunk_array; + output_buffer * const buffer = m_buffer; - unsigned int curarg = 0, chunk = 0, argno; - pp_wrapping_mode_t old_wrapping_mode; - bool any_unnumbered = false, any_numbered = false; + unsigned int chunk = 0, argno; const char **formatters[PP_NL_ARGMAX]; /* Allocate a new chunk structure. */ - new_chunk_array = XOBNEW (&buffer->chunk_obstack, struct chunk_info); + chunk_info *new_chunk_array = XOBNEW (&buffer->chunk_obstack, chunk_info); - new_chunk_array->prev = buffer->cur_chunk_array; + new_chunk_array->m_prev = buffer->cur_chunk_array; new_chunk_array->m_quotes = nullptr; buffer->cur_chunk_array = new_chunk_array; - args = new_chunk_array->args; + const char **args = new_chunk_array->m_args; /* Formatting phase 1: split up TEXT->format_spec into chunks in pp_buffer (PP)->args[]. Even-numbered chunks are to be output @@ -1352,7 +1373,9 @@ pp_format (pretty_printer *pp, memset (formatters, 0, sizeof formatters); - for (p = text->m_format_spec; *p; ) + unsigned int curarg = 0; + bool any_unnumbered = false, any_numbered = false; + for (const char *p = text->m_format_spec; *p; ) { while (*p != '\0' && *p != '%') { @@ -1377,20 +1400,19 @@ pp_format (pretty_printer *pp, { obstack_grow (&buffer->chunk_obstack, open_quote, strlen (open_quote)); - const char *colorstr - = colorize_start (pp_show_color (pp), "quote"); + const char *colorstr = colorize_start (m_show_color, "quote"); obstack_grow (&buffer->chunk_obstack, colorstr, strlen (colorstr)); p++; - on_begin_quote (*buffer, chunk, urlifier); + buffer->cur_chunk_array->on_begin_quote (*buffer, chunk, urlifier); continue; } case '>': { - on_end_quote (pp, *buffer, chunk, urlifier); + buffer->cur_chunk_array->on_end_quote (this, *buffer, chunk, urlifier); - const char *colorstr = colorize_stop (pp_show_color (pp)); + const char *colorstr = colorize_stop (m_show_color); obstack_grow (&buffer->chunk_obstack, colorstr, strlen (colorstr)); } /* FALLTHRU */ @@ -1402,7 +1424,7 @@ pp_format (pretty_printer *pp, case '}': { - const char *endurlstr = get_end_url_string (pp); + const char *endurlstr = get_end_url_string (this); obstack_grow (&buffer->chunk_obstack, endurlstr, strlen (endurlstr)); } @@ -1411,7 +1433,7 @@ pp_format (pretty_printer *pp, case 'R': { - const char *colorstr = colorize_stop (pp_show_color (pp)); + const char *colorstr = colorize_stop (m_show_color); obstack_grow (&buffer->chunk_obstack, colorstr, strlen (colorstr)); p++; @@ -1520,7 +1542,7 @@ pp_format (pretty_printer *pp, prefixing off. */ buffer->obstack = &buffer->chunk_obstack; const int old_line_length = buffer->line_length; - old_wrapping_mode = pp_set_verbatim_wrapping (pp); + const pp_wrapping_mode_t old_wrapping_mode = pp_set_verbatim_wrapping (this); /* Second phase. Replace each formatter with the formatted text it corresponds to. */ @@ -1533,6 +1555,8 @@ pp_format (pretty_printer *pp, bool hash = false; bool quote = false; + const char *p; + /* We do not attempt to enforce any ordering on the modifier characters. */ @@ -1583,14 +1607,14 @@ pp_format (pretty_printer *pp, if (quote) { - pp_begin_quote (pp, pp_show_color (pp)); - on_begin_quote (*buffer, chunk, urlifier); + pp_begin_quote (this, m_show_color); + buffer->cur_chunk_array->on_begin_quote (*buffer, chunk, urlifier); } switch (*p) { case 'r': - pp_string (pp, colorize_start (pp_show_color (pp), + pp_string (this, colorize_start (m_show_color, va_arg (*text->m_args_ptr, const char *))); break; @@ -1602,11 +1626,11 @@ pp_format (pretty_printer *pp, "\x" prefix. Otherwise print them all unchanged. */ int chr = va_arg (*text->m_args_ptr, int); if (ISPRINT (chr) || !quote) - pp_character (pp, chr); + pp_character (this, chr); else { const char str [2] = { chr, '\0' }; - pp_quoted_string (pp, str, 1); + pp_quoted_string (this, str, 1); } break; } @@ -1614,43 +1638,43 @@ pp_format (pretty_printer *pp, case 'd': case 'i': if (wide) - pp_wide_integer (pp, va_arg (*text->m_args_ptr, HOST_WIDE_INT)); + pp_wide_integer (this, va_arg (*text->m_args_ptr, HOST_WIDE_INT)); else - pp_integer_with_precision (pp, *text->m_args_ptr, precision, + pp_integer_with_precision (this, *text->m_args_ptr, precision, int, "d"); break; case 'o': if (wide) - pp_scalar (pp, "%" HOST_WIDE_INT_PRINT "o", + pp_scalar (this, "%" HOST_WIDE_INT_PRINT "o", va_arg (*text->m_args_ptr, unsigned HOST_WIDE_INT)); else - pp_integer_with_precision (pp, *text->m_args_ptr, precision, + pp_integer_with_precision (this, *text->m_args_ptr, precision, unsigned, "o"); break; case 's': if (quote) - pp_quoted_string (pp, va_arg (*text->m_args_ptr, const char *)); + pp_quoted_string (this, va_arg (*text->m_args_ptr, const char *)); else - pp_string (pp, va_arg (*text->m_args_ptr, const char *)); + pp_string (this, va_arg (*text->m_args_ptr, const char *)); break; case 'p': - pp_pointer (pp, va_arg (*text->m_args_ptr, void *)); + pp_pointer (this, va_arg (*text->m_args_ptr, void *)); break; case 'u': if (wide) - pp_scalar (pp, HOST_WIDE_INT_PRINT_UNSIGNED, + pp_scalar (this, HOST_WIDE_INT_PRINT_UNSIGNED, va_arg (*text->m_args_ptr, unsigned HOST_WIDE_INT)); else - pp_integer_with_precision (pp, *text->m_args_ptr, precision, + pp_integer_with_precision (this, *text->m_args_ptr, precision, unsigned, "u"); break; case 'f': - pp_double (pp, va_arg (*text->m_args_ptr, double)); + pp_double (this, va_arg (*text->m_args_ptr, double)); break; case 'Z': @@ -1660,11 +1684,11 @@ pp_format (pretty_printer *pp, for (unsigned i = 0; i < len; ++i) { - pp_scalar (pp, "%i", v[i]); + pp_scalar (this, "%i", v[i]); if (i < len - 1) { - pp_comma (pp); - pp_space (pp); + pp_comma (this); + pp_space (this); } } break; @@ -1672,10 +1696,10 @@ pp_format (pretty_printer *pp, case 'x': if (wide) - pp_scalar (pp, HOST_WIDE_INT_PRINT_HEX, + pp_scalar (this, HOST_WIDE_INT_PRINT_HEX, va_arg (*text->m_args_ptr, unsigned HOST_WIDE_INT)); else - pp_integer_with_precision (pp, *text->m_args_ptr, precision, + pp_integer_with_precision (this, *text->m_args_ptr, precision, unsigned, "x"); break; @@ -1714,7 +1738,7 @@ pp_format (pretty_printer *pp, Negative precision is treated as if it were omitted. */ size_t len = n < 0 ? strlen (s) : strnlen (s, n); - pp_append_text (pp, s, s + len); + pp_append_text (this, s, s + len); } break; @@ -1725,16 +1749,16 @@ pp_format (pretty_printer *pp, = va_arg (*text->m_args_ptr, diagnostic_event_id_ptr); gcc_assert (event_id->known_p ()); - pp_string (pp, colorize_start (pp_show_color (pp), "path")); - pp_character (pp, '('); - pp_decimal_int (pp, event_id->one_based ()); - pp_character (pp, ')'); - pp_string (pp, colorize_stop (pp_show_color (pp))); + pp_string (this, colorize_start (m_show_color, "path")); + pp_character (this, '('); + pp_decimal_int (this, event_id->one_based ()); + pp_character (this, ')'); + pp_string (this, colorize_stop (m_show_color)); } break; case '{': - pp_begin_url (pp, va_arg (*text->m_args_ptr, const char *)); + begin_url (va_arg (*text->m_args_ptr, const char *)); break; default: @@ -1746,18 +1770,19 @@ pp_format (pretty_printer *pp, potentially disable printing of the closing quote (e.g. when printing "'TYPEDEF' aka 'TYPE'" in the C family of frontends). */ - gcc_assert (pp_format_decoder (pp)); - ok = pp_format_decoder (pp) (pp, text, p, - precision, wide, plus, hash, "e, - formatters[argno]); + gcc_assert (pp_format_decoder (this)); + ok = m_format_decoder (this, text, p, + precision, wide, plus, hash, "e, + formatters[argno]); gcc_assert (ok); } } if (quote) { - on_end_quote (pp, *buffer, chunk, urlifier); - pp_end_quote (pp, pp_show_color (pp)); + buffer->cur_chunk_array->on_end_quote (this, *buffer, + chunk, urlifier); + pp_end_quote (this, m_show_color); } obstack_1grow (&buffer->chunk_obstack, '\0'); @@ -1770,14 +1795,14 @@ pp_format (pretty_printer *pp, /* If the client supplied a postprocessing object, call its "handle" hook here. */ - if (pp->m_format_postprocessor) - pp->m_format_postprocessor->handle (pp); + if (m_format_postprocessor) + m_format_postprocessor->handle (this); /* Revert to normal obstack and wrapping mode. */ buffer->obstack = &buffer->formatted_obstack; buffer->line_length = old_line_length; - pp_wrapping_mode (pp) = old_wrapping_mode; - pp_clear_state (pp); + pp_wrapping_mode (this) = old_wrapping_mode; + clear_state (); } struct auto_obstack @@ -1840,8 +1865,9 @@ quoting_info::handle_phase_3 (pretty_printer *pp, { unsigned int chunk; output_buffer * const buffer = pp_buffer (pp); - struct chunk_info *chunk_array = buffer->cur_chunk_array; - const char **args = chunk_array->args; + chunk_info *chunk_array = buffer->cur_chunk_array; + const char * const *args = chunk_array->get_args (); + quoting_info *quoting = chunk_array->get_quoting_info (); /* We need to construct the string into an intermediate buffer for this case, since using pp_string can introduce prefixes @@ -1856,9 +1882,9 @@ quoting_info::handle_phase_3 (pretty_printer *pp, correspond to. */ size_t start_of_run_byte_offset = 0; std::vector::const_iterator iter_run - = buffer->cur_chunk_array->m_quotes->m_phase_3_quotes.begin (); + = quoting->m_phase_3_quotes.begin (); std::vector::const_iterator end_runs - = buffer->cur_chunk_array->m_quotes->m_phase_3_quotes.end (); + = quoting->m_phase_3_quotes.end (); for (chunk = 0; args[chunk]; chunk++) { size_t start_of_chunk_idx = combined_buf.object_size (); @@ -1913,8 +1939,9 @@ pp_output_formatted_text (pretty_printer *pp, { unsigned int chunk; output_buffer * const buffer = pp_buffer (pp); - struct chunk_info *chunk_array = buffer->cur_chunk_array; - const char **args = chunk_array->args; + chunk_info *chunk_array = buffer->cur_chunk_array; + const char * const *args = chunk_array->get_args (); + quoting_info *quoting = chunk_array->get_quoting_info (); gcc_assert (buffer->obstack == &buffer->formatted_obstack); @@ -1923,19 +1950,15 @@ pp_output_formatted_text (pretty_printer *pp, /* If we have any deferred urlification, handle it now. */ if (urlifier - && pp->url_format != URL_FORMAT_NONE - && buffer->cur_chunk_array->m_quotes - && buffer->cur_chunk_array->m_quotes->has_phase_3_quotes_p ()) - buffer->cur_chunk_array->m_quotes->handle_phase_3 (pp, *urlifier); + && pp->supports_urls_p () + && quoting + && quoting->has_phase_3_quotes_p ()) + quoting->handle_phase_3 (pp, *urlifier); else for (chunk = 0; args[chunk]; chunk++) pp_string (pp, args[chunk]); - /* Deallocate the chunk structure and everything after it (i.e. the - associated series of formatted strings). */ - delete buffer->cur_chunk_array->m_quotes; - buffer->cur_chunk_array = chunk_array->prev; - obstack_free (&buffer->chunk_obstack, chunk_array); + chunk_array->pop_from_output_buffer (*buffer); } /* Helper subroutine of output_verbatim and verbatim. Do the appropriate @@ -1959,8 +1982,8 @@ pp_format_verbatim (pretty_printer *pp, text_info *text) void pp_flush (pretty_printer *pp) { - pp_clear_state (pp); - if (!pp->buffer->flush_p) + pp->clear_state (); + if (!pp_buffer (pp)->flush_p) return; pp_write_text_to_stream (pp); fflush (pp_buffer (pp)->stream); @@ -1971,7 +1994,7 @@ pp_flush (pretty_printer *pp) void pp_really_flush (pretty_printer *pp) { - pp_clear_state (pp); + pp->clear_state (); pp_write_text_to_stream (pp); fflush (pp_buffer (pp)->stream); } @@ -1983,7 +2006,7 @@ void pp_set_line_maximum_length (pretty_printer *pp, int length) { pp_line_cutoff (pp) = length; - pp_set_real_maximum_length (pp); + pp->set_real_maximum_length (); } /* Clear PRETTY-PRINTER output area text info. */ @@ -1999,13 +2022,13 @@ pp_clear_output_area (pretty_printer *pp) will eventually be free-ed. */ void -pp_set_prefix (pretty_printer *pp, char *prefix) +pretty_printer::set_prefix (char *prefix) { - free (pp->prefix); - pp->prefix = prefix; - pp_set_real_maximum_length (pp); - pp->emitted_prefix = false; - pp_indentation (pp) = 0; + free (m_prefix); + m_prefix = prefix; + set_real_maximum_length (); + m_emitted_prefix = false; + pp_indentation (this) = 0; } /* Take ownership of PP's prefix, setting it to NULL. @@ -2015,8 +2038,8 @@ pp_set_prefix (pretty_printer *pp, char *prefix) char * pp_take_prefix (pretty_printer *pp) { - char *result = pp->prefix; - pp->prefix = NULL; + char *result = pp->m_prefix; + pp->m_prefix = nullptr; return result; } @@ -2024,39 +2047,39 @@ pp_take_prefix (pretty_printer *pp) void pp_destroy_prefix (pretty_printer *pp) { - if (pp->prefix != NULL) + if (pp->m_prefix) { - free (pp->prefix); - pp->prefix = NULL; + free (pp->m_prefix); + pp->m_prefix = nullptr; } } -/* Write out PRETTY-PRINTER's prefix. */ +/* Write out this pretty_printer's prefix. */ void -pp_emit_prefix (pretty_printer *pp) +pretty_printer::emit_prefix () { - if (pp->prefix != NULL) + if (m_prefix) { - switch (pp_prefixing_rule (pp)) + switch (pp_prefixing_rule (this)) { default: case DIAGNOSTICS_SHOW_PREFIX_NEVER: break; case DIAGNOSTICS_SHOW_PREFIX_ONCE: - if (pp->emitted_prefix) + if (m_emitted_prefix) { - pp_indent (pp); + pp_indent (this); break; } - pp_indentation (pp) += 3; + pp_indentation (this) += 3; /* Fall through. */ case DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE: { - int prefix_length = strlen (pp->prefix); - pp_append_r (pp, pp->prefix, prefix_length); - pp->emitted_prefix = true; + int prefix_length = strlen (m_prefix); + pp_append_r (this, m_prefix, prefix_length); + m_emitted_prefix = true; } break; } @@ -2066,19 +2089,19 @@ pp_emit_prefix (pretty_printer *pp) /* Construct a PRETTY-PRINTER of MAXIMUM_LENGTH characters per line. */ pretty_printer::pretty_printer (int maximum_length) - : buffer (new (XCNEW (output_buffer)) output_buffer ()), - prefix (), - padding (pp_none), - maximum_length (), - indent_skip (), - wrapping (), - format_decoder (), + : m_buffer (new (XCNEW (output_buffer)) output_buffer ()), + m_prefix (nullptr), + m_padding (pp_none), + m_maximum_length (0), + m_indent_skip (0), + m_wrapping (), + m_format_decoder (nullptr), m_format_postprocessor (NULL), - emitted_prefix (), - need_newline (), - translate_identifiers (true), - show_color (), - url_format (URL_FORMAT_NONE), + m_emitted_prefix (false), + m_need_newline (false), + m_translate_identifiers (true), + m_show_color (false), + m_url_format (URL_FORMAT_NONE), m_skipping_null_url (false) { pp_line_cutoff (this) = maximum_length; @@ -2090,22 +2113,22 @@ pretty_printer::pretty_printer (int maximum_length) /* Copy constructor for pretty_printer. */ pretty_printer::pretty_printer (const pretty_printer &other) -: buffer (new (XCNEW (output_buffer)) output_buffer ()), - prefix (), - padding (other.padding), - maximum_length (other.maximum_length), - indent_skip (other.indent_skip), - wrapping (other.wrapping), - format_decoder (other.format_decoder), +: m_buffer (new (XCNEW (output_buffer)) output_buffer ()), + m_prefix (nullptr), + m_padding (other.m_padding), + m_maximum_length (other.m_maximum_length), + m_indent_skip (other.m_indent_skip), + m_wrapping (other.m_wrapping), + m_format_decoder (other.m_format_decoder), m_format_postprocessor (NULL), - emitted_prefix (other.emitted_prefix), - need_newline (other.need_newline), - translate_identifiers (other.translate_identifiers), - show_color (other.show_color), - url_format (other.url_format), + m_emitted_prefix (other.m_emitted_prefix), + m_need_newline (other.m_need_newline), + m_translate_identifiers (other.m_translate_identifiers), + m_show_color (other.m_show_color), + m_url_format (other.m_url_format), m_skipping_null_url (false) { - pp_line_cutoff (this) = maximum_length; + pp_line_cutoff (this) = m_maximum_length; /* By default, we emit prefixes once per message. */ pp_prefixing_rule (this) = pp_prefixing_rule (&other); pp_set_prefix (this, NULL); @@ -2118,9 +2141,9 @@ pretty_printer::~pretty_printer () { if (m_format_postprocessor) delete m_format_postprocessor; - buffer->~output_buffer (); - XDELETE (buffer); - free (prefix); + m_buffer->~output_buffer (); + XDELETE (m_buffer); + free (m_prefix); } /* Base class implementation of pretty_printer::clone vfunc. */ @@ -2142,7 +2165,7 @@ pp_append_text (pretty_printer *pp, const char *start, const char *end) /* Emit prefix and skip whitespace if we're starting a new line. */ if (pp_buffer (pp)->line_length == 0) { - pp_emit_prefix (pp); + pp->emit_prefix (); if (pp_is_wrapping_line (pp)) while (start != end && *start == ' ') ++start; @@ -2169,12 +2192,11 @@ pp_last_position_in_text (const pretty_printer *pp) /* Return the amount of characters PRETTY-PRINTER can accept to make a full line. Meaningful only in line-wrapping mode. */ int -pp_remaining_character_count_for_line (pretty_printer *pp) +pretty_printer::remaining_character_count_for_line () { - return pp->maximum_length - pp_buffer (pp)->line_length; + return m_maximum_length - pp_buffer (this)->line_length; } - /* Format a message into BUFFER a la printf. */ void pp_printf (pretty_printer *pp, const char *msg, ...) @@ -2219,7 +2241,7 @@ pp_character (pretty_printer *pp, int c) if (pp_is_wrapping_line (pp) /* If printing UTF-8, don't wrap in the middle of a sequence. */ && (((unsigned int) c) & 0xC0) != 0x80 - && pp_remaining_character_count_for_line (pp) <= 0) + && pp->remaining_character_count_for_line () <= 0) { pp_newline (pp); if (ISSPACE (c)) @@ -2319,12 +2341,12 @@ pp_quoted_string (pretty_printer *pp, const char *str, size_t n /* = -1 */) /* Maybe print out a whitespace if needed. */ void -pp_maybe_space (pretty_printer *pp) +pretty_printer::maybe_space () { - if (pp->padding != pp_none) + if (m_padding != pp_none) { - pp_space (pp); - pp->padding = pp_none; + pp_space (this); + m_padding = pp_none; } } @@ -2625,28 +2647,28 @@ identifier_to_locale (const char *ident) for the given URL. */ void -pp_begin_url (pretty_printer *pp, const char *url) +pretty_printer::begin_url (const char *url) { if (!url) { /* Handle null URL by skipping all output here, and in the next pp_end_url. */ - pp->m_skipping_null_url = true; + m_skipping_null_url = true; return; } - switch (pp->url_format) + switch (m_url_format) { case URL_FORMAT_NONE: break; case URL_FORMAT_ST: - pp_string (pp, "\33]8;;"); - pp_string (pp, url); - pp_string (pp, "\33\\"); + pp_string (this, "\33]8;;"); + pp_string (this, url); + pp_string (this, "\33\\"); break; case URL_FORMAT_BEL: - pp_string (pp, "\33]8;;"); - pp_string (pp, url); - pp_string (pp, "\a"); + pp_string (this, "\33]8;;"); + pp_string (this, url); + pp_string (this, "\a"); break; default: gcc_unreachable (); @@ -2659,7 +2681,7 @@ pp_begin_url (pretty_printer *pp, const char *url) static const char * get_end_url_string (pretty_printer *pp) { - switch (pp->url_format) + switch (pp->get_url_format ()) { case URL_FORMAT_NONE: return ""; @@ -2675,17 +2697,17 @@ get_end_url_string (pretty_printer *pp) /* If URL-printing is enabled, write a "close URL" escape sequence to PP. */ void -pp_end_url (pretty_printer *pp) +pretty_printer::end_url () { - if (pp->m_skipping_null_url) + if (m_skipping_null_url) { /* We gracefully handle pp_begin_url (NULL) by omitting output for both begin and end. Here we handle the latter. */ - pp->m_skipping_null_url = false; + m_skipping_null_url = false; return; } - if (pp->url_format != URL_FORMAT_NONE) - pp_string (pp, get_end_url_string (pp)); + if (m_url_format != URL_FORMAT_NONE) + pp_string (this, get_end_url_string (this)); } #if CHECKING_P @@ -2925,7 +2947,7 @@ class test_pretty_printer : public pretty_printer int max_line_length) { pp_set_prefix (this, xstrdup ("PREFIX: ")); - wrapping.rule = rule; + pp_prefixing_rule (this) = rule; pp_set_line_maximum_length (this, max_line_length); } }; @@ -3018,7 +3040,7 @@ test_urls () { { pretty_printer pp; - pp.url_format = URL_FORMAT_NONE; + pp.set_url_format (URL_FORMAT_NONE); pp_begin_url (&pp, "http://example.com"); pp_string (&pp, "This is a link"); pp_end_url (&pp); @@ -3028,7 +3050,7 @@ test_urls () { pretty_printer pp; - pp.url_format = URL_FORMAT_ST; + pp.set_url_format (URL_FORMAT_ST); pp_begin_url (&pp, "http://example.com"); pp_string (&pp, "This is a link"); pp_end_url (&pp); @@ -3038,7 +3060,7 @@ test_urls () { pretty_printer pp; - pp.url_format = URL_FORMAT_BEL; + pp.set_url_format (URL_FORMAT_BEL); pp_begin_url (&pp, "http://example.com"); pp_string (&pp, "This is a link"); pp_end_url (&pp); @@ -3054,7 +3076,7 @@ test_null_urls () { { pretty_printer pp; - pp.url_format = URL_FORMAT_NONE; + pp.set_url_format (URL_FORMAT_NONE); pp_begin_url (&pp, nullptr); pp_string (&pp, "This isn't a link"); pp_end_url (&pp); @@ -3064,7 +3086,7 @@ test_null_urls () { pretty_printer pp; - pp.url_format = URL_FORMAT_ST; + pp.set_url_format (URL_FORMAT_ST); pp_begin_url (&pp, nullptr); pp_string (&pp, "This isn't a link"); pp_end_url (&pp); @@ -3074,7 +3096,7 @@ test_null_urls () { pretty_printer pp; - pp.url_format = URL_FORMAT_BEL; + pp.set_url_format (URL_FORMAT_BEL); pp_begin_url (&pp, nullptr); pp_string (&pp, "This isn't a link"); pp_end_url (&pp); @@ -3122,7 +3144,7 @@ test_urlification () { { pretty_printer pp; - pp.url_format = URL_FORMAT_NONE; + pp.set_url_format (URL_FORMAT_NONE); pp_printf_with_urlifier (&pp, &urlifier, "foo %<-foption%> % bar"); ASSERT_STREQ ("foo `-foption' `unrecognized' bar", @@ -3130,7 +3152,7 @@ test_urlification () } { pretty_printer pp; - pp.url_format = URL_FORMAT_ST; + pp.set_url_format (URL_FORMAT_ST); pp_printf_with_urlifier (&pp, &urlifier, "foo %<-foption%> % bar"); ASSERT_STREQ @@ -3140,7 +3162,7 @@ test_urlification () } { pretty_printer pp; - pp.url_format = URL_FORMAT_BEL; + pp.set_url_format (URL_FORMAT_BEL); pp_printf_with_urlifier (&pp, &urlifier, "foo %<-foption%> % bar"); ASSERT_STREQ @@ -3153,7 +3175,7 @@ test_urlification () /* Use of "%qs". */ { pretty_printer pp; - pp.url_format = URL_FORMAT_ST; + pp.set_url_format (URL_FORMAT_ST); pp_printf_with_urlifier (&pp, &urlifier, "foo %qs %qs bar", "-foption", "unrecognized"); @@ -3167,7 +3189,7 @@ test_urlification () a mixture of phase 1 and phase 2. */ { pretty_printer pp; - pp.url_format = URL_FORMAT_ST; + pp.set_url_format (URL_FORMAT_ST); pp_printf_with_urlifier (&pp, &urlifier, "foo %<-f%s%> bar", "option"); @@ -3180,7 +3202,7 @@ test_urlification () quoted region. */ { pretty_printer pp; - pp.url_format = URL_FORMAT_ST; + pp.set_url_format (URL_FORMAT_ST); pp_printf_with_urlifier (&pp, &urlifier, "foo %<-f%sion%> bar %<-f%sion%> baz", "opt", "opt"); @@ -3192,7 +3214,7 @@ test_urlification () /* Likewise. */ { pretty_printer pp; - pp.url_format = URL_FORMAT_ST; + pp.set_url_format (URL_FORMAT_ST); pp_printf_with_urlifier (&pp, &urlifier, "foo %<%sption%> bar %<-f%sion%> baz", "-fo", "opt"); @@ -3205,7 +3227,7 @@ test_urlification () between a mixture of phase 1 and multiple phase 2. */ { pretty_printer pp; - pp.url_format = URL_FORMAT_ST; + pp.set_url_format (URL_FORMAT_ST); pp_printf_with_urlifier (&pp, &urlifier, "foo %<-f%s%s%> bar", "opt", "ion"); @@ -3217,7 +3239,7 @@ test_urlification () /* Mixed usage of %< and %s with a prefix. */ { pretty_printer pp; - pp.url_format = URL_FORMAT_ST; + pp.set_url_format (URL_FORMAT_ST); pp_set_prefix (&pp, xstrdup ("PREFIX")); pp_printf_with_urlifier (&pp, &urlifier, "foo %<-f%s%> bar", @@ -3230,7 +3252,7 @@ test_urlification () /* Example of mixed %< and %s with numbered args. */ { pretty_printer pp; - pp.url_format = URL_FORMAT_ST; + pp.set_url_format (URL_FORMAT_ST); pp_printf_with_urlifier (&pp, &urlifier, "foo %<-f%2$st%1$sn%> bar", "io", "op"); diff --git a/gcc/pretty-print.h b/gcc/pretty-print.h index 14a225eefe069..b41d3ce31d225 100644 --- a/gcc/pretty-print.h +++ b/gcc/pretty-print.h @@ -70,16 +70,38 @@ enum diagnostic_prefixing_rule_t }; class quoting_info; +class output_buffer; +class urlifier; /* The chunk_info data structure forms a stack of the results from the first phase of formatting (pp_format) which have not yet been output (pp_output_formatted_text). A stack is necessary because the diagnostic starter may decide to generate its own output by way of the formatter. */ -struct chunk_info +class chunk_info { + friend class pretty_printer; + +public: + const char * const *get_args () const { return m_args; } + quoting_info *get_quoting_info () const { return m_quotes; } + + void append_formatted_chunk (const char *content); + + void pop_from_output_buffer (output_buffer &buf); + +private: + void on_begin_quote (const output_buffer &buf, + unsigned chunk_idx, + const urlifier *urlifier); + + void on_end_quote (pretty_printer *pp, + output_buffer &buf, + unsigned chunk_idx, + const urlifier *urlifier); + /* Pointer to previous chunk on the stack. */ - struct chunk_info *prev; + chunk_info *m_prev; /* Array of chunks to output. Each chunk is a NUL-terminated string. In the first phase of formatting, even-numbered chunks are @@ -87,7 +109,7 @@ struct chunk_info The second phase replaces all odd-numbered chunks with formatted text, and the third phase simply emits all the chunks in sequence with appropriate line-wrapping. */ - const char *args[PP_NL_ARGMAX * 2]; + const char *m_args[PP_NL_ARGMAX * 2]; /* If non-null, information on quoted text runs within the chunks for use by a urlifier. */ @@ -114,7 +136,7 @@ class output_buffer struct obstack *obstack; /* Stack of chunk arrays. These come from the chunk_obstack. */ - struct chunk_info *cur_chunk_array; + chunk_info *cur_chunk_array; /* Where to output formatted text. */ FILE *stream; @@ -189,25 +211,12 @@ struct pp_wrapping_mode_t int line_cutoff; }; -/* Maximum characters per line in automatic line wrapping mode. - Zero means don't wrap lines. */ -#define pp_line_cutoff(PP) (PP)->wrapping.line_cutoff - -/* Prefixing rule used in formatting a diagnostic message. */ -#define pp_prefixing_rule(PP) (PP)->wrapping.rule - -/* Get or set the wrapping mode as a single entity. */ -#define pp_wrapping_mode(PP) (PP)->wrapping - /* The type of a hook that formats client-specific data onto a pretty_printer. A client-supplied formatter returns true if everything goes well, otherwise it returns false. */ typedef bool (*printer_fn) (pretty_printer *, text_info *, const char *, int, bool, bool, bool, bool *, const char **); -/* Client supplied function used to decode formats. */ -#define pp_format_decoder(PP) (PP)->format_decoder - /* Base class for an optional client-supplied object for doing additional processing between stages 2 and 3 of formatted printing. */ class format_postprocessor @@ -218,31 +227,51 @@ class format_postprocessor virtual void handle (pretty_printer *) = 0; }; -/* TRUE if a newline character needs to be added before further - formatting. */ -#define pp_needs_newline(PP) (PP)->need_newline +inline bool & pp_needs_newline (pretty_printer *pp); /* True if PRETTY-PRINTER is in line-wrapping mode. */ #define pp_is_wrapping_line(PP) (pp_line_cutoff (PP) > 0) -/* The amount of whitespace to be emitted when starting a new line. */ -#define pp_indentation(PP) (PP)->indent_skip - -/* True if identifiers are translated to the locale character set on - output. */ -#define pp_translate_identifiers(PP) (PP)->translate_identifiers - -/* True if colors should be shown. */ -#define pp_show_color(PP) (PP)->show_color +inline output_buffer *&pp_buffer (pretty_printer *pp); +inline output_buffer *pp_buffer (const pretty_printer *pp); +inline const char *pp_get_prefix (const pretty_printer *pp); +extern char *pp_take_prefix (pretty_printer *); +extern void pp_destroy_prefix (pretty_printer *); +inline int &pp_line_cutoff (pretty_printer *pp); +inline diagnostic_prefixing_rule_t &pp_prefixing_rule (pretty_printer *pp); +inline pp_wrapping_mode_t &pp_wrapping_mode (pretty_printer *pp); +inline int & pp_indentation (pretty_printer *pp); +inline bool & pp_translate_identifiers (pretty_printer *pp); +inline bool & pp_show_color (pretty_printer *pp); +inline printer_fn &pp_format_decoder (pretty_printer *pp); +inline format_postprocessor *& pp_format_postprocessor (pretty_printer *pp); class urlifier; /* The data structure that contains the bare minimum required to do - proper pretty-printing. Clients may derived from this structure + proper pretty-printing. Clients may derive from this structure and add additional fields they need. */ class pretty_printer { public: + friend inline output_buffer *&pp_buffer (pretty_printer *pp); + friend inline output_buffer *pp_buffer (const pretty_printer *pp); + friend inline const char *pp_get_prefix (const pretty_printer *pp); + friend char *pp_take_prefix (pretty_printer *); + friend void pp_destroy_prefix (pretty_printer *); + friend inline int &pp_line_cutoff (pretty_printer *pp); + friend inline diagnostic_prefixing_rule_t & + pp_prefixing_rule (pretty_printer *pp); + friend inline const diagnostic_prefixing_rule_t & + pp_prefixing_rule (const pretty_printer *pp); + friend inline pp_wrapping_mode_t &pp_wrapping_mode (pretty_printer *pp); + friend bool & pp_needs_newline (pretty_printer *pp); + friend int & pp_indentation (pretty_printer *pp); + friend bool & pp_translate_identifiers (pretty_printer *pp); + friend bool & pp_show_color (pretty_printer *pp); + friend printer_fn &pp_format_decoder (pretty_printer *pp); + friend format_postprocessor *& pp_format_postprocessor (pretty_printer *pp); + /* Default construct a pretty printer with specified maximum line length cut off limit. */ explicit pretty_printer (int = 0); @@ -252,25 +281,67 @@ class pretty_printer virtual pretty_printer *clone () const; + void set_output_stream (FILE *outfile) + { + m_buffer->stream = outfile; + } + + void set_prefix (char *prefix); + + void emit_prefix (); + + void format (text_info *text, + const urlifier *urlifier); + + void maybe_space (); + + bool supports_urls_p () const { return m_url_format != URL_FORMAT_NONE; } + diagnostic_url_format get_url_format () const { return m_url_format; } + void set_url_format (diagnostic_url_format url_format) + { + m_url_format = url_format; + } + + void begin_url (const char *url); + void end_url (); + + /* Switch into verbatim mode and return the old mode. */ + pp_wrapping_mode_t + set_verbatim_wrapping () + { + const pp_wrapping_mode_t oldmode = pp_wrapping_mode (this); + pp_line_cutoff (this) = 0; + pp_prefixing_rule (this) = DIAGNOSTICS_SHOW_PREFIX_NEVER; + return oldmode; + } + + void set_padding (pp_padding padding) { m_padding = padding; } + pp_padding get_padding () const { return m_padding; } + + void clear_state (); + void set_real_maximum_length (); + int remaining_character_count_for_line (); + +private: /* Where we print external representation of ENTITY. */ - output_buffer *buffer; + output_buffer *m_buffer; /* The prefix for each new line. If non-NULL, this is "owned" by the pretty_printer, and will eventually be free-ed. */ - char *prefix; + char *m_prefix; /* Where to put whitespace around the entity being formatted. */ - pp_padding padding; + pp_padding m_padding; /* The real upper bound of number of characters per line, taking into account the case of a very very looong prefix. */ - int maximum_length; + int m_maximum_length; /* Indentation count. */ - int indent_skip; + int m_indent_skip; /* Current wrapping mode. */ - pp_wrapping_mode_t wrapping; + pp_wrapping_mode_t m_wrapping; /* If non-NULL, this function formats a TEXT into the BUFFER. When called, TEXT->format_spec points to a format code. FORMAT_DECODER should call @@ -281,7 +352,7 @@ class pretty_printer returns, TEXT->format_spec should point to the last character processed. The QUOTE and BUFFER_PTR are passed in, to allow for deferring-handling of format codes (e.g. %H and %I in the C++ frontend). */ - printer_fn format_decoder; + printer_fn m_format_decoder; /* If non-NULL, this is called by pp_format once after all format codes have been processed, to allow for client-specific postprocessing. @@ -290,28 +361,112 @@ class pretty_printer format_postprocessor *m_format_postprocessor; /* Nonzero if current PREFIX was emitted at least once. */ - bool emitted_prefix; + bool m_emitted_prefix; /* Nonzero means one should emit a newline before outputting anything. */ - bool need_newline; + bool m_need_newline; /* Nonzero means identifiers are translated to the locale character set on output. */ - bool translate_identifiers; + bool m_translate_identifiers; /* Nonzero means that text should be colorized. */ - bool show_color; + bool m_show_color; /* Whether URLs should be emitted, and which terminator to use. */ - diagnostic_url_format url_format; + diagnostic_url_format m_url_format; - /* If true, then we've had a pp_begin_url (nullptr), and so the - next pp_end_url should be a no-op. */ + /* If true, then we've had a begin_url (nullptr), and so the + next end_url should be a no-op. */ bool m_skipping_null_url; }; +inline output_buffer *& +pp_buffer (pretty_printer *pp) +{ + return pp->m_buffer; +} + +inline output_buffer * +pp_buffer (const pretty_printer *pp) +{ + return pp->m_buffer; +} + inline const char * -pp_get_prefix (const pretty_printer *pp) { return pp->prefix; } +pp_get_prefix (const pretty_printer *pp) +{ + return pp->m_prefix; +} + +/* TRUE if a newline character needs to be added before further + formatting. */ +inline bool & +pp_needs_newline (pretty_printer *pp) +{ + return pp->m_need_newline; +} + +/* The amount of whitespace to be emitted when starting a new line. */ +inline int & +pp_indentation (pretty_printer *pp) +{ + return pp->m_indent_skip; +} + +/* True if identifiers are translated to the locale character set on + output. */ +inline bool & +pp_translate_identifiers (pretty_printer *pp) +{ + return pp->m_translate_identifiers; +} + +/* True if colors should be shown. */ +inline bool & +pp_show_color (pretty_printer *pp) +{ + return pp->m_show_color; +} + +inline printer_fn & +pp_format_decoder (pretty_printer *pp) +{ + return pp->m_format_decoder; +} + +inline format_postprocessor *& +pp_format_postprocessor (pretty_printer *pp) +{ + return pp->m_format_postprocessor; +} + +/* Maximum characters per line in automatic line wrapping mode. + Zero means don't wrap lines. */ +inline int & +pp_line_cutoff (pretty_printer *pp) +{ + return pp->m_wrapping.line_cutoff; +} + +/* Prefixing rule used in formatting a diagnostic message. */ +inline diagnostic_prefixing_rule_t & +pp_prefixing_rule (pretty_printer *pp) +{ + return pp->m_wrapping.rule; +} +inline const diagnostic_prefixing_rule_t & +pp_prefixing_rule (const pretty_printer *pp) +{ + return pp->m_wrapping.rule; +} + +/* Get or set the wrapping mode as a single entity. */ +inline pp_wrapping_mode_t & +pp_wrapping_mode (pretty_printer *pp) +{ + return pp->m_wrapping; +} #define pp_space(PP) pp_character (PP, ' ') #define pp_left_paren(PP) pp_character (PP, '(') @@ -375,17 +530,18 @@ pp_get_prefix (const pretty_printer *pp) { return pp->prefix; } : (ID))) -#define pp_buffer(PP) (PP)->buffer - extern void pp_set_line_maximum_length (pretty_printer *, int); -extern void pp_set_prefix (pretty_printer *, char *); -extern char *pp_take_prefix (pretty_printer *); -extern void pp_destroy_prefix (pretty_printer *); -extern int pp_remaining_character_count_for_line (pretty_printer *); +inline void pp_set_prefix (pretty_printer *pp, char *prefix) +{ + pp->set_prefix (prefix); +} extern void pp_clear_output_area (pretty_printer *); extern const char *pp_formatted_text (pretty_printer *); extern const char *pp_last_position_in_text (const pretty_printer *); -extern void pp_emit_prefix (pretty_printer *); +inline void pp_emit_prefix (pretty_printer *pp) +{ + pp->emit_prefix (); +} extern void pp_append_text (pretty_printer *, const char *, const char *); extern void pp_newline_and_flush (pretty_printer *); extern void pp_newline_and_indent (pretty_printer *, int); @@ -413,8 +569,11 @@ extern void pp_verbatim (pretty_printer *, const char *, ...) ATTRIBUTE_GCC_PPDIAG(2,3); extern void pp_flush (pretty_printer *); extern void pp_really_flush (pretty_printer *); -extern void pp_format (pretty_printer *, text_info *, - const urlifier * = nullptr); +inline void pp_format (pretty_printer *pp, text_info *text, + const urlifier *urlifier = nullptr) +{ + pp->format (text, urlifier); +} extern void pp_output_formatted_text (pretty_printer *, const urlifier * = nullptr); extern void pp_format_verbatim (pretty_printer *, text_info *); @@ -429,24 +588,32 @@ extern void pp_write_text_to_stream (pretty_printer *); extern void pp_write_text_as_dot_label_to_stream (pretty_printer *, bool); extern void pp_write_text_as_html_like_dot_to_stream (pretty_printer *pp); -extern void pp_maybe_space (pretty_printer *); +inline void pp_maybe_space (pretty_printer *pp) +{ + pp->maybe_space (); +} extern void pp_begin_quote (pretty_printer *, bool); extern void pp_end_quote (pretty_printer *, bool); -extern void pp_begin_url (pretty_printer *pp, const char *url); -extern void pp_end_url (pretty_printer *pp); +inline void +pp_begin_url (pretty_printer *pp, const char *url) +{ + pp->begin_url (url); +} + +inline void +pp_end_url (pretty_printer *pp) +{ + pp->end_url (); +} /* Switch into verbatim mode and return the old mode. */ inline pp_wrapping_mode_t -pp_set_verbatim_wrapping_ (pretty_printer *pp) +pp_set_verbatim_wrapping (pretty_printer *pp) { - pp_wrapping_mode_t oldmode = pp_wrapping_mode (pp); - pp_line_cutoff (pp) = 0; - pp_prefixing_rule (pp) = DIAGNOSTICS_SHOW_PREFIX_NEVER; - return oldmode; + return pp->set_verbatim_wrapping (); } -#define pp_set_verbatim_wrapping(PP) pp_set_verbatim_wrapping_ (PP) extern const char *identifier_to_locale (const char *); extern void *(*identifier_to_locale_alloc) (size_t); diff --git a/gcc/print-rtl.cc b/gcc/print-rtl.cc index ecb689f56a945..69c2e196e041b 100644 --- a/gcc/print-rtl.cc +++ b/gcc/print-rtl.cc @@ -2070,7 +2070,7 @@ void dump_value_slim (FILE *f, const_rtx x, int verbose) { pretty_printer rtl_slim_pp; - rtl_slim_pp.buffer->stream = f; + rtl_slim_pp.set_output_stream (f); print_value (&rtl_slim_pp, x, verbose); pp_flush (&rtl_slim_pp); } @@ -2081,7 +2081,7 @@ void dump_insn_slim (FILE *f, const rtx_insn *x) { pretty_printer rtl_slim_pp; - rtl_slim_pp.buffer->stream = f; + rtl_slim_pp.set_output_stream (f); print_insn_with_notes (&rtl_slim_pp, x); pp_flush (&rtl_slim_pp); } @@ -2095,7 +2095,7 @@ dump_rtl_slim (FILE *f, const rtx_insn *first, const rtx_insn *last, { const rtx_insn *insn, *tail; pretty_printer rtl_slim_pp; - rtl_slim_pp.buffer->stream = f; + rtl_slim_pp.set_output_stream (f); tail = last ? NEXT_INSN (last) : NULL; for (insn = first; diff --git a/gcc/print-tree.cc b/gcc/print-tree.cc index 7d38ed631d738..0dda09a99e3f0 100644 --- a/gcc/print-tree.cc +++ b/gcc/print-tree.cc @@ -954,11 +954,11 @@ print_node (FILE *file, const char *prefix, tree node, int indent, indent_to (file, indent + 4); fprintf (file, "def_stmt "); { - pretty_printer buffer; - buffer.buffer->stream = file; - pp_gimple_stmt_1 (&buffer, SSA_NAME_DEF_STMT (node), indent + 4, + pretty_printer pp; + pp.set_output_stream (file); + pp_gimple_stmt_1 (&pp, SSA_NAME_DEF_STMT (node), indent + 4, TDF_NONE); - pp_flush (&buffer); + pp_flush (&pp); } indent_to (file, indent + 4); diff --git a/gcc/range-op.h b/gcc/range-op.h index 7fd7f0d5ce631..e415f87d7e64f 100644 --- a/gcc/range-op.h +++ b/gcc/range-op.h @@ -336,8 +336,8 @@ inline bool range_cast (vrange &r, tree type) { gcc_checking_assert (r.supports_type_p (type)); - Value_Range tmp (r); - Value_Range varying (type); + value_range tmp (r); + value_range varying (type); varying.set_varying (type); // Call op_convert, if it fails, the result is varying. if (!range_op_handler (CONVERT_EXPR).fold_range (r, type, tmp, varying)) @@ -352,10 +352,10 @@ range_cast (vrange &r, tree type) // ie for float to int. inline bool -range_cast (Value_Range &r, tree type) +range_cast (value_range &r, tree type) { - Value_Range tmp (r); - Value_Range varying (type); + value_range tmp (r); + value_range varying (type); varying.set_varying (type); // Ensure we are in the correct mode for the call to fold. diff --git a/gcc/rust/ChangeLog b/gcc/rust/ChangeLog index cb36a755ac892..7ba055f6c0fed 100644 --- a/gcc/rust/ChangeLog +++ b/gcc/rust/ChangeLog @@ -1,3 +1,8 @@ +2024-06-11 Arthur Cohen + + * Make-lang.in: Remove overazealous LIBS = -ldl -lpthread line, link + crab1 against CRAB1_LIBS. + 2024-04-15 Thomas Schwinge * Make-lang.in (RUST_LIBDEPS): Inline into single user. diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in index 8db0416361839..e437c32e3471c 100644 --- a/gcc/rust/Make-lang.in +++ b/gcc/rust/Make-lang.in @@ -210,8 +210,11 @@ rust_OBJS = $(RUST_ALL_OBJS) rust/rustspec.o LIBPROC_MACRO_INTERNAL = ../libgrust/libproc_macro_internal/libproc_macro_internal.a + +RUST_LIBDEPS = $(LIBDEPS) $(LIBPROC_MACRO_INTERNAL) + # The compiler itself is called crab1 -crab1$(exeext): $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(LIBDEPS) $(LIBPROC_MACRO_INTERNAL) $(rust.prev) +crab1$(exeext): $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(RUST_LIBDEPS) $(rust.prev) @$(call LINK_PROGRESS,$(INDEX.rust),start) +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(LIBS) $(LIBPROC_MACRO_INTERNAL) $(BACKENDLIBS) diff --git a/gcc/sched-rgn.cc b/gcc/sched-rgn.cc index eb75d1bdb260d..3d8cff76aaf95 100644 --- a/gcc/sched-rgn.cc +++ b/gcc/sched-rgn.cc @@ -2882,7 +2882,7 @@ dump_rgn_dependencies_dot (FILE *file) int bb; pretty_printer pp; - pp.buffer->stream = file; + pp.set_output_stream (file); pp_printf (&pp, "digraph SchedDG {\n"); for (bb = 0; bb < current_nr_blocks; ++bb) diff --git a/gcc/selftest-diagnostic-path.cc b/gcc/selftest-diagnostic-path.cc new file mode 100644 index 0000000000000..6d21f2e55999c --- /dev/null +++ b/gcc/selftest-diagnostic-path.cc @@ -0,0 +1,233 @@ +/* Concrete classes for selftests involving diagnostic paths. + Copyright (C) 2019-2024 Free Software Foundation, Inc. + Contributed by David Malcolm + +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 +. */ + + +#include "config.h" +#define INCLUDE_VECTOR +#include "system.h" +#include "coretypes.h" +#include "version.h" +#include "demangle.h" +#include "backtrace.h" +#include "diagnostic.h" +#include "selftest-diagnostic-path.h" + +#if CHECKING_P + +namespace selftest { + +/* class test_diagnostic_path : public diagnostic_path. */ + +test_diagnostic_path::test_diagnostic_path (pretty_printer *event_pp) +: m_event_pp (event_pp) +{ + add_thread ("main"); +} + +/* Implementation of diagnostic_path::num_events vfunc for + test_diagnostic_path: simply get the number of events in the vec. */ + +unsigned +test_diagnostic_path::num_events () const +{ + return m_events.length (); +} + +/* Implementation of diagnostic_path::get_event vfunc for + test_diagnostic_path: simply return the event in the vec. */ + +const diagnostic_event & +test_diagnostic_path::get_event (int idx) const +{ + return *m_events[idx]; +} + +unsigned +test_diagnostic_path::num_threads () const +{ + return m_threads.length (); +} + +const diagnostic_thread & +test_diagnostic_path::get_thread (diagnostic_thread_id_t idx) const +{ + return *m_threads[idx]; +} + +bool +test_diagnostic_path::same_function_p (int event_idx_a, + int event_idx_b) const +{ + const char *name_a = m_events[event_idx_a]->get_function_name (); + const char *name_b = m_events[event_idx_b]->get_function_name (); + + if (name_a && name_b) + return 0 == strcmp (name_a, name_b); + return name_a == name_b; +} + +diagnostic_thread_id_t +test_diagnostic_path::add_thread (const char *name) +{ + m_threads.safe_push (new test_diagnostic_thread (name)); + return m_threads.length () - 1; +} + +/* Add an event to this path at LOC within function FNDECL at + stack depth DEPTH. + + Use m_context's printer to format FMT, as the text of the new + event. + + Return the id of the new event. */ + +diagnostic_event_id_t +test_diagnostic_path::add_event (location_t loc, + const char *funcname, + int depth, + const char *fmt, ...) +{ + pretty_printer *pp = m_event_pp; + pp_clear_output_area (pp); + + rich_location rich_loc (line_table, UNKNOWN_LOCATION); + + va_list ap; + + va_start (ap, fmt); + + /* No localization is done on FMT. */ + text_info ti (fmt, &ap, 0, nullptr, &rich_loc); + pp_format (pp, &ti); + pp_output_formatted_text (pp); + + va_end (ap); + + test_diagnostic_event *new_event + = new test_diagnostic_event (loc, funcname, depth, pp_formatted_text (pp)); + m_events.safe_push (new_event); + + pp_clear_output_area (pp); + + return diagnostic_event_id_t (m_events.length () - 1); +} + +diagnostic_event_id_t +test_diagnostic_path::add_thread_event (diagnostic_thread_id_t thread_id, + location_t loc, + const char *funcname, + int depth, + const char *fmt, ...) +{ + pretty_printer *pp = m_event_pp; + pp_clear_output_area (pp); + + rich_location rich_loc (line_table, UNKNOWN_LOCATION); + + va_list ap; + + va_start (ap, fmt); + + /* No localization is done on FMT. */ + text_info ti (fmt, &ap, 0, nullptr, &rich_loc); + + pp_format (pp, &ti); + pp_output_formatted_text (pp); + + va_end (ap); + + test_diagnostic_event *new_event + = new test_diagnostic_event (loc, funcname, depth, pp_formatted_text (pp), + thread_id); + m_events.safe_push (new_event); + + pp_clear_output_area (pp); + + return diagnostic_event_id_t (m_events.length () - 1); +} + +/* Mark the most recent event on this path (which must exist) as being + connected to the next one to be added. */ + +void +test_diagnostic_path::connect_to_next_event () +{ + gcc_assert (m_events.length () > 0); + m_events[m_events.length () - 1]->connect_to_next_event (); +} + +void +test_diagnostic_path::add_entry (const char *callee_name, + int stack_depth, + diagnostic_thread_id_t thread_id) +{ + add_thread_event (thread_id, UNKNOWN_LOCATION, callee_name, stack_depth, + "entering %qs", callee_name); +} + +void +test_diagnostic_path::add_return (const char *caller_name, + int stack_depth, + diagnostic_thread_id_t thread_id) +{ + add_thread_event (thread_id, UNKNOWN_LOCATION, caller_name, stack_depth, + "returning to %qs", caller_name); +} + +void +test_diagnostic_path::add_call (const char *caller_name, + int caller_stack_depth, + const char *callee_name, + diagnostic_thread_id_t thread_id) +{ + add_thread_event (thread_id, UNKNOWN_LOCATION, + caller_name, caller_stack_depth, + "calling %qs", callee_name); + add_entry (callee_name, caller_stack_depth + 1, thread_id); +} + +/* struct test_diagnostic_event. */ + +/* test_diagnostic_event's ctor. */ + +test_diagnostic_event:: +test_diagnostic_event (location_t loc, + const char *funcname, + int depth, + const char *desc, + diagnostic_thread_id_t thread_id) +: m_loc (loc), + m_logical_loc (LOGICAL_LOCATION_KIND_FUNCTION, funcname), + m_depth (depth), m_desc (xstrdup (desc)), + m_connected_to_next_event (false), + m_thread_id (thread_id) +{ +} + +/* test_diagnostic_event's dtor. */ + +test_diagnostic_event::~test_diagnostic_event () +{ + free (m_desc); +} + +} // namespace selftest + +#endif /* #if CHECKING_P */ diff --git a/gcc/selftest-diagnostic-path.h b/gcc/selftest-diagnostic-path.h new file mode 100644 index 0000000000000..51786a0f58993 --- /dev/null +++ b/gcc/selftest-diagnostic-path.h @@ -0,0 +1,163 @@ +/* Concrete classes for selftests involving diagnostic paths. + Copyright (C) 2019-2024 Free Software Foundation, Inc. + Contributed by David Malcolm + +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 +. */ + +#ifndef GCC_SELFTEST_DIAGNOSTIC_PATH_H +#define GCC_SELFTEST_DIAGNOSTIC_PATH_H + +#include "diagnostic-path.h" +#include "selftest-logical-location.h" + +/* The selftest code should entirely disappear in a production + configuration, hence we guard all of it with #if CHECKING_P. */ + +#if CHECKING_P + +namespace selftest { + +/* Concrete subclasses of the abstract base classes + declared in diagnostic-path.h for use in selftests. + + This code should have no dependency on "tree". */ + +/* An implementation of diagnostic_event. */ + +class test_diagnostic_event : public diagnostic_event +{ + public: + test_diagnostic_event (location_t loc, const char *funcname, int depth, + const char *desc, + diagnostic_thread_id_t thread_id = 0); + ~test_diagnostic_event (); + + location_t get_location () const final override { return m_loc; } + int get_stack_depth () const final override { return m_depth; } + label_text get_desc (bool) const final override + { + return label_text::borrow (m_desc); + } + const logical_location *get_logical_location () const final override + { + if (m_logical_loc.get_name ()) + return &m_logical_loc; + else + return nullptr; + } + meaning get_meaning () const final override + { + return meaning (); + } + bool connect_to_next_event_p () const final override + { + return m_connected_to_next_event; + } + diagnostic_thread_id_t get_thread_id () const final override + { + return m_thread_id; + } + + void connect_to_next_event () + { + m_connected_to_next_event = true; + } + + const char *get_function_name () const + { + return m_logical_loc.get_name (); + } + + private: + location_t m_loc; + test_logical_location m_logical_loc; + int m_depth; + char *m_desc; // has been formatted; doesn't get i18n-ed + bool m_connected_to_next_event; + diagnostic_thread_id_t m_thread_id; +}; + +/* A simple implementation of diagnostic_thread. */ + +class test_diagnostic_thread : public diagnostic_thread +{ +public: + test_diagnostic_thread (const char *name) : m_name (name) {} + label_text get_name (bool) const final override + { + return label_text::borrow (m_name); + } + +private: + const char *m_name; // has been i18n-ed and formatted +}; + +/* A concrete subclass of diagnostic_path for implementing selftests + - a vector of test_diagnostic_event instances + - adds member functions for adding test event + - does no translation of its events + - has no dependency on "tree". */ + +class test_diagnostic_path : public diagnostic_path +{ + public: + test_diagnostic_path (pretty_printer *event_pp); + + unsigned num_events () const final override; + const diagnostic_event & get_event (int idx) const final override; + unsigned num_threads () const final override; + const diagnostic_thread & + get_thread (diagnostic_thread_id_t) const final override; + bool + same_function_p (int event_idx_a, + int event_idx_b) const final override; + + diagnostic_thread_id_t add_thread (const char *name); + + diagnostic_event_id_t add_event (location_t loc, const char *funcname, int depth, + const char *fmt, ...) + ATTRIBUTE_GCC_DIAG(5,6); + diagnostic_event_id_t + add_thread_event (diagnostic_thread_id_t thread_id, + location_t loc, const char *funcname, int depth, + const char *fmt, ...) + ATTRIBUTE_GCC_DIAG(6,7); + + void connect_to_next_event (); + + void add_entry (const char *callee_name, int stack_depth, + diagnostic_thread_id_t thread_id = 0); + void add_return (const char *caller_name, int stack_depth, + diagnostic_thread_id_t thread_id = 0); + void add_call (const char *caller_name, + int caller_stack_depth, + const char *callee_name, + diagnostic_thread_id_t thread_id = 0); + + private: + auto_delete_vec m_threads; + auto_delete_vec m_events; + + /* (for use by add_event). */ + pretty_printer *m_event_pp; +}; + +} // namespace selftest + +#endif /* #if CHECKING_P */ + +#endif /* ! GCC_SELFTEST_DIAGNOSTIC_PATH_H */ diff --git a/gcc/selftest-logical-location.cc b/gcc/selftest-logical-location.cc new file mode 100644 index 0000000000000..8017672afa7e3 --- /dev/null +++ b/gcc/selftest-logical-location.cc @@ -0,0 +1,71 @@ +/* Concrete subclass of logical_location for use in selftests. + Copyright (C) 2024 Free Software Foundation, Inc. + Contributed by David Malcolm . + +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 +. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "selftest-logical-location.h" + +#if CHECKING_P + +namespace selftest { + +/* class test_logical_location : public logical_location. */ + +test_logical_location::test_logical_location (enum logical_location_kind kind, + const char *name) +: m_kind (kind), + m_name (name) +{ +} + +const char * +test_logical_location::get_short_name () const +{ + return m_name; +} + +const char * +test_logical_location::get_name_with_scope () const +{ + return m_name; +} + +const char * +test_logical_location::get_internal_name () const +{ + return m_name; +} + +enum logical_location_kind +test_logical_location::get_kind () const +{ + return m_kind; +} + +label_text +test_logical_location::get_name_for_path_output () const +{ + return label_text::borrow (m_name); +} + +} // namespace selftest + +#endif /* #if CHECKING_P */ diff --git a/gcc/selftest-logical-location.h b/gcc/selftest-logical-location.h new file mode 100644 index 0000000000000..819e111851e4c --- /dev/null +++ b/gcc/selftest-logical-location.h @@ -0,0 +1,58 @@ +/* Concrete subclass of logical_location for use in selftests. + Copyright (C) 2024 Free Software Foundation, Inc. + Contributed by David Malcolm . + +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 +. */ + +#ifndef GCC_SELFTEST_LOGICAL_LOCATION_H +#define GCC_SELFTEST_LOGICAL_LOCATION_H + +#include "logical-location.h" + +/* The selftest code should entirely disappear in a production + configuration, hence we guard all of it with #if CHECKING_P. */ + +#if CHECKING_P + +namespace selftest { + +/* Concrete subclass of logical_location for use in selftests. */ + +class test_logical_location : public logical_location +{ +public: + test_logical_location (enum logical_location_kind kind, + const char *name); + virtual const char *get_short_name () const final override; + virtual const char *get_name_with_scope () const final override; + virtual const char *get_internal_name () const final override; + virtual enum logical_location_kind get_kind () const final override; + virtual label_text get_name_for_path_output () const final override; + + const char *get_name () const { return m_name; } + + private: + enum logical_location_kind m_kind; + const char *m_name; +}; + +} // namespace selftest + +#endif /* #if CHECKING_P */ + + +#endif /* GCC_SELFTEST_LOGICAL_LOCATION_H. */ diff --git a/gcc/selftest-run-tests.cc b/gcc/selftest-run-tests.cc index d8f5e4b34c68d..e6779206c4702 100644 --- a/gcc/selftest-run-tests.cc +++ b/gcc/selftest-run-tests.cc @@ -102,7 +102,8 @@ selftest::run_tests () spellcheck_cc_tests (); spellcheck_tree_cc_tests (); tree_cfg_cc_tests (); - tree_diagnostic_path_cc_tests (); + diagnostic_path_cc_tests (); + simple_diagnostic_path_cc_tests (); attribs_cc_tests (); /* This one relies on most of the above. */ diff --git a/gcc/selftest.h b/gcc/selftest.h index 9e294ad1e5f96..dcb1463ed906d 100644 --- a/gcc/selftest.h +++ b/gcc/selftest.h @@ -222,6 +222,7 @@ extern void cgraph_cc_tests (); extern void convert_cc_tests (); extern void diagnostic_color_cc_tests (); extern void diagnostic_format_json_cc_tests (); +extern void diagnostic_path_cc_tests (); extern void diagnostic_show_locus_cc_tests (); extern void digraph_cc_tests (); extern void dumpfile_cc_tests (); @@ -250,6 +251,7 @@ extern void read_rtl_function_cc_tests (); extern void rtl_tests_cc_tests (); extern void sbitmap_cc_tests (); extern void selftest_cc_tests (); +extern void simple_diagnostic_path_cc_tests (); extern void simplify_rtx_cc_tests (); extern void spellcheck_cc_tests (); extern void spellcheck_tree_cc_tests (); @@ -258,7 +260,6 @@ extern void sreal_cc_tests (); extern void store_merging_cc_tests (); extern void tree_cc_tests (); extern void tree_cfg_cc_tests (); -extern void tree_diagnostic_path_cc_tests (); extern void tristate_cc_tests (); extern void typed_splay_tree_cc_tests (); extern void vec_cc_tests (); diff --git a/gcc/simple-diagnostic-path.cc b/gcc/simple-diagnostic-path.cc new file mode 100644 index 0000000000000..7c47b83093433 --- /dev/null +++ b/gcc/simple-diagnostic-path.cc @@ -0,0 +1,237 @@ +/* Concrete classes for implementing diagnostic paths. + Copyright (C) 2019-2024 Free Software Foundation, Inc. + Contributed by David Malcolm + +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 +. */ + + +#include "config.h" +#define INCLUDE_MEMORY +#define INCLUDE_VECTOR +#include "system.h" +#include "coretypes.h" +#include "tree.h" +#include "version.h" +#include "demangle.h" +#include "intl.h" +#include "backtrace.h" +#include "diagnostic.h" +#include "simple-diagnostic-path.h" +#include "selftest.h" + +/* class simple_diagnostic_path : public diagnostic_path. */ + +simple_diagnostic_path::simple_diagnostic_path (pretty_printer *event_pp) +: m_event_pp (event_pp), + m_localize_events (true) +{ + add_thread ("main"); +} + +/* Implementation of diagnostic_path::num_events vfunc for + simple_diagnostic_path: simply get the number of events in the vec. */ + +unsigned +simple_diagnostic_path::num_events () const +{ + return m_events.length (); +} + +/* Implementation of diagnostic_path::get_event vfunc for + simple_diagnostic_path: simply return the event in the vec. */ + +const diagnostic_event & +simple_diagnostic_path::get_event (int idx) const +{ + return *m_events[idx]; +} + +unsigned +simple_diagnostic_path::num_threads () const +{ + return m_threads.length (); +} + +const diagnostic_thread & +simple_diagnostic_path::get_thread (diagnostic_thread_id_t idx) const +{ + return *m_threads[idx]; +} + +bool +simple_diagnostic_path::same_function_p (int event_idx_a, + int event_idx_b) const +{ + return (m_events[event_idx_a]->get_fndecl () + == m_events[event_idx_b]->get_fndecl ()); +} + +diagnostic_thread_id_t +simple_diagnostic_path::add_thread (const char *name) +{ + m_threads.safe_push (new simple_diagnostic_thread (name)); + return m_threads.length () - 1; +} + +/* Add an event to this path at LOC within function FNDECL at + stack depth DEPTH. + + Use m_context's printer to format FMT, as the text of the new + event. Localize FMT iff m_localize_events is set. + + Return the id of the new event. */ + +diagnostic_event_id_t +simple_diagnostic_path::add_event (location_t loc, tree fndecl, int depth, + const char *fmt, ...) +{ + pretty_printer *pp = m_event_pp; + pp_clear_output_area (pp); + + rich_location rich_loc (line_table, UNKNOWN_LOCATION); + + va_list ap; + + va_start (ap, fmt); + + text_info ti (m_localize_events ? _(fmt) : fmt, + &ap, 0, nullptr, &rich_loc); + pp_format (pp, &ti); + pp_output_formatted_text (pp); + + va_end (ap); + + simple_diagnostic_event *new_event + = new simple_diagnostic_event (loc, fndecl, depth, pp_formatted_text (pp)); + m_events.safe_push (new_event); + + pp_clear_output_area (pp); + + return diagnostic_event_id_t (m_events.length () - 1); +} + +diagnostic_event_id_t +simple_diagnostic_path::add_thread_event (diagnostic_thread_id_t thread_id, + location_t loc, + tree fndecl, + int depth, + const char *fmt, ...) +{ + pretty_printer *pp = m_event_pp; + pp_clear_output_area (pp); + + rich_location rich_loc (line_table, UNKNOWN_LOCATION); + + va_list ap; + + va_start (ap, fmt); + + text_info ti (_(fmt), &ap, 0, nullptr, &rich_loc); + + pp_format (pp, &ti); + pp_output_formatted_text (pp); + + va_end (ap); + + simple_diagnostic_event *new_event + = new simple_diagnostic_event (loc, fndecl, depth, pp_formatted_text (pp), + thread_id); + m_events.safe_push (new_event); + + pp_clear_output_area (pp); + + return diagnostic_event_id_t (m_events.length () - 1); +} + +/* Mark the most recent event on this path (which must exist) as being + connected to the next one to be added. */ + +void +simple_diagnostic_path::connect_to_next_event () +{ + gcc_assert (m_events.length () > 0); + m_events[m_events.length () - 1]->connect_to_next_event (); +} + +/* struct simple_diagnostic_event. */ + +/* simple_diagnostic_event's ctor. */ + +simple_diagnostic_event:: +simple_diagnostic_event (location_t loc, + tree fndecl, + int depth, + const char *desc, + diagnostic_thread_id_t thread_id) +: m_loc (loc), m_fndecl (fndecl), m_logical_loc (fndecl), + m_depth (depth), m_desc (xstrdup (desc)), + m_connected_to_next_event (false), + m_thread_id (thread_id) +{ +} + +/* simple_diagnostic_event's dtor. */ + +simple_diagnostic_event::~simple_diagnostic_event () +{ + free (m_desc); +} + +#if CHECKING_P + +namespace selftest { + +static void +test_intraprocedural_path (pretty_printer *event_pp) +{ + tree fntype_void_void + = build_function_type_array (void_type_node, 0, NULL); + tree fndecl_foo = build_fn_decl ("foo", fntype_void_void); + + simple_diagnostic_path path (event_pp); + path.add_event (UNKNOWN_LOCATION, fndecl_foo, 0, "first %qs", "free"); + path.add_event (UNKNOWN_LOCATION, fndecl_foo, 0, "double %qs", "free"); + + ASSERT_EQ (path.num_events (), 2); + ASSERT_EQ (path.num_threads (), 1); + ASSERT_FALSE (path.interprocedural_p ()); + ASSERT_STREQ (path.get_event (0).get_desc (false).get (), "first `free'"); + ASSERT_STREQ (path.get_event (1).get_desc (false).get (), "double `free'"); +} + +/* Run all of the selftests within this file. */ + +void +simple_diagnostic_path_cc_tests () +{ + /* In a few places we use the global dc's printer to determine + colorization so ensure this off during the tests. */ + const bool saved_show_color = pp_show_color (global_dc->printer); + pp_show_color (global_dc->printer) = false; + + auto_fix_quotes fix_quotes; + std::unique_ptr event_pp + = std::unique_ptr (global_dc->printer->clone ()); + + test_intraprocedural_path (event_pp.get ()); + + pp_show_color (global_dc->printer) = saved_show_color; +} + +} // namespace selftest + +#endif /* #if CHECKING_P */ diff --git a/gcc/simple-diagnostic-path.h b/gcc/simple-diagnostic-path.h new file mode 100644 index 0000000000000..5147df5185bbd --- /dev/null +++ b/gcc/simple-diagnostic-path.h @@ -0,0 +1,139 @@ +/* Concrete classes for implementing diagnostic paths. + Copyright (C) 2019-2024 Free Software Foundation, Inc. + Contributed by David Malcolm + +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 +. */ + +#ifndef GCC_SIMPLE_DIAGNOSTIC_PATH_H +#define GCC_SIMPLE_DIAGNOSTIC_PATH_H + +#include "diagnostic-path.h" +#include "tree-logical-location.h" + +/* Concrete subclasses of the abstract base classes + declared in diagnostic-path.h. */ + +/* A simple implementation of diagnostic_event. */ + +class simple_diagnostic_event : public diagnostic_event +{ + public: + simple_diagnostic_event (location_t loc, tree fndecl, int depth, + const char *desc, + diagnostic_thread_id_t thread_id = 0); + ~simple_diagnostic_event (); + + location_t get_location () const final override { return m_loc; } + int get_stack_depth () const final override { return m_depth; } + label_text get_desc (bool) const final override + { + return label_text::borrow (m_desc); + } + const logical_location *get_logical_location () const final override + { + if (m_fndecl) + return &m_logical_loc; + else + return nullptr; + } + meaning get_meaning () const final override + { + return meaning (); + } + bool connect_to_next_event_p () const final override + { + return m_connected_to_next_event; + } + diagnostic_thread_id_t get_thread_id () const final override + { + return m_thread_id; + } + + void connect_to_next_event () + { + m_connected_to_next_event = true; + } + + tree get_fndecl () const { return m_fndecl; } + + private: + location_t m_loc; + tree m_fndecl; + tree_logical_location m_logical_loc; + int m_depth; + char *m_desc; // has been i18n-ed and formatted + bool m_connected_to_next_event; + diagnostic_thread_id_t m_thread_id; +}; + +/* A simple implementation of diagnostic_thread. */ + +class simple_diagnostic_thread : public diagnostic_thread +{ +public: + simple_diagnostic_thread (const char *name) : m_name (name) {} + label_text get_name (bool) const final override + { + return label_text::borrow (m_name); + } + +private: + const char *m_name; // has been i18n-ed and formatted +}; + +/* A simple implementation of diagnostic_path, as a vector of + simple_diagnostic_event instances. */ + +class simple_diagnostic_path : public diagnostic_path +{ + public: + simple_diagnostic_path (pretty_printer *event_pp); + + unsigned num_events () const final override; + const diagnostic_event & get_event (int idx) const final override; + unsigned num_threads () const final override; + const diagnostic_thread & + get_thread (diagnostic_thread_id_t) const final override; + bool + same_function_p (int event_idx_a, + int event_idx_b) const final override; + + diagnostic_thread_id_t add_thread (const char *name); + + diagnostic_event_id_t add_event (location_t loc, tree fndecl, int depth, + const char *fmt, ...) + ATTRIBUTE_GCC_DIAG(5,6); + diagnostic_event_id_t + add_thread_event (diagnostic_thread_id_t thread_id, + location_t loc, tree fndecl, int depth, + const char *fmt, ...) + ATTRIBUTE_GCC_DIAG(6,7); + + void connect_to_next_event (); + + void disable_event_localization () { m_localize_events = false; } + + private: + auto_delete_vec m_threads; + auto_delete_vec m_events; + + /* (for use by add_event). */ + pretty_printer *m_event_pp; + bool m_localize_events; +}; + +#endif /* ! GCC_SIMPLE_DIAGNOSTIC_PATH_H */ diff --git a/gcc/simplify-rtx.cc b/gcc/simplify-rtx.cc index 9bc3ef9ad9fda..35ba54c629218 100644 --- a/gcc/simplify-rtx.cc +++ b/gcc/simplify-rtx.cc @@ -4072,9 +4072,11 @@ simplify_context::simplify_binary_operation_1 (rtx_code code, if (VECTOR_MODE_P (mode) && GET_CODE (op0) == ASHIFTRT && (CONST_INT_P (XEXP (op0, 1)) || (GET_CODE (XEXP (op0, 1)) == CONST_VECTOR - && CONST_VECTOR_DUPLICATE_P (XEXP (op0, 1)))) + && CONST_VECTOR_DUPLICATE_P (XEXP (op0, 1)) + && CONST_INT_P (XVECEXP (XEXP (op0, 1), 0, 0)))) && GET_CODE (op1) == CONST_VECTOR - && CONST_VECTOR_DUPLICATE_P (op1)) + && CONST_VECTOR_DUPLICATE_P (op1) + && CONST_INT_P (XVECEXP (op1, 0, 0))) { unsigned HOST_WIDE_INT shift_count = (CONST_INT_P (XEXP (op0, 1)) @@ -7735,6 +7737,11 @@ simplify_context::simplify_subreg (machine_mode outermode, rtx op, poly_uint64 innermostsize = GET_MODE_SIZE (innermostmode); rtx newx; + /* Make sure that the relationship between the two subregs is + known at compile time. */ + if (!ordered_p (outersize, innermostsize)) + return NULL_RTX; + if (outermode == innermostmode && known_eq (byte, 0U) && known_eq (SUBREG_BYTE (op), 0)) diff --git a/gcc/target.def b/gcc/target.def index 70070caebc768..e5a9b52676e4b 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -2783,6 +2783,16 @@ DEFHOOK rtx, (rtx_insn **prep_seq, rtx_insn **gen_seq, rtx prev, rtx_code cmp_code, tree op0, tree op1, rtx_code bit_code), NULL) +/* Return true if the target supports conditional compare. */ +DEFHOOK +(have_ccmp, + "This target hook returns true if the target supports conditional compare.\n\ +This target hook is required only when the ccmp support is conditionally\n\ +enabled, such as in response to command-line flags. The default implementation\n\ +returns true iff @code{TARGET_GEN_CCMP_FIRST} is defined.", + bool, (void), + default_have_ccmp) + /* Return a new value for loop unroll size. */ DEFHOOK (loop_unroll_adjust, diff --git a/gcc/targhooks.cc b/gcc/targhooks.cc index fb339bf75dd83..4f53257e55c03 100644 --- a/gcc/targhooks.cc +++ b/gcc/targhooks.cc @@ -1887,6 +1887,12 @@ default_have_conditional_execution (void) return HAVE_conditional_execution; } +bool +default_have_ccmp (void) +{ + return targetm.gen_ccmp_first != NULL; +} + /* By default we assume that c99 functions are present at the runtime, but sincos is not. */ bool diff --git a/gcc/targhooks.h b/gcc/targhooks.h index 85f3817c176e9..f53913ebdfadd 100644 --- a/gcc/targhooks.h +++ b/gcc/targhooks.h @@ -216,6 +216,7 @@ extern void default_addr_space_diagnose_usage (addr_space_t, location_t); extern rtx default_addr_space_convert (rtx, tree, tree); extern unsigned int default_case_values_threshold (void); extern bool default_have_conditional_execution (void); +extern bool default_have_ccmp (void); extern bool default_libc_has_function (enum function_class, tree); extern bool default_libc_has_fast_function (int fcode); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f2569929416d6..2ae5731931d92 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,1337 @@ +2024-06-18 Jeff Law + + * gcc.target/riscv/zbs-ext-2.c: Do not run for -Os. + +2024-06-18 David Malcolm + + * gcc.dg/plugin/diagnostic_plugin_test_paths.c: Include + "simple-diagnostic-path.h". + +2024-06-18 Richard Biener + + PR tree-optimization/115537 + * gcc.dg/vect/pr115537.c: New testcase. + +2024-06-18 Jeff Law + + * gcc.target/riscv/zbs-ext-2.c: New file. + +2024-06-18 Richard Sandiford + + PR target/115464 + * gcc.target/aarch64/sve/acle/general/pr115464_2.c: New test. + +2024-06-18 Martin Uecker + + PR c/115109 + * gcc.dg/pr115109.c: New test. + * gcc.dg/c23-tag-enum-6.c: New test. + * gcc.dg/c23-tag-enum-7.c: New test. + +2024-06-18 Richard Biener + + PR tree-optimization/111793 + * gcc.dg/vect/vect-simd-clone-21.c: New testcase. + +2024-06-18 Kewen Lin + + PR testsuite/114842 + * c-c++-common/pr72747-1.c: Replace powerpc_altivec_ok with + powerpc_altivec, move dg-options and dg-additional-options lines + before dg-require-effective-target lines when it doesn't cause + any side effect like note message. + * c-c++-common/pr72747-2.c: Likewise. + * g++.dg/torture/pr79905.C: Likewise. + * g++.target/powerpc/altivec-1.C: Likewise. + * g++.target/powerpc/altivec-10.C: Likewise. + * g++.target/powerpc/altivec-11.C: Likewise. + * g++.target/powerpc/altivec-12.C: Likewise. + * g++.target/powerpc/altivec-13.C: Likewise. + * g++.target/powerpc/altivec-14.C: Likewise. + * g++.target/powerpc/altivec-15.C: Likewise. + * g++.target/powerpc/altivec-16.C: Likewise. + * g++.target/powerpc/altivec-17.C: Likewise. + * g++.target/powerpc/altivec-18.C: Likewise. + * g++.target/powerpc/altivec-2.C: Likewise. + * g++.target/powerpc/altivec-4.C: Likewise. + * g++.target/powerpc/altivec-5.C: Likewise. + * g++.target/powerpc/altivec-6.C: Likewise. + * g++.target/powerpc/altivec-7.C: Likewise. + * g++.target/powerpc/altivec-8.C: Likewise. + * g++.target/powerpc/altivec-9.C: Likewise. + * g++.target/powerpc/altivec-cell-1.C: Likewise. + * g++.target/powerpc/altivec-cell-5.C: Likewise. + * g++.target/powerpc/altivec-types-1.C: Likewise. + * g++.target/powerpc/altivec-types-2.C: Likewise. + * g++.target/powerpc/altivec-types-3.C: Likewise. + * g++.target/powerpc/altivec-types-4.C: Likewise. + * gcc.target/powerpc/altivec-1-runnable.c: Likewise. + * gcc.target/powerpc/altivec-11.c: Likewise. + * gcc.target/powerpc/altivec-13.c: Likewise. + * gcc.target/powerpc/altivec-14.c: Likewise. + * gcc.target/powerpc/altivec-15.c: Likewise. + * gcc.target/powerpc/altivec-16.c: Likewise. + * gcc.target/powerpc/altivec-17.c: Likewise. + * gcc.target/powerpc/altivec-18.c: Likewise. + * gcc.target/powerpc/altivec-19.c: Likewise. + * gcc.target/powerpc/altivec-2.c: Likewise. + * gcc.target/powerpc/altivec-21.c: Likewise. + * gcc.target/powerpc/altivec-22.c: Likewise. + * gcc.target/powerpc/altivec-23.c: Likewise. + * gcc.target/powerpc/altivec-25.c: Likewise. + * gcc.target/powerpc/altivec-26.c: Likewise. + * gcc.target/powerpc/altivec-27.c: Likewise. + * gcc.target/powerpc/altivec-28.c: Likewise. + * gcc.target/powerpc/altivec-29.c: Likewise. + * gcc.target/powerpc/altivec-30.c: Likewise. + * gcc.target/powerpc/altivec-31.c: Likewise. + * gcc.target/powerpc/altivec-32.c: Likewise. + * gcc.target/powerpc/altivec-33.c: Likewise. + * gcc.target/powerpc/altivec-34.c: Likewise. + * gcc.target/powerpc/altivec-35.c: Likewise. + * gcc.target/powerpc/altivec-36.c: Likewise. + * gcc.target/powerpc/altivec-4.c: Likewise. + * gcc.target/powerpc/altivec-5.c: Likewise. + * gcc.target/powerpc/altivec-6.c: Likewise. + * gcc.target/powerpc/altivec-7.c: Likewise. + * gcc.target/powerpc/altivec-8.c: Likewise. + * gcc.target/powerpc/altivec-9.c: Likewise. + * gcc.target/powerpc/altivec-cell-1.c: Likewise. + * gcc.target/powerpc/altivec-cell-5.c: Likewise. + * gcc.target/powerpc/altivec-cell-6.c: Likewise. + * gcc.target/powerpc/altivec-cell-7.c: Likewise. + * gcc.target/powerpc/altivec-perm-1.c: Likewise. + * gcc.target/powerpc/altivec-perm-2.c: Likewise. + * gcc.target/powerpc/altivec-perm-3.c: Likewise. + * gcc.target/powerpc/altivec-perm-4.c: Likewise. + * gcc.target/powerpc/altivec-pr22085.c: Likewise. + * gcc.target/powerpc/altivec-splat.c: Likewise. + * gcc.target/powerpc/altivec-types-1.c: Likewise. + * gcc.target/powerpc/altivec-types-2.c: Likewise. + * gcc.target/powerpc/altivec-types-3.c: Likewise. + * gcc.target/powerpc/altivec-types-4.c: Likewise. + * gcc.target/powerpc/altivec-volatile.c: Likewise. + * gcc.target/powerpc/altivec_vld_vst_addr-1.c: Likewise. + * gcc.target/powerpc/bool2-av.c: Likewise. + * gcc.target/powerpc/bool2-p5.c: Likewise. + * gcc.target/powerpc/bool3-av.c: Likewise. + * gcc.target/powerpc/builtin-vec-sums-be-int.c: Likewise. + * gcc.target/powerpc/builtins-3.c: Likewise. + * gcc.target/powerpc/cell_builtin-3.c: Likewise. + * gcc.target/powerpc/cell_builtin-5.c: Likewise. + * gcc.target/powerpc/cell_builtin-6.c: Likewise. + * gcc.target/powerpc/cell_builtin-7.c: Likewise. + * gcc.target/powerpc/cell_builtin-8.c: Likewise. + * gcc.target/powerpc/fold-vec-abs-char-fwrapv.c: Likewise. + * gcc.target/powerpc/fold-vec-abs-char.c: Likewise. + * gcc.target/powerpc/fold-vec-abs-int-fwrapv.c: Likewise. + * gcc.target/powerpc/fold-vec-abs-int-fwrapv.p7.c: Likewise. + * gcc.target/powerpc/fold-vec-abs-int-fwrapv.p8.c: Likewise. + * gcc.target/powerpc/fold-vec-abs-int.c: Likewise. + * gcc.target/powerpc/fold-vec-abs-int.p7.c: Likewise. + * gcc.target/powerpc/fold-vec-abs-int.p8.c: Likewise. + * gcc.target/powerpc/fold-vec-abs-short-fwrapv.c: Likewise. + * gcc.target/powerpc/fold-vec-abs-short.c: Likewise. + * gcc.target/powerpc/fold-vec-add-1.c: Likewise. + * gcc.target/powerpc/fold-vec-add-2.c: Likewise. + * gcc.target/powerpc/fold-vec-add-3.c: Likewise. + * gcc.target/powerpc/fold-vec-add-5.c: Likewise. + * gcc.target/powerpc/fold-vec-extract-double.p7.c: Likewise. + * gcc.target/powerpc/fold-vec-ld-char.c: Likewise. + * gcc.target/powerpc/fold-vec-ld-float.c: Likewise. + * gcc.target/powerpc/fold-vec-ld-int.c: Likewise. + * gcc.target/powerpc/fold-vec-ld-short.c: Likewise. + * gcc.target/powerpc/fold-vec-madd-short.c: Likewise. + * gcc.target/powerpc/fold-vec-mergehl-char.c: Likewise. + * gcc.target/powerpc/fold-vec-mergehl-float.c: Likewise. + * gcc.target/powerpc/fold-vec-mergehl-int.c: Likewise. + * gcc.target/powerpc/fold-vec-mergehl-short.c: Likewise. + * gcc.target/powerpc/fold-vec-minmax-char.c: Likewise. + * gcc.target/powerpc/fold-vec-minmax-int.c: Likewise. + * gcc.target/powerpc/fold-vec-minmax-short.c: Likewise. + * gcc.target/powerpc/fold-vec-missing-lhs.c: Likewise. + * gcc.target/powerpc/fold-vec-msum-char.c: Likewise. + * gcc.target/powerpc/fold-vec-msum-short.c: Likewise. + * gcc.target/powerpc/fold-vec-mule-char.c: Likewise. + * gcc.target/powerpc/fold-vec-mule-short.c: Likewise. + * gcc.target/powerpc/fold-vec-mult-char.c: Likewise. + * gcc.target/powerpc/fold-vec-mult-short.c: Likewise. + * gcc.target/powerpc/fold-vec-pack-int.c: Likewise. + * gcc.target/powerpc/fold-vec-pack-short.c: Likewise. + * gcc.target/powerpc/fold-vec-perm-char.c: Likewise. + * gcc.target/powerpc/fold-vec-perm-float.c: Likewise. + * gcc.target/powerpc/fold-vec-perm-int.c: Likewise. + * gcc.target/powerpc/fold-vec-perm-pixel.c: Likewise. + * gcc.target/powerpc/fold-vec-perm-short.c: Likewise. + * gcc.target/powerpc/fold-vec-shift-char.c: Likewise. + * gcc.target/powerpc/fold-vec-shift-int.c: Likewise. + * gcc.target/powerpc/fold-vec-shift-left-fwrapv.c: Likewise. + * gcc.target/powerpc/fold-vec-shift-left.c: Likewise. + * gcc.target/powerpc/fold-vec-shift-short.c: Likewise. + * gcc.target/powerpc/fold-vec-splat-32.c: Likewise. + * gcc.target/powerpc/fold-vec-splat-8.c: Likewise. + * gcc.target/powerpc/fold-vec-splat-char.c: Likewise. + * gcc.target/powerpc/fold-vec-splat-int.c: Likewise. + * gcc.target/powerpc/fold-vec-splat-short.c: Likewise. + * gcc.target/powerpc/fold-vec-splats-char.c: Likewise. + * gcc.target/powerpc/fold-vec-splats-int.c: Likewise. + * gcc.target/powerpc/fold-vec-splats-short.c: Likewise. + * gcc.target/powerpc/fold-vec-st-char.c: Likewise. + * gcc.target/powerpc/fold-vec-st-float.c: Likewise. + * gcc.target/powerpc/fold-vec-st-int.c: Likewise. + * gcc.target/powerpc/fold-vec-st-short.c: Likewise. + * gcc.target/powerpc/fold-vec-sub-char.c: Likewise. + * gcc.target/powerpc/fold-vec-sub-float.c: Likewise. + * gcc.target/powerpc/fold-vec-sub-int.c: Likewise. + * gcc.target/powerpc/fold-vec-sub-short.c: Likewise. + * gcc.target/powerpc/fold-vec-sums-int.c: Likewise. + * gcc.target/powerpc/fold-vec-unpack-char.c: Likewise. + * gcc.target/powerpc/fold-vec-unpack-pixel.c: Likewise. + * gcc.target/powerpc/fold-vec-unpack-short.c: Likewise. + * gcc.target/powerpc/ppc-fma-3.c: Likewise. + * gcc.target/powerpc/ppc-fma-4.c: Likewise. + * gcc.target/powerpc/ppc-fma-7.c: Likewise. + * gcc.target/powerpc/ppc-vector-memcpy.c: Likewise. + * gcc.target/powerpc/ppc-vector-memset.c: Likewise. + * gcc.target/powerpc/pr100645.c: Likewise. + * gcc.target/powerpc/pr101384-1.c: Likewise. + * gcc.target/powerpc/pr101384-2.c: Likewise. + * gcc.target/powerpc/pr103353.c: Likewise. + * gcc.target/powerpc/pr103702.c: Likewise. + * gcc.target/powerpc/pr108348-1.c: Likewise. + * gcc.target/powerpc/pr108348-2.c: Likewise. + * gcc.target/powerpc/pr109932-1.c: Likewise. + * gcc.target/powerpc/pr109932-2.c: Likewise. + * gcc.target/powerpc/pr110776.c: Likewise. + * gcc.target/powerpc/pr16155.c: Likewise. + * gcc.target/powerpc/pr16286.c: Likewise. + * gcc.target/powerpc/pr27158.c: Likewise. + * gcc.target/powerpc/pr37168.c: Likewise. + * gcc.target/powerpc/pr47197.c: Likewise. + * gcc.target/powerpc/pr67071-1.c: Likewise. + * gcc.target/powerpc/pr67071-2.c: Likewise. + * gcc.target/powerpc/pr67071-3.c: Likewise. + * gcc.target/powerpc/pr70010-2.c: Likewise. + * gcc.target/powerpc/pr70010-3.c: Likewise. + * gcc.target/powerpc/pr71297.c: Likewise. + * gcc.target/powerpc/pr82112.c: Likewise. + * gcc.target/powerpc/pr84220-sld.c: Likewise. + * gcc.target/powerpc/pr84878.c: Likewise. + * gcc.target/powerpc/pr86731-fwrapv.c: Likewise. + * gcc.target/powerpc/pr86731.c: Likewise. + * gcc.target/powerpc/pr88100.c: Likewise. + * gcc.target/powerpc/pragma_power6.c: Likewise. + * gcc.target/powerpc/pragma_power7.c: Likewise. + * gcc.target/powerpc/pragma_power9.c: Likewise. + * gcc.target/powerpc/swaps-p8-21.c: Likewise. + * gcc.target/powerpc/unpack-vectorize-1.c: Likewise. + * gcc.target/powerpc/vec-cg.c: Likewise. + * gcc.target/powerpc/vec-cmpne.c: Likewise. + * gcc.target/powerpc/vec-constvolatile.c: Likewise. + * gcc.target/powerpc/vec-mult-char-2.c: Likewise. + * gcc.target/powerpc/vec-rotate-1.c: Likewise. + * gcc.target/powerpc/vec-rotate-3.c: Likewise. + * gcc.target/powerpc/vec-shift.c: Likewise. + * g++.target/powerpc/altivec-3.C: Likewise. + * g++.target/powerpc/altivec-cell-2.C: Likewise. + * g++.target/powerpc/altivec-cell-3.C: Likewise. + * g++.target/powerpc/altivec-cell-4.C: Likewise. + * g++.target/powerpc/const2.C: Likewise. + * gcc.dg/debug/dwarf2/const-2.c: Likewise. + * gcc.dg/dfp/altivec-types.c: Likewise. + * gcc.dg/ubsan/pr88234.c: Likewise. + * gcc.dg/vect/vect-82_64.c: Likewise. + * gcc.dg/vect/vect-83_64.c: Likewise. + * gcc.target/powerpc/altivec-1.c: Likewise. + * gcc.target/powerpc/altivec-10.c: Likewise. + * gcc.target/powerpc/altivec-12.c: Likewise. + * gcc.target/powerpc/altivec-20.c: Likewise. + * gcc.target/powerpc/altivec-24.c: Likewise. + * gcc.target/powerpc/altivec-3.c: Likewise. + * gcc.target/powerpc/altivec-cell-2.c: Likewise. + * gcc.target/powerpc/altivec-cell-3.c: Likewise. + * gcc.target/powerpc/altivec-cell-4.c: Likewise. + * gcc.target/powerpc/altivec-consts.c: Likewise. + * gcc.target/powerpc/altivec-macros.c: Likewise. + * gcc.target/powerpc/altivec-varargs-1.c: Likewise. + * gcc.target/powerpc/altivec-vec-merge.c: Likewise. + * gcc.target/powerpc/darwin-save-world-1.c: Likewise. + * gcc.target/powerpc/le-altivec-consts.c: Likewise. + * gcc.target/powerpc/pr35907.c: Likewise. + * gcc.target/powerpc/vec-mult-char-1.c: Likewise. + +2024-06-18 Hu, Lin1 + + * gcc.target/i386/sse-cmp-1.c: New test. + * gcc.target/i386/sse-cmp-2.c: Ditto. + * gcc.target/i386/sse-cmp-error.c: Ditto. + +2024-06-17 Andrew Pinski + + PR tree-optimization/97405 + * gcc.target/aarch64/sve/pr97405-1.c: New test. + +2024-06-17 Jeff Law + + * gcc.target/riscv/zbs-zext-3.c: New test. + +2024-06-17 Jakub Jelinek + + PR driver/115440 + * g++.dg/cpp1z/pr115440.C: New test. + +2024-06-17 Andreas Krebbel + + * g++.dg/torture/vshuf-mem.C: Use -march=z14 only, if the we are + on a machine which can actually run it. + +2024-06-17 Joseph Myers + + * gcc.dg/c23-align-10.c, gcc.dg/c2y-align-1.c, + gcc.dg/c2y-align-2.c: New tests. + +2024-06-17 Jakub Jelinek + + PR c/115290 + * c-c++-common/Warray-compare-3.c: New test. + +2024-06-17 Jakub Jelinek + + PR target/111343 + PR c++/115511 + * g++.dg/cpp23/ext-floating18.C: New test. + +2024-06-17 Peter Bergner + + PR target/115389 + * gcc.target/powerpc/pr115389.c: New test. + +2024-06-17 Jeff Law + + * gcc.target/riscv/zbs-zext-2.c: New test. + +2024-06-17 Richard Biener + + PR tree-optimization/115508 + * gcc.target/i386/pr115508.c: New testcase. + +2024-06-17 Richard Biener + + PR tree-optimization/115492 + * gcc.dg/torture/pr115492.c: New testcase. + +2024-06-17 Lingling Kong + + * gcc.target/i386/apx-zu-1.c: Add attribute for noinline, + and target apx. + * gcc.target/i386/apx-zu-2.c: Add target-support check. + +2024-06-17 Hu, Lin1 + + PR target/115161 + * gcc.target/i386/pr115161-1.c: New test. + +2024-06-17 Andre Vehreschild + + * gfortran.dg/coarray_alloc_comp_3.f08: Moved to... + * gfortran.dg/coarray/alloc_comp_8.f90: ...here. + Should be tested for both -fcoarray=single and lib, resp. + * gfortran.dg/coarray_alloc_comp_4.f08: Fix program name. + +2024-06-17 Levy Hsu + + * gcc.target/i386/vpermt2-special-bf16-shufflue.c: New test. + +2024-06-17 Stefan Schulze Frielinghaus + + * gcc.target/s390/vector/vgm-df-1.c: Removed. + * gcc.target/s390/vector/vgm-di-1.c: Removed. + * gcc.target/s390/vector/vgm-hi-1.c: Removed. + * gcc.target/s390/vector/vgm-int128-1.c: Removed. + * gcc.target/s390/vector/vgm-longdouble-1.c: Removed. + * gcc.target/s390/vector/vgm-qi-1.c: Removed. + * gcc.target/s390/vector/vgm-sf-1.c: Removed. + * gcc.target/s390/vector/vgm-si-1.c: Removed. + * gcc.target/s390/vector/vgm-ti-1.c: Removed. + +2024-06-17 Stefan Schulze Frielinghaus + + * gcc.target/s390/vector/vec-extend-3.c: New test. + * gcc.target/s390/vector/vgm-df-1.c: New file. + * gcc.target/s390/vector/vgm-di-1.c: New file. + * gcc.target/s390/vector/vgm-hi-1.c: New file. + * gcc.target/s390/vector/vgm-int128-1.c: New file. + * gcc.target/s390/vector/vgm-longdouble-1.c: New file. + * gcc.target/s390/vector/vgm-qi-1.c: New file. + * gcc.target/s390/vector/vgm-sf-1.c: New file. + * gcc.target/s390/vector/vgm-si-1.c: New file. + * gcc.target/s390/vector/vgm-ti-1.c: New file. + +2024-06-17 Stefan Schulze Frielinghaus + + * gcc.target/s390/vector/vec-extend-1.c: New test. + * gcc.target/s390/vector/vec-extend-2.c: New test. + +2024-06-17 Stefan Schulze Frielinghaus + + * gcc.target/s390/nobp-table-jump-inline-z10.c: Do not perform + IPA. + * gcc.target/s390/nobp-table-jump-inline-z900.c: Dito. + * gcc.target/s390/nobp-table-jump-z10.c: Dito. + * gcc.target/s390/nobp-table-jump-z900.c: Dito. + +2024-06-17 Stefan Schulze Frielinghaus + + * gcc.target/s390/ifcvt-one-insn-bool.c: Fix loc. + +2024-06-16 Jeff Law + + * gcc.target/riscv/zbs-zext.c: New test. + +2024-06-15 Pan Li + + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-5.c: New test. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-6.c: New test. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-7.c: New test. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-8.c: New test. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-5.c: New test. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-6.c: New test. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-7.c: New test. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-8.c: New test. + +2024-06-15 Pan Li + + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-1.c: Leverage + the new header file for vector part. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-2.c: Ditto. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-3.c: Ditto. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-4.c: Ditto. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-1.c: Ditto. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-2.c: Ditto. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-3.c: Ditto. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-4.c: Ditto. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-1.c: Ditto. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-2.c: Ditto. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-3.c: Ditto. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-4.c: Ditto. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-1.c: Ditto. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-2.c: Ditto. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-3.c: Ditto. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-4.c: Ditto. + * gcc.target/riscv/sat_arith.h: Move vector part out. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_arith.h: New test. + +2024-06-14 Jakub Jelinek + + * g++.dg/torture/vshuf-mem.C: Add -Wno-psabi to dg-options. + +2024-06-14 Pan Li + + * gcc.target/riscv/sat_arith.h: Add helper macro for test. + * gcc.target/riscv/sat_u_sub-37.c: New test. + * gcc.target/riscv/sat_u_sub-38.c: New test. + * gcc.target/riscv/sat_u_sub-39.c: New test. + * gcc.target/riscv/sat_u_sub-40.c: New test. + * gcc.target/riscv/sat_u_sub-run-37.c: New test. + * gcc.target/riscv/sat_u_sub-run-38.c: New test. + * gcc.target/riscv/sat_u_sub-run-39.c: New test. + * gcc.target/riscv/sat_u_sub-run-40.c: New test. + +2024-06-14 Pan Li + + * gcc.target/riscv/sat_arith.h: Add helper macro for test. + * gcc.target/riscv/sat_u_sub-33.c: New test. + * gcc.target/riscv/sat_u_sub-34.c: New test. + * gcc.target/riscv/sat_u_sub-35.c: New test. + * gcc.target/riscv/sat_u_sub-36.c: New test. + * gcc.target/riscv/sat_u_sub-run-33.c: New test. + * gcc.target/riscv/sat_u_sub-run-34.c: New test. + * gcc.target/riscv/sat_u_sub-run-35.c: New test. + * gcc.target/riscv/sat_u_sub-run-36.c: New test. + +2024-06-14 Pan Li + + * gcc.target/riscv/sat_arith.h: Add helper macro for test. + * gcc.target/riscv/sat_u_sub-29.c: New test. + * gcc.target/riscv/sat_u_sub-30.c: New test. + * gcc.target/riscv/sat_u_sub-31.c: New test. + * gcc.target/riscv/sat_u_sub-32.c: New test. + * gcc.target/riscv/sat_u_sub-run-29.c: New test. + * gcc.target/riscv/sat_u_sub-run-30.c: New test. + * gcc.target/riscv/sat_u_sub-run-31.c: New test. + * gcc.target/riscv/sat_u_sub-run-32.c: New test. + +2024-06-14 Pan Li + + * gcc.target/riscv/sat_arith.h: Add helper macro for test. + * gcc.target/riscv/sat_u_sub-25.c: New test. + * gcc.target/riscv/sat_u_sub-26.c: New test. + * gcc.target/riscv/sat_u_sub-27.c: New test. + * gcc.target/riscv/sat_u_sub-28.c: New test. + * gcc.target/riscv/sat_u_sub-run-25.c: New test. + * gcc.target/riscv/sat_u_sub-run-26.c: New test. + * gcc.target/riscv/sat_u_sub-run-27.c: New test. + * gcc.target/riscv/sat_u_sub-run-28.c: New test. + +2024-06-14 Pan Li + + * gcc.target/riscv/sat_arith.h: Add helper macro for test. + * gcc.target/riscv/sat_u_sub-21.c: New test. + * gcc.target/riscv/sat_u_sub-22.c: New test. + * gcc.target/riscv/sat_u_sub-23.c: New test. + * gcc.target/riscv/sat_u_sub-24.c: New test. + * gcc.target/riscv/sat_u_sub-run-21.c: New test. + * gcc.target/riscv/sat_u_sub-run-22.c: New test. + * gcc.target/riscv/sat_u_sub-run-23.c: New test. + * gcc.target/riscv/sat_u_sub-run-24.c: New test. + +2024-06-14 Pan Li + + * gcc.target/riscv/sat_arith.h: Add helper macro for test. + * gcc.target/riscv/sat_u_sub-17.c: New test. + * gcc.target/riscv/sat_u_sub-18.c: New test. + * gcc.target/riscv/sat_u_sub-19.c: New test. + * gcc.target/riscv/sat_u_sub-20.c: New test. + * gcc.target/riscv/sat_u_sub-run-17.c: New test. + * gcc.target/riscv/sat_u_sub-run-18.c: New test. + * gcc.target/riscv/sat_u_sub-run-19.c: New test. + * gcc.target/riscv/sat_u_sub-run-20.c: New test. + +2024-06-14 Pan Li + + * gcc.target/riscv/sat_arith.h: Add helper macro for test. + * gcc.target/riscv/sat_u_sub-13.c: New test. + * gcc.target/riscv/sat_u_sub-14.c: New test. + * gcc.target/riscv/sat_u_sub-15.c: New test. + * gcc.target/riscv/sat_u_sub-16.c: New test. + * gcc.target/riscv/sat_u_sub-run-13.c: New test. + * gcc.target/riscv/sat_u_sub-run-14.c: New test. + * gcc.target/riscv/sat_u_sub-run-15.c: New test. + * gcc.target/riscv/sat_u_sub-run-16.c: New test. + +2024-06-14 Pan Li + + * gcc.target/riscv/sat_arith.h: Add helper macro for test. + * gcc.target/riscv/sat_u_sub-10.c: New test. + * gcc.target/riscv/sat_u_sub-11.c: New test. + * gcc.target/riscv/sat_u_sub-12.c: New test. + * gcc.target/riscv/sat_u_sub-9.c: New test. + * gcc.target/riscv/sat_u_sub-run-10.c: New test. + * gcc.target/riscv/sat_u_sub-run-11.c: New test. + * gcc.target/riscv/sat_u_sub-run-12.c: New test. + * gcc.target/riscv/sat_u_sub-run-9.c: New test. + +2024-06-14 Richard Biener + + * gcc.target/i386/vect-strided-3.c: Disable SSE4 instead of AVX. + +2024-06-14 Richard Biener + + * gcc.dg/vect/slp-reduc-12.c: New testcase. + +2024-06-14 Pan Li + + PR target/115456 + * gcc.target/riscv/rvv/base/pr115456-2.c: New test. + * gcc.target/riscv/rvv/base/pr115456-3.c: New test. + +2024-06-14 Richard Biener + + * gcc.dg/vect/pr115385.c: Enable AVX2 if available. + +2024-06-14 liuhongt + + * gcc.target/i386/avx2-pr98461.c: Scan either notl or + vpternlog. + * gcc.target/i386/avx512f-pr96891-3.c: Also scan for inversed + condition. + * gcc.target/i386/avx512f-vpternlogd-3.c: Adjust vpternlog + number to 673. + * gcc.target/i386/avx512f-vpternlogd-4.c: Ditto. + * gcc.target/i386/avx512f-vpternlogd-5.c: Ditto. + * gcc.target/i386/sse2-v1ti-vne.c: Add -mno-avx512f. + +2024-06-14 Roger Sayle + + * gcc.target/i386/pr115407.c: New test case. + +2024-06-14 Alexandre Oliva + + Revert: + 2024-06-14 Alexandre Oliva + + * gnat.dg/bias1.adb: Count occurrences of -7.*DW_AT_GNU_bias. + +2024-06-13 Patrick O'Neill + + * gcc.target/riscv/amo/amo-table-a-6-load-1.c: Increase test coverage to + include longs, shorts, chars, and bools. + * gcc.target/riscv/amo/amo-table-a-6-load-2.c: Ditto. + * gcc.target/riscv/amo/amo-table-a-6-load-3.c: Ditto. + * gcc.target/riscv/amo/amo-table-a-6-store-1.c: Ditto. + * gcc.target/riscv/amo/amo-table-a-6-store-2.c: Ditto. + * gcc.target/riscv/amo/amo-table-a-6-store-compat-3.c: Ditto. + * gcc.target/riscv/amo/amo-table-ztso-load-1.c: Ditto. + * gcc.target/riscv/amo/amo-table-ztso-load-2.c: Ditto. + * gcc.target/riscv/amo/amo-table-ztso-load-3.c: Ditto. + * gcc.target/riscv/amo/amo-table-ztso-store-1.c: Ditto. + * gcc.target/riscv/amo/amo-table-ztso-store-2.c: Ditto. + * gcc.target/riscv/amo/amo-table-ztso-store-3.c: Ditto. + +2024-06-13 Joseph Myers + + * gcc.dg/c23-complex-1.c, gcc.dg/c23-complex-2.c, + gcc.dg/c23-complex-3.c, gcc.dg/c23-complex-4.c, + gcc.dg/c2y-complex-1.c, gcc.dg/c2y-complex-2.c: New tests. + +2024-06-13 Carl Love + + * gcc.target/powerpc/altivec-2-runnable.c: Change dg-do + argument to run. + +2024-06-13 Jason Merrill + + PR c++/114683 + * g++.dg/modules/using-22_a.C: New test. + * g++.dg/modules/using-22_b.C: New test. + +2024-06-13 Jason Merrill + + PR c++/115194 + * g++.dg/modules/using-23_a.C: New test. + * g++.dg/modules/using-23_b.C: New test. + +2024-06-13 Patrick Palka + + PR c++/99678 + * g++.dg/cpp2a/concepts-requires38.C: New test. + +2024-06-13 Patrick Palka + + PR c++/115239 + * g++.dg/overload/error7.C: New test. + +2024-06-13 Richard Sandiford + + PR target/115464 + * gcc.target/aarch64/sve/acle/general/pr115464.c: New test. + +2024-06-13 Pan Li + + PR target/115456 + * gcc.target/riscv/rvv/base/pr115456-1.c: New test. + +2024-06-13 Hongyu Wang + + * gcc.target/i386/apx-ccmp-1.c: Adjust output to scan ctest. + * gcc.target/i386/apx-ccmp-2.c: Adjust some condition to + compare with 0. + +2024-06-13 Richard Biener + + * gcc.target/i386/vect-strided-1.c: New testcase. + * gcc.target/i386/vect-strided-2.c: Likewise. + * gcc.target/i386/vect-strided-3.c: Likewise. + * gcc.target/i386/vect-strided-4.c: Likewise. + +2024-06-13 Richard Biener + + PR tree-optimization/115385 + * gcc.dg/vect/pr115385.c: New testcase. + * gcc.target/i386/vect-pr115385.c: Likewise. + +2024-06-13 Richard Biener + + PR tree-optimization/114107 + PR tree-optimization/110445 + * gcc.dg/vect/pr114107.c: New testcase. + * gcc.dg/vect/pr103116-1.c: Adjust. + * gcc.dg/vect/pr103116-2.c: Likewise. + +2024-06-13 Andi Kleen + + * g++.dg/cpp1z/constexpr-asm-3.C: Adjust for new message. + +2024-06-13 Andi Kleen + + * g++.dg/cpp1z/constexpr-asm-1.C: Use std::std_string_view. + * g++.dg/cpp1z/constexpr-asm-3.C: Dito. + +2024-06-13 liuhongt + + * gcc.target/i386/pr115452.c: New test. + +2024-06-13 Pan Li + + * gcc.target/riscv/pr115387-1.c: Move to... + * gcc.dg/torture/pr115387-1.c: ...here. + * gcc.target/riscv/pr115387-2.c: Move to... + * gcc.dg/torture/pr115387-2.c: ...here. + +2024-06-13 Peter Bergner + + PR testsuite/115262 + * gcc.target/powerpc/pr66144-3.c (dg-do): Compile for all targets. + (dg-options): Add -fno-unroll-loops and remove -mvsx. + (scan-assembler): Change from this... + (scan-assembler-times): ...to this. Tweak regex to accept multiple + allowable instructions. + +2024-06-13 Lingling Kong + + * gcc.target/i386/apx-zu-1.c: New test. + * gcc.target/i386/apx-zu-2.c: New test. + +2024-06-13 Patrick Palka + + PR c++/115283 + * g++.dg/template/linkage5.C: New test. + +2024-06-12 Jason Merrill + + * g++.dg/modules/using-21_a.C: New test. + +2024-06-12 Jason Merrill + + * g++.dg/modules/using-20_a.C: New test. + +2024-06-12 Jason Merrill + + * g++.dg/cpp26/static_assert1.C: Fix diagnostic typos. + +2024-06-12 Patrick O'Neill + + * lib/target-supports.exp: Cleanup whitespace. + +2024-06-12 Patrick O'Neill + + * gcc.target/riscv/amo/amo-table-a-6-load-1.c: Update temp register regex. + * gcc.target/riscv/amo/amo-table-a-6-load-2.c: Ditto. + * gcc.target/riscv/amo/amo-table-a-6-load-3.c: Ditto. + * gcc.target/riscv/amo/amo-table-a-6-store-1.c: Ditto. + * gcc.target/riscv/amo/amo-table-a-6-store-2.c: Ditto. + * gcc.target/riscv/amo/amo-table-a-6-store-compat-3.c: Ditto. + * gcc.target/riscv/amo/amo-table-ztso-load-1.c: Ditto. + * gcc.target/riscv/amo/amo-table-ztso-load-2.c: Ditto. + * gcc.target/riscv/amo/amo-table-ztso-load-3.c: Ditto. + * gcc.target/riscv/amo/amo-table-ztso-store-1.c: Ditto. + * gcc.target/riscv/amo/amo-table-ztso-store-2.c: Ditto. + * gcc.target/riscv/amo/amo-table-ztso-store-3.c: Ditto. + +2024-06-12 Patrick O'Neill + + * gcc.target/riscv/amo/amo-table-a-6-amo-add-1.c: Update + __atomic_add_fetch args. + * gcc.target/riscv/amo/amo-table-a-6-amo-add-2.c: Ditto. + * gcc.target/riscv/amo/amo-table-a-6-amo-add-3.c: Ditto. + * gcc.target/riscv/amo/amo-table-a-6-amo-add-4.c: Ditto. + * gcc.target/riscv/amo/amo-table-a-6-amo-add-5.c: Ditto. + * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-1.c: Ditto. + * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-2.c: Ditto. + * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-3.c: Ditto. + * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-4.c: Ditto. + * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-5.c: Ditto. + * gcc.target/riscv/amo/amo-table-ztso-amo-add-1.c: Ditto. + * gcc.target/riscv/amo/amo-table-ztso-amo-add-2.c: Ditto. + * gcc.target/riscv/amo/amo-table-ztso-amo-add-3.c: Ditto. + * gcc.target/riscv/amo/amo-table-ztso-amo-add-4.c: Ditto. + * gcc.target/riscv/amo/amo-table-ztso-amo-add-5.c: Ditto. + * gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-1.c: Ditto. + * gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-2.c: Ditto. + * gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-3.c: Ditto. + * gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-4.c: Ditto. + * gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-5.c: Ditto. + * gcc.target/riscv/amo/amo-zaamo-preferred-over-zalrsc.c: Ditto. + * gcc.target/riscv/amo/amo-zalrsc-amo-add-1.c: Ditto. + * gcc.target/riscv/amo/amo-zalrsc-amo-add-2.c: Ditto. + * gcc.target/riscv/amo/amo-zalrsc-amo-add-3.c: Ditto. + * gcc.target/riscv/amo/amo-zalrsc-amo-add-4.c: Ditto. + * gcc.target/riscv/amo/amo-zalrsc-amo-add-5.c: Ditto. + +2024-06-12 Patrick O'Neill + + * gcc.target/riscv/amo-table-a-6-amo-add-1.c: Move to... + * gcc.target/riscv/amo/amo-table-a-6-amo-add-1.c: ...here. + * gcc.target/riscv/amo-table-a-6-amo-add-2.c: Move to... + * gcc.target/riscv/amo/amo-table-a-6-amo-add-2.c: ...here. + * gcc.target/riscv/amo-table-a-6-amo-add-3.c: Move to... + * gcc.target/riscv/amo/amo-table-a-6-amo-add-3.c: ...here. + * gcc.target/riscv/amo-table-a-6-amo-add-4.c: Move to... + * gcc.target/riscv/amo/amo-table-a-6-amo-add-4.c: ...here. + * gcc.target/riscv/amo-table-a-6-amo-add-5.c: Move to... + * gcc.target/riscv/amo/amo-table-a-6-amo-add-5.c: ...here. + * gcc.target/riscv/amo-table-a-6-compare-exchange-1.c: Move to... + * gcc.target/riscv/amo/amo-table-a-6-compare-exchange-1.c: ...here. + * gcc.target/riscv/amo-table-a-6-compare-exchange-2.c: Move to... + * gcc.target/riscv/amo/amo-table-a-6-compare-exchange-2.c: ...here. + * gcc.target/riscv/amo-table-a-6-compare-exchange-3.c: Move to... + * gcc.target/riscv/amo/amo-table-a-6-compare-exchange-3.c: ...here. + * gcc.target/riscv/amo-table-a-6-compare-exchange-4.c: Move to... + * gcc.target/riscv/amo/amo-table-a-6-compare-exchange-4.c: ...here. + * gcc.target/riscv/amo-table-a-6-compare-exchange-5.c: Move to... + * gcc.target/riscv/amo/amo-table-a-6-compare-exchange-5.c: ...here. + * gcc.target/riscv/amo-table-a-6-compare-exchange-6.c: Move to... + * gcc.target/riscv/amo/amo-table-a-6-compare-exchange-6.c: ...here. + * gcc.target/riscv/amo-table-a-6-compare-exchange-7.c: Move to... + * gcc.target/riscv/amo/amo-table-a-6-compare-exchange-7.c: ...here. + * gcc.target/riscv/amo-table-a-6-fence-1.c: Move to... + * gcc.target/riscv/amo/amo-table-a-6-fence-1.c: ...here. + * gcc.target/riscv/amo-table-a-6-fence-2.c: Move to... + * gcc.target/riscv/amo/amo-table-a-6-fence-2.c: ...here. + * gcc.target/riscv/amo-table-a-6-fence-3.c: Move to... + * gcc.target/riscv/amo/amo-table-a-6-fence-3.c: ...here. + * gcc.target/riscv/amo-table-a-6-fence-4.c: Move to... + * gcc.target/riscv/amo/amo-table-a-6-fence-4.c: ...here. + * gcc.target/riscv/amo-table-a-6-fence-5.c: Move to... + * gcc.target/riscv/amo/amo-table-a-6-fence-5.c: ...here. + * gcc.target/riscv/amo-table-a-6-load-1.c: Move to... + * gcc.target/riscv/amo/amo-table-a-6-load-1.c: ...here. + * gcc.target/riscv/amo-table-a-6-load-2.c: Move to... + * gcc.target/riscv/amo/amo-table-a-6-load-2.c: ...here. + * gcc.target/riscv/amo-table-a-6-load-3.c: Move to... + * gcc.target/riscv/amo/amo-table-a-6-load-3.c: ...here. + * gcc.target/riscv/amo-table-a-6-store-1.c: Move to... + * gcc.target/riscv/amo/amo-table-a-6-store-1.c: ...here. + * gcc.target/riscv/amo-table-a-6-store-2.c: Move to... + * gcc.target/riscv/amo/amo-table-a-6-store-2.c: ...here. + * gcc.target/riscv/amo-table-a-6-store-compat-3.c: Move to... + * gcc.target/riscv/amo/amo-table-a-6-store-compat-3.c: ...here. + * gcc.target/riscv/amo-table-a-6-subword-amo-add-1.c: Move to... + * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-1.c: ...here. + * gcc.target/riscv/amo-table-a-6-subword-amo-add-2.c: Move to... + * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-2.c: ...here. + * gcc.target/riscv/amo-table-a-6-subword-amo-add-3.c: Move to... + * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-3.c: ...here. + * gcc.target/riscv/amo-table-a-6-subword-amo-add-4.c: Move to... + * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-4.c: ...here. + * gcc.target/riscv/amo-table-a-6-subword-amo-add-5.c: Move to... + * gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-5.c: ...here. + * gcc.target/riscv/amo-table-ztso-amo-add-1.c: Move to... + * gcc.target/riscv/amo/amo-table-ztso-amo-add-1.c: ...here. + * gcc.target/riscv/amo-table-ztso-amo-add-2.c: Move to... + * gcc.target/riscv/amo/amo-table-ztso-amo-add-2.c: ...here. + * gcc.target/riscv/amo-table-ztso-amo-add-3.c: Move to... + * gcc.target/riscv/amo/amo-table-ztso-amo-add-3.c: ...here. + * gcc.target/riscv/amo-table-ztso-amo-add-4.c: Move to... + * gcc.target/riscv/amo/amo-table-ztso-amo-add-4.c: ...here. + * gcc.target/riscv/amo-table-ztso-amo-add-5.c: Move to... + * gcc.target/riscv/amo/amo-table-ztso-amo-add-5.c: ...here. + * gcc.target/riscv/amo-table-ztso-compare-exchange-1.c: Move to... + * gcc.target/riscv/amo/amo-table-ztso-compare-exchange-1.c: ...here. + * gcc.target/riscv/amo-table-ztso-compare-exchange-2.c: Move to... + * gcc.target/riscv/amo/amo-table-ztso-compare-exchange-2.c: ...here. + * gcc.target/riscv/amo-table-ztso-compare-exchange-3.c: Move to... + * gcc.target/riscv/amo/amo-table-ztso-compare-exchange-3.c: ...here. + * gcc.target/riscv/amo-table-ztso-compare-exchange-4.c: Move to... + * gcc.target/riscv/amo/amo-table-ztso-compare-exchange-4.c: ...here. + * gcc.target/riscv/amo-table-ztso-compare-exchange-5.c: Move to... + * gcc.target/riscv/amo/amo-table-ztso-compare-exchange-5.c: ...here. + * gcc.target/riscv/amo-table-ztso-compare-exchange-6.c: Move to... + * gcc.target/riscv/amo/amo-table-ztso-compare-exchange-6.c: ...here. + * gcc.target/riscv/amo-table-ztso-compare-exchange-7.c: Move to... + * gcc.target/riscv/amo/amo-table-ztso-compare-exchange-7.c: ...here. + * gcc.target/riscv/amo-table-ztso-fence-1.c: Move to... + * gcc.target/riscv/amo/amo-table-ztso-fence-1.c: ...here. + * gcc.target/riscv/amo-table-ztso-fence-2.c: Move to... + * gcc.target/riscv/amo/amo-table-ztso-fence-2.c: ...here. + * gcc.target/riscv/amo-table-ztso-fence-3.c: Move to... + * gcc.target/riscv/amo/amo-table-ztso-fence-3.c: ...here. + * gcc.target/riscv/amo-table-ztso-fence-4.c: Move to... + * gcc.target/riscv/amo/amo-table-ztso-fence-4.c: ...here. + * gcc.target/riscv/amo-table-ztso-fence-5.c: Move to... + * gcc.target/riscv/amo/amo-table-ztso-fence-5.c: ...here. + * gcc.target/riscv/amo-table-ztso-load-1.c: Move to... + * gcc.target/riscv/amo/amo-table-ztso-load-1.c: ...here. + * gcc.target/riscv/amo-table-ztso-load-2.c: Move to... + * gcc.target/riscv/amo/amo-table-ztso-load-2.c: ...here. + * gcc.target/riscv/amo-table-ztso-load-3.c: Move to... + * gcc.target/riscv/amo/amo-table-ztso-load-3.c: ...here. + * gcc.target/riscv/amo-table-ztso-store-1.c: Move to... + * gcc.target/riscv/amo/amo-table-ztso-store-1.c: ...here. + * gcc.target/riscv/amo-table-ztso-store-2.c: Move to... + * gcc.target/riscv/amo/amo-table-ztso-store-2.c: ...here. + * gcc.target/riscv/amo-table-ztso-store-3.c: Move to... + * gcc.target/riscv/amo/amo-table-ztso-store-3.c: ...here. + * gcc.target/riscv/amo-table-ztso-subword-amo-add-1.c: Move to... + * gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-1.c: ...here. + * gcc.target/riscv/amo-table-ztso-subword-amo-add-2.c: Move to... + * gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-2.c: ...here. + * gcc.target/riscv/amo-table-ztso-subword-amo-add-3.c: Move to... + * gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-3.c: ...here. + * gcc.target/riscv/amo-table-ztso-subword-amo-add-4.c: Move to... + * gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-4.c: ...here. + * gcc.target/riscv/amo-table-ztso-subword-amo-add-5.c: Move to... + * gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-5.c: ...here. + * gcc.target/riscv/amo-zaamo-preferred-over-zalrsc.c: Move to... + * gcc.target/riscv/amo/amo-zaamo-preferred-over-zalrsc.c: ...here. + * gcc.target/riscv/amo-zalrsc-amo-add-1.c: Move to... + * gcc.target/riscv/amo/amo-zalrsc-amo-add-1.c: ...here. + * gcc.target/riscv/amo-zalrsc-amo-add-2.c: Move to... + * gcc.target/riscv/amo/amo-zalrsc-amo-add-2.c: ...here. + * gcc.target/riscv/amo-zalrsc-amo-add-3.c: Move to... + * gcc.target/riscv/amo/amo-zalrsc-amo-add-3.c: ...here. + * gcc.target/riscv/amo-zalrsc-amo-add-4.c: Move to... + * gcc.target/riscv/amo/amo-zalrsc-amo-add-4.c: ...here. + * gcc.target/riscv/amo-zalrsc-amo-add-5.c: Move to... + * gcc.target/riscv/amo/amo-zalrsc-amo-add-5.c: ...here. + * gcc.target/riscv/inline-atomics-1.c: Move to... + * gcc.target/riscv/amo/inline-atomics-1.c: ...here. + * gcc.target/riscv/inline-atomics-2.c: Move to... + * gcc.target/riscv/amo/inline-atomics-2.c: ...here. + * gcc.target/riscv/inline-atomics-3.c: Move to... + * gcc.target/riscv/amo/inline-atomics-3.c: ...here. + * gcc.target/riscv/inline-atomics-4.c: Move to... + * gcc.target/riscv/amo/inline-atomics-4.c: ...here. + * gcc.target/riscv/inline-atomics-5.c: Move to... + * gcc.target/riscv/amo/inline-atomics-5.c: ...here. + * gcc.target/riscv/inline-atomics-6.c: Move to... + * gcc.target/riscv/amo/inline-atomics-6.c: ...here. + * gcc.target/riscv/inline-atomics-7.c: Move to... + * gcc.target/riscv/amo/inline-atomics-7.c: ...here. + * gcc.target/riscv/inline-atomics-8.c: Move to... + * gcc.target/riscv/amo/inline-atomics-8.c: ...here. + * gcc.target/riscv/pr114130.c: Move to... + * gcc.target/riscv/amo/pr114130.c: ...here. + * gcc.target/riscv/pr89835.c: Move to... + * gcc.target/riscv/amo/pr89835.c: ...here. + * gcc.target/riscv/amo/amo.exp: New file. + +2024-06-12 Andrew Pinski + + PR tree-optimization/115449 + * gcc.dg/tree-ssa/bitops-10.c: New test. + +2024-06-12 Victor Do Nascimento + + * gcc.dg/vect/vect-prefetch-drop.c: New test. + * gcc.target/aarch64/vect-prefetch-drop.c: Likewise. + +2024-06-12 David Malcolm + + * gcc.dg/plugin/analyzer_cpython_plugin.c (dump_refcnt_info): + Update for fields of pretty_printer becoming private. + +2024-06-12 Xi Ruoyao + + * gcc.target/loongarch/bstrins-1.c: New test. + * gcc.target/loongarch/bstrins-2.c: New test. + +2024-06-12 Torbjörn SVENSSON + Yvan ROUX + + PR target/115253 + * gcc.target/arm/cmse/extend-return.c: Update test case + condition for Armv8.1-M. + +2024-06-12 Alexandre Oliva + + PR tree-optimization/113681 + * c-c++-common/strub-pr113681.c: New. + +2024-06-12 Alexandre Oliva + + * gcc.target/arm/multilib.exp: Skip based on board cflags too. + +2024-06-12 Alexandre Oliva + + * gnat.dg/bias1.adb: Count occurrences of -7.*DW_AT_GNU_bias. + +2024-06-12 liuhongt + + * gcc.target/i386/pr115384.c: New test. + +2024-06-11 Joseph Myers + + * gcc.dg/c23-generic-1.c, gcc.dg/c23-generic-2.c, + gcc.dg/c23-generic-3.c, gcc.dg/c23-generic-4.c, + gcc.dg/c2y-generic-1.c, gcc.dg/c2y-generic-2.c, + gcc.dg/c2y-generic-3.c, gcc.dg/gnu2y-generic-1.c: New tests. + * gcc.dg/c23-tag-6.c: Use -pedantic-errors. + +2024-06-11 Patrick O'Neill + + * gcc.target/riscv/amo-zaamo-preferred-over-zalrsc.c: New test. + * gcc.target/riscv/amo-zalrsc-amo-add-1.c: New test. + * gcc.target/riscv/amo-zalrsc-amo-add-2.c: New test. + * gcc.target/riscv/amo-zalrsc-amo-add-3.c: New test. + * gcc.target/riscv/amo-zalrsc-amo-add-4.c: New test. + * gcc.target/riscv/amo-zalrsc-amo-add-5.c: New test. + +2024-06-11 Patrick O'Neill + + * gcc.target/riscv/amo-table-a-6-amo-add-1.c: Use Zaamo rather than A. + * gcc.target/riscv/amo-table-a-6-amo-add-2.c: Ditto. + * gcc.target/riscv/amo-table-a-6-amo-add-3.c: Ditto. + * gcc.target/riscv/amo-table-a-6-amo-add-4.c: Ditto. + * gcc.target/riscv/amo-table-a-6-amo-add-5.c: Ditto. + * gcc.target/riscv/amo-table-a-6-compare-exchange-1.c: Use Zalrsc rather + than A. + * gcc.target/riscv/amo-table-a-6-compare-exchange-2.c: Ditto. + * gcc.target/riscv/amo-table-a-6-compare-exchange-3.c: Ditto. + * gcc.target/riscv/amo-table-a-6-compare-exchange-4.c: Ditto. + * gcc.target/riscv/amo-table-a-6-compare-exchange-5.c: Ditto. + * gcc.target/riscv/amo-table-a-6-compare-exchange-6.c: Ditto. + * gcc.target/riscv/amo-table-a-6-compare-exchange-7.c: Ditto. + * gcc.target/riscv/amo-table-a-6-subword-amo-add-1.c: Use Zaamo rather + than A. + * gcc.target/riscv/amo-table-a-6-subword-amo-add-2.c: Ditto. + * gcc.target/riscv/amo-table-a-6-subword-amo-add-3.c: Ditto. + * gcc.target/riscv/amo-table-a-6-subword-amo-add-4.c: Ditto. + * gcc.target/riscv/amo-table-a-6-subword-amo-add-5.c: Ditto. + * gcc.target/riscv/amo-table-ztso-amo-add-1.c: Add Zaamo option. + * gcc.target/riscv/amo-table-ztso-amo-add-2.c: Ditto. + * gcc.target/riscv/amo-table-ztso-amo-add-3.c: Ditto. + * gcc.target/riscv/amo-table-ztso-amo-add-4.c: Ditto. + * gcc.target/riscv/amo-table-ztso-amo-add-5.c: Ditto. + * gcc.target/riscv/amo-table-ztso-compare-exchange-1.c: Use Zalrsc rather + than A. + * gcc.target/riscv/amo-table-ztso-compare-exchange-2.c: Ditto. + * gcc.target/riscv/amo-table-ztso-compare-exchange-3.c: Ditto. + * gcc.target/riscv/amo-table-ztso-compare-exchange-4.c: Ditto. + * gcc.target/riscv/amo-table-ztso-compare-exchange-5.c: Ditto. + * gcc.target/riscv/amo-table-ztso-compare-exchange-6.c: Ditto. + * gcc.target/riscv/amo-table-ztso-compare-exchange-7.c: Ditto. + * gcc.target/riscv/amo-table-ztso-subword-amo-add-1.c: Ditto. + * gcc.target/riscv/amo-table-ztso-subword-amo-add-2.c: Ditto. + * gcc.target/riscv/amo-table-ztso-subword-amo-add-3.c: Ditto. + * gcc.target/riscv/amo-table-ztso-subword-amo-add-4.c: Ditto. + * gcc.target/riscv/amo-table-ztso-subword-amo-add-5.c: Ditto. + * lib/target-supports.exp: Add testsuite infrastructure support for + Zaamo and Zalrsc. + +2024-06-11 Edwin Lu + Patrick O'Neill + + * gcc.target/riscv/attribute-15.c: Adjust expected arch string. + * gcc.target/riscv/attribute-16.c: Ditto. + * gcc.target/riscv/attribute-17.c: Ditto. + * gcc.target/riscv/attribute-18.c: Ditto. + * gcc.target/riscv/pr110696.c: Ditto. + * gcc.target/riscv/rvv/base/pr114352-1.c: Ditto. + * gcc.target/riscv/rvv/base/pr114352-3.c: Ditto. + +2024-06-11 Uros Bizjak + + PR target/112600 + * gcc.target/i386/pr112600-a.c: Also scan for cmov. + * gcc.target/i386/pr112600-b.c: Ditto. + +2024-06-11 Pengxuan Zheng + + * gcc.target/aarch64/trunc-vec.c: New test. + +2024-06-11 Andi Kleen + + * g++.dg/ext/asm11.C: Adjust to new error message. + * g++.dg/ext/asm9.C: Dito. + * g++.dg/parse/asm1.C: Dito. + * g++.dg/parse/asm2.C: Dito. + * g++.dg/parse/asm3.C: Dito. + * g++.dg/cpp1z/constexpr-asm-1.C: New test. + * g++.dg/cpp1z/constexpr-asm-2.C: New test. + * g++.dg/cpp1z/constexpr-asm-3.C: New test. + +2024-06-11 Andi Kleen + + * g++.dg/cpp26/static_assert1.C: Update to new error message. + * g++.dg/cpp0x/udlit-error1.C: Dito. + +2024-06-11 Gaius Mulley + + PR modula2/114529 + * gm2/base-lang/pass/SYSTEM.def: New test. + * gm2/base-lang/pass/base-lang-test.sh: New test. + * gm2/base-lang/pass/globalproctype.def: New test. + * gm2/base-lang/pass/globalproctype.mod: New test. + * gm2/base-lang/pass/globalvar.def: New test. + * gm2/base-lang/pass/globalvar.mod: New test. + * gm2/base-lang/pass/globalvarassign.def: New test. + * gm2/base-lang/pass/globalvarassign.mod: New test. + * gm2/base-lang/pass/localproctype.def: New test. + * gm2/base-lang/pass/localproctype.mod: New test. + * gm2/base-lang/pass/localvar.def: New test. + * gm2/base-lang/pass/localvar.mod: New test. + * gm2/base-lang/pass/localvarassign.def: New test. + * gm2/base-lang/pass/localvarassign.mod: New test. + * gm2/base-lang/pass/opaquefield.def: New test. + * gm2/base-lang/pass/opaquefield.mod: New test. + * gm2/base-lang/pass/opaquenew.def: New test. + * gm2/base-lang/pass/opaquenew.mod: New test. + * gm2/base-lang/pass/opaqueparam.def: New test. + * gm2/base-lang/pass/opaqueparam.mod: New test. + * gm2/base-lang/pass/opaquestr.def: New test. + * gm2/base-lang/pass/opaqueuse.def: New test. + * gm2/base-lang/pass/opaqueuse.mod: New test. + * gm2/base-lang/pass/opaqueusestr.def: New test. + * gm2/base-lang/pass/opaqueusestr.mod: New test. + * gm2/base-lang/pass/opaquevariant.def: New test. + * gm2/base-lang/pass/opaquevariant.mod: New test. + * gm2/base-lang/pass/opaquevarparam.def: New test. + * gm2/base-lang/pass/opaquevarparam.mod: New test. + * gm2/base-lang/pass/simplelist.def: New test. + * gm2/base-lang/pass/simplelist.mod: New test. + * gm2/base-lang/pass/simplelistiter.def: New test. + * gm2/base-lang/pass/simplelistiter.mod: New test. + * gm2/base-lang/pass/simpleopaque.def: New test. + * gm2/base-lang/pass/simpleopaque.mod: New test. + * gm2/base-lang/pass/straddress.def: New test. + * gm2/base-lang/pass/straddress.mod: New test. + * gm2/base-lang/pass/straddressexport.def: New test. + * gm2/base-lang/pass/straddressexport.mod: New test. + * gm2/base-lang/pass/unboundedarray.def: New test. + * gm2/base-lang/pass/unboundedarray.mod: New test. + +2024-06-11 Roger Sayle + + PR target/115397 + * gcc.target/i386/pr115397.c: New test case. + +2024-06-11 Pan Li + + * gcc.target/riscv/sat_arith.h: Add helper macros for test. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-1.c: New test. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-2.c: New test. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-3.c: New test. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-4.c: New test. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-1.c: New test. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-2.c: New test. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-3.c: New test. + * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-4.c: New test. + +2024-06-11 Jeff Law + + * gcc.target/riscv/round_32.c: Delete. + +2024-06-10 Raphael Zinsly + + * gcc.target/riscv/zbs-ext.c: New test. + +2024-06-10 Pan Li + + PR target/115387 + * gcc.target/riscv/pr115387-1.c: New test. + * gcc.target/riscv/pr115387-2.c: New test. + +2024-06-10 Andrew Pinski + + PR testsuite/115415 + PR tree-optimization/115388 + * gcc.dg/torture/pr115388.c: Use `signed char` directly instead + of plain `char`. + +2024-06-10 Raphael Zinsly + + * gcc.target/riscv/bext-ext.c: New test. + +2024-06-10 Richard Biener + + PR tree-optimization/115388 + * gcc.dg/torture/pr115388.c: New testcase. + +2024-06-10 Eric Botcazou + + PR ada/114708 + * gnat.dg/incomplete8.adb: New test. + +2024-06-10 Eric Botcazou + + PR ada/114398 + * gnat.dg/access11.adb: New test. + +2024-06-10 Richard Biener + + PR tree-optimization/115395 + * gcc.dg/vect/pr115395.c: New testcase. + +2024-06-10 Andreas Krebbel + + * g++.dg/torture/vshuf-mem.C: New test. + +2024-06-10 YunQiang Su + + * gcc.target/mips/r10k-cache-barrier-13.c: Add -mno-branch-likely + option. + +2024-06-10 Richard Biener + + PR tree-optimization/115383 + * gcc.dg/vect/pr115383.c: New testcase. + +2024-06-09 Uros Bizjak + + PR target/112600 + * gcc.target/i386/pr112600-b.c: New test. + +2024-06-08 Simon Martin + + PR c++/108438 + * g++.dg/parse/crash75.C: New test. + +2024-06-08 Uros Bizjak + + PR target/112600 + * gcc.target/i386/pr112600-a.c: New test. + +2024-06-08 Pan Li + + * gcc.target/riscv/sat_arith.h: Add test macros and comments. + * gcc.target/riscv/sat_u_sub-1.c: New test. + * gcc.target/riscv/sat_u_sub-2.c: New test. + * gcc.target/riscv/sat_u_sub-3.c: New test. + * gcc.target/riscv/sat_u_sub-4.c: New test. + * gcc.target/riscv/sat_u_sub-5.c: New test. + * gcc.target/riscv/sat_u_sub-6.c: New test. + * gcc.target/riscv/sat_u_sub-7.c: New test. + * gcc.target/riscv/sat_u_sub-8.c: New test. + * gcc.target/riscv/sat_u_sub-run-1.c: New test. + * gcc.target/riscv/sat_u_sub-run-2.c: New test. + * gcc.target/riscv/sat_u_sub-run-3.c: New test. + * gcc.target/riscv/sat_u_sub-run-4.c: New test. + * gcc.target/riscv/sat_u_sub-run-5.c: New test. + * gcc.target/riscv/sat_u_sub-run-6.c: New test. + * gcc.target/riscv/sat_u_sub-run-7.c: New test. + * gcc.target/riscv/sat_u_sub-run-8.c: New test. + +2024-06-07 David Malcolm + + * gcc.dg/analyzer/taint-alloc-4.c: Update expected result to + reflect change in message due to + region_model::get_representative_path_var_1 now handling RK_CAST. + +2024-06-07 David Malcolm + + PR analyzer/105892 + * c-c++-common/analyzer/out-of-bounds-pr110387.c: Add + expected warnings about pointer subtraction. + * c-c++-common/analyzer/ptr-subtraction-1.c: New test. + * c-c++-common/analyzer/ptr-subtraction-CWE-469-example.c: New test. + +2024-06-07 Simon Martin + + PR c++/107575 + * g++.dg/parse/crash74.C: New test. + +2024-06-07 Jason Merrill + + * g++.dg/modules/dashinclude-1_b.C: New test. + * g++.dg/modules/dashinclude-1_a.H: New test. + +2024-06-07 Patrick Palka + + PR c++/115378 + * g++.dg/cpp1y/decltype-auto-103497.C: Adjust expected diagnostic. + * g++.dg/template/pr95672.C: Likewise. + * g++.dg/cpp2a/lambda-targ5.C: New test. + +2024-06-07 Roger Sayle + + PR target/115351 + * g++.target/i386/pr115351.C: New test case. + +2024-06-07 Roger Sayle + Hongtao Liu + + * gcc.target/i386/avx512f-vpternlogd-1.c: Update test case. + * gcc.target/i386/avx512f-vpternlogq-1.c: Likewise. + * gcc.target/i386/avx512vl-vpternlogd-1.c: Likewise. + * gcc.target/i386/avx512vl-vpternlogq-1.c: Likewise. + * gcc.target/i386/pr100711-4.c: Likewise. + * gcc.target/i386/pr100711-5.c: Likewise. + * gcc.target/i386/avx512f-vpternlogd-3.c: New 128-bit test case. + * gcc.target/i386/avx512f-vpternlogd-4.c: New 256-bit test case. + * gcc.target/i386/avx512f-vpternlogd-5.c: New 512-bit test case. + * gcc.target/i386/avx512f-vpternlogq-3.c: New test case. + +2024-06-07 Michal Jires + + * gcc.dg/completion-2.c: Add -flto-partition=cache. + +2024-06-07 Andre Vehreschild + + PR fortran/90068 + * gfortran.dg/finalize_57.f90: New test. + +2024-06-07 Jakub Jelinek + + PR middle-end/115352 + * gcc.dg/torture/bitint-71.c: New test. + +2024-06-07 Rainer Orth + + PR go/87589 + * go.test/go-test.exp (go-gc-tests): Require split-stack support + for index0.go. + +2024-06-07 Andre Vehreschild + + PR fortran/90072 + * gfortran.dg/class_77.f90: New test. + +2024-06-07 liuhongt + + * gcc.dg/vect/pr112325.c:Add additional option --param + max-completely-peeled-insns=200 for power64*-*-*. + +2024-06-07 Pan Li + + * gcc.target/riscv/sat_arith.h: Add test macro for form 5. + * gcc.target/riscv/sat_u_add-21.c: New test. + * gcc.target/riscv/sat_u_add-22.c: New test. + * gcc.target/riscv/sat_u_add-23.c: New test. + * gcc.target/riscv/sat_u_add-24.c: New test. + * gcc.target/riscv/sat_u_add-run-21.c: New test. + * gcc.target/riscv/sat_u_add-run-22.c: New test. + * gcc.target/riscv/sat_u_add-run-23.c: New test. + * gcc.target/riscv/sat_u_add-run-24.c: New test. + +2024-06-07 Pan Li + + * gcc.target/riscv/sat_arith.h: Add test macro for form 4. + * gcc.target/riscv/sat_u_add-17.c: New test. + * gcc.target/riscv/sat_u_add-18.c: New test. + * gcc.target/riscv/sat_u_add-19.c: New test. + * gcc.target/riscv/sat_u_add-20.c: New test. + * gcc.target/riscv/sat_u_add-run-17.c: New test. + * gcc.target/riscv/sat_u_add-run-18.c: New test. + * gcc.target/riscv/sat_u_add-run-19.c: New test. + * gcc.target/riscv/sat_u_add-run-20.c: New test. + +2024-06-07 Pan Li + + * gcc.target/riscv/sat_arith.h: Add test macro for form 3. + * gcc.target/riscv/sat_u_add-13.c: New test. + * gcc.target/riscv/sat_u_add-14.c: New test. + * gcc.target/riscv/sat_u_add-15.c: New test. + * gcc.target/riscv/sat_u_add-16.c: New test. + * gcc.target/riscv/sat_u_add-run-13.c: New test. + * gcc.target/riscv/sat_u_add-run-14.c: New test. + * gcc.target/riscv/sat_u_add-run-15.c: New test. + * gcc.target/riscv/sat_u_add-run-16.c: New test. + +2024-06-07 Pan Li + + * gcc.target/riscv/sat_arith.h: Add test macro for form 2. + * gcc.target/riscv/sat_u_add-10.c: New test. + * gcc.target/riscv/sat_u_add-11.c: New test. + * gcc.target/riscv/sat_u_add-12.c: New test. + * gcc.target/riscv/sat_u_add-9.c: New test. + * gcc.target/riscv/sat_u_add-run-10.c: New test. + * gcc.target/riscv/sat_u_add-run-11.c: New test. + * gcc.target/riscv/sat_u_add-run-12.c: New test. + * gcc.target/riscv/sat_u_add-run-9.c: New test. + +2024-06-07 Pan Li + + * gcc.target/riscv/sat_arith.h: Add helper macro for form 1. + * gcc.target/riscv/sat_u_add-5.c: New test. + * gcc.target/riscv/sat_u_add-6.c: New test. + * gcc.target/riscv/sat_u_add-7.c: New test. + * gcc.target/riscv/sat_u_add-8.c: New test. + * gcc.target/riscv/sat_u_add-run-5.c: New test. + * gcc.target/riscv/sat_u_add-run-6.c: New test. + * gcc.target/riscv/sat_u_add-run-7.c: New test. + * gcc.target/riscv/sat_u_add-run-8.c: New test. + 2024-06-06 Jakub Jelinek PR c/114493 diff --git a/gcc/testsuite/c-c++-common/Warray-compare-3.c b/gcc/testsuite/c-c++-common/Warray-compare-3.c new file mode 100644 index 0000000000000..4725aa2b38bf4 --- /dev/null +++ b/gcc/testsuite/c-c++-common/Warray-compare-3.c @@ -0,0 +1,13 @@ +/* PR c/115290 */ +/* { dg-do compile } */ +/* { dg-options "-Warray-compare" } */ + +int a[32][32], b[32][32]; + +int +foo (int x, int y) +{ + return (x ? a : b) == (y ? a : b); /* { dg-warning "comparison between two arrays" } */ +/* { dg-message "use '&\\\(\[^\n\r]*\\\)\\\[0\\\] == &\\\(\[^\n\r]*\\\)\\\[0\\\]' to compare the addresses" "" { target c } .-1 } */ +/* { dg-message "use unary '\\\+' which decays operands to pointers or '&\\\(\[^\n\r]*\\\)\\\[0\\\] == &\\\(\[^\n\r]*\\\)\\\[0\\\]' to compare the addresses" "" { target c++ } .-2 } */ +} diff --git a/gcc/testsuite/c-c++-common/analyzer/out-of-bounds-pr110387.c b/gcc/testsuite/c-c++-common/analyzer/out-of-bounds-pr110387.c index a046659c83ea9..b4454805eb586 100644 --- a/gcc/testsuite/c-c++-common/analyzer/out-of-bounds-pr110387.c +++ b/gcc/testsuite/c-c++-common/analyzer/out-of-bounds-pr110387.c @@ -12,8 +12,8 @@ _S_copy (long __n) void _M_construct () { - x = &c - &b; + x = &c - &b; /* { dg-warning "undefined behavior when subtracting pointers" } */ unsigned long __dnew = x; if (__dnew > 1) - _S_copy (&c - &b); + _S_copy (&c - &b); /* { dg-warning "undefined behavior when subtracting pointers" } */ } diff --git a/gcc/testsuite/c-c++-common/analyzer/ptr-subtraction-1.c b/gcc/testsuite/c-c++-common/analyzer/ptr-subtraction-1.c new file mode 100644 index 0000000000000..73684c115fc2d --- /dev/null +++ b/gcc/testsuite/c-c++-common/analyzer/ptr-subtraction-1.c @@ -0,0 +1,46 @@ +#include + +ptrdiff_t +test_invalid_sub_addrs_of_locals (void) +{ + int a; /* { dg-message "underlying object for left-hand side of subtraction created here" } */ + int b; /* { dg-message "underlying object for right-hand side of subtraction created here" } */ + return &a - &b; /* { dg-warning "undefined behavior when subtracting pointers \\\[CWE-469\\\] \\\[-Wanalyzer-undefined-behavior-ptrdiff\\\]" } */ + /* { dg-message "subtraction of pointers has undefined behavior if they do not point into the same array object" "final event" { target *-*-* } .-1 } */ +} + +ptrdiff_t +test_valid_sub_addrs_within_array (void) +{ + int a[10]; + return &a[7] - &a[3]; +} + +ptrdiff_t +test_invalid_sub_addrs_within_arrays (void) +{ + int a[10]; /* { dg-message "left-hand side" } */ + int b[10]; /* { dg-message "right-hand side" } */ + return &a[7] - &b[3]; /* { dg-warning "undefined behavior when subtracting pointers" } */ +} + + +ptrdiff_t +test_invalid_sub_addrs_between_heap_allocs (size_t n) +{ + char *p = (char *)__builtin_malloc (n); /* { dg-message "left-hand side" } */ + char *q = (char *)__builtin_malloc (n); /* { dg-message "right-hand side" } */ + ptrdiff_t d = p - q; /* { dg-warning "undefined behavior when subtracting pointers" } */ + __builtin_free (p); + __builtin_free (q); + return d; +} + +int arr[42]; /* { dg-message "right-hand side" } */ +int sentinel; /* { dg-message "left-hand side" } */ + +ptrdiff_t +test_invalid_calc_of_array_size (void) +{ + return &sentinel - arr; /* { dg-warning "undefined behavior when subtracting pointers" } */ +} diff --git a/gcc/testsuite/c-c++-common/analyzer/ptr-subtraction-CWE-469-example.c b/gcc/testsuite/c-c++-common/analyzer/ptr-subtraction-CWE-469-example.c new file mode 100644 index 0000000000000..7f8bd342acb0c --- /dev/null +++ b/gcc/testsuite/c-c++-common/analyzer/ptr-subtraction-CWE-469-example.c @@ -0,0 +1,81 @@ +/* Example heavily adapted from https://cwe.mitre.org/data/definitions/469.html + which states "Copyright © 2006–2024, The MITRE Corporation. CWE, CWSS, CWRAF, and the CWE logo are trademarks of The MITRE Corporation." + and which has this on: + https://cwe.mitre.org/about/termsofuse.html + + Terms of Use + + CWE™ is free to use by any organization or individual for any research, development, and/or commercial purposes, per these CWE Terms of Use. Accordingly, The MITRE Corporation hereby grants you a non-exclusive, royalty-free license to use CWE for research, development, and commercial purposes. Any copy you make for such purposes is authorized on the condition that you reproduce MITRE’s copyright designation and this license in any such copy. CWE is a trademark of The MITRE Corporation. Please contact cwe@mitre.org if you require further clarification on this issue. + + DISCLAIMERS + + By accessing information through this site you (as “the user”) hereby agrees the site and the information is provided on an “as is” basis only without warranty of any kind, express or implied, including but not limited to implied warranties of merchantability, availability, accuracy, noninfringement, or fitness for a particular purpose. Use of this site and the information is at the user’s own risk. The user shall comply with all applicable laws, rules, and regulations, and the data source’s restrictions, when using the site. + + By contributing information to this site you (as “the contributor”) hereby represents and warrants the contributor has obtained all necessary permissions from copyright holders and other third parties to allow the contributor to contribute, and this site to host and display, the information and any such contribution, hosting, and displaying will not violate any law, rule, or regulation. Additionally, the contributor hereby grants all users of such information a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute such information and all derivative works. + + The MITRE Corporation expressly disclaims any liability for any damages arising from the contributor’s contribution of such information, the user’s use of the site or such information, and The MITRE Corporation’s hosting the tool and displaying the information. The foregoing disclaimer specifically includes but is not limited to general, consequential, indirect, incidental, exemplary, or special or punitive damages (including but not limited to loss of income, program interruption, loss of information, or other pecuniary loss) arising out of use of this information, no matter the cause of action, even if The MITRE Corporation has been advised of the possibility of such damages. */ + +/* We need this for the issue to be found, or the loop analysis + is too simplistic. */ +/* { dg-additional-options "-fno-analyzer-state-merge" } */ +/* { dg-additional-options "-Wno-analyzer-too-complex" } */ +/* { dg-additional-options "-Wno-analyzer-symbol-too-complex" } */ + +#include + +struct node { + int data; + struct node* next; +}; + +/* The example fails to initialize "tail" for the head == NULL case. */ + +int example_1_with_uninit (struct node* head) { + struct node* current = head; + struct node* tail; + while (current != NULL) { + tail = current; + current = current->next; + } + return tail - head; /* { dg-warning "use of uninitialized value 'tail'" } */ +} + +int example_1_bad (struct node* head) { + struct node* current = head; + struct node* tail = head; /* initialization added */ + while (current != NULL) { + tail = current; + current = current->next; + } + return tail - head; /* { dg-warning "undefined behavior when subtracting pointers" } */ +} + +int example_1_good (struct node* head) { + struct node* current = head; + int count = 0; + while (current != NULL) { + count++; + current = current->next; + } + return count; +} + +/* We need to add usage of the function to detect the issue. */ + +int usage_of_example_1_bad (void) +{ + struct node p; /* { dg-message "right-hand side" } */ + struct node q; /* { dg-message "left-hand side" } */ + p.next = &q; + q.next = NULL; + return example_1_bad (&p); +} + +int usage_of_example_1_good (void) +{ + struct node p; + struct node q; + p.next = &q; + q.next = NULL; + return example_1_good (&p); +} diff --git a/gcc/testsuite/c-c++-common/pr72747-1.c b/gcc/testsuite/c-c++-common/pr72747-1.c index e87069df0f667..f825dfafa6951 100644 --- a/gcc/testsuite/c-c++-common/pr72747-1.c +++ b/gcc/testsuite/c-c++-common/pr72747-1.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -fdump-tree-gimple" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* PR 72747: Test that cascaded definition is happening for constant vectors. */ diff --git a/gcc/testsuite/c-c++-common/pr72747-2.c b/gcc/testsuite/c-c++-common/pr72747-2.c index 080d6fc42510a..407840f19c40c 100644 --- a/gcc/testsuite/c-c++-common/pr72747-2.c +++ b/gcc/testsuite/c-c++-common/pr72747-2.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-c -maltivec -fdump-tree-gimple" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* PR 72747: test that cascaded definition is happening for non constants. */ diff --git a/gcc/testsuite/c-c++-common/strub-pr113681.c b/gcc/testsuite/c-c++-common/strub-pr113681.c new file mode 100644 index 0000000000000..3ef9017b2eb70 --- /dev/null +++ b/gcc/testsuite/c-c++-common/strub-pr113681.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrub=relaxed -fbranch-probabilities" } */ +/* { dg-require-effective-target strub } */ + +/* Same as torture/strub-inlineable1.c, but with -fbranch-probabilities, to + check that IPA tree-profiling won't ICE. It would when we refrained from + running passes that would take it to IPA_SSA, but ran the pass that asserted + for IPA_SSA. */ + +inline void __attribute__ ((strub ("internal"), always_inline)) +inl_int_ali (void) +{ + /* No internal wrapper, so this body ALWAYS gets inlined, + but it cannot be called from non-strub contexts. */ +} + +void +bat (void) +{ + /* Not allowed, not a strub context. */ + inl_int_ali (); /* { dg-error "context" } */ +} diff --git a/gcc/testsuite/g++.dg/cpp0x/udlit-error1.C b/gcc/testsuite/g++.dg/cpp0x/udlit-error1.C index 6d6cd454540a7..ea939c52c3394 100644 --- a/gcc/testsuite/g++.dg/cpp0x/udlit-error1.C +++ b/gcc/testsuite/g++.dg/cpp0x/udlit-error1.C @@ -12,7 +12,7 @@ void operator""_x(const char *, decltype(sizeof(0))); extern "C"_x { void g(); } // { dg-error "before user-defined string literal" } static_assert(true, "foo"_x); // { dg-error "'static_assert' with non-string message only available with" "" { target c++23_down } } - // { dg-error "'static_assert' message must be a string literal or object with 'size' and 'data' members" "" { target *-*-* } .-1 } + // { dg-error "constexpr string must be a string literal or object with 'size' and 'data' members" "" { target *-*-* } .-1 } // { dg-error "invalid use of 'void'" "" { target *-*-* } .-2 } [[deprecated("oof"_x)]] // { dg-error "string literal with user-defined suffix is invalid in this context" "" { target c++26 } } diff --git a/gcc/testsuite/g++.dg/cpp1y/decltype-auto-103497.C b/gcc/testsuite/g++.dg/cpp1y/decltype-auto-103497.C index cedd661710cd4..4162361d14f60 100644 --- a/gcc/testsuite/g++.dg/cpp1y/decltype-auto-103497.C +++ b/gcc/testsuite/g++.dg/cpp1y/decltype-auto-103497.C @@ -1,7 +1,7 @@ // PR c++/103497 // { dg-do compile { target c++14 } } -void foo(decltype(auto)... args); // { dg-error "cannot declare a parameter with .decltype.auto.." } +void foo(decltype(auto)... args); // { dg-error "contains no parameter packs" } int main() { foo(); diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-1.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-1.C new file mode 100644 index 0000000000000..311209acb43b2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-1.C @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu++17" } */ + +#include + +constexpr std::string_view genfoo () +{ + return "foo %1,%0"; +} + +constexpr std::string_view genoutput () +{ + return "=r"; +} + +constexpr std::string_view geninput () +{ + return "r"; +} + +constexpr std::string_view genclobber () +{ + return "memory"; +} + +void f() +{ + int a; + asm((genfoo ()) : (genoutput ()) (a) : (geninput ()) (1) : (genclobber ())); +} + +/* { dg-final { scan-assembler "foo" } } */ diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-2.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-2.C new file mode 100644 index 0000000000000..7d0eb590afbe1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-2.C @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu++11" } */ + +using size_t = typeof(sizeof(0)); +template +struct array { + constexpr size_t size () const { return N; } + constexpr const T *data () const { return a; } + const T a[N]; +}; + +void f() +{ + int a; + asm((array {'f','o','o'}) : + (array{'=','r'}) (a) : + (array{'r'}) (1) : + (array{'m','e','m','o','r','y'})); +} + +/* { dg-final { scan-assembler "foo" } } */ diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-3.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-3.C new file mode 100644 index 0000000000000..0cf8940e109cf --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-3.C @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu++17" } */ + +#include + +constexpr std::string_view genfoo () +{ + return "foo %1,%0"; +} + +constexpr std::string_view genoutput () +{ + return "=r"; +} + +constexpr std::string_view geninput () +{ + return "r"; +} + +constexpr std::string_view genclobber () +{ + return "memory"; +} + +void f() +{ + int a; + asm(genfoo () : /* { dg-error "expected string-literal or constexpr in parentheses" } */ + genoutput() (a) : + geninput() (1) : + genclobber()); +} diff --git a/gcc/testsuite/g++.dg/cpp1z/pr115440.C b/gcc/testsuite/g++.dg/cpp1z/pr115440.C new file mode 100644 index 0000000000000..788d4806fe2d2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/pr115440.C @@ -0,0 +1,8 @@ +// PR driver/115440 +// { dg-do compile { target c++17_only } } +// { dg-options "--c++17" } + +int i; + +// { dg-bogus "unrecognized command-line option '--c\\\+\\\+17'; did you mean '--stdc\\\+\\\+17'" "" { target *-*-* } 0 } +// { dg-error "unrecognized command-line option '--c\\\+\\\+17'" "" { target *-*-* } 0 } diff --git a/gcc/testsuite/g++.dg/cpp23/ext-floating18.C b/gcc/testsuite/g++.dg/cpp23/ext-floating18.C new file mode 100644 index 0000000000000..ece25464bfdf7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp23/ext-floating18.C @@ -0,0 +1,26 @@ +// P1467R9 - Extended floating-point types and standard names. +// { dg-do compile { target c++23 } } +// { dg-options "" } +// { dg-add-options float32 } + +constexpr int foo (float) { return 1; } +constexpr int foo (double) { return 2; } +constexpr int foo (long double) { return 3; } + +#ifdef __STDCPP_FLOAT32_T__ +#if __FLT_MAX_EXP__ == __FLT32_MAX_EXP__ \ + && __FLT_MAX_DIG__ == __FLT32_MAX_DIG__ +#if __FLT_MAX_EXP__ == __DBL_MAX_EXP__ \ + && __FLT_MAX_DIG__ == __DBL_MAX_DIG__ +static_assert (foo (1.0f32) == 2); +#else +static_assert (foo (1.0f32) == 1); +#endif +#endif +#endif +#ifdef __STDCPP_FLOAT64_T__ +#if __DBL_MAX_EXP__ == __FLT64_MAX_EXP__ \ + && __DBL_MAX_DIG__ == __FLT64_MAX_DIG__ +static_assert (foo (1.0f64) == 2); +#endif +#endif diff --git a/gcc/testsuite/g++.dg/cpp26/static_assert1.C b/gcc/testsuite/g++.dg/cpp26/static_assert1.C index 59724ae32ce31..f9ac8311b8276 100644 --- a/gcc/testsuite/g++.dg/cpp26/static_assert1.C +++ b/gcc/testsuite/g++.dg/cpp26/static_assert1.C @@ -6,25 +6,25 @@ static_assert (true, ""); static_assert (true, ("")); // { dg-warning "'static_assert' with non-string message only available with" "" { target c++23_down } } - // { dg-error "'static_assert' message must be a string literal or object with 'size' and 'data' members" "" { target *-*-* } .-1 } + // { dg-error "constexpr string must be a string literal or object with 'size' and 'data' members" "" { target *-*-* } .-1 } // { dg-error "request for member 'size' in '\\\(\\\"\\\"\\\)', which is of non-class type 'const char \\\[1\\\]'" "" { target *-*-* } .-2 } static_assert (true, "" + 0); // { dg-warning "'static_assert' with non-string message only available with" "" { target c++23_down } } - // { dg-error "'static_assert' message must be a string literal or object with 'size' and 'data' members" "" { target *-*-* } .-1 } + // { dg-error "constexpr string must be a string literal or object with 'size' and 'data' members" "" { target *-*-* } .-1 } // { dg-error "request for member 'size' in '\\\(const char\\\*\\\)\\\"\\\"', which is of non-class type 'const char\\\*'" "" { target *-*-* } .-2 } static_assert (true, 0); // { dg-warning "'static_assert' with non-string message only available with" "" { target c++23_down } } - // { dg-error "'static_assert' message must be a string literal or object with 'size' and 'data' members" "" { target *-*-* } .-1 } + // { dg-error "constexpr string must be a string literal or object with 'size' and 'data' members" "" { target *-*-* } .-1 } // { dg-error "request for member 'size' in '0', which is of non-class type 'int'" "" { target *-*-* } .-2 } struct A {}; static_assert (true, A {}); // { dg-warning "'static_assert' with non-string message only available with" "" { target c++23_down } } - // { dg-error "'static_assert' message must be a string literal or object with 'size' and 'data' members" "" { target *-*-* } .-1 } + // { dg-error "constexpr string must be a string literal or object with 'size' and 'data' members" "" { target *-*-* } .-1 } // { dg-error "'struct A' has no member named 'size'" "" { target *-*-* } .-2 } struct B { int size; }; static_assert (true, B {}); // { dg-warning "'static_assert' with non-string message only available with" "" { target c++23_down } } - // { dg-error "'static_assert' message must be a string literal or object with 'size' and 'data' members" "" { target *-*-* } .-1 } + // { dg-error "constexpr string must be a string literal or object with 'size' and 'data' members" "" { target *-*-* } .-1 } // { dg-error "'struct B' has no member named 'data'" "" { target *-*-* } .-2 } struct C { constexpr int size () const { return 0; } }; static_assert (true, C {}); // { dg-warning "'static_assert' with non-string message only available with" "" { target c++23_down } } - // { dg-error "'static_assert' message must be a string literal or object with 'size' and 'data' members" "" { target *-*-* } .-1 } + // { dg-error "constexpr string must be a string literal or object with 'size' and 'data' members" "" { target *-*-* } .-1 } // { dg-error "'struct C' has no member named 'data'" "" { target *-*-* } .-2 } struct D { constexpr int size () const { return 0; } int data; }; static_assert (true, D {}); // { dg-warning "'static_assert' with non-string message only available with" "" { target c++23_down } } @@ -37,13 +37,13 @@ static_assert (true, E {}); // { dg-warning "'static_assert' with non-string mes struct F { constexpr const char *size () const { return ""; } constexpr const char *data () const { return ""; } }; static_assert (true, F {}); // { dg-warning "'static_assert' with non-string message only available with" "" { target c++23_down } } - // { dg-error "'static_assert' message 'size\\\(\\\)' must be implicitly convertible to 'std::size_t'" "" { target *-*-* } .-1 } + // { dg-error "constexpr string 'size\\\(\\\)' must be implicitly convertible to 'std::size_t'" "" { target *-*-* } .-1 } // { dg-error "could not convert 'F\\\(\\\).F::size\\\(\\\)' from 'const char\\\*' to '\[^']*'" "" { target *-*-* } .-2 } // { dg-error "conversion from 'const char\\\*' to '\[^']*' in a converted constant expression" "" { target *-*-* } .-3 } struct G { constexpr long size () const { return 0; } constexpr float data () const { return 0.0f; } }; static_assert (true, G {}); // { dg-warning "'static_assert' with non-string message only available with" "" { target c++23_down } } - // { dg-error "'static_assert' message 'data\\\(\\\)' must be implicitly convertible to 'const char\\\*'" "" { target *-*-* } .-1 } + // { dg-error "constexpr string 'data\\\(\\\)' must be implicitly convertible to 'const char\\\*'" "" { target *-*-* } .-1 } // { dg-error "could not convert 'G\\\(\\\).G::data\\\(\\\)' from 'float' to 'const char\\\*'" "" { target *-*-* } .-2 } struct H { short size () const { return 0; } constexpr const char *data () const { return ""; } }; @@ -59,7 +59,7 @@ static_assert (true, J (1)); // { dg-warning "'static_assert' with non-string me static_assert (false, J (0)); // { dg-warning "'static_assert' with non-string message only available with" "" { target c++23_down } } // { dg-error "static assertion failed" "" { target *-*-* } .-1 } static_assert (false, J (1)); // { dg-warning "'static_assert' with non-string message only available with" "" { target c++23_down } } - // { dg-error "'static_assert' message 'size\\\(\\\)' must be a constant expression" "" { target *-*-* } .-1 } + // { dg-error "constexpr string 'size\\\(\\\)' must be a constant expression" "" { target *-*-* } .-1 } struct K { constexpr operator int () { return 4; } }; struct L { constexpr operator const char * () { return "test"; } }; struct M { constexpr K size () const { return {}; } @@ -72,7 +72,7 @@ struct N { constexpr int size () const { return 3; } constexpr const char *data () const { return new char[3] { 'b', 'a', 'd' }; } }; // { dg-error "'\\\* N\\\(\\\).N::data\\\(\\\)' is not a constant expression because allocated storage has not been deallocated" "" { target c++20 } } static_assert (true, N {}); // { dg-warning "'static_assert' with non-string message only available with" "" { target { c++20 && c++23_down } } } static_assert (false, N {}); // { dg-warning "'static_assert' with non-string message only available with" "" { target { c++20 && c++23_down } } } - // { dg-error "'static_assert' message 'data\\\(\\\)\\\[0\\\]' must be a constant expression" "" { target c++20 } .-1 } + // { dg-error "constexpr string 'data\\\(\\\)\\\[0\\\]' must be a constant expression" "" { target c++20 } .-1 } #endif constexpr const char a[] = { 't', 'e', 's', 't' }; struct O { constexpr int size () const { return 4; } @@ -133,7 +133,7 @@ static_assert (false, string_view (4, "testwithextrachars")); // { dg-warning "' // { dg-error "static assertion failed: test" "" { target *-*-* } .-1 } static_assert (false, string_view (42, "test")); // { dg-warning "'static_assert' with non-string message only available with" "" { target c++23_down } } // { dg-error "array subscript value '41' is outside the bounds of array type 'const char \\\[5\\\]'" "" { target *-*-* } .-1 } - // { dg-error "'static_assert' message 'data\\\(\\\)\\\[41\\\]' must be a constant expression" "" { target *-*-* } .-2 } + // { dg-error "constexpr string 'data\\\(\\\)\\\[41\\\]' must be a constant expression" "" { target *-*-* } .-2 } template struct array { @@ -143,7 +143,7 @@ struct array { }; static_assert (true, array { 'O', 'K' }); // { dg-warning "'static_assert' with non-string message only available with" "" { target c++23_down } } static_assert (true, array { L'O', L'K' }); // { dg-warning "'static_assert' with non-string message only available with" "" { target c++23_down } } - // { dg-error "'static_assert' message 'data\\\(\\\)' must be implicitly convertible to 'const char\\\*'" "" { target *-*-* } .-1 } + // { dg-error "constexpr string 'data\\\(\\\)' must be implicitly convertible to 'const char\\\*'" "" { target *-*-* } .-1 } // { dg-error "could not convert 'array{const wchar_t \\\[2\\\]{\[0-9]+, \[0-9]+}}.array::data\\\(\\\)' from 'const wchar_t\\\*' to 'const char\\\*'" "" { target *-*-* } .-2 } static_assert (false, array { 't', 'e', 's', 't' }); // { dg-warning "'static_assert' with non-string message only available with" "" { target c++23_down } } // { dg-error "static assertion failed: test" "" { target *-*-* } .-1 } @@ -235,7 +235,7 @@ namespace NN template struct G { static_assert (false, T{}); // { dg-warning "'static_assert' with non-string message only available with" "" { target c++23_down } } - }; // { dg-error "'static_assert' message must be a string literal or object with 'size' and 'data' members" "" { target *-*-* } .-1 } + }; // { dg-error "constexpr string must be a string literal or object with 'size' and 'data' members" "" { target *-*-* } .-1 } // { dg-error "request for member 'size' in '0', which is of non-class type 'long int'" "" { target *-*-* } .-2 } F fe; G gl; @@ -263,7 +263,7 @@ namespace NN static constexpr const char *data (int x = 0) { if (x) return nullptr; else throw 1; } }; // { dg-error "expression '' is not a constant expression" "" { target c++14 } } static_assert (true, J{}); // { dg-warning "'static_assert' with non-string message only available with" "" { target { c++14 && c++23_down } } } static_assert (false, J{}); // { dg-warning "'static_assert' with non-string message only available with" "" { target { c++14 && c++23_down } } } - // { dg-error "'static_assert' message 'data\\\(\\\)' must be a core constant expression" "" { target c++14 } .-1 } + // { dg-error "constexpr string 'data\\\(\\\)' must be a core constant expression" "" { target c++14 } .-1 } #endif #if __cpp_if_consteval >= 202106L struct K { @@ -286,14 +286,14 @@ namespace NN }; static_assert (true, M{}); // { dg-warning "'static_assert' with non-string message only available with" "" { target c++23_only } } static_assert (false, M{}); // { dg-warning "'static_assert' with non-string message only available with" "" { target c++23_only } } - // { dg-error "'static_assert' message 'size\\\(\\\)' must be a constant expression" "" { target c++23 } .-1 } + // { dg-error "constexpr string 'size\\\(\\\)' must be a constant expression" "" { target c++23 } .-1 } struct N { static constexpr int size () { return 4; } static constexpr const char *data () { if consteval { throw 1; } else { return "test"; } } // { dg-error "expression '' is not a constant expression" "" { target c++23 } } }; static_assert (true, N{}); // { dg-warning "'static_assert' with non-string message only available with" "" { target c++23_only } } static_assert (false, N{}); // { dg-warning "'static_assert' with non-string message only available with" "" { target c++23_only } } - // { dg-error "'static_assert' message 'data\\\(\\\)\\\[0\\\]' must be a constant expression" "" { target c++23 } .-1 } + // { dg-error "constexpr string 'data\\\(\\\)\\\[0\\\]' must be a constant expression" "" { target c++23 } .-1 } #endif struct O { constexpr int operator () () const { return 12; } }; struct P { constexpr const char *operator () () const { return "another test"; } }; diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-requires38.C b/gcc/testsuite/g++.dg/cpp2a/concepts-requires38.C new file mode 100644 index 0000000000000..663195b79cc7c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-requires38.C @@ -0,0 +1,14 @@ +// PR c++/99678 +// { dg-do compile { target c++20 } } + +template +void f1() requires undeclared_identifier; // { dg-error "not declared" } + +template +void f2() requires true && undeclared_identifier; // { dg-error "not declared" } + +template +void f3() requires false || undeclared_identifier; // { dg-error "not declared" } + +template +void f4() requires undeclared_identifier(T{}); // { dg-error "must be enclosed in parentheses" } diff --git a/gcc/testsuite/g++.dg/cpp2a/lambda-targ5.C b/gcc/testsuite/g++.dg/cpp2a/lambda-targ5.C new file mode 100644 index 0000000000000..efd4bb45d5874 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/lambda-targ5.C @@ -0,0 +1,15 @@ +// PR c++/115378 +// { dg-do compile { target c++20 } } + +struct tt {}; + +template +constexpr auto __counter = 1; + +template +using _as_base = tt; + +template +struct env : _as_base>... {}; + +env t; diff --git a/gcc/testsuite/g++.dg/ext/asm11.C b/gcc/testsuite/g++.dg/ext/asm11.C index 7939aacc0f424..97a299a7ecb29 100644 --- a/gcc/testsuite/g++.dg/ext/asm11.C +++ b/gcc/testsuite/g++.dg/ext/asm11.C @@ -6,15 +6,15 @@ void foo () { int i; - asm (); // { dg-error "expected string-literal before" } - asm (1); // { dg-error "expected string-literal before" } - asm (int); // { dg-error "expected string-literal before" } - asm (: "=r" (i)); // { dg-error "expected string-literal before" } - asm (1 : "=r" (i)); // { dg-error "expected string-literal before" } - asm (int : "=r" (i)); // { dg-error "expected string-literal before" } - asm (: : "r" (i)); // { dg-error "expected string-literal before" } - asm (1 : : "r" (i)); // { dg-error "expected string-literal before" } - asm (int : : "r" (i)); // { dg-error "expected string-literal before" } - asm (: : : "memory"); // { dg-error "expected string-literal before" } - asm (1 : : : "memory"); // { dg-error "expected string-literal before" } + asm (); // { dg-error "expected string-literal" } + asm (1); // { dg-error "expected string-literal" } + asm (int); // { dg-error "expected string-literal" } + asm (: "=r" (i)); // { dg-error "expected string-literal" } + asm (1 : "=r" (i)); // { dg-error "expected string-literal" } + asm (int : "=r" (i)); // { dg-error "expected string-literal" } + asm (: : "r" (i)); // { dg-error "expected string-literal" } + asm (1 : : "r" (i)); // { dg-error "expected string-literal" } + asm (int : : "r" (i)); // { dg-error "expected string-literal" } + asm (: : : "memory"); // { dg-error "expected string-literal" } + asm (1 : : : "memory"); // { dg-error "expected string-literal" } } diff --git a/gcc/testsuite/g++.dg/ext/asm9.C b/gcc/testsuite/g++.dg/ext/asm9.C index 9daa01bbf5f9d..3bce845c97a07 100644 --- a/gcc/testsuite/g++.dg/ext/asm9.C +++ b/gcc/testsuite/g++.dg/ext/asm9.C @@ -3,5 +3,6 @@ void foo() { - asm("" ::: X); // { dg-error "before" } + asm("" ::: X); // { dg-error "string-literal" } + // { dg-error "before" "" { target *-*-* } .-1 } } diff --git a/gcc/testsuite/g++.dg/modules/dashinclude-1_a.H b/gcc/testsuite/g++.dg/modules/dashinclude-1_a.H new file mode 100644 index 0000000000000..c1b40a5392432 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/dashinclude-1_a.H @@ -0,0 +1,5 @@ +// { dg-module-do run } +// { dg-additional-options "-fmodule-header" } +// { dg-module-cmi {} } + +inline int f() { return 0; } diff --git a/gcc/testsuite/g++.dg/modules/dashinclude-1_b.C b/gcc/testsuite/g++.dg/modules/dashinclude-1_b.C new file mode 100644 index 0000000000000..6e6a33407a46b --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/dashinclude-1_b.C @@ -0,0 +1,9 @@ +// Test that include translation works with command-line -include. +// { dg-additional-options "-fmodules-ts -fdump-lang-module -include $srcdir/g++.dg/modules/dashinclude-1_a.H" } + +int main () +{ + return f(); +} + +// { dg-final { scan-lang-dump {Translating include to import} module } } diff --git a/gcc/testsuite/g++.dg/modules/using-20_a.C b/gcc/testsuite/g++.dg/modules/using-20_a.C new file mode 100644 index 0000000000000..bb3bb6160f8b6 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-20_a.C @@ -0,0 +1,14 @@ +// { dg-additional-options "-fmodules-ts -fdump-lang-module -Wno-global-module" } +// { dg-final { scan-lang-dump {Writing definition '::foo::bar::baz'} module } } + +module; +namespace foo { + namespace bar { + struct baz { }; + } + using bar::baz; +} +export module foo; +namespace foo { + export using foo::baz; +} diff --git a/gcc/testsuite/g++.dg/modules/using-21_a.C b/gcc/testsuite/g++.dg/modules/using-21_a.C new file mode 100644 index 0000000000000..ce6e3f920f1e8 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-21_a.C @@ -0,0 +1,11 @@ +// { dg-additional-options "-fmodules-ts -Wno-global-module" } + +module; +namespace foo { + void baz(); +} +export module foo; +namespace foo { + export using foo::baz; + export using foo::baz; +} diff --git a/gcc/testsuite/g++.dg/modules/using-22_a.C b/gcc/testsuite/g++.dg/modules/using-22_a.C new file mode 100644 index 0000000000000..9eca9dacb46c1 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-22_a.C @@ -0,0 +1,24 @@ +// PR c++/114683 +// { dg-additional-options "-fmodules-ts -Wno-global-module" } + +module; + +namespace std +{ + inline namespace __cxx11 + { + template + struct basic_string{}; + } +} + +namespace foo { + using std::basic_string; +} + +export module std; + +export namespace std +{ + using std::basic_string; +} diff --git a/gcc/testsuite/g++.dg/modules/using-22_b.C b/gcc/testsuite/g++.dg/modules/using-22_b.C new file mode 100644 index 0000000000000..0b66f4ad6b089 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-22_b.C @@ -0,0 +1,13 @@ +// { dg-additional-options "-fmodules-ts" } + +import std; + +int main() +{ + std::basic_string s; + + // The inline namespace should not be exported, only the 'using' in std. + std::__cxx11::basic_string s2; // { dg-error "has not been declared" "" { xfail *-*-* } } + // The non-exported using should also not be visible. + foo::basic_string s3; // { dg-error "has not been declared" "" { xfail *-*-* } } +} diff --git a/gcc/testsuite/g++.dg/modules/using-23_a.C b/gcc/testsuite/g++.dg/modules/using-23_a.C new file mode 100644 index 0000000000000..e7e6fecbea651 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-23_a.C @@ -0,0 +1,19 @@ +// PR c++/115194 +// { dg-additional-options "-fmodules-ts -Wno-global-module" } + +module; + +namespace NS1 { + namespace NS2 { + class Thing {}; + } // NS2 + using NS2::Thing; +} // NS1 + +export module modA; + +export +namespace NS1 { + using ::NS1::Thing; + namespace NS2 { } +} diff --git a/gcc/testsuite/g++.dg/modules/using-23_b.C b/gcc/testsuite/g++.dg/modules/using-23_b.C new file mode 100644 index 0000000000000..6502c476b9b1f --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-23_b.C @@ -0,0 +1,7 @@ +// { dg-additional-options "-fmodules-ts" } + +import modA; + +using NS1::Thing; +using namespace NS1::NS2; +Thing thing; diff --git a/gcc/testsuite/g++.dg/overload/error7.C b/gcc/testsuite/g++.dg/overload/error7.C new file mode 100644 index 0000000000000..de50ce5f66e42 --- /dev/null +++ b/gcc/testsuite/g++.dg/overload/error7.C @@ -0,0 +1,10 @@ +// PR c++/115239 + +bool foo(char *, long); // #1, strictly viable, ambig with #2 +bool foo(char *, unsigned); // #2, strictly viable, ambig with #1 +bool foo(char, long); // #3, non-strictly viable +bool foo(char, unsigned); // #4, non-strictly viable + +int main() { + foo((char *)0, 0); // { dg-error "ambiguous" } +} diff --git a/gcc/testsuite/g++.dg/parse/asm1.C b/gcc/testsuite/g++.dg/parse/asm1.C index 009ffbd3ad353..9ce24b564dcee 100644 --- a/gcc/testsuite/g++.dg/parse/asm1.C +++ b/gcc/testsuite/g++.dg/parse/asm1.C @@ -3,4 +3,5 @@ void foo() { asm("" : 0); // { dg-error "numeric constant|token" } + // { dg-error "string-literal" "" { target *-*-* } .-1 } } diff --git a/gcc/testsuite/g++.dg/parse/asm2.C b/gcc/testsuite/g++.dg/parse/asm2.C index 09924c9c7c31a..d4e1c6e80de5d 100644 --- a/gcc/testsuite/g++.dg/parse/asm2.C +++ b/gcc/testsuite/g++.dg/parse/asm2.C @@ -3,4 +3,5 @@ void foo() { asm("" :: 0); // { dg-error "numeric constant|token" } + // { dg-error "string-literal" "" { target *-*-* } .-1 } } diff --git a/gcc/testsuite/g++.dg/parse/asm3.C b/gcc/testsuite/g++.dg/parse/asm3.C index 91f19e48cd5a1..dccee5ac68134 100644 --- a/gcc/testsuite/g++.dg/parse/asm3.C +++ b/gcc/testsuite/g++.dg/parse/asm3.C @@ -3,4 +3,5 @@ void foo() { asm ("%[x]" : [0](x)); // { dg-error "numeric constant|token" } + // { dg-error "string-literal" "" { target *-*-* } .-1 } } diff --git a/gcc/testsuite/g++.dg/parse/crash74.C b/gcc/testsuite/g++.dg/parse/crash74.C new file mode 100644 index 0000000000000..a7ba5094be670 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/crash74.C @@ -0,0 +1,11 @@ +// PR c++/107575 + +void f (void) { + virtual int f (void) const; // { dg-line line_4 } + virtual int f (void); // { dg-line line_5 } +} + +// { dg-error "outside class declaration" {} { target *-*-* } line_4 } +// { dg-error "cannot have cv-qualifier" {} { target *-*-* } line_4 } +// { dg-error "ambiguating new declaration of" {} { target *-*-* } line_4 } +// { dg-error "outside class declaration" {} { target *-*-* } line_5 } diff --git a/gcc/testsuite/g++.dg/parse/crash75.C b/gcc/testsuite/g++.dg/parse/crash75.C new file mode 100644 index 0000000000000..81a16e35b14c8 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/crash75.C @@ -0,0 +1,9 @@ +// PR c++/108438 +// { dg-options "-Wlogical-not-parentheses" } + +template +T foo (T arg, T& ref, T* ptr) +{ + int a = 1; + return static_cast(a); // { dg-error "expected" } +} diff --git a/gcc/testsuite/g++.dg/template/linkage5.C b/gcc/testsuite/g++.dg/template/linkage5.C new file mode 100644 index 0000000000000..7e8f93f546f11 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/linkage5.C @@ -0,0 +1,14 @@ +// PR c++/115283 +// { dg-final { scan-assembler "(weak|glob)\[^\n\]*_Z1fIiEv1AIX1CIT_EEE" } } +// { dg-do compile { target c++20 } } + +template +concept C = true; + +template +struct A { }; + +template +void f(A>) { } + +template void f(A); diff --git a/gcc/testsuite/g++.dg/template/pr95672.C b/gcc/testsuite/g++.dg/template/pr95672.C index c752b4a2c085a..d97b8db2e97a8 100644 --- a/gcc/testsuite/g++.dg/template/pr95672.C +++ b/gcc/testsuite/g++.dg/template/pr95672.C @@ -1,3 +1,3 @@ // PR c++/95672 // { dg-do compile { target c++14 } } -struct g_class : decltype (auto) ... { }; // { dg-error "invalid use of pack expansion" } +struct g_class : decltype (auto) ... { }; // { dg-error "contains no parameter packs" } diff --git a/gcc/testsuite/g++.dg/torture/pr79905.C b/gcc/testsuite/g++.dg/torture/pr79905.C index ab9d07c63736f..678f1a3e79297 100644 --- a/gcc/testsuite/g++.dg/torture/pr79905.C +++ b/gcc/testsuite/g++.dg/torture/pr79905.C @@ -1,7 +1,7 @@ // PR target/79905 // { dg-do compile { target { powerpc*-*-* } } } -// { dg-require-effective-target powerpc_altivec_ok } // { dg-options "-maltivec" } +// { dg-require-effective-target powerpc_altivec } typedef int V4i __attribute__((vector_size(16))); void a (V4i) { diff --git a/gcc/testsuite/g++.dg/torture/vshuf-mem.C b/gcc/testsuite/g++.dg/torture/vshuf-mem.C new file mode 100644 index 0000000000000..1d828e33a1404 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/vshuf-mem.C @@ -0,0 +1,27 @@ +// { dg-options "-std=c++11 -Wno-psabi" } +// { dg-do run } +// { dg-additional-options "-march=z14" { target s390_vxe } } + +/* This used to trigger (2024-05-28) the vectorize_vec_perm_const + backend hook to be invoked with a MEM source operand. Extracted + from onnxruntime's mlas library. */ + +typedef float V4SF __attribute__((vector_size (16))); +typedef int V4SI __attribute__((vector_size (16))); + +template < unsigned I0, unsigned I1, unsigned I2, unsigned I3 > V4SF +MlasShuffleFloat32x4 (V4SF Vector) +{ + return __builtin_shuffle (Vector, Vector, V4SI{I0, I1, I2, I3}); +} + +int +main () +{ + V4SF f = { 1.0f, 2.0f, 3.0f, 4.0f }; + if (MlasShuffleFloat32x4 < 1, 1, 1, 1 > (f)[3] != 2.0f) + __builtin_abort (); + if (MlasShuffleFloat32x4 < 3, 3, 3, 3 > (f)[1] != 4.0f) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/g++.target/i386/pr115351.C b/gcc/testsuite/g++.target/i386/pr115351.C new file mode 100644 index 0000000000000..24132f3b8c7bc --- /dev/null +++ b/gcc/testsuite/g++.target/i386/pr115351.C @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -std=c++11" } */ + +struct complex +{ + double real; + double imag; +}; + +complex blub(complex z) +{ + return { + z.real * z.real - z.imag * z.imag, + 2 * z.real * z.imag + }; +} + +/* { dg-final { scan-assembler-not "movq" } } */ +/* { dg-final { scan-assembler-not "xchg" } } */ diff --git a/gcc/testsuite/g++.target/powerpc/altivec-1.C b/gcc/testsuite/g++.target/powerpc/altivec-1.C index a809de2a3bf48..1b06c7651a963 100644 --- a/gcc/testsuite/g++.target/powerpc/altivec-1.C +++ b/gcc/testsuite/g++.target/powerpc/altivec-1.C @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/g++.target/powerpc/altivec-10.C b/gcc/testsuite/g++.target/powerpc/altivec-10.C index c9c475426113f..257db81af55fb 100644 --- a/gcc/testsuite/g++.target/powerpc/altivec-10.C +++ b/gcc/testsuite/g++.target/powerpc/altivec-10.C @@ -1,8 +1,8 @@ /* This is a compile-only test for interaction of "-maltivec" and "-save-temps". */ /* Author: Ziemowit Laski . */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-save-temps -maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/g++.target/powerpc/altivec-11.C b/gcc/testsuite/g++.target/powerpc/altivec-11.C index c767715c8b61b..49b61955b8fc5 100644 --- a/gcc/testsuite/g++.target/powerpc/altivec-11.C +++ b/gcc/testsuite/g++.target/powerpc/altivec-11.C @@ -1,7 +1,7 @@ /* Test handling of literal constant for dss operation. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/g++.target/powerpc/altivec-12.C b/gcc/testsuite/g++.target/powerpc/altivec-12.C index f57923e7155d4..a6659c86b6e43 100644 --- a/gcc/testsuite/g++.target/powerpc/altivec-12.C +++ b/gcc/testsuite/g++.target/powerpc/altivec-12.C @@ -1,7 +1,7 @@ /* Test vec_dst* functions with float pointer as first argument. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/g++.target/powerpc/altivec-13.C b/gcc/testsuite/g++.target/powerpc/altivec-13.C index 286d7789076ad..7b63b0e5ceb4e 100644 --- a/gcc/testsuite/g++.target/powerpc/altivec-13.C +++ b/gcc/testsuite/g++.target/powerpc/altivec-13.C @@ -3,8 +3,8 @@ AltiVec testsuite. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/g++.target/powerpc/altivec-14.C b/gcc/testsuite/g++.target/powerpc/altivec-14.C index 8f4cb6af65291..cd6b269d2f498 100644 --- a/gcc/testsuite/g++.target/powerpc/altivec-14.C +++ b/gcc/testsuite/g++.target/powerpc/altivec-14.C @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ void f (__attribute__((altivec (vector__))) signed int * a, __attribute__((altivec (vector__))) signed int * const b); diff --git a/gcc/testsuite/g++.target/powerpc/altivec-15.C b/gcc/testsuite/g++.target/powerpc/altivec-15.C index dc5d9552c365b..3a6ca133c7822 100644 --- a/gcc/testsuite/g++.target/powerpc/altivec-15.C +++ b/gcc/testsuite/g++.target/powerpc/altivec-15.C @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -mno-vsx" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* This test was added for an internal compiler error. The number and content of error messages is irrelevant. */ diff --git a/gcc/testsuite/g++.target/powerpc/altivec-16.C b/gcc/testsuite/g++.target/powerpc/altivec-16.C index cdfbc6d74aae8..b49747f5ca169 100644 --- a/gcc/testsuite/g++.target/powerpc/altivec-16.C +++ b/gcc/testsuite/g++.target/powerpc/altivec-16.C @@ -1,7 +1,7 @@ // PR c++/36662 // { dg-do compile } -// { dg-require-effective-target powerpc_altivec_ok } // { dg-options "-maltivec" } +// { dg-require-effective-target powerpc_altivec } #define vector __attribute__((altivec (vector__))) diff --git a/gcc/testsuite/g++.target/powerpc/altivec-17.C b/gcc/testsuite/g++.target/powerpc/altivec-17.C index d95ac16a69994..97b9026a52992 100644 --- a/gcc/testsuite/g++.target/powerpc/altivec-17.C +++ b/gcc/testsuite/g++.target/powerpc/altivec-17.C @@ -1,6 +1,6 @@ // { dg-do compile } -// { dg-require-effective-target powerpc_altivec_ok } // { dg-options "-maltivec" } +// { dg-require-effective-target powerpc_altivec } // Make sure that bool vectors have distinct names to int vectors diff --git a/gcc/testsuite/g++.target/powerpc/altivec-18.C b/gcc/testsuite/g++.target/powerpc/altivec-18.C index ddfca943c0c33..2bba33946e978 100644 --- a/gcc/testsuite/g++.target/powerpc/altivec-18.C +++ b/gcc/testsuite/g++.target/powerpc/altivec-18.C @@ -1,7 +1,7 @@ // PR target/82112 // { dg-do compile } -// { dg-require-effective-target powerpc_altivec_ok } // { dg-options "-maltivec" } +// { dg-require-effective-target powerpc_altivec } #include diff --git a/gcc/testsuite/g++.target/powerpc/altivec-2.C b/gcc/testsuite/g++.target/powerpc/altivec-2.C index b2eaf62a0ed10..9e8645246a9e6 100644 --- a/gcc/testsuite/g++.target/powerpc/altivec-2.C +++ b/gcc/testsuite/g++.target/powerpc/altivec-2.C @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -Wall -Wno-unused-but-set-variable -Wno-deprecated" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* This test checks if AltiVec builtins accept const-qualified arguments. */ diff --git a/gcc/testsuite/g++.target/powerpc/altivec-3.C b/gcc/testsuite/g++.target/powerpc/altivec-3.C index 522d62bd3ffdb..eeda0778fbef3 100644 --- a/gcc/testsuite/g++.target/powerpc/altivec-3.C +++ b/gcc/testsuite/g++.target/powerpc/altivec-3.C @@ -1,7 +1,7 @@ /* { dg-do run { target { vmx_hw } } } */ /* { dg-do compile { target { ! vmx_hw } } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Test for correct handling of AltiVec constants passed through '...' (va_arg). */ diff --git a/gcc/testsuite/g++.target/powerpc/altivec-4.C b/gcc/testsuite/g++.target/powerpc/altivec-4.C index 9ac1fbf38a387..9af75a67339b5 100644 --- a/gcc/testsuite/g++.target/powerpc/altivec-4.C +++ b/gcc/testsuite/g++.target/powerpc/altivec-4.C @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* PR c++/14425 */ diff --git a/gcc/testsuite/g++.target/powerpc/altivec-5.C b/gcc/testsuite/g++.target/powerpc/altivec-5.C index d11f1fabd25a4..a32f6cf6f6fb3 100644 --- a/gcc/testsuite/g++.target/powerpc/altivec-5.C +++ b/gcc/testsuite/g++.target/powerpc/altivec-5.C @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* PR c++/14426 */ diff --git a/gcc/testsuite/g++.target/powerpc/altivec-6.C b/gcc/testsuite/g++.target/powerpc/altivec-6.C index cfbfa4edc50a6..c961cf64a15e1 100644 --- a/gcc/testsuite/g++.target/powerpc/altivec-6.C +++ b/gcc/testsuite/g++.target/powerpc/altivec-6.C @@ -1,8 +1,8 @@ /* Test for correct handling of literal arguments. */ /* Author: Ziemowit Laski */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/g++.target/powerpc/altivec-7.C b/gcc/testsuite/g++.target/powerpc/altivec-7.C index de166879a167a..d5ea699e6c0ef 100644 --- a/gcc/testsuite/g++.target/powerpc/altivec-7.C +++ b/gcc/testsuite/g++.target/powerpc/altivec-7.C @@ -1,7 +1,7 @@ /* Test for AltiVec type overloading and name mangling. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/g++.target/powerpc/altivec-8.C b/gcc/testsuite/g++.target/powerpc/altivec-8.C index 2a5891ca0cfc3..841b111fdba9d 100644 --- a/gcc/testsuite/g++.target/powerpc/altivec-8.C +++ b/gcc/testsuite/g++.target/powerpc/altivec-8.C @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Author: Ziemowit Laski */ /* This test case exercises intrinsic/argument combinations that, diff --git a/gcc/testsuite/g++.target/powerpc/altivec-9.C b/gcc/testsuite/g++.target/powerpc/altivec-9.C index 6f07bdf30270b..5b6d132c1125d 100644 --- a/gcc/testsuite/g++.target/powerpc/altivec-9.C +++ b/gcc/testsuite/g++.target/powerpc/altivec-9.C @@ -1,7 +1,7 @@ /* Test for AltiVec function vec_ld, passing a pointer to const vector */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/g++.target/powerpc/altivec-cell-1.C b/gcc/testsuite/g++.target/powerpc/altivec-cell-1.C index cdef3222ad91e..fb4be8bb19a02 100644 --- a/gcc/testsuite/g++.target/powerpc/altivec-cell-1.C +++ b/gcc/testsuite/g++.target/powerpc/altivec-cell-1.C @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Basic test for the new VMX intrinsics. */ #include diff --git a/gcc/testsuite/g++.target/powerpc/altivec-cell-2.C b/gcc/testsuite/g++.target/powerpc/altivec-cell-2.C index 9601545913b4c..158344c387b16 100644 --- a/gcc/testsuite/g++.target/powerpc/altivec-cell-2.C +++ b/gcc/testsuite/g++.target/powerpc/altivec-cell-2.C @@ -1,7 +1,7 @@ /* { dg-do run { target { vmx_hw } } } */ /* { dg-do compile { target { ! vmx_hw } } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Test the vec_extract VMX intrinsics. */ #include diff --git a/gcc/testsuite/g++.target/powerpc/altivec-cell-3.C b/gcc/testsuite/g++.target/powerpc/altivec-cell-3.C index 76624009c69ea..21e7f63bafac4 100644 --- a/gcc/testsuite/g++.target/powerpc/altivec-cell-3.C +++ b/gcc/testsuite/g++.target/powerpc/altivec-cell-3.C @@ -1,7 +1,7 @@ /* { dg-do run { target { vmx_hw } } } */ /* { dg-do compile { target { ! vmx_hw } } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Test the vec_splats and vec_promote VMX intrinsics. */ #include diff --git a/gcc/testsuite/g++.target/powerpc/altivec-cell-4.C b/gcc/testsuite/g++.target/powerpc/altivec-cell-4.C index cbe7797240466..e222c7b6f0c7d 100644 --- a/gcc/testsuite/g++.target/powerpc/altivec-cell-4.C +++ b/gcc/testsuite/g++.target/powerpc/altivec-cell-4.C @@ -1,7 +1,7 @@ /* { dg-do run { target { vmx_hw } } } */ /* { dg-do compile { target { ! vmx_hw } } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Test the vec_splats and vec_promote VMX intrinsics. */ #include diff --git a/gcc/testsuite/g++.target/powerpc/altivec-cell-5.C b/gcc/testsuite/g++.target/powerpc/altivec-cell-5.C index 13320f6537c19..bd62b1c898438 100644 --- a/gcc/testsuite/g++.target/powerpc/altivec-cell-5.C +++ b/gcc/testsuite/g++.target/powerpc/altivec-cell-5.C @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Basic test for the new VMX intrinsics and error messages. */ #include diff --git a/gcc/testsuite/g++.target/powerpc/altivec-types-1.C b/gcc/testsuite/g++.target/powerpc/altivec-types-1.C index fe8e11fe07b17..4a2652e63a2e2 100644 --- a/gcc/testsuite/g++.target/powerpc/altivec-types-1.C +++ b/gcc/testsuite/g++.target/powerpc/altivec-types-1.C @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -mno-vsx -std=c++98" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Valid AltiVec vector types should be accepted with no warnings. */ diff --git a/gcc/testsuite/g++.target/powerpc/altivec-types-2.C b/gcc/testsuite/g++.target/powerpc/altivec-types-2.C index 44b557e92a115..e01b19d2321ef 100644 --- a/gcc/testsuite/g++.target/powerpc/altivec-types-2.C +++ b/gcc/testsuite/g++.target/powerpc/altivec-types-2.C @@ -1,7 +1,7 @@ /* { dg-do compile } */ -/* { dg-require-effective-target ilp32 } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -mno-vsx" } */ +/* { dg-require-effective-target ilp32 } */ +/* { dg-require-effective-target powerpc_altivec } */ /* These should get warnings for 32-bit code. */ diff --git a/gcc/testsuite/g++.target/powerpc/altivec-types-3.C b/gcc/testsuite/g++.target/powerpc/altivec-types-3.C index 8cb41394e2ddf..044f89217e952 100644 --- a/gcc/testsuite/g++.target/powerpc/altivec-types-3.C +++ b/gcc/testsuite/g++.target/powerpc/altivec-types-3.C @@ -1,7 +1,7 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ -/* { dg-require-effective-target lp64 } */ /* { dg-options "-maltivec -mno-vsx" } */ +/* { dg-require-effective-target powerpc_altivec } */ +/* { dg-require-effective-target lp64 } */ /* These should be rejected for 64-bit code. */ diff --git a/gcc/testsuite/g++.target/powerpc/altivec-types-4.C b/gcc/testsuite/g++.target/powerpc/altivec-types-4.C index 86592da7100cc..95dee2de0578b 100644 --- a/gcc/testsuite/g++.target/powerpc/altivec-types-4.C +++ b/gcc/testsuite/g++.target/powerpc/altivec-types-4.C @@ -1,7 +1,7 @@ /* { dg-do compile } */ -/* { dg-require-effective-target ilp32 } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -mno-vsx -mno-warn-altivec-long" } */ +/* { dg-require-effective-target ilp32 } */ +/* { dg-require-effective-target powerpc_altivec } */ /* These should not get warnings for 32-bit code when the warning is disabled. */ diff --git a/gcc/testsuite/g++.target/powerpc/const2.C b/gcc/testsuite/g++.target/powerpc/const2.C index 27f4c26585130..b3d92cdb8c5d2 100644 --- a/gcc/testsuite/g++.target/powerpc/const2.C +++ b/gcc/testsuite/g++.target/powerpc/const2.C @@ -1,5 +1,6 @@ -/* { dg-do compile { target powerpc_altivec_ok } } */ +/* { dg-do compile } */ /* { dg-options "-O -gdwarf-2 -dA -maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* { dg-final { scan-assembler "DW_AT_const_value" } } */ typedef float FloatVect __attribute__((__vector_size__(16))); diff --git a/gcc/testsuite/gcc.dg/analyzer/taint-alloc-4.c b/gcc/testsuite/gcc.dg/analyzer/taint-alloc-4.c index 9df9422491c87..7fe813d4e9e6c 100644 --- a/gcc/testsuite/gcc.dg/analyzer/taint-alloc-4.c +++ b/gcc/testsuite/gcc.dg/analyzer/taint-alloc-4.c @@ -23,6 +23,6 @@ test_1 (void *data) /* { dg-message "\\(1\\) function 'test_1' marked with '__at __analyzer_dump_state ("taint", args); /* { dg-warning "state: 'tainted'" } */ __analyzer_dump_state ("taint", args->sz); /* { dg-warning "state: 'tainted'" } */ - p = malloc (args->sz); /* { dg-warning "use of attacker-controlled value '\\*args.sz' as allocation size without upper-bounds checking" "warning" } */ - /* { dg-message "\\(\[0-9\]+\\) use of attacker-controlled value '\\*args.sz' as allocation size without upper-bounds checking" "final event" { target *-*-* } .-1 } */ + p = malloc (args->sz); /* { dg-warning "use of attacker-controlled value '\[^'\]*.sz' as allocation size without upper-bounds checking" "warning" } */ + /* { dg-message "\\(\[0-9\]+\\) use of attacker-controlled value '\[^'\]*.sz' as allocation size without upper-bounds checking" "final event" { target *-*-* } .-1 } */ } diff --git a/gcc/testsuite/gcc.dg/c23-align-10.c b/gcc/testsuite/gcc.dg/c23-align-10.c new file mode 100644 index 0000000000000..bd6b9c268c3a7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-align-10.c @@ -0,0 +1,6 @@ +/* Test C2Y alignof on an incomplete array type: not allowed in C23. */ +/* { dg-do compile } */ +/* { dg-options "-std=c23 -pedantic-errors" } */ + +int a = alignof(int[]); /* { dg-error "incomplete" } */ +int b = alignof(int[][1]); /* { dg-error "incomplete" } */ diff --git a/gcc/testsuite/gcc.dg/c23-complex-1.c b/gcc/testsuite/gcc.dg/c23-complex-1.c new file mode 100644 index 0000000000000..3607336593dd8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-complex-1.c @@ -0,0 +1,14 @@ +/* Test C2Y complex increment and decrement: disallowed for C23. */ +/* { dg-do compile } */ +/* { dg-options "-std=c23 -pedantic-errors" } */ + +_Complex float a; + +void +f (void) +{ + a++; /* { dg-error "does not support" } */ + ++a; /* { dg-error "does not support" } */ + a--; /* { dg-error "does not support" } */ + --a; /* { dg-error "does not support" } */ +} diff --git a/gcc/testsuite/gcc.dg/c23-complex-2.c b/gcc/testsuite/gcc.dg/c23-complex-2.c new file mode 100644 index 0000000000000..301b668ea1532 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-complex-2.c @@ -0,0 +1,15 @@ +/* Test C2Y complex increment and decrement: disallowed for C23 (warning with + -pedantic). */ +/* { dg-do compile } */ +/* { dg-options "-std=c23 -pedantic" } */ + +_Complex float a; + +void +f (void) +{ + a++; /* { dg-warning "does not support" } */ + ++a; /* { dg-warning "does not support" } */ + a--; /* { dg-warning "does not support" } */ + --a; /* { dg-warning "does not support" } */ +} diff --git a/gcc/testsuite/gcc.dg/c23-complex-3.c b/gcc/testsuite/gcc.dg/c23-complex-3.c new file mode 100644 index 0000000000000..6fef30105b091 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-complex-3.c @@ -0,0 +1,15 @@ +/* Test C2Y complex increment and decrement: allowed for C23 with + -Wno-c23-c2y-compat. */ +/* { dg-do compile } */ +/* { dg-options "-std=c23 -pedantic-errors -Wno-c23-c2y-compat" } */ + +_Complex float a; + +void +f (void) +{ + a++; + ++a; + a--; + --a; +} diff --git a/gcc/testsuite/gcc.dg/c23-complex-4.c b/gcc/testsuite/gcc.dg/c23-complex-4.c new file mode 100644 index 0000000000000..61d50e9a1dd89 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-complex-4.c @@ -0,0 +1,15 @@ +/* Test C2Y complex increment and decrement: allowed for C23 by default (not + pedantic). */ +/* { dg-do compile } */ +/* { dg-options "-std=c23" } */ + +_Complex float a; + +void +f (void) +{ + a++; + ++a; + a--; + --a; +} diff --git a/gcc/testsuite/gcc.dg/c23-generic-1.c b/gcc/testsuite/gcc.dg/c23-generic-1.c new file mode 100644 index 0000000000000..26c97fb4a9ee3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-generic-1.c @@ -0,0 +1,17 @@ +/* Test C2Y _Generic features: error with -std=c23 -pedantic-errors. */ +/* { dg-do compile } */ +/* { dg-options "-std=c23 -pedantic-errors" } */ + +_Static_assert (_Generic (const int, int : 1, const int : 2) == 2); /* { dg-error "use of type name" } */ + +_Static_assert (_Generic (void, int : 1, void : 2) == 2); /* { dg-error "use of type name" } */ +/* { dg-error "incomplete type" "incomplete type" { target *-*-* } .-1 } */ + +_Static_assert (_Generic (int (), int (*) () : 1, int () : 2) == 2); /* { dg-error "use of type name" } */ +/* { dg-error "function type" "function type" { target *-*-* } .-1 } */ + +const int ci; + +_Static_assert (_Generic (typeof (ci), const int : 1, int : 2) == 1); /* { dg-error "use of type name" } */ + +_Static_assert (_Generic (ci, const int : 1, int : 2) == 2); diff --git a/gcc/testsuite/gcc.dg/c23-generic-2.c b/gcc/testsuite/gcc.dg/c23-generic-2.c new file mode 100644 index 0000000000000..eb31d37b092ca --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-generic-2.c @@ -0,0 +1,17 @@ +/* Test C2Y _Generic features: warning with -std=c23 -pedantic. */ +/* { dg-do compile } */ +/* { dg-options "-std=c23 -pedantic" } */ + +_Static_assert (_Generic (const int, int : 1, const int : 2) == 2); /* { dg-warning "use of type name" } */ + +_Static_assert (_Generic (void, int : 1, void : 2) == 2); /* { dg-warning "use of type name" } */ +/* { dg-warning "incomplete type" "incomplete type" { target *-*-* } .-1 } */ + +_Static_assert (_Generic (int (), int (*) () : 1, int () : 2) == 2); /* { dg-warning "use of type name" } */ +/* { dg-warning "function type" "function type" { target *-*-* } .-1 } */ + +const int ci; + +_Static_assert (_Generic (typeof (ci), const int : 1, int : 2) == 1); /* { dg-warning "use of type name" } */ + +_Static_assert (_Generic (ci, const int : 1, int : 2) == 2); diff --git a/gcc/testsuite/gcc.dg/c23-generic-3.c b/gcc/testsuite/gcc.dg/c23-generic-3.c new file mode 100644 index 0000000000000..adf4b3549fffa --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-generic-3.c @@ -0,0 +1,16 @@ +/* Test C2Y _Generic features: no warning or error with -std=c23 + -pedantic-errors -Wno-c23-c2y-compat. */ +/* { dg-do compile } */ +/* { dg-options "-std=c23 -pedantic-errors -Wno-c23-c2y-compat" } */ + +_Static_assert (_Generic (const int, int : 1, const int : 2) == 2); + +_Static_assert (_Generic (void, int : 1, void : 2) == 2); + +_Static_assert (_Generic (int (), int (*) () : 1, int () : 2) == 2); + +const int ci; + +_Static_assert (_Generic (typeof (ci), const int : 1, int : 2) == 1); + +_Static_assert (_Generic (ci, const int : 1, int : 2) == 2); diff --git a/gcc/testsuite/gcc.dg/c23-generic-4.c b/gcc/testsuite/gcc.dg/c23-generic-4.c new file mode 100644 index 0000000000000..f9f65615dd989 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-generic-4.c @@ -0,0 +1,16 @@ +/* Test C2Y _Generic features: no warning or error with -std=c23 by + default. */ +/* { dg-do compile } */ +/* { dg-options "-std=c23" } */ + +_Static_assert (_Generic (const int, int : 1, const int : 2) == 2); + +_Static_assert (_Generic (void, int : 1, void : 2) == 2); + +_Static_assert (_Generic (int (), int (*) () : 1, int () : 2) == 2); + +const int ci; + +_Static_assert (_Generic (typeof (ci), const int : 1, int : 2) == 1); + +_Static_assert (_Generic (ci, const int : 1, int : 2) == 2); diff --git a/gcc/testsuite/gcc.dg/c23-tag-6.c b/gcc/testsuite/gcc.dg/c23-tag-6.c index 1b65ed3e35d41..7a81487c6e44b 100644 --- a/gcc/testsuite/gcc.dg/c23-tag-6.c +++ b/gcc/testsuite/gcc.dg/c23-tag-6.c @@ -1,6 +1,6 @@ /* * { dg-do compile } - * { dg-options "-std=c23" } + * { dg-options "-std=c23 -pedantic-errors" } */ // (in-)completeness diff --git a/gcc/testsuite/gcc.dg/c23-tag-enum-6.c b/gcc/testsuite/gcc.dg/c23-tag-enum-6.c new file mode 100644 index 0000000000000..29aef7ee3fdfb --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-tag-enum-6.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c23 -fno-short-enums" } */ + +#include + +enum E : int { a = 1, b = 2 }; +enum E : int { b = _Generic(a, enum E: 2), a = 1 }; + +enum H { x = 1 }; +enum H { x = 2UL + UINT_MAX }; /* { dg-error "outside the range" } */ + +enum K : int { z = 1 }; +enum K : int { z = 2UL + UINT_MAX }; /* { dg-error "outside the range" } */ + +enum F { A = 0, B = UINT_MAX }; +enum F { B = UINT_MAX, A }; /* { dg-error "outside the range" } */ + +enum G : unsigned int { C = 0, D = UINT_MAX }; +enum G : unsigned int { D = UINT_MAX, C }; /* { dg-error "overflow" } */ + diff --git a/gcc/testsuite/gcc.dg/c23-tag-enum-7.c b/gcc/testsuite/gcc.dg/c23-tag-enum-7.c new file mode 100644 index 0000000000000..d4c787c8f7167 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-tag-enum-7.c @@ -0,0 +1,41 @@ +/* { dg-do compile } + * { dg-options "-std=c23 -fno-short-enums" } */ + +#include + +// enumerators are all representable in int +enum E { a = 1UL, b = _Generic(a, int: 2) }; +static_assert(_Generic(a, int: 1)); +static_assert(_Generic(b, int: 1)); +enum E { a = 1UL, b = _Generic(a, int: 2) }; +static_assert(_Generic(a, int: 1)); +static_assert(_Generic(b, int: 1)); + +// enumerators are not representable in int +enum H { c = 1UL << (UINT_WIDTH + 1), d = 2 }; +static_assert(_Generic(c, enum H: 1)); +static_assert(_Generic(d, enum H: 1)); +enum H { c = 1UL << (UINT_WIDTH + 1), d = _Generic(c, enum H: 2) }; +static_assert(_Generic(c, enum H: 1)); +static_assert(_Generic(d, enum H: 1)); + +// there is an overflow in the first declaration +enum K { e = UINT_MAX, f, g = _Generic(e, unsigned int: 0) + _Generic(f, unsigned long: 1) }; +static_assert(_Generic(e, enum K: 1)); +static_assert(_Generic(f, enum K: 1)); +static_assert(_Generic(g, enum K: 1)); +enum K { e = UINT_MAX, f, g = _Generic(e, enum K: 0) + _Generic(f, enum K: 1) }; +static_assert(_Generic(e, enum K: 1)); +static_assert(_Generic(f, enum K: 1)); +static_assert(_Generic(g, enum K: 1)); + +// there is an overflow in the first declaration +enum U { k = INT_MAX, l, m = _Generic(k, int: 0) + _Generic(l, long: 1) }; +static_assert(_Generic(k, enum U: 1)); +static_assert(_Generic(l, enum U: 1)); +static_assert(_Generic(m, enum U: 1)); +enum U { k = INT_MAX, l, m = _Generic(k, enum U: 0) + _Generic(l, enum U: 1) }; +static_assert(_Generic(k, enum U: 1)); +static_assert(_Generic(l, enum U: 1)); +static_assert(_Generic(m, enum U: 1)); + diff --git a/gcc/testsuite/gcc.dg/c2y-align-1.c b/gcc/testsuite/gcc.dg/c2y-align-1.c new file mode 100644 index 0000000000000..3f9ab18c51863 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2y-align-1.c @@ -0,0 +1,6 @@ +/* Test C2Y alignof on an incomplete array type. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2y -pedantic-errors" } */ + +int a = alignof(int[]); +int b = alignof(int[][1]); diff --git a/gcc/testsuite/gcc.dg/c2y-align-2.c b/gcc/testsuite/gcc.dg/c2y-align-2.c new file mode 100644 index 0000000000000..b7b8715041376 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2y-align-2.c @@ -0,0 +1,8 @@ +/* Test C2Y alignof on an incomplete array type: still not allowed for other + incomplete types. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2y -pedantic-errors" } */ + +int a = alignof(void); /* { dg-error "void" } */ +struct s; +int b = alignof(struct s); /* { dg-error "incomplete" } */ diff --git a/gcc/testsuite/gcc.dg/c2y-complex-1.c b/gcc/testsuite/gcc.dg/c2y-complex-1.c new file mode 100644 index 0000000000000..29a8c2771ac7c --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2y-complex-1.c @@ -0,0 +1,232 @@ +/* Test C2Y complex increment and decrement. */ +/* { dg-do run } */ +/* { dg-options "-std=c2y -pedantic-errors" } */ + +extern void abort (void); +extern void exit (int); + +_Complex float a, ax; +_Complex double b, bx; +_Complex long double c, cx; + +int +main () +{ + ax = a++; + if (ax != 0 + || a != 1 + || __builtin_signbit (__builtin_crealf (ax)) + || __builtin_signbit (__builtin_cimagf (ax)) + || __builtin_signbit (__builtin_crealf (a)) + || __builtin_signbit (__builtin_cimagf (a))) + abort (); + a = __builtin_complex (0.0f, -0.0f); + ax = a++; + if (ax != 0 + || a != 1 + || __builtin_signbit (__builtin_crealf (ax)) + || !__builtin_signbit (__builtin_cimagf (ax)) + || __builtin_signbit (__builtin_crealf (a)) + || !__builtin_signbit (__builtin_cimagf (a))) + abort (); + a = 0; + ax = ++a; + if (ax != 1 + || a != 1 + || __builtin_signbit (__builtin_crealf (ax)) + || __builtin_signbit (__builtin_cimagf (ax)) + || __builtin_signbit (__builtin_crealf (a)) + || __builtin_signbit (__builtin_cimagf (a))) + abort (); + a = __builtin_complex (0.0f, -0.0f); + ax = ++a; + if (ax != 1 + || a != 1 + || __builtin_signbit (__builtin_crealf (ax)) + || !__builtin_signbit (__builtin_cimagf (ax)) + || __builtin_signbit (__builtin_crealf (a)) + || !__builtin_signbit (__builtin_cimagf (a))) + abort (); + a = 0; + ax = a--; + if (ax != 0 + || a != -1 + || __builtin_signbit (__builtin_crealf (ax)) + || __builtin_signbit (__builtin_cimagf (ax)) + || !__builtin_signbit (__builtin_crealf (a)) + || __builtin_signbit (__builtin_cimagf (a))) + abort (); + a = __builtin_complex (0.0f, -0.0f); + ax = a--; + if (ax != 0 + || a != -1 + || __builtin_signbit (__builtin_crealf (ax)) + || !__builtin_signbit (__builtin_cimagf (ax)) + || !__builtin_signbit (__builtin_crealf (a)) + || !__builtin_signbit (__builtin_cimagf (a))) + abort (); + a = 0; + ax = --a; + if (ax != -1 + || a != -1 + || !__builtin_signbit (__builtin_crealf (ax)) + || __builtin_signbit (__builtin_cimagf (ax)) + || !__builtin_signbit (__builtin_crealf (a)) + || __builtin_signbit (__builtin_cimagf (a))) + abort (); + a = __builtin_complex (0.0f, -0.0f); + ax = --a; + if (ax != -1 + || a != -1 + || !__builtin_signbit (__builtin_crealf (ax)) + || !__builtin_signbit (__builtin_cimagf (ax)) + || !__builtin_signbit (__builtin_crealf (a)) + || !__builtin_signbit (__builtin_cimagf (a))) + abort (); + + bx = b++; + if (bx != 0 + || b != 1 + || __builtin_signbit (__builtin_creal (bx)) + || __builtin_signbit (__builtin_cimag (bx)) + || __builtin_signbit (__builtin_creal (b)) + || __builtin_signbit (__builtin_cimag (b))) + abort (); + b = __builtin_complex (0.0, -0.0); + bx = b++; + if (bx != 0 + || b != 1 + || __builtin_signbit (__builtin_creal (bx)) + || !__builtin_signbit (__builtin_cimag (bx)) + || __builtin_signbit (__builtin_creal (b)) + || !__builtin_signbit (__builtin_cimag (b))) + abort (); + b = 0; + bx = ++b; + if (bx != 1 + || b != 1 + || __builtin_signbit (__builtin_creal (bx)) + || __builtin_signbit (__builtin_cimag (bx)) + || __builtin_signbit (__builtin_creal (b)) + || __builtin_signbit (__builtin_cimag (b))) + abort (); + b = __builtin_complex (0.0, -0.0); + bx = ++b; + if (bx != 1 + || b != 1 + || __builtin_signbit (__builtin_creal (bx)) + || !__builtin_signbit (__builtin_cimag (bx)) + || __builtin_signbit (__builtin_creal (b)) + || !__builtin_signbit (__builtin_cimag (b))) + abort (); + b = 0; + bx = b--; + if (bx != 0 + || b != -1 + || __builtin_signbit (__builtin_creal (bx)) + || __builtin_signbit (__builtin_cimag (bx)) + || !__builtin_signbit (__builtin_creal (b)) + || __builtin_signbit (__builtin_cimag (b))) + abort (); + b = __builtin_complex (0.0f, -0.0f); + bx = b--; + if (bx != 0 + || b != -1 + || __builtin_signbit (__builtin_creal (bx)) + || !__builtin_signbit (__builtin_cimag (bx)) + || !__builtin_signbit (__builtin_creal (b)) + || !__builtin_signbit (__builtin_cimag (b))) + abort (); + b = 0; + bx = --b; + if (bx != -1 + || b != -1 + || !__builtin_signbit (__builtin_creal (bx)) + || __builtin_signbit (__builtin_cimag (bx)) + || !__builtin_signbit (__builtin_creal (b)) + || __builtin_signbit (__builtin_cimag (b))) + abort (); + b = __builtin_complex (0.0f, -0.0f); + bx = --b; + if (bx != -1 + || b != -1 + || !__builtin_signbit (__builtin_creal (bx)) + || !__builtin_signbit (__builtin_cimag (bx)) + || !__builtin_signbit (__builtin_creal (b)) + || !__builtin_signbit (__builtin_cimag (b))) + abort (); + + cx = c++; + if (cx != 0 + || c != 1 + || __builtin_signbit (__builtin_creall (cx)) + || __builtin_signbit (__builtin_cimagl (cx)) + || __builtin_signbit (__builtin_creall (c)) + || __builtin_signbit (__builtin_cimagl (c))) + abort (); + c = __builtin_complex (0.0L, -0.0L); + cx = c++; + if (cx != 0 + || c != 1 + || __builtin_signbit (__builtin_creall (cx)) + || !__builtin_signbit (__builtin_cimagl (cx)) + || __builtin_signbit (__builtin_creall (c)) + || !__builtin_signbit (__builtin_cimagl (c))) + abort (); + c = 0; + cx = ++c; + if (cx != 1 + || c != 1 + || __builtin_signbit (__builtin_creall (cx)) + || __builtin_signbit (__builtin_cimagl (cx)) + || __builtin_signbit (__builtin_creall (c)) + || __builtin_signbit (__builtin_cimagl (c))) + abort (); + c = __builtin_complex (0.0L, -0.0L); + cx = ++c; + if (cx != 1 + || c != 1 + || __builtin_signbit (__builtin_creall (cx)) + || !__builtin_signbit (__builtin_cimagl (cx)) + || __builtin_signbit (__builtin_creall (c)) + || !__builtin_signbit (__builtin_cimagl (c))) + abort (); + c = 0; + cx = c--; + if (cx != 0 + || c != -1 + || __builtin_signbit (__builtin_creall (cx)) + || __builtin_signbit (__builtin_cimagl (cx)) + || !__builtin_signbit (__builtin_creall (c)) + || __builtin_signbit (__builtin_cimagl (c))) + abort (); + c = __builtin_complex (0.0L, -0.0L); + cx = c--; + if (cx != 0 + || c != -1 + || __builtin_signbit (__builtin_creall (cx)) + || !__builtin_signbit (__builtin_cimagl (cx)) + || !__builtin_signbit (__builtin_creall (c)) + || !__builtin_signbit (__builtin_cimagl (c))) + abort (); + c = 0; + cx = --c; + if (cx != -1 + || c != -1 + || !__builtin_signbit (__builtin_creall (cx)) + || __builtin_signbit (__builtin_cimagl (cx)) + || !__builtin_signbit (__builtin_creall (c)) + || __builtin_signbit (__builtin_cimagl (c))) + abort (); + c = __builtin_complex (0.0L, -0.0L); + cx = --c; + if (cx != -1 + || c != -1 + || !__builtin_signbit (__builtin_creall (cx)) + || !__builtin_signbit (__builtin_cimagl (cx)) + || !__builtin_signbit (__builtin_creall (c)) + || !__builtin_signbit (__builtin_cimagl (c))) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/c2y-complex-2.c b/gcc/testsuite/gcc.dg/c2y-complex-2.c new file mode 100644 index 0000000000000..0ca8949b07d19 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2y-complex-2.c @@ -0,0 +1,14 @@ +/* Test C2Y complex increment and decrement: warning with -Wc23-c2y-compat. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2y -pedantic-errors -Wc23-c2y-compat" } */ + +_Complex float a; + +void +f (void) +{ + a++; /* { dg-warning "does not support" } */ + ++a; /* { dg-warning "does not support" } */ + a--; /* { dg-warning "does not support" } */ + --a; /* { dg-warning "does not support" } */ +} diff --git a/gcc/testsuite/gcc.dg/c2y-generic-1.c b/gcc/testsuite/gcc.dg/c2y-generic-1.c new file mode 100644 index 0000000000000..afb46df99fe4e --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2y-generic-1.c @@ -0,0 +1,15 @@ +/* Test C2Y _Generic features. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2y -pedantic-errors" } */ + +_Static_assert (_Generic (const int, int : 1, const int : 2) == 2); + +_Static_assert (_Generic (void, int : 1, void : 2) == 2); + +_Static_assert (_Generic (int (), int (*) () : 1, int () : 2) == 2); + +const int ci; + +_Static_assert (_Generic (typeof (ci), const int : 1, int : 2) == 1); + +_Static_assert (_Generic (ci, const int : 1, int : 2) == 2); diff --git a/gcc/testsuite/gcc.dg/c2y-generic-2.c b/gcc/testsuite/gcc.dg/c2y-generic-2.c new file mode 100644 index 0000000000000..c37fcc1283b9b --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2y-generic-2.c @@ -0,0 +1,17 @@ +/* Test C2Y _Generic features: warning with -Wc23-c2y-compat. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2y -pedantic-errors -Wc23-c2y-compat" } */ + +_Static_assert (_Generic (const int, int : 1, const int : 2) == 2); /* { dg-warning "use of type name" } */ + +_Static_assert (_Generic (void, int : 1, void : 2) == 2); /* { dg-warning "use of type name" } */ +/* { dg-warning "incomplete type" "incomplete type" { target *-*-* } .-1 } */ + +_Static_assert (_Generic (int (), int (*) () : 1, int () : 2) == 2); /* { dg-warning "use of type name" } */ +/* { dg-warning "function type" "function type" { target *-*-* } .-1 } */ + +const int ci; + +_Static_assert (_Generic (typeof (ci), const int : 1, int : 2) == 1); /* { dg-warning "use of type name" } */ + +_Static_assert (_Generic (ci, const int : 1, int : 2) == 2); diff --git a/gcc/testsuite/gcc.dg/c2y-generic-3.c b/gcc/testsuite/gcc.dg/c2y-generic-3.c new file mode 100644 index 0000000000000..09174fdb095da --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2y-generic-3.c @@ -0,0 +1,9 @@ +/* Test C2Y _Generic features: VM types still not allowed. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2y -pedantic-errors" } */ + +void +f (int i) +{ + (void) _Generic (i, int : 1, int (*)[i] : 2); /* { dg-error "variable length" } */ +} diff --git a/gcc/testsuite/gcc.dg/completion-2.c b/gcc/testsuite/gcc.dg/completion-2.c index 166bfdc1424dc..99e6531220162 100644 --- a/gcc/testsuite/gcc.dg/completion-2.c +++ b/gcc/testsuite/gcc.dg/completion-2.c @@ -4,6 +4,7 @@ /* { dg-begin-multiline-output "" } -flto-partition=1to1 -flto-partition=balanced +-flto-partition=cache -flto-partition=max -flto-partition=none -flto-partition=one diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/const-2.c b/gcc/testsuite/gcc.dg/debug/dwarf2/const-2.c index b139122fdeba8..ec17ba439f3f8 100644 --- a/gcc/testsuite/gcc.dg/debug/dwarf2/const-2.c +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/const-2.c @@ -1,5 +1,6 @@ -/* { dg-do compile { target powerpc_altivec_ok } } */ +/* { dg-do compile } */ /* { dg-options "-O -gdwarf -dA -maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* { dg-final { scan-assembler "DW_AT_const_value" } } */ typedef float FloatVect __attribute__((__vector_size__(16))); diff --git a/gcc/testsuite/gcc.dg/dfp/altivec-types.c b/gcc/testsuite/gcc.dg/dfp/altivec-types.c index 6663a8f649a3e..3cf93c15f8ee8 100644 --- a/gcc/testsuite/gcc.dg/dfp/altivec-types.c +++ b/gcc/testsuite/gcc.dg/dfp/altivec-types.c @@ -1,5 +1,6 @@ -/* { dg-do compile { target { powerpc*-*-linux* && powerpc_altivec_ok } } } */ +/* { dg-do compile { target powerpc*-*-linux* } } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* GNU extension: PowerPC AltiVec Built-in Functions. These should be rejected as invalid AltiVec types. */ diff --git a/gcc/testsuite/gcc.dg/gnu2y-generic-1.c b/gcc/testsuite/gcc.dg/gnu2y-generic-1.c new file mode 100644 index 0000000000000..98868ad51d1c6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gnu2y-generic-1.c @@ -0,0 +1,15 @@ +/* Test C2Y _Generic features: __extension__ suppresses -Wc23-c2y-compat + warnings (and the state is restored after __extension__). */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu2y -pedantic-errors -Wc23-c2y-compat" } */ + +_Static_assert (__extension__ _Generic (const int, int : 1, const int : 2) == 2); +_Static_assert (_Generic (const int, int : 1, const int : 2) == 2); /* { dg-warning "use of type name" } */ + +_Static_assert (__extension__ _Generic (void, int : 1, void : 2) == 2); +_Static_assert (_Generic (void, int : 1, void : 2) == 2); /* { dg-warning "use of type name" } */ +/* { dg-warning "incomplete type" "incomplete type" { target *-*-* } .-1 } */ + +_Static_assert (__extension__ _Generic (int (), int (*) () : 1, int () : 2) == 2); +_Static_assert (_Generic (int (), int (*) () : 1, int () : 2) == 2); /* { dg-warning "use of type name" } */ +/* { dg-warning "function type" "function type" { target *-*-* } .-1 } */ diff --git a/gcc/testsuite/gcc.dg/plugin/analyzer_cpython_plugin.c b/gcc/testsuite/gcc.dg/plugin/analyzer_cpython_plugin.c index b53b347bb4fae..d71b75f44cca3 100644 --- a/gcc/testsuite/gcc.dg/plugin/analyzer_cpython_plugin.c +++ b/gcc/testsuite/gcc.dg/plugin/analyzer_cpython_plugin.c @@ -530,7 +530,7 @@ dump_refcnt_info (const hash_map ®ion_to_refcnt, pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = stderr; + pp.set_output_stream (stderr); for (const auto ®ion_refcnt : region_to_refcnt) { diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c index bf665005c8b5e..efa4ec475ab34 100644 --- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c @@ -38,6 +38,7 @@ #include "print-tree.h" #include "gcc-rich-location.h" #include "cgraph.h" +#include "simple-diagnostic-path.h" int plugin_is_GPL_compatible; diff --git a/gcc/testsuite/gcc.dg/pr115109.c b/gcc/testsuite/gcc.dg/pr115109.c new file mode 100644 index 0000000000000..4baee0f344534 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr115109.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c23 -fno-short-enums" } */ + +#include + +enum E { a = 1UL << (ULONG_WIDTH - 5), b = 2 }; +enum E { a = 1ULL << (ULONG_WIDTH - 5), b = _Generic(a, enum E: 2) }; + diff --git a/gcc/testsuite/gcc.dg/torture/bitint-71.c b/gcc/testsuite/gcc.dg/torture/bitint-71.c new file mode 100644 index 0000000000000..8ebd42b30b296 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/bitint-71.c @@ -0,0 +1,28 @@ +/* PR middle-end/115352 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=c23" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __BITINT_MAXWIDTH__ >= 385 +int +foo (_BitInt (385) b) +{ + return __builtin_sub_overflow_p (0, b, (_BitInt (65)) 0); +} +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 385 + if (!foo (-(_BitInt (385)) 0x00000000000000000c377e8a3fd1881fff035bb487a51c9ed1f7350befa7ec4450000000000000000a3cf8d1ebb723981wb)) + __builtin_abort (); + if (!foo (-0x1ffffffffffffffffc377e8a3fd1881fff035bb487a51c9ed1f7350befa7ec445ffffffffffffffffa3cf8d1ebb723981uwb)) + __builtin_abort (); + if (!foo (-(_BitInt (385)) 0x00000000000000000ffffffffffffffffffffffffffffffff00000000000000000000000000000000a3cf8d1ebb723981wb)) + __builtin_abort (); + if (!foo (-0x1ffffffffffffffff00000000000000000000000000000000ffffffffffffffffffffffffffffffffa3cf8d1ebb723981uwb)) + __builtin_abort (); +#endif +} diff --git a/gcc/testsuite/gcc.dg/torture/pr115387-1.c b/gcc/testsuite/gcc.dg/torture/pr115387-1.c new file mode 100644 index 0000000000000..d94e935fadec1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr115387-1.c @@ -0,0 +1,34 @@ +/* Test there is no ICE when compile. */ +/* { dg-do compile } */ + +#define PRINTF_CHK 0x34 + +typedef unsigned long uintptr_t; + +struct __printf_buffer { + char *write_ptr; + int status; +}; + +extern void __printf_buffer_init_end (struct __printf_buffer *, char *, char *); + +void +test (char *string, unsigned long maxlen, unsigned mode_flags) +{ + struct __printf_buffer buf; + + if ((mode_flags & PRINTF_CHK) != 0) + { + string[0] = '\0'; + uintptr_t end; + + if (__builtin_add_overflow ((uintptr_t) string, maxlen, &end)) + end = -1; + + __printf_buffer_init_end (&buf, string, (char *) end); + } + else + __printf_buffer_init_end (&buf, string, (char *) ~(uintptr_t) 0); + + *buf.write_ptr = '\0'; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr115387-2.c b/gcc/testsuite/gcc.dg/torture/pr115387-2.c new file mode 100644 index 0000000000000..9e93024b45ce2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr115387-2.c @@ -0,0 +1,17 @@ +/* Test there is no ICE when compile. */ +/* { dg-do compile } */ + +#include +#include + +char * +test (char *string, size_t maxlen) +{ + string[0] = '\0'; + uintptr_t end; + + if (__builtin_add_overflow ((uintptr_t) string, maxlen, &end)) + end = -1; + + return (char *) end; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr115388.c b/gcc/testsuite/gcc.dg/torture/pr115388.c new file mode 100644 index 0000000000000..17b3f1bcd9036 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr115388.c @@ -0,0 +1,34 @@ +/* { dg-do run } */ + +int printf(const char *, ...); +int a[10], b, c, d[0], h, i, j, k, l; +signed char e = -1, g; +volatile int f; +static void n() { + while (e >= 0) + while (1) + ; + for (b = 2; b >= 0; b--) { + for (k = 0; k < 4; k++) { + if (e || i) + continue; + for (h = 0; h < 2; h++) + f; + } + for (l = 2; l >= 0; l--) + g = 0; + for (; g < 1; g++) + if (c) + d[l] = 1; + a[9] = 0; + a[b] = 1; + while (j) + printf("\n"); + } +} +int main() { + n(); + if (a[1] != 1) + __builtin_abort(); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr115492.c b/gcc/testsuite/gcc.dg/torture/pr115492.c new file mode 100644 index 0000000000000..4ecc060768c0a --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr115492.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ + +int a = 2, b=0, *c = &a, *d = &a, e=0; +[[gnu::noipa]] +void f(int) {} +[[gnu::noipa]] +int h(int *k) { + int ***j; + if (b) { + *j = &k; // Note the unintialized j is used here + // but since it is conditional and b is always zero, there should no + // effect otherwise. + ***j; + } + f(*k); + *d = e; + return *k; +} +int main() { if (h(c)) __builtin_abort(); } diff --git a/gcc/testsuite/gcc.dg/tree-ssa/bitops-10.c b/gcc/testsuite/gcc.dg/tree-ssa/bitops-10.c new file mode 100644 index 0000000000000..000c5aef2377a --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/bitops-10.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-tree-optimized-raw" } */ +/* PR tree-optimization/115449 */ + +void setBit_un(unsigned char *a, int b) { + unsigned char c = 0x1UL << b; + *a &= ~c; + *a |= c; +} + +void setBit_sign(signed char *a, int b) { + signed char c = 0x1UL << b; + *a &= ~c; + *a |= c; +} + +void setBit(char *a, int b) { + char c = 0x1UL << b; + *a &= ~c; + *a |= c; +} +/* + All three should produce: + _1 = 1 << b_4(D); + c_5 = (cast) _1; + _2 = *a_7(D); + _3 = _2 | c_5; + *a_7(D) = _3; + Removing the `&~c` as we are matching `(~x & y) | x` -> `x | y` + match pattern even with extra casts are being involved. */ + +/* { dg-final { scan-tree-dump-not "bit_not_expr, " "optimized" } } */ +/* { dg-final { scan-tree-dump-not "bit_and_expr, " "optimized" } } */ +/* { dg-final { scan-tree-dump-times "bit_ior_expr, " 3 "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/ubsan/pr88234.c b/gcc/testsuite/gcc.dg/ubsan/pr88234.c index 2983cd88aa07d..5e4243bcaa4e3 100644 --- a/gcc/testsuite/gcc.dg/ubsan/pr88234.c +++ b/gcc/testsuite/gcc.dg/ubsan/pr88234.c @@ -1,7 +1,7 @@ /* PR target/88234 */ /* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-fsanitize=signed-integer-overflow -fno-sanitize-recover=signed-integer-overflow -O2 -maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-32.c b/gcc/testsuite/gcc.dg/vect/bb-slp-32.c index f10442e6d5685..4f72727b6948c 100644 --- a/gcc/testsuite/gcc.dg/vect/bb-slp-32.c +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-32.c @@ -1,14 +1,15 @@ -/* { dg-do compile } */ /* { dg-require-effective-target vect_int } */ /* { dg-additional-options "-fvect-cost-model=dynamic" } */ -void bar (int *); -int foo (int *p, int a, int b) +#include "tree-vect.h" + +int __attribute__((noipa)) +foo (int * __restrict__ x, int *p, int a, int b) { - int x[4]; + p = __builtin_assume_aligned (p, __BIGGEST_ALIGNMENT__); + x = __builtin_assume_aligned (x, __BIGGEST_ALIGNMENT__); int tem0, tem1, tem2, tem3; int sum = 0; - p = __builtin_assume_aligned (p, __BIGGEST_ALIGNMENT__); tem0 = p[0] + 1 + a; sum += tem0; x[0] = tem0; @@ -21,6 +22,19 @@ int foo (int *p, int a, int b) tem3 = p[3] + 4 + a; sum += tem3; x[3] = tem3; - bar (x); return sum; } + +int x[4] __attribute__((aligned(__BIGGEST_ALIGNMENT__))); +int p[4] __attribute__((aligned(__BIGGEST_ALIGNMENT__))) = { 0, 1, 2, 3 }; + +int main() +{ + check_vect (); + + if (foo (x, p, 7, 13) != 56) + abort (); + if (x[0] != 8 || x[1] != 16 || x[2] != 18 || x[3] != 14) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/vect/pr103116-1.c b/gcc/testsuite/gcc.dg/vect/pr103116-1.c index d3639fc8cfda9..280ec57eb4b9c 100644 --- a/gcc/testsuite/gcc.dg/vect/pr103116-1.c +++ b/gcc/testsuite/gcc.dg/vect/pr103116-1.c @@ -47,4 +47,6 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump "Data access with gaps requires scalar epilogue loop" "vect" { target { vect_perm && vect_int } } } } */ +/* When the target can compose a vector from its half we do not require + a scalar epilogue, but there's no effective target for this. */ +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { target { vect_perm && vect_int } } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/pr103116-2.c b/gcc/testsuite/gcc.dg/vect/pr103116-2.c index aa9797a94074c..ee5b82922f971 100644 --- a/gcc/testsuite/gcc.dg/vect/pr103116-2.c +++ b/gcc/testsuite/gcc.dg/vect/pr103116-2.c @@ -56,4 +56,5 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump "peeling for gaps insufficient for access" "vect" { target { vect_perm_short } } } } */ +/* Whether or not peeling for gaps is required depends on the ability of + the target to compose a vector from two-element bits. */ diff --git a/gcc/testsuite/gcc.dg/vect/pr114107.c b/gcc/testsuite/gcc.dg/vect/pr114107.c new file mode 100644 index 0000000000000..65175d9a68051 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr114107.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ + +void rescale_x4 (double* __restrict data, + const double* __restrict factor, int n) +{ + for (int i=0; i +#include + +#define COUNT 511 +#define MMAP_SIZE 0x20000 +#define ADDRESS 0x1122000000 +#define TYPE unsigned char + +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif + +void __attribute__((noipa)) foo(TYPE * __restrict x, + TYPE *y, int n) +{ + for (int i = 0; i < n; ++i) + { + x[16*i+0] = y[3*i+0]; + x[16*i+1] = y[3*i+1]; + x[16*i+2] = y[3*i+2]; + x[16*i+3] = y[3*i+0]; + x[16*i+4] = y[3*i+1]; + x[16*i+5] = y[3*i+2]; + x[16*i+6] = y[3*i+0]; + x[16*i+7] = y[3*i+1]; + x[16*i+8] = y[3*i+2]; + x[16*i+9] = y[3*i+0]; + x[16*i+10] = y[3*i+1]; + x[16*i+11] = y[3*i+2]; + x[16*i+12] = y[3*i+0]; + x[16*i+13] = y[3*i+1]; + x[16*i+14] = y[3*i+2]; + x[16*i+15] = y[3*i+0]; + } +} + +void __attribute__((noipa)) bar(TYPE * __restrict x, + TYPE *y, int n) +{ + for (int i = 0; i < n; ++i) + { + x[16*i+0] = y[5*i+0]; + x[16*i+1] = y[5*i+1]; + x[16*i+2] = y[5*i+2]; + x[16*i+3] = y[5*i+3]; + x[16*i+4] = y[5*i+4]; + x[16*i+5] = y[5*i+0]; + x[16*i+6] = y[5*i+1]; + x[16*i+7] = y[5*i+2]; + x[16*i+8] = y[5*i+3]; + x[16*i+9] = y[5*i+4]; + x[16*i+10] = y[5*i+0]; + x[16*i+11] = y[5*i+1]; + x[16*i+12] = y[5*i+2]; + x[16*i+13] = y[5*i+3]; + x[16*i+14] = y[5*i+4]; + x[16*i+15] = y[5*i+0]; + } +} + +TYPE x[COUNT * 16]; + +int +main (void) +{ + void *y; + TYPE *end_y; + + y = mmap ((void *) ADDRESS, MMAP_SIZE, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (y == MAP_FAILED) + { + perror ("mmap"); + return 1; + } + + end_y = (TYPE *) ((char *) y + MMAP_SIZE); + + foo (x, end_y - COUNT * 3, COUNT); + bar (x, end_y - COUNT * 5, COUNT); + + return 0; +} + +/* We always require a scalar epilogue here but we don't know which + targets support vector composition this way. */ diff --git a/gcc/testsuite/gcc.dg/vect/pr115395.c b/gcc/testsuite/gcc.dg/vect/pr115395.c new file mode 100644 index 0000000000000..cd1cee9f3dff3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr115395.c @@ -0,0 +1,27 @@ +/* { dg-additional-options "-mavx2" { target avx2_runtime } } */ + +#include "tree-vect.h" + +struct { + long header_size; + long start_offset; + long end_offset; +} myrar_dbo[5] = {{0, 87, 6980}, {0, 7087, 13980}, {0, 14087, 0}}; + +int i; +long offset; + +int main() +{ + check_vect (); + + offset += myrar_dbo[0].start_offset; + while (i < 2) { + i++; + offset += myrar_dbo[i].start_offset - myrar_dbo[i - 1].end_offset; + } + if (offset != 301) + abort(); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/vect/pr115537.c b/gcc/testsuite/gcc.dg/vect/pr115537.c new file mode 100644 index 0000000000000..99ed467feb884 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr115537.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-mcpu=neoverse-n1" { target aarch64*-*-* } } */ + +char *a; +int b; +void c() +{ + int d = 0, e = 0, f; + for (; f; ++f) + if (a[f] == 5) + ; + else if (a[f]) + e = 1; + else + d = 1; + if (d) + if (e) + b = 0; +} diff --git a/gcc/testsuite/gcc.dg/vect/slp-reduc-12.c b/gcc/testsuite/gcc.dg/vect/slp-reduc-12.c new file mode 100644 index 0000000000000..625f8097c5451 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/slp-reduc-12.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_hw_misalign } */ +/* { dg-additional-options "-Ofast" } */ + +double foo (double *x, int * __restrict a, int n) +{ + double r = 0.; + for (int i = 0; i < n; ++i) + { + a[i] = a[i] + i; + r += x[i]; + } + return r; +} + +/* { dg-final { scan-tree-dump "using single def-use cycle for reduction" "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-82_64.c b/gcc/testsuite/gcc.dg/vect/vect-82_64.c index 58fc50d474b5f..2ed02504b08ca 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-82_64.c +++ b/gcc/testsuite/gcc.dg/vect/vect-82_64.c @@ -1,6 +1,7 @@ -/* { dg-do run { target { { powerpc*-*-* && lp64 } && powerpc_altivec_ok } } } */ -/* { dg-do compile { target { { powerpc*-*-* && ilp32 } && powerpc_altivec_ok } } } */ +/* { dg-do run { target { powerpc*-*-* && lp64 } } } */ +/* { dg-do compile { target { powerpc*-*-* && ilp32 } } } */ /* { dg-additional-options "-mpowerpc64 -maltivec -fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* { dg-skip-if "" { powerpc-ibm-aix* } } */ #include diff --git a/gcc/testsuite/gcc.dg/vect/vect-83_64.c b/gcc/testsuite/gcc.dg/vect/vect-83_64.c index 88128d34c22d9..4dd4d00583112 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-83_64.c +++ b/gcc/testsuite/gcc.dg/vect/vect-83_64.c @@ -1,6 +1,7 @@ -/* { dg-do run { target { { powerpc*-*-* && lp64 } && powerpc_altivec_ok } } } */ -/* { dg-do compile { target { { powerpc*-*-* && ilp32 } && powerpc_altivec_ok } } } */ +/* { dg-do run { target { powerpc*-*-* && lp64 } } } */ +/* { dg-do compile { target { powerpc*-*-* && ilp32 } } } */ /* { dg-additional-options "-mpowerpc64 -maltivec -fdump-tree-optimized-details-blocks" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* { dg-skip-if "" { powerpc-ibm-aix* } } */ #include diff --git a/gcc/testsuite/gcc.dg/vect/vect-prefetch-drop.c b/gcc/testsuite/gcc.dg/vect/vect-prefetch-drop.c new file mode 100644 index 0000000000000..7a8915eb716b4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-prefetch-drop.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +void foo(int * restrict a, int * restrict b, int n){ + int i; + for(i=0; i +#include +#include + +svuint16_t +convolve4_4_x (uint16x8x2_t permute_tbl) +{ + return svset_neonq_u16 (svundef_u16 (), permute_tbl.val[1]); +} + +/* { dg-final { scan-assembler {\tmov\tz0\.d, z1\.d\n} } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr115464_2.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr115464_2.c new file mode 100644 index 0000000000000..f561c34f732b8 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr115464_2.c @@ -0,0 +1,11 @@ +/* { dg-options "-O2" } */ + +#include +#include +#include + +svuint16_t +convolve4_4_x (uint16x8x2_t permute_tbl, svuint16_t a) +{ + return svset_neonq_u16 (a, permute_tbl.val[1]); +} diff --git a/gcc/testsuite/gcc.target/aarch64/sve/pr97405-1.c b/gcc/testsuite/gcc.target/aarch64/sve/pr97405-1.c new file mode 100644 index 0000000000000..5efa32c99280e --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sve/pr97405-1.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-march=armv8.2-a+sve -O2" } +/* PR tree-optimization/97405 */ +#include "arm_sve.h" + +void +a (svuint8x3_t b, unsigned char *p, int c) { + if (c) + svst1_u8(svptrue_pat_b8(SV_VL16), p, svget3_u8(b, 1)); + else + svst1_u8(svwhilelt_b8(6, 6), p, svget3_u8(b, 1)); +} + diff --git a/gcc/testsuite/gcc.target/aarch64/trunc-vec.c b/gcc/testsuite/gcc.target/aarch64/trunc-vec.c new file mode 100644 index 0000000000000..05e8af7912de4 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/trunc-vec.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +/* { dg-final { scan-assembler-times {fcvtn\tv[0-9]+.2s, v[0-9]+.2d} 1 } } */ +void +f (double *__restrict a, float *__restrict b) +{ + b[0] = a[0]; + b[1] = a[1]; +} + +/* { dg-final { scan-assembler-times {fcvtn\tv[0-9]+.4h, v[0-9]+.4s} 1 } } */ +void +f1 (float *__restrict a, _Float16 *__restrict b) +{ + + b[0] = a[0]; + b[1] = a[1]; + b[2] = a[2]; + b[3] = a[3]; +} diff --git a/gcc/testsuite/gcc.target/aarch64/vect-prefetch-drop.c b/gcc/testsuite/gcc.target/aarch64/vect-prefetch-drop.c new file mode 100644 index 0000000000000..e654b99fde865 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/vect-prefetch-drop.c @@ -0,0 +1,13 @@ +/* { dg-do compile { target { aarch64*-*-* } } } */ +/* { dg-additional-options "-O3 -march=armv9.2-a+sve --std=c99" { target { aarch64*-*-* } } } */ + +void foo(double * restrict a, double * restrict b, int n){ + int i; + for(i=0; i @@ -20,7 +22,15 @@ typedef enum offset __attribute__ ((cmse_nonsecure_call)) ns_enum_foo_t (void); typedef bool __attribute__ ((cmse_nonsecure_call)) ns_bool_foo_t (void); /* -**unsignNonsecure0: +**unsignNonsecure0: { target arm_cmse_clear_ok } +** ... +** blxns r[0-3] +** ... +** uxtb r0, r0 +** ... +*/ +/* +**unsignNonsecure0: { target { ! arm_cmse_clear_ok } } ** ... ** bl __gnu_cmse_nonsecure_call ** uxtb r0, r0 @@ -32,7 +42,15 @@ unsigned char unsignNonsecure0 (ns_unsign_foo_t * ns_foo_p) } /* -**signNonsecure0: +**signNonsecure0: { target arm_cmse_clear_ok } +** ... +** blxns r[0-3] +** ... +** sxtb r0, r0 +** ... +*/ +/* +**signNonsecure0: { target { ! arm_cmse_clear_ok } } ** ... ** bl __gnu_cmse_nonsecure_call ** sxtb r0, r0 @@ -44,7 +62,15 @@ signed char signNonsecure0 (ns_sign_foo_t * ns_foo_p) } /* -**shortUnsignNonsecure0: +**shortUnsignNonsecure0: { target arm_cmse_clear_ok } +** ... +** blxns r[0-3] +** ... +** uxth r0, r0 +** ... +*/ +/* +**shortUnsignNonsecure0: { target { ! arm_cmse_clear_ok } } ** ... ** bl __gnu_cmse_nonsecure_call ** uxth r0, r0 @@ -56,7 +82,15 @@ unsigned short shortUnsignNonsecure0 (ns_short_unsign_foo_t * ns_foo_p) } /* -**shortSignNonsecure0: +**shortSignNonsecure0: { target arm_cmse_clear_ok } +** ... +** blxns r[0-3] +** ... +** sxth r0, r0 +** ... +*/ +/* +**shortSignNonsecure0: { target { ! arm_cmse_clear_ok } } ** ... ** bl __gnu_cmse_nonsecure_call ** sxth r0, r0 @@ -68,7 +102,15 @@ signed short shortSignNonsecure0 (ns_short_sign_foo_t * ns_foo_p) } /* -**enumNonsecure0: +**enumNonsecure0: { target arm_cmse_clear_ok } +** ... +** blxns r[0-3] +** ... +** uxtb r0, r0 +** ... +*/ +/* +**enumNonsecure0: { target { ! arm_cmse_clear_ok } } ** ... ** bl __gnu_cmse_nonsecure_call ** uxtb r0, r0 @@ -80,7 +122,15 @@ unsigned char __attribute__((noipa)) enumNonsecure0 (ns_enum_foo_t * ns_foo_p) } /* -**boolNonsecure0: +**boolNonsecure0: { target arm_cmse_clear_ok } +** ... +** blxns r[0-3] +** ... +** uxtb r0, r0 +** ... +*/ +/* +**boolNonsecure0: { target { ! arm_cmse_clear_ok } } ** ... ** bl __gnu_cmse_nonsecure_call ** uxtb r0, r0 diff --git a/gcc/testsuite/gcc.target/arm/multilib.exp b/gcc/testsuite/gcc.target/arm/multilib.exp index 4442d5d754bd6..12c93bc89d222 100644 --- a/gcc/testsuite/gcc.target/arm/multilib.exp +++ b/gcc/testsuite/gcc.target/arm/multilib.exp @@ -18,13 +18,15 @@ load_lib gcc-dg.exp dg-init -if { [board_info [target_info name] exists multilib_flags] - && [regexp {(-marm|-mthumb|-march=.*|-mcpu=.*|-mfpu=.*|-mfloat=abi=.*)\y} [board_info [target_info name] multilib_flags]] } { +foreach flagsvar {multilib_flags cflags} { + if { [board_info [target_info name] exists $flagsvar] + && [regexp {(-marm|-mthumb|-march=.*|-mcpu=.*|-mfpu=.*|-mfloat=abi=.*)\y} [board_info [target_info name] $flagsvar]] } { # Multilib flags override anything we can apply to a test, so # skip if any of the above options are set there. - verbose "skipping multilib tests due to multilib_flags setting" 1 + verbose "skipping multilib tests due to $flagsvar setting" 1 return + } } # We don't want to run this test multiple times in a parallel make check. diff --git a/gcc/testsuite/gcc.target/i386/apx-ccmp-1.c b/gcc/testsuite/gcc.target/i386/apx-ccmp-1.c index e4e112f07e052..a8b7057676002 100644 --- a/gcc/testsuite/gcc.target/i386/apx-ccmp-1.c +++ b/gcc/testsuite/gcc.target/i386/apx-ccmp-1.c @@ -96,9 +96,11 @@ f15 (double a, double b, int c, int d) /* { dg-final { scan-assembler-times "ccmpg" 2 } } */ /* { dg-final { scan-assembler-times "ccmple" 2 } } */ -/* { dg-final { scan-assembler-times "ccmpne" 4 } } */ -/* { dg-final { scan-assembler-times "ccmpe" 3 } } */ +/* { dg-final { scan-assembler-times "ccmpne" 2 } } */ +/* { dg-final { scan-assembler-times "ccmpe" 1 } } */ /* { dg-final { scan-assembler-times "ccmpbe" 1 } } */ +/* { dg-final { scan-assembler-times "ctestne" 2 } } */ +/* { dg-final { scan-assembler-times "cteste" 2 } } */ /* { dg-final { scan-assembler-times "ccmpa" 1 } } */ -/* { dg-final { scan-assembler-times "ccmpbl" 2 } } */ - +/* { dg-final { scan-assembler-times "ccmpbl" 1 } } */ +/* { dg-final { scan-assembler-times "ctestbl" 1 } } */ diff --git a/gcc/testsuite/gcc.target/i386/apx-ccmp-2.c b/gcc/testsuite/gcc.target/i386/apx-ccmp-2.c index 0123a686d2c41..4a0784394c326 100644 --- a/gcc/testsuite/gcc.target/i386/apx-ccmp-2.c +++ b/gcc/testsuite/gcc.target/i386/apx-ccmp-2.c @@ -12,7 +12,7 @@ int foo_apx(int a, int b, int c, int d) c += d; a += b; sum += a + c; - if (b != d && sum < c || sum > d) + if (b > d && sum != 0 || sum > d) { b += d; sum += b; @@ -32,7 +32,7 @@ int foo_noapx(int a, int b, int c, int d) c += d; a += b; sum += a + c; - if (b != d && sum < c || sum > d) + if (b > d && sum != 0 || sum > d) { b += d; sum += b; diff --git a/gcc/testsuite/gcc.target/i386/apx-zu-1.c b/gcc/testsuite/gcc.target/i386/apx-zu-1.c new file mode 100644 index 0000000000000..bc0e7fbb4dd61 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/apx-zu-1.c @@ -0,0 +1,44 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-mapxf -march=x86-64 -O2" } */ +/* { dg-final { scan-assembler-not "setle"} } */ +/* { dg-final { scan-assembler-not "setge"} } */ +/* { dg-final { scan-assembler-not "sete"} } */ +/* { dg-final { scan-assembler-not "xor"} } */ +/* { dg-final { scan-assembler-times "setzune" 1} } */ +/* { dg-final { scan-assembler-times "setzule" 1} } */ +/* { dg-final { scan-assembler-times "setzue" 1} } */ +/* { dg-final { scan-assembler-times "setzuge" 1} } */ +/* { dg-final { scan-assembler "imulzu"} } */ + +__attribute__((noinline, noclone, target("apxf"))) +long long foo0 (int a) +{ + return a == 0 ? 0 : 1; +} + +__attribute__((noinline, noclone, target("apxf"))) +long foo1 (int a, int b) +{ + return a > b ? 0 : 1; +} + +__attribute__((noinline, noclone, target("apxf"))) +int foo2 (int a, int b) +{ + return a != b ? 0 : 1; +} + +__attribute__((noinline, noclone, target("apxf"))) +short foo3 (int a, int b) +{ + return a < b ? 0 : 1; +} + +__attribute__((noinline, noclone, target("apxf"))) +unsigned long +f1(unsigned short x) +{ + unsigned short a; + a = x * 1000; + return a; +} diff --git a/gcc/testsuite/gcc.target/i386/apx-zu-2.c b/gcc/testsuite/gcc.target/i386/apx-zu-2.c new file mode 100644 index 0000000000000..7585492bd7c24 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/apx-zu-2.c @@ -0,0 +1,22 @@ +/* { dg-do run { target { ! ia32 } } } */ +/* { dg-require-effective-target apxf } */ +/* { dg-options "-mapxf -march=x86-64 -O2" } */ +#include "apx-zu-1.c" + +int main(void) +{ + if (!__builtin_cpu_supports ("apxf")) + return 0; + + if (foo0 (0)) + __builtin_abort (); + if (foo1 (3, 2)) + __builtin_abort (); + if (foo2 (3, 2)) + __builtin_abort (); + if (foo3 (2, 3)) + __builtin_abort (); + if (f1 (2) != 2000) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.target/i386/avx2-pr98461.c b/gcc/testsuite/gcc.target/i386/avx2-pr98461.c index 15f49b864daa4..225f2ab00e5f7 100644 --- a/gcc/testsuite/gcc.target/i386/avx2-pr98461.c +++ b/gcc/testsuite/gcc.target/i386/avx2-pr98461.c @@ -2,7 +2,7 @@ /* { dg-do compile } */ /* { dg-options "-O2 -mavx2 -masm=att" } */ /* { dg-final { scan-assembler-times "\tvpmovmskb\t" 6 } } */ -/* { dg-final { scan-assembler-times "\tnotl\t" 6 } } */ +/* { dg-final { scan-assembler-times "\t(?:notl|vpternlog\[dq\])\t" 6 } } */ /* { dg-final { scan-assembler-not "\tvpcmpeq" } } */ /* { dg-final { scan-assembler-not "\tvpxor" } } */ /* { dg-final { scan-assembler-not "\tvpandn" } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx512f-pr96891-3.c b/gcc/testsuite/gcc.target/i386/avx512f-pr96891-3.c index 06db75213050b..5b260818cb3c7 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-pr96891-3.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-pr96891-3.c @@ -3,7 +3,7 @@ /* { dg-final { scan-assembler-not {not[bwlqd]\]} } } */ /* { dg-final { scan-assembler-times {(?n)vpcmp[bwdq][ \t]*\$5} 4} } */ /* { dg-final { scan-assembler-times {(?n)vpcmp[bwdq][ \t]*\$6} 4} } */ -/* { dg-final { scan-assembler-times {(?n)vpcmp[bwdq][ \t]*\$7} 4} } */ +/* { dg-final { scan-assembler-times {(?n)vpcmp[bwdq][ \t]*\$[37]} 4} } */ /* { dg-final { scan-assembler-times {(?n)vcmpp[sd][ \t]*\$5} 2} } */ /* { dg-final { scan-assembler-times {(?n)vcmpp[sd][ \t]*\$6} 2} } */ /* { dg-final { scan-assembler-times {(?n)vcmpp[sd][ \t]*\$7} 2} } */ diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpternlogd-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpternlogd-1.c index a88153a85db3f..b0984879eab42 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpternlogd-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpternlogd-1.c @@ -1,6 +1,5 @@ /* { dg-do compile } */ /* { dg-options "-mavx512f -O2" } */ -/* { dg-final { scan-assembler-times "vpternlogd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ /* { dg-final { scan-assembler-times "vpternlogd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ /* { dg-final { scan-assembler-times "vpternlogd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpternlogd-3.c b/gcc/testsuite/gcc.target/i386/avx512f-vpternlogd-3.c new file mode 100644 index 0000000000000..9ed4680346be7 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpternlogd-3.c @@ -0,0 +1,955 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx512f" } */ + +typedef unsigned int V __attribute__ ((__vector_size__ (16))); + +V foo_0_1(V a, V b, V c) { return (V){0,0,0,0}; } + +V foo_1_1(V a, V b, V c) { return ~((b|a)|c); } + +V foo_2_1(V a, V b, V c) { return (~(b|a))&c; } + +V foo_3_1(V a, V b, V c) { return ~(b|a); } + +V foo_4_1(V a, V b, V c) { return (~(c|a))&b; } + +V foo_5_1(V a, V b, V c) { return ~(c|a); } + +V foo_6_1(V a, V b, V c) { return (c^b)&~a; } + +V foo_7_1(V a, V b, V c) { return ~((c&b)|a); } + +V foo_8_1(V a, V b, V c) { return (~a&c)&b; } +V foo_8_2(V a, V b, V c) { return (~a&b)&c; } +V foo_8_3(V a, V b, V c) { return (c&b)&~a; } + +V foo_9_1(V a, V b, V c) { return ~((c^b)|a); } + +V foo_10_1(V a, V b, V c) { return ~a&c; } + +V foo_11_1(V a, V b, V c) { return ~((~c&b)|a); } +V foo_11_2(V a, V b, V c) { return (~b|c)&~a; } + +V foo_12_1(V a, V b, V c) { return ~a&b; } + +V foo_13_1(V a, V b, V c) { return ~((~b&c)|a); } +V foo_13_2(V a, V b, V c) { return (~c|b)&~a; } + +V foo_14_1(V a, V b, V c) { return (c|b)&~a; } + +V foo_15_1(V a, V b, V c) { return ~a; } + +V foo_16_1(V a, V b, V c) { return (~(c|b))&a; } + +V foo_17_1(V a, V b, V c) { return ~(c|b); } + +V foo_18_1(V a, V b, V c) { return (c^a)&~b; } + +V foo_19_1(V a, V b, V c) { return ~((c&a)|b); } + +V foo_20_1(V a, V b, V c) { return (b^a)&~c; } + +V foo_21_1(V a, V b, V c) { return ~((b&a)|c); } + +V foo_22_1(V a, V b, V c) { return ((b^a)|(c&b))^c; } +V foo_22_2(V a, V b, V c) { return ((c^a)|(c&b))^b; } +V foo_22_3(V a, V b, V c) { return ((c^b)|(c&a))^a; } +V foo_22_4(V a, V b, V c) { return ((b&a)|c)^(b|a); } +V foo_22_5(V a, V b, V c) { return ((c&a)|b)^(c|a); } +V foo_22_6(V a, V b, V c) { return ((c&b)|a)^(c|b); } + +V foo_23_1(V a, V b, V c) { return ~(((b^a)&(c^a))^a); } +V foo_23_2(V a, V b, V c) { return ((b^a)&(c^a))^~a; } +V foo_23_3(V a, V b, V c) { return ((b^a)&(c^b))^~b; } +V foo_23_4(V a, V b, V c) { return ((b^a)&c)^(~(b&a)); } +V foo_23_5(V a, V b, V c) { return ((c^a)&(c^b))^~c; } +V foo_23_6(V a, V b, V c) { return ((c^a)&b)^(~(c&a)); } +V foo_23_7(V a, V b, V c) { return ((c^b)&a)^(~(c&b)); } +V foo_23_8(V a, V b, V c) { return (~((c^b)&a))^(c&b); } +V foo_23_9(V a, V b, V c) { return (~((c^a)&b))^(c&a); } +V foo_23_10(V a, V b, V c) { return (~((c^a)&(c^b)))^c; } +V foo_23_11(V a, V b, V c) { return (~((b^a)&c))^(b&a); } +V foo_23_12(V a, V b, V c) { return (~((b^a)&(c^b)))^b; } +V foo_23_13(V a, V b, V c) { return (~((b^a)&(c^a)))^a; } +V foo_23_14(V a, V b, V c) { return ((~(b^a))|c)^(b|a); } +V foo_23_15(V a, V b, V c) { return ((~(c^a))|b)^(c|a); } +V foo_23_16(V a, V b, V c) { return ((~(c^b))|a)^(c|b); } + +V foo_24_1(V a, V b, V c) { return (b^a)&(c^a); } + +V foo_25_1(V a, V b, V c) { return ~((c^b)|(c&a)); } +V foo_25_2(V a, V b, V c) { return ((c&a)|~b)^c; } +V foo_25_3(V a, V b, V c) { return ((b&a)|~c)^b; } + +V foo_26_1(V a, V b, V c) { return ((b&a)|c)^a; } + +V foo_27_1(V a, V b, V c) { return ~(((b^a)&c)^b); } +V foo_27_2(V a, V b, V c) { return ((b^a)&c)^~b; } +V foo_27_3(V a, V b, V c) { return (~b|c)^(c&a); } +V foo_27_4(V a, V b, V c) { return (~((b^a)&c))^b; } +V foo_27_5(V a, V b, V c) { return ((~(b^a))|c)^a; } +V foo_27_6(V a, V b, V c) { return (~c|a)^(c|b); } + +V foo_28_1(V a, V b, V c) { return ((c&a)|b)^a; } + +V foo_29_1(V a, V b, V c) { return ~(((c^a)&b)^c); } +V foo_29_2(V a, V b, V c) { return ((c^a)&b)^~c; } +V foo_29_3(V a, V b, V c) { return (~((c^a)&b))^c; } +V foo_29_4(V a, V b, V c) { return (~c|b)^(b&a); } +V foo_29_5(V a, V b, V c) { return ((~(c^a))|b)^a; } +V foo_29_6(V a, V b, V c) { return (~b|a)^(c|b); } + +V foo_30_1(V a, V b, V c) { return (c|b)^a; } + +V foo_31_1(V a, V b, V c) { return ~((c|b)&a); } + +V foo_32_1(V a, V b, V c) { return (~b&c)&a; } +V foo_32_2(V a, V b, V c) { return (~b&a)&c; } +V foo_32_3(V a, V b, V c) { return (c&a)&~b; } + +V foo_33_1(V a, V b, V c) { return ~((c^a)|b); } + +V foo_34_1(V a, V b, V c) { return ~b&c; } + +V foo_35_1(V a, V b, V c) { return ~((~c&a)|b); } +V foo_35_2(V a, V b, V c) { return (~a|c)&~b; } + +V foo_36_1(V a, V b, V c) { return (b^a)&(c^b); } + +V foo_37_1(V a, V b, V c) { return ~((c^a)|(c&b)); } +V foo_37_2(V a, V b, V c) { return ((c&b)|~a)^c; } +V foo_37_3(V a, V b, V c) { return ((b&a)|~c)^a; } + +V foo_38_1(V a, V b, V c) { return ((b&a)|c)^b; } + +V foo_39_1(V a, V b, V c) { return ~(((b^a)&c)^a); } +V foo_39_2(V a, V b, V c) { return ((b^a)&c)^~a; } +V foo_39_3(V a, V b, V c) { return (~a|c)^(c&b); } +V foo_39_4(V a, V b, V c) { return ((~(b^a))|c)^b; } +V foo_39_5(V a, V b, V c) { return (~((b^a)&c))^a; } +V foo_39_6(V a, V b, V c) { return (~c|b)^(c|a); } + +V foo_40_1(V a, V b, V c) { return (b^a)&c; } + +V foo_41_1(V a, V b, V c) { return ~((((b&a)|c)^a)^b); } +V foo_41_2(V a, V b, V c) { return (((b&a)|c)^b)^~a; } +V foo_41_3(V a, V b, V c) { return (~((b&a)|c))^(b^a); } +V foo_41_4(V a, V b, V c) { return (((b&a)|c)^a)^~b; } +V foo_41_5(V a, V b, V c) { return ((b&a)|c)^(~(b^a)); } +V foo_41_6(V a, V b, V c) { return (~(((b&a)|c)^a))^b; } +V foo_41_7(V a, V b, V c) { return ((b&a)|~c)^(b|a); } +V foo_41_8(V a, V b, V c) { return (~(((b&a)|c)^b))^a; } + +V foo_42_1(V a, V b, V c) { return (~(b&a))&c; } + +V foo_43_1(V a, V b, V c) { return ~(((b^a)&(c^a))^b); } +V foo_43_2(V a, V b, V c) { return ((b^a)&c)|(~(b|a)); } +V foo_43_3(V a, V b, V c) { return ((b^a)&c)^(~(b|a)); } +V foo_43_4(V a, V b, V c) { return ((b^a)&(c^b))^~a; } +V foo_43_5(V a, V b, V c) { return ((b^a)&(c^a))^~b; } +V foo_43_6(V a, V b, V c) { return ((b^a)|(c^a))^~c; } +V foo_43_7(V a, V b, V c) { return (~((b^a)|(c^a)))^c; } +V foo_43_8(V a, V b, V c) { return ((~(b^a))|c)^(b&a); } +V foo_43_9(V a, V b, V c) { return (~((b^a)&(c^a)))^b; } +V foo_43_10(V a, V b, V c) { return (~((b^a)&c))^(b|a); } +V foo_43_11(V a, V b, V c) { return (~((b^a)&(c^b)))^a; } +V foo_43_12(V a, V b, V c) { return ((c^b)|a)^(~c|b); } +V foo_43_13(V a, V b, V c) { return ((c^a)|b)^(~c|a); } + +V foo_44_1(V a, V b, V c) { return (b^a)&(c|b); } +V foo_44_2(V a, V b, V c) { return ((c|b)&a)^b; } + +V foo_45_1(V a, V b, V c) { return (~c|b)^a; } + +V foo_46_1(V a, V b, V c) { return (b&a)^(c|b); } +V foo_46_2(V a, V b, V c) { return ((c^a)|b)^a; } + +V foo_47_1(V a, V b, V c) { return ~((~c|b)&a); } +V foo_47_2(V a, V b, V c) { return (~b&c)|~a; } + +V foo_48_1(V a, V b, V c) { return ~b&a; } + +V foo_49_1(V a, V b, V c) { return ~((~a&c)|b); } +V foo_49_2(V a, V b, V c) { return (~c|a)&~b; } + +V foo_50_1(V a, V b, V c) { return (c|a)&~b; } + +V foo_51_1(V a, V b, V c) { return ~b; } + +V foo_52_1(V a, V b, V c) { return ((c&b)|a)^b; } + +V foo_53_1(V a, V b, V c) { return ~(((c^b)&a)^c); } +V foo_53_2(V a, V b, V c) { return ((c^b)&a)^~c; } +V foo_53_3(V a, V b, V c) { return (~((c^b)&a))^c; } +V foo_53_4(V a, V b, V c) { return (~c|a)^(b&a); } +V foo_53_5(V a, V b, V c) { return ((~(c^b))|a)^b; } +V foo_53_6(V a, V b, V c) { return (~a|b)^(c|a); } + +V foo_54_1(V a, V b, V c) { return (c|a)^b; } + +V foo_55_1(V a, V b, V c) { return ~((c|a)&b); } + +V foo_56_1(V a, V b, V c) { return (b^a)&(c|a); } +V foo_56_2(V a, V b, V c) { return ((c|a)&b)^a; } + +V foo_57_1(V a, V b, V c) { return (~c|a)^b; } + +V foo_58_1(V a, V b, V c) { return (b&a)^(c|a); } +V foo_58_2(V a, V b, V c) { return ((c^b)|a)^b; } + +V foo_59_1(V a, V b, V c) { return ~((~c|a)&b); } +V foo_59_2(V a, V b, V c) { return (~a&c)|~b; } + +V foo_60_1(V a, V b, V c) { return b^a; } + +V foo_61_1(V a, V b, V c) { return (~(c|a))|(b^a); } +V foo_61_2(V a, V b, V c) { return (~(c|b))|(b^a); } +V foo_61_3(V a, V b, V c) { return ((~(c|b))|a)^b; } +V foo_61_4(V a, V b, V c) { return ((~(c|a))|b)^a; } + +V foo_62_1(V a, V b, V c) { return (~a&c)|(b^a); } +V foo_62_2(V a, V b, V c) { return (~b&c)|(b^a); } +V foo_62_3(V a, V b, V c) { return ((~b&c)|a)^b; } +V foo_62_4(V a, V b, V c) { return ((~a&c)|b)^a; } + +V foo_63_1(V a, V b, V c) { return ~(b&a); } + +V foo_64_1(V a, V b, V c) { return (~c&b)&a; } +V foo_64_2(V a, V b, V c) { return (~c&a)&b; } +V foo_64_3(V a, V b, V c) { return (b&a)&~c; } + +V foo_65_1(V a, V b, V c) { return ~((b^a)|c); } + +V foo_66_1(V a, V b, V c) { return (c^a)&(c^b); } + +V foo_67_1(V a, V b, V c) { return ~((b^a)|(c&b)); } +V foo_67_2(V a, V b, V c) { return ((c&b)|~a)^b; } +V foo_67_3(V a, V b, V c) { return ((c&a)|~b)^a; } + +V foo_68_1(V a, V b, V c) { return ~c&b; } + +V foo_69_1(V a, V b, V c) { return ~((~b&a)|c); } +V foo_69_2(V a, V b, V c) { return (~a|b)&~c; } + +V foo_70_1(V a, V b, V c) { return ((c&a)|b)^c; } + +V foo_71_1(V a, V b, V c) { return ~(((c^a)&b)^a); } +V foo_71_2(V a, V b, V c) { return ((c^a)&b)^~a; } +V foo_71_3(V a, V b, V c) { return (~a|b)^(c&b); } +V foo_71_4(V a, V b, V c) { return ((~(c^a))|b)^c; } +V foo_71_5(V a, V b, V c) { return (~((c^a)&b))^a; } +V foo_71_6(V a, V b, V c) { return (~b|c)^(b|a); } + +V foo_72_1(V a, V b, V c) { return (c^a)&b; } + +V foo_73_1(V a, V b, V c) { return ~((((c&a)|b)^a)^c); } +V foo_73_2(V a, V b, V c) { return (((c&a)|b)^c)^~a; } +V foo_73_3(V a, V b, V c) { return (~((c&a)|b))^(c^a); } +V foo_73_4(V a, V b, V c) { return (((c&a)|b)^a)^~c; } +V foo_73_5(V a, V b, V c) { return ((c&a)|b)^(~(c^a)); } +V foo_73_6(V a, V b, V c) { return (~(((c&a)|b)^a))^c; } +V foo_73_7(V a, V b, V c) { return ((c&a)|~b)^(c|a); } +V foo_73_8(V a, V b, V c) { return (~(((c&a)|b)^c))^a; } + +V foo_74_1(V a, V b, V c) { return (c^a)&(c|b); } +V foo_74_2(V a, V b, V c) { return ((c|b)&a)^c; } + +V foo_75_1(V a, V b, V c) { return (~b|c)^a; } + +V foo_76_1(V a, V b, V c) { return (~(c&a))&b; } + +V foo_77_1(V a, V b, V c) { return ~(((b^a)&(c^a))^c); } +V foo_77_2(V a, V b, V c) { return ((c^a)&b)|(~(c|a)); } +V foo_77_3(V a, V b, V c) { return ((c^a)&b)^(~(c|a)); } +V foo_77_4(V a, V b, V c) { return ((c^a)&(c^b))^~a; } +V foo_77_5(V a, V b, V c) { return ((b^a)&(c^a))^~c; } +V foo_77_6(V a, V b, V c) { return ((b^a)|(c^a))^~b; } +V foo_77_7(V a, V b, V c) { return (~((b^a)|(c^a)))^b; } +V foo_77_8(V a, V b, V c) { return ((~(c^a))|b)^(c&a); } +V foo_77_9(V a, V b, V c) { return (~((b^a)&(c^a)))^c; } +V foo_77_10(V a, V b, V c) { return (~((c^a)&b))^(c|a); } +V foo_77_11(V a, V b, V c) { return ((c^b)|a)^(~b|c); } +V foo_77_12(V a, V b, V c) { return (~((c^a)&(c^b)))^a; } +V foo_77_13(V a, V b, V c) { return ((b^a)|c)^(~b|a); } + +V foo_78_1(V a, V b, V c) { return (c&a)^(c|b); } +V foo_78_2(V a, V b, V c) { return ((b^a)|c)^a; } + +V foo_79_1(V a, V b, V c) { return ~((~b|c)&a); } +V foo_79_2(V a, V b, V c) { return (~c&b)|~a; } + +V foo_80_1(V a, V b, V c) { return ~c&a; } + +V foo_81_1(V a, V b, V c) { return ~((~a&b)|c); } +V foo_81_2(V a, V b, V c) { return (~b|a)&~c; } + +V foo_82_1(V a, V b, V c) { return ((c&b)|a)^c; } + +V foo_83_1(V a, V b, V c) { return ~(((c^b)&a)^b); } +V foo_83_2(V a, V b, V c) { return ((c^b)&a)^~b; } +V foo_83_3(V a, V b, V c) { return (~((c^b)&a))^b; } +V foo_83_4(V a, V b, V c) { return (~b|a)^(c&a); } +V foo_83_5(V a, V b, V c) { return ((~(c^b))|a)^c; } +V foo_83_6(V a, V b, V c) { return (~a|c)^(b|a); } + +V foo_84_1(V a, V b, V c) { return (b|a)&~c; } + +V foo_85_1(V a, V b, V c) { return ~c; } + +V foo_86_1(V a, V b, V c) { return (b|a)^c; } + +V foo_87_1(V a, V b, V c) { return ~((b|a)&c); } + +V foo_88_1(V a, V b, V c) { return (c^a)&(b|a); } +V foo_88_2(V a, V b, V c) { return ((b|a)&c)^a; } + +V foo_89_1(V a, V b, V c) { return (~b|a)^c; } + +V foo_90_1(V a, V b, V c) { return c^a; } + +V foo_91_1(V a, V b, V c) { return (~(b|a))|(c^a); } +V foo_91_2(V a, V b, V c) { return (~(c|b))|(c^a); } +V foo_91_3(V a, V b, V c) { return ((~(c|b))|a)^c; } +V foo_91_4(V a, V b, V c) { return ((~(b|a))|c)^a; } + +V foo_92_1(V a, V b, V c) { return (c&a)^(b|a); } +V foo_92_2(V a, V b, V c) { return ((c^b)|a)^c; } + +V foo_93_1(V a, V b, V c) { return ~((~b|a)&c); } +V foo_93_2(V a, V b, V c) { return (~a&b)|~c; } + +V foo_94_1(V a, V b, V c) { return (~a&b)|(c^a); } +V foo_94_2(V a, V b, V c) { return (~c&b)|(c^a); } +V foo_94_3(V a, V b, V c) { return ((~c&b)|a)^c; } +V foo_94_4(V a, V b, V c) { return ((~a&b)|c)^a; } + +V foo_95_1(V a, V b, V c) { return ~(c&a); } + +V foo_96_1(V a, V b, V c) { return (c^b)&a; } + +V foo_97_1(V a, V b, V c) { return ~(((c|b)^a)|(c&b)); } +V foo_97_2(V a, V b, V c) { return (~((c&b)|a))^(c^b); } +V foo_97_3(V a, V b, V c) { return (((c&b)|a)^c)^~b; } +V foo_97_4(V a, V b, V c) { return (((c&b)|a)^b)^~c; } +V foo_97_5(V a, V b, V c) { return ((c&b)|~a)^(c|b); } +V foo_97_6(V a, V b, V c) { return ((c&b)|a)^(~(c^b)); } +V foo_97_7(V a, V b, V c) { return (~(((c&b)|a)^b))^c; } +V foo_97_8(V a, V b, V c) { return (~(((c&b)|a)^c))^b; } + +V foo_98_1(V a, V b, V c) { return (c^b)&(c|a); } +V foo_98_2(V a, V b, V c) { return ((c|a)&b)^c; } + +V foo_99_1(V a, V b, V c) { return (~a|c)^b; } + +V foo_100_1(V a, V b, V c) { return (c^b)&(b|a); } +V foo_100_2(V a, V b, V c) { return ((b|a)&c)^b; } + +V foo_101_1(V a, V b, V c) { return (~a|b)^c; } + +V foo_102_1(V a, V b, V c) { return c^b; } + +V foo_103_1(V a, V b, V c) { return (~(b|a))|(c^b); } +V foo_103_2(V a, V b, V c) { return (~(c|a))|(c^b); } +V foo_103_3(V a, V b, V c) { return ((~(c|a))|b)^c; } +V foo_103_4(V a, V b, V c) { return ((~(b|a))|c)^b; } + +V foo_104_1(V a, V b, V c) { return ((b&a)^c)&(b|a); } +V foo_104_2(V a, V b, V c) { return ((c&a)^b)&(c|a); } +V foo_104_3(V a, V b, V c) { return ((c&b)^a)&(c|b); } +V foo_104_4(V a, V b, V c) { return ((c|b)&a)^(c&b); } +V foo_104_5(V a, V b, V c) { return ((c|a)&b)^(c&a); } +V foo_104_6(V a, V b, V c) { return ((b|a)&c)^(b&a); } + +V foo_105_1(V a, V b, V c) { return ~((b^a)^c); } +V foo_105_2(V a, V b, V c) { return (c^b)^~a; } +V foo_105_3(V a, V b, V c) { return (c^a)^~b; } +V foo_105_4(V a, V b, V c) { return (b^a)^~c; } +V foo_105_5(V a, V b, V c) { return (~(c^b))^a; } +V foo_105_6(V a, V b, V c) { return (~(c^a))^b; } +V foo_105_7(V a, V b, V c) { return (~(b^a))^c; } + +V foo_106_1(V a, V b, V c) { return (b&a)^c; } + +V foo_107_1(V a, V b, V c) { return ~(((b|a)&c)^(b^a)); } +V foo_107_2(V a, V b, V c) { return ((b&a)^c)|(~(b|a)); } +V foo_107_3(V a, V b, V c) { return ((c^b)&(b|a))^~a; } +V foo_107_4(V a, V b, V c) { return ((c^a)&(b|a))^~b; } +V foo_107_5(V a, V b, V c) { return (~((b|a)&c))^(b^a); } +V foo_107_6(V a, V b, V c) { return (~((c^b)&(b|a)))^a; } +V foo_107_7(V a, V b, V c) { return (~((c^a)&(b|a)))^b; } +V foo_107_8(V a, V b, V c) { return ((b|a)&c)^(~(b^a)); } +V foo_107_9(V a, V b, V c) { return ((~(b|a))|c)^(b&a); } + +V foo_108_1(V a, V b, V c) { return (c&a)^b; } + +V foo_109_1(V a, V b, V c) { return ~(((b^a)&(c|a))^c); } +V foo_109_2(V a, V b, V c) { return ((c&a)^b)|(~(c|a)); } +V foo_109_3(V a, V b, V c) { return ((c^b)&(c|a))^~a; } +V foo_109_4(V a, V b, V c) { return (~((c|a)&b))^(c^a); } +V foo_109_5(V a, V b, V c) { return ((b^a)&(c|a))^~c; } +V foo_109_6(V a, V b, V c) { return (~((c^b)&(c|a)))^a; } +V foo_109_7(V a, V b, V c) { return ((~(c|a))|b)^(c&a); } +V foo_109_8(V a, V b, V c) { return ((c|a)&b)^(~(c^a)); } +V foo_109_9(V a, V b, V c) { return (~((b^a)&(c|a)))^c; } + +V foo_110_1(V a, V b, V c) { return (~a&c)|(c^b); } +V foo_110_2(V a, V b, V c) { return (~a&b)|(c^b); } +V foo_110_3(V a, V b, V c) { return ((~b|a)&c)^b; } +V foo_110_4(V a, V b, V c) { return ((~c|a)&b)^c; } + +V foo_111_1(V a, V b, V c) { return (c^b)|~a; } + +V foo_112_1(V a, V b, V c) { return (~(c&b))&a; } + +V foo_113_1(V a, V b, V c) { return ~(((b^a)&(c^b))^c); } +V foo_113_2(V a, V b, V c) { return ((b^a)|(c^a))^~a; } +V foo_113_3(V a, V b, V c) { return ((c^b)&a)|(~(c|b)); } +V foo_113_4(V a, V b, V c) { return ((c^b)&a)^(~(c|b)); } +V foo_113_5(V a, V b, V c) { return ((b^a)&(c^b))^~c; } +V foo_113_6(V a, V b, V c) { return ((c^a)&(c^b))^~b; } +V foo_113_7(V a, V b, V c) { return (~((b^a)|(c^a)))^a; } +V foo_113_8(V a, V b, V c) { return ((~(c^b))|a)^(c&b); } +V foo_113_9(V a, V b, V c) { return (~((c^b)&a))^(c|b); } +V foo_113_10(V a, V b, V c) { return (~((b^a)&(c^b)))^c; } +V foo_113_11(V a, V b, V c) { return ((c^a)|b)^(~a|c); } +V foo_113_12(V a, V b, V c) { return (~((c^a)&(c^b)))^b; } +V foo_113_13(V a, V b, V c) { return ((b^a)|c)^(~a|b); } + +V foo_114_1(V a, V b, V c) { return (c&b)^(c|a); } +V foo_114_2(V a, V b, V c) { return ((b^a)|c)^b; } + +V foo_115_1(V a, V b, V c) { return ~((~a|c)&b); } +V foo_115_2(V a, V b, V c) { return (~c&a)|~b; } + +V foo_116_1(V a, V b, V c) { return (c&b)^(b|a); } +V foo_116_2(V a, V b, V c) { return ((c^a)|b)^c; } + +V foo_117_1(V a, V b, V c) { return ~((~a|b)&c); } +V foo_117_2(V a, V b, V c) { return (~b&a)|~c; } + +V foo_118_1(V a, V b, V c) { return (~b&a)|(c^b); } +V foo_118_2(V a, V b, V c) { return (~c&a)|(c^b); } +V foo_118_3(V a, V b, V c) { return ((~c&a)|b)^c; } +V foo_118_4(V a, V b, V c) { return ((~b&a)|c)^b; } + +V foo_119_1(V a, V b, V c) { return ~(c&b); } + +V foo_120_1(V a, V b, V c) { return (c&b)^a; } + +V foo_121_1(V a, V b, V c) { return ~(((b^a)&(c|b))^c); } +V foo_121_2(V a, V b, V c) { return ((c&b)^a)|(~(c|b)); } +V foo_121_3(V a, V b, V c) { return (~((c|b)&a))^(c^b); } +V foo_121_4(V a, V b, V c) { return ((b^a)&(c|b))^~c; } +V foo_121_5(V a, V b, V c) { return ((c^a)&(c|b))^~b; } +V foo_121_6(V a, V b, V c) { return ((~(c|b))|a)^(c&b); } +V foo_121_7(V a, V b, V c) { return ((c|b)&a)^(~(c^b)); } +V foo_121_8(V a, V b, V c) { return (~((b^a)&(c|b)))^c; } +V foo_121_9(V a, V b, V c) { return (~((c^a)&(c|b)))^b; } + +V foo_122_1(V a, V b, V c) { return (~b&c)|(c^a); } +V foo_122_2(V a, V b, V c) { return (~b&a)|(c^a); } +V foo_122_3(V a, V b, V c) { return ((~a|b)&c)^a; } +V foo_122_4(V a, V b, V c) { return ((~c|b)&a)^c; } + +V foo_123_1(V a, V b, V c) { return (c^a)|~b; } + +V foo_124_1(V a, V b, V c) { return (~c&b)|(b^a); } +V foo_124_2(V a, V b, V c) { return (~c&a)|(b^a); } +V foo_124_3(V a, V b, V c) { return ((~a|c)&b)^a; } +V foo_124_4(V a, V b, V c) { return ((~b|c)&a)^b; } + +V foo_125_1(V a, V b, V c) { return (b^a)|~c; } + +V foo_126_1(V a, V b, V c) { return (b^a)|(c^a); } +V foo_126_2(V a, V b, V c) { return (b^a)|(c^b); } +V foo_126_3(V a, V b, V c) { return (c^a)|(c^b); } + +V foo_127_1(V a, V b, V c) { return ~((c&b)&a); } + +V foo_128_1(V a, V b, V c) { return (c&b)&a; } +V foo_128_2(V a, V b, V c) { return (c&a)&b; } +V foo_128_3(V a, V b, V c) { return (b&a)&c; } + +V foo_129_1(V a, V b, V c) { return ~((b^a)|(c^a)); } + +V foo_130_1(V a, V b, V c) { return (~(b^a))&c; } + +V foo_131_1(V a, V b, V c) { return ~((~c&b)|(b^a)); } +V foo_131_2(V a, V b, V c) { return ((~a|c)&b)^~a; } +V foo_131_3(V a, V b, V c) { return ((~b|c)&a)^~b; } +V foo_131_4(V a, V b, V c) { return (~((~b|c)&a))^b; } +V foo_131_5(V a, V b, V c) { return (~((~a|c)&b))^a; } +V foo_131_6(V a, V b, V c) { return (~a|c)&(~(b^a)); } +V foo_131_7(V a, V b, V c) { return (~b|c)&(~(b^a)); } + +V foo_132_1(V a, V b, V c) { return (~(c^a))&b; } + +V foo_133_1(V a, V b, V c) { return ~((~b&c)|(c^a)); } +V foo_133_2(V a, V b, V c) { return ((~a|b)&c)^~a; } +V foo_133_3(V a, V b, V c) { return (~((~c|b)&a))^c; } +V foo_133_4(V a, V b, V c) { return ((~c|b)&a)^~c; } +V foo_133_5(V a, V b, V c) { return (~((~a|b)&c))^a; } +V foo_133_6(V a, V b, V c) { return (~(c^a))&(~a|b); } +V foo_133_7(V a, V b, V c) { return (~(c^a))&(~c|b); } + +V foo_134_1(V a, V b, V c) { return ((b^a)&(c|b))^c; } +V foo_134_2(V a, V b, V c) { return ((c^a)&(c|b))^b; } +V foo_134_3(V a, V b, V c) { return ((c|b)&a)^(c^b); } +V foo_134_4(V a, V b, V c) { return ((b^a)^c)&(c|b); } + +V foo_135_1(V a, V b, V c) { return ~((c&b)^a); } +V foo_135_2(V a, V b, V c) { return (c&b)^~a; } +V foo_135_3(V a, V b, V c) { return (~(c&b))^a; } + +V foo_136_1(V a, V b, V c) { return c&b; } + +V foo_137_1(V a, V b, V c) { return ~((~b&a)|(c^b)); } +V foo_137_2(V a, V b, V c) { return (~((~c&a)|b))^c; } +V foo_137_3(V a, V b, V c) { return ((~b&a)|c)^~b; } +V foo_137_4(V a, V b, V c) { return (~((~b&a)|c))^b; } +V foo_137_5(V a, V b, V c) { return ((~c&a)|b)^~c; } +V foo_137_6(V a, V b, V c) { return (~(c^b))&(~a|c); } +V foo_137_7(V a, V b, V c) { return (~(c^b))&(~a|b); } + +V foo_138_1(V a, V b, V c) { return (~a|b)&c; } + +V foo_139_1(V a, V b, V c) { return ~((c&b)^(b|a)); } +V foo_139_2(V a, V b, V c) { return (~(b|a))|(c&b); } +V foo_139_3(V a, V b, V c) { return (~(b|a))^(c&b); } +V foo_139_4(V a, V b, V c) { return (~((c^a)|b))^c; } +V foo_139_5(V a, V b, V c) { return ((c^a)|b)^~c; } +V foo_139_6(V a, V b, V c) { return (~(c&b))^(b|a); } +V foo_139_7(V a, V b, V c) { return ((c^a)|~b)^a; } + +V foo_140_1(V a, V b, V c) { return (~a|c)&b; } + +V foo_141_1(V a, V b, V c) { return ~((c&b)^(c|a)); } +V foo_141_2(V a, V b, V c) { return (~(c|a))|(c&b); } +V foo_141_3(V a, V b, V c) { return (~(c|a))^(c&b); } +V foo_141_4(V a, V b, V c) { return ((b^a)|c)^~b; } +V foo_141_5(V a, V b, V c) { return (~((b^a)|c))^b; } +V foo_141_6(V a, V b, V c) { return (~(c&b))^(c|a); } +V foo_141_7(V a, V b, V c) { return ((b^a)|~c)^a; } + +V foo_142_1(V a, V b, V c) { return ((b^a)&(c^b))^c; } +V foo_142_2(V a, V b, V c) { return ((c^a)&(c^b))^b; } +V foo_142_3(V a, V b, V c) { return ((c^b)&a)^(c|b); } +V foo_142_4(V a, V b, V c) { return ((b^a)|(c^a))^a; } + +V foo_143_1(V a, V b, V c) { return (c&b)|~a; } + +V foo_144_1(V a, V b, V c) { return (~(c^b))&a; } + +V foo_145_1(V a, V b, V c) { return ~((~a&c)|(c^b)); } +V foo_145_2(V a, V b, V c) { return ((~b|a)&c)^~b; } +V foo_145_3(V a, V b, V c) { return (~((~c|a)&b))^c; } +V foo_145_4(V a, V b, V c) { return ((~c|a)&b)^~c; } +V foo_145_5(V a, V b, V c) { return (~((~b|a)&c))^b; } +V foo_145_6(V a, V b, V c) { return (~(c^b))&(~b|a); } +V foo_145_7(V a, V b, V c) { return (~(c^b))&(~c|a); } + +V foo_146_1(V a, V b, V c) { return ((b^a)&(c|a))^c; } +V foo_146_2(V a, V b, V c) { return ((c|a)&b)^(c^a); } +V foo_146_3(V a, V b, V c) { return ((c^b)&(c|a))^a; } +V foo_146_4(V a, V b, V c) { return ((b^a)^c)&(c|a); } + +V foo_147_1(V a, V b, V c) { return ~((c&a)^b); } +V foo_147_2(V a, V b, V c) { return (c&a)^~b; } +V foo_147_3(V a, V b, V c) { return (~(c&a))^b; } + +V foo_148_1(V a, V b, V c) { return ((b|a)&c)^(b^a); } +V foo_148_2(V a, V b, V c) { return ((c^a)&(b|a))^b; } +V foo_148_3(V a, V b, V c) { return ((c^b)&(b|a))^a; } +V foo_148_4(V a, V b, V c) { return ((b^a)^c)&(b|a); } + +V foo_149_1(V a, V b, V c) { return ~((b&a)^c); } +V foo_149_2(V a, V b, V c) { return (~(b&a))^c; } +V foo_149_3(V a, V b, V c) { return (b&a)^~c; } + +V foo_150_1(V a, V b, V c) { return (b^a)^c; } +V foo_150_2(V a, V b, V c) { return (c^a)^b; } +V foo_150_3(V a, V b, V c) { return (c^b)^a; } + +V foo_151_1(V a, V b, V c) { return ~(((b&a)^c)&(b|a)); } +V foo_151_2(V a, V b, V c) { return ((b^a)^c)|(~(b|a)); } +V foo_151_3(V a, V b, V c) { return ((b^a)^c)|(~(c|a)); } +V foo_151_4(V a, V b, V c) { return ((b^a)^c)|(~(c|b)); } +V foo_151_5(V a, V b, V c) { return (~((c|b)&a))^(c&b); } +V foo_151_6(V a, V b, V c) { return (~((c|a)&b))^(c&a); } +V foo_151_7(V a, V b, V c) { return ((~(b|a))|c)^(b^a); } +V foo_151_8(V a, V b, V c) { return ((~(c|a))|(b^a))^c; } +V foo_151_9(V a, V b, V c) { return ((b|a)&c)^(~(b&a)); } +V foo_151_10(V a, V b, V c) { return (~((b|a)&c))^(b&a); } +V foo_151_11(V a, V b, V c) { return ((~(c|a))|b)^(c^a); } +V foo_151_12(V a, V b, V c) { return ((~(b|a))|(c^a))^b; } +V foo_151_13(V a, V b, V c) { return ((c|a)&b)^(~(c&a)); } +V foo_151_14(V a, V b, V c) { return ((~(c|b))|a)^(c^b); } +V foo_151_15(V a, V b, V c) { return ((~(b|a))|(c^b))^a; } +V foo_151_16(V a, V b, V c) { return ((c|b)&a)^(~(c&b)); } + +V foo_152_1(V a, V b, V c) { return ((c|a)&~b)^c; } +V foo_152_2(V a, V b, V c) { return ((b|a)&~c)^b; } +V foo_152_3(V a, V b, V c) { return (~(c^b))&(c|a); } +V foo_152_4(V a, V b, V c) { return (~(c^b))&(b|a); } + +V foo_153_1(V a, V b, V c) { return ~(c^b); } +V foo_153_2(V a, V b, V c) { return ~b^c; } +V foo_153_3(V a, V b, V c) { return ~c^b; } + +V foo_154_1(V a, V b, V c) { return (~b&a)^c; } + +V foo_155_1(V a, V b, V c) { return ~((c^b)&(b|a)); } +V foo_155_2(V a, V b, V c) { return ((b|a)&c)^~b; } +V foo_155_3(V a, V b, V c) { return (~((b|a)&c))^b; } + +V foo_156_1(V a, V b, V c) { return (~c&a)^b; } + +V foo_157_1(V a, V b, V c) { return ~((c^b)&(c|a)); } +V foo_157_2(V a, V b, V c) { return (~((c|a)&b))^c; } +V foo_157_3(V a, V b, V c) { return ((c|a)&b)^~c; } + +V foo_158_1(V a, V b, V c) { return ((c|b)^a)|(c&b); } +V foo_158_2(V a, V b, V c) { return (((c&b)|a)^b)^c; } +V foo_158_3(V a, V b, V c) { return (((c&b)|a)^c)^b; } +V foo_158_4(V a, V b, V c) { return ((c&b)|a)^(c^b); } +V foo_158_5(V a, V b, V c) { return ((b^a)^c)|(c&b); } + +V foo_159_1(V a, V b, V c) { return ~((c^b)&a); } + +V foo_160_1(V a, V b, V c) { return c&a; } + +V foo_161_1(V a, V b, V c) { return ~((~a&b)|(c^a)); } +V foo_161_2(V a, V b, V c) { return (~((~c&b)|a))^c; } +V foo_161_3(V a, V b, V c) { return ((~a&b)|c)^~a; } +V foo_161_4(V a, V b, V c) { return (~((~a&b)|c))^a; } +V foo_161_5(V a, V b, V c) { return ((~c&b)|a)^~c; } +V foo_161_6(V a, V b, V c) { return (~(c^a))&(~b|c); } +V foo_161_7(V a, V b, V c) { return (~(c^a))&(~b|a); } + +V foo_162_1(V a, V b, V c) { return (~b|a)&c; } + +V foo_163_1(V a, V b, V c) { return ~((c&a)^(b|a)); } +V foo_163_2(V a, V b, V c) { return (~(b|a))|(c&a); } +V foo_163_3(V a, V b, V c) { return (~(b|a))^(c&a); } +V foo_163_4(V a, V b, V c) { return (~((c^b)|a))^c; } +V foo_163_5(V a, V b, V c) { return ((c^b)|a)^~c; } +V foo_163_6(V a, V b, V c) { return (~(c&a))^(b|a); } +V foo_163_7(V a, V b, V c) { return ((c^b)|~a)^b; } + +V foo_164_1(V a, V b, V c) { return ((c|b)&~a)^c; } +V foo_164_2(V a, V b, V c) { return ((b|a)&~c)^a; } +V foo_164_3(V a, V b, V c) { return (~(c^a))&(c|b); } +V foo_164_4(V a, V b, V c) { return (~(c^a))&(b|a); } + +V foo_165_1(V a, V b, V c) { return ~(c^a); } +V foo_165_2(V a, V b, V c) { return ~a^c; } +V foo_165_3(V a, V b, V c) { return ~c^a; } + +V foo_166_1(V a, V b, V c) { return (~a&b)^c; } + +V foo_167_1(V a, V b, V c) { return ~((c^a)&(b|a)); } +V foo_167_2(V a, V b, V c) { return ((b|a)&c)^~a; } +V foo_167_3(V a, V b, V c) { return (~((b|a)&c))^a; } + +V foo_168_1(V a, V b, V c) { return (b|a)&c; } + +V foo_169_1(V a, V b, V c) { return ~((b|a)^c); } +V foo_169_2(V a, V b, V c) { return (~(b|a))^c; } +V foo_169_3(V a, V b, V c) { return (b|a)^~c; } + +V foo_170_1(V a, V b, V c) { return c; } + +V foo_171_1(V a, V b, V c) { return (~(b|a))|c; } + +V foo_172_1(V a, V b, V c) { return ((c^b)&a)^b; } + +V foo_173_1(V a, V b, V c) { return ~(((c&b)|a)^c); } +V foo_173_2(V a, V b, V c) { return (~((c&b)|a))^c; } +V foo_173_3(V a, V b, V c) { return ((c&b)|a)^~c; } +V foo_173_4(V a, V b, V c) { return (~(c^a))|(c&b); } + +V foo_174_1(V a, V b, V c) { return (~a&b)|c; } + +V foo_175_1(V a, V b, V c) { return ~a|c; } + +V foo_176_1(V a, V b, V c) { return (~b|c)&a; } + +V foo_177_1(V a, V b, V c) { return ~((c&a)^(c|b)); } +V foo_177_2(V a, V b, V c) { return ((b^a)|c)^~a; } +V foo_177_3(V a, V b, V c) { return (~(c|b))|(c&a); } +V foo_177_4(V a, V b, V c) { return (~(c|b))^(c&a); } +V foo_177_5(V a, V b, V c) { return (~((b^a)|c))^a; } +V foo_177_6(V a, V b, V c) { return (~(c&a))^(c|b); } +V foo_177_7(V a, V b, V c) { return ((b^a)|~c)^b; } + +V foo_178_1(V a, V b, V c) { return ((b^a)&(c^a))^c; } +V foo_178_2(V a, V b, V c) { return ((c^a)&(c^b))^a; } +V foo_178_3(V a, V b, V c) { return ((c^a)&b)^(c|a); } +V foo_178_4(V a, V b, V c) { return ((b^a)|(c^a))^b; } + +V foo_179_1(V a, V b, V c) { return (c&a)|~b; } + +V foo_180_1(V a, V b, V c) { return (~c&b)^a; } + +V foo_181_1(V a, V b, V c) { return ~((c^a)&(c|b)); } +V foo_181_2(V a, V b, V c) { return (~((c|b)&a))^c; } +V foo_181_3(V a, V b, V c) { return ((c|b)&a)^~c; } + +V foo_182_1(V a, V b, V c) { return (((c&a)|b)^a)^c; } +V foo_182_2(V a, V b, V c) { return ((c|a)^b)|(c&a); } +V foo_182_3(V a, V b, V c) { return (((c&a)|b)^c)^a; } +V foo_182_4(V a, V b, V c) { return ((c&a)|b)^(c^a); } +V foo_182_5(V a, V b, V c) { return ((b^a)^c)|(c&a); } + +V foo_183_1(V a, V b, V c) { return ~((c^a)&b); } + +V foo_184_1(V a, V b, V c) { return ((c^a)&b)^a; } + +V foo_185_1(V a, V b, V c) { return ~(((c&a)|b)^c); } +V foo_185_2(V a, V b, V c) { return (~((c&a)|b))^c; } +V foo_185_3(V a, V b, V c) { return ((c&a)|b)^~c; } +V foo_185_4(V a, V b, V c) { return (~(c^b))|(c&a); } + +V foo_186_1(V a, V b, V c) { return (~b&a)|c; } + +V foo_187_1(V a, V b, V c) { return ~b|c; } + +V foo_188_1(V a, V b, V c) { return (b^a)|(c&b); } +V foo_188_2(V a, V b, V c) { return (b^a)|(c&a); } + +V foo_189_1(V a, V b, V c) { return ~((c^a)&(c^b)); } +V foo_189_2(V a, V b, V c) { return (~(c^b))|(b^a); } +V foo_189_3(V a, V b, V c) { return (~(c^a))|(b^a); } + +V foo_190_1(V a, V b, V c) { return (b^a)|c; } + +V foo_191_1(V a, V b, V c) { return (~(b&a))|c; } + +V foo_192_1(V a, V b, V c) { return b&a; } + +V foo_193_1(V a, V b, V c) { return ~((~a&c)|(b^a)); } +V foo_193_2(V a, V b, V c) { return (~((~b&c)|a))^b; } +V foo_193_3(V a, V b, V c) { return ((~a&c)|b)^~a; } +V foo_193_4(V a, V b, V c) { return (~((~a&c)|b))^a; } +V foo_193_5(V a, V b, V c) { return ((~b&c)|a)^~b; } +V foo_193_6(V a, V b, V c) { return (~(b^a))&(~c|b); } +V foo_193_7(V a, V b, V c) { return (~(b^a))&(~c|a); } + +V foo_194_1(V a, V b, V c) { return ((c|b)&~a)^b; } +V foo_194_2(V a, V b, V c) { return ((c|a)&~b)^a; } +V foo_194_3(V a, V b, V c) { return (~(b^a))&(c|b); } +V foo_194_4(V a, V b, V c) { return (~(b^a))&(c|a); } + +V foo_195_1(V a, V b, V c) { return ~(b^a); } +V foo_195_2(V a, V b, V c) { return ~a^b; } +V foo_195_3(V a, V b, V c) { return ~b^a; } + +V foo_196_1(V a, V b, V c) { return (~c|a)&b; } + +V foo_197_1(V a, V b, V c) { return ~((b&a)^(c|a)); } +V foo_197_2(V a, V b, V c) { return (~(c|a))|(b&a); } +V foo_197_3(V a, V b, V c) { return (~(c|a))^(b&a); } +V foo_197_4(V a, V b, V c) { return (~((c^b)|a))^b; } +V foo_197_5(V a, V b, V c) { return ((c^b)|a)^~b; } +V foo_197_6(V a, V b, V c) { return (~(b&a))^(c|a); } +V foo_197_7(V a, V b, V c) { return ((c^b)|~a)^c; } + +V foo_198_1(V a, V b, V c) { return (~a&c)^b; } + +V foo_199_1(V a, V b, V c) { return ~((b^a)&(c|a)); } +V foo_199_2(V a, V b, V c) { return ((c|a)&b)^~a; } +V foo_199_3(V a, V b, V c) { return (~((c|a)&b))^a; } + +V foo_200_1(V a, V b, V c) { return (c|a)&b; } + +V foo_201_1(V a, V b, V c) { return ~((c|a)^b); } +V foo_201_2(V a, V b, V c) { return (~(c|a))^b; } +V foo_201_3(V a, V b, V c) { return (c|a)^~b; } + +V foo_202_1(V a, V b, V c) { return ((c^b)&a)^c; } + +V foo_203_1(V a, V b, V c) { return ~(((c&b)|a)^b); } +V foo_203_2(V a, V b, V c) { return (~((c&b)|a))^b; } +V foo_203_3(V a, V b, V c) { return ((c&b)|a)^~b; } +V foo_203_4(V a, V b, V c) { return (~(b^a))|(c&b); } + +V foo_204_1(V a, V b, V c) { return b; } + +V foo_205_1(V a, V b, V c) { return (~(c|a))|b; } + +V foo_206_1(V a, V b, V c) { return (~a&c)|b; } + +V foo_207_1(V a, V b, V c) { return ~a|b; } + +V foo_208_1(V a, V b, V c) { return (~c|b)&a; } + +V foo_209_1(V a, V b, V c) { return ~((b&a)^(c|b)); } +V foo_209_2(V a, V b, V c) { return ((c^a)|b)^~a; } +V foo_209_3(V a, V b, V c) { return (~(c|b))|(b&a); } +V foo_209_4(V a, V b, V c) { return (~(c|b))^(b&a); } +V foo_209_5(V a, V b, V c) { return (~((c^a)|b))^a; } +V foo_209_6(V a, V b, V c) { return (~(b&a))^(c|b); } +V foo_209_7(V a, V b, V c) { return ((c^a)|~b)^c; } + +V foo_210_1(V a, V b, V c) { return (~b&c)^a; } + +V foo_211_1(V a, V b, V c) { return ~((b^a)&(c|b)); } +V foo_211_2(V a, V b, V c) { return (~((c|b)&a))^b; } +V foo_211_3(V a, V b, V c) { return ((c|b)&a)^~b; } + +V foo_212_1(V a, V b, V c) { return ((b^a)&(c^a))^b; } +V foo_212_2(V a, V b, V c) { return ((b^a)&(c^b))^a; } +V foo_212_3(V a, V b, V c) { return ((b^a)&c)^(b|a); } +V foo_212_4(V a, V b, V c) { return ((b^a)|(c^a))^c; } + +V foo_213_1(V a, V b, V c) { return (b&a)|~c; } + +V foo_214_1(V a, V b, V c) { return (((b&a)|c)^a)^b; } +V foo_214_2(V a, V b, V c) { return (((b&a)|c)^b)^a; } +V foo_214_3(V a, V b, V c) { return ((b&a)|c)^(b^a); } +V foo_214_4(V a, V b, V c) { return ((b|a)^c)|(b&a); } +V foo_214_5(V a, V b, V c) { return ((b^a)^c)|(b&a); } + +V foo_215_1(V a, V b, V c) { return ~((b^a)&c); } + +V foo_216_1(V a, V b, V c) { return ((b^a)&c)^a; } + +V foo_217_1(V a, V b, V c) { return ~(((b&a)|c)^b); } +V foo_217_2(V a, V b, V c) { return (~((b&a)|c))^b; } +V foo_217_3(V a, V b, V c) { return ((b&a)|c)^~b; } +V foo_217_4(V a, V b, V c) { return (~(c^b))|(b&a); } + +V foo_218_1(V a, V b, V c) { return (c^a)|(c&b); } +V foo_218_2(V a, V b, V c) { return (c^a)|(b&a); } + +V foo_219_1(V a, V b, V c) { return ~((b^a)&(c^b)); } +V foo_219_2(V a, V b, V c) { return (~(c^b))|(c^a); } +V foo_219_3(V a, V b, V c) { return (~(b^a))|(c^a); } + +V foo_220_1(V a, V b, V c) { return (~c&a)|b; } + +V foo_221_1(V a, V b, V c) { return ~c|b; } + +V foo_222_1(V a, V b, V c) { return (c^a)|b; } + +V foo_223_1(V a, V b, V c) { return (~(c&a))|b; } + +V foo_224_1(V a, V b, V c) { return (c|b)&a; } + +V foo_225_1(V a, V b, V c) { return ~((c|b)^a); } +V foo_225_2(V a, V b, V c) { return (c|b)^~a; } +V foo_225_3(V a, V b, V c) { return (~(c|b))^a; } + +V foo_226_1(V a, V b, V c) { return ((c^a)&b)^c; } + +V foo_227_1(V a, V b, V c) { return ~(((c&a)|b)^a); } +V foo_227_2(V a, V b, V c) { return ((c&a)|b)^~a; } +V foo_227_3(V a, V b, V c) { return (~((c&a)|b))^a; } +V foo_227_4(V a, V b, V c) { return (~(b^a))|(c&a); } + +V foo_228_1(V a, V b, V c) { return ((b^a)&c)^b; } + +V foo_229_1(V a, V b, V c) { return ~(((b&a)|c)^a); } +V foo_229_2(V a, V b, V c) { return ((b&a)|c)^~a; } +V foo_229_3(V a, V b, V c) { return (~((b&a)|c))^a; } +V foo_229_4(V a, V b, V c) { return (~(c^a))|(b&a); } + +V foo_230_1(V a, V b, V c) { return (c^b)|(c&a); } +V foo_230_2(V a, V b, V c) { return (c^b)|(b&a); } + +V foo_231_1(V a, V b, V c) { return ~((b^a)&(c^a)); } +V foo_231_2(V a, V b, V c) { return (~(c^a))|(c^b); } +V foo_231_3(V a, V b, V c) { return (~(b^a))|(c^b); } + +V foo_232_1(V a, V b, V c) { return ((b^a)&(c^a))^a; } +V foo_232_2(V a, V b, V c) { return ((b^a)&(c^b))^b; } +V foo_232_3(V a, V b, V c) { return ((b^a)&c)|(b&a); } +V foo_232_4(V a, V b, V c) { return ((b^a)&c)^(b&a); } +V foo_232_5(V a, V b, V c) { return ((c^a)&(c^b))^c; } +V foo_232_6(V a, V b, V c) { return ((c^a)&b)|(c&a); } +V foo_232_7(V a, V b, V c) { return ((c^a)&b)^(c&a); } +V foo_232_8(V a, V b, V c) { return ((c^b)&a)|(c&b); } +V foo_232_9(V a, V b, V c) { return ((c^b)&a)^(c&b); } +V foo_232_10(V a, V b, V c) { return ((c|b)&a)|(c&b); } +V foo_232_11(V a, V b, V c) { return ((c|a)&b)|(c&a); } +V foo_232_12(V a, V b, V c) { return ((b|a)&c)|(b&a); } +V foo_232_13(V a, V b, V c) { return ((b&a)|c)&(b|a); } +V foo_232_14(V a, V b, V c) { return ((c&a)|b)&(c|a); } +V foo_232_15(V a, V b, V c) { return ((c&b)|a)&(c|b); } + +V foo_233_1(V a, V b, V c) { return ~(((b^a)|(c&b))^c); } +V foo_233_2(V a, V b, V c) { return ((b&a)|c)^(~(b|a)); } +V foo_233_3(V a, V b, V c) { return ((c&a)|b)^(~(c|a)); } +V foo_233_4(V a, V b, V c) { return (~((c&b)|a))^(c|b); } +V foo_233_5(V a, V b, V c) { return ((c^b)|(c&a))^~a; } +V foo_233_6(V a, V b, V c) { return ((c&b)|a)^(~(c|b)); } +V foo_233_7(V a, V b, V c) { return (~((c&a)|b))^(c|a); } +V foo_233_8(V a, V b, V c) { return (~((b&a)|c))^(b|a); } +V foo_233_9(V a, V b, V c) { return (~((c^b)|(c&a)))^a; } +V foo_233_10(V a, V b, V c) { return (~((c^a)|(c&b)))^b; } +V foo_233_11(V a, V b, V c) { return ((c^a)|(c&b))^~b; } +V foo_233_12(V a, V b, V c) { return ((b&a)|~c)^(b^a); } +V foo_233_13(V a, V b, V c) { return (~((b^a)|(c&b)))^c; } +V foo_233_14(V a, V b, V c) { return ((b^a)|(c&b))^~c; } +V foo_233_15(V a, V b, V c) { return ((c&a)|~b)^(c^a); } +V foo_233_16(V a, V b, V c) { return ((c&b)|~a)^(c^b); } +V foo_233_17(V a, V b, V c) { return (~((b^a)^c))|(c&b); } +V foo_233_18(V a, V b, V c) { return (~((b^a)^c))|(c&a); } +V foo_233_19(V a, V b, V c) { return (~((b^a)^c))|(b&a); } +V foo_233_20(V a, V b, V c) { return (~((c|b)^a))|(c&b); } +V foo_233_21(V a, V b, V c) { return (~((c|a)^b))|(c&a); } +V foo_233_22(V a, V b, V c) { return (~((b|a)^c))|(b&a); } + +V foo_234_1(V a, V b, V c) { return (b&a)|c; } + +V foo_235_1(V a, V b, V c) { return (~(b^a))|c; } + +V foo_236_1(V a, V b, V c) { return (c&a)|b; } + +V foo_237_1(V a, V b, V c) { return (~(c^a))|b; } + +V foo_238_1(V a, V b, V c) { return c|b; } + +V foo_239_1(V a, V b, V c) { return (c|b)|~a; } +V foo_239_2(V a, V b, V c) { return (~a|b)|c; } +V foo_239_3(V a, V b, V c) { return (~a|c)|b; } + +V foo_240_1(V a, V b, V c) { return a; } + +V foo_241_1(V a, V b, V c) { return (~(c|b))|a; } + +V foo_242_1(V a, V b, V c) { return (~b&c)|a; } + +V foo_243_1(V a, V b, V c) { return ~b|a; } + +V foo_244_1(V a, V b, V c) { return (~c&b)|a; } + +V foo_245_1(V a, V b, V c) { return ~c|a; } + +V foo_246_1(V a, V b, V c) { return (c^b)|a; } + +V foo_247_1(V a, V b, V c) { return (~(c&b))|a; } + +V foo_248_1(V a, V b, V c) { return (c&b)|a; } + +V foo_249_1(V a, V b, V c) { return (~(c^b))|a; } + +V foo_250_1(V a, V b, V c) { return c|a; } + +V foo_251_1(V a, V b, V c) { return (c|a)|~b; } +V foo_251_2(V a, V b, V c) { return (~b|a)|c; } +V foo_251_3(V a, V b, V c) { return (~b|c)|a; } + +V foo_252_1(V a, V b, V c) { return b|a; } + +V foo_253_1(V a, V b, V c) { return (b|a)|~c; } +V foo_253_2(V a, V b, V c) { return (~c|a)|b; } +V foo_253_3(V a, V b, V c) { return (~c|b)|a; } + +V foo_254_1(V a, V b, V c) { return (b|a)|c; } +V foo_254_2(V a, V b, V c) { return (c|a)|b; } +V foo_254_3(V a, V b, V c) { return (c|b)|a; } + +V foo_255_1(V a, V b, V c) { return (V){~0,~0,~0,~0}; } + +/* { dg-final { scan-assembler-times "vpternlogd\[ \\t\]" 673 } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpternlogd-4.c b/gcc/testsuite/gcc.target/i386/avx512f-vpternlogd-4.c new file mode 100644 index 0000000000000..eb39ffc25642d --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpternlogd-4.c @@ -0,0 +1,955 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx512f" } */ + +typedef unsigned int V __attribute__ ((__vector_size__ (32))); + +V foo_0_1(V a, V b, V c) { return (V){0,0,0,0}; } + +V foo_1_1(V a, V b, V c) { return ~((b|a)|c); } + +V foo_2_1(V a, V b, V c) { return (~(b|a))&c; } + +V foo_3_1(V a, V b, V c) { return ~(b|a); } + +V foo_4_1(V a, V b, V c) { return (~(c|a))&b; } + +V foo_5_1(V a, V b, V c) { return ~(c|a); } + +V foo_6_1(V a, V b, V c) { return (c^b)&~a; } + +V foo_7_1(V a, V b, V c) { return ~((c&b)|a); } + +V foo_8_1(V a, V b, V c) { return (~a&c)&b; } +V foo_8_2(V a, V b, V c) { return (~a&b)&c; } +V foo_8_3(V a, V b, V c) { return (c&b)&~a; } + +V foo_9_1(V a, V b, V c) { return ~((c^b)|a); } + +V foo_10_1(V a, V b, V c) { return ~a&c; } + +V foo_11_1(V a, V b, V c) { return ~((~c&b)|a); } +V foo_11_2(V a, V b, V c) { return (~b|c)&~a; } + +V foo_12_1(V a, V b, V c) { return ~a&b; } + +V foo_13_1(V a, V b, V c) { return ~((~b&c)|a); } +V foo_13_2(V a, V b, V c) { return (~c|b)&~a; } + +V foo_14_1(V a, V b, V c) { return (c|b)&~a; } + +V foo_15_1(V a, V b, V c) { return ~a; } + +V foo_16_1(V a, V b, V c) { return (~(c|b))&a; } + +V foo_17_1(V a, V b, V c) { return ~(c|b); } + +V foo_18_1(V a, V b, V c) { return (c^a)&~b; } + +V foo_19_1(V a, V b, V c) { return ~((c&a)|b); } + +V foo_20_1(V a, V b, V c) { return (b^a)&~c; } + +V foo_21_1(V a, V b, V c) { return ~((b&a)|c); } + +V foo_22_1(V a, V b, V c) { return ((b^a)|(c&b))^c; } +V foo_22_2(V a, V b, V c) { return ((c^a)|(c&b))^b; } +V foo_22_3(V a, V b, V c) { return ((c^b)|(c&a))^a; } +V foo_22_4(V a, V b, V c) { return ((b&a)|c)^(b|a); } +V foo_22_5(V a, V b, V c) { return ((c&a)|b)^(c|a); } +V foo_22_6(V a, V b, V c) { return ((c&b)|a)^(c|b); } + +V foo_23_1(V a, V b, V c) { return ~(((b^a)&(c^a))^a); } +V foo_23_2(V a, V b, V c) { return ((b^a)&(c^a))^~a; } +V foo_23_3(V a, V b, V c) { return ((b^a)&(c^b))^~b; } +V foo_23_4(V a, V b, V c) { return ((b^a)&c)^(~(b&a)); } +V foo_23_5(V a, V b, V c) { return ((c^a)&(c^b))^~c; } +V foo_23_6(V a, V b, V c) { return ((c^a)&b)^(~(c&a)); } +V foo_23_7(V a, V b, V c) { return ((c^b)&a)^(~(c&b)); } +V foo_23_8(V a, V b, V c) { return (~((c^b)&a))^(c&b); } +V foo_23_9(V a, V b, V c) { return (~((c^a)&b))^(c&a); } +V foo_23_10(V a, V b, V c) { return (~((c^a)&(c^b)))^c; } +V foo_23_11(V a, V b, V c) { return (~((b^a)&c))^(b&a); } +V foo_23_12(V a, V b, V c) { return (~((b^a)&(c^b)))^b; } +V foo_23_13(V a, V b, V c) { return (~((b^a)&(c^a)))^a; } +V foo_23_14(V a, V b, V c) { return ((~(b^a))|c)^(b|a); } +V foo_23_15(V a, V b, V c) { return ((~(c^a))|b)^(c|a); } +V foo_23_16(V a, V b, V c) { return ((~(c^b))|a)^(c|b); } + +V foo_24_1(V a, V b, V c) { return (b^a)&(c^a); } + +V foo_25_1(V a, V b, V c) { return ~((c^b)|(c&a)); } +V foo_25_2(V a, V b, V c) { return ((c&a)|~b)^c; } +V foo_25_3(V a, V b, V c) { return ((b&a)|~c)^b; } + +V foo_26_1(V a, V b, V c) { return ((b&a)|c)^a; } + +V foo_27_1(V a, V b, V c) { return ~(((b^a)&c)^b); } +V foo_27_2(V a, V b, V c) { return ((b^a)&c)^~b; } +V foo_27_3(V a, V b, V c) { return (~b|c)^(c&a); } +V foo_27_4(V a, V b, V c) { return (~((b^a)&c))^b; } +V foo_27_5(V a, V b, V c) { return ((~(b^a))|c)^a; } +V foo_27_6(V a, V b, V c) { return (~c|a)^(c|b); } + +V foo_28_1(V a, V b, V c) { return ((c&a)|b)^a; } + +V foo_29_1(V a, V b, V c) { return ~(((c^a)&b)^c); } +V foo_29_2(V a, V b, V c) { return ((c^a)&b)^~c; } +V foo_29_3(V a, V b, V c) { return (~((c^a)&b))^c; } +V foo_29_4(V a, V b, V c) { return (~c|b)^(b&a); } +V foo_29_5(V a, V b, V c) { return ((~(c^a))|b)^a; } +V foo_29_6(V a, V b, V c) { return (~b|a)^(c|b); } + +V foo_30_1(V a, V b, V c) { return (c|b)^a; } + +V foo_31_1(V a, V b, V c) { return ~((c|b)&a); } + +V foo_32_1(V a, V b, V c) { return (~b&c)&a; } +V foo_32_2(V a, V b, V c) { return (~b&a)&c; } +V foo_32_3(V a, V b, V c) { return (c&a)&~b; } + +V foo_33_1(V a, V b, V c) { return ~((c^a)|b); } + +V foo_34_1(V a, V b, V c) { return ~b&c; } + +V foo_35_1(V a, V b, V c) { return ~((~c&a)|b); } +V foo_35_2(V a, V b, V c) { return (~a|c)&~b; } + +V foo_36_1(V a, V b, V c) { return (b^a)&(c^b); } + +V foo_37_1(V a, V b, V c) { return ~((c^a)|(c&b)); } +V foo_37_2(V a, V b, V c) { return ((c&b)|~a)^c; } +V foo_37_3(V a, V b, V c) { return ((b&a)|~c)^a; } + +V foo_38_1(V a, V b, V c) { return ((b&a)|c)^b; } + +V foo_39_1(V a, V b, V c) { return ~(((b^a)&c)^a); } +V foo_39_2(V a, V b, V c) { return ((b^a)&c)^~a; } +V foo_39_3(V a, V b, V c) { return (~a|c)^(c&b); } +V foo_39_4(V a, V b, V c) { return ((~(b^a))|c)^b; } +V foo_39_5(V a, V b, V c) { return (~((b^a)&c))^a; } +V foo_39_6(V a, V b, V c) { return (~c|b)^(c|a); } + +V foo_40_1(V a, V b, V c) { return (b^a)&c; } + +V foo_41_1(V a, V b, V c) { return ~((((b&a)|c)^a)^b); } +V foo_41_2(V a, V b, V c) { return (((b&a)|c)^b)^~a; } +V foo_41_3(V a, V b, V c) { return (~((b&a)|c))^(b^a); } +V foo_41_4(V a, V b, V c) { return (((b&a)|c)^a)^~b; } +V foo_41_5(V a, V b, V c) { return ((b&a)|c)^(~(b^a)); } +V foo_41_6(V a, V b, V c) { return (~(((b&a)|c)^a))^b; } +V foo_41_7(V a, V b, V c) { return ((b&a)|~c)^(b|a); } +V foo_41_8(V a, V b, V c) { return (~(((b&a)|c)^b))^a; } + +V foo_42_1(V a, V b, V c) { return (~(b&a))&c; } + +V foo_43_1(V a, V b, V c) { return ~(((b^a)&(c^a))^b); } +V foo_43_2(V a, V b, V c) { return ((b^a)&c)|(~(b|a)); } +V foo_43_3(V a, V b, V c) { return ((b^a)&c)^(~(b|a)); } +V foo_43_4(V a, V b, V c) { return ((b^a)&(c^b))^~a; } +V foo_43_5(V a, V b, V c) { return ((b^a)&(c^a))^~b; } +V foo_43_6(V a, V b, V c) { return ((b^a)|(c^a))^~c; } +V foo_43_7(V a, V b, V c) { return (~((b^a)|(c^a)))^c; } +V foo_43_8(V a, V b, V c) { return ((~(b^a))|c)^(b&a); } +V foo_43_9(V a, V b, V c) { return (~((b^a)&(c^a)))^b; } +V foo_43_10(V a, V b, V c) { return (~((b^a)&c))^(b|a); } +V foo_43_11(V a, V b, V c) { return (~((b^a)&(c^b)))^a; } +V foo_43_12(V a, V b, V c) { return ((c^b)|a)^(~c|b); } +V foo_43_13(V a, V b, V c) { return ((c^a)|b)^(~c|a); } + +V foo_44_1(V a, V b, V c) { return (b^a)&(c|b); } +V foo_44_2(V a, V b, V c) { return ((c|b)&a)^b; } + +V foo_45_1(V a, V b, V c) { return (~c|b)^a; } + +V foo_46_1(V a, V b, V c) { return (b&a)^(c|b); } +V foo_46_2(V a, V b, V c) { return ((c^a)|b)^a; } + +V foo_47_1(V a, V b, V c) { return ~((~c|b)&a); } +V foo_47_2(V a, V b, V c) { return (~b&c)|~a; } + +V foo_48_1(V a, V b, V c) { return ~b&a; } + +V foo_49_1(V a, V b, V c) { return ~((~a&c)|b); } +V foo_49_2(V a, V b, V c) { return (~c|a)&~b; } + +V foo_50_1(V a, V b, V c) { return (c|a)&~b; } + +V foo_51_1(V a, V b, V c) { return ~b; } + +V foo_52_1(V a, V b, V c) { return ((c&b)|a)^b; } + +V foo_53_1(V a, V b, V c) { return ~(((c^b)&a)^c); } +V foo_53_2(V a, V b, V c) { return ((c^b)&a)^~c; } +V foo_53_3(V a, V b, V c) { return (~((c^b)&a))^c; } +V foo_53_4(V a, V b, V c) { return (~c|a)^(b&a); } +V foo_53_5(V a, V b, V c) { return ((~(c^b))|a)^b; } +V foo_53_6(V a, V b, V c) { return (~a|b)^(c|a); } + +V foo_54_1(V a, V b, V c) { return (c|a)^b; } + +V foo_55_1(V a, V b, V c) { return ~((c|a)&b); } + +V foo_56_1(V a, V b, V c) { return (b^a)&(c|a); } +V foo_56_2(V a, V b, V c) { return ((c|a)&b)^a; } + +V foo_57_1(V a, V b, V c) { return (~c|a)^b; } + +V foo_58_1(V a, V b, V c) { return (b&a)^(c|a); } +V foo_58_2(V a, V b, V c) { return ((c^b)|a)^b; } + +V foo_59_1(V a, V b, V c) { return ~((~c|a)&b); } +V foo_59_2(V a, V b, V c) { return (~a&c)|~b; } + +V foo_60_1(V a, V b, V c) { return b^a; } + +V foo_61_1(V a, V b, V c) { return (~(c|a))|(b^a); } +V foo_61_2(V a, V b, V c) { return (~(c|b))|(b^a); } +V foo_61_3(V a, V b, V c) { return ((~(c|b))|a)^b; } +V foo_61_4(V a, V b, V c) { return ((~(c|a))|b)^a; } + +V foo_62_1(V a, V b, V c) { return (~a&c)|(b^a); } +V foo_62_2(V a, V b, V c) { return (~b&c)|(b^a); } +V foo_62_3(V a, V b, V c) { return ((~b&c)|a)^b; } +V foo_62_4(V a, V b, V c) { return ((~a&c)|b)^a; } + +V foo_63_1(V a, V b, V c) { return ~(b&a); } + +V foo_64_1(V a, V b, V c) { return (~c&b)&a; } +V foo_64_2(V a, V b, V c) { return (~c&a)&b; } +V foo_64_3(V a, V b, V c) { return (b&a)&~c; } + +V foo_65_1(V a, V b, V c) { return ~((b^a)|c); } + +V foo_66_1(V a, V b, V c) { return (c^a)&(c^b); } + +V foo_67_1(V a, V b, V c) { return ~((b^a)|(c&b)); } +V foo_67_2(V a, V b, V c) { return ((c&b)|~a)^b; } +V foo_67_3(V a, V b, V c) { return ((c&a)|~b)^a; } + +V foo_68_1(V a, V b, V c) { return ~c&b; } + +V foo_69_1(V a, V b, V c) { return ~((~b&a)|c); } +V foo_69_2(V a, V b, V c) { return (~a|b)&~c; } + +V foo_70_1(V a, V b, V c) { return ((c&a)|b)^c; } + +V foo_71_1(V a, V b, V c) { return ~(((c^a)&b)^a); } +V foo_71_2(V a, V b, V c) { return ((c^a)&b)^~a; } +V foo_71_3(V a, V b, V c) { return (~a|b)^(c&b); } +V foo_71_4(V a, V b, V c) { return ((~(c^a))|b)^c; } +V foo_71_5(V a, V b, V c) { return (~((c^a)&b))^a; } +V foo_71_6(V a, V b, V c) { return (~b|c)^(b|a); } + +V foo_72_1(V a, V b, V c) { return (c^a)&b; } + +V foo_73_1(V a, V b, V c) { return ~((((c&a)|b)^a)^c); } +V foo_73_2(V a, V b, V c) { return (((c&a)|b)^c)^~a; } +V foo_73_3(V a, V b, V c) { return (~((c&a)|b))^(c^a); } +V foo_73_4(V a, V b, V c) { return (((c&a)|b)^a)^~c; } +V foo_73_5(V a, V b, V c) { return ((c&a)|b)^(~(c^a)); } +V foo_73_6(V a, V b, V c) { return (~(((c&a)|b)^a))^c; } +V foo_73_7(V a, V b, V c) { return ((c&a)|~b)^(c|a); } +V foo_73_8(V a, V b, V c) { return (~(((c&a)|b)^c))^a; } + +V foo_74_1(V a, V b, V c) { return (c^a)&(c|b); } +V foo_74_2(V a, V b, V c) { return ((c|b)&a)^c; } + +V foo_75_1(V a, V b, V c) { return (~b|c)^a; } + +V foo_76_1(V a, V b, V c) { return (~(c&a))&b; } + +V foo_77_1(V a, V b, V c) { return ~(((b^a)&(c^a))^c); } +V foo_77_2(V a, V b, V c) { return ((c^a)&b)|(~(c|a)); } +V foo_77_3(V a, V b, V c) { return ((c^a)&b)^(~(c|a)); } +V foo_77_4(V a, V b, V c) { return ((c^a)&(c^b))^~a; } +V foo_77_5(V a, V b, V c) { return ((b^a)&(c^a))^~c; } +V foo_77_6(V a, V b, V c) { return ((b^a)|(c^a))^~b; } +V foo_77_7(V a, V b, V c) { return (~((b^a)|(c^a)))^b; } +V foo_77_8(V a, V b, V c) { return ((~(c^a))|b)^(c&a); } +V foo_77_9(V a, V b, V c) { return (~((b^a)&(c^a)))^c; } +V foo_77_10(V a, V b, V c) { return (~((c^a)&b))^(c|a); } +V foo_77_11(V a, V b, V c) { return ((c^b)|a)^(~b|c); } +V foo_77_12(V a, V b, V c) { return (~((c^a)&(c^b)))^a; } +V foo_77_13(V a, V b, V c) { return ((b^a)|c)^(~b|a); } + +V foo_78_1(V a, V b, V c) { return (c&a)^(c|b); } +V foo_78_2(V a, V b, V c) { return ((b^a)|c)^a; } + +V foo_79_1(V a, V b, V c) { return ~((~b|c)&a); } +V foo_79_2(V a, V b, V c) { return (~c&b)|~a; } + +V foo_80_1(V a, V b, V c) { return ~c&a; } + +V foo_81_1(V a, V b, V c) { return ~((~a&b)|c); } +V foo_81_2(V a, V b, V c) { return (~b|a)&~c; } + +V foo_82_1(V a, V b, V c) { return ((c&b)|a)^c; } + +V foo_83_1(V a, V b, V c) { return ~(((c^b)&a)^b); } +V foo_83_2(V a, V b, V c) { return ((c^b)&a)^~b; } +V foo_83_3(V a, V b, V c) { return (~((c^b)&a))^b; } +V foo_83_4(V a, V b, V c) { return (~b|a)^(c&a); } +V foo_83_5(V a, V b, V c) { return ((~(c^b))|a)^c; } +V foo_83_6(V a, V b, V c) { return (~a|c)^(b|a); } + +V foo_84_1(V a, V b, V c) { return (b|a)&~c; } + +V foo_85_1(V a, V b, V c) { return ~c; } + +V foo_86_1(V a, V b, V c) { return (b|a)^c; } + +V foo_87_1(V a, V b, V c) { return ~((b|a)&c); } + +V foo_88_1(V a, V b, V c) { return (c^a)&(b|a); } +V foo_88_2(V a, V b, V c) { return ((b|a)&c)^a; } + +V foo_89_1(V a, V b, V c) { return (~b|a)^c; } + +V foo_90_1(V a, V b, V c) { return c^a; } + +V foo_91_1(V a, V b, V c) { return (~(b|a))|(c^a); } +V foo_91_2(V a, V b, V c) { return (~(c|b))|(c^a); } +V foo_91_3(V a, V b, V c) { return ((~(c|b))|a)^c; } +V foo_91_4(V a, V b, V c) { return ((~(b|a))|c)^a; } + +V foo_92_1(V a, V b, V c) { return (c&a)^(b|a); } +V foo_92_2(V a, V b, V c) { return ((c^b)|a)^c; } + +V foo_93_1(V a, V b, V c) { return ~((~b|a)&c); } +V foo_93_2(V a, V b, V c) { return (~a&b)|~c; } + +V foo_94_1(V a, V b, V c) { return (~a&b)|(c^a); } +V foo_94_2(V a, V b, V c) { return (~c&b)|(c^a); } +V foo_94_3(V a, V b, V c) { return ((~c&b)|a)^c; } +V foo_94_4(V a, V b, V c) { return ((~a&b)|c)^a; } + +V foo_95_1(V a, V b, V c) { return ~(c&a); } + +V foo_96_1(V a, V b, V c) { return (c^b)&a; } + +V foo_97_1(V a, V b, V c) { return ~(((c|b)^a)|(c&b)); } +V foo_97_2(V a, V b, V c) { return (~((c&b)|a))^(c^b); } +V foo_97_3(V a, V b, V c) { return (((c&b)|a)^c)^~b; } +V foo_97_4(V a, V b, V c) { return (((c&b)|a)^b)^~c; } +V foo_97_5(V a, V b, V c) { return ((c&b)|~a)^(c|b); } +V foo_97_6(V a, V b, V c) { return ((c&b)|a)^(~(c^b)); } +V foo_97_7(V a, V b, V c) { return (~(((c&b)|a)^b))^c; } +V foo_97_8(V a, V b, V c) { return (~(((c&b)|a)^c))^b; } + +V foo_98_1(V a, V b, V c) { return (c^b)&(c|a); } +V foo_98_2(V a, V b, V c) { return ((c|a)&b)^c; } + +V foo_99_1(V a, V b, V c) { return (~a|c)^b; } + +V foo_100_1(V a, V b, V c) { return (c^b)&(b|a); } +V foo_100_2(V a, V b, V c) { return ((b|a)&c)^b; } + +V foo_101_1(V a, V b, V c) { return (~a|b)^c; } + +V foo_102_1(V a, V b, V c) { return c^b; } + +V foo_103_1(V a, V b, V c) { return (~(b|a))|(c^b); } +V foo_103_2(V a, V b, V c) { return (~(c|a))|(c^b); } +V foo_103_3(V a, V b, V c) { return ((~(c|a))|b)^c; } +V foo_103_4(V a, V b, V c) { return ((~(b|a))|c)^b; } + +V foo_104_1(V a, V b, V c) { return ((b&a)^c)&(b|a); } +V foo_104_2(V a, V b, V c) { return ((c&a)^b)&(c|a); } +V foo_104_3(V a, V b, V c) { return ((c&b)^a)&(c|b); } +V foo_104_4(V a, V b, V c) { return ((c|b)&a)^(c&b); } +V foo_104_5(V a, V b, V c) { return ((c|a)&b)^(c&a); } +V foo_104_6(V a, V b, V c) { return ((b|a)&c)^(b&a); } + +V foo_105_1(V a, V b, V c) { return ~((b^a)^c); } +V foo_105_2(V a, V b, V c) { return (c^b)^~a; } +V foo_105_3(V a, V b, V c) { return (c^a)^~b; } +V foo_105_4(V a, V b, V c) { return (b^a)^~c; } +V foo_105_5(V a, V b, V c) { return (~(c^b))^a; } +V foo_105_6(V a, V b, V c) { return (~(c^a))^b; } +V foo_105_7(V a, V b, V c) { return (~(b^a))^c; } + +V foo_106_1(V a, V b, V c) { return (b&a)^c; } + +V foo_107_1(V a, V b, V c) { return ~(((b|a)&c)^(b^a)); } +V foo_107_2(V a, V b, V c) { return ((b&a)^c)|(~(b|a)); } +V foo_107_3(V a, V b, V c) { return ((c^b)&(b|a))^~a; } +V foo_107_4(V a, V b, V c) { return ((c^a)&(b|a))^~b; } +V foo_107_5(V a, V b, V c) { return (~((b|a)&c))^(b^a); } +V foo_107_6(V a, V b, V c) { return (~((c^b)&(b|a)))^a; } +V foo_107_7(V a, V b, V c) { return (~((c^a)&(b|a)))^b; } +V foo_107_8(V a, V b, V c) { return ((b|a)&c)^(~(b^a)); } +V foo_107_9(V a, V b, V c) { return ((~(b|a))|c)^(b&a); } + +V foo_108_1(V a, V b, V c) { return (c&a)^b; } + +V foo_109_1(V a, V b, V c) { return ~(((b^a)&(c|a))^c); } +V foo_109_2(V a, V b, V c) { return ((c&a)^b)|(~(c|a)); } +V foo_109_3(V a, V b, V c) { return ((c^b)&(c|a))^~a; } +V foo_109_4(V a, V b, V c) { return (~((c|a)&b))^(c^a); } +V foo_109_5(V a, V b, V c) { return ((b^a)&(c|a))^~c; } +V foo_109_6(V a, V b, V c) { return (~((c^b)&(c|a)))^a; } +V foo_109_7(V a, V b, V c) { return ((~(c|a))|b)^(c&a); } +V foo_109_8(V a, V b, V c) { return ((c|a)&b)^(~(c^a)); } +V foo_109_9(V a, V b, V c) { return (~((b^a)&(c|a)))^c; } + +V foo_110_1(V a, V b, V c) { return (~a&c)|(c^b); } +V foo_110_2(V a, V b, V c) { return (~a&b)|(c^b); } +V foo_110_3(V a, V b, V c) { return ((~b|a)&c)^b; } +V foo_110_4(V a, V b, V c) { return ((~c|a)&b)^c; } + +V foo_111_1(V a, V b, V c) { return (c^b)|~a; } + +V foo_112_1(V a, V b, V c) { return (~(c&b))&a; } + +V foo_113_1(V a, V b, V c) { return ~(((b^a)&(c^b))^c); } +V foo_113_2(V a, V b, V c) { return ((b^a)|(c^a))^~a; } +V foo_113_3(V a, V b, V c) { return ((c^b)&a)|(~(c|b)); } +V foo_113_4(V a, V b, V c) { return ((c^b)&a)^(~(c|b)); } +V foo_113_5(V a, V b, V c) { return ((b^a)&(c^b))^~c; } +V foo_113_6(V a, V b, V c) { return ((c^a)&(c^b))^~b; } +V foo_113_7(V a, V b, V c) { return (~((b^a)|(c^a)))^a; } +V foo_113_8(V a, V b, V c) { return ((~(c^b))|a)^(c&b); } +V foo_113_9(V a, V b, V c) { return (~((c^b)&a))^(c|b); } +V foo_113_10(V a, V b, V c) { return (~((b^a)&(c^b)))^c; } +V foo_113_11(V a, V b, V c) { return ((c^a)|b)^(~a|c); } +V foo_113_12(V a, V b, V c) { return (~((c^a)&(c^b)))^b; } +V foo_113_13(V a, V b, V c) { return ((b^a)|c)^(~a|b); } + +V foo_114_1(V a, V b, V c) { return (c&b)^(c|a); } +V foo_114_2(V a, V b, V c) { return ((b^a)|c)^b; } + +V foo_115_1(V a, V b, V c) { return ~((~a|c)&b); } +V foo_115_2(V a, V b, V c) { return (~c&a)|~b; } + +V foo_116_1(V a, V b, V c) { return (c&b)^(b|a); } +V foo_116_2(V a, V b, V c) { return ((c^a)|b)^c; } + +V foo_117_1(V a, V b, V c) { return ~((~a|b)&c); } +V foo_117_2(V a, V b, V c) { return (~b&a)|~c; } + +V foo_118_1(V a, V b, V c) { return (~b&a)|(c^b); } +V foo_118_2(V a, V b, V c) { return (~c&a)|(c^b); } +V foo_118_3(V a, V b, V c) { return ((~c&a)|b)^c; } +V foo_118_4(V a, V b, V c) { return ((~b&a)|c)^b; } + +V foo_119_1(V a, V b, V c) { return ~(c&b); } + +V foo_120_1(V a, V b, V c) { return (c&b)^a; } + +V foo_121_1(V a, V b, V c) { return ~(((b^a)&(c|b))^c); } +V foo_121_2(V a, V b, V c) { return ((c&b)^a)|(~(c|b)); } +V foo_121_3(V a, V b, V c) { return (~((c|b)&a))^(c^b); } +V foo_121_4(V a, V b, V c) { return ((b^a)&(c|b))^~c; } +V foo_121_5(V a, V b, V c) { return ((c^a)&(c|b))^~b; } +V foo_121_6(V a, V b, V c) { return ((~(c|b))|a)^(c&b); } +V foo_121_7(V a, V b, V c) { return ((c|b)&a)^(~(c^b)); } +V foo_121_8(V a, V b, V c) { return (~((b^a)&(c|b)))^c; } +V foo_121_9(V a, V b, V c) { return (~((c^a)&(c|b)))^b; } + +V foo_122_1(V a, V b, V c) { return (~b&c)|(c^a); } +V foo_122_2(V a, V b, V c) { return (~b&a)|(c^a); } +V foo_122_3(V a, V b, V c) { return ((~a|b)&c)^a; } +V foo_122_4(V a, V b, V c) { return ((~c|b)&a)^c; } + +V foo_123_1(V a, V b, V c) { return (c^a)|~b; } + +V foo_124_1(V a, V b, V c) { return (~c&b)|(b^a); } +V foo_124_2(V a, V b, V c) { return (~c&a)|(b^a); } +V foo_124_3(V a, V b, V c) { return ((~a|c)&b)^a; } +V foo_124_4(V a, V b, V c) { return ((~b|c)&a)^b; } + +V foo_125_1(V a, V b, V c) { return (b^a)|~c; } + +V foo_126_1(V a, V b, V c) { return (b^a)|(c^a); } +V foo_126_2(V a, V b, V c) { return (b^a)|(c^b); } +V foo_126_3(V a, V b, V c) { return (c^a)|(c^b); } + +V foo_127_1(V a, V b, V c) { return ~((c&b)&a); } + +V foo_128_1(V a, V b, V c) { return (c&b)&a; } +V foo_128_2(V a, V b, V c) { return (c&a)&b; } +V foo_128_3(V a, V b, V c) { return (b&a)&c; } + +V foo_129_1(V a, V b, V c) { return ~((b^a)|(c^a)); } + +V foo_130_1(V a, V b, V c) { return (~(b^a))&c; } + +V foo_131_1(V a, V b, V c) { return ~((~c&b)|(b^a)); } +V foo_131_2(V a, V b, V c) { return ((~a|c)&b)^~a; } +V foo_131_3(V a, V b, V c) { return ((~b|c)&a)^~b; } +V foo_131_4(V a, V b, V c) { return (~((~b|c)&a))^b; } +V foo_131_5(V a, V b, V c) { return (~((~a|c)&b))^a; } +V foo_131_6(V a, V b, V c) { return (~a|c)&(~(b^a)); } +V foo_131_7(V a, V b, V c) { return (~b|c)&(~(b^a)); } + +V foo_132_1(V a, V b, V c) { return (~(c^a))&b; } + +V foo_133_1(V a, V b, V c) { return ~((~b&c)|(c^a)); } +V foo_133_2(V a, V b, V c) { return ((~a|b)&c)^~a; } +V foo_133_3(V a, V b, V c) { return (~((~c|b)&a))^c; } +V foo_133_4(V a, V b, V c) { return ((~c|b)&a)^~c; } +V foo_133_5(V a, V b, V c) { return (~((~a|b)&c))^a; } +V foo_133_6(V a, V b, V c) { return (~(c^a))&(~a|b); } +V foo_133_7(V a, V b, V c) { return (~(c^a))&(~c|b); } + +V foo_134_1(V a, V b, V c) { return ((b^a)&(c|b))^c; } +V foo_134_2(V a, V b, V c) { return ((c^a)&(c|b))^b; } +V foo_134_3(V a, V b, V c) { return ((c|b)&a)^(c^b); } +V foo_134_4(V a, V b, V c) { return ((b^a)^c)&(c|b); } + +V foo_135_1(V a, V b, V c) { return ~((c&b)^a); } +V foo_135_2(V a, V b, V c) { return (c&b)^~a; } +V foo_135_3(V a, V b, V c) { return (~(c&b))^a; } + +V foo_136_1(V a, V b, V c) { return c&b; } + +V foo_137_1(V a, V b, V c) { return ~((~b&a)|(c^b)); } +V foo_137_2(V a, V b, V c) { return (~((~c&a)|b))^c; } +V foo_137_3(V a, V b, V c) { return ((~b&a)|c)^~b; } +V foo_137_4(V a, V b, V c) { return (~((~b&a)|c))^b; } +V foo_137_5(V a, V b, V c) { return ((~c&a)|b)^~c; } +V foo_137_6(V a, V b, V c) { return (~(c^b))&(~a|c); } +V foo_137_7(V a, V b, V c) { return (~(c^b))&(~a|b); } + +V foo_138_1(V a, V b, V c) { return (~a|b)&c; } + +V foo_139_1(V a, V b, V c) { return ~((c&b)^(b|a)); } +V foo_139_2(V a, V b, V c) { return (~(b|a))|(c&b); } +V foo_139_3(V a, V b, V c) { return (~(b|a))^(c&b); } +V foo_139_4(V a, V b, V c) { return (~((c^a)|b))^c; } +V foo_139_5(V a, V b, V c) { return ((c^a)|b)^~c; } +V foo_139_6(V a, V b, V c) { return (~(c&b))^(b|a); } +V foo_139_7(V a, V b, V c) { return ((c^a)|~b)^a; } + +V foo_140_1(V a, V b, V c) { return (~a|c)&b; } + +V foo_141_1(V a, V b, V c) { return ~((c&b)^(c|a)); } +V foo_141_2(V a, V b, V c) { return (~(c|a))|(c&b); } +V foo_141_3(V a, V b, V c) { return (~(c|a))^(c&b); } +V foo_141_4(V a, V b, V c) { return ((b^a)|c)^~b; } +V foo_141_5(V a, V b, V c) { return (~((b^a)|c))^b; } +V foo_141_6(V a, V b, V c) { return (~(c&b))^(c|a); } +V foo_141_7(V a, V b, V c) { return ((b^a)|~c)^a; } + +V foo_142_1(V a, V b, V c) { return ((b^a)&(c^b))^c; } +V foo_142_2(V a, V b, V c) { return ((c^a)&(c^b))^b; } +V foo_142_3(V a, V b, V c) { return ((c^b)&a)^(c|b); } +V foo_142_4(V a, V b, V c) { return ((b^a)|(c^a))^a; } + +V foo_143_1(V a, V b, V c) { return (c&b)|~a; } + +V foo_144_1(V a, V b, V c) { return (~(c^b))&a; } + +V foo_145_1(V a, V b, V c) { return ~((~a&c)|(c^b)); } +V foo_145_2(V a, V b, V c) { return ((~b|a)&c)^~b; } +V foo_145_3(V a, V b, V c) { return (~((~c|a)&b))^c; } +V foo_145_4(V a, V b, V c) { return ((~c|a)&b)^~c; } +V foo_145_5(V a, V b, V c) { return (~((~b|a)&c))^b; } +V foo_145_6(V a, V b, V c) { return (~(c^b))&(~b|a); } +V foo_145_7(V a, V b, V c) { return (~(c^b))&(~c|a); } + +V foo_146_1(V a, V b, V c) { return ((b^a)&(c|a))^c; } +V foo_146_2(V a, V b, V c) { return ((c|a)&b)^(c^a); } +V foo_146_3(V a, V b, V c) { return ((c^b)&(c|a))^a; } +V foo_146_4(V a, V b, V c) { return ((b^a)^c)&(c|a); } + +V foo_147_1(V a, V b, V c) { return ~((c&a)^b); } +V foo_147_2(V a, V b, V c) { return (c&a)^~b; } +V foo_147_3(V a, V b, V c) { return (~(c&a))^b; } + +V foo_148_1(V a, V b, V c) { return ((b|a)&c)^(b^a); } +V foo_148_2(V a, V b, V c) { return ((c^a)&(b|a))^b; } +V foo_148_3(V a, V b, V c) { return ((c^b)&(b|a))^a; } +V foo_148_4(V a, V b, V c) { return ((b^a)^c)&(b|a); } + +V foo_149_1(V a, V b, V c) { return ~((b&a)^c); } +V foo_149_2(V a, V b, V c) { return (~(b&a))^c; } +V foo_149_3(V a, V b, V c) { return (b&a)^~c; } + +V foo_150_1(V a, V b, V c) { return (b^a)^c; } +V foo_150_2(V a, V b, V c) { return (c^a)^b; } +V foo_150_3(V a, V b, V c) { return (c^b)^a; } + +V foo_151_1(V a, V b, V c) { return ~(((b&a)^c)&(b|a)); } +V foo_151_2(V a, V b, V c) { return ((b^a)^c)|(~(b|a)); } +V foo_151_3(V a, V b, V c) { return ((b^a)^c)|(~(c|a)); } +V foo_151_4(V a, V b, V c) { return ((b^a)^c)|(~(c|b)); } +V foo_151_5(V a, V b, V c) { return (~((c|b)&a))^(c&b); } +V foo_151_6(V a, V b, V c) { return (~((c|a)&b))^(c&a); } +V foo_151_7(V a, V b, V c) { return ((~(b|a))|c)^(b^a); } +V foo_151_8(V a, V b, V c) { return ((~(c|a))|(b^a))^c; } +V foo_151_9(V a, V b, V c) { return ((b|a)&c)^(~(b&a)); } +V foo_151_10(V a, V b, V c) { return (~((b|a)&c))^(b&a); } +V foo_151_11(V a, V b, V c) { return ((~(c|a))|b)^(c^a); } +V foo_151_12(V a, V b, V c) { return ((~(b|a))|(c^a))^b; } +V foo_151_13(V a, V b, V c) { return ((c|a)&b)^(~(c&a)); } +V foo_151_14(V a, V b, V c) { return ((~(c|b))|a)^(c^b); } +V foo_151_15(V a, V b, V c) { return ((~(b|a))|(c^b))^a; } +V foo_151_16(V a, V b, V c) { return ((c|b)&a)^(~(c&b)); } + +V foo_152_1(V a, V b, V c) { return ((c|a)&~b)^c; } +V foo_152_2(V a, V b, V c) { return ((b|a)&~c)^b; } +V foo_152_3(V a, V b, V c) { return (~(c^b))&(c|a); } +V foo_152_4(V a, V b, V c) { return (~(c^b))&(b|a); } + +V foo_153_1(V a, V b, V c) { return ~(c^b); } +V foo_153_2(V a, V b, V c) { return ~b^c; } +V foo_153_3(V a, V b, V c) { return ~c^b; } + +V foo_154_1(V a, V b, V c) { return (~b&a)^c; } + +V foo_155_1(V a, V b, V c) { return ~((c^b)&(b|a)); } +V foo_155_2(V a, V b, V c) { return ((b|a)&c)^~b; } +V foo_155_3(V a, V b, V c) { return (~((b|a)&c))^b; } + +V foo_156_1(V a, V b, V c) { return (~c&a)^b; } + +V foo_157_1(V a, V b, V c) { return ~((c^b)&(c|a)); } +V foo_157_2(V a, V b, V c) { return (~((c|a)&b))^c; } +V foo_157_3(V a, V b, V c) { return ((c|a)&b)^~c; } + +V foo_158_1(V a, V b, V c) { return ((c|b)^a)|(c&b); } +V foo_158_2(V a, V b, V c) { return (((c&b)|a)^b)^c; } +V foo_158_3(V a, V b, V c) { return (((c&b)|a)^c)^b; } +V foo_158_4(V a, V b, V c) { return ((c&b)|a)^(c^b); } +V foo_158_5(V a, V b, V c) { return ((b^a)^c)|(c&b); } + +V foo_159_1(V a, V b, V c) { return ~((c^b)&a); } + +V foo_160_1(V a, V b, V c) { return c&a; } + +V foo_161_1(V a, V b, V c) { return ~((~a&b)|(c^a)); } +V foo_161_2(V a, V b, V c) { return (~((~c&b)|a))^c; } +V foo_161_3(V a, V b, V c) { return ((~a&b)|c)^~a; } +V foo_161_4(V a, V b, V c) { return (~((~a&b)|c))^a; } +V foo_161_5(V a, V b, V c) { return ((~c&b)|a)^~c; } +V foo_161_6(V a, V b, V c) { return (~(c^a))&(~b|c); } +V foo_161_7(V a, V b, V c) { return (~(c^a))&(~b|a); } + +V foo_162_1(V a, V b, V c) { return (~b|a)&c; } + +V foo_163_1(V a, V b, V c) { return ~((c&a)^(b|a)); } +V foo_163_2(V a, V b, V c) { return (~(b|a))|(c&a); } +V foo_163_3(V a, V b, V c) { return (~(b|a))^(c&a); } +V foo_163_4(V a, V b, V c) { return (~((c^b)|a))^c; } +V foo_163_5(V a, V b, V c) { return ((c^b)|a)^~c; } +V foo_163_6(V a, V b, V c) { return (~(c&a))^(b|a); } +V foo_163_7(V a, V b, V c) { return ((c^b)|~a)^b; } + +V foo_164_1(V a, V b, V c) { return ((c|b)&~a)^c; } +V foo_164_2(V a, V b, V c) { return ((b|a)&~c)^a; } +V foo_164_3(V a, V b, V c) { return (~(c^a))&(c|b); } +V foo_164_4(V a, V b, V c) { return (~(c^a))&(b|a); } + +V foo_165_1(V a, V b, V c) { return ~(c^a); } +V foo_165_2(V a, V b, V c) { return ~a^c; } +V foo_165_3(V a, V b, V c) { return ~c^a; } + +V foo_166_1(V a, V b, V c) { return (~a&b)^c; } + +V foo_167_1(V a, V b, V c) { return ~((c^a)&(b|a)); } +V foo_167_2(V a, V b, V c) { return ((b|a)&c)^~a; } +V foo_167_3(V a, V b, V c) { return (~((b|a)&c))^a; } + +V foo_168_1(V a, V b, V c) { return (b|a)&c; } + +V foo_169_1(V a, V b, V c) { return ~((b|a)^c); } +V foo_169_2(V a, V b, V c) { return (~(b|a))^c; } +V foo_169_3(V a, V b, V c) { return (b|a)^~c; } + +V foo_170_1(V a, V b, V c) { return c; } + +V foo_171_1(V a, V b, V c) { return (~(b|a))|c; } + +V foo_172_1(V a, V b, V c) { return ((c^b)&a)^b; } + +V foo_173_1(V a, V b, V c) { return ~(((c&b)|a)^c); } +V foo_173_2(V a, V b, V c) { return (~((c&b)|a))^c; } +V foo_173_3(V a, V b, V c) { return ((c&b)|a)^~c; } +V foo_173_4(V a, V b, V c) { return (~(c^a))|(c&b); } + +V foo_174_1(V a, V b, V c) { return (~a&b)|c; } + +V foo_175_1(V a, V b, V c) { return ~a|c; } + +V foo_176_1(V a, V b, V c) { return (~b|c)&a; } + +V foo_177_1(V a, V b, V c) { return ~((c&a)^(c|b)); } +V foo_177_2(V a, V b, V c) { return ((b^a)|c)^~a; } +V foo_177_3(V a, V b, V c) { return (~(c|b))|(c&a); } +V foo_177_4(V a, V b, V c) { return (~(c|b))^(c&a); } +V foo_177_5(V a, V b, V c) { return (~((b^a)|c))^a; } +V foo_177_6(V a, V b, V c) { return (~(c&a))^(c|b); } +V foo_177_7(V a, V b, V c) { return ((b^a)|~c)^b; } + +V foo_178_1(V a, V b, V c) { return ((b^a)&(c^a))^c; } +V foo_178_2(V a, V b, V c) { return ((c^a)&(c^b))^a; } +V foo_178_3(V a, V b, V c) { return ((c^a)&b)^(c|a); } +V foo_178_4(V a, V b, V c) { return ((b^a)|(c^a))^b; } + +V foo_179_1(V a, V b, V c) { return (c&a)|~b; } + +V foo_180_1(V a, V b, V c) { return (~c&b)^a; } + +V foo_181_1(V a, V b, V c) { return ~((c^a)&(c|b)); } +V foo_181_2(V a, V b, V c) { return (~((c|b)&a))^c; } +V foo_181_3(V a, V b, V c) { return ((c|b)&a)^~c; } + +V foo_182_1(V a, V b, V c) { return (((c&a)|b)^a)^c; } +V foo_182_2(V a, V b, V c) { return ((c|a)^b)|(c&a); } +V foo_182_3(V a, V b, V c) { return (((c&a)|b)^c)^a; } +V foo_182_4(V a, V b, V c) { return ((c&a)|b)^(c^a); } +V foo_182_5(V a, V b, V c) { return ((b^a)^c)|(c&a); } + +V foo_183_1(V a, V b, V c) { return ~((c^a)&b); } + +V foo_184_1(V a, V b, V c) { return ((c^a)&b)^a; } + +V foo_185_1(V a, V b, V c) { return ~(((c&a)|b)^c); } +V foo_185_2(V a, V b, V c) { return (~((c&a)|b))^c; } +V foo_185_3(V a, V b, V c) { return ((c&a)|b)^~c; } +V foo_185_4(V a, V b, V c) { return (~(c^b))|(c&a); } + +V foo_186_1(V a, V b, V c) { return (~b&a)|c; } + +V foo_187_1(V a, V b, V c) { return ~b|c; } + +V foo_188_1(V a, V b, V c) { return (b^a)|(c&b); } +V foo_188_2(V a, V b, V c) { return (b^a)|(c&a); } + +V foo_189_1(V a, V b, V c) { return ~((c^a)&(c^b)); } +V foo_189_2(V a, V b, V c) { return (~(c^b))|(b^a); } +V foo_189_3(V a, V b, V c) { return (~(c^a))|(b^a); } + +V foo_190_1(V a, V b, V c) { return (b^a)|c; } + +V foo_191_1(V a, V b, V c) { return (~(b&a))|c; } + +V foo_192_1(V a, V b, V c) { return b&a; } + +V foo_193_1(V a, V b, V c) { return ~((~a&c)|(b^a)); } +V foo_193_2(V a, V b, V c) { return (~((~b&c)|a))^b; } +V foo_193_3(V a, V b, V c) { return ((~a&c)|b)^~a; } +V foo_193_4(V a, V b, V c) { return (~((~a&c)|b))^a; } +V foo_193_5(V a, V b, V c) { return ((~b&c)|a)^~b; } +V foo_193_6(V a, V b, V c) { return (~(b^a))&(~c|b); } +V foo_193_7(V a, V b, V c) { return (~(b^a))&(~c|a); } + +V foo_194_1(V a, V b, V c) { return ((c|b)&~a)^b; } +V foo_194_2(V a, V b, V c) { return ((c|a)&~b)^a; } +V foo_194_3(V a, V b, V c) { return (~(b^a))&(c|b); } +V foo_194_4(V a, V b, V c) { return (~(b^a))&(c|a); } + +V foo_195_1(V a, V b, V c) { return ~(b^a); } +V foo_195_2(V a, V b, V c) { return ~a^b; } +V foo_195_3(V a, V b, V c) { return ~b^a; } + +V foo_196_1(V a, V b, V c) { return (~c|a)&b; } + +V foo_197_1(V a, V b, V c) { return ~((b&a)^(c|a)); } +V foo_197_2(V a, V b, V c) { return (~(c|a))|(b&a); } +V foo_197_3(V a, V b, V c) { return (~(c|a))^(b&a); } +V foo_197_4(V a, V b, V c) { return (~((c^b)|a))^b; } +V foo_197_5(V a, V b, V c) { return ((c^b)|a)^~b; } +V foo_197_6(V a, V b, V c) { return (~(b&a))^(c|a); } +V foo_197_7(V a, V b, V c) { return ((c^b)|~a)^c; } + +V foo_198_1(V a, V b, V c) { return (~a&c)^b; } + +V foo_199_1(V a, V b, V c) { return ~((b^a)&(c|a)); } +V foo_199_2(V a, V b, V c) { return ((c|a)&b)^~a; } +V foo_199_3(V a, V b, V c) { return (~((c|a)&b))^a; } + +V foo_200_1(V a, V b, V c) { return (c|a)&b; } + +V foo_201_1(V a, V b, V c) { return ~((c|a)^b); } +V foo_201_2(V a, V b, V c) { return (~(c|a))^b; } +V foo_201_3(V a, V b, V c) { return (c|a)^~b; } + +V foo_202_1(V a, V b, V c) { return ((c^b)&a)^c; } + +V foo_203_1(V a, V b, V c) { return ~(((c&b)|a)^b); } +V foo_203_2(V a, V b, V c) { return (~((c&b)|a))^b; } +V foo_203_3(V a, V b, V c) { return ((c&b)|a)^~b; } +V foo_203_4(V a, V b, V c) { return (~(b^a))|(c&b); } + +V foo_204_1(V a, V b, V c) { return b; } + +V foo_205_1(V a, V b, V c) { return (~(c|a))|b; } + +V foo_206_1(V a, V b, V c) { return (~a&c)|b; } + +V foo_207_1(V a, V b, V c) { return ~a|b; } + +V foo_208_1(V a, V b, V c) { return (~c|b)&a; } + +V foo_209_1(V a, V b, V c) { return ~((b&a)^(c|b)); } +V foo_209_2(V a, V b, V c) { return ((c^a)|b)^~a; } +V foo_209_3(V a, V b, V c) { return (~(c|b))|(b&a); } +V foo_209_4(V a, V b, V c) { return (~(c|b))^(b&a); } +V foo_209_5(V a, V b, V c) { return (~((c^a)|b))^a; } +V foo_209_6(V a, V b, V c) { return (~(b&a))^(c|b); } +V foo_209_7(V a, V b, V c) { return ((c^a)|~b)^c; } + +V foo_210_1(V a, V b, V c) { return (~b&c)^a; } + +V foo_211_1(V a, V b, V c) { return ~((b^a)&(c|b)); } +V foo_211_2(V a, V b, V c) { return (~((c|b)&a))^b; } +V foo_211_3(V a, V b, V c) { return ((c|b)&a)^~b; } + +V foo_212_1(V a, V b, V c) { return ((b^a)&(c^a))^b; } +V foo_212_2(V a, V b, V c) { return ((b^a)&(c^b))^a; } +V foo_212_3(V a, V b, V c) { return ((b^a)&c)^(b|a); } +V foo_212_4(V a, V b, V c) { return ((b^a)|(c^a))^c; } + +V foo_213_1(V a, V b, V c) { return (b&a)|~c; } + +V foo_214_1(V a, V b, V c) { return (((b&a)|c)^a)^b; } +V foo_214_2(V a, V b, V c) { return (((b&a)|c)^b)^a; } +V foo_214_3(V a, V b, V c) { return ((b&a)|c)^(b^a); } +V foo_214_4(V a, V b, V c) { return ((b|a)^c)|(b&a); } +V foo_214_5(V a, V b, V c) { return ((b^a)^c)|(b&a); } + +V foo_215_1(V a, V b, V c) { return ~((b^a)&c); } + +V foo_216_1(V a, V b, V c) { return ((b^a)&c)^a; } + +V foo_217_1(V a, V b, V c) { return ~(((b&a)|c)^b); } +V foo_217_2(V a, V b, V c) { return (~((b&a)|c))^b; } +V foo_217_3(V a, V b, V c) { return ((b&a)|c)^~b; } +V foo_217_4(V a, V b, V c) { return (~(c^b))|(b&a); } + +V foo_218_1(V a, V b, V c) { return (c^a)|(c&b); } +V foo_218_2(V a, V b, V c) { return (c^a)|(b&a); } + +V foo_219_1(V a, V b, V c) { return ~((b^a)&(c^b)); } +V foo_219_2(V a, V b, V c) { return (~(c^b))|(c^a); } +V foo_219_3(V a, V b, V c) { return (~(b^a))|(c^a); } + +V foo_220_1(V a, V b, V c) { return (~c&a)|b; } + +V foo_221_1(V a, V b, V c) { return ~c|b; } + +V foo_222_1(V a, V b, V c) { return (c^a)|b; } + +V foo_223_1(V a, V b, V c) { return (~(c&a))|b; } + +V foo_224_1(V a, V b, V c) { return (c|b)&a; } + +V foo_225_1(V a, V b, V c) { return ~((c|b)^a); } +V foo_225_2(V a, V b, V c) { return (c|b)^~a; } +V foo_225_3(V a, V b, V c) { return (~(c|b))^a; } + +V foo_226_1(V a, V b, V c) { return ((c^a)&b)^c; } + +V foo_227_1(V a, V b, V c) { return ~(((c&a)|b)^a); } +V foo_227_2(V a, V b, V c) { return ((c&a)|b)^~a; } +V foo_227_3(V a, V b, V c) { return (~((c&a)|b))^a; } +V foo_227_4(V a, V b, V c) { return (~(b^a))|(c&a); } + +V foo_228_1(V a, V b, V c) { return ((b^a)&c)^b; } + +V foo_229_1(V a, V b, V c) { return ~(((b&a)|c)^a); } +V foo_229_2(V a, V b, V c) { return ((b&a)|c)^~a; } +V foo_229_3(V a, V b, V c) { return (~((b&a)|c))^a; } +V foo_229_4(V a, V b, V c) { return (~(c^a))|(b&a); } + +V foo_230_1(V a, V b, V c) { return (c^b)|(c&a); } +V foo_230_2(V a, V b, V c) { return (c^b)|(b&a); } + +V foo_231_1(V a, V b, V c) { return ~((b^a)&(c^a)); } +V foo_231_2(V a, V b, V c) { return (~(c^a))|(c^b); } +V foo_231_3(V a, V b, V c) { return (~(b^a))|(c^b); } + +V foo_232_1(V a, V b, V c) { return ((b^a)&(c^a))^a; } +V foo_232_2(V a, V b, V c) { return ((b^a)&(c^b))^b; } +V foo_232_3(V a, V b, V c) { return ((b^a)&c)|(b&a); } +V foo_232_4(V a, V b, V c) { return ((b^a)&c)^(b&a); } +V foo_232_5(V a, V b, V c) { return ((c^a)&(c^b))^c; } +V foo_232_6(V a, V b, V c) { return ((c^a)&b)|(c&a); } +V foo_232_7(V a, V b, V c) { return ((c^a)&b)^(c&a); } +V foo_232_8(V a, V b, V c) { return ((c^b)&a)|(c&b); } +V foo_232_9(V a, V b, V c) { return ((c^b)&a)^(c&b); } +V foo_232_10(V a, V b, V c) { return ((c|b)&a)|(c&b); } +V foo_232_11(V a, V b, V c) { return ((c|a)&b)|(c&a); } +V foo_232_12(V a, V b, V c) { return ((b|a)&c)|(b&a); } +V foo_232_13(V a, V b, V c) { return ((b&a)|c)&(b|a); } +V foo_232_14(V a, V b, V c) { return ((c&a)|b)&(c|a); } +V foo_232_15(V a, V b, V c) { return ((c&b)|a)&(c|b); } + +V foo_233_1(V a, V b, V c) { return ~(((b^a)|(c&b))^c); } +V foo_233_2(V a, V b, V c) { return ((b&a)|c)^(~(b|a)); } +V foo_233_3(V a, V b, V c) { return ((c&a)|b)^(~(c|a)); } +V foo_233_4(V a, V b, V c) { return (~((c&b)|a))^(c|b); } +V foo_233_5(V a, V b, V c) { return ((c^b)|(c&a))^~a; } +V foo_233_6(V a, V b, V c) { return ((c&b)|a)^(~(c|b)); } +V foo_233_7(V a, V b, V c) { return (~((c&a)|b))^(c|a); } +V foo_233_8(V a, V b, V c) { return (~((b&a)|c))^(b|a); } +V foo_233_9(V a, V b, V c) { return (~((c^b)|(c&a)))^a; } +V foo_233_10(V a, V b, V c) { return (~((c^a)|(c&b)))^b; } +V foo_233_11(V a, V b, V c) { return ((c^a)|(c&b))^~b; } +V foo_233_12(V a, V b, V c) { return ((b&a)|~c)^(b^a); } +V foo_233_13(V a, V b, V c) { return (~((b^a)|(c&b)))^c; } +V foo_233_14(V a, V b, V c) { return ((b^a)|(c&b))^~c; } +V foo_233_15(V a, V b, V c) { return ((c&a)|~b)^(c^a); } +V foo_233_16(V a, V b, V c) { return ((c&b)|~a)^(c^b); } +V foo_233_17(V a, V b, V c) { return (~((b^a)^c))|(c&b); } +V foo_233_18(V a, V b, V c) { return (~((b^a)^c))|(c&a); } +V foo_233_19(V a, V b, V c) { return (~((b^a)^c))|(b&a); } +V foo_233_20(V a, V b, V c) { return (~((c|b)^a))|(c&b); } +V foo_233_21(V a, V b, V c) { return (~((c|a)^b))|(c&a); } +V foo_233_22(V a, V b, V c) { return (~((b|a)^c))|(b&a); } + +V foo_234_1(V a, V b, V c) { return (b&a)|c; } + +V foo_235_1(V a, V b, V c) { return (~(b^a))|c; } + +V foo_236_1(V a, V b, V c) { return (c&a)|b; } + +V foo_237_1(V a, V b, V c) { return (~(c^a))|b; } + +V foo_238_1(V a, V b, V c) { return c|b; } + +V foo_239_1(V a, V b, V c) { return (c|b)|~a; } +V foo_239_2(V a, V b, V c) { return (~a|b)|c; } +V foo_239_3(V a, V b, V c) { return (~a|c)|b; } + +V foo_240_1(V a, V b, V c) { return a; } + +V foo_241_1(V a, V b, V c) { return (~(c|b))|a; } + +V foo_242_1(V a, V b, V c) { return (~b&c)|a; } + +V foo_243_1(V a, V b, V c) { return ~b|a; } + +V foo_244_1(V a, V b, V c) { return (~c&b)|a; } + +V foo_245_1(V a, V b, V c) { return ~c|a; } + +V foo_246_1(V a, V b, V c) { return (c^b)|a; } + +V foo_247_1(V a, V b, V c) { return (~(c&b))|a; } + +V foo_248_1(V a, V b, V c) { return (c&b)|a; } + +V foo_249_1(V a, V b, V c) { return (~(c^b))|a; } + +V foo_250_1(V a, V b, V c) { return c|a; } + +V foo_251_1(V a, V b, V c) { return (c|a)|~b; } +V foo_251_2(V a, V b, V c) { return (~b|a)|c; } +V foo_251_3(V a, V b, V c) { return (~b|c)|a; } + +V foo_252_1(V a, V b, V c) { return b|a; } + +V foo_253_1(V a, V b, V c) { return (b|a)|~c; } +V foo_253_2(V a, V b, V c) { return (~c|a)|b; } +V foo_253_3(V a, V b, V c) { return (~c|b)|a; } + +V foo_254_1(V a, V b, V c) { return (b|a)|c; } +V foo_254_2(V a, V b, V c) { return (c|a)|b; } +V foo_254_3(V a, V b, V c) { return (c|b)|a; } + +V foo_255_1(V a, V b, V c) { return (V){~0,~0,~0,~0}; } + +/* { dg-final { scan-assembler-times "vpternlogd\[ \\t\]" 673 } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpternlogd-5.c b/gcc/testsuite/gcc.target/i386/avx512f-vpternlogd-5.c new file mode 100644 index 0000000000000..85de5b02ce6da --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpternlogd-5.c @@ -0,0 +1,955 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx512f" } */ + +typedef unsigned int V __attribute__ ((__vector_size__ (64))); + +V foo_0_1(V a, V b, V c) { return (V){0,0,0,0}; } + +V foo_1_1(V a, V b, V c) { return ~((b|a)|c); } + +V foo_2_1(V a, V b, V c) { return (~(b|a))&c; } + +V foo_3_1(V a, V b, V c) { return ~(b|a); } + +V foo_4_1(V a, V b, V c) { return (~(c|a))&b; } + +V foo_5_1(V a, V b, V c) { return ~(c|a); } + +V foo_6_1(V a, V b, V c) { return (c^b)&~a; } + +V foo_7_1(V a, V b, V c) { return ~((c&b)|a); } + +V foo_8_1(V a, V b, V c) { return (~a&c)&b; } +V foo_8_2(V a, V b, V c) { return (~a&b)&c; } +V foo_8_3(V a, V b, V c) { return (c&b)&~a; } + +V foo_9_1(V a, V b, V c) { return ~((c^b)|a); } + +V foo_10_1(V a, V b, V c) { return ~a&c; } + +V foo_11_1(V a, V b, V c) { return ~((~c&b)|a); } +V foo_11_2(V a, V b, V c) { return (~b|c)&~a; } + +V foo_12_1(V a, V b, V c) { return ~a&b; } + +V foo_13_1(V a, V b, V c) { return ~((~b&c)|a); } +V foo_13_2(V a, V b, V c) { return (~c|b)&~a; } + +V foo_14_1(V a, V b, V c) { return (c|b)&~a; } + +V foo_15_1(V a, V b, V c) { return ~a; } + +V foo_16_1(V a, V b, V c) { return (~(c|b))&a; } + +V foo_17_1(V a, V b, V c) { return ~(c|b); } + +V foo_18_1(V a, V b, V c) { return (c^a)&~b; } + +V foo_19_1(V a, V b, V c) { return ~((c&a)|b); } + +V foo_20_1(V a, V b, V c) { return (b^a)&~c; } + +V foo_21_1(V a, V b, V c) { return ~((b&a)|c); } + +V foo_22_1(V a, V b, V c) { return ((b^a)|(c&b))^c; } +V foo_22_2(V a, V b, V c) { return ((c^a)|(c&b))^b; } +V foo_22_3(V a, V b, V c) { return ((c^b)|(c&a))^a; } +V foo_22_4(V a, V b, V c) { return ((b&a)|c)^(b|a); } +V foo_22_5(V a, V b, V c) { return ((c&a)|b)^(c|a); } +V foo_22_6(V a, V b, V c) { return ((c&b)|a)^(c|b); } + +V foo_23_1(V a, V b, V c) { return ~(((b^a)&(c^a))^a); } +V foo_23_2(V a, V b, V c) { return ((b^a)&(c^a))^~a; } +V foo_23_3(V a, V b, V c) { return ((b^a)&(c^b))^~b; } +V foo_23_4(V a, V b, V c) { return ((b^a)&c)^(~(b&a)); } +V foo_23_5(V a, V b, V c) { return ((c^a)&(c^b))^~c; } +V foo_23_6(V a, V b, V c) { return ((c^a)&b)^(~(c&a)); } +V foo_23_7(V a, V b, V c) { return ((c^b)&a)^(~(c&b)); } +V foo_23_8(V a, V b, V c) { return (~((c^b)&a))^(c&b); } +V foo_23_9(V a, V b, V c) { return (~((c^a)&b))^(c&a); } +V foo_23_10(V a, V b, V c) { return (~((c^a)&(c^b)))^c; } +V foo_23_11(V a, V b, V c) { return (~((b^a)&c))^(b&a); } +V foo_23_12(V a, V b, V c) { return (~((b^a)&(c^b)))^b; } +V foo_23_13(V a, V b, V c) { return (~((b^a)&(c^a)))^a; } +V foo_23_14(V a, V b, V c) { return ((~(b^a))|c)^(b|a); } +V foo_23_15(V a, V b, V c) { return ((~(c^a))|b)^(c|a); } +V foo_23_16(V a, V b, V c) { return ((~(c^b))|a)^(c|b); } + +V foo_24_1(V a, V b, V c) { return (b^a)&(c^a); } + +V foo_25_1(V a, V b, V c) { return ~((c^b)|(c&a)); } +V foo_25_2(V a, V b, V c) { return ((c&a)|~b)^c; } +V foo_25_3(V a, V b, V c) { return ((b&a)|~c)^b; } + +V foo_26_1(V a, V b, V c) { return ((b&a)|c)^a; } + +V foo_27_1(V a, V b, V c) { return ~(((b^a)&c)^b); } +V foo_27_2(V a, V b, V c) { return ((b^a)&c)^~b; } +V foo_27_3(V a, V b, V c) { return (~b|c)^(c&a); } +V foo_27_4(V a, V b, V c) { return (~((b^a)&c))^b; } +V foo_27_5(V a, V b, V c) { return ((~(b^a))|c)^a; } +V foo_27_6(V a, V b, V c) { return (~c|a)^(c|b); } + +V foo_28_1(V a, V b, V c) { return ((c&a)|b)^a; } + +V foo_29_1(V a, V b, V c) { return ~(((c^a)&b)^c); } +V foo_29_2(V a, V b, V c) { return ((c^a)&b)^~c; } +V foo_29_3(V a, V b, V c) { return (~((c^a)&b))^c; } +V foo_29_4(V a, V b, V c) { return (~c|b)^(b&a); } +V foo_29_5(V a, V b, V c) { return ((~(c^a))|b)^a; } +V foo_29_6(V a, V b, V c) { return (~b|a)^(c|b); } + +V foo_30_1(V a, V b, V c) { return (c|b)^a; } + +V foo_31_1(V a, V b, V c) { return ~((c|b)&a); } + +V foo_32_1(V a, V b, V c) { return (~b&c)&a; } +V foo_32_2(V a, V b, V c) { return (~b&a)&c; } +V foo_32_3(V a, V b, V c) { return (c&a)&~b; } + +V foo_33_1(V a, V b, V c) { return ~((c^a)|b); } + +V foo_34_1(V a, V b, V c) { return ~b&c; } + +V foo_35_1(V a, V b, V c) { return ~((~c&a)|b); } +V foo_35_2(V a, V b, V c) { return (~a|c)&~b; } + +V foo_36_1(V a, V b, V c) { return (b^a)&(c^b); } + +V foo_37_1(V a, V b, V c) { return ~((c^a)|(c&b)); } +V foo_37_2(V a, V b, V c) { return ((c&b)|~a)^c; } +V foo_37_3(V a, V b, V c) { return ((b&a)|~c)^a; } + +V foo_38_1(V a, V b, V c) { return ((b&a)|c)^b; } + +V foo_39_1(V a, V b, V c) { return ~(((b^a)&c)^a); } +V foo_39_2(V a, V b, V c) { return ((b^a)&c)^~a; } +V foo_39_3(V a, V b, V c) { return (~a|c)^(c&b); } +V foo_39_4(V a, V b, V c) { return ((~(b^a))|c)^b; } +V foo_39_5(V a, V b, V c) { return (~((b^a)&c))^a; } +V foo_39_6(V a, V b, V c) { return (~c|b)^(c|a); } + +V foo_40_1(V a, V b, V c) { return (b^a)&c; } + +V foo_41_1(V a, V b, V c) { return ~((((b&a)|c)^a)^b); } +V foo_41_2(V a, V b, V c) { return (((b&a)|c)^b)^~a; } +V foo_41_3(V a, V b, V c) { return (~((b&a)|c))^(b^a); } +V foo_41_4(V a, V b, V c) { return (((b&a)|c)^a)^~b; } +V foo_41_5(V a, V b, V c) { return ((b&a)|c)^(~(b^a)); } +V foo_41_6(V a, V b, V c) { return (~(((b&a)|c)^a))^b; } +V foo_41_7(V a, V b, V c) { return ((b&a)|~c)^(b|a); } +V foo_41_8(V a, V b, V c) { return (~(((b&a)|c)^b))^a; } + +V foo_42_1(V a, V b, V c) { return (~(b&a))&c; } + +V foo_43_1(V a, V b, V c) { return ~(((b^a)&(c^a))^b); } +V foo_43_2(V a, V b, V c) { return ((b^a)&c)|(~(b|a)); } +V foo_43_3(V a, V b, V c) { return ((b^a)&c)^(~(b|a)); } +V foo_43_4(V a, V b, V c) { return ((b^a)&(c^b))^~a; } +V foo_43_5(V a, V b, V c) { return ((b^a)&(c^a))^~b; } +V foo_43_6(V a, V b, V c) { return ((b^a)|(c^a))^~c; } +V foo_43_7(V a, V b, V c) { return (~((b^a)|(c^a)))^c; } +V foo_43_8(V a, V b, V c) { return ((~(b^a))|c)^(b&a); } +V foo_43_9(V a, V b, V c) { return (~((b^a)&(c^a)))^b; } +V foo_43_10(V a, V b, V c) { return (~((b^a)&c))^(b|a); } +V foo_43_11(V a, V b, V c) { return (~((b^a)&(c^b)))^a; } +V foo_43_12(V a, V b, V c) { return ((c^b)|a)^(~c|b); } +V foo_43_13(V a, V b, V c) { return ((c^a)|b)^(~c|a); } + +V foo_44_1(V a, V b, V c) { return (b^a)&(c|b); } +V foo_44_2(V a, V b, V c) { return ((c|b)&a)^b; } + +V foo_45_1(V a, V b, V c) { return (~c|b)^a; } + +V foo_46_1(V a, V b, V c) { return (b&a)^(c|b); } +V foo_46_2(V a, V b, V c) { return ((c^a)|b)^a; } + +V foo_47_1(V a, V b, V c) { return ~((~c|b)&a); } +V foo_47_2(V a, V b, V c) { return (~b&c)|~a; } + +V foo_48_1(V a, V b, V c) { return ~b&a; } + +V foo_49_1(V a, V b, V c) { return ~((~a&c)|b); } +V foo_49_2(V a, V b, V c) { return (~c|a)&~b; } + +V foo_50_1(V a, V b, V c) { return (c|a)&~b; } + +V foo_51_1(V a, V b, V c) { return ~b; } + +V foo_52_1(V a, V b, V c) { return ((c&b)|a)^b; } + +V foo_53_1(V a, V b, V c) { return ~(((c^b)&a)^c); } +V foo_53_2(V a, V b, V c) { return ((c^b)&a)^~c; } +V foo_53_3(V a, V b, V c) { return (~((c^b)&a))^c; } +V foo_53_4(V a, V b, V c) { return (~c|a)^(b&a); } +V foo_53_5(V a, V b, V c) { return ((~(c^b))|a)^b; } +V foo_53_6(V a, V b, V c) { return (~a|b)^(c|a); } + +V foo_54_1(V a, V b, V c) { return (c|a)^b; } + +V foo_55_1(V a, V b, V c) { return ~((c|a)&b); } + +V foo_56_1(V a, V b, V c) { return (b^a)&(c|a); } +V foo_56_2(V a, V b, V c) { return ((c|a)&b)^a; } + +V foo_57_1(V a, V b, V c) { return (~c|a)^b; } + +V foo_58_1(V a, V b, V c) { return (b&a)^(c|a); } +V foo_58_2(V a, V b, V c) { return ((c^b)|a)^b; } + +V foo_59_1(V a, V b, V c) { return ~((~c|a)&b); } +V foo_59_2(V a, V b, V c) { return (~a&c)|~b; } + +V foo_60_1(V a, V b, V c) { return b^a; } + +V foo_61_1(V a, V b, V c) { return (~(c|a))|(b^a); } +V foo_61_2(V a, V b, V c) { return (~(c|b))|(b^a); } +V foo_61_3(V a, V b, V c) { return ((~(c|b))|a)^b; } +V foo_61_4(V a, V b, V c) { return ((~(c|a))|b)^a; } + +V foo_62_1(V a, V b, V c) { return (~a&c)|(b^a); } +V foo_62_2(V a, V b, V c) { return (~b&c)|(b^a); } +V foo_62_3(V a, V b, V c) { return ((~b&c)|a)^b; } +V foo_62_4(V a, V b, V c) { return ((~a&c)|b)^a; } + +V foo_63_1(V a, V b, V c) { return ~(b&a); } + +V foo_64_1(V a, V b, V c) { return (~c&b)&a; } +V foo_64_2(V a, V b, V c) { return (~c&a)&b; } +V foo_64_3(V a, V b, V c) { return (b&a)&~c; } + +V foo_65_1(V a, V b, V c) { return ~((b^a)|c); } + +V foo_66_1(V a, V b, V c) { return (c^a)&(c^b); } + +V foo_67_1(V a, V b, V c) { return ~((b^a)|(c&b)); } +V foo_67_2(V a, V b, V c) { return ((c&b)|~a)^b; } +V foo_67_3(V a, V b, V c) { return ((c&a)|~b)^a; } + +V foo_68_1(V a, V b, V c) { return ~c&b; } + +V foo_69_1(V a, V b, V c) { return ~((~b&a)|c); } +V foo_69_2(V a, V b, V c) { return (~a|b)&~c; } + +V foo_70_1(V a, V b, V c) { return ((c&a)|b)^c; } + +V foo_71_1(V a, V b, V c) { return ~(((c^a)&b)^a); } +V foo_71_2(V a, V b, V c) { return ((c^a)&b)^~a; } +V foo_71_3(V a, V b, V c) { return (~a|b)^(c&b); } +V foo_71_4(V a, V b, V c) { return ((~(c^a))|b)^c; } +V foo_71_5(V a, V b, V c) { return (~((c^a)&b))^a; } +V foo_71_6(V a, V b, V c) { return (~b|c)^(b|a); } + +V foo_72_1(V a, V b, V c) { return (c^a)&b; } + +V foo_73_1(V a, V b, V c) { return ~((((c&a)|b)^a)^c); } +V foo_73_2(V a, V b, V c) { return (((c&a)|b)^c)^~a; } +V foo_73_3(V a, V b, V c) { return (~((c&a)|b))^(c^a); } +V foo_73_4(V a, V b, V c) { return (((c&a)|b)^a)^~c; } +V foo_73_5(V a, V b, V c) { return ((c&a)|b)^(~(c^a)); } +V foo_73_6(V a, V b, V c) { return (~(((c&a)|b)^a))^c; } +V foo_73_7(V a, V b, V c) { return ((c&a)|~b)^(c|a); } +V foo_73_8(V a, V b, V c) { return (~(((c&a)|b)^c))^a; } + +V foo_74_1(V a, V b, V c) { return (c^a)&(c|b); } +V foo_74_2(V a, V b, V c) { return ((c|b)&a)^c; } + +V foo_75_1(V a, V b, V c) { return (~b|c)^a; } + +V foo_76_1(V a, V b, V c) { return (~(c&a))&b; } + +V foo_77_1(V a, V b, V c) { return ~(((b^a)&(c^a))^c); } +V foo_77_2(V a, V b, V c) { return ((c^a)&b)|(~(c|a)); } +V foo_77_3(V a, V b, V c) { return ((c^a)&b)^(~(c|a)); } +V foo_77_4(V a, V b, V c) { return ((c^a)&(c^b))^~a; } +V foo_77_5(V a, V b, V c) { return ((b^a)&(c^a))^~c; } +V foo_77_6(V a, V b, V c) { return ((b^a)|(c^a))^~b; } +V foo_77_7(V a, V b, V c) { return (~((b^a)|(c^a)))^b; } +V foo_77_8(V a, V b, V c) { return ((~(c^a))|b)^(c&a); } +V foo_77_9(V a, V b, V c) { return (~((b^a)&(c^a)))^c; } +V foo_77_10(V a, V b, V c) { return (~((c^a)&b))^(c|a); } +V foo_77_11(V a, V b, V c) { return ((c^b)|a)^(~b|c); } +V foo_77_12(V a, V b, V c) { return (~((c^a)&(c^b)))^a; } +V foo_77_13(V a, V b, V c) { return ((b^a)|c)^(~b|a); } + +V foo_78_1(V a, V b, V c) { return (c&a)^(c|b); } +V foo_78_2(V a, V b, V c) { return ((b^a)|c)^a; } + +V foo_79_1(V a, V b, V c) { return ~((~b|c)&a); } +V foo_79_2(V a, V b, V c) { return (~c&b)|~a; } + +V foo_80_1(V a, V b, V c) { return ~c&a; } + +V foo_81_1(V a, V b, V c) { return ~((~a&b)|c); } +V foo_81_2(V a, V b, V c) { return (~b|a)&~c; } + +V foo_82_1(V a, V b, V c) { return ((c&b)|a)^c; } + +V foo_83_1(V a, V b, V c) { return ~(((c^b)&a)^b); } +V foo_83_2(V a, V b, V c) { return ((c^b)&a)^~b; } +V foo_83_3(V a, V b, V c) { return (~((c^b)&a))^b; } +V foo_83_4(V a, V b, V c) { return (~b|a)^(c&a); } +V foo_83_5(V a, V b, V c) { return ((~(c^b))|a)^c; } +V foo_83_6(V a, V b, V c) { return (~a|c)^(b|a); } + +V foo_84_1(V a, V b, V c) { return (b|a)&~c; } + +V foo_85_1(V a, V b, V c) { return ~c; } + +V foo_86_1(V a, V b, V c) { return (b|a)^c; } + +V foo_87_1(V a, V b, V c) { return ~((b|a)&c); } + +V foo_88_1(V a, V b, V c) { return (c^a)&(b|a); } +V foo_88_2(V a, V b, V c) { return ((b|a)&c)^a; } + +V foo_89_1(V a, V b, V c) { return (~b|a)^c; } + +V foo_90_1(V a, V b, V c) { return c^a; } + +V foo_91_1(V a, V b, V c) { return (~(b|a))|(c^a); } +V foo_91_2(V a, V b, V c) { return (~(c|b))|(c^a); } +V foo_91_3(V a, V b, V c) { return ((~(c|b))|a)^c; } +V foo_91_4(V a, V b, V c) { return ((~(b|a))|c)^a; } + +V foo_92_1(V a, V b, V c) { return (c&a)^(b|a); } +V foo_92_2(V a, V b, V c) { return ((c^b)|a)^c; } + +V foo_93_1(V a, V b, V c) { return ~((~b|a)&c); } +V foo_93_2(V a, V b, V c) { return (~a&b)|~c; } + +V foo_94_1(V a, V b, V c) { return (~a&b)|(c^a); } +V foo_94_2(V a, V b, V c) { return (~c&b)|(c^a); } +V foo_94_3(V a, V b, V c) { return ((~c&b)|a)^c; } +V foo_94_4(V a, V b, V c) { return ((~a&b)|c)^a; } + +V foo_95_1(V a, V b, V c) { return ~(c&a); } + +V foo_96_1(V a, V b, V c) { return (c^b)&a; } + +V foo_97_1(V a, V b, V c) { return ~(((c|b)^a)|(c&b)); } +V foo_97_2(V a, V b, V c) { return (~((c&b)|a))^(c^b); } +V foo_97_3(V a, V b, V c) { return (((c&b)|a)^c)^~b; } +V foo_97_4(V a, V b, V c) { return (((c&b)|a)^b)^~c; } +V foo_97_5(V a, V b, V c) { return ((c&b)|~a)^(c|b); } +V foo_97_6(V a, V b, V c) { return ((c&b)|a)^(~(c^b)); } +V foo_97_7(V a, V b, V c) { return (~(((c&b)|a)^b))^c; } +V foo_97_8(V a, V b, V c) { return (~(((c&b)|a)^c))^b; } + +V foo_98_1(V a, V b, V c) { return (c^b)&(c|a); } +V foo_98_2(V a, V b, V c) { return ((c|a)&b)^c; } + +V foo_99_1(V a, V b, V c) { return (~a|c)^b; } + +V foo_100_1(V a, V b, V c) { return (c^b)&(b|a); } +V foo_100_2(V a, V b, V c) { return ((b|a)&c)^b; } + +V foo_101_1(V a, V b, V c) { return (~a|b)^c; } + +V foo_102_1(V a, V b, V c) { return c^b; } + +V foo_103_1(V a, V b, V c) { return (~(b|a))|(c^b); } +V foo_103_2(V a, V b, V c) { return (~(c|a))|(c^b); } +V foo_103_3(V a, V b, V c) { return ((~(c|a))|b)^c; } +V foo_103_4(V a, V b, V c) { return ((~(b|a))|c)^b; } + +V foo_104_1(V a, V b, V c) { return ((b&a)^c)&(b|a); } +V foo_104_2(V a, V b, V c) { return ((c&a)^b)&(c|a); } +V foo_104_3(V a, V b, V c) { return ((c&b)^a)&(c|b); } +V foo_104_4(V a, V b, V c) { return ((c|b)&a)^(c&b); } +V foo_104_5(V a, V b, V c) { return ((c|a)&b)^(c&a); } +V foo_104_6(V a, V b, V c) { return ((b|a)&c)^(b&a); } + +V foo_105_1(V a, V b, V c) { return ~((b^a)^c); } +V foo_105_2(V a, V b, V c) { return (c^b)^~a; } +V foo_105_3(V a, V b, V c) { return (c^a)^~b; } +V foo_105_4(V a, V b, V c) { return (b^a)^~c; } +V foo_105_5(V a, V b, V c) { return (~(c^b))^a; } +V foo_105_6(V a, V b, V c) { return (~(c^a))^b; } +V foo_105_7(V a, V b, V c) { return (~(b^a))^c; } + +V foo_106_1(V a, V b, V c) { return (b&a)^c; } + +V foo_107_1(V a, V b, V c) { return ~(((b|a)&c)^(b^a)); } +V foo_107_2(V a, V b, V c) { return ((b&a)^c)|(~(b|a)); } +V foo_107_3(V a, V b, V c) { return ((c^b)&(b|a))^~a; } +V foo_107_4(V a, V b, V c) { return ((c^a)&(b|a))^~b; } +V foo_107_5(V a, V b, V c) { return (~((b|a)&c))^(b^a); } +V foo_107_6(V a, V b, V c) { return (~((c^b)&(b|a)))^a; } +V foo_107_7(V a, V b, V c) { return (~((c^a)&(b|a)))^b; } +V foo_107_8(V a, V b, V c) { return ((b|a)&c)^(~(b^a)); } +V foo_107_9(V a, V b, V c) { return ((~(b|a))|c)^(b&a); } + +V foo_108_1(V a, V b, V c) { return (c&a)^b; } + +V foo_109_1(V a, V b, V c) { return ~(((b^a)&(c|a))^c); } +V foo_109_2(V a, V b, V c) { return ((c&a)^b)|(~(c|a)); } +V foo_109_3(V a, V b, V c) { return ((c^b)&(c|a))^~a; } +V foo_109_4(V a, V b, V c) { return (~((c|a)&b))^(c^a); } +V foo_109_5(V a, V b, V c) { return ((b^a)&(c|a))^~c; } +V foo_109_6(V a, V b, V c) { return (~((c^b)&(c|a)))^a; } +V foo_109_7(V a, V b, V c) { return ((~(c|a))|b)^(c&a); } +V foo_109_8(V a, V b, V c) { return ((c|a)&b)^(~(c^a)); } +V foo_109_9(V a, V b, V c) { return (~((b^a)&(c|a)))^c; } + +V foo_110_1(V a, V b, V c) { return (~a&c)|(c^b); } +V foo_110_2(V a, V b, V c) { return (~a&b)|(c^b); } +V foo_110_3(V a, V b, V c) { return ((~b|a)&c)^b; } +V foo_110_4(V a, V b, V c) { return ((~c|a)&b)^c; } + +V foo_111_1(V a, V b, V c) { return (c^b)|~a; } + +V foo_112_1(V a, V b, V c) { return (~(c&b))&a; } + +V foo_113_1(V a, V b, V c) { return ~(((b^a)&(c^b))^c); } +V foo_113_2(V a, V b, V c) { return ((b^a)|(c^a))^~a; } +V foo_113_3(V a, V b, V c) { return ((c^b)&a)|(~(c|b)); } +V foo_113_4(V a, V b, V c) { return ((c^b)&a)^(~(c|b)); } +V foo_113_5(V a, V b, V c) { return ((b^a)&(c^b))^~c; } +V foo_113_6(V a, V b, V c) { return ((c^a)&(c^b))^~b; } +V foo_113_7(V a, V b, V c) { return (~((b^a)|(c^a)))^a; } +V foo_113_8(V a, V b, V c) { return ((~(c^b))|a)^(c&b); } +V foo_113_9(V a, V b, V c) { return (~((c^b)&a))^(c|b); } +V foo_113_10(V a, V b, V c) { return (~((b^a)&(c^b)))^c; } +V foo_113_11(V a, V b, V c) { return ((c^a)|b)^(~a|c); } +V foo_113_12(V a, V b, V c) { return (~((c^a)&(c^b)))^b; } +V foo_113_13(V a, V b, V c) { return ((b^a)|c)^(~a|b); } + +V foo_114_1(V a, V b, V c) { return (c&b)^(c|a); } +V foo_114_2(V a, V b, V c) { return ((b^a)|c)^b; } + +V foo_115_1(V a, V b, V c) { return ~((~a|c)&b); } +V foo_115_2(V a, V b, V c) { return (~c&a)|~b; } + +V foo_116_1(V a, V b, V c) { return (c&b)^(b|a); } +V foo_116_2(V a, V b, V c) { return ((c^a)|b)^c; } + +V foo_117_1(V a, V b, V c) { return ~((~a|b)&c); } +V foo_117_2(V a, V b, V c) { return (~b&a)|~c; } + +V foo_118_1(V a, V b, V c) { return (~b&a)|(c^b); } +V foo_118_2(V a, V b, V c) { return (~c&a)|(c^b); } +V foo_118_3(V a, V b, V c) { return ((~c&a)|b)^c; } +V foo_118_4(V a, V b, V c) { return ((~b&a)|c)^b; } + +V foo_119_1(V a, V b, V c) { return ~(c&b); } + +V foo_120_1(V a, V b, V c) { return (c&b)^a; } + +V foo_121_1(V a, V b, V c) { return ~(((b^a)&(c|b))^c); } +V foo_121_2(V a, V b, V c) { return ((c&b)^a)|(~(c|b)); } +V foo_121_3(V a, V b, V c) { return (~((c|b)&a))^(c^b); } +V foo_121_4(V a, V b, V c) { return ((b^a)&(c|b))^~c; } +V foo_121_5(V a, V b, V c) { return ((c^a)&(c|b))^~b; } +V foo_121_6(V a, V b, V c) { return ((~(c|b))|a)^(c&b); } +V foo_121_7(V a, V b, V c) { return ((c|b)&a)^(~(c^b)); } +V foo_121_8(V a, V b, V c) { return (~((b^a)&(c|b)))^c; } +V foo_121_9(V a, V b, V c) { return (~((c^a)&(c|b)))^b; } + +V foo_122_1(V a, V b, V c) { return (~b&c)|(c^a); } +V foo_122_2(V a, V b, V c) { return (~b&a)|(c^a); } +V foo_122_3(V a, V b, V c) { return ((~a|b)&c)^a; } +V foo_122_4(V a, V b, V c) { return ((~c|b)&a)^c; } + +V foo_123_1(V a, V b, V c) { return (c^a)|~b; } + +V foo_124_1(V a, V b, V c) { return (~c&b)|(b^a); } +V foo_124_2(V a, V b, V c) { return (~c&a)|(b^a); } +V foo_124_3(V a, V b, V c) { return ((~a|c)&b)^a; } +V foo_124_4(V a, V b, V c) { return ((~b|c)&a)^b; } + +V foo_125_1(V a, V b, V c) { return (b^a)|~c; } + +V foo_126_1(V a, V b, V c) { return (b^a)|(c^a); } +V foo_126_2(V a, V b, V c) { return (b^a)|(c^b); } +V foo_126_3(V a, V b, V c) { return (c^a)|(c^b); } + +V foo_127_1(V a, V b, V c) { return ~((c&b)&a); } + +V foo_128_1(V a, V b, V c) { return (c&b)&a; } +V foo_128_2(V a, V b, V c) { return (c&a)&b; } +V foo_128_3(V a, V b, V c) { return (b&a)&c; } + +V foo_129_1(V a, V b, V c) { return ~((b^a)|(c^a)); } + +V foo_130_1(V a, V b, V c) { return (~(b^a))&c; } + +V foo_131_1(V a, V b, V c) { return ~((~c&b)|(b^a)); } +V foo_131_2(V a, V b, V c) { return ((~a|c)&b)^~a; } +V foo_131_3(V a, V b, V c) { return ((~b|c)&a)^~b; } +V foo_131_4(V a, V b, V c) { return (~((~b|c)&a))^b; } +V foo_131_5(V a, V b, V c) { return (~((~a|c)&b))^a; } +V foo_131_6(V a, V b, V c) { return (~a|c)&(~(b^a)); } +V foo_131_7(V a, V b, V c) { return (~b|c)&(~(b^a)); } + +V foo_132_1(V a, V b, V c) { return (~(c^a))&b; } + +V foo_133_1(V a, V b, V c) { return ~((~b&c)|(c^a)); } +V foo_133_2(V a, V b, V c) { return ((~a|b)&c)^~a; } +V foo_133_3(V a, V b, V c) { return (~((~c|b)&a))^c; } +V foo_133_4(V a, V b, V c) { return ((~c|b)&a)^~c; } +V foo_133_5(V a, V b, V c) { return (~((~a|b)&c))^a; } +V foo_133_6(V a, V b, V c) { return (~(c^a))&(~a|b); } +V foo_133_7(V a, V b, V c) { return (~(c^a))&(~c|b); } + +V foo_134_1(V a, V b, V c) { return ((b^a)&(c|b))^c; } +V foo_134_2(V a, V b, V c) { return ((c^a)&(c|b))^b; } +V foo_134_3(V a, V b, V c) { return ((c|b)&a)^(c^b); } +V foo_134_4(V a, V b, V c) { return ((b^a)^c)&(c|b); } + +V foo_135_1(V a, V b, V c) { return ~((c&b)^a); } +V foo_135_2(V a, V b, V c) { return (c&b)^~a; } +V foo_135_3(V a, V b, V c) { return (~(c&b))^a; } + +V foo_136_1(V a, V b, V c) { return c&b; } + +V foo_137_1(V a, V b, V c) { return ~((~b&a)|(c^b)); } +V foo_137_2(V a, V b, V c) { return (~((~c&a)|b))^c; } +V foo_137_3(V a, V b, V c) { return ((~b&a)|c)^~b; } +V foo_137_4(V a, V b, V c) { return (~((~b&a)|c))^b; } +V foo_137_5(V a, V b, V c) { return ((~c&a)|b)^~c; } +V foo_137_6(V a, V b, V c) { return (~(c^b))&(~a|c); } +V foo_137_7(V a, V b, V c) { return (~(c^b))&(~a|b); } + +V foo_138_1(V a, V b, V c) { return (~a|b)&c; } + +V foo_139_1(V a, V b, V c) { return ~((c&b)^(b|a)); } +V foo_139_2(V a, V b, V c) { return (~(b|a))|(c&b); } +V foo_139_3(V a, V b, V c) { return (~(b|a))^(c&b); } +V foo_139_4(V a, V b, V c) { return (~((c^a)|b))^c; } +V foo_139_5(V a, V b, V c) { return ((c^a)|b)^~c; } +V foo_139_6(V a, V b, V c) { return (~(c&b))^(b|a); } +V foo_139_7(V a, V b, V c) { return ((c^a)|~b)^a; } + +V foo_140_1(V a, V b, V c) { return (~a|c)&b; } + +V foo_141_1(V a, V b, V c) { return ~((c&b)^(c|a)); } +V foo_141_2(V a, V b, V c) { return (~(c|a))|(c&b); } +V foo_141_3(V a, V b, V c) { return (~(c|a))^(c&b); } +V foo_141_4(V a, V b, V c) { return ((b^a)|c)^~b; } +V foo_141_5(V a, V b, V c) { return (~((b^a)|c))^b; } +V foo_141_6(V a, V b, V c) { return (~(c&b))^(c|a); } +V foo_141_7(V a, V b, V c) { return ((b^a)|~c)^a; } + +V foo_142_1(V a, V b, V c) { return ((b^a)&(c^b))^c; } +V foo_142_2(V a, V b, V c) { return ((c^a)&(c^b))^b; } +V foo_142_3(V a, V b, V c) { return ((c^b)&a)^(c|b); } +V foo_142_4(V a, V b, V c) { return ((b^a)|(c^a))^a; } + +V foo_143_1(V a, V b, V c) { return (c&b)|~a; } + +V foo_144_1(V a, V b, V c) { return (~(c^b))&a; } + +V foo_145_1(V a, V b, V c) { return ~((~a&c)|(c^b)); } +V foo_145_2(V a, V b, V c) { return ((~b|a)&c)^~b; } +V foo_145_3(V a, V b, V c) { return (~((~c|a)&b))^c; } +V foo_145_4(V a, V b, V c) { return ((~c|a)&b)^~c; } +V foo_145_5(V a, V b, V c) { return (~((~b|a)&c))^b; } +V foo_145_6(V a, V b, V c) { return (~(c^b))&(~b|a); } +V foo_145_7(V a, V b, V c) { return (~(c^b))&(~c|a); } + +V foo_146_1(V a, V b, V c) { return ((b^a)&(c|a))^c; } +V foo_146_2(V a, V b, V c) { return ((c|a)&b)^(c^a); } +V foo_146_3(V a, V b, V c) { return ((c^b)&(c|a))^a; } +V foo_146_4(V a, V b, V c) { return ((b^a)^c)&(c|a); } + +V foo_147_1(V a, V b, V c) { return ~((c&a)^b); } +V foo_147_2(V a, V b, V c) { return (c&a)^~b; } +V foo_147_3(V a, V b, V c) { return (~(c&a))^b; } + +V foo_148_1(V a, V b, V c) { return ((b|a)&c)^(b^a); } +V foo_148_2(V a, V b, V c) { return ((c^a)&(b|a))^b; } +V foo_148_3(V a, V b, V c) { return ((c^b)&(b|a))^a; } +V foo_148_4(V a, V b, V c) { return ((b^a)^c)&(b|a); } + +V foo_149_1(V a, V b, V c) { return ~((b&a)^c); } +V foo_149_2(V a, V b, V c) { return (~(b&a))^c; } +V foo_149_3(V a, V b, V c) { return (b&a)^~c; } + +V foo_150_1(V a, V b, V c) { return (b^a)^c; } +V foo_150_2(V a, V b, V c) { return (c^a)^b; } +V foo_150_3(V a, V b, V c) { return (c^b)^a; } + +V foo_151_1(V a, V b, V c) { return ~(((b&a)^c)&(b|a)); } +V foo_151_2(V a, V b, V c) { return ((b^a)^c)|(~(b|a)); } +V foo_151_3(V a, V b, V c) { return ((b^a)^c)|(~(c|a)); } +V foo_151_4(V a, V b, V c) { return ((b^a)^c)|(~(c|b)); } +V foo_151_5(V a, V b, V c) { return (~((c|b)&a))^(c&b); } +V foo_151_6(V a, V b, V c) { return (~((c|a)&b))^(c&a); } +V foo_151_7(V a, V b, V c) { return ((~(b|a))|c)^(b^a); } +V foo_151_8(V a, V b, V c) { return ((~(c|a))|(b^a))^c; } +V foo_151_9(V a, V b, V c) { return ((b|a)&c)^(~(b&a)); } +V foo_151_10(V a, V b, V c) { return (~((b|a)&c))^(b&a); } +V foo_151_11(V a, V b, V c) { return ((~(c|a))|b)^(c^a); } +V foo_151_12(V a, V b, V c) { return ((~(b|a))|(c^a))^b; } +V foo_151_13(V a, V b, V c) { return ((c|a)&b)^(~(c&a)); } +V foo_151_14(V a, V b, V c) { return ((~(c|b))|a)^(c^b); } +V foo_151_15(V a, V b, V c) { return ((~(b|a))|(c^b))^a; } +V foo_151_16(V a, V b, V c) { return ((c|b)&a)^(~(c&b)); } + +V foo_152_1(V a, V b, V c) { return ((c|a)&~b)^c; } +V foo_152_2(V a, V b, V c) { return ((b|a)&~c)^b; } +V foo_152_3(V a, V b, V c) { return (~(c^b))&(c|a); } +V foo_152_4(V a, V b, V c) { return (~(c^b))&(b|a); } + +V foo_153_1(V a, V b, V c) { return ~(c^b); } +V foo_153_2(V a, V b, V c) { return ~b^c; } +V foo_153_3(V a, V b, V c) { return ~c^b; } + +V foo_154_1(V a, V b, V c) { return (~b&a)^c; } + +V foo_155_1(V a, V b, V c) { return ~((c^b)&(b|a)); } +V foo_155_2(V a, V b, V c) { return ((b|a)&c)^~b; } +V foo_155_3(V a, V b, V c) { return (~((b|a)&c))^b; } + +V foo_156_1(V a, V b, V c) { return (~c&a)^b; } + +V foo_157_1(V a, V b, V c) { return ~((c^b)&(c|a)); } +V foo_157_2(V a, V b, V c) { return (~((c|a)&b))^c; } +V foo_157_3(V a, V b, V c) { return ((c|a)&b)^~c; } + +V foo_158_1(V a, V b, V c) { return ((c|b)^a)|(c&b); } +V foo_158_2(V a, V b, V c) { return (((c&b)|a)^b)^c; } +V foo_158_3(V a, V b, V c) { return (((c&b)|a)^c)^b; } +V foo_158_4(V a, V b, V c) { return ((c&b)|a)^(c^b); } +V foo_158_5(V a, V b, V c) { return ((b^a)^c)|(c&b); } + +V foo_159_1(V a, V b, V c) { return ~((c^b)&a); } + +V foo_160_1(V a, V b, V c) { return c&a; } + +V foo_161_1(V a, V b, V c) { return ~((~a&b)|(c^a)); } +V foo_161_2(V a, V b, V c) { return (~((~c&b)|a))^c; } +V foo_161_3(V a, V b, V c) { return ((~a&b)|c)^~a; } +V foo_161_4(V a, V b, V c) { return (~((~a&b)|c))^a; } +V foo_161_5(V a, V b, V c) { return ((~c&b)|a)^~c; } +V foo_161_6(V a, V b, V c) { return (~(c^a))&(~b|c); } +V foo_161_7(V a, V b, V c) { return (~(c^a))&(~b|a); } + +V foo_162_1(V a, V b, V c) { return (~b|a)&c; } + +V foo_163_1(V a, V b, V c) { return ~((c&a)^(b|a)); } +V foo_163_2(V a, V b, V c) { return (~(b|a))|(c&a); } +V foo_163_3(V a, V b, V c) { return (~(b|a))^(c&a); } +V foo_163_4(V a, V b, V c) { return (~((c^b)|a))^c; } +V foo_163_5(V a, V b, V c) { return ((c^b)|a)^~c; } +V foo_163_6(V a, V b, V c) { return (~(c&a))^(b|a); } +V foo_163_7(V a, V b, V c) { return ((c^b)|~a)^b; } + +V foo_164_1(V a, V b, V c) { return ((c|b)&~a)^c; } +V foo_164_2(V a, V b, V c) { return ((b|a)&~c)^a; } +V foo_164_3(V a, V b, V c) { return (~(c^a))&(c|b); } +V foo_164_4(V a, V b, V c) { return (~(c^a))&(b|a); } + +V foo_165_1(V a, V b, V c) { return ~(c^a); } +V foo_165_2(V a, V b, V c) { return ~a^c; } +V foo_165_3(V a, V b, V c) { return ~c^a; } + +V foo_166_1(V a, V b, V c) { return (~a&b)^c; } + +V foo_167_1(V a, V b, V c) { return ~((c^a)&(b|a)); } +V foo_167_2(V a, V b, V c) { return ((b|a)&c)^~a; } +V foo_167_3(V a, V b, V c) { return (~((b|a)&c))^a; } + +V foo_168_1(V a, V b, V c) { return (b|a)&c; } + +V foo_169_1(V a, V b, V c) { return ~((b|a)^c); } +V foo_169_2(V a, V b, V c) { return (~(b|a))^c; } +V foo_169_3(V a, V b, V c) { return (b|a)^~c; } + +V foo_170_1(V a, V b, V c) { return c; } + +V foo_171_1(V a, V b, V c) { return (~(b|a))|c; } + +V foo_172_1(V a, V b, V c) { return ((c^b)&a)^b; } + +V foo_173_1(V a, V b, V c) { return ~(((c&b)|a)^c); } +V foo_173_2(V a, V b, V c) { return (~((c&b)|a))^c; } +V foo_173_3(V a, V b, V c) { return ((c&b)|a)^~c; } +V foo_173_4(V a, V b, V c) { return (~(c^a))|(c&b); } + +V foo_174_1(V a, V b, V c) { return (~a&b)|c; } + +V foo_175_1(V a, V b, V c) { return ~a|c; } + +V foo_176_1(V a, V b, V c) { return (~b|c)&a; } + +V foo_177_1(V a, V b, V c) { return ~((c&a)^(c|b)); } +V foo_177_2(V a, V b, V c) { return ((b^a)|c)^~a; } +V foo_177_3(V a, V b, V c) { return (~(c|b))|(c&a); } +V foo_177_4(V a, V b, V c) { return (~(c|b))^(c&a); } +V foo_177_5(V a, V b, V c) { return (~((b^a)|c))^a; } +V foo_177_6(V a, V b, V c) { return (~(c&a))^(c|b); } +V foo_177_7(V a, V b, V c) { return ((b^a)|~c)^b; } + +V foo_178_1(V a, V b, V c) { return ((b^a)&(c^a))^c; } +V foo_178_2(V a, V b, V c) { return ((c^a)&(c^b))^a; } +V foo_178_3(V a, V b, V c) { return ((c^a)&b)^(c|a); } +V foo_178_4(V a, V b, V c) { return ((b^a)|(c^a))^b; } + +V foo_179_1(V a, V b, V c) { return (c&a)|~b; } + +V foo_180_1(V a, V b, V c) { return (~c&b)^a; } + +V foo_181_1(V a, V b, V c) { return ~((c^a)&(c|b)); } +V foo_181_2(V a, V b, V c) { return (~((c|b)&a))^c; } +V foo_181_3(V a, V b, V c) { return ((c|b)&a)^~c; } + +V foo_182_1(V a, V b, V c) { return (((c&a)|b)^a)^c; } +V foo_182_2(V a, V b, V c) { return ((c|a)^b)|(c&a); } +V foo_182_3(V a, V b, V c) { return (((c&a)|b)^c)^a; } +V foo_182_4(V a, V b, V c) { return ((c&a)|b)^(c^a); } +V foo_182_5(V a, V b, V c) { return ((b^a)^c)|(c&a); } + +V foo_183_1(V a, V b, V c) { return ~((c^a)&b); } + +V foo_184_1(V a, V b, V c) { return ((c^a)&b)^a; } + +V foo_185_1(V a, V b, V c) { return ~(((c&a)|b)^c); } +V foo_185_2(V a, V b, V c) { return (~((c&a)|b))^c; } +V foo_185_3(V a, V b, V c) { return ((c&a)|b)^~c; } +V foo_185_4(V a, V b, V c) { return (~(c^b))|(c&a); } + +V foo_186_1(V a, V b, V c) { return (~b&a)|c; } + +V foo_187_1(V a, V b, V c) { return ~b|c; } + +V foo_188_1(V a, V b, V c) { return (b^a)|(c&b); } +V foo_188_2(V a, V b, V c) { return (b^a)|(c&a); } + +V foo_189_1(V a, V b, V c) { return ~((c^a)&(c^b)); } +V foo_189_2(V a, V b, V c) { return (~(c^b))|(b^a); } +V foo_189_3(V a, V b, V c) { return (~(c^a))|(b^a); } + +V foo_190_1(V a, V b, V c) { return (b^a)|c; } + +V foo_191_1(V a, V b, V c) { return (~(b&a))|c; } + +V foo_192_1(V a, V b, V c) { return b&a; } + +V foo_193_1(V a, V b, V c) { return ~((~a&c)|(b^a)); } +V foo_193_2(V a, V b, V c) { return (~((~b&c)|a))^b; } +V foo_193_3(V a, V b, V c) { return ((~a&c)|b)^~a; } +V foo_193_4(V a, V b, V c) { return (~((~a&c)|b))^a; } +V foo_193_5(V a, V b, V c) { return ((~b&c)|a)^~b; } +V foo_193_6(V a, V b, V c) { return (~(b^a))&(~c|b); } +V foo_193_7(V a, V b, V c) { return (~(b^a))&(~c|a); } + +V foo_194_1(V a, V b, V c) { return ((c|b)&~a)^b; } +V foo_194_2(V a, V b, V c) { return ((c|a)&~b)^a; } +V foo_194_3(V a, V b, V c) { return (~(b^a))&(c|b); } +V foo_194_4(V a, V b, V c) { return (~(b^a))&(c|a); } + +V foo_195_1(V a, V b, V c) { return ~(b^a); } +V foo_195_2(V a, V b, V c) { return ~a^b; } +V foo_195_3(V a, V b, V c) { return ~b^a; } + +V foo_196_1(V a, V b, V c) { return (~c|a)&b; } + +V foo_197_1(V a, V b, V c) { return ~((b&a)^(c|a)); } +V foo_197_2(V a, V b, V c) { return (~(c|a))|(b&a); } +V foo_197_3(V a, V b, V c) { return (~(c|a))^(b&a); } +V foo_197_4(V a, V b, V c) { return (~((c^b)|a))^b; } +V foo_197_5(V a, V b, V c) { return ((c^b)|a)^~b; } +V foo_197_6(V a, V b, V c) { return (~(b&a))^(c|a); } +V foo_197_7(V a, V b, V c) { return ((c^b)|~a)^c; } + +V foo_198_1(V a, V b, V c) { return (~a&c)^b; } + +V foo_199_1(V a, V b, V c) { return ~((b^a)&(c|a)); } +V foo_199_2(V a, V b, V c) { return ((c|a)&b)^~a; } +V foo_199_3(V a, V b, V c) { return (~((c|a)&b))^a; } + +V foo_200_1(V a, V b, V c) { return (c|a)&b; } + +V foo_201_1(V a, V b, V c) { return ~((c|a)^b); } +V foo_201_2(V a, V b, V c) { return (~(c|a))^b; } +V foo_201_3(V a, V b, V c) { return (c|a)^~b; } + +V foo_202_1(V a, V b, V c) { return ((c^b)&a)^c; } + +V foo_203_1(V a, V b, V c) { return ~(((c&b)|a)^b); } +V foo_203_2(V a, V b, V c) { return (~((c&b)|a))^b; } +V foo_203_3(V a, V b, V c) { return ((c&b)|a)^~b; } +V foo_203_4(V a, V b, V c) { return (~(b^a))|(c&b); } + +V foo_204_1(V a, V b, V c) { return b; } + +V foo_205_1(V a, V b, V c) { return (~(c|a))|b; } + +V foo_206_1(V a, V b, V c) { return (~a&c)|b; } + +V foo_207_1(V a, V b, V c) { return ~a|b; } + +V foo_208_1(V a, V b, V c) { return (~c|b)&a; } + +V foo_209_1(V a, V b, V c) { return ~((b&a)^(c|b)); } +V foo_209_2(V a, V b, V c) { return ((c^a)|b)^~a; } +V foo_209_3(V a, V b, V c) { return (~(c|b))|(b&a); } +V foo_209_4(V a, V b, V c) { return (~(c|b))^(b&a); } +V foo_209_5(V a, V b, V c) { return (~((c^a)|b))^a; } +V foo_209_6(V a, V b, V c) { return (~(b&a))^(c|b); } +V foo_209_7(V a, V b, V c) { return ((c^a)|~b)^c; } + +V foo_210_1(V a, V b, V c) { return (~b&c)^a; } + +V foo_211_1(V a, V b, V c) { return ~((b^a)&(c|b)); } +V foo_211_2(V a, V b, V c) { return (~((c|b)&a))^b; } +V foo_211_3(V a, V b, V c) { return ((c|b)&a)^~b; } + +V foo_212_1(V a, V b, V c) { return ((b^a)&(c^a))^b; } +V foo_212_2(V a, V b, V c) { return ((b^a)&(c^b))^a; } +V foo_212_3(V a, V b, V c) { return ((b^a)&c)^(b|a); } +V foo_212_4(V a, V b, V c) { return ((b^a)|(c^a))^c; } + +V foo_213_1(V a, V b, V c) { return (b&a)|~c; } + +V foo_214_1(V a, V b, V c) { return (((b&a)|c)^a)^b; } +V foo_214_2(V a, V b, V c) { return (((b&a)|c)^b)^a; } +V foo_214_3(V a, V b, V c) { return ((b&a)|c)^(b^a); } +V foo_214_4(V a, V b, V c) { return ((b|a)^c)|(b&a); } +V foo_214_5(V a, V b, V c) { return ((b^a)^c)|(b&a); } + +V foo_215_1(V a, V b, V c) { return ~((b^a)&c); } + +V foo_216_1(V a, V b, V c) { return ((b^a)&c)^a; } + +V foo_217_1(V a, V b, V c) { return ~(((b&a)|c)^b); } +V foo_217_2(V a, V b, V c) { return (~((b&a)|c))^b; } +V foo_217_3(V a, V b, V c) { return ((b&a)|c)^~b; } +V foo_217_4(V a, V b, V c) { return (~(c^b))|(b&a); } + +V foo_218_1(V a, V b, V c) { return (c^a)|(c&b); } +V foo_218_2(V a, V b, V c) { return (c^a)|(b&a); } + +V foo_219_1(V a, V b, V c) { return ~((b^a)&(c^b)); } +V foo_219_2(V a, V b, V c) { return (~(c^b))|(c^a); } +V foo_219_3(V a, V b, V c) { return (~(b^a))|(c^a); } + +V foo_220_1(V a, V b, V c) { return (~c&a)|b; } + +V foo_221_1(V a, V b, V c) { return ~c|b; } + +V foo_222_1(V a, V b, V c) { return (c^a)|b; } + +V foo_223_1(V a, V b, V c) { return (~(c&a))|b; } + +V foo_224_1(V a, V b, V c) { return (c|b)&a; } + +V foo_225_1(V a, V b, V c) { return ~((c|b)^a); } +V foo_225_2(V a, V b, V c) { return (c|b)^~a; } +V foo_225_3(V a, V b, V c) { return (~(c|b))^a; } + +V foo_226_1(V a, V b, V c) { return ((c^a)&b)^c; } + +V foo_227_1(V a, V b, V c) { return ~(((c&a)|b)^a); } +V foo_227_2(V a, V b, V c) { return ((c&a)|b)^~a; } +V foo_227_3(V a, V b, V c) { return (~((c&a)|b))^a; } +V foo_227_4(V a, V b, V c) { return (~(b^a))|(c&a); } + +V foo_228_1(V a, V b, V c) { return ((b^a)&c)^b; } + +V foo_229_1(V a, V b, V c) { return ~(((b&a)|c)^a); } +V foo_229_2(V a, V b, V c) { return ((b&a)|c)^~a; } +V foo_229_3(V a, V b, V c) { return (~((b&a)|c))^a; } +V foo_229_4(V a, V b, V c) { return (~(c^a))|(b&a); } + +V foo_230_1(V a, V b, V c) { return (c^b)|(c&a); } +V foo_230_2(V a, V b, V c) { return (c^b)|(b&a); } + +V foo_231_1(V a, V b, V c) { return ~((b^a)&(c^a)); } +V foo_231_2(V a, V b, V c) { return (~(c^a))|(c^b); } +V foo_231_3(V a, V b, V c) { return (~(b^a))|(c^b); } + +V foo_232_1(V a, V b, V c) { return ((b^a)&(c^a))^a; } +V foo_232_2(V a, V b, V c) { return ((b^a)&(c^b))^b; } +V foo_232_3(V a, V b, V c) { return ((b^a)&c)|(b&a); } +V foo_232_4(V a, V b, V c) { return ((b^a)&c)^(b&a); } +V foo_232_5(V a, V b, V c) { return ((c^a)&(c^b))^c; } +V foo_232_6(V a, V b, V c) { return ((c^a)&b)|(c&a); } +V foo_232_7(V a, V b, V c) { return ((c^a)&b)^(c&a); } +V foo_232_8(V a, V b, V c) { return ((c^b)&a)|(c&b); } +V foo_232_9(V a, V b, V c) { return ((c^b)&a)^(c&b); } +V foo_232_10(V a, V b, V c) { return ((c|b)&a)|(c&b); } +V foo_232_11(V a, V b, V c) { return ((c|a)&b)|(c&a); } +V foo_232_12(V a, V b, V c) { return ((b|a)&c)|(b&a); } +V foo_232_13(V a, V b, V c) { return ((b&a)|c)&(b|a); } +V foo_232_14(V a, V b, V c) { return ((c&a)|b)&(c|a); } +V foo_232_15(V a, V b, V c) { return ((c&b)|a)&(c|b); } + +V foo_233_1(V a, V b, V c) { return ~(((b^a)|(c&b))^c); } +V foo_233_2(V a, V b, V c) { return ((b&a)|c)^(~(b|a)); } +V foo_233_3(V a, V b, V c) { return ((c&a)|b)^(~(c|a)); } +V foo_233_4(V a, V b, V c) { return (~((c&b)|a))^(c|b); } +V foo_233_5(V a, V b, V c) { return ((c^b)|(c&a))^~a; } +V foo_233_6(V a, V b, V c) { return ((c&b)|a)^(~(c|b)); } +V foo_233_7(V a, V b, V c) { return (~((c&a)|b))^(c|a); } +V foo_233_8(V a, V b, V c) { return (~((b&a)|c))^(b|a); } +V foo_233_9(V a, V b, V c) { return (~((c^b)|(c&a)))^a; } +V foo_233_10(V a, V b, V c) { return (~((c^a)|(c&b)))^b; } +V foo_233_11(V a, V b, V c) { return ((c^a)|(c&b))^~b; } +V foo_233_12(V a, V b, V c) { return ((b&a)|~c)^(b^a); } +V foo_233_13(V a, V b, V c) { return (~((b^a)|(c&b)))^c; } +V foo_233_14(V a, V b, V c) { return ((b^a)|(c&b))^~c; } +V foo_233_15(V a, V b, V c) { return ((c&a)|~b)^(c^a); } +V foo_233_16(V a, V b, V c) { return ((c&b)|~a)^(c^b); } +V foo_233_17(V a, V b, V c) { return (~((b^a)^c))|(c&b); } +V foo_233_18(V a, V b, V c) { return (~((b^a)^c))|(c&a); } +V foo_233_19(V a, V b, V c) { return (~((b^a)^c))|(b&a); } +V foo_233_20(V a, V b, V c) { return (~((c|b)^a))|(c&b); } +V foo_233_21(V a, V b, V c) { return (~((c|a)^b))|(c&a); } +V foo_233_22(V a, V b, V c) { return (~((b|a)^c))|(b&a); } + +V foo_234_1(V a, V b, V c) { return (b&a)|c; } + +V foo_235_1(V a, V b, V c) { return (~(b^a))|c; } + +V foo_236_1(V a, V b, V c) { return (c&a)|b; } + +V foo_237_1(V a, V b, V c) { return (~(c^a))|b; } + +V foo_238_1(V a, V b, V c) { return c|b; } + +V foo_239_1(V a, V b, V c) { return (c|b)|~a; } +V foo_239_2(V a, V b, V c) { return (~a|b)|c; } +V foo_239_3(V a, V b, V c) { return (~a|c)|b; } + +V foo_240_1(V a, V b, V c) { return a; } + +V foo_241_1(V a, V b, V c) { return (~(c|b))|a; } + +V foo_242_1(V a, V b, V c) { return (~b&c)|a; } + +V foo_243_1(V a, V b, V c) { return ~b|a; } + +V foo_244_1(V a, V b, V c) { return (~c&b)|a; } + +V foo_245_1(V a, V b, V c) { return ~c|a; } + +V foo_246_1(V a, V b, V c) { return (c^b)|a; } + +V foo_247_1(V a, V b, V c) { return (~(c&b))|a; } + +V foo_248_1(V a, V b, V c) { return (c&b)|a; } + +V foo_249_1(V a, V b, V c) { return (~(c^b))|a; } + +V foo_250_1(V a, V b, V c) { return c|a; } + +V foo_251_1(V a, V b, V c) { return (c|a)|~b; } +V foo_251_2(V a, V b, V c) { return (~b|a)|c; } +V foo_251_3(V a, V b, V c) { return (~b|c)|a; } + +V foo_252_1(V a, V b, V c) { return b|a; } + +V foo_253_1(V a, V b, V c) { return (b|a)|~c; } +V foo_253_2(V a, V b, V c) { return (~c|a)|b; } +V foo_253_3(V a, V b, V c) { return (~c|b)|a; } + +V foo_254_1(V a, V b, V c) { return (b|a)|c; } +V foo_254_2(V a, V b, V c) { return (c|a)|b; } +V foo_254_3(V a, V b, V c) { return (c|b)|a; } + +V foo_255_1(V a, V b, V c) { return (V){~0,~0,~0,~0}; } + +/* { dg-final { scan-assembler-times "vpternlogd\[ \\t\]" 673 } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpternlogq-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vpternlogq-1.c index ef302464765af..8e5d22fd4d62b 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpternlogq-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpternlogq-1.c @@ -1,6 +1,5 @@ /* { dg-do compile } */ /* { dg-options "-mavx512f -O2" } */ -/* { dg-final { scan-assembler-times "vpternlogq\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ /* { dg-final { scan-assembler-times "vpternlogq\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ /* { dg-final { scan-assembler-times "vpternlogq\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpternlogq-3.c b/gcc/testsuite/gcc.target/i386/avx512f-vpternlogq-3.c new file mode 100644 index 0000000000000..fb943da19568e --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpternlogq-3.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=x86-64-v4" } */ + +#include +__m256i +foo2 (__m256i** a, __m256i b) +{ + return ~(**a); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512vl-vpternlogd-1.c b/gcc/testsuite/gcc.target/i386/avx512vl-vpternlogd-1.c index 045a266664c5c..dd53563d39d1e 100644 --- a/gcc/testsuite/gcc.target/i386/avx512vl-vpternlogd-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512vl-vpternlogd-1.c @@ -1,7 +1,5 @@ /* { dg-do compile } */ /* { dg-options "-mavx512vl -O2" } */ -/* { dg-final { scan-assembler-times "vpternlogd\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ -/* { dg-final { scan-assembler-times "vpternlogd\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ /* { dg-final { scan-assembler-times "vpternlogd\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ /* { dg-final { scan-assembler-times "vpternlogd\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ /* { dg-final { scan-assembler-times "vpternlogd\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx512vl-vpternlogq-1.c b/gcc/testsuite/gcc.target/i386/avx512vl-vpternlogq-1.c index 3a6707c8f65d3..31fec3e0dde9d 100644 --- a/gcc/testsuite/gcc.target/i386/avx512vl-vpternlogq-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512vl-vpternlogq-1.c @@ -1,7 +1,5 @@ /* { dg-do compile } */ /* { dg-options "-mavx512vl -O2" } */ -/* { dg-final { scan-assembler-times "vpternlogq\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ -/* { dg-final { scan-assembler-times "vpternlogq\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ /* { dg-final { scan-assembler-times "vpternlogq\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ /* { dg-final { scan-assembler-times "vpternlogq\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ /* { dg-final { scan-assembler-times "vpternlogq\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr100711-4.c b/gcc/testsuite/gcc.target/i386/pr100711-4.c index 3ca524f8a8a61..26152d63f8ca3 100644 --- a/gcc/testsuite/gcc.target/i386/pr100711-4.c +++ b/gcc/testsuite/gcc.target/i386/pr100711-4.c @@ -37,6 +37,6 @@ v8di foo_v8di (long long a, v8di b) return (__extension__ (v8di) {~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a}) | b; } -/* { dg-final { scan-assembler-times "vpternlog\[dq\]\[ \\t\]+\\\$0xbb" 4 { target { ! ia32 } } } } */ -/* { dg-final { scan-assembler-times "vpternlog\[dq\]\[ \\t\]+\\\$0xbb" 2 { target { ia32 } } } } */ +/* { dg-final { scan-assembler-times "vpternlog\[dq\]\[ \\t\]+\\\$207" 4 { target { ! ia32 } } } } */ +/* { dg-final { scan-assembler-times "vpternlogd\[ \\t\]+\\\$207" 2 { target { ia32 } } } } */ /* { dg-final { scan-assembler-times "vpternlog\[dq\]\[ \\t\]+\\\$0xdd" 2 { target { ia32 } } } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr100711-5.c b/gcc/testsuite/gcc.target/i386/pr100711-5.c index 161fbfcc2562e..820bed88ed5b1 100644 --- a/gcc/testsuite/gcc.target/i386/pr100711-5.c +++ b/gcc/testsuite/gcc.target/i386/pr100711-5.c @@ -37,4 +37,7 @@ v8di foo_v8di (long long a, v8di b) return (__extension__ (v8di) {~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a}) ^ b; } -/* { dg-final { scan-assembler-times "vpternlog\[dq\]\[ \\t\]+\\\$0x99" 4 } } */ +/* { dg-final { scan-assembler-times "vpternlog\[dq\]\[ \\t\]+\\\$195" 4 { target { ! ia32 } } } } */ +/* { dg-final { scan-assembler-times "vpternlogd\[ \\t\]+\\\$195" 2 { target { ia32 } } } } */ +/* { dg-final { scan-assembler-times "vpternlog\[dq\]\[ \\t\]+\\\$0x99" 2 { target { ia32 } } } } */ + diff --git a/gcc/testsuite/gcc.target/i386/pr112600-a.c b/gcc/testsuite/gcc.target/i386/pr112600-a.c new file mode 100644 index 0000000000000..2b0848604512e --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr112600-a.c @@ -0,0 +1,32 @@ +/* PR target/112600 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-times "sbb|cmov" 4 } } */ + +unsigned char +add_sat_char (unsigned char x, unsigned char y) +{ + unsigned char z; + return __builtin_add_overflow(x, y, &z) ? -1u : z; +} + +unsigned short +add_sat_short (unsigned short x, unsigned short y) +{ + unsigned short z; + return __builtin_add_overflow(x, y, &z) ? -1u : z; +} + +unsigned int +add_sat_int (unsigned int x, unsigned int y) +{ + unsigned int z; + return __builtin_add_overflow(x, y, &z) ? -1u : z; +} + +unsigned long +add_sat_long (unsigned long x, unsigned long y) +{ + unsigned long z; + return __builtin_add_overflow(x, y, &z) ? -1ul : z; +} diff --git a/gcc/testsuite/gcc.target/i386/pr112600-b.c b/gcc/testsuite/gcc.target/i386/pr112600-b.c new file mode 100644 index 0000000000000..ac4e26423b6fb --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr112600-b.c @@ -0,0 +1,40 @@ +/* PR target/112600 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-times "sbb|cmov" 4 } } */ + +unsigned char +sub_sat_char (unsigned char x, unsigned char y) +{ + unsigned char res; + res = x - y; + res &= -(x >= y); + return res; +} + +unsigned short +sub_sat_short (unsigned short x, unsigned short y) +{ + unsigned short res; + res = x - y; + res &= -(x >= y); + return res; +} + +unsigned int +sub_sat_int (unsigned int x, unsigned int y) +{ + unsigned int res; + res = x - y; + res &= -(x >= y); + return res; +} + +unsigned long +sub_sat_long (unsigned long x, unsigned long y) +{ + unsigned long res; + res = x - y; + res &= -(x >= y); + return res; +} diff --git a/gcc/testsuite/gcc.target/i386/pr115161-1.c b/gcc/testsuite/gcc.target/i386/pr115161-1.c new file mode 100644 index 0000000000000..8c45199bd5880 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr115161-1.c @@ -0,0 +1,65 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512f" } */ +/* { dg-require-effective-target avx512f } */ + +#define AVX512F + +#include "avx512f-helper.h" +#include "limits.h" + +#define SRC_SIZE ((AVX512F_LEN) / 64) +#include "avx512f-mask-type.h" +#define DST_SIZE ((AVX512F_LEN_HALF) / 32) + +static void +CALC (double *s, unsigned *r) +{ + int i; + + for (i = 0; i < SRC_SIZE; i++) + { + if (s[i] > UINT_MAX) + r[i] = UINT_MAX; + else + r[i] = (unsigned) s[i]; + } + for (i = SRC_SIZE; i < DST_SIZE; i++) + r[i] = 0; +} + +void +TEST (void) +{ + UNION_TYPE (AVX512F_LEN, d) s; + UNION_TYPE (AVX512F_LEN_HALF, i_ud) res1, res2, res3; + MASK_TYPE mask = MASK_VALUE; + unsigned res_ref[DST_SIZE] = { 0 }; + int i; + + for (i = 0; i < SRC_SIZE; i++) + { + s.a[i] = 123.456 * (i + 2000); + } + + s.a[0] = (float) UINT_MAX + 123.456; + + for (i = 0; i < DST_SIZE; i++) + res2.a[i] = DEFAULT_VALUE; + + res1.x = INTRINSIC (_cvttpd_epu32) (s.x); + res2.x = INTRINSIC (_mask_cvttpd_epu32) (res2.x, mask, s.x); + res3.x = INTRINSIC (_maskz_cvttpd_epu32) (mask, s.x); + + CALC (s.a, res_ref); + + if (UNION_CHECK (AVX512F_LEN_HALF, i_ud) (res1, res_ref)) + abort (); + + MASK_MERGE (i_ud) (res_ref, mask, SRC_SIZE); + if (UNION_CHECK (AVX512F_LEN_HALF, i_ud) (res2, res_ref)) + abort (); + + MASK_ZERO (i_ud) (res_ref, mask, SRC_SIZE); + if (UNION_CHECK (AVX512F_LEN_HALF, i_ud) (res3, res_ref)) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/pr115384.c b/gcc/testsuite/gcc.target/i386/pr115384.c new file mode 100644 index 0000000000000..31dd6f4eb18ac --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr115384.c @@ -0,0 +1,12 @@ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O" } */ + +typedef __attribute__((__vector_size__(sizeof(__int128)))) __int128 W; + +W w; + +void +foo() +{ + w = w >> 4 & 18446744073709551600llu; +} diff --git a/gcc/testsuite/gcc.target/i386/pr115397.c b/gcc/testsuite/gcc.target/i386/pr115397.c new file mode 100644 index 0000000000000..27835782b78d8 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr115397.c @@ -0,0 +1,17 @@ +/* { dg-do compile { target ia32 } } */ +/* { dg-options "-fPIC -mavx512f -O3" } */ + +int LONG_divide_AVX512F_dimensions_0; +void npy_set_floatstatus_overflow(); +void LONG_divide_AVX512F() { + long *src; + int raise_err = 0; + for (; LONG_divide_AVX512F_dimensions_0; + --LONG_divide_AVX512F_dimensions_0, ++src) { + long a = *src; + if (a) + raise_err = 1; + } + if (raise_err) + npy_set_floatstatus_overflow(); +} diff --git a/gcc/testsuite/gcc.target/i386/pr115407.c b/gcc/testsuite/gcc.target/i386/pr115407.c new file mode 100644 index 0000000000000..b6cb7a6d9ea9c --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr115407.c @@ -0,0 +1,9 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2 -mcmodel=large -mavx512bw" } */ +__attribute__((__vector_size__(64))) char v; + +void foo() { + v = v | v << 7; +} + +/* { dg-final { scan-assembler "vpternlog.*1to16" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr115452.c b/gcc/testsuite/gcc.target/i386/pr115452.c new file mode 100644 index 0000000000000..6c7935feb9f82 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr115452.c @@ -0,0 +1,4 @@ +/* { dg-do compile { target ia32 } } */ +/* { dg-options "-O2 -msse2 -mstv -mno-bmi -mno-stackrealign -fdump-rtl-stv2" } */ + +#include "pr70322-2.c" diff --git a/gcc/testsuite/gcc.target/i386/pr115508.c b/gcc/testsuite/gcc.target/i386/pr115508.c new file mode 100644 index 0000000000000..a97b2007f7a9c --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr115508.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=znver1" } */ + +typedef long long v4di __attribute__((vector_size(4 * sizeof (long long)))); + +v4di vec_var; +extern long long array1[]; +long long g(void) +{ + int total_error_4 = 0; + total_error_4 += array1 [0] + array1 [1] + array1 [2] + array1 [3]; + v4di t = vec_var; + long long iorvar = t [1] | t [0] | t [2] | t [3]; + return iorvar + total_error_4; +} diff --git a/gcc/testsuite/gcc.target/i386/sse-cmp-1.c b/gcc/testsuite/gcc.target/i386/sse-cmp-1.c new file mode 100644 index 0000000000000..eff90d4790e11 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/sse-cmp-1.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -msse2" } */ +/* { dg-final { scan-assembler-times "cmpsd" 1 } } */ +/* { dg-final { scan-assembler-times "cmpss" 1 } } */ +/* { dg-final { scan-assembler-times "cmppd" 1 } } */ +/* { dg-final { scan-assembler-times "cmpps" 1 } } */ + +#include + +__m128 a1, a2, a3, a4, a5, a6; +__m128d d1, d2, d3, d4, d5, d6; + +void +test (void) +{ + d1 = _mm_cmp_sd (d2, d3, 1); + a1 = _mm_cmp_ss (a2, a3, 2); + d1 = _mm_cmp_pd (d2, d3, 3); + a1 = _mm_cmp_ps (a2, a3, 4); +} diff --git a/gcc/testsuite/gcc.target/i386/sse-cmp-2.c b/gcc/testsuite/gcc.target/i386/sse-cmp-2.c new file mode 100644 index 0000000000000..77c05c484b6cf --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/sse-cmp-2.c @@ -0,0 +1,96 @@ +/* { dg-do run } */ +/* { dg-require-effective-target sse2 } */ +/* { dg-require-effective-target c99_runtime } */ +/* { dg-options "-O2 -msse2 -std=c99" } */ + +#include "sse2-check.h" +#include "emmintrin.h" +#include + +double sd1[2]={2134.3343,6678.346}; +double sd2[2]={41124.234,6678.346}; + +float ss1[4]={2134.3343,6678.346,453.345635,54646.464356}; +float ss2[4]={41124.234,6678.346,8653.65635,856.43576}; + +union +{ + double x[2]; + long long a[2]; +}dd, ed; + +union +{ + float x[4]; + int a[4]; +}ds, es; + +#define CHECK(INTSIZE, SIZE, NUNITS, SUFFIX) \ +void check##SUFFIX(unsigned imm, char *id) \ +{ \ + if(checkV##INTSIZE(d##SIZE.a, e##SIZE.a, NUNITS)){ \ + printf("mm_cmp_" #SUFFIX "(%s: 0x%x) FAILED\n", id, imm);\ + abort(); \ + } \ +} + +CHECK (l, d, 2, pd) +CHECK (i, s, 4, ps) +CHECK (l, d, 2, sd) +CHECK (i, s, 4, ss) + +#define CMP(imm, rel, SIZE, NUNITS, SUFFIX) \ + for (i = 0; i < NUNITS; i++) e##SIZE.a[i] = rel ? -1 : 0; \ + source##SIZE##1 = _mm_loadu_p##SIZE(s##SIZE##1); \ + source##SIZE##2 = _mm_loadu_p##SIZE(s##SIZE##2); \ + dest##SIZE = _mm_cmp_##SUFFIX(source##SIZE##1, source##SIZE##2, imm); \ + _mm_storeu_p##SIZE(d##SIZE.x, dest##SIZE); \ + check##SUFFIX(imm, "" #imm ""); + +static void +sse2_test () +{ + __m128d sourced1, sourced2, destd; + __m128 sources1, sources2, dests; + int i; + + CMP(_CMP_EQ_OQ, !isunordered(sd1[i], sd2[i]) && sd1[i] == sd2[i], d, 2, pd); + CMP(_CMP_LT_OS, !isunordered(sd1[i], sd2[i]) && sd1[i] < sd2[i], d, 2, pd); + CMP(_CMP_LE_OS, !isunordered(sd1[i], sd2[i]) && sd1[i] <= sd2[i], d, 2, pd); + CMP(_CMP_UNORD_Q, isunordered(sd1[i], sd2[i]), d, 2, pd); + CMP(_CMP_NEQ_UQ, isunordered(sd1[i], sd2[i]) || sd1[i] != sd2[i], d, 2, pd); + CMP(_CMP_NLT_US, isunordered(sd1[i], sd2[i]) || sd1[i] >= sd2[i], d, 2, pd); + CMP(_CMP_NLE_US, isunordered(sd1[i], sd2[i]) || sd1[i] > sd2[i], d, 2, pd); + CMP(_CMP_ORD_Q, !isunordered(sd1[i], sd2[i]), d, 2, pd); + + CMP(_CMP_EQ_OQ, !isunordered(ss1[i], ss2[i]) && ss1[i] == ss2[i], s, 4, ps); + CMP(_CMP_LT_OS, !isunordered(ss1[i], ss2[i]) && ss1[i] < ss2[i], s, 4, ps); + CMP(_CMP_LE_OS, !isunordered(ss1[i], ss2[i]) && ss1[i] <= ss2[i], s, 4, ps); + CMP(_CMP_UNORD_Q, isunordered(ss1[i], ss2[i]), s, 4, ps); + CMP(_CMP_NEQ_UQ, isunordered(ss1[i], ss2[i]) || ss1[i] != ss2[i], s, 4, ps); + CMP(_CMP_NLT_US, isunordered(ss1[i], ss2[i]) || ss1[i] >= ss2[i], s, 4, ps); + CMP(_CMP_NLE_US, isunordered(ss1[i], ss2[i]) || ss1[i] > ss2[i], s, 4, ps); + CMP(_CMP_ORD_Q, !isunordered(ss1[i], ss2[i]), s, 4, ps); + + dd.x[1] = ed.x[1] = sd1[1]; + + CMP(_CMP_EQ_OQ, !isunordered(sd1[0], sd2[0]) && sd1[0] == sd2[0], d, 1, sd); + CMP(_CMP_LT_OS, !isunordered(sd1[0], sd2[0]) && sd1[0] < sd2[0], d, 1, sd); + CMP(_CMP_LE_OS, !isunordered(sd1[0], sd2[0]) && sd1[0] <= sd2[0], d, 1, sd); + CMP(_CMP_UNORD_Q, isunordered(sd1[0], sd2[0]), d, 1, sd); + CMP(_CMP_NEQ_UQ, isunordered(sd1[0], sd2[0]) || sd1[0] != sd2[0], d, 1, sd); + CMP(_CMP_NLT_US, isunordered(sd1[0], sd2[0]) || sd1[0] >= sd2[0], d, 1, sd); + CMP(_CMP_NLE_US, isunordered(sd1[0], sd2[0]) || sd1[0] > sd2[0], d, 1, sd); + CMP(_CMP_ORD_Q, !isunordered(sd1[0], sd2[0]), d, 1, sd); + + for(i = 1; i < 4; i++) ds.x[i] = es.x[i] = ss1[i]; + + CMP(_CMP_EQ_OQ, !isunordered(ss1[0], ss2[0]) && ss1[0] == ss2[0], s, 1, ss); + CMP(_CMP_LT_OS, !isunordered(ss1[0], ss2[0]) && ss1[0] < ss2[0], s, 1, ss); + CMP(_CMP_LE_OS, !isunordered(ss1[0], ss2[0]) && ss1[0] <= ss2[0], s, 1, ss); + CMP(_CMP_UNORD_Q, isunordered(ss1[0], ss2[0]), s, 1, ss); + CMP(_CMP_NEQ_UQ, isunordered(ss1[0], ss2[0]) || ss1[0] != ss2[0], s, 1, ss); + CMP(_CMP_NLT_US, isunordered(ss1[0], ss2[0]) || ss1[0] >= ss2[0], s, 1, ss); + CMP(_CMP_NLE_US, isunordered(ss1[0], ss2[0]) || ss1[0] > ss2[0], s, 1, ss); + CMP(_CMP_ORD_Q, !isunordered(ss1[0], ss2[0]), s, 1, ss); +} diff --git a/gcc/testsuite/gcc.target/i386/sse-cmp-error.c b/gcc/testsuite/gcc.target/i386/sse-cmp-error.c new file mode 100644 index 0000000000000..fdf2463895384 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/sse-cmp-error.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -msse2 -mno-avx" } */ + +#include + +volatile __m128 a1, a2, a3; +volatile __m128d d1, d2, d3; + +void +test (void) +{ + d1 = _mm_cmp_sd (d2, d3, 8); /* { dg-error "'__builtin_ia32_cmpsd' needs isa option -mavx" } */ + a1 = _mm_cmp_ss (a2, a3, 8); /* { dg-error "'__builtin_ia32_cmpss' needs isa option -mavx" } */ + d1 = _mm_cmp_pd (d2, d3, 8); /* { dg-error "'__builtin_ia32_cmppd' needs isa option -mavx" } */ + a1 = _mm_cmp_ps (a2, a3, 8); /* { dg-error "'__builtin_ia32_cmpps' needs isa option -mavx" } */ +} diff --git a/gcc/testsuite/gcc.target/i386/sse2-v1ti-vne.c b/gcc/testsuite/gcc.target/i386/sse2-v1ti-vne.c index 767b0e4b3ac63..2394cff39f2c3 100644 --- a/gcc/testsuite/gcc.target/i386/sse2-v1ti-vne.c +++ b/gcc/testsuite/gcc.target/i386/sse2-v1ti-vne.c @@ -1,5 +1,5 @@ /* { dg-do compile { target int128 } } */ -/* { dg-options "-O2 -msse2" } */ +/* { dg-options "-O2 -msse2 -mno-avx512f" } */ typedef unsigned __int128 uv1ti __attribute__ ((__vector_size__ (16))); typedef unsigned long long uv2di __attribute__ ((__vector_size__ (16))); typedef unsigned int uv4si __attribute__ ((__vector_size__ (16))); diff --git a/gcc/testsuite/gcc.target/i386/vect-pr115385.c b/gcc/testsuite/gcc.target/i386/vect-pr115385.c new file mode 100644 index 0000000000000..a6be9ce4e5434 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/vect-pr115385.c @@ -0,0 +1,53 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -msse4.1 -mno-avx -fdump-tree-vect-details" } */ + +void __attribute__((noipa)) foo(unsigned char * __restrict x, + unsigned char *y, int n) +{ + for (int i = 0; i < n; ++i) + { + x[16*i+0] = y[3*i+0]; + x[16*i+1] = y[3*i+1]; + x[16*i+2] = y[3*i+2]; + x[16*i+3] = y[3*i+0]; + x[16*i+4] = y[3*i+1]; + x[16*i+5] = y[3*i+2]; + x[16*i+6] = y[3*i+0]; + x[16*i+7] = y[3*i+1]; + x[16*i+8] = y[3*i+2]; + x[16*i+9] = y[3*i+0]; + x[16*i+10] = y[3*i+1]; + x[16*i+11] = y[3*i+2]; + x[16*i+12] = y[3*i+0]; + x[16*i+13] = y[3*i+1]; + x[16*i+14] = y[3*i+2]; + x[16*i+15] = y[3*i+0]; + } +} + +void __attribute__((noipa)) bar(unsigned char * __restrict x, + unsigned char *y, int n) +{ + for (int i = 0; i < n; ++i) + { + x[16*i+0] = y[5*i+0]; + x[16*i+1] = y[5*i+1]; + x[16*i+2] = y[5*i+2]; + x[16*i+3] = y[5*i+3]; + x[16*i+4] = y[5*i+4]; + x[16*i+5] = y[5*i+0]; + x[16*i+6] = y[5*i+1]; + x[16*i+7] = y[5*i+2]; + x[16*i+8] = y[5*i+3]; + x[16*i+9] = y[5*i+4]; + x[16*i+10] = y[5*i+0]; + x[16*i+11] = y[5*i+1]; + x[16*i+12] = y[5*i+2]; + x[16*i+13] = y[5*i+3]; + x[16*i+14] = y[5*i+4]; + x[16*i+15] = y[5*i+0]; + } +} + +/* { dg-final { scan-tree-dump "Data access with gaps requires scalar epilogue loop" "vect"} } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect"} } */ diff --git a/gcc/testsuite/gcc.target/i386/vect-strided-1.c b/gcc/testsuite/gcc.target/i386/vect-strided-1.c new file mode 100644 index 0000000000000..db4a06711f11f --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/vect-strided-1.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -msse2 -mno-avx" } */ + +void foo (int * __restrict a, int *b, int s) +{ + for (int i = 0; i < 1024; ++i) + { + a[8*i+0] = b[s*i+0]; + a[8*i+1] = b[s*i+1]; + a[8*i+2] = b[s*i+2]; + a[8*i+3] = b[s*i+3]; + a[8*i+4] = b[s*i+4]; + a[8*i+5] = b[s*i+5]; + a[8*i+6] = b[s*i+4]; + a[8*i+7] = b[s*i+5]; + } +} + +/* Three two-element loads, two four-element stores. On ia32 we elide + a permute and perform a redundant load. */ +/* { dg-final { scan-assembler-times "movq" 2 } } */ +/* { dg-final { scan-assembler-times "movhps" 2 { target ia32 } } } */ +/* { dg-final { scan-assembler-times "movhps" 1 { target { ! ia32 } } } } */ +/* { dg-final { scan-assembler-times "movups" 2 } } */ diff --git a/gcc/testsuite/gcc.target/i386/vect-strided-2.c b/gcc/testsuite/gcc.target/i386/vect-strided-2.c new file mode 100644 index 0000000000000..6fd64e28cf0d3 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/vect-strided-2.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -msse2 -mno-avx" } */ + +void foo (int * __restrict a, int *b, int s) +{ + for (int i = 0; i < 1024; ++i) + { + a[4*i+0] = b[s*i+0]; + a[4*i+1] = b[s*i+1]; + a[4*i+2] = b[s*i+0]; + a[4*i+3] = b[s*i+1]; + } +} + +/* One two-element load, one four-element store. */ +/* { dg-final { scan-assembler-times "movq" 1 } } */ +/* { dg-final { scan-assembler-times "movups" 1 } } */ diff --git a/gcc/testsuite/gcc.target/i386/vect-strided-3.c b/gcc/testsuite/gcc.target/i386/vect-strided-3.c new file mode 100644 index 0000000000000..f9c54a6f71599 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/vect-strided-3.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -msse2 -mno-sse4 -fno-tree-slp-vectorize" } */ + +void foo (int * __restrict a, int *b, int s) +{ + if (s >= 6) + for (int i = 0; i < 1024; ++i) + { + a[s*i+0] = b[4*i+0]; + a[s*i+1] = b[4*i+1]; + a[s*i+2] = b[4*i+2]; + a[s*i+3] = b[4*i+3]; + a[s*i+4] = b[4*i+0]; + a[s*i+5] = b[4*i+1]; + } +} + +/* While the vectorizer generates 6 uint64 stores. */ +/* { dg-final { scan-assembler-times "movq" 4 } } */ +/* { dg-final { scan-assembler-times "movhps" 2 } } */ diff --git a/gcc/testsuite/gcc.target/i386/vect-strided-4.c b/gcc/testsuite/gcc.target/i386/vect-strided-4.c new file mode 100644 index 0000000000000..dd922926a2a7b --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/vect-strided-4.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -msse4.2 -mno-avx -fno-tree-slp-vectorize" } */ + +void foo (int * __restrict a, int * __restrict b, int *c, int s) +{ + if (s >= 2) + for (int i = 0; i < 1024; ++i) + { + a[s*i+0] = c[4*i+0]; + a[s*i+1] = c[4*i+1]; + b[s*i+0] = c[4*i+2]; + b[s*i+1] = c[4*i+3]; + } +} + +/* Vectorization factor two, two two-element stores to a using movq + and two two-element stores to b via pextrq/movhps of the high part. */ +/* { dg-final { scan-assembler-times "movq" 2 } } */ +/* { dg-final { scan-assembler-times "pextrq" 2 { target { ! ia32 } } } } */ +/* { dg-final { scan-assembler-times "movhps" 2 { target { ia32 } } } } */ diff --git a/gcc/testsuite/gcc.target/i386/vpermt2-special-bf16-shufflue.c b/gcc/testsuite/gcc.target/i386/vpermt2-special-bf16-shufflue.c new file mode 100755 index 0000000000000..5c65f2a988470 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/vpermt2-special-bf16-shufflue.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx512bf16 -mavx512vl" } */ +/* { dg-final { scan-assembler-not "vpermi2b" } } */ +/* { dg-final { scan-assembler-times "vcvtne2ps2bf16" 3 } } */ + +typedef __bf16 v8bf __attribute__((vector_size(16))); +typedef __bf16 v16bf __attribute__((vector_size(32))); +typedef __bf16 v32bf __attribute__((vector_size(64))); + +v8bf foo0(v8bf a, v8bf b) +{ + return __builtin_shufflevector(a, b, 1, 3, 5, 7, 9, 11, 13, 15); +} + +v16bf foo1(v16bf a, v16bf b) +{ + return __builtin_shufflevector(a, b, 1, 3, 5, 7, 9, 11, 13, 15, + 17, 19, 21, 23, 25, 27, 29, 31); +} + +v32bf foo2(v32bf a, v32bf b) +{ + return __builtin_shufflevector(a, b, 1, 3, 5, 7, 9, 11, 13, 15, + 17, 19, 21, 23, 25, 27, 29, 31, + 33, 35, 37, 39, 41, 43, 45, 47, + 49, 51, 53, 55, 57, 59, 61, 63); +} diff --git a/gcc/testsuite/gcc.target/loongarch/bstrins-1.c b/gcc/testsuite/gcc.target/loongarch/bstrins-1.c new file mode 100644 index 0000000000000..7cb3a95232225 --- /dev/null +++ b/gcc/testsuite/gcc.target/loongarch/bstrins-1.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=loongarch64 -mabi=lp64d" } */ +/* { dg-final { scan-assembler "bstrins\\.d\t\\\$r4,\\\$r0,4,0" } } */ + +long +x (long a) +{ + return a & -32; +} diff --git a/gcc/testsuite/gcc.target/loongarch/bstrins-2.c b/gcc/testsuite/gcc.target/loongarch/bstrins-2.c new file mode 100644 index 0000000000000..9777f502e5afe --- /dev/null +++ b/gcc/testsuite/gcc.target/loongarch/bstrins-2.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=loongarch64 -mabi=lp64d" } */ +/* { dg-final { scan-assembler "bstrins\\.d\t\\\$r\[0-9\]+,\\\$r0,4,0" } } */ + +struct aligned_buffer { + _Alignas(32) char x[1024]; +}; + +extern int f(char *); +int g(void) +{ + struct aligned_buffer buf; + return f(buf.x); +} diff --git a/gcc/testsuite/gcc.target/mips/r10k-cache-barrier-13.c b/gcc/testsuite/gcc.target/mips/r10k-cache-barrier-13.c index ee9c84b59882a..ac005fb08b343 100644 --- a/gcc/testsuite/gcc.target/mips/r10k-cache-barrier-13.c +++ b/gcc/testsuite/gcc.target/mips/r10k-cache-barrier-13.c @@ -1,4 +1,4 @@ -/* { dg-options "-mr10k-cache-barrier=store" } */ +/* { dg-options "-mr10k-cache-barrier=store -mno-branch-likely" } */ /* Test that indirect calls are protected. */ diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-1-runnable.c b/gcc/testsuite/gcc.target/powerpc/altivec-1-runnable.c index da8ebbc30bae4..4e32860a169b6 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-1-runnable.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-1-runnable.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-1.c b/gcc/testsuite/gcc.target/powerpc/altivec-1.c index b1809fe2c9c24..002fb83feab61 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-1.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-1.c @@ -1,7 +1,7 @@ /* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */ /* { dg-do compile { target { powerpc*-*-* && { ! vmx_hw } } } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Program to test PowerPC AltiVec instructions. */ diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-10.c b/gcc/testsuite/gcc.target/powerpc/altivec-10.c index f532eebbfab0b..50e84dba669b7 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-10.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-10.c @@ -1,7 +1,7 @@ /* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */ /* { dg-do compile { target { powerpc*-*-* && { ! vmx_hw } } } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -mabi=altivec -fno-inline" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-11.c b/gcc/testsuite/gcc.target/powerpc/altivec-11.c index 7e3510c3160a9..217ec5342fe24 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-11.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-11.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-O2 -maltivec -mno-vsx -mabi=altivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* { dg-final { scan-assembler-not "lvx" } } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-12.c b/gcc/testsuite/gcc.target/powerpc/altivec-12.c index 1f3175f979397..2d7863d0b2648 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-12.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-12.c @@ -1,7 +1,7 @@ /* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */ /* { dg-do compile { target { powerpc*-*-* && { ! vmx_hw } } } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Program to test PowerPC AltiVec instructions. */ diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-13.c b/gcc/testsuite/gcc.target/powerpc/altivec-13.c index 31ff5092014de..6f472b05e5382 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-13.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-13.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Author: Ziemowit Laski */ diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-14.c b/gcc/testsuite/gcc.target/powerpc/altivec-14.c index 55acb0b35ce52..452539c1b3e1f 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-14.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-14.c @@ -1,6 +1,6 @@ /* { dg-do compile { target { powerpc*-*-* && ilp32 } } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -mno-vsx" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-15.c b/gcc/testsuite/gcc.target/powerpc/altivec-15.c index 4e48cb7652f77..d4997a69ba668 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-15.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-15.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-16.c b/gcc/testsuite/gcc.target/powerpc/altivec-16.c index c36c3914b1ad3..bc9a7db25c7d6 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-16.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-16.c @@ -1,8 +1,8 @@ /* This is a compile-only test for interaction of "-maltivec" and "-save-temps". */ /* Author: Ziemowit Laski . */ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-save-temps -maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-17.c b/gcc/testsuite/gcc.target/powerpc/altivec-17.c index 8b1083268624a..7fb604b0f4a8b 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-17.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-17.c @@ -2,8 +2,8 @@ typedef name as a vector type specifier. */ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -mabi=altivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ typedef unsigned int ui; typedef signed char sc; diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-18.c b/gcc/testsuite/gcc.target/powerpc/altivec-18.c index 5d9885820492a..f7a85436329c4 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-18.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-18.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -mabi=altivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* { dg-final { scan-assembler "vcmpgtub" { target *-*-linux* } } } */ /* { dg-final { scan-assembler "vcmpgtsb" { target *-*-darwin* } } } */ /* { dg-final { scan-assembler "vcmpgtsh" } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-19.c b/gcc/testsuite/gcc.target/powerpc/altivec-19.c index 80f305a54472b..35c233b6d8c25 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-19.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-19.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* { dg-final { scan-assembler "dst" } } */ void foo ( char* image ) diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-2-runnable.c b/gcc/testsuite/gcc.target/powerpc/altivec-2-runnable.c index 6975ea57e6575..17b23eb9d50ec 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-2-runnable.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-2-runnable.c @@ -1,4 +1,4 @@ -/* { dg-do compile { target powerpc*-*-* } } */ +/* { dg-do run } */ /* { dg-options "-mvsx" } */ /* { dg-additional-options "-mdejagnu-cpu=power8" { target { ! has_arch_pwr8 } } } */ /* { dg-require-effective-target powerpc_vsx } */ diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-2.c b/gcc/testsuite/gcc.target/powerpc/altivec-2.c index a91ac0c43ac60..9e73d36e23716 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-2.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-2.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Program to test the vector_size attribute. This needs to run on a target that has vectors, so use AltiVec. */ diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-20.c b/gcc/testsuite/gcc.target/powerpc/altivec-20.c index 4af0bf9d88f4a..8e5ccd6f5da91 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-20.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-20.c @@ -1,5 +1,7 @@ -/* { dg-do compile { target powerpc_altivec_ok } } */ +/* { dg-do compile } */ /* { dg-options "-maltivec -mdejagnu-cpu=G5 -O2 -Wno-deprecated" } */ +/* { dg-require-effective-target powerpc_altivec } */ + #include diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-21.c b/gcc/testsuite/gcc.target/powerpc/altivec-21.c index 906aa197abf71..580f989e50ebb 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-21.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-21.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-22.c b/gcc/testsuite/gcc.target/powerpc/altivec-22.c index 3c07309e43f62..95b26d7dc1058 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-22.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-22.c @@ -1,6 +1,6 @@ /* { dg-do compile { target { powerpc*-*-* && ilp32 } } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-O3 -maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* { dg-final { scan-assembler-not "mfcr" } } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-23.c b/gcc/testsuite/gcc.target/powerpc/altivec-23.c index 3b039f73b0b6b..1e6f6d27ea4af 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-23.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-23.c @@ -3,8 +3,8 @@ initializer of automatic ones. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -mabi=altivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-24.c b/gcc/testsuite/gcc.target/powerpc/altivec-24.c index d296fe2465804..5c6db80e487bc 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-24.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-24.c @@ -1,7 +1,7 @@ /* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */ /* { dg-do compile { target { powerpc*-*-* && { ! vmx_hw } } } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-25.c b/gcc/testsuite/gcc.target/powerpc/altivec-25.c index a3bd0fd001dc7..d60a7c1cf3647 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-25.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-25.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2 -Wall" } */ +/* { dg-require-effective-target powerpc_altivec } */ #define vector __attribute__((__vector_size__(16) )) diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-26.c b/gcc/testsuite/gcc.target/powerpc/altivec-26.c index 689d13a514f0e..96369ec54aeaa 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-26.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-26.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* A compiler implementing context-sensitive keywords must define this preprocessor macro so that altivec.h does not provide the vector, diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-27.c b/gcc/testsuite/gcc.target/powerpc/altivec-27.c index 7db0ea01f2c74..51f4fd3c173b9 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-27.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-27.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #define f0() void x0 (vector float x) { } f0 () diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-28.c b/gcc/testsuite/gcc.target/powerpc/altivec-28.c index db6c25ac7e851..03ea5d128e238 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-28.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-28.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #define B bool #define P pixel diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-29.c b/gcc/testsuite/gcc.target/powerpc/altivec-29.c index fbce0f76c9d78..d69d720af7c66 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-29.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-29.c @@ -1,7 +1,7 @@ /* PR target/39558 */ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -save-temps" } */ +/* { dg-require-effective-target powerpc_altivec } */ #define ATTRIBUTE_UNUSED __attribute__((unused)) diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-3.c b/gcc/testsuite/gcc.target/powerpc/altivec-3.c index d388ad299a4d6..9df1ae4062505 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-3.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-3.c @@ -1,7 +1,7 @@ /* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */ /* { dg-do compile { target { powerpc*-*-* && { ! vmx_hw } } } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ extern void exit (int); extern void abort (void); diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-30.c b/gcc/testsuite/gcc.target/powerpc/altivec-30.c index 99783191db911..583507dda7e2c 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-30.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-30.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include #include diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-31.c b/gcc/testsuite/gcc.target/powerpc/altivec-31.c index 233efe1bebb0e..22f5bdb8df247 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-31.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-31.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #define f0(type) void x0##type (vector _Bool type x) { } f0 (int) diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-32.c b/gcc/testsuite/gcc.target/powerpc/altivec-32.c index 99b9a68c09a30..e805c3620c1f7 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-32.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-32.c @@ -1,7 +1,7 @@ /* { dg-do compile { target { powerpc*-*-* && lp64 } } } */ /* { dg-skip-if "" { powerpc*-*-darwin* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-O2 -ftree-vectorize -mdejagnu-cpu=power6 -maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* { dg-final { scan-assembler "vsel" } } */ /* { dg-final { scan-assembler "vrfim" } } */ /* { dg-final { scan-assembler "vrfip" } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-33.c b/gcc/testsuite/gcc.target/powerpc/altivec-33.c index 8e912679d2f87..2a2f2a5797310 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-33.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-33.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-O2 -maltivec -mno-vsx" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* We should only produce one vspltw as we already splatted the value. */ /* { dg-final { scan-assembler-times "vspltw" 1 } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-34.c b/gcc/testsuite/gcc.target/powerpc/altivec-34.c index 98fa5d2d4191a..40ba51639ce13 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-34.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-34.c @@ -1,7 +1,7 @@ /* PR target/49621 */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-O2 -maltivec -mno-vsx" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-35.c b/gcc/testsuite/gcc.target/powerpc/altivec-35.c index 8173dca94ac4b..cac46ec3e8ece 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-35.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-35.c @@ -1,7 +1,7 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -mno-vsx -O0" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-36.c b/gcc/testsuite/gcc.target/powerpc/altivec-36.c index ce9e6a36b5de0..c7c758678881d 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-36.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-36.c @@ -1,7 +1,7 @@ /* PR target/70296 */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -std=gnu11" } */ +/* { dg-require-effective-target powerpc_altivec } */ #define c(x) x #define f(x) diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-4.c b/gcc/testsuite/gcc.target/powerpc/altivec-4.c index 2c78f6586d61c..204a3c5275a4b 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-4.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-4.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O0 -Wall" } */ +/* { dg-require-effective-target powerpc_altivec } */ #define vector __attribute__((vector_size(16))) diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-5.c b/gcc/testsuite/gcc.target/powerpc/altivec-5.c index ae85cdbdc746b..4f251d1d0d202 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-5.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-5.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #define vector __attribute__((vector_size(16))) diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-6.c b/gcc/testsuite/gcc.target/powerpc/altivec-6.c index 29856fd0794ba..109944f539d12 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-6.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-6.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O0 -Wall -Wno-deprecated" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-7.c b/gcc/testsuite/gcc.target/powerpc/altivec-7.c index 42c04a1ed7949..460feffabcc6c 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-7.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-7.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Origin: Aldy Hernandez */ diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-8.c b/gcc/testsuite/gcc.target/powerpc/altivec-8.c index 6668cf2db80cb..326c836fe7bc9 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-8.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-8.c @@ -2,8 +2,8 @@ /* Test rs6000_legitimate_address. PRE_INC should be invalid. */ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-9.c b/gcc/testsuite/gcc.target/powerpc/altivec-9.c index b34dc1b51bee3..3abafdac51e11 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-9.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-9.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -mabi=altivec -g" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* PR9564 */ diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-cell-1.c b/gcc/testsuite/gcc.target/powerpc/altivec-cell-1.c index 20d29bf05291a..61a2729db1371 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-cell-1.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-cell-1.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Basic test for the new VMX intrinsics. */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-cell-2.c b/gcc/testsuite/gcc.target/powerpc/altivec-cell-2.c index fdb375c9efe07..f566fddb84c48 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-cell-2.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-cell-2.c @@ -1,7 +1,7 @@ /* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */ /* { dg-do compile { target { powerpc*-*-* && { ! vmx_hw } } } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Test the vec_extract VMX intrinsics. */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-cell-3.c b/gcc/testsuite/gcc.target/powerpc/altivec-cell-3.c index b941ab186fa15..09e2af8f41b8d 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-cell-3.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-cell-3.c @@ -1,7 +1,7 @@ /* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */ /* { dg-do compile { target { powerpc*-*-* && { ! vmx_hw } } } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Test the vec_splats and vec_promote VMX intrinsics. */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-cell-4.c b/gcc/testsuite/gcc.target/powerpc/altivec-cell-4.c index c694691d47591..8422b5e2d5586 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-cell-4.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-cell-4.c @@ -1,7 +1,7 @@ /* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */ /* { dg-do compile { target { powerpc*-*-* && { ! vmx_hw } } } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Test the vec_splats and vec_promote VMX intrinsics. */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-cell-5.c b/gcc/testsuite/gcc.target/powerpc/altivec-cell-5.c index 7e5bc78d56853..54c6aa076e94d 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-cell-5.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-cell-5.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Basic test for the new VMX intrinsics and error messages. */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-cell-6.c b/gcc/testsuite/gcc.target/powerpc/altivec-cell-6.c index b29838a64ee2c..3616df88686d9 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-cell-6.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-cell-6.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-O2 -maltivec -mabi=altivec -mdejagnu-cpu=cell" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include /* This used to ICE with reloading of a constant address. */ diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-cell-7.c b/gcc/testsuite/gcc.target/powerpc/altivec-cell-7.c index cbe5fb9f8a70c..50fe1834dd5da 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-cell-7.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-cell-7.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-O2 -maltivec -mabi=altivec -mdejagnu-cpu=cell" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* { dg-final { scan-assembler-times "vor" 2 } } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-consts.c b/gcc/testsuite/gcc.target/powerpc/altivec-consts.c index c68c68125d1ff..0f4dc6017a705 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-consts.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-consts.c @@ -1,7 +1,7 @@ /* { dg-do run { target vmx_hw } } */ /* { dg-do compile { target { ! vmx_hw } } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -mabi=altivec -O2 -save-temps" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Check that "easy" AltiVec constants are correctly synthesized. */ diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-macros.c b/gcc/testsuite/gcc.target/powerpc/altivec-macros.c index e5a09308ea60a..33eb4087e186d 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-macros.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-macros.c @@ -1,8 +1,8 @@ /* Copyright (C) 2007 Free Software Foundation, Inc. */ /* { dg-do preprocess } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Conditional macros should not be expanded by pragmas. */ #pragma __vector diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-perm-1.c b/gcc/testsuite/gcc.target/powerpc/altivec-perm-1.c index c3cf67e44f40e..f67868efcf2de 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-perm-1.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-perm-1.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-O -maltivec -mno-vsx" } */ +/* { dg-require-effective-target powerpc_altivec } */ typedef unsigned char V __attribute__((vector_size(16))); diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-perm-2.c b/gcc/testsuite/gcc.target/powerpc/altivec-perm-2.c index 1b90bb9567cbc..710e5a6fc972b 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-perm-2.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-perm-2.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-O -maltivec -mno-vsx" } */ +/* { dg-require-effective-target powerpc_altivec } */ typedef unsigned short V __attribute__((vector_size(16))); diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-perm-3.c b/gcc/testsuite/gcc.target/powerpc/altivec-perm-3.c index e6cf2f0464d38..ecec504f17561 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-perm-3.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-perm-3.c @@ -1,7 +1,7 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-skip-if "" { powerpc*le-*-* } } */ /* { dg-options "-O -maltivec -mno-vsx" } */ +/* { dg-require-effective-target powerpc_altivec } */ typedef unsigned char V __attribute__((vector_size(16))); diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-perm-4.c b/gcc/testsuite/gcc.target/powerpc/altivec-perm-4.c index 9598edfb01035..a1dff4c3eb762 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-perm-4.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-perm-4.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-O -maltivec -mno-vsx" } */ +/* { dg-require-effective-target powerpc_altivec } */ typedef unsigned int V __attribute__((vector_size(16))); diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-pr22085.c b/gcc/testsuite/gcc.target/powerpc/altivec-pr22085.c index a7b81bbad565a..3c3ac9ecf8147 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-pr22085.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-pr22085.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -fpreprocessed" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Program to test AltiVec with -fpreprocessed. */ int foo(__attribute__((altivec(vector__))) float x, diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-splat.c b/gcc/testsuite/gcc.target/powerpc/altivec-splat.c index 91ab72d783db2..e8e346158a48b 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-splat.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-splat.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -mabi=altivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Testcase by Richard Guenther and Steven Bosscher. Check that "easy" AltiVec constants are correctly synthesized diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-types-1.c b/gcc/testsuite/gcc.target/powerpc/altivec-types-1.c index b26f16ed3a896..fa4d3f0973c1b 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-types-1.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-types-1.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-linux* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -mno-vsx" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Valid AltiVec vector types should be accepted with no warnings. */ diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-types-2.c b/gcc/testsuite/gcc.target/powerpc/altivec-types-2.c index 4df12da0b1958..36a8dcf492b5c 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-types-2.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-types-2.c @@ -1,7 +1,7 @@ /* { dg-do compile { target powerpc*-*-linux* } } */ -/* { dg-require-effective-target ilp32 } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -mno-vsx" } */ +/* { dg-require-effective-target ilp32 } */ +/* { dg-require-effective-target powerpc_altivec } */ /* These should get warnings for 32-bit code. */ diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-types-3.c b/gcc/testsuite/gcc.target/powerpc/altivec-types-3.c index fe28e53b4e41f..2eb21f6c6935d 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-types-3.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-types-3.c @@ -1,7 +1,7 @@ /* { dg-do compile { target powerpc*-*-linux* } } */ -/* { dg-require-effective-target lp64 } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -mno-vsx" } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-require-effective-target powerpc_altivec } */ /* These should be rejected for 64-bit code. */ diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-types-4.c b/gcc/testsuite/gcc.target/powerpc/altivec-types-4.c index 52fa91453d5e5..7aaf01f36206d 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-types-4.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-types-4.c @@ -1,7 +1,7 @@ /* { dg-do compile { target powerpc*-*-linux* } } */ -/* { dg-require-effective-target ilp32 } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -mno-warn-altivec-long -mno-vsx" } */ +/* { dg-require-effective-target ilp32 } */ +/* { dg-require-effective-target powerpc_altivec } */ /* These should not get warnings for 32-bit code when the warning is disabled. */ diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-varargs-1.c b/gcc/testsuite/gcc.target/powerpc/altivec-varargs-1.c index d62f5bb8e47ef..8b106dc45f4da 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-varargs-1.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-varargs-1.c @@ -1,7 +1,7 @@ /* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */ /* { dg-do compile { target { powerpc*-*-* && { ! vmx_hw } } } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -mabi=altivec -fno-inline" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-vec-merge.c b/gcc/testsuite/gcc.target/powerpc/altivec-vec-merge.c index b1ed8b8649163..28d667ff69817 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-vec-merge.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-vec-merge.c @@ -1,7 +1,7 @@ /* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */ /* { dg-do compile { target { powerpc*-*-* && { ! vmx_hw } } } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2 -Wno-deprecated" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-volatile.c b/gcc/testsuite/gcc.target/powerpc/altivec-volatile.c index a2aa111459e34..b3b12b119be48 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec-volatile.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec-volatile.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Check that "volatile" type qualifier is propagated to vector type. */ diff --git a/gcc/testsuite/gcc.target/powerpc/altivec_vld_vst_addr-1.c b/gcc/testsuite/gcc.target/powerpc/altivec_vld_vst_addr-1.c index eb6d1ebd40f38..55549e40b0822 100644 --- a/gcc/testsuite/gcc.target/powerpc/altivec_vld_vst_addr-1.c +++ b/gcc/testsuite/gcc.target/powerpc/altivec_vld_vst_addr-1.c @@ -1,5 +1,5 @@ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Test vec_ld and vec_st can support both scalar and vector type address points, the list is: diff --git a/gcc/testsuite/gcc.target/powerpc/bool2-av.c b/gcc/testsuite/gcc.target/powerpc/bool2-av.c index 2d361e062ae07..db8be1bd5067f 100644 --- a/gcc/testsuite/gcc.target/powerpc/bool2-av.c +++ b/gcc/testsuite/gcc.target/powerpc/bool2-av.c @@ -1,7 +1,7 @@ /* { dg-do compile { target { powerpc*-*-* } } } */ /* { dg-skip-if "" { powerpc*-*-darwin* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-O2 -mdejagnu-cpu=power6 -maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* { dg-final { scan-assembler-not "\[ \t\]and " } } */ /* { dg-final { scan-assembler-not "\[ \t\]or " } } */ /* { dg-final { scan-assembler-not "\[ \t\]xor " } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/bool2-p5.c b/gcc/testsuite/gcc.target/powerpc/bool2-p5.c index 99ac143d99efc..86c71a1406d4c 100644 --- a/gcc/testsuite/gcc.target/powerpc/bool2-p5.c +++ b/gcc/testsuite/gcc.target/powerpc/bool2-p5.c @@ -1,7 +1,7 @@ /* { dg-do compile { target { powerpc*-*-* } } } */ /* { dg-skip-if "" { powerpc*-*-darwin* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-O2 -mdejagnu-cpu=power5 -mabi=altivec -mno-altivec -mno-vsx" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* { dg-final { scan-assembler "\[ \t\]and " } } */ /* { dg-final { scan-assembler "\[ \t\]or " } } */ /* { dg-final { scan-assembler "\[ \t\]xor " } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/bool3-av.c b/gcc/testsuite/gcc.target/powerpc/bool3-av.c index 92b5ed4992589..e0f88d44b81f4 100644 --- a/gcc/testsuite/gcc.target/powerpc/bool3-av.c +++ b/gcc/testsuite/gcc.target/powerpc/bool3-av.c @@ -1,7 +1,7 @@ /* { dg-do compile { target { powerpc*-*-* && lp64 } } } */ /* { dg-skip-if "" { powerpc*-*-darwin* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-O2 -mdejagnu-cpu=power6 -mabi=altivec -maltivec -mno-vsx" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* { dg-final { scan-assembler "\[ \t\]and " } } */ /* { dg-final { scan-assembler "\[ \t\]or " } } */ /* { dg-final { scan-assembler "\[ \t\]xor " } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/builtin-vec-sums-be-int.c b/gcc/testsuite/gcc.target/powerpc/builtin-vec-sums-be-int.c index b4dfd0637e472..b033ae523d3a3 100644 --- a/gcc/testsuite/gcc.target/powerpc/builtin-vec-sums-be-int.c +++ b/gcc/testsuite/gcc.target/powerpc/builtin-vec-sums-be-int.c @@ -2,8 +2,8 @@ It produces just the instruction vsumsws in LE and BE modes. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/builtins-3.c b/gcc/testsuite/gcc.target/powerpc/builtins-3.c index e048e8b235554..0b9aeafa955dd 100644 --- a/gcc/testsuite/gcc.target/powerpc/builtins-3.c +++ b/gcc/testsuite/gcc.target/powerpc/builtins-3.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/cell_builtin-3.c b/gcc/testsuite/gcc.target/powerpc/cell_builtin-3.c index efcbc03ecbce4..831289bc33dfb 100644 --- a/gcc/testsuite/gcc.target/powerpc/cell_builtin-3.c +++ b/gcc/testsuite/gcc.target/powerpc/cell_builtin-3.c @@ -1,7 +1,7 @@ /* { dg-do compile { target { powerpc*-*-* } } } */ /* { dg-skip-if "" { powerpc*-*-darwin* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-O2 -maltivec -mdejagnu-cpu=cell" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* { dg-final { scan-assembler-times "lvrx" 19 } } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/cell_builtin-5.c b/gcc/testsuite/gcc.target/powerpc/cell_builtin-5.c index db4282292eb68..283285bc5a2a8 100644 --- a/gcc/testsuite/gcc.target/powerpc/cell_builtin-5.c +++ b/gcc/testsuite/gcc.target/powerpc/cell_builtin-5.c @@ -1,7 +1,7 @@ /* { dg-do compile { target { powerpc*-*-* } } } */ /* { dg-skip-if "" { powerpc*-*-darwin* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-O2 -maltivec -mdejagnu-cpu=cell" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* { dg-final { scan-assembler-times "stvlx" 19 } } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/cell_builtin-6.c b/gcc/testsuite/gcc.target/powerpc/cell_builtin-6.c index ada27ea0d9ca6..0fbf6f2e9ff0d 100644 --- a/gcc/testsuite/gcc.target/powerpc/cell_builtin-6.c +++ b/gcc/testsuite/gcc.target/powerpc/cell_builtin-6.c @@ -1,7 +1,7 @@ /* { dg-do compile { target { powerpc*-*-* } } } */ /* { dg-skip-if "" { powerpc*-*-darwin* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-O2 -maltivec -mdejagnu-cpu=cell" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* { dg-final { scan-assembler-times "stvlxl" 19 } } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/cell_builtin-7.c b/gcc/testsuite/gcc.target/powerpc/cell_builtin-7.c index ab401568a1c2b..bdf1827f767a2 100644 --- a/gcc/testsuite/gcc.target/powerpc/cell_builtin-7.c +++ b/gcc/testsuite/gcc.target/powerpc/cell_builtin-7.c @@ -1,7 +1,7 @@ /* { dg-do compile { target { powerpc*-*-* } } } */ /* { dg-skip-if "" { powerpc*-*-darwin* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-O2 -maltivec -mdejagnu-cpu=cell" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* { dg-final { scan-assembler-times "stvrx" 19 } } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/cell_builtin-8.c b/gcc/testsuite/gcc.target/powerpc/cell_builtin-8.c index bbc81cd884dfb..289091862dcd1 100644 --- a/gcc/testsuite/gcc.target/powerpc/cell_builtin-8.c +++ b/gcc/testsuite/gcc.target/powerpc/cell_builtin-8.c @@ -1,7 +1,7 @@ /* { dg-do compile { target { powerpc*-*-* } } } */ /* { dg-skip-if "" { powerpc*-*-darwin* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-O2 -maltivec -mdejagnu-cpu=cell" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* { dg-final { scan-assembler-times "stvrxl" 19 } } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/darwin-save-world-1.c b/gcc/testsuite/gcc.target/powerpc/darwin-save-world-1.c index c45a90f0f5ca7..3326765f4fb7e 100644 --- a/gcc/testsuite/gcc.target/powerpc/darwin-save-world-1.c +++ b/gcc/testsuite/gcc.target/powerpc/darwin-save-world-1.c @@ -1,7 +1,7 @@ /* { dg-do run { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ -/* { dg-skip-if "need to be able to execute AltiVec" { ! { powerpc_altivec_ok && vmx_hw } } } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ +/* { dg-skip-if "need to be able to execute AltiVec" { ! { powerpc_altivec_ok && vmx_hw } } } */ /* With altivec turned on, Darwin wants to save the world but we did not mark lr as being saved any more as saving the lr is not needed for saving altivec registers. */ diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-char-fwrapv.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-char-fwrapv.c index 8b9887dd161e2..1a0add90853bc 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-char-fwrapv.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-char-fwrapv.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2 -fwrapv" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-char.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-char.c index 1f303b8d5b757..75e38a4aba139 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-char.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-char.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-int-fwrapv.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-int-fwrapv.c index 22eec38f25efc..37acdea9d8e72 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-int-fwrapv.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-int-fwrapv.c @@ -2,8 +2,8 @@ inputs produce the right results. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2 -fwrapv" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-int-fwrapv.p7.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-int-fwrapv.p7.c index b27c8a3205d4d..62ee53aa993d9 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-int-fwrapv.p7.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-int-fwrapv.p7.c @@ -2,8 +2,8 @@ inputs produce the right results when -mcpu=power7 is specified. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2 -mdejagnu-cpu=power7 -fwrapv" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-int-fwrapv.p8.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-int-fwrapv.p8.c index 4a154657a68e6..0d1884f826913 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-int-fwrapv.p8.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-int-fwrapv.p8.c @@ -2,8 +2,8 @@ inputs produce the right results when -mcpu=power8 is specified. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2 -mdejagnu-cpu=power8 -fwrapv" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-int.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-int.c index 4fb3fbe866457..8f0eb4d2a5b76 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-int.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-int.c @@ -2,8 +2,8 @@ inputs produce the right results. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-int.p7.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-int.p7.c index 6f437bdd2c58f..310d26f70020b 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-int.p7.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-int.p7.c @@ -2,8 +2,8 @@ inputs produce the right code when -mcpu=power7 is specified. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2 -mdejagnu-cpu=power7" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-int.p8.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-int.p8.c index 8c712d34ae5b2..eb8ba359ad658 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-int.p8.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-int.p8.c @@ -2,8 +2,8 @@ inputs produce the right code when -mcpu=power8 is specified. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2 -mdejagnu-cpu=power8" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-short-fwrapv.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-short-fwrapv.c index 705bbe974291e..0a867f33ae142 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-short-fwrapv.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-short-fwrapv.c @@ -2,8 +2,8 @@ inputs produce the right results. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2 -fwrapv" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-short.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-short.c index 0ad850f06b312..1ac66195afbd2 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-short.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-abs-short.c @@ -2,8 +2,8 @@ inputs produce the right results. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-add-1.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-add-1.c index 4ffdb81e709b7..3b6c39bb2e874 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-add-1.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-add-1.c @@ -2,8 +2,8 @@ inputs produce the right results. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-add-2.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-add-2.c index c3b5e1d4aec11..bc6369afb8568 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-add-2.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-add-2.c @@ -2,8 +2,8 @@ inputs produce the right results. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-add-3.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-add-3.c index bb7e644caad59..da21f5b893719 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-add-3.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-add-3.c @@ -2,8 +2,8 @@ inputs produce the right results. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-add-5.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-add-5.c index cc1d8c443a104..976b7647381b6 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-add-5.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-add-5.c @@ -2,8 +2,8 @@ inputs produce the right results. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -mno-vsx" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-extract-double.p7.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-extract-double.p7.c index e69d9253e2d28..a0ba94976ac42 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-extract-double.p7.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-extract-double.p7.c @@ -2,9 +2,9 @@ double inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-mdejagnu-cpu=power7 -O2" } */ /* { dg-additional-options "-mbig-endian" { target powerpc*-*-linux* } } */ +/* { dg-require-effective-target powerpc_altivec } */ // targeting P7 (BE), 2 tests. // P7 constants: xxpermdi diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-ld-char.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-ld-char.c index 9ed1a94231bfd..018e331c9f8bf 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-ld-char.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-ld-char.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-ld-float.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-ld-float.c index ff6b965c04072..8b5abfa286dbb 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-ld-float.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-ld-float.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-ld-int.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-ld-int.c index 8a477d0bf6154..fa3c635825c35 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-ld-int.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-ld-int.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-ld-short.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-ld-short.c index bb4835b59efc5..d99375736c67b 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-ld-short.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-ld-short.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-madd-short.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-madd-short.c index 0e78f3585f5d5..44ee7a07cf93b 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-madd-short.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-madd-short.c @@ -2,8 +2,8 @@ inputs produce the right results. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-mergehl-char.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-mergehl-char.c index 1762603ec7fe4..acbb5deb18078 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-mergehl-char.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-mergehl-char.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-mergehl-float.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-mergehl-float.c index 989101635b0c3..fc9d659d94759 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-mergehl-float.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-mergehl-float.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-mergehl-int.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-mergehl-int.c index 4da09fd8411a1..ee1f683033883 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-mergehl-int.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-mergehl-int.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2 " } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-mergehl-short.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-mergehl-short.c index b3a0362ee18a0..e394737518abe 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-mergehl-short.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-mergehl-short.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-minmax-char.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-minmax-char.c index 6c412a4ed2549..d35ff12a612a8 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-minmax-char.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-minmax-char.c @@ -2,8 +2,8 @@ inputs produce the right results. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-minmax-int.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-minmax-int.c index 0dea882db9f79..c1a9742361bf9 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-minmax-int.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-minmax-int.c @@ -2,8 +2,8 @@ inputs produce the right results. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-minmax-short.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-minmax-short.c index 02d12aa3fb98b..5fd1cdd9aa36c 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-minmax-short.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-minmax-short.c @@ -2,8 +2,8 @@ inputs produce the right results. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-missing-lhs.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-missing-lhs.c index 6add903828870..225c4e35d03d1 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-missing-lhs.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-missing-lhs.c @@ -4,8 +4,8 @@ This was noticed during debug of PR81317. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-msum-char.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-msum-char.c index 53519d502930d..6ad4b93984d3f 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-msum-char.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-msum-char.c @@ -2,8 +2,8 @@ produce the right results. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-msum-short.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-msum-short.c index 2e590ab8066a2..805dc14051920 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-msum-short.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-msum-short.c @@ -2,8 +2,8 @@ inputs produce the right results. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-mule-char.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-mule-char.c index 02d9789f86f17..1aaf2e77b726b 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-mule-char.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-mule-char.c @@ -2,8 +2,8 @@ inputs produce the right results. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-mule-short.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-mule-short.c index 79b44d530e5e1..2d387097e1109 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-mule-short.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-mule-short.c @@ -2,8 +2,8 @@ inputs produce the right results. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-mult-char.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-mult-char.c index 3f946e56fcf09..1834d9036672c 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-mult-char.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-mult-char.c @@ -2,8 +2,8 @@ inputs produce the right results. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-mult-short.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-mult-short.c index e7504db720fc8..54011805a1c53 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-mult-short.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-mult-short.c @@ -2,8 +2,8 @@ inputs produce the right results. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-pack-int.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-pack-int.c index 940faf36755d8..37cc506b357a3 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-pack-int.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-pack-int.c @@ -2,8 +2,8 @@ inputs produce the right results. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-pack-short.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-pack-short.c index 37cd191dbd819..02a95aacd3591 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-pack-short.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-pack-short.c @@ -2,8 +2,8 @@ inputs produce the right results. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-perm-char.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-perm-char.c index 56a89f3f79b85..15b57c6e07d2e 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-perm-char.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-perm-char.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-perm-float.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-perm-float.c index 64b8ac78deaab..cdc5dcbbe33d7 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-perm-float.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-perm-float.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-perm-int.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-perm-int.c index a6dd59524cb8b..c936326534ba5 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-perm-int.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-perm-int.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-perm-pixel.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-perm-pixel.c index 54fccd26e01ea..b1be1f4ff447e 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-perm-pixel.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-perm-pixel.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-perm-short.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-perm-short.c index 6a5d1a7df9678..e5391b2585983 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-perm-short.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-perm-short.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-shift-char.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-shift-char.c index ebe91e7bfcdfa..e16c08d98482c 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-shift-char.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-shift-char.c @@ -2,8 +2,8 @@ inputs produce the right results. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-shift-int.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-shift-int.c index e9c5fe1ad33aa..9d384b5e489d7 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-shift-int.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-shift-int.c @@ -2,8 +2,8 @@ inputs produce the right results. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-shift-left-fwrapv.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-shift-left-fwrapv.c index 34264807b8985..89dafb1f87a8d 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-shift-left-fwrapv.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-shift-left-fwrapv.c @@ -2,8 +2,8 @@ /* This test covers the shift left tests with the -fwrapv option. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2 -fwrapv" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-shift-left.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-shift-left.c index 36f92b431a4a4..4136b9e51dc85 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-shift-left.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-shift-left.c @@ -2,8 +2,8 @@ * This is a counterpart to the fold-vec-shift-left-frwapv test. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-shift-short.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-shift-short.c index 4ca7c1802a1ef..d906d87fa56aa 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-shift-short.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-shift-short.c @@ -2,8 +2,8 @@ inputs produce the right results. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-splat-32.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-splat-32.c index f59849edf3ef8..48c05092622c6 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-splat-32.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-splat-32.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-splat-8.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-splat-8.c index 64d6320bbaffc..ebe3c37bcfea0 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-splat-8.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-splat-8.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-splat-char.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-splat-char.c index fbe347c67e6f6..c789b4077a0b2 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-splat-char.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-splat-char.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-splat-int.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-splat-int.c index 5df96d11acb5c..dd3e1c806d9c2 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-splat-int.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-splat-int.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-splat-short.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-splat-short.c index 92bdfa4525fdc..bfbc52e70df76 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-splat-short.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-splat-short.c @@ -2,8 +2,8 @@ inputs produce the right results. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-splats-char.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-splats-char.c index 8f211537d2891..c6f1231d674b5 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-splats-char.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-splats-char.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2 " } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-splats-int.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-splats-int.c index dff0f55959958..98c65613437c0 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-splats-int.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-splats-int.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile { target lp64 } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2 " } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-splats-short.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-splats-short.c index 18102ac12547b..2ffc80a6b8799 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-splats-short.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-splats-short.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-st-char.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-st-char.c index d8de63fdeba60..0f2ad5f65b776 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-st-char.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-st-char.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-st-float.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-st-float.c index 61780fb308b29..f98b96a2cf565 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-st-float.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-st-float.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-st-int.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-st-int.c index 4155a8f130f82..56094f15e0999 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-st-int.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-st-int.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include // void vec_st (vector signed int, int, vector signed int *); diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-st-short.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-st-short.c index d9b7a0754a67d..f9d5af11d2316 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-st-short.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-st-short.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include // vector signed short vec_ld (int, const vector signed short *); diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-sub-char.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-sub-char.c index 5063bd8cb10b5..d2e21c1b9d0ec 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-sub-char.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-sub-char.c @@ -2,8 +2,8 @@ inputs produce the right results. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-sub-float.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-sub-float.c index 8a29def8cc26e..21ddc4a6a58d0 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-sub-float.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-sub-float.c @@ -2,8 +2,8 @@ inputs produce the right results. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -mno-vsx" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-sub-int.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-sub-int.c index 1fac1dc0eeb45..a52ecc0c40b23 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-sub-int.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-sub-int.c @@ -2,8 +2,8 @@ inputs produce the right results. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-sub-short.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-sub-short.c index 67052a2474d05..6768ffc1822c4 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-sub-short.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-sub-short.c @@ -2,8 +2,8 @@ inputs produce the right results. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-sums-int.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-sums-int.c index e1047facbffa6..eba75a860bee7 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-sums-int.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-sums-int.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-unpack-char.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-unpack-char.c index 7f4b3721b20f5..7b0d546d02e6c 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-unpack-char.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-unpack-char.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-unpack-pixel.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-unpack-pixel.c index 8e7d11026e969..0f427dbc434b8 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-unpack-pixel.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-unpack-pixel.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-unpack-short.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-unpack-short.c index da5101271f420..6772cad0300e8 100644 --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-unpack-short.c +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-unpack-short.c @@ -2,8 +2,8 @@ inputs produce the right code. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/le-altivec-consts.c b/gcc/testsuite/gcc.target/powerpc/le-altivec-consts.c index a1db5e92f8733..48e103e68093e 100644 --- a/gcc/testsuite/gcc.target/powerpc/le-altivec-consts.c +++ b/gcc/testsuite/gcc.target/powerpc/le-altivec-consts.c @@ -1,7 +1,7 @@ /* { dg-do run { target vmx_hw } } */ /* { dg-do compile { target { ! vmx_hw } } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -mabi=altivec -O2 -save-temps" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Check that "easy" AltiVec constants are correctly synthesized. */ diff --git a/gcc/testsuite/gcc.target/powerpc/ppc-fma-3.c b/gcc/testsuite/gcc.target/powerpc/ppc-fma-3.c index 8608116e2ee23..f10b9e3eb3951 100644 --- a/gcc/testsuite/gcc.target/powerpc/ppc-fma-3.c +++ b/gcc/testsuite/gcc.target/powerpc/ppc-fma-3.c @@ -1,8 +1,8 @@ /* { dg-do compile { target { powerpc*-*-* } } } */ /* { dg-skip-if "" { powerpc*-*-darwin* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ -/* { dg-require-effective-target powerpc_fprs } */ /* { dg-options "-O3 -ftree-vectorize -mdejagnu-cpu=power6 -maltivec -ffast-math -fno-unroll-loops" } */ +/* { dg-require-effective-target powerpc_altivec } */ +/* { dg-require-effective-target powerpc_fprs } */ /* { dg-final { scan-assembler-times "vmaddfp" 2 } } */ /* { dg-final { scan-assembler-times "fmadd " 2 } } */ /* { dg-final { scan-assembler-times "fmadds" 2 } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/ppc-fma-4.c b/gcc/testsuite/gcc.target/powerpc/ppc-fma-4.c index 291c2eec4d443..48b61099c0abc 100644 --- a/gcc/testsuite/gcc.target/powerpc/ppc-fma-4.c +++ b/gcc/testsuite/gcc.target/powerpc/ppc-fma-4.c @@ -1,8 +1,8 @@ /* { dg-do compile { target { powerpc*-*-* } } } */ /* { dg-skip-if "" { powerpc*-*-darwin* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ -/* { dg-require-effective-target powerpc_fprs } */ /* { dg-options "-O3 -ftree-vectorize -mdejagnu-cpu=power6 -maltivec -ffast-math -ffp-contract=off -fno-unroll-loops" } */ +/* { dg-require-effective-target powerpc_altivec } */ +/* { dg-require-effective-target powerpc_fprs } */ /* { dg-final { scan-assembler-times "vmaddfp" 1 } } */ /* { dg-final { scan-assembler-times "fmadd " 1 } } */ /* { dg-final { scan-assembler-times "fmadds" 1 } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/ppc-fma-7.c b/gcc/testsuite/gcc.target/powerpc/ppc-fma-7.c index 05299798c9bcc..4092e463452c6 100644 --- a/gcc/testsuite/gcc.target/powerpc/ppc-fma-7.c +++ b/gcc/testsuite/gcc.target/powerpc/ppc-fma-7.c @@ -1,8 +1,8 @@ /* { dg-do compile { target { powerpc*-*-* } } } */ /* { dg-skip-if "" { powerpc*-*-darwin* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ -/* { dg-require-effective-target powerpc_fprs } */ /* { dg-options "-O3 -ftree-vectorize -mdejagnu-cpu=power6 -ffast-math" } */ +/* { dg-require-effective-target powerpc_altivec } */ +/* { dg-require-effective-target powerpc_fprs } */ /* { dg-final { scan-assembler-times "fmadd" 1 } } */ /* { dg-final { scan-assembler-times "fmsub " 1 } } */ /* { dg-final { scan-assembler-not "fmul" } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/ppc-vector-memcpy.c b/gcc/testsuite/gcc.target/powerpc/ppc-vector-memcpy.c index 7464625826586..fa90de3669d1f 100644 --- a/gcc/testsuite/gcc.target/powerpc/ppc-vector-memcpy.c +++ b/gcc/testsuite/gcc.target/powerpc/ppc-vector-memcpy.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-O -maltivec -mno-vsx" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* { dg-final { scan-assembler "lvx" } } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/ppc-vector-memset.c b/gcc/testsuite/gcc.target/powerpc/ppc-vector-memset.c index 175a756eca7f3..0d4b9d6b29f7f 100644 --- a/gcc/testsuite/gcc.target/powerpc/ppc-vector-memset.c +++ b/gcc/testsuite/gcc.target/powerpc/ppc-vector-memset.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-O -maltivec -mno-vsx" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* { dg-final { scan-assembler "stvx" } } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/pr100645.c b/gcc/testsuite/gcc.target/powerpc/pr100645.c index c4e92cc805211..fc55cf306a373 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr100645.c +++ b/gcc/testsuite/gcc.target/powerpc/pr100645.c @@ -1,5 +1,5 @@ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-mdejagnu-cpu=power6 -maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* This used to ICE. */ diff --git a/gcc/testsuite/gcc.target/powerpc/pr101384-1.c b/gcc/testsuite/gcc.target/powerpc/pr101384-1.c index 41cf84bf8bcf4..8ada48cc5e0e5 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr101384-1.c +++ b/gcc/testsuite/gcc.target/powerpc/pr101384-1.c @@ -1,7 +1,7 @@ /* PR target/101384 */ /* { dg-do compile { target le } } */ /* { dg-options "-O2 -maltivec" } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ +/* { dg-require-effective-target powerpc_altivec } */ /* { dg-final { scan-assembler-times {\mvspltis[whb] [^\n\r]*,-1\M|\mxxspltib[^\n\r]*,255\M} 9 } } */ /* { dg-final { scan-assembler-times {\mvslw\M} 3 } } */ /* { dg-final { scan-assembler-times {\mvslh\M} 3 } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/pr101384-2.c b/gcc/testsuite/gcc.target/powerpc/pr101384-2.c index c14891b5ab47f..124dbeb83b63e 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr101384-2.c +++ b/gcc/testsuite/gcc.target/powerpc/pr101384-2.c @@ -1,7 +1,7 @@ /* PR target/101384 */ /* { dg-do compile { target be } } */ /* { dg-options "-O2 -maltivec" } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ +/* { dg-require-effective-target powerpc_altivec } */ /* { dg-final { scan-assembler-times {\mvspltis[whb] [^\n\r]*,-1\M|\mxxspltib [^\n\r]*,255\M} 9 } } */ /* { dg-final { scan-assembler-times {\mvslw\M} 3 } } */ /* { dg-final { scan-assembler-times {\mvslh\M} 3 } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/pr103353.c b/gcc/testsuite/gcc.target/powerpc/pr103353.c index 5d519fb1b7ba3..0473e6d0cdaf2 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr103353.c +++ b/gcc/testsuite/gcc.target/powerpc/pr103353.c @@ -1,8 +1,8 @@ -/* { dg-require-effective-target powerpc_altivec_ok } */ +/* { dg-options "-maltivec -mdejagnu-cpu=power6" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* If the default cpu type is power10 or later, MMA is enabled by default. To keep the test point available all the time, this case specifies -mdejagnu-cpu=power6 to make it be tested without MMA. */ -/* { dg-options "-maltivec -mdejagnu-cpu=power6" } */ /* Verify there is no ICE and don't check the error messages on MMA requirement since they could be fragile and are not test points diff --git a/gcc/testsuite/gcc.target/powerpc/pr103702.c b/gcc/testsuite/gcc.target/powerpc/pr103702.c index 585946fd64b63..37b98e7672bf9 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr103702.c +++ b/gcc/testsuite/gcc.target/powerpc/pr103702.c @@ -1,5 +1,3 @@ -/* We don't have one powerpc.*_ok for Power6, use altivec_ok conservatively. */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-mdejagnu-cpu=power6 -O2 -ftree-loop-vectorize -fno-tree-scev-cprop" } */ /* Verify there is no ICE. */ diff --git a/gcc/testsuite/gcc.target/powerpc/pr108348-1.c b/gcc/testsuite/gcc.target/powerpc/pr108348-1.c index 29cbe7abffcd9..630980ec936ce 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr108348-1.c +++ b/gcc/testsuite/gcc.target/powerpc/pr108348-1.c @@ -1,10 +1,10 @@ -/* { dg-require-effective-target powerpc_altivec_ok } */ +/* { dg-options "-mdejagnu-cpu=power9 -mabi=no-altivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* If the default cpu type is power10 or later, type __vector_quad is supported. To keep the test point available all the time, this case specifies -mdejagnu-cpu=power9 here. This needs -mabi=no-altivec to do the copying for pass-by-reference function argument on 32 bit environment. */ -/* { dg-options "-mdejagnu-cpu=power9 -mabi=no-altivec" } */ /* Verify there is no ICE on 32 bit and don't check the error messages on unsupported type since they could be fragile and are not test diff --git a/gcc/testsuite/gcc.target/powerpc/pr108348-2.c b/gcc/testsuite/gcc.target/powerpc/pr108348-2.c index 9aa8939e2f476..c7e8c6cd96d2b 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr108348-2.c +++ b/gcc/testsuite/gcc.target/powerpc/pr108348-2.c @@ -1,10 +1,10 @@ -/* { dg-require-effective-target powerpc_altivec_ok } */ +/* { dg-options "-mdejagnu-cpu=power9 -mabi=no-altivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* If the default cpu type is power10 or later, type __vector_pair is supported. To keep the test point available all the time, this case specifies -mdejagnu-cpu=power9 here. This needs -mabi=no-altivec to do the copying for pass-by-reference function argument on 32 bit environment. */ -/* { dg-options "-mdejagnu-cpu=power9 -mabi=no-altivec" } */ /* Verify there is no ICE on 32 bit and don't check the error messages on unsupported type since they could be fragile and are not test diff --git a/gcc/testsuite/gcc.target/powerpc/pr109932-1.c b/gcc/testsuite/gcc.target/powerpc/pr109932-1.c index 374d9f6061834..e2acf28950fb8 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr109932-1.c +++ b/gcc/testsuite/gcc.target/powerpc/pr109932-1.c @@ -1,6 +1,6 @@ -/* { dg-require-effective-target int128 } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -mno-vsx" } */ +/* { dg-require-effective-target int128 } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Verify there is no ICE but one expected error message instead. */ diff --git a/gcc/testsuite/gcc.target/powerpc/pr109932-2.c b/gcc/testsuite/gcc.target/powerpc/pr109932-2.c index 374d9f6061834..e2acf28950fb8 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr109932-2.c +++ b/gcc/testsuite/gcc.target/powerpc/pr109932-2.c @@ -1,6 +1,6 @@ -/* { dg-require-effective-target int128 } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -mno-vsx" } */ +/* { dg-require-effective-target int128 } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Verify there is no ICE but one expected error message instead. */ diff --git a/gcc/testsuite/gcc.target/powerpc/pr110776.c b/gcc/testsuite/gcc.target/powerpc/pr110776.c index 749159fd67549..e0c93004a3d2f 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr110776.c +++ b/gcc/testsuite/gcc.target/powerpc/pr110776.c @@ -1,5 +1,5 @@ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-O2 -mdejagnu-cpu=power6 -maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Verify there is no ICE. */ diff --git a/gcc/testsuite/gcc.target/powerpc/pr115389.c b/gcc/testsuite/gcc.target/powerpc/pr115389.c new file mode 100644 index 0000000000000..a091ee8a1be05 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr115389.c @@ -0,0 +1,17 @@ +/* PR target/115389 */ +/* { dg-do assemble } */ +/* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect -mno-vsx -mno-altivec -mabi=no-altivec -save-temps" } */ +/* { dg-require-effective-target rop_ok } */ + +/* Verify we do not emit invalid offsets for our ROP insns. */ + +extern void foo (void); +long +bar (void) +{ + foo (); + return 0; +} + +/* { dg-final { scan-assembler-times {\mhashst\M} 1 } } */ +/* { dg-final { scan-assembler-times {\mhashchk\M} 1 } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/pr16155.c b/gcc/testsuite/gcc.target/powerpc/pr16155.c index fffe957dcc4d1..0b2dfb220e891 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr16155.c +++ b/gcc/testsuite/gcc.target/powerpc/pr16155.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -ansi" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* PR 16155 * Compilation of a simple altivec test program fails if the -ansi flag is diff --git a/gcc/testsuite/gcc.target/powerpc/pr16286.c b/gcc/testsuite/gcc.target/powerpc/pr16286.c index 790b6409fbcd2..82a4351f9a73c 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr16286.c +++ b/gcc/testsuite/gcc.target/powerpc/pr16286.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* PR 16286 Compilation of a simple Altivec test program fails if vector, pixel diff --git a/gcc/testsuite/gcc.target/powerpc/pr27158.c b/gcc/testsuite/gcc.target/powerpc/pr27158.c index 5476577a92416..abdedf831d619 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr27158.c +++ b/gcc/testsuite/gcc.target/powerpc/pr27158.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-O2 -maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #define REGLIST \ "77", "78", "79", "80", "81", "82", "83", "84", "85", "86",\ "87", "88", "89", "90", "91", "92", "93", "94", "95", "96",\ diff --git a/gcc/testsuite/gcc.target/powerpc/pr35907.c b/gcc/testsuite/gcc.target/powerpc/pr35907.c index 7d5465ea1514b..82f58ab5871fa 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr35907.c +++ b/gcc/testsuite/gcc.target/powerpc/pr35907.c @@ -1,8 +1,8 @@ /* PR target/35907 */ /* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */ /* { dg-do compile { target { powerpc*-*-* && { ! vmx_hw } } } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-O2 -maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #define vector __attribute__((vector_size (16))) union diff --git a/gcc/testsuite/gcc.target/powerpc/pr37168.c b/gcc/testsuite/gcc.target/powerpc/pr37168.c index 8d35157d0f4a3..4347725508260 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr37168.c +++ b/gcc/testsuite/gcc.target/powerpc/pr37168.c @@ -1,7 +1,7 @@ /* PR target/37168 */ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-O2 -maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #define C 3.68249351546114573519399405666776E-44f #define vector __attribute__ ((altivec (vector__))) diff --git a/gcc/testsuite/gcc.target/powerpc/pr47197.c b/gcc/testsuite/gcc.target/powerpc/pr47197.c index a8930f2a5c809..b1e587480d8f2 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr47197.c +++ b/gcc/testsuite/gcc.target/powerpc/pr47197.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Compile-only test to ensure that expressions can be passed to Altivec builtins without error. */ diff --git a/gcc/testsuite/gcc.target/powerpc/pr66144-3.c b/gcc/testsuite/gcc.target/powerpc/pr66144-3.c index 4c93b2a7a3daf..14ecb809edc24 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr66144-3.c +++ b/gcc/testsuite/gcc.target/powerpc/pr66144-3.c @@ -1,5 +1,5 @@ -/* { dg-do compile { target { powerpc64*-*-* } } } */ -/* { dg-options "-mdejagnu-cpu=power8 -mvsx -O2 -ftree-vectorize" } */ +/* { dg-do compile } */ +/* { dg-options "-mdejagnu-cpu=power8 -O2 -ftree-vectorize -fno-unroll-loops" } */ /* { dg-require-effective-target powerpc_vsx } */ /* Verify that we can optimize a vector conditional move, where one of the arms @@ -20,7 +20,7 @@ test (void) a[i] = (b[i] == c[i]) ? -1 : a[i]; } -/* { dg-final { scan-assembler {\mvcmpequw\M} } } */ -/* { dg-final { scan-assembler {\mxxsel\M} } } */ +/* { dg-final { scan-assembler-times {\mvcmpequw\M} 1 } } */ +/* { dg-final { scan-assembler-times {\m(?:xxsel|xxlor|vor)\M} 1 } } */ /* { dg-final { scan-assembler-not {\mvspltisw\M} } } */ /* { dg-final { scan-assembler-not {\mxxlorc\M} } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/pr67071-1.c b/gcc/testsuite/gcc.target/powerpc/pr67071-1.c index 9a98dee958947..72c571b851c94 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr67071-1.c +++ b/gcc/testsuite/gcc.target/powerpc/pr67071-1.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-mdejagnu-cpu=power6 -maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ vector unsigned char foo_char (void) diff --git a/gcc/testsuite/gcc.target/powerpc/pr67071-2.c b/gcc/testsuite/gcc.target/powerpc/pr67071-2.c index b2146e28729d8..d35a62125b459 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr67071-2.c +++ b/gcc/testsuite/gcc.target/powerpc/pr67071-2.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-mdejagnu-cpu=power6 -maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ vector unsigned char foo_char (void) diff --git a/gcc/testsuite/gcc.target/powerpc/pr67071-3.c b/gcc/testsuite/gcc.target/powerpc/pr67071-3.c index c22511d5da9d3..b13f1ac59c7fe 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr67071-3.c +++ b/gcc/testsuite/gcc.target/powerpc/pr67071-3.c @@ -1,6 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-mdejagnu-cpu=power6 -maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ vector unsigned char diff --git a/gcc/testsuite/gcc.target/powerpc/pr70010-2.c b/gcc/testsuite/gcc.target/powerpc/pr70010-2.c index dd24208153721..bcd290177d3c5 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr70010-2.c +++ b/gcc/testsuite/gcc.target/powerpc/pr70010-2.c @@ -1,7 +1,7 @@ /* { dg-do compile } */ /* { dg-options "-O2 -flto -maltivec -mno-vsx" } */ /* { dg-require-effective-target lto } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ +/* { dg-require-effective-target powerpc_altivec } */ vector int c, a, b; diff --git a/gcc/testsuite/gcc.target/powerpc/pr70010-3.c b/gcc/testsuite/gcc.target/powerpc/pr70010-3.c index 9fd97d10074a6..ff72a2409d9a3 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr70010-3.c +++ b/gcc/testsuite/gcc.target/powerpc/pr70010-3.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O2 -maltivec -mno-vsx" } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ +/* { dg-require-effective-target powerpc_altivec } */ vector int c, a, b; diff --git a/gcc/testsuite/gcc.target/powerpc/pr71297.c b/gcc/testsuite/gcc.target/powerpc/pr71297.c index db1aaf016cd44..0bbc086bb3f8c 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr71297.c +++ b/gcc/testsuite/gcc.target/powerpc/pr71297.c @@ -1,6 +1,6 @@ /* PR target/71763 */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ +/* { dg-require-effective-target powerpc_altivec } */ int main () { diff --git a/gcc/testsuite/gcc.target/powerpc/pr82112.c b/gcc/testsuite/gcc.target/powerpc/pr82112.c index fbb0f9d3d0600..afb2306f6d832 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr82112.c +++ b/gcc/testsuite/gcc.target/powerpc/pr82112.c @@ -1,7 +1,7 @@ /* PR target/82112 */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -std=gnu90" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/pr84220-sld.c b/gcc/testsuite/gcc.target/powerpc/pr84220-sld.c index 2536fc30b988e..6f910ba9a17d1 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr84220-sld.c +++ b/gcc/testsuite/gcc.target/powerpc/pr84220-sld.c @@ -2,8 +2,8 @@ /* Test to ensure we generate invalid parameter errors rather than an ICE when calling builtin_vec_sld() with invalid parameters. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/pr84878.c b/gcc/testsuite/gcc.target/powerpc/pr84878.c index f96d3803d0623..8f47235a8db8b 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr84878.c +++ b/gcc/testsuite/gcc.target/powerpc/pr84878.c @@ -1,7 +1,7 @@ /* PR rtl-optimization/84878 */ /* { dg-do compile { target { powerpc*-*-* } } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-O2 -maltivec -mno-vsx -fmodulo-sched -ftree-vectorize -funroll-loops -fassociative-math -fno-signed-zeros -fno-trapping-math" } */ +/* { dg-require-effective-target powerpc_altivec } */ int ek; float zu; diff --git a/gcc/testsuite/gcc.target/powerpc/pr86731-fwrapv.c b/gcc/testsuite/gcc.target/powerpc/pr86731-fwrapv.c index f312550f04d67..7fdfbe4b00c2e 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr86731-fwrapv.c +++ b/gcc/testsuite/gcc.target/powerpc/pr86731-fwrapv.c @@ -4,9 +4,9 @@ gimple folding of the vec_sl() intrinsic. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ -/* { dg-require-effective-target lp64 } */ /* { dg-options "-maltivec -O3 -fwrapv " } */ +/* { dg-require-effective-target powerpc_altivec } */ +/* { dg-require-effective-target lp64 } */ #include /* original test as reported. */ diff --git a/gcc/testsuite/gcc.target/powerpc/pr86731.c b/gcc/testsuite/gcc.target/powerpc/pr86731.c index 19fefa584fedb..c30060d3c9729 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr86731.c +++ b/gcc/testsuite/gcc.target/powerpc/pr86731.c @@ -2,9 +2,9 @@ left shift properly. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ -/* { dg-require-effective-target lp64 } */ /* { dg-options "-maltivec -O3" } */ +/* { dg-require-effective-target powerpc_altivec } */ +/* { dg-require-effective-target lp64 } */ #include /* The original test as reported. */ diff --git a/gcc/testsuite/gcc.target/powerpc/pr88100.c b/gcc/testsuite/gcc.target/powerpc/pr88100.c index 764c897a49766..dd678a326a7be 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr88100.c +++ b/gcc/testsuite/gcc.target/powerpc/pr88100.c @@ -2,8 +2,8 @@ vec_splat_{su}{8,16,32} invalid data properly. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/pragma_power6.c b/gcc/testsuite/gcc.target/powerpc/pragma_power6.c index a9120b774151b..c21463f8a6ee8 100644 --- a/gcc/testsuite/gcc.target/powerpc/pragma_power6.c +++ b/gcc/testsuite/gcc.target/powerpc/pragma_power6.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-mdejagnu-cpu=power6 -maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/pragma_power7.c b/gcc/testsuite/gcc.target/powerpc/pragma_power7.c index 2e5b7c2b36945..d2e9add07c906 100644 --- a/gcc/testsuite/gcc.target/powerpc/pragma_power7.c +++ b/gcc/testsuite/gcc.target/powerpc/pragma_power7.c @@ -1,7 +1,7 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ -/* { dg-require-effective-target lp64 } */ /* { dg-options "-mdejagnu-cpu=power6 -maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ +/* { dg-require-effective-target lp64 } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/pragma_power9.c b/gcc/testsuite/gcc.target/powerpc/pragma_power9.c index e05f1f4ddfac0..2fbc5fa17efdd 100644 --- a/gcc/testsuite/gcc.target/powerpc/pragma_power9.c +++ b/gcc/testsuite/gcc.target/powerpc/pragma_power9.c @@ -1,7 +1,7 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ -/* { dg-require-effective-target lp64 } */ /* { dg-options "-mdejagnu-cpu=power6 -maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ +/* { dg-require-effective-target lp64 } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/swaps-p8-21.c b/gcc/testsuite/gcc.target/powerpc/swaps-p8-21.c index f50e2659528ca..e192ebffb73a5 100644 --- a/gcc/testsuite/gcc.target/powerpc/swaps-p8-21.c +++ b/gcc/testsuite/gcc.target/powerpc/swaps-p8-21.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-O2 -mdejagnu-cpu=power8 -maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* The expansion for vector character multiply introduces a vperm operation. This tests that changing the vperm mask allows us to remove all swaps diff --git a/gcc/testsuite/gcc.target/powerpc/unpack-vectorize-1.c b/gcc/testsuite/gcc.target/powerpc/unpack-vectorize-1.c index dceb5b89bd134..bef112bb10dce 100644 --- a/gcc/testsuite/gcc.target/powerpc/unpack-vectorize-1.c +++ b/gcc/testsuite/gcc.target/powerpc/unpack-vectorize-1.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2 -ftree-vectorize -fno-vect-cost-model -fno-unroll-loops -fdump-tree-vect-details" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Test if unpack vectorization succeeds for type signed/unsigned short and char. */ diff --git a/gcc/testsuite/gcc.target/powerpc/vec-cg.c b/gcc/testsuite/gcc.target/powerpc/vec-cg.c index c31d217d880ea..dd6bf3bb80507 100644 --- a/gcc/testsuite/gcc.target/powerpc/vec-cg.c +++ b/gcc/testsuite/gcc.target/powerpc/vec-cg.c @@ -4,8 +4,8 @@ etc. */ /* { dg-do compile { target powerpc*-*-* } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O0" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/vec-cmpne.c b/gcc/testsuite/gcc.target/powerpc/vec-cmpne.c index b57e0ac863850..ad93abdb9c37a 100644 --- a/gcc/testsuite/gcc.target/powerpc/vec-cmpne.c +++ b/gcc/testsuite/gcc.target/powerpc/vec-cmpne.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Test that the vec_cmpne builtin generates the expected Altivec instructions. */ diff --git a/gcc/testsuite/gcc.target/powerpc/vec-constvolatile.c b/gcc/testsuite/gcc.target/powerpc/vec-constvolatile.c index 07cbd5c291ad0..3b65cc1654ead 100644 --- a/gcc/testsuite/gcc.target/powerpc/vec-constvolatile.c +++ b/gcc/testsuite/gcc.target/powerpc/vec-constvolatile.c @@ -1,8 +1,8 @@ /* Test that const and volatile qualifiers can mix on vec_mul operands. */ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec -mvsx" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/vec-mult-char-1.c b/gcc/testsuite/gcc.target/powerpc/vec-mult-char-1.c index 4c9dbdc818848..c06bb4e9c76ef 100644 --- a/gcc/testsuite/gcc.target/powerpc/vec-mult-char-1.c +++ b/gcc/testsuite/gcc.target/powerpc/vec-mult-char-1.c @@ -1,6 +1,6 @@ /* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/vec-mult-char-2.c b/gcc/testsuite/gcc.target/powerpc/vec-mult-char-2.c index dcfa270a1ee2e..bffd50bc38301 100644 --- a/gcc/testsuite/gcc.target/powerpc/vec-mult-char-2.c +++ b/gcc/testsuite/gcc.target/powerpc/vec-mult-char-2.c @@ -1,6 +1,6 @@ /* { dg-do compile { target { powerpc*-*-* && vmx_hw } } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-options "-maltivec" } */ +/* { dg-require-effective-target powerpc_altivec } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/vec-rotate-1.c b/gcc/testsuite/gcc.target/powerpc/vec-rotate-1.c index 6fe96272dde29..e1260d11fd184 100644 --- a/gcc/testsuite/gcc.target/powerpc/vec-rotate-1.c +++ b/gcc/testsuite/gcc.target/powerpc/vec-rotate-1.c @@ -1,5 +1,5 @@ /* { dg-options "-O3 -maltivec" } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Check vectorizer can exploit vector rotation instructions on Power, mainly for the case rotation count is const number. diff --git a/gcc/testsuite/gcc.target/powerpc/vec-rotate-3.c b/gcc/testsuite/gcc.target/powerpc/vec-rotate-3.c index 373056256fcd5..a53e2b04eebfa 100644 --- a/gcc/testsuite/gcc.target/powerpc/vec-rotate-3.c +++ b/gcc/testsuite/gcc.target/powerpc/vec-rotate-3.c @@ -1,5 +1,5 @@ /* { dg-options "-O3 -maltivec" } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ +/* { dg-require-effective-target powerpc_altivec } */ /* Check vectorizer can exploit vector rotation instructions on Power, mainly for the case rotation count isn't const number. diff --git a/gcc/testsuite/gcc.target/powerpc/vec-shift.c b/gcc/testsuite/gcc.target/powerpc/vec-shift.c index 565324f3f3243..dcec88a8f863d 100644 --- a/gcc/testsuite/gcc.target/powerpc/vec-shift.c +++ b/gcc/testsuite/gcc.target/powerpc/vec-shift.c @@ -1,7 +1,7 @@ /* { dg-do compile { target { powerpc*-*-* } } } */ -/* { dg-require-effective-target powerpc_altivec_ok } */ /* { dg-skip-if "" { powerpc*-*-darwin* } } */ /* { dg-options "-mdejagnu-cpu=power7 -O2" } */ +/* { dg-require-effective-target powerpc_altivec } */ /* This used to ICE. During gimplification, "i" is widened to an unsigned int. We used to fail at expand time as we tried to cram an SImode item diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-load-1.c b/gcc/testsuite/gcc.target/riscv/amo-table-a-6-load-1.c deleted file mode 100644 index 3c79035e46d68..0000000000000 --- a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-load-1.c +++ /dev/null @@ -1,16 +0,0 @@ -/* { dg-do compile } */ -/* Verify that load mappings match Table A.6's recommended mapping. */ -/* { dg-options "-O3" } */ -/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ -/* { dg-final { check-function-bodies "**" "" } } */ - -/* -** foo: -** lw\ta[0-9]+,0\(a0\) -** sw\ta[0-9]+,0\(a1\) -** ret -*/ -void foo (int* bar, int* baz) -{ - __atomic_load(bar, baz, __ATOMIC_RELAXED); -} diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-load-2.c b/gcc/testsuite/gcc.target/riscv/amo-table-a-6-load-2.c deleted file mode 100644 index 7d74841846fac..0000000000000 --- a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-load-2.c +++ /dev/null @@ -1,17 +0,0 @@ -/* { dg-do compile } */ -/* Verify that load mappings match Table A.6's recommended mapping. */ -/* { dg-options "-O3" } */ -/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ -/* { dg-final { check-function-bodies "**" "" } } */ - -/* -** foo: -** lw\ta[0-9]+,0\(a0\) -** fence\tr,rw -** sw\ta[0-9]+,0\(a1\) -** ret -*/ -void foo (int* bar, int* baz) -{ - __atomic_load(bar, baz, __ATOMIC_ACQUIRE); -} diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-load-3.c b/gcc/testsuite/gcc.target/riscv/amo-table-a-6-load-3.c deleted file mode 100644 index ab95fa660d252..0000000000000 --- a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-load-3.c +++ /dev/null @@ -1,18 +0,0 @@ -/* { dg-do compile } */ -/* Verify that load mappings match Table A.6's recommended mapping. */ -/* { dg-options "-O3" } */ -/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ -/* { dg-final { check-function-bodies "**" "" } } */ - -/* -** foo: -** fence\trw,rw -** lw\ta[0-9]+,0\(a0\) -** fence\tr,rw -** sw\ta[0-9]+,0\(a1\) -** ret -*/ -void foo (int* bar, int* baz) -{ - __atomic_load(bar, baz, __ATOMIC_SEQ_CST); -} diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-store-1.c b/gcc/testsuite/gcc.target/riscv/amo-table-a-6-store-1.c deleted file mode 100644 index d852fddf03de5..0000000000000 --- a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-store-1.c +++ /dev/null @@ -1,16 +0,0 @@ -/* { dg-do compile } */ -/* Verify that store mappings match Table A.6's recommended mapping. */ -/* { dg-options "-O3" } */ -/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ -/* { dg-final { check-function-bodies "**" "" } } */ - -/* -** foo: -** lw\ta[0-9]+,0\(a1\) -** sw\ta[0-9]+,0\(a0\) -** ret -*/ -void foo (int* bar, int* baz) -{ - __atomic_store(bar, baz, __ATOMIC_RELAXED); -} diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-store-2.c b/gcc/testsuite/gcc.target/riscv/amo-table-a-6-store-2.c deleted file mode 100644 index ccb5e2af7cc16..0000000000000 --- a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-store-2.c +++ /dev/null @@ -1,17 +0,0 @@ -/* { dg-do compile } */ -/* Verify that store mappings match Table A.6's recommended mapping. */ -/* { dg-options "-O3" } */ -/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ -/* { dg-final { check-function-bodies "**" "" } } */ - -/* -** foo: -** lw\ta[0-9]+,0\(a1\) -** fence\trw,w -** sw\ta[0-9]+,0\(a0\) -** ret -*/ -void foo (int* bar, int* baz) -{ - __atomic_store(bar, baz, __ATOMIC_RELEASE); -} diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-store-compat-3.c b/gcc/testsuite/gcc.target/riscv/amo-table-a-6-store-compat-3.c deleted file mode 100644 index 761889f18cf9d..0000000000000 --- a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-store-compat-3.c +++ /dev/null @@ -1,18 +0,0 @@ -/* { dg-do compile } */ -/* Verify that store mapping are compatible with Table A.6 & A.7. */ -/* { dg-options "-O3" } */ -/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ -/* { dg-final { check-function-bodies "**" "" } } */ - -/* -** foo: -** lw\ta[0-9]+,0\(a1\) -** fence\trw,w -** sw\ta[0-9]+,0\(a0\) -** fence\trw,rw -** ret -*/ -void foo (int* bar, int* baz) -{ - __atomic_store(bar, baz, __ATOMIC_SEQ_CST); -} diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-load-1.c b/gcc/testsuite/gcc.target/riscv/amo-table-ztso-load-1.c deleted file mode 100644 index 631977985bd53..0000000000000 --- a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-load-1.c +++ /dev/null @@ -1,17 +0,0 @@ -/* { dg-do compile } */ -/* Verify that load mappings match the Ztso suggested mapping. */ -/* { dg-options "-O3" } */ -/* { dg-add-options riscv_ztso } */ -/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ -/* { dg-final { check-function-bodies "**" "" } } */ - -/* -** foo: -** lw\ta[0-9]+,0\(a0\) -** sw\ta[0-9]+,0\(a1\) -** ret -*/ -void foo (int* bar, int* baz) -{ - __atomic_load(bar, baz, __ATOMIC_RELAXED); -} diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-load-2.c b/gcc/testsuite/gcc.target/riscv/amo-table-ztso-load-2.c deleted file mode 100644 index 2c24f10fb44dc..0000000000000 --- a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-load-2.c +++ /dev/null @@ -1,17 +0,0 @@ -/* { dg-do compile } */ -/* Verify that load mappings match the Ztso suggested mapping. */ -/* { dg-options "-O3" } */ -/* { dg-add-options riscv_ztso } */ -/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ -/* { dg-final { check-function-bodies "**" "" } } */ - -/* -** foo: -** lw\ta[0-9]+,0\(a0\) -** sw\ta[0-9]+,0\(a1\) -** ret -*/ -void foo (int* bar, int* baz) -{ - __atomic_load(bar, baz, __ATOMIC_ACQUIRE); -} diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-load-3.c b/gcc/testsuite/gcc.target/riscv/amo-table-ztso-load-3.c deleted file mode 100644 index 7d2166d29c050..0000000000000 --- a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-load-3.c +++ /dev/null @@ -1,18 +0,0 @@ -/* { dg-do compile } */ -/* Verify that load mappings match the Ztso suggested mapping. */ -/* { dg-options "-O3" } */ -/* { dg-add-options riscv_ztso } */ -/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ -/* { dg-final { check-function-bodies "**" "" } } */ - -/* -** foo: -** fence\trw,rw -** lw\ta[0-9]+,0\(a0\) -** sw\ta[0-9]+,0\(a1\) -** ret -*/ -void foo (int* bar, int* baz) -{ - __atomic_load(bar, baz, __ATOMIC_SEQ_CST); -} diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-store-1.c b/gcc/testsuite/gcc.target/riscv/amo-table-ztso-store-1.c deleted file mode 100644 index 29a770285ef6d..0000000000000 --- a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-store-1.c +++ /dev/null @@ -1,17 +0,0 @@ -/* { dg-do compile } */ -/* Verify that store mappings match the Ztso suggested mapping. */ -/* { dg-options "-O3" } */ -/* { dg-add-options riscv_ztso } */ -/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ -/* { dg-final { check-function-bodies "**" "" } } */ - -/* -** foo: -** lw\ta[0-9]+,0\(a1\) -** sw\ta[0-9]+,0\(a0\) -** ret -*/ -void foo (int* bar, int* baz) -{ - __atomic_store(bar, baz, __ATOMIC_RELAXED); -} diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-store-2.c b/gcc/testsuite/gcc.target/riscv/amo-table-ztso-store-2.c deleted file mode 100644 index fb82360ad336f..0000000000000 --- a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-store-2.c +++ /dev/null @@ -1,17 +0,0 @@ -/* { dg-do compile } */ -/* Verify that store mappings match the Ztso suggested mapping. */ -/* { dg-options "-O3" } */ -/* { dg-add-options riscv_ztso } */ -/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ -/* { dg-final { check-function-bodies "**" "" } } */ - -/* -** foo: -** lw\ta[0-9]+,0\(a1\) -** sw\ta[0-9]+,0\(a0\) -** ret -*/ -void foo (int* bar, int* baz) -{ - __atomic_store(bar, baz, __ATOMIC_RELEASE); -} diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-store-3.c b/gcc/testsuite/gcc.target/riscv/amo-table-ztso-store-3.c deleted file mode 100644 index 88d8432d8c9bf..0000000000000 --- a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-store-3.c +++ /dev/null @@ -1,18 +0,0 @@ -/* { dg-do compile } */ -/* Verify that store mappings match the Ztso suggested mapping. */ -/* { dg-options "-O3" } */ -/* { dg-add-options riscv_ztso } */ -/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ -/* { dg-final { check-function-bodies "**" "" } } */ - -/* -** foo: -** lw\ta[0-9]+,0\(a1\) -** sw\ta[0-9]+,0\(a0\) -** fence\trw,rw -** ret -*/ -void foo (int* bar, int* baz) -{ - __atomic_store(bar, baz, __ATOMIC_SEQ_CST); -} diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-amo-add-1.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-amo-add-1.c similarity index 83% rename from gcc/testsuite/gcc.target/riscv/amo-table-a-6-amo-add-1.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-amo-add-1.c index 8ab1a02b40c6b..2e53abf28aa27 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-amo-add-1.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-amo-add-1.c @@ -1,7 +1,7 @@ /* { dg-do compile } */ /* Verify that atomic op mappings match Table A.6's recommended mapping. */ /* { dg-options "-O3" } */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zaamo } */ /* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ /* { dg-final { check-function-bodies "**" "" } } */ @@ -10,7 +10,7 @@ ** amoadd\.w\tzero,a1,0\(a0\) ** ret */ -void foo (int* bar, int* baz) +void foo (int* bar, int baz) { __atomic_add_fetch(bar, baz, __ATOMIC_RELAXED); } diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-amo-add-2.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-amo-add-2.c similarity index 83% rename from gcc/testsuite/gcc.target/riscv/amo-table-a-6-amo-add-2.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-amo-add-2.c index a5a841abdcd88..14d6b7e4b1b52 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-amo-add-2.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-amo-add-2.c @@ -1,7 +1,7 @@ /* { dg-do compile } */ /* Verify that atomic op mappings match Table A.6's recommended mapping. */ /* { dg-options "-O3" } */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zaamo } */ /* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ /* { dg-final { check-function-bodies "**" "" } } */ @@ -10,7 +10,7 @@ ** amoadd\.w\.aq\tzero,a1,0\(a0\) ** ret */ -void foo (int* bar, int* baz) +void foo (int* bar, int baz) { __atomic_add_fetch(bar, baz, __ATOMIC_ACQUIRE); } diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-amo-add-3.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-amo-add-3.c similarity index 83% rename from gcc/testsuite/gcc.target/riscv/amo-table-a-6-amo-add-3.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-amo-add-3.c index f523821b65835..937a00daf4cb5 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-amo-add-3.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-amo-add-3.c @@ -1,7 +1,7 @@ /* { dg-do compile } */ /* Verify that atomic op mappings match Table A.6's recommended mapping. */ /* { dg-options "-O3" } */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zaamo } */ /* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ /* { dg-final { check-function-bodies "**" "" } } */ @@ -10,7 +10,7 @@ ** amoadd\.w\.rl\tzero,a1,0\(a0\) ** ret */ -void foo (int* bar, int* baz) +void foo (int* bar, int baz) { __atomic_add_fetch(bar, baz, __ATOMIC_RELEASE); } diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-amo-add-4.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-amo-add-4.c similarity index 83% rename from gcc/testsuite/gcc.target/riscv/amo-table-a-6-amo-add-4.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-amo-add-4.c index f1561b52c894d..7d7f4e11dd411 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-amo-add-4.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-amo-add-4.c @@ -1,7 +1,7 @@ /* { dg-do compile } */ /* Verify that atomic op mappings match Table A.6's recommended mapping. */ /* { dg-options "-O3" } */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zaamo } */ /* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ /* { dg-final { check-function-bodies "**" "" } } */ @@ -10,7 +10,7 @@ ** amoadd\.w\.aqrl\tzero,a1,0\(a0\) ** ret */ -void foo (int* bar, int* baz) +void foo (int* bar, int baz) { __atomic_add_fetch(bar, baz, __ATOMIC_ACQ_REL); } diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-amo-add-5.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-amo-add-5.c similarity index 83% rename from gcc/testsuite/gcc.target/riscv/amo-table-a-6-amo-add-5.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-amo-add-5.c index 81f876ee62589..e5cf1e2e9cf6b 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-amo-add-5.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-amo-add-5.c @@ -1,7 +1,7 @@ /* { dg-do compile } */ /* Verify that atomic op mappings match Table A.6's recommended mapping. */ /* { dg-options "-O3" } */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zaamo } */ /* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ /* { dg-final { check-function-bodies "**" "" } } */ @@ -10,7 +10,7 @@ ** amoadd\.w\.aqrl\tzero,a1,0\(a0\) ** ret */ -void foo (int* bar, int* baz) +void foo (int* bar, int baz) { __atomic_add_fetch(bar, baz, __ATOMIC_SEQ_CST); } diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-compare-exchange-1.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-compare-exchange-1.c similarity index 90% rename from gcc/testsuite/gcc.target/riscv/amo-table-a-6-compare-exchange-1.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-compare-exchange-1.c index dc445f0316ac2..4917cd6bd2b6f 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-compare-exchange-1.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-compare-exchange-1.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* Verify that compare exchange mappings match Table A.6's recommended mapping. */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zalrsc } */ /* { dg-final { scan-assembler-times "lr.w\t" 1 } } */ /* { dg-final { scan-assembler-times "sc.w\t" 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-compare-exchange-2.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-compare-exchange-2.c similarity index 90% rename from gcc/testsuite/gcc.target/riscv/amo-table-a-6-compare-exchange-2.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-compare-exchange-2.c index 7e8ab7bb5ef15..121936507e3d4 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-compare-exchange-2.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-compare-exchange-2.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* Verify that compare exchange mappings match Table A.6's recommended mapping. */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zalrsc } */ /* { dg-final { scan-assembler-times "lr.w.aq\t" 1 } } */ /* { dg-final { scan-assembler-times "sc.w\t" 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-compare-exchange-3.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-compare-exchange-3.c similarity index 90% rename from gcc/testsuite/gcc.target/riscv/amo-table-a-6-compare-exchange-3.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-compare-exchange-3.c index 4cb6c42221372..649c7d2b1feb6 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-compare-exchange-3.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-compare-exchange-3.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* Verify that compare exchange mappings match Table A.6's recommended mapping. */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zalrsc } */ /* { dg-final { scan-assembler-times "lr.w.aq\t" 1 } } */ /* { dg-final { scan-assembler-times "sc.w\t" 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-compare-exchange-4.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-compare-exchange-4.c similarity index 90% rename from gcc/testsuite/gcc.target/riscv/amo-table-a-6-compare-exchange-4.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-compare-exchange-4.c index da81c34b92c5d..5f7fdeb1b21e5 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-compare-exchange-4.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-compare-exchange-4.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* Verify that compare exchange mappings match Table A.6's recommended mapping. */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zalrsc } */ /* { dg-final { scan-assembler-times "lr.w\t" 1 } } */ /* { dg-final { scan-assembler-times "sc.w.rl\t" 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-compare-exchange-5.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-compare-exchange-5.c similarity index 90% rename from gcc/testsuite/gcc.target/riscv/amo-table-a-6-compare-exchange-5.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-compare-exchange-5.c index bb16ccc754ccf..f4bd7d6d84280 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-compare-exchange-5.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-compare-exchange-5.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* Verify that compare exchange mappings match Table A.6's recommended mapping. */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zalrsc } */ /* { dg-final { scan-assembler-times "lr.w.aqrl\t" 1 } } */ /* { dg-final { scan-assembler-times "sc.w.rl\t" 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-compare-exchange-6.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-compare-exchange-6.c similarity index 91% rename from gcc/testsuite/gcc.target/riscv/amo-table-a-6-compare-exchange-6.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-compare-exchange-6.c index 0f3f0b49d9515..154764425ae9e 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-compare-exchange-6.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-compare-exchange-6.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* Verify that compare exchange mappings match Table A.6's recommended mapping. */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zalrsc } */ /* Mixed mappings need to be unioned. */ /* { dg-final { scan-assembler-times "lr.w.aq\t" 1 } } */ /* { dg-final { scan-assembler-times "sc.w.rl\t" 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-compare-exchange-7.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-compare-exchange-7.c similarity index 90% rename from gcc/testsuite/gcc.target/riscv/amo-table-a-6-compare-exchange-7.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-compare-exchange-7.c index d51de56cc7849..1671254091934 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-compare-exchange-7.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-compare-exchange-7.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* Verify that compare exchange mappings match Table A.6's recommended mapping. */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zalrsc } */ /* { dg-final { scan-assembler-times "lr.w.aqrl\t" 1 } } */ /* { dg-final { scan-assembler-times "sc.w.rl\t" 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-fence-1.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-fence-1.c similarity index 100% rename from gcc/testsuite/gcc.target/riscv/amo-table-a-6-fence-1.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-fence-1.c diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-fence-2.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-fence-2.c similarity index 100% rename from gcc/testsuite/gcc.target/riscv/amo-table-a-6-fence-2.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-fence-2.c diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-fence-3.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-fence-3.c similarity index 100% rename from gcc/testsuite/gcc.target/riscv/amo-table-a-6-fence-3.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-fence-3.c diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-fence-4.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-fence-4.c similarity index 100% rename from gcc/testsuite/gcc.target/riscv/amo-table-a-6-fence-4.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-fence-4.c diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-fence-5.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-fence-5.c similarity index 100% rename from gcc/testsuite/gcc.target/riscv/amo-table-a-6-fence-5.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-fence-5.c diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-load-1.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-load-1.c new file mode 100644 index 0000000000000..948fece612512 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-load-1.c @@ -0,0 +1,60 @@ +/* { dg-do compile } */ +/* Verify that load mappings match Table A.6's recommended mapping. */ +/* { dg-options "-O3" } */ +/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +/* +** atomic_load_long_relaxed: +** l[wd]\t[atx][0-9]+,0\(a0\) +** s[wd]\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_long_relaxed (long* bar, long* baz) +{ + __atomic_load(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_load_int_relaxed: +** lw\t[atx][0-9]+,0\(a0\) +** sw\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_int_relaxed (int* bar, int* baz) +{ + __atomic_load(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_load_short_relaxed: +** lh\t[atx][0-9]+,0\(a0\) +** sh\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_short_relaxed (short* bar, short* baz) +{ + __atomic_load(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_load_char_relaxed: +** lb\t[atx][0-9]+,0\(a0\) +** sb\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_char_relaxed (char* bar, char* baz) +{ + __atomic_load(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_load_bool_relaxed: +** lb\t[atx][0-9]+,0\(a0\) +** sb\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_bool_relaxed (_Bool* bar, _Bool* baz) +{ + __atomic_load(bar, baz, __ATOMIC_RELAXED); +} diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-load-2.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-load-2.c new file mode 100644 index 0000000000000..e855db9b761c9 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-load-2.c @@ -0,0 +1,65 @@ +/* { dg-do compile } */ +/* Verify that load mappings match Table A.6's recommended mapping. */ +/* { dg-options "-O3" } */ +/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +/* +** atomic_load_long_acquire: +** l[wd]\t[atx][0-9]+,0\(a0\) +** fence\tr,rw +** s[wd]\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_long_acquire (long* bar, long* baz) +{ + __atomic_load(bar, baz, __ATOMIC_ACQUIRE); +} + +/* +** atomic_load_int_acquire: +** lw\t[atx][0-9]+,0\(a0\) +** fence\tr,rw +** sw\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_int_acquire (int* bar, int* baz) +{ + __atomic_load(bar, baz, __ATOMIC_ACQUIRE); +} + +/* +** atomic_load_short_acquire: +** lh\t[atx][0-9]+,0\(a0\) +** fence\tr,rw +** sh\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_short_acquire (short* bar, short* baz) +{ + __atomic_load(bar, baz, __ATOMIC_ACQUIRE); +} + +/* +** atomic_load_char_acquire: +** lb\t[atx][0-9]+,0\(a0\) +** fence\tr,rw +** sb\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_char_acquire (char* bar, char* baz) +{ + __atomic_load(bar, baz, __ATOMIC_ACQUIRE); +} + +/* +** atomic_load_bool_acquire: +** lb\t[atx][0-9]+,0\(a0\) +** fence\tr,rw +** sb\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_bool_acquire (_Bool* bar, _Bool* baz) +{ + __atomic_load(bar, baz, __ATOMIC_ACQUIRE); +} diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-load-3.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-load-3.c new file mode 100644 index 0000000000000..6e79ca72abc7a --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-load-3.c @@ -0,0 +1,70 @@ +/* { dg-do compile } */ +/* Verify that load mappings match Table A.6's recommended mapping. */ +/* { dg-options "-O3" } */ +/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +/* +** atomic_load_long_seq_cst: +** fence\trw,rw +** l[wd]\t[atx][0-9]+,0\(a0\) +** fence\tr,rw +** s[wd]\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_long_seq_cst (long* bar, long* baz) +{ + __atomic_load(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_load_int_seq_cst: +** fence\trw,rw +** lw\t[atx][0-9]+,0\(a0\) +** fence\tr,rw +** sw\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_int_seq_cst (int* bar, int* baz) +{ + __atomic_load(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_load_short_seq_cst: +** fence\trw,rw +** lh\t[atx][0-9]+,0\(a0\) +** fence\tr,rw +** sh\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_short_seq_cst (short* bar, short* baz) +{ + __atomic_load(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_load_char_seq_cst: +** fence\trw,rw +** lb\t[atx][0-9]+,0\(a0\) +** fence\tr,rw +** sb\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_char_seq_cst (char* bar, char* baz) +{ + __atomic_load(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_load_bool_seq_cst: +** fence\trw,rw +** lb\t[atx][0-9]+,0\(a0\) +** fence\tr,rw +** sb\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_bool_seq_cst (_Bool* bar, _Bool* baz) +{ + __atomic_load(bar, baz, __ATOMIC_SEQ_CST); +} diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-store-1.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-store-1.c new file mode 100644 index 0000000000000..ee7e7dbc8ee2c --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-store-1.c @@ -0,0 +1,60 @@ +/* { dg-do compile } */ +/* Verify that store mappings match Table A.6's recommended mapping. */ +/* { dg-options "-O3" } */ +/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +/* +** atomic_store_long_relaxed: +** l[wd]\t[atx][0-9]+,0\(a1\) +** s[wd]\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_long_relaxed (long* bar, long* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_store_int_relaxed: +** lw\t[atx][0-9]+,0\(a1\) +** sw\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_int_relaxed (int* bar, int* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_store_short_relaxed: +** lhu\t[atx][0-9]+,0\(a1\) +** sh\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_short_relaxed (short* bar, short* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_store_char_relaxed: +** lbu\t[atx][0-9]+,0\(a1\) +** sb\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_char_relaxed (char* bar, char* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_store_bool_relaxed: +** lbu\t[atx][0-9]+,0\(a1\) +** sb\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_bool_relaxed (_Bool* bar, _Bool* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELAXED); +} diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-store-2.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-store-2.c new file mode 100644 index 0000000000000..5110512e1ad64 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-store-2.c @@ -0,0 +1,65 @@ +/* { dg-do compile } */ +/* Verify that store mappings match Table A.6's recommended mapping. */ +/* { dg-options "-O3" } */ +/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +/* +** atomic_store_long_release: +** l[wd]\t[atx][0-9]+,0\(a1\) +** fence\trw,w +** s[wd]\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_long_release (long* bar, long* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELEASE); +} + +/* +** atomic_store_int_release: +** lw\t[atx][0-9]+,0\(a1\) +** fence\trw,w +** sw\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_int_release (int* bar, int* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELEASE); +} + +/* +** atomic_store_short_release: +** lhu\t[atx][0-9]+,0\(a1\) +** fence\trw,w +** sh\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_short_release (short* bar, short* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELEASE); +} + +/* +** atomic_store_char_release: +** lbu\t[atx][0-9]+,0\(a1\) +** fence\trw,w +** sb\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_char_release (char* bar, char* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELEASE); +} + +/* +** atomic_store_bool_release: +** lbu\t[atx][0-9]+,0\(a1\) +** fence\trw,w +** sb\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_bool_release (_Bool* bar, _Bool* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELEASE); +} diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-store-compat-3.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-store-compat-3.c new file mode 100644 index 0000000000000..016e5dec87d40 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-store-compat-3.c @@ -0,0 +1,70 @@ +/* { dg-do compile } */ +/* Verify that store mapping are compatible with Table A.6 & A.7. */ +/* { dg-options "-O3" } */ +/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +/* +** atomic_store_long_seq_cst: +** l[wd]\t[atx][0-9]+,0\(a1\) +** fence\trw,w +** s[wd]\t[atx][0-9]+,0\(a0\) +** fence\trw,rw +** ret +*/ +void atomic_store_long_seq_cst (long* bar, long* baz) +{ + __atomic_store(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_store_int_seq_cst: +** lw\t[atx][0-9]+,0\(a1\) +** fence\trw,w +** sw\t[atx][0-9]+,0\(a0\) +** fence\trw,rw +** ret +*/ +void atomic_store_int_seq_cst (int* bar, int* baz) +{ + __atomic_store(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_store_short_seq_cst: +** lhu\t[atx][0-9]+,0\(a1\) +** fence\trw,w +** sh\t[atx][0-9]+,0\(a0\) +** fence\trw,rw +** ret +*/ +void atomic_store_short_seq_cst (short* bar, short* baz) +{ + __atomic_store(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_store_char_seq_cst: +** lbu\t[atx][0-9]+,0\(a1\) +** fence\trw,w +** sb\t[atx][0-9]+,0\(a0\) +** fence\trw,rw +** ret +*/ +void atomic_store_char_seq_cst (char* bar, char* baz) +{ + __atomic_store(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_store_bool_seq_cst: +** lbu\t[atx][0-9]+,0\(a1\) +** fence\trw,w +** sb\t[atx][0-9]+,0\(a0\) +** fence\trw,rw +** ret +*/ +void atomic_store_bool_seq_cst (_Bool* bar, _Bool* baz) +{ + __atomic_store(bar, baz, __ATOMIC_SEQ_CST); +} diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-subword-amo-add-1.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-1.c similarity index 79% rename from gcc/testsuite/gcc.target/riscv/amo-table-a-6-subword-amo-add-1.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-1.c index ca8aa715bed05..348b9c8db9c16 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-subword-amo-add-1.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-1.c @@ -1,10 +1,10 @@ /* { dg-do compile } */ /* Verify that subword atomic op mappings match Table A.6's recommended mapping. */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zalrsc } */ /* { dg-final { scan-assembler-times "lr.w\t" 1 } } */ /* { dg-final { scan-assembler-times "sc.w\t" 1 } } */ -void foo (short* bar, short* baz) +void foo (short* bar, short baz) { __atomic_add_fetch(bar, baz, __ATOMIC_RELAXED); } diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-subword-amo-add-2.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-2.c similarity index 79% rename from gcc/testsuite/gcc.target/riscv/amo-table-a-6-subword-amo-add-2.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-2.c index e64759a54aeec..3101158068484 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-subword-amo-add-2.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-2.c @@ -1,10 +1,10 @@ /* { dg-do compile } */ /* Verify that subword atomic op mappings match Table A.6's recommended mapping. */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zalrsc } */ /* { dg-final { scan-assembler-times "lr.w.aq\t" 1 } } */ /* { dg-final { scan-assembler-times "sc.w\t" 1 } } */ -void foo (short* bar, short* baz) +void foo (short* bar, short baz) { __atomic_add_fetch(bar, baz, __ATOMIC_ACQUIRE); } diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-subword-amo-add-3.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-3.c similarity index 79% rename from gcc/testsuite/gcc.target/riscv/amo-table-a-6-subword-amo-add-3.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-3.c index 9d3f69264fa57..38bedcd6b41de 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-subword-amo-add-3.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-3.c @@ -1,10 +1,10 @@ /* { dg-do compile } */ /* Verify that subword atomic op mappings match Table A.6's recommended mapping. */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zalrsc } */ /* { dg-final { scan-assembler-times "lr.w\t" 1 } } */ /* { dg-final { scan-assembler-times "sc.w.rl\t" 1 } } */ -void foo (short* bar, short* baz) +void foo (short* bar, short baz) { __atomic_add_fetch(bar, baz, __ATOMIC_RELEASE); } diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-subword-amo-add-4.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-4.c similarity index 79% rename from gcc/testsuite/gcc.target/riscv/amo-table-a-6-subword-amo-add-4.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-4.c index ba32ed59c2fe8..d69610e2d9ed6 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-subword-amo-add-4.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-4.c @@ -1,10 +1,10 @@ /* { dg-do compile } */ /* Verify that subword atomic op mappings match Table A.6's recommended mapping. */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zalrsc } */ /* { dg-final { scan-assembler-times "lr.w.aq\t" 1 } } */ /* { dg-final { scan-assembler-times "sc.w.rl\t" 1 } } */ -void foo (short* bar, short* baz) +void foo (short* bar, short baz) { __atomic_add_fetch(bar, baz, __ATOMIC_ACQ_REL); } diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-subword-amo-add-5.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-5.c similarity index 79% rename from gcc/testsuite/gcc.target/riscv/amo-table-a-6-subword-amo-add-5.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-5.c index f9be8c5e6281a..976f8909bdda8 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-a-6-subword-amo-add-5.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-subword-amo-add-5.c @@ -1,10 +1,10 @@ /* { dg-do compile } */ /* Verify that subword atomic op mappings match Table A.6's recommended mapping. */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zalrsc } */ /* { dg-final { scan-assembler-times "lr.w.aqrl\t" 1 } } */ /* { dg-final { scan-assembler-times "sc.w.rl\t" 1 } } */ -void foo (short* bar, short* baz) +void foo (short* bar, short baz) { __atomic_add_fetch(bar, baz, __ATOMIC_SEQ_CST); } diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-amo-add-1.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-amo-add-1.c similarity index 84% rename from gcc/testsuite/gcc.target/riscv/amo-table-ztso-amo-add-1.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-amo-add-1.c index a9edc33ff39df..000407a25830a 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-amo-add-1.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-amo-add-1.c @@ -1,7 +1,7 @@ /* { dg-do compile } */ /* Verify that atomic op mappings match the Ztso suggested mapping. */ /* { dg-options "-O3" } */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zaamo } */ /* { dg-add-options riscv_ztso } */ /* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ /* { dg-final { check-function-bodies "**" "" } } */ @@ -11,7 +11,7 @@ ** amoadd\.w\tzero,a1,0\(a0\) ** ret */ -void foo (int* bar, int* baz) +void foo (int* bar, int baz) { __atomic_add_fetch(bar, baz, __ATOMIC_RELAXED); } diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-amo-add-2.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-amo-add-2.c similarity index 84% rename from gcc/testsuite/gcc.target/riscv/amo-table-ztso-amo-add-2.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-amo-add-2.c index ad843402bcc75..3e441cadbf34f 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-amo-add-2.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-amo-add-2.c @@ -1,7 +1,7 @@ /* { dg-do compile } */ /* Verify that atomic op mappings the Ztso suggested mapping. */ /* { dg-options "-O3" } */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zaamo } */ /* { dg-add-options riscv_ztso } */ /* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ /* { dg-final { check-function-bodies "**" "" } } */ @@ -11,7 +11,7 @@ ** amoadd\.w\tzero,a1,0\(a0\) ** ret */ -void foo (int* bar, int* baz) +void foo (int* bar, int baz) { __atomic_add_fetch(bar, baz, __ATOMIC_ACQUIRE); } diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-amo-add-3.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-amo-add-3.c similarity index 84% rename from gcc/testsuite/gcc.target/riscv/amo-table-ztso-amo-add-3.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-amo-add-3.c index bdae5bb83a60c..8af1a2f79a4a5 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-amo-add-3.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-amo-add-3.c @@ -1,7 +1,7 @@ /* { dg-do compile } */ /* Verify that atomic op mappings match the Ztso suggested mapping. */ /* { dg-options "-O3" } */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zaamo } */ /* { dg-add-options riscv_ztso } */ /* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ /* { dg-final { check-function-bodies "**" "" } } */ @@ -11,7 +11,7 @@ ** amoadd\.w\tzero,a1,0\(a0\) ** ret */ -void foo (int* bar, int* baz) +void foo (int* bar, int baz) { __atomic_add_fetch(bar, baz, __ATOMIC_RELEASE); } diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-amo-add-4.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-amo-add-4.c similarity index 84% rename from gcc/testsuite/gcc.target/riscv/amo-table-ztso-amo-add-4.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-amo-add-4.c index 815a72f1e5648..0b3a7e5968965 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-amo-add-4.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-amo-add-4.c @@ -1,7 +1,7 @@ /* { dg-do compile } */ /* Verify that atomic op mappings match the Ztso suggested mapping. */ /* { dg-options "-O3" } */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zaamo } */ /* { dg-add-options riscv_ztso } */ /* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ /* { dg-final { check-function-bodies "**" "" } } */ @@ -11,7 +11,7 @@ ** amoadd\.w\tzero,a1,0\(a0\) ** ret */ -void foo (int* bar, int* baz) +void foo (int* bar, int baz) { __atomic_add_fetch(bar, baz, __ATOMIC_ACQ_REL); } diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-amo-add-5.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-amo-add-5.c similarity index 84% rename from gcc/testsuite/gcc.target/riscv/amo-table-ztso-amo-add-5.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-amo-add-5.c index eda6f01096ea7..f189827d6cf83 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-amo-add-5.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-amo-add-5.c @@ -1,7 +1,7 @@ /* { dg-do compile } */ /* Verify that atomic op mappings match the Ztso suggested mapping. */ /* { dg-options "-O3" } */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zaamo } */ /* { dg-add-options riscv_ztso } */ /* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ /* { dg-final { check-function-bodies "**" "" } } */ @@ -11,7 +11,7 @@ ** amoadd\.w\tzero,a1,0\(a0\) ** ret */ -void foo (int* bar, int* baz) +void foo (int* bar, int baz) { __atomic_add_fetch(bar, baz, __ATOMIC_SEQ_CST); } diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-compare-exchange-1.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-compare-exchange-1.c similarity index 90% rename from gcc/testsuite/gcc.target/riscv/amo-table-ztso-compare-exchange-1.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-compare-exchange-1.c index b6315c45e85ed..46a9f0c918a49 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-compare-exchange-1.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-compare-exchange-1.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* Verify that compare exchange mappings match the Ztso suggested mapping. */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zalrsc } */ /* { dg-add-options riscv_ztso } */ /* { dg-final { scan-assembler-times "lr.w\t" 1 } } */ /* { dg-final { scan-assembler-times "sc.w\t" 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-compare-exchange-2.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-compare-exchange-2.c similarity index 90% rename from gcc/testsuite/gcc.target/riscv/amo-table-ztso-compare-exchange-2.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-compare-exchange-2.c index e487184f6cf9d..20e325f2e7cc0 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-compare-exchange-2.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-compare-exchange-2.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* Verify that compare exchange mappings match the Ztso suggested mapping. */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zalrsc } */ /* { dg-add-options riscv_ztso } */ /* { dg-final { scan-assembler-times "lr.w\t" 1 } } */ /* { dg-final { scan-assembler-times "sc.w\t" 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-compare-exchange-3.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-compare-exchange-3.c similarity index 90% rename from gcc/testsuite/gcc.target/riscv/amo-table-ztso-compare-exchange-3.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-compare-exchange-3.c index e9c925f0923c6..0a443b461f326 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-compare-exchange-3.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-compare-exchange-3.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* Verify that compare exchange mappings match the Ztso suggested mapping. */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zalrsc } */ /* { dg-add-options riscv_ztso } */ /* { dg-final { scan-assembler-times "lr.w\t" 1 } } */ /* { dg-final { scan-assembler-times "sc.w\t" 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-compare-exchange-4.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-compare-exchange-4.c similarity index 90% rename from gcc/testsuite/gcc.target/riscv/amo-table-ztso-compare-exchange-4.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-compare-exchange-4.c index 6b4545596339f..35e01cdc8be05 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-compare-exchange-4.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-compare-exchange-4.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* Verify that compare exchange mappings match the Ztso suggested mapping. */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zalrsc } */ /* { dg-add-options riscv_ztso } */ /* { dg-final { scan-assembler-times "lr.w\t" 1 } } */ /* { dg-final { scan-assembler-times "sc.w\t" 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-compare-exchange-5.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-compare-exchange-5.c similarity index 91% rename from gcc/testsuite/gcc.target/riscv/amo-table-ztso-compare-exchange-5.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-compare-exchange-5.c index 02c9f0ada778e..cd884931bdfb4 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-compare-exchange-5.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-compare-exchange-5.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* Verify that compare exchange mappings match the Ztso suggested mapping. */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zalrsc } */ /* { dg-add-options riscv_ztso } */ /* { dg-final { scan-assembler-times "lr.w.aqrl\t" 1 } } */ /* { dg-final { scan-assembler-times "sc.w.rl\t" 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-compare-exchange-6.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-compare-exchange-6.c similarity index 90% rename from gcc/testsuite/gcc.target/riscv/amo-table-ztso-compare-exchange-6.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-compare-exchange-6.c index 75abd5d3dfbde..7da3b1dce48d6 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-compare-exchange-6.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-compare-exchange-6.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* Verify that compare exchange mappings match the Ztso suggested mapping. */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zalrsc } */ /* { dg-add-options riscv_ztso } */ /* { dg-final { scan-assembler-times "lr.w\t" 1 } } */ /* { dg-final { scan-assembler-times "sc.w\t" 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-compare-exchange-7.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-compare-exchange-7.c similarity index 91% rename from gcc/testsuite/gcc.target/riscv/amo-table-ztso-compare-exchange-7.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-compare-exchange-7.c index 33928c0eac416..53f6e6ace0bed 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-compare-exchange-7.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-compare-exchange-7.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* Verify that compare exchange mappings match the Ztso suggested mapping. */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zalrsc } */ /* { dg-add-options riscv_ztso } */ /* { dg-final { scan-assembler-times "lr.w.aqrl\t" 1 } } */ /* { dg-final { scan-assembler-times "sc.w.rl\t" 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-fence-1.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-fence-1.c similarity index 100% rename from gcc/testsuite/gcc.target/riscv/amo-table-ztso-fence-1.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-fence-1.c diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-fence-2.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-fence-2.c similarity index 100% rename from gcc/testsuite/gcc.target/riscv/amo-table-ztso-fence-2.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-fence-2.c diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-fence-3.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-fence-3.c similarity index 100% rename from gcc/testsuite/gcc.target/riscv/amo-table-ztso-fence-3.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-fence-3.c diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-fence-4.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-fence-4.c similarity index 100% rename from gcc/testsuite/gcc.target/riscv/amo-table-ztso-fence-4.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-fence-4.c diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-fence-5.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-fence-5.c similarity index 100% rename from gcc/testsuite/gcc.target/riscv/amo-table-ztso-fence-5.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-fence-5.c diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-load-1.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-load-1.c new file mode 100644 index 0000000000000..ef5dee6ee60e0 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-load-1.c @@ -0,0 +1,61 @@ +/* { dg-do compile } */ +/* Verify that load mappings match the Ztso suggested mapping. */ +/* { dg-options "-O3" } */ +/* { dg-add-options riscv_ztso } */ +/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +/* +** atomic_load_long_relaxed: +** l[wd]\t[atx][0-9]+,0\(a0\) +** s[wd]\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_long_relaxed (long* bar, long* baz) +{ + __atomic_load(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_load_int_relaxed: +** lw\t[atx][0-9]+,0\(a0\) +** sw\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_int_relaxed (int* bar, int* baz) +{ + __atomic_load(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_load_short_relaxed: +** lh\t[atx][0-9]+,0\(a0\) +** sh\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_short_relaxed (short* bar, short* baz) +{ + __atomic_load(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_load_char_relaxed: +** lb\t[atx][0-9]+,0\(a0\) +** sb\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_char_relaxed (char* bar, char* baz) +{ + __atomic_load(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_load_bool_relaxed: +** lb\t[atx][0-9]+,0\(a0\) +** sb\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_bool_relaxed (_Bool* bar, _Bool* baz) +{ + __atomic_load(bar, baz, __ATOMIC_RELAXED); +} diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-load-2.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-load-2.c new file mode 100644 index 0000000000000..4e94191812b1e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-load-2.c @@ -0,0 +1,61 @@ +/* { dg-do compile } */ +/* Verify that load mappings match the Ztso suggested mapping. */ +/* { dg-options "-O3" } */ +/* { dg-add-options riscv_ztso } */ +/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +/* +** atomic_load_long_acquire: +** l[wd]\t[atx][0-9]+,0\(a0\) +** s[wd]\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_long_acquire (long* bar, long* baz) +{ + __atomic_load(bar, baz, __ATOMIC_ACQUIRE); +} + +/* +** atomic_load_int_acquire: +** lw\t[atx][0-9]+,0\(a0\) +** sw\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_int_acquire (int* bar, int* baz) +{ + __atomic_load(bar, baz, __ATOMIC_ACQUIRE); +} + +/* +** atomic_load_short_acquire: +** lh\t[atx][0-9]+,0\(a0\) +** sh\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_short_acquire (short* bar, short* baz) +{ + __atomic_load(bar, baz, __ATOMIC_ACQUIRE); +} + +/* +** atomic_load_char_acquire: +** lb\t[atx][0-9]+,0\(a0\) +** sb\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_char_acquire (char* bar, char* baz) +{ + __atomic_load(bar, baz, __ATOMIC_ACQUIRE); +} + +/* +** atomic_load_bool_acquire: +** lb\t[atx][0-9]+,0\(a0\) +** sb\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_bool_acquire (_Bool* bar, _Bool* baz) +{ + __atomic_load(bar, baz, __ATOMIC_ACQUIRE); +} diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-load-3.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-load-3.c new file mode 100644 index 0000000000000..93cd8bb909cc2 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-load-3.c @@ -0,0 +1,66 @@ +/* { dg-do compile } */ +/* Verify that load mappings match the Ztso suggested mapping. */ +/* { dg-options "-O3" } */ +/* { dg-add-options riscv_ztso } */ +/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +/* +** atomic_load_long_seq_cst: +** fence\trw,rw +** l[wd]\t[atx][0-9]+,0\(a0\) +** s[wd]\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_long_seq_cst (long* bar, long* baz) +{ + __atomic_load(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_load_int_seq_cst: +** fence\trw,rw +** lw\t[atx][0-9]+,0\(a0\) +** sw\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_int_seq_cst (int* bar, int* baz) +{ + __atomic_load(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_load_short_seq_cst: +** fence\trw,rw +** lh\t[atx][0-9]+,0\(a0\) +** sh\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_short_seq_cst (short* bar, short* baz) +{ + __atomic_load(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_load_char_seq_cst: +** fence\trw,rw +** lb\t[atx][0-9]+,0\(a0\) +** sb\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_char_seq_cst (char* bar, char* baz) +{ + __atomic_load(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_load_bool_seq_cst: +** fence\trw,rw +** lb\t[atx][0-9]+,0\(a0\) +** sb\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_bool_seq_cst (_Bool* bar, _Bool* baz) +{ + __atomic_load(bar, baz, __ATOMIC_SEQ_CST); +} diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-store-1.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-store-1.c new file mode 100644 index 0000000000000..2f46470ae153b --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-store-1.c @@ -0,0 +1,61 @@ +/* { dg-do compile } */ +/* Verify that store mappings match the Ztso suggested mapping. */ +/* { dg-options "-O3" } */ +/* { dg-add-options riscv_ztso } */ +/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +/* +** atomic_store_long_relaxed: +** l[wd]\t[atx][0-9]+,0\(a1\) +** s[wd]\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_long_relaxed (long* bar, long* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_store_int_relaxed: +** lw\t[atx][0-9]+,0\(a1\) +** sw\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_int_relaxed (int* bar, int* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_store_short_relaxed: +** lhu\t[atx][0-9]+,0\(a1\) +** sh\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_short_relaxed (short* bar, short* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_store_char_relaxed: +** lbu\t[atx][0-9]+,0\(a1\) +** sb\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_char_relaxed (char* bar, char* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_store_bool_relaxed: +** lbu\t[atx][0-9]+,0\(a1\) +** sb\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_bool_relaxed (_Bool* bar, _Bool* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELAXED); +} diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-store-2.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-store-2.c new file mode 100644 index 0000000000000..dd2db3a787867 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-store-2.c @@ -0,0 +1,61 @@ +/* { dg-do compile } */ +/* Verify that store mappings match the Ztso suggested mapping. */ +/* { dg-options "-O3" } */ +/* { dg-add-options riscv_ztso } */ +/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +/* +** atomic_store_long_release: +** l[wd]\t[atx][0-9]+,0\(a1\) +** s[wd]\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_long_release (long* bar, long* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELEASE); +} + +/* +** atomic_store_int_release: +** lw\t[atx][0-9]+,0\(a1\) +** sw\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_int_release (int* bar, int* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELEASE); +} + +/* +** atomic_store_short_release: +** lhu\t[atx][0-9]+,0\(a1\) +** sh\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_short_release (short* bar, short* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELEASE); +} + +/* +** atomic_store_char_release: +** lbu\t[atx][0-9]+,0\(a1\) +** sb\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_char_release (char* bar, char* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELEASE); +} + +/* +** atomic_store_bool_release: +** lbu\t[atx][0-9]+,0\(a1\) +** sb\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_bool_release (_Bool* bar, _Bool* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELEASE); +} diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-store-3.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-store-3.c new file mode 100644 index 0000000000000..e32cfb1a3cbd3 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-store-3.c @@ -0,0 +1,66 @@ +/* { dg-do compile } */ +/* Verify that store mappings match the Ztso suggested mapping. */ +/* { dg-options "-O3" } */ +/* { dg-add-options riscv_ztso } */ +/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +/* +** atomic_store_long_seq_cst: +** l[wd]\t[atx][0-9]+,0\(a1\) +** s[wd]\t[atx][0-9]+,0\(a0\) +** fence\trw,rw +** ret +*/ +void atomic_store_long_seq_cst (long* bar, long* baz) +{ + __atomic_store(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_store_int_seq_cst: +** lw\t[atx][0-9]+,0\(a1\) +** sw\t[atx][0-9]+,0\(a0\) +** fence\trw,rw +** ret +*/ +void atomic_store_int_seq_cst (int* bar, int* baz) +{ + __atomic_store(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_store_short_seq_cst: +** lhu\t[atx][0-9]+,0\(a1\) +** sh\t[atx][0-9]+,0\(a0\) +** fence\trw,rw +** ret +*/ +void atomic_store_short_seq_cst (short* bar, short* baz) +{ + __atomic_store(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_store_char_seq_cst: +** lbu\t[atx][0-9]+,0\(a1\) +** sb\t[atx][0-9]+,0\(a0\) +** fence\trw,rw +** ret +*/ +void atomic_store_char_seq_cst (char* bar, char* baz) +{ + __atomic_store(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_store_bool_seq_cst: +** lbu\t[atx][0-9]+,0\(a1\) +** sb\t[atx][0-9]+,0\(a0\) +** fence\trw,rw +** ret +*/ +void atomic_store_bool_seq_cst (_Bool* bar, _Bool* baz) +{ + __atomic_store(bar, baz, __ATOMIC_SEQ_CST); +} diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-subword-amo-add-1.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-1.c similarity index 81% rename from gcc/testsuite/gcc.target/riscv/amo-table-ztso-subword-amo-add-1.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-1.c index 2a40d6b13761a..a44d6980eceaa 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-subword-amo-add-1.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-1.c @@ -1,11 +1,11 @@ /* { dg-do compile } */ /* Verify that subword atomic op mappings match the Ztso suggested mapping. */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zalrsc } */ /* { dg-add-options riscv_ztso } */ /* { dg-final { scan-assembler-times "lr.w\t" 1 } } */ /* { dg-final { scan-assembler-times "sc.w\t" 1 } } */ -void foo (short* bar, short* baz) +void foo (short* bar, short baz) { __atomic_add_fetch(bar, baz, __ATOMIC_RELAXED); } diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-subword-amo-add-2.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-2.c similarity index 81% rename from gcc/testsuite/gcc.target/riscv/amo-table-ztso-subword-amo-add-2.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-2.c index c79380f261179..8d28569c79cb2 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-subword-amo-add-2.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-2.c @@ -1,11 +1,11 @@ /* { dg-do compile } */ /* Verify that subword atomic op mappings match the Ztso suggested mapping. */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zalrsc } */ /* { dg-add-options riscv_ztso } */ /* { dg-final { scan-assembler-times "lr.w\t" 1 } } */ /* { dg-final { scan-assembler-times "sc.w\t" 1 } } */ -void foo (short* bar, short* baz) +void foo (short* bar, short baz) { __atomic_add_fetch(bar, baz, __ATOMIC_ACQUIRE); } diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-subword-amo-add-3.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-3.c similarity index 81% rename from gcc/testsuite/gcc.target/riscv/amo-table-ztso-subword-amo-add-3.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-3.c index d1a94eccfa837..fb803ab9cbf32 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-subword-amo-add-3.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-3.c @@ -1,11 +1,11 @@ /* { dg-do compile } */ /* Verify that subword atomic op mappings match the Ztso suggested mapping. */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zalrsc } */ /* { dg-add-options riscv_ztso } */ /* { dg-final { scan-assembler-times "lr.w\t" 1 } } */ /* { dg-final { scan-assembler-times "sc.w\t" 1 } } */ -void foo (short* bar, short* baz) +void foo (short* bar, short baz) { __atomic_add_fetch(bar, baz, __ATOMIC_RELEASE); } diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-subword-amo-add-4.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-4.c similarity index 81% rename from gcc/testsuite/gcc.target/riscv/amo-table-ztso-subword-amo-add-4.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-4.c index 3d65bc2f64aa5..a88e409063a0d 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-subword-amo-add-4.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-4.c @@ -1,11 +1,11 @@ /* { dg-do compile } */ /* Verify that subword atomic op mappings match the Ztso suggested mapping. */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zalrsc } */ /* { dg-add-options riscv_ztso } */ /* { dg-final { scan-assembler-times "lr.w\t" 1 } } */ /* { dg-final { scan-assembler-times "sc.w\t" 1 } } */ -void foo (short* bar, short* baz) +void foo (short* bar, short baz) { __atomic_add_fetch(bar, baz, __ATOMIC_ACQ_REL); } diff --git a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-subword-amo-add-5.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-5.c similarity index 81% rename from gcc/testsuite/gcc.target/riscv/amo-table-ztso-subword-amo-add-5.c rename to gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-5.c index 10354387a1376..d851e5e594478 100644 --- a/gcc/testsuite/gcc.target/riscv/amo-table-ztso-subword-amo-add-5.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-subword-amo-add-5.c @@ -1,11 +1,11 @@ /* { dg-do compile } */ /* Verify that subword atomic op mappings match the Ztso suggested mapping. */ -/* { dg-add-options riscv_a } */ +/* { dg-add-options riscv_zalrsc } */ /* { dg-add-options riscv_ztso } */ /* { dg-final { scan-assembler-times "lr.w.aqrl\t" 1 } } */ /* { dg-final { scan-assembler-times "sc.w.rl\t" 1 } } */ -void foo (short* bar, short* baz) +void foo (short* bar, short baz) { __atomic_add_fetch(bar, baz, __ATOMIC_SEQ_CST); } diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-zaamo-preferred-over-zalrsc.c b/gcc/testsuite/gcc.target/riscv/amo/amo-zaamo-preferred-over-zalrsc.c new file mode 100644 index 0000000000000..dae30c32e0167 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-zaamo-preferred-over-zalrsc.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* Ensure that AMO ops are emitted when both zalrsc and zaamo are enabled. */ +/* { dg-options "-O3" } */ +/* { dg-add-options riscv_zalrsc } */ +/* { dg-add-options riscv_zaamo } */ +/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +/* +** foo: +** amoadd\.w\tzero,a1,0\(a0\) +** ret +*/ +void foo (int* bar, int baz) +{ + __atomic_add_fetch(bar, baz, __ATOMIC_RELAXED); +} diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-zalrsc-amo-add-1.c b/gcc/testsuite/gcc.target/riscv/amo/amo-zalrsc-amo-add-1.c new file mode 100644 index 0000000000000..49c1a181d696b --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-zalrsc-amo-add-1.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* Verify that lrsc atomic op mappings match Table A.6's recommended mapping. */ +/* { dg-options "-O3 -march=rv64id_zalrsc -mabi=lp64d" } */ +/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +/* +** foo: +** 1: +** lr.w\t[atx][0-9]+, 0\(a0\) +** add\t[atx][0-9]+, [atx][0-9]+, a1 +** sc.w\t[atx][0-9]+, [atx][0-9]+, 0\(a0\) +** bnez\t[atx][0-9]+, 1b +** ret +*/ +void foo (int* bar, int baz) +{ + __atomic_add_fetch(bar, baz, __ATOMIC_RELAXED); +} diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-zalrsc-amo-add-2.c b/gcc/testsuite/gcc.target/riscv/amo/amo-zalrsc-amo-add-2.c new file mode 100644 index 0000000000000..af93c9a182b3e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-zalrsc-amo-add-2.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* Verify that lrsc atomic op mappings match Table A.6's recommended mapping. */ +/* { dg-options "-O3 -march=rv64id_zalrsc -mabi=lp64d" } */ +/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +/* +** foo: +** 1: +** lr.w.aq\t[atx][0-9]+, 0\(a0\) +** add\t[atx][0-9]+, [atx][0-9]+, a1 +** sc.w\t[atx][0-9]+, [atx][0-9]+, 0\(a0\) +** bnez\t[atx][0-9]+, 1b +** ret +*/ +void foo (int* bar, int baz) +{ + __atomic_add_fetch(bar, baz, __ATOMIC_ACQUIRE); +} diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-zalrsc-amo-add-3.c b/gcc/testsuite/gcc.target/riscv/amo/amo-zalrsc-amo-add-3.c new file mode 100644 index 0000000000000..ce68af841ea49 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-zalrsc-amo-add-3.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* Verify that lrsc atomic op mappings match Table A.6's recommended mapping. */ +/* { dg-options "-O3 -march=rv64id_zalrsc -mabi=lp64d" } */ +/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +/* +** foo: +** 1: +** lr.w\t[atx][0-9]+, 0\(a0\) +** add\t[atx][0-9]+, [atx][0-9]+, a1 +** sc.w.rl\t[atx][0-9]+, [atx][0-9]+, 0\(a0\) +** bnez\t[atx][0-9]+, 1b +** ret +*/ +void foo (int* bar, int baz) +{ + __atomic_add_fetch(bar, baz, __ATOMIC_RELEASE); +} diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-zalrsc-amo-add-4.c b/gcc/testsuite/gcc.target/riscv/amo/amo-zalrsc-amo-add-4.c new file mode 100644 index 0000000000000..be9f847782ec6 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-zalrsc-amo-add-4.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* Verify that lrsc atomic op mappings match Table A.6's recommended mapping. */ +/* { dg-options "-O3 -march=rv64id_zalrsc -mabi=lp64d" } */ +/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +/* +** foo: +** 1: +** lr.w.aq\t[atx][0-9]+, 0\(a0\) +** add\t[atx][0-9]+, [atx][0-9]+, a1 +** sc.w.rl\t[atx][0-9]+, [atx][0-9]+, 0\(a0\) +** bnez\t[atx][0-9]+, 1b +** ret +*/ +void foo (int* bar, int baz) +{ + __atomic_add_fetch(bar, baz, __ATOMIC_ACQ_REL); +} diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-zalrsc-amo-add-5.c b/gcc/testsuite/gcc.target/riscv/amo/amo-zalrsc-amo-add-5.c new file mode 100644 index 0000000000000..b31170c15db7a --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-zalrsc-amo-add-5.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* Verify that lrsc atomic op mappings match Table A.6's recommended mapping. */ +/* { dg-options "-O3 -march=rv64id_zalrsc -mabi=lp64d" } */ +/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +/* +** foo: +** 1: +** lr.w.aqrl\t[atx][0-9]+, 0\(a0\) +** add\t[atx][0-9]+, [atx][0-9]+, a1 +** sc.w.rl\t[atx][0-9]+, [atx][0-9]+, 0\(a0\) +** bnez\t[atx][0-9]+, 1b +** ret +*/ +void foo (int* bar, int baz) +{ + __atomic_add_fetch(bar, baz, __ATOMIC_SEQ_CST); +} diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo.exp b/gcc/testsuite/gcc.target/riscv/amo/amo.exp new file mode 100644 index 0000000000000..2806f4bda7aa8 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/amo/amo.exp @@ -0,0 +1,41 @@ +# Copyright (C) 2024-2024 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 +# . + +# GCC testsuite that uses the `dg.exp' driver. + +# Exit immediately if this isn't a RISC-V target. +if ![istarget riscv*-*-*] then { + return +} + +# Load support procs. +load_lib gcc-dg.exp + +# If a testcase doesn't have special options, use these. +global DEFAULT_CFLAGS +if ![info exists DEFAULT_CFLAGS] then { + set DEFAULT_CFLAGS " -ansi -pedantic-errors" +} + +# Initialize `dg'. +dg-init + +# Main loop. +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \ + "" $DEFAULT_CFLAGS + +# All done. +dg-finish diff --git a/gcc/testsuite/gcc.target/riscv/inline-atomics-1.c b/gcc/testsuite/gcc.target/riscv/amo/inline-atomics-1.c similarity index 100% rename from gcc/testsuite/gcc.target/riscv/inline-atomics-1.c rename to gcc/testsuite/gcc.target/riscv/amo/inline-atomics-1.c diff --git a/gcc/testsuite/gcc.target/riscv/inline-atomics-2.c b/gcc/testsuite/gcc.target/riscv/amo/inline-atomics-2.c similarity index 100% rename from gcc/testsuite/gcc.target/riscv/inline-atomics-2.c rename to gcc/testsuite/gcc.target/riscv/amo/inline-atomics-2.c diff --git a/gcc/testsuite/gcc.target/riscv/inline-atomics-3.c b/gcc/testsuite/gcc.target/riscv/amo/inline-atomics-3.c similarity index 100% rename from gcc/testsuite/gcc.target/riscv/inline-atomics-3.c rename to gcc/testsuite/gcc.target/riscv/amo/inline-atomics-3.c diff --git a/gcc/testsuite/gcc.target/riscv/inline-atomics-4.c b/gcc/testsuite/gcc.target/riscv/amo/inline-atomics-4.c similarity index 100% rename from gcc/testsuite/gcc.target/riscv/inline-atomics-4.c rename to gcc/testsuite/gcc.target/riscv/amo/inline-atomics-4.c diff --git a/gcc/testsuite/gcc.target/riscv/inline-atomics-5.c b/gcc/testsuite/gcc.target/riscv/amo/inline-atomics-5.c similarity index 100% rename from gcc/testsuite/gcc.target/riscv/inline-atomics-5.c rename to gcc/testsuite/gcc.target/riscv/amo/inline-atomics-5.c diff --git a/gcc/testsuite/gcc.target/riscv/inline-atomics-6.c b/gcc/testsuite/gcc.target/riscv/amo/inline-atomics-6.c similarity index 100% rename from gcc/testsuite/gcc.target/riscv/inline-atomics-6.c rename to gcc/testsuite/gcc.target/riscv/amo/inline-atomics-6.c diff --git a/gcc/testsuite/gcc.target/riscv/inline-atomics-7.c b/gcc/testsuite/gcc.target/riscv/amo/inline-atomics-7.c similarity index 100% rename from gcc/testsuite/gcc.target/riscv/inline-atomics-7.c rename to gcc/testsuite/gcc.target/riscv/amo/inline-atomics-7.c diff --git a/gcc/testsuite/gcc.target/riscv/inline-atomics-8.c b/gcc/testsuite/gcc.target/riscv/amo/inline-atomics-8.c similarity index 100% rename from gcc/testsuite/gcc.target/riscv/inline-atomics-8.c rename to gcc/testsuite/gcc.target/riscv/amo/inline-atomics-8.c diff --git a/gcc/testsuite/gcc.target/riscv/pr114130.c b/gcc/testsuite/gcc.target/riscv/amo/pr114130.c similarity index 100% rename from gcc/testsuite/gcc.target/riscv/pr114130.c rename to gcc/testsuite/gcc.target/riscv/amo/pr114130.c diff --git a/gcc/testsuite/gcc.target/riscv/pr89835.c b/gcc/testsuite/gcc.target/riscv/amo/pr89835.c similarity index 100% rename from gcc/testsuite/gcc.target/riscv/pr89835.c rename to gcc/testsuite/gcc.target/riscv/amo/pr89835.c diff --git a/gcc/testsuite/gcc.target/riscv/attribute-15.c b/gcc/testsuite/gcc.target/riscv/attribute-15.c index 59efeb6ea45a3..a2e394b6489bb 100644 --- a/gcc/testsuite/gcc.target/riscv/attribute-15.c +++ b/gcc/testsuite/gcc.target/riscv/attribute-15.c @@ -3,4 +3,4 @@ int foo() { } -/* { dg-final { scan-assembler ".attribute arch, \"rv32i2p0_m2p0_a2p0_f2p0_d2p0_c2p0\"" } } */ +/* { dg-final { scan-assembler ".attribute arch, \"rv32i2p0_m2p0_a2p0_f2p0_d2p0_c2p0_zaamo1p0_zalrsc1p0\"" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/attribute-16.c b/gcc/testsuite/gcc.target/riscv/attribute-16.c index 26f961efb4879..d2b18160cb5d4 100644 --- a/gcc/testsuite/gcc.target/riscv/attribute-16.c +++ b/gcc/testsuite/gcc.target/riscv/attribute-16.c @@ -3,4 +3,4 @@ int foo() { } -/* { dg-final { scan-assembler ".attribute arch, \"rv32i2p1_m2p0_a2p0_f2p2_d2p2_c2p0_zicsr2p0" } } */ +/* { dg-final { scan-assembler ".attribute arch, \"rv32i2p1_m2p0_a2p0_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zaamo1p0_zalrsc1p0\"" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/attribute-17.c b/gcc/testsuite/gcc.target/riscv/attribute-17.c index 0abff3705d9fb..fc2f488a3acab 100644 --- a/gcc/testsuite/gcc.target/riscv/attribute-17.c +++ b/gcc/testsuite/gcc.target/riscv/attribute-17.c @@ -3,4 +3,4 @@ int foo() { } -/* { dg-final { scan-assembler ".attribute arch, \"rv32i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0" } } */ +/* { dg-final { scan-assembler ".attribute arch, \"rv32i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zaamo1p0_zalrsc1p0\"" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/attribute-18.c b/gcc/testsuite/gcc.target/riscv/attribute-18.c index fddbf15fc3eef..eefd602103df8 100644 --- a/gcc/testsuite/gcc.target/riscv/attribute-18.c +++ b/gcc/testsuite/gcc.target/riscv/attribute-18.c @@ -1,4 +1,4 @@ /* { dg-do compile } */ /* { dg-options "-mriscv-attribute -march=rv64imafdc -mabi=lp64d -misa-spec=2.2" } */ int foo() {} -/* { dg-final { scan-assembler ".attribute arch, \"rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0\"" } } */ +/* { dg-final { scan-assembler ".attribute arch, \"rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0_zaamo1p0_zalrsc1p0\"" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/bext-ext.c b/gcc/testsuite/gcc.target/riscv/bext-ext.c new file mode 100644 index 0000000000000..eeef07d7013aa --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/bext-ext.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc_zbs -mabi=lp64" } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-O1" } } */ +typedef unsigned long uint64_t; +typedef unsigned int uint32_t; + +uint64_t bext1 (int dst, const uint32_t i) +{ + uint64_t checks = 1U; + checks &= dst >> i; + return checks; +} + +int bext2 (int dst, int i_denom) +{ + dst = 1 & (dst >> i_denom); + return dst; +} + +const uint32_t bext3 (uint32_t bit_count, uint32_t symbol) +{ + return (symbol >> bit_count) & 1; +} + +/* { dg-final { scan-assembler-times "bext\t" 3 } } */ +/* { dg-final { scan-assembler-not "sllw\t"} } */ +/* { dg-final { scan-assembler-not "srlw\t"} } */ diff --git a/gcc/testsuite/gcc.target/riscv/pr110696.c b/gcc/testsuite/gcc.target/riscv/pr110696.c index a630f04e74f9c..08682a047e001 100644 --- a/gcc/testsuite/gcc.target/riscv/pr110696.c +++ b/gcc/testsuite/gcc.target/riscv/pr110696.c @@ -4,4 +4,4 @@ int foo() { } -/* { dg-final { scan-assembler ".attribute arch, \"rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_v1p0_zicsr2p0_zifencei2p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl1024b1p0_zvl128b1p0_zvl2048b1p0_zvl256b1p0_zvl32b1p0_zvl4096b1p0_zvl512b1p0_zvl64b1p0\"" } } */ +/* { dg-final { scan-assembler ".attribute arch, \"rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_v1p0_zicsr2p0_zifencei2p0_zaamo1p0_zalrsc1p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl1024b1p0_zvl128b1p0_zvl2048b1p0_zvl256b1p0_zvl32b1p0_zvl4096b1p0_zvl512b1p0_zvl64b1p0\"" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/round_32.c b/gcc/testsuite/gcc.target/riscv/round_32.c deleted file mode 100644 index 88ff77aff2e04..0000000000000 --- a/gcc/testsuite/gcc.target/riscv/round_32.c +++ /dev/null @@ -1,23 +0,0 @@ -/* { dg-do compile { target { riscv32*-*-* } } } */ -/* { dg-require-effective-target glibc } */ -/* { dg-options "-march=rv32gc -mabi=ilp32d -fno-math-errno -funsafe-math-optimizations -fno-inline" } */ -/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ - -#include "round.c" - -/* { dg-final { scan-assembler-times {\mfcvt.w.s} 15 } } */ -/* { dg-final { scan-assembler-times {\mfcvt.s.w} 5 } } */ -/* { dg-final { scan-assembler-times {\mfcvt.d.w} 65 } } */ -/* { dg-final { scan-assembler-times {\mfcvt.w.d} 15 } } */ -/* { dg-final { scan-assembler-times {,rup} 6 } } */ -/* { dg-final { scan-assembler-times {,rmm} 6 } } */ -/* { dg-final { scan-assembler-times {,rdn} 6 } } */ -/* { dg-final { scan-assembler-times {,rtz} 6 } } */ -/* { dg-final { scan-assembler-not {\mfcvt.l.d} } } */ -/* { dg-final { scan-assembler-not {\mfcvt.d.l} } } */ -/* { dg-final { scan-assembler-not "\\sceil\\s" } } */ -/* { dg-final { scan-assembler-not "\\sfloor\\s" } } */ -/* { dg-final { scan-assembler-not "\\sround\\s" } } */ -/* { dg-final { scan-assembler-not "\\snearbyint\\s" } } */ -/* { dg-final { scan-assembler-not "\\srint\\s" } } */ -/* { dg-final { scan-assembler-not "\\stail\\s" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_arith.h b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_arith.h new file mode 100644 index 0000000000000..d5c81fbe5a9e2 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_arith.h @@ -0,0 +1,313 @@ +#ifndef HAVE_VEC_SAT_ARITH +#define HAVE_VEC_SAT_ARITH + +#include +#include + +/******************************************************************************/ +/* Saturation Add (unsigned and signed) */ +/******************************************************************************/ +#define DEF_VEC_SAT_U_ADD_FMT_1(T) \ +void __attribute__((noinline)) \ +vec_sat_u_add_##T##_fmt_1 (T *out, T *op_1, T *op_2, unsigned limit) \ +{ \ + unsigned i; \ + for (i = 0; i < limit; i++) \ + { \ + T x = op_1[i]; \ + T y = op_2[i]; \ + out[i] = (x + y) | (-(T)((T)(x + y) < x)); \ + } \ +} + +#define DEF_VEC_SAT_U_ADD_FMT_2(T) \ +void __attribute__((noinline)) \ +vec_sat_u_add_##T##_fmt_2 (T *out, T *op_1, T *op_2, unsigned limit) \ +{ \ + unsigned i; \ + for (i = 0; i < limit; i++) \ + { \ + T x = op_1[i]; \ + T y = op_2[i]; \ + out[i] = (T)(x + y) >= x ? (x + y) : -1; \ + } \ +} + +#define DEF_VEC_SAT_U_ADD_FMT_3(T) \ +void __attribute__((noinline)) \ +vec_sat_u_add_##T##_fmt_3 (T *out, T *op_1, T *op_2, unsigned limit) \ +{ \ + unsigned i; \ + for (i = 0; i < limit; i++) \ + { \ + T x = op_1[i]; \ + T y = op_2[i]; \ + T ret; \ + T overflow = __builtin_add_overflow (x, y, &ret); \ + out[i] = (T)(-overflow) | ret; \ + } \ +} + +#define DEF_VEC_SAT_U_ADD_FMT_4(T) \ +void __attribute__((noinline)) \ +vec_sat_u_add_##T##_fmt_4 (T *out, T *op_1, T *op_2, unsigned limit) \ +{ \ + unsigned i; \ + for (i = 0; i < limit; i++) \ + { \ + T x = op_1[i]; \ + T y = op_2[i]; \ + T ret; \ + out[i] = __builtin_add_overflow (x, y, &ret) ? -1 : ret; \ + } \ +} + +#define DEF_VEC_SAT_U_ADD_FMT_5(T) \ +void __attribute__((noinline)) \ +vec_sat_u_add_##T##_fmt_5 (T *out, T *op_1, T *op_2, unsigned limit) \ +{ \ + unsigned i; \ + for (i = 0; i < limit; i++) \ + { \ + T x = op_1[i]; \ + T y = op_2[i]; \ + T ret; \ + out[i] = __builtin_add_overflow (x, y, &ret) == 0 ? ret : -1; \ + } \ +} + +#define DEF_VEC_SAT_U_ADD_FMT_6(T) \ +void __attribute__((noinline)) \ +vec_sat_u_add_##T##_fmt_6 (T *out, T *op_1, T *op_2, unsigned limit) \ +{ \ + unsigned i; \ + for (i = 0; i < limit; i++) \ + { \ + T x = op_1[i]; \ + T y = op_2[i]; \ + out[i] = x <= (T)(x + y) ? (x + y) : -1; \ + } \ +} + +#define DEF_VEC_SAT_U_ADD_FMT_7(T) \ +void __attribute__((noinline)) \ +vec_sat_u_add_##T##_fmt_7 (T *out, T *op_1, T *op_2, unsigned limit) \ +{ \ + unsigned i; \ + for (i = 0; i < limit; i++) \ + { \ + T x = op_1[i]; \ + T y = op_2[i]; \ + out[i] = (T)(x + y) < x ? -1 : (x + y); \ + } \ +} + +#define DEF_VEC_SAT_U_ADD_FMT_8(T) \ +void __attribute__((noinline)) \ +vec_sat_u_add_##T##_fmt_8 (T *out, T *op_1, T *op_2, unsigned limit) \ +{ \ + unsigned i; \ + for (i = 0; i < limit; i++) \ + { \ + T x = op_1[i]; \ + T y = op_2[i]; \ + out[i] = x > (T)(x + y) ? -1 : (x + y); \ + } \ +} + +#define RUN_VEC_SAT_U_ADD_FMT_1(T, out, op_1, op_2, N) \ + vec_sat_u_add_##T##_fmt_1(out, op_1, op_2, N) + +#define RUN_VEC_SAT_U_ADD_FMT_2(T, out, op_1, op_2, N) \ + vec_sat_u_add_##T##_fmt_2(out, op_1, op_2, N) + +#define RUN_VEC_SAT_U_ADD_FMT_3(T, out, op_1, op_2, N) \ + vec_sat_u_add_##T##_fmt_3(out, op_1, op_2, N) + +#define RUN_VEC_SAT_U_ADD_FMT_4(T, out, op_1, op_2, N) \ + vec_sat_u_add_##T##_fmt_4(out, op_1, op_2, N) + +#define RUN_VEC_SAT_U_ADD_FMT_5(T, out, op_1, op_2, N) \ + vec_sat_u_add_##T##_fmt_5(out, op_1, op_2, N) + +#define RUN_VEC_SAT_U_ADD_FMT_6(T, out, op_1, op_2, N) \ + vec_sat_u_add_##T##_fmt_6(out, op_1, op_2, N) + +#define RUN_VEC_SAT_U_ADD_FMT_7(T, out, op_1, op_2, N) \ + vec_sat_u_add_##T##_fmt_7(out, op_1, op_2, N) + +#define RUN_VEC_SAT_U_ADD_FMT_8(T, out, op_1, op_2, N) \ + vec_sat_u_add_##T##_fmt_8(out, op_1, op_2, N) + +/******************************************************************************/ +/* Saturation Sub (Unsigned and Signed) */ +/******************************************************************************/ +#define DEF_VEC_SAT_U_SUB_FMT_1(T) \ +void __attribute__((noinline)) \ +vec_sat_u_sub_##T##_fmt_1 (T *out, T *op_1, T *op_2, unsigned limit) \ +{ \ + unsigned i; \ + for (i = 0; i < limit; i++) \ + { \ + T x = op_1[i]; \ + T y = op_2[i]; \ + out[i] = (x - y) & (-(T)(x >= y)); \ + } \ +} + +#define DEF_VEC_SAT_U_SUB_FMT_2(T) \ +void __attribute__((noinline)) \ +vec_sat_u_sub_##T##_fmt_2 (T *out, T *op_1, T *op_2, unsigned limit) \ +{ \ + unsigned i; \ + for (i = 0; i < limit; i++) \ + { \ + T x = op_1[i]; \ + T y = op_2[i]; \ + out[i] = (x - y) & (-(T)(x > y)); \ + } \ +} + +#define DEF_VEC_SAT_U_SUB_FMT_3(T) \ +void __attribute__((noinline)) \ +vec_sat_u_sub_##T##_fmt_3 (T *out, T *op_1, T *op_2, unsigned limit) \ +{ \ + unsigned i; \ + for (i = 0; i < limit; i++) \ + { \ + T x = op_1[i]; \ + T y = op_2[i]; \ + out[i] = x > y ? x - y : 0; \ + } \ +} + +#define DEF_VEC_SAT_U_SUB_FMT_4(T) \ +void __attribute__((noinline)) \ +vec_sat_u_sub_##T##_fmt_4 (T *out, T *op_1, T *op_2, unsigned limit) \ +{ \ + unsigned i; \ + for (i = 0; i < limit; i++) \ + { \ + T x = op_1[i]; \ + T y = op_2[i]; \ + out[i] = x >= y ? x - y : 0; \ + } \ +} + +#define DEF_VEC_SAT_U_SUB_FMT_5(T) \ +void __attribute__((noinline)) \ +vec_sat_u_sub_##T##_fmt_5 (T *out, T *op_1, T *op_2, unsigned limit) \ +{ \ + unsigned i; \ + for (i = 0; i < limit; i++) \ + { \ + T x = op_1[i]; \ + T y = op_2[i]; \ + out[i] = x < y ? 0 : x - y; \ + } \ +} + +#define DEF_VEC_SAT_U_SUB_FMT_6(T) \ +void __attribute__((noinline)) \ +vec_sat_u_sub_##T##_fmt_6 (T *out, T *op_1, T *op_2, unsigned limit) \ +{ \ + unsigned i; \ + for (i = 0; i < limit; i++) \ + { \ + T x = op_1[i]; \ + T y = op_2[i]; \ + out[i] = x <= y ? 0 : x - y; \ + } \ +} + +#define DEF_VEC_SAT_U_SUB_FMT_7(T) \ +void __attribute__((noinline)) \ +vec_sat_u_sub_##T##_fmt_7 (T *out, T *op_1, T *op_2, unsigned limit) \ +{ \ + unsigned i; \ + for (i = 0; i < limit; i++) \ + { \ + T x = op_1[i]; \ + T y = op_2[i]; \ + T ret; \ + T overflow = __builtin_sub_overflow (x, y, &ret); \ + out[i] = ret & (T)(overflow - 1); \ + } \ +} + +#define DEF_VEC_SAT_U_SUB_FMT_8(T) \ +void __attribute__((noinline)) \ +vec_sat_u_sub_##T##_fmt_8 (T *out, T *op_1, T *op_2, unsigned limit) \ +{ \ + unsigned i; \ + for (i = 0; i < limit; i++) \ + { \ + T x = op_1[i]; \ + T y = op_2[i]; \ + T ret; \ + T overflow = __builtin_sub_overflow (x, y, &ret); \ + out[i] = ret & (T)-(!overflow); \ + } \ +} + +#define DEF_VEC_SAT_U_SUB_FMT_9(T) \ +void __attribute__((noinline)) \ +vec_sat_u_sub_##T##_fmt_9 (T *out, T *op_1, T *op_2, unsigned limit) \ +{ \ + unsigned i; \ + for (i = 0; i < limit; i++) \ + { \ + T x = op_1[i]; \ + T y = op_2[i]; \ + T ret; \ + bool overflow = __builtin_sub_overflow (x, y, &ret); \ + out[i] = overflow ? 0 : ret; \ + } \ +} + +#define DEF_VEC_SAT_U_SUB_FMT_10(T) \ +void __attribute__((noinline)) \ +vec_sat_u_sub_##T##_fmt_10 (T *out, T *op_1, T *op_2, unsigned limit) \ +{ \ + unsigned i; \ + for (i = 0; i < limit; i++) \ + { \ + T x = op_1[i]; \ + T y = op_2[i]; \ + T ret; \ + bool overflow = __builtin_sub_overflow (x, y, &ret); \ + out[i] = !overflow ? ret : 0; \ + } \ +} + +#define RUN_VEC_SAT_U_SUB_FMT_1(T, out, op_1, op_2, N) \ + vec_sat_u_sub_##T##_fmt_1(out, op_1, op_2, N) + +#define RUN_VEC_SAT_U_SUB_FMT_2(T, out, op_1, op_2, N) \ + vec_sat_u_sub_##T##_fmt_2(out, op_1, op_2, N) + +#define RUN_VEC_SAT_U_SUB_FMT_3(T, out, op_1, op_2, N) \ + vec_sat_u_sub_##T##_fmt_3(out, op_1, op_2, N) + +#define RUN_VEC_SAT_U_SUB_FMT_4(T, out, op_1, op_2, N) \ + vec_sat_u_sub_##T##_fmt_4(out, op_1, op_2, N) + +#define RUN_VEC_SAT_U_SUB_FMT_5(T, out, op_1, op_2, N) \ + vec_sat_u_sub_##T##_fmt_5(out, op_1, op_2, N) + +#define RUN_VEC_SAT_U_SUB_FMT_6(T, out, op_1, op_2, N) \ + vec_sat_u_sub_##T##_fmt_6(out, op_1, op_2, N) + +#define RUN_VEC_SAT_U_SUB_FMT_7(T, out, op_1, op_2, N) \ + vec_sat_u_sub_##T##_fmt_7(out, op_1, op_2, N) + +#define RUN_VEC_SAT_U_SUB_FMT_8(T, out, op_1, op_2, N) \ + vec_sat_u_sub_##T##_fmt_8(out, op_1, op_2, N) + +#define RUN_VEC_SAT_U_SUB_FMT_9(T, out, op_1, op_2, N) \ + vec_sat_u_sub_##T##_fmt_9(out, op_1, op_2, N) + +#define RUN_VEC_SAT_U_SUB_FMT_10(T, out, op_1, op_2, N) \ + vec_sat_u_sub_##T##_fmt_10(out, op_1, op_2, N) + +#endif diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-1.c index dbbfa00afe2b6..6fe84f3945fee 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-1.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-1.c @@ -3,7 +3,7 @@ /* { dg-skip-if "" { *-*-* } { "-flto" } } */ /* { dg-final { check-function-bodies "**" "" } } */ -#include "../../../sat_arith.h" +#include "vec_sat_arith.h" /* ** vec_sat_u_add_uint8_t_fmt_1: diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-10.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-10.c new file mode 100644 index 0000000000000..b5dfaafa1eed8 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-10.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_add_uint16_t_fmt_3: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e16,\s*m1,\s*ta,\s*ma +** ... +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vsaddu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_ADD_FMT_3(uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 4 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-11.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-11.c new file mode 100644 index 0000000000000..84b55d0b3b61c --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-11.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_add_uint32_t_fmt_3: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e32,\s*m1,\s*ta,\s*ma +** ... +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vsaddu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_ADD_FMT_3(uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 4 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-12.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-12.c new file mode 100644 index 0000000000000..90332c216bbb1 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-12.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_add_uint64_t_fmt_3: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e64,\s*m1,\s*ta,\s*ma +** ... +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vsaddu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_ADD_FMT_3(uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 4 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-13.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-13.c new file mode 100644 index 0000000000000..09fdb7295077c --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-13.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_add_uint8_t_fmt_4: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e8,\s*m1,\s*ta,\s*ma +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vsaddu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_ADD_FMT_4(uint8_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-14.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-14.c new file mode 100644 index 0000000000000..b1171cc4de0d1 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-14.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_add_uint16_t_fmt_4: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e16,\s*m1,\s*ta,\s*ma +** ... +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vsaddu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_ADD_FMT_4(uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-15.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-15.c new file mode 100644 index 0000000000000..130eb7840ffae --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-15.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_add_uint32_t_fmt_4: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e32,\s*m1,\s*ta,\s*ma +** ... +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vsaddu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_ADD_FMT_4(uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-16.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-16.c new file mode 100644 index 0000000000000..37aefa05a5042 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-16.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_add_uint64_t_fmt_4: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e64,\s*m1,\s*ta,\s*ma +** ... +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vsaddu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_ADD_FMT_4(uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-17.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-17.c new file mode 100644 index 0000000000000..ac5ed050d9b9e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-17.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_add_uint8_t_fmt_5: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e8,\s*m1,\s*ta,\s*ma +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vsaddu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_ADD_FMT_5(uint8_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-18.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-18.c new file mode 100644 index 0000000000000..52beb95c43b37 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-18.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_add_uint16_t_fmt_5: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e16,\s*m1,\s*ta,\s*ma +** ... +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vsaddu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_ADD_FMT_5(uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-19.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-19.c new file mode 100644 index 0000000000000..e2d725a51d6d1 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-19.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_add_uint32_t_fmt_5: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e32,\s*m1,\s*ta,\s*ma +** ... +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vsaddu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_ADD_FMT_5(uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-2.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-2.c index 1253fdb5f6003..e9a40e0dcd049 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-2.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-2.c @@ -3,7 +3,7 @@ /* { dg-skip-if "" { *-*-* } { "-flto" } } */ /* { dg-final { check-function-bodies "**" "" } } */ -#include "../../../sat_arith.h" +#include "vec_sat_arith.h" /* ** vec_sat_u_add_uint16_t_fmt_1: diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-20.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-20.c new file mode 100644 index 0000000000000..e4fbb586dec9d --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-20.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_add_uint64_t_fmt_5: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e64,\s*m1,\s*ta,\s*ma +** ... +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vsaddu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_ADD_FMT_5(uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-21.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-21.c new file mode 100644 index 0000000000000..e53c3c9af4c45 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-21.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_add_uint8_t_fmt_6: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e8,\s*m1,\s*ta,\s*ma +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vsaddu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_ADD_FMT_6(uint8_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-22.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-22.c new file mode 100644 index 0000000000000..5fb5f6605c679 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-22.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_add_uint16_t_fmt_6: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e16,\s*m1,\s*ta,\s*ma +** ... +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vsaddu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_ADD_FMT_6(uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-23.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-23.c new file mode 100644 index 0000000000000..20927b7c32c82 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-23.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_add_uint32_t_fmt_6: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e32,\s*m1,\s*ta,\s*ma +** ... +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vsaddu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_ADD_FMT_6(uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-24.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-24.c new file mode 100644 index 0000000000000..b898f693e32a5 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-24.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_add_uint64_t_fmt_6: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e64,\s*m1,\s*ta,\s*ma +** ... +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vsaddu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_ADD_FMT_6(uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-25.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-25.c new file mode 100644 index 0000000000000..24b9b335c3295 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-25.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_add_uint8_t_fmt_7: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e8,\s*m1,\s*ta,\s*ma +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vsaddu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_ADD_FMT_7(uint8_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-26.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-26.c new file mode 100644 index 0000000000000..8cdbac7ea2c2b --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-26.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_add_uint16_t_fmt_7: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e16,\s*m1,\s*ta,\s*ma +** ... +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vsaddu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_ADD_FMT_7(uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-27.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-27.c new file mode 100644 index 0000000000000..89c09bbffde57 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-27.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_add_uint32_t_fmt_7: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e32,\s*m1,\s*ta,\s*ma +** ... +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vsaddu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_ADD_FMT_7(uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-28.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-28.c new file mode 100644 index 0000000000000..14b20e87b0e62 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-28.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_add_uint64_t_fmt_7: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e64,\s*m1,\s*ta,\s*ma +** ... +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vsaddu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_ADD_FMT_7(uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-29.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-29.c new file mode 100644 index 0000000000000..e96aa4b857932 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-29.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_add_uint8_t_fmt_8: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e8,\s*m1,\s*ta,\s*ma +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vsaddu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_ADD_FMT_8(uint8_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-3.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-3.c index 74bba9cadd11c..f30000698a2f7 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-3.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-3.c @@ -3,7 +3,7 @@ /* { dg-skip-if "" { *-*-* } { "-flto" } } */ /* { dg-final { check-function-bodies "**" "" } } */ -#include "../../../sat_arith.h" +#include "vec_sat_arith.h" /* ** vec_sat_u_add_uint32_t_fmt_1: diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-30.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-30.c new file mode 100644 index 0000000000000..88be0cd53489f --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-30.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_add_uint16_t_fmt_8: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e16,\s*m1,\s*ta,\s*ma +** ... +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vsaddu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_ADD_FMT_8(uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-31.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-31.c new file mode 100644 index 0000000000000..07e0149dda941 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-31.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_add_uint32_t_fmt_8: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e32,\s*m1,\s*ta,\s*ma +** ... +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vsaddu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_ADD_FMT_8(uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-32.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-32.c new file mode 100644 index 0000000000000..3a4c7581a29c9 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-32.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_add_uint64_t_fmt_8: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e64,\s*m1,\s*ta,\s*ma +** ... +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vsaddu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_ADD_FMT_8(uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-4.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-4.c index f3692b4cc2534..9c9ba2797d04f 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-4.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-4.c @@ -3,7 +3,7 @@ /* { dg-skip-if "" { *-*-* } { "-flto" } } */ /* { dg-final { check-function-bodies "**" "" } } */ -#include "../../../sat_arith.h" +#include "vec_sat_arith.h" /* ** vec_sat_u_add_uint64_t_fmt_1: diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-5.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-5.c new file mode 100644 index 0000000000000..a46a3c592c24b --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-5.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_add_uint8_t_fmt_2: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e8,\s*m1,\s*ta,\s*ma +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vsaddu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_ADD_FMT_2(uint8_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-6.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-6.c new file mode 100644 index 0000000000000..1ce6e7fd0eb10 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-6.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_add_uint16_t_fmt_2: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e16,\s*m1,\s*ta,\s*ma +** ... +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vsaddu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_ADD_FMT_2(uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-7.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-7.c new file mode 100644 index 0000000000000..dff577a21e1bf --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-7.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_add_uint32_t_fmt_2: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e32,\s*m1,\s*ta,\s*ma +** ... +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vsaddu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_ADD_FMT_2(uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-8.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-8.c new file mode 100644 index 0000000000000..6fd0f3a9b6c8f --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-8.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_add_uint64_t_fmt_2: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e64,\s*m1,\s*ta,\s*ma +** ... +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vsaddu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_ADD_FMT_2(uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-9.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-9.c new file mode 100644 index 0000000000000..15266572607ee --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-9.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_add_uint8_t_fmt_3: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e8,\s*m1,\s*ta,\s*ma +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vsaddu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_ADD_FMT_3(uint8_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 4 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-1.c index 1dcb333f687ad..151bc466c72bf 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-1.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-1.c @@ -1,7 +1,7 @@ /* { dg-do run { target { riscv_v } } } */ /* { dg-additional-options "-std=c99" } */ -#include "../../../sat_arith.h" +#include "vec_sat_arith.h" #define T uint8_t #define N 16 diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-10.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-10.c new file mode 100644 index 0000000000000..7039830cafaa4 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-10.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint16_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_ADD_FMT_3 + +DEF_VEC_SAT_U_ADD_FMT_3(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 4, + 5, 65534, 65535, 9, + }, + { + 0, 1, 1, 65534, + 65534, 65534, 65534, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 9, + }, + { + 0, 1, 2, 65534, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 18, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-11.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-11.c new file mode 100644 index 0000000000000..f5b7957b9b4e3 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-11.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint32_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_ADD_FMT_3 + +DEF_VEC_SAT_U_ADD_FMT_3(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 4, + 5, 4294967294, 4294967295, 9, + }, + { + 0, 1, 1, 4294967294, + 4294967294, 4294967294, 4294967294, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 9, + }, + { + 0, 1, 2, 4294967294, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 18, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-12.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-12.c new file mode 100644 index 0000000000000..a500414a9f531 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-12.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint64_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_ADD_FMT_3 + +DEF_VEC_SAT_U_ADD_FMT_3(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 4, + 5, 18446744073709551614u, 18446744073709551615u, 9, + }, + { + 0, 1, 1, 18446744073709551614u, + 18446744073709551614u, 18446744073709551614u, 18446744073709551614u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 9, + }, + { + 0, 1, 2, 18446744073709551614u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-13.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-13.c new file mode 100644 index 0000000000000..fd7e1af45c99c --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-13.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint8_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_ADD_FMT_4 + +DEF_VEC_SAT_U_ADD_FMT_4(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + }, + { + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + }, + { + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 4, + 5, 254, 255, 9, + }, + { + 0, 1, 1, 254, + 254, 254, 254, 255, + 255, 255, 255, 255, + 255, 255, 255, 9, + }, + { + 0, 1, 2, 254, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 18, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-14.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-14.c new file mode 100644 index 0000000000000..8896dad831b44 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-14.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint16_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_ADD_FMT_4 + +DEF_VEC_SAT_U_ADD_FMT_4(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 4, + 5, 65534, 65535, 9, + }, + { + 0, 1, 1, 65534, + 65534, 65534, 65534, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 9, + }, + { + 0, 1, 2, 65534, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 18, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-15.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-15.c new file mode 100644 index 0000000000000..1e40fffc65880 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-15.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint32_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_ADD_FMT_4 + +DEF_VEC_SAT_U_ADD_FMT_4(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 4, + 5, 4294967294, 4294967295, 9, + }, + { + 0, 1, 1, 4294967294, + 4294967294, 4294967294, 4294967294, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 9, + }, + { + 0, 1, 2, 4294967294, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 18, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-16.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-16.c new file mode 100644 index 0000000000000..3b39fa318f8b5 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-16.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint64_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_ADD_FMT_4 + +DEF_VEC_SAT_U_ADD_FMT_4(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 4, + 5, 18446744073709551614u, 18446744073709551615u, 9, + }, + { + 0, 1, 1, 18446744073709551614u, + 18446744073709551614u, 18446744073709551614u, 18446744073709551614u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 9, + }, + { + 0, 1, 2, 18446744073709551614u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-17.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-17.c new file mode 100644 index 0000000000000..17e244d089e3c --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-17.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint8_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_ADD_FMT_5 + +DEF_VEC_SAT_U_ADD_FMT_5(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + }, + { + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + }, + { + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 4, + 5, 254, 255, 9, + }, + { + 0, 1, 1, 254, + 254, 254, 254, 255, + 255, 255, 255, 255, + 255, 255, 255, 9, + }, + { + 0, 1, 2, 254, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 18, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-18.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-18.c new file mode 100644 index 0000000000000..532fa97fe8b5d --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-18.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint16_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_ADD_FMT_5 + +DEF_VEC_SAT_U_ADD_FMT_5(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 4, + 5, 65534, 65535, 9, + }, + { + 0, 1, 1, 65534, + 65534, 65534, 65534, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 9, + }, + { + 0, 1, 2, 65534, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 18, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-19.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-19.c new file mode 100644 index 0000000000000..b36b4c7d4d18e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-19.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint32_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_ADD_FMT_5 + +DEF_VEC_SAT_U_ADD_FMT_5(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 4, + 5, 4294967294, 4294967295, 9, + }, + { + 0, 1, 1, 4294967294, + 4294967294, 4294967294, 4294967294, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 9, + }, + { + 0, 1, 2, 4294967294, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 18, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-2.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-2.c index dbf01ac863df2..4d545226b2b0c 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-2.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-2.c @@ -1,7 +1,7 @@ /* { dg-do run { target { riscv_v } } } */ /* { dg-additional-options "-std=c99" } */ -#include "../../../sat_arith.h" +#include "vec_sat_arith.h" #define T uint16_t #define N 16 diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-20.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-20.c new file mode 100644 index 0000000000000..d3b64450dc48e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-20.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint64_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_ADD_FMT_5 + +DEF_VEC_SAT_U_ADD_FMT_5(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 4, + 5, 18446744073709551614u, 18446744073709551615u, 9, + }, + { + 0, 1, 1, 18446744073709551614u, + 18446744073709551614u, 18446744073709551614u, 18446744073709551614u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 9, + }, + { + 0, 1, 2, 18446744073709551614u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-21.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-21.c new file mode 100644 index 0000000000000..b5ce31b9b6f9e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-21.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint8_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_ADD_FMT_6 + +DEF_VEC_SAT_U_ADD_FMT_6(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + }, + { + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + }, + { + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 4, + 5, 254, 255, 9, + }, + { + 0, 1, 1, 254, + 254, 254, 254, 255, + 255, 255, 255, 255, + 255, 255, 255, 9, + }, + { + 0, 1, 2, 254, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 18, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-22.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-22.c new file mode 100644 index 0000000000000..611281ee77f39 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-22.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint16_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_ADD_FMT_6 + +DEF_VEC_SAT_U_ADD_FMT_6(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 4, + 5, 65534, 65535, 9, + }, + { + 0, 1, 1, 65534, + 65534, 65534, 65534, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 9, + }, + { + 0, 1, 2, 65534, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 18, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-23.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-23.c new file mode 100644 index 0000000000000..b7077567dc3d3 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-23.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint32_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_ADD_FMT_6 + +DEF_VEC_SAT_U_ADD_FMT_6(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 4, + 5, 4294967294, 4294967295, 9, + }, + { + 0, 1, 1, 4294967294, + 4294967294, 4294967294, 4294967294, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 9, + }, + { + 0, 1, 2, 4294967294, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 18, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-24.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-24.c new file mode 100644 index 0000000000000..9d8e91892e6db --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-24.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint64_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_ADD_FMT_6 + +DEF_VEC_SAT_U_ADD_FMT_6(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 4, + 5, 18446744073709551614u, 18446744073709551615u, 9, + }, + { + 0, 1, 1, 18446744073709551614u, + 18446744073709551614u, 18446744073709551614u, 18446744073709551614u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 9, + }, + { + 0, 1, 2, 18446744073709551614u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-25.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-25.c new file mode 100644 index 0000000000000..fbce1b6aa0102 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-25.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint8_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_ADD_FMT_7 + +DEF_VEC_SAT_U_ADD_FMT_7(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + }, + { + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + }, + { + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 4, + 5, 254, 255, 9, + }, + { + 0, 1, 1, 254, + 254, 254, 254, 255, + 255, 255, 255, 255, + 255, 255, 255, 9, + }, + { + 0, 1, 2, 254, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 18, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-26.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-26.c new file mode 100644 index 0000000000000..6562a59ebbb6e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-26.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint16_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_ADD_FMT_7 + +DEF_VEC_SAT_U_ADD_FMT_7(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 4, + 5, 65534, 65535, 9, + }, + { + 0, 1, 1, 65534, + 65534, 65534, 65534, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 9, + }, + { + 0, 1, 2, 65534, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 18, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-27.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-27.c new file mode 100644 index 0000000000000..b5693802ccc47 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-27.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint32_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_ADD_FMT_7 + +DEF_VEC_SAT_U_ADD_FMT_7(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 4, + 5, 4294967294, 4294967295, 9, + }, + { + 0, 1, 1, 4294967294, + 4294967294, 4294967294, 4294967294, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 9, + }, + { + 0, 1, 2, 4294967294, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 18, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-28.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-28.c new file mode 100644 index 0000000000000..5b32c97d37e2e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-28.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint64_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_ADD_FMT_7 + +DEF_VEC_SAT_U_ADD_FMT_7(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 4, + 5, 18446744073709551614u, 18446744073709551615u, 9, + }, + { + 0, 1, 1, 18446744073709551614u, + 18446744073709551614u, 18446744073709551614u, 18446744073709551614u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 9, + }, + { + 0, 1, 2, 18446744073709551614u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-29.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-29.c new file mode 100644 index 0000000000000..a8ed9b6e52b8f --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-29.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint8_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_ADD_FMT_8 + +DEF_VEC_SAT_U_ADD_FMT_8(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + }, + { + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + }, + { + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 4, + 5, 254, 255, 9, + }, + { + 0, 1, 1, 254, + 254, 254, 254, 255, + 255, 255, 255, 255, + 255, 255, 255, 9, + }, + { + 0, 1, 2, 254, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 18, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-3.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-3.c index 20ad2736403ef..f1b3a4fc79ebe 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-3.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-3.c @@ -1,7 +1,7 @@ /* { dg-do run { target { riscv_v } } } */ /* { dg-additional-options "-std=c99" } */ -#include "../../../sat_arith.h" +#include "vec_sat_arith.h" #define T uint32_t #define N 16 diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-30.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-30.c new file mode 100644 index 0000000000000..dd8d1a6970c1d --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-30.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint16_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_ADD_FMT_8 + +DEF_VEC_SAT_U_ADD_FMT_8(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 4, + 5, 65534, 65535, 9, + }, + { + 0, 1, 1, 65534, + 65534, 65534, 65534, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 9, + }, + { + 0, 1, 2, 65534, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 18, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-31.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-31.c new file mode 100644 index 0000000000000..a0fe504821cf3 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-31.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint32_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_ADD_FMT_8 + +DEF_VEC_SAT_U_ADD_FMT_8(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 4, + 5, 4294967294, 4294967295, 9, + }, + { + 0, 1, 1, 4294967294, + 4294967294, 4294967294, 4294967294, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 9, + }, + { + 0, 1, 2, 4294967294, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 18, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-32.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-32.c new file mode 100644 index 0000000000000..4aa353bea7510 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-32.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint64_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_ADD_FMT_8 + +DEF_VEC_SAT_U_ADD_FMT_8(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 4, + 5, 18446744073709551614u, 18446744073709551615u, 9, + }, + { + 0, 1, 1, 18446744073709551614u, + 18446744073709551614u, 18446744073709551614u, 18446744073709551614u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 9, + }, + { + 0, 1, 2, 18446744073709551614u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-4.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-4.c index 2f31edc527edf..4768d6283c6bb 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-4.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-4.c @@ -1,7 +1,7 @@ /* { dg-do run { target { riscv_v } } } */ /* { dg-additional-options "-std=c99" } */ -#include "../../../sat_arith.h" +#include "vec_sat_arith.h" #define T uint64_t #define N 16 diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-5.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-5.c new file mode 100644 index 0000000000000..aa6ec96d2dbb9 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-5.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint8_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_ADD_FMT_2 + +DEF_VEC_SAT_U_ADD_FMT_2(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + }, + { + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + }, + { + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 4, + 5, 254, 255, 9, + }, + { + 0, 1, 1, 254, + 254, 254, 254, 255, + 255, 255, 255, 255, + 255, 255, 255, 9, + }, + { + 0, 1, 2, 254, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 18, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-6.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-6.c new file mode 100644 index 0000000000000..3ba88c149e2ff --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-6.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint16_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_ADD_FMT_2 + +DEF_VEC_SAT_U_ADD_FMT_2(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 4, + 5, 65534, 65535, 9, + }, + { + 0, 1, 1, 65534, + 65534, 65534, 65534, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 9, + }, + { + 0, 1, 2, 65534, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 18, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-7.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-7.c new file mode 100644 index 0000000000000..b1c06efc48c4d --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-7.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint32_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_ADD_FMT_2 + +DEF_VEC_SAT_U_ADD_FMT_2(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 4, + 5, 4294967294, 4294967295, 9, + }, + { + 0, 1, 1, 4294967294, + 4294967294, 4294967294, 4294967294, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 9, + }, + { + 0, 1, 2, 4294967294, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 18, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-8.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-8.c new file mode 100644 index 0000000000000..df3b70d9c53df --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-8.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint64_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_ADD_FMT_2 + +DEF_VEC_SAT_U_ADD_FMT_2(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 4, + 5, 18446744073709551614u, 18446744073709551615u, 9, + }, + { + 0, 1, 1, 18446744073709551614u, + 18446744073709551614u, 18446744073709551614u, 18446744073709551614u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 9, + }, + { + 0, 1, 2, 18446744073709551614u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-9.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-9.c new file mode 100644 index 0000000000000..31919eda7e990 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-9.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint8_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_ADD_FMT_3 + +DEF_VEC_SAT_U_ADD_FMT_3(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + }, + { + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + }, + { + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 255, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 4, + 5, 254, 255, 9, + }, + { + 0, 1, 1, 254, + 254, 254, 254, 255, + 255, 255, 255, 255, + 255, 255, 255, 9, + }, + { + 0, 1, 2, 254, + 255, 255, 255, 255, + 255, 255, 255, 255, + 255, 255, 255, 18, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-1.c new file mode 100644 index 0000000000000..ff444ea386217 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-1.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint8_t_fmt_1: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e8,\s*m1,\s*ta,\s*ma +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_1(uint8_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 4 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-10.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-10.c new file mode 100644 index 0000000000000..e1c4020b36d27 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-10.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint16_t_fmt_3: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e16,\s*m1,\s*ta,\s*ma +** ... +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_3(uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-11.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-11.c new file mode 100644 index 0000000000000..cf744ade7c74f --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-11.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint32_t_fmt_3: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e32,\s*m1,\s*ta,\s*ma +** ... +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_3(uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-12.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-12.c new file mode 100644 index 0000000000000..c2d7e01ddf03f --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-12.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint64_t_fmt_3: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e64,\s*m1,\s*ta,\s*ma +** ... +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_3(uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-13.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-13.c new file mode 100644 index 0000000000000..d4d098f062320 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-13.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint8_t_fmt_4: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e8,\s*m1,\s*ta,\s*ma +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_4(uint8_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-14.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-14.c new file mode 100644 index 0000000000000..ba274f514dd95 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-14.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint16_t_fmt_4: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e16,\s*m1,\s*ta,\s*ma +** ... +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_4(uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-15.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-15.c new file mode 100644 index 0000000000000..5b666be33be08 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-15.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint32_t_fmt_4: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e32,\s*m1,\s*ta,\s*ma +** ... +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_4(uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-16.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-16.c new file mode 100644 index 0000000000000..6830f06945c7e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-16.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint64_t_fmt_4: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e64,\s*m1,\s*ta,\s*ma +** ... +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_4(uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-17.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-17.c new file mode 100644 index 0000000000000..8d50f5ff26c01 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-17.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint8_t_fmt_5: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e8,\s*m1,\s*ta,\s*ma +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_5(uint8_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-18.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-18.c new file mode 100644 index 0000000000000..a431ded301c71 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-18.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint16_t_fmt_5: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e16,\s*m1,\s*ta,\s*ma +** ... +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_5(uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-19.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-19.c new file mode 100644 index 0000000000000..acc7ef2d4f504 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-19.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint32_t_fmt_5: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e32,\s*m1,\s*ta,\s*ma +** ... +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_5(uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-2.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-2.c new file mode 100644 index 0000000000000..2bde6a23ead01 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-2.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint16_t_fmt_1: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e16,\s*m1,\s*ta,\s*ma +** ... +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_1(uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 4 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-20.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-20.c new file mode 100644 index 0000000000000..d74c09726350f --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-20.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint64_t_fmt_5: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e64,\s*m1,\s*ta,\s*ma +** ... +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_5(uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-21.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-21.c new file mode 100644 index 0000000000000..9799a1eb0c7ec --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-21.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint8_t_fmt_6: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e8,\s*m1,\s*ta,\s*ma +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_6(uint8_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-22.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-22.c new file mode 100644 index 0000000000000..bb1eeb42cf97d --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-22.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint16_t_fmt_6: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e16,\s*m1,\s*ta,\s*ma +** ... +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_6(uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-23.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-23.c new file mode 100644 index 0000000000000..642003cc11887 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-23.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint32_t_fmt_6: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e32,\s*m1,\s*ta,\s*ma +** ... +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_6(uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-24.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-24.c new file mode 100644 index 0000000000000..9bc9529573897 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-24.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint64_t_fmt_6: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e64,\s*m1,\s*ta,\s*ma +** ... +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_6(uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-25.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-25.c new file mode 100644 index 0000000000000..760eb3140bf9a --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-25.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint8_t_fmt_7: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e8,\s*m1,\s*ta,\s*ma +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_7(uint8_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 4 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-26.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-26.c new file mode 100644 index 0000000000000..1588161581270 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-26.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint16_t_fmt_7: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e16,\s*m1,\s*ta,\s*ma +** ... +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_7(uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 4 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-27.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-27.c new file mode 100644 index 0000000000000..611923bdc064e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-27.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint32_t_fmt_7: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e32,\s*m1,\s*ta,\s*ma +** ... +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_7(uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 4 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-28.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-28.c new file mode 100644 index 0000000000000..7fd0a1c24465d --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-28.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint64_t_fmt_7: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e64,\s*m1,\s*ta,\s*ma +** ... +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_7(uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 4 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-29.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-29.c new file mode 100644 index 0000000000000..2af9357948af4 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-29.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint8_t_fmt_8: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e8,\s*m1,\s*ta,\s*ma +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_8(uint8_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 4 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-3.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-3.c new file mode 100644 index 0000000000000..ab688fcde9618 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-3.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint32_t_fmt_1: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e32,\s*m1,\s*ta,\s*ma +** ... +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_1(uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 4 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-30.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-30.c new file mode 100644 index 0000000000000..7c2922be80da0 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-30.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint16_t_fmt_8: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e16,\s*m1,\s*ta,\s*ma +** ... +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_8(uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 4 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-31.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-31.c new file mode 100644 index 0000000000000..4be50b94f2712 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-31.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint32_t_fmt_8: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e32,\s*m1,\s*ta,\s*ma +** ... +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_8(uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 4 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-32.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-32.c new file mode 100644 index 0000000000000..28f05dca93bae --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-32.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint64_t_fmt_8: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e64,\s*m1,\s*ta,\s*ma +** ... +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_8(uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 4 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-33.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-33.c new file mode 100644 index 0000000000000..3478bb6ebc2c0 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-33.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint8_t_fmt_9: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e8,\s*m1,\s*ta,\s*ma +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_9(uint8_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-34.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-34.c new file mode 100644 index 0000000000000..a529395353521 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-34.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint16_t_fmt_9: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e16,\s*m1,\s*ta,\s*ma +** ... +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_9(uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-35.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-35.c new file mode 100644 index 0000000000000..69b2a60ea7e20 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-35.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint32_t_fmt_9: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e32,\s*m1,\s*ta,\s*ma +** ... +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_9(uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-36.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-36.c new file mode 100644 index 0000000000000..86c60cdbd442f --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-36.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint64_t_fmt_9: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e64,\s*m1,\s*ta,\s*ma +** ... +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_9(uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-37.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-37.c new file mode 100644 index 0000000000000..d58da2abd7651 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-37.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint8_t_fmt_10: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e8,\s*m1,\s*ta,\s*ma +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_10(uint8_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-38.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-38.c new file mode 100644 index 0000000000000..a8ec4f6548c4c --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-38.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint16_t_fmt_10: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e16,\s*m1,\s*ta,\s*ma +** ... +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_10(uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-39.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-39.c new file mode 100644 index 0000000000000..0bb1b46e31937 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-39.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint32_t_fmt_10: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e32,\s*m1,\s*ta,\s*ma +** ... +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_10(uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-4.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-4.c new file mode 100644 index 0000000000000..8bcca4fa474e7 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-4.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint64_t_fmt_1: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e64,\s*m1,\s*ta,\s*ma +** ... +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_1(uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 4 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-40.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-40.c new file mode 100644 index 0000000000000..d75c101a6beba --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-40.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint64_t_fmt_10: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e64,\s*m1,\s*ta,\s*ma +** ... +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_10(uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-5.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-5.c new file mode 100644 index 0000000000000..b05f3ad14ee12 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-5.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint8_t_fmt_2: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e8,\s*m1,\s*ta,\s*ma +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_2(uint8_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 4 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-6.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-6.c new file mode 100644 index 0000000000000..251a533235063 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-6.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint16_t_fmt_2: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e16,\s*m1,\s*ta,\s*ma +** ... +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle16\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_2(uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 4 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-7.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-7.c new file mode 100644 index 0000000000000..23fc3dcb1fd2e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-7.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint32_t_fmt_2: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e32,\s*m1,\s*ta,\s*ma +** ... +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle32\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_2(uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 4 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-8.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-8.c new file mode 100644 index 0000000000000..9ad3f327ed730 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-8.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint64_t_fmt_2: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e64,\s*m1,\s*ta,\s*ma +** ... +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle64\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_2(uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 4 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-9.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-9.c new file mode 100644 index 0000000000000..5075a535dd17b --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-9.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "vec_sat_arith.h" + +/* +** vec_sat_u_sub_uint8_t_fmt_3: +** ... +** vsetvli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*e8,\s*m1,\s*ta,\s*ma +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vle8\.v\s+v[0-9]+,\s*0\([atx][0-9]+\) +** vssubu\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+ +** ... +*/ +DEF_VEC_SAT_U_SUB_FMT_3(uint8_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-1.c new file mode 100644 index 0000000000000..b6c48388cf82d --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-1.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint8_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_1 + +DEF_VEC_SAT_U_SUB_FMT_1(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 0, 255, 255, 255, + 0, 255, 255, 255, + 0, 255, 255, 255, + 0, 255, 255, 255, + }, + { + 1, 255, 254, 251, + 1, 255, 254, 251, + 1, 255, 254, 251, + 1, 255, 254, 251, + }, + { + 0, 0, 1, 4, + 0, 0, 1, 4, + 0, 0, 1, 4, + 0, 0, 1, 4, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 255, + 5, 254, 255, 9, + }, + { + 0, 1, 0, 254, + 254, 254, 254, 255, + 255, 255, 0, 252, + 255, 255, 255, 1, + }, + { + 0, 0, 1, 0, + 0, 0, 0, 0, + 0, 0, 3, 3, + 0, 0, 0, 8, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-10.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-10.c new file mode 100644 index 0000000000000..d827c6be73bf9 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-10.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint16_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_3 + +DEF_VEC_SAT_U_SUB_FMT_3(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + { + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + }, + { + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 65535, 3, 65535, + 5, 65534, 65535, 9, + }, + { + 0, 1, 1, 65534, + 65534, 65534, 1, 65535, + 0, 65535, 65535, 0, + 65535, 65535, 1, 2, + }, + { + 0, 0, 0, 0, + 0, 0, 2, 0, + 1, 0, 0, 65535, + 0, 0, 65534, 7, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-11.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-11.c new file mode 100644 index 0000000000000..1f99d0d7b217b --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-11.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint32_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_3 + +DEF_VEC_SAT_U_SUB_FMT_3(T) + +T test_data[][3][N] = { + { + { + 0, 0, 4, 0, + 0, 0, 4, 0, + 0, 0, 4, 0, + 0, 0, 4, 0, + }, /* arg_0 */ + { + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + }, /* arg_1 */ + { + 0, 0, 2, 0, + 0, 0, 2, 0, + 0, 0, 2, 0, + 0, 0, 2, 0, + }, /* expect */ + }, + { + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + { + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + }, + { + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + }, + }, + { + { + 0, 0, 9, 0, + 1, 4294967295, 3, 0, + 1, 2, 3, 4, + 5, 4294967294, 4294967295, 4294967295, + }, + { + 0, 1, 1, 4294967294, + 1, 2, 4294967294, 4294967295, + 1, 4294967295, 4294967295, 1, + 1, 4294967295, 4294967290, 9, + }, + { + 0, 0, 8, 0, + 0, 4294967293, 0, 0, + 0, 0, 0, 3, + 4, 0, 5, 4294967286, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-12.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-12.c new file mode 100644 index 0000000000000..a9ad03c3898da --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-12.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint64_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_3 + +DEF_VEC_SAT_U_SUB_FMT_3(T) + +T test_data[][3][N] = { + { + { + 0, 9, 0, 0, + 0, 9, 0, 0, + 0, 9, 0, 0, + 0, 9, 0, 0, + }, /* arg_0 */ + { + 0, 2, 3, 1, + 0, 2, 3, 1, + 0, 2, 3, 1, + 0, 2, 3, 1, + }, /* arg_1 */ + { + 0, 7, 0, 0, + 0, 7, 0, 0, + 0, 7, 0, 0, + 0, 7, 0, 0, + }, /* expect */ + }, + { + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + { + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + }, + { + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + }, + }, + { + { + 0, 18446744073709551615u, 1, 0, + 1, 18446744073709551615u, 3, 0, + 1, 18446744073709551614u, 3, 4, + 5, 18446744073709551614u, 18446744073709551615u, 9, + }, + { + 0, 1, 1, 18446744073709551614u, + 18446744073709551614u, 18446744073709551614u, 18446744073709551614u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 1, + }, + { + 0, 18446744073709551614u, 0, 0, + 0, 1, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 8, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-13.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-13.c new file mode 100644 index 0000000000000..b56115d55b3f4 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-13.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint8_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_4 + +DEF_VEC_SAT_U_SUB_FMT_4(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 0, 255, 255, 255, + 0, 255, 255, 255, + 0, 255, 255, 255, + 0, 255, 255, 255, + }, + { + 1, 255, 254, 251, + 1, 255, 254, 251, + 1, 255, 254, 251, + 1, 255, 254, 251, + }, + { + 0, 0, 1, 4, + 0, 0, 1, 4, + 0, 0, 1, 4, + 0, 0, 1, 4, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 255, + 5, 254, 255, 9, + }, + { + 0, 1, 0, 254, + 254, 254, 254, 255, + 255, 255, 0, 252, + 255, 255, 255, 1, + }, + { + 0, 0, 1, 0, + 0, 0, 0, 0, + 0, 0, 3, 3, + 0, 0, 0, 8, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-14.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-14.c new file mode 100644 index 0000000000000..220007dc6fce1 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-14.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint16_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_4 + +DEF_VEC_SAT_U_SUB_FMT_4(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + { + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + }, + { + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 65535, 3, 65535, + 5, 65534, 65535, 9, + }, + { + 0, 1, 1, 65534, + 65534, 65534, 1, 65535, + 0, 65535, 65535, 0, + 65535, 65535, 1, 2, + }, + { + 0, 0, 0, 0, + 0, 0, 2, 0, + 1, 0, 0, 65535, + 0, 0, 65534, 7, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-15.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-15.c new file mode 100644 index 0000000000000..5876148784c5b --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-15.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint32_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_4 + +DEF_VEC_SAT_U_SUB_FMT_4(T) + +T test_data[][3][N] = { + { + { + 0, 0, 4, 0, + 0, 0, 4, 0, + 0, 0, 4, 0, + 0, 0, 4, 0, + }, /* arg_0 */ + { + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + }, /* arg_1 */ + { + 0, 0, 2, 0, + 0, 0, 2, 0, + 0, 0, 2, 0, + 0, 0, 2, 0, + }, /* expect */ + }, + { + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + { + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + }, + { + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + }, + }, + { + { + 0, 0, 9, 0, + 1, 4294967295, 3, 0, + 1, 2, 3, 4, + 5, 4294967294, 4294967295, 4294967295, + }, + { + 0, 1, 1, 4294967294, + 1, 2, 4294967294, 4294967295, + 1, 4294967295, 4294967295, 1, + 1, 4294967295, 4294967290, 9, + }, + { + 0, 0, 8, 0, + 0, 4294967293, 0, 0, + 0, 0, 0, 3, + 4, 0, 5, 4294967286, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-16.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-16.c new file mode 100644 index 0000000000000..468193932bfd0 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-16.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint64_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_4 + +DEF_VEC_SAT_U_SUB_FMT_4(T) + +T test_data[][3][N] = { + { + { + 0, 9, 0, 0, + 0, 9, 0, 0, + 0, 9, 0, 0, + 0, 9, 0, 0, + }, /* arg_0 */ + { + 0, 2, 3, 1, + 0, 2, 3, 1, + 0, 2, 3, 1, + 0, 2, 3, 1, + }, /* arg_1 */ + { + 0, 7, 0, 0, + 0, 7, 0, 0, + 0, 7, 0, 0, + 0, 7, 0, 0, + }, /* expect */ + }, + { + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + { + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + }, + { + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + }, + }, + { + { + 0, 18446744073709551615u, 1, 0, + 1, 18446744073709551615u, 3, 0, + 1, 18446744073709551614u, 3, 4, + 5, 18446744073709551614u, 18446744073709551615u, 9, + }, + { + 0, 1, 1, 18446744073709551614u, + 18446744073709551614u, 18446744073709551614u, 18446744073709551614u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 1, + }, + { + 0, 18446744073709551614u, 0, 0, + 0, 1, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 8, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-17.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-17.c new file mode 100644 index 0000000000000..12207ad7f52b0 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-17.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint8_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_5 + +DEF_VEC_SAT_U_SUB_FMT_5(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 0, 255, 255, 255, + 0, 255, 255, 255, + 0, 255, 255, 255, + 0, 255, 255, 255, + }, + { + 1, 255, 254, 251, + 1, 255, 254, 251, + 1, 255, 254, 251, + 1, 255, 254, 251, + }, + { + 0, 0, 1, 4, + 0, 0, 1, 4, + 0, 0, 1, 4, + 0, 0, 1, 4, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 255, + 5, 254, 255, 9, + }, + { + 0, 1, 0, 254, + 254, 254, 254, 255, + 255, 255, 0, 252, + 255, 255, 255, 1, + }, + { + 0, 0, 1, 0, + 0, 0, 0, 0, + 0, 0, 3, 3, + 0, 0, 0, 8, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-18.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-18.c new file mode 100644 index 0000000000000..9614f42417a90 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-18.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint16_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_5 + +DEF_VEC_SAT_U_SUB_FMT_5(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + { + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + }, + { + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 65535, 3, 65535, + 5, 65534, 65535, 9, + }, + { + 0, 1, 1, 65534, + 65534, 65534, 1, 65535, + 0, 65535, 65535, 0, + 65535, 65535, 1, 2, + }, + { + 0, 0, 0, 0, + 0, 0, 2, 0, + 1, 0, 0, 65535, + 0, 0, 65534, 7, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-19.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-19.c new file mode 100644 index 0000000000000..cbaf2b1427907 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-19.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint32_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_5 + +DEF_VEC_SAT_U_SUB_FMT_5(T) + +T test_data[][3][N] = { + { + { + 0, 0, 4, 0, + 0, 0, 4, 0, + 0, 0, 4, 0, + 0, 0, 4, 0, + }, /* arg_0 */ + { + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + }, /* arg_1 */ + { + 0, 0, 2, 0, + 0, 0, 2, 0, + 0, 0, 2, 0, + 0, 0, 2, 0, + }, /* expect */ + }, + { + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + { + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + }, + { + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + }, + }, + { + { + 0, 0, 9, 0, + 1, 4294967295, 3, 0, + 1, 2, 3, 4, + 5, 4294967294, 4294967295, 4294967295, + }, + { + 0, 1, 1, 4294967294, + 1, 2, 4294967294, 4294967295, + 1, 4294967295, 4294967295, 1, + 1, 4294967295, 4294967290, 9, + }, + { + 0, 0, 8, 0, + 0, 4294967293, 0, 0, + 0, 0, 0, 3, + 4, 0, 5, 4294967286, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-2.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-2.c new file mode 100644 index 0000000000000..18b53fd2df94c --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-2.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint16_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_1 + +DEF_VEC_SAT_U_SUB_FMT_1(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + { + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + }, + { + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 65535, 3, 65535, + 5, 65534, 65535, 9, + }, + { + 0, 1, 1, 65534, + 65534, 65534, 1, 65535, + 0, 65535, 65535, 0, + 65535, 65535, 1, 2, + }, + { + 0, 0, 0, 0, + 0, 0, 2, 0, + 1, 0, 0, 65535, + 0, 0, 65534, 7, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-20.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-20.c new file mode 100644 index 0000000000000..e1c59a977f0d9 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-20.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint64_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_5 + +DEF_VEC_SAT_U_SUB_FMT_5(T) + +T test_data[][3][N] = { + { + { + 0, 9, 0, 0, + 0, 9, 0, 0, + 0, 9, 0, 0, + 0, 9, 0, 0, + }, /* arg_0 */ + { + 0, 2, 3, 1, + 0, 2, 3, 1, + 0, 2, 3, 1, + 0, 2, 3, 1, + }, /* arg_1 */ + { + 0, 7, 0, 0, + 0, 7, 0, 0, + 0, 7, 0, 0, + 0, 7, 0, 0, + }, /* expect */ + }, + { + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + { + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + }, + { + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + }, + }, + { + { + 0, 18446744073709551615u, 1, 0, + 1, 18446744073709551615u, 3, 0, + 1, 18446744073709551614u, 3, 4, + 5, 18446744073709551614u, 18446744073709551615u, 9, + }, + { + 0, 1, 1, 18446744073709551614u, + 18446744073709551614u, 18446744073709551614u, 18446744073709551614u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 1, + }, + { + 0, 18446744073709551614u, 0, 0, + 0, 1, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 8, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-21.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-21.c new file mode 100644 index 0000000000000..aec82f86376de --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-21.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint8_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_6 + +DEF_VEC_SAT_U_SUB_FMT_6(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 0, 255, 255, 255, + 0, 255, 255, 255, + 0, 255, 255, 255, + 0, 255, 255, 255, + }, + { + 1, 255, 254, 251, + 1, 255, 254, 251, + 1, 255, 254, 251, + 1, 255, 254, 251, + }, + { + 0, 0, 1, 4, + 0, 0, 1, 4, + 0, 0, 1, 4, + 0, 0, 1, 4, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 255, + 5, 254, 255, 9, + }, + { + 0, 1, 0, 254, + 254, 254, 254, 255, + 255, 255, 0, 252, + 255, 255, 255, 1, + }, + { + 0, 0, 1, 0, + 0, 0, 0, 0, + 0, 0, 3, 3, + 0, 0, 0, 8, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-22.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-22.c new file mode 100644 index 0000000000000..bd5c7d206b459 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-22.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint16_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_6 + +DEF_VEC_SAT_U_SUB_FMT_6(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + { + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + }, + { + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 65535, 3, 65535, + 5, 65534, 65535, 9, + }, + { + 0, 1, 1, 65534, + 65534, 65534, 1, 65535, + 0, 65535, 65535, 0, + 65535, 65535, 1, 2, + }, + { + 0, 0, 0, 0, + 0, 0, 2, 0, + 1, 0, 0, 65535, + 0, 0, 65534, 7, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-23.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-23.c new file mode 100644 index 0000000000000..f5a1d6bd93043 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-23.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint32_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_6 + +DEF_VEC_SAT_U_SUB_FMT_6(T) + +T test_data[][3][N] = { + { + { + 0, 0, 4, 0, + 0, 0, 4, 0, + 0, 0, 4, 0, + 0, 0, 4, 0, + }, /* arg_0 */ + { + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + }, /* arg_1 */ + { + 0, 0, 2, 0, + 0, 0, 2, 0, + 0, 0, 2, 0, + 0, 0, 2, 0, + }, /* expect */ + }, + { + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + { + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + }, + { + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + }, + }, + { + { + 0, 0, 9, 0, + 1, 4294967295, 3, 0, + 1, 2, 3, 4, + 5, 4294967294, 4294967295, 4294967295, + }, + { + 0, 1, 1, 4294967294, + 1, 2, 4294967294, 4294967295, + 1, 4294967295, 4294967295, 1, + 1, 4294967295, 4294967290, 9, + }, + { + 0, 0, 8, 0, + 0, 4294967293, 0, 0, + 0, 0, 0, 3, + 4, 0, 5, 4294967286, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-24.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-24.c new file mode 100644 index 0000000000000..62c54a21e6fa3 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-24.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint64_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_6 + +DEF_VEC_SAT_U_SUB_FMT_6(T) + +T test_data[][3][N] = { + { + { + 0, 9, 0, 0, + 0, 9, 0, 0, + 0, 9, 0, 0, + 0, 9, 0, 0, + }, /* arg_0 */ + { + 0, 2, 3, 1, + 0, 2, 3, 1, + 0, 2, 3, 1, + 0, 2, 3, 1, + }, /* arg_1 */ + { + 0, 7, 0, 0, + 0, 7, 0, 0, + 0, 7, 0, 0, + 0, 7, 0, 0, + }, /* expect */ + }, + { + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + { + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + }, + { + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + }, + }, + { + { + 0, 18446744073709551615u, 1, 0, + 1, 18446744073709551615u, 3, 0, + 1, 18446744073709551614u, 3, 4, + 5, 18446744073709551614u, 18446744073709551615u, 9, + }, + { + 0, 1, 1, 18446744073709551614u, + 18446744073709551614u, 18446744073709551614u, 18446744073709551614u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 1, + }, + { + 0, 18446744073709551614u, 0, 0, + 0, 1, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 8, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-25.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-25.c new file mode 100644 index 0000000000000..b5bc00195a1fd --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-25.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint8_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_7 + +DEF_VEC_SAT_U_SUB_FMT_7(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 0, 255, 255, 255, + 0, 255, 255, 255, + 0, 255, 255, 255, + 0, 255, 255, 255, + }, + { + 1, 255, 254, 251, + 1, 255, 254, 251, + 1, 255, 254, 251, + 1, 255, 254, 251, + }, + { + 0, 0, 1, 4, + 0, 0, 1, 4, + 0, 0, 1, 4, + 0, 0, 1, 4, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 255, + 5, 254, 255, 9, + }, + { + 0, 1, 0, 254, + 254, 254, 254, 255, + 255, 255, 0, 252, + 255, 255, 255, 1, + }, + { + 0, 0, 1, 0, + 0, 0, 0, 0, + 0, 0, 3, 3, + 0, 0, 0, 8, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-26.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-26.c new file mode 100644 index 0000000000000..4446e150493ed --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-26.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint16_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_7 + +DEF_VEC_SAT_U_SUB_FMT_7(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + { + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + }, + { + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 65535, 3, 65535, + 5, 65534, 65535, 9, + }, + { + 0, 1, 1, 65534, + 65534, 65534, 1, 65535, + 0, 65535, 65535, 0, + 65535, 65535, 1, 2, + }, + { + 0, 0, 0, 0, + 0, 0, 2, 0, + 1, 0, 0, 65535, + 0, 0, 65534, 7, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-27.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-27.c new file mode 100644 index 0000000000000..dd725a5c8ffbf --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-27.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint32_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_7 + +DEF_VEC_SAT_U_SUB_FMT_7(T) + +T test_data[][3][N] = { + { + { + 0, 0, 4, 0, + 0, 0, 4, 0, + 0, 0, 4, 0, + 0, 0, 4, 0, + }, /* arg_0 */ + { + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + }, /* arg_1 */ + { + 0, 0, 2, 0, + 0, 0, 2, 0, + 0, 0, 2, 0, + 0, 0, 2, 0, + }, /* expect */ + }, + { + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + { + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + }, + { + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + }, + }, + { + { + 0, 0, 9, 0, + 1, 4294967295, 3, 0, + 1, 2, 3, 4, + 5, 4294967294, 4294967295, 4294967295, + }, + { + 0, 1, 1, 4294967294, + 1, 2, 4294967294, 4294967295, + 1, 4294967295, 4294967295, 1, + 1, 4294967295, 4294967290, 9, + }, + { + 0, 0, 8, 0, + 0, 4294967293, 0, 0, + 0, 0, 0, 3, + 4, 0, 5, 4294967286, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-28.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-28.c new file mode 100644 index 0000000000000..6baf65bea18eb --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-28.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint64_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_7 + +DEF_VEC_SAT_U_SUB_FMT_7(T) + +T test_data[][3][N] = { + { + { + 0, 9, 0, 0, + 0, 9, 0, 0, + 0, 9, 0, 0, + 0, 9, 0, 0, + }, /* arg_0 */ + { + 0, 2, 3, 1, + 0, 2, 3, 1, + 0, 2, 3, 1, + 0, 2, 3, 1, + }, /* arg_1 */ + { + 0, 7, 0, 0, + 0, 7, 0, 0, + 0, 7, 0, 0, + 0, 7, 0, 0, + }, /* expect */ + }, + { + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + { + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + }, + { + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + }, + }, + { + { + 0, 18446744073709551615u, 1, 0, + 1, 18446744073709551615u, 3, 0, + 1, 18446744073709551614u, 3, 4, + 5, 18446744073709551614u, 18446744073709551615u, 9, + }, + { + 0, 1, 1, 18446744073709551614u, + 18446744073709551614u, 18446744073709551614u, 18446744073709551614u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 1, + }, + { + 0, 18446744073709551614u, 0, 0, + 0, 1, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 8, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-29.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-29.c new file mode 100644 index 0000000000000..b828e95b8a1ac --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-29.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint8_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_8 + +DEF_VEC_SAT_U_SUB_FMT_8(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 0, 255, 255, 255, + 0, 255, 255, 255, + 0, 255, 255, 255, + 0, 255, 255, 255, + }, + { + 1, 255, 254, 251, + 1, 255, 254, 251, + 1, 255, 254, 251, + 1, 255, 254, 251, + }, + { + 0, 0, 1, 4, + 0, 0, 1, 4, + 0, 0, 1, 4, + 0, 0, 1, 4, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 255, + 5, 254, 255, 9, + }, + { + 0, 1, 0, 254, + 254, 254, 254, 255, + 255, 255, 0, 252, + 255, 255, 255, 1, + }, + { + 0, 0, 1, 0, + 0, 0, 0, 0, + 0, 0, 3, 3, + 0, 0, 0, 8, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-3.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-3.c new file mode 100644 index 0000000000000..527a95b9a9f97 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-3.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint32_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_1 + +DEF_VEC_SAT_U_SUB_FMT_1(T) + +T test_data[][3][N] = { + { + { + 0, 0, 4, 0, + 0, 0, 4, 0, + 0, 0, 4, 0, + 0, 0, 4, 0, + }, /* arg_0 */ + { + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + }, /* arg_1 */ + { + 0, 0, 2, 0, + 0, 0, 2, 0, + 0, 0, 2, 0, + 0, 0, 2, 0, + }, /* expect */ + }, + { + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + { + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + }, + { + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + }, + }, + { + { + 0, 0, 9, 0, + 1, 4294967295, 3, 0, + 1, 2, 3, 4, + 5, 4294967294, 4294967295, 4294967295, + }, + { + 0, 1, 1, 4294967294, + 1, 2, 4294967294, 4294967295, + 1, 4294967295, 4294967295, 1, + 1, 4294967295, 4294967290, 9, + }, + { + 0, 0, 8, 0, + 0, 4294967293, 0, 0, + 0, 0, 0, 3, + 4, 0, 5, 4294967286, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-30.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-30.c new file mode 100644 index 0000000000000..232f78d35441a --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-30.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint16_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_8 + +DEF_VEC_SAT_U_SUB_FMT_8(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + { + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + }, + { + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 65535, 3, 65535, + 5, 65534, 65535, 9, + }, + { + 0, 1, 1, 65534, + 65534, 65534, 1, 65535, + 0, 65535, 65535, 0, + 65535, 65535, 1, 2, + }, + { + 0, 0, 0, 0, + 0, 0, 2, 0, + 1, 0, 0, 65535, + 0, 0, 65534, 7, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-31.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-31.c new file mode 100644 index 0000000000000..03355327c6d03 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-31.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint32_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_8 + +DEF_VEC_SAT_U_SUB_FMT_8(T) + +T test_data[][3][N] = { + { + { + 0, 0, 4, 0, + 0, 0, 4, 0, + 0, 0, 4, 0, + 0, 0, 4, 0, + }, /* arg_0 */ + { + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + }, /* arg_1 */ + { + 0, 0, 2, 0, + 0, 0, 2, 0, + 0, 0, 2, 0, + 0, 0, 2, 0, + }, /* expect */ + }, + { + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + { + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + }, + { + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + }, + }, + { + { + 0, 0, 9, 0, + 1, 4294967295, 3, 0, + 1, 2, 3, 4, + 5, 4294967294, 4294967295, 4294967295, + }, + { + 0, 1, 1, 4294967294, + 1, 2, 4294967294, 4294967295, + 1, 4294967295, 4294967295, 1, + 1, 4294967295, 4294967290, 9, + }, + { + 0, 0, 8, 0, + 0, 4294967293, 0, 0, + 0, 0, 0, 3, + 4, 0, 5, 4294967286, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-32.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-32.c new file mode 100644 index 0000000000000..f8872ca521b10 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-32.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint64_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_8 + +DEF_VEC_SAT_U_SUB_FMT_8(T) + +T test_data[][3][N] = { + { + { + 0, 9, 0, 0, + 0, 9, 0, 0, + 0, 9, 0, 0, + 0, 9, 0, 0, + }, /* arg_0 */ + { + 0, 2, 3, 1, + 0, 2, 3, 1, + 0, 2, 3, 1, + 0, 2, 3, 1, + }, /* arg_1 */ + { + 0, 7, 0, 0, + 0, 7, 0, 0, + 0, 7, 0, 0, + 0, 7, 0, 0, + }, /* expect */ + }, + { + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + { + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + }, + { + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + }, + }, + { + { + 0, 18446744073709551615u, 1, 0, + 1, 18446744073709551615u, 3, 0, + 1, 18446744073709551614u, 3, 4, + 5, 18446744073709551614u, 18446744073709551615u, 9, + }, + { + 0, 1, 1, 18446744073709551614u, + 18446744073709551614u, 18446744073709551614u, 18446744073709551614u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 1, + }, + { + 0, 18446744073709551614u, 0, 0, + 0, 1, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 8, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-33.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-33.c new file mode 100644 index 0000000000000..e8f38813cabd7 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-33.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint8_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_9 + +DEF_VEC_SAT_U_SUB_FMT_9(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 0, 255, 255, 255, + 0, 255, 255, 255, + 0, 255, 255, 255, + 0, 255, 255, 255, + }, + { + 1, 255, 254, 251, + 1, 255, 254, 251, + 1, 255, 254, 251, + 1, 255, 254, 251, + }, + { + 0, 0, 1, 4, + 0, 0, 1, 4, + 0, 0, 1, 4, + 0, 0, 1, 4, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 255, + 5, 254, 255, 9, + }, + { + 0, 1, 0, 254, + 254, 254, 254, 255, + 255, 255, 0, 252, + 255, 255, 255, 1, + }, + { + 0, 0, 1, 0, + 0, 0, 0, 0, + 0, 0, 3, 3, + 0, 0, 0, 8, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-34.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-34.c new file mode 100644 index 0000000000000..346e1df39f3e6 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-34.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint16_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_9 + +DEF_VEC_SAT_U_SUB_FMT_9(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + { + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + }, + { + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 65535, 3, 65535, + 5, 65534, 65535, 9, + }, + { + 0, 1, 1, 65534, + 65534, 65534, 1, 65535, + 0, 65535, 65535, 0, + 65535, 65535, 1, 2, + }, + { + 0, 0, 0, 0, + 0, 0, 2, 0, + 1, 0, 0, 65535, + 0, 0, 65534, 7, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-35.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-35.c new file mode 100644 index 0000000000000..587a36a93f04f --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-35.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint32_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_9 + +DEF_VEC_SAT_U_SUB_FMT_9(T) + +T test_data[][3][N] = { + { + { + 0, 0, 4, 0, + 0, 0, 4, 0, + 0, 0, 4, 0, + 0, 0, 4, 0, + }, /* arg_0 */ + { + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + }, /* arg_1 */ + { + 0, 0, 2, 0, + 0, 0, 2, 0, + 0, 0, 2, 0, + 0, 0, 2, 0, + }, /* expect */ + }, + { + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + { + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + }, + { + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + }, + }, + { + { + 0, 0, 9, 0, + 1, 4294967295, 3, 0, + 1, 2, 3, 4, + 5, 4294967294, 4294967295, 4294967295, + }, + { + 0, 1, 1, 4294967294, + 1, 2, 4294967294, 4294967295, + 1, 4294967295, 4294967295, 1, + 1, 4294967295, 4294967290, 9, + }, + { + 0, 0, 8, 0, + 0, 4294967293, 0, 0, + 0, 0, 0, 3, + 4, 0, 5, 4294967286, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-36.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-36.c new file mode 100644 index 0000000000000..84a71050e8137 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-36.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint64_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_9 + +DEF_VEC_SAT_U_SUB_FMT_9(T) + +T test_data[][3][N] = { + { + { + 0, 9, 0, 0, + 0, 9, 0, 0, + 0, 9, 0, 0, + 0, 9, 0, 0, + }, /* arg_0 */ + { + 0, 2, 3, 1, + 0, 2, 3, 1, + 0, 2, 3, 1, + 0, 2, 3, 1, + }, /* arg_1 */ + { + 0, 7, 0, 0, + 0, 7, 0, 0, + 0, 7, 0, 0, + 0, 7, 0, 0, + }, /* expect */ + }, + { + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + { + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + }, + { + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + }, + }, + { + { + 0, 18446744073709551615u, 1, 0, + 1, 18446744073709551615u, 3, 0, + 1, 18446744073709551614u, 3, 4, + 5, 18446744073709551614u, 18446744073709551615u, 9, + }, + { + 0, 1, 1, 18446744073709551614u, + 18446744073709551614u, 18446744073709551614u, 18446744073709551614u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 1, + }, + { + 0, 18446744073709551614u, 0, 0, + 0, 1, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 8, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-37.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-37.c new file mode 100644 index 0000000000000..ba5642aa2047e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-37.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint8_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_10 + +DEF_VEC_SAT_U_SUB_FMT_10(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 0, 255, 255, 255, + 0, 255, 255, 255, + 0, 255, 255, 255, + 0, 255, 255, 255, + }, + { + 1, 255, 254, 251, + 1, 255, 254, 251, + 1, 255, 254, 251, + 1, 255, 254, 251, + }, + { + 0, 0, 1, 4, + 0, 0, 1, 4, + 0, 0, 1, 4, + 0, 0, 1, 4, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 255, + 5, 254, 255, 9, + }, + { + 0, 1, 0, 254, + 254, 254, 254, 255, + 255, 255, 0, 252, + 255, 255, 255, 1, + }, + { + 0, 0, 1, 0, + 0, 0, 0, 0, + 0, 0, 3, 3, + 0, 0, 0, 8, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-38.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-38.c new file mode 100644 index 0000000000000..bdb1ca3bbb0f8 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-38.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint16_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_10 + +DEF_VEC_SAT_U_SUB_FMT_10(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + { + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + }, + { + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 65535, 3, 65535, + 5, 65534, 65535, 9, + }, + { + 0, 1, 1, 65534, + 65534, 65534, 1, 65535, + 0, 65535, 65535, 0, + 65535, 65535, 1, 2, + }, + { + 0, 0, 0, 0, + 0, 0, 2, 0, + 1, 0, 0, 65535, + 0, 0, 65534, 7, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-39.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-39.c new file mode 100644 index 0000000000000..10ec04f2ad323 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-39.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint32_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_10 + +DEF_VEC_SAT_U_SUB_FMT_10(T) + +T test_data[][3][N] = { + { + { + 0, 0, 4, 0, + 0, 0, 4, 0, + 0, 0, 4, 0, + 0, 0, 4, 0, + }, /* arg_0 */ + { + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + }, /* arg_1 */ + { + 0, 0, 2, 0, + 0, 0, 2, 0, + 0, 0, 2, 0, + 0, 0, 2, 0, + }, /* expect */ + }, + { + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + { + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + }, + { + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + }, + }, + { + { + 0, 0, 9, 0, + 1, 4294967295, 3, 0, + 1, 2, 3, 4, + 5, 4294967294, 4294967295, 4294967295, + }, + { + 0, 1, 1, 4294967294, + 1, 2, 4294967294, 4294967295, + 1, 4294967295, 4294967295, 1, + 1, 4294967295, 4294967290, 9, + }, + { + 0, 0, 8, 0, + 0, 4294967293, 0, 0, + 0, 0, 0, 3, + 4, 0, 5, 4294967286, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-4.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-4.c new file mode 100644 index 0000000000000..b78fd824acd52 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-4.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint64_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_1 + +DEF_VEC_SAT_U_SUB_FMT_1(T) + +T test_data[][3][N] = { + { + { + 0, 9, 0, 0, + 0, 9, 0, 0, + 0, 9, 0, 0, + 0, 9, 0, 0, + }, /* arg_0 */ + { + 0, 2, 3, 1, + 0, 2, 3, 1, + 0, 2, 3, 1, + 0, 2, 3, 1, + }, /* arg_1 */ + { + 0, 7, 0, 0, + 0, 7, 0, 0, + 0, 7, 0, 0, + 0, 7, 0, 0, + }, /* expect */ + }, + { + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + { + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + }, + { + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + }, + }, + { + { + 0, 18446744073709551615u, 1, 0, + 1, 18446744073709551615u, 3, 0, + 1, 18446744073709551614u, 3, 4, + 5, 18446744073709551614u, 18446744073709551615u, 9, + }, + { + 0, 1, 1, 18446744073709551614u, + 18446744073709551614u, 18446744073709551614u, 18446744073709551614u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 1, + }, + { + 0, 18446744073709551614u, 0, 0, + 0, 1, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 8, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-40.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-40.c new file mode 100644 index 0000000000000..f6a1277225aed --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-40.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint64_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_10 + +DEF_VEC_SAT_U_SUB_FMT_10(T) + +T test_data[][3][N] = { + { + { + 0, 9, 0, 0, + 0, 9, 0, 0, + 0, 9, 0, 0, + 0, 9, 0, 0, + }, /* arg_0 */ + { + 0, 2, 3, 1, + 0, 2, 3, 1, + 0, 2, 3, 1, + 0, 2, 3, 1, + }, /* arg_1 */ + { + 0, 7, 0, 0, + 0, 7, 0, 0, + 0, 7, 0, 0, + 0, 7, 0, 0, + }, /* expect */ + }, + { + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + { + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + }, + { + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + }, + }, + { + { + 0, 18446744073709551615u, 1, 0, + 1, 18446744073709551615u, 3, 0, + 1, 18446744073709551614u, 3, 4, + 5, 18446744073709551614u, 18446744073709551615u, 9, + }, + { + 0, 1, 1, 18446744073709551614u, + 18446744073709551614u, 18446744073709551614u, 18446744073709551614u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 1, + }, + { + 0, 18446744073709551614u, 0, 0, + 0, 1, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 8, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-5.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-5.c new file mode 100644 index 0000000000000..cf72540feee62 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-5.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint8_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_2 + +DEF_VEC_SAT_U_SUB_FMT_2(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 0, 255, 255, 255, + 0, 255, 255, 255, + 0, 255, 255, 255, + 0, 255, 255, 255, + }, + { + 1, 255, 254, 251, + 1, 255, 254, 251, + 1, 255, 254, 251, + 1, 255, 254, 251, + }, + { + 0, 0, 1, 4, + 0, 0, 1, 4, + 0, 0, 1, 4, + 0, 0, 1, 4, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 255, + 5, 254, 255, 9, + }, + { + 0, 1, 0, 254, + 254, 254, 254, 255, + 255, 255, 0, 252, + 255, 255, 255, 1, + }, + { + 0, 0, 1, 0, + 0, 0, 0, 0, + 0, 0, 3, 3, + 0, 0, 0, 8, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-6.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-6.c new file mode 100644 index 0000000000000..e4e0c5671797e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-6.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint16_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_2 + +DEF_VEC_SAT_U_SUB_FMT_2(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + 65535, 65535, 65535, 65535, + }, + { + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + 55535, 45535, 35535, 25535, + }, + { + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + 10000, 20000, 30000, 40000, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 65535, 3, 65535, + 5, 65534, 65535, 9, + }, + { + 0, 1, 1, 65534, + 65534, 65534, 1, 65535, + 0, 65535, 65535, 0, + 65535, 65535, 1, 2, + }, + { + 0, 0, 0, 0, + 0, 0, 2, 0, + 1, 0, 0, 65535, + 0, 0, 65534, 7, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-7.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-7.c new file mode 100644 index 0000000000000..833ec62f3c567 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-7.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint32_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_2 + +DEF_VEC_SAT_U_SUB_FMT_2(T) + +T test_data[][3][N] = { + { + { + 0, 0, 4, 0, + 0, 0, 4, 0, + 0, 0, 4, 0, + 0, 0, 4, 0, + }, /* arg_0 */ + { + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + }, /* arg_1 */ + { + 0, 0, 2, 0, + 0, 0, 2, 0, + 0, 0, 2, 0, + 0, 0, 2, 0, + }, /* expect */ + }, + { + { + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + { + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + 1294967295, 2294967295, 3294967295, 4294967295, + }, + { + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + 3000000000, 2000000000, 1000000000, 0, + }, + }, + { + { + 0, 0, 9, 0, + 1, 4294967295, 3, 0, + 1, 2, 3, 4, + 5, 4294967294, 4294967295, 4294967295, + }, + { + 0, 1, 1, 4294967294, + 1, 2, 4294967294, 4294967295, + 1, 4294967295, 4294967295, 1, + 1, 4294967295, 4294967290, 9, + }, + { + 0, 0, 8, 0, + 0, 4294967293, 0, 0, + 0, 0, 0, 3, + 4, 0, 5, 4294967286, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-8.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-8.c new file mode 100644 index 0000000000000..fea1629609e1e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-8.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint64_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_2 + +DEF_VEC_SAT_U_SUB_FMT_2(T) + +T test_data[][3][N] = { + { + { + 0, 9, 0, 0, + 0, 9, 0, 0, + 0, 9, 0, 0, + 0, 9, 0, 0, + }, /* arg_0 */ + { + 0, 2, 3, 1, + 0, 2, 3, 1, + 0, 2, 3, 1, + 0, 2, 3, 1, + }, /* arg_1 */ + { + 0, 7, 0, 0, + 0, 7, 0, 0, + 0, 7, 0, 0, + 0, 7, 0, 0, + }, /* expect */ + }, + { + { + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + }, + { + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + 10446744073709551615u, 11446744073709551615u, 12446744073709551615u, 18446744073709551615u, + }, + { + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + 8000000000000000000u, 7000000000000000000u, 6000000000000000000u, 0u, + }, + }, + { + { + 0, 18446744073709551615u, 1, 0, + 1, 18446744073709551615u, 3, 0, + 1, 18446744073709551614u, 3, 4, + 5, 18446744073709551614u, 18446744073709551615u, 9, + }, + { + 0, 1, 1, 18446744073709551614u, + 18446744073709551614u, 18446744073709551614u, 18446744073709551614u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, + 18446744073709551615u, 18446744073709551615u, 18446744073709551615u, 1, + }, + { + 0, 18446744073709551614u, 0, 0, + 0, 1, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 8, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-9.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-9.c new file mode 100644 index 0000000000000..d87d48b4e9419 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-9.c @@ -0,0 +1,75 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "vec_sat_arith.h" + +#define T uint8_t +#define N 16 +#define RUN_VEC_SAT_BINARY RUN_VEC_SAT_U_SUB_FMT_3 + +DEF_VEC_SAT_U_SUB_FMT_3(T) + +T test_data[][3][N] = { + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* arg_0 */ + { + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + 0, 1, 2, 3, + }, /* arg_1 */ + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, /* expect */ + }, + { + { + 0, 255, 255, 255, + 0, 255, 255, 255, + 0, 255, 255, 255, + 0, 255, 255, 255, + }, + { + 1, 255, 254, 251, + 1, 255, 254, 251, + 1, 255, 254, 251, + 1, 255, 254, 251, + }, + { + 0, 0, 1, 4, + 0, 0, 1, 4, + 0, 0, 1, 4, + 0, 0, 1, 4, + }, + }, + { + { + 0, 0, 1, 0, + 1, 2, 3, 0, + 1, 2, 3, 255, + 5, 254, 255, 9, + }, + { + 0, 1, 0, 254, + 254, 254, 254, 255, + 255, 255, 0, 252, + 255, 255, 255, 1, + }, + { + 0, 0, 1, 0, + 0, 0, 0, 0, + 0, 0, 3, 3, + 0, 0, 0, 8, + }, + }, +}; + +#include "vec_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/pr114352-1.c b/gcc/testsuite/gcc.target/riscv/rvv/base/pr114352-1.c index b3f1f20fb79c8..faeb406498dad 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/base/pr114352-1.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/pr114352-1.c @@ -54,5 +54,5 @@ test_3 (int *a, int *b, int *out, unsigned count) out[i] = a[i] + b[i]; } -/* { dg-final { scan-assembler ".attribute arch, \"rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0\"" } } */ -/* { dg-final { scan-assembler ".option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_v1p0_zicsr2p0_zifencei2p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0" } } */ +/* { dg-final { scan-assembler ".attribute arch, \"rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zaamo1p0_zalrsc1p0\"" } } */ +/* { dg-final { scan-assembler ".option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_v1p0_zicsr2p0_zifencei2p0_zaamo1p0_zalrsc1p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/pr114352-3.c b/gcc/testsuite/gcc.target/riscv/rvv/base/pr114352-3.c index e7af4223d6a02..38815ef5bd021 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/base/pr114352-3.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/pr114352-3.c @@ -107,7 +107,7 @@ test_6 (_Float16 *a, _Float16 *b, _Float16 *out, unsigned count) out[i] = a[i] + b[i]; } -/* { dg-final { scan-assembler ".attribute arch, \"rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0\"" } } */ -/* { dg-final { scan-assembler ".option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_v1p0_zicsr2p0_zifencei2p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0" } } */ -/* { dg-final { scan-assembler ".option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zbb1p0" } } */ -/* { dg-final { scan-assembler ".option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zfh1p0_zfhmin1p0" } } */ +/* { dg-final { scan-assembler ".attribute arch, \"rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zaamo1p0_zalrsc1p0\"" } } */ +/* { dg-final { scan-assembler ".option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_v1p0_zicsr2p0_zifencei2p0_zaamo1p0_zalrsc1p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0" } } */ +/* { dg-final { scan-assembler ".option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zaamo1p0_zalrsc1p0_zbb1p0" } } */ +/* { dg-final { scan-assembler ".option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zaamo1p0_zalrsc1p0_zfh1p0_zfhmin1p0" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/pr115456-1.c b/gcc/testsuite/gcc.target/riscv/rvv/base/pr115456-1.c new file mode 100644 index 0000000000000..2c6cc7121b4c2 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/pr115456-1.c @@ -0,0 +1,31 @@ +/* Test there is no ICE when compile. */ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvfhmin -mabi=lp64d -O3 -ftree-vectorize" } */ + +#include +#include + +typedef _Float16 vnx4f __attribute__ ((vector_size (8))); + +vnx4f __attribute__ ((noinline, noclone)) +test_5 (vnx4f x, vnx4f y) +{ + return __builtin_shufflevector (x, y, 1, 3, 6, 7); +} + +int +main (void) +{ + vnx4f test_5_x = {0, 1, 3, 4}; + vnx4f test_5_y = {4, 5, 6, 7}; + vnx4f test_5_except = {1, 4, 6, 7}; + vnx4f test_5_real; + test_5_real = test_5 (test_5_x, test_5_y); + + for (int i = 0; i < 4; i++) + assert (test_5_real[i] == test_5_except[i]); + + return 0; +} + +/* { dg-final { scan-assembler-times {call\s+__extendhfsf2} 8 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/pr115456-2.c b/gcc/testsuite/gcc.target/riscv/rvv/base/pr115456-2.c new file mode 100644 index 0000000000000..453e18b1c79cc --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/pr115456-2.c @@ -0,0 +1,31 @@ +/* Test there is no ICE when compile. */ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvfhmin -mrvv-vector-bits=zvl -mabi=lp64d -O3 -ftree-vectorize" } */ + +#include +#include + +typedef _Float16 vnx4f __attribute__ ((vector_size (8))); + +vnx4f __attribute__ ((noinline, noclone)) +test_5 (vnx4f x, vnx4f y) +{ + return __builtin_shufflevector (x, y, 1, 3, 6, 7); +} + +int +main (void) +{ + vnx4f test_5_x = {0, 1, 3, 4}; + vnx4f test_5_y = {4, 5, 6, 7}; + vnx4f test_5_except = {1, 4, 6, 7}; + vnx4f test_5_real; + test_5_real = test_5 (test_5_x, test_5_y); + + for (int i = 0; i < 4; i++) + assert (test_5_real[i] == test_5_except[i]); + + return 0; +} + +/* { dg-final { scan-assembler-times {call\s+__extendhfsf2} 8 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/pr115456-3.c b/gcc/testsuite/gcc.target/riscv/rvv/base/pr115456-3.c new file mode 100644 index 0000000000000..2c54f1d753873 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/pr115456-3.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvfh -mabi=lp64d -O3 -ftree-vectorize" } */ + +#include +#include + +typedef _Float16 vnx4f __attribute__ ((vector_size (8))); + +vnx4f __attribute__ ((noinline, noclone)) +test_5 (vnx4f x, vnx4f y) +{ + return __builtin_shufflevector (x, y, 1, 3, 6, 7); +} + +int +main (void) +{ + vnx4f test_5_x = {0, 1, 3, 4}; + vnx4f test_5_y = {4, 5, 6, 7}; + vnx4f test_5_except = {1, 4, 6, 7}; + vnx4f test_5_real; + test_5_real = test_5 (test_5_x, test_5_y); + + for (int i = 0; i < 4; i++) + assert (test_5_real[i] == test_5_except[i]); + + return 0; +} + +/* { dg-final { scan-assembler-not {call\s+__extendhfsf2} } } */ +/* { dg-final { scan-assembler-times {vfmv\.f\.s\s+fa[0-9]+,\s*v[0-9]+} 4 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_arith.h b/gcc/testsuite/gcc.target/riscv/sat_arith.h index 976ef1c44c138..0c2e44af71897 100644 --- a/gcc/testsuite/gcc.target/riscv/sat_arith.h +++ b/gcc/testsuite/gcc.target/riscv/sat_arith.h @@ -2,7 +2,11 @@ #define HAVE_SAT_ARITH #include +#include +/******************************************************************************/ +/* Saturation Add (unsigned and signed) */ +/******************************************************************************/ #define DEF_SAT_U_ADD_FMT_1(T) \ T __attribute__((noinline)) \ sat_u_add_##T##_fmt_1 (T x, T y) \ @@ -49,19 +53,6 @@ sat_u_add_##T##_fmt_6 (T x, T y) \ return (T)(x + y) < x ? -1 : (x + y); \ } -#define DEF_VEC_SAT_U_ADD_FMT_1(T) \ -void __attribute__((noinline)) \ -vec_sat_u_add_##T##_fmt_1 (T *out, T *op_1, T *op_2, unsigned limit) \ -{ \ - unsigned i; \ - for (i = 0; i < limit; i++) \ - { \ - T x = op_1[i]; \ - T y = op_2[i]; \ - out[i] = (x + y) | (-(T)((T)(x + y) < x)); \ - } \ -} - #define RUN_SAT_U_ADD_FMT_1(T, x, y) sat_u_add_##T##_fmt_1(x, y) #define RUN_SAT_U_ADD_FMT_2(T, x, y) sat_u_add_##T##_fmt_2(x, y) #define RUN_SAT_U_ADD_FMT_3(T, x, y) sat_u_add_##T##_fmt_3(x, y) @@ -69,7 +60,116 @@ vec_sat_u_add_##T##_fmt_1 (T *out, T *op_1, T *op_2, unsigned limit) \ #define RUN_SAT_U_ADD_FMT_5(T, x, y) sat_u_add_##T##_fmt_5(x, y) #define RUN_SAT_U_ADD_FMT_6(T, x, y) sat_u_add_##T##_fmt_6(x, y) -#define RUN_VEC_SAT_U_ADD_FMT_1(T, out, op_1, op_2, N) \ - vec_sat_u_add_##T##_fmt_1(out, op_1, op_2, N) +/******************************************************************************/ +/* Saturation Sub (Unsigned and Signed) */ +/******************************************************************************/ +#define DEF_SAT_U_SUB_FMT_1(T) \ +T __attribute__((noinline)) \ +sat_u_sub_##T##_fmt_1 (T x, T y) \ +{ \ + return (x - y) & (-(T)(x >= y)); \ +} + +#define DEF_SAT_U_SUB_FMT_2(T) \ +T __attribute__((noinline)) \ +sat_u_sub_##T##_fmt_2 (T x, T y) \ +{ \ + return (x - y) & (-(T)(x > y)); \ +} + +#define DEF_SAT_U_SUB_FMT_3(T) \ +T __attribute__((noinline)) \ +sat_u_sub_##T##_fmt_3 (T x, T y) \ +{ \ + return x > y ? x - y : 0; \ +} + +#define DEF_SAT_U_SUB_FMT_4(T) \ +T __attribute__((noinline)) \ +sat_u_sub_##T##_fmt_4 (T x, T y) \ +{ \ + return x >= y ? x - y : 0; \ +} + +#define DEF_SAT_U_SUB_FMT_5(T) \ +T __attribute__((noinline)) \ +sat_u_sub_##T##_fmt_5 (T x, T y) \ +{ \ + return x < y ? 0 : x - y; \ +} + +#define DEF_SAT_U_SUB_FMT_6(T) \ +T __attribute__((noinline)) \ +sat_u_sub_##T##_fmt_6 (T x, T y) \ +{ \ + return x <= y ? 0 : x - y; \ +} + +#define DEF_SAT_U_SUB_FMT_7(T) \ +T __attribute__((noinline)) \ +sat_u_sub_##T##_fmt_7 (T x, T y) \ +{ \ + T ret; \ + T overflow = __builtin_sub_overflow (x, y, &ret); \ + return ret & (T)(overflow - 1); \ +} + +#define DEF_SAT_U_SUB_FMT_8(T) \ +T __attribute__((noinline)) \ +sat_u_sub_##T##_fmt_8 (T x, T y) \ +{ \ + T ret; \ + T overflow = __builtin_sub_overflow (x, y, &ret); \ + return ret & (T)-(!overflow); \ +} + +#define DEF_SAT_U_SUB_FMT_9(T) \ +T __attribute__((noinline)) \ +sat_u_sub_##T##_fmt_9 (T x, T y) \ +{ \ + T ret; \ + T overflow = __builtin_sub_overflow (x, y, &ret); \ + return overflow ? 0 : ret; \ +} + +#define DEF_SAT_U_SUB_FMT_10(T) \ +T __attribute__((noinline)) \ +sat_u_sub_##T##_fmt_10 (T x, T y) \ +{ \ + T ret; \ + T overflow = __builtin_sub_overflow (x, y, &ret); \ + return !overflow ? ret : 0; \ +} + +#define DEF_SAT_U_SUB_FMT_11(T) \ +T __attribute__((noinline)) \ +sat_u_sub_##T##_fmt_11 (T x, T y) \ +{ \ + T ret; \ + bool overflow = __builtin_sub_overflow (x, y, &ret); \ + return overflow ? 0 : ret; \ +} + +#define DEF_SAT_U_SUB_FMT_12(T) \ +T __attribute__((noinline)) \ +sat_u_sub_##T##_fmt_12 (T x, T y) \ +{ \ + T ret; \ + bool overflow = __builtin_sub_overflow (x, y, &ret); \ + return !overflow ? ret : 0; \ +} + +#define RUN_SAT_U_SUB_FMT_1(T, x, y) sat_u_sub_##T##_fmt_1(x, y) +#define RUN_SAT_U_SUB_FMT_2(T, x, y) sat_u_sub_##T##_fmt_2(x, y) +#define RUN_SAT_U_SUB_FMT_3(T, x, y) sat_u_sub_##T##_fmt_3(x, y) +#define RUN_SAT_U_SUB_FMT_4(T, x, y) sat_u_sub_##T##_fmt_4(x, y) +#define RUN_SAT_U_SUB_FMT_5(T, x, y) sat_u_sub_##T##_fmt_5(x, y) +#define RUN_SAT_U_SUB_FMT_6(T, x, y) sat_u_sub_##T##_fmt_6(x, y) +#define RUN_SAT_U_SUB_FMT_7(T, x, y) sat_u_sub_##T##_fmt_7(x, y) +#define RUN_SAT_U_SUB_FMT_8(T, x, y) sat_u_sub_##T##_fmt_8(x, y) +#define RUN_SAT_U_SUB_FMT_9(T, x, y) sat_u_sub_##T##_fmt_9(x, y) +#define RUN_SAT_U_SUB_FMT_10(T, x, y) sat_u_sub_##T##_fmt_10(x, y) +#define RUN_SAT_U_SUB_FMT_11(T, x, y) sat_u_sub_##T##_fmt_11(x, y) +#define RUN_SAT_U_SUB_FMT_12(T, x, y) sat_u_sub_##T##_fmt_12(x, y) #endif diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-1.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-1.c new file mode 100644 index 0000000000000..73be7d5942252 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-1.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint8_t_fmt_1: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*a0,\s*[atx][0-9]+ +** andi\s+a0,\s*a0,\s*0xff +** ret +*/ +DEF_SAT_U_SUB_FMT_1(uint8_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-10.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-10.c new file mode 100644 index 0000000000000..6e78164865f00 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-10.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint16_t_fmt_3: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slli\s+a0,\s*a0,\s*48 +** srli\s+a0,\s*a0,\s*48 +** ret +*/ +DEF_SAT_U_SUB_FMT_3(uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-11.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-11.c new file mode 100644 index 0000000000000..84e34657f5510 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-11.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint32_t_fmt_3: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** sext.w\s+a0,\s*a0 +** ret +*/ +DEF_SAT_U_SUB_FMT_3(uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-12.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-12.c new file mode 100644 index 0000000000000..eea282b21aef7 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-12.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint64_t_fmt_3: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+a0,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** ret +*/ +DEF_SAT_U_SUB_FMT_3(uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-13.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-13.c new file mode 100644 index 0000000000000..edb7017f9b1dd --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-13.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint8_t_fmt_4: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*a0,\s*[atx][0-9]+ +** andi\s+a0,\s*a0,\s*0xff +** ret +*/ +DEF_SAT_U_SUB_FMT_4(uint8_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-14.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-14.c new file mode 100644 index 0000000000000..2aab9f65586b2 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-14.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint16_t_fmt_4: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slli\s+a0,\s*a0,\s*48 +** srli\s+a0,\s*a0,\s*48 +** ret +*/ +DEF_SAT_U_SUB_FMT_4(uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-15.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-15.c new file mode 100644 index 0000000000000..25ad702bf0469 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-15.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint32_t_fmt_4: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** sext.w\s+a0,\s*a0 +** ret +*/ +DEF_SAT_U_SUB_FMT_4(uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-16.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-16.c new file mode 100644 index 0000000000000..72c1931608fc2 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-16.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint64_t_fmt_4: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+a0,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** ret +*/ +DEF_SAT_U_SUB_FMT_4(uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-17.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-17.c new file mode 100644 index 0000000000000..853ddcfd285c8 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-17.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint8_t_fmt_5: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*a0,\s*[atx][0-9]+ +** andi\s+a0,\s*a0,\s*0xff +** ret +*/ +DEF_SAT_U_SUB_FMT_5(uint8_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-18.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-18.c new file mode 100644 index 0000000000000..423a6f8217032 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-18.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint16_t_fmt_5: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slli\s+a0,\s*a0,\s*48 +** srli\s+a0,\s*a0,\s*48 +** ret +*/ +DEF_SAT_U_SUB_FMT_5(uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-19.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-19.c new file mode 100644 index 0000000000000..29b9c235d976e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-19.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint32_t_fmt_5: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** sext.w\s+a0,\s*a0 +** ret +*/ +DEF_SAT_U_SUB_FMT_5(uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-2.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-2.c new file mode 100644 index 0000000000000..7bd5efcd9d928 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-2.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint16_t_fmt_1: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slli\s+a0,\s*a0,\s*48 +** srli\s+a0,\s*a0,\s*48 +** ret +*/ +DEF_SAT_U_SUB_FMT_1(uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-20.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-20.c new file mode 100644 index 0000000000000..89e84d60f94b5 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-20.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint64_t_fmt_5: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+a0,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** ret +*/ +DEF_SAT_U_SUB_FMT_5(uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-21.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-21.c new file mode 100644 index 0000000000000..9a8fb7f1c91e5 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-21.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint8_t_fmt_6: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*a0,\s*[atx][0-9]+ +** andi\s+a0,\s*a0,\s*0xff +** ret +*/ +DEF_SAT_U_SUB_FMT_6(uint8_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-22.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-22.c new file mode 100644 index 0000000000000..6182169edc5a7 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-22.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint16_t_fmt_6: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slli\s+a0,\s*a0,\s*48 +** srli\s+a0,\s*a0,\s*48 +** ret +*/ +DEF_SAT_U_SUB_FMT_6(uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-23.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-23.c new file mode 100644 index 0000000000000..820110cdbb082 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-23.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint32_t_fmt_6: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** sext.w\s+a0,\s*a0 +** ret +*/ +DEF_SAT_U_SUB_FMT_6(uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-24.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-24.c new file mode 100644 index 0000000000000..48e6296e31506 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-24.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint64_t_fmt_6: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+a0,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** ret +*/ +DEF_SAT_U_SUB_FMT_6(uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-25.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-25.c new file mode 100644 index 0000000000000..8780ef0c8f118 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-25.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint8_t_fmt_7: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*a0,\s*[atx][0-9]+ +** andi\s+a0,\s*a0,\s*0xff +** ret +*/ +DEF_SAT_U_SUB_FMT_7(uint8_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-26.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-26.c new file mode 100644 index 0000000000000..f720f619d0973 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-26.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint16_t_fmt_7: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slli\s+a0,\s*a0,\s*48 +** srli\s+a0,\s*a0,\s*48 +** ret +*/ +DEF_SAT_U_SUB_FMT_7(uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-27.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-27.c new file mode 100644 index 0000000000000..779c9247e026d --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-27.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint32_t_fmt_7: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** sext.w\s+a0,\s*a0 +** ret +*/ +DEF_SAT_U_SUB_FMT_7(uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-28.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-28.c new file mode 100644 index 0000000000000..86b80dbccd565 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-28.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint64_t_fmt_7: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+a0,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** ret +*/ +DEF_SAT_U_SUB_FMT_7(uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-29.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-29.c new file mode 100644 index 0000000000000..1a2da50256e39 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-29.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint8_t_fmt_8: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*a0,\s*[atx][0-9]+ +** andi\s+a0,\s*a0,\s*0xff +** ret +*/ +DEF_SAT_U_SUB_FMT_8(uint8_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-3.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-3.c new file mode 100644 index 0000000000000..a60fc9ba71ebb --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-3.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint32_t_fmt_1: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** sext.w\s+a0,\s*a0 +** ret +*/ +DEF_SAT_U_SUB_FMT_1(uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-30.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-30.c new file mode 100644 index 0000000000000..75aa75063690a --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-30.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint16_t_fmt_8: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slli\s+a0,\s*a0,\s*48 +** srli\s+a0,\s*a0,\s*48 +** ret +*/ +DEF_SAT_U_SUB_FMT_8(uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-31.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-31.c new file mode 100644 index 0000000000000..bc935ea0f3dd1 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-31.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint32_t_fmt_8: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** sext.w\s+a0,\s*a0 +** ret +*/ +DEF_SAT_U_SUB_FMT_8(uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-32.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-32.c new file mode 100644 index 0000000000000..f0f2254182c85 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-32.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint64_t_fmt_8: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+a0,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** ret +*/ +DEF_SAT_U_SUB_FMT_8(uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-33.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-33.c new file mode 100644 index 0000000000000..aca4bd28b5de2 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-33.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint8_t_fmt_9: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*a0,\s*[atx][0-9]+ +** andi\s+a0,\s*a0,\s*0xff +** ret +*/ +DEF_SAT_U_SUB_FMT_9(uint8_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-34.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-34.c new file mode 100644 index 0000000000000..f87a51a504be8 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-34.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint16_t_fmt_9: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slli\s+a0,\s*a0,\s*48 +** srli\s+a0,\s*a0,\s*48 +** ret +*/ +DEF_SAT_U_SUB_FMT_9(uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-35.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-35.c new file mode 100644 index 0000000000000..13c3e922f1412 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-35.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint32_t_fmt_9: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** sext.w\s+a0,\s*a0 +** ret +*/ +DEF_SAT_U_SUB_FMT_9(uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-36.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-36.c new file mode 100644 index 0000000000000..0254f539e09c4 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-36.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint64_t_fmt_9: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+a0,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** ret +*/ +DEF_SAT_U_SUB_FMT_9(uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-37.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-37.c new file mode 100644 index 0000000000000..8c97a518d2c15 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-37.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint8_t_fmt_10: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*a0,\s*[atx][0-9]+ +** andi\s+a0,\s*a0,\s*0xff +** ret +*/ +DEF_SAT_U_SUB_FMT_10(uint8_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-38.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-38.c new file mode 100644 index 0000000000000..7e3cec2a9a724 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-38.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint16_t_fmt_10: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slli\s+a0,\s*a0,\s*48 +** srli\s+a0,\s*a0,\s*48 +** ret +*/ +DEF_SAT_U_SUB_FMT_10(uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-39.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-39.c new file mode 100644 index 0000000000000..cd37f526abdb7 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-39.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint32_t_fmt_10: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** sext.w\s+a0,\s*a0 +** ret +*/ +DEF_SAT_U_SUB_FMT_10(uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-4.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-4.c new file mode 100644 index 0000000000000..bae46a0bd83e1 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-4.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint64_t_fmt_1: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+a0,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** ret +*/ +DEF_SAT_U_SUB_FMT_1(uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-40.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-40.c new file mode 100644 index 0000000000000..165be89731350 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-40.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint64_t_fmt_10: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+a0,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** ret +*/ +DEF_SAT_U_SUB_FMT_10(uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-41.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-41.c new file mode 100644 index 0000000000000..dd13f94e40f2e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-41.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint8_t_fmt_11: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*a0,\s*[atx][0-9]+ +** andi\s+a0,\s*a0,\s*0xff +** ret +*/ +DEF_SAT_U_SUB_FMT_11(uint8_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-42.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-42.c new file mode 100644 index 0000000000000..3ed4195b18b2c --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-42.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint16_t_fmt_11: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slli\s+a0,\s*a0,\s*48 +** srli\s+a0,\s*a0,\s*48 +** ret +*/ +DEF_SAT_U_SUB_FMT_11(uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-43.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-43.c new file mode 100644 index 0000000000000..b1afaf1fa66c2 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-43.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint32_t_fmt_11: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** sext.w\s+a0,\s*a0 +** ret +*/ +DEF_SAT_U_SUB_FMT_11(uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-44.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-44.c new file mode 100644 index 0000000000000..123f6bde3b9a4 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-44.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint64_t_fmt_11: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+a0,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** ret +*/ +DEF_SAT_U_SUB_FMT_11(uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-45.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-45.c new file mode 100644 index 0000000000000..1aad8961e29d9 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-45.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint8_t_fmt_12: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*a0,\s*[atx][0-9]+ +** andi\s+a0,\s*a0,\s*0xff +** ret +*/ +DEF_SAT_U_SUB_FMT_12(uint8_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-46.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-46.c new file mode 100644 index 0000000000000..d184043f6f833 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-46.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint16_t_fmt_12: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slli\s+a0,\s*a0,\s*48 +** srli\s+a0,\s*a0,\s*48 +** ret +*/ +DEF_SAT_U_SUB_FMT_12(uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-47.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-47.c new file mode 100644 index 0000000000000..033d3b0fb76a3 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-47.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint32_t_fmt_12: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** sext.w\s+a0,\s*a0 +** ret +*/ +DEF_SAT_U_SUB_FMT_12(uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-48.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-48.c new file mode 100644 index 0000000000000..135de21471016 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-48.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint64_t_fmt_12: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+a0,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** ret +*/ +DEF_SAT_U_SUB_FMT_12(uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-5.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-5.c new file mode 100644 index 0000000000000..e917487a6401e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-5.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint8_t_fmt_2: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*a0,\s*[atx][0-9]+ +** andi\s+a0,\s*a0,\s*0xff +** ret +*/ +DEF_SAT_U_SUB_FMT_2(uint8_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-6.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-6.c new file mode 100644 index 0000000000000..4e3c91d205d5b --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-6.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint16_t_fmt_2: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** slli\s+a0,\s*a0,\s*48 +** srli\s+a0,\s*a0,\s*48 +** ret +*/ +DEF_SAT_U_SUB_FMT_2(uint16_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-7.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-7.c new file mode 100644 index 0000000000000..e1b0eaccf95a7 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-7.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint32_t_fmt_2: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** sext.w\s+a0,\s*a0 +** ret +*/ +DEF_SAT_U_SUB_FMT_2(uint32_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-8.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-8.c new file mode 100644 index 0000000000000..d73f00fcf02d6 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-8.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint64_t_fmt_2: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*a0,\s*a1 +** addi\s+a0,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*[atx][0-9]+,\s*[atx][0-9]+ +** ret +*/ +DEF_SAT_U_SUB_FMT_2(uint64_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-9.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-9.c new file mode 100644 index 0000000000000..b24bf3eb54981 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-9.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc -mabi=lp64d -O3 -fdump-rtl-expand-details -fno-schedule-insns -fno-schedule-insns2" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +#include "sat_arith.h" + +/* +** sat_u_sub_uint8_t_fmt_3: +** sub\s+[atx][0-9]+,\s*a0,\s*a1 +** sltu\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+ +** addi\s+[atx][0-9]+,\s*[atx][0-9]+,\s*-1 +** and\s+a0,\s*a0,\s*[atx][0-9]+ +** andi\s+a0,\s*a0,\s*0xff +** ret +*/ +DEF_SAT_U_SUB_FMT_3(uint8_t) + +/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-1.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-1.c new file mode 100644 index 0000000000000..931420a309870 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-1.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint8_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_1 + +DEF_SAT_U_SUB_FMT_1(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 255, 254, 1, }, + { 255, 255, 0, }, + { 254, 255, 0, }, + { 253, 254, 0, }, + { 0, 255, 0, }, + { 1, 255, 0, }, + { 32, 5, 27, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-10.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-10.c new file mode 100644 index 0000000000000..ea52ff4573eb3 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-10.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint16_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_3 + +DEF_SAT_U_SUB_FMT_3(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 65535, 65534, 1, }, + { 65535, 65535, 0, }, + { 65534, 65535, 0, }, + { 65533, 65534, 0, }, + { 0, 65535, 0, }, + { 1, 65535, 0, }, + { 35, 5, 30, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-11.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-11.c new file mode 100644 index 0000000000000..fdea8916ab3cf --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-11.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint32_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_3 + +DEF_SAT_U_SUB_FMT_3(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 4294967295, 4294967294, 1, }, + { 4294967295, 4294967295, 0, }, + { 4294967294, 4294967295, 0, }, + { 4294967293, 4294967294, 0, }, + { 1, 4294967295, 0, }, + { 2, 4294967295, 0, }, + { 5, 1, 4, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-12.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-12.c new file mode 100644 index 0000000000000..164ee77fb761c --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-12.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint64_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_3 + +DEF_SAT_U_SUB_FMT_3(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 18446744073709551615u, 18446744073709551614u, 1, }, + { 18446744073709551615u, 18446744073709551615u, 0, }, + { 18446744073709551614u, 18446744073709551615u, 0, }, + { 18446744073709551613u, 18446744073709551614u, 0, }, + { 0, 18446744073709551615u, 0, }, + { 1, 18446744073709551615u, 0, }, + { 43, 11, 32, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-13.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-13.c new file mode 100644 index 0000000000000..c8ae7a6680d23 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-13.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint8_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_4 + +DEF_SAT_U_SUB_FMT_4(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 255, 254, 1, }, + { 255, 255, 0, }, + { 254, 255, 0, }, + { 253, 254, 0, }, + { 0, 255, 0, }, + { 1, 255, 0, }, + { 32, 5, 27, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-14.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-14.c new file mode 100644 index 0000000000000..9b57861b578d9 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-14.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint16_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_4 + +DEF_SAT_U_SUB_FMT_4(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 65535, 65534, 1, }, + { 65535, 65535, 0, }, + { 65534, 65535, 0, }, + { 65533, 65534, 0, }, + { 0, 65535, 0, }, + { 1, 65535, 0, }, + { 35, 5, 30, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-15.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-15.c new file mode 100644 index 0000000000000..df2eecef6fb4b --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-15.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint32_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_4 + +DEF_SAT_U_SUB_FMT_4(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 4294967295, 4294967294, 1, }, + { 4294967295, 4294967295, 0, }, + { 4294967294, 4294967295, 0, }, + { 4294967293, 4294967294, 0, }, + { 1, 4294967295, 0, }, + { 2, 4294967295, 0, }, + { 5, 1, 4, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-16.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-16.c new file mode 100644 index 0000000000000..09e9ac38a83f1 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-16.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint64_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_4 + +DEF_SAT_U_SUB_FMT_4(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 18446744073709551615u, 18446744073709551614u, 1, }, + { 18446744073709551615u, 18446744073709551615u, 0, }, + { 18446744073709551614u, 18446744073709551615u, 0, }, + { 18446744073709551613u, 18446744073709551614u, 0, }, + { 0, 18446744073709551615u, 0, }, + { 1, 18446744073709551615u, 0, }, + { 43, 11, 32, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-17.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-17.c new file mode 100644 index 0000000000000..b2823112b62b8 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-17.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint8_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_5 + +DEF_SAT_U_SUB_FMT_5(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 255, 254, 1, }, + { 255, 255, 0, }, + { 254, 255, 0, }, + { 253, 254, 0, }, + { 0, 255, 0, }, + { 1, 255, 0, }, + { 32, 5, 27, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-18.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-18.c new file mode 100644 index 0000000000000..9f575a47bfe8e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-18.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint16_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_5 + +DEF_SAT_U_SUB_FMT_5(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 65535, 65534, 1, }, + { 65535, 65535, 0, }, + { 65534, 65535, 0, }, + { 65533, 65534, 0, }, + { 0, 65535, 0, }, + { 1, 65535, 0, }, + { 35, 5, 30, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-19.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-19.c new file mode 100644 index 0000000000000..c370455c3d41b --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-19.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint32_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_5 + +DEF_SAT_U_SUB_FMT_5(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 4294967295, 4294967294, 1, }, + { 4294967295, 4294967295, 0, }, + { 4294967294, 4294967295, 0, }, + { 4294967293, 4294967294, 0, }, + { 1, 4294967295, 0, }, + { 2, 4294967295, 0, }, + { 5, 1, 4, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-2.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-2.c new file mode 100644 index 0000000000000..1534cf9982771 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-2.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint16_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_1 + +DEF_SAT_U_SUB_FMT_1(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 65535, 65534, 1, }, + { 65535, 65535, 0, }, + { 65534, 65535, 0, }, + { 65533, 65534, 0, }, + { 0, 65535, 0, }, + { 1, 65535, 0, }, + { 35, 5, 30, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-20.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-20.c new file mode 100644 index 0000000000000..22d82f973d44a --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-20.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint64_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_5 + +DEF_SAT_U_SUB_FMT_5(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 18446744073709551615u, 18446744073709551614u, 1, }, + { 18446744073709551615u, 18446744073709551615u, 0, }, + { 18446744073709551614u, 18446744073709551615u, 0, }, + { 18446744073709551613u, 18446744073709551614u, 0, }, + { 0, 18446744073709551615u, 0, }, + { 1, 18446744073709551615u, 0, }, + { 43, 11, 32, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-21.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-21.c new file mode 100644 index 0000000000000..0b4cbdbf59930 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-21.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint8_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_6 + +DEF_SAT_U_SUB_FMT_6(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 255, 254, 1, }, + { 255, 255, 0, }, + { 254, 255, 0, }, + { 253, 254, 0, }, + { 0, 255, 0, }, + { 1, 255, 0, }, + { 32, 5, 27, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-22.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-22.c new file mode 100644 index 0000000000000..e0dda451775f6 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-22.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint16_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_6 + +DEF_SAT_U_SUB_FMT_6(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 65535, 65534, 1, }, + { 65535, 65535, 0, }, + { 65534, 65535, 0, }, + { 65533, 65534, 0, }, + { 0, 65535, 0, }, + { 1, 65535, 0, }, + { 35, 5, 30, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-23.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-23.c new file mode 100644 index 0000000000000..dfd95ef58c391 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-23.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint32_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_6 + +DEF_SAT_U_SUB_FMT_6(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 4294967295, 4294967294, 1, }, + { 4294967295, 4294967295, 0, }, + { 4294967294, 4294967295, 0, }, + { 4294967293, 4294967294, 0, }, + { 1, 4294967295, 0, }, + { 2, 4294967295, 0, }, + { 5, 1, 4, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-24.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-24.c new file mode 100644 index 0000000000000..7cac446aa336b --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-24.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint64_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_6 + +DEF_SAT_U_SUB_FMT_6(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 18446744073709551615u, 18446744073709551614u, 1, }, + { 18446744073709551615u, 18446744073709551615u, 0, }, + { 18446744073709551614u, 18446744073709551615u, 0, }, + { 18446744073709551613u, 18446744073709551614u, 0, }, + { 0, 18446744073709551615u, 0, }, + { 1, 18446744073709551615u, 0, }, + { 43, 11, 32, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-25.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-25.c new file mode 100644 index 0000000000000..d101d2897c9e4 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-25.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint8_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_7 + +DEF_SAT_U_SUB_FMT_7(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 255, 254, 1, }, + { 255, 255, 0, }, + { 254, 255, 0, }, + { 253, 254, 0, }, + { 0, 255, 0, }, + { 1, 255, 0, }, + { 32, 5, 27, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-26.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-26.c new file mode 100644 index 0000000000000..10c65fec97db5 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-26.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint16_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_7 + +DEF_SAT_U_SUB_FMT_7(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 65535, 65534, 1, }, + { 65535, 65535, 0, }, + { 65534, 65535, 0, }, + { 65533, 65534, 0, }, + { 0, 65535, 0, }, + { 1, 65535, 0, }, + { 35, 5, 30, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-27.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-27.c new file mode 100644 index 0000000000000..e3b4dde683da4 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-27.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint32_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_7 + +DEF_SAT_U_SUB_FMT_7(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 4294967295, 4294967294, 1, }, + { 4294967295, 4294967295, 0, }, + { 4294967294, 4294967295, 0, }, + { 4294967293, 4294967294, 0, }, + { 1, 4294967295, 0, }, + { 2, 4294967295, 0, }, + { 5, 1, 4, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-28.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-28.c new file mode 100644 index 0000000000000..6e93fcff032d5 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-28.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint64_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_7 + +DEF_SAT_U_SUB_FMT_7(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 18446744073709551615u, 18446744073709551614u, 1, }, + { 18446744073709551615u, 18446744073709551615u, 0, }, + { 18446744073709551614u, 18446744073709551615u, 0, }, + { 18446744073709551613u, 18446744073709551614u, 0, }, + { 0, 18446744073709551615u, 0, }, + { 1, 18446744073709551615u, 0, }, + { 43, 11, 32, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-29.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-29.c new file mode 100644 index 0000000000000..1f74562125bc0 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-29.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint8_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_8 + +DEF_SAT_U_SUB_FMT_8(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 255, 254, 1, }, + { 255, 255, 0, }, + { 254, 255, 0, }, + { 253, 254, 0, }, + { 0, 255, 0, }, + { 1, 255, 0, }, + { 32, 5, 27, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-3.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-3.c new file mode 100644 index 0000000000000..5c60d28997f92 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-3.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint32_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_1 + +DEF_SAT_U_SUB_FMT_1(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 4294967295, 4294967294, 1, }, + { 4294967295, 4294967295, 0, }, + { 4294967294, 4294967295, 0, }, + { 4294967293, 4294967294, 0, }, + { 1, 4294967295, 0, }, + { 2, 4294967295, 0, }, + { 5, 1, 4, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-30.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-30.c new file mode 100644 index 0000000000000..4e50e3f804edc --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-30.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint16_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_8 + +DEF_SAT_U_SUB_FMT_8(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 65535, 65534, 1, }, + { 65535, 65535, 0, }, + { 65534, 65535, 0, }, + { 65533, 65534, 0, }, + { 0, 65535, 0, }, + { 1, 65535, 0, }, + { 35, 5, 30, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-31.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-31.c new file mode 100644 index 0000000000000..3c8f78d7ed31f --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-31.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint32_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_8 + +DEF_SAT_U_SUB_FMT_8(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 4294967295, 4294967294, 1, }, + { 4294967295, 4294967295, 0, }, + { 4294967294, 4294967295, 0, }, + { 4294967293, 4294967294, 0, }, + { 1, 4294967295, 0, }, + { 2, 4294967295, 0, }, + { 5, 1, 4, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-32.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-32.c new file mode 100644 index 0000000000000..932596a28e71e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-32.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint64_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_8 + +DEF_SAT_U_SUB_FMT_8(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 18446744073709551615u, 18446744073709551614u, 1, }, + { 18446744073709551615u, 18446744073709551615u, 0, }, + { 18446744073709551614u, 18446744073709551615u, 0, }, + { 18446744073709551613u, 18446744073709551614u, 0, }, + { 0, 18446744073709551615u, 0, }, + { 1, 18446744073709551615u, 0, }, + { 43, 11, 32, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-33.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-33.c new file mode 100644 index 0000000000000..ab8b4750d0126 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-33.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint8_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_9 + +DEF_SAT_U_SUB_FMT_9(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 255, 254, 1, }, + { 255, 255, 0, }, + { 254, 255, 0, }, + { 253, 254, 0, }, + { 0, 255, 0, }, + { 1, 255, 0, }, + { 32, 5, 27, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-34.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-34.c new file mode 100644 index 0000000000000..66a82f20ca5ec --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-34.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint16_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_9 + +DEF_SAT_U_SUB_FMT_9(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 65535, 65534, 1, }, + { 65535, 65535, 0, }, + { 65534, 65535, 0, }, + { 65533, 65534, 0, }, + { 0, 65535, 0, }, + { 1, 65535, 0, }, + { 35, 5, 30, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-35.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-35.c new file mode 100644 index 0000000000000..a54b5c33bc12e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-35.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint32_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_9 + +DEF_SAT_U_SUB_FMT_9(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 4294967295, 4294967294, 1, }, + { 4294967295, 4294967295, 0, }, + { 4294967294, 4294967295, 0, }, + { 4294967293, 4294967294, 0, }, + { 1, 4294967295, 0, }, + { 2, 4294967295, 0, }, + { 5, 1, 4, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-36.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-36.c new file mode 100644 index 0000000000000..97943b3e3b604 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-36.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint64_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_9 + +DEF_SAT_U_SUB_FMT_9(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 18446744073709551615u, 18446744073709551614u, 1, }, + { 18446744073709551615u, 18446744073709551615u, 0, }, + { 18446744073709551614u, 18446744073709551615u, 0, }, + { 18446744073709551613u, 18446744073709551614u, 0, }, + { 0, 18446744073709551615u, 0, }, + { 1, 18446744073709551615u, 0, }, + { 43, 11, 32, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-37.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-37.c new file mode 100644 index 0000000000000..2a157f027da5c --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-37.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint8_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_10 + +DEF_SAT_U_SUB_FMT_10(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 255, 254, 1, }, + { 255, 255, 0, }, + { 254, 255, 0, }, + { 253, 254, 0, }, + { 0, 255, 0, }, + { 1, 255, 0, }, + { 32, 5, 27, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-38.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-38.c new file mode 100644 index 0000000000000..ae87544c9c4be --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-38.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint16_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_10 + +DEF_SAT_U_SUB_FMT_10(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 65535, 65534, 1, }, + { 65535, 65535, 0, }, + { 65534, 65535, 0, }, + { 65533, 65534, 0, }, + { 0, 65535, 0, }, + { 1, 65535, 0, }, + { 35, 5, 30, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-39.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-39.c new file mode 100644 index 0000000000000..43414ae2d84d5 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-39.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint32_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_10 + +DEF_SAT_U_SUB_FMT_10(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 4294967295, 4294967294, 1, }, + { 4294967295, 4294967295, 0, }, + { 4294967294, 4294967295, 0, }, + { 4294967293, 4294967294, 0, }, + { 1, 4294967295, 0, }, + { 2, 4294967295, 0, }, + { 5, 1, 4, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-4.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-4.c new file mode 100644 index 0000000000000..403764c856875 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-4.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint64_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_1 + +DEF_SAT_U_SUB_FMT_1(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 18446744073709551615u, 18446744073709551614u, 1, }, + { 18446744073709551615u, 18446744073709551615u, 0, }, + { 18446744073709551614u, 18446744073709551615u, 0, }, + { 18446744073709551613u, 18446744073709551614u, 0, }, + { 0, 18446744073709551615u, 0, }, + { 1, 18446744073709551615u, 0, }, + { 43, 11, 32, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-40.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-40.c new file mode 100644 index 0000000000000..3ef70a19c5810 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-40.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint64_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_10 + +DEF_SAT_U_SUB_FMT_10(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 18446744073709551615u, 18446744073709551614u, 1, }, + { 18446744073709551615u, 18446744073709551615u, 0, }, + { 18446744073709551614u, 18446744073709551615u, 0, }, + { 18446744073709551613u, 18446744073709551614u, 0, }, + { 0, 18446744073709551615u, 0, }, + { 1, 18446744073709551615u, 0, }, + { 43, 11, 32, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-41.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-41.c new file mode 100644 index 0000000000000..949bd0d6f48c8 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-41.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint8_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_11 + +DEF_SAT_U_SUB_FMT_11(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 255, 254, 1, }, + { 255, 255, 0, }, + { 254, 255, 0, }, + { 253, 254, 0, }, + { 0, 255, 0, }, + { 1, 255, 0, }, + { 32, 5, 27, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-42.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-42.c new file mode 100644 index 0000000000000..534795cdd8fa4 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-42.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint16_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_11 + +DEF_SAT_U_SUB_FMT_11(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 65535, 65534, 1, }, + { 65535, 65535, 0, }, + { 65534, 65535, 0, }, + { 65533, 65534, 0, }, + { 0, 65535, 0, }, + { 1, 65535, 0, }, + { 35, 5, 30, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-43.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-43.c new file mode 100644 index 0000000000000..4d0a34fff3b49 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-43.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint32_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_11 + +DEF_SAT_U_SUB_FMT_11(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 4294967295, 4294967294, 1, }, + { 4294967295, 4294967295, 0, }, + { 4294967294, 4294967295, 0, }, + { 4294967293, 4294967294, 0, }, + { 1, 4294967295, 0, }, + { 2, 4294967295, 0, }, + { 5, 1, 4, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-44.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-44.c new file mode 100644 index 0000000000000..d74d10dc4e0d2 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-44.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint64_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_11 + +DEF_SAT_U_SUB_FMT_11(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 18446744073709551615u, 18446744073709551614u, 1, }, + { 18446744073709551615u, 18446744073709551615u, 0, }, + { 18446744073709551614u, 18446744073709551615u, 0, }, + { 18446744073709551613u, 18446744073709551614u, 0, }, + { 0, 18446744073709551615u, 0, }, + { 1, 18446744073709551615u, 0, }, + { 43, 11, 32, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-45.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-45.c new file mode 100644 index 0000000000000..209965cb8bdb3 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-45.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint8_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_12 + +DEF_SAT_U_SUB_FMT_12(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 255, 254, 1, }, + { 255, 255, 0, }, + { 254, 255, 0, }, + { 253, 254, 0, }, + { 0, 255, 0, }, + { 1, 255, 0, }, + { 32, 5, 27, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-46.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-46.c new file mode 100644 index 0000000000000..80cce95188c68 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-46.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint16_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_12 + +DEF_SAT_U_SUB_FMT_12(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 65535, 65534, 1, }, + { 65535, 65535, 0, }, + { 65534, 65535, 0, }, + { 65533, 65534, 0, }, + { 0, 65535, 0, }, + { 1, 65535, 0, }, + { 35, 5, 30, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-47.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-47.c new file mode 100644 index 0000000000000..3ecd19c472f94 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-47.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint32_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_12 + +DEF_SAT_U_SUB_FMT_12(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 4294967295, 4294967294, 1, }, + { 4294967295, 4294967295, 0, }, + { 4294967294, 4294967295, 0, }, + { 4294967293, 4294967294, 0, }, + { 1, 4294967295, 0, }, + { 2, 4294967295, 0, }, + { 5, 1, 4, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-48.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-48.c new file mode 100644 index 0000000000000..2d7bfc47a31aa --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-48.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint64_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_12 + +DEF_SAT_U_SUB_FMT_12(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 18446744073709551615u, 18446744073709551614u, 1, }, + { 18446744073709551615u, 18446744073709551615u, 0, }, + { 18446744073709551614u, 18446744073709551615u, 0, }, + { 18446744073709551613u, 18446744073709551614u, 0, }, + { 0, 18446744073709551615u, 0, }, + { 1, 18446744073709551615u, 0, }, + { 43, 11, 32, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-5.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-5.c new file mode 100644 index 0000000000000..6fa44ca323bdf --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-5.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint8_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_2 + +DEF_SAT_U_SUB_FMT_2(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 255, 254, 1, }, + { 255, 255, 0, }, + { 254, 255, 0, }, + { 253, 254, 0, }, + { 0, 255, 0, }, + { 1, 255, 0, }, + { 32, 5, 27, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-6.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-6.c new file mode 100644 index 0000000000000..7deaae9a5fdc3 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-6.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint16_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_2 + +DEF_SAT_U_SUB_FMT_2(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 65535, 65534, 1, }, + { 65535, 65535, 0, }, + { 65534, 65535, 0, }, + { 65533, 65534, 0, }, + { 0, 65535, 0, }, + { 1, 65535, 0, }, + { 35, 5, 30, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-7.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-7.c new file mode 100644 index 0000000000000..d9b1d5cbfe29f --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-7.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint32_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_2 + +DEF_SAT_U_SUB_FMT_2(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 4294967295, 4294967294, 1, }, + { 4294967295, 4294967295, 0, }, + { 4294967294, 4294967295, 0, }, + { 4294967293, 4294967294, 0, }, + { 1, 4294967295, 0, }, + { 2, 4294967295, 0, }, + { 5, 1, 4, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-8.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-8.c new file mode 100644 index 0000000000000..2774c235cc37c --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-8.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint64_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_2 + +DEF_SAT_U_SUB_FMT_2(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 18446744073709551615u, 18446744073709551614u, 1, }, + { 18446744073709551615u, 18446744073709551615u, 0, }, + { 18446744073709551614u, 18446744073709551615u, 0, }, + { 18446744073709551613u, 18446744073709551614u, 0, }, + { 0, 18446744073709551615u, 0, }, + { 1, 18446744073709551615u, 0, }, + { 43, 11, 32, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-9.c b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-9.c new file mode 100644 index 0000000000000..724adf92d3e16 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/sat_u_sub-run-9.c @@ -0,0 +1,25 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "sat_arith.h" + +#define T uint8_t +#define RUN_SAT_BINARY RUN_SAT_U_SUB_FMT_3 + +DEF_SAT_U_SUB_FMT_3(T) + +T test_data[][3] = { + /* arg_0, arg_1, expect */ + { 0, 0, 0, }, + { 0, 1, 0, }, + { 1, 1, 0, }, + { 255, 254, 1, }, + { 255, 255, 0, }, + { 254, 255, 0, }, + { 253, 254, 0, }, + { 0, 255, 0, }, + { 1, 255, 0, }, + { 32, 5, 27, }, +}; + +#include "scalar_sat_binary.h" diff --git a/gcc/testsuite/gcc.target/riscv/zbs-ext-2.c b/gcc/testsuite/gcc.target/riscv/zbs-ext-2.c new file mode 100644 index 0000000000000..690dd722bce99 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/zbs-ext-2.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc_zbb_zbs -mabi=lp64" } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" } } */ + + +typedef unsigned int uint32_t; +uint32_t foo(uint32_t pos) +{ + return (1 << (7-(pos) % 8)); +} + +typedef unsigned int uint32_t; +uint32_t foo2(uint32_t pos) +{ + return (1 << (pos & 0xf)); +} + +/* { dg-final { scan-assembler-not "sll\t" } } */ +/* { dg-final { scan-assembler-times "bset\t" 2 } } */ +/* { dg-final { scan-assembler-times "andi\t" 1 } } */ +/* { dg-final { scan-assembler-times "andn\t" 1 } } */ +/* { dg-final { scan-assembler-times "li\t" 1 } } */ +/* { dg-final { scan-assembler-times "ret" 2 } } */ + diff --git a/gcc/testsuite/gcc.target/riscv/zbs-ext.c b/gcc/testsuite/gcc.target/riscv/zbs-ext.c new file mode 100644 index 0000000000000..65f42545b5f2c --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/zbs-ext.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc_zbs -mabi=lp64" } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-O1" } } */ +typedef unsigned long uint64_t; +typedef unsigned int uint32_t; + +uint64_t bclr (const uint32_t i) +{ + uint64_t checks = 10; + checks &= ~(1U << i); + return checks; +} + +/* { dg-final { scan-assembler-times "bclr\t" 1 } } */ +/* { dg-final { scan-assembler-not "sllw\t"} } */ diff --git a/gcc/testsuite/gcc.target/riscv/zbs-zext-2.c b/gcc/testsuite/gcc.target/riscv/zbs-zext-2.c new file mode 100644 index 0000000000000..ebd269d1695c2 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/zbs-zext-2.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc_zbs -mabi=lp64" } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-O1" } } */ +unsigned long long foo(long long symbol) +{ + return 1u << symbol; +} + +/* { dg-final { scan-assembler-times "bset\t" 1 } } */ +/* { dg-final { scan-assembler-not "li\t"} } */ +/* { dg-final { scan-assembler-not "sllw\t"} } */ +/* { dg-final { scan-assembler-not "zext.w\t"} } */ diff --git a/gcc/testsuite/gcc.target/riscv/zbs-zext-3.c b/gcc/testsuite/gcc.target/riscv/zbs-zext-3.c new file mode 100644 index 0000000000000..0239014e06bf5 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/zbs-zext-3.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc_zba_zbb_zbs -mabi=lp64d" { target { rv64 } } } */ +/* { dg-options "-march=rv32gc_zba_zbb_zbs -mabi=ilp32" { target { rv32 } } } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */ + +/* We need to adjust the constant so this works for rv32 and rv64. */ +#if __riscv_xlen == 32 +#define ONE 1U +#else +#define ONE 1ULL +#endif + +void add_to_hard_reg_set(long long *a, unsigned int count) { + int i = 0; + while(i++ < count) + *a |= (1U << i); +} + +void remove_from_hard_reg_set(long long *a, unsigned int count) { + int i = 0; + while(i++ < count) + *a &= ~(ONE << i); +} + + +/* { dg-final { scan-assembler-not "and\t" } } */ +/* { dg-final { scan-assembler-not "andn\t" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/zbs-zext.c b/gcc/testsuite/gcc.target/riscv/zbs-zext.c new file mode 100644 index 0000000000000..5773b15d29878 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/zbs-zext.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc_zbs -mabi=lp64" } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-O1" } } */ +typedef unsigned long uint64_t; +typedef unsigned int uint32_t; + +uint64_t bset (const uint32_t i) +{ + uint64_t checks = 8; + checks |= 1U << i; + return checks; +} + +uint64_t binv (const uint32_t i) +{ + uint64_t checks = 8; + checks ^= 1U << i; + return checks; +} + +uint64_t bclr (const uint32_t i) +{ + uint64_t checks = 10; + checks &= ~(1U << i); + return checks; +} + +/* { dg-final { scan-assembler-times "bset\t" 1 } } */ +/* { dg-final { scan-assembler-times "binv\t" 1 } } */ +/* { dg-final { scan-assembler-times "bclr\t" 1 } } */ +/* { dg-final { scan-assembler-not "sllw\t"} } */ diff --git a/gcc/testsuite/gcc.target/s390/ifcvt-one-insn-bool.c b/gcc/testsuite/gcc.target/s390/ifcvt-one-insn-bool.c index 0c8c2f879a692..4ae29dbd6b618 100644 --- a/gcc/testsuite/gcc.target/s390/ifcvt-one-insn-bool.c +++ b/gcc/testsuite/gcc.target/s390/ifcvt-one-insn-bool.c @@ -3,7 +3,7 @@ /* { dg-do compile { target { s390*-*-* } } } */ /* { dg-options "-O2 -march=z13 -mzarch" } */ -/* { dg-final { scan-assembler "lochinh\t%r.?,1" } } */ +/* { dg-final { scan-assembler "lochile\t%r.?,1" } } */ #include int foo (int *a, unsigned int n) diff --git a/gcc/testsuite/gcc.target/s390/nobp-table-jump-inline-z10.c b/gcc/testsuite/gcc.target/s390/nobp-table-jump-inline-z10.c index 8dfd7e4c78613..121751166d0a4 100644 --- a/gcc/testsuite/gcc.target/s390/nobp-table-jump-inline-z10.c +++ b/gcc/testsuite/gcc.target/s390/nobp-table-jump-inline-z10.c @@ -4,29 +4,29 @@ /* case-values-threshold will be set to 20 by the back-end when jump thunk are requested. */ -int __attribute__((noinline,noclone)) foo1 (void) { return 1; } -int __attribute__((noinline,noclone)) foo2 (void) { return 2; } -int __attribute__((noinline,noclone)) foo3 (void) { return 3; } -int __attribute__((noinline,noclone)) foo4 (void) { return 4; } -int __attribute__((noinline,noclone)) foo5 (void) { return 5; } -int __attribute__((noinline,noclone)) foo6 (void) { return 6; } -int __attribute__((noinline,noclone)) foo7 (void) { return 7; } -int __attribute__((noinline,noclone)) foo8 (void) { return 8; } -int __attribute__((noinline,noclone)) foo9 (void) { return 9; } -int __attribute__((noinline,noclone)) foo10 (void) { return 10; } -int __attribute__((noinline,noclone)) foo11 (void) { return 11; } -int __attribute__((noinline,noclone)) foo12 (void) { return 12; } -int __attribute__((noinline,noclone)) foo13 (void) { return 13; } -int __attribute__((noinline,noclone)) foo14 (void) { return 14; } -int __attribute__((noinline,noclone)) foo15 (void) { return 15; } -int __attribute__((noinline,noclone)) foo16 (void) { return 16; } -int __attribute__((noinline,noclone)) foo17 (void) { return 17; } -int __attribute__((noinline,noclone)) foo18 (void) { return 18; } -int __attribute__((noinline,noclone)) foo19 (void) { return 19; } -int __attribute__((noinline,noclone)) foo20 (void) { return 20; } +int __attribute__((noipa)) foo1 (void) { return 1; } +int __attribute__((noipa)) foo2 (void) { return 2; } +int __attribute__((noipa)) foo3 (void) { return 3; } +int __attribute__((noipa)) foo4 (void) { return 4; } +int __attribute__((noipa)) foo5 (void) { return 5; } +int __attribute__((noipa)) foo6 (void) { return 6; } +int __attribute__((noipa)) foo7 (void) { return 7; } +int __attribute__((noipa)) foo8 (void) { return 8; } +int __attribute__((noipa)) foo9 (void) { return 9; } +int __attribute__((noipa)) foo10 (void) { return 10; } +int __attribute__((noipa)) foo11 (void) { return 11; } +int __attribute__((noipa)) foo12 (void) { return 12; } +int __attribute__((noipa)) foo13 (void) { return 13; } +int __attribute__((noipa)) foo14 (void) { return 14; } +int __attribute__((noipa)) foo15 (void) { return 15; } +int __attribute__((noipa)) foo16 (void) { return 16; } +int __attribute__((noipa)) foo17 (void) { return 17; } +int __attribute__((noipa)) foo18 (void) { return 18; } +int __attribute__((noipa)) foo19 (void) { return 19; } +int __attribute__((noipa)) foo20 (void) { return 20; } -int __attribute__((noinline,noclone)) +int __attribute__((noipa)) bar (int a) { int ret = 0; diff --git a/gcc/testsuite/gcc.target/s390/nobp-table-jump-inline-z900.c b/gcc/testsuite/gcc.target/s390/nobp-table-jump-inline-z900.c index 46d2c54bcff10..5ad0c72afc366 100644 --- a/gcc/testsuite/gcc.target/s390/nobp-table-jump-inline-z900.c +++ b/gcc/testsuite/gcc.target/s390/nobp-table-jump-inline-z900.c @@ -4,29 +4,29 @@ /* case-values-threshold will be set to 20 by the back-end when jump thunk are requested. */ -int __attribute__((noinline,noclone)) foo1 (void) { return 1; } -int __attribute__((noinline,noclone)) foo2 (void) { return 2; } -int __attribute__((noinline,noclone)) foo3 (void) { return 3; } -int __attribute__((noinline,noclone)) foo4 (void) { return 4; } -int __attribute__((noinline,noclone)) foo5 (void) { return 5; } -int __attribute__((noinline,noclone)) foo6 (void) { return 6; } -int __attribute__((noinline,noclone)) foo7 (void) { return 7; } -int __attribute__((noinline,noclone)) foo8 (void) { return 8; } -int __attribute__((noinline,noclone)) foo9 (void) { return 9; } -int __attribute__((noinline,noclone)) foo10 (void) { return 10; } -int __attribute__((noinline,noclone)) foo11 (void) { return 11; } -int __attribute__((noinline,noclone)) foo12 (void) { return 12; } -int __attribute__((noinline,noclone)) foo13 (void) { return 13; } -int __attribute__((noinline,noclone)) foo14 (void) { return 14; } -int __attribute__((noinline,noclone)) foo15 (void) { return 15; } -int __attribute__((noinline,noclone)) foo16 (void) { return 16; } -int __attribute__((noinline,noclone)) foo17 (void) { return 17; } -int __attribute__((noinline,noclone)) foo18 (void) { return 18; } -int __attribute__((noinline,noclone)) foo19 (void) { return 19; } -int __attribute__((noinline,noclone)) foo20 (void) { return 20; } +int __attribute__((noipa)) foo1 (void) { return 1; } +int __attribute__((noipa)) foo2 (void) { return 2; } +int __attribute__((noipa)) foo3 (void) { return 3; } +int __attribute__((noipa)) foo4 (void) { return 4; } +int __attribute__((noipa)) foo5 (void) { return 5; } +int __attribute__((noipa)) foo6 (void) { return 6; } +int __attribute__((noipa)) foo7 (void) { return 7; } +int __attribute__((noipa)) foo8 (void) { return 8; } +int __attribute__((noipa)) foo9 (void) { return 9; } +int __attribute__((noipa)) foo10 (void) { return 10; } +int __attribute__((noipa)) foo11 (void) { return 11; } +int __attribute__((noipa)) foo12 (void) { return 12; } +int __attribute__((noipa)) foo13 (void) { return 13; } +int __attribute__((noipa)) foo14 (void) { return 14; } +int __attribute__((noipa)) foo15 (void) { return 15; } +int __attribute__((noipa)) foo16 (void) { return 16; } +int __attribute__((noipa)) foo17 (void) { return 17; } +int __attribute__((noipa)) foo18 (void) { return 18; } +int __attribute__((noipa)) foo19 (void) { return 19; } +int __attribute__((noipa)) foo20 (void) { return 20; } -int __attribute__((noinline,noclone)) +int __attribute__((noipa)) bar (int a) { int ret = 0; diff --git a/gcc/testsuite/gcc.target/s390/nobp-table-jump-z10.c b/gcc/testsuite/gcc.target/s390/nobp-table-jump-z10.c index 9dfe391f33708..6bd308f63b574 100644 --- a/gcc/testsuite/gcc.target/s390/nobp-table-jump-z10.c +++ b/gcc/testsuite/gcc.target/s390/nobp-table-jump-z10.c @@ -3,29 +3,29 @@ /* case-values-threshold will be set to 20 by the back-end when jump thunk are requested. */ -int __attribute__((noinline,noclone)) foo1 (void) { return 1; } -int __attribute__((noinline,noclone)) foo2 (void) { return 2; } -int __attribute__((noinline,noclone)) foo3 (void) { return 3; } -int __attribute__((noinline,noclone)) foo4 (void) { return 4; } -int __attribute__((noinline,noclone)) foo5 (void) { return 5; } -int __attribute__((noinline,noclone)) foo6 (void) { return 6; } -int __attribute__((noinline,noclone)) foo7 (void) { return 7; } -int __attribute__((noinline,noclone)) foo8 (void) { return 8; } -int __attribute__((noinline,noclone)) foo9 (void) { return 9; } -int __attribute__((noinline,noclone)) foo10 (void) { return 10; } -int __attribute__((noinline,noclone)) foo11 (void) { return 11; } -int __attribute__((noinline,noclone)) foo12 (void) { return 12; } -int __attribute__((noinline,noclone)) foo13 (void) { return 13; } -int __attribute__((noinline,noclone)) foo14 (void) { return 14; } -int __attribute__((noinline,noclone)) foo15 (void) { return 15; } -int __attribute__((noinline,noclone)) foo16 (void) { return 16; } -int __attribute__((noinline,noclone)) foo17 (void) { return 17; } -int __attribute__((noinline,noclone)) foo18 (void) { return 18; } -int __attribute__((noinline,noclone)) foo19 (void) { return 19; } -int __attribute__((noinline,noclone)) foo20 (void) { return 20; } +int __attribute__((noipa)) foo1 (void) { return 1; } +int __attribute__((noipa)) foo2 (void) { return 2; } +int __attribute__((noipa)) foo3 (void) { return 3; } +int __attribute__((noipa)) foo4 (void) { return 4; } +int __attribute__((noipa)) foo5 (void) { return 5; } +int __attribute__((noipa)) foo6 (void) { return 6; } +int __attribute__((noipa)) foo7 (void) { return 7; } +int __attribute__((noipa)) foo8 (void) { return 8; } +int __attribute__((noipa)) foo9 (void) { return 9; } +int __attribute__((noipa)) foo10 (void) { return 10; } +int __attribute__((noipa)) foo11 (void) { return 11; } +int __attribute__((noipa)) foo12 (void) { return 12; } +int __attribute__((noipa)) foo13 (void) { return 13; } +int __attribute__((noipa)) foo14 (void) { return 14; } +int __attribute__((noipa)) foo15 (void) { return 15; } +int __attribute__((noipa)) foo16 (void) { return 16; } +int __attribute__((noipa)) foo17 (void) { return 17; } +int __attribute__((noipa)) foo18 (void) { return 18; } +int __attribute__((noipa)) foo19 (void) { return 19; } +int __attribute__((noipa)) foo20 (void) { return 20; } -int __attribute__((noinline,noclone)) +int __attribute__((noipa)) bar (int a) { int ret = 0; diff --git a/gcc/testsuite/gcc.target/s390/nobp-table-jump-z900.c b/gcc/testsuite/gcc.target/s390/nobp-table-jump-z900.c index f1439a8b1205b..4d8fb95e2c43a 100644 --- a/gcc/testsuite/gcc.target/s390/nobp-table-jump-z900.c +++ b/gcc/testsuite/gcc.target/s390/nobp-table-jump-z900.c @@ -4,29 +4,29 @@ /* case-values-threshold will be set to 20 by the back-end when jump thunk are requested. */ -int __attribute__((noinline,noclone)) foo1 (void) { return 1; } -int __attribute__((noinline,noclone)) foo2 (void) { return 2; } -int __attribute__((noinline,noclone)) foo3 (void) { return 3; } -int __attribute__((noinline,noclone)) foo4 (void) { return 4; } -int __attribute__((noinline,noclone)) foo5 (void) { return 5; } -int __attribute__((noinline,noclone)) foo6 (void) { return 6; } -int __attribute__((noinline,noclone)) foo7 (void) { return 7; } -int __attribute__((noinline,noclone)) foo8 (void) { return 8; } -int __attribute__((noinline,noclone)) foo9 (void) { return 9; } -int __attribute__((noinline,noclone)) foo10 (void) { return 10; } -int __attribute__((noinline,noclone)) foo11 (void) { return 11; } -int __attribute__((noinline,noclone)) foo12 (void) { return 12; } -int __attribute__((noinline,noclone)) foo13 (void) { return 13; } -int __attribute__((noinline,noclone)) foo14 (void) { return 14; } -int __attribute__((noinline,noclone)) foo15 (void) { return 15; } -int __attribute__((noinline,noclone)) foo16 (void) { return 16; } -int __attribute__((noinline,noclone)) foo17 (void) { return 17; } -int __attribute__((noinline,noclone)) foo18 (void) { return 18; } -int __attribute__((noinline,noclone)) foo19 (void) { return 19; } -int __attribute__((noinline,noclone)) foo20 (void) { return 20; } +int __attribute__((noipa)) foo1 (void) { return 1; } +int __attribute__((noipa)) foo2 (void) { return 2; } +int __attribute__((noipa)) foo3 (void) { return 3; } +int __attribute__((noipa)) foo4 (void) { return 4; } +int __attribute__((noipa)) foo5 (void) { return 5; } +int __attribute__((noipa)) foo6 (void) { return 6; } +int __attribute__((noipa)) foo7 (void) { return 7; } +int __attribute__((noipa)) foo8 (void) { return 8; } +int __attribute__((noipa)) foo9 (void) { return 9; } +int __attribute__((noipa)) foo10 (void) { return 10; } +int __attribute__((noipa)) foo11 (void) { return 11; } +int __attribute__((noipa)) foo12 (void) { return 12; } +int __attribute__((noipa)) foo13 (void) { return 13; } +int __attribute__((noipa)) foo14 (void) { return 14; } +int __attribute__((noipa)) foo15 (void) { return 15; } +int __attribute__((noipa)) foo16 (void) { return 16; } +int __attribute__((noipa)) foo17 (void) { return 17; } +int __attribute__((noipa)) foo18 (void) { return 18; } +int __attribute__((noipa)) foo19 (void) { return 19; } +int __attribute__((noipa)) foo20 (void) { return 20; } -int __attribute__((noinline,noclone)) +int __attribute__((noipa)) bar (int a) { int ret = 0; diff --git a/gcc/testsuite/gcc.target/s390/vector/vec-extend-1.c b/gcc/testsuite/gcc.target/s390/vector/vec-extend-1.c new file mode 100644 index 0000000000000..5f4f2c3e27477 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/vector/vec-extend-1.c @@ -0,0 +1,79 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=z13 -mzarch" } */ +/* { dg-final { check-function-bodies "**" "" "" } } */ + +typedef signed char v2qi __attribute__ ((vector_size (2))); +typedef short v2hi __attribute__ ((vector_size (4))); +typedef int v2si __attribute__ ((vector_size (8))); +typedef long long v2di __attribute__ ((vector_size (16))); + +typedef unsigned char uv2qi __attribute__ ((vector_size (2))); +typedef unsigned short uv2hi __attribute__ ((vector_size (4))); +typedef unsigned int uv2si __attribute__ ((vector_size (8))); +typedef unsigned long long uv2di __attribute__ ((vector_size (16))); + +/* +** extendv2qiv2hi2: +** vuphb %v24,%v24 +** br %r14 +*/ + +v2hi extendv2qiv2hi2 (v2qi x) +{ + return __builtin_convertvector (x, v2hi); +} + +/* +** extendv2hiv2si2: +** vuphh %v24,%v24 +** br %r14 +*/ + +v2si extendv2hiv2si2 (v2hi x) +{ + return __builtin_convertvector (x, v2si); +} + +/* +** extendv2siv2di2: +** vuphf %v24,%v24 +** br %r14 +*/ + +v2di extendv2siv2di2 (v2si x) +{ + return __builtin_convertvector (x, v2di); +} + +/* +** extenduv2qiuv2hi2: +** vuplhb %v24,%v24 +** br %r14 +*/ + +uv2hi extenduv2qiuv2hi2 (uv2qi x) +{ + return __builtin_convertvector (x, uv2hi); +} + +/* +** extenduv2hiuv2si2: +** vuplhh %v24,%v24 +** br %r14 +*/ + +uv2si extenduv2hiuv2si2 (uv2hi x) +{ + return __builtin_convertvector (x, uv2si); +} + +/* +** extenduv2siuv2di2: +** vuplhf %v24,%v24 +** br %r14 +*/ + +uv2di extenduv2siuv2di2 (uv2si x) +{ + return __builtin_convertvector (x, uv2di); +} diff --git a/gcc/testsuite/gcc.target/s390/vector/vec-extend-2.c b/gcc/testsuite/gcc.target/s390/vector/vec-extend-2.c new file mode 100644 index 0000000000000..d9c07ea9d0055 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/vector/vec-extend-2.c @@ -0,0 +1,55 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=z13 -mzarch" } */ +/* { dg-final { check-function-bodies "**" "" "" } } */ + +typedef signed char v4qi __attribute__ ((vector_size (4))); +typedef short v4hi __attribute__ ((vector_size (8))); +typedef int v4si __attribute__ ((vector_size (16))); + +typedef unsigned char uv4qi __attribute__ ((vector_size (4))); +typedef unsigned short uv4hi __attribute__ ((vector_size (8))); +typedef unsigned int uv4si __attribute__ ((vector_size (16))); + +/* +** extendv4qiv4hi2: +** vuphb %v24,%v24 +** br %r14 +*/ + +v4hi extendv4qiv4hi2 (v4qi x) +{ + return __builtin_convertvector (x, v4hi); +} + +/* +** extendv4hiv4si2: +** vuphh %v24,%v24 +** br %r14 +*/ + +v4si extendv4hiv4si2 (v4hi x) +{ + return __builtin_convertvector (x, v4si); +} + +/* +** extenduv4qiuv4hi2: +** vuplhb %v24,%v24 +** br %r14 +*/ + +uv4hi extenduv4qiuv4hi2 (uv4qi x) +{ + return __builtin_convertvector (x, uv4hi); +} + +/* +** extenduv4hiuv4si2: +** vuplhh %v24,%v24 +** br %r14 +*/ + +uv4si extenduv4hiuv4si2 (uv4hi x) +{ + return __builtin_convertvector (x, uv4si); +} diff --git a/gcc/testsuite/gcc.target/s390/vector/vec-extend-3.c b/gcc/testsuite/gcc.target/s390/vector/vec-extend-3.c new file mode 100644 index 0000000000000..2b02e7bf9f803 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/vector/vec-extend-3.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=z13 -mzarch" } */ +/* { dg-final { check-function-bodies "**" "" "" } } */ + +typedef float v2sf __attribute__ ((vector_size (8))); +typedef double v2df __attribute__ ((vector_size (16))); + +/* +** extendv2sfv2df2: +** vmrhf %v24,%v24,%v24 +** vldeb %v24,%v24 +** br %r14 +*/ + +v2df extendv2sfv2df2 (v2sf x) +{ + return __builtin_convertvector (x, v2df); +} diff --git a/gcc/testsuite/gfortran.dg/class_76.f90 b/gcc/testsuite/gfortran.dg/class_76.f90 index 1ee1e1fc25f2c..c9842a15feabc 100644 --- a/gcc/testsuite/gfortran.dg/class_76.f90 +++ b/gcc/testsuite/gfortran.dg/class_76.f90 @@ -61,6 +61,6 @@ function newContainer(thing) end function newContainer end program returned_memory_leak -! { dg-final { scan-tree-dump-times "newabstract" 14 "original" } } +! { dg-final { scan-tree-dump-times "newabstract" 15 "original" } } ! { dg-final { scan-tree-dump-times "__builtin_free" 8 "original" } } diff --git a/gcc/testsuite/gfortran.dg/class_77.f90 b/gcc/testsuite/gfortran.dg/class_77.f90 new file mode 100644 index 0000000000000..ef38dd6774345 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/class_77.f90 @@ -0,0 +1,83 @@ +! { dg-do compile } +! { dg-additional-options "-fdump-tree-original" } +! +! PR fortran/90072 +! +! Contributed by Brad Richardson +! + +module types + implicit none + + type, abstract :: base_returned + end type base_returned + + type, extends(base_returned) :: first_returned + end type first_returned + + type, extends(base_returned) :: second_returned + end type second_returned + + type, abstract :: base_called + contains + procedure(get_), deferred :: get + end type base_called + + type, extends(base_called) :: first_extended + contains + procedure :: get => getFirst + end type first_extended + + type, extends(base_called) :: second_extended + contains + procedure :: get => getSecond + end type second_extended + + abstract interface + function get_(self) result(returned) + import base_called + import base_returned + class(base_called), intent(in) :: self + class(base_returned), allocatable :: returned + end function get_ + end interface +contains + function getFirst(self) result(returned) + class(first_extended), intent(in) :: self + class(base_returned), allocatable :: returned + + allocate(returned, source = first_returned()) + end function getFirst + + function getSecond(self) result(returned) + class(second_extended), intent(in) :: self + class(base_returned), allocatable :: returned + + allocate(returned, source = second_returned()) + end function getSecond +end module types + +program dispatch_memory_leak + implicit none + + call run() +contains + subroutine run() + use types, only: base_returned, base_called, first_extended + + class(base_called), allocatable :: to_call + class(base_returned), allocatable :: to_get + + allocate(to_call, source = first_extended()) + allocate(to_get, source = to_call%get()) + + deallocate(to_get) + select type(to_call) + type is (first_extended) + allocate(to_get, source = to_call%get()) + end select + end subroutine run +end program dispatch_memory_leak + +! { dg-final { scan-tree-dump-times "__builtin_free" 5 "original" } } + diff --git a/gcc/testsuite/gfortran.dg/class_78.f90 b/gcc/testsuite/gfortran.dg/class_78.f90 new file mode 100644 index 0000000000000..3e2a0245afbf4 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/class_78.f90 @@ -0,0 +1,29 @@ +! { dg-do run } +! +! PR fortran/90076 +! +! Contributed by Brad Richardson +! + +program assignment_memory_leak + implicit none + + type, abstract :: base + end type base + + type, extends(base) :: extended + end type extended + + call run() +contains + subroutine run() + class(base), allocatable :: var + + var = newVar() ! Crash fixed + end subroutine run + + function newVar() + class(extended), allocatable :: newVar + end function newVar +end program assignment_memory_leak + diff --git a/gcc/testsuite/gfortran.dg/coarray_alloc_comp_3.f08 b/gcc/testsuite/gfortran.dg/coarray/alloc_comp_8.f90 similarity index 95% rename from gcc/testsuite/gfortran.dg/coarray_alloc_comp_3.f08 rename to gcc/testsuite/gfortran.dg/coarray/alloc_comp_8.f90 index e2037aa58093d..8b1539251298f 100644 --- a/gcc/testsuite/gfortran.dg/coarray_alloc_comp_3.f08 +++ b/gcc/testsuite/gfortran.dg/coarray/alloc_comp_8.f90 @@ -1,12 +1,11 @@ ! { dg-do run } -! { dg-options "-fcoarray=lib -lcaf_single" } ! { dg-additional-options "-latomic" { target libatomic_available } } ! ! Contributed by Andre Vehreschild ! Check that manually freeing components does not lead to a runtime crash, ! when the auto-deallocation is taking care. -program coarray_alloc_comp_3 +program alloc_comp_6 implicit none type dt diff --git a/gcc/testsuite/gfortran.dg/coarray_alloc_comp_4.f08 b/gcc/testsuite/gfortran.dg/coarray_alloc_comp_4.f08 index 6586ec651ddfa..4c71a90af8fa8 100644 --- a/gcc/testsuite/gfortran.dg/coarray_alloc_comp_4.f08 +++ b/gcc/testsuite/gfortran.dg/coarray_alloc_comp_4.f08 @@ -5,7 +5,7 @@ ! Contributed by Andre Vehreschild ! Check that sub-components are caf_deregistered and not freed. -program coarray_alloc_comp_3 +program coarray_alloc_comp_4 implicit none type dt diff --git a/gcc/testsuite/gfortran.dg/finalize_57.f90 b/gcc/testsuite/gfortran.dg/finalize_57.f90 new file mode 100644 index 0000000000000..b6257357c752c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/finalize_57.f90 @@ -0,0 +1,63 @@ +! { dg-do compile } +! { dg-additional-options "-fdump-tree-original" } +! +! PR fortran/90068 +! +! Contributed by Brad Richardson +! + +program array_memory_leak + implicit none + + type, abstract :: base + end type base + + type, extends(base) :: extended + end type extended + + type :: container + class(base), allocatable :: thing + end type + + type, extends(base) :: collection + type(container), allocatable :: stuff(:) + end type collection + + call run() + call bad() +contains + subroutine run() + type(collection) :: my_thing + type(container) :: a_container + + a_container = newContainer(newExtended()) ! This is fine + my_thing = newCollection([a_container]) + end subroutine run + + subroutine bad() + type(collection) :: my_thing + + my_thing = newCollection([newContainer(newExtended())]) ! This is a memory leak + end subroutine bad + + function newExtended() + type(extended) :: newExtended + end function newExtended + + function newContainer(thing) + class(base), intent(in) :: thing + type(container) :: newContainer + + allocate(newContainer%thing, source = thing) + end function newContainer + + function newCollection(things) + type(container), intent(in) :: things(:) + type(collection) :: newCollection + + newCollection%stuff = things + end function newCollection +end program array_memory_leak + +! { dg-final { scan-tree-dump-times "__builtin_free" 15 "original" } } + diff --git a/gcc/testsuite/gm2/base-lang/pass/SYSTEM.def b/gcc/testsuite/gm2/base-lang/pass/SYSTEM.def new file mode 100644 index 0000000000000..fde650bee2462 --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/SYSTEM.def @@ -0,0 +1,197 @@ +(* SYSTEM.def provides access to the SYSTEM dependent module. + +Copyright (C) 2001-2024 Free Software Foundation, Inc. +Contributed by Gaius Mulley . + +This file is part of GNU Modula-2. + +GNU Modula-2 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. + +GNU Modula-2 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. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +. *) + +DEFINITION MODULE SYSTEM ; + +EXPORT QUALIFIED BITSPERBYTE, BYTESPERWORD, + ADDRESS, WORD, BYTE, CSIZE_T, CSSIZE_T, (* @SYSTEM_DATATYPES@ *) + ADR, TSIZE, ROTATE, SHIFT, THROW, TBITSIZE ; + (* SIZE is also exported if -fpim2 is used. *) + +CONST + BITSPERBYTE = __ATTRIBUTE__ __BUILTIN__ ((BITS_PER_UNIT)) ; + BYTESPERWORD = __ATTRIBUTE__ __BUILTIN__ ((UNITS_PER_WORD)) ; + +(* Note that the full list of system and sized datatypes include: + LOC, WORD, BYTE, ADDRESS, + + (and the non language standard target types) + + INTEGER8, INTEGER16, INTEGER32, INTEGER64, + CARDINAL8, CARDINAL16, CARDINAL32, CARDINAL64, + WORD16, WORD32, WORD64, BITSET8, BITSET16, + BITSET32, REAL32, REAL64, REAL128, COMPLEX32, + COMPLEX64, COMPLEX128, CSIZE_T, CSSIZE_T. + + Also note that the non-standard data types will + move into another module in the future. *) + + +(* The following types are supported on this target: +TYPE + @SYSTEM_TYPES@ +*) + + +(* + all the functions below are declared internally to gm2 + ====================================================== + +PROCEDURE ADR (VAR v: ): ADDRESS; + (* Returns the address of variable v. *) + +PROCEDURE SIZE (v: ) : ZType; + (* Returns the number of BYTES used to store a v of + any specified . Only available if -fpim2 is used. + *) + +PROCEDURE TSIZE () : CARDINAL; + (* Returns the number of BYTES used to store a value of the + specified . + *) + +PROCEDURE ROTATE (val: ; + num: INTEGER): ; + (* Returns a bit sequence obtained from val by rotating up/right + or down/right by the absolute value of num. The direction is + down/right if the sign of num is negative, otherwise the direction + is up/left. + *) + +PROCEDURE SHIFT (val: ; + num: INTEGER): ; + (* Returns a bit sequence obtained from val by shifting up/left + or down/right by the absolute value of num, introducing + zeros as necessary. The direction is down/right if the sign of + num is negative, otherwise the direction is up/left. + *) + +PROCEDURE THROW (i: INTEGER) <* noreturn *> ; + (* + THROW is a GNU extension and was not part of the PIM or ISO + standards. It throws an exception which will be caught by the + EXCEPT block (assuming it exists). This is a compiler builtin + function which interfaces to the GCC exception handling runtime + system. + GCC uses the term throw, hence the naming distinction between + the GCC builtin and the Modula-2 runtime library procedure Raise. + The later library procedure Raise will call SYSTEM.THROW after + performing various housekeeping activities. + *) + +PROCEDURE TBITSIZE () : CARDINAL ; + (* Returns the minimum number of bits necessary to represent + . This procedure function is only useful for determining + the number of bits used for any type field within a packed RECORD. + It is not particularly useful elsewhere since might be + optimized for speed, for example a BOOLEAN could occupy a WORD. + *) +*) + +(* The following procedures are invoked by GNU Modula-2 to + shift non word sized set types. They are not strictly part + of the core PIM Modula-2, however they are used + to implement the SHIFT procedure defined above, + which are in turn used by the Logitech compatible libraries. + + Users will access these procedures by using the procedure + SHIFT above and GNU Modula-2 will map SHIFT onto one of + the following procedures. +*) + +(* + ShiftVal - is a runtime procedure whose job is to implement + the SHIFT procedure of ISO SYSTEM. GNU Modula-2 will + inline a SHIFT of a single WORD sized set and will only + call this routine for larger sets. +*) + +PROCEDURE ShiftVal (VAR s, d: ARRAY OF BITSET; + SetSizeInBits: CARDINAL; + ShiftCount: INTEGER) ; + + +(* + ShiftLeft - performs the shift left for a multi word set. + This procedure might be called by the back end of + GNU Modula-2 depending whether amount is known at + compile time. +*) + +PROCEDURE ShiftLeft (VAR s, d: ARRAY OF BITSET; + SetSizeInBits: CARDINAL; + ShiftCount: CARDINAL) ; + +(* + ShiftRight - performs the shift left for a multi word set. + This procedure might be called by the back end of + GNU Modula-2 depending whether amount is known at + compile time. +*) + +PROCEDURE ShiftRight (VAR s, d: ARRAY OF BITSET; + SetSizeInBits: CARDINAL; + ShiftCount: CARDINAL) ; + + +(* + RotateVal - is a runtime procedure whose job is to implement + the ROTATE procedure of ISO SYSTEM. GNU Modula-2 will + inline a ROTATE of a single WORD (or less) + sized set and will only call this routine for larger + sets. +*) + +PROCEDURE RotateVal (VAR s, d: ARRAY OF BITSET; + SetSizeInBits: CARDINAL; + RotateCount: INTEGER) ; + + +(* + RotateLeft - performs the rotate left for a multi word set. + This procedure might be called by the back end of + GNU Modula-2 depending whether amount is known at + compile time. +*) + +PROCEDURE RotateLeft (VAR s, d: ARRAY OF BITSET; + SetSizeInBits: CARDINAL; + RotateCount: CARDINAL) ; + + +(* + RotateRight - performs the rotate right for a multi word set. + This procedure might be called by the back end of + GNU Modula-2 depending whether amount is known at + compile time. +*) + +PROCEDURE RotateRight (VAR s, d: ARRAY OF BITSET; + SetSizeInBits: CARDINAL; + RotateCount: CARDINAL) ; + + +END SYSTEM. diff --git a/gcc/testsuite/gm2/base-lang/pass/base-lang-test.sh b/gcc/testsuite/gm2/base-lang/pass/base-lang-test.sh new file mode 100755 index 0000000000000..de33018775fca --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/base-lang-test.sh @@ -0,0 +1,291 @@ +#!/bin/sh +# Copyright (C) 2024 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 +# . + +# This file was written by Gaius Mulley (gaiusmod2@gmail.com) + +# This script performs base language translation tests with the bootstrap tool mc. + +MC=$1 +GCCSRCDIR=$2 +GCCBUILDDIR=$3 +GXX=$4 + + +SCRATCHDIR=${GCCBUILDDIR}/m2/mc-base-lang-test + + +function compile () { + echo $* + if ! $* ; then + echo $* + echo "bootstrap compiler ${MC} failed: $*" + exit 1 + fi +} + + +function compile_def () { + SRC=$1 + compile ${MC} -o=${SCRATCHDIR}/G${SRC}.h --olang=c++ --h-file-prefix=G --quiet \ + -I${GCCSRCDIR}/m2/gm2-libs -I${GCCSRCDIR}/testsuite/gm2/base-lang/pass \ + ${GCCSRCDIR}/testsuite/gm2/base-lang/pass/${SRC}.def +} + + +function compile_mod () { + SRC=$1 + compile ${MC} -o=${SCRATCHDIR}/G${SRC}.cc --olang=c++ --h-file-prefix=G --quiet \ + -I${GCCSRCDIR}/m2/gm2-libs -I${GCCSRCDIR}/testsuite/gm2/base-lang/pass \ + ${GCCSRCDIR}/testsuite/gm2/base-lang/pass/${SRC}.mod +} + + +# +# verify - check that the translated sources compile with -Wodr +# + +function verify () { + SRC=$1 + if ${GXX} -Wodr -Werror -I${SCRATCHDIR} -c ${SCRATCHDIR}/G${SRC}.cc -o ${SCRATCHDIR}/G${SRC}.o ; then + echo "${NAME}: Passed" + else + echo "${NAME}: Failed (${GXX} -Wodr -Werror -I${SCRATCHDIR} -c ${SCRATCHDIR}/G${SRC}.cc)" + exit 1 + fi +} + + +function localvar () { + rm -rf ${SCRATCHDIR} + mkdir -p ${SCRATCHDIR} + NAME="local variable creation" + compile_def localvar + compile_mod localvar + verify localvar +} + + +function globalvar () { + rm -rf ${SCRATCHDIR} + mkdir -p ${SCRATCHDIR} + NAME="global variable creation" + compile_def globalvar + compile_mod globalvar + verify globalvar +} + + +function localvarassign () { + rm -rf ${SCRATCHDIR} + mkdir -p ${SCRATCHDIR} + NAME="local variable assignment" + compile_def localvarassign + compile_mod localvarassign + verify localvarassign +} + + +function globalvarassign () { + rm -rf ${SCRATCHDIR} + mkdir -p ${SCRATCHDIR} + NAME="global variable assignment" + compile_def globalvarassign + compile_mod globalvarassign + verify globalvarassign +} + + +function localproctype () { + rm -rf ${SCRATCHDIR} + mkdir -p ${SCRATCHDIR} + NAME="local proctype creation" + compile_def localproctype + compile_mod localproctype + verify localproctype +} + + +function globalproctype () { + rm -rf ${SCRATCHDIR} + mkdir -p ${SCRATCHDIR} + NAME="global proctype creation" + compile_def globalproctype + compile_mod globalproctype + verify globalproctype +} + + +function simpleopaque () { + rm -rf ${SCRATCHDIR} + mkdir -p ${SCRATCHDIR} + NAME="simple opaque type creation" + compile_def simpleopaque + compile_mod simpleopaque + verify simpleopaque +} + + +function simplelist () { + rm -rf ${SCRATCHDIR} + mkdir -p ${SCRATCHDIR} + NAME="simple list opaque type field manipulation" + compile_def simplelist + compile_mod simplelist + verify simplelist +} + + +function simplelistiter () { + rm -rf ${SCRATCHDIR} + mkdir -p ${SCRATCHDIR} + NAME="simple iteration using opaque type field" + compile_def simplelistiter + compile_mod simplelistiter + verify simplelistiter +} + + +function opaqueparam () { + rm -rf ${SCRATCHDIR} + mkdir -p ${SCRATCHDIR} + NAME="opaque parameter and field assignment" + compile_def opaqueparam + compile_mod opaqueparam + verify opaqueparam +} + + +function opaqueuse () { + rm -rf ${SCRATCHDIR} + mkdir -p ${SCRATCHDIR} + NAME="opaque use" + compile_def opaqueparam + compile_def opaqueuse + compile_mod opaqueuse + verify opaqueuse +} + + +function opaquestr () { + rm -rf ${SCRATCHDIR} + mkdir -p ${SCRATCHDIR} + NAME="opaque str" + compile_def opaquestr + compile_def opaqueusestr + compile_mod opaqueusestr + verify opaqueusestr +} + + +function opaquenew () { + rm -rf ${SCRATCHDIR} + mkdir -p ${SCRATCHDIR} + NAME="opaque new" + compile_def opaquenew + compile_mod opaquenew + verify opaquenew +} + + +function opaquefield () { + rm -rf ${SCRATCHDIR} + mkdir -p ${SCRATCHDIR} + NAME="opaque field" + compile_def opaquestr + compile_def opaquefield + compile_mod opaquefield + verify opaquefield +} + + +function opaquevariant () { + rm -rf ${SCRATCHDIR} + mkdir -p ${SCRATCHDIR} + NAME="opaque variant" + compile_def opaquevariant + compile_mod opaquevariant + verify opaquevariant +} + + +function opaquevarparam () { + rm -rf ${SCRATCHDIR} + mkdir -p ${SCRATCHDIR} + NAME="opaque variant" + compile_def opaquevarparam + compile_mod opaquevarparam + verify opaquevarparam +} + + +function straddress () { + rm -rf ${SCRATCHDIR} + mkdir -p ${SCRATCHDIR} + NAME="string address" + compile_def SYSTEM + compile_def straddress + compile_mod straddress + verify straddress +} + + +function straddressexport () { + rm -rf ${SCRATCHDIR} + mkdir -p ${SCRATCHDIR} + NAME="string address" + compile_def SYSTEM + compile_def straddressexport + compile_mod straddressexport + verify straddressexport +} + + +function unboundedarray () { + rm -rf ${SCRATCHDIR} + mkdir -p ${SCRATCHDIR} + NAME="string address" + compile_def unboundedarray + compile_mod unboundedarray + verify unboundedarray +} + + +function runall () { + localvar + globalvar + localvarassign + globalvarassign + localproctype + globalproctype + simpleopaque + simplelist + simplelistiter + opaqueparam + opaqueuse + opaquestr + opaquenew + opaquefield + opaquevariant + opaquevarparam + straddress + straddressexport + unboundedarray + echo "all base language boot strap tests pass -Wodr -Werror" +} + + +runall diff --git a/gcc/testsuite/gm2/base-lang/pass/globalproctype.def b/gcc/testsuite/gm2/base-lang/pass/globalproctype.def new file mode 100644 index 0000000000000..ce52321495ab8 --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/globalproctype.def @@ -0,0 +1,7 @@ +DEFINITION MODULE globalproctype ; (*!m2pim*) + +TYPE + myproc = PROCEDURE (CARDINAL) ; + + +END globalproctype. diff --git a/gcc/testsuite/gm2/base-lang/pass/globalproctype.mod b/gcc/testsuite/gm2/base-lang/pass/globalproctype.mod new file mode 100644 index 0000000000000..bddb5a9fdd50d --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/globalproctype.mod @@ -0,0 +1,13 @@ +IMPLEMENTATION MODULE globalproctype ; (*!m2pim*) + + +PROCEDURE foo (c: CARDINAL) ; +BEGIN +END foo ; + + +VAR + p: myproc ; +BEGIN + p := foo +END globalproctype. diff --git a/gcc/testsuite/gm2/base-lang/pass/globalvar.def b/gcc/testsuite/gm2/base-lang/pass/globalvar.def new file mode 100644 index 0000000000000..8c6ff983df4e6 --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/globalvar.def @@ -0,0 +1,3 @@ +DEFINITION MODULE globalvar ; (*!m2pim*) + +END globalvar. diff --git a/gcc/testsuite/gm2/base-lang/pass/globalvar.mod b/gcc/testsuite/gm2/base-lang/pass/globalvar.mod new file mode 100644 index 0000000000000..d18058c31ea5e --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/globalvar.mod @@ -0,0 +1,6 @@ +IMPLEMENTATION MODULE globalvar ; (*!m2pim*) + +VAR + i: INTEGER ; +BEGIN +END globalvar. diff --git a/gcc/testsuite/gm2/base-lang/pass/globalvarassign.def b/gcc/testsuite/gm2/base-lang/pass/globalvarassign.def new file mode 100644 index 0000000000000..8238bbf4bd3ca --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/globalvarassign.def @@ -0,0 +1,3 @@ +DEFINITION MODULE globalvarassign ; (*!m2pim*) + +END globalvarassign. diff --git a/gcc/testsuite/gm2/base-lang/pass/globalvarassign.mod b/gcc/testsuite/gm2/base-lang/pass/globalvarassign.mod new file mode 100644 index 0000000000000..17e88e4301339 --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/globalvarassign.mod @@ -0,0 +1,8 @@ +IMPLEMENTATION MODULE globalvarassign ; (*!m2pim*) + + +VAR + i: INTEGER ; +BEGIN + i := 1 +END globalvarassign. diff --git a/gcc/testsuite/gm2/base-lang/pass/localproctype.def b/gcc/testsuite/gm2/base-lang/pass/localproctype.def new file mode 100644 index 0000000000000..54164f9727ef5 --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/localproctype.def @@ -0,0 +1,3 @@ +DEFINITION MODULE localproctype ; (*!m2pim*) + +END localproctype. diff --git a/gcc/testsuite/gm2/base-lang/pass/localproctype.mod b/gcc/testsuite/gm2/base-lang/pass/localproctype.mod new file mode 100644 index 0000000000000..e896ef2a73d05 --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/localproctype.mod @@ -0,0 +1,16 @@ +IMPLEMENTATION MODULE localproctype ; (*!m2pim*) + +TYPE + myproc = PROCEDURE (CARDINAL) ; + + +PROCEDURE foo (c: CARDINAL) ; +BEGIN +END foo ; + + +VAR + p: myproc ; +BEGIN + p := foo +END localproctype. diff --git a/gcc/testsuite/gm2/base-lang/pass/localvar.def b/gcc/testsuite/gm2/base-lang/pass/localvar.def new file mode 100644 index 0000000000000..726d46174a92c --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/localvar.def @@ -0,0 +1,3 @@ +DEFINITION MODULE localvar ; (*!m2pim*) + +END localvar. diff --git a/gcc/testsuite/gm2/base-lang/pass/localvar.mod b/gcc/testsuite/gm2/base-lang/pass/localvar.mod new file mode 100644 index 0000000000000..0839351c49a7f --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/localvar.mod @@ -0,0 +1,11 @@ +IMPLEMENTATION MODULE localvar ; (*!m2pim*) + +PROCEDURE foo ; +VAR + i: INTEGER ; +BEGIN +END foo ; + +BEGIN + foo +END localvar. diff --git a/gcc/testsuite/gm2/base-lang/pass/localvarassign.def b/gcc/testsuite/gm2/base-lang/pass/localvarassign.def new file mode 100644 index 0000000000000..a9bb7a43df788 --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/localvarassign.def @@ -0,0 +1,3 @@ +DEFINITION MODULE localvarassign ; (*!m2pim*) + +END localvarassign. diff --git a/gcc/testsuite/gm2/base-lang/pass/localvarassign.mod b/gcc/testsuite/gm2/base-lang/pass/localvarassign.mod new file mode 100644 index 0000000000000..d4de6a5452045 --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/localvarassign.mod @@ -0,0 +1,14 @@ +IMPLEMENTATION MODULE localvarassign ; (*!m2pim*) + + +PROCEDURE foo ; +VAR + i: INTEGER ; +BEGIN + i := 1 +END foo ; + + +BEGIN + foo +END localvarassign. diff --git a/gcc/testsuite/gm2/base-lang/pass/opaquefield.def b/gcc/testsuite/gm2/base-lang/pass/opaquefield.def new file mode 100644 index 0000000000000..83006ec8e3b30 --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/opaquefield.def @@ -0,0 +1,8 @@ +DEFINITION MODULE opaquefield ; (*!m2pim*) + +TYPE + Content ; + +PROCEDURE create () : Content ; + +END opaquefield. diff --git a/gcc/testsuite/gm2/base-lang/pass/opaquefield.mod b/gcc/testsuite/gm2/base-lang/pass/opaquefield.mod new file mode 100644 index 0000000000000..4bbf2238455ba --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/opaquefield.mod @@ -0,0 +1,19 @@ +IMPLEMENTATION MODULE opaquefield ; (*!m2pim*) + +FROM opaquestr IMPORT String, initString ; + +TYPE + Content = POINTER TO RECORD + next: String ; + END ; + +PROCEDURE create () : Content ; +VAR + c: Content ; +BEGIN + c^.next := initString () ; + RETURN c +END create ; + + +END opaquefield. diff --git a/gcc/testsuite/gm2/base-lang/pass/opaquenew.def b/gcc/testsuite/gm2/base-lang/pass/opaquenew.def new file mode 100644 index 0000000000000..457c3e56a624b --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/opaquenew.def @@ -0,0 +1,8 @@ +DEFINITION MODULE opaquenew ; (*!m2pim*) + +TYPE + List ; + +PROCEDURE dupList (l: List) : List ; + +END opaquenew. diff --git a/gcc/testsuite/gm2/base-lang/pass/opaquenew.mod b/gcc/testsuite/gm2/base-lang/pass/opaquenew.mod new file mode 100644 index 0000000000000..c9b873f3abf93 --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/opaquenew.mod @@ -0,0 +1,18 @@ +IMPLEMENTATION MODULE opaquenew ; (*!m2pim*) + +TYPE + List = POINTER TO RECORD + next: List ; + END ; + + +PROCEDURE dupList (l: List) : List ; +VAR + n: List ; +BEGIN + (* NEW (n) *) + n^ := l^ ; + RETURN n +END dupList ; + +END opaquenew. diff --git a/gcc/testsuite/gm2/base-lang/pass/opaqueparam.def b/gcc/testsuite/gm2/base-lang/pass/opaqueparam.def new file mode 100644 index 0000000000000..007bfb798003d --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/opaqueparam.def @@ -0,0 +1,12 @@ +DEFINITION MODULE opaqueparam ; (*!m2pim*) + +TYPE + List ; + + +PROCEDURE initList () : List ; + +PROCEDURE add (l: List) ; + + +END opaqueparam. diff --git a/gcc/testsuite/gm2/base-lang/pass/opaqueparam.mod b/gcc/testsuite/gm2/base-lang/pass/opaqueparam.mod new file mode 100644 index 0000000000000..1b854f0b60d4b --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/opaqueparam.mod @@ -0,0 +1,32 @@ +IMPLEMENTATION MODULE opaqueparam ; (*!m2pim*) + +TYPE + List = POINTER TO RECORD + next: List ; + END ; + + +PROCEDURE local (l: List) : List ; +BEGIN + RETURN l +END local ; + + +PROCEDURE add (l: List) ; +BEGIN + IF l = NIL + THEN + l^.next := local (initList ()) + END +END add ; + + +PROCEDURE initList () : List ; +VAR + l: List ; +BEGIN + RETURN l +END initList ; + + +END opaqueparam. diff --git a/gcc/testsuite/gm2/base-lang/pass/opaquestr.def b/gcc/testsuite/gm2/base-lang/pass/opaquestr.def new file mode 100644 index 0000000000000..8ebf1665c83ba --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/opaquestr.def @@ -0,0 +1,10 @@ +DEFINITION MODULE opaquestr ; (*!m2pim*) + +TYPE + String ; + +PROCEDURE initString () : String ; +PROCEDURE concat (left, right: String) : String ; + + +END opaquestr. diff --git a/gcc/testsuite/gm2/base-lang/pass/opaqueuse.def b/gcc/testsuite/gm2/base-lang/pass/opaqueuse.def new file mode 100644 index 0000000000000..084d2555195d2 --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/opaqueuse.def @@ -0,0 +1,7 @@ +DEFINITION MODULE opaqueuse ; (*!m2pim*) + +FROM opaqueparam IMPORT List ; + +PROCEDURE extending (l: List) : List ; + +END opaqueuse. diff --git a/gcc/testsuite/gm2/base-lang/pass/opaqueuse.mod b/gcc/testsuite/gm2/base-lang/pass/opaqueuse.mod new file mode 100644 index 0000000000000..577a54b558d2f --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/opaqueuse.mod @@ -0,0 +1,15 @@ +IMPLEMENTATION MODULE opaqueuse ; (*!m2pim*) + +FROM opaqueparam IMPORT initList, add ; + +PROCEDURE extending (l: List) : List ; +VAR + n: List ; +BEGIN + n := initList () ; + add (n) ; + RETURN n +END extending ; + + +END opaqueuse. diff --git a/gcc/testsuite/gm2/base-lang/pass/opaqueusestr.def b/gcc/testsuite/gm2/base-lang/pass/opaqueusestr.def new file mode 100644 index 0000000000000..1e05e45335ce0 --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/opaqueusestr.def @@ -0,0 +1,9 @@ +DEFINITION MODULE opaqueusestr ; (*!m2pim*) + +FROM opaquestr IMPORT String ; + +PROCEDURE doDecimalPlaces (s: String; n: CARDINAL) : String ; +PROCEDURE IntegerToString (i: INTEGER) : String ; + + +END opaqueusestr. diff --git a/gcc/testsuite/gm2/base-lang/pass/opaqueusestr.mod b/gcc/testsuite/gm2/base-lang/pass/opaqueusestr.mod new file mode 100644 index 0000000000000..65aebee1fd5b5 --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/opaqueusestr.mod @@ -0,0 +1,27 @@ +IMPLEMENTATION MODULE opaqueusestr ; (*!m2pim*) + +FROM opaquestr IMPORT initString, concat ; + + +PROCEDURE rtos (r: REAL; TotalWidth, FractionWidth: CARDINAL) : String ; +BEGIN + RETURN ( NIL ) +END rtos ; + + +PROCEDURE doDecimalPlaces (s: String; n: CARDINAL) : String ; +BEGIN + RETURN concat (s, initString ()) +END doDecimalPlaces ; + + +PROCEDURE IntegerToString (i: INTEGER) : String ; +VAR + s: String ; +BEGIN + s := initString () ; + RETURN s +END IntegerToString ; + + +END opaqueusestr. diff --git a/gcc/testsuite/gm2/base-lang/pass/opaquevariant.def b/gcc/testsuite/gm2/base-lang/pass/opaquevariant.def new file mode 100644 index 0000000000000..84f0bbd05ed6d --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/opaquevariant.def @@ -0,0 +1,6 @@ +DEFINITION MODULE opaquevariant ; (*!m2pim*) + +TYPE + Opaque ; + +END opaquevariant. diff --git a/gcc/testsuite/gm2/base-lang/pass/opaquevariant.mod b/gcc/testsuite/gm2/base-lang/pass/opaquevariant.mod new file mode 100644 index 0000000000000..3197a04ca3103 --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/opaquevariant.mod @@ -0,0 +1,26 @@ +IMPLEMENTATION MODULE opaquevariant ; (*!m2pim*) + +TYPE + colour = (red, blue, green) ; + Opaque = POINTER TO RECORD + CASE key: colour OF + + red : truefield : TrueRec | + blue, + green: falsefield: FalseRec + + END + END ; + + TrueRec = RECORD + a: Opaque + END ; + + FalseRec = RECORD + b: Opaque + END ; + +VAR + v: Opaque ; + +END opaquevariant. diff --git a/gcc/testsuite/gm2/base-lang/pass/opaquevarparam.def b/gcc/testsuite/gm2/base-lang/pass/opaquevarparam.def new file mode 100644 index 0000000000000..3249da17964d0 --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/opaquevarparam.def @@ -0,0 +1,9 @@ +DEFINITION MODULE opaquevarparam ; + +TYPE + Opaque ; + +PROCEDURE del (VAR o: Opaque) ; + + +END opaquevarparam. diff --git a/gcc/testsuite/gm2/base-lang/pass/opaquevarparam.mod b/gcc/testsuite/gm2/base-lang/pass/opaquevarparam.mod new file mode 100644 index 0000000000000..90a34bda2b400 --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/opaquevarparam.mod @@ -0,0 +1,16 @@ +IMPLEMENTATION MODULE opaquevarparam ; + +TYPE + Opaque = POINTER TO RECORD + next: Opaque ; + END ; + +PROCEDURE del (VAR o: Opaque) ; +BEGIN + IF o # NIL + THEN + del (o^.next) + END +END del ; + +END opaquevarparam. diff --git a/gcc/testsuite/gm2/base-lang/pass/simplelist.def b/gcc/testsuite/gm2/base-lang/pass/simplelist.def new file mode 100644 index 0000000000000..f6221757f6e2e --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/simplelist.def @@ -0,0 +1,11 @@ +DEFINITION MODULE simplelist ; (*!m2pim*) + +TYPE + List ; + +PROCEDURE initList () : List ; + +PROCEDURE concat (l: List) : List ; + + +END simplelist. diff --git a/gcc/testsuite/gm2/base-lang/pass/simplelist.mod b/gcc/testsuite/gm2/base-lang/pass/simplelist.mod new file mode 100644 index 0000000000000..37b1e5959177f --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/simplelist.mod @@ -0,0 +1,33 @@ +IMPLEMENTATION MODULE simplelist ; (*!m2pim*) + + +TYPE + List = POINTER TO RECORD + next: List ; + END ; + + +PROCEDURE initList () : List ; +VAR + l: List ; +BEGIN + (* Ignore NEW (l) for now. *) + RETURN l +END initList ; + + +PROCEDURE concat (l: List) : List ; +BEGIN + l^.next := initList () ; + RETURN l +END concat ; + + +PROCEDURE addList (l: List) : List ; +BEGIN + l^.next := initList () ; + RETURN l +END addList ; + + +END simplelist. diff --git a/gcc/testsuite/gm2/base-lang/pass/simplelistiter.def b/gcc/testsuite/gm2/base-lang/pass/simplelistiter.def new file mode 100644 index 0000000000000..b2eae7652b15f --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/simplelistiter.def @@ -0,0 +1,10 @@ +DEFINITION MODULE simplelistiter ; (*!m2pim*) + +TYPE + List ; + +PROCEDURE initList () : List ; + +PROCEDURE items (l: List) : CARDINAL ; + +END simplelistiter. diff --git a/gcc/testsuite/gm2/base-lang/pass/simplelistiter.mod b/gcc/testsuite/gm2/base-lang/pass/simplelistiter.mod new file mode 100644 index 0000000000000..10cacde3637ac --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/simplelistiter.mod @@ -0,0 +1,30 @@ +IMPLEMENTATION MODULE simplelistiter ; (*!m2pim*) + +TYPE + List = POINTER TO RECORD + next: List ; + END ; + +PROCEDURE initList () : List ; +VAR + l: List ; +BEGIN + RETURN l +END initList ; + + +PROCEDURE items (l: List) : CARDINAL ; +(* VAR + count: CARDINAL ; *) +BEGIN +(* count := 0 ; *) + WHILE l # NIL DO + (* INC (count) ; *) + l := l^.next + END ; + (* RETURN count *) + RETURN 0 +END items ; + + +END simplelistiter. diff --git a/gcc/testsuite/gm2/base-lang/pass/simpleopaque.def b/gcc/testsuite/gm2/base-lang/pass/simpleopaque.def new file mode 100644 index 0000000000000..ca601aad01817 --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/simpleopaque.def @@ -0,0 +1,13 @@ +DEFINITION MODULE simpleopaque ; (*!m2pim*) + +TYPE + List ; + +PROCEDURE init () : List ; + +PROCEDURE join (left, right: List) : List ; + +PROCEDURE delete (VAR l: List) ; + + +END simpleopaque. diff --git a/gcc/testsuite/gm2/base-lang/pass/simpleopaque.mod b/gcc/testsuite/gm2/base-lang/pass/simpleopaque.mod new file mode 100644 index 0000000000000..62d56c0160221 --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/simpleopaque.mod @@ -0,0 +1,32 @@ +IMPLEMENTATION MODULE simpleopaque ; (*!m2pim*) + +TYPE + List = POINTER TO RECORD + next: List ; + END ; + + +PROCEDURE init () : List ; +VAR + l: List ; +BEGIN + RETURN l +END init ; + + +PROCEDURE join (left, right: List) : List ; +VAR + l: List ; +BEGIN + l := left ; + RETURN l +END join ; + + +PROCEDURE delete (VAR l: List) ; +BEGIN + l := NIL +END delete ; + + +END simpleopaque. diff --git a/gcc/testsuite/gm2/base-lang/pass/straddress.def b/gcc/testsuite/gm2/base-lang/pass/straddress.def new file mode 100644 index 0000000000000..24b243c2c72d0 --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/straddress.def @@ -0,0 +1,5 @@ +DEFINITION MODULE straddress ; (*!m2pim*) + +PROCEDURE Open (a: ARRAY OF CHAR) ; + +END straddress. diff --git a/gcc/testsuite/gm2/base-lang/pass/straddress.mod b/gcc/testsuite/gm2/base-lang/pass/straddress.mod new file mode 100644 index 0000000000000..78f90baee6ced --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/straddress.mod @@ -0,0 +1,16 @@ +IMPLEMENTATION MODULE straddress ; (*!m2pim*) + +FROM SYSTEM IMPORT ADDRESS, ADR ; + + +PROCEDURE open (a: ADDRESS) ; +BEGIN +END open ; + +PROCEDURE Open (a: ARRAY OF CHAR) ; +BEGIN + open (ADR (a)) +END Open ; + + +END straddress. diff --git a/gcc/testsuite/gm2/base-lang/pass/straddressexport.def b/gcc/testsuite/gm2/base-lang/pass/straddressexport.def new file mode 100644 index 0000000000000..34618ec120476 --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/straddressexport.def @@ -0,0 +1,8 @@ +DEFINITION MODULE straddressexport ; (*!m2pim*) + +FROM SYSTEM IMPORT ADDRESS ; + +PROCEDURE Open (a: ARRAY OF CHAR) ; +PROCEDURE open (a: ADDRESS) ; + +END straddressexport. diff --git a/gcc/testsuite/gm2/base-lang/pass/straddressexport.mod b/gcc/testsuite/gm2/base-lang/pass/straddressexport.mod new file mode 100644 index 0000000000000..0f1cca932ae0c --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/straddressexport.mod @@ -0,0 +1,16 @@ +IMPLEMENTATION MODULE straddressexport ; (*!m2pim*) + +FROM SYSTEM IMPORT ADR ; + + +PROCEDURE open (a: ADDRESS) ; +BEGIN +END open ; + +PROCEDURE Open (a: ARRAY OF CHAR) ; +BEGIN + open (ADR (a)) +END Open ; + + +END straddressexport. diff --git a/gcc/testsuite/gm2/base-lang/pass/unboundedarray.def b/gcc/testsuite/gm2/base-lang/pass/unboundedarray.def new file mode 100644 index 0000000000000..52c00356f176f --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/unboundedarray.def @@ -0,0 +1,5 @@ +DEFINITION MODULE unboundedarray ; + +PROCEDURE message (m: ARRAY OF CARDINAL) ; + +END unboundedarray. diff --git a/gcc/testsuite/gm2/base-lang/pass/unboundedarray.mod b/gcc/testsuite/gm2/base-lang/pass/unboundedarray.mod new file mode 100644 index 0000000000000..48f027efee1a6 --- /dev/null +++ b/gcc/testsuite/gm2/base-lang/pass/unboundedarray.mod @@ -0,0 +1,8 @@ +IMPLEMENTATION MODULE unboundedarray ; + +PROCEDURE message (m: ARRAY OF CARDINAL) ; +BEGIN + m[0] := 1 +END message ; + +END unboundedarray. diff --git a/gcc/testsuite/gnat.dg/access11.adb b/gcc/testsuite/gnat.dg/access11.adb new file mode 100644 index 0000000000000..7c5a07cf6fdb9 --- /dev/null +++ b/gcc/testsuite/gnat.dg/access11.adb @@ -0,0 +1,80 @@ +-- PR ada/114398 +-- Testcase by Dennis van Raaij + +-- { dg-do run } + +with Ada.Finalization; + +procedure Access11 is + + package Pkg is + + type Int is + new Ada.Finalization.Limited_Controlled + with record + Value : Integer; + end record; + + procedure Set (This : out Int; To : Integer); + procedure Set (This : out Int; To : Int); + + function "+" (Left, Right : Int) return Int; + + overriding procedure Initialize (This : in out Int); + overriding procedure Finalize (This : in out Int); + + end Pkg; + + package body Pkg is + + procedure Set (This : out Int; To : Integer) is + begin + This.Value := To; + end Set; + + procedure Set (This : out Int; To : Int) is + begin + This.Value := To.Value; + end Set; + + function "+" (Left, Right : Int) return Int is + begin + return Result : Int do + Result.Value := Left.Value + Right.Value; + end return; + end "+"; + + overriding procedure Initialize (This : in out Int) is + begin + This.Value := 42; + end Initialize; + + overriding procedure Finalize (This : in out Int) is + begin + This.Value := 0; + end Finalize; + + end Pkg; + + use Pkg; + + type Binary_Operator is access + function (Left, Right : Int) return Int; + + procedure Test + (Op : Binary_Operator; + Left, Right : Int) + is + Result : Int; + begin + Result.Set (Op (Left, Right)); + end Test; + + A, B : Int; + +begin + A.Set (7); + B.Set (9); + + Test ("+"'Access, A, B); +end; diff --git a/gcc/testsuite/gnat.dg/incomplete8.adb b/gcc/testsuite/gnat.dg/incomplete8.adb new file mode 100644 index 0000000000000..63fef59e8669b --- /dev/null +++ b/gcc/testsuite/gnat.dg/incomplete8.adb @@ -0,0 +1,22 @@ +-- PR ada/114708 +-- Reported by Jere + +-- { dg-do compile } + +procedure Incomplete8 is + + generic + type Element_Type(<>); + package Test_Incomplete_Formal is + type Element_Access is access Element_Type; + end Test_Incomplete_Formal; + + type Node; + + package P is new Test_Incomplete_Formal(Node); + + type Node is limited null record; + +begin + null; +end; diff --git a/gcc/testsuite/go.test/go-test.exp b/gcc/testsuite/go.test/go-test.exp index 8fdc7b420be37..9831738074663 100644 --- a/gcc/testsuite/go.test/go-test.exp +++ b/gcc/testsuite/go.test/go-test.exp @@ -477,7 +477,8 @@ proc go-gc-tests { } { if { ( [file tail $test] == "select2.go" \ || [file tail $test] == "stack.go" \ || [file tail $test] == "peano.go" \ - || [file tail $test] == "nilptr2.go" ) \ + || [file tail $test] == "nilptr2.go" \ + || [file tail $test] == "index0.go" ) \ && ! [check_effective_target_split_stack] } { # These tests fails on targets without split stack. untested $name diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 5c0a3dade2227..e307f4e69efb0 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -28,7 +28,7 @@ # If ARGS is not empty, its first element is a string that # should be added to the command line. # -# Assume by default that CONTENTS is C code. +# Assume by default that CONTENTS is C code. # Otherwise, code should contain: # "/* Assembly" for assembly code, # "// C++" for c++, @@ -39,12 +39,12 @@ # "// Go" for Go # "// Rust" for Rust # and "(* Modula-2" for Modula-2 -# If the tool is ObjC/ObjC++ then we overide the extension to .m/.mm to +# If the tool is ObjC/ObjC++ then we overide the extension to .m/.mm to # allow for ObjC/ObjC++ specific flags. proc check_compile {basename type contents args} { global tool - verbose "check_compile tool: $tool for $basename" + verbose "check_compile tool: $tool for $basename" # Save additional_sources to avoid compiling testsuite's sources # against check_compile's source. @@ -100,7 +100,7 @@ proc check_compile {basename type contents args} { global compiler_flags set save_compiler_flags $compiler_flags set lines [${tool}_target_compile $src $output $compile_type "$options"] - set compiler_flags $save_compiler_flags + set compiler_flags $save_compiler_flags file delete $src set scan_output $output @@ -280,8 +280,8 @@ proc check_configured_with { pattern } { set options [list "additional_flags=-v"] set gcc_output [${tool}_target_compile "" "" "none" $options] if { [ regexp "Configured with: \[^\n\]*$pattern" $gcc_output ] } { - verbose "Matched: $pattern" 2 - return 1 + verbose "Matched: $pattern" 2 + return 1 } verbose "Failed to match: $pattern" 2 @@ -301,19 +301,19 @@ proc check_weak_available { } { # All mips targets should support it if { [ string first "mips" $target_cpu ] >= 0 } { - return 1 + return 1 } # All AIX targets should support it if { [istarget *-*-aix*] } { - return 1 + return 1 } # All solaris2 targets should support it if { [istarget *-*-solaris2*] } { - return 1 + return 1 } # Windows targets Cygwin and MingW32 support it @@ -346,13 +346,13 @@ proc check_weak_available { } { set objformat [gcc_target_object_format] switch $objformat { - elf { return 1 } - ecoff { return 1 } - a.out { return 1 } + elf { return 1 } + ecoff { return 1 } + a.out { return 1 } mach-o { return 1 } som { return 1 } - unknown { return -1 } - default { return 0 } + unknown { return -1 } + default { return 0 } } } @@ -414,31 +414,31 @@ proc check_effective_target_vma_equals_lma { } { if [string match "" $lines] then { # No error messages - set objdump_name [find_binutils_prog objdump] - set output [remote_exec host "$objdump_name" "--section-headers --section=.data $exe"] - set output [lindex $output 1] - - remote_file build delete $exe - - # Example output of objdump: - #vma_equals_lma9059.exe: file format elf32-littlearm - # - #Sections: - #Idx Name Size VMA LMA File off Algn - # 6 .data 00000558 20000000 08002658 00020000 2**3 - # CONTENTS, ALLOC, LOAD, DATA - - # Capture LMA and VMA columns for .data section - if ![ regexp {\d*\d+\s+\.data\s+\d+\s+(\d+)\s+(\d+)} $output dummy vma lma ] { - verbose "Could not parse objdump output" 2 - return 0 - } else { - return [string equal $vma $lma] - } + set objdump_name [find_binutils_prog objdump] + set output [remote_exec host "$objdump_name" "--section-headers --section=.data $exe"] + set output [lindex $output 1] + + remote_file build delete $exe + + # Example output of objdump: + #vma_equals_lma9059.exe: file format elf32-littlearm + # + #Sections: + #Idx Name Size VMA LMA File off Algn + # 6 .data 00000558 20000000 08002658 00020000 2**3 + # CONTENTS, ALLOC, LOAD, DATA + + # Capture LMA and VMA columns for .data section + if ![ regexp {\d*\d+\s+\.data\s+\d+\s+(\d+)\s+(\d+)} $output dummy vma lma ] { + verbose "Could not parse objdump output" 2 + return 0 + } else { + return [string equal $vma $lma] + } } else { - remote_file build delete $exe - verbose "Could not determine if VMA is equal to LMA. Assuming not equal." 2 - return 0 + remote_file build delete $exe + verbose "Could not determine if VMA is equal to LMA. Assuming not equal." 2 + return 0 } }] } @@ -501,7 +501,7 @@ proc check_alias_available { } { return [check_cached_effective_target alias_available { set src alias[pid].c set obj alias[pid].o - verbose "check_alias_available compiling testfile $src" 2 + verbose "check_alias_available compiling testfile $src" 2 set f [open $src "w"] # Compile a small test program. The definition of "g" is # necessary to keep the Solaris assembler from complaining @@ -569,7 +569,7 @@ proc check_ifunc_available { } { #endif extern void f_ (); typedef void F (void); - F* g (void) { return &f_; } + F* g (void) { return &f_; } void f () __attribute__ ((ifunc ("g"))); #ifdef __cplusplus } @@ -631,7 +631,7 @@ proc check_dot_available { } { # Return 1 if according to target_info struct and explicit target list # target is supposed to support trampolines. - + proc check_effective_target_trampolines { } { if [target_info exists gcc,no_trampolines] { return 0 @@ -695,7 +695,7 @@ proc check_effective_target_signal { } { # Return 1 if according to target_info struct and explicit target list # target disables -fdelete-null-pointer-checks. Targets should return 0 # if they simply default to -fno-delete-null-pointer-checks but obey -# -fdelete-null-pointer-checks when passed explicitly (and tests that +# -fdelete-null-pointer-checks when passed explicitly (and tests that # depend on this option should do that). proc check_effective_target_keeps_null_pointer_checks { } { @@ -703,8 +703,8 @@ proc check_effective_target_keeps_null_pointer_checks { } { return 1 } if { [istarget msp430-*-*] - || [istarget avr-*-*] } { - return 1; + || [istarget avr-*-*] } { + return 1; } return 0 } @@ -716,7 +716,7 @@ proc check_effective_target_keeps_null_pointer_checks { } { # Each individual perf tries to grab it # This causes problems with parallel test suite runs. Instead # limit us to 8 pages (32K), which should be good enough -# for the small test programs. With the default settings +# for the small test programs. With the default settings # this allows parallelism of 16 and higher of parallel gcc-auto-profile proc profopt-perf-wrapper { } { global srcdir @@ -740,9 +740,9 @@ proc check_profiling_available { test_what } { if { $test_what == "-fauto-profile" } { if { !([istarget i?86-*-linux*] || [istarget x86_64-*-linux*]) } { - verbose "autofdo only supported on linux" - return 0 - } + verbose "autofdo only supported on linux" + return 0 + } # not cross compiling? if { ![isnative] } { verbose "autofdo not supported for non native builds" @@ -753,7 +753,7 @@ proc check_profiling_available { test_what } { verbose "autofdo not supported" return 0 } - global srcdir + global srcdir set status [remote_exec host "$srcdir/../config/i386/gcc-auto-profile" "-m8 true -v >/dev/null"] if { [lindex $status 0] != 0 } { verbose "autofdo not supported because perf does not work" @@ -763,9 +763,9 @@ proc check_profiling_available { test_what } { # no good way to check this in advance -- check later instead. #set status [remote_exec host "create_gcov" "2>/dev/null"] #if { [lindex $status 0] != 255 } { - # verbose "autofdo not supported due to missing create_gcov" - # return 0 - #} + # verbose "autofdo not supported due to missing create_gcov" + # return 0 + #} } # Support for -p on solaris2 relies on mcrt1.o which comes with the @@ -831,7 +831,7 @@ proc check_profiling_available { test_what } { || [istarget powerpc-*-eabi*] || [istarget powerpc-*-elf] || [istarget pru-*-*] - || [istarget rx-*-*] + || [istarget rx-*-*] || [istarget tic6x-*-elf] || [istarget visium-*-*] || [istarget xstormy16-*] @@ -847,7 +847,7 @@ proc check_profiling_available { test_what } { # -pg link test result can't be cached since it may change between # runs. if { $profiling_working == 1 - && ![check_no_compiler_messages_nocache profiling executable { + && ![check_no_compiler_messages_nocache profiling executable { int main() { return 0; } } "-pg"] } { set profiling_working 0 } @@ -1020,7 +1020,7 @@ proc check_effective_target_tls_native {} { if { [istarget *-*-vxworks*] } { return 0 } - + return [check_no_messages_and_pattern tls_native "!emutls" assembly { __thread int i; int f (void) { return i; } @@ -1036,7 +1036,7 @@ proc check_effective_target_tls_emulated {} { if { [istarget *-*-vxworks*] } { return 1 } - + return [check_no_messages_and_pattern tls_emulated "emutls" assembly { __thread int i; int f (void) { return i; } @@ -1066,8 +1066,8 @@ proc check_effective_target_cas_char {} { proc check_effective_target_cas_int {} { return [check_no_compiler_messages cas_int assembly { #if __INT_MAX__ == 0x7fff && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 - /* ok */ - #elif __INT_MAX__ == 0x7fffffff && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 + /* ok */ + #elif __INT_MAX__ == 0x7fffffff && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 /* ok */ #else #error unsupported @@ -1082,7 +1082,7 @@ proc check_effective_target_function_sections {} { if { [istarget *-*-darwin*] } { return 0 } - + return [check_no_compiler_messages functionsections assembly { void foo (void) { } } "-ffunction-sections"] @@ -1100,11 +1100,11 @@ proc check_effective_target_scheduling {} { proc check_effective_target_trapping {} { return [check_no_compiler_messages trapping object { - int add (int a, int b) { return a + b; } + int add (int a, int b) { return a + b; } } "-ftrapv"] } -# Return 1 if compilation with -fgraphite is error-free for trivial +# Return 1 if compilation with -fgraphite is error-free for trivial # code, 0 otherwise. proc check_effective_target_fgraphite {} { @@ -1210,7 +1210,7 @@ proc check_effective_target_posix_memalign {} { proc check_effective_target_setrlimit {} { # Darwin has non-posix compliant RLIMIT_AS if { [istarget *-*-darwin*] } { - return 0 + return 0 } return [check_function_available "setrlimit"] } @@ -1476,9 +1476,9 @@ proc check_effective_target_hard_float { } { # hard float for single precision only. if { [istarget csky*-*-*] } { return [check_no_compiler_messages hard_float assembly { - #if defined __csky_soft_float__ - #error __csky_soft_float__ - #endif + #if defined __csky_soft_float__ + #error __csky_soft_float__ + #endif }] } @@ -1737,7 +1737,7 @@ proc check_effective_target_fortran_real_10 { } { # 0 otherwise. This differs from check_effective_target_fortran_real_16 # because _Float128 has the additional requirement that it be the # 128-bit IEEE encoding; even if _Float128 is available in C, it may not -# have a corresponding Fortran kind on targets (PowerPC) that use some +# have a corresponding Fortran kind on targets (PowerPC) that use some # other encoding for long double/TFmode/real(16). proc check_effective_target_fortran_real_c_float128 { } { return [check_no_compiler_messages fortran_real_c_float128 executable { @@ -1774,10 +1774,10 @@ proc check_effective_target_fortran_ieee { flags } { proc check_effective_target_fortran_largest_fp_has_sqrt { } { return [check_no_compiler_messages fortran_largest_fp_has_sqrt executable { ! Fortran - use iso_fortran_env, only: real_kinds - integer,parameter:: maxFP = real_kinds(ubound(real_kinds,dim=1)) + use iso_fortran_env, only: real_kinds + integer,parameter:: maxFP = real_kinds(ubound(real_kinds,dim=1)) real(kind=maxFP), volatile :: x - x = 2.0_maxFP + x = 2.0_maxFP x = sqrt (x) end }] @@ -1804,9 +1804,9 @@ proc check_effective_target_fortran_large_int { } { proc check_effective_target_fortran_integer_16 { } { return [check_no_compiler_messages fortran_integer_16 executable { - ! Fortran - integer(16) :: i - end + ! Fortran + integer(16) :: i + end }] } @@ -1889,6 +1889,28 @@ proc check_effective_target_riscv_a { } { }] } +# Return 1 if the target arch supports the atomic LRSC extension, 0 otherwise. +# Cache the result. + +proc check_effective_target_riscv_zalrsc { } { + return [check_no_compiler_messages riscv_ext_zalrsc assembly { + #ifndef __riscv_zalrsc + #error "Not __riscv_zalrsc" + #endif + }] +} + +# Return 1 if the target arch supports the atomic AMO extension, 0 otherwise. +# Cache the result. + +proc check_effective_target_riscv_zaamo { } { + return [check_no_compiler_messages riscv_ext_zaamo assembly { + #ifndef __riscv_zaamo + #error "Not __riscv_zaamo" + #endif + }] +} + # Return 1 if the target arch supports the double precision floating point # extension, 0 otherwise. Cache the result. @@ -2010,7 +2032,7 @@ proc check_effective_target_riscv_v_ok { } { proc check_effective_target_riscv_zfh_ok { } { # If the target already supports zfh without any added options, # we may assume we can execute just fine. - # ??? Other cases we should consider: + # ??? Other cases we should consider: # - target / simulator already supports zfh extension - test for that. # - target is a simulator, and dg-add-options knows how to enable zfh support in that simulator if { [check_effective_target_riscv_zfh] } { @@ -2107,7 +2129,7 @@ proc check_effective_target_riscv_v_misalign_ok { } { proc riscv_get_arch { } { set gcc_march "" # ??? do we neeed to add more extensions to the list below? - foreach ext { i m a f d q c v zicsr zifencei zfh zba zbb zbc zbs zvbb zvfh ztso } { + foreach ext { i m a f d q c v zicsr zifencei zfh zba zbb zbc zbs zvbb zvfh ztso zaamo zalrsc } { if { [check_no_compiler_messages riscv_ext_$ext assembly [string map [list DEF __riscv_$ext] { #ifndef DEF #error "Not DEF" @@ -2166,6 +2188,30 @@ proc add_options_for_riscv_v { flags } { return "$flags -march=[regsub {[[:alnum:]]*} [riscv_get_arch] &v]" } +proc add_options_for_riscv_zaamo { flags } { + if { [lsearch $flags -march=*] >= 0 } { + # If there are multiple -march flags, we have to adjust all of them. + set flags [regsub -all -- {(?:^|[[:space:]])-march=[[:alnum:]_.]*} $flags &_zaamo ] + return [regsub -all -- {((?:^|[[:space:]])-march=[[:alnum:]_.]*_zaamo[[:alnum:]_.]*)_zaamo} $flags \\1 ] + } + if { [check_effective_target_riscv_zaamo] } { + return "$flags" + } + return "$flags -march=[riscv_get_arch]_zaamo" +} + +proc add_options_for_riscv_zalrsc { flags } { + if { [lsearch $flags -march=*] >= 0 } { + # If there are multiple -march flags, we have to adjust all of them. + set flags [regsub -all -- {(?:^|[[:space:]])-march=[[:alnum:]_.]*} $flags &_zalrsc ] + return [regsub -all -- {((?:^|[[:space:]])-march=[[:alnum:]_.]*_zalrsc[[:alnum:]_.]*)_zalrsc} $flags \\1 ] + } + if { [check_effective_target_riscv_zalrsc] } { + return "$flags" + } + return "$flags -march=[riscv_get_arch]_zalrsc" +} + proc add_options_for_riscv_zfh { flags } { if { [lsearch $flags -march=*] >= 0 } { # If there are multiple -march flags, we have to adjust all of them. @@ -2506,7 +2552,7 @@ proc check_effective_target_avx512f_runtime { } { # Return 1 if bmi2 instructions can be compiled. proc check_effective_target_bmi2 { } { if { !([istarget i?86-*-*] || [istarget x86_64-*-*]) } { - return 0 + return 0 } return [check_no_compiler_messages bmi2 object { unsigned int @@ -2658,7 +2704,7 @@ proc check_ppc_cpu_supports_hw_available { } { asm volatile ("xxlor vs0,vs0,vs0"); #else asm volatile ("xxlor 0,0,0"); - #endif + #endif if (!__builtin_cpu_supports ("vsx")) return 1; return 0; @@ -2711,7 +2757,7 @@ proc check_p8vector_hw_available { } { asm volatile ("xxlorc vs0,vs0,vs0"); #else asm volatile ("xxlorc 0,0,0"); - #endif + #endif return 0; } } $options @@ -2969,7 +3015,7 @@ proc check_effective_target_long_double_ieee128 { } { int main() { _Float128 a2; - long double b2; + long double b2; if (sizeof (long double) != 16) return 1; b = one + two; @@ -3012,7 +3058,7 @@ proc check_vsx_hw_available { } { asm volatile ("xxlor vs0,vs0,vs0"); #else asm volatile ("xxlor 0,0,0"); - #endif + #endif return 0; } } $options @@ -3045,7 +3091,7 @@ proc check_vmx_hw_available { } { asm volatile ("vor v0,v0,v0"); #else asm volatile ("vor 0,0,0"); - #endif + #endif return 0; } } $options @@ -3099,11 +3145,11 @@ proc check_effective_target_cell_hw { } { { #ifdef __MACH__ asm volatile ("vor v0,v0,v0"); - asm volatile ("lvlx v0,r0,r0"); + asm volatile ("lvlx v0,r0,r0"); #else asm volatile ("vor 0,0,0"); - asm volatile ("lvlx 0,0,0"); - #endif + asm volatile ("lvlx 0,0,0"); + #endif return 0; } } $options @@ -3431,9 +3477,9 @@ proc check_effective_target_ptr32plus { } { # in a 32-bit slot when in memory, so sizeof(void *) returns 4, but it # cannot really hold a 32-bit address, so we always return false here. if { [istarget msp430-*-*] } { - return 0 + return 0 } - + return [check_no_compiler_messages ptr32plus object { int dummy[sizeof (void *) >= 4 ? 1 : -1]; }] @@ -3639,7 +3685,7 @@ proc check_effective_target_double64plus { } { proc check_effective_target_has_w_floating_suffix { } { set opts "" if [check_effective_target_c++] { - append opts "-std=gnu++03" + append opts "-std=gnu++03" } return [check_no_compiler_messages w_fp_suffix object { float dummy = 1.0w; @@ -3652,7 +3698,7 @@ proc check_effective_target_has_w_floating_suffix { } { proc check_effective_target_has_q_floating_suffix { } { set opts "" if [check_effective_target_c++] { - append opts "-std=gnu++03" + append opts "-std=gnu++03" } return [check_no_compiler_messages q_fp_suffix object { float dummy = 1.0q; @@ -3664,43 +3710,43 @@ proc check_effective_target_has_q_floating_suffix { } { proc check_effective_target_float16 {} { return [check_no_compiler_messages_nocache float16 object { - _Float16 foo (_Float16 x) { return x; } + _Float16 foo (_Float16 x) { return x; } } [add_options_for_float16 ""]] } proc check_effective_target_float32 {} { return [check_no_compiler_messages_nocache float32 object { - _Float32 x; + _Float32 x; } [add_options_for_float32 ""]] } proc check_effective_target_float64 {} { return [check_no_compiler_messages_nocache float64 object { - _Float64 x; + _Float64 x; } [add_options_for_float64 ""]] } proc check_effective_target_float128 {} { return [check_no_compiler_messages_nocache float128 object { - _Float128 x; + _Float128 x; } [add_options_for_float128 ""]] } proc check_effective_target_float32x {} { return [check_no_compiler_messages_nocache float32x object { - _Float32x x; + _Float32x x; } [add_options_for_float32x ""]] } proc check_effective_target_float64x {} { return [check_no_compiler_messages_nocache float64x object { - _Float64x x; + _Float64x x; } [add_options_for_float64x ""]] } proc check_effective_target_float128x {} { return [check_no_compiler_messages_nocache float128x object { - _Float128x x; + _Float128x x; } [add_options_for_float128x ""]] } @@ -3864,7 +3910,7 @@ proc check_effective_target_scalar_all_fma { } { proc check_effective_target_fixed_point { } { return [check_no_compiler_messages fixed_point object { - _Sat _Fract x; _Sat _Accum y; + _Sat _Fract x; _Sat _Accum y; }] } @@ -3899,8 +3945,8 @@ proc check_effective_target_bitint575 { } { proc check_effective_target_bitint65535 { } { return [check_no_compiler_messages bitint65535 object { - _BitInt (2) a = 1wb; - unsigned _BitInt (65535) b = 0uwb; + _BitInt (2) a = 1wb; + unsigned _BitInt (65535) b = 0uwb; } "-std=c23"] } @@ -4064,8 +4110,8 @@ proc check_effective_target_vect_cmdline_needed { } { proc check_effective_target_vect_int { } { return [check_cached_effective_target_indexed vect_int { expr { - [istarget i?86-*-*] || [istarget x86_64-*-*] - || [istarget powerpc*-*-*] + [istarget i?86-*-*] || [istarget x86_64-*-*] + || [istarget powerpc*-*-*] || [istarget amdgcn-*-*] || [istarget sparc*-*-*] || [istarget alpha*-*-*] @@ -4323,7 +4369,7 @@ proc check_effective_target_int128 { } { }] } -# Return 1 if the target supports unsigned int->float conversion +# Return 1 if the target supports unsigned int->float conversion # proc check_effective_target_vect_uintfloat_cvt { } { @@ -4378,7 +4424,7 @@ proc check_effective_target_vect_floatuint_cvt { } { || ([istarget riscv*-*-*] && [check_effective_target_riscv_v]) || ([istarget loongarch*-*-*] - && [check_effective_target_loongarch_sx]) }}] + && [check_effective_target_loongarch_sx]) }}] } # Return 1 if the target supports vector integer char -> long long extend optab @@ -4388,7 +4434,7 @@ proc check_effective_target_vect_ext_char_longlong { } { return [check_cached_effective_target_indexed vect_ext_char_longlong { expr { ([istarget riscv*-*-*] && [check_effective_target_riscv_v]) - || ([istarget loongarch*-*-*] + || ([istarget loongarch*-*-*] && [check_effective_target_loongarch_sx]) }}] } @@ -4434,9 +4480,9 @@ proc check_effective_target_aarch64_little_endian { } { } return [check_no_compiler_messages aarch64_little_endian assembly { - #if !defined(__aarch64__) || defined(__AARCH64EB__) - #error FOO - #endif + #if !defined(__aarch64__) || defined(__AARCH64EB__) + #error FOO + #endif }] } @@ -4568,7 +4614,7 @@ proc check_effective_target_arm_vect_no_misalign { } { return [check_no_compiler_messages arm_vect_no_misalign assembly { #if !defined(__arm__) \ || (defined(__ARM_FEATURE_UNALIGNED) \ - && defined(__ARMEL__)) + && defined(__ARMEL__)) #error !__arm__ || (__ARMEL__ && __ARM_FEATURE_UNALIGNED) #endif }] @@ -4806,7 +4852,7 @@ proc check_effective_target_arm_crypto_ok_nocache { } { uint8x16_t foo (uint8x16_t a, uint8x16_t b) { - return vaeseq_u8 (a, b); + return vaeseq_u8 (a, b); } } "$flags"] } { set et_arm_crypto_flags $flags @@ -4828,7 +4874,7 @@ proc check_effective_target_arm_crypto_ok { } { # Add options for crypto extensions. proc add_options_for_arm_crypto { flags } { if { ! [check_effective_target_arm_crypto_ok] } { - return "$flags" + return "$flags" } global et_arm_crypto_flags return "$flags $et_arm_crypto_flags" @@ -4849,14 +4895,14 @@ proc add_options_for_arm_neon { flags } { proc add_options_for_arm_v8_vfp { flags } { if { ! [check_effective_target_arm_v8_vfp_ok] } { - return "$flags" + return "$flags" } return "$flags -mfpu=fp-armv8 -mfloat-abi=softfp" } proc add_options_for_arm_v8_neon { flags } { if { ! [check_effective_target_arm_v8_neon_ok] } { - return "$flags" + return "$flags" } global et_arm_v8_neon_flags return "$flags $et_arm_v8_neon_flags -march=armv8-a" @@ -4897,7 +4943,7 @@ proc add_options_for_arm_v8_2a_fp16_neon { flags } { proc add_options_for_arm_crc { flags } { if { ! [check_effective_target_arm_crc_ok] } { - return "$flags" + return "$flags" } global et_arm_crc_flags return "$flags $et_arm_crc_flags" @@ -4919,7 +4965,7 @@ proc add_options_for_arm_neonv2 { flags } { # Add the options needed for vfp3. proc add_options_for_arm_vfp3 { flags } { if { ! [check_effective_target_arm_vfp3_ok] } { - return "$flags" + return "$flags" } return "$flags -mfpu=vfp3 -mfloat-abi=softfp" } @@ -5147,7 +5193,7 @@ proc check_effective_target_arm_neon_fp16_ok_nocache { } { float16x4_t foo (float32x4_t arg) { - return vcvt_f16_f32 (arg); + return vcvt_f16_f32 (arg); } } "$et_arm_neon_flags $flags"] } { set et_arm_neon_fp16_flags [concat $et_arm_neon_flags $flags] @@ -5182,7 +5228,7 @@ proc check_effective_target_arm_neon_softfp_fp16_ok_nocache { } { float16x4_t foo (float32x4_t arg) { - return vcvt_f16_f32 (arg); + return vcvt_f16_f32 (arg); } } "$et_arm_neon_flags $flags"] } { set et_arm_neon_softfp_fp16_flags [concat $et_arm_neon_flags $flags] @@ -5234,7 +5280,7 @@ proc add_options_for_arm_neon_softfp_fp16 { flags } { proc add_options_for_aarch64_sve { flags } { if { ![istarget aarch64*-*-*] || [check_effective_target_aarch64_sve] } { - return "$flags" + return "$flags" } return "$flags -march=armv8.2-a+sve" } @@ -5320,7 +5366,7 @@ proc check_effective_target_arm_v8_neon_ok_nocache { } { void foo () { - __asm__ volatile ("vrintn.f32 q0, q0"); + __asm__ volatile ("vrintn.f32 q0, q0"); } } "$flags -march=armv8-a"] } { set et_arm_v8_neon_flags $flags @@ -5351,11 +5397,11 @@ proc check_effective_target_arm_neonv2_ok_nocache { } { foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-vfpv4" "-mfpu=neon-vfpv4 -mfloat-abi=softfp"} { if { [check_no_compiler_messages_nocache arm_neonv2_ok object { #include "arm_neon.h" - float32x2_t + float32x2_t foo (float32x2_t a, float32x2_t b, float32x2_t c) - { - return vfma_f32 (a, b, c); - } + { + return vfma_f32 (a, b, c); + } } "$et_arm_neon_flags $flags"] } { set et_arm_neonv2_flags [concat $et_arm_neon_flags $flags] return 1 @@ -5433,7 +5479,7 @@ proc check_effective_target_arm_fp16_ok_nocache { } { return 1; } if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "" } ]] { - # The existing -mfpu value is OK; use it, but add softfp. + # The existing -mfpu value is OK; use it, but add softfp. set et_arm_fp16_flags "-mfloat-abi=softfp" return 1; } @@ -5548,7 +5594,7 @@ foreach { armfunc armflag armdefs } { return "$flags FLAG" } - proc check_effective_target_arm_arch_FUNC_link { } { + proc check_effective_target_arm_arch_FUNC_link { } { return [check_no_compiler_messages arm_arch_FUNC_link executable { #include int dummy; @@ -5564,7 +5610,7 @@ foreach { armfunc armflag armdefs } { return 0; } } [add_options_for_arm_arch_FUNC ""]] - } + } }] } @@ -6137,22 +6183,22 @@ proc check_effective_target_arm_v8_2a_dotprod_neon_ok_nocache { } { set et_arm_v8_2a_dotprod_neon_flags "" if { ![istarget arm*-*-*] && ![istarget aarch64*-*-*] } { - return 0; + return 0; } # Iterate through sets of options to find the compiler flags that # need to be added to the -march option. foreach flags {"" "-mfloat-abi=softfp -mfpu=neon-fp-armv8" "-mfloat-abi=hard -mfpu=neon-fp-armv8"} { - if { [check_no_compiler_messages_nocache \ - arm_v8_2a_dotprod_neon_ok object { + if { [check_no_compiler_messages_nocache \ + arm_v8_2a_dotprod_neon_ok object { #include - #if !defined (__ARM_FEATURE_DOTPROD) - #error "__ARM_FEATURE_DOTPROD not defined" - #endif - } "$flags -march=armv8.2-a+dotprod"] } { - set et_arm_v8_2a_dotprod_neon_flags "$flags -march=armv8.2-a+dotprod" - return 1 - } + #if !defined (__ARM_FEATURE_DOTPROD) + #error "__ARM_FEATURE_DOTPROD not defined" + #endif + } "$flags -march=armv8.2-a+dotprod"] } { + set et_arm_v8_2a_dotprod_neon_flags "$flags -march=armv8.2-a+dotprod" + return 1 + } } return 0; @@ -6167,25 +6213,25 @@ proc check_effective_target_arm_v8_1m_mve_ok_nocache { } { set et_arm_v8_1m_mve_flags "" if { ![istarget arm*-*-*] } { - return 0; + return 0; } # Iterate through sets of options to find the compiler flags that # need to be added to the -march option. foreach flags {"" "-mfloat-abi=softfp -mfpu=auto -march=armv8.1-m.main+mve" "-mfloat-abi=hard -mfpu=auto -march=armv8.1-m.main+mve"} { - if { [check_no_compiler_messages_nocache \ - arm_v8_1m_mve_ok object { - #if !defined (__ARM_FEATURE_MVE) - #error "__ARM_FEATURE_MVE not defined" - #endif + if { [check_no_compiler_messages_nocache \ + arm_v8_1m_mve_ok object { + #if !defined (__ARM_FEATURE_MVE) + #error "__ARM_FEATURE_MVE not defined" + #endif #if __ARM_BIG_ENDIAN #error "MVE intrinsics are not supported in Big-Endian mode." #endif #include - } "$flags -mthumb"] } { - set et_arm_v8_1m_mve_flags "$flags -mthumb --save-temps" - return 1 - } + } "$flags -mthumb"] } { + set et_arm_v8_1m_mve_flags "$flags -mthumb --save-temps" + return 1 + } } return 0; @@ -6193,12 +6239,12 @@ proc check_effective_target_arm_v8_1m_mve_ok_nocache { } { proc check_effective_target_arm_v8_1m_mve_ok { } { return [check_cached_effective_target arm_v8_1m_mve_ok \ - check_effective_target_arm_v8_1m_mve_ok_nocache] + check_effective_target_arm_v8_1m_mve_ok_nocache] } proc add_options_for_arm_v8_1m_mve { flags } { if { ! [check_effective_target_arm_v8_1m_mve_ok] } { - return "$flags" + return "$flags" } global et_arm_v8_1m_mve_flags return "$flags $et_arm_v8_1m_mve_flags" @@ -6206,12 +6252,12 @@ proc add_options_for_arm_v8_1m_mve { flags } { proc check_effective_target_arm_v8_2a_dotprod_neon_ok { } { return [check_cached_effective_target arm_v8_2a_dotprod_neon_ok \ - check_effective_target_arm_v8_2a_dotprod_neon_ok_nocache] + check_effective_target_arm_v8_2a_dotprod_neon_ok_nocache] } proc add_options_for_arm_v8_2a_dotprod_neon { flags } { if { ! [check_effective_target_arm_v8_2a_dotprod_neon_ok] } { - return "$flags" + return "$flags" } global et_arm_v8_2a_dotprod_neon_flags return "$flags $et_arm_v8_2a_dotprod_neon_flags" @@ -6226,22 +6272,22 @@ proc check_effective_target_arm_v8_2a_i8mm_ok_nocache { } { set et_arm_v8_2a_i8mm_flags "" if { ![istarget arm*-*-*] && ![istarget aarch64*-*-*] } { - return 0; + return 0; } # Iterate through sets of options to find the compiler flags that # need to be added to the -march option. foreach flags {"" "-mfloat-abi=softfp -mfpu=neon-fp-armv8" "-mfloat-abi=hard -mfpu=neon-fp-armv8" } { - if { [check_no_compiler_messages_nocache \ - arm_v8_2a_i8mm_ok object { - #include - #if !defined (__ARM_FEATURE_MATMUL_INT8) - #error "__ARM_FEATURE_MATMUL_INT8 not defined" - #endif - } "$flags -march=armv8.2-a+i8mm"] } { - set et_arm_v8_2a_i8mm_flags "$flags -march=armv8.2-a+i8mm" - return 1 - } + if { [check_no_compiler_messages_nocache \ + arm_v8_2a_i8mm_ok object { + #include + #if !defined (__ARM_FEATURE_MATMUL_INT8) + #error "__ARM_FEATURE_MATMUL_INT8 not defined" + #endif + } "$flags -march=armv8.2-a+i8mm"] } { + set et_arm_v8_2a_i8mm_flags "$flags -march=armv8.2-a+i8mm" + return 1 + } } return 0; @@ -6249,12 +6295,12 @@ proc check_effective_target_arm_v8_2a_i8mm_ok_nocache { } { proc check_effective_target_arm_v8_2a_i8mm_ok { } { return [check_cached_effective_target arm_v8_2a_i8mm_ok \ - check_effective_target_arm_v8_2a_i8mm_ok_nocache] + check_effective_target_arm_v8_2a_i8mm_ok_nocache] } proc add_options_for_arm_v8_2a_i8mm { flags } { if { ! [check_effective_target_arm_v8_2a_i8mm_ok] } { - return "$flags" + return "$flags" } global et_arm_v8_2a_i8mm_flags return "$flags $et_arm_v8_2a_i8mm_flags" @@ -6269,24 +6315,24 @@ proc check_effective_target_arm_fp16fml_neon_ok_nocache { } { set et_arm_fp16fml_neon_flags "" if { ![istarget arm*-*-*] } { - return 0; + return 0; } # Iterate through sets of options to find the compiler flags that # need to be added to the -march option. foreach flags {"" "-mfloat-abi=softfp -mfpu=neon-fp-armv8" "-mfloat-abi=hard -mfpu=neon-fp-armv8"} { - if { [check_no_compiler_messages_nocache \ - arm_fp16fml_neon_ok assembly { + if { [check_no_compiler_messages_nocache \ + arm_fp16fml_neon_ok assembly { #include float32x2_t foo (float32x2_t r, float16x4_t a, float16x4_t b) { return vfmlal_high_f16 (r, a, b); } - } "$flags -march=armv8.2-a+fp16fml"] } { - set et_arm_fp16fml_neon_flags "$flags -march=armv8.2-a+fp16fml" - return 1 - } + } "$flags -march=armv8.2-a+fp16fml"] } { + set et_arm_fp16fml_neon_flags "$flags -march=armv8.2-a+fp16fml" + return 1 + } } return 0; @@ -6294,12 +6340,12 @@ proc check_effective_target_arm_fp16fml_neon_ok_nocache { } { proc check_effective_target_arm_fp16fml_neon_ok { } { return [check_cached_effective_target arm_fp16fml_neon_ok \ - check_effective_target_arm_fp16fml_neon_ok_nocache] + check_effective_target_arm_fp16fml_neon_ok_nocache] } proc add_options_for_arm_fp16fml_neon { flags } { if { ! [check_effective_target_arm_fp16fml_neon_ok] } { - return "$flags" + return "$flags" } global et_arm_fp16fml_neon_flags return "$flags $et_arm_fp16fml_neon_flags" @@ -6313,19 +6359,19 @@ proc check_effective_target_arm_v8_2a_bf16_neon_ok_nocache { } { set et_arm_v8_2a_bf16_neon_flags "" if { ![istarget arm*-*-*] && ![istarget aarch64*-*-*] } { - return 0; + return 0; } foreach flags {"" "-mfloat-abi=softfp -mfpu=neon-fp-armv8" "-mfloat-abi=hard -mfpu=neon-fp-armv8" } { - if { [check_no_compiler_messages_nocache arm_v8_2a_bf16_neon_ok object { - #include - #if !defined (__ARM_FEATURE_BF16_VECTOR_ARITHMETIC) - #error "__ARM_FEATURE_BF16_VECTOR_ARITHMETIC not defined" - #endif - } "$flags -march=armv8.2-a+bf16"] } { - set et_arm_v8_2a_bf16_neon_flags "$flags -march=armv8.2-a+bf16" - return 1 - } + if { [check_no_compiler_messages_nocache arm_v8_2a_bf16_neon_ok object { + #include + #if !defined (__ARM_FEATURE_BF16_VECTOR_ARITHMETIC) + #error "__ARM_FEATURE_BF16_VECTOR_ARITHMETIC not defined" + #endif + } "$flags -march=armv8.2-a+bf16"] } { + set et_arm_v8_2a_bf16_neon_flags "$flags -march=armv8.2-a+bf16" + return 1 + } } return 0; @@ -6333,12 +6379,12 @@ proc check_effective_target_arm_v8_2a_bf16_neon_ok_nocache { } { proc check_effective_target_arm_v8_2a_bf16_neon_ok { } { return [check_cached_effective_target arm_v8_2a_bf16_neon_ok \ - check_effective_target_arm_v8_2a_bf16_neon_ok_nocache] + check_effective_target_arm_v8_2a_bf16_neon_ok_nocache] } proc add_options_for_arm_v8_2a_bf16_neon { flags } { if { ! [check_effective_target_arm_v8_2a_bf16_neon_ok] } { - return "$flags" + return "$flags" } global et_arm_v8_2a_bf16_neon_flags return "$flags $et_arm_v8_2a_bf16_neon_flags" @@ -6411,7 +6457,7 @@ foreach { armfunc armflag armdef arminc } { return "$flags $et_FUNC_flags" } - proc check_effective_target_FUNC_link { } { + proc check_effective_target_FUNC_link { } { if { ! [check_effective_target_FUNC_ok] } { return 0; } @@ -6445,7 +6491,7 @@ foreach { armfunc armflag armdef arminc } { return 0; } } [add_options_for_FUNC ""]] - } + } }] } @@ -6454,7 +6500,7 @@ foreach { armfunc armflag armdef arminc } { proc check_effective_target_arm_v8_neon_hw { } { return [check_runtime arm_v8_neon_hw_available { - #include "arm_neon.h" + #include "arm_neon.h" int main (void) { @@ -6592,33 +6638,33 @@ proc check_effective_target_arm_v8_2a_fp16_neon_hw { } { proc check_effective_target_arm_v8_2a_dotprod_neon_hw { } { if { ![check_effective_target_arm_v8_2a_dotprod_neon_ok] } { - return 0; + return 0; } return [check_runtime arm_v8_2a_dotprod_neon_hw_available { - #include "arm_neon.h" - int - main (void) - { + #include "arm_neon.h" + int + main (void) + { uint32x2_t results = {0,0}; uint8x8_t a = {1,1,1,1,2,2,2,2}; uint8x8_t b = {2,2,2,2,3,3,3,3}; - #ifdef __ARM_ARCH_ISA_A64 - asm ("udot %0.2s, %1.8b, %2.8b" - : "=w"(results) - : "w"(a), "w"(b) - : /* No clobbers. */); + #ifdef __ARM_ARCH_ISA_A64 + asm ("udot %0.2s, %1.8b, %2.8b" + : "=w"(results) + : "w"(a), "w"(b) + : /* No clobbers. */); #else - asm ("vudot.u8 %P0, %P1, %P2" - : "=w"(results) - : "w"(a), "w"(b) - : /* No clobbers. */); - #endif - - return (results[0] == 8 && results[1] == 24) ? 1 : 0; - } + asm ("vudot.u8 %P0, %P1, %P2" + : "=w"(results) + : "w"(a), "w"(b) + : /* No clobbers. */); + #endif + + return (results[0] == 8 && results[1] == 24) ? 1 : 0; + } } [add_options_for_arm_v8_2a_dotprod_neon ""]] } @@ -6628,34 +6674,34 @@ proc check_effective_target_arm_v8_2a_dotprod_neon_hw { } { proc check_effective_target_arm_v8_2a_i8mm_neon_hw { } { if { ![check_effective_target_arm_v8_2a_i8mm_ok] } { - return 0; + return 0; } return [check_runtime arm_v8_2a_i8mm_neon_hw_available { - #include "arm_neon.h" - int - main (void) - { + #include "arm_neon.h" + int + main (void) + { uint32x2_t results = {0,0}; uint8x8_t a = {1,1,1,1,2,2,2,2}; int8x8_t b = {2,2,2,2,3,3,3,3}; - #ifdef __ARM_ARCH_ISA_A64 - asm ("usdot %0.2s, %1.8b, %2.8b" - : "=w"(results) - : "w"(a), "w"(b) - : /* No clobbers. */); + #ifdef __ARM_ARCH_ISA_A64 + asm ("usdot %0.2s, %1.8b, %2.8b" + : "=w"(results) + : "w"(a), "w"(b) + : /* No clobbers. */); #else - asm ("vusdot.u8 %P0, %P1, %P2" - : "=w"(results) - : "w"(a), "w"(b) - : /* No clobbers. */); - #endif + asm ("vusdot.u8 %P0, %P1, %P2" + : "=w"(results) + : "w"(a), "w"(b) + : /* No clobbers. */); + #endif - return (vget_lane_u32 (results, 0) == 8 + return (vget_lane_u32 (results, 0) == 8 && vget_lane_u32 (results, 1) == 24) ? 1 : 0; - } + } } [add_options_for_arm_v8_2a_i8mm ""]] } @@ -6683,7 +6729,7 @@ proc check_effective_target_arm_neonv2 { } { #else #ifndef __ARM_FEATURE_FMA #error not NEONv2 - #else + #else int dummy; #endif #endif @@ -6854,7 +6900,7 @@ proc check_effective_target_arm_prefer_ldrd_strd { } { } return [check_no_messages_and_pattern arm_prefer_ldrd_strd "strd\tr" assembly { - void foo (void) { __asm__ ("" ::: "r4", "r5"); } + void foo (void) { __asm__ ("" ::: "r4", "r5"); } } "-O2 -mthumb" ] } @@ -6867,13 +6913,13 @@ proc check_effective_target_arm_ldrd_strd_ok { } { return [check_no_compiler_messages arm_ldrd_strd_ok object { int main(void) { - __UINT64_TYPE__ a = 1, b = 10; - __UINT64_TYPE__ *c = &b; - // `a` will be in a valid register since it's a DImode quantity. - asm ("ldrd %0, %1" - : "=r" (a) - : "m" (c)); - return a == 10; + __UINT64_TYPE__ a = 1, b = 10; + __UINT64_TYPE__ *c = &b; + // `a` will be in a valid register since it's a DImode quantity. + asm ("ldrd %0, %1" + : "=r" (a) + : "m" (c)); + return a == 10; } }] } @@ -7447,7 +7493,7 @@ proc check_effective_target_vect_bool_cmp { } { proc check_effective_target_vect_char_add { } { return [check_cached_effective_target_indexed vect_char_add { expr { - [istarget i?86-*-*] || [istarget x86_64-*-*] + [istarget i?86-*-*] || [istarget x86_64-*-*] || [istarget powerpc*-*-*] || [istarget amdgcn-*-*] || [istarget ia64-*-*] @@ -7550,8 +7596,8 @@ proc check_effective_target_vect_float_strict { } { proc check_effective_target_vect_double { } { return [check_cached_effective_target_indexed vect_double { - expr { (([istarget i?86-*-*] || [istarget x86_64-*-*]) - && [check_no_compiler_messages vect_double assembly { + expr { (([istarget i?86-*-*] || [istarget x86_64-*-*]) + && [check_no_compiler_messages vect_double assembly { #ifdef __tune_atom__ # error No double vectorizer support. #endif @@ -7774,7 +7820,7 @@ proc check_effective_target_vect_perm_short { } { && [is-effective-target aarch64_little_endian]) || [istarget powerpc*-*-*] || (([istarget i?86-*-*] || [istarget x86_64-*-*]) - && [check_ssse3_available]) + && [check_ssse3_available]) || ([istarget mips*-*-*] && [et-is-effective-target mips_msa]) || ([istarget s390*-*-*] @@ -7836,10 +7882,10 @@ proc check_effective_target_ifn_copysign { } { proc check_effective_target_vect_widen_sum_hi_to_si_pattern { } { return [check_cached_effective_target_indexed vect_widen_sum_hi_to_si_pattern { expr { [istarget powerpc*-*-*] - || ([istarget aarch64*-*-*] + || ([istarget aarch64*-*-*] && ![check_effective_target_aarch64_sve]) || [is-effective-target arm_neon] - || [istarget ia64-*-*] }}] + || [istarget ia64-*-*] }}] } # Return 1 if the target plus current options supports a vector @@ -7852,7 +7898,7 @@ proc check_effective_target_vect_widen_sum_hi_to_si_pattern { } { proc check_effective_target_vect_widen_sum_hi_to_si { } { return [check_cached_effective_target_indexed vect_widen_sum_hi_to_si { expr { [check_effective_target_vect_unpack] - || [istarget powerpc*-*-*] + || [istarget powerpc*-*-*] || [istarget ia64-*-*] || [istarget loongarch*-*-*] || [istarget riscv*-*-*] }}] @@ -7864,7 +7910,7 @@ proc check_effective_target_vect_widen_sum_hi_to_si { } { # promotion (unpacking) from chars to shorts. # # This won't change for different subtargets so cache the result. - + proc check_effective_target_vect_widen_sum_qi_to_hi { } { return [check_cached_effective_target_indexed vect_widen_sum_qi_to_hi { expr { [check_effective_target_vect_unpack] @@ -7878,7 +7924,7 @@ proc check_effective_target_vect_widen_sum_qi_to_hi { } { # widening summation of *char* args into *int* result, 0 otherwise. # # This won't change for different subtargets so cache the result. - + proc check_effective_target_vect_widen_sum_qi_to_si { } { return [check_cached_effective_target_indexed vect_widen_sum_qi_to_si { expr { [istarget powerpc*-*-*] @@ -7904,7 +7950,7 @@ proc check_effective_target_vect_widen_mult_qi_to_hi { } { && ![check_effective_target_aarch64_sve]) || [is-effective-target arm_neon] || ([istarget s390*-*-*] - && [check_effective_target_s390_vx])) + && [check_effective_target_s390_vx])) || [istarget amdgcn-*-*] }}] } @@ -7920,7 +7966,7 @@ proc check_effective_target_vect_widen_mult_qi_to_hi { } { proc check_effective_target_vect_widen_mult_hi_to_si { } { return [check_cached_effective_target_indexed vect_widen_mult_hi_to_si { expr { ([check_effective_target_vect_unpack] - && [check_effective_target_vect_int_mult]) + && [check_effective_target_vect_int_mult]) || ([istarget powerpc*-*-*] || [istarget ia64-*-*] || ([istarget aarch64*-*-*] @@ -7940,7 +7986,7 @@ proc check_effective_target_vect_widen_mult_hi_to_si { } { proc check_effective_target_vect_widen_mult_qi_to_hi_pattern { } { return [check_cached_effective_target_indexed vect_widen_mult_qi_to_hi_pattern { expr { [istarget powerpc*-*-*] - || ([is-effective-target arm_neon] + || ([is-effective-target arm_neon] && [check_effective_target_arm_little_endian]) || ([istarget s390*-*-*] && [check_effective_target_s390_vx]) @@ -8069,7 +8115,7 @@ proc check_effective_target_vect_udot_hi { } { || ([istarget mips*-*-*] && [et-is-effective-target mips_msa]) || ([istarget riscv*-*-*] - && [check_effective_target_riscv_v]) + && [check_effective_target_riscv_v]) || ([istarget loongarch*-*-*] && [check_effective_target_loongarch_sx]) }}] } @@ -8123,23 +8169,23 @@ proc check_effective_target_vect_sdiv_pow2_si {} { } # Return 1 if the target plus current options supports a vector -# demotion (packing) of shorts (to chars) and ints (to shorts) +# demotion (packing) of shorts (to chars) and ints (to shorts) # using modulo arithmetic, 0 otherwise. # # This won't change for different subtargets so cache the result. - + proc check_effective_target_vect_pack_trunc { } { return [check_cached_effective_target_indexed vect_pack_trunc { expr { [istarget powerpc*-*-*] - || [istarget i?86-*-*] || [istarget x86_64-*-*] - || [istarget aarch64*-*-*] - || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok] + || [istarget i?86-*-*] || [istarget x86_64-*-*] + || [istarget aarch64*-*-*] + || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok] && [check_effective_target_arm_little_endian]) || ([istarget mips*-*-*] && [et-is-effective-target mips_msa]) || ([istarget s390*-*-*] && [check_effective_target_s390_vx]) - || [istarget amdgcn*-*-*] + || [istarget amdgcn*-*-*] || ([istarget riscv*-*-*] && [check_effective_target_riscv_v]) || ([istarget loongarch*-*-*] @@ -8150,16 +8196,16 @@ proc check_effective_target_vect_pack_trunc { } { # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise. # # This won't change for different subtargets so cache the result. - + proc check_effective_target_vect_unpack { } { return [check_cached_effective_target_indexed vect_unpack { expr { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*]) - || [istarget i?86-*-*] || [istarget x86_64-*-*] - || [istarget ia64-*-*] - || [istarget aarch64*-*-*] + || [istarget i?86-*-*] || [istarget x86_64-*-*] + || [istarget ia64-*-*] + || [istarget aarch64*-*-*] || ([istarget mips*-*-*] && [et-is-effective-target mips_msa]) - || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok] + || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok] && [check_effective_target_arm_little_endian]) || ([istarget s390*-*-*] && [check_effective_target_s390_vx]) @@ -8221,7 +8267,7 @@ proc check_effective_target_vect_hw_misalign { } { return 1 } - return 0 + return 0 }] } @@ -8247,11 +8293,11 @@ proc check_effective_target_vect_aligned_arrays { } { proc check_effective_target_no_alignment_constraints { } { return [check_runtime_nocache no_alignment_constraints { - int - main (void) - { - return __BIGGEST_ALIGNMENT__ == 1 ? 0 : 1; - } + int + main (void) + { + return __BIGGEST_ALIGNMENT__ == 1 ? 0 : 1; + } }] } @@ -8289,7 +8335,7 @@ proc check_effective_target_natural_alignment_32 { } { proc check_effective_target_natural_alignment_64 { } { return [check_cached_effective_target_indexed natural_alignment_64 { expr { [is-effective-target natural_alignment_32] - && [is-effective-target lp64] && ![istarget *-*-darwin*] } + && [is-effective-target lp64] && ![istarget *-*-darwin*] } }] } @@ -8320,7 +8366,7 @@ proc check_effective_target_vect_check_ptrs { } { proc check_effective_target_vect_fully_masked { } { return [expr { [check_effective_target_aarch64_sve] - || [istarget amdgcn*-*-*] + || [istarget amdgcn*-*-*] || [check_effective_target_riscv_v] }] } @@ -8561,7 +8607,7 @@ proc check_vect_slp_store_usage { pattern macro } { # Check pattern exits in lines, set it to zero if not found. if { [regexp $pattern $lines] } then { - return 1 + return 1 } return 0 @@ -8763,7 +8809,7 @@ proc check_effective_target_vector_alignment_reachable { } { proc check_effective_target_vector_alignment_reachable_for_64bit { } { set et_vector_alignment_reachable_for_64bit 0 - if { [check_effective_target_vect_aligned_arrays] + if { [check_effective_target_vect_aligned_arrays] || [check_effective_target_natural_alignment_64] } { set et_vector_alignment_reachable_for_64bit 1 } @@ -8864,7 +8910,7 @@ proc check_effective_target_vect_cond_mixed { } { return [check_cached_effective_target_indexed vect_cond_mixed { expr { [istarget i?86-*-*] || [istarget x86_64-*-*] || [istarget aarch64*-*-*] - || [istarget powerpc*-*-*] + || [istarget powerpc*-*-*] || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) || ([istarget mips*-*-*] @@ -8978,16 +9024,16 @@ proc check_effective_target_vect_extract_even_odd { } { expr { [istarget aarch64*-*-*] || [istarget powerpc*-*-*] || [is-effective-target arm_neon] - || [istarget i?86-*-*] || [istarget x86_64-*-*] - || [istarget ia64-*-*] + || [istarget i?86-*-*] || [istarget x86_64-*-*] + || [istarget ia64-*-*] || ([istarget mips*-*-*] && ([et-is-effective-target mips_msa] || [et-is-effective-target mpaired_single])) || ([istarget s390*-*-*] && [check_effective_target_s390_vx]) - || ([istarget riscv*-*-*] + || ([istarget riscv*-*-*] && [check_effective_target_riscv_v]) - || ([istarget loongarch*-*-*] + || ([istarget loongarch*-*-*] && [check_effective_target_loongarch_sx]) }}] } @@ -8998,8 +9044,8 @@ proc check_effective_target_vect_interleave { } { expr { [istarget aarch64*-*-*] || [istarget powerpc*-*-*] || [is-effective-target arm_neon] - || [istarget i?86-*-*] || [istarget x86_64-*-*] - || [istarget ia64-*-*] + || [istarget i?86-*-*] || [istarget x86_64-*-*] + || [istarget ia64-*-*] || ([istarget mips*-*-*] && ([et-is-effective-target mpaired_single] || [et-is-effective-target mips_msa])) @@ -9062,7 +9108,7 @@ proc available_vector_sizes { } { } elseif { [istarget sparc*-*-*] } { lappend result 64 } elseif { [istarget amdgcn*-*-*] } { - # 6 different lane counts, and 4 element sizes + # 6 different lane counts, and 4 element sizes lappend result 4096 2048 1024 512 256 128 64 32 16 8 4 2 } elseif { [istarget riscv*-*-*] } { if { [check_effective_target_riscv_v] } { @@ -9131,7 +9177,7 @@ proc check_effective_target_vect_call_copysignf { } { expr { [istarget i?86-*-*] || [istarget x86_64-*-*] || [istarget powerpc*-*-*] || [istarget aarch64*-*-*] - || [istarget amdgcn-*-*] + || [istarget amdgcn-*-*] || ([istarget riscv*-*-*] && [check_effective_target_riscv_v]) || ([istarget loongarch*-*-*] @@ -9172,7 +9218,7 @@ proc check_effective_target_vect_call_sqrtf { } { || ([istarget powerpc*-*-*] && [check_vsx_hw_available]) || ([istarget s390*-*-*] && [check_effective_target_s390_vx]) - || [istarget amdgcn-*-*] + || [istarget amdgcn-*-*] || ([istarget riscv*-*-*] && [check_effective_target_riscv_v]) || ([istarget loongarch*-*-*] @@ -9253,7 +9299,7 @@ proc check_effective_target_vect_call_floorf { } { proc check_effective_target_vect_call_lceil { } { return [check_cached_effective_target_indexed vect_call_lceil { expr { [istarget aarch64*-*-*] - || [istarget loongarch*-*-*] }}] + || [istarget loongarch*-*-*] }}] } # Return 1 if the target supports vector lfloor calls. @@ -9261,7 +9307,7 @@ proc check_effective_target_vect_call_lceil { } { proc check_effective_target_vect_call_lfloor { } { return [check_cached_effective_target_indexed vect_call_lfloor { expr { [istarget aarch64*-*-*] - || [istarget loongarch*-*-*] }}] + || [istarget loongarch*-*-*] }}] } # Return 1 if the target supports vector nearbyint calls. @@ -9296,7 +9342,7 @@ proc check_effective_target_vect_call_roundf { } { proc check_effective_target_vect_logical_reduc { } { return [expr { [check_effective_target_aarch64_sve] - || [istarget amdgcn-*-*] + || [istarget amdgcn-*-*] || [check_effective_target_riscv_v] || [check_effective_target_loongarch_sx] || [istarget i?86-*-*] || [istarget x86_64-*-*]}] @@ -9367,10 +9413,10 @@ proc check_effective_target_popcountl { } { proc check_effective_target_popcountll { } { return [check_no_messages_and_pattern popcountll "!\\(call" rtl-expand { - int foo (long long b) - { - return __builtin_popcountll (b); - } + int foo (long long b) + { + return __builtin_popcountll (b); + } } "" ] } @@ -9379,10 +9425,10 @@ proc check_effective_target_popcountll { } { proc check_effective_target_popcount { } { return [check_no_messages_and_pattern popcount "!\\(call" rtl-expand { - int foo (int b) - { - return __builtin_popcount (b); - } + int foo (int b) + { + return __builtin_popcount (b); + } } "" ] } @@ -9390,10 +9436,10 @@ proc check_effective_target_popcount { } { proc check_effective_target_clz { } { return [check_no_messages_and_pattern clz "!\\(call" rtl-expand { - int foo (int b) - { - return __builtin_clz (b); - } + int foo (int b) + { + return __builtin_clz (b); + } } "" ] } @@ -9412,10 +9458,10 @@ proc check_effective_target_clzl { } { proc check_effective_target_clzll { } { return [check_no_messages_and_pattern clzll "!\\(call" rtl-expand { - int foo (long long b) - { - return __builtin_clzll (b); - } + int foo (long long b) + { + return __builtin_clzll (b); + } } "" ] } @@ -9423,10 +9469,10 @@ proc check_effective_target_clzll { } { proc check_effective_target_ctz { } { return [check_no_messages_and_pattern ctz "!\\(call" rtl-expand { - int foo (int b) - { - return __builtin_ctz (b); - } + int foo (int b) + { + return __builtin_ctz (b); + } } "" ] } @@ -9445,10 +9491,10 @@ proc check_effective_target_ctzl { } { proc check_effective_target_ctzll { } { return [check_no_messages_and_pattern ctzll "!\\(call" rtl-expand { - int foo (long long b) - { - return __builtin_ctzll (b); - } + int foo (long long b) + { + return __builtin_ctzll (b); + } } "" ] } @@ -9513,7 +9559,7 @@ proc check_effective_target_bswap { } { || [istarget rs6000-*-*] || [istarget s390*-*-*] || ([istarget riscv*-*-*] - && [check_no_compiler_messages_nocache riscv_zbb object { + && [check_no_compiler_messages_nocache riscv_zbb object { #if __riscv_zbb <= 0 #error ZBB is not enabled #endif @@ -9537,14 +9583,14 @@ proc check_effective_target_sync_int_long { } { expr { [istarget ia64-*-*] || [istarget i?86-*-*] || [istarget x86_64-*-*] || [istarget aarch64*-*-*] - || [istarget alpha*-*-*] - || [istarget arm*-*-linux-*] - || [istarget arm*-*-uclinuxfdpiceabi] + || [istarget alpha*-*-*] + || [istarget arm*-*-linux-*] + || [istarget arm*-*-uclinuxfdpiceabi] || ([istarget arm*-*-*] && [check_effective_target_arm_acq_rel]) || [istarget bfin*-*linux*] || [istarget hppa*-*linux*] - || [istarget s390*-*-*] + || [istarget s390*-*-*] || [istarget powerpc*-*-*] || [istarget cris-*-*] || ([istarget sparc*-*-*] && [check_effective_target_sparc_v9]) @@ -9560,7 +9606,7 @@ proc check_effective_target_sync_int_long { } { proc check_effective_target_sync_int_long_stack { } { return [check_cached_effective_target sync_int_long_stack { expr { ![istarget nvptx*-*-*] - && [check_effective_target_sync_int_long] + && [check_effective_target_sync_int_long] }}] } @@ -9573,13 +9619,13 @@ proc check_effective_target_sync_char_short { } { expr { [istarget aarch64*-*-*] || [istarget ia64-*-*] || [istarget i?86-*-*] || [istarget x86_64-*-*] - || [istarget alpha*-*-*] - || [istarget arm*-*-linux-*] - || [istarget arm*-*-uclinuxfdpiceabi] + || [istarget alpha*-*-*] + || [istarget arm*-*-linux-*] + || [istarget arm*-*-uclinuxfdpiceabi] || ([istarget arm*-*-*] && [check_effective_target_arm_acq_rel]) || [istarget hppa*-*linux*] - || [istarget s390*-*-*] + || [istarget s390*-*-*] || [istarget powerpc*-*-*] || [istarget cris-*-*] || ([istarget sparc*-*-*] && [check_effective_target_sparc_v9]) @@ -10034,7 +10080,7 @@ proc check_effective_target_fd_truncate { } { proc add_options_for_ieee { flags } { if { [istarget alpha*-*-*] - || [istarget sh*-*-*] } { + || [istarget sh*-*-*] } { return "$flags -mieee" } if { [istarget rx-*-*] } { @@ -10057,20 +10103,20 @@ proc add_options_for_bind_pic_locally { flags } { # order to make sure that the multilib_flags doesn't override this. if {[check_no_compiler_messages using_pic2 assembly { - #if __PIC__ != 2 - #error __PIC__ != 2 - #endif + #if __PIC__ != 2 + #error __PIC__ != 2 + #endif }]} { - set flags_to_postpone "-fPIE" - return $flags + set flags_to_postpone "-fPIE" + return $flags } if {[check_no_compiler_messages using_pic1 assembly { - #if __PIC__ != 1 - #error __PIC__ != 1 - #endif + #if __PIC__ != 1 + #error __PIC__ != 1 + #endif }]} { - set flags_to_postpone "-fpie" - return $flags + set flags_to_postpone "-fpie" + return $flags } return $flags } @@ -10119,7 +10165,7 @@ proc check_effective_target_c99_runtime { } { proc check_effective_target_cfi { } { return [check_no_compiler_messages cfi assembly { #ifdef __GCC_HAVE_DWARF2_CFI_ASM - /* ok */ + /* ok */ #else #error unsupported #endif @@ -10167,7 +10213,7 @@ proc check_effective_target_4byte_wchar_t { } { proc check_effective_target_automatic_stack_alignment { } { # Ordinarily x86 supports automatic stack alignment ... if { [istarget i?86*-*-*] || [istarget x86_64-*-*] } then { - if { [istarget *-*-mingw*] || [istarget *-*-cygwin*] } { + if { [istarget *-*-mingw*] || [istarget *-*-cygwin*] } { # ... except Win64 SEH doesn't. Succeed for Win32 though. return [check_effective_target_ilp32]; } @@ -10305,7 +10351,7 @@ proc check_effective_target_avx2 { } { typedef long long __v4di __attribute__ ((__vector_size__ (32))); __v4di mm256_is32_andnotsi256 (__v4di __X, __v4di __Y) - { + { return __builtin_ia32_andnotsi256 (__X, __Y); } } "-O0 -mavx2" ] @@ -10317,7 +10363,7 @@ proc check_effective_target_avxvnni { } { typedef int __v8si __attribute__ ((__vector_size__ (32))); __v8si _mm256_dpbusd_epi32 (__v8si __A, __v8si __B, __v8si __C) - { + { return __builtin_ia32_vpdpbusd_v8si (__A, __B, __C); } } "-mavxvnni" ] @@ -10329,7 +10375,7 @@ proc check_effective_target_avxifma { } { typedef long long __v4di __attribute__ ((__vector_size__ (32))); __v4di _mm256_maddlo_epu64 (__v4di __A, __v4di __B, __v4di __C) - { + { return __builtin_ia32_vpmadd52luq256 (__A, __B, __C); } } "-O0 -mavxifma" ] @@ -10341,7 +10387,7 @@ proc check_effective_target_avxvnniint8 { } { typedef int __v8si __attribute__ ((__vector_size__ (32))); __v8si _mm256_dpbssd_epi32 (__v8si __A, __v8si __B, __v8si __C) - { + { return __builtin_ia32_vpdpbssd256 (__A, __B, __C); } } "-O0 -mavxvnniint8" ] @@ -10363,7 +10409,7 @@ proc check_effective_target_avxneconvert { } { proc check_effective_target_cmpccxadd { } { return [check_no_compiler_messages cmpccxadd object { int _cmpccxadd_epi32 (int *__A, int __B, int __C, const int __D) - { + { return (int)__builtin_ia32_cmpccxadd (__A, __B, __C, 1); } } "-mcmpccxadd" ] @@ -10397,7 +10443,7 @@ proc check_effective_target_avxvnniint16 { } { typedef int __v8si __attribute__ ((__vector_size__ (32))); __v8si _mm256_dpwsud_avx_epi32 (__v8si __A, __v8si __B, __v8si __C) - { + { return __builtin_ia32_vpdpwsud256 (__A, __B, __C); } } "-O0 -mavxvnniint16" ] @@ -10425,7 +10471,7 @@ proc check_effective_target_sha512 { } { typedef long long __v4di __attribute__ ((__vector_size__ (32))); __m256i _mm256_sha512msg2_epi64 (__m256i __A, __m256i __B) - { + { return (__m256i) __builtin_ia32_vsha512msg2 ((__v4di) __A, (__v4di) __B); } @@ -10435,14 +10481,14 @@ proc check_effective_target_sha512 { } { # Return 1 if sm4 instructions can be compiled. proc check_effective_target_sm4 { } { return [check_no_compiler_messages sm4 object { - typedef long long __m128i __attribute__ ((__vector_size__ (16))); - typedef int __v4si __attribute__ ((__vector_size__ (16))); - __m128i - _mm_sm4key4_epi32 (__m128i __A, __m128i __B) - { - return (__m128i) __builtin_ia32_vsm4key4128 ((__v4si) __A, + typedef long long __m128i __attribute__ ((__vector_size__ (16))); + typedef int __v4si __attribute__ ((__vector_size__ (16))); + __m128i + _mm_sm4key4_epi32 (__m128i __A, __m128i __B) + { + return (__m128i) __builtin_ia32_vsm4key4128 ((__v4si) __A, (__v4si) __B); - } + } } "-msm4" ] } @@ -10477,7 +10523,7 @@ proc check_effective_target_sse { } { proc check_effective_target_sse2 { } { return [check_no_compiler_messages sse2 object { typedef long long __m128i __attribute__ ((__vector_size__ (16))); - + __m128i _mm_srli_si128 (__m128i __A, int __N) { return (__m128i)__builtin_ia32_psrldqi128 (__A, 8); @@ -10633,7 +10679,7 @@ proc check_effective_target_sse4a { } { # Return 1 if fma4 instructions can be compiled. proc check_effective_target_fma4 { } { return [check_no_compiler_messages fma4 object { - typedef float __m128 __attribute__ ((__vector_size__ (16))); + typedef float __m128 __attribute__ ((__vector_size__ (16))); typedef float __v4sf __attribute__ ((__vector_size__ (16))); __m128 _mm_macc_ps(__m128 __A, __m128 __B, __m128 __C) { @@ -10647,7 +10693,7 @@ proc check_effective_target_fma4 { } { # Return 1 if fma instructions can be compiled. proc check_effective_target_fma { } { return [check_no_compiler_messages fma object { - typedef float __m128 __attribute__ ((__vector_size__ (16))); + typedef float __m128 __attribute__ ((__vector_size__ (16))); typedef float __v4sf __attribute__ ((__vector_size__ (16))); __m128 _mm_macc_ps(__m128 __A, __m128 __B, __m128 __C) { @@ -10722,8 +10768,8 @@ proc check_effective_target_avx512vl { } { __v4di mm256_and_epi64 (__v4di __X, __v4di __Y) { - __v4di __W; - return __builtin_ia32_pandq256_mask (__X, __Y, __W, -1); + __v4di __W; + return __builtin_ia32_pandq256_mask (__X, __Y, __W, -1); } } "-mavx512vl" ] } @@ -10762,7 +10808,7 @@ proc check_effective_target_sha { } { __m128i _mm_sha1msg1_epu32 (__m128i __X, __m128i __Y) { - return (__m128i) __builtin_ia32_sha1msg1 ((__v4si)__X, + return (__m128i) __builtin_ia32_sha1msg1 ((__v4si)__X, (__v4si)__Y); } } "-O2 -msha" ] @@ -10897,48 +10943,48 @@ proc check_effective_target_avx5124vnniw { } { # Return 1 if avx512_vpopcntdq instructions can be compiled. proc check_effective_target_avx512vpopcntdq { } { return [check_no_compiler_messages avx512vpopcntdq object { - typedef int __v16si __attribute__ ((__vector_size__ (64))); + typedef int __v16si __attribute__ ((__vector_size__ (64))); - __v16si - _mm512_popcnt_epi32 (__v16si __A) - { - return (__v16si) __builtin_ia32_vpopcountd_v16si ((__v16si) __A); - } + __v16si + _mm512_popcnt_epi32 (__v16si __A) + { + return (__v16si) __builtin_ia32_vpopcountd_v16si ((__v16si) __A); + } } "-mavx512vpopcntdq" ] } # Return 1 if 128 or 256-bit avx512_vpopcntdq instructions can be compiled. proc check_effective_target_avx512vpopcntdqvl { } { return [check_no_compiler_messages avx512vpopcntdqvl object { - typedef int __v8si __attribute__ ((__vector_size__ (32))); + typedef int __v8si __attribute__ ((__vector_size__ (32))); - __v8si - _mm256_popcnt_epi32 (__v8si __A) - { - return (__v8si) __builtin_ia32_vpopcountd_v8si ((__v8si) __A); - } + __v8si + _mm256_popcnt_epi32 (__v8si __A) + { + return (__v8si) __builtin_ia32_vpopcountd_v8si ((__v8si) __A); + } } "-mavx512vpopcntdq -mavx512vl" ] } # Return 1 if gfni instructions can be compiled. proc check_effective_target_gfni { } { return [check_no_compiler_messages gfni object { - typedef char __v16qi __attribute__ ((__vector_size__ (16))); + typedef char __v16qi __attribute__ ((__vector_size__ (16))); - __v16qi - _mm_gf2p8affineinv_epi64_epi8 (__v16qi __A, __v16qi __B, const int __C) - { - return (__v16qi) __builtin_ia32_vgf2p8affineinvqb_v16qi ((__v16qi) __A, + __v16qi + _mm_gf2p8affineinv_epi64_epi8 (__v16qi __A, __v16qi __B, const int __C) + { + return (__v16qi) __builtin_ia32_vgf2p8affineinvqb_v16qi ((__v16qi) __A, (__v16qi) __B, 0); - } + } } "-mgfni" ] } # Return 1 if avx512vbmi2 instructions can be compiled. proc check_effective_target_avx512vbmi2 { } { return [check_no_compiler_messages avx512vbmi2 object { - typedef char __v16qi __attribute__ ((__vector_size__ (16))); + typedef char __v16qi __attribute__ ((__vector_size__ (16))); typedef unsigned long long __mmask16; __v16qi @@ -10954,7 +11000,7 @@ proc check_effective_target_avx512vbmi2 { } { # Return 1 if avx512vbmi2 instructions can be compiled. proc check_effective_target_avx512vnni { } { return [check_no_compiler_messages avx512vnni object { - typedef int __v16si __attribute__ ((__vector_size__ (64))); + typedef int __v16si __attribute__ ((__vector_size__ (64))); __v16si _mm_mask_compress_epi8 (__v16si __A, __v16si __B, __v16si __C) @@ -10970,7 +11016,7 @@ proc check_effective_target_avx512vnni { } { proc check_effective_target_avx512vaes { } { return [check_no_compiler_messages avx512vaes object { - typedef int __v16si __attribute__ ((__vector_size__ (64))); + typedef int __v16si __attribute__ ((__vector_size__ (64))); __v32qi _mm256_aesdec_epi128 (__v32qi __A, __v32qi __B) @@ -11027,26 +11073,26 @@ proc check_effective_target_amx_fp16 { } { # Return 1 if vpclmulqdq instructions can be compiled. proc check_effective_target_vpclmulqdq { } { return [check_no_compiler_messages vpclmulqdq object { - typedef long long __v4di __attribute__ ((__vector_size__ (32))); + typedef long long __v4di __attribute__ ((__vector_size__ (32))); - __v4di - _mm256_clmulepi64_epi128 (__v4di __A, __v4di __B) - { - return (__v4di) __builtin_ia32_vpclmulqdq_v4di (__A, __B, 0); - } + __v4di + _mm256_clmulepi64_epi128 (__v4di __A, __v4di __B) + { + return (__v4di) __builtin_ia32_vpclmulqdq_v4di (__A, __B, 0); + } } "-mvpclmulqdq -mavx512vl" ] } # Return 1 if avx512_bitalg instructions can be compiled. proc check_effective_target_avx512bitalg { } { return [check_no_compiler_messages avx512bitalg object { - typedef short int __v32hi __attribute__ ((__vector_size__ (64))); + typedef short int __v32hi __attribute__ ((__vector_size__ (64))); - __v32hi - _mm512_popcnt_epi16 (__v32hi __A) - { - return (__v32hi) __builtin_ia32_vpopcountw_v32hi ((__v32hi) __A); - } + __v32hi + _mm512_popcnt_epi16 (__v32hi __A) + { + return (__v32hi) __builtin_ia32_vpopcountw_v32hi ((__v32hi) __A); + } } "-mavx512bitalg" ] } @@ -11054,9 +11100,9 @@ proc check_effective_target_avx512bitalg { } { proc check_effective_target_wchar_t_char16_t_compatible { } { return [check_no_compiler_messages wchar_t_char16_t object { - __WCHAR_TYPE__ wc; - __CHAR16_TYPE__ *p16 = &wc; - char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1]; + __WCHAR_TYPE__ wc; + __CHAR16_TYPE__ *p16 = &wc; + char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1]; }] } @@ -11064,9 +11110,9 @@ proc check_effective_target_wchar_t_char16_t_compatible { } { proc check_effective_target_wchar_t_char32_t_compatible { } { return [check_no_compiler_messages wchar_t_char32_t object { - __WCHAR_TYPE__ wc; - __CHAR32_TYPE__ *p32 = &wc; - char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1]; + __WCHAR_TYPE__ wc; + __CHAR32_TYPE__ *p32 = &wc; + char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1]; }] } @@ -11155,9 +11201,9 @@ proc check_effective_target_gas { } { # version of GAS (and reports GNU assembler in its -v output) but # but doesn't support many of the modern GAS features. if { [ string first "cctools" $as_output ] >= 0 } { - set use_gas_saved 0 + set use_gas_saved 0 } else { - set use_gas_saved 1 + set use_gas_saved 1 } } else { set use_gas_saved 0 @@ -11229,7 +11275,7 @@ proc check_effective_target_analyzer { } { proc check_effective_target_maybe_x32 { } { return [check_no_compiler_messages maybe_x32 object { - void foo (void) {} + void foo (void) {} } "-mx32 -maddress-mode=short"] } @@ -11465,7 +11511,7 @@ proc check_effective_target_implicit_constexpr { } { proc check_effective_target_run_expensive_tests { } { if { [getenv GCC_TEST_RUN_EXPENSIVE] != "" } { - return 1 + return 1 } return 0 } @@ -11504,7 +11550,7 @@ proc check_effective_target_strndup {} { proc check_effective_target_sigsetjmp {} { if { [check_function_available "sigsetjmp"] - || [check_function_available "__sigsetjmp"] } { + || [check_function_available "__sigsetjmp"] } { return 1 } return 0 @@ -11527,49 +11573,49 @@ proc check_vect_support_and_set_flags { } { global EFFECTIVE_TARGETS if [istarget powerpc-*paired*] { - lappend DEFAULT_VECTCFLAGS "-mpaired" - if [check_750cl_hw_available] { - set dg-do-what-default run - } else { - set dg-do-what-default compile - } + lappend DEFAULT_VECTCFLAGS "-mpaired" + if [check_750cl_hw_available] { + set dg-do-what-default run + } else { + set dg-do-what-default compile + } } elseif [istarget powerpc*-*-*] { - # Skip targets not supporting -maltivec. - if ![is-effective-target powerpc_altivec_ok] { - return 0 - } - - lappend DEFAULT_VECTCFLAGS "-maltivec" - if [check_p9vector_hw_available] { - # For power10 and up, don't specify -mcpu=power9, so that we - # can have more testing coverage with higher cpu types. - if ![check_power10_hw_available] { - lappend DEFAULT_VECTCFLAGS "-mcpu=power9" - } - } elseif [check_p8vector_hw_available] { - lappend DEFAULT_VECTCFLAGS "-mcpu=power8" - } elseif [check_vsx_hw_available] { - lappend DEFAULT_VECTCFLAGS "-mvsx" "-mno-allow-movmisalign" - } - - if [check_vmx_hw_available] { - set dg-do-what-default run - } else { - if [is-effective-target ilp32] { - # Specify a cpu that supports VMX for compile-only tests. - # Place -mcpu=970 first to avoid possible overriding on - # some other cpu type specified above. + # Skip targets not supporting -maltivec. + if ![is-effective-target powerpc_altivec_ok] { + return 0 + } + + lappend DEFAULT_VECTCFLAGS "-maltivec" + if [check_p9vector_hw_available] { + # For power10 and up, don't specify -mcpu=power9, so that we + # can have more testing coverage with higher cpu types. + if ![check_power10_hw_available] { + lappend DEFAULT_VECTCFLAGS "-mcpu=power9" + } + } elseif [check_p8vector_hw_available] { + lappend DEFAULT_VECTCFLAGS "-mcpu=power8" + } elseif [check_vsx_hw_available] { + lappend DEFAULT_VECTCFLAGS "-mvsx" "-mno-allow-movmisalign" + } + + if [check_vmx_hw_available] { + set dg-do-what-default run + } else { + if [is-effective-target ilp32] { + # Specify a cpu that supports VMX for compile-only tests. + # Place -mcpu=970 first to avoid possible overriding on + # some other cpu type specified above. set DEFAULT_VECTCFLAGS [linsert $DEFAULT_VECTCFLAGS 0 "-mcpu=970"] - } - set dg-do-what-default compile - } + } + set dg-do-what-default compile + } } elseif { [istarget i?86-*-*] || [istarget x86_64-*-*] } { - lappend DEFAULT_VECTCFLAGS "-msse2" - if { [check_effective_target_sse2_runtime] } { - set dg-do-what-default run - } else { - set dg-do-what-default compile - } + lappend DEFAULT_VECTCFLAGS "-msse2" + if { [check_effective_target_sse2_runtime] } { + set dg-do-what-default run + } else { + set dg-do-what-default compile + } } elseif { [istarget mips*-*-*] && [check_effective_target_nomips16] } { if { [check_effective_target_mpaired_single "-mpaired-single"] } { @@ -11580,43 +11626,43 @@ proc check_vect_support_and_set_flags { } { } if { [check_effective_target_mips_msa "-mmsa"] } { lappend EFFECTIVE_TARGETS mips_msa - } + } return [llength $EFFECTIVE_TARGETS] } elseif [istarget sparc*-*-*] { - lappend DEFAULT_VECTCFLAGS "-mcpu=ultrasparc" "-mvis" - if [check_effective_target_ultrasparc_hw] { - set dg-do-what-default run - } else { - set dg-do-what-default compile - } + lappend DEFAULT_VECTCFLAGS "-mcpu=ultrasparc" "-mvis" + if [check_effective_target_ultrasparc_hw] { + set dg-do-what-default run + } else { + set dg-do-what-default compile + } } elseif [istarget alpha*-*-*] { - # Alpha's vectorization capabilities are extremely limited. - # It's more effort than its worth disabling all of the tests - # that it cannot pass. But if you actually want to see what - # does work, command out the return. - return 0 - - lappend DEFAULT_VECTCFLAGS "-mmax" - if [check_alpha_max_hw_available] { - set dg-do-what-default run - } else { - set dg-do-what-default compile - } + # Alpha's vectorization capabilities are extremely limited. + # It's more effort than its worth disabling all of the tests + # that it cannot pass. But if you actually want to see what + # does work, command out the return. + return 0 + + lappend DEFAULT_VECTCFLAGS "-mmax" + if [check_alpha_max_hw_available] { + set dg-do-what-default run + } else { + set dg-do-what-default compile + } } elseif [istarget ia64-*-*] { - set dg-do-what-default run + set dg-do-what-default run } elseif [is-effective-target arm_neon_ok] { - eval lappend DEFAULT_VECTCFLAGS [add_options_for_arm_neon ""] - # NEON does not support denormals, so is not used for vectorization by - # default to avoid loss of precision. We must pass -ffast-math to test - # vectorization of float operations. - lappend DEFAULT_VECTCFLAGS "-ffast-math" - if [is-effective-target arm_neon_hw] { - set dg-do-what-default run - } else { - set dg-do-what-default compile - } + eval lappend DEFAULT_VECTCFLAGS [add_options_for_arm_neon ""] + # NEON does not support denormals, so is not used for vectorization by + # default to avoid loss of precision. We must pass -ffast-math to test + # vectorization of float operations. + lappend DEFAULT_VECTCFLAGS "-ffast-math" + if [is-effective-target arm_neon_hw] { + set dg-do-what-default run + } else { + set dg-do-what-default compile + } } elseif [istarget aarch64*-*-*] { - set dg-do-what-default run + set dg-do-what-default run } elseif [istarget s390*-*-*] { # The S/390 backend set a default of 2 for that value. # Override it to have the same situation as with other @@ -11626,21 +11672,21 @@ proc check_vect_support_and_set_flags { } { lappend DEFAULT_VECTCFLAGS "--param" "max-unroll-times=8" lappend DEFAULT_VECTCFLAGS "--param" "max-completely-peeled-insns=200" lappend DEFAULT_VECTCFLAGS "--param" "max-completely-peel-times=16" - if [check_effective_target_s390_vxe2] { + if [check_effective_target_s390_vxe2] { lappend DEFAULT_VECTCFLAGS "-march=z15" "-mzarch" - set dg-do-what-default run + set dg-do-what-default run } elseif [check_effective_target_s390_vxe] { lappend DEFAULT_VECTCFLAGS "-march=z14" "-mzarch" - set dg-do-what-default run + set dg-do-what-default run } elseif [check_effective_target_s390_vx] { lappend DEFAULT_VECTCFLAGS "-march=z13" "-mzarch" - set dg-do-what-default run - } else { + set dg-do-what-default run + } else { lappend DEFAULT_VECTCFLAGS "-march=z14" "-mzarch" - set dg-do-what-default compile - } + set dg-do-what-default compile + } } elseif [istarget amdgcn-*-*] { - set dg-do-what-default run + set dg-do-what-default run } elseif [istarget riscv*-*-*] { if [check_effective_target_riscv_v] { set dg-do-what-default run @@ -11663,7 +11709,7 @@ proc check_vect_support_and_set_flags { } { set dg-do-what-default compile } } else { - return 0 + return 0 } return 1 @@ -11783,15 +11829,15 @@ proc check_effective_target_aarch64_variant_pcs { } { proc check_effective_target_avr_tiny { } { if { [istarget avr*-*-*] } { - return [check_no_compiler_messages avr_tiny object { - #ifdef __AVR_TINY__ - int dummy; - #else - #error target not a reduced AVR Tiny core - #endif - }] + return [check_no_compiler_messages avr_tiny object { + #ifdef __AVR_TINY__ + int dummy; + #else + #error target not a reduced AVR Tiny core + #endif + }] } else { - return 0 + return 0 } } @@ -12401,7 +12447,7 @@ proc check_effective_target_divmod { } { # or define libfunc for divmod. if { [istarget arm*-*-*] || [istarget i?86-*-*] || [istarget x86_64-*-*] - || [istarget amdgcn-*-*] } { + || [istarget amdgcn-*-*] } { return 1 } return 0 @@ -12549,14 +12595,14 @@ proc check_effective_target_autoincdec { } { # # This is used to restrict the stack-clash mitigation tests to # just those targets that have been explicitly supported. -# +# # In addition to the prologue work on those targets, each target's # properties should be described in the functions below so that # tests do not become a mess of unreadable target conditions. -# +# proc check_effective_target_supports_stack_clash_protection { } { - if { [istarget x86_64-*-*] || [istarget i?86-*-*] + if { [istarget x86_64-*-*] || [istarget i?86-*-*] || [istarget powerpc*-*-*] || [istarget rs6000*-*-*] || [istarget aarch64*-**] || [istarget s390*-*-*] || [istarget loongarch64*-**] } { @@ -12652,14 +12698,14 @@ proc check_effective_target_cet { } { # Return 1 if target supports floating point "infinite" proc check_effective_target_inf { } { return [check_no_compiler_messages supports_inf assembly { - const double pinf = __builtin_inf (); + const double pinf = __builtin_inf (); }] } # Return 1 if target supports floating point "infinite" for float. proc check_effective_target_inff { } { return [check_no_compiler_messages supports_inff assembly { - const float pinf = __builtin_inff (); + const float pinf = __builtin_inff (); }] } @@ -12672,21 +12718,21 @@ proc check_effective_target_arm_v8_3a_complex_neon_ok_nocache { } { set et_arm_v8_3a_complex_neon_flags "" if { ![istarget arm*-*-*] && ![istarget aarch64*-*-*] } { - return 0; + return 0; } # Iterate through sets of options to find the compiler flags that # need to be added to the -march option. foreach flags {"" "-mfloat-abi=softfp -mfpu=auto" "-mfloat-abi=hard -mfpu=auto"} { - if { [check_no_compiler_messages_nocache \ - arm_v8_3a_complex_neon_ok assembly { - #if !defined (__ARM_FEATURE_COMPLEX) - #error "__ARM_FEATURE_COMPLEX not defined" - #endif - } "$flags -march=armv8.3-a"] } { - set et_arm_v8_3a_complex_neon_flags "$flags -march=armv8.3-a" - return 1; - } + if { [check_no_compiler_messages_nocache \ + arm_v8_3a_complex_neon_ok assembly { + #if !defined (__ARM_FEATURE_COMPLEX) + #error "__ARM_FEATURE_COMPLEX not defined" + #endif + } "$flags -march=armv8.3-a"] } { + set et_arm_v8_3a_complex_neon_flags "$flags -march=armv8.3-a" + return 1; + } } return 0; @@ -12694,12 +12740,12 @@ proc check_effective_target_arm_v8_3a_complex_neon_ok_nocache { } { proc check_effective_target_arm_v8_3a_complex_neon_ok { } { return [check_cached_effective_target arm_v8_3a_complex_neon_ok \ - check_effective_target_arm_v8_3a_complex_neon_ok_nocache] + check_effective_target_arm_v8_3a_complex_neon_ok_nocache] } proc add_options_for_arm_v8_3a_complex_neon { flags } { if { ! [check_effective_target_arm_v8_3a_complex_neon_ok] } { - return "$flags" + return "$flags" } global et_arm_v8_3a_complex_neon_flags return "$flags $et_arm_v8_3a_complex_neon_flags" @@ -12714,22 +12760,22 @@ proc check_effective_target_arm_v8_3a_fp16_complex_neon_ok_nocache { } { set et_arm_v8_3a_fp16_complex_neon_flags "" if { ![istarget arm*-*-*] && ![istarget aarch64*-*-*] } { - return 0; + return 0; } # Iterate through sets of options to find the compiler flags that # need to be added to the -march option. foreach flags {"" "-mfloat-abi=softfp -mfpu=auto" "-mfloat-abi=hard -mfpu=auto"} { - if { [check_no_compiler_messages_nocache \ - arm_v8_3a_fp16_complex_neon_ok assembly { - #if !defined (__ARM_FEATURE_COMPLEX) - #error "__ARM_FEATURE_COMPLEX not defined" - #endif - } "$flags -march=armv8.3-a+fp16"] } { - set et_arm_v8_3a_fp16_complex_neon_flags \ + if { [check_no_compiler_messages_nocache \ + arm_v8_3a_fp16_complex_neon_ok assembly { + #if !defined (__ARM_FEATURE_COMPLEX) + #error "__ARM_FEATURE_COMPLEX not defined" + #endif + } "$flags -march=armv8.3-a+fp16"] } { + set et_arm_v8_3a_fp16_complex_neon_flags \ "$flags -march=armv8.3-a+fp16" - return 1; - } + return 1; + } } return 0; @@ -12737,12 +12783,12 @@ proc check_effective_target_arm_v8_3a_fp16_complex_neon_ok_nocache { } { proc check_effective_target_arm_v8_3a_fp16_complex_neon_ok { } { return [check_cached_effective_target arm_v8_3a_fp16_complex_neon_ok \ - check_effective_target_arm_v8_3a_fp16_complex_neon_ok_nocache] + check_effective_target_arm_v8_3a_fp16_complex_neon_ok_nocache] } proc add_options_for_arm_v8_3a_fp16_complex_neon { flags } { if { ! [check_effective_target_arm_v8_3a_fp16_complex_neon_ok] } { - return "$flags" + return "$flags" } global et_arm_v8_3a_fp16_complex_neon_flags return "$flags $et_arm_v8_3a_fp16_complex_neon_flags" @@ -12755,33 +12801,33 @@ proc add_options_for_arm_v8_3a_fp16_complex_neon { flags } { proc check_effective_target_arm_v8_3a_complex_neon_hw { } { if { ![check_effective_target_arm_v8_3a_complex_neon_ok] } { - return 1; + return 1; } return [check_runtime arm_v8_3a_complex_neon_hw_available { - #include "arm_neon.h" - int - main (void) - { - - float32x2_t results = {-4.0,5.0}; - float32x2_t a = {1.0,3.0}; - float32x2_t b = {2.0,5.0}; - - #ifdef __ARM_ARCH_ISA_A64 - asm ("fcadd %0.2s, %1.2s, %2.2s, #90" - : "=w"(results) - : "w"(a), "w"(b) - : /* No clobbers. */); - - #else - asm ("vcadd.f32 %P0, %P1, %P2, #90" - : "=w"(results) - : "w"(a), "w"(b) - : /* No clobbers. */); - #endif - - return (results[0] == 8 && results[1] == 24) ? 0 : 1; - } + #include "arm_neon.h" + int + main (void) + { + + float32x2_t results = {-4.0,5.0}; + float32x2_t a = {1.0,3.0}; + float32x2_t b = {2.0,5.0}; + + #ifdef __ARM_ARCH_ISA_A64 + asm ("fcadd %0.2s, %1.2s, %2.2s, #90" + : "=w"(results) + : "w"(a), "w"(b) + : /* No clobbers. */); + + #else + asm ("vcadd.f32 %P0, %P1, %P2, #90" + : "=w"(results) + : "w"(a), "w"(b) + : /* No clobbers. */); + #endif + + return (results[0] == 8 && results[1] == 24) ? 0 : 1; + } } [add_options_for_arm_v8_3a_complex_neon ""]] } @@ -12800,12 +12846,12 @@ proc check_effective_target_arm_v8_3a_bkey_directive { } { proc check_effective_target_arm_v8_1_lob_ok { } { if { ![check_effective_target_arm_cortex_m] } { - return 0; + return 0; } else { return [check_runtime arm_v8_1_lob_hw_available { int main (void) - { int i = 0; + { int i = 0; asm ("movw r3, #10\n\t" /* movs? */ "dls lr, r3" : : : "r3", "lr"); loop: @@ -12860,11 +12906,11 @@ proc check_effective_target_glibc { } { foreach N {hf sf} { eval [string map [list N $N] { - proc check_effective_target_vect_complex_rot_N { } { - return [check_cached_effective_target_indexed vect_complex_rot_N { - expr { [istarget aarch64*-*-*] - || [istarget arm*-*-*] }}] - } + proc check_effective_target_vect_complex_rot_N { } { + return [check_cached_effective_target_indexed vect_complex_rot_N { + expr { [istarget aarch64*-*-*] + || [istarget arm*-*-*] }}] + } }] } @@ -12875,10 +12921,10 @@ foreach N {hf sf} { foreach N {df} { eval [string map [list N $N] { - proc check_effective_target_vect_complex_rot_N { } { - return [check_cached_effective_target_indexed vect_complex_rot_N { - expr { [istarget aarch64*-*-*] }}] - } + proc check_effective_target_vect_complex_rot_N { } { + return [check_cached_effective_target_indexed vect_complex_rot_N { + expr { [istarget aarch64*-*-*] }}] + } }] } @@ -12893,17 +12939,17 @@ proc check_effective_target_llvm_binutils { } { proc check_effective_target_mfentry { } { if { !([istarget i?86-*-*] || [istarget x86_64-*-*]) } { - return 0 + return 0 } return [check_no_compiler_messages mfentry object { - void foo (void) { } + void foo (void) { } } "-mfentry"] } # Return 1 if this target supports indirect calls proc check_effective_target_indirect_calls { } { if { [istarget bpf-*-*] } { - return 0 + return 0 } return 1 } @@ -13153,7 +13199,7 @@ proc check_effective_target_lra { } { # Otherwise check the reload dump for messages emitted solely by LRA. return [check_no_messages_and_pattern lra "\\\*{9} Local #1: \\\*{9}" rtl-reload { - void foo (void) {} + void foo (void) {} } {-O2 -fdump-rtl-reload-details}] ;# LRA notes requires a detailed dump. } @@ -13185,9 +13231,9 @@ proc check_effective_target_recent_python3 { } { set result [remote_exec host "python3 -c \"import sys; assert sys.version_info >= (3, 6)\""] set status [lindex $result 0] if { $status == 0 } then { - return 1; + return 1; } else { - return 0; + return 0; } } @@ -13197,9 +13243,9 @@ proc check_effective_target_python3_module { module } { set result [remote_exec host "python3 -c \"import $module\""] set status [lindex $result 0] if { $status == 0 } then { - return 1; + return 1; } else { - return 0; + return 0; } } @@ -13209,9 +13255,9 @@ proc check_effective_target_pytest3 { } { set result [remote_exec host "python3 -m pytest --color=no -rap -s --tb=no --version"] set status [lindex $result 0] if { $status == 0 } then { - return 1; + return 1; } else { - return 0; + return 0; } } @@ -13249,7 +13295,7 @@ main: .byte 0 } ""] } - + # Return 1 if this target has prog named "$prog", 0 otherwise. proc check_is_prog_name_available { prog } { @@ -13259,7 +13305,7 @@ proc check_is_prog_name_available { prog } { set output [lindex [${tool}_target_compile "" "" "none" $options] 0] if { $output == $prog } { - return 0 + return 0 } return 1 @@ -13278,65 +13324,65 @@ proc check_effective_target_const_volatile_readonly_section { } { # Return 1 if the CORE-V MAC extension is available. proc check_effective_target_cv_mac { } { if { !([istarget riscv*-*-*]) } { - return 0 + return 0 } return [check_no_compiler_messages cv_mac object { - void foo (void) - { - asm ("cv.mac t0, t1, t2"); - } + void foo (void) + { + asm ("cv.mac t0, t1, t2"); + } } "-march=rv32i_xcvmac" ] } # Return 1 if the CORE-V ALU extension is available. proc check_effective_target_cv_alu { } { if { !([istarget riscv*-*-*]) } { - return 0 + return 0 } return [check_no_compiler_messages cv_alu object { - void foo (void) - { - asm ("cv.addn t0, t1, t2, 0"); - } + void foo (void) + { + asm ("cv.addn t0, t1, t2, 0"); + } } "-march=rv32i_xcvalu" ] } # Return 1 if the CORE-V ELW extension is available. proc check_effective_target_cv_elw { } { if { !([istarget riscv*-*-*]) } { - return 0 + return 0 } return [check_no_compiler_messages cv_elw object { - void foo (void) - { - asm ("cv.elw x0, 0(x0)"); - } + void foo (void) + { + asm ("cv.elw x0, 0(x0)"); + } } "-march=rv32i_xcvelw" ] } # Return 1 if the CORE-V SIMD extension is available. proc check_effective_target_cv_simd { } { if { !([istarget riscv*-*-*]) } { - return 0 + return 0 } return [check_no_compiler_messages cv_simd object { - void foo (void) - { - asm ("cv.add.sc.b x0, x0, x0"); - } + void foo (void) + { + asm ("cv.add.sc.b x0, x0, x0"); + } } "-march=rv32i_xcvsimd" ] } # Return 1 if the CORE-V BI extension is available proc check_effective_target_cv_bi { } { if { !([istarget riscv*-*-*]) } { - return 0 + return 0 } return [check_no_compiler_messages cv_bi object { - void foo (void) - { - asm ("cv.beqimm t0, -16, foo"); - } + void foo (void) + { + asm ("cv.beqimm t0, -16, foo"); + } } "-march=rv32i_xcvbi" ] } @@ -13350,13 +13396,13 @@ proc check_effective_target_loongarch_sx { } { proc check_effective_target_loongarch_sx_as { } { return [check_no_compiler_messages loongarch_sx_as object { - #include - int main (void) - { - __m128i a, b, c; - c = __lsx_vand_v (a, b); - return 0; - } + #include + int main (void) + { + __m128i a, b, c; + c = __lsx_vand_v (a, b); + return 0; + } } "-mlsx"] } @@ -13405,7 +13451,7 @@ proc check_effective_target_loongarch_call36_support { } { proc check_effective_target_tls_le_relax { } { if [check_effective_target_tls_native] { return [check_no_compiler_messages loongarch_tls_le_relax object { - /* Assembly code */ + /* Assembly code */ lu12i.w $r12, %le_hi20_r(a) }] } diff --git a/gcc/text-art/canvas.cc b/gcc/text-art/canvas.cc index 5bb33b2c6fac8..8e5d96808d8c2 100644 --- a/gcc/text-art/canvas.cc +++ b/gcc/text-art/canvas.cc @@ -80,8 +80,8 @@ canvas::print_to_pp (pretty_printer *pp, pp_string (pp, per_line_prefix); pretty_printer line_pp; - line_pp.show_color = pp->show_color; - line_pp.url_format = pp->url_format; + pp_show_color (&line_pp) = pp_show_color (pp); + line_pp.set_url_format (pp->get_url_format ()); const int final_x_in_row = get_final_x_in_row (y); for (int x = 0; x <= final_x_in_row; x++) { @@ -133,7 +133,7 @@ canvas::debug (bool styled) const if (styled) { pp_show_color (&pp) = true; - pp.url_format = determine_url_format (DIAGNOSTICS_URL_AUTO); + pp.set_url_format (determine_url_format (DIAGNOSTICS_URL_AUTO)); } print_to_pp (&pp); fprintf (stderr, "%s\n", pp_formatted_text (&pp)); @@ -383,7 +383,7 @@ test_canvas_urls () { pretty_printer pp; pp_show_color (&pp) = true; - pp.url_format = URL_FORMAT_ST; + pp.set_url_format (URL_FORMAT_ST); assert_canvas_streq (SELFTEST_LOCATION, canvas, &pp, (/* Line 1. */ "\n" @@ -400,7 +400,7 @@ test_canvas_urls () { pretty_printer pp; pp_show_color (&pp) = true; - pp.url_format = URL_FORMAT_BEL; + pp.set_url_format (URL_FORMAT_BEL); assert_canvas_streq (SELFTEST_LOCATION, canvas, &pp, (/* Line 1. */ "\n" diff --git a/gcc/text-art/dump.h b/gcc/text-art/dump.h index e94f308f8ceec..4659d1424b509 100644 --- a/gcc/text-art/dump.h +++ b/gcc/text-art/dump.h @@ -63,7 +63,7 @@ void dump_to_file (const T &obj, FILE *outf) pp_format_decoder (&pp) = default_tree_printer; if (outf == stderr) pp_show_color (&pp) = pp_show_color (global_dc->printer); - pp.buffer->stream = outf; + pp.set_output_stream (outf); text_art::theme *theme = global_dc->get_diagram_theme (); dump_to_pp (obj, theme, &pp); diff --git a/gcc/text-art/selftests.cc b/gcc/text-art/selftests.cc index 5b4679b0cda1b..2b113b6b01778 100644 --- a/gcc/text-art/selftests.cc +++ b/gcc/text-art/selftests.cc @@ -71,7 +71,7 @@ selftest::assert_canvas_streq (const location &loc, if (styled) { pp_show_color (&pp) = true; - pp.url_format = URL_FORMAT_DEFAULT; + pp.set_url_format (URL_FORMAT_DEFAULT); } assert_canvas_streq (loc, canvas, &pp, expected_str); } diff --git a/gcc/text-art/style.cc b/gcc/text-art/style.cc index 5c58d432cf484..e5e9bdfdf7b7b 100644 --- a/gcc/text-art/style.cc +++ b/gcc/text-art/style.cc @@ -232,7 +232,7 @@ style::print_changes (pretty_printer *pp, { if (!old_style.m_url.empty ()) pp_end_url (pp); - if (pp->url_format != URL_FORMAT_NONE + if (pp->supports_urls_p () && !new_style.m_url.empty ()) { /* Adapted from pp_begin_url, but encoding the @@ -241,7 +241,7 @@ style::print_changes (pretty_printer *pp, pp_string (pp, "\33]8;;"); for (auto ch : new_style.m_url) pp_unicode_character (pp, ch); - switch (pp->url_format) + switch (pp->get_url_format ()) { default: case URL_FORMAT_NONE: diff --git a/gcc/text-art/styled-string.cc b/gcc/text-art/styled-string.cc index 78c65498921a1..988fe8a742aa6 100644 --- a/gcc/text-art/styled-string.cc +++ b/gcc/text-art/styled-string.cc @@ -566,7 +566,7 @@ styled_string::from_fmt_va (style_manager &sm, text_info text (fmt, args, errno); pretty_printer pp; pp_show_color (&pp) = true; - pp.url_format = URL_FORMAT_DEFAULT; + pp.set_url_format (URL_FORMAT_DEFAULT); pp_format_decoder (&pp) = format_decoder; pp_format (&pp, &text); pp_output_formatted_text (&pp); diff --git a/gcc/timevar.def b/gcc/timevar.def index 8e2168e08176e..6fc368591387f 100644 --- a/gcc/timevar.def +++ b/gcc/timevar.def @@ -161,6 +161,7 @@ DEFTIMEVAR (TV_TREE_VRP , "tree VRP") DEFTIMEVAR (TV_TREE_VRP_THREADER , "tree VRP threader") DEFTIMEVAR (TV_TREE_EARLY_VRP , "tree Early VRP") DEFTIMEVAR (TV_TREE_FAST_VRP , "tree Fast VRP") +DEFTIMEVAR (TV_TREE_ARRAY_BOUNDS , "warn array bounds") DEFTIMEVAR (TV_TREE_COPY_PROP , "tree copy propagation") DEFTIMEVAR (TV_FIND_REFERENCED_VARS , "tree find ref. vars") DEFTIMEVAR (TV_TREE_PTA , "tree PTA") diff --git a/gcc/tree-data-ref.cc b/gcc/tree-data-ref.cc index 7b5f2d1623863..bd61069b6316d 100644 --- a/gcc/tree-data-ref.cc +++ b/gcc/tree-data-ref.cc @@ -5868,6 +5868,8 @@ get_references_in_stmt (gimple *stmt, vec *references) clobbers_memory = true; break; } + else if (gimple_call_builtin_p (stmt, BUILT_IN_PREFETCH)) + clobbers_memory = false; else clobbers_memory = true; } diff --git a/gcc/tree-diagnostic.cc b/gcc/tree-diagnostic.cc index a660c7d0785b9..fc78231dfa448 100644 --- a/gcc/tree-diagnostic.cc +++ b/gcc/tree-diagnostic.cc @@ -51,201 +51,6 @@ default_tree_diagnostic_starter (diagnostic_context *context, diagnostic)); } -/* This is a pair made of a location and the line map it originated - from. It's used in the maybe_unwind_expanded_macro_loc function - below. */ -struct loc_map_pair -{ - const line_map_macro *map; - location_t where; -}; - - -/* Unwind the different macro expansions that lead to the token which - location is WHERE and emit diagnostics showing the resulting - unwound macro expansion trace. Let's look at an example to see how - the trace looks like. Suppose we have this piece of code, - artificially annotated with the line numbers to increase - legibility: - - $ cat -n test.c - 1 #define OPERATE(OPRD1, OPRT, OPRD2) \ - 2 OPRD1 OPRT OPRD2; - 3 - 4 #define SHIFTL(A,B) \ - 5 OPERATE (A,<<,B) - 6 - 7 #define MULT(A) \ - 8 SHIFTL (A,1) - 9 - 10 void - 11 g () - 12 { - 13 MULT (1.0);// 1.0 << 1; <-- so this is an error. - 14 } - - Here is the diagnostic that we want the compiler to generate: - - test.c: In function ‘g’: - test.c:5:14: error: invalid operands to binary << (have ‘double’ and ‘int’) - test.c:2:9: note: in definition of macro 'OPERATE' - test.c:8:3: note: in expansion of macro 'SHIFTL' - test.c:13:3: note: in expansion of macro 'MULT' - - The part that goes from the third to the fifth line of this - diagnostic (the lines containing the 'note:' string) is called the - unwound macro expansion trace. That's the part generated by this - function. */ - -void -maybe_unwind_expanded_macro_loc (diagnostic_context *context, - location_t where) -{ - const struct line_map *map; - auto_vec loc_vec; - unsigned ix; - loc_map_pair loc, *iter; - - const location_t original_loc = where; - - map = linemap_lookup (line_table, where); - if (!linemap_macro_expansion_map_p (map)) - return; - - /* Let's unwind the macros that got expanded and led to the token - which location is WHERE. We are going to store these macros into - LOC_VEC, so that we can later walk it at our convenience to - display a somewhat meaningful trace of the macro expansion - history to the user. Note that the first macro of the trace - (which is OPERATE in the example above) is going to be stored at - the beginning of LOC_VEC. */ - - do - { - loc.where = where; - loc.map = linemap_check_macro (map); - - loc_vec.safe_push (loc); - - /* WHERE is the location of a token inside the expansion of a - macro. MAP is the map holding the locations of that macro - expansion. Let's get the location of the token inside the - context that triggered the expansion of this macro. - This is basically how we go "down" in the trace of macro - expansions that led to WHERE. */ - where = linemap_unwind_toward_expansion (line_table, where, &map); - } while (linemap_macro_expansion_map_p (map)); - - /* Now map is set to the map of the location in the source that - first triggered the macro expansion. This must be an ordinary map. */ - const line_map_ordinary *ord_map = linemap_check_ordinary (map); - - /* Walk LOC_VEC and print the macro expansion trace, unless the - first macro which expansion triggered this trace was expanded - inside a system header. */ - int saved_location_line = - expand_location_to_spelling_point (original_loc).line; - - if (!LINEMAP_SYSP (ord_map)) - FOR_EACH_VEC_ELT (loc_vec, ix, iter) - { - /* Sometimes, in the unwound macro expansion trace, we want to - print a part of the context that shows where, in the - definition of the relevant macro, is the token (we are - looking at) used. That is the case in the introductory - comment of this function, where we print: - - test.c:2:9: note: in definition of macro 'OPERATE'. - - We print that "macro definition context" because the - diagnostic line (emitted by the call to - pp_ouput_formatted_text in diagnostic_report_diagnostic): - - test.c:5:14: error: invalid operands to binary << (have ‘double’ and ‘int’) - - does not point into the definition of the macro where the - token '<<' (that is an argument to the function-like macro - OPERATE) is used. So we must "display" the line of that - macro definition context to the user somehow. - - A contrario, when the first interesting diagnostic line - points into the definition of the macro, we don't need to - display any line for that macro definition in the trace - anymore, otherwise it'd be redundant. */ - - /* Okay, now here is what we want. For each token resulting - from macro expansion we want to show: 1/ where in the - definition of the macro the token comes from; 2/ where the - macro got expanded. */ - - /* Resolve the location iter->where into the locus 1/ of the - comment above. */ - location_t resolved_def_loc = - linemap_resolve_location (line_table, iter->where, - LRK_MACRO_DEFINITION_LOCATION, NULL); - - /* Don't print trace for locations that are reserved or from - within a system header. */ - const line_map_ordinary *m = NULL; - location_t l = - linemap_resolve_location (line_table, resolved_def_loc, - LRK_SPELLING_LOCATION, &m); - location_t l0 = l; - if (IS_ADHOC_LOC (l0)) - l0 = get_location_from_adhoc_loc (line_table, l0); - if (l0 < RESERVED_LOCATION_COUNT || LINEMAP_SYSP (m)) - continue; - - /* We need to print the context of the macro definition only - when the locus of the first displayed diagnostic (displayed - before this trace) was inside the definition of the - macro. */ - const int resolved_def_loc_line = SOURCE_LINE (m, l0); - if (ix == 0 && saved_location_line != resolved_def_loc_line) - { - diagnostic_append_note (context, resolved_def_loc, - "in definition of macro %qs", - linemap_map_get_macro_name (iter->map)); - /* At this step, as we've printed the context of the macro - definition, we don't want to print the context of its - expansion, otherwise, it'd be redundant. */ - continue; - } - - /* Resolve the location of the expansion point of the macro - which expansion gave the token represented by def_loc. - This is the locus 2/ of the earlier comment. */ - location_t resolved_exp_loc = - linemap_resolve_location (line_table, - iter->map->get_expansion_point_location (), - LRK_MACRO_DEFINITION_LOCATION, NULL); - - diagnostic_append_note (context, resolved_exp_loc, - "in expansion of macro %qs", - linemap_map_get_macro_name (iter->map)); - } -} - -/* This is a diagnostic finalizer implementation that is aware of - virtual locations produced by libcpp. - - It has to be called by the diagnostic finalizer of front ends that - uses libcpp and wish to get diagnostics involving tokens resulting - from macro expansion. - - For a given location, if said location belongs to a token - resulting from a macro expansion, this starter prints the context - of the token. E.g, for multiply nested macro expansion, it - unwinds the nested macro expansions and prints them in a manner - that is similar to what is done for function call stacks, or - template instantiation contexts. */ -void -virt_loc_aware_diagnostic_finalizer (diagnostic_context *context, - const diagnostic_info *diagnostic) -{ - maybe_unwind_expanded_macro_loc (context, diagnostic_location (diagnostic)); -} - /* Default tree printer. Handles declarations only. */ bool default_tree_printer (pretty_printer *pp, text_info *text, const char *spec, @@ -374,8 +179,6 @@ tree_diagnostics_defaults (diagnostic_context *context) diagnostic_starter (context) = default_tree_diagnostic_starter; diagnostic_finalizer (context) = default_diagnostic_finalizer; diagnostic_format_decoder (context) = default_tree_printer; - context->m_print_path = default_tree_diagnostic_path_printer; - context->m_make_json_for_path = default_tree_make_json_for_path; context->set_set_locations_callback (set_inlining_locations); context->set_client_data_hooks (make_compiler_data_hooks ()); } diff --git a/gcc/tree-diagnostic.h b/gcc/tree-diagnostic.h index 1d13368537a9f..6ebac381ace8d 100644 --- a/gcc/tree-diagnostic.h +++ b/gcc/tree-diagnostic.h @@ -50,19 +50,9 @@ along with GCC; see the file COPYING3. If not see void diagnostic_report_current_function (diagnostic_context *, const diagnostic_info *); -void virt_loc_aware_diagnostic_finalizer (diagnostic_context *, - const diagnostic_info *); void tree_diagnostics_defaults (diagnostic_context *context); bool default_tree_printer (pretty_printer *, text_info *, const char *, int, bool, bool, bool, bool *, const char **); -extern void default_tree_diagnostic_path_printer (diagnostic_context *, - const diagnostic_path *); -extern json::value *default_tree_make_json_for_path (diagnostic_context *, - const diagnostic_path *); - -extern void maybe_unwind_expanded_macro_loc (diagnostic_context *context, - location_t where); - #endif /* ! GCC_TREE_DIAGNOSTIC_H */ diff --git a/gcc/tree-if-conv.cc b/gcc/tree-if-conv.cc index c4c3ed41a4470..57992b6decaf2 100644 --- a/gcc/tree-if-conv.cc +++ b/gcc/tree-if-conv.cc @@ -936,12 +936,11 @@ ifcvt_memrefs_wont_trap (gimple *stmt, vec drs) /* an unconditionaly write won't trap if the base is written to unconditionally. */ - if (base_master_dr - && DR_BASE_W_UNCONDITIONALLY (*base_master_dr)) - return flag_store_data_races; - /* or the base is known to be not readonly. */ - else if (base_object_writable (DR_REF (a))) - return flag_store_data_races; + if ((base_master_dr + && DR_BASE_W_UNCONDITIONALLY (*base_master_dr)) + /* or the base is known to be not readonly. */ + || base_object_writable (DR_REF (a))) + return !ref_can_have_store_data_races (base); } return false; diff --git a/gcc/tree-logical-location.cc b/gcc/tree-logical-location.cc index 0333b3186424b..ca8b34a42d36b 100644 --- a/gcc/tree-logical-location.cc +++ b/gcc/tree-logical-location.cc @@ -25,6 +25,7 @@ along with GCC; see the file COPYING3. If not see #include "pretty-print.h" #include "tree-logical-location.h" #include "langhooks.h" +#include "intl.h" /* class compiler_logical_location : public logical_location. */ @@ -82,6 +83,16 @@ compiler_logical_location::get_kind_for_tree (tree decl) } } +label_text +compiler_logical_location::get_name_for_tree_for_path_output (tree decl) +{ + gcc_assert (decl); + const char *n = DECL_NAME (decl) + ? identifier_to_locale (lang_hooks.decl_printable_name (decl, 2)) + : _(""); + return label_text::borrow (n); +} + /* class tree_logical_location : public compiler_logical_location. */ /* Implementation of the logical_location vfuncs, using m_decl. */ @@ -114,6 +125,13 @@ tree_logical_location::get_kind () const return get_kind_for_tree (m_decl); } +label_text +tree_logical_location::get_name_for_path_output () const +{ + gcc_assert (m_decl); + return get_name_for_tree_for_path_output (m_decl); +} + /* class current_fndecl_logical_location : public compiler_logical_location. */ /* Implementation of the logical_location vfuncs, using @@ -146,3 +164,10 @@ current_fndecl_logical_location::get_kind () const gcc_assert (current_function_decl); return get_kind_for_tree (current_function_decl); } + +label_text +current_fndecl_logical_location::get_name_for_path_output () const +{ + gcc_assert (current_function_decl); + return get_name_for_tree_for_path_output (current_function_decl); +} diff --git a/gcc/tree-logical-location.h b/gcc/tree-logical-location.h index feaad6ed8995d..8634f3a49c03f 100644 --- a/gcc/tree-logical-location.h +++ b/gcc/tree-logical-location.h @@ -33,6 +33,7 @@ class compiler_logical_location : public logical_location static const char *get_name_with_scope_for_tree (tree); static const char *get_internal_name_for_tree (tree); static enum logical_location_kind get_kind_for_tree (tree); + static label_text get_name_for_tree_for_path_output (tree); }; /* Concrete subclass of logical_location, with reference to a specific @@ -47,6 +48,7 @@ class tree_logical_location : public compiler_logical_location const char *get_name_with_scope () const final override; const char *get_internal_name () const final override; enum logical_location_kind get_kind () const final override; + label_text get_name_for_path_output () const final override; private: tree m_decl; @@ -62,6 +64,7 @@ class current_fndecl_logical_location : public compiler_logical_location const char *get_name_with_scope () const final override; const char *get_internal_name () const final override; enum logical_location_kind get_kind () const final override; + label_text get_name_for_path_output () const final override; }; #endif /* GCC_TREE_LOGICAL_LOCATION_H. */ diff --git a/gcc/tree-loop-distribution.cc b/gcc/tree-loop-distribution.cc index 4d1ed234fcbe7..f87393ee94d66 100644 --- a/gcc/tree-loop-distribution.cc +++ b/gcc/tree-loop-distribution.cc @@ -345,9 +345,9 @@ static void dot_rdg_1 (FILE *file, struct graph *rdg) { int i; - pretty_printer buffer; - pp_needs_newline (&buffer) = false; - buffer.buffer->stream = file; + pretty_printer pp; + pp_needs_newline (&pp) = false; + pp.set_output_stream (file); fprintf (file, "digraph RDG {\n"); @@ -357,8 +357,8 @@ dot_rdg_1 (FILE *file, struct graph *rdg) struct graph_edge *e; fprintf (file, "%d [label=\"[%d] ", i, i); - pp_gimple_stmt_1 (&buffer, RDGV_STMT (v), 0, TDF_SLIM); - pp_flush (&buffer); + pp_gimple_stmt_1 (&pp, RDGV_STMT (v), 0, TDF_SLIM); + pp_flush (&pp); fprintf (file, "\"]\n"); /* Highlight reads from memory. */ diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h index 29267589eeb38..edebb2be245d9 100644 --- a/gcc/tree-pass.h +++ b/gcc/tree-pass.h @@ -470,6 +470,7 @@ extern gimple_opt_pass *make_pass_fre (gcc::context *ctxt); extern gimple_opt_pass *make_pass_check_data_deps (gcc::context *ctxt); extern gimple_opt_pass *make_pass_copy_prop (gcc::context *ctxt); extern gimple_opt_pass *make_pass_isolate_erroneous_paths (gcc::context *ctxt); +extern gimple_opt_pass *make_pass_array_bounds (gcc::context *ctxt); extern gimple_opt_pass *make_pass_early_vrp (gcc::context *ctxt); extern gimple_opt_pass *make_pass_fast_vrp (gcc::context *ctxt); extern gimple_opt_pass *make_pass_vrp (gcc::context *ctxt); diff --git a/gcc/tree-pretty-print.cc b/gcc/tree-pretty-print.cc index 601cf215ca844..4bb946bb0e832 100644 --- a/gcc/tree-pretty-print.cc +++ b/gcc/tree-pretty-print.cc @@ -4814,7 +4814,7 @@ maybe_init_pretty_print (FILE *file) pp_translate_identifiers (tree_pp) = false; } - tree_pp->buffer->stream = file; + tree_pp->set_output_stream (file); } static void diff --git a/gcc/tree-pretty-print.h b/gcc/tree-pretty-print.h index 0da6242629b72..c5089f82cf6a3 100644 --- a/gcc/tree-pretty-print.h +++ b/gcc/tree-pretty-print.h @@ -56,6 +56,6 @@ extern void print_call_name (pretty_printer *, tree, dump_flags_t); extern void pp_tree_identifier (pretty_printer *, tree); extern void dump_function_header (FILE *, tree, dump_flags_t); extern void pp_double_int (pretty_printer *pp, double_int d, bool uns); -extern void dump_location (pretty_printer *buffer, location_t loc); +extern void dump_location (pretty_printer *pp, location_t loc); #endif /* ! GCC_TREE_PRETTY_PRINT_H */ diff --git a/gcc/tree-profile.cc b/gcc/tree-profile.cc index b87c121790c99..e4bb689cef589 100644 --- a/gcc/tree-profile.cc +++ b/gcc/tree-profile.cc @@ -2070,7 +2070,8 @@ pass_ipa_tree_profile::gate (function *) disabled. */ return (!in_lto_p && !flag_auto_profile && (flag_branch_probabilities || flag_test_coverage - || profile_arc_flag || condition_coverage_flag)); + || profile_arc_flag || condition_coverage_flag) + && !seen_error ()); } } // anon namespace diff --git a/gcc/tree-ssa-alias.cc b/gcc/tree-ssa-alias.cc index 1a91d63a31ec2..fab048b0b594d 100644 --- a/gcc/tree-ssa-alias.cc +++ b/gcc/tree-ssa-alias.cc @@ -3704,6 +3704,25 @@ stmt_kills_ref_p (gimple *stmt, tree ref) return stmt_kills_ref_p (stmt, &r); } +/* Return whether REF can be subject to store data races. */ + +bool +ref_can_have_store_data_races (tree ref) +{ + /* With -fallow-store-data-races do not care about them. */ + if (flag_store_data_races) + return false; + + tree base = get_base_address (ref); + if (auto_var_p (base) + && ! may_be_aliased (base)) + /* Automatic variables not aliased are not subject to + data races. */ + return false; + + return true; +} + /* Walk the virtual use-def chain of VUSE until hitting the virtual operand TARGET or a statement clobbering the memory reference REF in which diff --git a/gcc/tree-ssa-alias.h b/gcc/tree-ssa-alias.h index 5cd64e722955c..5834533ae9cd4 100644 --- a/gcc/tree-ssa-alias.h +++ b/gcc/tree-ssa-alias.h @@ -144,6 +144,8 @@ extern bool call_may_clobber_ref_p (gcall *, tree, bool = true); extern bool call_may_clobber_ref_p_1 (gcall *, ao_ref *, bool = true); extern bool stmt_kills_ref_p (gimple *, tree); extern bool stmt_kills_ref_p (gimple *, ao_ref *); +extern bool ref_can_have_store_data_races (tree); + enum translate_flags { TR_TRANSLATE, TR_VALUEIZE_AND_DISAMBIGUATE, TR_DISAMBIGUATE }; extern tree get_continuation_for_phi (gimple *, ao_ref *, bool, diff --git a/gcc/tree-ssa-dom.cc b/gcc/tree-ssa-dom.cc index 800bc5a4117eb..221fe6db32187 100644 --- a/gcc/tree-ssa-dom.cc +++ b/gcc/tree-ssa-dom.cc @@ -1437,7 +1437,7 @@ dom_opt_dom_walker::set_global_ranges_from_unreachable_edges (basic_block bb) || (gimple_bb (SSA_NAME_DEF_STMT (name)) == pred_e->src))) { - Value_Range r (TREE_TYPE (name)); + value_range r (TREE_TYPE (name)); if (m_ranger->range_on_edge (r, pred_e, name) && !r.varying_p () @@ -2032,7 +2032,7 @@ cprop_operand (gimple *stmt, use_operand_p op_p, range_query *query) val = SSA_NAME_VALUE (op); if (!val) { - Value_Range r (TREE_TYPE (op)); + value_range r (TREE_TYPE (op)); tree single; if (query->range_of_expr (r, op, stmt) && r.singleton_p (&single)) val = single; diff --git a/gcc/tree-ssa-dse.cc b/gcc/tree-ssa-dse.cc index 9252ca3405000..63bf4491cf6d0 100644 --- a/gcc/tree-ssa-dse.cc +++ b/gcc/tree-ssa-dse.cc @@ -1018,8 +1018,11 @@ dse_classify_store (ao_ref *ref, gimple *stmt, if (defvar == stop_at_vuse) return DSE_STORE_LIVE; - FOR_EACH_IMM_USE_STMT (use_stmt, ui, defvar) + use_operand_p usep; + FOR_EACH_IMM_USE_FAST (usep, ui, defvar) { + use_stmt = USE_STMT (usep); + /* Limit stmt walking. */ if (++cnt > param_dse_max_alias_queries_per_store) { @@ -1031,31 +1034,43 @@ dse_classify_store (ao_ref *ref, gimple *stmt, have to be careful with loops and with memory references containing operands that are also operands of PHI nodes. See gcc.c-torture/execute/20051110-*.c. */ - if (gimple_code (use_stmt) == GIMPLE_PHI) + if (gphi *phi = dyn_cast (use_stmt)) { /* Look through single-argument PHIs. */ - if (gimple_phi_num_args (use_stmt) == 1) - worklist.safe_push (gimple_phi_result (use_stmt)); - - /* If we already visited this PHI ignore it for further - processing. */ - else if (!bitmap_bit_p (visited, - SSA_NAME_VERSION - (PHI_RESULT (use_stmt)))) + if (gimple_phi_num_args (phi) == 1) + worklist.safe_push (gimple_phi_result (phi)); + else { /* If we visit this PHI by following a backedge then we have to make sure ref->ref only refers to SSA names that are invariant with respect to the loop - represented by this PHI node. */ - if (dominated_by_p (CDI_DOMINATORS, gimple_bb (stmt), - gimple_bb (use_stmt)) - && !for_each_index (ref->ref ? &ref->ref : &ref->base, - check_name, gimple_bb (use_stmt))) - return DSE_STORE_LIVE; - defs.safe_push (use_stmt); - if (!first_phi_def) - first_phi_def = as_a (use_stmt); - last_phi_def = as_a (use_stmt); + represented by this PHI node. We handle irreducible + regions by relying on backedge marking and identifying + the head of the (sub-)region. */ + edge e = gimple_phi_arg_edge + (phi, PHI_ARG_INDEX_FROM_USE (usep)); + if (e->flags & EDGE_DFS_BACK) + { + basic_block rgn_head + = nearest_common_dominator (CDI_DOMINATORS, + gimple_bb (phi), + e->src); + if (!for_each_index (ref->ref + ? &ref->ref : &ref->base, + check_name, rgn_head)) + return DSE_STORE_LIVE; + } + /* If we already visited this PHI ignore it for further + processing. But note we have to check each incoming + edge above. */ + if (!bitmap_bit_p (visited, + SSA_NAME_VERSION (PHI_RESULT (phi)))) + { + defs.safe_push (phi); + if (!first_phi_def) + first_phi_def = phi;; + last_phi_def = phi; + } } } /* If the statement is a use the store is not dead. */ @@ -1681,7 +1696,11 @@ pass_dse::execute (function *fun) /* Dead store elimination is fundamentally a reverse program order walk. */ int *rpo = XNEWVEC (int, n_basic_blocks_for_fn (fun) - NUM_FIXED_BLOCKS); - int n = pre_and_rev_post_order_compute_fn (fun, NULL, rpo, false); + auto_bitmap exit_bbs; + bitmap_set_bit (exit_bbs, EXIT_BLOCK); + edge entry = single_succ_edge (ENTRY_BLOCK_PTR_FOR_FN (fun)); + int n = rev_post_order_and_mark_dfs_back_seme (fun, entry, + exit_bbs, false, rpo, NULL); for (int i = n; i != 0; --i) { basic_block bb = BASIC_BLOCK_FOR_FN (fun, rpo[i-1]); diff --git a/gcc/tree-ssa-loop-ch.cc b/gcc/tree-ssa-loop-ch.cc index d7dd3e5459d7c..525eb357858a9 100644 --- a/gcc/tree-ssa-loop-ch.cc +++ b/gcc/tree-ssa-loop-ch.cc @@ -115,13 +115,13 @@ loop_static_stmt_p (class loop *loop, gimple *stmt) { tree type = gimple_range_type (stmt); - if (!type || !Value_Range::supports_type_p (type)) + if (!type || !value_range::supports_type_p (type)) return false; if (!query) query = get_range_query (loop, gimple_bb (stmt), ranger); - Value_Range r (gimple_range_type (stmt)); + value_range r (gimple_range_type (stmt)); if (!query->range_of_stmt (r, stmt)) return false; return r.singleton_p (); diff --git a/gcc/tree-ssa-loop-im.cc b/gcc/tree-ssa-loop-im.cc index f3fda2bd7ce1e..3acbd886a0daa 100644 --- a/gcc/tree-ssa-loop-im.cc +++ b/gcc/tree-ssa-loop-im.cc @@ -2298,7 +2298,7 @@ execute_sm (class loop *loop, im_mem_ref *ref, bool always_stored = ref_always_accessed_p (loop, ref, true); if (maybe_mt && (bb_in_transaction (loop_preheader_edge (loop)->src) - || (! flag_store_data_races && ! always_stored))) + || (ref_can_have_store_data_races (ref->mem.ref) && ! always_stored))) multi_threaded_model_p = true; if (multi_threaded_model_p && !use_other_flag_var) diff --git a/gcc/tree-ssa-loop-niter.cc b/gcc/tree-ssa-loop-niter.cc index 92db9c72ee479..f87731ef8929a 100644 --- a/gcc/tree-ssa-loop-niter.cc +++ b/gcc/tree-ssa-loop-niter.cc @@ -4092,7 +4092,7 @@ record_nonwrapping_iv (class loop *loop, tree base, tree step, gimple *stmt, if (tree_int_cst_sign_bit (step)) { wide_int max; - Value_Range base_range (TREE_TYPE (orig_base)); + value_range base_range (TREE_TYPE (orig_base)); if (get_range_query (cfun)->range_of_expr (base_range, orig_base) && !base_range.undefined_p ()) max = wi::to_wide (base_range.ubound ()); @@ -4115,7 +4115,7 @@ record_nonwrapping_iv (class loop *loop, tree base, tree step, gimple *stmt, else { wide_int min; - Value_Range base_range (TREE_TYPE (orig_base)); + value_range base_range (TREE_TYPE (orig_base)); if (get_range_query (cfun)->range_of_expr (base_range, orig_base) && !base_range.undefined_p ()) min = wi::to_wide (base_range.lbound ()); diff --git a/gcc/tree-ssa-loop-split.cc b/gcc/tree-ssa-loop-split.cc index a6be0cef7b093..68435485b7913 100644 --- a/gcc/tree-ssa-loop-split.cc +++ b/gcc/tree-ssa-loop-split.cc @@ -144,7 +144,7 @@ split_at_bb_p (class loop *loop, basic_block bb, tree *border, affine_iv *iv, value range. */ else { - Value_Range r (TREE_TYPE (op0)); + value_range r (TREE_TYPE (op0)); get_global_range_query ()->range_of_expr (r, op0, stmt); if (!r.varying_p () && !r.undefined_p () && TREE_CODE (op1) == INTEGER_CST) diff --git a/gcc/tree-ssa-math-opts.cc b/gcc/tree-ssa-math-opts.cc index 173b0366f5e8d..5708548872203 100644 --- a/gcc/tree-ssa-math-opts.cc +++ b/gcc/tree-ssa-math-opts.cc @@ -4186,6 +4186,36 @@ match_unsigned_saturation_sub (gimple_stmt_iterator *gsi, gassign *stmt) build_saturation_binary_arith_call (gsi, IFN_SAT_SUB, lhs, ops[0], ops[1]); } +/* + * Try to match saturation unsigned sub. + * [local count: 1073741824]: + * if (x_2(D) > y_3(D)) + * goto ; [50.00%] + * else + * goto ; [50.00%] + * + * [local count: 536870912]: + * _4 = x_2(D) - y_3(D); + * + * [local count: 1073741824]: + * # _1 = PHI <0(2), _4(3)> + * => + * [local count: 1073741824]: + * _1 = .SAT_SUB (x_2(D), y_3(D)); */ +static void +match_unsigned_saturation_sub (gimple_stmt_iterator *gsi, gphi *phi) +{ + if (gimple_phi_num_args (phi) != 2) + return; + + tree ops[2]; + tree phi_result = gimple_phi_result (phi); + + if (gimple_unsigned_integer_sat_sub (phi_result, ops, NULL)) + build_saturation_binary_arith_call (gsi, phi, IFN_SAT_SUB, phi_result, + ops[0], ops[1]); +} + /* Recognize for unsigned x x = y - z; if (x > y) @@ -6102,8 +6132,9 @@ math_opts_dom_walker::after_dom_children (basic_block bb) for (gphi_iterator psi = gsi_start_phis (bb); !gsi_end_p (psi); gsi_next (&psi)) { - gimple_stmt_iterator gsi = gsi_last_bb (bb); + gimple_stmt_iterator gsi = gsi_after_labels (bb); match_unsigned_saturation_add (&gsi, psi.phi ()); + match_unsigned_saturation_sub (&gsi, psi.phi ()); } for (gsi = gsi_after_labels (bb); !gsi_end_p (gsi);) @@ -6129,6 +6160,7 @@ math_opts_dom_walker::after_dom_children (basic_block bb) continue; } match_arith_overflow (&gsi, stmt, code, m_cfg_changed_p); + match_unsigned_saturation_sub (&gsi, as_a (stmt)); break; case PLUS_EXPR: @@ -6167,6 +6199,7 @@ math_opts_dom_walker::after_dom_children (basic_block bb) break; case COND_EXPR: + case BIT_AND_EXPR: match_unsigned_saturation_sub (&gsi, as_a (stmt)); break; diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index 65f63eb0652e0..f05ca727503b0 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -1326,11 +1326,11 @@ value_replacement (basic_block cond_bb, basic_block middle_bb, { /* After the optimization PHI result can have value which it couldn't have previously. */ - Value_Range r (TREE_TYPE (phires)); + value_range r (TREE_TYPE (phires)); if (get_global_range_query ()->range_of_expr (r, phires, phi)) { - Value_Range tmp (carg, carg); + value_range tmp (carg, carg); r.union_ (tmp); reset_flow_sensitive_info (phires); set_range_info (phires, r); @@ -3343,9 +3343,7 @@ cond_store_replacement (basic_block middle_bb, basic_block join_bb, /* If LHS is an access to a local variable without address-taken (or when we allow data races) and known not to trap, we could always safely move down the store. */ - tree base = get_base_address (lhs); - if (!auto_var_p (base) - || (TREE_ADDRESSABLE (base) && !flag_store_data_races) + if (ref_can_have_store_data_races (lhs) || tree_could_trap_p (lhs)) return false; } diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc index 726e9d88b8f42..fbbfa55783399 100644 --- a/gcc/tree-ssa-sccvn.cc +++ b/gcc/tree-ssa-sccvn.cc @@ -1201,14 +1201,8 @@ ao_ref_init_from_vn_reference (ao_ref *ref, case STRING_CST: /* This can show up in ARRAY_REF bases. */ case INTEGER_CST: - *op0_p = op->op0; - op0_p = NULL; - break; - case SSA_NAME: - /* SSA names we have to get at one available since it contains - flow-sensitive info. */ - *op0_p = vn_valueize (op->op0); + *op0_p = op->op0; op0_p = NULL; break; @@ -2731,6 +2725,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, copy_reference_ops_from_ref (lhs, &lhs_ops); valueize_refs_1 (&lhs_ops, &valueized_anything, true); } + vn_context_bb = saved_rpo_bb; ao_ref_init (&lhs_ref, lhs); lhs_ref_ok = true; if (valueized_anything @@ -2739,11 +2734,9 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, ao_ref_base_alias_set (&lhs_ref), TREE_TYPE (lhs), lhs_ops) && !refs_may_alias_p_1 (ref, &lhs_ref, data->tbaa_p)) { - vn_context_bb = saved_rpo_bb; *disambiguate_only = TR_VALUEIZE_AND_DISAMBIGUATE; return NULL; } - vn_context_bb = saved_rpo_bb; /* When the def is a CLOBBER we can optimistically disambiguate against it since any overlap it would be undefined behavior. @@ -3641,19 +3634,13 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, /* Adjust *ref from the new operands. */ ao_ref rhs1_ref; ao_ref_init (&rhs1_ref, rhs1); - basic_block saved_rpo_bb = vn_context_bb; - vn_context_bb = gimple_bb (def_stmt); if (!ao_ref_init_from_vn_reference (&r, force_no_tbaa ? 0 : ao_ref_alias_set (&rhs1_ref), force_no_tbaa ? 0 : ao_ref_base_alias_set (&rhs1_ref), vr->type, vr->operands)) - { - vn_context_bb = saved_rpo_bb; - return (void *)-1; - } - vn_context_bb = saved_rpo_bb; + return (void *)-1; /* This can happen with bitfields. */ if (maybe_ne (ref->size, r.size)) { @@ -3852,14 +3839,8 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, return data->finish (0, 0, val); /* Adjust *ref from the new operands. */ - basic_block saved_rpo_bb = vn_context_bb; - vn_context_bb = gimple_bb (def_stmt); if (!ao_ref_init_from_vn_reference (&r, 0, 0, vr->type, vr->operands)) - { - vn_context_bb = saved_rpo_bb; - return (void *)-1; - } - vn_context_bb = saved_rpo_bb; + return (void *)-1; /* This can happen with bitfields. */ if (maybe_ne (ref->size, r.size)) return (void *)-1; @@ -3947,13 +3928,31 @@ vn_reference_lookup_pieces (tree vuse, alias_set_type set, unsigned limit = param_sccvn_max_alias_queries_per_access; vn_walk_cb_data data (&vr1, NULL_TREE, NULL, kind, true, NULL_TREE, false); + vec ops_for_ref; + if (!valueized_p) + ops_for_ref = vr1.operands; + else + { + /* For ao_ref_from_mem we have to ensure only available SSA names + end up in base and the only convenient way to make this work + for PRE is to re-valueize with that in mind. */ + ops_for_ref.create (operands.length ()); + ops_for_ref.quick_grow (operands.length ()); + memcpy (ops_for_ref.address (), + operands.address (), + sizeof (vn_reference_op_s) + * operands.length ()); + valueize_refs_1 (&ops_for_ref, &valueized_p, true); + } if (ao_ref_init_from_vn_reference (&r, set, base_set, type, - vr1.operands)) + ops_for_ref)) *vnresult = ((vn_reference_t) walk_non_aliased_vuses (&r, vr1.vuse, true, vn_reference_lookup_2, vn_reference_lookup_3, vuse_valueize, limit, &data)); + if (ops_for_ref != shared_lookup_references) + ops_for_ref.release (); gcc_checking_assert (vr1.operands == shared_lookup_references); if (*vnresult && data.same_val @@ -4054,9 +4053,18 @@ vn_reference_lookup (tree op, tree vuse, vn_lookup_kind kind, vn_reference_t wvnresult; ao_ref r; unsigned limit = param_sccvn_max_alias_queries_per_access; + auto_vec ops_for_ref; + if (valueized_anything) + { + copy_reference_ops_from_ref (op, &ops_for_ref); + bool tem; + valueize_refs_1 (&ops_for_ref, &tem, true); + } + /* Make sure to use a valueized reference if we valueized anything. + Otherwise preserve the full reference for advanced TBAA. */ if (!valueized_anything || !ao_ref_init_from_vn_reference (&r, vr1.set, vr1.base_set, - vr1.type, vr1.operands)) + vr1.type, ops_for_ref)) { ao_ref_init (&r, op); /* Record the extra info we're getting from the full ref. */ diff --git a/gcc/tree-ssa-strlen.cc b/gcc/tree-ssa-strlen.cc index d3c7dc3a80f62..ee60909aa21ae 100644 --- a/gcc/tree-ssa-strlen.cc +++ b/gcc/tree-ssa-strlen.cc @@ -215,7 +215,7 @@ get_range (tree val, gimple *stmt, wide_int minmax[2], rvals = get_range_query (cfun); } - Value_Range vr (TREE_TYPE (val)); + value_range vr (TREE_TYPE (val)); if (!rvals->range_of_expr (vr, val, stmt)) return NULL_TREE; diff --git a/gcc/tree-ssa-threadedge.cc b/gcc/tree-ssa-threadedge.cc index 70f269e29fb82..7f82639b8ecc2 100644 --- a/gcc/tree-ssa-threadedge.cc +++ b/gcc/tree-ssa-threadedge.cc @@ -1418,7 +1418,7 @@ hybrid_jt_simplifier::simplify (gimple *stmt, gimple *, basic_block, if (gimple_code (stmt) == GIMPLE_COND || gimple_code (stmt) == GIMPLE_ASSIGN) { - Value_Range r (gimple_range_type (stmt)); + value_range r (gimple_range_type (stmt)); tree ret; if (m_query->range_of_stmt (r, stmt) && r.singleton_p (&ret)) return ret; @@ -1457,7 +1457,7 @@ hybrid_jt_simplifier::compute_exit_dependencies (bitmap dependencies, tree op = gimple_op (stmt, i); if (op && TREE_CODE (op) == SSA_NAME - && Value_Range::supports_type_p (TREE_TYPE (op))) + && value_range::supports_type_p (TREE_TYPE (op))) bitmap_set_bit (dependencies, SSA_NAME_VERSION (op)); } } diff --git a/gcc/tree-ssanames.cc b/gcc/tree-ssanames.cc index 1753a421a0ba6..615d522d0b12c 100644 --- a/gcc/tree-ssanames.cc +++ b/gcc/tree-ssanames.cc @@ -432,7 +432,7 @@ set_range_info (tree name, const vrange &r) return false; } - Value_Range tmp (type); + value_range tmp (type); if (range_info_p (name)) range_info_get_range (name, tmp); else @@ -751,7 +751,7 @@ duplicate_ssa_name_range_info (tree name, tree src) if (range_info_p (src)) { - Value_Range src_range (TREE_TYPE (src)); + value_range src_range (TREE_TYPE (src)); range_info_get_range (src, src_range); range_info_set_range (name, src_range); } diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index ceb92156b5849..eeb75c09e91aa 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -6030,25 +6030,14 @@ vect_create_epilog_for_reduction (loop_vec_info loop_vinfo, tree induc_val = NULL_TREE; tree adjustment_def = NULL; - if (slp_node) - { - /* Optimize: for induction condition reduction, if we can't use zero - for induc_val, use initial_def. */ - if (STMT_VINFO_REDUC_TYPE (reduc_info) == INTEGER_INDUC_COND_REDUCTION) - induc_val = STMT_VINFO_VEC_INDUC_COND_INITIAL_VAL (reduc_info); - /* ??? Coverage for 'else' isn't clear. */ - } + /* Optimize: for induction condition reduction, if we can't use zero + for induc_val, use initial_def. */ + if (STMT_VINFO_REDUC_TYPE (reduc_info) == INTEGER_INDUC_COND_REDUCTION) + induc_val = STMT_VINFO_VEC_INDUC_COND_INITIAL_VAL (reduc_info); + else if (double_reduc) + ; else - { - /* Optimize: for induction condition reduction, if we can't use zero - for induc_val, use initial_def. */ - if (STMT_VINFO_REDUC_TYPE (reduc_info) == INTEGER_INDUC_COND_REDUCTION) - induc_val = STMT_VINFO_VEC_INDUC_COND_INITIAL_VAL (reduc_info); - else if (double_reduc) - ; - else - adjustment_def = STMT_VINFO_REDUC_EPILOGUE_ADJUSTMENT (reduc_info); - } + adjustment_def = STMT_VINFO_REDUC_EPILOGUE_ADJUSTMENT (reduc_info); stmt_vec_info single_live_out_stmt[] = { stmt_info }; array_slice live_out_stmts = single_live_out_stmt; @@ -6854,8 +6843,8 @@ vect_create_epilog_for_reduction (loop_vec_info loop_vinfo, with the original initial value, unless induc_val is the same as initial_def already. */ tree zcompare = make_ssa_name (boolean_type_node); - epilog_stmt = gimple_build_assign (zcompare, EQ_EXPR, new_temp, - induc_val); + epilog_stmt = gimple_build_assign (zcompare, EQ_EXPR, + scalar_results[0], induc_val); gsi_insert_before (&exit_gsi, epilog_stmt, GSI_SAME_STMT); tree initial_def = reduc_info->reduc_initial_values[0]; tree tmp = make_ssa_name (new_scalar_dest); @@ -6873,7 +6862,7 @@ vect_create_epilog_for_reduction (loop_vec_info loop_vinfo, if (adjustment_def) { - gcc_assert (!slp_reduc); + gcc_assert (!slp_reduc || group_size == 1); gimple_seq stmts = NULL; if (double_reduc) { @@ -7215,9 +7204,17 @@ vectorize_fold_left_reduction (loop_vec_info loop_vinfo, tree len = NULL_TREE; tree bias = NULL_TREE; if (LOOP_VINFO_FULLY_MASKED_P (loop_vinfo)) - mask = vect_get_loop_mask (loop_vinfo, gsi, masks, vec_num, vectype_in, i); + { + tree loop_mask = vect_get_loop_mask (loop_vinfo, gsi, masks, + vec_num, vectype_in, i); + if (is_cond_op) + mask = prepare_vec_mask (loop_vinfo, TREE_TYPE (loop_mask), + loop_mask, vec_opmask[i], gsi); + else + mask = loop_mask; + } else if (is_cond_op) - mask = vec_opmask[0]; + mask = vec_opmask[i]; if (LOOP_VINFO_FULLY_WITH_LENGTH_P (loop_vinfo)) { len = vect_get_loop_len (loop_vinfo, gsi, lens, vec_num, vectype_in, @@ -8086,13 +8083,14 @@ vectorizable_reduction (loop_vec_info loop_vinfo, if ((reduction_type == COND_REDUCTION || reduction_type == INTEGER_INDUC_COND_REDUCTION - || reduction_type == CONST_COND_REDUCTION) + || reduction_type == CONST_COND_REDUCTION + || reduction_type == EXTRACT_LAST_REDUCTION) && slp_node && SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node) > 1) { if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, - "multiple types in condition reduction reduction.\n"); + "multiple types in condition reduction.\n"); return false; } @@ -8323,7 +8321,11 @@ vectorizable_reduction (loop_vec_info loop_vinfo, participating. When unrolling we want each unrolled iteration to have its own reduction accumulator since one of the main goals of unrolling a reduction is to reduce the aggregate loop-carried latency. */ - if (ncopies > 1 + if ((ncopies > 1 + || (slp_node + && !REDUC_GROUP_FIRST_ELEMENT (stmt_info) + && SLP_TREE_LANES (slp_node) == 1 + && vect_get_num_copies (loop_vinfo, vectype_in) > 1)) && (STMT_VINFO_RELEVANT (stmt_info) <= vect_used_only_live) && reduc_chain_length == 1 && loop_vinfo->suggested_unroll_factor == 1) @@ -8376,6 +8378,10 @@ vectorizable_reduction (loop_vec_info loop_vinfo, single_defuse_cycle = false; } } + if (dump_enabled_p () && single_defuse_cycle) + dump_printf_loc (MSG_NOTE, vect_location, + "using single def-use cycle for reduction by reducing " + "multiple vectors to one in the loop body\n"); STMT_VINFO_FORCE_SINGLE_CYCLE (reduc_info) = single_defuse_cycle; /* If the reduction stmt is one of the patterns that have lane @@ -8531,9 +8537,8 @@ vect_transform_reduction (loop_vec_info loop_vinfo, { tree vectype_out = STMT_VINFO_VECTYPE (stmt_info); class loop *loop = LOOP_VINFO_LOOP (loop_vinfo); - int i; - int ncopies; - int vec_num; + unsigned ncopies; + unsigned vec_num; stmt_vec_info reduc_info = info_for_reduction (loop_vinfo, stmt_info); gcc_assert (reduc_info->is_reduc_info); @@ -8580,7 +8585,6 @@ vect_transform_reduction (loop_vec_info loop_vinfo, auto_vec vec_oprnds0; auto_vec vec_oprnds1; auto_vec vec_oprnds2; - tree def0; if (dump_enabled_p ()) dump_printf_loc (MSG_NOTE, vect_location, "transform reduction.\n"); @@ -8655,20 +8659,21 @@ vect_transform_reduction (loop_vec_info loop_vinfo, definition. */ if (single_defuse_cycle) { - gcc_assert (!slp_node); - vect_get_vec_defs_for_operand (loop_vinfo, stmt_info, 1, - op.ops[reduc_index], - reduc_index == 0 ? &vec_oprnds0 - : (reduc_index == 1 ? &vec_oprnds1 - : &vec_oprnds2)); + vect_get_vec_defs (loop_vinfo, stmt_info, slp_node, 1, + reduc_index == 0 ? op.ops[0] : NULL_TREE, &vec_oprnds0, + reduc_index == 1 ? op.ops[1] : NULL_TREE, &vec_oprnds1, + reduc_index == 2 ? op.ops[2] : NULL_TREE, + &vec_oprnds2); } bool emulated_mixed_dot_prod = vect_is_emulated_mixed_dot_prod (stmt_info); - FOR_EACH_VEC_ELT (vec_oprnds0, i, def0) + unsigned num = (reduc_index == 0 + ? vec_oprnds1.length () : vec_oprnds0.length ()); + for (unsigned i = 0; i < num; ++i) { gimple *new_stmt; - tree vop[3] = { def0, vec_oprnds1[i], NULL_TREE }; + tree vop[3] = { vec_oprnds0[i], vec_oprnds1[i], NULL_TREE }; if (masked_loop_p && !mask_by_cond_expr) { /* No conditional ifns have been defined for dot-product yet. */ @@ -8723,10 +8728,7 @@ vect_transform_reduction (loop_vec_info loop_vinfo, vect_finish_stmt_generation (loop_vinfo, stmt_info, new_stmt, gsi); } - if (slp_node) - slp_node->push_vec_def (new_stmt); - else if (single_defuse_cycle - && i < ncopies - 1) + if (single_defuse_cycle && i < num - 1) { if (reduc_index == 0) vec_oprnds0.safe_push (gimple_get_lhs (new_stmt)); @@ -8735,6 +8737,8 @@ vect_transform_reduction (loop_vec_info loop_vinfo, else if (reduc_index == 2) vec_oprnds2.safe_push (gimple_get_lhs (new_stmt)); } + else if (slp_node) + slp_node->push_vec_def (new_stmt); else STMT_VINFO_VEC_STMTS (stmt_info).safe_push (new_stmt); } @@ -8798,7 +8802,10 @@ vect_transform_cycle_phi (loop_vec_info loop_vinfo, /* Check whether we should use a single PHI node and accumulate vectors to one before the backedge. */ if (STMT_VINFO_FORCE_SINGLE_CYCLE (reduc_info)) - ncopies = 1; + { + ncopies = 1; + vec_num = 1; + } /* Create the destination vector */ gphi *phi = as_a (stmt_info->stmt); @@ -12188,8 +12195,10 @@ vect_transform_loop (loop_vec_info loop_vinfo, gimple *loop_vectorized_call) !gsi_end_p (si);) { stmt = gsi_stmt (si); - /* During vectorization remove existing clobber stmts. */ - if (gimple_clobber_p (stmt)) + /* During vectorization remove existing clobber stmts and + prefetches. */ + if (gimple_clobber_p (stmt) + || gimple_call_builtin_p (stmt, BUILT_IN_PREFETCH)) { unlink_stmt_vdef (stmt); gsi_remove (&si, true); diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index 7e3d0107b4e71..7d18b5bfee5d2 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -9669,6 +9669,7 @@ vect_schedule_slp_node (vec_info *vinfo, si = gsi_after_labels (vinfo->bbs[0]); } else if (is_a (vinfo) + && SLP_TREE_CODE (node) != VEC_PERM_EXPR && gimple_bb (last_stmt) != gimple_bb (stmt_info->stmt) && gimple_could_trap_p (stmt_info->stmt)) { diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 5098b7fab6a8d..ca6052662a305 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -1643,7 +1643,7 @@ check_load_store_for_partial_vectors (loop_vec_info loop_vinfo, tree vectype, MASK_TYPE is the type of both masks. If new statements are needed, insert them before GSI. */ -static tree +tree prepare_vec_mask (loop_vec_info loop_vinfo, tree mask_type, tree loop_mask, tree vec_mask, gimple_stmt_iterator *gsi) { @@ -2036,17 +2036,42 @@ get_group_load_store_type (vec_info *vinfo, stmt_vec_info stmt_info, first_dr_info = STMT_VINFO_DR_INFO (SLP_TREE_SCALAR_STMTS (slp_node)[0]); if (STMT_VINFO_STRIDED_P (first_stmt_info)) - { - /* Try to use consecutive accesses of DR_GROUP_SIZE elements, - separated by the stride, until we have a complete vector. - Fall back to scalar accesses if that isn't possible. */ - if (multiple_p (nunits, group_size)) - *memory_access_type = VMAT_STRIDED_SLP; - else - *memory_access_type = VMAT_ELEMENTWISE; - } + /* Try to use consecutive accesses of as many elements as possible, + separated by the stride, until we have a complete vector. + Fall back to scalar accesses if that isn't possible. */ + *memory_access_type = VMAT_STRIDED_SLP; else { + int cmp = compare_step_with_zero (vinfo, stmt_info); + if (cmp < 0) + { + if (single_element_p) + /* ??? The VMAT_CONTIGUOUS_REVERSE code generation is + only correct for single element "interleaving" SLP. */ + *memory_access_type = get_negative_load_store_type + (vinfo, stmt_info, vectype, vls_type, 1, poffset); + else + { + /* Try to use consecutive accesses of DR_GROUP_SIZE elements, + separated by the stride, until we have a complete vector. + Fall back to scalar accesses if that isn't possible. */ + if (multiple_p (nunits, group_size)) + *memory_access_type = VMAT_STRIDED_SLP; + else + *memory_access_type = VMAT_ELEMENTWISE; + } + } + else if (cmp == 0 && loop_vinfo) + { + gcc_assert (vls_type == VLS_LOAD); + *memory_access_type = VMAT_INVARIANT; + /* Invariant accesses perform only component accesses, alignment + is irrelevant for them. */ + *alignment_support_scheme = dr_unaligned_supported; + } + else + *memory_access_type = VMAT_CONTIGUOUS; + overrun_p = loop_vinfo && gap != 0; if (overrun_p && vls_type != VLS_LOAD) { @@ -2065,6 +2090,21 @@ get_group_load_store_type (vec_info *vinfo, stmt_vec_info stmt_info, / vect_get_scalar_dr_size (first_dr_info))) overrun_p = false; + /* When we have a contiguous access across loop iterations + but the access in the loop doesn't cover the full vector + we can end up with no gap recorded but still excess + elements accessed, see PR103116. Make sure we peel for + gaps if necessary and sufficient and give up if not. + + If there is a combination of the access not covering the full + vector and a gap recorded then we may need to peel twice. */ + if (loop_vinfo + && *memory_access_type == VMAT_CONTIGUOUS + && SLP_TREE_LOAD_PERMUTATION (slp_node).exists () + && !multiple_p (group_size * LOOP_VINFO_VECT_FACTOR (loop_vinfo), + nunits)) + overrun_p = true; + /* If the gap splits the vector in half and the target can do half-vector operations avoid the epilogue peeling by simply loading half of the vector only. Usually @@ -2097,60 +2137,28 @@ get_group_load_store_type (vec_info *vinfo, stmt_vec_info stmt_info, "Peeling for outer loop is not supported\n"); return false; } - int cmp = compare_step_with_zero (vinfo, stmt_info); - if (cmp < 0) - { - if (single_element_p) - /* ??? The VMAT_CONTIGUOUS_REVERSE code generation is - only correct for single element "interleaving" SLP. */ - *memory_access_type = get_negative_load_store_type - (vinfo, stmt_info, vectype, vls_type, 1, poffset); - else - { - /* Try to use consecutive accesses of DR_GROUP_SIZE elements, - separated by the stride, until we have a complete vector. - Fall back to scalar accesses if that isn't possible. */ - if (multiple_p (nunits, group_size)) - *memory_access_type = VMAT_STRIDED_SLP; - else - *memory_access_type = VMAT_ELEMENTWISE; - } - } - else if (cmp == 0 && loop_vinfo) - { - gcc_assert (vls_type == VLS_LOAD); - *memory_access_type = VMAT_INVARIANT; - /* Invariant accesses perform only component accesses, alignment - is irrelevant for them. */ - *alignment_support_scheme = dr_unaligned_supported; - } - else - *memory_access_type = VMAT_CONTIGUOUS; - - /* When we have a contiguous access across loop iterations - but the access in the loop doesn't cover the full vector - we can end up with no gap recorded but still excess - elements accessed, see PR103116. Make sure we peel for - gaps if necessary and sufficient and give up if not. - - If there is a combination of the access not covering the full - vector and a gap recorded then we may need to peel twice. */ - if (loop_vinfo - && *memory_access_type == VMAT_CONTIGUOUS - && SLP_TREE_LOAD_PERMUTATION (slp_node).exists () - && !multiple_p (group_size * LOOP_VINFO_VECT_FACTOR (loop_vinfo), - nunits)) - { - unsigned HOST_WIDE_INT cnunits, cvf; - if (!can_overrun_p - || !nunits.is_constant (&cnunits) + /* Peeling for gaps assumes that a single scalar iteration + is enough to make sure the last vector iteration doesn't + access excess elements. */ + if (overrun_p + && (!can_div_trunc_p (group_size + * LOOP_VINFO_VECT_FACTOR (loop_vinfo) - gap, + nunits, &tem, &remain) + || maybe_lt (remain + group_size, nunits))) + { + /* But peeling a single scalar iteration is enough if + we can use the next power-of-two sized partial + access and that is sufficiently small to be covered + by the single scalar iteration. */ + unsigned HOST_WIDE_INT cnunits, cvf, cremain, cpart_size; + if (!nunits.is_constant (&cnunits) || !LOOP_VINFO_VECT_FACTOR (loop_vinfo).is_constant (&cvf) - /* Peeling for gaps assumes that a single scalar iteration - is enough to make sure the last vector iteration doesn't - access excess elements. - ??? Enhancements include peeling multiple iterations - or using masked loads with a static mask. */ - || (group_size * cvf) % cnunits + group_size - gap < cnunits) + || (((cremain = group_size * cvf - gap % cnunits), true) + && ((cpart_size = (1 << ceil_log2 (cremain))) != cnunits) + && (cremain + group_size < cpart_size + || vector_vector_composition_type + (vectype, cnunits / cpart_size, + &half_vtype) == NULL_TREE))) { if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, @@ -2158,7 +2166,6 @@ get_group_load_store_type (vec_info *vinfo, stmt_vec_info stmt_info, "access\n"); return false; } - overrun_p = true; } /* If this is single-element interleaving with an element @@ -8496,12 +8503,29 @@ vectorizable_store (vec_info *vinfo, tree lvectype = vectype; if (slp) { - if (group_size < const_nunits - && const_nunits % group_size == 0) + HOST_WIDE_INT n = gcd (group_size, const_nunits); + if (n == const_nunits) { - nstores = const_nunits / group_size; - lnel = group_size; - ltype = build_vector_type (elem_type, group_size); + int mis_align = dr_misalignment (first_dr_info, vectype); + dr_alignment_support dr_align + = vect_supportable_dr_alignment (vinfo, dr_info, vectype, + mis_align); + if (dr_align == dr_aligned + || dr_align == dr_unaligned_supported) + { + nstores = 1; + lnel = const_nunits; + ltype = vectype; + lvectype = vectype; + alignment_support_scheme = dr_align; + misalignment = mis_align; + } + } + else if (n > 1) + { + nstores = const_nunits / n; + lnel = n; + ltype = build_vector_type (elem_type, n); lvectype = vectype; /* First check if vec_extract optab doesn't support extraction @@ -8510,7 +8534,7 @@ vectorizable_store (vec_info *vinfo, machine_mode vmode; if (!VECTOR_MODE_P (TYPE_MODE (vectype)) || !related_vector_mode (TYPE_MODE (vectype), elmode, - group_size).exists (&vmode) + n).exists (&vmode) || (convert_optab_handler (vec_extract_optab, TYPE_MODE (vectype), vmode) == CODE_FOR_nothing)) @@ -8521,8 +8545,8 @@ vectorizable_store (vec_info *vinfo, re-interpreting it as the original vector type if supported. */ unsigned lsize - = group_size * GET_MODE_BITSIZE (elmode); - unsigned int lnunits = const_nunits / group_size; + = n * GET_MODE_BITSIZE (elmode); + unsigned int lnunits = const_nunits / n; /* If we can't construct such a vector fall back to element extracts from the original vector type and element size stores. */ @@ -8535,7 +8559,7 @@ vectorizable_store (vec_info *vinfo, != CODE_FOR_nothing)) { nstores = lnunits; - lnel = group_size; + lnel = n; ltype = build_nonstandard_integer_type (lsize, 1); lvectype = build_vector_type (ltype, nstores); } @@ -8546,24 +8570,6 @@ vectorizable_store (vec_info *vinfo, issue exists here for reasonable archs. */ } } - else if (group_size >= const_nunits - && group_size % const_nunits == 0) - { - int mis_align = dr_misalignment (first_dr_info, vectype); - dr_alignment_support dr_align - = vect_supportable_dr_alignment (vinfo, dr_info, vectype, - mis_align); - if (dr_align == dr_aligned - || dr_align == dr_unaligned_supported) - { - nstores = 1; - lnel = const_nunits; - ltype = vectype; - lvectype = vectype; - alignment_support_scheme = dr_align; - misalignment = mis_align; - } - } ltype = build_aligned_type (ltype, TYPE_ALIGN (elem_type)); ncopies = SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node); } @@ -10343,34 +10349,32 @@ vectorizable_load (vec_info *vinfo, auto_vec dr_chain; if (memory_access_type == VMAT_STRIDED_SLP) { - if (group_size < const_nunits) + HOST_WIDE_INT n = gcd (group_size, const_nunits); + /* Use the target vector type if the group size is a multiple + of it. */ + if (n == const_nunits) + { + nloads = 1; + lnel = const_nunits; + ltype = vectype; + } + /* Else use the biggest vector we can load the group without + accessing excess elements. */ + else if (n > 1) { - /* First check if vec_init optab supports construction from vector - elts directly. Otherwise avoid emitting a constructor of - vector elements by performing the loads using an integer type - of the same size, constructing a vector of those and then - re-interpreting it as the original vector type. This avoids a - huge runtime penalty due to the general inability to perform - store forwarding from smaller stores to a larger load. */ tree ptype; tree vtype - = vector_vector_composition_type (vectype, - const_nunits / group_size, + = vector_vector_composition_type (vectype, const_nunits / n, &ptype); if (vtype != NULL_TREE) { - nloads = const_nunits / group_size; - lnel = group_size; + nloads = const_nunits / n; + lnel = n; lvectype = vtype; ltype = ptype; } } - else - { - nloads = 1; - lnel = const_nunits; - ltype = vectype; - } + /* Else fall back to the default element-wise access. */ ltype = build_aligned_type (ltype, TYPE_ALIGN (TREE_TYPE (vectype))); } /* Load vector(1) scalar_type if it's 1 element-wise vectype. */ @@ -11587,6 +11591,27 @@ vectorizable_load (vec_info *vinfo, gcc_assert (new_vtype || LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo)); + /* But still reduce the access size to the next + required power-of-two so peeling a single + scalar iteration is sufficient. */ + unsigned HOST_WIDE_INT cremain; + if (remain.is_constant (&cremain)) + { + unsigned HOST_WIDE_INT cpart_size + = 1 << ceil_log2 (cremain); + if (known_gt (nunits, cpart_size) + && constant_multiple_p (nunits, cpart_size, + &num)) + { + tree ptype; + new_vtype + = vector_vector_composition_type (vectype, + num, + &ptype); + if (new_vtype) + ltype = ptype; + } + } } } tree offset @@ -12415,6 +12440,9 @@ vectorizable_condition (vec_info *vinfo, reduction_type != EXTRACT_LAST_REDUCTION ? else_clause : NULL, vectype, &vec_oprnds3); + if (reduction_type == EXTRACT_LAST_REDUCTION) + vec_else_clause = else_clause; + /* Arguments are ready. Create the new vector stmt. */ FOR_EACH_VEC_ELT (vec_oprnds0, i, vec_cond_lhs) { @@ -12557,17 +12585,24 @@ vectorizable_condition (vec_info *vinfo, { gimple *old_stmt = vect_orig_stmt (stmt_info)->stmt; tree lhs = gimple_get_lhs (old_stmt); + if ((unsigned)i != vec_oprnds0.length () - 1) + lhs = copy_ssa_name (lhs); if (len) new_stmt = gimple_build_call_internal - (IFN_LEN_FOLD_EXTRACT_LAST, 5, else_clause, vec_compare, - vec_then_clause, len, bias); + (IFN_LEN_FOLD_EXTRACT_LAST, 5, vec_else_clause, vec_compare, + vec_then_clause, len, bias); else new_stmt = gimple_build_call_internal - (IFN_FOLD_EXTRACT_LAST, 3, else_clause, vec_compare, - vec_then_clause); + (IFN_FOLD_EXTRACT_LAST, 3, vec_else_clause, vec_compare, + vec_then_clause); gimple_call_set_lhs (new_stmt, lhs); SSA_NAME_DEF_STMT (lhs) = new_stmt; - if (old_stmt == gsi_stmt (*gsi)) + if ((unsigned)i != vec_oprnds0.length () - 1) + { + vect_finish_stmt_generation (vinfo, stmt_info, new_stmt, gsi); + vec_else_clause = lhs; + } + else if (old_stmt == gsi_stmt (*gsi)) vect_finish_replace_stmt (vinfo, stmt_info, new_stmt); else { diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index 97ec9c341e7d0..6bb0f5c3a56f6 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -2508,6 +2508,9 @@ extern void vect_free_slp_tree (slp_tree); extern bool compatible_calls_p (gcall *, gcall *); extern int vect_slp_child_index_for_operand (const gimple *, int op, bool); +extern tree prepare_vec_mask (loop_vec_info, tree, tree, tree, + gimple_stmt_iterator *); + /* In tree-vect-patterns.cc. */ extern void vect_mark_pattern_stmts (vec_info *, stmt_vec_info, gimple *, tree); diff --git a/gcc/tree-vrp.cc b/gcc/tree-vrp.cc index 1c7b451d8fb12..5f5eb9b57e94f 100644 --- a/gcc/tree-vrp.cc +++ b/gcc/tree-vrp.cc @@ -223,7 +223,7 @@ remove_unreachable::handle_early (gimple *s, edge e) // Set the global value for each. FOR_EACH_GORI_EXPORT_NAME (m_ranger.gori_ssa (), e->src, name) { - Value_Range r (TREE_TYPE (name)); + value_range r (TREE_TYPE (name)); m_ranger.range_on_entry (r, e->dest, name); // Nothing at this late stage we can do if the write fails. if (!set_range_info (name, r)) @@ -333,8 +333,8 @@ remove_unreachable::remove_and_update_globals () FOR_EACH_GORI_EXPORT_NAME (m_ranger.gori_ssa (), e->src, name) { // Ensure the cache is set for NAME in the succ block. - Value_Range r(TREE_TYPE (name)); - Value_Range ex(TREE_TYPE (name)); + value_range r(TREE_TYPE (name)); + value_range ex(TREE_TYPE (name)); m_ranger.range_on_entry (r, e->dest, name); m_ranger.range_on_entry (ex, EXIT_BLOCK_PTR_FOR_FN (cfun), name); // If the range produced by this __builtin_unreachacble expression @@ -381,8 +381,8 @@ remove_unreachable::remove_and_update_globals () name = ssa_name (i); if (!name || SSA_NAME_IN_FREE_LIST (name)) continue; - Value_Range r (TREE_TYPE (name)); - Value_Range exp_range (TREE_TYPE (name)); + value_range r (TREE_TYPE (name)); + value_range exp_range (TREE_TYPE (name)); r.set_undefined (); FOR_EACH_IMM_USE_FAST (use_p, iter, name) { @@ -1095,8 +1095,7 @@ class rvrp_folder : public substitute_and_fold_engine from anywhere to perform a VRP pass, including from EVRP. */ unsigned int -execute_ranger_vrp (struct function *fun, bool warn_array_bounds_p, - bool final_p) +execute_ranger_vrp (struct function *fun, bool final_p) { loop_optimizer_init (LOOPS_NORMAL | LOOPS_HAVE_RECORDED_EXITS); rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa); @@ -1113,28 +1112,7 @@ execute_ranger_vrp (struct function *fun, bool warn_array_bounds_p, if (dump_file && (dump_flags & TDF_DETAILS)) ranger->dump (dump_file); - if ((warn_array_bounds || warn_strict_flex_arrays) && warn_array_bounds_p) - { - // Set all edges as executable, except those ranger says aren't. - int non_exec_flag = ranger->non_executable_edge_flag; - basic_block bb; - FOR_ALL_BB_FN (bb, fun) - { - edge_iterator ei; - edge e; - FOR_EACH_EDGE (e, ei, bb->succs) - if (e->flags & non_exec_flag) - e->flags &= ~EDGE_EXECUTABLE; - else - e->flags |= EDGE_EXECUTABLE; - } - scev_reset (); - array_bounds_checker array_checker (fun, ranger); - array_checker.check (); - } - - - if (Value_Range::supports_type_p (TREE_TYPE + if (value_range::supports_type_p (TREE_TYPE (TREE_TYPE (current_function_decl))) && flag_ipa_vrp && !lookup_attribute ("noipa", DECL_ATTRIBUTES (current_function_decl))) @@ -1142,7 +1120,7 @@ execute_ranger_vrp (struct function *fun, bool warn_array_bounds_p, edge e; edge_iterator ei; bool found = false; - Value_Range return_range (TREE_TYPE (TREE_TYPE (current_function_decl))); + value_range return_range (TREE_TYPE (TREE_TYPE (current_function_decl))); FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR_FOR_FN (cfun)->preds) if (greturn *ret = dyn_cast (*gsi_last_bb (e->src))) { @@ -1153,7 +1131,7 @@ execute_ranger_vrp (struct function *fun, bool warn_array_bounds_p, found = true; continue; } - Value_Range r (TREE_TYPE (retval)); + value_range r (TREE_TYPE (retval)); if (ranger->range_of_expr (r, retval, ret) && !r.undefined_p () && !r.varying_p ()) @@ -1230,7 +1208,7 @@ class fvrp_folder : public substitute_and_fold_engine tree name = gimple_range_ssa_p (PHI_RESULT (psi.phi ())); if (name) { - Value_Range vr(TREE_TYPE (name)); + value_range vr(TREE_TYPE (name)); m_dom_ranger->range_of_stmt (vr, psi.phi (), name); } } @@ -1247,7 +1225,7 @@ class fvrp_folder : public substitute_and_fold_engine tree type = gimple_range_type (s); if (type) { - Value_Range vr(type); + value_range vr(type); m_dom_ranger->range_of_stmt (vr, s); } } @@ -1330,14 +1308,13 @@ const pass_data pass_data_fast_vrp = class pass_vrp : public gimple_opt_pass { public: - pass_vrp (gcc::context *ctxt, const pass_data &data_, bool warn_p) - : gimple_opt_pass (data_, ctxt), data (data_), - warn_array_bounds_p (warn_p), final_p (false) + pass_vrp (gcc::context *ctxt, const pass_data &data_) + : gimple_opt_pass (data_, ctxt), data (data_), final_p (false) { } /* opt_pass methods: */ opt_pass * clone () final override - { return new pass_vrp (m_ctxt, data, false); } + { return new pass_vrp (m_ctxt, data); } void set_pass_param (unsigned int n, bool param) final override { gcc_assert (n == 0); @@ -1350,12 +1327,11 @@ class pass_vrp : public gimple_opt_pass if (&data == &pass_data_fast_vrp) return execute_fast_vrp (fun); - return execute_ranger_vrp (fun, warn_array_bounds_p, final_p); + return execute_ranger_vrp (fun, final_p); } private: const pass_data &data; - bool warn_array_bounds_p; bool final_p; }; // class pass_vrp @@ -1393,9 +1369,9 @@ class pass_assumptions : public gimple_opt_pass if (!name || !gimple_range_ssa_p (name)) continue; tree type = TREE_TYPE (name); - if (!Value_Range::supports_type_p (type)) + if (!value_range::supports_type_p (type)) continue; - Value_Range assume_range (type); + value_range assume_range (type); if (query.assume_range_p (assume_range, name)) { // Set the global range of NAME to anything calculated. @@ -1426,19 +1402,19 @@ class pass_assumptions : public gimple_opt_pass gimple_opt_pass * make_pass_vrp (gcc::context *ctxt) { - return new pass_vrp (ctxt, pass_data_vrp, true); + return new pass_vrp (ctxt, pass_data_vrp); } gimple_opt_pass * make_pass_early_vrp (gcc::context *ctxt) { - return new pass_vrp (ctxt, pass_data_early_vrp, false); + return new pass_vrp (ctxt, pass_data_early_vrp); } gimple_opt_pass * make_pass_fast_vrp (gcc::context *ctxt) { - return new pass_vrp (ctxt, pass_data_fast_vrp, false); + return new pass_vrp (ctxt, pass_data_fast_vrp); } gimple_opt_pass * diff --git a/gcc/value-query.cc b/gcc/value-query.cc index 556a0f39b0944..0a280be580bca 100644 --- a/gcc/value-query.cc +++ b/gcc/value-query.cc @@ -74,10 +74,10 @@ range_query::value_of_expr (tree expr, gimple *stmt) { tree t; - if (!Value_Range::supports_type_p (TREE_TYPE (expr))) + if (!value_range::supports_type_p (TREE_TYPE (expr))) return NULL_TREE; - Value_Range r (TREE_TYPE (expr)); + value_range r (TREE_TYPE (expr)); if (range_of_expr (r, expr, stmt)) { @@ -99,9 +99,9 @@ range_query::value_on_edge (edge e, tree expr) { tree t; - if (!Value_Range::supports_type_p (TREE_TYPE (expr))) + if (!value_range::supports_type_p (TREE_TYPE (expr))) return NULL_TREE; - Value_Range r (TREE_TYPE (expr)); + value_range r (TREE_TYPE (expr)); if (range_on_edge (r, e, expr)) { // A constant used in an unreachable block often returns as UNDEFINED. @@ -127,9 +127,9 @@ range_query::value_of_stmt (gimple *stmt, tree name) gcc_checking_assert (!name || name == gimple_get_lhs (stmt)); - if (!name || !Value_Range::supports_type_p (TREE_TYPE (name))) + if (!name || !value_range::supports_type_p (TREE_TYPE (name))) return NULL_TREE; - Value_Range r (TREE_TYPE (name)); + value_range r (TREE_TYPE (name)); if (range_of_stmt (r, stmt, name) && r.singleton_p (&t)) return t; return NULL_TREE; @@ -144,10 +144,10 @@ range_query::value_on_entry (basic_block bb, tree expr) tree t; gcc_checking_assert (bb); - if (!Value_Range::supports_type_p (TREE_TYPE (expr))) + if (!value_range::supports_type_p (TREE_TYPE (expr))) return NULL_TREE; - Value_Range r (TREE_TYPE (expr)); + value_range r (TREE_TYPE (expr)); if (range_on_entry (r, bb, expr) && r.singleton_p (&t)) return t; @@ -163,10 +163,10 @@ range_query::value_on_exit (basic_block bb, tree expr) tree t; gcc_checking_assert (bb); - if (!Value_Range::supports_type_p (TREE_TYPE (expr))) + if (!value_range::supports_type_p (TREE_TYPE (expr))) return NULL_TREE; - Value_Range r (TREE_TYPE (expr)); + value_range r (TREE_TYPE (expr)); if (range_on_exit (r, bb, expr) && r.singleton_p (&t)) return t; @@ -317,7 +317,7 @@ range_query::get_tree_range (vrange &r, tree expr, gimple *stmt, else type = TREE_TYPE (expr); - if (!Value_Range::supports_type_p (type)) + if (!value_range::supports_type_p (type)) { r.set_undefined (); return false; @@ -381,13 +381,13 @@ range_query::get_tree_range (vrange &r, tree expr, gimple *stmt, tree op0 = TREE_OPERAND (expr, 0); tree op1 = TREE_OPERAND (expr, 1); if (COMPARISON_CLASS_P (expr) - && !Value_Range::supports_type_p (TREE_TYPE (op0))) + && !value_range::supports_type_p (TREE_TYPE (op0))) return false; range_op_handler op (TREE_CODE (expr)); if (op) { - Value_Range r0 (TREE_TYPE (op0)); - Value_Range r1 (TREE_TYPE (op1)); + value_range r0 (TREE_TYPE (op0)); + value_range r1 (TREE_TYPE (op1)); invoke_range_of_expr (r0, op0, stmt, bbentry, bbexit); invoke_range_of_expr (r1, op1, stmt, bbentry, bbexit); if (!op.fold_range (r, type, r0, r1)) @@ -401,10 +401,10 @@ range_query::get_tree_range (vrange &r, tree expr, gimple *stmt, { range_op_handler op (TREE_CODE (expr)); tree op0_type = TREE_TYPE (TREE_OPERAND (expr, 0)); - if (op && Value_Range::supports_type_p (op0_type)) + if (op && value_range::supports_type_p (op0_type)) { - Value_Range r0 (TREE_TYPE (TREE_OPERAND (expr, 0))); - Value_Range r1 (type); + value_range r0 (TREE_TYPE (TREE_OPERAND (expr, 0))); + value_range r1 (type); r1.set_varying (type); invoke_range_of_expr (r0, TREE_OPERAND (expr, 0), stmt, bbentry, bbexit); diff --git a/gcc/value-range-storage.cc b/gcc/value-range-storage.cc index 8e8d61d593504..d3d98f98d7b19 100644 --- a/gcc/value-range-storage.cc +++ b/gcc/value-range-storage.cc @@ -186,7 +186,7 @@ vrange_storage::set_vrange (const vrange &r) && !is_a (r) && !r.undefined_p ()) { - Value_Range tmp (r); + value_range tmp (r); get_vrange (tmp, r.type ()); gcc_checking_assert (tmp == r); } diff --git a/gcc/value-range.cc b/gcc/value-range.cc index dbb4f81ae3c4a..9c3eb78459dde 100644 --- a/gcc/value-range.cc +++ b/gcc/value-range.cc @@ -62,7 +62,7 @@ irange::accept (const vrange_visitor &v) const } void -Value_Range::dump (FILE *out) const +value_range::dump (FILE *out) const { if (m_vrange) m_vrange->dump (out); @@ -71,7 +71,7 @@ Value_Range::dump (FILE *out) const } DEBUG_FUNCTION void -debug (const Value_Range &r) +debug (const value_range &r) { r.dump (stderr); fprintf (stderr, "\n"); @@ -282,23 +282,23 @@ vrange::operator== (const vrange &src) const void vrange::dump (FILE *file) const { - pretty_printer buffer; - pp_needs_newline (&buffer) = true; - buffer.buffer->stream = file; - vrange_printer vrange_pp (&buffer); + pretty_printer pp; + pp_needs_newline (&pp) = true; + pp.set_output_stream (file); + vrange_printer vrange_pp (&pp); this->accept (vrange_pp); - pp_flush (&buffer); + pp_flush (&pp); } void irange_bitmask::dump (FILE *file) const { char buf[WIDE_INT_PRINT_BUFFER_SIZE], *p; - pretty_printer buffer; + pretty_printer pp; - pp_needs_newline (&buffer) = true; - buffer.buffer->stream = file; - pp_string (&buffer, "MASK "); + pp_needs_newline (&pp) = true; + pp.set_output_stream (file); + pp_string (&pp, "MASK "); unsigned len_mask, len_val; if (print_hex_buf_size (m_mask, &len_mask) | print_hex_buf_size (m_value, &len_val)) @@ -306,11 +306,11 @@ irange_bitmask::dump (FILE *file) const else p = buf; print_hex (m_mask, p); - pp_string (&buffer, p); - pp_string (&buffer, " VALUE "); + pp_string (&pp, p); + pp_string (&pp, " VALUE "); print_hex (m_value, p); - pp_string (&buffer, p); - pp_flush (&buffer); + pp_string (&pp, p); + pp_flush (&pp); } namespace inchash diff --git a/gcc/value-range.h b/gcc/value-range.h index 3cc15d5151697..4a8d69f340841 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -58,7 +58,7 @@ enum value_range_discriminator // Abstract class for ranges of any of the supported types. // // To query what types ranger and the entire ecosystem can support, -// use Value_Range::supports_type_p(tree type). This is a static +// use value_range::supports_type_p(tree type). This is a static // method available independently of any vrange object. // // To query what a given vrange variant can support, use: @@ -77,7 +77,7 @@ enum value_range_discriminator class vrange { template friend bool is_a (vrange &); - friend class Value_Range; + friend class value_range; friend void streamer_write_vrange (struct output_block *, const vrange &); friend class range_op_handler; public: @@ -753,20 +753,20 @@ class vrange_visitor // object to a function accepting a vrange, the correct type must be // set. If it isn't, you can do so with set_type(). -class Value_Range +class value_range { public: - Value_Range (); - Value_Range (const vrange &r); - Value_Range (tree type); - Value_Range (tree, tree, value_range_kind kind = VR_RANGE); - Value_Range (const Value_Range &); - ~Value_Range (); + value_range (); + value_range (const vrange &r); + value_range (tree type); + value_range (tree, tree, value_range_kind kind = VR_RANGE); + value_range (const value_range &); + ~value_range (); void set_type (tree type); vrange& operator= (const vrange &); - Value_Range& operator= (const Value_Range &); - bool operator== (const Value_Range &r) const; - bool operator!= (const Value_Range &r) const; + value_range& operator= (const value_range &); + bool operator== (const value_range &r) const; + bool operator!= (const value_range &r) const; operator vrange &(); operator const vrange &() const; void dump (FILE *) const; @@ -812,7 +812,7 @@ class Value_Range // with either set_type() or with an assignment into it. inline -Value_Range::Value_Range () +value_range::value_range () : m_buffer () { m_vrange = NULL; @@ -821,7 +821,7 @@ Value_Range::Value_Range () // Copy constructor. inline -Value_Range::Value_Range (const Value_Range &r) +value_range::value_range (const value_range &r) { init (*r.m_vrange); } @@ -829,7 +829,7 @@ Value_Range::Value_Range (const Value_Range &r) // Copy constructor from a vrange. inline -Value_Range::Value_Range (const vrange &r) +value_range::value_range (const vrange &r) { init (r); } @@ -838,7 +838,7 @@ Value_Range::Value_Range (const vrange &r) // is not supported, default to unsupported_range. inline -Value_Range::Value_Range (tree type) +value_range::value_range (tree type) { init (type); } @@ -847,14 +847,14 @@ Value_Range::Value_Range (tree type) // and MAX are trees. inline -Value_Range::Value_Range (tree min, tree max, value_range_kind kind) +value_range::value_range (tree min, tree max, value_range_kind kind) { init (TREE_TYPE (min)); m_vrange->set (min, max, kind); } inline -Value_Range::~Value_Range () +value_range::~value_range () { if (m_vrange) m_vrange->~vrange (); @@ -864,7 +864,7 @@ Value_Range::~Value_Range () // TYPE. Clean-up memory if there was a previous object. inline void -Value_Range::set_type (tree type) +value_range::set_type (tree type) { if (m_vrange) m_vrange->~vrange (); @@ -875,7 +875,7 @@ Value_Range::set_type (tree type) // TYPE. inline void -Value_Range::init (tree type) +value_range::init (tree type) { gcc_checking_assert (TYPE_P (type)); @@ -892,7 +892,7 @@ Value_Range::init (tree type) // Initialize object with a copy of R. inline void -Value_Range::init (const vrange &r) +value_range::init (const vrange &r) { if (is_a (r)) m_vrange = new (&m_buffer.ints) int_range_max (as_a (r)); @@ -910,7 +910,7 @@ Value_Range::init (const vrange &r) // right thing. inline vrange & -Value_Range::operator= (const vrange &r) +value_range::operator= (const vrange &r) { if (m_vrange) m_vrange->~vrange (); @@ -918,8 +918,8 @@ Value_Range::operator= (const vrange &r) return *m_vrange; } -inline Value_Range & -Value_Range::operator= (const Value_Range &r) +inline value_range & +value_range::operator= (const value_range &r) { // No need to call the m_vrange destructor here, as we will do so in // the assignment below. @@ -928,25 +928,25 @@ Value_Range::operator= (const Value_Range &r) } inline bool -Value_Range::operator== (const Value_Range &r) const +value_range::operator== (const value_range &r) const { return *m_vrange == *r.m_vrange; } inline bool -Value_Range::operator!= (const Value_Range &r) const +value_range::operator!= (const value_range &r) const { return *m_vrange != *r.m_vrange; } inline -Value_Range::operator vrange &() +value_range::operator vrange &() { return *m_vrange; } inline -Value_Range::operator const vrange &() const +value_range::operator const vrange &() const { return *m_vrange; } @@ -954,7 +954,7 @@ Value_Range::operator const vrange &() const // Return TRUE if TYPE is supported by the vrange infrastructure. inline bool -Value_Range::supports_type_p (const_tree type) +value_range::supports_type_p (const_tree type) { return irange::supports_p (type) || prange::supports_p (type) diff --git a/gcc/vr-values.cc b/gcc/vr-values.cc index 470e3145787cb..cf273a3fc6231 100644 --- a/gcc/vr-values.cc +++ b/gcc/vr-values.cc @@ -310,8 +310,8 @@ tree simplify_using_ranges::fold_cond_with_ops (enum tree_code code, tree op0, tree op1, gimple *s) { - Value_Range r0 (TREE_TYPE (op0)); - Value_Range r1 (TREE_TYPE (op1)); + value_range r0 (TREE_TYPE (op0)); + value_range r1 (TREE_TYPE (op1)); if (!query->range_of_expr (r0, op0, s) || !query->range_of_expr (r1, op1, s)) return NULL_TREE; @@ -451,7 +451,7 @@ simplify_using_ranges::legacy_fold_cond (gcond *stmt, edge *taken_edge_p) fprintf (dump_file, "\t"); print_generic_expr (dump_file, use); fprintf (dump_file, ": "); - Value_Range r (TREE_TYPE (use)); + value_range r (TREE_TYPE (use)); query->range_of_expr (r, use, stmt); r.dump (dump_file); } diff --git a/libatomic/ChangeLog b/libatomic/ChangeLog index dd234a64372ba..f7f57c3774bf5 100644 --- a/libatomic/ChangeLog +++ b/libatomic/ChangeLog @@ -1,3 +1,55 @@ +2024-06-12 Victor Do Nascimento + + * config/linux/aarch64/atomic_16.S: Reorganize functions in + file. + (HAVE_FEAT_LSE2): Delete. + +2024-06-12 Victor Do Nascimento + + * config/linux/aarch64/atomic_16.S: Remove unnecessary + aliasing. + (LSE): New. + (ENTRY_ALIASED): Likewise. + * config/linux/aarch64/host-config.h (LSE_ATOP): New. + (LSE2_ATOP): Likewise. + (LSE128_ATOP): Likewise. + (IFUNC_COND_1): Make its definition conditional on above 3 + macros. + (IFUNC_NCOND): Likewise. + +2024-06-12 Victor Do Nascimento + + * cas_n.c (LAT_CAS_N): New. + * exch_n.c (LAT_EXCH_N): Likewise. + * fadd_n.c (LAT_FADD_N): Likewise. + * fand_n.c (LAT_FAND_N): Likewise. + * fence.c (LAT_FENCE): Likewise. + * fenv.c (LAT_FENV): Likewise. + * fior_n.c (LAT_FIOR_N): Likewise. + * flag.c (LAT_FLAG): Likewise. + * fnand_n.c (LAT_FNAND_N): Likewise. + * fop_n.c (LAT_FOP_N): Likewise + * fsub_n.c (LAT_FSUB_N): Likewise. + * fxor_n.c (LAT_FXOR_N): Likewise. + * gcas.c (LAT_GCAS): Likewise. + * gexch.c (LAT_GEXCH): Likewise. + * glfree.c (LAT_GLFREE): Likewise. + * gload.c (LAT_GLOAD): Likewise. + * gstore.c (LAT_GSTORE): Likewise. + * load_n.c (LAT_LOAD_N): Likewise. + * store_n.c (LAT_STORE_N): Likewise. + * tas_n.c (LAT_TAS_N): Likewise. + +2024-06-12 Victor Do Nascimento + + * acinclude.m4 (LIBAT_TEST_FEAT_AARCH64_LSE128): Delete. + * auto-config.h.in (HAVE_FEAT_LSE128): Likewise + * config/linux/aarch64/atomic_16.S: Replace all LSE128 + instructions with equivalent `.inst' directives. + (HAVE_FEAT_LSE128): Remove all references. + * configure: Regenerate. + * configure.ac: Remove call to LIBAT_TEST_FEAT_AARCH64_LSE128. + 2024-05-31 Rainer Orth PR testsuite/115294 diff --git a/libatomic/acinclude.m4 b/libatomic/acinclude.m4 index 6d2e0b1c355c4..f35ab5b60a509 100644 --- a/libatomic/acinclude.m4 +++ b/libatomic/acinclude.m4 @@ -83,24 +83,6 @@ AC_DEFUN([LIBAT_TEST_ATOMIC_BUILTIN],[ ]) ]) -dnl -dnl Test if the host assembler supports armv9.4-a LSE128 isns. -dnl -AC_DEFUN([LIBAT_TEST_FEAT_AARCH64_LSE128],[ - AC_CACHE_CHECK([for armv9.4-a LSE128 insn support], - [libat_cv_have_feat_lse128],[ - AC_LANG_CONFTEST([AC_LANG_PROGRAM([],[asm(".arch armv9-a+lse128")])]) - if AC_TRY_EVAL(ac_compile); then - eval libat_cv_have_feat_lse128=yes - else - eval libat_cv_have_feat_lse128=no - fi - rm -f conftest* - ]) - LIBAT_DEFINE_YESNO([HAVE_FEAT_LSE128], [$libat_cv_have_feat_lse128], - [Have LSE128 support for 16 byte integers.]) -]) - dnl dnl Test if we have __atomic_load and __atomic_store for mode $1, size $2 dnl diff --git a/libatomic/auto-config.h.in b/libatomic/auto-config.h.in index 7c78933b07d10..ab3424a759eae 100644 --- a/libatomic/auto-config.h.in +++ b/libatomic/auto-config.h.in @@ -105,9 +105,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H -/* Have LSE128 support for 16 byte integers. */ -#undef HAVE_FEAT_LSE128 - /* Define to 1 if you have the header file. */ #undef HAVE_FENV_H diff --git a/libatomic/cas_n.c b/libatomic/cas_n.c index a080b990371bd..2a6357e48db33 100644 --- a/libatomic/cas_n.c +++ b/libatomic/cas_n.c @@ -22,6 +22,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ +#define LAT_CAS_N #include "libatomic_i.h" @@ -122,3 +123,4 @@ SIZE(libat_compare_exchange) (UTYPE *mptr, UTYPE *eptr, UTYPE newval, #endif EXPORT_ALIAS (SIZE(compare_exchange)); +#undef LAT_CAS_N diff --git a/libatomic/config/linux/aarch64/atomic_16.S b/libatomic/config/linux/aarch64/atomic_16.S index b63e97ac5a228..c44c31c641841 100644 --- a/libatomic/config/linux/aarch64/atomic_16.S +++ b/libatomic/config/linux/aarch64/atomic_16.S @@ -40,31 +40,23 @@ #include "auto-config.h" -#if !HAVE_IFUNC -# undef HAVE_FEAT_LSE128 -# define HAVE_FEAT_LSE128 0 -#endif - -#define HAVE_FEAT_LSE2 HAVE_IFUNC - -#if HAVE_FEAT_LSE128 - .arch armv9-a+lse128 -#else .arch armv8-a+lse -#endif #define LSE128(NAME) libat_##NAME##_i1 -#define LSE2(NAME) libat_##NAME##_i2 +#define LSE(NAME) libat_##NAME##_i1 +#define LSE2(NAME) libat_##NAME##_i1 #define CORE(NAME) libat_##NAME #define ATOMIC(NAME) __atomic_##NAME +/* Emit __atomic_* entrypoints if no ifuncs. */ +#define ENTRY_ALIASED(NAME) ENTRY2 (CORE (NAME), ALIAS (NAME, ATOMIC, CORE)) + #if HAVE_IFUNC # define ENTRY(NAME) ENTRY2 (CORE (NAME), ) # define ENTRY_FEAT(NAME, FEAT) ENTRY2 (FEAT (NAME), ) # define END_FEAT(NAME, FEAT) END2 (FEAT (NAME)) #else -/* Emit __atomic_* entrypoints if no ifuncs. */ -# define ENTRY(NAME) ENTRY2 (CORE (NAME), ALIAS (NAME, ATOMIC, CORE)) +# define ENTRY(NAME) ENTRY_ALIASED (NAME) #endif #define END(NAME) END2 (CORE (NAME)) @@ -122,6 +114,9 @@ NAME: \ #define SEQ_CST 5 +/* Core implementations: Not dependent on the presence of further architectural + extensions. */ + ENTRY (load_16) mov x5, x0 cbnz w1, 2f @@ -140,31 +135,6 @@ ENTRY (load_16) END (load_16) -#if HAVE_FEAT_LSE2 -ENTRY_FEAT (load_16, LSE2) - cbnz w1, 1f - - /* RELAXED. */ - ldp res0, res1, [x0] - ret -1: - cmp w1, SEQ_CST - b.eq 2f - - /* ACQUIRE/CONSUME (Load-AcquirePC semantics). */ - ldp res0, res1, [x0] - dmb ishld - ret - - /* SEQ_CST. */ -2: ldar tmp0, [x0] /* Block reordering with Store-Release instr. */ - ldp res0, res1, [x0] - dmb ishld - ret -END_FEAT (load_16, LSE2) -#endif - - ENTRY (store_16) cbnz w4, 2f @@ -182,23 +152,6 @@ ENTRY (store_16) END (store_16) -#if HAVE_FEAT_LSE2 -ENTRY_FEAT (store_16, LSE2) - cbnz w4, 1f - - /* RELAXED. */ - stp in0, in1, [x0] - ret - - /* RELEASE/SEQ_CST. */ -1: ldxp xzr, tmp0, [x0] - stlxp w4, in0, in1, [x0] - cbnz w4, 1b - ret -END_FEAT (store_16, LSE2) -#endif - - ENTRY (exchange_16) mov x5, x0 cbnz w4, 2f @@ -226,31 +179,6 @@ ENTRY (exchange_16) END (exchange_16) -#if HAVE_FEAT_LSE128 -ENTRY_FEAT (exchange_16, LSE128) - mov tmp0, x0 - mov res0, in0 - mov res1, in1 - cbnz w4, 1f - - /* RELAXED. */ - swpp res0, res1, [tmp0] - ret -1: - cmp w4, ACQUIRE - b.hi 2f - - /* ACQUIRE/CONSUME. */ - swppa res0, res1, [tmp0] - ret - - /* RELEASE/ACQ_REL/SEQ_CST. */ -2: swppal res0, res1, [tmp0] - ret -END_FEAT (exchange_16, LSE128) -#endif - - ENTRY (compare_exchange_16) ldp exp0, exp1, [x1] cbz w4, 3f @@ -298,45 +226,9 @@ ENTRY (compare_exchange_16) END (compare_exchange_16) -#if HAVE_FEAT_LSE2 -ENTRY_FEAT (compare_exchange_16, LSE2) - ldp exp0, exp1, [x1] - mov tmp0, exp0 - mov tmp1, exp1 - cbz w4, 2f - cmp w4, RELEASE - b.hs 3f - - /* ACQUIRE/CONSUME. */ - caspa exp0, exp1, in0, in1, [x0] -0: - cmp exp0, tmp0 - ccmp exp1, tmp1, 0, eq - bne 1f - mov x0, 1 - ret -1: - stp exp0, exp1, [x1] - mov x0, 0 - ret - - /* RELAXED. */ -2: casp exp0, exp1, in0, in1, [x0] - b 0b - - /* RELEASE. */ -3: b.hi 4f - caspl exp0, exp1, in0, in1, [x0] - b 0b - - /* ACQ_REL/SEQ_CST. */ -4: caspal exp0, exp1, in0, in1, [x0] - b 0b -END_FEAT (compare_exchange_16, LSE2) -#endif -ENTRY (fetch_add_16) +ENTRY_ALIASED (fetch_add_16) mov x5, x0 cbnz w4, 2f @@ -358,7 +250,7 @@ ENTRY (fetch_add_16) END (fetch_add_16) -ENTRY (add_fetch_16) +ENTRY_ALIASED (add_fetch_16) mov x5, x0 cbnz w4, 2f @@ -380,7 +272,7 @@ ENTRY (add_fetch_16) END (add_fetch_16) -ENTRY (fetch_sub_16) +ENTRY_ALIASED (fetch_sub_16) mov x5, x0 cbnz w4, 2f @@ -402,7 +294,7 @@ ENTRY (fetch_sub_16) END (fetch_sub_16) -ENTRY (sub_fetch_16) +ENTRY_ALIASED (sub_fetch_16) mov x5, x0 cbnz w4, 2f @@ -446,31 +338,6 @@ ENTRY (fetch_or_16) END (fetch_or_16) -#if HAVE_FEAT_LSE128 -ENTRY_FEAT (fetch_or_16, LSE128) - mov tmp0, x0 - mov res0, in0 - mov res1, in1 - cbnz w4, 1f - - /* RELAXED. */ - ldsetp res0, res1, [tmp0] - ret -1: - cmp w4, ACQUIRE - b.hi 2f - - /* ACQUIRE/CONSUME. */ - ldsetpa res0, res1, [tmp0] - ret - - /* RELEASE/ACQ_REL/SEQ_CST. */ -2: ldsetpal res0, res1, [tmp0] - ret -END_FEAT (fetch_or_16, LSE128) -#endif - - ENTRY (or_fetch_16) mov x5, x0 cbnz w4, 2f @@ -493,36 +360,6 @@ ENTRY (or_fetch_16) END (or_fetch_16) -#if HAVE_FEAT_LSE128 -ENTRY_FEAT (or_fetch_16, LSE128) - cbnz w4, 1f - mov tmp0, in0 - mov tmp1, in1 - - /* RELAXED. */ - ldsetp in0, in1, [x0] - orr res0, in0, tmp0 - orr res1, in1, tmp1 - ret -1: - cmp w4, ACQUIRE - b.hi 2f - - /* ACQUIRE/CONSUME. */ - ldsetpa in0, in1, [x0] - orr res0, in0, tmp0 - orr res1, in1, tmp1 - ret - - /* RELEASE/ACQ_REL/SEQ_CST. */ -2: ldsetpal in0, in1, [x0] - orr res0, in0, tmp0 - orr res1, in1, tmp1 - ret -END_FEAT (or_fetch_16, LSE128) -#endif - - ENTRY (fetch_and_16) mov x5, x0 cbnz w4, 2f @@ -545,32 +382,6 @@ ENTRY (fetch_and_16) END (fetch_and_16) -#if HAVE_FEAT_LSE128 -ENTRY_FEAT (fetch_and_16, LSE128) - mov tmp0, x0 - mvn res0, in0 - mvn res1, in1 - cbnz w4, 1f - - /* RELAXED. */ - ldclrp res0, res1, [tmp0] - ret - -1: - cmp w4, ACQUIRE - b.hi 2f - - /* ACQUIRE/CONSUME. */ - ldclrpa res0, res1, [tmp0] - ret - - /* RELEASE/ACQ_REL/SEQ_CST. */ -2: ldclrpal res0, res1, [tmp0] - ret -END_FEAT (fetch_and_16, LSE128) -#endif - - ENTRY (and_fetch_16) mov x5, x0 cbnz w4, 2f @@ -593,38 +404,7 @@ ENTRY (and_fetch_16) END (and_fetch_16) -#if HAVE_FEAT_LSE128 -ENTRY_FEAT (and_fetch_16, LSE128) - mvn tmp0, in0 - mvn tmp0, in1 - cbnz w4, 1f - - /* RELAXED. */ - ldclrp tmp0, tmp1, [x0] - and res0, tmp0, in0 - and res1, tmp1, in1 - ret - -1: - cmp w4, ACQUIRE - b.hi 2f - - /* ACQUIRE/CONSUME. */ - ldclrpa tmp0, tmp1, [x0] - and res0, tmp0, in0 - and res1, tmp1, in1 - ret - - /* RELEASE/ACQ_REL/SEQ_CST. */ -2: ldclrpal tmp0, tmp1, [x5] - and res0, tmp0, in0 - and res1, tmp1, in1 - ret -END_FEAT (and_fetch_16, LSE128) -#endif - - -ENTRY (fetch_xor_16) +ENTRY_ALIASED (fetch_xor_16) mov x5, x0 cbnz w4, 2f @@ -646,7 +426,7 @@ ENTRY (fetch_xor_16) END (fetch_xor_16) -ENTRY (xor_fetch_16) +ENTRY_ALIASED (xor_fetch_16) mov x5, x0 cbnz w4, 2f @@ -668,7 +448,7 @@ ENTRY (xor_fetch_16) END (xor_fetch_16) -ENTRY (fetch_nand_16) +ENTRY_ALIASED (fetch_nand_16) mov x5, x0 mvn in0, in0 mvn in1, in1 @@ -692,7 +472,7 @@ ENTRY (fetch_nand_16) END (fetch_nand_16) -ENTRY (nand_fetch_16) +ENTRY_ALIASED (nand_fetch_16) mov x5, x0 mvn in0, in0 mvn in1, in1 @@ -718,7 +498,7 @@ END (nand_fetch_16) /* __atomic_test_and_set is always inlined, so this entry is unused and only required for completeness. */ -ENTRY (test_and_set_16) +ENTRY_ALIASED (test_and_set_16) /* RELAXED/ACQUIRE/CONSUME/RELEASE/ACQ_REL/SEQ_CST. */ mov x5, x0 @@ -729,45 +509,224 @@ ENTRY (test_and_set_16) END (test_and_set_16) -/* Alias entry points which are the same in LSE2 and LSE128. */ - #if HAVE_IFUNC -# if !HAVE_FEAT_LSE128 -ALIAS (exchange_16, LSE128, LSE2) -ALIAS (fetch_or_16, LSE128, LSE2) -ALIAS (fetch_and_16, LSE128, LSE2) -ALIAS (or_fetch_16, LSE128, LSE2) -ALIAS (and_fetch_16, LSE128, LSE2) -# endif -ALIAS (load_16, LSE128, LSE2) -ALIAS (store_16, LSE128, LSE2) -ALIAS (compare_exchange_16, LSE128, LSE2) -ALIAS (fetch_add_16, LSE128, LSE2) -ALIAS (add_fetch_16, LSE128, LSE2) -ALIAS (fetch_sub_16, LSE128, LSE2) -ALIAS (sub_fetch_16, LSE128, LSE2) -ALIAS (fetch_xor_16, LSE128, LSE2) -ALIAS (xor_fetch_16, LSE128, LSE2) -ALIAS (fetch_nand_16, LSE128, LSE2) -ALIAS (nand_fetch_16, LSE128, LSE2) -ALIAS (test_and_set_16, LSE128, LSE2) - -/* Alias entry points which are the same in baseline and LSE2. */ - -ALIAS (exchange_16, LSE2, CORE) -ALIAS (fetch_add_16, LSE2, CORE) -ALIAS (add_fetch_16, LSE2, CORE) -ALIAS (fetch_sub_16, LSE2, CORE) -ALIAS (sub_fetch_16, LSE2, CORE) -ALIAS (fetch_or_16, LSE2, CORE) -ALIAS (or_fetch_16, LSE2, CORE) -ALIAS (fetch_and_16, LSE2, CORE) -ALIAS (and_fetch_16, LSE2, CORE) -ALIAS (fetch_xor_16, LSE2, CORE) -ALIAS (xor_fetch_16, LSE2, CORE) -ALIAS (fetch_nand_16, LSE2, CORE) -ALIAS (nand_fetch_16, LSE2, CORE) -ALIAS (test_and_set_16, LSE2, CORE) +/* ifunc implementations: Carries run-time dependence on the presence of further + architectural extensions. */ + +ENTRY_FEAT (exchange_16, LSE128) + mov tmp0, x0 + mov res0, in0 + mov res1, in1 + cbnz w4, 1f + + /* RELAXED. */ + /* swpp res0, res1, [tmp0] */ + .inst 0x192180c0 + ret +1: + cmp w4, ACQUIRE + b.hi 2f + + /* ACQUIRE/CONSUME. */ + /* swppa res0, res1, [tmp0] */ + .inst 0x19a180c0 + ret + + /* RELEASE/ACQ_REL/SEQ_CST. */ +2: /* swppal res0, res1, [tmp0] */ + .inst 0x19e180c0 + ret +END_FEAT (exchange_16, LSE128) + + +ENTRY_FEAT (fetch_or_16, LSE128) + mov tmp0, x0 + mov res0, in0 + mov res1, in1 + cbnz w4, 1f + + /* RELAXED. */ + /* ldsetp res0, res1, [tmp0] */ + .inst 0x192130c0 + ret +1: + cmp w4, ACQUIRE + b.hi 2f + + /* ACQUIRE/CONSUME. */ + /* ldsetpa res0, res1, [tmp0] */ + .inst 0x19a130c0 + ret + + /* RELEASE/ACQ_REL/SEQ_CST. */ +2: /* ldsetpal res0, res1, [tmp0] */ + .inst 0x19e130c0 + ret +END_FEAT (fetch_or_16, LSE128) + + +ENTRY_FEAT (or_fetch_16, LSE128) + cbnz w4, 1f + mov tmp0, in0 + mov tmp1, in1 + + /* RELAXED. */ + /* ldsetp in0, in1, [x0] */ + .inst 0x19233002 + orr res0, in0, tmp0 + orr res1, in1, tmp1 + ret +1: + cmp w4, ACQUIRE + b.hi 2f + + /* ACQUIRE/CONSUME. */ + /* ldsetpa in0, in1, [x0] */ + .inst 0x19a33002 + orr res0, in0, tmp0 + orr res1, in1, tmp1 + ret + + /* RELEASE/ACQ_REL/SEQ_CST. */ +2: /* ldsetpal in0, in1, [x0] */ + .inst 0x19e33002 + orr res0, in0, tmp0 + orr res1, in1, tmp1 + ret +END_FEAT (or_fetch_16, LSE128) + + +ENTRY_FEAT (fetch_and_16, LSE128) + mov tmp0, x0 + mvn res0, in0 + mvn res1, in1 + cbnz w4, 1f + + /* RELAXED. */ + /* ldclrp res0, res1, [tmp0] */ + .inst 0x192110c0 + ret + +1: + cmp w4, ACQUIRE + b.hi 2f + + /* ACQUIRE/CONSUME. */ + /* ldclrpa res0, res1, [tmp0] */ + .inst 0x19a110c0 + ret + + /* RELEASE/ACQ_REL/SEQ_CST. */ +2: /* ldclrpal res0, res1, [tmp0] */ + .inst 0x19e110c0 + ret +END_FEAT (fetch_and_16, LSE128) + + +ENTRY_FEAT (and_fetch_16, LSE128) + mvn tmp0, in0 + mvn tmp0, in1 + cbnz w4, 1f + + /* RELAXED. */ + /* ldclrp tmp0, tmp1, [x0] */ + .inst 0x19271006 + and res0, tmp0, in0 + and res1, tmp1, in1 + ret + +1: + cmp w4, ACQUIRE + b.hi 2f + + /* ACQUIRE/CONSUME. */ + /* ldclrpa tmp0, tmp1, [x0] */ + .inst 0x19a71006 + and res0, tmp0, in0 + and res1, tmp1, in1 + ret + + /* RELEASE/ACQ_REL/SEQ_CST. */ +2: /* ldclrpal tmp0, tmp1, [x5] */ + .inst 0x19e710a6 + and res0, tmp0, in0 + and res1, tmp1, in1 + ret +END_FEAT (and_fetch_16, LSE128) + + +ENTRY_FEAT (load_16, LSE2) + cbnz w1, 1f + + /* RELAXED. */ + ldp res0, res1, [x0] + ret +1: + cmp w1, SEQ_CST + b.eq 2f + + /* ACQUIRE/CONSUME (Load-AcquirePC semantics). */ + ldp res0, res1, [x0] + dmb ishld + ret + + /* SEQ_CST. */ +2: ldar tmp0, [x0] /* Block reordering with Store-Release instr. */ + ldp res0, res1, [x0] + dmb ishld + ret +END_FEAT (load_16, LSE2) + + +ENTRY_FEAT (store_16, LSE2) + cbnz w4, 1f + + /* RELAXED. */ + stp in0, in1, [x0] + ret + + /* RELEASE/SEQ_CST. */ +1: ldxp xzr, tmp0, [x0] + stlxp w4, in0, in1, [x0] + cbnz w4, 1b + ret +END_FEAT (store_16, LSE2) + + +ENTRY_FEAT (compare_exchange_16, LSE) + ldp exp0, exp1, [x1] + mov tmp0, exp0 + mov tmp1, exp1 + cbz w4, 2f + cmp w4, RELEASE + b.hs 3f + + /* ACQUIRE/CONSUME. */ + caspa exp0, exp1, in0, in1, [x0] +0: + cmp exp0, tmp0 + ccmp exp1, tmp1, 0, eq + bne 1f + mov x0, 1 + ret +1: + stp exp0, exp1, [x1] + mov x0, 0 + ret + + /* RELAXED. */ +2: casp exp0, exp1, in0, in1, [x0] + b 0b + + /* RELEASE. */ +3: b.hi 4f + caspl exp0, exp1, in0, in1, [x0] + b 0b + + /* ACQ_REL/SEQ_CST. */ +4: caspal exp0, exp1, in0, in1, [x0] + b 0b +END_FEAT (compare_exchange_16, LSE) #endif /* GNU_PROPERTY_AARCH64_* macros from elf.h for use in asm code. */ diff --git a/libatomic/config/linux/aarch64/host-config.h b/libatomic/config/linux/aarch64/host-config.h index e1a699948f483..d05e9eb628f54 100644 --- a/libatomic/config/linux/aarch64/host-config.h +++ b/libatomic/config/linux/aarch64/host-config.h @@ -48,15 +48,36 @@ typedef struct __ifunc_arg_t { # define _IFUNC_ARG_HWCAP (1ULL << 62) #endif -#if N == 16 -# define IFUNC_COND_1 (has_lse128 (hwcap, features)) -# define IFUNC_COND_2 (has_lse2 (hwcap, features)) -# define IFUNC_NCOND(N) 2 -#else -# define IFUNC_COND_1 (hwcap & HWCAP_ATOMICS) -# define IFUNC_NCOND(N) 1 +/* From the file which imported `host-config.h' we can ascertain which + architectural extension provides relevant atomic support. From this, + we can proceed to tweak the ifunc selector behavior. */ +#if defined (LAT_CAS_N) +# define LSE_ATOP +#elif defined (LAT_LOAD_N) || defined (LAT_STORE_N) +# define LSE2_ATOP +#elif defined (LAT_EXCH_N) || defined (LAT_FIOR_N) || defined (LAT_FAND_N) +# define LSE128_ATOP #endif +# if N == 16 +# if defined (LSE_ATOP) +# define IFUNC_NCOND(N) 1 +# define IFUNC_COND_1 (hwcap & HWCAP_ATOMICS) +# elif defined (LSE2_ATOP) +# define IFUNC_NCOND(N) 1 +# define IFUNC_COND_1 (has_lse2 (hwcap, features)) +# elif defined (LSE128_ATOP) +# define IFUNC_NCOND(N) 1 +# define IFUNC_COND_1 (has_lse128 (hwcap, features)) +# else +# define IFUNC_NCOND(N) 0 +# define IFUNC_ALT 1 +# endif +# else +# define IFUNC_COND_1 (hwcap & HWCAP_ATOMICS) +# define IFUNC_NCOND(N) 1 +# endif + #define MIDR_IMPLEMENTOR(midr) (((midr) >> 24) & 255) #define MIDR_PARTNUM(midr) (((midr) >> 4) & 0xfff) diff --git a/libatomic/configure b/libatomic/configure index 32cb3ecac262b..d579bab96f86c 100755 --- a/libatomic/configure +++ b/libatomic/configure @@ -14697,49 +14697,6 @@ _ACEOF -# Check for target-specific assembly-level support for atomic operations. - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for armv9.4-a LSE128 insn support" >&5 -$as_echo_n "checking for armv9.4-a LSE128 insn support... " >&6; } -if ${libat_cv_have_feat_lse128+:} false; then : - $as_echo_n "(cached) " >&6 -else - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -asm(".arch armv9-a+lse128") - ; - return 0; -} -_ACEOF - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - eval libat_cv_have_feat_lse128=yes - else - eval libat_cv_have_feat_lse128=no - fi - rm -f conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libat_cv_have_feat_lse128" >&5 -$as_echo "$libat_cv_have_feat_lse128" >&6; } - - yesno=`echo $libat_cv_have_feat_lse128 | tr 'yesno' '1 0 '` - -cat >>confdefs.h <<_ACEOF -#define HAVE_FEAT_LSE128 $yesno -_ACEOF - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } if ${ac_cv_c_bigendian+:} false; then : diff --git a/libatomic/configure.ac b/libatomic/configure.ac index 85824fa7614c3..32a2cdb13aee4 100644 --- a/libatomic/configure.ac +++ b/libatomic/configure.ac @@ -206,9 +206,6 @@ LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_CAS]) LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_FETCH_ADD]) LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_FETCH_OP]) -# Check for target-specific assembly-level support for atomic operations. -LIBAT_TEST_FEAT_AARCH64_LSE128() - AC_C_BIGENDIAN # I don't like the default behaviour of WORDS_BIGENDIAN undefined for LE. AH_BOTTOM( diff --git a/libatomic/exch_n.c b/libatomic/exch_n.c index e5ff80769b904..184d3de1009ec 100644 --- a/libatomic/exch_n.c +++ b/libatomic/exch_n.c @@ -22,6 +22,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ +#define LAT_EXCH_N #include "libatomic_i.h" @@ -126,3 +127,4 @@ SIZE(libat_exchange) (UTYPE *mptr, UTYPE newval, int smodel UNUSED) #endif EXPORT_ALIAS (SIZE(exchange)); +#undef LAT_EXCH_N diff --git a/libatomic/fadd_n.c b/libatomic/fadd_n.c index bc15b8bc0e644..32b75cec654f3 100644 --- a/libatomic/fadd_n.c +++ b/libatomic/fadd_n.c @@ -22,6 +22,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ +#define LAT_FADD_N #include #define NAME add @@ -43,3 +44,4 @@ #endif #include "fop_n.c" +#undef LAT_FADD_N diff --git a/libatomic/fand_n.c b/libatomic/fand_n.c index ffe9ed8700fdb..9eab55bcd72b0 100644 --- a/libatomic/fand_n.c +++ b/libatomic/fand_n.c @@ -1,3 +1,5 @@ +#define LAT_FAND_N #define NAME and #define OP(X,Y) ((X) & (Y)) #include "fop_n.c" +#undef LAT_FAND_N diff --git a/libatomic/fence.c b/libatomic/fence.c index a9b1e280c5a02..4022194a57ad9 100644 --- a/libatomic/fence.c +++ b/libatomic/fence.c @@ -21,6 +21,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ +#define LAT_FENCE #include "libatomic_i.h" #include @@ -43,3 +44,4 @@ void { atomic_signal_fence (order); } +#undef LAT_FENCE diff --git a/libatomic/fenv.c b/libatomic/fenv.c index 41f187c1f8505..dccad356a31ff 100644 --- a/libatomic/fenv.c +++ b/libatomic/fenv.c @@ -21,6 +21,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ +#define LAT_FENV #include "libatomic_i.h" #ifdef HAVE_FENV_H @@ -70,3 +71,4 @@ __atomic_feraiseexcept (int excepts __attribute__ ((unused))) } #endif } +#undef LAT_FENV diff --git a/libatomic/fior_n.c b/libatomic/fior_n.c index 55d0d66b469ff..2b58d4805d6cd 100644 --- a/libatomic/fior_n.c +++ b/libatomic/fior_n.c @@ -1,3 +1,5 @@ +#define LAT_FIOR_N #define NAME or #define OP(X,Y) ((X) | (Y)) #include "fop_n.c" +#undef LAT_FIOR_N diff --git a/libatomic/flag.c b/libatomic/flag.c index e4a5a27819a95..8afd80c91308f 100644 --- a/libatomic/flag.c +++ b/libatomic/flag.c @@ -21,6 +21,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ +#define LAT_FLAG #include "libatomic_i.h" #include @@ -62,3 +63,4 @@ void { return atomic_flag_clear_explicit (object, order); } +#undef LAT_FLAG diff --git a/libatomic/fnand_n.c b/libatomic/fnand_n.c index a3c98c7049480..84a02709cbbb2 100644 --- a/libatomic/fnand_n.c +++ b/libatomic/fnand_n.c @@ -1,3 +1,5 @@ +#define LAT_FNAND_N #define NAME nand #define OP(X,Y) ~((X) & (Y)) #include "fop_n.c" +#undef LAT_FNAND_N diff --git a/libatomic/fop_n.c b/libatomic/fop_n.c index f5eb07e859fbe..fefff3a57a424 100644 --- a/libatomic/fop_n.c +++ b/libatomic/fop_n.c @@ -22,6 +22,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ +#define LAT_FOP_N #include @@ -198,3 +199,4 @@ SIZE(C3(libat_,NAME,_fetch)) (UTYPE *mptr, UTYPE opval, int smodel UNUSED) EXPORT_ALIAS (SIZE(C2(fetch_,NAME))); EXPORT_ALIAS (SIZE(C2(NAME,_fetch))); +#undef LAT_FOP_N diff --git a/libatomic/fsub_n.c b/libatomic/fsub_n.c index e9f8d7d25e181..49b375a543fea 100644 --- a/libatomic/fsub_n.c +++ b/libatomic/fsub_n.c @@ -1,3 +1,5 @@ +#define LAT_FSUB_N #define NAME sub #define OP(X,Y) ((X) - (Y)) #include "fop_n.c" +#undef LAT_FSUB_N diff --git a/libatomic/fxor_n.c b/libatomic/fxor_n.c index 0f2d962412738..d9a91bc3b23c8 100644 --- a/libatomic/fxor_n.c +++ b/libatomic/fxor_n.c @@ -1,3 +1,5 @@ +#define LAT_FXOR_N #define NAME xor #define OP(X,Y) ((X) ^ (Y)) #include "fop_n.c" +#undef LAT_FXOR_N diff --git a/libatomic/gcas.c b/libatomic/gcas.c index 21d11305f1e8b..af4a5f5c5eea4 100644 --- a/libatomic/gcas.c +++ b/libatomic/gcas.c @@ -22,6 +22,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ +#define LAT_GCAS #include "libatomic_i.h" @@ -118,3 +119,4 @@ libat_compare_exchange (size_t n, void *mptr, void *eptr, void *dptr, } EXPORT_ALIAS (compare_exchange); +#undef LAT_GCAS diff --git a/libatomic/gexch.c b/libatomic/gexch.c index 6233759a2e82a..afb054c0ef281 100644 --- a/libatomic/gexch.c +++ b/libatomic/gexch.c @@ -22,6 +22,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ +#define LAT_GEXCH #include "libatomic_i.h" @@ -142,3 +143,4 @@ libat_exchange (size_t n, void *mptr, void *vptr, void *rptr, int smodel) } EXPORT_ALIAS (exchange); +#undef LAT_GEXCH diff --git a/libatomic/glfree.c b/libatomic/glfree.c index 58a45126194c9..1051ceb81cdd6 100644 --- a/libatomic/glfree.c +++ b/libatomic/glfree.c @@ -22,6 +22,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ +#define LAT_GLFREE #include "libatomic_i.h" /* Accesses with a power-of-two size are not lock-free if we don't have an @@ -80,3 +81,4 @@ libat_is_lock_free (size_t n, void *ptr) } EXPORT_ALIAS (is_lock_free); +#undef LAT_GLFREE diff --git a/libatomic/gload.c b/libatomic/gload.c index 4b3198cc5aeca..9b499672161f3 100644 --- a/libatomic/gload.c +++ b/libatomic/gload.c @@ -22,6 +22,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ +#define LAT_GLOAD #include "libatomic_i.h" @@ -98,3 +99,4 @@ libat_load (size_t n, void *mptr, void *rptr, int smodel) } EXPORT_ALIAS (load); +#undef LAT_GLOAD diff --git a/libatomic/gstore.c b/libatomic/gstore.c index 505a7b9b2dfa7..b2636059bd845 100644 --- a/libatomic/gstore.c +++ b/libatomic/gstore.c @@ -22,6 +22,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ +#define LAT_GSTORE #include "libatomic_i.h" @@ -106,3 +107,4 @@ libat_store (size_t n, void *mptr, void *vptr, int smodel) } EXPORT_ALIAS (store); +#undef LAT_GSTORE diff --git a/libatomic/load_n.c b/libatomic/load_n.c index 7513f19183372..657c8e23ed238 100644 --- a/libatomic/load_n.c +++ b/libatomic/load_n.c @@ -22,6 +22,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ +#define LAT_LOAD_N #include "libatomic_i.h" @@ -113,3 +114,4 @@ SIZE(libat_load) (UTYPE *mptr, int smodel) #endif EXPORT_ALIAS (SIZE(load)); +#undef LAT_LOAD_N diff --git a/libatomic/store_n.c b/libatomic/store_n.c index d8ab5e69a508e..079e22d75ba7a 100644 --- a/libatomic/store_n.c +++ b/libatomic/store_n.c @@ -22,6 +22,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ +#define LAT_STORE_N #include "libatomic_i.h" @@ -110,3 +111,4 @@ SIZE(libat_store) (UTYPE *mptr, UTYPE newval, int smodel) #endif EXPORT_ALIAS (SIZE(store)); +#undef LAT_STORE_N diff --git a/libatomic/tas_n.c b/libatomic/tas_n.c index 4a01cd2a5c872..9321b3a4e025d 100644 --- a/libatomic/tas_n.c +++ b/libatomic/tas_n.c @@ -22,6 +22,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ +#define LAT_TAS_N #include "libatomic_i.h" @@ -113,3 +114,4 @@ SIZE(libat_test_and_set) (UTYPE *mptr, int smodel UNUSED) #endif EXPORT_ALIAS (SIZE(test_and_set)); +#undef LAT_TAS_N diff --git a/libbacktrace/ChangeLog b/libbacktrace/ChangeLog index 56f2865bf8206..12b9381f7357c 100644 --- a/libbacktrace/ChangeLog +++ b/libbacktrace/ChangeLog @@ -1,3 +1,8 @@ +2024-06-16 Ian Lance Taylor + + * elf.c (elf_fetch_bits_backward) Don't fail if no bits are + available. + 2024-05-03 Ian Lance Taylor * pecoff.c (struct dll_notification_data): Define. diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c index 3cd87020b0315..735f875250089 100644 --- a/libbacktrace/elf.c +++ b/libbacktrace/elf.c @@ -1182,14 +1182,7 @@ elf_fetch_bits_backward (const unsigned char **ppin, val = *pval; if (unlikely (pin <= pinend)) - { - if (bits == 0) - { - elf_uncompress_failed (); - return 0; - } - return 1; - } + return 1; pin -= 4; diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index 3e6f592b0526f..c631ace4380ef 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,14 @@ +2024-06-11 Joseph Myers + + * include/cpplib.h (CLK_GNUC2Y, CLK_STDC2Y): New. + * init.cc (lang_defaults): Add GNUC2Y and STDC2Y entries. + (cpp_init_builtins): Define __STDC_VERSION__ to 202500L for GNUC2Y + and STDC2Y. + +2024-06-07 Jason Merrill + + * files.cc (_cpp_stack_file): LC_ENTER for -include header unit. + 2024-05-29 Jason Merrill * mkdeps.cc (make_write): Change .c++m to .c++-module. diff --git a/libcpp/files.cc b/libcpp/files.cc index c61df339e2072..78f56e30bdeb8 100644 --- a/libcpp/files.cc +++ b/libcpp/files.cc @@ -1008,7 +1008,10 @@ _cpp_stack_file (cpp_reader *pfile, _cpp_file *file, include_type type, if (decrement) pfile->line_table->highest_location--; - if (file->header_unit <= 0) + /* Normally a header unit becomes an __import directive in the current file, + but with -include we need something to LC_LEAVE to trigger the file_change + hook and continue to the next -include or the main source file. */ + if (file->header_unit <= 0 || type == IT_CMDLINE) /* Add line map and do callbacks. */ _cpp_do_file_change (pfile, LC_ENTER, file->path, /* With preamble injection, start on line zero, diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h index c62374d31929c..d76817c94fc47 100644 --- a/libcpp/include/cpplib.h +++ b/libcpp/include/cpplib.h @@ -172,8 +172,9 @@ enum cpp_ttype /* C language kind, used when calling cpp_create_reader. */ enum c_lang {CLK_GNUC89 = 0, CLK_GNUC99, CLK_GNUC11, CLK_GNUC17, CLK_GNUC23, + CLK_GNUC2Y, CLK_STDC89, CLK_STDC94, CLK_STDC99, CLK_STDC11, CLK_STDC17, - CLK_STDC23, + CLK_STDC23, CLK_STDC2Y, CLK_GNUCXX, CLK_CXX98, CLK_GNUCXX11, CLK_CXX11, CLK_GNUCXX14, CLK_CXX14, CLK_GNUCXX17, CLK_CXX17, CLK_GNUCXX20, CLK_CXX20, CLK_GNUCXX23, CLK_CXX23, diff --git a/libcpp/init.cc b/libcpp/init.cc index c457fa659e7b8..9ae06a9595d90 100644 --- a/libcpp/init.cc +++ b/libcpp/init.cc @@ -109,12 +109,14 @@ static const struct lang_flags lang_defaults[] = /* GNUC11 */ { 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0 }, /* GNUC17 */ { 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0 }, /* GNUC23 */ { 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1 }, + /* GNUC2Y */ { 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1 }, /* STDC89 */ { 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* STDC94 */ { 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* STDC99 */ { 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* STDC11 */ { 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* STDC17 */ { 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* STDC23 */ { 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1 }, + /* STDC2Y */ { 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1 }, /* GNUCXX */ { 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1 }, /* CXX98 */ { 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1 }, /* GNUCXX11 */ { 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1 }, @@ -595,6 +597,9 @@ cpp_init_builtins (cpp_reader *pfile, int hosted) else if (CPP_OPTION (pfile, lang) == CLK_STDC23 || CPP_OPTION (pfile, lang) == CLK_GNUC23) _cpp_define_builtin (pfile, "__STDC_VERSION__ 202311L"); + else if (CPP_OPTION (pfile, lang) == CLK_STDC2Y + || CPP_OPTION (pfile, lang) == CLK_GNUC2Y) + _cpp_define_builtin (pfile, "__STDC_VERSION__ 202500L"); else if (CPP_OPTION (pfile, lang) == CLK_STDC17 || CPP_OPTION (pfile, lang) == CLK_GNUC17) _cpp_define_builtin (pfile, "__STDC_VERSION__ 201710L"); diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index bf1ff5198e6d5..7c24757c6ee32 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,7 @@ +2024-06-10 Jan Beulich + + * config/aarch64/cpuinfo.c: Provide AT_HWCAP2. + 2024-06-06 Andre Vieira PR target/115360 diff --git a/libgcc/config/aarch64/cpuinfo.c b/libgcc/config/aarch64/cpuinfo.c index 544c5516133ec..ec36d1057383b 100644 --- a/libgcc/config/aarch64/cpuinfo.c +++ b/libgcc/config/aarch64/cpuinfo.c @@ -146,6 +146,9 @@ struct { #define HWCAP_PACG (1UL << 31) #endif +#ifndef AT_HWCAP2 +#define AT_HWCAP2 26 +#endif #ifndef HWCAP2_DCPODP #define HWCAP2_DCPODP (1 << 0) #endif diff --git a/libgcc/config/avr/libf7/ChangeLog b/libgcc/config/avr/libf7/ChangeLog index d5ce1fe9ab1ee..ce80d3815beb1 100644 --- a/libgcc/config/avr/libf7/ChangeLog +++ b/libgcc/config/avr/libf7/ChangeLog @@ -1,3 +1,8 @@ +2024-06-14 Georg-Johann Lay + + PR target/115419 + * libf7.c (f7_get_double): Round tie breaks to even LSB. + 2024-06-01 Georg-Johann Lay PR target/115317 diff --git a/libgcc/config/avr/libf7/libf7.c b/libgcc/config/avr/libf7/libf7.c index 375becb854c1d..6fae4fc1a2de6 100644 --- a/libgcc/config/avr/libf7/libf7.c +++ b/libgcc/config/avr/libf7/libf7.c @@ -440,11 +440,21 @@ f7_double_t f7_get_double (const f7_t *aa) mant &= 0x00ffffffffffffff; - // FIXME: For subnormals, rounding is premature and should be - // done *after* the mantissa has been shifted into place - // (or the round value be shifted left accordingly). - // Round. - mant += 1u << (F7_MANT_BITS - (1 + DBL_DIG_MANT) - 1); + // PR115419: The least significant nibble tells how to round: + // Tie breaks are rounded to even (Banker's rounding). + uint8_t lsn = mant & 0xff; + lsn &= 0xf; + // The LSB of the outgoing double is at bit 3. + if (lsn & (1 << 3)) + ++lsn; + if (lsn > (1 << 2)) + { + // FIXME: For subnormals, rounding is premature and should be + // done *after* the mantissa has been shifted into place + // (or the round value be shifted left accordingly). + // Round. + mant += 1u << (F7_MANT_BITS - (1 + DBL_DIG_MANT) - 1); + } uint8_t dex; register uint64_t r18 __asm ("r18") = mant; diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index acbd7165d5f58..907f6cfb0e83c 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,217 @@ +2024-06-18 Jonathan Wakely + + * include/bits/cpp_type_traits.h: Fix outdated comment about the + number of standard integer types. + +2024-06-14 Jonathan Wakely + + PR libstdc++/110572 + * libsupc++/typeinfo (type_info::operator==): Add always_inline + attribute for targets where the ABI requries equality to be + non-inline. + * testsuite/18_support/type_info/110572.cc: New test. + +2024-06-14 Jonathan Wakely + + * libsupc++/new_opa.cc [!_GLIBCXX_HOSTED]: Fix declaration of + posix_memalign. + +2024-06-13 Alexandre Oliva + + PR libstdc++/114359 + * testsuite/26_numerics/random/binomial_distribution/114359.cc: + Require cmath. + +2024-06-13 Ken Matsui + + * include/std/type_traits (__add_rval_ref_t): Use + __add_rvalue_reference built-in trait. + +2024-06-13 Ken Matsui + + * include/std/type_traits (__add_lval_ref_t): Use + __add_lvalue_reference built-in trait. + +2024-06-13 Ken Matsui + Jonathan Wakely + + * include/bits/cpp_type_traits.h (__is_pointer): Use + __is_pointer built-in trait. + * include/std/type_traits (is_pointer): Likewise. Optimize its + implementation. + (is_pointer_v): Likewise. + +2024-06-13 Jonathan Wakely + + * include/bits/ranges_base.h (range_common_reference_t): New + alias template, as per LWG 3860. + * testsuite/std/ranges/range.cc: Check it. + +2024-06-13 Jonathan Wakely + + * include/bits/ranges_base.h (const_iterator_t): Change + preprocessor condition to use __glibcxx_ranges_as_const. + (const_sentinel_t, range_const_reference_t): Likewise. + (__access::__possibly_const_range, cbegin, cend, crbegin) + (crend, cdata): Likewise. + * include/bits/stl_iterator.h (iter_const_reference_t) + (basic_const_iterator, const_iterator, const_sentinel) + (make_const_iterator): Likewise. + +2024-06-13 Jonathan Wakely + + PR libstdc++/115420 + * include/bits/hashtable.h (_Hashtable): Add static_assert to + check that hash function is copy constructible. + * testsuite/23_containers/unordered_map/115420.cc: New test. + +2024-06-13 Jonathan Wakely + + PR libstdc++/113376 + * include/pstl/pstl_config.h: Use #if instead of #ifdef to test + the _PSTL_USAGE_WARNINGS macro. + +2024-06-13 Ken Matsui + + * include/std/type_traits (is_nothrow_invocable): Use + __is_nothrow_invocable built-in trait. + * testsuite/20_util/is_nothrow_invocable/incomplete_args_neg.cc: + Handle the new error from __is_nothrow_invocable. + * testsuite/20_util/is_nothrow_invocable/incomplete_neg.cc: + Likewise. + +2024-06-13 Ken Matsui + + * include/std/type_traits (is_invocable): Use __is_invocable + built-in trait. + * testsuite/20_util/is_invocable/incomplete_args_neg.cc: Handle + the new error from __is_invocable. + * testsuite/20_util/is_invocable/incomplete_neg.cc: Likewise. + +2024-06-13 Ken Matsui + + * include/std/type_traits (rank): Use __array_rank built-in + trait. + (rank_v): Likewise. + +2024-06-13 Ken Matsui + + * include/std/type_traits (decay): Use __decay built-in trait. + +2024-06-13 Ken Matsui + + * include/std/type_traits (remove_all_extents): Use + __remove_all_extents built-in trait. + +2024-06-13 Ken Matsui + + * include/std/type_traits (remove_extent): Use __remove_extent + built-in trait. + +2024-06-13 Ken Matsui + + * include/std/type_traits (add_pointer): Use __add_pointer + built-in trait. + +2024-06-13 Ken Matsui + + * include/std/type_traits (is_unbounded_array_v): Use + __is_unbounded_array built-in trait. + +2024-06-13 Ken Matsui + + * include/std/type_traits (is_volatile): Use __is_volatile + built-in trait. + (is_volatile_v): Likewise. + +2024-06-13 Ken Matsui + + * include/std/type_traits (is_const): Use __is_const built-in + trait. + (is_const_v): Likewise. + +2024-06-12 Alexandre Oliva + + * testsuite/26_numerics/headers/cmath/constexpr_std_c++23.cc: + Require cmath. + * testsuite/26_numerics/headers/cmath/functions_std_c++23.cc: + Likewise. + * testsuite/26_numerics/headers/cmath/nextafter_c++23.cc: + Likewise. + +2024-06-12 Alexandre Oliva + + * testsuite/20_util/from_chars/8.cc: Skip float128_t testing + on aarch64-rtems*. + * testsuite/20_util/to_chars/float128_c++23.cc: Xfail run on + aarch64-rtems*. + +2024-06-12 Jonathan Wakely + + PR libstdc++/115399 + * include/tr2/dynamic_bitset (operator>>=): Remove redundant + call to _M_do_sanitize. + * include/tr2/dynamic_bitset.tcc (_M_do_left_shift): Zero out + low bits in words that should no longer be populated. + (_M_do_right_shift): Likewise for high bits. + * testsuite/tr2/dynamic_bitset/pr115399.cc: New test. + +2024-06-12 Jonathan Wakely + + * include/bits/hashtable.h (_Hashtable::clear): Do not use + memset to zero out bucket pointers. + (_Hashtable::_M_assign_elements): Likewise. + +2024-06-11 Jonathan Wakely + + * include/std/chrono (leap_seconds): Add comment. + * testsuite/std/time/leap_seconds/io.cc: New test. + +2024-06-10 François Dumont + + * include/bits/hashtable.h (~_Hashtable()): Replace clear call with + a _M_deallocate_nodes call. + +2024-06-08 Deev Patel + Jonathan Wakely + + * include/bits/atomic_base.h (__atomic_impl::__clear_padding): + Add missing constexpr specifier. + * testsuite/29_atomics/atomic_float/constinit.cc: New test. + +2024-06-08 Michael Levine + + PR libstdc++/108760 + * include/bits/ranges_algo.h (ranges::out_value_result): + Move to . + (ranges::iota_result, ranges::__iota_fn, ranges::iota): Move to + . + * include/bits/ranges_algobase.h (ranges::out_value_result): + Move to here. + * include/std/numeric (ranges::iota_result, ranges::__iota_fn) + (ranges::iota): Move to here. + * testsuite/25_algorithms/iota/1.cc: Renamed to ... + * testsuite/26_numerics/iota/2.cc: ... here. + +2024-06-08 Jonathan Wakely + + * include/std/algorithm: Define __glibcxx_want_ranges. + * testsuite/25_algorithms/headers/algorithm/synopsis.cc: Check + feature test macro in C++20 mode. + +2024-06-07 Jonathan Wakely + + * include/bits/ranges_algobase.h: Include . + +2024-06-07 Alexandre Oliva + + * include/std/variant: Drop obsolete workaround. + +2024-06-07 Jonathan Wakely + + * include/bits/ptr_traits.h (to_address): Optimize. + * testsuite/20_util/to_address/1_neg.cc: Adjust dg-error text. + 2024-06-06 Alexandre Oliva * include/bits/c++config (_GLIBCXX_CLANG): Define or undefine. diff --git a/libstdc++-v3/include/bits/atomic_base.h b/libstdc++-v3/include/bits/atomic_base.h index 062f154974031..20901b7fc06f7 100644 --- a/libstdc++-v3/include/bits/atomic_base.h +++ b/libstdc++-v3/include/bits/atomic_base.h @@ -968,7 +968,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template - _GLIBCXX_ALWAYS_INLINE _Tp* + _GLIBCXX_ALWAYS_INLINE _GLIBCXX14_CONSTEXPR _Tp* __clear_padding(_Tp& __val) noexcept { auto* __ptr = std::__addressof(__val); diff --git a/libstdc++-v3/include/bits/cpp_type_traits.h b/libstdc++-v3/include/bits/cpp_type_traits.h index 59f1a1875eb8a..6834dee555707 100644 --- a/libstdc++-v3/include/bits/cpp_type_traits.h +++ b/libstdc++-v3/include/bits/cpp_type_traits.h @@ -130,10 +130,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typedef __false_type __type; }; - // Thirteen specializations (yes there are eleven standard integer - // types; long long and unsigned long long are - // supported as extensions). Up to four target-specific __int - // types are supported as well. + // Explicit specializations for the standard integer types. + // Up to four target-specific __int types are supported as well. template<> struct __is_integer { @@ -363,6 +361,13 @@ __INT_N(__GLIBCXX_TYPE_INT_N_3) // // Pointer types // +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_pointer) + template + struct __is_pointer : __truth_type<_IsPtr> + { + enum { __value = _IsPtr }; + }; +#else template struct __is_pointer { @@ -376,6 +381,7 @@ __INT_N(__GLIBCXX_TYPE_INT_N_3) enum { __value = 1 }; typedef __true_type __type; }; +#endif // // An arithmetic type is an integer type or a floating point type diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h index cd3e1ac297c5c..361da2b3b4d41 100644 --- a/libstdc++-v3/include/bits/hashtable.h +++ b/libstdc++-v3/include/bits/hashtable.h @@ -34,6 +34,7 @@ #include #include +#include // fill_n #include // __has_is_transparent_t #if __cplusplus > 201402L # include @@ -209,6 +210,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static_assert(is_same{}, "unordered container must have the same value_type as its allocator"); #endif + static_assert(is_copy_constructible<_Hash>::value, + "hash function must be copy constructible"); using __traits_type = _Traits; using __hash_cached = typename __traits_type::__hash_cached; @@ -1376,8 +1379,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_bucket_count = __ht._M_bucket_count; } else - __builtin_memset(_M_buckets, 0, - _M_bucket_count * sizeof(__node_base_ptr)); + std::fill_n(_M_buckets, _M_bucket_count, nullptr); __try { @@ -1400,8 +1402,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_buckets = __former_buckets; _M_bucket_count = __former_bucket_count; } - __builtin_memset(_M_buckets, 0, - _M_bucket_count * sizeof(__node_base_ptr)); + std::fill_n(_M_buckets, _M_bucket_count, nullptr); __throw_exception_again; } } @@ -1664,7 +1665,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION "Cache the hash code or qualify your functors involved" " in hash code and bucket index computation with noexcept"); - clear(); + this->_M_deallocate_nodes(_M_begin()); _M_deallocate_buckets(); } @@ -2582,8 +2583,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION clear() noexcept { this->_M_deallocate_nodes(_M_begin()); - __builtin_memset(_M_buckets, 0, - _M_bucket_count * sizeof(__node_base_ptr)); + std::fill_n(_M_buckets, _M_bucket_count, nullptr); _M_element_count = 0; _M_before_begin._M_nxt = nullptr; } diff --git a/libstdc++-v3/include/bits/ptr_traits.h b/libstdc++-v3/include/bits/ptr_traits.h index 6c65001cb7410..ca67feecca38e 100644 --- a/libstdc++-v3/include/bits/ptr_traits.h +++ b/libstdc++-v3/include/bits/ptr_traits.h @@ -200,36 +200,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template using __ptr_rebind = typename pointer_traits<_Ptr>::template rebind<_Tp>; +#ifndef __glibcxx_to_address // C++ < 20 template + [[__gnu__::__always_inline__]] constexpr _Tp* __to_address(_Tp* __ptr) noexcept { - static_assert(!std::is_function<_Tp>::value, "not a function pointer"); + static_assert(!std::is_function<_Tp>::value, "std::to_address argument " + "must not be a function pointer"); return __ptr; } -#ifndef __glibcxx_to_address // C++ < 20 template constexpr typename std::pointer_traits<_Ptr>::element_type* __to_address(const _Ptr& __ptr) { return std::__to_address(__ptr.operator->()); } #else - template - constexpr auto - __to_address(const _Ptr& __ptr) noexcept - -> decltype(std::pointer_traits<_Ptr>::to_address(__ptr)) - { return std::pointer_traits<_Ptr>::to_address(__ptr); } - - template - constexpr auto - __to_address(const _Ptr& __ptr, _None...) noexcept - { - if constexpr (is_base_of_v<__gnu_debug::_Safe_iterator_base, _Ptr>) - return std::__to_address(__ptr.base().operator->()); - else - return std::__to_address(__ptr.operator->()); - } - /** * @brief Obtain address referenced by a pointer to an object * @param __ptr A pointer to an object @@ -237,9 +223,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @ingroup pointer_abstractions */ template + [[__gnu__::__always_inline__]] constexpr _Tp* to_address(_Tp* __ptr) noexcept - { return std::__to_address(__ptr); } + { + static_assert(!is_function_v<_Tp>, "std::to_address argument " + "must not be a function pointer"); + return __ptr; + } /** * @brief Obtain address referenced by a pointer to an object @@ -251,7 +242,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template constexpr auto to_address(const _Ptr& __ptr) noexcept - { return std::__to_address(__ptr); } + { + if constexpr (requires { pointer_traits<_Ptr>::to_address(__ptr); }) + return pointer_traits<_Ptr>::to_address(__ptr); + else if constexpr (is_base_of_v<__gnu_debug::_Safe_iterator_base, _Ptr>) + return std::to_address(__ptr.base().operator->()); + else + return std::to_address(__ptr.operator->()); + } + + /// @cond undocumented + /// Compatibility for use in code that is also compiled as pre-C++20. + template + [[__gnu__::__always_inline__]] + constexpr auto + __to_address(const _Ptr& __ptr) noexcept + { return std::to_address(__ptr); } + /// @endcond #endif // __glibcxx_to_address _GLIBCXX_END_NAMESPACE_VERSION diff --git a/libstdc++-v3/include/bits/ranges_algo.h b/libstdc++-v3/include/bits/ranges_algo.h index 62faff173bdbf..d258be0b93f37 100644 --- a/libstdc++-v3/include/bits/ranges_algo.h +++ b/libstdc++-v3/include/bits/ranges_algo.h @@ -3521,58 +3521,6 @@ namespace ranges #endif // __glibcxx_ranges_contains -#if __glibcxx_ranges_iota >= 202202L // C++ >= 23 - - template - struct out_value_result - { - [[no_unique_address]] _Out out; - [[no_unique_address]] _Tp value; - - template - requires convertible_to - && convertible_to - constexpr - operator out_value_result<_Out2, _Tp2>() const & - { return {out, value}; } - - template - requires convertible_to<_Out, _Out2> - && convertible_to<_Tp, _Tp2> - constexpr - operator out_value_result<_Out2, _Tp2>() && - { return {std::move(out), std::move(value)}; } - }; - - template - using iota_result = out_value_result<_Out, _Tp>; - - struct __iota_fn - { - template _Sent, weakly_incrementable _Tp> - requires indirectly_writable<_Out, const _Tp&> - constexpr iota_result<_Out, _Tp> - operator()(_Out __first, _Sent __last, _Tp __value) const - { - while (__first != __last) - { - *__first = static_cast(__value); - ++__first; - ++__value; - } - return {std::move(__first), std::move(__value)}; - } - - template _Range> - constexpr iota_result, _Tp> - operator()(_Range&& __r, _Tp __value) const - { return (*this)(ranges::begin(__r), ranges::end(__r), std::move(__value)); } - }; - - inline constexpr __iota_fn iota{}; - -#endif // __glibcxx_ranges_iota - #if __glibcxx_ranges_find_last >= 202207L // C++ >= 23 struct __find_last_fn diff --git a/libstdc++-v3/include/bits/ranges_algobase.h b/libstdc++-v3/include/bits/ranges_algobase.h index e26a73a27d680..7ce5ac314f252 100644 --- a/libstdc++-v3/include/bits/ranges_algobase.h +++ b/libstdc++-v3/include/bits/ranges_algobase.h @@ -35,9 +35,11 @@ #include #include #include +#include // __memcpy #include // ranges::begin, ranges::range etc. #include // __invoke #include // __is_byte +#include // __memcmp #if __cpp_lib_concepts namespace std _GLIBCXX_VISIBILITY(default) @@ -70,6 +72,29 @@ namespace ranges __is_move_iterator> = true; } // namespace __detail +#if __glibcxx_ranges_iota >= 202202L // C++ >= 23 + template + struct out_value_result + { + [[no_unique_address]] _Out out; + [[no_unique_address]] _Tp value; + + template + requires convertible_to + && convertible_to + constexpr + operator out_value_result<_Out2, _Tp2>() const & + { return {out, value}; } + + template + requires convertible_to<_Out, _Out2> + && convertible_to<_Tp, _Tp2> + constexpr + operator out_value_result<_Out2, _Tp2>() && + { return {std::move(out), std::move(value)}; } + }; +#endif // __glibcxx_ranges_iota + struct __equal_fn { template _Sent1, diff --git a/libstdc++-v3/include/bits/ranges_base.h b/libstdc++-v3/include/bits/ranges_base.h index 6597ffa532d41..63eb552b48bb3 100644 --- a/libstdc++-v3/include/bits/ranges_base.h +++ b/libstdc++-v3/include/bits/ranges_base.h @@ -513,7 +513,7 @@ namespace ranges template using sentinel_t = decltype(ranges::end(std::declval<_Range&>())); -#if __cplusplus > 202002L +#if __glibcxx_ranges_as_const // >= C++23 template using const_iterator_t = const_iterator>; @@ -537,6 +537,12 @@ namespace ranges using range_rvalue_reference_t = iter_rvalue_reference_t>; + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3860. range_common_reference_t is missing + template + using range_common_reference_t + = iter_common_reference_t>; + /// [range.sized] The sized_range concept. template concept sized_range = range<_Tp> @@ -616,7 +622,7 @@ namespace ranges concept common_range = range<_Tp> && same_as, sentinel_t<_Tp>>; -#if __cplusplus > 202002L +#if __glibcxx_ranges_as_const // >= C++23 template concept constant_range = input_range<_Tp> && std::__detail::__constant_iterator>; @@ -624,7 +630,7 @@ namespace ranges namespace __access { -#if __cplusplus > 202020L +#if __glibcxx_ranges_as_const // >= C++23 template constexpr auto& __possibly_const_range(_Range& __r) noexcept @@ -651,7 +657,7 @@ namespace ranges struct _CBegin { -#if __cplusplus > 202002L +#if __glibcxx_ranges_as_const // >= C++23 template<__maybe_borrowed_range _Tp> [[nodiscard]] constexpr auto @@ -679,7 +685,7 @@ namespace ranges struct _CEnd final { -#if __cplusplus > 202002L +#if __glibcxx_ranges_as_const // >= C++23 template<__maybe_borrowed_range _Tp> [[nodiscard]] constexpr auto @@ -707,7 +713,7 @@ namespace ranges struct _CRBegin { -#if __cplusplus > 202002L +#if __glibcxx_ranges_as_const // >= C++23 template<__maybe_borrowed_range _Tp> [[nodiscard]] constexpr auto @@ -735,7 +741,7 @@ namespace ranges struct _CREnd { -#if __cplusplus > 202002L +#if __glibcxx_ranges_as_const // >= C++23 template<__maybe_borrowed_range _Tp> [[nodiscard]] constexpr auto @@ -763,7 +769,7 @@ namespace ranges struct _CData { -#if __cplusplus > 202002L +#if __glibcxx_ranges_as_const // >= C++23 template<__maybe_borrowed_range _Tp> [[nodiscard]] constexpr const auto* diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h index 560a10a7abe82..d382305727096 100644 --- a/libstdc++-v3/include/bits/stl_iterator.h +++ b/libstdc++-v3/include/bits/stl_iterator.h @@ -2571,7 +2571,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION void>; }; -#if __cplusplus > 202020L +#if __glibcxx_ranges_as_const // >= C++23 template using iter_const_reference_t = common_reference_t&&, iter_reference_t<_It>>; diff --git a/libstdc++-v3/include/bits/stl_tempbuf.h b/libstdc++-v3/include/bits/stl_tempbuf.h index fa03fd277042a..759c4937744b6 100644 --- a/libstdc++-v3/include/bits/stl_tempbuf.h +++ b/libstdc++-v3/include/bits/stl_tempbuf.h @@ -82,7 +82,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION inline _Tp* __get_temporary_buffer(ptrdiff_t __len) _GLIBCXX_NOTHROW { - if (__builtin_expect(__len > (size_t(-1) / sizeof(_Tp)), 0)) + if (__builtin_expect(size_t(__len) > (size_t(-1) / sizeof(_Tp)), 0)) return 0; #if __cpp_aligned_new @@ -200,6 +200,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION size_type _M_original_len; struct _Impl { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" explicit _Impl(ptrdiff_t __original_len) { @@ -208,6 +210,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_len = __p.second; _M_buffer = __p.first; } +#pragma GCC diagnostic pop ~_Impl() { std::__detail::__return_temporary_buffer(_M_buffer, _M_len); } @@ -315,8 +318,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __ucr(__first, __last, __seed); } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" template _Temporary_buffer<_ForwardIterator, _Tp>:: _Temporary_buffer(_ForwardIterator __seed, size_type __original_len) @@ -324,7 +325,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { std::__uninitialized_construct_buf(begin(), end(), __seed); } -#pragma GCC diagnostic pop _GLIBCXX_END_NAMESPACE_VERSION } // namespace diff --git a/libstdc++-v3/include/pstl/pstl_config.h b/libstdc++-v3/include/pstl/pstl_config.h index 7157a8a492ed9..6fae15460eac8 100644 --- a/libstdc++-v3/include/pstl/pstl_config.h +++ b/libstdc++-v3/include/pstl/pstl_config.h @@ -177,7 +177,7 @@ #define _PSTL_PRAGMA_MESSAGE_IMPL(x) _PSTL_PRAGMA(message(_PSTL_STRING_CONCAT(_PSTL_PRAGMA_LOCATION, x))) -#if defined(_PSTL_USAGE_WARNINGS) +#if _PSTL_USAGE_WARNINGS # define _PSTL_PRAGMA_MESSAGE(x) _PSTL_PRAGMA_MESSAGE_IMPL(x) # define _PSTL_PRAGMA_MESSAGE_POLICIES(x) _PSTL_PRAGMA_MESSAGE_IMPL(x) #else diff --git a/libstdc++-v3/include/std/algorithm b/libstdc++-v3/include/std/algorithm index a4602a8807e62..163e6b5dca72b 100644 --- a/libstdc++-v3/include/std/algorithm +++ b/libstdc++-v3/include/std/algorithm @@ -67,6 +67,7 @@ #define __glibcxx_want_constexpr_algorithms #define __glibcxx_want_freestanding_algorithm #define __glibcxx_want_parallel_algorithm +#define __glibcxx_want_ranges #define __glibcxx_want_ranges_contains #define __glibcxx_want_ranges_find_last #define __glibcxx_want_ranges_fold diff --git a/libstdc++-v3/include/std/chrono b/libstdc++-v3/include/std/chrono index b0aadf83b03f0..7ffa536072846 100644 --- a/libstdc++-v3/include/std/chrono +++ b/libstdc++-v3/include/std/chrono @@ -2925,6 +2925,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION const leap_second& __y) noexcept { return !(__x < __y.date()); } + // This is a simplified form of the constraint specified in the standard, + // three_way_comparable_with>. template _Duration> [[nodiscard]] friend constexpr auto operator<=>(const leap_second& __x, diff --git a/libstdc++-v3/include/std/numeric b/libstdc++-v3/include/std/numeric index c912db4a5195a..201bb8e74a121 100644 --- a/libstdc++-v3/include/std/numeric +++ b/libstdc++-v3/include/std/numeric @@ -89,6 +89,10 @@ #define __glibcxx_want_saturation_arithmetic #include +#if __glibcxx_ranges_iota >= 202202L // C++ >= 23 +# include // for ranges::out_value_result +#endif + #ifdef __glibcxx_saturation_arithmetic // C++ >= 26 # include #endif @@ -726,6 +730,40 @@ namespace __detail /// @} group numeric_ops #endif // C++17 +namespace ranges +{ +#if __glibcxx_ranges_iota >= 202202L // C++ >= 23 + + template + using iota_result = out_value_result<_Out, _Tp>; + + struct __iota_fn + { + template _Sent, weakly_incrementable _Tp> + requires indirectly_writable<_Out, const _Tp&> + constexpr iota_result<_Out, _Tp> + operator()(_Out __first, _Sent __last, _Tp __value) const + { + while (__first != __last) + { + *__first = static_cast(__value); + ++__first; + ++__value; + } + return {std::move(__first), std::move(__value)}; + } + + template _Range> + constexpr iota_result, _Tp> + operator()(_Range&& __r, _Tp __value) const + { return (*this)(ranges::begin(__r), ranges::end(__r), std::move(__value)); } + }; + + inline constexpr __iota_fn iota{}; + +#endif // __glibcxx_ranges_iota +} // namespace ranges + _GLIBCXX_END_NAMESPACE_VERSION } // namespace std diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index b441bf9908f78..a31de2ee4abb6 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -542,19 +542,33 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public true_type { }; #endif - template - struct __is_pointer_helper + /// is_pointer +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_pointer) + template + struct is_pointer + : public __bool_constant<__is_pointer(_Tp)> + { }; +#else + template + struct is_pointer : public false_type { }; template - struct __is_pointer_helper<_Tp*> + struct is_pointer<_Tp*> : public true_type { }; - /// is_pointer template - struct is_pointer - : public __is_pointer_helper<__remove_cv_t<_Tp>>::type - { }; + struct is_pointer<_Tp* const> + : public true_type { }; + + template + struct is_pointer<_Tp* volatile> + : public true_type { }; + + template + struct is_pointer<_Tp* const volatile> + : public true_type { }; +#endif /// is_lvalue_reference template @@ -835,6 +849,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Type properties. /// is_const +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_const) + template + struct is_const + : public __bool_constant<__is_const(_Tp)> + { }; +#else template struct is_const : public false_type { }; @@ -842,8 +862,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct is_const<_Tp const> : public true_type { }; +#endif /// is_volatile +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_volatile) + template + struct is_volatile + : public __bool_constant<__is_volatile(_Tp)> + { }; +#else template struct is_volatile : public false_type { }; @@ -851,6 +878,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct is_volatile<_Tp volatile> : public true_type { }; +#endif /// is_trivial template @@ -1129,6 +1157,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; /// @cond undocumented +#if _GLIBCXX_USE_BUILTIN_TRAIT(__add_lvalue_reference) + template + using __add_lval_ref_t = __add_lvalue_reference(_Tp); +#else template struct __add_lvalue_reference_helper { using type = _Tp; }; @@ -1139,6 +1171,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template using __add_lval_ref_t = typename __add_lvalue_reference_helper<_Tp>::type; +#endif /// @endcond /// is_copy_constructible @@ -1151,6 +1184,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; /// @cond undocumented +#if _GLIBCXX_USE_BUILTIN_TRAIT(__add_rvalue_reference) + template + using __add_rval_ref_t = __add_rvalue_reference(_Tp); +#else template struct __add_rvalue_reference_helper { using type = _Tp; }; @@ -1161,6 +1198,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template using __add_rval_ref_t = typename __add_rvalue_reference_helper<_Tp>::type; +#endif /// @endcond /// is_move_constructible @@ -1433,6 +1471,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; /// rank +#if _GLIBCXX_USE_BUILTIN_TRAIT(__array_rank) + template + struct rank + : public integral_constant { }; +#else template struct rank : public integral_constant { }; @@ -1444,6 +1487,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct rank<_Tp[]> : public integral_constant::value> { }; +#endif /// extent template @@ -2064,6 +2108,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Array modifications. /// remove_extent +#if _GLIBCXX_USE_BUILTIN_TRAIT(__remove_extent) + template + struct remove_extent + { using type = __remove_extent(_Tp); }; +#else template struct remove_extent { using type = _Tp; }; @@ -2075,8 +2124,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct remove_extent<_Tp[]> { using type = _Tp; }; +#endif /// remove_all_extents +#if _GLIBCXX_USE_BUILTIN_TRAIT(__remove_all_extents) + template + struct remove_all_extents + { using type = __remove_all_extents(_Tp); }; +#else template struct remove_all_extents { using type = _Tp; }; @@ -2088,6 +2143,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct remove_all_extents<_Tp[]> { using type = typename remove_all_extents<_Tp>::type; }; +#endif #if __cplusplus > 201103L /// Alias template for remove_extent @@ -2121,6 +2177,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { }; #endif + /// add_pointer +#if _GLIBCXX_USE_BUILTIN_TRAIT(__add_pointer) + template + struct add_pointer + { using type = __add_pointer(_Tp); }; +#else template struct __add_pointer_helper { using type = _Tp; }; @@ -2129,7 +2191,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __add_pointer_helper<_Tp, __void_t<_Tp*>> { using type = _Tp*; }; - /// add_pointer template struct add_pointer : public __add_pointer_helper<_Tp> @@ -2142,6 +2203,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct add_pointer<_Tp&&> { using type = _Tp*; }; +#endif #if __cplusplus > 201103L /// Alias template for remove_pointer @@ -2246,6 +2308,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// @cond undocumented +#if _GLIBCXX_USE_BUILTIN_TRAIT(__decay) + template + struct decay + { using type = __decay(_Tp); }; +#else // Decay trait for arrays and functions, used for perfect forwarding // in make_pair, make_tuple, etc. template @@ -2277,6 +2344,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct decay<_Tp&&> { using type = typename __decay_selector<_Tp>::type; }; +#endif /// @cond undocumented @@ -3157,7 +3225,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// std::is_invocable template struct is_invocable +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_invocable) + : public __bool_constant<__is_invocable(_Fn, _ArgTypes...)> +#else : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type +#endif { static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}), "_Fn must be a complete class or an unbounded array"); @@ -3183,8 +3255,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// std::is_nothrow_invocable template struct is_nothrow_invocable +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_nothrow_invocable) + : public __bool_constant<__is_nothrow_invocable(_Fn, _ArgTypes...)> +#else : __and_<__is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>, __call_is_nothrow_<_Fn, _ArgTypes...>>::type +#endif { static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}), "_Fn must be a complete class or an unbounded array"); @@ -3254,8 +3330,22 @@ template inline constexpr bool is_array_v<_Tp[_Num]> = true; #endif +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_pointer) template - inline constexpr bool is_pointer_v = is_pointer<_Tp>::value; + inline constexpr bool is_pointer_v = __is_pointer(_Tp); +#else +template + inline constexpr bool is_pointer_v = false; +template + inline constexpr bool is_pointer_v<_Tp*> = true; +template + inline constexpr bool is_pointer_v<_Tp* const> = true; +template + inline constexpr bool is_pointer_v<_Tp* volatile> = true; +template + inline constexpr bool is_pointer_v<_Tp* const volatile> = true; +#endif + template inline constexpr bool is_lvalue_reference_v = false; template @@ -3331,10 +3421,15 @@ template inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value; #endif +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_const) +template + inline constexpr bool is_const_v = __is_const(_Tp); +#else template inline constexpr bool is_const_v = false; template inline constexpr bool is_const_v = true; +#endif #if _GLIBCXX_USE_BUILTIN_TRAIT(__is_function) template @@ -3348,10 +3443,15 @@ template inline constexpr bool is_function_v<_Tp&&> = false; #endif +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_volatile) +template + inline constexpr bool is_volatile_v = __is_volatile(_Tp); +#else template inline constexpr bool is_volatile_v = false; template inline constexpr bool is_volatile_v = true; +#endif template inline constexpr bool is_trivial_v = __is_trivial(_Tp); @@ -3483,12 +3583,17 @@ template template inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value; +#if _GLIBCXX_USE_BUILTIN_TRAIT(__array_rank) +template + inline constexpr size_t rank_v = __array_rank(_Tp); +#else template inline constexpr size_t rank_v = 0; template inline constexpr size_t rank_v<_Tp[_Size]> = 1 + rank_v<_Tp>; template inline constexpr size_t rank_v<_Tp[]> = 1 + rank_v<_Tp>; +#endif template inline constexpr size_t extent_v = 0; @@ -3658,11 +3763,16 @@ template /// True for a type that is an array of unknown bound. /// @ingroup variable_templates /// @since C++20 +# if _GLIBCXX_USE_BUILTIN_TRAIT(__is_unbounded_array) + template + inline constexpr bool is_unbounded_array_v = __is_unbounded_array(_Tp); +# else template inline constexpr bool is_unbounded_array_v = false; template inline constexpr bool is_unbounded_array_v<_Tp[]> = true; +# endif /// True for a type that is an array of known bound. /// @since C++20 diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant index 51aaa62085170..13ea1dd384965 100644 --- a/libstdc++-v3/include/std/variant +++ b/libstdc++-v3/include/std/variant @@ -1758,11 +1758,6 @@ namespace __detail::__variant }, __rhs); } -#if defined(_GLIBCXX_CLANG) && __clang_major__ <= 7 - public: - using _Base::_M_u; // See https://bugs.llvm.org/show_bug.cgi?id=31852 -#endif - private: template friend constexpr decltype(auto) diff --git a/libstdc++-v3/include/tr2/dynamic_bitset b/libstdc++-v3/include/tr2/dynamic_bitset index 0e4e889428704..274c4f6a1386e 100644 --- a/libstdc++-v3/include/tr2/dynamic_bitset +++ b/libstdc++-v3/include/tr2/dynamic_bitset @@ -815,10 +815,7 @@ namespace tr2 operator>>=(size_type __pos) { if (__builtin_expect(__pos < this->_M_Nb, 1)) - { - this->_M_do_right_shift(__pos); - this->_M_do_sanitize(); - } + this->_M_do_right_shift(__pos); else this->_M_do_reset(); return *this; diff --git a/libstdc++-v3/include/tr2/dynamic_bitset.tcc b/libstdc++-v3/include/tr2/dynamic_bitset.tcc index 63ba6f285c7a1..5aac7d88ee374 100644 --- a/libstdc++-v3/include/tr2/dynamic_bitset.tcc +++ b/libstdc++-v3/include/tr2/dynamic_bitset.tcc @@ -60,8 +60,7 @@ namespace tr2 this->_M_w[__wshift] = this->_M_w[0] << __offset; } - //// std::fill(this->_M_w.begin(), this->_M_w.begin() + __wshift, - //// static_cast<_WordT>(0)); + std::fill_n(this->_M_w.begin(), __wshift, _WordT(0)); } } @@ -88,8 +87,7 @@ namespace tr2 this->_M_w[__limit] = this->_M_w[_M_w.size()-1] >> __offset; } - ////std::fill(this->_M_w.begin() + __limit + 1, this->_M_w.end(), - //// static_cast<_WordT>(0)); + std::fill_n(this->_M_w.end() - __wshift, __wshift, _WordT(0)); } } diff --git a/libstdc++-v3/libsupc++/new_opa.cc b/libstdc++-v3/libsupc++/new_opa.cc index 35606e1c1b3d7..c7c7e7946239c 100644 --- a/libstdc++-v3/libsupc++/new_opa.cc +++ b/libstdc++-v3/libsupc++/new_opa.cc @@ -47,7 +47,7 @@ using std::size_t; extern "C" { # if _GLIBCXX_HAVE_POSIX_MEMALIGN - void *posix_memalign(void **, size_t alignment, size_t size); + int posix_memalign(void **, size_t alignment, size_t size); # elif _GLIBCXX_HAVE_ALIGNED_ALLOC void *aligned_alloc(size_t alignment, size_t size); # elif _GLIBCXX_HAVE__ALIGNED_MALLOC diff --git a/libstdc++-v3/libsupc++/typeinfo b/libstdc++-v3/libsupc++/typeinfo index fcc3077d06091..35e72bb18ee52 100644 --- a/libstdc++-v3/libsupc++/typeinfo +++ b/libstdc++-v3/libsupc++/typeinfo @@ -188,6 +188,9 @@ namespace std #endif #if __GXX_TYPEINFO_EQUALITY_INLINE || __cplusplus > 202002L +# if ! __GXX_TYPEINFO_EQUALITY_INLINE + [[__gnu__::__always_inline__]] +# endif _GLIBCXX23_CONSTEXPR inline bool type_info::operator==(const type_info& __arg) const _GLIBCXX_NOEXCEPT { diff --git a/libstdc++-v3/testsuite/18_support/type_info/110572.cc b/libstdc++-v3/testsuite/18_support/type_info/110572.cc new file mode 100644 index 0000000000000..64081879b77d8 --- /dev/null +++ b/libstdc++-v3/testsuite/18_support/type_info/110572.cc @@ -0,0 +1,11 @@ +// { dg-options "-static-libstdc++" } +// { dg-require-static-libstdcxx } +// { dg-require-cpp-feature-test __cpp_rtti } +// { dg-do link } + +#include + +int main() +{ + return typeid(0) == typeid(0u); +} diff --git a/libstdc++-v3/testsuite/20_util/from_chars/8.cc b/libstdc++-v3/testsuite/20_util/from_chars/8.cc index a6343422c5a91..bacad89943b5f 100644 --- a/libstdc++-v3/testsuite/20_util/from_chars/8.cc +++ b/libstdc++-v3/testsuite/20_util/from_chars/8.cc @@ -17,7 +17,7 @@ // { dg-do run { target c++23 } } // { dg-add-options ieee } -// { dg-additional-options "-DSKIP_LONG_DOUBLE" { target aarch64-*-vxworks* } } +// { dg-additional-options "-DSKIP_LONG_DOUBLE" { target aarch64-*-vxworks* aarch64-*-rtems* } } #include #include diff --git a/libstdc++-v3/testsuite/20_util/is_invocable/incomplete_args_neg.cc b/libstdc++-v3/testsuite/20_util/is_invocable/incomplete_args_neg.cc index a575750f9e9ce..9619129b8170b 100644 --- a/libstdc++-v3/testsuite/20_util/is_invocable/incomplete_args_neg.cc +++ b/libstdc++-v3/testsuite/20_util/is_invocable/incomplete_args_neg.cc @@ -18,6 +18,7 @@ // . // { dg-error "must be a complete class" "" { target *-*-* } 0 } +// { dg-prune-output "invalid use of incomplete type" } #include diff --git a/libstdc++-v3/testsuite/20_util/is_invocable/incomplete_neg.cc b/libstdc++-v3/testsuite/20_util/is_invocable/incomplete_neg.cc index 05848603555bb..b478ebce815d5 100644 --- a/libstdc++-v3/testsuite/20_util/is_invocable/incomplete_neg.cc +++ b/libstdc++-v3/testsuite/20_util/is_invocable/incomplete_neg.cc @@ -18,6 +18,7 @@ // . // { dg-error "must be a complete class" "" { target *-*-* } 0 } +// { dg-prune-output "invalid use of incomplete type" } #include diff --git a/libstdc++-v3/testsuite/20_util/is_nothrow_invocable/incomplete_args_neg.cc b/libstdc++-v3/testsuite/20_util/is_nothrow_invocable/incomplete_args_neg.cc index 3c225883eaf25..3f8542dd366df 100644 --- a/libstdc++-v3/testsuite/20_util/is_nothrow_invocable/incomplete_args_neg.cc +++ b/libstdc++-v3/testsuite/20_util/is_nothrow_invocable/incomplete_args_neg.cc @@ -18,6 +18,7 @@ // . // { dg-error "must be a complete class" "" { target *-*-* } 0 } +// { dg-prune-output "invalid use of incomplete type" } #include diff --git a/libstdc++-v3/testsuite/20_util/is_nothrow_invocable/incomplete_neg.cc b/libstdc++-v3/testsuite/20_util/is_nothrow_invocable/incomplete_neg.cc index 5a728bfa03bac..d3bdf08448b5e 100644 --- a/libstdc++-v3/testsuite/20_util/is_nothrow_invocable/incomplete_neg.cc +++ b/libstdc++-v3/testsuite/20_util/is_nothrow_invocable/incomplete_neg.cc @@ -18,6 +18,7 @@ // . // { dg-error "must be a complete class" "" { target *-*-* } 0 } +// { dg-prune-output "invalid use of incomplete type" } #include diff --git a/libstdc++-v3/testsuite/20_util/to_address/1_neg.cc b/libstdc++-v3/testsuite/20_util/to_address/1_neg.cc index 7385f0f335c0a..10e919757bbb0 100644 --- a/libstdc++-v3/testsuite/20_util/to_address/1_neg.cc +++ b/libstdc++-v3/testsuite/20_util/to_address/1_neg.cc @@ -16,7 +16,7 @@ // . // { dg-do compile { target c++20 } } -// { dg-error "not a function pointer" "" { target *-*-* } 0 } +// { dg-error "must not be a function pointer" "" { target *-*-* } 0 } #include diff --git a/libstdc++-v3/testsuite/20_util/to_chars/float128_c++23.cc b/libstdc++-v3/testsuite/20_util/to_chars/float128_c++23.cc index ca00761ee7c98..6cb9cadcd2041 100644 --- a/libstdc++-v3/testsuite/20_util/to_chars/float128_c++23.cc +++ b/libstdc++-v3/testsuite/20_util/to_chars/float128_c++23.cc @@ -19,7 +19,7 @@ // { dg-require-effective-target ieee_floats } // { dg-require-effective-target size32plus } // { dg-add-options ieee } -// { dg-xfail-run-if "from_chars limited to double-precision" { aarch64-*-vxworks* } } +// { dg-xfail-run-if "from_chars limited to double-precision" { aarch64-*-vxworks* aarch64-*-rtems* } } #include #include diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/115420.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/115420.cc new file mode 100644 index 0000000000000..5528bf813bd72 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/115420.cc @@ -0,0 +1,16 @@ +// { dg-do compile { target c++11 } } + +#include + +struct S { }; + +void +test_pr115420() +{ + std::unordered_map m; // { dg-error "here" } +} + +// { dg-error "hash function must be copy constructible" "" { target *-*-* } 0 } +// { dg-prune-output "use of deleted function" } +// { dg-prune-output "is private" } +// { dg-prune-output "no matching function" } diff --git a/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc b/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc index 8c61a614a4779..08a47aa95c3f0 100644 --- a/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc +++ b/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc @@ -19,6 +19,14 @@ #include +#if __cplusplus >= 202002L +#ifndef __cpp_lib_ranges +# error "Feature test macro for ranges is missing in " +#elif __cpp_lib_ranges < 201911L +# error "Feature test macro for ranges has wrong value in " +#endif +#endif + namespace std { // 25.1, non-modifying sequence operations: diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/constexpr_std_c++23.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/constexpr_std_c++23.cc index 0e3d112fe2e80..3c2377fd6987b 100644 --- a/libstdc++-v3/testsuite/26_numerics/headers/cmath/constexpr_std_c++23.cc +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/constexpr_std_c++23.cc @@ -16,6 +16,7 @@ // . // { dg-do link { target c++23 } } +// { dg-require-cmath "" } #include #include diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++23.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++23.cc index 000cebf364aaa..ea68ac5da7551 100644 --- a/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++23.cc +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++23.cc @@ -16,6 +16,7 @@ // . // { dg-do link { target c++23 } } +// { dg-require-cmath "" } #include #include diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/nextafter_c++23.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/nextafter_c++23.cc index 7d7e10bd8aea3..91767d22cc3f2 100644 --- a/libstdc++-v3/testsuite/26_numerics/headers/cmath/nextafter_c++23.cc +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/nextafter_c++23.cc @@ -16,6 +16,7 @@ // . // { dg-do run { target c++23 } } +// { dg-require-cmath "" } #include #include diff --git a/libstdc++-v3/testsuite/25_algorithms/iota/1.cc b/libstdc++-v3/testsuite/26_numerics/iota/2.cc similarity index 96% rename from libstdc++-v3/testsuite/25_algorithms/iota/1.cc rename to libstdc++-v3/testsuite/26_numerics/iota/2.cc index 61bf418b4dae4..040c48d91ce21 100644 --- a/libstdc++-v3/testsuite/25_algorithms/iota/1.cc +++ b/libstdc++-v3/testsuite/26_numerics/iota/2.cc @@ -1,6 +1,6 @@ // { dg-do run { target c++23 } } -#include +#include #include #include diff --git a/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/114359.cc b/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/114359.cc index c1e4c380bf91d..12d967dcbfd34 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/114359.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/114359.cc @@ -2,6 +2,19 @@ // Bug 114359 - std::binomial_distribution hangs in infinite loop +// { dg-require-cmath "" } + +// The requirement above is not strictly true. The test should work +// without cmath, and it probably does, but without cmath, +// binomial_distribution::operator() skips the optimized algorithm and +// calls _M_waiting to loop a gazillion times. On aarch64-rtems6 +// qemu, that loop takes over 5 minutes to go through a small fraction +// of the iteration space (__x at 22k, limited at 1G; __sum at 2e-5, +// limited at 0.69). The bug we're regression-testing here was in the +// cmath-requiring bit, so even if this could conceivably not time out +// on a really fast machine, there's hardly any reason to exercise +// this extreme case. + #include int main() diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_float/constinit.cc b/libstdc++-v3/testsuite/29_atomics/atomic_float/constinit.cc new file mode 100644 index 0000000000000..6b3f4f76b4ccb --- /dev/null +++ b/libstdc++-v3/testsuite/29_atomics/atomic_float/constinit.cc @@ -0,0 +1,3 @@ +// { dg-do compile { target c++20 } } +#include +constinit std::atomic a(0.0f); diff --git a/libstdc++-v3/testsuite/std/ranges/range.cc b/libstdc++-v3/testsuite/std/ranges/range.cc index 1843565913756..760f6ffacfdb9 100644 --- a/libstdc++-v3/testsuite/std/ranges/range.cc +++ b/libstdc++-v3/testsuite/std/ranges/range.cc @@ -83,3 +83,9 @@ static_assert( same_as, char&&> ); static_assert( same_as, WritableObject> ); + +// LWG 3860. range_common_reference_t is missing +static_assert( same_as, + char&> ); +static_assert( same_as, + char&> ); diff --git a/libstdc++-v3/testsuite/std/time/leap_seconds/io.cc b/libstdc++-v3/testsuite/std/time/leap_seconds/io.cc new file mode 100644 index 0000000000000..511fafdd1a0bd --- /dev/null +++ b/libstdc++-v3/testsuite/std/time/leap_seconds/io.cc @@ -0,0 +1,56 @@ +// { dg-do run { target c++20 } } +// { dg-require-effective-target tzdb } +// { dg-require-effective-target cxx11_abi } + +#include +#include +#include +#include + +void +test_output() +{ + using namespace std::chrono; + + std::ostringstream out; + out << '\n'; + + for (auto& l : get_tzdb().leap_seconds) + if (l <= sys_days{2018y/March/17d}) + out << l.date() << ": " << l.value() << '\n'; + + VERIFY( out.str() == R"( +1972-07-01 00:00:00: 1s +1973-01-01 00:00:00: 1s +1974-01-01 00:00:00: 1s +1975-01-01 00:00:00: 1s +1976-01-01 00:00:00: 1s +1977-01-01 00:00:00: 1s +1978-01-01 00:00:00: 1s +1979-01-01 00:00:00: 1s +1980-01-01 00:00:00: 1s +1981-07-01 00:00:00: 1s +1982-07-01 00:00:00: 1s +1983-07-01 00:00:00: 1s +1985-07-01 00:00:00: 1s +1988-01-01 00:00:00: 1s +1990-01-01 00:00:00: 1s +1991-01-01 00:00:00: 1s +1992-07-01 00:00:00: 1s +1993-07-01 00:00:00: 1s +1994-07-01 00:00:00: 1s +1996-01-01 00:00:00: 1s +1997-07-01 00:00:00: 1s +1999-01-01 00:00:00: 1s +2006-01-01 00:00:00: 1s +2009-01-01 00:00:00: 1s +2012-07-01 00:00:00: 1s +2015-07-01 00:00:00: 1s +2017-01-01 00:00:00: 1s +)" ); +} + +int main() +{ + test_output(); +} diff --git a/libstdc++-v3/testsuite/tr2/dynamic_bitset/pr115399.cc b/libstdc++-v3/testsuite/tr2/dynamic_bitset/pr115399.cc new file mode 100644 index 0000000000000..e626e4a5d1566 --- /dev/null +++ b/libstdc++-v3/testsuite/tr2/dynamic_bitset/pr115399.cc @@ -0,0 +1,37 @@ +// { dg-do run { target c++11 } } + +// PR libstdc++/115399 +// std::tr2::dynamic_bitset shift behaves differently from std::bitset + +#include +#include + +void +test_left_shift() +{ + std::tr2::dynamic_bitset<> b(65); + b[0] = 1; + auto b2 = b << 64; + VERIFY(b2[64] == 1); + VERIFY(b2[0] == 0); + b <<= 64; + VERIFY( b2 == b ); +} + +void +test_right_shift() +{ + std::tr2::dynamic_bitset<> b(65); + b[64] = 1; + auto b2 = b >> 64; + VERIFY(b2[64] == 0); + VERIFY(b2[0] == 1); + b >>= 64; + VERIFY( b2 == b ); +} + +int main() +{ + test_left_shift(); + test_right_shift(); +}