Skip to content

Commit 794377d

Browse files
committed
rustfmt using nightly-2025-02-16.
1 parent f891a5a commit 794377d

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
@@ -1094,9 +1094,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
10941094
};
10951095
// TODO: rspirv doesn't have insert_variable function
10961096
let result_id = builder.id();
1097-
let inst = Instruction::new(Op::Variable, Some(ptr_ty), Some(result_id), vec![
1098-
Operand::StorageClass(StorageClass::Function),
1099-
]);
1097+
let inst = Instruction::new(
1098+
Op::Variable,
1099+
Some(ptr_ty),
1100+
Some(result_id),
1101+
vec![Operand::StorageClass(StorageClass::Function)],
1102+
);
11001103
builder.insert_into_block(index, inst).unwrap();
11011104
result_id.with_type(ptr_ty)
11021105
}
@@ -1169,13 +1172,16 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
11691172
let ((line_start, col_start), (line_end, col_end)) =
11701173
(line_col_range.start, line_col_range.end);
11711174

1172-
self.custom_inst(void_ty, CustomInst::SetDebugSrcLoc {
1173-
file: Operand::IdRef(file.file_name_op_string_id),
1174-
line_start: Operand::IdRef(self.const_u32(line_start).def(self)),
1175-
line_end: Operand::IdRef(self.const_u32(line_end).def(self)),
1176-
col_start: Operand::IdRef(self.const_u32(col_start).def(self)),
1177-
col_end: Operand::IdRef(self.const_u32(col_end).def(self)),
1178-
});
1175+
self.custom_inst(
1176+
void_ty,
1177+
CustomInst::SetDebugSrcLoc {
1178+
file: Operand::IdRef(file.file_name_op_string_id),
1179+
line_start: Operand::IdRef(self.const_u32(line_start).def(self)),
1180+
line_end: Operand::IdRef(self.const_u32(line_end).def(self)),
1181+
col_start: Operand::IdRef(self.const_u32(col_start).def(self)),
1182+
col_end: Operand::IdRef(self.const_u32(col_end).def(self)),
1183+
},
1184+
);
11791185
}
11801186

11811187
// HACK(eddyb) remove the previous instruction if made irrelevant.
@@ -1524,11 +1530,14 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
15241530
let signed = match ty.kind() {
15251531
ty::Int(_) => true,
15261532
ty::Uint(_) => false,
1527-
other => self.fatal(format!("Unexpected {} type: {other:#?}", match oop {
1528-
OverflowOp::Add => "checked add",
1529-
OverflowOp::Sub => "checked sub",
1530-
OverflowOp::Mul => "checked mul",
1531-
})),
1533+
other => self.fatal(format!(
1534+
"Unexpected {} type: {other:#?}",
1535+
match oop {
1536+
OverflowOp::Add => "checked add",
1537+
OverflowOp::Sub => "checked sub",
1538+
OverflowOp::Mul => "checked mul",
1539+
}
1540+
)),
15321541
};
15331542

15341543
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
@@ -607,18 +622,21 @@ impl Builder<'_, '_> {
607622
// so the best thing we can do is use our own custom instruction.
608623
let kind_id = self.emit().string(kind);
609624
let message_debug_printf_fmt_str_id = self.emit().string(message_debug_printf_fmt_str);
610-
self.custom_inst(void_ty, CustomInst::Abort {
611-
kind: Operand::IdRef(kind_id),
612-
message_debug_printf: [message_debug_printf_fmt_str_id]
613-
.into_iter()
614-
.chain(
615-
message_debug_printf_args
616-
.into_iter()
617-
.map(|arg| arg.def(self)),
618-
)
619-
.map(Operand::IdRef)
620-
.collect(),
621-
});
625+
self.custom_inst(
626+
void_ty,
627+
CustomInst::Abort {
628+
kind: Operand::IdRef(kind_id),
629+
message_debug_printf: [message_debug_printf_fmt_str_id]
630+
.into_iter()
631+
.chain(
632+
message_debug_printf_args
633+
.into_iter()
634+
.map(|arg| arg.def(self)),
635+
)
636+
.map(Operand::IdRef)
637+
.collect(),
638+
},
639+
);
622640
self.unreachable();
623641

624642
// 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
@@ -172,11 +172,17 @@ impl<'tcx> ConstCodegenMethods<'tcx> for CodegenCx<'tcx> {
172172
.layout_of(self.tcx.types.str_)
173173
.spirv_type(DUMMY_SP, self);
174174
(
175-
self.def_constant(self.type_ptr_to(str_ty), SpirvConst::PtrTo {
176-
pointee: self
177-
.constant_composite(str_ty, s.bytes().map(|b| self.const_u8(b).def_cx(self)))
178-
.def_cx(self),
179-
}),
175+
self.def_constant(
176+
self.type_ptr_to(str_ty),
177+
SpirvConst::PtrTo {
178+
pointee: self
179+
.constant_composite(
180+
str_ty,
181+
s.bytes().map(|b| self.const_u8(b).def_cx(self)),
182+
)
183+
.def_cx(self),
184+
},
185+
),
180186
self.const_usize(len as u64),
181187
)
182188
}

crates/rustc_codegen_spirv/src/codegen_cx/declare.rs

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

128128
let declared = fn_id.with_type(function_type);
129129

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

366369
impl<'tcx> StaticCodegenMethods for CodegenCx<'tcx> {
367370
fn static_addr_of(&self, cv: Self::Value, _align: Align, _kind: Option<&str>) -> Self::Value {
368-
self.def_constant(self.type_ptr_to(cv.ty), SpirvConst::PtrTo {
369-
pointee: cv.def_cx(self),
370-
})
371+
self.def_constant(
372+
self.type_ptr_to(cv.ty),
373+
SpirvConst::PtrTo {
374+
pointee: cv.def_cx(self),
375+
},
376+
)
371377
}
372378

373379
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)