Home | History | Annotate | Download | only in ARM
      1 ; RUN: llc < %s -mtriple=armv7-none-linux-gnueabi | FileCheck %s
      2 ; Test that we correctly use registers and align elements when using va_arg
      3 
      4 %struct_t = type { double, double, double }
      5 @static_val = constant %struct_t { double 1.0, double 2.0, double 3.0 }
      6 
      7 declare void @llvm.va_start(i8*) nounwind
      8 declare void @llvm.va_end(i8*) nounwind
      9 
     10 ; CHECK-LABEL: test_byval_8_bytes_alignment:
     11 define void @test_byval_8_bytes_alignment(i32 %i, ...) {
     12 entry:
     13 ; CHECK: stm     r0, {r1, r2, r3}
     14   %g = alloca i8*
     15   %g1 = bitcast i8** %g to i8*
     16   call void @llvm.va_start(i8* %g1)
     17 
     18 ; CHECK: add	[[REG:(r[0-9]+)|(lr)]], {{(r[0-9]+)|(lr)}}, #7
     19 ; CHECK: bfc	[[REG]], #0, #3
     20   %0 = va_arg i8** %g, double
     21   call void @llvm.va_end(i8* %g1)
     22 
     23   ret void
     24 }
     25 
     26 ; CHECK-LABEL: main:
     27 ; CHECK: movw [[BASE:r[0-9]+]], :lower16:static_val
     28 ; CHECK: movt [[BASE]], :upper16:static_val
     29 ; ldm is not formed when the coalescer failed to coalesce everything.
     30 ; CHECK: ldrd    r2, [[TMP:r[0-9]+]], {{\[}}[[BASE]]{{\]}}
     31 ; CHECK: movw r0, #555
     32 define i32 @main() {
     33 entry:
     34   call void (i32, ...)* @test_byval_8_bytes_alignment(i32 555, %struct_t* byval @static_val)
     35   ret i32 0
     36 }
     37 
     38 declare void @f(double);
     39 
     40 ; CHECK-LABEL:     test_byval_8_bytes_alignment_fixed_arg:
     41 ; CHECK-NOT:   str     r1
     42 ; CHECK:       str     r3, [sp, #12]
     43 ; CHECK:       str     r2, [sp, #8]
     44 ; CHECK-NOT:   str     r1
     45 define void @test_byval_8_bytes_alignment_fixed_arg(i32 %n1, %struct_t* byval %val) nounwind {
     46 entry:
     47   %a = getelementptr inbounds %struct_t* %val, i32 0, i32 0
     48   %0 = load double* %a
     49   call void (double)* @f(double %0)
     50   ret void
     51 }
     52 
     53 ; CHECK-LABEL: main_fixed_arg:
     54 ; CHECK: movw [[BASE:r[0-9]+]], :lower16:static_val
     55 ; CHECK: movt [[BASE]], :upper16:static_val
     56 ; ldm is not formed when the coalescer failed to coalesce everything.
     57 ; CHECK: ldrd     r2, [[TMP:r[0-9]+]], {{\[}}[[BASE]]{{\]}}
     58 ; CHECK: movw r0, #555
     59 define i32 @main_fixed_arg() {
     60 entry:
     61   call void (i32, %struct_t*)* @test_byval_8_bytes_alignment_fixed_arg(i32 555, %struct_t* byval @static_val)
     62   ret i32 0
     63 }
     64