Skip to content

Commit 8e62f65

Browse files
committed
[DCtoHW] Some modules don't have bodies
Check was segfaulting on `hw.module.extern`s since they don't have bodies. Extra check was unnecessary since the argument types should always match the input port types.
1 parent baa4452 commit 8e62f65

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lib/Conversion/DCToHW/DCToHW.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -838,10 +838,8 @@ static bool isDCType(Type type) { return isa<TokenType, ValueType>(type); }
838838
/// Returns true if the given `op` is considered as legal - i.e. it does not
839839
/// contain any dc-typed values.
840840
static bool isLegalOp(Operation *op) {
841-
if (auto funcOp = dyn_cast<HWModuleLike>(op)) {
842-
return llvm::none_of(funcOp.getPortTypes(), isDCType) &&
843-
llvm::none_of(funcOp.getBodyBlock()->getArgumentTypes(), isDCType);
844-
}
841+
if (auto funcOp = dyn_cast<HWModuleLike>(op))
842+
return llvm::none_of(funcOp.getPortTypes(), isDCType);
845843

846844
bool operandsOK = llvm::none_of(op->getOperandTypes(), isDCType);
847845
bool resultsOK = llvm::none_of(op->getResultTypes(), isDCType);

test/Conversion/DCToHW/basic.mlir

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,9 @@ hw.module @merge(in %first : !dc.token, in %second : !dc.token, out token : !dc.
196196
%selected = dc.merge %first, %second
197197
hw.output %selected : !dc.value<i1>
198198
}
199+
200+
// CHECK: hw.module.extern @ext(in %a : i32, out b : i32)
201+
hw.module.extern @ext(in %a : i32, out b : i32)
202+
203+
// CHECK: hw.module.extern @extDC(in %a : !esi.channel<i32>, out b : i32)
204+
hw.module.extern @extDC(in %a : !dc.value<i32>, out b : i32)

0 commit comments

Comments
 (0)