1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-08 03:22:21 +03:00

Begin setting a foundation on which to convert the VM from a stack-based

to a register-based machine.  Everything is still mostly stack based with
this check-in.  This change merely begins adding infrastructure to support
a register-based architecture. (CVS 4652)

FossilOrigin-Name: 051ec01f2799e095516015f2ef0180e50fac387c
This commit is contained in:
drh
2008-01-02 00:34:36 +00:00
parent 8f2c54e6e2
commit d4e70ebd6f
17 changed files with 403 additions and 225 deletions

View File

@@ -12,7 +12,7 @@
** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite.
**
** $Id: expr.c,v 1.321 2008/01/01 19:02:09 danielk1977 Exp $
** $Id: expr.c,v 1.322 2008/01/02 00:34:37 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -1647,7 +1647,7 @@ int sqlite3FindInIndex(Parse *pParse, Expr *pX, int mustBeUnique){
sqlite3VdbeAddOp(v, OP_MemInt, 1, iMem);
sqlite3VdbeAddOp(v, OP_Integer, iDb, 0);
VdbeComment((v, "# %s", pIdx->zName));
VdbeComment((v, "%s", pIdx->zName));
sqlite3VdbeOp3(v,OP_OpenRead,iTab,pIdx->tnum,pKey,P3_KEYINFO_HANDOFF);
eType = IN_INDEX_INDEX;
sqlite3VdbeAddOp(v, OP_SetNumColumns, iTab, pIdx->nColumn);
@@ -1806,11 +1806,11 @@ void sqlite3CodeSubselect(Parse *pParse, Expr *pExpr){
if( pExpr->op==TK_SELECT ){
sop = SRT_Mem;
sqlite3VdbeAddOp(v, OP_MemNull, iMem, 0);
VdbeComment((v, "# Init subquery result"));
VdbeComment((v, "Init subquery result"));
}else{
sop = SRT_Exists;
sqlite3VdbeAddOp(v, OP_MemInt, 0, iMem);
VdbeComment((v, "# Init EXISTS result"));
VdbeComment((v, "Init EXISTS result"));
}
sqlite3ExprDelete(pSel->pLimit);
pSel->pLimit = sqlite3PExpr(pParse, TK_INTEGER, 0, 0, &one);
@@ -2174,7 +2174,7 @@ void sqlite3ExprCode(Parse *pParse, Expr *pExpr){
sqlite3CodeSubselect(pParse, pExpr);
}
sqlite3VdbeAddOp(v, OP_MemLoad, pExpr->iColumn, 0);
VdbeComment((v, "# load subquery result"));
VdbeComment((v, "load subquery result"));
break;
}
case TK_IN: {
@@ -2301,7 +2301,7 @@ void sqlite3ExprCode(Parse *pParse, Expr *pExpr){
assert( pExpr->iColumn == OE_Ignore );
sqlite3VdbeAddOp(v, OP_ContextPop, 0, 0);
sqlite3VdbeAddOp(v, OP_Goto, 0, pParse->trigStack->ignoreJump);
VdbeComment((v, "# raise(IGNORE)"));
VdbeComment((v, "raise(IGNORE)"));
}
stackChng = 0;
break;
@@ -2344,6 +2344,26 @@ void sqlite3ExprCodeAndCache(Parse *pParse, Expr *pExpr){
}
#endif
/*
** Generate code to evaluate an expression and store the result in
** a designated register. If the target register number is negative,
** allocate a new register to store the result. Return the target
** register number regardless.
**
** The current implementation is a rough prototype for experimental
** purposes. There are many optimization opportunities here.
*/
int sqlite3ExprIntoReg(Parse *pParse, Expr *pExpr, int target){
Vdbe *v = pParse->pVdbe;
if( v==0 ) return -1;
sqlite3ExprCode(pParse, pExpr);
if( target<0 ){
target = pParse->nMem++;
}
sqlite3VdbeAddOp(v, OP_MemStore, target, 1);
return target;
}
/*
** Generate code that pushes the value of every element of the given
** expression list onto the stack.