• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; Ensure that jump tables can be handled by the mblaze backend. The
2; jump table should be lowered to a "br" instruction using one of the
3; available registers.
4;
5; RUN: llc < %s -march=mblaze | FileCheck %s
6
7define i32 @jmptable(i32 %arg)
8{
9    ; CHECK:        jmptable:
10    switch i32 %arg, label %DEFAULT [ i32 0, label %L0
11                                      i32 1, label %L1
12                                      i32 2, label %L2
13                                      i32 3, label %L3
14                                      i32 4, label %L4
15                                      i32 5, label %L5
16                                      i32 6, label %L6
17                                      i32 7, label %L7
18                                      i32 8, label %L8
19                                      i32 9, label %L9 ]
20
21    ; CHECK:        lw   [[REG:r[0-9]*]]
22    ; CHECK:        brad [[REG]]
23L0:
24    %var0 = add i32 %arg, 0
25    br label %DONE
26
27L1:
28    %var1 = add i32 %arg, 1
29    br label %DONE
30
31L2:
32    %var2 = add i32 %arg, 2
33    br label %DONE
34
35L3:
36    %var3 = add i32 %arg, 3
37    br label %DONE
38
39L4:
40    %var4 = add i32 %arg, 4
41    br label %DONE
42
43L5:
44    %var5 = add i32 %arg, 5
45    br label %DONE
46
47L6:
48    %var6 = add i32 %arg, 6
49    br label %DONE
50
51L7:
52    %var7 = add i32 %arg, 7
53    br label %DONE
54
55L8:
56    %var8 = add i32 %arg, 8
57    br label %DONE
58
59L9:
60    %var9 = add i32 %arg, 9
61    br label %DONE
62
63DEFAULT:
64    unreachable
65
66DONE:
67    %rval = phi i32 [ %var0, %L0 ],
68                    [ %var1, %L1 ],
69                    [ %var2, %L2 ],
70                    [ %var3, %L3 ],
71                    [ %var4, %L4 ],
72                    [ %var5, %L5 ],
73                    [ %var6, %L6 ],
74                    [ %var7, %L7 ],
75                    [ %var8, %L8 ],
76                    [ %var9, %L9 ]
77    ret i32 %rval
78    ; CHECK:        rtsd
79}
80