mirror of
https://github.com/codex-storage/constantine.git
synced 2025-01-12 03:54:14 +00:00
Nvidia JIT fixes (#290)
* lib org change, need serialization/io_limbs import * fix unused variable and useless conversion warnings * Update LLVM bindings to LLVM-16
This commit is contained in:
parent
4ccd8aaab8
commit
67fbd8c699
@ -248,16 +248,20 @@ proc getGlobalPassRegistry(): PassRegistryRef {.importc: "LLVMGetGlobalPassRegis
|
||||
proc initializeCore(registry: PassRegistryRef) {.importc: "LLVMInitializeCore".}
|
||||
proc initializeTransformUtils(registry: PassRegistryRef) {.importc: "LLVMInitializeTransformUtils".}
|
||||
proc initializeScalarOpts(registry: PassRegistryRef) {.importc: "LLVMInitializeScalarOpts".}
|
||||
proc initializeObjCARCOpts(registry: PassRegistryRef) {.importc: "LLVMInitializeObjCARCOpts".}
|
||||
proc initializeVectorization(registry: PassRegistryRef) {.importc: "LLVMInitializeVectorization".}
|
||||
proc initializeInstCombine(registry: PassRegistryRef) {.importc: "LLVMInitializeInstCombine".}
|
||||
proc initializeAggressiveInstCombiner(registry: PassRegistryRef) {.importc: "LLVMInitializeAggressiveInstCombiner".}
|
||||
proc initializeIPO(registry: PassRegistryRef) {.importc: "LLVMInitializeIPO".}
|
||||
proc initializeInstrumentation(registry: PassRegistryRef) {.importc: "LLVMInitializeInstrumentation".}
|
||||
proc initializeAnalysis(registry: PassRegistryRef) {.importc: "LLVMInitializeAnalysis".}
|
||||
proc initializeIPA(registry: PassRegistryRef) {.importc: "LLVMInitializeIPA".}
|
||||
proc initializeCodeGen(registry: PassRegistryRef) {.importc: "LLVMInitializeCodeGen".}
|
||||
proc initializeTarget(registry: PassRegistryRef) {.importc: "LLVMInitializeTarget".}
|
||||
|
||||
# Removed in LLVM 16
|
||||
# ------------------
|
||||
# proc initializeObjCARCOpts(registry: PassRegistryRef) {.importc: "LLVMInitializeObjCARCOpts".}
|
||||
# proc initializeAggressiveInstCombiner(registry: PassRegistryRef) {.importc: "LLVMInitializeAggressiveInstCombiner".}
|
||||
# proc initializeInstrumentation(registry: PassRegistryRef) {.importc: "LLVMInitializeInstrumentation".}
|
||||
|
||||
{.pop.}
|
||||
|
||||
# https://llvm.org/doxygen/group__LLVMCTarget.html
|
||||
|
@ -10,7 +10,7 @@ import
|
||||
../../math/config/[curves, precompute],
|
||||
../../math/io/io_bigints,
|
||||
../primitives, ../bithacks,
|
||||
../../serialization/[endians, codecs],
|
||||
../../serialization/[endians, codecs, io_limbs],
|
||||
./llvm
|
||||
|
||||
# ############################################################
|
||||
|
@ -120,7 +120,7 @@ template emitToFile*(t: TargetMachineRef, m: ModuleRef,
|
||||
writeStackTrace()
|
||||
stderr.write("\"emitToFile\" for module '" & astToStr(module) & "' " & $instantiationInfo() & " exited with error: " & $cstring(errMsg) & '\n')
|
||||
errMsg.dispose()
|
||||
quit 1
|
||||
quit 1
|
||||
|
||||
template emitToString*(t: TargetMachineRef, m: ModuleRef, codegen: CodeGenFileType): string =
|
||||
## Codegen to string
|
||||
@ -147,17 +147,20 @@ proc initializePasses* =
|
||||
registry.initializeCore()
|
||||
registry.initializeTransformUtils()
|
||||
registry.initializeScalarOpts()
|
||||
registry.initializeObjCARCOpts()
|
||||
registry.initializeVectorization()
|
||||
registry.initializeInstCombine()
|
||||
registry.initializeAggressiveInstCombiner()
|
||||
registry.initializeIPO()
|
||||
registry.initializeInstrumentation()
|
||||
registry.initializeAnalysis()
|
||||
registry.initializeIPA()
|
||||
registry.initializeCodeGen()
|
||||
registry.initializeTarget()
|
||||
|
||||
# Removed in LLVM 16
|
||||
# --------------------------------
|
||||
# registry.initializeObjCARCOpts()
|
||||
# registry.initializeAggressiveInstCombiner()
|
||||
# registry.initializeInstrumentation()
|
||||
|
||||
# Builder
|
||||
# ------------------------------------------------------------
|
||||
|
||||
|
@ -96,7 +96,7 @@ macro genInstr(body: untyped): untyped =
|
||||
let lhs = op[2][0][3][0]
|
||||
|
||||
instrBody.add quote do:
|
||||
let `ctx` = builder.getContext()
|
||||
let `ctx` {.used.} = builder.getContext()
|
||||
# lhs: ValueRef or uint32 or uint64
|
||||
let `numBits` = when `lhs` is ValueRef|ConstValueRef: `lhs`.getTypeOf().getIntTypeWidth()
|
||||
else: 8*sizeof(`lhs`)
|
||||
@ -226,13 +226,11 @@ macro genInstr(body: untyped): untyped =
|
||||
for op in operands:
|
||||
# when op is ValueRef: op
|
||||
# else: constInt(uint64(op))
|
||||
opArray.add newCall(
|
||||
bindSym"ValueRef",
|
||||
nnkWhenStmt.newTree(
|
||||
nnkElifBranch.newTree(nnkInfix.newTree(ident"is", op, bindSym"AnyValueRef"), op),
|
||||
nnkElse.newTree(newCall(ident"constInt", regTy, newCall(ident"uint64", op)))
|
||||
opArray.add nnkWhenStmt.newTree(
|
||||
nnkElifBranch.newTree(nnkInfix.newTree(ident"is", op, bindSym"ValueRef"), op),
|
||||
nnkElifBranch.newTree(nnkInfix.newTree(ident"is", op, bindSym"ConstValueRef"), newCall(ident"ValueRef", op)),
|
||||
nnkElse.newTree(newCall(ident"ValueRef", newCall(ident"constInt", regTy, newCall(ident"uint64", op))))
|
||||
)
|
||||
)
|
||||
# builder.call2(ty, inlineASM, [lhs, rhs], name)
|
||||
instrBody.add newCall(
|
||||
ident"call2", ident"builder", fnTy,
|
||||
|
Loading…
x
Reference in New Issue
Block a user