This is an archive of the discontinued LLVM Phabricator instance.

[Clang][RISCV] Guard vector float16 type correctly with semantic analysis
ClosedPublic

Authored by eopXD on Feb 9 2023, 8:13 AM.

Details

Summary

Before this commit, vector float 16 types (e.g. vfloat16m1_t) of RVV
is only defined when extension zvfh is defined. However this
generate inaccurate diagnostics like:

error: unknown type name 'vfloat16m1_t'

This commit improves the compiler by guarding type check correctly
under semantic analysis.

Diff Detail

Event Timeline

eopXD created this revision.Feb 9 2023, 8:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 9 2023, 8:13 AM
eopXD requested review of this revision.Feb 9 2023, 8:13 AM
eopXD retitled this revision from [Clang][RISCV] Guard vector float16 type correctly under Sema to [Clang][RISCV] Guard vector float16 type correctly with semantic analysis.Feb 9 2023, 8:16 AM

Are you going to do f32, f64, and i64 as well?

eopXD added a comment.Feb 9 2023, 8:41 AM

Are you going to do f32, f64, and i64 as well?

Yes, going to add them once this commit lands.

eopXD added a comment.Feb 9 2023, 9:30 AM

Forward declaration (snippet below) is still allowed after this commit.

#include <riscv_vector.h>

vfloat16m1_t foo();

I see the same behavior under https://github.com/llvm/llvm-project/blob/main/clang/test/Sema/x86_64-no-x87.cpp. If I add type check under SemaDecl.cpp::Sema::ActOnFunctionDeclarator, the compiler will emit repeating warning for the same function. Currently I don't know what is the best fix for this.

eopXD updated this revision to Diff 496160.Feb 9 2023, 9:45 AM

Update code: rename error for vector support, remove dead code under SemaRISCVVectorLoopup.cpp

eopXD updated this revision to Diff 496183.Feb 9 2023, 10:54 AM

Update code: check for experimental-zvfh instead of zvfh.

eopXD updated this revision to Diff 496311.Feb 9 2023, 6:52 PM

Update code based on comments from Craig.

eopXD updated this revision to Diff 496382.Feb 10 2023, 1:48 AM

Update code: use a more scalable way to check for RVV type.

craig.topper added inline comments.Feb 10 2023, 9:29 PM
clang/lib/Sema/Sema.cpp
2045

experimental- is an internal naming scheme. "experimental-" is not used in -march so it should be in the error message.

eopXD updated this revision to Diff 496680.Feb 11 2023, 5:28 AM

Address comment from Craig.

eopXD marked an inline comment as done.Feb 11 2023, 5:28 AM
This revision is now accepted and ready to land.Feb 13 2023, 1:15 PM
This revision was landed with ongoing or failed builds.Feb 13 2023, 6:07 PM
This revision was automatically updated to reflect the committed changes.