Security Scol plugin
cpu.h
Go to the documentation of this file.
1// cpu.h - originally written and placed in the public domain by Wei Dai
2// updated for ARM and PowerPC by Jeffrey Walton.
3// updated to split CPU_Query() and CPU_Probe() by Jeffrey Walton.
4
29
30#ifndef CRYPTOPP_CPU_H
31#define CRYPTOPP_CPU_H
32
33#include "config.h"
34
35// Issue 340
36#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
37# pragma GCC diagnostic push
38# pragma GCC diagnostic ignored "-Wconversion"
39# pragma GCC diagnostic ignored "-Wsign-conversion"
40#endif
41
42// Applies to both X86/X32/X64 and ARM32/ARM64
43#if defined(CRYPTOPP_LLVM_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION)
44 #define NEW_LINE "\n"
45 #define INTEL_PREFIX ".intel_syntax;"
46 #define INTEL_NOPREFIX ".intel_syntax;"
47 #define ATT_PREFIX ".att_syntax;"
48 #define ATT_NOPREFIX ".att_syntax;"
49#elif defined(__GNUC__)
50 #define NEW_LINE
51 #define INTEL_PREFIX ".intel_syntax prefix;"
52 #define INTEL_NOPREFIX ".intel_syntax noprefix;"
53 #define ATT_PREFIX ".att_syntax prefix;"
54 #define ATT_NOPREFIX ".att_syntax noprefix;"
55#else
56 #define NEW_LINE
57 #define INTEL_PREFIX
58 #define INTEL_NOPREFIX
59 #define ATT_PREFIX
60 #define ATT_NOPREFIX
61#endif
62
63// Thanks to v1ne at https://github.com/weidai11/cryptopp/pull/1133
64#define PERCENT_PASTE(x) "%" #x
65#define PERCENT_REG(x) PERCENT_PASTE(x)
66
67#ifdef CRYPTOPP_GENERATE_X64_MASM
68
69#define CRYPTOPP_X86_ASM_AVAILABLE
70#define CRYPTOPP_BOOL_X64 1
71#define CRYPTOPP_SSE2_ASM_AVAILABLE 1
72#define NAMESPACE_END
73
74#else
75
76NAMESPACE_BEGIN(CryptoPP)
77
78// ***************************** IA-32 ***************************** //
79
80#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64 || CRYPTOPP_DOXYGEN_PROCESSING
81
82#define CRYPTOPP_CPUID_AVAILABLE 1
83
84// Hide from Doxygen
85#ifndef CRYPTOPP_DOXYGEN_PROCESSING
86// These should not be used directly
87extern CRYPTOPP_DLL bool g_x86DetectionDone;
88extern CRYPTOPP_DLL bool g_hasSSE2;
89extern CRYPTOPP_DLL bool g_hasSSSE3;
90extern CRYPTOPP_DLL bool g_hasSSE41;
91extern CRYPTOPP_DLL bool g_hasSSE42;
92extern CRYPTOPP_DLL bool g_hasMOVBE;
93extern CRYPTOPP_DLL bool g_hasAESNI;
94extern CRYPTOPP_DLL bool g_hasCLMUL;
95extern CRYPTOPP_DLL bool g_hasAVX;
96extern CRYPTOPP_DLL bool g_hasAVX2;
97extern CRYPTOPP_DLL bool g_hasSHA;
98extern CRYPTOPP_DLL bool g_hasADX;
99extern CRYPTOPP_DLL bool g_isP4;
100extern CRYPTOPP_DLL bool g_hasRDRAND;
101extern CRYPTOPP_DLL bool g_hasRDSEED;
102extern CRYPTOPP_DLL bool g_hasPadlockRNG;
103extern CRYPTOPP_DLL bool g_hasPadlockACE;
104extern CRYPTOPP_DLL bool g_hasPadlockACE2;
105extern CRYPTOPP_DLL bool g_hasPadlockPHE;
106extern CRYPTOPP_DLL bool g_hasPadlockPMM;
107extern CRYPTOPP_DLL word32 g_cacheLineSize;
108
109CRYPTOPP_DLL void CRYPTOPP_API DetectX86Features();
110CRYPTOPP_DLL bool CRYPTOPP_API CpuId(word32 func, word32 subfunc, word32 output[4]);
111#endif // CRYPTOPP_DOXYGEN_PROCESSING
112
114
115
122inline bool HasSSE2()
123{
124#if (CRYPTOPP_SSE2_ASM_AVAILABLE || CRYPTOPP_SSE2_INTRIN_AVAILABLE)
125 if (!g_x86DetectionDone)
126 DetectX86Features();
127 return g_hasSSE2;
128#else
129 return false;
130#endif
131}
132
137inline bool HasSSSE3()
138{
139#if CRYPTOPP_SSSE3_AVAILABLE
140 if (!g_x86DetectionDone)
141 DetectX86Features();
142 return g_hasSSSE3;
143#else
144 return false;
145#endif
146}
147
152inline bool HasSSE41()
153{
154#if CRYPTOPP_SSE41_AVAILABLE
155 if (!g_x86DetectionDone)
156 DetectX86Features();
157 return g_hasSSE41;
158#else
159 return false;
160#endif
161}
162
167inline bool HasSSE42()
168{
169#if CRYPTOPP_SSE42_AVAILABLE
170 if (!g_x86DetectionDone)
171 DetectX86Features();
172 return g_hasSSE42;
173#else
174 return false;
175#endif
176}
177
183inline bool HasMOVBE()
184{
185#if CRYPTOPP_SSE42_AVAILABLE
186 if (!g_x86DetectionDone)
187 DetectX86Features();
188 return g_hasMOVBE;
189#else
190 return false;
191#endif
192}
193
199inline bool HasAESNI()
200{
201#if CRYPTOPP_AESNI_AVAILABLE
202 if (!g_x86DetectionDone)
203 DetectX86Features();
204 return g_hasAESNI;
205#else
206 return false;
207#endif
208}
209
215inline bool HasCLMUL()
216{
217#if CRYPTOPP_CLMUL_AVAILABLE
218 if (!g_x86DetectionDone)
219 DetectX86Features();
220 return g_hasCLMUL;
221#else
222 return false;
223#endif
224}
225
231inline bool HasSHA()
232{
233#if CRYPTOPP_SHANI_AVAILABLE
234 if (!g_x86DetectionDone)
235 DetectX86Features();
236 return g_hasSHA;
237#else
238 return false;
239#endif
240}
241
247inline bool HasADX()
248{
249#if CRYPTOPP_ADX_AVAILABLE
250 if (!g_x86DetectionDone)
251 DetectX86Features();
252 return g_hasADX;
253#else
254 return false;
255#endif
256}
257
263inline bool HasAVX()
264{
265#if CRYPTOPP_AVX_AVAILABLE
266 if (!g_x86DetectionDone)
267 DetectX86Features();
268 return g_hasAVX;
269#else
270 return false;
271#endif
272}
273
279inline bool HasAVX2()
280{
281#if CRYPTOPP_AVX2_AVAILABLE
282 if (!g_x86DetectionDone)
283 DetectX86Features();
284 return g_hasAVX2;
285#else
286 return false;
287#endif
288}
289
294inline bool HasRDRAND()
295{
296#if CRYPTOPP_RDRAND_AVAILABLE
297 if (!g_x86DetectionDone)
298 DetectX86Features();
299 return g_hasRDRAND;
300#else
301 return false;
302#endif
303}
304
309inline bool HasRDSEED()
310{
311#if CRYPTOPP_RDSEED_AVAILABLE
312 if (!g_x86DetectionDone)
313 DetectX86Features();
314 return g_hasRDSEED;
315#else
316 return false;
317#endif
318}
319
324inline bool HasPadlockRNG()
325{
326#if CRYPTOPP_PADLOCK_RNG_AVAILABLE
327 if (!g_x86DetectionDone)
328 DetectX86Features();
329 return g_hasPadlockRNG;
330#else
331 return false;
332#endif
333}
334
339inline bool HasPadlockACE()
340{
341#if CRYPTOPP_PADLOCK_ACE_AVAILABLE
342 if (!g_x86DetectionDone)
343 DetectX86Features();
344 return g_hasPadlockACE;
345#else
346 return false;
347#endif
348}
349
354inline bool HasPadlockACE2()
355{
356#if CRYPTOPP_PADLOCK_ACE2_AVAILABLE
357 if (!g_x86DetectionDone)
358 DetectX86Features();
359 return g_hasPadlockACE2;
360#else
361 return false;
362#endif
363}
364
369inline bool HasPadlockPHE()
370{
371#if CRYPTOPP_PADLOCK_PHE_AVAILABLE
372 if (!g_x86DetectionDone)
373 DetectX86Features();
374 return g_hasPadlockPHE;
375#else
376 return false;
377#endif
378}
379
384inline bool HasPadlockPMM()
385{
386#if CRYPTOPP_PADLOCK_PMM_AVAILABLE
387 if (!g_x86DetectionDone)
388 DetectX86Features();
389 return g_hasPadlockPMM;
390#else
391 return false;
392#endif
393}
394
399inline bool IsP4()
400{
401 if (!g_x86DetectionDone)
402 DetectX86Features();
403 return g_isP4;
404}
405
414inline int GetCacheLineSize()
415{
416 if (!g_x86DetectionDone)
417 DetectX86Features();
418 return g_cacheLineSize;
419}
421
422#endif // CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64
423
424// ***************************** ARM-32, Aarch32 and Aarch64 ***************************** //
425
426#if CRYPTOPP_BOOL_ARM32 || CRYPTOPP_BOOL_ARMV8 || CRYPTOPP_DOXYGEN_PROCESSING
427
428// Hide from Doxygen
429#ifndef CRYPTOPP_DOXYGEN_PROCESSING
430extern bool g_ArmDetectionDone;
431extern bool g_hasARMv7;
432extern bool g_hasNEON;
433extern bool g_hasPMULL;
434extern bool g_hasCRC32;
435extern bool g_hasAES;
436extern bool g_hasSHA1;
437extern bool g_hasSHA2;
438extern bool g_hasSHA512;
439extern bool g_hasSHA3;
440extern bool g_hasSM3;
441extern bool g_hasSM4;
442void CRYPTOPP_API DetectArmFeatures();
443#endif // CRYPTOPP_DOXYGEN_PROCESSING
444
446
447
453inline bool HasARMv7()
454{
455 // ASIMD is a core feature on Aarch32 and Aarch64 like SSE2 is a core feature on x86_64
456#if defined(__aarch32__) || defined(__aarch64__)
457 return true;
458#else
459 if (!g_ArmDetectionDone)
460 DetectArmFeatures();
461 return g_hasARMv7;
462#endif
463}
464
473inline bool HasNEON()
474{
475 // ASIMD is a core feature on Aarch32 and Aarch64 like SSE2 is a core feature on x86_64
476#if defined(CRYPTOPP_ARM_ASIMD_AVAILABLE)
477 return true;
478#elif defined(CRYPTOPP_ARM_NEON_AVAILABLE)
479 if (!g_ArmDetectionDone)
480 DetectArmFeatures();
481 return g_hasNEON;
482#else
483 return false;
484#endif
485}
486
497inline bool HasCRC32()
498{
499#if defined(CRYPTOPP_ARM_CRC32_AVAILABLE)
500 if (!g_ArmDetectionDone)
501 DetectArmFeatures();
502 return g_hasCRC32;
503#else
504 return false;
505#endif
506}
507
517inline bool HasAES()
518{
519#if defined(CRYPTOPP_ARM_AES_AVAILABLE)
520 if (!g_ArmDetectionDone)
521 DetectArmFeatures();
522 return g_hasAES;
523#else
524 return false;
525#endif
526}
527
537inline bool HasPMULL()
538{
539#if defined(CRYPTOPP_ARM_PMULL_AVAILABLE)
540 if (!g_ArmDetectionDone)
541 DetectArmFeatures();
542 return g_hasPMULL;
543#else
544 return false;
545#endif
546}
547
557inline bool HasSHA1()
558{
559#if defined(CRYPTOPP_ARM_SHA1_AVAILABLE)
560 if (!g_ArmDetectionDone)
561 DetectArmFeatures();
562 return g_hasSHA1;
563#else
564 return false;
565#endif
566}
567
577inline bool HasSHA2()
578{
579#if defined(CRYPTOPP_ARM_SHA2_AVAILABLE)
580 if (!g_ArmDetectionDone)
581 DetectArmFeatures();
582 return g_hasSHA2;
583#else
584 return false;
585#endif
586}
587
597inline bool HasSHA3()
598{
599#if defined(CRYPTOPP_ARM_SHA3_AVAILABLE)
600 if (!g_ArmDetectionDone)
601 DetectArmFeatures();
602 return g_hasSHA3;
603#else
604 return false;
605#endif
606}
607
617inline bool HasSHA512()
618{
619#if defined(CRYPTOPP_ARM_SHA512_AVAILABLE)
620 if (!g_ArmDetectionDone)
621 DetectArmFeatures();
622 return g_hasSHA512;
623#else
624 return false;
625#endif
626}
627
637inline bool HasSM3()
638{
639#if defined(CRYPTOPP_ARM_SM3_AVAILABLE)
640 if (!g_ArmDetectionDone)
641 DetectArmFeatures();
642 return g_hasSM3;
643#else
644 return false;
645#endif
646}
647
657inline bool HasSM4()
658{
659#if defined(CRYPTOPP_ARM_SM4_AVAILABLE)
660 if (!g_ArmDetectionDone)
661 DetectArmFeatures();
662 return g_hasSM4;
663#else
664 return false;
665#endif
666}
667
669
670#endif // CRYPTOPP_BOOL_ARM32 || CRYPTOPP_BOOL_ARMV8
671
672// ***************************** PowerPC ***************************** //
673
674#if CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64 || CRYPTOPP_DOXYGEN_PROCESSING
675
676// Hide from Doxygen
677#ifndef CRYPTOPP_DOXYGEN_PROCESSING
678extern bool g_PowerPcDetectionDone;
679extern bool g_hasAltivec;
680extern bool g_hasPower7;
681extern bool g_hasPower8;
682extern bool g_hasPower9;
683extern bool g_hasAES;
684extern bool g_hasPMULL;
685extern bool g_hasSHA256;
686extern bool g_hasSHA512;
687extern bool g_hasDARN;
688extern word32 g_cacheLineSize;
689void CRYPTOPP_API DetectPowerPcFeatures();
690#endif // CRYPTOPP_DOXYGEN_PROCESSING
691
693
694
702inline bool HasAltivec()
703{
704#if CRYPTOPP_ALTIVEC_AVAILABLE
705 if (!g_PowerPcDetectionDone)
706 DetectPowerPcFeatures();
707 return g_hasAltivec;
708#else
709 return false;
710#endif
711}
712
719inline bool HasPower7()
720{
721#if CRYPTOPP_POWER7_AVAILABLE
722 if (!g_PowerPcDetectionDone)
723 DetectPowerPcFeatures();
724 return g_hasPower7;
725#else
726 return false;
727#endif
728}
729
736inline bool HasPower8()
737{
738#if CRYPTOPP_POWER8_AVAILABLE
739 if (!g_PowerPcDetectionDone)
740 DetectPowerPcFeatures();
741 return g_hasPower8;
742#else
743 return false;
744#endif
745}
746
753inline bool HasPower9()
754{
755#if CRYPTOPP_POWER9_AVAILABLE
756 if (!g_PowerPcDetectionDone)
757 DetectPowerPcFeatures();
758 return g_hasPower9;
759#else
760 return false;
761#endif
762}
763
771inline bool HasAES()
772{
773#if CRYPTOPP_POWER8_AES_AVAILABLE
774 if (!g_PowerPcDetectionDone)
775 DetectPowerPcFeatures();
776 return g_hasAES;
777#else
778 return false;
779#endif
780}
781
789inline bool HasPMULL()
790{
791#if CRYPTOPP_POWER8_VMULL_AVAILABLE
792 if (!g_PowerPcDetectionDone)
793 DetectPowerPcFeatures();
794 return g_hasPMULL;
795#else
796 return false;
797#endif
798}
799
807inline bool HasSHA256()
808{
809#if CRYPTOPP_POWER8_SHA_AVAILABLE
810 if (!g_PowerPcDetectionDone)
811 DetectPowerPcFeatures();
812 return g_hasSHA256;
813#else
814 return false;
815#endif
816}
817
825inline bool HasSHA512()
826{
827#if CRYPTOPP_POWER8_SHA_AVAILABLE
828 if (!g_PowerPcDetectionDone)
829 DetectPowerPcFeatures();
830 return g_hasSHA512;
831#else
832 return false;
833#endif
834}
835
842inline bool HasDARN()
843{
844#if CRYPTOPP_POWER9_AVAILABLE
845 if (!g_PowerPcDetectionDone)
846 DetectPowerPcFeatures();
847 // see comments in cpu.cpp
848# if defined(__ibmxl__) && defined(__linux__)
849 return false;
850# else
851 return g_hasDARN;
852# endif
853#else
854 return false;
855#endif
856}
857
866inline int GetCacheLineSize()
867{
868 if (!g_PowerPcDetectionDone)
869 DetectPowerPcFeatures();
870 return g_cacheLineSize;
871}
872
874
875#endif // CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64
876
877// ***************************** L1 cache line ***************************** //
878
879// Non-Intel systems
880#if !(CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64)
890{
891 return CRYPTOPP_L1_CACHE_LINE_SIZE;
892}
893#endif // Non-Intel systems
894
895#endif // CRYPTOPP_GENERATE_X64_MASM
896
897// ***************************** Inline ASM Helper ***************************** //
898
899#ifndef CRYPTOPP_DOXYGEN_PROCESSING
900
901#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64
902
903#ifdef CRYPTOPP_GENERATE_X64_MASM
904 #define AS1(x) x*newline*
905 #define AS2(x, y) x, y*newline*
906 #define AS3(x, y, z) x, y, z*newline*
907 #define ASS(x, y, a, b, c, d) x, y, a*64+b*16+c*4+d*newline*
908 #define ASL(x) label##x:*newline*
909 #define ASJ(x, y, z) x label##y*newline*
910 #define ASC(x, y) x label##y*newline*
911 #define AS_HEX(y) 0##y##h
912#elif defined(_MSC_VER) || defined(__BORLANDC__)
913 #define AS1(x) __asm {x}
914 #define AS2(x, y) __asm {x, y}
915 #define AS3(x, y, z) __asm {x, y, z}
916 #define ASS(x, y, a, b, c, d) __asm {x, y, (a)*64+(b)*16+(c)*4+(d)}
917 #define ASL(x) __asm {label##x:}
918 #define ASJ(x, y, z) __asm {x label##y}
919 #define ASC(x, y) __asm {x label##y}
920 #define CRYPTOPP_NAKED __declspec(naked)
921 #define AS_HEX(y) 0x##y
922#else
923 // define these in two steps to allow arguments to be expanded
924 #define GNU_AS1(x) #x ";" NEW_LINE
925 #define GNU_AS2(x, y) #x ", " #y ";" NEW_LINE
926 #define GNU_AS3(x, y, z) #x ", " #y ", " #z ";" NEW_LINE
927 #define GNU_ASL(x) "\n" #x ":" NEW_LINE
928// clang 5.0.0 and apple clang 9.0.0 don't support numerical backward jumps
929#if (CRYPTOPP_LLVM_CLANG_VERSION >= 50000) || (CRYPTOPP_APPLE_CLANG_VERSION >= 90000)
930 #define GNU_ASJ(x, y, z) ATT_PREFIX ";" NEW_LINE #x " " #y #z ";" NEW_LINE INTEL_PREFIX ";" NEW_LINE
931#else
932 #define GNU_ASJ(x, y, z) #x " " #y #z ";" NEW_LINE
933#endif
934 #define AS1(x) GNU_AS1(x)
935 #define AS2(x, y) GNU_AS2(x, y)
936 #define AS3(x, y, z) GNU_AS3(x, y, z)
937 #define ASS(x, y, a, b, c, d) #x ", " #y ", " #a "*64+" #b "*16+" #c "*4+" #d ";"
938 #define ASL(x) GNU_ASL(x)
939 #define ASJ(x, y, z) GNU_ASJ(x, y, z)
940 #define ASC(x, y) #x " " #y ";"
941 #define CRYPTOPP_NAKED
942 #define AS_HEX(y) 0x##y
943#endif
944
945#define IF0(y)
946#define IF1(y) y
947
948#ifdef CRYPTOPP_GENERATE_X64_MASM
949#define ASM_MOD(x, y) ((x) MOD (y))
950#define XMMWORD_PTR XMMWORD PTR
951#else
952// GNU assembler doesn't seem to have mod operator
953#define ASM_MOD(x, y) ((x)-((x)/(y))*(y))
954// GAS 2.15 doesn't support XMMWORD PTR. it seems necessary only for MASM
955#define XMMWORD_PTR
956#endif
957
958#if CRYPTOPP_BOOL_X86
959 #define AS_REG_1 ecx
960 #define AS_REG_2 edx
961 #define AS_REG_3 esi
962 #define AS_REG_4 edi
963 #define AS_REG_5 eax
964 #define AS_REG_6 ebx
965 #define AS_REG_7 ebp
966 #define AS_REG_1d ecx
967 #define AS_REG_2d edx
968 #define AS_REG_3d esi
969 #define AS_REG_4d edi
970 #define AS_REG_5d eax
971 #define AS_REG_6d ebx
972 #define AS_REG_7d ebp
973 #define WORD_SZ 4
974 #define WORD_REG(x) e##x
975 #define WORD_PTR DWORD PTR
976 #define AS_PUSH_IF86(x) AS1(push e##x)
977 #define AS_POP_IF86(x) AS1(pop e##x)
978 #define AS_JCXZ jecxz
979#elif CRYPTOPP_BOOL_X32
980 #define AS_REG_1 ecx
981 #define AS_REG_2 edx
982 #define AS_REG_3 r8d
983 #define AS_REG_4 r9d
984 #define AS_REG_5 eax
985 #define AS_REG_6 r10d
986 #define AS_REG_7 r11d
987 #define AS_REG_1d ecx
988 #define AS_REG_2d edx
989 #define AS_REG_3d r8d
990 #define AS_REG_4d r9d
991 #define AS_REG_5d eax
992 #define AS_REG_6d r10d
993 #define AS_REG_7d r11d
994 #define WORD_SZ 4
995 #define WORD_REG(x) e##x
996 #define WORD_PTR DWORD PTR
997 #define AS_PUSH_IF86(x) AS1(push r##x)
998 #define AS_POP_IF86(x) AS1(pop r##x)
999 #define AS_JCXZ jecxz
1000#elif CRYPTOPP_BOOL_X64
1001 #ifdef CRYPTOPP_GENERATE_X64_MASM
1002 #define AS_REG_1 rcx
1003 #define AS_REG_2 rdx
1004 #define AS_REG_3 r8
1005 #define AS_REG_4 r9
1006 #define AS_REG_5 rax
1007 #define AS_REG_6 r10
1008 #define AS_REG_7 r11
1009 #define AS_REG_1d ecx
1010 #define AS_REG_2d edx
1011 #define AS_REG_3d r8d
1012 #define AS_REG_4d r9d
1013 #define AS_REG_5d eax
1014 #define AS_REG_6d r10d
1015 #define AS_REG_7d r11d
1016 #else
1017 #define AS_REG_1 rdi
1018 #define AS_REG_2 rsi
1019 #define AS_REG_3 rdx
1020 #define AS_REG_4 rcx
1021 #define AS_REG_5 r8
1022 #define AS_REG_6 r9
1023 #define AS_REG_7 r10
1024 #define AS_REG_1d edi
1025 #define AS_REG_2d esi
1026 #define AS_REG_3d edx
1027 #define AS_REG_4d ecx
1028 #define AS_REG_5d r8d
1029 #define AS_REG_6d r9d
1030 #define AS_REG_7d r10d
1031 #endif
1032 #define WORD_SZ 8
1033 #define WORD_REG(x) r##x
1034 #define WORD_PTR QWORD PTR
1035 #define AS_PUSH_IF86(x)
1036 #define AS_POP_IF86(x)
1037 #define AS_JCXZ jrcxz
1038#endif
1039
1040// helper macro for stream cipher output
1041#define AS_XMM_OUTPUT4(labelPrefix, inputPtr, outputPtr, x0, x1, x2, x3, t, p0, p1, p2, p3, increment)\
1042 AS2( test inputPtr, inputPtr)\
1043 ASC( jz, labelPrefix##3)\
1044 AS2( test inputPtr, 15)\
1045 ASC( jnz, labelPrefix##7)\
1046 AS2( pxor xmm##x0, [inputPtr+p0*16])\
1047 AS2( pxor xmm##x1, [inputPtr+p1*16])\
1048 AS2( pxor xmm##x2, [inputPtr+p2*16])\
1049 AS2( pxor xmm##x3, [inputPtr+p3*16])\
1050 AS2( add inputPtr, increment*16)\
1051 ASC( jmp, labelPrefix##3)\
1052 ASL(labelPrefix##7)\
1053 AS2( movdqu xmm##t, [inputPtr+p0*16])\
1054 AS2( pxor xmm##x0, xmm##t)\
1055 AS2( movdqu xmm##t, [inputPtr+p1*16])\
1056 AS2( pxor xmm##x1, xmm##t)\
1057 AS2( movdqu xmm##t, [inputPtr+p2*16])\
1058 AS2( pxor xmm##x2, xmm##t)\
1059 AS2( movdqu xmm##t, [inputPtr+p3*16])\
1060 AS2( pxor xmm##x3, xmm##t)\
1061 AS2( add inputPtr, increment*16)\
1062 ASL(labelPrefix##3)\
1063 AS2( test outputPtr, 15)\
1064 ASC( jnz, labelPrefix##8)\
1065 AS2( movdqa [outputPtr+p0*16], xmm##x0)\
1066 AS2( movdqa [outputPtr+p1*16], xmm##x1)\
1067 AS2( movdqa [outputPtr+p2*16], xmm##x2)\
1068 AS2( movdqa [outputPtr+p3*16], xmm##x3)\
1069 ASC( jmp, labelPrefix##9)\
1070 ASL(labelPrefix##8)\
1071 AS2( movdqu [outputPtr+p0*16], xmm##x0)\
1072 AS2( movdqu [outputPtr+p1*16], xmm##x1)\
1073 AS2( movdqu [outputPtr+p2*16], xmm##x2)\
1074 AS2( movdqu [outputPtr+p3*16], xmm##x3)\
1075 ASL(labelPrefix##9)\
1076 AS2( add outputPtr, increment*16)
1077
1078#endif // CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64
1079
1080#endif // Not CRYPTOPP_DOXYGEN_PROCESSING
1081
1082NAMESPACE_END
1083
1084// Issue 340
1085#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
1086# pragma GCC diagnostic pop
1087#endif
1088
1089#endif // CRYPTOPP_CPU_H
Library configuration file.
unsigned int word32
32-bit unsigned datatype
Definition config_int.h:62
int GetCacheLineSize()
Provides the cache line size.
Definition cpu.h:889