xref: /llvm-project/llvm/test/MC/AMDGPU/gfx10-constant-bus.s (revision 252c42354eca54274ed7b10c32c73c6937478e8b)
1// RUN: not llvm-mc -triple=amdgcn -mcpu=gfx1010 -show-encoding %s | FileCheck -check-prefixes=GCN,GFX10 %s
2// RUN: not llvm-mc -triple=amdgcn -mcpu=gfx1010 %s 2>&1 | FileCheck -check-prefixes=GCN-ERR --implicit-check-not=error: %s
3// RUN: not llvm-mc -triple=amdgcn -mcpu=gfx1100 -show-encoding %s | FileCheck -check-prefixes=GCN,GFX11 %s
4// RUN: not llvm-mc -triple=amdgcn -mcpu=gfx1100 %s 2>&1 | FileCheck -check-prefixes=GCN-ERR,GFX11-ERR --implicit-check-not=error: %s
5
6//-----------------------------------------------------------------------------------------
7// On GFX10 we can use two scalar operands (except for 64-bit shift instructions)
8
9v_add_f32 v0, s0, s1
10// GCN: v_add_f32_e64 v0, s0, s1        ; encoding: [0x00,0x00,0x03,0xd5,0x00,0x02,0x00,0x00]
11
12v_madak_f32 v0, s0, v1, 42.42
13// GFX10: v_madak_f32 v0, s0, v1, 0x4229ae14 ; encoding: [0x00,0x02,0x00,0x42,0x14,0xae,0x29,0x42]
14// GFX11-ERR: :[[@LINE-2]]:{{[0-9]+}}: error: instruction not supported on this GPU
15
16v_med3_f32 v0, s0, s0, s1
17// GFX10: v_med3_f32 v0, s0, s0, s1       ; encoding: [0x00,0x00,0x57,0xd5,0x00,0x00,0x04,0x00]
18// GFX11: v_med3_f32 v0, s0, s0, s1       ; encoding: [0x00,0x00,0x1f,0xd6,0x00,0x00,0x04,0x00]
19
20//-----------------------------------------------------------------------------------------
21// 64-bit shift instructions can use only one scalar value input
22
23v_ashrrev_i64 v[0:1], 0x100, s[0:1]
24// GCN-ERR: :[[@LINE-1]]:{{[0-9]+}}: error: invalid operand (violates constant bus restrictions)
25
26v_ashrrev_i64 v[0:1], s2, s[0:1]
27// GCN-ERR: :[[@LINE-1]]:{{[0-9]+}}: error: invalid operand (violates constant bus restrictions)
28
29//-----------------------------------------------------------------------------------------
30// v_div_fmas implicitly reads VCC, so only one scalar operand is possible
31
32v_div_fmas_f32 v5, s3, s3, s3
33// GFX10: v_div_fmas_f32 v5, s3, s3, s3   ; encoding: [0x05,0x00,0x6f,0xd5,0x03,0x06,0x0c,0x00]
34// GFX11: v_div_fmas_f32 v5, s3, s3, s3   ; encoding: [0x05,0x00,0x37,0xd6,0x03,0x06,0x0c,0x00]
35
36v_div_fmas_f32 v5, s3, s3, s2
37// GCN-ERR: :[[@LINE-1]]:{{[0-9]+}}: error: invalid operand (violates constant bus restrictions)
38
39v_div_fmas_f32 v5, s3, 0x123, v3
40// GCN-ERR: :[[@LINE-1]]:{{[0-9]+}}: error: invalid operand (violates constant bus restrictions)
41
42v_div_fmas_f64 v[5:6], 0x12345678, 0x12345678, 0x12345678
43// GFX10: v_div_fmas_f64 v[5:6], 0x12345678, 0x12345678, 0x12345678 ; encoding: [0x05,0x00,0x70,0xd5,0xff,0xfe,0xfd,0x03,0x78,0x56,0x34,0x12]
44// GFX11: v_div_fmas_f64 v[5:6], 0x12345678, 0x12345678, 0x12345678 ; encoding: [0x05,0x00,0x38,0xd6,0xff,0xfe,0xfd,0x03,0x78,0x56,0x34,0x12]
45
46v_div_fmas_f64 v[5:6], v[1:2], s[2:3], v[3:4]
47// GFX10: v_div_fmas_f64 v[5:6], v[1:2], s[2:3], v[3:4] ; encoding: [0x05,0x00,0x70,0xd5,0x01,0x05,0x0c,0x04]
48// GFX11: v_div_fmas_f64 v[5:6], v[1:2], s[2:3], v[3:4] ; encoding: [0x05,0x00,0x38,0xd6,0x01,0x05,0x0c,0x04]
49
50v_div_fmas_f64 v[5:6], v[1:2], s[2:3], 0x123456
51// GCN-ERR: :[[@LINE-1]]:{{[0-9]+}}: error: invalid operand (violates constant bus restrictions)
52
53//-----------------------------------------------------------------------------------------
54// v_mad_u64_u32 has operands of different sizes.
55// When these operands are literals, they are counted as 2 scalar values even if literals are identical.
56
57v_lshlrev_b64 v[5:6], 0x3f717273, 0x3f717273
58// GCN-ERR: :[[@LINE-1]]:{{[0-9]+}}: error: invalid operand (violates constant bus restrictions)
59
60v_mad_u64_u32 v[5:6], s12, v1, 0x12345678, 0x12345678
61// GFX10: v_mad_u64_u32 v[5:6], s12, v1, 0x12345678, 0x12345678 ; encoding: [0x05,0x0c,0x76,0xd5,0x01,0xff,0xfd,0x03,0x78,0x56,0x34,0x12]
62// GFX11: v_mad_u64_u32 v[5:6], s12, v1, 0x12345678, 0x12345678 ; encoding: [0x05,0x0c,0xfe,0xd6,0x01,0xff,0xfd,0x03,0x78,0x56,0x34,0x12]
63
64v_mad_u64_u32 v[5:6], s12, s1, 0x12345678, 0x12345678
65// GCN-ERR: :[[@LINE-1]]:{{[0-9]+}}: error: invalid operand (violates constant bus restrictions)
66
67//-----------------------------------------------------------------------------------------
68// null is free
69
70v_bfe_u32 v5, s1, s2, null
71// GFX10: v_bfe_u32 v5, s1, s2, null      ; encoding: [0x05,0x00,0x48,0xd5,0x01,0x04,0xf4,0x01]
72// GFX11: v_bfe_u32 v5, s1, s2, null      ; encoding: [0x05,0x00,0x10,0xd6,0x01,0x04,0xf0,0x01]
73