Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Commit

Permalink
fix: disable warning for intrinsic assign.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanzhang Wang committed May 8, 2023
1 parent 33484c5 commit 51fbc2e
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 14 deletions.
36 changes: 27 additions & 9 deletions gcc/config/riscv/riscv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3785,16 +3785,28 @@ riscv_arg_has_vector (const_tree type)
Only check the value type and no checking for vector pointer type. */

static void
riscv_pass_in_vector_p (const_tree type)
riscv_pass_in_vector_p (const tree type, bool pass_by_reference)
{
static int warned = 0;

if (type && riscv_arg_has_vector (type) && !warned)
if (type)
{
warning (OPT_Wpsabi, "ABI for the scalable vector type is currently in "
"experimental stage and may changes in the upcoming version of "
"GCC.");
warned = 1;

bool has_vector = false;

if (TREE_CODE (type) == POINTER_TYPE && pass_by_reference)
has_vector = riscv_arg_has_vector (TREE_TYPE (type));
else
has_vector = riscv_arg_has_vector (type);

if (has_vector && !warned)
{

warning (OPT_Wpsabi, "ABI for the scalable vector type is currently "
"in experimental stage and may changes in the upcoming "
"version of GCC.");
warned = 1;
}
}
}

Expand Down Expand Up @@ -3882,9 +3894,6 @@ 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;
Expand Down Expand Up @@ -3915,6 +3924,8 @@ riscv_function_arg (cumulative_args_t cum_v, const function_arg_info &arg)
if (arg.end_marker_p ())
return NULL;

riscv_pass_in_vector_p (arg.type, arg.pass_by_reference);

return riscv_get_arg_info (&info, cum, arg.mode, arg.type, arg.named, false);
}

Expand Down Expand Up @@ -3971,6 +3982,13 @@ riscv_function_value (const_tree type, const_tree func, machine_mode mode)
mode = promote_function_mode (type, mode, &unsigned_p, func, 1);
}

if (func && DECL_RESULT (func))
{
tree return_type = TREE_TYPE (DECL_RESULT (func));
riscv_pass_in_vector_p (const_cast<tree> (type),
TREE_CODE (return_type) != POINTER_TYPE);
}

memset (&args, 0, sizeof args);
return riscv_get_arg_info (&info, &args, mode, type, true, true);
}
Expand Down
3 changes: 2 additions & 1 deletion gcc/testsuite/gcc.target/riscv/vector-abi-1.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/* { dg-do compile } */
/* { dg-options "-O0 -march=rv64gcv -mabi=lp64d" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */

#include "riscv_vector.h"

void
fun (vint32m1_t a) { } /* { dg-warning "the vector type" } */
fun (vint32m1_t a) { } /* { dg-warning "the scalable vector type" } */

void
bar ()
Expand Down
3 changes: 2 additions & 1 deletion gcc/testsuite/gcc.target/riscv/vector-abi-2.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/* { dg-do compile } */
/* { dg-options "-march=rv64gcv -mabi=lp64d" } */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */

#include "riscv_vector.h"

vint32m1_t
fun (vint32m1_t* a) { return *a; } /* { dg-warning "the vector type" } */
fun (vint32m1_t* a) { return *a; } /* { dg-warning "the scalable vector type" } */

void
bar ()
Expand Down
2 changes: 1 addition & 1 deletion gcc/testsuite/gcc.target/riscv/vector-abi-3.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "riscv_vector.h"

vint32m1_t*
fun (vint32m1_t* a) { return a; } /* { dg-bogus "the vector type" } */
fun (vint32m1_t* a) { return a; } /* { dg-bogus "the scalable vector type" } */

void
bar ()
Expand Down
2 changes: 1 addition & 1 deletion gcc/testsuite/gcc.target/riscv/vector-abi-4.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
typedef int v4si __attribute__ ((vector_size (16)));

v4si
fun (v4si a) { return a; } /* { dg-bogus "the vector type" } */
fun (v4si a) { return a; } /* { dg-bogus "the scalable vector type" } */

void
bar ()
Expand Down
2 changes: 1 addition & 1 deletion gcc/testsuite/gcc.target/riscv/vector-abi-5.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ typedef int v4si __attribute__ ((vector_size (16)));
struct A { int a; v4si b; };

void
fun (struct A a) {} /* { dg-bogus "the vector type" } */
fun (struct A a) {} /* { dg-bogus "the scalable vector type" } */

void
bar ()
Expand Down
20 changes: 20 additions & 0 deletions gcc/testsuite/gcc.target/riscv/vector-abi-6.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* { dg-do compile } */
/* { dg-options "-march=rv64gcv -mabi=lp64d" } */
#include "riscv_vector.h"

void
foo(int32_t *in1, int32_t *in2, int32_t *in3, int32_t *out,
size_t n, int cond) {
size_t vl;
if (cond)
vl = __riscv_vsetvlmax_e32m1();
else
vl = __riscv_vsetvlmax_e16mf2();
for (size_t i = 0; i < n; i += 1)
{
vint32m1_t a = __riscv_vle32_v_i32m1(in1, vl); /* { dg-bogus "the scalable vector type" } */
vint32m1_t b = __riscv_vle32_v_i32m1_tu(a, in2, vl);
vint32m1_t c = __riscv_vle32_v_i32m1_tu(b, in3, vl);
__riscv_vse32_v_i32m1(out, c, vl);
}
}

0 comments on commit 51fbc2e

Please sign in to comment.