Skip to content

Commit bb1dc8a

Browse files
committed
[ImportVerilog] Skip bodies for pure virtual non-void methods
Consolidates A11 branches: agent11/pure-virtual-nonvoid-methods
1 parent 2aaa416 commit bb1dc8a

3 files changed

Lines changed: 31 additions & 0 deletions

File tree

.github/workflows/uploadWheels.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ jobs:
8383
8484
- name: Setup Python
8585
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
86+
with:
87+
python-version: '3.14'
8688

8789
- name: Install cibuildwheel
8890
run: python -m pip install cibuildwheel==3.3.0

lib/Conversion/ImportVerilog/Structure.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,6 +1973,10 @@ Context::defineFunction(const slang::ast::SubroutineSymbol &subroutine) {
19731973
// symbol and calls to it are not eliminated.
19741974
if (subroutine.flags.has(slang::ast::MethodFlags::DPIImport))
19751975
return success();
1976+
// Pure virtual methods only contribute class method declarations and vtable
1977+
// slots. They have no body to define, including for non-void return types.
1978+
if (subroutine.flags.has(slang::ast::MethodFlags::Pure))
1979+
return success();
19761980

19771981
const bool isMethod = (subroutine.thisVar != nullptr);
19781982

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// RUN: circt-translate --import-verilog %s | FileCheck %s
2+
// RUN: circt-verilog --ir-moore %s
3+
// REQUIRES: slang
4+
// UNSUPPORTED: valgrind
5+
6+
// clang-format off
7+
// CHECK-LABEL: moore.class.classdecl @StringBase {
8+
// CHECK: moore.class.methoddecl @text : (!moore.class<@StringBase>) -> !moore.string
9+
// CHECK: }
10+
virtual class StringBase;
11+
pure virtual function string text();
12+
endclass
13+
14+
// CHECK-LABEL: moore.class.classdecl @StringLeaf extends @StringBase {
15+
// CHECK: moore.class.methoddecl @text -> @"StringLeaf::text" : (!moore.class<@StringLeaf>) -> !moore.string
16+
// CHECK: }
17+
// CHECK-LABEL: func.func private @"StringLeaf::text"(%arg0: !moore.class<@StringLeaf>) -> !moore.string {
18+
// CHECK: return
19+
// CHECK: }
20+
class StringLeaf extends StringBase;
21+
virtual function string text();
22+
return "leaf";
23+
endfunction
24+
endclass
25+
// clang-format on

0 commit comments

Comments
 (0)