Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/circt/Dialect/RTG/IR/RTGOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def ConstantOp : RTGOp<"constant", [

def SequenceOp : RTGOp<"sequence", [
IsolatedFromAbove,
Symbol,
DeclareOpInterfaceMethods<Symbol, ["getVisibility", "setVisibility"]>,
SingleBlock,
NoTerminator,
HasParent<"mlir::ModuleOp">,
Expand Down
9 changes: 9 additions & 0 deletions lib/Dialect/RTG/IR/RTGOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ void SequenceOp::print(OpAsmPrinter &p) {
p.printRegion(getBodyRegion(), /*printEntryBlockArgs=*/false);
}

mlir::SymbolTable::Visibility SequenceOp::getVisibility() {
return mlir::SymbolTable::Visibility::Private;
}

void SequenceOp::setVisibility(mlir::SymbolTable::Visibility visibility) {
// Do nothing, always private.
assert(false && "cannot change visibility of sequence");
}

//===----------------------------------------------------------------------===//
// GetSequenceOp
//===----------------------------------------------------------------------===//
Expand Down
6 changes: 6 additions & 0 deletions test/Dialect/RTG/Transform/sequence-dce.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// RUN: circt-opt --symbol-dce %s | FileCheck %s

// CHECK-NOT: @seq1
rtg.sequence @seq1() {
rtg.comment "to be removed"
}
1 change: 1 addition & 0 deletions unittests/Dialect/RTG/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
add_circt_unittest(CIRCTRTGTests
MaterializerTest.cpp
OpTests.cpp
)

target_link_libraries(CIRCTRTGTests
Expand Down
34 changes: 34 additions & 0 deletions unittests/Dialect/RTG/OpTests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "circt/Dialect/RTG/IR/RTGDialect.h"
#include "circt/Dialect/RTG/IR/RTGOps.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
#include "gtest/gtest.h"

using namespace mlir;
using namespace circt;
using namespace rtg;

namespace {

TEST(SequenceTests, Visibility) {
MLIRContext context;
context.loadDialect<RTGDialect>();
Location loc(UnknownLoc::get(&context));
auto moduleOp = ModuleOp::create(loc);
OpBuilder builder = OpBuilder::atBlockBegin(moduleOp.getBody());
auto sequence =
SequenceOp::create(builder, loc, "seq", SequenceType::get(&context, {}));

ASSERT_TRUE(sequence.isPrivate());
ASSERT_TRUE(sequence.canDiscardOnUseEmpty());
}

} // namespace
Loading