• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; Ensure that indirect calls work and that they are lowered to some
2; sort of branch and link instruction.
3;
4; RUN: llc < %s -march=mblaze -mattr=+mul,+fpu,+barrel | FileCheck %s
5
6declare i32 @printf(i8*, ...)
7@MSG = internal constant [13 x i8] c"Message: %d\0A\00"
8
9@FUNS = private constant [5 x i32 (i32,i32)*]
10    [ i32 (i32,i32)* @doadd,
11      i32 (i32,i32)* @dosub,
12      i32 (i32,i32)* @domul,
13      i32 (i32,i32)* @dodiv,
14      i32 (i32,i32)* @dorem ]
15
16define i32 @doadd(i32 %a, i32 %b)
17{
18    ; CHECK:        doadd:
19    %tmp.0 = add i32 %a, %b
20    ret i32 %tmp.0
21    ; CHECK:        rtsd
22}
23
24define i32 @dosub(i32 %a, i32 %b)
25{
26    ; CHECK:        dosub:
27    %tmp.0 = sub i32 %a, %b
28    ret i32 %tmp.0
29    ; CHECK:        rtsd
30}
31
32define i32 @domul(i32 %a, i32 %b)
33{
34    ; CHECK:        domul:
35    %tmp.0 = mul i32 %a, %b
36    ret i32 %tmp.0
37    ; CHECK:        rtsd
38}
39
40define i32 @dodiv(i32 %a, i32 %b)
41{
42    ; CHECK:        dodiv:
43    %tmp.0 = sdiv i32 %a, %b
44    ret i32 %tmp.0
45    ; CHECK:        rtsd
46}
47
48define i32 @dorem(i32 %a, i32 %b)
49{
50    ; CHECK:        dorem:
51    %tmp.0 = srem i32 %a, %b
52    ret i32 %tmp.0
53    ; CHECK:        rtsd
54}
55
56define i32 @callind(i32 %a, i32 %b)
57{
58    ; CHECK:        callind:
59entry:
60    br label %loop
61
62loop:
63    %tmp.0 = phi i32 [ 0, %entry ], [ %tmp.3, %loop ]
64    %dst.0 = getelementptr [5 x i32 (i32,i32)*]* @FUNS, i32 0, i32 %tmp.0
65    %dst.1 = load i32 (i32,i32)** %dst.0
66    %tmp.1 = call i32 %dst.1(i32 %a, i32 %b)
67    ; CHECK-NOT:    brli
68    ; CHECK-NOT:    brlai
69    ; CHECK:        brl
70
71    call i32 (i8*,...)* @printf( i8* getelementptr([13 x i8]* @MSG,i32 0,i32 0),
72                                 i32 %tmp.1)
73    ; CHECK:        brl
74
75    %tmp.2 = add i32 %tmp.0, 1
76    %tmp.3 = urem i32 %tmp.2, 5
77
78    br label %loop
79    ; CHECK:        br
80}
81