From 77aa3bd9ae71f5c6d483396631b2defd59a9d69a Mon Sep 17 00:00:00 2001 From: torben-hansen <50673096+torben-hansen@users.noreply.github.com> Date: Fri, 24 Nov 2023 08:43:58 -0800 Subject: [PATCH] Wire up s2n-bignum Ed25519 backend (#1309) Wires up the Ed25519 s2n-bignum backend to the frontend. From now on, all Ed25519 operations will use s2n-bignum on supported hardware. --- CMakeLists.txt | 3 + crypto/curve25519/curve25519.c | 221 +++++- crypto/fipsmodule/CMakeLists.txt | 42 +- tests/ci/common_posix_setup.sh | 2 +- .../s2n-bignum/include/s2n-bignum_aws-lc.h | 78 +++ util/fipstools/delocate/delocate.peg | 1 + util/fipstools/delocate/delocate.peg.go | 631 ++++++------------ .../delocate/testdata/aarch64-Basic/in.s | 4 + .../delocate/testdata/aarch64-Basic/out.s | 4 + 9 files changed, 523 insertions(+), 463 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 92d3f6ebcc..4a1271c719 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -158,6 +158,9 @@ if(BORINGSSL_PREFIX AND BORINGSSL_PREFIX_SYMBOLS AND GO_EXECUTABLE) COMMAND sed -i.bak '/ curve25519_x25519/d' ${CMAKE_CURRENT_BINARY_DIR}/symbol_prefix_include/openssl/boringssl_prefix_symbols.h COMMAND sed -i.bak '/ curve25519_x25519/d' ${CMAKE_CURRENT_BINARY_DIR}/symbol_prefix_include/openssl/boringssl_prefix_symbols_asm.h COMMAND sed -i.bak '/ curve25519_x25519/d' ${CMAKE_CURRENT_BINARY_DIR}/symbol_prefix_include/openssl/boringssl_prefix_symbols_nasm.inc + COMMAND sed -i.bak '/ edwards25519_/d' ${CMAKE_CURRENT_BINARY_DIR}/symbol_prefix_include/openssl/boringssl_prefix_symbols.h + COMMAND sed -i.bak '/ edwards25519_/d' ${CMAKE_CURRENT_BINARY_DIR}/symbol_prefix_include/openssl/boringssl_prefix_symbols_asm.h + COMMAND sed -i.bak '/ edwards25519_/d' ${CMAKE_CURRENT_BINARY_DIR}/symbol_prefix_include/openssl/boringssl_prefix_symbols_nasm.inc COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_BINARY_DIR}/symbol_prefix_include/openssl/boringssl_prefix_symbols.h.bak ${CMAKE_CURRENT_BINARY_DIR}/symbol_prefix_include/openssl/boringssl_prefix_symbols_asm.h.bak diff --git a/crypto/curve25519/curve25519.c b/crypto/curve25519/curve25519.c index 38df5c948e..7d08592ecd 100644 --- a/crypto/curve25519/curve25519.c +++ b/crypto/curve25519/curve25519.c @@ -64,7 +64,6 @@ #define CURVE25519_S2N_BIGNUM_CAPABLE #endif - OPENSSL_INLINE int curve25519_s2n_bignum_capable(void) { #if defined(CURVE25519_S2N_BIGNUM_CAPABLE) return 1; @@ -73,40 +72,43 @@ OPENSSL_INLINE int curve25519_s2n_bignum_capable(void) { #endif } -// Return 0 until ED25519 lands in s2n-bignum +// Temporarily use separate function for Ed25519. See CryptoAlg-2198. OPENSSL_INLINE int ed25519_s2n_bignum_capable(void) { +#if defined(CURVE25519_S2N_BIGNUM_CAPABLE) && !defined(AWSLC_FIPS) + return 1; +#else return 0; +#endif } // Stub functions if implementations are not compiled. // These functions have to abort, otherwise we risk applications assuming they // did work without actually doing anything. +#if !defined(CURVE25519_S2N_BIGNUM_CAPABLE) || defined(BORINGSSL_FIPS) + +#define S2N_BIGNUM_STUB_FUNC(return_type, symbol, ...) \ + return_type symbol(__VA_ARGS__); \ + return_type symbol(__VA_ARGS__) { abort(); } \ + +S2N_BIGNUM_STUB_FUNC(void, bignum_mod_n25519, uint64_t z[4], uint64_t k, uint64_t *x) +S2N_BIGNUM_STUB_FUNC(void, bignum_neg_p25519, uint64_t z[4], uint64_t x[4]) +S2N_BIGNUM_STUB_FUNC(void, bignum_madd_n25519, uint64_t z[4], uint64_t x[4], uint64_t y[4], uint64_t c[4]) +S2N_BIGNUM_STUB_FUNC(void, bignum_madd_n25519_alt, uint64_t z[4], uint64_t x[4], uint64_t y[4], uint64_t c[4]) +S2N_BIGNUM_STUB_FUNC(void, edwards25519_encode, uint8_t z[32], uint64_t p[8]) +S2N_BIGNUM_STUB_FUNC(uint64_t, edwards25519_decode, uint64_t z[8], const uint8_t c[32]) +S2N_BIGNUM_STUB_FUNC(uint64_t, edwards25519_decode_alt, uint64_t z[8], const uint8_t c[32]) +S2N_BIGNUM_STUB_FUNC(void, edwards25519_scalarmulbase, uint64_t res[8],uint64_t scalar[4]) +S2N_BIGNUM_STUB_FUNC(void, edwards25519_scalarmulbase_alt, uint64_t res[8],uint64_t scalar[4]) +S2N_BIGNUM_STUB_FUNC(void, edwards25519_scalarmuldouble, uint64_t res[8], uint64_t scalar[4], uint64_t point[8], uint64_t bscalar[4]) +S2N_BIGNUM_STUB_FUNC(void, edwards25519_scalarmuldouble_alt, uint64_t res[8], uint64_t scalar[4], uint64_t point[8], uint64_t bscalar[4]) #if !defined(CURVE25519_S2N_BIGNUM_CAPABLE) - -void curve25519_x25519_byte(uint8_t res[32], const uint8_t scalar[32], - const uint8_t point[32]); -void curve25519_x25519_byte_alt(uint8_t res[32], const uint8_t scalar[32], - const uint8_t point[32]); -void curve25519_x25519base_byte(uint8_t res[32], const uint8_t scalar[32]); -void curve25519_x25519base_byte_alt(uint8_t res[32], const uint8_t scalar[32]); - -void curve25519_x25519_byte(uint8_t res[32], const uint8_t scalar[32], - const uint8_t point[32]) { - abort(); -} -void curve25519_x25519_byte_alt(uint8_t res[32], const uint8_t scalar[32], - const uint8_t point[32]) { - abort(); -} -void curve25519_x25519base_byte(uint8_t res[32], const uint8_t scalar[32]) { - abort(); -} -void curve25519_x25519base_byte_alt(uint8_t res[32], const uint8_t scalar[32]) { - abort(); -} - +S2N_BIGNUM_STUB_FUNC(void, curve25519_x25519_byte, uint8_t res[32], const uint8_t scalar[32], const uint8_t point[32]) +S2N_BIGNUM_STUB_FUNC(void, curve25519_x25519_byte_alt, uint8_t res[32], const uint8_t scalar[32], const uint8_t point[32]) +S2N_BIGNUM_STUB_FUNC(void, curve25519_x25519base_byte, uint8_t res[32], const uint8_t scalar[32]) +S2N_BIGNUM_STUB_FUNC(void, curve25519_x25519base_byte_alt, uint8_t res[32], const uint8_t scalar[32]) #endif // !defined(CURVE25519_S2N_BIGNUM_CAPABLE) +#endif // !defined(CURVE25519_S2N_BIGNUM_CAPABLE) || defined(BORINGSSL_FIPS) // Run-time detection for each implementation @@ -261,27 +263,192 @@ static void x25519_s2n_bignum_public_from_private( #endif } -// Stub function until ED25519 lands in s2n-bignum static void ed25519_public_key_from_hashed_seed_s2n_bignum( uint8_t out_public_key[ED25519_PUBLIC_KEY_LEN], uint8_t az[SHA512_DIGEST_LENGTH]) { + + uint64_t uint64_point[8] = {0}; + uint64_t uint64_hashed_seed[4] = {0}; + OPENSSL_memcpy(uint64_hashed_seed, az, 32); + +#if defined(OPENSSL_X86_64) + + if (curve25519_s2n_bignum_no_alt_capable() == 1) { + edwards25519_scalarmulbase(uint64_point, uint64_hashed_seed); + } else if (curve25519_s2n_bignum_alt_capable() == 1) { + edwards25519_scalarmulbase_alt(uint64_point, uint64_hashed_seed); + } else { + abort(); + } + +#elif defined(OPENSSL_AARCH64) + + if (curve25519_s2n_bignum_alt_capable() == 1) { + edwards25519_scalarmulbase_alt(uint64_point, uint64_hashed_seed); + } else if (curve25519_s2n_bignum_no_alt_capable() == 1) { + edwards25519_scalarmulbase(uint64_point, uint64_hashed_seed); + } else { + abort(); + } + +#else + + // Should not call this function unless s2n-bignum is supported. abort(); + +#endif + + edwards25519_encode(out_public_key, uint64_point); } -// Stub function until Ed25519 lands in s2n-bignum // |s| is of length |ED25519_PRIVATE_KEY_SEED_LEN| // |A| is of length |ED25519_PUBLIC_KEY_LEN|. static void ed25519_sign_s2n_bignum( uint8_t out_sig[ED25519_SIGNATURE_LEN], uint8_t r[SHA512_DIGEST_LENGTH], const uint8_t *s, const uint8_t *A, const void *message, size_t message_len) { + + void (*scalarmulbase)(uint64_t res[8],uint64_t scalar[4]); + void (*madd)(uint64_t z[4], uint64_t x[4], uint64_t y[4], uint64_t c[4]); + +#if defined(OPENSSL_X86_64) + + if (curve25519_s2n_bignum_no_alt_capable() == 1) { + scalarmulbase = edwards25519_scalarmulbase; + madd = bignum_madd_n25519; + } else if (curve25519_s2n_bignum_alt_capable() == 1) { + scalarmulbase = edwards25519_scalarmulbase_alt; + madd = bignum_madd_n25519_alt; + } else { + abort(); + } + +#elif defined(OPENSSL_AARCH64) + + if (curve25519_s2n_bignum_alt_capable() == 1) { + scalarmulbase = edwards25519_scalarmulbase_alt; + madd = bignum_madd_n25519_alt; + } else if (curve25519_s2n_bignum_no_alt_capable() == 1) { + scalarmulbase = edwards25519_scalarmulbase; + madd = bignum_madd_n25519; + } else { + abort(); + } + +#else + + scalarmulbase = edwards25519_scalarmulbase; + madd = bignum_madd_n25519; + + // Should not call this function unless s2n-bignum is supported. abort(); + +#endif + + uint8_t k[SHA512_DIGEST_LENGTH] = {0}; + uint64_t R[8] = {0}; + uint64_t z[4] = {0}; + uint64_t uint64_r[8] = {0}; + uint64_t uint64_k[8] = {0}; + uint64_t uint64_s[4] = {0}; + OPENSSL_memcpy(uint64_r, r, 64); + OPENSSL_memcpy(uint64_s, s, 32); + + // Reduce r modulo the order of the base-point B. + bignum_mod_n25519(uint64_r, 8, uint64_r); + + // Compute [r]B. + scalarmulbase(R, uint64_r); + edwards25519_encode(out_sig, R); + + // Compute k = SHA512(R || A || message) + // R is of length 32 octets + ed25519_sha512(k, out_sig, 32, A, ED25519_PUBLIC_KEY_LEN, message, + message_len); + OPENSSL_memcpy(uint64_k, k, SHA512_DIGEST_LENGTH); + bignum_mod_n25519(uint64_k, 8, uint64_k); + + + // Compute S = r + k * s modulo the order of the base-point B. + // out_sig = R || S + madd(z, uint64_k, uint64_s, uint64_r); + OPENSSL_memcpy(out_sig + 32, z, 32); } static int ed25519_verify_s2n_bignum(uint8_t R_computed_encoded[32], const uint8_t public_key[32], uint8_t R_expected[32], uint8_t S[32], const uint8_t *message, size_t message_len) { + + void (*scalarmuldouble)(uint64_t res[8], uint64_t scalar[4], + uint64_t point[8], uint64_t bscalar[4]); + uint64_t (*decode)(uint64_t z[8], const uint8_t c[32]); + +#if defined(OPENSSL_X86_64) + + if (curve25519_s2n_bignum_no_alt_capable() == 1) { + scalarmuldouble = edwards25519_scalarmuldouble; + decode = edwards25519_decode; + } else if (curve25519_s2n_bignum_alt_capable() == 1) { + scalarmuldouble = edwards25519_scalarmuldouble_alt; + decode = edwards25519_decode_alt; + } else { + abort(); + } + +#elif defined(OPENSSL_AARCH64) + + if (curve25519_s2n_bignum_alt_capable() == 1) { + scalarmuldouble = edwards25519_scalarmuldouble_alt; + decode = edwards25519_decode_alt; + } else if (curve25519_s2n_bignum_no_alt_capable() == 1) { + scalarmuldouble = edwards25519_scalarmuldouble; + decode = edwards25519_decode; + } else { + abort(); + } + +#else + + scalarmuldouble = edwards25519_scalarmuldouble; + decode = edwards25519_decode; + + // Should not call this function unless s2n-bignum is supported. abort(); + +#endif + + uint8_t k[SHA512_DIGEST_LENGTH] = {0}; + uint64_t uint64_k[8] = {0}; + uint64_t uint64_R[8] = {0}; + uint64_t uint64_S[4] = {0}; + uint64_t A[8] = {0}; + + // Decode public key as A'. + if (decode(A, public_key) != 0) { + return 0; + } + + // Step: rfc8032 5.1.7.2 + // Compute k = SHA512(R_expected || public_key || message). + ed25519_sha512(k, R_expected, 32, public_key, ED25519_PUBLIC_KEY_LEN, message, + message_len); + OPENSSL_memcpy(uint64_k, k, SHA512_DIGEST_LENGTH); + bignum_mod_n25519(uint64_k, 8, uint64_k); + + // Step: rfc8032 5.1.7.3 + // Recall, we must compute [S]B - [k]A'. + // First negate A'. Point negation for the twisted edwards curve when points + // are represented in the extended coordinate system is simply: + // -(X,Y,Z,T) = (-X,Y,Z,-T). + // See "Twisted Edwards curves revisited" https://ia.cr/2008/522. + bignum_neg_p25519(A, A); + + // Compute R_have <- [S]B - [k]A'. + OPENSSL_memcpy(uint64_S, S, 32); + scalarmuldouble(uint64_R, uint64_k, A, uint64_S); + edwards25519_encode(R_computed_encoded, uint64_R); + + return 1; } void ed25519_sha512(uint8_t out[SHA512_DIGEST_LENGTH], diff --git a/crypto/fipsmodule/CMakeLists.txt b/crypto/fipsmodule/CMakeLists.txt index 003ec4c629..72ebf2ad1e 100644 --- a/crypto/fipsmodule/CMakeLists.txt +++ b/crypto/fipsmodule/CMakeLists.txt @@ -219,11 +219,27 @@ if((((ARCH STREQUAL "x86_64") AND NOT MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) OR curve25519/curve25519_x25519.S curve25519/curve25519_x25519_alt.S curve25519/curve25519_x25519base.S - curve25519/curve25519_x25519base_alt.S - ) + curve25519/curve25519_x25519base_alt.S) + + # Delocater FIPS issue: CryptoAlg-2198 + if(NOT FIPS) + list(APPEND S2N_BIGNUM_ASM_SOURCES + curve25519/bignum_mod_n25519.S + curve25519/bignum_neg_p25519.S + curve25519/bignum_madd_n25519.S + curve25519/bignum_madd_n25519_alt.S + curve25519/edwards25519_decode.S + curve25519/edwards25519_decode_alt.S + curve25519/edwards25519_encode.S + curve25519/edwards25519_scalarmulbase.S + curve25519/edwards25519_scalarmulbase_alt.S + curve25519/edwards25519_scalarmuldouble.S + curve25519/edwards25519_scalarmuldouble_alt.S + ) + endif() elseif(ARCH STREQUAL "aarch64") - # byte-level interface for aarch64 s2n-bignum curve25519 is in - # files with "byte" tags. + # byte-level interface for aarch64 s2n-bignum x25519 are in + # files with "byte" tags, but ed25519 is not, neither are they byte-level... list(APPEND S2N_BIGNUM_ASM_SOURCES curve25519/curve25519_x25519_byte.S curve25519/curve25519_x25519_byte_alt.S @@ -231,6 +247,24 @@ if((((ARCH STREQUAL "x86_64") AND NOT MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) OR curve25519/curve25519_x25519base_byte_alt.S ) + # Delocater FIPS issue: CryptoAlg-2198 + if(NOT FIPS) + list(APPEND S2N_BIGNUM_ASM_SOURCES + curve25519/bignum_mod_n25519.S + curve25519/bignum_neg_p25519.S + curve25519/bignum_madd_n25519.S + curve25519/bignum_madd_n25519_alt.S + curve25519/edwards25519_decode.S + curve25519/edwards25519_decode_alt.S + curve25519/edwards25519_encode.S + curve25519/edwards25519_scalarmulbase.S + curve25519/edwards25519_scalarmulbase_alt.S + curve25519/edwards25519_scalarmuldouble.S + curve25519/edwards25519_scalarmuldouble_alt.S + ) + endif() + + # Big integer arithmetics using s2n-bignum list(APPEND S2N_BIGNUM_ASM_SOURCES fastmul/bignum_kmul_16_32.S diff --git a/tests/ci/common_posix_setup.sh b/tests/ci/common_posix_setup.sh index 2e30378672..0687f09563 100644 --- a/tests/ci/common_posix_setup.sh +++ b/tests/ci/common_posix_setup.sh @@ -115,7 +115,7 @@ function verify_symbols_prefixed { # * "\(bignum\|curve25519_x25519\)": match string of either "bignum" or "curve25519_x25519". # Recall that the option "-v" reverse the pattern matching. So, we are really # filtering out lines that contain either "bignum" or "curve25519_x25519". - cat "$BUILD_ROOT"/symbols_final_crypto.txt "$BUILD_ROOT"/symbols_final_ssl.txt | grep -v -e '^_\?\(bignum\|curve25519_x25519\)' > "$SRC_ROOT"/symbols_final.txt + cat "$BUILD_ROOT"/symbols_final_crypto.txt "$BUILD_ROOT"/symbols_final_ssl.txt | grep -v -e '^_\?\(bignum\|curve25519_x25519\|edwards25519\)' > "$SRC_ROOT"/symbols_final.txt # Now filter out every line that has the unique prefix $CUSTOM_PREFIX. If we # have any lines left, then some symbol(s) weren't prefixed, unexpectedly. if [ $(grep -c -v ${CUSTOM_PREFIX} "$SRC_ROOT"/symbols_final.txt) -ne 0 ]; then diff --git a/third_party/s2n-bignum/include/s2n-bignum_aws-lc.h b/third_party/s2n-bignum/include/s2n-bignum_aws-lc.h index b007db3849..58b9453f4b 100644 --- a/third_party/s2n-bignum/include/s2n-bignum_aws-lc.h +++ b/third_party/s2n-bignum/include/s2n-bignum_aws-lc.h @@ -246,3 +246,81 @@ extern void bignum_copy_row_from_table_16_neon (uint64_t *z, const uint64_t *tab // Input table[height*32]; output z[32] extern void bignum_copy_row_from_table_32_neon (uint64_t *z, const uint64_t *table, uint64_t height, uint64_t idx); + +#if !defined(BORINGSSL_FIPS) +// Reduction is modulo the order of the curve25519/edwards25519 basepoint, +// which is n_25519 = 2^252 + 27742317777372353535851937790883648493. +// Reduce modulo basepoint order, z := x mod n_25519 +// Input x[k]; output z[4] +extern void bignum_mod_n25519(uint64_t z[static 4], uint64_t k, uint64_t *x); + +// Negate modulo p_25519, z := (-x) mod p_25519, assuming x reduced +// Input x[4]; output z[4] +extern void bignum_neg_p25519(uint64_t z[static 4], uint64_t x[static 4]); + +// Performs z := (x * y + c) mod n_25519, where the modulus is +// n_25519 = 2^252 + 27742317777372353535851937790883648493, the +// order of the curve25519/edwards25519 basepoint. The result z +// and the inputs x, y and c are all 4 digits (256 bits). +// Inputs x[4], y[4], c[4]; output z[4] +extern void bignum_madd_n25519(uint64_t z[static 4], uint64_t x[static 4], + uint64_t y[static 4], uint64_t c[static 4]); +extern void bignum_madd_n25519_alt(uint64_t z[static 4], uint64_t x[static 4], + uint64_t y[static 4], uint64_t c[static 4]); + +// This assumes that the input buffer p points to a pair of 256-bit +// numbers x (at p) and y (at p+4) representing a point (x,y) on the +// edwards25519 curve. It is assumed that both x and y are < p_25519 +// but there is no checking of this, nor of the fact that (x,y) is +// in fact on the curve. +// +// The output in z is a little-endian array of bytes corresponding to +// the standard compressed encoding of a point as 2^255 * x_0 + y +// where x_0 is the least significant bit of x. +// See "https://datatracker.ietf.org/doc/html/rfc8032#section-5.1.2" +// In this implementation, y is simply truncated to 255 bits, but if +// it is reduced mod p_25519 as expected this does not affect values. +extern void edwards25519_encode(uint8_t z[static 32], uint64_t p[static 8]); + +// This interprets the input byte string as a little-endian number +// representing a point (x,y) on the edwards25519 curve, encoded as +// 2^255 * x_0 + y where x_0 is the least significant bit of x. It +// returns the full pair of coordinates x (at z) and y (at z+4). The +// return code is 0 for success and 1 for failure, which means that +// the input does not correspond to the encoding of any edwards25519 +// point. This can happen for three reasons, where y = the lowest +// 255 bits of the input: +// +// * y >= p_25519 +// Input y coordinate is not reduced +// * (y^2 - 1) * (1 + d_25519 * y^2) has no modular square root +// There is no x such that (x,y) is on the curve +// * y^2 = 1 and top bit of input is set +// Cannot be the canonical encoding of (0,1) or (0,-1) +// +// Input c[32] (bytes); output function return and z[8] +extern uint64_t edwards25519_decode(uint64_t z[static 8], const uint8_t c[static 32]); +extern uint64_t edwards25519_decode_alt(uint64_t z[static 8], const uint8_t c[static 32]); + +// Given a scalar n, returns point (X,Y) = n * B where B = (...,4/5) is +// the standard basepoint for the edwards25519 (Ed25519) curve. +// Input scalar[4]; output res[8] +extern void edwards25519_scalarmulbase(uint64_t res[static 8], uint64_t scalar[static 4]); +extern void edwards25519_scalarmulbase_alt(uint64_t res[static 8], uint64_t scalar[static 4]); + +// Given scalar = n, point = P and bscalar = m, returns in res +// the point (X,Y) = n * P + m * B where B = (...,4/5) is +// the standard basepoint for the edwards25519 (Ed25519) curve. +// +// Both 256-bit coordinates of the input point P are implicitly +// reduced modulo 2^255-19 if they are not already in reduced form, +// but the conventional usage is that they *are* already reduced. +// The scalars can be arbitrary 256-bit numbers but may also be +// considered as implicitly reduced modulo the group order. +// +// Input scalar[4], point[8], bscalar[4]; output res[8] +extern void edwards25519_scalarmuldouble(uint64_t res[static 8], uint64_t scalar[static 4], + uint64_t point[static 8], uint64_t bscalar[static 4]); +extern void edwards25519_scalarmuldouble_alt(uint64_t res[static 8], uint64_t scalar[static 4], + uint64_t point[static 8], uint64_t bscalar[static 4]); +#endif diff --git a/util/fipstools/delocate/delocate.peg b/util/fipstools/delocate/delocate.peg index 1fdabf5094..8900af05cc 100644 --- a/util/fipstools/delocate/delocate.peg +++ b/util/fipstools/delocate/delocate.peg @@ -118,6 +118,7 @@ Offset <- '+'? '-'? (("0b" [01]+) / [0-9]+ ( OffsetOperator [0-9]+ OffsetOperator [0-9]+ )? / [0-9]+ ( OffsetOperator [0-9]+ )? / '(' [0-9]+ WS? OffsetOperator WS? [0-9]+ ')' OffsetOperator [0-9]+ OffsetOperator [0-9]+ / + '(' [0-9]+ WS? OffsetOperator WS? [0-9]+ ')' OffsetOperator [0-9]+ !'x' / '(' [0-9]+ WS? OffsetOperator WS? [0-9]+ ')' / '(' [0-9]+ WS? OffsetOperator WS? [0-9]+ WS? OffsetOperator WS? [0-9]+')')![[A-Z]] ) diff --git a/util/fipstools/delocate/delocate.peg.go b/util/fipstools/delocate/delocate.peg.go index 1111645d00..8a80b35661 100644 --- a/util/fipstools/delocate/delocate.peg.go +++ b/util/fipstools/delocate/delocate.peg.go @@ -1,14 +1,14 @@ package main -// Code generated by ./peg/peg delocate.peg DO NOT EDIT. +// Code generated by /home/ec2-user/go/bin/peg ./delocate.peg DO NOT EDIT. import ( - "bytes" "fmt" "io" "os" "sort" "strconv" + "strings" ) const endSymbol rune = 1114112 @@ -244,13 +244,12 @@ func (t *tokens32) Tokens() []token32 { } type Asm struct { - Buffer string - buffer []rune - rules [56]func() bool - parse func(rule ...int) error - reset func() - Pretty bool - disableMemoize bool + Buffer string + buffer []rune + rules [56]func() bool + parse func(rule ...int) error + reset func() + Pretty bool tokens32 } @@ -335,9 +334,9 @@ func (p *Asm) WriteSyntaxTree(w io.Writer) { } func (p *Asm) SprintSyntaxTree() string { - var b bytes.Buffer - p.WriteSyntaxTree(&b) - return b.String() + var bldr strings.Builder + p.WriteSyntaxTree(&bldr) + return bldr.String() } func Pretty(pretty bool) func(*Asm) error { @@ -353,30 +352,11 @@ func Size(size int) func(*Asm) error { return nil } } - -func DisableMemoize() func(*Asm) error { - return func(p *Asm) error { - p.disableMemoize = true - return nil - } -} - -type memo struct { - Matched bool - Partial []token32 -} - -type memoKey struct { - Rule uint32 - Position uint32 -} - func (p *Asm) Init(options ...func(*Asm) error) error { var ( max token32 position, tokenIndex uint32 buffer []rune - memoization map[memoKey]memo ) for _, option := range options { err := option(p) @@ -387,7 +367,7 @@ func (p *Asm) Init(options ...func(*Asm) error) error { p.reset = func() { max = token32{} position, tokenIndex = 0, 0 - memoization = make(map[memoKey]memo) + p.buffer = []rune(p.Buffer) if len(p.buffer) == 0 || p.buffer[len(p.buffer)-1] != endSymbol { p.buffer = append(p.buffer, endSymbol) @@ -420,34 +400,6 @@ func (p *Asm) Init(options ...func(*Asm) error) error { } } - memoize := func(rule uint32, begin uint32, tokenIndexStart uint32, matched bool) { - if p.disableMemoize { - return - } - key := memoKey{rule, begin} - if !matched { - memoization[key] = memo{Matched: false} - } else { - t := tree.tree[tokenIndexStart:tokenIndex] - tokenCopy := make([]token32, len(t)) - copy(tokenCopy, t) - memoization[key] = memo{Matched: true, Partial: tokenCopy} - } - } - - memoizedResult := func(m memo) bool { - if !m.Matched { - return false - } - tree.tree = append(tree.tree[:tokenIndex], m.Partial...) - tokenIndex += uint32(len(m.Partial)) - position = m.Partial[len(m.Partial)-1].end - if tree.tree[tokenIndex-1].begin != position && position > max.end { - max = tree.tree[tokenIndex-1] - } - return true - } - matchDot := func() bool { if buffer[position] != endSymbol { position++ @@ -476,9 +428,6 @@ func (p *Asm) Init(options ...func(*Asm) error) error { nil, /* 0 AsmFile <- <(Statement* !.)> */ func() bool { - if memoized, ok := memoization[memoKey{0, position}]; ok { - return memoizedResult(memoized) - } position0, tokenIndex0 := position, tokenIndex { position1 := position @@ -503,18 +452,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { } add(ruleAsmFile, position1) } - memoize(0, position0, tokenIndex0, true) return true l0: - memoize(0, position0, tokenIndex0, false) position, tokenIndex = position0, tokenIndex0 return false }, /* 1 Statement <- <(WS? (Label / ((GlobalDirective / LocationDirective / LabelContainingDirective / Instruction / Directive / Comment / ) WS? ((Comment? '\n') / ';'))))> */ func() bool { - if memoized, ok := memoization[memoKey{1, position}]; ok { - return memoizedResult(memoized) - } position5, tokenIndex5 := position, tokenIndex { position6 := position @@ -615,18 +559,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { l9: add(ruleStatement, position6) } - memoize(1, position5, tokenIndex5, true) return true l5: - memoize(1, position5, tokenIndex5, false) position, tokenIndex = position5, tokenIndex5 return false }, /* 2 GlobalDirective <- <((('.' ('g' / 'G') ('l' / 'L') ('o' / 'O') ('b' / 'B') ('a' / 'A') ('l' / 'L')) / ('.' ('g' / 'G') ('l' / 'L') ('o' / 'O') ('b' / 'B') ('l' / 'L'))) WS SymbolName)> */ func() bool { - if memoized, ok := memoization[memoKey{2, position}]; ok { - return memoizedResult(memoized) - } position24, tokenIndex24 := position, tokenIndex { position25 := position @@ -818,18 +757,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { } add(ruleGlobalDirective, position25) } - memoize(2, position24, tokenIndex24, true) return true l24: - memoize(2, position24, tokenIndex24, false) position, tokenIndex = position24, tokenIndex24 return false }, /* 3 Directive <- <('.' DirectiveName (WS Args)?)> */ func() bool { - if memoized, ok := memoization[memoKey{3, position}]; ok { - return memoizedResult(memoized) - } position50, tokenIndex50 := position, tokenIndex { position51 := position @@ -855,18 +789,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { l53: add(ruleDirective, position51) } - memoize(3, position50, tokenIndex50, true) return true l50: - memoize(3, position50, tokenIndex50, false) position, tokenIndex = position50, tokenIndex50 return false }, /* 4 DirectiveName <- <([a-z] / [A-Z] / ([0-9] / [0-9]) / '_')+> */ func() bool { - if memoized, ok := memoization[memoKey{4, position}]; ok { - return memoizedResult(memoized) - } position54, tokenIndex54 := position, tokenIndex { position55 := position @@ -959,18 +888,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { } add(ruleDirectiveName, position55) } - memoize(4, position54, tokenIndex54, true) return true l54: - memoize(4, position54, tokenIndex54, false) position, tokenIndex = position54, tokenIndex54 return false }, /* 5 LocationDirective <- <(FileDirective / LocDirective)> */ func() bool { - if memoized, ok := memoization[memoKey{5, position}]; ok { - return memoizedResult(memoized) - } position70, tokenIndex70 := position, tokenIndex { position71 := position @@ -989,18 +913,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { l72: add(ruleLocationDirective, position71) } - memoize(5, position70, tokenIndex70, true) return true l70: - memoize(5, position70, tokenIndex70, false) position, tokenIndex = position70, tokenIndex70 return false }, /* 6 FileDirective <- <('.' ('f' / 'F') ('i' / 'I') ('l' / 'L') ('e' / 'E') WS (!('#' / '\n') .)+)> */ func() bool { - if memoized, ok := memoization[memoKey{6, position}]; ok { - return memoizedResult(memoized) - } position74, tokenIndex74 := position, tokenIndex { position75 := position @@ -1128,18 +1047,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { } add(ruleFileDirective, position75) } - memoize(6, position74, tokenIndex74, true) return true l74: - memoize(6, position74, tokenIndex74, false) position, tokenIndex = position74, tokenIndex74 return false }, /* 7 LocDirective <- <('.' ('l' / 'L') ('o' / 'O') ('c' / 'C') WS (!('#' / '/' / '\n') .)+)> */ func() bool { - if memoized, ok := memoization[memoKey{7, position}]; ok { - return memoizedResult(memoized) - } position92, tokenIndex92 := position, tokenIndex { position93 := position @@ -1266,18 +1180,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { } add(ruleLocDirective, position93) } - memoize(7, position92, tokenIndex92, true) return true l92: - memoize(7, position92, tokenIndex92, false) position, tokenIndex = position92, tokenIndex92 return false }, /* 8 Args <- <(Arg (WS? ',' WS? Arg)*)> */ func() bool { - if memoized, ok := memoization[memoKey{8, position}]; ok { - return memoizedResult(memoized) - } position110, tokenIndex110 := position, tokenIndex { position111 := position @@ -1320,19 +1229,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { } add(ruleArgs, position111) } - memoize(8, position110, tokenIndex110, true) return true l110: - memoize(8, position110, tokenIndex110, false) position, tokenIndex = position110, tokenIndex110 return false }, /* 9 Arg <- <(QuotedArg / ([0-9] / [0-9] / ([a-z] / [A-Z]) / '%' / '+' / '-' / '*' / '_' / '@' / '.')*)> */ func() bool { - if memoized, ok := memoization[memoKey{9, position}]; ok { - return memoizedResult(memoized) - } - position118, tokenIndex118 := position, tokenIndex { position119 := position { @@ -1436,14 +1339,10 @@ func (p *Asm) Init(options ...func(*Asm) error) error { l120: add(ruleArg, position119) } - memoize(9, position118, tokenIndex118, true) return true }, /* 10 QuotedArg <- <('"' QuotedText '"')> */ func() bool { - if memoized, ok := memoization[memoKey{10, position}]; ok { - return memoizedResult(memoized) - } position136, tokenIndex136 := position, tokenIndex { position137 := position @@ -1460,19 +1359,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { position++ add(ruleQuotedArg, position137) } - memoize(10, position136, tokenIndex136, true) return true l136: - memoize(10, position136, tokenIndex136, false) position, tokenIndex = position136, tokenIndex136 return false }, /* 11 QuotedText <- <(EscapedChar / (!'"' .))*> */ func() bool { - if memoized, ok := memoization[memoKey{11, position}]; ok { - return memoizedResult(memoized) - } - position138, tokenIndex138 := position, tokenIndex { position139 := position l140: @@ -1507,14 +1400,10 @@ func (p *Asm) Init(options ...func(*Asm) error) error { } add(ruleQuotedText, position139) } - memoize(11, position138, tokenIndex138, true) return true }, /* 12 LabelContainingDirective <- <(LabelContainingDirectiveName WS SymbolArgs)> */ func() bool { - if memoized, ok := memoization[memoKey{12, position}]; ok { - return memoizedResult(memoized) - } position145, tokenIndex145 := position, tokenIndex { position146 := position @@ -1529,18 +1418,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { } add(ruleLabelContainingDirective, position146) } - memoize(12, position145, tokenIndex145, true) return true l145: - memoize(12, position145, tokenIndex145, false) position, tokenIndex = position145, tokenIndex145 return false }, /* 13 LabelContainingDirectiveName <- <(('.' ('x' / 'X') ('w' / 'W') ('o' / 'O') ('r' / 'R') ('d' / 'D')) / ('.' ('w' / 'W') ('o' / 'O') ('r' / 'R') ('d' / 'D')) / ('.' ('l' / 'L') ('o' / 'O') ('n' / 'N') ('g' / 'G')) / ('.' ('s' / 'S') ('e' / 'E') ('t' / 'T')) / ('.' ('b' / 'B') ('y' / 'Y') ('t' / 'T') ('e' / 'E')) / ('.' '8' ('b' / 'B') ('y' / 'Y') ('t' / 'T') ('e' / 'E')) / ('.' '4' ('b' / 'B') ('y' / 'Y') ('t' / 'T') ('e' / 'E')) / ('.' ('q' / 'Q') ('u' / 'U') ('a' / 'A') ('d' / 'D')) / ('.' ('t' / 'T') ('c' / 'C')) / ('.' ('l' / 'L') ('o' / 'O') ('c' / 'C') ('a' / 'A') ('l' / 'L') ('e' / 'E') ('n' / 'N') ('t' / 'T') ('r' / 'R') ('y' / 'Y')) / ('.' ('s' / 'S') ('i' / 'I') ('z' / 'Z') ('e' / 'E')) / ('.' ('t' / 'T') ('y' / 'Y') ('p' / 'P') ('e' / 'E')) / ('.' ('u' / 'U') ('l' / 'L') ('e' / 'E') ('b' / 'B') '1' '2' '8') / ('.' ('s' / 'S') ('l' / 'L') ('e' / 'E') ('b' / 'B') '1' '2' '8'))> */ func() bool { - if memoized, ok := memoization[memoKey{13, position}]; ok { - return memoizedResult(memoized) - } position147, tokenIndex147 := position, tokenIndex { position148 := position @@ -2577,18 +2461,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { l149: add(ruleLabelContainingDirectiveName, position148) } - memoize(13, position147, tokenIndex147, true) return true l147: - memoize(13, position147, tokenIndex147, false) position, tokenIndex = position147, tokenIndex147 return false }, /* 14 SymbolArgs <- <(SymbolArg (WS? ',' WS? SymbolArg)*)> */ func() bool { - if memoized, ok := memoization[memoKey{14, position}]; ok { - return memoizedResult(memoized) - } position283, tokenIndex283 := position, tokenIndex { position284 := position @@ -2631,18 +2510,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { } add(ruleSymbolArgs, position284) } - memoize(14, position283, tokenIndex283, true) return true l283: - memoize(14, position283, tokenIndex283, false) position, tokenIndex = position283, tokenIndex283 return false }, /* 15 SymbolShift <- <((('<' '<') / ('>' '>')) WS? [0-9]+)> */ func() bool { - if memoized, ok := memoization[memoKey{15, position}]; ok { - return memoizedResult(memoized) - } position291, tokenIndex291 := position, tokenIndex { position292 := position @@ -2696,18 +2570,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { } add(ruleSymbolShift, position292) } - memoize(15, position291, tokenIndex291, true) return true l291: - memoize(15, position291, tokenIndex291, false) position, tokenIndex = position291, tokenIndex291 return false }, /* 16 SymbolArg <- <((OpenParen WS?)? (Offset / SymbolType / ((Offset / LocalSymbol / SymbolName / Dot) (WS? Operator WS? (Offset / LocalSymbol / SymbolName))*) / (LocalLabelRef WS? Operator WS? LocalLabelRef) / (LocalSymbol TCMarker?) / (SymbolName Offset) / (SymbolName TCMarker?)) (WS? CloseParen)? (WS? SymbolShift)?)> */ func() bool { - if memoized, ok := memoization[memoKey{16, position}]; ok { - return memoizedResult(memoized) - } position299, tokenIndex299 := position, tokenIndex { position300 := position @@ -2936,18 +2805,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { l338: add(ruleSymbolArg, position300) } - memoize(16, position299, tokenIndex299, true) return true l299: - memoize(16, position299, tokenIndex299, false) position, tokenIndex = position299, tokenIndex299 return false }, /* 17 OpenParen <- <'('> */ func() bool { - if memoized, ok := memoization[memoKey{17, position}]; ok { - return memoizedResult(memoized) - } position341, tokenIndex341 := position, tokenIndex { position342 := position @@ -2957,18 +2821,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { position++ add(ruleOpenParen, position342) } - memoize(17, position341, tokenIndex341, true) return true l341: - memoize(17, position341, tokenIndex341, false) position, tokenIndex = position341, tokenIndex341 return false }, /* 18 CloseParen <- <')'> */ func() bool { - if memoized, ok := memoization[memoKey{18, position}]; ok { - return memoizedResult(memoized) - } position343, tokenIndex343 := position, tokenIndex { position344 := position @@ -2978,18 +2837,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { position++ add(ruleCloseParen, position344) } - memoize(18, position343, tokenIndex343, true) return true l343: - memoize(18, position343, tokenIndex343, false) position, tokenIndex = position343, tokenIndex343 return false }, /* 19 SymbolType <- <(('@' / '%') (('f' 'u' 'n' 'c' 't' 'i' 'o' 'n') / ('o' 'b' 'j' 'e' 'c' 't')))> */ func() bool { - if memoized, ok := memoization[memoKey{19, position}]; ok { - return memoizedResult(memoized) - } position345, tokenIndex345 := position, tokenIndex { position346 := position @@ -3073,18 +2927,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { l349: add(ruleSymbolType, position346) } - memoize(19, position345, tokenIndex345, true) return true l345: - memoize(19, position345, tokenIndex345, false) position, tokenIndex = position345, tokenIndex345 return false }, /* 20 Dot <- <'.'> */ func() bool { - if memoized, ok := memoization[memoKey{20, position}]; ok { - return memoizedResult(memoized) - } position351, tokenIndex351 := position, tokenIndex { position352 := position @@ -3094,18 +2943,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { position++ add(ruleDot, position352) } - memoize(20, position351, tokenIndex351, true) return true l351: - memoize(20, position351, tokenIndex351, false) position, tokenIndex = position351, tokenIndex351 return false }, /* 21 TCMarker <- <('[' 'T' 'C' ']')> */ func() bool { - if memoized, ok := memoization[memoKey{21, position}]; ok { - return memoizedResult(memoized) - } position353, tokenIndex353 := position, tokenIndex { position354 := position @@ -3127,18 +2971,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { position++ add(ruleTCMarker, position354) } - memoize(21, position353, tokenIndex353, true) return true l353: - memoize(21, position353, tokenIndex353, false) position, tokenIndex = position353, tokenIndex353 return false }, /* 22 EscapedChar <- <('\\' .)> */ func() bool { - if memoized, ok := memoization[memoKey{22, position}]; ok { - return memoizedResult(memoized) - } position355, tokenIndex355 := position, tokenIndex { position356 := position @@ -3151,18 +2990,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { } add(ruleEscapedChar, position356) } - memoize(22, position355, tokenIndex355, true) return true l355: - memoize(22, position355, tokenIndex355, false) position, tokenIndex = position355, tokenIndex355 return false }, /* 23 WS <- <(' ' / '\t')+> */ func() bool { - if memoized, ok := memoization[memoKey{23, position}]; ok { - return memoizedResult(memoized) - } position357, tokenIndex357 := position, tokenIndex { position358 := position @@ -3205,18 +3039,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { } add(ruleWS, position358) } - memoize(23, position357, tokenIndex357, true) return true l357: - memoize(23, position357, tokenIndex357, false) position, tokenIndex = position357, tokenIndex357 return false }, /* 24 Comment <- <((('/' '/') / '#') (!'\n' .)*)> */ func() bool { - if memoized, ok := memoization[memoKey{24, position}]; ok { - return memoizedResult(memoized) - } position365, tokenIndex365 := position, tokenIndex { position366 := position @@ -3261,18 +3090,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { } add(ruleComment, position366) } - memoize(24, position365, tokenIndex365, true) return true l365: - memoize(24, position365, tokenIndex365, false) position, tokenIndex = position365, tokenIndex365 return false }, /* 25 Label <- <((LocalSymbol / LocalLabel / SymbolName) ':')> */ func() bool { - if memoized, ok := memoization[memoKey{25, position}]; ok { - return memoizedResult(memoized) - } position372, tokenIndex372 := position, tokenIndex { position373 := position @@ -3301,18 +3125,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { position++ add(ruleLabel, position373) } - memoize(25, position372, tokenIndex372, true) return true l372: - memoize(25, position372, tokenIndex372, false) position, tokenIndex = position372, tokenIndex372 return false }, /* 26 SymbolName <- <(([a-z] / [A-Z] / '.' / '_') ([a-z] / [A-Z] / '.' / ([0-9] / [0-9]) / '$' / '_')*)> */ func() bool { - if memoized, ok := memoization[memoKey{26, position}]; ok { - return memoizedResult(memoized) - } position377, tokenIndex377 := position, tokenIndex { position378 := position @@ -3408,18 +3227,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { } add(ruleSymbolName, position378) } - memoize(26, position377, tokenIndex377, true) return true l377: - memoize(26, position377, tokenIndex377, false) position, tokenIndex = position377, tokenIndex377 return false }, /* 27 LocalSymbol <- <('.' 'L' ([a-z] / [A-Z] / ([a-z] / [A-Z]) / '.' / ([0-9] / [0-9]) / '$' / '_')+)> */ func() bool { - if memoized, ok := memoization[memoKey{27, position}]; ok { - return memoizedResult(memoized) - } position393, tokenIndex393 := position, tokenIndex { position394 := position @@ -3584,18 +3398,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { } add(ruleLocalSymbol, position394) } - memoize(27, position393, tokenIndex393, true) return true l393: - memoize(27, position393, tokenIndex393, false) position, tokenIndex = position393, tokenIndex393 return false }, /* 28 LocalLabel <- <([0-9] ([0-9] / '$')*)> */ func() bool { - if memoized, ok := memoization[memoKey{28, position}]; ok { - return memoizedResult(memoized) - } position419, tokenIndex419 := position, tokenIndex { position420 := position @@ -3627,18 +3436,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { } add(ruleLocalLabel, position420) } - memoize(28, position419, tokenIndex419, true) return true l419: - memoize(28, position419, tokenIndex419, false) position, tokenIndex = position419, tokenIndex419 return false }, /* 29 LocalLabelRef <- <([0-9] ([0-9] / '$')* ('b' / 'f'))> */ func() bool { - if memoized, ok := memoization[memoKey{29, position}]; ok { - return memoizedResult(memoized) - } position425, tokenIndex425 := position, tokenIndex { position426 := position @@ -3685,18 +3489,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { l431: add(ruleLocalLabelRef, position426) } - memoize(29, position425, tokenIndex425, true) return true l425: - memoize(29, position425, tokenIndex425, false) position, tokenIndex = position425, tokenIndex425 return false }, /* 30 Instruction <- <(InstructionName (WS InstructionArg (WS? ','? WS? InstructionArg)*)?)> */ func() bool { - if memoized, ok := memoization[memoKey{30, position}]; ok { - return memoizedResult(memoized) - } position433, tokenIndex433 := position, tokenIndex { position434 := position @@ -3759,18 +3558,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { l436: add(ruleInstruction, position434) } - memoize(30, position433, tokenIndex433, true) return true l433: - memoize(30, position433, tokenIndex433, false) position, tokenIndex = position433, tokenIndex433 return false }, /* 31 InstructionName <- <(([a-z] / [A-Z]) ([a-z] / [A-Z] / '.' / ([0-9] / [0-9]))* ('.' / '+' / '-')?)> */ func() bool { - if memoized, ok := memoization[memoKey{31, position}]; ok { - return memoizedResult(memoized) - } position445, tokenIndex445 := position, tokenIndex { position446 := position @@ -3867,18 +3661,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { l458: add(ruleInstructionName, position446) } - memoize(31, position445, tokenIndex445, true) return true l445: - memoize(31, position445, tokenIndex445, false) position, tokenIndex = position445, tokenIndex445 return false }, /* 32 InstructionArg <- <(IndirectionIndicator? (ARMConstantTweak / RegisterOrConstant / LocalLabelRef / TOCRefHigh / TOCRefLow / GOTLocation / GOTSymbolOffset / MemoryRef) AVX512Token*)> */ func() bool { - if memoized, ok := memoization[memoKey{32, position}]; ok { - return memoizedResult(memoized) - } position462, tokenIndex462 := position, tokenIndex { position463 := position @@ -3953,18 +3742,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { } add(ruleInstructionArg, position463) } - memoize(32, position462, tokenIndex462, true) return true l462: - memoize(32, position462, tokenIndex462, false) position, tokenIndex = position462, tokenIndex462 return false }, /* 33 GOTLocation <- <('$' '_' 'G' 'L' 'O' 'B' 'A' 'L' '_' 'O' 'F' 'F' 'S' 'E' 'T' '_' 'T' 'A' 'B' 'L' 'E' '_' '-' LocalSymbol)> */ func() bool { - if memoized, ok := memoization[memoKey{33, position}]; ok { - return memoizedResult(memoized) - } position476, tokenIndex476 := position, tokenIndex { position477 := position @@ -4065,18 +3849,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { } add(ruleGOTLocation, position477) } - memoize(33, position476, tokenIndex476, true) return true l476: - memoize(33, position476, tokenIndex476, false) position, tokenIndex = position476, tokenIndex476 return false }, /* 34 GOTSymbolOffset <- <(('$' SymbolName ('@' 'G' 'O' 'T') ('O' 'F' 'F')?) / (':' ('g' / 'G') ('o' / 'O') ('t' / 'T') ':' SymbolName))> */ func() bool { - if memoized, ok := memoization[memoKey{34, position}]; ok { - return memoizedResult(memoized) - } position478, tokenIndex478 := position, tokenIndex { position479 := position @@ -4187,18 +3966,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { l480: add(ruleGOTSymbolOffset, position479) } - memoize(34, position478, tokenIndex478, true) return true l478: - memoize(34, position478, tokenIndex478, false) position, tokenIndex = position478, tokenIndex478 return false }, /* 35 AVX512Token <- <(WS? '{' '%'? ([0-9] / [a-z])* '}')> */ func() bool { - if memoized, ok := memoization[memoKey{35, position}]; ok { - return memoizedResult(memoized) - } position490, tokenIndex490 := position, tokenIndex { position491 := position @@ -4255,18 +4029,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { position++ add(ruleAVX512Token, position491) } - memoize(35, position490, tokenIndex490, true) return true l490: - memoize(35, position490, tokenIndex490, false) position, tokenIndex = position490, tokenIndex490 return false }, /* 36 TOCRefHigh <- <('.' 'T' 'O' 'C' '.' '-' (('0' 'b') / ('.' 'L' ([a-z] / [A-Z] / '_' / [0-9])+)) ('@' ('h' / 'H') ('a' / 'A')))> */ func() bool { - if memoized, ok := memoization[memoKey{36, position}]; ok { - return memoizedResult(memoized) - } position500, tokenIndex500 := position, tokenIndex { position501 := position @@ -4418,18 +4187,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { l516: add(ruleTOCRefHigh, position501) } - memoize(36, position500, tokenIndex500, true) return true l500: - memoize(36, position500, tokenIndex500, false) position, tokenIndex = position500, tokenIndex500 return false }, /* 37 TOCRefLow <- <('.' 'T' 'O' 'C' '.' '-' (('0' 'b') / ('.' 'L' ([a-z] / [A-Z] / '_' / [0-9])+)) ('@' ('l' / 'L')))> */ func() bool { - if memoized, ok := memoization[memoKey{37, position}]; ok { - return memoizedResult(memoized) - } position518, tokenIndex518 := position, tokenIndex { position519 := position @@ -4566,18 +4330,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { l532: add(ruleTOCRefLow, position519) } - memoize(37, position518, tokenIndex518, true) return true l518: - memoize(37, position518, tokenIndex518, false) position, tokenIndex = position518, tokenIndex518 return false }, /* 38 IndirectionIndicator <- <'*'> */ func() bool { - if memoized, ok := memoization[memoKey{38, position}]; ok { - return memoizedResult(memoized) - } position534, tokenIndex534 := position, tokenIndex { position535 := position @@ -4587,18 +4346,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { position++ add(ruleIndirectionIndicator, position535) } - memoize(38, position534, tokenIndex534, true) return true l534: - memoize(38, position534, tokenIndex534, false) position, tokenIndex = position534, tokenIndex534 return false }, /* 39 RegisterOrConstant <- <((('%' ([a-z] / [A-Z]) ([a-z] / [A-Z] / ([0-9] / [0-9]))*) / ('$' [0-9]+ WS? '*' WS? '(' [0-9]+ WS? '-' WS? [0-9]+ ')') / ('$'? ((Offset Offset) / Offset)) / ('#' Offset ('*' [0-9]+ ('-' [0-9] [0-9]*)?)?) / ('#' '~'? '(' [0-9] WS? ('<' '<') WS? [0-9] [0-9]? ')') / (('#' / '$') '~'? ('0' 'x')? ([0-9] / [0-9] / ([a-f] / [A-F]))+) / ('$' '(' '-' [0-9]+ ')') / ARMRegister) !('f' / 'b' / ':' / '(' / '+' / '-'))> */ func() bool { - if memoized, ok := memoization[memoKey{39, position}]; ok { - return memoizedResult(memoized) - } position536, tokenIndex536 := position, tokenIndex { position537 := position @@ -5146,18 +4900,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { } add(ruleRegisterOrConstant, position537) } - memoize(39, position536, tokenIndex536, true) return true l536: - memoize(39, position536, tokenIndex536, false) position, tokenIndex = position536, tokenIndex536 return false }, /* 40 ARMConstantTweak <- <(((('u' / 's') (('x' / 'X') ('t' / 'T')) ('x' / 'w' / 'h' / 'b')) / (('l' / 'L') ('s' / 'S') ('l' / 'L')) / (('l' / 'L') ('s' / 'S') ('r' / 'R')) / (('r' / 'R') ('o' / 'O') ('r' / 'R')) / (('a' / 'A') ('s' / 'S') ('r' / 'R'))) (WS '#'? Offset)?)> */ func() bool { - if memoized, ok := memoization[memoKey{40, position}]; ok { - return memoizedResult(memoized) - } position616, tokenIndex616 := position, tokenIndex { position617 := position @@ -5457,18 +5206,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { l658: add(ruleARMConstantTweak, position617) } - memoize(40, position616, tokenIndex616, true) return true l616: - memoize(40, position616, tokenIndex616, false) position, tokenIndex = position616, tokenIndex616 return false }, /* 41 ARMRegister <- <((('s' / 'S') ('p' / 'P')) / (('x' / 'w' / 'd' / 'q' / 's' / 'h' / 'b') [0-9] [0-9]?) / (('x' / 'X') ('z' / 'Z') ('r' / 'R')) / (('w' / 'W') ('z' / 'Z') ('r' / 'R')) / (('n' / 'N') ('z' / 'Z') ('c' / 'C') ('v' / 'V')) / ARMVectorRegister / ('{' WS? ARMVectorRegister WS? ((',' / '-') WS? ARMVectorRegister)* WS? '}' ('[' [0-9] [0-9]? ']')?))> */ func() bool { - if memoized, ok := memoization[memoKey{41, position}]; ok { - return memoizedResult(memoized) - } position661, tokenIndex661 := position, tokenIndex { position662 := position @@ -5850,18 +5594,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { l663: add(ruleARMRegister, position662) } - memoize(41, position661, tokenIndex661, true) return true l661: - memoize(41, position661, tokenIndex661, false) position, tokenIndex = position661, tokenIndex661 return false }, /* 42 ARMVectorRegister <- <(('v' / 'V') [0-9] [0-9]? ('.' [0-9]* ('b' / 's' / 'd' / 'h' / 'q') ('[' [0-9] [0-9]? ']')?)?)> */ func() bool { - if memoized, ok := memoization[memoKey{42, position}]; ok { - return memoizedResult(memoized) - } position719, tokenIndex719 := position, tokenIndex { position720 := position @@ -5985,18 +5724,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { l726: add(ruleARMVectorRegister, position720) } - memoize(42, position719, tokenIndex719, true) return true l719: - memoize(42, position719, tokenIndex719, false) position, tokenIndex = position719, tokenIndex719 return false }, /* 43 MemoryRef <- <((SymbolRef BaseIndexScale) / SymbolRef / Low12BitsSymbolRef / (Offset* BaseIndexScale) / (SegmentRegister Offset BaseIndexScale) / (SegmentRegister BaseIndexScale) / (SegmentRegister Offset) / ARMBaseIndexScale / BaseIndexScale)> */ func() bool { - if memoized, ok := memoization[memoKey{43, position}]; ok { - return memoizedResult(memoized) - } position738, tokenIndex738 := position, tokenIndex { position739 := position @@ -6082,18 +5816,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { l740: add(ruleMemoryRef, position739) } - memoize(43, position738, tokenIndex738, true) return true l738: - memoize(43, position738, tokenIndex738, false) position, tokenIndex = position738, tokenIndex738 return false }, /* 44 SymbolRef <- <((Offset* '+')? (LocalSymbol / SymbolName) Offset* ('@' Section Offset*)?)> */ func() bool { - if memoized, ok := memoization[memoKey{44, position}]; ok { - return memoizedResult(memoized) - } position751, tokenIndex751 := position, tokenIndex { position752 := position @@ -6167,18 +5896,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { l762: add(ruleSymbolRef, position752) } - memoize(44, position751, tokenIndex751, true) return true l751: - memoize(44, position751, tokenIndex751, false) position, tokenIndex = position751, tokenIndex751 return false }, /* 45 Low12BitsSymbolRef <- <(':' ('l' / 'L') ('o' / 'O') '1' '2' ':' (LocalSymbol / SymbolName) Offset?)> */ func() bool { - if memoized, ok := memoization[memoKey{45, position}]; ok { - return memoizedResult(memoized) - } position765, tokenIndex765 := position, tokenIndex { position766 := position @@ -6253,18 +5977,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { l774: add(ruleLow12BitsSymbolRef, position766) } - memoize(45, position765, tokenIndex765, true) return true l765: - memoize(45, position765, tokenIndex765, false) position, tokenIndex = position765, tokenIndex765 return false }, /* 46 ARMBaseIndexScale <- <('[' ARMRegister (',' WS? (('#'? Offset (('*' [0-9]+) / ('*' '(' [0-9]+ Operator [0-9]+ ')') / ('+' [0-9]+)*)?) / ('#'? ARMGOTLow12) / ('#'? Low12BitsSymbolRef) / ARMRegister) (',' WS? ARMConstantTweak)?)? ']' ARMPostincrement?)> */ func() bool { - if memoized, ok := memoization[memoKey{46, position}]; ok { - return memoizedResult(memoized) - } position775, tokenIndex775 := position, tokenIndex { position776 := position @@ -6501,18 +6220,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { l811: add(ruleARMBaseIndexScale, position776) } - memoize(46, position775, tokenIndex775, true) return true l775: - memoize(46, position775, tokenIndex775, false) position, tokenIndex = position775, tokenIndex775 return false }, /* 47 ARMGOTLow12 <- <(':' ('g' / 'G') ('o' / 'O') ('t' / 'T') '_' ('l' / 'L') ('o' / 'O') '1' '2' ':' SymbolName)> */ func() bool { - if memoized, ok := memoization[memoKey{47, position}]; ok { - return memoizedResult(memoized) - } position812, tokenIndex812 := position, tokenIndex { position813 := position @@ -6616,18 +6330,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { } add(ruleARMGOTLow12, position813) } - memoize(47, position812, tokenIndex812, true) return true l812: - memoize(47, position812, tokenIndex812, false) position, tokenIndex = position812, tokenIndex812 return false }, /* 48 ARMPostincrement <- <'!'> */ func() bool { - if memoized, ok := memoization[memoKey{48, position}]; ok { - return memoizedResult(memoized) - } position824, tokenIndex824 := position, tokenIndex { position825 := position @@ -6637,18 +6346,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { position++ add(ruleARMPostincrement, position825) } - memoize(48, position824, tokenIndex824, true) return true l824: - memoize(48, position824, tokenIndex824, false) position, tokenIndex = position824, tokenIndex824 return false }, /* 49 BaseIndexScale <- <('(' RegisterOrConstant? WS? (',' WS? RegisterOrConstant WS? (',' [0-9]+)?)? ')')> */ func() bool { - if memoized, ok := memoization[memoKey{49, position}]; ok { - return memoizedResult(memoized) - } position826, tokenIndex826 := position, tokenIndex { position827 := position @@ -6742,18 +6446,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { position++ add(ruleBaseIndexScale, position827) } - memoize(49, position826, tokenIndex826, true) return true l826: - memoize(49, position826, tokenIndex826, false) position, tokenIndex = position826, tokenIndex826 return false }, /* 50 Operator <- <('+' / '-')> */ func() bool { - if memoized, ok := memoization[memoKey{50, position}]; ok { - return memoizedResult(memoized) - } position842, tokenIndex842 := position, tokenIndex { position843 := position @@ -6774,18 +6473,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { l844: add(ruleOperator, position843) } - memoize(50, position842, tokenIndex842, true) return true l842: - memoize(50, position842, tokenIndex842, false) position, tokenIndex = position842, tokenIndex842 return false }, /* 51 OffsetOperator <- <('+' / '-' / '*')> */ func() bool { - if memoized, ok := memoization[memoKey{51, position}]; ok { - return memoizedResult(memoized) - } position846, tokenIndex846 := position, tokenIndex { position847 := position @@ -6813,18 +6507,13 @@ func (p *Asm) Init(options ...func(*Asm) error) error { l848: add(ruleOffsetOperator, position847) } - memoize(51, position846, tokenIndex846, true) return true l846: - memoize(51, position846, tokenIndex846, false) position, tokenIndex = position846, tokenIndex846 return false }, - /* 52 Offset <- <('+'? '-'? (('0' ('b' / 'B') ('0' / '1')+) / ('0' ('x' / 'X') ([0-9] / [0-9] / ([a-f] / [A-F]))+) / ((([0-9]+ WS OffsetOperator [0-9]+) / ([0-9]+ (OffsetOperator '(' [0-9]+ OffsetOperator [0-9]+ ')')?) / ([0-9]+ (OffsetOperator [0-9]+ OffsetOperator [0-9]+)?) / ([0-9]+ (OffsetOperator [0-9]+)?) / ('(' [0-9]+ WS? OffsetOperator WS? [0-9]+ ')' OffsetOperator [0-9]+ OffsetOperator [0-9]+) / ('(' [0-9]+ WS? OffsetOperator WS? [0-9]+ ')') / ('(' [0-9]+ WS? OffsetOperator WS? [0-9]+ WS? OffsetOperator WS? [0-9]+ ')')) !([a-z] / [A-Z]))))> */ + /* 52 Offset <- <('+'? '-'? (('0' ('b' / 'B') ('0' / '1')+) / ('0' ('x' / 'X') ([0-9] / [0-9] / ([a-f] / [A-F]))+) / ((([0-9]+ WS OffsetOperator [0-9]+) / ([0-9]+ (OffsetOperator '(' [0-9]+ OffsetOperator [0-9]+ ')')?) / ([0-9]+ (OffsetOperator [0-9]+ OffsetOperator [0-9]+)?) / ([0-9]+ (OffsetOperator [0-9]+)?) / ('(' [0-9]+ WS? OffsetOperator WS? [0-9]+ ')' OffsetOperator [0-9]+ OffsetOperator [0-9]+) / ('(' [0-9]+ WS? OffsetOperator WS? [0-9]+ ')' OffsetOperator [0-9]+ !'x') / ('(' [0-9]+ WS? OffsetOperator WS? [0-9]+ ')') / ('(' [0-9]+ WS? OffsetOperator WS? [0-9]+ WS? OffsetOperator WS? [0-9]+ ')')) !([a-z] / [A-Z]))))> */ func() bool { - if memoized, ok := memoization[memoKey{52, position}]; ok { - return memoizedResult(memoized) - } position851, tokenIndex851 := position, tokenIndex { position852 := position @@ -7381,15 +7070,11 @@ func (p *Asm) Init(options ...func(*Asm) error) error { goto l926 } position++ - goto l882 - l926: - position, tokenIndex = position882, tokenIndex882 - if buffer[position] != rune('(') { - goto l851 + if !_rules[ruleOffsetOperator]() { + goto l926 } - position++ if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l851 + goto l926 } position++ l935: @@ -7405,41 +7090,48 @@ func (p *Asm) Init(options ...func(*Asm) error) error { } { position937, tokenIndex937 := position, tokenIndex - if !_rules[ruleWS]() { + if buffer[position] != rune('x') { goto l937 } - goto l938 + position++ + goto l926 l937: position, tokenIndex = position937, tokenIndex937 } - l938: - if !_rules[ruleOffsetOperator]() { - goto l851 - } - { - position939, tokenIndex939 := position, tokenIndex - if !_rules[ruleWS]() { - goto l939 - } - goto l940 - l939: - position, tokenIndex = position939, tokenIndex939 + goto l882 + l926: + position, tokenIndex = position882, tokenIndex882 + if buffer[position] != rune('(') { + goto l938 } - l940: + position++ if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l851 + goto l938 } position++ - l941: + l939: { - position942, tokenIndex942 := position, tokenIndex + position940, tokenIndex940 := position, tokenIndex if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l942 + goto l940 } position++ - goto l941 - l942: - position, tokenIndex = position942, tokenIndex942 + goto l939 + l940: + position, tokenIndex = position940, tokenIndex940 + } + { + position941, tokenIndex941 := position, tokenIndex + if !_rules[ruleWS]() { + goto l941 + } + goto l942 + l941: + position, tokenIndex = position941, tokenIndex941 + } + l942: + if !_rules[ruleOffsetOperator]() { + goto l938 } { position943, tokenIndex943 := position, tokenIndex @@ -7451,19 +7143,32 @@ func (p *Asm) Init(options ...func(*Asm) error) error { position, tokenIndex = position943, tokenIndex943 } l944: - if !_rules[ruleOffsetOperator]() { - goto l851 + if c := buffer[position]; c < rune('0') || c > rune('9') { + goto l938 } + position++ + l945: { - position945, tokenIndex945 := position, tokenIndex - if !_rules[ruleWS]() { - goto l945 + position946, tokenIndex946 := position, tokenIndex + if c := buffer[position]; c < rune('0') || c > rune('9') { + goto l946 } - goto l946 - l945: - position, tokenIndex = position945, tokenIndex945 + position++ + goto l945 + l946: + position, tokenIndex = position946, tokenIndex946 + } + if buffer[position] != rune(')') { + goto l938 } - l946: + position++ + goto l882 + l938: + position, tokenIndex = position882, tokenIndex882 + if buffer[position] != rune('(') { + goto l851 + } + position++ if c := buffer[position]; c < rune('0') || c > rune('9') { goto l851 } @@ -7479,6 +7184,82 @@ func (p *Asm) Init(options ...func(*Asm) error) error { l948: position, tokenIndex = position948, tokenIndex948 } + { + position949, tokenIndex949 := position, tokenIndex + if !_rules[ruleWS]() { + goto l949 + } + goto l950 + l949: + position, tokenIndex = position949, tokenIndex949 + } + l950: + if !_rules[ruleOffsetOperator]() { + goto l851 + } + { + position951, tokenIndex951 := position, tokenIndex + if !_rules[ruleWS]() { + goto l951 + } + goto l952 + l951: + position, tokenIndex = position951, tokenIndex951 + } + l952: + if c := buffer[position]; c < rune('0') || c > rune('9') { + goto l851 + } + position++ + l953: + { + position954, tokenIndex954 := position, tokenIndex + if c := buffer[position]; c < rune('0') || c > rune('9') { + goto l954 + } + position++ + goto l953 + l954: + position, tokenIndex = position954, tokenIndex954 + } + { + position955, tokenIndex955 := position, tokenIndex + if !_rules[ruleWS]() { + goto l955 + } + goto l956 + l955: + position, tokenIndex = position955, tokenIndex955 + } + l956: + if !_rules[ruleOffsetOperator]() { + goto l851 + } + { + position957, tokenIndex957 := position, tokenIndex + if !_rules[ruleWS]() { + goto l957 + } + goto l958 + l957: + position, tokenIndex = position957, tokenIndex957 + } + l958: + if c := buffer[position]; c < rune('0') || c > rune('9') { + goto l851 + } + position++ + l959: + { + position960, tokenIndex960 := position, tokenIndex + if c := buffer[position]; c < rune('0') || c > rune('9') { + goto l960 + } + position++ + goto l959 + l960: + position, tokenIndex = position960, tokenIndex960 + } if buffer[position] != rune(')') { goto l851 } @@ -7486,147 +7267,135 @@ func (p *Asm) Init(options ...func(*Asm) error) error { } l882: { - position949, tokenIndex949 := position, tokenIndex + position961, tokenIndex961 := position, tokenIndex { - position950, tokenIndex950 := position, tokenIndex + position962, tokenIndex962 := position, tokenIndex if c := buffer[position]; c < rune('a') || c > rune('z') { - goto l951 + goto l963 } position++ - goto l950 - l951: - position, tokenIndex = position950, tokenIndex950 + goto l962 + l963: + position, tokenIndex = position962, tokenIndex962 if c := buffer[position]; c < rune('A') || c > rune('Z') { - goto l949 + goto l961 } position++ } - l950: + l962: goto l851 - l949: - position, tokenIndex = position949, tokenIndex949 + l961: + position, tokenIndex = position961, tokenIndex961 } } l857: add(ruleOffset, position852) } - memoize(52, position851, tokenIndex851, true) return true l851: - memoize(52, position851, tokenIndex851, false) position, tokenIndex = position851, tokenIndex851 return false }, /* 53 Section <- <([a-z] / [A-Z] / '@')+> */ func() bool { - if memoized, ok := memoization[memoKey{53, position}]; ok { - return memoizedResult(memoized) - } - position952, tokenIndex952 := position, tokenIndex + position964, tokenIndex964 := position, tokenIndex { - position953 := position + position965 := position { - position956, tokenIndex956 := position, tokenIndex + position968, tokenIndex968 := position, tokenIndex if c := buffer[position]; c < rune('a') || c > rune('z') { - goto l957 + goto l969 } position++ - goto l956 - l957: - position, tokenIndex = position956, tokenIndex956 + goto l968 + l969: + position, tokenIndex = position968, tokenIndex968 if c := buffer[position]; c < rune('A') || c > rune('Z') { - goto l958 + goto l970 } position++ - goto l956 - l958: - position, tokenIndex = position956, tokenIndex956 + goto l968 + l970: + position, tokenIndex = position968, tokenIndex968 if buffer[position] != rune('@') { - goto l952 + goto l964 } position++ } - l956: - l954: + l968: + l966: { - position955, tokenIndex955 := position, tokenIndex + position967, tokenIndex967 := position, tokenIndex { - position959, tokenIndex959 := position, tokenIndex + position971, tokenIndex971 := position, tokenIndex if c := buffer[position]; c < rune('a') || c > rune('z') { - goto l960 + goto l972 } position++ - goto l959 - l960: - position, tokenIndex = position959, tokenIndex959 + goto l971 + l972: + position, tokenIndex = position971, tokenIndex971 if c := buffer[position]; c < rune('A') || c > rune('Z') { - goto l961 + goto l973 } position++ - goto l959 - l961: - position, tokenIndex = position959, tokenIndex959 + goto l971 + l973: + position, tokenIndex = position971, tokenIndex971 if buffer[position] != rune('@') { - goto l955 + goto l967 } position++ } - l959: - goto l954 - l955: - position, tokenIndex = position955, tokenIndex955 + l971: + goto l966 + l967: + position, tokenIndex = position967, tokenIndex967 } - add(ruleSection, position953) + add(ruleSection, position965) } - memoize(53, position952, tokenIndex952, true) return true - l952: - memoize(53, position952, tokenIndex952, false) - position, tokenIndex = position952, tokenIndex952 + l964: + position, tokenIndex = position964, tokenIndex964 return false }, /* 54 SegmentRegister <- <('%' ([c-g] / 's') ('s' ':'))> */ func() bool { - if memoized, ok := memoization[memoKey{54, position}]; ok { - return memoizedResult(memoized) - } - position962, tokenIndex962 := position, tokenIndex + position974, tokenIndex974 := position, tokenIndex { - position963 := position + position975 := position if buffer[position] != rune('%') { - goto l962 + goto l974 } position++ { - position964, tokenIndex964 := position, tokenIndex + position976, tokenIndex976 := position, tokenIndex if c := buffer[position]; c < rune('c') || c > rune('g') { - goto l965 + goto l977 } position++ - goto l964 - l965: - position, tokenIndex = position964, tokenIndex964 + goto l976 + l977: + position, tokenIndex = position976, tokenIndex976 if buffer[position] != rune('s') { - goto l962 + goto l974 } position++ } - l964: + l976: if buffer[position] != rune('s') { - goto l962 + goto l974 } position++ if buffer[position] != rune(':') { - goto l962 + goto l974 } position++ - add(ruleSegmentRegister, position963) + add(ruleSegmentRegister, position975) } - memoize(54, position962, tokenIndex962, true) return true - l962: - memoize(54, position962, tokenIndex962, false) - position, tokenIndex = position962, tokenIndex962 + l974: + position, tokenIndex = position974, tokenIndex974 return false }, } diff --git a/util/fipstools/delocate/testdata/aarch64-Basic/in.s b/util/fipstools/delocate/testdata/aarch64-Basic/in.s index cb1d08989e..f18d242f0f 100644 --- a/util/fipstools/delocate/testdata/aarch64-Basic/in.s +++ b/util/fipstools/delocate/testdata/aarch64-Basic/in.s @@ -82,6 +82,10 @@ foo: add w0, w1, b2, sxtw add w0, w1, b2, sxtx + // Make sure we can parse different immediates + add x22, sp, #(13*32) + add x22, sp, #(13*32)+96 + add x22, sp, #(13*32)+96*32 local_function: diff --git a/util/fipstools/delocate/testdata/aarch64-Basic/out.s b/util/fipstools/delocate/testdata/aarch64-Basic/out.s index 1c6db2ea13..ec62f4b595 100644 --- a/util/fipstools/delocate/testdata/aarch64-Basic/out.s +++ b/util/fipstools/delocate/testdata/aarch64-Basic/out.s @@ -136,6 +136,10 @@ foo: add w0, w1, b2, sxtw add w0, w1, b2, sxtx + // Make sure we can parse different immediates + add x22, sp, #(13*32) + add x22, sp, #(13*32)+96 + add x22, sp, #(13*32)+96*32 .Llocal_function_local_target: local_function: