Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 122 lines (75 sloc) 2.237 kb
508a53b @bacek Add simple todo
bacek authored
1 =head1 NAME
2
3 TODO - This is the TODO file for a PIR implementation in PGE.
4
5 =head1 PARSING
6
7 Currently parsing is mostly done. Some areas require particular
8 attention:
9
10 =over 4
11
12 =item * C<var_ref>
13
14 Currently C<< <id> >> rule is overused. We need to split it into
15 C<< <id> >> and C<< <var_ref> >> rules to implement checks for
16 undeclared variables.
17
18 =item * C<heredoc>
19
20 =item * C<macro>
21
22 =back
23
24 =head1 OPTIMISING
25
26 Optimising isn't started yet. General roadmap:
27
28 =over 4
29
30 =item *
31
32 Implement PASTing.
33
34 =item *
35
36 Convert PAST to Lambda-lifted form
37
38 =item *
39
40 Optimise using full power of FP notation.
41
42 =over 4
43
44 =item *
45
46 Dead Code Elimination. E.g. unused variables, etc.
47
48 =item *
49
50 Constant propagation.
51
52 =item *
53
54 (Put more stuff here)
55
56 =back
57
58 =item *
59
60 Convert back to PAST using "lambda dropping".
61
62 =back
63
64 =head1 "Lambda lifting" and "lambda dropping"
65
66 To avoid hassles with SSA and Phi function used for analyse imperative
67 languages I'm going to convert PIR to functional representation.
68
69 Consider next PIR fragment:
70
71 # Print even values from array
72 .sub "foo"
73 .param pmc array
74 $P0 = iter array
75 loop:
76 unless $P0 goto done
77 $P1 = shift $P0
78 $I0 = $P1 % 2
79 if $I0 goto loop
80 say $P1
81 goto loop
82 done:
83
84 .end
85
86 This code can be represented as:
87
88 foo(array) =
89 $P0 = iter array
90 loop($P0)
91
92 loop($P0) =
93 unless $P0 tailcall done()
94 $P1 = shift $P0
95 $I0 = $P1 % 2
96 if $I0 tailcall loop($P0)
97 say $P1
98 tailcall loop($P0)
99
100 done() =
101
102 Every line with assignment statement introduce new "static context". RHS
103 evaluated in parent static context. LHS bind value in "child" static
104 context. Which give us next easy ways to optimise out unused variables,
105 constant propagating, etc.
106
107 After optimisation we use lambda-dropping to inline function and convert
108 it back to PAST for further processing.
109
110
111 =head1 PBC Emitting
112
113 After (or in parallel with) optimisation implementation we can start
114 work on emitting PBC directly from POST tree without serialisation to
115 PIR and invoking IMCC/PIRC. Current Packfile PMCs are robust enough for
116 generating PBC. What we'll need a some kind of "SerializableSub" for
117 generate PBC properly without attaching to current interp.
118
119 =cut
120
121
Something went wrong with that request. Please try again.