/* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
-** All rights reserved.
-**
-** Authors: Goetz Lindenmaier
-**
-** testprogram.
+* All rights reserved.
+*
+* Authors: Goetz Lindenmaier
+*
+* testprogram.
*/
# include <string.h>
# include "irdump.h"
# include "firm.h"
-/** This example describes a possible representation of heap allocated
-*** variables of imperative programs.
-*** It constructs the IR for the following program:
-***
-***
-*** main(): int
-*** int *a[10];
-***
-*** a = malloc(sizeof(a[10]));
-*** return (a[3]);
-*** end;
-***
-*** The array is placed on the heap. The pointer to the array that
-*** is a local variable is represented as a dataflow edge.
-*** There are two ways to model allocation to the heap in programs with
-*** explicit memory allocation:
-*** 1. Model the calls to malloc and free as simple procedure (of compiler
-*** known procedures returning a pointer. This is the simpler way of
-*** generating FIRM, but restricts the information that can be deduced
-*** for the call.
-*** 2. Insert an Alloc node. A later pass can lower this to the compiler
-*** known function. This makes the allocation explicit in FIRM, supporting
-*** optimization.
-*** A problem is modeling free. There is no free node in FIRM. Is this
-*** a necessary extension?
-*** This example shows the second alternative, where the size of the array
-*** is explicitly computed.
+/**
+* variables of imperative programs.
+* It constructs the IR for the following program:
+*
+*
+* main(): int
+* int *a[10];
+*
+* a = malloc(sizeof(a[10]));
+* return (a[3]);
+* end;
+*
+* The array is placed on the heap. The pointer to the array that
+* is a local variable is represented as a dataflow edge.
+* There are two ways to model allocation to the heap in programs with
+* explicit memory allocation:
+* 1. Model the calls to malloc and free as simple procedure (of compiler
+* known procedures returning a pointer. This is the simpler way of
+* generating FIRM, but restricts the information that can be deduced
+* for the call.
+* 2. Insert an Alloc node. A later pass can lower this to the compiler
+* known function. This makes the allocation explicit in FIRM, supporting
+* optimization.
+* A problem is modeling free. There is no free node in FIRM. Is this
+* a necessary extension?
+* This example shows the second alternative, where the size of the array
+* is explicitly computed.
**/
#define OPTIMIZE_NODE 0
/* first build procedure main */
owner = get_glob_type();
- proc_main = new_type_method(id_from_str("main", 4), 0, 1);
+ proc_main = new_type_method(id_from_str("ARRAY-HEAP_EXAMPLE_main", 23), 0, 1);
set_method_res_type(proc_main, 0, (type *)prim_t_int);
- proc_main_e = new_entity ((type*)owner, id_from_str ("main", 4), (type *)proc_main);
+ proc_main_e = new_entity ((type*)owner, id_from_str ("ARRAY-HEAP_EXAMPLE_main", 23), (type *)proc_main);
main_irg = new_ir_graph (proc_main_e, 4);
/* make type information for the array and set the bounds */