3 unlink "opcode.h", "opnames.h";
4 open(OC, ">opcode.h") || die "Can't create opcode.h: $!\n";
5 open(ON, ">opnames.h") || die "Can't create opnames.h: $!\n";
14 ($key, $desc, $check, $flags, $args) = split(/\t+/, $_, 5);
16 warn qq[Description "$desc" duplicates $seen{$desc}\n] if $seen{$desc};
17 die qq[Opcode "$key" duplicates $seen{$key}\n] if $seen{$key};
18 $seen{$desc} = qq[description of opcode "$key"];
19 $seen{$key} = qq[opcode "$key"];
23 $check{$key} = $check;
25 $flags{$key} = $flags;
33 /* !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
34 This file is built by opcode.pl from its data. Any changes made here
38 #define Perl_pp_i_preinc Perl_pp_preinc
39 #define Perl_pp_i_predec Perl_pp_predec
40 #define Perl_pp_i_postinc Perl_pp_postinc
41 #define Perl_pp_i_postdec Perl_pp_postdec
46 /* !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
47 This file is built by opcode.pl from its data. Any changes made here
55 print ON "\t", &tab(3,"OP_\U$_,"), "/* ", $i++, " */\n";
57 print ON "\t", &tab(3,"OP_max"), "\n";
58 print ON "} opcode;\n";
59 print ON "\n#define MAXO ", scalar @ops, "\n\n";
61 # Emit op names and descriptions.
68 EXT char *PL_op_name[];
70 EXT char *PL_op_name[] = {
85 EXT char *PL_op_desc[];
87 EXT char *PL_op_desc[] = {
91 print qq(\t"$desc{$_}",\n);
102 # Emit function declarations.
104 #for (sort keys %ckname) {
105 # print "OP *\t", &tab(3,$_),"(pTHX_ OP* o);\n";
111 # print "OP *\t", &tab(3, "pp_$_"), "(pTHX);\n";
114 # Emit ppcode switch array.
121 EXT OP * (CPERLscope(*PL_ppaddr)[])(pTHX);
123 EXT OP * (CPERLscope(*PL_ppaddr)[])(pTHX) = {
127 print "\tPerl_pp_$_,\n";
136 # Emit check routines.
140 EXT OP * (CPERLscope(*PL_check)[]) (pTHX_ OP *op);
142 EXT OP * (CPERLscope(*PL_check)[]) (pTHX_ OP *op) = {
146 print "\t", &tab(3, "Perl_$check{$_},"), "/* $_ */\n";
155 # Emit allowed argument types.
161 EXT U32 PL_opargs[] = {
171 R, 7, # scalar reference
183 '"', 8, # pvop_or_svop
186 '%', 11, # baseop_or_unop
187 '-', 12, # filestatop
194 $argsum |= 1 if $flags =~ /m/; # needs stack mark
195 $argsum |= 2 if $flags =~ /f/; # fold constants
196 $argsum |= 4 if $flags =~ /s/; # always produces scalar
197 $argsum |= 8 if $flags =~ /t/; # needs target scalar
198 $argsum |= (8|256) if $flags =~ /T/; # ... which may be lexical
199 $argsum |= 16 if $flags =~ /i/; # always produces integer
200 $argsum |= 32 if $flags =~ /I/; # has corresponding int op
201 $argsum |= 64 if $flags =~ /d/; # danger, unknown side effects
202 $argsum |= 128 if $flags =~ /u/; # defaults to $_
204 $flags =~ /([\W\d_])/ or die qq[Opcode "$_" has no class indicator];
205 $argsum |= $opclass{$1} << 9;
206 $mul = 0x2000; # 2 ^ OASHIFT
207 for $arg (split(' ',$args{$_})) {
208 $argnum = ($arg =~ s/\?//) ? 8 : 0;
209 $argnum += $argnum{$arg};
210 warn "# Conflicting bit 32 for '$_'.\n"
211 if $argnum & 8 and $mul == 0x10000000;
212 $argsum += $argnum * $mul;
215 $argsum = sprintf("0x%08x", $argsum);
216 print "\t", &tab(3, "$argsum,"), "/* $_ */\n";
226 close OC or die "Error closing opcode.h: $!";
227 close ON or die "Error closing opnames.h: $!";
231 open PP, '>pp_proto.h' or die "Error creating pp_proto.h: $!";
232 open PPSYM, '>pp.sym' or die "Error creating pp.sym: $!";
235 /* !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
236 This file is built by opcode.pl from its data. Any changes made here
244 # !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
245 # This file is built by opcode.pl from its data. Any changes made here
252 for (sort keys %ckname) {
253 print PP "PERL_CKDEF(Perl_$_)\n";
254 print PPSYM "Perl_$_\n";
255 #OP *\t", &tab(3,$_),"(OP* o);\n";
261 next if /^i_(pre|post)(inc|dec)$/;
262 print PP "PERL_PPDEF(Perl_pp_$_)\n";
263 print PPSYM "Perl_pp_$_\n";
266 close PP or die "Error closing pp_proto.h: $!";
267 close PPSYM or die "Error closing pp.sym: $!";
269 ###########################################################################
272 $t .= "\t" x ($l - (length($t) + 1) / 8);
275 ###########################################################################
277 # Some comments about 'T' opcode classifier:
279 # Safe to set if the ppcode uses:
280 # tryAMAGICbin, tryAMAGICun, SETn, SETi, SETu, PUSHn, PUSHTARG, SETTARG,
281 # SETs(TARG), XPUSHn, XPUSHu,
283 # Unsafe to set if the ppcode uses dTARG or [X]RETPUSH[YES|NO|UNDEF]
285 # lt and friends do SETs (including ncmp, but not scmp)
287 # pp.c pos substr each not OK (RETPUSHUNDEF)
288 # substr vec also not OK due to LV to target (are they???)
289 # ref not OK (RETPUSHNO)
290 # trans not OK (dTARG; TARG = sv_newmortal();)
291 # ucfirst etc not OK: TMP arg processed inplace
292 # each repeat not OK too due to array context
293 # pack split - unknown whether they are safe
296 # readline - unknown whether it is safe
297 # match subst not OK (dTARG)
298 # grepwhile not OK (not always setting)
301 # mapwhile flip caller not OK (not always setting)
304 # backtick glob warn die not OK (not always setting)
305 # warn not OK (RETPUSHYES)
306 # open fileno getc sysread syswrite ioctl accept shutdown
307 # ftsize(etc) readlink telldir fork alarm getlogin not OK (RETPUSHUNDEF)
308 # umask select not OK (XPUSHs(&PL_sv_undef);)
309 # fileno getc sysread syswrite tell not OK (meth("FILENO" "GETC"))
310 # sselect shm* sem* msg* syscall - unknown whether they are safe
311 # gmtime not OK (list context)
315 # New ops always go at the very end
319 null null operation ck_null 0
321 scalar scalar ck_fun s% S
325 pushmark pushmark ck_null s0
326 wantarray wantarray ck_null is0
328 const constant item ck_svconst s$
330 gvsv scalar variable ck_null ds*
331 gv glob value ck_null ds*
332 gelem glob elem ck_null d2 S S
333 padsv private variable ck_null ds0
334 padav private array ck_null d0
335 padhv private hash ck_null d0
336 padany private something ck_null d0
338 pushre push regexp ck_null d/
340 # References and stuff.
342 rv2gv ref-to-glob cast ck_rvconst ds1
343 rv2sv scalar deref ck_rvconst ds1
344 av2arylen array length ck_null is1
345 rv2cv subroutine deref ck_rvconst d1
346 anoncode anonymous subroutine ck_anoncode $
347 prototype subroutine prototype ck_null s% S
348 refgen reference constructor ck_spair m1 L
349 srefgen single ref constructor ck_null fs1 S
350 ref reference-type operator ck_fun stu% S?
351 bless bless ck_fun s@ S S?
355 backtick backticks ck_null t%
356 # glob defaults its first arg to $_
357 glob glob ck_glob t@ S? S?
358 readline <HANDLE> ck_null t%
359 rcatline append I/O operator ck_null t%
361 # Bindable operators.
363 regcmaybe regexp comp once ck_fun s1 S
364 regcreset regexp reset interpolation flag ck_fun s1 S
365 regcomp regexp compilation ck_null s| S
366 match pattern match ck_match d/
367 qr pattern quote ck_match s/
368 subst substitution ck_null dis/ S
369 substcont substitution cont ck_null dis|
370 trans character translation ck_null is" S
373 # sassign is special-cased for op class
375 sassign scalar assignment ck_sassign s0
376 aassign list assignment ck_null t2 L L
378 chop chop ck_spair mTs% L
379 schop scalar chop ck_null sTu% S?
380 chomp safe chop ck_spair mTs% L
381 schomp scalar safe chop ck_null sTu% S?
382 defined defined operator ck_defined isu% S?
383 undef undef operator ck_lfun s% S?
384 study study ck_fun su% S?
385 pos match position ck_lfun stu% S?
387 preinc preincrement ck_lfun dIs1 S
388 i_preinc integer preincrement ck_lfun dis1 S
389 predec predecrement ck_lfun dIs1 S
390 i_predec integer predecrement ck_lfun dis1 S
391 postinc postincrement ck_lfun dIsT1 S
392 i_postinc integer postincrement ck_lfun disT1 S
393 postdec postdecrement ck_lfun dIsT1 S
394 i_postdec integer postdecrement ck_lfun disT1 S
396 # Ordinary operators.
398 pow exponentiation ck_null fsT2 S S
400 multiply multiplication ck_null IfsT2 S S
401 i_multiply integer multiplication ck_null ifsT2 S S
402 divide division ck_null IfsT2 S S
403 i_divide integer division ck_null ifsT2 S S
404 modulo modulus ck_null IifsT2 S S
405 i_modulo integer modulus ck_null ifsT2 S S
406 repeat repeat ck_repeat mt2 L S
408 add addition ck_null IfsT2 S S
409 i_add integer addition ck_null ifsT2 S S
410 subtract subtraction ck_null IfsT2 S S
411 i_subtract integer subtraction ck_null ifsT2 S S
412 concat concatenation ck_concat fsT2 S S
413 stringify string ck_fun fsT@ S
415 left_shift left bitshift ck_bitop fsT2 S S
416 right_shift right bitshift ck_bitop fsT2 S S
418 lt numeric lt ck_null Iifs2 S S
419 i_lt integer lt ck_null ifs2 S S
420 gt numeric gt ck_null Iifs2 S S
421 i_gt integer gt ck_null ifs2 S S
422 le numeric le ck_null Iifs2 S S
423 i_le integer le ck_null ifs2 S S
424 ge numeric ge ck_null Iifs2 S S
425 i_ge integer ge ck_null ifs2 S S
426 eq numeric eq ck_null Iifs2 S S
427 i_eq integer eq ck_null ifs2 S S
428 ne numeric ne ck_null Iifs2 S S
429 i_ne integer ne ck_null ifs2 S S
430 ncmp spaceship operator ck_null Iifst2 S S
431 i_ncmp integer spaceship ck_null ifst2 S S
433 slt string lt ck_scmp ifs2 S S
434 sgt string gt ck_scmp ifs2 S S
435 sle string le ck_scmp ifs2 S S
436 sge string ge ck_scmp ifs2 S S
437 seq string eq ck_null ifs2 S S
438 sne string ne ck_null ifs2 S S
439 scmp string comparison ck_scmp ifst2 S S
441 bit_and bitwise and ck_bitop fsT2 S S
442 bit_xor bitwise xor ck_bitop fsT2 S S
443 bit_or bitwise or ck_bitop fsT2 S S
445 negate negate ck_null IfsT1 S
446 i_negate integer negate ck_null ifsT1 S
447 not not ck_null ifs1 S
448 complement 1's complement ck_bitop fsT1 S
450 # High falutin' math.
452 atan2 atan2 ck_fun fsT@ S S
453 sin sin ck_fun fsTu% S?
454 cos cos ck_fun fsTu% S?
455 rand rand ck_fun sT% S?
456 srand srand ck_fun s% S?
457 exp exp ck_fun fsTu% S?
458 log log ck_fun fsTu% S?
459 sqrt sqrt ck_fun fsTu% S?
463 int int ck_fun fsTu% S?
464 hex hex ck_fun fsTu% S?
465 oct oct ck_fun fsTu% S?
466 abs abs ck_fun fsTu% S?
470 length length ck_lengthconst isTu% S?
471 substr substr ck_fun st@ S S S? S?
472 vec vec ck_fun ist@ S S S
474 index index ck_index isT@ S S S?
475 rindex rindex ck_index isT@ S S S?
477 sprintf sprintf ck_fun_locale mfsT@ S L
478 formline formline ck_fun ms@ S L
479 ord ord ck_fun ifsTu% S?
480 chr chr ck_fun fsTu% S?
481 crypt crypt ck_fun fsT@ S S
482 ucfirst upper case first ck_fun_locale fstu% S?
483 lcfirst lower case first ck_fun_locale fstu% S?
484 uc upper case ck_fun_locale fstu% S?
485 lc lower case ck_fun_locale fstu% S?
486 quotemeta quote metachars ck_fun fsTu% S?
490 rv2av array deref ck_rvconst dt1
491 aelemfast known array element ck_null s* A S
492 aelem array element ck_null s2 A S
493 aslice array slice ck_null m@ A L
498 values values ck_fun t% H
499 keys keys ck_fun t% H
500 delete delete ck_delete % S
501 exists exists operator ck_exists is% S
502 rv2hv hash deref ck_rvconst dt1
503 helem hash elem ck_null s2@ H S
504 hslice hash slice ck_null m@ H L
506 # Explosives and implosives.
508 unpack unpack ck_fun @ S S
509 pack pack ck_fun mst@ S L
510 split split ck_split t@ S S S
511 join join ck_fun msT@ S L
515 list list ck_null m@ L
516 lslice list slice ck_null 2 H L L
517 anonlist anonymous list ck_fun ms@ L
518 anonhash anonymous hash ck_fun ms@ L
520 splice splice ck_fun m@ A S? S? L
521 push push ck_fun imsT@ A L
522 pop pop ck_shift s% A
523 shift shift ck_shift s% A
524 unshift unshift ck_fun imsT@ A L
525 sort sort ck_sort m@ C? L
526 reverse reverse ck_fun mt@ L
528 grepstart grep ck_grep dm@ C L
529 grepwhile grep iterator ck_null dt|
531 mapstart map ck_grep dm@ C L
532 mapwhile map iterator ck_null dt|
536 range flipflop ck_null | S S
537 flip range (or flip) ck_null 1 S S
538 flop range (or flop) ck_null 1
542 and logical and ck_null |
543 or logical or ck_null |
544 xor logical xor ck_null fs2 S S
545 cond_expr conditional expression ck_null d|
546 andassign logical and assignment ck_null s|
547 orassign logical or assignment ck_null s|
549 method method lookup ck_method d1
550 entersub subroutine entry ck_subr dmt1 L
551 leavesub subroutine exit ck_null 1
552 caller caller ck_fun t% S?
553 warn warn ck_fun imst@ L
554 die die ck_fun dimst@ L
555 reset reset ck_fun is% S?
557 lineseq line sequence ck_null @
558 nextstate next statement ck_null s;
559 dbstate debug next statement ck_null s;
560 unstack iteration finalizer ck_null s0
561 enter block entry ck_null 0
562 leave block exit ck_null @
563 scope block ck_null @
564 enteriter foreach loop entry ck_null d{
565 iter foreach loop iterator ck_null 0
566 enterloop loop entry ck_null d{
567 leaveloop loop exit ck_null 2
568 return return ck_null dm@ L
569 last last ck_null ds}
570 next next ck_null ds}
571 redo redo ck_null ds}
572 dump dump ck_null ds}
573 goto goto ck_null ds}
574 exit exit ck_fun ds% S?
577 #nswitch numeric switch ck_null d
578 #cswitch character switch ck_null d
582 open open ck_fun ist@ F S? S?
583 close close ck_fun is% F?
584 pipe_op pipe ck_fun is@ F F
586 fileno fileno ck_fun ist% F
587 umask umask ck_fun ist% S?
588 binmode binmode ck_fun s% F
590 tie tie ck_fun idms@ R S L
591 untie untie ck_fun is% R
592 tied tied ck_fun s% R
593 dbmopen dbmopen ck_fun is@ H S S
594 dbmclose dbmclose ck_fun is% H
596 sselect select system call ck_select t@ S S S S
597 select select ck_select st@ F?
599 getc getc ck_eof st% F?
600 read read ck_fun imst@ F R S S?
601 enterwrite write ck_fun dis% F?
602 leavewrite write exit ck_null 1
604 prtf printf ck_listiob ims@ F? L
605 print print ck_listiob ims@ F? L
607 sysopen sysopen ck_fun s@ F S S S?
608 sysseek sysseek ck_fun s@ F S S
609 sysread sysread ck_fun imst@ F R S S?
610 syswrite syswrite ck_fun imst@ F S S? S?
612 send send ck_fun imst@ F S S S?
613 recv recv ck_fun imst@ F R S S
615 eof eof ck_eof is% F?
616 tell tell ck_fun st% F?
617 seek seek ck_fun s@ F S S
618 # truncate really behaves as if it had both "S S" and "F S"
619 truncate truncate ck_trunc is@ S S
621 fcntl fcntl ck_fun st@ F S S
622 ioctl ioctl ck_fun st@ F S S
623 flock flock ck_fun isT@ F S
627 socket socket ck_fun is@ F S S S
628 sockpair socketpair ck_fun is@ F F S S S
630 bind bind ck_fun is@ F S
631 connect connect ck_fun is@ F S
632 listen listen ck_fun is@ F S
633 accept accept ck_fun ist@ F F
634 shutdown shutdown ck_fun ist@ F S
636 gsockopt getsockopt ck_fun is@ F S S
637 ssockopt setsockopt ck_fun is@ F S S S
639 getsockname getsockname ck_fun is% F
640 getpeername getpeername ck_fun is% F
644 lstat lstat ck_ftst u- F
645 stat stat ck_ftst u- F
646 ftrread -R ck_ftst isu- F
647 ftrwrite -W ck_ftst isu- F
648 ftrexec -X ck_ftst isu- F
649 fteread -r ck_ftst isu- F
650 ftewrite -w ck_ftst isu- F
651 fteexec -x ck_ftst isu- F
652 ftis -e ck_ftst isu- F
653 fteowned -O ck_ftst isu- F
654 ftrowned -o ck_ftst isu- F
655 ftzero -z ck_ftst isu- F
656 ftsize -s ck_ftst istu- F
657 ftmtime -M ck_ftst stu- F
658 ftatime -A ck_ftst stu- F
659 ftctime -C ck_ftst stu- F
660 ftsock -S ck_ftst isu- F
661 ftchr -c ck_ftst isu- F
662 ftblk -b ck_ftst isu- F
663 ftfile -f ck_ftst isu- F
664 ftdir -d ck_ftst isu- F
665 ftpipe -p ck_ftst isu- F
666 ftlink -l ck_ftst isu- F
667 ftsuid -u ck_ftst isu- F
668 ftsgid -g ck_ftst isu- F
669 ftsvtx -k ck_ftst isu- F
670 fttty -t ck_ftst is- F
671 fttext -T ck_ftst isu- F
672 ftbinary -B ck_ftst isu- F
676 chdir chdir ck_fun isT% S?
677 chown chown ck_fun imsT@ L
678 chroot chroot ck_fun isTu% S?
679 unlink unlink ck_fun imsTu@ L
680 chmod chmod ck_fun imsT@ L
681 utime utime ck_fun imsT@ L
682 rename rename ck_fun isT@ S S
683 link link ck_fun isT@ S S
684 symlink symlink ck_fun isT@ S S
685 readlink readlink ck_fun stu% S?
686 mkdir mkdir ck_fun isT@ S S
687 rmdir rmdir ck_fun isTu% S?
691 open_dir opendir ck_fun is@ F S
692 readdir readdir ck_fun % F
693 telldir telldir ck_fun st% F
694 seekdir seekdir ck_fun s@ F S
695 rewinddir rewinddir ck_fun s% F
696 closedir closedir ck_fun is% F
700 fork fork ck_null ist0
701 wait wait ck_null isT0
702 waitpid waitpid ck_fun isT@ S S
703 system system ck_exec imsT@ S? L
704 exec exec ck_exec dimsT@ S? L
705 kill kill ck_fun dimsT@ L
706 getppid getppid ck_null isT0
707 getpgrp getpgrp ck_fun isT% S?
708 setpgrp setpgrp ck_fun isT@ S? S?
709 getpriority getpriority ck_fun isT@ S S
710 setpriority setpriority ck_fun isT@ S S S
714 time time ck_null isT0
716 localtime localtime ck_fun t% S?
717 gmtime gmtime ck_fun t% S?
718 alarm alarm ck_fun istu% S?
719 sleep sleep ck_fun isT% S?
723 shmget shmget ck_fun imst@ S S S
724 shmctl shmctl ck_fun imst@ S S S
725 shmread shmread ck_fun imst@ S S S S
726 shmwrite shmwrite ck_fun imst@ S S S S
730 msgget msgget ck_fun imst@ S S
731 msgctl msgctl ck_fun imst@ S S S
732 msgsnd msgsnd ck_fun imst@ S S S
733 msgrcv msgrcv ck_fun imst@ S S S S S
737 semget semget ck_fun imst@ S S S
738 semctl semctl ck_fun imst@ S S S S
739 semop semop ck_fun imst@ S S
743 require require ck_require du% S?
744 dofile do 'file' ck_fun d1 S
745 entereval eval string ck_eval d% S
746 leaveeval eval exit ck_null 1 S
747 #evalonce eval constant string ck_null d1 S
748 entertry eval block ck_null |
749 leavetry eval block exit ck_null @
753 ghbyname gethostbyname ck_fun % S
754 ghbyaddr gethostbyaddr ck_fun @ S S
755 ghostent gethostent ck_null 0
756 gnbyname getnetbyname ck_fun % S
757 gnbyaddr getnetbyaddr ck_fun @ S S
758 gnetent getnetent ck_null 0
759 gpbyname getprotobyname ck_fun % S
760 gpbynumber getprotobynumber ck_fun @ S
761 gprotoent getprotoent ck_null 0
762 gsbyname getservbyname ck_fun @ S S
763 gsbyport getservbyport ck_fun @ S S
764 gservent getservent ck_null 0
765 shostent sethostent ck_fun is% S
766 snetent setnetent ck_fun is% S
767 sprotoent setprotoent ck_fun is% S
768 sservent setservent ck_fun is% S
769 ehostent endhostent ck_null is0
770 enetent endnetent ck_null is0
771 eprotoent endprotoent ck_null is0
772 eservent endservent ck_null is0
773 gpwnam getpwnam ck_fun % S
774 gpwuid getpwuid ck_fun % S
775 gpwent getpwent ck_null 0
776 spwent setpwent ck_null is0
777 epwent endpwent ck_null is0
778 ggrnam getgrnam ck_fun % S
779 ggrgid getgrgid ck_fun % S
780 ggrent getgrent ck_null 0
781 sgrent setgrent ck_null is0
782 egrent endgrent ck_null is0
783 getlogin getlogin ck_null st0
787 syscall syscall ck_fun imst@ S L
789 # For multi-threading
790 lock lock ck_rfun s% S
791 threadsv per-thread variable ck_null ds0
794 setstate set statement info ck_null s;
795 method_named method with known name ck_null d$