mirror of
https://github.com/logos-storage/constantine.git
synced 2026-01-05 22:53:12 +00:00
* rework assembler register/mem and constraint declarations * Introduce constraint UnmutatedPointerToWriteMem * Create invidual memory cell operands * [Assembly] fully support indirect memory addressing * fix calling convention for exported procs * Prepare for switch to intel syntax to avoid clang constant propagation asm symbol name interfering OR pointer+offset addressing * use modifiers to prevent bad string mixin fo assembler to linker of propagated consts * Assembly: switch to intel syntax * with working memory operand - now works with LTO on both GCC and clang and constant folding * use memory operand in more places * remove some inline now that we have lto * cleanup compiler config and benches * tracer shouldn't force dependencies when unused * fix cc on linux * nimble fixes * update README [skip CI] * update MacOS CI with Homebrew Clang * oops nimble bindings disappeared * more nimble fixes * fix sha256 exported symbol * improve constraints on modular addition * Add extra constraint to force reloading of pointer in reg inputs * Fix LLVM gold linker running out of registers * workaround MinGW64 GCC 12.2 bad codegen in t_pairing_cyclotomic_subgroup with LTO
53 lines
2.0 KiB
Nim
53 lines
2.0 KiB
Nim
# Constantine
|
|
# Copyright (c) 2018-2019 Status Research & Development GmbH
|
|
# Copyright (c) 2020-Present Mamy André-Ratsimbazafy
|
|
# Licensed and distributed under either of
|
|
# * MIT license (license terms in the root directory or at http://opensource.org/licenses/MIT).
|
|
# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0).
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
|
|
|
# This module allows flexible exports of procedures.
|
|
# 1. This allows configuring all exported names from the protocol files
|
|
# instead of having those in many different places.
|
|
# 2. No extra public wrapper proc are needed, reducing function call/return overhead.
|
|
# i.e. if we have an inner sha256.hash function
|
|
# and we need an exported `ctt_sha256_hash` and we also have a `hash_to_curve` function
|
|
# that internally uses `sha256.hash`,
|
|
# the ideal outcome is for `sha256.hash to be exported as `ctt_sha256_hash` and
|
|
# have `hash_to_curve` directly use that.
|
|
# 3. Furthermore while compiling Nim only, no export marker (noconv, dynlib, exportc) are used.
|
|
#
|
|
# Each prefix must be modified before importing the module to export
|
|
|
|
# Exportable functions
|
|
# ----------------------------------------------------------------------------------------------
|
|
|
|
var prefix_sha256* {.compileTime.} = ""
|
|
|
|
# Conditional exports
|
|
# ----------------------------------------------------------------------------------------------
|
|
|
|
import std/macros
|
|
|
|
macro libPrefix*(prefix: static string, procAst: untyped): untyped =
|
|
if prefix == "":
|
|
return procAst
|
|
else:
|
|
var pragmas = procAst.pragma
|
|
if pragmas.kind == nnkEmpty:
|
|
pragmas = nnkPragma.newTree()
|
|
|
|
pragmas.add ident"noconv"
|
|
pragmas.add nnkExprColonExpr.newTree(
|
|
ident"exportc",
|
|
newLit(prefix & "$1"))
|
|
pragmas.add nnkExprColonExpr.newTree(
|
|
ident"raises",
|
|
nnkBracket.newTree())
|
|
|
|
if appType == "lib":
|
|
pragmas.add ident"dynlib"
|
|
|
|
result = procAst
|
|
result.pragma = pragmas
|