convert:
movi v31.4s, 0
ext v0.16b, v31.16b, v0.16b, #14
ret
We generate an ext with movi because this has same latency as a shift however
it has twice the throughput. The zero vector is zero latency as such in real
workloads this codegen is much better than using shifts.
As a reminder, BF16 -> FP32 is just shifting left 16 bits.
The expand pattern has to rely on generating multiple subregs due to a
restriction that subregs can't chang floating point size and type at the same
time.
I've tried alternative approaches like using the EXT as SF mode, but the
paradoxical subreg of BF -> SF isn't allowed and using an extend doesn't work
because extend is what we're defining.
Paul Thomas [Fri, 31 Oct 2025 12:59:23 +0000 (12:59 +0000)]
Fortran: Use specific PDT constructors from a generic list [PR122452]
2025-10-31 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/122452
* primary.cc (gfc_match_rvalue): Give priority to specific
procedures in a generic interface with the same name as a
PDT template. If found, use as the procedure instead of the
constructor generated from the PDT template.
gcc/testsuite/
PR fortran/122452
* gfortran.dg/pdt_65.f03: New test.
Richard Biener [Fri, 31 Oct 2025 07:57:39 +0000 (08:57 +0100)]
tree-optimization/122502 - avoid folding during imm use walk with active ranger
The following works around an unfortunate interaction with ranger
and immediate use walking. An actual solution needs more thoughts.
PR tree-optimization/122502
* tree-scalar-evolution.cc (final_value_replacement_loop):
Avoid folding from within FOR_EACH_IMM_USE_STMT due to active
ranger.
Andrew Pinski [Mon, 27 Oct 2025 23:20:40 +0000 (16:20 -0700)]
fold: Remove div_if_zero_remainder [PR122437]
While looking into something related to fold-const.cc, I noticed
that div_if_zero_remainder was unused. The last use of it was
removed in r5-3374-gf65586dcd19846 (via the removal of try_move_mult_to_index),
over 11 years ago. So it is time to remove this unused function too.
Plus this function is just a small wrapper around wi::multiple_of_p but
creating trees which can get expensive so folks should use wi::multiple_of_p
directly instead.
Bootstrapped and tested on x86_64-linux-gnu.
PR tree-optimization/122437
gcc/ChangeLog:
* fold-const.cc (div_if_zero_remainder): Remove.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Andrew Pinski [Fri, 31 Oct 2025 00:46:54 +0000 (17:46 -0700)]
sccp: Fix ICE during folding after proping const in some cases [PR122497]
In this case we originally had:
```
# g_4.3_21 = PHI <g_4.3_12(3)>
_1 = g_4.3_21 + 2;
_2 = g_2[_1][g_4.3_21];
```
SCCP figures out g_4.3_12/g_4.3_21 is 1.
final_value_replacement_loop would remove the phi defining _12.
do the constant prop of the const 1 but that would ICE as we try
to fold the reference `g_2[_1][g_4.3_21]` but that would try to see
the range of `_1` but since `_1` refers back to _21 there would be an
ICE as the phi is already been removed.
The obvious fix is to move the constant prop until after the new statement
for _21 is created.
Lulu Cheng [Thu, 6 Mar 2025 08:28:08 +0000 (16:28 +0800)]
LoongArch: Remove the "-mlasx" compilation option from the test cases.
Because LoongArch previously lacked support for 128-bit vectors
(vec_widen_{add/sub/mult}_{hi/lo}), the following test cases
needed to be enabled for 256-bit vectors to pass.
Now that 128-bit support has been added, "-mlasx" has been removed.
Lulu Cheng [Thu, 23 Oct 2025 09:14:19 +0000 (17:14 +0800)]
LoongArch: Implement the vector dot product operation with quadruple width.
The logic for the vector dot product operation, where the destination
elements are quadruple the width of the source elements, is as
follows (Take sdot_prodv4siv16qi as an example.):
Jakub Jelinek [Thu, 30 Oct 2025 21:37:33 +0000 (22:37 +0100)]
c++: Fix up and tweak std-name-hint.gperf
When converting reflection metafunction evaluation into gperf, I had
a look at the other *.gperf files in gcc/cp/.
cfns.gperf doesn't have any hash conflicts, but std-name-hint.gperf
has 7, which I believe means that for 7 of the strings it falls back to some
slow loop over not sure how many entries.
Apparently, 2 out of the 7 conflicts are just because two lines are
identically duplicated in the file, the patch included below fixes that.
2025-10-30 Jakub Jelinek <jakub@redhat.com>
* std-name-hint.gperf: Remove duplicate entries for ispanstream
and istringstream.
* std-name-hint.h: Regenerate.
Owen Avery [Thu, 2 Oct 2025 22:21:46 +0000 (18:21 -0400)]
gccrs: Improve ErrorPropagationExpr handling
gcc/rust/ChangeLog:
* ast/rust-ast-pointer-visitor.cc (PointerVisitor::visit):
Handle the expression contained in an ErrorPropagationExpr.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Likewise.
gccrs: Attempt to resolve pattern items in tuple pattern with a rest pattern
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-pattern.cc (visit(TuplePattern)): Update HAS_REST
case to continue to attempt to resolve pattern items after emitting size error.
Ryo Yoshida [Sun, 19 Oct 2025 13:45:17 +0000 (22:45 +0900)]
gccrs: Fix ICE on enum in tuple struct pattern
When we typecheck a tuple struct pattern and the type of its path is
an enum, it may refer to the enum itself and not a variant. Emit an
E0532 error on such cases.
* typecheck/rust-hir-type-check-base.cc (parse_repr_options): Changed TOKEN_TREE
assert into error, update malformed repr attribute error message to be inline
with other attribute error messages.
Lucas Ly Ba [Wed, 15 Oct 2025 15:28:36 +0000 (15:28 +0000)]
gccrs: fix inner attr derive doesn't show error
gcc/rust/ChangeLog:
* ast/rust-ast.cc (Attribute::is_derive):
Change string derive to its definition.
* util/rust-attribute-values.h:
Add attribute definition derive.
* util/rust-attributes.cc (AttributeChecker::visit):
Add method check_inner_attributes.
(AttributeChecker::check_inner_attributes):
Check if there is a bad inner attribute.
* util/rust-attributes.h:
Add method check_inner_attributes in .h.
gcc/testsuite/ChangeLog:
* rust/compile/issue-4212.rs: New test.
Signed-off-by: Lucas Ly Ba <lucas.ly-ba@outlook.fr>
Philip Herron [Sat, 4 Oct 2025 20:53:40 +0000 (21:53 +0100)]
gccrs: Refactor TyTy::ConstType into separate types
This patch refactors the const generic type system to follow the same pattern
as regular type parameters. The monolithic ConstType is split into four
distinct types:
gccrs: Implement compilation support for HIR::TupleStructItemsHasRest
gcc/rust/ChangeLog:
* backend/rust-compile-pattern.cc: Add compilation support for TupleStructItemsHasRest
in CompilePatternCheckExpr(TupleStructPattern) & CompilePatternBindings(TupleStructPattern)
gccrs: Implement lowering of AST::TupleStructItemsHasRest
gcc/rust/ChangeLog:
* hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::visit(TupleStructPattern)):
Implement lowering of AST::TupleStructItemsHasRest to HIR.
* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit(TupleStructPattern)):
Add the respective type checking for AST::TupleStructItemsHasRest
* checks/errors/rust-hir-pattern-analysis.cc (lower_tuple_pattern):
Add respective pattern for HAS_REST case.
gccrs: Fix StructPattern type checking rejecting tuple struct scrutinee
Previously, type checking of StructPattern will throw an error if it is used
to match against a tuple struct, even though it is possible to do so in rustc.
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-pattern.cc (visit(StructPattern)): Add type check
support for StructPatterns matching against a TUPLE type ADT.
* backend/rust-compile-pattern.cc(CompilePatternBindings::visit(StructPattern)):
Update assert to allow TUPLE type ADTs.
* hir/tree/rust-hir.cc (StructPatternField::as_string()): Improve info dumped.
* backend/rust-compile-extern.h: Add includes.
(CompileExternItem::visit): Use get_link_name.
(CompileExternItem::get_link_name): New static member function.
* util/rust-attribute-values.h (Attributes::LINK_NAME): New
static constexpr member variable.
* util/rust-attributes.cc (__definitions): New entry for
LINK_NAME.
* util/rust-ggc.cc: Include "rust-ast.h".
(Ident::Ident): Add overload for Rust::Identifier.
* util/rust-ggc.h (class Identifier): Forward declare.
(Ident::Ident): Add overload for Rust::Identifier.
* expand/rust-macro-expand.cc: Forward invocation tree locus to
substitution context.
* expand/rust-macro-substitute-ctx.cc: Use origin location for expanded
tokens.
* expand/rust-macro-substitute-ctx.h (class SubstituteCtx): Save
invocation location.
Builtin metavars are not in the fragment, the compiler should not emit
an error message.
gcc/rust/ChangeLog:
* expand/rust-macro-substitute-ctx.cc (is_builtin_metavariable): Add
function to check builtin metavars knowledge.
(SubstituteCtx::check_repetition_amount): Do not process missing
fragment.
Philip Herron [Mon, 22 Sep 2025 10:09:56 +0000 (11:09 +0100)]
gccrs: Add error diag for self params on plain functions
self params dont have a type unless used within impl blocks. Rustc as far as I
can tell in this senario generics a synthetic param of type Self in this senario
so that it keeps consistent error diagnostic for number of parameters but the
logic for what the parameter typpe should be seems unclear.
Philip Herron [Wed, 3 Sep 2025 09:21:06 +0000 (10:21 +0100)]
gccrs: Remove old hack from resolve operator overload
This was an old chunk of code to try and sort out the Self type on resolving
methods for impl blocks. But this is not required when our unify code works
properly.
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-expr.cc: remove old hack
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
This commit imports stdarch 1.49.0 into libgrust/rustc-lib/stdarch. This
is necessary for compiling libcore, as libcore attempts to reuse some
files from stdarch.
libgrust/ChangeLog:
* rustc-lib/stdarch/.cirrus.yml: New file.
* rustc-lib/stdarch/.github/workflows/main.yml: New file.
* rustc-lib/stdarch/.gitignore: New file.
* rustc-lib/stdarch/CONTRIBUTING.md: New file.
* rustc-lib/stdarch/Cargo.toml: New file.
* rustc-lib/stdarch/LICENSE-APACHE: New file.
* rustc-lib/stdarch/LICENSE-MIT: New file.
* rustc-lib/stdarch/README.md: New file.
* rustc-lib/stdarch/ci/android-install-ndk.sh: New file.
* rustc-lib/stdarch/ci/android-install-sdk.sh: New file.
* rustc-lib/stdarch/ci/android-sysimage.sh: New file.
* rustc-lib/stdarch/ci/docker/aarch64-linux-android/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/aarch64-unknown-linux-gnu/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/arm-linux-androideabi/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/armv7-unknown-linux-gnueabihf/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/i586-unknown-linux-gnu/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/i686-unknown-linux-gnu/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/mips-unknown-linux-gnu/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/mipsel-unknown-linux-musl/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/nvptx64-nvidia-cuda/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/powerpc-unknown-linux-gnu/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/s390x-unknown-linux-gnu/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/wasm32-wasi/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/x86_64-linux-android/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/x86_64-unknown-linux-gnu-emulated/Dockerfile: New file.
* rustc-lib/stdarch/ci/docker/x86_64-unknown-linux-gnu/Dockerfile: New file.
* rustc-lib/stdarch/ci/dox.sh: New file.
* rustc-lib/stdarch/ci/gba.json: New file.
* rustc-lib/stdarch/ci/run-docker.sh: New file.
* rustc-lib/stdarch/ci/run.sh: New file.
* rustc-lib/stdarch/ci/runtest-android.rs: New file.
* rustc-lib/stdarch/ci/style.sh: New file.
* rustc-lib/stdarch/crates/assert-instr-macro/Cargo.toml: New file.
* rustc-lib/stdarch/crates/assert-instr-macro/build.rs: New file.
* rustc-lib/stdarch/crates/assert-instr-macro/src/lib.rs: New file.
* rustc-lib/stdarch/crates/core_arch/Cargo.toml: New file.
* rustc-lib/stdarch/crates/core_arch/LICENSE-APACHE: New file.
* rustc-lib/stdarch/crates/core_arch/LICENSE-MIT: New file.
* rustc-lib/stdarch/crates/core_arch/README.md: New file.
* rustc-lib/stdarch/crates/core_arch/avx512f.md: New file.
* rustc-lib/stdarch/crates/core_arch/build.rs: New file.
* rustc-lib/stdarch/crates/core_arch/rustfmt.toml: New file.
* rustc-lib/stdarch/crates/core_arch/src/aarch64/crc.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/aarch64/crypto.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/aarch64/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/aarch64/neon/generated.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/aarch64/neon/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/aarch64/prefetch.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/aarch64/test_support.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/aarch64/tme.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/aarch64/v8.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/barrier/common.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/barrier/cp15.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/barrier/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/barrier/not_mclass.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/barrier/v8.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/dsp.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/ex.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/hints.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/registers/aarch32.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/registers/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/registers/v6m.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/registers/v7m.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/sat.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/acle/simd32.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/arm/armclang.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/arm/crc.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/arm/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/arm/neon/generated.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/arm/neon/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/arm/neon/table_lookup_tests.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/arm/test_support.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/arm/v6.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/arm/v7.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/core_arch_docs.md: New file.
* rustc-lib/stdarch/crates/core_arch/src/lib.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/macros.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/mips/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/mips/msa.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/mips/msa/macros.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/nvptx/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/powerpc/altivec.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/powerpc/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/powerpc/vsx.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/powerpc64/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/simd.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/simd_llvm.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/v64.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/wasm32/atomic.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/wasm32/memory.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/wasm32/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/wasm32/simd128.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/abm.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/adx.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/aes.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/avx.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/avx2.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/avx512f.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/avx512ifma.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/bmi1.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/bmi2.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/bswap.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/bt.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/cpuid.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/eflags.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/f16c.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/fma.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/fxsr.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/macros.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/pclmulqdq.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/rdrand.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/rdtsc.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/rtm.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/sha.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/sse.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/sse2.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/sse3.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/sse41.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/sse42.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/sse4a.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/ssse3.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/tbm.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/test.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86/xsave.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/abm.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/adx.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/avx.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/avx2.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/avx512f.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/bmi.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/bmi2.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/bswap.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/bt.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/cmpxchg16b.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/fxsr.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/mod.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/rdrand.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/sse.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/sse2.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/sse41.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/sse42.rs: New file.
* rustc-lib/stdarch/crates/core_arch/src/x86_64/xsave.rs: New file.
* rustc-lib/stdarch/crates/core_arch/tests/cpu-detection.rs: New file.
* rustc-lib/stdarch/crates/simd-test-macro/Cargo.toml: New file.
* rustc-lib/stdarch/crates/simd-test-macro/src/lib.rs: New file.
* rustc-lib/stdarch/crates/std_detect/Cargo.toml: New file.
* rustc-lib/stdarch/crates/std_detect/LICENSE-APACHE: New file.
* rustc-lib/stdarch/crates/std_detect/LICENSE-MIT: New file.
* rustc-lib/stdarch/crates/std_detect/README.md: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/arch/aarch64.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/arch/arm.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/arch/mips.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/arch/mips64.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/arch/powerpc.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/arch/powerpc64.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/arch/x86.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/bit.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/cache.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/error_macros.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/macros.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/mod.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/aarch64.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/freebsd/aarch64.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/freebsd/arm.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/freebsd/auxvec.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/freebsd/mod.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/freebsd/powerpc.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/linux/aarch64.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/linux/arm.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/linux/auxvec.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/linux/cpuinfo.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/linux/mips.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/linux/mod.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/linux/powerpc.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/other.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/windows/aarch64.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/os/x86.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/test_data/linux-rpi3.auxv: New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/test_data/linux-x64-i7-6850k.auxv:
New file.
* rustc-lib/stdarch/crates/std_detect/src/detect/test_data/macos-virtualbox-linux-x86-4850HQ.auxv:
New file.
* rustc-lib/stdarch/crates/std_detect/src/lib.rs: New file.
* rustc-lib/stdarch/crates/std_detect/src/mod.rs: New file.
* rustc-lib/stdarch/crates/std_detect/tests/cpu-detection.rs: New file.
* rustc-lib/stdarch/crates/std_detect/tests/macro_trailing_commas.rs: New file.
* rustc-lib/stdarch/crates/std_detect/tests/x86-specific.rs: New file.
* rustc-lib/stdarch/crates/stdarch-gen/Cargo.toml: New file.
* rustc-lib/stdarch/crates/stdarch-gen/README.md: New file.
* rustc-lib/stdarch/crates/stdarch-gen/neon.spec: New file.
* rustc-lib/stdarch/crates/stdarch-gen/src/main.rs: New file.
* rustc-lib/stdarch/crates/stdarch-test/Cargo.toml: New file.
* rustc-lib/stdarch/crates/stdarch-test/src/disassembly.rs: New file.
* rustc-lib/stdarch/crates/stdarch-test/src/lib.rs: New file.
* rustc-lib/stdarch/crates/stdarch-test/src/wasm.rs: New file.
* rustc-lib/stdarch/crates/stdarch-verify/.gitattributes: New file.
* rustc-lib/stdarch/crates/stdarch-verify/Cargo.toml: New file.
* rustc-lib/stdarch/crates/stdarch-verify/arm-intrinsics.html: New file.
* rustc-lib/stdarch/crates/stdarch-verify/build.rs: New file.
* rustc-lib/stdarch/crates/stdarch-verify/mips-msa.h: New file.
* rustc-lib/stdarch/crates/stdarch-verify/src/lib.rs: New file.
* rustc-lib/stdarch/crates/stdarch-verify/tests/arm.rs: New file.
* rustc-lib/stdarch/crates/stdarch-verify/tests/mips.rs: New file.
* rustc-lib/stdarch/crates/stdarch-verify/tests/x86-intel.rs: New file.
* rustc-lib/stdarch/crates/stdarch-verify/x86-intel.xml: New file.
* rustc-lib/stdarch/examples/Cargo.toml: New file.
* rustc-lib/stdarch/examples/hex.rs: New file.
* rustc-lib/stdarch/examples/wasm.rs: New file.
* rustc-lib/stdarch/triagebot.toml: New file.
* rustc-lib/stdarch/vendor.yml: New file.
Philip Herron [Fri, 12 Sep 2025 15:37:32 +0000 (16:37 +0100)]
gccrs: Fix ICE with invalid const expression
This patch handles the overflowed var expression in the const block, so that
we error properly in the const expr code. It was missing some stuff from the
c++ implementation in how this should be handled properly.
Fixes Rust-GCC#4139
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (CompileExpr::compile_integer_literal): cleanup
* backend/rust-constexpr.cc (struct constexpr_global_ctx): port over c++ helpers
(decl_really_constant_value): likewise
(eval_constant_expression): likewise
(non_const_var_error): likewise
gcc/testsuite/ChangeLog:
* rust/compile/issue-4139.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Philip Herron [Wed, 3 Sep 2025 19:50:59 +0000 (20:50 +0100)]
gccrs: track abi and unsafety on fnptrs for proper type checking
We need to distinguish between abi's and unsafety on fnptrs. There is
a commented out check because there is a regression in:
rust/compile/try-catch-unwind-{new/old}.rs
But i think this is because the test case should be taking an FnOnce
from reading std::panic in rust 1.49. Where as we are passing an fnptr
which is probably because we didnt support fnonce at all then.
Addresses Rust-GCC/gccrs#4090
gcc/rust/ChangeLog:
* hir/tree/rust-hir-item.h: add unsafe helper
* typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): pass in abi and unsafe
* typecheck/rust-tyty.cc (BaseType::monomorphized_clone): likewise
(FnPtr::as_string): emit more info
(FnPtr::clone): update ctor call
* typecheck/rust-tyty.h: new ctor params
* typecheck/rust-unify.cc (UnifyRules::expect_fnptr): check abi and unsafe
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gccrs: Unify path-to-type handling in Late resolver
gcc/rust/ChangeLog:
* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Use
resolve_type_path_like in overloads for TypePath,
StructExprStruct, StructExprStructBase, and
StructExprStructFields.
(resolve_type_path_like): New static function based off
Late::visit overload for TypePath.
* util/rust-unwrap-segment.h (unwrap_segment_error_string): New
inline static function definitions.
Philip Herron [Sun, 31 Aug 2025 21:57:05 +0000 (22:57 +0100)]
gccrs: Fix segv when handling invalid array capacities
We need to catch the error node for the array capacity and return early.
Otherwise we try to const evaluate something thats just silly. Also
when compiling array expressions we can simply reuse the array capacity
expression we already have cons folded.
Fixes Rust-GCC#3965
gcc/rust/ChangeLog:
* backend/rust-compile-context.h: add assertions for context peeks
* backend/rust-compile-expr.cc (CompileExpr::visit): check for valid loop context
(CompileExpr::array_copied_expr): just reuse array tyty capacity value
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): catch error
gcc/testsuite/ChangeLog:
* rust/compile/issue-3965-1.rs: New test.
* rust/compile/issue-3965-2.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
This doesn't actually handle the attribute, although it does allow us to
recognize it as valid.
gcc/rust/ChangeLog:
* util/rust-attribute-values.h
(Attributes::RUSTC_ALLOW_CONST_FN_UNSTABLE): New static
constexpr member variable.
* util/rust-attributes.cc (__definitions): Add entry for
RUSTC_ALLOW_CONST_FN_UNSTABLE.
Philip Herron [Sun, 3 Aug 2025 18:53:23 +0000 (19:53 +0100)]
gccrs: allow unifications against non const types
When type resolving a function which returns a const generic for example
this means its unifying the ConstType vs the the specified type so this
mean unwrapping the type of the const.
gcc/rust/ChangeLog:
* typecheck/rust-unify.cc (UnifyRules::go): unwrap the const type
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Philip Herron [Fri, 29 Aug 2025 16:54:54 +0000 (17:54 +0100)]
gccrs: Remove fully the can_eq TyTy::BaseType::can_eq interface
This was an initial helper from back in the day which was not maintained
but was a nice const simple way to check if types are compatable. But
reusing our unify code is much much more acurate and single source of
truth on the type system.
Philip Herron [Fri, 29 Aug 2025 16:42:10 +0000 (17:42 +0100)]
gccrs: simplify cloning of types during unify
We should only clone when we commit and it was successful. With no
cloning there is a regression in min specialization 2. Probably because
it needs to know the unify site hirid and ensure we have it set there.
Philip Herron [Mon, 25 Aug 2025 12:30:22 +0000 (13:30 +0100)]
gccrs: respect the unify rules commit flag
We use the types compatable interface for unify here and so if
we dont respect the commit flag the interface can have unintended
side effects with infer type hints throwing things off down the line.
Philip Herron [Mon, 25 Aug 2025 10:34:25 +0000 (11:34 +0100)]
gccrs: Remove some const usage so we can get rid of more can_eq usage
I needed to remove som usage of const so we can get rid of can_eq in
type bounds probe. This means we can use the types_compatable interface
instead. Which is much better.
Philip Herron [Mon, 25 Aug 2025 19:44:16 +0000 (20:44 +0100)]
gccrs: Make the coerce borrowed pointer consistent with try flag
This interface is not respecting the coercion api commit is always false,
we need to ensure this is respected via the try flag like the rest of the
coercion logic.
gcc/rust/ChangeLog:
* typecheck/rust-coercion.cc (TypeCoercionRules::select): respect try flag
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gccrs: Error out on unsuffixed self list use declaration
gcc/rust/ChangeLog:
* resolve/rust-early-name-resolver-2.0.cc (Early::finalize_rebind_import):
Replace assert with early break and remove early return.
(Early::visit): Check for unsuffixed lower self list.
* resolve/rust-early-name-resolver-2.0.h: Add visit function prototype.
gcc/testsuite/ChangeLog:
* rust/compile/use_self_alone_in_list.rs: New test.
Owen Avery [Sat, 23 Aug 2025 02:26:05 +0000 (22:26 -0400)]
gccrs: nr1.0: Remove support in borrow checker
gcc/rust/ChangeLog:
* checks/errors/borrowck/rust-bir-builder-internal.h: Remove
inclusion of "rust-name-resolver.h".
(BuilderContext::resolver): Change type to nr2.0 resolver.
(BuilderContext::BuilderContext): Change initialization of
resolver reference.
(AbstractBuilder::resolve_label): Assume name resolution 2.0 is
enabled.
(AbstractBuilder::resolve_variable): Likewise.
(AbstractBuilder::resolve_variable_or_fn): Likewise.
Owen Avery [Sat, 23 Aug 2025 02:57:05 +0000 (22:57 -0400)]
gccrs: nr1.0: Remove support in pattern checker
gcc/rust/ChangeLog:
* checks/errors/rust-hir-pattern-analysis.cc: Remove inclusion
of "options.h".
(PatternChecker::PatternChecker): Change initialization of
resolver reference.
(PatternChecker::visit): Assume name resolution 2.0 is enabled.
* checks/errors/rust-hir-pattern-analysis.h: Include nr2.0
header instead of nr1.0 header.
(PatternChecker::resolver): Change type to nr2.0 resolver.
Owen Avery [Sat, 23 Aug 2025 02:12:35 +0000 (22:12 -0400)]
gccrs: nr1.0: Remove support in rust-session-manager.cc
gcc/rust/ChangeLog:
* rust-session-manager.cc: Remove inclusion of name resolution
1.0 headers.
(Session::compile_crate): Assume name resolution 2.0 is enabled.
(Session::expansion): Likewise.
(Session::load_extern_crate): Likewise.
Owen Avery [Sat, 23 Aug 2025 17:29:54 +0000 (13:29 -0400)]
gccrs: nr1.0: Remove support in privacy checker
gcc/rust/ChangeLog:
* checks/errors/privacy/rust-privacy-check.cc: Adjust includes.
(Resolver::resolve): Pass 2.0 name resolution context to
VisibilityResolver and PrivacyReporter.
* checks/errors/privacy/rust-privacy-reporter.cc
(PrivacyReporter::PrivacyReporter): Change type of resolver
parameter.
(is_child_module): Remove static function.
(PrivacyReporter::check_for_privacy_violation): Assume nr2.0 is
enabled and handle removal of is_child_module.
* checks/errors/privacy/rust-privacy-reporter.h: Adjust
includes.
(PrivacyReporter::PrivacyReporter): Change type of resolver
parameter.
(PrivacyReporter::resolver): Change member variable type.
* checks/errors/privacy/rust-visibility-resolver.cc: Adjust
includes.
(VisibilityResolver::VisibilityResolver): Change type of
resolver parameter.
(VisibilityResolver::resolve_module_path): Assume nr2.0 is
enabled.
* checks/errors/privacy/rust-visibility-resolver.h: Adjust
includes.
(VisibilityResolver::VisibilityResolver): Change type of
resolver parameter.
(VisibilityResolver::resolver): Change member variable type.
gccrs: Refactor AST Patterns that hold multiple pattern items
Patterns include TuplePattern, TupleStructPattern & SlicePattern. Besides making their pattern
items container class inherit from a common `PatternItems` base class just like in HIR for
better standardization, mentions of `Range` are also changed to `HasRest` or `NoRest`.
gcc/rust/ChangeLog:
* ast/rust-pattern.h:
- Add a new base abstract class `PatternItems` which are used by pattern items class
class derivatives for `TuplePattern`, `TupleStructPattern` & `SlicePattern`.
- Standardized the derived class names to have `HasRest` or `NoRest` as suffixes.
- Values for the common `ItemType` enum is updated to `HAS_REST` or `NO_REST`.
* ast/rust-pattern.cc: Renamed the classes accordingly.
* ast/rust-ast-collector.cc: Renamed the classes accordingly.
* ast/rust-ast-collector.h: Renamed the classes accordingly.
* ast/rust-ast-full-decls.h: Renamed the classes accordingly.
* ast/rust-ast-visitor.cc: Renamed the classes accordingly.
* ast/rust-ast-visitor.h: Renamed the classes accordingly.
* ast/rust-desugar-for-loops.cc: Renamed the classes accordingly.
* ast/rust-desugar-question-mark.cc: Renamed the classes accordingly.
* expand/rust-cfg-strip.cc: Renamed the classes accordingly.
* expand/rust-cfg-strip.h: Renamed the classes accordingly.
* expand/rust-derive-clone.cc: Renamed the classes accordingly.
* expand/rust-derive-cmp-common.cc: Renamed the classes accordingly.
* expand/rust-derive-hash.cc: Renamed the classes accordingly.
* expand/rust-derive-ord.cc: Renamed the classes accordingly.
* expand/rust-derive-partial-eq.cc: Renamed the classes accordingly.
* expand/rust-derive.h: Renamed the classes accordingly.
* expand/rust-expand-visitor.cc: Renamed the classes accordingly.
* expand/rust-expand-visitor.h: Renamed the classes accordingly.
* hir/rust-ast-lower-base.cc: Renamed the classes accordingly.
* hir/rust-ast-lower-base.h: Renamed the classes accordingly.
* hir/rust-ast-lower-pattern.cc: Renamed the classes accordingly.
* hir/tree/rust-hir-pattern.h: Renamed the classes accordingly.
* parse/rust-parse-impl.h: Renamed the classes accordingly.
* resolve/rust-ast-resolve-base.cc: Renamed the classes accordingly.
* resolve/rust-ast-resolve-base.h: Renamed the classes accordingly.
* resolve/rust-ast-resolve-pattern.cc: Renamed the classes accordingly.
* util/rust-attributes.cc: Renamed the classes accordingly.
* util/rust-attributes.h: Renamed the classes accordingly.
Owen Avery [Sun, 24 Aug 2025 23:37:45 +0000 (19:37 -0400)]
gccrs: Avoid std::unique_ptr<std::string> in Token
gcc/rust/ChangeLog:
* ast/rust-ast-collector.cc (TokenCollector::visit): Use
should_have_str instead of has_str.
* ast/rust-ast.cc (Token::as_string): Likewise.
* expand/rust-macro-builtins-offset-of.cc
(MacroBuiltin::offset_of_handler): Likewise.
* lex/rust-lex.cc (Lexer::dump_and_skip): Likewise.
* ast/rust-ast.h (class Token): Remove dead code.
(Token::has_str): Remove function.
(Token::should_have_str): New function.
* lex/rust-token.cc (Token::get_str): Remove function
definition.
* lex/rust-token.h: Include "rust-diagnostics.h".
(Token::str): Change type from std::unique_ptr<std::string> to
std::string.
(Token::Token): Adjust initialization of str member variable and
the type of the parameter used to initialize it.
(Token::make_identifier): Accept std::string instead of rvalue
reference to std::string.
(Token::make_int): Likewise.
(Token::make_float): Likewise.
(Token::make_string): Likewise.
(Token::make_byte_string): Likewise.
(Token::make_raw_string): Likewise.
(Token::make_inner_doc_comment): Likewise.
(Token::make_outer_doc_comment): Likewise.
(Token::make_lifetime): Likewise.
(Token::get_str): Add definition to function declaration.
(Token::has_str): Remove member function.
(Token::should_have_str): Handle INNER_DOC_COMMENT and
OUTER_DOC_COMMENT.