minor stuff
This commit is contained in:
parent
a562de2d91
commit
ab8241ad42
4 changed files with 8 additions and 14 deletions
|
|
@ -223,7 +223,7 @@ proc semRangeAux(c: PContext, n: PNode, prev: PType): PType =
|
||||||
if not hasUnknownTypes:
|
if not hasUnknownTypes:
|
||||||
if not sameType(rangeT[0].skipTypes({tyRange}), rangeT[1].skipTypes({tyRange})):
|
if not sameType(rangeT[0].skipTypes({tyRange}), rangeT[1].skipTypes({tyRange})):
|
||||||
localError(c.config, n.info, "type mismatch")
|
localError(c.config, n.info, "type mismatch")
|
||||||
elif not rangeT[0].isOrdinalType(allowUint=true) and rangeT[0].kind notin tyFloat..tyFloat128 or
|
elif not isOrdinalType(rangeT[0]) and rangeT[0].kind notin tyFloat..tyFloat128 or
|
||||||
rangeT[0].kind == tyBool:
|
rangeT[0].kind == tyBool:
|
||||||
localError(c.config, n.info, "ordinal or float type expected")
|
localError(c.config, n.info, "ordinal or float type expected")
|
||||||
elif enumHasHoles(rangeT[0]):
|
elif enumHasHoles(rangeT[0]):
|
||||||
|
|
|
||||||
|
|
@ -718,7 +718,7 @@ proc transformCase(c: PTransf, n: PNode): PTransNode =
|
||||||
result.add(elseBranch)
|
result.add(elseBranch)
|
||||||
elif result.PNode.lastSon.kind != nkElse and not (
|
elif result.PNode.lastSon.kind != nkElse and not (
|
||||||
skipTypes(n.sons[0].typ, abstractVarRange).kind in
|
skipTypes(n.sons[0].typ, abstractVarRange).kind in
|
||||||
{tyInt..tyInt64, tyChar, tyEnum, tyUInt..tyUInt32}):
|
{tyInt..tyInt64, tyChar, tyEnum, tyUInt..tyUInt64}):
|
||||||
# fix a stupid code gen bug by normalizing:
|
# fix a stupid code gen bug by normalizing:
|
||||||
var elseBranch = newTransNode(nkElse, n.info, 1)
|
var elseBranch = newTransNode(nkElse, n.info, 1)
|
||||||
elseBranch[0] = newTransNode(nkNilLit, n.info, 0)
|
elseBranch[0] = newTransNode(nkNilLit, n.info, 0)
|
||||||
|
|
|
||||||
|
|
@ -158,9 +158,9 @@ proc enumHasHoles*(t: PType): bool =
|
||||||
proc isOrdinalType*(t: PType, allowEnumWithHoles: bool = false): bool =
|
proc isOrdinalType*(t: PType, allowEnumWithHoles: bool = false): bool =
|
||||||
assert(t != nil)
|
assert(t != nil)
|
||||||
const
|
const
|
||||||
baseKinds = {tyChar,tyInt..tyUInt64,tyBool,tyEnum}
|
baseKinds = {tyChar,tyInt..tyInt64,tyUInt..tyUInt64,tyBool,tyEnum}
|
||||||
parentKinds = {tyRange, tyOrdinal, tyGenericInst, tyAlias, tySink, tyDistinct}
|
parentKinds = {tyRange, tyOrdinal, tyGenericInst, tyAlias, tySink, tyDistinct}
|
||||||
result = (t.kind in baseKinds and not (t.enumHasHoles and not allowEnumWithHoles)) or
|
result = (t.kind in baseKinds and (not t.enumHasHoles or allowEnumWithHoles)) or
|
||||||
(t.kind in parentKinds and isOrdinalType(t.lastSon, allowEnumWithHoles))
|
(t.kind in parentKinds and isOrdinalType(t.lastSon, allowEnumWithHoles))
|
||||||
|
|
||||||
proc iterOverTypeAux(marker: var IntSet, t: PType, iter: TTypeIter,
|
proc iterOverTypeAux(marker: var IntSet, t: PType, iter: TTypeIter,
|
||||||
|
|
|
||||||
|
|
@ -682,6 +682,7 @@ proc genUnaryABI(c: PCtx; n: PNode; dest: var TDest; opc: TOpcode; imm: BiggestI
|
||||||
c.gABI(n, opc, dest, tmp, imm)
|
c.gABI(n, opc, dest, tmp, imm)
|
||||||
c.freeTemp(tmp)
|
c.freeTemp(tmp)
|
||||||
|
|
||||||
|
|
||||||
proc genBinaryABC(c: PCtx; n: PNode; dest: var TDest; opc: TOpcode) =
|
proc genBinaryABC(c: PCtx; n: PNode; dest: var TDest; opc: TOpcode) =
|
||||||
let
|
let
|
||||||
tmp = c.genx(n.sons[1])
|
tmp = c.genx(n.sons[1])
|
||||||
|
|
@ -999,22 +1000,15 @@ proc genMagic(c: PCtx; n: PNode; dest: var TDest; m: TMagic) =
|
||||||
of mMulF64: genBinaryABC(c, n, dest, opcMulFloat)
|
of mMulF64: genBinaryABC(c, n, dest, opcMulFloat)
|
||||||
of mDivF64: genBinaryABC(c, n, dest, opcDivFloat)
|
of mDivF64: genBinaryABC(c, n, dest, opcDivFloat)
|
||||||
of mShrI:
|
of mShrI:
|
||||||
# the idea here is to narrow type if needed before executing right shift
|
# modified: genBinaryABC(c, n, dest, opcShrInt)
|
||||||
# inlined modified: genNarrowU(c, n, dest)
|
# narrowU is applied to the left operandthe idea here is to narrow the left operand
|
||||||
let t = skipTypes(n.typ, abstractVar-{tyTypeDesc})
|
|
||||||
# uint is uint64 in the VM, we we only need to mask the result for
|
|
||||||
# other unsigned types:
|
|
||||||
let tmp = c.genx(n.sons[1])
|
let tmp = c.genx(n.sons[1])
|
||||||
if t.kind in {tyUInt8..tyUInt32, tyInt8..tyInt32}:
|
c.genNarrowU(n, tmp)
|
||||||
c.gABC(n, opcNarrowU, tmp, TRegister(t.size*8))
|
|
||||||
|
|
||||||
# inlined modified: genBinaryABC(c, n, dest, opcShrInt)
|
|
||||||
let tmp2 = c.genx(n.sons[2])
|
let tmp2 = c.genx(n.sons[2])
|
||||||
if dest < 0: dest = c.getTemp(n.typ)
|
if dest < 0: dest = c.getTemp(n.typ)
|
||||||
c.gABC(n, opcShrInt, dest, tmp, tmp2)
|
c.gABC(n, opcShrInt, dest, tmp, tmp2)
|
||||||
c.freeTemp(tmp)
|
c.freeTemp(tmp)
|
||||||
c.freeTemp(tmp2)
|
c.freeTemp(tmp2)
|
||||||
|
|
||||||
of mShlI:
|
of mShlI:
|
||||||
genBinaryABC(c, n, dest, opcShlInt)
|
genBinaryABC(c, n, dest, opcShlInt)
|
||||||
# genNarrowU modified
|
# genNarrowU modified
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue