PIPS
Methods dealing with statements

Conditional execution is used to mask the call to MakeSimpleIoInst2. More...

+ Collaboration diagram for Methods dealing with statements:

Modules

 Statement predicate methods
 detects a statement with no special effect...
 

Functions

void statement_remove_extensions (statement s)
 That's all folks. More...
 
void statement_remove_useless_label (statement s, bool *changed)
 remove the label of a statement if the statement is not unstructured. More...
 
bool belong_to_statement (statement stmt, statement s, bool found_p)
 return true if s is enclosed in stmt NL: What is the difference with statement_in_statement_p? More...
 
entity find_final_statement_label (statement s)
 Find the label associated with the last statement executed within s. More...
 
string comment_sentinel (tag t)
 Start a single line comment. More...
 

Variables

list add_statement_declarations_t::statement_to_all_included_declarations
 
set add_statement_declarations_t::cache
 
list entities_t::lents
 
set entities_t::sents
 
statement fswl::st
 statement matching condition More...
 
entity fswl::key
 used for the condition More...
 
list fswp::l
 
const char * fswp::begin
 
statement sb::searched_statement
 
bool sb::found_p
 
statement replace_statement_context::old_stat
 
statement replace_statement_context::new_stat
 
bool replace_statement_context::found_p
 

Detailed Description

Conditional execution is used to mask the call to MakeSimpleIoInst2.

It is preserved because the current validation suite does not include test cases covering its replacement.

include "syntax.h" // MakeSimpleIoInst2

Function Documentation

◆ belong_to_statement()

bool belong_to_statement ( statement  stmt,
statement  s,
bool  found_p 
)

return true if s is enclosed in stmt NL: What is the difference with statement_in_statement_p?

Parameters
stmttmt
found_pound_p

Definition at line 4304 of file statement.c.

4305 {
4306  if(!found_p){
4308  return true;
4309  else
4310  {
4312  switch(instruction_tag(inst)) {
4313  case is_instruction_block: {
4314  bool bs = found_p;
4315  MAPL( stmt_ptr,
4316  {
4317  statement local_stmt = STATEMENT(CAR( stmt_ptr ));
4318  bs = bs || belong_to_statement(local_stmt, s, found_p);
4319  },
4320  instruction_block( inst ) );
4321  return bs;
4322  }
4323  case is_instruction_test :{
4324  test t = instruction_test(inst);
4325  bool bt = found_p || belong_to_statement(test_true(t), s, found_p);
4326  return bt || belong_to_statement(test_false(t), s, found_p);
4327  break;
4328  }
4329  case is_instruction_loop : {
4330  loop l = statement_loop(stmt);
4331  statement body = loop_body(l);
4332  return found_p || belong_to_statement(body, s, found_p);
4333  break;
4334  }
4335  case is_instruction_forloop :{
4337  statement body = forloop_body(l);
4338  return found_p || belong_to_statement(body, s, found_p);
4339  break;
4340  }
4341  case is_instruction_whileloop : {
4343  statement body = whileloop_body(l);
4344  return found_p || belong_to_statement(body, s, found_p);
4345  break;
4346  }
4347  case is_instruction_call:
4348  return found_p || false;
4349  break;
4350  default:
4351  break;
4352  }
4353  }
4354  }
4355  else return true;
4356  return found_p;
4357 }
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define MAPL(_map_list_cp, _code, _l)
Apply some code on the addresses of all the elements of a list.
Definition: newgen_list.h:203
loop statement_loop(statement s)
Get the loop of a statement.
Definition: statement.c:1374
whileloop statement_whileloop(statement s)
Get the whileloop of a statement.
Definition: statement.c:1383
forloop statement_forloop(statement s)
Get the forloop of a statement.
Definition: statement.c:1426
bool belong_to_statement(statement stmt, statement s, bool found_p)
return true if s is enclosed in stmt NL: What is the difference with statement_in_statement_p?
Definition: statement.c:4304
#define is_instruction_block
soft block->sequence transition
#define instruction_block(i)
#define loop_body(x)
Definition: ri.h:1644
#define statement_ordering(x)
Definition: ri.h:2454
#define test_false(x)
Definition: ri.h:2837
@ is_instruction_whileloop
Definition: ri.h:1472
@ is_instruction_test
Definition: ri.h:1470
@ is_instruction_call
Definition: ri.h:1474
@ is_instruction_forloop
Definition: ri.h:1477
@ is_instruction_loop
Definition: ri.h:1471
#define instruction_tag(x)
Definition: ri.h:1511
#define test_true(x)
Definition: ri.h:2835
#define whileloop_body(x)
Definition: ri.h:3162
#define statement_instruction(x)
Definition: ri.h:2458
#define instruction_test(x)
Definition: ri.h:1517
#define forloop_body(x)
Definition: ri.h:1372
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
Definition: statement.c:54

References belong_to_statement(), CAR, forloop_body, replace_statement_context::found_p, instruction_block, instruction_tag, instruction_test, is_instruction_block, is_instruction_call, is_instruction_forloop, is_instruction_loop, is_instruction_test, is_instruction_whileloop, loop_body, MAPL, STATEMENT, statement_forloop(), statement_instruction, statement_loop(), statement_ordering, statement_whileloop(), test_false, test_true, and whileloop_body.

Referenced by belong_to_statement().

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

◆ comment_sentinel()

string comment_sentinel ( tag  t)

Start a single line comment.

Returns
a string containing the begin of a comment line, language dependent

Definition at line 4420 of file statement.c.

4420  {
4421  switch(t) {
4422  case is_language_c: return "//";
4423  case is_language_fortran: return "C";
4424  case is_language_fortran95: return "!";
4425  default: pips_internal_error("language unknown not handled"); return NULL ;
4426  }
4427 }
#define pips_internal_error
Definition: misc-local.h:149
@ is_language_fortran
Definition: ri.h:1566
@ is_language_fortran95
Definition: ri.h:1568
@ is_language_c
Definition: ri.h:1567

References is_language_c, is_language_fortran, is_language_fortran95, and pips_internal_error.

Referenced by loop_test(), and whileloop_test().

+ Here is the caller graph for this function:

◆ find_final_statement_label()

entity find_final_statement_label ( statement  s)

Find the label associated with the last statement executed within s.

If empty blocks are allowed, we've recursed one statement too far.

There cannot be a final statement. The test itself is the final instruction.

Must be the label of the exit node.

fsl should be either a meaningful label or the empty label

Definition at line 4360 of file statement.c.

4361 {
4362  entity fsl = entity_undefined;
4364  list l = list_undefined;
4365 
4366  switch(instruction_tag(i)) {
4367 
4368  case is_instruction_block:
4369  if(!ENDP(l=gen_last(instruction_block(i)))) {
4370  fsl = statement_label(STATEMENT(CAR(l)));
4371  }
4372  else {
4373  /* If empty blocks are allowed, we've recursed one statement too
4374  far. */
4375  pips_internal_error("Useless empty sequence. Unexpected in controlized code.");
4376  }
4377  break;
4378 
4379  case is_instruction_test:
4380  /* There cannot be a final statement. The test itself is the final
4381  instruction. */
4382  fsl = statement_label(s);
4383  break;
4384 
4385  case is_instruction_loop:
4387  break;
4388 
4389  case is_instruction_goto:
4390  pips_internal_error("Controlized code should not contain GO TO statements");
4391  break;
4392 
4393  case is_instruction_call:
4394  fsl = statement_label(s);
4395  break;
4396 
4398  /* Must be the label of the exit node. */
4401  break;
4402 
4403  default:
4404  pips_internal_error("Unknown instruction tag: %d",
4405  instruction_tag(i));
4406  }
4407 
4408  /* fsl should be either a meaningful label or the empty label */
4409  if(entity_undefined_p(fsl)) {
4410  pips_internal_error("Undefined final label");
4411  }
4412 
4413  return fsl;
4414 }
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
list gen_last(list l)
Return the last element of a list.
Definition: list.c:578
#define list_undefined
Undefined list definition :-)
Definition: newgen_list.h:69
entity find_final_statement_label(statement s)
Find the label associated with the last statement executed within s.
Definition: statement.c:4360
#define instruction_loop(x)
Definition: ri.h:1520
#define statement_label(x)
Definition: ri.h:2450
#define entity_undefined_p(x)
Definition: ri.h:2762
#define entity_undefined
Definition: ri.h:2761
@ is_instruction_goto
Definition: ri.h:1473
@ is_instruction_unstructured
Definition: ri.h:1475
#define unstructured_exit(x)
Definition: ri.h:3006
#define control_statement(x)
Definition: ri.h:941
#define instruction_unstructured(x)
Definition: ri.h:1532
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References CAR, control_statement, ENDP, entity_undefined, entity_undefined_p, find_final_statement_label(), gen_last(), instruction_block, instruction_loop, instruction_tag, instruction_unstructured, is_instruction_block, is_instruction_call, is_instruction_goto, is_instruction_loop, is_instruction_test, is_instruction_unstructured, list_undefined, loop_body, pips_internal_error, STATEMENT, statement_instruction, statement_label, and unstructured_exit.

Referenced by find_final_statement_label(), and full_loop_unroll().

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

◆ statement_remove_extensions()

void statement_remove_extensions ( statement  s)

That's all folks.

purge a statement from its extensions

Definition at line 4263 of file statement.c.

4263  {
4267 }
void gen_full_free_list(list l)
Definition: genClib.c:1023
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define statement_extensions(x)
Definition: ri.h:2464
#define extensions_extension(x)
Definition: ri.h:1330

References extensions_extension, gen_full_free_list(), NIL, and statement_extensions.

+ Here is the call graph for this function:

◆ statement_remove_useless_label()

void statement_remove_useless_label ( statement  s,
bool changed 
)

remove the label of a statement if the statement is not unstructured.

labels on fortran loops and Fortran return are also preserved

Parameters
sstatement considered
Parameters
changedhanged

Definition at line 4275 of file statement.c.

4276 {
4278  if (!instruction_unstructured_p(i) &&
4280  {
4281  // under pyps, do not remove loop label like this */
4282  if (!(get_bool_property("PYPS") && instruction_loop_p(i)))
4283  {
4286  {
4287  // SG: should free_entity?
4288  *changed = true;
4290 
4291  // OK but guarded by previous test
4292  if (instruction_loop_p(i))
4294  if( instruction_whileloop_p(i) )
4296  }
4297  }
4298  }
4299 }
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
bool fortran_return_statement_p(statement s)
Test if a statement is a Fortran "return".
Definition: statement.c:188
bool c_module_p(entity m)
Test if a module "m" is written in C.
Definition: entity.c:2777
entity entity_empty_label(void)
Definition: entity.c:1105
bool entity_empty_label_p(entity e)
Definition: entity.c:666
#define instruction_loop_p(x)
Definition: ri.h:1518
#define whileloop_label(x)
Definition: ri.h:3164
#define loop_label(x)
Definition: ri.h:1646
#define instruction_unstructured_p(x)
Definition: ri.h:1530
#define instruction_whileloop(x)
Definition: ri.h:1523
#define instruction_whileloop_p(x)
Definition: ri.h:1521

References c_module_p(), entity_empty_label(), entity_empty_label_p(), fortran_return_statement_p(), get_bool_property(), get_current_module_entity(), instruction_loop, instruction_loop_p, instruction_unstructured_p, instruction_whileloop, instruction_whileloop_p, loop_label, statement_instruction, statement_label, and whileloop_label.

Referenced by stmt_rm_labels(), and stmt_rm_useless_label_rwt().

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

Variable Documentation

◆ begin

const char* fswp::begin

◆ cache

set add_statement_declarations_t::cache

Definition at line 3225 of file statement.c.

Referenced by add_statement_declarations(), and statement_to_declarations().

◆ found_p [1/2]

bool sb::found_p

Definition at line 4049 of file statement.c.

Referenced by statement_in_statement_p(), and statement_in_statement_walker().

◆ found_p [2/2]

bool replace_statement_context::found_p

◆ key

entity fswl::key

used for the condition

Definition at line 3779 of file statement.c.

Referenced by find_statements_with_label_walker().

◆ l

list fswp::l

◆ lents

◆ new_stat

statement replace_statement_context::new_stat

Definition at line 4107 of file statement.c.

Referenced by replace_statement_walker(), and statement_replace_in_root_statement().

◆ old_stat

statement replace_statement_context::old_stat

Definition at line 4106 of file statement.c.

Referenced by replace_statement_walker(), and statement_replace_in_root_statement().

◆ searched_statement

statement sb::searched_statement

Definition at line 4048 of file statement.c.

Referenced by statement_in_statement_p(), and statement_in_statement_walker().

◆ sents

◆ st

statement fswl::st

statement matching condition

Definition at line 3778 of file statement.c.

Referenced by find_statement_from_label(), and find_statements_with_label_walker().

◆ statement_to_all_included_declarations

list add_statement_declarations_t::statement_to_all_included_declarations

Definition at line 3224 of file statement.c.

Referenced by add_statement_declarations(), and statement_to_declarations().