[svn:parrot] r40076 - in branches/ops_pct/compilers/opsc: . ops t

cotto at svn.parrot.org cotto at svn.parrot.org
Tue Jul 14 07:44:50 UTC 2009


Author: cotto
Date: Tue Jul 14 07:44:50 2009
New Revision: 40076
URL: https://trac.parrot.org/parrot/changeset/40076

Log:
[opsc] start working on a generate_runcores stage to transform the past into C runcore code

Modified:
   branches/ops_pct/compilers/opsc/ops/oplib.pm
   branches/ops_pct/compilers/opsc/opsc_core.pir
   branches/ops_pct/compilers/opsc/t/04-oplib_parse_ops.t

Modified: branches/ops_pct/compilers/opsc/ops/oplib.pm
==============================================================================
--- branches/ops_pct/compilers/opsc/ops/oplib.pm	Tue Jul 14 05:59:14 2009	(r40075)
+++ branches/ops_pct/compilers/opsc/ops/oplib.pm	Tue Jul 14 07:44:50 2009	(r40076)
@@ -30,7 +30,7 @@
 
 Op files. Mandatory argument of C<BUILD> method.
 
-=item * C<@.ops>
+=item * C<@.ops_past>
 
 List of parsed ops. Currently as C<PAST::Block>, but we probably will use
 more specific class inherited from C<PAST::Block> to provide some helper
@@ -97,28 +97,35 @@
         die("We need some files!")
     }
     self<files>      := @files;
-    self<num_file>   := $num_file  || 'src/ops/ops.num';
-    self<skip_file>  := $skip_file || 'src/ops/ops.skip';
+    self<num_file>   := $num_file  || '../../src/ops/ops.num';
+    self<skip_file>  := $skip_file || '../../src/ops/ops.skip';
 
     # Initialize self.
     self<max_op_num> := 0;
     self<optable>    := hash();
     self<skiptable>  := hash();
-    self<ops>        := <>;
+    self<ops_past>   := <>;
+
+    self.load_op_map_files();
+
+    #split ops_past into ops
+    self.build_ops();
 
     self;
 }
 
 =item C<parse_ops>
 
-Parse all ops files passed to BUILD method. Create self.ops list for parsed ops.
+Parse all ops files passed to BUILD method. Create self.ops list for parsed
+ops.  This function is used primarily for testing.  When invoked directly, the
+HLLCompiler sets the past directly.
 
 =cut
 
 method parse_ops() {
     for self.files() {
         for @(self.parse_ops_file($_)) {
-            self<ops>.push($_);
+            self<ops_past>.push($_);
         }
     }
 }
@@ -138,6 +145,15 @@
     $past<ops>;
 }
 
+=item C<set_ops_past>
+
+Assign an already-constructed past tree to self.
+
+=cut
+
+method set_ops_past($past) {
+    self<ops_past> := past;
+}
 
 =item C<load_op_map_files>
 
@@ -150,6 +166,60 @@
     self._load_skip_file();
 }
 
+=item C<build_ops>
+
+Take C<ops_past> and do any runcore-agnostic processing on it.  This means such
+things as expanding opcodes with C<in> params into multiple functions,
+determining jump flags, etc.
+
+=cut
+
+method build_ops() {
+    
+    #ops.num is guaranteed not to have any holes, but the ordering also comes
+    #from all the .ops files catted together.  It should be sufficient to go
+    #through the past, expanding ops to opfuncs as necessary and simply
+    #verifying that they end up with the right number.  A special case is
+    #experimental.ops, which don't appear in ops.num.
+
+    my $op_num := 0;
+
+    for self<ops_past> {
+        my $cur_op := $_;
+        my $jump_flags := self.get_jump_flags($cur_op);
+        #figure out all the constant data: flags, name, etc
+        #build an array of args
+        #$args := [ [] ];
+        #for eq:
+        #     [ [ {'dir'=>'in', 'type'=>'ic', 'label'=>0}, {'dir'=>'in', 'type'=>'i', 'label'=>0} ] , ...
+
+
+
+        #check for any skiplisted long opnames before adding them to ops
+
+    }
+
+    #'JUMP' => '0',
+    #'NAME' => 'end',
+    #'FLAGS' => {
+    #    '' => undef,
+    #    'flow' => undef,
+    #    'check_event' => undef,
+    #    'base_core' => undef
+    #},
+    #'ARGDIRS' => [],
+    #'TYPE' => 'inline',
+    #'CODE' => 0,
+    #'ARGS' => [],
+    #'BODY' => '#line 53 "src/ops/core.ops"
+    #{{=0}};
+    #',
+    #'LABELS' => []
+
+
+}
+
+
 method _load_num_file() {
     # slurp isn't very efficient. But extending NQP beyond bare minimum is not in scope.
     my $buf := slurp(self<num_file>);
@@ -206,7 +276,7 @@
 
 =over 4
 
-=item * C<ops>
+=item * C<ops_past>
 
 =item * C<files>
 
@@ -218,8 +288,8 @@
 
 =cut
 
-method ops() {
-    self<ops>;
+method ops_past() {
+    self<ops_past>;
 }
 
 method files() {

Modified: branches/ops_pct/compilers/opsc/opsc_core.pir
==============================================================================
--- branches/ops_pct/compilers/opsc/opsc_core.pir	Tue Jul 14 05:59:14 2009	(r40075)
+++ branches/ops_pct/compilers/opsc/opsc_core.pir	Tue Jul 14 07:44:50 2009	(r40076)
@@ -20,14 +20,31 @@
     $P0.'removestage'('post')
     $P0.'removestage'('pir')
     $P0.'removestage'('evalpmc')
-    $P0.'addstage'('exit', 'after'=>'past')
+    $P0.'addstage'('generate_runcores', 'after'=>'past')
 
 .end
 
-.sub 'exit' :method
+.sub 'generate_runcores' :method
     .param pmc past
     .param pmc adverbs :slurpy :named
 
+    .local pmc oplib, files
+
+    $P0 = find_caller_lex "$?FILES"
+    $S0 = $P0
+    files = split " ", $S0
+    #do oplib stuff
+    # - make an oplib
+    $P0 = get_hll_global ['Ops'], 'OpLib'
+    oplib = $P0.'new'()
+    #use default location for ops.num and ops.skip for now
+    oplib.'BUILD'(files :named("files"))
+    oplib.'set_ops_past'(past)
+
+    #for each runcore
+    # * make a clone of the op tree
+    # * call the runcore with it 
+
     exit 0
 .end
 

Modified: branches/ops_pct/compilers/opsc/t/04-oplib_parse_ops.t
==============================================================================
--- branches/ops_pct/compilers/opsc/t/04-oplib_parse_ops.t	Tue Jul 14 05:59:14 2009	(r40075)
+++ branches/ops_pct/compilers/opsc/t/04-oplib_parse_ops.t	Tue Jul 14 07:44:50 2009	(r40076)
@@ -24,9 +24,8 @@
 
 # 86 core
 # 116 math
-ok(+($lib.ops) == 86 + 116, "ops file parsed");
+ok(+($lib.ops_past) == 86 + 116, "ops file parsed");
 
-$lib.load_op_map_files();
 # It's 1258 currently. But testing for exact match isn't nessary.
 ok( $lib.max_op_num > 1200, "ops.num file parsed");
 


More information about the parrot-commits mailing list