mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
InlineDispatcherSwitch: improve function signature
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user