X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/blobdiff_plain/e492db887af6561dd33aa18e3887efaeb219fd16..3c0490d192453fad6827c29dfc21af2587772dad:/base/asm-common.h diff --git a/base/asm-common.h b/base/asm-common.h index d81e4098..040250ba 100644 --- a/base/asm-common.h +++ b/base/asm-common.h @@ -1,6 +1,6 @@ /// -*- mode: asm; asm-comment-char: ?/ -*- /// -/// Fancy SIMD implementation of Salsa20 +/// Common definitions for asesembler source files /// /// (c) 2015 Straylight/Edgeware /// @@ -24,6 +24,9 @@ /// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, /// MA 02111-1307, USA. +#ifndef CATACOMB_ASM_COMMON_H +#define CATACOMB_ASM_COMMON_H + ///-------------------------------------------------------------------------- /// General definitions. @@ -217,11 +220,11 @@ name: # define INTADDR__1(addr, got) addr #endif -// Permutations for SIMD instructions. SHUF(D, C, B, A) is an immediate, -// suitable for use in `pshufd' or `shufpd', which copies element D -// (0 <= D < 4) of the source to element 3 of the destination, element C to -// element 2, element B to element 1, and element A to element 0. -#define SHUF(d, c, b, a) (64*(d) + 16*(c) + 4*(b) + (a)) +// Permutations for SIMD instructions. SHUF(A, B, C, D) is an immediate, +// suitable for use in `pshufd' or `shufpd', which copies element A +// (0 <= A < 4) of the source to element 0 of the destination, element B to +// element 1, element C to element 2, and element D to element 3. +#define SHUF(a, b, c, d) ((a) + 4*(b) + 16*(c) + 64*(d)) // Map register names to their individual pieces. @@ -255,10 +258,10 @@ name: # define _DECOR_abcd_q(reg) r##reg##x #endif -#define _DECOR_xp_b(reg) reg##l #define _DECOR_xp_w(reg) reg #define _DECOR_xp_d(reg) e##reg #if CPUFAM_AMD64 +# define _DECOR_xp_b(reg) reg##l # define _DECOR_xp_q(reg) r##reg #endif @@ -276,22 +279,24 @@ name: # define _DECOR_rn_r(reg) reg #endif +#define _DECOR_mem_b(addr) byte ptr addr +#define _DECOR_mem_w(addr) word ptr addr +#define _DECOR_mem_d(addr) dword ptr addr +#if CPUFAM_AMD64 +# define _DECOR_mem_q(addr) qword ptr addr +#endif + #if CPUFAM_X86 # define _DECOR_abcd_r(reg) e##reg##x # define _DECOR_xp_r(reg) e##reg # define _DECOR_ip_r(reg) e##reg +# define _DECOR_mem_r(addr) dword ptr addr #endif #if CPUFAM_AMD64 # define _DECOR_abcd_r(reg) r##reg##x # define _DECOR_xp_r(reg) r##reg # define _DECOR_ip_r(reg) r##reg -#endif - -#define _DECOR_mem_b(addr) byte ptr addr -#define _DECOR_mem_w(addr) word ptr addr -#define _DECOR_mem_d(addr) dword ptr addr -#if CPUFAM_AMD64 -# define _DECOR_mem_q(addr) qword ptr addr +# define _DECOR_mem_r(addr) qword ptr addr #endif // R_r(decor) applies decoration decor to register r, which is an internal @@ -1181,3 +1186,5 @@ name: #endif ///----- That's all, folks -------------------------------------------------- + +#endif