Skip to content

Commit ad5fefd

Browse files
committed
Zcmp extension: review comments and bugfix (spimm support fix)
Signed-off-by: Albert Yosher <[email protected]>
1 parent 9019654 commit ad5fefd

File tree

4 files changed

+8
-44
lines changed

4 files changed

+8
-44
lines changed

arch/inst/Zcmp/cm.pop.yaml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@ long_name: Destroy function call stack frame
77
description: |
88
Destroy stack frame: load `ra` and 0 to 12 saved registers from the stack frame, deallocate the stack frame.
99
This instruction pops (loads) the registers in `reg_list` from stack memory, and then adjusts the stack pointer by `stack_adj`.
10-
--
11-
12-
Stack Adjustment Calculation:
13-
14-
--
15-
`stack_adj_base` is the minimum number of bytes, in multiples of 16-byte address increments, required to cover the registers in the list.
16-
`spimm` is the number of additional 16-byte address increments allocated for the stack frame.
17-
The total stack adjustment represents the total size of the stack frame, which is `stack_adj_base` added to `spimm` scaled by 16, as defined above.
18-
--
1910
2011
Restrictions on stack_adj:
2112
@@ -35,6 +26,7 @@ encoding:
3526
not: [0, 1, 2, 3]
3627
- name: spimm
3728
location: 3-2
29+
left_shift: 4
3830
access:
3931
s: always
4032
u: always
@@ -47,10 +39,9 @@ operation(): |
4739
4840
XReg size = xlen();
4941
XReg nreg = (rlist == 15) ? 13 : (rlist - 3);
50-
XReg stack_additional_adj = (spimm * 16);
5142
XReg stack_aligned_adj = (nreg * 4 + 15) & ~0xF;
5243
XReg virtual_address_sp = X[2];
53-
XReg virtual_address_new_sp = virtual_address_sp + stack_aligned_adj + stack_additional_adj;
44+
XReg virtual_address_new_sp = virtual_address_sp + stack_aligned_adj + spimm;
5445
XReg virtual_address_base = virtual_address_new_sp - (nreg * size);
5546
5647
X[ 1] = read_memory_xlen(virtual_address_base + 0*size, $encoding);

arch/inst/Zcmp/cm.popret.yaml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@ long_name: Destroy function call stack frame and return to `ra`.
77
description: |
88
Destroy stack frame: load `ra` and 0 to 12 saved registers from the stack frame, deallocate the stack frame, return to `ra`.
99
This instruction pops (loads) the registers in `reg_list` from stack memory, and then adjusts the stack pointer by `stack_adj` and then return to `ra`.
10-
--
11-
12-
Stack Adjustment Calculation:
13-
14-
--
15-
`stack_adj_base` is the minimum number of bytes, in multiples of 16-byte address increments, required to cover the registers in the list.
16-
`spimm` is the number of additional 16-byte address increments allocated for the stack frame.
17-
The total stack adjustment represents the total size of the stack frame, which is `stack_adj_base` added to `spimm` scaled by 16, as defined above.
18-
--
1910
2011
Restrictions on stack_adj:
2112
@@ -35,6 +26,7 @@ encoding:
3526
not: [0, 1, 2, 3]
3627
- name: spimm
3728
location: 3-2
29+
left_shift: 4
3830
access:
3931
s: always
4032
u: always
@@ -47,10 +39,9 @@ operation(): |
4739
4840
XReg size = xlen();
4941
XReg nreg = (rlist == 15) ? 13 : (rlist - 3);
50-
XReg stack_additional_adj = (spimm * 16);
5142
XReg stack_aligned_adj = (nreg * 4 + 15) & ~0xF;
5243
XReg virtual_address_sp = X[2];
53-
XReg virtual_address_new_sp = virtual_address_sp + stack_aligned_adj + stack_additional_adj;
44+
XReg virtual_address_new_sp = virtual_address_sp + stack_aligned_adj + spimm;
5445
XReg virtual_address_base = virtual_address_new_sp - (nreg * size);
5546
5647
X[ 1] = read_memory_xlen(virtual_address_base + 0*size, $encoding);

arch/inst/Zcmp/cm.popretz.yaml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@ long_name: Destroy function call stack frame, move zero to `a0` and return to `r
77
description: |
88
Destroy stack frame: load `ra` and 0 to 12 saved registers from the stack frame, deallocate the stack frame, move zero to `a0`, return to `ra`.
99
This instruction pops (loads) the registers in `reg_list` from stack memory, and then adjusts the stack pointer by `stack_adj`, move zero to `a0` and then return to `ra`.
10-
--
11-
12-
Stack Adjustment Calculation:
13-
14-
--
15-
`stack_adj_base` is the minimum number of bytes, in multiples of 16-byte address increments, required to cover the registers in the list.
16-
`spimm` is the number of additional 16-byte address increments allocated for the stack frame.
17-
The total stack adjustment represents the total size of the stack frame, which is `stack_adj_base` added to `spimm` scaled by 16, as defined above.
18-
--
1910
2011
Restrictions on stack_adj:
2112
@@ -35,6 +26,7 @@ encoding:
3526
not: [0, 1, 2, 3]
3627
- name: spimm
3728
location: 3-2
29+
left_shift: 4
3830
access:
3931
s: always
4032
u: always
@@ -47,10 +39,9 @@ operation(): |
4739
4840
XReg size = xlen();
4941
XReg nreg = (rlist == 15) ? 13 : (rlist - 3);
50-
XReg stack_additional_adj = (spimm * 16);
5142
XReg stack_aligned_adj = (nreg * 4 + 15) & ~0xF;
5243
XReg virtual_address_sp = X[2];
53-
XReg virtual_address_new_sp = virtual_address_sp + stack_aligned_adj + stack_additional_adj;
44+
XReg virtual_address_new_sp = virtual_address_sp + stack_aligned_adj + spimm;
5445
XReg virtual_address_base = virtual_address_new_sp - (nreg * size);
5546
5647
X[ 1] = read_memory_xlen(virtual_address_base + 0*size, $encoding);

arch/inst/Zcmp/cm.push.yaml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,6 @@ description: |
1010
and then creates the stack frame by decrementing the stack pointer by `stack_adj`,
1111
including any additional stack space requested by the value of `spimm`.
1212
The `spimm` could be 0, 1, 2 or 3 corresponding to additional stack allocated size of 0, 16, 32 or 48 bytes.
13-
--
14-
15-
Stack Adjustment Calculation:
16-
17-
--
18-
`stack_adj_base` is the minimum number of bytes, in multiples of 16-byte address increments, required to cover the registers in the list.
19-
`spimm` is the number of additional 16-byte address increments allocated for the stack frame.
20-
The total stack adjustment represents the total size of the stack frame, which is `stack_adj_base` added to `spimm` scaled by 16, as defined above.
21-
--
2213
2314
Restrictions on stack_adj:
2415
@@ -38,6 +29,7 @@ encoding:
3829
not: [0, 1, 2, 3]
3930
- name: spimm
4031
location: 3-2
32+
left_shift: 4
4133
access:
4234
s: always
4335
u: always
@@ -50,10 +42,9 @@ operation(): |
5042
5143
XReg size = xlen();
5244
XReg nreg = (rlist == 15) ? 13 : (rlist - 3);
53-
XReg stack_additional_adj = (spimm * 16);
5445
XReg stack_aligned_adj = (nreg * 4 + 15) & ~0xF;
5546
XReg virtual_address_sp = X[2];
56-
XReg virtual_address_new_sp = virtual_address_sp - stack_aligned_adj - stack_additional_adj;
47+
XReg virtual_address_new_sp = virtual_address_sp - stack_aligned_adj - spimm;
5748
XReg virtual_address_base = virtual_address_sp - (nreg * size);
5849
5950
write_memory_xlen(virtual_address_base + 0*size, X[ 1], $encoding);

0 commit comments

Comments
 (0)