Skip to content

Commit bbac553

Browse files
dongyasunNelson Chu
authored andcommitted
RISC-V: Add zilsd & zclsd support
Ref: https://github.com/riscv/riscv-zilsd/blob/main/zilsd.adoc Signed-off-by: dysun <[email protected]> Co-developed-by: LIU Xu <[email protected]> Co-developed-by: ZHAO Fujin <[email protected]>
1 parent b892db3 commit bbac553

File tree

12 files changed

+215
-1
lines changed

12 files changed

+215
-1
lines changed

bfd/elfxx-riscv.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,6 +1239,7 @@ static struct riscv_implicit_subset riscv_implicit_subsets[] =
12391239

12401240
{"zicfilp", "+zicsr", check_implicit_always},
12411241
{"zicfiss", "+zimop,+zicsr", check_implicit_always},
1242+
{"zclsd", "+zca,+zilsd", check_implicit_always},
12421243

12431244
{"sha", "+h,+ssstateen,+shcounterenw,+shvstvala,+shtvala,+shvstvecd,+shvsatpa,+shgatpa", check_implicit_always},
12441245

@@ -1382,6 +1383,7 @@ static struct riscv_supported_ext riscv_supported_std_z_ext[] =
13821383
{"zimop", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
13831384
{"zicfiss", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
13841385
{"zicfilp", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
1386+
{"zilsd", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
13851387
{"zmmul", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
13861388
{"za64rs", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
13871389
{"za128rs", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
@@ -1462,6 +1464,7 @@ static struct riscv_supported_ext riscv_supported_std_z_ext[] =
14621464
{"zcmop", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
14631465
{"zcmp", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
14641466
{"zcmt", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
1467+
{"zclsd", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
14651468
{NULL, 0, 0, 0, 0}
14661469
};
14671470

@@ -2158,6 +2161,15 @@ riscv_parse_check_conflicts (riscv_parse_subset_t *rps)
21582161
(_("`xtheadvector' is conflict with the `v' extension"));
21592162
no_conflict = false;
21602163
}
2164+
if (riscv_lookup_subset (rps->subset_list, "zclsd", &subset)
2165+
&& ((riscv_lookup_subset (rps->subset_list, "c", &subset)
2166+
&& riscv_lookup_subset (rps->subset_list, "f", &subset))
2167+
|| riscv_lookup_subset (rps->subset_list, "zcf", &subset)))
2168+
{
2169+
rps->error_handler
2170+
(_("`zclsd' is conflict with the `c+f'/ `zcf' extension"));
2171+
no_conflict = false;
2172+
}
21612173
if (riscv_lookup_subset (rps->subset_list, "ssnpm", &subset) && xlen != 64)
21622174
{
21632175
rps->error_handler (_ ("rv%d does not support the `ssnpm' extension"),
@@ -2826,6 +2838,10 @@ riscv_multi_subset_supports (riscv_parse_subset_t *rps,
28262838
case INSN_CLASS_SMCTR_OR_SSCTR:
28272839
return (riscv_subset_supports (rps, "smctr")
28282840
|| riscv_subset_supports (rps, "ssctr"));
2841+
case INSN_CLASS_ZILSD:
2842+
return riscv_subset_supports (rps, "zilsd");
2843+
case INSN_CLASS_ZCLSD:
2844+
return riscv_subset_supports (rps, "zclsd");
28292845
case INSN_CLASS_SMRNMI:
28302846
return riscv_subset_supports (rps, "smrnmi");
28312847
case INSN_CLASS_SVINVAL:
@@ -3143,6 +3159,10 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps,
31433159
return "zcmt";
31443160
case INSN_CLASS_SMCTR_OR_SSCTR:
31453161
return _("smctr' or `ssctr");
3162+
case INSN_CLASS_ZILSD:
3163+
return "zilsd";
3164+
case INSN_CLASS_ZCLSD:
3165+
return "zclsd";
31463166
case INSN_CLASS_SMRNMI:
31473167
return "smrnmi";
31483168
case INSN_CLASS_SVINVAL:
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#as: -march=rv32i_zilsd
2+
#name: Lx/Sx macro insns for Zilsd
3+
#source: l-s-macro.s
4+
#objdump: -dwr
5+
6+
.*:[ ]+file format .*
7+
8+
9+
Disassembly of section .text:
10+
11+
0+ <L>:
12+
[ ]+[0-9a-f]+:[ ]+00000517[ ]+auipc[ ]+a0,0x0[ ]+[0-9a-f]+:[ ]+R_RISCV_PCREL_HI20[ ]+bval
13+
[ ]+[0-9a-f]+:[ ]+R_RISCV_RELAX.*
14+
[ ]+[0-9a-f]+:[ ]+00050503[ ]+lb[ ]+a0,0\(a0\) # [0-9a-f]+( <.*>)?[ ]+[0-9a-f]+:[ ]+R_RISCV_PCREL_LO12_I[ ]+.*
15+
[ ]+[0-9a-f]+:[ ]+R_RISCV_RELAX.*
16+
[ ]+[0-9a-f]+:[ ]+00000517[ ]+auipc[ ]+a0,0x0[ ]+[0-9a-f]+:[ ]+R_RISCV_PCREL_HI20[ ]+bval
17+
[ ]+[0-9a-f]+:[ ]+R_RISCV_RELAX.*
18+
[ ]+[0-9a-f]+:[ ]+00054503[ ]+lbu[ ]+a0,0\(a0\) # [0-9a-f]+( <.*>)?[ ]+[0-9a-f]+:[ ]+R_RISCV_PCREL_LO12_I[ ]+.*
19+
[ ]+[0-9a-f]+:[ ]+R_RISCV_RELAX.*
20+
[ ]+[0-9a-f]+:[ ]+00000517[ ]+auipc[ ]+a0,0x0[ ]+[0-9a-f]+:[ ]+R_RISCV_PCREL_HI20[ ]+hval
21+
[ ]+[0-9a-f]+:[ ]+R_RISCV_RELAX.*
22+
[ ]+[0-9a-f]+:[ ]+00051503[ ]+lh[ ]+a0,0\(a0\) # [0-9a-f]+( <.*>)?[ ]+[0-9a-f]+:[ ]+R_RISCV_PCREL_LO12_I[ ]+.*
23+
[ ]+[0-9a-f]+:[ ]+R_RISCV_RELAX.*
24+
[ ]+[0-9a-f]+:[ ]+00000517[ ]+auipc[ ]+a0,0x0[ ]+[0-9a-f]+:[ ]+R_RISCV_PCREL_HI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_RELAX.*
42+
[ ]+[0-9a-f]+:[ ]+00000297[ ]+auipc[ ]+t0,0x0[ ]+[0-9a-f]+:[ ]+R_RISCV_PCREL_HI20[ ]+hval
43+
[ ]+[0-9a-f]+:[ ]+R_RISCV_RELAX.*
44+
[ ]+[0-9a-f]+:[ ]+00a29023[ ]+sh[ ]+a0,0\(t0\) # [0-9a-f]+( <.*>)?[ ]+[0-9a-f]+:[ ]+R_RISCV_PCREL_LO12_S[ ]+.*
45+
[ ]+[0-9a-f]+:[ ]+R_RISCV_RELAX.*
46+
[ ]+[0-9a-f]+:[ ]+00000297[ ]+auipc[ ]+t0,0x0[ ]+[0-9a-f]+:[ ]+R_RISCV_PCREL_HI20[ ]+wval
47+
[ ]+[0-9a-f]+:[ ]+R_RISCV_RELAX.*
48+
[ ]+[0-9a-f]+:[ ]+00a2a023[ ]+sw[ ]+a0,0\(t0\) # [0-9a-f]+( <.*>)?[ ]+[0-9a-f]+:[ ]+R_RISCV_PCREL_LO12_S[ ]+.*
49+
[ ]+[0-9a-f]+:[ ]+R_RISCV_RELAX.*
50+
[ ]+[0-9a-f]+:[ ]+00000297[ ]+auipc[ ]+t0,0x0[ ]+[0-9a-f]+:[ ]+R_RISCV_PCREL_HI20[ ]+dval
51+
[ ]+[0-9a-f]+:[ ]+R_RISCV_RELAX.*
52+
[ ]+[0-9a-f]+:[ ]+00a2b023[ ]+sd[ ]+a0,0\(t0\) # [0-9a-f]+( <.*>)?[ ]+[0-9a-f]+:[ ]+R_RISCV_PCREL_LO12_S[ ]+.*
53+
[ ]+[0-9a-f]+:[ ]+R_RISCV_RELAX.*

gas/testsuite/gas/riscv/l-s-macro.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#as: -march=rv64i
1+
#as: -march=rv64i -defsym __64_bit__=1
22
#name: Lx/Sx macro insns
33
#objdump: -dwr
44

gas/testsuite/gas/riscv/l-s-macro.s

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ L:
44
lh a0, hval
55
lhu a0, hval
66
lw a0, wval
7+
.ifdef __64_bit__
78
lwu a0, wval
9+
.endif
810
ld a0, dval
911

1012
S:

gas/testsuite/gas/riscv/march-help.l

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ All available -march extensions for RISC-V:
2828
zimop 1.0
2929
zicfiss 1.0
3030
zicfilp 1.0
31+
zilsd 1.0
3132
zmmul 1.0
3233
za64rs 1.0
3334
za128rs 1.0
@@ -108,6 +109,7 @@ All available -march extensions for RISC-V:
108109
zcmop 1.0
109110
zcmp 1.0
110111
zcmt 1.0
112+
zclsd 1.0
111113
sha 1.0
112114
shcounterenw 1.0
113115
shgatpa 1.0
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#as: -march=rv32ima_zilsd_zclsd
2+
#source: zilsd-zclsd-fail.s
3+
#error_output: zilsd-zclsd-fail.l
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.*: Assembler messages:
2+
.*: Error: illegal operands `ld x7,\(x5\)'
3+
.*: Error: illegal operands `ld x9,8\(x11\)'
4+
.*: Error: illegal operands `ld x13,16\(x16\)'
5+
.*: Error: illegal operands `sd x7,\(x5\)'
6+
.*: Error: illegal operands `sd x9,8\(x11\)'
7+
.*: Error: illegal operands `sd x13,16\(x16\)'
8+
.*: Error: illegal operands `c.ld x11,\(x9\)'
9+
.*: Error: illegal operands `c.ld x13,\(x16\)'
10+
.*: Error: illegal operands `c.ldsp x0,\(x2\)'
11+
.*: Error: illegal operands `c.ldsp x11,\(x2\)'
12+
.*: Error: illegal operands `c.sd x11,\(x9\)'
13+
.*: Error: illegal operands `c.sd x13,\(x16\)'
14+
.*: Error: illegal operands `c.sdsp x11,\(x2\)'
15+
.*: Error: illegal operands `c.sdsp x13,8\(x2\)'
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
target:
2+
ld x7, (x5)
3+
ld x9, 8(x11)
4+
ld x13, 16(x16)
5+
sd x7, (x5)
6+
sd x9, 8(x11)
7+
sd x13, 16(x16)
8+
c.ld x11, (x9)
9+
c.ld x13, (x16)
10+
c.ldsp x0, (x2)
11+
c.ldsp x11, (x2)
12+
c.sd x11, (x9)
13+
c.sd x13, (x16)
14+
c.sdsp x11, (x2)
15+
c.sdsp x13, 8(x2)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#as: -march=rv32ima_zilsd_zclsd
2+
#source: zilsd-zclsd.s
3+
#objdump: -d -Mno-aliases
4+
5+
.*:[ ]+file format .*
6+
7+
8+
Disassembly of section .text:
9+
10+
0+000 <target>:
11+
[ ]+0:[ ]+0007b303[ ]+ld[ ]+t1,0\(a5\)
12+
[ ]+4:[ ]+00883903[ ]+ld[ ]+s2,8\(a6\)
13+
[ ]+8:[ ]+0105ba03[ ]+ld[ ]+s4,16\(a1\)
14+
[ ]+c:[ ]+0067b023[ ]+sd[ ]+t1,0\(a5\)
15+
[ ]+10:[ ]+01283423[ ]+sd[ ]+s2,8\(a6\)
16+
[ ]+14:[ ]+0145b823[ ]+sd[ ]+s4,16\(a1\)
17+
[ ]+18:[ ]+6380[ ]+c.ld[ ]+s0,0\(a5\)
18+
[ ]+1a:[ ]+6408[ ]+c.ld[ ]+a0,8\(s0\)
19+
[ ]+1c:[ ]+6a90[ ]+c.ld[ ]+a2,16\(a3\)
20+
[ ]+1e:[ ]+e380[ ]+c.sd[ ]+s0,0\(a5\)
21+
[ ]+20:[ ]+e408[ ]+c.sd[ ]+a0,8\(s0\)
22+
[ ]+22:[ ]+ea90[ ]+c.sd[ ]+a2,16\(a3\)
23+
[ ]+24:[ ]+6122[ ]+c.ldsp[ ]+sp,8\(sp\)
24+
[ ]+26:[ ]+652a[ ]+c.ldsp[ ]+a0,136\(sp\)
25+
[ ]+28:[ ]+7f7e[ ]+c.ldsp[ ]+t5,504\(sp\)
26+
[ ]+2a:[ ]+e002[ ]+c.sdsp[ ]+zero,0\(sp\)
27+
[ ]+2c:[ ]+e40a[ ]+c.sdsp[ ]+sp,8\(sp\)
28+
[ ]+2e:[ ]+e52a[ ]+c.sdsp[ ]+a0,136\(sp\)
29+
[ ]+30:[ ]+fffa[ ]+c.sdsp[ ]+t5,504\(sp\)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
target:
2+
ld x6, (x15)
3+
ld x18, 8(x16)
4+
ld x20, 16(x11)
5+
sd x6, (x15)
6+
sd x18, 8(x16)
7+
sd x20, 16(x11)
8+
c.ld x8, (x15)
9+
c.ld x10, 8(x8)
10+
c.ld x12, 16(x13)
11+
c.sd x8, (x15)
12+
c.sd x10, 8(x8)
13+
c.sd x12, 16(x13)
14+
c.ldsp x2, 8(sp)
15+
c.ldsp x10, 136(sp)
16+
c.ldsp x30, 504(sp)
17+
c.sdsp x0, (sp)
18+
c.sdsp x2, 8(sp)
19+
c.sdsp x10, 136(sp)
20+
c.sdsp x30, 504(sp)

0 commit comments

Comments
 (0)