fix operators containing percent for VM usage (#13536)
* fixes #13513 * merge tarithmetics in tarithm
This commit is contained in:
parent
e64f1c7ee4
commit
2f557652d4
11 changed files with 165 additions and 137 deletions
|
|
@ -617,7 +617,6 @@ type
|
|||
mEqI, mLeI, mLtI,
|
||||
mEqF64, mLeF64, mLtF64,
|
||||
mLeU, mLtU,
|
||||
mLeU64, mLtU64,
|
||||
mEqEnum, mLeEnum, mLtEnum,
|
||||
mEqCh, mLeCh, mLtCh,
|
||||
mEqB, mLeB, mLtB,
|
||||
|
|
@ -687,7 +686,6 @@ const
|
|||
mEqI, mLeI, mLtI,
|
||||
mEqF64, mLeF64, mLtF64,
|
||||
mLeU, mLtU,
|
||||
mLeU64, mLtU64,
|
||||
mEqEnum, mLeEnum, mLtEnum,
|
||||
mEqCh, mLeCh, mLtCh,
|
||||
mEqB, mLeB, mLtB,
|
||||
|
|
|
|||
|
|
@ -605,8 +605,6 @@ proc binaryArith(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
|
|||
of mLtF64: applyFormat("($1 < $2)")
|
||||
of mLeU: applyFormat("((NU$3)($1) <= (NU$3)($2))")
|
||||
of mLtU: applyFormat("((NU$3)($1) < (NU$3)($2))")
|
||||
of mLeU64: applyFormat("((NU64)($1) <= (NU64)($2))")
|
||||
of mLtU64: applyFormat("((NU64)($1) < (NU64)($2))")
|
||||
of mEqEnum: applyFormat("($1 == $2)")
|
||||
of mLeEnum: applyFormat("($1 <= $2)")
|
||||
of mLtEnum: applyFormat("($1 < $2)")
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ import ast, astalgo
|
|||
|
||||
const
|
||||
someCmp = {mEqI, mEqF64, mEqEnum, mEqCh, mEqB, mEqRef, mEqProc,
|
||||
mLeI, mLeF64, mLeU, mLeU64, mLeEnum,
|
||||
mLeCh, mLeB, mLePtr, mLtI, mLtF64, mLtU, mLtU64, mLtEnum,
|
||||
mLeI, mLeF64, mLeU, mLeEnum,
|
||||
mLeCh, mLeB, mLePtr, mLtI, mLtF64, mLtU, mLtEnum,
|
||||
mLtCh, mLtB, mLtPtr}
|
||||
|
||||
proc isCounter(s: PSym): bool {.inline.} =
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ const
|
|||
mEqStr, mEqSet, mEqCString}
|
||||
|
||||
# set excluded here as the semantics are vastly different:
|
||||
someLe = {mLeI, mLeF64, mLeU, mLeU64, mLeEnum,
|
||||
someLe = {mLeI, mLeF64, mLeU, mLeEnum,
|
||||
mLeCh, mLeB, mLePtr, mLeStr}
|
||||
someLt = {mLtI, mLtF64, mLtU, mLtU64, mLtEnum,
|
||||
someLt = {mLtI, mLtF64, mLtU, mLtEnum,
|
||||
mLtCh, mLtB, mLtPtr, mLtStr}
|
||||
|
||||
someLen = {mLengthOpenArray, mLengthStr, mLengthArray, mLengthSeq}
|
||||
|
|
|
|||
|
|
@ -371,69 +371,67 @@ type
|
|||
const # magic checked op; magic unchecked op;
|
||||
jsMagics: TMagicOps = [
|
||||
mAddI: ["addInt", ""],
|
||||
["subInt", ""], # SubI
|
||||
["mulInt", ""], # MulI
|
||||
["divInt", ""], # DivI
|
||||
["modInt", ""], # ModI
|
||||
["addInt", ""], # Succ
|
||||
["subInt", ""], # Pred
|
||||
["", ""], # AddF64
|
||||
["", ""], # SubF64
|
||||
["", ""], # MulF64
|
||||
["", ""], # DivF64
|
||||
["", ""], # ShrI
|
||||
["", ""], # ShlI
|
||||
["", ""], # AshrI
|
||||
["", ""], # BitandI
|
||||
["", ""], # BitorI
|
||||
["", ""], # BitxorI
|
||||
["nimMin", "nimMin"], # MinI
|
||||
["nimMax", "nimMax"], # MaxI
|
||||
["", ""], # addU
|
||||
["", ""], # subU
|
||||
["", ""], # mulU
|
||||
["", ""], # divU
|
||||
["", ""], # modU
|
||||
["", ""], # EqI
|
||||
["", ""], # LeI
|
||||
["", ""], # LtI
|
||||
["", ""], # EqF64
|
||||
["", ""], # LeF64
|
||||
["", ""], # LtF64
|
||||
["", ""], # leU
|
||||
["", ""], # ltU
|
||||
["", ""], # leU64
|
||||
["", ""], # ltU64
|
||||
["", ""], # EqEnum
|
||||
["", ""], # LeEnum
|
||||
["", ""], # LtEnum
|
||||
["", ""], # EqCh
|
||||
["", ""], # LeCh
|
||||
["", ""], # LtCh
|
||||
["", ""], # EqB
|
||||
["", ""], # LeB
|
||||
["", ""], # LtB
|
||||
["", ""], # EqRef
|
||||
["", ""], # LePtr
|
||||
["", ""], # LtPtr
|
||||
["", ""], # Xor
|
||||
["", ""], # EqCString
|
||||
["", ""], # EqProc
|
||||
["negInt", ""], # UnaryMinusI
|
||||
["negInt64", ""], # UnaryMinusI64
|
||||
["absInt", ""], # AbsI
|
||||
["", ""], # Not
|
||||
["", ""], # UnaryPlusI
|
||||
["", ""], # BitnotI
|
||||
["", ""], # UnaryPlusF64
|
||||
["", ""], # UnaryMinusF64
|
||||
["nimCharToStr", "nimCharToStr"],
|
||||
["nimBoolToStr", "nimBoolToStr"],
|
||||
["cstrToNimstr", "cstrToNimstr"],
|
||||
["cstrToNimstr", "cstrToNimstr"],
|
||||
["cstrToNimstr", "cstrToNimstr"],
|
||||
["cstrToNimstr", "cstrToNimstr"],
|
||||
["", ""]]
|
||||
mSubI: ["subInt", ""],
|
||||
mMulI: ["mulInt", ""],
|
||||
mDivI: ["divInt", ""],
|
||||
mModI: ["modInt", ""],
|
||||
mSucc: ["addInt", ""],
|
||||
mPred: ["subInt", ""],
|
||||
mAddF64: ["", ""],
|
||||
mSubF64: ["", ""],
|
||||
mMulF64: ["", ""],
|
||||
mDivF64: ["", ""],
|
||||
mShrI: ["", ""],
|
||||
mShlI: ["", ""],
|
||||
mAshrI: ["", ""],
|
||||
mBitandI: ["", ""],
|
||||
mBitorI: ["", ""],
|
||||
mBitxorI: ["", ""],
|
||||
mMinI: ["nimMin", "nimMin"],
|
||||
mMaxI: ["nimMax", "nimMax"],
|
||||
mAddU: ["", ""],
|
||||
mSubU: ["", ""],
|
||||
mMulU: ["", ""],
|
||||
mDivU: ["", ""],
|
||||
mModU: ["", ""],
|
||||
mEqI: ["", ""],
|
||||
mLeI: ["", ""],
|
||||
mLtI: ["", ""],
|
||||
mEqF64: ["", ""],
|
||||
mLeF64: ["", ""],
|
||||
mLtF64: ["", ""],
|
||||
mLeU: ["", ""],
|
||||
mLtU: ["", ""],
|
||||
mEqEnum: ["", ""],
|
||||
mLeEnum: ["", ""],
|
||||
mLtEnum: ["", ""],
|
||||
mEqCh: ["", ""],
|
||||
mLeCh: ["", ""],
|
||||
mLtCh: ["", ""],
|
||||
mEqB: ["", ""],
|
||||
mLeB: ["", ""],
|
||||
mLtB: ["", ""],
|
||||
mEqRef: ["", ""],
|
||||
mLePtr: ["", ""],
|
||||
mLtPtr: ["", ""],
|
||||
mXor: ["", ""],
|
||||
mEqCString: ["", ""],
|
||||
mEqProc: ["", ""],
|
||||
mUnaryMinusI: ["negInt", ""],
|
||||
mUnaryMinusI64: ["negInt64", ""],
|
||||
mAbsI: ["absInt", ""],
|
||||
mNot: ["", ""],
|
||||
mUnaryPlusI: ["", ""],
|
||||
mBitnotI: ["", ""],
|
||||
mUnaryPlusF64: ["", ""],
|
||||
mUnaryMinusF64: ["", ""],
|
||||
mCharToStr: ["nimCharToStr", "nimCharToStr"],
|
||||
mBoolToStr: ["nimBoolToStr", "nimBoolToStr"],
|
||||
mIntToStr: ["cstrToNimstr", "cstrToNimstr"],
|
||||
mInt64ToStr: ["cstrToNimstr", "cstrToNimstr"],
|
||||
mFloatToStr: ["cstrToNimstr", "cstrToNimstr"],
|
||||
mCStrToStr: ["cstrToNimstr", "cstrToNimstr"],
|
||||
mStrToStr: ["", ""]]
|
||||
|
||||
proc needsTemp(p: PProc; n: PNode): bool =
|
||||
# check if n contains a call to determine
|
||||
|
|
@ -575,8 +573,6 @@ proc arithAux(p: PProc, n: PNode, r: var TCompRes, op: TMagic) =
|
|||
of mLtF64: applyFormat("($1 < $2)", "($1 < $2)")
|
||||
of mLeU: applyFormat("($1 <= $2)", "($1 <= $2)")
|
||||
of mLtU: applyFormat("($1 < $2)", "($1 < $2)")
|
||||
of mLeU64: applyFormat("($1 <= $2)", "($1 <= $2)")
|
||||
of mLtU64: applyFormat("($1 < $2)", "($1 < $2)")
|
||||
of mEqEnum: applyFormat("($1 == $2)", "($1 == $2)")
|
||||
of mLeEnum: applyFormat("($1 <= $2)", "($1 <= $2)")
|
||||
of mLtEnum: applyFormat("($1 < $2)", "($1 < $2)")
|
||||
|
|
|
|||
|
|
@ -288,9 +288,9 @@ proc evalOp(m: TMagic, n, a, b, c: PNode; g: ModuleGraph): PNode =
|
|||
of mLtStr: result = newIntNodeT(toInt128(ord(getStr(a) < getStr(b))), n, g)
|
||||
of mLeStr: result = newIntNodeT(toInt128(ord(getStr(a) <= getStr(b))), n, g)
|
||||
of mEqStr: result = newIntNodeT(toInt128(ord(getStr(a) == getStr(b))), n, g)
|
||||
of mLtU, mLtU64:
|
||||
of mLtU:
|
||||
result = newIntNodeT(toInt128(ord(`<%`(toInt64(getOrdValue(a)), toInt64(getOrdValue(b))))), n, g)
|
||||
of mLeU, mLeU64:
|
||||
of mLeU:
|
||||
result = newIntNodeT(toInt128(ord(`<=%`(toInt64(getOrdValue(a)), toInt64(getOrdValue(b))))), n, g)
|
||||
of mBitandI, mAnd: result = newIntNodeT(bitand(a.getInt, b.getInt), n, g)
|
||||
of mBitorI, mOr: result = newIntNodeT(bitor(getInt(a), getInt(b)), n, g)
|
||||
|
|
|
|||
|
|
@ -1071,8 +1071,8 @@ proc genMagic(c: PCtx; n: PNode; dest: var TDest; m: TMagic) =
|
|||
of mEqF64: genBinaryABC(c, n, dest, opcEqFloat)
|
||||
of mLeF64: genBinaryABC(c, n, dest, opcLeFloat)
|
||||
of mLtF64: genBinaryABC(c, n, dest, opcLtFloat)
|
||||
of mLePtr, mLeU, mLeU64: genBinaryABC(c, n, dest, opcLeu)
|
||||
of mLtPtr, mLtU, mLtU64: genBinaryABC(c, n, dest, opcLtu)
|
||||
of mLePtr, mLeU: genBinaryABC(c, n, dest, opcLeu)
|
||||
of mLtPtr, mLtU: genBinaryABC(c, n, dest, opcLtu)
|
||||
of mEqProc, mEqRef:
|
||||
genBinaryABC(c, n, dest, opcEqRef)
|
||||
of mXor: genBinaryABC(c, n, dest, opcXor)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue