-
Notifications
You must be signed in to change notification settings - Fork 275
RISCV: Add vector psabi checking. #376
base: rvv-submission-v1
Are you sure you want to change the base?
RISCV: Add vector psabi checking. #376
Conversation
This patch adds support to check function's argument or return is vector type and throw warning if yes. gcc/ChangeLog: * config/riscv/riscv.cc (riscv_vector_psabi_warnning): (riscv_arg_has_vector): (riscv_pass_in_vector_p): (riscv_get_arg_info): gcc/testsuite/ChangeLog: * gcc.target/riscv/vector-abi-1.c: New test. * gcc.target/riscv/vector-abi-2.c: New test. * gcc.target/riscv/vector-abi-3.c: New test. * gcc.target/riscv/vector-abi-4.c: New test. * gcc.target/riscv/vector-abi-5.c: New test. Signed-off-by: Yanzhang Wang <[email protected]> Co-authored-by: Kito Cheng <[email protected]>
bc09437
to
2c68135
Compare
Not familiar with ABI. I think it's all kito's call :) |
gcc/config/riscv/riscv.cc
Outdated
if (type && riscv_arg_has_vector (type) && !warned) | ||
{ | ||
warning (OPT_Wpsabi, "ABI for the vector type is currently in experimental" | ||
"stage and may changes in the upcoming version of GCC."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will the message become something like in experimentalstage and ...
instead of in experimental stage and ...
after joining?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. You're right. Will modify it in the fix commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, thank you!
gcc/config/riscv/riscv.cc
Outdated
intrinsic vector type. Because we can't get the decl for the params. */ | ||
|
||
static bool | ||
riscv_arg_has_vector_size_attribute (const_tree type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
riscv_scalable_vector_type_p
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
gcc/config/riscv/riscv.cc
Outdated
if (!TYPE_P (TREE_TYPE (f))) | ||
break; | ||
|
||
/* If there's vector_size attribute, ignore it. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignore it if it's fixed length vector.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
gcc/config/riscv/riscv.cc
Outdated
|
||
/* If there's vector_size attribute, ignore it. */ | ||
if (VECTOR_TYPE_P (TREE_TYPE (f))) | ||
is_vector = !riscv_arg_has_vector_size_attribute (type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
riscv_arg_has_vector_size_attribute (TREE_TYPE (f))
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, you're right. It should be the field type.
gcc/config/riscv/riscv.cc
Outdated
tree size = TYPE_SIZE (type); | ||
if (size && TREE_CODE (size) == INTEGER_CST) | ||
return true; | ||
|
||
/* For the data type like vint32m1_t, the size code is POLY_INT_CST. */ | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return value should be inverted after function rename :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh understand. Could I know why the intrinsic vector type is named as scalable vector
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's the term defined in AArch64 SVE actually, and we follow to use that term in our backend too , e.g. riscv.cc:riscv_v_adjust_scalable_frame
gcc/config/riscv/riscv.cc
Outdated
|
||
if (type && riscv_arg_has_vector (type) && !warned) | ||
{ | ||
warning (OPT_Wpsabi, "ABI for the vector type is currently in " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vector
-> scalable vector
, that should more clear that it's exclude fixed length vector.
Hi @kito-cheng , The commit 51fbc2e tries to fix the warning on intrinsic APIs. I'm not sure whether it's a right solution ? I think the problem is we want to distinguish below 3 scenarios,
Both three will call But there's another new issue. When compiling with |
51fbc2e
to
a6c96b8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only one minor comment, you can go to mailing list after you address that :)
} CUMULATIVE_ARGS; | ||
|
||
/* Initialize a variable CUM of type CUMULATIVE_ARGS | ||
for a call to a function whose data type is FNTYPE. | ||
For a library call, FNTYPE is 0. */ | ||
|
||
void init_cumulative_args (CUMULATIVE_ARGS *, tree, rtx, tree, int); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to riscv_init_cumulative_args
and put into riscv-protos.h
.
This patch adds support to check function's argument or return is vector type and throw warning.
gcc/ChangeLog:
gcc/testsuite/ChangeLog: