aboutsummaryrefslogtreecommitdiff
path: root/tool/mkopcodeh.tcl
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2016-02-02 02:22:30 +0000
committerdrh <drh@noemail.net>2016-02-02 02:22:30 +0000
commit33c1eb64772caf48a33d92e1a3c5a577c9ba1aa9 (patch)
treee820c4a4276381c4c71f8cf891e75dc67302fa8b /tool/mkopcodeh.tcl
parente1ed0bb6077cc223fa54f58ae835f133d1c4aa59 (diff)
parentb8db549832d2acc2fc30327e6fb5c0474820f122 (diff)
downloadsqlite-33c1eb64772caf48a33d92e1a3c5a577c9ba1aa9.tar.gz
sqlite-33c1eb64772caf48a33d92e1a3c5a577c9ba1aa9.zip
Merge all recent enhancements from trunk.
FossilOrigin-Name: f3f9200115caf4b356f90ec97c351d1afbcb9bf6
Diffstat (limited to 'tool/mkopcodeh.tcl')
-rw-r--r--tool/mkopcodeh.tcl54
1 files changed, 29 insertions, 25 deletions
diff --git a/tool/mkopcodeh.tcl b/tool/mkopcodeh.tcl
index 4c36f24ba..053c7f898 100644
--- a/tool/mkopcodeh.tcl
+++ b/tool/mkopcodeh.tcl
@@ -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} {