added vtable size attribute to class types
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Fri, 19 May 2006 15:15:41 +0000 (15:15 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Fri, 19 May 2006 15:15:41 +0000 (15:15 +0000)
added vtable number to method entities

[r7786]

ir/tr/entity.c
ir/tr/entity.h
ir/tr/type.c
ir/tr/type.h
ir/tr/type_t.h

index c1761a7..42e5424 100644 (file)
@@ -1252,7 +1252,7 @@ ir_graph *
 
 void
 set_entity_irg(entity *ent, ir_graph *irg) {
-  assert(ent && is_Method_type(get_entity_type(ent)));
+  assert(ent && is_method_entity(ent));
   /* Wie kann man die Referenz auf einen IRG löschen, z.B. wenn die
    * Methode selbst nicht mehr aufgerufen werden kann, die Entität
    * aber erhalten bleiben soll?  Wandle die Entitaet in description oder
@@ -1266,6 +1266,16 @@ set_entity_irg(entity *ent, ir_graph *irg) {
   ent->attr.mtd_attr.irg = irg;
 }
 
+unsigned get_entity_vtable_number(entity *ent) {
+  assert(ent && is_method_entity(ent));
+  return ent->attr.mtd_attr.vtable_number;
+}
+
+void set_entity_vtable_number(entity *ent, unsigned vtable_number) {
+  assert(ent && is_method_entity(ent));
+  ent->attr.mtd_attr.vtable_number = vtable_number;
+}
+
 int
 (is_entity)(const void *thing) {
   return _is_entity(thing);
index 1358683..b9db476 100644 (file)
@@ -60,8 +60,8 @@
  *                   If (type != method_type) access of this field will cause
  *                   an assertion.
  */
-#ifndef _ENTITY_H_
-#define _ENTITY_H_
+#ifndef _FIRM_TR_ENTITY_H_
+#define _FIRM_TR_ENTITY_H_
 
 #include "firm_types.h"
 #include "dbginfo.h"
@@ -316,6 +316,12 @@ void    set_entity_link(entity *ent, void *l);
 ir_graph *get_entity_irg(const entity *ent);
 void      set_entity_irg(entity *ent, ir_graph *irg);
 
+/** Gets the entity vtable number. */
+unsigned get_entity_vtable_number(entity *ent);
+
+/** Sets the entity vtable number. */
+void     set_entity_vtable_number(entity *ent, unsigned vtable_number);
+
 /** Return the peculiarity of an entity. */
 peculiarity get_entity_peculiarity (const entity *ent);
 
@@ -604,4 +610,4 @@ typedef enum acc_bits {
 #define IS_WRITTEN(a)  ((a) & ptr_access_write)
 #define IS_STORED(a)   ((a) & ptr_access_store)
 
-#endif /* _ENTITY_H_ */
+#endif /* _FIRM_TR_ENTITY_H_ */
index 3288048..3b8b211 100644 (file)
@@ -770,6 +770,7 @@ ir_type *new_d_type_class (ident *name, dbg_info *db) {
   res->attr.ca.supertypes  = NEW_ARR_F (ir_type *, 0);
   res->attr.ca.peculiarity = peculiarity_existent;
   res->attr.ca.type_info   = NULL;
+  res->attr.ca.vtable_size = 0;
   res->attr.ca.final       = 0;
   res->attr.ca.dfn         = 0;
   hook_new_type(res);
@@ -976,10 +977,22 @@ void        set_class_peculiarity (ir_type *clss, peculiarity pec) {
   clss->attr.ca.peculiarity = pec;
 }
 
+/* Returns the size of the virtual function table. */
+unsigned (get_class_vtable_size)(const ir_type *clss) {
+  return _get_class_vtable_size(clss);
+}
+
+/* Sets a new size of the virtual function table. */
+void (set_class_vtable_size)(ir_type *clss, unsigned size) {
+  _set_class_vtable_size(clss, size);
+}
+
+/* Returns non-zero if a class is final. */
 int (is_class_final)(const ir_type *clss) {
   return _is_class_final(clss);
 }
 
+/* Sets if a class is final. */
 void (set_class_final)(ir_type *clss, int final) {
   _set_class_final(clss, final);
 }
index efb9d28..fc87b50 100644 (file)
@@ -1,17 +1,18 @@
+/*
+ * Project:     libFIRM
+ * File name:   ir/tr/type.h
+ * Purpose:     Representation of types.
+ * Author:      Goetz Lindenmaier
+ * Modified by: Michael Beck
+ * Created:
+ * Copyright:   (c) 2001-2003 Universität Karlsruhe
+ * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
+ * CVS-ID:      $Id$
+ */
+
 /**
  * @file type.h
  *
- * Project:     libFIRM                                                   <br>
- * File name:   ir/tr/type.h                                              <br>
- * Purpose:     Representation of types.                                  <br>
- * Author:      Goetz Lindenmaier                                         <br>
- * Modified by:                                                           <br>
- * Created:                                                               <br>
- * Copyright:   (c) 2001-2003 Universität Karlsruhe                       <br>
- * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE. <br>
- * CVS-ID:      $Id$
- *
- *
  *  Datastructure to hold type information.
  *
  *  This module supplies a datastructure to represent all types
@@ -31,7 +32,6 @@
  *
  *  @see  tpop.h
  */
-
 #ifndef _FIRM_TR_TYPE_H_
 #define _FIRM_TR_TYPE_H_
 
@@ -435,6 +435,9 @@ int smaller_type (ir_type *st, ir_type *lt);
  *                 representing this type.  This information is useful for lowering
  *                 of InstOf and TypeChk nodes.  Default: NULL
  *
+ *  - vtable_size: The size of this class vritual function table.
+ *                 Default:  0
+ *
  *  - final:       A final class is always a leaf in the class hierarchy.  Final
  *                 classes cannot be super classes of other ones.  As this information
  *                 can only be computed in whole world compilations, we allow to
@@ -591,6 +594,12 @@ entity *get_class_type_info(const ir_type *clss);
 /** Set a type info entity for the class. */
 void set_class_type_info(ir_type *clss, entity *ent);
 
+/** Returns the size of the virtual function table. */
+unsigned get_class_vtable_size(const ir_type *clss);
+
+/** Sets a new size of the virtual function table. */
+void set_class_vtable_size(ir_type *clss, unsigned size);
+
 /** Returns non-zero if a class is final. */
 int is_class_final(const ir_type *clss);
 
index 6a55be9..27e7e1c 100644 (file)
@@ -35,33 +35,34 @@ typedef struct {
   ir_type **supertypes;/**< direct supertypes */
   peculiarity peculiarity;  /**< peculiarity of this class */
   entity  *type_info;  /**< a entity representing this class, used for type info */
+  unsigned vtable_size;/**< size of the vtable */
   unsigned final;      /**< non-zero if this is a final class */
   int dfn;             /**< number used for 'instanceof' operator */
 } cls_attr;
 
 /** struct attributes */
 typedef struct {
-  entity **members;    /**< fields of this struct. No method entities allowed. */
+  entity **members;    /**< Fields of this struct. No method entities allowed. */
 } stc_attr;
 
 /** A (type, entity) pair */
 typedef struct {
-  ir_type *tp;         /**< a type */
-  entity  *ent;        /**< an entity */
+  ir_type *tp;         /**< A type. */
+  entity  *ent;        /**< An entity. */
 } tp_ent_pair;
 
 /** method attributes */
 typedef struct {
-  int n_params;                   /**< number of parameters */
-  tp_ent_pair *param_type;        /**< array of parameter type/value entities pairs */
+  int n_params;                   /**< Number of parameters. */
+  tp_ent_pair *param_type;        /**< Array of parameter type/value entities pairs. */
   ir_type *value_params;          /**< A type whose entities represent copied value arguments. */
-  int n_res;                      /**< number of results */
-  tp_ent_pair *res_type;          /**< array of result type/value entity pairs */
+  int n_res;                      /**< Number of results. */
+  tp_ent_pair *res_type;          /**< Array of result type/value entity pairs. */
   ir_type *value_ress;            /**< A type whose entities represent copied value results. */
   variadicity variadicity;        /**< variadicity of the method. */
-  int first_variadic_param;       /**< index of the first variadic param or -1 if non-variadic .*/
+  int first_variadic_param;       /**< index of the first variadic parameter or -1 if non-variadic .*/
   unsigned additional_properties; /**< Set of additional method properties. */
-  unsigned irg_calling_conv;      /**< this is a set of calling convention flags. */
+  unsigned irg_calling_conv;      /**< A set of calling convention flags. */
 } mtd_attr;
 
 /** union attributes */
@@ -343,6 +344,18 @@ _get_class_member   (const ir_type *clss, int pos) {
   return clss->attr.ca.members[pos];
 }
 
+static INLINE unsigned
+_get_class_vtable_size(const ir_type *clss) {
+  assert(clss && (clss->type_op == type_class));
+  return clss->attr.ca.vtable_size;
+}
+
+static INLINE void
+_set_class_vtable_size(ir_type *clss, unsigned vtable_size) {
+  assert(clss && (clss->type_op == type_class));
+  clss->attr.ca.vtable_size = vtable_size;
+}
+
 static INLINE int
 _is_class_final   (const ir_type *clss) {
   assert(clss && (clss->type_op == type_class));
@@ -476,6 +489,8 @@ _set_method_calling_convention(ir_type *method, unsigned cc_mask) {
 #define is_Class_type(clss)               _is_class_type(clss)
 #define get_class_n_members(clss)         _get_class_n_members(clss)
 #define get_class_member(clss, pos)       _get_class_member(clss, pos)
+#define get_class_vtable_size(clss)       _get_class_vtable_size(clss)
+#define set_class_vtable_size(clss, size) _set_class_vtable_size(clss, size)
 #define is_class_final(clss)              _is_class_final(clss)
 #define set_class_final(clss, final)      _set_class_final(clss, final)
 #define is_Struct_type(strct)             _is_struct_type(strct)