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

Commit

Permalink
Add version control with patch e944b27
Browse files Browse the repository at this point in the history
  • Loading branch information
kito-cheng authored and WuSiYu committed May 17, 2021
1 parent 7617e74 commit f4ff3f3
Show file tree
Hide file tree
Showing 21 changed files with 403 additions and 86 deletions.
287 changes: 215 additions & 72 deletions gcc/common/config/riscv/riscv-common.c

Large diffs are not rendered by default.

17 changes: 16 additions & 1 deletion gcc/config.gcc
Original file line number Diff line number Diff line change
Expand Up @@ -4496,14 +4496,29 @@ case "${target}" in
;;

riscv*-*-*)
supported_defaults="abi arch tune riscv_attribute"
supported_defaults="abi arch tune riscv_attribute isa_spec"

case "${target}" in
riscv-* | riscv32*) xlen=32 ;;
riscv64*) xlen=64 ;;
*) echo "Unsupported RISC-V target ${target}" 1>&2; exit 1 ;;
esac

case "${with_isa_spec}" in
""|default|2.2)
tm_defines="${tm_defines} TARGET_DEFAULT_ISA_SPEC=ISA_SPEC_CLASS_2P2"
;;
20191213 | 201912)
tm_defines="${tm_defines} TARGET_DEFAULT_ISA_SPEC=ISA_SPEC_CLASS_20191213"
;;
20190608 | 201906)
tm_defines="${tm_defines} TARGET_DEFAULT_ISA_SPEC=ISA_SPEC_CLASS_20190608"
;;
*)
echo "--with-isa-spec only accept 2.2, 20191213, 201912, 20190608 or 201906" 1>&2
exit 1
esac

case "${with_riscv_attribute}" in
yes)
tm_defines="${tm_defines} TARGET_RISCV_ATTRIBUTE=1"
Expand Down
12 changes: 12 additions & 0 deletions gcc/config.in
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,18 @@
#endif


/* Define if your assembler supports -misa-spec=. */
#ifndef USED_FOR_TARGET
#undef HAVE_AS_MISA_SPEC
#endif


/* Define if your assembler supports -march=rv*_zifencei. */
#ifndef USED_FOR_TARGET
#undef HAVE_AS_MARCH_ZIFENCEI
#endif


/* Define if your assembler supports relocs needed by -fpic. */
#ifndef USED_FOR_TARGET
#undef HAVE_AS_SMALL_PIC_RELOCS
Expand Down
10 changes: 10 additions & 0 deletions gcc/config/riscv/riscv-opts.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ enum riscv_code_model {
};
extern enum riscv_code_model riscv_cmodel;

enum riscv_isa_spec_class {
ISA_SPEC_CLASS_NONE,

ISA_SPEC_CLASS_2P2,
ISA_SPEC_CLASS_20190608,
ISA_SPEC_CLASS_20191213
};

extern enum riscv_isa_spec_class riscv_isa_spec;

/* Keep this list in sync with define_attr "tune" in riscv.md. */
enum riscv_microarchitecture_type {
generic,
Expand Down
9 changes: 8 additions & 1 deletion gcc/config/riscv/riscv.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,20 @@ extern const char *riscv_default_mtune (int argc, const char **argv);
#define TARGET_64BIT (__riscv_xlen == 64)
#endif /* IN_LIBGCC2 */

#ifdef HAVE_AS_MISA_SPEC
#define ASM_MISA_SPEC "%{misa-spec=*}"
#else
#define ASM_MISA_SPEC ""
#endif

#undef ASM_SPEC
#define ASM_SPEC "\
%(subtarget_asm_debugging_spec) \
%{" FPIE_OR_FPIC_SPEC ":-fpic} \
%{march=*} \
%{mabi=*} \
%(subtarget_asm_spec)"
%(subtarget_asm_spec)" \
ASM_MISA_SPEC

#undef DRIVER_SELF_SPECS
#define DRIVER_SELF_SPECS \
Expand Down
23 changes: 23 additions & 0 deletions gcc/config/riscv/riscv.opt
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,26 @@ Enum(riscv_align_data) String(natural) Value(riscv_align_data_type_natural)

TargetVariable
int riscv_crypto_subext

TargetVariable
int riscv_bitmanip_subext

TargetVariable
int riscv_zi_subext

Enum
Name(isa_spec_class) Type(enum riscv_isa_spec_class)
Supported ISA specs (for use with the -misa-spec= option):

EnumValue
Enum(isa_spec_class) String(2.2) Value(ISA_SPEC_CLASS_2P2)

EnumValue
Enum(isa_spec_class) String(20190608) Value(ISA_SPEC_CLASS_20190608)

EnumValue
Enum(isa_spec_class) String(20191213) Value(ISA_SPEC_CLASS_20191213)

misa-spec=
Target Report RejectNegative Joined Enum(isa_spec_class) Var(riscv_isa_spec) Init(TARGET_DEFAULT_ISA_SPEC)
Set the version of RISC-V ISA spec.
62 changes: 62 additions & 0 deletions gcc/configure
Original file line number Diff line number Diff line change
Expand Up @@ -28107,6 +28107,68 @@ if test $gcc_cv_as_riscv_attribute = yes; then

$as_echo "#define HAVE_AS_RISCV_ATTRIBUTE 1" >>confdefs.h

fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for -misa-spec= support" >&5
$as_echo_n "checking assembler for -misa-spec= support... " >&6; }
if ${gcc_cv_as_riscv_isa_spec+:} false; then :
$as_echo_n "(cached) " >&6
else
gcc_cv_as_riscv_isa_spec=no
if test x$gcc_cv_as != x; then
$as_echo '' > conftest.s
if { ac_try='$gcc_cv_as $gcc_cv_as_flags -misa-spec=2.2 -o conftest.o conftest.s >&5'
{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
(eval $ac_try) 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; }
then
gcc_cv_as_riscv_isa_spec=yes
else
echo "configure: failed program was" >&5
cat conftest.s >&5
fi
rm -f conftest.o conftest.s
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_riscv_isa_spec" >&5
$as_echo "$gcc_cv_as_riscv_isa_spec" >&6; }
if test $gcc_cv_as_riscv_isa_spec = yes; then

$as_echo "#define HAVE_AS_MISA_SPEC 1" >>confdefs.h

fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for -march=rv32i_zifencei support" >&5
$as_echo_n "checking assembler for -march=rv32i_zifencei support... " >&6; }
if ${gcc_cv_as_riscv_march_zifencei+:} false; then :
$as_echo_n "(cached) " >&6
else
gcc_cv_as_riscv_march_zifencei=no
if test x$gcc_cv_as != x; then
$as_echo '' > conftest.s
if { ac_try='$gcc_cv_as $gcc_cv_as_flags -march=rv32i_zifencei -o conftest.o conftest.s >&5'
{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
(eval $ac_try) 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; }
then
gcc_cv_as_riscv_march_zifencei=yes
else
echo "configure: failed program was" >&5
cat conftest.s >&5
fi
rm -f conftest.o conftest.s
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_riscv_march_zifencei" >&5
$as_echo "$gcc_cv_as_riscv_march_zifencei" >&6; }
if test $gcc_cv_as_riscv_march_zifencei = yes; then

$as_echo "#define HAVE_AS_MARCH_ZIFENCEI 1" >>confdefs.h

fi

;;
Expand Down
10 changes: 10 additions & 0 deletions gcc/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -5088,6 +5088,16 @@ configured with --enable-newlib-nano-formatted-io.])
[.attribute stack_align,4],,
[AC_DEFINE(HAVE_AS_RISCV_ATTRIBUTE, 1,
[Define if your assembler supports .attribute.])])
gcc_GAS_CHECK_FEATURE([-misa-spec= support],
gcc_cv_as_riscv_isa_spec,,
[-misa-spec=2.2],,,
[AC_DEFINE(HAVE_AS_MISA_SPEC, 1,
[Define if the assembler understands -misa-spec=.])])
gcc_GAS_CHECK_FEATURE([-march=rv32i_zifencei support],
gcc_cv_as_riscv_march_zifencei,,
[-march=rv32i_zifencei],,,
[AC_DEFINE(HAVE_AS_MARCH_ZIFENCEI, 1,
[Define if the assembler understands -march=rv*_zifencei.])])
;;
s390*-*-*)
gcc_GAS_CHECK_FEATURE([.gnu_attribute support],
Expand Down
6 changes: 6 additions & 0 deletions gcc/testsuite/gcc.target/riscv/arch-10.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* { dg-do compile } */
/* { dg-options "-O2 -march=rv32gf2 -mabi=ilp32" } */
int foo()
{
}
/* { dg-error "Extension `f' appear more than one time." "" { target *-*-* } 0 } */
5 changes: 5 additions & 0 deletions gcc/testsuite/gcc.target/riscv/arch-11.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* { dg-do compile } */
/* { dg-options "-O2 -march=rv32g_zicsr2 -mabi=ilp32" } */
int foo()
{
}
6 changes: 6 additions & 0 deletions gcc/testsuite/gcc.target/riscv/arch-9.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* { dg-do compile } */
/* { dg-options "-O2 -march=rv32g2 -mabi=ilp32" } */
int foo()
{
}
/* { dg-warning "version of `g` will be omitted, please specify version for individual extension." "" { target *-*-* } 0 } */
2 changes: 1 addition & 1 deletion gcc/testsuite/gcc.target/riscv/attribute-11.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* { dg-do compile } */
/* { dg-options "-O -mriscv-attribute -march=rv32id -mabi=ilp32" } */
/* { dg-options "-O -mriscv-attribute -march=rv32id -mabi=ilp32 -misa-spec=2.2" } */
int foo()
{
}
Expand Down
2 changes: 1 addition & 1 deletion gcc/testsuite/gcc.target/riscv/attribute-12.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* { dg-do compile } */
/* { dg-options "-O -mriscv-attribute -march=rv32ifd -mabi=ilp32" } */
/* { dg-options "-O -mriscv-attribute -march=rv32ifd -mabi=ilp32 -misa-spec=2.2" } */
int foo()
{
}
Expand Down
2 changes: 1 addition & 1 deletion gcc/testsuite/gcc.target/riscv/attribute-13.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* { dg-do compile } */
/* { dg-options "-O -mriscv-attribute -march=rv32if3d -mabi=ilp32" } */
/* { dg-options "-O -mriscv-attribute -march=rv32if3d -mabi=ilp32 -misa-spec=2.2" } */
int foo()
{
}
Expand Down
6 changes: 6 additions & 0 deletions gcc/testsuite/gcc.target/riscv/attribute-14.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* { dg-do compile } */
/* { dg-options "-O -mriscv-attribute -march=rv32if -mabi=ilp32 -misa-spec=20190608" } */
int foo()
{
}
/* { dg-final { scan-assembler ".attribute arch, \"rv32i2p1_f2p2_zicsr2p0\"" } } */
6 changes: 6 additions & 0 deletions gcc/testsuite/gcc.target/riscv/attribute-15.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* { dg-do compile } */
/* { dg-options "-O -mriscv-attribute -march=rv32gc -mabi=ilp32 -misa-spec=2.2" } */
int foo()
{
}
/* { dg-final { scan-assembler ".attribute arch, \"rv32i2p0_m2p0_a2p0_f2p0_d2p0_c2p0\"" } } */
6 changes: 6 additions & 0 deletions gcc/testsuite/gcc.target/riscv/attribute-16.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* { dg-do compile } */
/* { dg-options "-O -mriscv-attribute -march=rv32gc -mabi=ilp32 -misa-spec=20190608" } */
int foo()
{
}
/* { dg-final { scan-assembler ".attribute arch, \"rv32i2p1_m2p0_a2p0_f2p2_d2p2_c2p0_zicsr2p0" } } */
6 changes: 6 additions & 0 deletions gcc/testsuite/gcc.target/riscv/attribute-17.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* { dg-do compile } */
/* { dg-options "-O -mriscv-attribute -march=rv32gc -mabi=ilp32 -misa-spec=20191213" } */
int foo()
{
}
/* { dg-final { scan-assembler ".attribute arch, \"rv32i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0" } } */
6 changes: 0 additions & 6 deletions gcc/testsuite/gcc.target/riscv/attribute-6.c

This file was deleted.

4 changes: 2 additions & 2 deletions gcc/testsuite/gcc.target/riscv/attribute-8.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* { dg-do compile } */
/* { dg-options "-O -mriscv-attribute -march=rv32i2p0xv5_xabc -mabi=ilp32" } */
/* { dg-options "-O -mriscv-attribute -march=rv32i2p0xabc_xv5 -mabi=ilp32" } */
int foo()
{
}
/* { dg-final { scan-assembler ".attribute arch, \"rv32i2p0_xv5p0_xabc2p0\"" } } */
/* { dg-final { scan-assembler ".attribute arch, \"rv32i2p0_xabc_xv5p0\"" } } */
2 changes: 1 addition & 1 deletion gcc/testsuite/gcc.target/riscv/attribute-9.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
int foo()
{
}
/* { dg-final { scan-assembler ".attribute arch, \"rv32i2p0_sabc2p0_xbar2p0\"" } } */
/* { dg-final { scan-assembler ".attribute arch, \"rv32i2p0_sabc_xbar\"" } } */

0 comments on commit f4ff3f3

Please sign in to comment.