diff options
author | Jim Cromie <jim.cromie@gmail.com> | 2011-04-18 14:05:35 -0600 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-09-09 23:30:56 -0700 |
commit | 2b420b633b59fecd2561eeec600f17160862175b (patch) | |
tree | d88082f1bb7e3517d085feca3337cb9aa1ec1d08 /regen | |
parent | 0b2be16900832ccd9de494ff538bf070d8623089 (diff) | |
download | perl-2b420b633b59fecd2561eeec600f17160862175b.tar.gz |
implement OP_IS_NUMCOMPARE like other OP_IS macros
other macros are written by regen/opcode.pl into opnames.h
Generate OP_IS_NUMCOMPARE the same way, and get a micro-optimization.
Adds a new 'S<' operand type for the numeric comparison ops.
Needs make regen.
Diffstat (limited to 'regen')
-rwxr-xr-x | regen/opcode.pl | 19 | ||||
-rw-r--r-- | regen/opcodes | 29 |
2 files changed, 27 insertions, 21 deletions
diff --git a/regen/opcode.pl b/regen/opcode.pl index 791de9f4be..5e1cf62dc8 100755 --- a/regen/opcode.pl +++ b/regen/opcode.pl @@ -349,9 +349,10 @@ my %opflags = ( 'u' => 128, # defaults to $_ ); -my %OP_IS_SOCKET; -my %OP_IS_FILETEST; -my %OP_IS_FT_ACCESS; +my %OP_IS_SOCKET; # /Fs/ +my %OP_IS_FILETEST; # /F-/ +my %OP_IS_FT_ACCESS; # /F-+/ +my %OP_IS_NUMCOMPARE; # /S</ my $OCSHIFT = 8; my $OASHIFT = 12; @@ -376,6 +377,9 @@ for my $op (@ops) { $OP_IS_FILETEST{$op} = $opnum{$op} if $arg =~ s/-//; $OP_IS_FT_ACCESS{$op} = $opnum{$op} if $arg =~ s/\+//; } + elsif ($arg =~ /^S</) { + $OP_IS_NUMCOMPARE{$op} = $opnum{$op} if $arg =~ s/<//; + } my $argnum = ($arg =~ s/\?//) ? 8 : 0; die "op = $op, arg = $arg\n" unless exists $argnum{$arg}; @@ -411,6 +415,7 @@ EO_OP_IS_COMMENT gen_op_is_macro( \%OP_IS_SOCKET, 'OP_IS_SOCKET'); gen_op_is_macro( \%OP_IS_FILETEST, 'OP_IS_FILETEST'); gen_op_is_macro( \%OP_IS_FT_ACCESS, 'OP_IS_FILETEST_ACCESS'); +gen_op_is_macro( \%OP_IS_NUMCOMPARE, 'OP_IS_NUMCOMPARE'); sub gen_op_is_macro { my ($op_is, $macname) = @_; @@ -431,14 +436,14 @@ sub gen_op_is_macro { if ( $op_is->{$last} - $op_is->{$first} == scalar @rest + 1) { # contiguous ops -> optimized version - print $on "(op) >= OP_" . uc($first) . " && (op) <= OP_" . uc($last); - print $on ")\n"; + print $on "(op) >= OP_" . uc($first) + . " && (op) <= OP_" . uc($last); } else { print $on join(" || \\\n\t ", - map { "(op) == OP_" . uc() } sort keys %$op_is); - print $on ")\n"; + map { "(op) == OP_" . uc() } sort keys %$op_is); } + print $on ")\n"; } } diff --git a/regen/opcodes b/regen/opcodes index d6720c3cb3..7b871dbb3c 100644 --- a/regen/opcodes +++ b/regen/opcodes @@ -30,6 +30,7 @@ # scalar - S list - L array - A # hash - H sub (CV) - C file - F # socket - Fs filetest - F- filetest_access - F-+ +# num-compare - S< # reference - R # "?" denotes an optional operand. @@ -137,20 +138,20 @@ stringify string ck_fun fsT@ S left_shift left bitshift (<<) ck_bitop fsT2 S S right_shift right bitshift (>>) ck_bitop fsT2 S S -lt numeric lt (<) ck_null Iifs2 S S -i_lt integer lt (<) ck_null ifs2 S S -gt numeric gt (>) ck_null Iifs2 S S -i_gt integer gt (>) ck_null ifs2 S S -le numeric le (<=) ck_null Iifs2 S S -i_le integer le (<=) ck_null ifs2 S S -ge numeric ge (>=) ck_null Iifs2 S S -i_ge integer ge (>=) ck_null ifs2 S S -eq numeric eq (==) ck_null Iifs2 S S -i_eq integer eq (==) ck_null ifs2 S S -ne numeric ne (!=) ck_null Iifs2 S S -i_ne integer ne (!=) ck_null ifs2 S S -ncmp numeric comparison (<=>) ck_null Iifst2 S S -i_ncmp integer comparison (<=>) ck_null ifst2 S S +lt numeric lt (<) ck_null Iifs2 S S< +i_lt integer lt (<) ck_null ifs2 S S< +gt numeric gt (>) ck_null Iifs2 S S< +i_gt integer gt (>) ck_null ifs2 S S< +le numeric le (<=) ck_null Iifs2 S S< +i_le integer le (<=) ck_null ifs2 S S< +ge numeric ge (>=) ck_null Iifs2 S S< +i_ge integer ge (>=) ck_null ifs2 S S< +eq numeric eq (==) ck_null Iifs2 S S< +i_eq integer eq (==) ck_null ifs2 S S< +ne numeric ne (!=) ck_null Iifs2 S S< +i_ne integer ne (!=) ck_null ifs2 S S< +ncmp numeric comparison (<=>) ck_null Iifst2 S S< +i_ncmp integer comparison (<=>) ck_null ifst2 S S< slt string lt ck_null ifs2 S S sgt string gt ck_null ifs2 S S |