projects
/
libfirm
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
*** empty log message ***
[libfirm]
/
testprograms
/
oo_inline_example.c
diff --git
a/testprograms/oo_inline_example.c
b/testprograms/oo_inline_example.c
index
2821b88
..
d8ba70c
100644
(file)
--- a/
testprograms/oo_inline_example.c
+++ b/
testprograms/oo_inline_example.c
@@
-1,13
+1,14
@@
-/* Copyright (C)2002 by Universitaet Karlsruhe
-** All rights reserved.
-**
-** Authors: Goetz Lindenmaier
-**
-** testprogram.
-*/
-
-/* $ID$ */
-
+/*
+ * Project: libFIRM
+ * File name: testprograms/oo_inline_example.c
+ * Purpose: Test inlineing.
+ * Author: Goetz Lindenmaier
+ * Modified by:
+ * Created:
+ * CVS-ID: $Id$
+ * Copyright: (c) 1999-2003 Universität Karlsruhe
+ * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
+ */
# include <stdio.h>
# include <string.h>
# include <stdio.h>
# include <string.h>
@@
-16,28
+17,28
@@
# include "irdump.h"
# include "firm.h"
# include "irdump.h"
# include "firm.h"
-/**
This file constructs the IR for the following program:
-*
**
@@@ this is no more correct ...
-*
**
class PRIMA {
-*
**
a: int;
-*
**
-*
**
int c(d: int) {
-*
**
return (d + self.a);
-*
**
}
-*
**
-*
**
void set_a(e:int) {
-*
**
self.a = e;
-*
**
}
-*
**
-*
**
}
-*
**
-*
**
int main() {
-*
**
o: PRIMA;
-*
**
o = new PRIMA;
-*
**
o.set_a(2);
-*
**
return o.c(5);
-*
**
};
-*
**
+/**
+* @@@ this is no more correct ...
+* class PRIMA {
+* a: int;
+*
+* int c(d: int) {
+* return (d + self.a);
+* }
+*
+* void set_a(e:int) {
+* self.a = e;
+* }
+*
+* }
+*
+* int main() {
+* o: PRIMA;
+* o = new PRIMA;
+* o.set_a(2);
+* return o.c(5);
+* };
+*
**/
int
**/
int
@@
-58,7
+59,7
@@
main(void)
int i;
int i;
- init_firm ();
+ init_firm (
NULL
);
set_optimize(1);
set_opt_inline (1);
set_optimize(1);
set_opt_inline (1);
@@
-67,11
+68,11
@@
main(void)
set_opt_dead_node_elimination(1);
/*** Make basic type information for primitive type int. ***/
set_opt_dead_node_elimination(1);
/*** Make basic type information for primitive type int. ***/
- prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_
i
);
+ prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_
Is
);
/*** Make type information for the class (PRIMA). ***/
/* The type of the class */
/*** Make type information for the class (PRIMA). ***/
/* The type of the class */
- class_prima = new_type_class(
id_from_str ("PRIMA_INLINE", 5
));
+ class_prima = new_type_class(
new_id_from_str ("PRIMA_INLINE"
));
/* We need type information for pointers to the class: */
class_p_ptr = new_type_pointer (id_from_str ("class_prima_ptr", 15),
class_prima);
/* We need type information for pointers to the class: */
class_p_ptr = new_type_pointer (id_from_str ("class_prima_ptr", 15),
class_prima);
@@
-99,12
+100,12
@@
main(void)
owner is the global type. */
owner = get_glob_type();
/* Main has zero parameters and one result. */
owner is the global type. */
owner = get_glob_type();
/* Main has zero parameters and one result. */
- proc_main = new_type_method(id_from_str("
main", 4
), 0, 1);
+ proc_main = new_type_method(id_from_str("
OO_INLINE_EXAMPLE_main", 22
), 0, 1);
/* The result type is int. */
set_method_res_type(proc_main, 0, prim_t_int);
/* The entity for main. */
/* The result type is int. */
set_method_res_type(proc_main, 0, prim_t_int);
/* The entity for main. */
- proc_main_e = new_entity (owner, id_from_str ("
main", 4
), proc_main);
+ proc_main_e = new_entity (owner, id_from_str ("
OO_INLINE_EXAMPLE_main", 22
), proc_main);
/** Build code for procedure main. **/
/* We need one local variable (for "o"). */
/** Build code for procedure main. **/
/* We need one local variable (for "o"). */
@@
-115,26
+116,27
@@
main(void)
set_irp_main_irg(main_irg);
/* Make the constants. They are independent of a block. */
set_irp_main_irg(main_irg);
/* Make the constants. They are independent of a block. */
- c2 = new_Const (mode_
i, tarval_from_long (mode_i, 2
));
- c5 = new_Const (mode_
i, tarval_from_long (mode_i, 5
));
+ c2 = new_Const (mode_
Is, new_tarval_from_long (2, mode_Is
));
+ c5 = new_Const (mode_
Is, new_tarval_from_long (5, mode_Is
));
/* There is only one block in main, it contains the allocation and the calls. */
/* Allocate the defined object and generate the type information. */
/* There is only one block in main, it contains the allocation and the calls. */
/* Allocate the defined object and generate the type information. */
- obj_size = new_SymConst((type_or_id_p)class_prima, size);
+ symconst_symbol sym = { class_prima };
+ obj_size = new_SymConst(sym, symconst_size);
obj_o = new_Alloc(get_store(), obj_size, class_prima, heap_alloc);
set_store(new_Proj(obj_o, mode_M, 0)); /* make the changed memory visible */
obj_o = new_Alloc(get_store(), obj_size, class_prima, heap_alloc);
set_store(new_Proj(obj_o, mode_M, 0)); /* make the changed memory visible */
- obj_o = new_Proj(obj_o, mode_
p
, 2); /* remember the pointer to the object */
+ obj_o = new_Proj(obj_o, mode_
P
, 2); /* remember the pointer to the object */
set_value(o_pos, obj_o);
/* Get the pointer to the procedure from the object. */
proc_ptr = new_simpleSel(get_store(), /* The memory containing the object. */
set_value(o_pos, obj_o);
/* Get the pointer to the procedure from the object. */
proc_ptr = new_simpleSel(get_store(), /* The memory containing the object. */
- get_value(o_pos, mode_
p
),/* The pointer to the object. */
+ get_value(o_pos, mode_
P
),/* The pointer to the object. */
proc_set_a_e ); /* The feature to select. */
/* Call procedure set_a, first built array with parameters. */
{
ir_node *in[2];
proc_set_a_e ); /* The feature to select. */
/* Call procedure set_a, first built array with parameters. */
{
ir_node *in[2];
- in[0] = get_value(o_pos, mode_
p
);
+ in[0] = get_value(o_pos, mode_
P
);
in[1] = c2;
set_a_call = new_Call(get_store(), proc_ptr, 2, in, proc_set_a);
in[1] = c2;
set_a_call = new_Call(get_store(), proc_ptr, 2, in, proc_set_a);
@@
-143,12
+145,12
@@
main(void)
set_store(new_Proj(set_a_call, mode_M, 0));
/* Get the pointer to the nest procedure from the object. */
set_store(new_Proj(set_a_call, mode_M, 0));
/* Get the pointer to the nest procedure from the object. */
- proc_ptr = new_simpleSel(get_store(), get_value(o_pos, mode_
p
), proc_c_e);
+ proc_ptr = new_simpleSel(get_store(), get_value(o_pos, mode_
P
), proc_c_e);
/* call procedure c, first built array with parameters */
{
ir_node *in[2];
/* call procedure c, first built array with parameters */
{
ir_node *in[2];
- in[0] = get_value(o_pos, mode_
p
);
+ in[0] = get_value(o_pos, mode_
P
);
in[1] = c5;
c_call = new_Call(get_store(), proc_ptr, 2, in, proc_c);
}
in[1] = c5;
c_call = new_Call(get_store(), proc_ptr, 2, in, proc_c);
}
@@
-156,7
+158,7
@@
main(void)
set_store(new_Proj(c_call, mode_M, 0));
/* Get the result of the procedure: select the result tuple from the call,
then the proper result from the tuple. */
set_store(new_Proj(c_call, mode_M, 0));
/* Get the result of the procedure: select the result tuple from the call,
then the proper result from the tuple. */
- res = new_Proj(new_Proj(c_call, mode_T, 2), mode_
i
, 0);
+ res = new_Proj(new_Proj(c_call, mode_T, 2), mode_
Is
, 0);
/* return the results of procedure main */
{
/* return the results of procedure main */
{
@@
-182,9
+184,9
@@
main(void)
self_pos = 0; e_pos = 1;
/* get the procedure parameter */
self_pos = 0; e_pos = 1;
/* get the procedure parameter */
- self = new_Proj(get_irg_args(set_a_irg), mode_
p
, 0);
+ self = new_Proj(get_irg_args(set_a_irg), mode_
P
, 0);
set_value(self_pos, self);
set_value(self_pos, self);
- par1 = new_Proj(get_irg_args(set_a_irg), mode_
i
, 1);
+ par1 = new_Proj(get_irg_args(set_a_irg), mode_
Is
, 1);
set_value(e_pos, par1);
/* Create and select the entity to set */
a_ptr = new_simpleSel(get_store(), self, a_e);
set_value(e_pos, par1);
/* Create and select the entity to set */
a_ptr = new_simpleSel(get_store(), self, a_e);
@@
-211,11
+213,11
@@
main(void)
c_irg = new_ir_graph (proc_c_e, 5);
/* get the procedure parameter */
c_irg = new_ir_graph (proc_c_e, 5);
/* get the procedure parameter */
- self = new_Proj(get_irg_args(c_irg), mode_
p
, 0);
+ self = new_Proj(get_irg_args(c_irg), mode_
P
, 0);
set_value(0, self);
set_value(0, self);
- par1 = new_Proj(get_irg_args(c_irg), mode_
i
, 1);
+ par1 = new_Proj(get_irg_args(c_irg), mode_
Is
, 1);
set_value(1, par1);
set_value(1, par1);
- set_value(2, new_Const (mode_
i, tarval_from_long (mode_i, 0
)));
+ set_value(2, new_Const (mode_
Is, new_tarval_from_long (0, mode_Is
)));
x = new_Jmp();
mature_block (get_irg_current_block(c_irg));
x = new_Jmp();
mature_block (get_irg_current_block(c_irg));
@@
-223,12
+225,12
@@
main(void)
/* generate a block for the loop header and the conditional branch */
r = new_immBlock ();
add_in_edge (r, x);
/* generate a block for the loop header and the conditional branch */
r = new_immBlock ();
add_in_edge (r, x);
- x = new_Cond (new_Proj(new_Cmp(new_Const (mode_
i, tarval_from_long (mode_i, 0
)),
- new_Const (mode_
i, tarval_from_long (mode_i, 0
))),
+ x = new_Cond (new_Proj(new_Cmp(new_Const (mode_
Is, new_tarval_from_long (0, mode_Is
)),
+ new_Const (mode_
Is, new_tarval_from_long (0, mode_Is
))),
mode_b, Eq));
mode_b, Eq));
- /* x = new_Cond (new_Proj(new_Cmp(new_Const (mode_
i, tarval_from_long (mode_i, 0
)),
- get_value(1, mode_
i
)),
+ /* x = new_Cond (new_Proj(new_Cmp(new_Const (mode_
Is, new_tarval_from_long (0, mode_Is
)),
+ get_value(1, mode_
Is
)),
mode_b, Eq));*/
f = new_Proj (x, mode_X, 0);
t = new_Proj (x, mode_X, 1);
mode_b, Eq));*/
f = new_Proj (x, mode_X, 0);
t = new_Proj (x, mode_X, 1);
@@
-240,11
+242,11
@@
main(void)
/* The code in the loop body,
as we are dealing with local variables only the dataflow edges
are manipulated. */
/* The code in the loop body,
as we are dealing with local variables only the dataflow edges
are manipulated. */
- set_value (3, get_value (1, mode_
i
));
- set_value (1, get_value (2, mode_
i
));
- set_value (2, get_value (3, mode_
i
));
+ set_value (3, get_value (1, mode_
Is
));
+ set_value (1, get_value (2, mode_
Is
));
+ set_value (2, get_value (3, mode_
Is
));
a_ptr = new_simpleSel(get_store(), self, a_e);
a_ptr = new_simpleSel(get_store(), self, a_e);
- set_store(new_Store(get_store(), a_ptr, get_value(2, mode_
i
)));
+ set_store(new_Store(get_store(), a_ptr, get_value(2, mode_
Is
)));
x = new_Jmp ();
add_in_edge(r, x);
mature_block (b);
x = new_Jmp ();
add_in_edge(r, x);
mature_block (b);
@@
-257,12
+259,12
@@
main(void)
a_ptr = new_simpleSel(get_store(), self, a_e);
a_val = new_Load(get_store(), a_ptr);
set_store(new_Proj(a_val, mode_M, 0));
a_ptr = new_simpleSel(get_store(), self, a_e);
a_val = new_Load(get_store(), a_ptr);
set_store(new_Proj(a_val, mode_M, 0));
- a_val = new_Proj(a_val, mode_
i
, 2);
+ a_val = new_Proj(a_val, mode_
Is
, 2);
/* return the result */
{
ir_node *in[1];
/* return the result */
{
ir_node *in[1];
- in[0] = new_Add(par1, a_val, mode_
i
);
+ in[0] = new_Add(par1, a_val, mode_
Is
);
x = new_Return (get_store (), 1, in);
}
x = new_Return (get_store (), 1, in);
}
@@
-282,7
+284,7
@@
main(void)
current_ir_graph = main_irg;
printf("Inlining set_a ...\n");
inline_method(set_a_call, set_a_irg);
current_ir_graph = main_irg;
printf("Inlining set_a ...\n");
inline_method(set_a_call, set_a_irg);
- printf("I
NLINE
ing c ...\n");
+ printf("I
nline
ing c ...\n");
inline_method(c_call, c_irg);
printf("Optimizing ...\n");
inline_method(c_call, c_irg);
printf("Optimizing ...\n");
@@
-293,6
+295,9
@@
main(void)
}
printf("Dumping graphs of all procedures and a type graph.\n");
}
printf("Dumping graphs of all procedures and a type graph.\n");
+ /* Touch ld names to distinguish names from oo_inline names. */
+ get_entity_ld_ident(proc_set_a_e);
+ get_entity_ld_ident(proc_c_e);
turn_off_edge_labels();
dump_all_ir_graphs(dump_ir_block_graph);
dump_all_ir_graphs(dump_ir_block_graph_w_types);
turn_off_edge_labels();
dump_all_ir_graphs(dump_ir_block_graph);
dump_all_ir_graphs(dump_ir_block_graph_w_types);
@@
-300,5
+305,5
@@
main(void)
printf("Use xvcg to view these graphs:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
printf("Use xvcg to view these graphs:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
- return (
1
);
+ return (
0
);
}
}