Skip to content

Commit 513039f

Browse files
refactor(naga): rename MathFunction::FindLsb to FirstTrailingBit
1 parent a7a2f16 commit 513039f

File tree

12 files changed

+18
-16
lines changed

12 files changed

+18
-16
lines changed

naga/src/back/glsl/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3574,7 +3574,7 @@ impl<'a, W: Write> Writer<'a, W> {
35743574

35753575
return Ok(());
35763576
}
3577-
Mf::FindLsb => "findLSB",
3577+
Mf::FirstTrailingBit => "findLSB",
35783578
Mf::FirstLeadingBit => "findMSB",
35793579
// data packing
35803580
Mf::Pack4x8snorm => "packSnorm4x8",
@@ -3597,7 +3597,7 @@ impl<'a, W: Write> Writer<'a, W> {
35973597
// so they need to be cast to uint if the argument is also an uint.
35983598
let ret_might_need_int_to_uint = matches!(
35993599
fun,
3600-
Mf::FindLsb | Mf::FirstLeadingBit | Mf::CountOneBits | Mf::Abs
3600+
Mf::FirstTrailingBit | Mf::FirstLeadingBit | Mf::CountOneBits | Mf::Abs
36013601
);
36023602

36033603
// Some GLSL functions only accept signed integers (like abs),

naga/src/back/hlsl/writer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2907,7 +2907,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
29072907
Mf::CountLeadingZeros => Function::CountLeadingZeros,
29082908
Mf::CountOneBits => Function::MissingIntOverload("countbits"),
29092909
Mf::ReverseBits => Function::MissingIntOverload("reversebits"),
2910-
Mf::FindLsb => Function::MissingIntReturnType("firstbitlow"),
2910+
Mf::FirstTrailingBit => Function::MissingIntReturnType("firstbitlow"),
29112911
Mf::FirstLeadingBit => Function::MissingIntReturnType("firstbithigh"),
29122912
Mf::ExtractBits => Function::Regular(EXTRACT_BITS_FUNCTION),
29132913
Mf::InsertBits => Function::Regular(INSERT_BITS_FUNCTION),

naga/src/back/msl/writer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1820,7 +1820,7 @@ impl<W: Write> Writer<W> {
18201820
Mf::ReverseBits => "reverse_bits",
18211821
Mf::ExtractBits => "",
18221822
Mf::InsertBits => "",
1823-
Mf::FindLsb => "",
1823+
Mf::FirstTrailingBit => "",
18241824
Mf::FirstLeadingBit => "",
18251825
// data packing
18261826
Mf::Pack4x8snorm => "pack_float_to_snorm4x8",
@@ -1859,7 +1859,7 @@ impl<W: Write> Writer<W> {
18591859
write!(self.out, " - ")?;
18601860
self.put_expression(arg1.unwrap(), context, false)?;
18611861
write!(self.out, ")")?;
1862-
} else if fun == Mf::FindLsb {
1862+
} else if fun == Mf::FirstTrailingBit {
18631863
let scalar = context.resolve_type(arg).scalar().unwrap();
18641864
let constant = scalar.width * 8 + 1;
18651865

naga/src/back/spv/block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,7 @@ impl<'w> BlockContext<'w> {
11831183
count_id,
11841184
))
11851185
}
1186-
Mf::FindLsb => MathOp::Ext(spirv::GLOp::FindILsb),
1186+
Mf::FirstTrailingBit => MathOp::Ext(spirv::GLOp::FindILsb),
11871187
Mf::FirstLeadingBit => {
11881188
if arg_ty.scalar_width() == Some(4) {
11891189
let thing = match arg_scalar_kind {

naga/src/back/wgsl/writer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1708,7 +1708,7 @@ impl<W: Write> Writer<W> {
17081708
Mf::ReverseBits => Function::Regular("reverseBits"),
17091709
Mf::ExtractBits => Function::Regular("extractBits"),
17101710
Mf::InsertBits => Function::Regular("insertBits"),
1711-
Mf::FindLsb => Function::Regular("firstTrailingBit"),
1711+
Mf::FirstTrailingBit => Function::Regular("firstTrailingBit"),
17121712
Mf::FirstLeadingBit => Function::Regular("firstLeadingBit"),
17131713
// data packing
17141714
Mf::Pack4x8snorm => Function::Regular("pack4x8snorm"),

naga/src/front/glsl/builtins.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ fn inject_standard_builtins(
646646
"bitfieldReverse" => MathFunction::ReverseBits,
647647
"bitfieldExtract" => MathFunction::ExtractBits,
648648
"bitfieldInsert" => MathFunction::InsertBits,
649-
"findLSB" => MathFunction::FindLsb,
649+
"findLSB" => MathFunction::FirstTrailingBit,
650650
"findMSB" => MathFunction::FirstLeadingBit,
651651
_ => unreachable!(),
652652
};
@@ -695,7 +695,9 @@ fn inject_standard_builtins(
695695
// we need to cast the return type of findLsb / findMsb
696696
let mc = if scalar.kind == Sk::Uint {
697697
match mc {
698-
MacroCall::MathFunction(MathFunction::FindLsb) => MacroCall::FindLsbUint,
698+
MacroCall::MathFunction(MathFunction::FirstTrailingBit) => {
699+
MacroCall::FindLsbUint
700+
}
699701
MacroCall::MathFunction(MathFunction::FirstLeadingBit) => {
700702
MacroCall::FindMsbUint
701703
}
@@ -1789,7 +1791,7 @@ impl MacroCall {
17891791
)?,
17901792
mc @ (MacroCall::FindLsbUint | MacroCall::FindMsbUint) => {
17911793
let fun = match mc {
1792-
MacroCall::FindLsbUint => MathFunction::FindLsb,
1794+
MacroCall::FindLsbUint => MathFunction::FirstTrailingBit,
17931795
MacroCall::FindMsbUint => MathFunction::FirstLeadingBit,
17941796
_ => unreachable!(),
17951797
};

naga/src/front/spv/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2985,7 +2985,7 @@ impl<I: Iterator<Item = u32>> Frontend<I> {
29852985
Glo::UnpackHalf2x16 => Mf::Unpack2x16float,
29862986
Glo::UnpackUnorm2x16 => Mf::Unpack2x16unorm,
29872987
Glo::UnpackSnorm2x16 => Mf::Unpack2x16snorm,
2988-
Glo::FindILsb => Mf::FindLsb,
2988+
Glo::FindILsb => Mf::FirstTrailingBit,
29892989
Glo::FindUMsb | Glo::FindSMsb => Mf::FirstLeadingBit,
29902990
// TODO: https://github.com/gfx-rs/naga/issues/2526
29912991
Glo::Modf | Glo::Frexp => return Err(Error::UnsupportedExtInst(inst_id)),

naga/src/front/wgsl/parse/conv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ pub fn map_standard_fun(word: &str) -> Option<crate::MathFunction> {
235235
"reverseBits" => Mf::ReverseBits,
236236
"extractBits" => Mf::ExtractBits,
237237
"insertBits" => Mf::InsertBits,
238-
"firstTrailingBit" => Mf::FindLsb,
238+
"firstTrailingBit" => Mf::FirstTrailingBit,
239239
"firstLeadingBit" => Mf::FirstLeadingBit,
240240
// data packing
241241
"pack4x8snorm" => Mf::Pack4x8snorm,

naga/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,7 @@ pub enum MathFunction {
12111211
ReverseBits,
12121212
ExtractBits,
12131213
InsertBits,
1214-
FindLsb,
1214+
FirstTrailingBit,
12151215
FirstLeadingBit,
12161216
// data packing
12171217
Pack4x8snorm,

naga/src/proc/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ impl super::MathFunction {
509509
Self::ReverseBits => 1,
510510
Self::ExtractBits => 3,
511511
Self::InsertBits => 4,
512-
Self::FindLsb => 1,
512+
Self::FirstTrailingBit => 1,
513513
Self::FirstLeadingBit => 1,
514514
// data packing
515515
Self::Pack4x8snorm => 1,

naga/src/proc/typifier.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ impl<'a> ResolveContext<'a> {
788788
Mf::ReverseBits |
789789
Mf::ExtractBits |
790790
Mf::InsertBits |
791-
Mf::FindLsb |
791+
Mf::FirstTrailingBit |
792792
Mf::FirstLeadingBit => match *res_arg.inner_with(types) {
793793
Ti::Scalar(scalar @ crate::Scalar {
794794
kind: crate::ScalarKind::Sint | crate::ScalarKind::Uint,

naga/src/valid/expression.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,7 @@ impl super::Validator {
13581358
| Mf::CountOneBits
13591359
| Mf::ReverseBits
13601360
| Mf::FirstLeadingBit
1361-
| Mf::FindLsb => {
1361+
| Mf::FirstTrailingBit => {
13621362
if arg1_ty.is_some() || arg2_ty.is_some() || arg3_ty.is_some() {
13631363
return Err(ExpressionError::WrongArgumentCount(fun));
13641364
}

0 commit comments

Comments
 (0)