Skip to content

Commit

Permalink
Merge pull request chipsalliance#3793 from alainmarcel/alainmarcel-pa…
Browse files Browse the repository at this point in the history
…tch-1

file and package struct decl
  • Loading branch information
alaindargelas authored Aug 7, 2023
2 parents 1fe8e84 + dbfcb05 commit 801fa58
Show file tree
Hide file tree
Showing 11 changed files with 1,308 additions and 64 deletions.
23 changes: 22 additions & 1 deletion include/Surelog/DesignCompile/CompileFileContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,25 @@ class Design;
class SymbolTable;
class ErrorContainer;

struct FunctorCompileFileContentDecl {
FunctorCompileFileContentDecl(CompileDesign* compiler, FileContent* file,
Design* design, SymbolTable* symbols,
ErrorContainer* errors)
: m_compileDesign(compiler),
m_fileContent(file),
m_design(design),
m_symbols(symbols),
m_errors(errors) {}
int32_t operator()() const;

private:
CompileDesign* const m_compileDesign;
FileContent* const m_fileContent;
Design* const m_design;
SymbolTable* const m_symbols;
ErrorContainer* const m_errors;
};

struct FunctorCompileFileContent {
FunctorCompileFileContent(CompileDesign* compiler, FileContent* file,
Design* design, SymbolTable* symbols,
Expand All @@ -58,9 +77,10 @@ class CompileFileContent final {
public:
CompileFileContent(CompileDesign* compiler, FileContent* file,
Design* design,
bool declOnly,
[[maybe_unused]] SymbolTable* symbols,
[[maybe_unused]] ErrorContainer* errors)
: m_compileDesign(compiler), m_fileContent(file), m_design(design) {
: m_compileDesign(compiler), m_fileContent(file), m_design(design), m_declOnly(declOnly) {
m_helper.seterrorReporting(errors, symbols);
}

Expand All @@ -75,6 +95,7 @@ class CompileFileContent final {
Design* const m_design;

CompileHelper m_helper;
bool m_declOnly = false;
};

} // namespace SURELOG
Expand Down
3 changes: 3 additions & 0 deletions src/DesignCompile/CompileDesign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ bool CompileDesign::compilation_() {
compileMT_<FileContent, Design::FileIdDesignContentMap, FunctorResolve>(
all_files, maxThreadCount);

compileMT_<FileContent, Design::FileIdDesignContentMap,
FunctorCompileFileContentDecl>(all_files, maxThreadCount);

collectObjects_(all_files, design, false);
m_compiler->getDesign()->orderPackages();

Expand Down
102 changes: 62 additions & 40 deletions src/DesignCompile/CompileFileContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,17 @@

namespace SURELOG {

int32_t FunctorCompileFileContentDecl::operator()() const {
CompileFileContent* instance = new CompileFileContent(
m_compileDesign, m_fileContent, m_design, true, m_symbols, m_errors);
instance->compile();
delete instance;
return 0;
}

int32_t FunctorCompileFileContent::operator()() const {
CompileFileContent* instance = new CompileFileContent(
m_compileDesign, m_fileContent, m_design, m_symbols, m_errors);
m_compileDesign, m_fileContent, m_design, false, m_symbols, m_errors);
instance->compile();
delete instance;
return 0;
Expand Down Expand Up @@ -64,61 +72,75 @@ bool CompileFileContent::collectObjects_() {
VObjectType type = fC->Type(id);
switch (type) {
case VObjectType::paPackage_import_item: {
m_helper.importPackage(m_fileContent, m_design, fC, id,
m_compileDesign);
m_helper.compileImportDeclaration(m_fileContent, fC, id,
m_compileDesign);
FileCNodeId fnid(fC, id);
m_fileContent->addObject(type, fnid);
if (m_declOnly == false) {
m_helper.importPackage(m_fileContent, m_design, fC, id,
m_compileDesign);
m_helper.compileImportDeclaration(m_fileContent, fC, id,
m_compileDesign);
FileCNodeId fnid(fC, id);
m_fileContent->addObject(type, fnid);
}
break;
}
case VObjectType::paFunction_declaration: {
m_helper.compileFunction(m_fileContent, fC, id, m_compileDesign,
Reduce::No, nullptr, true);
m_helper.compileFunction(m_fileContent, fC, id, m_compileDesign,
Reduce::No, nullptr, true);
if (m_declOnly == false) {
m_helper.compileFunction(m_fileContent, fC, id, m_compileDesign,
Reduce::No, nullptr, true);
m_helper.compileFunction(m_fileContent, fC, id, m_compileDesign,
Reduce::No, nullptr, true);
}
break;
}
case VObjectType::paData_declaration: {
m_helper.compileDataDeclaration(m_fileContent, fC, id, false,
m_compileDesign, Reduce::Yes, nullptr);
if (m_declOnly) {
m_helper.compileDataDeclaration(m_fileContent, fC, id, false,
m_compileDesign, Reduce::Yes,
nullptr);
}
break;
}
case VObjectType::paParameter_declaration: {
NodeId list_of_type_assignments = fC->Child(id);
if (fC->Type(list_of_type_assignments) ==
VObjectType::paList_of_type_assignments ||
fC->Type(list_of_type_assignments) == VObjectType::paTYPE) {
// Type param
m_helper.compileParameterDeclaration(
m_fileContent, fC, list_of_type_assignments, m_compileDesign,
Reduce::Yes, false, nullptr, false, false);

} else {
m_helper.compileParameterDeclaration(m_fileContent, fC, id,
m_compileDesign, Reduce::Yes,
false, nullptr, false, false);
if (m_declOnly) {
NodeId list_of_type_assignments = fC->Child(id);
if (fC->Type(list_of_type_assignments) ==
VObjectType::paList_of_type_assignments ||
fC->Type(list_of_type_assignments) == VObjectType::paTYPE) {
// Type param
m_helper.compileParameterDeclaration(
m_fileContent, fC, list_of_type_assignments, m_compileDesign,
Reduce::Yes, false, nullptr, false, false);

} else {
m_helper.compileParameterDeclaration(m_fileContent, fC, id,
m_compileDesign, Reduce::Yes,
false, nullptr, false, false);
}
}
break;
}
case VObjectType::paLet_declaration: {
m_helper.compileLetDeclaration(m_fileContent, fC, id, m_compileDesign);
if (m_declOnly) {
m_helper.compileLetDeclaration(m_fileContent, fC, id,
m_compileDesign);
}
break;
}
case VObjectType::paLocal_parameter_declaration: {
NodeId list_of_type_assignments = fC->Child(id);
if (fC->Type(list_of_type_assignments) ==
VObjectType::paList_of_type_assignments ||
fC->Type(list_of_type_assignments) == VObjectType::paTYPE) {
// Type param
m_helper.compileParameterDeclaration(
m_fileContent, fC, list_of_type_assignments, m_compileDesign,
Reduce::Yes, true, nullptr, false, false);

} else {
m_helper.compileParameterDeclaration(m_fileContent, fC, id,
m_compileDesign, Reduce::Yes,
true, nullptr, false, false);
if (m_declOnly) {
NodeId list_of_type_assignments = fC->Child(id);
if (fC->Type(list_of_type_assignments) ==
VObjectType::paList_of_type_assignments ||
fC->Type(list_of_type_assignments) == VObjectType::paTYPE) {
// Type param
m_helper.compileParameterDeclaration(
m_fileContent, fC, list_of_type_assignments, m_compileDesign,
Reduce::Yes, true, nullptr, false, false);

} else {
m_helper.compileParameterDeclaration(m_fileContent, fC, id,
m_compileDesign, Reduce::Yes,
true, nullptr, false, false);
}
}
break;
}
Expand Down
6 changes: 4 additions & 2 deletions tests/ClassTypeParam/ClassTypeParam.log
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

=== UHDM Object Stats Begin (Non-Elaborated Model) ===
class_defn 5
class_typespec 9
class_typespec 8
class_var 3
design 1
extends 1
Expand All @@ -46,12 +46,13 @@ param_assign 6
ref_obj 4
string_typespec 4
type_parameter 10
unsupported_typespec 1
=== UHDM Object Stats End ===
[INF:UH0707] Elaborating UHDM...

=== UHDM Object Stats Begin (Elaborated Model) ===
class_defn 5
class_typespec 14
class_typespec 13
class_var 4
design 1
extends 3
Expand All @@ -65,6 +66,7 @@ param_assign 18
ref_obj 4
string_typespec 4
type_parameter 22
unsupported_typespec 1
=== UHDM Object Stats End ===
[INF:UH0708] Writing UHDM DB: ${SURELOG_DIR}/build/regression/ClassTypeParam/slpp_unit/surelog.uhdm ...

Expand Down
Loading

0 comments on commit 801fa58

Please sign in to comment.