diff --git a/lexers/m/mlir.go b/lexers/m/mlir.go new file mode 100644 index 0000000..137beae --- /dev/null +++ b/lexers/m/mlir.go @@ -0,0 +1,43 @@ +package m + +import ( + . "github.com/alecthomas/chroma" // nolint + "github.com/alecthomas/chroma/lexers/internal" +) + +// MLIR lexer. +var Mlir = internal.Register(MustNewLexer( + &Config{ + Name: "MLIR", + Aliases: []string{"mlir"}, + Filenames: []string{"*.mlir"}, + MimeTypes: []string{"text/x-mlir"}, + }, + Rules{ + "root": { + Include("whitespace"), + {`c?"[^"]*?"`, LiteralString, nil}, + {`\^([-a-zA-Z$._][\w\-$.0-9]*)\s*`, NameLabel, nil}, + {`([\w\d_$.]+)\s*=`, NameLabel, nil}, + Include("keyword"), + {`->`, Punctuation, nil}, + {`@([\w_][\w\d_$.]*)`, NameFunction, nil}, + {`[%#][\w\d_$.]+`, NameVariable, nil}, + {`([1-9?][\d?]*\s*x)+`, LiteralNumber, nil}, + {`0[xX][a-fA-F0-9]+`, LiteralNumber, nil}, + {`-?\d+(?:[.]\d+)?(?:[eE][-+]?\d+(?:[.]\d+)?)?`, LiteralNumber, nil}, + {`[=<>{}\[\]()*.,!:]|x\b`, Punctuation, nil}, + {`[\w\d]*`, Text, nil}, + }, + "whitespace": { + {`(\n|\s)+`, Text, nil}, + {`//.*?\n`, Comment, nil}, + }, + "keyword": { + {Words(``, ``, `constant`, `return`), KeywordType, nil}, + {Words(``, ``, `func`, `loc`, `memref`, `tensor`, `vector`), KeywordType, nil}, + {`bf16|f16|f32|f64|index`, Keyword, nil}, + {`i[1-9]\d*`, Keyword, nil}, + }, + }, +)) diff --git a/lexers/testdata/mlir.actual b/lexers/testdata/mlir.actual new file mode 100644 index 0000000..db86a3f --- /dev/null +++ b/lexers/testdata/mlir.actual @@ -0,0 +1,102 @@ +// CHECK-LABEL: func @func_with_ops(%arg0: f32) { +func @func_with_ops(%a : f32) { + // CHECK: %0 = "getTensor"() : () -> tensor<4x4x?xf32> + %t = "getTensor"() : () -> tensor<4x4x?xvector<10xf32>>> + + %i6 = muli %i2, %i2 : i32 + %t2 = "std.dim"(%t){index = 2} : (tensor<4x4x?xvector<10xf32>>) -> index + %x = "foo"(%a, %a) : (f32,f32) -> (memref<1 x i32, (d0) -> (d0), 4>) + + return +} + +func @count(%x: tensor (i64, i64) + attributes {fruit = "banana"} { + return %x, %x: i64, i64 +} + +func @correct_number_of_regions() { + // CHECK: test.two_region_op + "test.two_region_op"()( + {"work"() : () -> ()}, + {"work"() : () -> ()} + ) : () -> () + return +} + +func @inline_notation() -> i32 { + %1 = "foo"() : () -> i32 loc("foo") + %1p = "foo"() : () -> i32 loc(fused<"myPass">["abc", "de"]) + + // CHECK: constant 4 : index loc(callsite("foo" at "mysource.cc":10:8)) + %2 = constant 4 : index loc(callsite("foo" at "mysource.cc":10:8)) + + affine.for %i0 = 0 to 8 { + } loc(fused["foo", "mysource.cc":10:8]) + + affine.if #set0(%2) { + } loc(fused<"myPass">["foo", "foo2"]) + + return %1 : i32 loc(unknown) +} + +func @simple(i64, i1) -> i64 { +^bb0(%a: i64, %cond: i1): // Code dominated by ^bb0 may refer to %a + cond_br %cond, ^bb1, ^bb2 + +^bb1: + br ^bb3(%a: i64) // Branch passes %a as the argument + +^bb2: + %b = addi %a, %a : i64 + br ^bb3(%b: i64) // Branch passes %b as the argument + +// ^bb3 receives an argument, named %c, from predecessors +// and passes it on to bb4 twice. +^bb3(%c: i64): + br ^bb4(%c, %c : i64, i64) + +^bb4(%d : i64, %e : i64): + %0 = addi %d, %e : i64 + return %0 : i64 +} + +// CHECK-LABEL: func @func_with_ops(%arg0: f32) { +func @func_with_ops(f32) { +^bb0(%a : f32): + %t = "getTensor"() : () -> tensor<4x4x?xf32> + %t2 = "std.dim"(%t){index = 2} : (tensor<4x4x?xf32>) -> index + + %x = "std.addf"(%a, %a) : (f32,f32) -> (f32) // help + + return +} + +func @multiblock() { + return // CHECK: return +^bb1: // CHECK: ^bb1: // no predecessors + br ^bb4 // CHECK: br ^bb3 +^bb2: // CHECK: ^bb2: // pred: ^bb2 + br ^bb2 // CHECK: br ^bb2 +^bb4: // CHECK: ^bb3: // pred: ^bb1 + return // CHECK: return +} + +func @dialect_attribute_with_type() { + "foo.unknown_op"() {foo = #foo.attr : i32} : () -> () +} + +func @inline_notation() -> i32 { + %1 = "foo"() : () -> i32 loc("foo") + + %2 = constant 4 : index loc(callsite("foo" at "mysource.cc":10:8)) + + affine.for %i0 = 0 to 8 { + } loc(fused["foo", "mysource.cc":10:8]) + + affine.if #set0(%2) { + } loc(fused<"myPass">["foo", "foo2"]) + + return %1 : i32 loc(unknown) +} + diff --git a/lexers/testdata/mlir.expected b/lexers/testdata/mlir.expected new file mode 100644 index 0000000..db846a1 --- /dev/null +++ b/lexers/testdata/mlir.expected @@ -0,0 +1,796 @@ +[ + {"type":"Comment","value":"// CHECK-LABEL: func @func_with_ops(%arg0: f32) {\n"}, + {"type":"KeywordType","value":"func"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"@func_with_ops"}, + {"type":"Punctuation","value":"("}, + {"type":"NameVariable","value":"%a"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"f32"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"{"}, + {"type":"Text","value":"\n "}, + {"type":"Comment","value":"// CHECK: %0 = \"getTensor\"() : () -\u003e tensor\u003c4x4x?xf32\u003e\n"}, + {"type":"Text","value":" "}, + {"type":"NameVariable","value":"%t"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"="}, + {"type":"Text","value":" "}, + {"type":"LiteralString","value":"\"getTensor\""}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"-\u003e"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"tensor"}, + {"type":"Punctuation","value":"\u003c"}, + {"type":"LiteralNumber","value":"4x4x?x"}, + {"type":"KeywordType","value":"vector"}, + {"type":"Punctuation","value":"\u003c"}, + {"type":"LiteralNumber","value":"10x"}, + {"type":"Keyword","value":"f32"}, + {"type":"Punctuation","value":"\u003e\u003e\u003e"}, + {"type":"Text","value":"\n\n "}, + {"type":"NameVariable","value":"%i6"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"="}, + {"type":"Text","value":" muli "}, + {"type":"NameVariable","value":"%i2"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"NameVariable","value":"%i2"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"i32"}, + {"type":"Text","value":"\n "}, + {"type":"NameVariable","value":"%t2"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"="}, + {"type":"Text","value":" "}, + {"type":"LiteralString","value":"\"std.dim\""}, + {"type":"Punctuation","value":"("}, + {"type":"NameVariable","value":"%t"}, + {"type":"Punctuation","value":"){"}, + {"type":"NameLabel","value":"index ="}, + {"type":"Text","value":" "}, + {"type":"LiteralNumber","value":"2"}, + {"type":"Punctuation","value":"}"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"("}, + {"type":"KeywordType","value":"tensor"}, + {"type":"Punctuation","value":"\u003c"}, + {"type":"LiteralNumber","value":"4x4x?x"}, + {"type":"KeywordType","value":"vector"}, + {"type":"Punctuation","value":"\u003c"}, + {"type":"LiteralNumber","value":"10x"}, + {"type":"Keyword","value":"f32"}, + {"type":"Punctuation","value":"\u003e\u003e)"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"-\u003e"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"index"}, + {"type":"Text","value":"\n "}, + {"type":"NameVariable","value":"%x"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"="}, + {"type":"Text","value":" "}, + {"type":"LiteralString","value":"\"foo\""}, + {"type":"Punctuation","value":"("}, + {"type":"NameVariable","value":"%a"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"NameVariable","value":"%a"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"("}, + {"type":"Keyword","value":"f32"}, + {"type":"Punctuation","value":","}, + {"type":"Keyword","value":"f32"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"-\u003e"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"("}, + {"type":"KeywordType","value":"memref"}, + {"type":"Punctuation","value":"\u003c"}, + {"type":"LiteralNumber","value":"1 x"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"i32"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"("}, + {"type":"Text","value":"d0"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"-\u003e"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"("}, + {"type":"Text","value":"d0"}, + {"type":"Punctuation","value":"),"}, + {"type":"Text","value":" "}, + {"type":"LiteralNumber","value":"4"}, + {"type":"Punctuation","value":"\u003e)"}, + {"type":"Text","value":"\n\n "}, + {"type":"KeywordType","value":"return"}, + {"type":"Text","value":"\n"}, + {"type":"Punctuation","value":"}"}, + {"type":"Text","value":"\n\n"}, + {"type":"KeywordType","value":"func"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"@count"}, + {"type":"Punctuation","value":"("}, + {"type":"NameVariable","value":"%x"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"tensor"}, + {"type":"Punctuation","value":"\u003c"}, + {"type":"Keyword","value":"i64"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"-\u003e"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"("}, + {"type":"Keyword","value":"i64"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"i64"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n attributes "}, + {"type":"Punctuation","value":"{"}, + {"type":"NameLabel","value":"fruit ="}, + {"type":"Text","value":" "}, + {"type":"LiteralString","value":"\"banana\""}, + {"type":"Punctuation","value":"}"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"{"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordType","value":"return"}, + {"type":"Text","value":" "}, + {"type":"NameVariable","value":"%x"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"NameVariable","value":"%x"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"i64"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"i64"}, + {"type":"Text","value":"\n"}, + {"type":"Punctuation","value":"}"}, + {"type":"Text","value":"\n\n"}, + {"type":"KeywordType","value":"func"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"@correct_number_of_regions"}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"{"}, + {"type":"Text","value":"\n "}, + {"type":"Comment","value":"// CHECK: test.two_region_op\n"}, + {"type":"Text","value":" "}, + {"type":"LiteralString","value":"\"test.two_region_op\""}, + {"type":"Punctuation","value":"()("}, + {"type":"Text","value":"\n "}, + {"type":"Punctuation","value":"{"}, + {"type":"LiteralString","value":"\"work\""}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"-\u003e"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"()},"}, + {"type":"Text","value":"\n "}, + {"type":"Punctuation","value":"{"}, + {"type":"LiteralString","value":"\"work\""}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"-\u003e"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"()}"}, + {"type":"Text","value":"\n "}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"-\u003e"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordType","value":"return"}, + {"type":"Text","value":"\n"}, + {"type":"Punctuation","value":"}"}, + {"type":"Text","value":"\n\n"}, + {"type":"KeywordType","value":"func"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"@inline_notation"}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"-\u003e"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"i32"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"{"}, + {"type":"Text","value":"\n "}, + {"type":"NameVariable","value":"%1"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"="}, + {"type":"Text","value":" "}, + {"type":"LiteralString","value":"\"foo\""}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"-\u003e"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"i32"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"loc"}, + {"type":"Punctuation","value":"("}, + {"type":"LiteralString","value":"\"foo\""}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n "}, + {"type":"NameVariable","value":"%1p"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"="}, + {"type":"Text","value":" "}, + {"type":"LiteralString","value":"\"foo\""}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"-\u003e"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"i32"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"loc"}, + {"type":"Punctuation","value":"("}, + {"type":"Text","value":"fused"}, + {"type":"Punctuation","value":"\u003c"}, + {"type":"LiteralString","value":"\"myPass\""}, + {"type":"Punctuation","value":"\u003e["}, + {"type":"LiteralString","value":"\"abc\""}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"LiteralString","value":"\"de\""}, + {"type":"Punctuation","value":"])"}, + {"type":"Text","value":"\n\n "}, + {"type":"Comment","value":"// CHECK: constant 4 : index loc(callsite(\"foo\" at \"mysource.cc\":10:8))\n"}, + {"type":"Text","value":" "}, + {"type":"NameVariable","value":"%2"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"="}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"constant"}, + {"type":"Text","value":" "}, + {"type":"LiteralNumber","value":"4"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"index"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"loc"}, + {"type":"Punctuation","value":"("}, + {"type":"Text","value":"callsite"}, + {"type":"Punctuation","value":"("}, + {"type":"LiteralString","value":"\"foo\""}, + {"type":"Text","value":" at "}, + {"type":"LiteralString","value":"\"mysource.cc\""}, + {"type":"Punctuation","value":":"}, + {"type":"LiteralNumber","value":"10"}, + {"type":"Punctuation","value":":"}, + {"type":"LiteralNumber","value":"8"}, + {"type":"Punctuation","value":"))"}, + {"type":"Text","value":"\n\n affine"}, + {"type":"Punctuation","value":"."}, + {"type":"Text","value":"for "}, + {"type":"NameVariable","value":"%i0"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"="}, + {"type":"Text","value":" "}, + {"type":"LiteralNumber","value":"0"}, + {"type":"Text","value":" to "}, + {"type":"LiteralNumber","value":"8"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"{"}, + {"type":"Text","value":"\n "}, + {"type":"Punctuation","value":"}"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"loc"}, + {"type":"Punctuation","value":"("}, + {"type":"Text","value":"fused"}, + {"type":"Punctuation","value":"["}, + {"type":"LiteralString","value":"\"foo\""}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"LiteralString","value":"\"mysource.cc\""}, + {"type":"Punctuation","value":":"}, + {"type":"LiteralNumber","value":"10"}, + {"type":"Punctuation","value":":"}, + {"type":"LiteralNumber","value":"8"}, + {"type":"Punctuation","value":"])"}, + {"type":"Text","value":"\n\n affine"}, + {"type":"Punctuation","value":"."}, + {"type":"Text","value":"if "}, + {"type":"NameVariable","value":"#set0"}, + {"type":"Punctuation","value":"("}, + {"type":"NameVariable","value":"%2"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"{"}, + {"type":"Text","value":"\n "}, + {"type":"Punctuation","value":"}"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"loc"}, + {"type":"Punctuation","value":"("}, + {"type":"Text","value":"fused"}, + {"type":"Punctuation","value":"\u003c"}, + {"type":"LiteralString","value":"\"myPass\""}, + {"type":"Punctuation","value":"\u003e["}, + {"type":"LiteralString","value":"\"foo\""}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"LiteralString","value":"\"foo2\""}, + {"type":"Punctuation","value":"])"}, + {"type":"Text","value":"\n\n "}, + {"type":"KeywordType","value":"return"}, + {"type":"Text","value":" "}, + {"type":"NameVariable","value":"%1"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"i32"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"loc"}, + {"type":"Punctuation","value":"("}, + {"type":"Text","value":"unknown"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n"}, + {"type":"Punctuation","value":"}"}, + {"type":"Text","value":"\n\n"}, + {"type":"KeywordType","value":"func"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"@simple"}, + {"type":"Punctuation","value":"("}, + {"type":"Keyword","value":"i64"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"i1"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"-\u003e"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"i64"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"{"}, + {"type":"Text","value":"\n"}, + {"type":"NameLabel","value":"^bb0"}, + {"type":"Punctuation","value":"("}, + {"type":"NameVariable","value":"%a"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"i64"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"NameVariable","value":"%cond"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"i1"}, + {"type":"Punctuation","value":"):"}, + {"type":"Text","value":" "}, + {"type":"Comment","value":"// Code dominated by ^bb0 may refer to %a\n"}, + {"type":"Text","value":" cond_br "}, + {"type":"NameVariable","value":"%cond"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"NameLabel","value":"^bb1"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"NameLabel","value":"^bb2\n\n^bb1"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":"\n br "}, + {"type":"NameLabel","value":"^bb3"}, + {"type":"Punctuation","value":"("}, + {"type":"NameVariable","value":"%a"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"i64"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Comment","value":"// Branch passes %a as the argument\n"}, + {"type":"Text","value":"\n"}, + {"type":"NameLabel","value":"^bb2"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":"\n "}, + {"type":"NameVariable","value":"%b"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"="}, + {"type":"Text","value":" addi "}, + {"type":"NameVariable","value":"%a"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"NameVariable","value":"%a"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"i64"}, + {"type":"Text","value":"\n br "}, + {"type":"NameLabel","value":"^bb3"}, + {"type":"Punctuation","value":"("}, + {"type":"NameVariable","value":"%b"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"i64"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Comment","value":"// Branch passes %b as the argument\n"}, + {"type":"Text","value":"\n"}, + {"type":"Comment","value":"// ^bb3 receives an argument, named %c, from predecessors\n// and passes it on to bb4 twice.\n"}, + {"type":"NameLabel","value":"^bb3"}, + {"type":"Punctuation","value":"("}, + {"type":"NameVariable","value":"%c"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"i64"}, + {"type":"Punctuation","value":"):"}, + {"type":"Text","value":"\n br "}, + {"type":"NameLabel","value":"^bb4"}, + {"type":"Punctuation","value":"("}, + {"type":"NameVariable","value":"%c"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"NameVariable","value":"%c"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"i64"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"i64"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n\n"}, + {"type":"NameLabel","value":"^bb4"}, + {"type":"Punctuation","value":"("}, + {"type":"NameVariable","value":"%d"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"i64"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"NameVariable","value":"%e"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"i64"}, + {"type":"Punctuation","value":"):"}, + {"type":"Text","value":"\n "}, + {"type":"NameVariable","value":"%0"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"="}, + {"type":"Text","value":" addi "}, + {"type":"NameVariable","value":"%d"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"NameVariable","value":"%e"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"i64"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordType","value":"return"}, + {"type":"Text","value":" "}, + {"type":"NameVariable","value":"%0"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"i64"}, + {"type":"Text","value":"\n"}, + {"type":"Punctuation","value":"}"}, + {"type":"Text","value":"\n\n"}, + {"type":"Comment","value":"// CHECK-LABEL: func @func_with_ops(%arg0: f32) {\n"}, + {"type":"KeywordType","value":"func"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"@func_with_ops"}, + {"type":"Punctuation","value":"("}, + {"type":"Keyword","value":"f32"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"{"}, + {"type":"Text","value":"\n"}, + {"type":"NameLabel","value":"^bb0"}, + {"type":"Punctuation","value":"("}, + {"type":"NameVariable","value":"%a"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"f32"}, + {"type":"Punctuation","value":"):"}, + {"type":"Text","value":"\n "}, + {"type":"NameVariable","value":"%t"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"="}, + {"type":"Text","value":" "}, + {"type":"LiteralString","value":"\"getTensor\""}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"-\u003e"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"tensor"}, + {"type":"Punctuation","value":"\u003c"}, + {"type":"LiteralNumber","value":"4x4x?x"}, + {"type":"Keyword","value":"f32"}, + {"type":"Punctuation","value":"\u003e"}, + {"type":"Text","value":"\n "}, + {"type":"NameVariable","value":"%t2"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"="}, + {"type":"Text","value":" "}, + {"type":"LiteralString","value":"\"std.dim\""}, + {"type":"Punctuation","value":"("}, + {"type":"NameVariable","value":"%t"}, + {"type":"Punctuation","value":"){"}, + {"type":"NameLabel","value":"index ="}, + {"type":"Text","value":" "}, + {"type":"LiteralNumber","value":"2"}, + {"type":"Punctuation","value":"}"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"("}, + {"type":"KeywordType","value":"tensor"}, + {"type":"Punctuation","value":"\u003c"}, + {"type":"LiteralNumber","value":"4x4x?x"}, + {"type":"Keyword","value":"f32"}, + {"type":"Punctuation","value":"\u003e)"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"-\u003e"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"index"}, + {"type":"Text","value":"\n\n "}, + {"type":"NameVariable","value":"%x"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"="}, + {"type":"Text","value":" "}, + {"type":"LiteralString","value":"\"std.addf\""}, + {"type":"Punctuation","value":"("}, + {"type":"NameVariable","value":"%a"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"NameVariable","value":"%a"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"("}, + {"type":"Keyword","value":"f32"}, + {"type":"Punctuation","value":","}, + {"type":"Keyword","value":"f32"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"-\u003e"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"("}, + {"type":"Keyword","value":"f32"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Comment","value":"// help\n"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordType","value":"return"}, + {"type":"Text","value":"\n"}, + {"type":"Punctuation","value":"}"}, + {"type":"Text","value":"\n\n"}, + {"type":"KeywordType","value":"func"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"@multiblock"}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"{"}, + {"type":"Text","value":"\n "}, + {"type":"KeywordType","value":"return"}, + {"type":"Text","value":" "}, + {"type":"Comment","value":"// CHECK: return\n"}, + {"type":"NameLabel","value":"^bb1"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Comment","value":"// CHECK: ^bb1: // no predecessors\n"}, + {"type":"Text","value":" br "}, + {"type":"NameLabel","value":"^bb4 "}, + {"type":"Comment","value":"// CHECK: br ^bb3\n"}, + {"type":"NameLabel","value":"^bb2"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Comment","value":"// CHECK: ^bb2: // pred: ^bb2\n"}, + {"type":"Text","value":" br "}, + {"type":"NameLabel","value":"^bb2 "}, + {"type":"Comment","value":"// CHECK: br ^bb2\n"}, + {"type":"NameLabel","value":"^bb4"}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Comment","value":"// CHECK: ^bb3: // pred: ^bb1\n"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"return"}, + {"type":"Text","value":" "}, + {"type":"Comment","value":"// CHECK: return\n"}, + {"type":"Punctuation","value":"}"}, + {"type":"Text","value":"\n\n"}, + {"type":"KeywordType","value":"func"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"@dialect_attribute_with_type"}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"{"}, + {"type":"Text","value":"\n "}, + {"type":"LiteralString","value":"\"foo.unknown_op\""}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"{"}, + {"type":"NameLabel","value":"foo ="}, + {"type":"Text","value":" "}, + {"type":"NameVariable","value":"#foo.attr"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"i32"}, + {"type":"Punctuation","value":"}"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"-\u003e"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":"\n"}, + {"type":"Punctuation","value":"}"}, + {"type":"Text","value":"\n\n"}, + {"type":"KeywordType","value":"func"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"@inline_notation"}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"-\u003e"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"i32"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"{"}, + {"type":"Text","value":"\n "}, + {"type":"NameVariable","value":"%1"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"="}, + {"type":"Text","value":" "}, + {"type":"LiteralString","value":"\"foo\""}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"-\u003e"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"i32"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"loc"}, + {"type":"Punctuation","value":"("}, + {"type":"LiteralString","value":"\"foo\""}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n\n "}, + {"type":"NameVariable","value":"%2"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"="}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"constant"}, + {"type":"Text","value":" "}, + {"type":"LiteralNumber","value":"4"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"index"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"loc"}, + {"type":"Punctuation","value":"("}, + {"type":"Text","value":"callsite"}, + {"type":"Punctuation","value":"("}, + {"type":"LiteralString","value":"\"foo\""}, + {"type":"Text","value":" at "}, + {"type":"LiteralString","value":"\"mysource.cc\""}, + {"type":"Punctuation","value":":"}, + {"type":"LiteralNumber","value":"10"}, + {"type":"Punctuation","value":":"}, + {"type":"LiteralNumber","value":"8"}, + {"type":"Punctuation","value":"))"}, + {"type":"Text","value":"\n\n affine"}, + {"type":"Punctuation","value":"."}, + {"type":"Text","value":"for "}, + {"type":"NameVariable","value":"%i0"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"="}, + {"type":"Text","value":" "}, + {"type":"LiteralNumber","value":"0"}, + {"type":"Text","value":" to "}, + {"type":"LiteralNumber","value":"8"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"{"}, + {"type":"Text","value":"\n "}, + {"type":"Punctuation","value":"}"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"loc"}, + {"type":"Punctuation","value":"("}, + {"type":"Text","value":"fused"}, + {"type":"Punctuation","value":"["}, + {"type":"LiteralString","value":"\"foo\""}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"LiteralString","value":"\"mysource.cc\""}, + {"type":"Punctuation","value":":"}, + {"type":"LiteralNumber","value":"10"}, + {"type":"Punctuation","value":":"}, + {"type":"LiteralNumber","value":"8"}, + {"type":"Punctuation","value":"])"}, + {"type":"Text","value":"\n\n affine"}, + {"type":"Punctuation","value":"."}, + {"type":"Text","value":"if "}, + {"type":"NameVariable","value":"#set0"}, + {"type":"Punctuation","value":"("}, + {"type":"NameVariable","value":"%2"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"{"}, + {"type":"Text","value":"\n "}, + {"type":"Punctuation","value":"}"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"loc"}, + {"type":"Punctuation","value":"("}, + {"type":"Text","value":"fused"}, + {"type":"Punctuation","value":"\u003c"}, + {"type":"LiteralString","value":"\"myPass\""}, + {"type":"Punctuation","value":"\u003e["}, + {"type":"LiteralString","value":"\"foo\""}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"LiteralString","value":"\"foo2\""}, + {"type":"Punctuation","value":"])"}, + {"type":"Text","value":"\n\n "}, + {"type":"KeywordType","value":"return"}, + {"type":"Text","value":" "}, + {"type":"NameVariable","value":"%1"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":":"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"i32"}, + {"type":"Text","value":" "}, + {"type":"KeywordType","value":"loc"}, + {"type":"Punctuation","value":"("}, + {"type":"Text","value":"unknown"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n"}, + {"type":"Punctuation","value":"}"}, + {"type":"Text","value":"\n\n"} +]