Skip to content

Add feature detection macros for SB and DIT - #475

Open
dingxiangfei2009 wants to merge 1 commit into
ARM-software:mainfrom
dingxiangfei2009:sb-dit-feat
Open

dingxiangfei2009 wants to merge 1 commit into
ARM-software:mainfrom
dingxiangfei2009:sb-dit-feat

Conversation

@dingxiangfei2009

@dingxiangfei2009 dingxiangfei2009 commented Nov 1, 2026 •

Copy link
Copy Markdown
  • SB has existed in ARMv8 for some time and has not received a detection macro assignment. This feature would certainly be more useful if compilers understand its semantics and apply the appropriate value barriers. At the moment, programmers would need to insert value barriers manually, which can be easily forgotten.
  • DIT has been added in ARMv8.4 and and become mandatory in ARMv8.5-A. A feature detection macro would also be useful.

Fix #463


name: Pull request
about: feature proposal


Thank you for submitting a pull request!

If this PR is about a bugfix:

Please use the bugfix label and make sure to go through the checklist below.

If this PR is about a proposal:

We are looking forward to evaluate your proposal, and if possible to
make it part of the Arm C Language Extension (ACLE) specifications.

We would like to encourage you reading through the contribution
guidelines
, in particular the section on submitting
a proposal
.

Please use the proposal label.

As for any pull request, please make sure to go through the below
checklist.

Checklist: (mark with X those which apply)

  • If an issue reporting the bug exists, I have mentioned it in the
    PR (do not bother creating the issue if all you want to do is
    fixing the bug yourself).
  • I have added/updated the SPDX-FileCopyrightText lines on top
    of any file I have edited. Format is SPDX-FileCopyrightText: Copyright {year} {entity or name} <{contact informations}>
    (Please update existing copyright lines if applicable. You can
    specify year ranges with hyphen , as in 2017-2019, and use
    commas to separate gaps, as in 2018-2020, 2022).
  • I have updated the Copyright section of the sources of the
    specification I have edited (this will show up in the text
    rendered in the PDF and other output format supported). The
    format is the same described in the previous item.
  • I have run the CI scripts (if applicable, as they might be
    tricky to set up on non-*nix machines). The sequence can be
    found in the contribution
    guidelines
    . Don't
    worry if you cannot run these scripts on your machine, your
    patch will be automatically checked in the Actions of the pull
    request.
  • I have added an item that describes the changes I have
    introduced in this PR in section Changelog for year 20xx (this year)
    of section Preface/About this document.
    Create Changelog for year 20xx if it does not exist. Notice that
    changes that are not modifying the content and rendering of the
    specifications (both HTML and PDF) do not need to be listed.
  • When modifying content and/or its rendering, I have checked the
    correctness of the result in the PDF output (please refer to the
    instructions on how to build the PDFs
    locally
    ).
  • Please DO NOT add my GitHub profile to the list of contributors
    in the README page of the project.

@dingxiangfei2009

Copy link
Copy Markdown
Author

@AlfieRichardsArm @CarolineConcatto would you mind a look?

@dingxiangfei2009

dingxiangfei2009 commented Nov 19, 2026 •

Copy link
Copy Markdown
Author

I have prepared a patch to LLVM to expose the predefined macros, if that is the concern. I will follow up with GCC later.

llvm/llvm-project#244219

@AlfieRichardsArm

Copy link
Copy Markdown
Contributor

Hi, sorry for the delay, the feature macros look very reasonable to me.

I am not an expert on speculation barriers so don't feel qualified to comment on the speculation barrier API.

Specifically, I am very uncertain what API contract the intrinsic could have in regards to optimizations? I guess it can operate similarly to a memory barrier and we will prevent any memory reads or writes being moved over it, but is that enough?

@dingxiangfei2009

Copy link
Copy Markdown
Author

Thank you for looking into this @AlfieRichardsArm. Sorry I got sick unfortunately so I am slowly catching up with emails.

I realized, conceptually all three of isb, dsb and sb should ideally also be scheduling barriers from the codegen perspective. Sadly the document has not mentioned this for isb and dsb.

I would propose the wording for sb to fix this first and add this back to isb and dsb later. What do you think?

- SB has existed in ARMv8 for some time and has not received a detection
  macro assignment. This feature would certainly be more useful if
  compilers understand its semantics and apply the appropriate value
  barriers.
- DIT has been added in ARMv8.4 and and become mandatory in ARMv8.5-A. A
  feature detection macro would also be useful due to the history.


Signed-off-by: Xiangfei Ding <xfding@google.com>
Comment thread main/acle.md
Comment on lines +3679 to +3683
The `__sb()` intrinsic also acts as a compiler barrier of the appropriate
type. In the narrowest sense, this intrinsic poses as a memory barrier
so that memory loads and store do not reorder across it; and a scheduling
barrier so that surrounding code in program order should not be reordered
across it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is the new wording on the expectation on the compiler implementation.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[proposal] __ARM_FEATURE_DIT

2 participants