Home | History | Annotate | Download | only in SPARC
      1 ; RUN: llc -march=sparc  < %s | FileCheck %s
      2 
      3 ;; Ensure that spills and reloads work for various types on
      4 ;; sparcv8.
      5 
      6 ;; For i32/i64 tests, use an asm statement which clobbers most
      7 ;; registers to ensure the spill will happen.
      8 
      9 ; CHECK-LABEL: test_i32_spill:
     10 ; CHECK:       and %i0, %i1, %o0
     11 ; CHECK:       st %o0, [%fp+{{.+}}]
     12 ; CHECK:       add %o0, %o0, %g0
     13 ; CHECK:       ld [%fp+{{.+}}, %i0
     14 define i32 @test_i32_spill(i32 %a, i32 %b) {
     15 entry:
     16   %r0 = and i32 %a, %b
     17   ; The clobber list has all registers except g0/o0. (Only o0 is usable.)
     18   %0 = call i32 asm sideeffect "add $0,$1,%g0", "=r,0,~{i0},~{i1},~{i2},~{i3},~{i4},~{i5},~{i6},~{i7},~{g1},~{g2},~{g3},~{g4},~{g5},~{g6},~{g7},~{l0},~{l1},~{l2},~{l3},~{l4},~{l5},~{l6},~{l7},~{o1},~{o2},~{o3},~{o4},~{o5},~{o6},~{o7}"(i32 %r0)
     19   ret i32 %r0
     20 }
     21 
     22 ; CHECK-LABEL: test_i64_spill:
     23 ; CHECK:       and %i0, %i2, %o0
     24 ; CHECK:       and %i1, %i3, %o1
     25 ; CHECK:       std %o0, [%fp+{{.+}}]
     26 ; CHECK:       add %o0, %o0, %g0
     27 ; CHECK:       ldd [%fp+{{.+}}, %i0
     28 define i64 @test_i64_spill(i64 %a, i64 %b) {
     29 entry:
     30   %r0 = and i64 %a, %b
     31   ; The clobber list has all registers except g0,g1,o0,o1. (Only o0/o1 are a usable pair)
     32   ; So, o0/o1 must be used.
     33   %0 = call i64 asm sideeffect "add $0,$1,%g0", "=r,0,~{i0},~{i1},~{i2},~{i3},~{i4},~{i5},~{i6},~{i7},~{g2},~{g3},~{g4},~{g5},~{g6},~{g7},~{l0},~{l1},~{l2},~{l3},~{l4},~{l5},~{l6},~{l7},~{o2},~{o3},~{o4},~{o5},~{o7}"(i64 %r0)
     34   ret i64 %r0
     35 }
     36 
     37 ;; For float/double tests, a call is a suitable clobber as *all* FPU
     38 ;; registers are caller-save on sparcv8.
     39 
     40 ; CHECK-LABEL: test_float_spill:
     41 ; CHECK:       fadds %f1, %f0, [[R:%[f][0-31]]]
     42 ; CHECK:       st [[R]], [%fp+{{.+}}]
     43 ; CHECK:       call
     44 ; CHECK:       ld [%fp+{{.+}}, %f0
     45 declare float @foo_float(float)
     46 define float @test_float_spill(float %a, float %b) {
     47 entry:
     48   %r0 = fadd float %a, %b
     49   %0 = call float @foo_float(float %r0)
     50   ret float %r0
     51 }
     52 
     53 ; CHECK-LABEL: test_double_spill:
     54 ; CHECK:       faddd %f2, %f0, [[R:%[f][0-31]]]
     55 ; CHECK:       std [[R]], [%fp+{{.+}}]
     56 ; CHECK:       call
     57 ; CHECK:       ldd [%fp+{{.+}}, %f0
     58 declare double @foo_double(double)
     59 define double @test_double_spill(double %a, double %b) {
     60 entry:
     61   %r0 = fadd double %a, %b
     62   %0 = call double @foo_double(double %r0)
     63   ret double %r0
     64 }
     65