PIPS
test_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 test_spaghettify.c:

Go to the source code of this file.

Functions

static control make_condition_from_test (test the_test, 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_if_true_from_test (test the_test, const char *module_name)
 Build and return a new control containing "if true" statement of the "destructured" test. More...
 
static control make_if_false_from_test (test the_test, const char *module_name)
 Build and return a new control containing "if false" statement of the "destructured" test. More...
 
static control make_exit_from_test ()
 Build and return a new control containing exit statement of the "destructured" test (this is a continue statement) More...
 
static unstructured make_unstructured_from_test (test the_test, statement stat, const char *module_name)
 Build and return a new unstructured coding the "destructured" test. More...
 
statement spaghettify_test (statement stat, const char *module_name)
 test_spaghettify.c More...
 

Function Documentation

◆ make_condition_from_test()

static control make_condition_from_test ( test  the_test,
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 tests. Build and return a new control containing condition statement of the "destructured" test

Definition at line 62 of file test_spaghettify.c.

64 {
65  statement condition_statement;
66  test condition_test
67  = make_test (test_condition(the_test),
70 
71 
72  condition_statement = make_statement(entity_empty_label(),
73  statement_number(stat),
74  statement_ordering(stat),
77  condition_test),
78  NIL,NULL,
80  return make_control (condition_statement, NIL, NIL);
81 }
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
control make_control(statement a1, list a2, list a3)
Definition: ri.c:523
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
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 test_condition(x)
Definition: ri.h:2833
#define statement_number(x)
Definition: ri.h:2452

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

Referenced by make_unstructured_from_test().

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

◆ make_exit_from_test()

static control make_exit_from_test ( )
static

Build and return a new control containing exit statement of the "destructured" test (this is a continue statement)

Definition at line 111 of file test_spaghettify.c.

112 {
114 }

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

Referenced by make_unstructured_from_test().

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

◆ make_if_false_from_test()

static control make_if_false_from_test ( test  the_test,
const char *  module_name 
)
static

Build and return a new control containing "if false" statement of the "destructured" test.

Definition at line 99 of file test_spaghettify.c.

101 {
103  module_name),
104  NIL, NIL);
105 }
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
statement spaghettify_statement(statement, const char *)
spaghettify.c
Definition: spaghettify.c:85
#define test_false(x)
Definition: ri.h:2837

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

Referenced by make_unstructured_from_test().

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

◆ make_if_true_from_test()

static control make_if_true_from_test ( test  the_test,
const char *  module_name 
)
static

Build and return a new control containing "if true" statement of the "destructured" test.

Definition at line 87 of file test_spaghettify.c.

89 {
91  module_name),
92  NIL, NIL);
93 }
#define test_true(x)
Definition: ri.h:2835

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

Referenced by make_unstructured_from_test().

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

◆ make_unstructured_from_test()

static unstructured make_unstructured_from_test ( test  the_test,
statement  stat,
const char *  module_name 
)
static

Build and return a new unstructured coding the "destructured" test.

The first connexion is the false one

Definition at line 119 of file test_spaghettify.c.

122 {
123  control condition = make_condition_from_test (the_test,stat);
125  control if_true = make_if_true_from_test (the_test,module_name);
126  control if_false = make_if_false_from_test (the_test,module_name);
127 
128  /* The first connexion is the false one */
129  //link_2_control_nodes (condition, if_false);
130  //link_2_control_nodes (condition, if_true);
131  link_3_control_nodes (condition, if_true, if_false);
132  link_2_control_nodes (if_true, exit);
133  link_2_control_nodes (if_false, exit);
134 
135  return make_unstructured (condition, exit);
136 }
unstructured make_unstructured(control a1, control a2)
Definition: ri.c:2778
void link_3_control_nodes(control c_test, control c_then, control c_else)
Add an edge between 2 control nodes.
Definition: control.c:1249
void link_2_control_nodes(control source, control target)
Add an edge between 2 control nodes.
Definition: control.c:1193
#define exit(code)
Definition: misc-local.h:54
static control make_exit_from_test()
Build and return a new control containing exit statement of the "destructured" test (this is a contin...
static control make_if_true_from_test(test the_test, const char *module_name)
Build and return a new control containing "if true" statement of the "destructured" test.
static control make_condition_from_test(test the_test, statement stat)
The spaghettifier is used in context of PHRASE project while creating "Finite State Machine"-like cod...
static control make_if_false_from_test(test the_test, const char *module_name)
Build and return a new control containing "if false" statement of the "destructured" test.

References exit, link_2_control_nodes(), link_3_control_nodes(), make_condition_from_test(), make_exit_from_test(), make_if_false_from_test(), make_if_true_from_test(), make_unstructured(), and module_name().

Referenced by spaghettify_test().

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

◆ spaghettify_test()

statement spaghettify_test ( statement  stat,
const char *  module_name 
)

test_spaghettify.c

Parameters
stattat
module_nameodule_name

Definition at line 142 of file test_spaghettify.c.

143 {
144  statement returned_statement = stat;
145  instruction unstructured_instruction;
146  unstructured new_unstructured;
147 
148  pips_assert("Statement is TEST in FSM_GENERATION",
151 
152  pips_debug(2, "spaghettify_test, module %s\n", module_name);
153 
154  new_unstructured
157  stat,
158  module_name);
159 
160  unstructured_instruction = make_instruction(is_instruction_unstructured,
161  new_unstructured);
162 
163  statement_instruction(returned_statement) = unstructured_instruction;
164  return returned_statement;
165 }
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
@ is_instruction_unstructured
Definition: ri.h:1475
#define instruction_tag(x)
Definition: ri.h:1511
#define statement_instruction(x)
Definition: ri.h:2458
#define instruction_test(x)
Definition: ri.h:1517
static unstructured make_unstructured_from_test(test the_test, statement stat, const char *module_name)
Build and return a new unstructured coding the "destructured" test.

References instruction_tag, instruction_test, is_instruction_test, is_instruction_unstructured, make_instruction(), make_unstructured_from_test(), 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: