mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Number VDBE opcodes starting with 0 instead of 1, as this obviates the
lower-bound test on "switch(opcode){...}", making the code smaller and faster. FossilOrigin-Name: 4c9222f75bfac47f5422fff86b2d69a61933b3a2
This commit is contained in:
@ -81,8 +81,8 @@ while {![eof $in]} {
|
||||
set in1($name) 0
|
||||
set in2($name) 0
|
||||
set in3($name) 0
|
||||
set out1($name) 0
|
||||
set out2($name) 0
|
||||
set out3($name) 0
|
||||
for {set i 3} {$i<[llength $line]-1} {incr i} {
|
||||
switch [string trim [lindex $line $i] ,] {
|
||||
same {
|
||||
@ -112,16 +112,19 @@ while {![eof $in]} {
|
||||
|
||||
# Assign numbers to all opcodes and output the result.
|
||||
#
|
||||
set cnt 0
|
||||
set max 0
|
||||
puts "/* Automatically generated. Do not edit */"
|
||||
puts "/* See the tool/mkopcodeh.tcl script for details */"
|
||||
set op(OP_Noop) -1
|
||||
set order($nOp) OP_Noop
|
||||
incr nOp
|
||||
set op(OP_Explain) -1
|
||||
set order($nOp) OP_Explain
|
||||
incr nOp
|
||||
foreach name {OP_Noop OP_Explain} {
|
||||
set jump($name) 0
|
||||
set in1($name) 0
|
||||
set in2($name) 0
|
||||
set in3($name) 0
|
||||
set out2($name) 0
|
||||
set out3($name) 0
|
||||
set op($name) -1
|
||||
set order($nOp) $name
|
||||
incr nOp
|
||||
}
|
||||
|
||||
# The following are the opcodes that are processed by resolveP2Values()
|
||||
#
|
||||
@ -144,7 +147,7 @@ set rp2v_ops {
|
||||
# Assign small values to opcodes that are processed by resolveP2Values()
|
||||
# to make code generation for the switch() statement smaller and faster.
|
||||
#
|
||||
set cnt 0
|
||||
set cnt -1
|
||||
for {set i 0} {$i<$nOp} {incr i} {
|
||||
set name $order($i)
|
||||
if {[lsearch $rp2v_ops $name]>=0} {
|
||||
@ -169,7 +172,7 @@ for {set i 0} {$i<$nOp} {incr i} {
|
||||
}
|
||||
}
|
||||
set max $cnt
|
||||
for {set i 1} {$i<=$nOp} {incr i} {
|
||||
for {set i 0} {$i<$nOp} {incr i} {
|
||||
if {![info exists used($i)]} {
|
||||
set def($i) "OP_NotUsed_$i"
|
||||
}
|
||||
@ -196,27 +199,28 @@ for {set i 1} {$i<=$nOp} {incr i} {
|
||||
# Generate the bitvectors:
|
||||
#
|
||||
set bv(0) 0
|
||||
for {set i 1} {$i<=$max} {incr i} {
|
||||
for {set i 0} {$i<=$max} {incr i} {
|
||||
set name $def($i)
|
||||
if {[info exists jump($name)] && $jump($name)} {set a0 1} {set a0 0}
|
||||
if {[info exists in1($name)] && $in1($name)} {set a1 2} {set a1 0}
|
||||
if {[info exists in2($name)] && $in2($name)} {set a2 4} {set a2 0}
|
||||
if {[info exists in3($name)] && $in3($name)} {set a3 8} {set a3 0}
|
||||
if {[info exists out2($name)] && $out2($name)} {set a4 16} {set a4 0}
|
||||
if {[info exists out3($name)] && $out3($name)} {set a5 32} {set a5 0}
|
||||
set bv($i) [expr {$a0+$a1+$a2+$a3+$a4+$a5}]
|
||||
set x 0
|
||||
if {$jump($name)} {incr x 1}
|
||||
if {$in1($name)} {incr x 2}
|
||||
if {$in2($name)} {incr x 4}
|
||||
if {$in3($name)} {incr x 8}
|
||||
if {$out2($name)} {incr x 16}
|
||||
if {$out3($name)} {incr x 32}
|
||||
set bv($i) $x
|
||||
}
|
||||
puts ""
|
||||
puts "/* Properties such as \"out2\" or \"jump\" that are specified in"
|
||||
puts "** comments following the \"case\" for each opcode in the vdbe.c"
|
||||
puts "** are encoded into bitvectors as follows:"
|
||||
puts "*/"
|
||||
puts "#define OPFLG_JUMP 0x0001 /* jump: P2 holds jmp target */"
|
||||
puts "#define OPFLG_IN1 0x0002 /* in1: P1 is an input */"
|
||||
puts "#define OPFLG_IN2 0x0004 /* in2: P2 is an input */"
|
||||
puts "#define OPFLG_IN3 0x0008 /* in3: P3 is an input */"
|
||||
puts "#define OPFLG_OUT2 0x0010 /* out2: P2 is an output */"
|
||||
puts "#define OPFLG_OUT3 0x0020 /* out3: P3 is an output */"
|
||||
puts "#define OPFLG_JUMP 0x01 /* jump: P2 holds jmp target */"
|
||||
puts "#define OPFLG_IN1 0x02 /* in1: P1 is an input */"
|
||||
puts "#define OPFLG_IN2 0x04 /* in2: P2 is an input */"
|
||||
puts "#define OPFLG_IN3 0x08 /* in3: P3 is an input */"
|
||||
puts "#define OPFLG_OUT2 0x10 /* out2: P2 is an output */"
|
||||
puts "#define OPFLG_OUT3 0x20 /* out3: P3 is an output */"
|
||||
puts "#define OPFLG_INITIALIZER \173\\"
|
||||
for {set i 0} {$i<=$max} {incr i} {
|
||||
if {$i%8==0} {
|
||||
|
Reference in New Issue
Block a user