1515const unsigned int host_char_bit = 8 ;
1616
1717// float16 intrinsics
18- // TODO: use LLVM's compiler-rt on all platforms (Xcode already links compiler-rt)
19-
20- #if !defined(_OS_DARWIN_ )
2118
2219static inline float half_to_float (uint16_t ival ) JL_NOTSAFEPOINT
2320{
@@ -188,22 +185,17 @@ static inline uint16_t float_to_half(float param) JL_NOTSAFEPOINT
188185 return h ;
189186}
190187
191- JL_DLLEXPORT float __gnu_h2f_ieee (uint16_t param )
188+ JL_DLLEXPORT float julia__gnu_h2f_ieee (uint16_t param )
192189{
193190 return half_to_float (param );
194191}
195192
196- JL_DLLEXPORT float __extendhfsf2 (uint16_t param )
197- {
198- return half_to_float (param );
199- }
200-
201- JL_DLLEXPORT uint16_t __gnu_f2h_ieee (float param )
193+ JL_DLLEXPORT uint16_t julia__gnu_f2h_ieee (float param )
202194{
203195 return float_to_half (param );
204196}
205197
206- JL_DLLEXPORT uint16_t __truncdfhf2 (double param )
198+ JL_DLLEXPORT uint16_t julia__truncdfhf2 (double param )
207199{
208200 float res = (float )param ;
209201 uint32_t resi ;
@@ -225,7 +217,25 @@ JL_DLLEXPORT uint16_t __truncdfhf2(double param)
225217 return float_to_half (res );
226218}
227219
228- #endif
220+ //JL_DLLEXPORT double julia__extendhfdf2(uint16_t n) { return (double)julia__gnu_h2f_ieee(n); }
221+ //JL_DLLEXPORT int32_t julia__fixhfsi(uint16_t n) { return (int32_t)julia__gnu_h2f_ieee(n); }
222+ //JL_DLLEXPORT int64_t julia__fixhfdi(uint16_t n) { return (int64_t)julia__gnu_h2f_ieee(n); }
223+ //JL_DLLEXPORT uint32_t julia__fixunshfsi(uint16_t n) { return (uint32_t)julia__gnu_h2f_ieee(n); }
224+ //JL_DLLEXPORT uint64_t julia__fixunshfdi(uint16_t n) { return (uint64_t)julia__gnu_h2f_ieee(n); }
225+ //JL_DLLEXPORT uint16_t julia__floatsihf(int32_t n) { return julia__gnu_f2h_ieee((float)n); }
226+ //JL_DLLEXPORT uint16_t julia__floatdihf(int64_t n) { return julia__gnu_f2h_ieee((float)n); }
227+ //JL_DLLEXPORT uint16_t julia__floatunsihf(uint32_t n) { return julia__gnu_f2h_ieee((float)n); }
228+ //JL_DLLEXPORT uint16_t julia__floatundihf(uint64_t n) { return julia__gnu_f2h_ieee((float)n); }
229+ //HANDLE_LIBCALL(F16, F128, __extendhftf2)
230+ //HANDLE_LIBCALL(F16, F80, __extendhfxf2)
231+ //HANDLE_LIBCALL(F80, F16, __truncxfhf2)
232+ //HANDLE_LIBCALL(F128, F16, __trunctfhf2)
233+ //HANDLE_LIBCALL(PPCF128, F16, __trunctfhf2)
234+ //HANDLE_LIBCALL(F16, I128, __fixhfti)
235+ //HANDLE_LIBCALL(F16, I128, __fixunshfti)
236+ //HANDLE_LIBCALL(I128, F16, __floattihf)
237+ //HANDLE_LIBCALL(I128, F16, __floatuntihf)
238+
229239
230240// run time version of bitcast intrinsic
231241JL_DLLEXPORT jl_value_t * jl_bitcast (jl_value_t * ty , jl_value_t * v )
@@ -551,9 +561,9 @@ static inline unsigned select_by_size(unsigned sz) JL_NOTSAFEPOINT
551561 }
552562
553563#define fp_select (a , func ) \
554- sizeof(a) = = sizeof(float) ? func##f((float)a) : func(a)
564+ sizeof(a) < = sizeof(float) ? func##f((float)a) : func(a)
555565#define fp_select2 (a , b , func ) \
556- sizeof(a) = = sizeof(float) ? func##f(a, b) : func(a, b)
566+ sizeof(a) < = sizeof(float) ? func##f(a, b) : func(a, b)
557567
558568// fast-function generators //
559569
@@ -597,11 +607,11 @@ static inline void name(unsigned osize, void *pa, void *pr) JL_NOTSAFEPOINT \
597607static inline void name(unsigned osize, void *pa, void *pr) JL_NOTSAFEPOINT \
598608{ \
599609 uint16_t a = *(uint16_t*)pa; \
600- float A = __gnu_h2f_ieee (a); \
610+ float A = julia__gnu_h2f_ieee (a); \
601611 if (osize == 16) { \
602612 float R; \
603613 OP(&R, A); \
604- *(uint16_t*)pr = __gnu_f2h_ieee (R); \
614+ *(uint16_t*)pr = julia__gnu_f2h_ieee (R); \
605615 } else { \
606616 OP((uint16_t*)pr, A); \
607617 } \
@@ -625,11 +635,11 @@ static void jl_##name##16(unsigned runtime_nbits, void *pa, void *pb, void *pr)
625635{ \
626636 uint16_t a = *(uint16_t*)pa; \
627637 uint16_t b = *(uint16_t*)pb; \
628- float A = __gnu_h2f_ieee (a); \
629- float B = __gnu_h2f_ieee (b); \
638+ float A = julia__gnu_h2f_ieee (a); \
639+ float B = julia__gnu_h2f_ieee (b); \
630640 runtime_nbits = 16; \
631641 float R = OP(A, B); \
632- *(uint16_t*)pr = __gnu_f2h_ieee (R); \
642+ *(uint16_t*)pr = julia__gnu_f2h_ieee (R); \
633643}
634644
635645// float or integer inputs, bool output
@@ -650,8 +660,8 @@ static int jl_##name##16(unsigned runtime_nbits, void *pa, void *pb) JL_NOTSAFEP
650660{ \
651661 uint16_t a = *(uint16_t*)pa; \
652662 uint16_t b = *(uint16_t*)pb; \
653- float A = __gnu_h2f_ieee (a); \
654- float B = __gnu_h2f_ieee (b); \
663+ float A = julia__gnu_h2f_ieee (a); \
664+ float B = julia__gnu_h2f_ieee (b); \
655665 runtime_nbits = 16; \
656666 return OP(A, B); \
657667}
@@ -691,12 +701,12 @@ static void jl_##name##16(unsigned runtime_nbits, void *pa, void *pb, void *pc,
691701 uint16_t a = *(uint16_t*)pa; \
692702 uint16_t b = *(uint16_t*)pb; \
693703 uint16_t c = *(uint16_t*)pc; \
694- float A = __gnu_h2f_ieee (a); \
695- float B = __gnu_h2f_ieee (b); \
696- float C = __gnu_h2f_ieee (c); \
704+ float A = julia__gnu_h2f_ieee (a); \
705+ float B = julia__gnu_h2f_ieee (b); \
706+ float C = julia__gnu_h2f_ieee (c); \
697707 runtime_nbits = 16; \
698708 float R = OP(A, B, C); \
699- *(uint16_t*)pr = __gnu_f2h_ieee (R); \
709+ *(uint16_t*)pr = julia__gnu_f2h_ieee (R); \
700710}
701711
702712
@@ -1318,7 +1328,7 @@ static inline int fpiseq##nbits(c_type a, c_type b) JL_NOTSAFEPOINT { \
13181328fpiseq_n (float , 32 )
13191329fpiseq_n (double , 64 )
13201330#define fpiseq (a ,b ) \
1321- sizeof(a) = = sizeof(float) ? fpiseq32(a, b) : fpiseq64(a, b)
1331+ sizeof(a) < = sizeof(float) ? fpiseq32(a, b) : fpiseq64(a, b)
13221332
13231333bool_fintrinsic (eq ,eq_float )
13241334bool_fintrinsic (ne ,ne_float )
@@ -1367,7 +1377,7 @@ cvt_iintrinsic(LLVMFPtoUI, fptoui)
13671377 if (!(osize < 8 * sizeof(a))) \
13681378 jl_error("fptrunc: output bitsize must be < input bitsize"); \
13691379 else if (osize == 16) \
1370- *(uint16_t*)pr = __gnu_f2h_ieee (a); \
1380+ *(uint16_t*)pr = julia__gnu_f2h_ieee (a); \
13711381 else if (osize == 32) \
13721382 *(float*)pr = a; \
13731383 else if (osize == 64) \
0 commit comments