Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

research: update LLVM x86 compiler and JIT #452

Merged
merged 1 commit into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions constantine/math_compiler/ir.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
# at your option. This file may not be copied, modified, or distributed except according to those terms.

import
constantine/math/config/[curves, precompute],
constantine/named/algebras,
constantine/named/deriv/precompute,
constantine/math/io/io_bigints,
constantine/platforms/[primitives, bithacks],
constantine/platforms/llvm/llvm,
Expand All @@ -30,6 +31,7 @@ type

Backend* = enum
bkNvidiaPTX
bkX86_64_Linux

FnDef* = tuple[fnTy: TypeRef, fnImpl: ValueRef]
# calling getTypeOf on a ValueRef function
Expand All @@ -51,6 +53,9 @@ proc new*(T: type Assembler_LLVM, backend: Backend, moduleName: cstring): Assemb
result.module.setTarget("nvptx64-nvidia-cuda")
# Datalayout for NVVM IR 1.8 (CUDA 11.6)
result.module.setDataLayout("e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-i128:128:128-f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64")
of bkX86_64_Linux:
{.warning : "The x86 LLVM backend is incomplete and for research purposes only".}
result.module.setTarget("x86_64-pc-linux-gnu")

result.builder = result.ctx.createBuilder()
result.i1_t = result.ctx.int1_t()
Expand Down Expand Up @@ -188,7 +193,7 @@ type
spareBits*: uint8

CurveMetadata* = object
curve*: Curve
curve*: Algebra
prefix*: string
wordSize*: WordSize
fp*: FieldConst
Expand Down
1 change: 0 additions & 1 deletion research/codegen/nim.cfg

This file was deleted.

6 changes: 3 additions & 3 deletions research/codegen/x86_inlineasm.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import
std/[macros, strutils],
./llvm
constantine/platforms/llvm/llvm

# ############################################################
#
Expand Down Expand Up @@ -85,7 +85,7 @@ macro genInstr(body: untyped): untyped =


instrBody.add quote do:
let `asmString` = if numBits == 64: static(`instr` & "q") & static(" " & `instrParam`)
let `asmString` = if `numBits` == 64: static(`instr` & "q") & static(" " & `instrParam`)
else: static(`instr` & "l") & static(" " & `instrParam`)

instrBody.add quote do:
Expand Down Expand Up @@ -206,4 +206,4 @@ genInstr():
op adcx_rr: ("adcx", "%2, %0;", "=r,%0,r", [lhs, rhs])
op adcx_rm: ("adcx", "%2, %0;", "=r,0,m", [lhs, rhs])
op adox_rr: ("adox", "%2, %0;", "=r,%0,r", [lhs, rhs])
op adox_rm: ("adox", "%2, %0;", "=r,0,m", [lhs, rhs])
op adox_rm: ("adox", "%2, %0;", "=r,0,m", [lhs, rhs])
9 changes: 5 additions & 4 deletions research/codegen/x86.nim → research/codegen/x86_instr.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
# at your option. This file may not be copied, modified, or distributed except according to those terms.

import
./bindings/c_abi,
./llvm, ./ir,
./x86_inlineasm,
../primitives
constantine/platforms/llvm/bindings/c_abi,
constantine/platforms/llvm/llvm,
constantine/platforms/primitives,
constantine/math_compiler/ir,
./x86_inlineasm

export x86_inlineasm

Expand Down
Loading
Loading