From eda599f394b4753c1e363003795b3be755043628 Mon Sep 17 00:00:00 2001 From: Martin Erhart Date: Thu, 12 Dec 2024 19:45:52 +0000 Subject: [PATCH] [RTG][Elaboration] Add support for 'index.add' and 'index.cmp' --- .../circt/Dialect/RTG/Transforms/RTGPasses.td | 2 +- lib/Dialect/RTG/Transforms/CMakeLists.txt | 2 +- .../RTG/Transforms/ElaborationPass.cpp | 161 ++++++++++-- test/Dialect/RTG/Transform/elaboration.mlir | 235 ++++++++++-------- 4 files changed, 284 insertions(+), 116 deletions(-) diff --git a/include/circt/Dialect/RTG/Transforms/RTGPasses.td b/include/circt/Dialect/RTG/Transforms/RTGPasses.td index 6eff4b5be034..a725ad4dd0f1 100644 --- a/include/circt/Dialect/RTG/Transforms/RTGPasses.td +++ b/include/circt/Dialect/RTG/Transforms/RTGPasses.td @@ -29,7 +29,7 @@ def ElaborationPass : Pass<"rtg-elaborate", "mlir::ModuleOp"> { "The seed for any RNG constructs used in the pass.">, ]; - let dependentDialects = ["mlir::arith::ArithDialect"]; + let dependentDialects = ["mlir::index::IndexDialect"]; } #endif // CIRCT_DIALECT_RTG_TRANSFORMS_RTGPASSES_TD diff --git a/lib/Dialect/RTG/Transforms/CMakeLists.txt b/lib/Dialect/RTG/Transforms/CMakeLists.txt index 70dcd46cb5f9..50f47352aefa 100644 --- a/lib/Dialect/RTG/Transforms/CMakeLists.txt +++ b/lib/Dialect/RTG/Transforms/CMakeLists.txt @@ -9,7 +9,7 @@ add_circt_dialect_library(CIRCTRTGTransforms LINK_LIBS PRIVATE CIRCTRTGDialect - MLIRArithDialect + MLIRIndexDialect MLIRIR MLIRPass ) diff --git a/lib/Dialect/RTG/Transforms/ElaborationPass.cpp b/lib/Dialect/RTG/Transforms/ElaborationPass.cpp index 9877fa51a6d8..f783397d7dc3 100644 --- a/lib/Dialect/RTG/Transforms/ElaborationPass.cpp +++ b/lib/Dialect/RTG/Transforms/ElaborationPass.cpp @@ -17,7 +17,8 @@ #include "circt/Dialect/RTG/IR/RTGVisitors.h" #include "circt/Dialect/RTG/Transforms/RTGPasses.h" #include "circt/Support/Namespace.h" -#include "mlir/Dialect/Arith/IR/Arith.h" +#include "mlir/Dialect/Index/IR/IndexDialect.h" +#include "mlir/Dialect/Index/IR/IndexOps.h" #include "mlir/IR/IRMapping.h" #include "mlir/IR/PatternMatch.h" #include "llvm/Support/Debug.h" @@ -85,7 +86,7 @@ namespace { /// The abstract base class for elaborated values. struct ElaboratorValue { public: - enum class ValueKind { Attribute, Set, Bag, Sequence }; + enum class ValueKind { Attribute, Set, Bag, Sequence, Index, Bool }; ElaboratorValue(ValueKind kind) : kind(kind) {} virtual ~ElaboratorValue() {} @@ -144,6 +145,74 @@ class AttributeValue : public ElaboratorValue { const TypedAttr attr; }; +/// Holds an evaluated value of a `IndexType`'d value. +class IndexValue : public ElaboratorValue { +public: + IndexValue(size_t index) : ElaboratorValue(ValueKind::Index), index(index) {} + + // Implement LLVMs RTTI + static bool classof(const ElaboratorValue *val) { + return val->getKind() == ValueKind::Index; + } + + llvm::hash_code getHashValue() const override { + return llvm::hash_value(index); + } + + bool isEqual(const ElaboratorValue &other) const override { + auto *indexValue = dyn_cast(&other); + if (!indexValue) + return false; + + return index == indexValue->index; + } + +#ifndef NDEBUG + void print(llvm::raw_ostream &os) const override { + os << ""; + } +#endif + + size_t getIndex() const { return index; } + +private: + const size_t index; +}; + +/// Holds an evaluated value of an `i1` type'd value. +class BoolValue : public ElaboratorValue { +public: + BoolValue(bool value) : ElaboratorValue(ValueKind::Bool), value(value) {} + + // Implement LLVMs RTTI + static bool classof(const ElaboratorValue *val) { + return val->getKind() == ValueKind::Bool; + } + + llvm::hash_code getHashValue() const override { + return llvm::hash_value(value); + } + + bool isEqual(const ElaboratorValue &other) const override { + auto *val = dyn_cast(&other); + if (!val) + return false; + + return value == val->value; + } + +#ifndef NDEBUG + void print(llvm::raw_ostream &os) const override { + os << ""; + } +#endif + + bool getBool() const { return value; } + +private: + const bool value; +}; + /// Holds an evaluated value of a `SetType`'d value. class SetValue : public ElaboratorValue { public: @@ -366,7 +435,8 @@ class Materializer { OpBuilder builder(block, insertionPoint); return TypeSwitch(val) - .Case([&](auto val) { + .Case([&](auto val) { return visit(val, builder, loc, elabRequests, emitError); }) .Default([](auto val) { @@ -389,13 +459,11 @@ class Materializer { function_ref emitError) { auto attr = val->getAttr(); - // For integer attributes (and arithmetic operations on them) we use the - // arith dialect. - if (isa(attr)) { - Value res = builder.getContext() - ->getLoadedDialect() - ->materializeConstant(builder, attr, attr.getType(), loc) - ->getResult(0); + // For index attributes (and arithmetic operations on them) we use the + // index dialect. + if (auto intAttr = dyn_cast(attr); + intAttr && isa(attr.getType())) { + Value res = builder.create(loc, intAttr); materializedValues[val] = res; return res; } @@ -417,6 +485,22 @@ class Materializer { return res; } + Value visit(IndexValue *val, OpBuilder &builder, Location loc, + std::queue &elabRequests, + function_ref emitError) { + Value res = builder.create(loc, val->getIndex()); + materializedValues[val] = res; + return res; + } + + Value visit(BoolValue *val, OpBuilder &builder, Location loc, + std::queue &elabRequests, + function_ref emitError) { + Value res = builder.create(loc, val->getBool()); + materializedValues[val] = res; + return res; + } + Value visit(SetValue *val, OpBuilder &builder, Location loc, std::queue &elabRequests, function_ref emitError) { @@ -451,7 +535,7 @@ class Materializer { if (iter != integerValues.end()) { materializedWeight = iter->second; } else { - materializedWeight = builder.create( + materializedWeight = builder.create( loc, builder.getIndexAttr(weight)); integerValues[weight] = materializedWeight; } @@ -606,9 +690,8 @@ class Elaborator : public RTGOpVisitor> { // If the multiple is not stored as an AttributeValue, the elaboration // must have already failed earlier (since we don't have // unevaluated/opaque values). - auto *interpMultiple = cast(state.at(multiple)); - uint64_t m = cast(interpMultiple->getAttr()).getInt(); - bag[interpValue] += m; + auto *interpMultiple = cast(state.at(multiple)); + bag[interpValue] += interpMultiple->getIndex(); } internalizeResult(op.getBag(), std::move(bag), op.getType()); @@ -688,6 +771,43 @@ class Elaborator : public RTGOpVisitor> { return DeletionKind::Delete; } + FailureOr visitOp(index::AddOp op) { + size_t lhs = cast(state.at(op.getLhs()))->getIndex(); + size_t rhs = cast(state.at(op.getRhs()))->getIndex(); + internalizeResult(op.getResult(), lhs + rhs); + return DeletionKind::Delete; + } + + FailureOr visitOp(index::CmpOp op) { + size_t lhs = cast(state.at(op.getLhs()))->getIndex(); + size_t rhs = cast(state.at(op.getRhs()))->getIndex(); + bool result; + switch (op.getPred()) { + case index::IndexCmpPredicate::EQ: + result = lhs == rhs; + break; + case index::IndexCmpPredicate::NE: + result = lhs != rhs; + break; + case index::IndexCmpPredicate::ULT: + result = lhs < rhs; + break; + case index::IndexCmpPredicate::ULE: + result = lhs <= rhs; + break; + case index::IndexCmpPredicate::UGT: + result = lhs > rhs; + break; + case index::IndexCmpPredicate::UGE: + result = lhs >= rhs; + break; + default: + return op->emitOpError("elaboration not supported"); + } + internalizeResult(op.getResult(), result); + return DeletionKind::Delete; + } + FailureOr dispatchOpVisitor(Operation *op) { if (op->hasTrait()) { SmallVector result; @@ -700,11 +820,20 @@ class Elaborator : public RTGOpVisitor> { return op->emitError( "only typed attributes supported for constant-like operations"); - internalizeResult(op->getResult(0), attr); + auto intAttr = dyn_cast(attr); + if (intAttr && isa(attr.getType())) + internalizeResult(op->getResult(0), intAttr.getInt()); + else if (intAttr && intAttr.getType().isSignlessInteger(1)) + internalizeResult(op->getResult(0), intAttr.getInt()); + else + internalizeResult(op->getResult(0), attr); + return DeletionKind::Delete; } - return RTGBase::dispatchOpVisitor(op); + return TypeSwitch>(op) + .Case([&](auto op) { return visitOp(op); }) + .Default([&](Operation *op) { return RTGBase::dispatchOpVisitor(op); }); } LogicalResult elaborate(SequenceOp family, SequenceOp dest, diff --git a/test/Dialect/RTG/Transform/elaboration.mlir b/test/Dialect/RTG/Transform/elaboration.mlir index 7330c9a1a14b..d67218d482cf 100644 --- a/test/Dialect/RTG/Transform/elaboration.mlir +++ b/test/Dialect/RTG/Transform/elaboration.mlir @@ -1,109 +1,109 @@ // RUN: circt-opt --rtg-elaborate=seed=0 --split-input-file --verify-diagnostics %s | FileCheck %s -func.func @dummy1(%arg0: i32, %arg1: i32, %arg2: !rtg.set) -> () {return} -func.func @dummy2(%arg0: i32) -> () {return} -func.func @dummy3(%arg0: i64) -> () {return} -func.func @dummy4(%arg0: i32, %arg1: i32, %arg2: !rtg.bag, %arg3: !rtg.bag) -> () {return} -func.func @dummy5(%arg0: index) -> () {return} +func.func @dummy1(%arg0: index, %arg1: index, %arg2: !rtg.set) -> () {return} +func.func @dummy2(%arg0: index) -> () {return} +func.func @dummy3(%arg0: !rtg.sequence) -> () {return} +func.func @dummy4(%arg0: index, %arg1: index, %arg2: !rtg.bag, %arg3: !rtg.bag) -> () {return} +func.func @dummy5(%arg0: i1) -> () {return} // Test the set operations and passing a sequence to another one via argument // CHECK-LABEL: rtg.test @setOperations rtg.test @setOperations : !rtg.dict<> { - // CHECK-NEXT: [[V0:%.+]] = arith.constant 2 : i32 - // CHECK-NEXT: [[V1:%.+]] = arith.constant 3 : i32 - // CHECK-NEXT: [[V2:%.+]] = arith.constant 4 : i32 - // CHECK-NEXT: [[V3:%.+]] = rtg.set_create [[V1]], [[V2]] : i32 + // CHECK-NEXT: [[V0:%.+]] = index.constant 2 + // CHECK-NEXT: [[V1:%.+]] = index.constant 3 + // CHECK-NEXT: [[V2:%.+]] = index.constant 4 + // CHECK-NEXT: [[V3:%.+]] = rtg.set_create [[V1]], [[V2]] : index // CHECK-NEXT: func.call @dummy1([[V0]], [[V1]], [[V3]]) : // CHECK-NEXT: } - %0 = arith.constant 2 : i32 - %1 = arith.constant 3 : i32 - %2 = arith.constant 4 : i32 - %3 = arith.constant 5 : i32 - %set0 = rtg.set_create %0, %1, %0 : i32 - %set1 = rtg.set_create %2, %0 : i32 - %set = rtg.set_union %set0, %set1 : !rtg.set - %4 = rtg.set_select_random %set : !rtg.set {rtg.elaboration_custom_seed = 1} - %new_set = rtg.set_create %3, %4 : i32 - %diff = rtg.set_difference %set, %new_set : !rtg.set - %5 = rtg.set_select_random %diff : !rtg.set {rtg.elaboration_custom_seed = 2} - func.call @dummy1(%4, %5, %diff) : (i32, i32, !rtg.set) -> () + %0 = index.constant 2 + %1 = index.constant 3 + %2 = index.constant 4 + %3 = index.constant 5 + %set0 = rtg.set_create %0, %1, %0 : index + %set1 = rtg.set_create %2, %0 : index + %set = rtg.set_union %set0, %set1 : !rtg.set + %4 = rtg.set_select_random %set : !rtg.set {rtg.elaboration_custom_seed = 1} + %new_set = rtg.set_create %3, %4 : index + %diff = rtg.set_difference %set, %new_set : !rtg.set + %5 = rtg.set_select_random %diff : !rtg.set {rtg.elaboration_custom_seed = 2} + func.call @dummy1(%4, %5, %diff) : (index, index, !rtg.set) -> () } // CHECK-LABEL: rtg.test @bagOperations rtg.test @bagOperations : !rtg.dict<> { - // CHECK-NEXT: [[V0:%.+]] = arith.constant 2 : i32 - // CHECK-NEXT: [[V1:%.+]] = arith.constant 8 : index - // CHECK-NEXT: [[V2:%.+]] = arith.constant 3 : i32 - // CHECK-NEXT: [[V3:%.+]] = arith.constant 7 : index - // CHECK-NEXT: [[V4:%.+]] = rtg.bag_create ([[V1]] x [[V0]], [[V3]] x [[V2]]) : i32 - // CHECK-NEXT: [[V5:%.+]] = rtg.bag_create ([[V1]] x [[V0]]) : i32 + // CHECK-NEXT: [[V0:%.+]] = index.constant 2 + // CHECK-NEXT: [[V1:%.+]] = index.constant 8 + // CHECK-NEXT: [[V2:%.+]] = index.constant 3 + // CHECK-NEXT: [[V3:%.+]] = index.constant 7 + // CHECK-NEXT: [[V4:%.+]] = rtg.bag_create ([[V1]] x [[V0]], [[V3]] x [[V2]]) : index + // CHECK-NEXT: [[V5:%.+]] = rtg.bag_create ([[V1]] x [[V0]]) : index // CHECK-NEXT: func.call @dummy4([[V0]], [[V0]], [[V4]], [[V5]]) : - %multiple = arith.constant 8 : index - %seven = arith.constant 7 : index - %one = arith.constant 1 : index - %0 = arith.constant 2 : i32 - %1 = arith.constant 3 : i32 - %bag0 = rtg.bag_create (%seven x %0, %multiple x %1) : i32 - %bag1 = rtg.bag_create (%one x %0) : i32 - %bag = rtg.bag_union %bag0, %bag1 : !rtg.bag - %2 = rtg.bag_select_random %bag : !rtg.bag {rtg.elaboration_custom_seed = 3} - %new_bag = rtg.bag_create (%one x %2) : i32 - %diff = rtg.bag_difference %bag, %new_bag : !rtg.bag - %3 = rtg.bag_select_random %diff : !rtg.bag {rtg.elaboration_custom_seed = 4} - %diff2 = rtg.bag_difference %bag, %new_bag inf : !rtg.bag - %4 = rtg.bag_select_random %diff2 : !rtg.bag {rtg.elaboration_custom_seed = 5} - func.call @dummy4(%3, %4, %diff, %diff2) : (i32, i32, !rtg.bag, !rtg.bag) -> () + %multiple = index.constant 8 + %seven = index.constant 7 + %one = index.constant 1 + %0 = index.constant 2 + %1 = index.constant 3 + %bag0 = rtg.bag_create (%seven x %0, %multiple x %1) : index + %bag1 = rtg.bag_create (%one x %0) : index + %bag = rtg.bag_union %bag0, %bag1 : !rtg.bag + %2 = rtg.bag_select_random %bag : !rtg.bag {rtg.elaboration_custom_seed = 3} + %new_bag = rtg.bag_create (%one x %2) : index + %diff = rtg.bag_difference %bag, %new_bag : !rtg.bag + %3 = rtg.bag_select_random %diff : !rtg.bag {rtg.elaboration_custom_seed = 4} + %diff2 = rtg.bag_difference %bag, %new_bag inf : !rtg.bag + %4 = rtg.bag_select_random %diff2 : !rtg.bag {rtg.elaboration_custom_seed = 5} + func.call @dummy4(%3, %4, %diff, %diff2) : (index, index, !rtg.bag, !rtg.bag) -> () } // CHECK-LABEL: rtg.test @setSize rtg.test @setSize : !rtg.dict<> { - // CHECK-NEXT: [[C:%.+]] = arith.constant 1 : index - // CHECK-NEXT: func.call @dummy5([[C]]) + // CHECK-NEXT: [[C:%.+]] = index.constant 1 + // CHECK-NEXT: func.call @dummy2([[C]]) // CHECK-NEXT: } - %c5_i32 = arith.constant 5 : i32 - %set = rtg.set_create %c5_i32 : i32 - %size = rtg.set_size %set : !rtg.set - func.call @dummy5(%size) : (index) -> () + %c5 = index.constant 5 + %set = rtg.set_create %c5 : index + %size = rtg.set_size %set : !rtg.set + func.call @dummy2(%size) : (index) -> () } // CHECK-LABEL: rtg.test @bagSize rtg.test @bagSize : !rtg.dict<> { - // CHECK-NEXT: [[C:%.+]] = arith.constant 1 : index - // CHECK-NEXT: func.call @dummy5([[C]]) + // CHECK-NEXT: [[C:%.+]] = index.constant 1 + // CHECK-NEXT: func.call @dummy2([[C]]) // CHECK-NEXT: } - %c8 = arith.constant 8 : index - %c5_i32 = arith.constant 5 : i32 - %bag = rtg.bag_create (%c8 x %c5_i32) : i32 - %size = rtg.bag_unique_size %bag : !rtg.bag - func.call @dummy5(%size) : (index) -> () + %c8 = index.constant 8 + %c5 = index.constant 5 + %bag = rtg.bag_create (%c8 x %c5) : index + %size = rtg.bag_unique_size %bag : !rtg.bag + func.call @dummy2(%size) : (index) -> () } // CHECK-LABEL: @targetTest_target0 -// CHECK: [[V0:%.+]] = arith.constant 0 +// CHECK: [[V0:%.+]] = index.constant 0 // CHECK: func.call @dummy2([[V0]]) : // CHECK-LABEL: @targetTest_target1 -// CHECK: [[V0:%.+]] = arith.constant 1 +// CHECK: [[V0:%.+]] = index.constant 1 // CHECK: func.call @dummy2([[V0]]) : -rtg.test @targetTest : !rtg.dict { -^bb0(%arg0: i32): - func.call @dummy2(%arg0) : (i32) -> () +rtg.test @targetTest : !rtg.dict { +^bb0(%arg0: index): + func.call @dummy2(%arg0) : (index) -> () } // CHECK-NOT: @unmatchedTest -rtg.test @unmatchedTest : !rtg.dict { -^bb0(%arg0: i64): - func.call @dummy3(%arg0) : (i64) -> () +rtg.test @unmatchedTest : !rtg.dict { +^bb0(%arg0: !rtg.sequence): + func.call @dummy3(%arg0) : (!rtg.sequence) -> () } -rtg.target @target0 : !rtg.dict { - %0 = arith.constant 0 : i32 - rtg.yield %0 : i32 +rtg.target @target0 : !rtg.dict { + %0 = index.constant 0 + rtg.yield %0 : index } -rtg.target @target1 : !rtg.dict { - %0 = arith.constant 1 : i32 - rtg.yield %0 : i32 +rtg.target @target1 : !rtg.dict { + %0 = index.constant 1 + rtg.yield %0 : index } // Unused sequences are removed @@ -112,41 +112,41 @@ rtg.sequence @unused {} rtg.sequence @seq0 { ^bb0(%arg0: index): - func.call @dummy5(%arg0) : (index) -> () + func.call @dummy2(%arg0) : (index) -> () } rtg.sequence @seq1 { ^bb0(%arg0: index): %0 = rtg.sequence_closure @seq0(%arg0 : index) - func.call @dummy5(%arg0) : (index) -> () + func.call @dummy2(%arg0) : (index) -> () rtg.invoke_sequence %0 - func.call @dummy5(%arg0) : (index) -> () + func.call @dummy2(%arg0) : (index) -> () } // CHECK-LABEL: rtg.test @nestedSequences rtg.test @nestedSequences : !rtg.dict<> { - // CHECK: arith.constant 0 : index - // CHECK: func.call @dummy5 - // CHECK: func.call @dummy5 - // CHECK: func.call @dummy5 - %0 = arith.constant 0 : index + // CHECK: index.constant 0 + // CHECK: func.call @dummy2 + // CHECK: func.call @dummy2 + // CHECK: func.call @dummy2 + %0 = index.constant 0 %1 = rtg.sequence_closure @seq1(%0 : index) rtg.invoke_sequence %1 } rtg.sequence @seq2 { ^bb0(%arg0: index): - func.call @dummy5(%arg0) : (index) -> () + func.call @dummy2(%arg0) : (index) -> () } // CHECK-LABEL: rtg.test @sameSequenceDifferentArgs rtg.test @sameSequenceDifferentArgs : !rtg.dict<> { - // CHECK: [[C0:%.+]] = arith.constant 0 : index - // CHECK: func.call @dummy5([[C0]]) - // CHECK: [[C1:%.+]] = arith.constant 1 : index - // CHECK: func.call @dummy5([[C1]]) - %0 = arith.constant 0 : index - %1 = arith.constant 1 : index + // CHECK: [[C0:%.+]] = index.constant 0 + // CHECK: func.call @dummy2([[C0]]) + // CHECK: [[C1:%.+]] = index.constant 1 + // CHECK: func.call @dummy2([[C1]]) + %0 = index.constant 0 + %1 = index.constant 1 %2 = rtg.sequence_closure @seq2(%0 : index) %3 = rtg.sequence_closure @seq2(%1 : index) rtg.invoke_sequence %2 @@ -156,18 +156,18 @@ rtg.test @sameSequenceDifferentArgs : !rtg.dict<> { rtg.sequence @seq3 { ^bb0(%arg0: !rtg.set): %0 = rtg.set_select_random %arg0 : !rtg.set // we can't use a custom seed here because it would render the test useless - func.call @dummy5(%0) : (index) -> () + func.call @dummy2(%0) : (index) -> () } // CHECK-LABEL: rtg.test @sequenceClosureFixesRandomization rtg.test @sequenceClosureFixesRandomization : !rtg.dict<> { - // CHECK: %c0 = arith.constant 0 : index - // CHECK: func.call @dummy5(%c0 - // CHECK: %c1 = arith.constant 1 : index - // CHECK: func.call @dummy5(%c1 - // CHECK: func.call @dummy5(%c0 - %0 = arith.constant 0 : index - %1 = arith.constant 1 : index + // CHECK: %idx0 = index.constant 0 + // CHECK: func.call @dummy2(%idx0 + // CHECK: %idx1 = index.constant 1 + // CHECK: func.call @dummy2(%idx1 + // CHECK: func.call @dummy2(%idx0 + %0 = index.constant 0 + %1 = index.constant 1 %2 = rtg.set_create %0, %1 : index %3 = rtg.sequence_closure @seq3(%2 : !rtg.set) %4 = rtg.sequence_closure @seq3(%2 : !rtg.set) @@ -176,28 +176,67 @@ rtg.test @sequenceClosureFixesRandomization : !rtg.dict<> { rtg.invoke_sequence %3 } +// CHECK-LABLE: @indexOps +rtg.test @indexOps : !rtg.dict<> { + // CHECK: [[C:%.+]] = index.constant 2 + // CHECK: [[T:%.+]] = index.bool.constant true + // CHECK: [[F:%.+]] = index.bool.constant false + %0 = index.constant 1 + + // CHECK: func.call @dummy2([[C]]) + %1 = index.add %0, %0 + func.call @dummy2(%1) : (index) -> () + + // CHECK: func.call @dummy5([[T]]) + %2 = index.cmp eq(%0, %0) + func.call @dummy5(%2) : (i1) -> () + + // CHECK: func.call @dummy5([[F]]) + %3 = index.cmp ne(%0, %0) + func.call @dummy5(%3) : (i1) -> () + + // CHECK: func.call @dummy5([[F]]) + %4 = index.cmp ult(%0, %0) + func.call @dummy5(%4) : (i1) -> () + + // CHECK: func.call @dummy5([[T]]) + %5 = index.cmp ule(%0, %0) + func.call @dummy5(%5) : (i1) -> () + + // CHECK: func.call @dummy5([[F]]) + %6 = index.cmp ugt(%0, %0) + func.call @dummy5(%6) : (i1) -> () + + // CHECK: func.call @dummy5([[T]]) + %7 = index.cmp uge(%0, %0) + func.call @dummy5(%7) : (i1) -> () + + %8 = index.bool.constant true + // CHECK: func.call @dummy5([[T]]) + func.call @dummy5(%8) : (i1) -> () +} + // ----- rtg.test @nestedRegionsNotSupported : !rtg.dict<> { - %cond = arith.constant false // expected-error @below {{nested regions not supported}} - scf.if %cond { } + scf.execute_region { scf.yield } } // ----- rtg.test @untypedAttributes : !rtg.dict<> { // expected-error @below {{only typed attributes supported for constant-like operations}} - %0 = rtgtest.constant_test i32 {value = [10 : i32]} + %0 = rtgtest.constant_test index {value = [10 : index]} } // ----- -func.func @dummy(%arg0: i32) {return} +func.func @dummy(%arg0: index) {return} rtg.test @untypedAttributes : !rtg.dict<> { - %0 = rtgtest.constant_test i32 {value = "str"} + %0 = rtgtest.constant_test index {value = "str"} // expected-error @below {{materializer of dialect 'builtin' unable to materialize value for attribute '"str"'}} // expected-note @below {{while materializing value for operand#0}} - func.call @dummy(%0) : (i32) -> () + func.call @dummy(%0) : (index) -> () }