crypto.25519.field: de-inline mul for small builds (#14775)

This commit is contained in:
Eric Milliken 2023-03-06 22:28:11 +00:00 committed by GitHub
parent 6ab04b5941
commit ccf00ccdf7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,5 @@
const std = @import("std"); const std = @import("std");
const builtin = @import("builtin");
const crypto = std.crypto; const crypto = std.crypto;
const readIntLittle = std.mem.readIntLittle; const readIntLittle = std.mem.readIntLittle;
const writeIntLittle = std.mem.writeIntLittle; const writeIntLittle = std.mem.writeIntLittle;
@ -6,6 +7,12 @@ const writeIntLittle = std.mem.writeIntLittle;
const NonCanonicalError = crypto.errors.NonCanonicalError; const NonCanonicalError = crypto.errors.NonCanonicalError;
const NotSquareError = crypto.errors.NotSquareError; const NotSquareError = crypto.errors.NotSquareError;
// Inline conditionally, when it can result in large code generation.
const bloaty_inline = switch (builtin.mode) {
.ReleaseSafe, .ReleaseFast => .Inline,
.Debug, .ReleaseSmall => .Unspecified,
};
pub const Fe = struct { pub const Fe = struct {
limbs: [5]u64, limbs: [5]u64,
@ -264,7 +271,7 @@ pub const Fe = struct {
} }
/// Multiply two field elements /// Multiply two field elements
pub inline fn mul(a: Fe, b: Fe) Fe { pub fn mul(a: Fe, b: Fe) callconv(bloaty_inline) Fe {
var ax: [5]u128 = undefined; var ax: [5]u128 = undefined;
var bx: [5]u128 = undefined; var bx: [5]u128 = undefined;
var a19: [5]u128 = undefined; var a19: [5]u128 = undefined;