1 // RUN: mlir-opt %s | mlir-opt | FileCheck %s
3 // CHECK-LABEL: @binary_ops
4 // CHECK-SAME: %[[A:.*]]: index, %[[B:.*]]: index
5 func.func @binary_ops(%a: index, %b: index) {
6 // CHECK-NEXT: index.add %[[A]], %[[B]]
8 // CHECK-NEXT: index.sub %[[A]], %[[B]]
10 // CHECK-NEXT: index.mul %[[A]], %[[B]]
12 // CHECK-NEXT: index.divs %[[A]], %[[B]]
13 %3 = index.divs %a, %b
14 // CHECK-NEXT: index.divu %[[A]], %[[B]]
15 %4 = index.divu %a, %b
16 // CHECK-NEXT: index.ceildivs %[[A]], %[[B]]
17 %5 = index.ceildivs %a, %b
18 // CHECK-NEXT: index.ceildivu %[[A]], %[[B]]
19 %6 = index.ceildivu %a, %b
20 // CHECK-NEXT: index.floordivs %[[A]], %[[B]]
21 %7 = index.floordivs %a, %b
22 // CHECK-NEXT: index.rems %[[A]], %[[B]]
23 %8 = index.rems %a, %b
24 // CHECK-NEXT: index.remu %[[A]], %[[B]]
25 %9 = index.remu %a, %b
26 // CHECK-NEXT: index.maxs %[[A]], %[[B]]
27 %10 = index.maxs %a, %b
28 // CHECK-NEXT: index.maxu %[[A]], %[[B]]
29 %11 = index.maxu %a, %b
30 // CHECK-NEXT: index.shl %[[A]], %[[B]]
31 %12 = index.shl %a, %b
32 // CHECK-NEXT: index.shrs %[[A]], %[[B]]
33 %13 = index.shrs %a, %b
34 // CHECK-NEXT: index.shru %[[A]], %[[B]]
35 %14 = index.shru %a, %b
39 // CHECK-LABEL: @cmp_op
40 // CHECK-SAME: %[[A:.*]]: index, %[[B:.*]]: index
41 func.func @cmp_op(%a: index, %b: index) {
42 // CHECK-NEXT: index.cmp eq(%[[A]], %[[B]])
43 %0 = index.cmp eq(%a, %b)
44 // CHECK-NEXT: index.cmp ne(%[[A]], %[[B]])
45 %1 = index.cmp ne(%a, %b)
46 // CHECK-NEXT: index.cmp slt(%[[A]], %[[B]])
47 %2 = index.cmp slt(%a, %b)
48 // CHECK-NEXT: index.cmp sle(%[[A]], %[[B]])
49 %3 = index.cmp sle(%a, %b)
50 // CHECK-NEXT: index.cmp sgt(%[[A]], %[[B]])
51 %4 = index.cmp sgt(%a, %b)
52 // CHECK-NEXT: index.cmp sge(%[[A]], %[[B]])
53 %5 = index.cmp sge(%a, %b)
54 // CHECK-NEXT: index.cmp ult(%[[A]], %[[B]])
55 %6 = index.cmp ult(%a, %b)
56 // CHECK-NEXT: index.cmp ule(%[[A]], %[[B]])
57 %7 = index.cmp ule(%a, %b)
58 // CHECK-NEXT: index.cmp ugt(%[[A]], %[[B]])
59 %8 = index.cmp ugt(%a, %b)
60 // CHECK-NEXT: index.cmp uge(%[[A]], %[[B]])
61 %9 = index.cmp uge(%a, %b)
65 // CHECK-LABEL: @sizeof_op
66 func.func @sizeof_op() {
67 // CHECK: index.sizeof
72 // CHECK-LABEL: @constant_op
73 func.func @constant_op() {
74 // CHECK-NEXT: index.constant 0
76 // CHECK-NEXT: index.constant 1
78 // CHECK-NEXT: index.constant 42
79 %2 = index.constant 42
83 // CHECK-LABEL: @bool_constant_op
84 func.func @bool_constant_op() {
85 // CHECK-NEXT: index.bool.constant true
86 %0 = index.bool.constant true
87 // CHECK-NEXT: index.bool.constant false
88 %1 = index.bool.constant false
92 // CHECK-LABEL: @cast_op
93 // CHECK-SAME: %[[A:.*]]: index, %[[B:.*]]: i32, %[[C:.*]]: i64
94 func.func @cast_op(%a: index, %b: i32, %c: i64) {
95 // CHECK-NEXT: index.casts %[[A]] : index to i64
96 %0 = index.casts %a : index to i64
97 // CHECK-NEXT: index.casts %[[B]] : i32 to index
98 %1 = index.casts %b : i32 to index
99 // CHECK-NEXT: index.casts %[[C]] : i64 to index
100 %2 = index.casts %c : i64 to index
101 // CHECK-NEXT: index.castu %[[A]] : index to i64
102 %3 = index.castu %a : index to i64
103 // CHECK-NEXT: index.castu %[[B]] : i32 to index
104 %4 = index.castu %b : i32 to index
105 // CHECK-NEXT: index.castu %[[C]] : i64 to index
106 %5 = index.castu %c : i64 to index