This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Adding "armv8.8-a" BC instruction.
ClosedPublic

Authored by tmatheson on Dec 22 2021, 3:20 AM.

Details

Summary

This instruction is described in the Arm A64 Instruction Set Architecture documentation available here:
https://developer.arm.com/documentation/ddi0596/2021-12/Base-Instructions/BC-cond--Branch-Consistent-conditionally-?lang=en

FEAT_HBC "Hinted Conditional Branches" is listed in the 2021 A-Profile Architecture Extensions: https://developer.arm.com/architectures/cpu-architecture/a-profile/exploration-tools/feature-names-for-a-profile

'BC.cc', where 'cc' is any ordinary condition code, is an instruction
that looks exactly like B.cc (the normal conditional branch), except
that bit 4 of the encoding is 1 rather than 0, which hints something
to the branch predictor (specifically, that this branch is expected to
be highly consistent, even though _which way_ it will consistently go
is not known at compile time).

This commit introduces a special subtarget feature for HBC, which is a
dependency of the top-level 8.8-A feature, and uses that to enable the
new BC instruction.

Patch by Simon Tatham and Tomas Matheson

Diff Detail

Event Timeline

tmatheson created this revision.Dec 22 2021, 3:20 AM
tmatheson requested review of this revision.Dec 22 2021, 3:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 22 2021, 3:20 AM
nickdesaulniers added a comment.EditedDec 28 2021, 11:11 AM

Can you please site the relevant section of the Arm ARM for these extensions in the commit message?

My copy ver ARM DDI 0487G.b (ID072021) doesn't seem to mention these. (Checked § C4.1.3 and § A2).

Since it doesn't seem to mention 8.8, so I can't personally verify the encodings. But that's fine if another reviewer perhaps can?

llvm/lib/Target/AArch64/AArch64.td
420

Should this be hinted branch conditional to match HBC, or does the ARM ARM refer to it as such?

llvm/test/MC/AArch64/armv8.8a-hbc.s
4–5

Why do you need a temporary file (%t) here? Can't you just use a pipe as above?

23

Do you need to define lbl somewhere?

tmatheson edited the summary of this revision. (Show Details)Dec 29 2021, 11:24 AM
tmatheson updated this revision to Diff 396566.Dec 29 2021, 1:21 PM
tmatheson marked an inline comment as done.

Tweak description and test case.

tmatheson added inline comments.Dec 29 2021, 1:23 PM
llvm/lib/Target/AArch64/AArch64.td
420

No, the name of the feature is "Hinted conditional branches" but it is referred to as FEAT_HBC.

https://developer.arm.com/architectures/cpu-architecture/a-profile/exploration-tools/feature-names-for-a-profile

However, I've updated the description to match the format used for the existing extensions.

I don't think there is a version of the Arm ARM with these extensions released yet, but I've added links to the A64 ISA docs to the description.

llvm/test/MC/AArch64/armv8.8a-hbc.s
23

Apparently not, but I've added it as a label for clarity.

nickdesaulniers accepted this revision.Dec 29 2021, 2:31 PM
nickdesaulniers added inline comments.
llvm/test/MC/Disassembler/AArch64/armv8.8a-hbc.txt
4–5

Same question about the temporary here; prefer a pipe if possible. Sorry I missed that on my first look.

This revision is now accepted and ready to land.Dec 29 2021, 2:31 PM

Use pipe in second test

tmatheson marked an inline comment as done.Dec 29 2021, 11:28 PM

Thanks for the comments

This revision was landed with ongoing or failed builds.Jan 3 2022, 4:34 AM
This revision was automatically updated to reflect the committed changes.
Matt added a subscriber: Matt.Jan 4 2022, 9:39 AM