*** empty log message ***
authorGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Wed, 17 Jan 2001 12:27:34 +0000 (12:27 +0000)
committerGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Wed, 17 Jan 2001 12:27:34 +0000 (12:27 +0000)
[r84]

16 files changed:
Changes
Makefile
ir/common/bool.h
ir/ir/irdump.c
ir/ir/irgmod.c
ir/ir/irgmod.h
ir/ir/irgwalk.h
ir/ir/irnode.c
ir/ir/irnode.h
ir/ir/irprog.c
ir/ir/irvrfy.c
ir/tr/entity.c
ir/tr/entity.h
ir/tr/entity_t.h
ir/tr/type.c
ir/tr/type.h

diff --git a/Changes b/Changes
index 9cc6b41..277e0cd 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,14 @@
+
+  15.01.2001 Goetz
+  added set/get_SymConst_type_or_id.
+  added field offset to entity.
+
+  12.01.2001 Goetz
+  Some changes to make the lib better portable
+
+  29.12.2000 Goetz
+  Initialize max_node_nr in irprog.
+
   27.12.2000 Goetz
   Now outputs warning if faulty type in irdump, dump_type_info.
   Explicit string termination in irdump, vcg_open.
index 8a26c20..cb06cf1 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 # Hey, emacs, this is a -*- makefile -*-
 #
-# Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
+# Copyright (C) 1998 - 2001 by Universitaet Karlsruhe
 # All rights reserved.
 # Author: Goetz Lindenmaier
 #
 
 SUBDIRS = ir testprograms
 
-MAKE    = /usr/bin/make -k
-SHELL   = /bin/sh
+ifeq (,($MAKE))
+MAKE = /usr/bin/make -k
+endif
 
-.PHONY: default all clean realclean install depend ir testprograms
+#MAKE = ${MAKE:-/usr/bin/make} #  Vorschlag Uwe
+#MAKE = /usr/bin/make -k
+#SHELL   = /bin/sh
 
+.PHONY: default all clean realclean install depend ir testprograms
 
+# Makes the intermediate representation and bundles it into a
+# library
 ir:
        $(MAKE) -C ir
+# Makes the library, i.e., compiles and bundles the intermediate
+# representation and extracts the necessary headers into directory
+# include.
+lib:   ir
+       $(MAKE) -C ir lib
 
-all:   TAGS ir testprograms
-
+# Makes the testprograms.
 testprograms:
        $(MAKE) -C testprograms
 
-lib:   ir
-       $(MAKE) -C ir lib
+# Makes everything
+all:   TAGS ir lib testprograms
+
 
 clean:
        for i in $(SUBDIRS); do  $(MAKE) -C $$i clean; done
index 80cd5e7..305f96b 100644 (file)
 # ifndef _BOOL_H_
 # define _BOOL_H_
 
-# ifndef __CPLUSPLUS
+# ifndef __cplusplus
 
 typedef unsigned char bool;
 
-# endif
+# endif /* __cplusplus */
 
 # endif /* _BOOL_H_ */
index 56ccd0c..baf5464 100644 (file)
@@ -27,6 +27,8 @@
 #define DEFAULT_TYPE_ATTRIBUTE ""
 #define TYPE_EDGE_ATTR ""
 
+#define PRINT_NODEID(X) fprintf(F, "%p", X)
+
 /* file to dump to */
 static FILE *F;
 
@@ -139,7 +141,8 @@ void
 dump_node (ir_node *n) {
 
   /* dump this node */
-  xfprintf (F, "node: {title: \"%p\" label: \"", n);
+  xfprintf (F, "node: {title: \""); PRINT_NODEID(n); fprintf(F, "\" label: \"");
+
   dump_node_opcode(n);
   dump_node_mode (n);
   xfprintf (F, " ");
@@ -156,7 +159,7 @@ void
 dump_ir_node (ir_node *n)
 {
   /* dump this node */
-  xfprintf (F, "node: {title: \"%p\" label: ", n);
+  fprintf (F, "node: {title: \""); PRINT_NODEID(n); fprintf(F, "\" label: ");
 
   switch (n->op->code) {  /* node label */
   case iro_Start:
@@ -605,7 +608,7 @@ dump_ir_block (ir_node *block, void *env) {
   if (get_irn_opcode(block) == iro_Block) {
 
     /* This is a block. So dump the vcg information to make a block. */
-    xfprintf(F, "graph: { title: \"%p\"  label: \"", block);
+    xfprintf(F, "graph: { title: \""); PRINT_NODEID(block); fprintf(F, "\"  label: \"");
 #ifdef DEBUG_libfirm
     xfprintf (F, "%ld", get_irn_node_nr(block));
 #else
index a4a381f..ec7cc6d 100644 (file)
@@ -1,3 +1,4 @@
+
 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
 ** All rights reserved.
 **
index 21c6546..02531c6 100644 (file)
 # include "irnode.h"
 
 /* Turns a node into a "useless" Tuple.  The Tuple just forms a tuple
-   from several inputs.  The tuples predecessors have to be
+   from several inputs.  The predecessors of the tuple have to be
    set by hand.
    This is useful if a node returning a tuple is removed, but the Projs
    extracting values from the tuple are not available. */
 void turn_into_tuple (ir_node *node, int arity);
 
-/* Exchanges two nodes by conserving edges leaving old (i.e., pointers)
-   pointing to old. */
+/* Exchanges two nodes by conserving edges leaving old (i.e., pointers
+   pointing to old).  Turns the old node into an Id. Requires that
+   current_ir_graph is set properly. */
 inline void exchange (ir_node *old, ir_node *new);
 
 #endif /* ifndef _IRGMOD_H_ */
index b9f0019..f0bc842 100644 (file)
    Executes pre before visiting the predecessor of a node, post after.
    irg_walk uses the visited flag in irg and the nodes to determine visited
    nodes.  It executes inc_irg_visited(current_ir_graph) to generate a new
-   flag. */
+   flag.
+   The void* env can be used to pass status information between the
+   pre and post functions.  */
 void irg_walk(ir_node *node,
              void (pre)(ir_node*, void*), void (post)(ir_node*, void*),
              void *env);
 
-/* walks only over Block nodes in the graph.  Has it's own visited
+/* Walks only over Block nodes in the graph.  Has it's own visited
    flag, so that it can be interleaved with the other walker.         */
 void irg_block_walk(ir_node *node,
                    void (pre)(ir_node*, void*), void (post)(ir_node*, void*),
index 871551c..f3b5277 100644 (file)
@@ -573,8 +573,6 @@ get_SymConst_ptrinfo (ir_node *node) {
   assert (   (node->op == op_SymConst)
           && (get_SymConst_kind(node) == linkage_ptr_info));
   return node->attr.i.tori.ptrinfo;
-
-
 }
 
 inline void
@@ -584,6 +582,18 @@ set_SymConst_ptrinfo (ir_node *node, ident *ptrinfo) {
   node->attr.i.tori.ptrinfo = ptrinfo;
 }
 
+inline type_or_id_p
+get_SymConst_type_or_id (ir_node *node) {
+  assert (node->op == op_SymConst);
+  return &(node->attr.i.tori);
+}
+
+inline void
+set_SymConst_type_or_id (ir_node *node, type_or_id_p tori) {
+  assert (node->op == op_SymConst);
+  memcpy (&(node->attr.i.tori), tori, sizeof(type_or_id));
+}
+
 inline ir_node *
 get_Sel_mem (ir_node *node) {
   assert (node->op == op_Sel);
index b64def6..3e01eb4 100644 (file)
@@ -130,19 +130,25 @@ inline void     set_Const_tarval (ir_node *node, tarval *con);
      this flag. */
 typedef enum {
   type_tag,          /* The SymConst is a type tag for the given type.
-                       Type_or_id_p is type * */
+                       Type_or_id_p is type *. */
   size,              /* The SymConst is the size of the given type.
-                       Type_or_id_p is 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 * */
+                       by the linker. Type_or_id_p is ident *. */
 } symconst_kind;
 typedef union type_or_id * type_or_id_p;
 inline symconst_kind get_SymConst_kind (ir_node *node);
 inline void          set_SymConst_kind (ir_node *node, symconst_kind num);
+/* Only to access SymConst of kind type_tag or size.  Else assertion: */
 inline type    *get_SymConst_type (ir_node *node);
 inline void     set_SymConst_type (ir_node *node, type *type);
+/* Only to access SymConst of kind linkage_ptr_info.  Else assertion: */
 inline ident   *get_SymConst_ptrinfo (ir_node *node);
 inline void     set_SymConst_ptrinfo (ir_node *node, ident *ptrinfo);
+/* Sets both: type and ptrinfo.  Needed to treat the node independent of
+   its semantics: */
+inline type_or_id_p get_SymConst_type_or_id (ir_node *node);
+inline void set_SymConst_type_or_id (ir_node *node, type_or_id_p tori);
 
 inline ir_node *get_Sel_mem (ir_node *node);
 inline void     set_Sel_mem (ir_node *node, ir_node *mem);
index 20973ae..ab56985 100644 (file)
@@ -35,6 +35,10 @@ ir_prog *new_ir_prog (void) {
                                               strlen(GLOBAL_TYPE_NAME)));
   add_irp_type((type *)res->glob_type);
 
+#ifdef DEBUG_libfirm
+  res->max_node_nr = 1;
+#endif
+
   return res;
 }
 
@@ -111,8 +115,10 @@ void  set_irp_type(int pos, type *typ) {
 
 }
 
+#ifdef DEBUG_libfirm
 int get_irp_new_node_nr() {
   assert(irp);
   irp->max_node_nr = irp->max_node_nr + 1;
   return irp->max_node_nr - 1;
 }
+#endif
index d82c9c5..74e0ee7 100644 (file)
@@ -3,7 +3,7 @@
 **
 ** Authors: Christian Schaefer
 **
-**
+x**
 */
 
 # include "irgraph_t.h"
index 6b9ad6b..91043f3 100644 (file)
@@ -116,6 +116,16 @@ set_entity_type (entity *ent, type *type) {
   ent->type = type;
 }
 
+inline int
+get_entity_offset (entity *ent) {
+  return ent->offset;
+}
+
+inline void
+set_entity_offset (entity *ent, int offset) {
+  ent->offset = offset;
+}
+
 inline ir_graph *
 get_entity_irg(entity *ent) {
   assert (ent);
index 4d33672..4614c08 100644 (file)
 **  of procedures defined in the scope of an other procedure is the
 **  enclosing procedure.
 **
+**  In detail the datastructure entity has the following fields:
+**
+**  ident *name     Name of this entity as specified in the source code.
+**                  Only unequivocal in conjuction with scope.
+**  ident *ld_name  Unique name of this entity, i.e., the mangled
+**                  name.  E.g., for a class `A' with field `a' this
+**                  is the ident for `A_a'.
+**  type *type      The type of this entity, e.g., a method type, a
+**                  basic type of the language or a class itself.
+**  type *owner;    The class this entity belongs to.  In case of local
+**                 variables the method they are defined in.
+**  int offset;     Offset in byte for this entity.  Fixed when layout
+**                 of owner is determined.
+**  ir_graph *irg;  If (type == method_type) this is the corresponding irg.
+**                 The ir_graph constructor automatically sets this field.
+**                  If (type !- method_type) access of this field will cause
+**                  an assertion.
 */
 
 # ifndef _ENTITY_H_
@@ -80,6 +97,9 @@ inline void  assert_legal_owner_of_ent(type *owner);
 type     *get_entity_type (entity *ent);
 void      set_entity_type (entity *ent, type *type);
 
+int       get_entity_offset (entity *ent);
+void      set_entity_offset (entity *ent, int offset);
+
 /* The entity knows the corresponding irg if the entity is a method.
    This allows to get from a Call to the called irg. */
 ir_graph *get_entity_irg(entity *ent);
index 6c08cfd..9ec5659 100644 (file)
@@ -45,8 +45,10 @@ struct entity {
                            is the ident for `A_a'. */
   type *type;           /* The type of this entity, e.g., a method type, a
                            basic type of the language or a class itself */
-  type *owner;          /* The class this entity belongs to.  In case of local variables
-                          the method they are defined in. */
+  type *owner;          /* The class this entity belongs to.  In case of local
+                          variables the method they are defined in. */
+  int  offset;          /* Offset in byte for this entity.  Fixed when layout
+                          of owner is determined.  */
   /* for methods */
   ir_graph *irg;        /* If (type == method_type) this is the corresponding irg.
                           The ir_graph constructor automatically sets this field.
index 829aed1..d1bdeac 100644 (file)
@@ -147,6 +147,19 @@ get_class_n_supertype (type_class *clss)
   return (ARR_LEN (clss->supertypes))-1;
 }
 
+int
+get_class_size (type_class *clss) {
+  assert(clss);
+  return clss->size;
+}
+
+void
+set_class_size (type_class *clss, int size) {
+  assert(clss);
+  clss->size = size;
+}
+
+
 /*******************************************************************/
 /** TYPE_STRCT                                                   **/
 /*******************************************************************/
index ae883dc..8c16654 100644 (file)
@@ -217,6 +217,10 @@ struct type_class {
   type_class **supertypes; /* direct supertypes */
   unsigned long visit;     /* visited counter for walks of
                              the type information */
+  int size;                /* Size of an entity of this type.  This is determined
+                             when fixing the layout of this class.  Size must be
+                             given in bytes. */
+
 };
 
 
@@ -248,6 +252,10 @@ int         get_class_n_supertype (type_class *clss);
 type_class *get_class_supertype (type_class *clss, int pos);
 void        set_class_supertype (type_class *clss, type_class *supertype, int pos);
 
+int         get_class_size (type_class *clss);
+void        set_class_size (type_class *clss, int size);
+
+
 /*******************************************************************/
 /** TYPE_STRCT                                                   **/
 /*******************************************************************/