llvm/llvm/test/CodeGen/AVR/pseudo/LPMBRdZ.mir

# RUN: llc -mtriple=avr -mattr=+lpm -mattr=+lpmx -start-before=greedy %s -o - \
# RUN:     | FileCheck %s
# RUN: llc -mtriple=avr -mattr=+lpm -mattr=-lpmx -start-before=greedy %s -o - \
# RUN:     | FileCheck --check-prefix=NOX %s

# This test checks the expansion of the 8-bit LPMBRdZ pseudo instruction and that
# the register allocator won't use R31R30 as an output register (which would
# lead to undefined behavior).

--- |
  target triple = "avr--"
  define void @test_lpmbrdz() {
  entry:
    ret void
  }
...

---
name:            test_lpmbrdz
tracksRegLiveness: true
body: |
  bb.0.entry:
    liveins: $r31r30

    ; CHECK-LABEL: test_lpmbrdz:
    ; CHECK:       ; %bb.0:
    ; CHECK-NEXT:    lpm r30, Z
    ; CHECK-NEXT:    ret

    ; NOX-LABEL:   test_lpmbrdz
    ; NOX:         ; %bb.0:
    ; NOX-NEXT:      lpm
    ; NOX-NEXT:      mov r30, r0
    ; NOX-NEXT:      ret

    %1:zreg = COPY killed $r31r30
    %2:gpr8 = LPMBRdZ %1, implicit-def dead $r0
    $r30 = COPY %2
    RET implicit $r30
...