1// RUN: not llvm-mc -arch=amdgcn -show-encoding %s | FileCheck --check-prefix=GCN --check-prefix=SICI %s 2// RUN: not llvm-mc -arch=amdgcn %s 2>&1 | FileCheck %s --check-prefix=NOSICI --implicit-check-not=error: 3// RUN: llvm-mc -arch=amdgcn -mcpu=fiji -show-encoding %s | FileCheck --check-prefix=GCN --check-prefix=VI %s 4 5//===----------------------------------------------------------------------===// 6// Edge Cases 7//===----------------------------------------------------------------------===// 8 9s_nop 0 10// GCN: s_nop 0 ; encoding: [0x00,0x00,0x80,0xbf] 11 12s_nop 0xffff 13// GCN: s_nop 0xffff ; encoding: [0xff,0xff,0x80,0xbf] 14 15//===----------------------------------------------------------------------===// 16// Instructions 17//===----------------------------------------------------------------------===// 18 19s_nop 1 20// GCN: s_nop 1 ; encoding: [0x01,0x00,0x80,0xbf] 21 22s_endpgm 23// GCN: s_endpgm ; encoding: [0x00,0x00,0x81,0xbf] 24 25s_branch 2 26// GCN: s_branch 2 ; encoding: [0x02,0x00,0x82,0xbf] 27 28s_cbranch_scc0 3 29// GCN: s_cbranch_scc0 3 ; encoding: [0x03,0x00,0x84,0xbf] 30 31s_cbranch_scc1 4 32// GCN: s_cbranch_scc1 4 ; encoding: [0x04,0x00,0x85,0xbf] 33 34s_cbranch_vccz 5 35// GCN: s_cbranch_vccz 5 ; encoding: [0x05,0x00,0x86,0xbf] 36 37s_cbranch_vccnz 6 38// GCN: s_cbranch_vccnz 6 ; encoding: [0x06,0x00,0x87,0xbf] 39 40s_cbranch_execz 7 41// GCN: s_cbranch_execz 7 ; encoding: [0x07,0x00,0x88,0xbf] 42 43s_cbranch_execnz 8 44// GCN: s_cbranch_execnz 8 ; encoding: [0x08,0x00,0x89,0xbf] 45 46s_cbranch_cdbgsys 9 47// GCN: s_cbranch_cdbgsys 9 ; encoding: [0x09,0x00,0x97,0xbf] 48 49s_cbranch_cdbgsys_and_user 10 50// GCN: s_cbranch_cdbgsys_and_user 10 ; encoding: [0x0a,0x00,0x9a,0xbf] 51 52s_cbranch_cdbgsys_or_user 11 53// GCN: s_cbranch_cdbgsys_or_user 11 ; encoding: [0x0b,0x00,0x99,0xbf] 54 55s_cbranch_cdbguser 12 56// GCN: s_cbranch_cdbguser 12 ; encoding: [0x0c,0x00,0x98,0xbf] 57 58s_barrier 59// GCN: s_barrier ; encoding: [0x00,0x00,0x8a,0xbf] 60 61//===----------------------------------------------------------------------===// 62// s_waitcnt 63//===----------------------------------------------------------------------===// 64 65s_waitcnt 0 66// GCN: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) ; encoding: [0x00,0x00,0x8c,0xbf] 67 68s_waitcnt vmcnt(0) & expcnt(0) & lgkmcnt(0) 69// GCN: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) ; encoding: [0x00,0x00,0x8c,0xbf] 70 71s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) 72// GCN: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) ; encoding: [0x00,0x00,0x8c,0xbf] 73 74s_waitcnt vmcnt(0), expcnt(0), lgkmcnt(0) 75// GCN: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) ; encoding: [0x00,0x00,0x8c,0xbf] 76 77s_waitcnt vmcnt(1) 78// GCN: s_waitcnt vmcnt(1) ; encoding: [0x71,0x0f,0x8c,0xbf] 79 80s_waitcnt vmcnt(9) 81// GCN: s_waitcnt vmcnt(9) ; encoding: [0x79,0x0f,0x8c,0xbf] 82 83s_waitcnt vmcnt(15) 84// GCN: s_waitcnt ; encoding: [0x7f,0x0f,0x8c,0xbf] 85 86s_waitcnt vmcnt_sat(9) 87// GCN: s_waitcnt vmcnt(9) ; encoding: [0x79,0x0f,0x8c,0xbf] 88 89s_waitcnt vmcnt_sat(15) 90// GCN: s_waitcnt ; encoding: [0x7f,0x0f,0x8c,0xbf] 91 92s_waitcnt vmcnt_sat(16) 93// GCN: s_waitcnt ; encoding: [0x7f,0x0f,0x8c,0xbf] 94 95s_waitcnt expcnt(2) 96// GCN: s_waitcnt expcnt(2) ; encoding: [0x2f,0x0f,0x8c,0xbf] 97 98s_waitcnt expcnt(7) 99// GCN: s_waitcnt ; encoding: [0x7f,0x0f,0x8c,0xbf] 100 101s_waitcnt expcnt_sat(2) 102// GCN: s_waitcnt expcnt(2) ; encoding: [0x2f,0x0f,0x8c,0xbf] 103 104s_waitcnt expcnt_sat(7) 105// GCN: s_waitcnt ; encoding: [0x7f,0x0f,0x8c,0xbf] 106 107s_waitcnt expcnt_sat(0xFFFF0000) 108// GCN: s_waitcnt ; encoding: [0x7f,0x0f,0x8c,0xbf] 109 110s_waitcnt lgkmcnt(3) 111// GCN: s_waitcnt lgkmcnt(3) ; encoding: [0x7f,0x03,0x8c,0xbf] 112 113s_waitcnt lgkmcnt(9) 114// GCN: s_waitcnt lgkmcnt(9) ; encoding: [0x7f,0x09,0x8c,0xbf] 115 116s_waitcnt lgkmcnt(15) 117// GCN: s_waitcnt ; encoding: [0x7f,0x0f,0x8c,0xbf] 118 119s_waitcnt vmcnt(0), expcnt(0) 120// GCN: s_waitcnt vmcnt(0) expcnt(0) ; encoding: [0x00,0x0f,0x8c,0xbf] 121 122s_waitcnt lgkmcnt_sat(3) 123// GCN: s_waitcnt lgkmcnt(3) ; encoding: [0x7f,0x03,0x8c,0xbf] 124 125s_waitcnt lgkmcnt_sat(9) 126// GCN: s_waitcnt lgkmcnt(9) ; encoding: [0x7f,0x09,0x8c,0xbf] 127 128s_waitcnt lgkmcnt_sat(15) 129// GCN: s_waitcnt ; encoding: [0x7f,0x0f,0x8c,0xbf] 130 131s_waitcnt lgkmcnt_sat(16) 132// GCN: s_waitcnt ; encoding: [0x7f,0x0f,0x8c,0xbf] 133 134x=1 135s_waitcnt lgkmcnt_sat(x+1) 136// GCN: s_waitcnt lgkmcnt(2) ; encoding: [0x7f,0x02,0x8c,0xbf] 137 138s_waitcnt lgkmcnt_sat(1+x) 139// GCN: s_waitcnt lgkmcnt(2) ; encoding: [0x7f,0x02,0x8c,0xbf] 140 141s_waitcnt x+1 142// GCN: s_waitcnt vmcnt(2) expcnt(0) lgkmcnt(0) ; encoding: [0x02,0x00,0x8c,0xbf] 143 144s_waitcnt 1+x 145// GCN: s_waitcnt vmcnt(2) expcnt(0) lgkmcnt(0) ; encoding: [0x02,0x00,0x8c,0xbf] 146 147lgkmcnt_sat=1 148s_waitcnt lgkmcnt_sat 149// GCN: s_waitcnt vmcnt(1) expcnt(0) lgkmcnt(0) ; encoding: [0x01,0x00,0x8c,0xbf] 150 151s_waitcnt lgkmcnt_sat+1 152// GCN: s_waitcnt vmcnt(2) expcnt(0) lgkmcnt(0) ; encoding: [0x02,0x00,0x8c,0xbf] 153 154//===----------------------------------------------------------------------===// 155// misc sopp instructions 156//===----------------------------------------------------------------------===// 157 158s_sethalt 9 159// GCN: s_sethalt 9 ; encoding: [0x09,0x00,0x8d,0xbf] 160 161s_setkill 7 162// GCN: s_setkill 7 ; encoding: [0x07,0x00,0x8b,0xbf] 163 164s_sleep 10 165// GCN: s_sleep 10 ; encoding: [0x0a,0x00,0x8e,0xbf] 166 167s_setprio 1 168// GCN: s_setprio 1 ; encoding: [0x01,0x00,0x8f,0xbf] 169 170//===----------------------------------------------------------------------===// 171// s_sendmsg 172//===----------------------------------------------------------------------===// 173 174s_sendmsg 0x1 175// GCN: s_sendmsg sendmsg(MSG_INTERRUPT) ; encoding: [0x01,0x00,0x90,0xbf] 176 177s_sendmsg sendmsg(1) 178// GCN: s_sendmsg sendmsg(MSG_INTERRUPT) ; encoding: [0x01,0x00,0x90,0xbf] 179 180s_sendmsg sendmsg(MSG_INTERRUPT) 181// GCN: s_sendmsg sendmsg(MSG_INTERRUPT) ; encoding: [0x01,0x00,0x90,0xbf] 182 183s_sendmsg 0x12 184// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf] 185 186s_sendmsg sendmsg(2, 1) 187// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf] 188 189s_sendmsg sendmsg(2, GS_OP_CUT) 190// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf] 191 192s_sendmsg sendmsg(MSG_GS, GS_OP_CUT) 193// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf] 194 195s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) 196// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf] 197 198s_sendmsg sendmsg(MSG_GS, 1) 199// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf] 200 201s_sendmsg sendmsg(MSG_GS, 1, 1) 202// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 1) ; encoding: [0x12,0x01,0x90,0xbf] 203 204s_sendmsg 0x122 205// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT, 1) ; encoding: [0x22,0x01,0x90,0xbf] 206 207s_sendmsg sendmsg(2, 2, 1) 208// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT, 1) ; encoding: [0x22,0x01,0x90,0xbf] 209 210s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT, 1) 211// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT, 1) ; encoding: [0x22,0x01,0x90,0xbf] 212 213s_sendmsg 0x232 214// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT_CUT, 2) ; encoding: [0x32,0x02,0x90,0xbf] 215 216s_sendmsg sendmsg(2, 3, 2) 217// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT_CUT, 2) ; encoding: [0x32,0x02,0x90,0xbf] 218 219s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT_CUT, 2) 220// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT_CUT, 2) ; encoding: [0x32,0x02,0x90,0xbf] 221 222s_sendmsg 0x3 223// GCN: s_sendmsg sendmsg(MSG_GS_DONE, GS_OP_NOP) ; encoding: [0x03,0x00,0x90,0xbf] 224 225s_sendmsg sendmsg(3, 0) 226// GCN: s_sendmsg sendmsg(MSG_GS_DONE, GS_OP_NOP) ; encoding: [0x03,0x00,0x90,0xbf] 227 228s_sendmsg sendmsg(MSG_GS_DONE, GS_OP_NOP) 229// GCN: s_sendmsg sendmsg(MSG_GS_DONE, GS_OP_NOP) ; encoding: [0x03,0x00,0x90,0xbf] 230 231s_sendmsg 0x1f 232// GCN: s_sendmsg sendmsg(MSG_SYSMSG, SYSMSG_OP_ECC_ERR_INTERRUPT) ; encoding: [0x1f,0x00,0x90,0xbf] 233 234s_sendmsg sendmsg(15, 1) 235// GCN: s_sendmsg sendmsg(MSG_SYSMSG, SYSMSG_OP_ECC_ERR_INTERRUPT) ; encoding: [0x1f,0x00,0x90,0xbf] 236 237s_sendmsg sendmsg(MSG_SYSMSG, SYSMSG_OP_ECC_ERR_INTERRUPT) 238// GCN: s_sendmsg sendmsg(MSG_SYSMSG, SYSMSG_OP_ECC_ERR_INTERRUPT) ; encoding: [0x1f,0x00,0x90,0xbf] 239 240s_sendmsghalt 3 241// GCN: s_sendmsghalt sendmsg(MSG_GS_DONE, GS_OP_NOP) ; encoding: [0x03,0x00,0x91,0xbf] 242 243s_sendmsghalt sendmsg(MSG_GS, GS_OP_EMIT, 1) 244// GCN: s_sendmsghalt sendmsg(MSG_GS, GS_OP_EMIT, 1) ; encoding: [0x22,0x01,0x91,0xbf] 245 246//===----------------------------------------------------------------------===// 247// s_sendmsg with a numeric message id (no validation) 248//===----------------------------------------------------------------------===// 249 250s_sendmsg 2 251// GCN: s_sendmsg sendmsg(2, 0, 0) ; encoding: [0x02,0x00,0x90,0xbf] 252 253s_sendmsg 0x4 254// GCN: s_sendmsg sendmsg(4, 0, 0) ; encoding: [0x04,0x00,0x90,0xbf] 255 256s_sendmsg 9 257// GCN: s_sendmsg sendmsg(9, 0, 0) ; encoding: [0x09,0x00,0x90,0xbf] 258 259s_sendmsg 11 260// GCN: s_sendmsg sendmsg(11, 0, 0) ; encoding: [0x0b,0x00,0x90,0xbf] 261 262s_sendmsg 0x6f 263// GCN: s_sendmsg sendmsg(15, 6, 0) ; encoding: [0x6f,0x00,0x90,0xbf] 264 265s_sendmsg sendmsg(1, 3) 266// GCN: s_sendmsg sendmsg(1, 3, 0) ; encoding: [0x31,0x00,0x90,0xbf] 267 268s_sendmsg sendmsg(1, 3, 2) 269// GCN: s_sendmsg sendmsg(1, 3, 2) ; encoding: [0x31,0x02,0x90,0xbf] 270 271s_sendmsg sendmsg(2, 0, 1) 272// GCN: s_sendmsg sendmsg(2, 0, 1) ; encoding: [0x02,0x01,0x90,0xbf] 273 274s_sendmsg sendmsg(15, 7, 3) 275// GCN: s_sendmsg sendmsg(15, 7, 3) ; encoding: [0x7f,0x03,0x90,0xbf] 276 277s_sendmsg 4567 278// GCN: s_sendmsg 4567 ; encoding: [0xd7,0x11,0x90,0xbf] 279 280//===----------------------------------------------------------------------===// 281// s_sendmsg with expressions 282//===----------------------------------------------------------------------===// 283 284sendmsg=2 285s_sendmsg sendmsg 286// GCN: s_sendmsg sendmsg(2, 0, 0) ; encoding: [0x02,0x00,0x90,0xbf] 287 288sendmsg=1 289s_sendmsg sendmsg+1 290// GCN: s_sendmsg sendmsg(2, 0, 0) ; encoding: [0x02,0x00,0x90,0xbf] 291 292s_sendmsg 1+sendmsg 293// GCN: s_sendmsg sendmsg(2, 0, 0) ; encoding: [0x02,0x00,0x90,0xbf] 294 295msg=1 296s_sendmsg sendmsg(msg) 297// GCN: s_sendmsg sendmsg(MSG_INTERRUPT) ; encoding: [0x01,0x00,0x90,0xbf] 298 299msg=0 300s_sendmsg sendmsg(msg+1) 301// GCN: s_sendmsg sendmsg(MSG_INTERRUPT) ; encoding: [0x01,0x00,0x90,0xbf] 302 303msg=0 304s_sendmsg sendmsg(1+msg) 305// GCN: s_sendmsg sendmsg(MSG_INTERRUPT) ; encoding: [0x01,0x00,0x90,0xbf] 306 307msg=2 308op=1 309s_sendmsg sendmsg(msg, op) 310// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf] 311 312msg=1 313op=0 314s_sendmsg sendmsg(msg+1, op+1) 315// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf] 316 317msg=1 318op=0 319s_sendmsg sendmsg(1+msg, 1+op) 320// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf] 321 322msg=1 323op=2 324stream=1 325s_sendmsg sendmsg(msg+1, op+1, stream+1) 326// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT_CUT, 2) ; encoding: [0x32,0x02,0x90,0xbf] 327 328msg=1 329op=2 330stream=1 331s_sendmsg sendmsg(1+msg, 1+op, 1+stream) 332// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT_CUT, 2) ; encoding: [0x32,0x02,0x90,0xbf] 333 334MSG_GS=-1 335GS_OP_EMIT=-1 336s_sendmsghalt sendmsg(MSG_GS, GS_OP_EMIT, 1) 337// GCN: s_sendmsghalt sendmsg(MSG_GS, GS_OP_EMIT, 1) ; encoding: [0x22,0x01,0x91,0xbf] 338 339//===----------------------------------------------------------------------===// 340// misc sopp instructions 341//===----------------------------------------------------------------------===// 342 343s_trap 4 344// GCN: s_trap 4 ; encoding: [0x04,0x00,0x92,0xbf] 345 346s_icache_inv 347// GCN: s_icache_inv ; encoding: [0x00,0x00,0x93,0xbf] 348 349s_incperflevel 5 350// GCN: s_incperflevel 5 ; encoding: [0x05,0x00,0x94,0xbf] 351 352s_decperflevel 6 353// GCN: s_decperflevel 6 ; encoding: [0x06,0x00,0x95,0xbf] 354 355s_ttracedata 356// GCN: s_ttracedata ; encoding: [0x00,0x00,0x96,0xbf] 357 358s_set_gpr_idx_off 359// VI: s_set_gpr_idx_off ; encoding: [0x00,0x00,0x9c,0xbf] 360// NOSICI: error: instruction not supported on this GPU 361 362s_set_gpr_idx_mode 0 363// VI: s_set_gpr_idx_mode gpr_idx() ; encoding: [0x00,0x00,0x9d,0xbf] 364// NOSICI: error: instruction not supported on this GPU 365 366s_set_gpr_idx_mode gpr_idx() 367// VI: s_set_gpr_idx_mode gpr_idx() ; encoding: [0x00,0x00,0x9d,0xbf] 368// NOSICI: error: instruction not supported on this GPU 369 370s_set_gpr_idx_mode 15 371// VI: s_set_gpr_idx_mode gpr_idx(SRC0,SRC1,SRC2,DST) ; encoding: [0x0f,0x00,0x9d,0xbf] 372// NOSICI: error: instruction not supported on this GPU 373 374s_set_gpr_idx_mode gpr_idx(SRC2,SRC1,SRC0,DST) 375// VI: s_set_gpr_idx_mode gpr_idx(SRC0,SRC1,SRC2,DST) ; encoding: [0x0f,0x00,0x9d,0xbf] 376// NOSICI: error: instruction not supported on this GPU 377 378s_endpgm_saved 379// VI: s_endpgm_saved ; encoding: [0x00,0x00,0x9b,0xbf] 380// NOSICI: error: instruction not supported on this GPU 381 382s_wakeup 383// VI: s_wakeup ; encoding: [0x00,0x00,0x83,0xbf] 384// NOSICI: error: instruction not supported on this GPU 385 386//===----------------------------------------------------------------------===// 387// absolute expressions as branch offsets 388//===----------------------------------------------------------------------===// 389 390offset = 3 391s_branch 1+offset 392// GCN: s_branch 4 ; encoding: [0x04,0x00,0x82,0xbf] 393 394offset = 3 395s_branch offset+1 396// GCN: s_branch 4 ; encoding: [0x04,0x00,0x82,0xbf] 397