xref: /aosp_15_r20/external/llvm/test/MC/AMDGPU/expressions.s (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker// RUN: llvm-mc -arch=amdgcn -mcpu=fiji -show-encoding %s | FileCheck %s --check-prefix=VI
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Worker.globl global
5*9880d681SAndroid Build Coastguard Worker.globl gds
6*9880d681SAndroid Build Coastguard Worker
7*9880d681SAndroid Build Coastguard Worker// Parse a global expression
8*9880d681SAndroid Build Coastguard Workers_mov_b32 s0, global
9*9880d681SAndroid Build Coastguard Worker// VI: s_mov_b32 s0, global ; encoding: [0xff,0x00,0x80,0xbe,A,A,A,A]
10*9880d681SAndroid Build Coastguard Worker// VI-NEXT: ;   fixup A - offset: 4, value: global, kind: FK_PCRel_4
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Worker// Use a token with the same name as a global
13*9880d681SAndroid Build Coastguard Workerds_gws_init v2 gds
14*9880d681SAndroid Build Coastguard Worker// VI: ds_gws_init v2 gds ; encoding: [0x00,0x00,0x33,0xd8,0x02,0x00,0x00,0x00]
15*9880d681SAndroid Build Coastguard Worker
16*9880d681SAndroid Build Coastguard Worker// Use a global with the same name as a token
17*9880d681SAndroid Build Coastguard Workers_mov_b32 s0, gds
18*9880d681SAndroid Build Coastguard Worker// VI: s_mov_b32 s0, gds ; encoding: [0xff,0x00,0x80,0xbe,A,A,A,A]
19*9880d681SAndroid Build Coastguard Worker// VI-NEXT: ;   fixup A - offset: 4, value: gds, kind: FK_PCRel_4
20*9880d681SAndroid Build Coastguard Worker
21*9880d681SAndroid Build Coastguard Worker// Use a binary expression
22*9880d681SAndroid Build Coastguard Workers_mov_b32 s0, gds+4
23*9880d681SAndroid Build Coastguard Worker// VI: s_mov_b32 s0, gds+4 ; encoding: [0xff,0x00,0x80,0xbe,A,A,A,A]
24*9880d681SAndroid Build Coastguard Worker// VI-NEXT: ;   fixup A - offset: 4, value: gds+4, kind: FK_PCRel_4
25*9880d681SAndroid Build Coastguard Worker
26*9880d681SAndroid Build Coastguard Worker// Consecutive instructions with no blank line in between to make sure we
27*9880d681SAndroid Build Coastguard Worker// don't call Lex() too many times.
28*9880d681SAndroid Build Coastguard Workers_add_u32 s0, s0, global+4
29*9880d681SAndroid Build Coastguard Workers_addc_u32 s1, s1, 0
30*9880d681SAndroid Build Coastguard Worker// VI: s_add_u32 s0, s0, global+4
31*9880d681SAndroid Build Coastguard Worker// VI: s_addc_u32 s1, s1, 0
32*9880d681SAndroid Build Coastguard Worker
33*9880d681SAndroid Build Coastguard Worker// Use a computed expression that results in an inline immediate.
34*9880d681SAndroid Build Coastguard Worker.set foo, 4
35*9880d681SAndroid Build Coastguard Workers_mov_b32 s0, foo+2
36*9880d681SAndroid Build Coastguard Worker// VI: s_mov_b32 s0, 6 ; encoding: [0x86,0x00,0x80,0xbe]
37*9880d681SAndroid Build Coastguard Worker
38*9880d681SAndroid Build Coastguard Worker// Use a computed expression that results in a non-inline immediate.
39*9880d681SAndroid Build Coastguard Worker.set foo, 512
40*9880d681SAndroid Build Coastguard Workers_mov_b32 s0, foo+2
41*9880d681SAndroid Build Coastguard Worker// VI: s_mov_b32 s0, 514 ; encoding: [0xff,0x00,0x80,0xbe,0x02,0x02,0x00,0x00]
42