195 lines · plain
1// RUN: mlir-opt -emit-bytecode -allow-unregistered-dialect %s | mlir-opt -allow-unregistered-dialect -mlir-print-local-scope | FileCheck %s2 3//===----------------------------------------------------------------------===//4// ArrayAttr5//===----------------------------------------------------------------------===//6 7// CHECK-LABEL: @TestArray8module @TestArray attributes {9 // CHECK: bytecode.array = [unit]10 bytecode.array = [unit]11} {}12 13//===----------------------------------------------------------------------===//14// DenseArrayAttr15//===----------------------------------------------------------------------===//16 17// CHECK-LABEL: @TestDenseArray18module @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+0322 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// DenseIntOfFPElementsAttr29//===----------------------------------------------------------------------===//30 31// CHECK-LABEL: @TestDenseIntOrFPElements32// 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// DenseStringElementsAttr43//===----------------------------------------------------------------------===//44 45// CHECK-LABEL: @TestDenseStringElementsAttr46module @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// FloatAttr53//===----------------------------------------------------------------------===//54 55// CHECK-LABEL: @TestFloat56module @TestFloat attributes {57 // CHECK: bytecode.float = 1.000000e+01 : f6458 // CHECK: bytecode.float1 = 0.10000{{.*}} : f8059 // CHECK: bytecode.float2 = 0.10000{{.*}} : f12860 // CHECK: bytecode.float3 = -5.000000e-01 : bf1661 bytecode.float = 10.0 : f64,62 bytecode.float1 = 0.1 : f80,63 bytecode.float2 = 0.1 : f128,64 bytecode.float3 = -0.5 : bf1665} {}66 67//===----------------------------------------------------------------------===//68// IntegerAttr69//===----------------------------------------------------------------------===//70 71// CHECK-LABEL: @TestInt72module @TestInt attributes {73 // CHECK: bytecode.int = false74 // CHECK: bytecode.int1 = -1 : i875 // CHECK: bytecode.int2 = 800 : ui6476 // CHECK: bytecode.int3 = 90000000000000000300000000000000000001 : i12877 bytecode.int = false,78 bytecode.int1 = -1 : i8,79 bytecode.int2 = 800 : ui64,80 bytecode.int3 = 90000000000000000300000000000000000001 : i12881} {}82 83//===----------------------------------------------------------------------===//84// SparseElementsAttr85//===----------------------------------------------------------------------===//86 87// CHECK-LABEL: @TestSparseElements88module @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// StringAttr96//===----------------------------------------------------------------------===//97 98// CHECK-LABEL: @TestString99module @TestString attributes {100 // CHECK: bytecode.string = "hello"101 // CHECK: bytecode.string2 = "hello" : i32102 bytecode.string = "hello",103 bytecode.string2 = "hello" : i32104} {}105 106//===----------------------------------------------------------------------===//107// SymbolRefAttr108//===----------------------------------------------------------------------===//109 110// CHECK-LABEL: @TestSymbolRef111module @TestSymbolRef attributes {112 // CHECK: bytecode.ref = @foo113 // CHECK: bytecode.ref2 = @foo::@bar::@foo114 bytecode.ref = @foo,115 bytecode.ref2 = @foo::@bar::@foo116} {}117 118//===----------------------------------------------------------------------===//119// TypeAttr120//===----------------------------------------------------------------------===//121 122// CHECK-LABEL: @TestType123module @TestType attributes {124 // CHECK: bytecode.type = i178125 bytecode.type = i178126} {}127 128//===----------------------------------------------------------------------===//129// DistinctAttr130//===----------------------------------------------------------------------===//131 132// CHECK-LABEL: @TestDistinct133module @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// CallSiteLoc144//===----------------------------------------------------------------------===//145 146// CHECK-LABEL: @TestLocCallSite147module @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// FileLineColLoc154//===----------------------------------------------------------------------===//155 156// CHECK-LABEL: @TestLocFileLineCol157module @TestLocFileLineCol attributes {158 // CHECK: bytecode.loc = loc("mysource.cc":10:8)159 bytecode.loc = loc("mysource.cc":10:8)160} {}161 162//===----------------------------------------------------------------------===//163// FusedLoc164//===----------------------------------------------------------------------===//165 166// CHECK-LABEL: @TestLocFused167module @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// NameLoc176//===----------------------------------------------------------------------===//177 178// CHECK-LABEL: @TestLocName179module @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// UnknownLoc188//===----------------------------------------------------------------------===//189 190// CHECK-LABEL: @TestLocUnknown191module @TestLocUnknown attributes {192 // CHECK: bytecode.loc = loc(unknown)193 bytecode.loc = loc(unknown)194} {}195