Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Literal::zero where appropriate. #2549

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Use Literal::zero where appropriate.
jimblandy committed Oct 9, 2023
commit 1d41f4fc279b3e079c36c0fa8a3a57e96cb813df
31 changes: 6 additions & 25 deletions src/proc/mod.rs
Original file line number Diff line number Diff line change
@@ -623,33 +623,14 @@ impl GlobalCtx<'_> {
handle: crate::Handle<crate::Expression>,
arena: &crate::Arena<crate::Expression>,
) -> Option<crate::Literal> {
Some(match arena[handle] {
crate::Expression::Literal(literal) => literal,
match arena[handle] {
crate::Expression::Literal(literal) => Some(literal),
crate::Expression::ZeroValue(ty) => match gctx.types[ty].inner {
crate::TypeInner::Scalar {
kind: crate::ScalarKind::Sint,
width: 4,
} => crate::Literal::I32(0),
crate::TypeInner::Scalar {
kind: crate::ScalarKind::Uint,
width: 4,
} => crate::Literal::U32(0),
crate::TypeInner::Scalar {
kind: crate::ScalarKind::Float,
width: 4,
} => crate::Literal::F32(0.0),
crate::TypeInner::Scalar {
kind: crate::ScalarKind::Float,
width: 8,
} => crate::Literal::F64(0.0),
crate::TypeInner::Scalar {
kind: crate::ScalarKind::Bool,
width: 1,
} => crate::Literal::Bool(false),
_ => return None,
crate::TypeInner::Scalar { kind, width } => crate::Literal::zero(kind, width),
_ => None,
},
_ => return None,
})
_ => None,
}
}
match arena[handle] {
crate::Expression::Constant(c) => {