blob: 689577a700244037a92a4d731a36744f57fcaefe [file] [log] [blame]
Amaury Sechete8ea7d82016-02-04 23:26:19 +00001; RUN: llvm-as < %s | llvm-dis > %t.orig
2; RUN: llvm-as < %s | llvm-c-test --echo > %t.echo
Reid Kleckner6da91152016-02-05 18:21:28 +00003; RUN: diff -w %t.orig %t.echo
Amaury Sechete8ea7d82016-02-04 23:26:19 +00004
Amaury Sechet55909672016-02-16 05:11:24 +00005target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
6target triple = "x86_64-apple-macosx10.11.0"
7
Amaury Sechetaad93532016-02-10 00:38:50 +00008%S = type { i64, %S* }
9
Amaury Sechete8ba2bf2016-02-17 22:13:33 +000010@var = global i32 42
11@ext = external global i32*
12@cst = constant %S { i64 1, %S* @cst }
13@tl = thread_local global { i64, %S* } { i64 1, %S* @cst }
Amaury Sechetb3256862016-03-13 00:58:25 +000014@arr = linkonce_odr global [5 x i8] [ i8 2, i8 3, i8 5, i8 7, i8 11 ]
15@str = private unnamed_addr constant [13 x i8] c"hello world\0A\00"
Amaury Sechete8ba2bf2016-02-17 22:13:33 +000016@hidden = hidden global i32 7
17@protected = protected global i32 23
18@section = global i32 27, section ".custom"
19@align = global i32 31, align 4
20
Amaury Sechetaad93532016-02-10 00:38:50 +000021define { i64, %S* } @unpackrepack(%S %s) {
22 %1 = extractvalue %S %s, 0
23 %2 = extractvalue %S %s, 1
24 %3 = insertvalue { i64, %S* } undef, %S* %2, 1
25 %4 = insertvalue { i64, %S* } %3, i64 %1, 0
26 ret { i64, %S* } %4
27}
28
Amaury Sechete8ea7d82016-02-04 23:26:19 +000029declare void @decl()
30
Amaury Sechetaad93532016-02-10 00:38:50 +000031; TODO: label and metadata types
Amaury Sechete8ea7d82016-02-04 23:26:19 +000032define void @types() {
33 %1 = alloca half
34 %2 = alloca float
35 %3 = alloca double
36 %4 = alloca x86_fp80
37 %5 = alloca fp128
38 %6 = alloca ppc_fp128
39 %7 = alloca i7
40 %8 = alloca void (i1)*
41 %9 = alloca [3 x i22]
42 %10 = alloca i328 addrspace(5)*
43 %11 = alloca <5 x i23*>
44 %12 = alloca x86_mmx
45 ret void
46}
47
Amaury Sechetb6df4352016-02-05 01:27:11 +000048define i32 @iops(i32 %a, i32 %b) {
Amaury Sechete8ea7d82016-02-04 23:26:19 +000049 %1 = add i32 %a, %b
Amaury Sechetb6df4352016-02-05 01:27:11 +000050 %2 = mul i32 %a, %1
51 %3 = sub i32 %2, %1
52 %4 = udiv i32 %3, %b
53 %5 = sdiv i32 %2, %4
54 %6 = urem i32 %3, %5
55 %7 = srem i32 %2, %6
56 %8 = shl i32 %1, %b
57 %9 = lshr i32 %a, %7
58 %10 = ashr i32 %b, %8
59 %11 = and i32 %9, %10
60 %12 = or i32 %2, %11
61 %13 = xor i32 %12, %4
62 ret i32 %13
Amaury Sechete8ea7d82016-02-04 23:26:19 +000063}
64
65define i32 @call() {
Amaury Sechetb6df4352016-02-05 01:27:11 +000066 %1 = call i32 @iops(i32 23, i32 19)
Amaury Sechete8ea7d82016-02-04 23:26:19 +000067 ret i32 %1
68}
Amaury Secheta82042e2016-02-09 22:36:41 +000069
Amaury Sechete7e62172016-02-09 23:15:02 +000070define i32 @cond(i32 %a, i32 %b) {
Amaury Secheta82042e2016-02-09 22:36:41 +000071 br label %br
72unreachable:
73 unreachable
74br:
Amaury Sechete7e62172016-02-09 23:15:02 +000075 %1 = icmp eq i32 %a, %b
76 br i1 %1, label %next0, label %unreachable
77next0:
78 %2 = icmp ne i32 %a, %b
79 br i1 %2, label %next1, label %unreachable
80next1:
81 %3 = icmp ugt i32 %a, %b
82 br i1 %3, label %next2, label %unreachable
83next2:
84 %4 = icmp uge i32 %a, %b
85 br i1 %4, label %next3, label %unreachable
86next3:
87 %5 = icmp ult i32 %a, %b
88 br i1 %5, label %next4, label %unreachable
89next4:
90 %6 = icmp ule i32 %a, %b
91 br i1 %6, label %next5, label %unreachable
92next5:
93 %7 = icmp sgt i32 %a, %b
94 br i1 %7, label %next6, label %unreachable
95next6:
96 %8 = icmp sge i32 %a, %b
97 br i1 %8, label %next7, label %unreachable
98next7:
99 %9 = icmp slt i32 %a, %b
100 br i1 %9, label %next8, label %unreachable
101next8:
102 %10 = icmp sle i32 %a, %b
103 br i1 %10, label %next9, label %unreachable
104next9:
105 ret i32 0
Amaury Secheta82042e2016-02-09 22:36:41 +0000106}
Amaury Sechet2f432082016-02-11 21:37:54 +0000107
108define i32 @loop(i32 %i) {
109 br label %cond
110cond:
111 %c = phi i32 [ %i, %0 ], [ %j, %do ]
112 %p = phi i32 [ %r, %do ], [ 789, %0 ]
113 %1 = icmp eq i32 %c, 0
114 br i1 %1, label %do, label %done
115do:
116 %2 = sub i32 %p, 23
117 %j = sub i32 %i, 1
118 %r = mul i32 %2, 3
119 br label %cond
120done:
121 ret i32 %p
122}