From 569c6676a6ddb0ff73821d7693b5e18ddef809b9 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 16 Oct 2014 22:51:35 -0400 Subject: Imported Upstream version 3.2.0 --- mkopcodeh.awk | 126 ++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 100 insertions(+), 26 deletions(-) (limited to 'mkopcodeh.awk') diff --git a/mkopcodeh.awk b/mkopcodeh.awk index f6b90c1..babfdc6 100644 --- a/mkopcodeh.awk +++ b/mkopcodeh.awk @@ -35,7 +35,34 @@ # Remember the TK_ values from the parse.h file /^#define TK_/ { - tk[$2] = 0+$3 + tk[$2] = 0+$3 # tk[x] holds the numeric value for TK symbol X +} + +# Find "/* Opcode: " lines in the vdbe.c file. Each one introduces +# a new opcode. Remember which parameters are used. +/^.. Opcode: / { + currentOp = "OP_" $3 + m = 0 + for(i=4; i<=NF; i++){ + x = $i + if( x=="P1" ) m += 1 + if( x=="P2" ) m += 2 + if( x=="P3" ) m += 4 + if( x=="P4" ) m += 8 + if( x=="P5" ) m += 16 + } + paramused[currentOp] = m +} + +# Find "** Synopsis: " lines that follow Opcode: +/^.. Synopsis: / { + if( currentOp ){ + x = $3 + for(i=4; i<=NF; i++){ + x = x " " $i + } + synopsis[currentOp] = x + } } # Scan for "case OP_aaaa:" lines in the vdbe.c file @@ -43,7 +70,7 @@ name = $2 sub(/:/,"",name) sub("\r","",name) - op[name] = -1 + op[name] = -1 # op[x] holds the numeric value for OP symbol x jump[name] = 0 out2_prerelease[name] = 0 in1[name] = 0 @@ -55,9 +82,11 @@ if($i=="same" && $(i+1)=="as"){ sym = $(i+2) sub(/,/,"",sym) - op[name] = tk[sym] - used[op[name]] = 1 - sameas[op[name]] = sym + val = tk[sym] + op[name] = val + used[val] = 1 + sameas[val] = sym + def[val] = name } x = $i sub(",","",x) @@ -90,31 +119,69 @@ END { order[n_op++] = "OP_Noop"; op["OP_Explain"] = -1; order[n_op++] = "OP_Explain"; + + # Assign small values to opcodes that are processed by resolveP2Values() + # to make code generation for the switch() statement smaller and faster. for(i=0; i=0 ) continue; + if( name=="OP_Function" \ + || name=="OP_AggStep" \ + || name=="OP_Transaction" \ + || name=="OP_AutoCommit" \ + || name=="OP_Savepoint" \ + || name=="OP_Checkpoint" \ + || name=="OP_Vacuum" \ + || name=="OP_JournalMode" \ + || name=="OP_VUpdate" \ + || name=="OP_VFilter" \ + || name=="OP_Next" \ + || name=="OP_NextIfOpen" \ + || name=="OP_SorterNext" \ + || name=="OP_Prev" \ + || name=="OP_PrevIfOpen" \ + ){ cnt++ while( used[cnt] ) cnt++ op[name] = cnt + used[cnt] = 1 + def[cnt] = name } - used[op[name]] = 1; - if( op[name]>max ) max = op[name] - printf "#define %-25s %15d", name, op[name] - if( sameas[op[name]] ) { - printf " /* same as %-12s*/", sameas[op[name]] - } - printf "\n" + } + # Generate the numeric values for opcodes + for(i=0; i