Commit Graph

63 Commits

Author SHA1 Message Date
Alexandros Lamprineas
5dac2db5a8 [FMV][AArch64] Remove features which can be expressed as a combination of others. (#113580)
Removes sve-bf16, sve-ebf16, and sve-i8mm since they are obsolete. One
could write target_version("sve+bf16") instead of sve-bf16 for instance.

Approved in ACLE as https://github.com/ARM-software/acle/pull/353
2024-10-30 11:53:50 +00:00
Freddy Ye
c4248fa3ed [X86] Support MOVRS and AVX10.2 instructions. (#113274)
Ref.: https://cdrdv2.intel.com/v1/dl/getContent/671368
2024-10-25 09:00:19 +08:00
Alexandros Lamprineas
a91ebcdd91 [FMV][AArch64] Unify aes with pmull and sve2-aes with sve2-pmull128. (#111673)
According to the Arm Architecture Reference Manual for A-profile
architecture you can't have one feature without having the other:

ID_AA64ZFR0_EL1.AES, bits [7:4]

> FEAT_SVE_AES implements the functionality identified by the value
0b0001.
> FEAT_SVE_PMULL128 implements the functionality identified by the value
0b0010.
> The permitted values are 0b0000 and 0b0010.

(The following was removed from the latest release of the specification,
but it appears to be a mistake that was not intended to relax the
architecture constraints. The discrepancy has been reported)

ID_AA64ISAR0_EL1.AES, bits [7:4]

> FEAT_AES implements the functionality identified by the value 0b0001.
> FEAT_PMULL implements the functionality identified by the value
0b0010.
> From Armv8, the permitted values are 0b0000 and 0b0010.

Approved in ACLE as https://github.com/ARM-software/acle/pull/352
2024-10-23 16:28:55 +01:00
Freddy Ye
9e3d4653af [X86] Update Model value for Arrow Lake. (#113273)
Ref.: https://cdrdv2.intel.com/v1/dl/getContent/671368
2024-10-23 09:44:26 +08:00
Alexandros Lamprineas
b6e9ba017f [FMV][AArch64] Unify features memtag and memtag2. (#112511)
If we split these features in the compiler (see relevant pull request
https://github.com/llvm/llvm-project/pull/109299), we would only be able
to hand-write a 'memtag2' version using inline assembly since the
compiler cannot generate the instructions that become available with
FEAT_MTE2. However these instructions only work at Exception Level 1, so
they would be unusable since FMV is a user space facility. I am
therefore unifying them.

Approved in ACLE as https://github.com/ARM-software/acle/pull/351
2024-10-21 21:40:57 +01:00
Yangyu Chen
7fc3491c04 [compiler-rt][RISCV] Use u64 data type for marchid and mimpid (#112163)
Base on https://github.com/riscv-non-isa/riscv-c-api-doc/pull/91 , the
marchid and mimpid are MXLEN bits wide, and kernel returned them as u64
data type. So we should use u64 data type for marchid and mimpid in
__riscv_cpu_model struct here.

Signed-off-by: Yangyu Chen <cyy@cyyself.name>
2024-10-14 16:23:01 +08:00
RipleyTom
c5f7a32356 [X86] Add AMD Llano family detection (#111312)
Very simple one liner, adds the missing detection for the Llano family
which is essentially a refreshed K10:
Documentation of the family id:
https://en.wikichip.org/wiki/amd/cpuid#Family_18_.2812h.29
Documentation that it fits into amdfam10:
https://en.wikipedia.org/wiki/AMD_10h#12h
2024-10-07 08:33:26 -07:00
Alexandros Lamprineas
40f0f7b4ec [FMV][AArch64] Unify features ssbs and ssbs2. (#110297)
According to https://developer.arm.com/documentation/102105/latest Arm
Architecture Reference Manual for A-profile architecture: Known issues

2.206 D22789
In section C5.2.25 "SSBS, Speculative Store Bypass Safe", under the
heading 'Configurations', the text that reads:

"This register is present only when FEAT_SSBS is implemented. Otherwise,
direct accesses to SSBS are UNDEFINED."

is changed to read:

"This register is present only when FEAT_SSBS2 is implemented.
Otherwise, direct accesses to SSBS are UNDEFINED."

This suggests that it's not worth splitting FEAT_SSBS2 from FEAT_SSBS in
the compiler, since FEAT_SSBS cannot be used for predicating the MRS/MSR
instructions. Those can access PSTATE.SSBS only when FEAT_SSBS2 is
available. Moreover, there are no hardware implementations which
implement FEAT_SSBS without FEAT_SSBS2, therefore unifying these
features in the specification should not be a regression for feature
detection.

Approved in ACLE as https://github.com/ARM-software/acle/pull/350
2024-10-07 15:00:08 +01:00
Alexandros Lamprineas
f78009adea [compiler-rt][FMV][AArch64] Remove sha1 from fuchsia and apple targets. (#110291)
In e2cc63d80c I forgot to remove these
references. Fixes buildbot https://lab.llvm.org/buildbot/#/builders/11/builds/5749
2024-09-27 17:16:33 +01:00
Alexandros Lamprineas
e2cc63d80c [FMV][AArch64] Remove feature sha1 from FMV. (#108383)
Sha1 has been unified with sha2 in the ACLE spec
(see https://github.com/ARM-software/acle/pull/347)
so I am changing the compiler to adhere to it.
2024-09-27 16:30:54 +01:00
Alexandros Lamprineas
d497f465df [FMV][AArch64] Unify ls64, ls64_v and ls64_accdata. (#108024)
Originally I tried spliting these features in the compiler with
https://github.com/llvm/llvm-project/pull/101712, but we decided to lump
those features in the ACLE specification (see
https://github.com/ARM-software/acle/pull/346). Since there are no
hardware implementations out there which implement ls64 without ls64_v
or ls64_accdata, this shouldn't be a regression for feature detection.
2024-09-20 19:10:54 +01:00
Ganesh
02e4186d0b [X86] AMD Zen 5 Initial enablement (#107964)
This patch enables the basic skeleton enablement of AMD next gen zen5 CPUs.
2024-09-13 17:45:33 +01:00
Saleem Abdulrasool
73535076f2 builtins: replicate aarch64.c change into aarch64.h
Perform the same macro expansion in the header to improve handling
the various ARM64 environments which use different CPU architecture
identification macro spellings.
2024-09-12 08:42:51 -07:00
Saleem Abdulrasool
4570984e7f builtins: honour _M_ARM64 as __aarch64__
When clang is used as `clang-cl`, we use MSVC style macros. The spelling
of `__aarch64__` is converted to `_M_ARM64`. Account for this
alternative spelling in the conditional check. While in the area, add a
tertiary spelling of `__arm64__` to ensure that we catch more of the
variants.
2024-09-11 12:16:24 -07:00
Piyou Chen
2505546aee [compiler-rt][RISCV][NFC] Update code_model with latest spec (#106498)
The spec could be found here
https://github.com/riscv-non-isa/riscv-c-api-doc/pull/74

This patch updates the following symbol:

```
mVendorID -> mvendorid
mArchID -> marchid
mImplID -> mimpid
```
2024-08-29 17:55:27 +08:00
Brad Smith
da25e08a4c [builitins] Only try to use getauxval on Linux (#104047)
OpenBSD now has sys/auxv.h but does not use getauxval.
2024-08-15 20:50:12 -04:00
Piyou Chen
8bf298fa95 [RISCV][compiler-rt] create __riscv__cpu_model for vendorID, ArchID, … (#101449)
…ImplID

This patch 

1. remove the vendorId from `__riscv_vendor_feature_bits`
2. Define a new structure for vendorID, ArchID and ImplID
3. Update the relate init code
2024-08-14 18:11:54 +08:00
Piyou Chen
c4206f1ff1 [RISCV][compiler-rt] Update __init_riscv_feature_bits prototype (#101472)
This patch add `void* PlatformArgs` parameter to
`__init_riscv_feature_bits`. `PlatformArgs` allows the platform to
provide pre-computed data and access it without extra effort. For
example, Linux could pass the vDSO object to avoid an extra system call.

```
__init_riscv_feature_bits()

->

__init_riscv_feature_bits(void *PlatformArgs)
```
2024-08-14 17:30:53 +08:00
Brad Smith
e2f9c18533 [builtins] Rename sysauxv to getauxval to reflect the function called. NFCI (#102796) 2024-08-11 19:19:45 -04:00
Piyou Chen
82f52d9c42 [RISCV] Support new groupid/bitmask for cpu_model (#101632)
The spec can be found at
https://github.com/riscv-non-isa/riscv-c-api-doc/pull/74.

1. Add the new extension GroupID/Bitmask with latest hwprobe key.
2. Update the `initRISCVFeature `
3. Update `EmitRISCVCpuSupports` due to not only group0 now.
2024-08-08 14:42:41 +08:00
Phoebe Wang
259ca9ee9c Reland "[X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (#101452)" (#101616)
Ref.: https://cdrdv2.intel.com/v1/dl/getContent/828965
2024-08-03 09:26:07 +08:00
Phoebe Wang
2e0588d5e1 Revert "[X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions" (#101612)
Reverts llvm/llvm-project#101452

There are several buildbot failed. Revert first.
2024-08-02 13:04:10 +08:00
Phoebe Wang
10bad2c8d7 [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (#101452)
Ref.: https://cdrdv2.intel.com/v1/dl/getContent/828965
2024-08-02 12:10:50 +08:00
Alex Bradbury
96b1ae8927 [compiler-rt][RISCV][NFC] Add link to kernel documenation on hwprobe interface
Makes it a little easier for future reviewers/maintainers.
2024-07-30 10:37:55 +01:00
Dmitry Chestnykh
d09fc8f0b7 [compiler-rt][builtins] Fix -Werror build problem (#100312)
GCC-14.1.1 emit an error due to uninitialized variables
x86.c:303:17: error: ‘EAX’ may be used uninitialized
[-Werror=maybe-uninitialized]
x86.c:970:35: error: ‘MaxLevel’ may be used uninitialized
[-Werror=maybe-uninitialized]
x86.c:987:48: error: ‘MaxExtLevel’ may be used uninitialized
[-Werror=maybe-uninitialized]
It doesn't handle properly that these variables initialized indirectly
in functions that takes pointers to them
2024-07-24 10:41:25 +03:00
Aiden Grossman
599f8e1120 Reland "[compiler-rt][X86] Use functions in cpuid.h instead of inline assembly (#97877)"
This reverts commit f1905f0644.

This relands commit 19cf8deabe.

There were issues with the preprocessor includes that should have
excluded MSVC still including clang functions building on windows and
using intrin.h. This relanding fixes this behavior by additionally
wrapping the uses of __get_cpuid and __get_cpuid_count in _MSC_VER so
that clang in MSVC mode, which includes intrin.h, does not have any
conflicts.
2024-07-24 03:58:23 +00:00
Piyou Chen
73ac953626 [RISCV][compiler-rt] Small fixes for __riscv_feature_bits (#100158)
Changes included:

- Adding CONSTRUCTOR_ATTRIBUTE so that the static data is setup early on
in process lifetime. This is required by gcc docs for
__builtin_cpu_supports which we hope to implement in terms of this.
- Move the length initialization outside of the #if defined(linux) block
so that the length field always reflects the size of the structures even
if non of the feature bits are non-zero.
- Change the __riscv_vendor_feature_bits.length field to match the
length of the actual structure.

Note: Copy from https://github.com/llvm/llvm-project/pull/99958

---------

Co-authored-by: Philip Reames <preames@rivosinc.com>
2024-07-24 07:52:08 +08:00
James Y Knight
3c6ea7b716 Remove 3DNow! from X86TargetParser. (#99352)
This addresses the spurious inclusion of (now unsupported) target
features '-3dnow' and '-3dnowa' when disabling mmx (when then caused log
output from `clang -mno-mmx`).

It should've been part of PR #96246, but was missed.

Also tweaks the warning in prfchwintrin.h to not recommend the
deprecated mm3dnow.h header.
2024-07-20 11:28:06 -04:00
Aiden Grossman
f1905f0644 Revert "[compiler-rt][X86] Use functions in cpuid.h instead of inline assembly (#97877)"
This reverts commit f6616e99c7.

Was causing buildbot failures on Windows. I also remember seeing a
AMDGPU buildbot failing somewhere on a warning as they have -Werror
enabled.
2024-07-09 01:14:02 +00:00
Aiden Grossman
f6616e99c7 Reland "Revert "[compiler-rt][X86] Use functions in cpuid.h instead of inline assembly (#97877)""
This reverts commit 2039e13064.

This relands commit 19cf8deabe.

Added some additional preprocessor directives to ensure that Host.cpp
only includes cpuid.h when being built on x86.
2024-07-08 21:47:40 +00:00
Aiden Grossman
87e914db85 [compiler-rt][X86] Unify getAMDProcessorTypeAndSubType (#97863)
This patch unifies the implementation of getAMDProcessorTypeAndSubtype
between compiler-rt and LLVM.

This patch is intended to be a step towards pulling these functions out
into identical .inc files to better facilitate code sharing between LLVM
and compiler-rt.
2024-07-08 11:03:29 -07:00
Aiden Grossman
2039e13064 Revert "[compiler-rt][X86] Use functions in cpuid.h instead of inline assembly (#97877)"
This reverts commit 19cf8deabe.

This was causing quite a few buildbot failures (see the PR description).
Reverting for now while I have time to sort it out. Seems like it should
just be conditional preprocessor macros for X86 however.
2024-07-08 18:00:51 +00:00
Aiden Grossman
19cf8deabe [compiler-rt][X86] Use functions in cpuid.h instead of inline assembly (#97877)
This patch makes the host/feature detection in compiler-rt and LLVM use
the functions provided in cpuid.h(__get_cpuid, __get_cpuid_count)
instead of inline assembly. This simplifies the implementation and moves
any inline assembly away to a more common place.

A while ago, some similar cleanup was attempted, but this ended up
resulting in some compilation errors due to toolchain minimum version
issues (https://bugs.llvm.org/show_bug.cgi?id=30384). After the
reversion landed, there have been no attempts since then to clean up the
code, even though the minimum supported compilers now support the
relevant functions (https://godbolt.org/z/o1Mjz8ndv).
2024-07-08 10:54:35 -07:00
Aiden Grossman
23d1d95958 [LLVM][compiler-rt][AArch64] Refactor AArch64 CPU features (#97777)
This patch refactors the AArch64 CPUFeatures enum into a separate
include file that is identical between LLVM and compiler-rt. This, along
with a test in compiler-rt to ensure that the two stay in sync.
2024-07-05 10:59:51 -07:00
Jon Roelofs
0c0281130e fixup! [compiler-rt][AArch64][FMV] Use the hw.optional.arm.caps fast path (#95275)
https://github.com/llvm/llvm-project/pull/95275#issuecomment-2177366693
2024-06-18 19:04:03 -07:00
Jon Roelofs
4f8c961924 [compiler-rt][AArch64][FMV] Use the hw.optional.arm.caps fast path (#95275)
MacOS 15.0 and iOS 18.0 added a new sysctl to fetch a bitvector of all
the hw.optional.arm.FEAT_*'s in one go. Using this has a perf advantage
over doing multiple round-trips to the kernel and back, but since it's
not present in older oses, we still need the slow fallback.
2024-06-13 18:06:20 -07:00
Alexandros Lamprineas
933d6be8e8 [FMV][compiler-rt] Fix cpu features initialization. (#95149)
To detect features we either use HWCAPs or directly extract system
register bitfields and compare with a value. In many cases equality
comparisons give wrong results for example FEAT_SVE is not set if SVE2
is available (see the issue #93651). I am also making the access to
__aarch64_cpu_features atomic.

The corresponding PR for the ACLE specification is
https://github.com/ARM-software/acle/pull/322.
2024-06-13 11:45:39 +01:00
Kerry McLaughlin
043cc5a227 [AArch64][compiler-rt] Add a function returning the current vector length (#92921)
__arm_get_current_vg emits a cntd instruction if in streaming mode or SVE is
available at runtime, otherwise it will return 0.
2024-06-05 10:57:14 +01:00
David Spickett
c674dbc2a8 Revert "[FMV] Remove useless features according the latest ACLE spec." (#89184)
Reverts llvm/llvm-project#88965

This caused a test suite failure:
https://lab.llvm.org/buildbot/#/builders/185/builds/6583
NOEXE: test-suite::aarch64-acle-fmv-features.test

```
/home/tcwg-buildbot/worker/clang-aarch64-lld-2stage/test/test-suite/SingleSource/UnitTests/AArch64/acle-fmv-features.c:98:1: error: redefinition of 'check_sha1'
   98 | CHECK(sha1, {
      | ^
/home/tcwg-buildbot/worker/clang-aarch64-lld-2stage/test/test-suite/SingleSource/UnitTests/AArch64/acle-fmv-features.c:36:17: note: expanded from macro 'CHECK'
   36 |     static void check_##X(void) { \
      |                 ^
<scratch space>:150:1: note: expanded from here
  150 | check_sha1
      | ^
```

I presume that the useless features need to be removed from the fmv test
as well.
2024-04-18 09:25:47 +01:00
Alexandros Lamprineas
19c6a7feca [FMV] Remove useless features according the latest ACLE spec. (#88965)
As explained in https://github.com/ARM-software/acle/pull/315 we
are deprecating features which aren't adding any value. These are:

sha1, pmull, dit, dgh, ebf16, sve-bf16, sve-ebf16, sve-i8mm,
sve2-pmull128, memtag2, memtag3, ssbs2, bti, ls64_v, ls64_accdata
2024-04-17 17:16:58 +01:00
Freddy Ye
1fe6be8794 [X86] Support APXF to enable __builtin_cpu_supports. (#80636)
For referring, APX's spec:
https://cdrdv2.intel.com/v1/dl/getContent/784266
APX's index in libgcc:
https://github.com/gcc-mirror/gcc/blob/master/gcc/common/config/i386/i386-cpuinfo.h#L267
2024-02-23 15:18:42 +08:00
Freddy Ye
72105605d1 [X86] Support more ISAs to enable __builtin_cpu_supports (#79086)
This patch will also expand supports for attribute/target, while
the priority of newly supported ISAs will be set to zero.
2024-02-04 21:21:12 +08:00
Jon Roelofs
659419ac2f [builtins][FMV] Remove dead include from fmv/apple.inc. NFC 2024-02-02 13:41:21 -08:00
Jon Roelofs
9b48aa203a [compiler-rt][builtins][FMV] Early exit in the Apple __init_cpu_features_resolver(). NFC 2024-01-26 09:22:20 -08:00
Alexandros Lamprineas
179ba129f5 [AArch64][FMV] Support feature MOPS in Function Multi Versioning. (#78788)
The patch adds support for FEAT_MOPS (Memory Copy and Memory Set
instructions) in Function Multi Versioning. The bits [19:16] of the
system register ID_AA64ISAR2_EL1 indicate whether FEAT_MOPS is
implemented in AArch64 state. This information is accessible via ELF
hwcaps.
2024-01-23 15:48:12 +00:00
Jon Roelofs
c083b38007 [builtins][FMV][Apple] Use builtin atomic load/store, instead of libdispatch (#78807) 2024-01-22 09:10:16 -08:00
Freddy Ye
f3a4de395c [X86] Support "f16c" and "avx512fp16" for __builtin_cpu_supports (#78384)
This resolves issue #65320.
This also supports clarify sapphirerapids and cooperlake for
cpu_specific/dispatch.
2024-01-18 09:22:04 +08:00
Jon Roelofs
45ccc3b968 [compiler-rt][builtins] Add a missing 'const' to the Apple __init_cpu_features_resolver 2024-01-12 13:54:20 -08:00
Aiden Grossman
3ddf368524 [X86] Fix warning in cpu detection due to unsigned comparison
a15532d764 landed a patch that added
support for detecting more AMD znver2 CPUs and cleaned up some of the
surrounding code, including the znver3 detection. Since one model group
is 00h-0fh, I adjusted the check to include checking if the value is
greater than zero. Since the value is unsigned, this is always true and
gcc warns on it. This patch removes the comparison with zero to get rid
of the compiler warning.
2023-12-29 17:58:53 -08:00
Dimitry Andric
953ae94149 [builtins] Fix CPU feature detection for FreeBSD on AArch64 (#76532)
[builtins] Fix CPU feature detection for FreeBSD on AArch64

This is a follow-up to #75635 which broke the build for FreeBSD on
AArch64:

```
compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/freebsd.inc:3:16: error: call to undeclared function 'elf_aux_info'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    3 |   int result = elf_aux_info(AT_HWCAP, &hwcap, sizeof hwcap);
      |                ^
```

Using `elf_aux_info()` requires including `<sys/auxv.h>` first. To
prevent redeclaration issues with `hwcap.inc` attempting to define
`HWCAP_xxx` macros before `<sys/auxv.h>` does so, include `<sys/auxv.h>`
before any of the `.inc` files on FreeBSD.
2023-12-29 11:13:40 +01:00