File: macro-examples.s

package info (click to toggle)
llvm-toolchain-11 1%3A11.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 995,808 kB
  • sloc: cpp: 4,767,656; ansic: 760,916; asm: 477,436; python: 170,940; objc: 69,804; lisp: 29,914; sh: 23,855; f90: 18,173; pascal: 7,551; perl: 7,471; ml: 5,603; awk: 3,489; makefile: 2,573; xml: 915; cs: 573; fortran: 503; javascript: 452
file content (35 lines) | stat: -rw-r--r-- 1,139 bytes parent folder | download | duplicates (22)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// RUN: llvm-mc -arch=amdgcn -mcpu=fiji %s | FileCheck %s --check-prefix=VI

//===----------------------------------------------------------------------===//
// Example of reg[expr] and reg[epxr1:expr2] syntax in macros.
//===----------------------------------------------------------------------===//

.macro REG_NUM_EXPR_EXAMPLE width iter iter_end
    .if \width == 4
      flat_load_dwordx4   v[8 + (\iter * 4):8 + (\iter * 4) + 3], v[2:3]
    .else
      flat_load_dword     v[8 + \iter], v[2:3]
    .endif

    .if (\iter_end - \iter)
      REG_NUM_EXPR_EXAMPLE \width, (\iter + 1), \iter_end
    .endif
 .endm

REG_NUM_EXPR_EXAMPLE 4, 0, 0
// VI:   flat_load_dwordx4 v[8:11], v[2:3]

REG_NUM_EXPR_EXAMPLE 1, 0, 0
// VI:   flat_load_dword v8, v[2:3]

REG_NUM_EXPR_EXAMPLE 4, 1, 4
// VI:   flat_load_dwordx4 v[12:15], v[2:3]
// VI:   flat_load_dwordx4 v[16:19], v[2:3]
// VI:   flat_load_dwordx4 v[20:23], v[2:3]
// VI:   flat_load_dwordx4 v[24:27], v[2:3]

REG_NUM_EXPR_EXAMPLE 1, 1, 4
// VI:   flat_load_dword v9, v[2:3]
// VI:   flat_load_dword v10, v[2:3]
// VI:   flat_load_dword v11, v[2:3]
// VI:   flat_load_dword v12, v[2:3]