Home | History | Annotate | Download | only in ARC
      1 ; RUN: llc -march=arc < %s | FileCheck %s
      2 
      3 
      4 declare i32 @goo1(i32) nounwind
      5 
      6 ; CHECK-LABEL: call1
      7 ; CHECK: bl @goo1
      8 define i32 @call1(i32 %a) nounwind {
      9 entry:
     10   %x = call i32 @goo1(i32 %a)
     11   ret i32 %x
     12 }
     13 
     14 declare i32 @goo2(i32, i32, i32, i32, i32, i32, i32, i32) nounwind
     15 
     16 ; CHECK-LABEL: call2
     17 ; CHECK-DAG: mov %r0, 0
     18 ; CHECK-DAG: mov %r1, 1
     19 ; CHECK-DAG: mov %r2, 2
     20 ; CHECK-DAG: mov %r3, 3
     21 ; CHECK-DAG: mov %r4, 4
     22 ; CHECK-DAG: mov %r5, 5
     23 ; CHECK-DAG: mov %r6, 6
     24 ; CHECK-DAG: mov %r7, 7
     25 ; CHECK: bl @goo2
     26 define i32 @call2() nounwind {
     27 entry:
     28   %x = call i32 @goo2(i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7)
     29   ret i32 %x
     30 }
     31 
     32 declare i32 @goo3(i64, i32, i64) nounwind
     33 ; call goo3(0xEEEEEEEE77777777, 0x55555555, 0xAAAAAAAA33333333)
     34 ; 0xEEEEEEEE == -286331154
     35 ; 0x77777777 == 2004318071
     36 ; 0x55555555 == 1431655765
     37 ; 0xAAAAAAAA == -1431655766
     38 ; 0x33333333 == 858993459
     39 ; CHECK-LABEL: call3
     40 ; CHECK-DAG: mov %r0, 2004318071
     41 ; CHECK-DAG: mov %r1, -286331154
     42 ; CHECK-DAG: mov %r2, 1431655765
     43 ; CHECK-DAG: mov %r3, 858993459
     44 ; CHECK-DAG: mov %r4, -1431655766
     45 ; CHECK: bl @goo3
     46 define i32 @call3() nounwind {
     47 entry:
     48   %x = call i32 @goo3(i64 17216961133457930103,
     49                       i32 1431655765,
     50                       i64 12297829380468716339)
     51   ret i32 %x
     52 }
     53 
     54 declare i64 @goo4()
     55 
     56 ; 64-bit values are returned in r0r1
     57 ; CHECK-LABEL: call4
     58 ; CHECK: bl @goo4
     59 ; CHECK: lsr %r0, %r1, 16
     60 define i32 @call4() nounwind {
     61   %x = call i64 @goo4()
     62   %v1 = lshr i64 %x, 48
     63   %v = trunc i64 %v1 to i32
     64   ret i32 %v
     65 }
     66 
     67 ; 0x0000ffff00ff00ff=281470698455295
     68 ; returned as r0=0x00ff00ff=16711935, r1=0x0000ffff=65535
     69 ; CHECK-LABEL: ret1
     70 ; CHECK-DAG: mov %r1, 65535
     71 ; CHECK-DAG: mov %r0, 16711935
     72 define i64 @ret1() nounwind {
     73   ret i64 281470698455295
     74 }
     75 
     76 @funcptr = external global i32 (i32)*, align 4
     77 ; Indirect calls use JL
     78 ; CHECK-LABEL: call_indirect
     79 ; CHECK-DAG: ld %r[[REG:[0-9]+]], [@funcptr]
     80 ; CHECK-DAG: mov %r0, 12
     81 ; CHECK:     jl [%r[[REG]]]
     82 define i32 @call_indirect(i32 %x) nounwind {
     83   %f = load i32 (i32)*, i32 (i32)** @funcptr, align 4
     84   %call = call i32 %f(i32 12)
     85   %add = add nsw i32 %call, %x
     86   ret i32 %add
     87 }
     88 
     89