This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Imply extensions in RISCVTargetInfo::initFeatureMap
ClosedPublic

Authored by eopXD on Nov 6 2021, 2:05 AM.

Details

Summary

Under ASTContext, clang only copies the features from the options with
Target->initFeatureMap, and no implications is done there. This makes
clang_cc1 fail to imply into zve32x for the vector extension, and test
cases will have to add -target-feature +experimental-zve32x in order
to work.

This patch fixes it.

Diff Detail

Event Timeline

eopXD created this revision.Nov 6 2021, 2:05 AM
eopXD requested review of this revision.Nov 6 2021, 2:05 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptNov 6 2021, 2:05 AM
eopXD retitled this revision from [Clang][RISCV] Let clang_cc1 be able to imply feautes to [RISCV] Let clang_cc1 be able to imply features.Nov 6 2021, 2:11 AM
eopXD edited the summary of this revision. (Show Details)
eopXD updated this revision to Diff 385256.Nov 6 2021, 3:01 AM

Rebase.

eopXD updated this revision to Diff 385258.Nov 6 2021, 3:10 AM

Rebase.

eopXD updated this revision to Diff 385275.Nov 6 2021, 7:40 AM

Rebase.

eopXD updated this revision to Diff 385277.Nov 6 2021, 7:49 AM

Rebase.

eopXD retitled this revision from [RISCV] Let clang_cc1 be able to imply features to [RISCV] Imply extensions in RISCVTargetInfo::initFeatureMap.Nov 7 2021, 1:45 AM
eopXD updated this revision to Diff 401525.Jan 19 2022, 11:58 PM

Rebase to latest main.

This patch needs to be landed before D112613 because clang_cc1 needs to do correct implication from v, zve32f, zve64f and zve64d and this patch fixes the issue.

kito-cheng accepted this revision.Jan 20 2022, 12:58 AM

Otherwise LGTM.

clang/lib/Basic/Targets/RISCV.cpp
235–236

Maybe update XLen based on the if condition? that might save one StringMap query.

unsigned XLen = 32;

if (getTriple().getArch() == llvm::Triple::riscv64) {
  Features["64bit"] = true;
  XLen = 64;
}
This revision is now accepted and ready to land.Jan 20 2022, 12:58 AM
eopXD updated this revision to Diff 401541.Jan 20 2022, 1:10 AM
eopXD marked an inline comment as done.

Update code based on @kito-cheng 's comment.

This revision was automatically updated to reflect the committed changes.

@eopXD, hi, this patch make us lost +relax and -save-restore by default, would you please fix it?

eopXD added a comment.Feb 11 2022, 4:04 AM

@eopXD, hi, this patch make us lost +relax and -save-restore by default, would you please fix it?

Sure, let me look into it.
Do you have an existing test case for your situation? (Or I will make one while fixing)