Commit f1308e4b by Richard Biener Committed by Richard Biener

genmatch.c: Remove <map>, <utility> and <string> includes.

2014-10-30  Richard Biener  <rguenther@suse.de>

	* genmatch.c: Remove <map>, <utility> and <string> includes.
	Include ggc.h and hash-map.h.
	(ggc_internal_cleared_alloc): Provide stub definition.
	(ggc_free): Likewise.
	(struct capture_id_map_hasher): New traits for hash_map.
	(cid_map_t): New typedef.
	(everywhere else): Replace std::map use with cid_map_t.
	* hash-map.h (hash_map::elements): New member function.
	* Makefile.in (build/genmatch.o): Add $(HASH_TABLE_H),
	hash-map.h and $(GGC_H) as dependency.

From-SVN: r216940
parent d822570f
2014-10-30 Richard Biener <rguenther@suse.de> 2014-10-30 Richard Biener <rguenther@suse.de>
* genmatch.c: Remove <map>, <utility> and <string> includes.
Include ggc.h and hash-map.h.
(ggc_internal_cleared_alloc): Provide stub definition.
(ggc_free): Likewise.
(struct capture_id_map_hasher): New traits for hash_map.
(cid_map_t): New typedef.
(everywhere else): Replace std::map use with cid_map_t.
* hash-map.h (hash_map::elements): New member function.
* Makefile.in (build/genmatch.o): Add $(HASH_TABLE_H),
hash-map.h and $(GGC_H) as dependency.
2014-10-30 Richard Biener <rguenther@suse.de>
* genmatch.c (capture_info::walk_c_expr): Ignore capture * genmatch.c (capture_info::walk_c_expr): Ignore capture
uses inside TREE_TYPE (). uses inside TREE_TYPE ().
* gimple-ssa-strength-reduction.c (stmt_cost): Use CASE_CONVERT. * gimple-ssa-strength-reduction.c (stmt_cost): Use CASE_CONVERT.
...@@ -2495,7 +2495,7 @@ build/genhooks.o : genhooks.c $(TARGET_DEF) $(C_TARGET_DEF) \ ...@@ -2495,7 +2495,7 @@ build/genhooks.o : genhooks.c $(TARGET_DEF) $(C_TARGET_DEF) \
build/genmddump.o : genmddump.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H) \ build/genmddump.o : genmddump.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H) \
coretypes.h $(GTM_H) errors.h $(READ_MD_H) gensupport.h coretypes.h $(GTM_H) errors.h $(READ_MD_H) gensupport.h
build/genmatch.o : genmatch.c $(BCONFIG_H) $(SYSTEM_H) \ build/genmatch.o : genmatch.c $(BCONFIG_H) $(SYSTEM_H) \
coretypes.h errors.h coretypes.h errors.h $(HASH_TABLE_H) hash-map.h $(GGC_H)
# Compile the programs that generate insn-* from the machine description. # Compile the programs that generate insn-* from the machine description.
# They are compiled with $(COMPILER_FOR_BUILD), and associated libraries, # They are compiled with $(COMPILER_FOR_BUILD), and associated libraries,
......
...@@ -23,19 +23,30 @@ along with GCC; see the file COPYING3. If not see ...@@ -23,19 +23,30 @@ along with GCC; see the file COPYING3. If not see
#include "bconfig.h" #include "bconfig.h"
#include <new> #include <new>
#include <map>
#include <utility>
#include <string>
#include "system.h" #include "system.h"
#include "coretypes.h" #include "coretypes.h"
#include "ggc.h"
#include <cpplib.h> #include <cpplib.h>
#include "errors.h" #include "errors.h"
#include "hashtab.h" #include "hashtab.h"
#include "hash-table.h" #include "hash-table.h"
#include "hash-map.h"
#include "vec.h" #include "vec.h"
#include "is-a.h" #include "is-a.h"
/* Stubs for GGC referenced through instantiations triggered by hash-map. */
void *ggc_internal_cleared_alloc (size_t, void (*)(void *),
size_t, size_t
CXX_MEM_STAT_INFO)
{
return NULL;
}
void ggc_free (void *)
{
}
/* libccp helpers. */ /* libccp helpers. */
static struct line_maps *line_table; static struct line_maps *line_table;
...@@ -350,6 +361,28 @@ get_operator (const char *id) ...@@ -350,6 +361,28 @@ get_operator (const char *id)
} }
/* Helper for the capture-id map. */
struct capture_id_map_hasher : default_hashmap_traits
{
static inline hashval_t hash (const char *);
static inline bool equal_keys (const char *, const char *);
};
inline hashval_t
capture_id_map_hasher::hash (const char *id)
{
return htab_hash_string (id);
}
inline bool
capture_id_map_hasher::equal_keys (const char *id1, const char *id2)
{
return strcmp (id1, id2) == 0;
}
typedef hash_map<const char *, unsigned, capture_id_map_hasher> cid_map_t;
/* The AST produced by parsing of the pattern definitions. */ /* The AST produced by parsing of the pattern definitions. */
...@@ -410,13 +443,13 @@ struct c_expr : public operand ...@@ -410,13 +443,13 @@ struct c_expr : public operand
}; };
c_expr (cpp_reader *r_, vec<cpp_token> code_, unsigned nr_stmts_, c_expr (cpp_reader *r_, vec<cpp_token> code_, unsigned nr_stmts_,
vec<id_tab> ids_, std::map<std::string, unsigned> *capture_ids_) vec<id_tab> ids_, cid_map_t *capture_ids_)
: operand (OP_C_EXPR), r (r_), code (code_), capture_ids (capture_ids_), : operand (OP_C_EXPR), r (r_), code (code_), capture_ids (capture_ids_),
nr_stmts (nr_stmts_), ids (ids_) {} nr_stmts (nr_stmts_), ids (ids_) {}
/* cpplib tokens and state to transform this back to source. */ /* cpplib tokens and state to transform this back to source. */
cpp_reader *r; cpp_reader *r;
vec<cpp_token> code; vec<cpp_token> code;
std::map<std::string, unsigned> *capture_ids; cid_map_t *capture_ids;
/* The number of statements parsed (well, the number of ';'s). */ /* The number of statements parsed (well, the number of ';'s). */
unsigned nr_stmts; unsigned nr_stmts;
/* The identifier replacement vector. */ /* The identifier replacement vector. */
...@@ -492,11 +525,11 @@ struct simplify ...@@ -492,11 +525,11 @@ struct simplify
simplify (operand *match_, source_location match_location_, simplify (operand *match_, source_location match_location_,
struct operand *result_, source_location result_location_, struct operand *result_, source_location result_location_,
vec<if_or_with> ifexpr_vec_, vec<vec<user_id *> > for_vec_, vec<if_or_with> ifexpr_vec_, vec<vec<user_id *> > for_vec_,
std::map<std::string, unsigned> *capture_ids_) cid_map_t *capture_ids_)
: match (match_), match_location (match_location_), : match (match_), match_location (match_location_),
result (result_), result_location (result_location_), result (result_), result_location (result_location_),
ifexpr_vec (ifexpr_vec_), for_vec (for_vec_), ifexpr_vec (ifexpr_vec_), for_vec (for_vec_),
capture_ids (capture_ids_), capture_max (capture_ids_->size () - 1) {} capture_ids (capture_ids_), capture_max (capture_ids_->elements () - 1) {}
/* The expression that is matched against the GENERIC or GIMPLE IL. */ /* The expression that is matched against the GENERIC or GIMPLE IL. */
operand *match; operand *match;
...@@ -513,7 +546,7 @@ struct simplify ...@@ -513,7 +546,7 @@ struct simplify
in the lowering phase. */ in the lowering phase. */
vec<vec<user_id *> > for_vec; vec<vec<user_id *> > for_vec;
/* A map of capture identifiers to indexes. */ /* A map of capture identifiers to indexes. */
std::map<std::string, unsigned> *capture_ids; cid_map_t *capture_ids;
int capture_max; int capture_max;
}; };
...@@ -1419,7 +1452,7 @@ c_expr::gen_transform (FILE *f, const char *dest, ...@@ -1419,7 +1452,7 @@ c_expr::gen_transform (FILE *f, const char *dest,
id = (const char *)n->val.str.text; id = (const char *)n->val.str.text;
else else
id = (const char *)CPP_HASHNODE (n->val.node.node)->ident.str; id = (const char *)CPP_HASHNODE (n->val.node.node)->ident.str;
fprintf (f, "captures[%u]", (*capture_ids)[id]); fprintf (f, "captures[%u]", *capture_ids->get(id));
++i; ++i;
continue; continue;
} }
...@@ -2029,7 +2062,7 @@ capture_info::walk_c_expr (c_expr *e) ...@@ -2029,7 +2062,7 @@ capture_info::walk_c_expr (c_expr *e)
id = (const char *)n->val.str.text; id = (const char *)n->val.str.text;
else else
id = (const char *)CPP_HASHNODE (n->val.node.node)->ident.str; id = (const char *)CPP_HASHNODE (n->val.node.node)->ident.str;
info[(*e->capture_ids)[id]].force_no_side_effects_p = true; info[*e->capture_ids->get(id)].force_no_side_effects_p = true;
} }
} }
} }
...@@ -2439,7 +2472,7 @@ private: ...@@ -2439,7 +2472,7 @@ private:
vec<if_or_with> active_ifs; vec<if_or_with> active_ifs;
vec<vec<user_id *> > active_fors; vec<vec<user_id *> > active_fors;
std::map<std::string, unsigned> *capture_ids; cid_map_t *capture_ids;
public: public:
vec<simplify *> simplifiers; vec<simplify *> simplifiers;
...@@ -2615,10 +2648,12 @@ parser::parse_capture (operand *op) ...@@ -2615,10 +2648,12 @@ parser::parse_capture (operand *op)
id = get_ident (); id = get_ident ();
else else
fatal_at (token, "expected number or identifier"); fatal_at (token, "expected number or identifier");
unsigned next_id = capture_ids->size (); unsigned next_id = capture_ids->elements ();
std::pair<std::map<std::string, unsigned>::iterator, bool> res bool existed;
= capture_ids->insert (std::pair<std::string, unsigned>(id, next_id)); unsigned &num = capture_ids->get_or_insert (id, &existed);
return new capture ((*res.first).second, op); if (!existed)
num = next_id;
return new capture (num, op);
} }
/* Parse an expression /* Parse an expression
...@@ -2799,7 +2834,7 @@ parser::parse_simplify (source_location match_location, ...@@ -2799,7 +2834,7 @@ parser::parse_simplify (source_location match_location,
expr *result) expr *result)
{ {
/* Reset the capture map. */ /* Reset the capture map. */
capture_ids = new std::map<std::string, unsigned>; capture_ids = new cid_map_t;
const cpp_token *loc = peek (); const cpp_token *loc = peek ();
struct operand *match = parse_op (); struct operand *match = parse_op ();
......
...@@ -264,6 +264,8 @@ public: ...@@ -264,6 +264,8 @@ public:
break; break;
} }
size_t elements () const { return m_table.elements (); }
private: private:
template<typename T, typename U, typename V> friend void gt_ggc_mx (hash_map<T, U, V> *); template<typename T, typename U, typename V> friend void gt_ggc_mx (hash_map<T, U, V> *);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment