Commit fe4cd998 authored by Matthias Braun's avatar Matthias Braun
Browse files

remove a bunch of is_XXX firm_kind convenience functions

This sort of typeless programming is bad style and deprecated.
parent eed48301
......@@ -134,16 +134,6 @@ FIRM_API ir_graph *new_ir_graph(ir_entity *ent, int n_loc);
*/
FIRM_API void free_ir_graph(ir_graph *irg);
/**
* Checks whether a pointer points to a ir graph.
*
* @param thing an arbitrary pointer
*
* @return
* true if the thing is a IR graph, else false
*/
FIRM_API int is_ir_graph(const void *thing);
/** Returns the entity of an IR graph. */
FIRM_API ir_entity *get_irg_entity(const ir_graph *irg);
/** Sets the entity of an IR graph. */
......
......@@ -48,11 +48,6 @@ typedef union {
ir_graph *irg; /**< Pointer to an ir_graph element (only callgraph loop trees) */
} loop_element;
/** Tests whether a given pointer points to a loop.
* @note only works reliably if @p thing points to something with a ::firm_kind
* header */
FIRM_API int is_ir_loop(const void *thing);
/** Sets the outermost loop in ir graph as basic access to loop tree. */
FIRM_API void set_irg_loop(ir_graph *irg, ir_loop *l);
......
......@@ -113,16 +113,6 @@ FIRM_API ir_mode *new_float_mode(const char *name,
*/
FIRM_API ir_mode *new_non_arithmetic_mode(const char *name);
/**
* Checks whether a pointer points to a mode.
*
* @param thing an arbitrary pointer
*
* @return
* true if the thing is a mode, else false
*/
FIRM_API int is_mode(const void *thing);
/** Returns the ident* of the mode */
FIRM_API ident *get_mode_ident(const ir_mode *mode);
......
......@@ -41,17 +41,6 @@
* @{
*/
/**
* Checks whether a pointer points to a ir node. This is guessed by looking
* at the few bytes of the thing. Most things used in firm have a firm_kind
* attribute there. This function might falsely return true though for things
* without a firm_kind at the beginning.
*
* @param thing an arbitrary pointer
* @return non-zero if the thing is a ir mode, else zero
*/
FIRM_API int is_ir_node(const void *thing);
/**
* Returns the number of predecessors without the block predecessor.
*
......
......@@ -699,16 +699,6 @@ FIRM_API int tarval_is_minus_inf(const ir_tarval *tv);
*/
FIRM_API int tarval_is_finite(const ir_tarval *tv);
/**
* Checks whether a pointer points to a tarval.
*
* @param thing an arbitrary pointer
*
* @return
* true if the thing is a tarval, else false
*/
FIRM_API int is_tarval(const void *thing);
/** @} */
#include "end.h"
......
......@@ -582,16 +582,6 @@ FIRM_API void set_entity_overwrittenby(ir_entity *ent, size_t pos,
FIRM_API void remove_entity_overwrittenby(ir_entity *ent,
ir_entity *overwrites);
/**
* Checks whether a pointer points to an entity.
*
* @param thing an arbitrary pointer
*
* @return
* true if the thing is an entity, else false
*/
FIRM_API int is_entity(const void *thing);
/** Returns true if the type of the entity is a primitive, pointer
* or method type.
*
......@@ -1063,16 +1053,6 @@ FIRM_API void set_type_dbg_info(ir_type *tp, type_dbg_info *db);
*/
FIRM_API type_dbg_info *get_type_dbg_info(const ir_type *tp);
/**
* Checks whether a pointer points to a type.
*
* @param thing an arbitrary pointer
*
* @return
* true if the thing is a type, else false
*/
FIRM_API int is_type(const void *thing);
/**
* Outputs a unique number for this type if libfirm is compiled for
* debugging, (configure with --enable-debug) else returns the address
......
......@@ -110,11 +110,6 @@ void *get_loop_link(const ir_loop *loop)
return loop->link;
}
int (is_ir_loop)(const void *thing)
{
return _is_ir_loop(thing);
}
void (set_irg_loop)(ir_graph *irg, ir_loop *loop)
{
_set_irg_loop(irg, loop);
......
......@@ -408,7 +408,7 @@ void add_immBlock_pred(ir_node *block, ir_node *jmp)
{
assert(is_Block(block) && "Error: Must be a Block");
assert(!get_Block_matured(block) && "Error: Block already matured!\n");
assert(is_ir_node(jmp));
assert(jmp->kind == k_ir_node);
int const n = ARR_LEN(block->in) - 1;
ARR_APP1(ir_node *, block->in, jmp);
......@@ -507,7 +507,7 @@ void set_r_value(ir_graph *irg, int pos, ir_node *value)
assert(irg_is_constrained(irg, IR_GRAPH_CONSTRAINT_CONSTRUCTION));
assert(pos >= 0);
assert(pos + 1 < irg->n_loc);
assert(is_ir_node(value));
assert(value->kind == k_ir_node);
irg->current_block->attr.block.graph_arr[pos + 1] = value;
}
......
......@@ -256,7 +256,7 @@ ir_graph *create_irg_copy(ir_graph *irg)
void free_ir_graph(ir_graph *irg)
{
assert(is_ir_graph(irg));
assert(irg->kind == k_ir_graph);
remove_irp_irg(irg);
confirm_irg_properties(irg, IR_GRAPH_PROPERTIES_NONE);
......@@ -276,11 +276,6 @@ void free_ir_graph(ir_graph *irg)
free_graph(irg);
}
int (is_ir_graph)(const void *thing)
{
return is_ir_graph_(thing);
}
long get_irg_graph_nr(const ir_graph *irg)
{
#ifdef DEBUG_libfirm
......
......@@ -22,7 +22,6 @@
#include "irloop.h"
#include "obst.h"
#define is_ir_graph(thing) is_ir_graph_(thing)
#define get_irg_start_block(irg) get_irg_start_block_(irg)
#define set_irg_start_block(irg, node) set_irg_start_block_(irg, node)
#define get_irg_start(irg) get_irg_start_(irg)
......@@ -121,11 +120,6 @@ int node_is_in_irgs_storage(const ir_graph *irg, const ir_node *n);
/* inline functions for graphs */
/*-------------------------------------------------------------------*/
static inline int is_ir_graph_(const void *thing)
{
return (get_kind(thing) == k_ir_graph);
}
/** Returns the start block of a graph. */
static inline ir_node *get_irg_start_block_(const ir_graph *irg)
{
......
......@@ -234,7 +234,7 @@ static void irg_walk_in_or_dep_2(ir_node *node, irg_walk_func *pre,
void irg_walk_in_or_dep(ir_node *node, irg_walk_func *pre, irg_walk_func *post,
void *env)
{
assert(is_ir_node(node));
assert(node->kind == k_ir_node);
ir_graph *const irg = get_irn_irg(node);
ir_reserve_resources(irg, IR_RESOURCE_IRN_VISITED);
......
......@@ -295,11 +295,6 @@ ir_tarval *get_mode_NAN(const ir_mode *mode)
return mode->nan;
}
int is_mode(const void *thing)
{
return get_kind(thing) == k_ir_mode;
}
int (mode_is_signed)(const ir_mode *mode)
{
return mode_is_signed_(mode);
......
......@@ -141,11 +141,6 @@ ir_node *new_similar_node(ir_node *const old, ir_node *const block, ir_node **co
return n;
}
int (is_ir_node)(const void *thing)
{
return is_ir_node_(thing);
}
int (get_irn_arity)(const ir_node *node)
{
return get_irn_arity_(node);
......@@ -428,19 +423,19 @@ long get_irn_node_nr(const ir_node *node)
void *(get_irn_generic_attr)(ir_node *node)
{
assert(is_ir_node(node));
assert(node->kind == k_ir_node);
return get_irn_generic_attr_(node);
}
const void *(get_irn_generic_attr_const)(const ir_node *node)
{
assert(is_ir_node(node));
assert(node->kind == k_ir_node);
return get_irn_generic_attr_const_(node);
}
unsigned (get_irn_idx)(const ir_node *node)
{
assert(is_ir_node(node));
assert(node->kind == k_ir_node);
return get_irn_idx_(node);
}
......
......@@ -20,7 +20,6 @@
#include "iredges_t.h"
/* This section MUST come first, so the inline functions get used in this header. */
#define is_ir_node(thing) is_ir_node_(thing)
#define get_irn_arity(node) get_irn_arity_(node)
#define get_irn_n(node, n) get_irn_n_(node, n)
#define get_irn_mode(node) get_irn_mode_(node)
......@@ -95,15 +94,6 @@ ir_node **get_irn_in(const ir_node *node);
/* functions so they can be inlined. */
/*-------------------------------------------------------------------*/
/**
* Checks whether a pointer points to a ir node.
* Intern version for libFirm.
*/
static inline int is_ir_node_(const void *thing)
{
return (get_kind(thing) == k_ir_node);
}
static inline unsigned get_irn_idx_(const ir_node *node)
{
return node->node_idx;
......@@ -302,7 +292,7 @@ static inline void set_irn_link_(ir_node *node, void *link)
*/
static inline void *get_irn_link_(const ir_node *node)
{
assert(is_ir_node_(node));
assert(node->kind == k_ir_node);
return node->link;
}
......@@ -315,7 +305,7 @@ static inline void *get_irn_link_(const ir_node *node)
static inline op_pin_state get_irn_pinned_(const ir_node *node)
{
op_pin_state state;
assert(is_ir_node_(node));
assert(node->kind == k_ir_node);
/* Check opcode */
state = get_op_pinned_(get_irn_op_(node));
......@@ -327,7 +317,7 @@ static inline op_pin_state get_irn_pinned_(const ir_node *node)
static inline int is_binop_(const ir_node *node)
{
assert(is_ir_node_(node));
assert(node->kind == k_ir_node);
return (node->op->opar == oparity_binary);
}
......
......@@ -200,7 +200,7 @@ static ir_entity *deep_entity_copy(ir_entity *old)
ir_entity *copy_entity_own(ir_entity *old, ir_type *new_owner)
{
assert(is_entity(old));
assert(old->kind == k_entity);
assert(is_compound_type(new_owner));
assert(get_type_state(new_owner) != layout_fixed);
if (old->owner == new_owner)
......@@ -272,7 +272,7 @@ ir_type *(get_entity_owner)(const ir_entity *ent)
void set_entity_owner(ir_entity *ent, ir_type *owner)
{
assert(is_entity(ent));
assert(ent->kind == k_entity);
assert(is_compound_type(owner));
remove_compound_member(ent->owner, ent);
......@@ -804,11 +804,6 @@ int is_unknown_entity(const ir_entity *entity)
return entity->entity_kind == IR_ENTITY_UNKNOWN;
}
int (is_entity)(const void *thing)
{
return _is_entity(thing);
}
int is_atomic_entity(const ir_entity *ent)
{
ir_type *t = get_entity_type(ent);
......
......@@ -18,7 +18,6 @@
#include "type_t.h"
#include "ident.h"
#define is_entity(thing) _is_entity(thing)
#define get_entity_name(ent) _get_entity_name(ent)
#define get_entity_ident(ent) _get_entity_ident(ent)
#define set_entity_ident(ent, id) _set_entity_ident(ent, id)
......@@ -235,7 +234,7 @@ ir_entity *new_got_entry_entity(ir_entity *reference);
void set_entity_irg(ir_entity *ent, ir_graph *irg);
/* ----------------------- inline functions ------------------------ */
static inline int _is_entity(const void *thing)
static inline bool is_entity(const void *thing)
{
return get_kind(thing) == k_entity;
}
......
......@@ -116,7 +116,6 @@ static pset *get_entity_map(const ir_entity *ent, dir d)
static pset *get_type_map(const ir_type *tp, dir d)
{
assert(is_type(tp));
tr_inh_trans_tp *found = get_firm_kind_entry((const firm_kind *)tp);
return found->directions[d];
}
......
......@@ -182,6 +182,11 @@ ident *(get_type_tpop_nameid)(const ir_type *tp)
return get_type_tpop_nameid_(tp);
}
static inline bool is_type(const void *thing)
{
return get_kind(thing) == k_type;
}
const char* get_type_tpop_name(const ir_type *tp)
{
assert(is_type(tp));
......@@ -341,11 +346,6 @@ void (set_type_dbg_info)(ir_type *tp, type_dbg_info *db)
set_type_dbg_info_(tp, db);
}
int (is_type)(const void *thing)
{
return is_type_(thing);
}
static void compound_init(ir_type *type)
{
type->attr.ca.members = NEW_ARR_F(ir_entity*, 0);
......
......@@ -35,7 +35,6 @@
#define type_visited(tp) type_visited_(tp)
#define get_type_dbg_info(tp) get_type_dbg_info_(tp)
#define set_type_dbg_info(tp, db) set_type_dbg_info_(tp, db)
#define is_type(thing) is_type_(thing)
#define is_Class_type(clss) is_class_type_(clss)
#define get_class_n_members(clss) get_class_n_members_(clss)
#define get_class_member(clss, pos) get_class_member_(clss, pos)
......@@ -198,11 +197,6 @@ static inline ir_visited_t get_master_type_visited_(void)
return firm_type_visited;
}
static inline int is_type_(const void *thing)
{
return get_kind(thing) == k_type;
}
static inline int is_lowered_type(const ir_type *tp)
{
return tp->flags & tf_lowered_type;
......@@ -257,7 +251,7 @@ static inline ir_mode *get_type_mode_(const ir_type *tp)
static inline unsigned get_type_alignment_bytes_(const ir_type *type)
{
assert(is_type(type));
assert(type->kind == k_type);
return type->align;
}
......
......@@ -1521,11 +1521,6 @@ void finish_tarval(void)
del_set(tarvals); tarvals = NULL;
}
int (is_tarval)(const void *thing)
{
return is_tarval_(thing);
}
bool tarval_in_range(ir_tarval const *const min, ir_tarval const *const val, ir_tarval const *const max)
{
assert(tarval_cmp(min, max) & ir_relation_less_equal);
......
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