Skip to content

Commit 7f8ac50

Browse files
vberbenets-sckv-sc
authored andcommitted
[snippy] memory initialization support
Use the -init-memory= option to initialize memory. Along with it, you must also provide the -init-regs-in-elf option. Possible values of -init-memory= are: 1. no - not initialize memory 2. full - initialize all RW sections from the layout with random values 3. full-with-addresses - add sections initialized with the addresses you specify here to the output .elf file 4. runtile - use the initialization function. The RW sections will be marked as NOLOAD and the initialization function will be called in runtime to initialize the data section. 5. loads – This setting is similar to runtime, but it only initializes the addresses that were accessed in the program. 6. loads-with-addresses – This setting is similar to loads, but it only initializes legal addresses from the scheme. 7. ascii-file – initialize memory as an ASCII file. Then, use it along with the --init-memory-file option to initialize memory in the format snippy uses to dump memory sections
1 parent 2b6509d commit 7f8ac50

56 files changed

Lines changed: 2893 additions & 8 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# RUN: llvm-snippy %s --model-plugin None -o %t
2+
# RUN: llvm-readelf -S %t.elf | FileCheck %s
3+
4+
options:
5+
mtriple: riscv64
6+
enable-phdrs-definition: true
7+
num-instrs: 100
8+
init-memory: runtime
9+
init-regs-in-elf: true
10+
11+
sections:
12+
- name: 1
13+
VMA: 0x1000000
14+
SIZE: 0x2000
15+
LMA: 0x1000000
16+
ACCESS: rx
17+
PHDR: 'header1'
18+
- name: 2
19+
VMA: 0x1002000
20+
SIZE: 0x2000
21+
LMA: 0x1002000
22+
ACCESS: rx
23+
PHDR: 'header2'
24+
- name: 3
25+
VMA: 0x1000
26+
SIZE: 0x1000
27+
LMA: 0x1000
28+
ACCESS: rw
29+
PHDR: 'header3'
30+
- name: 4
31+
VMA: 0x100000
32+
SIZE: 0x1000
33+
LMA: 0x100000
34+
ACCESS: r
35+
PHDR: 'header3'
36+
37+
code-layout:
38+
ranges:
39+
- start: 0x1000000
40+
size: 0x2000
41+
stride: 0x100
42+
first-offset: 0
43+
last-offset: 0xff
44+
- start: 0x1002000
45+
size: 0x2000
46+
stride: 0x100
47+
first-offset: 0
48+
last-offset: 0xff
49+
histogram:
50+
- [ADD, 3.0]
51+
- [BLT, 1.0]
52+
- [LD, 3.0]
53+
- [SW, 3.0]
54+
55+
# CHECK: .snippy.1.rx
56+
# CHECK-SAME: PROGBITS
57+
# CHECK: .snippy.2.rx
58+
# CHECK-SAME: PROGBITS
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# RUN: llvm-snippy %s --model-plugin None -o %t
2+
# RUN: llvm-readelf -S %t.elf | FileCheck %s
3+
4+
options:
5+
mtriple: riscv64
6+
num-instrs: 100
7+
init-memory: runtime
8+
init-regs-in-elf: true
9+
10+
sections:
11+
- name: 1
12+
VMA: 0x100000
13+
SIZE: 0x20000
14+
LMA: 0x100000
15+
ACCESS: rx
16+
- name: 2
17+
VMA: 0x130000
18+
SIZE: 0x20000
19+
LMA: 0x130000
20+
ACCESS: rx
21+
- name: 3
22+
VMA: 0x200000
23+
SIZE: 0x1000
24+
LMA: 0x200000
25+
ACCESS: rw
26+
27+
28+
code-layout:
29+
ranges:
30+
- start: 0x100000
31+
size: 0x10000
32+
stride: 0x10000
33+
first-offset: 0
34+
last-offset: 0xffff
35+
- start: 0x130000
36+
size: 0x10000
37+
stride: 0x10000
38+
first-offset: 0
39+
last-offset: 0xffff
40+
histogram:
41+
- [ADD, 3.0]
42+
- [BLT, 1.0]
43+
44+
# CHECK: .snippy.1.rx
45+
# CHECK-SAME: PROGBITS
46+
# CHECK: .snippy.2.rx
47+
# CHECK-SAME: PROGBITS
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Section {2}:
2+
0x0: 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11
3+
4+
end-of-sections-init
5+
6+
Section {4}:
7+
0x0: 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Section {2}:
2+
0x0: Bf 00 11 6f 07
3+
0x5: bf 11 49 aa 55 77 91 02 01 10
4+
0xf: 8F
5+
0x10: 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Section {2}:
2+
0x0: 11
3+
0x1: 22
4+
0x2: 33
5+
0x3: 44
6+
0x4: 55
7+
0x5: 66
8+
0x6: 77
9+
0x7: 88
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Section {2}:
2+
0x0: 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11
3+
0x10: 11 11 11 11 11 BOBA 11 11 11 11 11 11 11 11 11 11
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Section {2}:
2+
0x0:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Section {2}:
2+
0x0: 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11
3+
4+
Section {4}:
5+
0x0: 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# RUN: llvm-snippy %s -model-plugin=None \
2+
# RUN: --init-memory=ascii-file --init-memory-file=%S/Inputs/memory-map.yaml
3+
4+
sections:
5+
- name: 1
6+
VMA: 0x100000
7+
SIZE: 0x100000
8+
LMA: 0x100000
9+
ACCESS: rx
10+
- name: 2
11+
VMA: 0x200000
12+
SIZE: 0x000010
13+
LMA: 0x200000
14+
ACCESS: rw
15+
- name: 4
16+
VMA: 0x400000
17+
SIZE: 0x000010
18+
LMA: 0x400000
19+
ACCESS: rw
20+
21+
options:
22+
mtriple: "riscv64"
23+
mcpu: "generic-rv64"
24+
num-instrs: 10
25+
26+
histogram:
27+
- [LB, 2.0]
28+
- [ADD, 4.0]
29+
- [SW, 2.0]
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# RUN: not llvm-snippy %s -model-plugin=None \
2+
# RUN: --init-memory-file=%S/Inputs/memory-map-wrong-byte-format.yaml \
3+
# RUN: --init-memory=ascii-file |& FileCheck %s
4+
5+
sections:
6+
- name: 1
7+
VMA: 0x210000
8+
SIZE: 0x100000
9+
LMA: 0x210000
10+
ACCESS: rx
11+
- name: 2
12+
VMA: 0x100000
13+
SIZE: 0x001000
14+
LMA: 0x100000
15+
ACCESS: rw
16+
17+
options:
18+
mtriple: "riscv64"
19+
mcpu: "generic-rv64"
20+
num-instrs: 10
21+
22+
23+
histogram:
24+
- [LB, 2.0]
25+
26+
# CHECK: error: [memory-map-wrong-byte-format.yaml, 3]
27+
# CHECK: Wrong memory init file format: can't convert to byte: BOBA

0 commit comments

Comments
 (0)