summaryrefslogtreecommitdiff
path: root/regen/opcode.pl
diff options
context:
space:
mode:
authorJim Cromie <jim.cromie@gmail.com>2011-04-18 14:05:35 -0600
committerFather Chrysostomos <sprout@cpan.org>2011-09-09 23:30:56 -0700
commit2b420b633b59fecd2561eeec600f17160862175b (patch)
treed88082f1bb7e3517d085feca3337cb9aa1ec1d08 /regen/opcode.pl
parent0b2be16900832ccd9de494ff538bf070d8623089 (diff)
downloadperl-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/opcode.pl')
-rwxr-xr-xregen/opcode.pl19
1 files changed, 12 insertions, 7 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";
}
}