[AIE] Add a SubtargetFeature capability set for aie2p#1172
Open
atassis wants to merge 1 commit into
Open
Conversation
atassis
requested review from
F-Stuckmann,
SagarMaheshwari99,
abhinay-anubola,
abnikant,
andcarminati,
katerynamuts,
khallouh,
konstantinschwarz,
martien-de-jong,
mludevid,
niwinanto and
stephenneuendorffer
as code owners
July 21, 2026 00:50
atassis
force-pushed
the
aie2p-subtarget-capability-set
branch
from
July 22, 2026 14:49
034387e to
2ba8ff0
Compare
The AIE backend has no capability mechanism today. The ProcessorModel feature lists are empty and target selection is by CPU name, so code that needs to know what a part supports falls back to an __AIEARCH__ == 21 style arch check (for example in aiebase_typedefs.h). That models capability as a level, but the revisions are not nested, so capability is really a set. Add real SubtargetFeature flags (bfp16, acc2048) and wire them to the aie2p ProcessorModel, mirroring how other targets model capability as a feature set. TableGen then generates the hasBFP16()/hasAcc2048() accessors, so a backend pass can query a capability instead of the CPU name. Expose the same features through clang: default them on for the aie2p triple, resolve -target-feature overrides, and emit __AIE_HAS_BFP16__ and __AIE_HAS_ACC2048__ from getTargetDefines the same way __AVX__ is emitted. A kernel can then select a code path with #if __AIE_HAS_BFP16__ instead of an arch guard, and the choice follows the capability: it is absent when the feature is disabled and absent on a revision that does not carry it. This does not change codegen for any existing target. Add preprocessor and codegen tests covering the default, the disabled feature, and a revision without the feature.
atassis
force-pushed
the
aie2p-subtarget-capability-set
branch
from
July 24, 2026 18:42
2ba8ff0 to
df8869c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The AIE backend has no real capability mechanism today. The ProcessorModel
subtarget feature lists are empty and target selection is by CPU name, so code
that needs to know what a part supports falls back to
#if __AIEARCH__ == 21style gating (for example in
clang/lib/Headers/aiebase_typedefs.h). Thattreats capability as a level, but the revisions are not nested: aie2p has
native bfp16, while aie2ps drops bfp16 for MX and adds native fp8. Capability
is a set, not a point on a line.
This change adds real SubtargetFeature flags so code can query a capability
(for example
ST.hasBFP16()in the backend, or#if __AIE_HAS_BFP16__in akernel) instead of hard-coding an arch number. It mirrors how AMDGPU already
models capability as a feature set rather than a level. It is the smallest
self-contained step in that direction and does not change codegen for existing
targets.
I wrote up the fuller reasoning, including how this lines up with AMD's own GPU
stack, here: https://atassis.ru/writing/amd-contract-first-e99255/
That is an outside suggestion and not an AMD position; this PR is just the
first concrete slice.
What changed
Backend:
AIEFeatures.tdwith two real SubtargetFeatures:FeatureBFP16(native block-floating-point multiply-accumulate) and
FeatureAcc2048(2048-bit accumulator register file). It is a set, not a level.
AIE2P.tdand add the two features to theaie2pProcessorModel feature list, which was previously empty.
aie2andaie2psare left as they were, so aie2ps deliberately does not gain bfp16. That is
what shows the set is not nested.
hasBFP16()andhasAcc2048()on the aie2psubtarget. I expose them through the standard
GET_SUBTARGETINFO_MACROexpansion in
AIE2PSubtarget.h, declaring the generated bits ahead of themembers that trigger
ParseSubtargetFeaturesso the default initializercannot clobber a parsed value.
Clang:
bfp16andacc2048on for the aie2p triple ininitFeatureMap, resolves any-target-featureoverride inhandleTargetFeatures, and emits__AIE_HAS_BFP16__/__AIE_HAS_ACC2048__from
getTargetDefines, the same shape as__AVX__on X86.hasFeaturereports the same bits.
What did not change
state; nothing in tree selects on them yet except the new test kernel, which
selects a path via the capability macro rather than an arch guard.
Testing
clang/test/Preprocessor/aie-capability-macros.c:__AIE_HAS_BFP16__isdefined for aie2p by default, absent when compiled with
-target-feature -bfp16, and absent for aie2ps. So the macro tracks the capability, not thetarget name, and the set is not nested.
clang/test/CodeGen/aie/aie2p/aie2p-capability-select.cc: a kernel selectsits multiply-accumulate path with
#if __AIE_HAS_BFP16__and no arch guard.It lowers to the native path by default and to the fallback when the feature
is turned off.