Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32 |
2 | .\" | |
3 | .\" Standard preamble: | |
4 | .\" ======================================================================== | |
5 | .de Sh \" Subsection heading | |
6 | .br | |
7 | .if t .Sp | |
8 | .ne 5 | |
9 | .PP | |
10 | \fB\\$1\fR | |
11 | .PP | |
12 | .. | |
13 | .de Sp \" Vertical space (when we can't use .PP) | |
14 | .if t .sp .5v | |
15 | .if n .sp | |
16 | .. | |
17 | .de Vb \" Begin verbatim text | |
18 | .ft CW | |
19 | .nf | |
20 | .ne \\$1 | |
21 | .. | |
22 | .de Ve \" End verbatim text | |
23 | .ft R | |
24 | .fi | |
25 | .. | |
26 | .\" Set up some character translations and predefined strings. \*(-- will | |
27 | .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left | |
28 | .\" double quote, and \*(R" will give a right double quote. | will give a | |
29 | .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to | |
30 | .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' | |
31 | .\" expand to `' in nroff, nothing in troff, for use with C<>. | |
32 | .tr \(*W-|\(bv\*(Tr | |
33 | .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' | |
34 | .ie n \{\ | |
35 | . ds -- \(*W- | |
36 | . ds PI pi | |
37 | . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch | |
38 | . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch | |
39 | . ds L" "" | |
40 | . ds R" "" | |
41 | . ds C` "" | |
42 | . ds C' "" | |
43 | 'br\} | |
44 | .el\{\ | |
45 | . ds -- \|\(em\| | |
46 | . ds PI \(*p | |
47 | . ds L" `` | |
48 | . ds R" '' | |
49 | 'br\} | |
50 | .\" | |
51 | .\" If the F register is turned on, we'll generate index entries on stderr for | |
52 | .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index | |
53 | .\" entries marked with X<> in POD. Of course, you'll have to process the | |
54 | .\" output yourself in some meaningful fashion. | |
55 | .if \nF \{\ | |
56 | . de IX | |
57 | . tm Index:\\$1\t\\n%\t"\\$2" | |
58 | .. | |
59 | . nr % 0 | |
60 | . rr F | |
61 | .\} | |
62 | .\" | |
63 | .\" For nroff, turn off justification. Always turn off hyphenation; it makes | |
64 | .\" way too many mistakes in technical documents. | |
65 | .hy 0 | |
66 | .if n .na | |
67 | .\" | |
68 | .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). | |
69 | .\" Fear. Run. Save yourself. No user-serviceable parts. | |
70 | . \" fudge factors for nroff and troff | |
71 | .if n \{\ | |
72 | . ds #H 0 | |
73 | . ds #V .8m | |
74 | . ds #F .3m | |
75 | . ds #[ \f1 | |
76 | . ds #] \fP | |
77 | .\} | |
78 | .if t \{\ | |
79 | . ds #H ((1u-(\\\\n(.fu%2u))*.13m) | |
80 | . ds #V .6m | |
81 | . ds #F 0 | |
82 | . ds #[ \& | |
83 | . ds #] \& | |
84 | .\} | |
85 | . \" simple accents for nroff and troff | |
86 | .if n \{\ | |
87 | . ds ' \& | |
88 | . ds ` \& | |
89 | . ds ^ \& | |
90 | . ds , \& | |
91 | . ds ~ ~ | |
92 | . ds / | |
93 | .\} | |
94 | .if t \{\ | |
95 | . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" | |
96 | . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' | |
97 | . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' | |
98 | . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' | |
99 | . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' | |
100 | . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' | |
101 | .\} | |
102 | . \" troff and (daisy-wheel) nroff accents | |
103 | .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' | |
104 | .ds 8 \h'\*(#H'\(*b\h'-\*(#H' | |
105 | .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] | |
106 | .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' | |
107 | .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' | |
108 | .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] | |
109 | .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] | |
110 | .ds ae a\h'-(\w'a'u*4/10)'e | |
111 | .ds Ae A\h'-(\w'A'u*4/10)'E | |
112 | . \" corrections for vroff | |
113 | .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' | |
114 | .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' | |
115 | . \" for low resolution devices (crt and lpr) | |
116 | .if \n(.H>23 .if \n(.V>19 \ | |
117 | \{\ | |
118 | . ds : e | |
119 | . ds 8 ss | |
120 | . ds o a | |
121 | . ds d- d\h'-1'\(ga | |
122 | . ds D- D\h'-1'\(hy | |
123 | . ds th \o'bp' | |
124 | . ds Th \o'LP' | |
125 | . ds ae ae | |
126 | . ds Ae AE | |
127 | .\} | |
128 | .rm #[ #] #H #V #F C | |
129 | .\" ======================================================================== | |
130 | .\" | |
131 | .IX Title "B::CC 3" | |
132 | .TH B::CC 3 "2001-09-21" "perl v5.8.8" "Perl Programmers Reference Guide" | |
133 | .SH "NAME" | |
134 | B::CC \- Perl compiler's optimized C translation backend | |
135 | .SH "SYNOPSIS" | |
136 | .IX Header "SYNOPSIS" | |
137 | .Vb 1 | |
138 | \& perl -MO=CC[,OPTIONS] foo.pl | |
139 | .Ve | |
140 | .SH "DESCRIPTION" | |
141 | .IX Header "DESCRIPTION" | |
142 | This compiler backend takes Perl source and generates C source code | |
143 | corresponding to the flow of your program. In other words, this | |
144 | backend is somewhat a \*(L"real\*(R" compiler in the sense that many people | |
145 | think about compilers. Note however that, currently, it is a very | |
146 | poor compiler in that although it generates (mostly, or at least | |
147 | sometimes) correct code, it performs relatively few optimisations. | |
148 | This will change as the compiler develops. The result is that | |
149 | running an executable compiled with this backend may start up more | |
150 | quickly than running the original Perl program (a feature shared | |
151 | by the \fBC\fR compiler backend\*(--see \fIB::C\fR) and may also execute | |
152 | slightly faster. This is by no means a good optimising compiler\*(--yet. | |
153 | .SH "OPTIONS" | |
154 | .IX Header "OPTIONS" | |
155 | If there are any non-option arguments, they are taken to be | |
156 | names of objects to be saved (probably doesn't work properly yet). | |
157 | Without extra arguments, it saves the main program. | |
158 | .IP "\fB\-ofilename\fR" 4 | |
159 | .IX Item "-ofilename" | |
160 | Output to filename instead of \s-1STDOUT\s0 | |
161 | .IP "\fB\-v\fR" 4 | |
162 | .IX Item "-v" | |
163 | Verbose compilation (currently gives a few compilation statistics). | |
164 | .IP "\fB\-\-\fR" 4 | |
165 | .IX Item "--" | |
166 | Force end of options | |
167 | .IP "\fB\-uPackname\fR" 4 | |
168 | .IX Item "-uPackname" | |
169 | Force apparently unused subs from package Packname to be compiled. | |
170 | This allows programs to use eval \*(L"\fIfoo()\fR\*(R" even when sub foo is never | |
171 | seen to be used at compile time. The down side is that any subs which | |
172 | really are never used also have code generated. This option is | |
173 | necessary, for example, if you have a signal handler foo which you | |
174 | initialise with \f(CW\*(C`$SIG{BAR} = "foo"\*(C'\fR. A better fix, though, is just | |
175 | to change it to \f(CW\*(C`$SIG{BAR} = \e&foo\*(C'\fR. You can have multiple \fB\-u\fR | |
176 | options. The compiler tries to figure out which packages may possibly | |
177 | have subs in which need compiling but the current version doesn't do | |
178 | it very well. In particular, it is confused by nested packages (i.e. | |
179 | of the form \f(CW\*(C`A::B\*(C'\fR) where package \f(CW\*(C`A\*(C'\fR does not contain any subs. | |
180 | .IP "\fB\-mModulename\fR" 4 | |
181 | .IX Item "-mModulename" | |
182 | Instead of generating source for a runnable executable, generate | |
183 | source for an \s-1XSUB\s0 module. The boot_Modulename function (which | |
184 | DynaLoader can look for) does the appropriate initialisation and runs | |
185 | the main part of the Perl source that is being compiled. | |
186 | .IP "\fB\-D\fR" 4 | |
187 | .IX Item "-D" | |
188 | Debug options (concatenated or separate flags like \f(CW\*(C`perl \-D\*(C'\fR). | |
189 | .IP "\fB\-Dr\fR" 4 | |
190 | .IX Item "-Dr" | |
191 | Writes debugging output to \s-1STDERR\s0 just as it's about to write to the | |
192 | program's runtime (otherwise writes debugging info as comments in | |
193 | its C output). | |
194 | .IP "\fB\-DO\fR" 4 | |
195 | .IX Item "-DO" | |
196 | Outputs each \s-1OP\s0 as it's compiled | |
197 | .IP "\fB\-Ds\fR" 4 | |
198 | .IX Item "-Ds" | |
199 | Outputs the contents of the shadow stack at each \s-1OP\s0 | |
200 | .IP "\fB\-Dp\fR" 4 | |
201 | .IX Item "-Dp" | |
202 | Outputs the contents of the shadow pad of lexicals as it's loaded for | |
203 | each sub or the main program. | |
204 | .IP "\fB\-Dq\fR" 4 | |
205 | .IX Item "-Dq" | |
206 | Outputs the name of each fake \s-1PP\s0 function in the queue as it's about | |
207 | to process it. | |
208 | .IP "\fB\-Dl\fR" 4 | |
209 | .IX Item "-Dl" | |
210 | Output the filename and line number of each original line of Perl | |
211 | code as it's processed (\f(CW\*(C`pp_nextstate\*(C'\fR). | |
212 | .IP "\fB\-Dt\fR" 4 | |
213 | .IX Item "-Dt" | |
214 | Outputs timing information of compilation stages. | |
215 | .IP "\fB\-f\fR" 4 | |
216 | .IX Item "-f" | |
217 | Force optimisations on or off one at a time. | |
218 | .IP "\fB\-ffreetmps\-each\-bblock\fR" 4 | |
219 | .IX Item "-ffreetmps-each-bblock" | |
220 | Delays \s-1FREETMPS\s0 from the end of each statement to the end of the each | |
221 | basic block. | |
222 | .IP "\fB\-ffreetmps\-each\-loop\fR" 4 | |
223 | .IX Item "-ffreetmps-each-loop" | |
224 | Delays \s-1FREETMPS\s0 from the end of each statement to the end of the group | |
225 | of basic blocks forming a loop. At most one of the freetmps\-each\-* | |
226 | options can be used. | |
227 | .IP "\fB\-fomit\-taint\fR" 4 | |
228 | .IX Item "-fomit-taint" | |
229 | Omits generating code for handling perl's tainting mechanism. | |
230 | .IP "\fB\-On\fR" 4 | |
231 | .IX Item "-On" | |
232 | Optimisation level (n = 0, 1, 2, ...). \fB\-O\fR means \fB\-O1\fR. | |
233 | Currently, \fB\-O1\fR sets \fB\-ffreetmps\-each\-bblock\fR and \fB\-O2\fR | |
234 | sets \fB\-ffreetmps\-each\-loop\fR. | |
235 | .SH "EXAMPLES" | |
236 | .IX Header "EXAMPLES" | |
237 | .Vb 2 | |
238 | \& perl -MO=CC,-O2,-ofoo.c foo.pl | |
239 | \& perl cc_harness -o foo foo.c | |
240 | .Ve | |
241 | .PP | |
242 | Note that \f(CW\*(C`cc_harness\*(C'\fR lives in the \f(CW\*(C`B\*(C'\fR subdirectory of your perl | |
243 | library directory. The utility called \f(CW\*(C`perlcc\*(C'\fR may also be used to | |
244 | help make use of this compiler. | |
245 | .PP | |
246 | .Vb 2 | |
247 | \& perl -MO=CC,-mFoo,-oFoo.c Foo.pm | |
248 | \& perl cc_harness -shared -c -o Foo.so Foo.c | |
249 | .Ve | |
250 | .SH "BUGS" | |
251 | .IX Header "BUGS" | |
252 | Plenty. Current status: experimental. | |
253 | .SH "DIFFERENCES" | |
254 | .IX Header "DIFFERENCES" | |
255 | These aren't really bugs but they are constructs which are heavily | |
256 | tied to perl's compile-and-go implementation and with which this | |
257 | compiler backend cannot cope. | |
258 | .Sh "Loops" | |
259 | .IX Subsection "Loops" | |
260 | Standard perl calculates the target of \*(L"next\*(R", \*(L"last\*(R", and \*(L"redo\*(R" | |
261 | at run\-time. The compiler calculates the targets at compile\-time. | |
262 | For example, the program | |
263 | .PP | |
264 | .Vb 5 | |
265 | \& sub skip_on_odd { next NUMBER if $_[0] % 2 } | |
266 | \& NUMBER: for ($i = 0; $i < 5; $i++) { | |
267 | \& skip_on_odd($i); | |
268 | \& print $i; | |
269 | \& } | |
270 | .Ve | |
271 | .PP | |
272 | produces the output | |
273 | .PP | |
274 | .Vb 1 | |
275 | \& 024 | |
276 | .Ve | |
277 | .PP | |
278 | with standard perl but gives a compile-time error with the compiler. | |
279 | .ie n .Sh "Context of ""..""" | |
280 | .el .Sh "Context of ``..''" | |
281 | .IX Subsection "Context of .." | |
282 | The context (scalar or array) of the \*(L"..\*(R" operator determines whether | |
283 | it behaves as a range or a flip/flop. Standard perl delays until | |
284 | runtime the decision of which context it is in but the compiler needs | |
285 | to know the context at compile\-time. For example, | |
286 | .PP | |
287 | .Vb 4 | |
288 | \& @a = (4,6,1,0,0,1); | |
289 | \& sub range { (shift @a)..(shift @a) } | |
290 | \& print range(); | |
291 | \& while (@a) { print scalar(range()) } | |
292 | .Ve | |
293 | .PP | |
294 | generates the output | |
295 | .PP | |
296 | .Vb 1 | |
297 | \& 456123E0 | |
298 | .Ve | |
299 | .PP | |
300 | with standard Perl but gives a compile-time error with compiled Perl. | |
301 | .Sh "Arithmetic" | |
302 | .IX Subsection "Arithmetic" | |
303 | Compiled Perl programs use native C arithmetic much more frequently | |
304 | than standard perl. Operations on large numbers or on boundary | |
305 | cases may produce different behaviour. | |
306 | .Sh "Deprecated features" | |
307 | .IX Subsection "Deprecated features" | |
308 | Features of standard perl such as \f(CW$[\fR which have been deprecated | |
309 | in standard perl since Perl5 was released have not been implemented | |
310 | in the compiler. | |
311 | .SH "AUTHOR" | |
312 | .IX Header "AUTHOR" | |
313 | Malcolm Beattie, \f(CW\*(C`mbeattie@sable.ox.ac.uk\*(C'\fR |