PIPS
cmfortran.c File Reference
#include <stdio.h>
#include <string.h>
#include "linear.h"
#include "genC.h"
#include "text-util.h"
#include "ri-util.h"
#include "prettyprint.h"
+ Include dependency graph for cmfortran.c:

Go to the source code of this file.

Functions

conswords_cmf_loop_range (range obj)
 Prettyprinter for CM FORTRAN loops. More...
 
text text_loop_cmf (entity module, const char *label, int margin, loop obj, int n, list lr, list lidx)
 ===================================================================== More...
 

Function Documentation

◆ text_loop_cmf()

text text_loop_cmf ( entity  module,
const char*  label,
int  margin,
loop  obj,
int  n,
list  lr,
list  lidx 
)

=====================================================================

Parameters
moduleodule
labelabel
marginargin
objbj
lrr
lidxidx

Definition at line 66 of file cmfortran.c.

73 {
74  text result_text = text_undefined;
75  instruction i;
76  entity idx;
77  range r;
78 
80  idx = loop_index(obj);
81  r = loop_range(obj);
82 
83  lr = gen_nconc(lr, CONS(RANGE, r, NIL));
84  lidx = gen_nconc(lidx, CONS(ENTITY, idx, NIL));
85 
86  if(!instruction_assign_p(i)) {
87  if(instruction_loop_p(i)) {
88  result_text = text_loop_cmf(module, label, margin,
89  instruction_loop(i), n, lr, lidx);
90  }
91  }
92  else {
93  list pc, lli, llr;
94  unformatted u;
95 
96  pc = CHAIN_SWORD(NIL, "FORALL(");
97  for(lli = lidx, llr = lr; !ENDP(lli); POP(lli), POP(llr)) {
98  pc = CHAIN_SWORD(pc, entity_local_name(ENTITY(CAR(lli))));
99  pc = CHAIN_SWORD(pc, " = ");
100  pc = gen_nconc(pc, words_cmf_loop_range(RANGE(CAR(llr))));
101  if(CDR(lli) != NIL)
102  pc = CHAIN_SWORD(pc, ", ");
103  }
104  pc = CHAIN_SWORD(pc, ") ");
105  pc = gen_nconc(pc, Words_Call(instruction_call(i), 0, true, true));
106  u = make_unformatted(strdup(label), n, margin, pc) ;
107  result_text = make_text(CONS(SENTENCE,
109  u),
110  NIL));
111  }
112  return(result_text);
113 }
unformatted make_unformatted(string a1, intptr_t a2, intptr_t a3, list a4)
Definition: text.c:149
sentence make_sentence(enum sentence_utype tag, void *val)
Definition: text.c:59
text make_text(list a)
Definition: text.c:107
text text_loop_cmf(entity module, const char *label, int margin, loop obj, int n, list lr, list lidx)
=====================================================================
Definition: cmfortran.c:66
cons * words_cmf_loop_range(range obj)
Prettyprinter for CM FORTRAN loops.
Definition: cmfortran.c:46
bool instruction_assign_p(instruction i)
Test if an instruction is an assignment.
Definition: instruction.c:164
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
#define POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#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
#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
static char * module
Definition: pips.c:74
list Words_Call(call obj, int precedence, bool leftmost, bool is_a_subroutine)
Definition: misc.c:2597
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 loop_body(x)
Definition: ri.h:1644
#define instruction_loop_p(x)
Definition: ri.h:1518
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define instruction_loop(x)
Definition: ri.h:1520
#define RANGE(x)
RANGE.
Definition: ri.h:2257
#define statement_instruction(x)
Definition: ri.h:2458
#define instruction_call(x)
Definition: ri.h:1529
#define loop_range(x)
Definition: ri.h:1642
#define loop_index(x)
Definition: ri.h:1640
char * strdup()
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
#define CHAIN_SWORD(l, s)
#define SENTENCE(x)
newgen_unformatted_domain_defined
Definition: text.h:36
#define text_undefined
Definition: text.h:91
@ is_sentence_unformatted
Definition: text.h:58

References CAR, CDR, CHAIN_SWORD, CONS, ENDP, ENTITY, entity_local_name(), gen_nconc(), instruction_assign_p(), instruction_call, instruction_loop, instruction_loop_p, is_sentence_unformatted, loop_body, loop_index, loop_range, make_sentence(), make_text(), make_unformatted(), module, NIL, POP, RANGE, SENTENCE, statement_instruction, strdup(), text_undefined, Words_Call(), and words_cmf_loop_range().

Referenced by text_loop().

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

◆ words_cmf_loop_range()

cons* words_cmf_loop_range ( range  obj)

Prettyprinter for CM FORTRAN loops.

cmfortran.c

There are memory leaks here since a new expression is constructed. =====================================================================

expression_constant_p(range_increment(obj)) &&

Parameters
objbj

Definition at line 46 of file cmfortran.c.

48 {
49  cons *pc;
51 
52  pc = Words_Subexpression(range_lower(obj), 0, true);
53  pc = CHAIN_SWORD(pc,":");
54  pc = gen_nconc(pc, Words_Subexpression(range_upper(obj), 0, true));
55  if (/* expression_constant_p(range_increment(obj)) && */
56  strcmp( entity_local_name(call_function(c)), "1") == 0 )
57  return(pc);
58  pc = CHAIN_SWORD(pc,":");
60 
61  return(pc);
62 }
list Words_Subexpression(expression obj, int precedence, bool leftmost)
Definition: misc.c:2695
list Words_Expression(expression obj)
of string
Definition: misc.c:2616
#define call_function(x)
Definition: ri.h:709
#define range_upper(x)
Definition: ri.h:2290
#define range_increment(x)
Definition: ri.h:2292
#define syntax_call(x)
Definition: ri.h:2736
#define range_lower(x)
Definition: ri.h:2288
#define expression_syntax(x)
Definition: ri.h:1247

References call_function, CHAIN_SWORD, entity_local_name(), expression_syntax, gen_nconc(), range_increment, range_lower, range_upper, syntax_call, Words_Expression(), and Words_Subexpression().

Referenced by text_loop_cmf().

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