mirror of https://github.com/llvm/circt.git
[RTG] Sequences are always private (#8792)
This commit is contained in:
parent
964cc8be4f
commit
01a53d4552
|
@ -46,7 +46,7 @@ def ConstantOp : RTGOp<"constant", [
|
|||
|
||||
def SequenceOp : RTGOp<"sequence", [
|
||||
IsolatedFromAbove,
|
||||
Symbol,
|
||||
DeclareOpInterfaceMethods<Symbol, ["getVisibility", "setVisibility"]>,
|
||||
SingleBlock,
|
||||
NoTerminator,
|
||||
HasParent<"mlir::ModuleOp">,
|
||||
|
|
|
@ -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
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
// RUN: circt-opt --symbol-dce %s | FileCheck %s
|
||||
|
||||
// CHECK-NOT: @seq1
|
||||
rtg.sequence @seq1() {
|
||||
rtg.comment "to be removed"
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
add_circt_unittest(CIRCTRTGTests
|
||||
MaterializerTest.cpp
|
||||
OpTests.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(CIRCTRTGTests
|
||||
|
|
|
@ -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…
Reference in New Issue