mirror of
https://github.com/Z3Prover/z3
synced 2025-04-27 02:45:51 +00:00
initial u256
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
c053c7f1c8
commit
babb90832c
22 changed files with 6635 additions and 1 deletions
73
src/math/bigfix/Hacl_Bignum_Base.h
Normal file
73
src/math/bigfix/Hacl_Bignum_Base.h
Normal file
|
@ -0,0 +1,73 @@
|
|||
/* MIT License
|
||||
*
|
||||
* Copyright (c) 2016-2020 INRIA, CMU and Microsoft Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __Hacl_Bignum_Base_H
|
||||
#define __Hacl_Bignum_Base_H
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "kremlin/internal/types.h"
|
||||
#include "kremlin/lowstar_endianness.h"
|
||||
#include <string.h>
|
||||
#include "kremlin/internal/target.h"
|
||||
|
||||
static inline uint64_t
|
||||
Hacl_Bignum_Base_mul_wide_add_u64(uint64_t a, uint64_t b, uint64_t c_in, uint64_t *out)
|
||||
{
|
||||
FStar_UInt128_uint128
|
||||
res = FStar_UInt128_add(FStar_UInt128_mul_wide(a, b), FStar_UInt128_uint64_to_uint128(c_in));
|
||||
out[0U] = FStar_UInt128_uint128_to_uint64(res);
|
||||
return FStar_UInt128_uint128_to_uint64(FStar_UInt128_shift_right(res, (uint32_t)64U));
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
Hacl_Bignum_Base_mul_wide_add2_u32(uint32_t a, uint32_t b, uint32_t c_in, uint32_t *out)
|
||||
{
|
||||
uint32_t out0 = out[0U];
|
||||
uint64_t res = (uint64_t)a * (uint64_t)b + (uint64_t)c_in + (uint64_t)out0;
|
||||
out[0U] = (uint32_t)res;
|
||||
return (uint32_t)(res >> (uint32_t)32U);
|
||||
}
|
||||
|
||||
static inline uint64_t
|
||||
Hacl_Bignum_Base_mul_wide_add2_u64(uint64_t a, uint64_t b, uint64_t c_in, uint64_t *out)
|
||||
{
|
||||
uint64_t out0 = out[0U];
|
||||
FStar_UInt128_uint128
|
||||
res =
|
||||
FStar_UInt128_add(FStar_UInt128_add(FStar_UInt128_mul_wide(a, b),
|
||||
FStar_UInt128_uint64_to_uint128(c_in)),
|
||||
FStar_UInt128_uint64_to_uint128(out0));
|
||||
out[0U] = FStar_UInt128_uint128_to_uint64(res);
|
||||
return FStar_UInt128_uint128_to_uint64(FStar_UInt128_shift_right(res, (uint32_t)64U));
|
||||
}
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#define __Hacl_Bignum_Base_H_DEFINED
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue