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

*** empty log message ***

[r63]
parent 48e79b69
15.8.2000 Goetz until 3.9.00
Separated irnode.h and many others into two files: one public
one private.
Added funcionality to extract headers for lib.
23.8.2000 Goetz
type_dump also dumps irg->ent
if_example: corrected nr of locals
......
......@@ -24,7 +24,7 @@ all: TAGS ir testprograms
testprograms:
$(MAKE) -C testprograms
lib:
lib: ir
$(MAKE) -C ir lib
clean:
......@@ -32,7 +32,7 @@ clean:
realclean:
for i in $(SUBDIRS); do $(MAKE) -C $$i realclean; done
rm -f libfirm.a core include/*
rm -f libfirm.a core include/*.h
TAGFILES = $(shell find . -name '*.c' -o -name '*.h')
......
......@@ -29,12 +29,13 @@ CFILES = $(MEMBERS:.m=.c)
CFILES += xfprintf.c xfprintf.c xfprintf.c
HFILES = $(MEMBERS:.m=.h)
HFILES += tune.h xp_help.h xprintf.h misc.h
HFILES += tune.h xp_help.h xprintf.h misc.h bool.h
HFILES += common.h debug.h entity.h gmp.h host.h ident.h irgraph.h \
irmode.h irnode.h irop.h irprog.h label.h misc.h obst.h \
pset.h set.h tv.h type.h xprintf.h xp_help.h
DISTRIB = $(DISTRIBMEMBERS:.m=.h)
DISTRIB += bool.h
OFILES = $(MEMBERS:%.m=../objects/%.o)
OFILES += ../objects/xfprintf.o \
......
/* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
** All rights reserved.
**
** Authors: Goetz Lindenmaier.
**
** bool.h: Datatype bool.
**
*/
# ifndef _BOOL_H_
# define _BOOL_H_
typedef unsigned char bool;
# endif /* _BOOL_H_ */
......@@ -10,6 +10,8 @@
# ifndef _COMMON_H_
# define _COMMON_H_
// GL# include <assert.h>
/** Global flags. Set these by autoconf?? **/
/* There are two implementations of the Phi node construction. The first
......
......@@ -6,11 +6,12 @@
*/
# include <stdio.h>
# include "ident.h"
# include "ident_t.h"
# include "firm.h"
# include "mangle.h"
# include "xp_help.h"
# include "irnode_t.h"
# include "tv_t.h"
void
init_firm (void)
......
......@@ -57,16 +57,14 @@
# define _FIRM_H_
/* The representations */
# include "irprog.h"
# include "type.h"
# include "entity.h"
# include "irprog.h" /* control flow and data of a program */
# include "type.h" /* type representation */
# include "entity.h" /* entity representation */
# include "tv.h" /* target values */
# include "ident.h" /* source code identificators */
/* Functionality */
# include "ircons.h"
# include "irgopt.h"
/* */
# include "xprintf.h"
# include "ircons.h" /* construct ir */
# include "irgopt.h" /* optimize ir */
/* initialize firm */
void init_firm (void);
......
......@@ -2,9 +2,8 @@
Copyright (C) 1995, 1996 Markus Armbruster
All rights reserved. */
#ifndef _MISC_H
#define _MISC_H
#ifndef _MISC_H_
#define _MISC_H_
/* Declare alloca() */
......@@ -29,7 +28,7 @@ void *alloca ();
#include "host.h"
#include "bool.h"
/* Alignment of nodes, cf common/tag.h, a power of two.
......@@ -53,7 +52,6 @@ void *alloca ();
#define IS_POW2(n) ((((n)-1) & (n)) == 0)
typedef unsigned char bool;
typedef int (*cmp_fun) (const void *, const void *);
......@@ -80,4 +78,4 @@ extern const char *tmalloc_tag;
# define XMALLOC_TRACE
#endif
#endif
#endif /* _MISC_H_ */
......@@ -55,7 +55,7 @@ TARGET = all
$(TARGET): $(DFILES) $(OFILES)
lib:
cp $(DISTRIB) ../../include/
# cp $(DISTRIB) ../../include/
clean:
rm -f $(OFILES) $(DFILES)
......
......@@ -27,6 +27,7 @@ MEMBERS = $(DISTRIBMEMBERS)
CFILES = $(MEMBERS:.m=.c)
HFILES = $(MEMBERS:.m=.h)
HFILES += ident_t.h
HFILES += array.h cookies.h debug.h host.h misc.h set.h tune.h xprintf.h \
xp_help.h
......@@ -43,6 +44,8 @@ TARGET = all
.DEFAULT: $(TARGET)
.SILENT: $(DFILES) clean # hides output
$(TARGET): $(DFILES) $(OFILES)
%.d: %.c
$(SHELL) -ec '$(CXX) $(DEPENDFLAGS) $(INCLUDES) $(X_INCLUDES) $< | sed '\''s/\($*\)\.o[ :]*/\.\.\/objects\/\1.o $@ : /g'\'' > $@'
......@@ -53,8 +56,6 @@ TARGET = all
lib:
cp $(DISTRIB) ../../include
$(TARGET): $(DFILES) $(OFILES)
clean:
rm -f $(OFILES) $(DFILES)
......
......@@ -11,7 +11,7 @@
#include <string.h>
#include "array.h"
#include "tune.h"
#include "ident.h"
#include "ident_t.h"
#include "xprintf.h"
#define XX_USER(name) ident *id_##name;
......@@ -93,3 +93,20 @@ id_init (void)
#undef XX_USER
#undef XX_INTERNAL
}
#if 1
inline ident *id_from_str (char *str, int len) {
assert (len > 0);
return (const set_entry *)set_hinsert (id_set, (str), (len), ID_HASH ((str), (len)));
}
inline const char *id_to_str (ident *id) {
return ((const char *)&(id)->dptr[0]);
}
inline int id_to_strlen(ident *id) {
return ((id)->size);
}
#endif
......@@ -10,66 +10,13 @@
# ifndef _IDENT_H_
# define _IDENT_H_
#include <assert.h>
#include <stddef.h>
#include "misc.h"
#include "debug.h"
#include "set.h"
# include "xprintf.h"
# include "xp_help.h"
# include "assert.h"
/* Identifiers */
typedef const struct set_entry ident;
/* Caution: strings _not_ zero-terminated! */
#define ID_FROM_STR(str, len) \
(assert ((len) > 0), \
(const set_entry *)set_hinsert (id_set, (str), (len), ID_HASH ((str), (len))))
#define ID_TO_STR(id) ((const char *)&(id)->dptr[0])
#define ID_TO_STRLEN(id) ((id)->size)
#define ID_TO_HASH(id) ((long)(id) + (id)->hash)
ident *new_id_derived (const char *pfx, ident *);
ident *new_id_internal (void);
bool id_is_internal (ident *);
void id_init (void);
#ifdef NDEBUG
# define ID_VRFY(id) ((void)0)
# define IDS_VRFY(id) ((void)0)
#else
# define ID_VRFY(id) \
assert ( (id) \
&& ( !d_ (df_vrfy_level, 1) \
|| (ID_FROM_STR (ID_TO_STR((id)), ID_TO_STRLEN((id))) == (id))))
# define IDS_VRFY(id) ids_vrfy ((id))
void ids_vrfy (ident **id);
#endif
#ifdef STATS
# define id_stats() set_stats (id_set)
#else
# define id_stats() ((void)0)
#endif
/* Private */
/* @@@ tune */
#define ID_HASH(str, len) \
((( ((unsigned char *)(str))[0] * 33 \
+ ((unsigned char *)(str))[(len)>>1]) * 31 \
+ ((unsigned char *)(str))[(len)-1]) * 9 \
+ (len))
extern set *id_set;
# define id_from_str ID_FROM_STR
# define id_to_str ID_TO_STR
# define id_to_strlen ID_TO_STRLEN
int ident_print (XP_PAR1, const xprintf_info *, XP_PARN);
inline ident *id_from_str (char *str, int len);
inline const char *id_to_str (ident *id);
inline int id_to_strlen(ident *id);
# endif /* _IDENT_H_ */
/* Declarations for ident.
Copyright (C) 1995, 1996 Markus Armbruster */
/* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
** All rights reserved.
**
** Authors: Martin Trapp, Christian Schaefer
*/
# ifndef _IDENT_T_H_
# define _IDENT_T_H_
#include <assert.h>
#include <stddef.h>
#include "misc.h"
#include "debug.h"
#include "set.h"
#include "ident.h"
# include "xprintf.h"
# include "xp_help.h"
/* Caution: strings _not_ zero-terminated! */
#define ID_FROM_STR(str, len) \
(assert ((len) > 0), \
(const set_entry *)set_hinsert (id_set, (str), (len), ID_HASH ((str), (len))))
#define ID_TO_STR(id) ((const char *)&(id)->dptr[0])
#define ID_TO_STRLEN(id) ((id)->size)
#define ID_TO_HASH(id) ((long)(id) + (id)->hash)
ident *new_id_derived (const char *pfx, ident *);
ident *new_id_internal (void);
bool id_is_internal (ident *);
void id_init (void);
#ifdef NDEBUG
# define ID_VRFY(id) ((void)0)
# define IDS_VRFY(id) ((void)0)
#else
# define ID_VRFY(id) \
assert ( (id) \
&& ( !d_ (df_vrfy_level, 1) \
|| (ID_FROM_STR (ID_TO_STR((id)), ID_TO_STRLEN((id))) == (id))))
# define IDS_VRFY(id) ids_vrfy ((id))
void ids_vrfy (ident **id);
#endif
#ifdef STATS
# define id_stats() set_stats (id_set)
#else
# define id_stats() ((void)0)
#endif
/* Private */
/* @@@ tune */
#define ID_HASH(str, len) \
((( ((unsigned char *)(str))[0] * 33 \
+ ((unsigned char *)(str))[(len)>>1]) * 31 \
+ ((unsigned char *)(str))[(len)-1]) * 9 \
+ (len))
extern set *id_set;
#if 0
# define id_from_str ID_FROM_STR
# define id_to_str ID_TO_STR
# define id_to_strlen ID_TO_STRLEN
#endif
int ident_print (XP_PAR1, const xprintf_info *, XP_PARN);
# endif /* _IDENT_T_H_ */
......@@ -22,13 +22,14 @@ X_INCLUDES =
SHELL = /bin/sh
MAKE = /usr/bin/make
DISTRIBMEMBERS = ircons.m irdump.m irflag.m irgmod.m irgraph.m irgopt.m \
DISTRIBMEMBERS = ircons.m irdump.m irflag.m irgmod.m irgraph.m irgopt.m \
irgwalk.m irmode.m irnode.m irop.m iropt.m irprog.m irvrfy.m
MEMBERS = $(DISTRIBMEMBERS)
CFILES = $(MEMBERS:.m=.c)
HFILES = $(MEMBERS:.m=.h)
HFILES += irnode_t.h irgraph_t.h
HFILES += array.h common.h cookies.h debug.h entity.h gmp.h \
host.h ident.h label.h misc.h obst.h pdeq.h pset.h \
set.h tune.h tv.h type.h xprintf.h xp_help.h irnode2.h
......
......@@ -9,6 +9,8 @@
** by Goetz Lindenmaier
*/
# include "irgraph_t.h"
# include "irnode_t.h"
# include "ircons.h"
# include "common.h"
# include "irvrfy.h"
......@@ -18,23 +20,23 @@
# include "array.h"
/* memset belongs to string.h */
# include "string.h"
# include "irnode_t.h"
#if USE_EXPICIT_PHI_IN_STACK
/* A stack needed for the automatic Phi node construction in constructor
Phi_in. */
Phi_in. Redefinition in irgraph.c!! */
struct Phi_in_stack {
ir_node **stack;
int pos;
};
typedef struct Phi_in_stack Phi_in_stack;
#endif
/*********************************************** */
/** privat interfaces, for professional use only */
/* Constructs a Block with a fixed number of predecessors.
Does not set current_block. */
Does not set current_block. Can not be used with automatic
Phi node construction. */
inline ir_node *
new_r_Block (ir_graph *irg, int arity, ir_node **in)
{
......@@ -42,6 +44,7 @@ new_r_Block (ir_graph *irg, int arity, ir_node **in)
res = new_ir_node (irg, NULL, op_Block, mode_R, arity, in);
set_Block_matured(res, 1);
set_Block_block_visited(res, 0);
irn_vrfy (res);
return res;
......@@ -602,30 +605,35 @@ new_End (void)
return res;
}
#if 0
/* Constructs a Block with a fixed number of predecessors.
Does set current_block. Can be used with automatic Phi
node construction. */
ir_node *
new_Block (void)
new_Block (int arity, ir_node **in)
{
ir_node *res;
res = new_ir_node (current_ir_graph, NULL, op_Block, mode_R, -1, NULL);
res = new_r_Block (arity, in);
current_ir_graph->current_block = res;
res->attr.block.matured = 0;
set_Block_block_visited(res, 0);
/* forget this optimization. use this only if mature !!!!
res = optimize (res); */
irn_vrfy (res);
/** create a new dynamic array, which stores all parameters in irnodes */
/** using the same obstack as the whole irgraph */
/* Create and initialize array for Phi-node construction. */
res->attr.block.graph_arr = NEW_ARR_D (ir_node *, current_ir_graph->obst,
current_ir_graph->params);
/** initialize the parameter array */
memset(res->attr.block.graph_arr, 0, sizeof(ir_node *)*current_ir_graph->params);
res = optimize (res);
irn_vrfy (res);
return res;
}
#else
ir_node *
new_Block (void)
{
return new_immBlock();
}
#endif
/*************************************************************************/
/* Methods necessary for automatic Phi node creation */
......@@ -1502,7 +1510,31 @@ new_Bad (void)
/*************************************************************************/
/* Comfortable interface with automatic Phi node construction. */
/* (Uses also constructors of ?? interface, except new_Block. */
/* add an adge to a jmp node */
/*************************************************************************/
/** Block construction **/
/* immature Block without predecessors */
ir_node *new_immBlock (void) {
ir_node *res;
/* creates a new dynamic in-array as length of in is -1 */
res = new_ir_node (current_ir_graph, NULL, op_Block, mode_R, -1, NULL);
current_ir_graph->current_block = res;
res->attr.block.matured = 0;
set_Block_block_visited(res, 0);
/* Create and initialize array for Phi-node construction. */
res->attr.block.graph_arr = NEW_ARR_D (ir_node *, current_ir_graph->obst,
current_ir_graph->params);
memset(res->attr.block.graph_arr, 0, sizeof(ir_node *)*current_ir_graph->params);
/* Immature block may not be optimized! */
irn_vrfy (res);
return res;
}
/* add an adge to a jmp/control flow node */
void
add_in_edge (ir_node *block, ir_node *jmp)
{
......
......@@ -1089,17 +1089,14 @@
# include "entity.h"
# include "tv.h"
# include "type.h"
# include "pdeq.h"
#if USE_EXPICIT_PHI_IN_STACK
/* A stack needed for the automatic Phi node construction in constructor
Phi_in. */
typedef struct Phi_in_stack Phi_in_stack;
#endif
/***************************************************************************/
/* The raw interface */
/***************************************************************************/
/* Constructs a Block with a fixed number of predecessors.
Does not set current_block. Can not be used with automatic
Phi node construction. */
ir_node *new_r_Block (ir_graph *irg, int arity, ir_node **in);
ir_node *new_r_Start (ir_graph *irg, ir_node *block);
ir_node *new_r_End (ir_graph *irg, ir_node *block);
......@@ -1179,6 +1176,7 @@ ir_node *new_r_Bad ();
/*************************************************************************/
/* The block oriented interface */
/*************************************************************************/
/* Sets the current block in which the following constructors place the
nodes they construct. */
......@@ -1189,6 +1187,9 @@ void switch_block (ir_node *target);
and add a new one so dass das dann so aussieht:
passe die Beispeilprogramme an! */
#if 0
/* Constructs a Block with a fixed number of predecessors.
Does set current_block. Can be used with automatic Phi
node construction. */
ir_node *new_Block(int arity, ir_node **in); /* creates mature Block */
#else
ir_node *new_Block (void);
......@@ -1243,6 +1244,7 @@ ir_node *new_Bad (void);
/* Supports automatic Phi node construction. */
/* All routines of the block oriented interface except new_Block are */
/* needed also. */
/***********************************************************************/
/** Block construction **/
/* immature Block without predecessors */
......@@ -1252,7 +1254,7 @@ ir_node *new_immBlock (void);
void add_in_edge (ir_node *immblock, ir_node *jmp);
/* fixes the number of predecessors of a block. */
void mature_block (ir_node *block);
void mature_block (ir_node *block);
/** Parameter administration **/
/* Read a value from the array with the local variables. Use this
......@@ -1272,15 +1274,9 @@ ir_node *get_store (void);
/* Write a store. */
void set_store (ir_node *store);
/* This function is for internal use only. It is visible as it is needed
in irgraph.c to create the stack that is needed for automatic Phi
construction. */
#if USE_EXPICIT_PHI_IN_STACK
Phi_in_stack *new_Phi_in_stack();
#endif
/**************************************************************************/
/* initialize ir construction */
/***********************************************************************/
/* initialize ir construction */
/***********************************************************************/
void init_cons (void);
......
......@@ -6,9 +6,9 @@
** irdump.h: dumping of an intermediate representation graph
*/
# include <assert.h>
# include "irdump.h"
# include "irnode_t.h"
# include "irgraph_t.h"
# include "irdump.h"
# include "panic.h"
# include <string.h>
# include "entity.h"
......
......@@ -32,6 +32,6 @@ void dump_cfg (ir_graph *irg);
void dump_type_graph (ir_graph *irg);
/* dumps a graph and the type inforamtion. */
void dump_ir_graph_w_types (ir_graph *irg);
void dump_ir_graph_w_types (ir_graph *irg);
# endif /* _IRDUMP_H_ */
......@@ -7,6 +7,7 @@
*/
# include "irnode_t.h"
# include "irgraph_t.h"
# include "irgmod.h"
# include "array.h"
......
......@@ -11,7 +11,6 @@
# 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
set by hand.
......
Markdown is supported
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