<commit_before>//===------------- Float16Support.cpp - Swift Float16 Support -------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// Implementations of:
//
// __gnu_h2f_ieee
// __gnu_f2h_ieee
// __truncdfhf2
//
// On Darwin platforms, these are provided by the host compiler-rt, but we
// can't depend on that everywhere, so we have to provide them in the Swift
// runtime. Calls to these symbols are automatically generated by LLVM when
// operating on Float16, so they are used *even though they appear to have
// no call sites anywhere in Swift*.
//
// These may require different naming or mangling on other targets; what I've
// setup here is correct for Linux/x86.
//
//===----------------------------------------------------------------------===//

// Android NDK <r21 do not provide `__aeabi_d2h` in the compiler runtime,
// provide shims in that case.
#if (defined(__ANDROID__) && defined(__ARM_ARCH_7A__) && defined(__ARM_EABI__)) || \
  ((defined(__i686__) || defined(__x86_64__)) && !defined(__APPLE__))

#include "../SwiftShims/Visibility.h"

static unsigned toEncoding(float f) {
  unsigned e;
  static_assert(sizeof e == sizeof f, "float and int must have the same size");
  __builtin_memcpy(&e, &f, sizeof f);
  return e;
}

static float fromEncoding(unsigned int e) {
  float f;
  static_assert(sizeof f == sizeof e, "float and int must have the same size");
  __builtin_memcpy(&f, &e, sizeof f);
  return f;
}

#if defined(__x86_64__) && defined(__F16C__)

// If we're compiling the runtime for a target that has the conversion
// instruction, we might as well just use those. In theory, we'd also be
// compiling Swift for that target and not need these builtins at all,
// but who knows what could go wrong, and they're tiny functions.
# include <immintrin.h>

SWIFT_RUNTIME_EXPORT float __gnu_h2f_ieee(short h) {
  return _mm_cvtss_f32(_mm_cvtph_ps(_mm_set_epi64x(0,h)));
}<commit_msg>runtime: enable shims for Float16 on Windows (x86)<commit_after>//===------------- Float16Support.cpp - Swift Float16 Support -------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// Implementations of:
//
// __gnu_h2f_ieee
// __gnu_f2h_ieee
// __truncdfhf2
//
// On Darwin platforms, these are provided by the host compiler-rt, but we
// can't depend on that everywhere, so we have to provide them in the Swift
// runtime. Calls to these symbols are automatically generated by LLVM when
// operating on Float16, so they are used *even though they appear to have
// no call sites anywhere in Swift*.
//
// These may require different naming or mangling on other targets; what I've
// setup here is correct for Linux/x86.
//
//===----------------------------------------------------------------------===//

// Android NDK <r21 do not provide `__aeabi_d2h` in the compiler runtime,
// provide shims in that case.
#if (defined(__ANDROID__) && defined(__ARM_ARCH_7A__) && defined(__ARM_EABI__)) || \
  ((defined(__i386__) || defined(__i686__) || defined(__x86_64__)) && !defined(__APPLE__))

#include "../SwiftShims/Visibility.h"

static unsigned toEncoding(float f) {
  unsigned e;
  static_assert(sizeof e == sizeof f, "float and int must have the same size");
  __builtin_memcpy(&e, &f, sizeof f);
  return e;
}

static float fromEncoding(unsigned int e) {
  float f;
  static_assert(sizeof f == sizeof e, "float and int must have the same size");
  __builtin_memcpy(&f, &e, sizeof f);
  return f;
}

#if defined(__x86_64__) && defined(__F16C__)

// If we're compiling the runtime for a target that has the conversion
// instruction, we might as well just use those. In theory, we'd also be
// compiling Swift for that target and not need these builtins at all,
// but who knows what could go wrong, and they're tiny functions.
# include <immintrin.h>

SWIFT_RUNTIME_EXPORT float __gnu_h2f_ieee(short h) {
  return _mm_cvtss_f32(_mm_cvtph_ps(_mm_set_epi64x(0,h)));
}
{'fraction_non_alphanumeric': 0.178266438941076, 'fraction_numerical': 0.020281810418445772, 'mean_word_length': 2.80275974025974, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3507158', 'n_tokens_mistral': 1438, 'n_tokens_neox': 1345, 'n_words': 532}