From d84d85587c94220a91b1a8db46e1797a9eeb50a5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=B6tz=20Lindenmaier?= Date: Mon, 25 Aug 2003 08:22:50 +0000 Subject: [PATCH] better name, new access routine [r1756] --- ir/tr/tpop.c | 4 ++-- ir/tr/type.c | 14 ++++++++++++++ ir/tr/type.h | 5 +++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ir/tr/tpop.c b/ir/tr/tpop.c index 0112caadc..8eeec1f14 100644 --- a/ir/tr/tpop.c +++ b/ir/tr/tpop.c @@ -55,8 +55,8 @@ init_tpop(void) type_pointer = new_tpop (tpo_pointer , id_from_str("pointer" , 7), sizeof (ptr_attr)); type_primitive = new_tpop (tpo_primitive , id_from_str("primitive" , 9), /* sizeof (pri_attr) */ 0); type_id = new_tpop (tpo_id , id_from_str("type_id" , 7), /* sizeof (id_attr) */ 0); - tpop_none = new_tpop (tpo_none , id_from_str("type_none" , 9), /* sizeof (non_attr) */ 0); - tpop_unknown = new_tpop (tpo_unknown , id_from_str("type_unknown",12), /* sizeof (ukn_attr) */ 0); + tpop_none = new_tpop (tpo_none , id_from_str("tpop_none" , 9), /* sizeof (non_attr) */ 0); + tpop_unknown = new_tpop (tpo_unknown , id_from_str("tpop_unknown",12), /* sizeof (ukn_attr) */ 0); } /* Returns the string for the tp_opcode. */ diff --git a/ir/tr/type.c b/ir/tr/type.c index f1d1e3685..ec71e0203 100644 --- a/ir/tr/type.c +++ b/ir/tr/type.c @@ -1340,6 +1340,20 @@ bool is_pointer_type (type *pointer) { if (pointer->type_op == type_pointer) return 1; else return 0; } +/* Returns the first pointer type that has as points_to tp. + * Not efficient: O(#types). + * If not found returns unknown_type. */ +type *find_pointer_type_to_type (type *tp) { + int i; + for (i = 0; i < get_irp_n_types(); ++i) { + type *found = get_irp_type(i); + if (is_pointer_type(found) && get_pointer_points_to_type(found) == tp) + return (found); + } + return unknown_type; +} + + /*******************************************************************/ /** TYPE_PRIMITIVE **/ diff --git a/ir/tr/type.h b/ir/tr/type.h index a36480096..e5db6fdb8 100644 --- a/ir/tr/type.h +++ b/ir/tr/type.h @@ -745,6 +745,11 @@ type *get_pointer_points_to_type (type *pointer); /** Returns true if a type is a pointer type. */ bool is_pointer_type (type *pointer); +/** Returns the first pointer type that has as points_to tp. + * Not efficient: O(#types). + * If not found returns unknown_type. */ +type *find_pointer_type_to_type (type *tp); + /** * @page primitive_type Representation of a primitive type * -- 2.20.1