This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
5b988a11aab7ce2b5a27c194da485a418d4aa6d5
[perl5.git] / regen / opcodes
1 # New ops always go at the end
2 # The restriction on having custom as the last op has been removed
3
4 # A recapitulation of the format of this file:
5 # The file consists of five columns: the name of the op, an English
6 # description, the name of the "check" routine used to optimize this
7 # operation, some flags, and a description of the operands.
8
9 # The flags consist of options followed by a mandatory op class signifier
10
11 # The classes are:
12 # baseop      - 0            unop     - 1            binop      - 2
13 # logop       - |            listop   - @            pmop       - /
14 # padop/svop  - $            padop    - # (unused)   loop       - {
15 # baseop/unop - %            loopexop - }            filestatop - -
16 # pvop/svop   - "            cop      - ;
17
18 # Other options are:
19 #   needs stack mark                    - m
20 #   needs constant folding              - f
21 #   produces a scalar                   - s
22 #   produces an integer                 - i
23 #   needs a target                      - t
24 #   target can be in a pad              - T
25 #   has a corresponding integer version - I
26 #   has side effects                    - d
27 #   uses $_ if no argument given        - u
28
29 # Values for the operands are:
30 # scalar      - S            list     - L            array     - A
31 # hash        - H            sub (CV) - C            file      - F
32 # socket      - Fs           filetest - F-           filetest_access - F-+
33 # num-compare - S<           dirhandle - DF
34
35 # reference - R
36 # "?" denotes an optional operand.
37
38 # Nothing.
39
40 null            null operation          ck_null         0       
41 stub            stub                    ck_null         0
42 scalar          scalar                  ck_fun          s%      S
43
44 # Pushy stuff.
45
46 pushmark        pushmark                ck_null         s0      
47 wantarray       wantarray               ck_null         is0     
48
49 const           constant item           ck_svconst      s$      
50
51 gvsv            scalar variable         ck_null         ds$     
52 gv              glob value              ck_null         ds$     
53 gelem           glob elem               ck_null         d2      S S
54 padsv           private variable        ck_null         ds0
55 padav           private array           ck_null         d0
56 padhv           private hash            ck_null         d0
57 padany          private value           ck_null         d0
58
59 pushre          push regexp             ck_null         d/
60
61 # References and stuff.
62
63 rv2gv           ref-to-glob cast        ck_rvconst      ds1     
64 rv2sv           scalar dereference      ck_rvconst      ds1     
65 av2arylen       array length            ck_null         is1     
66 rv2cv           subroutine dereference  ck_rvconst      d1
67 anoncode        anonymous subroutine    ck_anoncode     $       
68 prototype       subroutine prototype    ck_null         s%      S
69 refgen          reference constructor   ck_spair        m1      L
70 srefgen         single ref constructor  ck_null         fs1     S
71 ref             reference-type operator ck_fun          stu%    S?
72 bless           bless                   ck_fun          s@      S S?
73
74 # Pushy I/O.
75
76 backtick        quoted execution (``, qx)       ck_open         tu%     S?
77 # glob defaults its first arg to $_
78 glob            glob                    ck_glob         t@      S?
79 readline        <HANDLE>                ck_readline     t%      F?
80 rcatline        append I/O operator     ck_null         t$
81
82 # Bindable operators.
83
84 regcmaybe       regexp internal guard   ck_fun          s1      S
85 regcreset       regexp internal reset   ck_fun          s1      S
86 regcomp         regexp compilation      ck_null         s|      S
87 match           pattern match (m//)     ck_match        d/
88 qr              pattern quote (qr//)    ck_match        s/
89 subst           substitution (s///)     ck_match        dis/    S
90 substcont       substitution iterator   ck_null         dis|    
91 trans           transliteration (tr///) ck_match        is"     S
92 # y///r
93 transr          transliteration (tr///) ck_match        is"     S
94
95 # Lvalue operators.
96 # sassign is special-cased for op class
97
98 sassign         scalar assignment       ck_sassign      s0
99 aassign         list assignment         ck_null         t2      L L
100
101 chop            chop                    ck_spair        mts%    L
102 schop           scalar chop             ck_null         stu%    S?
103 chomp           chomp                   ck_spair        mTs%    L
104 schomp          scalar chomp            ck_null         sTu%    S?
105 defined         defined operator        ck_defined      isu%    S?
106 undef           undef operator          ck_lfun         s%      S?
107 study           study                   ck_fun          su%     S?
108 pos             match position          ck_lfun         stu%    S?
109
110 preinc          preincrement (++)               ck_lfun         dIs1    S
111 i_preinc        integer preincrement (++)       ck_lfun         dis1    S
112 predec          predecrement (--)               ck_lfun         dIs1    S
113 i_predec        integer predecrement (--)       ck_lfun         dis1    S
114 postinc         postincrement (++)              ck_lfun         dIst1   S
115 i_postinc       integer postincrement (++)      ck_lfun         disT1   S
116 postdec         postdecrement (--)              ck_lfun         dIst1   S
117 i_postdec       integer postdecrement (--)      ck_lfun         disT1   S
118
119 # Ordinary operators.
120
121 pow             exponentiation (**)     ck_null         fsT2    S S
122
123 multiply        multiplication (*)      ck_null         IfsT2   S S
124 i_multiply      integer multiplication (*)      ck_null         ifsT2   S S
125 divide          division (/)            ck_null         IfsT2   S S
126 i_divide        integer division (/)    ck_null         ifsT2   S S
127 modulo          modulus (%)             ck_null         IifsT2  S S
128 i_modulo        integer modulus (%)     ck_null         ifsT2   S S
129 repeat          repeat (x)              ck_repeat       mt2     L S
130
131 add             addition (+)            ck_null         IfsT2   S S
132 i_add           integer addition (+)    ck_null         ifsT2   S S
133 subtract        subtraction (-)         ck_null         IfsT2   S S
134 i_subtract      integer subtraction (-) ck_null         ifsT2   S S
135 concat          concatenation (.) or string     ck_concat       fsT2    S S
136 stringify       string                  ck_fun          fsT@    S
137
138 left_shift      left bitshift (<<)      ck_bitop        fsT2    S S
139 right_shift     right bitshift (>>)     ck_bitop        fsT2    S S
140
141 lt              numeric lt (<)          ck_cmp          Iifs2   S S<
142 i_lt            integer lt (<)          ck_cmp          ifs2    S S<
143 gt              numeric gt (>)          ck_cmp          Iifs2   S S<
144 i_gt            integer gt (>)          ck_cmp          ifs2    S S<
145 le              numeric le (<=)         ck_cmp          Iifs2   S S<
146 i_le            integer le (<=)         ck_cmp          ifs2    S S<
147 ge              numeric ge (>=)         ck_cmp          Iifs2   S S<
148 i_ge            integer ge (>=)         ck_cmp          ifs2    S S<
149 eq              numeric eq (==)         ck_null         Iifs2   S S<
150 i_eq            integer eq (==)         ck_null         ifs2    S S<
151 ne              numeric ne (!=)         ck_null         Iifs2   S S<
152 i_ne            integer ne (!=)         ck_null         ifs2    S S<
153 ncmp            numeric comparison (<=>)        ck_null         Iifst2  S S<
154 i_ncmp          integer comparison (<=>)        ck_null         ifst2   S S<
155
156 slt             string lt               ck_null         ifs2    S S
157 sgt             string gt               ck_null         ifs2    S S
158 sle             string le               ck_null         ifs2    S S
159 sge             string ge               ck_null         ifs2    S S
160 seq             string eq               ck_null         ifs2    S S
161 sne             string ne               ck_null         ifs2    S S
162 scmp            string comparison (cmp) ck_null         ifst2   S S
163
164 bit_and         bitwise and (&)         ck_bitop        fst2    S S
165 bit_xor         bitwise xor (^)         ck_bitop        fst2    S S
166 bit_or          bitwise or (|)          ck_bitop        fst2    S S
167
168 negate          negation (-)            ck_null         Ifst1   S
169 i_negate        integer negation (-)    ck_null         ifsT1   S
170 not             not                     ck_null         ifs1    S
171 complement      1's complement (~)      ck_bitop        fst1    S
172
173 smartmatch      smart match             ck_smartmatch   s2
174
175 # High falutin' math.
176
177 atan2           atan2                   ck_fun          fsT@    S S
178 sin             sin                     ck_fun          fsTu%   S?
179 cos             cos                     ck_fun          fsTu%   S?
180 rand            rand                    ck_fun          sT%     S?
181 srand           srand                   ck_fun          sT%     S?
182 exp             exp                     ck_fun          fsTu%   S?
183 log             log                     ck_fun          fsTu%   S?
184 sqrt            sqrt                    ck_fun          fsTu%   S?
185
186 # Lowbrow math.
187
188 int             int                     ck_fun          fsTu%   S?
189 hex             hex                     ck_fun          fsTu%   S?
190 oct             oct                     ck_fun          fsTu%   S?
191 abs             abs                     ck_fun          fsTu%   S?
192
193 # String stuff.
194
195 length          length                  ck_fun          ifsTu%  S?
196 substr          substr                  ck_substr       st@     S S S? S?
197 vec             vec                     ck_fun          ist@    S S S
198
199 index           index                   ck_index        isT@    S S S?
200 rindex          rindex                  ck_index        isT@    S S S?
201
202 sprintf         sprintf                 ck_fun          fmst@   S L
203 formline        formline                ck_fun          ms@     S L
204 ord             ord                     ck_fun          ifsTu%  S?
205 chr             chr                     ck_fun          fsTu%   S?
206 crypt           crypt                   ck_fun          fsT@    S S
207 ucfirst         ucfirst                 ck_fun          fstu%   S?
208 lcfirst         lcfirst                 ck_fun          fstu%   S?
209 uc              uc                      ck_fun          fstu%   S?
210 lc              lc                      ck_fun          fstu%   S?
211 quotemeta       quotemeta               ck_fun          fstu%   S?
212
213 # Arrays.
214
215 rv2av           array dereference       ck_rvconst      dt1     
216 aelemfast       constant array element  ck_null         s$      A S
217 aelemfast_lex   constant lexical array element  ck_null         d0      A S
218 aelem           array element           ck_null         s2      A S
219 aslice          array slice             ck_null         m@      A L
220
221 aeach           each on array           ck_each         %       A
222 akeys           keys on array           ck_each         t%      A
223 avalues         values on array         ck_each         t%      A
224
225 # Hashes.
226
227 each            each                    ck_each         %       H
228 values          values                  ck_each         t%      H
229 keys            keys                    ck_each         t%      H
230 delete          delete                  ck_delete       %       S
231 exists          exists                  ck_exists       is%     S
232 rv2hv           hash dereference        ck_rvconst      dt1     
233 helem           hash element            ck_null         s2      H S
234 hslice          hash slice              ck_null         m@      H L
235 boolkeys        boolkeys                ck_fun          %       H
236
237 # Explosives and implosives.
238
239 unpack          unpack                  ck_fun          u@      S S?
240 pack            pack                    ck_fun          mst@    S L
241 split           split                   ck_split        t@      S S S
242 join            join or string          ck_join         mst@    S L
243
244 # List operators.
245
246 list            list                    ck_null         m@      L
247 lslice          list slice              ck_null         2       H L L
248 anonlist        anonymous list ([])     ck_fun          ms@     L
249 anonhash        anonymous hash ({})     ck_fun          ms@     L
250
251 splice          splice                  ck_fun          m@      A S? S? L
252 push            push                    ck_fun          imsT@   A L
253 pop             pop                     ck_shift        s%      A?
254 shift           shift                   ck_shift        s%      A?
255 unshift         unshift                 ck_fun          imsT@   A L
256 sort            sort                    ck_sort         dm@     C? L
257 reverse         reverse                 ck_fun          mt@     L
258
259 grepstart       grep                    ck_grep         dm@     C L
260 grepwhile       grep iterator           ck_null         dt|     
261
262 mapstart        map                     ck_grep         dm@     C L
263 mapwhile        map iterator            ck_null         dt|
264
265 # Range stuff.
266
267 range           flipflop                ck_null         |       S S
268 flip            range (or flip)         ck_null         1       S S
269 flop            range (or flop)         ck_null         1
270
271 # Control.
272
273 and             logical and (&&)                ck_null         |       
274 or              logical or (||)                 ck_null         |       
275 xor             logical xor                     ck_null         fs2     S S     
276 dor             defined or (//)                 ck_null         |
277 cond_expr       conditional expression          ck_null         d|      
278 andassign       logical and assignment (&&=)    ck_null         s|      
279 orassign        logical or assignment (||=)     ck_null         s|      
280 dorassign       defined or assignment (//=)     ck_null         s|
281
282 method          method lookup           ck_method       d1
283 entersub        subroutine entry        ck_subr         dmt1    L
284 leavesub        subroutine exit         ck_null         1       
285 leavesublv      lvalue subroutine return        ck_null         1       
286 caller          caller                  ck_fun          t%      S?
287 warn            warn                    ck_fun          imst@   L
288 die             die                     ck_die          dimst@  L
289 reset           symbol reset            ck_fun          is%     S?
290
291 lineseq         line sequence           ck_null         @       
292 nextstate       next statement          ck_null         s;      
293 dbstate         debug next statement    ck_null         s;      
294 unstack         iteration finalizer     ck_null         s0
295 enter           block entry             ck_null         0       
296 leave           block exit              ck_null         @       
297 scope           block                   ck_null         @       
298 enteriter       foreach loop entry      ck_null         d{      
299 iter            foreach loop iterator   ck_null         0       
300 enterloop       loop entry              ck_null         d{      
301 leaveloop       loop exit               ck_null         2       
302 return          return                  ck_return       dm@     L
303 last            last                    ck_null         ds}     
304 next            next                    ck_null         ds}     
305 redo            redo                    ck_null         ds}     
306 dump            dump                    ck_null         ds}     
307 goto            goto                    ck_null         ds}     
308 exit            exit                    ck_exit         ds%     S?
309 method_named    method with known name  ck_null         d$
310
311 entergiven      given()                 ck_null         d|
312 leavegiven      leave given block       ck_null         1
313 enterwhen       when()                  ck_null         d|
314 leavewhen       leave when block        ck_null         1
315 break           break                   ck_null         0
316 continue        continue                ck_null         0
317
318 # I/O.
319
320 open            open                    ck_open         ismt@   F S? L
321 close           close                   ck_fun          is%     F?
322 pipe_op         pipe                    ck_fun          is@     F F
323
324 fileno          fileno                  ck_fun          ist%    F
325 umask           umask                   ck_fun          ist%    S?
326 binmode         binmode                 ck_fun          s@      F S?
327
328 tie             tie                     ck_fun          idms@   R S L
329 untie           untie                   ck_fun          is%     R
330 tied            tied                    ck_fun          s%      R
331 dbmopen         dbmopen                 ck_fun          is@     H S S
332 dbmclose        dbmclose                ck_fun          is%     H
333
334 sselect         select system call      ck_select       t@      S S S S
335 select          select                  ck_select       st@     F?
336
337 getc            getc                    ck_eof          st%     F?
338 read            read                    ck_fun          imst@   F R S S?
339 enterwrite      write                   ck_fun          dis%    F?
340 leavewrite      write exit              ck_null         1       
341
342 prtf            printf                  ck_listiob      ims@    F? L
343 print           print                   ck_listiob      ims@    F? L
344 say             say                     ck_listiob      ims@    F? L
345
346 sysopen         sysopen                 ck_fun          s@      F S S S?
347 sysseek         sysseek                 ck_fun          s@      F S S
348 sysread         sysread                 ck_fun          imst@   F R S S?
349 syswrite        syswrite                ck_fun          imst@   F S S? S?
350
351 eof             eof                     ck_eof          is%     F?
352 tell            tell                    ck_fun          st%     F?
353 seek            seek                    ck_fun          s@      F S S
354 # truncate really behaves as if it had both "S S" and "F S"
355 truncate        truncate                ck_trunc        is@     S S
356
357 fcntl           fcntl                   ck_fun          st@     F S S
358 ioctl           ioctl                   ck_fun          st@     F S S
359 flock           flock                   ck_fun          isT@    F S
360
361 # Sockets.  OP_IS_SOCKET wants them consecutive (so moved 1st 2)
362
363 send            send                    ck_fun          imst@   Fs S S S?
364 recv            recv                    ck_fun          imst@   Fs R S S
365
366 socket          socket                  ck_fun          is@     Fs S S S
367 sockpair        socketpair              ck_fun          is@     Fs Fs S S S
368
369 bind            bind                    ck_fun          is@     Fs S
370 connect         connect                 ck_fun          is@     Fs S
371 listen          listen                  ck_fun          is@     Fs S
372 accept          accept                  ck_fun          ist@    Fs Fs
373 shutdown        shutdown                ck_fun          ist@    Fs S
374
375 gsockopt        getsockopt              ck_fun          is@     Fs S S
376 ssockopt        setsockopt              ck_fun          is@     Fs S S S
377
378 getsockname     getsockname             ck_fun          is%     Fs
379 getpeername     getpeername             ck_fun          is%     Fs
380
381 # Stat calls.  OP_IS_FILETEST wants them consecutive.
382
383 lstat           lstat                   ck_ftst         u-      F?
384 stat            stat                    ck_ftst         u-      F?
385 ftrread         -R                      ck_ftst         isu-    F-+
386 ftrwrite        -W                      ck_ftst         isu-    F-+
387 ftrexec         -X                      ck_ftst         isu-    F-+
388 fteread         -r                      ck_ftst         isu-    F-+
389 ftewrite        -w                      ck_ftst         isu-    F-+
390 fteexec         -x                      ck_ftst         isu-    F-+
391 ftis            -e                      ck_ftst         isu-    F-
392 ftsize          -s                      ck_ftst         istu-   F-
393 ftmtime         -M                      ck_ftst         stu-    F-
394 ftatime         -A                      ck_ftst         stu-    F-
395 ftctime         -C                      ck_ftst         stu-    F-
396 ftrowned        -O                      ck_ftst         isu-    F-
397 fteowned        -o                      ck_ftst         isu-    F-
398 ftzero          -z                      ck_ftst         isu-    F-
399 ftsock          -S                      ck_ftst         isu-    F-
400 ftchr           -c                      ck_ftst         isu-    F-
401 ftblk           -b                      ck_ftst         isu-    F-
402 ftfile          -f                      ck_ftst         isu-    F-
403 ftdir           -d                      ck_ftst         isu-    F-
404 ftpipe          -p                      ck_ftst         isu-    F-
405 ftsuid          -u                      ck_ftst         isu-    F-
406 ftsgid          -g                      ck_ftst         isu-    F-
407 ftsvtx          -k                      ck_ftst         isu-    F-
408 ftlink          -l                      ck_ftst         isu-    F-
409 fttty           -t                      ck_ftst         is-     F-
410 fttext          -T                      ck_ftst         isu-    F-
411 ftbinary        -B                      ck_ftst         isu-    F-
412
413 # File calls.
414
415 # chdir really behaves as if it had both "S?" and "F?"
416 chdir           chdir                   ck_chdir        isT%    S?
417 chown           chown                   ck_fun          imsT@   L
418 chroot          chroot                  ck_fun          isTu%   S?
419 unlink          unlink                  ck_fun          imsTu@  L
420 chmod           chmod                   ck_fun          imsT@   L
421 utime           utime                   ck_fun          imsT@   L
422 rename          rename                  ck_fun          isT@    S S
423 link            link                    ck_fun          isT@    S S
424 symlink         symlink                 ck_fun          isT@    S S
425 readlink        readlink                ck_fun          stu%    S?
426 mkdir           mkdir                   ck_fun          isTu@   S? S?
427 rmdir           rmdir                   ck_fun          isTu%   S?
428
429 # Directory calls.
430
431 open_dir        opendir                 ck_fun          is@     F S
432 readdir         readdir                 ck_fun          %       DF
433 telldir         telldir                 ck_fun          st%     DF
434 seekdir         seekdir                 ck_fun          s@      DF S
435 rewinddir       rewinddir               ck_fun          s%      DF
436 closedir        closedir                ck_fun          is%     DF
437
438 # Process control.
439
440 fork            fork                    ck_null         ist0    
441 wait            wait                    ck_null         isT0    
442 waitpid         waitpid                 ck_fun          isT@    S S
443 system          system                  ck_exec         imsT@   S? L
444 exec            exec                    ck_exec         dimsT@  S? L
445 kill            kill                    ck_fun          dimsT@  L
446 getppid         getppid                 ck_null         isT0    
447 getpgrp         getpgrp                 ck_fun          isT%    S?
448 setpgrp         setpgrp                 ck_fun          isT@    S? S?
449 getpriority     getpriority             ck_fun          isT@    S S
450 setpriority     setpriority             ck_fun          isT@    S S S
451
452 # Time calls.
453
454 time            time                    ck_null         isT0    
455 tms             times                   ck_null         0       
456 localtime       localtime               ck_fun          t%      S?
457 gmtime          gmtime                  ck_fun          t%      S?
458 alarm           alarm                   ck_fun          istu%   S?
459 sleep           sleep                   ck_fun          isT%    S?
460
461 # Shared memory.
462
463 shmget          shmget                  ck_fun          imst@   S S S
464 shmctl          shmctl                  ck_fun          imst@   S S S
465 shmread         shmread                 ck_fun          imst@   S S S S
466 shmwrite        shmwrite                ck_fun          imst@   S S S S
467
468 # Message passing.
469
470 msgget          msgget                  ck_fun          imst@   S S
471 msgctl          msgctl                  ck_fun          imst@   S S S
472 msgsnd          msgsnd                  ck_fun          imst@   S S S
473 msgrcv          msgrcv                  ck_fun          imst@   S S S S S
474
475 # Semaphores.
476
477 semop           semop                   ck_fun          imst@   S S
478 semget          semget                  ck_fun          imst@   S S S
479 semctl          semctl                  ck_fun          imst@   S S S S
480
481 # Eval.
482
483 require         require                 ck_require      du%     S?
484 dofile          do "file"               ck_fun          d1      S
485 hintseval       eval hints              ck_svconst      s$
486 entereval       eval "string"           ck_eval         d%      S
487 leaveeval       eval "string" exit      ck_null         1       S
488 #evalonce       eval constant string    ck_null         d1      S
489 entertry        eval {block}            ck_eval         d|      
490 leavetry        eval {block} exit       ck_null         @       
491
492 # Get system info.
493
494 ghbyname        gethostbyname           ck_fun          %       S
495 ghbyaddr        gethostbyaddr           ck_fun          @       S S
496 ghostent        gethostent              ck_null         0       
497 gnbyname        getnetbyname            ck_fun          %       S
498 gnbyaddr        getnetbyaddr            ck_fun          @       S S
499 gnetent         getnetent               ck_null         0       
500 gpbyname        getprotobyname          ck_fun          %       S
501 gpbynumber      getprotobynumber        ck_fun          @       S
502 gprotoent       getprotoent             ck_null         0       
503 gsbyname        getservbyname           ck_fun          @       S S
504 gsbyport        getservbyport           ck_fun          @       S S
505 gservent        getservent              ck_null         0       
506 shostent        sethostent              ck_fun          is%     S
507 snetent         setnetent               ck_fun          is%     S
508 sprotoent       setprotoent             ck_fun          is%     S
509 sservent        setservent              ck_fun          is%     S
510 ehostent        endhostent              ck_null         is0     
511 enetent         endnetent               ck_null         is0     
512 eprotoent       endprotoent             ck_null         is0     
513 eservent        endservent              ck_null         is0     
514 gpwnam          getpwnam                ck_fun          %       S
515 gpwuid          getpwuid                ck_fun          %       S
516 gpwent          getpwent                ck_null         0       
517 spwent          setpwent                ck_null         is0     
518 epwent          endpwent                ck_null         is0     
519 ggrnam          getgrnam                ck_fun          %       S
520 ggrgid          getgrgid                ck_fun          %       S
521 ggrent          getgrent                ck_null         0       
522 sgrent          setgrent                ck_null         is0     
523 egrent          endgrent                ck_null         is0     
524 getlogin        getlogin                ck_null         st0     
525
526 # Miscellaneous.
527
528 syscall         syscall                 ck_fun          imst@   S L
529
530 # For multi-threading
531 lock            lock                    ck_rfun         s%      R
532
533 # For state support
534
535 once            once                    ck_null         |       
536
537 custom          unknown custom operator         ck_null         0
538
539 # For smart dereference for each/keys/values
540 reach           each on reference                       ck_each         %       S
541 rkeys           keys on reference                       ck_each         t%      S
542 rvalues         values on reference                     ck_each         t%      S
543
544 # For CORE:: subs
545 coreargs        CORE:: subroutine       ck_null         $