PIPS
forloop_spaghettify.c File Reference
#include <stdio.h>
#include <ctype.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "effects.h"
#include "resources.h"
#include "misc.h"
#include "ri-util.h"
#include "effects-util.h"
#include "text-util.h"
#include "dg.h"
#include "phrase_tools.h"
#include "spaghettify.h"
+ Include dependency graph for forloop_spaghettify.c:

Go to the source code of this file.

Functions

static control make_condition_from_forloop (forloop curLoop, statement stat)
 The spaghettifier is used in context of PHRASE project while creating "Finite State Machine"-like code portions in order to synthetise them in reconfigurables units. More...
 
static control make_exit_from_forloop ()
 
static control make_body_from_forloop (forloop curLoop, const char *module_name)
 
static unstructured make_unstructured_from_forloop (forloop curLoop, statement stat, const char *module_name)
 
statement spaghettify_forloop (statement stat, const char *module_name)
 This function takes the statement stat as parameter and return a new spaghettized statement, asserting stat is a FORLOOP statement. More...
 

Function Documentation

◆ make_body_from_forloop()

static control make_body_from_forloop ( forloop  curLoop,
const char *  module_name 
)
static

Definition at line 87 of file forloop_spaghettify.c.

89 {
90  return make_control
92  module_name), NIL, NIL);
93 }
control make_control(statement a1, list a2, list a3)
Definition: ri.c:523
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
statement spaghettify_statement(statement, const char *)
spaghettify.c
Definition: spaghettify.c:85
#define forloop_body(x)
Definition: ri.h:1372

References forloop_body, make_control(), module_name(), NIL, and spaghettify_statement().

Referenced by make_unstructured_from_forloop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_condition_from_forloop()

static control make_condition_from_forloop ( forloop  curLoop,
statement  stat 
)
static

The spaghettifier is used in context of PHRASE project while creating "Finite State Machine"-like code portions in order to synthetise them in reconfigurables units.

This file contains the code used for spaghettify forloops.

NOT YET IMPLEMENTED

Definition at line 59 of file forloop_spaghettify.c.

61 {
62  statement condition_statement;
63 
64  test condition_test
65  = make_test (forloop_condition(curLoop),
68 
69 
70  condition_statement = make_statement(entity_empty_label(),
71  statement_number(stat),
72  statement_ordering(stat),
75  condition_test),
76  NIL,NULL,
78 
79  return make_control(condition_statement, NIL, NIL);
80 }
test make_test(expression a1, statement a2, statement a3)
Definition: ri.c:2607
statement make_statement(entity a1, intptr_t a2, intptr_t a3, string a4, instruction a5, list a6, string a7, extensions a8, synchronization a9)
Definition: ri.c:2222
instruction make_instruction(enum instruction_utype tag, void *val)
Definition: ri.c:1166
synchronization make_synchronization_none(void)
Definition: ri.c:2424
statement make_continue_statement(entity)
Definition: statement.c:953
#define empty_comments
Empty comments (i.e.
entity entity_empty_label(void)
Definition: entity.c:1105
#define statement_ordering(x)
Definition: ri.h:2454
@ is_instruction_test
Definition: ri.h:1470
#define statement_extensions(x)
Definition: ri.h:2464
#define forloop_condition(x)
Definition: ri.h:1368
#define statement_number(x)
Definition: ri.h:2452

References empty_comments, entity_empty_label(), forloop_condition, is_instruction_test, make_continue_statement(), make_control(), make_instruction(), make_statement(), make_synchronization_none(), make_test(), NIL, statement_extensions, statement_number, and statement_ordering.

Referenced by make_unstructured_from_forloop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_exit_from_forloop()

static control make_exit_from_forloop ( )
static

Definition at line 82 of file forloop_spaghettify.c.

References entity_empty_label(), make_continue_statement(), make_control(), and NIL.

Referenced by make_unstructured_from_forloop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_unstructured_from_forloop()

static unstructured make_unstructured_from_forloop ( forloop  curLoop,
statement  stat,
const char *  module_name 
)
static

false condition, we exit from forloop

true condition, we go to body

after body, we go back to condition

Definition at line 95 of file forloop_spaghettify.c.

98 {
99  control condition = make_condition_from_forloop(curLoop, stat);
102 
103  expression loopInit = forloop_initialization(curLoop);
104  expression loopCond = forloop_condition(curLoop);
105  expression loopInc = forloop_increment(curLoop);
106 
107  pips_assert("syntax_call_p(expression_syntax(loopInit))",
108  syntax_call_p(expression_syntax(loopInit)));
109 
110  pips_assert("syntax_call_p(expression_syntax(loopCond))",
111  syntax_call_p(expression_syntax(loopCond)));
112 
113  pips_assert("syntax_call_p(expression_syntax(loopInc))",
114  syntax_call_p(expression_syntax(loopInc)));
115 
118 
119  control init_control = make_control(initStat, NIL, NIL);
120  control inc_control = make_control(incStat, NIL, NIL);
121 
122  link_2_control_nodes (init_control, condition);
123  link_2_control_nodes (condition, exit); /* false condition, we exit from forloop */
124  link_2_control_nodes (condition, body); /* true condition, we go to body */
125  link_2_control_nodes(body, inc_control);
126  link_2_control_nodes (inc_control, condition); /* after body, we go back to condition */
127 
128  return make_unstructured(init_control, exit);
129 }
unstructured make_unstructured(control a1, control a2)
Definition: ri.c:2778
static control make_body_from_forloop(forloop curLoop, const char *module_name)
static control make_exit_from_forloop()
static control make_condition_from_forloop(forloop curLoop, statement stat)
The spaghettifier is used in context of PHRASE project while creating "Finite State Machine"-like cod...
void link_2_control_nodes(control source, control target)
Add an edge between 2 control nodes.
Definition: control.c:1193
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define exit(code)
Definition: misc-local.h:54
#define call_to_statement(c)
#define forloop_initialization(x)
Definition: ri.h:1366
#define forloop_increment(x)
Definition: ri.h:1370
#define syntax_call_p(x)
Definition: ri.h:2734
#define syntax_call(x)
Definition: ri.h:2736
#define expression_syntax(x)
Definition: ri.h:1247

References call_to_statement, exit, expression_syntax, forloop_condition, forloop_increment, forloop_initialization, link_2_control_nodes(), make_body_from_forloop(), make_condition_from_forloop(), make_control(), make_exit_from_forloop(), make_unstructured(), module_name(), NIL, pips_assert, syntax_call, and syntax_call_p.

Referenced by spaghettify_forloop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ spaghettify_forloop()

statement spaghettify_forloop ( statement  stat,
const char *  module_name 
)

This function takes the statement stat as parameter and return a new spaghettized statement, asserting stat is a FORLOOP statement.

forloop_spaghettify.c

Parameters
stattat
module_nameodule_name

Definition at line 135 of file forloop_spaghettify.c.

136 {
137  statement returned_statement = stat;
138  instruction unstructured_instruction;
139  unstructured new_unstructured;
140 
141  pips_assert("Statement is FORLOOP in FSM_GENERATION",
144 
145  pips_debug(2, "spaghettify_forloop, module %s\n", module_name);
146 
147  new_unstructured
150  stat,
151  module_name);
152 
153  unstructured_instruction = make_instruction(is_instruction_unstructured,
154  new_unstructured);
155 
156  statement_instruction(returned_statement) = unstructured_instruction;
157 
158  return returned_statement;
159 }
static unstructured make_unstructured_from_forloop(forloop curLoop, statement stat, const char *module_name)
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
@ is_instruction_unstructured
Definition: ri.h:1475
@ is_instruction_forloop
Definition: ri.h:1477
#define instruction_tag(x)
Definition: ri.h:1511
#define instruction_forloop(x)
Definition: ri.h:1538
#define statement_instruction(x)
Definition: ri.h:2458

References instruction_forloop, instruction_tag, is_instruction_forloop, is_instruction_unstructured, make_instruction(), make_unstructured_from_forloop(), module_name(), pips_assert, pips_debug, and statement_instruction.

Referenced by full_spaghettify_statement(), and spaghettify_statement().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: