[svn:parrot] r43246 - in branches/pirc_config: . compilers/pirc config/gen/makefiles config/init lib/Parrot/Configure/Options lib/Parrot/Configure/Options/Conf lib/Parrot/Configure/Step

coke at svn.parrot.org coke at svn.parrot.org
Sat Dec 26 15:42:35 UTC 2009


Author: coke
Date: Sat Dec 26 15:42:34 2009
New Revision: 43246
URL: https://trac.parrot.org/parrot/changeset/43246

Log:
first pass. adds --pirc=(pirc|imcc) and has that set a -Define;
nothing yet done with the -Define.

Added:
   branches/pirc_config/config/init/pirc.pm
Modified:
   branches/pirc_config/Configure.pl
   branches/pirc_config/DEPRECATED.pod
   branches/pirc_config/compilers/pirc/README.pod
   branches/pirc_config/config/gen/makefiles/root.in
   branches/pirc_config/config/init/defaults.pm
   branches/pirc_config/lib/Parrot/Configure/Options/Conf.pm
   branches/pirc_config/lib/Parrot/Configure/Options/Conf/Shared.pm
   branches/pirc_config/lib/Parrot/Configure/Step/List.pm

Modified: branches/pirc_config/Configure.pl
==============================================================================
--- branches/pirc_config/Configure.pl	Sat Dec 26 15:39:16 2009	(r43245)
+++ branches/pirc_config/Configure.pl	Sat Dec 26 15:42:34 2009	(r43246)
@@ -327,6 +327,10 @@
 
 =over 4
 
+=item C<--pirc=(imcc|pirc)>
+
+Select the compiler to use for compiling PIR and PASM (Defaults to imcc).
+
 =item C<--intval=(type)>
 
 Use the given type for C<INTVAL>.

Modified: branches/pirc_config/DEPRECATED.pod
==============================================================================
--- branches/pirc_config/DEPRECATED.pod	Sat Dec 26 15:39:16 2009	(r43245)
+++ branches/pirc_config/DEPRECATED.pod	Sat Dec 26 15:42:34 2009	(r43246)
@@ -33,6 +33,17 @@
  .include 'warnings.pasm'
  warningson .PARROT_WARNINGS_DEPRECATED_FLAG
 
+=head1 Configuration
+
+=over 4
+
+=item C<--pirc> option [experimental]
+
+This option allows the developer to switch between using IMCC and PIRC.
+PIRC is considered experimental and is not supported.
+
+=back 
+
 =head1 PMCS
 
 =over 4

Modified: branches/pirc_config/compilers/pirc/README.pod
==============================================================================
--- branches/pirc_config/compilers/pirc/README.pod	Sat Dec 26 15:39:16 2009	(r43245)
+++ branches/pirc_config/compilers/pirc/README.pod	Sat Dec 26 15:42:34 2009	(r43246)
@@ -3,11 +3,11 @@
 
 =head1 NAME
 
-README.txt - Readme file for PIRC compiler.
+README.pod - Readme file for PIRC compiler.
 
 =head1 DESCRIPTION
 
-PIRC is a fresh implementation of the PIR language using Bison and Flex.
+PIRC is an implementation of the PIR language using Bison and Flex.
 Its main features are:
 
 =over 4
@@ -28,39 +28,13 @@
 
 =head2 Compiling and Running
 
-=head3 Windows using Microsoft Visual Studio
+to use pirc as the pir compiler for parrot, use:
 
-To compile PIRC on windows using MSVC:
-
-   nmake
-
-When running PIRC, it needs the shared library C<libparrot>; an easy way to do
-this is copy C<libparrot.dll> in the Parrot root directory to C<compilers/pirc/src>.
-
-Running PIRC is as easy as:
-
- pirc test.pir
-
-See 'pirc -h' for help.
-
-=head3 Linux using GCC
-
-The Makefile should work fine on Linux:
-
- cd compilers/pirc && make
-
-When running PIRC, it needs the shared library C<libparrot>; in order to let
-PIRC find it, set the path as follows:
-
- export LD_LIBRARY_PATH=../../../blib/lib
-
-Running is as easy as:
-
- ./pirc test.pir
+ perl Configure.pl --pirc=pirc
 
 =head2 Overview
 
-The new Bison/Flex based implementation of the PIR compiler is designed
+This Bison/Flex based implementation of the PIR compiler is designed
 as a two-stage compiler:
 
 =over 4
@@ -95,16 +69,18 @@
    $S0 = "This is a heredoc string\n  divided\n    over\n      five\n        lines.\n"
  .end
 
-In order to allow C<.include>d file to have heredoc strings, the heredoc preprocessor
-also handles the C<.include> directive, even though logically this is a macro function.
-See the discussion below for how the C<.include> directive works.
+In order to allow C<.include>d file to have heredoc strings, the heredoc
+preprocessor also handles the C<.include> directive, even though logically
+this is a macro function.  See the discussion below for how the C<.include>
+directive works.
 
 =head2 PIR compilers
 
-The PIR compiler parses the output of the heredoc preprocessor. PIRC's lexer also
-handles macros.
+The PIR compiler parses the output of the heredoc preprocessor. PIRC's lexer
+also handles macros.
 
-The macro layer basically implements text replacements. The following directives are handled:
+The macro layer basically implements text replacements. The following
+directives are handled:
 
 =over 4
 
@@ -120,9 +96,10 @@
 
 =head3 C<.include>
 
-The C<.include> directive takes a string argument, which is the name of a file. The
-contents of this file are inserted at the point where the C<.include> directive
-is written. To illustrate this, consider the following example:
+The C<.include> directive takes a string argument, which is the name of a
+file. The contents of this file are inserted at the point where the
+C<.include> directive is written. To illustrate this, consider the following
+example:
 
  main.pir:
  ========================
@@ -206,8 +183,8 @@
  set $I0, 42
 
 will select the C<set_i_ic> instruction: this is the C<set> instruction, taking
-an integer (i) result operand and an integer constant (ic) operand. Other examples
-are:
+an integer (i) result operand and an integer constant (ic) operand. Other
+examples include:
 
  $P0[1] = 42           --> set_p_kic_ic # kic = key integer constant
  $I0 = $P0["hi"]       --> set_i_p_kc   # kc = key constant from constant table
@@ -278,23 +255,19 @@
 
  add $I0, $I0, 1
 
-Again, in C one would write (again ignoring the valid identifier issue): C<$I0++>,
-or in other words, C<incrementing> the given identifier. Parrot has C<inc> and C<dec>
-instructions built-in as well, so that the above statement C<$I0 = $I0 + 1> can be
-optimized to:
+Again, in C one would write (again ignoring the valid identifier issue):
+C<$I0++>, or in other words, C<incrementing> the given identifier. Parrot has
+C<inc> and C<dec> instructions built-in as well, so that the above statement
+C<$I0 = $I0 + 1> can be optimized to:
 
  inc $I0
 
 =head3 Vanilla Register Allocator
 
 The PIR compiler implements a vanilla register allocator. This means that each
-declared C<.local> or C<.param> symbol, and each PIR register ($Px, $Sx, $Ix, $Nx)
-is assigned a unique PASM register, that is associated with the original symbol
-or PIR register throughout the subroutine.
-
-PIRC has a register optimizer, which can optimize the register usage. Run PIRC
-with the C<-r> option to activate this. The register optimizer is implemented
-using a Linear Scan Register allocator.
+declared C<.local> or C<.param> symbol, and each PIR register ($Px, $Sx, $Ix,
+$Nx) is assigned a unique PASM register, that is associated with the original
+symbol or PIR register throughout the subroutine.
 
 The implementation of the vanilla register allocator is done in the PIR symbol
 management module (C<pirsymbol.c>).
@@ -302,6 +275,8 @@
 =head2 Register optimizer
 
 PIRC has a register optimizer, which uses a Linear Scan Register algorithm.
+Run parrot with the C<-r> option to enable it.
+
 For each symbolic register, a live-interval object is created, which has
 an I<start> and I<end> point, indicating the first and last usage of that
 symbolic register in the sub. The register optimizer figures out when
@@ -313,7 +288,6 @@
 Bytecode generation is done, but there is the occasional bug. These
 are reported in trac.parrot.org.
 
-
 =head1 IMPLEMENTATION
 
 The directory compilers/pirc has a number of subdirectories:
@@ -322,18 +296,22 @@
 
 =item doc - contains documentation.
 
-=item heredoc - contains the implementation of the heredoc preprocessor. This is now
-integrated with pirc/src. It now only has a driver program to build a stand-alone
-heredoc preprocessor.
+=item heredoc - contains the implementation of the heredoc preprocessor.
+
+This is now integrated with pirc/src. It now only has a driver program to
+build a stand-alone heredoc preprocessor.
 
 =item src - contains the Bison/Flex implementation of PIRC
 
-=item t - for tests. Tests input is fed into Parrot after compilation,
+=item t - for tests.
+
+Tests input is fed into Parrot after compilation,
 which will run the code.
 
-=item macro - contains the old implementation of the macro preprocessor. This is now
-integrated with pirc/src. These files are kept as a reference until the macro
-preprocessor in pirc/src is completed.
+=item macro - contains the old implementation of the macro preprocessor.
+
+This is now integrated with pirc/src. These files are kept as a reference
+until the macro preprocessor in pirc/src is completed.
 
 =back
 
@@ -368,9 +346,9 @@
 
 =head2 Cygwin processable lexer spec.
 
-The file C<pir.l> from which the lexer is generated is I<not> processable by Cygwin's
-default version of Flex. In order to make a reentrant lexer, a newer version is needed,
-which can be downloaded from the link below.
+The file C<pir.l> from which the lexer is generated is I<not> processable by
+Cygwin's default version of Flex. In order to make a reentrant lexer, a newer
+version is needed, which can be downloaded from
 
 L<http://sourceforge.net/project/downloading.php?groupname=flex&filename=flex-2.5.33.tar.gz&use_mirror=belnet>
 
@@ -383,9 +361,7 @@
 
 =head1 BUGS
 
-Having a look at this implementation would be greatly appreciated, and any resulting
-feedback even more :-). Please post bug reports in trac.parrot.org.
-
+Please post bug reports in trac.parrot.org.
 
 =head1 SEE ALSO
 

Modified: branches/pirc_config/config/gen/makefiles/root.in
==============================================================================
--- branches/pirc_config/config/gen/makefiles/root.in	Sat Dec 26 15:39:16 2009	(r43245)
+++ branches/pirc_config/config/gen/makefiles/root.in	Sat Dec 26 15:42:34 2009	(r43246)
@@ -468,7 +468,8 @@
     $(IO_O_FILES) \
     $(CLASS_O_FILES) \
     $(ENCODING_O_FILES) \
-    $(IMCC_O_FILES)
+    $(IMCC_O_FILES) \
+    $(PIRC_O_FILES)
 
 OPS_FILES := @ops@ $(GEN_OPSFILES)
 
@@ -487,8 +488,9 @@
 PDB                 := $(CUR_DIR)/parrot_debugger$(EXE)
 PBC_TO_EXE          := $(CUR_DIR)/pbc_to_exe$(EXE)
 PARROT_CONFIG       := $(CUR_DIR)/parrot_config$(EXE)
-PIRC                := $(CUR_DIR)/pirc$(EXE)
 NQP                 := $(CUR_DIR)/parrot-nqp$(EXE)
+# XXX Eventually eliminate this, as it should be bundled in PARROT
+PIRC                := $(CUR_DIR)/pirc$(EXE)
 
 # Installable executables
 INSTALLABLEPARROT   := $(CUR_DIR)/installable_parrot$(EXE)

Modified: branches/pirc_config/config/init/defaults.pm
==============================================================================
--- branches/pirc_config/config/init/defaults.pm	Sat Dec 26 15:39:16 2009	(r43245)
+++ branches/pirc_config/config/init/defaults.pm	Sat Dec 26 15:42:34 2009	(r43246)
@@ -264,6 +264,8 @@
 
     $conf->data->set( 'archname', $Config{archname});
 
+    $conf->data->set( 'pirc', 'imcc'); 
+
     # adjust archname, cc and libs for e.g. --m=32
     # remember corrected archname - jit.pm was using $Config('archname')
     _64_bit_adjustments($conf);

Added: branches/pirc_config/config/init/pirc.pm
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ branches/pirc_config/config/init/pirc.pm	Sat Dec 26 15:42:34 2009	(r43246)
@@ -0,0 +1,63 @@
+# Copyright (C) 2009, Parrot Foundation.
+# $Id: $
+
+=head1 NAME
+
+config/init/pirc.pm - select between IMCC and PIRC for PIR compilation
+
+=head1 DESCRIPTION
+
+Determines whether the default of 'imcc' should be overridden. Temporary
+step to get us using pirc.
+
+=cut
+
+package init::pirc;
+
+use strict;
+use warnings;
+
+use base qw(Parrot::Configure::Step);
+
+use Parrot::Configure::Step;
+#use Parrot::Configure::Utils ':gen';
+
+sub _init {
+    my $self = shift;
+    my %data;
+    $data{description} = q{Select PIR compiler};
+    $data{result}      = q{};
+    return \%data;
+}
+
+sub runstep {
+    my ( $self, $conf ) = @_;
+
+
+    my $opt = $conf->options->get('pirc');
+    if (defined($opt) )  {
+        $conf->data->set('pirc', $opt);
+    }
+
+    my $pirc = $conf->data->get('pirc');
+    if ($pirc ne 'imcc' && $pirc ne 'pirc') {
+        warn "\ninvalid --pirc='$pirc': must be imcc or pirc\n";
+        exit 1;
+    }
+
+    if ($pirc eq 'pirc') {
+        $conf->data->add(' ', 'ccflags', '-DPARROT_PIRC_COMPILER=pirc');
+    }
+ 
+    $self->set_result($pirc);
+    return 1;
+}
+
+1;
+
+# Local Variables:
+#   mode: cperl
+#   cperl-indent-level: 4
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:

Modified: branches/pirc_config/lib/Parrot/Configure/Options/Conf.pm
==============================================================================
--- branches/pirc_config/lib/Parrot/Configure/Options/Conf.pm	Sat Dec 26 15:39:16 2009	(r43245)
+++ branches/pirc_config/lib/Parrot/Configure/Options/Conf.pm	Sat Dec 26 15:42:34 2009	(r43246)
@@ -86,6 +86,7 @@
 
 Parrot Options:
 
+   --pirc=(imcc|pirc)   Select compiler to use for PIR (defaults to imcc)
    --intval=(type)      Use the given type for INTVAL
    --floatval=(type)    Use the given type for FLOATVAL
    --opcode=(type)      Use the given type for opcodes

Modified: branches/pirc_config/lib/Parrot/Configure/Options/Conf/Shared.pm
==============================================================================
--- branches/pirc_config/lib/Parrot/Configure/Options/Conf/Shared.pm	Sat Dec 26 15:39:16 2009	(r43245)
+++ branches/pirc_config/lib/Parrot/Configure/Options/Conf/Shared.pm	Sat Dec 26 15:42:34 2009	(r43246)
@@ -60,6 +60,7 @@
     ops
     optimize
     parrot_is_shared
+    pirc
     prefix
     profile
     sbindir

Modified: branches/pirc_config/lib/Parrot/Configure/Step/List.pm
==============================================================================
--- branches/pirc_config/lib/Parrot/Configure/Step/List.pm	Sat Dec 26 15:39:16 2009	(r43245)
+++ branches/pirc_config/lib/Parrot/Configure/Step/List.pm	Sat Dec 26 15:42:34 2009	(r43246)
@@ -13,6 +13,7 @@
     init::install
     init::hints
     init::headers
+    init::pirc
     inter::progs
     inter::make
     inter::lex


More information about the parrot-commits mailing list