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
b8f363d7
Commit
b8f363d7
authored
Jul 06, 2004
by
Beyhan
Browse files
new SymConst semantics
[r3313]
parent
3619d43b
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
ir/ana/cgana.c
View file @
b8f363d7
...
...
@@ -85,6 +85,9 @@ static entity *get_inherited_methods_implementation(entity *inh_meth) {
if
(
get_irn_op
(
addr
)
==
op_Const
)
{
impl_meth
=
tarval_to_entity
(
get_Const_tarval
(
addr
));
}
else
if
((
get_irn_op
(
addr
)
==
op_SymConst
)
&&
(
get_SymConst_kind
(
addr
)
==
symconst_addr_ent
))
{
impl_meth
=
get_SymConst_entity
(
addr
);
}
else
{
assert
(
0
&&
"Complex constant values not supported -- address of method should be straight constant!"
);
}
...
...
@@ -222,19 +225,20 @@ static void sel_methods_walker(ir_node * node, pmap * ldname_map) {
if
(
get_irn_op
(
node
)
==
op_SymConst
)
{
/* Wenn mglich SymConst-Operation durch Const-Operation
* ersetzen. */
if
(
get_SymConst_kind
(
node
)
==
linkage_ptr_info
)
{
pmap_entry
*
entry
=
pmap_find
(
ldname_map
,
(
void
*
)
get_SymConst_
ptrinfo
(
node
));
if
(
get_SymConst_kind
(
node
)
==
symconst_addr_name
)
{
pmap_entry
*
entry
=
pmap_find
(
ldname_map
,
(
void
*
)
get_SymConst_
name
(
node
));
if
(
entry
!=
NULL
)
{
/* Method is declared in the compiled code */
entity
*
ent
=
entry
->
value
;
if
(
get_opt_normalize
()
&&
(
get_entity_visibility
(
ent
)
!=
visibility_external_allocated
))
{
/* Meth. is defined */
ir_node
*
new_node
;
assert
(
get_entity_irg
(
ent
));
set_irg_current_block
(
current_ir_graph
,
get_nodes_Block
(
node
));
new_node
=
new_d_Const
(
get_irn_dbg_info
(
node
),
mode_P_mach
,
new_tarval_from_entity
(
ent
,
mode_P_mach
));
DBG_OPT_NORMALIZE
;
exchange
(
node
,
new_node
);
}
entity
*
ent
=
entry
->
value
;
if
(
get_opt_normalize
()
&&
(
get_entity_visibility
(
ent
)
!=
visibility_external_allocated
))
{
/* Meth. is defined */
ir_node
*
new_node
;
symconst_symbol
sym
;
assert
(
get_entity_irg
(
ent
));
sym
.
entity_p
=
ent
;
set_irg_current_block
(
current_ir_graph
,
get_nodes_Block
(
node
));
new_node
=
new_d_SymConst
(
get_irn_dbg_info
(
node
),
sym
,
symconst_addr_ent
);
DBG_OPT_NORMALIZE
;
DDMN
(
new_node
);
exchange
(
node
,
new_node
);
}
}
}
}
else
if
(
get_irn_op
(
node
)
==
op_Sel
&&
...
...
@@ -454,8 +458,20 @@ static void callee_ana_node(ir_node * node, eset * methods) {
switch
(
get_irn_opcode
(
node
))
{
case
iro_SymConst
:
/* externe Methode (wegen fix_symconst!) */
eset_insert
(
methods
,
MARK
);
/* free method -> unknown */
if
(
get_SymConst_kind
(
node
)
==
symconst_addr_ent
)
{
entity
*
ent
=
get_SymConst_entity
(
node
);
assert
(
ent
&&
is_method_type
(
get_entity_type
(
ent
)));
if
(
get_entity_visibility
(
ent
)
!=
visibility_external_allocated
)
{
assert
(
get_entity_irg
(
ent
));
eset_insert
(
methods
,
ent
);
}
else
{
eset_insert
(
methods
,
MARK
);
/* free method -> unknown */
}
}
else
{
assert
(
get_SymConst_kind
(
node
)
==
symconst_addr_name
);
/* externe Methode (wegen fix_symconst!) */
eset_insert
(
methods
,
MARK
);
/* free method -> unknown */
}
break
;
case
iro_Const
:
{
...
...
@@ -641,7 +657,15 @@ static void free_mark(ir_node * node, eset * set) {
break
;
}
case
iro_SymConst
:
/* nothing: SymConst points to extern method */
if
(
get_SymConst_kind
(
node
)
==
symconst_addr_ent
)
{
entity
*
ent
=
get_SymConst_entity
(
node
);
if
(
is_method_type
(
get_entity_type
(
ent
)))
{
eset_insert
(
set
,
ent
);
}
}
else
{
assert
(
get_SymConst_kind
(
node
)
==
symconst_addr_name
);
/* nothing: SymConst points to extern method */
}
break
;
case
iro_Const
:
{
tarval
*
val
=
get_Const_tarval
(
node
);
...
...
@@ -696,7 +720,7 @@ static void free_ana_walker(ir_node * node, eset * set) {
for
(
i
=
get_Call_arity
(
node
)
-
1
;
i
>=
0
;
--
i
)
{
ir_node
*
pred
=
get_Call_param
(
node
,
i
);
if
(
mode_is_reference
(
get_irn_mode
(
pred
)))
{
free_mark
(
pred
,
set
);
free_mark
(
pred
,
set
);
}
}
break
;
...
...
ir/ana/rta.c
View file @
b8f363d7
...
...
@@ -166,9 +166,23 @@ static void rta_act (ir_node *node, void *env)
/* it's an externally allocated thing. */
}
}
else
if
(
iro_SymConst
==
get_irn_opcode
(
ptr
))
{
/* CALL SYMCONST */
if
(
get_SymConst_kind
(
ptr
)
==
symconst_addr_ent
)
{
ent
=
get_SymConst_entity
(
ptr
);
ir_graph
*
graph
=
get_entity_irg
(
ent
);
/* don't use get_implementing_graph on a Const! */
if
(
graph
)
{
*
change
=
add_graph
(
graph
);
}
else
{
/* it's an externally allocated thing. */
}
}
else
if
(
get_SymConst_kind
(
ptr
)
==
symconst_addr_name
)
{
/* If this SymConst refers to a method the method is external_visible
and therefore must be considered live anyways. */
/* assert (ent && "couldn't determine entity of call to symConst"); */
}
else
{
/* other symconst. */
}
}
}
else
if
(
iro_Alloc
==
op
)
{
/* ALLOC */
type
*
type
=
get_Alloc_type
(
node
);
...
...
@@ -298,8 +312,7 @@ static void force_description (entity *ent, entity *addr)
if
(
peculiarity_inherited
==
get_entity_peculiarity
(
over
))
{
/* We rely on the fact that cse is performed on the const_code_irg. */
entity
*
my_addr
=
tarval_to_entity
(
get_Const_tarval
(
get_atomic_ent_value
(
over
)));
entity
*
my_addr
=
get_SymConst_entity
(
get_atomic_ent_value
(
over
));
if
(
addr
==
my_addr
)
{
force_description
(
over
,
addr
);
...
...
@@ -307,9 +320,9 @@ static void force_description (entity *ent, entity *addr)
}
else
if
(
peculiarity_existent
==
get_entity_peculiarity
(
over
))
{
/* check whether 'over' forces 'inheritance' of *our* graph: */
ir_node
*
f_addr
=
get_atomic_ent_value
(
over
);
entity
*
impl_ent
=
tarval_to_entity
(
get_Const_
tarval
(
f_addr
)
)
;
entity
*
impl_ent
=
get_
Sym
Const_
entity
(
f_addr
);
assert
((
get_irn_op
(
f_addr
)
==
op_Const
)
&&
"can't do complex addrs"
);
assert
((
get_irn_op
(
f_addr
)
==
op_
Sym
Const
)
&&
"can't do complex addrs"
);
if
(
impl_ent
==
addr
)
{
assert
(
0
&&
"gibt's denn sowas"
);
force_description
(
over
,
addr
);
...
...
@@ -531,6 +544,9 @@ void rta_report (void)
/*
* $Log$
* Revision 1.19 2004/07/06 12:30:37 beyhan
* new SymConst semantics
*
* Revision 1.18 2004/06/27 21:17:41 liekweg
* Added comment
*
...
...
ir/common/firm.h
View file @
b8f363d7
...
...
@@ -107,9 +107,15 @@ extern "C" {
/**
* Initialize the firm library.
*
* @param func This function is called, whenever a local variable is used before definition
* Initializes the firm library. Allocates default data structures.
* Initializes configurable behaviour of the library.
*
* The parameter func may be NULL. In that case, the old FIRM behavior is conserved.
* @param func This function is called, whenever a local variable is
* used before definition. The function should either insert a default value,
* or raise a compiler error.
*
* The parameter func may be NULL. In that case, the original FIRM behavior
* is conserved.
*
* @see default_initialize_local_variable_func_t
*/
...
...
ir/ir/ircons.c
View file @
b8f363d7
...
...
@@ -679,26 +679,31 @@ new_rd_InstOf (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
}
INLINE
ir_node
*
new_rd_SymConst
(
dbg_info
*
db
,
ir_graph
*
irg
,
ir_node
*
block
,
type_or_id_p
value
,
symconst_kind
symkind
)
new_rd_SymConst
(
dbg_info
*
db
,
ir_graph
*
irg
,
ir_node
*
block
,
symconst_symbol
value
,
symconst_kind
symkind
)
{
ir_node
*
res
;
ir_mode
*
mode
;
if
(
symkind
==
linkage_ptr_info
)
if
(
(
symkind
==
symconst_addr_name
)
||
(
symkind
==
symconst_addr_ent
)
)
mode
=
mode_P_mach
;
else
mode
=
mode_Iu
;
res
=
new_ir_node
(
db
,
irg
,
block
,
op_SymConst
,
mode
,
0
,
NULL
);
res
->
attr
.
i
.
num
=
symkind
;
if
(
symkind
==
linkage_ptr_info
)
{
res
->
attr
.
i
.
tori
.
ptrinfo
=
(
ident
*
)
value
;
res
->
attr
.
i
.
sym
=
value
;
/*
if (symkind == symconst_addr_name) {
res->attr.i.sym.ident_p = (ident *)value;
} else if (symkind == symconst_addr_ent) {
res->attr.i.sym.entity = (entity *)value;
} else {
assert
(
(
(
symkind
==
type_tag
)
||
(
symkind
==
size
))
assert ( ( (symkind ==
symconst_
type_tag)
|| (symkind ==
symconst_
size))
&& (is_type(value)));
res
->
attr
.
i
.
tori
.
typ
=
(
type
*
)
value
;
res->attr.i.
sym
.typ = (type *)value;
}
*/
res
=
optimize_node
(
res
);
irn_vrfy_irg
(
res
,
irg
);
return
res
;
...
...
@@ -867,7 +872,7 @@ INLINE ir_node *new_r_Const (ir_graph *irg, ir_node *block,
return
new_rd_Const
(
NULL
,
irg
,
block
,
mode
,
con
);
}
INLINE
ir_node
*
new_r_SymConst
(
ir_graph
*
irg
,
ir_node
*
block
,
type_or_id_p
value
,
symconst_kind
symkind
)
{
symconst_symbol
value
,
symconst_kind
symkind
)
{
return
new_rd_SymConst
(
NULL
,
irg
,
block
,
value
,
symkind
);
}
INLINE
ir_node
*
new_r_Sel
(
ir_graph
*
irg
,
ir_node
*
block
,
ir_node
*
store
,
...
...
@@ -2238,7 +2243,7 @@ new_d_InstOf (dbg_info *db, ir_node *store, ir_node *objptr, type *ent)
}
ir_node
*
new_d_SymConst
(
dbg_info
*
db
,
type_or_id_p
value
,
symconst_kind
kind
)
new_d_SymConst
(
dbg_info
*
db
,
symconst_symbol
value
,
symconst_kind
kind
)
{
return
new_rd_SymConst
(
db
,
current_ir_graph
,
current_ir_graph
->
start_block
,
value
,
kind
);
...
...
@@ -2485,7 +2490,7 @@ ir_node *new_Raise (ir_node *store, ir_node *obj) {
ir_node
*
new_Const
(
ir_mode
*
mode
,
tarval
*
con
)
{
return
new_d_Const
(
NULL
,
mode
,
con
);
}
ir_node
*
new_SymConst
(
type_or_id_p
value
,
symconst_kind
kind
)
{
ir_node
*
new_SymConst
(
symconst_symbol
value
,
symconst_kind
kind
)
{
return
new_d_SymConst
(
NULL
,
value
,
kind
);
}
ir_node
*
new_simpleSel
(
ir_node
*
store
,
ir_node
*
objptr
,
entity
*
ent
)
{
...
...
ir/ir/ircons.h
View file @
b8f363d7
This diff is collapsed.
Click to expand it.
ir/ir/irdump.c
View file @
b8f363d7
...
...
@@ -452,14 +452,18 @@ dump_node_opcode(FILE *F, ir_node *n)
}
break
;
case
iro_SymConst
:
{
if
(
get_SymConst_kind
(
n
)
==
linkage_ptr_info
)
{
if
(
get_SymConst_kind
(
n
)
==
symconst_addr_name
)
{
/* don't use get_SymConst_ptr_info as it mangles the name. */
fprintf
(
F
,
"SymC %s"
,
get_id_str
(
get_SymConst_ptrinfo
(
n
)));
fprintf
(
F
,
"SymC %s"
,
get_id_str
(
get_SymConst_name
(
n
)));
}
else
if
(
get_SymConst_kind
(
n
)
==
symconst_addr_ent
)
{
assert
(
get_SymConst_entity
(
n
));
assert
(
is_entity
(
get_SymConst_entity
(
n
)));
fprintf
(
F
,
"SymC &%s"
,
get_entity_name
(
get_SymConst_entity
(
n
)));
}
else
{
assert
(
get_kind
(
get_SymConst_type
(
n
))
==
k_type
);
assert
(
get_type_ident
(
get_SymConst_type
(
n
)));
fprintf
(
F
,
"SymC %s "
,
get_type_name_ex
(
get_SymConst_type
(
n
),
&
bad
));
if
(
get_SymConst_kind
(
n
)
==
type_tag
)
if
(
get_SymConst_kind
(
n
)
==
symconst_
type_tag
)
fprintf
(
F
,
"tag"
);
else
fprintf
(
F
,
"size"
);
...
...
@@ -626,6 +630,7 @@ static INLINE int dump_node_info(ir_node *n)
fprintf
(
F
,
" info1:
\"
"
);
if
(
opt_dump_pointer_values_to_info
)
fprintf
(
F
,
"addr: %p
\n
"
,
(
void
*
)
n
);
fprintf
(
F
,
"mode: %s
\n
"
,
get_mode_name
(
get_irn_mode
(
n
)));
fprintf
(
F
,
"visited: %ld
\n
"
,
get_irn_visited
(
n
));
irg
=
get_irn_irg
(
n
);
if
(
irg
!=
get_const_code_irg
())
...
...
@@ -1159,8 +1164,8 @@ static void dump_node2type_edges (ir_node *n, void *env)
/* @@@ some consts have an entity */
break
;
case
iro_SymConst
:
if
(
(
get_SymConst_kind
(
n
)
==
type_tag
)
||
(
get_SymConst_kind
(
n
)
==
size
))
if
(
(
get_SymConst_kind
(
n
)
==
symconst_
type_tag
)
||
(
get_SymConst_kind
(
n
)
==
symconst_
size
))
{
print_node_type_edge
(
F
,
n
,
get_SymConst_type
(
n
),
NODE2TYPE_EDGE_ATTR
);
}
...
...
ir/ir/irgopt.h
View file @
b8f363d7
...
...
@@ -23,7 +23,9 @@
# include "irgraph.h"
/** Applies local optimizations (see iropt.h) to all nodes in the graph. */
/** Applies local optimizations (see iropt.h) to all nodes in the graph.
*
* @param irg The graph to be optimized. */
void
local_optimize_graph
(
ir_graph
*
irg
);
/** Performs dead node elimination by copying the ir graph to a new obstack.
...
...
@@ -43,14 +45,19 @@ void local_optimize_graph (ir_graph *irg);
* Callee information must be freed (irg_callee_info_none).
*
* Attention: the numbers assigned to nodes if the library is compiled for
* development/debugging are not conserved by copying. */
* development/debugging are not conserved by copying.
*
* @param irg The graph to be optimized. */
void
dead_node_elimination
(
ir_graph
*
irg
);
/** Removes Bad Bad predecesors from Blocks and the corresponding
inputs to Phi nodes as in dead_node_elimination but without
copying the graph.
@todo not implemented! / buggy? */
/** Cleans the control flow from Bad predecesors.
*
* Removes Bad predecesors from Blocks and the corresponding
* inputs to Phi nodes as in dead_node_elimination but without
* copying the graph.
*
* @param irg The graph to be optimized.
*/
void
remove_bad_predecessors
(
ir_graph
*
irg
);
/** Inlines a method at the given call site.
...
...
ir/ir/irgraph.h
View file @
b8f363d7
...
...
@@ -75,9 +75,10 @@ typedef struct ir_graph ir_graph;
* did actually change something). Code placement is necessary.
*/
/** Global variable holding the current IR-graph.
* This global variable is used by the ir construction
* interface in ircons and by the optimizations.
/** Global variable holding the current ir graph.
*
* This global variable is used by the ir construction
* interface in ircons and by the optimizations.
*/
extern
ir_graph
*
current_ir_graph
;
...
...
ir/ir/irnode.c
View file @
b8f363d7
...
...
@@ -80,7 +80,7 @@ const char *pns_name_arr [] = {
};
const
char
*
symconst_name_arr
[]
=
{
"type_tag"
,
"size"
,
"
linkage_ptr_info
"
"type_tag"
,
"size"
,
"
addr_name"
,
"addr_ent
"
};
void
...
...
@@ -893,43 +893,59 @@ set_SymConst_kind (ir_node *node, symconst_kind num) {
type
*
get_SymConst_type
(
ir_node
*
node
)
{
assert
(
(
node
->
op
==
op_SymConst
)
&&
(
get_SymConst_kind
(
node
)
==
type_tag
||
get_SymConst_kind
(
node
)
==
size
));
return
node
->
attr
.
i
.
tori
.
ty
p
=
skip_tid
(
node
->
attr
.
i
.
tori
.
ty
p
);
&&
(
get_SymConst_kind
(
node
)
==
symconst_
type_tag
||
get_SymConst_kind
(
node
)
==
symconst_
size
));
return
node
->
attr
.
i
.
sym
.
type_
p
=
skip_tid
(
node
->
attr
.
i
.
sym
.
type_
p
);
}
void
set_SymConst_type
(
ir_node
*
node
,
type
*
tp
)
{
assert
(
(
node
->
op
==
op_SymConst
)
&&
(
get_SymConst_kind
(
node
)
==
type_tag
||
get_SymConst_kind
(
node
)
==
size
));
node
->
attr
.
i
.
tori
.
ty
p
=
tp
;
&&
(
get_SymConst_kind
(
node
)
==
symconst_
type_tag
||
get_SymConst_kind
(
node
)
==
symconst_
size
));
node
->
attr
.
i
.
sym
.
type_
p
=
tp
;
}
ident
*
get_SymConst_
ptrinfo
(
ir_node
*
node
)
{
get_SymConst_
name
(
ir_node
*
node
)
{
assert
(
(
node
->
op
==
op_SymConst
)
&&
(
get_SymConst_kind
(
node
)
==
linkage_ptr_info
));
return
node
->
attr
.
i
.
tori
.
ptrinfo
;
&&
(
get_SymConst_kind
(
node
)
==
symconst_addr_name
));
return
node
->
attr
.
i
.
sym
.
ident_p
;
}
void
set_SymConst_
ptrinfo
(
ir_node
*
node
,
ident
*
ptrinfo
)
{
set_SymConst_
name
(
ir_node
*
node
,
ident
*
name
)
{
assert
(
(
node
->
op
==
op_SymConst
)
&&
(
get_SymConst_kind
(
node
)
==
linkage_ptr_info
));
node
->
attr
.
i
.
tori
.
ptrinfo
=
ptrinfo
;
&&
(
get_SymConst_kind
(
node
)
==
symconst_addr_name
));
node
->
attr
.
i
.
sym
.
ident_p
=
name
;
}
type_or_id_p
/* Only to access SymConst of kind symconst_addr_ent. Else assertion: */
entity
*
get_SymConst_entity
(
ir_node
*
node
)
{
assert
(
(
node
->
op
==
op_SymConst
)
&&
(
get_SymConst_kind
(
node
)
==
symconst_addr_ent
));
return
node
->
attr
.
i
.
sym
.
entity_p
;
}
void
set_SymConst_entity
(
ir_node
*
node
,
entity
*
ent
)
{
assert
(
(
node
->
op
==
op_SymConst
)
&&
(
get_SymConst_kind
(
node
)
==
symconst_addr_ent
));
node
->
attr
.
i
.
sym
.
entity_p
=
ent
;
}
symconst_symbol
get_SymConst_type_or_id
(
ir_node
*
node
)
{
assert
(
node
->
op
==
op_SymConst
);
return
&
(
node
->
attr
.
i
.
tori
)
;
return
node
->
attr
.
i
.
sym
;
}
void
set_SymConst_type_or_id
(
ir_node
*
node
,
type_or_id_p
tori
)
{
set_SymConst_type_or_id
(
ir_node
*
node
,
symconst_symbol
sym
)
{
assert
(
node
->
op
==
op_SymConst
);
memcpy
(
&
(
node
->
attr
.
i
.
tori
),
tori
,
sizeof
(
type_or_id
));
//memcpy (&(node->attr.i.sym), sym, sizeof(type_or_id));
node
->
attr
.
i
.
sym
=
sym
;
}
ir_node
*
...
...
ir/ir/irnode.h
View file @
b8f363d7
...
...
@@ -391,31 +391,60 @@ void set_Const_type (ir_node *node, type *tp);
represented by SymConst. The content of the attribute type_or_id
depends on this tag. Use the proper access routine after testing
this flag. */
#define type_tag symconst_type_tag
//#define size symconst_size geht nicht, benennt auf size in type.c um!
#define linkage_ptr_info symconst_addr_name
typedef
enum
{
type_tag
,
/**< The SymConst is a type tag for the given type.
Type_or_id_p is type *. */
size
,
/**< The SymConst is the size of the given type.
Type_or_id_p is type *. */
linkage_ptr_info
/**< The SymConst is a symbolic pointer to be filled in
by the linker. Type_or_id_p is ident *. If the name
refers to an entity also compiled, this entity must be external_visible,
so that it is not removed by some optimization. An optimization must
not analyse linkage_ptr_info SymConsts. */
symconst_type_tag
,
/**< The SymConst is a type tag for the given type.
Type_or_id_p is type *. */
symconst_size
,
/**< The SymConst is the size of the given type.
Type_or_id_p is type *. */
symconst_addr_name
,
/**< The SymConst is a symbolic pointer to be filled in
by the linker. The pointer is represented by a string.
Type_or_id_p is ident *. */
symconst_addr_ent
/**< The SymConst is a symbolic pointer to be filled in
by the linker. The pointer is represented by an entity.
Type_or_id_p is entity *. */
}
symconst_kind
;
typedef
union
type_or_id
*
type_or_id_p
;
/** SymConst attributes
This union contains the symbolic information represented by the node */
union
symconst_symbol
{
type
*
type_p
;
//old typ
ident
*
ident_p
;
// old ptrinfo
entity
*
entity_p
;
// entity_p
};
typedef
union
symconst_symbol
symconst_symbol
;
/** Access the kind of the SymConst. */
symconst_kind
get_SymConst_kind
(
const
ir_node
*
node
);
void
set_SymConst_kind
(
ir_node
*
node
,
symconst_kind
num
);
/* Only to access SymConst of kind type_tag or size. Else assertion: */
/** Only to access SymConst of kind type_tag or size. Else assertion: */
type
*
get_SymConst_type
(
ir_node
*
node
);
void
set_SymConst_type
(
ir_node
*
node
,
type
*
tp
);
/* Only to access SymConst of kind linkage_ptr_info. Else assertion: */
/** Only to access SymConst of kind addr_name. Else assertion: */
/* old:
ident *get_SymConst_ptrinfo (ir_node *node);
void set_SymConst_ptrinfo (ir_node *node, ident *ptrinfo);
/* Sets both: type and ptrinfo. Needed to treat the node independent of
its semantics. Does a memcpy for the memory tori points to. */
type_or_id_p
get_SymConst_type_or_id
(
ir_node
*
node
);
void
set_SymConst_type_or_id
(
ir_node
*
node
,
type_or_id_p
tori
);
*/
#define get_SymConst_ptrinfo get_SymConst_name
#define set_SymConst_ptrinfo set_SymConst_name
ident
*
get_SymConst_name
(
ir_node
*
node
);
void
set_SymConst_name
(
ir_node
*
node
,
ident
*
name
);
/** Only to access SymConst of kind addr_ent. Else assertion: */
entity
*
get_SymConst_entity
(
ir_node
*
node
);
void
set_SymConst_entity
(
ir_node
*
node
,
entity
*
ent
);
/** Sets both: type and ptrinfo. Needed to treat the node independent of
its semantics. Does a memcpy for the memory sym points to. */
#define get_SymConst_type_or_id get_SymConst_symbol
#define set_SymConst_type_or_id set_SymConst_symbol
symconst_symbol
get_SymConst_symbol
(
ir_node
*
node
);
void
set_SymConst_symbol
(
ir_node
*
node
,
symconst_symbol
sym
);
ir_node
*
get_Sel_mem
(
ir_node
*
node
);
void
set_Sel_mem
(
ir_node
*
node
,
ir_node
*
mem
);
...
...
ir/ir/irnode_t.h
View file @
b8f363d7
...
...
@@ -39,6 +39,10 @@
# include "exc.h"
#include "set.h"
#include "entity_t.h"
#include "type_t.h"
/** ir node attributes **/
/** Block attributes */
...
...
@@ -85,15 +89,8 @@ typedef struct {
type
*
tp
;
/**< the source type, for analyses. default: type_unknown. */
}
const_attr
;
/** SymConst attributes
This union contains the symbolic information represented by the node */
typedef
union
type_or_id
{
type
*
typ
;
ident
*
ptrinfo
;
}
type_or_id
;
typedef
struct
{
type_or_i
d
tori
;
symconst_symbol
sym
;
// ol
d tori
symconst_kind
num
;
}
symconst_attr
;
...
...
@@ -170,7 +167,7 @@ typedef union {
callbegin_attr
callbegin
;
/**< For CallBegin */
alloc_attr
a
;
/**< For Alloc. */
io_attr
io
;
/**< For InstOf */
type
*
f
;
/**< For Free. */
type
*
f
;
/**< For Free. */
cast_attr
cast
;
/**< For Cast. */
int
phi0_pos
;
/**< For Phi. Used to remember the value defined by
this Phi node. Needed when the Phi is completed
...
...
ir/ir/iropt.c
View file @
b8f363d7
...
...
@@ -60,7 +60,7 @@ static tarval *computed_value_Const(ir_node *n)
static
tarval
*
computed_value_SymConst
(
ir_node
*
n
)
{
if
((
get_SymConst_kind
(
n
)
==
size
)
&&
if
((
get_SymConst_kind
(
n
)
==
symconst_
size
)
&&
(
get_type_state
(
get_SymConst_type
(
n
)))
==
layout_fixed
)
return
new_tarval_from_long
(
get_type_size_bytes
(
get_SymConst_type
(
n
)),
mode_Is
);
return
tarval_bad
;
...
...
@@ -1376,7 +1376,7 @@ static int node_cmp_attr_Free(ir_node *a, ir_node *b)
static
int
node_cmp_attr_SymConst
(
ir_node
*
a
,
ir_node
*
b
)
{
return
(
get_irn_symconst_attr
(
a
).
num
!=
get_irn_symconst_attr
(
b
).
num
)
||
(
get_irn_symconst_attr
(
a
).
tori
.
ty
p
!=
get_irn_symconst_attr
(
b
).
tori
.
ty
p
);
||
(
get_irn_symconst_attr
(
a
).
sym
.
type_
p
!=
get_irn_symconst_attr
(
b
).
sym
.
type_
p
);
}
static
int
node_cmp_attr_Call
(
ir_node
*
a
,
ir_node
*
b
)
...
...
ir/tr/entity.c
View file @
b8f363d7
...
...
@@ -82,10 +82,12 @@ new_entity (type *owner, ident *name, type *type)
res
->
visibility
=
visibility_local
;
res
->
offset
=
-
1
;
if
(
is_method_type
(
type
))
{
symconst_symbol
sym
;
sym
.
entity_p
=
res
;
res
->
variability
=
variability_constant
;
rem
=
current_ir_graph
;
current_ir_graph
=
get_const_code_irg
();
res
->
value
=
new_Const
(
mode_P_mach
,
new_tarval_from_entity
(
res
,
mode_P_mach
)
);
res
->
value
=
new_
Sym
Const
(
sym
,
symconst_addr_ent
);
current_ir_graph
=
rem
;
}
else
{
res
->
variability
=
variability_uninitialized
;
...
...
@@ -488,7 +490,9 @@ ir_node *copy_const_value(ir_node *n) {
case
iro_Const
:
nn
=
new_Const
(
m
,
get_Const_tarval
(
n
));
break
;
case
iro_SymConst
:
nn
=
new_SymConst
(
get_SymConst_type_or_id
(
n
),
get_SymConst_kind
(
n
));
break
;
nn
=
new_SymConst
(
get_SymConst_type_or_id
(
n
),
get_SymConst_kind
(
n
));
break
;
case
iro_Add
:
nn
=
new_Add
(
copy_const_value
(
get_Add_left
(
n
)),
copy_const_value
(
get_Add_right
(
n
)),
m
);
break
;
...
...
ir/tr/typewalk.c
View file @
b8f363d7
...
...
@@ -165,8 +165,8 @@ static void start_type_walk(ir_node *node, void *env) {
switch
(
get_irn_opcode
(
node
))
{
/* node label */
case
iro_SymConst
:
if
(
(
get_SymConst_kind
(
node
)
==
type_tag
)
||
(
get_SymConst_kind
(
node
)
==
size
))
if
(
(
get_SymConst_kind
(
node
)
==
symconst_
type_tag
)
||
(
get_SymConst_kind
(
node
)
==
symconst_
size
))
type_walk_2
((
type_or_ent
*
)
get_SymConst_type
(
node
),
pre
,
post
,
envi
);
break
;
case
iro_Sel
:
...
...
ir/tv/tv.c
View file @
b8f363d7
...
...
@@ -404,7 +404,9 @@ long double tarval_to_double(tarval *tv)
}
/* The tarval represents the address of the entity. As the address must
be constant the entity must have as owner the global type. */
be constant the entity must have as owner the global type.
* We no more support this function: Use the new SymConst instead.
*/
tarval
*
new_tarval_from_entity
(
entity
*
ent
,
ir_mode
*
mode
)
{
ANNOUNCE
();
...
...
@@ -413,6 +415,8 @@ tarval *new_tarval_from_entity (entity *ent, ir_mode *mode)
return
get_tarval
((
void
*
)
ent
,
0
,
mode
);
}
int
tarval_is_entity
(
tarval
*
tv
)
{
ANNOUNCE
();
...
...
@@ -1470,32 +1474,32 @@ int tarval_snprintf(char *buf, size_t len, tarval *tv)
break
;
case
irms_reference
:
if
(
tv
==
tarval_P_void
)
return
snprintf
(
buf
,
len
,
"NULL"
);
if
(
tv
==
tarval_P_void
)
return
snprintf
(
buf
,
len
,
"NULL"
);
if
(
tv
->
value
!=
NULL
)
if
(
tarval_is_entity
(
tv
))
{
if
(
get_entity_peculiarity
((
entity
*
)
tv
->
value
)
!=
peculiarity_description
)
return
snprintf
(
buf
,
len
,
"%s%s%s"
,
prefix
,
get_entity_ld_name
((
entity
*
)
tv
->
value
),
suffix
);
else
{
if
(
mode_info
->
mode_output
==
TVO_NATIVE
)
return
snprintf
(
buf
,
len
,
"NULL"
);
else
return
snprintf
(
buf
,
len
,
"0"
);
}