From 5b567bb7b5f4558bc809be14ca2250e9dce1fd17 Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=B6tz=20Lindenmaier?= Date: Mon, 12 Jul 2004 09:49:31 +0000 Subject: [PATCH] fix for firmjni [r3402] --- firmjni/Makefile.in | 2 +- firmjni/testprograms/run-results.txt | 20 ++++++------- ir/ir/ircons.c | 20 +++++++++++++ ir/ir/ircons.h | 43 ++++++++++++++++++++++++---- ir/ir/irnode.h | 12 +++----- 5 files changed, 72 insertions(+), 25 deletions(-) diff --git a/firmjni/Makefile.in b/firmjni/Makefile.in index 2c3889553..762bd2366 100644 --- a/firmjni/Makefile.in +++ b/firmjni/Makefile.in @@ -68,7 +68,7 @@ FIRM_PATH_HEADERS=common/firm.h common/firm_common.h \ ir/ircons.h ir/ircgcons.h ir/irflag.h ir/irvrfy.h ir/irdump.h \ ir/iropt.h ir/irgopt.h ir/ircgopt.h \ ana/irouts.h ana/irdom.h ana/irloop.h ana/cgana.h \ - ir/irgmod.h tr/typegmod.h opt/tailrec.h stat/firmstat.h + ir/irgmod.h tr/typegmod.h opt/tailrec.h FIRM_SOURCE_DIR_HEADERS=$(addprefix $(SOURCE_DIR)/,$(FIRM_HEADERS)) diff --git a/firmjni/testprograms/run-results.txt b/firmjni/testprograms/run-results.txt index 346ee03be..ab33c2a6a 100644 --- a/firmjni/testprograms/run-results.txt +++ b/firmjni/testprograms/run-results.txt @@ -7,20 +7,20 @@ use xvcg to view this graph: Creating an IR graph: IfElseExample... Optimization: 3 -new Node 33 -old Node 32 +new Node 32 +old Node 31 Optimization: 2 -new Nodes: 35, -old Nodes: 36, 34, 35, +new Nodes: 34, +old Nodes: 35, 33, 34, Optimization: 2 -new Nodes: 20, -old Nodes: 37, 34, 20, +new Nodes: 19, +old Nodes: 36, 33, 19, Optimization: 4 -new Nodes: 27, -old Nodes: 42, 35, +new Nodes: 26, +old Nodes: 41, 34, Done building the graph. Optimizing it. Optimization: 4 -new Nodes: 27, -old Nodes: 42, 35, +new Nodes: 26, +old Nodes: 41, 34, use xvcg to view this graph: /ben/goetz/bin/xvcg GRAPHNAME diff --git a/ir/ir/ircons.c b/ir/ir/ircons.c index 198380b7e..e455c8896 100644 --- a/ir/ir/ircons.c +++ b/ir/ir/ircons.c @@ -721,6 +721,26 @@ new_rd_SymConst (dbg_info* db, ir_graph *irg, ir_node *block, symconst_symbol va return res; } +ir_node *new_rd_SymConst_addr_ent (dbg_info *db, ir_graph *irg, entity *symbol, type *tp) { + symconst_symbol sym = {(type *)symbol}; + return new_rd_SymConst_type(db, irg, irg->start_block, sym, symconst_addr_ent, tp); +} + +ir_node *new_rd_SymConst_addr_name (dbg_info *db, ir_graph *irg, ident *symbol, type *tp) { + symconst_symbol sym = {(type *)symbol}; + return new_rd_SymConst_type(db, irg, irg->start_block, sym, symconst_addr_name, tp); +} + +ir_node *new_rd_SymConst_type_tag (dbg_info *db, ir_graph *irg, type *symbol, type *tp) { + symconst_symbol sym = {symbol}; + return new_rd_SymConst_type(db, irg, irg->start_block, sym, symconst_type_tag, tp); +} + +ir_node *new_rd_SymConst_size (dbg_info *db, ir_graph *irg, type *symbol, type *tp) { + symconst_symbol sym = {symbol}; + return new_rd_SymConst_type(db, irg, irg->start_block, sym, symconst_size, tp); +} + INLINE ir_node * new_rd_Sync (dbg_info* db, ir_graph *irg, ir_node *block, int arity, ir_node **in) { diff --git a/ir/ir/ircons.h b/ir/ir/ircons.h index 78355bc92..26bb4f121 100644 --- a/ir/ir/ircons.h +++ b/ir/ir/ircons.h @@ -1300,6 +1300,9 @@ ir_node *new_rd_Const (dbg_info *db, ir_graph *irg, ir_node *block, * Outputs of the node. * An unsigned integer (I_u) or a pointer (P). * + * Mention union in declaration so that the firmjni generator recognizes that + * it can not cast the argument to an int. + * * @param *db A pointer for debug information. * @param *irg The ir graph the node belongs to. * @param *block The ir block the node belongs to. @@ -1308,14 +1311,42 @@ ir_node *new_rd_Const (dbg_info *db, ir_graph *irg, ir_node *block, * @param tp The source type of the constant. */ ir_node * -new_rd_SymConst_type (dbg_info* db, ir_graph *irg, ir_node *block, symconst_symbol value, +new_rd_SymConst_type (dbg_info* db, ir_graph *irg, ir_node *block, union symconst_symbol value, symconst_kind symkind, type *tp); /** Constructor for a SymConst node. * * Same as new_rd_SymConst_type, except that it sets the type to type_unknown. */ ir_node *new_rd_SymConst (dbg_info *db, ir_graph *irg, ir_node *block, - symconst_symbol value, symconst_kind symkind); + union symconst_symbol value, symconst_kind symkind); + +/** Constructor for a SymConst addr_ent node. + * + * Same as new_rd_SymConst_type, except that the constructor is tailored for + * symconst_addr_ent. + * Adds the symconst to the start block of irg. */ +ir_node *new_rd_SymConst_addr_ent (dbg_info *db, ir_graph *irg, entity *symbol, type *tp); + +/** Constructor for a SymConst addr_name node. + * + * Same as new_rd_SymConst_type, except that the constructor is tailored for + * symconst_addr_ent. + * Adds the symconst to the start block of irg. */ +ir_node *new_rd_SymConst_addr_name (dbg_info *db, ir_graph *irg, ident *symbol, type *tp); + +/** Constructor for a SymConst type_tag node. + * + * Same as new_rd_SymConst_type, except that the constructor is tailored for + * symconst_addr_ent. + * Adds the symconst to the start block of irg. */ +ir_node *new_rd_SymConst_type_tag (dbg_info *db, ir_graph *irg, type *symbol, type *tp); + +/** Constructor for a SymConst size node. + * + * Same as new_rd_SymConst_type, except that the constructor is tailored for + * symconst_addr_ent. + * Adds the symconst to the start block of irg. */ +ir_node *new_rd_SymConst_size (dbg_info *db, ir_graph *irg, type *symbol, type *tp); /** Constructor for a Sel node. * @@ -1975,7 +2006,7 @@ ir_node *new_r_Const (ir_graph *irg, ir_node *block, * @param symkind The kind of the symbolic constant: type_tag, size or link_info. */ ir_node *new_r_SymConst (ir_graph *irg, ir_node *block, - symconst_symbol value, symconst_kind symkind); + union symconst_symbol value, symconst_kind symkind); /** Constructor for a Sel node. * @@ -2682,12 +2713,12 @@ ir_node *new_d_Const (dbg_info* db, ir_mode *mode, tarval *con); * @param tp The source type of the constant. * */ -ir_node *new_d_SymConst_type (dbg_info* db, symconst_symbol value, symconst_kind kind, type* tp); +ir_node *new_d_SymConst_type (dbg_info* db, union symconst_symbol value, symconst_kind kind, type* tp); /** Constructor for a SymConst node. * * Same as new_d_SymConst_type, except that it sets the type to type_unknown. */ -ir_node *new_d_SymConst (dbg_info* db, symconst_symbol value, symconst_kind kind); +ir_node *new_d_SymConst (dbg_info* db, union symconst_symbol value, symconst_kind kind); /** Constructor for a simpleSel node. * @@ -3393,7 +3424,7 @@ ir_node *new_Const (ir_mode *mode, tarval *con); * @param symkind The kind of the symbolic constant: symconst_type_tag, symconst_size or symconst_addr_name. * */ -ir_node *new_SymConst (symconst_symbol value, symconst_kind kind); +ir_node *new_SymConst (union symconst_symbol value, symconst_kind kind); /** Constructor for a simpelSel node. * diff --git a/ir/ir/irnode.h b/ir/ir/irnode.h index 0f4d84a37..6070fbcd3 100644 --- a/ir/ir/irnode.h +++ b/ir/ir/irnode.h @@ -426,10 +426,6 @@ type *get_SymConst_type (ir_node *node); void set_SymConst_type (ir_node *node, type *tp); /** Only to access SymConst of kind addr_name. Else assertion: */ -/* old: -ident *get_SymConst_ptrinfo (ir_node *node); -void set_SymConst_ptrinfo (ir_node *node, ident *ptrinfo); -*/ #define get_SymConst_ptrinfo get_SymConst_name #define set_SymConst_ptrinfo set_SymConst_name ident *get_SymConst_name (ir_node *node); @@ -441,10 +437,10 @@ void set_SymConst_entity (ir_node *node, entity *ent); /** Sets both: type and ptrinfo. Needed to treat the node independent of its semantics. Does a memcpy for the memory sym points to. */ -#define get_SymConst_type_or_id get_SymConst_symbol -#define set_SymConst_type_or_id set_SymConst_symbol -symconst_symbol get_SymConst_symbol (ir_node *node); -void set_SymConst_symbol (ir_node *node, symconst_symbol sym); +/* write 'union': firmjni then does not create a method... */ +union symconst_symbol get_SymConst_symbol (ir_node *node); +void set_SymConst_symbol (ir_node *node, + union symconst_symbol sym); ir_node *get_Sel_mem (ir_node *node); void set_Sel_mem (ir_node *node, ir_node *mem); -- 2.20.1