Commit 86179505 authored by Götz Lindenmaier's avatar Götz Lindenmaier
Browse files

Added new type opcode "id".

Implemented exchange_type similarly to exchange for Ir_nodes.
Added to all type access routines skip_tid so that only real tyeps
are retruned.
the new opcode should never be visible externaly.C

[r223]
parent 5c418faf
9.7.2001 Goetz
Added some new access routines to types.
List of overwritten fields for entities.
Removed a bug in irnode.
4.7.2001 Goetz
Added a routine to set the mangled entity name.
Added two routines to copy entites.
......
......@@ -13,6 +13,7 @@
#include "irgraph_t.h"
#include "ident_t.h"
#include "irmode_t.h"
#include "typegmod_t.h"
#include "array.h"
#ifdef DEBUG_libfirm
......@@ -324,7 +325,7 @@ inline type *
get_irn_free_attr (ir_node *node)
{
assert (node->op == op_Free);
return node->attr.f;
return node->attr.f = skip_tid(node->attr.f);
}
inline symconst_attr
......@@ -338,7 +339,7 @@ inline type *
get_irn_call_attr (ir_node *node)
{
assert (node->op == op_Call);
return node->attr.call;
return node->attr.call = skip_tid(node->attr.call);
}
inline sel_attr
......@@ -603,7 +604,7 @@ 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.typ;
return node->attr.i.tori.typ = skip_tid(node->attr.i.tori.typ);
}
inline void
......@@ -785,7 +786,7 @@ set_Call_param (ir_node *node, int pos, ir_node *param) {
inline type *
get_Call_type (ir_node *node) {
assert (node->op == op_Call);
return node->attr.call;
return node->attr.call = skip_tid(node->attr.call);
}
inline void
......@@ -1590,7 +1591,7 @@ set_Alloc_size (ir_node *node, ir_node *size) {
inline type *
get_Alloc_type (ir_node *node) {
assert (node->op == op_Alloc);
return node->attr.a.type;
return node->attr.a.type = skip_tid(node->attr.a.type);
}
inline void
......@@ -1651,7 +1652,7 @@ set_Free_size (ir_node *node, ir_node *size) {
inline type *
get_Free_type (ir_node *node) {
assert (node->op == op_Free);
return node->attr.f;
return node->attr.f = skip_tid(node->attr.f);
}
inline void
......
......@@ -13,6 +13,7 @@
# include "irprog_t.h"
# include "array.h"
# include "obst.h"
# include "typegmod.h"
#define GLOBAL_TYPE_NAME "GlobalType"
......@@ -62,7 +63,7 @@ void set_irp_main_irg(ir_graph *main_irg) {
type *get_glob_type(void) {
assert(irp);
return irp->glob_type;
return irp->glob_type = skip_tid(irp->glob_type);
}
/* Adds irg to the list of ir graphs in irp. */
......@@ -107,8 +108,8 @@ int get_irp_n_types (void) {
type *get_irp_type(int pos) {
assert (irp && irp->types);
/* Strangely the first element of the array is NULL. Why?? */
return irp->types[pos+1];
/* Don't set the skip_id result so that no double entries are generated. */
return skip_id(irp->types[pos+1]);
}
void set_irp_type(int pos, type *typ) {
......@@ -116,7 +117,6 @@ void set_irp_type(int pos, type *typ) {
assert (pos < (ARR_LEN((irp)->types) - 1));
/* Strangely the first element of the array is NULL. Why?? */
irp->types[pos+1] = typ;
}
#ifdef DEBUG_libfirm
......
......@@ -10,12 +10,13 @@ srcdir = @srcdir@
topdir = ../..
subdir := ir/tr
INSTALL_HEADERS = entity.h mangle.h tpop.h type.h typewalk.h type_or_entity.h
INSTALL_HEADERS = entity.h mangle.h tpop.h type.h typewalk.h type_or_entity.h typegmod.h
SOURCES = $(INSTALL_HEADERS)
SOURCES += Makefile.in \
entity.c entity_t.h mangle.c tpop.c tpop_t.h type.c type_t.h typewalk.c
entity.c entity_t.h mangle.c tpop.c tpop_t.h type.c type_t.h \
typewalk.c typegmod.c typegmod_t.h
include $(topdir)/MakeRules
......
......@@ -118,7 +118,7 @@ void set_entity_ld_ident (entity *, ident *ld_ident);
inline type *
get_entity_owner (entity *ent) {
return ent->owner;
return ent->owner = skip_tid(ent->owner);
}
inline void
......@@ -144,7 +144,8 @@ get_entity_ld_ident (entity *ent)
return ent->ld_name;
}
void set_entity_ld_ident (entity *ent, ident *ld_ident) {
inline void
set_entity_ld_ident (entity *ent, ident *ld_ident) {
ent->ld_name = ld_ident;
}
......@@ -155,7 +156,7 @@ void set_entity_ld_name (entity *, char *ld_name);
inline type *
get_entity_type (entity *ent) {
return ent->type;
return ent->type = skip_tid(ent->type);
}
inline void
......
......@@ -118,6 +118,7 @@ void set_entity_ld_name (entity *ent, char *ld_name);
*/
type *get_entity_owner (entity *ent);
/* Sets the owner field in entity to owner. */
void set_entity_owner (entity *ent, type *owner);
inline void assert_legal_owner_of_ent(type *owner);
......
......@@ -44,6 +44,7 @@ init_tpop(void)
type_enumeration = new_tpop (tpo_enumeration, id_from_str("enumeration",11), sizeof (enm_attr));
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);
}
/* Returns the string for the tp_opcode. */
......
......@@ -35,7 +35,8 @@ typedef enum {
tpo_array,
tpo_enumeration,
tpo_pointer,
tpo_primitive
tpo_primitive,
tpo_id
} tp_opcode;
/******/
......@@ -224,4 +225,28 @@ extern tp_op *type_pointer;
extern tp_op *type_primitive;
/******/
/****d* tpop/type_id
*
* NAME
* type_id
* PURPOSE
* This type opcode is an auxiliary opcode dedicated to support transformations
* of the type structure. If a type is changed to another type with another
* opcode the new type will be allocated with new memory. All nodes refereing
* to the old type need to be changed to refer the new one. This is simplified
* by turning the old type into an id type that merely forwards to the new type
* that now replaces the old one.
* type_ids should never be visible out of the type module. All access routines
* should automatically check for type_id and eventually follow the forward in
* type_id. Two types are exchanged by a call to exchange_types.
* If a type_id is visible externally report this as bug. If it is assured that
* this never happens this extern variable can be moved to type_t.h.
* NOTES
* This struct is dynamically allocated but constant for the lifetime
* of the library.
* SOURCE
*/
extern tp_op *type_id;
/******/
# endif /*_TYPEOP_H_ */
......@@ -32,6 +32,7 @@
# include <stddef.h>
# include "type_t.h"
# include "tpop_t.h"
# include "typegmod_t.h"
# include "array.h"
/*******************************************************************/
......@@ -43,8 +44,11 @@ unsigned long type_visited;
inline type *
new_type(tp_op *type_op, ir_mode *mode, ident* name) {
type *res;
int node_size ;
int node_size = offsetof (type, attr) + type_op->attr_size;
assert(type_op != type_id);
node_size = offsetof (type, attr) + type_op->attr_size;
res = (type *) xmalloc (node_size);
add_irp_type(res); /* Remember the new type global. */
......@@ -206,7 +210,7 @@ int get_class_n_subtype (type *clss) {
}
type *get_class_subtype (type *clss, int pos) {
assert(clss && (clss->type_op == type_class));
return clss->attr.ca.subtypes[pos+1];
return clss->attr.ca.subtypes[pos+1] = skip_tid(clss->attr.ca.subtypes[pos+1]);
}
void set_class_subtype (type *clss, type *subtype, int pos) {
assert(clss && (clss->type_op == type_class));
......@@ -235,7 +239,7 @@ int get_class_n_supertype (type *clss) {
}
type *get_class_supertype (type *clss, int pos) {
assert(clss && (clss->type_op == type_class));
return clss->attr.ca.supertypes[pos+1];
return clss->attr.ca.supertypes[pos+1] = skip_tid(clss->attr.ca.supertypes[pos+1]);
}
void set_class_supertype (type *clss, type *supertype, int pos) {
assert(clss && (clss->type_op == type_class));
......@@ -326,7 +330,7 @@ int get_method_n_params (type *method) {
}
type *get_method_param_type(type *method, int pos) {
assert(method && (method->type_op == type_method));
return method->attr.ma.param_type[pos];
return method->attr.ma.param_type[pos] = skip_tid(method->attr.ma.param_type[pos]);
}
void set_method_param_type(type *method, int pos, type* type) {
assert(method && (method->type_op == type_method));
......@@ -339,7 +343,7 @@ int get_method_n_res (type *method) {
}
type *get_method_res_type(type *method, int pos) {
assert(method && (method->type_op == type_method));
return method->attr.ma.res_type[pos];
return method->attr.ma.res_type[pos] = skip_tid(method->attr.ma.res_type[pos]);
}
void set_method_res_type(type *method, int pos, type* type) {
assert(method && (method->type_op == type_method));
......@@ -374,7 +378,7 @@ int get_union_n_types (type *uni) {
}
type *get_union_unioned_type (type *uni, int pos) {
assert(uni && (uni->type_op == type_union));
return uni->attr.ua.unioned_type[pos];
return uni->attr.ua.unioned_type[pos] = skip_tid(uni->attr.ua.unioned_type[pos]);
}
void set_union_unioned_type (type *uni, int pos, type *type) {
assert(uni && (uni->type_op == type_union));
......@@ -478,7 +482,7 @@ void set_array_element_type (type *array, type *type) {
}
type *get_array_element_type (type *array) {
assert(array && (array->type_op == type_array));
return array->attr.aa.element_type;
return array->attr.aa.element_type = skip_tid(array->attr.aa.element_type);
}
void set_array_element_entity (type *array, entity *ent) {
assert(array && (array->type_op == type_array));
......@@ -561,7 +565,7 @@ void set_pointer_points_to_type (type *pointer, type *type) {
}
type *get_pointer_points_to_type (type *pointer) {
assert(pointer && (pointer->type_op == type_pointer));
return pointer->attr.pa.points_to;
return pointer->attr.pa.points_to = skip_tid(pointer->attr.pa.points_to);
}
/* typecheck */
......
......@@ -76,6 +76,12 @@ typedef struct { * No private attr yet. *
} pri_attr;
*/
/*
typedef struct { * No private attr, must be smaller than others! *
} id_attr;
*/
typedef union {
cls_attr ca;
stc_attr sa;
......@@ -108,7 +114,7 @@ struct type {
* SYNOPSIS
* type *new_type(tp_op *type_op, ir_mode *mode, ident* name);
* INPUTS
* type_op - the kind of this type
* type_op - the kind of this type. May not be type_id.
* mode - the mode to be used for this type, may be NULL
* name - an ident for the name of this type.
* RESULT
......
Supports Markdown
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