PIPS
flint_utils.c File Reference
#include "local.h"
+ Include dependency graph for flint_utils.c:

Go to the source code of this file.

Macros

#define FATAL(msg, value)   {fprintf(stderr,msg,value);exit(1);}
 Print error message and exit from flint. More...
 

Functions

bool number_of_elements (list ld, intptr_t *the_result)
 flint_utils.c More...
 
bool size_of_dimension (dimension d, intptr_t *the_int)
 this function computes the size of a dimension. More...
 
bool control_type_in_expression (enum basic_utype a_basic, int __attribute__((unused)) a_dim, expression exp)
 
bool find_bd_parameter (parameter param, basic *base, list *dims)
 
bool find_bd_type_variable (type tp, basic *base, list *dims)
 
bool find_bd_expression (expression exp, basic *base, list *dims)
 
bool find_bd_reference (reference ref, basic *base, list *dims)
 
bool find_bd_call (call c, basic *base, list *dims)
 

Macro Definition Documentation

◆ FATAL

#define FATAL (   msg,
  value 
)    {fprintf(stderr,msg,value);exit(1);}

Print error message and exit from flint.

Definition at line 42 of file flint_utils.c.

Function Documentation

◆ control_type_in_expression()

bool control_type_in_expression ( enum basic_utype  a_basic,
int __attribute__((unused))  a_dim,
expression  exp 
)

else

Definition at line 94 of file flint_utils.c.

97 {
98  basic b;
99  list d;
100  intptr_t n;
101  bool ok_dim = false, ok = find_bd_expression(exp, &b, &d);
102 
103  if (ok)
104  ok_dim = number_of_elements(d, &n);
105 
106  if (ok && ok_dim)
107  return ((basic_tag(b) == a_basic) && (n = 1));
108 
109  /* else */
110 
111  flint_message("control type in expression",
112  "warning : cannot verify the type\n");
113  return (true);
114 }
void flint_message(char *fun, char *fmt,...)
Definition: flint.c:147
bool find_bd_expression(expression exp, basic *base, list *dims)
Definition: flint_utils.c:141
bool number_of_elements(list ld, intptr_t *the_result)
flint_utils.c
Definition: flint_utils.c:50
#define basic_tag(x)
Definition: ri.h:613
static bool ok
#define intptr_t
Definition: stdint.in.h:294
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207

References basic_tag, exp, find_bd_expression(), flint_message(), intptr_t, number_of_elements(), and ok.

+ Here is the call graph for this function:

◆ find_bd_call()

bool find_bd_call ( call  c,
basic base,
list dims 
)
Parameters
basease
dimsims

Definition at line 191 of file flint_utils.c.

195 {
196  entity fct = call_function(c);
197  type tp = entity_type(fct);
198 
199  if (!type_functional_p(tp)) {
200  flint_message("find_bd_call",
201  "very strange function encountered\n");
202  return (false);
203  }
205 }
bdt base
Current expression.
Definition: bdt_read_paf.c:100
bool find_bd_type_variable(type tp, basic *base, list *dims)
Definition: flint_utils.c:125
#define type_functional_p(x)
Definition: ri.h:2950
#define functional_result(x)
Definition: ri.h:1444
#define call_function(x)
Definition: ri.h:709
#define type_functional(x)
Definition: ri.h:2952
#define entity_type(x)
Definition: ri.h:2792

References base, call_function, entity_type, find_bd_type_variable(), flint_message(), functional_result, type_functional, and type_functional_p.

Referenced by find_bd_expression().

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

◆ find_bd_expression()

bool find_bd_expression ( expression  exp,
basic base,
list dims 
)
Parameters
expxp
basease
dimsims

Definition at line 141 of file flint_utils.c.

145 {
147  reference re;
148  call c;
149 
150  switch (syntax_tag(s)) {
151  case is_syntax_reference:
152  re = syntax_reference(s);
153  return (find_bd_reference(re, base, dims));
154  case is_syntax_range:
155  flint_message("find_bd_expression", "no basic in this expression\n");
156  return (false);
157  case is_syntax_call:
158  c = syntax_call(s);
159  return (find_bd_call(c, base, dims));
160  default:
161  FATAL("find_bd_expression : unexpected tag %u\n", syntax_tag(s));
162  }
163 
164  return (false);
165 }
#define FATAL(msg, value)
Print error message and exit from flint.
Definition: flint_utils.c:42
bool find_bd_call(call c, basic *base, list *dims)
Definition: flint_utils.c:191
bool find_bd_reference(reference ref, basic *base, list *dims)
Definition: flint_utils.c:167
#define syntax_reference(x)
Definition: ri.h:2730
#define syntax_tag(x)
Definition: ri.h:2727
@ is_syntax_range
Definition: ri.h:2692
@ is_syntax_call
Definition: ri.h:2693
@ is_syntax_reference
Definition: ri.h:2691
#define syntax_call(x)
Definition: ri.h:2736
#define expression_syntax(x)
Definition: ri.h:1247

References base, exp, expression_syntax, FATAL, find_bd_call(), find_bd_reference(), flint_message(), is_syntax_call, is_syntax_range, is_syntax_reference, syntax_call, syntax_reference, and syntax_tag.

Referenced by check_call_basic_and_dim(), check_call_intrinsic(), and control_type_in_expression().

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

◆ find_bd_parameter()

bool find_bd_parameter ( parameter  param,
basic base,
list dims 
)
Parameters
paramaram
basease
dimsims

Definition at line 116 of file flint_utils.c.

120 {
121  type tp = parameter_type(param);
122  return (find_bd_type_variable(tp, base, dims));
123 }
#define parameter_type(x)
Definition: ri.h:1819
Definition: replace.c:135

References base, find_bd_type_variable(), and parameter_type.

Referenced by check_call_basic_and_dim().

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

◆ find_bd_reference()

bool find_bd_reference ( reference  ref,
basic base,
list dims 
)
Parameters
refef
basease
dimsims

Definition at line 167 of file flint_utils.c.

171 {
173  list ind = reference_indices(ref);
174  type tp = entity_type(var);
175  int len_ind = gen_length(ind), len_dim, i;
176  bool ok;
177 
178  ok = find_bd_type_variable(tp, base, dims);
179  if (!ok)
180  return (false);
181 
182  len_dim = gen_length((*dims));
183  if (len_dim < len_ind)
184  return (false);
185 
186  for (i = 1; i <= len_ind; i++)
187  (*dims) = CDR(*dims);
188  return (true);
189 }
static reference ref
Current stmt (an integer)
Definition: adg_read_paf.c:163
size_t gen_length(const list l)
Definition: list.c:150
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
#define reference_variable(x)
Definition: ri.h:2326
#define reference_indices(x)
Definition: ri.h:2328

References base, CDR, entity_type, find_bd_type_variable(), gen_length(), ok, ref, reference_indices, and reference_variable.

Referenced by find_bd_expression().

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

◆ find_bd_type_variable()

bool find_bd_type_variable ( type  tp,
basic base,
list dims 
)
Parameters
tpp
basease
dimsims

Definition at line 125 of file flint_utils.c.

129 {
130  if (!type_variable_p(tp)) {
131  flint_message("find_bd_type_var",
132  "very strange type encountered, waiting for a variable\n");
133  return (false);
134  }
136  *dims = variable_dimensions(type_variable(tp));
137 
138  return (true);
139 }
#define type_variable(x)
Definition: ri.h:2949
#define variable_dimensions(x)
Definition: ri.h:3122
#define type_variable_p(x)
Definition: ri.h:2947
#define variable_basic(x)
Definition: ri.h:3120

References base, flint_message(), type_variable, type_variable_p, variable_basic, and variable_dimensions.

Referenced by check_overlap_in_common(), check_the_reference(), find_bd_call(), find_bd_parameter(), find_bd_reference(), and position_in_the_area().

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

◆ number_of_elements()

bool number_of_elements ( list  ld,
intptr_t the_result 
)

flint_utils.c

Parameters
ldd
the_resulthe_result

Definition at line 50 of file flint_utils.c.

53 {
54  list pc;
55  intptr_t a_temp_int;
56  bool ok = true;
57 
58  (*the_result) = 1;
59 
60  for (pc = ld;
61  (pc != NULL) && (ok = size_of_dimension(DIMENSION(CAR(pc)), &a_temp_int));
62  pc = CDR(pc)) {
63  (*the_result) *= a_temp_int;
64  }
65 
66  return (ok);
67 }
bool size_of_dimension(dimension d, intptr_t *the_int)
this function computes the size of a dimension.
Definition: flint_utils.c:71
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92

References CAR, CDR, DIMENSION, intptr_t, ok, and size_of_dimension().

Referenced by check_call_dim(), control_type_in_expression(), make_emulated_shared_variable(), and position_in_the_area().

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

◆ size_of_dimension()

bool size_of_dimension ( dimension  d,
intptr_t the_int 
)

this function computes the size of a dimension.

else

Parameters
the_inthe_int

Definition at line 71 of file flint_utils.c.

74 {
75  intptr_t upper_dim, lower_dim;
76 
77  if (expression_integer_value(dimension_upper(d), &upper_dim) &&
78  expression_integer_value(dimension_lower(d), &lower_dim)) {
79  (*the_int) = upper_dim - lower_dim + 1;
80  return (true);
81  }
82  /* else */
83  return (false);
84 }
bool expression_integer_value(expression e, intptr_t *pval)
Definition: eval.c:792
#define dimension_lower(x)
Definition: ri.h:980
#define dimension_upper(x)
Definition: ri.h:982

References dimension_lower, dimension_upper, expression_integer_value(), and intptr_t.

Referenced by number_of_elements().

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