llvm/llvm/test/CodeGen/AArch64/GlobalISel/legalize-fpmode.mir

# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 2
# RUN: llc -mtriple=aarch64-linux-gnu -run-pass=legalizer %s -o - | FileCheck %s

--- |
  target triple = "aarch64-unknown-linux-gnu"

  declare i32 @llvm.get.fpmode.i32()
  declare void @llvm.set.fpmode.i32(i32)
  declare void @llvm.reset.fpmode()

  define i32 @func_get_fpmode() #0 {
  entry:
    %fpmode = call i32 @llvm.get.fpmode.i32()
    ret i32 %fpmode
  }

  define void @func_set_fpmode(i32 %fpmode) #0 {
  entry:
    call void @llvm.set.fpmode.i32(i32 %fpmode)
    ret void
  }

  define void @func_reset() #0 {
  entry:
    call void @llvm.reset.fpmode()
    ret void
  }

  attributes #0 = { nounwind "use-soft-float"="true" }

...
---
name:            func_get_fpmode
tracksRegLiveness: true
body:             |
  bb.1.entry:
    ; CHECK-LABEL: name: func_get_fpmode
    ; CHECK: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %stack.0
    ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
    ; CHECK-NEXT: $x0 = COPY [[FRAME_INDEX]](p0)
    ; CHECK-NEXT: BL &fegetmode, csr_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit $x0
    ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
    ; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[FRAME_INDEX]](p0) :: (load (s32) from %stack.0)
    ; CHECK-NEXT: $w0 = COPY [[LOAD]](s32)
    ; CHECK-NEXT: RET_ReallyLR implicit $w0
    %0:_(s32) = G_GET_FPMODE
    $w0 = COPY %0(s32)
    RET_ReallyLR implicit $w0

...
---
name:            func_set_fpmode
tracksRegLiveness: true
body:             |
  bb.1.entry:
    liveins: $w0

    ; CHECK-LABEL: name: func_set_fpmode
    ; CHECK: liveins: $w0
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
    ; CHECK-NEXT: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %stack.0
    ; CHECK-NEXT: G_STORE [[COPY]](s32), [[FRAME_INDEX]](p0) :: (store (s32) into %stack.0)
    ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp
    ; CHECK-NEXT: $x0 = COPY [[FRAME_INDEX]](p0)
    ; CHECK-NEXT: BL &fesetmode, csr_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit $x0
    ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp
    ; CHECK-NEXT: RET_ReallyLR
    %0:_(s32) = COPY $w0
    G_SET_FPMODE %0(s32)
    RET_ReallyLR

...
---
name:            func_reset
tracksRegLiveness: true
body:             |
  bb.1.entry:
    ; CHECK-LABEL: name: func_reset
    ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 -1
    ; CHECK-NEXT: [[INTTOPTR:%[0-9]+]]:_(p0) = G_INTTOPTR [[C]](s64)
    ; CHECK-NEXT: $x0 = COPY [[INTTOPTR]](p0)
    ; CHECK-NEXT: TCRETURNdi &fesetmode, 0, csr_aarch64_aapcs, implicit $sp, implicit $x0
    G_RESET_FPMODE
    RET_ReallyLR

...