diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d8a520..7f783a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ FetchContent_MakeAvailable(slang) add_executable(sv-bugpoint source/SvBugpoint.cpp source/Utils.cpp source/PairRemovers.cpp source/BodyRemover.cpp source/BodyPartsRemover.cpp source/DeclRemover.cpp source/InstantationRemover.cpp source/ModportRemover.cpp source/ContAssignRemover.cpp source/ParamAssignRemover.cpp - source/StatementsRemover.cpp source/MemberRemover.cpp source/ImportsRemover.cpp) + source/StatementsRemover.cpp source/MemberRemover.cpp source/ImportsRemover.cpp source/TypedefReplacer.cpp) target_link_libraries(sv-bugpoint PRIVATE slang::slang) target_precompile_headers(sv-bugpoint PUBLIC diff --git a/source/OneTimeRemoversFwd.hpp b/source/OneTimeRemoversFwd.hpp index 76eee2f..4e0e062 100644 --- a/source/OneTimeRemoversFwd.hpp +++ b/source/OneTimeRemoversFwd.hpp @@ -14,5 +14,7 @@ class ContAssignRemover; class ModportRemover; class InstantationRemover; +class TypedefReplacer; + template bool removeLoop(std::shared_ptr& tree, std::string stageName, std::string passIdx); diff --git a/source/SvBugpoint.cpp b/source/SvBugpoint.cpp index 7eafcbb..44b6664 100644 --- a/source/SvBugpoint.cpp +++ b/source/SvBugpoint.cpp @@ -32,19 +32,21 @@ bool removeLoop(PairRemover rewriter, bool pass(std::shared_ptr& tree, const std::string& passIdx = "-") { bool commited = false; - commited |= removeLoop(tree, "bodyRemover", passIdx); - commited |= removeLoop(tree, "instantiationRemover", passIdx); - commited |= removeLoop(tree, "bodyPartsRemover", passIdx); - commited |= removeLoop(makeExternRemover(tree), tree, "externRemover", passIdx); - commited |= removeLoop(tree, "declRemover", passIdx); - commited |= removeLoop(tree, "statementsRemover", passIdx); - commited |= removeLoop(tree, "importsRemover", passIdx); - commited |= removeLoop(tree, "paramAssignRemover", passIdx); - commited |= removeLoop(tree, "contAssignRemover", passIdx); - commited |= removeLoop(tree, "memberRemover", passIdx); - commited |= removeLoop(tree, "modportRemover", passIdx); - commited |= removeLoop(makePortsRemover(tree), tree, "portsRemover", passIdx); - commited |= removeLoop(makeStructFieldRemover(tree), tree, "structRemover", passIdx); + commited |= removeLoop(tree, "bodyRemover", passIdx); + + // commited |= removeLoop(tree, "bodyRemover", passIdx); + // commited |= removeLoop(tree, "instantiationRemover", passIdx); + // commited |= removeLoop(tree, "bodyPartsRemover", passIdx); + // commited |= removeLoop(makeExternRemover(tree), tree, "externRemover", passIdx); + // commited |= removeLoop(tree, "declRemover", passIdx); + // commited |= removeLoop(tree, "statementsRemover", passIdx); + // commited |= removeLoop(tree, "importsRemover", passIdx); + // commited |= removeLoop(tree, "paramAssignRemover", passIdx); + // commited |= removeLoop(tree, "contAssignRemover", passIdx); + // commited |= removeLoop(tree, "memberRemover", passIdx); + // commited |= removeLoop(tree, "modportRemover", passIdx); + // commited |= removeLoop(makePortsRemover(tree), tree, "portsRemover", passIdx); + // commited |= removeLoop(makeStructFieldRemover(tree), tree, "structRemover", passIdx); return commited; } diff --git a/source/TypedefReplacer.cpp b/source/TypedefReplacer.cpp new file mode 100644 index 0000000..500597c --- /dev/null +++ b/source/TypedefReplacer.cpp @@ -0,0 +1,50 @@ +#include "OneTimeRemover.hpp" +#include "slang/syntax/AllSyntax.h" +#include "slang/syntax/SyntaxNode.h" + +class TypedefReplacer : public OneTimeRemover { + public: + // ShouldVisitChildren handle(const IntegerTypeSyntax& node, bool isNodeRemovable) { + + // // printf + // std::cerr << node.toString() << "\n"; + // // std::cerr << node.keyword << "\n" << node.dimensions; + // // removed = node.type->sourceRange(); + // // state = REGISTER_SUCCESSOR; + // // // removeChildList(node, node.items); + // // // node.type; + // // return DONT_VISIT_CHILDREN; + // } + ShouldVisitChildren handle(const TypedefDeclarationSyntax& node, bool isNodeRemovable) { + // printf + std::cerr << node.toString() << "\n"; + // IntegerTypeSyntax s; + // ; + replace(*node.type, *alloc.emplace(IntegerTypeSyntax(SyntaxKind::IntType, makeToken(parsing::TokenKind::IntegerKeyword, "int"), {}, SyntaxList({})))); + removed = node.type->sourceRange(); + state = REGISTER_SUCCESSOR; + // removeChildList(node, node.items); + // node.type; + return DONT_VISIT_CHILDREN; + } + + // ShouldVisitChildren handle(const FunctionDeclarationSyntax& node, bool isNodeRemovable) { + // removeChildList(node, node.items); + // return VISIT_CHILDREN; + // } + + // ShouldVisitChildren handle(const ModuleDeclarationSyntax& node, bool isNodeRemovable) { + // removeChildList(node, node.members); + // return VISIT_CHILDREN; + // } + + // ShouldVisitChildren handle(const BlockStatementSyntax& node, bool isNodeRemovable) { + // removeChildList(node, node.items); + // return VISIT_CHILDREN; + // } +}; + +template bool removeLoop(std::shared_ptr& tree, + std::string stageName, + std::string passIdx); +