PIPS
myintrinsics.c File Reference
#include "all.h"
+ Include dependency graph for myintrinsics.c:

Go to the source code of this file.

Data Structures

struct  IoElementDescriptor
 {{ banner More...
 
struct  IntrinsicEffectDescriptor
 the following data structure describes an intrinsic function: its name and the function to apply on a call to this intrinsic to get the effects of the call More...
 

Typedefs

typedef struct IoElementDescriptor IoElementDescriptor
 {{ banner More...
 

Functions

list comp_regions_of_intrinsic (entity e, list args, transformer context)
 }} More...
 
list proper_comp_regions_of_intrinsic (entity e, list args, transformer context)
 }} More...
 
list no_write_comp_regions (entity __attribute__((unused)) e, list args, transformer context)
 }} More...
 
list affect_comp_regions (entity __attribute__((unused)) e, list args, transformer context)
 }} More...
 
static IoElementDescriptorSearchIoElement (char *s, char *i) const
 }} More...
 
list io_comp_regions (entity e, list args, transformer context)
 }} More...
 
list comp_regions_of_ioelem (expression exp, tag act, transformer context)
 }} More...
 
list comp_regions_of_iolist (list exprs, tag act, transformer context)
 }} More...
 
list comp_regions_of_implied_do (expression exp, tag act, transformer context)
 }} More...
 

Variables

static IoElementDescriptor IoElementDescriptorUndefined
 
static IoElementDescriptor IoElementDescriptorTable []
 
static IntrinsicEffectDescriptor IntrinsicDescriptorTable []
 

Typedef Documentation

◆ IoElementDescriptor

{{ banner

package regions : Alexis Platonoff, 22 Aout 1990

This File contains the main functions that compute the regions of a call to an intrinsic function : "+", "COS", etc... }} {{ data structures for handling descriptors the following data structure indicates whether an io element generates a read regions or a write region. the kind of region depends on the instruction type: for instance, access generates a read region if used within an open statement, and a write region when used inside an inquire statement

Function Documentation

◆ affect_comp_regions()

list affect_comp_regions ( entity __attribute__((unused))  e,
list  args,
transformer  context 
)

}}

{{ affect_comp_regions ==============================================================================

Definition at line 332 of file myintrinsics.c.

335 {
336  list le = NIL;
337 
338  expression lhs = EXPRESSION(CAR(args));
339  syntax s = expression_syntax(lhs);
340 
341  expression rhs = EXPRESSION(CAR(CDR(args)));
342 
343  debug(5, "affect_comp_regions", "begin\n");
344 
345  if (! syntax_reference_p(s))
346  pips_internal_error("not a reference");
347 
348 
350 
353 
354  debug(5, "affect_comp_regions", "end\n");
355 
356  return(le);
357 }
list comp_regions_of_write(reference, transformer)
}}}
Definition: propagate.c:753
list CompRegionsExactUnion(list, list, bool(*)(effect, effect))
list comp_regions_of_expression(expression, transformer)
{{{ comp_regions_of_expression
Definition: propagate.c:701
bool effects_same_action_p(effect, effect)
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
#define pips_internal_error
Definition: misc-local.h:149
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
#define syntax_reference_p(x)
Definition: ri.h:2728
#define syntax_reference(x)
Definition: ri.h:2730
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define expression_syntax(x)
Definition: ri.h:1247
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
Definition: delay.c:253

References CAR, CDR, comp_regions_of_expression(), comp_regions_of_write(), CompRegionsExactUnion(), debug(), effects_same_action_p(), EXPRESSION, expression_syntax, NIL, pips_internal_error, syntax_reference, and syntax_reference_p.

+ Here is the call graph for this function:

◆ comp_regions_of_implied_do()

list comp_regions_of_implied_do ( expression  exp,
tag  act,
transformer  context 
)

}}

{{ comp_regions_of_implied_do an implied do is a call to an intrinsic function named IMPLIED-DO; its first argument is the loop index, the second one is a range, and the remaining ones are expressions to be written or references to be read, or another implied_do (BA).

loop index

range

regions of implied do index it is must_written but may read because the implied loop might execute no iteration.

the loop index is must-written

Read effects are masked by the first write to the implied-do loop variable

regions of implied-loop bounds and increment

the preconditions of the current statement don't include those induced by the implied_do, because they are local to the statement. But we need them to properly calculate the regions. the solution is to add to the current context the preconditions due to the current implied_do (think of nested implied_do). the regions are calculated, and projected along the index. BA, September 27, 1993.

on a un autre implied_do imbrique'

indices are removed from regions because this is a loop

Parameters
expxp
actct
contextontext

Definition at line 544 of file myintrinsics.c.

548 {
549  list le, lep, lr, args;
550  transformer local_context;
551  expression arg1, arg2;
552  entity index;
553  range r;
554  reference ref;
555 
556  pips_assert("comp_regions_of_implied_do", expression_implied_do_p(exp));
557 
558  debug(5, "comp_regions_of_implied_do", "begin\n");
559 
561  arg1 = EXPRESSION(CAR(args)); /* loop index */
562  arg2 = EXPRESSION(CAR(CDR(args))); /* range */
563 
564  pips_assert("comp_regions_of_implied_do",
566 
567  pips_assert("comp_regions_of_implied_do",
569 
570 
572  ref = make_reference(index, NIL);
573 
574  r = syntax_range(expression_syntax(arg2));
575 
576  /* regions of implied do index
577  * it is must_written but may read because the implied loop
578  * might execute no iteration.
579  */
580 
581  le = comp_regions_of_write(ref, context); /* the loop index is must-written */
582  /* Read effects are masked by the first write to the implied-do loop variable */
583 
584  /* regions of implied-loop bounds and increment */
587 
588 
589  /* the preconditions of the current statement don't include those
590  * induced by the implied_do, because they are local to the statement.
591  * But we need them to properly calculate the regions.
592  * the solution is to add to the current context the preconditions
593  * due to the current implied_do (think of nested implied_do).
594  * the regions are calculated, and projected along the index.
595  * BA, September 27, 1993.
596  */
597 
598  local_context = transformer_dup(context);
599  local_context = add_index_range_conditions(local_context, index, r,
601  transformer_arguments(local_context) =
603  entity_to_new_value(index));
604 
605  ifdebug(7) {
606  debug(7, "comp_regions_of_implied_do", "local context : \n%s\n",
607  precondition_to_string(local_context));
608  }
609 
610  MAP(EXPRESSION, expr,
611  {
612  syntax s = expression_syntax(expr);
613 
614  if (syntax_reference_p(s))
615  if (act == is_action_write)
616  lep = comp_regions_of_write(syntax_reference(s),local_context);
617  else
618  lep = comp_regions_of_expression(expr, local_context);
619  else
620  /* on a un autre implied_do imbrique' */
621  lep = comp_regions_of_implied_do(expr, act, local_context);
622 
623 
624  /* indices are removed from regions because this is a loop */
625  lr = NIL;
626  MAP(REGION, reg,
627  {
628  if (region_entity(reg) != index)
629  lr = region_add_to_regions(reg,lr);
630  else
631  {
632  debug(5, "comp_regions_of_implied_do", "index removed");
633  region_free(reg);
634  }
635  }, lep);
636  gen_free_list(lep);
638 
639  }, CDR(CDR(args)));
640 
641  ifdebug(7) {
642  debug(7, "comp_regions_of_implied_do", "regions before projection :\n");
643  print_regions(le);
644  fprintf(stderr, "\n");
645  }
646 
648  entity_to_new_value(index),
649  r);
650 
651  ifdebug(6) {
652  debug(6, "comp_regions_of_implied_do", "regions after projection :\n");
653  print_regions(le);
654  fprintf(stderr, "\n");
655  }
656 
657 
658  transformer_free(local_context);
659  local_context = transformer_undefined;
660 
661  debug(5, "comp_regions_of_implied_do", "end\n");
662 
663  return(le);
664 }
reference make_reference(entity a1, list a2)
Definition: ri.c:2083
static reference ref
Current stmt (an integer)
Definition: adg_read_paf.c:163
cons * arguments_add_entity(cons *a, entity e)
Definition: arguments.c:85
transformer transformer_dup(transformer t_in)
transformer package - basic routines
Definition: basic.c:49
void transformer_free(transformer t)
Definition: basic.c:68
#define region_entity(reg)
#define REGION
list region_add_to_regions(effect, list)
void region_free(effect)
void print_regions(list)
void project_regions_along_loop_index(list, entity, range)
void project_regions_along_loop_index(list l_reg, entity index, l_range) input : a list l_reg of regi...
@ is_action_write
Definition: effects.h:293
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
Apply/map an instruction block on all the elements of a list (old fashioned)
Definition: newgen_list.h:226
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
list comp_regions_of_implied_do(expression exp, tag act, transformer context)
}}
Definition: myintrinsics.c:544
bool expression_implied_do_p(e)
Definition: expression.c:817
#define transformer_undefined
Definition: ri.h:2847
#define reference_variable(x)
Definition: ri.h:2326
#define syntax_range(x)
Definition: ri.h:2733
#define transformer_arguments(x)
Definition: ri.h:2871
#define syntax_call(x)
Definition: ri.h:2736
#define call_arguments(x)
Definition: ri.h:711
#define syntax_range_p(x)
Definition: ri.h:2731
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
transformer add_index_range_conditions(transformer pre, entity i, range r, transformer tfb)
Definition: loop.c:711
#define ifdebug(n)
Definition: sg.c:47
string precondition_to_string(transformer pre)
Definition: prettyprint.c:58
entity entity_to_new_value(entity)
Definition: value.c:859
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207

References add_index_range_conditions(), arguments_add_entity(), call_arguments, CAR, CDR, comp_regions_of_expression(), comp_regions_of_implied_do(), comp_regions_of_write(), CompRegionsExactUnion(), debug(), effects_same_action_p(), entity_to_new_value(), exp, EXPRESSION, expression_implied_do_p(), expression_syntax, fprintf(), gen_free_list(), ifdebug, is_action_write, make_reference(), MAP, NIL, pips_assert, precondition_to_string(), print_regions(), project_regions_along_loop_index(), ref, reference_variable, REGION, region_add_to_regions(), region_entity, region_free(), syntax_call, syntax_range, syntax_range_p, syntax_reference, syntax_reference_p, transformer_arguments, transformer_dup(), transformer_free(), and transformer_undefined.

Referenced by comp_regions_of_implied_do(), and comp_regions_of_iolist().

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

◆ comp_regions_of_intrinsic()

list comp_regions_of_intrinsic ( entity  e,
list  args,
transformer  context 
)

}}

myintrinsics.c

{{ comp_regions_of_intrinsic list comp_regions_of_intrinsic(entity e, list args, transformer context) input : a intrinsic function name, the list or arguments, and the calling context. output : the corresponding list of regions. modifies : nothing. comment :

Parameters
argsrgs
contextontext

Definition at line 270 of file myintrinsics.c.

274 {
275  return (proper_comp_regions_of_intrinsic(e, args, context));
276 }
list proper_comp_regions_of_intrinsic(entity e, list args, transformer context)
}}
Definition: myintrinsics.c:286

References proper_comp_regions_of_intrinsic().

Referenced by comp_regions_of_call().

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

◆ comp_regions_of_ioelem()

list comp_regions_of_ioelem ( expression  exp,
tag  act,
transformer  context 
)

}}

{{ comp_regions_of_io_element ==============================================================================

Parameters
expxp
actct
contextontext

Definition at line 461 of file myintrinsics.c.

465 {
466  list lr;
467 
468  debug(5, "comp_regions_of_io_elem", "begin\n");
469  if (act == is_action_write) {
471 
472  debug(6, "comp_regions_of_io_elem", "is_action_write\n");
473  pips_assert("comp_regions_of_ioelem", syntax_reference_p(s));
474 
476  }
477  else {
478  debug(6, "comp_regions_of_io_elem", "is_action_read\n");
480  }
481 
482  debug(5, "comp_regions_of_elem", "end\n");
483 
484  return(lr);
485 }

References comp_regions_of_expression(), comp_regions_of_write(), debug(), exp, expression_syntax, is_action_write, pips_assert, syntax_reference, and syntax_reference_p.

Referenced by io_comp_regions().

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

◆ comp_regions_of_iolist()

list comp_regions_of_iolist ( list  exprs,
tag  act,
transformer  context 
)

}}

{{ comp_regions_of_io_list ==============================================================================

There is a bug with effects of io list

READ *,N,(T(I),I=1,N)

there is write effect on N but for the io list, we don't have this effect !

Cause : there is no loop for the list exprs !!! /NN:2000/

Parameters
exprsxprs
actct
contextontext

Definition at line 489 of file myintrinsics.c.

493 {
494  list le = NIL;
495  debug(5, "comp_regions_of_io_list", "begin\n");
496  while (!ENDP(exprs))
497  {
498  expression exp = EXPRESSION(CAR(exprs));
499  list lep = NIL;
500 
501  /* There is a bug with effects of io list
502 
503  READ *,N,(T(I),I=1,N)
504 
505  there is write effect on N but for the io list,
506  we don't have this effect !
507 
508  Cause : there is no loop for the list exprs !!! /NN:2000/ */
509 
512  }
513  else {
514  if (act == is_action_write) {
516 
517  debug(6, "comp_regions_of_io_list", "is_action_write");
518  pips_assert("comp_regions_of_iolist", syntax_reference_p(s));
520  }
521  else {
522  debug(6, "comp_regions_of_io_elem", "is_action_read");
524  }
525  }
526 
528 
529  exprs = CDR(exprs);
530  }
531 
532  debug(5, "comp_regions_of_io_list", "end\n");
533 
534  return(le);
535 }
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66

References CAR, CDR, comp_regions_of_expression(), comp_regions_of_implied_do(), comp_regions_of_write(), CompRegionsExactUnion(), debug(), effects_same_action_p(), ENDP, exp, EXPRESSION, expression_implied_do_p(), expression_syntax, is_action_write, NIL, pips_assert, syntax_reference, and syntax_reference_p.

Referenced by io_comp_regions().

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

◆ io_comp_regions()

list io_comp_regions ( entity  e,
list  args,
transformer  context 
)

}}

{{ io_comp_regions

regions effects on logical units - taken from effects/io.c

We simulate actions on files by read/write actions to a static integer array GO: It is necessary to do a read and and write action to the array, because it updates the file-pointer so it reads it and then writes it ...

Parameters
argsrgs
contextontext

Definition at line 378 of file myintrinsics.c.

382 {
383  list le = NIL, pc, lep;
384 
385  debug(5, "io_comp_regions", "begin\n");
386 
387  for (pc = args; pc != NIL; pc = CDR(pc)) {
389  entity ci;
391 
392  pips_assert("io_comp_regions", syntax_call_p(s));
393 
394  ci = call_function(syntax_call(s));
396 
397  pc = CDR(pc);
398 
399  if (strcmp(p->IoElementName, "IOLIST=") == 0) {
401  }
402  else {
404  p->ReadOrWrite, context);
405  }
406 
407  if (p->MayOrMust == is_approximation_may)
408  {
409  MAP(REGION, reg,
410  {
413  }, lep);
414  }
415 
417 
418  /* regions effects on logical units - taken from effects/io.c */
419  if ((get_bool_property ("PRETTYPRINT_IO_EFFECTS")) &&
420  (pc != NIL) &&
421  (strcmp(p->IoElementName, "UNIT=") == 0))
422  {
423  /* We simulate actions on files by read/write actions
424  to a static integer array
425  GO:
426  It is necessary to do a read and and write action to
427  the array, because it updates the file-pointer so
428  it reads it and then writes it ...*/
429  entity private_io_entity;
430  reference ref;
431  list indices = NIL;
432 
435  EXPRESSION(CAR(pc)),NIL));
436 
437  private_io_entity = FindEntity(TOP_LEVEL_MODULE_NAME,
439 
440  pips_assert("regions_effects", private_io_entity != entity_undefined);
441 
442  ref = make_reference(private_io_entity,indices);
443  le = CompRegionsExactUnion(le,
446  le = CompRegionsExactUnion(le,
449 
450  }
451 
452  }
453 
454  debug(5, "io_comp_regions", "end\n");
455 
456  return(le);
457 }
list comp_regions_of_read(reference, transformer)
}}}
Definition: propagate.c:715
#define approximation_tag(x)
Definition: effects.h:362
@ is_approximation_may
Definition: effects.h:341
#define effect_approximation(x)
Definition: effects.h:644
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
static list indices
Definition: icm.c:204
static IoElementDescriptor * SearchIoElement(char *s, char *i) const
}}
Definition: myintrinsics.c:361
list comp_regions_of_iolist(list exprs, tag act, transformer context)
}}
Definition: myintrinsics.c:489
list comp_regions_of_ioelem(expression exp, tag act, transformer context)
}}
Definition: myintrinsics.c:461
#define TOP_LEVEL_MODULE_NAME
Module containing the global variables in Fortran and C.
Definition: naming-local.h:101
#define IO_EFFECTS_ARRAY_NAME
array of Logical UNits; it is more or less handled as the current file pointer; in C,...
entity FindEntity(const char *package, const char *name)
Retrieve an entity from its package/module name and its local name.
Definition: entity.c:1503
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
Definition: entity.c:453
#define call_function(x)
Definition: ri.h:709
#define syntax_call_p(x)
Definition: ri.h:2734
#define entity_undefined
Definition: ri.h:2761

References approximation_tag, call_function, CAR, CDR, comp_regions_of_ioelem(), comp_regions_of_iolist(), comp_regions_of_read(), comp_regions_of_write(), CompRegionsExactUnion(), CONS, debug(), effect_approximation, effects_same_action_p(), entity_local_name(), entity_undefined, EXPRESSION, expression_syntax, FindEntity(), gen_nconc(), get_bool_property(), indices, IO_EFFECTS_ARRAY_NAME, IoElementDescriptor::IoElementName, is_approximation_may, make_reference(), MAP, IoElementDescriptor::MayOrMust, NIL, pips_assert, IoElementDescriptor::ReadOrWrite, ref, REGION, SearchIoElement(), syntax_call, syntax_call_p, and TOP_LEVEL_MODULE_NAME.

+ Here is the call graph for this function:

◆ no_write_comp_regions()

list no_write_comp_regions ( entity __attribute__((unused))  e,
list  args,
transformer  context 
)

}}

{{ no_write_comp_regions ==============================================================================

Definition at line 315 of file myintrinsics.c.

318 {
319  list lr;
320 
321  debug(5, "no_write_comp_regions", "begin\n");
323  debug(5, "no_write_comp_regions", "end\n");
324  return(lr);
325 }
list comp_regions_of_expressions(list, transformer)
}}}
Definition: propagate.c:678

References comp_regions_of_expressions(), and debug().

+ Here is the call graph for this function:

◆ proper_comp_regions_of_intrinsic()

list proper_comp_regions_of_intrinsic ( entity  e,
list  args,
transformer  context 
)

}}

{{ proper_comp_regions_of_intrinsic list proper_comp_regions_of_intrinsic(entity e, list args, transformer context) input : a intrinsic function name, the list or arguments, and the calling context. output : the corresponding list of regions. modifies : nothing. comment :

Parameters
argsrgs
contextontext

Definition at line 286 of file myintrinsics.c.

290 {
291  const char* s = entity_local_name(e);
293  list lr;
294 
295  debug(3, "proper_comp_regions_of_intrinsic", "begin\n");
296 
297  while (pid->name != NULL) {
298  if (strcmp(pid->name, s) == 0) {
299  lr = (*(pid->f))(e, args, context);
300  debug(3, "proper_comp_regions_of_intrinsic", "end\n");
301  return(lr);
302  }
303 
304  pid += 1;
305  }
306 
307  pips_internal_error("unknown intrinsic %s", s);
308 
309  return(NIL);
310 }
static IntrinsicEffectDescriptor IntrinsicDescriptorTable[]
Definition: myintrinsics.c:125
the following data structure describes an intrinsic function: its name and the function to apply on a...
Definition: myintrinsics.c:120

References debug(), entity_local_name(), IntrinsicEffectDescriptor::f, IntrinsicDescriptorTable, IntrinsicEffectDescriptor::name, NIL, and pips_internal_error.

Referenced by comp_regions_of_intrinsic().

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

◆ SearchIoElement()

static IoElementDescriptor* SearchIoElement ( char *  s,
char *  i 
) const
static

}}

{{ SearchIoElements

Never reaches this point. Only to avoid a warning at compile time. BC.

Definition at line 361 of file myintrinsics.c.

363 {
365 
366  while (p->StmtName != NULL) {
367  if (strcmp(p->StmtName, s) == 0 && strcmp(p->IoElementName, i) == 0)
368  return(p);
369  p += 1;
370  }
371 
372  pips_internal_error("unknown io element %s %s", s, i);
373  /* Never reaches this point. Only to avoid a warning at compile time. BC. */
375 }
static IoElementDescriptor IoElementDescriptorUndefined
Definition: myintrinsics.c:48
static IoElementDescriptor IoElementDescriptorTable[]
Definition: myintrinsics.c:50

References IoElementDescriptorTable, IoElementDescriptorUndefined, IoElementDescriptor::IoElementName, pips_internal_error, and IoElementDescriptor::StmtName.

Referenced by io_comp_regions().

+ Here is the caller graph for this function:

Variable Documentation

◆ IntrinsicDescriptorTable

IntrinsicEffectDescriptor IntrinsicDescriptorTable[]
static

Definition at line 125 of file myintrinsics.c.

Referenced by proper_comp_regions_of_intrinsic().

◆ IoElementDescriptorTable

IoElementDescriptor IoElementDescriptorTable[]
static

Definition at line 50 of file myintrinsics.c.

Referenced by SearchIoElement().

◆ IoElementDescriptorUndefined

IoElementDescriptor IoElementDescriptorUndefined
static

Definition at line 48 of file myintrinsics.c.

Referenced by SearchIoElement().