1// RUN: mlir-opt -emit-bytecode -allow-unregistered-dialect %s | mlir-opt -allow-unregistered-dialect -mlir-print-local-scope | FileCheck %s 2 3//===----------------------------------------------------------------------===// 4// ArrayAttr 5//===----------------------------------------------------------------------===// 6 7// CHECK-LABEL: @TestArray 8module @TestArray attributes { 9 // CHECK: bytecode.array = [unit] 10 bytecode.array = [unit] 11} {} 12 13//===----------------------------------------------------------------------===// 14// DenseArrayAttr 15//===----------------------------------------------------------------------===// 16 17// CHECK-LABEL: @TestDenseArray 18module @TestDenseArray attributes { 19 // CHECK: bytecode.test1 = array<i1: true, false, true, false, false> 20 // CHECK: bytecode.test2 = array<i8: 10, 32, -1> 21 // CHECK: bytecode.test3 = array<f64: 1.{{.*}}e+01, 3.2{{.*}}e+01, 1.809{{.*}}e+03 22 bytecode.test1 = array<i1: true, false, true, false, false>, 23 bytecode.test2 = array<i8: 10, 32, 255>, 24 bytecode.test3 = array<f64: 10.0, 32.0, 1809.0> 25} {} 26 27//===----------------------------------------------------------------------===// 28// DenseIntOfFPElementsAttr 29//===----------------------------------------------------------------------===// 30 31// CHECK-LABEL: @TestDenseIntOrFPElements 32// CHECK: bytecode.test1 = dense<true> : tensor<256xi1> 33// CHECK: bytecode.test2 = dense<[10, 32, -1]> : tensor<3xi8> 34// CHECK: bytecode.test3 = dense<[1.{{.*}}e+01, 3.2{{.*}}e+01, 1.809{{.*}}e+03]> : tensor<3xf64> 35module @TestDenseIntOrFPElements attributes { 36 bytecode.test1 = dense<true> : tensor<256xi1>, 37 bytecode.test2 = dense<[10, 32, 255]> : tensor<3xi8>, 38 bytecode.test3 = dense<[10.0, 32.0, 1809.0]> : tensor<3xf64> 39} {} 40 41//===----------------------------------------------------------------------===// 42// DenseStringElementsAttr 43//===----------------------------------------------------------------------===// 44 45// CHECK-LABEL: @TestDenseStringElementsAttr 46module @TestDenseStringElementsAttr attributes { 47 bytecode.test1 = dense<"splat"> : tensor<256x!bytecode.string>, 48 bytecode.test2 = dense<["foo", "bar", "baz"]> : tensor<3x!bytecode.string> 49} {} 50 51//===----------------------------------------------------------------------===// 52// FloatAttr 53//===----------------------------------------------------------------------===// 54 55// CHECK-LABEL: @TestFloat 56module @TestFloat attributes { 57 // CHECK: bytecode.float = 1.000000e+01 : f64 58 // CHECK: bytecode.float1 = 0.10000{{.*}} : f80 59 // CHECK: bytecode.float2 = 0.10000{{.*}} : f128 60 // CHECK: bytecode.float3 = -5.000000e-01 : bf16 61 bytecode.float = 10.0 : f64, 62 bytecode.float1 = 0.1 : f80, 63 bytecode.float2 = 0.1 : f128, 64 bytecode.float3 = -0.5 : bf16 65} {} 66 67//===----------------------------------------------------------------------===// 68// IntegerAttr 69//===----------------------------------------------------------------------===// 70 71// CHECK-LABEL: @TestInt 72module @TestInt attributes { 73 // CHECK: bytecode.int = false 74 // CHECK: bytecode.int1 = -1 : i8 75 // CHECK: bytecode.int2 = 800 : ui64 76 // CHECK: bytecode.int3 = 90000000000000000300000000000000000001 : i128 77 bytecode.int = false, 78 bytecode.int1 = -1 : i8, 79 bytecode.int2 = 800 : ui64, 80 bytecode.int3 = 90000000000000000300000000000000000001 : i128 81} {} 82 83//===----------------------------------------------------------------------===// 84// SparseElementsAttr 85//===----------------------------------------------------------------------===// 86 87// CHECK-LABEL: @TestSparseElements 88module @TestSparseElements attributes { 89 // CHECK-LITERAL: bytecode.sparse = sparse<[[0, 0], [1, 2]], [1, 5]> : tensor<3x4xi32> 90 bytecode.sparse = sparse<[[0, 0], [1, 2]], [1, 5]> : tensor<3x4xi32> 91} {} 92 93 94//===----------------------------------------------------------------------===// 95// StringAttr 96//===----------------------------------------------------------------------===// 97 98// CHECK-LABEL: @TestString 99module @TestString attributes { 100 // CHECK: bytecode.string = "hello" 101 // CHECK: bytecode.string2 = "hello" : i32 102 bytecode.string = "hello", 103 bytecode.string2 = "hello" : i32 104} {} 105 106//===----------------------------------------------------------------------===// 107// SymbolRefAttr 108//===----------------------------------------------------------------------===// 109 110// CHECK-LABEL: @TestSymbolRef 111module @TestSymbolRef attributes { 112 // CHECK: bytecode.ref = @foo 113 // CHECK: bytecode.ref2 = @foo::@bar::@foo 114 bytecode.ref = @foo, 115 bytecode.ref2 = @foo::@bar::@foo 116} {} 117 118//===----------------------------------------------------------------------===// 119// TypeAttr 120//===----------------------------------------------------------------------===// 121 122// CHECK-LABEL: @TestType 123module @TestType attributes { 124 // CHECK: bytecode.type = i178 125 bytecode.type = i178 126} {} 127 128//===----------------------------------------------------------------------===// 129// DistinctAttr 130//===----------------------------------------------------------------------===// 131 132// CHECK-LABEL: @TestDistinct 133module @TestDistinct attributes { 134 // CHECK: bytecode.distinct = distinct[0]<42 : i32> 135 // CHECK: bytecode.distinct2 = distinct[0]<42 : i32> 136 // CHECK: bytecode.distinct3 = distinct[1]<42 : i32> 137 bytecode.distinct = distinct[0]<42 : i32>, 138 bytecode.distinct2 = distinct[0]<42 : i32>, 139 bytecode.distinct3 = distinct[1]<42 : i32> 140} {} 141 142//===----------------------------------------------------------------------===// 143// CallSiteLoc 144//===----------------------------------------------------------------------===// 145 146// CHECK-LABEL: @TestLocCallSite 147module @TestLocCallSite attributes { 148 // CHECK: bytecode.loc = loc(callsite("foo" at "mysource.cc":10:8)) 149 bytecode.loc = loc(callsite("foo" at "mysource.cc":10:8)) 150} {} 151 152//===----------------------------------------------------------------------===// 153// FileLineColLoc 154//===----------------------------------------------------------------------===// 155 156// CHECK-LABEL: @TestLocFileLineCol 157module @TestLocFileLineCol attributes { 158 // CHECK: bytecode.loc = loc("mysource.cc":10:8) 159 bytecode.loc = loc("mysource.cc":10:8) 160} {} 161 162//===----------------------------------------------------------------------===// 163// FusedLoc 164//===----------------------------------------------------------------------===// 165 166// CHECK-LABEL: @TestLocFused 167module @TestLocFused attributes { 168 // CHECK: bytecode.loc = loc(fused["foo", "mysource.cc":10:8]) 169 // CHECK: bytecode.loc2 = loc(fused<"myPass">["foo", "foo2"]) 170 bytecode.loc = loc(fused["foo", "mysource.cc":10:8]), 171 bytecode.loc2 = loc(fused<"myPass">["foo", "foo2"]) 172} {} 173 174//===----------------------------------------------------------------------===// 175// NameLoc 176//===----------------------------------------------------------------------===// 177 178// CHECK-LABEL: @TestLocName 179module @TestLocName attributes { 180 // CHECK: bytecode.loc = loc("foo") 181 // CHECK: bytecode.loc2 = loc("foo"("mysource.cc":10:8)) 182 bytecode.loc = loc("foo"), 183 bytecode.loc2 = loc("foo"("mysource.cc":10:8)) 184} {} 185 186//===----------------------------------------------------------------------===// 187// UnknownLoc 188//===----------------------------------------------------------------------===// 189 190// CHECK-LABEL: @TestLocUnknown 191module @TestLocUnknown attributes { 192 // CHECK: bytecode.loc = loc(unknown) 193 bytecode.loc = loc(unknown) 194} {} 195