PandA-2024.02
remove_ending_if.cpp File Reference

Collapse and if and its "then" branch only if it is shorter than one cycle and the else is a BB composed only by return and PHI statements. More...

#include "remove_ending_if.hpp"
#include "Parameter.hpp"
#include "allocation_information.hpp"
#include "application_manager.hpp"
#include "basic_block.hpp"
#include "behavioral_helper.hpp"
#include "call_graph.hpp"
#include "call_graph_manager.hpp"
#include "custom_set.hpp"
#include "cyclic_topological_sort.hpp"
#include "dbgPrintHelper.hpp"
#include "design_flow_manager.hpp"
#include "ext_tree_node.hpp"
#include "function_behavior.hpp"
#include "hls.hpp"
#include "hls_constraints.hpp"
#include "hls_manager.hpp"
#include "hls_step.hpp"
#include "schedule.hpp"
#include "string_manipulation.hpp"
#include "token_interface.hpp"
#include "tree_basic_block.hpp"
#include "tree_helper.hpp"
#include "tree_manager.hpp"
#include "tree_manipulation.hpp"
#include "tree_reindex.hpp"
#include <cstdlib>
#include <fstream>
Include dependency graph for remove_ending_if.cpp:

Go to the source code of this file.

Detailed Description

Collapse and if and its "then" branch only if it is shorter than one cycle and the else is a BB composed only by return and PHI statements.

Complete description: This step collapses an if block and its "then" branch only if the branch lasts one cycle and doesn't contain store and call. Furthermore, the BB following the if should be the last BB (preceding the EXTI) and has to contain only a return statement ad a PHI statement, also the "then" BB has to be linked to this block. | _ _ _ _| _ _ _ _ _ _ _ _ _ _ _ | | | | | IF BLOC | |IF + THEN STMTs| |_ _ _ _ _ _ _ | |_ _ _ _ _ _ _ _| / \ | / \ | / \ TRANSFORMATION | _ _ _ _ /_ _ _ \ _ _ _ _|_ _ _ _ | | / ----—> | | | THEN BRANCH | / | RETURN | |_ _ _ _ _ _ _ | / |_ _ _ _ _ _ _ _| \ / \ / \ / _ __ _ _/_ _ | | | RETURN & PHI| |_ _ _ _ _ _ _|

Macro idea:

  1. Find the pattern
  2. Manipulation

Find the pattern = chain of if condition

  1. Looking for a bloc that is connected to the EXIT bloc and that has exactly 2 incoming arcs
  2. If 1 -> Check if one of the 2 blocks contains an IF stmt and identify it.
  3. If 2 -> Check if the identified IF has exactly 2 succ and one is the bloc found in 1 and the other has only one pred and one succ and the succ is the bloc found in 1
  4. If 3 -> Check if the "then" branch doesn't contain call or store statement
  5. If 4 -> pattern found and the bloc of the "then" branch is identified, also the "if" bloc is identified
  6. Compute how much lasts the "then" branch
  7. If it lasts less then one cycle then the manipulation phase is enabled

Manipulation For each stmt in the bloc identified as "then" branch:

  1. Delete the current stmt in the bloc
  2. Move the current stmt in the "if" bloc
  3. Update the scheduling for the moved stmt The void bloc will be removed by other steps.
Author
Marco Arnaboldi marco.nosp@m.1.ar.nosp@m.nabol.nosp@m.di@p.nosp@m.olimi.nosp@m..it $Revision$ $Date$ Last modified by $Author$

Definition in file remove_ending_if.cpp.


Generated on Mon Feb 12 2024 13:03:21 for PandA-2024.02 by doxygen 1.8.13