summaryrefslogtreecommitdiff
path: root/ext/pdo_sqlite/sqlite/mkopcodeh.awk
diff options
context:
space:
mode:
Diffstat (limited to 'ext/pdo_sqlite/sqlite/mkopcodeh.awk')
-rw-r--r--ext/pdo_sqlite/sqlite/mkopcodeh.awk90
1 files changed, 60 insertions, 30 deletions
diff --git a/ext/pdo_sqlite/sqlite/mkopcodeh.awk b/ext/pdo_sqlite/sqlite/mkopcodeh.awk
index 0fa50ead09..796a7afe7a 100644
--- a/ext/pdo_sqlite/sqlite/mkopcodeh.awk
+++ b/ext/pdo_sqlite/sqlite/mkopcodeh.awk
@@ -41,15 +41,21 @@
# Remember the TK_ values from the parse.h file
/^#define TK_/ {
- tk[$2] = $3
+ tk[$2] = 0+$3
}
# Scan for "case OP_aaaa:" lines in the vdbe.c file
/^case OP_/ {
name = $2
- gsub(/:/,"",name)
- gsub("\r","",name)
+ sub(/:/,"",name)
+ sub("\r","",name)
op[name] = -1
+ jump[name] = 0
+ out2_prerelease[name] = 0
+ in1[name] = 0
+ in2[name] = 0
+ in3[name] = 0
+ out3[name] = 0
for(i=3; i<NF; i++){
if($i=="same" && $(i+1)=="as"){
sym = $(i+2)
@@ -58,8 +64,20 @@
used[op[name]] = 1
sameas[op[name]] = sym
}
- if($i=="no-push"){
- nopush[name] = 1
+ x = $i
+ sub(",","",x)
+ if(x=="jump"){
+ jump[name] = 1
+ }else if(x=="out2-prerelease"){
+ out2_prerelease[name] = 1
+ }else if(x=="in1"){
+ in1[name] = 1
+ }else if(x=="in2"){
+ in2[name] = 1
+ }else if(x=="in3"){
+ in3[name] = 1
+ }else if(x=="out3"){
+ out3[name] = 1
}
}
}
@@ -70,6 +88,8 @@ END {
max = 0
print "/* Automatically generated. Do not edit */"
print "/* See the mkopcodeh.awk script for details */"
+ op["OP_Noop"] = -1;
+ op["OP_Explain"] = -1;
for(name in op){
if( op[name]<0 ){
cnt++
@@ -96,32 +116,42 @@ END {
}
}
- # Generate the 10 16-bit bitmasks used by function opcodeUsesStack()
- # in vdbeaux.c. See comments in that function for details.
- #
- nopush[0] = 0 # 0..15
- nopush[1] = 0 # 16..31
- nopush[2] = 0 # 32..47
- nopush[3] = 0 # 48..63
- nopush[4] = 0 # 64..79
- nopush[5] = 0 # 80..95
- nopush[6] = 0 # 96..111
- nopush[7] = 0 # 112..127
- nopush[8] = 0 # 128..143
- nopush[9] = 0 # 144..159
+ # Generate the bitvectors:
+ #
+ # bit 0: jump
+ # bit 1: pushes a result onto stack
+ # bit 2: output to p1. release p1 before opcode runs
+ #
+ for(i=0; i<=max; i++) bv[i] = 0;
for(name in op){
- if( nopush[name] ){
- n = op[name]
- j = n%16
- i = ((n - j)/16)
- nopush[i] = nopush[i] + (2^j)
- }
+ x = op[name]
+ a0 = a1 = a2 = a3 = a4 = a5 = a6 = a7 = 0
+ # a8 = a9 = a10 = a11 = a12 = a13 = a14 = a15 = 0
+ if( jump[name] ) a0 = 1;
+ if( out2_prerelease[name] ) a1 = 2;
+ if( in1[name] ) a2 = 4;
+ if( in2[name] ) a3 = 8;
+ if( in3[name] ) a4 = 16;
+ if( out3[name] ) a5 = 32;
+ # bv[x] = a0+a1+a2+a3+a4+a5+a6+a7+a8+a9+a10+a11+a12+a13+a14+a15;
+ bv[x] = a0+a1+a2+a3+a4+a5+a6+a7;
}
- printf "\n"
- print "/* Opcodes that are guaranteed to never push a value onto the stack"
- print "** contain a 1 their corresponding position of the following mask"
- print "** set. See the opcodeNoPush() function in vdbeaux.c */"
- for(i=0; i<10; i++){
- printf "#define NOPUSH_MASK_%d 0x%04x\n", i, nopush[i]
+ print "\n"
+ print "/* Properties such as \"out2\" or \"jump\" that are specified in"
+ print "** comments following the \"case\" for each opcode in the vdbe.c"
+ print "** are encoded into bitvectors as follows:"
+ print "*/"
+ print "#define OPFLG_JUMP 0x0001 /* jump: P2 holds jmp target */"
+ print "#define OPFLG_OUT2_PRERELEASE 0x0002 /* out2-prerelease: */"
+ print "#define OPFLG_IN1 0x0004 /* in1: P1 is an input */"
+ print "#define OPFLG_IN2 0x0008 /* in2: P2 is an input */"
+ print "#define OPFLG_IN3 0x0010 /* in3: P3 is an input */"
+ print "#define OPFLG_OUT3 0x0020 /* out3: P3 is an output */"
+ print "#define OPFLG_INITIALIZER {\\"
+ for(i=0; i<=max; i++){
+ if( i%8==0 ) printf("/* %3d */",i)
+ printf " 0x%02x,", bv[i]
+ if( i%8==7 ) printf("\\\n");
}
+ print "}"
}