Skip to content

Commit ff54cd7

Browse files
committed
rustfmt using nightly-2025-02-16.
1 parent bf7c2e6 commit ff54cd7

File tree

17 files changed

+310
-204
lines changed

17 files changed

+310
-204
lines changed

crates/rustc_codegen_spirv/src/builder/builder_methods.rs

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,9 +1275,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
12751275
};
12761276
// TODO: rspirv doesn't have insert_variable function
12771277
let result_id = builder.id();
1278-
let inst = Instruction::new(Op::Variable, Some(ptr_ty), Some(result_id), vec![
1279-
Operand::StorageClass(StorageClass::Function),
1280-
]);
1278+
let inst = Instruction::new(
1279+
Op::Variable,
1280+
Some(ptr_ty),
1281+
Some(result_id),
1282+
vec![Operand::StorageClass(StorageClass::Function)],
1283+
);
12811284
builder.insert_into_block(index, inst).unwrap();
12821285
result_id.with_type(ptr_ty)
12831286
}
@@ -1350,13 +1353,16 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
13501353
let ((line_start, col_start), (line_end, col_end)) =
13511354
(line_col_range.start, line_col_range.end);
13521355

1353-
self.custom_inst(void_ty, CustomInst::SetDebugSrcLoc {
1354-
file: Operand::IdRef(file.file_name_op_string_id),
1355-
line_start: Operand::IdRef(self.const_u32(line_start).def(self)),
1356-
line_end: Operand::IdRef(self.const_u32(line_end).def(self)),
1357-
col_start: Operand::IdRef(self.const_u32(col_start).def(self)),
1358-
col_end: Operand::IdRef(self.const_u32(col_end).def(self)),
1359-
});
1356+
self.custom_inst(
1357+
void_ty,
1358+
CustomInst::SetDebugSrcLoc {
1359+
file: Operand::IdRef(file.file_name_op_string_id),
1360+
line_start: Operand::IdRef(self.const_u32(line_start).def(self)),
1361+
line_end: Operand::IdRef(self.const_u32(line_end).def(self)),
1362+
col_start: Operand::IdRef(self.const_u32(col_start).def(self)),
1363+
col_end: Operand::IdRef(self.const_u32(col_end).def(self)),
1364+
},
1365+
);
13601366
}
13611367

13621368
// HACK(eddyb) remove the previous instruction if made irrelevant.
@@ -1705,11 +1711,14 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
17051711
let signed = match ty.kind() {
17061712
ty::Int(_) => true,
17071713
ty::Uint(_) => false,
1708-
other => self.fatal(format!("Unexpected {} type: {other:#?}", match oop {
1709-
OverflowOp::Add => "checked add",
1710-
OverflowOp::Sub => "checked sub",
1711-
OverflowOp::Mul => "checked mul",
1712-
})),
1714+
other => self.fatal(format!(
1715+
"Unexpected {} type: {other:#?}",
1716+
match oop {
1717+
OverflowOp::Add => "checked add",
1718+
OverflowOp::Sub => "checked sub",
1719+
OverflowOp::Mul => "checked mul",
1720+
}
1721+
)),
17131722
};
17141723

17151724
let result = if is_add {

crates/rustc_codegen_spirv/src/builder/intrinsics.rs

Lines changed: 53 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,11 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> {
161161
}
162162
sym::sinf32 | sym::sinf64 => self.gl_op(GLOp::Sin, ret_ty, [args[0].immediate()]),
163163
sym::cosf32 | sym::cosf64 => self.gl_op(GLOp::Cos, ret_ty, [args[0].immediate()]),
164-
sym::powf32 | sym::powf64 => self.gl_op(GLOp::Pow, ret_ty, [
165-
args[0].immediate(),
166-
args[1].immediate(),
167-
]),
164+
sym::powf32 | sym::powf64 => self.gl_op(
165+
GLOp::Pow,
166+
ret_ty,
167+
[args[0].immediate(), args[1].immediate()],
168+
),
168169
sym::expf32 | sym::expf64 => self.gl_op(GLOp::Exp, ret_ty, [args[0].immediate()]),
169170
sym::exp2f32 | sym::exp2f64 => self.gl_op(GLOp::Exp2, ret_ty, [args[0].immediate()]),
170171
sym::logf32 | sym::logf64 => self.gl_op(GLOp::Log, ret_ty, [args[0].immediate()]),
@@ -176,20 +177,26 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> {
176177
let ln = self.gl_op(GLOp::Log, ret_ty, [args[0].immediate()]);
177178
self.fmul(mul, ln)
178179
}
179-
sym::fmaf32 | sym::fmaf64 => self.gl_op(GLOp::Fma, ret_ty, [
180-
args[0].immediate(),
181-
args[1].immediate(),
182-
args[2].immediate(),
183-
]),
180+
sym::fmaf32 | sym::fmaf64 => self.gl_op(
181+
GLOp::Fma,
182+
ret_ty,
183+
[
184+
args[0].immediate(),
185+
args[1].immediate(),
186+
args[2].immediate(),
187+
],
188+
),
184189
sym::fabsf32 | sym::fabsf64 => self.gl_op(GLOp::FAbs, ret_ty, [args[0].immediate()]),
185-
sym::minnumf32 | sym::minnumf64 => self.gl_op(GLOp::FMin, ret_ty, [
186-
args[0].immediate(),
187-
args[1].immediate(),
188-
]),
189-
sym::maxnumf32 | sym::maxnumf64 => self.gl_op(GLOp::FMax, ret_ty, [
190-
args[0].immediate(),
191-
args[1].immediate(),
192-
]),
190+
sym::minnumf32 | sym::minnumf64 => self.gl_op(
191+
GLOp::FMin,
192+
ret_ty,
193+
[args[0].immediate(), args[1].immediate()],
194+
),
195+
sym::maxnumf32 | sym::maxnumf64 => self.gl_op(
196+
GLOp::FMax,
197+
ret_ty,
198+
[args[0].immediate(), args[1].immediate()],
199+
),
193200
sym::copysignf32 | sym::copysignf64 => {
194201
let val = args[0].immediate();
195202
let sign = args[1].immediate();
@@ -485,9 +492,13 @@ impl Builder<'_, '_> {
485492
if trailing {
486493
let lsb = self
487494
.emit()
488-
.ext_inst(u32, None, glsl, GLOp::FindILsb as u32, [Operand::IdRef(
489-
arg,
490-
)])
495+
.ext_inst(
496+
u32,
497+
None,
498+
glsl,
499+
GLOp::FindILsb as u32,
500+
[Operand::IdRef(arg)],
501+
)
491502
.unwrap();
492503
if offset == 0 {
493504
lsb
@@ -499,9 +510,13 @@ impl Builder<'_, '_> {
499510
// rust is always unsigned, so FindUMsb
500511
let msb_bit = self
501512
.emit()
502-
.ext_inst(u32, None, glsl, GLOp::FindUMsb as u32, [Operand::IdRef(
503-
arg,
504-
)])
513+
.ext_inst(
514+
u32,
515+
None,
516+
glsl,
517+
GLOp::FindUMsb as u32,
518+
[Operand::IdRef(arg)],
519+
)
505520
.unwrap();
506521
// the glsl op returns the Msb bit, not the amount of leading zeros of this u32
507522
// leading zeros = 31 - Msb bit
@@ -606,18 +621,21 @@ impl Builder<'_, '_> {
606621
// so the best thing we can do is use our own custom instruction.
607622
let kind_id = self.emit().string(kind);
608623
let message_debug_printf_fmt_str_id = self.emit().string(message_debug_printf_fmt_str);
609-
self.custom_inst(void_ty, CustomInst::Abort {
610-
kind: Operand::IdRef(kind_id),
611-
message_debug_printf: [message_debug_printf_fmt_str_id]
612-
.into_iter()
613-
.chain(
614-
message_debug_printf_args
615-
.into_iter()
616-
.map(|arg| arg.def(self)),
617-
)
618-
.map(Operand::IdRef)
619-
.collect(),
620-
});
624+
self.custom_inst(
625+
void_ty,
626+
CustomInst::Abort {
627+
kind: Operand::IdRef(kind_id),
628+
message_debug_printf: [message_debug_printf_fmt_str_id]
629+
.into_iter()
630+
.chain(
631+
message_debug_printf_args
632+
.into_iter()
633+
.map(|arg| arg.def(self)),
634+
)
635+
.map(Operand::IdRef)
636+
.collect(),
637+
},
638+
);
621639
self.unreachable();
622640

623641
// HACK(eddyb) we still need an active block in case the user of this

crates/rustc_codegen_spirv/src/builder/libm_intrinsics.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,11 @@ impl Builder<'_, '_> {
230230
}
231231
LibmIntrinsic::Custom(LibmCustomIntrinsic::Cbrt) => {
232232
assert_eq!(args.len(), 1);
233-
self.gl_op(GLOp::Pow, result_type, [
234-
args[0],
235-
self.constant_float(args[0].ty, 1.0 / 3.0),
236-
])
233+
self.gl_op(
234+
GLOp::Pow,
235+
result_type,
236+
[args[0], self.constant_float(args[0].ty, 1.0 / 3.0)],
237+
)
237238
}
238239
LibmIntrinsic::Custom(LibmCustomIntrinsic::Log10) => {
239240
assert_eq!(args.len(), 1);

crates/rustc_codegen_spirv/src/codegen_cx/constant.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,17 @@ impl<'tcx> ConstCodegenMethods<'tcx> for CodegenCx<'tcx> {
169169
.layout_of(self.tcx.types.str_)
170170
.spirv_type(DUMMY_SP, self);
171171
(
172-
self.def_constant(self.type_ptr_to(str_ty), SpirvConst::PtrTo {
173-
pointee: self
174-
.constant_composite(str_ty, s.bytes().map(|b| self.const_u8(b).def_cx(self)))
175-
.def_cx(self),
176-
}),
172+
self.def_constant(
173+
self.type_ptr_to(str_ty),
174+
SpirvConst::PtrTo {
175+
pointee: self
176+
.constant_composite(
177+
str_ty,
178+
s.bytes().map(|b| self.const_u8(b).def_cx(self)),
179+
)
180+
.def_cx(self),
181+
},
182+
),
177183
self.const_usize(len as u64),
178184
)
179185
}

crates/rustc_codegen_spirv/src/codegen_cx/declare.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,16 @@ impl<'tcx> CodegenCx<'tcx> {
131131

132132
let declared = fn_id.with_type(function_type);
133133

134-
let attrs = AggregatedSpirvAttributes::parse(self, match self.tcx.def_kind(def_id) {
135-
// This was made to ICE cross-crate at some point, but then got
136-
// reverted in https://github.com/rust-lang/rust/pull/111381.
137-
// FIXME(eddyb) remove this workaround once we rustup past that.
138-
DefKind::Closure => &[],
139-
_ => self.tcx.get_attrs_unchecked(def_id),
140-
});
134+
let attrs = AggregatedSpirvAttributes::parse(
135+
self,
136+
match self.tcx.def_kind(def_id) {
137+
// This was made to ICE cross-crate at some point, but then got
138+
// reverted in https://github.com/rust-lang/rust/pull/111381.
139+
// FIXME(eddyb) remove this workaround once we rustup past that.
140+
DefKind::Closure => &[],
141+
_ => self.tcx.get_attrs_unchecked(def_id),
142+
},
143+
);
141144
if let Some(entry) = attrs.entry.map(|attr| attr.value) {
142145
let entry_name = entry
143146
.name
@@ -339,9 +342,12 @@ impl<'tcx> PreDefineCodegenMethods<'tcx> for CodegenCx<'tcx> {
339342

340343
impl<'tcx> StaticCodegenMethods for CodegenCx<'tcx> {
341344
fn static_addr_of(&self, cv: Self::Value, _align: Align, _kind: Option<&str>) -> Self::Value {
342-
self.def_constant(self.type_ptr_to(cv.ty), SpirvConst::PtrTo {
343-
pointee: cv.def_cx(self),
344-
})
345+
self.def_constant(
346+
self.type_ptr_to(cv.ty),
347+
SpirvConst::PtrTo {
348+
pointee: cv.def_cx(self),
349+
},
350+
)
345351
}
346352

347353
fn codegen_static(&self, def_id: DefId) {

crates/rustc_codegen_spirv/src/codegen_cx/entry.rs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -354,10 +354,13 @@ impl<'tcx> CodegenCx<'tcx> {
354354
if !ref_is_read_only && storage_class_requires_read_only {
355355
let mut err = self.tcx.dcx().struct_span_err(
356356
hir_param.ty_span,
357-
format!("entry-point requires {}...", match explicit_mutbl {
358-
hir::Mutability::Not => "interior mutability",
359-
hir::Mutability::Mut => "a mutable reference",
360-
}),
357+
format!(
358+
"entry-point requires {}...",
359+
match explicit_mutbl {
360+
hir::Mutability::Not => "interior mutability",
361+
hir::Mutability::Mut => "a mutable reference",
362+
}
363+
),
361364
);
362365
{
363366
let note_message =
@@ -445,9 +448,11 @@ impl<'tcx> CodegenCx<'tcx> {
445448
let mut emit = self.emit_global();
446449
let spec_const_id =
447450
emit.spec_constant_bit32(value_spirv_type, default.unwrap_or(0));
448-
emit.decorate(spec_const_id, Decoration::SpecId, [Operand::LiteralBit32(
449-
id,
450-
)]);
451+
emit.decorate(
452+
spec_const_id,
453+
Decoration::SpecId,
454+
[Operand::LiteralBit32(id)],
455+
);
451456
(
452457
Err("`#[spirv(spec_constant)]` is not an entry-point interface variable"),
453458
Ok(spec_const_id),
@@ -772,10 +777,13 @@ impl<'tcx> CodegenCx<'tcx> {
772777
} => true,
773778
SpirvType::RuntimeArray { element: elt, .. }
774779
| SpirvType::Array { element: elt, .. } => {
775-
matches!(self.lookup_type(elt), SpirvType::Image {
776-
dim: Dim::DimSubpassData,
777-
..
778-
})
780+
matches!(
781+
self.lookup_type(elt),
782+
SpirvType::Image {
783+
dim: Dim::DimSubpassData,
784+
..
785+
}
786+
)
779787
}
780788
_ => false,
781789
};

crates/rustc_codegen_spirv/src/custom_decorations.rs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,16 @@ pub trait CustomDecoration<'a>: Sized {
3939
let mut encoded = Self::ENCODING_PREFIX.to_string();
4040
self.encode(&mut encoded).unwrap();
4141

42-
Instruction::new(Op::DecorateString, None, None, vec![
43-
Operand::IdRef(id),
44-
Operand::Decoration(Decoration::UserTypeGOOGLE),
45-
Operand::LiteralString(encoded),
46-
])
42+
Instruction::new(
43+
Op::DecorateString,
44+
None,
45+
None,
46+
vec![
47+
Operand::IdRef(id),
48+
Operand::Decoration(Decoration::UserTypeGOOGLE),
49+
Operand::LiteralString(encoded),
50+
],
51+
)
4752
}
4853

4954
fn try_decode_from_inst(inst: &Instruction) -> Option<(Word, LazilyDecoded<'_, Self>)> {
@@ -54,10 +59,13 @@ pub trait CustomDecoration<'a>: Sized {
5459
let prefixed_encoded = inst.operands[2].unwrap_literal_string();
5560
let encoded = prefixed_encoded.strip_prefix(Self::ENCODING_PREFIX)?;
5661

57-
Some((id, LazilyDecoded {
58-
encoded,
59-
_marker: PhantomData,
60-
}))
62+
Some((
63+
id,
64+
LazilyDecoded {
65+
encoded,
66+
_marker: PhantomData,
67+
},
68+
))
6169
} else {
6270
None
6371
}

0 commit comments

Comments
 (0)