PIPS
operatorid.c File Reference
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "effects.h"
#include "resources.h"
#include "misc.h"
#include "ri-util.h"
#include "effects-util.h"
#include "sac.h"
#include "patterns.h"
#include "pipsdbm.h"
+ Include dependency graph for operatorid.c:

Go to the source code of this file.

Data Structures

struct  oper_id_mapping
 

Functions

void set_simd_operator_mappings (void *m)
 operatorid.c More...
 
void reset_simd_operator_mappings ()
 
static void insert_mapping (oper_id_mapping *item)
 
static int do_get_operator_id (const char *ename)
 
int get_operator_id (entity e)
 
bool simd_operator_mappings (const string module_name)
 

Variables

static operator_id_tree mappings = NULL
 
static oper_id_mapping operators []
 

Function Documentation

◆ do_get_operator_id()

static int do_get_operator_id ( const char *  ename)
static

Definition at line 143 of file operatorid.c.

144 {
146  for(const char *s = ename; *s != 0; s++)
147  {
148  operator_id_tree next;
149  intptr_t c = *s;
150 
151  next = (operator_id_tree)hash_get(operator_id_tree_sons(t), (void*)c);
152  if (next == HASH_UNDEFINED_VALUE)
153  {
154  return UNKNOWN_TOK;
155  }
156  t = next;
157  }
158  return operator_id_tree_id(t);
159 }
@ UNKNOWN_TOK
"invalid token"
Definition: patterns.h:57
void * hash_get(const hash_table htp, const void *key)
this function retrieves in the hash table pointed to by htp the couple whose key is equal to key.
Definition: hash.c:449
#define HASH_UNDEFINED_VALUE
value returned by hash_get() when the key is not found; could also be called HASH_KEY_NOT_FOUND,...
Definition: newgen_hash.h:56
static operator_id_tree mappings
Definition: operatorid.c:42
struct _newgen_struct_operator_id_tree_ * operator_id_tree
Definition: sac_private.h:90
#define operator_id_tree_sons(x)
Definition: sac_private.h:331
#define operator_id_tree_id(x)
Definition: sac_private.h:329
#define intptr_t
Definition: stdint.in.h:294

References hash_get(), HASH_UNDEFINED_VALUE, intptr_t, mappings, operator_id_tree_id, operator_id_tree_sons, and UNKNOWN_TOK.

Referenced by get_operator_id().

+ 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 }
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:

◆ insert_mapping()

static void insert_mapping ( oper_id_mapping item)
static

Definition at line 116 of file operatorid.c.

117 {
118  char * s;
120 
121  t = mappings;
122  for(s = item->name; *s != 0; s++)
123  {
124  operator_id_tree next;
125  intptr_t c = *s;
126 
127  next = (operator_id_tree)hash_get(operator_id_tree_sons(t), (void*)c);
128  if (next == HASH_UNDEFINED_VALUE)
129  {
131  hash_put(operator_id_tree_sons(t), (void *)c, (void*)next);
132  }
133 
134  t = next;
135  }
136 
138  pips_user_warning("overwriting previous mapping...\n");
139 
140  operator_id_tree_id(t) = item->id;
141 }
operator_id_tree make_operator_id_tree(intptr_t a1, operator_id_sons a2)
Definition: sac_private.c:237
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
void hash_put(hash_table htp, const void *key, const void *val)
This functions stores a couple (key,val) in the hash table pointed to by htp.
Definition: hash.c:364
#define pips_user_warning
Definition: misc-local.h:146
@ hash_int
Definition: newgen_hash.h:32
#define HASH_DEFAULT_SIZE
Definition: newgen_hash.h:26

References HASH_DEFAULT_SIZE, hash_get(), hash_int, hash_put(), hash_table_make(), HASH_UNDEFINED_VALUE, oper_id_mapping::id, intptr_t, make_operator_id_tree(), mappings, oper_id_mapping::name, operator_id_tree_id, operator_id_tree_sons, pips_user_warning, and UNKNOWN_TOK.

Referenced by simd_operator_mappings().

+ Here is the call graph for this function:
+ Here is the caller 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 }
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172

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_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:

◆ simd_operator_mappings()

bool simd_operator_mappings ( const string  module_name)

create a new operator id

put it in pipsdbm

Parameters
module_nameodule_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 }
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
#define DB_PUT_MEMORY_RESOURCE(res_name, own_name, res_val)
conform to old interface.
Definition: pipsdbm-local.h:66
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:

Variable Documentation

◆ mappings

◆ operators

oper_id_mapping operators[]
static

Definition at line 66 of file operatorid.c.

Referenced by simd_operator_mappings().