IC: rodfiles: no floats (#17720)

This commit is contained in:
Andreas Rumpf 2021-04-14 22:35:18 +02:00 • committed by GitHub
commit eff9d75379
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 21 deletions

View file

@ -224,7 +224,7 @@ proc toLitId(x: string; m: var PackedModule): LitId =
proc toLitId(x: BiggestInt; m: var PackedModule): LitId = proc toLitId(x: BiggestInt; m: var PackedModule): LitId =
## store an integer as a literal ## store an integer as a literal
result = getOrIncl(m.sh.integers, x) result = getOrIncl(m.sh.numbers, x)
proc toPackedInfo(x: TLineInfo; c: var PackedEncoder; m: var PackedModule): PackedLineInfo = proc toPackedInfo(x: TLineInfo; c: var PackedEncoder; m: var PackedModule): PackedLineInfo =
PackedLineInfo(line: x.line, col: x.col, file: toLitId(x.fileIndex, c, m)) PackedLineInfo(line: x.line, col: x.col, file: toLitId(x.fileIndex, c, m))
@ -400,7 +400,7 @@ proc toPackedNode*(n: PNode; ir: var PackedTree; c: var PackedEncoder; m: var Pa
typeId: storeTypeLater(n.typ, c, m), info: info) typeId: storeTypeLater(n.typ, c, m), info: info)
of externIntLit: of externIntLit:
ir.nodes.add PackedNode(kind: n.kind, flags: n.flags, ir.nodes.add PackedNode(kind: n.kind, flags: n.flags,
operand: int32 getOrIncl(m.sh.integers, n.intVal), operand: int32 getOrIncl(m.sh.numbers, n.intVal),
typeId: storeTypeLater(n.typ, c, m), info: info) typeId: storeTypeLater(n.typ, c, m), info: info)
of nkStrLit..nkTripleStrLit: of nkStrLit..nkTripleStrLit:
ir.nodes.add PackedNode(kind: n.kind, flags: n.flags, ir.nodes.add PackedNode(kind: n.kind, flags: n.flags,
@ -408,7 +408,7 @@ proc toPackedNode*(n: PNode; ir: var PackedTree; c: var PackedEncoder; m: var Pa
typeId: storeTypeLater(n.typ, c, m), info: info) typeId: storeTypeLater(n.typ, c, m), info: info)
of nkFloatLit..nkFloat128Lit: of nkFloatLit..nkFloat128Lit:
ir.nodes.add PackedNode(kind: n.kind, flags: n.flags, ir.nodes.add PackedNode(kind: n.kind, flags: n.flags,
operand: int32 getOrIncl(m.sh.floats, n.floatVal), operand: int32 getOrIncl(m.sh.numbers, cast[BiggestInt](n.floatVal)),
typeId: storeTypeLater(n.typ, c, m), info: info) typeId: storeTypeLater(n.typ, c, m), info: info)
else: else:
let patchPos = ir.prepare(n.kind, n.flags, let patchPos = ir.prepare(n.kind, n.flags,
@ -521,8 +521,7 @@ proc loadRodFile*(filename: AbsoluteFile; m: var PackedModule; config: ConfigRef
loadSeqSection depsSection, m.imports loadSeqSection depsSection, m.imports
loadTabSection integersSection, m.sh.integers loadTabSection numbersSection, m.sh.numbers
loadTabSection floatsSection, m.sh.floats
loadSeqSection exportsSection, m.exports loadSeqSection exportsSection, m.exports
@ -587,8 +586,7 @@ proc saveRodFile*(filename: AbsoluteFile; encoder: var PackedEncoder; m: var Pac
storeSeqSection depsSection, m.imports storeSeqSection depsSection, m.imports
storeTabSection integersSection, m.sh.integers storeTabSection numbersSection, m.sh.numbers
storeTabSection floatsSection, m.sh.floats
storeSeqSection exportsSection, m.exports storeSeqSection exportsSection, m.exports
@ -700,11 +698,11 @@ proc loadNodes*(c: var PackedDecoder; g: var PackedModuleGraph; thisModule: int;
of directIntLit: of directIntLit:
result.intVal = tree.nodes[n.int].operand result.intVal = tree.nodes[n.int].operand
of externIntLit: of externIntLit:
result.intVal = g[thisModule].fromDisk.sh.integers[n.litId] result.intVal = g[thisModule].fromDisk.sh.numbers[n.litId]
of nkStrLit..nkTripleStrLit: of nkStrLit..nkTripleStrLit:
result.strVal = g[thisModule].fromDisk.sh.strings[n.litId] result.strVal = g[thisModule].fromDisk.sh.strings[n.litId]
of nkFloatLit..nkFloat128Lit: of nkFloatLit..nkFloat128Lit:
result.floatVal = g[thisModule].fromDisk.sh.floats[n.litId] result.floatVal = cast[BiggestFloat](g[thisModule].fromDisk.sh.numbers[n.litId])
of nkModuleRef: of nkModuleRef:
let (n1, n2) = sons2(tree, n) let (n1, n2) = sons2(tree, n)
assert n1.kind == nkInt32Lit assert n1.kind == nkInt32Lit
@ -1151,5 +1149,4 @@ proc rodViewer*(rodfile: AbsoluteFile; config: ConfigRef, cache: IdentCache) =
echo "symbols: ", m.sh.syms.len, " types: ", m.sh.types.len, echo "symbols: ", m.sh.syms.len, " types: ", m.sh.types.len,
" top level nodes: ", m.topLevel.nodes.len, " other nodes: ", m.bodies.nodes.len, " top level nodes: ", m.topLevel.nodes.len, " other nodes: ", m.bodies.nodes.len,
" strings: ", m.sh.strings.len, " integers: ", m.sh.integers.len, " strings: ", m.sh.strings.len, " numbers: ", m.sh.numbers.len
" floats: ", m.sh.floats.len

View file

@ -79,12 +79,10 @@ proc checkNode(c: var CheckedContext; tree: PackedTree; n: NodePos) =
checkLocalSym(c, tree.nodes[n.int].operand) checkLocalSym(c, tree.nodes[n.int].operand)
of directIntLit: of directIntLit:
discard discard
of externIntLit: of externIntLit, nkFloatLit..nkFloat128Lit:
assert c.g.packed[c.thisModule].fromDisk.sh.integers.hasLitId n.litId assert c.g.packed[c.thisModule].fromDisk.sh.numbers.hasLitId n.litId
of nkStrLit..nkTripleStrLit: of nkStrLit..nkTripleStrLit:
assert c.g.packed[c.thisModule].fromDisk.sh.strings.hasLitId n.litId assert c.g.packed[c.thisModule].fromDisk.sh.strings.hasLitId n.litId
of nkFloatLit..nkFloat128Lit:
assert c.g.packed[c.thisModule].fromDisk.sh.floats.hasLitId n.litId
of nkModuleRef: of nkModuleRef:
let (n1, n2) = sons2(tree, n) let (n1, n2) = sons2(tree, n)
assert n1.kind == nkInt32Lit assert n1.kind == nkInt32Lit

View file

@ -106,8 +106,8 @@ type
syms*: seq[PackedSym] syms*: seq[PackedSym]
types*: seq[PackedType] types*: seq[PackedType]
strings*: BiTable[string] # we could share these between modules. strings*: BiTable[string] # we could share these between modules.
integers*: BiTable[BiggestInt] numbers*: BiTable[BiggestInt] # we also store floats in here so
floats*: BiTable[BiggestFloat] # that we can assure that every bit is kept
#config*: ConfigRef #config*: ConfigRef
PackedInstantiation* = object PackedInstantiation* = object
@ -394,10 +394,13 @@ proc toString*(tree: PackedTree; n: NodePos; sh: Shared; nesting: int;
result.addInt tree.nodes[pos].operand result.addInt tree.nodes[pos].operand
of externSIntLit: of externSIntLit:
result.add " " result.add " "
result.addInt sh.integers[LitId tree.nodes[pos].operand] result.addInt sh.numbers[LitId tree.nodes[pos].operand]
of externUIntLit: of externUIntLit:
result.add " " result.add " "
result.add $cast[uint64](sh.integers[LitId tree.nodes[pos].operand]) result.add $cast[uint64](sh.numbers[LitId tree.nodes[pos].operand])
of nkFloatLit..nkFloat128Lit:
result.add " "
result.add $cast[BiggestFloat](sh.numbers[LitId tree.nodes[pos].operand])
else: else:
result.add "(\n" result.add "(\n"
for i in 1..(nesting+1)*2: result.add ' ' for i in 1..(nesting+1)*2: result.add ' '

View file

@ -16,8 +16,7 @@ type
stringsSection stringsSection
checkSumsSection checkSumsSection
depsSection depsSection
integersSection numbersSection
floatsSection
exportsSection exportsSection
reexportsSection reexportsSection
compilerProcsSection compilerProcsSection