Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIRRTL][CAPI] add LayerConvention Enum and Attr #8073

Merged
merged 1 commit into from
Jan 13, 2025
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
11 changes: 11 additions & 0 deletions include/circt-c/Dialect/FIRRTL.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ typedef enum FIRRTLConvention {
FIRRTL_CONVENTION_SCALARIZED,
} FIRRTLConvention;

/// Layer lowering conventions.
// NOLINTNEXTLINE(modernize-use-using)
typedef enum FIRRTLLayerConvention {
FIRRTL_LAYER_CONVENTION_BIND,
FIRRTL_LAYER_CONVENTION_INLINE,
} FIRRTLLayerConvention;

/// Port direction.
// NOLINTNEXTLINE(modernize-use-using)
typedef enum FIRRTLDirection {
Expand Down Expand Up @@ -266,6 +273,10 @@ MLIR_CAPI_EXPORTED MlirType firrtlTypeGetMaskType(MlirType type);
MLIR_CAPI_EXPORTED MlirAttribute
firrtlAttrGetConvention(MlirContext ctx, FIRRTLConvention convention);

/// Creates a LayerConventionAttr with the specified value.
MLIR_CAPI_EXPORTED MlirAttribute
firrtlAttrGetLayerConvention(MlirContext ctx, FIRRTLLayerConvention convention);

/// Creates a DenseBoolArrayAttr with the specified port directions.
MLIR_CAPI_EXPORTED MlirAttribute firrtlAttrGetPortDirs(
MlirContext ctx, size_t count, const FIRRTLDirection *dirs);
Expand Down
16 changes: 16 additions & 0 deletions lib/CAPI/Dialect/FIRRTL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,22 @@ MlirAttribute firrtlAttrGetConvention(MlirContext ctx,
return wrap(ConventionAttr::get(unwrap(ctx), value));
}

MlirAttribute firrtlAttrGetLayerConvention(MlirContext ctx,
FIRRTLLayerConvention convention) {
LayerConvention value;

switch (convention) {
case FIRRTL_LAYER_CONVENTION_BIND:
value = LayerConvention::Bind;
break;
case FIRRTL_LAYER_CONVENTION_INLINE:
value = LayerConvention::Inline;
break;
}

return wrap(LayerConventionAttr::get(unwrap(ctx), value));
}

MlirAttribute firrtlAttrGetPortDirs(MlirContext ctx, size_t count,
const FIRRTLDirection *dirs) {
static_assert(FIRRTL_DIRECTION_IN ==
Expand Down
Loading