Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove request for preprocessor guards from header files. #321

Merged
merged 14 commits into from
Aug 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 50 additions & 13 deletions main/acle.md
Original file line number Diff line number Diff line change
Expand Up @@ -925,8 +925,8 @@ and:
to the more specific header files below. These intrinsics are in the
C implementation namespace and begin with double underscores. It is
unspecified whether they are available without the header being
included. The `__ARM_ACLE` macro should be tested before including the
header:
included. When `__ARM_ACLE` is defined to `1`, the header file is
guaranteed to be available.

``` c
#ifdef __ARM_ACLE
Expand All @@ -939,8 +939,9 @@ header:
`<arm_fp16.h>` is provided to define the scalar 16-bit floating point
arithmetic intrinsics. As these intrinsics are in the user namespace,
an implementation would not normally define them until the header is
included. The `__ARM_FEATURE_FP16_SCALAR_ARITHMETIC` feature macro
should be tested before including the header:
included. When `__ARM_FEATURE_FP16_SCALAR_ARITHMETIC` is defined to `1`,
the header file is available regardless of the context in which the macro
is evaluated.

``` c
#ifdef __ARM_FEATURE_FP16_SCALAR_ARITHMETIC
Expand All @@ -953,8 +954,9 @@ should be tested before including the header:
`<arm_bf16.h>` is provided to define the 16-bit brain floating point
arithmetic intrinsics. As these intrinsics are in the user namespace,
an implementation would not normally define them until the header is
included. The `__ARM_FEATURE_BF16` feature macro
should be tested before including the header:
included. When `__ARM_FEATURE_BF16` is defined to `1`, the header file is
guaranteed to be available regardless of the context in which the macro
is evaluated.

``` c
#ifdef __ARM_FEATURE_BF16
Expand All @@ -975,8 +977,10 @@ instructions available are conversion intrinsics between `bfloat16_t` and
intrinsics](#advanced-simd-neon-intrinsics) and associated
[data types](#vector-data-types). As these intrinsics and data types are
in the user namespace, an implementation would not normally define them
until the header is included. The `__ARM_NEON` macro should be tested
before including the header:
until the header is included. When `__ARM_NEON` is defined to `1`,
the header file is available regardless of the context in which the macro is
evaluated.


``` c
#ifdef __ARM_NEON
Expand All @@ -999,8 +1003,8 @@ following it. --><span id="arm_sve.h"></span>
`<arm_sve.h>` defines data types and intrinsics for SVE and its
extensions; see [SVE language extensions and
intrinsics](#sve-language-extensions-and-intrinsics) for details.
You should test the `__ARM_FEATURE_SVE` macro before including the
header:
When `__ARM_FEATURE_SVE` is defined to `1`, the header file is available
regardless of the context in which the macro is evaluated.

``` c
#ifdef __ARM_FEATURE_SVE
Expand All @@ -1019,7 +1023,7 @@ Including `<arm_sve.h>` also includes the following header files:

`<arm_neon_sve_bridge.h>` defines intrinsics for moving data between
Neon and SVE vector types; see [NEON-SVE Bridge](#neon-sve-bridge)
for details. The `__ARM_NEON_SVE_BRIDGE` macro should be tested
for details. The `__ARM_NEON_SVE_BRIDGE` macro should be tested
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: unnecessary change.

before including the header:

``` c
Expand Down Expand Up @@ -1061,8 +1065,8 @@ change or be extended in the future.

`<arm_sme.h>` declares functions and defines intrinsics for SME
and its extensions; see [SME language extensions and intrinsics](#sme-language-extensions-and-intrinsics)
for details. The `__ARM_FEATURE_SME` macro should be tested before
including the header:
for details. When `__ARM_FEATURE_SME` is defined to `1`, the header file is
available regardless of the context in which the macro is evaluated.

``` c
#ifdef __ARM_FEATURE_SME
Expand All @@ -1072,6 +1076,39 @@ including the header:

Including `<arm_sme.h>` also includes [`<arm_sve.h>`](#arm_sve.h).

### Predefined feature macros and header files

CarolineConcatto marked this conversation as resolved.
Show resolved Hide resolved
Evaluating a feature macro returns the availability of intrinsics and inline
assembly for that feature, but no assumptions should be made on the order or
context in which the preprocessor macros are evaluated. For example:

``` c
__attribute__((target("+sve")))
void foo() {
#ifdef __ARM_FEATURE_SVE
// The user should make no assumptions that the target attribute
// has enabled the __ARM_FEATURE_SVE macro.
Comment on lines +1089 to +1090
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: whitespace

Suggested change
// The user should make no assumptions that the target attribute
// has enabled the __ARM_FEATURE_SVE macro.
// The user should make no assumptions that the target attribute
// has enabled the __ARM_FEATURE_SVE macro.

#endif
}
```

CarolineConcatto marked this conversation as resolved.
Show resolved Hide resolved
The compiler may add additional restrictions to the intrinsics beyond what is
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

captured by the ACLE macros depending on the context in which the intrinsics
are used. For example:
Comment on lines +1095 to +1097
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still not convinced this is worth pointing out, because the compiler may also enforce requirements on the range of immediate arguments, and we never bothered to document that either. That said though, I don't see any harm in adding this either.


``` c
#include <arm_sme.h>
void foo(svbool_t pg, void *ptr, uint32_t slice_base) {
#ifdef __ARM_FEATURE_SME
svst1_hor_za8(0, slice_base, pg, ptr);
CarolineConcatto marked this conversation as resolved.
Show resolved Hide resolved
#endif
}
```

If `__ARM_FEATURE_SME` evaluates to `true` the SME intrinsic `svst1_hor_za8`
is available, but `foo` may still fail to compile because the call does not
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

occur in a [streaming statement](#streaming-statement).

## Attributes

GCC-style attributes are provided to annotate types, objects and
Expand Down
Loading