@@ -749,18 +749,20 @@ proc genNarrow(c: PCtx; n: PNode; dest: TDest) =
749749 let t = skipTypes (n.typ, abstractVar- {tyTypeDesc})
750750 # uint is uint64 in the VM, we we only need to mask the result for
751751 # other unsigned types:
752- if t.kind in {tyUInt8.. tyUInt32} or (t.kind == tyUInt and t.size < 8 ):
753- c.gABC (n, opcNarrowU, dest, TRegister (t.size* 8 ))
754- elif t.kind in {tyInt8.. tyInt32} or (t.kind == tyInt and t.size < 8 ):
755- c.gABC (n, opcNarrowS, dest, TRegister (t.size* 8 ))
752+ let size = getSize (c.config, t)
753+ if t.kind in {tyUInt8.. tyUInt32} or (t.kind == tyUInt and size < 8 ):
754+ c.gABC (n, opcNarrowU, dest, TRegister (size* 8 ))
755+ elif t.kind in {tyInt8.. tyInt32} or (t.kind == tyInt and size < 8 ):
756+ c.gABC (n, opcNarrowS, dest, TRegister (size* 8 ))
756757
757758proc genNarrowU (c: PCtx ; n: PNode ; dest: TDest ) =
758759 let t = skipTypes (n.typ, abstractVar- {tyTypeDesc})
759760 # uint is uint64 in the VM, we we only need to mask the result for
760761 # other unsigned types:
762+ let size = getSize (c.config, t)
761763 if t.kind in {tyUInt8.. tyUInt32, tyInt8.. tyInt32} or
762- (t.kind in {tyUInt, tyInt} and t. size < 8 ):
763- c.gABC (n, opcNarrowU, dest, TRegister (t. size* 8 ))
764+ (t.kind in {tyUInt, tyInt} and size < 8 ):
765+ c.gABC (n, opcNarrowU, dest, TRegister (size* 8 ))
764766
765767proc genBinaryABCnarrow (c: PCtx ; n: PNode ; dest: var TDest ; opc: TOpcode ) =
766768 genBinaryABC (c, n, dest, opc)
@@ -1088,10 +1090,11 @@ proc genMagic(c: PCtx; n: PNode; dest: var TDest; m: TMagic) =
10881090 genBinaryABC (c, n, dest, opcShlInt)
10891091 # genNarrowU modified
10901092 let t = skipTypes (n.typ, abstractVar- {tyTypeDesc})
1091- if t.kind in {tyUInt8.. tyUInt32} or (t.kind == tyUInt and t.size < 8 ):
1092- c.gABC (n, opcNarrowU, dest, TRegister (t.size* 8 ))
1093- elif t.kind in {tyInt8.. tyInt32} or (t.kind == tyInt and t.size < 8 ):
1094- c.gABC (n, opcSignExtend, dest, TRegister (t.size* 8 ))
1093+ let size = getSize (c.config, t)
1094+ if t.kind in {tyUInt8.. tyUInt32} or (t.kind == tyUInt and size < 8 ):
1095+ c.gABC (n, opcNarrowU, dest, TRegister (size* 8 ))
1096+ elif t.kind in {tyInt8.. tyInt32} or (t.kind == tyInt and size < 8 ):
1097+ c.gABC (n, opcSignExtend, dest, TRegister (size* 8 ))
10951098 of mAshrI: genBinaryABC (c, n, dest, opcAshrInt)
10961099 of mBitandI: genBinaryABC (c, n, dest, opcBitandInt)
10971100 of mBitorI: genBinaryABC (c, n, dest, opcBitorInt)
@@ -1125,8 +1128,9 @@ proc genMagic(c: PCtx; n: PNode; dest: var TDest; m: TMagic) =
11251128 genUnaryABC (c, n, dest, opcBitnotInt)
11261129 # genNarrowU modified, do not narrow signed types
11271130 let t = skipTypes (n.typ, abstractVar- {tyTypeDesc})
1128- if t.kind in {tyUInt8.. tyUInt32} or (t.kind == tyUInt and t.size < 8 ):
1129- c.gABC (n, opcNarrowU, dest, TRegister (t.size* 8 ))
1131+ let size = getSize (c.config, t)
1132+ if t.kind in {tyUInt8.. tyUInt32} or (t.kind == tyUInt and size < 8 ):
1133+ c.gABC (n, opcNarrowU, dest, TRegister (size* 8 ))
11301134 of mCharToStr, mBoolToStr, mIntToStr, mInt64ToStr, mFloatToStr, mCStrToStr, mStrToStr, mEnumToStr:
11311135 genConv (c, n, n[1 ], dest)
11321136 of mEqStr, mEqCString: genBinaryABC (c, n, dest, opcEqStr)
0 commit comments