Skip to content

Commit

Permalink
Add BVec::TRUE and BVec::FALSE (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
atlv24 authored Oct 1, 2022
1 parent 30f1788 commit 5c46189
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 40 deletions.
13 changes: 6 additions & 7 deletions codegen/templates/vec_mask.rs.tera
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,12 @@ pub struct {{ self_t }}(pub(crate) {{ simd_t }});

const MASK: [u32; 2] = [0, 0xff_ff_ff_ff];

const FALSE: {{ self_t }} = {{ self_t }}::new(
{% for c in components %}
false,
{%- endfor %}
);

impl {{ self_t }} {
/// All false.
pub const FALSE: Self = Self::splat(false);

/// All true.
pub const TRUE: Self = Self::splat(true);

/// Creates a new vector mask.
#[inline(always)]
Expand Down Expand Up @@ -276,7 +275,7 @@ impl {{ self_t }} {
impl Default for {{ self_t }} {
#[inline]
fn default() -> Self {
FALSE
Self::FALSE
}
}

Expand Down
10 changes: 7 additions & 3 deletions src/bool/bvec2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ pub struct BVec2 {

const MASK: [u32; 2] = [0, 0xff_ff_ff_ff];

const FALSE: BVec2 = BVec2::new(false, false);

impl BVec2 {
/// All false.
pub const FALSE: Self = Self::splat(false);

/// All true.
pub const TRUE: Self = Self::splat(true);

/// Creates a new vector mask.
#[inline(always)]
pub const fn new(x: bool, y: bool) -> Self {
Expand Down Expand Up @@ -64,7 +68,7 @@ impl BVec2 {
impl Default for BVec2 {
#[inline]
fn default() -> Self {
FALSE
Self::FALSE
}
}

Expand Down
10 changes: 7 additions & 3 deletions src/bool/bvec3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ pub struct BVec3 {

const MASK: [u32; 2] = [0, 0xff_ff_ff_ff];

const FALSE: BVec3 = BVec3::new(false, false, false);

impl BVec3 {
/// All false.
pub const FALSE: Self = Self::splat(false);

/// All true.
pub const TRUE: Self = Self::splat(true);

/// Creates a new vector mask.
#[inline(always)]
pub const fn new(x: bool, y: bool, z: bool) -> Self {
Expand Down Expand Up @@ -69,7 +73,7 @@ impl BVec3 {
impl Default for BVec3 {
#[inline]
fn default() -> Self {
FALSE
Self::FALSE
}
}

Expand Down
10 changes: 7 additions & 3 deletions src/bool/bvec4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ pub struct BVec4 {

const MASK: [u32; 2] = [0, 0xff_ff_ff_ff];

const FALSE: BVec4 = BVec4::new(false, false, false, false);

impl BVec4 {
/// All false.
pub const FALSE: Self = Self::splat(false);

/// All true.
pub const TRUE: Self = Self::splat(true);

/// Creates a new vector mask.
#[inline(always)]
pub const fn new(x: bool, y: bool, z: bool, w: bool) -> Self {
Expand Down Expand Up @@ -71,7 +75,7 @@ impl BVec4 {
impl Default for BVec4 {
#[inline]
fn default() -> Self {
FALSE
Self::FALSE
}
}

Expand Down
10 changes: 7 additions & 3 deletions src/bool/coresimd/bvec3a.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ pub struct BVec3A(pub(crate) mask32x4);

const MASK: [u32; 2] = [0, 0xff_ff_ff_ff];

const FALSE: BVec3A = BVec3A::new(false, false, false);

impl BVec3A {
/// All false.
pub const FALSE: Self = Self::splat(false);

/// All true.
pub const TRUE: Self = Self::splat(true);

/// Creates a new vector mask.
#[inline(always)]
pub const fn new(x: bool, y: bool, z: bool) -> Self {
Expand Down Expand Up @@ -82,7 +86,7 @@ impl BVec3A {
impl Default for BVec3A {
#[inline]
fn default() -> Self {
FALSE
Self::FALSE
}
}

Expand Down
10 changes: 7 additions & 3 deletions src/bool/coresimd/bvec4a.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ pub struct BVec4A(pub(crate) mask32x4);

const MASK: [u32; 2] = [0, 0xff_ff_ff_ff];

const FALSE: BVec4A = BVec4A::new(false, false, false, false);

impl BVec4A {
/// All false.
pub const FALSE: Self = Self::splat(false);

/// All true.
pub const TRUE: Self = Self::splat(true);

/// Creates a new vector mask.
#[inline(always)]
pub const fn new(x: bool, y: bool, z: bool, w: bool) -> Self {
Expand Down Expand Up @@ -93,7 +97,7 @@ impl BVec4A {
impl Default for BVec4A {
#[inline]
fn default() -> Self {
FALSE
Self::FALSE
}
}

Expand Down
10 changes: 7 additions & 3 deletions src/bool/scalar/bvec3a.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ pub struct BVec3A {

const MASK: [u32; 2] = [0, 0xff_ff_ff_ff];

const FALSE: BVec3A = BVec3A::new(false, false, false);

impl BVec3A {
/// All false.
pub const FALSE: Self = Self::splat(false);

/// All true.
pub const TRUE: Self = Self::splat(true);

/// Creates a new vector mask.
#[inline(always)]
pub const fn new(x: bool, y: bool, z: bool) -> Self {
Expand Down Expand Up @@ -73,7 +77,7 @@ impl BVec3A {
impl Default for BVec3A {
#[inline]
fn default() -> Self {
FALSE
Self::FALSE
}
}

Expand Down
10 changes: 7 additions & 3 deletions src/bool/scalar/bvec4a.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ pub struct BVec4A {

const MASK: [u32; 2] = [0, 0xff_ff_ff_ff];

const FALSE: BVec4A = BVec4A::new(false, false, false, false);

impl BVec4A {
/// All false.
pub const FALSE: Self = Self::splat(false);

/// All true.
pub const TRUE: Self = Self::splat(true);

/// Creates a new vector mask.
#[inline(always)]
pub const fn new(x: bool, y: bool, z: bool, w: bool) -> Self {
Expand Down Expand Up @@ -76,7 +80,7 @@ impl BVec4A {
impl Default for BVec4A {
#[inline]
fn default() -> Self {
FALSE
Self::FALSE
}
}

Expand Down
10 changes: 7 additions & 3 deletions src/bool/sse2/bvec3a.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ pub struct BVec3A(pub(crate) __m128);

const MASK: [u32; 2] = [0, 0xff_ff_ff_ff];

const FALSE: BVec3A = BVec3A::new(false, false, false);

impl BVec3A {
/// All false.
pub const FALSE: Self = Self::splat(false);

/// All true.
pub const TRUE: Self = Self::splat(true);

/// Creates a new vector mask.
#[inline(always)]
pub const fn new(x: bool, y: bool, z: bool) -> Self {
Expand Down Expand Up @@ -85,7 +89,7 @@ impl BVec3A {
impl Default for BVec3A {
#[inline]
fn default() -> Self {
FALSE
Self::FALSE
}
}

Expand Down
10 changes: 7 additions & 3 deletions src/bool/sse2/bvec4a.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ pub struct BVec4A(pub(crate) __m128);

const MASK: [u32; 2] = [0, 0xff_ff_ff_ff];

const FALSE: BVec4A = BVec4A::new(false, false, false, false);

impl BVec4A {
/// All false.
pub const FALSE: Self = Self::splat(false);

/// All true.
pub const TRUE: Self = Self::splat(true);

/// Creates a new vector mask.
#[inline(always)]
pub const fn new(x: bool, y: bool, z: bool, w: bool) -> Self {
Expand Down Expand Up @@ -96,7 +100,7 @@ impl BVec4A {
impl Default for BVec4A {
#[inline]
fn default() -> Self {
FALSE
Self::FALSE
}
}

Expand Down
10 changes: 7 additions & 3 deletions src/bool/wasm32/bvec3a.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ pub struct BVec3A(pub(crate) v128);

const MASK: [u32; 2] = [0, 0xff_ff_ff_ff];

const FALSE: BVec3A = BVec3A::new(false, false, false);

impl BVec3A {
/// All false.
pub const FALSE: Self = Self::splat(false);

/// All true.
pub const TRUE: Self = Self::splat(true);

/// Creates a new vector mask.
#[inline(always)]
pub const fn new(x: bool, y: bool, z: bool) -> Self {
Expand Down Expand Up @@ -77,7 +81,7 @@ impl BVec3A {
impl Default for BVec3A {
#[inline]
fn default() -> Self {
FALSE
Self::FALSE
}
}

Expand Down
10 changes: 7 additions & 3 deletions src/bool/wasm32/bvec4a.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ pub struct BVec4A(pub(crate) v128);

const MASK: [u32; 2] = [0, 0xff_ff_ff_ff];

const FALSE: BVec4A = BVec4A::new(false, false, false, false);

impl BVec4A {
/// All false.
pub const FALSE: Self = Self::splat(false);

/// All true.
pub const TRUE: Self = Self::splat(true);

/// Creates a new vector mask.
#[inline(always)]
pub const fn new(x: bool, y: bool, z: bool, w: bool) -> Self {
Expand Down Expand Up @@ -83,7 +87,7 @@ impl BVec4A {
impl Default for BVec4A {
#[inline]
fn default() -> Self {
FALSE
Self::FALSE
}
}

Expand Down

0 comments on commit 5c46189

Please sign in to comment.