+
+ 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.
# 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
# ifndef _BOOL_H_
# define _BOOL_H_
-# ifndef __CPLUSPLUS
+# ifndef __cplusplus
typedef unsigned char bool;
-# endif
+# endif /* __cplusplus */
# endif /* _BOOL_H_ */
#define DEFAULT_TYPE_ATTRIBUTE ""
#define TYPE_EDGE_ATTR ""
+#define PRINT_NODEID(X) fprintf(F, "%p", X)
+
/* file to dump to */
static FILE *F;
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, " ");
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:
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
+
/* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
** All rights reserved.
**
# 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_ */
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*),
assert ( (node->op == op_SymConst)
&& (get_SymConst_kind(node) == linkage_ptr_info));
return node->attr.i.tori.ptrinfo;
-
-
}
inline void
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);
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);
strlen(GLOBAL_TYPE_NAME)));
add_irp_type((type *)res->glob_type);
+#ifdef DEBUG_libfirm
+ res->max_node_nr = 1;
+#endif
+
return res;
}
}
+#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
**
** Authors: Christian Schaefer
**
-**
+x**
*/
# include "irgraph_t.h"
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);
** 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_
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);
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.
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 **/
/*******************************************************************/
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. */
+
};
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 **/
/*******************************************************************/