rust-lang / rust-lang/stdarch

Minor license issues

Open
#259 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
694
Forks
336
Avg merge
5d 14h
Merged PRs (30d)
9

Description

While updating #247 I realized that some of the comments have been copy&pasted 1:1 from clang, e.g. in

/// Compares the 8-bit integer elements of two 64-bit integer vectors of
/// [8 x i8] to determine if the element of the first vector is greater than
/// the corresponding element of the second vector.
///
/// The comparison yields 0 for false, 0xFF for true.
#[inline(always)]
#[target_feature = "+mmx"]
#[cfg_attr(test, assert_instr(pcmpgtb))]
pub unsafe fn _mm_cmpgt_pi8(a: i8x8, b: i8x8) -> i8x8 {
    mem::transmute(pcmpgtb(mem::transmute(a), mem::transmute(b)))
}

googling the comment "Compares the 8-bit integer elements of two 64-bit integer vectors of [8 x i8] to determine if the element of the first vector is greater than the corresponding element of the second vector." returns a single result and that's the clang source code.

Since clang is licensed under the University of Illinois/NCSA Open Source License (with portions dual licensed under the MIT License) we should:

  • license stdsimd under these two licenses as well,
  • add a copyright notice to the readme stating that parts of the code has been derived from clang.

I don't know how this affects including stdsimd in std, but if this is not acceptable we should probably ask for legal counsel if removing the copy & pasted comments would be enough to be safe. Other intrinsics like:

/// Converts a 64-bit vector of 16-bit unsigned integer values into a
/// 128-bit vector of [4 x float].
#[inline(always)]
#[target_feature = "+sse"]
pub unsafe fn _mm_cvtpu16_ps(a: u16x4) -> f32x4 {
    let b = mem::transmute(mmx::_mm_setzero_si64());
    let c = mmx::_mm_unpackhi_pi16(a.as_i16x4(), b);
    let r = i586::_mm_setzero_ps();
    let r = cvtpi2ps(r, mem::transmute(c));
    let r = i586::_mm_movelh_ps(r, r);
    let c = mmx::_mm_unpacklo_pi16(a.as_i16x4(), b);
    cvtpi2ps(r, mem::transmute(c))
}

must do exactly what clang does to generate the same code, which means they are necessarily going to look a lot like clang's implementation:

static __inline__ __m128 __DEFAULT_FN_ATTRS
_mm_cvtpu16_ps(__m64 __a)
{
  __m64 __b, __c;
  __m128 __r;

  __b = _mm_setzero_si64();
  __c = _mm_unpackhi_pi16(__a, __b);
  __r = _mm_setzero_ps();
  __r = _mm_cvtpi32_ps(__r, __c);
  __r = _mm_movelh_ps(__r, __r);
  __c = _mm_unpacklo_pi16(__a, __b);
  __r = _mm_cvtpi32_ps(__r, __c);

  return __r;
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the copied Rust intrinsic comments, the README, and the referenced clang lib/Headers/xmmintrin.h implementation. Determine whether the requested University of Illinois/NCSA and MIT licensing notices are acceptable for stdsimd and its inclusion in std; done means the licensing decision and required notices are documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, rust
Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.