1// RUN: mlir-opt %s | mlir-opt | FileCheck %s 2 3// CHECK-LABEL: func @ops 4// CHECK-SAME: (%[[I32:.*]]: !llvm.i32, %[[FLOAT:.*]]: !llvm.float, %[[I8PTR1:.*]]: !llvm.ptr<i8>, %[[I8PTR2:.*]]: !llvm.ptr<i8>, %[[BOOL:.*]]: !llvm.i1) 5func @ops(%arg0: !llvm.i32, %arg1: !llvm.float, 6 %arg2: !llvm.ptr<i8>, %arg3: !llvm.ptr<i8>, 7 %arg4: !llvm.i1) { 8// Integer arithmetic binary operations. 9// 10// CHECK: {{.*}} = llvm.add %[[I32]], %[[I32]] : !llvm.i32 11// CHECK: {{.*}} = llvm.sub %[[I32]], %[[I32]] : !llvm.i32 12// CHECK: {{.*}} = llvm.mul %[[I32]], %[[I32]] : !llvm.i32 13// CHECK: {{.*}} = llvm.udiv %[[I32]], %[[I32]] : !llvm.i32 14// CHECK: {{.*}} = llvm.sdiv %[[I32]], %[[I32]] : !llvm.i32 15// CHECK: {{.*}} = llvm.urem %[[I32]], %[[I32]] : !llvm.i32 16// CHECK: {{.*}} = llvm.srem %[[I32]], %[[I32]] : !llvm.i32 17// CHECK: {{.*}} = llvm.icmp "ne" %[[I32]], %[[I32]] : !llvm.i32 18 %0 = llvm.add %arg0, %arg0 : !llvm.i32 19 %1 = llvm.sub %arg0, %arg0 : !llvm.i32 20 %2 = llvm.mul %arg0, %arg0 : !llvm.i32 21 %3 = llvm.udiv %arg0, %arg0 : !llvm.i32 22 %4 = llvm.sdiv %arg0, %arg0 : !llvm.i32 23 %5 = llvm.urem %arg0, %arg0 : !llvm.i32 24 %6 = llvm.srem %arg0, %arg0 : !llvm.i32 25 %7 = llvm.icmp "ne" %arg0, %arg0 : !llvm.i32 26 27// Floating point binary operations. 28// 29// CHECK: {{.*}} = llvm.fadd %[[FLOAT]], %[[FLOAT]] : !llvm.float 30// CHECK: {{.*}} = llvm.fsub %[[FLOAT]], %[[FLOAT]] : !llvm.float 31// CHECK: {{.*}} = llvm.fmul %[[FLOAT]], %[[FLOAT]] : !llvm.float 32// CHECK: {{.*}} = llvm.fdiv %[[FLOAT]], %[[FLOAT]] : !llvm.float 33// CHECK: {{.*}} = llvm.frem %[[FLOAT]], %[[FLOAT]] : !llvm.float 34 %8 = llvm.fadd %arg1, %arg1 : !llvm.float 35 %9 = llvm.fsub %arg1, %arg1 : !llvm.float 36 %10 = llvm.fmul %arg1, %arg1 : !llvm.float 37 %11 = llvm.fdiv %arg1, %arg1 : !llvm.float 38 %12 = llvm.frem %arg1, %arg1 : !llvm.float 39 40// Memory-related operations. 41// 42// CHECK-NEXT: %[[ALLOCA:.*]] = llvm.alloca %[[I32]] x !llvm.double : (!llvm.i32) -> !llvm.ptr<double> 43// CHECK-NEXT: %[[GEP:.*]] = llvm.getelementptr %[[ALLOCA]][%[[I32]], %[[I32]]] : (!llvm.ptr<double>, !llvm.i32, !llvm.i32) -> !llvm.ptr<double> 44// CHECK-NEXT: %[[VALUE:.*]] = llvm.load %[[GEP]] : !llvm.ptr<double> 45// CHECK-NEXT: llvm.store %[[VALUE]], %[[ALLOCA]] : !llvm.ptr<double> 46// CHECK-NEXT: %{{.*}} = llvm.bitcast %[[ALLOCA]] : !llvm.ptr<double> to !llvm.ptr<i64> 47 %13 = llvm.alloca %arg0 x !llvm.double : (!llvm.i32) -> !llvm.ptr<double> 48 %14 = llvm.getelementptr %13[%arg0, %arg0] : (!llvm.ptr<double>, !llvm.i32, !llvm.i32) -> !llvm.ptr<double> 49 %15 = llvm.load %14 : !llvm.ptr<double> 50 llvm.store %15, %13 : !llvm.ptr<double> 51 %16 = llvm.bitcast %13 : !llvm.ptr<double> to !llvm.ptr<i64> 52 53// Function call-related operations. 54// 55// CHECK: %[[STRUCT:.*]] = llvm.call @foo(%[[I32]]) : (!llvm.i32) -> !llvm.struct<(i32, double, i32)> 56// CHECK: %[[VALUE:.*]] = llvm.extractvalue %[[STRUCT]][0] : !llvm.struct<(i32, double, i32)> 57// CHECK: %[[NEW_STRUCT:.*]] = llvm.insertvalue %[[VALUE]], %[[STRUCT]][2] : !llvm.struct<(i32, double, i32)> 58// CHECK: %[[FUNC:.*]] = llvm.mlir.addressof @foo : !llvm.ptr<func<struct<(i32, double, i32)> (i32)>> 59// CHECK: %{{.*}} = llvm.call %[[FUNC]](%[[I32]]) : (!llvm.i32) -> !llvm.struct<(i32, double, i32)> 60 %17 = llvm.call @foo(%arg0) : (!llvm.i32) -> !llvm.struct<(i32, double, i32)> 61 %18 = llvm.extractvalue %17[0] : !llvm.struct<(i32, double, i32)> 62 %19 = llvm.insertvalue %18, %17[2] : !llvm.struct<(i32, double, i32)> 63 %20 = llvm.mlir.addressof @foo : !llvm.ptr<func<struct<(i32, double, i32)> (i32)>> 64 %21 = llvm.call %20(%arg0) : (!llvm.i32) -> !llvm.struct<(i32, double, i32)> 65 66 67// Terminator operations and their successors. 68// 69// CHECK: llvm.br ^[[BB1:.*]] 70 llvm.br ^bb1 71 72// CHECK: ^[[BB1]] 73^bb1: 74// CHECK: llvm.cond_br %7, ^[[BB2:.*]], ^[[BB1]] 75 llvm.cond_br %7, ^bb2, ^bb1 76 77// CHECK: ^[[BB2]] 78^bb2: 79// CHECK: %{{.*}} = llvm.mlir.undef : !llvm.struct<(i32, double, i32)> 80// CHECK: %{{.*}} = llvm.mlir.constant(42 : i64) : !llvm.i47 81 %22 = llvm.mlir.undef : !llvm.struct<(i32, double, i32)> 82 %23 = llvm.mlir.constant(42) : !llvm.i47 83 84// Misc operations. 85// CHECK: %{{.*}} = llvm.select %{{.*}}, %{{.*}}, %{{.*}} : !llvm.i1, !llvm.i32 86 %24 = llvm.select %7, %0, %1 : !llvm.i1, !llvm.i32 87 88// Integer to pointer and pointer to integer conversions. 89// 90// CHECK: %[[PTR:.*]] = llvm.inttoptr %[[I32]] : !llvm.i32 to !llvm.ptr<i32> 91// CHECK: %{{.*}} = llvm.ptrtoint %[[PTR]] : !llvm.ptr<i32> to !llvm.i32 92 %25 = llvm.inttoptr %arg0 : !llvm.i32 to !llvm.ptr<i32> 93 %26 = llvm.ptrtoint %25 : !llvm.ptr<i32> to !llvm.i32 94 95// Extended and Quad floating point 96// 97// CHECK: %{{.*}} = llvm.fpext %[[FLOAT]] : !llvm.float to !llvm.x86_fp80 98// CHECK: %{{.*}} = llvm.fpext %[[FLOAT]] : !llvm.float to !llvm.fp128 99 %27 = llvm.fpext %arg1 : !llvm.float to !llvm.x86_fp80 100 %28 = llvm.fpext %arg1 : !llvm.float to !llvm.fp128 101 102// CHECK: %{{.*}} = llvm.fneg %[[FLOAT]] : !llvm.float 103 %29 = llvm.fneg %arg1 : !llvm.float 104 105// CHECK: "llvm.intr.sin"(%[[FLOAT]]) : (!llvm.float) -> !llvm.float 106 %30 = "llvm.intr.sin"(%arg1) : (!llvm.float) -> !llvm.float 107 108// CHECK: "llvm.intr.pow"(%[[FLOAT]], %[[FLOAT]]) : (!llvm.float, !llvm.float) -> !llvm.float 109 %31 = "llvm.intr.pow"(%arg1, %arg1) : (!llvm.float, !llvm.float) -> !llvm.float 110 111// CHECK: "llvm.intr.bitreverse"(%{{.*}}) : (!llvm.i32) -> !llvm.i32 112 %32 = "llvm.intr.bitreverse"(%arg0) : (!llvm.i32) -> !llvm.i32 113 114// CHECK: "llvm.intr.ctpop"(%{{.*}}) : (!llvm.i32) -> !llvm.i32 115 %33 = "llvm.intr.ctpop"(%arg0) : (!llvm.i32) -> !llvm.i32 116 117// CHECK: "llvm.intr.memcpy"(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) : (!llvm.ptr<i8>, !llvm.ptr<i8>, !llvm.i32, !llvm.i1) -> () 118 "llvm.intr.memcpy"(%arg2, %arg3, %arg0, %arg4) : (!llvm.ptr<i8>, !llvm.ptr<i8>, !llvm.i32, !llvm.i1) -> () 119 120// CHECK: "llvm.intr.memcpy"(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) : (!llvm.ptr<i8>, !llvm.ptr<i8>, !llvm.i32, !llvm.i1) -> () 121 "llvm.intr.memcpy"(%arg2, %arg3, %arg0, %arg4) : (!llvm.ptr<i8>, !llvm.ptr<i8>, !llvm.i32, !llvm.i1) -> () 122 123// CHECK: %[[SZ:.*]] = llvm.mlir.constant 124 %sz = llvm.mlir.constant(10: i64) : !llvm.i64 125// CHECK: "llvm.intr.memcpy.inline"(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) : (!llvm.ptr<i8>, !llvm.ptr<i8>, !llvm.i64, !llvm.i1) -> () 126 "llvm.intr.memcpy.inline"(%arg2, %arg3, %sz, %arg4) : (!llvm.ptr<i8>, !llvm.ptr<i8>, !llvm.i64, !llvm.i1) -> () 127 128// CHECK: llvm.return 129 llvm.return 130} 131 132// An larger self-contained function. 133// CHECK-LABEL: llvm.func @foo(%{{.*}}: !llvm.i32) -> !llvm.struct<(i32, double, i32)> { 134llvm.func @foo(%arg0: !llvm.i32) -> !llvm.struct<(i32, double, i32)> { 135// CHECK: %[[V0:.*]] = llvm.mlir.constant(3 : i64) : !llvm.i32 136// CHECK: %[[V1:.*]] = llvm.mlir.constant(3 : i64) : !llvm.i32 137// CHECK: %[[V2:.*]] = llvm.mlir.constant(4.200000e+01 : f64) : !llvm.double 138// CHECK: %[[V3:.*]] = llvm.mlir.constant(4.200000e+01 : f64) : !llvm.double 139// CHECK: %[[V4:.*]] = llvm.add %[[V0]], %[[V1]] : !llvm.i32 140// CHECK: %[[V5:.*]] = llvm.mul %[[V4]], %[[V1]] : !llvm.i32 141// CHECK: %[[V6:.*]] = llvm.fadd %[[V2]], %[[V3]] : !llvm.double 142// CHECK: %[[V7:.*]] = llvm.fsub %[[V3]], %[[V6]] : !llvm.double 143// CHECK: %[[V8:.*]] = llvm.mlir.constant(1 : i64) : !llvm.i1 144// CHECK: llvm.cond_br %[[V8]], ^[[BB1:.*]](%[[V4]] : !llvm.i32), ^[[BB2:.*]](%[[V4]] : !llvm.i32) 145 %0 = llvm.mlir.constant(3) : !llvm.i32 146 %1 = llvm.mlir.constant(3) : !llvm.i32 147 %2 = llvm.mlir.constant(4.200000e+01) : !llvm.double 148 %3 = llvm.mlir.constant(4.200000e+01) : !llvm.double 149 %4 = llvm.add %0, %1 : !llvm.i32 150 %5 = llvm.mul %4, %1 : !llvm.i32 151 %6 = llvm.fadd %2, %3 : !llvm.double 152 %7 = llvm.fsub %3, %6 : !llvm.double 153 %8 = llvm.mlir.constant(1) : !llvm.i1 154 llvm.cond_br %8, ^bb1(%4 : !llvm.i32), ^bb2(%4 : !llvm.i32) 155 156// CHECK:^[[BB1]](%[[V9:.*]]: !llvm.i32): 157// CHECK: %[[V10:.*]] = llvm.call @foo(%[[V9]]) : (!llvm.i32) -> !llvm.struct<(i32, double, i32)> 158// CHECK: %[[V11:.*]] = llvm.extractvalue %[[V10]][0] : !llvm.struct<(i32, double, i32)> 159// CHECK: %[[V12:.*]] = llvm.extractvalue %[[V10]][1] : !llvm.struct<(i32, double, i32)> 160// CHECK: %[[V13:.*]] = llvm.extractvalue %[[V10]][2] : !llvm.struct<(i32, double, i32)> 161// CHECK: %[[V14:.*]] = llvm.mlir.undef : !llvm.struct<(i32, double, i32)> 162// CHECK: %[[V15:.*]] = llvm.insertvalue %[[V5]], %[[V14]][0] : !llvm.struct<(i32, double, i32)> 163// CHECK: %[[V16:.*]] = llvm.insertvalue %[[V7]], %[[V15]][1] : !llvm.struct<(i32, double, i32)> 164// CHECK: %[[V17:.*]] = llvm.insertvalue %[[V11]], %[[V16]][2] : !llvm.struct<(i32, double, i32)> 165// CHECK: llvm.return %[[V17]] : !llvm.struct<(i32, double, i32)> 166^bb1(%9: !llvm.i32): 167 %10 = llvm.call @foo(%9) : (!llvm.i32) -> !llvm.struct<(i32, double, i32)> 168 %11 = llvm.extractvalue %10[0] : !llvm.struct<(i32, double, i32)> 169 %12 = llvm.extractvalue %10[1] : !llvm.struct<(i32, double, i32)> 170 %13 = llvm.extractvalue %10[2] : !llvm.struct<(i32, double, i32)> 171 %14 = llvm.mlir.undef : !llvm.struct<(i32, double, i32)> 172 %15 = llvm.insertvalue %5, %14[0] : !llvm.struct<(i32, double, i32)> 173 %16 = llvm.insertvalue %7, %15[1] : !llvm.struct<(i32, double, i32)> 174 %17 = llvm.insertvalue %11, %16[2] : !llvm.struct<(i32, double, i32)> 175 llvm.return %17 : !llvm.struct<(i32, double, i32)> 176 177// CHECK:^[[BB2]](%[[V18:.*]]: !llvm.i32): 178// CHECK: %[[V19:.*]] = llvm.mlir.undef : !llvm.struct<(i32, double, i32)> 179// CHECK: %[[V20:.*]] = llvm.insertvalue %[[V18]], %[[V19]][0] : !llvm.struct<(i32, double, i32)> 180// CHECK: %[[V21:.*]] = llvm.insertvalue %[[V7]], %[[V20]][1] : !llvm.struct<(i32, double, i32)> 181// CHECK: %[[V22:.*]] = llvm.insertvalue %[[V5]], %[[V21]][2] : !llvm.struct<(i32, double, i32)> 182// CHECK: llvm.return %[[V22]] : !llvm.struct<(i32, double, i32)> 183^bb2(%18: !llvm.i32): 184 %19 = llvm.mlir.undef : !llvm.struct<(i32, double, i32)> 185 %20 = llvm.insertvalue %18, %19[0] : !llvm.struct<(i32, double, i32)> 186 %21 = llvm.insertvalue %7, %20[1] : !llvm.struct<(i32, double, i32)> 187 %22 = llvm.insertvalue %5, %21[2] : !llvm.struct<(i32, double, i32)> 188 llvm.return %22 : !llvm.struct<(i32, double, i32)> 189} 190 191// CHECK-LABEL: @casts 192// CHECK-SAME: (%[[I32:.*]]: !llvm.i32, %[[I64:.*]]: !llvm.i64, %[[V4I32:.*]]: !llvm.vec<4 x i32>, %[[V4I64:.*]]: !llvm.vec<4 x i64>, %[[I32PTR:.*]]: !llvm.ptr<i32>) 193func @casts(%arg0: !llvm.i32, %arg1: !llvm.i64, %arg2: !llvm.vec<4 x i32>, 194 %arg3: !llvm.vec<4 x i64>, %arg4: !llvm.ptr<i32>) { 195// CHECK: = llvm.sext %[[I32]] : !llvm.i32 to !llvm.i56 196 %0 = llvm.sext %arg0 : !llvm.i32 to !llvm.i56 197// CHECK: = llvm.zext %[[I32]] : !llvm.i32 to !llvm.i64 198 %1 = llvm.zext %arg0 : !llvm.i32 to !llvm.i64 199// CHECK: = llvm.trunc %[[I64]] : !llvm.i64 to !llvm.i56 200 %2 = llvm.trunc %arg1 : !llvm.i64 to !llvm.i56 201// CHECK: = llvm.sext %[[V4I32]] : !llvm.vec<4 x i32> to !llvm.vec<4 x i56> 202 %3 = llvm.sext %arg2 : !llvm.vec<4 x i32> to !llvm.vec<4 x i56> 203// CHECK: = llvm.zext %[[V4I32]] : !llvm.vec<4 x i32> to !llvm.vec<4 x i64> 204 %4 = llvm.zext %arg2 : !llvm.vec<4 x i32> to !llvm.vec<4 x i64> 205// CHECK: = llvm.trunc %[[V4I64]] : !llvm.vec<4 x i64> to !llvm.vec<4 x i56> 206 %5 = llvm.trunc %arg3 : !llvm.vec<4 x i64> to !llvm.vec<4 x i56> 207// CHECK: = llvm.sitofp %[[I32]] : !llvm.i32 to !llvm.float 208 %6 = llvm.sitofp %arg0 : !llvm.i32 to !llvm.float 209// CHECK: %[[FLOAT:.*]] = llvm.uitofp %[[I32]] : !llvm.i32 to !llvm.float 210 %7 = llvm.uitofp %arg0 : !llvm.i32 to !llvm.float 211// CHECK: = llvm.fptosi %[[FLOAT]] : !llvm.float to !llvm.i32 212 %8 = llvm.fptosi %7 : !llvm.float to !llvm.i32 213// CHECK: = llvm.fptoui %[[FLOAT]] : !llvm.float to !llvm.i32 214 %9 = llvm.fptoui %7 : !llvm.float to !llvm.i32 215// CHECK: = llvm.addrspacecast %[[I32PTR]] : !llvm.ptr<i32> to !llvm.ptr<i32, 2> 216 %10 = llvm.addrspacecast %arg4 : !llvm.ptr<i32> to !llvm.ptr<i32, 2> 217 llvm.return 218} 219 220// CHECK-LABEL: @vect 221func @vect(%arg0: !llvm.vec<4 x float>, %arg1: !llvm.i32, %arg2: !llvm.float) { 222// CHECK: = llvm.extractelement {{.*}} : !llvm.vec<4 x float> 223 %0 = llvm.extractelement %arg0[%arg1 : !llvm.i32] : !llvm.vec<4 x float> 224// CHECK: = llvm.insertelement {{.*}} : !llvm.vec<4 x float> 225 %1 = llvm.insertelement %arg2, %arg0[%arg1 : !llvm.i32] : !llvm.vec<4 x float> 226// CHECK: = llvm.shufflevector {{.*}} [0 : i32, 0 : i32, 0 : i32, 0 : i32, 7 : i32] : !llvm.vec<4 x float>, !llvm.vec<4 x float> 227 %2 = llvm.shufflevector %arg0, %arg0 [0 : i32, 0 : i32, 0 : i32, 0 : i32, 7 : i32] : !llvm.vec<4 x float>, !llvm.vec<4 x float> 228// CHECK: = llvm.mlir.constant(dense<1.000000e+00> : vector<4xf32>) : !llvm.vec<4 x float> 229 %3 = llvm.mlir.constant(dense<1.0> : vector<4xf32>) : !llvm.vec<4 x float> 230 return 231} 232 233// CHECK-LABEL: @alloca 234func @alloca(%size : !llvm.i64) { 235 // CHECK: llvm.alloca %{{.*}} x !llvm.i32 : (!llvm.i64) -> !llvm.ptr<i32> 236 llvm.alloca %size x !llvm.i32 {alignment = 0} : (!llvm.i64) -> (!llvm.ptr<i32>) 237 // CHECK: llvm.alloca %{{.*}} x !llvm.i32 {alignment = 8 : i64} : (!llvm.i64) -> !llvm.ptr<i32> 238 llvm.alloca %size x !llvm.i32 {alignment = 8} : (!llvm.i64) -> (!llvm.ptr<i32>) 239 llvm.return 240} 241 242// CHECK-LABEL: @null 243func @null() { 244 // CHECK: llvm.mlir.null : !llvm.ptr<i8> 245 %0 = llvm.mlir.null : !llvm.ptr<i8> 246 // CHECK: llvm.mlir.null : !llvm.ptr<struct<(ptr<func<void (i32, ptr<func<void ()>>)>>, i64)>> 247 %1 = llvm.mlir.null : !llvm.ptr<struct<(ptr<func<void (i32, ptr<func<void ()>>)>>, i64)>> 248 llvm.return 249} 250 251// CHECK-LABEL: @atomicrmw 252func @atomicrmw(%ptr : !llvm.ptr<float>, %val : !llvm.float) { 253 // CHECK: llvm.atomicrmw fadd %{{.*}}, %{{.*}} unordered : !llvm.float 254 %0 = llvm.atomicrmw fadd %ptr, %val unordered : !llvm.float 255 llvm.return 256} 257 258// CHECK-LABEL: @cmpxchg 259func @cmpxchg(%ptr : !llvm.ptr<i32>, %cmp : !llvm.i32, %new : !llvm.i32) { 260 // CHECK: llvm.cmpxchg %{{.*}}, %{{.*}}, %{{.*}} acq_rel monotonic : !llvm.i32 261 %0 = llvm.cmpxchg %ptr, %cmp, %new acq_rel monotonic : !llvm.i32 262 llvm.return 263} 264 265llvm.mlir.global external constant @_ZTIi() : !llvm.ptr<i8> 266llvm.func @bar(!llvm.ptr<i8>, !llvm.ptr<i8>, !llvm.ptr<i8>) 267llvm.func @__gxx_personality_v0(...) -> !llvm.i32 268 269// CHECK-LABEL: @invokeLandingpad 270llvm.func @invokeLandingpad() -> !llvm.i32 attributes { personality = @__gxx_personality_v0 } { 271// CHECK: %[[a0:.*]] = llvm.mlir.constant(0 : i32) : !llvm.i32 272// CHECK: %{{.*}} = llvm.mlir.constant(3 : i32) : !llvm.i32 273// CHECK: %[[a2:.*]] = llvm.mlir.constant("\01") : !llvm.array<1 x i8> 274// CHECK: %[[a3:.*]] = llvm.mlir.null : !llvm.ptr<ptr<i8>> 275// CHECK: %[[a4:.*]] = llvm.mlir.null : !llvm.ptr<i8> 276// CHECK: %[[a5:.*]] = llvm.mlir.addressof @_ZTIi : !llvm.ptr<ptr<i8>> 277// CHECK: %[[a6:.*]] = llvm.bitcast %[[a5]] : !llvm.ptr<ptr<i8>> to !llvm.ptr<i8> 278// CHECK: %[[a7:.*]] = llvm.mlir.constant(1 : i32) : !llvm.i32 279// CHECK: %[[a8:.*]] = llvm.alloca %[[a7]] x !llvm.i8 : (!llvm.i32) -> !llvm.ptr<i8> 280// CHECK: %{{.*}} = llvm.invoke @foo(%[[a7]]) to ^[[BB2:.*]] unwind ^[[BB1:.*]] : (!llvm.i32) -> !llvm.struct<(i32, double, i32)> 281 %0 = llvm.mlir.constant(0 : i32) : !llvm.i32 282 %1 = llvm.mlir.constant(3 : i32) : !llvm.i32 283 %2 = llvm.mlir.constant("\01") : !llvm.array<1 x i8> 284 %3 = llvm.mlir.null : !llvm.ptr<ptr<i8>> 285 %4 = llvm.mlir.null : !llvm.ptr<i8> 286 %5 = llvm.mlir.addressof @_ZTIi : !llvm.ptr<ptr<i8>> 287 %6 = llvm.bitcast %5 : !llvm.ptr<ptr<i8>> to !llvm.ptr<i8> 288 %7 = llvm.mlir.constant(1 : i32) : !llvm.i32 289 %8 = llvm.alloca %7 x !llvm.i8 : (!llvm.i32) -> !llvm.ptr<i8> 290 %9 = llvm.invoke @foo(%7) to ^bb2 unwind ^bb1 : (!llvm.i32) -> !llvm.struct<(i32, double, i32)> 291 292// CHECK: ^[[BB1]]: 293// CHECK: %[[lp:.*]] = llvm.landingpad cleanup (catch %[[a3]] : !llvm.ptr<ptr<i8>>) (catch %[[a6]] : !llvm.ptr<i8>) (filter %[[a2]] : !llvm.array<1 x i8>) : !llvm.struct<(ptr<i8>, i32)> 294// CHECK: llvm.resume %[[lp]] : !llvm.struct<(ptr<i8>, i32)> 295^bb1: 296 %10 = llvm.landingpad cleanup (catch %3 : !llvm.ptr<ptr<i8>>) (catch %6 : !llvm.ptr<i8>) (filter %2 : !llvm.array<1 x i8>) : !llvm.struct<(ptr<i8>, i32)> 297 llvm.resume %10 : !llvm.struct<(ptr<i8>, i32)> 298 299// CHECK: ^[[BB2]]: 300// CHECK: llvm.return %[[a7]] : !llvm.i32 301^bb2: 302 llvm.return %7 : !llvm.i32 303 304// CHECK: ^[[BB3:.*]]: 305// CHECK: llvm.invoke @bar(%[[a8]], %[[a6]], %[[a4]]) to ^[[BB2]] unwind ^[[BB1]] : (!llvm.ptr<i8>, !llvm.ptr<i8>, !llvm.ptr<i8>) -> () 306^bb3: 307 llvm.invoke @bar(%8, %6, %4) to ^bb2 unwind ^bb1 : (!llvm.ptr<i8>, !llvm.ptr<i8>, !llvm.ptr<i8>) -> () 308 309// CHECK: ^[[BB4:.*]]: 310// CHECK: llvm.return %[[a0]] : !llvm.i32 311^bb4: 312 llvm.return %0 : !llvm.i32 313} 314 315// CHECK-LABEL: @useFreezeOp 316func @useFreezeOp(%arg0: !llvm.i32) { 317 // CHECK: = llvm.freeze %[[ARG0:.*]] : !llvm.i32 318 %0 = llvm.freeze %arg0 : !llvm.i32 319 // CHECK: %[[x:.*]] = llvm.mlir.undef : !llvm.i8 320 %1 = llvm.mlir.undef : !llvm.i8 321 // CHECK: = llvm.freeze %[[x]] : !llvm.i8 322 %2 = llvm.freeze %1 : !llvm.i8 323 return 324} 325 326// CHECK-LABEL: @useFenceInst 327func @useFenceInst() { 328 // CHECK: syncscope("agent") seq_cst 329 llvm.fence syncscope("agent") seq_cst 330 // CHECK: seq_cst 331 llvm.fence syncscope("") seq_cst 332 // CHECK: release 333 llvm.fence release 334 return 335} 336 337// CHECK-LABEL: @useInlineAsm 338llvm.func @useInlineAsm(%arg0: !llvm.i32) { 339 // CHECK: llvm.inline_asm {{.*}} (!llvm.i32) -> !llvm.i8 340 %0 = llvm.inline_asm "bswap $0", "=r,r" %arg0 : (!llvm.i32) -> !llvm.i8 341 342 // CHECK-NEXT: llvm.inline_asm {{.*}} (!llvm.i32, !llvm.i32) -> !llvm.i8 343 %1 = llvm.inline_asm "foo", "bar" %arg0, %arg0 : (!llvm.i32, !llvm.i32) -> !llvm.i8 344 345 // CHECK-NEXT: llvm.inline_asm has_side_effects {{.*}} (!llvm.i32, !llvm.i32) -> !llvm.i8 346 %2 = llvm.inline_asm has_side_effects "foo", "bar" %arg0, %arg0 : (!llvm.i32, !llvm.i32) -> !llvm.i8 347 348 // CHECK-NEXT: llvm.inline_asm is_align_stack {{.*}} (!llvm.i32, !llvm.i32) -> !llvm.i8 349 %3 = llvm.inline_asm is_align_stack "foo", "bar" %arg0, %arg0 : (!llvm.i32, !llvm.i32) -> !llvm.i8 350 351 // CHECK-NEXT: llvm.inline_asm "foo", "=r,=r,r" {{.*}} : (!llvm.i32) -> !llvm.struct<(i8, i8)> 352 %5 = llvm.inline_asm "foo", "=r,=r,r" %arg0 : (!llvm.i32) -> !llvm.struct<(i8, i8)> 353 354 llvm.return 355} 356