aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2024-06-11C++: Support constexpr strings for asm statementsAndi Kleen11-42/+193
Some programing styles use a lot of inline assembler, and it is common to use very complex preprocessor macros to generate the assembler strings for the asm statements. In C++ there would be a typesafe alternative using templates and constexpr to generate the assembler strings, but unfortunately the asm statement requires plain string literals, so this doesn't work. This patch modifies the C++ parser to accept strings generated by constexpr instead of just plain strings. This requires new syntax because e.g. asm("..." : "r" (expr)) would be ambigious with a function call. I chose () to make it unique. For example now you can write constexpr const char *genasm() { return "insn"; } constexpr const char *genconstraint() { return "r"; } asm(genasm() :: (genconstraint()) (input)); The constexpr strings are allowed for the asm template, the constraints and the clobbers (every time current asm accepts a string) This version allows the same constexprs as C++26 static_assert, following Jakub's suggestion. The drawback of this scheme is that the constexpr doesn't have full control over the input/output/clobber lists, but that can be usually handled with a switch statement. One could imagine more flexible ways to handle that, for example supporting constexpr vectors for the clobber list, or similar. But even without that it is already useful. Bootstrapped and full test on x86_64-linux. gcc/c-family/ChangeLog: * c-cppbuiltin.cc (c_cpp_builtins): Define __GXX_CONSTEXPR_ASM__ gcc/cp/ChangeLog: * 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. gcc/ChangeLog: * doc/extend.texi: Document constexpr asm. gcc/testsuite/ChangeLog: * 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-11Factor out static_assert constexpr string extraction for reuseAndi Kleen4-132/+176
The only semantics changes are slightly more vague error messages to generalize. gcc/cp/ChangeLog: * 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. gcc/testsuite/ChangeLog: * g++.dg/cpp26/static_assert1.C: Update to new error message. * g++.dg/cpp0x/udlit-error1.C: Dito.
2024-06-11scev query mismatch messageAndrew MacLeod1-3/+12
Add a message to the listing if SCEV is not invoked because of a range_query mismatch * 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-11libstdc++: Add test for chrono::leap_seconds ostream insertionJonathan Wakely2-0/+58
Also add a comment to the three-way comparison oeprator for chrono::leap_seconds, noting the deviation from the spec (which is functionally equivalent). What we implement is the originally proposed resolution to LWG 3383, which should compile slightly more efficiently than the final accepted resolution. libstdc++-v3/ChangeLog: * include/std/chrono (leap_seconds): Add comment. * testsuite/std/time/leap_seconds/io.cc: New test.
2024-06-11rust: Do not link with libdl and libpthread unconditionallyArthur Cohen5-1/+205
ChangeLog: * 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. gcc/rust/ChangeLog: * Make-lang.in: Remove overazealous LIBS = -ldl -lpthread line, link crab1 against CRAB1_LIBS.
2024-06-11PR modula2/114529 Avoid ODR violations in bootstrap translated sourcesGaius Mulley124-5605/+8057
This patch changes the bootstrap tool mc to avoid redefining any data types and therefore preventing ODR violations. All exported opaque type usages are implemented as void *. Local opaque type usages (static functions containing opaque type parameters) use the full declaration. mc casts usages between void * and full opaque type as necessary. The --extended-opaque option in mc has been disabled, as this generated ODR violations. The extended-opaque option inlined all declarations in the translated implementation module. As this is no longer used there is now a .h file for each .def file and a .cc file for every .mod file. This results in more Makefile rules for the ppg tool in Make-maintainer.in. gcc/m2/ChangeLog: 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. gcc/testsuite/ChangeLog: 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. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-06-11i386: PR target/115397: AVX512 ternlog vs. -m32 -fPIC constant pool.Roger Sayle2-1/+19
This patch fixes PR target/115397, a recent regression caused by my ternlog patch that results in an ICE (building numpy) with -m32 -fPIC. The problem is that ix86_broadcast_from_constant, which calls get_pool_constant, doesn't handle the UNSPEC_GOTOFF that's created by calling validize_mem when using -fPIC on i686. The logic here is a bit convoluted (and my future patches will clean some of this up), but the simplest fix is to call ix86_broadcast_from_constant between the calls to force_const_mem and the call to validize_mem. Perhaps a better solution might be to call targetm.delegitimize_address from the middle-end's get_pool_constant, but ultimately the best approach would be to not place things in the constant pool if we don't need to. My plans to move (broadcast) constant handling from expand to split1 should simplify this. 2024-06-11 Roger Sayle <roger@nextmovesoftware.com> gcc/ChangeLog 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. gcc/testsuite/ChangeLog PR target/115397 * gcc.target/i386/pr115397.c: New test case.
2024-06-11RISC-V: Implement .SAT_SUB for unsigned vector intPan Li12-5/+437
As the middle support of .SAT_SUB committed, implement the unsigned vector int of .SAT_SUB for the riscv backend. Consider below example code: 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)); \ } \ } Before this patch: ... vsetvli a5,a3,e64,m1,ta,mu slli a4,a5,3 vle64.v v2,0(a1) vle64.v v1,0(a2) vmsgeu.vv v0,v2,v1 vmv1r.v v3,v4 vsub.vv v3,v2,v1,v0.t vse64.v v3,0(a0) ... After this patch: ... vsetvli a5,a3,e64,m1,ta,ma slli a4,a5,3 vle64.v v1,0(a1) vle64.v v2,0(a2) vssubu.vv v1,v1,v2 vse64.v v1,0(a0) ... The below test suites are passed for this patch. * The rv64gcv fully regression test. gcc/ChangeLog: * config/riscv/autovec.md (ussub<mode>3): 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. gcc/testsuite/ChangeLog: * 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. Signed-off-by: Pan Li <pan2.li@intel.com>
2024-06-11fixincludes: bypass the math_exception fix on __cplusplusFrancois-Xavier Coudert3-29/+6
fixincludes/ChangeLog: * fixincl.x: Regenerate. * inclhack.def (math_exception): Bypass on __cplusplus. * tests/base/math.h: Regenerate.
2024-06-10[committed] [RISC-V] Drop dead round_32 testJeff Law1-23/+0
This test is no longer useful. It doesn't test what it was originally intended to test and there's really no way to recover it sanely. We agreed in the patchwork meeting last week that if we want to test Zfa that we'll write a new test for that. Similarly if we want to do deeper testing of the non-Zfa sequences in this space that we'd write new tests for those as well (execution tests in particular). So dropping this test. gcc/testsuite * gcc.target/riscv/round_32.c: Delete.
2024-06-11Daily bump.GCC Administrator6-1/+349
2024-06-11modula2: Fix typos, grammar, and a linkGerald Pfeifer1-3/+3
gcc: * doc/gm2.texi (Documentation): Fix typos, grammar, and a link.
2024-06-10Move array_bounds warnings into a separate pass.Andrew MacLeod6-41/+67
Array bounds checking is currently tied to VRP. This causes issues with using laternate VRP algorithms as well as experimenting with moving the location of the warnings later. This moves it to its own pass and cleans up the vrp_pass object. * 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[to-be-committed] [RISC-V] Use bext for extracting a bit into a SImode objectRaphael Zinsly2-0/+32
bext is defined as (src >> n) & 1. With that formulation, particularly the "&1" means the result is implicitly zero extended. So we can safely use it on SI objects for rv64 without the need to do any explicit extension. This patch adds the obvious pattern and a few testcases. I think one of the tests is derived from coremark, the other two from spec2017. This has churned through Ventana's CI system repeatedly since it was first written. Assuming pre-commit CI doesn't complain, I'll commit it on Raphael's behalf later today or Monday. gcc/ * config/riscv/bitmanip.md (*bextdisi): New pattern. gcc/testsuite * gcc.target/riscv/zbs-ext.c: New test.
2024-06-10[PATCH v1] Widening-Mul: Fix one ICE of gcall insertion for PHI matchPan Li3-1/+54
When enabled the PHI handing for COND_EXPR, we need to insert the gcall to replace the PHI node. Unfortunately, I made a mistake that insert the gcall to before the last stmt of the bb. See below gimple, the PHI is located at no.1 but we insert the gcall (aka no.9) to the end of the bb. Then the use of _9 in no.2 will have no def and will trigger ICE when verify_ssa. 1. # _9 = PHI <_3(4), 18446744073709551615(3)> // The PHI node to be deleted. 2. prephitmp_36 = (char *) _9; 3. buf.write_base = string_13(D); 4. buf.write_ptr = string_13(D); 5. buf.write_end = prephitmp_36; 6. buf.written = 0; 7. buf.mode = 3; 8. _7 = buf.write_end; 9. _9 = .SAT_ADD (string.0_2, maxlen_15(D)); // Insert gcall to last bb by mistake This patch would like to insert the gcall to before the start of the bb stmt. To ensure the possible use of PHI_result will have a def exists. After this patch the above gimple will be: 0. _9 = .SAT_ADD (string.0_2, maxlen_15(D)); // Insert gcall to start bb by mistake 1. # _9 = PHI <_3(4), 18446744073709551615(3)> // The PHI node to be deleted. 2. prephitmp_36 = (char *) _9; 3. buf.write_base = string_13(D); 4. buf.write_ptr = string_13(D); 5. buf.write_end = prephitmp_36; 6. buf.written = 0; 7. buf.mode = 3; 8. _7 = buf.write_end; The below test suites are passed for this patch: * The rv64gcv fully regression test with newlib. * The rv64gcv build with glibc. * The x86 regression test with newlib. * The x86 bootstrap test with newlib. PR target/115387 gcc/ChangeLog: * tree-ssa-math-opts.cc (math_opts_dom_walker::after_dom_children): Take the gsi of start_bb instead of last_bb. gcc/testsuite/ChangeLog: * gcc.target/riscv/pr115387-1.c: New test. * gcc.target/riscv/pr115387-2.c: New test.
2024-06-10libstdc++: [_Hashtable] Optimize destructorFrançois Dumont1-1/+1
Hashtable destructor do not need to call clear() method that in addition to destroying all nodes also reset all buckets to nullptr. libstdc++-v3/ChangeLog: * include/bits/hashtable.h (~_Hashtable()): Replace clear call with a _M_deallocate_nodes call.
2024-06-10Fix pr115388.c: plain char could be unsigned by default [PR115415]Andrew Pinski1-1/+1
This is a simple fix to the testcase as plain `char` could be unsigned by default on some targets (e.g. aarch64 and powerpc). Committed as obvious after quick test of the testcase on both aarch64 and x86_64. gcc/testsuite/ChangeLog: PR testsuite/115415 PR tree-optimization/115388 * gcc.dg/torture/pr115388.c: Use `signed char` directly instead of plain `char`. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2024-06-10[to-be-committed] [RISC-V] Use bext for extracting a bit into a SImode objectRaphael Zinsly2-0/+39
bext is defined as (src >> n) & 1. With that formulation, particularly the "&1" means the result is implicitly zero extended. So we can safely use it on SI objects for rv64 without the need to do any explicit extension. This patch adds the obvious pattern and a few testcases. I think one of the tests is derived from coremark, the other two from spec2017. This has churned through Ventana's CI system repeatedly since it was first written. Assuming pre-commit CI doesn't complain, I'll commit it on Raphael's behalf later today or Monday. gcc/ * config/riscv/bitmanip.md (*bextdisi): New pattern. gcc/testsuite * gcc.target/riscv/bext-ext.c: New test.
2024-06-10tree-optimization/115388 - wrong DSE in irreductible regionsRichard Biener2-21/+74
The following fixes a latent bug in DSE with regarding to variant array accesses where the code avoiding bogus DSE in loops fails to handle irreducible regions. For those we need to make sure backedges are marked and discover a header for the irreducible region to check invariantness. PR tree-optimization/115388 * tree-ssa-dse.cc (dse_classify_store): Handle irreducible regions. (pass_dse::execute): Make sure to mark backedges. * gcc.dg/torture/pr115388.c: New testcase.
2024-06-10Add testcase for PR ada/114708Eric Botcazou1-0/+22
gcc/testsuite/ PR ada/114708 * gnat.dg/incomplete8.adb: New test.
2024-06-10Add testcase for PR ada/114398Eric Botcazou1-0/+80
gcc/testsuite/ PR ada/114398 * gnat.dg/access11.adb: New test.
2024-06-10tree-optimization/115395 - wrong-code with SLP reduction in epilogRichard Biener2-19/+35
When we continue a non-SLP reduction from the main loop in the epilog with a SLP reduction we currently fail to handle an adjustment by the initial value because that's not a thing with SLP. As long as we have the possibility to mix SLP and non-SLP we have to handle it though. 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. * gcc.dg/vect/pr115395.c: New testcase.
2024-06-10ada: Add support for No_Implicit_Conditionals to nonbinary modular typesEric Botcazou1-55/+77
The expansion of additive operations for nonbinary modular types implemented in the front-end and its counterpart in code generators may create branches, which is not allowed when restriction No_Implicit_Conditionals is in effect. This changes it to use an explicit Mod operation when the restriction is in effect, which is assumed not to create such branches. gcc/ada/ * 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-10ada: Storage_Error in indirect call to function returning limited typeJavier Miranda2-8/+15
At runtime the code generated by the compiler reports the exception Storage_Error in an indirect call through an access-to-subprogram variable that references a function returning a limited tagged type object. gcc/ada/ * 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-10ada: Derived type with convention C must override convention C_Pass_By_CopyGary Dismukes1-0/+9
If a type DT is derived from a record type T with convention C_Pass_By_Copy and explicitly specifies convention C (via aspect or pragma), then type DT should not be treated as a type with convention C_Pass_By_Copy. Any parameters of the derived type should be passed by reference rather than by copy. The compiler was incorrectly inheriting convention C_Pass_By_Copy, by inheriting the flag set on the parent type, but that flag needs to be unset in the case where the convention is overridden. gcc/ada/ * 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-10ada: Minor code adjustment to "not Present" testGary Dismukes1-1/+1
This is just changing a "not Present (...)" test to "No (...)" to address a CB complaint from gnatcheck. gcc/ada/ * sem_aggr.adb (Resolve_Iterated_Association): Change "not Present" to "No" in test of Add_Named_Subp.
2024-06-10ada: For freezing, treat an extension or delta aggregate like a regular ↵Steve Baird1-1/+3
aggregate. Extend existing special freezing rules for regular aggregates to also apply to extension and delta aggregates. gcc/ada/ * freeze.adb (Should_Freeze_Type.Is_Dispatching_Call_Or_Aggregate): Treat an extension aggregate or a delta aggregate like a regular aggregate.
2024-06-10ada: Resolve compilation issues with container aggregates in draft ACATS B testsGary Dismukes1-6/+20
This change set addresses compilation problems encountered in the draft versions of the following ACATS B tests for container aggregates: B435001 (container aggregates with Assign_Indexed) B435002 (container aggregates with Add_Unnamed) B435003 (container aggregates with Add_Named) B435004 (container aggregates with Assign_Indexed and Add_Unnamed) gcc/ada/ * 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-10ada: Missing style check for extra parentheses in operatorsJustin Squirek7-9/+34
This patch fixes an issue in the compiler whereby wrapping an operand of a boolean operator resulted in a failure to detect whether or not they were unnecessary for the -gnatyx style checks. gcc/ada/ * 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-10ada: Iterator filter ignored on formal loopJustin Squirek1-8/+37
This patch fixs an issue where iterator filters for formal container and formal container element loops got silently ignored and remained unexpanded. gcc/ada/ * exp_ch5.adb (Expand_Formal_Container_Element_Loop): Add expansion of filter condition. (Expand_Formal_Container_Loop): Add expansion of filter condition.
2024-06-10ada: Crash checking accessibility level on private typeJustin Squirek1-1/+1
This patch fixes an issue in the compiler whereby calculating a static accessibility level on a private type with an access discriminant resulted in a compile time crash when No_Dynamic_Accessibility_Checks is enabled. gcc/ada/ * accessibility.adb (Accessibility_Level): Use Get_Full_View to avoid crashes when calculating scope.
2024-06-10ada: Unreferenced warning on abstract subprogramJustin Squirek1-4/+8
This patch modifies the unreferenced entity warning in the compiler to avoid noisily warning about unreferenced abstract subprogram. gcc/ada/ * sem_warn.adb (Warn_On_Unreferenced_Entity): Add a condition to ignore warnings on unreferenced abstract subprogram.
2024-06-10ada: Further refine 'Super attributeJustin Squirek1-0/+6
This patch adds the restriction on 'Super such that it cannot apply to objects whose parent type is an interface. gcc/ada/ * sem_attr.adb (Analyze_Attribute): Add check for interface parent types.
2024-06-10ada: Fix references to Ada RM in commentsPiotr Trojanek9-12/+11
We seem to have a convention of using "RM" in the GNAT comments, not "Ada RM". Also, the paragraph references by convention should appear in parentheses, e.g. "8.3(12.3/2)", not "8.3 12.3/2". gcc/ada/ * 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-10ada: Tune code related to potentially unevaluated expressionsPiotr Trojanek2-6/+4
Code cleanup; semantics is unaffected. gcc/ada/ * 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-10ada: Remove streaming facilities from generics for formal containersYannick Moy2-92/+0
The dependency on Ada.Streams is problematic for light runtimes. As these streaming facilities are in fact not used in formal containers, remove the corresponding dead code. gcc/ada/ * libgnat/a-chtgfo.adb (Generic_Read, Generic_Write): Remove. * libgnat/a-chtgfo.ads: Same. Remove dependency on Ada.Streams.
2024-06-10ada: Fix usage of SetThreadAffinityMaskRonan Desplanques2-4/+4
This patches fixes the signature of the binding to SetThreadAffinityMask in the run-time library. It also fixes the error checking after calls to SetThreadAffinityMask. The previous code behaved as if SetThreadAffinityMask returned 1 on success, but it in fact returns a pointer value on success and 0 on failure. gcc/ada/ * libgnarl/s-taprop__mingw.adb (Set_Task_Affinity): Fix usage of SetThreadAffinityMask. * libgnat/s-winext.ads (SetThreadAffinityMask): Fix binding signature.
2024-06-10ada: Fix usage of SetThreadIdealProcessorRonan Desplanques1-2/+11
This patches fixes the way the run-time library checks the return value of SetThreadIdealProcessor. gcc/ada/ * libgnarl/s-taprop__mingw.adb (Set_Task_Affinity): Fix usage of SetThreadIdealProcessor.
2024-06-10ada: Remove incorrect assertion in run-timeRonan Desplanques1-11/+11
There is a special case of file paths on Windows that are absolute but don't start with a drive letter: UNC paths. This patch removes an assertion in System.OS_Lib.Normalize_Pathname that failed to take this case into account. It also renames a local subprogram of Normalize_Pathname to make its purpose clearer. gcc/ada/ * libgnat/s-os_lib.adb (Normalize_Pathname): Remove incorrect assert statement. (Missed_Drive_Letter): Rename into... (Drive_Letter_Omitted): This.
2024-06-10ada: Fix incorrect lower bound presumption in gnatlinkRonan Desplanques1-9/+8
This patch fixes a subprogram in gnatlink that incorrectly assumed that the strings it is passed as arguments all have a lower bound of 1. gcc/ada/ * gnatlink.adb (Check_File_Name): Fix incorrect assumption.
2024-06-10ada: Cleanup repeated code in expansion of stream attributesPiotr Trojanek2-23/+16
In expansion of various attributes, in particular for the Input/Output and Read/Write attributes, we can use constants that are already used for expansion of many other attributes. gcc/ada/ * 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-10ada: Adjust comments and doc about the new use of restriction No_StreamsPiotr Trojanek5-15/+19
Extend code comment; move recently added documentation from pragma No_Tagged_Streams to restriction No_Streams. gcc/ada/ * 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-10ada: Skip processing of NUL character for attribute Type_KeyPiotr Trojanek1-4/+4
Code cleanup; behavior is unaffected. gcc/ada/ * sem_attr.adb (Analyze_Attribute): Use fully qualified name without a NUL, so that it doesn't need to be skipped afterwards.
2024-06-10ada: Simplify check for type without stream operationsPiotr Trojanek2-5/+3
Recursive routine Type_Without_Stream_Operation was checking restriction No_Default_Stream_Attributes at every call, which was confusing and inefficient. This routine is only called from the places: Check_Stream_Attribute, which already checks if this restriction is active, and Stream_Operation_OK, where we add such a check. Cleanup related to extending the use of No_Streams restriction. gcc/ada/ * 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-10ada: Enable inlining for subprograms with multiple return statementsPiotr Trojanek1-83/+8
With the support for forward GOTO statements in the GNATprove backend, we can now inline subprograms with multiple return statements in the frontend. Also, fix inconsistent source locations in the inlined code, which were now triggering assertion violations in the code for GNATprove counterexamples. gcc/ada/ * 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-10ada: Add switch to disable expansion of assertions in CodePeer modePiotr Trojanek2-3/+12
A new debug switch -gnatd_k is added, which has only effect in CodePeer mode. When enabled, assertion expressions are no longer expanded (which is the default in the CodePeer mode); instead, their expansion needs to be explicitly enabled by pragma Assertion_Policy. gcc/ada/ * 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-10ada: Refactor common code for dynamic and static class-wide preconditionsPiotr Trojanek1-18/+18
Code cleanup; semantics is unaffected. gcc/ada/ * 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-10ada: Cleanup building of error messages for class-wide contractsPiotr Trojanek1-2/+1
Code cleanup; semantics is unaffected. gcc/ada/ * exp_ch6.adb (Build_Dynamic_Check_Helper_Call): Remove unused iteration over formal parameters.
2024-06-10ada: Fix handling of aspects CPU and Interrupt_PriorityPiotr Trojanek1-1/+6
When resolving aspect expression, aspects CPU and Interrupt_Priority should be handled like the aspect Priority; in particular, all these expressions can reference discriminants of the annotated task type. gcc/ada/ * 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-10ada: Remove unnecessary guard against empty listPiotr Trojanek1-9/+6
Code cleanup; semantics is unaffected. gcc/ada/ * sem_prag.adb (Report_Extra_Clauses): Remove redundant check for empty list, because First works also for No_List.