X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=testprograms%2Foo_inline_example.c;h=d8ba70c3192a484f8d34a2dbeca25585e97ab7cf;hb=0eb9e8a7def8f3003527c59013190344d27f38f2;hp=69bdb2531d707f30ceccea0fa49215f5d1273773;hpb=6ed168c29789db8edf25c87f2da9164c49a5512c;p=libfirm diff --git a/testprograms/oo_inline_example.c b/testprograms/oo_inline_example.c index 69bdb2531..d8ba70c31 100644 --- 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 # include @@ -16,28 +17,28 @@ # 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 @@ -58,7 +59,7 @@ main(void) int i; - init_firm (); + init_firm (NULL); set_optimize(1); set_opt_inline (1); @@ -71,7 +72,7 @@ main(void) /*** 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); @@ -99,12 +100,12 @@ main(void) 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. */ - 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"). */ @@ -115,12 +116,13 @@ main(void) set_irp_main_irg(main_irg); /* Make the constants. They are independent of a block. */ - c2 = new_Const (mode_Is, tarval_from_long (mode_Is, 2)); - c5 = new_Const (mode_Is, tarval_from_long (mode_Is, 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. */ - 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_Proj(obj_o, mode_P, 2); /* remember the pointer to the object */ @@ -215,7 +217,7 @@ main(void) set_value(0, self); par1 = new_Proj(get_irg_args(c_irg), mode_Is, 1); set_value(1, par1); - set_value(2, new_Const (mode_Is, tarval_from_long (mode_Is, 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)); @@ -223,11 +225,11 @@ main(void) /* 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_Is, tarval_from_long (mode_Is, 0)), - new_Const (mode_Is, tarval_from_long (mode_Is, 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)); - /* x = new_Cond (new_Proj(new_Cmp(new_Const (mode_Is, tarval_from_long (mode_Is, 0)), + /* 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); @@ -282,7 +284,7 @@ main(void) current_ir_graph = main_irg; printf("Inlining set_a ...\n"); inline_method(set_a_call, set_a_irg); - printf("INLINEing c ...\n"); + printf("Inlineing c ...\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"); + /* 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);