Skip to content

Commit 3dfd0fe

Browse files
authored
feat(data): Add a few missing pseudoinstructions (#717)
1 parent 9659790 commit 3dfd0fe

22 files changed

+99
-20
lines changed

arch/inst/I/addi.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ access:
2222
vs: always
2323
vu: always
2424
data_independent_timing: true
25+
pseudoinstructions:
26+
- when: (xd == 0 && xs1 == 0 && imm == 0)
27+
to: nop
28+
- when: imm == 0
29+
to: mv xd,xs1
2530
operation(): X[xd] = X[xs1] + $signed(imm);
2631

2732
# SPDX-SnippetBegin

arch/inst/I/addiw.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ access:
2323
vs: always
2424
vu: always
2525
data_independent_timing: true
26+
pseudoinstructions:
27+
- when: imm == 0
28+
to: sext.w xd,xs1
2629
operation(): |
2730
XReg operand = sext(X[xs1], 31);
2831
X[xd] = sext(operand + imm, 31);

arch/inst/I/andi.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ access:
2222
vs: always
2323
vu: always
2424
data_independent_timing: true
25+
pseudoinstructions:
26+
- when: imm == 255
27+
to: zext.b
2528
operation(): X[xd] = X[xs1] & $signed(imm);
2629

2730
# SPDX-SnippetBegin

arch/inst/I/beq.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ access:
2626
u: always
2727
vs: always
2828
vu: always
29+
pseudoinstructions:
30+
- when: xs2 == 0
31+
to: beqz xs1,imm
2932
operation(): |
3033
XReg lhs = X[xs1];
3134
XReg rhs = X[xs2];

arch/inst/I/bge.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ access:
2626
u: always
2727
vs: always
2828
vu: always
29+
pseudoinstructions:
30+
- when: xs1 == 0
31+
to: blez xs2,imm
32+
- when: xs2 == 0
33+
to: blez xs1,imm
2934
operation(): |
3035
XReg lhs = X[xs1];
3136
XReg rhs = X[xs2];

arch/inst/I/blt.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ access:
2626
u: always
2727
vs: always
2828
vu: always
29+
pseudoinstructions:
30+
- when: xs2 == 0
31+
to: bltz xs1,imm
32+
- when: xs1 == 0
33+
to: bgtz xs2,imm
2934
operation(): |
3035
XReg lhs = X[xs1];
3136
XReg rhs = X[xs2];

arch/inst/I/bne.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ access:
2626
u: always
2727
vs: always
2828
vu: always
29+
pseudoinstructions:
30+
- when: xs2 == 0
31+
to: bnez xs1,imm
2932
operation(): |
3033
XReg lhs = X[xs1];
3134
XReg rhs = X[xs2];

arch/inst/I/fence.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ hints:
198198
pseudoinstructions:
199199
- when: (pred == 1) && (succ == 0) && (xd == 0) && (xs1 == 0)
200200
to: pause
201+
- when: (pred == 4'b1111) && (succ == 4'b1111)
202+
to: fence # fence => fence iorw,iorw
201203

202204
# SPDX-SnippetBegin
203205
# SPDX-FileCopyrightText: 2017-2025 Contributors to the RISCV Sail Model <https://github.com/riscv/sail-riscv/blob/master/LICENCE>

arch/inst/I/jal.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ access:
2323
u: always
2424
vs: always
2525
vu: always
26+
pseudoinstructions:
27+
- when: imm == 0
28+
to: j xd
29+
- when: xd == x1
30+
to: jal imm
2631
operation(): |
2732
XReg retrun_addr = $pc + 4;
2833

arch/inst/I/jalr.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ access:
2525
u: always
2626
vs: always
2727
vu: always
28+
pseudoinstructions:
29+
- when: xd == 0
30+
to: jr imm(xs1)
31+
- when: (rd == 0 && xs1 == x1 && imm == 0)
32+
to: ret
2833
operation(): |
2934
XReg returnaddr;
3035
returnaddr = $pc + 4;

0 commit comments

Comments
 (0)