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
612d040e
Commit
612d040e
authored
Feb 23, 2005
by
Götz Lindenmaier
Browse files
cast access routines
[r5218]
parent
5cf3f413
Changes
2
Hide whitespace changes
Inline
Side-by-side
ir/ir/irnode.c
View file @
612d040e
...
...
@@ -1357,6 +1357,52 @@ set_Cast_type (ir_node *node, type *to_tp) {
node
->
attr
.
cast
.
totype
=
to_tp
;
}
/* Checks for upcast.
*
* Returns true if the Cast node casts a class type to a super type.
*/
int
is_Cast_upcast
(
ir_node
*
node
)
{
type
*
totype
=
get_Cast_type
(
node
);
type
*
fromtype
=
get_irn_typeinfo_type
(
get_Cast_op
(
node
));
ir_graph
*
myirg
=
get_irn_irg
(
node
);
assert
(
get_irg_typeinfo_state
(
myirg
)
==
ir_typeinfo_consistent
);
assert
(
fromtype
);
while
(
is_Pointer_type
(
totype
)
&&
is_Pointer_type
(
fromtype
))
{
totype
=
get_pointer_points_to_type
(
totype
);
fromtype
=
get_pointer_points_to_type
(
fromtype
);
}
assert
(
fromtype
);
if
(
!
is_Class_type
(
totype
))
return
false
;
return
is_subclass_of
(
fromtype
,
totype
);
}
/* Checks for downcast.
*
* Returns true if the Cast node casts a class type to a sub type.
*/
int
is_Cast_downcast
(
ir_node
*
node
)
{
type
*
totype
=
get_Cast_type
(
node
);
type
*
fromtype
=
get_irn_typeinfo_type
(
get_Cast_op
(
node
));
assert
(
get_irg_typeinfo_state
(
get_irn_irg
(
node
))
==
ir_typeinfo_consistent
);
assert
(
fromtype
);
while
(
is_Pointer_type
(
totype
)
&&
is_Pointer_type
(
fromtype
))
{
totype
=
get_pointer_points_to_type
(
totype
);
fromtype
=
get_pointer_points_to_type
(
fromtype
);
}
assert
(
fromtype
);
if
(
!
is_Class_type
(
totype
))
return
false
;
return
is_subclass_of
(
totype
,
fromtype
);
}
int
(
is_unop
)(
const
ir_node
*
node
)
{
return
_is_unop
(
node
);
...
...
ir/ir/irnode.h
View file @
612d040e
...
...
@@ -246,6 +246,9 @@ ir_node *get_Block_cfgpred (ir_node *node, int pos);
void
set_Block_cfgpred
(
ir_node
*
node
,
int
pos
,
ir_node
*
pred
);
bool
get_Block_matured
(
ir_node
*
node
);
void
set_Block_matured
(
ir_node
*
node
,
bool
matured
);
/** A visited flag only for block nodes.
* @see also: get_irn_visited() inc_irg_visited() inc_irg_block_visited()*/
unsigned
long
get_Block_block_visited
(
ir_node
*
node
);
void
set_Block_block_visited
(
ir_node
*
node
,
unsigned
long
visit
);
ir_node
*
set_Block_dead
(
ir_node
*
block
);
...
...
@@ -701,6 +704,21 @@ void set_Cast_op (ir_node *node, ir_node *op);
type
*
get_Cast_type
(
ir_node
*
node
);
void
set_Cast_type
(
ir_node
*
node
,
type
*
to_tp
);
/** Checks for upcast.
*
* Returns true if the Cast node casts a class type to a super type.
* Works also for pointers to classes (recursively).
*/
int
is_Cast_upcast
(
ir_node
*
node
);
/** Checks for downcast.
*
* Returns true if the Cast node casts a class type to a sub type.
* Works also for pointers to classes (recursively).
*/
int
is_Cast_downcast
(
ir_node
*
node
);
/** Returns true if n is Phi or Filter in interprocedural_view.
Returns false if irg in phase building and the Phi has zero
predecessors: it's a Phi0. */
...
...
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