new.
authorGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Wed, 14 Mar 2001 15:27:26 +0000 (15:27 +0000)
committerGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Wed, 14 Mar 2001 15:27:26 +0000 (15:27 +0000)
[r138]

ir/tr/tpop.c [new file with mode: 0644]
ir/tr/tpop_t.h [new file with mode: 0644]
ir/tr/type_t.h [new file with mode: 0644]

diff --git a/ir/tr/tpop.c b/ir/tr/tpop.c
new file mode 100644 (file)
index 0000000..fd7f78b
--- /dev/null
@@ -0,0 +1,65 @@
+/* Copyright (C) 2001 by Universitaet Karlsruhe
+** All rights reserved.
+**
+** Authors: Goetz Lindenmaier
+**
+*/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+# include "tpop_t.h"
+# include "type_t.h"
+
+tp_op *type_class;
+tp_op *type_struct;
+tp_op *type_method;
+tp_op *type_union;
+tp_op *type_array;
+tp_op *type_enumeration;
+tp_op *type_pointer;
+tp_op *type_primitive;
+
+tp_op *
+new_tpop (tp_opcode code, ident *name, size_t attr_size)
+{
+  tp_op *res;
+
+  res = (tp_op *) xmalloc (sizeof (tp_op));
+  res->code = code;
+  res->name = name;
+  res->attr_size = attr_size;
+  return res;
+}
+
+void
+init_tpop(void)
+{
+  type_class       = new_tpop (tpo_class      , id_from_str("class"      , 5), sizeof (cls_attr));
+  type_struct      = new_tpop (tpo_struct     , id_from_str("struct"     , 6), sizeof (stc_attr));
+  type_method      = new_tpop (tpo_method     , id_from_str("method"     , 6), sizeof (mtd_attr));
+  type_union       = new_tpop (tpo_union      , id_from_str("union"      , 5), sizeof (uni_attr));
+  type_array       = new_tpop (tpo_array      , id_from_str("array"      , 5), sizeof (arr_attr));
+  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);
+}
+
+/* Returns the string for the tp_opcode. */
+const char  *get_tpop_name      (tp_op *op) {
+  return id_to_str(op->name);
+}
+
+tp_opcode get_tpop_code (tp_op *op){
+  return op->code;
+}
+
+ident *get_tpop_ident(tp_op *op){
+  return op->name;
+}
+
+/* returns the attribute size of the operator. */
+int get_tpop_attr_size (tp_op *op) {
+  return op->attr_size;
+}
diff --git a/ir/tr/tpop_t.h b/ir/tr/tpop_t.h
new file mode 100644 (file)
index 0000000..ec11429
--- /dev/null
@@ -0,0 +1,86 @@
+
+# ifndef _IROP_T_H_
+# define _IROP_T_H_
+
+# include <stddef.h>
+# include "tpop.h"
+/****h* libfirm/tpop_t.h
+ *
+ * NAME
+ *   file tpop_t.h
+ * COPYRIGHT
+ *   (C) 2001 by Universitaet Karlsruhe
+ * AUTHORS
+ *   Goetz Lindenmaier
+ * NOTES
+ *   This file contains the datatypes hidden in tpop.h.
+ * SEE ALSO
+ *   tpop.h
+ *****
+ */
+
+struct tp_op {
+  tp_opcode code;
+  ident *name;
+  size_t attr_size;
+};
+
+/****f* tpop/new_tpop
+ *
+ * NAME
+ *   new_tpop - Returns a new type opcode.
+ * NOTE
+ *   Allocates a new tp_op struct and initializes it's fields with
+ *   the passed values.  This function is only to be used during
+ *   initialization of the library.
+ * SYNOPSIS
+ *   tp_op * new_tpop (tp_opcode code, ident *name, size_t attr_size);
+ * INPUTS
+ *   code      - the enum for this type opcode.
+ *   name      - an ident for the name of the type opcode.
+ *   attr_size - the size of the attributes necessary for a type with
+ *               this opcode
+ * RESULT
+ *   A new type opcode.
+ ***
+ */
+tp_op * new_tpop (tp_opcode code, ident *name, size_t attr_size);
+
+/****f* tpop/new_tpop
+ *
+ * NAME
+ *   init_tpop - Initialize the tpop module.
+ * NOTE
+ *   Must be called during the initizlization of the library. Allocates
+ *   opcodes and sets the globals that are external visible as specified
+ *   in tpop.h.
+ * SYNOPSIS
+ *   void init_tpop (void);
+ * INPUTS
+ * RESULT
+ * SIDE EFFECTS
+ *   Allocates opcodes for classes, struct, method, union, array,
+ *   enumeration, pointer and primitive and sets the according values.
+ ***
+ */
+void init_tpop (void);
+
+/****f* tpop/get_topo_attr_size
+ *
+ * NAME
+ *   get_topo_attr_size - Returns the size of the attribute to this kind
+ *   of type.
+ * NOTE
+ *   Internal feature.
+ * SYNOPSIS
+ *   int get_tpop_attr_size (tp_op *op)
+ * INPUTS
+ *   op - The type opcode to get the size for.
+ * RESULT
+ *   The size of the attribute of types with this opcode.
+ * SIDE EFFECTS
+ ***
+ */
+int get_tpop_attr_size (tp_op *op);
+
+#endif /* _IROP_T_H_ */
diff --git a/ir/tr/type_t.h b/ir/tr/type_t.h
new file mode 100644 (file)
index 0000000..50a65aa
--- /dev/null
@@ -0,0 +1,117 @@
+
+# ifndef _TYPE_T_H_
+# define _TYPE_T_H_
+
+# include "type.h"
+
+/****h* libfirm/type_t.h
+ *
+ * NAME
+ *   file type_t.h
+ * COPYRIGHT
+ *   (C) 2001 by Universitaet Karlsruhe
+ * AUTHORS
+ *   Goetz Lindenmaier
+ * NOTES
+ *   This file contains the datatypes hidden in type.h.
+ * SEE ALSO
+ *   type.h tpop_t.h tpop.h
+ *****
+ */
+
+typedef struct {
+  entity **members;    /* fields and methods of this class */
+  type   **subtypes;   /* direct subtypes */
+  type   **supertypes; /* direct supertypes */
+} cls_attr;
+
+typedef struct {
+  entity **members;    /* fields of this struct. No method entities
+                         allowed. */
+} stc_attr;
+
+typedef struct {
+  int n_params;        /* number of parameters */
+  type **param_type;   /* code generation needs this information.
+                          Should it be generated by the frontend,
+                          or does this impose unnecessary work for
+                          optimizations that change the parameters of
+                          methods? */
+  int n_res;           /* number of results */
+  type **res_type;     /* array with result types */
+} mtd_attr;
+
+typedef struct {
+  int     n_types;
+  type  **unioned_type;/* a list of unioned types. */
+  ident **delim_names; /* names of the union delimiters. */
+} uni_attr;
+
+typedef struct {
+  int   n_dimensions;  /* Number of array dimensions.  */
+  int  *lower_bound;   /* Lower bounds of dimensions.  Usually all 0. */
+  int  *upper_bound;   /* Upper bounds or dimensions. */
+  type *element_type;  /* The type of the array elements. */
+} arr_attr;
+
+typedef struct {
+  int      n_enums;    /* Number of enumerators. */
+  tarval **enumer;     /* Contains all constants that represent a member
+                          of the enum -- enumerators. */
+  ident  **enum_nameid;/* Contains the names of the enum fields as specified by
+                          the source program */
+} enm_attr;
+
+typedef struct {
+  type *points_to;     /* The type of the enitity the pointer points to. */
+} ptr_attr;
+
+/*
+typedef struct {        * No private attr yet. *
+} pri_attr;
+*/
+
+typedef union {
+  cls_attr ca;
+  stc_attr sa;
+  mtd_attr ma;
+  uni_attr ua;
+  arr_attr aa;
+  enm_attr ea;
+  ptr_attr pa;
+} tp_attr;
+
+struct type {
+  firm_kind kind;
+  tp_op *type_op;
+  ir_mode *mode;
+  ident *name;
+  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. */
+  unsigned long visit;     /* visited counter for walks of the type information */
+  tp_attr attr;            /* type kind specific fields. This must be the last
+                             entry in this struct!  Varying size! */
+};
+
+/****f* type_t.h/new_type
+ *
+ * NAME
+ *   new_type - creates a new type representation
+ * SYNOPSIS
+ *  type *new_type(tp_op *type_op, ir_mode *mode, ident* name);
+ * INPUTS
+ *   type_op - the kind of this type
+ *   mode    - the mode to be used for this type, may be NULL
+ *   name    - an ident for the name of this type.
+ * RESULT
+ *   a new type of the given type.  The remaining private attributes are not
+ *   initalized.
+ ***
+ */
+inline type *
+new_type(tp_op *type_op,
+        ir_mode *mode,
+        ident* name);
+
+# endif /* _TYPE_T_H_ */