IC: green tests (#17311)
* IC: renamed to_packed_ast module to ic module * IC: don't store the --forceBuild flag, makes it easier to test * IC: enable hello world test * Codegen: refactorings for IC; changed the name mangling algorithm * fixed the HCR regressions * life is too short for HCR * tconvexhull is now allowed to use deepCopy * IC exposed a stdlib bug, required a refactoring * codegen: code cleanups * IC: even if a module is outdated, its dependencies might come from disk * IC: progress * IC: better name mangling, module IDs are not stable * IC: another refactoring helping with --ic:on --gc:arc * disable arraymancer on Windows for the time being * disable arraymancer altogether * IC: make basic test work with 'nim cpp' * IC: progress on --ic:on --gc:arc * wip; name mangling for type info
This commit is contained in:
parent
60fc7e986b
commit
6c1c8f51b3
30 changed files with 249 additions and 187 deletions
25
lib/system/countbits_impl.nim
Normal file
25
lib/system/countbits_impl.nim
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#
|
||||
#
|
||||
# Nim's Runtime Library
|
||||
# (c) Copyright 2012 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## Contains the used algorithms for counting bits.
|
||||
|
||||
proc countBits32*(n: uint32): int {.compilerproc.} =
|
||||
# generic formula is from: https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
|
||||
var v = uint32(n)
|
||||
v = v - ((v shr 1'u32) and 0x55555555'u32)
|
||||
v = (v and 0x33333333'u32) + ((v shr 2'u32) and 0x33333333'u32)
|
||||
result = (((v + (v shr 4'u32) and 0xF0F0F0F'u32) * 0x1010101'u32) shr 24'u32).int
|
||||
|
||||
proc countBits64*(n: uint64): int {.compilerproc, inline.} =
|
||||
# generic formula is from: https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
|
||||
var v = uint64(n)
|
||||
v = v - ((v shr 1'u64) and 0x5555555555555555'u64)
|
||||
v = (v and 0x3333333333333333'u64) + ((v shr 2'u64) and 0x3333333333333333'u64)
|
||||
v = (v + (v shr 4'u64) and 0x0F0F0F0F0F0F0F0F'u64)
|
||||
result = ((v * 0x0101010101010101'u64) shr 56'u64).int
|
||||
|
|
@ -567,7 +567,7 @@ when defined(cpp) and appType != "lib" and not gotoBasedExceptions and
|
|||
type
|
||||
StdException {.importcpp: "std::exception", header: "<exception>".} = object
|
||||
|
||||
proc what(ex: StdException): cstring {.importcpp: "((char *)#.what())".}
|
||||
proc what(ex: StdException): cstring {.importcpp: "((char *)#.what())", nodecl.}
|
||||
|
||||
proc setTerminate(handler: proc() {.noconv.})
|
||||
{.importc: "std::set_terminate", header: "<exception>".}
|
||||
|
|
|
|||
|
|
@ -14,21 +14,6 @@ type
|
|||
|
||||
# bitops can't be imported here, therefore the code duplication.
|
||||
|
||||
proc countBits32(n: uint32): int {.compilerproc.} =
|
||||
# generic formula is from: https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
|
||||
var v = uint32(n)
|
||||
v = v - ((v shr 1'u32) and 0x55555555'u32)
|
||||
v = (v and 0x33333333'u32) + ((v shr 2'u32) and 0x33333333'u32)
|
||||
result = (((v + (v shr 4'u32) and 0xF0F0F0F'u32) * 0x1010101'u32) shr 24'u32).int
|
||||
|
||||
proc countBits64(n: uint64): int {.compilerproc, inline.} =
|
||||
# generic formula is from: https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
|
||||
var v = uint64(n)
|
||||
v = v - ((v shr 1'u64) and 0x5555555555555555'u64)
|
||||
v = (v and 0x3333333333333333'u64) + ((v shr 2'u64) and 0x3333333333333333'u64)
|
||||
v = (v + (v shr 4'u64) and 0x0F0F0F0F0F0F0F0F'u64)
|
||||
result = ((v * 0x0101010101010101'u64) shr 56'u64).int
|
||||
|
||||
proc cardSet(s: NimSet, len: int): int {.compilerproc, inline.} =
|
||||
var i = 0
|
||||
result = 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue