aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc
AgeCommit message (Collapse)AuthorFilesLines
2024-11-14aarch64: Add support for fp8fma instructionsSaurabh Jha1-0/+2
The AArch64 FEAT_FP8FMA extension introduces instructions for multiply-add of vectors. This patch introduces the following instructions: 1. {vmlalbq|vmlaltq}_f16_mf8_fpm. 2. {vmlalbq|vmlaltq}_lane{q}_f16_mf8_fpm. 3. {vmlallbbq|vmlallbtq|vmlalltbq|vmlallttq}_f32_mf8_fpm. 4. {vmlallbbq|vmlallbtq|vmlalltbq|vmlallttq}_lane{q}_f32_mf8_fpm. It introduces the fp8fma flag. gcc/ChangeLog: * config/aarch64/aarch64-builtins.cc (check_simd_lane_bounds): Add support for new unspecs. (aarch64_expand_pragma_builtins): Add support for new unspecs. * config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins): New flags. * config/aarch64/aarch64-option-extensions.def (AARCH64_OPT_EXTENSION): New flags. * config/aarch64/aarch64-simd-pragma-builtins.def (ENTRY_FMA_FPM): Macro to declare fma intrinsics. (REQUIRED_EXTENSIONS): Define to declare functions behind command line flags. * config/aarch64/aarch64-simd.md: (@aarch64_<fpm_uns_op><VQ_HSF:mode><VQ_HSF:mode><V16QI_ONLY:mode><V16QI_ONLY:mode): Instruction pattern for fma intrinsics. (@aarch64_<fpm_uns_op><VQ_HSF:mode><VQ_HSF:mode><V16QI_ONLY:mode><VB:mode><SI_ONLY:mode): Instruction pattern for fma intrinsics with lane. * config/aarch64/aarch64.h (TARGET_FP8FMA): New flag for fp8fma instructions. * config/aarch64/iterators.md: New attributes and iterators. * doc/invoke.texi: New flag for fp8fma instructions. gcc/testsuite/ChangeLog: * gcc.target/aarch64/simd/fma_fpm.c: New test.
2024-11-14aarch64: Add support for fp8dot2 and fp8dot4Saurabh Jha1-0/+4
The AArch64 FEAT_FP8DOT2 and FEAT_FP8DOT4 extension introduces instructions for dot product of vectors. This patch introduces the following intrinsics: 1. vdot{q}_{fp16|fp32}_mf8_fpm. 2. vdot{q}_lane{q}_{fp16|fp32}_mf8_fpm. It introduces two flags: fp8dot2 and fp8dot4. We had to add space for another type in aarch64_pragma_builtins_data struct. The macros were updated to reflect that. We added a new aarch64_builtin_signature variant, quaternary, and added support for it in the functions aarch64_fntype and aarch64_expand_pragma_builtin. We added a new namespace, function_checker, to implement range checks for functions defined using the new pragma approach. The old intrinsic range checks will continue to work. All the new AdvSIMD intrinsics we define that need lane checks should be using the function in this namespace to implement the checks. gcc/ChangeLog: * config/aarch64/aarch64-builtins.cc (ENTRY): Change to handle extra type. (enum class): Added new variant. (struct aarch64_pragma_builtins_data): Add support for another type. (aarch64_get_number_of_args): Handle new signature. (require_integer_constant): New function to check whether the operand is an integer constant. (require_immediate_range): New function to validate index ranges. (check_simd_lane_bounds): New function to validate index operands. (aarch64_general_check_builtin_call): Call function_checker::check-simd_lane_bounds. (aarch64_expand_pragma_builtin): Handle new signature. * config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins): New flags. * config/aarch64/aarch64-option-extensions.def (AARCH64_OPT_EXTENSION): New flags. * config/aarch64/aarch64-simd-pragma-builtins.def (ENTRY_BINARY): Change to handle extra type. (ENTRY_BINARY_FPM): Change to handle extra type. (ENTRY_UNARY_FPM): Change to handle extra type. (ENTRY_TERNARY_FPM_LANE): Macro to declare fpm ternary with lane intrinsics. (ENTRY_VDOT_FPM): Macro to declare vdot intrinsics. (REQUIRED_EXTENSIONS): Define to declare functions behind command line flags. * config/aarch64/aarch64-simd.md: (@aarch64_<fpm_uns_op><VHF:mode><VHF:mode><VB:mode><VB:mode>): Instruction pattern for vdot2 intrinsics. (@aarch64_<fpm_uns_op><VHF:mode><VHF:mode><VB:mode><VB2:mode><SI_ONLY:mode>): Instruction pattern for vdot2 intrinsics with lane. (@aarch64_<fpm_uns_op><VDQSF:mode><VDQSF:mode><VB:mode><VB:mode>): Instruction pattern for vdot4 intrinsics. (@aarch64_<fpm_uns_op><VDQSF:mode><VDQSF:mode><VB:mode><VB2:mode><SI_ONLY:mode>): Instruction pattern for vdo4 intrinsics with lane. * config/aarch64/aarch64.h (TARGET_FP8DOT2): New flag for fp8dot2 instructions. (TARGET_FP8DOT4): New flag for fp8dot4 instructions. * config/aarch64/iterators.md: New attributes and iterators. * doc/invoke.texi: New flag for fp8dot2 and fp8dot4 instructions. gcc/testsuite/ChangeLog: * gcc.target/aarch64/simd/vdot2_fpmdot.c: New test. * gcc.target/aarch64/simd/vdot4_fpmdot.c: New test.
2024-11-13i386: Add -mveclibabi=aocl [PR56504]Filip Kastl1-15/+42
We currently support generating vectorized math calls to the AMD core math library (ACML) (-mveclibabi=acml). That library is end-of-life and its successor is the math library from AMD Optimizing CPU Libraries (AOCL). This patch adds support for AOCL (-mveclibabi=aocl). That significantly broadens the range of vectorized math functions optimized for AMD CPUs that GCC can generate calls to. See the edit to invoke.texi for a complete list of added functions. Compared to the list of functions in AOCL LibM docs I left out these vectorized function families: - sincos and all functions working with arrays ... Because these functions have pointer arguments and that would require a bigger rework of ix86_veclibabi_aocl(). Also, I'm not sure if GCC even ever generates calls to these functions. - linearfrac ... Because these functions are specific to the AMD library. There's no equivalent glibc function nor GCC internal function nor GCC built-in. - powx, sqrt, fabs ... Because GCC doesn't vectorize these functions into calls and uses instructions instead. I also left amd_vrd2_expm1() (the AMD docs list the function but I wasn't able to link calls to it with the current version of the library). gcc/ChangeLog: PR target/56504 * config/i386/i386-options.cc (ix86_option_override_internal): Add ix86_veclibabi_type_aocl case. * config/i386/i386-options.h (ix86_veclibabi_aocl): Add extern ix86_veclibabi_aocl(). * config/i386/i386-opts.h (enum ix86_veclibabi): Add ix86_veclibabi_type_aocl into the ix86_veclibabi enum. * config/i386/i386.cc (ix86_veclibabi_aocl): New function. * config/i386/i386.opt: Add the 'aocl' type. * doc/invoke.texi: Document -mveclibabi=aocl. gcc/testsuite/ChangeLog: PR target/56504 * gcc.target/i386/vectorize-aocl1.c: New test. Signed-off-by: Filip Kastl <fkastl@suse.cz>
2024-11-13Introduce TARGET_CLONES_ATTR_SEPARATOR for RISC-VYangyu Chen2-0/+14
Some architectures may use ',' in the attribute string, but it is not used as the separator for different targets. To avoid conflict, we introduce a new macro TARGET_CLONES_ATTR_SEPARATOR to separate different clones. As an example, according to RISC-V C-API Specification [1], RISC-V allows ',' in the attribute string in the "arch=" option to specify one more ISA extensions in the same target function, which conflict with the default separator to separate different clones. This patch introduces TARGET_CLONES_ATTR_SEPARATOR for RISC-V and choose '#' as the separator, since '#' is not allowed in the target_clones option string. [1] https://github.com/riscv-non-isa/riscv-c-api-doc/blob/c6c5d6d9cf96b342293315a5dff3d25e96ef8191/src/c-api.adoc#__attribute__targetattr-string Signed-off-by: Yangyu Chen <cyy@cyyself.name> gcc/ChangeLog: * defaults.h (TARGET_CLONES_ATTR_SEPARATOR): Define new macro. * multiple_target.cc (get_attr_str): Use TARGET_CLONES_ATTR_SEPARATOR to separate attributes. (separate_attrs): Likewise. (expand_target_clones): Likewise. * attribs.cc (attr_strcmp): Likewise. (sorted_attr_string): Likewise. * tree.cc (get_target_clone_attr_len): Likewise. * config/riscv/riscv.h (TARGET_CLONES_ATTR_SEPARATOR): Define TARGET_CLONES_ATTR_SEPARATOR for RISC-V. * doc/tm.texi: Document TARGET_CLONES_ATTR_SEPARATOR. * doc/tm.texi.in: Likewise.
2024-11-13c: add Wzero-as-null-pointer-constant [PR117059]Martin Uecker1-3/+2
Add warnings for the use of zero as a null pointer constant to the C FE. PR c/117059 gcc/c-family/ChangeLog: * c.opt (Wzero-as-null-pointer-constant): Enable for C and ObjC. gcc/c/ChangeLog: * c-typeck.cc (parse_build_binary_op): Add warning. (build_conditional_expr): Add warning. (convert_for_assignment): Add warning. gcc/ChangeLog: * doc/invoke.texi (Wzero-as-null-pointer-constant): Adapt description. gcc/testsuite/ChangeLog: * gcc.dg/Wzero-as-null-pointer-constant.c: New test. Suggested-by: Alejandro Colomar <alx@kernel.org> Acked-by: Alejandro Colomar <alx@kernel.org> Reviewed-by: Joseph Myers <josmyers@redhat.com>
2024-11-11c++: rename -fmodules-ts to -fmodulesJason Merrill1-12/+12
The C++ modules support is not targeting the Modules TS, so it doesn't make much sense to refer to the TS in the option name. But keep the old spelling as an undocumented alias for now. gcc/ChangeLog: * doc/invoke.texi: Rename -fmodules-ts to -fmodules. gcc/c-family/ChangeLog: * c.opt: Add -fmodules with same effect as -fmodules-ts. gcc/cp/ChangeLog: * lang-specs.h: Check fmodules* instead of fmodules-ts.
2024-11-11c++: Add __builtin_operator_{new,delete} supportJakub Jelinek1-0/+28
clang++ adds __builtin_operator_{new,delete} builtins which as documented work similarly to ::operator {new,delete}, except that it is an error if the called ::operator {new,delete} is not a replaceable global operator and allow optimizations which C++ normally allows just when those are used from new/delete expressions https://eel.is/c++draft/expr.new#14 When using these builtins, the same optimizations can be done even when using those builtins. For GCC we note that in the CALL_FROM_NEW_OR_DELETE_P flag on CALL_EXPRs. The following patch implements it as a C++ FE keyword (because passing references through ... changes the argument and so BUILT_IN_FRONTEND builtin can't be used), just attempts to call the ::operator {new,delete} and if it isn't replaceable, diagnoses it. libstdc++ already uses the builtin in some cases. 2024-11-11 Jakub Jelinek <jakub@redhat.com> gcc/c-family/ * c-common.h (enum rid): Add RID_BUILTIN_OPERATOR_NEW and RID_BUILTIN_OPERATOR_DELETE. (names_builtin_p): Change return type from bool to int. * c-common.cc (c_common_reswords): Add __builtin_operator_new and __builtin_operator_delete. gcc/c/ * c-decl.cc (names_builtin_p): Change return type from bool to int, adjust return statments. gcc/cp/ * parser.cc (cp_parser_postfix_expression): Handle RID_BUILTIN_OPERATOR_NEW and RID_BUILTIN_OPERATOR_DELETE. * cp-objcp-common.cc (names_builtin_p): Change return type from bool to int, adjust return statments. Handle RID_BUILTIN_OPERATOR_NEW and RID_BUILTIN_OPERATOR_DELETE. * pt.cc (tsubst_expr) <case CALL_EXPR>: Handle CALL_FROM_NEW_OR_DELETE_P. gcc/ * doc/extend.texi (New/Delete Builtins): Document __builtin_operator_new and __builtin_operator_delete. gcc/testsuite/ * g++.dg/ext/builtin-operator-new-1.C: New test. * g++.dg/ext/builtin-operator-new-2.C: New test. * g++.dg/ext/builtin-operator-new-3.C: New test.
2024-11-11aarch64: Add common subset of SVE2p1 and SMERichard Sandiford1-0/+2
Some instructions that were previously restricted to streaming mode can also be used in non-streaming mode with SVE2.1. This patch adds support for those, as well as the usual new-extension boilerplate. A later patch will add the feature macro. gcc/ * config/aarch64/aarch64-option-extensions.def (sve2p1): New extension. * doc/invoke.texi (sve2p1): Document it. * config/aarch64/aarch64-sve-builtins-sve2.def: Mark instructions that are common to both SVE2p1 and SME. * config/aarch64/aarch64.h (TARGET_SVE2p1): New macro. (TARGET_SVE2p1_OR_SME): Likewise. * config/aarch64/aarch64-sve2.md (@aarch64_sve_psel<BHSD_BITS>): Require TARGET_SVE2p1_OR_SME instead of TARGET_STREAMING. (*aarch64_sve_psel<BHSD_BITS>_plus): Likewise. (@aarch64_sve_<su>clamp<mode>): Likewise. (*aarch64_sve_<su>clamp<mode>_x): Likewise. (@aarch64_pred_<optab><mode>): Likewise. (@cond_<optab><mode>): Likewise. gcc/testsuite/ * lib/target-supports.exp (check_effective_target_aarch64_asm_sve2p1_ok): New procedure. * gcc.target/aarch64/sve/clamp_1.c: New test. * gcc.target/aarch64/sve/clamp_2.c: Likewise. * gcc.target/aarch64/sve2/acle/asm/clamp_s16.c: Likewise. * gcc.target/aarch64/sve2/acle/asm/clamp_s32.c: Likewise. * gcc.target/aarch64/sve2/acle/asm/clamp_s64.c: Likewise. * gcc.target/aarch64/sve2/acle/asm/clamp_s8.c: Likewise. * gcc.target/aarch64/sve2/acle/asm/clamp_u16.c: Likewise. * gcc.target/aarch64/sve2/acle/asm/clamp_u32.c: Likewise. * gcc.target/aarch64/sve2/acle/asm/clamp_u64.c: Likewise. * gcc.target/aarch64/sve2/acle/asm/clamp_u8.c: Likewise. * gcc.target/aarch64/sve2/acle/asm/psel_lane_b16.c: Likewise. * gcc.target/aarch64/sve2/acle/asm/psel_lane_b32.c: Likewise. * gcc.target/aarch64/sve2/acle/asm/psel_lane_b64.c: Likewise. * gcc.target/aarch64/sve2/acle/asm/psel_lane_b8.c: Likewise. * gcc.target/aarch64/sve2/acle/asm/psel_lane_c16.c: Likewise. * gcc.target/aarch64/sve2/acle/asm/psel_lane_c32.c: Likewise. * gcc.target/aarch64/sve2/acle/asm/psel_lane_c64.c: Likewise. * gcc.target/aarch64/sve2/acle/asm/psel_lane_c8.c: Likewise. * gcc.target/aarch64/sve2/acle/asm/revd_bf16.c: Likewise. * gcc.target/aarch64/sve2/acle/asm/revd_f16.c: Likewise. * gcc.target/aarch64/sve2/acle/asm/revd_f32.c: Likewise. * gcc.target/aarch64/sve2/acle/asm/revd_f64.c: Likewise. * gcc.target/aarch64/sve2/acle/asm/revd_s16.c: Likewise. * gcc.target/aarch64/sve2/acle/asm/revd_s32.c: Likewise. * gcc.target/aarch64/sve2/acle/asm/revd_s64.c: Likewise. * gcc.target/aarch64/sve2/acle/asm/revd_s8.c: Likewise. * gcc.target/aarch64/sve2/acle/asm/revd_u16.c: Likewise. * gcc.target/aarch64/sve2/acle/asm/revd_u32.c: Likewise. * gcc.target/aarch64/sve2/acle/asm/revd_u64.c: Likewise. * gcc.target/aarch64/sve2/acle/asm/revd_u8.c: Likewise.
2024-11-11doc: install: document UBSAN_OPTIONSSam James1-1/+3
Explain that 'bootstrap-ubsan' won't abort on errors by default and how to override that by setting UBSAN_OPTIONS. gcc/ChangeLog: PR other/116948 * doc/install.texi (Building a native compiler): Document UBSAN_OPTIONS.
2024-11-11doc: install: document bootstrap-ubsanSam James1-0/+4
gcc/ChangeLog: PR other/116948 * doc/install.texi (Building a native compiler): Mention bootstrap-ubsan.
2024-11-11Initial Diamond Rapids SupportHaochen Jiang2-0/+17
gcc/ChangeLog: * common/config/i386/cpuinfo.h (get_intel_cpu): Handle Diamond Rapids. * common/config/i386/i386-common.cc (processor_name): Add Diamond Rapids. (processor_alias_table): Ditto. * common/config/i386/i386-cpuinfo.h (enum processor_types): Add INTEL_COREI7_DIAMONDRAPIDS. * config.gcc: Add -march=diamondrapids. * config/i386/driver-i386.cc (host_detect_local_cpu): Handle diamondrapids. * config/i386/i386-c.cc (ix86_target_macros_internal): Ditto. * config/i386/i386-options.cc (processor_cost_table): Ditto. (m_DIAMONDRAPIDS): New. (m_CORE_AVX512): Add diamondrapids. * config/i386/i386.h (enum processor_type): Ditto. * doc/extend.texi: Ditto. * doc/invoke.texi: Ditto. gcc/testsuite/ChangeLog: * g++.target/i386/mv16.C: Ditto. * gcc.target/i386/funcspec-56.inc: Handle new march.
2024-11-08aarch64: Extend support for the AE family of Cortex CPUsVictor Do Nascimento1-4/+5
Implement -mcpu options for: - Cortex-A520AE - Cortex-A720AE - Cortex-R82AE These all implement the same feature sets as their non-AE counterparts, using the same scheduler and costs and differing only in their respective part numbers. gcc/ChangeLog: * config/aarch64/aarch64-cores.def (cortex-a520ae, cortex-a720ae, cortex-r82ae): Define new entries. * config/aarch64/aarch64-tune.md: Regenerate. * doc/invoke.texi: Document A520AE, A720AE and R82AE CPUs.
2024-11-07Doc: Add doc for standard name mask_len_strided_load{store}mPan Li1-0/+27
This patch would like to add doc for the below 2 standard names. 1. strided load: v = mask_len_strided_load (ptr, stried, mask, len, bias) 2. strided store: mask_len_stried_store (ptr, stride, v, mask, len, bias) gcc/ChangeLog: * doc/md.texi: Add doc for mask_len_stried_load{store}. Signed-off-by: Pan Li <pan2.li@intel.com> Co-Authored-By: Juzhe-Zhong <juzhe.zhong@rivai.ai>
2024-11-04aarch64: Fix incorrect LS64 documentationRichard Sandiford1-3/+2
As Yuta Mukai pointed out, the manual wrongly said that LS64 is enabled by default for Armv8.7-A and above, and for Armv9.2-A and above. LS64 is not mandatory at any architecture level (and the code correctly implemented that). I think this was a leftover from an early version of the spec. gcc/ * doc/invoke.texi: Fix documentation of LS64 so that it's not implied by Armv8.7-A or Armv9.2-A.
2024-11-04aarch64: Add support for FUJITSU-MONAKA (-mcpu=fujitsu-monaka) CPUYuta Mukai1-1/+1
This patch adds initial support for FUJITSU-MONAKA CPU. The cost model will be corrected in the future. 2024-11-04 Yuta Mukai <mukai.yuta@fujitsu.com> gcc/ChangeLog: * config/aarch64/aarch64-cores.def (AARCH64_CORE): Add fujitsu-monaka. * config/aarch64/aarch64-tune.md: Regenerate. * config/aarch64/aarch64.cc: Include fujitsu-monaka tuning model. * doc/invoke.texi: Document -mcpu=fujitsu-monaka. * config/aarch64/tuning_models/fujitsu_monaka.h: New file.
2024-11-03docs: Document that __builtin_assoc_barrier also can be used for FMAs [PR115023]Andrew Pinski1-2/+14
I noticed that __builtin_assoc_barrier makes a differnce for FMAs formation but it was not documented. This adds that documentation even with a small example. Build the HTML documents to make sure everything looks correct. gcc/ChangeLog: PR middle-end/115023 * doc/extend.texi (__builtin_assoc_barrier): Document ffp-contract=fast and FMA usage. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2024-11-01[committed] Make LRA default for ft32 and remove -mlra optionJeff Law1-2/+1
I was looking to clean up an old patch I'm carrying in my tester. My first thought was that ft32 was likely going to be deprecated because it wasn't using LRA -- which in turn would mean the patch in question could just be removed. But then I checked, ft32 has an LRA option and if turned on it gets the exact same test results as with reload. While the port mentions a failure with sieve.c, that's been there since the port was introduced in 2015. It's working well enough that I think just converting it is the right thing to do. The testsuite patch which precipitated this one will follow separately. I've kept the -mlra option for compatibility sake, but it's ignored. Pushing to the trunk. gcc/ * config/ft32/ft32.cc (ft32_lra_p): Remove. (TARGET_LRA_P): Likewise. * config/ft32/ft32.opt: Make -mlra ignored. * doc/invoke.texi: Adjust documentation for -mlra on ft32.
2024-11-01c++: Adjust docs and option descriptions for the publishing of C++23Jakub Jelinek2-12/+22
Now that C++23 has been finally published, the following patch attempts to mention it in the option descriptions and documentation. Given that it has been published about 1.5 years after being finalized and has the 14882:2024 document number pair rather than :2023, I wasn't sure when exactly to use 2023 (as informal name) and when 2024 (as year of publishing), so I've tried to use 2024 in standards.texi which talks more formally about the standards and a note that it has been published in 2024 when it is talked about more informally. I remember at least one older edition has been published in January too, but the ISO pages pretend it was published still in December of the previous year, in this case it doesn't. 2024-11-01 Jakub Jelinek <jakub@redhat.com> gcc/ * doc/standards.texi (C++ Language): Mention also the 2024 revision and -std=gnu++23 option. * doc/invoke.texi (-std=): Adjust description of c++23, c++2b, gnu++23 and gnu++2b now that ISO C++ 14882:2024 is published. gcc/c-family/ * c.opt (std=c++2b, std=c++23, std=gnu++2b, std=gnu++23): Adjust description now that ISO C++ 14882:2024 is published.
2024-11-01Support Intel AMX-MOVRSHu, Lin13-3/+14
gcc/ChangeLog: * common/config/i386/cpuinfo.h (get_available_features): Detect AMX-MOVRS. * common/config/i386/i386-common.cc (OPTION_MASK_ISA2_AMX_MOVRS_SET): New. (OPTION_MASK_ISA2_AMX_MOVRS_UNSET): Ditto. (ix86_handle_option): Handle -mamx-movrs. * common/config/i386/i386-cpuinfo.h (enum processor_features): Add FEATURE_AMX_MOVRS. * common/config/i386/i386-isas.h: Add ISA_NAME_TABLE_ENTRY for amx-movrs. * config.gcc: Add amxmovrsintrin.h. * config/i386/cpuid.h (bit_AMX_MOVRS): New. * config/i386/i386-c.cc (ix86_target_macros_internal): Define __AMX_MOVRS__. * config/i386/i386-isa.def (AMX_MOVRS): Add DEF_PTA(AMX_MOVRS). * config/i386/i386-options.cc (ix86_valid_target_attribute_inner_p): Handle amx-movrs. * config/i386/i386.opt: Add option -mamx-movrs. * config/i386/i386.opt.urls: Regenerated. * config/i386/immintrin.h: Include amxmovrsintrin.h * doc/extend.texi: Document amx-movrs. * doc/invoke.texi: Document -mamx-movrs. * doc/sourcebuild.texi: Document target amx-movrs. * config/i386/amxmovrsintrin.h: New file. gcc/testsuite/ChangeLog: * g++.dg/other/i386-2.C: Add -mamx-movrs. * g++.dg/other/i386-3.C: Ditto. * gcc.target/i386/amx-check.h: Add new check for amx-movrs. * gcc.target/i386/funcspec-56.inc: Add new target attribute. * gcc.target/i386/sse-12.c: Add -mamx-movrs. * gcc.target/i386/sse-13.c: Ditto. * gcc.target/i386/sse-14.c: Ditto. * gcc.target/i386/sse-22.c: Add amx-movrs. * gcc.target/i386/sse-23.c: Ditto. * lib/target-supports.exp (check_effective_target_amx_movrs): New. * gcc.target/i386/amxmovrs-asmatt-1.c: New test. * gcc.target/i386/amxmovrs-asmintel-1.c: Ditto. * gcc.target/i386/amxmovrs-t2rpntlvw-2.c: Ditto. * gcc.target/i386/amxmovrs-tileloaddrs-2.c: Ditto.
2024-11-01Support Intel MOVRSHu, Lin14-6/+18
gcc/ChangeLog: * builtins.cc (expand_builtin_prefetch): Expand for prefetchrst2. * common/config/i386/cpuinfo.h (get_available_features): Detect movrs. * common/config/i386/i386-common.cc (OPTION_MASK_ISA2_MOVRS_SET): New. (OPTION_MASK_ISA2_MOVRS_UNSET): Ditto. (ix86_handle_option): Handle -mmovrs. * common/config/i386/i386-cpuinfo.h (enum processor_features): Add FEATURE_MOVRS. * common/config/i386/i386-isas.h: Add ISA_NAME_TABLE_ENTRY for movrs. * config.gcc: Add movrsintrin.h * config/i386/cpuid.h (bit_MOVRS): New. * config/i386/i386-builtin-types.def: Add DEF_FUNCTION_TYPE (CHAR, PCCHAR), (SHORT, PCSHORT), (INT, PCINT), (INT64, PCINT64). * config/i386/i386-builtin.def (BDESC): Add new builtins. * config/i386/i386-c.cc (ix86_target_macros_internal): Add __MOVRS__. * config/i386/i386-expand.cc (ix86_expand_special_args_builtin): Define __MOVRS__. * config/i386/i386-isa.def (MOVRS): Add DEF_PTA(MOVRS) * config/i386/i386-options.cc (ix86_valid_target_attribute_inner_p): Handle movrs. * config/i386/i386.md (movrs<mode>): New. * config/i386/i386.opt: Add option -mmovrs. * config/i386/i386.opt.urls: Regenerated. * config/i386/immintrin.h: Include movrsintrin.h * config/i386/sse.md (unspecv): Add UNSPEC_VMOVRS. (VI1248_AVX10_2): New. (avx10_2_movrs_vmovrs<ssemodesuffix><mode><mask_name>): New define_insn. * config/i386/xmmintrin.h: Add prefetchrst2. * doc/extend.texi: Document movrs. * doc/invoke.texi: Document -mmovrs. * doc/rtl.texi: Document extension of prefetchrst2. * doc/sourcebuild.texi: Document target movrs. * config/i386/movrsintrin.h: New. gcc/testsuite/ChangeLog: * g++.dg/other/i386-2.C: Add -mmovrs. * g++.dg/other/i386-3.C: Ditto. * gcc.c-torture/execute/builtin-prefetch-1.c: Expand rws. * gcc.dg/builtin-prefetch-1.c: Ditto. * gcc.target/i386/avx-1.c: Ditto. * gcc.target/i386/avx-2.c: Ditto. * gcc.target/i386/funcspec-56.inc: Add new target attribute. * gcc.target/i386/sse-12.c: Add -mmovrs. * gcc.target/i386/sse-13.c: Ditto. * gcc.target/i386/sse-14.c: Ditto. * gcc.target/i386/sse-22.c: Add movrs. * gcc.target/i386/sse-23.c: Ditto * gcc.target/i386/avx10_2-512-movrs-1.c: New test. * gcc.target/i386/avx10_2-movrs-1.c: Ditto. * gcc.target/i386/movrs-1.c: Ditto. Co-authored-by: Haochen Jiang <haochen.jiang@intel.com>
2024-11-01Support Intel AMX-FP8Liwei Xu3-4/+15
gcc/ChangeLog: * common/config/i386/cpuinfo.h (get_available_features): Detect amx-fp8. * common/config/i386/i386-common.cc (OPTION_MASK_ISA2_AMX_FP8_SET): New macros. (OPTION_MASK_ISA2_AMX_FP8_UNSET): Ditto. (ix86_handle_option): Handle -mamx-fp8. * common/config/i386/i386-cpuinfo.h (enum processor_features): Add FEATURE_AMX_FP8. * common/config/i386/i386-isas.h: Add ISA_NAME_TABLE_ENTRY for amx-fp8. * config.gcc: Add amxfp8intrin.h. * config/i386/cpuid.h (bit_AMX_FP8): New. * config/i386/i386-c.cc (ix86_target_macros_internal): Define __AMX_FP8__. * config/i386/i386-isa.def (AMX_FP8): Add DEF_PTA for AMX_FP8. * config/i386/i386-options.cc (ix86_valid_target_attribute_inner_p): Add new ATTR. * config/i386/i386.opt: Add -mamx-fp8. * config/i386/i386.opt.urls: Regenerated. * config/i386/immintrin.h: Include amxfp8intrin.h. * doc/extend.texi: Document -mamx-fp8. * doc/invoke.texi: Document -mamx-fp8. * doc/sourcebuild.texi: Document -mamx-fp8. * config/i386/amxfp8intrin.h: New file. gcc/testsuite/ChangeLog: * g++.dg/other/i386-2.C: Add -mamx-fp8. * g++.dg/other/i386-3.C: Ditto. * gcc.target/i386/amx-check.h: Check for amx-fp8. * gcc.target/i386/amx-helper.h: Ditto. * gcc.target/i386/fp8-helper.h: Ditto. * gcc.target/i386/funcspec-56.inc: Add new target attribute. * gcc.target/i386/sse-12.c: Add -mamx-fp8. * gcc.target/i386/sse-13.c: Ditto. * gcc.target/i386/sse-14.c: Ditto. * gcc.target/i386/sse-22.c: Ditto. * gcc.target/i386/sse-23.c: Ditto. * lib/target-supports.exp: New proc. * gcc.target/i386/amxfp8-asmatt-1.c: New test. * gcc.target/i386/amxfp8-asmintel-1.c: Ditto. * gcc.target/i386/amxfp8-dpbf8ps-2.c: Ditto. * gcc.target/i386/amxfp8-dpbhf8ps-2.c: Ditto. * gcc.target/i386/amxfp8-dphbf8ps-2.c: Ditto. * gcc.target/i386/amxfp8-dphf8ps-2.c: Ditto. * gcc.target/i386/fp-emulation.h: Emulates NaN behaviour. Co-authored-by: Hu, Lin1 <lin1.hu@intel.com>
2024-11-01Support Intel AMX-TRANSPOSEHaochen Jiang3-4/+15
gcc/ChangeLog: * common/config/i386/cpuinfo.h (get_available_features): Detect AMX-TRANSPOSE. * common/config/i386/i386-common.cc (OPTION_MASK_ISA2_AMX_TRANSPOSE_SET, OPTION_MASK_ISA2_AMX_TRANSPOSE_UNSET): New. (ix86_handle_option): Handle -mamx-transpose. * common/config/i386/i386-cpuinfo.h (enum processor_features): Add FEATURE_AMX_TRANSPOSE. * common/config/i386/i386-isas.h: Add ISA_NAME_TABLE_ENTRY for amx-transpose. * config.gcc: Add amxtransposeintrin.h. * config/i386/cpuid.h (bit_AMX_TRANSPOSE): New. * config/i386/i386-c.cc (ix86_target_macros_internal): Define __AMX_TRANSPOSE__. * config/i386/i386-isa.def (AMX_TRANSPOSE): Add DEF_PTA(AMX_TRANSPOSE). * config/i386/i386-options.cc (ix86_valid_target_attribute_inner_p): Handle amx-transpose. * config/i386/i386.opt: Add option -mamx-transpose. * config/i386/i386.opt.urls: Regenerated. * config/i386/immintrin.h: Include amxtransposeintrin.h. * doc/extend.texi: Document amx-transpose. * doc/invoke.texi: Document -mamx-transpose. * doc/sourcebuild.texi: Document target amx-transpose. * config/i386/amxtransposeintrin.h: New file. gcc/testsuite/ChangeLog: * g++.dg/other/i386-2.C: Add -mamx-transpose. * g++.dg/other/i386-3.C: Ditto. * gcc.target/i386/amx-check.h: Add new check for amx-transpose. (__tilepair): New. (zero_pair_tile_src): New. (check_pair_tile_register): New. * gcc.target/i386/funcspec-56.inc: Add new target attribute. * gcc.target/i386/amx-helper.h: Add amx-transpose support. (init_pair_tile_src): New function. * gcc.target/i386/sse-12.c: Add -mamx-tranpose. * gcc.target/i386/sse-13.c: Ditto. * gcc.target/i386/sse-14.c: Ditto. * gcc.target/i386/sse-22.c: Add amx-transpose. * gcc.target/i386/sse-23.c: Ditto. * lib/target-supports.exp (check_effective_target_amx_transposed): New. * gcc.target/i386/amxtranspose-asmatt-1.c: New test. * gcc.target/i386/amxtranspose-asmintel-1.c: Ditto. * gcc.target/i386/amxtranspose-2rpntlvw-2.c: Ditto. * gcc.target/i386/amxtranspose-conjtcmmimfp16ps-2.c: Ditto. * gcc.target/i386/amxtranspose-conjtfp16-2.c: Ditto. * gcc.target/i386/amxtranspose-tcmmimfp16ps-2.c: Ditto. * gcc.target/i386/amxtranspose-tcmmrlfp16ps-2.c: Ditto. * gcc.target/i386/amxtranspose-tdpbf16ps-2.c: Ditto. * gcc.target/i386/amxtranspose-tdpfp16ps-2.c: Ditto. * gcc.target/i386/amxtranspose-tmmultf32ps-2.c: Ditto. * gcc.target/i386/amxtranspose-transposed-2.c: Ditto.
2024-11-01Support Intel AMX-TF32Haochen Jiang3-4/+15
gcc/ChangeLog: * common/config/i386/cpuinfo.h (get_available_features): Detect AMX-TF32. * common/config/i386/i386-common.cc (OPTION_MASK_ISA2_AMX_TF32_SET, OPTION_MASK_ISA2_AMX_TF32_UNSET): New. (ix86_handle_option): Handle -mamx-tf32. * common/config/i386/i386-cpuinfo.h (enum processor_features): Add FEATURE_AMX_TF32. * common/config/i386/i386-isas.h: Add ISA_NAME_TABLE_ENTRY for amx-tf32. * config.gcc: Add amxtf32intrin.h * config/i386/cpuid.h (bit_AMX_TF32): New. * config/i386/i386-c.cc (ix86_target_macros_internal): Handle amx-tf32. * config/i386/i386-isa.def (AMX_TF32): Add DEF_PTA(AMX_TF32). * config/i386/i386-options.cc (ix86_valid_target_attribute_inner_p): Handle amx-tf32. * config/i386/i386.opt: Add option -mamx-tf32. * config/i386/i386.opt.urls: Regenerated. * config/i386/immintrin.h: Include amxtf32intrin.h. * doc/extend.texi: Document amx-tf32. * doc/invoke.texi: Document -mamx-tf32. * doc/sourcebuild.texi: Document target amx-tf32. * config/i386/amxtf32intrin.h: New file. gcc/testsuite/ChangeLog: * g++.dg/other/i386-2.C: Add -mamx-tf32. * g++.dg/other/i386-3.C: Ditto. * gcc.target/i386/amx-check.h: Add cpu check for AMX-TF32. * gcc.target/i386/funcspec-56.inc: Add new target attribute. * gcc.target/i386/sse-12.c: Add -mamx-tf32. * gcc.target/i386/sse-13.c: Ditto. * gcc.target/i386/sse-14.c: Ditto. * gcc.target/i386/sse-22.c: Add amx-tf32. * gcc.target/i386/sse-23.c: Ditto. * lib/target-supports.exp (check_effective_target_amx_tf32): New. * gcc.target/i386/amx-helper.h: New file for tf32 support. * gcc.target/i386/amxtf32-asmatt-1.c: New test. * gcc.target/i386/amxtf32-asmintel-1.c: Ditto. * gcc.target/i386/amxtf32-mmultf32ps-2.c: Ditto.
2024-11-01Support Intel AMX-AVX512Haochen Jiang3-4/+15
gcc/ChangeLog: * common/config/i386/cpuinfo.h (get_available_features): Detect AMX-AVX512. * common/config/i386/i386-common.cc (OPTION_MASK_ISA2_AMX_AVX512_SET, OPTION_MASK_ISA2_AMX_AVX512_UNSET): New. (ix86_handle_option): Handle -mamx-avx512. * common/config/i386/i386-cpuinfo.h (enum processor_features): Add FEATURE_AMX_AVX512. * common/config/i386/i386-isas.h: Add ISA_NAME_TABLE_ENTRY for amx-avx512. * config.gcc: Add amxavx512intrin.h * config/i386/cpuid.h (bit_AMX_AVX512): New. * config/i386/i386-c.cc (ix86_target_macros_internal): Handle amx-avx512. * config/i386/i386-isa.def (AMX_AVX512): Add DEF_PTA(AMX_AVX512). * config/i386/i386-options.cc (ix86_valid_target_attribute_inner_p): Handle amx-avx512. * config/i386/i386.opt: Add option -mamx-avx512. * config/i386/i386.opt.urls: Regenerated. * config/i386/immintrin.h: Include amxavx512intrin.h * doc/extend.texi: Document amx-avx512. * doc/invoke.texi: Document -mamx-avx512. * doc/sourcebuild.texi: Document target amx-avx512. * config/i386/amxavx512intrin.h: New file. gcc/testsuite/ChangeLog: * g++.dg/other/i386-2.C: Add -mamx-avx512. * g++.dg/other/i386-3.C: Ditto. * gcc.target/i386/amx-check.h: Add cpu check for AMX-AVX512. * gcc.target/i386/amx-helper.h: Support amx-avx512. * gcc.target/i386/funcspec-56.inc: Add new target attribute. * gcc.target/i386/sse-12.c: Add -mamx-avx512. * gcc.target/i386/sse-13.c: Ditto. * gcc.target/i386/sse-14.c: Ditto. * gcc.target/i386/sse-22.c: Add amx-avx512. * gcc.target/i386/sse-23.c: Ditto. * lib/target-supports.exp (check_effective_target_amx_avx512): New. * gcc.target/i386/amxavx512-asmatt-1.c: New test. * gcc.target/i386/amxavx512-asmintel-1.c: Ditto. * gcc.target/i386/amxavx512-cvtrowd2ps-2.c: Ditto. * gcc.target/i386/amxavx512-cvtrowps2pbf16-2.c: Ditto. * gcc.target/i386/amxavx512-cvtrowps2ph-2.c: Ditto. * gcc.target/i386/amxavx512-movrow-2.c: Ditto. Co-authored-by: Yu, Bing <bing1.yu@intel.com>
2024-10-30c: Do not document C23 support as experimental and incompleteJoseph Myers3-8/+6
Since C23 support is substantially feature-complete, update documentation to no longer refer to it as experimental and incomplete. Bootstrapped with no regressions for x86_64-pc-linux-gnu. gcc/ * doc/cpp.texi (__STDC_VERSION__): Do not refer to C23 support as experimental. * doc/invoke.texi (std=c23, std=gnu23): Do not document as experimental and incomplete. * doc/standards.texi: Do not refer to C23 support as experimental and incomplete. gcc/c-family/ * c.opt (std=c23, std=gnu23, std=iso9899:2024): Do not mark as experimental and incomplete.
2024-10-29diagnostics: support multiple output formats simultaneously [PR116613]David Malcolm1-0/+97
This patch generalizes diagnostic_context so that rather than having a single output format, it has a vector of zero or more. It adds new two options: -fdiagnostics-add-output=DIAGNOSTICS-OUTPUT-SPEC -fdiagnostics-set-output=DIAGNOSTICS-OUTPUT-SPEC which both take a new configuration syntax of the form SCHEME ("text" or "sarif"), optionally followed by ":" and one or more KEY=VALUE pairs, in this form: <SCHEME> <SCHEME>:<KEY>=<VALUE> <SCHEME>:<KEY>=<VALUE>,<KEY2>=<VALUE2> ...etc where each SCHEME supports some set of keys. For example, it's now possible to use: -fdiagnostics-add-output=sarif:version=2.1,file=foo.2.1.sarif \ -fdiagnostics-add-output=sarif:version=2.2-prerelease,file=foo.2.2.sarif to add a pair of outputs, each writing to a different file, using versions 2.1 and 2.2 of the SARIF standard respectively, whilst also emitting the classic text form of the diagnostics to stderr. I hope the new syntax gives us room to potentially add new kinds of output sink in the future (e.g. RPC notifications), and to add new key/value pairs as needed by the different sinks. Implementation-wise, the diagnostic_context's m_printer which previously was used directly by the single output format now becomes a "reference printer", created by the client (such as the frontend), with defaults modified by command-line options. Each of the multiple output sinks has its own pretty_printer instance, created by cloning the context's reference printer. gcc/ChangeLog: PR other/116613 * Makefile.in (OBJS-libcommon-target): Add opts-diagnostic.o. * common.opt (fdiagnostics-add-output=): New. (fdiagnostics-set-output=): New. (diagnostics_output_format): Drop sarif-file-2.2-prerelease from enum. * common.opt.urls: Regenerate. * diagnostic-buffer.h (diagnostic_buffer::~diagnostic_buffer): New. (diagnostic_buffer::ensure_per_format_buffer): Rename to... (diagnostic_buffer::ensure_per_format_buffers): ...this. (diagnostic_buffer::m_per_format_buffer): Replace with... (diagnostic_buffer::m_per_format_buffers): ...this, updating type. * diagnostic-format-json.cc (json_output_format::update_printer): New. (json_output_format::follows_reference_printer_p): New. (diagnostic_output_format_init_json): Drop redundant call to set_path_format, as this is not a text output format. * diagnostic-format-sarif.cc: Include "diagnostic-format-text.h". (sarif_builder::set_printer): New. (sarif_builder::sarif_builder): Add "printer" param and use it for m_printer. (sarif_builder::make_location_object::escape_nonascii_renderer::render): Rather than using dc.m_printer, create a diagnostic_text_output_format instance and use its printer. (sarif_output_format::follows_reference_printer_p): New. (sarif_output_format::update_printer): New. (sarif_output_format::sarif_output_format): Pass in correct printer to m_builder's ctor. (diagnostic_output_format_init_sarif): Drop redundant call to set_path_format, as this is not a text output format. Replace calls to pp_show_color and set_token_printer with call to update_printer. Drop redundant call to set_show_highlight_colors, as this printer does not show colors. (diagnostic_output_format_init_sarif_file): Split out file opening into... (diagnostic_output_format_open_sarif_file): ...this new function. (make_sarif_sink): New. (selftest::test_make_location_object): Provide a pp for the builder. * diagnostic-format-sarif.h (diagnostic_output_format_open_sarif_file): New decl. (make_sarif_sink): New decl. * diagnostic-format-text.cc (diagnostic_text_output_format::dump): Dump sm_follows_reference_printer. (diagnostic_text_output_format::on_report_verbatim): New. (diagnostic_text_output_format::follows_reference_printer_p): New. (diagnostic_text_output_format::update_printer): New. * diagnostic-format-text.h (diagnostic_text_output_format::diagnostic_text_output_format): Add optional "follows_reference_printer" param. (diagnostic_text_output_format::on_report_verbatim): New decl. (diagnostic_text_output_format::after_diagnostic): Drop "final". (diagnostic_text_output_format::follows_reference_printer_p): New decl. (class diagnostic_text_output_format): Convert private members to protected. (diagnostic_text_output_format::m_follows_reference_printer): New field. * diagnostic-format.h (diagnostic_output_format::on_report_verbatim): New vfunc. (diagnostic_output_format::follows_reference_printer_p): New vfunc. (diagnostic_output_format::update_printer): New vfunc. (diagnostic_output_format::get_printer): Use m_printer rather than a printer from m_context. (diagnostic_output_format::diagnostic_output_format): Initialize m_printer by cloning the context's printer. (diagnostic_output_format::m_printer): New field. * diagnostic-global-context.cc (verbatim): Reimplement in terms of global_dc->report_verbatim, moving existing implementation to diagnostic_text_output_format::on_report_verbatim. (fnotice): Support multiple output sinks by using a new global_dc->supports_fnotice_on_stderr_p. * diagnostic-output-file.h (diagnostic_output_file::diagnostic_output_file): New default ctor. (diagnostic_output_file::operator=): Implement move assignment. * diagnostic-path.cc (selftest::test_interprocedural_path_1): Pass false for new param of text_output's ctor. * diagnostic-show-locus.cc (selftest::test_layout_x_offset_display_utf8): Use reference printer. (selftest::test_layout_x_offset_display_tab): Likewise. (selftest::test_one_liner_fixit_remove): Likewise. * diagnostic.cc: Include "pretty-print-urlifier.h". (diagnostic_set_caret_max_width): Update for global_dc's m_printer becoming reference printer. (diagnostic_context::initialize): Update for m_printer becoming m_reference_printer. Use ::make_unique to create it. Update for m_output_format becoming m_output_sinks. (diagnostic_context::color_init): Update the reference printer, then update the printers for any output sinks that follow it. (diagnostic_context::urls_init): Likewise. (diagnostic_context::finish): Update comment. Update for m_output_format becoming m_output_sinks. Update for m_printer becoming m_reference_printer and use "delete" on it rather than XDELETE. (diagnostic_context::dump): Update for m_printer becoming reference printer, and for multiple output sinks. (diagnostic_context::set_output_format): Reimplement for supporting multiple output sinks. (diagnostic_context::get_output_format): Likewise. (diagnostic_context::add_sink): New. (diagnostic_context::supports_fnotice_on_stderr_p): New. (diagnostic_context::set_pretty_printer): New. (diagnostic_context::refresh_output_sinks): New. (diagnostic_context::set_format_decoder): New. (diagnostic_context::set_show_highlight_colors): New. (diagnostic_context::set_prefixing_rule): New. (diagnostic_context::report_diagnostic): Update to support multiple output sinks. (diagnostic_context::report_verbatim): New. (diagnostic_context::emit_diagram): Update to support multiple output sinks. (diagnostic_context::error_recursion): Update to use m_reference_printer. (fancy_abort): Likewise. (diagnostic_context::end_group): Update to support multiple output sinks. (diagnostic_output_format::dump): Implement. (diagnostic_output_format::on_report_verbatim): Likewise. (diagnostic_output_format_init): Drop DIAGNOSTICS_OUTPUT_FORMAT_SARIF_FILE_2_2_PRERELEASE. (diagnostic_context::set_diagnostic_buffer): Reimplement to support multiple output sinks. (diagnostic_context::clear_diagnostic_buffer): Likewise. (diagnostic_context::flush_diagnostic_buffer): Likewise. (diagnostic_buffer::diagnostic_buffer): Initialize m_per_format_buffers. (diagnostic_buffer::~diagnostic_buffer): New dtor. (diagnostic_buffer::dump): Reimplement to support multiple output sinks. (diagnostic_buffer::empty_p): Likewise. (diagnostic_buffer::move_to): Likewise. (diagnostic_buffer::ensure_per_format_buffer): Likewise, renaming to... (diagnostic_buffer::ensure_per_format_buffers): ...this. * diagnostic.h (DIAGNOSTICS_OUTPUT_FORMAT_SARIF_FILE_2_2_PRERELEASE): Delete. (class diagnostic_context): Add friend class diagnostic_buffer. (diagnostic_context::set_pretty_printer): New decl. (diagnostic_context::refresh_output_sinks): New decl. (diagnostic_context::report_verbatim): New decl. (diagnostic_context::get_output_format): Drop. (diagnostic_context::set_show_highlight_colors): Drop body. (diagnostic_context::set_format_decoder): New decl. (diagnostic_context::set_prefixing_rule): New decl. (diagnostic_context::clone_printer): Reimplement. (diagnostic_context::get_reference_printer): New accessor. (diagnostic_context::add_sink): New decl. (diagnostic_context::supports_fnotice_on_stderr_p): New decl. (diagnostic_context::m_printer): Replace with... (diagnostic_context::m_reference_printer): ...this, and make private. (diagnostic_context::m_output_format): Replace with... (diagnostic_context::m_output_sinks): ...this. (diagnostic_format_decoder): Delete. (diagnostic_prefixing_rule): Delete. (diagnostic_ready_p): Delete. * doc/invoke.texi: Document -fdiagnostics-add-output= and -fdiagnostics-set-output=. * gcc.cc: Include "opts-diagnostic.h". (driver_handle_option): Handle cases OPT_fdiagnostics_add_output_ and OPT_fdiagnostics_set_output_. * opts-diagnostic.cc: New file. * opts-diagnostic.h (handle_OPT_fdiagnostics_add_output_): New decl. (handle_OPT_fdiagnostics_set_output_): New decl. * opts-global.cc (init_options_once): Update for global_dc's m_printer becoming reference printer. Call global_dc->refresh_output_sinks. * opts.cc (common_handle_option): Replace use of diagnostic_prefixing_rule with dc->set_prefixing_rule. Handle cases OPT_fdiagnostics_add_output_ and OPT_fdiagnostics_set_output_. Update for m_printer becoming reference printer. * selftest-diagnostic.cc (selftest::test_diagnostic_context::test_diagnostic_context): Update for m_printer becoming reference printer. (test_diagnostic_context::test_show_locus): Likewise. * selftest-run-tests.cc (selftest::run_tests): Call selftest::opts_diagnostic_cc_tests. * selftest.h (selftest::opts_diagnostic_cc_tests): New decl. * simple-diagnostic-path.cc (selftest::simple_diagnostic_path_cc_tests): Use reference printer. * toplev.cc (announce_function): Update for global_dc's m_printer becoming reference printer. (toplev::main): Likewise. * tree-diagnostic.cc (tree_diagnostics_defaults): Replace use of diagnostic_format_decoder with context->set_format_decoder. * tree-diagnostic.h (tree_dump_pretty_printer::tree_dump_pretty_printer): Update for global_dc's m_printer becoming reference printer. * tree.cc (escaped_string::escape): Likewise. (selftest::test_escaped_strings): Likewise. gcc/ada/ChangeLog: PR other/116613 * gcc-interface/misc.cc (internal_error_function): Update for m_printer becoming reference printer. gcc/analyzer/ChangeLog: PR other/116613 * analyzer-language.cc (on_finish_translation_unit): Update for m_printer becoming reference printer. * engine.cc (run_checkers): Likewise. * program-point.cc (function_point::print_source_line): Likewise. gcc/c-family/ChangeLog: PR other/116613 * c-format.cc (selftest::test_type_mismatch_range_labels): Update for m_printer becoming reference printer. (selftest::test_type_mismatch_range_labels): Likewise. gcc/c/ChangeLog: PR other/116613 * c-objc-common.cc: Include "make-unique.h". (c_initialize_diagnostics): Use unique_ptr for pretty_printer. Use context->set_format_decoder. gcc/cp/ChangeLog: PR other/116613 * error.cc (cxx_initialize_diagnostics): Use unique_ptr for pretty_printer. Use context->set_format_decoder. * module.cc (noisy_p): Update for global_dc's m_printer becoming reference printer. gcc/d/ChangeLog: PR other/116613 * d-diagnostic.cc (d_diagnostic_report_diagnostic): Update for m_printer becoming reference printer. gcc/fortran/ChangeLog: PR other/116613 * error.cc (gfc_diagnostic_build_kind_prefix): Update for global_dc's m_printer becoming reference printer. (gfc_diagnostics_init): Replace usage of diagnostic_format_decoder with global_dc->set_format_decoder. gcc/jit/ChangeLog: PR other/116613 * dummy-frontend.cc: Include "make-unique.h". (class jit_diagnostic_listener): New. (jit_begin_diagnostic): Update comment. (jit_end_diagnostic): Drop call to add_diagnostic. (jit_langhook_init): Set the output format to a new jit_diagnostic_listener. * jit-playback.cc (playback::context::add_diagnostic): Add "text" param and use that rather than trying to get the text from a pretty_printer. * jit-playback.h (playback::context::add_diagnostic): Add "text" param. gcc/testsuite/ChangeLog: PR other/116613 * gcc.dg/plugin/analyzer_cpython_plugin.c (dump_refcnt_info): Update for global_dc's m_printer becoming reference printer. * gcc.dg/plugin/crash-test-ice-in-header-sarif-2.2.c: Replace usage of -fdiagnostics-format=sarif-file-2.2-prerelease with -fdiagnostics-set-output=sarif:version=2.2-prerelease. * gcc.dg/plugin/diagnostic_plugin_test_paths.c: Update for global_dc's m_printer becoming reference printer. * gcc.dg/plugin/diagnostic_plugin_xhtml_format.c: Update for changes to output formats. * gcc.dg/plugin/expensive_selftests_plugin.c: Update for global_dc's m_printer becoming reference printer. * gcc.dg/sarif-output/add-output-sarif-defaults.c: New test. * gcc.dg/sarif-output/bad-binary-op.c: New test. * gcc.dg/sarif-output/bad-binary-op.py: New support script. * gcc.dg/sarif-output/multiple-outputs.c: New test. * gcc.dg/sarif-output/multiple-outputs.py: New support script. * lib/scansarif.exp (verify-sarif-file): Add an optional second argument specifying the expected filename of the .sarif file. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-10-29c: Add __builtin_stdc_rotate_{left,right} builtins [PR117030]Jakub Jelinek1-0/+26
I believe the new C2Y <stdbit.h> type-generic functions stdc_rotate_{left,right} have the same problems the other stdc_* type-generic functions had. If we want to support arbitrary unsigned _BitInt(N), don't want to use statement expressions (so that one can actually use them in static variable initializers), don't want to evaluate the arguments multiple times and don't want to expand the arguments multiple times during preprocessing to avoid the old tgmath preprocessing bloat, we need a built-in for those. The following patch adds those. And as we need to support rotations by 0 and tree-ssa-forwprop.cc is only able to pattern recognize with BIT_AND_EXPR for that case (i.e. for power of two widths), the patch just constructs LROTATE_EXPR/RROTATE_EXPR right away. Negative second arguments are considered UB, while positive ones are modulo precision. 2024-10-29 Jakub Jelinek <jakub@redhat.com> PR c/117030 gcc/ * doc/extend.texi (__builtin_stdc_rotate_left, __builtin_stdc_rotate_right): Document. gcc/c-family/ * c-common.cc (c_common_reswords): Add __builtin_stdc_rotate_left and __builtin_stdc_rotate_right. * c-ubsan.cc (ubsan_instrument_shift): For {L,R}ROTATE_EXPR just check if op1 is negative. gcc/c/ * c-parser.cc: Include asan.h and c-family/c-ubsan.h. (c_parser_postfix_expression): Handle __builtin_stdc_rotate_left and __builtin_stdc_rotate_right. * c-fold.cc (c_fully_fold_internal): Handle LROTATE_EXPR and RROTATE_EXPR. gcc/testsuite/ * gcc.dg/builtin-stdc-rotate-1.c: New test. * gcc.dg/builtin-stdc-rotate-2.c: New test. * gcc.dg/ubsan/builtin-stdc-rotate-1.c: New test. * gcc.dg/ubsan/builtin-stdc-rotate-2.c: New test.
2024-10-28build: update bootstrap req to C++14Jason Merrill1-7/+13
We moved to a bootstrap requirement of C++11 in GCC 11, 8 years after support was stable in GCC 4.8. It is now 8 years since C++14 was the default mode in GCC 6 (and 9 years since support was complete in GCC 5), and we have a few bits of optional C++14 code in the compiler, so it seems a good time to update the bootstrap requirement again. The big benefit of the change is the greater constexpr power, but C++14 also added variable templates, generic lambdas, lambda init-capture, binary literals, and numeric literal digit separators. C++14 was feature-complete in GCC 5, and became the default in GCC 6. 5.4.0 bootstraps trunk correctly; trunk stage1 built with 5.3.0 breaks in eh_data_format_name due to PR69995. gcc/ChangeLog: * doc/install.texi (Prerequisites): Update to C++14. ChangeLog: * configure.ac: Update requirement to C++14. * configure: Regenerate.
2024-10-27c-family: -Wleading-whitespace= argument spellingJakub Jelinek1-2/+2
On Thu, Oct 24, 2024 at 03:33:25PM -0400, Eric Gallager wrote: > On Thu, Oct 24, 2024 at 4:17 AM Jakub Jelinek <jakub@redhat.com> wrote: > > I've tried to build stage3 with > > -Wleading-whitespace=blanks -Wtrailing-whitespace=blank -Wno-error=leading-whitespace=blanks -Wno-error=trailing-whitespace=blank > > So wait, it's "blanks" (plural) when it's leading, but "blank" > (singular) when it's trailing? That inconsistency bothers me... I've mentioned it already in https://gcc.gnu.org/pipermail/gcc-patches/2024-October/664664.html Citing that here: Not sure about the kinds for the option, given -Wleading-whitespace= uses plural and this option singular and -Wleading-whitespace= spaces means literally just ' ' characters, while space in -Wtrailing-whitespace= was ' ', '\t', '\v' and '\f'; so category; perhaps just use any and blanks? Other preferences? Here is a patch to do the blank->blanks and space->any changes. 2024-10-27 Jakub Jelinek <jakub@redhat.com> gcc/ * doc/invoke.texi (Wtrailing-whitespace=): Change blank argument to blanks and space argument to any. gcc/c-family/ * c.opt (warn_trailing_whitespace_kind): Change blank to blanks and space to any. gcc/testsuite/ * c-c++-common/cpp/Wtrailing-whitespace-2.c: Use -Wtrailing-whitespace=blanks rather than -Wtrailing-whitespace=blank. * c-c++-common/cpp/Wtrailing-whitespace-3.c: Use -Wtrailing-whitespace=any rather than -Wtrailing-whitespace=space. * c-c++-common/cpp/Wtrailing-whitespace-7.c: Use -Wtrailing-whitespace=blanks rather than -Wtrailing-whitespace=blank. * c-c++-common/cpp/Wtrailing-whitespace-8.c: Use -Wtrailing-whitespace=any rather than -Wtrailing-whitespace=space.
2024-10-23doc: remove obsolete deprecated infoJason Merrill1-10/+0
These formerly deprecated features eventually made it into the C++ standard. gcc/ChangeLog: * doc/extend.texi (Deprecated Features): Remove text about some no-longer-deprecated features.
2024-10-23libcpp: Add -Wleading-whitespace= warningJakub Jelinek1-1/+24
The following patch on top of the r15-4346 patch adds -Wleading-whitespace= warning option. This warning doesn't care how much one actually indents which line in the source (that is something that can't be easily done in the preprocessor without doing syntactic analysis), but just simple checks on what kind of whitespace is used in the indentation. I think it is still useful to get warnings about such issues early, while git diagnoses some of it in patches (e.g. the tab after space case), getting the warnings earlier might help avoiding such issues sooner. There are projects which ban use of tabs and require just spaces, others which require indentation just with horizontal tabs, and finally projects which want indentation with tabs for multiples of tabstop size followed by spaces (fewer than tabstop size), like GCC. For all 3 kinds the warning diagnoses indentation with '\v' or '\f' characters (unless line contains just whitespace), and for the last one also cases where a space in the indentation is followed by horizontal tab or where there are N or more consecutive spaces in the indentation (for -ftabstop=N). BTW, for additional testing I've enabled the warnings (without -Werror for them) in stage3. There are many warnings (both trailing and leading whitespace), some of them something that can be easily fixed in the headers or source files, but others with whitespace issues in generated sources, so if we enable the warnings, either we'd need to adjust the generators or disable the warnings in (some of the) generated files. 2024-10-23 Jakub Jelinek <jakub@redhat.com> libcpp/ * include/cpplib.h (struct cpp_options): Add cpp_warn_leading_whitespace and cpp_tabstop members. (enum cpp_warning_reason): Add CPP_W_LEADING_WHITESPACE. * internal.h (struct _cpp_line_note): Document new line note kinds. * init.cc (cpp_create_reader): Set cpp_tabstop to 8. * lex.cc (find_leading_whitespace_issues): New function. (_cpp_clean_line): Use it. (_cpp_process_line_notes): Handle 'L', 'S' and 'T' line notes. (lex_raw_string): Clear type on 'L', 'S' and 'T' line notes inside of raw string literals. gcc/ * doc/invoke.texi (Wleading-whitespace=): Document. gcc/c-family/ * c.opt (Wleading-whitespace=): New option. * c-opts.cc (c_common_post_options): Set cpp_opts->cpp_tabstop to global_dc->m_tabstop. gcc/testsuite/ * c-c++-common/cpp/Wleading-whitespace-1.c: New test. * c-c++-common/cpp/Wleading-whitespace-2.c: New test. * c-c++-common/cpp/Wleading-whitespace-3.c: New test. * c-c++-common/cpp/Wleading-whitespace-4.c: New test.
2024-10-19phiopt: do factor_out_conditional_operation for all phis [PR112418]Andrew Pinski1-0/+4
Sometimes factor_out_conditional_operation can factor out an operation that causes a phi node to become the same element. Other times, we want to factor out a binary operator because it can improve code generation, an example is PR 110015 (openjpeg). Note this includes a heuristic to decide if factoring out the operation is profitable or not. It can be expanded to include a better live range extend detector. Right now it has a simple one where if it is live on a dominating path, it is considered a live or if there are a small # of assign statements (defaults to 5), then it does not extend the live range too much. Bootstrapped and tested on x86_64-linux-gnu. PR tree-optimization/112418 gcc/ChangeLog: * tree-ssa-phiopt.cc (is_factor_profitable): New function. (factor_out_conditional_operation): Add merge argument. Remove arg0/arg1 arguments. Return bool instead of the new phi. Early return for virtual ops. Call is_factor_profitable to check if the factoring would be profitable. (pass_phiopt::execute): Call factor_out_conditional_operation on all phis instead of just singleton phi. * doc/invoke.texi (--param phiopt-factor-max-stmts-live=): Document. * params.opt (--param=phiopt-factor-max-stmts-live=): New opt. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/factor_op_phi-1.c: New test. * gcc.dg/tree-ssa/factor_op_phi-2.c: New test. * gcc.dg/tree-ssa/factor_op_phi-3.c: New test. * gcc.dg/tree-ssa/factor_op_phi-4.c: New test. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2024-10-17doc: remove outdated C++ Concepts sectionPatrick Palka1-44/+0
This was added as part of the initial Concepts TS implementation and reflects an early version of the Concepts TS paper, which is very different from standard C++20 concepts (and even from more recent versions of the Concepts TS, support for which we deprecated in GCC 14 and removed for GCC 15). So there's not much to salvage from this section besides the __is_same trait documentation which we can conveniently move to the previous Type Traits section. gcc/ChangeLog: * doc/extend.texi (C++ Concepts): Remove section. Move __is_same documentation to the previous Type Traits section. Reviewed-by: Jason Merrill <jason@redhat.com>
2024-10-16Fix bootstrap on 32-bit SPARC/SolarisEric Botcazou1-3/+0
The 'U' constraint cannot be used with LRA. gcc/ PR target/113952 PR target/117168 * config/sparc/constraints.md ('U'): Delete. * config/sparc/sparc.md (*movdi_insn_sp32): Remove U alternatives. (*movdf_insn_sp32): Likewise. (*mov<VM64:mode>_insn_sp32): Likewise. * doc/md.texi (SPARC constraints): Remove entry for 'U'.
2024-10-16sparc: drop -mlraSam James1-9/+1
The sparc port gained LRA support in r7-5076-gf99bd883fb0d05 and has defaulted to LRA since r7-5642-g70a6dbe7e37e69. Let's finish the transition by dropping -mlra entirely. Tested on sparc64-unknown-linux-gnu with no regressions. gcc/ChangeLog: PR target/113952 * config/sparc/sparc.cc (sparc_lra_p): Delete. (TARGET_LRA_P): Ditto. (sparc_option_override): Don't use MASK_LRA. * config/sparc/sparc.md (disabled,enabled): Drop lra attribute. * config/sparc/sparc.opt: Delete -mlra. * config/sparc/sparc.opt.urls: Ditto. * doc/invoke.texi (SPARC options): Drop -mlra and -mno-lra.
2024-10-15Provide new GCC builtin __builtin_counted_by_ref [PR116016]Qing Zhao1-0/+55
With the addition of the 'counted_by' attribute and its wide roll-out within the Linux kernel, a use case has been found that would be very nice to have for object allocators: being able to set the counted_by counter variable without knowing its name. For example, given: struct foo { ... int counter; ... struct bar array[] __attribute__((counted_by (counter))); } *p; The existing Linux object allocators are roughly: #define MAX(A, B) (A > B) ? (A) : (B) #define alloc(P, FAM, COUNT) ({ \ __auto_type __p = &(P); \ size_t __size = MAX (sizeof(*P), __builtin_offsetof (__typeof(*P), FAM) + sizeof (*(P->FAM)) * COUNT); \ *__p = kmalloc(__size); \ }) Right now, any addition of a counted_by annotation must also include an open-coded assignment of the counter variable after the allocation: p = alloc(p, array, how_many); p->counter = how_many; In order to avoid the tedious and error-prone work of manually adding the open-coded counted-by intializations everywhere in the Linux kernel, a new GCC builtin __builtin_counted_by_ref will be very useful to be added to help the adoption of the counted-by attribute. -- Built-in Function: TYPE __builtin_counted_by_ref (PTR) The built-in function '__builtin_counted_by_ref' checks whether the array object pointed by the pointer PTR has another object associated with it that represents the number of elements in the array object through the 'counted_by' attribute (i.e. the counted-by object). If so, returns a pointer to the corresponding counted-by object. If such counted-by object does not exist, returns a null pointer. This built-in function is only available in C for now. The argument PTR must be a pointer to an array. The TYPE of the returned value is a pointer type pointing to the corresponding type of the counted-by object or a void pointer type in case of a null pointer being returned. With this new builtin, the central allocator could be updated to: #define MAX(A, B) (A > B) ? (A) : (B) #define alloc(P, FAM, COUNT) ({ \ __auto_type __p = &(P); \ __auto_type __c = (COUNT); \ size_t __size = MAX (sizeof (*(*__p)),\ __builtin_offsetof (__typeof(*(*__p)),FAM) \ + sizeof (*((*__p)->FAM)) * __c); \ if ((*__p = kmalloc(__size))) { \ __auto_type ret = __builtin_counted_by_ref((*__p)->FAM); \ *_Generic(ret, void *: &(size_t){0}, default: ret) = __c; \ } \ }) And then structs can gain the counted_by attribute without needing additional open-coded counter assignments for each struct, and unannotated structs could still use the same allocator. PR c/116016 gcc/c-family/ChangeLog: * c-common.cc: Add new __builtin_counted_by_ref. * c-common.h (enum rid): Add RID_BUILTIN_COUNTED_BY_REF. gcc/c/ChangeLog: * c-decl.cc (names_builtin_p): Add RID_BUILTIN_COUNTED_BY_REF. * c-parser.cc (has_counted_by_object): New routine. (get_counted_by_ref): New routine. (c_parser_postfix_expression): Handle New RID_BUILTIN_COUNTED_BY_REF. * c-tree.h: New routine handle_counted_by_for_component_ref. * c-typeck.cc (handle_counted_by_for_component_ref): New routine. (build_component_ref): Call the new routine. gcc/ChangeLog: * doc/extend.texi: Add documentation for __builtin_counted_by_ref. gcc/testsuite/ChangeLog: * gcc.dg/builtin-counted-by-ref-1.c: New test. * gcc.dg/builtin-counted-by-ref.c: New test.
2024-10-15C++: Add opindex for -Wchanges-meaning [PR117157]Andrew Pinski1-0/+2
Adds missing opindex for -Wchanges-meaning Pushed as obvious after building the HTML and checking the index. gcc/ChangeLog: PR c++/117157 * doc/invoke.texi (Wno-changes-meaning): Add opindex. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2024-10-15libcpp: Add -Wtrailing-blanks warningJakub Jelinek1-1/+17
Trailing blanks is something even git diff diagnoses; while it is a coding style issue, if it is so common that git diff diagnoses it, I think it could be useful to various projects to check that at compile time. Dunno if it should be included in -Wextra, currently it isn't, and due to tons of trailing whitespace in our sources, haven't enabled it for when building gcc itself either. Note, git diff also diagnoses indentation with tab following space, wonder if we couldn't have trivial warning options where one would simply ask for checking of indentation with no tabs, just spaces vs. indentation with tabs followed by spaces (but never tab width or more spaces in the indentation). I think that would be easy to do also on the libcpp side. Checking how much something should be exactly indented requires syntax analysis (at least some limited one) and can consider columns of first token on line, but what the exact indentation blanks were is something only libcpp knows. On Thu, Sep 19, 2024 at 08:17:24AM +0200, Richard Biener wrote: > Generally I like diagnosing this early. For the above I'd say -Wtrailing-whitespace= > with a set of things to diagnose (and a sane default - just spaces and tabs - for > -Wtrailiing-whitespace) would be nice. As for naming possibly follow the > is{space,blank,cntrl} character classifications? If those are a good > fit, that is. The patch currently allows blank (' ' '\t') and space (' ' '\t' '\f' '\v'), cntrl not yet added, not anything non-ASCII, but in theory could be added later (though, non-ASCII would be just for inside of comments, say non-breaking space etc. in the source is otherwise an error). 2024-10-15 Jakub Jelinek <jakub@redhat.com> libcpp/ * include/cpplib.h (struct cpp_options): Add cpp_warn_trailing_whitespace member. (enum cpp_warning_reason): Add CPP_W_TRAILING_WHITESPACE. * internal.h (struct _cpp_line_note): Document 'W' line note. * lex.cc (_cpp_clean_line): Add 'W' line note for trailing whitespace except for trailing whitespace after backslash. Formatting fix. (_cpp_process_line_notes): Emit -Wtrailing-whitespace diagnostics. Formatting fixes. (lex_raw_string): Clear type on 'W' notes. gcc/ * doc/invoke.texi (Wtrailing-whitespace): Document. gcc/c-family/ * c.opt (Wtrailing-whitespace=): New option. (Wtrailing-whitespace): New alias. * c.opt.urls: Regenerate. gcc/testsuite/ * c-c++-common/cpp/Wtrailing-whitespace-1.c: New test. * c-c++-common/cpp/Wtrailing-whitespace-2.c: New test. * c-c++-common/cpp/Wtrailing-whitespace-3.c: New test. * c-c++-common/cpp/Wtrailing-whitespace-4.c: New test. * c-c++-common/cpp/Wtrailing-whitespace-5.c: New test. * c-c++-common/cpp/Wtrailing-whitespace-6.c: New test. * c-c++-common/cpp/Wtrailing-whitespace-7.c: New test. * c-c++-common/cpp/Wtrailing-whitespace-8.c: New test. * c-c++-common/cpp/Wtrailing-whitespace-9.c: New test. * c-c++-common/cpp/Wtrailing-whitespace-10.c: New test.
2024-10-09diagnostics: mark the JSON output format as deprecatedDavid Malcolm1-264/+2
The bulk of the documentation for -fdiagnostics-format= is taken up by a description of the "json" format added in r9-4156-g478dd60ddcf177. I don't plan to add any extra features to the "json" format; all my future work on machine-readable GCC diagnostics is likely to be on the SARIF output format (https://gcc.gnu.org/wiki/SARIF). Hence users seeking machine-readable output from GCC should use SARIF. This patch removes the long documentation of the format and describes it as deprecated. gcc/ChangeLog: * doc/invoke.texi (fdiagnostics-format): Describe "json" et al as deprecated, and remove the long description of the output format. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-10-10Enable vectorization for unknown tripcount in very cheap cost model but ↵liuhongt1-7/+4
disable epilog vectorization. gcc/ChangeLog: * tree-vect-loop.cc (vect_analyze_loop_costing): Enable vectorization for LOOP_VINFO_PEELING_FOR_NITER in very cheap cost model. (vect_analyze_loop): Disable epilogue vectorization in very cheap cost model. * doc/invoke.texi: Adjust documents for very-cheap cost model.
2024-10-09gcc/doc: adjust __builtin_choose_expr() descriptionJan Beulich1-5/+6
Present wording has misled people to believe the ?: operator would be evaluating all three of the involved expressions. gcc/ * doc/extend.texi: Clarify __builtin_choose_expr() (dis)similarity to the ?: operator.
2024-10-08gcc, libcpp: Add warning switch for "#pragma once in main file" [PR89808]Ken Matsui1-2/+8
This patch adds a warning switch for "#pragma once in main file". The warning option name is Wpragma-once-outside-header, which is the same as Clang provides. PR preprocessor/89808 gcc/c-family/ChangeLog: * c.opt (Wpragma_once_outside_header): Define new option. * c.opt.urls: Regenerate. gcc/ChangeLog: * doc/invoke.texi (Warning Options): Document -Wno-pragma-once-outside-header. libcpp/ChangeLog: * include/cpplib.h (cpp_warning_reason): Define CPP_W_PRAGMA_ONCE_OUTSIDE_HEADER. * directives.cc (do_pragma_once): Use CPP_W_PRAGMA_ONCE_OUTSIDE_HEADER. gcc/testsuite/ChangeLog: * g++.dg/warn/Wno-pragma-once-outside-header.C: New test. * g++.dg/warn/Wpragma-once-outside-header.C: New test. Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org> Reviewed-by: Marek Polacek <polacek@redhat.com>
2024-10-08ssa-math-opts, i386: Handle most unordered values rather than just 2 [PR116896]Jakub Jelinek1-2/+5
On Mon, Oct 07, 2024 at 10:32:57AM +0200, Richard Biener wrote: > > They are implementation defined, -1, 0, 1, 2 is defined by libstdc++: > > using type = signed char; > > enum class _Ord : type { equivalent = 0, less = -1, greater = 1 }; > > enum class _Ncmp : type { _Unordered = 2 }; > > https://eel.is/c++draft/cmp#categories.pre-1 documents them as > > enum class ord { equal = 0, equivalent = equal, less = -1, greater = 1 }; // exposition only > > enum class ncmp { unordered = -127 }; // exposition only > > and now looking at it, LLVM's libc++ takes that literally and uses > > -1, 0, 1, -127. One can't use <=> operator without including <compare> > > which provides the enums, so I think if all we care about is libstdc++, > > then just hardcoding -1, 0, 1, 2 is fine, if we want to also optimize > > libc++ when used with gcc, we could support -1, 0, 1, -127 as another > > option. > > Supporting arbitrary 4 values doesn't make sense, at least on x86 the > > only reason to do the conversion to int in an optab is a good sequence > > to turn the flag comparisons to -1, 0, 1. So, either we do nothing > > more than the patch, or add handle both 2 and -127 for unordered, > > or add support for arbitrary value for the unordered case except > > -1, 0, 1 (then -1 could mean signed int, 1 unsigned int, 0 do the jumps > > and any other value what should be returned for unordered. Here is an incremental patch which adds support for (almost) arbitrary unordered constant value. It changes the .SPACESHIP and spaceship<mode>4 optab conventions, so 0 means use branches, floating point, -1, 0, 1, 2 results consumed by tree-ssa-math-opts.cc emitted comparisons, -1 means signed int comparisons, -1, 0, 1 results, 1 means unsigned int comparisons, -1, 0, 1 results, and for constant other than -1, 0, 1 which fit into [-128, 127] converted to the PHI type are otherwise specified as the last argument (then it is -1, 0, 1, C results). 2024-10-08 Jakub Jelinek <jakub@redhat.com> PR middle-end/116896 * tree-ssa-math-opts.cc (optimize_spaceship): Handle unordered values other than 2, but they still need to be signed char range possibly converted to the PHI result and can't be in [-1, 1] range. Use last .SPACESHIP argument of 1 for unsigned int comparisons, -1 for signed int, 0 for floating point branches and any other for floating point with that value as unordered. * config/i386/i386-expand.cc (ix86_expand_fp_spaceship): Use op2 rather const2_rtx if op2 is not const0_rtx for unordered result. (ix86_expand_int_spaceship): Change INTVAL (op2) == 1 tests to INTVAL (op2) != -1. * doc/md.texi (spaceship@var{m}4): Document the above changes. * gcc.target/i386/pr116896.c: New test.
2024-10-08LoongArch: Add support to annotate tablejumpXi Ruoyao1-1/+12
This is per the request from the kernel developers. For generating the ORC unwind info, the objtool program needs to analysis the control flow of a .o file. If a jump table is used, objtool has to correlate the jump instruction with the table. On x86 (where objtool was initially developed) it's simple: a relocation entry natrually correlates them because one single instruction is used for table-based jump. But on an RISC machine objtool would have to reconstruct the data flow if it must find out the correlation on its own. So, emit an additional section to store the correlation info as pairs of addresses, each pair contains the address of a jump instruction (jr) and the address of the jump table. This is very trivial to implement in GCC. gcc/ChangeLog: * config/loongarch/genopts/loongarch.opt.in (mannotate-tablejump): New option. * config/loongarch/loongarch.opt: Regenerate. * config/loongarch/loongarch.md (tablejump<mode>): Emit additional correlation info between the jump instruction and the jump table, if -mannotate-tablejump. * doc/invoke.texi: Document -mannotate-tablejump. gcc/testsuite/ChangeLog: * gcc.target/loongarch/jump-table-annotate.c: New test. Suggested-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2024-10-07c++: modules don't require preprocessor outputJason Merrill1-7/+6
init_modules has rejected -M -fmodules-ts on the premise that module dependency analysis requires macro expansion, but this is no longer accurate; P1857 prohibited module directives produced by macro expansion. They can still be dependent on #if directives, but those are still handled with -fdirectives-only. What wasn't working was -M or -dM, because cpp_scan_nooutput never called module_token_pre to implement the import. The simplest fix is to use the -fdirectives-only scan when modules are enabled and teach directives_only_cb about flag_no_output. gcc/cp/ChangeLog: * module.cc (init_modules): Don't warn about -M. gcc/c-family/ChangeLog: * c-ppoutput.cc (preprocess_file): For modules, use directives-only scan even with flag_no_output. (directives_only_cb): Respect flag_no_output. gcc/ChangeLog: * doc/invoke.texi (C++ Module Preprocessing): Allow -M, refer to -fdeps. gcc/testsuite/ChangeLog: * g++.dg/modules/macro-8_a.H: New test. * g++.dg/modules/macro-8_b.C: New test. * g++.dg/modules/macro-8_c.C: New test. * g++.dg/modules/macro-8_d.C: New test.
2024-10-07ssa-math-opts, i386: Improve spaceship expansion [PR116896]Jakub Jelinek1-2/+6
The PR notes that we don't emit optimal code for C++ spaceship operator if the result is returned as an integer rather than the result just being compared against different values and different code executed based on that. So e.g. for template <typename T> auto foo (T x, T y) { return x <=> y; } for both floating point types, signed integer types and unsigned integer types. auto in that case is std::strong_ordering or std::partial_ordering, which are fancy C++ abstractions around struct with signed char member which is -1, 0, 1 for the strong ordering and -1, 0, 1, 2 for the partial ordering (but for -ffast-math 2 is never the case). I'm afraid functions like that are fairly common and unless they are inlined, we really need to map the comparison to those -1, 0, 1 or -1, 0, 1, 2 values. Now, for floating point spaceship I've in the past already added an optimization (with tree-ssa-math-opts.cc discovery and named optab, the optab only defined on x86 though right now), which ensures there is just a single comparison instruction and then just tests based on flags. Now, if we have code like: auto a = x <=> y; if (a == std::partial_ordering::less) bar (); else if (a == std::partial_ordering::greater) baz (); else if (a == std::partial_ordering::equivalent) qux (); else if (a == std::partial_ordering::unordered) corge (); etc., that results in decent code generation, the spaceship named pattern on x86 optimizes for the jumps, so emits comparisons on the flags, followed by setting the result to -1, 0, 1, 2 and subsequent jump pass optimizes that well. But if the result needs to be stored into an integer and just returned that way or there are no immediate jumps based on it (or turned into some non-standard integer values like -42, 0, 36, 75 etc.), then CE doesn't do a good job for that, we end up with say comiss %xmm1, %xmm0 jp .L4 seta %al movl $0, %edx leal -1(%rax,%rax), %eax cmove %edx, %eax ret .L4: movl $2, %eax ret The jp is good, that is the unlikely case and can't be easily handled in straight line code due to the layout of the flags, but the rest uses cmov which often isn't a win and a weird math. With the patch below we can get instead xorl %eax, %eax comiss %xmm1, %xmm0 jp .L2 seta %al sbbl $0, %eax ret .L2: movl $2, %eax ret The patch changes the discovery in the generic code, by detecting if the future .SPACESHIP result is just used in a PHI with -1, 0, 1 or -1, 0, 1, 2 values (the latter for HONOR_NANS) and passes that as a flag in a new argument to .SPACESHIP ifn, so that the named pattern is told whether it should optimize for branches or for loading the result into a -1, 0, 1 (, 2) integer. Additionally, it doesn't detect just floating point <=> anymore, but also integer and unsigned integer, but in those cases only if an integer -1, 0, 1 is wanted (otherwise == and > or similar comparisons result in good code). The backend then can for those integer or unsigned integer <=>s return effectively (x > y) - (x < y) in a way that is efficient on the target (so for x86 with ensuring zero initialization first when needed before setcc; one for floating point and unsigned, where there is just one setcc and the second one optimized into sbb instruction, two for the signed int case). So e.g. for signed int we now emit xorl %edx, %edx xorl %eax, %eax cmpl %esi, %edi setl %dl setg %al subl %edx, %eax ret and for unsigned xorl %eax, %eax cmpl %esi, %edi seta %al sbbb $0, %al ret Note, I wonder if other targets wouldn't benefit from defining the named optab too... 2024-10-07 Jakub Jelinek <jakub@redhat.com> PR middle-end/116896 * optabs.def (spaceship_optab): Use spaceship$a4 rather than spaceship$a3. * internal-fn.cc (expand_SPACESHIP): Expect 3 call arguments rather than 2, expand the last one, expect 4 operands of spaceship_optab. * tree-ssa-math-opts.cc: Include cfghooks.h. (optimize_spaceship): Check if a single PHI is initialized to -1, 0, 1, 2 or -1, 0, 1 values, in that case pass 1 as last (new) argument to .SPACESHIP and optimize away the comparisons, otherwise pass 0. Also check for integer comparisons rather than floating point, in that case do it only if there is a single PHI with -1, 0, 1 values and pass 1 to last argument of .SPACESHIP if the <=> is signed, 2 if unsigned. * config/i386/i386-protos.h (ix86_expand_fp_spaceship): Add another rtx argument. (ix86_expand_int_spaceship): Declare. * config/i386/i386-expand.cc (ix86_expand_fp_spaceship): Add arg3 argument, if it is const0_rtx, expand like before, otherwise emit optimized sequence for setting the result into a GPR. (ix86_expand_int_spaceship): New function. * config/i386/i386.md (UNSPEC_SETCC_SI_SLP): New UNSPEC code. (setcc_si_slp): New define_expand. (*setcc_si_slp): New define_insn_and_split. (setcc + setcc + movzbl): New define_peephole2. (spaceship<mode>3): Renamed to ... (spaceship<mode>4): ... this. Add an extra operand, pass it to ix86_expand_fp_spaceship. (spaceshipxf3): Renamed to ... (spaceshipxf4): ... this. Add an extra operand, pass it to ix86_expand_fp_spaceship. (spaceship<mode>4): New define_expand for SWI modes. * doc/md.texi (spaceship@var{m}3): Renamed to ... (spaceship@var{m}4): ... this. Document the meaning of last operand. * g++.target/i386/pr116896-1.C: New test. * g++.target/i386/pr116896-2.C: New test.
2024-10-06doc: Focus on DWARF for FreeBSDGerald Pfeifer1-3/+1
gcc: PR target/69374 * doc/install.texi (Specific) <*-*-freebsd*>: Focus on DWARF only.
2024-10-04doc: Drop GCC 2.6 ABI change note for H8/h8300-hmsGerald Pfeifer1-5/+0
gcc: PR target/69374 * doc/install.texi (Specific) <h8300-hms>: Drop GCC 2.6 ABI change note.
2024-10-03c++: -Wdeprecated enables later standard deprecationsJason Merrill1-6/+16
By default -Wdeprecated warns about deprecations in the active standard. When specified explicitly, let's also warn about deprecations in later standards. gcc/c-family/ChangeLog: * c-opts.cc (c_common_post_options): Explicit -Wdeprecated enables deprecations from later standards. gcc/ChangeLog: * doc/invoke.texi: Explicit -Wdeprecated enables more warnings.
2024-10-03c++: add -Wdeprecated-literal-operator [CWG2521]Jason Merrill1-0/+12
C++23 CWG issue 2521 (https://wg21.link/cwg2521) deprecates user-defined literal operators declared with the optional space between "" and the suffix. Many testcases used that syntax; I removed the space from most of them, and added C++23 warning tests to a few. CWG 2521 gcc/ChangeLog: * doc/invoke.texi: Document -Wdeprecated-literal-operator. gcc/c-family/ChangeLog: * c.opt: Add -Wdeprecated-literal-operator. * c-opts.cc (c_common_post_options): Default on in C++23. * c.opt.urls: Regenerate. gcc/cp/ChangeLog: * parser.cc (location_between): New. (cp_parser_operator): Handle -Wdeprecated-literal-operator. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/udlit-string-literal.h * g++.dg/cpp0x/Wliteral-suffix2.C * g++.dg/cpp0x/constexpr-55708.C * g++.dg/cpp0x/gnu_fext-numeric-literals.C * g++.dg/cpp0x/gnu_fno-ext-numeric-literals.C * g++.dg/cpp0x/pr51420.C * g++.dg/cpp0x/pr60209-neg.C * g++.dg/cpp0x/pr60209.C * g++.dg/cpp0x/pr61038.C * g++.dg/cpp0x/std_fext-numeric-literals.C * g++.dg/cpp0x/std_fno-ext-numeric-literals.C * g++.dg/cpp0x/udlit-addr.C * g++.dg/cpp0x/udlit-args-neg.C * g++.dg/cpp0x/udlit-args.C * g++.dg/cpp0x/udlit-args2.C * g++.dg/cpp0x/udlit-clink-neg.C * g++.dg/cpp0x/udlit-concat-neg.C * g++.dg/cpp0x/udlit-concat.C * g++.dg/cpp0x/udlit-constexpr.C * g++.dg/cpp0x/udlit-cpp98-neg.C * g++.dg/cpp0x/udlit-declare-neg.C * g++.dg/cpp0x/udlit-embed-quote.C * g++.dg/cpp0x/udlit-extended-id-1.C * g++.dg/cpp0x/udlit-extended-id-3.C * g++.dg/cpp0x/udlit-extern-c.C * g++.dg/cpp0x/udlit-friend.C * g++.dg/cpp0x/udlit-general.C * g++.dg/cpp0x/udlit-implicit-conv-neg-char8_t.C * g++.dg/cpp0x/udlit-implicit-conv-neg.C * g++.dg/cpp0x/udlit-inline.C * g++.dg/cpp0x/udlit-mangle.C * g++.dg/cpp0x/udlit-member-neg.C * g++.dg/cpp0x/udlit-namespace.C * g++.dg/cpp0x/udlit-nofunc-neg.C * g++.dg/cpp0x/udlit-nonempty-str-neg.C * g++.dg/cpp0x/udlit-nosuffix-neg.C * g++.dg/cpp0x/udlit-nounder-neg.C * g++.dg/cpp0x/udlit-operator-neg.C * g++.dg/cpp0x/udlit-overflow-neg.C * g++.dg/cpp0x/udlit-overflow.C * g++.dg/cpp0x/udlit-preproc-neg.C * g++.dg/cpp0x/udlit-raw-length.C * g++.dg/cpp0x/udlit-raw-op-string-neg.C * g++.dg/cpp0x/udlit-raw-op.C * g++.dg/cpp0x/udlit-raw-str.C * g++.dg/cpp0x/udlit-resolve-char8_t.C * g++.dg/cpp0x/udlit-resolve.C * g++.dg/cpp0x/udlit-shadow-neg.C * g++.dg/cpp0x/udlit-string-length.C * g++.dg/cpp0x/udlit-suffix-neg.C * g++.dg/cpp0x/udlit-template.C * g++.dg/cpp0x/udlit-tmpl-arg-neg.C * g++.dg/cpp0x/udlit-tmpl-arg-neg2.C * g++.dg/cpp0x/udlit-tmpl-arg.C * g++.dg/cpp0x/udlit-tmpl-parms-neg.C * g++.dg/cpp0x/udlit-tmpl-parms.C * g++.dg/cpp1y/pr57640.C * g++.dg/cpp1y/pr88872.C * g++.dg/cpp26/unevalstr1.C * g++.dg/cpp2a/concepts-pr60391.C * g++.dg/cpp2a/consteval-prop21.C * g++.dg/cpp2a/nontype-class6.C * g++.dg/cpp2a/udlit-class-nttp-ctad-neg.C * g++.dg/cpp2a/udlit-class-nttp-ctad-neg2.C * g++.dg/cpp2a/udlit-class-nttp-ctad.C * g++.dg/cpp2a/udlit-class-nttp-neg.C * g++.dg/cpp2a/udlit-class-nttp-neg2.C * g++.dg/cpp2a/udlit-class-nttp.C * g++.dg/ext/is_convertible2.C * g++.dg/lookup/pr87269.C * g++.dg/cpp0x/udlit_system_header: Adjust for C++23 deprecated operator "" _suffix. * g++.dg/DRs/dr2521.C: New test.