Skip to content

Commit

Permalink
[CAPI][Moore] Remove signedness
Browse files Browse the repository at this point in the history
Update the Moore C API to match changes made to the type system. CI
doesn't build the C API currently, which means these breakages often go
unnoticed.
  • Loading branch information
fabianschuiki committed May 9, 2024
1 parent 3008f9c commit 1a311bb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 31 deletions.
13 changes: 1 addition & 12 deletions include/circt-c/Dialect/Moore.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,6 @@ enum MooreRealKind {
MooreRealTime,
};

enum MooreSign {
/// No sign is explicitly given.
MooreNone,
/// Explicitly marked to be unsigned.
MooreUnsigned,
/// Explicitly marked to be signed.
MooreSigned,
};

/// Create a void type.
MLIR_CAPI_EXPORTED MlirType mooreVoidTypeGet(MlirContext ctx);
/// Create a string type.
Expand All @@ -77,8 +68,7 @@ MLIR_CAPI_EXPORTED MlirType mooreChandleTypeGet(MlirContext ctx);
MLIR_CAPI_EXPORTED MlirType mooreEventTypeGet(MlirContext ctx);
/// Create an int type.
MLIR_CAPI_EXPORTED MlirType mooreIntTypeGet(MlirContext ctx,
enum MooreIntKind kind,
enum MooreSign sign);
enum MooreIntKind kind);
/// Create a `logic` type.
MLIR_CAPI_EXPORTED MlirType mooreIntTypeGetLogic(MlirContext ctx);
/// Create an `int` type.
Expand Down Expand Up @@ -119,7 +109,6 @@ mooreUnpackedQueueDimTypeGetWithBound(MlirType inner, unsigned bound);
/// Create a simple bit-vector type.
MLIR_CAPI_EXPORTED MlirType mooreSimpleBitVectorTypeGet(MlirContext ctx,
bool isFourValued,
bool isSigned,
unsigned size);
/// Checks whether the passed UnpackedType is a four-valued type.
MLIR_CAPI_EXPORTED bool mooreIsFourValuedType(MlirType type);
Expand Down
23 changes: 4 additions & 19 deletions lib/CAPI/Dialect/Moore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,6 @@ MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Moore, moore, MooreDialect)
// Types
//===----------------------------------------------------------------------===//

static std::optional<Sign> convertMooreSign(enum MooreSign sign) {
switch (sign) {
case MooreSign::MooreSigned:
return Sign::Signed;
case MooreSign::MooreUnsigned:
return Sign::Unsigned;
case MooreSign::MooreNone:
return {};
}
llvm_unreachable("All cases should be covered.");
}

static IntType::Kind convertMooreIntKind(enum MooreIntKind kind) {
switch (kind) {
case MooreIntKind::MooreBit:
Expand Down Expand Up @@ -96,10 +84,8 @@ MlirType mooreEventTypeGet(MlirContext ctx) {
}

/// Create an int type.
MlirType mooreIntTypeGet(MlirContext ctx, enum MooreIntKind kind,
enum MooreSign sign) {
return wrap(IntType::get(unwrap(ctx), convertMooreIntKind(kind),
convertMooreSign(sign)));
MlirType mooreIntTypeGet(MlirContext ctx, enum MooreIntKind kind) {
return wrap(IntType::get(unwrap(ctx), convertMooreIntKind(kind)));
}

/// Create a `logic` type.
Expand Down Expand Up @@ -177,10 +163,9 @@ MlirType mooreUnpackedQueueDimTypeGetWithBound(MlirType inner, unsigned bound) {

/// Create a simple bit-vector type.
MlirType mooreSimpleBitVectorTypeGet(MlirContext ctx, bool isFourValued,
bool isSigned, unsigned size) {
unsigned size) {
Domain domain = isFourValued ? Domain::FourValued : Domain::TwoValued;
Sign sign = isSigned ? Sign::Signed : Sign::Unsigned;
return wrap(SimpleBitVectorType(domain, sign, size).getType(unwrap(ctx)));
return wrap(SimpleBitVectorType(domain, size).getType(unwrap(ctx)));
}

/// Checks whether the passed UnpackedType is a four-valued type.
Expand Down

0 comments on commit 1a311bb

Please sign in to comment.