InlineDispatcherSwitch: improve function signature

This commit is contained in:
Andrea Gussoni
2024-04-30 17:02:27 +02:00
parent 8d7beaf332
commit 3763d781d3
3 changed files with 12 additions and 8 deletions
+2 -2
View File
@@ -1016,12 +1016,12 @@ void beautifyAST(const model::Binary &Model, Function &F, ASTTree &CombedAST) {
// Perform the `SwitchBreak` simplification
revng_log(BeautifyLogger, "Performing SwitchBreak simplification");
RootNode = simplifySwitchBreak(CombedAST, RootNode);
RootNode = simplifySwitchBreak(CombedAST);
Dumper.log("After-switchbreak-simplify");
// Perform the dispatcher `switch` inlining
revng_log(BeautifyLogger, "Performing dispatcher switch inlining\n");
RootNode = inlineDispatcherSwitch(CombedAST, RootNode);
RootNode = inlineDispatcherSwitch(CombedAST);
Dumper.log("after-dispatcher-switch-inlining");
// Perform the simplification of `switch` with two entries in a `if`
@@ -767,12 +767,14 @@ inlineDispatcherSwitchImpl(ASTTree &AST,
rc_return Node;
}
ASTNode *inlineDispatcherSwitch(ASTTree &AST, ASTNode *RootNode) {
ASTNode *inlineDispatcherSwitch(ASTTree &AST) {
// Compute the loop -> dispatcher switch correspondence
LoopDispatcherMap LoopDispatcherMap = computeLoopDispatcher(AST);
RootNode = inlineDispatcherSwitchImpl(AST, RootNode, LoopDispatcherMap);
ASTNode *RootNode = inlineDispatcherSwitchImpl(AST,
AST.getRoot(),
LoopDispatcherMap);
// Update the root field of the AST
AST.setRoot(RootNode);
@@ -945,13 +947,15 @@ simplifySwitchBreakImpl(ASTTree &AST,
/// are superfluous. We consider such nodes as `SwitchBreakNode`s that compose
/// the entirety of a `case` of a `switch`, which must not have a `default`
/// `case`.
ASTNode *simplifySwitchBreak(ASTTree &AST, ASTNode *RootNode) {
ASTNode *simplifySwitchBreak(ASTTree &AST) {
// Compute the loop -> dispatcher switch correspondence
LoopDispatcherMap LoopDispatcherMap = computeLoopDispatcher(AST);
// Simplify away `SwitchBreakNode`s from `switch`es
RootNode = simplifySwitchBreakImpl(AST, RootNode, LoopDispatcherMap);
ASTNode *RootNode = simplifySwitchBreakImpl(AST,
AST.getRoot(),
LoopDispatcherMap);
AST.setRoot(RootNode);
return RootNode;
+2 -2
View File
@@ -10,6 +10,6 @@
class ASTNode;
class ASTTree;
extern ASTNode *inlineDispatcherSwitch(ASTTree &AST, ASTNode *RootNode);
extern ASTNode *inlineDispatcherSwitch(ASTTree &AST);
extern ASTNode *simplifySwitchBreak(ASTTree &AST, ASTNode *RootNode);
extern ASTNode *simplifySwitchBreak(ASTTree &AST);