Author: jonathan
Date: Sat Jan 28 14:51:31 2006
New Revision: 11367

Modified:
   trunk/docs/imcc/syntax.pod
   trunk/t/compilers/imcc/reg/alloc.t
Log:
Documentation and a test for :non_volatile.

Modified: trunk/docs/imcc/syntax.pod
==============================================================================
--- trunk/docs/imcc/syntax.pod  (original)
+++ trunk/docs/imcc/syntax.pod  Sat Jan 28 14:51:31 2006
@@ -198,15 +198,19 @@ Define a I<compilation unit> with the la
 
 Define a I<compilation unit> containing PASM code.
 
-=item .local <type> <identifier>
+=item .local <type> <identifier> [:non_volatile]
 
 =item .sym <type> <identifier>
 
 Define a local name B<identifier> for this I<compilation unit> and of
-the given B<type>. You can define multiple identifiers of the same type by 
separating
-them with commas:
+the given B<type>. You can define multiple identifiers of the same type by
+separating them with commas:
+
   .sym int i, j
 
+The optional B<:non_volatile> modifier requests that the local is assigned a
+register that will not be re-used in the current compilation unit.
+
 =item .lex <identifier>, <reg>
 
 Declare a lexical variable that is an alias for a PMC register. The
@@ -276,7 +280,7 @@ Directives used for Parrot Calling Conve
 At the top of a subroutine, declare a local variable, in the mannter
 of B<.local>, into which parameter(s) of the current subroutine should
 be stored. Available flags:
-C<:slurpy>, C<:optional>, and C<:opt_flag>.
+C<:slurpy>, C<:optional>, C<:opt_flag> and C<:non_volatile>.
 
 =item .param <reg> [:<flag> ...]
 

Modified: trunk/t/compilers/imcc/reg/alloc.t
==============================================================================
--- trunk/t/compilers/imcc/reg/alloc.t  (original)
+++ trunk/t/compilers/imcc/reg/alloc.t  Sat Jan 28 14:51:31 2006
@@ -1,62 +1,85 @@
-#!perl -w
-# Copyright: 2005 The Perl Foundation.  All Rights Reserved.
-# $Id$
-
-use strict;
-use Parrot::Test tests => 2;
-
-pir_output_is(<<'CODE', <<'OUT', "alligator");
-# if the side-effect of set_addr/continuation isn't
-# detected this program prints "Hi\nalligator\n"
-
-.sub main :main
-    $P0 = new .String
-    $P0 = "Hi\n"
-    $I0 = 2
-lab:
-    print $P0
-    dec $I0
-    unless $I0 goto ex
-    new $P1, .Continuation
-    set_addr $P1, lab
-    $P2 = find_name "alligator"
-    set_args "(0)", $P1
-    invokecc $P2
-ex:
-.end
-.sub alligator
-    get_params "(0)", $P0
-    invokecc $P0
-.end
-CODE
-Hi
-Hi
-OUT
-
-pir_output_is(<<'CODE', <<'OUT', "alligator 2 - r9629");
-.sub xyz
-    .local pmc args
-    args = new .ResizablePMCArray
-    push args, "abc"
-    push args, "def"
-    push args, "POPME"
-
-    $S0 = args[-1]
-    if $S0 != "POPME" goto start
-    $P0 = pop args
-  start:
-    $I1 = elements args
-    $I0 = 0
-  loop:
-    if $I0 >= $I1 goto end
-    $S0 = args[$I0]
-    print $S0
-    print "\n"
-    inc $I0
-    goto loop
-  end:
-.end
-CODE
-abc
-def
-OUT
+#!perl -w

+# Copyright: 2005 The Perl Foundation.  All Rights Reserved.

+# $Id$

+

+use strict;

+use Parrot::Test tests => 3;

+

+pir_output_is(<<'CODE', <<'OUT', "alligator");

+# if the side-effect of set_addr/continuation isn't

+# detected this program prints "Hi\nalligator\n"

+

+.sub main :main

+    $P0 = new .String

+    $P0 = "Hi\n"

+    $I0 = 2

+lab:

+    print $P0

+    dec $I0

+    unless $I0 goto ex

+    new $P1, .Continuation

+    set_addr $P1, lab

+    $P2 = find_name "alligator"

+    set_args "(0)", $P1

+    invokecc $P2

+ex:

+.end

+.sub alligator

+    get_params "(0)", $P0

+    invokecc $P0

+.end

+CODE

+Hi

+Hi

+OUT

+

+pir_output_is(<<'CODE', <<'OUT', "alligator 2 - r9629");

+.sub xyz

+    .local pmc args

+    args = new .ResizablePMCArray

+    push args, "abc"

+    push args, "def"

+    push args, "POPME"

+

+    $S0 = args[-1]

+    if $S0 != "POPME" goto start

+    $P0 = pop args

+  start:

+    $I1 = elements args

+    $I0 = 0

+  loop:

+    if $I0 >= $I1 goto end

+    $S0 = args[$I0]

+    print $S0

+    print "\n"

+    inc $I0

+    goto loop

+  end:

+.end

+CODE

+abc

+def

+OUT

+

+pir_2_pasm_is(<<'CODE', <<'OUT', ":non_volatile");

+.sub main

+  .local int i :non_volatile

+  .local int j :non_volatile

+  .local int k :non_volatile

+  .local int l :non_volatile

+  i = 5

+  j = 10

+  k = i + j

+  l = k + j

+.end

+CODE

+# IMCC does produce b0rken PASM files

+# see http://[EMAIL PROTECTED]/rt3/Ticket/Display.html?id=32392

+main:

+  set I0, 5

+  set I1, 10

+  add I2, I0, I1

+  add I3, I2, I1

+  set_returns

+  returncc

+OUT

Reply via email to