PIPS

non well structured à la Fortran do-loop into an equivalent code with tests and gotos. More...

+ Collaboration diagram for Desugaring functions used to transform:

Functions

statement unsugared_loop_header (statement sl)
 LOOP_HEADER, LOOP_TEST and LOOP_INC build the desugaring phases of a do-loop L for the loop header (i=1), the test (i<10) and the increment (i=i+1). More...
 
statement unsugared_forloop_header (statement sl)
 
statement unsugared_whileloop_header (statement sl __attribute__((__unused__)))
 
statement unsugared_loop_test (statement sl)
 Do a crude test of end of do-loop for do-loop unsugaring. More...
 
statement unsugared_forloop_test (statement sl)
 
statement unsugared_whileloop_test (statement sl)
 
statement unsugared_loop_inc (statement sl)
 Do an index increment instruction for do-loop unsugaring. More...
 
statement unsugared_forloop_inc (statement sl)
 

Detailed Description

non well structured à la Fortran do-loop into an equivalent code with tests and gotos.

Function Documentation

◆ unsugared_forloop_header()

statement unsugared_forloop_header ( statement  sl)
Parameters
sll

Definition at line 474 of file controlizer.c.

475 {
476  forloop l = statement_forloop(sl);
480 
481  return is;
482 }
instruction make_instruction_expression(expression _field_)
Definition: ri.c:1196
expression copy_expression(expression p)
EXPRESSION.
Definition: ri.c:850
statement instruction_to_statement(instruction)
Build a statement from a give instruction.
Definition: statement.c:597
forloop statement_forloop(statement)
Get the forloop of a statement.
Definition: statement.c:1426
#define forloop_initialization(x)
Definition: ri.h:1366

References copy_expression(), forloop_initialization, instruction_to_statement(), make_instruction_expression(), and statement_forloop().

Referenced by controlize_forloop().

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

◆ unsugared_forloop_inc()

statement unsugared_forloop_inc ( statement  sl)
Parameters
sll

Definition at line 569 of file controlizer.c.

570 {
571  forloop l = statement_forloop(sl);
575 
576  return s;
577 }
#define forloop_increment(x)
Definition: ri.h:1370

References copy_expression(), forloop_increment, instruction_to_statement(), make_instruction_expression(), and statement_forloop().

Referenced by controlize_forloop().

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

◆ unsugared_forloop_test()

statement unsugared_forloop_test ( statement  sl)

Build if (c) with empty branches:

Parameters
sll

Definition at line 518 of file controlizer.c.

519 {
520  forloop l = statement_forloop(sl);
522  /* Build if (c) with empty branches: */
523  test t = make_test(c,
526 
528  return ts;
529 }
test make_test(expression a1, statement a2, statement a3)
Definition: ri.c:2607
instruction make_instruction_test(test _field_)
Definition: ri.c:1172
statement make_plain_continue_statement(void)
Make a simple continue statement to be used as a NOP or ";" in C.
Definition: statement.c:964
#define forloop_condition(x)
Definition: ri.h:1368

References copy_expression(), forloop_condition, instruction_to_statement(), make_instruction_test(), make_plain_continue_statement(), make_test(), and statement_forloop().

Referenced by controlize_forloop().

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

◆ unsugared_loop_header()

statement unsugared_loop_header ( statement  sl)

LOOP_HEADER, LOOP_TEST and LOOP_INC build the desugaring phases of a do-loop L for the loop header (i=1), the test (i<10) and the increment (i=i+1).

Make an index initialization header for an unsugared à la Fortran do-loop "do i = l,u,s"

Parameters
[in]slis the do-loop statement
Returns
an assignment statement "i = l"

Build a reference expression to the loop index:

Assign the lower range to it:

Parameters
sll

Definition at line 463 of file controlizer.c.

464 {
465  loop l = statement_loop(sl);
466  /* Build a reference expression to the loop index: */
468  /* Assign the lower range to it: */
470 
471  return hs;
472 }
loop statement_loop(statement)
Get the loop of a statement.
Definition: statement.c:1374
statement make_assign_statement(expression, expression)
Definition: statement.c:583
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
Definition: expression.c:165
#define range_lower(x)
Definition: ri.h:2288
#define loop_range(x)
Definition: ri.h:1642
#define loop_index(x)
Definition: ri.h:1640

References copy_expression(), entity_to_expression(), loop_index, loop_range, make_assign_statement(), range_lower, and statement_loop().

Referenced by controlize_loop().

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

◆ unsugared_loop_inc()

statement unsugared_loop_inc ( statement  sl)

Do an index increment instruction for do-loop unsugaring.

TODO : indeed the code is wrong since it only works for loops without side effects on the index inside the loop

Parameters
[in]slis a statement loop of the form "do i = l, u, s"
Returns
a "i = i + s" statement test "if (i < u)" with empty then and else branches.

Build "i + s"

Build "i = i +s"

Parameters
sll

Definition at line 554 of file controlizer.c.

555 {
556  loop l = statement_loop(sl);
557  /* Build "i + s" */
559  // Even for C code? To verify for pointers...
562  /* Build "i = i +s" */
564  c);
565 
566  return s;
567 }
#define PLUS_OPERATOR_NAME
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292
expression MakeBinaryCall(entity f, expression eg, expression ed)
Creates a call expression to a function with 2 arguments.
Definition: expression.c:354
#define range_increment(x)
Definition: ri.h:2292

References copy_expression(), entity_intrinsic(), entity_to_expression(), loop_index, loop_range, make_assign_statement(), MakeBinaryCall(), PLUS_OPERATOR_NAME, range_increment, and statement_loop().

Referenced by controlize_loop().

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

◆ unsugared_loop_test()

statement unsugared_loop_test ( statement  sl)

Do a crude test of end of do-loop for do-loop unsugaring.

TODO : indeed the code is wrong since it only works for loops without side effects on the index inside the loop and if the stride is positive, and the upper bound greated than the lower bound

Parameters
[in]slis a statement loop of the form "do i = l, u, s"
Returns
a test statement "if (i < u)" with empty then and else branches.

Build i < u

Build if (i < u) with empty branches:

Parameters
sll

Definition at line 502 of file controlizer.c.

503 {
504  loop l = statement_loop(sl);
505  /* Build i < u */
509  /* Build if (i < u) with empty branches: */
510  test t = make_test(c,
513 
515  return ts;
516 }
#define GREATER_THAN_OPERATOR_NAME
#define range_upper(x)
Definition: ri.h:2290

References copy_expression(), entity_intrinsic(), entity_to_expression(), GREATER_THAN_OPERATOR_NAME, instruction_to_statement(), loop_index, loop_range, make_instruction_test(), make_plain_continue_statement(), make_test(), MakeBinaryCall(), range_upper, and statement_loop().

Referenced by controlize_loop().

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

◆ unsugared_whileloop_header()

statement unsugared_whileloop_header ( statement sl   __attribute__(__unused__))

Definition at line 484 of file controlizer.c.

485 {
487 
488  return hs;
489 }

References make_plain_continue_statement().

Referenced by controlize_repeatloop(), and controlize_whileloop().

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

◆ unsugared_whileloop_test()

statement unsugared_whileloop_test ( statement  sl)
Parameters
sll

Definition at line 531 of file controlizer.c.

532 {
535  test t = make_test(c,
538 
540  return ts;
541 }
whileloop statement_whileloop(statement)
Get the whileloop of a statement.
Definition: statement.c:1383
#define whileloop_condition(x)
Definition: ri.h:3160

References copy_expression(), instruction_to_statement(), make_instruction_test(), make_plain_continue_statement(), make_test(), statement_whileloop(), and whileloop_condition.

Referenced by controlize_repeatloop(), and controlize_whileloop().

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