Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
0f301e31
Commit
0f301e31
authored
Jan 15, 2013
by
Matthias Braun
Browse files
avoid ir_op_ops struct in public API
structs are bad in a library API. We provide setter functions for the fields now.
parent
60ccdca9
Changes
5
Hide whitespace changes
Inline
Side-by-side
include/libfirm/firm_types.h
View file @
0f301e31
...
...
@@ -83,9 +83,6 @@ typedef struct ir_entity ir_entity;
/** @ingroup ir_cdep
* Control Dependence Analysis Results */
typedef
struct
ir_cdep
ir_cdep
;
/** @ingroup be
* Target Architecture specific node operations */
typedef
struct
arch_irn_ops_t
arch_irn_ops_t
;
/** A graph transformation pass */
typedef
struct
ir_graph_pass_t
ir_graph_pass_t
;
/** A whole program transformation pass */
...
...
include/libfirm/irop.h
View file @
0f301e31
...
...
@@ -218,30 +218,36 @@ typedef enum {
*/
typedef
void
(
*
dump_node_func
)(
FILE
*
out
,
const
ir_node
*
self
,
dump_reason_t
reason
);
/**
* io_op Operations.
*/
typedef
struct
{
hash_func
hash
;
/**< Calculate a hash value for an IR node. */
computed_value_func
computed_value
;
/**< Evaluates a node into a tarval if possible. */
computed_value_func
computed_value_Proj
;
/**< Evaluates a Proj node into a tarval if possible. */
equivalent_node_func
equivalent_node
;
/**< Optimizes the node by returning an equivalent one. */
equivalent_node_func
equivalent_node_Proj
;
/**< Optimizes the Proj node by returning an equivalent one. */
transform_node_func
transform_node
;
/**< Optimizes the node by transforming it. */
transform_node_func
transform_node_Proj
;
/**< Optimizes the Proj node by transforming it. */
node_cmp_attr_func
node_cmp_attr
;
/**< Compares two node attributes. */
reassociate_func
reassociate
;
/**< Reassociate a tree. */
copy_attr_func
copy_attr
;
/**< Copy node attributes. */
get_type_attr_func
get_type_attr
;
/**< Returns the type attribute of a node. */
get_entity_attr_func
get_entity_attr
;
/**< Returns the entity attribute of a node. */
verify_node_func
verify_node
;
/**< Verify the node. */
verify_proj_node_func
verify_proj_node
;
/**< Verify the Proj node. */
dump_node_func
dump_node
;
/**< Dump a node. */
op_func
generic
;
/**< A generic function pointer. */
op_func
generic1
;
/**< A generic function pointer. */
op_func
generic2
;
/**< A generic function pointer. */
const
arch_irn_ops_t
*
be_ops
;
/**< callbacks used by the backend. */
}
ir_op_ops
;
/** Sets hash callback @p func for operation @p op */
FIRM_API
void
set_op_hash
(
ir_op
*
op
,
hash_func
func
);
/** Sets computed_value callback @p func for operation @p op */
FIRM_API
void
set_op_computed_value
(
ir_op
*
op
,
computed_value_func
func
);
/** Sets compute_value for Proj callback @p func for operation @p op */
FIRM_API
void
set_op_computed_value_proj
(
ir_op
*
op
,
computed_value_func
func
);
/** Sets equivalent node callback @p func for operation @p op */
FIRM_API
void
set_op_equivalent_node
(
ir_op
*
op
,
equivalent_node_func
func
);
/** Sets equivalent Proj node callback @p func for operation @p op */
FIRM_API
void
set_op_equivalent_node_proj
(
ir_op
*
op
,
equivalent_node_func
func
);
/** Sets transform node callback @p func for operation @p op */
FIRM_API
void
set_op_transform_node
(
ir_op
*
op
,
transform_node_func
func
);
/** Sets transform Proj node callback @p func for operation @p op */
FIRM_API
void
set_op_transform_node_proj
(
ir_op
*
op
,
transform_node_func
func
);
/** Sets cmp_attr callback @p func for operation @p op */
FIRM_API
void
set_op_cmp_attr
(
ir_op
*
op
,
node_cmp_attr_func
func
);
/** Sets reassociation callback @p func for operation @p op */
FIRM_API
void
set_op_reassociate
(
ir_op
*
op
,
reassociate_func
func
);
/** Sets attribute copy callback @p func for operation @p op */
FIRM_API
void
set_op_copy_attr
(
ir_op
*
op
,
copy_attr_func
func
);
/** Sets get type callback @p func for operation @p op */
FIRM_API
void
set_op_get_type_attr
(
ir_op
*
op
,
get_type_attr_func
func
);
/** Sets get entity callback @p func for operation @p op */
FIRM_API
void
set_op_get_entity_attr
(
ir_op
*
op
,
get_entity_attr_func
func
);
/** Sets verify callback @p func for operation @p op */
FIRM_API
void
set_op_verify
(
ir_op
*
op
,
verify_node_func
func
);
/** Sets proj verify callback @p func for operation @p op */
FIRM_API
void
set_op_verify_proj
(
ir_op
*
op
,
verify_proj_node_func
func
);
/** Sets dump callback @p func for operation @p op */
FIRM_API
void
set_op_dump
(
ir_op
*
op
,
dump_node_func
func
);
/**
* Creates a new IR operation.
...
...
@@ -290,9 +296,6 @@ FIRM_API void ir_op_set_memory_index(ir_op *op, int memory_index);
FIRM_API
void
ir_op_set_fragile_indices
(
ir_op
*
op
,
int
pn_x_regular
,
int
pn_x_except
);
/** Returns the ir_op_ops of an ir_op. */
FIRM_API
ir_op_ops
const
*
get_op_ops
(
ir_op
const
*
op
);
/** @} */
#include "end.h"
...
...
ir/ir/irop.c
View file @
0f301e31
...
...
@@ -175,11 +175,6 @@ void (set_generic_function_ptr)(ir_op *op, op_func func)
set_generic_function_ptr_
(
op
,
func
);
}
ir_op_ops
const
*
(
get_op_ops
)(
ir_op
const
*
const
op
)
{
return
get_op_ops_
(
op
);
}
irop_flags
get_op_flags
(
const
ir_op
*
op
)
{
return
(
irop_flags
)
op
->
flags
;
...
...
@@ -539,21 +534,81 @@ static void switch_copy_attr(ir_graph *irg, const ir_node *old_node,
new_node
->
attr
.
switcha
.
n_outs
=
old_node
->
attr
.
switcha
.
n_outs
;
}
static
void
register_node_cmp_func
(
ir_op
*
op
,
node_cmp_attr_func
func
)
void
set_op_hash
(
ir_op
*
op
,
hash_func
func
)
{
op
->
ops
.
hash
=
func
;
}
void
set_op_computed_value
(
ir_op
*
op
,
computed_value_func
func
)
{
op
->
ops
.
computed_value
=
func
;
}
void
set_op_computed_value_proj
(
ir_op
*
op
,
computed_value_func
func
)
{
op
->
ops
.
computed_value_Proj
=
func
;
}
void
set_op_equivalent_node
(
ir_op
*
op
,
equivalent_node_func
func
)
{
op
->
ops
.
equivalent_node
=
func
;
}
void
set_op_equivalent_node_proj
(
ir_op
*
op
,
equivalent_node_func
func
)
{
op
->
ops
.
equivalent_node_Proj
=
func
;
}
void
set_op_transform_node
(
ir_op
*
op
,
transform_node_func
func
)
{
op
->
ops
.
transform_node
=
func
;
}
void
set_op_transform_node_proj
(
ir_op
*
op
,
transform_node_func
func
)
{
op
->
ops
.
transform_node_Proj
=
func
;
}
void
set_op_cmp_attr
(
ir_op
*
op
,
node_cmp_attr_func
func
)
{
op
->
ops
.
node_cmp_attr
=
func
;
}
static
void
register_node_hash_func
(
ir_op
*
op
,
hash
_func
func
)
void
set_op_reassociate
(
ir_op
*
op
,
reassociate
_func
func
)
{
op
->
ops
.
hash
=
func
;
op
->
ops
.
reassociate
=
func
;
}
static
void
register_node
_copy_attr
_func
(
ir_op
*
op
,
copy_attr_func
func
)
void
set_op
_copy_attr
(
ir_op
*
op
,
copy_attr_func
func
)
{
op
->
ops
.
copy_attr
=
func
;
}
void
set_op_get_type_attr
(
ir_op
*
op
,
get_type_attr_func
func
)
{
op
->
ops
.
get_type_attr
=
func
;
}
void
set_op_get_entity_attr
(
ir_op
*
op
,
get_entity_attr_func
func
)
{
op
->
ops
.
get_entity_attr
=
func
;
}
void
set_op_verify
(
ir_op
*
op
,
verify_node_func
func
)
{
op
->
ops
.
verify_node
=
func
;
}
void
set_op_verify_proj
(
ir_op
*
op
,
verify_proj_node_func
func
)
{
op
->
ops
.
verify_proj_node
=
func
;
}
void
set_op_dump
(
ir_op
*
op
,
dump_node_func
func
)
{
op
->
ops
.
dump_node
=
func
;
}
static
void
generated_init_op
(
void
);
static
void
generated_finish_op
(
void
);
...
...
@@ -563,34 +618,34 @@ void firm_init_op(void)
generated_init_op
();
be_init_op
();
register_node
_cmp_
func
(
op_ASM
,
node_cmp_attr_ASM
);
register_node
_cmp_
func
(
op_Alloc
,
node_cmp_attr_Alloc
);
register_node
_cmp_
func
(
op_Builtin
,
node_cmp_attr_Builtin
);
register_node
_cmp_
func
(
op_Call
,
node_cmp_attr_Call
);
register_node
_cmp_
func
(
op_Cmp
,
node_cmp_attr_Cmp
);
register_node
_cmp_
func
(
op_Confirm
,
node_cmp_attr_Confirm
);
register_node
_cmp_
func
(
op_Const
,
node_cmp_attr_Const
);
register_node
_cmp_
func
(
op_CopyB
,
node_cmp_attr_CopyB
);
register_node
_cmp_
func
(
op_Div
,
node_cmp_attr_Div
);
register_node
_cmp_
func
(
op_Dummy
,
node_cmp_attr_Dummy
);
register_node
_cmp_
func
(
op_Free
,
node_cmp_attr_Free
);
register_node
_cmp_
func
(
op_InstOf
,
node_cmp_attr_InstOf
);
register_node
_cmp_
func
(
op_Load
,
node_cmp_attr_Load
);
register_node
_cmp_
func
(
op_Mod
,
node_cmp_attr_Mod
);
register_node
_cmp_
func
(
op_Phi
,
node_cmp_attr_Phi
);
register_node
_cmp_
func
(
op_Proj
,
node_cmp_attr_Proj
);
register_node
_cmp_
func
(
op_Sel
,
node_cmp_attr_Sel
);
register_node
_cmp_
func
(
op_Store
,
node_cmp_attr_Store
);
register_node
_cmp_
func
(
op_SymConst
,
node_cmp_attr_SymConst
);
register_node_hash_func
(
op_Const
,
hash_Const
);
register_node_hash_func
(
op_SymConst
,
hash_SymConst
);
register_node
_copy_attr
_func
(
op_Call
,
call_copy_attr
);
register_node
_copy_attr
_func
(
op_Block
,
block_copy_attr
);
register_node
_copy_attr
_func
(
op_Phi
,
phi_copy_attr
);
register_node
_copy_attr
_func
(
op_ASM
,
ASM_copy_attr
);
register_node
_copy_attr
_func
(
op_Switch
,
switch_copy_attr
);
set_op
_cmp_
attr
(
op_ASM
,
node_cmp_attr_ASM
);
set_op
_cmp_
attr
(
op_Alloc
,
node_cmp_attr_Alloc
);
set_op
_cmp_
attr
(
op_Builtin
,
node_cmp_attr_Builtin
);
set_op
_cmp_
attr
(
op_Call
,
node_cmp_attr_Call
);
set_op
_cmp_
attr
(
op_Cmp
,
node_cmp_attr_Cmp
);
set_op
_cmp_
attr
(
op_Confirm
,
node_cmp_attr_Confirm
);
set_op
_cmp_
attr
(
op_Const
,
node_cmp_attr_Const
);
set_op
_cmp_
attr
(
op_CopyB
,
node_cmp_attr_CopyB
);
set_op
_cmp_
attr
(
op_Div
,
node_cmp_attr_Div
);
set_op
_cmp_
attr
(
op_Dummy
,
node_cmp_attr_Dummy
);
set_op
_cmp_
attr
(
op_Free
,
node_cmp_attr_Free
);
set_op
_cmp_
attr
(
op_InstOf
,
node_cmp_attr_InstOf
);
set_op
_cmp_
attr
(
op_Load
,
node_cmp_attr_Load
);
set_op
_cmp_
attr
(
op_Mod
,
node_cmp_attr_Mod
);
set_op
_cmp_
attr
(
op_Phi
,
node_cmp_attr_Phi
);
set_op
_cmp_
attr
(
op_Proj
,
node_cmp_attr_Proj
);
set_op
_cmp_
attr
(
op_Sel
,
node_cmp_attr_Sel
);
set_op
_cmp_
attr
(
op_Store
,
node_cmp_attr_Store
);
set_op
_cmp_
attr
(
op_SymConst
,
node_cmp_attr_SymConst
);
set_op_hash
(
op_Const
,
hash_Const
);
set_op_hash
(
op_SymConst
,
hash_SymConst
);
set_op
_copy_attr
(
op_Call
,
call_copy_attr
);
set_op
_copy_attr
(
op_Block
,
block_copy_attr
);
set_op
_copy_attr
(
op_Phi
,
phi_copy_attr
);
set_op
_copy_attr
(
op_ASM
,
ASM_copy_attr
);
set_op
_copy_attr
(
op_Switch
,
switch_copy_attr
);
ir_register_opt_node_ops
();
ir_register_reassoc_node_ops
();
...
...
ir/ir/irop_t.h
View file @
0f301e31
...
...
@@ -21,7 +21,6 @@
#define get_op_code(op) get_op_code_(op)
#define get_op_ident(op) get_op_ident_(op)
#define get_op_pinned(op) get_op_pinned_(op)
#define get_op_ops(op) get_op_ops_(op)
#define set_op_tag(op, tag) set_op_tag_((op), (tag))
#define get_op_tag(op) get_op_tag_(op)
#define set_op_attr(op, attr) set_op_attr_((op), (attr))
...
...
@@ -45,7 +44,7 @@ void firm_finish_op(void);
* Returns the attribute size of nodes of this opcode.
* @note Use not encouraged, internal feature.
*/
static
inline
size_t
get_op_attr_size
(
const
ir_op
*
op
)
static
inline
size_t
get_op_attr_size
(
const
ir_op
*
op
)
{
return
op
->
attr_size
;
}
...
...
@@ -142,7 +141,7 @@ static inline op_func get_generic_function_ptr_(const ir_op *op)
return
op
->
ops
.
generic
;
}
static
inline
ir_op_ops
const
*
get_op_ops
_
(
ir_op
const
*
const
op
)
static
inline
ir_op_ops
const
*
get_op_ops
(
ir_op
const
*
const
op
)
{
return
&
op
->
ops
;
}
...
...
ir/ir/irtypes.h
View file @
0f301e31
...
...
@@ -18,6 +18,7 @@
#include "irmode.h"
#include "irnode.h"
#include "iredgekinds.h"
#include "irop.h"
#include "irtypeinfo.h"
#include "irmemory.h"
#include "callgraph.h"
...
...
@@ -33,6 +34,33 @@ struct ir_nodemap {
void
**
data
;
/**< maps node indices to void* */
};
typedef
struct
arch_irn_ops_t
arch_irn_ops_t
;
/**
* Operation specific callbacks.
*/
typedef
struct
{
hash_func
hash
;
/**< Calculate a hash value for an IR node. */
computed_value_func
computed_value
;
/**< Evaluates a node into a tarval if possible. */
computed_value_func
computed_value_Proj
;
/**< Evaluates a Proj node into a tarval if possible. */
equivalent_node_func
equivalent_node
;
/**< Optimizes the node by returning an equivalent one. */
equivalent_node_func
equivalent_node_Proj
;
/**< Optimizes the Proj node by returning an equivalent one. */
transform_node_func
transform_node
;
/**< Optimizes the node by transforming it. */
transform_node_func
transform_node_Proj
;
/**< Optimizes the Proj node by transforming it. */
node_cmp_attr_func
node_cmp_attr
;
/**< Compares two node attributes. */
reassociate_func
reassociate
;
/**< Reassociate a tree. */
copy_attr_func
copy_attr
;
/**< Copy node attributes. */
get_type_attr_func
get_type_attr
;
/**< Returns the type attribute of a node. */
get_entity_attr_func
get_entity_attr
;
/**< Returns the entity attribute of a node. */
verify_node_func
verify_node
;
/**< Verify the node. */
verify_proj_node_func
verify_proj_node
;
/**< Verify the Proj node. */
dump_node_func
dump_node
;
/**< Dump a node. */
op_func
generic
;
/**< A generic function pointer. */
op_func
generic1
;
/**< A generic function pointer. */
op_func
generic2
;
/**< A generic function pointer. */
const
arch_irn_ops_t
*
be_ops
;
/**< callbacks used by the backend. */
}
ir_op_ops
;
/** The type of an ir_op. */
struct
ir_op
{
unsigned
code
;
/**< The unique opcode of the op. */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment