llvm/llvm/test/CodeGen/AMDGPU/required-export-priority.mir

# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
# RUN: llc -mtriple=amdgcn -mcpu=gfx1150 -run-pass=post-RA-hazard-rec %s -o - | FileCheck -check-prefixes=GFX1150 %s
# RUN: llc -mtriple=amdgcn -mcpu=gfx11-generic -run-pass=post-RA-hazard-rec %s -o - | FileCheck -check-prefixes=GFX1150 %s

--- |
  define amdgpu_ps void @end_of_shader() {
    ret void
  }
  define amdgpu_ps void @end_of_shader_return_to_epilogue() {
    ret void
  }
  define amdgpu_ps void @end_of_block() {
    ret void
  }
  define amdgpu_ps void @start_of_block() {
    ret void
  }
  define amdgpu_ps void @block_of_exports() {
    ret void
  }
  define amdgpu_ps void @sparse_exports() {
    ret void
  }
  define amdgpu_ps void @existing_setprio_1() {
    ret void
  }
  define amdgpu_ps void @existing_setprio_2() {
    ret void
  }
...

---
name: end_of_shader
tracksRegLiveness: true
liveins:
  - { reg: '$vgpr0' }
body: |
  bb.0:
    liveins: $vgpr0
    ; GFX1150-LABEL: name: end_of_shader
    ; GFX1150: liveins: $vgpr0
    ; GFX1150-NEXT: {{  $}}
    ; GFX1150-NEXT: S_SETPRIO 2
    ; GFX1150-NEXT: EXP_DONE 0, $vgpr0, $vgpr0, $vgpr0, $vgpr0, -1, -1, 15, implicit $exec
    ; GFX1150-NEXT: S_SETPRIO 0
    ; GFX1150-NEXT: S_NOP 0
    ; GFX1150-NEXT: S_NOP 0
    ; GFX1150-NEXT: S_ENDPGM 0
    EXP_DONE 0, $vgpr0, $vgpr0, $vgpr0, $vgpr0, -1, -1, 15, implicit $exec
    S_ENDPGM 0
...

---
name: end_of_shader_return_to_epilogue
tracksRegLiveness: true
liveins:
  - { reg: '$vgpr0' }
body: |
  bb.0:
    liveins: $vgpr0
    ; GFX1150-LABEL: name: end_of_shader_return_to_epilogue
    ; GFX1150: liveins: $vgpr0
    ; GFX1150-NEXT: {{  $}}
    ; GFX1150-NEXT: S_SETPRIO 2
    ; GFX1150-NEXT: EXP_DONE 0, $vgpr0, $vgpr0, $vgpr0, $vgpr0, -1, -1, 15, implicit $exec
    ; GFX1150-NEXT: S_SETPRIO 0
    ; GFX1150-NEXT: S_WAITCNT_EXPCNT $sgpr_null, 0
    ; GFX1150-NEXT: S_NOP 0
    ; GFX1150-NEXT: S_NOP 0
    ; GFX1150-NEXT: S_SETPRIO 2
    ; GFX1150-NEXT: SI_RETURN_TO_EPILOG $vgpr0
    EXP_DONE 0, $vgpr0, $vgpr0, $vgpr0, $vgpr0, -1, -1, 15, implicit $exec
    SI_RETURN_TO_EPILOG $vgpr0
...

---
name: end_of_block
tracksRegLiveness: true
liveins:
  - { reg: '$vgpr0' }
body: |
  ; GFX1150-LABEL: name: end_of_block
  ; GFX1150: bb.0:
  ; GFX1150-NEXT:   successors: %bb.1(0x80000000)
  ; GFX1150-NEXT:   liveins: $vgpr0
  ; GFX1150-NEXT: {{  $}}
  ; GFX1150-NEXT:   S_SETPRIO 2
  ; GFX1150-NEXT:   EXP_DONE 0, $vgpr0, $vgpr0, $vgpr0, $vgpr0, -1, -1, 15, implicit $exec
  ; GFX1150-NEXT:   S_SETPRIO 0
  ; GFX1150-NEXT:   S_WAITCNT_EXPCNT $sgpr_null, 0
  ; GFX1150-NEXT:   S_NOP 0
  ; GFX1150-NEXT:   S_NOP 0
  ; GFX1150-NEXT:   S_SETPRIO 2
  ; GFX1150-NEXT: {{  $}}
  ; GFX1150-NEXT: bb.1:
  ; GFX1150-NEXT:   S_ENDPGM 0
  bb.0:
    liveins: $vgpr0
    EXP_DONE 0, $vgpr0, $vgpr0, $vgpr0, $vgpr0, -1, -1, 15, implicit $exec

  bb.1:
    S_ENDPGM 0
...

---
name: start_of_block
tracksRegLiveness: true
liveins:
  - { reg: '$vgpr0' }
body: |
  ; GFX1150-LABEL: name: start_of_block
  ; GFX1150: bb.0:
  ; GFX1150-NEXT:   successors: %bb.1(0x80000000)
  ; GFX1150-NEXT:   liveins: $vgpr0
  ; GFX1150-NEXT: {{  $}}
  ; GFX1150-NEXT:   S_SETPRIO 2
  ; GFX1150-NEXT: {{  $}}
  ; GFX1150-NEXT: bb.1:
  ; GFX1150-NEXT:   successors: %bb.2(0x80000000)
  ; GFX1150-NEXT:   liveins: $vgpr0
  ; GFX1150-NEXT: {{  $}}
  ; GFX1150-NEXT:   EXP_DONE 0, $vgpr0, $vgpr0, $vgpr0, $vgpr0, -1, -1, 15, implicit $exec
  ; GFX1150-NEXT:   S_SETPRIO 0
  ; GFX1150-NEXT:   S_WAITCNT_EXPCNT $sgpr_null, 0
  ; GFX1150-NEXT:   S_NOP 0
  ; GFX1150-NEXT:   S_NOP 0
  ; GFX1150-NEXT:   S_SETPRIO 2
  ; GFX1150-NEXT: {{  $}}
  ; GFX1150-NEXT: bb.2:
  ; GFX1150-NEXT:   S_ENDPGM 0
  bb.0:
    liveins: $vgpr0

  bb.1:
    liveins: $vgpr0
    EXP_DONE 0, $vgpr0, $vgpr0, $vgpr0, $vgpr0, -1, -1, 15, implicit $exec

  bb.2:
    S_ENDPGM 0
...

---
name: block_of_exports
tracksRegLiveness: true
liveins:
  - { reg: '$vgpr0' }
body: |
  bb.0:
    liveins: $vgpr0
    ; GFX1150-LABEL: name: block_of_exports
    ; GFX1150: liveins: $vgpr0
    ; GFX1150-NEXT: {{  $}}
    ; GFX1150-NEXT: S_SETPRIO 2
    ; GFX1150-NEXT: EXP 2, $vgpr0, $vgpr0, $vgpr0, $vgpr0, -1, -1, 15, implicit $exec
    ; GFX1150-NEXT: EXP 1, $vgpr0, $vgpr0, $vgpr0, $vgpr0, -1, -1, 15, implicit $exec
    ; GFX1150-NEXT: EXP_DONE 0, $vgpr0, $vgpr0, $vgpr0, $vgpr0, -1, -1, 15, implicit $exec
    ; GFX1150-NEXT: S_SETPRIO 0
    ; GFX1150-NEXT: S_NOP 0
    ; GFX1150-NEXT: S_NOP 0
    ; GFX1150-NEXT: S_ENDPGM 0
    EXP 2, $vgpr0, $vgpr0, $vgpr0, $vgpr0, -1, -1, 15, implicit $exec
    EXP 1, $vgpr0, $vgpr0, $vgpr0, $vgpr0, -1, -1, 15, implicit $exec
    EXP_DONE 0, $vgpr0, $vgpr0, $vgpr0, $vgpr0, -1, -1, 15, implicit $exec
    S_ENDPGM 0
...

---
name: sparse_exports
tracksRegLiveness: true
liveins:
  - { reg: '$vgpr0' }
body: |
  bb.0:
    liveins: $vgpr0
    ; GFX1150-LABEL: name: sparse_exports
    ; GFX1150: liveins: $vgpr0
    ; GFX1150-NEXT: {{  $}}
    ; GFX1150-NEXT: S_SETPRIO 2
    ; GFX1150-NEXT: EXP 2, $vgpr0, $vgpr0, $vgpr0, $vgpr0, -1, -1, 15, implicit $exec
    ; GFX1150-NEXT: S_SETPRIO 0
    ; GFX1150-NEXT: S_WAITCNT_EXPCNT $sgpr_null, 0
    ; GFX1150-NEXT: S_NOP 0
    ; GFX1150-NEXT: S_NOP 0
    ; GFX1150-NEXT: S_SETPRIO 2
    ; GFX1150-NEXT: $vgpr0 = V_AND_B32_e32 1, $vgpr0, implicit $exec
    ; GFX1150-NEXT: EXP 1, $vgpr0, $vgpr0, $vgpr0, $vgpr0, -1, -1, 15, implicit $exec
    ; GFX1150-NEXT: S_SETPRIO 0
    ; GFX1150-NEXT: S_WAITCNT_EXPCNT $sgpr_null, 0
    ; GFX1150-NEXT: S_NOP 0
    ; GFX1150-NEXT: S_NOP 0
    ; GFX1150-NEXT: S_SETPRIO 2
    ; GFX1150-NEXT: $vgpr0 = V_OR_B32_e32 2, $vgpr0, implicit $exec
    ; GFX1150-NEXT: EXP_DONE 0, $vgpr0, $vgpr0, $vgpr0, $vgpr0, -1, -1, 15, implicit $exec
    ; GFX1150-NEXT: S_SETPRIO 0
    ; GFX1150-NEXT: S_NOP 0
    ; GFX1150-NEXT: S_NOP 0
    ; GFX1150-NEXT: S_ENDPGM 0
    EXP 2, $vgpr0, $vgpr0, $vgpr0, $vgpr0, -1, -1, 15, implicit $exec
    $vgpr0 = V_AND_B32_e32 1, $vgpr0, implicit $exec
    EXP 1, $vgpr0, $vgpr0, $vgpr0, $vgpr0, -1, -1, 15, implicit $exec
    $vgpr0 = V_OR_B32_e32 2, $vgpr0, implicit $exec
    EXP_DONE 0, $vgpr0, $vgpr0, $vgpr0, $vgpr0, -1, -1, 15, implicit $exec
    S_ENDPGM 0
...

---
name: existing_setprio_1
tracksRegLiveness: true
liveins:
  - { reg: '$vgpr0' }
body: |
  ; GFX1150-LABEL: name: existing_setprio_1
  ; GFX1150: bb.0:
  ; GFX1150-NEXT:   successors: %bb.1(0x80000000)
  ; GFX1150-NEXT:   liveins: $vgpr0
  ; GFX1150-NEXT: {{  $}}
  ; GFX1150-NEXT:   S_SETPRIO 2
  ; GFX1150-NEXT:   $vgpr0 = V_AND_B32_e32 1, $vgpr0, implicit $exec
  ; GFX1150-NEXT: {{  $}}
  ; GFX1150-NEXT: bb.1:
  ; GFX1150-NEXT:   successors: %bb.2(0x80000000)
  ; GFX1150-NEXT:   liveins: $vgpr0
  ; GFX1150-NEXT: {{  $}}
  ; GFX1150-NEXT:   S_SETPRIO 3
  ; GFX1150-NEXT:   $vgpr0 = V_OR_B32_e32 2, $vgpr0, implicit $exec
  ; GFX1150-NEXT:   S_SETPRIO 2
  ; GFX1150-NEXT: {{  $}}
  ; GFX1150-NEXT: bb.2:
  ; GFX1150-NEXT:   successors: %bb.3(0x80000000)
  ; GFX1150-NEXT:   liveins: $vgpr0
  ; GFX1150-NEXT: {{  $}}
  ; GFX1150-NEXT:   S_SETPRIO 3
  ; GFX1150-NEXT:   $vgpr0 = V_OR_B32_e32 3, $vgpr0, implicit $exec
  ; GFX1150-NEXT:   S_SETPRIO 2
  ; GFX1150-NEXT: {{  $}}
  ; GFX1150-NEXT: bb.3:
  ; GFX1150-NEXT:   liveins: $vgpr0
  ; GFX1150-NEXT: {{  $}}
  ; GFX1150-NEXT:   EXP 1, $vgpr0, $vgpr0, $vgpr0, $vgpr0, -1, -1, 15, implicit $exec
  ; GFX1150-NEXT:   EXP_DONE 0, $vgpr0, $vgpr0, $vgpr0, $vgpr0, -1, -1, 15, implicit $exec
  ; GFX1150-NEXT:   S_SETPRIO 0
  ; GFX1150-NEXT:   S_NOP 0
  ; GFX1150-NEXT:   S_NOP 0
  ; GFX1150-NEXT:   S_ENDPGM 0
  bb.0:
    liveins: $vgpr0
    $vgpr0 = V_AND_B32_e32 1, $vgpr0, implicit $exec

  bb.1:
    liveins: $vgpr0
    S_SETPRIO 3
    $vgpr0 = V_OR_B32_e32 2, $vgpr0, implicit $exec
    S_SETPRIO 0

  bb.2:
    liveins: $vgpr0
    S_SETPRIO 1
    $vgpr0 = V_OR_B32_e32 3, $vgpr0, implicit $exec
    S_SETPRIO 0

  bb.3:
    liveins: $vgpr0
    EXP 1, $vgpr0, $vgpr0, $vgpr0, $vgpr0, -1, -1, 15, implicit $exec
    EXP_DONE 0, $vgpr0, $vgpr0, $vgpr0, $vgpr0, -1, -1, 15, implicit $exec
    S_ENDPGM 0
...

---
name: existing_setprio_2
tracksRegLiveness: true
liveins:
  - { reg: '$vgpr0' }
body: |
  bb.0:
    liveins: $vgpr0
    ; GFX1150-LABEL: name: existing_setprio_2
    ; GFX1150: liveins: $vgpr0
    ; GFX1150-NEXT: {{  $}}
    ; GFX1150-NEXT: S_SETPRIO 3
    ; GFX1150-NEXT: EXP 1, $vgpr0, $vgpr0, $vgpr0, $vgpr0, -1, -1, 15, implicit $exec
    ; GFX1150-NEXT: EXP_DONE 0, $vgpr0, $vgpr0, $vgpr0, $vgpr0, -1, -1, 15, implicit $exec
    ; GFX1150-NEXT: S_SETPRIO 0
    ; GFX1150-NEXT: S_WAITCNT_EXPCNT $sgpr_null, 0
    ; GFX1150-NEXT: S_NOP 0
    ; GFX1150-NEXT: S_NOP 0
    ; GFX1150-NEXT: S_SETPRIO 2
    ; GFX1150-NEXT: S_SETPRIO 3
    ; GFX1150-NEXT: S_ENDPGM 0
    S_SETPRIO 3
    EXP 1, $vgpr0, $vgpr0, $vgpr0, $vgpr0, -1, -1, 15, implicit $exec
    EXP_DONE 0, $vgpr0, $vgpr0, $vgpr0, $vgpr0, -1, -1, 15, implicit $exec
    S_SETPRIO 3
    S_ENDPGM 0
...