Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
sgizler committed Sep 25, 2024
1 parent 520fdbf commit a326501
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions source/OneTimeRemoversFwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ class ContAssignRemover;
class ModportRemover;
class InstantationRemover;

class TypedefReplacer;

template <typename T>
bool removeLoop(std::shared_ptr<SyntaxTree>& tree, std::string stageName, std::string passIdx);
28 changes: 15 additions & 13 deletions source/SvBugpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,21 @@ bool removeLoop(PairRemover rewriter,
bool pass(std::shared_ptr<SyntaxTree>& tree, const std::string& passIdx = "-") {
bool commited = false;

commited |= removeLoop<BodyRemover>(tree, "bodyRemover", passIdx);
commited |= removeLoop<InstantationRemover>(tree, "instantiationRemover", passIdx);
commited |= removeLoop<BodyPartsRemover>(tree, "bodyPartsRemover", passIdx);
commited |= removeLoop(makeExternRemover(tree), tree, "externRemover", passIdx);
commited |= removeLoop<DeclRemover>(tree, "declRemover", passIdx);
commited |= removeLoop<StatementsRemover>(tree, "statementsRemover", passIdx);
commited |= removeLoop<ImportsRemover>(tree, "importsRemover", passIdx);
commited |= removeLoop<ParamAssignRemover>(tree, "paramAssignRemover", passIdx);
commited |= removeLoop<ContAssignRemover>(tree, "contAssignRemover", passIdx);
commited |= removeLoop<MemberRemover>(tree, "memberRemover", passIdx);
commited |= removeLoop<ModportRemover>(tree, "modportRemover", passIdx);
commited |= removeLoop(makePortsRemover(tree), tree, "portsRemover", passIdx);
commited |= removeLoop(makeStructFieldRemover(tree), tree, "structRemover", passIdx);
commited |= removeLoop<TypedefReplacer>(tree, "bodyRemover", passIdx);

// commited |= removeLoop<BodyRemover>(tree, "bodyRemover", passIdx);
// commited |= removeLoop<InstantationRemover>(tree, "instantiationRemover", passIdx);
// commited |= removeLoop<BodyPartsRemover>(tree, "bodyPartsRemover", passIdx);
// commited |= removeLoop(makeExternRemover(tree), tree, "externRemover", passIdx);
// commited |= removeLoop<DeclRemover>(tree, "declRemover", passIdx);
// commited |= removeLoop<StatementsRemover>(tree, "statementsRemover", passIdx);
// commited |= removeLoop<ImportsRemover>(tree, "importsRemover", passIdx);
// commited |= removeLoop<ParamAssignRemover>(tree, "paramAssignRemover", passIdx);
// commited |= removeLoop<ContAssignRemover>(tree, "contAssignRemover", passIdx);
// commited |= removeLoop<MemberRemover>(tree, "memberRemover", passIdx);
// commited |= removeLoop<ModportRemover>(tree, "modportRemover", passIdx);
// commited |= removeLoop(makePortsRemover(tree), tree, "portsRemover", passIdx);
// commited |= removeLoop(makeStructFieldRemover(tree), tree, "structRemover", passIdx);

return commited;
}
Expand Down
50 changes: 50 additions & 0 deletions source/TypedefReplacer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include "OneTimeRemover.hpp"
#include "slang/syntax/AllSyntax.h"
#include "slang/syntax/SyntaxNode.h"

class TypedefReplacer : public OneTimeRemover<TypedefReplacer> {
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>(IntegerTypeSyntax(SyntaxKind::IntType, makeToken(parsing::TokenKind::IntegerKeyword, "int"), {}, SyntaxList<VariableDimensionSyntax>({}))));
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<TypedefReplacer>(std::shared_ptr<SyntaxTree>& tree,
std::string stageName,
std::string passIdx);

0 comments on commit a326501

Please sign in to comment.