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
10 changes: 1 addition & 9 deletions include/circt/Dialect/LLHD/LLHDOps.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "circt/Dialect/LLHD/LLHDEnums.h.inc"
#include "circt/Dialect/LLHD/LLHDTypes.h"
#include "circt/Support/LLVM.h"
#include "circt/Support/ProceduralRegionTrait.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/Interfaces/CallInterfaces.h"
#include "mlir/Interfaces/ControlFlowInterfaces.h"
Expand All @@ -32,15 +33,6 @@ namespace llhd {
unsigned getLLHDTypeWidth(Type type);
Type getLLHDElementType(Type type);

/// Signals that an operations regions are procedural.
template <typename ConcreteType>
class ProceduralRegion
: public mlir::OpTrait::TraitBase<ConcreteType, ProceduralRegion> {
static LogicalResult verifyTrait(Operation *op) {
return mlir::OpTrait::impl::verifyNRegions(op, 1);
}
};

void registerDestructableIntegerExternalModel(mlir::DialectRegistry &registry);

} // namespace llhd
Expand Down
5 changes: 1 addition & 4 deletions include/circt/Dialect/LLHD/LLHDOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

include "circt/Dialect/LLHD/LLHDDialect.td"
include "circt/Dialect/LLHD/LLHDTypes.td"
include "circt/Support/ProceduralRegionTrait.td"
include "mlir/IR/EnumAttr.td"
include "mlir/IR/OpAsmInterface.td"
include "mlir/IR/SymbolInterfaces.td"
Expand Down Expand Up @@ -54,10 +55,6 @@ class SmallerOrEqualResultTypeWidthConstraint<string result, string input>
CPred<"llhd::getLLHDTypeWidth($" # result # ".getType()) <= " #
"llhd::getLLHDTypeWidth($" # input # ".getType())">>;

def ProceduralRegion : NativeOpTrait<"ProceduralRegion"> {
let cppNamespace = "::circt::llhd";
}

//===----------------------------------------------------------------------===//
// Constants
//===----------------------------------------------------------------------===//
Expand Down
5 changes: 1 addition & 4 deletions include/circt/Dialect/SV/SV.td
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#ifndef CIRCT_DIALECT_SV_SV
#define CIRCT_DIALECT_SV_SV

include "circt/Support/ProceduralRegionTrait.td"
include "mlir/IR/AttrTypeBase.td"
include "mlir/IR/OpBase.td"
include "mlir/IR/OpAsmInterface.td"
Expand All @@ -25,10 +26,6 @@ include "circt/Dialect/SV/SVDialect.td"
class SVOp<string mnemonic, list<Trait> traits = []> :
Op<SVDialect, mnemonic, traits>;

def ProceduralRegion : NativeOpTrait<"ProceduralRegion"> {
let cppNamespace = "::circt::sv";
}

def ProceduralOp : NativeOpTrait<"ProceduralOp"> {
let cppNamespace = "::circt::sv";
}
Expand Down
10 changes: 1 addition & 9 deletions include/circt/Dialect/SV/SVOps.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "circt/Dialect/SV/SVAttributes.h"
#include "circt/Dialect/SV/SVDialect.h"
#include "circt/Dialect/SV/SVTypes.h"
#include "circt/Support/ProceduralRegionTrait.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/IR/SymbolTable.h"
#include "mlir/Interfaces/CallInterfaces.h"
Expand Down Expand Up @@ -170,15 +171,6 @@ LogicalResult verifyInProceduralRegion(Operation *op);
/// Return true if the specified operation is not in a procedural region.
LogicalResult verifyInNonProceduralRegion(Operation *op);

/// Signals that an operations regions are procedural.
template <typename ConcreteType>
class ProceduralRegion
: public mlir::OpTrait::TraitBase<ConcreteType, ProceduralRegion> {
static LogicalResult verifyTrait(Operation *op) {
return mlir::OpTrait::impl::verifyAtLeastNRegions(op, 1);
}
};

/// This class verifies that the specified op is located in a procedural region.
template <typename ConcreteType>
class ProceduralOp
Expand Down
33 changes: 33 additions & 0 deletions include/circt/Support/ProceduralRegionTrait.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
//
// This header file defines the `ProceduralRegion` trait.
//
//===----------------------------------------------------------------------===//

#ifndef CIRCT_SUPPORT_PROCEDURALREGIONTRAIT_H
#define CIRCT_SUPPORT_PROCEDURALREGIONTRAIT_H

#include "circt/Support/LLVM.h"
#include "mlir/IR/OpDefinition.h"
#include "llvm/Support/LogicalResult.h"

namespace circt {

/// Signals that an operation's regions are procedural.
template <typename ConcreteType>
class ProceduralRegion
: public mlir::OpTrait::TraitBase<ConcreteType, ProceduralRegion> {
static LogicalResult verifyTrait(Operation *op) {
return mlir::OpTrait::impl::verifyNRegions(op, 1);
}
};

} // namespace circt

#endif // CIRCT_SUPPORT_PROCEDURALREGIONTRAIT_H
18 changes: 18 additions & 0 deletions include/circt/Support/ProceduralRegionTrait.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#ifndef CIRCT_SUPPORT_PROCDURALREGIONTRAIT_TD
#define CIRCT_SUPPORT_PROCDURALREGIONTRAIT_TD

include "mlir/IR/OpBase.td"

def ProceduralRegion : NativeOpTrait<"ProceduralRegion"> {
let cppNamespace = "::circt";
}

#endif // CIRCT_SUPPORT_PROCDURALREGIONTRAIT_TD
1 change: 1 addition & 0 deletions lib/Conversion/ExportVerilog/ExportVerilog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "circt/Support/Path.h"
#include "circt/Support/PrettyPrinter.h"
#include "circt/Support/PrettyPrinterHelpers.h"
#include "circt/Support/ProceduralRegionTrait.h"
#include "circt/Support/Version.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
Expand Down
1 change: 1 addition & 0 deletions lib/Conversion/ExportVerilog/PrepareForEmission.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "circt/Dialect/LTL/LTLDialect.h"
#include "circt/Dialect/Verif/VerifDialect.h"
#include "circt/Support/LoweringOptions.h"
#include "circt/Support/ProceduralRegionTrait.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/Interfaces/CallInterfaces.h"
#include "mlir/Pass/Pass.h"
Expand Down
3 changes: 2 additions & 1 deletion lib/Conversion/SimToSV/SimToSV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "circt/Dialect/Sim/SimDialect.h"
#include "circt/Dialect/Sim/SimOps.h"
#include "circt/Support/Namespace.h"
#include "circt/Support/ProceduralRegionTrait.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/DialectImplementation.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
Expand Down Expand Up @@ -398,7 +399,7 @@ static bool moveOpsIntoIfdefGuardsAndProcesses(Operation *rootOp) {
// If there was no pre-existing guard, create one.
if (!block) {
OpBuilder builder(op);
if (op->getParentOp()->hasTrait<sv::ProceduralRegion>())
if (op->getParentOp()->hasTrait<ProceduralRegion>())
block = sv::IfDefProceduralOp::create(
builder, loc, "SYNTHESIS", [] {}, [] {})
.getElseBlock();
Expand Down
5 changes: 3 additions & 2 deletions lib/Dialect/SV/SVOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "circt/Dialect/HW/ModuleImplementation.h"
#include "circt/Dialect/SV/SVAttributes.h"
#include "circt/Support/CustomDirectiveImpl.h"
#include "circt/Support/ProceduralRegionTrait.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Matchers.h"
Expand Down Expand Up @@ -56,14 +57,14 @@ bool sv::isExpression(Operation *op) {
}

LogicalResult sv::verifyInProceduralRegion(Operation *op) {
if (op->getParentOp()->hasTrait<sv::ProceduralRegion>())
if (op->getParentOp()->hasTrait<ProceduralRegion>())
return success();
op->emitError() << op->getName() << " should be in a procedural region";
return failure();
}

LogicalResult sv::verifyInNonProceduralRegion(Operation *op) {
if (!op->getParentOp()->hasTrait<sv::ProceduralRegion>())
if (!op->getParentOp()->hasTrait<ProceduralRegion>())
return success();
op->emitError() << op->getName() << " should be in a non-procedural region";
return failure();
Expand Down
3 changes: 2 additions & 1 deletion lib/Dialect/SV/Transforms/HWCleanup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "circt/Dialect/SV/SVAttributes.h"
#include "circt/Dialect/SV/SVOps.h"
#include "circt/Dialect/SV/SVPasses.h"
#include "circt/Support/ProceduralRegionTrait.h"
#include "mlir/Pass/Pass.h"

namespace circt {
Expand Down Expand Up @@ -144,7 +145,7 @@ void HWCleanupPass::runOnOperation() {
/// Recursively process all of the regions in the specified op, dispatching to
/// graph or procedural processing as appropriate.
void HWCleanupPass::runOnRegionsInOp(Operation &op) {
if (op.hasTrait<sv::ProceduralRegion>()) {
if (op.hasTrait<ProceduralRegion>()) {
for (auto &region : op.getRegions())
runOnProceduralRegion(region);
} else {
Expand Down
3 changes: 2 additions & 1 deletion lib/Dialect/SV/Transforms/HWLegalizeModules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "circt/Dialect/SV/SVOps.h"
#include "circt/Dialect/SV/SVPasses.h"
#include "circt/Support/LoweringOptions.h"
#include "circt/Support/ProceduralRegionTrait.h"
#include "mlir/IR/Builders.h"
#include "mlir/Pass/Pass.h"

Expand Down Expand Up @@ -288,7 +289,7 @@ Value HWLegalizeModulesPass::lowerLookupToCasez(Operation &op, Value input,
// A casez is a procedural operation, so if we're in a
// non-procedural region we need to inject an always_comb
// block.
if (!op.getParentOp()->hasTrait<sv::ProceduralRegion>()) {
if (!op.getParentOp()->hasTrait<ProceduralRegion>()) {
auto alwaysComb = sv::AlwaysCombOp::create(builder, loc);
builder.setInsertionPointToEnd(alwaysComb.getBodyBlock());
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Dialect/Sim/SimOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "circt/Dialect/HW/HWTypes.h"
#include "circt/Dialect/SV/SVOps.h"
#include "circt/Support/CustomDirectiveImpl.h"
#include "circt/Support/ProceduralRegionTrait.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/LLVMIR/LLVMTypes.h"
#include "mlir/IR/PatternMatch.h"
Expand Down Expand Up @@ -639,7 +640,7 @@ LogicalResult PrintFormattedProcOp::verify() {
}

if (isa_and_nonnull<sv::SVDialect>(parentOp->getDialect())) {
if (!parentOp->hasTrait<sv::ProceduralRegion>())
if (!parentOp->hasTrait<ProceduralRegion>())
return emitOpError("must be within a procedural region.");
return success();
}
Expand Down
Loading