/ Check-in [e730195f]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Update the generator AWK script for opcodes.h so that it always generates opcode numbers in the same order and is not dependent on the hash order of opcode names within AWK.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e730195f52429dc1bc4c1559880effd68e3eced9
User & Date: drh 2009-11-02 18:14:50
Context
2009-11-02
18:44
Bug fix in the recent changes to mkopcodeh.awk. check-in: 6610cac4 user: drh tags: trunk
18:14
Update the generator AWK script for opcodes.h so that it always generates opcode numbers in the same order and is not dependent on the hash order of opcode names within AWK. check-in: e730195f user: drh tags: trunk
18:01
Do not insert the date and time of generation into the amalgamation. check-in: 9f6cf13d user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to mkopcodeh.awk.

    21     21   # OP_Add and OP_Divide.  By making TK_ADD==OP_Add and TK_DIVIDE==OP_Divide,
    22     22   # code to translate from one to the other is avoided.  This makes the
    23     23   # code generator run (infinitesimally) faster and more importantly it makes
    24     24   # the library footprint smaller.
    25     25   #
    26     26   # This script also scans for lines of the form:
    27     27   #
    28         -#       case OP_aaaa:       /* no-push */
           28  +#       case OP_aaaa:       /* jump, in1, in2, in3, out2-prerelease, out3 */
    29     29   #
    30         -# When the no-push comment is found on an opcode, it means that that
    31         -# opcode does not leave a result on the stack.  By identifying which
    32         -# opcodes leave results on the stack it is possible to determine a
    33         -# much smaller upper bound on the size of the stack.  This allows
    34         -# a smaller stack to be allocated, which is important to embedded
    35         -# systems with limited memory space.  This script generates a series
    36         -# of "NOPUSH_MASK" defines that contain bitmaps of opcodes that leave
    37         -# results on the stack.  The NOPUSH_MASK defines are used in vdbeaux.c
    38         -# to help determine the maximum stack size.
           30  +# When such comments are found on an opcode, it means that certain
           31  +# properties apply to that opcode.  Set corresponding flags using the
           32  +# OPFLG_INITIALIZER macro.
    39     33   #
    40     34   
    41     35   
    42     36   # Remember the TK_ values from the parse.h file
    43     37   /^#define TK_/ {
    44     38     tk[$2] = 0+$3
    45     39   }
................................................................................
    76     70         in2[name] = 1
    77     71       }else if(x=="in3"){
    78     72         in3[name] = 1
    79     73       }else if(x=="out3"){
    80     74         out3[name] = 1
    81     75       }
    82     76     }
           77  +  order[n_op++] = name;
    83     78   }
    84     79   
    85     80   # Assign numbers to all opcodes and output the result.
    86     81   END {
    87     82     cnt = 0
    88     83     max = 0
    89     84     print "/* Automatically generated.  Do not edit */"
    90     85     print "/* See the mkopcodeh.awk script for details */"
    91     86     op["OP_Noop"] = -1;
    92     87     op["OP_Explain"] = -1;
    93         -  for(name in op){
           88  +  for(i=0; i<n_op; i++){
           89  +    name = order[i];
    94     90       if( op[name]<0 ){
    95     91         cnt++
    96     92         while( used[cnt] ) cnt++
    97     93         op[name] = cnt
    98     94       }
    99     95       used[op[name]] = 1;
   100     96       if( op[name]>max ) max = op[name]
................................................................................
   119    115     # Generate the bitvectors:
   120    116     #
   121    117     #  bit 0:     jump
   122    118     #  bit 1:     pushes a result onto stack
   123    119     #  bit 2:     output to p1.  release p1 before opcode runs
   124    120     #
   125    121     for(i=0; i<=max; i++) bv[i] = 0;
   126         -  for(name in op){
          122  +  for(i=0; i<n_op; i++){
          123  +    name = order[i];
   127    124       x = op[name]
   128    125       a0 = a1 = a2 = a3 = a4 = a5 = a6 = a7 = 0
   129    126       # a8 = a9 = a10 = a11 = a12 = a13 = a14 = a15 = 0
   130    127       if( jump[name] ) a0 = 1;
   131    128       if( out2_prerelease[name] ) a1 = 2;
   132    129       if( in1[name] ) a2 = 4;
   133    130       if( in2[name] ) a3 = 8;