Skip to content

Commit 437f448

Browse files
authored
cranelift: Cleanup testing docs (#5549)
Removes some docs from tests that we no longer have. Updates the ebb examples to the new block based examples.
1 parent a5fc046 commit 437f448

File tree

1 file changed

+25
-69
lines changed

1 file changed

+25
-69
lines changed

cranelift/docs/testing.md

Lines changed: 25 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ The `set` lines apply settings cumulatively:
6060
test legalizer
6161
set opt_level=best
6262
set is_pic=1
63-
isa riscv64
63+
target riscv64
6464
set is_pic=0
65-
isa riscv32 supports_m=false
65+
target riscv32 supports_m=false
6666
6767
function %foo() {}
6868
```
@@ -116,13 +116,13 @@ Example:
116116

117117
```
118118
function %r1() -> i32, f32 {
119-
ebb1:
119+
block1:
120120
v10 = iconst.i32 3
121121
v20 = f32const 0.0
122122
return v10, v20
123123
}
124124
; sameln: function %r1() -> i32, f32 {
125-
; nextln: ebb0:
125+
; nextln: block0:
126126
; nextln: v10 = iconst.i32 3
127127
; nextln: v20 = f32const 0.0
128128
; nextln: return v10, v20
@@ -142,8 +142,8 @@ reported location of the error is verified:
142142
test verifier
143143
144144
function %test(i32) {
145-
ebb0(v0: i32):
146-
jump ebb1 ; error: terminator
145+
block0(v0: i32):
146+
jump block1 ; error: terminator
147147
return
148148
}
149149
```
@@ -169,17 +169,17 @@ command:
169169
function %nonsense(i32, i32) -> f32 {
170170
; check: digraph %nonsense {
171171
; regex: I=\binst\d+\b
172-
; check: label="{ebb0 | <$(BRZ=$I)>brz ebb2 | <$(JUMP=$I)>jump ebb1}"]
172+
; check: label="{block0 | <$(BRZ=$I)>brz block2 | <$(JUMP=$I)>jump block1}"]
173173
174-
ebb0(v0: i32, v1: i32):
175-
brz v1, ebb2 ; unordered: ebb0:$BRZ -> ebb2
174+
block0(v0: i32, v1: i32):
175+
brz v1, block2 ; unordered: block0:$BRZ -> block2
176176
v2 = iconst.i32 0
177-
jump ebb1(v2) ; unordered: ebb0:$JUMP -> ebb1
177+
jump block1(v2) ; unordered: block0:$JUMP -> block1
178178
179-
ebb1(v5: i32):
179+
block1(v5: i32):
180180
return v0
181181
182-
ebb2:
182+
block2:
183183
v100 = f32const 0.0
184184
return v100
185185
}
@@ -194,14 +194,14 @@ Compute the dominator tree of each function and validate it against the
194194
test domtree
195195
196196
function %test(i32) {
197-
ebb0(v0: i32):
198-
jump ebb1 ; dominates: ebb1
199-
ebb1:
200-
brz v0, ebb3 ; dominates: ebb3
201-
jump ebb2 ; dominates: ebb2
202-
ebb2:
203-
jump ebb3
204-
ebb3:
197+
block0(v0: i32):
198+
jump block1 ; dominates: block1
199+
block1:
200+
brz v0, block3 ; dominates: block3
201+
jump block2 ; dominates: block2
202+
block2:
203+
jump block3
204+
block3:
205205
return
206206
}
207207
```
@@ -233,36 +233,6 @@ assigning registers and stack slots to all values.
233233

234234
The resulting function is then run through filecheck.
235235

236-
### `test binemit`
237-
238-
Test the emission of binary machine code.
239-
240-
The functions must contains instructions that are annotated with both encodings
241-
and value locations (registers or stack slots). For instructions that are
242-
annotated with a `bin:` directive, the emitted hexadecimal machine code for
243-
that instruction is compared to the directive:
244-
245-
```
246-
test binemit
247-
isa riscv
248-
249-
function %int32() {
250-
ebb0:
251-
[-,%x5] v0 = iconst.i32 1
252-
[-,%x6] v1 = iconst.i32 2
253-
[R#0c,%x7] v10 = iadd v0, v1 ; bin: 006283b3
254-
[R#200c,%x8] v11 = isub v0, v1 ; bin: 40628433
255-
return
256-
}
257-
```
258-
259-
If any instructions are unencoded (indicated with a `[-]` encoding field), they
260-
will be encoded using the same mechanism as the legalizer uses. However,
261-
illegal instructions for the ISA won't be expanded into other instruction
262-
sequences. Instead the test will fail.
263-
264-
Value locations must be present if they are required to compute the binary
265-
bits. Missing value locations will cause the test to crash.
266236

267237
### `test simple-gvn`
268238

@@ -321,9 +291,9 @@ This test command allows several directives:
321291
- to check the result of a function, add a `run` directive and call the
322292
preceding function with a comparison (`==` or `!=`) (see `%bar` below)
323293
- for backwards compatibility, to check the result of a function with a
324-
`() -> b*` signature, only the `run` directive is required, with no
325-
invocation or comparison (see `%baz` below); a `true` value is
326-
interpreted as a successful test execution, whereas a `false` value is
294+
`() -> i*` signature, only the `run` directive is required, with no
295+
invocation or comparison (see `%baz` below); a non zero value is
296+
interpreted as a successful test execution, whereas a zero value is
327297
interpreted as a failed test.
328298

329299
Currently a `target` is required but is only used to indicate whether the host
@@ -353,24 +323,10 @@ Example:
353323
; run: %bar(1) == 2
354324
355325
; legacy method of checking the results of a function
356-
function %baz() -> b1 {
326+
function %baz() -> i8 {
357327
block0:
358-
v0 = bconst.b1 true
328+
v0 = iconst.i8 1
359329
return v0
360330
}
361331
; run
362332
```
363-
364-
#### Environment directives
365-
366-
Some tests need additional resources to be provided by the filetest infrastructure.
367-
368-
When any of the following directives is present the first argument of the function is *required* to be a `i64 vmctx`.
369-
The filetest infrastructure will then pass a pointer to the environment struct via this argument.
370-
371-
The environment struct is essentially a list of pointers with info about the resources requested by the directives. These
372-
pointers are always 8 bytes, and laid out sequentially in memory. Even for 32 bit machines, where we only fill the first
373-
4 bytes of the pointer slot.
374-
375-
Currently, we only support requesting heaps, however this is a generic mechanism that should
376-
be able to introduce any sort of environment support that we may need later. (e.g. tables, global values, external functions)

0 commit comments

Comments
 (0)