1# Copyright (C) 2001-2012, Parrot Foundation. 2 3=pod 4 5=head1 NAME 6 7docs/imcc/README.pod - Readme file for IMCC. 8 9=head1 DESCRIPTION 10 11This README sets out the Intermediate Code Compiler (IMCC) for Parrot. The 12language it compiles is currently termed Parrot Intermediate Language (PIR). 13 14Why? Writing a compiler is a significant undertaking, and we are trying 15to elevate some of the burden on potential language designers, including the 16designers of the Perl6 compiler. We can provide a common back-end for Parrot 17that does the following: 18 19=over 4 20 21=over 8 22 23=item Register Allocation and Spillage 24 25=item Constant folding and expression evaluation 26 27=item Instruction selection 28 29=item Optimization 30 31=item Bytecode generation 32 33=back 34 35=back 36 37This way, language designers can get right to work on 38 39=over 4 40 41=over 8 42 43=item tokenizing, parsing, type checking AST/DAG production 44 45=back 46 47=back 48 49They, then, can simply feed PIR to IMCC which will compile directly to Parrot 50bytecode.[*] 51 52=head2 Register Allocation 53 54The allocator uses graph-coloring and du-chains to assign registers to 55lexicals and symbolic temporaries. One weakness of the allocator is the lack 56of branch analysis. A brute force method is used in the du-chain computation 57where we assume any symbol is live from the time it was first used until 58either the last time it was used or the last branch instruction. This is 59being replaced with directed graphs of basic blocks and flow analysis. 60 61=head2 Optimization 62 63We break the instructions into a directed graph of basic blocks. The plan is 64to translate to SSA form to make optimizations easier. 65 66=head2 Why C and Bison? 67 68Until Perl6 compiles itself (and does it fast), a Bison parser is the easiest 69to maintain. An additional, important benefit, is C-based parsers are pretty 70darn fast. Currently assembling Parrot on the fly is still relatively slow. 71 72Instructions not known to IMCC are looked up in parrot's op_info_table and 73must have the proper amount and types of arguments. 74 75=head1 FEEDBACK, PATCHES, etc. 76 77Please email parrot-dev@lists.parrot.org with any bug-reports or patches. 78 79=head1 AUTHORS 80 81=over 4 82 83=item Original Author: 84 85Melvin Smith <melvin.smith@mindspring.com>, <melvins@us.ibm.com> 86 87=item Contributing Authors: 88 89=over 8 90 91=item Angel Faus <afaus@corp.vlex.com> ... CFG, life analysis 92 93=item Sean O'Rourke <seano@cpan.org> ... anyop, iANY 94 95=item Leopold Toetsch <lt@toetsch.at> ... major rewrite 96 97=item .................................... numerous bugfixes/cleanup/rewrite 98 99=item .................................... optimizer.c 100 101=item .................................... run parrot code inside IMCC 102 103=item Juergen Boemmels <boemmels@physik.uni-kl.de> 104 105=item .................................... Macro preprocessor 106 107=back 108 109=back 110 111=head1 NOTE 112 113[*] So far, all the compiler does is register allocation and spilling. I like 114Steve Muchnick's MIR language, and I'm taking a few things from it. 115 116I expect the IR compiler to be FAST, simple, and maintainable, and never 117to develop featuritis; however I want it to be adequate for all languages 118targeting parrot. Did I mention it needs to be FAST? 119 120=head1 COPYRIGHT 121 122Copyright (C) 2001-2012, Parrot Foundation. 123 124=cut 125