11cb0ef41Sopenharmony_ci#include <stdint.h>
21cb0ef41Sopenharmony_ci#include <stddef.h>
31cb0ef41Sopenharmony_ci#include <stdlib.h>
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#include "../../../include/libbase64.h"
61cb0ef41Sopenharmony_ci#include "../../tables/tables.h"
71cb0ef41Sopenharmony_ci#include "../../codecs.h"
81cb0ef41Sopenharmony_ci#include "config.h"
91cb0ef41Sopenharmony_ci#include "../../env.h"
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ci#if HAVE_AVX2
121cb0ef41Sopenharmony_ci#include <immintrin.h>
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ci// Only enable inline assembly on supported compilers and on 64-bit CPUs.
151cb0ef41Sopenharmony_ci#ifndef BASE64_AVX2_USE_ASM
161cb0ef41Sopenharmony_ci# if (defined(__GNUC__) || defined(__clang__)) && BASE64_WORDSIZE == 64
171cb0ef41Sopenharmony_ci#  define BASE64_AVX2_USE_ASM 1
181cb0ef41Sopenharmony_ci# else
191cb0ef41Sopenharmony_ci#  define BASE64_AVX2_USE_ASM 0
201cb0ef41Sopenharmony_ci# endif
211cb0ef41Sopenharmony_ci#endif
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_ci#include "dec_reshuffle.c"
241cb0ef41Sopenharmony_ci#include "dec_loop.c"
251cb0ef41Sopenharmony_ci
261cb0ef41Sopenharmony_ci#if BASE64_AVX2_USE_ASM
271cb0ef41Sopenharmony_ci# include "enc_loop_asm.c"
281cb0ef41Sopenharmony_ci#else
291cb0ef41Sopenharmony_ci# include "enc_translate.c"
301cb0ef41Sopenharmony_ci# include "enc_reshuffle.c"
311cb0ef41Sopenharmony_ci# include "enc_loop.c"
321cb0ef41Sopenharmony_ci#endif
331cb0ef41Sopenharmony_ci
341cb0ef41Sopenharmony_ci#endif	// HAVE_AVX2
351cb0ef41Sopenharmony_ci
361cb0ef41Sopenharmony_ciBASE64_ENC_FUNCTION(avx2)
371cb0ef41Sopenharmony_ci{
381cb0ef41Sopenharmony_ci#if HAVE_AVX2
391cb0ef41Sopenharmony_ci	#include "../generic/enc_head.c"
401cb0ef41Sopenharmony_ci	enc_loop_avx2(&s, &slen, &o, &olen);
411cb0ef41Sopenharmony_ci	#include "../generic/enc_tail.c"
421cb0ef41Sopenharmony_ci#else
431cb0ef41Sopenharmony_ci	BASE64_ENC_STUB
441cb0ef41Sopenharmony_ci#endif
451cb0ef41Sopenharmony_ci}
461cb0ef41Sopenharmony_ci
471cb0ef41Sopenharmony_ciBASE64_DEC_FUNCTION(avx2)
481cb0ef41Sopenharmony_ci{
491cb0ef41Sopenharmony_ci#if HAVE_AVX2
501cb0ef41Sopenharmony_ci	#include "../generic/dec_head.c"
511cb0ef41Sopenharmony_ci	dec_loop_avx2(&s, &slen, &o, &olen);
521cb0ef41Sopenharmony_ci	#include "../generic/dec_tail.c"
531cb0ef41Sopenharmony_ci#else
541cb0ef41Sopenharmony_ci	BASE64_DEC_STUB
551cb0ef41Sopenharmony_ci#endif
561cb0ef41Sopenharmony_ci}
57