PIPS
sac.h File Reference
#include "sac_private.h"
#include "dg.h"
#include "graph.h"
+ Include dependency graph for sac.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define FUNC_TO_ATOMIZE_P(call)
 
#define IF_TO_CONVERT   "PIPS IF_TO_CONVERT"
 if conversion More...
 
#define IF_CONV_TO_COMPACT   "PIPS IF_CONV_TO_COMPACT"
 
#define ENTITY_FUNCTION_P(f)
 
#define SIMD_MASKED_SUFFIX   "_MASKED"
 simd_loop_const_elim.c More...
 
#define SIMD_GENERIC_SUFFIX   "_GENERIC"
 
#define SIMD_CONSTANT_SUFFIX   "_CONSTANT"
 
#define SIMD_BROADCAST_SUFFIX   "_BROADCAST"
 
#define SAC_PADDING_ENTITY_NAME   "PADDING_VALUE"
 
#define STATEMENT_INFO_NEWGEN_DOMAIN   SIMDSTATEMENTINFO_NEWGEN_DOMAIN
 
#define gen_STATEMENT_INFO_cons   gen_SIMDSTATEMENTINFO_cons
 
#define CHECK_VECTORELEMENT(ve)
 

Typedefs

typedef hash_table operator_id_sons
 Warning! Do not modify this file that is automatically generated! More...
 
typedef dg_arc_label arc_label
 
typedef dg_vertex_label vertex_label
 

Functions

int patterns_yyparse ()
 
int patterns_yylex ()
 
void patterns_yyerror (const char *)
 
bool if_conversion_compact (char *)
 cproto-generated files More...
 
bool if_conversion_init (char *)
 if_conversion_init.c More...
 
match get_statement_match_of_kind (statement, opcodeClass)
 simdizer.c More...
 
string sac_commenter (entity)
 
bool simdizer (char *)
 
bool simdizer_init (const char *)
 
int effective_variables_width (instruction)
 varwidth.c More...
 
void init_vector_to_expressions (void)
 codegen.c More...
 
void reset_vector_to_expressions (void)
 
void invalidate_expressions_in_statement (statement)
 
bool expression_reference_or_field_p (expression)
 
bool simd_vector_entity_p (entity)
 
int get_subwordSize_from_opcode (opcode, int)
 
opcode generate_opcode (string, list, float)
 auto-guess vector size More...
 
expression distance_between_expression (const expression, const expression)
 computes the distance betwwen two expression More...
 
bool sac_aligned_entity_p (entity)
 
statement make_shuffle_statement (entity *, list, int *)
 
simdstatement make_simd_statements (set, list)
 
list generate_simd_code (simdstatement, float *)
 
bool loop_auto_unroll (const char *)
 unroll.c More...
 
bool simdizer_auto_unroll (char *)
 
bool simdizer_auto_tile (const char *)
 
void set_simd_operator_mappings (void *)
 operatorid.c More...
 
void reset_simd_operator_mappings (void)
 
int get_operator_id (entity)
 
bool simd_operator_mappings (const string)
 
void set_simd_treematch (matchTree)
 treematch.c More...
 
void reset_simd_treematch (void)
 
void simd_reset_finalArgType (void)
 
void simd_fill_finalArgType (statement)
 
void simd_fill_curArgType (statement)
 
bool simd_check_argType (void)
 
list match_statement (statement)
 return a list of matching statements More...
 
void insert_opcodeClass (char *, int, list)
 
void insert_pattern (char *, list, list)
 
bool simd_treematcher (const string)
 
statement simd_atomize_this_expression (entity(*)(entity, basic), expression)
 atomizer.c More...
 
bool simd_atomizer (char *)
 
bool reduction_atomization (const char *)
 
void insert_transformation (char *, int, int, int, int, int, list)
 vectransform.c More...
 
bool sac_expression_reduction_p (expression)
 reductions.c More...
 
bool simd_remove_reductions (char *)
 remove reductions by expanding reduced scalar to an array More...
 
bool redundant_load_store_elimination (char *)
 
bool scalar_renaming (char *)
 singleass.c More...
 
bool deatomizer (char *)
 deatomizer.c More...
 
bool if_conversion (char *)
 if_conversion.c More...
 
bool loop_nest_unswitching (const char *)
 
bool simd_memory_packing (char *)
 simd_memory_packing.c More...
 
int patterns_yywrap (void)
 
void patterns_yyrestart (FILE *)
 
void patterns_yypop_buffer_state (void)
 
int patterns_yyget_lineno (void)
 
FILE * patterns_yyget_in (void)
 
FILE * patterns_yyget_out (void)
 
int patterns_yyget_leng (void)
 
char * patterns_yyget_text (void)
 
void patterns_yyset_lineno (int)
 
void patterns_yyset_in (FILE *)
 
void patterns_yyset_out (FILE *)
 
int patterns_yyget_debug (void)
 
void patterns_yyset_debug (int)
 
int patterns_yylex_destroy (void)
 
void * patterns_yyalloc (yy_size_t)
 
void * patterns_yyrealloc (void *, yy_size_t)
 
void patterns_yyfree (void *)
 

Variables

FILE * patterns_yyin
 symbols exported by the parser More...
 
size_t sac_lineno
 patterns.c More...
 
statement sac_current_block
 
instruction sac_real_current_instruction
 
int patterns_yychar
 
int patterns_yynerrs
 
int patterns_yyleng
 lexer.c More...
 
FILE * patterns_yyout
 
int patterns_yylineno
 
int patterns_yy_flex_debug
 
char * patterns_yytext
 

Macro Definition Documentation

◆ CHECK_VECTORELEMENT

#define CHECK_VECTORELEMENT (   ve)
Value:
do {\
pips_assert("vector Index seems legal",vectorElement_vectorIndex(ve) >= 0 && vectorElement_vectorIndex(ve) < simdStatementInfo_nbArgs(vectorElement_statement(ve)));\
} while(0)

Definition at line 70 of file sac.h.

◆ ENTITY_FUNCTION_P

#define ENTITY_FUNCTION_P (   f)
Value:
size_t gen_length(const list l)
Definition: list.c:150
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
#define module_functional_parameters(func)
#define type_functional_p(x)
Definition: ri.h:2950
#define entity_type(x)
Definition: ri.h:2792

Definition at line 55 of file sac.h.

◆ FUNC_TO_ATOMIZE_P

#define FUNC_TO_ATOMIZE_P (   call)
Value:
(\
type_functional_p(entity_type(call_function(call))) && \
)
#define ENTITY_DEREFERENCING_P(e)
#define ENTITY_POINT_TO_P(e)
#define ENTITY_FIELD_P(e)
C data structure and pointer management.
#define call_function(x)
Definition: ri.h:709

Definition at line 42 of file sac.h.

◆ gen_STATEMENT_INFO_cons

#define gen_STATEMENT_INFO_cons   gen_SIMDSTATEMENTINFO_cons

Definition at line 67 of file sac.h.

◆ IF_CONV_TO_COMPACT

#define IF_CONV_TO_COMPACT   "PIPS IF_CONV_TO_COMPACT"

Definition at line 52 of file sac.h.

◆ IF_TO_CONVERT

#define IF_TO_CONVERT   "PIPS IF_TO_CONVERT"

if conversion

Definition at line 51 of file sac.h.

◆ SAC_PADDING_ENTITY_NAME

#define SAC_PADDING_ENTITY_NAME   "PADDING_VALUE"

Definition at line 64 of file sac.h.

◆ SIMD_BROADCAST_SUFFIX

#define SIMD_BROADCAST_SUFFIX   "_BROADCAST"

Definition at line 63 of file sac.h.

◆ SIMD_CONSTANT_SUFFIX

#define SIMD_CONSTANT_SUFFIX   "_CONSTANT"

Definition at line 62 of file sac.h.

◆ SIMD_GENERIC_SUFFIX

#define SIMD_GENERIC_SUFFIX   "_GENERIC"

Definition at line 61 of file sac.h.

◆ SIMD_MASKED_SUFFIX

#define SIMD_MASKED_SUFFIX   "_MASKED"

simd_loop_const_elim.c

Definition at line 60 of file sac.h.

◆ STATEMENT_INFO_NEWGEN_DOMAIN

#define STATEMENT_INFO_NEWGEN_DOMAIN   SIMDSTATEMENTINFO_NEWGEN_DOMAIN

Definition at line 66 of file sac.h.

Typedef Documentation

◆ arc_label

Definition at line 36 of file sac.h.

◆ operator_id_sons

Warning! Do not modify this file that is automatically generated!

Modify src/Libs/sac/sac-local.h instead, to add your own modifications. header file built by cproto sac-local.h

Definition at line 32 of file sac.h.

◆ vertex_label

Definition at line 37 of file sac.h.

Function Documentation

◆ deatomizer()

bool deatomizer ( char *  mod_name)

deatomizer.c

get the resources

Now do the job

Reorder the module, because new statements have been added

update/release resources

Parameters
mod_nameod_name

Definition at line 726 of file deatomizer.c.

727 {
728  /* get the resources */
729  statement mod_stmt = (statement)
730  db_get_memory_resource(DBR_CODE, mod_name, true);
731 
734  set_ordering_to_statement(mod_stmt);
735 
736  dep_graph = (graph) db_get_memory_resource(DBR_DG, mod_name, true);
737 
739  db_get_memory_resource(DBR_PROPER_EFFECTS, mod_name, true));
740 
741  debug_on("DEATOMIZER");
742 
743  /* Now do the job */
744 
745  // To prevent some warnings
747 
748  gen_recurse(mod_stmt, statement_domain,
750 
751  // Restore the warning
753 
754  pips_assert("Statement is consistent after DEATOMIZER",
755  statement_consistent_p(mod_stmt));
756 
757  /* Reorder the module, because new statements have been added */
758  module_reorder(mod_stmt);
759  DB_PUT_MEMORY_RESOURCE(DBR_CODE, mod_name, mod_stmt);
760 
761  /* update/release resources */
766 
767  debug_off();
768 
769  return true;
770 }
bool statement_consistent_p(statement p)
Definition: ri.c:2195
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
static bool da_simple_sequence_filter(statement s)
Definition: deatomizer.c:698
static void da_simple_statements(statement s)
Definition: deatomizer.c:676
static graph dep_graph
Definition: deatomizer.c:65
void reset_proper_rw_effects(void)
void set_proper_rw_effects(statement_effects)
#define gen_recurse(start, domain_number, flt, rwt)
Definition: genC.h:283
struct _newgen_struct_graph_ * graph
Definition: graph.h:31
void reset_current_module_entity(void)
Reset the current module entity.
Definition: static.c:97
void reset_current_module_statement(void)
Reset the current module statement.
Definition: static.c:221
statement set_current_module_statement(statement)
Set the current module statement.
Definition: static.c:165
entity set_current_module_entity(entity)
static.c
Definition: static.c:66
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
Definition: database.c:755
#define DB_PUT_MEMORY_RESOURCE(res_name, own_name, res_val)
conform to old interface.
Definition: pipsdbm-local.h:66
void hash_dont_warn_on_redefinition(void)
Definition: hash.c:188
void hash_warn_on_redefinition(void)
these function set the variable should_i_warn_on_redefinition to the value true or false
Definition: hash.c:183
#define debug_on(env)
Definition: misc-local.h:157
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define debug_off()
Definition: misc-local.h:160
hash_table set_ordering_to_statement(statement s)
To be used instead of initialize_ordering_to_statement() to make sure that the hash table ots is in s...
Definition: ordering.c:172
void reset_ordering_to_statement(void)
Reset the mapping from ordering to statement.
Definition: ordering.c:185
bool module_reorder(statement body)
Reorder a module and recompute order to statement if any.
Definition: reorder.c:244
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
Definition: entity.c:1479
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362

References da_simple_sequence_filter(), da_simple_statements(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, dep_graph, gen_recurse, hash_dont_warn_on_redefinition(), hash_warn_on_redefinition(), module_name_to_entity(), module_reorder(), pips_assert, reset_current_module_entity(), reset_current_module_statement(), reset_ordering_to_statement(), reset_proper_rw_effects(), set_current_module_entity(), set_current_module_statement(), set_ordering_to_statement(), set_proper_rw_effects(), statement_consistent_p(), and statement_domain.

+ Here is the call graph for this function:

◆ distance_between_expression()

expression distance_between_expression ( const expression  exp0,
const expression  exp1 
)

computes the distance betwwen two expression

Returns
expression_undefined if not comparable, an expression of the distance otherwise

reference with different variables have an infinite distance

Parameters
exp0xp0
exp1xp1

Definition at line 419 of file codegen.c.

420 {
421  bool eval_sizeof = get_bool_property("EVAL_SIZEOF");
422  set_bool_property("EVAL_SIZEOF",true);
425  {
426  reference r0 = expression_reference(exp0),
427  r1 = expression_reference(exp1);
428 
429  /* reference with different variables have an infinite distance */
430  entity e0 = reference_variable(r0),
431  e1 = reference_variable(r1);
432  expression edistance = distance_between_entity(e0,e1);
433  if(!expression_undefined_p(edistance))
434  {
435  basic b = basic_of_reference(r0);
436  expression offset0 = sreference_offset(r0),
437  offset1 = sreference_offset(r1);
438  expression distance = make_op_exp(MINUS_OPERATOR_NAME,offset1,offset0);
440  distance,int_to_expression(SizeOfElements(b)));
441  free_basic(b);
442  result= make_op_exp(PLUS_OPERATOR_NAME,distance,edistance);
443  }
444  }
445  else if (expression_field_p(exp0) && expression_field_p(exp1))
446  {
448  str1 = binary_call_lhs(expression_call(exp1));
449  expression lhs_distance = distance_between_expression(str0,str1);
451  if(!expression_undefined_p(lhs_distance) && !expression_undefined_p(rhs_distance))
452  result = make_op_exp(MINUS_OPERATOR_NAME,lhs_distance,rhs_distance);
453  }
454  set_bool_property("EVAL_SIZEOF",eval_sizeof);
455  //maxima_simplify(&result);
456  simplify_expression(&result);
457  return result;
458 }
void free_basic(basic p)
Definition: ri.c:107
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
void set_bool_property(const char *, bool)
#define binary_call_rhs(c)
#define MINUS_OPERATOR_NAME
#define PLUS_OPERATOR_NAME
#define binary_call_lhs(c)
#define MULTIPLY_OPERATOR_NAME
bool simplify_expression(expression *pexp)
use polynomials to simplify an expression in some cases this operation can change the basic of the ex...
Definition: expression.c:3770
bool expression_field_p(expression e)
The expression is of kind "s.a", where "s" is a struct and a "a" field.
Definition: expression.c:491
call expression_call(expression e)
Definition: expression.c:445
expression int_to_expression(_int i)
transform an int into an expression and generate the corresponding entity if necessary; it is not cle...
Definition: expression.c:1188
expression make_op_exp(char *op_name, expression exp1, expression exp2)
================================================================
Definition: expression.c:2012
bool expression_reference_p(expression e)
Test if an expression is a reference.
Definition: expression.c:528
reference expression_reference(expression e)
Short cut, meaningful only if expression_reference_p(e) holds.
Definition: expression.c:1832
_int SizeOfElements(basic)
This function returns the length in bytes of the Fortran or C type represented by a basic,...
Definition: size.c:297
basic basic_of_reference(reference)
Retrieves the basic of a reference in a newly allocated basic object.
Definition: type.c:1459
#define reference_variable(x)
Definition: ri.h:2326
#define expression_undefined
Definition: ri.h:1223
#define expression_undefined_p(x)
Definition: ri.h:1224
static expression sreference_offset(reference r)
computes the offset between an entity and its reference
Definition: codegen.c:373
expression distance_between_expression(const expression exp0, const expression exp1)
computes the distance betwwen two expression
Definition: codegen.c:419
static expression distance_between_entity(const entity e0, const entity e1)
Definition: codegen.c:404

References basic_of_reference(), binary_call_lhs, binary_call_rhs, distance_between_entity(), expression_call(), expression_field_p(), expression_reference(), expression_reference_p(), expression_undefined, expression_undefined_p, free_basic(), get_bool_property(), int_to_expression(), make_op_exp(), MINUS_OPERATOR_NAME, MULTIPLY_OPERATOR_NAME, PLUS_OPERATOR_NAME, reference_variable, set_bool_property(), simplify_expression(), SizeOfElements(), and sreference_offset().

Referenced by comparable_statements_on_distance_p(), compare_statements_on_distance_to_origin(), conflict_is_a_real_conflict_p(), consecutive_expression_p(), and do_simdizer_init().

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

◆ effective_variables_width()

int effective_variables_width ( instruction  i)

varwidth.c

Definition at line 85 of file varwidth.c.

86 {
87  int g_varwidth = 0;
88 
90 
91  return g_varwidth;
92 }
#define gen_context_recurse(start, ctxt, domain_number, flt, rwt)
Definition: genC.h:285
void gen_null2(__attribute__((unused)) void *u1, __attribute__((unused)) void *u2)
idem with 2 args, to please overpeaky compiler checks
Definition: genClib.c:2758
#define reference_domain
newgen_range_domain_defined
Definition: ri.h:338
static bool variables_width_filter(reference r, int *g_varwidth)
Definition: varwidth.c:43

References gen_context_recurse, gen_null2(), reference_domain, and variables_width_filter().

Referenced by compute_parallelism_factor(), and compute_variable_size().

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

◆ expression_reference_or_field_p()

bool expression_reference_or_field_p ( expression  e)

Definition at line 192 of file codegen.c.

193 {
195 }

References expression_field_p(), and expression_reference_p().

Referenced by do_simdizer_init(), get_optimal_opcode(), and sac_statement_to_expressions_gather().

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

◆ generate_opcode()

opcode generate_opcode ( string  name,
list  types,
float  cost 
)

auto-guess vector size

Parameters
nameame
typesypes
costost

Definition at line 276 of file codegen.c.

277 {
278  intptr_t elem_size=0,vector_size = get_int_property("SAC_SIMD_REGISTER_WIDTH");
279  opcode oc = make_opcode(name,vector_size,types,cost);
280  int n = gen_length(types);
281  for(int i=0; i<n;i++)
282  {
283  int curr = get_subwordSize_from_opcode(oc,i);
284  if(curr > elem_size) elem_size=curr;
285  }
286  opcode_vectorSize(oc)/=elem_size;
287  if( opcode_vectorSize(oc) * elem_size !=get_int_property("SAC_SIMD_REGISTER_WIDTH"))
288  pips_user_warning("SAC_SIMD_REGISTER_WIDTH and description of %s leads "
289  "to partially filled register\n", name);
290  return oc;
291 }
int get_int_property(const string)
opcode make_opcode(string a1, intptr_t a2, list a3, float a4)
Definition: sac_private.c:195
#define pips_user_warning
Definition: misc-local.h:146
int get_subwordSize_from_opcode(opcode oc, int argNum)
Definition: codegen.c:246
#define opcode_vectorSize(x)
Definition: sac_private.h:291
#define intptr_t
Definition: stdint.in.h:294

References gen_length(), get_int_property(), get_subwordSize_from_opcode(), intptr_t, make_opcode(), opcode_vectorSize, and pips_user_warning.

+ Here is the call graph for this function:

◆ generate_simd_code()

list generate_simd_code ( simdstatement  ssi,
float *  simdCost 
)

this is the classical generation process: several load, an exec and a store

the order is reversed, but we use it

Parameters
ssisi
simdCostimdCost

Definition at line 1325 of file codegen.c.

1326 {
1327  gSimdCost = 0;
1328 
1329  pips_debug(3,"generate_simd_code 1\n");
1330 
1331  /* this is the classical generation process:
1332  * several load, an exec and a store
1333  */
1334  //First, the load statement(s)
1335  list loads=NIL;
1336  for(int i = 0; i < simdstatement_nbArgs(ssi)-1; i++)
1337  {
1338  statement s = generate_load_statement(ssi, i);
1339  if (! statement_undefined_p(s))
1340  loads = CONS(STATEMENT, s, loads);
1341  }
1342 
1343  //Then, the exec statement
1345 
1346  //Finally, the save statement (always generated. It is up to
1347  //latter phases (USE-DEF elimination....) to remove it, if needed
1349 
1350  list out = NIL;
1351  out=CONS(STATEMENT,save,CONS(STATEMENT,exec,loads));
1352  *simdCost += gSimdCost;
1353  pips_debug(3,"generate_simd_code 2 that costs %lf\n",gSimdCost);
1354  /* the order is reversed, but we use it */
1355  return out;
1356 }
static FILE * out
Definition: alias_check.c:128
#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
float_t save[SIZE][SIZE]
Definition: jacobi.c:9
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define statement_undefined_p(x)
Definition: ri.h:2420
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
static statement generate_load_statement(simdstatement si, int line)
Definition: codegen.c:1267
static float gSimdCost
Definition: codegen.c:56
static statement generate_exec_statement(simdstatement ss)
Definition: codegen.c:1249
static statement generate_save_statement(simdstatement si)
Definition: codegen.c:1300
#define simdstatement_nbArgs(x)
Definition: sac_private.h:493
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References CONS, generate_exec_statement(), generate_load_statement(), generate_save_statement(), gSimdCost, NIL, out, pips_debug, save, simdstatement_nbArgs, STATEMENT, and statement_undefined_p.

Referenced by simdize_simple_statements_pass2().

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

◆ get_operator_id()

int get_operator_id ( entity  e)

retry with uppercase version, cos -> COS :)

Definition at line 161 of file operatorid.c.

162 {
163  const char* ename = entity_local_name(e);
164  int res = do_get_operator_id(ename);
165  if(res == UNKNOWN_TOK )
166  {
167  /* retry with uppercase version, cos -> COS :) */
168  ename = strupper(strdup(ename),ename);
169  res = do_get_operator_id(ename);
170  }
171  return res;
172 }
@ UNKNOWN_TOK
"invalid token"
Definition: patterns.h:57
string strupper(string, const char *)
Definition: string.c:213
static int do_get_operator_id(const char *ename)
Definition: operatorid.c:143
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
char * strdup()

References do_get_operator_id(), entity_local_name(), strdup(), strupper(), and UNKNOWN_TOK.

Referenced by match_call().

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

◆ get_statement_match_of_kind()

match get_statement_match_of_kind ( statement  s,
opcodeClass  kind 
)

simdizer.c

Parameters
kindind

Definition at line 101 of file simdizer.c.

102 {
104 
105  for( ; l!=NIL; l=CDR(l))
106  {
107  match m = MATCH(CAR(l));
108  if (match_type(m) == kind)
109  return m;
110  }
111 
112  return match_undefined;
113 }
#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 MATCH(x)
MATCH.
Definition: sac_private.h:221
#define match_type(x)
Definition: sac_private.h:251
#define match_undefined
Definition: sac_private.h:227
static list get_statement_matches(statement s)
Definition: simdizer.c:90

References CAR, CDR, get_statement_matches(), MATCH, match_type, match_undefined, and NIL.

Referenced by make_simd_statements().

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

◆ get_subwordSize_from_opcode()

int get_subwordSize_from_opcode ( opcode  oc,
int  argNum 
)
Parameters
occ
argNumrgNum

Definition at line 246 of file codegen.c.

247 {
248  int type = INT(gen_nth(argNum, opcode_argType(oc)));
249 
250  switch(type)
251  {
252  case QI_REF_TOK:
253  return 8;
254  case HI_REF_TOK:
255  return 16;
256  case SI_REF_TOK:
257  return 32;
258  case DI_REF_TOK:
259  return 64;
260  case SF_REF_TOK:
261  return 32;
262  case DF_REF_TOK:
263  return 64;
264  case SC_REF_TOK:
265  return 64;
266  case DC_REF_TOK:
267  return 128;
268  default:
269  pips_internal_error("subword size unknown.");
270  }
271 
272  return 8;
273 }
@ DC_REF_TOK
SC_REF_TOK
Definition: patterns.h:66
@ SC_REF_TOK
DF_REF_TOK
Definition: patterns.h:65
@ HI_REF_TOK
QI_REF_TOK
Definition: patterns.h:60
@ DI_REF_TOK
SI_REF_TOK
Definition: patterns.h:62
@ SI_REF_TOK
HI_REF_TOK
Definition: patterns.h:61
@ QI_REF_TOK
REFERENCE_TOK
Definition: patterns.h:59
@ SF_REF_TOK
DI_REF_TOK
Definition: patterns.h:63
@ DF_REF_TOK
SF_REF_TOK
Definition: patterns.h:64
@ INT
Definition: atomic.c:48
gen_chunk gen_nth(int n, const list l)
to be used as ENTITY(gen_nth(3, l))...
Definition: list.c:710
#define pips_internal_error
Definition: misc-local.h:149
#define opcode_argType(x)
Definition: sac_private.h:293

References DC_REF_TOK, DF_REF_TOK, DI_REF_TOK, gen_nth(), HI_REF_TOK, INT, opcode_argType, pips_internal_error, QI_REF_TOK, SC_REF_TOK, SF_REF_TOK, and SI_REF_TOK.

Referenced by compute_parallelism_factor(), generate_opcode(), get_optimal_opcode(), and make_simd_statement().

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

◆ if_conversion()

bool if_conversion ( char *  mod_name)

if_conversion.c

Parameters
mod_nameod_name

Definition at line 281 of file if_conversion.c.

282 {
283  // get the resources
284  statement mod_stmt = (statement)
285  db_get_memory_resource(DBR_CODE, mod_name, true);
286 
289 
290  debug_on("IF_CONVERSION_DEBUG_LEVEL");
291  // Now do the job
292 
294 
295  // Reorder the module, because new statements have been added
296  module_reorder(mod_stmt);
297  DB_PUT_MEMORY_RESOURCE(DBR_CODE, mod_name, mod_stmt);
298  DB_PUT_MEMORY_RESOURCE(DBR_CALLEES, mod_name,
299  compute_callees(mod_stmt));
300 
301  // update/release resources
304 
305  debug_off();
306 
307  return true;
308 }
callees compute_callees(const statement stat)
Recompute the callees of a module statement.
Definition: callgraph.c:355
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
Definition: genClib.c:2780
static void if_conv_statement(statement cs)

References compute_callees(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, gen_recurse, gen_true(), if_conv_statement(), module_name_to_entity(), module_reorder(), reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), and statement_domain.

+ Here is the call graph for this function:

◆ if_conversion_compact()

bool if_conversion_compact ( char *  mod_name)

cproto-generated files

if_conversion_compact.c

Parameters
mod_nameod_name

Definition at line 252 of file if_conversion_compact.c.

253 {
254  // get the resources
255  statement mod_stmt = (statement)
256  db_get_memory_resource(DBR_CODE, mod_name, true);
257 
260  set_ordering_to_statement(mod_stmt);
261 
262  graph dg = (graph) db_get_memory_resource(DBR_DG, mod_name, true);
263 
265  db_get_memory_resource(DBR_PROPER_EFFECTS, mod_name, true));
266 
267  debug_on("IF_CONVERSION_COMPACT_DEBUG_LEVEL");
268  // Now do the job
269 
271 
272  // Reorder the module, because new statements have been added
273  module_reorder(mod_stmt);
274  DB_PUT_MEMORY_RESOURCE(DBR_CODE, mod_name, mod_stmt);
275 
276  // update/release resources
281 
282  debug_off();
283 
284  return true;
285 }
static graph dg
dg is the dependency graph ; FIXME : should not be static global ?
Definition: chains.c:124
bool gen_true2(__attribute__((unused)) gen_chunk *u1, __attribute__((unused)) void *u2)
Definition: genClib.c:2785
static void if_conversion_compact_stats(statement stat, graph dg)

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, dg, gen_context_recurse, gen_true2(), if_conversion_compact_stats(), module_name_to_entity(), module_reorder(), reset_current_module_entity(), reset_current_module_statement(), reset_ordering_to_statement(), reset_proper_rw_effects(), set_current_module_entity(), set_current_module_statement(), set_ordering_to_statement(), set_proper_rw_effects(), and statement_domain.

+ Here is the call graph for this function:

◆ if_conversion_init()

bool if_conversion_init ( char *  mod_name)

if_conversion_init.c

Parameters
mod_nameod_name

Definition at line 337 of file if_conversion_init.c.

338 {
339  // get the resources
341  statement root = (statement) db_get_memory_resource(DBR_CODE, mod_name, true);
343 
344  set_current_module_statement(fake);// to prevent a complex bug with gen_recurse and AddEntityToCurrentModule
345  set_complexity_map( (statement_mapping) db_get_memory_resource(DBR_COMPLEXITIES, mod_name, true));
346 
347  debug_on("IF_CONVERSION_INIT_DEBUG_LEVEL");
348 
349  ifdebug(1) {
350  pips_debug(1, "Code before if_conversion_init:\n");
351  print_statement(root);
352  }
353 
354  // Now do the job
356 
357  ifdebug(1) {
358  pips_debug(1, "Code after if_conv_init_statement:\n");
359  print_statement(root);
360  }
361 
362  // and share decl
365  free_statement(fake);
366 
367  ifdebug(1) {
368  pips_debug(1, "Code after copying from fake statement:\n");
369  print_statement(root);
370  }
371 
372  // Reorder the module, because new statements have been added
373  module_reorder(root);
374  DB_PUT_MEMORY_RESOURCE(DBR_CODE, mod_name, root);
375 
376  // update/release resources
380 
381  debug_off();
382 
383  return true;
384 }
statement copy_statement(statement p)
STATEMENT.
Definition: ri.c:2186
void free_statement(statement p)
Definition: ri.c:2189
void reset_complexity_map(void)
void set_complexity_map(statement_mapping)
statement make_empty_block_statement(void)
Build an empty statement (block/sequence)
Definition: statement.c:625
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
Definition: newgen_list.h:179
list statement_block(statement)
Get the list of block statements of a statement sequence.
Definition: statement.c:1338
void insert_statement_no_matter_what(statement, statement, bool)
Break the IR consistency or, at the very least, do not insert new declarations at the usual place,...
Definition: statement.c:2581
static void if_conv_init_statement(statement stat)
void print_statement(statement)
Print a statement on stderr.
Definition: statement.c:98
#define ifdebug(n)
Definition: sg.c:47

References copy_statement(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, FOREACH, free_statement(), gen_recurse, gen_true(), if_conv_init_statement(), ifdebug, insert_statement_no_matter_what(), make_empty_block_statement(), module_name_to_entity(), module_reorder(), pips_debug, print_statement(), reset_complexity_map(), reset_current_module_entity(), reset_current_module_statement(), set_complexity_map(), set_current_module_entity(), set_current_module_statement(), STATEMENT, statement_block(), and statement_domain.

+ Here is the call graph for this function:

◆ init_vector_to_expressions()

void init_vector_to_expressions ( void  )

codegen.c

Definition at line 59 of file codegen.c.

60 {
63 }
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
@ hash_pointer
Definition: newgen_hash.h:32
#define hash_table_undefined_p(h)
Definition: newgen_hash.h:50
#define HASH_DEFAULT_SIZE
Definition: newgen_hash.h:26
static hash_table vector_to_expressions
Definition: codegen.c:58

References HASH_DEFAULT_SIZE, hash_pointer, hash_table_make(), hash_table_undefined_p, pips_assert, and vector_to_expressions.

Referenced by simdize_simple_statements_pass2().

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

◆ insert_opcodeClass()

void insert_opcodeClass ( char *  s,
int  nbArgs,
list  opcodes 
)
Parameters
nbArgsbArgs
opcodespcodes

Definition at line 267 of file treematch.c.

268 {
269  //Add the class and name in the map
270  make_opcodeClass(s, nbArgs, opcodes);
271 }
opcodeClass make_opcodeClass(string a1, intptr_t a2, list a3)
Definition: sac_private.c:468

References make_opcodeClass().

+ Here is the call graph for this function:

◆ insert_pattern()

void insert_pattern ( char *  s,
list  tokens,
list  args 
)

no such branch -> create a new branch

Parameters
tokensokens
argsrgs

Definition at line 278 of file treematch.c.

279 {
281  patternx p;
283 
284  if (c == opcodeClass_undefined)
285  {
286  pips_user_warning("defining pattern for an undefined opcodeClass (%s).",s);
287  return;
288  }
289 
290  p = make_patternx(c, args);
291 
292  for( ; tokens != NIL; tokens = CDR(tokens) )
293  {
294  int token = INT(CAR(tokens));
295  matchTree next = select_tree_branch(m, token);
296 
297  if (next == matchTree_undefined)
298  {
299  /* no such branch -> create a new branch */
300  next = make_tree();
301  insert_tree_branch(m, token, next);
302  }
303 
304  m = next;
305  }
306 
308 }
patternx make_patternx(opcodeClass a1, list a2)
Definition: sac_private.c:334
#define matchTree_undefined
Definition: sac_private.h:150
#define opcodeClass_undefined
Definition: sac_private.h:507
#define PATTERNX(x)
PATTERNX.
Definition: sac_private.h:384
#define matchTree_patterns(x)
Definition: sac_private.h:174
static matchTree select_tree_branch(matchTree t, int token)
Definition: treematch.c:120
static matchTree patterns_tree
Definition: treematch.c:45
static void insert_tree_branch(matchTree t, int token, matchTree n)
Definition: treematch.c:115
static opcodeClass get_opcodeClass(char *s)
Definition: treematch.c:273
static matchTree make_tree()
Definition: treematch.c:108

References CAR, CDR, CONS, get_opcodeClass(), insert_tree_branch(), INT, make_patternx(), make_tree(), matchTree_patterns, matchTree_undefined, NIL, opcodeClass_undefined, patterns_tree, PATTERNX, pips_user_warning, and select_tree_branch().

+ Here is the call graph for this function:

◆ insert_transformation()

void insert_transformation ( char *  name,
int  vectorLengthOut,
int  subwordSizeOut,
int  vectorLengthIn,
int  subwordSizeIn,
int  nbArgs,
list  mapping 
)

vectransform.c

Parameters
nameame
vectorLengthOutectorLengthOut
subwordSizeOutubwordSizeOut
vectorLengthInectorLengthIn
subwordSizeInubwordSizeIn
nbArgsbArgs
mappingapping

Definition at line 43 of file vectransform.c.

44 {
45  int i;
46  list l;
48  vectorLengthOut,
49  subwordSizeOut,
50  vectorLengthIn,
51  subwordSizeIn,
52  nbArgs,
53  (int*)malloc(sizeof(int)*vectorLengthOut));
54 
55  for(i = vectorLengthOut-1, l=mapping; (i>=0) && (l!=NIL); i--, l=CDR(l))
56  transformation_mapping(t)[i] = INT(CAR(l));
57 
59 }
transformation make_transformation(string a1, intptr_t a2, intptr_t a3, intptr_t a4, intptr_t a5, intptr_t a6, int *a7)
Definition: sac_private.c:510
void * malloc(YYSIZE_T)
#define transformation_mapping(x)
Definition: sac_private.h:589
#define TRANSFORMATION(x)
TRANSFORMATION.
Definition: sac_private.h:542
static list transformations
transformation>
Definition: vectransform.c:41

References CAR, CDR, CONS, INT, make_transformation(), malloc(), NIL, strdup(), TRANSFORMATION, transformation_mapping, and transformations.

+ Here is the call graph for this function:

◆ invalidate_expressions_in_statement()

void invalidate_expressions_in_statement ( statement  s)

Definition at line 162 of file codegen.c.

163 {
165  void * hiter = NULL;
166  entity key;
167  list value;
168  list purge = NIL;
169  while( (hiter = hash_table_scan(vector_to_expressions,hiter,(void**)&key,(void**)&value) ))
170  {
171  bool invalidate=false;
173  {
175  {
176  FOREACH(EFFECT,eff,effects)
178  {
180  break;
181  }
182  }
183  if(invalidate) break;
184  }
185  if(invalidate) purge=CONS(ENTITY,key,purge);
186  }
187  FOREACH(ENTITY,e,purge)
189  gen_free_list(purge);
190 }
list load_proper_rw_effects_list(statement)
#define effect_any_reference(e)
FI: cannot be used as a left hand side.
#define EFFECT(x)
EFFECT.
Definition: effects.h:608
void gen_full_free_list(list l)
Definition: genClib.c:1023
bool references_may_conflict_p(reference r1, reference r2)
Check if two references may conflict.
Definition: conflicts.c:426
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
void * hash_del(hash_table htp, const void *key)
this function removes from the hash table pointed to by htp the couple whose key is equal to key.
Definition: hash.c:439
void * hash_table_scan(hash_table htp, void *hentryp_arg, void **pkey, void **pval)
Definition: hash.c:844
struct _newgen_struct_value_ * value
Definition: ri.h:455
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217

References CONS, EFFECT, effect_any_reference, ENTITY, EXPRESSION, expression_reference(), expression_reference_p(), expression_undefined_p, FOREACH, gen_free_list(), gen_full_free_list(), hash_del(), hash_table_scan(), load_proper_rw_effects_list(), NIL, references_may_conflict_p(), and vector_to_expressions.

Referenced by simdize_simple_statements_pass2().

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

◆ loop_auto_unroll()

bool loop_auto_unroll ( const char *  mod_name)

unroll.c

do the job

Parameters
mod_nameod_name

Definition at line 270 of file unroll.c.

270  {
271  // get the resources
272  statement mod_stmt = (statement)
273  db_get_memory_resource(DBR_CODE, mod_name, true);
274 
277 
278  debug_on("SIMDIZER_DEBUG_LEVEL");
279 
280  /* do the job */
281  const char* slabel = get_string_property_or_ask("LOOP_LABEL","enter the label of a loop !");
282  entity elabel = find_label_entity(mod_name,slabel);
283 
284  if(entity_undefined_p(elabel)) {
285  pips_user_error("label %s does not exist !\n", slabel);
286  }
287  else {
288  statement theloopstatement = find_loop_from_label(get_current_module_statement(),elabel);
289  if(!statement_undefined_p(theloopstatement)) {
290  simple_simd_unroll_loop_filter(theloopstatement);
291  }
292  }
293 
294  pips_assert("Statement is consistent after SIMDIZER_AUTO_UNROLL",
295  statement_consistent_p(mod_stmt));
296 
297  // Reorder the module, because new statements have been added
298  module_reorder(mod_stmt);
299  DB_PUT_MEMORY_RESOURCE(DBR_CODE, mod_name, mod_stmt);
300 
301  // update/release resources
304 
305  debug_off();
306 
307  return true;
308 }
statement get_current_module_statement(void)
Get the current module statement.
Definition: static.c:208
#define pips_user_error
Definition: misc-local.h:147
const char * get_string_property_or_ask(const char *, const char[])
entity find_label_entity(const char *, const char *)
util.c
Definition: util.c:43
#define entity_undefined_p(x)
Definition: ri.h:2762
statement find_loop_from_label(statement, entity)
Definition: util.c:218
static bool simple_simd_unroll_loop_filter(statement s)
Definition: unroll.c:173

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, entity_undefined_p, find_label_entity(), find_loop_from_label(), get_current_module_statement(), get_string_property_or_ask(), module_name_to_entity(), module_reorder(), pips_assert, pips_user_error, reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), simple_simd_unroll_loop_filter(), statement_consistent_p(), and statement_undefined_p.

+ Here is the call graph for this function:

◆ loop_nest_unswitching()

bool loop_nest_unswitching ( const char *  module_name)
Parameters
module_nameodule_name

Definition at line 391 of file if_conversion.c.

391  {
394 
395  list l=NIL;
398  pips_assert("everything went well\n",ENDP(l));
399 
400 
401  // Reorder the module, because new statements have been added
404 
407  return true;
408 }
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
static void do_loop_nest_unswitching(statement st, list *conditions)

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, do_loop_nest_unswitching(), ENDP, gen_context_recurse, gen_true2(), get_current_module_statement(), module_name(), module_name_to_entity(), module_reorder(), NIL, pips_assert, reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), and statement_domain.

+ Here is the call graph for this function:

◆ make_shuffle_statement()

statement make_shuffle_statement ( entity from,
list  expressions,
int perms 
)

If the permutation indexes are equivalent to an invertion, generate an SIMD_INVERT function (useful for some MIS).

Parameters
fromrom
expressionsxpressions
permserms

Definition at line 1068 of file codegen.c.

1068  {
1069  list shuffle=NIL;
1070  FOREACH(EXPRESSION,_,expressions)
1073  entity out = make_entity_copy(*from);
1075  string sshuffle;
1076  statement outs;
1077  /* If the permutation indexes are equivalent to an invertion,
1078  * generate an SIMD_INVERT function (useful for some MIS). */
1079  if (perms[0] == 4 && perms[1] == 3 && perms[2] == 2 && perms[3] == 1) {
1080  asprintf(&sshuffle,"SIMD_INVERT_%s",
1081  get_vect_name_from_data(gen_length(expressions),expressions));
1082  list args = NIL;
1083  args = CONS(EXPRESSION,entity_to_expression(*from),args);
1084  args = CONS(EXPRESSION,entity_to_expression(out),args);
1085 
1086  outs = instruction_to_statement(
1088  make_call(
1090  args)
1091  )
1092  );
1093  }
1094  else {
1095  asprintf(&sshuffle,"SIMD_SHUFFLE_%s",
1096  get_vect_name_from_data(gen_length(expressions),expressions));
1097 
1098  outs = instruction_to_statement(
1100  make_call(
1104  )
1105  );
1106  }
1107  *from=out;
1108  return outs;
1109 }
call make_call(entity a1, list a2)
Definition: ri.c:269
instruction make_instruction_call(call _field_)
Definition: ri.c:1184
statement instruction_to_statement(instruction)
Build a statement from a give instruction.
Definition: statement.c:597
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
#define _
A substitute for POSIX 2008 <stddef.h>, for platforms that have issues.
Definition: stddef.in.h:59
#define asprintf
Definition: misc-local.h:225
entity make_entity_copy(entity e)
Create a copy of an entity, with (almost) identical type, storage and initial value if move_initializ...
Definition: entity.c:2433
entity module_name_to_runtime_entity(const char *name)
similar to module_name_to_entity but generates a warning and a stub if the entity is not found
Definition: entity.c:1485
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
Definition: expression.c:165
void AddEntityToCurrentModule(entity)
Add a variable entity to the current module declarations.
Definition: variable.c:260
static string get_vect_name_from_data(int argc, list exps)
Definition: codegen.c:524
void shuffle(int n, float r[n], float r3[n], float r2[n], float a[n], float b[n])
Definition: shuffle.c:9

References _, AddEntityToCurrentModule(), asprintf, CONS, entity_to_expression(), EXPRESSION, FOREACH, gen_length(), gen_nreverse(), get_vect_name_from_data(), instruction_to_statement(), int_to_expression(), make_call(), make_entity_copy(), make_instruction_call(), module_name_to_runtime_entity(), NIL, out, and shuffle().

Referenced by try_all_permutations().

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

◆ make_simd_statements()

simdstatement make_simd_statements ( set  opkinds,
list  statements 
)

there should be a better order than this

get the variables

compute the opcode to use

update the pointer to the next statement to be processed

generate the statement information

Parameters
opkindspkinds
statementstatements

Definition at line 1193 of file codegen.c.

1194 {
1195  list args[MAX_PACK];
1196  /* there should be a better order than this */
1197  list first = statements;
1198  list last = gen_last(first);
1199  list kinds = set_to_list(opkinds);
1200 
1201  pips_debug(3,"make_simd_statements 1\n");
1202 
1203  if (first == last)
1204  return simdstatement_undefined;
1205 
1206  pips_debug(3,"make_simd_statements 2\n");
1207 
1208  list i = first;
1210 
1211  opcodeClass type = OPCODECLASS(CAR(kinds));
1212  {
1213  int index;
1214  opcode oc;
1215  list j;
1216 
1217  /* get the variables */
1218  for( index = 0, j = i;
1219  (index < MAX_PACK) && (j != CDR(last));
1220  index++, j = CDR(j) )
1221  {
1223  args[index] = match_args(m);
1224  }
1225 
1226  /* compute the opcode to use */
1227  oc = get_optimal_opcode(type, index, args);
1228 
1229  if (!opcode_undefined_p(oc))
1230  {
1231  /* update the pointer to the next statement to be processed */
1232  for(index = 0;
1233  (index<opcode_vectorSize(oc)) && (i!=CDR(last));
1234  index++)
1235  {
1236  i = CDR(i);
1237  }
1238 
1239  /* generate the statement information */
1240  pips_debug(3,"make_simd_statements : simd\n");
1241  instr = make_simd_statement(type, oc, args);
1242  }
1243  }
1244 
1245  pips_debug(3,"make_simd_statements 3\n");
1246  return instr;
1247 }
list gen_last(list l)
Return the last element of a list.
Definition: list.c:578
list set_to_list(const set)
create a list from a set the set is not freed
Definition: set.c:436
static simdstatement make_simd_statement(opcodeClass kind, opcode oc, list *args)
Definition: codegen.c:1128
static opcode get_optimal_opcode(opcodeClass kind, int argc, list *args)
Computes the optimal opcode for simdizing 'argc' statements of the 'kind' operation,...
Definition: codegen.c:297
#define MAX_PACK
Definition: codegen.c:52
match get_statement_match_of_kind(statement, opcodeClass)
simdizer.c
Definition: simdizer.c:101
#define simdstatement_undefined
Definition: sac_private.h:465
#define match_args(x)
Definition: sac_private.h:253
#define opcode_undefined_p(x)
Definition: sac_private.h:264
#define OPCODECLASS(x)
OPCODECLASS.
Definition: sac_private.h:501

References CAR, CDR, gen_last(), get_optimal_opcode(), get_statement_match_of_kind(), make_simd_statement(), match_args, MAX_PACK, opcode_undefined_p, opcode_vectorSize, OPCODECLASS, pips_debug, set_to_list(), simdstatement_undefined, and STATEMENT.

Referenced by simdize_simple_statements_pass2().

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

◆ match_statement()

list match_statement ( statement  s)

return a list of matching statements

find the matching patterns

build the matches

Definition at line 237 of file treematch.c.

238 {
239  list matches = NIL;
240 
241  if (statement_call_p(s))
242  {
243 
244  /* find the matching patterns */
245  list args = NIL;
247  if (matchTree_undefined_p(t))
248  {
249  gen_free_list(args);
250  return NIL;
251  }
252 
253  /* build the matches */
255  {
256  match m = make_match(
257  patternx_class(p),
258  merge_lists(args, patternx_args(p))
259  );
260  matches = CONS(MATCH, m, matches);
261  }
262  }
263 
264  return matches;
265 }
match make_match(opcodeClass a1, list a2)
Definition: sac_private.c:153
call statement_call(statement)
Get the call of a statement.
Definition: statement.c:1406
bool statement_call_p(statement)
Definition: statement.c:364
#define matchTree_undefined_p(x)
Definition: sac_private.h:151
#define patternx_class(x)
Definition: sac_private.h:414
#define patternx_args(x)
Definition: sac_private.h:416
static hash_table matches
Definition: simdizer.c:60
static matchTree match_call(call, matchTree, list *)
Warning: list of arguments is built in reversed order (the head is in fact the last argument)
Definition: treematch.c:183
static list merge_lists(list l, list format)
merge the 2 lists.
Definition: treematch.c:204

References CONS, FOREACH, gen_free_list(), make_match(), MATCH, match_call(), matches, matchTree_patterns, matchTree_undefined_p, merge_lists(), NIL, patterns_tree, PATTERNX, patternx_args, patternx_class, statement_call(), and statement_call_p().

Referenced by compute_parallelism_factor(), and init_statement_matches_map().

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

◆ patterns_yyalloc()

void* patterns_yyalloc ( yy_size_t  )

◆ patterns_yyerror()

void patterns_yyerror ( const char *  s)

Definition at line 1863 of file patterns.c.

1864 {
1865  pips_internal_error("patterns parser:%zd: %s\n",sac_lineno, s);
1866 }
size_t sac_lineno
patterns.c
Definition: patterns.c:97

References pips_internal_error, and sac_lineno.

◆ patterns_yyfree()

void patterns_yyfree ( void *  )

◆ patterns_yyget_debug()

int patterns_yyget_debug ( void  )

◆ patterns_yyget_in()

FILE* patterns_yyget_in ( void  )

◆ patterns_yyget_leng()

int patterns_yyget_leng ( void  )

◆ patterns_yyget_lineno()

int patterns_yyget_lineno ( void  )

◆ patterns_yyget_out()

FILE* patterns_yyget_out ( void  )

◆ patterns_yyget_text()

char* patterns_yyget_text ( void  )

◆ patterns_yylex()

int patterns_yylex ( )

◆ patterns_yylex_destroy()

int patterns_yylex_destroy ( void  )

◆ patterns_yyparse()

int patterns_yyparse ( )

◆ patterns_yypop_buffer_state()

void patterns_yypop_buffer_state ( void  )

◆ patterns_yyrealloc()

void* patterns_yyrealloc ( void *  ,
yy_size_t   
)

◆ patterns_yyrestart()

void patterns_yyrestart ( FILE *  )

◆ patterns_yyset_debug()

void patterns_yyset_debug ( int  )

◆ patterns_yyset_in()

void patterns_yyset_in ( FILE *  )

◆ patterns_yyset_lineno()

void patterns_yyset_lineno ( int  )

◆ patterns_yyset_out()

void patterns_yyset_out ( FILE *  )

◆ patterns_yywrap()

int patterns_yywrap ( void  )

Definition at line 1858 of file patterns.c.

1859 {
1860  return 1;
1861 }

◆ reduction_atomization()

bool reduction_atomization ( const char *  module_name)

prelude

do the job

postlude

Parameters
module_nameodule_name

Definition at line 459 of file atomizer.c.

459  {
460  /* prelude */
464 
465  /* do the job */
469 
470  /* postlude */
474  return true;
475 }
const char * get_current_module_name(void)
Get the name of the current module.
Definition: static.c:121
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
Definition: genClib.c:2752
void reset_cumulated_reductions(void)
void set_cumulated_reductions(pstatement_reductions)
static bool do_reduction_atomization(statement s)
Definition: atomizer.c:429

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, do_reduction_atomization(), gen_null(), gen_recurse, get_current_module_name(), get_current_module_statement(), module_name(), module_name_to_entity(), module_reorder(), reset_cumulated_reductions(), reset_current_module_entity(), reset_current_module_statement(), set_cumulated_reductions(), set_current_module_entity(), set_current_module_statement(), and statement_domain.

+ Here is the call graph for this function:

◆ redundant_load_store_elimination()

bool redundant_load_store_elimination ( char *  module_name)

Get the code of the module.

Parameters
module_nameodule_name

Definition at line 788 of file reductions.c.

789 {
790  /* Get the code of the module. */
792  statement module_stat = (statement)db_get_memory_resource(DBR_CODE, module_name, true);
793  set_ordering_to_statement(module_stat);
795  set_current_module_statement( module_stat);
798 
800 
801  // buggy and incomplete
802  //do_sac_reduction_optimizations(dependence_graph);
804 
805  unnormalize_expression(module_stat);
806  module_reorder(module_stat);
807  DB_PUT_MEMORY_RESOURCE(DBR_CODE, module_name, module_stat);
809 
810 
816 
817  return true;
818 }
static graph dependence_graph
Definition: delay.c:93
void set_cumulated_rw_effects(statement_effects)
void reset_cumulated_rw_effects(void)
void unnormalize_expression(void *st)
void unnormalize_expression(expression exp): puts all the normalized field of expressions in "st" to ...
Definition: normalize.c:452
static void do_redundant_load_store_elimination(graph dg)
Definition: reductions.c:752
static char * module
Definition: pips.c:74

References compute_callees(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, dependence_graph, do_redundant_load_store_elimination(), get_current_module_statement(), module, module_name(), module_name_to_entity(), module_reorder(), reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), reset_ordering_to_statement(), reset_proper_rw_effects(), set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), set_ordering_to_statement(), set_proper_rw_effects(), and unnormalize_expression().

+ Here is the call graph for this function:

◆ reset_simd_operator_mappings()

void reset_simd_operator_mappings ( void  )

Definition at line 48 of file operatorid.c.

49 {
50  pips_assert("already set",mappings);
51  mappings=NULL;
52 }
static operator_id_tree mappings
Definition: operatorid.c:42

References mappings, and pips_assert.

Referenced by simd_operator_mappings(), simd_unroll_as_needed(), and simdizer().

+ Here is the caller graph for this function:

◆ reset_simd_treematch()

void reset_simd_treematch ( void  )

Definition at line 52 of file treematch.c.

53 {
54  pips_assert("tree match already set",patterns_tree!=NULL);
55  patterns_tree=NULL;
56 }

References patterns_tree, and pips_assert.

Referenced by simd_treematcher(), simd_unroll_as_needed(), and simdizer().

+ Here is the caller graph for this function:

◆ reset_vector_to_expressions()

void reset_vector_to_expressions ( void  )

Definition at line 64 of file codegen.c.

65 {
69 }
void hash_table_free(hash_table htp)
this function deletes a hash table that is no longer useful.
Definition: hash.c:327
#define hash_table_undefined
Value of an undefined hash_table.
Definition: newgen_hash.h:49

References hash_table_free(), hash_table_undefined, hash_table_undefined_p, pips_assert, and vector_to_expressions.

Referenced by simdize_simple_statements_pass2().

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

◆ sac_aligned_entity_p()

bool sac_aligned_entity_p ( entity  e)

Definition at line 646 of file codegen.c.

647 {
649 }
#define same_stringn_p(a, b, c)
Definition: misc-local.h:199
const char * entity_user_name(entity e)
Since entity_local_name may contain PIPS special characters such as prefixes (label,...
Definition: entity.c:487
#define SAC_ALIGNED_VECTOR_NAME
Definition: codegen.c:645

References entity_user_name(), SAC_ALIGNED_VECTOR_NAME, and same_stringn_p.

Referenced by sac_aligned_expression_p(), and sac_commenter().

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

◆ sac_commenter()

string sac_commenter ( entity  e)

Definition at line 821 of file simdizer.c.

822 {
823  if(sac_aligned_entity_p(e))
824  {
825  return strdup("SAC generated temporary array");
826  }
827  else if(simd_vector_entity_p(e))
828  {
829  string s,g = basic_to_string(entity_basic(e));
830  asprintf(&s,"PIPS:SAC generated %s vector(s)", g);
831  free(g);
832  return s;
833  }
834  else
835  return strdup("PIPS:SAC generated variable");
836 }
void free(void *)
string basic_to_string(basic)
Definition: type.c:87
basic entity_basic(entity e)
return the basic associated to entity e if it's a function/variable/constant basic_undefined otherwis...
Definition: entity.c:1380
bool simd_vector_entity_p(entity e)
Definition: codegen.c:197
bool sac_aligned_entity_p(entity e)
Definition: codegen.c:646

References asprintf, basic_to_string(), entity_basic(), free(), sac_aligned_entity_p(), simd_vector_entity_p(), and strdup().

Referenced by simdizer().

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

◆ sac_expression_reduction_p()

bool sac_expression_reduction_p ( expression  e)

reductions.c

Definition at line 55 of file reductions.c.

55  {
56  if(expression_reference_p(e)) {
57  const char* refname = entity_user_name(reference_variable(expression_reference(e)));
58  if(refname==strstr(refname,get_string_property("SIMD_REMOVE_REDUCTIONS_PREFIX")))
59  return true;
60  }
61  return false;
62 }
char * get_string_property(const char *)

References entity_user_name(), expression_reference(), expression_reference_p(), get_string_property(), and reference_variable.

+ Here is the call graph for this function:

◆ scalar_renaming()

bool scalar_renaming ( char *  mod_name)

singleass.c

singleass.c

Get the resources

needed for vertex_to_statement

prune graph

Now do the job

Reorder the module, because new statements have been added

update/release resources

Parameters
mod_nameod_name

Definition at line 300 of file singleass.c.

301 {
302  /* Get the resources */
303  statement mod_stmt = (statement)
304  db_get_memory_resource(DBR_CODE, mod_name, true);
305  graph dg = (graph) db_get_memory_resource(DBR_DG, mod_name, true);
306 
309  set_ordering_to_statement(mod_stmt); /* needed for vertex_to_statement */
310 
312  db_get_memory_resource(DBR_PROPER_EFFECTS, mod_name, true));
313 
314  debug_on("SCALAR_RENAMING_DEBUG_LEVEL");
315 
316  /* prune graph */
318 
319  /* Now do the job */
321 
322  pips_assert("Statement is consistent after SCALAR_RENAMING",
323  statement_consistent_p(mod_stmt));
324 
325  /* Reorder the module, because new statements have been added */
326  module_reorder(mod_stmt);
327 
328  DB_PUT_MEMORY_RESOURCE(DBR_CODE, mod_name, mod_stmt);
329 
330  /* update/release resources */
335 
336  debug_off();
337 
338  return true;
339 }
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
static void simplify_dg(entity module, graph dg)
removes redundant arcs from dg.
Definition: singleass.c:288
static void do_scalar_renaming(entity module, statement module_statement, graph dg)
do scalar renaming for graph dg of module module and statements module_statement
Definition: singleass.c:180

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, dg, do_scalar_renaming(), get_current_module_entity(), get_current_module_statement(), module_name_to_entity(), module_reorder(), pips_assert, reset_current_module_entity(), reset_current_module_statement(), reset_ordering_to_statement(), reset_proper_rw_effects(), set_current_module_entity(), set_current_module_statement(), set_ordering_to_statement(), set_proper_rw_effects(), simplify_dg(), and statement_consistent_p().

+ Here is the call graph for this function:

◆ set_simd_operator_mappings()

void set_simd_operator_mappings ( void *  m)

operatorid.c

Definition at line 43 of file operatorid.c.

44 {
45  pips_assert("not already set",mappings==NULL);
46  mappings=m;
47 }

References mappings, and pips_assert.

Referenced by simd_operator_mappings(), simd_unroll_as_needed(), and simdizer().

+ Here is the caller graph for this function:

◆ set_simd_treematch()

void set_simd_treematch ( matchTree  t)

treematch.c

Definition at line 46 of file treematch.c.

47 {
48  pips_assert("tree match not already set",patterns_tree==NULL);
49  patterns_tree=t;
50 }

References patterns_tree, and pips_assert.

Referenced by simd_treematcher(), simd_unroll_as_needed(), and simdizer().

+ Here is the caller graph for this function:

◆ simd_atomize_this_expression()

statement simd_atomize_this_expression ( entity(*)(entity, basic create,
expression  e 
)

atomizer.c

atomizer.c

it does not make sense to atomize a range...

SG: in case of expression similar to (a+2), if a is a short (or a char ...), the user may expect the result is a short too the C syntax expect 2 is an int set the property to false if you want to override this behavior

force all integer to char, then compute the basic validate only if we can guess the size from something not a constant integer

Definition at line 87 of file atomizer.c.

89 {
90  basic bofe = basic_undefined;
91 
92  /* it does not make sense to atomize a range...
93  */
94  if (syntax_range_p(expression_syntax(e))) return NULL;
95 
96  /* SG: in case of expression similar to (a+2), if a is a short (or a char ...),
97  * the user may expect the result is a short too
98  * the C syntax expect 2 is an int
99  * set the property to false if you want to override this behavior
100  */
101  if( get_bool_property("SIMD_OVERRIDE_CONSTANT_TYPE_INFERENCE") )
102  {
103  expression etemp = copy_expression(e);
104  bool patch_all=true;
105  /* force all integer to char, then compute the basic
106  * validate only if we can guess the size from something not a constant integer
107  */
109  if( !patch_all )
110  bofe=basic_of_expression(etemp);
111  free_expression(etemp);
112  }
113 
114  if(basic_undefined_p(bofe) )
115  bofe = basic_of_expression(e);
116 
117  if(!basic_undefined_p(bofe)) {
118  if (!basic_overloaded_p(bofe))
119  {
120  entity newvar = (*create)(get_current_module_entity(), bofe);
121  AddEntityToCurrentModule(newvar);
126 
127  return assign;
128  }
129 
130  free_basic(bofe);
131  }
132  return NULL;
133 }
expression make_expression(syntax a1, normalized a2)
Definition: ri.c:886
expression copy_expression(expression p)
EXPRESSION.
Definition: ri.c:850
reference make_reference(entity a1, list a2)
Definition: ri.c:2083
void free_expression(expression p)
Definition: ri.c:853
syntax make_syntax_reference(reference _field_)
Definition: ri.c:2494
statement make_assign_statement(expression, expression)
Definition: statement.c:583
void normalize_all_expressions_of(void *obj)
Definition: normalize.c:668
basic basic_of_expression(expression)
basic basic_of_expression(expression exp): Makes a basic of the same basic as the expression "exp".
Definition: type.c:1383
#define normalized_undefined
Definition: ri.h:1745
#define basic_overloaded_p(x)
Definition: ri.h:623
#define basic_undefined_p(x)
Definition: ri.h:557
#define basic_undefined
Definition: ri.h:556
#define syntax_range_p(x)
Definition: ri.h:2731
#define expression_syntax(x)
Definition: ri.h:1247
#define syntax_domain
newgen_synchronization_domain_defined
Definition: ri.h:402
static void patch_constant_size(syntax s, bool *patch_all)
Definition: atomizer.c:62

References AddEntityToCurrentModule(), basic_of_expression(), basic_overloaded_p, basic_undefined, basic_undefined_p, copy_expression(), entity_to_expression(), expression_syntax, free_basic(), free_expression(), gen_context_recurse, gen_true2(), get_bool_property(), get_current_module_entity(), make_assign_statement(), make_expression(), make_reference(), make_syntax_reference(), NIL, normalize_all_expressions_of(), normalized_undefined, patch_constant_size(), syntax_domain, and syntax_range_p.

Referenced by atomize_condition(), and simd_do_atomize().

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

◆ simd_atomizer()

bool simd_atomizer ( char *  mod_name)

get the resources

Now do the job

Reorder the module, because new statements have been added

update/release resources

Parameters
mod_nameod_name

Definition at line 361 of file atomizer.c.

362 {
363  /* get the resources */
364  statement mod_stmt = (statement)
365  db_get_memory_resource(DBR_CODE, mod_name, true);
366 
369 
370  debug_on("SIMD_ATOMIZER_DEBUG_LEVEL");
371 
372 
373  /* Now do the job */
375 
376  /* Reorder the module, because new statements have been added */
377  module_reorder(mod_stmt);
378  DB_PUT_MEMORY_RESOURCE(DBR_CODE, mod_name, mod_stmt);
379 
380  /* update/release resources */
383 
384  debug_off();
385 
386  return true;
387 }
static void atomize_statements(statement cs)
This function is called for all statements in the code.
Definition: atomizer.c:352

References atomize_statements(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, gen_recurse, gen_true(), module_name_to_entity(), module_reorder(), reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), and statement_domain.

+ Here is the call graph for this function:

◆ simd_check_argType()

bool simd_check_argType ( void  )

Definition at line 87 of file treematch.c.

88 {
89  list pCurBas = curArgType;
90 
91  FOREACH(BASIC, finBas, finalArgType)
92  {
93  if(ENDP(pCurBas) )
94  return false;
95  basic curBas = BASIC(CAR(pCurBas));
96  if(!basic_equal_p(curBas, finBas))
97  return false;
98  pCurBas = CDR(pCurBas);
99  }
100 
102  curArgType = NIL;
103 
104  return true;
105 }
bool basic_equal_p(basic, basic)
Definition: type.c:927
#define BASIC(x)
BASIC.
Definition: ri.h:550
static list curArgType
Definition: treematch.c:59
static list finalArgType
Definition: treematch.c:58

References BASIC, basic_equal_p(), CAR, CDR, curArgType, ENDP, finalArgType, FOREACH, gen_full_free_list(), and NIL.

Referenced by extract_matching_statements().

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

◆ simd_fill_curArgType()

void simd_fill_curArgType ( statement  stat)
Parameters
stattat

Definition at line 82 of file treematch.c.

83 {
85 }
static list simd_fill_curArgType_call(call ca)
Definition: treematch.c:69

References curArgType, simd_fill_curArgType_call(), and statement_call().

Referenced by extract_matching_statements().

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

◆ simd_fill_finalArgType()

void simd_fill_finalArgType ( statement  stat)
Parameters
stattat

Definition at line 77 of file treematch.c.

References finalArgType, simd_fill_curArgType_call(), and statement_call().

Referenced by simdize_simple_statements_pass2().

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

◆ simd_memory_packing()

bool simd_memory_packing ( char *  mod_name)

simd_memory_packing.c

simd_memory_packing.c

Parameters
mod_namename of the module to convert
Returns
false if something went wrong

get the resources

first step : create a vector <> array table

second step : look for any array `‘vectorized’' in the parameter and modify their type to fit the real array size

update/release resources

Parameters
mod_nameod_name

Definition at line 151 of file simd_memory_packing.c.

152 {
153  bool failed = false;
154  /* get the resources */
155  statement mod_stmt = (statement)db_get_memory_resource(DBR_CODE, mod_name, true);
158 
159  /* first step : create a vector <> array table */
160  hash_table array_to_vector = hash_table_make(hash_pointer,0);
161  gen_context_recurse(mod_stmt, array_to_vector, statement_domain, gen_true2, simd_trace_call);
162  if(( failed=hash_table_empty_p(array_to_vector)) )
163  {
164  pips_user_warning("I did not find any simd load / store operation :'(\n");
165  goto simd_memory_packing_end;
166  }
167 
168  /* second step : look for any array ``vectorized'' in the parameter
169  * and modify their type to fit the real array size
170  */
171  {
172  bool replaced_something = simd_replace_parameters(array_to_vector);
173  if( ( failed = !replaced_something ) )
174  {
175  pips_user_warning("I did not find any vectorized array in module parameters :'(\n");
176  goto simd_memory_packing_end;
177  }
179  add_new_module_from_text( mod_name,
180  t,
182  );
183  free_text(t);
184  /* update/release resources */
185  hash_table_free(array_to_vector);
186 
189  }
190 
191 simd_memory_packing_end:
192  return !failed;
193 }
void free_text(text p)
Definition: text.c:74
bool add_new_module_from_text(const char *module_name, text code_text, bool is_fortran, const char *compilation_unit_name)
Add the new resource files associated to a module with its more-or-less correct code.
Definition: initializer.c:431
#define hash_table_empty_p(htp)
Definition: newgen_hash.h:58
text text_module(entity, statement)
bool fortran_module_p(entity m)
Test if a module is in Fortran.
Definition: entity.c:2799
static bool simd_replace_parameters(hash_table array_to_vector)
static void simd_trace_call(statement s, hash_table array_to_vector)
string compilation_unit_of_module(const char *)
The output is undefined if the module is referenced but not defined in the workspace,...
Definition: module.c:350

References add_new_module_from_text(), compilation_unit_of_module(), db_get_memory_resource(), fortran_module_p(), free_text(), gen_context_recurse, gen_true2(), get_current_module_entity(), get_current_module_name(), get_current_module_statement(), hash_pointer, hash_table_empty_p, hash_table_free(), hash_table_make(), module_name_to_entity(), pips_user_warning, reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), simd_replace_parameters(), simd_trace_call(), statement_domain, and text_module().

+ Here is the call graph for this function:

◆ simd_operator_mappings()

bool simd_operator_mappings ( const  string)

create a new operator id

put it in pipsdbm

Parameters
stringodule_name

Definition at line 174 of file operatorid.c.

175 {
177  /* create a new operator id */
180 
181  for(size_t i=0; operators[i].name != NULL; i++)
183 
184  /* put it in pipsdbm */
185  DB_PUT_MEMORY_RESOURCE(DBR_SIMD_OPERATOR_MAPPINGS,"",m);
186 
188  return true;
189 }
operator_id_tree make_operator_id_tree(intptr_t a1, operator_id_sons a2)
Definition: sac_private.c:237
@ hash_int
Definition: newgen_hash.h:32
static oper_id_mapping operators[]
Definition: operatorid.c:66
static void insert_mapping(oper_id_mapping *item)
Definition: operatorid.c:116
void reset_simd_operator_mappings()
Definition: operatorid.c:48
void set_simd_operator_mappings(void *m)
operatorid.c
Definition: operatorid.c:43

References DB_PUT_MEMORY_RESOURCE, HASH_DEFAULT_SIZE, hash_int, hash_table_make(), insert_mapping(), make_operator_id_tree(), module_name(), oper_id_mapping::name, operators, pips_assert, reset_simd_operator_mappings(), set_simd_operator_mappings(), and UNKNOWN_TOK.

+ Here is the call graph for this function:

◆ simd_remove_reductions()

bool simd_remove_reductions ( char *  mod_name)

remove reductions by expanding reduced scalar to an array

Parameters
mod_namemodule to remove reductions from
Returns
true

get the resources

Now do the job

Reorder the module, because new statements have been added

update/release resources

Parameters
mod_nameod_name

Definition at line 571 of file reductions.c.

572 {
573 
574  /* get the resources */
577  set_cumulated_reductions((pstatement_reductions) db_get_memory_resource(DBR_CUMULATED_REDUCTIONS, mod_name, true));
578 
579  debug_on("SIMDREDUCTION_DEBUG_LEVEL");
580 
581  /* Now do the job */
582  set skip = set_make(set_pointer);
584  set_free(skip);
585 
586  pips_assert("Statement is consistent after remove reductions", statement_consistent_p(get_current_module_statement()));
587 
588  /* Reorder the module, because new statements have been added */
593 
594  /* update/release resources */
598 
599  debug_off();
600 
601  return true;
602 }
bool clean_up_sequences(statement s)
Recursively clean up the statement sequences by fusing them if possible and by removing useless one.
void set_free(set)
Definition: set.c:332
@ set_pointer
Definition: newgen_set.h:44
set set_make(set_type)
Create an empty set of any type but hash_private.
Definition: set.c:102
static bool reduction_rewrite_filter(statement s, set skip)
Definition: reductions.c:557
static void reductions_rewrite(statement s, set skip)
Definition: reductions.c:475
FI: I do not understand why the type is duplicated at the set level.
Definition: set.c:59

References clean_up_sequences(), compute_callees(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, gen_context_recurse, get_current_module_statement(), module_name_to_entity(), module_reorder(), pips_assert, reduction_rewrite_filter(), reductions_rewrite(), reset_cumulated_reductions(), reset_current_module_entity(), reset_current_module_statement(), set_cumulated_reductions(), set_current_module_entity(), set_current_module_statement(), set_free(), set_make(), set_pointer, statement_consistent_p(), and statement_domain.

+ Here is the call graph for this function:

◆ simd_reset_finalArgType()

void simd_reset_finalArgType ( void  )

Definition at line 61 of file treematch.c.

62 {
64  finalArgType = NIL;
65 
67  curArgType = NIL;
68 }

References curArgType, finalArgType, gen_free_list(), and NIL.

Referenced by simdize_simple_statements_pass2().

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

◆ simd_treematcher()

bool simd_treematcher ( const  string)

create a new tree match

fill it

put it in pipsdbm

clean up

Parameters
stringodule_name

Definition at line 310 of file treematch.c.

311 {
313  /* create a new tree match */
314  matchTree treematch = make_tree();
315  set_simd_treematch(treematch);
316 
317  /* fill it */
318  sac_lineno=0;
319  patterns_yyin=fopen_config("patterns.def","SIMD_PATTERN_FILE",NULL);
321  fclose(patterns_yyin);
322 
323  /* put it in pipsdbm */
324  DB_PUT_MEMORY_RESOURCE(DBR_SIMD_TREEMATCH,"",treematch);
325 
326  /* clean up */
328  return true;
329 }
int patterns_yyparse(void)
FILE * fopen_config(const char *canonical_name, const char *cproperty, const char *cenv)
Definition: file.c:952
FILE * patterns_yyin
symbols exported by the parser
Definition: sac.h:157
void reset_simd_treematch()
Definition: treematch.c:52
void set_simd_treematch(matchTree t)
treematch.c
Definition: treematch.c:46

References DB_PUT_MEMORY_RESOURCE, fopen_config(), make_tree(), module_name(), patterns_yyin, patterns_yyparse(), pips_assert, reset_simd_treematch(), sac_lineno, and set_simd_treematch().

+ Here is the call graph for this function:

◆ simd_vector_entity_p()

bool simd_vector_entity_p ( entity  e)

Definition at line 197 of file codegen.c.

198 {
199  return
202  && !entity_scalar_p(e);
203  ;
204 }
bool entity_scalar_p(entity)
The concrete type of e is a scalar type.
Definition: variable.c:1113
#define type_variable_p(x)
Definition: ri.h:2947
#define VECTOR_POSTFIX
Definition: codegen.c:53

References entity_scalar_p(), entity_type, entity_user_name(), type_variable_p, and VECTOR_POSTFIX.

Referenced by get_basic_from_opcode(), and sac_commenter().

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

◆ simdizer()

bool simdizer ( char *  mod_name)

get the resources

Now do the job

Reorder the module, because new statements have been added

update/release resources

Parameters
mod_nameod_name

Definition at line 854 of file simdizer.c.

855 {
856  /* get the resources */
857  statement mod_stmt = (statement)
858  db_get_memory_resource(DBR_CODE, mod_name, true);
859 
860  set_current_module_statement(mod_stmt);
862  set_ordering_to_statement(mod_stmt);
863  simdizer_context sc = { .dg = (graph) db_get_memory_resource(DBR_DG, mod_name, true),
864  .nb_enclosing_loops = 0,
865  .result = false };
866  set_simd_treematch((matchTree)db_get_memory_resource(DBR_SIMD_TREEMATCH,"",true));
867  set_simd_operator_mappings(db_get_memory_resource(DBR_SIMD_OPERATOR_MAPPINGS,"",true));
868  statement_effects se = (statement_effects)db_get_memory_resource(DBR_PROPER_EFFECTS,mod_name,true);
869  remove_preferences(se);
873 
874  debug_on("SIMDIZER_DEBUG_LEVEL");
875 
876  /* Now do the job */
880  NULL);
881 
882  pips_assert("Statement is consistent after SIMDIZER",
883  statement_consistent_p(mod_stmt));
884 
885  /* Reorder the module, because new statements have been added */
886  clean_up_sequences(mod_stmt);
887  module_reorder(mod_stmt);
888  DB_PUT_MEMORY_RESOURCE(DBR_CODE, mod_name, mod_stmt);
889  DB_PUT_MEMORY_RESOURCE(DBR_CALLEES, mod_name, compute_callees(mod_stmt));
890  //DB_PUT_MEMORY_RESOURCE(DBR_DG, mod_name, dependence_graph);
891 
892  /* update/release resources */
900 
901  debug_off();
902 
903  return sc.result;
904 }
void remove_preferences(void *)
delay.c
Definition: delay.c:89
struct _newgen_struct_statement_effects_ * statement_effects
Definition: effects.h:210
void set_conflict_testing_properties()
conflicts.c
Definition: conflicts.c:68
void gen_context_multi_recurse(void *o, void *context,...)
Multi-recursion with context function visitor.
Definition: genClib.c:3373
void pop_generated_variable_commenter(void)
Definition: statement.c:2623
void push_generated_variable_commenter(string(*)(entity))
Definition: statement.c:2616
#define loop_domain
newgen_language_domain_defined
Definition: ri.h:218
void reset_simd_treematch(void)
Definition: treematch.c:52
void set_simd_treematch(matchTree)
treematch.c
Definition: treematch.c:46
static void simdize_simple_statements(statement s, simdizer_context *sc)
Definition: simdizer.c:740
static bool incr_counter(loop l, simdizer_context *sc)
Definition: simdizer.c:838
static void decr_counter(loop l, simdizer_context *sc)
Definition: simdizer.c:843
static bool simd_simple_sequence_filter(statement s, __attribute__((unused)) simdizer_context *sc)
Definition: simdizer.c:816
string sac_commenter(entity e)
Definition: simdizer.c:821

References clean_up_sequences(), compute_callees(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, decr_counter(), simdizer_context::dg, gen_context_multi_recurse(), incr_counter(), loop_domain, module_name_to_entity(), module_reorder(), pips_assert, pop_generated_variable_commenter(), push_generated_variable_commenter(), remove_preferences(), reset_current_module_entity(), reset_current_module_statement(), reset_ordering_to_statement(), reset_proper_rw_effects(), reset_simd_operator_mappings(), reset_simd_treematch(), simdizer_context::result, sac_commenter(), set_conflict_testing_properties(), set_current_module_entity(), set_current_module_statement(), set_ordering_to_statement(), set_proper_rw_effects(), set_simd_operator_mappings(), set_simd_treematch(), simd_simple_sequence_filter(), simdize_simple_statements(), statement_consistent_p(), and statement_domain.

+ Here is the call graph for this function:

◆ simdizer_auto_tile()

bool simdizer_auto_tile ( const char *  module_name)

do the job

retrieve loop indices that are referenced as last element

build tests

iterate over all possible combination of tests

create the if's recursively

validate

Parameters
module_nameodule_name

Definition at line 409 of file unroll.c.

409  {
410  bool success = false;
414 
415  /* do the job */
416  const char* slabel = get_string_property_or_ask("LOOP_LABEL","enter the label of a loop !");
417  entity elabel = find_label_entity(module_name,slabel);
418 
419  if(entity_undefined_p(elabel)) {
420  pips_user_error("label %s does not exist !\n", slabel);
421  }
422  else {
423  statement theloopstatement = find_loop_from_label(get_current_module_statement(),elabel);
424  if(!statement_undefined_p(theloopstatement)) {
425  if(perfectly_nested_loop_p(theloopstatement)) {
426  /* retrieve loop indices that are referenced as last element */
429  list tloops = NIL;
431  list allloops =gen_copy_seq(tloops);
432  FOREACH(STATEMENT,l,allloops) {
434  gen_remove_once(&tloops,l);
435  }
436  theloopstatement=STATEMENT(CAR((tloops)));
437  //allloops=gen_nreverse(allloops);
438  while(theloopstatement!=STATEMENT(CAR(allloops))) POP(allloops);
439  set_free(indices);
441 
442  /* build tests */
443  int max_unroll_rate = simple_simd_unroll_rate(statement_loop(theloopstatement));
444  int nloops=gen_length(allloops);
445  /* iterate over all possible combination of tests */
446  expression alltests[1+nloops];
447  alltests[nloops] = expression_undefined ;
448  int j=0;
449  FOREACH(STATEMENT,sl,allloops) {
450  alltests[j++]=MakeBinaryCall(
453  int_to_expression(2*max_unroll_rate)
454  );
455  }
456  /* create the if's recursively */
457  statement root =
459  theloopstatement,
460  nloops,
461  alltests);
463  *theloopstatement=*root;
464  loop_label(statement_loop(theloopstatement))=elabel;
465  success=true;
466 
467  /* validate */
470  }
471  else pips_user_error("loop is not perfectly nested !\n");
472  }
473  else pips_user_error("label is not on a loop!\n");
474  }
475 
479  return success;
480 }
static list loops
bool success
Definition: gpips-local.h:59
bool perfectly_nested_loop_p(statement stat)
Test if a statement is a perfect loop-nest.
Definition: loop.c:543
#define POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59
void gen_remove_once(list *pl, const void *o)
Remove the first occurence of o in list pl:
Definition: list.c:691
list gen_copy_seq(list l)
Copy a list structure.
Definition: list.c:501
loop statement_loop(statement)
Get the loop of a statement.
Definition: statement.c:1374
static list indices
Definition: icm.c:204
set set_assign_list(set, const list)
assigns a list contents to a set all duplicated elements are lost
Definition: set.c:474
bool set_belong_p(const set, const void *)
Definition: set.c:194
#define GREATER_THAN_OPERATOR_NAME
@ range_to_nbiter
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292
expression range_to_expression(range r, enum range_to_expression_mode mode)
computes the distance between the lower bound and the upper bound of the range
Definition: eval.c:963
expression MakeBinaryCall(entity f, expression eg, expression ed)
Creates a call expression to a function with 2 arguments.
Definition: expression.c:354
#define loop_label(x)
Definition: ri.h:1646
#define loop_range(x)
Definition: ri.h:1642
#define loop_index(x)
Definition: ri.h:1640
static void gather_local_indices(reference r, set s)
Definition: unroll.c:339
static statement simdizer_auto_tile_generate_all_tests(statement root, int maxdepth, expression tests[1+maxdepth])
Definition: unroll.c:400
static int simple_simd_unroll_rate(loop l)
Definition: unroll.c:141
static void stmt_rm_labels(statement s)
Definition: unroll.c:404
static void keep_loop_indices(statement s, list *L)
Definition: unroll.c:349

References CAR, db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, entity_intrinsic(), entity_undefined_p, expression_undefined, find_label_entity(), find_loop_from_label(), FOREACH, gather_local_indices(), gen_context_recurse, gen_copy_seq(), gen_free_list(), gen_length(), gen_recurse, gen_remove_once(), gen_true(), gen_true2(), get_current_module_statement(), get_string_property_or_ask(), GREATER_THAN_OPERATOR_NAME, indices, int_to_expression(), keep_loop_indices(), loop_index, loop_label, loop_range, loops, MakeBinaryCall(), module_name(), module_name_to_entity(), module_reorder(), NIL, perfectly_nested_loop_p(), pips_user_error, POP, range_to_expression(), range_to_nbiter, reference_domain, reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), set_assign_list(), set_belong_p(), set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), set_free(), set_make(), set_pointer, simdizer_auto_tile_generate_all_tests(), simple_simd_unroll_rate(), STATEMENT, statement_domain, statement_loop(), statement_undefined_p, and stmt_rm_labels().

+ Here is the call graph for this function:

◆ simdizer_auto_unroll()

bool simdizer_auto_unroll ( char *  mod_name)
Parameters
mod_nameod_name

Definition at line 310 of file unroll.c.

311 {
312  // get the resources
313  statement mod_stmt = (statement)
314  db_get_memory_resource(DBR_CODE, mod_name, true);
315 
318 
319  debug_on("SIMDIZER_DEBUG_LEVEL");
320 
321  simd_unroll_as_needed(mod_stmt);
322 
323  pips_assert("Statement is consistent after SIMDIZER_AUTO_UNROLL",
324  statement_consistent_p(mod_stmt));
325 
326  // Reorder the module, because new statements have been added
327  module_reorder(mod_stmt);
328  DB_PUT_MEMORY_RESOURCE(DBR_CODE, mod_name, mod_stmt);
329 
330  // update/release resources
333 
334  debug_off();
335 
336  return true;
337 }
static void simd_unroll_as_needed(statement module_stmt)
Definition: unroll.c:251

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, module_name_to_entity(), module_reorder(), pips_assert, reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), simd_unroll_as_needed(), and statement_consistent_p().

+ Here is the call graph for this function:

◆ simdizer_init()

bool simdizer_init ( const char *  module_name)

get the resources

normalize blocks

then split blocks containing declarations statement

then split blocks containing labeled statement

sort commutative operators

reset

Parameters
module_nameodule_name

Definition at line 1023 of file simdizer.c.

1024 {
1025  /* get the resources */
1028 
1029  /* normalize blocks */
1031 
1032  /* then split blocks containing declarations statement */
1034 
1035  /* then split blocks containing labeled statement */
1037 
1038  /* sort commutative operators */
1040 
1043 
1044  /* reset */
1047 
1048  return true;
1049 
1050 }
#define call_domain
newgen_callees_domain_defined
Definition: ri.h:58
static void do_split_decl_block_statements(statement s)
Definition: simdizer.c:983
static void do_simdizer_init(call c)
Definition: simdizer.c:907
static void do_split_block_statements(statement s)
Definition: simdizer.c:953

References call_domain, clean_up_sequences(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, do_simdizer_init(), do_split_block_statements(), do_split_decl_block_statements(), gen_recurse, gen_true(), get_current_module_statement(), module_name(), module_name_to_entity(), module_reorder(), reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), and statement_domain.

+ Here is the call graph for this function:

Variable Documentation

◆ patterns_yy_flex_debug

int patterns_yy_flex_debug
extern

◆ patterns_yychar

int patterns_yychar
extern

◆ patterns_yyin

FILE* patterns_yyin
extern

symbols exported by the parser

Definition at line 157 of file sac.h.

◆ patterns_yyleng

int patterns_yyleng
extern

lexer.c

◆ patterns_yylineno

int patterns_yylineno
extern

◆ patterns_yynerrs

int patterns_yynerrs
extern

◆ patterns_yyout

FILE* patterns_yyout
extern

◆ patterns_yytext

char* patterns_yytext
extern

◆ sac_current_block

statement sac_current_block
extern

Definition at line 722 of file simdizer.c.

Referenced by make_new_simd_vector_with_prefix(), and simdize_simple_statements().

◆ sac_lineno

size_t sac_lineno
extern

patterns.c

Definition at line 149 of file sac.h.

Referenced by patterns_yyerror(), and simd_treematcher().

◆ sac_real_current_instruction

instruction sac_real_current_instruction
extern

Definition at line 723 of file simdizer.c.

Referenced by make_loadsave_statement(), and simdize_simple_statements().