systemc-clang
systemc-clang copied to clipboard
A case for generating constructors with only initialization list
In https://github.com/intel/systemc-compiler/blob/main/tests/method/test_const_static_mem.cpp#L94 .
// Constant static members, constant records
struct Simple {
bool a;
sc_uint<4> b;
Simple(bool a, sc_uint<4> b) : a(a), b(b)
{}
};
...
const Simple mrec1{false, 4};
const Simple mrec2{false, 5};
...
Currently, given class Simple
, no constructor is generated, potential because there is nothing in the constructor.
Instead, we have the following code generated for mrec1 and mrec2.
hVardecl mrec1_scclang_global_2 [
hTypeinfo NONAME [
hType Simple_ NOLIST
]
hVarInit NONAME [
hLiteral 0 NOLIST
hLiteral 4 NOLIST
]
]
hVardecl mrec2_scclang_global_3 [
hTypeinfo NONAME [
hType Simple_ NOLIST
]
hVarInit NONAME [
hLiteral 0 NOLIST
hLiteral 5 NOLIST
]
]
hTypedef Simple_ [
hTypeField a [
hType bool NOLIST
]
hTypeField b [
hType sc_uint [
hLiteral 4 NOLIST
]
]
]
While it is possible that we generate assignments in the Python backend, we don't have enough information to guarantee correct assignments. Consider changing the variable declaration in C++ into:
// Constant static members, constant records
struct Simple {
bool a;
sc_uint<4> b;
Simple(sc_uint<4> b, bool a) : a(a), b(b)
{}
};
const Simple mrec1{4, false};
We currently do not have information to map 4 to b
.
Check if Simple/mrec1 is not at the global level