xref: /aosp_15_r20/external/mesa3d/src/amd/compiler/tests/README.md (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1*61046927SAndroid Build Coastguard WorkerTests are wrapped in a `BEGIN_TEST`/`END_TEST` and write data to the `output` file pointer. Tests have checks against the output. They are single line comments prefixed with certain characters:
2*61046927SAndroid Build Coastguard Worker
3*61046927SAndroid Build Coastguard Worker- `!` fails the test if the current line does not match the pattern
4*61046927SAndroid Build Coastguard Worker- `>>` skips to the first line which matches the pattern, or fails the test if there is none
5*61046927SAndroid Build Coastguard Worker- `;` executes python code to extend the pattern syntax by inserting functions into the variable dictionary, fail the test, insert more checks or consume characters from the output
6*61046927SAndroid Build Coastguard Worker
7*61046927SAndroid Build Coastguard WorkerBefore this prefix, there can be a `~` to only perform the check for certain
8*61046927SAndroid Build Coastguard Workervariants (a regex directly following the `~` is used).
9*61046927SAndroid Build Coastguard Worker
10*61046927SAndroid Build Coastguard Worker# Pattern Syntax
11*61046927SAndroid Build Coastguard WorkerPatterns can define variables which can be accessed in both python code and the pattern itself. These are useful for readability or dealing with unstable identifiers in the output. Variable identifiers are sequences of digits, ascii letters or `_` (though they cannot start with a digit).
12*61046927SAndroid Build Coastguard Worker
13*61046927SAndroid Build Coastguard Worker- `\` can be used to match the following literal character without interpreting it.
14*61046927SAndroid Build Coastguard Worker- Most characters expect the same characters in the output.
15*61046927SAndroid Build Coastguard Worker- A sequence of spaces in the pattern expects a sequence of spaces or tabs in the output.
16*61046927SAndroid Build Coastguard Worker- A `#` in the pattern expects an unsigned integer in the output. The `#` can be followed by an identifier to store the integer in a variable.
17*61046927SAndroid Build Coastguard Worker- A `$` in the pattern stores the output until the first whitespace character into a variable.
18*61046927SAndroid Build Coastguard Worker- A `%` in the pattern followed by an identifier is the same as a `#` but it expects a `%` before the integer in the output. It basically matches a ACO temporary.
19*61046927SAndroid Build Coastguard Worker- A `@` calls a variable as a function. It can be followed by an argument string wrapped in `(` and `)`.
20*61046927SAndroid Build Coastguard Worker
21*61046927SAndroid Build Coastguard Worker# Functions
22*61046927SAndroid Build Coastguard Worker- `s64`, `s96`, `s128`, `v2`, `v3`, etc, expand to a pattern which matches a disassembled instruction's definition or operand. It later checks that the size and alignment is what's expected.
23*61046927SAndroid Build Coastguard Worker- `match_func` expands to a sequence of `$` and inserts functions with expand to the extracted output
24*61046927SAndroid Build Coastguard Worker- `search_re` consumes the rest of the line and fails the test if the pattern is not found
25