-
Notifications
You must be signed in to change notification settings - Fork 274
RISCV: Add vector psabi checking. #376
base: rvv-submission-v1
Are you sure you want to change the base?
Changes from 4 commits
2c68135
211f26b
1004381
f9bafb8
cb6ae98
33484c5
a6c96b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3728,6 +3728,75 @@ riscv_pass_fpr_pair (machine_mode mode, unsigned regno1, | |
GEN_INT (offset2)))); | ||
} | ||
|
||
/* Use the TYPE_SIZE to distinguish the type with vector_size attribute and | ||
intrinsic vector type. Because we can't get the decl for the params. */ | ||
|
||
static bool | ||
riscv_arg_has_vector_size_attribute (const_tree type) | ||
{ | ||
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 commentThe 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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
} | ||
|
||
static bool | ||
riscv_arg_has_vector (const_tree type) | ||
{ | ||
bool is_vector = false; | ||
|
||
switch (TREE_CODE (type)) | ||
{ | ||
case RECORD_TYPE: | ||
if (!COMPLETE_TYPE_P (type)) | ||
break; | ||
|
||
for (tree f = TYPE_FIELDS (type); f; f = DECL_CHAIN (f)) | ||
if (TREE_CODE (f) == FIELD_DECL) | ||
{ | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
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 commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, you're right. It should be the field type. |
||
else | ||
is_vector = riscv_arg_has_vector (TREE_TYPE (f)); | ||
} | ||
|
||
break; | ||
|
||
case VECTOR_TYPE: | ||
kito-cheng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
is_vector = !riscv_arg_has_vector_size_attribute (type); | ||
break; | ||
|
||
default: | ||
is_vector = false; | ||
break; | ||
} | ||
|
||
return is_vector; | ||
} | ||
|
||
/* Pass the type to check whether it's a vector type or contains vector type. | ||
Only check the value type and no checking for vector pointer type. */ | ||
|
||
static void | ||
riscv_pass_in_vector_p (const_tree type) | ||
{ | ||
static int warned = 0; | ||
yanzhang-dev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
"experimental stage and may changes in the upcoming version of " | ||
"GCC."); | ||
warned = 1; | ||
} | ||
} | ||
|
||
/* Fill INFO with information about a single argument, and return an | ||
RTL pattern to pass or return the argument. CUM is the cumulative | ||
state for earlier arguments. MODE is the mode of this argument and | ||
|
@@ -3812,6 +3881,9 @@ riscv_get_arg_info (struct riscv_arg_info *info, const CUMULATIVE_ARGS *cum, | |
} | ||
} | ||
|
||
/* Only check existing of vector type. */ | ||
riscv_pass_in_vector_p (type); | ||
|
||
/* Work out the size of the argument. */ | ||
num_bytes = type ? int_size_in_bytes (type) : GET_MODE_SIZE (mode).to_constant (); | ||
num_words = (num_bytes + UNITS_PER_WORD - 1) / UNITS_PER_WORD; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* { dg-do compile } */ | ||
/* { dg-options "-O0 -march=rv64gcv -mabi=lp64d" } */ | ||
|
||
#include "riscv_vector.h" | ||
|
||
void | ||
fun (vint32m1_t a) { } /* { dg-warning "the vector type" } */ | ||
|
||
void | ||
bar () | ||
{ | ||
vint32m1_t a; | ||
fun (a); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* { dg-do compile } */ | ||
/* { dg-options "-march=rv64gcv -mabi=lp64d" } */ | ||
|
||
#include "riscv_vector.h" | ||
|
||
vint32m1_t | ||
fun (vint32m1_t* a) { return *a; } /* { dg-warning "the vector type" } */ | ||
kito-cheng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
void | ||
bar () | ||
{ | ||
vint32m1_t a; | ||
fun (&a); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* { dg-do compile } */ | ||
/* { dg-options "-march=rv64gcv -mabi=lp64d" } */ | ||
|
||
#include "riscv_vector.h" | ||
|
||
vint32m1_t* | ||
fun (vint32m1_t* a) { return a; } /* { dg-bogus "the vector type" } */ | ||
|
||
void | ||
bar () | ||
{ | ||
vint32m1_t a; | ||
fun (&a); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* { dg-do compile } */ | ||
/* { dg-options "-march=rv64gcv -mabi=lp64d" } */ | ||
|
||
#include "riscv_vector.h" | ||
|
||
typedef int v4si __attribute__ ((vector_size (16))); | ||
|
||
v4si | ||
fun (v4si a) { return a; } /* { dg-bogus "the vector type" } */ | ||
|
||
void | ||
bar () | ||
{ | ||
v4si a; | ||
fun (a); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* { dg-do compile } */ | ||
/* { dg-options "-march=rv64gcv -mabi=lp64d" } */ | ||
|
||
typedef int v4si __attribute__ ((vector_size (16))); | ||
struct A { int a; v4si b; }; | ||
|
||
void | ||
fun (struct A a) {} /* { dg-bogus "the vector type" } */ | ||
|
||
void | ||
bar () | ||
{ | ||
struct A a; | ||
fun (a); | ||
} |
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.