added copyright information
[libfirm] / testprograms / if_example.c
index daf1b9c..14fa110 100644 (file)
@@ -1,9 +1,9 @@
 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
-** All rights reserved.
-**
-** Authors: Christian Schaefer, Goetz Lindenmaier
-**
-** testprogram.
+* All rights reserved.
+*
+* Authors: Christian Schaefer, Goetz Lindenmaier
+*
+* testprogram.
 */
 
 # include <stdio.h>
 # include "firm.h"
 
 /**
-***  This file constructs the ir for the following pseudo-program:
-***
-***  int main(int a) {
-***    int b = 2;
-***    if ( a == b )
-***      { a := a - 3; }
-***
-***    return a;
-***  }
+*  This file constructs the ir for the following pseudo-program:
+*
+*  int main(int a) {
+*    int b = 2;
+*    if ( a == b )
+*      { a := a - 3; }
+*
+*    return a;
+*  }
 **/
 
 int
@@ -38,10 +38,10 @@ main(void)
 
   printf("\nCreating an IR graph: IF_EXAMPLE...\n");
 
-  init_firm ();
+  init_firm (NULL);
 
 #define CLASSNAME "IF_EXAMPLE"
-#define METHODNAME "main"
+#define METHODNAME "IF_EXAMPLE_main"
 #define NRARGS 1
 #define NRES 1
 
@@ -78,7 +78,7 @@ main(void)
   set_value (a_pos, new_Proj (get_irg_args(irg), mode_Is, 0));
   /* Generate the constant and assign it to b. The assignment is resovled to a
      dataflow edge. */
-  set_value (b_pos, new_Const (mode_Is, tarval_from_long (mode_Is, 2)));
+  set_value (b_pos, new_Const (mode_Is, new_tarval_from_long (2, mode_Is)));
   /* We know all predecessors of the block and all set_values and set_stores are
      preformed.   We can mature the block.  */
   mature_block (get_irg_current_block(irg));
@@ -92,9 +92,14 @@ main(void)
   /* generate and fill the then block */
   r = new_immBlock ();
   add_in_edge (r, t);
-  a = new_Sub(get_value(a_pos, mode_Is),
-              new_Const (mode_Is, tarval_from_long (mode_Is, 3)),
+  {
+    ir_node *b,*c;
+    c = new_Const (mode_Is, new_tarval_from_long (3, mode_Is));
+    b = get_value(a_pos, mode_Is);
+    a = new_Sub(b,
+              c,
              mode_Is);
+  }
   set_value (a_pos, a);
 
   mature_block (r);