77 Commits

Author SHA1 Message Date
Alexandros Lamprineas
cd3798d7ef
[FMV][AArch64] Add feature CSSC and detect on linux platform. (#132727)
Also removes priority bits for unused features predres and ls64.

Added to ACLE with https://github.com/ARM-software/acle/pull/390
2025-03-26 08:40:29 +00:00
Piyou Chen
2cd8207b26
[RISCV][compiler-rt] drop __riscv_vendor_feature_bits (#126460)
Address https://github.com/riscv-non-isa/riscv-c-api-doc/pull/101
2025-02-11 15:19:19 +08:00
Alexandros Lamprineas
474f5d2aef
[FMV][AArch64] Remove features predres and ls64. (#124266)
These cannot be detected by reading the ID_AA64ISAR1_EL1 register since
their corresponding bitfields are hidden. Additionally the instructions
that these features enable are unusable from EL0.

ACLE: https://github.com/ARM-software/acle/pull/382
2025-01-24 17:22:27 +00:00
Sander de Smalen
cb4f4a8a4d
[compiler-rt][AArch64] Rewrite SME routines to all use __aarch64_cpu_features. (#119414)
When #92921 added the `__arm_get_current_vg` functionality, it used the
FMV feature bits mechanism rather than the mechanism that was previously
added for SME which called `getauxval` on Linux platforms or
`__aarch64_sme_accessible` required for baremetal libraries. It is
better to always use `__aarch64_cpu_features`.

For baremetal we still need to rely on `__arm_sme_accessible` to
initialise the struct.
2024-12-11 15:53:17 +00:00
Phoebe Wang
a63931292b
[X86] Fix typo of gracemont (#118486) 2024-12-03 20:56:52 +08:00
Phoebe Wang
3348b4688f
[X86][compiler-rt] Split CPU names even they have the same subtype (#118237)
Fixes: #118205
2024-12-02 18:51:19 +08:00
Daniel Kiss
77bf34c315
[AArch64][compiler-rt] Add LSE support for Windows. (#116706) 2024-11-20 11:05:31 +01:00
Freddy Ye
97836bed63
Reland "[X86] Support -march=diamondrapids (#113881)" (#116564)
Ref.: https://cdrdv2.intel.com/v1/dl/getContent/671368
2024-11-18 10:40:32 +08:00
Freddy Ye
90e92239bd
Revert "[X86] Support -march=diamondrapids (#113881)" (#116563)
This reverts commit 826b845c9e97448395431be3e4e5da585bd98c5e.
2024-11-18 08:45:28 +08:00
Freddy Ye
826b845c9e
[X86] Support -march=diamondrapids (#113881)
Ref.: https://cdrdv2.intel.com/v1/dl/getContent/671368
2024-11-18 08:31:17 +08:00
Daniel Kiss
2a1586dfb5
[compiler-rt] Add cpu model init for Windows. (#111961) 2024-11-13 11:05:40 +01:00
Alexandros Lamprineas
799e520c51
[FMV] Remove feature dgh. (#115363)
It belongs to the HINT space so it can be executed as NOP if the
hardware doesn't support it.

Reviewed in ACLE -> https://github.com/ARM-software/acle/pull/357
2024-11-08 10:18:41 +00:00
Alexandros Lamprineas
e8b7d8bfb5
[FMV][AArch64] Remove features which expose non exploitable runtime behavior. (#114387)
Features ebf16, memtag3, and rpres allow existing instructions to behave
differently depending on the value of certain control registers. FMV
does not read the content of control registers making these features
unsuitable for runtime dispatch. See the ACLE patch for more info:
https://github.com/ARM-software/acle/pull/355
2024-11-07 17:15:23 +00:00
Kito Cheng
522880cb99
[compiler-rt][RISCV] Avoid using __init_riscv_feature_bits as a direc… (#115316)
…t constructor

`__init_riscv_feature_bits` takes an argument that can be
platform-specific, potentially pointing to the VDSO address of the
hwprobe system call for Linux. However, marking it as a constructor does
not guarantee that 0/NULL will always be passed to this argument, which
may result in treating an uninitialized or garbage value as a pointer to
hwprobe, leading to a crash.

The simplest solution is to introduce a small constructor function to
ensure that the platform-specific argument is set to 0/NULL.
2024-11-08 00:06:48 +08:00
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 e2cc63d80ce374fa04067c105a45ca7f0abba329 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 f1905f064451bf688577976a13000c9c47e58452.

This relands commit 19cf8deabe1124831164987f1b9bf2f806c0a875.

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 f6616e99c71c15d530060346ec29c3246d7fc235.

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 2039e130649d8469bc85fa31ba7422d1d3739f90.

This relands commit 19cf8deabe1124831164987f1b9bf2f806c0a875.

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 19cf8deabe1124831164987f1b9bf2f806c0a875.

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