Testing for avx512

This commit is contained in:
Sy
2020-05-27 13:41:57 +02:00
parent bfad636369
commit bdd12a3396
326 changed files with 155258 additions and 67 deletions
@@ -30,6 +30,8 @@
#ifndef __NR_LDPC_CNPROC__H__
#define __NR_LDPC_CNPROC__H__
//#include "/opt/rh/devtoolset-7/root/lib/gcc/x86_64-redhat-linux/7/include/avx2intrin.h"
#include "immintrin.h"
/**
\brief Performs CN processing for BG2 on the CN processing buffer and stores the results in the CN processing results buffer.
@@ -38,6 +38,8 @@
#include "nrLDPC_mPass.h"
#include "nrLDPC_cnProc.h"
#include "nrLDPC_bnProc.h"
#include "nrLDPC_tools/include/avx512fintrin.h"
/*********************************include files-> AVX2**********************/
/*----------------------------BG1-----------------------------------------*/
@@ -160,62 +162,64 @@
/**************************include files for -->AVX512 ******************/
//test
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z384_13_AVX512.c"
/#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z384_13_AVX512.c"
/*#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z352_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z320_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z288_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z256_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z240_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z224_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z208_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z192_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z176_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z160_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z144_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z128_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z120_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z112_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z104_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z96_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z88_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z80_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z72_13_AVX512.c"
/*#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z352_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z320_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z288_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z256_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z240_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z224_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z208_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z192_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z176_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z64_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z60_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z56_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z52_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z48_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z44_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z40_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z36_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z32_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z30_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z160_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z144_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z128_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z120_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z112_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z104_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z96_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z88_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z80_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z72_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z28_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z26_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z24_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z22_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z20_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z18_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z16_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z15_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z14_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z13_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z64_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z60_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z56_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z52_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z48_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z44_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z40_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z36_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z32_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z30_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z12_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z11_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z10_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z9_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z8_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z7_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z6_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z5_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z4_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z3_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/nrLDPC_cnProc_BG1_Z2_13_AVX512.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z28_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z26_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z24_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z22_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z20_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z18_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z16_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z15_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z14_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z13_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z12_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z11_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z10_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z9_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z8_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z7_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z6_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z5_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z4_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z3_13_AVX2.c"
#include "nrLDPC_tools/ldpc_gen_files/avx2/nrLDPC_cnProc_BG1_Z2_13_AVX2.c"
*/
#define NR_LDPC_ENABLE_PARITY_CHECK
#define NR_LDPC_PROFILER_DETAIL
@@ -328,11 +332,11 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDP
switch (Z)
{
case 384:
{ //we test here
//nrLDPC_cnProc_BG1_Z384_13_AVX2(p_procBuf->cnProcBuf,p_procBuf->cnProcBufRes);
nrLDPC_cnProc_BG1_Z384_13_AVX512(p_procBuf->cnProcBuf,p_procBuf->cnProcBufRes);
{
// nrLDPC_cnProc_BG1_Z384_13_AVX2(p_procBuf->cnProcBuf,p_procBuf->cnProcBufRes);
nrLDPC_cnProc_BG1_Z384_13_AVX512(p_procBuf->cnProcBuf,p_procBuf->cnProcBufRes); //were test here
break;
}
}
case 352:
{
nrLDPC_cnProc_BG1_Z352_13_AVX2(p_procBuf->cnProcBuf,p_procBuf->cnProcBufRes);
@@ -683,7 +687,7 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDP
case 384:
{
nrLDPC_cnProc_BG2_Z384_13_AVX2(p_procBuf->cnProcBuf,p_procBuf->cnProcBufRes);
// nrLDPC_cnProc_BG2_Z384_13_AVX512(p_procBuf->cnProcBuf,p_procBuf->cnProcBufRes);
// nrLDPC_cnProc_BG2_Z384_13_AVX512(p_procBuf->cnProcBuf,p_procBuf->cnProcBufRes);
break;
}
case 352:
@@ -1118,8 +1122,8 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDP
{
case 384:
{
nrLDPC_cnProc_BG1_Z384_13_AVX2(p_procBuf->cnProcBuf,p_procBuf->cnProcBufRes);
// nrLDPC_cnProc_BG1_Z384_13_AVX512(p_procBuf->cnProcBuf,p_procBuf->cnProcBufRes);
//nrLDPC_cnProc_BG1_Z384_13_AVX2(p_procBuf->cnProcBuf,p_procBuf->cnProcBufRes);
nrLDPC_cnProc_BG1_Z384_13_AVX512(p_procBuf->cnProcBuf,p_procBuf->cnProcBufRes); //we test here
break;
}
case 352:
@@ -1917,15 +1921,15 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDP
switch (Z)
{
case 384:
{//we test here
//nrLDPC_cnProc_BG1_Z384_13_AVX2(p_procBuf->cnProcBuf,p_procBuf->cnProcBufRes);
nrLDPC_cnProc_BG1_Z384_13_AVX512(p_procBuf->cnProcBuf,p_procBuf->cnProcBufRes);
{
// nrLDPC_cnProc_BG1_Z384_13_AVX2(p_procBuf->cnProcBuf,p_procBuf->cnProcBufRes);
nrLDPC_cnProc_BG1_Z384_13_AVX512(p_procBuf->cnProcBuf,p_procBuf->cnProcBufRes); //we test here
break;
}
case 352:
{
nrLDPC_cnProc_BG1_Z352_13_AVX2(p_procBuf->cnProcBuf,p_procBuf->cnProcBufRes);
// nrLDPC_cnProc_BG1_Z352_13_AVX512(p_procBuf->cnProcBuf,p_procBuf->cnProcBufRes);
//nrLDPC_cnProc_BG1_Z352_13_AVX2(p_procBuf->cnProcBuf,p_procBuf->cnProcBufRes);
nrLDPC_cnProc_BG1_Z352_13_AVX512(p_procBuf->cnProcBuf,p_procBuf->cnProcBufRes);
break;
}
@@ -2267,9 +2271,9 @@ static inline uint32_t nrLDPC_decoder_core(int8_t* p_llr, int8_t* p_out, t_nrLDP
switch (Z)
{
case 384:
{ //we test here
//nrLDPC_cnProc_BG2_Z384_13_AVX2(p_procBuf->cnProcBuf,p_procBuf->cnProcBufRes);
nrLDPC_cnProc_BG2_Z384_13_AVX512(p_procBuf->cnProcBuf,p_procBuf->cnProcBufRes);
{
nrLDPC_cnProc_BG2_Z384_13_AVX2(p_procBuf->cnProcBuf,p_procBuf->cnProcBufRes);
// nrLDPC_cnProc_BG2_Z384_13_AVX512(p_procBuf->cnProcBuf,p_procBuf->cnProcBufRes);
break;
}
case 352:
@@ -21,6 +21,8 @@ void nrLDPC_cnProc_BG1_generator_AVX2(uint16_t Z,int R)
fprintf(fd,"#include <stdint.h>\n");
fprintf(fd,"#include <immintrin.h>\n");
fprintf(fd,"#include "\"../include/avx512fintrin.h>\"\n");
fprintf(fd,"void nrLDPC_cnProc_BG1_Z%d_%s_AVX2(int8_t* cnProcBuf,int8_t* cnProcBufRes) {\n",Z,ratestr[R]);
const uint8_t* lut_numCnInCnGroups;
@@ -20,7 +20,7 @@ void nrLDPC_cnProc_BG1_generator_AVX512(uint16_t Z,int R)
fprintf(fd,"#include <stdint.h>\n");
fprintf(fd,"#include <immintrin.h>\n");
fprintf(fd, "#include \"../include/avx512fintrin.h\"\n");
fprintf(fd, "__m512i _mm512_sign_epi16(__m512i a, __m512i b){ \n"); /* Emulate _mm512_sign_epi16() with instructions that exist in the AVX-512 instruction set */
fprintf(fd, "b = _mm512_min_epi16(b, _mm512_set1_epi16(1)); \n" );
@@ -20,6 +20,7 @@ void nrLDPC_cnProc_BG2_generator_AVX512(uint16_t Z,int R)
fprintf(fd,"#include <stdint.h>\n");
fprintf(fd,"#include <immintrin.h>\n");
fprintf(fd, "#include \"../include/avx512fintrin.h\"\n");
fprintf(fd, "__m512i _mm512_sign_epi16(__m512i a, __m512i b){ \n"); /* Emulate _mm512_sign_epi16() with instructions that exist in the AVX-512 instruction set */
@@ -0,0 +1,81 @@
/* Copyright (C) 2012-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#if !defined _X86INTRIN_H_INCLUDED && !defined _IMMINTRIN_H_INCLUDED
# error "Never use <adxintrin.h> directly; include <x86intrin.h> instead."
#endif
#ifndef _ADXINTRIN_H_INCLUDED
#define _ADXINTRIN_H_INCLUDED
extern __inline unsigned char
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_subborrow_u32 (unsigned char __CF, unsigned int __X,
unsigned int __Y, unsigned int *__P)
{
return __builtin_ia32_sbb_u32 (__CF, __X, __Y, __P);
}
extern __inline unsigned char
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_addcarry_u32 (unsigned char __CF, unsigned int __X,
unsigned int __Y, unsigned int *__P)
{
return __builtin_ia32_addcarryx_u32 (__CF, __X, __Y, __P);
}
extern __inline unsigned char
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_addcarryx_u32 (unsigned char __CF, unsigned int __X,
unsigned int __Y, unsigned int *__P)
{
return __builtin_ia32_addcarryx_u32 (__CF, __X, __Y, __P);
}
#ifdef __x86_64__
extern __inline unsigned char
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_subborrow_u64 (unsigned char __CF, unsigned long long __X,
unsigned long long __Y, unsigned long long *__P)
{
return __builtin_ia32_sbb_u64 (__CF, __X, __Y, __P);
}
extern __inline unsigned char
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_addcarry_u64 (unsigned char __CF, unsigned long long __X,
unsigned long long __Y, unsigned long long *__P)
{
return __builtin_ia32_addcarryx_u64 (__CF, __X, __Y, __P);
}
extern __inline unsigned char
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_addcarryx_u64 (unsigned char __CF, unsigned long long __X,
unsigned long long __Y, unsigned long long *__P)
{
return __builtin_ia32_addcarryx_u64 (__CF, __X, __Y, __P);
}
#endif
#endif /* _ADXINTRIN_H_INCLUDED */
@@ -0,0 +1,93 @@
/* Copyright (C) 2007-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
/* Implemented from the specification included in the AMD Programmers
Manual Update, version 2.x */
#ifndef _AMMINTRIN_H_INCLUDED
#define _AMMINTRIN_H_INCLUDED
/* We need definitions from the SSE3, SSE2 and SSE header files*/
#include <pmmintrin.h>
#ifndef __SSE4A__
#pragma GCC push_options
#pragma GCC target("sse4a")
#define __DISABLE_SSE4A__
#endif /* __SSE4A__ */
extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_stream_sd (double * __P, __m128d __Y)
{
__builtin_ia32_movntsd (__P, (__v2df) __Y);
}
extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_stream_ss (float * __P, __m128 __Y)
{
__builtin_ia32_movntss (__P, (__v4sf) __Y);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_extract_si64 (__m128i __X, __m128i __Y)
{
return (__m128i) __builtin_ia32_extrq ((__v2di) __X, (__v16qi) __Y);
}
#ifdef __OPTIMIZE__
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_extracti_si64 (__m128i __X, unsigned const int __I, unsigned const int __L)
{
return (__m128i) __builtin_ia32_extrqi ((__v2di) __X, __I, __L);
}
#else
#define _mm_extracti_si64(X, I, L) \
((__m128i) __builtin_ia32_extrqi ((__v2di)(__m128i)(X), \
(unsigned int)(I), (unsigned int)(L)))
#endif
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_insert_si64 (__m128i __X,__m128i __Y)
{
return (__m128i) __builtin_ia32_insertq ((__v2di)__X, (__v2di)__Y);
}
#ifdef __OPTIMIZE__
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_inserti_si64(__m128i __X, __m128i __Y, unsigned const int __I, unsigned const int __L)
{
return (__m128i) __builtin_ia32_insertqi ((__v2di)__X, (__v2di)__Y, __I, __L);
}
#else
#define _mm_inserti_si64(X, Y, I, L) \
((__m128i) __builtin_ia32_insertqi ((__v2di)(__m128i)(X), \
(__v2di)(__m128i)(Y), \
(unsigned int)(I), (unsigned int)(L)))
#endif
#ifdef __DISABLE_SSE4A__
#undef __DISABLE_SSE4A__
#pragma GCC pop_options
#endif /* __DISABLE_SSE4A__ */
#endif /* _AMMINTRIN_H_INCLUDED */
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,216 @@
/* Copyright (C) 2015-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#if !defined _IMMINTRIN_H_INCLUDED
# error "Never use <avx5124fmapsintrin.h> directly; include <x86intrin.h> instead."
#endif
#ifndef _AVX5124FMAPSINTRIN_H_INCLUDED
#define _AVX5124FMAPSINTRIN_H_INCLUDED
#ifndef __AVX5124FMAPS__
#pragma GCC push_options
//#pragma GCC target("avx5124fmaps")
#define __DISABLE_AVX5124FMAPS__
#endif /* __AVX5124FMAPS__ */
extern __inline __m512
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm512_4fmadd_ps (__m512 __A, __m512 __B, __m512 __C,
__m512 __D, __m512 __E, __m128 *__F)
{
return (__m512) __builtin_ia32_4fmaddps ((__v16sf) __B,
(__v16sf) __C,
(__v16sf) __D,
(__v16sf) __E,
(__v16sf) __A,
(const __v4sf *) __F);
}
extern __inline __m512
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask_4fmadd_ps (__m512 __A, __mmask16 __U, __m512 __B,
__m512 __C, __m512 __D, __m512 __E, __m128 *__F)
{
return (__m512) __builtin_ia32_4fmaddps_mask ((__v16sf) __B,
(__v16sf) __C,
(__v16sf) __D,
(__v16sf) __E,
(__v16sf) __A,
(const __v4sf *) __F,
(__v16sf) __A,
(__mmask16) __U);
}
extern __inline __m512
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm512_maskz_4fmadd_ps (__mmask16 __U,
__m512 __A, __m512 __B, __m512 __C,
__m512 __D, __m512 __E, __m128 *__F)
{
return (__m512) __builtin_ia32_4fmaddps_mask ((__v16sf) __B,
(__v16sf) __C,
(__v16sf) __D,
(__v16sf) __E,
(__v16sf) __A,
(const __v4sf *) __F,
(__v16sf) _mm512_setzero_ps (),
(__mmask16) __U);
}
extern __inline __m128
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_4fmadd_ss (__m128 __A, __m128 __B, __m128 __C,
__m128 __D, __m128 __E, __m128 *__F)
{
return (__m128) __builtin_ia32_4fmaddss ((__v4sf) __B,
(__v4sf) __C,
(__v4sf) __D,
(__v4sf) __E,
(__v4sf) __A,
(const __v4sf *) __F);
}
extern __inline __m128
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_mask_4fmadd_ss (__m128 __A, __mmask8 __U, __m128 __B, __m128 __C,
__m128 __D, __m128 __E, __m128 *__F)
{
return (__m128) __builtin_ia32_4fmaddss_mask ((__v4sf) __B,
(__v4sf) __C,
(__v4sf) __D,
(__v4sf) __E,
(__v4sf) __A,
(const __v4sf *) __F,
(__v4sf) __A,
(__mmask8) __U);
}
extern __inline __m128
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_maskz_4fmadd_ss (__mmask8 __U, __m128 __A, __m128 __B, __m128 __C,
__m128 __D, __m128 __E, __m128 *__F)
{
return (__m128) __builtin_ia32_4fmaddss_mask ((__v4sf) __B,
(__v4sf) __C,
(__v4sf) __D,
(__v4sf) __E,
(__v4sf) __A,
(const __v4sf *) __F,
(__v4sf) _mm_setzero_ps (),
(__mmask8) __U);
}
extern __inline __m512
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm512_4fnmadd_ps (__m512 __A, __m512 __B, __m512 __C,
__m512 __D, __m512 __E, __m128 *__F)
{
return (__m512) __builtin_ia32_4fnmaddps ((__v16sf) __B,
(__v16sf) __C,
(__v16sf) __D,
(__v16sf) __E,
(__v16sf) __A,
(const __v4sf *) __F);
}
extern __inline __m512
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask_4fnmadd_ps (__m512 __A, __mmask16 __U, __m512 __B,
__m512 __C, __m512 __D, __m512 __E, __m128 *__F)
{
return (__m512) __builtin_ia32_4fnmaddps_mask ((__v16sf) __B,
(__v16sf) __C,
(__v16sf) __D,
(__v16sf) __E,
(__v16sf) __A,
(const __v4sf *) __F,
(__v16sf) __A,
(__mmask16) __U);
}
extern __inline __m512
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm512_maskz_4fnmadd_ps (__mmask16 __U,
__m512 __A, __m512 __B, __m512 __C,
__m512 __D, __m512 __E, __m128 *__F)
{
return (__m512) __builtin_ia32_4fnmaddps_mask ((__v16sf) __B,
(__v16sf) __C,
(__v16sf) __D,
(__v16sf) __E,
(__v16sf) __A,
(const __v4sf *) __F,
(__v16sf) _mm512_setzero_ps (),
(__mmask16) __U);
}
extern __inline __m128
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_4fnmadd_ss (__m128 __A, __m128 __B, __m128 __C,
__m128 __D, __m128 __E, __m128 *__F)
{
return (__m128) __builtin_ia32_4fnmaddss ((__v4sf) __B,
(__v4sf) __C,
(__v4sf) __D,
(__v4sf) __E,
(__v4sf) __A,
(const __v4sf *) __F);
}
extern __inline __m128
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_mask_4fnmadd_ss (__m128 __A, __mmask8 __U, __m128 __B, __m128 __C,
__m128 __D, __m128 __E, __m128 *__F)
{
return (__m128) __builtin_ia32_4fnmaddss_mask ((__v4sf) __B,
(__v4sf) __C,
(__v4sf) __D,
(__v4sf) __E,
(__v4sf) __A,
(const __v4sf *) __F,
(__v4sf) __A,
(__mmask8) __U);
}
extern __inline __m128
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_maskz_4fnmadd_ss (__mmask8 __U, __m128 __A, __m128 __B, __m128 __C,
__m128 __D, __m128 __E, __m128 *__F)
{
return (__m128) __builtin_ia32_4fnmaddss_mask ((__v4sf) __B,
(__v4sf) __C,
(__v4sf) __D,
(__v4sf) __E,
(__v4sf) __A,
(const __v4sf *) __F,
(__v4sf) _mm_setzero_ps (),
(__mmask8) __U);
}
#ifdef __DISABLE_AVX5124FMAPS__
#undef __DISABLE_AVX5124FMAPS__
#pragma GCC pop_options
#endif /* __DISABLE_AVX5124FMAPS__ */
#endif /* _AVX5124FMAPSINTRIN_H_INCLUDED */
@@ -0,0 +1,132 @@
/* Copyright (C) 2015-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#if !defined _IMMINTRIN_H_INCLUDED
# error "Never use <avx5124vnniwintrin.h> directly; include <x86intrin.h> instead."
#endif
#ifndef _AVX5124VNNIWINTRIN_H_INCLUDED
#define _AVX5124VNNIWINTRIN_H_INCLUDED
#ifndef __AVX5124VNNIW__
#pragma GCC push_options
//#pragma GCC target("avx5124vnniw")
#define __DISABLE_AVX5124VNNIW__
#endif /* __AVX5124VNNIW__ */
extern __inline __m512i
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm512_4dpwssd_epi32 (__m512i __A, __m512i __B, __m512i __C,
__m512i __D, __m512i __E, __m128i *__F)
{
return (__m512i) __builtin_ia32_vp4dpwssd ((__v16si) __B,
(__v16si) __C,
(__v16si) __D,
(__v16si) __E,
(__v16si) __A,
(const __v4si *) __F);
}
extern __inline __m512i
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask_4dpwssd_epi32 (__m512i __A, __mmask16 __U, __m512i __B,
__m512i __C, __m512i __D, __m512i __E,
__m128i *__F)
{
return (__m512i) __builtin_ia32_vp4dpwssd_mask ((__v16si) __B,
(__v16si) __C,
(__v16si) __D,
(__v16si) __E,
(__v16si) __A,
(const __v4si *) __F,
(__v16si) __A,
(__mmask16) __U);
}
extern __inline __m512i
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm512_maskz_4dpwssd_epi32 (__mmask16 __U, __m512i __A, __m512i __B,
__m512i __C, __m512i __D, __m512i __E,
__m128i *__F)
{
return (__m512i) __builtin_ia32_vp4dpwssd_mask ((__v16si) __B,
(__v16si) __C,
(__v16si) __D,
(__v16si) __E,
(__v16si) __A,
(const __v4si *) __F,
(__v16si) _mm512_setzero_ps (),
(__mmask16) __U);
}
extern __inline __m512i
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm512_4dpwssds_epi32 (__m512i __A, __m512i __B, __m512i __C,
__m512i __D, __m512i __E, __m128i *__F)
{
return (__m512i) __builtin_ia32_vp4dpwssds ((__v16si) __B,
(__v16si) __C,
(__v16si) __D,
(__v16si) __E,
(__v16si) __A,
(const __v4si *) __F);
}
extern __inline __m512i
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask_4dpwssds_epi32 (__m512i __A, __mmask16 __U, __m512i __B,
__m512i __C, __m512i __D, __m512i __E,
__m128i *__F)
{
return (__m512i) __builtin_ia32_vp4dpwssds_mask ((__v16si) __B,
(__v16si) __C,
(__v16si) __D,
(__v16si) __E,
(__v16si) __A,
(const __v4si *) __F,
(__v16si) __A,
(__mmask16) __U);
}
extern __inline __m512i
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm512_maskz_4dpwssds_epi32 (__mmask16 __U, __m512i __A, __m512i __B,
__m512i __C, __m512i __D, __m512i __E,
__m128i *__F)
{
return (__m512i) __builtin_ia32_vp4dpwssds_mask ((__v16si) __B,
(__v16si) __C,
(__v16si) __D,
(__v16si) __E,
(__v16si) __A,
(const __v4si *) __F,
(__v16si) _mm512_setzero_ps (),
(__mmask16) __U);
}
#ifdef __DISABLE_AVX5124VNNIW__
#undef __DISABLE_AVX5124VNNIW__
#pragma GCC pop_options
#endif /* __DISABLE_AVX5124VNNIW__ */
#endif /* _AVX5124VNNIWINTRIN_H_INCLUDED */
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,184 @@
/* Copyright (C) 2013-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _IMMINTRIN_H_INCLUDED
#error "Never use <avx512cdintrin.h> directly; include <immintrin.h> instead."
#endif
#ifndef _AVX512CDINTRIN_H_INCLUDED
#define _AVX512CDINTRIN_H_INCLUDED
#ifndef __AVX512CD__
#pragma GCC push_options
//#pragma GCC target("avx512cd")
#define __DISABLE_AVX512CD__
#endif /* __AVX512CD__ */
/* Internal data types for implementing the intrinsics. */
typedef long long __v8di __attribute__ ((__vector_size__ (64)));
typedef int __v16si __attribute__ ((__vector_size__ (64)));
/* The Intel API is flexible enough that we must allow aliasing with other
vector types, and their scalar components. */
typedef long long __m512i __attribute__ ((__vector_size__ (64), __may_alias__));
typedef double __m512d __attribute__ ((__vector_size__ (64), __may_alias__));
typedef unsigned char __mmask8;
typedef unsigned short __mmask16;
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_conflict_epi32 (__m512i __A)
{
return (__m512i)
__builtin_ia32_vpconflictsi_512_mask ((__v16si) __A,
(__v16si) _mm512_setzero_si512 (),
(__mmask16) -1);
}
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask_conflict_epi32 (__m512i __W, __mmask16 __U, __m512i __A)
{
return (__m512i) __builtin_ia32_vpconflictsi_512_mask ((__v16si) __A,
(__v16si) __W,
(__mmask16) __U);
}
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_maskz_conflict_epi32 (__mmask16 __U, __m512i __A)
{
return (__m512i)
__builtin_ia32_vpconflictsi_512_mask ((__v16si) __A,
(__v16si) _mm512_setzero_si512 (),
(__mmask16) __U);
}
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_conflict_epi64 (__m512i __A)
{
return (__m512i)
__builtin_ia32_vpconflictdi_512_mask ((__v8di) __A,
(__v8di) _mm512_setzero_si512 (),
(__mmask8) -1);
}
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask_conflict_epi64 (__m512i __W, __mmask8 __U, __m512i __A)
{
return (__m512i) __builtin_ia32_vpconflictdi_512_mask ((__v8di) __A,
(__v8di) __W,
(__mmask8) __U);
}
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_maskz_conflict_epi64 (__mmask8 __U, __m512i __A)
{
return (__m512i)
__builtin_ia32_vpconflictdi_512_mask ((__v8di) __A,
(__v8di) _mm512_setzero_si512 (),
(__mmask8) __U);
}
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_lzcnt_epi64 (__m512i __A)
{
return (__m512i)
__builtin_ia32_vplzcntq_512_mask ((__v8di) __A,
(__v8di) _mm512_setzero_si512 (),
(__mmask8) -1);
}
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask_lzcnt_epi64 (__m512i __W, __mmask8 __U, __m512i __A)
{
return (__m512i) __builtin_ia32_vplzcntq_512_mask ((__v8di) __A,
(__v8di) __W,
(__mmask8) __U);
}
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_maskz_lzcnt_epi64 (__mmask8 __U, __m512i __A)
{
return (__m512i)
__builtin_ia32_vplzcntq_512_mask ((__v8di) __A,
(__v8di) _mm512_setzero_si512 (),
(__mmask8) __U);
}
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_lzcnt_epi32 (__m512i __A)
{
return (__m512i)
__builtin_ia32_vplzcntd_512_mask ((__v16si) __A,
(__v16si) _mm512_setzero_si512 (),
(__mmask16) -1);
}
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask_lzcnt_epi32 (__m512i __W, __mmask16 __U, __m512i __A)
{
return (__m512i) __builtin_ia32_vplzcntd_512_mask ((__v16si) __A,
(__v16si) __W,
(__mmask16) __U);
}
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_maskz_lzcnt_epi32 (__mmask16 __U, __m512i __A)
{
return (__m512i)
__builtin_ia32_vplzcntd_512_mask ((__v16si) __A,
(__v16si) _mm512_setzero_si512 (),
(__mmask16) __U);
}
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_broadcastmb_epi64 (__mmask8 __A)
{
return (__m512i) __builtin_ia32_broadcastmb512 (__A);
}
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_broadcastmw_epi32 (__mmask16 __A)
{
return (__m512i) __builtin_ia32_broadcastmw512 (__A);
}
#ifdef __DISABLE_AVX512CD__
#undef __DISABLE_AVX512CD__
#pragma GCC pop_options
#endif /* __DISABLE_AVX512CD__ */
#endif /* _AVX512CDINTRIN_H_INCLUDED */
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,394 @@
/* Copyright (C) 2013-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _IMMINTRIN_H_INCLUDED
#error "Never use <avx512erintrin.h> directly; include <immintrin.h> instead."
#endif
#ifndef _AVX512ERINTRIN_H_INCLUDED
#define _AVX512ERINTRIN_H_INCLUDED
#ifndef __AVX512ER__
//#pragma GCC push_options
#pragma GCC target("avx512er")
#define __DISABLE_AVX512ER__
#endif /* __AVX512ER__ */
/* Internal data types for implementing the intrinsics. */
typedef double __v8df __attribute__ ((__vector_size__ (64)));
typedef float __v16sf __attribute__ ((__vector_size__ (64)));
/* The Intel API is flexible enough that we must allow aliasing with other
vector types, and their scalar components. */
typedef float __m512 __attribute__ ((__vector_size__ (64), __may_alias__));
typedef double __m512d __attribute__ ((__vector_size__ (64), __may_alias__));
typedef unsigned char __mmask8;
typedef unsigned short __mmask16;
#ifdef __OPTIMIZE__
extern __inline __m512d
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_exp2a23_round_pd (__m512d __A, int __R)
{
__m512d __W;
return (__m512d) __builtin_ia32_exp2pd_mask ((__v8df) __A,
(__v8df) __W,
(__mmask8) -1, __R);
}
extern __inline __m512d
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask_exp2a23_round_pd (__m512d __W, __mmask8 __U, __m512d __A, int __R)
{
return (__m512d) __builtin_ia32_exp2pd_mask ((__v8df) __A,
(__v8df) __W,
(__mmask8) __U, __R);
}
extern __inline __m512d
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_maskz_exp2a23_round_pd (__mmask8 __U, __m512d __A, int __R)
{
return (__m512d) __builtin_ia32_exp2pd_mask ((__v8df) __A,
(__v8df) _mm512_setzero_pd (),
(__mmask8) __U, __R);
}
extern __inline __m512
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_exp2a23_round_ps (__m512 __A, int __R)
{
__m512 __W;
return (__m512) __builtin_ia32_exp2ps_mask ((__v16sf) __A,
(__v16sf) __W,
(__mmask16) -1, __R);
}
extern __inline __m512
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask_exp2a23_round_ps (__m512 __W, __mmask16 __U, __m512 __A, int __R)
{
return (__m512) __builtin_ia32_exp2ps_mask ((__v16sf) __A,
(__v16sf) __W,
(__mmask16) __U, __R);
}
extern __inline __m512
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_maskz_exp2a23_round_ps (__mmask16 __U, __m512 __A, int __R)
{
return (__m512) __builtin_ia32_exp2ps_mask ((__v16sf) __A,
(__v16sf) _mm512_setzero_ps (),
(__mmask16) __U, __R);
}
extern __inline __m512d
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_rcp28_round_pd (__m512d __A, int __R)
{
__m512d __W;
return (__m512d) __builtin_ia32_rcp28pd_mask ((__v8df) __A,
(__v8df) __W,
(__mmask8) -1, __R);
}
extern __inline __m512d
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask_rcp28_round_pd (__m512d __W, __mmask8 __U, __m512d __A, int __R)
{
return (__m512d) __builtin_ia32_rcp28pd_mask ((__v8df) __A,
(__v8df) __W,
(__mmask8) __U, __R);
}
extern __inline __m512d
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_maskz_rcp28_round_pd (__mmask8 __U, __m512d __A, int __R)
{
return (__m512d) __builtin_ia32_rcp28pd_mask ((__v8df) __A,
(__v8df) _mm512_setzero_pd (),
(__mmask8) __U, __R);
}
extern __inline __m512
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_rcp28_round_ps (__m512 __A, int __R)
{
__m512 __W;
return (__m512) __builtin_ia32_rcp28ps_mask ((__v16sf) __A,
(__v16sf) __W,
(__mmask16) -1, __R);
}
extern __inline __m512
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask_rcp28_round_ps (__m512 __W, __mmask16 __U, __m512 __A, int __R)
{
return (__m512) __builtin_ia32_rcp28ps_mask ((__v16sf) __A,
(__v16sf) __W,
(__mmask16) __U, __R);
}
extern __inline __m512
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_maskz_rcp28_round_ps (__mmask16 __U, __m512 __A, int __R)
{
return (__m512) __builtin_ia32_rcp28ps_mask ((__v16sf) __A,
(__v16sf) _mm512_setzero_ps (),
(__mmask16) __U, __R);
}
extern __inline __m128d
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_rcp28_round_sd (__m128d __A, __m128d __B, int __R)
{
return (__m128d) __builtin_ia32_rcp28sd_round ((__v2df) __B,
(__v2df) __A,
__R);
}
extern __inline __m128
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_rcp28_round_ss (__m128 __A, __m128 __B, int __R)
{
return (__m128) __builtin_ia32_rcp28ss_round ((__v4sf) __B,
(__v4sf) __A,
__R);
}
extern __inline __m512d
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_rsqrt28_round_pd (__m512d __A, int __R)
{
__m512d __W;
return (__m512d) __builtin_ia32_rsqrt28pd_mask ((__v8df) __A,
(__v8df) __W,
(__mmask8) -1, __R);
}
extern __inline __m512d
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask_rsqrt28_round_pd (__m512d __W, __mmask8 __U, __m512d __A, int __R)
{
return (__m512d) __builtin_ia32_rsqrt28pd_mask ((__v8df) __A,
(__v8df) __W,
(__mmask8) __U, __R);
}
extern __inline __m512d
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_maskz_rsqrt28_round_pd (__mmask8 __U, __m512d __A, int __R)
{
return (__m512d) __builtin_ia32_rsqrt28pd_mask ((__v8df) __A,
(__v8df) _mm512_setzero_pd (),
(__mmask8) __U, __R);
}
extern __inline __m512
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_rsqrt28_round_ps (__m512 __A, int __R)
{
__m512 __W;
return (__m512) __builtin_ia32_rsqrt28ps_mask ((__v16sf) __A,
(__v16sf) __W,
(__mmask16) -1, __R);
}
extern __inline __m512
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask_rsqrt28_round_ps (__m512 __W, __mmask16 __U, __m512 __A, int __R)
{
return (__m512) __builtin_ia32_rsqrt28ps_mask ((__v16sf) __A,
(__v16sf) __W,
(__mmask16) __U, __R);
}
extern __inline __m512
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_maskz_rsqrt28_round_ps (__mmask16 __U, __m512 __A, int __R)
{
return (__m512) __builtin_ia32_rsqrt28ps_mask ((__v16sf) __A,
(__v16sf) _mm512_setzero_ps (),
(__mmask16) __U, __R);
}
extern __inline __m128d
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_rsqrt28_round_sd (__m128d __A, __m128d __B, int __R)
{
return (__m128d) __builtin_ia32_rsqrt28sd_round ((__v2df) __B,
(__v2df) __A,
__R);
}
extern __inline __m128
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_rsqrt28_round_ss (__m128 __A, __m128 __B, int __R)
{
return (__m128) __builtin_ia32_rsqrt28ss_round ((__v4sf) __B,
(__v4sf) __A,
__R);
}
#else
#define _mm512_exp2a23_round_pd(A, C) \
__builtin_ia32_exp2pd_mask(A, (__v8df)_mm512_setzero_pd(), -1, C)
#define _mm512_mask_exp2a23_round_pd(W, U, A, C) \
__builtin_ia32_exp2pd_mask(A, W, U, C)
#define _mm512_maskz_exp2a23_round_pd(U, A, C) \
__builtin_ia32_exp2pd_mask(A, (__v8df)_mm512_setzero_pd(), U, C)
#define _mm512_exp2a23_round_ps(A, C) \
__builtin_ia32_exp2ps_mask(A, (__v16sf)_mm512_setzero_ps(), -1, C)
#define _mm512_mask_exp2a23_round_ps(W, U, A, C) \
__builtin_ia32_exp2ps_mask(A, W, U, C)
#define _mm512_maskz_exp2a23_round_ps(U, A, C) \
__builtin_ia32_exp2ps_mask(A, (__v16sf)_mm512_setzero_ps(), U, C)
#define _mm512_rcp28_round_pd(A, C) \
__builtin_ia32_rcp28pd_mask(A, (__v8df)_mm512_setzero_pd(), -1, C)
#define _mm512_mask_rcp28_round_pd(W, U, A, C) \
__builtin_ia32_rcp28pd_mask(A, W, U, C)
#define _mm512_maskz_rcp28_round_pd(U, A, C) \
__builtin_ia32_rcp28pd_mask(A, (__v8df)_mm512_setzero_pd(), U, C)
#define _mm512_rcp28_round_ps(A, C) \
__builtin_ia32_rcp28ps_mask(A, (__v16sf)_mm512_setzero_ps(), -1, C)
#define _mm512_mask_rcp28_round_ps(W, U, A, C) \
__builtin_ia32_rcp28ps_mask(A, W, U, C)
#define _mm512_maskz_rcp28_round_ps(U, A, C) \
__builtin_ia32_rcp28ps_mask(A, (__v16sf)_mm512_setzero_ps(), U, C)
#define _mm512_rsqrt28_round_pd(A, C) \
__builtin_ia32_rsqrt28pd_mask(A, (__v8df)_mm512_setzero_pd(), -1, C)
#define _mm512_mask_rsqrt28_round_pd(W, U, A, C) \
__builtin_ia32_rsqrt28pd_mask(A, W, U, C)
#define _mm512_maskz_rsqrt28_round_pd(U, A, C) \
__builtin_ia32_rsqrt28pd_mask(A, (__v8df)_mm512_setzero_pd(), U, C)
#define _mm512_rsqrt28_round_ps(A, C) \
__builtin_ia32_rsqrt28ps_mask(A, (__v16sf)_mm512_setzero_ps(), -1, C)
#define _mm512_mask_rsqrt28_round_ps(W, U, A, C) \
__builtin_ia32_rsqrt28ps_mask(A, W, U, C)
#define _mm512_maskz_rsqrt28_round_ps(U, A, C) \
__builtin_ia32_rsqrt28ps_mask(A, (__v16sf)_mm512_setzero_ps(), U, C)
#define _mm_rcp28_round_sd(A, B, R) \
__builtin_ia32_rcp28sd_round(A, B, R)
#define _mm_rcp28_round_ss(A, B, R) \
__builtin_ia32_rcp28ss_round(A, B, R)
#define _mm_rsqrt28_round_sd(A, B, R) \
__builtin_ia32_rsqrt28sd_round(A, B, R)
#define _mm_rsqrt28_round_ss(A, B, R) \
__builtin_ia32_rsqrt28ss_round(A, B, R)
#endif
#define _mm512_exp2a23_pd(A) \
_mm512_exp2a23_round_pd(A, _MM_FROUND_CUR_DIRECTION)
#define _mm512_mask_exp2a23_pd(W, U, A) \
_mm512_mask_exp2a23_round_pd(W, U, A, _MM_FROUND_CUR_DIRECTION)
#define _mm512_maskz_exp2a23_pd(U, A) \
_mm512_maskz_exp2a23_round_pd(U, A, _MM_FROUND_CUR_DIRECTION)
#define _mm512_exp2a23_ps(A) \
_mm512_exp2a23_round_ps(A, _MM_FROUND_CUR_DIRECTION)
#define _mm512_mask_exp2a23_ps(W, U, A) \
_mm512_mask_exp2a23_round_ps(W, U, A, _MM_FROUND_CUR_DIRECTION)
#define _mm512_maskz_exp2a23_ps(U, A) \
_mm512_maskz_exp2a23_round_ps(U, A, _MM_FROUND_CUR_DIRECTION)
#define _mm512_rcp28_pd(A) \
_mm512_rcp28_round_pd(A, _MM_FROUND_CUR_DIRECTION)
#define _mm512_mask_rcp28_pd(W, U, A) \
_mm512_mask_rcp28_round_pd(W, U, A, _MM_FROUND_CUR_DIRECTION)
#define _mm512_maskz_rcp28_pd(U, A) \
_mm512_maskz_rcp28_round_pd(U, A, _MM_FROUND_CUR_DIRECTION)
#define _mm512_rcp28_ps(A) \
_mm512_rcp28_round_ps(A, _MM_FROUND_CUR_DIRECTION)
#define _mm512_mask_rcp28_ps(W, U, A) \
_mm512_mask_rcp28_round_ps(W, U, A, _MM_FROUND_CUR_DIRECTION)
#define _mm512_maskz_rcp28_ps(U, A) \
_mm512_maskz_rcp28_round_ps(U, A, _MM_FROUND_CUR_DIRECTION)
#define _mm512_rsqrt28_pd(A) \
_mm512_rsqrt28_round_pd(A, _MM_FROUND_CUR_DIRECTION)
#define _mm512_mask_rsqrt28_pd(W, U, A) \
_mm512_mask_rsqrt28_round_pd(W, U, A, _MM_FROUND_CUR_DIRECTION)
#define _mm512_maskz_rsqrt28_pd(U, A) \
_mm512_maskz_rsqrt28_round_pd(U, A, _MM_FROUND_CUR_DIRECTION)
#define _mm512_rsqrt28_ps(A) \
_mm512_rsqrt28_round_ps(A, _MM_FROUND_CUR_DIRECTION)
#define _mm512_mask_rsqrt28_ps(W, U, A) \
_mm512_mask_rsqrt28_round_ps(W, U, A, _MM_FROUND_CUR_DIRECTION)
#define _mm512_maskz_rsqrt28_ps(U, A) \
_mm512_maskz_rsqrt28_round_ps(U, A, _MM_FROUND_CUR_DIRECTION)
#define _mm_rcp28_sd(A, B) \
__builtin_ia32_rcp28sd_round(B, A, _MM_FROUND_CUR_DIRECTION)
#define _mm_rcp28_ss(A, B) \
__builtin_ia32_rcp28ss_round(B, A, _MM_FROUND_CUR_DIRECTION)
#define _mm_rsqrt28_sd(A, B) \
__builtin_ia32_rsqrt28sd_round(B, A, _MM_FROUND_CUR_DIRECTION)
#define _mm_rsqrt28_ss(A, B) \
__builtin_ia32_rsqrt28ss_round(B, A, _MM_FROUND_CUR_DIRECTION)
#ifdef __DISABLE_AVX512ER__
#undef __DISABLE_AVX512ER__
#pragma GCC pop_options
#endif /* __DISABLE_AVX512ER__ */
#endif /* _AVX512ERINTRIN_H_INCLUDED */
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,104 @@
/* Copyright (C) 2013-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _IMMINTRIN_H_INCLUDED
#error "Never use <avx512ifmaintrin.h> directly; include <immintrin.h> instead."
#endif
#ifndef _AVX512IFMAINTRIN_H_INCLUDED
#define _AVX512IFMAINTRIN_H_INCLUDED
#ifndef __AVX512IFMA__
#pragma GCC push_options
//#pragma GCC target("avx512ifma")
#define __DISABLE_AVX512IFMA__
#endif /* __AVX512IFMA__ */
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_madd52lo_epu64 (__m512i __X, __m512i __Y, __m512i __Z)
{
return (__m512i) __builtin_ia32_vpmadd52luq512_mask ((__v8di) __X,
(__v8di) __Y,
(__v8di) __Z,
(__mmask8) -1);
}
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_madd52hi_epu64 (__m512i __X, __m512i __Y, __m512i __Z)
{
return (__m512i) __builtin_ia32_vpmadd52huq512_mask ((__v8di) __X,
(__v8di) __Y,
(__v8di) __Z,
(__mmask8) -1);
}
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask_madd52lo_epu64 (__m512i __W, __mmask8 __M, __m512i __X,
__m512i __Y)
{
return (__m512i) __builtin_ia32_vpmadd52luq512_mask ((__v8di) __W,
(__v8di) __X,
(__v8di) __Y,
(__mmask8) __M);
}
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask_madd52hi_epu64 (__m512i __W, __mmask8 __M, __m512i __X,
__m512i __Y)
{
return (__m512i) __builtin_ia32_vpmadd52huq512_mask ((__v8di) __W,
(__v8di) __X,
(__v8di) __Y,
(__mmask8) __M);
}
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_maskz_madd52lo_epu64 (__mmask8 __M, __m512i __X, __m512i __Y, __m512i __Z)
{
return (__m512i) __builtin_ia32_vpmadd52luq512_maskz ((__v8di) __X,
(__v8di) __Y,
(__v8di) __Z,
(__mmask8) __M);
}
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_maskz_madd52hi_epu64 (__mmask8 __M, __m512i __X, __m512i __Y, __m512i __Z)
{
return (__m512i) __builtin_ia32_vpmadd52huq512_maskz ((__v8di) __X,
(__v8di) __Y,
(__v8di) __Z,
(__mmask8) __M);
}
#ifdef __DISABLE_AVX512IFMA__
#undef __DISABLE_AVX512IFMA__
#pragma GCC pop_options
#endif /* __DISABLE_AVX512IFMA__ */
#endif /* _AVX512IFMAINTRIN_H_INCLUDED */
@@ -0,0 +1,164 @@
/* Copyright (C) 2013-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _IMMINTRIN_H_INCLUDED
#error "Never use <avx512ifmavlintrin.h> directly; include <immintrin.h> instead."
#endif
#ifndef _AVX512IFMAVLINTRIN_H_INCLUDED
#define _AVX512IFMAVLINTRIN_H_INCLUDED
#if !defined(__AVX512VL__) || !defined(__AVX512IFMA__)
#pragma GCC push_options
//#pragma GCC target("avx512ifma,avx512vl")
#define __DISABLE_AVX512IFMAVL__
#endif /* __AVX512IFMAVL__ */
extern __inline __m128i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_madd52lo_epu64 (__m128i __X, __m128i __Y, __m128i __Z)
{
return (__m128i) __builtin_ia32_vpmadd52luq128_mask ((__v2di) __X,
(__v2di) __Y,
(__v2di) __Z,
(__mmask8) -1);
}
extern __inline __m128i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_madd52hi_epu64 (__m128i __X, __m128i __Y, __m128i __Z)
{
return (__m128i) __builtin_ia32_vpmadd52huq128_mask ((__v2di) __X,
(__v2di) __Y,
(__v2di) __Z,
(__mmask8) -1);
}
extern __inline __m256i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm256_madd52lo_epu64 (__m256i __X, __m256i __Y, __m256i __Z)
{
return (__m256i) __builtin_ia32_vpmadd52luq256_mask ((__v4di) __X,
(__v4di) __Y,
(__v4di) __Z,
(__mmask8) -1);
}
extern __inline __m256i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm256_madd52hi_epu64 (__m256i __X, __m256i __Y, __m256i __Z)
{
return (__m256i) __builtin_ia32_vpmadd52huq256_mask ((__v4di) __X,
(__v4di) __Y,
(__v4di) __Z,
(__mmask8) -1);
}
extern __inline __m128i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_mask_madd52lo_epu64 (__m128i __W, __mmask8 __M, __m128i __X, __m128i __Y)
{
return (__m128i) __builtin_ia32_vpmadd52luq128_mask ((__v2di) __W,
(__v2di) __X,
(__v2di) __Y,
(__mmask8) __M);
}
extern __inline __m128i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_mask_madd52hi_epu64 (__m128i __W, __mmask8 __M, __m128i __X, __m128i __Y)
{
return (__m128i) __builtin_ia32_vpmadd52huq128_mask ((__v2di) __W,
(__v2di) __X,
(__v2di) __Y,
(__mmask8) __M);
}
extern __inline __m256i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm256_mask_madd52lo_epu64 (__m256i __W, __mmask8 __M, __m256i __X,
__m256i __Y)
{
return (__m256i) __builtin_ia32_vpmadd52luq256_mask ((__v4di) __W,
(__v4di) __X,
(__v4di) __Y,
(__mmask8) __M);
}
extern __inline __m256i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm256_mask_madd52hi_epu64 (__m256i __W, __mmask8 __M, __m256i __X,
__m256i __Y)
{
return (__m256i) __builtin_ia32_vpmadd52huq256_mask ((__v4di) __W,
(__v4di) __X,
(__v4di) __Y,
(__mmask8) __M);
}
extern __inline __m128i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_maskz_madd52lo_epu64 (__mmask8 __M, __m128i __X, __m128i __Y, __m128i __Z)
{
return (__m128i) __builtin_ia32_vpmadd52luq128_maskz ((__v2di) __X,
(__v2di) __Y,
(__v2di) __Z,
(__mmask8) __M);
}
extern __inline __m128i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_maskz_madd52hi_epu64 (__mmask8 __M, __m128i __X, __m128i __Y, __m128i __Z)
{
return (__m128i) __builtin_ia32_vpmadd52huq128_maskz ((__v2di) __X,
(__v2di) __Y,
(__v2di) __Z,
(__mmask8) __M);
}
extern __inline __m256i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm256_maskz_madd52lo_epu64 (__mmask8 __M, __m256i __X, __m256i __Y, __m256i __Z)
{
return (__m256i) __builtin_ia32_vpmadd52luq256_maskz ((__v4di) __X,
(__v4di) __Y,
(__v4di) __Z,
(__mmask8) __M);
}
extern __inline __m256i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm256_maskz_madd52hi_epu64 (__mmask8 __M, __m256i __X, __m256i __Y, __m256i __Z)
{
return (__m256i) __builtin_ia32_vpmadd52huq256_maskz ((__v4di) __X,
(__v4di) __Y,
(__v4di) __Z,
(__mmask8) __M);
}
#ifdef __DISABLE_AVX512IFMAVL__
#undef __DISABLE_AVX512IFMAVL__
#pragma GCC pop_options
#endif /* __DISABLE_AVX512IFMAVL__ */
#endif /* _AVX512IFMAVLINTRIN_H_INCLUDED */
@@ -0,0 +1,264 @@
/* Copyright (C) 2013-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _IMMINTRIN_H_INCLUDED
#error "Never use <avx512pfintrin.h> directly; include <immintrin.h> instead."
#endif
#ifndef _AVX512PFINTRIN_H_INCLUDED
#define _AVX512PFINTRIN_H_INCLUDED
#ifndef __AVX512PF__
#pragma GCC push_options
//#pragma GCC target("avx512pf")
#define __DISABLE_AVX512PF__
#endif /* __AVX512PF__ */
/* Internal data types for implementing the intrinsics. */
typedef long long __v8di __attribute__ ((__vector_size__ (64)));
typedef int __v16si __attribute__ ((__vector_size__ (64)));
/* The Intel API is flexible enough that we must allow aliasing with other
vector types, and their scalar components. */
typedef long long __m512i __attribute__ ((__vector_size__ (64), __may_alias__));
typedef unsigned char __mmask8;
typedef unsigned short __mmask16;
#ifdef __OPTIMIZE__
extern __inline void
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_prefetch_i32gather_pd (__m256i __index, void const *__addr,
int __scale, int __hint)
{
__builtin_ia32_gatherpfdpd ((__mmask8) 0xFF, (__v8si) __index, __addr,
__scale, __hint);
}
extern __inline void
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_prefetch_i32gather_ps (__m512i __index, void const *__addr,
int __scale, int __hint)
{
__builtin_ia32_gatherpfdps ((__mmask16) 0xFFFF, (__v16si) __index, __addr,
__scale, __hint);
}
extern __inline void
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask_prefetch_i32gather_pd (__m256i __index, __mmask8 __mask,
void const *__addr, int __scale, int __hint)
{
__builtin_ia32_gatherpfdpd (__mask, (__v8si) __index, __addr, __scale,
__hint);
}
extern __inline void
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask_prefetch_i32gather_ps (__m512i __index, __mmask16 __mask,
void const *__addr, int __scale, int __hint)
{
__builtin_ia32_gatherpfdps (__mask, (__v16si) __index, __addr, __scale,
__hint);
}
extern __inline void
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_prefetch_i64gather_pd (__m512i __index, void const *__addr,
int __scale, int __hint)
{
__builtin_ia32_gatherpfqpd ((__mmask8) 0xFF, (__v8di) __index, __addr,
__scale, __hint);
}
extern __inline void
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_prefetch_i64gather_ps (__m512i __index, void const *__addr,
int __scale, int __hint)
{
__builtin_ia32_gatherpfqps ((__mmask8) 0xFF, (__v8di) __index, __addr,
__scale, __hint);
}
extern __inline void
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask_prefetch_i64gather_pd (__m512i __index, __mmask8 __mask,
void const *__addr, int __scale, int __hint)
{
__builtin_ia32_gatherpfqpd (__mask, (__v8di) __index, __addr, __scale,
__hint);
}
extern __inline void
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask_prefetch_i64gather_ps (__m512i __index, __mmask8 __mask,
void const *__addr, int __scale, int __hint)
{
__builtin_ia32_gatherpfqps (__mask, (__v8di) __index, __addr, __scale,
__hint);
}
extern __inline void
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_prefetch_i32scatter_pd (void *__addr, __m256i __index, int __scale,
int __hint)
{
__builtin_ia32_scatterpfdpd ((__mmask8) 0xFF, (__v8si) __index, __addr,
__scale, __hint);
}
extern __inline void
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_prefetch_i32scatter_ps (void *__addr, __m512i __index, int __scale,
int __hint)
{
__builtin_ia32_scatterpfdps ((__mmask16) 0xFFFF, (__v16si) __index, __addr,
__scale, __hint);
}
extern __inline void
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask_prefetch_i32scatter_pd (void *__addr, __mmask8 __mask,
__m256i __index, int __scale, int __hint)
{
__builtin_ia32_scatterpfdpd (__mask, (__v8si) __index, __addr, __scale,
__hint);
}
extern __inline void
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask_prefetch_i32scatter_ps (void *__addr, __mmask16 __mask,
__m512i __index, int __scale, int __hint)
{
__builtin_ia32_scatterpfdps (__mask, (__v16si) __index, __addr, __scale,
__hint);
}
extern __inline void
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_prefetch_i64scatter_pd (void *__addr, __m512i __index, int __scale,
int __hint)
{
__builtin_ia32_scatterpfqpd ((__mmask8) 0xFF, (__v8di) __index,__addr,
__scale, __hint);
}
extern __inline void
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_prefetch_i64scatter_ps (void *__addr, __m512i __index, int __scale,
int __hint)
{
__builtin_ia32_scatterpfqps ((__mmask8) 0xFF, (__v8di) __index, __addr,
__scale, __hint);
}
extern __inline void
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask_prefetch_i64scatter_pd (void *__addr, __mmask16 __mask,
__m512i __index, int __scale, int __hint)
{
__builtin_ia32_scatterpfqpd (__mask, (__v8di) __index, __addr, __scale,
__hint);
}
extern __inline void
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask_prefetch_i64scatter_ps (void *__addr, __mmask16 __mask,
__m512i __index, int __scale, int __hint)
{
__builtin_ia32_scatterpfqps (__mask, (__v8di) __index, __addr, __scale,
__hint);
}
#else
#define _mm512_prefetch_i32gather_pd(INDEX, ADDR, SCALE, HINT) \
__builtin_ia32_gatherpfdpd ((__mmask8)0xFF, (__v8si)(__m256i)INDEX, \
(void const *)ADDR, (int)SCALE, (int)HINT)
#define _mm512_prefetch_i32gather_ps(INDEX, ADDR, SCALE, HINT) \
__builtin_ia32_gatherpfdps ((__mmask16)0xFFFF, (__v16si)(__m512i)INDEX, \
(void const *)ADDR, (int)SCALE, (int)HINT)
#define _mm512_mask_prefetch_i32gather_pd(INDEX, MASK, ADDR, SCALE, HINT) \
__builtin_ia32_gatherpfdpd ((__mmask8)MASK, (__v8si)(__m256i)INDEX, \
(void const *)ADDR, (int)SCALE, (int)HINT)
#define _mm512_mask_prefetch_i32gather_ps(INDEX, MASK, ADDR, SCALE, HINT) \
__builtin_ia32_gatherpfdps ((__mmask16)MASK, (__v16si)(__m512i)INDEX, \
(void const *)ADDR, (int)SCALE, (int)HINT)
#define _mm512_prefetch_i64gather_pd(INDEX, ADDR, SCALE, HINT) \
__builtin_ia32_gatherpfqpd ((__mmask8)0xFF, (__v8di)(__m512i)INDEX, \
(void *)ADDR, (int)SCALE, (int)HINT)
#define _mm512_prefetch_i64gather_ps(INDEX, ADDR, SCALE, HINT) \
__builtin_ia32_gatherpfqps ((__mmask8)0xFF, (__v8di)(__m512i)INDEX, \
(void *)ADDR, (int)SCALE, (int)HINT)
#define _mm512_mask_prefetch_i64gather_pd(INDEX, MASK, ADDR, SCALE, HINT) \
__builtin_ia32_gatherpfqpd ((__mmask8)MASK, (__v8di)(__m512i)INDEX, \
(void *)ADDR, (int)SCALE, (int)HINT)
#define _mm512_mask_prefetch_i64gather_ps(INDEX, MASK, ADDR, SCALE, HINT) \
__builtin_ia32_gatherpfqps ((__mmask8)MASK, (__v8di)(__m512i)INDEX, \
(void *)ADDR, (int)SCALE, (int)HINT)
#define _mm512_prefetch_i32scatter_pd(ADDR, INDEX, SCALE, HINT) \
__builtin_ia32_scatterpfdpd ((__mmask8)0xFF, (__v8si)(__m256i)INDEX, \
(void *)ADDR, (int)SCALE, (int)HINT)
#define _mm512_prefetch_i32scatter_ps(ADDR, INDEX, SCALE, HINT) \
__builtin_ia32_scatterpfdps ((__mmask16)0xFFFF, (__v16si)(__m512i)INDEX, \
(void *)ADDR, (int)SCALE, (int)HINT)
#define _mm512_mask_prefetch_i32scatter_pd(ADDR, MASK, INDEX, SCALE, HINT) \
__builtin_ia32_scatterpfdpd ((__mmask8)MASK, (__v8si)(__m256i)INDEX, \
(void *)ADDR, (int)SCALE, (int)HINT)
#define _mm512_mask_prefetch_i32scatter_ps(ADDR, MASK, INDEX, SCALE, HINT) \
__builtin_ia32_scatterpfdps ((__mmask16)MASK, (__v16si)(__m512i)INDEX, \
(void *)ADDR, (int)SCALE, (int)HINT)
#define _mm512_prefetch_i64scatter_pd(ADDR, INDEX, SCALE, HINT) \
__builtin_ia32_scatterpfqpd ((__mmask8)0xFF, (__v8di)(__m512i)INDEX, \
(void *)ADDR, (int)SCALE, (int)HINT)
#define _mm512_prefetch_i64scatter_ps(ADDR, INDEX, SCALE, HINT) \
__builtin_ia32_scatterpfqps ((__mmask8)0xFF, (__v8di)(__m512i)INDEX, \
(void *)ADDR, (int)SCALE, (int)HINT)
#define _mm512_mask_prefetch_i64scatter_pd(ADDR, MASK, INDEX, SCALE, HINT) \
__builtin_ia32_scatterpfqpd ((__mmask8)MASK, (__v8di)(__m512i)INDEX, \
(void *)ADDR, (int)SCALE, (int)HINT)
#define _mm512_mask_prefetch_i64scatter_ps(ADDR, MASK, INDEX, SCALE, HINT) \
__builtin_ia32_scatterpfqps ((__mmask8)MASK, (__v8di)(__m512i)INDEX, \
(void *)ADDR, (int)SCALE, (int)HINT)
#endif
#ifdef __DISABLE_AVX512PF__
#undef __DISABLE_AVX512PF__
#pragma GCC pop_options
#endif /* __DISABLE_AVX512PF__ */
#endif /* _AVX512PFINTRIN_H_INCLUDED */
@@ -0,0 +1,158 @@
/* Copyright (C) 2013-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _IMMINTRIN_H_INCLUDED
#error "Never use <avx512vbmiintrin.h> directly; include <immintrin.h> instead."
#endif
#ifndef _AVX512VBMIINTRIN_H_INCLUDED
#define _AVX512VBMIINTRIN_H_INCLUDED
#ifndef __AVX512VBMI__
#pragma GCC push_options
//#pragma GCC target("avx512vbmi")
#define __DISABLE_AVX512VBMI__
#endif /* __AVX512VBMI__ */
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask_multishift_epi64_epi8 (__m512i __W, __mmask64 __M, __m512i __X, __m512i __Y)
{
return (__m512i) __builtin_ia32_vpmultishiftqb512_mask ((__v64qi) __X,
(__v64qi) __Y,
(__v64qi) __W,
(__mmask64) __M);
}
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_maskz_multishift_epi64_epi8 (__mmask64 __M, __m512i __X, __m512i __Y)
{
return (__m512i) __builtin_ia32_vpmultishiftqb512_mask ((__v64qi) __X,
(__v64qi) __Y,
(__v64qi)
_mm512_setzero_si512 (),
(__mmask64) __M);
}
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_multishift_epi64_epi8 (__m512i __X, __m512i __Y)
{
return (__m512i) __builtin_ia32_vpmultishiftqb512_mask ((__v64qi) __X,
(__v64qi) __Y,
(__v64qi)
_mm512_undefined_epi32 (),
(__mmask64) -1);
}
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_permutexvar_epi8 (__m512i __A, __m512i __B)
{
return (__m512i) __builtin_ia32_permvarqi512_mask ((__v64qi) __B,
(__v64qi) __A,
(__v64qi)
_mm512_undefined_epi32 (),
(__mmask64) -1);
}
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_maskz_permutexvar_epi8 (__mmask64 __M, __m512i __A,
__m512i __B)
{
return (__m512i) __builtin_ia32_permvarqi512_mask ((__v64qi) __B,
(__v64qi) __A,
(__v64qi)
_mm512_setzero_si512(),
(__mmask64) __M);
}
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask_permutexvar_epi8 (__m512i __W, __mmask64 __M, __m512i __A,
__m512i __B)
{
return (__m512i) __builtin_ia32_permvarqi512_mask ((__v64qi) __B,
(__v64qi) __A,
(__v64qi) __W,
(__mmask64) __M);
}
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_permutex2var_epi8 (__m512i __A, __m512i __I, __m512i __B)
{
return (__m512i) __builtin_ia32_vpermt2varqi512_mask ((__v64qi) __I
/* idx */ ,
(__v64qi) __A,
(__v64qi) __B,
(__mmask64) -1);
}
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask_permutex2var_epi8 (__m512i __A, __mmask64 __U,
__m512i __I, __m512i __B)
{
return (__m512i) __builtin_ia32_vpermt2varqi512_mask ((__v64qi) __I
/* idx */ ,
(__v64qi) __A,
(__v64qi) __B,
(__mmask64)
__U);
}
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask2_permutex2var_epi8 (__m512i __A, __m512i __I,
__mmask64 __U, __m512i __B)
{
return (__m512i) __builtin_ia32_vpermi2varqi512_mask ((__v64qi) __A,
(__v64qi) __I
/* idx */ ,
(__v64qi) __B,
(__mmask64)
__U);
}
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_maskz_permutex2var_epi8 (__mmask64 __U, __m512i __A,
__m512i __I, __m512i __B)
{
return (__m512i) __builtin_ia32_vpermt2varqi512_maskz ((__v64qi) __I
/* idx */ ,
(__v64qi) __A,
(__v64qi) __B,
(__mmask64)
__U);
}
#ifdef __DISABLE_AVX512VBMI__
#undef __DISABLE_AVX512VBMI__
#pragma GCC pop_options
#endif /* __DISABLE_AVX512VBMI__ */
#endif /* _AVX512VBMIINTRIN_H_INCLUDED */
@@ -0,0 +1,273 @@
/* Copyright (C) 2013-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _IMMINTRIN_H_INCLUDED
#error "Never use <avx512vbmivlintrin.h> directly; include <immintrin.h> instead."
#endif
#ifndef _AVX512VBMIVLINTRIN_H_INCLUDED
#define _AVX512VBMIVLINTRIN_H_INCLUDED
#if !defined(__AVX512VL__) || !defined(__AVX512VBMI__)
#pragma GCC push_options
//#pragma GCC target("avx512vbmi,avx512vl")
#define __DISABLE_AVX512VBMIVL__
#endif /* __AVX512VBMIVL__ */
extern __inline __m256i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm256_mask_multishift_epi64_epi8 (__m256i __W, __mmask32 __M, __m256i __X, __m256i __Y)
{
return (__m256i) __builtin_ia32_vpmultishiftqb256_mask ((__v32qi) __X,
(__v32qi) __Y,
(__v32qi) __W,
(__mmask32) __M);
}
extern __inline __m256i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm256_maskz_multishift_epi64_epi8 (__mmask32 __M, __m256i __X, __m256i __Y)
{
return (__m256i) __builtin_ia32_vpmultishiftqb256_mask ((__v32qi) __X,
(__v32qi) __Y,
(__v32qi)
_mm256_setzero_si256 (),
(__mmask32) __M);
}
extern __inline __m256i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm256_multishift_epi64_epi8 (__m256i __X, __m256i __Y)
{
return (__m256i) __builtin_ia32_vpmultishiftqb256_mask ((__v32qi) __X,
(__v32qi) __Y,
(__v32qi)
_mm256_undefined_si256 (),
(__mmask32) -1);
}
extern __inline __m128i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_mask_multishift_epi64_epi8 (__m128i __W, __mmask16 __M, __m128i __X, __m128i __Y)
{
return (__m128i) __builtin_ia32_vpmultishiftqb128_mask ((__v16qi) __X,
(__v16qi) __Y,
(__v16qi) __W,
(__mmask16) __M);
}
extern __inline __m128i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_maskz_multishift_epi64_epi8 (__mmask16 __M, __m128i __X, __m128i __Y)
{
return (__m128i) __builtin_ia32_vpmultishiftqb128_mask ((__v16qi) __X,
(__v16qi) __Y,
(__v16qi)
_mm_setzero_si128 (),
(__mmask16) __M);
}
extern __inline __m128i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_multishift_epi64_epi8 (__m128i __X, __m128i __Y)
{
return (__m128i) __builtin_ia32_vpmultishiftqb128_mask ((__v16qi) __X,
(__v16qi) __Y,
(__v16qi)
_mm_undefined_si128 (),
(__mmask16) -1);
}
extern __inline __m256i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm256_permutexvar_epi8 (__m256i __A, __m256i __B)
{
return (__m256i) __builtin_ia32_permvarqi256_mask ((__v32qi) __B,
(__v32qi) __A,
(__v32qi)
_mm256_undefined_si256 (),
(__mmask32) -1);
}
extern __inline __m256i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm256_maskz_permutexvar_epi8 (__mmask32 __M, __m256i __A,
__m256i __B)
{
return (__m256i) __builtin_ia32_permvarqi256_mask ((__v32qi) __B,
(__v32qi) __A,
(__v32qi)
_mm256_setzero_si256 (),
(__mmask32) __M);
}
extern __inline __m256i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm256_mask_permutexvar_epi8 (__m256i __W, __mmask32 __M, __m256i __A,
__m256i __B)
{
return (__m256i) __builtin_ia32_permvarqi256_mask ((__v32qi) __B,
(__v32qi) __A,
(__v32qi) __W,
(__mmask32) __M);
}
extern __inline __m128i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_permutexvar_epi8 (__m128i __A, __m128i __B)
{
return (__m128i) __builtin_ia32_permvarqi128_mask ((__v16qi) __B,
(__v16qi) __A,
(__v16qi)
_mm_undefined_si128 (),
(__mmask16) -1);
}
extern __inline __m128i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_maskz_permutexvar_epi8 (__mmask16 __M, __m128i __A, __m128i __B)
{
return (__m128i) __builtin_ia32_permvarqi128_mask ((__v16qi) __B,
(__v16qi) __A,
(__v16qi)
_mm_setzero_si128 (),
(__mmask16) __M);
}
extern __inline __m128i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_mask_permutexvar_epi8 (__m128i __W, __mmask16 __M, __m128i __A,
__m128i __B)
{
return (__m128i) __builtin_ia32_permvarqi128_mask ((__v16qi) __B,
(__v16qi) __A,
(__v16qi) __W,
(__mmask16) __M);
}
extern __inline __m256i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm256_permutex2var_epi8 (__m256i __A, __m256i __I, __m256i __B)
{
return (__m256i) __builtin_ia32_vpermt2varqi256_mask ((__v32qi) __I
/* idx */ ,
(__v32qi) __A,
(__v32qi) __B,
(__mmask32) -1);
}
extern __inline __m256i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm256_mask_permutex2var_epi8 (__m256i __A, __mmask32 __U,
__m256i __I, __m256i __B)
{
return (__m256i) __builtin_ia32_vpermt2varqi256_mask ((__v32qi) __I
/* idx */ ,
(__v32qi) __A,
(__v32qi) __B,
(__mmask32)
__U);
}
extern __inline __m256i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm256_mask2_permutex2var_epi8 (__m256i __A, __m256i __I,
__mmask32 __U, __m256i __B)
{
return (__m256i) __builtin_ia32_vpermi2varqi256_mask ((__v32qi) __A,
(__v32qi) __I
/* idx */ ,
(__v32qi) __B,
(__mmask32)
__U);
}
extern __inline __m256i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm256_maskz_permutex2var_epi8 (__mmask32 __U, __m256i __A,
__m256i __I, __m256i __B)
{
return (__m256i) __builtin_ia32_vpermt2varqi256_maskz ((__v32qi) __I
/* idx */ ,
(__v32qi) __A,
(__v32qi) __B,
(__mmask32)
__U);
}
extern __inline __m128i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_permutex2var_epi8 (__m128i __A, __m128i __I, __m128i __B)
{
return (__m128i) __builtin_ia32_vpermt2varqi128_mask ((__v16qi) __I
/* idx */ ,
(__v16qi) __A,
(__v16qi) __B,
(__mmask16) -1);
}
extern __inline __m128i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_mask_permutex2var_epi8 (__m128i __A, __mmask16 __U, __m128i __I,
__m128i __B)
{
return (__m128i) __builtin_ia32_vpermt2varqi128_mask ((__v16qi) __I
/* idx */ ,
(__v16qi) __A,
(__v16qi) __B,
(__mmask16)
__U);
}
extern __inline __m128i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_mask2_permutex2var_epi8 (__m128i __A, __m128i __I, __mmask16 __U,
__m128i __B)
{
return (__m128i) __builtin_ia32_vpermi2varqi128_mask ((__v16qi) __A,
(__v16qi) __I
/* idx */ ,
(__v16qi) __B,
(__mmask16)
__U);
}
extern __inline __m128i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_maskz_permutex2var_epi8 (__mmask16 __U, __m128i __A, __m128i __I,
__m128i __B)
{
return (__m128i) __builtin_ia32_vpermt2varqi128_maskz ((__v16qi) __I
/* idx */ ,
(__v16qi) __A,
(__v16qi) __B,
(__mmask16)
__U);
}
#ifdef __DISABLE_AVX512VBMIVL__
#undef __DISABLE_AVX512VBMIVL__
#pragma GCC pop_options
#endif /* __DISABLE_AVX512VBMIVL__ */
#endif /* _AVX512VBMIVLINTRIN_H_INCLUDED */
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,94 @@
/* Copyright (C) 2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#if !defined _IMMINTRIN_H_INCLUDED
# error "Never use <avx512vpopcntdqintrin.h> directly; include <x86intrin.h> instead."
#endif
#ifndef _AVX512VPOPCNTDQINTRIN_H_INCLUDED
#define _AVX512VPOPCNTDQINTRIN_H_INCLUDED
#ifndef __AVX512VPOPCNTDQ__
#pragma GCC push_options
//#pragma GCC target("avx512vpopcntdq")
#define __DISABLE_AVX512VPOPCNTDQ__
#endif /* __AVX512VPOPCNTDQ__ */
extern __inline __m512i
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm512_popcnt_epi32 (__m512i __A)
{
return (__m512i) __builtin_ia32_vpopcountd_v16si ((__v16si) __A);
}
extern __inline __m512i
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask_popcnt_epi32 (__m512i __A, __mmask16 __U, __m512i __B)
{
return (__m512i) __builtin_ia32_vpopcountd_v16si_mask ((__v16si) __A,
(__v16si) __B,
(__mmask16) __U);
}
extern __inline __m512i
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm512_maskz_popcnt_epi32 (__mmask16 __U, __m512i __A)
{
return (__m512i) __builtin_ia32_vpopcountd_v16si_mask ((__v16si) __A,
(__v16si)
_mm512_setzero_si512 (),
(__mmask16) __U);
}
extern __inline __m512i
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm512_popcnt_epi64 (__m512i __A)
{
return (__m512i) __builtin_ia32_vpopcountq_v8di ((__v8di) __A);
}
extern __inline __m512i
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm512_mask_popcnt_epi64 (__m512i __A, __mmask8 __U, __m512i __B)
{
return (__m512i) __builtin_ia32_vpopcountq_v8di_mask ((__v8di) __A,
(__v8di) __B,
(__mmask8) __U);
}
extern __inline __m512i
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm512_maskz_popcnt_epi64 (__mmask8 __U, __m512i __A)
{
return (__m512i) __builtin_ia32_vpopcountq_v8di_mask ((__v8di) __A,
(__v8di)
_mm512_setzero_si512 (),
(__mmask8) __U);
}
#ifdef __DISABLE_AVX512VPOPCNTDQ__
#undef __DISABLE_AVX512VPOPCNTDQ__
#pragma GCC pop_options
#endif /* __DISABLE_AVX512VPOPCNTDQ__ */
#endif /* _AVX512VPOPCNTDQINTRIN_H_INCLUDED */
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,109 @@
/* Copyright (C) 2011-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#if !defined _X86INTRIN_H_INCLUDED && !defined _IMMINTRIN_H_INCLUDED
# error "Never use <bmi2intrin.h> directly; include <x86intrin.h> instead."
#endif
#ifndef _BMI2INTRIN_H_INCLUDED
#define _BMI2INTRIN_H_INCLUDED
#ifndef __BMI2__
#pragma GCC push_options
#pragma GCC target("bmi2")
#define __DISABLE_BMI2__
#endif /* __BMI2__ */
extern __inline unsigned int
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_bzhi_u32 (unsigned int __X, unsigned int __Y)
{
return __builtin_ia32_bzhi_si (__X, __Y);
}
extern __inline unsigned int
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_pdep_u32 (unsigned int __X, unsigned int __Y)
{
return __builtin_ia32_pdep_si (__X, __Y);
}
extern __inline unsigned int
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_pext_u32 (unsigned int __X, unsigned int __Y)
{
return __builtin_ia32_pext_si (__X, __Y);
}
#ifdef __x86_64__
extern __inline unsigned long long
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_bzhi_u64 (unsigned long long __X, unsigned long long __Y)
{
return __builtin_ia32_bzhi_di (__X, __Y);
}
extern __inline unsigned long long
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_pdep_u64 (unsigned long long __X, unsigned long long __Y)
{
return __builtin_ia32_pdep_di (__X, __Y);
}
extern __inline unsigned long long
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_pext_u64 (unsigned long long __X, unsigned long long __Y)
{
return __builtin_ia32_pext_di (__X, __Y);
}
extern __inline unsigned long long
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mulx_u64 (unsigned long long __X, unsigned long long __Y,
unsigned long long *__P)
{
unsigned __int128 __res = (unsigned __int128) __X * __Y;
*__P = (unsigned long long) (__res >> 64);
return (unsigned long long) __res;
}
#else /* !__x86_64__ */
extern __inline unsigned int
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mulx_u32 (unsigned int __X, unsigned int __Y, unsigned int *__P)
{
unsigned long long __res = (unsigned long long) __X * __Y;
*__P = (unsigned int) (__res >> 32);
return (unsigned int) __res;
}
#endif /* !__x86_64__ */
#ifdef __DISABLE_BMI2__
#undef __DISABLE_BMI2__
#pragma GCC pop_options
#endif /* __DISABLE_BMI2__ */
#endif /* _BMI2INTRIN_H_INCLUDED */
@@ -0,0 +1,184 @@
/* Copyright (C) 2010-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#if !defined _X86INTRIN_H_INCLUDED && !defined _IMMINTRIN_H_INCLUDED
# error "Never use <bmiintrin.h> directly; include <x86intrin.h> instead."
#endif
#ifndef _BMIINTRIN_H_INCLUDED
#define _BMIINTRIN_H_INCLUDED
#ifndef __BMI__
#pragma GCC push_options
#pragma GCC target("bmi")
#define __DISABLE_BMI__
#endif /* __BMI__ */
extern __inline unsigned short __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__tzcnt_u16 (unsigned short __X)
{
return __builtin_ia32_tzcnt_u16 (__X);
}
extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__andn_u32 (unsigned int __X, unsigned int __Y)
{
return ~__X & __Y;
}
extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__bextr_u32 (unsigned int __X, unsigned int __Y)
{
return __builtin_ia32_bextr_u32 (__X, __Y);
}
extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_bextr_u32 (unsigned int __X, unsigned int __Y, unsigned __Z)
{
return __builtin_ia32_bextr_u32 (__X, ((__Y & 0xff) | ((__Z & 0xff) << 8)));
}
extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__blsi_u32 (unsigned int __X)
{
return __X & -__X;
}
extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_blsi_u32 (unsigned int __X)
{
return __blsi_u32 (__X);
}
extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__blsmsk_u32 (unsigned int __X)
{
return __X ^ (__X - 1);
}
extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_blsmsk_u32 (unsigned int __X)
{
return __blsmsk_u32 (__X);
}
extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__blsr_u32 (unsigned int __X)
{
return __X & (__X - 1);
}
extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_blsr_u32 (unsigned int __X)
{
return __blsr_u32 (__X);
}
extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__tzcnt_u32 (unsigned int __X)
{
return __builtin_ia32_tzcnt_u32 (__X);
}
extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_tzcnt_u32 (unsigned int __X)
{
return __builtin_ia32_tzcnt_u32 (__X);
}
#ifdef __x86_64__
extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__andn_u64 (unsigned long long __X, unsigned long long __Y)
{
return ~__X & __Y;
}
extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__bextr_u64 (unsigned long long __X, unsigned long long __Y)
{
return __builtin_ia32_bextr_u64 (__X, __Y);
}
extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_bextr_u64 (unsigned long long __X, unsigned int __Y, unsigned int __Z)
{
return __builtin_ia32_bextr_u64 (__X, ((__Y & 0xff) | ((__Z & 0xff) << 8)));
}
extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__blsi_u64 (unsigned long long __X)
{
return __X & -__X;
}
extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_blsi_u64 (unsigned long long __X)
{
return __blsi_u64 (__X);
}
extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__blsmsk_u64 (unsigned long long __X)
{
return __X ^ (__X - 1);
}
extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_blsmsk_u64 (unsigned long long __X)
{
return __blsmsk_u64 (__X);
}
extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__blsr_u64 (unsigned long long __X)
{
return __X & (__X - 1);
}
extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_blsr_u64 (unsigned long long __X)
{
return __blsr_u64 (__X);
}
extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__tzcnt_u64 (unsigned long long __X)
{
return __builtin_ia32_tzcnt_u64 (__X);
}
extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_tzcnt_u64 (unsigned long long __X)
{
return __builtin_ia32_tzcnt_u64 (__X);
}
#endif /* __x86_64__ */
#ifdef __DISABLE_BMI__
#undef __DISABLE_BMI__
#pragma GCC pop_options
#endif /* __DISABLE_BMI__ */
#endif /* _BMIINTRIN_H_INCLUDED */
@@ -0,0 +1,29 @@
/* Copyright (C) 2007-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _BMMINTRIN_H_INCLUDED
#define _BMMINTRIN_H_INCLUDED
# error "SSE5 instruction set removed from compiler"
#endif /* _BMMINTRIN_H_INCLUDED */
@@ -0,0 +1,82 @@
/* cilk.h -*-C++-*-
*
* Copyright (C) 2010-2016, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* *********************************************************************
*
* PLEASE NOTE: This file is a downstream copy of a file mainitained in
* a repository at cilkplus.org. Changes made to this file that are not
* submitted through the contribution process detailed at
* http://www.cilkplus.org/submit-cilk-contribution will be lost the next
* time that a new version is released. Changes only submitted to the
* GNU compiler collection or posted to the git repository at
* https://bitbucket.org/intelcilkruntime/intel-cilk-runtime.git are
* not tracked.
*
* We welcome your contributions to this open source project. Thank you
* for your assistance in helping us improve Cilk Plus.
*/
/** @file cilk.h
*
* @brief Provides convenient aliases for Intel(R) Cilk(TM) language keywords.
*
* @details
* Since Intel Cilk Plus is a nonstandard extension to both C and C++, the Intel
* Cilk language keywords all begin with "`_Cilk_`", which guarantees that they
* will not conflict with user-defined identifiers in properly written
* programs. This way, a Cilk-enabled C or C++ compiler can safely compile
* "standard" C and C++ programs.
*
* However, this means that the keywords _look_ like something grafted on to
* the base language. Therefore, you can include this header:
*
* #include "cilk/cilk.h"
*
* and then write the Intel Cilk keywords with a "`cilk_`" prefix instead of
* "`_Cilk_`".
*
* @ingroup language
*/
/** @defgroup language Language Keywords
* Definitions for the Intel Cilk language.
* @{
*/
#ifndef cilk_spawn
# define cilk_spawn _Cilk_spawn ///< Spawn a task that can execute in parallel.
# define cilk_sync _Cilk_sync ///< Wait for spawned tasks to complete.
# define cilk_for _Cilk_for ///< Execute iterations of a `for` loop in parallel.
#endif
/// @}
@@ -0,0 +1,436 @@
/* cilk_api.h
*
* Copyright (C) 2009-2016, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* *********************************************************************
*
* PLEASE NOTE: This file is a downstream copy of a file mainitained in
* a repository at cilkplus.org. Changes made to this file that are not
* submitted through the contribution process detailed at
* http://www.cilkplus.org/submit-cilk-contribution will be lost the next
* time that a new version is released. Changes only submitted to the
* GNU compiler collection or posted to the git repository at
* https://bitbucket.org/intelcilkruntime/intel-cilk-runtime.git are
* not tracked.
*
* We welcome your contributions to this open source project. Thank you
* for your assistance in helping us improve Cilk Plus.
*/
/** @file cilk_api.h
*
* @brief Defines the Intel(R) Cilk(TM) Plus API for use by applications.
*
* @ingroup api
*/
#ifndef INCLUDED_CILK_API_H
#define INCLUDED_CILK_API_H
/** @defgroup api Runtime API
* API to interact with the Intel Cilk Plus runtime.
* @{
*/
#ifndef CILK_STUB /* Real (non-stub) definitions */
#if ! defined(__cilk) && ! defined(USE_CILK_API)
# ifdef _WIN32
# error Cilk API is being used with non-Cilk compiler (or Cilk is disabled)
# else
# warning Cilk API is being used with non-Cilk compiler (or Cilk is disabled)
# endif
#endif
#include <cilk/common.h>
#ifdef __cplusplus
# include <cstddef> /* Defines size_t */
#else
# include <stddef.h> /* Defines size_t */
#endif
#ifdef _WIN32
# ifndef IN_CILK_RUNTIME
/* Ensure the library is brought if any of these functions are being called. */
# pragma comment(lib, "cilkrts")
# endif
# ifndef __cplusplus
# include <wchar.h>
# endif
#endif /* _WIN32 */
__CILKRTS_BEGIN_EXTERN_C
/** Return values from `__cilkrts_set_param()` and `__cilkrts_set_param_w()`
*/
enum __cilkrts_set_param_status {
__CILKRTS_SET_PARAM_SUCCESS = 0, /**< Success - parameter set */
__CILKRTS_SET_PARAM_UNIMP = 1, /**< Unimplemented parameter */
__CILKRTS_SET_PARAM_XRANGE = 2, /**< Parameter value out of range */
__CILKRTS_SET_PARAM_INVALID = 3, /**< Invalid parameter value */
__CILKRTS_SET_PARAM_LATE = 4 /**< Too late to change parameter value */
};
/** Sets user controllable runtime parameters
*
* Call this function to set runtime parameters that control the behavior
* of the Intel Cilk Plus scheduler.
*
* @param param A string specifying the parameter to be set. One of:
* - `"nworkers"`
* - `"force reduce"`
* @param value A string specifying the parameter value.
* @returns A value from the @ref __cilkrts_set_param_status
* enumeration indicating the result of the operation.
*
* @par The "nworkers" parameter
*
* This parameter specifies the number of worker threads to be created by the
* Intel Cilk Plus runtime. @a Value must be a string of digits to be parsed by
* `strtol()` as a decimal number.
*
* The number of worker threads is:
* 1. the value set with `__cilkrts_set_param("nworkers")`, if it is
* positive; otherwise,
* 2. the value of the CILK_NWORKERS environment variable, if it is
* defined; otherwise
* 3. the number of cores available, as reported by the operating system.
*
* @note
* Technically, Intel Cilk Plus distinguishes between the _user thread_ (the thread
* that the user code was executing on when the Intel Cilk Plus runtime started),
* and _worker threads_ (new threads created by the Intel Cilk Plus runtime to
* support Intel Cilk Plus parallelism). `nworkers` actually includes both the user
* thread and the worker threads; that is, it is one greater than the number of
* true "worker threads".
*
* @note
* Setting `nworkers = 1` produces serial behavior. Intel Cilk Plus spawns and syncs
* will be executed, but with only one worker, continuations will never be
* stolen, so all code will execute in serial.
*
* @warning
* The number of worker threads can only be set *before* the runtime has
* started. Attempting to set it when the runtime is running will have no
* effect, and will return an error code. You can call __cilkrts_end_cilk()
* to shut down the runtime to change the number of workers.
*
* @warning
* The default Intel Cilk scheduler behavior is usually pretty good. The
* ability to override `nworkers` can be useful for experimentation, but it
* won't usually be necessary for getting good performance.
*
* @par The "force reduce" parameter
*
* This parameter controls whether the runtime should allocate a new view
* for a reducer for every parallel strand that it is accessed on. (See
* @ref pagereducers.) @a Value must be `"1"` or `"true"` to enable the
* "force reduce" behavior, or `"0"` or `"false"` to disable it.
*
* "Force reduce" behavior will also be enabled if
* `__cilkrts_set_param("force reduce")` is not called, but the
* `CILK_FORCE_REDUCE` environment variable is defined.
*
* @warning
* When this option is enabled, `nworkers` should be set to `1`. Using "force
* reduce" with more than one worker may result in runtime errors.
*
* @warning
* Enabling this option can significantly reduce performance. Use it
* _only_ as a debugging tool.
*/
CILK_API(int) __cilkrts_set_param(const char *param, const char *value);
#ifdef _WIN32
/**
* Sets user controllable parameters using wide strings
*
* @note This variant of __cilkrts_set_param() is only available
* on Windows.
*
* @copydetails __cilkrts_set_param
*/
CILK_API(int) __cilkrts_set_param_w(const wchar_t *param, const wchar_t *value);
#endif
/** Shuts down and deallocates all Intel Cilk Plus states. If Intel Cilk Plus is still in
* use by the calling thread, the runtime aborts the application. Otherwise, the
* runtime waits for all other threads using Intel Cilk Plus to exit.
*/
CILK_API(void) __cilkrts_end_cilk(void);
/** Initializes Intel Cilk Plus data structures and start the runtime.
*/
CILK_API(void) __cilkrts_init(void);
/** Returns the runtime `nworkers` parameter. (See the discussion of `nworkers`
* in the documentation for __cilkrts_set_param().)
*/
CILK_API(int) __cilkrts_get_nworkers(void);
/** Returns the number of thread data structures.
*
* This function returns the number of data structures that have been allocated
* by the runtime to hold information about user and worker threads.
*
* If you don't already know what this is good for, then you probably don't
* need it. :)
*/
CILK_API(int) __cilkrts_get_total_workers(void);
/** Returns a small integer identifying the current thread.
*
* What thread is the function running on? Each worker thread
* started by the Intel Cilk Plus runtime library has a unique worker number in the
* range `1 .. nworkers - 1`.
*
* All _user_ threads (threads started by the user, or by other libraries) are
* identified as worker number 0. Therefore, the worker number is not unique
* across multiple user threads.
*/
CILK_API(int) __cilkrts_get_worker_number(void);
/** Tests whether "force reduce" behavior is enabled.
*
* @return Non-zero if force-reduce mode is on, zero if it is off.
*/
CILK_API(int) __cilkrts_get_force_reduce(void);
/** Interacts with tools
*/
CILK_API(void)
__cilkrts_metacall(unsigned int tool, unsigned int code, void *data);
#ifdef _WIN32
/// Windows exception description record.
typedef struct _EXCEPTION_RECORD _EXCEPTION_RECORD;
/** Function signature for Windows exception notification callbacks.
*/
typedef void (*__cilkrts_pfn_seh_callback)(const _EXCEPTION_RECORD *exception);
/** Specifies a function to call when a non-C++ exception is caught.
*
* Intel Cilk Plus parallelism plays nicely with C++ exception handling, but
* the Intel Cilk Plus runtime has no way to unwind the stack across a strand
* boundary for Microsoft SEH ("Structured Exception Handling") exceptions.
* Therefore, when the runtime catches such an exception, it must abort the
* application.
*
* If an SEH callback has been set, the runtime will call it before aborting.
*
* @param pfn A pointer to a callback function to be called before the
* runtime aborts the program because of an SEH exception.
*/
CILK_API(int) __cilkrts_set_seh_callback(__cilkrts_pfn_seh_callback pfn);
#endif /* _WIN32 */
#if __CILKRTS_ABI_VERSION >= 1
/* Pedigree API is available only for compilers that use ABI version >= 1. */
/** @name Pedigrees
*/
//@{
// @cond internal
/** Support for __cilkrts_get_pedigree.
*/
CILK_API(__cilkrts_pedigree)
__cilkrts_get_pedigree_internal(__cilkrts_worker *w);
/** Support for __cilkrts_bump_worker_rank.
*/
CILK_API(int)
__cilkrts_bump_worker_rank_internal(__cilkrts_worker* w);
/// @endcond
/** Gets the current pedigree in a linked list representation.
*
* This routine returns a copy of the last node in the pedigree list.
* For example, if the current pedigree (in order) is <1, 2, 3, 4>,
* then this method returns a node with rank == 4, and whose parent
* field points to the node with rank of 3. In summary, following the
* nodes in the chain visits the terms of the pedigree in reverse.
*
* The returned node is guaranteed to be valid only until the caller
* of this routine has returned.
*/
__CILKRTS_INLINE
__cilkrts_pedigree __cilkrts_get_pedigree(void)
{
return __cilkrts_get_pedigree_internal(__cilkrts_get_tls_worker());
}
/** Context used by __cilkrts_get_pedigree_info.
*
* @deprecated
* This data structure is only used by the deprecated
* __cilkrts_get_pedigree_info function.
*
* Callers should initialize the `data` array to NULL and set the `size`
* field to `sizeof(__cilkrts_pedigree_context_t)` before the first call
* to `__cilkrts_get_pedigree_info()`. Also, callers should not examine or
* modify `data` thereafter.
*/
typedef struct
{
__STDNS size_t size; /**< Size of the struct in bytes */
void *data[3]; /**< Opaque context data */
} __cilkrts_pedigree_context_t;
/** Gets pedigree information.
*
* @deprecated
* Use __cilkrts_get_pedigree() instead.
*
* This routine allows code to walk up the stack of Intel Cilk Plus frames to gather
* the pedigree.
*
* Initialize the pedigree walk by filling the pedigree context with NULLs
* and setting the size field to `sizeof(__cilkrts_pedigree_context)`.
* Other than initialization to NULL to start the walk, user coder should
* consider the pedigree context data opaque and should not examine or
* modify it.
*
* @returns 0 - Success - birthrank is valid
* @returns >0 - End of pedigree walk
* @returns -1 - Failure - No worker bound to thread
* @returns -2 - Failure - Sanity check failed,
* @returns -3 - Failure - Invalid context size
* @returns -4 - Failure - Internal error - walked off end of chain of frames
*/
CILK_API(int)
__cilkrts_get_pedigree_info(/* In/Out */ __cilkrts_pedigree_context_t *context,
/* Out */ uint64_t *sf_birthrank);
/** Gets the rank of the currently executing worker.
*
* @deprecated
* Use `__cilkrts_get_pedigree().rank` instead.
*
* @returns 0 - Success - *rank is valid
* @returns <0 - Failure - *rank is not changed
*/
CILK_EXPORT_AND_INLINE
int __cilkrts_get_worker_rank(uint64_t *rank)
{
*rank = __cilkrts_get_pedigree().rank;
return 0;
}
/** Increments the pedigree rank of the currently executing worker.
*
* @returns 0 - Success - rank was incremented
* @returns -1 - Failure
*/
CILK_EXPORT_AND_INLINE
int __cilkrts_bump_worker_rank(void)
{
return __cilkrts_bump_worker_rank_internal(__cilkrts_get_tls_worker());
}
/** Increments the pedigree rank for a `cilk_for` loop.
* Obsolete.
*
* @deprecated
* This function was provided to allow the user to manipulate the pedigree
* rank of a `cilk_for` loop. The compiler now generates code to do that
* manipulation automatically, so this function is now unnecessary. It may
* be called, but will have no effect.
*/
CILK_EXPORT_AND_INLINE
int __cilkrts_bump_loop_rank(void)
{
return 0;
}
//@}
#endif /* __CILKRTS_ABI_VERSION >= 1 */
__CILKRTS_END_EXTERN_C
#else /* CILK_STUB */
// Programs compiled with CILK_STUB are not linked with the Intel Cilk Plus runtime
// library, so they should not have external references to runtime functions.
// Therefore, the functions are replaced with stubs.
#ifdef _WIN32
#define __cilkrts_set_param_w(name,value) ((value), 0)
#define __cilkrts_set_seh_callback(pfn) (0)
#endif
#define __cilkrts_set_param(name,value) ((value), 0)
#define __cilkrts_end_cilk() ((void) 0)
#define __cilkrts_init() ((void) 0)
#define __cilkrts_get_nworkers() (1)
#define __cilkrts_get_total_workers() (1)
#define __cilkrts_get_worker_number() (0)
#define __cilkrts_get_force_reduce() (0)
#define __cilkrts_metacall(tool,code,data) ((tool), (code), (data), 0)
#if __CILKRTS_ABI_VERSION >= 1
/* Pedigree stubs */
#define __cilkrts_get_pedigree_info(context, sf_birthrank) (-1)
#define __cilkrts_get_worker_rank(rank) (*(rank) = 0)
#define __cilkrts_bump_worker_rank() (-1)
#define __cilkrts_bump_loop_rank() (-1)
/*
* A stub method for __cilkrts_get_pedigree.
* Returns an empty __cilkrts_pedigree.
*/
__CILKRTS_INLINE
__cilkrts_pedigree __cilkrts_get_pedigree_stub(void)
{
__cilkrts_pedigree ans;
ans.rank = 0;
ans.parent = NULL;
return ans;
}
/* Renamed to an actual stub method. */
#define __cilkrts_get_pedigree() __cilkrts_get_pedigree_stub()
#endif /* __CILKRTS_ABI_VERSION >= 1 */
#endif /* CILK_STUB */
//@}
#endif /* INCLUDED_CILK_API_H */
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2009-2016, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* *********************************************************************
*
* PLEASE NOTE: This file is a downstream copy of a file mainitained in
* a repository at cilkplus.org. Changes made to this file that are not
* submitted through the contribution process detailed at
* http://www.cilkplus.org/submit-cilk-contribution will be lost the next
* time that a new version is released. Changes only submitted to the
* GNU compiler collection or posted to the git repository at
* https://bitbucket.org/intelcilkruntime/intel-cilk-runtime.git are
* not tracked.
*
* We welcome your contributions to this open source project. Thank you
* for your assistance in helping us improve Cilk Plus.
*
*/
/* THIS FILE IS DEPRECATED. USE cilk_api.h INSTEAD. */
#include <cilk/cilk_api.h>
@@ -0,0 +1,71 @@
/* cilk_stub.h -*-C++-*-
*
* Copyright (C) 2009-2016, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* *********************************************************************
*
* PLEASE NOTE: This file is a downstream copy of a file mainitained in
* a repository at cilkplus.org. Changes made to this file that are not
* submitted through the contribution process detailed at
* http://www.cilkplus.org/submit-cilk-contribution will be lost the next
* time that a new version is released. Changes only submitted to the
* GNU compiler collection or posted to the git repository at
* https://bitbucket.org/intelcilkruntime/intel-cilk-runtime.git are
* not tracked.
*
* We welcome your contributions to this open source project. Thank you
* for your assistance in helping us improve Cilk Plus.
*
*/
#ifndef INCLUDED_CILK_STUB_DOT_H
#define INCLUDED_CILK_STUB_DOT_H
/* Definitions for creating a serialization from an Intel(R) Cilk(TM) Plus program.
* These definitions are suitable for use by a compiler that is not
* Cilk-enabled.
*/
/* Pretend we are a non-Cilk compiler */
#undef __cilk
#define CILK_STUB
/* Replace Intel Cilk keywords with serial equivalents */
#define _Cilk_spawn
#define _Cilk_sync
#define _Cilk_for for
/* Replace simd-loop keywords with serial equivalents */
#define _Simd
#define _Safelen(...)
#define _Reduction(...)
#endif /* ! defined(INCLUDED_CILK_STUB_DOT_H) */
@@ -0,0 +1,139 @@
/*
* Copyright (C) 2009-2016, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* *********************************************************************
*
* PLEASE NOTE: This file is a downstream copy of a file mainitained in
* a repository at cilkplus.org. Changes made to this file that are not
* submitted through the contribution process detailed at
* http://www.cilkplus.org/submit-cilk-contribution will be lost the next
* time that a new version is released. Changes only submitted to the
* GNU compiler collection or posted to the git repository at
* https://bitbucket.org/intelcilkruntime/intel-cilk-runtime.git are
* not tracked.
*
* We welcome your contributions to this open source project. Thank you
* for your assistance in helping us improve Cilk Plus.
*
******************************************************************************
*
* cilk_undocumented.h
*
* This file defines exported functions that are not included in the standard
* documentation.
*/
#ifndef INCLUDED_CILK_UNDOCUMENTED_H
#define INCLUDED_CILK_UNDOCUMENTED_H
#include <cilk/common.h>
#ifndef CILK_STUB
__CILKRTS_BEGIN_EXTERN_C
/*
* __cilkrts_synched
*
* Allows an application to determine if there are any outstanding children at
* this instant. This function will examine the current full frame to
* determine this. This function will return a valid result only when called
* within a spawn continuation, within the stack frame of the continuation
* itself.
*/
CILK_EXPORT __CILKRTS_NOTHROW
int __cilkrts_synched(void);
/*
* __cilkrts_cilkscreen_puts
*
* Allows an application to write a string to the Cilkscreen log.
* The standard error stream will be flushed after the write.
*/
CILK_EXPORT __CILKRTS_NOTHROW
void __cilkrts_cilkscreen_puts(const char *);
/*
* __cilkrts_get_sf
*
* A debugging aid that allows an application to get the __cilkrts_stack_frame
* for the current function. Only compiled into the DLL in debug builds.
*/
CILK_EXPORT __CILKRTS_NOTHROW
void *__cilkrts_get_sf(void);
/**
* Returns the size of stacks created by Intel(R) Cilk(TM) Plus.
*/
CILK_EXPORT __CILKRTS_NOTHROW
size_t __cilkrts_get_stack_size(void);
/**
* Dumps runtime statistics to stderr.
* Undocumented API for debugging.
*/
CILK_EXPORT __CILKRTS_NOTHROW
void __cilkrts_dump_stats(void);
struct __cilk_tbb_unwatch_thunk;
struct __cilk_tbb_stack_op_thunk;
CILK_EXPORT __CILKRTS_NOTHROW
int __cilkrts_watch_stack(struct __cilk_tbb_unwatch_thunk *u,
struct __cilk_tbb_stack_op_thunk o);
#ifndef IN_CILK_RUNTIME
#ifdef _WIN32
/* Do not use CILK_API because __cilkrts_worker_stub must be __stdcall */
CILK_EXPORT unsigned __CILKRTS_NOTHROW __stdcall
__cilkrts_worker_stub(void *arg);
#else
/* Do not use CILK_API because __cilkrts_worker_stub have default visibility */
CILK_EXPORT void* __CILKRTS_NOTHROW
__cilkrts_worker_stub(void *arg);
#endif /* _WIN32 */
#endif /* IN_CILK_RUNTIME */
__CILKRTS_END_EXTERN_C
#else /* CILK_STUB */
/* Stubs for the api functions */
#define __cilkrts_get_stack_size() (0)
#define __cilkrts_synched() (1)
#endif /* CILK_STUB */
#endif /* INCLUDED_CILK_UNDOCUMENTED_H */
@@ -0,0 +1,385 @@
/** common.h
*
* Copyright (C) 2010-2016, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* *********************************************************************
*
* PLEASE NOTE: This file is a downstream copy of a file mainitained in
* a repository at cilkplus.org. Changes made to this file that are not
* submitted through the contribution process detailed at
* http://www.cilkplus.org/submit-cilk-contribution will be lost the next
* time that a new version is released. Changes only submitted to the
* GNU compiler collection or posted to the git repository at
* https://bitbucket.org/intelcilkruntime/intel-cilk-runtime.git are
* not tracked.
*
* We welcome your contributions to this open source project. Thank you
* for your assistance in helping us improve Cilk Plus.
*/
/** @file common.h
*
* @brief Defines common macros and structures used by the Intel(R) Cilk(TM) Plus runtime.
*
* @ingroup common
*/
/** @defgroup common Common Definitions
* Definitions for runtime macros, structures, and classes.
* @{
*/
#ifndef INCLUDED_CILK_COMMON
#define INCLUDED_CILK_COMMON
#ifdef __cplusplus
/** Namespace for all Intel Cilk Plus definitions that can be included in user code.
*/
namespace cilk {
/** Namespace for definitions re-used in other Intel Cilk Plus definitions.
*/
namespace internal {}
}
#endif
/** Intel Cilk Plus library version = 1.02
*/
#define CILK_LIBRARY_VERSION 102
#ifdef __cplusplus
# include <cassert>
#else
# include <assert.h>
#endif
/**
* Prefix standard library function and type names with __STDNS to
* get correct lookup in both C and C++.
*/
#ifdef __cplusplus
# define __STDNS std::
#else
# define __STDNS
#endif
/**
* @def CILK_EXPORT
* Define export of runtime functions from shared library.
* Should be exported only from cilkrts*.dll/cilkrts*.so
* @def CILK_EXPORT_DATA
* Define export of runtime data from shared library.
*/
#ifdef _WIN32
# ifdef IN_CILK_RUNTIME
# define CILK_EXPORT __declspec(dllexport)
# define CILK_EXPORT_DATA __declspec(dllexport)
# else
# define CILK_EXPORT __declspec(dllimport)
# define CILK_EXPORT_DATA __declspec(dllimport)
# endif /* IN_CILK_RUNTIME */
#elif defined(__CYGWIN__) || defined(__APPLE__) || defined(_DARWIN_C_SOURCE)
# define CILK_EXPORT /* nothing */
# define CILK_EXPORT_DATA /* nothing */
#else /* Unix/gcc */
# if defined(IN_CILK_RUNTIME) && defined(HAVE_ATTRIBUTE_VISIBILITY)
# define CILK_EXPORT __attribute__((visibility("protected")))
# define CILK_EXPORT_DATA __attribute__((visibility("protected")))
# else
# define CILK_EXPORT /* nothing */
# define CILK_EXPORT_DATA /* nothing */
# endif /* IN_CILK_RUNTIME */
#endif /* Unix/gcc */
/**
* @def __CILKRTS_BEGIN_EXTERN_C
* Macro to denote the start of a section in which all names have "C" linkage.
* That is, none of the names are to be mangled.
* @see __CILKRTS_END_EXTERN_C
* @see __CILKRTS_EXTERN_C
*
* @def __CILKRTS_END_EXTERN_C
* Macro to denote the end of a section in which all names have "C" linkage.
* That is, none of the names are to be mangled.
* @see __CILKRTS_BEGIN_EXTERN_C
* @see __CILKRTS_EXTERN_C
*
* @def __CILKRTS_EXTERN_C
* Macro to prefix a single definition which has "C" linkage.
* That is, the defined name is not to be mangled.
* @see __CILKRTS_BEGIN_EXTERN_C
* @see __CILKRTS_END_EXTERN_C
*/
#ifdef __cplusplus
# define __CILKRTS_BEGIN_EXTERN_C extern "C" {
# define __CILKRTS_END_EXTERN_C }
# define __CILKRTS_EXTERN_C extern "C"
#else
# define __CILKRTS_BEGIN_EXTERN_C
# define __CILKRTS_END_EXTERN_C
# define __CILKRTS_EXTERN_C
#endif
/**
* OS-independent macro to specify a function which is known to not throw
* an exception.
*/
#ifdef __cplusplus
# ifdef _WIN32
# define __CILKRTS_NOTHROW __declspec(nothrow)
# else /* Unix/gcc */
# define __CILKRTS_NOTHROW __attribute__((nothrow))
# endif /* Unix/gcc */
#else
# define __CILKRTS_NOTHROW /* nothing */
#endif /* __cplusplus */
/** Cache alignment. (Good enough for most architectures.)
*/
#define __CILKRTS_CACHE_LINE__ 64
/**
* Macro to specify alignment of a data member in a structure.
* Because of the way that gcc's alignment attribute is defined, @a n must
* be a numeric literal, not just a compile-time constant expression.
*/
#ifdef _WIN32
# define CILK_ALIGNAS(n) __declspec(align(n))
#else /* Unix/gcc */
# define CILK_ALIGNAS(n) __attribute__((__aligned__(n)))
#endif
/**
* Macro to specify cache-line alignment of a data member in a structure.
*/
#define __CILKRTS_CACHE_ALIGN CILK_ALIGNAS(__CILKRTS_CACHE_LINE__)
/**
* Macro to specify a class as being at least as strictly aligned as some
* type on Windows. gcc does not provide a way of doing this, so on Unix,
* this just specifies the largest natural type alignment. Put the macro
* between the `class` keyword and the class name:
*
* class CILK_ALIGNAS_TYPE(foo) bar { ... };
*/
#ifdef _WIN32
# define CILK_ALIGNAS_TYPE(t) __declspec(align(__alignof(t)))
#else /* Unix/gcc */
# define CILK_ALIGNAS_TYPE(t) __attribute__((__aligned__))
#endif
/**
* @def CILK_API(RET_TYPE)
* A function called explicitly by the programmer.
* @def CILK_ABI(RET_TYPE)
* A function called by compiler-generated code.
* @def CILK_ABI_THROWS(RET_TYPE)
* An ABI function that may throw an exception
*
* Even when these are the same definitions, they should be separate macros so
* that they can be easily found in the code.
*/
#ifdef _WIN32
# define CILK_API(RET_TYPE) CILK_EXPORT RET_TYPE __CILKRTS_NOTHROW __cdecl
# define CILK_ABI(RET_TYPE) CILK_EXPORT RET_TYPE __CILKRTS_NOTHROW __cdecl
# define CILK_ABI_THROWS(RET_TYPE) CILK_EXPORT RET_TYPE __cdecl
#else
# define CILK_API(RET_TYPE) CILK_EXPORT RET_TYPE __CILKRTS_NOTHROW
# define CILK_ABI(RET_TYPE) CILK_EXPORT RET_TYPE __CILKRTS_NOTHROW
# define CILK_ABI_THROWS(RET_TYPE) CILK_EXPORT RET_TYPE
#endif
/**
* __CILKRTS_ASSERT should be defined for debugging only, otherwise it
* interferes with vectorization. Since NDEBUG is not reliable (it must be
* set by the user), we must use a platform-specific detection of debug mode.
*/
#if defined(_WIN32) && defined(_DEBUG)
/* Windows debug */
# define __CILKRTS_ASSERT(e) assert(e)
#elif (! defined(_WIN32)) && ! defined(__OPTIMIZE__)
/* Unix non-optimized */
# define __CILKRTS_ASSERT(e) assert(e)
#elif defined __cplusplus
/* C++ non-debug */
# define __CILKRTS_ASSERT(e) static_cast<void>(0)
#else
/* C non-debug */
# define __CILKRTS_ASSERT(e) ((void) 0)
#endif
/**
* OS-independent macro to specify a function that should be inlined
*/
#ifdef __cplusplus
// C++
# define __CILKRTS_INLINE inline
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
// C99
# define __CILKRTS_INLINE static inline
#elif defined(_MSC_VER)
// C89 on Windows
# define __CILKRTS_INLINE __inline
#else
// C89 on GCC-compatible systems
# define __CILKRTS_INLINE extern __inline__
#endif
/**
* Functions marked as CILK_EXPORT_AND_INLINE have both
* inline versions defined in the Intel Cilk Plus API, as well as
* non-inlined versions that are exported (for
* compatibility with previous versions that did not
* inline the functions).
*/
#ifdef COMPILING_CILK_API_FUNCTIONS
# define CILK_EXPORT_AND_INLINE CILK_EXPORT
#else
# define CILK_EXPORT_AND_INLINE __CILKRTS_INLINE
#endif
/**
* Try to determine if compiler supports rvalue references.
*/
#if defined(__cplusplus) && !defined(__CILKRTS_RVALUE_REFERENCES)
# if __cplusplus >= 201103L // C++11
# define __CILKRTS_RVALUE_REFERENCES 1
# elif defined(__GXX_EXPERIMENTAL_CXX0X__)
# define __CILKRTS_RVALUE_REFERENCES 1
# elif __cplusplus >= 199711L && __cplusplus < 201103L
// Compiler recognizes a language version prior to C++11
# elif __INTEL_COMPILER == 1200 && defined(__STDC_HOSTED__)
// Intel compiler version 12.0
// __cplusplus has a non-standard definition. In the absence of a
// proper definition, look for the C++0x macro, __STDC_HOSTED__.
# define __CILKRTS_RVALUE_REFERENCES 1
# elif __INTEL_COMPILER > 1200 && defined(CHAR16T)
// Intel compiler version >= 12.1
// __cplusplus has a non-standard definition. In the absence of a
// proper definition, look for the Intel macro, CHAR16T
# define __CILKRTS_RVALUE_REFERENCES 1
# endif
#endif
/*
* Include stdint.h to define the standard integer types.
*
* Unfortunately Microsoft doesn't provide stdint.h until Visual Studio 2010,
* so use our own definitions until those are available
*/
#if ! defined(_MSC_VER) || (_MSC_VER >= 1600)
# include <stdint.h>
#else
# ifndef __MS_STDINT_TYPES_DEFINED__
# define __MS_STDINT_TYPES_DEFINED__
typedef signed char int8_t;
typedef short int16_t;
typedef int int32_t;
typedef __int64 int64_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned __int64 uint64_t;
# endif /* __MS_STDINT_TYPES_DEFINED__ */
#endif /* ! defined(_MSC_VER) || (_MSC_VER >= 1600) */
/**
* @brief Application Binary Interface (ABI) version of the Intel Cilk Plus runtime
* library.
*
* The compiler determines the ABI version used for compilation. Object files
* compiled with higher ABI versions are not compatible with libraries compiled
* with lower ABI versions. However, an object file compiled with a lower ABI
* version can be used with a library compiled with a higher ABI version
* (unless otherwise stated.)
*/
#ifndef __CILKRTS_ABI_VERSION
# ifdef IN_CILK_RUNTIME
# define __CILKRTS_ABI_VERSION 1
# elif defined(__INTEL_COMPILER) && (__INTEL_COMPILER <= 1200)
// Intel compilers prior to version 12.1 support only ABI 0
# define __CILKRTS_ABI_VERSION 0
# else
// Non-Intel compiler or Intel compiler after version 12.0.
# define __CILKRTS_ABI_VERSION 1
# endif
#endif
// These structs are exported because the inlining of
// the internal version of API methods require a worker
// structure as parameter.
__CILKRTS_BEGIN_EXTERN_C
/// Worker struct, exported for inlined API methods
/// @ingroup api
struct __cilkrts_worker;
/// Worker struct, exported for inlined API methods
/// @ingroup api
typedef struct __cilkrts_worker __cilkrts_worker;
/// Worker struct pointer, exported for inlined API methods
/// @ingroup api
typedef struct __cilkrts_worker *__cilkrts_worker_ptr;
/// Fetch the worker out of TLS.
CILK_ABI(__cilkrts_worker_ptr) __cilkrts_get_tls_worker(void);
/// void *, defined to work around complaints from the compiler
/// about using __declspec(nothrow) after the "void *" return type
typedef void * __cilkrts_void_ptr;
__CILKRTS_END_EXTERN_C
#if __CILKRTS_ABI_VERSION >= 1
// Pedigree API is available only for compilers that use ABI version >= 1.
/** Pedigree information kept in the worker and stack frame.
* @ingroup api
*/
typedef struct __cilkrts_pedigree
{
/** Rank at start of spawn helper. Saved rank for spawning functions */
uint64_t rank;
/** Link to next in chain */
const struct __cilkrts_pedigree *parent;
} __cilkrts_pedigree;
#endif // __CILKRTS_ABI_VERSION >= 1
/// @}
#endif /* INCLUDED_CILK_COMMON */
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,183 @@
/*
* Copyright (C) 2009-2016, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* *********************************************************************
*
* PLEASE NOTE: This file is a downstream copy of a file mainitained in
* a repository at cilkplus.org. Changes made to this file that are not
* submitted through the contribution process detailed at
* http://www.cilkplus.org/submit-cilk-contribution will be lost the next
* time that a new version is released. Changes only submitted to the
* GNU compiler collection or posted to the git repository at
* https://bitbucket.org/intelcilkruntime/intel-cilk-runtime.git are
* not tracked.
*
* We welcome your contributions to this open source project. Thank you
* for your assistance in helping us improve Cilk Plus.
*
*/
#ifndef INCLUDED_CILK_HYPEROBJECT_BASE
#define INCLUDED_CILK_HYPEROBJECT_BASE
#ifdef __cplusplus
# include <cstdlib>
# include <cstddef>
#else
# include <stdlib.h>
# include <stddef.h>
#endif
#include <cilk/common.h>
#if defined _WIN32 || defined _WIN64
# if !defined CILK_STUB && !defined IN_CILK_RUNTIME
/* bring in the Intel(R) Cilk(TM) Plus library, which has definitions for some of these
* functions. */
# pragma comment(lib, "cilkrts")
# endif
#endif
/* The __CILKRTS_STRAND_PURE attribute tells the compiler that the value
* returned by 'func' for a given argument to 'func' will remain valid until
* the next strand boundary (spawn or sync) or until the next call to a
* function with the __CILKRTS_STRAND_STALE attribute using the same function
* argument.
*/
#if 0 && defined __cilk && (defined __GNUC__ && !defined _WIN32) && defined __cilkartsrev
# define __CILKRTS_STRAND_PURE(func) \
func __attribute__((__cilk_hyper__("lookup")))
# define __CILKRTS_STRAND_STALE(func) \
func __attribute__((__cilk_hyper__("flush")))
#else
# define __CILKRTS_STRAND_PURE(func) func
# define __CILKRTS_STRAND_STALE(func) func
#endif
/*****************************************************************************
* C runtime interface to the hyperobject subsystem
*****************************************************************************/
__CILKRTS_BEGIN_EXTERN_C
/* Callback function signatures. The 'r' argument always points to the
* reducer itself and is commonly ignored. */
typedef void (*cilk_c_reducer_reduce_fn_t)(void* r, void* lhs, void* rhs);
typedef void (*cilk_c_reducer_identity_fn_t)(void* r, void* view);
typedef void (*cilk_c_reducer_destroy_fn_t)(void* r, void* view);
typedef void* (*cilk_c_reducer_allocate_fn_t)(void* r, __STDNS size_t bytes);
typedef void (*cilk_c_reducer_deallocate_fn_t)(void* r, void* view);
/** Representation of the monoid */
typedef struct cilk_c_monoid {
cilk_c_reducer_reduce_fn_t reduce_fn;
cilk_c_reducer_identity_fn_t identity_fn;
cilk_c_reducer_destroy_fn_t destroy_fn;
cilk_c_reducer_allocate_fn_t allocate_fn;
cilk_c_reducer_deallocate_fn_t deallocate_fn;
} cilk_c_monoid;
/** Base of the hyperobject */
typedef struct __cilkrts_hyperobject_base
{
cilk_c_monoid __c_monoid;
unsigned long long __flags;
__STDNS ptrdiff_t __view_offset; /* offset (in bytes) to leftmost view */
__STDNS size_t __view_size; /* Size of each view */
} __cilkrts_hyperobject_base;
#ifndef CILK_STUB
/* Library functions. */
CILK_EXPORT
void __cilkrts_hyper_create(__cilkrts_hyperobject_base *key);
CILK_EXPORT void __CILKRTS_STRAND_STALE(
__cilkrts_hyper_destroy(__cilkrts_hyperobject_base *key));
CILK_EXPORT void* __CILKRTS_STRAND_PURE(
__cilkrts_hyper_lookup(__cilkrts_hyperobject_base *key));
CILK_EXPORT
void* __cilkrts_hyperobject_alloc(void* ignore, __STDNS size_t bytes);
CILK_EXPORT
void __cilkrts_hyperobject_dealloc(void* ignore, void* view);
/* No-op destroy function */
CILK_EXPORT
void __cilkrts_hyperobject_noop_destroy(void* ignore, void* ignore2);
#else // CILK_STUB
// Programs compiled with CILK_STUB are not linked with the Intel Cilk Plus runtime
// library, so they should not have external references to cilkrts functions.
// Furthermore, they don't need the hyperobject functionality, so the
// functions can be stubbed.
#define __cilkrts_hyperobject_create __cilkrts_hyperobject_create__stub
__CILKRTS_INLINE
void __cilkrts_hyper_create(__cilkrts_hyperobject_base *key)
{}
#define __cilkrts_hyperobject_destroy __cilkrts_hyperobject_destroy__stub
__CILKRTS_INLINE
void __cilkrts_hyper_destroy(__cilkrts_hyperobject_base *key)
{}
#define __cilkrts_hyperobject_lookup __cilkrts_hyperobject_lookup__stub
__CILKRTS_INLINE
void* __cilkrts_hyper_lookup(__cilkrts_hyperobject_base *key)
{ return (char*)(key) + key->__view_offset; }
// Pointers to these functions are stored into monoids, so real functions
// are needed.
#define __cilkrts_hyperobject_alloc __cilkrts_hyperobject_alloc__stub
__CILKRTS_INLINE
void* __cilkrts_hyperobject_alloc(void* ignore, __STDNS size_t bytes)
{ assert(0); return __STDNS malloc(bytes); }
#define __cilkrts_hyperobject_dealloc __cilkrts_hyperobject_dealloc__stub
__CILKRTS_INLINE
void __cilkrts_hyperobject_dealloc(void* ignore, void* view)
{ assert(0); __STDNS free(view); }
#define __cilkrts_hyperobject_noop_destroy \
__cilkrts_hyperobject_noop_destroy__stub
__CILKRTS_INLINE
void __cilkrts_hyperobject_noop_destroy(void* ignore, void* ignore2)
{}
#endif
__CILKRTS_END_EXTERN_C
#endif /* INCLUDED_CILK_HYPEROBJECT_BASE */
@@ -0,0 +1,621 @@
/* metaprogramming.h -*- C++ -*-
*
* Copyright (C) 2012-2016, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* *********************************************************************
*
* PLEASE NOTE: This file is a downstream copy of a file mainitained in
* a repository at cilkplus.org. Changes made to this file that are not
* submitted through the contribution process detailed at
* http://www.cilkplus.org/submit-cilk-contribution will be lost the next
* time that a new version is released. Changes only submitted to the
* GNU compiler collection or posted to the git repository at
* https://bitbucket.org/intelcilkruntime/intel-cilk-runtime.git are
* not tracked.
*
* We welcome your contributions to this open source project. Thank you
* for your assistance in helping us improve Cilk Plus.
*/
/** @file metaprogramming.h
*
* @brief Defines metaprogramming utility classes used in the Intel(R) Cilk(TM) Plus library.
*
* @ingroup common
*/
#ifndef METAPROGRAMMING_H_INCLUDED
#define METAPROGRAMMING_H_INCLUDED
#ifdef __cplusplus
#include <functional>
#include <new>
#include <cstdlib>
#ifdef _WIN32
#include <malloc.h>
#endif
#include <algorithm>
namespace cilk {
namespace internal {
/** Test if a class is empty.
*
* If @a Class is an empty (and therefore necessarily stateless) class, then
* the "empty base-class optimization" guarantees that
* `sizeof(check_for_empty_class<Class>) == sizeof(char)`. Conversely, if
* `sizeof(check_for_empty_class<Class>) > sizeof(char)`, then @a Class is not
* empty, and we must discriminate distinct instances of @a Class.
*
* Typical usage:
*
* // General definition of A<B> for non-empty B:
* template <typename B, bool BIsEmpty = class_is_empty<B>::value> >
* class A { ... };
*
* // Specialized definition of A<B> for empty B:
* template <typename B>
* class A<B, true> { ... };
*
* @tparam Class The class to be tested for emptiness.
*
* @result The `value` member will be `true` if @a Class is empty,
* `false` otherwise.
*
* @ingroup common
*/
template <class Class>
class class_is_empty {
class check_for_empty_class : public Class
{
char m_data;
public:
// Declared but not defined
check_for_empty_class();
check_for_empty_class(const check_for_empty_class&);
check_for_empty_class& operator=(const check_for_empty_class&);
~check_for_empty_class();
};
public:
/** Constant is true if and only if @a Class is empty.
*/
static const bool value = (sizeof(check_for_empty_class) == sizeof(char));
};
/** Get the alignment of a type.
*
* For example:
*
* align_of<double>::value == 8
*
* @tparam Tp The type whose alignment is to be computed.
*
* @result The `value` member of an instantiation of this class template
* will hold the integral alignment requirement of @a Tp.
*
* @pre @a Tp shall be a complete type.
*
* @ingroup common
*/
template <typename Tp>
struct align_of
{
private:
struct imp {
char m_padding;
Tp m_val;
// The following declarations exist to suppress compiler-generated
// definitions, in case @a Tp does not have a public default
// constructor, copy constructor, or destructor.
imp(const imp&); // Declared but not defined
~imp(); // Declared but not defined
};
public:
/// The integral alignment requirement of @a Tp.
static const std::size_t value = (sizeof(imp) - sizeof(Tp));
};
/** A class containing raw bytes with a specified alignment and size.
*
* An object of type `aligned_storage<S, A>` will have alignment `A` and
* size at least `S`. Its contents will be uninitialized bytes.
*
* @tparam Size The required minimum size of the resulting class.
* @tparam Alignment The required alignment of the resulting class.
*
* @pre @a Alignment shall be a power of 2 no greater than 64.
*
* @note This is implemented using the `CILK_ALIGNAS` macro, which uses
* the non-standard, implementation-specific features
* `__declspec(align(N))` on Windows, and
* `__attribute__((__aligned__(N)))` on Unix. The `gcc` implementation
* of `__attribute__((__aligned__(N)))` requires a numeric literal `N`
* (_not_ an arbitrary compile-time constant expression). Therefore,
* this class is implemented using specialization on the required
* alignment.
*
* @note The template class is specialized only for the supported
* alignments. An attempt to instantiate it for an unsupported
* alignment will result in a compilation error.
*/
template <std::size_t Size, std::size_t Alignment>
struct aligned_storage;
/// @cond
template<std::size_t Size> class aligned_storage<Size, 1>
{ CILK_ALIGNAS( 1) char m_bytes[Size]; };
template<std::size_t Size> class aligned_storage<Size, 2>
{ CILK_ALIGNAS( 2) char m_bytes[Size]; };
template<std::size_t Size> class aligned_storage<Size, 4>
{ CILK_ALIGNAS( 4) char m_bytes[Size]; };
template<std::size_t Size> class aligned_storage<Size, 8>
{ CILK_ALIGNAS( 8) char m_bytes[Size]; };
template<std::size_t Size> class aligned_storage<Size, 16>
{ CILK_ALIGNAS(16) char m_bytes[Size]; };
template<std::size_t Size> class aligned_storage<Size, 32>
{ CILK_ALIGNAS(32) char m_bytes[Size]; };
template<std::size_t Size> class aligned_storage<Size, 64>
{ CILK_ALIGNAS(64) char m_bytes[Size]; };
/// @endcond
/** A buffer of uninitialized bytes with the same size and alignment as a
* specified type.
*
* The class `storage_for_object<Type>` will have the same size and alignment
* properties as `Type`, but it will contain only raw (uninitialized) bytes.
* This allows the definition of a data member which can contain a `Type`
* object which is initialized explicitly under program control, rather
* than implicitly as part of the initialization of the containing class.
* For example:
*
* class C {
* storage_for_object<MemberClass> _member;
* public:
* C() ... // Does NOT initialize _member
* void initialize(args)
* { new (_member.pointer()) MemberClass(args); }
* const MemberClass& member() const { return _member.object(); }
* MemberClass& member() { return _member.object(); }
*
* @tparam Type The type whose size and alignment are to be reflected
* by this class.
*/
template <typename Type>
class storage_for_object :
aligned_storage< sizeof(Type), align_of<Type>::value >
{
public:
/// Return a typed reference to the buffer.
const Type& object() const { return *reinterpret_cast<Type*>(this); }
/// Return a typed reference to the buffer.
Type& object() { return *reinterpret_cast<Type*>(this); }
};
/** Get the functor class corresponding to a binary function type.
*
* The `binary_functor` template class can be instantiated with a binary
* functor class or with a real binary function, and will yield an equivalent
* binary functor class in either case.
*
* @tparam F A binary functor class, a binary function type, or a pointer to
* binary function type.
*
* @result `binary_functor<F>::%type` will be the same as @a F if @a F is
* a class. It will be a `std::pointer_to_binary_function` wrapper
* if @a F is a binary function or binary function pointer type.
* (It will _not_ necessarily be an `Adaptable Binary Function`
* class, since @a F might be a non-adaptable binary functor
* class.)
*
* @ingroup common
*/
template <typename F>
struct binary_functor {
/// The binary functor class equivalent to @a F.
typedef F type;
};
/// @copydoc binary_functor
/// Specialization for binary function.
template <typename R, typename A, typename B>
struct binary_functor<R(A,B)> {
/// The binary functor class equivalent to @a F.
typedef std::pointer_to_binary_function<A, B, R> type;
};
/// @copydoc binary_functor
/// Specialization for pointer to binary function.
template <typename R, typename A, typename B>
struct binary_functor<R(*)(A,B)> {
/// The binary functor class equivalent to @a F.
typedef std::pointer_to_binary_function<A, B, R> type;
};
/** Indirect binary function class with specified types.
*
* `typed_indirect_binary_function<F>` is an `Adaptable Binary Function` class
* based on an existing binary functor class or binary function type @a F. If
* @a F is a stateless class, then this class will be empty, and its
* `operator()` will invoke @a F's `operator()`. Otherwise, an object of this
* class will hold a pointer to an object of type @a F, and will refer its
* `operator()` calls to the pointed-to @a F object.
*
* That is, suppose that we have the declarations:
*
* F *p;
* typed_indirect_binary_function<F, int, int, bool> ibf(p);
*
* Then:
*
* - `ibf(x, y) == (*p)(x, y)`.
* - `ibf(x, y)` will not do a pointer dereference if `F` is an empty class.
*
* @note Just to repeat: if `F` is an empty class, then
* `typed_indirect_binary_function\<F\>' is also an empty class.
* This is critical for its use in the
* @ref cilk::cilk_lib_1_1::min_max_internal::view_base
* "min/max reducer view classes", where it allows the view to
* call a comparison functor in the monoid without actually
* having to allocate a pointer in the view class when the
* comparison class is empty.
*
* @note If you have an `Adaptable Binary Function` class or a binary
* function type, then you can use the
* @ref indirect_binary_function class, which derives the
* argument and result types parameter type instead of requiring
* you to specify them as template arguments.
*
* @tparam F A binary functor class, a binary function type, or a pointer to
* binary function type.
* @param A1 The first argument type.
* @param A2 The second argument type.
* @param R The result type.
*
* @see min_max::comparator_base
* @see indirect_binary_function
*
* @ingroup common
*/
template < typename F
, typename A1
, typename A2
, typename R
, typename Functor = typename binary_functor<F>::type
, bool FunctorIsEmpty = class_is_empty<Functor>::value
>
class typed_indirect_binary_function : std::binary_function<A1, A2, R>
{
const F* f;
public:
/// Constructor captures a pointer to the wrapped function.
typed_indirect_binary_function(const F* f) : f(f) {}
/// Return the comparator pointer, or `NULL` if the comparator is stateless.
const F* pointer() const { return f; }
/// Apply the pointed-to functor to the arguments.
R operator()(const A1& a1, const A2& a2) const { return (*f)(a1, a2); }
};
/// @copydoc typed_indirect_binary_function
/// Specialization for an empty functor class. (This is only possible if @a F
/// itself is an empty class. If @a F is a function or pointer-to-function
/// type, then the functor will contain a pointer.)
template <typename F, typename A1, typename A2, typename R, typename Functor>
class typed_indirect_binary_function<F, A1, A2, R, Functor, true> :
std::binary_function<A1, A2, R>
{
public:
/// Return `NULL` for the comparator pointer of a stateless comparator.
const F* pointer() const { return 0; }
/// Constructor discards the pointer to a stateless functor class.
typed_indirect_binary_function(const F* f) {}
/// Create an instance of the stateless functor class and apply it to the arguments.
R operator()(const A1& a1, const A2& a2) const { return F()(a1, a2); }
};
/** Indirect binary function class with inferred types.
*
* This is identical to @ref cilk::internal::typed_indirect_binary_function,
* except that it derives the binary function argument and result types from
* the parameter type @a F instead of taking them as additional template
* parameters. If @a F is a class type, then it must be an `Adaptable Binary
* Function`.
*
* @see typed_indirect_binary_function
*
* @ingroup common
*/
template <typename F, typename Functor = typename binary_functor<F>::type>
class indirect_binary_function :
typed_indirect_binary_function< F
, typename Functor::first_argument_type
, typename Functor::second_argument_type
, typename Functor::result_type
>
{
typedef typed_indirect_binary_function< F
, typename Functor::first_argument_type
, typename Functor::second_argument_type
, typename Functor::result_type
>
base;
public:
indirect_binary_function(const F* f) : base(f) {} ///< Constructor
};
/** Choose a type based on a boolean constant.
*
* This metafunction is identical to C++11's condition metafunction.
* It needs to be here until we can reasonably assume that users will be
* compiling with C++11.
*
* @tparam Cond A boolean constant.
* @tparam IfTrue A type.
* @tparam IfFalse A type.
* @result The `type` member will be a typedef of @a IfTrue if @a Cond
* is true, and a typedef of @a IfFalse if @a Cond is false.
*
* @ingroup common
*/
template <bool Cond, typename IfTrue, typename IfFalse>
struct condition
{
typedef IfTrue type; ///< The type selected by the condition.
};
/// @copydoc condition
/// Specialization for @a Cond == `false`.
template <typename IfTrue, typename IfFalse>
struct condition<false, IfTrue, IfFalse>
{
typedef IfFalse type; ///< The type selected by the condition.
};
/** @def __CILKRTS_STATIC_ASSERT
*
* @brief Compile-time assertion.
*
* Causes a compilation error if a compile-time constant expression is false.
*
* @par Usage example.
* This assertion is used in reducer_min_max.h to avoid defining
* legacy reducer classes that would not be binary-compatible with the
* same classes compiled with earlier versions of the reducer library.
*
* __CILKRTS_STATIC_ASSERT(
* internal::class_is_empty< internal::binary_functor<Compare> >::value,
* "cilk::reducer_max<Value, Compare> only works with an empty Compare class");
*
* @note In a C++11 compiler, this is just the language predefined
* `static_assert` macro.
*
* @note In a non-C++11 compiler, the @a Msg string is not directly included
* in the compiler error message, but it may appear if the compiler
* prints the source line that the error occurred on.
*
* @param Cond The expression to test.
* @param Msg A string explaining the failure.
*
* @ingroup common
*/
#if defined(__INTEL_CXX11_MODE__) || defined(__GXX_EXPERIMENTAL_CXX0X__)
# define __CILKRTS_STATIC_ASSERT(Cond, Msg) static_assert(Cond, Msg)
#else
# define __CILKRTS_STATIC_ASSERT(Cond, Msg) \
typedef int __CILKRTS_STATIC_ASSERT_DUMMY_TYPE \
[::cilk::internal::static_assert_failure<(Cond)>::Success]
/// @cond internal
template <bool> struct static_assert_failure { };
template <> struct static_assert_failure<true> { enum { Success = 1 }; };
# define __CILKRTS_STATIC_ASSERT_DUMMY_TYPE \
__CILKRTS_STATIC_ASSERT_DUMMY_TYPE1(__cilkrts_static_assert_, __LINE__)
# define __CILKRTS_STATIC_ASSERT_DUMMY_TYPE1(a, b) \
__CILKRTS_STATIC_ASSERT_DUMMY_TYPE2(a, b)
# define __CILKRTS_STATIC_ASSERT_DUMMY_TYPE2(a, b) a ## b
/// @endcond
#endif
/// @cond internal
/** @name Aligned heap management.
*/
//@{
/** Implementation-specific aligned memory allocation function.
*
* @param size The minimum number of bytes to allocate.
* @param alignment The required alignment (must be a power of 2).
* @return The address of a block of memory of at least @a size
* bytes. The address will be a multiple of @a alignment.
* `NULL` if the allocation fails.
*
* @see deallocate_aligned()
*/
inline void* allocate_aligned(std::size_t size, std::size_t alignment)
{
#ifdef _WIN32
return _aligned_malloc(size, alignment);
#else
#if defined(__ANDROID__) || defined(__VXWORKS__)
return memalign(std::max(alignment, sizeof(void*)), size);
#else
void* ptr;
return (posix_memalign(&ptr, std::max(alignment, sizeof(void*)), size) == 0) ? ptr : 0;
#endif
#endif
}
/** Implementation-specific aligned memory deallocation function.
*
* @param ptr A pointer which was returned by a call to alloc_aligned().
*/
inline void deallocate_aligned(void* ptr)
{
#ifdef _WIN32
_aligned_free(ptr);
#else
std::free(ptr);
#endif
}
/** Class to allocate and guard an aligned pointer.
*
* A new_aligned_pointer object allocates aligned heap-allocated memory when
* it is created, and automatically deallocates it when it is destroyed
* unless its `ok()` function is called.
*
* @tparam T The type of the object to allocate on the heap. The allocated
* will have the size and alignment of an object of type T.
*/
template <typename T>
class new_aligned_pointer {
void* m_ptr;
public:
/// Constructor allocates the pointer.
new_aligned_pointer() :
m_ptr(allocate_aligned(sizeof(T), internal::align_of<T>::value)) {}
/// Destructor deallocates the pointer.
~new_aligned_pointer() { if (m_ptr) deallocate_aligned(m_ptr); }
/// Get the pointer.
operator void*() { return m_ptr; }
/// Return the pointer and release the guard.
T* ok() {
T* ptr = static_cast<T*>(m_ptr);
m_ptr = 0;
return ptr;
}
};
//@}
/// @endcond
} // namespace internal
//@{
/** Allocate an aligned data structure on the heap.
*
* `cilk::aligned_new<T>([args])` is equivalent to `new T([args])`, except
* that it guarantees that the returned pointer will be at least as aligned
* as the alignment requirements of type `T`.
*
* @ingroup common
*/
template <typename T>
T* aligned_new()
{
internal::new_aligned_pointer<T> ptr;
new (ptr) T();
return ptr.ok();
}
template <typename T, typename T1>
T* aligned_new(const T1& x1)
{
internal::new_aligned_pointer<T> ptr;
new (ptr) T(x1);
return ptr.ok();
}
template <typename T, typename T1, typename T2>
T* aligned_new(const T1& x1, const T2& x2)
{
internal::new_aligned_pointer<T> ptr;
new (ptr) T(x1, x2);
return ptr.ok();
}
template <typename T, typename T1, typename T2, typename T3>
T* aligned_new(const T1& x1, const T2& x2, const T3& x3)
{
internal::new_aligned_pointer<T> ptr;
new (ptr) T(x1, x2, x3);
return ptr.ok();
}
template <typename T, typename T1, typename T2, typename T3, typename T4>
T* aligned_new(const T1& x1, const T2& x2, const T3& x3, const T4& x4)
{
internal::new_aligned_pointer<T> ptr;
new (ptr) T(x1, x2, x3, x4);
return ptr.ok();
}
template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5>
T* aligned_new(const T1& x1, const T2& x2, const T3& x3, const T4& x4, const T5& x5)
{
internal::new_aligned_pointer<T> ptr;
new (ptr) T(x1, x2, x3, x4, x5);
return ptr.ok();
}
//@}
/** Deallocate an aligned data structure on the heap.
*
* `cilk::aligned_delete(ptr)` is equivalent to `delete ptr`, except that it
* operates on a pointer that was allocated by aligned_new().
*
* @ingroup common
*/
template <typename T>
void aligned_delete(const T* ptr)
{
ptr->~T();
internal::deallocate_aligned((void*)ptr);
}
} // namespace cilk
#endif // __cplusplus
#endif // METAPROGRAMMING_H_INCLUDED
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,48 @@
/*
* Copyright (C) 2009-2016, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* *********************************************************************
*
* PLEASE NOTE: This file is a downstream copy of a file mainitained in
* a repository at cilkplus.org. Changes made to this file that are not
* submitted through the contribution process detailed at
* http://www.cilkplus.org/submit-cilk-contribution will be lost the next
* time that a new version is released. Changes only submitted to the
* GNU compiler collection or posted to the git repository at
* https://bitbucket.org/intelcilkruntime/intel-cilk-runtime.git are
* not tracked.
*
* We welcome your contributions to this open source project. Thank you
* for your assistance in helping us improve Cilk Plus.
*
*/
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,57 @@
/* reducer_max.h -*- C++ -*-
*
* Copyright (C) 2009-2016, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* *********************************************************************
*
* PLEASE NOTE: This file is a downstream copy of a file mainitained in
* a repository at cilkplus.org. Changes made to this file that are not
* submitted through the contribution process detailed at
* http://www.cilkplus.org/submit-cilk-contribution will be lost the next
* time that a new version is released. Changes only submitted to the
* GNU compiler collection or posted to the git repository at
* https://bitbucket.org/intelcilkruntime/intel-cilk-runtime.git are
* not tracked.
*
* We welcome your contributions to this open source project. Thank you
* for your assistance in helping us improve Cilk Plus.
*/
/** @file reducer_max.h
*
* @brief Defines classes for doing parallel maximum reductions.
*
* @ingroup ReducersMinMax
*
* @see ReducersMinMax
*/
#include "reducer_min_max.h"
@@ -0,0 +1,57 @@
/* reducer_min.h -*- C++ -*-
*
* Copyright (C) 2009-2016, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* *********************************************************************
*
* PLEASE NOTE: This file is a downstream copy of a file mainitained in
* a repository at cilkplus.org. Changes made to this file that are not
* submitted through the contribution process detailed at
* http://www.cilkplus.org/submit-cilk-contribution will be lost the next
* time that a new version is released. Changes only submitted to the
* GNU compiler collection or posted to the git repository at
* https://bitbucket.org/intelcilkruntime/intel-cilk-runtime.git are
* not tracked.
*
* We welcome your contributions to this open source project. Thank you
* for your assistance in helping us improve Cilk Plus.
*/
/** @file reducer_min.h
*
* @brief Defines classes for doing parallel minimum reductions.
*
* @ingroup ReducersMinMax
*
* @see ReducersMinMax
*/
#include "reducer_min_max.h"
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,701 @@
/* reducer_opadd.h -*- C++ -*-
*
* Copyright (C) 2009-2016, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* *********************************************************************
*
* PLEASE NOTE: This file is a downstream copy of a file mainitained in
* a repository at cilkplus.org. Changes made to this file that are not
* submitted through the contribution process detailed at
* http://www.cilkplus.org/submit-cilk-contribution will be lost the next
* time that a new version is released. Changes only submitted to the
* GNU compiler collection or posted to the git repository at
* https://bitbucket.org/intelcilkruntime/intel-cilk-runtime.git are
* not tracked.
*
* We welcome your contributions to this open source project. Thank you
* for your assistance in helping us improve Cilk Plus.
*/
/** @file reducer_opadd.h
*
* @brief Defines classes for doing parallel addition reductions.
*
* @ingroup ReducersAdd
*
* @see ReducersAdd
*/
#ifndef REDUCER_OPADD_H_INCLUDED
#define REDUCER_OPADD_H_INCLUDED
#include <cilk/reducer.h>
/** @defgroup ReducersAdd Addition Reducers
*
* Addition reducers allow the computation of the sum of a set of values in
* parallel.
*
* @ingroup Reducers
*
* You should be familiar with @ref pagereducers "Intel(R) Cilk(TM) Plus reducers",
* described in file `reducers.md`, and particularly with @ref reducers_using,
* before trying to use the information in this file.
*
* @section redopadd_usage Usage Example
*
* cilk::reducer< cilk::op_add<int> > r;
* cilk_for (int i = 0; i != N; ++i) {
* *r += a[i];
* }
* return r.get_value();
*
* @section redopadd_monoid The Monoid
*
* @subsection redopadd_monoid_values Value Set
*
* The value set of an addition reducer is the set of values of `Type`, which
* is expected to be a builtin numeric type (or something like it, such as
* `std::complex`).
*
* @subsection redopadd_monoid_operator Operator
*
* The operator of an addition reducer is the addition operator, defined by
* the "`+`" binary operator on `Type`.
*
* @subsection redopadd_monoid_identity Identity
*
* The identity value of the reducer is the numeric value "`0`". This is
* expected to be the value of the default constructor `Type()`.
*
* @section redopadd_operations Operations
*
* @subsection redopadd_constructors Constructors
*
* reducer() // identity
* reducer(const Type& value)
* reducer(move_in(Type& variable))
*
* @subsection redopadd_get_set Set and Get
*
* r.set_value(const Type& value)
* const Type& = r.get_value() const
* r.move_in(Type& variable)
* r.move_out(Type& variable)
*
* @subsection redopadd_initial Initial Values
*
* If an addition reducer is constructed without an explicit initial value,
* then its initial value will be its identity value, as long as `Type`
* satisfies the requirements of @ref redopadd_types.
*
* @subsection redopadd_view_ops View Operations
*
* *r += a
* *r -= a
* ++*r
* --*r
* (*r)++
* (*r)--
* *r = *r + a
* *r = *r - a
* *r = *r ± a1 ± a2 … ± an
*
* The post-increment and post-decrement operations do not return a value. (If
* they did, they would expose the value contained in the view, which is
* non-deterministic in the middle of a reduction.)
*
* Note that subtraction operations are allowed on an addition reducer because
* subtraction is equivalent to addition with a negated operand. It is true
* that `(x - y) - z` is not equivalent to `x - (y - z)`, but
* `(x + (-y)) + (-z)` _is_ equivalent to `x + ((-y) + (-z))`.
*
* @section redopadd_floating_point Issues with Floating-Point Types
*
* Because of precision and round-off issues, floating-point addition is not
* really associative. For example, `(1e30 + -1e30) + 1 == 1`, but
* `1e30 + (-1e30 + 1) == 0`.
*
* In many cases, this won't matter, but computations which have been
* carefully ordered to control round-off errors may not deal well with
* being reassociated. In general, you should be sure to understand the
* floating-point behavior of your program before doing any transformation
* that will reassociate its computations.
*
* @section redopadd_types Type and Operator Requirements
*
* `Type` must be `Copy Constructible`, `Default Constructible`, and
* `Assignable`.
*
* The operator "`+=`" must be defined on `Type`, with `x += a` having the
* same meaning as `x = x + a`. In addition, if the code uses the "`-=`",
* pre-increment, post-increment, pre-decrement, or post-decrement operators,
* then the corresponding operators must be defined on `Type`.
*
* The expression `Type()` must be a valid expression which yields the
* identity value (the value of `Type` whose numeric value is zero).
*
* @section redopadd_in_c Addition Reducers in C
*
* The @ref CILK_C_REDUCER_OPADD and @ref CILK_C_REDUCER_OPADD_TYPE macros can
* be used to do addition reductions in C. For example:
*
* CILK_C_REDUCER_OPADD(r, double, 0);
* CILK_C_REGISTER_REDUCER(r);
* cilk_for(int i = 0; i != n; ++i) {
* REDUCER_VIEW(r) += a[i];
* }
* CILK_C_UNREGISTER_REDUCER(r);
* printf("The sum of the elements of a is %f\n", REDUCER_VIEW(r));
*
* See @ref reducers_c_predefined.
*/
#ifdef __cplusplus
namespace cilk {
/** The addition reducer view class.
*
* This is the view class for reducers created with
* `cilk::reducer< cilk::op_add<Type> >`. It holds the accumulator variable
* for the reduction, and allows only addition and subtraction operations to
* be performed on it.
*
* @note The reducer "dereference" operation (`reducer::operator *()`)
* yields a reference to the view. Thus, for example, the view class's
* `+=` operation would be used in an expression like `*r += a`, where
* `r` is an op_add reducer variable.
*
* @tparam Type The type of the contained accumulator variable. This will
* be the value type of a monoid_with_view that is
* instantiated with this view.
*
* @see ReducersAdd
* @see op_add
*
* @ingroup ReducersAdd
*/
template <typename Type>
class op_add_view : public scalar_view<Type>
{
typedef scalar_view<Type> base;
public:
/** Class to represent the right-hand side of
* `*reducer = *reducer ± value`.
*
* The only assignment operator for the op_add_view class takes an
* rhs_proxy as its operand. This results in the syntactic restriction
* that the only expressions that can be assigned to an op_add_view are
* ones which generate an rhs_proxy - that is, expressions of the form
* `op_add_view ± value ... ± value`.
*
* @warning
* The lhs and rhs views in such an assignment must be the same;
* otherwise, the behavior will be undefined. (I.e., `v1 = v1 + x` is
* legal; `v1 = v2 + x` is illegal.) This condition will be checked with a
* runtime assertion when compiled in debug mode.
*
* @see op_add_view
*/
class rhs_proxy {
friend class op_add_view;
const op_add_view* m_view;
Type m_value;
// Constructor is invoked only from op_add_view::operator+() and
// op_add_view::operator-().
//
rhs_proxy(const op_add_view* view, const Type& value) :
m_view(view), m_value(value) {}
rhs_proxy& operator=(const rhs_proxy&); // Disable assignment operator
rhs_proxy(); // Disable default constructor
public:
///@{
/** Adds or subtracts an additional rhs value. If `v` is an op_add_view
* and `a1` is a value, then the expression `v + a1` invokes the view's
* `operator+()` to create an rhs_proxy for `(v, a1)`; then
* `v + a1 + a2` invokes the rhs_proxy's `operator+()` to create a new
* rhs_proxy for `(v, a1+a2)`. This allows the right-hand side of an
* assignment to be not just `view ± value`, but
* `view ± value ± value ... ± value`. The effect is that
*
* v = v ± a1 ± a2 ... ± an;
*
* is evaluated as
*
* v = v ± (±a1 ± a2 ... ± an);
*/
rhs_proxy& operator+(const Type& x) { m_value += x; return *this; }
rhs_proxy& operator-(const Type& x) { m_value -= x; return *this; }
///@}
};
/** Default/identity constructor. This constructor initializes the
* contained value to `Type()`, which is expected to be the identity value
* for addition on `Type`.
*/
op_add_view() : base() {}
/** Construct with a specified initial value.
*/
explicit op_add_view(const Type& v) : base(v) {}
/** Reduces the views of two strands.
*
* This function is invoked by the @ref op_add monoid to combine the views
* of two strands when the right strand merges with the left one. It adds
* the value contained in the right-strand view to the value contained in
* the left-strand view, and leaves the value in the right-strand view
* undefined.
*
* @param right A pointer to the right-strand view. (`this` points to
* the left-strand view.)
*
* @note Used only by the @ref op_add monoid to implement the monoid
* reduce operation.
*/
void reduce(op_add_view* right) { this->m_value += right->m_value; }
/** @name Accumulator variable updates.
*
* These functions support the various syntaxes for incrementing or
* decrementing the accumulator variable contained in the view.
*/
///@{
/** Increments the accumulator variable by @a x.
*/
op_add_view& operator+=(const Type& x) { this->m_value += x; return *this; }
/** Decrements the accumulator variable by @a x.
*/
op_add_view& operator-=(const Type& x) { this->m_value -= x; return *this; }
/** Pre-increment.
*/
op_add_view& operator++() { ++this->m_value; return *this; }
/** Post-increments.
*
* @note Conventionally, post-increment operators return the old value
* of the incremented variable. However, reducer views do not
* expose their contained values, so `view++` does not have a
* return value.
*/
void operator++(int) { this->m_value++; }
/** Pre-decrements.
*/
op_add_view& operator--() { --this->m_value; return *this; }
/** Post-decrements.
*
* @note Conventionally, post-decrement operators return the old value
* of the decremented variable. However, reducer views do not
* expose their contained values, so `view--` does not have a
* return value.
*/
void operator--(int) { this->m_value--; }
/** Creates an object representing `*this + x`.
*
* @see rhs_proxy
*/
rhs_proxy operator+(const Type& x) const { return rhs_proxy(this, x); }
/** Creates an object representing `*this - x`.
*
* @see rhs_proxy
*/
rhs_proxy operator-(const Type& x) const { return rhs_proxy(this, -x); }
/** Assigns the result of a `view ± value` expression to the view. Note that
* this is the only assignment operator for this class.
*
* @see rhs_proxy
*/
op_add_view& operator=(const rhs_proxy& rhs) {
__CILKRTS_ASSERT(this == rhs.m_view);
this->m_value += rhs.m_value;
return *this;
}
///@}
};
/** Monoid class for addition reductions. Instantiate the cilk::reducer
* template class with an op_add monoid to create an addition reducer class.
* For example, to compute
* the sum of a set of `int` values:
*
* cilk::reducer< cilk::op_add<int> > r;
*
* @tparam Type The reducer value type.
* @tparam Align If `false` (the default), reducers instantiated on this
* monoid will be naturally aligned (the Intel Cilk Plus library 1.0
* behavior). If `true`, reducers instantiated on this monoid
* will be cache-aligned for binary compatibility with
* reducers in Intel Cilk Plus library version 0.9.
*
* @see ReducersAdd
* @see op_add_view
*
* @ingroup ReducersAdd
*/
template <typename Type, bool Align = false>
struct op_add : public monoid_with_view<op_add_view<Type>, Align> {};
/** **Deprecated** addition reducer wrapper class.
*
* reducer_opadd is the same as @ref reducer<@ref op_add>, except that
* reducer_opadd is a proxy for the contained view, so that accumulator
* variable update operations can be applied directly to the reducer. For
* example, a value is added to a `reducer<%op_add>` with `*r += a`, but a
* value can be added to a `%reducer_opadd` with `r += a`.
*
* @deprecated Users are strongly encouraged to use `reducer<monoid>`
* reducers rather than the old wrappers like reducer_opadd.
* The `reducer<monoid>` reducers show the reducer/monoid/view
* architecture more clearly, are more consistent in their
* implementation, and present a simpler model for new
* user-implemented reducers.
*
* @note Implicit conversions are provided between `%reducer_opadd`
* and `reducer<%op_add>`. This allows incremental code
* conversion: old code that used `%reducer_opadd` can pass a
* `%reducer_opadd` to a converted function that now expects a
* pointer or reference to a `reducer<%op_add>`, and vice
* versa.
*
* @tparam Type The value type of the reducer.
*
* @see op_add
* @see reducer
* @see ReducersAdd
*
* @ingroup ReducersAdd
*/
template <typename Type>
class reducer_opadd : public reducer< op_add<Type, true> >
{
typedef reducer< op_add<Type, true> > base;
using base::view;
public:
/// The view type for the reducer.
typedef typename base::view_type view_type;
/// The view's rhs proxy type.
typedef typename view_type::rhs_proxy rhs_proxy;
/// The view type for the reducer.
typedef view_type View;
/// The monoid type for the reducer.
typedef typename base::monoid_type Monoid;
/** @name Constructors
*/
///@{
/** Default (identity) constructor.
*
* Constructs the wrapper with the default initial value of `Type()`.
*/
reducer_opadd() {}
/** Value constructor.
*
* Constructs the wrapper with a specified initial value.
*/
explicit reducer_opadd(const Type& initial_value) : base(initial_value) {}
///@}
/** @name Forwarded functions
* @details Functions that update the contained accumulator variable are
* simply forwarded to the contained @ref op_add_view. */
///@{
/// @copydoc op_add_view::operator+=(const Type&)
reducer_opadd& operator+=(const Type& x) { view() += x; return *this; }
/// @copydoc op_add_view::operator-=(const Type&)
reducer_opadd& operator-=(const Type& x) { view() -= x; return *this; }
/// @copydoc op_add_view::operator++()
reducer_opadd& operator++() { ++view(); return *this; }
/// @copydoc op_add_view::operator++(int)
void operator++(int) { view()++; }
/// @copydoc op_add_view::operator-\-()
reducer_opadd& operator--() { --view(); return *this; }
/// @copydoc op_add_view::operator-\-(int)
void operator--(int) { view()--; }
// The legacy definitions of reducer_opadd::operator+() and
// reducer_opadd::operator-() have different behavior and a different
// return type than this definition. The legacy version is defined as a
// member function, so this new version is defined as a free function to
// give it a different signature, so that they won't end up sharing a
// single object file entry.
/// @copydoc op_add_view::operator+(const Type&) const
friend rhs_proxy operator+(const reducer_opadd& r, const Type& x)
{
return r.view() + x;
}
/// @copydoc op_add_view::operator-(const Type&) const
friend rhs_proxy operator-(const reducer_opadd& r, const Type& x)
{
return r.view() - x;
}
/// @copydoc op_add_view::operator=(const rhs_proxy&)
reducer_opadd& operator=(const rhs_proxy& temp)
{
view() = temp;
return *this;
}
///@}
/** @name Dereference
* @details Dereferencing a wrapper is a no-op. It simply returns the
* wrapper. Combined with the rule that the wrapper forwards view
* operations to its contained view, this means that view operations can
* be written the same way on reducers and wrappers, which is convenient
* for incrementally converting old code using wrappers to use reducers
* instead. That is:
*
* reducer< op_add<int> > r;
* *r += a; // *r returns the view
* // operator += is a view member function
*
* reducer_opadd<int> w;
* *w += a; // *w returns the wrapper
* // operator += is a wrapper member function that
* // calls the corresponding view function
*/
///@{
reducer_opadd& operator*() { return *this; }
reducer_opadd const& operator*() const { return *this; }
reducer_opadd* operator->() { return this; }
reducer_opadd const* operator->() const { return this; }
///@}
/** @name Upcast
* @details In Intel Cilk Plus library 0.9, reducers were always cache-aligned.
* In library 1.0, reducer cache alignment is optional. By default,
* reducers are unaligned (i.e., just naturally aligned), but legacy
* wrappers inherit from cache-aligned reducers for binary compatibility.
*
* This means that a wrapper will automatically be upcast to its aligned
* reducer base class. The following conversion operators provide
* pseudo-upcasts to the corresponding unaligned reducer class.
*/
///@{
operator reducer< op_add<Type, false> >& ()
{
return *reinterpret_cast< reducer< op_add<Type, false> >* >(this);
}
operator const reducer< op_add<Type, false> >& () const
{
return *reinterpret_cast< const reducer< op_add<Type, false> >* >(this);
}
///@}
};
/// @cond internal
/** Metafunction specialization for reducer conversion.
*
* This specialization of the @ref legacy_reducer_downcast template class
* defined in reducer.h causes the `reducer< op_add<Type> >` class to have an
* `operator reducer_opadd<Type>& ()` conversion operator that statically
* downcasts the `reducer<op_add>` to the corresponding `reducer_opadd` type.
* (The reverse conversion, from `reducer_opadd` to `reducer<op_add>`, is just
* an upcast, which is provided for free by the language.)
*
* @ingroup ReducersAdd
*/
template <typename Type, bool Align>
struct legacy_reducer_downcast<reducer<op_add<Type, Align> > >
{
typedef reducer_opadd<Type> type;
};
/// @endcond
} // namespace cilk
#endif // __cplusplus
/** @ingroup ReducersAdd
*/
///@{
/** @name C Language Reducer Macros
*
* These macros are used to declare and work with numeric op_add reducers in
* C code.
*
* @see @ref page_reducers_in_c
*/
///@{
__CILKRTS_BEGIN_EXTERN_C
/** Declares opadd reducer type name.
*
* This macro expands into the identifier which is the name of the op_add
* reducer type for a specified numeric type.
*
* @param tn The @ref reducers_c_type_names "numeric type name" specifying
* the type of the reducer.
*
* @see @ref reducers_c_predefined
* @see ReducersAdd
*/
#define CILK_C_REDUCER_OPADD_TYPE(tn) \
__CILKRTS_MKIDENT(cilk_c_reducer_opadd_,tn)
/** Declares an op_add reducer object.
*
* This macro expands into a declaration of an op_add reducer object for a
* specified numeric type. For example:
*
* CILK_C_REDUCER_OPADD(my_reducer, double, 0.0);
*
* @param obj The variable name to be used for the declared reducer object.
* @param tn The @ref reducers_c_type_names "numeric type name" specifying
* the type of the reducer.
* @param v The initial value for the reducer. (A value which can be
* assigned to the numeric type represented by @a tn.)
*
* @see @ref reducers_c_predefined
* @see ReducersAdd
*/
#define CILK_C_REDUCER_OPADD(obj,tn,v) \
CILK_C_REDUCER_OPADD_TYPE(tn) obj = \
CILK_C_INIT_REDUCER(_Typeof(obj.value), \
__CILKRTS_MKIDENT(cilk_c_reducer_opadd_reduce_,tn), \
__CILKRTS_MKIDENT(cilk_c_reducer_opadd_identity_,tn), \
__cilkrts_hyperobject_noop_destroy, v)
/// @cond internal
/** Declares the op_add reducer functions for a numeric type.
*
* This macro expands into external function declarations for functions which
* implement the reducer functionality for the op_add reducer type for a
* specified numeric type.
*
* @param t The value type of the reducer.
* @param tn The value "type name" identifier, used to construct the reducer
* type name, function names, etc.
*/
#define CILK_C_REDUCER_OPADD_DECLARATION(t,tn) \
typedef CILK_C_DECLARE_REDUCER(t) CILK_C_REDUCER_OPADD_TYPE(tn); \
__CILKRTS_DECLARE_REDUCER_REDUCE(cilk_c_reducer_opadd,tn,l,r); \
__CILKRTS_DECLARE_REDUCER_IDENTITY(cilk_c_reducer_opadd,tn);
/** Defines the op_add reducer functions for a numeric type.
*
* This macro expands into function definitions for functions which implement
* the reducer functionality for the op_add reducer type for a specified
* numeric type.
*
* @param t The value type of the reducer.
* @param tn The value "type name" identifier, used to construct the reducer
* type name, function names, etc.
*/
#define CILK_C_REDUCER_OPADD_DEFINITION(t,tn) \
typedef CILK_C_DECLARE_REDUCER(t) CILK_C_REDUCER_OPADD_TYPE(tn); \
__CILKRTS_DECLARE_REDUCER_REDUCE(cilk_c_reducer_opadd,tn,l,r) \
{ *(t*)l += *(t*)r; } \
__CILKRTS_DECLARE_REDUCER_IDENTITY(cilk_c_reducer_opadd,tn) \
{ *(t*)v = 0; }
///@{
/** @def CILK_C_REDUCER_OPADD_INSTANCE
* @brief Declares or defines implementation functions for a reducer type.
*
* In the runtime source file c_reducers.c, the macro `CILK_C_DEFINE_REDUCERS`
* will be defined, and this macro will generate reducer implementation
* functions. Everywhere else, `CILK_C_DEFINE_REDUCERS` will be undefined,
* and this macro will expand into external declarations for the functions.
*/
#ifdef CILK_C_DEFINE_REDUCERS
# define CILK_C_REDUCER_OPADD_INSTANCE(t,tn) \
CILK_C_REDUCER_OPADD_DEFINITION(t,tn)
#else
# define CILK_C_REDUCER_OPADD_INSTANCE(t,tn) \
CILK_C_REDUCER_OPADD_DECLARATION(t,tn)
#endif
///@}
/* Declares or defines an instance of the reducer type and its functions for each
* numeric type.
*/
CILK_C_REDUCER_OPADD_INSTANCE(char, char)
CILK_C_REDUCER_OPADD_INSTANCE(unsigned char, uchar)
CILK_C_REDUCER_OPADD_INSTANCE(signed char, schar)
CILK_C_REDUCER_OPADD_INSTANCE(wchar_t, wchar_t)
CILK_C_REDUCER_OPADD_INSTANCE(short, short)
CILK_C_REDUCER_OPADD_INSTANCE(unsigned short, ushort)
CILK_C_REDUCER_OPADD_INSTANCE(int, int)
CILK_C_REDUCER_OPADD_INSTANCE(unsigned int, uint)
CILK_C_REDUCER_OPADD_INSTANCE(unsigned int, unsigned) /* alternate name */
CILK_C_REDUCER_OPADD_INSTANCE(long, long)
CILK_C_REDUCER_OPADD_INSTANCE(unsigned long, ulong)
CILK_C_REDUCER_OPADD_INSTANCE(long long, longlong)
CILK_C_REDUCER_OPADD_INSTANCE(unsigned long long, ulonglong)
CILK_C_REDUCER_OPADD_INSTANCE(float, float)
CILK_C_REDUCER_OPADD_INSTANCE(double, double)
CILK_C_REDUCER_OPADD_INSTANCE(long double, longdouble)
//@endcond
__CILKRTS_END_EXTERN_C
///@}
///@}
#endif /* REDUCER_OPADD_H_INCLUDED */
@@ -0,0 +1,614 @@
/* reducer_opand.h -*- C++ -*-
*
* Copyright (C) 2009-2016, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* *********************************************************************
*
* PLEASE NOTE: This file is a downstream copy of a file mainitained in
* a repository at cilkplus.org. Changes made to this file that are not
* submitted through the contribution process detailed at
* http://www.cilkplus.org/submit-cilk-contribution will be lost the next
* time that a new version is released. Changes only submitted to the
* GNU compiler collection or posted to the git repository at
* https://bitbucket.org/intelcilkruntime/intel-cilk-runtime.git are
* not tracked.
*
* We welcome your contributions to this open source project. Thank you
* for your assistance in helping us improve Cilk Plus.
*/
/** @file reducer_opand.h
*
* @brief Defines classes for doing parallel bitwise AND reductions.
*
* @ingroup ReducersAnd
*
* @see ReducersAnd
*/
#ifndef REDUCER_OPAND_H_INCLUDED
#define REDUCER_OPAND_H_INCLUDED
#include <cilk/reducer.h>
/** @defgroup ReducersAnd Bitwise AND Reducers
*
* Bitwise AND reducers allow the computation of the bitwise AND of a set of
* values in parallel.
*
* @ingroup Reducers
*
* You should be familiar with @ref pagereducers "Intel(R) Cilk(TM) Plus reducers",
* described in file `reducers.md`, and particularly with @ref reducers_using,
* before trying to use the information in this file.
*
* @section redopand_usage Usage Example
*
* cilk::reducer< cilk::op_and<unsigned> > r;
* cilk_for (int i = 0; i != N; ++i) {
* *r &= a[i];
* }
* unsigned result;
* r.move_out(result);
*
* @section redopand_monoid The Monoid
*
* @subsection redopand_monoid_values Value Set
*
* The value set of a bitwise AND reducer is the set of values of `Type`,
* which is expected to be a builtin integer type which has a representation
* as a sequence of bits (or something like it, such as `bool` or
* `std::bitset`).
*
* @subsection redopand_monoid_operator Operator
*
* The bitwise AND operator is defined by the "`&`" binary operator on `Type`.
*
* @subsection redopand_monoid_identity Identity
*
* The identity value of the reducer is the value whose representation
* contains all 1-bits. This is expected to be the value of the expression
* `~Type()` (i.e., the bitwise negation operator applied to the default value
* of the value type).
*
* @section redopand_operations Operations
*
* @subsection redopand_constructors Constructors
*
* reducer() // identity
* reducer(const Type& value)
* reducer(move_in(Type& variable))
*
* @subsection redopand_get_set Set and Get
*
* r.set_value(const Type& value)
* const Type& = r.get_value() const
* r.move_in(Type& variable)
* r.move_out(Type& variable)
*
* @subsection redopand_initial Initial Values
*
* If a bitwise AND reducer is constructed without an explicit initial value,
* then its initial value will be its identity value, as long as `Type`
* satisfies the requirements of @ref redopand_types.
*
* @subsection redopand_view_ops View Operations
*
* *r &= a
* *r = *r & a
* *r = *r & a1 & a2 … & an
*
* @section redopand_types Type and Operator Requirements
*
* `Type` must be `Copy Constructible`, `Default Constructible`, and
* `Assignable`.
*
* The operator "`&=`" must be defined on `Type`, with `x &= a` having the
* same meaning as `x = x & a`.
*
* The expression `~ Type()` must be a valid expression which yields the
* identity value (the value of `Type` whose representation consists of all
* 1-bits).
*
* @section redopand_in_c Bitwise AND Reducers in C
*
* The @ref CILK_C_REDUCER_OPAND and @ref CILK_C_REDUCER_OPAND_TYPE macros can
* be used to do bitwise AND reductions in C. For example:
*
* CILK_C_REDUCER_OPAND(r, uint, ~0);
* CILK_C_REGISTER_REDUCER(r);
* cilk_for(int i = 0; i != n; ++i) {
* REDUCER_VIEW(r) &= a[i];
* }
* CILK_C_UNREGISTER_REDUCER(r);
* printf("The bitwise AND of the elements of a is %x\n", REDUCER_VIEW(r));
*
* See @ref reducers_c_predefined.
*/
#ifdef __cplusplus
namespace cilk {
/** The bitwise AND reducer view class.
*
* This is the view class for reducers created with
* `cilk::reducer< cilk::op_and<Type> >`. It holds the accumulator variable
* for the reduction, and allows only AND operations to be performed on it.
*
* @note The reducer "dereference" operation (`reducer::operator *()`)
* yields a reference to the view. Thus, for example, the view class's
* `&=` operation would be used in an expression like `*r &= a`, where
* `r` is an opmod reducer variable.
*
* @tparam Type The type of the contained accumulator variable. This will
* be the value type of a monoid_with_view that is
* instantiated with this view.
*
* @see ReducersAnd
* @see op_and
*
* @ingroup ReducersAnd
*/
template <typename Type>
class op_and_view : public scalar_view<Type>
{
typedef scalar_view<Type> base;
public:
/** Class to represent the right-hand side of `*reducer = *reducer & value`.
*
* The only assignment operator for the op_and_view class takes an
* rhs_proxy as its operand. This results in the syntactic restriction
* that the only expressions that can be assigned to an op_and_view are
* ones which generate an rhs_proxy - that is, expressions of the form
* `op_and_view & value ... & value`.
*
* @warning
* The lhs and rhs views in such an assignment must be the same;
* otherwise, the behavior will be undefined. (I.e., `v1 = v1 & x` is
* legal; `v1 = v2 & x` is illegal.) This condition will be checked with
* a runtime assertion when compiled in debug mode.
*
* @see op_and_view
*/
class rhs_proxy {
private:
friend class op_and_view;
const op_and_view* m_view;
Type m_value;
// Constructor is invoked only from op_and_view::operator&().
//
rhs_proxy(const op_and_view* view, const Type& value) : m_view(view), m_value(value) {}
rhs_proxy& operator=(const rhs_proxy&); // Disable assignment operator
rhs_proxy(); // Disable default constructor
public:
/** Bitwise AND with an additional `rhs` value. If `v` is an op_and_view
* and `a1` is a value, then the expression `v & a1` invokes the
* view's `operator&()` to create an rhs_proxy for `(v, a1)`; then
* `v & a1 & a2` invokes the rhs_proxy's `operator&()` to create a new
* rhs_proxy for `(v, a1&a2)`. This allows the right-hand side of an
* assignment to be not just `view & value`, but
* `view & value & value ... & value`. The effect is that
*
* v = v & a1 & a2 ... & an;
*
* is evaluated as
*
* v = v & (a1 & a2 ... & an);
*/
rhs_proxy& operator&(const Type& x) { m_value &= x; return *this; }
};
/** Default/identity constructor. This constructor initializes the
* contained value to `~ Type()`.
*/
op_and_view() : base(~Type()) {}
/** Construct with a specified initial value.
*/
explicit op_and_view(const Type& v) : base(v) {}
/** Reduces the views of two strands.
*
* This function is invoked by the @ref op_and monoid to combine the views
* of two strands when the right strand merges with the left one. It
* "ANDs" the value contained in the left-strand view with the value
* contained in the right-strand view, and leaves the value in the
* right-strand view undefined.
*
* @param right A pointer to the right-strand view. (`this` points to
* the left-strand view.)
*
* @note Used only by the @ref op_and monoid to implement the monoid
* reduce operation.
*/
void reduce(op_and_view* right) { this->m_value &= right->m_value; }
/** @name Accumulator variable updates.
*
* These functions support the various syntaxes for "ANDing" the
* accumulator variable contained in the view with some value.
*/
///@{
/** Performs AND between the accumulator variable and @a x.
*/
op_and_view& operator&=(const Type& x) { this->m_value &= x; return *this; }
/** Creates an object representing `*this & x`.
*
* @see rhs_proxy
*/
rhs_proxy operator&(const Type& x) const { return rhs_proxy(this, x); }
/** Assigns the result of a `view & value` expression to the view. Note that
* this is the only assignment operator for this class.
*
* @see rhs_proxy
*/
op_and_view& operator=(const rhs_proxy& rhs) {
__CILKRTS_ASSERT(this == rhs.m_view);
this->m_value &= rhs.m_value;
return *this;
}
///@}
};
/** Monoid class for bitwise AND reductions. Instantiate the cilk::reducer
* template class with an op_and monoid to create a bitwise AND reducer
* class. For example, to compute the bitwise AND of a set of `unsigned long`
* values:
*
* cilk::reducer< cilk::op_and<unsigned long> > r;
*
* @tparam Type The reducer value type.
* @tparam Align If `false` (the default), reducers instantiated on this
* monoid will be naturally aligned (the Intel Cilk Plus library 1.0
* behavior). If `true`, reducers instantiated on this monoid
* will be cache-aligned for binary compatibility with
* reducers in Intel Cilk Plus library version 0.9.
*
* @see ReducersAnd
* @see op_and_view
*
* @ingroup ReducersAnd
*/
template <typename Type, bool Align = false>
struct op_and : public monoid_with_view<op_and_view<Type>, Align> {};
/** Deprecated bitwise AND reducer class.
*
* reducer_opand is the same as @ref reducer<@ref op_and>, except that
* reducer_opand is a proxy for the contained view, so that accumulator
* variable update operations can be applied directly to the reducer. For
* example, a value is "ANDed" with a `reducer<%op_and>` with `*r &= a`, but a
* value can be "ANDed" with a `%reducer_opand` with `r &= a`.
*
* @deprecated Users are strongly encouraged to use `reducer<monoid>`
* reducers rather than the old wrappers like reducer_opand.
* The `reducer<monoid>` reducers show the reducer/monoid/view
* architecture more clearly, are more consistent in their
* implementation, and present a simpler model for new
* user-implemented reducers.
*
* @note Implicit conversions are provided between `%reducer_opand`
* and `reducer<%op_and>`. This allows incremental code
* conversion: old code that used `%reducer_opand` can pass a
* `%reducer_opand` to a converted function that now expects a
* pointer or reference to a `reducer<%op_and>`, and vice
* versa.
*
* @tparam Type The value type of the reducer.
*
* @see op_and
* @see reducer
* @see ReducersAnd
*
* @ingroup ReducersAnd
*/
template <typename Type>
class reducer_opand : public reducer< op_and<Type, true> >
{
typedef reducer< op_and<Type, true> > base;
using base::view;
public:
/// The view type for the reducer.
typedef typename base::view_type view_type;
/// The view's rhs proxy type.
typedef typename view_type::rhs_proxy rhs_proxy;
/// The view type for the reducer.
typedef view_type View;
/// The monoid type for the reducer.
typedef typename base::monoid_type Monoid;
/** @name Constructors
*/
///@{
/** Default constructor.
*
* Constructs the wrapper with the default initial value of `Type()`
* (not the identity value).
*/
reducer_opand() : base(Type()) {}
/** Value constructor.
*
* Constructs the wrapper with a specified initial value.
*/
explicit reducer_opand(const Type& initial_value) : base(initial_value) {}
///@}
/** @name Forwarded functions
* @details Functions that update the contained accumulator variable are
* simply forwarded to the contained @ref op_and_view. */
///@{
/// @copydoc op_and_view::operator&=(const Type&)
reducer_opand& operator&=(const Type& x)
{
view() &= x;
return *this;
}
// The legacy definition of reducer_opand::operator&() has different
// behavior and a different return type than this definition. The legacy
// version is defined as a member function, so this new version is defined
// as a free function to give it a different signature, so that they won't
// end up sharing a single object file entry.
/// @copydoc op_and_view::operator&(const Type&) const
friend rhs_proxy operator&(const reducer_opand& r, const Type& x)
{
return r.view() & x;
}
/// @copydoc op_and_view::operator=(const rhs_proxy&)
reducer_opand& operator=(const rhs_proxy& temp)
{
view() = temp;
return *this;
}
///@}
/** @name Dereference
* @details Dereferencing a wrapper is a no-op. It simply returns the
* wrapper. Combined with the rule that the wrapper forwards view
* operations to its contained view, this means that view operations can
* be written the same way on reducers and wrappers, which is convenient
* for incrementally converting old code using wrappers to use reducers
* instead. That is:
*
* reducer< op_and<int> > r;
* *r &= a; // *r returns the view
* // operator &= is a view member function
*
* reducer_opand<int> w;
* *w &= a; // *w returns the wrapper
* // operator &= is a wrapper member function that
* // calls the corresponding view function
*/
///@{
reducer_opand& operator*() { return *this; }
reducer_opand const& operator*() const { return *this; }
reducer_opand* operator->() { return this; }
reducer_opand const* operator->() const { return this; }
///@}
/** @name Upcast
* @details In Intel Cilk Plus library 0.9, reducers were always cache-aligned.
* In library 1.0, reducer cache alignment is optional. By default,
* reducers are unaligned (i.e., just naturally aligned), but legacy
* wrappers inherit from cache-aligned reducers for binary compatibility.
*
* This means that a wrapper will automatically be upcast to its aligned
* reducer base class. The following conversion operators provide
* pseudo-upcasts to the corresponding unaligned reducer class.
*/
///@{
operator reducer< op_and<Type, false> >& ()
{
return *reinterpret_cast< reducer< op_and<Type, false> >* >(this);
}
operator const reducer< op_and<Type, false> >& () const
{
return *reinterpret_cast< const reducer< op_and<Type, false> >* >(this);
}
///@}
};
/// @cond internal
/** Metafunction specialization for reducer conversion.
*
* This specialization of the @ref legacy_reducer_downcast template class
* defined in reducer.h causes the `reducer< op_and<Type> >` class to have an
* `operator reducer_opand<Type>& ()` conversion operator that statically
* downcasts the `reducer<op_and>` to the corresponding `reducer_opand` type.
* (The reverse conversion, from `reducer_opand` to `reducer<op_and>`, is just
* an upcast, which is provided for free by the language.)
*
* @ingroup ReducersAnd
*/
template <typename Type, bool Align>
struct legacy_reducer_downcast<reducer<op_and<Type, Align> > >
{
typedef reducer_opand<Type> type;
};
/// @endcond
} // namespace cilk
#endif // __cplusplus
/** @ingroup ReducersAdd
*/
///@{
/** @name C language reducer macros
*
* These macros are used to declare and work with op_and reducers in C code.
*
* @see @ref page_reducers_in_c
*/
///@{
__CILKRTS_BEGIN_EXTERN_C
/** Declares `opand` reducer type name.
*
* This macro expands into the identifier which is the name of the op_and
* reducer type for a specified numeric type.
*
* @param tn The @ref reducers_c_type_names "numeric type name" specifying
* the type of the reducer.
*
* @see @ref reducers_c_predefined
* @see ReducersAnd
*/
#define CILK_C_REDUCER_OPAND_TYPE(tn) \
__CILKRTS_MKIDENT(cilk_c_reducer_opand_,tn)
/** Declares an op_and reducer object.
*
* This macro expands into a declaration of an op_and reducer object for a
* specified numeric type. For example:
*
* CILK_C_REDUCER_OPAND(my_reducer, ulong, ~0UL);
*
* @param obj The variable name to be used for the declared reducer object.
* @param tn The @ref reducers_c_type_names "numeric type name" specifying
* the type of the reducer.
* @param v The initial value for the reducer. (A value which can be
* assigned to the numeric type represented by @a tn.)
*
* @see @ref reducers_c_predefined
* @see ReducersAnd
*/
#define CILK_C_REDUCER_OPAND(obj,tn,v) \
CILK_C_REDUCER_OPAND_TYPE(tn) obj = \
CILK_C_INIT_REDUCER(_Typeof(obj.value), \
__CILKRTS_MKIDENT(cilk_c_reducer_opand_reduce_,tn), \
__CILKRTS_MKIDENT(cilk_c_reducer_opand_identity_,tn), \
__cilkrts_hyperobject_noop_destroy, v)
/// @cond internal
/** Declares the op_and reducer functions for a numeric type.
*
* This macro expands into external function declarations for functions which
* implement the reducer functionality for the op_and reducer type for a
* specified numeric type.
*
* @param t The value type of the reducer.
* @param tn The value "type name" identifier, used to construct the reducer
* type name, function names, etc.
*/
#define CILK_C_REDUCER_OPAND_DECLARATION(t,tn) \
typedef CILK_C_DECLARE_REDUCER(t) CILK_C_REDUCER_OPAND_TYPE(tn); \
__CILKRTS_DECLARE_REDUCER_REDUCE(cilk_c_reducer_opand,tn,l,r); \
__CILKRTS_DECLARE_REDUCER_IDENTITY(cilk_c_reducer_opand,tn);
/** Defines the op_and reducer functions for a numeric type.
*
* This macro expands into function definitions for functions which implement
* the reducer functionality for the op_and reducer type for a specified
* numeric type.
*
* @param t The value type of the reducer.
* @param tn The value "type name" identifier, used to construct the reducer
* type name, function names, etc.
*/
#define CILK_C_REDUCER_OPAND_DEFINITION(t,tn) \
typedef CILK_C_DECLARE_REDUCER(t) CILK_C_REDUCER_OPAND_TYPE(tn); \
__CILKRTS_DECLARE_REDUCER_REDUCE(cilk_c_reducer_opand,tn,l,r) \
{ *(t*)l &= *(t*)r; } \
__CILKRTS_DECLARE_REDUCER_IDENTITY(cilk_c_reducer_opand,tn) \
{ *(t*)v = ~((t)0); }
///@{
/** @def CILK_C_REDUCER_OPAND_INSTANCE
* @brief Declares or defines implementation functions for a reducer type.
*
* In the runtime source file c_reducers.c, the macro `CILK_C_DEFINE_REDUCERS`
* will be defined, and this macro will generate reducer implementation
* functions. Everywhere else, `CILK_C_DEFINE_REDUCERS` will be undefined, and
* this macro will expand into external declarations for the functions.
*/
#ifdef CILK_C_DEFINE_REDUCERS
# define CILK_C_REDUCER_OPAND_INSTANCE(t,tn) \
CILK_C_REDUCER_OPAND_DEFINITION(t,tn)
#else
# define CILK_C_REDUCER_OPAND_INSTANCE(t,tn) \
CILK_C_REDUCER_OPAND_DECLARATION(t,tn)
#endif
///@}
/* Declares or defines an instance of the reducer type and its functions for
* each numeric type.
*/
CILK_C_REDUCER_OPAND_INSTANCE(char, char)
CILK_C_REDUCER_OPAND_INSTANCE(unsigned char, uchar)
CILK_C_REDUCER_OPAND_INSTANCE(signed char, schar)
CILK_C_REDUCER_OPAND_INSTANCE(wchar_t, wchar_t)
CILK_C_REDUCER_OPAND_INSTANCE(short, short)
CILK_C_REDUCER_OPAND_INSTANCE(unsigned short, ushort)
CILK_C_REDUCER_OPAND_INSTANCE(int, int)
CILK_C_REDUCER_OPAND_INSTANCE(unsigned int, uint)
CILK_C_REDUCER_OPAND_INSTANCE(unsigned int, unsigned) /* alternate name */
CILK_C_REDUCER_OPAND_INSTANCE(long, long)
CILK_C_REDUCER_OPAND_INSTANCE(unsigned long, ulong)
CILK_C_REDUCER_OPAND_INSTANCE(long long, longlong)
CILK_C_REDUCER_OPAND_INSTANCE(unsigned long long, ulonglong)
//@endcond
__CILKRTS_END_EXTERN_C
///@}
///@}
#endif /* REDUCER_OPAND_H_INCLUDED */
@@ -0,0 +1,453 @@
/* reducer_opmul.h -*- C++ -*-
*
* Copyright (C) 2012-2016, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* *********************************************************************
*
* PLEASE NOTE: This file is a downstream copy of a file mainitained in
* a repository at cilkplus.org. Changes made to this file that are not
* submitted through the contribution process detailed at
* http://www.cilkplus.org/submit-cilk-contribution will be lost the next
* time that a new version is released. Changes only submitted to the
* GNU compiler collection or posted to the git repository at
* https://bitbucket.org/intelcilkruntime/intel-cilk-runtime.git are
* not tracked.
*
* We welcome your contributions to this open source project. Thank you
* for your assistance in helping us improve Cilk Plus.
*/
/** @file reducer_opmul.h
*
* @brief Defines classes for doing parallel multiplication reductions.
*
* @ingroup ReducersMul
*
* @see ReducersMul
*/
#ifndef REDUCER_OPMUL_H_INCLUDED
#define REDUCER_OPMUL_H_INCLUDED
#include <cilk/reducer.h>
/** @defgroup ReducersMul Multiplication Reducers
*
* Multiplication reducers allow the computation of the product of a set of
* values in parallel.
*
* @ingroup Reducers
*
* You should be familiar with @ref pagereducers "Intel(R) Cilk(TM) Plus reducers",
* described in file `reducers.md`, and particularly with @ref reducers_using,
* before trying to use the information in this file.
*
* @section redopmul_usage Usage Example
*
* cilk::reducer< cilk::op_mul<double> > r;
* cilk_for (int i = 0; i != N; ++i) {
* *r *= a[i];
* }
* double product;
* r.move_out(product);
*
* @section redopmul_monoid The Monoid
*
* @subsection redopmul_monoid_values Value Set
*
* The value set of a multiplication reducer is the set of values of `Type`,
* which is expected to be a builtin numeric type (or something like it, such
* as `std::complex`).
*
* @subsection redopmul_monoid_operator Operator
*
* The operator of a multiplication reducer is the multiplication operation,
* defined by the "`*`" binary operator on `Type`.
*
* @subsection redopmul_monoid_identity Identity
*
* The identity value of the reducer is the numeric value "`1`". This is
* expected to be the value of the expression `Type(1)`.
*
* @section redopmul_operations Operations
*
* @subsection redopmul_constructors Constructors
*
* reducer() // identity
* reducer(const Type& value)
* reducer(move_in(Type& variable))
*
* @subsection redopmul_get_set Set and Get
*
* r.set_value(const Type& value)
* const Type& = r.get_value() const
* r.move_in(Type& variable)
* r.move_out(Type& variable)
*
* @subsection redopmul_initial Initial Values
*
* If a multiplication reducer is constructed without an explicit initial
* value, then its initial value will be its identity value, as long as `Type`
* satisfies the requirements of @ref redopmul_types.
*
* @subsection redopmul_view_ops View Operations
*
* *r *= a
* *r = *r * a
* *r = *r * a1 * a2 … * an
*
* @section redopmul_floating_point Issues with Floating-Point Types
*
* Because of overflow and underflow issues, floating-point multiplication is
* not really associative. For example, `(1e200 * 1e-200) * 1e-200 == 1e-200`,
* but `1e200 * (1e-200 * 1e-200 == 0.
*
* In many cases, this won't matter, but computations which have been
* carefully ordered to control overflow and underflow may not deal well with
* being reassociated. In general, you should be sure to understand the
* floating-point behavior of your program before doing any transformation
* that will reassociate its computations.
*
* @section redopmul_types Type and Operator Requirements
*
* `Type` must be `Copy Constructible`, `Default Constructible`, and
* `Assignable`.
*
* The operator "`*=`" must be defined on `Type`, with `x *= a` having the same
* meaning as `x = x * a`.
*
* The expression `Type(1)` must be a valid expression which yields the
* identity value (the value of `Type` whose numeric value is `1`).
*
* @section redopmul_in_c Multiplication Reducers in C
*
* The @ref CILK_C_REDUCER_OPMUL and @ref CILK_C_REDUCER_OPMUL_TYPE macros can
* be used to do multiplication reductions in C. For example:
*
* CILK_C_REDUCER_OPMUL(r, double, 1);
* CILK_C_REGISTER_REDUCER(r);
* cilk_for(int i = 0; i != n; ++i) {
* REDUCER_VIEW(r) *= a[i];
* }
* CILK_C_UNREGISTER_REDUCER(r);
* printf("The product of the elements of a is %f\n", REDUCER_VIEW(r));
*
* See @ref reducers_c_predefined.
*/
#ifdef __cplusplus
namespace cilk {
/** The multiplication reducer view class.
*
* This is the view class for reducers created with
* `cilk::reducer< cilk::op_mul<Type> >`. It holds the accumulator variable
* for the reduction, and allows only multiplication operations to be
* performed on it.
*
* @note The reducer "dereference" operation (`reducer::operator *()`)
* yields a reference to the view. Thus, for example, the view class's
* `*=` operation would be used in an expression like `*r *= a`, where
* `r` is an op_mul reducer variable.
*
* @tparam Type The type of the contained accumulator variable. This will
* be the value type of a monoid_with_view that is
* instantiated with this view.
*
* @see ReducersMul
* @see op_mul
*
* @ingroup ReducersMul
*/
template <typename Type>
class op_mul_view : public scalar_view<Type>
{
typedef scalar_view<Type> base;
public:
/** Class to represent the right-hand side of `*reducer = *reducer * value`.
*
* The only assignment operator for the op_mul_view class takes an
* rhs_proxy as its operand. This results in the syntactic restriction
* that the only expressions that can be assigned to an op_mul_view are
* ones which generate an rhs_proxy - that is, expressions of the form
* `op_mul_view * value ... * value`.
*
* @warning
* The lhs and rhs views in such an assignment must be the same;
* otherwise, the behavior will be undefined. (I.e., `v1 = v1 * x` is
* legal; `v1 = v2 * x` is illegal.) This condition will be checked with a
* runtime assertion when compiled in debug mode.
*
* @see op_mul_view
*/
class rhs_proxy {
friend class op_mul_view;
const op_mul_view* m_view;
Type m_value;
// Constructor is invoked only from op_mul_view::operator*().
//
rhs_proxy(const op_mul_view* view, const Type& value) : m_view(view), m_value(value) {}
rhs_proxy& operator=(const rhs_proxy&); // Disable assignment operator
rhs_proxy(); // Disable default constructor
public:
/** Multiplies by an additional `rhs` value. If `v` is an op_mul_view and
* `a1` is a value, then the expression `v * a1` invokes the view's
* `operator*()` to create an rhs_proxy for `(v, a1)`; then
* `v * a1 * a2` invokes the rhs_proxy's `operator*()` to create a
* new rhs_proxy for `(v, a1*a2)`. This allows the right-hand side of
* an assignment to be not just `view * value`, but
* `view * value * value ... * value`. The effect is that
*
* v = v * a1 * a2 ... * an;
*
* is evaluated as
*
* v = v * (a1 * a2 ... * an);
*/
rhs_proxy& operator*(const Type& x) { m_value *= x; return *this; }
};
/** Default/identity constructor. This constructor initializes the
* contained value to `Type(1)`, which is expected to be the identity
* value for multiplication on `Type`.
*/
op_mul_view() : base(Type(1)) {}
/** Construct with a specified initial value.
*/
explicit op_mul_view(const Type& v) : base(v) {}
/** Reduces two strand views.
*
* This function is invoked by the @ref op_mul monoid to combine the views
* of two strands when the right strand merges with the left one. It
* multiplies the value contained in the left-strand view by the value
* contained in the right-strand view, and leaves the value in the
* right-strand view undefined.
*
* @param right A pointer to the right-strand view. (`this` points to
* the left-strand view.)
*
* @note Used only by the @ref op_mul monoid to implement the monoid
* reduce operation.
*/
void reduce(op_mul_view* right) { this->m_value *= right->m_value; }
/** @name Accumulator variable updates.
*
* These functions support the various syntaxes for multiplying the
* accumulator variable contained in the view by some value.
*/
///@{
/** Multiplies the accumulator variable by @a x.
*/
op_mul_view& operator*=(const Type& x) { this->m_value *= x; return *this; }
/** Creates an object representing `*this * x`.
*
* @see rhs_proxy
*/
rhs_proxy operator*(const Type& x) const { return rhs_proxy(this, x); }
/** Assigns the result of a `view * value` expression to the view. Note that
* this is the only assignment operator for this class.
*
* @see rhs_proxy
*/
op_mul_view& operator=(const rhs_proxy& rhs) {
__CILKRTS_ASSERT(this == rhs.m_view);
this->m_value *= rhs.m_value;
return *this;
}
///@}
};
/** Monoid class for multiplication reductions. Instantiate the cilk::reducer
* template class with an op_mul monoid to create a multiplication reducer
* class. For example, to compute the product of a set of `double` values:
*
* cilk::reducer< cilk::op_mul<double> > r;
*
* @see ReducersMul
* @see op_mul_view
*
* @ingroup ReducersMul
*/
template <typename Type>
struct op_mul : public monoid_with_view< op_mul_view<Type> > {};
} // namespace cilk
#endif // __cplusplus
/** @ingroup ReducersAdd
*/
///@{
/** @name C language reducer macros
*
* These macros are used to declare and work with numeric op_mul reducers in
* C code.
*
* @see @ref page_reducers_in_c
*/
///@{
__CILKRTS_BEGIN_EXTERN_C
/** Declares `opmul` reducer type name.
*
* This macro expands into the identifier which is the name of the op_mul
* reducer type for a specified numeric type.
*
* @param tn The @ref reducers_c_type_names "numeric type name" specifying
* the type of the reducer.
*
* @see @ref reducers_c_predefined
* @see ReducersMul
*/
#define CILK_C_REDUCER_OPMUL_TYPE(tn) \
__CILKRTS_MKIDENT(cilk_c_reducer_opmul_,tn)
/** Declares an op_mul reducer object.
*
* This macro expands into a declaration of an op_mul reducer object for a
* specified numeric type. For example:
*
* CILK_C_REDUCER_OPMUL(my_reducer, double, 1.0);
*
* @param obj The variable name to be used for the declared reducer object.
* @param tn The @ref reducers_c_type_names "numeric type name" specifying
* the type of the reducer.
* @param v The initial value for the reducer. (A value which can be
* assigned to the numeric type represented by @a tn.)
*
* @see @ref reducers_c_predefined
* @see ReducersMul
*/
#define CILK_C_REDUCER_OPMUL(obj,tn,v) \
CILK_C_REDUCER_OPMUL_TYPE(tn) obj = \
CILK_C_INIT_REDUCER(_Typeof(obj.value), \
__CILKRTS_MKIDENT(cilk_c_reducer_opmul_reduce_,tn), \
__CILKRTS_MKIDENT(cilk_c_reducer_opmul_identity_,tn), \
__cilkrts_hyperobject_noop_destroy, v)
/// @cond internal
/** Declares the op_mul reducer functions for a numeric type.
*
* This macro expands into external function declarations for functions which
* implement the reducer functionality for the op_mul reducer type for a
* specified numeric type.
*
* @param t The value type of the reducer.
* @param tn The value "type name" identifier, used to construct the reducer
* type name, function names, etc.
*/
#define CILK_C_REDUCER_OPMUL_DECLARATION(t,tn) \
typedef CILK_C_DECLARE_REDUCER(t) CILK_C_REDUCER_OPMUL_TYPE(tn); \
__CILKRTS_DECLARE_REDUCER_REDUCE(cilk_c_reducer_opmul,tn,l,r); \
__CILKRTS_DECLARE_REDUCER_IDENTITY(cilk_c_reducer_opmul,tn);
/** Defines the op_mul reducer functions for a numeric type.
*
* This macro expands into function definitions for functions which implement
* the reducer functionality for the op_mul reducer type for a specified
* numeric type.
*
* @param t The value type of the reducer.
* @param tn The value "type name" identifier, used to construct the reducer
* type name, function names, etc.
*/
#define CILK_C_REDUCER_OPMUL_DEFINITION(t,tn) \
typedef CILK_C_DECLARE_REDUCER(t) CILK_C_REDUCER_OPMUL_TYPE(tn); \
__CILKRTS_DECLARE_REDUCER_REDUCE(cilk_c_reducer_opmul,tn,l,r) \
{ *(t*)l *= *(t*)r; } \
__CILKRTS_DECLARE_REDUCER_IDENTITY(cilk_c_reducer_opmul,tn) \
{ *(t*)v = 1; }
///@{
/** @def CILK_C_REDUCER_OPMUL_INSTANCE
* @brief Declares or defines implementation functions for a reducer type.
*
* In the runtime source file c_reducers.c, the macro `CILK_C_DEFINE_REDUCERS`
* will be defined, and this macro will generate reducer implementation
* functions. Everywhere else, `CILK_C_DEFINE_REDUCERS` will be undefined, and
* this macro will expand into external declarations for the functions.
*/
#ifdef CILK_C_DEFINE_REDUCERS
# define CILK_C_REDUCER_OPMUL_INSTANCE(t,tn) \
CILK_C_REDUCER_OPMUL_DEFINITION(t,tn)
#else
# define CILK_C_REDUCER_OPMUL_INSTANCE(t,tn) \
CILK_C_REDUCER_OPMUL_DECLARATION(t,tn)
#endif
///@}
/* Declares or defines an instance of the reducer type and its functions for each
* numeric type.
*/
CILK_C_REDUCER_OPMUL_INSTANCE(char, char)
CILK_C_REDUCER_OPMUL_INSTANCE(unsigned char, uchar)
CILK_C_REDUCER_OPMUL_INSTANCE(signed char, schar)
CILK_C_REDUCER_OPMUL_INSTANCE(wchar_t, wchar_t)
CILK_C_REDUCER_OPMUL_INSTANCE(short, short)
CILK_C_REDUCER_OPMUL_INSTANCE(unsigned short, ushort)
CILK_C_REDUCER_OPMUL_INSTANCE(int, int)
CILK_C_REDUCER_OPMUL_INSTANCE(unsigned int, uint)
CILK_C_REDUCER_OPMUL_INSTANCE(unsigned int, unsigned) /* alternate name */
CILK_C_REDUCER_OPMUL_INSTANCE(long, long)
CILK_C_REDUCER_OPMUL_INSTANCE(unsigned long, ulong)
CILK_C_REDUCER_OPMUL_INSTANCE(long long, longlong)
CILK_C_REDUCER_OPMUL_INSTANCE(unsigned long long, ulonglong)
CILK_C_REDUCER_OPMUL_INSTANCE(float, float)
CILK_C_REDUCER_OPMUL_INSTANCE(double, double)
CILK_C_REDUCER_OPMUL_INSTANCE(long double, longdouble)
//@endcond
__CILKRTS_END_EXTERN_C
///@}
///@}
#endif /* REDUCER_OPMUL_H_INCLUDED */
@@ -0,0 +1,609 @@
/* reducer_opor.h -*- C++ -*-
*
* Copyright (C) 2009-2016, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* *********************************************************************
*
* PLEASE NOTE: This file is a downstream copy of a file mainitained in
* a repository at cilkplus.org. Changes made to this file that are not
* submitted through the contribution process detailed at
* http://www.cilkplus.org/submit-cilk-contribution will be lost the next
* time that a new version is released. Changes only submitted to the
* GNU compiler collection or posted to the git repository at
* https://bitbucket.org/intelcilkruntime/intel-cilk-runtime.git are
* not tracked.
*
* We welcome your contributions to this open source project. Thank you
* for your assistance in helping us improve Cilk Plus.
*/
/** @file reducer_opor.h
*
* @brief Defines classes for doing parallel bitwise OR reductions.
*
* @ingroup ReducersOr
*
* @see ReducersOr
*/
#ifndef REDUCER_OPOR_H_INCLUDED
#define REDUCER_OPOR_H_INCLUDED
#include <cilk/reducer.h>
/** @defgroup ReducersOr Bitwise `OR` Reducers
*
* Bitwise `OR` reducers allow the computation of the bitwise `OR` of a set of
* values in parallel.
*
* @ingroup Reducers
*
* You should be familiar with @ref pagereducers "Intel(R) Cilk(TM) Plus reducers",
* described in file `reducers.md`, and particularly with @ref reducers_using,
* before trying to use the information in this file.
*
* @section redopor_usage Usage Example
*
* cilk::reducer< cilk::op_or<unsigned> > r;
* cilk_for (int i = 0; i != N; ++i) {
* *r |= a[i];
* }
* unsigned result;
* r.move_out(result);
*
* @section redopor_monoid The Monoid
*
* @subsection redopor_monoid_values Value Set
*
* The value set of a bitwise `OR` reducer is the set of values of `Type`, which
* is expected to be a builtin integer type which has a representation as a
* sequence of bits (or something like it, such as `bool` or `std::bitset`).
*
* @subsection redopor_monoid_operator Operator
*
* The operator of a bitwise `OR` reducer is the bitwise OR operator, defined by
* the "`|`" binary operator on `Type`.
*
* @subsection redopor_monoid_identity Identity
*
* The identity value of the reducer is the value whose representation
* contains all 0-bits. This is expected to be the value of the default
* constructor `Type()`.
*
* @section redopor_operations Operations
*
* @subsection redopor_constructors Constructors
*
* reducer() // identity
* reducer(const Type& value)
* reducer(move_in(Type& variable))
*
* @subsection redopor_get_set Set and Get
*
* r.set_value(const Type& value)
* const Type& = r.get_value() const
* r.move_in(Type& variable)
* r.move_out(Type& variable)
*
* @subsection redopor_initial Initial Values
*
* If a bitwise OR reducer is constructed without an explicit initial value,
* then its initial value will be its identity value, as long as `Type`
* satisfies the requirements of @ref redopor_types.
*
* @subsection redopor_view_ops View Operations
*
* *r |= a
* *r = *r | a
* *r = *r | a1 | a2 … | an
*
* @section redopor_types Type and Operator Requirements
*
* `Type` must be `Copy Constructible`, `Default Constructible`, and
* `Assignable`.
*
* The operator "`|=`" must be defined on `Type`, with `x |= a` having the
* same meaning as `x = x | a`.
*
* The expression `Type()` must be a valid expression which yields the
* identity value (the value of `Type` whose representation consists of all
* 0-bits).
*
* @section redopor_in_c Bitwise OR Reducers in C
*
* The @ref CILK_C_REDUCER_OPOR and @ref CILK_C_REDUCER_OPOR_TYPE macros can
* be used to do bitwise OR reductions in C. For example:
*
* CILK_C_REDUCER_OPOR(r, uint, 0);
* CILK_C_REGISTER_REDUCER(r);
* cilk_for(int i = 0; i != n; ++i) {
* REDUCER_VIEW(r) |= a[i];
* }
* CILK_C_UNREGISTER_REDUCER(r);
* printf("The bitwise OR of the elements of a is %x\n", REDUCER_VIEW(r));
*
* See @ref reducers_c_predefined.
*/
#ifdef __cplusplus
namespace cilk {
/** The bitwise OR reducer view class.
*
* This is the view class for reducers created with
* `cilk::reducer< cilk::op_or<Type> >`. It holds the accumulator variable for
* the reduction, and allows only `or` operations to be performed on it.
*
* @note The reducer "dereference" operation (`reducer::operator *()`)
* yields a reference to the view. Thus, for example, the view class's
* `|=` operation would be used in an expression like `*r |= a`, where
* `r` is an opmod reducer variable.
*
* @tparam Type The type of the contained accumulator variable. This will
* be the value type of a monoid_with_view that is
* instantiated with this view.
*
* @see ReducersOr
* @see op_or
*
* @ingroup ReducersOr
*/
template <typename Type>
class op_or_view : public scalar_view<Type>
{
typedef scalar_view<Type> base;
public:
/** Class to represent the right-hand side of `*reducer = *reducer | value`.
*
* The only assignment operator for the op_or_view class takes an
* rhs_proxy as its operand. This results in the syntactic restriction
* that the only expressions that can be assigned to an op_or_view are
* ones which generate an rhs_proxy - that is, expressions of the form
* `op_or_view | value ... | value`.
*
* @warning
* The lhs and rhs views in such an assignment must be the same;
* otherwise, the behavior will be undefined. (I.e., `v1 = v1 | x` is
* legal; `v1 = v2 | x` is illegal.) This condition will be checked with
* a runtime assertion when compiled in debug mode.
*
* @see op_or_view
*/
class rhs_proxy {
friend class op_or_view;
const op_or_view* m_view;
Type m_value;
// Constructor is invoked only from op_or_view::operator|().
//
rhs_proxy(const op_or_view* view, const Type& value) : m_view(view), m_value(value) {}
rhs_proxy& operator=(const rhs_proxy&); // Disable assignment operator
rhs_proxy(); // Disable default constructor
public:
/** bitwise OR with an additional rhs value. If `v` is an op_or_view
* and `a1` is a value, then the expression `v | a1` invokes the
* view's `operator|()` to create an rhs_proxy for `(v, a1)`; then
* `v | a1 | a2` invokes the rhs_proxy's `operator|()` to create a new
* rhs_proxy for `(v, a1|a2)`. This allows the right-hand side of an
* assignment to be not just `view | value`, but
( `view | value | value ... | value`. The effect is that
*
* v = v | a1 | a2 ... | an;
*
* is evaluated as
*
* v = v | (a1 | a2 ... | an);
*/
rhs_proxy& operator|(const Type& x) { m_value |= x; return *this; }
};
/** Default/identity constructor. This constructor initializes the
* contained value to `Type()`.
*/
op_or_view() : base() {}
/** Construct with a specified initial value.
*/
explicit op_or_view(const Type& v) : base(v) {}
/** Reduces the views of two strands.
*
* This function is invoked by the @ref op_or monoid to combine the views
* of two strands when the right strand merges with the left one. It
* "ORs" the value contained in the left-strand view by the value
* contained in the right-strand view, and leaves the value in the
* right-strand view undefined.
*
* @param right A pointer to the right-strand view. (`this` points to
* the left-strand view.)
*
* @note Used only by the @ref op_or monoid to implement the monoid
* reduce operation.
*/
void reduce(op_or_view* right) { this->m_value |= right->m_value; }
/** @name Accumulator variable updates.
*
* These functions support the various syntaxes for "ORing" the
* accumulator variable contained in the view with some value.
*/
///@{
/** Perfoms an OR operation between the accumulator variable and @a x.
*/
op_or_view& operator|=(const Type& x) { this->m_value |= x; return *this; }
/** Creates an object representing `*this | x`.
*
* @see rhs_proxy
*/
rhs_proxy operator|(const Type& x) const { return rhs_proxy(this, x); }
/** Assigns the result of a `view | value` expression to the view. Note that
* this is the only assignment operator for this class.
*
* @see rhs_proxy
*/
op_or_view& operator=(const rhs_proxy& rhs) {
__CILKRTS_ASSERT(this == rhs.m_view);
this->m_value |= rhs.m_value;
return *this;
}
///@}
};
/** Monoid class for bitwise OR reductions. Instantiate the cilk::reducer
* template class with an op_or monoid to create a bitwise OR reducer
* class. For example, to compute the bitwise OR of a set of `unsigned long`
* values:
*
* cilk::reducer< cilk::op_or<unsigned long> > r;
*
* @tparam Type The reducer value type.
* @tparam Align If `false` (the default), reducers instantiated on this
* monoid will be naturally aligned (the Intel Cilk Plus library 1.0
* behavior). If `true`, reducers instantiated on this monoid
* will be cache-aligned for binary compatibility with
* reducers in Intel Cilk Plus library version 0.9.
*
* @see ReducersOr
* @see op_or_view
*
* @ingroup ReducersOr
*/
template <typename Type, bool Align = false>
struct op_or : public monoid_with_view<op_or_view<Type>, Align> {};
/** Deprecated bitwise OR reducer class.
*
* reducer_opor is the same as @ref reducer<@ref op_or>, except that
* reducer_opor is a proxy for the contained view, so that accumulator
* variable update operations can be applied directly to the reducer. For
* example, a value is "ORed" with a `reducer<%op_or>` with `*r |= a`, but a
* value can be "ORed" with a `%reducer_opor` with `r |= a`.
*
* @deprecated Users are strongly encouraged to use `reducer<monoid>`
* reducers rather than the old wrappers like reducer_opor.
* The `reducer<monoid>` reducers show the reducer/monoid/view
* architecture more clearly, are more consistent in their
* implementation, and present a simpler model for new
* user-implemented reducers.
*
* @note Implicit conversions are provided between `%reducer_opor`
* and `reducer<%op_or>`. This allows incremental code
* conversion: old code that used `%reducer_opor` can pass a
* `%reducer_opor` to a converted function that now expects a
* pointer or reference to a `reducer<%op_or>`, and vice
* versa.
*
* @tparam Type The value type of the reducer.
*
* @see op_or
* @see reducer
* @see ReducersOr
*
* @ingroup ReducersOr
*/
template <typename Type>
class reducer_opor : public reducer< op_or<Type, true> >
{
typedef reducer< op_or<Type, true> > base;
using base::view;
public:
/// The view type for the reducer.
typedef typename base::view_type view_type;
/// The view's rhs proxy type.
typedef typename view_type::rhs_proxy rhs_proxy;
/// The view type for the reducer.
typedef view_type View;
/// The monoid type for the reducer.
typedef typename base::monoid_type Monoid;
/** @name Constructors
*/
///@{
/** Default (identity) constructor.
*
* Constructs the wrapper with the default initial value of `Type()`.
*/
reducer_opor() {}
/** Value constructor.
*
* Constructs the wrapper with a specified initial value.
*/
explicit reducer_opor(const Type& initial_value) : base(initial_value) {}
///@}
/** @name Forwarded functions
* @details Functions that update the contained accumulator variable are
* simply forwarded to the contained @ref op_and_view. */
///@{
/// @copydoc op_or_view::operator|=(const Type&)
reducer_opor& operator|=(const Type& x)
{
view() |= x; return *this;
}
// The legacy definition of reducer_opor::operator|() has different
// behavior and a different return type than this definition. The legacy
// version is defined as a member function, so this new version is defined
// as a free function to give it a different signature, so that they won't
// end up sharing a single object file entry.
/// @copydoc op_or_view::operator|(const Type&) const
friend rhs_proxy operator|(const reducer_opor& r, const Type& x)
{
return r.view() | x;
}
/// @copydoc op_and_view::operator=(const rhs_proxy&)
reducer_opor& operator=(const rhs_proxy& temp)
{
view() = temp; return *this;
}
///@}
/** @name Dereference
* @details Dereferencing a wrapper is a no-op. It simply returns the
* wrapper. Combined with the rule that the wrapper forwards view
* operations to its contained view, this means that view operations can
* be written the same way on reducers and wrappers, which is convenient
* for incrementally converting old code using wrappers to use reducers
* instead. That is:
*
* reducer< op_and<int> > r;
* *r &= a; // *r returns the view
* // operator &= is a view member function
*
* reducer_opand<int> w;
* *w &= a; // *w returns the wrapper
* // operator &= is a wrapper member function that
* // calls the corresponding view function
*/
///@{
reducer_opor& operator*() { return *this; }
reducer_opor const& operator*() const { return *this; }
reducer_opor* operator->() { return this; }
reducer_opor const* operator->() const { return this; }
///@}
/** @name Upcast
* @details In Intel Cilk Plus library 0.9, reducers were always cache-aligned.
* In library 1.0, reducer cache alignment is optional. By default,
* reducers are unaligned (i.e., just naturally aligned), but legacy
* wrappers inherit from cache-aligned reducers for binary compatibility.
*
* This means that a wrapper will automatically be upcast to its aligned
* reducer base class. The following conversion operators provide
* pseudo-upcasts to the corresponding unaligned reducer class.
*/
///@{
operator reducer< op_or<Type, false> >& ()
{
return *reinterpret_cast< reducer< op_or<Type, false> >* >(this);
}
operator const reducer< op_or<Type, false> >& () const
{
return *reinterpret_cast< const reducer< op_or<Type, false> >* >(this);
}
///@}
};
/// @cond internal
/** Metafunction specialization for reducer conversion.
*
* This specialization of the @ref legacy_reducer_downcast template class
* defined in reducer.h causes the `reducer< op_or<Type> >` class to have an
* `operator reducer_opor<Type>& ()` conversion operator that statically
* downcasts the `reducer<op_or>` to the corresponding `reducer_opor` type.
* (The reverse conversion, from `reducer_opor` to `reducer<op_or>`, is just
* an upcast, which is provided for free by the language.)
*
* @ingroup ReducersOr
*/
template <typename Type, bool Align>
struct legacy_reducer_downcast<reducer<op_or<Type, Align> > >
{
typedef reducer_opor<Type> type;
};
/// @endcond
} // namespace cilk
#endif /* __cplusplus */
/** @ingroup ReducersOr
*/
///@{
/** @name C language reducer macros
*
* These macros are used to declare and work with op_or reducers in C code.
*
* @see @ref page_reducers_in_c
*/
///@{
__CILKRTS_BEGIN_EXTERN_C
/** Declares OPOR reducer type name.
*
* This macro expands into the identifier which is the name of the op_or
* reducer type for a specified numeric type.
*
* @param tn The @ref reducers_c_type_names "numeric type name" specifying
* the type of the reducer.
*
* @see @ref reducers_c_predefined
* @see ReducersOr
*/
#define CILK_C_REDUCER_OPOR_TYPE(tn) \
__CILKRTS_MKIDENT(cilk_c_reducer_opor_,tn)
/** Declares an op_or reducer object.
*
* This macro expands into a declaration of an op_or reducer object for a
* specified numeric type. For example:
*
* CILK_C_REDUCER_OPOR(my_reducer, ulong, 0);
*
* @param obj The variable name to be used for the declared reducer object.
* @param tn The @ref reducers_c_type_names "numeric type name" specifying
* the type of the reducer.
* @param v The initial value for the reducer. (A value which can be
* assigned to the numeric type represented by @a tn.)
*
* @see @ref reducers_c_predefined
* @see ReducersOr
*/
#define CILK_C_REDUCER_OPOR(obj,tn,v) \
CILK_C_REDUCER_OPOR_TYPE(tn) obj = \
CILK_C_INIT_REDUCER(_Typeof(obj.value), \
__CILKRTS_MKIDENT(cilk_c_reducer_opor_reduce_,tn), \
__CILKRTS_MKIDENT(cilk_c_reducer_opor_identity_,tn), \
__cilkrts_hyperobject_noop_destroy, v)
/// @cond internal
/** Declares the op_or reducer functions for a numeric type.
*
* This macro expands into external function declarations for functions which
* implement the reducer functionality for the op_or reducer type for a
* specified numeric type.
*
* @param t The value type of the reducer.
* @param tn The value "type name" identifier, used to construct the reducer
* type name, function names, etc.
*/
#define CILK_C_REDUCER_OPOR_DECLARATION(t,tn) \
typedef CILK_C_DECLARE_REDUCER(t) CILK_C_REDUCER_OPOR_TYPE(tn); \
__CILKRTS_DECLARE_REDUCER_REDUCE(cilk_c_reducer_opor,tn,l,r); \
__CILKRTS_DECLARE_REDUCER_IDENTITY(cilk_c_reducer_opor,tn);
/** Defines the op_or reducer functions for a numeric type.
*
* This macro expands into function definitions for functions which implement
* the reducer functionality for the op_or reducer type for a specified
* numeric type.
*
* @param t The value type of the reducer.
* @param tn The value "type name" identifier, used to construct the reducer
* type name, function names, etc.
*/
#define CILK_C_REDUCER_OPOR_DEFINITION(t,tn) \
typedef CILK_C_DECLARE_REDUCER(t) CILK_C_REDUCER_OPOR_TYPE(tn); \
__CILKRTS_DECLARE_REDUCER_REDUCE(cilk_c_reducer_opor,tn,l,r) \
{ *(t*)l |= *(t*)r; } \
__CILKRTS_DECLARE_REDUCER_IDENTITY(cilk_c_reducer_opor,tn) \
{ *(t*)v = 0; }
///@{
/** @def CILK_C_REDUCER_OPOR_INSTANCE
* @brief Declares or defines implementation functions for a reducer type.
*
* In the runtime source file c_reducers.c, the macro `CILK_C_DEFINE_REDUCERS`
* will be defined, and this macro will generate reducer implementation
* functions. Everywhere else, `CILK_C_DEFINE_REDUCERS` will be undefined, and
* this macro will expand into external declarations for the functions.
*/
#ifdef CILK_C_DEFINE_REDUCERS
# define CILK_C_REDUCER_OPOR_INSTANCE(t,tn) \
CILK_C_REDUCER_OPOR_DEFINITION(t,tn)
#else
# define CILK_C_REDUCER_OPOR_INSTANCE(t,tn) \
CILK_C_REDUCER_OPOR_DECLARATION(t,tn)
#endif
///@}
/* Declare or define an instance of the reducer type and its functions for each
* numeric type.
*/
CILK_C_REDUCER_OPOR_INSTANCE(char, char)
CILK_C_REDUCER_OPOR_INSTANCE(unsigned char, uchar)
CILK_C_REDUCER_OPOR_INSTANCE(signed char, schar)
CILK_C_REDUCER_OPOR_INSTANCE(wchar_t, wchar_t)
CILK_C_REDUCER_OPOR_INSTANCE(short, short)
CILK_C_REDUCER_OPOR_INSTANCE(unsigned short, ushort)
CILK_C_REDUCER_OPOR_INSTANCE(int, int)
CILK_C_REDUCER_OPOR_INSTANCE(unsigned int, uint)
CILK_C_REDUCER_OPOR_INSTANCE(unsigned int, unsigned) /* alternate name */
CILK_C_REDUCER_OPOR_INSTANCE(long, long)
CILK_C_REDUCER_OPOR_INSTANCE(unsigned long, ulong)
CILK_C_REDUCER_OPOR_INSTANCE(long long, longlong)
CILK_C_REDUCER_OPOR_INSTANCE(unsigned long long, ulonglong)
//@endcond
__CILKRTS_END_EXTERN_C
///@}
///@}
#endif /* REDUCER_OPOR_H_INCLUDED */
@@ -0,0 +1,608 @@
/* reducer_opxor.h -*- C++ -*-
*
* Copyright (C) 2009-2016, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* *********************************************************************
*
* PLEASE NOTE: This file is a downstream copy of a file mainitained in
* a repository at cilkplus.org. Changes made to this file that are not
* submitted through the contribution process detailed at
* http://www.cilkplus.org/submit-cilk-contribution will be lost the next
* time that a new version is released. Changes only submitted to the
* GNU compiler collection or posted to the git repository at
* https://bitbucket.org/intelcilkruntime/intel-cilk-runtime.git are
* not tracked.
*
* We welcome your contributions to this open source project. Thank you
* for your assistance in helping us improve Cilk Plus.
*/
/** @file reducer_opxor.h
*
* @brief Defines classes for doing parallel bitwise or reductions.
*
* @ingroup ReducersXor
*
* @see ReducersXor
*/
#ifndef REDUCER_OPXOR_H_INCLUDED
#define REDUCER_OPXOR_H_INCLUDED
#include <cilk/reducer.h>
/** @defgroup ReducersXor Bitwise XOR Reducers
*
* Bitwise XOR reducers allow the computation of the bitwise XOR of a set of
* values in parallel.
*
* @ingroup Reducers
*
* You should be familiar with @ref pagereducers "Intel(R) Cilk(TM) Plus reducers",
* described in file `reducers.md`, and particularly with @ref reducers_using,
* before trying to use the information in this file.
*
* @section redopxor_usage Usage Example
*
* cilk::reducer< cilk::op_xor<unsigned> > r;
* cilk_for (int i = 0; i != N; ++i) {
* *r ^= a[i];
* }
* unsigned result;
* r.move_out(result);
*
* @section redopxor_monoid The Monoid
*
* @subsection redopxor_monoid_values Value Set
*
* The value set of a bitwise XOR reducer is the set of values of `Type`, which
* is expected to be a builtin integer type which has a representation as a
* sequence of bits (or something like it, such as `bool` or `std::bitset`).
*
* @subsection redopxor_monoid_operator Operator
*
* The bitwise XOR operator is defined by the "`^`" binary operator on `Type`.
*
* @subsection redopxor_monoid_identity Identity
*
* The identity value of the reducer is the value whose representation
* contains all 0-bits. This is expected to be the value of the default
* constructor `Type()`.
*
* @section redopxor_operations Operations
*
* @subsection redopxor_constructors Constructors
*
* reducer() // identity
* reducer(const Type& value)
* reducer(move_in(Type& variable))
*
* @subsection redopxor_get_set Set and Get
*
* r.set_value(const Type& value)
* const Type& = r.get_value() const
* r.move_in(Type& variable)
* r.move_out(Type& variable)
*
* @subsection redopxor_initial Initial Values
*
* If a bitwise XOR reducer is constructed without an explicit initial value,
* then its initial value will be its identity value, as long as `Type`
* satisfies the requirements of @ref redopxor_types.
*
* @subsection redopxor_view_ops View Operations
*
* *r ^= a
* *r = *r ^ a
* *r = *r ^ a1 ^ a2 … ^ an
*
* @section redopxor_types Type and Operator Requirements
*
* `Type` must be `Copy Constructible`, `Default Constructible`, and
* `Assignable`.
*
* The operator "`^=`" must be defined on `Type`, with `x ^= a` having the
* same meaning as `x = x ^ a`.
*
* The expression `Type()` must be a valid expression which yields the
* identity value (the value of `Type` whose representation consists of all
* 0-bits).
*
* @section redopxor_in_c Bitwise XOR Reducers in C
*
* The @ref CILK_C_REDUCER_OPXOR and @ref CILK_C_REDUCER_OPXOR_TYPE macros can
* be used to do bitwise XOR reductions in C. For example:
*
* CILK_C_REDUCER_OPXOR(r, uint, 0);
* CILK_C_REGISTER_REDUCER(r);
* cilk_for(int i = 0; i != n; ++i) {
* REDUCER_VIEW(r) ^= a[i];
* }
* CILK_C_UNREGISTER_REDUCER(r);
* printf("The bitwise XOR of the elements of a is %x\n", REDUCER_VIEW(r));
*
* See @ref reducers_c_predefined.
*/
#ifdef __cplusplus
namespace cilk {
/** The bitwise XOR reducer view class.
*
* This is the view class for reducers created with
* `cilk::reducer< cilk::op_xor<Type> >`. It holds the accumulator variable
* for the reduction, and allows only `xor` operations to be performed on it.
*
* @note The reducer "dereference" operation (`reducer::operator *()`)
* yields a reference to the view. Thus, for example, the view class's
* `^=` operation would be used in an expression like `*r ^= a`, where
* `r` is an opmod reducer variable.
*
* @tparam Type The type of the contained accumulator variable. This will
* be the value type of a monoid_with_view that is
* instantiated with this view.
*
* @see ReducersXor
* @see op_xor
*
* @ingroup ReducersXor
*/
template <typename Type>
class op_xor_view : public scalar_view<Type>
{
typedef scalar_view<Type> base;
public:
/** Class to represent the right-hand side of `*reducer = *reducer ^ value`.
*
* The only assignment operator for the op_xor_view class takes an
* rhs_proxy as its operand. This results in the syntactic restriction
* that the only expressions that can be assigned to an op_xor_view are
* ones which generate an rhs_proxy - that is, expressions of the form
* `op_xor_view ^ value ... ^ value`.
*
* @warning
* The lhs and rhs views in such an assignment must be the same;
* otherwise, the behavior will be undefined. (I.e., `v1 = v1 ^ x` is
* legal; `v1 = v2 ^ x` is illegal.) This condition will be checked with
* a runtime assertion when compiled in debug mode.
*
* @see op_xor_view
*/
class rhs_proxy {
friend class op_xor_view;
const op_xor_view* m_view;
Type m_value;
// Constructor is invoked only from op_xor_view::operator^().
//
rhs_proxy(const op_xor_view* view, const Type& value) : m_view(view), m_value(value) {}
rhs_proxy& operator=(const rhs_proxy&); // Disable assignment operator
rhs_proxy(); // Disable default constructor
public:
/** bitwise XOR with an additional rhs value. If `v` is an op_xor_view
* and `a1` is a value, then the expression `v ^ a1` invokes the
* view's `operator^()` to create an rhs_proxy for `(v, a1)`; then
* `v ^ a1 ^ a2` invokes the rhs_proxy's `operator^()` to create a new
* rhs_proxy for `(v, a1^a2)`. This allows the right-hand side of an
* assignment to be not just `view ^ value`, but
( `view ^ value ^ value ... ^ value`. The effect is that
*
* v = v ^ a1 ^ a2 ... ^ an;
*
* is evaluated as
*
* v = v ^ (a1 ^ a2 ... ^ an);
*/
rhs_proxy& operator^(const Type& x) { m_value ^= x; return *this; }
};
/** Default/identity constructor. This constructor initializes the
* contained value to `Type()`.
*/
op_xor_view() : base() {}
/** Construct with a specified initial value.
*/
explicit op_xor_view(const Type& v) : base(v) {}
/** Reduces the views of two strands.
*
* This function is invoked by the @ref op_xor monoid to combine the views
* of two strands when the right strand merges with the left one. It
* "XORs" the value contained in the left-strand view by the value
* contained in the right-strand view, and leaves the value in the
* right-strand view undefined.
*
* @param right A pointer to the right-strand view. (`this` points to
* the left-strand view.)
*
* @note Used only by the @ref op_xor monoid to implement the monoid
* reduce operation.
*/
void reduce(op_xor_view* right) { this->m_value ^= right->m_value; }
/** @name Accumulator variable updates.
*
* These functions support the various syntaxes for "XORing" the
* accumulator variable contained in the view with some value.
*/
///@{
/** Performs XOR operation between the accumulator variable and @a x.
*/
op_xor_view& operator^=(const Type& x) { this->m_value ^= x; return *this; }
/** Creates an object representing `*this ^ x`.
*
* @see rhs_proxy
*/
rhs_proxy operator^(const Type& x) const { return rhs_proxy(this, x); }
/** Assigns the result of a `view ^ value` expression to the view. Note that
* this is the only assignment operator for this class.
*
* @see rhs_proxy
*/
op_xor_view& operator=(const rhs_proxy& rhs) {
__CILKRTS_ASSERT(this == rhs.m_view);
this->m_value ^= rhs.m_value;
return *this;
}
///@}
};
/** Monoid class for bitwise XOR reductions. Instantiate the cilk::reducer
* template class with an op_xor monoid to create a bitwise XOR reducer
* class. For example, to compute the bitwise XOR of a set of `unsigned long`
* values:
*
* cilk::reducer< cilk::op_xor<unsigned long> > r;
*
* @tparam Type The reducer value type.
* @tparam Align If `false` (the default), reducers instantiated on this
* monoid will be naturally aligned (the Intel Cilk Plus library 1.0
* behavior). If `true`, reducers instantiated on this monoid
* will be cache-aligned for binary compatibility with
* reducers in Intel Cilk Plus library version 0.9.
*
* @see ReducersXor
* @see op_xor_view
*
* @ingroup ReducersXor
*/
template <typename Type, bool Align = false>
struct op_xor : public monoid_with_view<op_xor_view<Type>, Align> {};
/** Deprecated bitwise XOR reducer class.
*
* reducer_opxor is the same as @ref reducer<@ref op_xor>, except that
* reducer_opxor is a proxy for the contained view, so that accumulator
* variable update operations can be applied directly to the reducer. For
* example, a value is "XORed" with a `reducer<%op_xor>` with `*r ^= a`, but a
* value can be "XORed" with a `%reducer_opxor` with `r ^= a`.
*
* @deprecated Users are strongly encouraged to use `reducer<monoid>`
* reducers rather than the old wrappers like reducer_opand.
* The `reducer<monoid>` reducers show the reducer/monoid/view
* architecture more clearly, are more consistent in their
* implementation, and present a simpler model for new
* user-implemented reducers.
*
* @note Implicit conversions are provided between `%reducer_opxor`
* and `reducer<%op_xor>`. This allows incremental code
* conversion: old code that used `%reducer_opxor` can pass a
* `%reducer_opxor` to a converted function that now expects a
* pointer or reference to a `reducer<%op_xor>`, and vice
* versa.
*
* @tparam Type The value type of the reducer.
*
* @see op_xor
* @see reducer
* @see ReducersXor
*
* @ingroup ReducersXor
*/
template <typename Type>
class reducer_opxor : public reducer< op_xor<Type, true> >
{
typedef reducer< op_xor<Type, true> > base;
using base::view;
public:
/// The view type for the reducer.
typedef typename base::view_type view_type;
/// The view's rhs proxy type.
typedef typename view_type::rhs_proxy rhs_proxy;
/// The view type for the reducer.
typedef view_type View;
/// The monoid type for the reducer.
typedef typename base::monoid_type Monoid;
/** @name Constructors
*/
///@{
/** Default (identity) constructor.
*
* Constructs the wrapper with the default initial value of `Type()`.
*/
reducer_opxor() {}
/** Value constructor.
*
* Constructs the wrapper with a specified initial value.
*/
explicit reducer_opxor(const Type& initial_value) : base(initial_value) {}
///@}
/** @name Forwarded functions
* @details Functions that update the contained accumulator variable are
* simply forwarded to the contained @ref op_and_view. */
///@{
/// @copydoc op_xor_view::operator^=(const Type&)
reducer_opxor& operator^=(const Type& x)
{
view() ^= x; return *this;
}
// The legacy definition of reducer_opxor::operator^() has different
// behavior and a different return type than this definition. The legacy
// version is defined as a member function, so this new version is defined
// as a free function to give it a different signature, so that they won't
// end up sharing a single object file entry.
/// @copydoc op_xor_view::operator^(const Type&) const
friend rhs_proxy operator^(const reducer_opxor& r, const Type& x)
{
return r.view() ^ x;
}
/// @copydoc op_and_view::operator=(const rhs_proxy&)
reducer_opxor& operator=(const rhs_proxy& temp)
{
view() = temp; return *this;
}
///@}
/** @name Dereference
* @details Dereferencing a wrapper is a no-op. It simply returns the
* wrapper. Combined with the rule that the wrapper forwards view
* operations to its contained view, this means that view operations can
* be written the same way on reducers and wrappers, which is convenient
* for incrementally converting old code using wrappers to use reducers
* instead. That is:
*
* reducer< op_and<int> > r;
* *r &= a; // *r returns the view
* // operator &= is a view member function
*
* reducer_opand<int> w;
* *w &= a; // *w returns the wrapper
* // operator &= is a wrapper member function that
* // calls the corresponding view function
*/
///@{
reducer_opxor& operator*() { return *this; }
reducer_opxor const& operator*() const { return *this; }
reducer_opxor* operator->() { return this; }
reducer_opxor const* operator->() const { return this; }
///@}
/** @name Upcast
* @details In Intel Cilk Plus library 0.9, reducers were always cache-aligned.
* In library 1.0, reducer cache alignment is optional. By default,
* reducers are unaligned (i.e., just naturally aligned), but legacy
* wrappers inherit from cache-aligned reducers for binary compatibility.
*
* This means that a wrapper will automatically be upcast to its aligned
* reducer base class. The following conversion operators provide
* pseudo-upcasts to the corresponding unaligned reducer class.
*/
///@{
operator reducer< op_xor<Type, false> >& ()
{
return *reinterpret_cast< reducer< op_xor<Type, false> >* >(this);
}
operator const reducer< op_xor<Type, false> >& () const
{
return *reinterpret_cast< const reducer< op_xor<Type, false> >* >(this);
}
///@}
};
/// @cond internal
/** Metafunction specialization for reducer conversion.
*
* This specialization of the @ref legacy_reducer_downcast template class
* defined in reducer.h causes the `reducer< op_xor<Type> >` class to have an
* `operator reducer_opxor<Type>& ()` conversion operator that statically
* downcasts the `reducer<op_xor>` to the corresponding `reducer_opxor` type.
* (The reverse conversion, from `reducer_opxor` to `reducer<op_xor>`, is just
* an upcast, which is provided for free by the language.)
*
* @ingroup ReducersXor
*/
template <typename Type, bool Align>
struct legacy_reducer_downcast<reducer<op_xor<Type, Align> > >
{
typedef reducer_opxor<Type> type;
};
/// @endcond
} // namespace cilk
#endif /* __cplusplus */
/** @ingroup ReducersXor
*/
///@{
/** @name C language reducer macros
*
* These macros are used to declare and work with op_xor reducers in C code.
*
* @see @ref page_reducers_in_c
*/
///@{
__CILKRTS_BEGIN_EXTERN_C
/** Declares OPXOR reducer type name.
*
* This macro expands into the identifier which is the name of the op_xor
* reducer type for a specified numeric type.
*
* @param tn The @ref reducers_c_type_names "numeric type name" specifying
* the type of the reducer.
*
* @see @ref reducers_c_predefined
* @see ReducersXor
*/
#define CILK_C_REDUCER_OPXOR_TYPE(tn) \
__CILKRTS_MKIDENT(cilk_c_reducer_opxor_,tn)
/** Declares an op_xor reducer object.
*
* This macro expands into a declaration of an op_xor reducer object for a
* specified numeric type. For example:
*
* CILK_C_REDUCER_OPXOR(my_reducer, ulong, 0);
*
* @param obj The variable name to be used for the declared reducer object.
* @param tn The @ref reducers_c_type_names "numeric type name" specifying
* the type of the reducer.
* @param v The initial value for the reducer. (A value which can be
* assigned to the numeric type represented by @a tn.)
*
* @see @ref reducers_c_predefined
* @see ReducersXor
*/
#define CILK_C_REDUCER_OPXOR(obj,tn,v) \
CILK_C_REDUCER_OPXOR_TYPE(tn) obj = \
CILK_C_INIT_REDUCER(_Typeof(obj.value), \
__CILKRTS_MKIDENT(cilk_c_reducer_opxor_reduce_,tn), \
__CILKRTS_MKIDENT(cilk_c_reducer_opxor_identity_,tn), \
__cilkrts_hyperobject_noop_destroy, v)
/// @cond internal
/** Declares the op_xor reducer functions for a numeric type.
*
* This macro expands into external function declarations for functions which
* implement the reducer functionality for the op_xor reducer type for a
* specified numeric type.
*
* @param t The value type of the reducer.
* @param tn The value "type name" identifier, used to construct the reducer
* type name, function names, etc.
*/
#define CILK_C_REDUCER_OPXOR_DECLARATION(t,tn) \
typedef CILK_C_DECLARE_REDUCER(t) CILK_C_REDUCER_OPXOR_TYPE(tn); \
__CILKRTS_DECLARE_REDUCER_REDUCE(cilk_c_reducer_opxor,tn,l,r); \
__CILKRTS_DECLARE_REDUCER_IDENTITY(cilk_c_reducer_opxor,tn);
/** Defines the op_xor reducer functions for a numeric type.
*
* This macro expands into function definitions for functions which implement
* the reducer functionality for the op_xor reducer type for a specified
* numeric type.
*
* @param t The value type of the reducer.
* @param tn The value "type name" identifier, used to construct the reducer
* type name, function names, etc.
*/
#define CILK_C_REDUCER_OPXOR_DEFINITION(t,tn) \
typedef CILK_C_DECLARE_REDUCER(t) CILK_C_REDUCER_OPXOR_TYPE(tn); \
__CILKRTS_DECLARE_REDUCER_REDUCE(cilk_c_reducer_opxor,tn,l,r) \
{ *(t*)l ^= *(t*)r; } \
__CILKRTS_DECLARE_REDUCER_IDENTITY(cilk_c_reducer_opxor,tn) \
{ *(t*)v = 0; }
///@{
/** @def CILK_C_REDUCER_OPXOR_INSTANCE
* @brief Declares or defines implementation functions for a reducer type.
*
* In the runtime source file c_reducers.c, the macro `CILK_C_DEFINE_REDUCERS`
* will be defined, and this macro will generate reducer implementation
* functions. Everywhere else, `CILK_C_DEFINE_REDUCERS` will be undefined, and
* this macro will expand into external declarations for the functions.
*/
#ifdef CILK_C_DEFINE_REDUCERS
# define CILK_C_REDUCER_OPXOR_INSTANCE(t,tn) \
CILK_C_REDUCER_OPXOR_DEFINITION(t,tn)
#else
# define CILK_C_REDUCER_OPXOR_INSTANCE(t,tn) \
CILK_C_REDUCER_OPXOR_DECLARATION(t,tn)
#endif
///@}
/* Declares or defines an instance of the reducer type and its functions for each
* numeric type.
*/
CILK_C_REDUCER_OPXOR_INSTANCE(char, char)
CILK_C_REDUCER_OPXOR_INSTANCE(unsigned char, uchar)
CILK_C_REDUCER_OPXOR_INSTANCE(signed char, schar)
CILK_C_REDUCER_OPXOR_INSTANCE(wchar_t, wchar_t)
CILK_C_REDUCER_OPXOR_INSTANCE(short, short)
CILK_C_REDUCER_OPXOR_INSTANCE(unsigned short, ushort)
CILK_C_REDUCER_OPXOR_INSTANCE(int, int)
CILK_C_REDUCER_OPXOR_INSTANCE(unsigned int, uint)
CILK_C_REDUCER_OPXOR_INSTANCE(unsigned int, unsigned) /* alternate name */
CILK_C_REDUCER_OPXOR_INSTANCE(long, long)
CILK_C_REDUCER_OPXOR_INSTANCE(unsigned long, ulong)
CILK_C_REDUCER_OPXOR_INSTANCE(long long, longlong)
CILK_C_REDUCER_OPXOR_INSTANCE(unsigned long long, ulonglong)
//@endcond
__CILKRTS_END_EXTERN_C
///@}
///@}
#endif /* REDUCER_OPXOR_H_INCLUDED */
@@ -0,0 +1,517 @@
/* reducer_ostream.h -*- C++ -*-
*
* Copyright (C) 2009-2016, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* *********************************************************************
*
* PLEASE NOTE: This file is a downstream copy of a file mainitained in
* a repository at cilkplus.org. Changes made to this file that are not
* submitted through the contribution process detailed at
* http://www.cilkplus.org/submit-cilk-contribution will be lost the next
* time that a new version is released. Changes only submitted to the
* GNU compiler collection or posted to the git repository at
* https://bitbucket.org/intelcilkruntime/intel-cilk-runtime.git are
* not tracked.
*
* We welcome your contributions to this open source project. Thank you
* for your assistance in helping us improve Cilk Plus.
*/
/** @file reducer_ostream.h
*
* @brief Defines a class for writing to an ostream in parallel.
*
* @ingroup ReducersOstream
*
* @see @ref ReducersOstream
*/
#ifndef REDUCER_OSTREAM_H_INCLUDED
#define REDUCER_OSTREAM_H_INCLUDED
#include <cilk/reducer.h>
#include <ostream>
#include <sstream>
/** @defgroup ReducersOstream Ostream Reducers
*
* Ostream reducers allow multiple strands to write to an ostream in parallel.
*
* @ingroup Reducers
*
* You should be familiar with @ref pagereducers "Intel(R) Cilk(TM) Plus reducers",
* described in file reducers.md, and particularly with @ref reducers_using,
* before trying to use the information in this file.
*
* @section redostream_usage Usage Example
*
* One of the most common debugging techniques is adding `print` statements
* to the code being debugged. When the code is parallelized, the results can
* be less than satisfactory, as output from multiple strands is mingled in an
* unpredictable way. Like other reducers, an ostream reducer requires minimal
* recoding to guarantee that the output from parallelized computation will be
* ordered the same as though the computation were executed serially.
*
* cilk::reducer<cilk::op_ostream> r(std::cerr);
* cilk_for (int i = 0; i != data.size(); ++i) {
* *r << "Iteration " << i << ":\n";
* ... some computation ...
* *r << " Step 1:" << some information;
* ... some more computation ...
* *r << " Step 2:" << some more information;
* ... still more computation ...
* *r << " Step 3:" << still more information;
* }
*
* Output on standard error:
*
* Iteration 1:
* Step 1: ...
* Step 2: ...
* Step 3: ...
* Iteration 2:
* Step 1: ...
* Step 2: ...
* Step 3: ...
* Iteration 3:
* Step 1: ...
* Step 2: ...
* Step 3: ...
* ...
*
* @section redostream_overview Overview
*
* An "ostream reducer" is not really a reducer. It uses the reducer
* technology to coordinate operations on parallel strands to achieve
* the same behavior in a parallel computation that would be seen in a
* serial computation, but it does not have a monoid. It has a "monoid
* class," because that is part of the implementation framework, but it
* does not represent a mathematical monoid: there is no value type, no
* associative operation, and no identity value. The reducer is used for
* its side effect rather than to construct a value.
*
* You might think of an ostream reducer as a relative of a
* @ref ReducersString "string reducer" which uses stream output
* syntax (`stream << value`) instead of string append syntax
* (`string += value`), and which writes its result string to an
* ostream instead of making it available as the reducer value.
*
* Another difference is that "real" reducers protect their contained
* value quite strongly from improper access by the user. Ostream reducers,
* on the other hand, pretty much have to expose the ostream, since normal
* use of an ostream involves accessing its internal state. Furthermore,
* the ostream reducer just coordinates output to an existing ostream -
* there is nothing to keep the user from writing directly to the attached
* stream, with unpredictable results.
*
* @section redostream_operations Operations
*
* In the operation descriptions below, the type name `Ostream` refers to the
* reducer's ostream type, `std::basic_ostream<Char, Traits>`.
*
* @subsection redostream_constructors Constructors
*
* The only constructor is
*
* reducer(const Ostream& os)
*
* This creates a reducer that is associated with the existing ostream `os`.
* Anything "written to" the reducer will (eventually) be written to `os`.
*
* @subsection redostream_get_set Set and Get
*
* Just as a stream does not have a "value," neither does an ostream
* reducer. Therefore, none of the usual `set_value`, `get_value`,
* `move_in`, or `move_out` functions are available for ostream reducers.
*
* @subsection redostream_initial Initial Values
*
* Ostream reducers do not have default constructors.
*
* @subsection redostream_view_ops View Operations
*
* An ostream reducer view is actually a kind of `std::ostream`. Therefore,
* any operation that can be used on an ostream can be used on an ostream
* reducer view. For example:
*
* reducer<op_ostream> r(cout);
* *r << setw(5) << (x=1) << endl;
*
*
* @section redostream_performance Performance Considerations
*
* Ostream reducers work by creating a string stream for each non-leftmost
* view. When two strands are merged, the contents of the string buffer of the
* right view are written to the left view. Since all non-leftmost strands are
* eventually merged, all output is eventually written to the associated
* ostream.
*
* This implementation has two consequences.
*
* First, all output written to an ostream reducer on a stolen strand is kept
* in memory (in a string buffer) until the strand is merged with the leftmost
* strand. This means that some portion of the output written to an ostream
* reducer during a parallel computation - half of the total output, on
* average - will temporarily be held in memory during the computation.
* Obviously, ostream reducers will work better for small and moderate amounts
* of output.
*
* Second, buffered ostream reducer content must be copied at every merge.
* The total amount of copying is potentially proportional to the total amount
* of output multiplied by the number of strands stolen during the computation.
*
* In short, writing to an ostream in a parallel computation with an ostream
* reducer will always be less efficient than writing the same output directly
* to the ostream in a serial computation. The value of the ostream
* reducer is not in the writing of the ostream itself, but in removing the
* race and serialization obstacles that the ostream output would cause in an
* otherwise parallelizable computation.
*
*
* @section redostream_state Stream State
*
* The reducer implementation can correctly order the output that is written
* to an ostream. However, an ostream has additional state that controls its
* behavior, such as its formatting attributes, error state, extensible arrays, * and registered callbacks. If these are modified during the computation, the * reducer implementation cannot guarantee that they will be the same in a
* parallel computation as in a serial computation. In particular:
*
* - In the serial execution, the ostream state in the continuation of a
* spawn will be the same as the state at the end of the spawned function.
* In the parallel execution, if the continuation is stolen, its view will
* contain a newly created ostream with the default initial state.
* - In the serial execution, the ostream state following a sync is the same
* as the state before the sync. In the parallel execution, if the
* continuation is stolen, then the state following the sync will be the
* same as the state at the end of some spawned function.
*
* In short, you must not make any assumptions about the stream state of an
* ostream reducer:
*
* - Following a `cilk_spawn`.
* - Following a `cilk_sync`.
* - At the start of an iteration of a `cilk_for` loop.
* - Following the completion of a `cilk_for` loop.
*
* @section redostream_types Type and Operator Requirements
*
* `std::basic_ostream<Char, Traits>` must be a valid type.
*/
namespace cilk {
/** @ingroup ReducersOstream */
//@{
/** The ostream reducer view class.
*
* This is the view class for reducers created with
* `cilk::reducer< cilk::op_basic_ostream<Char, Traits> >`. It holds the
* actual ostream for a parallel strand, and allows only stream output
* operations to be performed on it.
*
* @note The reducer "dereference" operation (`reducer::operator *()`)
* yields a reference to the view. Thus, for example, the view
* class's `<<` operation would be used in an expression like
* `*r << "x = " << x`, where `r` is an ostream reducer.
*
* @tparam Char The ostream element type (not the ostream type).
* @tparam Traits The character traits type.
*
* @see ReducersOstream
* @see op_basic_ostream
*/
template<typename Char, typename Traits>
class op_basic_ostream_view : public std::basic_ostream<Char, Traits>
{
typedef std::basic_ostream<Char, Traits> base;
typedef std::basic_ostream<Char, Traits> ostream_type;
// A non-leftmost view is associated with a private string buffer. (The
// leftmost view is associated with the buffer of the reducer's associated
// ostream, so its private buffer is unused.)
//
std::basic_stringbuf<Char, Traits> m_buffer;
public:
/** Value type. Required by @ref monoid_with_view.
*/
typedef ostream_type value_type;
/** Reduce operation. Required by @ref monoid_with_view.
*/
void reduce(op_basic_ostream_view* other)
{
// Writing an empty buffer results in failure. Testing `sgetc()` is the
// easiest way of checking for an empty buffer.
if (other->m_buffer.sgetc() != Traits::eof()) {
*this << (&other->m_buffer);
}
}
/** Non-leftmost (identity) view constructor. The view is associated with
* its internal buffer. Required by @ref monoid_base.
*/
op_basic_ostream_view() : base(&m_buffer) {}
/** Leftmost view constructor. The view is associated with an existing
* ostream.
*/
op_basic_ostream_view(const ostream_type& os) : base(0)
{
base::rdbuf(os.rdbuf()); // Copy stream buffer
base::flags(os.flags()); // Copy formatting flags
base::setstate(os.rdstate()); // Copy error state
}
/** Sets/gets.
*
* These are all no-ops.
*/
//@{
void view_set_value(const value_type&)
{ assert("set_value() is not allowed on ostream reducers" && 0); }
const value_type& view_get_value() const
{ assert("get_value() is not allowed on ostream reducers" && 0);
return *this; }
typedef value_type const& return_type_for_get_value;
void view_move_in(const value_type&)
{ assert("move_in() is not allowed on ostream reducers" && 0); }
void view_move_out(const value_type&)
{ assert("move_out() is not allowed on ostream reducers" && 0); }
//@}
};
/** Ostream monoid class. Instantiate the cilk::reducer template class with an
* op_basic_ostream monoid to create an ostream reducer class:
*
* cilk::reducer< cilk::op_basic_string<char> > r;
*
* @tparam Char The stream element type (not the stream type).
* @tparam Traits The character traits type.
*
* @see ReducersOstream
* @see op_basic_ostream_view
* @see reducer_ostream
* @see op_ostream
* @see op_wostream
*/
template<typename Char,
typename Traits = std::char_traits<Char>,
bool Align = false>
class op_basic_ostream :
public monoid_with_view< op_basic_ostream_view<Char, Traits>, Align >
{
typedef monoid_with_view< op_basic_ostream_view<Char, Traits>, Align >
base;
typedef std::basic_ostream<Char, Traits> ostream_type;
typedef provisional_guard<typename base::view_type> view_guard;
public:
/** View type of the monoid.
*/
typedef typename base::view_type view_type;
/** @name Construct function.
*
* The only supported ostream reducer constructor takes a reference to
* an existing ostream.
*
* @param os The ostream destination for receive all data written to the
* reducer.
*/
static void construct(
op_basic_ostream* monoid,
view_type* view,
const ostream_type& os)
{
view_guard vg( new((void*) view) view_type(os) );
vg.confirm_if( new((void*) monoid) op_basic_ostream );
}
};
/**
* Convenience typedef for narrow ostreams.
*/
typedef op_basic_ostream<char> op_ostream;
/**
* Convenience typedef for wide ostreams.
*/
typedef op_basic_ostream<wchar_t> op_wostream;
/// @cond internal
class reducer_ostream;
/** Metafunction specialization for reducer conversion.
*
* This specialization of the @ref legacy_reducer_downcast template class
* defined in reducer.h causes the `reducer<op_basic_ostream<char> >` class
* to have an `operator reducer_ostream& ()` conversion operator that
* statically downcasts the `reducer<op_basic_ostream<char> >` to
* `reducer_ostream`. (The reverse conversion, from `reducer_ostream` to
* `reducer<op_basic_ostream<char> >`, is just an upcast, which is provided
* for free by the language.)
*/
template<bool Align>
struct legacy_reducer_downcast<
reducer<op_basic_ostream<char, std::char_traits<char>, Align> > >
{
typedef reducer_ostream type;
};
/// @endcond
/** Deprecated ostream reducer class.
*
* reducer_ostream is the same as @ref cilk::reducer<@ref op_ostream>, except
* that reducer_ostream is a proxy for the contained view, so that ostream
* operations can be applied directly to the reducer. For example, a number is
* written to a `reducer<op_ostream>` with `*r << x`, but a number can be
* written to a `reducer_ostream` with `r << x`.
*
* @deprecated Users are strongly encouraged to use `reducer<monoid>`
* reducers rather than the old wrappers like reducer_ostream. The
* `reducer<monoid>` reducers show the reducer/monoid/view
* architecture more clearly, are more consistent in their
* implementation, and present a simpler model for new
* user-implemented reducers.
*
* @note Implicit conversions are provided between `%reducer_ostream`
* and `reducer<%op_ostream>`. This allows incremental code
* conversion: old code that used `%reducer_ostream` can pass a
* `%reducer_ostream` to a converted function that now expects a
* pointer or reference to a `reducer<%op_ostream>`, and vice versa.
*
* @tparam Char The stream element type (not the stream type).
* @tparam Traits The character traits type.
*
* @see op_ostream
* @see reducer
* @see ReducersOstream
*/
class reducer_ostream :
public reducer<op_basic_ostream<char, std::char_traits<char>, true> >
{
typedef reducer<op_basic_ostream<char, std::char_traits<char>, true> > base;
using base::view;
public:
/// The view type for the reducer.
typedef base::view_type View;
/// The monoid type for the reducer.
typedef base::monoid_type Monoid;
/** Constructs an initial `reducer_ostream` from a `std::ostream`. The
* specified stream is used as the eventual destination for all text
* streamed to this hyperobject.
*/
explicit reducer_ostream(const std::ostream &os) : base(os) {}
/** Returns a modifiable reference to the underlying 'ostream' object.
*/
std::ostream& get_reference() { return view(); }
/** Writes to the ostream.
*/
template<typename T>
std::ostream& operator<< (const T &v)
{
return view() << v;
}
/**
* Calls a manipulator.
*
* @param _Pfn Pointer to the manipulator function.
*/
reducer_ostream& operator<< (std::ostream &(*_Pfn)(std::ostream &))
{
(*_Pfn)(view());
return *this;
}
/** @name Dereference
* @details Dereferencing a wrapper is a no-op. It simply returns the
* wrapper. Combined with the rule that the wrapper forwards view
* operations to its contained view, this means that view operations can
* be written the same way on reducers and wrappers, which is convenient
* for incrementally converting old code using wrappers to use reducers
* instead. That is:
*
* reducer<op_ostream> r;
* *r << "a"; // *r returns the view
* // operator<<() is a view member function
*
* reducer_ostream w;
* *w << "a"; // *w returns the wrapper
* // operator<<() is a wrapper member function
* // that calls the corresponding view function
*/
//@{
reducer_ostream& operator*() { return *this; }
reducer_ostream const& operator*() const { return *this; }
reducer_ostream* operator->() { return this; }
reducer_ostream const* operator->() const { return this; }
//@}
/** @name Upcast
* @details In Intel Cilk Plus library 0.9, reducers were always cache-aligned.
* In library 1.0, reducer cache alignment is optional. By default,
* reducers are unaligned (i.e., just naturally aligned), but legacy
* wrappers inherit from cache-aligned reducers for binary compatibility.
*
* This means that a wrapper will automatically be upcast to its aligned
* reducer base class. The following conversion operators provide
* pseudo-upcasts to the corresponding unaligned reducer class.
*/
//@{
operator reducer<op_ostream>& ()
{
return *reinterpret_cast< reducer<op_ostream>* >(this);
}
operator const reducer<op_ostream>& () const
{
return *reinterpret_cast< const reducer<op_ostream>* >(this);
}
//@}
};
} // namespace cilk
#endif // REDUCER_OSTREAM_H_INCLUDED
@@ -0,0 +1,763 @@
/* reducer_string.h -*- C++ -*-
*
* Copyright (C) 2009-2016, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* *********************************************************************
*
* PLEASE NOTE: This file is a downstream copy of a file mainitained in
* a repository at cilkplus.org. Changes made to this file that are not
* submitted through the contribution process detailed at
* http://www.cilkplus.org/submit-cilk-contribution will be lost the next
* time that a new version is released. Changes only submitted to the
* GNU compiler collection or posted to the git repository at
* https://bitbucket.org/intelcilkruntime/intel-cilk-runtime.git are
* not tracked.
*
* We welcome your contributions to this open source project. Thank you
* for your assistance in helping us improve Cilk Plus.
*/
/** @file reducer_string.h
*
* @brief Defines classes for doing parallel string creation by appending.
*
* @ingroup ReducersString
*
* @see ReducersString
*/
#ifndef REDUCER_STRING_H_INCLUDED
#define REDUCER_STRING_H_INCLUDED
#include <cilk/reducer.h>
#include <string>
#include <list>
/** @defgroup ReducersString String Reducers
*
* String reducers allow the creation of a string by concatenating a set of
* strings or characters in parallel.
*
* @ingroup Reducers
*
* You should be familiar with @ref pagereducers "Intel(R) Cilk(TM) Plus reducers",
* described in file reducers.md, and particularly with @ref reducers_using,
* before trying to use the information in this file.
*
* @section redstring_usage Usage Example
*
* vector<Data> data;
* void expensive_string_computation(const Data& x, string& s);
* cilk::reducer<cilk::op_string> r;
* cilk_for (int i = 0; i != data.size(); ++i) {
* string temp;
* expensive_string_computation(data[i], temp);
* *r += temp;
* }
* string result;
* r.move_out(result);
*
* @section redstring_monoid The Monoid
*
* @subsection redstring_monoid_values Value Set
*
* The value set of a string reducer is the set of values of the class
* `std::basic_string<Char, Traits, Alloc>`, which we refer to as "the
* reducer's string type".
*
* @subsection redstring_monoid_operator Operator
*
* The operator of a string reducer is the string concatenation operator,
* defined by the "`+`" binary operator on the reducer's string type.
*
* @subsection redstring_monoid_identity Identity
*
* The identity value of a string reducer is the empty string, which is the
* value of the expression
* `std::basic_string<Char, Traits, Alloc>([allocator])`.
*
* @section redstring_operations Operations
*
* In the operation descriptions below, the type name `String` refers to the
* reducer's string type, `std::basic_string<Char, Traits, Alloc>`.
*
* @subsection redstring_constructors Constructors
*
* Any argument list which is valid for a `std::basic_string` constructor is
* valid for a string reducer constructor. The usual move-in constructor is
* also provided:
*
* reducer(move_in(String& variable))
*
* @subsection redstring_get_set Set and Get
*
* r.set_value(const String& value)
* const String& = r.get_value() const
* r.move_in(String& variable)
* r.move_out(String& variable)
*
* @subsection redstring_initial Initial Values
*
* A string reducer with no constructor arguments, or with only an allocator
* argument, will initially contain the identity value, an empty string.
*
* @subsection redstring_view_ops View Operations
*
* *r += a
* r->append(a)
* r->append(a, b)
* r->push_back(a)
*
* These operations on string reducer views are the same as the corresponding
* operations on strings.
*
* @section redstring_performance Performance Considerations
*
* String reducers work by creating a string for each view, collecting those
* strings in a list, and then concatenating them into a single result string
* at the end of the computation. This last step takes place in serial code,
* and necessarily takes time proportional to the length of the result string.
* Thus, a parallel string reducer cannot actually speed up the time spent
* directly creating the string. This trivial example would probably be slower
* (because of reducer overhead) than the corresponding serial code:
*
* vector<string> a;
* reducer<op_string> r;
* cilk_for (int i = 0; i != a.length(); ++i) {
* *r += a[i];
* }
* string result;
* r.move_out(result);
*
* What a string reducer _can_ do is to allow the _remainder_ of the
* computation to be done in parallel, without having to worry about managing
* the string computation.
*
* The strings for new views are created (by the view identity constructor)
* using the same allocator as the string that was created when the reducer
* was constructed. Note that this allocator is determined when the reducer is
* constructed. The following two examples may have very different behavior:
*
* string<Char, Traits, Allocator> a_string;
*
* reducer< op_string<Char, Traits, Allocator> reducer1(move_in(a_string));
* ... parallel computation ...
* reducer1.move_out(a_string);
*
* reducer< op_string<Char, Traits, Allocator> reducer2;
* reducer2.move_in(a_string);
* ... parallel computation ...
* reducer2.move_out(a_string);
*
* * `reducer1` will be constructed with the same allocator as `a_string`,
* because the string was specified in the constructor. The `move_in`
* and `move_out` can therefore be done with a `swap` in constant time.
* * `reducer2` will be constructed with a _default_ allocator of type
* `Allocator`, which may not be the same as the allocator of `a_string`.
* Therefore, the `move_in` and `move_out` may have to be done with a copy
* in _O(N)_ time.
*
* (All instances of an allocator type with no internal state (like
* `std::allocator`) are "the same". You only need to worry about the "same
* allocator" issue when you create string reducers with custom allocator
* types.)
*
* @section redstring_types Type and Operator Requirements
*
* `std::basic_string<Char, Traits, Alloc>` must be a valid type.
*/
namespace cilk {
/** @ingroup ReducersString */
//@{
/** The string append reducer view class.
*
* This is the view class for reducers created with
* `cilk::reducer< cilk::op_basic_string<Char, Traits, Allocator> >`. It holds
* the accumulator variable for the reduction, and allows only append
* operations to be performed on it.
*
* @note The reducer "dereference" operation (`reducer::operator *()`)
* yields a reference to the view. Thus, for example, the view class's
* `append` operation would be used in an expression like
* `r->append(a)`, where `r` is a string append reducer variable.
*
* @tparam Char The string element type (not the string type).
* @tparam Traits The character traits type.
* @tparam Alloc The string allocator type.
*
* @see ReducersString
* @see op_basic_string
*/
template<typename Char, typename Traits, typename Alloc>
class op_basic_string_view
{
typedef std::basic_string<Char, Traits, Alloc> string_type;
typedef std::list<string_type> list_type;
typedef typename string_type::size_type size_type;
// The view's value is represented by a list of strings and a single
// string. The value is the concatenation of the strings in the list with
// the single string at the end. All string operations apply to the single
// string; reduce operations cause lists of partial strings from multiple
// strands to be combined.
//
mutable string_type m_string;
mutable list_type m_list;
// Before returning the value of the reducer, concatenate all the strings
// in the list with the single string.
//
void flatten() const
{
if (m_list.empty()) return;
typename list_type::iterator i;
size_type len = m_string.size();
for (i = m_list.begin(); i != m_list.end(); ++i)
len += i->size();
string_type result(get_allocator());
result.reserve(len);
for (i = m_list.begin(); i != m_list.end(); ++i)
result += *i;
m_list.clear();
result += m_string;
result.swap(m_string);
}
public:
/** @name Monoid support.
*/
//@{
/// Required by @ref monoid_with_view
typedef string_type value_type;
/// Required by @ref op_string
Alloc get_allocator() const
{
return m_string.get_allocator();
}
/** Reduces the views of two strands.
*
* This function is invoked by the @ref op_basic_string monoid to combine
* the views of two strands when the right strand merges with the left
* one. It appends the value contained in the right-strand view to the
* value contained in the left-strand view, and leaves the value in the
* right-strand view undefined.
*
* @param right A pointer to the right-strand view. (`this` points to
* the left-strand view.)
*
* @note Used only by the @ref op_basic_string monoid to implement the
* monoid reduce operation.
*/
void reduce(op_basic_string_view* right)
{
if (!right->m_string.empty() || !right->m_list.empty()) {
// (list, string) + (right_list, right_string) =>
// (list + {string} + right_list, right_string)
if (!m_string.empty()) {
// simulate m_list.push_back(std::move(m_string))
m_list.push_back(string_type(get_allocator()));
m_list.back().swap(m_string);
}
m_list.splice(m_list.end(), right->m_list);
m_string.swap(right->m_string);
}
}
//@}
/** @name Passes constructor arguments to the string constructor.
*/
//@{
op_basic_string_view() : m_string() {}
template <typename T1>
op_basic_string_view(const T1& x1) : m_string(x1) {}
template <typename T1, typename T2>
op_basic_string_view(const T1& x1, const T2& x2) : m_string(x1, x2) {}
template <typename T1, typename T2, typename T3>
op_basic_string_view(const T1& x1, const T2& x2, const T3& x3) : m_string(x1, x2, x3) {}
template <typename T1, typename T2, typename T3, typename T4>
op_basic_string_view(const T1& x1, const T2& x2, const T3& x3, const T4& x4) :
m_string(x1, x2, x3, x4) {}
//@}
/** Move-in constructor.
*/
explicit op_basic_string_view(move_in_wrapper<value_type> w)
: m_string(w.value().get_allocator())
{
m_string.swap(w.value());
}
/** @name @ref reducer support.
*/
//@{
void view_move_in(string_type& s)
{
m_list.clear();
if (m_string.get_allocator() == s.get_allocator())
// Equal allocators. Do a (fast) swap.
m_string.swap(s);
else
// Unequal allocators. Do a (slow) copy.
m_string = s;
s.clear();
}
void view_move_out(string_type& s)
{
flatten();
if (m_string.get_allocator() == s.get_allocator())
// Equal allocators. Do a (fast) swap.
m_string.swap(s);
else
// Unequal allocators. Do a (slow) copy.
s = m_string;
m_string.clear();
}
void view_set_value(const string_type& s)
{ m_list.clear(); m_string = s; }
string_type const& view_get_value() const
{ flatten(); return m_string; }
typedef string_type const& return_type_for_get_value;
string_type & view_get_reference()
{ flatten(); return m_string; }
string_type const& view_get_reference() const
{ flatten(); return m_string; }
//@}
/** @name View modifier operations.
*
* @details These simply wrap the corresponding operations on the underlying string.
*/
//@{
template <typename T>
op_basic_string_view& operator +=(const T& x)
{ m_string += x; return *this; }
template <typename T1>
op_basic_string_view& append(const T1& x1)
{ m_string.append(x1); return *this; }
template <typename T1, typename T2>
op_basic_string_view& append(const T1& x1, const T2& x2)
{ m_string.append(x1, x2); return *this; }
template <typename T1, typename T2, typename T3>
op_basic_string_view& append(const T1& x1, const T2& x2, const T3& x3)
{ m_string.append(x1, x2, x3); return *this; }
void push_back(const Char x) { m_string.push_back(x); }
//@}
};
/** String append monoid class. Instantiate the cilk::reducer template class
* with an op_basic_string monoid to create a string append reducer class. For
* example, to concatenate a collection of standard strings:
*
* cilk::reducer< cilk::op_basic_string<char> > r;
*
* @tparam Char The string element type (not the string type).
* @tparam Traits The character traits type.
* @tparam Alloc The string allocator type.
* @tparam Align If `false` (the default), reducers instantiated on this
* monoid will be naturally aligned (the Intel Cilk Plus library 1.0
* behavior). If `true`, reducers instantiated on this monoid
* will be cache-aligned for binary compatibility with
* reducers in Intel Cilk Plus library version 0.9.
*
* @see ReducersString
* @see op_basic_string_view
* @see reducer_basic_string
* @see op_string
* @see op_wstring
*/
template<typename Char,
typename Traits = std::char_traits<Char>,
typename Alloc = std::allocator<Char>,
bool Align = false>
class op_basic_string :
public monoid_with_view< op_basic_string_view<Char, Traits, Alloc>, Align >
{
typedef monoid_with_view< op_basic_string_view<Char, Traits, Alloc>, Align >
base;
typedef provisional_guard<typename base::view_type> view_guard;
Alloc m_allocator;
public:
/** View type of the monoid.
*/
typedef typename base::view_type view_type;
/** Constructor.
*
* There is no default constructor for string monoids, because the
* allocator must always be specified.
*
* @param allocator The list allocator to be used when
* identity-constructing new views.
*/
op_basic_string(const Alloc& allocator = Alloc()) : m_allocator(allocator)
{}
/** Creates an identity view.
*
* String view identity constructors take the string allocator as an
* argument.
*
* @param v The address of the uninitialized memory in which the view
* will be constructed.
*/
void identity(view_type *v) const
{ ::new((void*) v) view_type(m_allocator); }
/** @name Construct functions
*
* A string append reduction monoid must have a copy of the allocator of
* the leftmost view's string, so that it can use it in the `identity`
* operation. This, in turn, requires that string reduction monoids have a
* specialized `construct()` function.
*
* All string reducer monoid `construct()` functions first construct the
* leftmost view, using the arguments that were passed in from the reducer
* constructor. They then call the view's `get_allocator()` function to
* get the string allocator from the string in the leftmost view, and pass
* that to the monoid constructor.
*/
//@{
static void construct(op_basic_string* monoid, view_type* view)
{
view_guard vg( new((void*) view) view_type() );
vg.confirm_if(
new((void*) monoid) op_basic_string(view->get_allocator()) );
}
template <typename T1>
static void construct(op_basic_string* monoid, view_type* view,
const T1& x1)
{
view_guard vg( new((void*) view) view_type(x1) );
vg.confirm_if(
new((void*) monoid) op_basic_string(view->get_allocator()) );
}
template <typename T1, typename T2>
static void construct(op_basic_string* monoid, view_type* view,
const T1& x1, const T2& x2)
{
view_guard vg( new((void*) view) view_type(x1, x2) );
vg.confirm_if(
new((void*) monoid) op_basic_string(view->get_allocator()) );
}
template <typename T1, typename T2, typename T3>
static void construct(op_basic_string* monoid, view_type* view,
const T1& x1, const T2& x2, const T3& x3)
{
view_guard vg( new((void*) view) view_type(x1, x2, x3) );
vg.confirm_if(
new((void*) monoid) op_basic_string(view->get_allocator()) );
}
template <typename T1, typename T2, typename T3, typename T4>
static void construct(op_basic_string* monoid, view_type* view,
const T1& x1, const T2& x2, const T3& x3,
const T4& x4)
{
view_guard vg( new((void*) view) view_type(x1, x2, x3, x4) );
vg.confirm_if(
new((void*) monoid) op_basic_string(view->get_allocator()) );
}
//@}
};
/** Convenience typedef for 8-bit strings
*/
typedef op_basic_string<char> op_string;
/** Convenience typedef for 16-bit strings
*/
typedef op_basic_string<wchar_t> op_wstring;
/** Deprecated string append reducer class.
*
* reducer_basic_string is the same as @ref reducer<@ref op_basic_string>,
* except that reducer_basic_string is a proxy for the contained view, so that
* accumulator variable update operations can be applied directly to the
* reducer. For example, a value is appended to a `reducer<%op_basic_string>`
* with `r->push_back(a)`, but a value can be appended to a `%reducer_opand`
* with `r.push_back(a)`.
*
* @deprecated Users are strongly encouraged to use `reducer<monoid>`
* reducers rather than the old wrappers like reducer_basic_string.
* The `reducer<monoid>` reducers show the reducer/monoid/view
* architecture more clearly, are more consistent in their
* implementation, and present a simpler model for new
* user-implemented reducers.
*
* @note Implicit conversions are provided between `%reducer_basic_string`
* and `reducer<%op_basic_string>`. This allows incremental code
* conversion: old code that used `%reducer_basic_string` can pass a
* `%reducer_basic_string` to a converted function that now expects a
* pointer or reference to a `reducer<%op_basic_string>`, and vice
* versa.
*
* @tparam Char The string element type (not the string type).
* @tparam Traits The character traits type.
* @tparam Alloc The string allocator type.
*
* @see op_basic_string
* @see reducer
* @see ReducersString
*/
template<typename Char,
typename Traits = std::char_traits<Char>,
typename Alloc = std::allocator<Char> >
class reducer_basic_string :
public reducer< op_basic_string<Char, Traits, Alloc, true> >
{
typedef reducer< op_basic_string<Char, Traits, Alloc, true> > base;
using base::view;
public:
/// The reducer's string type.
typedef typename base::value_type string_type;
/// The reducer's primitive component type.
typedef Char basic_value_type;
/// The string size type.
typedef typename string_type::size_type size_type;
/// The view type for the reducer.
typedef typename base::view_type View;
/// The monoid type for the reducer.
typedef typename base::monoid_type Monoid;
/** @name Constructors
*/
//@{
/** @name Forward constructor calls to the base class.
*
* All basic_string constructor forms are supported.
*/
//@{
reducer_basic_string() {}
template <typename T1>
reducer_basic_string(const T1& x1) :
base(x1) {}
template <typename T1, typename T2>
reducer_basic_string(const T1& x1, const T2& x2) :
base(x1, x2) {}
template <typename T1, typename T2, typename T3>
reducer_basic_string(const T1& x1, const T2& x2, const T3& x3) :
base(x1, x2, x3) {}
template <typename T1, typename T2, typename T3, typename T4>
reducer_basic_string(const T1& x1, const T2& x2, const T3& x3, const T4& x4) :
base(x1, x2, x3, x4) {}
//@}
/** Allows mutable access to the string within the current view.
*
* @warning If this method is called before the parallel calculation is
* complete, the string returned by this method will be a
* partial result.
*
* @returns A mutable reference to the string within the current view.
*/
string_type &get_reference()
{ return view().view_get_reference(); }
/** Allows read-only access to the string within the current view.
*
* @warning If this method is called before the parallel calculation is
* complete, the string returned by this method will be a
* partial result.
*
* @returns A const reference to the string within the current view.
*/
string_type const &get_reference() const
{ return view().view_get_reference(); }
/** @name Appends to the string.
*
* These operations are simply forwarded to the view.
*/
//@{
void append(const Char *ptr)
{ view().append(ptr); }
void append(const Char *ptr, size_type count)
{ view().append(ptr, count); }
void append(const string_type &str, size_type offset, size_type count)
{ view().append(str, offset, count); }
void append(const string_type &str)
{ view().append(str); }
void append(size_type count, Char ch)
{ view().append(count, ch); }
// Appends to the string
reducer_basic_string<Char, Traits, Alloc> &operator+=(Char ch)
{ view() += ch; return *this; }
reducer_basic_string<Char, Traits, Alloc> &operator+=(const Char *ptr)
{ view() += ptr; return *this; }
reducer_basic_string<Char, Traits, Alloc> &operator+=(const string_type &right)
{ view() += right; return *this; }
//@}
/** @name Dereference
* @details Dereferencing a wrapper is a no-op. It simply returns the
* wrapper. Combined with the rule that the wrapper forwards view
* operations to its contained view, this means that view operations can
* be written the same way on reducers and wrappers, which is convenient
* for incrementally converting old code using wrappers to use reducers
* instead. That is:
*
* reducer<op_string> r;
* r->push_back(a); // r-> returns the view
* // push_back() is a view member function
*
* reducer_string w;
* w->push_back(a); // *w returns the wrapper
* // push_back() is a wrapper member function
* // that calls the corresponding view function
*/
//@{
reducer_basic_string& operator*() { return *this; }
reducer_basic_string const& operator*() const { return *this; }
reducer_basic_string* operator->() { return this; }
reducer_basic_string const* operator->() const { return this; }
//@}
/** @name Upcast
* @details In Intel Cilk Plus library 0.9, reducers were always cache-aligned.
* In library 1.0, reducer cache alignment is optional. By default,
* reducers are unaligned (i.e., just naturally aligned), but legacy
* wrappers inherit from cache-aligned reducers for binary compatibility.
*
* This means that a wrapper will automatically be upcast to its aligned
* reducer base class. The following conversion operators provide
* pseudo-upcasts to the corresponding unaligned reducer class.
*/
//@{
operator reducer< op_basic_string<Char, Traits, Alloc, false> >& ()
{
return *reinterpret_cast< reducer<
op_basic_string<Char, Traits, Alloc, false> >*
>(this);
}
operator const reducer< op_basic_string<Char, Traits, Alloc, false> >& () const
{
return *reinterpret_cast< const reducer<
op_basic_string<Char, Traits, Alloc, false> >*
>(this);
}
//@}
};
/** Convenience typedef for 8-bit strings
*/
typedef reducer_basic_string<char> reducer_string;
/** Convenience typedef for 16-bit strings
*/
typedef reducer_basic_string<wchar_t> reducer_wstring;
/// @cond internal
/// @cond internal
/** Metafunction specialization for reducer conversion.
*
* This specialization of the @ref legacy_reducer_downcast template class
* defined in reducer.h causes the `reducer< op_basic_string<Char> >` class to
* have an `operator reducer_basic_string<Char>& ()` conversion operator that
* statically downcasts the `reducer<op_basic_string>` to the corresponding
* `reducer_basic_string` type. (The reverse conversion, from
* `reducer_basic_string` to `reducer<op_basic_string>`, is just an upcast,
* which is provided for free by the language.)
*
* @ingroup ReducersString
*/
template<typename Char, typename Traits, typename Alloc, bool Align>
struct legacy_reducer_downcast<
reducer<op_basic_string<Char, Traits, Alloc, Align> > >
{
typedef reducer_basic_string<Char, Traits, Alloc> type;
};
/// @endcond
//@}
} // namespace cilk
#endif // REDUCER_STRING_H_INCLUDED
@@ -0,0 +1,49 @@
/* Copyright (C) 2013-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#if !defined _X86INTRIN_H_INCLUDED
# error "Never use <clflushoptintrin.h> directly; include <x86intrin.h> instead."
#endif
#ifndef _CLFLUSHOPTINTRIN_H_INCLUDED
#define _CLFLUSHOPTINTRIN_H_INCLUDED
#ifndef __CLFLUSHOPT__
#pragma GCC push_options
#pragma GCC target("clflushopt")
#define __DISABLE_CLFLUSHOPT__
#endif /* __CLFLUSHOPT__ */
extern __inline void
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_clflushopt (void *__A)
{
__builtin_ia32_clflushopt (__A);
}
#ifdef __DISABLE_CLFLUSHOPT__
#undef __DISABLE_CLFLUSHOPT__
#pragma GCC pop_options
#endif /* __DISABLE_CLFLUSHOPT__ */
#endif /* _CLFLUSHOPTINTRIN_H_INCLUDED */
@@ -0,0 +1,49 @@
/* Copyright (C) 2013-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#if !defined _X86INTRIN_H_INCLUDED
# error "Never use <clwbintrin.h> directly; include <x86intrin.h> instead."
#endif
#ifndef _CLWBINTRIN_H_INCLUDED
#define _CLWBINTRIN_H_INCLUDED
#ifndef __CLWB__
#pragma GCC push_options
#pragma GCC target("clwb")
#define __DISABLE_CLWB__
#endif /* __CLWB__ */
extern __inline void
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_clwb (void *__A)
{
__builtin_ia32_clwb (__A);
}
#ifdef __DISABLE_CLWB__
#undef __DISABLE_CLWB__
#pragma GCC pop_options
#endif /* __DISABLE_CLWB__ */
#endif /* _CLWBINTRIN_H_INCLUDED */
@@ -0,0 +1,44 @@
/* Copyright (C) 2012-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _CLZEROINTRIN_H_INCLUDED
#define _CLZEROINTRIN_H_INCLUDED
#ifndef __CLZERO__
#pragma GCC push_options
#pragma GCC target("clzero")
#define __DISABLE_CLZERO__
#endif /* __CLZERO__ */
extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_clzero (void * __I)
{
__builtin_ia32_clzero (__I);
}
#ifdef __DISABLE_CLZERO__
#undef __DISABLE_CLZERO__
#pragma GCC pop_options
#endif /* __DISABLE_CLZERO__ */
#endif /* _CLZEROINTRIN_H_INCLUDED */
@@ -0,0 +1,273 @@
/*
* Copyright (C) 2007-2017 Free Software Foundation, Inc.
*
* This file is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 3, or (at your option) any
* later version.
*
* This file is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* Under Section 7 of GPL version 3, you are granted additional
* permissions described in the GCC Runtime Library Exception, version
* 3.1, as published by the Free Software Foundation.
*
* You should have received a copy of the GNU General Public License and
* a copy of the GCC Runtime Library Exception along with this program;
* see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
* <http://www.gnu.org/licenses/>.
*/
/* %ecx */
#define bit_SSE3 (1 << 0)
#define bit_PCLMUL (1 << 1)
#define bit_LZCNT (1 << 5)
#define bit_SSSE3 (1 << 9)
#define bit_FMA (1 << 12)
#define bit_CMPXCHG16B (1 << 13)
#define bit_SSE4_1 (1 << 19)
#define bit_SSE4_2 (1 << 20)
#define bit_MOVBE (1 << 22)
#define bit_POPCNT (1 << 23)
#define bit_AES (1 << 25)
#define bit_XSAVE (1 << 26)
#define bit_OSXSAVE (1 << 27)
#define bit_AVX (1 << 28)
#define bit_F16C (1 << 29)
#define bit_RDRND (1 << 30)
/* %edx */
#define bit_CMPXCHG8B (1 << 8)
#define bit_CMOV (1 << 15)
#define bit_MMX (1 << 23)
#define bit_FXSAVE (1 << 24)
#define bit_SSE (1 << 25)
#define bit_SSE2 (1 << 26)
/* Extended Features (%eax == 0x80000001) */
/* %ecx */
#define bit_LAHF_LM (1 << 0)
#define bit_ABM (1 << 5)
#define bit_SSE4a (1 << 6)
#define bit_PRFCHW (1 << 8)
#define bit_XOP (1 << 11)
#define bit_LWP (1 << 15)
#define bit_FMA4 (1 << 16)
#define bit_TBM (1 << 21)
#define bit_MWAITX (1 << 29)
/* %edx */
#define bit_MMXEXT (1 << 22)
#define bit_LM (1 << 29)
#define bit_3DNOWP (1 << 30)
#define bit_3DNOW (1u << 31)
/* %ebx */
#define bit_CLZERO (1 << 0)
/* Extended Features (%eax == 7) */
/* %ebx */
#define bit_FSGSBASE (1 << 0)
#define bit_SGX (1 << 2)
#define bit_BMI (1 << 3)
#define bit_HLE (1 << 4)
#define bit_AVX2 (1 << 5)
#define bit_BMI2 (1 << 8)
#define bit_RTM (1 << 11)
#define bit_MPX (1 << 14)
#define bit_AVX512F (1 << 16)
#define bit_AVX512DQ (1 << 17)
#define bit_RDSEED (1 << 18)
#define bit_ADX (1 << 19)
#define bit_AVX512IFMA (1 << 21)
#define bit_CLFLUSHOPT (1 << 23)
#define bit_CLWB (1 << 24)
#define bit_AVX512PF (1 << 26)
#define bit_AVX512ER (1 << 27)
#define bit_AVX512CD (1 << 28)
#define bit_SHA (1 << 29)
#define bit_AVX512BW (1 << 30)
#define bit_AVX512VL (1u << 31)
/* %ecx */
#define bit_PREFETCHWT1 (1 << 0)
#define bit_AVX512VBMI (1 << 1)
#define bit_PKU (1 << 3)
#define bit_OSPKE (1 << 4)
#define bit_AVX512VPOPCNTDQ (1 << 14)
#define bit_RDPID (1 << 22)
/* %edx */
#define bit_AVX5124VNNIW (1 << 2)
#define bit_AVX5124FMAPS (1 << 3)
/* XFEATURE_ENABLED_MASK register bits (%eax == 13, %ecx == 0) */
#define bit_BNDREGS (1 << 3)
#define bit_BNDCSR (1 << 4)
/* Extended State Enumeration Sub-leaf (%eax == 13, %ecx == 1) */
#define bit_XSAVEOPT (1 << 0)
#define bit_XSAVEC (1 << 1)
#define bit_XSAVES (1 << 3)
/* Signatures for different CPU implementations as returned in uses
of cpuid with level 0. */
#define signature_AMD_ebx 0x68747541
#define signature_AMD_ecx 0x444d4163
#define signature_AMD_edx 0x69746e65
#define signature_CENTAUR_ebx 0x746e6543
#define signature_CENTAUR_ecx 0x736c7561
#define signature_CENTAUR_edx 0x48727561
#define signature_CYRIX_ebx 0x69727943
#define signature_CYRIX_ecx 0x64616574
#define signature_CYRIX_edx 0x736e4978
#define signature_INTEL_ebx 0x756e6547
#define signature_INTEL_ecx 0x6c65746e
#define signature_INTEL_edx 0x49656e69
#define signature_TM1_ebx 0x6e617254
#define signature_TM1_ecx 0x55504361
#define signature_TM1_edx 0x74656d73
#define signature_TM2_ebx 0x756e6547
#define signature_TM2_ecx 0x3638784d
#define signature_TM2_edx 0x54656e69
#define signature_NSC_ebx 0x646f6547
#define signature_NSC_ecx 0x43534e20
#define signature_NSC_edx 0x79622065
#define signature_NEXGEN_ebx 0x4778654e
#define signature_NEXGEN_ecx 0x6e657669
#define signature_NEXGEN_edx 0x72446e65
#define signature_RISE_ebx 0x65736952
#define signature_RISE_ecx 0x65736952
#define signature_RISE_edx 0x65736952
#define signature_SIS_ebx 0x20536953
#define signature_SIS_ecx 0x20536953
#define signature_SIS_edx 0x20536953
#define signature_UMC_ebx 0x20434d55
#define signature_UMC_ecx 0x20434d55
#define signature_UMC_edx 0x20434d55
#define signature_VIA_ebx 0x20414956
#define signature_VIA_ecx 0x20414956
#define signature_VIA_edx 0x20414956
#define signature_VORTEX_ebx 0x74726f56
#define signature_VORTEX_ecx 0x436f5320
#define signature_VORTEX_edx 0x36387865
#define __cpuid(level, a, b, c, d) \
__asm__ ("cpuid\n\t" \
: "=a" (a), "=b" (b), "=c" (c), "=d" (d) \
: "0" (level))
#define __cpuid_count(level, count, a, b, c, d) \
__asm__ ("cpuid\n\t" \
: "=a" (a), "=b" (b), "=c" (c), "=d" (d) \
: "0" (level), "2" (count))
/* Return highest supported input value for cpuid instruction. ext can
be either 0x0 or 0x80000000 to return highest supported value for
basic or extended cpuid information. Function returns 0 if cpuid
is not supported or whatever cpuid returns in eax register. If sig
pointer is non-null, then first four bytes of the signature
(as found in ebx register) are returned in location pointed by sig. */
static __inline unsigned int
__get_cpuid_max (unsigned int __ext, unsigned int *__sig)
{
unsigned int __eax, __ebx, __ecx, __edx;
#ifndef __x86_64__
/* See if we can use cpuid. On AMD64 we always can. */
#if __GNUC__ >= 3
__asm__ ("pushf{l|d}\n\t"
"pushf{l|d}\n\t"
"pop{l}\t%0\n\t"
"mov{l}\t{%0, %1|%1, %0}\n\t"
"xor{l}\t{%2, %0|%0, %2}\n\t"
"push{l}\t%0\n\t"
"popf{l|d}\n\t"
"pushf{l|d}\n\t"
"pop{l}\t%0\n\t"
"popf{l|d}\n\t"
: "=&r" (__eax), "=&r" (__ebx)
: "i" (0x00200000));
#else
/* Host GCCs older than 3.0 weren't supporting Intel asm syntax
nor alternatives in i386 code. */
__asm__ ("pushfl\n\t"
"pushfl\n\t"
"popl\t%0\n\t"
"movl\t%0, %1\n\t"
"xorl\t%2, %0\n\t"
"pushl\t%0\n\t"
"popfl\n\t"
"pushfl\n\t"
"popl\t%0\n\t"
"popfl\n\t"
: "=&r" (__eax), "=&r" (__ebx)
: "i" (0x00200000));
#endif
if (!((__eax ^ __ebx) & 0x00200000))
return 0;
#endif
/* Host supports cpuid. Return highest supported cpuid input value. */
__cpuid (__ext, __eax, __ebx, __ecx, __edx);
if (__sig)
*__sig = __ebx;
return __eax;
}
/* Return cpuid data for requested cpuid leaf, as found in returned
eax, ebx, ecx and edx registers. The function checks if cpuid is
supported and returns 1 for valid cpuid information or 0 for
unsupported cpuid leaf. All pointers are required to be non-null. */
static __inline int
__get_cpuid (unsigned int __leaf,
unsigned int *__eax, unsigned int *__ebx,
unsigned int *__ecx, unsigned int *__edx)
{
unsigned int __ext = __leaf & 0x80000000;
unsigned int __maxlevel = __get_cpuid_max (__ext, 0);
if (__maxlevel == 0 || __maxlevel < __leaf)
return 0;
__cpuid (__leaf, *__eax, *__ebx, *__ecx, *__edx);
return 1;
}
/* Same as above, but sub-leaf can be specified. */
static __inline int
__get_cpuid_count (unsigned int __leaf, unsigned int __subleaf,
unsigned int *__eax, unsigned int *__ebx,
unsigned int *__ecx, unsigned int *__edx)
{
unsigned int __ext = __leaf & 0x80000000;
unsigned int __maxlevel = __get_cpuid_max (__ext, 0);
if (__maxlevel == 0 || __maxlevel < __leaf)
return 0;
__cpuid_count (__leaf, __subleaf, *__eax, *__ebx, *__ecx, *__edx);
return 1;
}
@@ -0,0 +1,72 @@
/* Copyright (C) 2002-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef __CROSS_STDARG_H_INCLUDED
#define __CROSS_STDARG_H_INCLUDED
/* Make sure that for non x64 targets cross builtins are defined. */
#ifndef __x86_64__
/* Call abi ms_abi. */
#define __builtin_ms_va_list __builtin_va_list
#define __builtin_ms_va_copy __builtin_va_copy
#define __builtin_ms_va_start __builtin_va_start
#define __builtin_ms_va_end __builtin_va_end
/* Call abi sysv_abi. */
#define __builtin_sysv_va_list __builtin_va_list
#define __builtin_sysv_va_copy __builtin_va_copy
#define __builtin_sysv_va_start __builtin_va_start
#define __builtin_sysv_va_end __builtin_va_end
#endif
#define __ms_va_copy(__d,__s) __builtin_ms_va_copy(__d,__s)
#define __ms_va_start(__v,__l) __builtin_ms_va_start(__v,__l)
#define __ms_va_arg(__v,__l) __builtin_va_arg(__v,__l)
#define __ms_va_end(__v) __builtin_ms_va_end(__v)
#define __sysv_va_copy(__d,__s) __builtin_sysv_va_copy(__d,__s)
#define __sysv_va_start(__v,__l) __builtin_sysv_va_start(__v,__l)
#define __sysv_va_arg(__v,__l) __builtin_va_arg(__v,__l)
#define __sysv_va_end(__v) __builtin_sysv_va_end(__v)
#ifndef __GNUC_SYSV_VA_LIST
#define __GNUC_SYSV_VA_LIST
typedef __builtin_sysv_va_list __gnuc_sysv_va_list;
#endif
#ifndef _SYSV_VA_LIST_DEFINED
#define _SYSV_VA_LIST_DEFINED
typedef __gnuc_sysv_va_list sysv_va_list;
#endif
#ifndef __GNUC_MS_VA_LIST
#define __GNUC_MS_VA_LIST
typedef __builtin_ms_va_list __gnuc_ms_va_list;
#endif
#ifndef _MS_VA_LIST_DEFINED
#define _MS_VA_LIST_DEFINED
typedef __gnuc_ms_va_list ms_va_list;
#endif
#endif /* __CROSS_STDARG_H_INCLUDED */
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,98 @@
/* Copyright (C) 2011-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#if !defined _X86INTRIN_H_INCLUDED && !defined _IMMINTRIN_H_INCLUDED
# error "Never use <f16intrin.h> directly; include <x86intrin.h> or <immintrin.h> instead."
#endif
#ifndef _F16CINTRIN_H_INCLUDED
#define _F16CINTRIN_H_INCLUDED
#ifndef __F16C__
#pragma GCC push_options
#pragma GCC target("f16c")
#define __DISABLE_F16C__
#endif /* __F16C__ */
extern __inline float __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_cvtsh_ss (unsigned short __S)
{
__v8hi __H = __extension__ (__v8hi){ (short) __S, 0, 0, 0, 0, 0, 0, 0 };
__v4sf __A = __builtin_ia32_vcvtph2ps (__H);
return __builtin_ia32_vec_ext_v4sf (__A, 0);
}
extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cvtph_ps (__m128i __A)
{
return (__m128) __builtin_ia32_vcvtph2ps ((__v8hi) __A);
}
extern __inline __m256 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_cvtph_ps (__m128i __A)
{
return (__m256) __builtin_ia32_vcvtph2ps256 ((__v8hi) __A);
}
#ifdef __OPTIMIZE__
extern __inline unsigned short __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_cvtss_sh (float __F, const int __I)
{
__v4sf __A = __extension__ (__v4sf){ __F, 0, 0, 0 };
__v8hi __H = __builtin_ia32_vcvtps2ph (__A, __I);
return (unsigned short) __builtin_ia32_vec_ext_v8hi (__H, 0);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cvtps_ph (__m128 __A, const int __I)
{
return (__m128i) __builtin_ia32_vcvtps2ph ((__v4sf) __A, __I);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_cvtps_ph (__m256 __A, const int __I)
{
return (__m128i) __builtin_ia32_vcvtps2ph256 ((__v8sf) __A, __I);
}
#else
#define _cvtss_sh(__F, __I) \
(__extension__ \
({ \
__v4sf __A = __extension__ (__v4sf){ __F, 0, 0, 0 }; \
__v8hi __H = __builtin_ia32_vcvtps2ph (__A, __I); \
(unsigned short) __builtin_ia32_vec_ext_v8hi (__H, 0); \
}))
#define _mm_cvtps_ph(A, I) \
((__m128i) __builtin_ia32_vcvtps2ph ((__v4sf)(__m128) A, (int) (I)))
#define _mm256_cvtps_ph(A, I) \
((__m128i) __builtin_ia32_vcvtps2ph256 ((__v8sf)(__m256) A, (int) (I)))
#endif /* __OPTIMIZE */
#ifdef __DISABLE_F16C__
#undef __DISABLE_F16C__
#pragma GCC pop_options
#endif /* __DISABLE_F16C__ */
#endif /* _F16CINTRIN_H_INCLUDED */
@@ -0,0 +1,506 @@
/* Copyright (C) 2002-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
/*
* ISO C Standard: 5.2.4.2.2 Characteristics of floating types <float.h>
*/
#ifndef _FLOAT_H___
#define _FLOAT_H___
/* Radix of exponent representation, b. */
#undef FLT_RADIX
#define FLT_RADIX __FLT_RADIX__
/* Number of base-FLT_RADIX digits in the significand, p. */
#undef FLT_MANT_DIG
#undef DBL_MANT_DIG
#undef LDBL_MANT_DIG
#define FLT_MANT_DIG __FLT_MANT_DIG__
#define DBL_MANT_DIG __DBL_MANT_DIG__
#define LDBL_MANT_DIG __LDBL_MANT_DIG__
/* Number of decimal digits, q, such that any floating-point number with q
decimal digits can be rounded into a floating-point number with p radix b
digits and back again without change to the q decimal digits,
p * log10(b) if b is a power of 10
floor((p - 1) * log10(b)) otherwise
*/
#undef FLT_DIG
#undef DBL_DIG
#undef LDBL_DIG
#define FLT_DIG __FLT_DIG__
#define DBL_DIG __DBL_DIG__
#define LDBL_DIG __LDBL_DIG__
/* Minimum int x such that FLT_RADIX**(x-1) is a normalized float, emin */
#undef FLT_MIN_EXP
#undef DBL_MIN_EXP
#undef LDBL_MIN_EXP
#define FLT_MIN_EXP __FLT_MIN_EXP__
#define DBL_MIN_EXP __DBL_MIN_EXP__
#define LDBL_MIN_EXP __LDBL_MIN_EXP__
/* Minimum negative integer such that 10 raised to that power is in the
range of normalized floating-point numbers,
ceil(log10(b) * (emin - 1))
*/
#undef FLT_MIN_10_EXP
#undef DBL_MIN_10_EXP
#undef LDBL_MIN_10_EXP
#define FLT_MIN_10_EXP __FLT_MIN_10_EXP__
#define DBL_MIN_10_EXP __DBL_MIN_10_EXP__
#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__
/* Maximum int x such that FLT_RADIX**(x-1) is a representable float, emax. */
#undef FLT_MAX_EXP
#undef DBL_MAX_EXP
#undef LDBL_MAX_EXP
#define FLT_MAX_EXP __FLT_MAX_EXP__
#define DBL_MAX_EXP __DBL_MAX_EXP__
#define LDBL_MAX_EXP __LDBL_MAX_EXP__
/* Maximum integer such that 10 raised to that power is in the range of
representable finite floating-point numbers,
floor(log10((1 - b**-p) * b**emax))
*/
#undef FLT_MAX_10_EXP
#undef DBL_MAX_10_EXP
#undef LDBL_MAX_10_EXP
#define FLT_MAX_10_EXP __FLT_MAX_10_EXP__
#define DBL_MAX_10_EXP __DBL_MAX_10_EXP__
#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__
/* Maximum representable finite floating-point number,
(1 - b**-p) * b**emax
*/
#undef FLT_MAX
#undef DBL_MAX
#undef LDBL_MAX
#define FLT_MAX __FLT_MAX__
#define DBL_MAX __DBL_MAX__
#define LDBL_MAX __LDBL_MAX__
/* The difference between 1 and the least value greater than 1 that is
representable in the given floating point type, b**1-p. */
#undef FLT_EPSILON
#undef DBL_EPSILON
#undef LDBL_EPSILON
#define FLT_EPSILON __FLT_EPSILON__
#define DBL_EPSILON __DBL_EPSILON__
#define LDBL_EPSILON __LDBL_EPSILON__
/* Minimum normalized positive floating-point number, b**(emin - 1). */
#undef FLT_MIN
#undef DBL_MIN
#undef LDBL_MIN
#define FLT_MIN __FLT_MIN__
#define DBL_MIN __DBL_MIN__
#define LDBL_MIN __LDBL_MIN__
/* Addition rounds to 0: zero, 1: nearest, 2: +inf, 3: -inf, -1: unknown. */
/* ??? This is supposed to change with calls to fesetround in <fenv.h>. */
#undef FLT_ROUNDS
#define FLT_ROUNDS 1
#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \
|| (defined (__cplusplus) && __cplusplus >= 201103L)
/* The floating-point expression evaluation method. The precise
definitions of these values are generalised to include support for
the interchange and extended types defined in ISO/IEC TS 18661-3.
Prior to this (for C99/C11) the definitions were:
-1 indeterminate
0 evaluate all operations and constants just to the range and
precision of the type
1 evaluate operations and constants of type float and double
to the range and precision of the double type, evaluate
long double operations and constants to the range and
precision of the long double type
2 evaluate all operations and constants to the range and
precision of the long double type
The TS 18661-3 definitions are:
-1 indeterminate
0 evaluate all operations and constants, whose semantic type has
at most the range and precision of float, to the range and
precision of float; evaluate all other operations and constants
to the range and precision of the semantic type.
1 evaluate all operations and constants, whose semantic type has
at most the range and precision of double, to the range and
precision of double; evaluate all other operations and constants
to the range and precision of the semantic type.
2 evaluate all operations and constants, whose semantic type has
at most the range and precision of long double, to the range and
precision of long double; evaluate all other operations and
constants to the range and precision of the semantic type.
N where _FloatN is a supported interchange floating type
evaluate all operations and constants, whose semantic type has
at most the range and precision of the _FloatN type, to the
range and precision of the _FloatN type; evaluate all other
operations and constants to the range and precision of the
semantic type.
N + 1, where _FloatNx is a supported extended floating type
evaluate operations and constants, whose semantic type has at
most the range and precision of the _FloatNx type, to the range
and precision of the _FloatNx type; evaluate all other
operations and constants to the range and precision of the
semantic type.
The compiler predefines two macros:
__FLT_EVAL_METHOD__
Which, depending on the value given for
-fpermitted-flt-eval-methods, may be limited to only those values
for FLT_EVAL_METHOD defined in C99/C11.
__FLT_EVAL_METHOD_TS_18661_3__
Which always permits the values for FLT_EVAL_METHOD defined in
ISO/IEC TS 18661-3.
Here we want to use __FLT_EVAL_METHOD__, unless
__STDC_WANT_IEC_60559_TYPES_EXT__ is defined, in which case the user
is specifically asking for the ISO/IEC TS 18661-3 types, so we use
__FLT_EVAL_METHOD_TS_18661_3__.
??? This ought to change with the setting of the fp control word;
the value provided by the compiler assumes the widest setting. */
#undef FLT_EVAL_METHOD
#ifdef __STDC_WANT_IEC_60559_TYPES_EXT__
#define FLT_EVAL_METHOD __FLT_EVAL_METHOD_TS_18661_3__
#else
#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
#endif
/* Number of decimal digits, n, such that any floating-point number in the
widest supported floating type with pmax radix b digits can be rounded
to a floating-point number with n decimal digits and back again without
change to the value,
pmax * log10(b) if b is a power of 10
ceil(1 + pmax * log10(b)) otherwise
*/
#undef DECIMAL_DIG
#define DECIMAL_DIG __DECIMAL_DIG__
#endif /* C99 */
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
/* Versions of DECIMAL_DIG for each floating-point type. */
#undef FLT_DECIMAL_DIG
#undef DBL_DECIMAL_DIG
#undef LDBL_DECIMAL_DIG
#define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
#define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
#define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
/* Whether types support subnormal numbers. */
#undef FLT_HAS_SUBNORM
#undef DBL_HAS_SUBNORM
#undef LDBL_HAS_SUBNORM
#define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
#define DBL_HAS_SUBNORM __DBL_HAS_DENORM__
#define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__
/* Minimum positive values, including subnormals. */
#undef FLT_TRUE_MIN
#undef DBL_TRUE_MIN
#undef LDBL_TRUE_MIN
#define FLT_TRUE_MIN __FLT_DENORM_MIN__
#define DBL_TRUE_MIN __DBL_DENORM_MIN__
#define LDBL_TRUE_MIN __LDBL_DENORM_MIN__
#endif /* C11 */
#ifdef __STDC_WANT_IEC_60559_BFP_EXT__
/* Number of decimal digits for which conversions between decimal
character strings and binary formats, in both directions, are
correctly rounded. */
#define CR_DECIMAL_DIG __UINTMAX_MAX__
#endif
#ifdef __STDC_WANT_IEC_60559_TYPES_EXT__
/* Constants for _FloatN and _FloatNx types from TS 18661-3. See
comments above for their semantics. */
#ifdef __FLT16_MANT_DIG__
#undef FLT16_MANT_DIG
#define FLT16_MANT_DIG __FLT16_MANT_DIG__
#undef FLT16_DIG
#define FLT16_DIG __FLT16_DIG__
#undef FLT16_MIN_EXP
#define FLT16_MIN_EXP __FLT16_MIN_EXP__
#undef FLT16_MIN_10_EXP
#define FLT16_MIN_10_EXP __FLT16_MIN_10_EXP__
#undef FLT16_MAX_EXP
#define FLT16_MAX_EXP __FLT16_MAX_EXP__
#undef FLT16_MAX_10_EXP
#define FLT16_MAX_10_EXP __FLT16_MAX_10_EXP__
#undef FLT16_MAX
#define FLT16_MAX __FLT16_MAX__
#undef FLT16_EPSILON
#define FLT16_EPSILON __FLT16_EPSILON__
#undef FLT16_MIN
#define FLT16_MIN __FLT16_MIN__
#undef FLT16_DECIMAL_DIG
#define FLT16_DECIMAL_DIG __FLT16_DECIMAL_DIG__
#undef FLT16_TRUE_MIN
#define FLT16_TRUE_MIN __FLT16_DENORM_MIN__
#endif /* __FLT16_MANT_DIG__. */
#ifdef __FLT32_MANT_DIG__
#undef FLT32_MANT_DIG
#define FLT32_MANT_DIG __FLT32_MANT_DIG__
#undef FLT32_DIG
#define FLT32_DIG __FLT32_DIG__
#undef FLT32_MIN_EXP
#define FLT32_MIN_EXP __FLT32_MIN_EXP__
#undef FLT32_MIN_10_EXP
#define FLT32_MIN_10_EXP __FLT32_MIN_10_EXP__
#undef FLT32_MAX_EXP
#define FLT32_MAX_EXP __FLT32_MAX_EXP__
#undef FLT32_MAX_10_EXP
#define FLT32_MAX_10_EXP __FLT32_MAX_10_EXP__
#undef FLT32_MAX
#define FLT32_MAX __FLT32_MAX__
#undef FLT32_EPSILON
#define FLT32_EPSILON __FLT32_EPSILON__
#undef FLT32_MIN
#define FLT32_MIN __FLT32_MIN__
#undef FLT32_DECIMAL_DIG
#define FLT32_DECIMAL_DIG __FLT32_DECIMAL_DIG__
#undef FLT32_TRUE_MIN
#define FLT32_TRUE_MIN __FLT32_DENORM_MIN__
#endif /* __FLT32_MANT_DIG__. */
#ifdef __FLT64_MANT_DIG__
#undef FLT64_MANT_DIG
#define FLT64_MANT_DIG __FLT64_MANT_DIG__
#undef FLT64_DIG
#define FLT64_DIG __FLT64_DIG__
#undef FLT64_MIN_EXP
#define FLT64_MIN_EXP __FLT64_MIN_EXP__
#undef FLT64_MIN_10_EXP
#define FLT64_MIN_10_EXP __FLT64_MIN_10_EXP__
#undef FLT64_MAX_EXP
#define FLT64_MAX_EXP __FLT64_MAX_EXP__
#undef FLT64_MAX_10_EXP
#define FLT64_MAX_10_EXP __FLT64_MAX_10_EXP__
#undef FLT64_MAX
#define FLT64_MAX __FLT64_MAX__
#undef FLT64_EPSILON
#define FLT64_EPSILON __FLT64_EPSILON__
#undef FLT64_MIN
#define FLT64_MIN __FLT64_MIN__
#undef FLT64_DECIMAL_DIG
#define FLT64_DECIMAL_DIG __FLT64_DECIMAL_DIG__
#undef FLT64_TRUE_MIN
#define FLT64_TRUE_MIN __FLT64_DENORM_MIN__
#endif /* __FLT64_MANT_DIG__. */
#ifdef __FLT128_MANT_DIG__
#undef FLT128_MANT_DIG
#define FLT128_MANT_DIG __FLT128_MANT_DIG__
#undef FLT128_DIG
#define FLT128_DIG __FLT128_DIG__
#undef FLT128_MIN_EXP
#define FLT128_MIN_EXP __FLT128_MIN_EXP__
#undef FLT128_MIN_10_EXP
#define FLT128_MIN_10_EXP __FLT128_MIN_10_EXP__
#undef FLT128_MAX_EXP
#define FLT128_MAX_EXP __FLT128_MAX_EXP__
#undef FLT128_MAX_10_EXP
#define FLT128_MAX_10_EXP __FLT128_MAX_10_EXP__
#undef FLT128_MAX
#define FLT128_MAX __FLT128_MAX__
#undef FLT128_EPSILON
#define FLT128_EPSILON __FLT128_EPSILON__
#undef FLT128_MIN
#define FLT128_MIN __FLT128_MIN__
#undef FLT128_DECIMAL_DIG
#define FLT128_DECIMAL_DIG __FLT128_DECIMAL_DIG__
#undef FLT128_TRUE_MIN
#define FLT128_TRUE_MIN __FLT128_DENORM_MIN__
#endif /* __FLT128_MANT_DIG__. */
#ifdef __FLT32X_MANT_DIG__
#undef FLT32X_MANT_DIG
#define FLT32X_MANT_DIG __FLT32X_MANT_DIG__
#undef FLT32X_DIG
#define FLT32X_DIG __FLT32X_DIG__
#undef FLT32X_MIN_EXP
#define FLT32X_MIN_EXP __FLT32X_MIN_EXP__
#undef FLT32X_MIN_10_EXP
#define FLT32X_MIN_10_EXP __FLT32X_MIN_10_EXP__
#undef FLT32X_MAX_EXP
#define FLT32X_MAX_EXP __FLT32X_MAX_EXP__
#undef FLT32X_MAX_10_EXP
#define FLT32X_MAX_10_EXP __FLT32X_MAX_10_EXP__
#undef FLT32X_MAX
#define FLT32X_MAX __FLT32X_MAX__
#undef FLT32X_EPSILON
#define FLT32X_EPSILON __FLT32X_EPSILON__
#undef FLT32X_MIN
#define FLT32X_MIN __FLT32X_MIN__
#undef FLT32X_DECIMAL_DIG
#define FLT32X_DECIMAL_DIG __FLT32X_DECIMAL_DIG__
#undef FLT32X_TRUE_MIN
#define FLT32X_TRUE_MIN __FLT32X_DENORM_MIN__
#endif /* __FLT32X_MANT_DIG__. */
#ifdef __FLT64X_MANT_DIG__
#undef FLT64X_MANT_DIG
#define FLT64X_MANT_DIG __FLT64X_MANT_DIG__
#undef FLT64X_DIG
#define FLT64X_DIG __FLT64X_DIG__
#undef FLT64X_MIN_EXP
#define FLT64X_MIN_EXP __FLT64X_MIN_EXP__
#undef FLT64X_MIN_10_EXP
#define FLT64X_MIN_10_EXP __FLT64X_MIN_10_EXP__
#undef FLT64X_MAX_EXP
#define FLT64X_MAX_EXP __FLT64X_MAX_EXP__
#undef FLT64X_MAX_10_EXP
#define FLT64X_MAX_10_EXP __FLT64X_MAX_10_EXP__
#undef FLT64X_MAX
#define FLT64X_MAX __FLT64X_MAX__
#undef FLT64X_EPSILON
#define FLT64X_EPSILON __FLT64X_EPSILON__
#undef FLT64X_MIN
#define FLT64X_MIN __FLT64X_MIN__
#undef FLT64X_DECIMAL_DIG
#define FLT64X_DECIMAL_DIG __FLT64X_DECIMAL_DIG__
#undef FLT64X_TRUE_MIN
#define FLT64X_TRUE_MIN __FLT64X_DENORM_MIN__
#endif /* __FLT64X_MANT_DIG__. */
#ifdef __FLT128X_MANT_DIG__
#undef FLT128X_MANT_DIG
#define FLT128X_MANT_DIG __FLT128X_MANT_DIG__
#undef FLT128X_DIG
#define FLT128X_DIG __FLT128X_DIG__
#undef FLT128X_MIN_EXP
#define FLT128X_MIN_EXP __FLT128X_MIN_EXP__
#undef FLT128X_MIN_10_EXP
#define FLT128X_MIN_10_EXP __FLT128X_MIN_10_EXP__
#undef FLT128X_MAX_EXP
#define FLT128X_MAX_EXP __FLT128X_MAX_EXP__
#undef FLT128X_MAX_10_EXP
#define FLT128X_MAX_10_EXP __FLT128X_MAX_10_EXP__
#undef FLT128X_MAX
#define FLT128X_MAX __FLT128X_MAX__
#undef FLT128X_EPSILON
#define FLT128X_EPSILON __FLT128X_EPSILON__
#undef FLT128X_MIN
#define FLT128X_MIN __FLT128X_MIN__
#undef FLT128X_DECIMAL_DIG
#define FLT128X_DECIMAL_DIG __FLT128X_DECIMAL_DIG__
#undef FLT128X_TRUE_MIN
#define FLT128X_TRUE_MIN __FLT128X_DENORM_MIN__
#endif /* __FLT128X_MANT_DIG__. */
#endif /* __STDC_WANT_IEC_60559_TYPES_EXT__. */
#ifdef __STDC_WANT_DEC_FP__
/* Draft Technical Report 24732, extension for decimal floating-point
arithmetic: Characteristic of decimal floating types <float.h>. */
/* Number of base-FLT_RADIX digits in the significand, p. */
#undef DEC32_MANT_DIG
#undef DEC64_MANT_DIG
#undef DEC128_MANT_DIG
#define DEC32_MANT_DIG __DEC32_MANT_DIG__
#define DEC64_MANT_DIG __DEC64_MANT_DIG__
#define DEC128_MANT_DIG __DEC128_MANT_DIG__
/* Minimum exponent. */
#undef DEC32_MIN_EXP
#undef DEC64_MIN_EXP
#undef DEC128_MIN_EXP
#define DEC32_MIN_EXP __DEC32_MIN_EXP__
#define DEC64_MIN_EXP __DEC64_MIN_EXP__
#define DEC128_MIN_EXP __DEC128_MIN_EXP__
/* Maximum exponent. */
#undef DEC32_MAX_EXP
#undef DEC64_MAX_EXP
#undef DEC128_MAX_EXP
#define DEC32_MAX_EXP __DEC32_MAX_EXP__
#define DEC64_MAX_EXP __DEC64_MAX_EXP__
#define DEC128_MAX_EXP __DEC128_MAX_EXP__
/* Maximum representable finite decimal floating-point number
(there are 6, 15, and 33 9s after the decimal points respectively). */
#undef DEC32_MAX
#undef DEC64_MAX
#undef DEC128_MAX
#define DEC32_MAX __DEC32_MAX__
#define DEC64_MAX __DEC64_MAX__
#define DEC128_MAX __DEC128_MAX__
/* The difference between 1 and the least value greater than 1 that is
representable in the given floating point type. */
#undef DEC32_EPSILON
#undef DEC64_EPSILON
#undef DEC128_EPSILON
#define DEC32_EPSILON __DEC32_EPSILON__
#define DEC64_EPSILON __DEC64_EPSILON__
#define DEC128_EPSILON __DEC128_EPSILON__
/* Minimum normalized positive floating-point number. */
#undef DEC32_MIN
#undef DEC64_MIN
#undef DEC128_MIN
#define DEC32_MIN __DEC32_MIN__
#define DEC64_MIN __DEC64_MIN__
#define DEC128_MIN __DEC128_MIN__
/* Minimum subnormal positive floating-point number. */
#undef DEC32_SUBNORMAL_MIN
#undef DEC64_SUBNORMAL_MIN
#undef DEC128_SUBNORMAL_MIN
#define DEC32_SUBNORMAL_MIN __DEC32_SUBNORMAL_MIN__
#define DEC64_SUBNORMAL_MIN __DEC64_SUBNORMAL_MIN__
#define DEC128_SUBNORMAL_MIN __DEC128_SUBNORMAL_MIN__
/* The floating-point expression evaluation method.
-1 indeterminate
0 evaluate all operations and constants just to the range and
precision of the type
1 evaluate operations and constants of type _Decimal32
and _Decimal64 to the range and precision of the _Decimal64
type, evaluate _Decimal128 operations and constants to the
range and precision of the _Decimal128 type;
2 evaluate all operations and constants to the range and
precision of the _Decimal128 type. */
#undef DEC_EVAL_METHOD
#define DEC_EVAL_METHOD __DEC_EVAL_METHOD__
#endif /* __STDC_WANT_DEC_FP__ */
#endif /* _FLOAT_H___ */
@@ -0,0 +1,241 @@
/* Copyright (C) 2007-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _X86INTRIN_H_INCLUDED
# error "Never use <fma4intrin.h> directly; include <x86intrin.h> instead."
#endif
#ifndef _FMA4INTRIN_H_INCLUDED
#define _FMA4INTRIN_H_INCLUDED
/* We need definitions from the SSE4A, SSE3, SSE2 and SSE header files. */
#include <ammintrin.h>
#ifndef __FMA4__
#pragma GCC push_options
#pragma GCC target("fma4")
#define __DISABLE_FMA4__
#endif /* __FMA4__ */
/* 128b Floating point multiply/add type instructions. */
extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_macc_ps (__m128 __A, __m128 __B, __m128 __C)
{
return (__m128) __builtin_ia32_vfmaddps ((__v4sf)__A, (__v4sf)__B, (__v4sf)__C);
}
extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_macc_pd (__m128d __A, __m128d __B, __m128d __C)
{
return (__m128d) __builtin_ia32_vfmaddpd ((__v2df)__A, (__v2df)__B, (__v2df)__C);
}
extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_macc_ss (__m128 __A, __m128 __B, __m128 __C)
{
return (__m128) __builtin_ia32_vfmaddss ((__v4sf)__A, (__v4sf)__B, (__v4sf)__C);
}
extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_macc_sd (__m128d __A, __m128d __B, __m128d __C)
{
return (__m128d) __builtin_ia32_vfmaddsd ((__v2df)__A, (__v2df)__B, (__v2df)__C);
}
extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_msub_ps (__m128 __A, __m128 __B, __m128 __C)
{
return (__m128) __builtin_ia32_vfmaddps ((__v4sf)__A, (__v4sf)__B, -(__v4sf)__C);
}
extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_msub_pd (__m128d __A, __m128d __B, __m128d __C)
{
return (__m128d) __builtin_ia32_vfmaddpd ((__v2df)__A, (__v2df)__B, -(__v2df)__C);
}
extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_msub_ss (__m128 __A, __m128 __B, __m128 __C)
{
return (__m128) __builtin_ia32_vfmaddss ((__v4sf)__A, (__v4sf)__B, -(__v4sf)__C);
}
extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_msub_sd (__m128d __A, __m128d __B, __m128d __C)
{
return (__m128d) __builtin_ia32_vfmaddsd ((__v2df)__A, (__v2df)__B, -(__v2df)__C);
}
extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_nmacc_ps (__m128 __A, __m128 __B, __m128 __C)
{
return (__m128) __builtin_ia32_vfmaddps (-(__v4sf)__A, (__v4sf)__B, (__v4sf)__C);
}
extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_nmacc_pd (__m128d __A, __m128d __B, __m128d __C)
{
return (__m128d) __builtin_ia32_vfmaddpd (-(__v2df)__A, (__v2df)__B, (__v2df)__C);
}
extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_nmacc_ss (__m128 __A, __m128 __B, __m128 __C)
{
return (__m128) __builtin_ia32_vfmaddss (-(__v4sf)__A, (__v4sf)__B, (__v4sf)__C);
}
extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_nmacc_sd (__m128d __A, __m128d __B, __m128d __C)
{
return (__m128d) __builtin_ia32_vfmaddsd (-(__v2df)__A, (__v2df)__B, (__v2df)__C);
}
extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_nmsub_ps (__m128 __A, __m128 __B, __m128 __C)
{
return (__m128) __builtin_ia32_vfmaddps (-(__v4sf)__A, (__v4sf)__B, -(__v4sf)__C);
}
extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_nmsub_pd (__m128d __A, __m128d __B, __m128d __C)
{
return (__m128d) __builtin_ia32_vfmaddpd (-(__v2df)__A, (__v2df)__B, -(__v2df)__C);
}
extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_nmsub_ss (__m128 __A, __m128 __B, __m128 __C)
{
return (__m128) __builtin_ia32_vfmaddss (-(__v4sf)__A, (__v4sf)__B, -(__v4sf)__C);
}
extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_nmsub_sd (__m128d __A, __m128d __B, __m128d __C)
{
return (__m128d) __builtin_ia32_vfmaddsd (-(__v2df)__A, (__v2df)__B, -(__v2df)__C);
}
extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_maddsub_ps (__m128 __A, __m128 __B, __m128 __C)
{
return (__m128) __builtin_ia32_vfmaddsubps ((__v4sf)__A, (__v4sf)__B, (__v4sf)__C);
}
extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_maddsub_pd (__m128d __A, __m128d __B, __m128d __C)
{
return (__m128d) __builtin_ia32_vfmaddsubpd ((__v2df)__A, (__v2df)__B, (__v2df)__C);
}
extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_msubadd_ps (__m128 __A, __m128 __B, __m128 __C)
{
return (__m128) __builtin_ia32_vfmaddsubps ((__v4sf)__A, (__v4sf)__B, -(__v4sf)__C);
}
extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_msubadd_pd (__m128d __A, __m128d __B, __m128d __C)
{
return (__m128d) __builtin_ia32_vfmaddsubpd ((__v2df)__A, (__v2df)__B, -(__v2df)__C);
}
/* 256b Floating point multiply/add type instructions. */
extern __inline __m256 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_macc_ps (__m256 __A, __m256 __B, __m256 __C)
{
return (__m256) __builtin_ia32_vfmaddps256 ((__v8sf)__A, (__v8sf)__B, (__v8sf)__C);
}
extern __inline __m256d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_macc_pd (__m256d __A, __m256d __B, __m256d __C)
{
return (__m256d) __builtin_ia32_vfmaddpd256 ((__v4df)__A, (__v4df)__B, (__v4df)__C);
}
extern __inline __m256 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_msub_ps (__m256 __A, __m256 __B, __m256 __C)
{
return (__m256) __builtin_ia32_vfmaddps256 ((__v8sf)__A, (__v8sf)__B, -(__v8sf)__C);
}
extern __inline __m256d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_msub_pd (__m256d __A, __m256d __B, __m256d __C)
{
return (__m256d) __builtin_ia32_vfmaddpd256 ((__v4df)__A, (__v4df)__B, -(__v4df)__C);
}
extern __inline __m256 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_nmacc_ps (__m256 __A, __m256 __B, __m256 __C)
{
return (__m256) __builtin_ia32_vfmaddps256 (-(__v8sf)__A, (__v8sf)__B, (__v8sf)__C);
}
extern __inline __m256d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_nmacc_pd (__m256d __A, __m256d __B, __m256d __C)
{
return (__m256d) __builtin_ia32_vfmaddpd256 (-(__v4df)__A, (__v4df)__B, (__v4df)__C);
}
extern __inline __m256 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_nmsub_ps (__m256 __A, __m256 __B, __m256 __C)
{
return (__m256) __builtin_ia32_vfmaddps256 (-(__v8sf)__A, (__v8sf)__B, -(__v8sf)__C);
}
extern __inline __m256d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_nmsub_pd (__m256d __A, __m256d __B, __m256d __C)
{
return (__m256d) __builtin_ia32_vfmaddpd256 (-(__v4df)__A, (__v4df)__B, -(__v4df)__C);
}
extern __inline __m256 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_maddsub_ps (__m256 __A, __m256 __B, __m256 __C)
{
return (__m256) __builtin_ia32_vfmaddsubps256 ((__v8sf)__A, (__v8sf)__B, (__v8sf)__C);
}
extern __inline __m256d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_maddsub_pd (__m256d __A, __m256d __B, __m256d __C)
{
return (__m256d) __builtin_ia32_vfmaddsubpd256 ((__v4df)__A, (__v4df)__B, (__v4df)__C);
}
extern __inline __m256 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_msubadd_ps (__m256 __A, __m256 __B, __m256 __C)
{
return (__m256) __builtin_ia32_vfmaddsubps256 ((__v8sf)__A, (__v8sf)__B, -(__v8sf)__C);
}
extern __inline __m256d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_msubadd_pd (__m256d __A, __m256d __B, __m256d __C)
{
return (__m256d) __builtin_ia32_vfmaddsubpd256 ((__v4df)__A, (__v4df)__B, -(__v4df)__C);
}
#ifdef __DISABLE_FMA4__
#undef __DISABLE_FMA4__
#pragma GCC pop_options
#endif /* __DISABLE_FMA4__ */
#endif
@@ -0,0 +1,302 @@
/* Copyright (C) 2011-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _IMMINTRIN_H_INCLUDED
# error "Never use <fmaintrin.h> directly; include <immintrin.h> instead."
#endif
#ifndef _FMAINTRIN_H_INCLUDED
#define _FMAINTRIN_H_INCLUDED
#ifndef __FMA__
#pragma GCC push_options
#pragma GCC target("fma")
#define __DISABLE_FMA__
#endif /* __FMA__ */
extern __inline __m128d
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_fmadd_pd (__m128d __A, __m128d __B, __m128d __C)
{
return (__m128d)__builtin_ia32_vfmaddpd ((__v2df)__A, (__v2df)__B,
(__v2df)__C);
}
extern __inline __m256d
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_fmadd_pd (__m256d __A, __m256d __B, __m256d __C)
{
return (__m256d)__builtin_ia32_vfmaddpd256 ((__v4df)__A, (__v4df)__B,
(__v4df)__C);
}
extern __inline __m128
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_fmadd_ps (__m128 __A, __m128 __B, __m128 __C)
{
return (__m128)__builtin_ia32_vfmaddps ((__v4sf)__A, (__v4sf)__B,
(__v4sf)__C);
}
extern __inline __m256
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_fmadd_ps (__m256 __A, __m256 __B, __m256 __C)
{
return (__m256)__builtin_ia32_vfmaddps256 ((__v8sf)__A, (__v8sf)__B,
(__v8sf)__C);
}
extern __inline __m128d
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_fmadd_sd (__m128d __A, __m128d __B, __m128d __C)
{
return (__m128d) __builtin_ia32_vfmaddsd3 ((__v2df)__A, (__v2df)__B,
(__v2df)__C);
}
extern __inline __m128
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_fmadd_ss (__m128 __A, __m128 __B, __m128 __C)
{
return (__m128) __builtin_ia32_vfmaddss3 ((__v4sf)__A, (__v4sf)__B,
(__v4sf)__C);
}
extern __inline __m128d
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_fmsub_pd (__m128d __A, __m128d __B, __m128d __C)
{
return (__m128d)__builtin_ia32_vfmaddpd ((__v2df)__A, (__v2df)__B,
-(__v2df)__C);
}
extern __inline __m256d
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_fmsub_pd (__m256d __A, __m256d __B, __m256d __C)
{
return (__m256d)__builtin_ia32_vfmaddpd256 ((__v4df)__A, (__v4df)__B,
-(__v4df)__C);
}
extern __inline __m128
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_fmsub_ps (__m128 __A, __m128 __B, __m128 __C)
{
return (__m128)__builtin_ia32_vfmaddps ((__v4sf)__A, (__v4sf)__B,
-(__v4sf)__C);
}
extern __inline __m256
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_fmsub_ps (__m256 __A, __m256 __B, __m256 __C)
{
return (__m256)__builtin_ia32_vfmaddps256 ((__v8sf)__A, (__v8sf)__B,
-(__v8sf)__C);
}
extern __inline __m128d
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_fmsub_sd (__m128d __A, __m128d __B, __m128d __C)
{
return (__m128d)__builtin_ia32_vfmaddsd3 ((__v2df)__A, (__v2df)__B,
-(__v2df)__C);
}
extern __inline __m128
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_fmsub_ss (__m128 __A, __m128 __B, __m128 __C)
{
return (__m128)__builtin_ia32_vfmaddss3 ((__v4sf)__A, (__v4sf)__B,
-(__v4sf)__C);
}
extern __inline __m128d
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_fnmadd_pd (__m128d __A, __m128d __B, __m128d __C)
{
return (__m128d)__builtin_ia32_vfmaddpd (-(__v2df)__A, (__v2df)__B,
(__v2df)__C);
}
extern __inline __m256d
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_fnmadd_pd (__m256d __A, __m256d __B, __m256d __C)
{
return (__m256d)__builtin_ia32_vfmaddpd256 (-(__v4df)__A, (__v4df)__B,
(__v4df)__C);
}
extern __inline __m128
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_fnmadd_ps (__m128 __A, __m128 __B, __m128 __C)
{
return (__m128)__builtin_ia32_vfmaddps (-(__v4sf)__A, (__v4sf)__B,
(__v4sf)__C);
}
extern __inline __m256
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_fnmadd_ps (__m256 __A, __m256 __B, __m256 __C)
{
return (__m256)__builtin_ia32_vfmaddps256 (-(__v8sf)__A, (__v8sf)__B,
(__v8sf)__C);
}
extern __inline __m128d
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_fnmadd_sd (__m128d __A, __m128d __B, __m128d __C)
{
return (__m128d)__builtin_ia32_vfmaddsd3 ((__v2df)__A, -(__v2df)__B,
(__v2df)__C);
}
extern __inline __m128
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_fnmadd_ss (__m128 __A, __m128 __B, __m128 __C)
{
return (__m128)__builtin_ia32_vfmaddss3 ((__v4sf)__A, -(__v4sf)__B,
(__v4sf)__C);
}
extern __inline __m128d
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_fnmsub_pd (__m128d __A, __m128d __B, __m128d __C)
{
return (__m128d)__builtin_ia32_vfmaddpd (-(__v2df)__A, (__v2df)__B,
-(__v2df)__C);
}
extern __inline __m256d
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_fnmsub_pd (__m256d __A, __m256d __B, __m256d __C)
{
return (__m256d)__builtin_ia32_vfmaddpd256 (-(__v4df)__A, (__v4df)__B,
-(__v4df)__C);
}
extern __inline __m128
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_fnmsub_ps (__m128 __A, __m128 __B, __m128 __C)
{
return (__m128)__builtin_ia32_vfmaddps (-(__v4sf)__A, (__v4sf)__B,
-(__v4sf)__C);
}
extern __inline __m256
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_fnmsub_ps (__m256 __A, __m256 __B, __m256 __C)
{
return (__m256)__builtin_ia32_vfmaddps256 (-(__v8sf)__A, (__v8sf)__B,
-(__v8sf)__C);
}
extern __inline __m128d
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_fnmsub_sd (__m128d __A, __m128d __B, __m128d __C)
{
return (__m128d)__builtin_ia32_vfmaddsd3 ((__v2df)__A, -(__v2df)__B,
-(__v2df)__C);
}
extern __inline __m128
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_fnmsub_ss (__m128 __A, __m128 __B, __m128 __C)
{
return (__m128)__builtin_ia32_vfmaddss3 ((__v4sf)__A, -(__v4sf)__B,
-(__v4sf)__C);
}
extern __inline __m128d
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_fmaddsub_pd (__m128d __A, __m128d __B, __m128d __C)
{
return (__m128d)__builtin_ia32_vfmaddsubpd ((__v2df)__A, (__v2df)__B,
(__v2df)__C);
}
extern __inline __m256d
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_fmaddsub_pd (__m256d __A, __m256d __B, __m256d __C)
{
return (__m256d)__builtin_ia32_vfmaddsubpd256 ((__v4df)__A,
(__v4df)__B,
(__v4df)__C);
}
extern __inline __m128
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_fmaddsub_ps (__m128 __A, __m128 __B, __m128 __C)
{
return (__m128)__builtin_ia32_vfmaddsubps ((__v4sf)__A, (__v4sf)__B,
(__v4sf)__C);
}
extern __inline __m256
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_fmaddsub_ps (__m256 __A, __m256 __B, __m256 __C)
{
return (__m256)__builtin_ia32_vfmaddsubps256 ((__v8sf)__A,
(__v8sf)__B,
(__v8sf)__C);
}
extern __inline __m128d
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_fmsubadd_pd (__m128d __A, __m128d __B, __m128d __C)
{
return (__m128d)__builtin_ia32_vfmaddsubpd ((__v2df)__A, (__v2df)__B,
-(__v2df)__C);
}
extern __inline __m256d
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_fmsubadd_pd (__m256d __A, __m256d __B, __m256d __C)
{
return (__m256d)__builtin_ia32_vfmaddsubpd256 ((__v4df)__A,
(__v4df)__B,
-(__v4df)__C);
}
extern __inline __m128
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_fmsubadd_ps (__m128 __A, __m128 __B, __m128 __C)
{
return (__m128)__builtin_ia32_vfmaddsubps ((__v4sf)__A, (__v4sf)__B,
-(__v4sf)__C);
}
extern __inline __m256
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm256_fmsubadd_ps (__m256 __A, __m256 __B, __m256 __C)
{
return (__m256)__builtin_ia32_vfmaddsubps256 ((__v8sf)__A,
(__v8sf)__B,
-(__v8sf)__C);
}
#ifdef __DISABLE_FMA__
#undef __DISABLE_FMA__
#pragma GCC pop_options
#endif /* __DISABLE_FMA__ */
#endif
@@ -0,0 +1,73 @@
/* Copyright (C) 2012-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
/* #if !defined _X86INTRIN_H_INCLUDED && !defined _IMMINTRIN_H_INCLUDED */
/* # error "Never use <fxsrintrin.h> directly; include <x86intrin.h> instead." */
/* #endif */
#ifndef _FXSRINTRIN_H_INCLUDED
#define _FXSRINTRIN_H_INCLUDED
#ifndef __FXSR__
#pragma GCC push_options
#pragma GCC target("fxsr")
#define __DISABLE_FXSR__
#endif /* __FXSR__ */
extern __inline void
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_fxsave (void *__P)
{
__builtin_ia32_fxsave (__P);
}
extern __inline void
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_fxrstor (void *__P)
{
__builtin_ia32_fxrstor (__P);
}
#ifdef __x86_64__
extern __inline void
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_fxsave64 (void *__P)
{
__builtin_ia32_fxsave64 (__P);
}
extern __inline void
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_fxrstor64 (void *__P)
{
__builtin_ia32_fxrstor64 (__P);
}
#endif
#ifdef __DISABLE_FXSR__
#undef __DISABLE_FXSR__
#pragma GCC pop_options
#endif /* __DISABLE_FXSR__ */
#endif /* _FXSRINTRIN_H_INCLUDED */
@@ -0,0 +1,313 @@
/* Copyright (C) 2009-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _X86INTRIN_H_INCLUDED
# error "Never use <ia32intrin.h> directly; include <x86intrin.h> instead."
#endif
/* 32bit bsf */
extern __inline int
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__bsfd (int __X)
{
return __builtin_ctz (__X);
}
/* 32bit bsr */
extern __inline int
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__bsrd (int __X)
{
return __builtin_ia32_bsrsi (__X);
}
/* 32bit bswap */
extern __inline int
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__bswapd (int __X)
{
return __builtin_bswap32 (__X);
}
#ifndef __iamcu__
#ifndef __SSE4_2__
#pragma GCC push_options
#pragma GCC target("sse4.2")
#define __DISABLE_SSE4_2__
#endif /* __SSE4_2__ */
/* 32bit accumulate CRC32 (polynomial 0x11EDC6F41) value. */
extern __inline unsigned int
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__crc32b (unsigned int __C, unsigned char __V)
{
return __builtin_ia32_crc32qi (__C, __V);
}
extern __inline unsigned int
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__crc32w (unsigned int __C, unsigned short __V)
{
return __builtin_ia32_crc32hi (__C, __V);
}
extern __inline unsigned int
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__crc32d (unsigned int __C, unsigned int __V)
{
return __builtin_ia32_crc32si (__C, __V);
}
#ifdef __DISABLE_SSE4_2__
#undef __DISABLE_SSE4_2__
#pragma GCC pop_options
#endif /* __DISABLE_SSE4_2__ */
#endif /* __iamcu__ */
/* 32bit popcnt */
extern __inline int
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__popcntd (unsigned int __X)
{
return __builtin_popcount (__X);
}
#ifndef __iamcu__
/* rdpmc */
extern __inline unsigned long long
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__rdpmc (int __S)
{
return __builtin_ia32_rdpmc (__S);
}
#endif /* __iamcu__ */
/* rdtsc */
extern __inline unsigned long long
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__rdtsc (void)
{
return __builtin_ia32_rdtsc ();
}
#ifndef __iamcu__
/* rdtscp */
extern __inline unsigned long long
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__rdtscp (unsigned int *__A)
{
return __builtin_ia32_rdtscp (__A);
}
#endif /* __iamcu__ */
/* 8bit rol */
extern __inline unsigned char
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__rolb (unsigned char __X, int __C)
{
return __builtin_ia32_rolqi (__X, __C);
}
/* 16bit rol */
extern __inline unsigned short
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__rolw (unsigned short __X, int __C)
{
return __builtin_ia32_rolhi (__X, __C);
}
/* 32bit rol */
extern __inline unsigned int
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__rold (unsigned int __X, int __C)
{
return (__X << __C) | (__X >> (32 - __C));
}
/* 8bit ror */
extern __inline unsigned char
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__rorb (unsigned char __X, int __C)
{
return __builtin_ia32_rorqi (__X, __C);
}
/* 16bit ror */
extern __inline unsigned short
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__rorw (unsigned short __X, int __C)
{
return __builtin_ia32_rorhi (__X, __C);
}
/* 32bit ror */
extern __inline unsigned int
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__rord (unsigned int __X, int __C)
{
return (__X >> __C) | (__X << (32 - __C));
}
/* Pause */
extern __inline void
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__pause (void)
{
__builtin_ia32_pause ();
}
#ifdef __x86_64__
/* 64bit bsf */
extern __inline int
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__bsfq (long long __X)
{
return __builtin_ctzll (__X);
}
/* 64bit bsr */
extern __inline int
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__bsrq (long long __X)
{
return __builtin_ia32_bsrdi (__X);
}
/* 64bit bswap */
extern __inline long long
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__bswapq (long long __X)
{
return __builtin_bswap64 (__X);
}
#ifndef __SSE4_2__
#pragma GCC push_options
#pragma GCC target("sse4.2")
#define __DISABLE_SSE4_2__
#endif /* __SSE4_2__ */
/* 64bit accumulate CRC32 (polynomial 0x11EDC6F41) value. */
extern __inline unsigned long long
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__crc32q (unsigned long long __C, unsigned long long __V)
{
return __builtin_ia32_crc32di (__C, __V);
}
#ifdef __DISABLE_SSE4_2__
#undef __DISABLE_SSE4_2__
#pragma GCC pop_options
#endif /* __DISABLE_SSE4_2__ */
/* 64bit popcnt */
extern __inline long long
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__popcntq (unsigned long long __X)
{
return __builtin_popcountll (__X);
}
/* 64bit rol */
extern __inline unsigned long long
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__rolq (unsigned long long __X, int __C)
{
return (__X << __C) | (__X >> (64 - __C));
}
/* 64bit ror */
extern __inline unsigned long long
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__rorq (unsigned long long __X, int __C)
{
return (__X >> __C) | (__X << (64 - __C));
}
/* Read flags register */
extern __inline unsigned long long
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__readeflags (void)
{
return __builtin_ia32_readeflags_u64 ();
}
/* Write flags register */
extern __inline void
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__writeeflags (unsigned long long __X)
{
__builtin_ia32_writeeflags_u64 (__X);
}
#define _bswap64(a) __bswapq(a)
#define _popcnt64(a) __popcntq(a)
#else
/* Read flags register */
extern __inline unsigned int
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__readeflags (void)
{
return __builtin_ia32_readeflags_u32 ();
}
/* Write flags register */
extern __inline void
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__writeeflags (unsigned int __X)
{
__builtin_ia32_writeeflags_u32 (__X);
}
#endif
/* On LP64 systems, longs are 64-bit. Use the appropriate rotate
* function. */
#ifdef __LP64__
#define _lrotl(a,b) __rolq((a), (b))
#define _lrotr(a,b) __rorq((a), (b))
#else
#define _lrotl(a,b) __rold((a), (b))
#define _lrotr(a,b) __rord((a), (b))
#endif
#define _bit_scan_forward(a) __bsfd(a)
#define _bit_scan_reverse(a) __bsrd(a)
#define _bswap(a) __bswapd(a)
#define _popcnt32(a) __popcntd(a)
#ifndef __iamcu__
#define _rdpmc(a) __rdpmc(a)
#define _rdtscp(a) __rdtscp(a)
#endif /* __iamcu__ */
#define _rdtsc() __rdtsc()
#define _rotwl(a,b) __rolw((a), (b))
#define _rotwr(a,b) __rorw((a), (b))
#define _rotl(a,b) __rold((a), (b))
#define _rotr(a,b) __rord((a), (b))
@@ -0,0 +1,217 @@
/* Copyright (C) 2008-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _IMMINTRIN_H_INCLUDED
#define _IMMINTRIN_H_INCLUDED
#include <mmintrin.h>
#include <xmmintrin.h>
#include <emmintrin.h>
#include <pmmintrin.h>
#include <tmmintrin.h>
#include <smmintrin.h>
#include <wmmintrin.h>
#include <avxintrin.h>
#include <avx2intrin.h>
#include <avx512fintrin.h>
#include <avx512erintrin.h>
#include <avx512pfintrin.h>
#include <avx512cdintrin.h>
#include <avx512vlintrin.h>
#include <avx512bwintrin.h>
#include <avx512dqintrin.h>
#include <avx512vlbwintrin.h>
#include <avx512vldqintrin.h>
#include <avx512ifmaintrin.h>
#include <avx512ifmavlintrin.h>
#include <avx512vbmiintrin.h>
#include <avx512vbmivlintrin.h>
#include <avx5124fmapsintrin.h>
#include <avx5124vnniwintrin.h>
#include <avx512vpopcntdqintrin.h>
#include <shaintrin.h>
#include <lzcntintrin.h>
#include <bmiintrin.h>
#include <bmi2intrin.h>
#include <fmaintrin.h>
#include <f16cintrin.h>
#include <rtmintrin.h>
#include <xtestintrin.h>
#ifndef __RDRND__
#pragma GCC push_options
#pragma GCC target("rdrnd")
#define __DISABLE_RDRND__
#endif /* __RDRND__ */
extern __inline int
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_rdrand16_step (unsigned short *__P)
{
return __builtin_ia32_rdrand16_step (__P);
}
extern __inline int
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_rdrand32_step (unsigned int *__P)
{
return __builtin_ia32_rdrand32_step (__P);
}
#ifdef __DISABLE_RDRND__
#undef __DISABLE_RDRND__
#pragma GCC pop_options
#endif /* __DISABLE_RDRND__ */
#ifndef __RDPID__
#pragma GCC push_options
#pragma GCC target("rdpid")
#define __DISABLE_RDPID__
#endif /* __RDPID__ */
extern __inline unsigned int
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_rdpid_u32 (void)
{
return __builtin_ia32_rdpid ();
}
#ifdef __DISABLE_RDPID__
#undef __DISABLE_RDPID__
#pragma GCC pop_options
#endif /* __DISABLE_RDPID__ */
#ifdef __x86_64__
#ifndef __FSGSBASE__
#pragma GCC push_options
#pragma GCC target("fsgsbase")
#define __DISABLE_FSGSBASE__
#endif /* __FSGSBASE__ */
extern __inline unsigned int
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_readfsbase_u32 (void)
{
return __builtin_ia32_rdfsbase32 ();
}
extern __inline unsigned long long
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_readfsbase_u64 (void)
{
return __builtin_ia32_rdfsbase64 ();
}
extern __inline unsigned int
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_readgsbase_u32 (void)
{
return __builtin_ia32_rdgsbase32 ();
}
extern __inline unsigned long long
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_readgsbase_u64 (void)
{
return __builtin_ia32_rdgsbase64 ();
}
extern __inline void
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_writefsbase_u32 (unsigned int __B)
{
__builtin_ia32_wrfsbase32 (__B);
}
extern __inline void
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_writefsbase_u64 (unsigned long long __B)
{
__builtin_ia32_wrfsbase64 (__B);
}
extern __inline void
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_writegsbase_u32 (unsigned int __B)
{
__builtin_ia32_wrgsbase32 (__B);
}
extern __inline void
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_writegsbase_u64 (unsigned long long __B)
{
__builtin_ia32_wrgsbase64 (__B);
}
#ifdef __DISABLE_FSGSBASE__
#undef __DISABLE_FSGSBASE__
#pragma GCC pop_options
#endif /* __DISABLE_FSGSBASE__ */
#ifndef __RDRND__
#pragma GCC push_options
#pragma GCC target("rdrnd")
#define __DISABLE_RDRND__
#endif /* __RDRND__ */
extern __inline int
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_rdrand64_step (unsigned long long *__P)
{
return __builtin_ia32_rdrand64_step (__P);
}
#ifdef __DISABLE_RDRND__
#undef __DISABLE_RDRND__
#pragma GCC pop_options
#endif /* __DISABLE_RDRND__ */
#endif /* __x86_64__ */
#endif /* _IMMINTRIN_H_INCLUDED */
@@ -0,0 +1,45 @@
/* Copyright (C) 1997-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
/*
* ISO C Standard: 7.9 Alternative spellings <iso646.h>
*/
#ifndef _ISO646_H
#define _ISO646_H
#ifndef __cplusplus
#define and &&
#define and_eq &=
#define bitand &
#define bitor |
#define compl ~
#define not !
#define not_eq !=
#define or ||
#define or_eq |=
#define xor ^
#define xor_eq ^=
#endif
#endif
@@ -0,0 +1,197 @@
/* Copyright (C) 1992-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
/* This administrivia gets added to the beginning of limits.h
if the system has its own version of limits.h. */
/* We use _GCC_LIMITS_H_ because we want this not to match
any macros that the system's limits.h uses for its own purposes. */
#ifndef _GCC_LIMITS_H_ /* Terminated in limity.h. */
#define _GCC_LIMITS_H_
#ifndef _LIBC_LIMITS_H_
/* Use "..." so that we find syslimits.h only in this same directory. */
#include "syslimits.h"
#endif
/* Copyright (C) 1991-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _LIMITS_H___
#define _LIMITS_H___
/* Number of bits in a `char'. */
#undef CHAR_BIT
#define CHAR_BIT __CHAR_BIT__
/* Maximum length of a multibyte character. */
#ifndef MB_LEN_MAX
#define MB_LEN_MAX 1
#endif
/* Minimum and maximum values a `signed char' can hold. */
#undef SCHAR_MIN
#define SCHAR_MIN (-SCHAR_MAX - 1)
#undef SCHAR_MAX
#define SCHAR_MAX __SCHAR_MAX__
/* Maximum value an `unsigned char' can hold. (Minimum is 0). */
#undef UCHAR_MAX
#if __SCHAR_MAX__ == __INT_MAX__
# define UCHAR_MAX (SCHAR_MAX * 2U + 1U)
#else
# define UCHAR_MAX (SCHAR_MAX * 2 + 1)
#endif
/* Minimum and maximum values a `char' can hold. */
#ifdef __CHAR_UNSIGNED__
# undef CHAR_MIN
# if __SCHAR_MAX__ == __INT_MAX__
# define CHAR_MIN 0U
# else
# define CHAR_MIN 0
# endif
# undef CHAR_MAX
# define CHAR_MAX UCHAR_MAX
#else
# undef CHAR_MIN
# define CHAR_MIN SCHAR_MIN
# undef CHAR_MAX
# define CHAR_MAX SCHAR_MAX
#endif
/* Minimum and maximum values a `signed short int' can hold. */
#undef SHRT_MIN
#define SHRT_MIN (-SHRT_MAX - 1)
#undef SHRT_MAX
#define SHRT_MAX __SHRT_MAX__
/* Maximum value an `unsigned short int' can hold. (Minimum is 0). */
#undef USHRT_MAX
#if __SHRT_MAX__ == __INT_MAX__
# define USHRT_MAX (SHRT_MAX * 2U + 1U)
#else
# define USHRT_MAX (SHRT_MAX * 2 + 1)
#endif
/* Minimum and maximum values a `signed int' can hold. */
#undef INT_MIN
#define INT_MIN (-INT_MAX - 1)
#undef INT_MAX
#define INT_MAX __INT_MAX__
/* Maximum value an `unsigned int' can hold. (Minimum is 0). */
#undef UINT_MAX
#define UINT_MAX (INT_MAX * 2U + 1U)
/* Minimum and maximum values a `signed long int' can hold.
(Same as `int'). */
#undef LONG_MIN
#define LONG_MIN (-LONG_MAX - 1L)
#undef LONG_MAX
#define LONG_MAX __LONG_MAX__
/* Maximum value an `unsigned long int' can hold. (Minimum is 0). */
#undef ULONG_MAX
#define ULONG_MAX (LONG_MAX * 2UL + 1UL)
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* Minimum and maximum values a `signed long long int' can hold. */
# undef LLONG_MIN
# define LLONG_MIN (-LLONG_MAX - 1LL)
# undef LLONG_MAX
# define LLONG_MAX __LONG_LONG_MAX__
/* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */
# undef ULLONG_MAX
# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
#endif
#if defined (__GNU_LIBRARY__) ? defined (__USE_GNU) : !defined (__STRICT_ANSI__)
/* Minimum and maximum values a `signed long long int' can hold. */
# undef LONG_LONG_MIN
# define LONG_LONG_MIN (-LONG_LONG_MAX - 1LL)
# undef LONG_LONG_MAX
# define LONG_LONG_MAX __LONG_LONG_MAX__
/* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */
# undef ULONG_LONG_MAX
# define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1ULL)
#endif
#ifdef __STDC_WANT_IEC_60559_BFP_EXT__
/* TS 18661-1 widths of integer types. */
# undef CHAR_WIDTH
# define CHAR_WIDTH __SCHAR_WIDTH__
# undef SCHAR_WIDTH
# define SCHAR_WIDTH __SCHAR_WIDTH__
# undef UCHAR_WIDTH
# define UCHAR_WIDTH __SCHAR_WIDTH__
# undef SHRT_WIDTH
# define SHRT_WIDTH __SHRT_WIDTH__
# undef USHRT_WIDTH
# define USHRT_WIDTH __SHRT_WIDTH__
# undef INT_WIDTH
# define INT_WIDTH __INT_WIDTH__
# undef UINT_WIDTH
# define UINT_WIDTH __INT_WIDTH__
# undef LONG_WIDTH
# define LONG_WIDTH __LONG_WIDTH__
# undef ULONG_WIDTH
# define ULONG_WIDTH __LONG_WIDTH__
# undef LLONG_WIDTH
# define LLONG_WIDTH __LONG_LONG_WIDTH__
# undef ULLONG_WIDTH
# define ULLONG_WIDTH __LONG_LONG_WIDTH__
#endif
#endif /* _LIMITS_H___ */
/* This administrivia gets added to the end of limits.h
if the system has its own version of limits.h. */
#else /* not _GCC_LIMITS_H_ */
#ifdef _GCC_NEXT_LIMITS_H
#include_next <limits.h> /* recurse down to the real one */
#endif
#endif /* not _GCC_LIMITS_H_ */
@@ -0,0 +1,107 @@
/* Copyright (C) 2007-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _X86INTRIN_H_INCLUDED
# error "Never use <lwpintrin.h> directly; include <x86intrin.h> instead."
#endif
#ifndef _LWPINTRIN_H_INCLUDED
#define _LWPINTRIN_H_INCLUDED
#ifndef __LWP__
#pragma GCC push_options
#pragma GCC target("lwp")
#define __DISABLE_LWP__
#endif /* __LWP__ */
extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__llwpcb (void *__pcbAddress)
{
__builtin_ia32_llwpcb (__pcbAddress);
}
extern __inline void * __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__slwpcb (void)
{
return __builtin_ia32_slwpcb ();
}
#ifdef __OPTIMIZE__
extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__lwpval32 (unsigned int __data2, unsigned int __data1, unsigned int __flags)
{
__builtin_ia32_lwpval32 (__data2, __data1, __flags);
}
#ifdef __x86_64__
extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__lwpval64 (unsigned long long __data2, unsigned int __data1,
unsigned int __flags)
{
__builtin_ia32_lwpval64 (__data2, __data1, __flags);
}
#endif
#else
#define __lwpval32(D2, D1, F) \
(__builtin_ia32_lwpval32 ((unsigned int) (D2), (unsigned int) (D1), \
(unsigned int) (F)))
#ifdef __x86_64__
#define __lwpval64(D2, D1, F) \
(__builtin_ia32_lwpval64 ((unsigned long long) (D2), (unsigned int) (D1), \
(unsigned int) (F)))
#endif
#endif
#ifdef __OPTIMIZE__
extern __inline unsigned char __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__lwpins32 (unsigned int __data2, unsigned int __data1, unsigned int __flags)
{
return __builtin_ia32_lwpins32 (__data2, __data1, __flags);
}
#ifdef __x86_64__
extern __inline unsigned char __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__lwpins64 (unsigned long long __data2, unsigned int __data1,
unsigned int __flags)
{
return __builtin_ia32_lwpins64 (__data2, __data1, __flags);
}
#endif
#else
#define __lwpins32(D2, D1, F) \
(__builtin_ia32_lwpins32 ((unsigned int) (D2), (unsigned int) (D1), \
(unsigned int) (F)))
#ifdef __x86_64__
#define __lwpins64(D2, D1, F) \
(__builtin_ia32_lwpins64 ((unsigned long long) (D2), (unsigned int) (D1), \
(unsigned int) (F)))
#endif
#endif
#ifdef __DISABLE_LWP__
#undef __DISABLE_LWP__
#pragma GCC pop_options
#endif /* __DISABLE_LWP__ */
#endif /* _LWPINTRIN_H_INCLUDED */
@@ -0,0 +1,75 @@
/* Copyright (C) 2009-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#if !defined _X86INTRIN_H_INCLUDED && !defined _IMMINTRIN_H_INCLUDED
# error "Never use <lzcntintrin.h> directly; include <x86intrin.h> instead."
#endif
#ifndef _LZCNTINTRIN_H_INCLUDED
#define _LZCNTINTRIN_H_INCLUDED
#ifndef __LZCNT__
#pragma GCC push_options
#pragma GCC target("lzcnt")
#define __DISABLE_LZCNT__
#endif /* __LZCNT__ */
extern __inline unsigned short __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__lzcnt16 (unsigned short __X)
{
return __builtin_ia32_lzcnt_u16 (__X);
}
extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__lzcnt32 (unsigned int __X)
{
return __builtin_ia32_lzcnt_u32 (__X);
}
extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_lzcnt_u32 (unsigned int __X)
{
return __builtin_ia32_lzcnt_u32 (__X);
}
#ifdef __x86_64__
extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__lzcnt64 (unsigned long long __X)
{
return __builtin_ia32_lzcnt_u64 (__X);
}
extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_lzcnt_u64 (unsigned long long __X)
{
return __builtin_ia32_lzcnt_u64 (__X);
}
#endif
#ifdef __DISABLE_LZCNT__
#undef __DISABLE_LZCNT__
#pragma GCC pop_options
#endif /* __DISABLE_LZCNT__ */
#endif /* _LZCNTINTRIN_H_INCLUDED */
@@ -0,0 +1,233 @@
/* Copyright (C) 2004-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
/* Implemented from the mm3dnow.h (of supposedly AMD origin) included with
MSVC 7.1. */
#ifndef _MM3DNOW_H_INCLUDED
#define _MM3DNOW_H_INCLUDED
#include <mmintrin.h>
#include <prfchwintrin.h>
#if defined __x86_64__ && !defined __SSE__ || !defined __3dNOW__
#pragma GCC push_options
#ifdef __x86_64__
#pragma GCC target("sse,3dnow")
#else
#pragma GCC target("3dnow")
#endif
#define __DISABLE_3dNOW__
#endif /* __3dNOW__ */
extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_femms (void)
{
__builtin_ia32_femms();
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pavgusb (__m64 __A, __m64 __B)
{
return (__m64)__builtin_ia32_pavgusb ((__v8qi)__A, (__v8qi)__B);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pf2id (__m64 __A)
{
return (__m64)__builtin_ia32_pf2id ((__v2sf)__A);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pfacc (__m64 __A, __m64 __B)
{
return (__m64)__builtin_ia32_pfacc ((__v2sf)__A, (__v2sf)__B);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pfadd (__m64 __A, __m64 __B)
{
return (__m64)__builtin_ia32_pfadd ((__v2sf)__A, (__v2sf)__B);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pfcmpeq (__m64 __A, __m64 __B)
{
return (__m64)__builtin_ia32_pfcmpeq ((__v2sf)__A, (__v2sf)__B);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pfcmpge (__m64 __A, __m64 __B)
{
return (__m64)__builtin_ia32_pfcmpge ((__v2sf)__A, (__v2sf)__B);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pfcmpgt (__m64 __A, __m64 __B)
{
return (__m64)__builtin_ia32_pfcmpgt ((__v2sf)__A, (__v2sf)__B);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pfmax (__m64 __A, __m64 __B)
{
return (__m64)__builtin_ia32_pfmax ((__v2sf)__A, (__v2sf)__B);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pfmin (__m64 __A, __m64 __B)
{
return (__m64)__builtin_ia32_pfmin ((__v2sf)__A, (__v2sf)__B);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pfmul (__m64 __A, __m64 __B)
{
return (__m64)__builtin_ia32_pfmul ((__v2sf)__A, (__v2sf)__B);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pfrcp (__m64 __A)
{
return (__m64)__builtin_ia32_pfrcp ((__v2sf)__A);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pfrcpit1 (__m64 __A, __m64 __B)
{
return (__m64)__builtin_ia32_pfrcpit1 ((__v2sf)__A, (__v2sf)__B);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pfrcpit2 (__m64 __A, __m64 __B)
{
return (__m64)__builtin_ia32_pfrcpit2 ((__v2sf)__A, (__v2sf)__B);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pfrsqrt (__m64 __A)
{
return (__m64)__builtin_ia32_pfrsqrt ((__v2sf)__A);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pfrsqit1 (__m64 __A, __m64 __B)
{
return (__m64)__builtin_ia32_pfrsqit1 ((__v2sf)__A, (__v2sf)__B);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pfsub (__m64 __A, __m64 __B)
{
return (__m64)__builtin_ia32_pfsub ((__v2sf)__A, (__v2sf)__B);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pfsubr (__m64 __A, __m64 __B)
{
return (__m64)__builtin_ia32_pfsubr ((__v2sf)__A, (__v2sf)__B);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pi2fd (__m64 __A)
{
return (__m64)__builtin_ia32_pi2fd ((__v2si)__A);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pmulhrw (__m64 __A, __m64 __B)
{
return (__m64)__builtin_ia32_pmulhrw ((__v4hi)__A, (__v4hi)__B);
}
extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_prefetch (void *__P)
{
__builtin_prefetch (__P, 0, 3 /* _MM_HINT_T0 */);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_from_float (float __A)
{
return __extension__ (__m64)(__v2sf){ __A, 0.0f };
}
extern __inline float __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_to_float (__m64 __A)
{
union { __v2sf v; float a[2]; } __tmp;
__tmp.v = (__v2sf)__A;
return __tmp.a[0];
}
#ifdef __DISABLE_3dNOW__
#undef __DISABLE_3dNOW__
#pragma GCC pop_options
#endif /* __DISABLE_3dNOW__ */
#if defined __x86_64__ && !defined __SSE__ || !defined __3dNOW_A__
#pragma GCC push_options
#ifdef __x86_64__
#pragma GCC target("sse,3dnowa")
#else
#pragma GCC target("3dnowa")
#endif
#define __DISABLE_3dNOW_A__
#endif /* __3dNOW_A__ */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pf2iw (__m64 __A)
{
return (__m64)__builtin_ia32_pf2iw ((__v2sf)__A);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pfnacc (__m64 __A, __m64 __B)
{
return (__m64)__builtin_ia32_pfnacc ((__v2sf)__A, (__v2sf)__B);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pfpnacc (__m64 __A, __m64 __B)
{
return (__m64)__builtin_ia32_pfpnacc ((__v2sf)__A, (__v2sf)__B);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pi2fw (__m64 __A)
{
return (__m64)__builtin_ia32_pi2fw ((__v2si)__A);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pswapd (__m64 __A)
{
return (__m64)__builtin_ia32_pswapdsf ((__v2sf)__A);
}
#ifdef __DISABLE_3dNOW_A__
#undef __DISABLE_3dNOW_A__
#pragma GCC pop_options
#endif /* __DISABLE_3dNOW_A__ */
#endif /* _MM3DNOW_H_INCLUDED */
@@ -0,0 +1,57 @@
/* Copyright (C) 2004-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _MM_MALLOC_H_INCLUDED
#define _MM_MALLOC_H_INCLUDED
#include <stdlib.h>
/* We can't depend on <stdlib.h> since the prototype of posix_memalign
may not be visible. */
#ifndef __cplusplus
extern int posix_memalign (void **, size_t, size_t);
#else
extern "C" int posix_memalign (void **, size_t, size_t) throw ();
#endif
static __inline void *
_mm_malloc (size_t __size, size_t __alignment)
{
void *__ptr;
if (__alignment == 1)
return malloc (__size);
if (__alignment == 2 || (sizeof (void *) == 8 && __alignment == 4))
__alignment = sizeof (void *);
if (posix_memalign (&__ptr, __alignment, __size) == 0)
return __ptr;
else
return NULL;
}
static __inline void
_mm_free (void *__ptr)
{
free (__ptr);
}
#endif /* _MM_MALLOC_H_INCLUDED */
@@ -0,0 +1,949 @@
/* Copyright (C) 2002-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
/* Implemented from the specification included in the Intel C++ Compiler
User Guide and Reference, version 9.0. */
#ifndef _MMINTRIN_H_INCLUDED
#define _MMINTRIN_H_INCLUDED
#if defined __x86_64__ && !defined __SSE__ || !defined __MMX__
#pragma GCC push_options
#ifdef __x86_64__
#pragma GCC target("sse,mmx")
#else
#pragma GCC target("mmx")
#endif
#define __DISABLE_MMX__
#endif /* __MMX__ */
/* The Intel API is flexible enough that we must allow aliasing with other
vector types, and their scalar components. */
typedef int __m64 __attribute__ ((__vector_size__ (8), __may_alias__));
/* Unaligned version of the same type */
typedef int __m64_u __attribute__ ((__vector_size__ (8), __may_alias__, __aligned__ (1)));
/* Internal data types for implementing the intrinsics. */
typedef int __v2si __attribute__ ((__vector_size__ (8)));
typedef short __v4hi __attribute__ ((__vector_size__ (8)));
typedef char __v8qi __attribute__ ((__vector_size__ (8)));
typedef long long __v1di __attribute__ ((__vector_size__ (8)));
typedef float __v2sf __attribute__ ((__vector_size__ (8)));
/* Empty the multimedia state. */
extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_empty (void)
{
__builtin_ia32_emms ();
}
extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_empty (void)
{
_mm_empty ();
}
/* Convert I to a __m64 object. The integer is zero-extended to 64-bits. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cvtsi32_si64 (int __i)
{
return (__m64) __builtin_ia32_vec_init_v2si (__i, 0);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_from_int (int __i)
{
return _mm_cvtsi32_si64 (__i);
}
#ifdef __x86_64__
/* Convert I to a __m64 object. */
/* Intel intrinsic. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_from_int64 (long long __i)
{
return (__m64) __i;
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cvtsi64_m64 (long long __i)
{
return (__m64) __i;
}
/* Microsoft intrinsic. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cvtsi64x_si64 (long long __i)
{
return (__m64) __i;
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_set_pi64x (long long __i)
{
return (__m64) __i;
}
#endif
/* Convert the lower 32 bits of the __m64 object into an integer. */
extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cvtsi64_si32 (__m64 __i)
{
return __builtin_ia32_vec_ext_v2si ((__v2si)__i, 0);
}
extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_to_int (__m64 __i)
{
return _mm_cvtsi64_si32 (__i);
}
#ifdef __x86_64__
/* Convert the __m64 object to a 64bit integer. */
/* Intel intrinsic. */
extern __inline long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_to_int64 (__m64 __i)
{
return (long long)__i;
}
extern __inline long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cvtm64_si64 (__m64 __i)
{
return (long long)__i;
}
/* Microsoft intrinsic. */
extern __inline long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cvtsi64_si64x (__m64 __i)
{
return (long long)__i;
}
#endif
/* Pack the four 16-bit values from M1 into the lower four 8-bit values of
the result, and the four 16-bit values from M2 into the upper four 8-bit
values of the result, all with signed saturation. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_packs_pi16 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_packsswb ((__v4hi)__m1, (__v4hi)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_packsswb (__m64 __m1, __m64 __m2)
{
return _mm_packs_pi16 (__m1, __m2);
}
/* Pack the two 32-bit values from M1 in to the lower two 16-bit values of
the result, and the two 32-bit values from M2 into the upper two 16-bit
values of the result, all with signed saturation. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_packs_pi32 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_packssdw ((__v2si)__m1, (__v2si)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_packssdw (__m64 __m1, __m64 __m2)
{
return _mm_packs_pi32 (__m1, __m2);
}
/* Pack the four 16-bit values from M1 into the lower four 8-bit values of
the result, and the four 16-bit values from M2 into the upper four 8-bit
values of the result, all with unsigned saturation. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_packs_pu16 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_packuswb ((__v4hi)__m1, (__v4hi)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_packuswb (__m64 __m1, __m64 __m2)
{
return _mm_packs_pu16 (__m1, __m2);
}
/* Interleave the four 8-bit values from the high half of M1 with the four
8-bit values from the high half of M2. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_unpackhi_pi8 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_punpckhbw ((__v8qi)__m1, (__v8qi)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_punpckhbw (__m64 __m1, __m64 __m2)
{
return _mm_unpackhi_pi8 (__m1, __m2);
}
/* Interleave the two 16-bit values from the high half of M1 with the two
16-bit values from the high half of M2. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_unpackhi_pi16 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_punpckhwd ((__v4hi)__m1, (__v4hi)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_punpckhwd (__m64 __m1, __m64 __m2)
{
return _mm_unpackhi_pi16 (__m1, __m2);
}
/* Interleave the 32-bit value from the high half of M1 with the 32-bit
value from the high half of M2. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_unpackhi_pi32 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_punpckhdq ((__v2si)__m1, (__v2si)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_punpckhdq (__m64 __m1, __m64 __m2)
{
return _mm_unpackhi_pi32 (__m1, __m2);
}
/* Interleave the four 8-bit values from the low half of M1 with the four
8-bit values from the low half of M2. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_unpacklo_pi8 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_punpcklbw ((__v8qi)__m1, (__v8qi)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_punpcklbw (__m64 __m1, __m64 __m2)
{
return _mm_unpacklo_pi8 (__m1, __m2);
}
/* Interleave the two 16-bit values from the low half of M1 with the two
16-bit values from the low half of M2. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_unpacklo_pi16 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_punpcklwd ((__v4hi)__m1, (__v4hi)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_punpcklwd (__m64 __m1, __m64 __m2)
{
return _mm_unpacklo_pi16 (__m1, __m2);
}
/* Interleave the 32-bit value from the low half of M1 with the 32-bit
value from the low half of M2. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_unpacklo_pi32 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_punpckldq ((__v2si)__m1, (__v2si)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_punpckldq (__m64 __m1, __m64 __m2)
{
return _mm_unpacklo_pi32 (__m1, __m2);
}
/* Add the 8-bit values in M1 to the 8-bit values in M2. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_add_pi8 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_paddb ((__v8qi)__m1, (__v8qi)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_paddb (__m64 __m1, __m64 __m2)
{
return _mm_add_pi8 (__m1, __m2);
}
/* Add the 16-bit values in M1 to the 16-bit values in M2. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_add_pi16 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_paddw ((__v4hi)__m1, (__v4hi)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_paddw (__m64 __m1, __m64 __m2)
{
return _mm_add_pi16 (__m1, __m2);
}
/* Add the 32-bit values in M1 to the 32-bit values in M2. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_add_pi32 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_paddd ((__v2si)__m1, (__v2si)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_paddd (__m64 __m1, __m64 __m2)
{
return _mm_add_pi32 (__m1, __m2);
}
/* Add the 64-bit values in M1 to the 64-bit values in M2. */
#ifndef __SSE2__
#pragma GCC push_options
#pragma GCC target("sse2,mmx")
#define __DISABLE_SSE2__
#endif /* __SSE2__ */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_add_si64 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_paddq ((__v1di)__m1, (__v1di)__m2);
}
#ifdef __DISABLE_SSE2__
#undef __DISABLE_SSE2__
#pragma GCC pop_options
#endif /* __DISABLE_SSE2__ */
/* Add the 8-bit values in M1 to the 8-bit values in M2 using signed
saturated arithmetic. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_adds_pi8 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_paddsb ((__v8qi)__m1, (__v8qi)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_paddsb (__m64 __m1, __m64 __m2)
{
return _mm_adds_pi8 (__m1, __m2);
}
/* Add the 16-bit values in M1 to the 16-bit values in M2 using signed
saturated arithmetic. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_adds_pi16 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_paddsw ((__v4hi)__m1, (__v4hi)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_paddsw (__m64 __m1, __m64 __m2)
{
return _mm_adds_pi16 (__m1, __m2);
}
/* Add the 8-bit values in M1 to the 8-bit values in M2 using unsigned
saturated arithmetic. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_adds_pu8 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_paddusb ((__v8qi)__m1, (__v8qi)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_paddusb (__m64 __m1, __m64 __m2)
{
return _mm_adds_pu8 (__m1, __m2);
}
/* Add the 16-bit values in M1 to the 16-bit values in M2 using unsigned
saturated arithmetic. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_adds_pu16 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_paddusw ((__v4hi)__m1, (__v4hi)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_paddusw (__m64 __m1, __m64 __m2)
{
return _mm_adds_pu16 (__m1, __m2);
}
/* Subtract the 8-bit values in M2 from the 8-bit values in M1. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_sub_pi8 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_psubb ((__v8qi)__m1, (__v8qi)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_psubb (__m64 __m1, __m64 __m2)
{
return _mm_sub_pi8 (__m1, __m2);
}
/* Subtract the 16-bit values in M2 from the 16-bit values in M1. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_sub_pi16 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_psubw ((__v4hi)__m1, (__v4hi)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_psubw (__m64 __m1, __m64 __m2)
{
return _mm_sub_pi16 (__m1, __m2);
}
/* Subtract the 32-bit values in M2 from the 32-bit values in M1. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_sub_pi32 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_psubd ((__v2si)__m1, (__v2si)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_psubd (__m64 __m1, __m64 __m2)
{
return _mm_sub_pi32 (__m1, __m2);
}
/* Add the 64-bit values in M1 to the 64-bit values in M2. */
#ifndef __SSE2__
#pragma GCC push_options
#pragma GCC target("sse2,mmx")
#define __DISABLE_SSE2__
#endif /* __SSE2__ */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_sub_si64 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_psubq ((__v1di)__m1, (__v1di)__m2);
}
#ifdef __DISABLE_SSE2__
#undef __DISABLE_SSE2__
#pragma GCC pop_options
#endif /* __DISABLE_SSE2__ */
/* Subtract the 8-bit values in M2 from the 8-bit values in M1 using signed
saturating arithmetic. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_subs_pi8 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_psubsb ((__v8qi)__m1, (__v8qi)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_psubsb (__m64 __m1, __m64 __m2)
{
return _mm_subs_pi8 (__m1, __m2);
}
/* Subtract the 16-bit values in M2 from the 16-bit values in M1 using
signed saturating arithmetic. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_subs_pi16 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_psubsw ((__v4hi)__m1, (__v4hi)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_psubsw (__m64 __m1, __m64 __m2)
{
return _mm_subs_pi16 (__m1, __m2);
}
/* Subtract the 8-bit values in M2 from the 8-bit values in M1 using
unsigned saturating arithmetic. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_subs_pu8 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_psubusb ((__v8qi)__m1, (__v8qi)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_psubusb (__m64 __m1, __m64 __m2)
{
return _mm_subs_pu8 (__m1, __m2);
}
/* Subtract the 16-bit values in M2 from the 16-bit values in M1 using
unsigned saturating arithmetic. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_subs_pu16 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_psubusw ((__v4hi)__m1, (__v4hi)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_psubusw (__m64 __m1, __m64 __m2)
{
return _mm_subs_pu16 (__m1, __m2);
}
/* Multiply four 16-bit values in M1 by four 16-bit values in M2 producing
four 32-bit intermediate results, which are then summed by pairs to
produce two 32-bit results. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_madd_pi16 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_pmaddwd ((__v4hi)__m1, (__v4hi)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pmaddwd (__m64 __m1, __m64 __m2)
{
return _mm_madd_pi16 (__m1, __m2);
}
/* Multiply four signed 16-bit values in M1 by four signed 16-bit values in
M2 and produce the high 16 bits of the 32-bit results. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_mulhi_pi16 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_pmulhw ((__v4hi)__m1, (__v4hi)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pmulhw (__m64 __m1, __m64 __m2)
{
return _mm_mulhi_pi16 (__m1, __m2);
}
/* Multiply four 16-bit values in M1 by four 16-bit values in M2 and produce
the low 16 bits of the results. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_mullo_pi16 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_pmullw ((__v4hi)__m1, (__v4hi)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pmullw (__m64 __m1, __m64 __m2)
{
return _mm_mullo_pi16 (__m1, __m2);
}
/* Shift four 16-bit values in M left by COUNT. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_sll_pi16 (__m64 __m, __m64 __count)
{
return (__m64) __builtin_ia32_psllw ((__v4hi)__m, (__v4hi)__count);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_psllw (__m64 __m, __m64 __count)
{
return _mm_sll_pi16 (__m, __count);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_slli_pi16 (__m64 __m, int __count)
{
return (__m64) __builtin_ia32_psllwi ((__v4hi)__m, __count);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_psllwi (__m64 __m, int __count)
{
return _mm_slli_pi16 (__m, __count);
}
/* Shift two 32-bit values in M left by COUNT. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_sll_pi32 (__m64 __m, __m64 __count)
{
return (__m64) __builtin_ia32_pslld ((__v2si)__m, (__v2si)__count);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pslld (__m64 __m, __m64 __count)
{
return _mm_sll_pi32 (__m, __count);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_slli_pi32 (__m64 __m, int __count)
{
return (__m64) __builtin_ia32_pslldi ((__v2si)__m, __count);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pslldi (__m64 __m, int __count)
{
return _mm_slli_pi32 (__m, __count);
}
/* Shift the 64-bit value in M left by COUNT. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_sll_si64 (__m64 __m, __m64 __count)
{
return (__m64) __builtin_ia32_psllq ((__v1di)__m, (__v1di)__count);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_psllq (__m64 __m, __m64 __count)
{
return _mm_sll_si64 (__m, __count);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_slli_si64 (__m64 __m, int __count)
{
return (__m64) __builtin_ia32_psllqi ((__v1di)__m, __count);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_psllqi (__m64 __m, int __count)
{
return _mm_slli_si64 (__m, __count);
}
/* Shift four 16-bit values in M right by COUNT; shift in the sign bit. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_sra_pi16 (__m64 __m, __m64 __count)
{
return (__m64) __builtin_ia32_psraw ((__v4hi)__m, (__v4hi)__count);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_psraw (__m64 __m, __m64 __count)
{
return _mm_sra_pi16 (__m, __count);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_srai_pi16 (__m64 __m, int __count)
{
return (__m64) __builtin_ia32_psrawi ((__v4hi)__m, __count);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_psrawi (__m64 __m, int __count)
{
return _mm_srai_pi16 (__m, __count);
}
/* Shift two 32-bit values in M right by COUNT; shift in the sign bit. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_sra_pi32 (__m64 __m, __m64 __count)
{
return (__m64) __builtin_ia32_psrad ((__v2si)__m, (__v2si)__count);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_psrad (__m64 __m, __m64 __count)
{
return _mm_sra_pi32 (__m, __count);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_srai_pi32 (__m64 __m, int __count)
{
return (__m64) __builtin_ia32_psradi ((__v2si)__m, __count);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_psradi (__m64 __m, int __count)
{
return _mm_srai_pi32 (__m, __count);
}
/* Shift four 16-bit values in M right by COUNT; shift in zeros. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_srl_pi16 (__m64 __m, __m64 __count)
{
return (__m64) __builtin_ia32_psrlw ((__v4hi)__m, (__v4hi)__count);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_psrlw (__m64 __m, __m64 __count)
{
return _mm_srl_pi16 (__m, __count);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_srli_pi16 (__m64 __m, int __count)
{
return (__m64) __builtin_ia32_psrlwi ((__v4hi)__m, __count);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_psrlwi (__m64 __m, int __count)
{
return _mm_srli_pi16 (__m, __count);
}
/* Shift two 32-bit values in M right by COUNT; shift in zeros. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_srl_pi32 (__m64 __m, __m64 __count)
{
return (__m64) __builtin_ia32_psrld ((__v2si)__m, (__v2si)__count);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_psrld (__m64 __m, __m64 __count)
{
return _mm_srl_pi32 (__m, __count);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_srli_pi32 (__m64 __m, int __count)
{
return (__m64) __builtin_ia32_psrldi ((__v2si)__m, __count);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_psrldi (__m64 __m, int __count)
{
return _mm_srli_pi32 (__m, __count);
}
/* Shift the 64-bit value in M left by COUNT; shift in zeros. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_srl_si64 (__m64 __m, __m64 __count)
{
return (__m64) __builtin_ia32_psrlq ((__v1di)__m, (__v1di)__count);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_psrlq (__m64 __m, __m64 __count)
{
return _mm_srl_si64 (__m, __count);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_srli_si64 (__m64 __m, int __count)
{
return (__m64) __builtin_ia32_psrlqi ((__v1di)__m, __count);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_psrlqi (__m64 __m, int __count)
{
return _mm_srli_si64 (__m, __count);
}
/* Bit-wise AND the 64-bit values in M1 and M2. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_and_si64 (__m64 __m1, __m64 __m2)
{
return __builtin_ia32_pand (__m1, __m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pand (__m64 __m1, __m64 __m2)
{
return _mm_and_si64 (__m1, __m2);
}
/* Bit-wise complement the 64-bit value in M1 and bit-wise AND it with the
64-bit value in M2. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_andnot_si64 (__m64 __m1, __m64 __m2)
{
return __builtin_ia32_pandn (__m1, __m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pandn (__m64 __m1, __m64 __m2)
{
return _mm_andnot_si64 (__m1, __m2);
}
/* Bit-wise inclusive OR the 64-bit values in M1 and M2. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_or_si64 (__m64 __m1, __m64 __m2)
{
return __builtin_ia32_por (__m1, __m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_por (__m64 __m1, __m64 __m2)
{
return _mm_or_si64 (__m1, __m2);
}
/* Bit-wise exclusive OR the 64-bit values in M1 and M2. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_xor_si64 (__m64 __m1, __m64 __m2)
{
return __builtin_ia32_pxor (__m1, __m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pxor (__m64 __m1, __m64 __m2)
{
return _mm_xor_si64 (__m1, __m2);
}
/* Compare eight 8-bit values. The result of the comparison is 0xFF if the
test is true and zero if false. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cmpeq_pi8 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_pcmpeqb ((__v8qi)__m1, (__v8qi)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pcmpeqb (__m64 __m1, __m64 __m2)
{
return _mm_cmpeq_pi8 (__m1, __m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cmpgt_pi8 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_pcmpgtb ((__v8qi)__m1, (__v8qi)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pcmpgtb (__m64 __m1, __m64 __m2)
{
return _mm_cmpgt_pi8 (__m1, __m2);
}
/* Compare four 16-bit values. The result of the comparison is 0xFFFF if
the test is true and zero if false. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cmpeq_pi16 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_pcmpeqw ((__v4hi)__m1, (__v4hi)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pcmpeqw (__m64 __m1, __m64 __m2)
{
return _mm_cmpeq_pi16 (__m1, __m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cmpgt_pi16 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_pcmpgtw ((__v4hi)__m1, (__v4hi)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pcmpgtw (__m64 __m1, __m64 __m2)
{
return _mm_cmpgt_pi16 (__m1, __m2);
}
/* Compare two 32-bit values. The result of the comparison is 0xFFFFFFFF if
the test is true and zero if false. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cmpeq_pi32 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_pcmpeqd ((__v2si)__m1, (__v2si)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pcmpeqd (__m64 __m1, __m64 __m2)
{
return _mm_cmpeq_pi32 (__m1, __m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cmpgt_pi32 (__m64 __m1, __m64 __m2)
{
return (__m64) __builtin_ia32_pcmpgtd ((__v2si)__m1, (__v2si)__m2);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_pcmpgtd (__m64 __m1, __m64 __m2)
{
return _mm_cmpgt_pi32 (__m1, __m2);
}
/* Creates a 64-bit zero. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_setzero_si64 (void)
{
return (__m64)0LL;
}
/* Creates a vector of two 32-bit values; I0 is least significant. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_set_pi32 (int __i1, int __i0)
{
return (__m64) __builtin_ia32_vec_init_v2si (__i0, __i1);
}
/* Creates a vector of four 16-bit values; W0 is least significant. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_set_pi16 (short __w3, short __w2, short __w1, short __w0)
{
return (__m64) __builtin_ia32_vec_init_v4hi (__w0, __w1, __w2, __w3);
}
/* Creates a vector of eight 8-bit values; B0 is least significant. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_set_pi8 (char __b7, char __b6, char __b5, char __b4,
char __b3, char __b2, char __b1, char __b0)
{
return (__m64) __builtin_ia32_vec_init_v8qi (__b0, __b1, __b2, __b3,
__b4, __b5, __b6, __b7);
}
/* Similar, but with the arguments in reverse order. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_setr_pi32 (int __i0, int __i1)
{
return _mm_set_pi32 (__i1, __i0);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_setr_pi16 (short __w0, short __w1, short __w2, short __w3)
{
return _mm_set_pi16 (__w3, __w2, __w1, __w0);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_setr_pi8 (char __b0, char __b1, char __b2, char __b3,
char __b4, char __b5, char __b6, char __b7)
{
return _mm_set_pi8 (__b7, __b6, __b5, __b4, __b3, __b2, __b1, __b0);
}
/* Creates a vector of two 32-bit values, both elements containing I. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_set1_pi32 (int __i)
{
return _mm_set_pi32 (__i, __i);
}
/* Creates a vector of four 16-bit values, all elements containing W. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_set1_pi16 (short __w)
{
return _mm_set_pi16 (__w, __w, __w, __w);
}
/* Creates a vector of eight 8-bit values, all elements containing B. */
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_set1_pi8 (char __b)
{
return _mm_set_pi8 (__b, __b, __b, __b, __b, __b, __b, __b);
}
#ifdef __DISABLE_MMX__
#undef __DISABLE_MMX__
#pragma GCC pop_options
#endif /* __DISABLE_MMX__ */
#endif /* _MMINTRIN_H_INCLUDED */
@@ -0,0 +1,50 @@
/* Copyright (C) 2012-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _MWAITXINTRIN_H_INCLUDED
#define _MWAITXINTRIN_H_INCLUDED
#ifndef __MWAITX__
#pragma GCC push_options
#pragma GCC target("mwaitx")
#define __DISABLE_MWAITX__
#endif /* __MWAITX__ */
extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_monitorx (void const * __P, unsigned int __E, unsigned int __H)
{
__builtin_ia32_monitorx (__P, __E, __H);
}
extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_mwaitx (unsigned int __E, unsigned int __H, unsigned int __C)
{
__builtin_ia32_mwaitx (__E, __H, __C);
}
#ifdef __DISABLE_MWAITX__
#undef __DISABLE_MWAITX__
#pragma GCC pop_options
#endif /* __DISABLE_MWAITX__ */
#endif /* _MWAITXINTRIN_H_INCLUDED */
@@ -0,0 +1,33 @@
/* Copyright (C) 2007-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
/* Implemented from the specification included in the Intel C++ Compiler
User Guide and Reference, version 10.0. */
#ifndef _NMMINTRIN_H_INCLUDED
#define _NMMINTRIN_H_INCLUDED
/* We just include SSE4.1 header file. */
#include <smmintrin.h>
#endif /* _NMMINTRIN_H_INCLUDED */
@@ -0,0 +1,165 @@
/* Copyright (C) 2005-2017 Free Software Foundation, Inc.
Contributed by Richard Henderson <rth@redhat.com>.
This file is part of the GNU Offloading and Multi Processing Library
(libgomp).
Libgomp is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _OMP_H
#define _OMP_H 1
#ifndef _LIBGOMP_OMP_LOCK_DEFINED
#define _LIBGOMP_OMP_LOCK_DEFINED 1
/* These two structures get edited by the libgomp build process to
reflect the shape of the two types. Their internals are private
to the library. */
typedef struct
{
unsigned char _x[4]
__attribute__((__aligned__(4)));
} omp_lock_t;
typedef struct
{
unsigned char _x[8 + sizeof (void *)]
__attribute__((__aligned__(sizeof (void *))));
} omp_nest_lock_t;
#endif
typedef enum omp_sched_t
{
omp_sched_static = 1,
omp_sched_dynamic = 2,
omp_sched_guided = 3,
omp_sched_auto = 4
} omp_sched_t;
typedef enum omp_proc_bind_t
{
omp_proc_bind_false = 0,
omp_proc_bind_true = 1,
omp_proc_bind_master = 2,
omp_proc_bind_close = 3,
omp_proc_bind_spread = 4
} omp_proc_bind_t;
typedef enum omp_lock_hint_t
{
omp_lock_hint_none = 0,
omp_lock_hint_uncontended = 1,
omp_lock_hint_contended = 2,
omp_lock_hint_nonspeculative = 4,
omp_lock_hint_speculative = 8,
} omp_lock_hint_t;
#ifdef __cplusplus
extern "C" {
# define __GOMP_NOTHROW throw ()
#else
# define __GOMP_NOTHROW __attribute__((__nothrow__))
#endif
extern void omp_set_num_threads (int) __GOMP_NOTHROW;
extern int omp_get_num_threads (void) __GOMP_NOTHROW;
extern int omp_get_max_threads (void) __GOMP_NOTHROW;
extern int omp_get_thread_num (void) __GOMP_NOTHROW;
extern int omp_get_num_procs (void) __GOMP_NOTHROW;
extern int omp_in_parallel (void) __GOMP_NOTHROW;
extern void omp_set_dynamic (int) __GOMP_NOTHROW;
extern int omp_get_dynamic (void) __GOMP_NOTHROW;
extern void omp_set_nested (int) __GOMP_NOTHROW;
extern int omp_get_nested (void) __GOMP_NOTHROW;
extern void omp_init_lock (omp_lock_t *) __GOMP_NOTHROW;
extern void omp_init_lock_with_hint (omp_lock_t *, omp_lock_hint_t)
__GOMP_NOTHROW;
extern void omp_destroy_lock (omp_lock_t *) __GOMP_NOTHROW;
extern void omp_set_lock (omp_lock_t *) __GOMP_NOTHROW;
extern void omp_unset_lock (omp_lock_t *) __GOMP_NOTHROW;
extern int omp_test_lock (omp_lock_t *) __GOMP_NOTHROW;
extern void omp_init_nest_lock (omp_nest_lock_t *) __GOMP_NOTHROW;
extern void omp_init_nest_lock_with_hint (omp_nest_lock_t *, omp_lock_hint_t)
__GOMP_NOTHROW;
extern void omp_destroy_nest_lock (omp_nest_lock_t *) __GOMP_NOTHROW;
extern void omp_set_nest_lock (omp_nest_lock_t *) __GOMP_NOTHROW;
extern void omp_unset_nest_lock (omp_nest_lock_t *) __GOMP_NOTHROW;
extern int omp_test_nest_lock (omp_nest_lock_t *) __GOMP_NOTHROW;
extern double omp_get_wtime (void) __GOMP_NOTHROW;
extern double omp_get_wtick (void) __GOMP_NOTHROW;
extern void omp_set_schedule (omp_sched_t, int) __GOMP_NOTHROW;
extern void omp_get_schedule (omp_sched_t *, int *) __GOMP_NOTHROW;
extern int omp_get_thread_limit (void) __GOMP_NOTHROW;
extern void omp_set_max_active_levels (int) __GOMP_NOTHROW;
extern int omp_get_max_active_levels (void) __GOMP_NOTHROW;
extern int omp_get_level (void) __GOMP_NOTHROW;
extern int omp_get_ancestor_thread_num (int) __GOMP_NOTHROW;
extern int omp_get_team_size (int) __GOMP_NOTHROW;
extern int omp_get_active_level (void) __GOMP_NOTHROW;
extern int omp_in_final (void) __GOMP_NOTHROW;
extern int omp_get_cancellation (void) __GOMP_NOTHROW;
extern omp_proc_bind_t omp_get_proc_bind (void) __GOMP_NOTHROW;
extern int omp_get_num_places (void) __GOMP_NOTHROW;
extern int omp_get_place_num_procs (int) __GOMP_NOTHROW;
extern void omp_get_place_proc_ids (int, int *) __GOMP_NOTHROW;
extern int omp_get_place_num (void) __GOMP_NOTHROW;
extern int omp_get_partition_num_places (void) __GOMP_NOTHROW;
extern void omp_get_partition_place_nums (int *) __GOMP_NOTHROW;
extern void omp_set_default_device (int) __GOMP_NOTHROW;
extern int omp_get_default_device (void) __GOMP_NOTHROW;
extern int omp_get_num_devices (void) __GOMP_NOTHROW;
extern int omp_get_num_teams (void) __GOMP_NOTHROW;
extern int omp_get_team_num (void) __GOMP_NOTHROW;
extern int omp_is_initial_device (void) __GOMP_NOTHROW;
extern int omp_get_initial_device (void) __GOMP_NOTHROW;
extern int omp_get_max_task_priority (void) __GOMP_NOTHROW;
extern void *omp_target_alloc (__SIZE_TYPE__, int) __GOMP_NOTHROW;
extern void omp_target_free (void *, int) __GOMP_NOTHROW;
extern int omp_target_is_present (void *, int) __GOMP_NOTHROW;
extern int omp_target_memcpy (void *, void *, __SIZE_TYPE__, __SIZE_TYPE__,
__SIZE_TYPE__, int, int) __GOMP_NOTHROW;
extern int omp_target_memcpy_rect (void *, void *, __SIZE_TYPE__, int,
const __SIZE_TYPE__ *,
const __SIZE_TYPE__ *,
const __SIZE_TYPE__ *,
const __SIZE_TYPE__ *,
const __SIZE_TYPE__ *, int, int)
__GOMP_NOTHROW;
extern int omp_target_associate_ptr (void *, void *, __SIZE_TYPE__,
__SIZE_TYPE__, int) __GOMP_NOTHROW;
extern int omp_target_disassociate_ptr (void *, int) __GOMP_NOTHROW;
#ifdef __cplusplus
}
#endif
#endif /* _OMP_H */
@@ -0,0 +1,131 @@
/* OpenACC Runtime Library User-facing Declarations
Copyright (C) 2013-2017 Free Software Foundation, Inc.
Contributed by Mentor Embedded.
This file is part of the GNU Offloading and Multi Processing Library
(libgomp).
Libgomp is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _OPENACC_H
#define _OPENACC_H 1
/* The OpenACC standard is silent on whether or not including <openacc.h>
might or must not include other header files. We chose to include
some. */
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
#if __cplusplus >= 201103
# define __GOACC_NOTHROW noexcept
#elif __cplusplus
# define __GOACC_NOTHROW throw ()
#else /* Not C++ */
# define __GOACC_NOTHROW __attribute__ ((__nothrow__))
#endif
/* Types */
typedef enum acc_device_t {
/* Keep in sync with include/gomp-constants.h. */
acc_device_none = 0,
acc_device_default = 1,
acc_device_host = 2,
/* acc_device_host_nonshm = 3 removed. */
acc_device_not_host = 4,
acc_device_nvidia = 5,
_ACC_device_hwm,
/* Ensure enumeration is layout compatible with int. */
_ACC_highest = __INT_MAX__,
_ACC_neg = -1
} acc_device_t;
typedef enum acc_async_t {
/* Keep in sync with include/gomp-constants.h. */
acc_async_noval = -1,
acc_async_sync = -2
} acc_async_t;
int acc_get_num_devices (acc_device_t) __GOACC_NOTHROW;
void acc_set_device_type (acc_device_t) __GOACC_NOTHROW;
acc_device_t acc_get_device_type (void) __GOACC_NOTHROW;
void acc_set_device_num (int, acc_device_t) __GOACC_NOTHROW;
int acc_get_device_num (acc_device_t) __GOACC_NOTHROW;
int acc_async_test (int) __GOACC_NOTHROW;
int acc_async_test_all (void) __GOACC_NOTHROW;
void acc_wait (int) __GOACC_NOTHROW;
void acc_wait_async (int, int) __GOACC_NOTHROW;
void acc_wait_all (void) __GOACC_NOTHROW;
void acc_wait_all_async (int) __GOACC_NOTHROW;
void acc_init (acc_device_t) __GOACC_NOTHROW;
void acc_shutdown (acc_device_t) __GOACC_NOTHROW;
#ifdef __cplusplus
int acc_on_device (int __arg) __GOACC_NOTHROW;
#else
int acc_on_device (acc_device_t __arg) __GOACC_NOTHROW;
#endif
void *acc_malloc (size_t) __GOACC_NOTHROW;
void acc_free (void *) __GOACC_NOTHROW;
/* Some of these would be more correct with const qualifiers, but
the standard specifies otherwise. */
void *acc_copyin (void *, size_t) __GOACC_NOTHROW;
void *acc_present_or_copyin (void *, size_t) __GOACC_NOTHROW;
void *acc_create (void *, size_t) __GOACC_NOTHROW;
void *acc_present_or_create (void *, size_t) __GOACC_NOTHROW;
void acc_copyout (void *, size_t) __GOACC_NOTHROW;
void acc_delete (void *, size_t) __GOACC_NOTHROW;
void acc_update_device (void *, size_t) __GOACC_NOTHROW;
void acc_update_self (void *, size_t) __GOACC_NOTHROW;
void acc_map_data (void *, void *, size_t) __GOACC_NOTHROW;
void acc_unmap_data (void *) __GOACC_NOTHROW;
void *acc_deviceptr (void *) __GOACC_NOTHROW;
void *acc_hostptr (void *) __GOACC_NOTHROW;
int acc_is_present (void *, size_t) __GOACC_NOTHROW;
void acc_memcpy_to_device (void *, void *, size_t) __GOACC_NOTHROW;
void acc_memcpy_from_device (void *, void *, size_t) __GOACC_NOTHROW;
/* Old names. OpenACC does not specify whether these can or must
not be macros, inlines or aliases for the new names. */
#define acc_pcreate acc_present_or_create
#define acc_pcopyin acc_present_or_copyin
/* CUDA-specific routines. */
void *acc_get_current_cuda_device (void) __GOACC_NOTHROW;
void *acc_get_current_cuda_context (void) __GOACC_NOTHROW;
void *acc_get_cuda_stream (int) __GOACC_NOTHROW;
int acc_set_cuda_stream (int, void *) __GOACC_NOTHROW;
#ifdef __cplusplus
}
/* Forwarding function with correctly typed arg. */
#pragma acc routine seq
inline int acc_on_device (acc_device_t __arg) __GOACC_NOTHROW
{
return acc_on_device ((int) __arg);
}
#endif
#endif /* _OPENACC_H */
@@ -0,0 +1,56 @@
/* Copyright (C) 2015-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#if !defined _X86INTRIN_H_INCLUDED
# error "Never use <pkuintrin.h> directly; include <x86intrin.h> instead."
#endif
#ifndef _PKUINTRIN_H_INCLUDED
#define _PKUINTRIN_H_INCLUDED
#ifndef __PKU__
#pragma GCC push_options
#pragma GCC target("pku")
#define __DISABLE_PKU__
#endif /* __PKU__ */
extern __inline unsigned int
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_rdpkru_u32 (void)
{
return __builtin_ia32_rdpkru ();
}
extern __inline void
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_wrpkru (unsigned int __key)
{
__builtin_ia32_wrpkru (__key);
}
#ifdef __DISABLE_PKU__
#undef __DISABLE_PKU__
#pragma GCC pop_options
#endif /* __DISABLE_PKU__ */
#endif /* _PKUINTRIN_H_INCLUDED */
@@ -0,0 +1,132 @@
/* Copyright (C) 2003-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
/* Implemented from the specification included in the Intel C++ Compiler
User Guide and Reference, version 9.0. */
#ifndef _PMMINTRIN_H_INCLUDED
#define _PMMINTRIN_H_INCLUDED
/* We need definitions from the SSE2 and SSE header files*/
#include <emmintrin.h>
#ifndef __SSE3__
#pragma GCC push_options
#pragma GCC target("sse3")
#define __DISABLE_SSE3__
#endif /* __SSE3__ */
/* Additional bits in the MXCSR. */
#define _MM_DENORMALS_ZERO_MASK 0x0040
#define _MM_DENORMALS_ZERO_ON 0x0040
#define _MM_DENORMALS_ZERO_OFF 0x0000
#define _MM_SET_DENORMALS_ZERO_MODE(mode) \
_mm_setcsr ((_mm_getcsr () & ~_MM_DENORMALS_ZERO_MASK) | (mode))
#define _MM_GET_DENORMALS_ZERO_MODE() \
(_mm_getcsr() & _MM_DENORMALS_ZERO_MASK)
extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_addsub_ps (__m128 __X, __m128 __Y)
{
return (__m128) __builtin_ia32_addsubps ((__v4sf)__X, (__v4sf)__Y);
}
extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_hadd_ps (__m128 __X, __m128 __Y)
{
return (__m128) __builtin_ia32_haddps ((__v4sf)__X, (__v4sf)__Y);
}
extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_hsub_ps (__m128 __X, __m128 __Y)
{
return (__m128) __builtin_ia32_hsubps ((__v4sf)__X, (__v4sf)__Y);
}
extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_movehdup_ps (__m128 __X)
{
return (__m128) __builtin_ia32_movshdup ((__v4sf)__X);
}
extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_moveldup_ps (__m128 __X)
{
return (__m128) __builtin_ia32_movsldup ((__v4sf)__X);
}
extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_addsub_pd (__m128d __X, __m128d __Y)
{
return (__m128d) __builtin_ia32_addsubpd ((__v2df)__X, (__v2df)__Y);
}
extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_hadd_pd (__m128d __X, __m128d __Y)
{
return (__m128d) __builtin_ia32_haddpd ((__v2df)__X, (__v2df)__Y);
}
extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_hsub_pd (__m128d __X, __m128d __Y)
{
return (__m128d) __builtin_ia32_hsubpd ((__v2df)__X, (__v2df)__Y);
}
extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_loaddup_pd (double const *__P)
{
return _mm_load1_pd (__P);
}
extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_movedup_pd (__m128d __X)
{
return _mm_shuffle_pd (__X, __X, _MM_SHUFFLE2 (0,0));
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_lddqu_si128 (__m128i const *__P)
{
return (__m128i) __builtin_ia32_lddqu ((char const *)__P);
}
extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_monitor (void const * __P, unsigned int __E, unsigned int __H)
{
__builtin_ia32_monitor (__P, __E, __H);
}
extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_mwait (unsigned int __E, unsigned int __H)
{
__builtin_ia32_mwait (__E, __H);
}
#ifdef __DISABLE_SSE3__
#undef __DISABLE_SSE3__
#pragma GCC pop_options
#endif /* __DISABLE_SSE3__ */
#endif /* _PMMINTRIN_H_INCLUDED */
@@ -0,0 +1,53 @@
/* Copyright (C) 2009-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _POPCNTINTRIN_H_INCLUDED
#define _POPCNTINTRIN_H_INCLUDED
#ifndef __POPCNT__
#pragma GCC push_options
#pragma GCC target("popcnt")
#define __DISABLE_POPCNT__
#endif /* __POPCNT__ */
/* Calculate a number of bits set to 1. */
extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_popcnt_u32 (unsigned int __X)
{
return __builtin_popcount (__X);
}
#ifdef __x86_64__
extern __inline long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_popcnt_u64 (unsigned long long __X)
{
return __builtin_popcountll (__X);
}
#endif
#ifdef __DISABLE_POPCNT__
#undef __DISABLE_POPCNT__
#pragma GCC pop_options
#endif /* __DISABLE_POPCNT__ */
#endif /* _POPCNTINTRIN_H_INCLUDED */
@@ -0,0 +1,37 @@
/* Copyright (C) 2012-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#if !defined _X86INTRIN_H_INCLUDED && !defined _MM3DNOW_H_INCLUDED
# error "Never use <prfchwintrin.h> directly; include <x86intrin.h> or <mm3dnow.h> instead."
#endif
#ifndef _PRFCHWINTRIN_H_INCLUDED
#define _PRFCHWINTRIN_H_INCLUDED
extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_m_prefetchw (void *__P)
{
__builtin_prefetch (__P, 1, 3 /* _MM_HINT_T0 */);
}
#endif /* _PRFCHWINTRIN_H_INCLUDED */
@@ -0,0 +1,66 @@
/* Copyright (C) 2012-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#if !defined _X86INTRIN_H_INCLUDED
# error "Never use <rdseedintrin.h> directly; include <x86intrin.h> instead."
#endif
#ifndef _RDSEEDINTRIN_H_INCLUDED
#define _RDSEEDINTRIN_H_INCLUDED
#ifndef __RDSEED__
#pragma GCC push_options
#pragma GCC target("rdseed")
#define __DISABLE_RDSEED__
#endif /* __RDSEED__ */
extern __inline int
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_rdseed16_step (unsigned short *__p)
{
return __builtin_ia32_rdseed_hi_step (__p);
}
extern __inline int
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_rdseed32_step (unsigned int *__p)
{
return __builtin_ia32_rdseed_si_step (__p);
}
#ifdef __x86_64__
extern __inline int
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_rdseed64_step (unsigned long long *__p)
{
return __builtin_ia32_rdseed_di_step (__p);
}
#endif
#ifdef __DISABLE_RDSEED__
#undef __DISABLE_RDSEED__
#pragma GCC pop_options
#endif /* __DISABLE_RDSEED__ */
#endif /* _RDSEEDINTRIN_H_INCLUDED */
@@ -0,0 +1,84 @@
/* Copyright (C) 2012-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _IMMINTRIN_H_INCLUDED
# error "Never use <rtmintrin.h> directly; include <immintrin.h> instead."
#endif
#ifndef _RTMINTRIN_H_INCLUDED
#define _RTMINTRIN_H_INCLUDED
#ifndef __RTM__
#pragma GCC push_options
#pragma GCC target("rtm")
#define __DISABLE_RTM__
#endif /* __RTM__ */
#define _XBEGIN_STARTED (~0u)
#define _XABORT_EXPLICIT (1 << 0)
#define _XABORT_RETRY (1 << 1)
#define _XABORT_CONFLICT (1 << 2)
#define _XABORT_CAPACITY (1 << 3)
#define _XABORT_DEBUG (1 << 4)
#define _XABORT_NESTED (1 << 5)
#define _XABORT_CODE(x) (((x) >> 24) & 0xFF)
/* Start an RTM code region. Return _XBEGIN_STARTED on success and the
abort condition otherwise. */
extern __inline unsigned int
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_xbegin (void)
{
return __builtin_ia32_xbegin ();
}
/* Specify the end of an RTM code region. If it corresponds to the
outermost transaction, then attempts the transaction commit. If the
commit fails, then control is transferred to the outermost transaction
fallback handler. */
extern __inline void
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_xend (void)
{
__builtin_ia32_xend ();
}
/* Force an RTM abort condition. The control is transferred to the
outermost transaction fallback handler with the abort condition IMM. */
#ifdef __OPTIMIZE__
extern __inline void
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_xabort (const unsigned int __imm)
{
__builtin_ia32_xabort (__imm);
}
#else
#define _xabort(N) __builtin_ia32_xabort (N)
#endif /* __OPTIMIZE__ */
#ifdef __DISABLE_RTM__
#undef __DISABLE_RTM__
#pragma GCC pop_options
#endif /* __DISABLE_RTM__ */
#endif /* _RTMINTRIN_H_INCLUDED */
@@ -0,0 +1,149 @@
//===-- sanitizer/asan_interface.h ------------------------------*- C++ -*-===//
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file is a part of AddressSanitizer.
//
// Public interface header.
//===----------------------------------------------------------------------===//
#ifndef SANITIZER_ASAN_INTERFACE_H
#define SANITIZER_ASAN_INTERFACE_H
#include <sanitizer/common_interface_defs.h>
#ifdef __cplusplus
extern "C" {
#endif
// Marks memory region [addr, addr+size) as unaddressable.
// This memory must be previously allocated by the user program. Accessing
// addresses in this region from instrumented code is forbidden until
// this region is unpoisoned. This function is not guaranteed to poison
// the whole region - it may poison only subregion of [addr, addr+size) due
// to ASan alignment restrictions.
// Method is NOT thread-safe in the sense that no two threads can
// (un)poison memory in the same memory region simultaneously.
void __asan_poison_memory_region(void const volatile *addr, size_t size);
// Marks memory region [addr, addr+size) as addressable.
// This memory must be previously allocated by the user program. Accessing
// addresses in this region is allowed until this region is poisoned again.
// This function may unpoison a superregion of [addr, addr+size) due to
// ASan alignment restrictions.
// Method is NOT thread-safe in the sense that no two threads can
// (un)poison memory in the same memory region simultaneously.
void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
// User code should use macros instead of functions.
#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
#define ASAN_POISON_MEMORY_REGION(addr, size) \
__asan_poison_memory_region((addr), (size))
#define ASAN_UNPOISON_MEMORY_REGION(addr, size) \
__asan_unpoison_memory_region((addr), (size))
#else
#define ASAN_POISON_MEMORY_REGION(addr, size) \
((void)(addr), (void)(size))
#define ASAN_UNPOISON_MEMORY_REGION(addr, size) \
((void)(addr), (void)(size))
#endif
// Returns 1 if addr is poisoned (i.e. 1-byte read/write access to this
// address will result in error report from AddressSanitizer).
// Otherwise returns 0.
int __asan_address_is_poisoned(void const volatile *addr);
// If at least one byte in [beg, beg+size) is poisoned, return the address
// of the first such byte. Otherwise return 0.
void *__asan_region_is_poisoned(void *beg, size_t size);
// Print the description of addr (useful when debugging in gdb).
void __asan_describe_address(void *addr);
// Useful for calling from a debugger to get information about an ASan error.
// Returns 1 if an error has been (or is being) reported, otherwise returns 0.
int __asan_report_present();
// Useful for calling from a debugger to get information about an ASan error.
// If an error has been (or is being) reported, the following functions return
// the pc, bp, sp, address, access type (0 = read, 1 = write), access size and
// bug description (e.g. "heap-use-after-free"). Otherwise they return 0.
void *__asan_get_report_pc();
void *__asan_get_report_bp();
void *__asan_get_report_sp();
void *__asan_get_report_address();
int __asan_get_report_access_type();
size_t __asan_get_report_access_size();
const char *__asan_get_report_description();
// Useful for calling from the debugger to get information about a pointer.
// Returns the category of the given pointer as a constant string.
// Possible return values are "global", "stack", "stack-fake", "heap",
// "heap-invalid", "shadow-low", "shadow-gap", "shadow-high", "unknown".
// If global or stack, tries to also return the variable name, address and
// size. If heap, tries to return the chunk address and size. 'name' should
// point to an allocated buffer of size 'name_size'.
const char *__asan_locate_address(void *addr, char *name, size_t name_size,
void **region_address, size_t *region_size);
// Useful for calling from the debugger to get the allocation stack trace
// and thread ID for a heap address. Stores up to 'size' frames into 'trace',
// returns the number of stored frames or 0 on error.
size_t __asan_get_alloc_stack(void *addr, void **trace, size_t size,
int *thread_id);
// Useful for calling from the debugger to get the free stack trace
// and thread ID for a heap address. Stores up to 'size' frames into 'trace',
// returns the number of stored frames or 0 on error.
size_t __asan_get_free_stack(void *addr, void **trace, size_t size,
int *thread_id);
// Useful for calling from the debugger to get the current shadow memory
// mapping.
void __asan_get_shadow_mapping(size_t *shadow_scale, size_t *shadow_offset);
// This is an internal function that is called to report an error.
// However it is still a part of the interface because users may want to
// set a breakpoint on this function in a debugger.
void __asan_report_error(void *pc, void *bp, void *sp,
void *addr, int is_write, size_t access_size);
// Deprecated. Call __sanitizer_set_death_callback instead.
void __asan_set_death_callback(void (*callback)(void));
void __asan_set_error_report_callback(void (*callback)(const char*));
// User may provide function that would be called right when ASan detects
// an error. This can be used to notice cases when ASan detects an error, but
// the program crashes before ASan report is printed.
void __asan_on_error();
// Prints accumulated stats to stderr. Used for debugging.
void __asan_print_accumulated_stats();
// This function may be optionally provided by user and should return
// a string containing ASan runtime options. See asan_flags.h for details.
const char* __asan_default_options();
// The following 2 functions facilitate garbage collection in presence of
// asan's fake stack.
// Returns an opaque handler to be used later in __asan_addr_is_in_fake_stack.
// Returns NULL if the current thread does not have a fake stack.
void *__asan_get_current_fake_stack();
// If fake_stack is non-NULL and addr belongs to a fake frame in
// fake_stack, returns the address on real stack that corresponds to
// the fake frame and sets beg/end to the boundaries of this fake frame.
// Otherwise returns NULL and does not touch beg/end.
// If beg/end are NULL, they are not touched.
// This function may be called from a thread other than the owner of
// fake_stack, but the owner thread need to be alive.
void *__asan_addr_is_in_fake_stack(void *fake_stack, void *addr, void **beg,
void **end);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // SANITIZER_ASAN_INTERFACE_H
@@ -0,0 +1,187 @@
//===-- sanitizer/common_interface_defs.h -----------------------*- C++ -*-===//
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Common part of the public sanitizer interface.
//===----------------------------------------------------------------------===//
#ifndef SANITIZER_COMMON_INTERFACE_DEFS_H
#define SANITIZER_COMMON_INTERFACE_DEFS_H
#include <stddef.h>
#include <stdint.h>
// GCC does not understand __has_feature.
#if !defined(__has_feature)
# define __has_feature(x) 0
#endif
#ifdef __cplusplus
extern "C" {
#endif
// Arguments for __sanitizer_sandbox_on_notify() below.
typedef struct {
// Enable sandbox support in sanitizer coverage.
int coverage_sandboxed;
// File descriptor to write coverage data to. If -1 is passed, a file will
// be pre-opened by __sanitizer_sandobx_on_notify(). This field has no
// effect if coverage_sandboxed == 0.
intptr_t coverage_fd;
// If non-zero, split the coverage data into well-formed blocks. This is
// useful when coverage_fd is a socket descriptor. Each block will contain
// a header, allowing data from multiple processes to be sent over the same
// socket.
unsigned int coverage_max_block_size;
} __sanitizer_sandbox_arguments;
// Tell the tools to write their reports to "path.<pid>" instead of stderr.
void __sanitizer_set_report_path(const char *path);
// Tell the tools to write their reports to the provided file descriptor
// (casted to void *).
void __sanitizer_set_report_fd(void *fd);
// Notify the tools that the sandbox is going to be turned on. The reserved
// parameter will be used in the future to hold a structure with functions
// that the tools may call to bypass the sandbox.
void __sanitizer_sandbox_on_notify(__sanitizer_sandbox_arguments *args);
// This function is called by the tool when it has just finished reporting
// an error. 'error_summary' is a one-line string that summarizes
// the error message. This function can be overridden by the client.
void __sanitizer_report_error_summary(const char *error_summary);
// Some of the sanitizers (e.g. asan/tsan) may miss bugs that happen
// in unaligned loads/stores. In order to find such bugs reliably one needs
// to replace plain unaligned loads/stores with these calls.
uint16_t __sanitizer_unaligned_load16(const void *p);
uint32_t __sanitizer_unaligned_load32(const void *p);
uint64_t __sanitizer_unaligned_load64(const void *p);
void __sanitizer_unaligned_store16(void *p, uint16_t x);
void __sanitizer_unaligned_store32(void *p, uint32_t x);
void __sanitizer_unaligned_store64(void *p, uint64_t x);
// Annotate the current state of a contiguous container, such as
// std::vector, std::string or similar.
// A contiguous container is a container that keeps all of its elements
// in a contiguous region of memory. The container owns the region of memory
// [beg, end); the memory [beg, mid) is used to store the current elements
// and the memory [mid, end) is reserved for future elements;
// beg <= mid <= end. For example, in "std::vector<> v"
// beg = &v[0];
// end = beg + v.capacity() * sizeof(v[0]);
// mid = beg + v.size() * sizeof(v[0]);
//
// This annotation tells the Sanitizer tool about the current state of the
// container so that the tool can report errors when memory from [mid, end)
// is accessed. Insert this annotation into methods like push_back/pop_back.
// Supply the old and the new values of mid (old_mid/new_mid).
// In the initial state mid == end and so should be the final
// state when the container is destroyed or when it reallocates the storage.
//
// Use with caution and don't use for anything other than vector-like classes.
//
// For AddressSanitizer, 'beg' should be 8-aligned and 'end' should
// be either 8-aligned or it should point to the end of a separate heap-,
// stack-, or global- allocated buffer. I.e. the following will not work:
// int64_t x[2]; // 16 bytes, 8-aligned.
// char *beg = (char *)&x[0];
// char *end = beg + 12; // Not 8 aligned, not the end of the buffer.
// This however will work fine:
// int32_t x[3]; // 12 bytes, but 8-aligned under AddressSanitizer.
// char *beg = (char*)&x[0];
// char *end = beg + 12; // Not 8-aligned, but is the end of the buffer.
void __sanitizer_annotate_contiguous_container(const void *beg,
const void *end,
const void *old_mid,
const void *new_mid);
// Returns true if the contiguous container [beg, end) is properly poisoned
// (e.g. with __sanitizer_annotate_contiguous_container), i.e. if
// - [beg, mid) is addressable,
// - [mid, end) is unaddressable.
// Full verification requires O(end-beg) time; this function tries to avoid
// such complexity by touching only parts of the container around beg/mid/end.
int __sanitizer_verify_contiguous_container(const void *beg, const void *mid,
const void *end);
// Similar to __sanitizer_verify_contiguous_container but returns the address
// of the first improperly poisoned byte otherwise. Returns null if the area
// is poisoned properly.
const void *__sanitizer_contiguous_container_find_bad_address(
const void *beg, const void *mid, const void *end);
// Print the stack trace leading to this call. Useful for debugging user code.
void __sanitizer_print_stack_trace();
// Symbolizes the supplied 'pc' using the format string 'fmt'.
// Outputs at most 'out_buf_size' bytes into 'out_buf'.
// The format syntax is described in
// lib/sanitizer_common/sanitizer_stacktrace_printer.h.
void __sanitizer_symbolize_pc(void *pc, const char *fmt, char *out_buf,
size_t out_buf_size);
// Same as __sanitizer_symbolize_pc, but for data section (i.e. globals).
void __sanitizer_symbolize_global(void *data_ptr, const char *fmt,
char *out_buf, size_t out_buf_size);
// Sets the callback to be called right before death on error.
// Passing 0 will unset the callback.
void __sanitizer_set_death_callback(void (*callback)(void));
// Interceptor hooks.
// Whenever a libc function interceptor is called it checks if the
// corresponding weak hook is defined, and it so -- calls it.
// The primary use case is data-flow-guided fuzzing, where the fuzzer needs
// to know what is being passed to libc functions, e.g. memcmp.
// FIXME: implement more hooks.
void __sanitizer_weak_hook_memcmp(void *called_pc, const void *s1,
const void *s2, size_t n, int result);
void __sanitizer_weak_hook_strncmp(void *called_pc, const char *s1,
const char *s2, size_t n, int result);
void __sanitizer_weak_hook_strncasecmp(void *called_pc, const char *s1,
const char *s2, size_t n, int result);
void __sanitizer_weak_hook_strcmp(void *called_pc, const char *s1,
const char *s2, int result);
void __sanitizer_weak_hook_strcasecmp(void *called_pc, const char *s1,
const char *s2, int result);
void __sanitizer_weak_hook_strstr(void *called_pc, const char *s1,
const char *s2, char *result);
void __sanitizer_weak_hook_strcasestr(void *called_pc, const char *s1,
const char *s2, char *result);
void __sanitizer_weak_hook_memmem(void *called_pc,
const void *s1, size_t len1,
const void *s2, size_t len2, void *result);
// Prints stack traces for all live heap allocations ordered by total
// allocation size until `top_percent` of total live heap is shown.
// `top_percent` should be between 1 and 100.
// Experimental feature currently available only with asan on Linux/x86_64.
void __sanitizer_print_memory_profile(size_t top_percent);
// Fiber annotation interface.
// Before switching to a different stack, one must call
// __sanitizer_start_switch_fiber with a pointer to the bottom of the
// destination stack and its size. When code starts running on the new stack,
// it must call __sanitizer_finish_switch_fiber to finalize the switch.
// The start_switch function takes a void** to store the current fake stack if
// there is one (it is needed when detect_stack_use_after_return is enabled).
// When restoring a stack, this pointer must be given to the finish_switch
// function. In most cases, this void* can be stored on the stack just before
// switching. When leaving a fiber definitely, null must be passed as first
// argument to the start_switch function so that the fake stack is destroyed.
// If you do not want support for stack use-after-return detection, you can
// always pass null to these two functions.
// Note that the fake stack mechanism is disabled during fiber switch, so if a
// signal callback runs during the switch, it will not benefit from the stack
// use-after-return detection.
void __sanitizer_start_switch_fiber(void **fake_stack_save,
const void *bottom, size_t size);
void __sanitizer_finish_switch_fiber(void *fake_stack_save,
const void **bottom_old,
size_t *size_old);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // SANITIZER_COMMON_INTERFACE_DEFS_H
@@ -0,0 +1,82 @@
//===-- sanitizer/lsan_interface.h ------------------------------*- C++ -*-===//
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file is a part of LeakSanitizer.
//
// Public interface header.
//===----------------------------------------------------------------------===//
#ifndef SANITIZER_LSAN_INTERFACE_H
#define SANITIZER_LSAN_INTERFACE_H
#include <sanitizer/common_interface_defs.h>
#ifdef __cplusplus
extern "C" {
#endif
// Allocations made between calls to __lsan_disable() and __lsan_enable() will
// be treated as non-leaks. Disable/enable pairs may be nested.
void __lsan_disable();
void __lsan_enable();
// The heap object into which p points will be treated as a non-leak.
void __lsan_ignore_object(const void *p);
// Memory regions registered through this interface will be treated as sources
// of live pointers during leak checking. Useful if you store pointers in
// mapped memory.
// Points of note:
// - __lsan_unregister_root_region() must be called with the same pointer and
// size that have earlier been passed to __lsan_register_root_region()
// - LSan will skip any inaccessible memory when scanning a root region. E.g.,
// if you map memory within a larger region that you have mprotect'ed, you can
// register the entire large region.
// - the implementation is not optimized for performance. This interface is
// intended to be used for a small number of relatively static regions.
void __lsan_register_root_region(const void *p, size_t size);
void __lsan_unregister_root_region(const void *p, size_t size);
// Check for leaks now. This function behaves identically to the default
// end-of-process leak check. In particular, it will terminate the process if
// leaks are found and the exitcode runtime flag is non-zero.
// Subsequent calls to this function will have no effect and end-of-process
// leak check will not run. Effectively, end-of-process leak check is moved to
// the time of first invocation of this function.
// By calling this function early during process shutdown, you can instruct
// LSan to ignore shutdown-only leaks which happen later on.
void __lsan_do_leak_check();
// Check for leaks now. Returns zero if no leaks have been found or if leak
// detection is disabled, non-zero otherwise.
// This function may be called repeatedly, e.g. to periodically check a
// long-running process. It prints a leak report if appropriate, but does not
// terminate the process. It does not affect the behavior of
// __lsan_do_leak_check() or the end-of-process leak check, and is not
// affected by them.
int __lsan_do_recoverable_leak_check();
// The user may optionally provide this function to disallow leak checking
// for the program it is linked into (if the return value is non-zero). This
// function must be defined as returning a constant value; any behavior beyond
// that is unsupported.
int __lsan_is_turned_off();
// This function may be optionally provided by the user and should return
// a string containing LSan suppressions.
const char *__lsan_default_suppressions();
#ifdef __cplusplus
} // extern "C"
namespace __lsan {
class ScopedDisabler {
public:
ScopedDisabler() { __lsan_disable(); }
~ScopedDisabler() { __lsan_enable(); }
};
} // namespace __lsan
#endif
#endif // SANITIZER_LSAN_INTERFACE_H
@@ -0,0 +1,177 @@
#ifndef _SGXINTRIN_H_INCLUDED
#define _SGXINTRIN_H_INCLUDED
#ifndef __SGX__
#pragma GCC push_options
#pragma GCC target("sgx")
#define __DISABLE_SGX__
#endif /* __SGX__ */
#define __encls_bc(leaf, b, c, retval) \
__asm__ __volatile__ ("encls\n\t" \
: "=a" (retval) \
: "a" (leaf), "b" (b), "c" (c) \
: "cc")
#define __encls_bcd(leaf, b, c, d, retval) \
__asm__ __volatile__("encls\n\t" \
: "=a" (retval) \
: "a" (leaf), "b" (b), "c" (c), "d" (d) \
: "cc")
#define __encls_c(leaf, c, retval) \
__asm__ __volatile__("encls\n\t" \
: "=a" (retval) \
: "a" (leaf), "c" (c) \
: "cc")
#define __encls_edbgrd(leaf, b, c, retval) \
__asm__ __volatile__("encls\n\t" \
: "=a" (retval), "=b" (b) \
: "a" (leaf), "c" (c))
#define __encls_generic(leaf, b, c, d, retval) \
__asm__ __volatile__("encls\n\t" \
: "=a" (retval), "=b" (b), "=c" (c), "=d" (d)\
: "a" (leaf), "b" (b), "c" (c), "d" (d) \
: "cc")
#define __enclu_bc(leaf, b, c, retval) \
__asm__ __volatile__("enclu\n\t" \
: "=a" (retval) \
: "a" (leaf), "b" (b), "c" (c) \
: "cc")
#define __enclu_bcd(leaf, b, c, d, retval) \
__asm__ __volatile__("enclu\n\t" \
: "=a" (retval) \
: "a" (leaf), "b" (b), "c" (c), "d" (d) \
: "cc")
#define __enclu_eenter(leaf, b, c, retval) \
__asm__ __volatile__("enclu\n\t" \
: "=a" (retval), "=c" (c) \
: "a" (leaf), "b" (b), "c" (c) \
: "cc")
#define __enclu_eexit(leaf, b, c, retval) \
__asm__ __volatile__("enclu\n\t" \
: "=a" (retval), "=c" (c) \
: "a" (leaf), "b" (b) \
: "cc")
#define __enclu_generic(leaf, b, c, d, retval) \
__asm__ __volatile__("enclu\n\t" \
: "=a" (retval), "=b" (b), "=c" (c), "=d" (d)\
: "a" (leaf), "b" (b), "c" (c), "d" (d) \
: "cc")
extern __inline int
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_encls_u32 (const int __L, size_t __D[])
{
enum __encls_type
{
__SGX_ECREATE = 0x00,
__SGX_EADD = 0x01,
__SGX_EINIT = 0x02,
__SGX_EREMOVE = 0x03,
__SGX_EDBGRD = 0x04,
__SGX_EDBGWR = 0x05,
__SGX_EEXTEND = 0x06,
__SGX_ELDB = 0x07,
__SGX_ELDU = 0x08,
__SGX_EBLOCK = 0x09,
__SGX_EPA = 0x0A,
__SGX_EWB = 0x0B,
__SGX_ETRACK = 0x0C,
__SGX_EAUG = 0x0D,
__SGX_EMODPR = 0x0E,
__SGX_EMODT = 0x0F
};
enum __encls_type __T = (enum __encls_type)__L;
int __R = 0;
if (!__builtin_constant_p (__T))
__encls_generic (__L, __D[0], __D[1], __D[2], __R);
else switch (__T)
{
case __SGX_ECREATE:
case __SGX_EADD:
case __SGX_EDBGWR:
case __SGX_EEXTEND:
case __SGX_EPA:
case __SGX_EMODPR:
case __SGX_EMODT:
case __SGX_EAUG:
__encls_bc (__L, __D[0], __D[1], __R);
break;
case __SGX_EINIT:
case __SGX_ELDB:
case __SGX_ELDU:
case __SGX_EWB:
__encls_bcd (__L, __D[0], __D[1], __D[2], __R);
break;
case __SGX_EREMOVE:
case __SGX_EBLOCK:
case __SGX_ETRACK:
__encls_c (__L, __D[1], __R);
break;
case __SGX_EDBGRD:
__encls_edbgrd (__L, __D[0], __D[1], __R);
break;
default:
return -1;
}
return __R;
}
extern __inline int
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_enclu_u32 (const int __L, size_t __D[])
{
enum __enclu_type
{
__SGX_EREPORT = 0x00,
__SGX_EGETKEY = 0x01,
__SGX_EENTER = 0x02,
__SGX_ERESUME = 0x03,
__SGX_EEXIT = 0x04,
__SGX_EACCEPT = 0x05,
__SGX_EMODPE = 0x06,
__SGX_EACCEPTCOPY = 0x07
};
enum __enclu_type __T = (enum __enclu_type) __L;
int __R = 0;
if (!__builtin_constant_p (__T))
__enclu_generic (__L, __D[0], __D[1], __D[2], __R);
else switch (__T)
{
case __SGX_EREPORT:
case __SGX_EACCEPTCOPY:
__enclu_bcd (__L, __D[0], __D[1], __D[2], __R);
break;
case __SGX_EGETKEY:
case __SGX_ERESUME:
case __SGX_EACCEPT:
case __SGX_EMODPE:
__enclu_bc (__L, __D[0], __D[1], __R);
break;
case __SGX_EENTER:
__enclu_eenter (__L, __D[0], __D[1], __R);
break;
case __SGX_EEXIT:
__enclu_eexit (__L, __D[0], __D[1], __R);
break;
default:
return -1;
}
return __R;
}
#ifdef __DISABLE_SGX__
#undef __DISABLE_SGX__
#pragma GCC pop_options
#endif /* __DISABLE_SGX__ */
#endif /* _SGXINTRIN_H_INCLUDED */
@@ -0,0 +1,98 @@
/* Copyright (C) 2013-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _IMMINTRIN_H_INCLUDED
#error "Never use <shaintrin.h> directly; include <immintrin.h> instead."
#endif
#ifndef _SHAINTRIN_H_INCLUDED
#define _SHAINTRIN_H_INCLUDED
#ifndef __SHA__
#pragma GCC push_options
#pragma GCC target("sha")
#define __DISABLE_SHA__
#endif /* __SHA__ */
extern __inline __m128i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_sha1msg1_epu32 (__m128i __A, __m128i __B)
{
return (__m128i) __builtin_ia32_sha1msg1 ((__v4si) __A, (__v4si) __B);
}
extern __inline __m128i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_sha1msg2_epu32 (__m128i __A, __m128i __B)
{
return (__m128i) __builtin_ia32_sha1msg2 ((__v4si) __A, (__v4si) __B);
}
extern __inline __m128i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_sha1nexte_epu32 (__m128i __A, __m128i __B)
{
return (__m128i) __builtin_ia32_sha1nexte ((__v4si) __A, (__v4si) __B);
}
#ifdef __OPTIMIZE__
extern __inline __m128i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_sha1rnds4_epu32 (__m128i __A, __m128i __B, const int __I)
{
return (__m128i) __builtin_ia32_sha1rnds4 ((__v4si) __A, (__v4si) __B, __I);
}
#else
#define _mm_sha1rnds4_epu32(A, B, I) \
((__m128i) __builtin_ia32_sha1rnds4 ((__v4si)(__m128i)A, \
(__v4si)(__m128i)B, (int)I))
#endif
extern __inline __m128i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_sha256msg1_epu32 (__m128i __A, __m128i __B)
{
return (__m128i) __builtin_ia32_sha256msg1 ((__v4si) __A, (__v4si) __B);
}
extern __inline __m128i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_sha256msg2_epu32 (__m128i __A, __m128i __B)
{
return (__m128i) __builtin_ia32_sha256msg2 ((__v4si) __A, (__v4si) __B);
}
extern __inline __m128i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_sha256rnds2_epu32 (__m128i __A, __m128i __B, __m128i __C)
{
return (__m128i) __builtin_ia32_sha256rnds2 ((__v4si) __A, (__v4si) __B,
(__v4si) __C);
}
#ifdef __DISABLE_SHA__
#undef __DISABLE_SHA__
#pragma GCC pop_options
#endif /* __DISABLE_SHA__ */
#endif /* _SHAINTRIN_H_INCLUDED */
@@ -0,0 +1,862 @@
/* Copyright (C) 2007-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
/* Implemented from the specification included in the Intel C++ Compiler
User Guide and Reference, version 10.0. */
#ifndef _SMMINTRIN_H_INCLUDED
#define _SMMINTRIN_H_INCLUDED
/* We need definitions from the SSSE3, SSE3, SSE2 and SSE header
files. */
#include <tmmintrin.h>
#ifndef __SSE4_1__
#pragma GCC push_options
#pragma GCC target("sse4.1")
#define __DISABLE_SSE4_1__
#endif /* __SSE4_1__ */
/* Rounding mode macros. */
#define _MM_FROUND_TO_NEAREST_INT 0x00
#define _MM_FROUND_TO_NEG_INF 0x01
#define _MM_FROUND_TO_POS_INF 0x02
#define _MM_FROUND_TO_ZERO 0x03
#define _MM_FROUND_CUR_DIRECTION 0x04
#define _MM_FROUND_RAISE_EXC 0x00
#define _MM_FROUND_NO_EXC 0x08
#define _MM_FROUND_NINT \
(_MM_FROUND_TO_NEAREST_INT | _MM_FROUND_RAISE_EXC)
#define _MM_FROUND_FLOOR \
(_MM_FROUND_TO_NEG_INF | _MM_FROUND_RAISE_EXC)
#define _MM_FROUND_CEIL \
(_MM_FROUND_TO_POS_INF | _MM_FROUND_RAISE_EXC)
#define _MM_FROUND_TRUNC \
(_MM_FROUND_TO_ZERO | _MM_FROUND_RAISE_EXC)
#define _MM_FROUND_RINT \
(_MM_FROUND_CUR_DIRECTION | _MM_FROUND_RAISE_EXC)
#define _MM_FROUND_NEARBYINT \
(_MM_FROUND_CUR_DIRECTION | _MM_FROUND_NO_EXC)
/* Test Instruction */
/* Packed integer 128-bit bitwise comparison. Return 1 if
(__V & __M) == 0. */
extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_testz_si128 (__m128i __M, __m128i __V)
{
return __builtin_ia32_ptestz128 ((__v2di)__M, (__v2di)__V);
}
/* Packed integer 128-bit bitwise comparison. Return 1 if
(__V & ~__M) == 0. */
extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_testc_si128 (__m128i __M, __m128i __V)
{
return __builtin_ia32_ptestc128 ((__v2di)__M, (__v2di)__V);
}
/* Packed integer 128-bit bitwise comparison. Return 1 if
(__V & __M) != 0 && (__V & ~__M) != 0. */
extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_testnzc_si128 (__m128i __M, __m128i __V)
{
return __builtin_ia32_ptestnzc128 ((__v2di)__M, (__v2di)__V);
}
/* Macros for packed integer 128-bit comparison intrinsics. */
#define _mm_test_all_zeros(M, V) _mm_testz_si128 ((M), (V))
#define _mm_test_all_ones(V) \
_mm_testc_si128 ((V), _mm_cmpeq_epi32 ((V), (V)))
#define _mm_test_mix_ones_zeros(M, V) _mm_testnzc_si128 ((M), (V))
/* Packed/scalar double precision floating point rounding. */
#ifdef __OPTIMIZE__
extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_round_pd (__m128d __V, const int __M)
{
return (__m128d) __builtin_ia32_roundpd ((__v2df)__V, __M);
}
extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_round_sd(__m128d __D, __m128d __V, const int __M)
{
return (__m128d) __builtin_ia32_roundsd ((__v2df)__D,
(__v2df)__V,
__M);
}
#else
#define _mm_round_pd(V, M) \
((__m128d) __builtin_ia32_roundpd ((__v2df)(__m128d)(V), (int)(M)))
#define _mm_round_sd(D, V, M) \
((__m128d) __builtin_ia32_roundsd ((__v2df)(__m128d)(D), \
(__v2df)(__m128d)(V), (int)(M)))
#endif
/* Packed/scalar single precision floating point rounding. */
#ifdef __OPTIMIZE__
extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_round_ps (__m128 __V, const int __M)
{
return (__m128) __builtin_ia32_roundps ((__v4sf)__V, __M);
}
extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_round_ss (__m128 __D, __m128 __V, const int __M)
{
return (__m128) __builtin_ia32_roundss ((__v4sf)__D,
(__v4sf)__V,
__M);
}
#else
#define _mm_round_ps(V, M) \
((__m128) __builtin_ia32_roundps ((__v4sf)(__m128)(V), (int)(M)))
#define _mm_round_ss(D, V, M) \
((__m128) __builtin_ia32_roundss ((__v4sf)(__m128)(D), \
(__v4sf)(__m128)(V), (int)(M)))
#endif
/* Macros for ceil/floor intrinsics. */
#define _mm_ceil_pd(V) _mm_round_pd ((V), _MM_FROUND_CEIL)
#define _mm_ceil_sd(D, V) _mm_round_sd ((D), (V), _MM_FROUND_CEIL)
#define _mm_floor_pd(V) _mm_round_pd((V), _MM_FROUND_FLOOR)
#define _mm_floor_sd(D, V) _mm_round_sd ((D), (V), _MM_FROUND_FLOOR)
#define _mm_ceil_ps(V) _mm_round_ps ((V), _MM_FROUND_CEIL)
#define _mm_ceil_ss(D, V) _mm_round_ss ((D), (V), _MM_FROUND_CEIL)
#define _mm_floor_ps(V) _mm_round_ps ((V), _MM_FROUND_FLOOR)
#define _mm_floor_ss(D, V) _mm_round_ss ((D), (V), _MM_FROUND_FLOOR)
/* SSE4.1 */
/* Integer blend instructions - select data from 2 sources using
constant/variable mask. */
#ifdef __OPTIMIZE__
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_blend_epi16 (__m128i __X, __m128i __Y, const int __M)
{
return (__m128i) __builtin_ia32_pblendw128 ((__v8hi)__X,
(__v8hi)__Y,
__M);
}
#else
#define _mm_blend_epi16(X, Y, M) \
((__m128i) __builtin_ia32_pblendw128 ((__v8hi)(__m128i)(X), \
(__v8hi)(__m128i)(Y), (int)(M)))
#endif
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_blendv_epi8 (__m128i __X, __m128i __Y, __m128i __M)
{
return (__m128i) __builtin_ia32_pblendvb128 ((__v16qi)__X,
(__v16qi)__Y,
(__v16qi)__M);
}
/* Single precision floating point blend instructions - select data
from 2 sources using constant/variable mask. */
#ifdef __OPTIMIZE__
extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_blend_ps (__m128 __X, __m128 __Y, const int __M)
{
return (__m128) __builtin_ia32_blendps ((__v4sf)__X,
(__v4sf)__Y,
__M);
}
#else
#define _mm_blend_ps(X, Y, M) \
((__m128) __builtin_ia32_blendps ((__v4sf)(__m128)(X), \
(__v4sf)(__m128)(Y), (int)(M)))
#endif
extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_blendv_ps (__m128 __X, __m128 __Y, __m128 __M)
{
return (__m128) __builtin_ia32_blendvps ((__v4sf)__X,
(__v4sf)__Y,
(__v4sf)__M);
}
/* Double precision floating point blend instructions - select data
from 2 sources using constant/variable mask. */
#ifdef __OPTIMIZE__
extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_blend_pd (__m128d __X, __m128d __Y, const int __M)
{
return (__m128d) __builtin_ia32_blendpd ((__v2df)__X,
(__v2df)__Y,
__M);
}
#else
#define _mm_blend_pd(X, Y, M) \
((__m128d) __builtin_ia32_blendpd ((__v2df)(__m128d)(X), \
(__v2df)(__m128d)(Y), (int)(M)))
#endif
extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_blendv_pd (__m128d __X, __m128d __Y, __m128d __M)
{
return (__m128d) __builtin_ia32_blendvpd ((__v2df)__X,
(__v2df)__Y,
(__v2df)__M);
}
/* Dot product instructions with mask-defined summing and zeroing parts
of result. */
#ifdef __OPTIMIZE__
extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_dp_ps (__m128 __X, __m128 __Y, const int __M)
{
return (__m128) __builtin_ia32_dpps ((__v4sf)__X,
(__v4sf)__Y,
__M);
}
extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_dp_pd (__m128d __X, __m128d __Y, const int __M)
{
return (__m128d) __builtin_ia32_dppd ((__v2df)__X,
(__v2df)__Y,
__M);
}
#else
#define _mm_dp_ps(X, Y, M) \
((__m128) __builtin_ia32_dpps ((__v4sf)(__m128)(X), \
(__v4sf)(__m128)(Y), (int)(M)))
#define _mm_dp_pd(X, Y, M) \
((__m128d) __builtin_ia32_dppd ((__v2df)(__m128d)(X), \
(__v2df)(__m128d)(Y), (int)(M)))
#endif
/* Packed integer 64-bit comparison, zeroing or filling with ones
corresponding parts of result. */
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cmpeq_epi64 (__m128i __X, __m128i __Y)
{
return (__m128i) ((__v2di)__X == (__v2di)__Y);
}
/* Min/max packed integer instructions. */
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_min_epi8 (__m128i __X, __m128i __Y)
{
return (__m128i) __builtin_ia32_pminsb128 ((__v16qi)__X, (__v16qi)__Y);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_max_epi8 (__m128i __X, __m128i __Y)
{
return (__m128i) __builtin_ia32_pmaxsb128 ((__v16qi)__X, (__v16qi)__Y);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_min_epu16 (__m128i __X, __m128i __Y)
{
return (__m128i) __builtin_ia32_pminuw128 ((__v8hi)__X, (__v8hi)__Y);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_max_epu16 (__m128i __X, __m128i __Y)
{
return (__m128i) __builtin_ia32_pmaxuw128 ((__v8hi)__X, (__v8hi)__Y);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_min_epi32 (__m128i __X, __m128i __Y)
{
return (__m128i) __builtin_ia32_pminsd128 ((__v4si)__X, (__v4si)__Y);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_max_epi32 (__m128i __X, __m128i __Y)
{
return (__m128i) __builtin_ia32_pmaxsd128 ((__v4si)__X, (__v4si)__Y);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_min_epu32 (__m128i __X, __m128i __Y)
{
return (__m128i) __builtin_ia32_pminud128 ((__v4si)__X, (__v4si)__Y);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_max_epu32 (__m128i __X, __m128i __Y)
{
return (__m128i) __builtin_ia32_pmaxud128 ((__v4si)__X, (__v4si)__Y);
}
/* Packed integer 32-bit multiplication with truncation of upper
halves of results. */
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_mullo_epi32 (__m128i __X, __m128i __Y)
{
return (__m128i) ((__v4su)__X * (__v4su)__Y);
}
/* Packed integer 32-bit multiplication of 2 pairs of operands
with two 64-bit results. */
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_mul_epi32 (__m128i __X, __m128i __Y)
{
return (__m128i) __builtin_ia32_pmuldq128 ((__v4si)__X, (__v4si)__Y);
}
/* Insert single precision float into packed single precision array
element selected by index N. The bits [7-6] of N define S
index, the bits [5-4] define D index, and bits [3-0] define
zeroing mask for D. */
#ifdef __OPTIMIZE__
extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_insert_ps (__m128 __D, __m128 __S, const int __N)
{
return (__m128) __builtin_ia32_insertps128 ((__v4sf)__D,
(__v4sf)__S,
__N);
}
#else
#define _mm_insert_ps(D, S, N) \
((__m128) __builtin_ia32_insertps128 ((__v4sf)(__m128)(D), \
(__v4sf)(__m128)(S), (int)(N)))
#endif
/* Helper macro to create the N value for _mm_insert_ps. */
#define _MM_MK_INSERTPS_NDX(S, D, M) (((S) << 6) | ((D) << 4) | (M))
/* Extract binary representation of single precision float from packed
single precision array element of X selected by index N. */
#ifdef __OPTIMIZE__
extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_extract_ps (__m128 __X, const int __N)
{
union { int i; float f; } __tmp;
__tmp.f = __builtin_ia32_vec_ext_v4sf ((__v4sf)__X, __N);
return __tmp.i;
}
#else
#define _mm_extract_ps(X, N) \
(__extension__ \
({ \
union { int i; float f; } __tmp; \
__tmp.f = __builtin_ia32_vec_ext_v4sf ((__v4sf)(__m128)(X), (int)(N)); \
__tmp.i; \
}))
#endif
/* Extract binary representation of single precision float into
D from packed single precision array element of S selected
by index N. */
#define _MM_EXTRACT_FLOAT(D, S, N) \
{ (D) = __builtin_ia32_vec_ext_v4sf ((__v4sf)(S), (N)); }
/* Extract specified single precision float element into the lower
part of __m128. */
#define _MM_PICK_OUT_PS(X, N) \
_mm_insert_ps (_mm_setzero_ps (), (X), \
_MM_MK_INSERTPS_NDX ((N), 0, 0x0e))
/* Insert integer, S, into packed integer array element of D
selected by index N. */
#ifdef __OPTIMIZE__
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_insert_epi8 (__m128i __D, int __S, const int __N)
{
return (__m128i) __builtin_ia32_vec_set_v16qi ((__v16qi)__D,
__S, __N);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_insert_epi32 (__m128i __D, int __S, const int __N)
{
return (__m128i) __builtin_ia32_vec_set_v4si ((__v4si)__D,
__S, __N);
}
#ifdef __x86_64__
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_insert_epi64 (__m128i __D, long long __S, const int __N)
{
return (__m128i) __builtin_ia32_vec_set_v2di ((__v2di)__D,
__S, __N);
}
#endif
#else
#define _mm_insert_epi8(D, S, N) \
((__m128i) __builtin_ia32_vec_set_v16qi ((__v16qi)(__m128i)(D), \
(int)(S), (int)(N)))
#define _mm_insert_epi32(D, S, N) \
((__m128i) __builtin_ia32_vec_set_v4si ((__v4si)(__m128i)(D), \
(int)(S), (int)(N)))
#ifdef __x86_64__
#define _mm_insert_epi64(D, S, N) \
((__m128i) __builtin_ia32_vec_set_v2di ((__v2di)(__m128i)(D), \
(long long)(S), (int)(N)))
#endif
#endif
/* Extract integer from packed integer array element of X selected by
index N. */
#ifdef __OPTIMIZE__
extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_extract_epi8 (__m128i __X, const int __N)
{
return (unsigned char) __builtin_ia32_vec_ext_v16qi ((__v16qi)__X, __N);
}
extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_extract_epi32 (__m128i __X, const int __N)
{
return __builtin_ia32_vec_ext_v4si ((__v4si)__X, __N);
}
#ifdef __x86_64__
extern __inline long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_extract_epi64 (__m128i __X, const int __N)
{
return __builtin_ia32_vec_ext_v2di ((__v2di)__X, __N);
}
#endif
#else
#define _mm_extract_epi8(X, N) \
((int) (unsigned char) __builtin_ia32_vec_ext_v16qi ((__v16qi)(__m128i)(X), (int)(N)))
#define _mm_extract_epi32(X, N) \
((int) __builtin_ia32_vec_ext_v4si ((__v4si)(__m128i)(X), (int)(N)))
#ifdef __x86_64__
#define _mm_extract_epi64(X, N) \
((long long) __builtin_ia32_vec_ext_v2di ((__v2di)(__m128i)(X), (int)(N)))
#endif
#endif
/* Return horizontal packed word minimum and its index in bits [15:0]
and bits [18:16] respectively. */
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_minpos_epu16 (__m128i __X)
{
return (__m128i) __builtin_ia32_phminposuw128 ((__v8hi)__X);
}
/* Packed integer sign-extension. */
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cvtepi8_epi32 (__m128i __X)
{
return (__m128i) __builtin_ia32_pmovsxbd128 ((__v16qi)__X);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cvtepi16_epi32 (__m128i __X)
{
return (__m128i) __builtin_ia32_pmovsxwd128 ((__v8hi)__X);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cvtepi8_epi64 (__m128i __X)
{
return (__m128i) __builtin_ia32_pmovsxbq128 ((__v16qi)__X);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cvtepi32_epi64 (__m128i __X)
{
return (__m128i) __builtin_ia32_pmovsxdq128 ((__v4si)__X);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cvtepi16_epi64 (__m128i __X)
{
return (__m128i) __builtin_ia32_pmovsxwq128 ((__v8hi)__X);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cvtepi8_epi16 (__m128i __X)
{
return (__m128i) __builtin_ia32_pmovsxbw128 ((__v16qi)__X);
}
/* Packed integer zero-extension. */
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cvtepu8_epi32 (__m128i __X)
{
return (__m128i) __builtin_ia32_pmovzxbd128 ((__v16qi)__X);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cvtepu16_epi32 (__m128i __X)
{
return (__m128i) __builtin_ia32_pmovzxwd128 ((__v8hi)__X);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cvtepu8_epi64 (__m128i __X)
{
return (__m128i) __builtin_ia32_pmovzxbq128 ((__v16qi)__X);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cvtepu32_epi64 (__m128i __X)
{
return (__m128i) __builtin_ia32_pmovzxdq128 ((__v4si)__X);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cvtepu16_epi64 (__m128i __X)
{
return (__m128i) __builtin_ia32_pmovzxwq128 ((__v8hi)__X);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cvtepu8_epi16 (__m128i __X)
{
return (__m128i) __builtin_ia32_pmovzxbw128 ((__v16qi)__X);
}
/* Pack 8 double words from 2 operands into 8 words of result with
unsigned saturation. */
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_packus_epi32 (__m128i __X, __m128i __Y)
{
return (__m128i) __builtin_ia32_packusdw128 ((__v4si)__X, (__v4si)__Y);
}
/* Sum absolute 8-bit integer difference of adjacent groups of 4
byte integers in the first 2 operands. Starting offsets within
operands are determined by the 3rd mask operand. */
#ifdef __OPTIMIZE__
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_mpsadbw_epu8 (__m128i __X, __m128i __Y, const int __M)
{
return (__m128i) __builtin_ia32_mpsadbw128 ((__v16qi)__X,
(__v16qi)__Y, __M);
}
#else
#define _mm_mpsadbw_epu8(X, Y, M) \
((__m128i) __builtin_ia32_mpsadbw128 ((__v16qi)(__m128i)(X), \
(__v16qi)(__m128i)(Y), (int)(M)))
#endif
/* Load double quadword using non-temporal aligned hint. */
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_stream_load_si128 (__m128i *__X)
{
return (__m128i) __builtin_ia32_movntdqa ((__v2di *) __X);
}
#ifndef __SSE4_2__
#pragma GCC push_options
#pragma GCC target("sse4.2")
#define __DISABLE_SSE4_2__
#endif /* __SSE4_2__ */
/* These macros specify the source data format. */
#define _SIDD_UBYTE_OPS 0x00
#define _SIDD_UWORD_OPS 0x01
#define _SIDD_SBYTE_OPS 0x02
#define _SIDD_SWORD_OPS 0x03
/* These macros specify the comparison operation. */
#define _SIDD_CMP_EQUAL_ANY 0x00
#define _SIDD_CMP_RANGES 0x04
#define _SIDD_CMP_EQUAL_EACH 0x08
#define _SIDD_CMP_EQUAL_ORDERED 0x0c
/* These macros specify the polarity. */
#define _SIDD_POSITIVE_POLARITY 0x00
#define _SIDD_NEGATIVE_POLARITY 0x10
#define _SIDD_MASKED_POSITIVE_POLARITY 0x20
#define _SIDD_MASKED_NEGATIVE_POLARITY 0x30
/* These macros specify the output selection in _mm_cmpXstri (). */
#define _SIDD_LEAST_SIGNIFICANT 0x00
#define _SIDD_MOST_SIGNIFICANT 0x40
/* These macros specify the output selection in _mm_cmpXstrm (). */
#define _SIDD_BIT_MASK 0x00
#define _SIDD_UNIT_MASK 0x40
/* Intrinsics for text/string processing. */
#ifdef __OPTIMIZE__
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cmpistrm (__m128i __X, __m128i __Y, const int __M)
{
return (__m128i) __builtin_ia32_pcmpistrm128 ((__v16qi)__X,
(__v16qi)__Y,
__M);
}
extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cmpistri (__m128i __X, __m128i __Y, const int __M)
{
return __builtin_ia32_pcmpistri128 ((__v16qi)__X,
(__v16qi)__Y,
__M);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cmpestrm (__m128i __X, int __LX, __m128i __Y, int __LY, const int __M)
{
return (__m128i) __builtin_ia32_pcmpestrm128 ((__v16qi)__X, __LX,
(__v16qi)__Y, __LY,
__M);
}
extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cmpestri (__m128i __X, int __LX, __m128i __Y, int __LY, const int __M)
{
return __builtin_ia32_pcmpestri128 ((__v16qi)__X, __LX,
(__v16qi)__Y, __LY,
__M);
}
#else
#define _mm_cmpistrm(X, Y, M) \
((__m128i) __builtin_ia32_pcmpistrm128 ((__v16qi)(__m128i)(X), \
(__v16qi)(__m128i)(Y), (int)(M)))
#define _mm_cmpistri(X, Y, M) \
((int) __builtin_ia32_pcmpistri128 ((__v16qi)(__m128i)(X), \
(__v16qi)(__m128i)(Y), (int)(M)))
#define _mm_cmpestrm(X, LX, Y, LY, M) \
((__m128i) __builtin_ia32_pcmpestrm128 ((__v16qi)(__m128i)(X), \
(int)(LX), (__v16qi)(__m128i)(Y), \
(int)(LY), (int)(M)))
#define _mm_cmpestri(X, LX, Y, LY, M) \
((int) __builtin_ia32_pcmpestri128 ((__v16qi)(__m128i)(X), (int)(LX), \
(__v16qi)(__m128i)(Y), (int)(LY), \
(int)(M)))
#endif
/* Intrinsics for text/string processing and reading values of
EFlags. */
#ifdef __OPTIMIZE__
extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cmpistra (__m128i __X, __m128i __Y, const int __M)
{
return __builtin_ia32_pcmpistria128 ((__v16qi)__X,
(__v16qi)__Y,
__M);
}
extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cmpistrc (__m128i __X, __m128i __Y, const int __M)
{
return __builtin_ia32_pcmpistric128 ((__v16qi)__X,
(__v16qi)__Y,
__M);
}
extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cmpistro (__m128i __X, __m128i __Y, const int __M)
{
return __builtin_ia32_pcmpistrio128 ((__v16qi)__X,
(__v16qi)__Y,
__M);
}
extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cmpistrs (__m128i __X, __m128i __Y, const int __M)
{
return __builtin_ia32_pcmpistris128 ((__v16qi)__X,
(__v16qi)__Y,
__M);
}
extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cmpistrz (__m128i __X, __m128i __Y, const int __M)
{
return __builtin_ia32_pcmpistriz128 ((__v16qi)__X,
(__v16qi)__Y,
__M);
}
extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cmpestra (__m128i __X, int __LX, __m128i __Y, int __LY, const int __M)
{
return __builtin_ia32_pcmpestria128 ((__v16qi)__X, __LX,
(__v16qi)__Y, __LY,
__M);
}
extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cmpestrc (__m128i __X, int __LX, __m128i __Y, int __LY, const int __M)
{
return __builtin_ia32_pcmpestric128 ((__v16qi)__X, __LX,
(__v16qi)__Y, __LY,
__M);
}
extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cmpestro (__m128i __X, int __LX, __m128i __Y, int __LY, const int __M)
{
return __builtin_ia32_pcmpestrio128 ((__v16qi)__X, __LX,
(__v16qi)__Y, __LY,
__M);
}
extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cmpestrs (__m128i __X, int __LX, __m128i __Y, int __LY, const int __M)
{
return __builtin_ia32_pcmpestris128 ((__v16qi)__X, __LX,
(__v16qi)__Y, __LY,
__M);
}
extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cmpestrz (__m128i __X, int __LX, __m128i __Y, int __LY, const int __M)
{
return __builtin_ia32_pcmpestriz128 ((__v16qi)__X, __LX,
(__v16qi)__Y, __LY,
__M);
}
#else
#define _mm_cmpistra(X, Y, M) \
((int) __builtin_ia32_pcmpistria128 ((__v16qi)(__m128i)(X), \
(__v16qi)(__m128i)(Y), (int)(M)))
#define _mm_cmpistrc(X, Y, M) \
((int) __builtin_ia32_pcmpistric128 ((__v16qi)(__m128i)(X), \
(__v16qi)(__m128i)(Y), (int)(M)))
#define _mm_cmpistro(X, Y, M) \
((int) __builtin_ia32_pcmpistrio128 ((__v16qi)(__m128i)(X), \
(__v16qi)(__m128i)(Y), (int)(M)))
#define _mm_cmpistrs(X, Y, M) \
((int) __builtin_ia32_pcmpistris128 ((__v16qi)(__m128i)(X), \
(__v16qi)(__m128i)(Y), (int)(M)))
#define _mm_cmpistrz(X, Y, M) \
((int) __builtin_ia32_pcmpistriz128 ((__v16qi)(__m128i)(X), \
(__v16qi)(__m128i)(Y), (int)(M)))
#define _mm_cmpestra(X, LX, Y, LY, M) \
((int) __builtin_ia32_pcmpestria128 ((__v16qi)(__m128i)(X), (int)(LX), \
(__v16qi)(__m128i)(Y), (int)(LY), \
(int)(M)))
#define _mm_cmpestrc(X, LX, Y, LY, M) \
((int) __builtin_ia32_pcmpestric128 ((__v16qi)(__m128i)(X), (int)(LX), \
(__v16qi)(__m128i)(Y), (int)(LY), \
(int)(M)))
#define _mm_cmpestro(X, LX, Y, LY, M) \
((int) __builtin_ia32_pcmpestrio128 ((__v16qi)(__m128i)(X), (int)(LX), \
(__v16qi)(__m128i)(Y), (int)(LY), \
(int)(M)))
#define _mm_cmpestrs(X, LX, Y, LY, M) \
((int) __builtin_ia32_pcmpestris128 ((__v16qi)(__m128i)(X), (int)(LX), \
(__v16qi)(__m128i)(Y), (int)(LY), \
(int)(M)))
#define _mm_cmpestrz(X, LX, Y, LY, M) \
((int) __builtin_ia32_pcmpestriz128 ((__v16qi)(__m128i)(X), (int)(LX), \
(__v16qi)(__m128i)(Y), (int)(LY), \
(int)(M)))
#endif
/* Packed integer 64-bit comparison, zeroing or filling with ones
corresponding parts of result. */
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_cmpgt_epi64 (__m128i __X, __m128i __Y)
{
return (__m128i) ((__v2di)__X > (__v2di)__Y);
}
#ifdef __DISABLE_SSE4_2__
#undef __DISABLE_SSE4_2__
#pragma GCC pop_options
#endif /* __DISABLE_SSE4_2__ */
#ifdef __DISABLE_SSE4_1__
#undef __DISABLE_SSE4_1__
#pragma GCC pop_options
#endif /* __DISABLE_SSE4_1__ */
#include <popcntintrin.h>
#ifndef __SSE4_1__
#pragma GCC push_options
#pragma GCC target("sse4.1")
#define __DISABLE_SSE4_1__
#endif /* __SSE4_1__ */
#ifndef __SSE4_2__
#pragma GCC push_options
#pragma GCC target("sse4.2")
#define __DISABLE_SSE4_2__
#endif /* __SSE4_1__ */
/* Accumulate CRC32 (polynomial 0x11EDC6F41) value. */
extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_crc32_u8 (unsigned int __C, unsigned char __V)
{
return __builtin_ia32_crc32qi (__C, __V);
}
extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_crc32_u16 (unsigned int __C, unsigned short __V)
{
return __builtin_ia32_crc32hi (__C, __V);
}
extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_crc32_u32 (unsigned int __C, unsigned int __V)
{
return __builtin_ia32_crc32si (__C, __V);
}
#ifdef __x86_64__
extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_crc32_u64 (unsigned long long __C, unsigned long long __V)
{
return __builtin_ia32_crc32di (__C, __V);
}
#endif
#ifdef __DISABLE_SSE4_2__
#undef __DISABLE_SSE4_2__
#pragma GCC pop_options
#endif /* __DISABLE_SSE4_2__ */
#ifdef __DISABLE_SSE4_1__
#undef __DISABLE_SSE4_1__
#pragma GCC pop_options
#endif /* __DISABLE_SSE4_1__ */
#endif /* _SMMINTRIN_H_INCLUDED */
@@ -0,0 +1,39 @@
/* Copyright (C) 2011-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
/* ISO C1X: 7.15 Alignment <stdalign.h>. */
#ifndef _STDALIGN_H
#define _STDALIGN_H
#ifndef __cplusplus
#define alignas _Alignas
#define alignof _Alignof
#define __alignas_is_defined 1
#define __alignof_is_defined 1
#endif
#endif /* stdalign.h */
@@ -0,0 +1,127 @@
/* Copyright (C) 1989-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
/*
* ISO C Standard: 7.15 Variable arguments <stdarg.h>
*/
#ifndef _STDARG_H
#ifndef _ANSI_STDARG_H_
#ifndef __need___va_list
#define _STDARG_H
#define _ANSI_STDARG_H_
#endif /* not __need___va_list */
#undef __need___va_list
/* Define __gnuc_va_list. */
#ifndef __GNUC_VA_LIST
#define __GNUC_VA_LIST
typedef __builtin_va_list __gnuc_va_list;
#endif
/* Define the standard macros for the user,
if this invocation was from the user program. */
#ifdef _STDARG_H
#define va_start(v,l) __builtin_va_start(v,l)
#define va_end(v) __builtin_va_end(v)
#define va_arg(v,l) __builtin_va_arg(v,l)
#if !defined(__STRICT_ANSI__) || __STDC_VERSION__ + 0 >= 199900L \
|| __cplusplus + 0 >= 201103L
#define va_copy(d,s) __builtin_va_copy(d,s)
#endif
#define __va_copy(d,s) __builtin_va_copy(d,s)
/* Define va_list, if desired, from __gnuc_va_list. */
/* We deliberately do not define va_list when called from
stdio.h, because ANSI C says that stdio.h is not supposed to define
va_list. stdio.h needs to have access to that data type,
but must not use that name. It should use the name __gnuc_va_list,
which is safe because it is reserved for the implementation. */
#ifdef _BSD_VA_LIST
#undef _BSD_VA_LIST
#endif
#if defined(__svr4__) || (defined(_SCO_DS) && !defined(__VA_LIST))
/* SVR4.2 uses _VA_LIST for an internal alias for va_list,
so we must avoid testing it and setting it here.
SVR4 uses _VA_LIST as a flag in stdarg.h, but we should
have no conflict with that. */
#ifndef _VA_LIST_
#define _VA_LIST_
#ifdef __i860__
#ifndef _VA_LIST
#define _VA_LIST va_list
#endif
#endif /* __i860__ */
typedef __gnuc_va_list va_list;
#ifdef _SCO_DS
#define __VA_LIST
#endif
#endif /* _VA_LIST_ */
#else /* not __svr4__ || _SCO_DS */
/* The macro _VA_LIST_ is the same thing used by this file in Ultrix.
But on BSD NET2 we must not test or define or undef it.
(Note that the comments in NET 2's ansi.h
are incorrect for _VA_LIST_--see stdio.h!) */
#if !defined (_VA_LIST_) || defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__) || defined(WINNT)
/* The macro _VA_LIST_DEFINED is used in Windows NT 3.5 */
#ifndef _VA_LIST_DEFINED
/* The macro _VA_LIST is used in SCO Unix 3.2. */
#ifndef _VA_LIST
/* The macro _VA_LIST_T_H is used in the Bull dpx2 */
#ifndef _VA_LIST_T_H
/* The macro __va_list__ is used by BeOS. */
#ifndef __va_list__
typedef __gnuc_va_list va_list;
#endif /* not __va_list__ */
#endif /* not _VA_LIST_T_H */
#endif /* not _VA_LIST */
#endif /* not _VA_LIST_DEFINED */
#if !(defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__))
#define _VA_LIST_
#endif
#ifndef _VA_LIST
#define _VA_LIST
#endif
#ifndef _VA_LIST_DEFINED
#define _VA_LIST_DEFINED
#endif
#ifndef _VA_LIST_T_H
#define _VA_LIST_T_H
#endif
#ifndef __va_list__
#define __va_list__
#endif
#endif /* not _VA_LIST_, except on certain systems */
#endif /* not __svr4__ */
#endif /* _STDARG_H */
#endif /* not _ANSI_STDARG_H_ */
#endif /* not _STDARG_H */
@@ -0,0 +1,243 @@
/* Copyright (C) 2013-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
/* ISO C11 Standard: 7.17 Atomics <stdatomic.h>. */
#ifndef _STDATOMIC_H
#define _STDATOMIC_H
typedef enum
{
memory_order_relaxed = __ATOMIC_RELAXED,
memory_order_consume = __ATOMIC_CONSUME,
memory_order_acquire = __ATOMIC_ACQUIRE,
memory_order_release = __ATOMIC_RELEASE,
memory_order_acq_rel = __ATOMIC_ACQ_REL,
memory_order_seq_cst = __ATOMIC_SEQ_CST
} memory_order;
typedef _Atomic _Bool atomic_bool;
typedef _Atomic char atomic_char;
typedef _Atomic signed char atomic_schar;
typedef _Atomic unsigned char atomic_uchar;
typedef _Atomic short atomic_short;
typedef _Atomic unsigned short atomic_ushort;
typedef _Atomic int atomic_int;
typedef _Atomic unsigned int atomic_uint;
typedef _Atomic long atomic_long;
typedef _Atomic unsigned long atomic_ulong;
typedef _Atomic long long atomic_llong;
typedef _Atomic unsigned long long atomic_ullong;
typedef _Atomic __CHAR16_TYPE__ atomic_char16_t;
typedef _Atomic __CHAR32_TYPE__ atomic_char32_t;
typedef _Atomic __WCHAR_TYPE__ atomic_wchar_t;
typedef _Atomic __INT_LEAST8_TYPE__ atomic_int_least8_t;
typedef _Atomic __UINT_LEAST8_TYPE__ atomic_uint_least8_t;
typedef _Atomic __INT_LEAST16_TYPE__ atomic_int_least16_t;
typedef _Atomic __UINT_LEAST16_TYPE__ atomic_uint_least16_t;
typedef _Atomic __INT_LEAST32_TYPE__ atomic_int_least32_t;
typedef _Atomic __UINT_LEAST32_TYPE__ atomic_uint_least32_t;
typedef _Atomic __INT_LEAST64_TYPE__ atomic_int_least64_t;
typedef _Atomic __UINT_LEAST64_TYPE__ atomic_uint_least64_t;
typedef _Atomic __INT_FAST8_TYPE__ atomic_int_fast8_t;
typedef _Atomic __UINT_FAST8_TYPE__ atomic_uint_fast8_t;
typedef _Atomic __INT_FAST16_TYPE__ atomic_int_fast16_t;
typedef _Atomic __UINT_FAST16_TYPE__ atomic_uint_fast16_t;
typedef _Atomic __INT_FAST32_TYPE__ atomic_int_fast32_t;
typedef _Atomic __UINT_FAST32_TYPE__ atomic_uint_fast32_t;
typedef _Atomic __INT_FAST64_TYPE__ atomic_int_fast64_t;
typedef _Atomic __UINT_FAST64_TYPE__ atomic_uint_fast64_t;
typedef _Atomic __INTPTR_TYPE__ atomic_intptr_t;
typedef _Atomic __UINTPTR_TYPE__ atomic_uintptr_t;
typedef _Atomic __SIZE_TYPE__ atomic_size_t;
typedef _Atomic __PTRDIFF_TYPE__ atomic_ptrdiff_t;
typedef _Atomic __INTMAX_TYPE__ atomic_intmax_t;
typedef _Atomic __UINTMAX_TYPE__ atomic_uintmax_t;
#define ATOMIC_VAR_INIT(VALUE) (VALUE)
/* Initialize an atomic object pointed to by PTR with VAL. */
#define atomic_init(PTR, VAL) \
atomic_store_explicit (PTR, VAL, __ATOMIC_RELAXED)
#define kill_dependency(Y) \
__extension__ \
({ \
__auto_type __kill_dependency_tmp = (Y); \
__kill_dependency_tmp; \
})
extern void atomic_thread_fence (memory_order);
#define atomic_thread_fence(MO) __atomic_thread_fence (MO)
extern void atomic_signal_fence (memory_order);
#define atomic_signal_fence(MO) __atomic_signal_fence (MO)
#define atomic_is_lock_free(OBJ) __atomic_is_lock_free (sizeof (*(OBJ)), (OBJ))
#define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE
#define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE
#define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE
#define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE
#define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE
#define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE
#define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE
#define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE
#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE
#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE
/* Note that these macros require __typeof__ and __auto_type to remove
_Atomic qualifiers (and const qualifiers, if those are valid on
macro operands).
Also note that the header file uses the generic form of __atomic
builtins, which requires the address to be taken of the value
parameter, and then we pass that value on. This allows the macros
to work for any type, and the compiler is smart enough to convert
these to lock-free _N variants if possible, and throw away the
temps. */
#define atomic_store_explicit(PTR, VAL, MO) \
__extension__ \
({ \
__auto_type __atomic_store_ptr = (PTR); \
__typeof__ (*__atomic_store_ptr) __atomic_store_tmp = (VAL); \
__atomic_store (__atomic_store_ptr, &__atomic_store_tmp, (MO)); \
})
#define atomic_store(PTR, VAL) \
atomic_store_explicit (PTR, VAL, __ATOMIC_SEQ_CST)
#define atomic_load_explicit(PTR, MO) \
__extension__ \
({ \
__auto_type __atomic_load_ptr = (PTR); \
__typeof__ (*__atomic_load_ptr) __atomic_load_tmp; \
__atomic_load (__atomic_load_ptr, &__atomic_load_tmp, (MO)); \
__atomic_load_tmp; \
})
#define atomic_load(PTR) atomic_load_explicit (PTR, __ATOMIC_SEQ_CST)
#define atomic_exchange_explicit(PTR, VAL, MO) \
__extension__ \
({ \
__auto_type __atomic_exchange_ptr = (PTR); \
__typeof__ (*__atomic_exchange_ptr) __atomic_exchange_val = (VAL); \
__typeof__ (*__atomic_exchange_ptr) __atomic_exchange_tmp; \
__atomic_exchange (__atomic_exchange_ptr, &__atomic_exchange_val, \
&__atomic_exchange_tmp, (MO)); \
__atomic_exchange_tmp; \
})
#define atomic_exchange(PTR, VAL) \
atomic_exchange_explicit (PTR, VAL, __ATOMIC_SEQ_CST)
#define atomic_compare_exchange_strong_explicit(PTR, VAL, DES, SUC, FAIL) \
__extension__ \
({ \
__auto_type __atomic_compare_exchange_ptr = (PTR); \
__typeof__ (*__atomic_compare_exchange_ptr) __atomic_compare_exchange_tmp \
= (DES); \
__atomic_compare_exchange (__atomic_compare_exchange_ptr, (VAL), \
&__atomic_compare_exchange_tmp, 0, \
(SUC), (FAIL)); \
})
#define atomic_compare_exchange_strong(PTR, VAL, DES) \
atomic_compare_exchange_strong_explicit (PTR, VAL, DES, __ATOMIC_SEQ_CST, \
__ATOMIC_SEQ_CST)
#define atomic_compare_exchange_weak_explicit(PTR, VAL, DES, SUC, FAIL) \
__extension__ \
({ \
__auto_type __atomic_compare_exchange_ptr = (PTR); \
__typeof__ (*__atomic_compare_exchange_ptr) __atomic_compare_exchange_tmp \
= (DES); \
__atomic_compare_exchange (__atomic_compare_exchange_ptr, (VAL), \
&__atomic_compare_exchange_tmp, 1, \
(SUC), (FAIL)); \
})
#define atomic_compare_exchange_weak(PTR, VAL, DES) \
atomic_compare_exchange_weak_explicit (PTR, VAL, DES, __ATOMIC_SEQ_CST, \
__ATOMIC_SEQ_CST)
#define atomic_fetch_add(PTR, VAL) __atomic_fetch_add ((PTR), (VAL), \
__ATOMIC_SEQ_CST)
#define atomic_fetch_add_explicit(PTR, VAL, MO) \
__atomic_fetch_add ((PTR), (VAL), (MO))
#define atomic_fetch_sub(PTR, VAL) __atomic_fetch_sub ((PTR), (VAL), \
__ATOMIC_SEQ_CST)
#define atomic_fetch_sub_explicit(PTR, VAL, MO) \
__atomic_fetch_sub ((PTR), (VAL), (MO))
#define atomic_fetch_or(PTR, VAL) __atomic_fetch_or ((PTR), (VAL), \
__ATOMIC_SEQ_CST)
#define atomic_fetch_or_explicit(PTR, VAL, MO) \
__atomic_fetch_or ((PTR), (VAL), (MO))
#define atomic_fetch_xor(PTR, VAL) __atomic_fetch_xor ((PTR), (VAL), \
__ATOMIC_SEQ_CST)
#define atomic_fetch_xor_explicit(PTR, VAL, MO) \
__atomic_fetch_xor ((PTR), (VAL), (MO))
#define atomic_fetch_and(PTR, VAL) __atomic_fetch_and ((PTR), (VAL), \
__ATOMIC_SEQ_CST)
#define atomic_fetch_and_explicit(PTR, VAL, MO) \
__atomic_fetch_and ((PTR), (VAL), (MO))
typedef _Atomic struct
{
#if __GCC_ATOMIC_TEST_AND_SET_TRUEVAL == 1
_Bool __val;
#else
unsigned char __val;
#endif
} atomic_flag;
#define ATOMIC_FLAG_INIT { 0 }
extern _Bool atomic_flag_test_and_set (volatile atomic_flag *);
#define atomic_flag_test_and_set(PTR) \
__atomic_test_and_set ((PTR), __ATOMIC_SEQ_CST)
extern _Bool atomic_flag_test_and_set_explicit (volatile atomic_flag *,
memory_order);
#define atomic_flag_test_and_set_explicit(PTR, MO) \
__atomic_test_and_set ((PTR), (MO))
extern void atomic_flag_clear (volatile atomic_flag *);
#define atomic_flag_clear(PTR) __atomic_clear ((PTR), __ATOMIC_SEQ_CST)
extern void atomic_flag_clear_explicit (volatile atomic_flag *, memory_order);
#define atomic_flag_clear_explicit(PTR, MO) __atomic_clear ((PTR), (MO))
#endif /* _STDATOMIC_H */
@@ -0,0 +1,54 @@
/* Copyright (C) 1998-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
/*
* ISO C Standard: 7.16 Boolean type and values <stdbool.h>
*/
#ifndef _STDBOOL_H
#define _STDBOOL_H
#ifndef __cplusplus
#define bool _Bool
#define true 1
#define false 0
#else /* __cplusplus */
/* Supporting _Bool in C++ is a GCC extension. */
#define _Bool bool
#if __cplusplus < 201103L
/* Defining these macros in C++98 is a GCC extension. */
#define bool bool
#define false false
#define true true
#endif
#endif /* __cplusplus */
/* Signal that all the definitions are present. */
#define __bool_true_false_are_defined 1
#endif /* stdbool.h */
@@ -0,0 +1,451 @@
/* Copyright (C) 1989-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
/*
* ISO C Standard: 7.17 Common definitions <stddef.h>
*/
#if (!defined(_STDDEF_H) && !defined(_STDDEF_H_) && !defined(_ANSI_STDDEF_H) \
&& !defined(__STDDEF_H__)) \
|| defined(__need_wchar_t) || defined(__need_size_t) \
|| defined(__need_ptrdiff_t) || defined(__need_NULL) \
|| defined(__need_wint_t)
/* Any one of these symbols __need_* means that GNU libc
wants us just to define one data type. So don't define
the symbols that indicate this file's entire job has been done. */
#if (!defined(__need_wchar_t) && !defined(__need_size_t) \
&& !defined(__need_ptrdiff_t) && !defined(__need_NULL) \
&& !defined(__need_wint_t))
#define _STDDEF_H
#define _STDDEF_H_
/* snaroff@next.com says the NeXT needs this. */
#define _ANSI_STDDEF_H
#endif
#ifndef __sys_stdtypes_h
/* This avoids lossage on SunOS but only if stdtypes.h comes first.
There's no way to win with the other order! Sun lossage. */
/* On 4.3bsd-net2, make sure ansi.h is included, so we have
one less case to deal with in the following. */
#if defined (__BSD_NET2__) || defined (____386BSD____) || (defined (__FreeBSD__) && (__FreeBSD__ < 5)) || defined(__NetBSD__)
#include <machine/ansi.h>
#endif
/* On FreeBSD 5, machine/ansi.h does not exist anymore... */
#if defined (__FreeBSD__) && (__FreeBSD__ >= 5)
#include <sys/_types.h>
#endif
/* In 4.3bsd-net2, machine/ansi.h defines these symbols, which are
defined if the corresponding type is *not* defined.
FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_.
NetBSD defines _I386_ANSI_H_ and _X86_64_ANSI_H_ instead of _ANSI_H_ */
#if defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) || defined(_X86_64_ANSI_H_) || defined(_I386_ANSI_H_)
#if !defined(_SIZE_T_) && !defined(_BSD_SIZE_T_)
#define _SIZE_T
#endif
#if !defined(_PTRDIFF_T_) && !defined(_BSD_PTRDIFF_T_)
#define _PTRDIFF_T
#endif
/* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_
instead of _WCHAR_T_. */
#if !defined(_WCHAR_T_) && !defined(_BSD_WCHAR_T_)
#ifndef _BSD_WCHAR_T_
#define _WCHAR_T
#endif
#endif
/* Undef _FOO_T_ if we are supposed to define foo_t. */
#if defined (__need_ptrdiff_t) || defined (_STDDEF_H_)
#undef _PTRDIFF_T_
#undef _BSD_PTRDIFF_T_
#endif
#if defined (__need_size_t) || defined (_STDDEF_H_)
#undef _SIZE_T_
#undef _BSD_SIZE_T_
#endif
#if defined (__need_wchar_t) || defined (_STDDEF_H_)
#undef _WCHAR_T_
#undef _BSD_WCHAR_T_
#endif
#endif /* defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) || defined(_X86_64_ANSI_H_) || defined(_I386_ANSI_H_) */
/* Sequent's header files use _PTRDIFF_T_ in some conflicting way.
Just ignore it. */
#if defined (__sequent__) && defined (_PTRDIFF_T_)
#undef _PTRDIFF_T_
#endif
/* On VxWorks, <type/vxTypesBase.h> may have defined macros like
_TYPE_size_t which will typedef size_t. fixincludes patched the
vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is
not defined, and so that defining this macro defines _GCC_SIZE_T.
If we find that the macros are still defined at this point, we must
invoke them so that the type is defined as expected. */
#if defined (_TYPE_ptrdiff_t) && (defined (__need_ptrdiff_t) || defined (_STDDEF_H_))
_TYPE_ptrdiff_t;
#undef _TYPE_ptrdiff_t
#endif
#if defined (_TYPE_size_t) && (defined (__need_size_t) || defined (_STDDEF_H_))
_TYPE_size_t;
#undef _TYPE_size_t
#endif
#if defined (_TYPE_wchar_t) && (defined (__need_wchar_t) || defined (_STDDEF_H_))
_TYPE_wchar_t;
#undef _TYPE_wchar_t
#endif
/* In case nobody has defined these types, but we aren't running under
GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and
__WCHAR_TYPE__ have reasonable values. This can happen if the
parts of GCC is compiled by an older compiler, that actually
include gstddef.h, such as collect2. */
/* Signed type of difference of two pointers. */
/* Define this type if we are doing the whole job,
or if we want this type in particular. */
#if defined (_STDDEF_H) || defined (__need_ptrdiff_t)
#ifndef _PTRDIFF_T /* in case <sys/types.h> has defined it. */
#ifndef _T_PTRDIFF_
#ifndef _T_PTRDIFF
#ifndef __PTRDIFF_T
#ifndef _PTRDIFF_T_
#ifndef _BSD_PTRDIFF_T_
#ifndef ___int_ptrdiff_t_h
#ifndef _GCC_PTRDIFF_T
#ifndef _PTRDIFF_T_DECLARED /* DragonFly */
#define _PTRDIFF_T
#define _T_PTRDIFF_
#define _T_PTRDIFF
#define __PTRDIFF_T
#define _PTRDIFF_T_
#define _BSD_PTRDIFF_T_
#define ___int_ptrdiff_t_h
#define _GCC_PTRDIFF_T
#define _PTRDIFF_T_DECLARED
#ifndef __PTRDIFF_TYPE__
#define __PTRDIFF_TYPE__ long int
#endif
typedef __PTRDIFF_TYPE__ ptrdiff_t;
#endif /* _PTRDIFF_T_DECLARED */
#endif /* _GCC_PTRDIFF_T */
#endif /* ___int_ptrdiff_t_h */
#endif /* _BSD_PTRDIFF_T_ */
#endif /* _PTRDIFF_T_ */
#endif /* __PTRDIFF_T */
#endif /* _T_PTRDIFF */
#endif /* _T_PTRDIFF_ */
#endif /* _PTRDIFF_T */
/* If this symbol has done its job, get rid of it. */
#undef __need_ptrdiff_t
#endif /* _STDDEF_H or __need_ptrdiff_t. */
/* Unsigned type of `sizeof' something. */
/* Define this type if we are doing the whole job,
or if we want this type in particular. */
#if defined (_STDDEF_H) || defined (__need_size_t)
#ifndef __size_t__ /* BeOS */
#ifndef __SIZE_T__ /* Cray Unicos/Mk */
#ifndef _SIZE_T /* in case <sys/types.h> has defined it. */
#ifndef _SYS_SIZE_T_H
#ifndef _T_SIZE_
#ifndef _T_SIZE
#ifndef __SIZE_T
#ifndef _SIZE_T_
#ifndef _BSD_SIZE_T_
#ifndef _SIZE_T_DEFINED_
#ifndef _SIZE_T_DEFINED
#ifndef _BSD_SIZE_T_DEFINED_ /* Darwin */
#ifndef _SIZE_T_DECLARED /* FreeBSD 5 */
#ifndef ___int_size_t_h
#ifndef _GCC_SIZE_T
#ifndef _SIZET_
#ifndef __size_t
#define __size_t__ /* BeOS */
#define __SIZE_T__ /* Cray Unicos/Mk */
#define _SIZE_T
#define _SYS_SIZE_T_H
#define _T_SIZE_
#define _T_SIZE
#define __SIZE_T
#define _SIZE_T_
#define _BSD_SIZE_T_
#define _SIZE_T_DEFINED_
#define _SIZE_T_DEFINED
#define _BSD_SIZE_T_DEFINED_ /* Darwin */
#define _SIZE_T_DECLARED /* FreeBSD 5 */
#define ___int_size_t_h
#define _GCC_SIZE_T
#define _SIZET_
#if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \
|| defined(__DragonFly__) \
|| defined(__FreeBSD_kernel__)
/* __size_t is a typedef on FreeBSD 5, must not trash it. */
#elif defined (__VMS__)
/* __size_t is also a typedef on VMS. */
#else
#define __size_t
#endif
#ifndef __SIZE_TYPE__
#define __SIZE_TYPE__ long unsigned int
#endif
#if !(defined (__GNUG__) && defined (size_t))
typedef __SIZE_TYPE__ size_t;
#ifdef __BEOS__
typedef long ssize_t;
#endif /* __BEOS__ */
#endif /* !(defined (__GNUG__) && defined (size_t)) */
#endif /* __size_t */
#endif /* _SIZET_ */
#endif /* _GCC_SIZE_T */
#endif /* ___int_size_t_h */
#endif /* _SIZE_T_DECLARED */
#endif /* _BSD_SIZE_T_DEFINED_ */
#endif /* _SIZE_T_DEFINED */
#endif /* _SIZE_T_DEFINED_ */
#endif /* _BSD_SIZE_T_ */
#endif /* _SIZE_T_ */
#endif /* __SIZE_T */
#endif /* _T_SIZE */
#endif /* _T_SIZE_ */
#endif /* _SYS_SIZE_T_H */
#endif /* _SIZE_T */
#endif /* __SIZE_T__ */
#endif /* __size_t__ */
#undef __need_size_t
#endif /* _STDDEF_H or __need_size_t. */
/* Wide character type.
Locale-writers should change this as necessary to
be big enough to hold unique values not between 0 and 127,
and not (wchar_t) -1, for each defined multibyte character. */
/* Define this type if we are doing the whole job,
or if we want this type in particular. */
#if defined (_STDDEF_H) || defined (__need_wchar_t)
#ifndef __wchar_t__ /* BeOS */
#ifndef __WCHAR_T__ /* Cray Unicos/Mk */
#ifndef _WCHAR_T
#ifndef _T_WCHAR_
#ifndef _T_WCHAR
#ifndef __WCHAR_T
#ifndef _WCHAR_T_
#ifndef _BSD_WCHAR_T_
#ifndef _BSD_WCHAR_T_DEFINED_ /* Darwin */
#ifndef _BSD_RUNE_T_DEFINED_ /* Darwin */
#ifndef _WCHAR_T_DECLARED /* FreeBSD 5 */
#ifndef _WCHAR_T_DEFINED_
#ifndef _WCHAR_T_DEFINED
#ifndef _WCHAR_T_H
#ifndef ___int_wchar_t_h
#ifndef __INT_WCHAR_T_H
#ifndef _GCC_WCHAR_T
#define __wchar_t__ /* BeOS */
#define __WCHAR_T__ /* Cray Unicos/Mk */
#define _WCHAR_T
#define _T_WCHAR_
#define _T_WCHAR
#define __WCHAR_T
#define _WCHAR_T_
#define _BSD_WCHAR_T_
#define _WCHAR_T_DEFINED_
#define _WCHAR_T_DEFINED
#define _WCHAR_T_H
#define ___int_wchar_t_h
#define __INT_WCHAR_T_H
#define _GCC_WCHAR_T
#define _WCHAR_T_DECLARED
/* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_
instead of _WCHAR_T_, and _BSD_RUNE_T_ (which, unlike the other
symbols in the _FOO_T_ family, stays defined even after its
corresponding type is defined). If we define wchar_t, then we
must undef _WCHAR_T_; for BSD/386 1.1 (and perhaps others), if
we undef _WCHAR_T_, then we must also define rune_t, since
headers like runetype.h assume that if machine/ansi.h is included,
and _BSD_WCHAR_T_ is not defined, then rune_t is available.
machine/ansi.h says, "Note that _WCHAR_T_ and _RUNE_T_ must be of
the same type." */
#ifdef _BSD_WCHAR_T_
#undef _BSD_WCHAR_T_
#ifdef _BSD_RUNE_T_
#if !defined (_ANSI_SOURCE) && !defined (_POSIX_SOURCE)
typedef _BSD_RUNE_T_ rune_t;
#define _BSD_WCHAR_T_DEFINED_
#define _BSD_RUNE_T_DEFINED_ /* Darwin */
#if defined (__FreeBSD__) && (__FreeBSD__ < 5)
/* Why is this file so hard to maintain properly? In contrast to
the comment above regarding BSD/386 1.1, on FreeBSD for as long
as the symbol has existed, _BSD_RUNE_T_ must not stay defined or
redundant typedefs will occur when stdlib.h is included after this file. */
#undef _BSD_RUNE_T_
#endif
#endif
#endif
#endif
/* FreeBSD 5 can't be handled well using "traditional" logic above
since it no longer defines _BSD_RUNE_T_ yet still desires to export
rune_t in some cases... */
#if defined (__FreeBSD__) && (__FreeBSD__ >= 5)
#if !defined (_ANSI_SOURCE) && !defined (_POSIX_SOURCE)
#if __BSD_VISIBLE
#ifndef _RUNE_T_DECLARED
typedef __rune_t rune_t;
#define _RUNE_T_DECLARED
#endif
#endif
#endif
#endif
#ifndef __WCHAR_TYPE__
#define __WCHAR_TYPE__ int
#endif
#ifndef __cplusplus
typedef __WCHAR_TYPE__ wchar_t;
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif /* _WCHAR_T_DECLARED */
#endif /* _BSD_RUNE_T_DEFINED_ */
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif /* __WCHAR_T__ */
#endif /* __wchar_t__ */
#undef __need_wchar_t
#endif /* _STDDEF_H or __need_wchar_t. */
#if defined (__need_wint_t)
#ifndef _WINT_T
#define _WINT_T
#ifndef __WINT_TYPE__
#define __WINT_TYPE__ unsigned int
#endif
typedef __WINT_TYPE__ wint_t;
#endif
#undef __need_wint_t
#endif
/* In 4.3bsd-net2, leave these undefined to indicate that size_t, etc.
are already defined. */
/* BSD/OS 3.1 and FreeBSD [23].x require the MACHINE_ANSI_H check here. */
/* NetBSD 5 requires the I386_ANSI_H and X86_64_ANSI_H checks here. */
#if defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) || defined(_X86_64_ANSI_H_) || defined(_I386_ANSI_H_)
/* The references to _GCC_PTRDIFF_T_, _GCC_SIZE_T_, and _GCC_WCHAR_T_
are probably typos and should be removed before 2.8 is released. */
#ifdef _GCC_PTRDIFF_T_
#undef _PTRDIFF_T_
#undef _BSD_PTRDIFF_T_
#endif
#ifdef _GCC_SIZE_T_
#undef _SIZE_T_
#undef _BSD_SIZE_T_
#endif
#ifdef _GCC_WCHAR_T_
#undef _WCHAR_T_
#undef _BSD_WCHAR_T_
#endif
/* The following ones are the real ones. */
#ifdef _GCC_PTRDIFF_T
#undef _PTRDIFF_T_
#undef _BSD_PTRDIFF_T_
#endif
#ifdef _GCC_SIZE_T
#undef _SIZE_T_
#undef _BSD_SIZE_T_
#endif
#ifdef _GCC_WCHAR_T
#undef _WCHAR_T_
#undef _BSD_WCHAR_T_
#endif
#endif /* _ANSI_H_ || _MACHINE_ANSI_H_ || _X86_64_ANSI_H_ || _I386_ANSI_H_ */
#endif /* __sys_stdtypes_h */
/* A null pointer constant. */
#if defined (_STDDEF_H) || defined (__need_NULL)
#undef NULL /* in case <stdio.h> has defined it. */
#ifdef __GNUG__
#define NULL __null
#else /* G++ */
#ifndef __cplusplus
#define NULL ((void *)0)
#else /* C++ */
#define NULL 0
#endif /* C++ */
#endif /* G++ */
#endif /* NULL not defined and <stddef.h> or need NULL. */
#undef __need_NULL
#ifdef _STDDEF_H
/* Offset of member MEMBER in a struct of type TYPE. */
#define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)
#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) \
|| (defined(__cplusplus) && __cplusplus >= 201103L)
#ifndef _GCC_MAX_ALIGN_T
#define _GCC_MAX_ALIGN_T
/* Type whose alignment is supported in every context and is at least
as great as that of any standard type not using alignment
specifiers. */
typedef struct {
long long __max_align_ll __attribute__((__aligned__(__alignof__(long long))));
long double __max_align_ld __attribute__((__aligned__(__alignof__(long double))));
/* _Float128 is defined as a basic type, so max_align_t must be
sufficiently aligned for it. This code must work in C++, so we
use __float128 here; that is only available on some
architectures, but only on i386 is extra alignment needed for
__float128. */
#ifdef __i386__
__float128 __max_align_f128 __attribute__((__aligned__(__alignof(__float128))));
#endif
} max_align_t;
#endif
#endif /* C11 or C++11. */
#if defined(__cplusplus) && __cplusplus >= 201103L
#ifndef _GXX_NULLPTR_T
#define _GXX_NULLPTR_T
typedef decltype(nullptr) nullptr_t;
#endif
#endif /* C++11. */
#endif /* _STDDEF_H was defined this time */
#endif /* !_STDDEF_H && !_STDDEF_H_ && !_ANSI_STDDEF_H && !__STDDEF_H__
|| __need_XXX was not defined before */
@@ -0,0 +1,204 @@
/* Copyright (C) 2007-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
/* ISO/IEC JTC1 SC22 WG14 N1169
* Date: 2006-04-04
* ISO/IEC TR 18037
* Programming languages - C - Extensions to support embedded processors
*/
#ifndef _STDFIX_H
#define _STDFIX_H
/* 7.18a.1 Introduction. */
#undef fract
#undef accum
#undef sat
#define fract _Fract
#define accum _Accum
#define sat _Sat
/* 7.18a.3 Precision macros. */
#undef SFRACT_FBIT
#undef SFRACT_MIN
#undef SFRACT_MAX
#undef SFRACT_EPSILON
#define SFRACT_FBIT __SFRACT_FBIT__
#define SFRACT_MIN __SFRACT_MIN__
#define SFRACT_MAX __SFRACT_MAX__
#define SFRACT_EPSILON __SFRACT_EPSILON__
#undef USFRACT_FBIT
#undef USFRACT_MIN
#undef USFRACT_MAX
#undef USFRACT_EPSILON
#define USFRACT_FBIT __USFRACT_FBIT__
#define USFRACT_MIN __USFRACT_MIN__ /* GCC extension. */
#define USFRACT_MAX __USFRACT_MAX__
#define USFRACT_EPSILON __USFRACT_EPSILON__
#undef FRACT_FBIT
#undef FRACT_MIN
#undef FRACT_MAX
#undef FRACT_EPSILON
#define FRACT_FBIT __FRACT_FBIT__
#define FRACT_MIN __FRACT_MIN__
#define FRACT_MAX __FRACT_MAX__
#define FRACT_EPSILON __FRACT_EPSILON__
#undef UFRACT_FBIT
#undef UFRACT_MIN
#undef UFRACT_MAX
#undef UFRACT_EPSILON
#define UFRACT_FBIT __UFRACT_FBIT__
#define UFRACT_MIN __UFRACT_MIN__ /* GCC extension. */
#define UFRACT_MAX __UFRACT_MAX__
#define UFRACT_EPSILON __UFRACT_EPSILON__
#undef LFRACT_FBIT
#undef LFRACT_MIN
#undef LFRACT_MAX
#undef LFRACT_EPSILON
#define LFRACT_FBIT __LFRACT_FBIT__
#define LFRACT_MIN __LFRACT_MIN__
#define LFRACT_MAX __LFRACT_MAX__
#define LFRACT_EPSILON __LFRACT_EPSILON__
#undef ULFRACT_FBIT
#undef ULFRACT_MIN
#undef ULFRACT_MAX
#undef ULFRACT_EPSILON
#define ULFRACT_FBIT __ULFRACT_FBIT__
#define ULFRACT_MIN __ULFRACT_MIN__ /* GCC extension. */
#define ULFRACT_MAX __ULFRACT_MAX__
#define ULFRACT_EPSILON __ULFRACT_EPSILON__
#undef LLFRACT_FBIT
#undef LLFRACT_MIN
#undef LLFRACT_MAX
#undef LLFRACT_EPSILON
#define LLFRACT_FBIT __LLFRACT_FBIT__ /* GCC extension. */
#define LLFRACT_MIN __LLFRACT_MIN__ /* GCC extension. */
#define LLFRACT_MAX __LLFRACT_MAX__ /* GCC extension. */
#define LLFRACT_EPSILON __LLFRACT_EPSILON__ /* GCC extension. */
#undef ULLFRACT_FBIT
#undef ULLFRACT_MIN
#undef ULLFRACT_MAX
#undef ULLFRACT_EPSILON
#define ULLFRACT_FBIT __ULLFRACT_FBIT__ /* GCC extension. */
#define ULLFRACT_MIN __ULLFRACT_MIN__ /* GCC extension. */
#define ULLFRACT_MAX __ULLFRACT_MAX__ /* GCC extension. */
#define ULLFRACT_EPSILON __ULLFRACT_EPSILON__ /* GCC extension. */
#undef SACCUM_FBIT
#undef SACCUM_IBIT
#undef SACCUM_MIN
#undef SACCUM_MAX
#undef SACCUM_EPSILON
#define SACCUM_FBIT __SACCUM_FBIT__
#define SACCUM_IBIT __SACCUM_IBIT__
#define SACCUM_MIN __SACCUM_MIN__
#define SACCUM_MAX __SACCUM_MAX__
#define SACCUM_EPSILON __SACCUM_EPSILON__
#undef USACCUM_FBIT
#undef USACCUM_IBIT
#undef USACCUM_MIN
#undef USACCUM_MAX
#undef USACCUM_EPSILON
#define USACCUM_FBIT __USACCUM_FBIT__
#define USACCUM_IBIT __USACCUM_IBIT__
#define USACCUM_MIN __USACCUM_MIN__ /* GCC extension. */
#define USACCUM_MAX __USACCUM_MAX__
#define USACCUM_EPSILON __USACCUM_EPSILON__
#undef ACCUM_FBIT
#undef ACCUM_IBIT
#undef ACCUM_MIN
#undef ACCUM_MAX
#undef ACCUM_EPSILON
#define ACCUM_FBIT __ACCUM_FBIT__
#define ACCUM_IBIT __ACCUM_IBIT__
#define ACCUM_MIN __ACCUM_MIN__
#define ACCUM_MAX __ACCUM_MAX__
#define ACCUM_EPSILON __ACCUM_EPSILON__
#undef UACCUM_FBIT
#undef UACCUM_IBIT
#undef UACCUM_MIN
#undef UACCUM_MAX
#undef UACCUM_EPSILON
#define UACCUM_FBIT __UACCUM_FBIT__
#define UACCUM_IBIT __UACCUM_IBIT__
#define UACCUM_MIN __UACCUM_MIN__ /* GCC extension. */
#define UACCUM_MAX __UACCUM_MAX__
#define UACCUM_EPSILON __UACCUM_EPSILON__
#undef LACCUM_FBIT
#undef LACCUM_IBIT
#undef LACCUM_MIN
#undef LACCUM_MAX
#undef LACCUM_EPSILON
#define LACCUM_FBIT __LACCUM_FBIT__
#define LACCUM_IBIT __LACCUM_IBIT__
#define LACCUM_MIN __LACCUM_MIN__
#define LACCUM_MAX __LACCUM_MAX__
#define LACCUM_EPSILON __LACCUM_EPSILON__
#undef ULACCUM_FBIT
#undef ULACCUM_IBIT
#undef ULACCUM_MIN
#undef ULACCUM_MAX
#undef ULACCUM_EPSILON
#define ULACCUM_FBIT __ULACCUM_FBIT__
#define ULACCUM_IBIT __ULACCUM_IBIT__
#define ULACCUM_MIN __ULACCUM_MIN__ /* GCC extension. */
#define ULACCUM_MAX __ULACCUM_MAX__
#define ULACCUM_EPSILON __ULACCUM_EPSILON__
#undef LLACCUM_FBIT
#undef LLACCUM_IBIT
#undef LLACCUM_MIN
#undef LLACCUM_MAX
#undef LLACCUM_EPSILON
#define LLACCUM_FBIT __LLACCUM_FBIT__ /* GCC extension. */
#define LLACCUM_IBIT __LLACCUM_IBIT__ /* GCC extension. */
#define LLACCUM_MIN __LLACCUM_MIN__ /* GCC extension. */
#define LLACCUM_MAX __LLACCUM_MAX__ /* GCC extension. */
#define LLACCUM_EPSILON __LLACCUM_EPSILON__ /* GCC extension. */
#undef ULLACCUM_FBIT
#undef ULLACCUM_IBIT
#undef ULLACCUM_MIN
#undef ULLACCUM_MAX
#undef ULLACCUM_EPSILON
#define ULLACCUM_FBIT __ULLACCUM_FBIT__ /* GCC extension. */
#define ULLACCUM_IBIT __ULLACCUM_IBIT__ /* GCC extension. */
#define ULLACCUM_MIN __ULLACCUM_MIN__ /* GCC extension. */
#define ULLACCUM_MAX __ULLACCUM_MAX__ /* GCC extension. */
#define ULLACCUM_EPSILON __ULLACCUM_EPSILON__ /* GCC extension. */
#endif /* _STDFIX_H */
@@ -0,0 +1,364 @@
/* Copyright (C) 2008-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
/*
* ISO C Standard: 7.18 Integer types <stdint.h>
*/
#ifndef _GCC_STDINT_H
#define _GCC_STDINT_H
/* 7.8.1.1 Exact-width integer types */
#ifdef __INT8_TYPE__
typedef __INT8_TYPE__ int8_t;
#endif
#ifdef __INT16_TYPE__
typedef __INT16_TYPE__ int16_t;
#endif
#ifdef __INT32_TYPE__
typedef __INT32_TYPE__ int32_t;
#endif
#ifdef __INT64_TYPE__
typedef __INT64_TYPE__ int64_t;
#endif
#ifdef __UINT8_TYPE__
typedef __UINT8_TYPE__ uint8_t;
#endif
#ifdef __UINT16_TYPE__
typedef __UINT16_TYPE__ uint16_t;
#endif
#ifdef __UINT32_TYPE__
typedef __UINT32_TYPE__ uint32_t;
#endif
#ifdef __UINT64_TYPE__
typedef __UINT64_TYPE__ uint64_t;
#endif
/* 7.8.1.2 Minimum-width integer types */
typedef __INT_LEAST8_TYPE__ int_least8_t;
typedef __INT_LEAST16_TYPE__ int_least16_t;
typedef __INT_LEAST32_TYPE__ int_least32_t;
typedef __INT_LEAST64_TYPE__ int_least64_t;
typedef __UINT_LEAST8_TYPE__ uint_least8_t;
typedef __UINT_LEAST16_TYPE__ uint_least16_t;
typedef __UINT_LEAST32_TYPE__ uint_least32_t;
typedef __UINT_LEAST64_TYPE__ uint_least64_t;
/* 7.8.1.3 Fastest minimum-width integer types */
typedef __INT_FAST8_TYPE__ int_fast8_t;
typedef __INT_FAST16_TYPE__ int_fast16_t;
typedef __INT_FAST32_TYPE__ int_fast32_t;
typedef __INT_FAST64_TYPE__ int_fast64_t;
typedef __UINT_FAST8_TYPE__ uint_fast8_t;
typedef __UINT_FAST16_TYPE__ uint_fast16_t;
typedef __UINT_FAST32_TYPE__ uint_fast32_t;
typedef __UINT_FAST64_TYPE__ uint_fast64_t;
/* 7.8.1.4 Integer types capable of holding object pointers */
#ifdef __INTPTR_TYPE__
typedef __INTPTR_TYPE__ intptr_t;
#endif
#ifdef __UINTPTR_TYPE__
typedef __UINTPTR_TYPE__ uintptr_t;
#endif
/* 7.8.1.5 Greatest-width integer types */
typedef __INTMAX_TYPE__ intmax_t;
typedef __UINTMAX_TYPE__ uintmax_t;
#if (!defined __cplusplus || __cplusplus >= 201103L \
|| defined __STDC_LIMIT_MACROS)
/* 7.18.2 Limits of specified-width integer types */
#ifdef __INT8_MAX__
# undef INT8_MAX
# define INT8_MAX __INT8_MAX__
# undef INT8_MIN
# define INT8_MIN (-INT8_MAX - 1)
#endif
#ifdef __UINT8_MAX__
# undef UINT8_MAX
# define UINT8_MAX __UINT8_MAX__
#endif
#ifdef __INT16_MAX__
# undef INT16_MAX
# define INT16_MAX __INT16_MAX__
# undef INT16_MIN
# define INT16_MIN (-INT16_MAX - 1)
#endif
#ifdef __UINT16_MAX__
# undef UINT16_MAX
# define UINT16_MAX __UINT16_MAX__
#endif
#ifdef __INT32_MAX__
# undef INT32_MAX
# define INT32_MAX __INT32_MAX__
# undef INT32_MIN
# define INT32_MIN (-INT32_MAX - 1)
#endif
#ifdef __UINT32_MAX__
# undef UINT32_MAX
# define UINT32_MAX __UINT32_MAX__
#endif
#ifdef __INT64_MAX__
# undef INT64_MAX
# define INT64_MAX __INT64_MAX__
# undef INT64_MIN
# define INT64_MIN (-INT64_MAX - 1)
#endif
#ifdef __UINT64_MAX__
# undef UINT64_MAX
# define UINT64_MAX __UINT64_MAX__
#endif
#undef INT_LEAST8_MAX
#define INT_LEAST8_MAX __INT_LEAST8_MAX__
#undef INT_LEAST8_MIN
#define INT_LEAST8_MIN (-INT_LEAST8_MAX - 1)
#undef UINT_LEAST8_MAX
#define UINT_LEAST8_MAX __UINT_LEAST8_MAX__
#undef INT_LEAST16_MAX
#define INT_LEAST16_MAX __INT_LEAST16_MAX__
#undef INT_LEAST16_MIN
#define INT_LEAST16_MIN (-INT_LEAST16_MAX - 1)
#undef UINT_LEAST16_MAX
#define UINT_LEAST16_MAX __UINT_LEAST16_MAX__
#undef INT_LEAST32_MAX
#define INT_LEAST32_MAX __INT_LEAST32_MAX__
#undef INT_LEAST32_MIN
#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)
#undef UINT_LEAST32_MAX
#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__
#undef INT_LEAST64_MAX
#define INT_LEAST64_MAX __INT_LEAST64_MAX__
#undef INT_LEAST64_MIN
#define INT_LEAST64_MIN (-INT_LEAST64_MAX - 1)
#undef UINT_LEAST64_MAX
#define UINT_LEAST64_MAX __UINT_LEAST64_MAX__
#undef INT_FAST8_MAX
#define INT_FAST8_MAX __INT_FAST8_MAX__
#undef INT_FAST8_MIN
#define INT_FAST8_MIN (-INT_FAST8_MAX - 1)
#undef UINT_FAST8_MAX
#define UINT_FAST8_MAX __UINT_FAST8_MAX__
#undef INT_FAST16_MAX
#define INT_FAST16_MAX __INT_FAST16_MAX__
#undef INT_FAST16_MIN
#define INT_FAST16_MIN (-INT_FAST16_MAX - 1)
#undef UINT_FAST16_MAX
#define UINT_FAST16_MAX __UINT_FAST16_MAX__
#undef INT_FAST32_MAX
#define INT_FAST32_MAX __INT_FAST32_MAX__
#undef INT_FAST32_MIN
#define INT_FAST32_MIN (-INT_FAST32_MAX - 1)
#undef UINT_FAST32_MAX
#define UINT_FAST32_MAX __UINT_FAST32_MAX__
#undef INT_FAST64_MAX
#define INT_FAST64_MAX __INT_FAST64_MAX__
#undef INT_FAST64_MIN
#define INT_FAST64_MIN (-INT_FAST64_MAX - 1)
#undef UINT_FAST64_MAX
#define UINT_FAST64_MAX __UINT_FAST64_MAX__
#ifdef __INTPTR_MAX__
# undef INTPTR_MAX
# define INTPTR_MAX __INTPTR_MAX__
# undef INTPTR_MIN
# define INTPTR_MIN (-INTPTR_MAX - 1)
#endif
#ifdef __UINTPTR_MAX__
# undef UINTPTR_MAX
# define UINTPTR_MAX __UINTPTR_MAX__
#endif
#undef INTMAX_MAX
#define INTMAX_MAX __INTMAX_MAX__
#undef INTMAX_MIN
#define INTMAX_MIN (-INTMAX_MAX - 1)
#undef UINTMAX_MAX
#define UINTMAX_MAX __UINTMAX_MAX__
/* 7.18.3 Limits of other integer types */
#undef PTRDIFF_MAX
#define PTRDIFF_MAX __PTRDIFF_MAX__
#undef PTRDIFF_MIN
#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)
#undef SIG_ATOMIC_MAX
#define SIG_ATOMIC_MAX __SIG_ATOMIC_MAX__
#undef SIG_ATOMIC_MIN
#define SIG_ATOMIC_MIN __SIG_ATOMIC_MIN__
#undef SIZE_MAX
#define SIZE_MAX __SIZE_MAX__
#undef WCHAR_MAX
#define WCHAR_MAX __WCHAR_MAX__
#undef WCHAR_MIN
#define WCHAR_MIN __WCHAR_MIN__
#undef WINT_MAX
#define WINT_MAX __WINT_MAX__
#undef WINT_MIN
#define WINT_MIN __WINT_MIN__
#endif /* (!defined __cplusplus || __cplusplus >= 201103L
|| defined __STDC_LIMIT_MACROS) */
#if (!defined __cplusplus || __cplusplus >= 201103L \
|| defined __STDC_CONSTANT_MACROS)
#undef INT8_C
#define INT8_C(c) __INT8_C(c)
#undef INT16_C
#define INT16_C(c) __INT16_C(c)
#undef INT32_C
#define INT32_C(c) __INT32_C(c)
#undef INT64_C
#define INT64_C(c) __INT64_C(c)
#undef UINT8_C
#define UINT8_C(c) __UINT8_C(c)
#undef UINT16_C
#define UINT16_C(c) __UINT16_C(c)
#undef UINT32_C
#define UINT32_C(c) __UINT32_C(c)
#undef UINT64_C
#define UINT64_C(c) __UINT64_C(c)
#undef INTMAX_C
#define INTMAX_C(c) __INTMAX_C(c)
#undef UINTMAX_C
#define UINTMAX_C(c) __UINTMAX_C(c)
#endif /* (!defined __cplusplus || __cplusplus >= 201103L
|| defined __STDC_CONSTANT_MACROS) */
#ifdef __STDC_WANT_IEC_60559_BFP_EXT__
/* TS 18661-1 widths of integer types. */
#ifdef __INT8_TYPE__
# undef INT8_WIDTH
# define INT8_WIDTH 8
#endif
#ifdef __UINT8_TYPE__
# undef UINT8_WIDTH
# define UINT8_WIDTH 8
#endif
#ifdef __INT16_TYPE__
# undef INT16_WIDTH
# define INT16_WIDTH 16
#endif
#ifdef __UINT16_TYPE__
# undef UINT16_WIDTH
# define UINT16_WIDTH 16
#endif
#ifdef __INT32_TYPE__
# undef INT32_WIDTH
# define INT32_WIDTH 32
#endif
#ifdef __UINT32_TYPE__
# undef UINT32_WIDTH
# define UINT32_WIDTH 32
#endif
#ifdef __INT64_TYPE__
# undef INT64_WIDTH
# define INT64_WIDTH 64
#endif
#ifdef __UINT64_TYPE__
# undef UINT64_WIDTH
# define UINT64_WIDTH 64
#endif
#undef INT_LEAST8_WIDTH
#define INT_LEAST8_WIDTH __INT_LEAST8_WIDTH__
#undef UINT_LEAST8_WIDTH
#define UINT_LEAST8_WIDTH __INT_LEAST8_WIDTH__
#undef INT_LEAST16_WIDTH
#define INT_LEAST16_WIDTH __INT_LEAST16_WIDTH__
#undef UINT_LEAST16_WIDTH
#define UINT_LEAST16_WIDTH __INT_LEAST16_WIDTH__
#undef INT_LEAST32_WIDTH
#define INT_LEAST32_WIDTH __INT_LEAST32_WIDTH__
#undef UINT_LEAST32_WIDTH
#define UINT_LEAST32_WIDTH __INT_LEAST32_WIDTH__
#undef INT_LEAST64_WIDTH
#define INT_LEAST64_WIDTH __INT_LEAST64_WIDTH__
#undef UINT_LEAST64_WIDTH
#define UINT_LEAST64_WIDTH __INT_LEAST64_WIDTH__
#undef INT_FAST8_WIDTH
#define INT_FAST8_WIDTH __INT_FAST8_WIDTH__
#undef UINT_FAST8_WIDTH
#define UINT_FAST8_WIDTH __INT_FAST8_WIDTH__
#undef INT_FAST16_WIDTH
#define INT_FAST16_WIDTH __INT_FAST16_WIDTH__
#undef UINT_FAST16_WIDTH
#define UINT_FAST16_WIDTH __INT_FAST16_WIDTH__
#undef INT_FAST32_WIDTH
#define INT_FAST32_WIDTH __INT_FAST32_WIDTH__
#undef UINT_FAST32_WIDTH
#define UINT_FAST32_WIDTH __INT_FAST32_WIDTH__
#undef INT_FAST64_WIDTH
#define INT_FAST64_WIDTH __INT_FAST64_WIDTH__
#undef UINT_FAST64_WIDTH
#define UINT_FAST64_WIDTH __INT_FAST64_WIDTH__
#ifdef __INTPTR_TYPE__
# undef INTPTR_WIDTH
# define INTPTR_WIDTH __INTPTR_WIDTH__
#endif
#ifdef __UINTPTR_TYPE__
# undef UINTPTR_WIDTH
# define UINTPTR_WIDTH __INTPTR_WIDTH__
#endif
#undef INTMAX_WIDTH
#define INTMAX_WIDTH __INTMAX_WIDTH__
#undef UINTMAX_WIDTH
#define UINTMAX_WIDTH __INTMAX_WIDTH__
#undef PTRDIFF_WIDTH
#define PTRDIFF_WIDTH __PTRDIFF_WIDTH__
#undef SIG_ATOMIC_WIDTH
#define SIG_ATOMIC_WIDTH __SIG_ATOMIC_WIDTH__
#undef SIZE_WIDTH
#define SIZE_WIDTH __SIZE_WIDTH__
#undef WCHAR_WIDTH
#define WCHAR_WIDTH __WCHAR_WIDTH__
#undef WINT_WIDTH
#define WINT_WIDTH __WINT_WIDTH__
#endif
#endif /* _GCC_STDINT_H */
@@ -0,0 +1,14 @@
#ifndef _GCC_WRAP_STDINT_H
#if __STDC_HOSTED__
# if defined __cplusplus && __cplusplus >= 201103L
# undef __STDC_LIMIT_MACROS
# define __STDC_LIMIT_MACROS
# undef __STDC_CONSTANT_MACROS
# define __STDC_CONSTANT_MACROS
# endif
# include_next <stdint.h>
#else
# include "stdint-gcc.h"
#endif
#define _GCC_WRAP_STDINT_H
#endif
@@ -0,0 +1,35 @@
/* Copyright (C) 2011-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
/* ISO C1X: 7.23 _Noreturn <stdnoreturn.h>. */
#ifndef _STDNORETURN_H
#define _STDNORETURN_H
#ifndef __cplusplus
#define noreturn _Noreturn
#endif
#endif /* stdnoreturn.h */
@@ -0,0 +1,8 @@
/* syslimits.h stands for the system's own limits.h file.
If we can use it ok unmodified, then we install this text.
If fixincludes fixes it, then the fixed version is installed
instead of this text. */
#define _GCC_NEXT_LIMITS_H /* tell gcc's limits.h to recurse */
#include_next <limits.h>
#undef _GCC_NEXT_LIMITS_H
@@ -0,0 +1,180 @@
/* Copyright (C) 2010-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _X86INTRIN_H_INCLUDED
# error "Never use <tbmintrin.h> directly; include <x86intrin.h> instead."
#endif
#ifndef _TBMINTRIN_H_INCLUDED
#define _TBMINTRIN_H_INCLUDED
#ifndef __TBM__
#pragma GCC push_options
#pragma GCC target("tbm")
#define __DISABLE_TBM__
#endif /* __TBM__ */
#ifdef __OPTIMIZE__
extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__bextri_u32 (unsigned int __X, const unsigned int __I)
{
return __builtin_ia32_bextri_u32 (__X, __I);
}
#else
#define __bextri_u32(X, I) \
((unsigned int)__builtin_ia32_bextri_u32 ((unsigned int)(X), \
(unsigned int)(I)))
#endif /*__OPTIMIZE__ */
extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__blcfill_u32 (unsigned int __X)
{
return __X & (__X + 1);
}
extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__blci_u32 (unsigned int __X)
{
return __X | ~(__X + 1);
}
extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__blcic_u32 (unsigned int __X)
{
return ~__X & (__X + 1);
}
extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__blcmsk_u32 (unsigned int __X)
{
return __X ^ (__X + 1);
}
extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__blcs_u32 (unsigned int __X)
{
return __X | (__X + 1);
}
extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__blsfill_u32 (unsigned int __X)
{
return __X | (__X - 1);
}
extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__blsic_u32 (unsigned int __X)
{
return ~__X | (__X - 1);
}
extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__t1mskc_u32 (unsigned int __X)
{
return ~__X | (__X + 1);
}
extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__tzmsk_u32 (unsigned int __X)
{
return ~__X & (__X - 1);
}
#ifdef __x86_64__
#ifdef __OPTIMIZE__
extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__bextri_u64 (unsigned long long __X, const unsigned int __I)
{
return __builtin_ia32_bextri_u64 (__X, __I);
}
#else
#define __bextri_u64(X, I) \
((unsigned long long)__builtin_ia32_bextri_u64 ((unsigned long long)(X), \
(unsigned long long)(I)))
#endif /*__OPTIMIZE__ */
extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__blcfill_u64 (unsigned long long __X)
{
return __X & (__X + 1);
}
extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__blci_u64 (unsigned long long __X)
{
return __X | ~(__X + 1);
}
extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__blcic_u64 (unsigned long long __X)
{
return ~__X & (__X + 1);
}
extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__blcmsk_u64 (unsigned long long __X)
{
return __X ^ (__X + 1);
}
extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__blcs_u64 (unsigned long long __X)
{
return __X | (__X + 1);
}
extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__blsfill_u64 (unsigned long long __X)
{
return __X | (__X - 1);
}
extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__blsic_u64 (unsigned long long __X)
{
return ~__X | (__X - 1);
}
extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__t1mskc_u64 (unsigned long long __X)
{
return ~__X | (__X + 1);
}
extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
__tzmsk_u64 (unsigned long long __X)
{
return ~__X & (__X - 1);
}
#endif /* __x86_64__ */
#ifdef __DISABLE_TBM__
#undef __DISABLE_TBM__
#pragma GCC pop_options
#endif /* __DISABLE_TBM__ */
#endif /* _TBMINTRIN_H_INCLUDED */
@@ -0,0 +1,249 @@
/* Copyright (C) 2006-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
/* Implemented from the specification included in the Intel C++ Compiler
User Guide and Reference, version 9.1. */
#ifndef _TMMINTRIN_H_INCLUDED
#define _TMMINTRIN_H_INCLUDED
/* We need definitions from the SSE3, SSE2 and SSE header files*/
#include <pmmintrin.h>
#ifndef __SSSE3__
#pragma GCC push_options
#pragma GCC target("ssse3")
#define __DISABLE_SSSE3__
#endif /* __SSSE3__ */
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_hadd_epi16 (__m128i __X, __m128i __Y)
{
return (__m128i) __builtin_ia32_phaddw128 ((__v8hi)__X, (__v8hi)__Y);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_hadd_epi32 (__m128i __X, __m128i __Y)
{
return (__m128i) __builtin_ia32_phaddd128 ((__v4si)__X, (__v4si)__Y);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_hadds_epi16 (__m128i __X, __m128i __Y)
{
return (__m128i) __builtin_ia32_phaddsw128 ((__v8hi)__X, (__v8hi)__Y);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_hadd_pi16 (__m64 __X, __m64 __Y)
{
return (__m64) __builtin_ia32_phaddw ((__v4hi)__X, (__v4hi)__Y);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_hadd_pi32 (__m64 __X, __m64 __Y)
{
return (__m64) __builtin_ia32_phaddd ((__v2si)__X, (__v2si)__Y);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_hadds_pi16 (__m64 __X, __m64 __Y)
{
return (__m64) __builtin_ia32_phaddsw ((__v4hi)__X, (__v4hi)__Y);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_hsub_epi16 (__m128i __X, __m128i __Y)
{
return (__m128i) __builtin_ia32_phsubw128 ((__v8hi)__X, (__v8hi)__Y);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_hsub_epi32 (__m128i __X, __m128i __Y)
{
return (__m128i) __builtin_ia32_phsubd128 ((__v4si)__X, (__v4si)__Y);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_hsubs_epi16 (__m128i __X, __m128i __Y)
{
return (__m128i) __builtin_ia32_phsubsw128 ((__v8hi)__X, (__v8hi)__Y);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_hsub_pi16 (__m64 __X, __m64 __Y)
{
return (__m64) __builtin_ia32_phsubw ((__v4hi)__X, (__v4hi)__Y);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_hsub_pi32 (__m64 __X, __m64 __Y)
{
return (__m64) __builtin_ia32_phsubd ((__v2si)__X, (__v2si)__Y);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_hsubs_pi16 (__m64 __X, __m64 __Y)
{
return (__m64) __builtin_ia32_phsubsw ((__v4hi)__X, (__v4hi)__Y);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_maddubs_epi16 (__m128i __X, __m128i __Y)
{
return (__m128i) __builtin_ia32_pmaddubsw128 ((__v16qi)__X, (__v16qi)__Y);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_maddubs_pi16 (__m64 __X, __m64 __Y)
{
return (__m64) __builtin_ia32_pmaddubsw ((__v8qi)__X, (__v8qi)__Y);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_mulhrs_epi16 (__m128i __X, __m128i __Y)
{
return (__m128i) __builtin_ia32_pmulhrsw128 ((__v8hi)__X, (__v8hi)__Y);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_mulhrs_pi16 (__m64 __X, __m64 __Y)
{
return (__m64) __builtin_ia32_pmulhrsw ((__v4hi)__X, (__v4hi)__Y);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_shuffle_epi8 (__m128i __X, __m128i __Y)
{
return (__m128i) __builtin_ia32_pshufb128 ((__v16qi)__X, (__v16qi)__Y);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_shuffle_pi8 (__m64 __X, __m64 __Y)
{
return (__m64) __builtin_ia32_pshufb ((__v8qi)__X, (__v8qi)__Y);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_sign_epi8 (__m128i __X, __m128i __Y)
{
return (__m128i) __builtin_ia32_psignb128 ((__v16qi)__X, (__v16qi)__Y);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_sign_epi16 (__m128i __X, __m128i __Y)
{
return (__m128i) __builtin_ia32_psignw128 ((__v8hi)__X, (__v8hi)__Y);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_sign_epi32 (__m128i __X, __m128i __Y)
{
return (__m128i) __builtin_ia32_psignd128 ((__v4si)__X, (__v4si)__Y);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_sign_pi8 (__m64 __X, __m64 __Y)
{
return (__m64) __builtin_ia32_psignb ((__v8qi)__X, (__v8qi)__Y);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_sign_pi16 (__m64 __X, __m64 __Y)
{
return (__m64) __builtin_ia32_psignw ((__v4hi)__X, (__v4hi)__Y);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_sign_pi32 (__m64 __X, __m64 __Y)
{
return (__m64) __builtin_ia32_psignd ((__v2si)__X, (__v2si)__Y);
}
#ifdef __OPTIMIZE__
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_alignr_epi8(__m128i __X, __m128i __Y, const int __N)
{
return (__m128i) __builtin_ia32_palignr128 ((__v2di)__X,
(__v2di)__Y, __N * 8);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_alignr_pi8(__m64 __X, __m64 __Y, const int __N)
{
return (__m64) __builtin_ia32_palignr ((__v1di)__X,
(__v1di)__Y, __N * 8);
}
#else
#define _mm_alignr_epi8(X, Y, N) \
((__m128i) __builtin_ia32_palignr128 ((__v2di)(__m128i)(X), \
(__v2di)(__m128i)(Y), \
(int)(N) * 8))
#define _mm_alignr_pi8(X, Y, N) \
((__m64) __builtin_ia32_palignr ((__v1di)(__m64)(X), \
(__v1di)(__m64)(Y), \
(int)(N) * 8))
#endif
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_abs_epi8 (__m128i __X)
{
return (__m128i) __builtin_ia32_pabsb128 ((__v16qi)__X);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_abs_epi16 (__m128i __X)
{
return (__m128i) __builtin_ia32_pabsw128 ((__v8hi)__X);
}
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_abs_epi32 (__m128i __X)
{
return (__m128i) __builtin_ia32_pabsd128 ((__v4si)__X);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_abs_pi8 (__m64 __X)
{
return (__m64) __builtin_ia32_pabsb ((__v8qi)__X);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_abs_pi16 (__m64 __X)
{
return (__m64) __builtin_ia32_pabsw ((__v4hi)__X);
}
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_abs_pi32 (__m64 __X)
{
return (__m64) __builtin_ia32_pabsd ((__v2si)__X);
}
#ifdef __DISABLE_SSSE3__
#undef __DISABLE_SSSE3__
#pragma GCC pop_options
#endif /* __DISABLE_SSSE3__ */
#endif /* _TMMINTRIN_H_INCLUDED */
@@ -0,0 +1,291 @@
/* Exception handling and frame unwind runtime interface routines.
Copyright (C) 2001-2017 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
/* This is derived from the C++ ABI for IA-64. Where we diverge
for cross-architecture compatibility are noted with "@@@". */
#ifndef _UNWIND_H
#define _UNWIND_H
#if defined (__SEH__) && !defined (__USING_SJLJ_EXCEPTIONS__)
/* Only for _GCC_specific_handler. */
#include <windows.h>
#endif
#ifndef HIDE_EXPORTS
#pragma GCC visibility push(default)
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Level 1: Base ABI */
/* @@@ The IA-64 ABI uses uint64 throughout. Most places this is
inefficient for 32-bit and smaller machines. */
typedef unsigned _Unwind_Word __attribute__((__mode__(__unwind_word__)));
typedef signed _Unwind_Sword __attribute__((__mode__(__unwind_word__)));
#if defined(__ia64__) && defined(__hpux__)
typedef unsigned _Unwind_Ptr __attribute__((__mode__(__word__)));
#else
typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__)));
#endif
typedef unsigned _Unwind_Internal_Ptr __attribute__((__mode__(__pointer__)));
/* @@@ The IA-64 ABI uses a 64-bit word to identify the producer and
consumer of an exception. We'll go along with this for now even on
32-bit machines. We'll need to provide some other option for
16-bit machines and for machines with > 8 bits per byte. */
typedef unsigned _Unwind_Exception_Class __attribute__((__mode__(__DI__)));
/* The unwind interface uses reason codes in several contexts to
identify the reasons for failures or other actions. */
typedef enum
{
_URC_NO_REASON = 0,
_URC_FOREIGN_EXCEPTION_CAUGHT = 1,
_URC_FATAL_PHASE2_ERROR = 2,
_URC_FATAL_PHASE1_ERROR = 3,
_URC_NORMAL_STOP = 4,
_URC_END_OF_STACK = 5,
_URC_HANDLER_FOUND = 6,
_URC_INSTALL_CONTEXT = 7,
_URC_CONTINUE_UNWIND = 8
} _Unwind_Reason_Code;
/* The unwind interface uses a pointer to an exception header object
as its representation of an exception being thrown. In general, the
full representation of an exception object is language- and
implementation-specific, but it will be prefixed by a header
understood by the unwind interface. */
struct _Unwind_Exception;
typedef void (*_Unwind_Exception_Cleanup_Fn) (_Unwind_Reason_Code,
struct _Unwind_Exception *);
struct _Unwind_Exception
{
_Unwind_Exception_Class exception_class;
_Unwind_Exception_Cleanup_Fn exception_cleanup;
#if !defined (__USING_SJLJ_EXCEPTIONS__) && defined (__SEH__)
_Unwind_Word private_[6];
#else
_Unwind_Word private_1;
_Unwind_Word private_2;
#endif
/* @@@ The IA-64 ABI says that this structure must be double-word aligned.
Taking that literally does not make much sense generically. Instead we
provide the maximum alignment required by any type for the machine. */
} __attribute__((__aligned__));
/* The ACTIONS argument to the personality routine is a bitwise OR of one
or more of the following constants. */
typedef int _Unwind_Action;
#define _UA_SEARCH_PHASE 1
#define _UA_CLEANUP_PHASE 2
#define _UA_HANDLER_FRAME 4
#define _UA_FORCE_UNWIND 8
#define _UA_END_OF_STACK 16
/* The target can override this macro to define any back-end-specific
attributes required for the lowest-level stack frame. */
#ifndef LIBGCC2_UNWIND_ATTRIBUTE
#define LIBGCC2_UNWIND_ATTRIBUTE
#endif
/* This is an opaque type used to refer to a system-specific data
structure used by the system unwinder. This context is created and
destroyed by the system, and passed to the personality routine
during unwinding. */
struct _Unwind_Context;
/* Raise an exception, passing along the given exception object. */
extern _Unwind_Reason_Code LIBGCC2_UNWIND_ATTRIBUTE
_Unwind_RaiseException (struct _Unwind_Exception *);
/* Raise an exception for forced unwinding. */
typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)
(int, _Unwind_Action, _Unwind_Exception_Class,
struct _Unwind_Exception *, struct _Unwind_Context *, void *);
extern _Unwind_Reason_Code LIBGCC2_UNWIND_ATTRIBUTE
_Unwind_ForcedUnwind (struct _Unwind_Exception *, _Unwind_Stop_Fn, void *);
/* Helper to invoke the exception_cleanup routine. */
extern void _Unwind_DeleteException (struct _Unwind_Exception *);
/* Resume propagation of an existing exception. This is used after
e.g. executing cleanup code, and not to implement rethrowing. */
extern void LIBGCC2_UNWIND_ATTRIBUTE
_Unwind_Resume (struct _Unwind_Exception *);
/* @@@ Resume propagation of a FORCE_UNWIND exception, or to rethrow
a normal exception that was handled. */
extern _Unwind_Reason_Code LIBGCC2_UNWIND_ATTRIBUTE
_Unwind_Resume_or_Rethrow (struct _Unwind_Exception *);
/* @@@ Use unwind data to perform a stack backtrace. The trace callback
is called for every stack frame in the call chain, but no cleanup
actions are performed. */
typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)
(struct _Unwind_Context *, void *);
extern _Unwind_Reason_Code LIBGCC2_UNWIND_ATTRIBUTE
_Unwind_Backtrace (_Unwind_Trace_Fn, void *);
/* These functions are used for communicating information about the unwind
context (i.e. the unwind descriptors and the user register state) between
the unwind library and the personality routine and landing pad. Only
selected registers may be manipulated. */
extern _Unwind_Word _Unwind_GetGR (struct _Unwind_Context *, int);
extern void _Unwind_SetGR (struct _Unwind_Context *, int, _Unwind_Word);
extern _Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *);
extern _Unwind_Ptr _Unwind_GetIPInfo (struct _Unwind_Context *, int *);
extern void _Unwind_SetIP (struct _Unwind_Context *, _Unwind_Ptr);
/* @@@ Retrieve the CFA of the given context. */
extern _Unwind_Word _Unwind_GetCFA (struct _Unwind_Context *);
extern void *_Unwind_GetLanguageSpecificData (struct _Unwind_Context *);
extern _Unwind_Ptr _Unwind_GetRegionStart (struct _Unwind_Context *);
/* The personality routine is the function in the C++ (or other language)
runtime library which serves as an interface between the system unwind
library and language-specific exception handling semantics. It is
specific to the code fragment described by an unwind info block, and
it is always referenced via the pointer in the unwind info block, and
hence it has no ABI-specified name.
Note that this implies that two different C++ implementations can
use different names, and have different contents in the language
specific data area. Moreover, that the language specific data
area contains no version info because name of the function invoked
provides more effective versioning by detecting at link time the
lack of code to handle the different data format. */
typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)
(int, _Unwind_Action, _Unwind_Exception_Class,
struct _Unwind_Exception *, struct _Unwind_Context *);
/* @@@ The following alternate entry points are for setjmp/longjmp
based unwinding. */
struct SjLj_Function_Context;
extern void _Unwind_SjLj_Register (struct SjLj_Function_Context *);
extern void _Unwind_SjLj_Unregister (struct SjLj_Function_Context *);
extern _Unwind_Reason_Code LIBGCC2_UNWIND_ATTRIBUTE
_Unwind_SjLj_RaiseException (struct _Unwind_Exception *);
extern _Unwind_Reason_Code LIBGCC2_UNWIND_ATTRIBUTE
_Unwind_SjLj_ForcedUnwind (struct _Unwind_Exception *, _Unwind_Stop_Fn, void *);
extern void LIBGCC2_UNWIND_ATTRIBUTE
_Unwind_SjLj_Resume (struct _Unwind_Exception *);
extern _Unwind_Reason_Code LIBGCC2_UNWIND_ATTRIBUTE
_Unwind_SjLj_Resume_or_Rethrow (struct _Unwind_Exception *);
/* @@@ The following provide access to the base addresses for text
and data-relative addressing in the LDSA. In order to stay link
compatible with the standard ABI for IA-64, we inline these. */
#ifdef __ia64__
static inline _Unwind_Ptr
_Unwind_GetDataRelBase (struct _Unwind_Context *_C)
{
/* The GP is stored in R1. */
return _Unwind_GetGR (_C, 1);
}
static inline _Unwind_Ptr
_Unwind_GetTextRelBase (struct _Unwind_Context *_C __attribute__ ((__unused__)))
{
__builtin_abort ();
return 0;
}
/* @@@ Retrieve the Backing Store Pointer of the given context. */
extern _Unwind_Word _Unwind_GetBSP (struct _Unwind_Context *);
#else
extern _Unwind_Ptr _Unwind_GetDataRelBase (struct _Unwind_Context *);
extern _Unwind_Ptr _Unwind_GetTextRelBase (struct _Unwind_Context *);
#endif
/* @@@ Given an address, return the entry point of the function that
contains it. */
extern void * _Unwind_FindEnclosingFunction (void *pc);
#ifndef __SIZEOF_LONG__
#error "__SIZEOF_LONG__ macro not defined"
#endif
#ifndef __SIZEOF_POINTER__
#error "__SIZEOF_POINTER__ macro not defined"
#endif
/* leb128 type numbers have a potentially unlimited size.
The target of the following definitions of _sleb128_t and _uleb128_t
is to have efficient data types large enough to hold the leb128 type
numbers used in the unwind code.
Mostly these types will simply be defined to long and unsigned long
except when a unsigned long data type on the target machine is not
capable of storing a pointer. */
#if __SIZEOF_LONG__ >= __SIZEOF_POINTER__
typedef long _sleb128_t;
typedef unsigned long _uleb128_t;
#elif __SIZEOF_LONG_LONG__ >= __SIZEOF_POINTER__
typedef long long _sleb128_t;
typedef unsigned long long _uleb128_t;
#else
# error "What type shall we use for _sleb128_t?"
#endif
#if defined (__SEH__) && !defined (__USING_SJLJ_EXCEPTIONS__)
/* Handles the mapping from SEH to GCC interfaces. */
EXCEPTION_DISPOSITION _GCC_specific_handler (PEXCEPTION_RECORD, void *,
PCONTEXT, PDISPATCHER_CONTEXT,
_Unwind_Personality_Fn);
#endif
#ifdef __cplusplus
}
#endif
#ifndef HIDE_EXPORTS
#pragma GCC visibility pop
#endif
#endif /* unwind.h */

Some files were not shown because too many files have changed in this diff Show More