Skip to content

Commit

Permalink
[EraVM][MC] Add tests for new instructions: tload, tstore, log.decommit
Browse files Browse the repository at this point in the history
Add MC tests for three new instructions: transient load/store and
decommit. These instructions are already defined in TableGen files and
can be emitted by the backend (see intrinsic.ll and transient.ll
tests inside llvm/tests/CodeGen/EraVM directory), so using the existing
mnemonic names for now.
  • Loading branch information
atrosinenko authored and asl committed May 22, 2024
1 parent 6114207 commit 4765984
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 5 deletions.
10 changes: 7 additions & 3 deletions llvm/test/MC/EraVM/asm-parser/misc.s
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
foo:

; mnemonics
precompile r3, r4, r5
log.decommit r3, r4, r5
precompile r3, r4, r5
context.this r3
context.caller r3
context.code_source r3
Expand All @@ -17,7 +18,8 @@ foo:
context.set_gas_per_pubdata r3

; modifiers (condition)
precompile.lt r3, r4, r5
log.decommit.lt r3, r4, r5
precompile.lt r3, r4, r5
context.this.lt r3
context.caller.lt r3
context.code_source.lt r3
Expand All @@ -34,7 +36,8 @@ foo:
; CHECK: .text
; CHECK:foo:

; CHECK: precompile r3, r4, r5
; CHECK: log.decommit r3, r4, r5
; CHECK: precompile r3, r4, r5
; CHECK: context.this r3
; CHECK: context.caller r3
; CHECK: context.code_source r3
Expand All @@ -46,6 +49,7 @@ foo:
; CHECK: context.inc_tx_num
; CHECK: context.set_gas_per_pubdata r3

; CHECK: log.decommit.lt r3, r4, r5
; CHECK: precompile.lt r3, r4, r5
; CHECK: context.this.lt r3
; CHECK: context.caller.lt r3
Expand Down
8 changes: 8 additions & 0 deletions llvm/test/MC/EraVM/asm-parser/storage.s
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,25 @@ foo:
; mnemonics
sload r3, r4
sstore r3, r4
tload r3, r4
tstore r3, r4

; modifiers (condition)
sload.lt r3, r4
sstore.lt r3, r4
tload.lt r3, r4
tstore.lt r3, r4

; COM: Autogenerated checks below, see README.md.
; CHECK: .text
; CHECK:foo:

; CHECK: sload r3, r4
; CHECK: sstore r3, r4
; CHECK: tload r3, r4
; CHECK: tstore r3, r4

; CHECK: sload.lt r3, r4
; CHECK: sstore.lt r3, r4
; CHECK: tload.lt r3, r4
; CHECK: tstore.lt r3, r4
4 changes: 3 additions & 1 deletion llvm/test/MC/EraVM/decoding/misc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# CHECK: .text

[0x00,0x00,0x00,0x00,0x05,0x43,0x04,0x45]
[0x00,0x00,0x00,0x00,0x05,0x43,0x04,0x20]
[0x00,0x00,0x00,0x00,0x03,0x00,0x04,0x10]
[0x00,0x00,0x00,0x00,0x03,0x00,0x04,0x11]
Expand All @@ -13,7 +14,8 @@
[0x00,0x00,0x00,0x00,0x03,0x00,0x04,0x13]
[0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x19]
[0x00,0x00,0x00,0x00,0x00,0x03,0x04,0x18]
# CHECK: precompile r3, r4, r5
# CHECK: log.decommit r3, r4, r5
# CHECK: precompile r3, r4, r5
# CHECK: context.this r3
# CHECK: context.caller r3
# CHECK: context.code_source r3
Expand Down
5 changes: 5 additions & 0 deletions llvm/test/MC/EraVM/decoding/storage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@
[0x00,0x00,0x00,0x00,0x00,0x43,0x04,0x1b]
# CHECK: sload r3, r4
# CHECK: sstore r3, r4

[0x00,0x00,0x00,0x00,0x04,0x03,0x04,0x46]
[0x00,0x00,0x00,0x00,0x00,0x43,0x04,0x47]
# CHECK: tload r3, r4
# CHECK: tstore r3, r4
4 changes: 3 additions & 1 deletion llvm/test/MC/EraVM/encoding/misc.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
.text
foo:

precompile r3, r4, r5
log.decommit r3, r4, r5
precompile r3, r4, r5
context.this r3
context.caller r3
context.code_source r3
Expand All @@ -18,6 +19,7 @@ foo:
; CHECK: .text
; CHECK:foo:

; CHECK: log.decommit r3, r4, r5 ; encoding: [0x00,0x00,0x00,0x00,0x05,0x43,0x04,0x45]
; CHECK: precompile r3, r4, r5 ; encoding: [0x00,0x00,0x00,0x00,0x05,0x43,0x04,0x20]
; CHECK: context.this r3 ; encoding: [0x00,0x00,0x00,0x00,0x03,0x00,0x04,0x10]
; CHECK: context.caller r3 ; encoding: [0x00,0x00,0x00,0x00,0x03,0x00,0x04,0x11]
Expand Down
6 changes: 6 additions & 0 deletions llvm/test/MC/EraVM/encoding/storage.s
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ foo:
sload r3, r4
sstore r3, r4

tload r3, r4
tstore r3, r4

; CHECK: .text
; CHECK:foo:

; CHECK: sload r3, r4 ; encoding: [0x00,0x00,0x00,0x00,0x04,0x03,0x04,0x1a]
; CHECK: sstore r3, r4 ; encoding: [0x00,0x00,0x00,0x00,0x00,0x43,0x04,0x1b]

; CHECK: tload r3, r4 ; encoding: [0x00,0x00,0x00,0x00,0x04,0x03,0x04,0x46]
; CHECK: tstore r3, r4 ; encoding: [0x00,0x00,0x00,0x00,0x00,0x43,0x04,0x47]

0 comments on commit 4765984

Please sign in to comment.