From: <wel...@us...> - 2009-12-09 13:21:11
|
Revision: 4934 http://planeshift.svn.sourceforge.net/planeshift/?rev=4934&view=rev Author: weltall2 Date: 2009-12-09 13:20:59 +0000 (Wed, 09 Dec 2009) Log Message: ----------- updated fparser to 4.0.2 * Fixed bug which caused functions like "x*4/2" to be parsed incorrectly. * Fixed bug with functions of type "cosh(asinh(x))" which potentially caused a stack corruption. Modified Paths: -------------- trunk/src/tools/fparser/fp_identifier_parser.inc trunk/src/tools/fparser/fp_opcode_add.inc trunk/src/tools/fparser/fparser.cpp trunk/src/tools/fparser/fparser.h trunk/src/tools/fparser/fparser.html trunk/src/tools/fparser/fparser_gmpint.h trunk/src/tools/fparser/fparser_mpfr.h trunk/src/tools/fparser/fpaux.h trunk/src/tools/fparser/fpconfig.h trunk/src/tools/fparser/fpoptimizer.cpp trunk/src/tools/fparser/fptypes.h Modified: trunk/src/tools/fparser/fp_identifier_parser.inc =================================================================== --- trunk/src/tools/fparser/fp_identifier_parser.inc 2009-12-08 22:31:33 UTC (rev 4933) +++ trunk/src/tools/fparser/fp_identifier_parser.inc 2009-12-09 13:20:59 UTC (rev 4934) @@ -9,7 +9,8 @@ function names that long just are not defined, the point is moot. */ const unsigned char* const uptr = (const unsigned char*) input; - while(nameLength < maximumNameLength) + typedef signed char schar; + while(likely(nameLength < maximumNameLength)) { unsigned char byte = uptr[nameLength+0]; /* Handle the common case of A-Za-z first */ @@ -45,7 +46,7 @@ if(byte == 0xC2 && uptr[nameLength+1]==0xA0) break; // skip nbsp // C2-DF - next common case when >= 0x40 // Valid sequence: C2-DF 80-BF - if((unsigned char)(uptr[nameLength+1] - 0x80) > (0xBF-0x80)) break; + if(schar(uptr[nameLength+1]) > schar(0xBF)) break; nameLength += 2; continue; } @@ -59,18 +60,21 @@ if(byte == 0xED) break; // ED is invalid // Valid sequence: E1-EC 80-BF 80-BF // And: EE-EF 80-BF 80-BF - if(byte == 0xE2 && uptr[nameLength+1] == 0x80 - && ((uptr[nameLength+2] >= 0x80 - && uptr[nameLength+2] <= 0x8B) - || (uptr[nameLength+2] == 0xAF))) break; // break on various space characters - if(byte == 0xE2 && uptr[nameLength+1] == 0x81 - && uptr[nameLength+2] == 0x9F) break; // this too + if(byte == 0xE2) + { + // break on various space characters + if(uptr[nameLength+1] == 0x80 + && (schar(uptr[nameLength+2]) <= schar(0x8B) + || (uptr[nameLength+2] == 0xAF))) break; + if(uptr[nameLength+1] == 0x81 + && uptr[nameLength+2] == 0x9F) break; + } else if(byte == 0xE3 && uptr[nameLength+1] == 0x80 && uptr[nameLength+2] == 0x80) break; // this too - if((unsigned char)(uptr[nameLength+1] - 0x80) > (0xBF-0x80)) break; + if(schar(uptr[nameLength+1]) > schar(0xBF)) break; } - if((unsigned char)(uptr[nameLength+2] - 0x80) > (0xBF-0x80)) break; + if(schar(uptr[nameLength+2]) > schar(0xBF)) break; nameLength += 3; continue; } @@ -85,17 +89,17 @@ if(byte == 0xF4) // F4 { // Valid sequence: F4 80-8F - if((unsigned char)(uptr[nameLength+1] - 0x80) > (0x8F-0x80)) break; + if(schar(uptr[nameLength+1]) > schar(0x8F)) break; } else { // F1-F3 // Valid sequence: F1-F3 80-BF 80-BF 80-BF - if((unsigned char)(uptr[nameLength+1] - 0x80) > (0xBF-0x80)) break; + if(schar(uptr[nameLength+1]) > schar(0xBF)) break; } } - if((unsigned char)(uptr[nameLength+2] - 0x80) > (0xBF-0x80)) break; - if((unsigned char)(uptr[nameLength+3] - 0x80) > (0xBF-0x80)) break; + if(schar(uptr[nameLength+2]) > schar(0xBF)) break; + if(schar(uptr[nameLength+3]) > schar(0xBF)) break; nameLength += 4; continue; } Modified: trunk/src/tools/fparser/fp_opcode_add.inc =================================================================== --- trunk/src/tools/fparser/fp_opcode_add.inc 2009-12-08 22:31:33 UTC (rev 4933) +++ trunk/src/tools/fparser/fp_opcode_add.inc 2009-12-09 13:20:59 UTC (rev 4934) @@ -1,4 +1,4 @@ -/* Function Parser for C++ v4.0.1 +/* Function Parser for C++ v4.0.2 Note: This file contains generated code and is thus not intended to be to be modified by hand. It was generated by @@ -18,8 +18,674 @@ ByteCodePtr = !data->ByteCode.empty() ? &data->ByteCode[0] + data->ByteCode.size() - 1 : 0; \ ImmedPtr = !data->Immed.empty() ? &data->Immed[0] + data->Immed.size() - 1 : 0; FP_ReDefinePointers(); +#if(!FP_FLOAT_VERSION) Value_t x; + unsigned A; Value_t y; + switch(opcode) + { + TailCall_cNeg: + case cNeg: + switch(ByteCodePtr[0]) + { + case cMul: + switch(ByteCodePtr[-1]) + { + case cImmed: + x = ImmedPtr[0]; + FP_TRACE_BYTECODE_OPTIMIZATION("x cMul cNeg", "[-x] cMul"); + /* ByteCodePtr[-1] = cImmed; */ // redundant, matches x @ 2 + /* ByteCodePtr[0] = cMul; */ // redundant, matches cMul @ 1 + goto Laa; + } + break; + case cNeg: + FP_TRACE_BYTECODE_OPTIMIZATION("cNeg cNeg", ""); + goto Lab; + case cImmed: + x = ImmedPtr[0]; + FP_TRACE_BYTECODE_OPTIMIZATION("x cNeg", "[-x]"); + /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 + goto Laa; + } + break; + TailCall_cInv: + case cInv: + switch(ByteCodePtr[0]) + { + case cInv: + FP_TRACE_BYTECODE_OPTIMIZATION("cInv cInv", ""); + goto Lab; + case cImmed: + x = ImmedPtr[0]; + if(x!=Value_t(0)) + { + FP_TRACE_BYTECODE_OPTIMIZATION("x[x!=Value_t(0)] cInv", "[Value_t(1)/x]"); + /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 + goto Lac; + } + break; + } + break; + TailCall_cMul: + case cMul: + switch(ByteCodePtr[0]) + { + case cInv: + FP_TRACE_BYTECODE_OPTIMIZATION("cInv cMul", "cDiv"); + goto Lad; + case cImmed: + x = ImmedPtr[0]; + if(x==Value_t(0)) + { + switch(ByteCodePtr[-1]) + { + case cImmed: break; + default: + A = ByteCodePtr[-1]; + if(A >= VarBegin) + { + FP_TRACE_BYTECODE_OPTIMIZATION("A[A >= VarBegin] x[x==Value_t(0)] cMul", "[x]"); + /* ImmedPtr[0] = x; */ // redundant, matches x @ 1 + goto Lae; + } + } + } + switch(ByteCodePtr[-1]) + { + case cNeg: + FP_TRACE_BYTECODE_OPTIMIZATION("cNeg x cMul", "[-x] cMul"); + /* opcode = cMul; */ // redundant, matches cMul @ 0 + goto Laf; + case cMul: + switch(ByteCodePtr[-2]) + { + case cImmed: + y = ImmedPtr[-1]; + FP_TRACE_BYTECODE_OPTIMIZATION("y cMul x cMul", "[y*x] cMul"); + /* ByteCodePtr[-2] = cImmed; */ // redundant, matches y @ 3 + /* ByteCodePtr[-1] = cMul; */ // redundant, matches cMul @ 2 + goto Lag; + } + break; + case cImmed: + y = ImmedPtr[-1]; + FP_TRACE_BYTECODE_OPTIMIZATION("y x cMul", "[y*x]"); + /* ByteCodePtr[-1] = cImmed; */ // redundant, matches y @ 2 + goto Lag; + } + if(x==Value_t(1)) + { + FP_TRACE_BYTECODE_OPTIMIZATION("x[x==Value_t(1)] cMul", ""); + goto Lah; + } + if(x==Value_t(2)) + { + FP_TRACE_BYTECODE_OPTIMIZATION("x[x==Value_t(2)] cMul", "cDup cAdd"); + goto Lai; + } + if(x==Value_t(-1)) + { + FP_TRACE_BYTECODE_OPTIMIZATION("x[x==Value_t(-1)] cMul", "cNeg"); + goto Laj; + } + break; + default: + A = ByteCodePtr[0]; + FP_TRACE_BYTECODE_OPTIMIZATION("A cMul", "[DO_MAYBE_SQR]"); + if(A >= VarBegin) + { + if(A == ByteCodePtr[-1]) + { ByteCodePtr[0] = cSqr; return; } + if(ByteCodePtr[-1] == cMul && A == ByteCodePtr[-2]) + { ByteCodePtr[0] = cMul; ByteCodePtr[-1] = cSqr; return; } + } + } + break; + TailCall_cDiv: + case cDiv: + switch(ByteCodePtr[0]) + { + case cImmed: + x = ImmedPtr[0]; + if(x!=Value_t(0)) + { + switch(ByteCodePtr[-1]) + { + case cImmed: + y = ImmedPtr[-1]; + FP_TRACE_BYTECODE_OPTIMIZATION("y x[x!=Value_t(0)] cDiv", "[y/x]"); + /* ByteCodePtr[-1] = cImmed; */ // redundant, matches y @ 2 + goto Lak; + } + } + switch(ByteCodePtr[-1]) + { + case cNeg: + FP_TRACE_BYTECODE_OPTIMIZATION("cNeg x cDiv", "[-x] cDiv"); + /* opcode = cDiv; */ // redundant, matches cDiv @ 0 + goto Lal; + } + if(x==Value_t(1)) + { + FP_TRACE_BYTECODE_OPTIMIZATION("x[x==Value_t(1)] cDiv", ""); + goto Lah; + } + break; + } + break; + TailCall_cMod: + case cMod: + switch(ByteCodePtr[0]) + { + case cImmed: + x = ImmedPtr[0]; + if(x!=Value_t(0)) + { + switch(ByteCodePtr[-1]) + { + case cImmed: + y = ImmedPtr[-1]; + FP_TRACE_BYTECODE_OPTIMIZATION("y x[x!=Value_t(0)] cMod", "[fp_mod(y,x)]"); + /* ByteCodePtr[-1] = cImmed; */ // redundant, matches y @ 2 + goto Lam; + } + } + break; + } + break; + TailCall_cAdd: + case cAdd: + switch(ByteCodePtr[0]) + { + case cDup: + switch(ByteCodePtr[-1]) + { + case cAdd: + switch(ByteCodePtr[-2]) + { + case cDup: + FP_TRACE_BYTECODE_OPTIMIZATION("cDup cAdd cDup cAdd", "[4] cMul"); + goto Lan; + } + break; + } + break; + case cNeg: + FP_TRACE_BYTECODE_OPTIMIZATION("cNeg cAdd", "cSub"); + goto Lba; + case cImmed: + x = ImmedPtr[0]; + switch(ByteCodePtr[-1]) + { + case cAdd: + switch(ByteCodePtr[-2]) + { + case cImmed: + y = ImmedPtr[-1]; + FP_TRACE_BYTECODE_OPTIMIZATION("y cAdd x cAdd", "[y+x] cAdd"); + /* ByteCodePtr[-2] = cImmed; */ // redundant, matches y @ 3 + /* ByteCodePtr[-1] = cAdd; */ // redundant, matches cAdd @ 2 + goto Lbb; + } + break; + case cSub: + switch(ByteCodePtr[-2]) + { + case cImmed: + y = ImmedPtr[-1]; + FP_TRACE_BYTECODE_OPTIMIZATION("y cSub x cAdd", "[y-x] cSub"); + /* ByteCodePtr[-2] = cImmed; */ // redundant, matches y @ 3 + /* ByteCodePtr[-1] = cSub; */ // redundant, matches cSub @ 2 + goto Lbc; + } + break; + case cImmed: + y = ImmedPtr[-1]; + FP_TRACE_BYTECODE_OPTIMIZATION("y x cAdd", "[y+x]"); + /* ByteCodePtr[-1] = cImmed; */ // redundant, matches y @ 2 + goto Lbb; + } + if(x==Value_t(0)) + { + FP_TRACE_BYTECODE_OPTIMIZATION("x[x==Value_t(0)] cAdd", ""); + goto Lah; + } + break; + } + break; + TailCall_cSub: + case cSub: + switch(ByteCodePtr[0]) + { + case cNeg: + FP_TRACE_BYTECODE_OPTIMIZATION("cNeg cSub", "cAdd"); + goto Lbd; + case cImmed: + x = ImmedPtr[0]; + switch(ByteCodePtr[-1]) + { + case cSub: + switch(ByteCodePtr[-2]) + { + case cImmed: + y = ImmedPtr[-1]; + FP_TRACE_BYTECODE_OPTIMIZATION("y cSub x cSub", "[y+x] cSub"); + /* ByteCodePtr[-2] = cImmed; */ // redundant, matches y @ 3 + /* ByteCodePtr[-1] = cSub; */ // redundant, matches cSub @ 2 + goto Lbb; + } + break; + case cAdd: + switch(ByteCodePtr[-2]) + { + case cImmed: + y = ImmedPtr[-1]; + FP_TRACE_BYTECODE_OPTIMIZATION("y cAdd x cSub", "[y-x] cAdd"); + /* ByteCodePtr[-2] = cImmed; */ // redundant, matches y @ 3 + /* ByteCodePtr[-1] = cAdd; */ // redundant, matches cAdd @ 2 + goto Lbc; + } + break; + case cImmed: + y = ImmedPtr[-1]; + FP_TRACE_BYTECODE_OPTIMIZATION("y x cSub", "[y-x]"); + /* ByteCodePtr[-1] = cImmed; */ // redundant, matches y @ 2 + goto Lbc; + } + if(x==Value_t(0)) + { + FP_TRACE_BYTECODE_OPTIMIZATION("x[x==Value_t(0)] cSub", ""); + goto Lah; + } + break; + } + break; + TailCall_cMin: + case cMin: + switch(ByteCodePtr[0]) + { + case cImmed: + x = ImmedPtr[0]; + switch(ByteCodePtr[-1]) + { + case cImmed: + y = ImmedPtr[-1]; + FP_TRACE_BYTECODE_OPTIMIZATION("y x cMin", "[Min(x,y)]"); + /* ByteCodePtr[-1] = cImmed; */ // redundant, matches y @ 2 + goto Lbe; + } + break; + } + break; + TailCall_cMax: + case cMax: + switch(ByteCodePtr[0]) + { + case cImmed: + x = ImmedPtr[0]; + switch(ByteCodePtr[-1]) + { + case cImmed: + y = ImmedPtr[-1]; + FP_TRACE_BYTECODE_OPTIMIZATION("y x cMax", "[Max(x,y)]"); + /* ByteCodePtr[-1] = cImmed; */ // redundant, matches y @ 2 + goto Lbf; + } + break; + } + break; + TailCall_cNot: + case cNot: + switch(ByteCodePtr[0]) + { + case cLess: + FP_TRACE_BYTECODE_OPTIMIZATION("cLess cNot", "cGreaterOrEq"); + goto Lbg; + case cLessOrEq: + FP_TRACE_BYTECODE_OPTIMIZATION("cLessOrEq cNot", "cGreater"); + goto Lbh; + case cGreater: + FP_TRACE_BYTECODE_OPTIMIZATION("cGreater cNot", "cLessOrEq"); + goto Lbi; + case cGreaterOrEq: + FP_TRACE_BYTECODE_OPTIMIZATION("cGreaterOrEq cNot", "cLess"); + goto Lbj; + case cEqual: + FP_TRACE_BYTECODE_OPTIMIZATION("cEqual cNot", "cNEqual"); + goto Lbk; + case cNEqual: + FP_TRACE_BYTECODE_OPTIMIZATION("cNEqual cNot", "cEqual"); + goto Lbl; + case cNeg: + FP_TRACE_BYTECODE_OPTIMIZATION("cNeg cNot", "cNot"); + /* opcode = cNot; */ // redundant, matches cNot @ 0 + goto Lbm; + case cAbs: + FP_TRACE_BYTECODE_OPTIMIZATION("cAbs cNot", "cNot"); + /* opcode = cNot; */ // redundant, matches cNot @ 0 + goto Lbm; + case cNot: + FP_TRACE_BYTECODE_OPTIMIZATION("cNot cNot", "cNotNot"); + goto Lbn; + case cNotNot: + FP_TRACE_BYTECODE_OPTIMIZATION("cNotNot cNot", "cNot"); + /* opcode = cNot; */ // redundant, matches cNot @ 0 + goto Lbm; + case cAbsNotNot: + FP_TRACE_BYTECODE_OPTIMIZATION("cAbsNotNot cNot", "cAbsNot"); + goto Lca; + case cAbsNot: + switch(ByteCodePtr[-1]) + { + case cImmed: break; + default: + A = ByteCodePtr[-1]; + if(IsLogicalOpcode(A)) + { + FP_TRACE_BYTECODE_OPTIMIZATION("A[IsLogicalOpcode(A)] cAbsNot cNot", "A"); + /* ByteCodePtr[-1] = A; */ // redundant, matches A @ 2 + goto Lab; + } + FP_TRACE_BYTECODE_OPTIMIZATION("A cAbsNot cNot", "A cAbsNotNot"); + /* ByteCodePtr[-1] = A; */ // redundant, matches A @ 2 + goto Lcb; + } + break; + case cImmed: + x = ImmedPtr[0]; + FP_TRACE_BYTECODE_OPTIMIZATION("x cNot", "[!truthValue(x)]"); + /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 + goto Lcc; + default: + A = ByteCodePtr[0]; + if(IsNeverNegativeValueOpcode(A)) + { + FP_TRACE_BYTECODE_OPTIMIZATION("A[IsNeverNegativeValueOpcode(A)] cNot", "A cAbsNot"); + /* ByteCodePtr[0] = A; */ // redundant, matches A @ 1 + goto Lcd; + } + } + break; + TailCall_cLess: + case cLess: + switch(ByteCodePtr[0]) + { + case cImmed: + x = ImmedPtr[0]; + if(x==Value_t(0)) + { + switch(ByteCodePtr[-1]) + { + case cImmed: break; + default: + A = ByteCodePtr[-1]; + if(IsNeverNegativeValueOpcode(A)) + { + FP_TRACE_BYTECODE_OPTIMIZATION("A[IsNeverNegativeValueOpcode(A)] x[x==Value_t(0)] cLess", "A [x] cMul"); + /* ByteCodePtr[-1] = A; */ // redundant, matches A @ 2 + /* ImmedPtr[0] = x; */ // redundant, matches x @ 1 + /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 + goto Lce; + } + } + } + switch(ByteCodePtr[-1]) + { + case cImmed: + y = ImmedPtr[-1]; + FP_TRACE_BYTECODE_OPTIMIZATION("y x cLess", "[fp_less(y,x)]"); + /* ByteCodePtr[-1] = cImmed; */ // redundant, matches y @ 2 + goto Lcf; + } + break; + } + break; + TailCall_cLessOrEq: + case cLessOrEq: + switch(ByteCodePtr[0]) + { + case cImmed: + x = ImmedPtr[0]; + switch(ByteCodePtr[-1]) + { + case cImmed: + y = ImmedPtr[-1]; + FP_TRACE_BYTECODE_OPTIMIZATION("y x cLessOrEq", "[fp_lessOrEq(y,x)]"); + /* ByteCodePtr[-1] = cImmed; */ // redundant, matches y @ 2 + goto Lcg; + } + break; + } + break; + TailCall_cGreater: + case cGreater: + switch(ByteCodePtr[0]) + { + case cImmed: + x = ImmedPtr[0]; + switch(ByteCodePtr[-1]) + { + case cImmed: + y = ImmedPtr[-1]; + FP_TRACE_BYTECODE_OPTIMIZATION("y x cGreater", "[fp_less(x,y)]"); + /* ByteCodePtr[-1] = cImmed; */ // redundant, matches y @ 2 + goto Lch; + } + break; + } + break; + TailCall_cGreaterOrEq: + case cGreaterOrEq: + switch(ByteCodePtr[0]) + { + case cImmed: + x = ImmedPtr[0]; + switch(ByteCodePtr[-1]) + { + case cImmed: + y = ImmedPtr[-1]; + FP_TRACE_BYTECODE_OPTIMIZATION("y x cGreaterOrEq", "[fp_lessOrEq(x,y)]"); + /* ByteCodePtr[-1] = cImmed; */ // redundant, matches y @ 2 + goto Lci; + } + break; + } + break; + TailCall_cEqual: + case cEqual: + switch(ByteCodePtr[0]) + { + case cImmed: + x = ImmedPtr[0]; + switch(ByteCodePtr[-1]) + { + case cImmed: + y = ImmedPtr[-1]; + FP_TRACE_BYTECODE_OPTIMIZATION("y x cEqual", "[fp_equal(y,x)]"); + /* ByteCodePtr[-1] = cImmed; */ // redundant, matches y @ 2 + goto Lcj; + } + break; + } + break; + TailCall_cNEqual: + case cNEqual: + switch(ByteCodePtr[0]) + { + case cImmed: + x = ImmedPtr[0]; + switch(ByteCodePtr[-1]) + { + case cImmed: + y = ImmedPtr[-1]; + FP_TRACE_BYTECODE_OPTIMIZATION("y x cNEqual", "[fp_nequal(y,x)]"); + /* ByteCodePtr[-1] = cImmed; */ // redundant, matches y @ 2 + goto Lck; + } + break; + } + break; + TailCall_cAnd: + case cAnd: + switch(ByteCodePtr[0]) + { + case cImmed: + x = ImmedPtr[0]; + switch(ByteCodePtr[-1]) + { + case cImmed: + y = ImmedPtr[-1]; + FP_TRACE_BYTECODE_OPTIMIZATION("y x cAnd", "[truthValue(x)&&truthValue(y)]"); + /* ByteCodePtr[-1] = cImmed; */ // redundant, matches y @ 2 + goto Lcl; + } + break; + } + break; + TailCall_cOr: + case cOr: + switch(ByteCodePtr[0]) + { + case cImmed: + x = ImmedPtr[0]; + switch(ByteCodePtr[-1]) + { + case cImmed: + y = ImmedPtr[-1]; + FP_TRACE_BYTECODE_OPTIMIZATION("y x cOr", "[truthValue(x)||truthValue(y)]"); + /* ByteCodePtr[-1] = cImmed; */ // redundant, matches y @ 2 + goto Lcm; + } + break; + } + break; + TailCall_cAbs: + case cAbs: + switch(ByteCodePtr[0]) + { + case cNeg: + FP_TRACE_BYTECODE_OPTIMIZATION("cNeg cAbs", "cAbs"); + /* opcode = cAbs; */ // redundant, matches cAbs @ 0 + goto Lcn; + case cImmed: break; + default: + A = ByteCodePtr[0]; + if(IsNeverNegativeValueOpcode(A)) + { + FP_TRACE_BYTECODE_OPTIMIZATION("A[IsNeverNegativeValueOpcode(A)] cAbs", "A"); + /* ByteCodePtr[0] = A; */ // redundant, matches A @ 1 + return; + } + } + break; + } + goto Lda; +Laa: ImmedPtr[0] = -x; return; +Lab: data->ByteCode.pop_back(); return; +Lac: ImmedPtr[0] = Value_t(1)/x; return; +Lad: ByteCodePtr -= 1; + data->ByteCode.pop_back(); + opcode = cDiv; +Ldb: goto TailCall_cDiv; +Lae: ByteCodePtr[-1] = cImmed; goto Lab; +Laf: ImmedPtr[0] = -x; + ByteCodePtr[-1] = cImmed; + ByteCodePtr -= 1; + data->ByteCode.pop_back(); +Ldc: goto TailCall_cMul; +Lag: ImmedPtr[-1] = y*x; +Lah: data->Immed.pop_back(); goto Lab; +Lai: ByteCodePtr[0] = cDup; + ImmedPtr -= 1; + data->Immed.pop_back(); +Ldd: opcode = cAdd; + goto TailCall_cAdd; +Laj: data->Immed.pop_back(); + data->ByteCode.pop_back(); + opcode = cNeg; + FP_ReDefinePointers(); + goto TailCall_cNeg; +Lak: ImmedPtr[-1] = y/x; goto Lah; +Lal: ImmedPtr[0] = -x; + ByteCodePtr[-1] = cImmed; + ByteCodePtr -= 1; + data->ByteCode.pop_back(); goto Ldb; +Lam: ImmedPtr[-1] = fp_mod(y,x); goto Lah; +Lan: data->Immed.push_back(4); + ByteCodePtr[-2] = cImmed; + ByteCodePtr -= 2; + data->ByteCode.pop_back(); + data->ByteCode.pop_back(); + opcode = cMul; + FP_ReDefinePointers(); goto Ldc; +Lba: ByteCodePtr -= 1; + data->ByteCode.pop_back(); + opcode = cSub; + goto TailCall_cSub; +Lbb: ImmedPtr[-1] = y+x; goto Lah; +Lbc: ImmedPtr[-1] = y-x; goto Lah; +Lbd: ByteCodePtr -= 1; + data->ByteCode.pop_back(); goto Ldd; +Lbe: ImmedPtr[-1] = Min(x,y); goto Lah; +Lbf: ImmedPtr[-1] = Max(x,y); goto Lah; +Lbg: ByteCodePtr -= 1; + data->ByteCode.pop_back(); + opcode = cGreaterOrEq; + goto TailCall_cGreaterOrEq; +Lbh: ByteCodePtr -= 1; + data->ByteCode.pop_back(); + opcode = cGreater; + goto TailCall_cGreater; +Lbi: ByteCodePtr -= 1; + data->ByteCode.pop_back(); + opcode = cLessOrEq; + goto TailCall_cLessOrEq; +Lbj: ByteCodePtr -= 1; + data->ByteCode.pop_back(); + opcode = cLess; + goto TailCall_cLess; +Lbk: ByteCodePtr -= 1; + data->ByteCode.pop_back(); + opcode = cNEqual; + goto TailCall_cNEqual; +Lbl: ByteCodePtr -= 1; + data->ByteCode.pop_back(); + opcode = cEqual; + goto TailCall_cEqual; +Lbm: ByteCodePtr -= 1; + data->ByteCode.pop_back(); + goto TailCall_cNot; +Lbn: ByteCodePtr[0] = cNotNot; return; +Lca: ByteCodePtr[0] = cAbsNot; return; +Lcb: ByteCodePtr[0] = cAbsNotNot; return; +Lcc: ImmedPtr[0] = !truthValue(x); return; +Lcd: data->ByteCode.push_back(cAbsNot); return; +Lce: opcode = cMul; goto Ldc; +Lcf: ImmedPtr[-1] = fp_less(y,x); goto Lah; +Lcg: ImmedPtr[-1] = fp_lessOrEq(y,x); goto Lah; +Lch: ImmedPtr[-1] = fp_less(x,y); goto Lah; +Lci: ImmedPtr[-1] = fp_lessOrEq(x,y); goto Lah; +Lcj: ImmedPtr[-1] = fp_equal(y,x); goto Lah; +Lck: ImmedPtr[-1] = fp_nequal(y,x); goto Lah; +Lcl: ImmedPtr[-1] = truthValue(x)&&truthValue(y); goto Lah; +Lcm: ImmedPtr[-1] = truthValue(x)||truthValue(y); goto Lah; +Lcn: ByteCodePtr -= 1; + data->ByteCode.pop_back(); + goto TailCall_cAbs; +Lda: data->ByteCode.push_back(opcode); return; +return; +// This list of dummy gotos is here to inhibit +// compiler warnings on unused labels +goto TailCall_cAnd;goto TailCall_cEqual;goto TailCall_cGreater; +goto TailCall_cGreaterOrEq;goto TailCall_cInv;goto TailCall_cLess; +goto TailCall_cLessOrEq;goto TailCall_cMax;goto TailCall_cMin; +goto TailCall_cMod;goto TailCall_cNEqual;goto TailCall_cOr; +goto TailCall_cSub; +#endif +#if(FP_FLOAT_VERSION) + Value_t x; + Value_t y; unsigned A; switch(opcode) { @@ -36,7 +702,7 @@ case cSqr: FP_TRACE_BYTECODE_OPTIMIZATION("cSqr x[!isEvenInteger(x*Value_t(2))] cPow", "cAbs [x*Value_t(2)] cPow"); /* opcode = cPow; */ // redundant, matches cPow @ 0 - goto Laa; + goto Lde; } } if(IsIntegerConst(x)) @@ -53,32 +719,22 @@ FP_TRACE_BYTECODE_OPTIMIZATION("y[!IsIntegerConst(y)] cPow x[IsIntegerConst(x)] cPow", "[y*x] cPow"); /* ByteCodePtr[-2] = cImmed; */ // redundant, matches y @ 3 /* ByteCodePtr[-1] = cPow; */ // redundant, matches cPow @ 2 - goto Lab; + goto Lag; } break; } FP_TRACE_BYTECODE_OPTIMIZATION("cPow x[IsIntegerConst(x)] cPow", "[x] cMul cPow"); /* ImmedPtr[0] = x; */ // redundant, matches x @ 1 /* opcode = cPow; */ // redundant, matches cPow @ 0 - goto Lac; -#if(!FP_INT_VERSION) + goto Ldf; case cExp: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cExp x[IsIntegerConst(x)] cPow", "[x] cMul cExp"); /* ImmedPtr[0] = x; */ // redundant, matches x @ 1 - goto Lad; -#endif - break; -#endif -#if(!FP_INT_VERSION) + goto Ldg; case cExp2: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cExp2 x[IsIntegerConst(x)] cPow", "[x] cMul cExp2"); /* ImmedPtr[0] = x; */ // redundant, matches x @ 1 - goto Lae; -#endif - break; -#endif + goto Ldh; } } if(isEvenInteger(x)) @@ -89,58 +745,42 @@ FP_TRACE_BYTECODE_OPTIMIZATION("cAbs x[isEvenInteger(x)] cPow", "[x] cPow"); /* ImmedPtr[0] = x; */ // redundant, matches x @ 1 /* opcode = cPow; */ // redundant, matches cPow @ 0 - goto Laf; + goto Ldi; case cMul: switch(ByteCodePtr[-2]) { case cAbs: FP_TRACE_BYTECODE_OPTIMIZATION("cAbs cMul x[isEvenInteger(x)] cPow", "cMul [x] cPow"); /* opcode = cPow; */ // redundant, matches cPow @ 0 - goto Lag; + goto Ldj; } break; } } -#if(!FP_INT_VERSION) if(x==Value_t(0.5)) { -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x[x==Value_t(0.5)] cPow", "cSqrt"); - goto Lah; -#endif + goto Ldk; } -#endif -#if(!FP_INT_VERSION) if(x==Value_t(1)/Value_t(3)) { -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x[x==Value_t(1)/Value_t(3)] cPow", "cCbrt"); - goto Lai; -#endif + goto Ldl; } -#endif -#if(!FP_INT_VERSION) if(x==Value_t(1)/Value_t(-3)) { -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x[x==Value_t(1)/Value_t(-3)] cPow", "cCbrt cInv"); - goto Laj; -#endif + goto Ldm; } -#endif -#if(!FP_INT_VERSION) if(x==Value_t(-0.5)) { -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x[x==Value_t(-0.5)] cPow", "cRSqrt"); - goto Lak; -#endif + goto Ldn; } -#endif if(x==Value_t(-1)) { FP_TRACE_BYTECODE_OPTIMIZATION("x[x==Value_t(-1)] cPow", "cInv"); - goto Lal; + goto Lea; } switch(ByteCodePtr[-1]) { @@ -153,25 +793,25 @@ { FP_TRACE_BYTECODE_OPTIMIZATION("y[isEvenInteger(y)&&!isEvenInteger(x*y)] cPow x cPow", "cAbs [y*x] cPow"); /* opcode = cPow; */ // redundant, matches cPow @ 0 - goto Lam; + goto Leb; } FP_TRACE_BYTECODE_OPTIMIZATION("y cPow x cPow", "[y*x] cPow"); /* ByteCodePtr[-2] = cImmed; */ // redundant, matches y @ 3 /* ByteCodePtr[-1] = cPow; */ // redundant, matches cPow @ 2 - goto Lab; + goto Lag; } break; case cSqr: FP_TRACE_BYTECODE_OPTIMIZATION("cSqr x cPow", "[x*Value_t(2)] cPow"); /* opcode = cPow; */ // redundant, matches cPow @ 0 - goto Lan; + goto Lec; case cImmed: y = ImmedPtr[-1]; if( y!=Value_t(0) || x>=Value_t(0)) { FP_TRACE_BYTECODE_OPTIMIZATION("y[ y!=Value_t(0) || x>=Value_t(0)] x cPow", "[fp_pow(y,x)]"); /* ByteCodePtr[-1] = cImmed; */ // redundant, matches y @ 2 - goto Lba; + goto Led; } break; } @@ -182,36 +822,23 @@ } break; TailCall_cSqrt: -#if(!FP_INT_VERSION) case cSqrt: -#if(!FP_INT_VERSION) switch(ByteCodePtr[0]) { -#if(!FP_INT_VERSION) case cSqr: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cSqr cSqrt", "cAbs"); - goto Lbb; -#endif - break; -#endif + goto Lee; case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) if(x>=Value_t(0)) { -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x[x>=Value_t(0)] cSqrt", "[fp_sqrt(x)]"); /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 - goto Lbc; -#endif + goto Lef; } -#endif break; } -#endif break; -#endif TailCall_cAbs: case cAbs: switch(ByteCodePtr[0]) @@ -219,15 +846,12 @@ case cNeg: FP_TRACE_BYTECODE_OPTIMIZATION("cNeg cAbs", "cAbs"); /* opcode = cAbs; */ // redundant, matches cAbs @ 0 - goto Lbd; + goto Lcn; case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x cAbs", "[fp_abs(x)]"); /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 - goto Lbe; -#endif - break; + goto Leg; default: A = ByteCodePtr[0]; if(IsNeverNegativeValueOpcode(A)) @@ -239,720 +863,408 @@ } break; TailCall_cAcos: -#if(!FP_INT_VERSION) case cAcos: -#if(!FP_INT_VERSION) switch(ByteCodePtr[0]) { case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x cAcos", "[fp_acos(x)]"); /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 - goto Lbf; -#endif - break; + goto Leh; } -#endif break; -#endif TailCall_cAcosh: -#if(!FP_INT_VERSION) case cAcosh: -#if(!FP_INT_VERSION) switch(ByteCodePtr[0]) { case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) if(x>=Value_t(-1)&&x<=Value_t(1)) { -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x[x>=Value_t(-1)&&x<=Value_t(1)] cAcosh", "[fp_acosh(x)]"); /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 - goto Lbg; -#endif + goto Lei; } -#endif break; } -#endif break; -#endif TailCall_cAsinh: -#if(!FP_INT_VERSION) case cAsinh: -#if(!FP_INT_VERSION) switch(ByteCodePtr[0]) { case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) if(x>=Value_t(-1)&&x<=Value_t(1)) { -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x[x>=Value_t(-1)&&x<=Value_t(1)] cAsinh", "[fp_asinh(x)]"); /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 - goto Lbh; -#endif + goto Lej; } -#endif break; } -#endif break; -#endif TailCall_cAtan: -#if(!FP_INT_VERSION) case cAtan: -#if(!FP_INT_VERSION) switch(ByteCodePtr[0]) { case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x cAtan", "[fp_atan(x)]"); /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 - goto Lbi; -#endif - break; + goto Lek; } -#endif break; -#endif TailCall_cAtanh: -#if(!FP_INT_VERSION) case cAtanh: -#if(!FP_INT_VERSION) switch(ByteCodePtr[0]) { case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x cAtanh", "[fp_atanh(x)]"); /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 - goto Lbj; -#endif - break; + goto Lel; } -#endif break; -#endif TailCall_cCbrt: -#if(!FP_INT_VERSION) case cCbrt: -#if(!FP_INT_VERSION) switch(ByteCodePtr[0]) { case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x cCbrt", "[fp_cbrt(x)]"); /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 - goto Lbk; -#endif - break; + goto Lem; } -#endif break; -#endif TailCall_cCeil: -#if(!FP_INT_VERSION) case cCeil: -#if(!FP_INT_VERSION) switch(ByteCodePtr[0]) { case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x cCeil", "[fp_ceil(x)]"); /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 - goto Lbl; -#endif - break; + goto Len; default: A = ByteCodePtr[0]; -#if(!FP_INT_VERSION) if(IsAlwaysIntegerOpcode(A)) { -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("A[IsAlwaysIntegerOpcode(A)] cCeil", "A"); /* ByteCodePtr[0] = A; */ // redundant, matches A @ 1 return; -#endif } -#endif } -#endif break; -#endif TailCall_cCos: -#if(!FP_INT_VERSION) case cCos: -#if(!FP_INT_VERSION) switch(ByteCodePtr[0]) { -#if(!FP_INT_VERSION) case cAcos: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cAcos cCos", ""); - goto Lbm; -#endif - break; -#endif -#if(!FP_INT_VERSION) + goto Lab; case cAbs: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cAbs cCos", "cCos"); /* opcode = cCos; */ // redundant, matches cCos @ 0 - goto Lbn; -#endif - break; -#endif -#if(!FP_INT_VERSION) + goto Lfa; case cNeg: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cNeg cCos", "cCos"); /* opcode = cCos; */ // redundant, matches cCos @ 0 - goto Lbn; -#endif - break; -#endif + goto Lfa; case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x cCos", "[fp_cos(x)]"); /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 - goto Lca; -#endif - break; + goto Lfb; } -#endif break; -#endif TailCall_cCosh: -#if(!FP_INT_VERSION) case cCosh: -#if(!FP_INT_VERSION) switch(ByteCodePtr[0]) { -#if(!FP_INT_VERSION) case cAcosh: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cAcosh cCosh", ""); - goto Lbm; -#endif - break; -#endif -#if(!FP_INT_VERSION) + goto Lab; case cAbs: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cAbs cCosh", "cCosh"); /* opcode = cCosh; */ // redundant, matches cCosh @ 0 - goto Lcb; -#endif - break; -#endif -#if(!FP_INT_VERSION) + goto Lfc; case cNeg: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cNeg cCosh", "cCosh"); /* opcode = cCosh; */ // redundant, matches cCosh @ 0 - goto Lcb; -#endif - break; -#endif -#if(!FP_INT_VERSION) + goto Lfc; case cAsinh: -#if(!FP_INT_VERSION) - FP_TRACE_BYTECODE_OPTIMIZATION("cAsinh cCosh", "cSqr [Value_t(1)] cAdd cSqrt"); - goto Lcc; -#endif - break; -#endif + FP_TRACE_BYTECODE_OPTIMIZATION("cAsinh cCosh", "[DO_STACKPLUS1] cSqr [Value_t(1)] cAdd cSqrt"); + incStackPtr(); + --StackPtr; + goto Lfd; case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x cCosh", "[fp_cosh(x)]"); /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 - goto Lcd; -#endif - break; + goto Lfe; } -#endif break; -#endif TailCall_cExp: -#if(!FP_INT_VERSION) case cExp: -#if(!FP_INT_VERSION) switch(ByteCodePtr[0]) { -#if(!FP_INT_VERSION) case cLog: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cLog cExp", ""); - goto Lbm; -#endif - break; -#endif -#if(!FP_INT_VERSION) + goto Lab; case cAdd: -#if(!FP_INT_VERSION) switch(ByteCodePtr[-1]) { case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x cAdd cExp", "cExp [fp_exp(x)] cMul"); - goto Lce; -#endif - break; + goto Lff; } -#endif break; -#endif case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x cExp", "[fp_exp(x)]"); /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 - goto Lcf; -#endif - break; + goto Lfg; } -#endif break; -#endif TailCall_cExp2: -#if(!FP_INT_VERSION) case cExp2: -#if(!FP_INT_VERSION) switch(ByteCodePtr[0]) { -#if(!FP_INT_VERSION) case cLog2: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cLog2 cExp2", ""); - goto Lbm; -#endif - break; -#endif -#if(!FP_INT_VERSION) + goto Lab; case cAdd: -#if(!FP_INT_VERSION) switch(ByteCodePtr[-1]) { case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x cAdd cExp2", "cExp2 [fp_exp2(x)] cMul"); - goto Lcg; -#endif - break; + goto Lfh; } -#endif break; -#endif case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x cExp2", "[fp_exp2(x)]"); /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 - goto Lch; -#endif - break; + goto Lfi; } -#endif break; -#endif TailCall_cFloor: -#if(!FP_INT_VERSION) case cFloor: -#if(!FP_INT_VERSION) switch(ByteCodePtr[0]) { case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x cFloor", "[fp_floor(x)]"); /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 - goto Lci; -#endif - break; + goto Lfj; default: A = ByteCodePtr[0]; -#if(!FP_INT_VERSION) if(IsAlwaysIntegerOpcode(A)) { -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("A[IsAlwaysIntegerOpcode(A)] cFloor", "A"); /* ByteCodePtr[0] = A; */ // redundant, matches A @ 1 return; -#endif } -#endif } -#endif break; -#endif TailCall_cInt: -#if(!FP_INT_VERSION) case cInt: -#if(!FP_INT_VERSION) switch(ByteCodePtr[0]) { case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x cInt", "[fp_int(x)]"); /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 - goto Lcj; -#endif - break; + goto Lfk; default: A = ByteCodePtr[0]; -#if(!FP_INT_VERSION) if(IsAlwaysIntegerOpcode(A)) { -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("A[IsAlwaysIntegerOpcode(A)] cInt", "A"); /* ByteCodePtr[0] = A; */ // redundant, matches A @ 1 return; -#endif } -#endif } -#endif break; -#endif TailCall_cLog: -#if(!FP_INT_VERSION) case cLog: -#if(!FP_INT_VERSION) switch(ByteCodePtr[0]) { -#if(!FP_INT_VERSION) case cSqr: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cSqr cLog", "cAbs cLog cDup cAdd"); - goto Lck; -#endif - break; -#endif -#if(!FP_INT_VERSION) + goto Lfl; case cExp: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cExp cLog", ""); - goto Lbm; -#endif - break; -#endif + goto Lab; case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) if(x>=Value_t(0)) { -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x[x>=Value_t(0)] cLog", "[fp_log(x)]"); /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 - goto Lcl; -#endif + goto Lfm; } -#endif break; } -#endif break; -#endif TailCall_cLog10: -#if(!FP_INT_VERSION) case cLog10: -#if(!FP_INT_VERSION) switch(ByteCodePtr[0]) { -#if(!FP_INT_VERSION) case cSqr: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cSqr cLog10", "cAbs cLog10 cDup cAdd"); - goto Lcm; -#endif - break; -#endif + goto Lfn; case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) if(x>=Value_t(0)) { -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x[x>=Value_t(0)] cLog10", "[fp_log10(x)]"); /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 - goto Lcn; -#endif + goto Lga; } -#endif break; } -#endif break; -#endif TailCall_cLog2: -#if(!FP_INT_VERSION) case cLog2: -#if(!FP_INT_VERSION) switch(ByteCodePtr[0]) { -#if(!FP_INT_VERSION) case cSqr: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cSqr cLog2", "cAbs cLog2 cDup cAdd"); - goto Lda; -#endif - break; -#endif -#if(!FP_INT_VERSION) + goto Lgb; case cExp2: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cExp2 cLog2", ""); - goto Lbm; -#endif - break; -#endif + goto Lab; case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) if(x>=Value_t(0)) { -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x[x>=Value_t(0)] cLog2", "[fp_log2(x)]"); /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 - goto Ldb; -#endif + goto Lgc; } -#endif break; } -#endif break; -#endif TailCall_cSin: -#if(!FP_INT_VERSION) case cSin: -#if(!FP_INT_VERSION) switch(ByteCodePtr[0]) { -#if(!FP_INT_VERSION) case cAsin: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cAsin cSin", ""); - goto Lbm; -#endif - break; -#endif -#if(!FP_INT_VERSION) + goto Lab; case cNeg: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cNeg cSin", "cSin cNeg"); - goto Ldc; -#endif - break; -#endif + goto Lgd; case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x cSin", "[fp_sin(x)]"); /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 - goto Ldd; -#endif - break; + goto Lge; } -#endif break; -#endif TailCall_cSinh: -#if(!FP_INT_VERSION) case cSinh: -#if(!FP_INT_VERSION) switch(ByteCodePtr[0]) { -#if(!FP_INT_VERSION) case cAsinh: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cAsinh cSinh", ""); - goto Lbm; -#endif - break; -#endif -#if(!FP_INT_VERSION) + goto Lab; case cNeg: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cNeg cSinh", "cSinh cNeg"); - goto Lde; -#endif - break; -#endif -#if(!FP_INT_VERSION) + goto Lgf; case cAcosh: -#if(!FP_INT_VERSION) - FP_TRACE_BYTECODE_OPTIMIZATION("cAcosh cSinh", "cSqr [Value_t(-1)] cAdd cSqrt"); - goto Ldf; -#endif - break; -#endif + FP_TRACE_BYTECODE_OPTIMIZATION("cAcosh cSinh", "[DO_STACKPLUS1] cSqr [Value_t(-1)] cAdd cSqrt"); + incStackPtr(); + --StackPtr; + goto Lgg; case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x cSinh", "[fp_sinh(x)]"); /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 - goto Ldg; -#endif - break; + goto Lgh; } -#endif break; -#endif TailCall_cTan: -#if(!FP_INT_VERSION) case cTan: -#if(!FP_INT_VERSION) switch(ByteCodePtr[0]) { -#if(!FP_INT_VERSION) case cAtan: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cAtan cTan", ""); - goto Lbm; -#endif - break; -#endif -#if(!FP_INT_VERSION) + goto Lab; case cAtan2: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cAtan2 cTan", "cDiv"); - goto Ldh; -#endif - break; -#endif -#if(!FP_INT_VERSION) + goto Lad; case cNeg: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cNeg cTan", "cTan cNeg"); - goto Ldi; -#endif - break; -#endif + goto Lgi; case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x cTan", "[fp_tan(x)]"); /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 - goto Ldj; -#endif - break; + goto Lgj; } -#endif break; -#endif TailCall_cTanh: -#if(!FP_INT_VERSION) case cTanh: -#if(!FP_INT_VERSION) switch(ByteCodePtr[0]) { -#if(!FP_INT_VERSION) case cAtanh: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cAtanh cTanh", ""); - goto Lbm; -#endif - break; -#endif -#if(!FP_INT_VERSION) + goto Lab; case cNeg: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cNeg cTanh", "cTanh cNeg"); - goto Ldk; -#endif - break; -#endif + goto Lgk; case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x cTanh", "[fp_tanh(x)]"); /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 - goto Ldl; -#endif - break; + goto Lgl; } -#endif break; -#endif TailCall_cTrunc: -#if(!FP_INT_VERSION) case cTrunc: -#if(!FP_INT_VERSION) switch(ByteCodePtr[0]) { case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x cTrunc", "[fp_trunc(x)]"); /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 - goto Ldm; -#endif - break; + goto Lgm; default: A = ByteCodePtr[0]; -#if(!FP_INT_VERSION) if(IsAlwaysIntegerOpcode(A)) { -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("A[IsAlwaysIntegerOpcode(A)] cTrunc", "A"); /* ByteCodePtr[0] = A; */ // redundant, matches A @ 1 return; -#endif } -#endif } -#endif break; -#endif TailCall_cDeg: -#if(!FP_INT_VERSION) case cDeg: -#if(!FP_INT_VERSION) switch(ByteCodePtr[0]) { case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x cDeg", "[RadiansToDegrees(x)]"); /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 - goto Ldn; -#endif - break; + goto Lgn; } -#endif break; -#endif TailCall_cRad: -#if(!FP_INT_VERSION) case cRad: -#if(!FP_INT_VERSION) switch(ByteCodePtr[0]) { case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x cRad", "[DegreesToRadians(x)]"); /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 - goto Lea; -#endif - break; + goto Lha; } -#endif break; -#endif TailCall_cNeg: case cNeg: switch(ByteCodePtr[0]) @@ -965,145 +1277,91 @@ FP_TRACE_BYTECODE_OPTIMIZATION("x cMul cNeg", "[-x] cMul"); /* ByteCodePtr[-1] = cImmed; */ // redundant, matches x @ 2 /* ByteCodePtr[0] = cMul; */ // redundant, matches cMul @ 1 - goto Leb; + goto Laa; } break; case cNeg: FP_TRACE_BYTECODE_OPTIMIZATION("cNeg cNeg", ""); - goto Lbm; -#if(!FP_INT_VERSION) + goto Lab; case cFloor: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cFloor cNeg", "cNeg cCeil"); - goto Lec; -#endif - break; -#endif -#if(!FP_INT_VERSION) + goto Lhb; case cCeil: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cCeil cNeg", "cNeg cFloor"); - goto Led; -#endif - break; -#endif -#if(!FP_INT_VERSION) + goto Lhc; case cSin: -#if(!FP_INT_VERSION) switch(ByteCodePtr[-1]) { -#if(!FP_INT_VERSION) case cMul: -#if(!FP_INT_VERSION) switch(ByteCodePtr[-2]) { case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x cMul cSin cNeg", "[-x] cMul cSin"); /* ByteCodePtr[-2] = cImmed; */ // redundant, matches x @ 3 /* ByteCodePtr[-1] = cMul; */ // redundant, matches cMul @ 2 /* ByteCodePtr[0] = cSin; */ // redundant, matches cSin @ 1 - goto Leb; -#endif - break; + goto Laa; } -#endif break; -#endif } -#endif break; -#endif -#if(!FP_INT_VERSION) case cSinh: -#if(!FP_INT_VERSION) switch(ByteCodePtr[-1]) { -#if(!FP_INT_VERSION) case cMul: -#if(!FP_INT_VERSION) switch(ByteCodePtr[-2]) { case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x cMul cSinh cNeg", "[-x] cMul cSinh"); /* ByteCodePtr[-2] = cImmed; */ // redundant, matches x @ 3 /* ByteCodePtr[-1] = cMul; */ // redundant, matches cMul @ 2 /* ByteCodePtr[0] = cSinh; */ // redundant, matches cSinh @ 1 - goto Leb; -#endif - break; + goto Laa; } -#endif break; -#endif } -#endif break; -#endif -#if(!FP_INT_VERSION) case cTan: -#if(!FP_INT_VERSION) switch(ByteCodePtr[-1]) { -#if(!FP_INT_VERSION) case cMul: -#if(!FP_INT_VERSION) switch(ByteCodePtr[-2]) { case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x cMul cTan cNeg", "[-x] cMul cTan"); /* ByteCodePtr[-2] = cImmed; */ // redundant, matches x @ 3 /* ByteCodePtr[-1] = cMul; */ // redundant, matches cMul @ 2 /* ByteCodePtr[0] = cTan; */ // redundant, matches cTan @ 1 - goto Leb; -#endif - break; + goto Laa; } -#endif break; -#endif } -#endif break; -#endif -#if(!FP_INT_VERSION) case cTanh: -#if(!FP_INT_VERSION) switch(ByteCodePtr[-1]) { -#if(!FP_INT_VERSION) case cMul: -#if(!FP_INT_VERSION) switch(ByteCodePtr[-2]) { case cImmed: x = ImmedPtr[0]; -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("x cMul cTanh cNeg", "[-x] cMul cTanh"); /* ByteCodePtr[-2] = cImmed; */ // redundant, matches x @ 3 /* ByteCodePtr[-1] = cMul; */ // redundant, matches cMul @ 2 /* ByteCodePtr[0] = cTanh; */ // redundant, matches cTanh @ 1 - goto Leb; -#endif - break; + goto Laa; } -#endif break; -#endif } -#endif break; -#endif case cImmed: x = ImmedPtr[0]; FP_TRACE_BYTECODE_OPTIMIZATION("x cNeg", "[-x]"); /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 - goto Leb; + goto Laa; } break; TailCall_cInv: @@ -1112,65 +1370,35 @@ { case cInv: FP_TRACE_BYTECODE_OPTIMIZATION("cInv cInv", ""); - goto Lbm; + goto Lab; case cPow: FP_TRACE_BYTECODE_OPTIMIZATION("cPow cInv", "cNeg cPow"); - goto Lee; -#if(!FP_INT_VERSION) + goto Lhd; case cSin: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cSin cInv", "cCsc"); - goto Lef; -#endif - break; -#endif -#if(!FP_INT_VERSION) + goto Lhe; case cCos: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cCos cInv", "cSec"); - goto Leg; -#endif - break; -#endif -#if(!FP_INT_VERSION) + goto Lhf; case cTan: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cTan cInv", "cCot"); - goto Leh; -#endif - break; -#endif -#if(!FP_INT_VERSION) + goto Lhg; case cCsc: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cCsc cInv", "cSin"); - goto Lei; -#endif - break; -#endif -#if(!FP_INT_VERSION) + goto Lhh; case cSec: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cSec cInv", "cCos"); - goto Lej; -#endif - break; -#endif -#if(!FP_INT_VERSION) + goto Lhi; case cCot: -#if(!FP_INT_VERSION) FP_TRACE_BYTECODE_OPTIMIZATION("cCot cInv", "cTan"); - goto Lek; -#endif - break; -#endif + goto Lhj; case cImmed: x = ImmedPtr[0]; if(x!=Value_t(0)) { FP_TRACE_BYTECODE_OPTIMIZATION("x[x!=Value_t(0)] cInv", "[Value_t(1)/x]"); /* ByteCodePtr[0] = cImmed; */ // redundant, matches x @ 1 - goto Lel; + goto Lac; } break; } @@ -1181,7 +1409,7 @@ { case cInv: FP_TRACE_BYTECODE_OPTIMIZATION("cInv cMul", "cDiv"); - goto Ldh; + goto Lad; case cPow: switch(ByteCodePtr[-1]) { @@ -1192,7 +1420,7 @@ FP_TRACE_BYTECODE_OPTIMIZATION("x[x<0] cPow cMul", "[-x] cPow cDiv"); /* ByteCodePtr[-1] = cImmed; */ // redundant, matches x @ 2 /* ByteCodePtr[0] = cPow; */ // redundant, matches cPow @ 1 - goto Lem; + goto Lhk; } break; } @@ -1210,47 +1438,75 @@ { FP_TRACE_BYTECODE_OPTIMIZATION("A[A >= VarBegin] x[x==Value_t(0)] cMul", "[x]"); /* ImmedPtr[0] = x; */ // redundant, matches x @ 1 - goto Len; + goto Lae; } } } switch(ByteCodePtr[-1]) { + case cDeg: + FP_TRACE_BYTECODE_OPTIMIZATION("cDeg x cMul", "[RadiansToDegrees(x)] cMul"); + /* opcode = cMul; */ // redundant, matches cMul @ 0 + goto Lhl; + case cRad: + FP_TRACE_BYTECODE_OPTIMIZATION("cRad x cMul", "[DegreesToRadians(x)] cMul"); + /* opcode = cMul; */ // redundant, matches cMul @ 0 + goto Lhm; case cNeg: FP_TRACE_BYTECODE_OPTIMIZATION("cNeg x cMul", "[-x] cMul"); /* opcode = cMul; */ // redundant, matches cMul @ 0 - goto Lfa; + goto Laf; case cMul: switch(ByteCodePtr[-2]) { case cImmed: y = ImmedPtr[-1]; + if((y*x)==GetRadiansToDegreesFactor<Value_t>()) + { + FP_TRACE_BYTECODE_OPTIMIZATION("y[(y*x)==GetRadiansToDegreesFactor<Value_t>()] cMul x cMul", "cDeg"); + goto Lhn; + } + if((y*x)==GetDegreesToRadiansFactor<Value_t>()) + { + FP_TRACE_BYTECODE_OPTIMIZATION("y[(y*x)==GetDegreesToRadiansFactor<Value_t>()] cMul x cMul", "cRad"); + goto Lia; + ... [truncated message content] |