Skip to content

Commit

Permalink
fixup! feat(const_eval): impl. abs
Browse files Browse the repository at this point in the history
  • Loading branch information
ErichDonGubler committed Dec 14, 2023
1 parent 596bef9 commit cfe4e5b
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions naga/src/proc/constant_evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,23 @@ macro_rules! gen_component_wise_extractor {
};
}

gen_component_wise_extractor! {
component_wise_scalar -> Scalar,
literals: [
AbstractFloat => AbstractFloat,
F32 => F32,
AbstractInt => AbstractInt,
U32 => U32,
I32 => I32,
],
scalar_kinds: [
Float,
AbstractFloat,
Uint,
AbstractInt,
],
}

gen_component_wise_extractor! {
component_wise_float -> Float,
literals: [
Expand Down Expand Up @@ -2318,6 +2335,32 @@ impl From<f32> for Expression {
}
}

impl From<i64> for Expression {
fn from(value: i64) -> Self {
Self::Literal(Literal::AbstractInt(value))
}
}

impl From<u32> for Expression {
fn from(value: u32) -> Self {
Self::Literal(Literal::U32(value))
}
}

impl From<i32> for Expression {
fn from(value: i32) -> Self {
Self::Literal(Literal::I32(value))
}
}

pub(super) enum Scalar<const N: usize> {
AbstractFloat([f64; N]),
F32([f32; N]),
AbstractInt([i64; N]),
U32([u32; N]),
I32([i32; N]),
}

pub(super) enum Float<const N: usize> {
Abstract([f64; N]),
F32([f32; N]),
Expand Down

0 comments on commit cfe4e5b

Please sign in to comment.