mirror of
https://github.com/EmbarkStudios/rust-gpu.git
synced 2024-11-21 22:34:34 +00:00
Clippy fixes
This commit is contained in:
parent
86d6042204
commit
33c2f80835
@ -74,7 +74,7 @@ impl<'a> Trie<'a> {
|
|||||||
let full_child_name = if full_name.is_empty() {
|
let full_child_name = if full_name.is_empty() {
|
||||||
(*child_name).to_string()
|
(*child_name).to_string()
|
||||||
} else {
|
} else {
|
||||||
format!("{}::{}", full_name, child_name)
|
format!("{full_name}::{child_name}")
|
||||||
};
|
};
|
||||||
if child.present {
|
if child.present {
|
||||||
assert!(child.children.is_empty());
|
assert!(child.children.is_empty());
|
||||||
|
@ -78,7 +78,7 @@ fn main() -> ExitCode {
|
|||||||
match check_toolchain_version() {
|
match check_toolchain_version() {
|
||||||
Ok(_) => ExitCode::SUCCESS,
|
Ok(_) => ExitCode::SUCCESS,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprint!("{}", e);
|
eprint!("{e}");
|
||||||
ExitCode::FAILURE
|
ExitCode::FAILURE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -270,7 +270,7 @@ impl fmt::Display for PointeeTy<'_> {
|
|||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
PointeeTy::Ty(ty) => write!(f, "{}", ty.ty),
|
PointeeTy::Ty(ty) => write!(f, "{}", ty.ty),
|
||||||
PointeeTy::Fn(ty) => write!(f, "{}", ty),
|
PointeeTy::Fn(ty) => write!(f, "{ty}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -577,8 +577,7 @@ fn dig_scalar_pointee<'tcx>(
|
|||||||
Some(old_pointee) if old_pointee != new_pointee => {
|
Some(old_pointee) if old_pointee != new_pointee => {
|
||||||
cx.tcx.sess.fatal(format!(
|
cx.tcx.sess.fatal(format!(
|
||||||
"dig_scalar_pointee: unsupported Pointer with different \
|
"dig_scalar_pointee: unsupported Pointer with different \
|
||||||
pointee types ({:?} vs {:?}) at offset {:?} in {:#?}",
|
pointee types ({old_pointee:?} vs {new_pointee:?}) at offset {offset:?} in {layout:#?}"
|
||||||
old_pointee, new_pointee, offset, layout
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
_ => pointee = Some(new_pointee),
|
_ => pointee = Some(new_pointee),
|
||||||
@ -860,7 +859,7 @@ fn trans_intrinsic_type<'tcx>(
|
|||||||
None => Err(cx
|
None => Err(cx
|
||||||
.tcx
|
.tcx
|
||||||
.sess
|
.sess
|
||||||
.err(format!("Invalid value for Image const generic: {}", value))),
|
.err(format!("Invalid value for Image const generic: {value}"))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ impl AggregatedSpirvAttributes {
|
|||||||
}) => {
|
}) => {
|
||||||
cx.tcx
|
cx.tcx
|
||||||
.sess
|
.sess
|
||||||
.delay_span_bug(span, format!("multiple {} attributes", category));
|
.delay_span_bug(span, format!("multiple {category} attributes"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -333,7 +333,7 @@ impl CheckSpirvAttrVisitor<'_> {
|
|||||||
if let Err(msg) = valid {
|
if let Err(msg) = valid {
|
||||||
self.tcx.sess.span_err(
|
self.tcx.sess.span_err(
|
||||||
span,
|
span,
|
||||||
format!("`{:?}` storage class {}", storage_class, msg),
|
format!("`{storage_class:?}` storage class {msg}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -355,8 +355,7 @@ impl CheckSpirvAttrVisitor<'_> {
|
|||||||
self.tcx.sess.span_err(
|
self.tcx.sess.span_err(
|
||||||
span,
|
span,
|
||||||
format!(
|
format!(
|
||||||
"attribute is only valid on a {}, not on a {}",
|
"attribute is only valid on a {expected_target}, not on a {target}"
|
||||||
expected_target, target
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -371,11 +370,10 @@ impl CheckSpirvAttrVisitor<'_> {
|
|||||||
.struct_span_err(
|
.struct_span_err(
|
||||||
span,
|
span,
|
||||||
&format!(
|
&format!(
|
||||||
"only one {} attribute is allowed on a {}",
|
"only one {category} attribute is allowed on a {target}"
|
||||||
category, target
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.span_note(prev_span, &format!("previous {} attribute", category))
|
.span_note(prev_span, &format!("previous {category} attribute"))
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -193,8 +193,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
.constant_u64(self.span(), memset_fill_u64(fill_byte))
|
.constant_u64(self.span(), memset_fill_u64(fill_byte))
|
||||||
.def(self),
|
.def(self),
|
||||||
_ => self.fatal(&format!(
|
_ => self.fatal(&format!(
|
||||||
"memset on integer width {} not implemented yet",
|
"memset on integer width {width} not implemented yet"
|
||||||
width
|
|
||||||
)),
|
)),
|
||||||
},
|
},
|
||||||
SpirvType::Float(width) => match width {
|
SpirvType::Float(width) => match width {
|
||||||
@ -205,8 +204,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
.constant_f64(self.span(), f64::from_bits(memset_fill_u64(fill_byte)))
|
.constant_f64(self.span(), f64::from_bits(memset_fill_u64(fill_byte)))
|
||||||
.def(self),
|
.def(self),
|
||||||
_ => self.fatal(&format!(
|
_ => self.fatal(&format!(
|
||||||
"memset on float width {} not implemented yet",
|
"memset on float width {width} not implemented yet"
|
||||||
width
|
|
||||||
)),
|
)),
|
||||||
},
|
},
|
||||||
SpirvType::Adt { .. } => self.fatal("memset on structs not implemented yet"),
|
SpirvType::Adt { .. } => self.fatal("memset on structs not implemented yet"),
|
||||||
@ -253,16 +251,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
32 => memset_dynamic_scalar(self, fill_var, 4, false),
|
32 => memset_dynamic_scalar(self, fill_var, 4, false),
|
||||||
64 => memset_dynamic_scalar(self, fill_var, 8, false),
|
64 => memset_dynamic_scalar(self, fill_var, 8, false),
|
||||||
_ => self.fatal(&format!(
|
_ => self.fatal(&format!(
|
||||||
"memset on integer width {} not implemented yet",
|
"memset on integer width {width} not implemented yet"
|
||||||
width
|
|
||||||
)),
|
)),
|
||||||
},
|
},
|
||||||
SpirvType::Float(width) => match width {
|
SpirvType::Float(width) => match width {
|
||||||
32 => memset_dynamic_scalar(self, fill_var, 4, true),
|
32 => memset_dynamic_scalar(self, fill_var, 4, true),
|
||||||
64 => memset_dynamic_scalar(self, fill_var, 8, true),
|
64 => memset_dynamic_scalar(self, fill_var, 8, true),
|
||||||
_ => self.fatal(&format!(
|
_ => self.fatal(&format!(
|
||||||
"memset on float width {} not implemented yet",
|
"memset on float width {width} not implemented yet"
|
||||||
width
|
|
||||||
)),
|
)),
|
||||||
},
|
},
|
||||||
SpirvType::Adt { .. } => self.fatal("memset on structs not implemented yet"),
|
SpirvType::Adt { .. } => self.fatal("memset on structs not implemented yet"),
|
||||||
@ -367,7 +363,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
if !self.builder.has_capability(Capability::VariablePointers) {
|
if !self.builder.has_capability(Capability::VariablePointers) {
|
||||||
self.zombie(
|
self.zombie(
|
||||||
def,
|
def,
|
||||||
&format!("{} without OpCapability VariablePointers", inst),
|
&format!("{inst} without OpCapability VariablePointers"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -725,8 +721,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
|
|||||||
fn construct_8(self_: &Builder<'_, '_>, signed: bool, v: u128) -> Operand {
|
fn construct_8(self_: &Builder<'_, '_>, signed: bool, v: u128) -> Operand {
|
||||||
if v > u8::MAX as u128 {
|
if v > u8::MAX as u128 {
|
||||||
self_.fatal(&format!(
|
self_.fatal(&format!(
|
||||||
"Switches to values above u8::MAX not supported: {:?}",
|
"Switches to values above u8::MAX not supported: {v:?}"
|
||||||
v
|
|
||||||
))
|
))
|
||||||
} else if signed {
|
} else if signed {
|
||||||
// this cast chain can probably be collapsed, but, whatever, be safe
|
// this cast chain can probably be collapsed, but, whatever, be safe
|
||||||
@ -738,8 +733,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
|
|||||||
fn construct_16(self_: &Builder<'_, '_>, signed: bool, v: u128) -> Operand {
|
fn construct_16(self_: &Builder<'_, '_>, signed: bool, v: u128) -> Operand {
|
||||||
if v > u16::MAX as u128 {
|
if v > u16::MAX as u128 {
|
||||||
self_.fatal(&format!(
|
self_.fatal(&format!(
|
||||||
"Switches to values above u16::MAX not supported: {:?}",
|
"Switches to values above u16::MAX not supported: {v:?}"
|
||||||
v
|
|
||||||
))
|
))
|
||||||
} else if signed {
|
} else if signed {
|
||||||
Operand::LiteralInt32(v as u16 as i16 as i32 as u32)
|
Operand::LiteralInt32(v as u16 as i16 as i32 as u32)
|
||||||
@ -750,8 +744,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
|
|||||||
fn construct_32(self_: &Builder<'_, '_>, _signed: bool, v: u128) -> Operand {
|
fn construct_32(self_: &Builder<'_, '_>, _signed: bool, v: u128) -> Operand {
|
||||||
if v > u32::MAX as u128 {
|
if v > u32::MAX as u128 {
|
||||||
self_.fatal(&format!(
|
self_.fatal(&format!(
|
||||||
"Switches to values above u32::MAX not supported: {:?}",
|
"Switches to values above u32::MAX not supported: {v:?}"
|
||||||
v
|
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
Operand::LiteralInt32(v as u32)
|
Operand::LiteralInt32(v as u32)
|
||||||
@ -760,8 +753,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
|
|||||||
fn construct_64(self_: &Builder<'_, '_>, _signed: bool, v: u128) -> Operand {
|
fn construct_64(self_: &Builder<'_, '_>, _signed: bool, v: u128) -> Operand {
|
||||||
if v > u64::MAX as u128 {
|
if v > u64::MAX as u128 {
|
||||||
self_.fatal(&format!(
|
self_.fatal(&format!(
|
||||||
"Switches to values above u64::MAX not supported: {:?}",
|
"Switches to values above u64::MAX not supported: {v:?}"
|
||||||
v
|
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
Operand::LiteralInt64(v as u64)
|
Operand::LiteralInt64(v as u64)
|
||||||
@ -776,8 +768,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
|
|||||||
32 => construct_32,
|
32 => construct_32,
|
||||||
64 => construct_64,
|
64 => construct_64,
|
||||||
other => self.fatal(&format!(
|
other => self.fatal(&format!(
|
||||||
"switch selector cannot have width {} (only 8, 16, 32, and 64 bits allowed)",
|
"switch selector cannot have width {other} (only 8, 16, 32, and 64 bits allowed)"
|
||||||
other
|
|
||||||
)),
|
)),
|
||||||
};
|
};
|
||||||
(signed, construct_case)
|
(signed, construct_case)
|
||||||
@ -1025,8 +1016,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
|
|||||||
pointee
|
pointee
|
||||||
}
|
}
|
||||||
ty => self.fatal(&format!(
|
ty => self.fatal(&format!(
|
||||||
"load called on variable that wasn't a pointer: {:?}",
|
"load called on variable that wasn't a pointer: {ty:?}"
|
||||||
ty
|
|
||||||
)),
|
)),
|
||||||
};
|
};
|
||||||
self.emit()
|
self.emit()
|
||||||
@ -1055,8 +1045,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
|
|||||||
pointee
|
pointee
|
||||||
}
|
}
|
||||||
ty => self.fatal(&format!(
|
ty => self.fatal(&format!(
|
||||||
"atomic_load called on variable that wasn't a pointer: {:?}",
|
"atomic_load called on variable that wasn't a pointer: {ty:?}"
|
||||||
ty
|
|
||||||
)),
|
)),
|
||||||
};
|
};
|
||||||
// TODO: Default to device scope
|
// TODO: Default to device scope
|
||||||
@ -1135,7 +1124,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
|
|||||||
let start = dest.project_index(self, zero).llval;
|
let start = dest.project_index(self, zero).llval;
|
||||||
|
|
||||||
let elem_layout = dest.layout.field(self.cx(), 0);
|
let elem_layout = dest.layout.field(self.cx(), 0);
|
||||||
let elem_ty = elem_layout.spirv_type(self.span(), &self);
|
let elem_ty = elem_layout.spirv_type(self.span(), self);
|
||||||
let align = dest.align.restrict_for_offset(elem_layout.size);
|
let align = dest.align.restrict_for_offset(elem_layout.size);
|
||||||
|
|
||||||
for i in 0..count {
|
for i in 0..count {
|
||||||
@ -1159,8 +1148,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
|
|||||||
let ptr_elem_ty = match self.lookup_type(ptr.ty) {
|
let ptr_elem_ty = match self.lookup_type(ptr.ty) {
|
||||||
SpirvType::Pointer { pointee } => pointee,
|
SpirvType::Pointer { pointee } => pointee,
|
||||||
ty => self.fatal(&format!(
|
ty => self.fatal(&format!(
|
||||||
"store called on variable that wasn't a pointer: {:?}",
|
"store called on variable that wasn't a pointer: {ty:?}"
|
||||||
ty
|
|
||||||
)),
|
)),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1192,8 +1180,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
|
|||||||
) -> Self::Value {
|
) -> Self::Value {
|
||||||
if flags != MemFlags::empty() {
|
if flags != MemFlags::empty() {
|
||||||
self.err(&format!(
|
self.err(&format!(
|
||||||
"store_with_flags is not supported yet: {:?}",
|
"store_with_flags is not supported yet: {flags:?}"
|
||||||
flags
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
self.store(val, ptr, align)
|
self.store(val, ptr, align)
|
||||||
@ -1209,8 +1196,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
|
|||||||
let ptr_elem_ty = match self.lookup_type(ptr.ty) {
|
let ptr_elem_ty = match self.lookup_type(ptr.ty) {
|
||||||
SpirvType::Pointer { pointee } => pointee,
|
SpirvType::Pointer { pointee } => pointee,
|
||||||
ty => self.fatal(&format!(
|
ty => self.fatal(&format!(
|
||||||
"atomic_store called on variable that wasn't a pointer: {:?}",
|
"atomic_store called on variable that wasn't a pointer: {ty:?}"
|
||||||
ty
|
|
||||||
)),
|
)),
|
||||||
};
|
};
|
||||||
assert_ty_eq!(self, ptr_elem_ty, val.ty);
|
assert_ty_eq!(self, ptr_elem_ty, val.ty);
|
||||||
@ -1248,8 +1234,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
|
|||||||
pointee
|
pointee
|
||||||
}
|
}
|
||||||
other => self.fatal(&format!(
|
other => self.fatal(&format!(
|
||||||
"struct_gep not on pointer type: {:?}, index {}",
|
"struct_gep not on pointer type: {other:?}, index {idx}"
|
||||||
other, idx
|
|
||||||
)),
|
)),
|
||||||
};
|
};
|
||||||
let pointee_kind = self.lookup_type(pointee);
|
let pointee_kind = self.lookup_type(pointee);
|
||||||
@ -1264,8 +1249,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
|
|||||||
inner_type
|
inner_type
|
||||||
}
|
}
|
||||||
other => self.fatal(&format!(
|
other => self.fatal(&format!(
|
||||||
"struct_gep not on struct, array, or vector type: {:?}, index {}",
|
"struct_gep not on struct, array, or vector type: {other:?}, index {idx}"
|
||||||
other, idx
|
|
||||||
)),
|
)),
|
||||||
};
|
};
|
||||||
let result_type = SpirvType::Pointer {
|
let result_type = SpirvType::Pointer {
|
||||||
@ -1410,8 +1394,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
|
|||||||
match self.lookup_type(val.ty) {
|
match self.lookup_type(val.ty) {
|
||||||
SpirvType::Pointer { .. } => (),
|
SpirvType::Pointer { .. } => (),
|
||||||
other => self.fatal(&format!(
|
other => self.fatal(&format!(
|
||||||
"ptrtoint called on non-pointer source type: {:?}",
|
"ptrtoint called on non-pointer source type: {other:?}"
|
||||||
other
|
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
if val.ty == dest_ty {
|
if val.ty == dest_ty {
|
||||||
@ -1431,8 +1414,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
|
|||||||
match self.lookup_type(dest_ty) {
|
match self.lookup_type(dest_ty) {
|
||||||
SpirvType::Pointer { .. } => (),
|
SpirvType::Pointer { .. } => (),
|
||||||
other => self.fatal(&format!(
|
other => self.fatal(&format!(
|
||||||
"inttoptr called on non-pointer dest type: {:?}",
|
"inttoptr called on non-pointer dest type: {other:?}"
|
||||||
other
|
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
if val.ty == dest_ty {
|
if val.ty == dest_ty {
|
||||||
@ -1540,8 +1522,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
|
|||||||
.with_type(dest_ty)
|
.with_type(dest_ty)
|
||||||
}
|
}
|
||||||
(val_ty, dest_ty_spv) => self.fatal(&format!(
|
(val_ty, dest_ty_spv) => self.fatal(&format!(
|
||||||
"TODO: intcast not implemented yet: val={:?} val.ty={:?} dest_ty={:?} is_signed={}",
|
"TODO: intcast not implemented yet: val={val:?} val.ty={val_ty:?} dest_ty={dest_ty_spv:?} is_signed={is_signed}"
|
||||||
val, val_ty, dest_ty_spv, is_signed
|
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1566,16 +1547,14 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
|
|||||||
_ => match self.lookup_type(val.ty) {
|
_ => match self.lookup_type(val.ty) {
|
||||||
SpirvType::Pointer { pointee } => (val, pointee),
|
SpirvType::Pointer { pointee } => (val, pointee),
|
||||||
other => self.fatal(&format!(
|
other => self.fatal(&format!(
|
||||||
"pointercast called on non-pointer source type: {:?}",
|
"pointercast called on non-pointer source type: {other:?}"
|
||||||
other
|
|
||||||
)),
|
)),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
let dest_pointee = match self.lookup_type(dest_ty) {
|
let dest_pointee = match self.lookup_type(dest_ty) {
|
||||||
SpirvType::Pointer { pointee } => pointee,
|
SpirvType::Pointer { pointee } => pointee,
|
||||||
other => self.fatal(&format!(
|
other => self.fatal(&format!(
|
||||||
"pointercast called on non-pointer dest type: {:?}",
|
"pointercast called on non-pointer dest type: {other:?}"
|
||||||
other
|
|
||||||
)),
|
)),
|
||||||
};
|
};
|
||||||
if val.ty == dest_ty {
|
if val.ty == dest_ty {
|
||||||
@ -1869,8 +1848,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
|
|||||||
) {
|
) {
|
||||||
if flags != MemFlags::empty() {
|
if flags != MemFlags::empty() {
|
||||||
self.err(&format!(
|
self.err(&format!(
|
||||||
"memcpy with mem flags is not supported yet: {:?}",
|
"memcpy with mem flags is not supported yet: {flags:?}"
|
||||||
flags
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
let const_size = self.builder.lookup_const_u64(size);
|
let const_size = self.builder.lookup_const_u64(size);
|
||||||
@ -1928,8 +1906,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
|
|||||||
) {
|
) {
|
||||||
if flags != MemFlags::empty() {
|
if flags != MemFlags::empty() {
|
||||||
self.err(&format!(
|
self.err(&format!(
|
||||||
"memset with mem flags is not supported yet: {:?}",
|
"memset with mem flags is not supported yet: {flags:?}"
|
||||||
flags
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
let elem_ty = match self.lookup_type(ptr.ty) {
|
let elem_ty = match self.lookup_type(ptr.ty) {
|
||||||
@ -1979,8 +1956,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
|
|||||||
let result_type = match self.lookup_type(vec.ty) {
|
let result_type = match self.lookup_type(vec.ty) {
|
||||||
SpirvType::Vector { element, .. } => element,
|
SpirvType::Vector { element, .. } => element,
|
||||||
other => self.fatal(&format!(
|
other => self.fatal(&format!(
|
||||||
"extract_element not implemented on type {:?}",
|
"extract_element not implemented on type {other:?}"
|
||||||
other
|
|
||||||
)),
|
)),
|
||||||
};
|
};
|
||||||
match self.builder.lookup_const_u64(idx) {
|
match self.builder.lookup_const_u64(idx) {
|
||||||
@ -2046,7 +2022,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
|
|||||||
SpirvType::Adt { field_types, .. } => {
|
SpirvType::Adt { field_types, .. } => {
|
||||||
assert_ty_eq!(self, field_types[idx as usize], elt.ty);
|
assert_ty_eq!(self, field_types[idx as usize], elt.ty);
|
||||||
}
|
}
|
||||||
other => self.fatal(&format!("insert_value not implemented on type {:?}", other)),
|
other => self.fatal(&format!("insert_value not implemented on type {other:?}")),
|
||||||
};
|
};
|
||||||
self.emit()
|
self.emit()
|
||||||
.composite_insert(
|
.composite_insert(
|
||||||
@ -2111,8 +2087,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
|
|||||||
let dst_pointee_ty = match self.lookup_type(dst.ty) {
|
let dst_pointee_ty = match self.lookup_type(dst.ty) {
|
||||||
SpirvType::Pointer { pointee } => pointee,
|
SpirvType::Pointer { pointee } => pointee,
|
||||||
ty => self.fatal(&format!(
|
ty => self.fatal(&format!(
|
||||||
"atomic_cmpxchg called on variable that wasn't a pointer: {:?}",
|
"atomic_cmpxchg called on variable that wasn't a pointer: {ty:?}"
|
||||||
ty
|
|
||||||
)),
|
)),
|
||||||
};
|
};
|
||||||
assert_ty_eq!(self, dst_pointee_ty, cmp.ty);
|
assert_ty_eq!(self, dst_pointee_ty, cmp.ty);
|
||||||
@ -2148,8 +2123,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
|
|||||||
let dst_pointee_ty = match self.lookup_type(dst.ty) {
|
let dst_pointee_ty = match self.lookup_type(dst.ty) {
|
||||||
SpirvType::Pointer { pointee } => pointee,
|
SpirvType::Pointer { pointee } => pointee,
|
||||||
ty => self.fatal(&format!(
|
ty => self.fatal(&format!(
|
||||||
"atomic_rmw called on variable that wasn't a pointer: {:?}",
|
"atomic_rmw called on variable that wasn't a pointer: {ty:?}"
|
||||||
ty
|
|
||||||
)),
|
)),
|
||||||
};
|
};
|
||||||
assert_ty_eq!(self, dst_pointee_ty, src.ty);
|
assert_ty_eq!(self, dst_pointee_ty, src.ty);
|
||||||
|
@ -123,8 +123,7 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
TyKind::Float(_) => self.fadd(args[0].immediate(), args[1].immediate()),
|
TyKind::Float(_) => self.fadd(args[0].immediate(), args[1].immediate()),
|
||||||
other => self.fatal(&format!(
|
other => self.fatal(&format!(
|
||||||
"Unimplemented saturating_add intrinsic type: {:#?}",
|
"Unimplemented saturating_add intrinsic type: {other:#?}"
|
||||||
other
|
|
||||||
)),
|
)),
|
||||||
};
|
};
|
||||||
// TODO: Implement this
|
// TODO: Implement this
|
||||||
@ -139,8 +138,7 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
TyKind::Float(_) => self.fsub(args[0].immediate(), args[1].immediate()),
|
TyKind::Float(_) => self.fsub(args[0].immediate(), args[1].immediate()),
|
||||||
other => self.fatal(&format!(
|
other => self.fatal(&format!(
|
||||||
"Unimplemented saturating_sub intrinsic type: {:#?}",
|
"Unimplemented saturating_sub intrinsic type: {other:#?}"
|
||||||
other
|
|
||||||
)),
|
)),
|
||||||
};
|
};
|
||||||
// TODO: Implement this
|
// TODO: Implement this
|
||||||
@ -316,11 +314,11 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> {
|
|||||||
let res3 = self.or(res3, res4);
|
let res3 = self.or(res3, res4);
|
||||||
self.or(res1, res3)
|
self.or(res1, res3)
|
||||||
}
|
}
|
||||||
other => self.fatal(&format!("bswap not implemented for int width {}", other)),
|
other => self.fatal(&format!("bswap not implemented for int width {other}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => self.fatal(&format!("TODO: Unknown intrinsic '{}'", name)),
|
_ => self.fatal(&format!("TODO: Unknown intrinsic '{name}'")),
|
||||||
};
|
};
|
||||||
|
|
||||||
if !fn_abi.ret.is_ignore() {
|
if !fn_abi.ret.is_ignore() {
|
||||||
|
@ -137,8 +137,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
pointee
|
pointee
|
||||||
}
|
}
|
||||||
other_type => self.fatal(&format!(
|
other_type => self.fatal(&format!(
|
||||||
"GEP first deref not implemented for type {:?}",
|
"GEP first deref not implemented for type {other_type:?}"
|
||||||
other_type
|
|
||||||
)),
|
)),
|
||||||
};
|
};
|
||||||
for index in indices.iter().cloned().skip(1) {
|
for index in indices.iter().cloned().skip(1) {
|
||||||
|
@ -65,8 +65,7 @@ impl<'a, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'tcx> {
|
|||||||
let unsupported_options = options & !SUPPORTED_OPTIONS;
|
let unsupported_options = options & !SUPPORTED_OPTIONS;
|
||||||
if !unsupported_options.is_empty() {
|
if !unsupported_options.is_empty() {
|
||||||
self.err(&format!(
|
self.err(&format!(
|
||||||
"asm flags not supported: {:?}",
|
"asm flags not supported: {unsupported_options:?}"
|
||||||
unsupported_options
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
// vec of lines, and each line is vec of tokens
|
// vec of lines, and each line is vec of tokens
|
||||||
@ -105,7 +104,7 @@ impl<'a, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'tcx> {
|
|||||||
if let Some(modifier) = modifier {
|
if let Some(modifier) = modifier {
|
||||||
self.tcx.sess.span_err(
|
self.tcx.sess.span_err(
|
||||||
span,
|
span,
|
||||||
format!("asm modifiers are not supported: {}", modifier),
|
format!("asm modifiers are not supported: {modifier}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let line = tokens.last_mut().unwrap();
|
let line = tokens.last_mut().unwrap();
|
||||||
@ -167,14 +166,13 @@ impl<'a, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'tcx> {
|
|||||||
(false, AsmBlock::Open) => (),
|
(false, AsmBlock::Open) => (),
|
||||||
(false, AsmBlock::End(terminator)) => {
|
(false, AsmBlock::End(terminator)) => {
|
||||||
self.err(&format!(
|
self.err(&format!(
|
||||||
"trailing terminator {:?} requires `options(noreturn)`",
|
"trailing terminator {terminator:?} requires `options(noreturn)`"
|
||||||
terminator
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (id, num) in id_map {
|
for (id, num) in id_map {
|
||||||
if !defined_ids.contains(&num) {
|
if !defined_ids.contains(&num) {
|
||||||
self.err(&format!("%{} is used but not defined", id));
|
self.err(&format!("%{id} is used but not defined"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -237,7 +235,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
|
|||||||
Some('\'') => '\'',
|
Some('\'') => '\'',
|
||||||
Some('"') => '"',
|
Some('"') => '"',
|
||||||
Some(escape) => {
|
Some(escape) => {
|
||||||
self.err(&format!("invalid escape '\\{}'", escape));
|
self.err(&format!("invalid escape '\\{escape}'"));
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -312,12 +310,10 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
|
|||||||
if storage_class != StorageClass::Generic {
|
if storage_class != StorageClass::Generic {
|
||||||
self.struct_err("TypePointer in asm! requires `Generic` storage class")
|
self.struct_err("TypePointer in asm! requires `Generic` storage class")
|
||||||
.note(&format!(
|
.note(&format!(
|
||||||
"`{:?}` storage class was specified",
|
"`{storage_class:?}` storage class was specified"
|
||||||
storage_class
|
|
||||||
))
|
))
|
||||||
.help(&format!(
|
.help(&format!(
|
||||||
"the storage class will be inferred automatically (e.g. to `{:?}`)",
|
"the storage class will be inferred automatically (e.g. to `{storage_class:?}`)"
|
||||||
storage_class
|
|
||||||
))
|
))
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
@ -378,8 +374,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
|
|||||||
AsmBlock::End(terminator) => {
|
AsmBlock::End(terminator) => {
|
||||||
if op != Op::Label {
|
if op != Op::Label {
|
||||||
self.err(&format!(
|
self.err(&format!(
|
||||||
"expected OpLabel after terminator {:?}",
|
"expected OpLabel after terminator {terminator:?}"
|
||||||
terminator
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -461,7 +456,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
|
|||||||
let inst_class = if let Some(inst) = inst_class {
|
let inst_class = if let Some(inst) = inst_class {
|
||||||
inst
|
inst
|
||||||
} else {
|
} else {
|
||||||
self.err(&format!("unknown spirv instruction {}", inst_name));
|
self.err(&format!("unknown spirv instruction {inst_name}"));
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let result_id = match out_register {
|
let result_id = match out_register {
|
||||||
@ -792,7 +787,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
|
|||||||
_ => {
|
_ => {
|
||||||
self.tcx
|
self.tcx
|
||||||
.sess
|
.sess
|
||||||
.span_err(span, format!("invalid register: {}", reg));
|
.span_err(span, format!("invalid register: {reg}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -809,7 +804,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
|
|||||||
Some(OutRegister::Regular({
|
Some(OutRegister::Regular({
|
||||||
let num = *id_map.entry(id).or_insert_with(|| self.emit().id());
|
let num = *id_map.entry(id).or_insert_with(|| self.emit().id());
|
||||||
if !defined_ids.insert(num) {
|
if !defined_ids.insert(num) {
|
||||||
self.err(&format!("%{} is defined more than once", id));
|
self.err(&format!("%{id} is defined more than once"));
|
||||||
}
|
}
|
||||||
num
|
num
|
||||||
}))
|
}))
|
||||||
@ -1071,7 +1066,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
|
|||||||
|
|
||||||
(OperandKind::LiteralInteger, Some(word)) => match word.parse() {
|
(OperandKind::LiteralInteger, Some(word)) => match word.parse() {
|
||||||
Ok(v) => inst.operands.push(dr::Operand::LiteralInt32(v)),
|
Ok(v) => inst.operands.push(dr::Operand::LiteralInt32(v)),
|
||||||
Err(e) => self.err(&format!("invalid integer: {}", e)),
|
Err(e) => self.err(&format!("invalid integer: {e}")),
|
||||||
},
|
},
|
||||||
(OperandKind::LiteralString, _) => {
|
(OperandKind::LiteralString, _) => {
|
||||||
if let Token::String(value) = token {
|
if let Token::String(value) = token {
|
||||||
@ -1126,7 +1121,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
|
|||||||
}
|
}
|
||||||
(OperandKind::LiteralExtInstInteger, Some(word)) => match word.parse() {
|
(OperandKind::LiteralExtInstInteger, Some(word)) => match word.parse() {
|
||||||
Ok(v) => inst.operands.push(dr::Operand::LiteralExtInstInteger(v)),
|
Ok(v) => inst.operands.push(dr::Operand::LiteralExtInstInteger(v)),
|
||||||
Err(e) => self.err(&format!("invalid integer: {}", e)),
|
Err(e) => self.err(&format!("invalid integer: {e}")),
|
||||||
},
|
},
|
||||||
(OperandKind::LiteralSpecConstantOpInteger, Some(word)) => {
|
(OperandKind::LiteralSpecConstantOpInteger, Some(word)) => {
|
||||||
match self.instruction_table.table.get(word) {
|
match self.instruction_table.table.get(word) {
|
||||||
@ -1147,25 +1142,24 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
|
|||||||
Some(Token::Word(word)) => match word.parse() {
|
Some(Token::Word(word)) => match word.parse() {
|
||||||
Ok(v) => inst.operands.push(dr::Operand::LiteralInt32(v)),
|
Ok(v) => inst.operands.push(dr::Operand::LiteralInt32(v)),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
self.err(&format!("invalid integer: {}", e));
|
self.err(&format!("invalid integer: {e}"));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Some(Token::String(_)) => {
|
Some(Token::String(_)) => {
|
||||||
self.err(&format!(
|
self.err(&format!(
|
||||||
"expected a literal, not a string for a {:?}",
|
"expected a literal, not a string for a {kind:?}"
|
||||||
kind
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
Some(Token::Placeholder(_, span)) => {
|
Some(Token::Placeholder(_, span)) => {
|
||||||
self.tcx.sess.span_err(
|
self.tcx.sess.span_err(
|
||||||
span,
|
span,
|
||||||
format!("expected a literal, not a dynamic value for a {:?}", kind),
|
format!("expected a literal, not a dynamic value for a {kind:?}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Some(Token::Typeof(_, span, _)) => {
|
Some(Token::Typeof(_, span, _)) => {
|
||||||
self.tcx.sess.span_err(
|
self.tcx.sess.span_err(
|
||||||
span,
|
span,
|
||||||
format!("expected a literal, not a type for a {:?}", kind),
|
format!("expected a literal, not a type for a {kind:?}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
@ -1191,163 +1185,162 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
|
|||||||
(OperandKind::ImageOperands, Some(word)) => {
|
(OperandKind::ImageOperands, Some(word)) => {
|
||||||
match parse_bitflags_operand(IMAGE_OPERANDS, word) {
|
match parse_bitflags_operand(IMAGE_OPERANDS, word) {
|
||||||
Some(x) => inst.operands.push(dr::Operand::ImageOperands(x)),
|
Some(x) => inst.operands.push(dr::Operand::ImageOperands(x)),
|
||||||
None => self.err(&format!("Unknown ImageOperands {}", word)),
|
None => self.err(&format!("Unknown ImageOperands {word}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(OperandKind::FPFastMathMode, Some(word)) => {
|
(OperandKind::FPFastMathMode, Some(word)) => {
|
||||||
match parse_bitflags_operand(FP_FAST_MATH_MODE, word) {
|
match parse_bitflags_operand(FP_FAST_MATH_MODE, word) {
|
||||||
Some(x) => inst.operands.push(dr::Operand::FPFastMathMode(x)),
|
Some(x) => inst.operands.push(dr::Operand::FPFastMathMode(x)),
|
||||||
None => self.err(&format!("Unknown FPFastMathMode {}", word)),
|
None => self.err(&format!("Unknown FPFastMathMode {word}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(OperandKind::SelectionControl, Some(word)) => {
|
(OperandKind::SelectionControl, Some(word)) => {
|
||||||
match parse_bitflags_operand(SELECTION_CONTROL, word) {
|
match parse_bitflags_operand(SELECTION_CONTROL, word) {
|
||||||
Some(x) => inst.operands.push(dr::Operand::SelectionControl(x)),
|
Some(x) => inst.operands.push(dr::Operand::SelectionControl(x)),
|
||||||
None => self.err(&format!("Unknown SelectionControl {}", word)),
|
None => self.err(&format!("Unknown SelectionControl {word}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(OperandKind::LoopControl, Some(word)) => {
|
(OperandKind::LoopControl, Some(word)) => {
|
||||||
match parse_bitflags_operand(LOOP_CONTROL, word) {
|
match parse_bitflags_operand(LOOP_CONTROL, word) {
|
||||||
Some(x) => inst.operands.push(dr::Operand::LoopControl(x)),
|
Some(x) => inst.operands.push(dr::Operand::LoopControl(x)),
|
||||||
None => self.err(&format!("Unknown LoopControl {}", word)),
|
None => self.err(&format!("Unknown LoopControl {word}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(OperandKind::FunctionControl, Some(word)) => {
|
(OperandKind::FunctionControl, Some(word)) => {
|
||||||
match parse_bitflags_operand(FUNCTION_CONTROL, word) {
|
match parse_bitflags_operand(FUNCTION_CONTROL, word) {
|
||||||
Some(x) => inst.operands.push(dr::Operand::FunctionControl(x)),
|
Some(x) => inst.operands.push(dr::Operand::FunctionControl(x)),
|
||||||
None => self.err(&format!("Unknown FunctionControl {}", word)),
|
None => self.err(&format!("Unknown FunctionControl {word}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(OperandKind::MemorySemantics, Some(word)) => {
|
(OperandKind::MemorySemantics, Some(word)) => {
|
||||||
match parse_bitflags_operand(MEMORY_SEMANTICS, word) {
|
match parse_bitflags_operand(MEMORY_SEMANTICS, word) {
|
||||||
Some(x) => inst.operands.push(dr::Operand::MemorySemantics(x)),
|
Some(x) => inst.operands.push(dr::Operand::MemorySemantics(x)),
|
||||||
None => self.err(&format!("Unknown MemorySemantics {}", word)),
|
None => self.err(&format!("Unknown MemorySemantics {word}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(OperandKind::MemoryAccess, Some(word)) => {
|
(OperandKind::MemoryAccess, Some(word)) => {
|
||||||
match parse_bitflags_operand(MEMORY_ACCESS, word) {
|
match parse_bitflags_operand(MEMORY_ACCESS, word) {
|
||||||
Some(x) => inst.operands.push(dr::Operand::MemoryAccess(x)),
|
Some(x) => inst.operands.push(dr::Operand::MemoryAccess(x)),
|
||||||
None => self.err(&format!("Unknown MemoryAccess {}", word)),
|
None => self.err(&format!("Unknown MemoryAccess {word}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(OperandKind::KernelProfilingInfo, Some(word)) => {
|
(OperandKind::KernelProfilingInfo, Some(word)) => {
|
||||||
match parse_bitflags_operand(KERNEL_PROFILING_INFO, word) {
|
match parse_bitflags_operand(KERNEL_PROFILING_INFO, word) {
|
||||||
Some(x) => inst.operands.push(dr::Operand::KernelProfilingInfo(x)),
|
Some(x) => inst.operands.push(dr::Operand::KernelProfilingInfo(x)),
|
||||||
None => self.err(&format!("Unknown KernelProfilingInfo {}", word)),
|
None => self.err(&format!("Unknown KernelProfilingInfo {word}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(OperandKind::RayFlags, Some(word)) => match parse_bitflags_operand(RAY_FLAGS, word) {
|
(OperandKind::RayFlags, Some(word)) => match parse_bitflags_operand(RAY_FLAGS, word) {
|
||||||
Some(x) => inst.operands.push(dr::Operand::RayFlags(x)),
|
Some(x) => inst.operands.push(dr::Operand::RayFlags(x)),
|
||||||
None => self.err(&format!("Unknown RayFlags {}", word)),
|
None => self.err(&format!("Unknown RayFlags {word}")),
|
||||||
},
|
},
|
||||||
(OperandKind::FragmentShadingRate, Some(word)) => {
|
(OperandKind::FragmentShadingRate, Some(word)) => {
|
||||||
match parse_bitflags_operand(FRAGMENT_SHADING_RATE, word) {
|
match parse_bitflags_operand(FRAGMENT_SHADING_RATE, word) {
|
||||||
Some(x) => inst.operands.push(dr::Operand::FragmentShadingRate(x)),
|
Some(x) => inst.operands.push(dr::Operand::FragmentShadingRate(x)),
|
||||||
None => self.err(&format!("Unknown FragmentShadingRate {}", word)),
|
None => self.err(&format!("Unknown FragmentShadingRate {word}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(OperandKind::SourceLanguage, Some(word)) => match word.parse() {
|
(OperandKind::SourceLanguage, Some(word)) => match word.parse() {
|
||||||
Ok(x) => inst.operands.push(dr::Operand::SourceLanguage(x)),
|
Ok(x) => inst.operands.push(dr::Operand::SourceLanguage(x)),
|
||||||
Err(()) => self.err(&format!("Unknown SourceLanguage {}", word)),
|
Err(()) => self.err(&format!("Unknown SourceLanguage {word}")),
|
||||||
},
|
},
|
||||||
(OperandKind::ExecutionModel, Some(word)) => match word.parse() {
|
(OperandKind::ExecutionModel, Some(word)) => match word.parse() {
|
||||||
Ok(x) => inst.operands.push(dr::Operand::ExecutionModel(x)),
|
Ok(x) => inst.operands.push(dr::Operand::ExecutionModel(x)),
|
||||||
Err(()) => self.err(&format!("unknown ExecutionModel {}", word)),
|
Err(()) => self.err(&format!("unknown ExecutionModel {word}")),
|
||||||
},
|
},
|
||||||
(OperandKind::AddressingModel, Some(word)) => match word.parse() {
|
(OperandKind::AddressingModel, Some(word)) => match word.parse() {
|
||||||
Ok(x) => inst.operands.push(dr::Operand::AddressingModel(x)),
|
Ok(x) => inst.operands.push(dr::Operand::AddressingModel(x)),
|
||||||
Err(()) => self.err(&format!("unknown AddressingModel {}", word)),
|
Err(()) => self.err(&format!("unknown AddressingModel {word}")),
|
||||||
},
|
},
|
||||||
(OperandKind::MemoryModel, Some(word)) => match word.parse() {
|
(OperandKind::MemoryModel, Some(word)) => match word.parse() {
|
||||||
Ok(x) => inst.operands.push(dr::Operand::MemoryModel(x)),
|
Ok(x) => inst.operands.push(dr::Operand::MemoryModel(x)),
|
||||||
Err(()) => self.err(&format!("unknown MemoryModel {}", word)),
|
Err(()) => self.err(&format!("unknown MemoryModel {word}")),
|
||||||
},
|
},
|
||||||
(OperandKind::ExecutionMode, Some(word)) => match word.parse() {
|
(OperandKind::ExecutionMode, Some(word)) => match word.parse() {
|
||||||
Ok(x) => inst.operands.push(dr::Operand::ExecutionMode(x)),
|
Ok(x) => inst.operands.push(dr::Operand::ExecutionMode(x)),
|
||||||
Err(()) => self.err(&format!("unknown ExecutionMode {}", word)),
|
Err(()) => self.err(&format!("unknown ExecutionMode {word}")),
|
||||||
},
|
},
|
||||||
(OperandKind::StorageClass, Some(word)) => match word.parse() {
|
(OperandKind::StorageClass, Some(word)) => match word.parse() {
|
||||||
Ok(x) => inst.operands.push(dr::Operand::StorageClass(x)),
|
Ok(x) => inst.operands.push(dr::Operand::StorageClass(x)),
|
||||||
Err(()) => self.err(&format!("unknown StorageClass {}", word)),
|
Err(()) => self.err(&format!("unknown StorageClass {word}")),
|
||||||
},
|
},
|
||||||
(OperandKind::Dim, Some(word)) => match word.parse() {
|
(OperandKind::Dim, Some(word)) => match word.parse() {
|
||||||
Ok(x) => inst.operands.push(dr::Operand::Dim(x)),
|
Ok(x) => inst.operands.push(dr::Operand::Dim(x)),
|
||||||
Err(()) => self.err(&format!("unknown Dim {}", word)),
|
Err(()) => self.err(&format!("unknown Dim {word}")),
|
||||||
},
|
},
|
||||||
(OperandKind::SamplerAddressingMode, Some(word)) => match word.parse() {
|
(OperandKind::SamplerAddressingMode, Some(word)) => match word.parse() {
|
||||||
Ok(x) => inst.operands.push(dr::Operand::SamplerAddressingMode(x)),
|
Ok(x) => inst.operands.push(dr::Operand::SamplerAddressingMode(x)),
|
||||||
Err(()) => self.err(&format!("unknown SamplerAddressingMode {}", word)),
|
Err(()) => self.err(&format!("unknown SamplerAddressingMode {word}")),
|
||||||
},
|
},
|
||||||
(OperandKind::SamplerFilterMode, Some(word)) => match word.parse() {
|
(OperandKind::SamplerFilterMode, Some(word)) => match word.parse() {
|
||||||
Ok(x) => inst.operands.push(dr::Operand::SamplerFilterMode(x)),
|
Ok(x) => inst.operands.push(dr::Operand::SamplerFilterMode(x)),
|
||||||
Err(()) => self.err(&format!("unknown SamplerFilterMode {}", word)),
|
Err(()) => self.err(&format!("unknown SamplerFilterMode {word}")),
|
||||||
},
|
},
|
||||||
(OperandKind::ImageFormat, Some(word)) => match word.parse() {
|
(OperandKind::ImageFormat, Some(word)) => match word.parse() {
|
||||||
Ok(x) => inst.operands.push(dr::Operand::ImageFormat(x)),
|
Ok(x) => inst.operands.push(dr::Operand::ImageFormat(x)),
|
||||||
Err(()) => self.err(&format!("unknown ImageFormat {}", word)),
|
Err(()) => self.err(&format!("unknown ImageFormat {word}")),
|
||||||
},
|
},
|
||||||
(OperandKind::ImageChannelOrder, Some(word)) => match word.parse() {
|
(OperandKind::ImageChannelOrder, Some(word)) => match word.parse() {
|
||||||
Ok(x) => inst.operands.push(dr::Operand::ImageChannelOrder(x)),
|
Ok(x) => inst.operands.push(dr::Operand::ImageChannelOrder(x)),
|
||||||
Err(()) => self.err(&format!("unknown ImageChannelOrder {}", word)),
|
Err(()) => self.err(&format!("unknown ImageChannelOrder {word}")),
|
||||||
},
|
},
|
||||||
(OperandKind::ImageChannelDataType, Some(word)) => match word.parse() {
|
(OperandKind::ImageChannelDataType, Some(word)) => match word.parse() {
|
||||||
Ok(x) => inst.operands.push(dr::Operand::ImageChannelDataType(x)),
|
Ok(x) => inst.operands.push(dr::Operand::ImageChannelDataType(x)),
|
||||||
Err(()) => self.err(&format!("unknown ImageChannelDataType {}", word)),
|
Err(()) => self.err(&format!("unknown ImageChannelDataType {word}")),
|
||||||
},
|
},
|
||||||
(OperandKind::FPRoundingMode, Some(word)) => match word.parse() {
|
(OperandKind::FPRoundingMode, Some(word)) => match word.parse() {
|
||||||
Ok(x) => inst.operands.push(dr::Operand::FPRoundingMode(x)),
|
Ok(x) => inst.operands.push(dr::Operand::FPRoundingMode(x)),
|
||||||
Err(()) => self.err(&format!("unknown FPRoundingMode {}", word)),
|
Err(()) => self.err(&format!("unknown FPRoundingMode {word}")),
|
||||||
},
|
},
|
||||||
(OperandKind::LinkageType, Some(word)) => match word.parse() {
|
(OperandKind::LinkageType, Some(word)) => match word.parse() {
|
||||||
Ok(x) => inst.operands.push(dr::Operand::LinkageType(x)),
|
Ok(x) => inst.operands.push(dr::Operand::LinkageType(x)),
|
||||||
Err(()) => self.err(&format!("unknown LinkageType {}", word)),
|
Err(()) => self.err(&format!("unknown LinkageType {word}")),
|
||||||
},
|
},
|
||||||
(OperandKind::AccessQualifier, Some(word)) => match word.parse() {
|
(OperandKind::AccessQualifier, Some(word)) => match word.parse() {
|
||||||
Ok(x) => inst.operands.push(dr::Operand::AccessQualifier(x)),
|
Ok(x) => inst.operands.push(dr::Operand::AccessQualifier(x)),
|
||||||
Err(()) => self.err(&format!("unknown AccessQualifier {}", word)),
|
Err(()) => self.err(&format!("unknown AccessQualifier {word}")),
|
||||||
},
|
},
|
||||||
(OperandKind::FunctionParameterAttribute, Some(word)) => match word.parse() {
|
(OperandKind::FunctionParameterAttribute, Some(word)) => match word.parse() {
|
||||||
Ok(x) => inst
|
Ok(x) => inst
|
||||||
.operands
|
.operands
|
||||||
.push(dr::Operand::FunctionParameterAttribute(x)),
|
.push(dr::Operand::FunctionParameterAttribute(x)),
|
||||||
Err(()) => self.err(&format!("unknown FunctionParameterAttribute {}", word)),
|
Err(()) => self.err(&format!("unknown FunctionParameterAttribute {word}")),
|
||||||
},
|
},
|
||||||
(OperandKind::Decoration, Some(word)) => match word.parse() {
|
(OperandKind::Decoration, Some(word)) => match word.parse() {
|
||||||
Ok(x) => inst.operands.push(dr::Operand::Decoration(x)),
|
Ok(x) => inst.operands.push(dr::Operand::Decoration(x)),
|
||||||
Err(()) => self.err(&format!("unknown Decoration {}", word)),
|
Err(()) => self.err(&format!("unknown Decoration {word}")),
|
||||||
},
|
},
|
||||||
(OperandKind::BuiltIn, Some(word)) => match word.parse() {
|
(OperandKind::BuiltIn, Some(word)) => match word.parse() {
|
||||||
Ok(x) => inst.operands.push(dr::Operand::BuiltIn(x)),
|
Ok(x) => inst.operands.push(dr::Operand::BuiltIn(x)),
|
||||||
Err(()) => self.err(&format!("unknown BuiltIn {}", word)),
|
Err(()) => self.err(&format!("unknown BuiltIn {word}")),
|
||||||
},
|
},
|
||||||
(OperandKind::Scope, Some(word)) => match word.parse() {
|
(OperandKind::Scope, Some(word)) => match word.parse() {
|
||||||
Ok(x) => inst.operands.push(dr::Operand::Scope(x)),
|
Ok(x) => inst.operands.push(dr::Operand::Scope(x)),
|
||||||
Err(()) => self.err(&format!("unknown Scope {}", word)),
|
Err(()) => self.err(&format!("unknown Scope {word}")),
|
||||||
},
|
},
|
||||||
(OperandKind::GroupOperation, Some(word)) => match word.parse() {
|
(OperandKind::GroupOperation, Some(word)) => match word.parse() {
|
||||||
Ok(x) => inst.operands.push(dr::Operand::GroupOperation(x)),
|
Ok(x) => inst.operands.push(dr::Operand::GroupOperation(x)),
|
||||||
Err(()) => self.err(&format!("unknown GroupOperation {}", word)),
|
Err(()) => self.err(&format!("unknown GroupOperation {word}")),
|
||||||
},
|
},
|
||||||
(OperandKind::KernelEnqueueFlags, Some(word)) => match word.parse() {
|
(OperandKind::KernelEnqueueFlags, Some(word)) => match word.parse() {
|
||||||
Ok(x) => inst.operands.push(dr::Operand::KernelEnqueueFlags(x)),
|
Ok(x) => inst.operands.push(dr::Operand::KernelEnqueueFlags(x)),
|
||||||
Err(()) => self.err(&format!("unknown KernelEnqueueFlags {}", word)),
|
Err(()) => self.err(&format!("unknown KernelEnqueueFlags {word}")),
|
||||||
},
|
},
|
||||||
(OperandKind::Capability, Some(word)) => match word.parse() {
|
(OperandKind::Capability, Some(word)) => match word.parse() {
|
||||||
Ok(x) => inst.operands.push(dr::Operand::Capability(x)),
|
Ok(x) => inst.operands.push(dr::Operand::Capability(x)),
|
||||||
Err(()) => self.err(&format!("unknown Capability {}", word)),
|
Err(()) => self.err(&format!("unknown Capability {word}")),
|
||||||
},
|
},
|
||||||
(OperandKind::RayQueryIntersection, Some(word)) => match word.parse() {
|
(OperandKind::RayQueryIntersection, Some(word)) => match word.parse() {
|
||||||
Ok(x) => inst.operands.push(dr::Operand::RayQueryIntersection(x)),
|
Ok(x) => inst.operands.push(dr::Operand::RayQueryIntersection(x)),
|
||||||
Err(()) => self.err(&format!("unknown RayQueryIntersection {}", word)),
|
Err(()) => self.err(&format!("unknown RayQueryIntersection {word}")),
|
||||||
},
|
},
|
||||||
(OperandKind::RayQueryCommittedIntersectionType, Some(word)) => match word.parse() {
|
(OperandKind::RayQueryCommittedIntersectionType, Some(word)) => match word.parse() {
|
||||||
Ok(x) => inst
|
Ok(x) => inst
|
||||||
.operands
|
.operands
|
||||||
.push(dr::Operand::RayQueryCommittedIntersectionType(x)),
|
.push(dr::Operand::RayQueryCommittedIntersectionType(x)),
|
||||||
Err(()) => self.err(&format!(
|
Err(()) => self.err(&format!(
|
||||||
"unknown RayQueryCommittedIntersectionType {}",
|
"unknown RayQueryCommittedIntersectionType {word}"
|
||||||
word
|
|
||||||
)),
|
)),
|
||||||
},
|
},
|
||||||
(OperandKind::RayQueryCandidateIntersectionType, Some(word)) => match word.parse() {
|
(OperandKind::RayQueryCandidateIntersectionType, Some(word)) => match word.parse() {
|
||||||
@ -1355,28 +1348,26 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
|
|||||||
.operands
|
.operands
|
||||||
.push(dr::Operand::RayQueryCandidateIntersectionType(x)),
|
.push(dr::Operand::RayQueryCandidateIntersectionType(x)),
|
||||||
Err(()) => self.err(&format!(
|
Err(()) => self.err(&format!(
|
||||||
"unknown RayQueryCandidateIntersectionType {}",
|
"unknown RayQueryCandidateIntersectionType {word}"
|
||||||
word
|
|
||||||
)),
|
)),
|
||||||
},
|
},
|
||||||
(kind, None) => match token {
|
(kind, None) => match token {
|
||||||
Token::Word(_) => bug!(),
|
Token::Word(_) => bug!(),
|
||||||
Token::String(_) => {
|
Token::String(_) => {
|
||||||
self.err(&format!(
|
self.err(&format!(
|
||||||
"expected a literal, not a string for a {:?}",
|
"expected a literal, not a string for a {kind:?}"
|
||||||
kind
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
Token::Placeholder(_, span) => {
|
Token::Placeholder(_, span) => {
|
||||||
self.tcx.sess.span_err(
|
self.tcx.sess.span_err(
|
||||||
span,
|
span,
|
||||||
format!("expected a literal, not a dynamic value for a {:?}", kind),
|
format!("expected a literal, not a dynamic value for a {kind:?}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Token::Typeof(_, span, _) => {
|
Token::Typeof(_, span, _) => {
|
||||||
self.tcx.sess.span_err(
|
self.tcx.sess.span_err(
|
||||||
span,
|
span,
|
||||||
format!("expected a literal, not a type for a {:?}", kind),
|
format!("expected a literal, not a type for a {kind:?}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -665,8 +665,7 @@ impl<'tcx> BuilderSpirv<'tcx> {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
inst.operands.len(),
|
inst.operands.len(),
|
||||||
1,
|
1,
|
||||||
"global already has initializer defined: {}",
|
"global already has initializer defined: {global}"
|
||||||
global
|
|
||||||
);
|
);
|
||||||
inst.operands.push(Operand::IdRef(initializer));
|
inst.operands.push(Operand::IdRef(initializer));
|
||||||
module.types_global_values.push(inst);
|
module.types_global_values.push(inst);
|
||||||
|
@ -66,7 +66,7 @@ impl<'tcx> CodegenCx<'tcx> {
|
|||||||
_ => self
|
_ => self
|
||||||
.tcx
|
.tcx
|
||||||
.sess
|
.sess
|
||||||
.fatal(format!("Invalid constant value for bool: {}", val)),
|
.fatal(format!("Invalid constant value for bool: {val}")),
|
||||||
},
|
},
|
||||||
SpirvType::Integer(128, _) => {
|
SpirvType::Integer(128, _) => {
|
||||||
let result = self.undef(ty);
|
let result = self.undef(ty);
|
||||||
@ -233,7 +233,7 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> {
|
|||||||
_ => self
|
_ => self
|
||||||
.tcx
|
.tcx
|
||||||
.sess
|
.sess
|
||||||
.fatal(format!("Invalid constant value for bool: {}", data)),
|
.fatal(format!("Invalid constant value for bool: {data}")),
|
||||||
},
|
},
|
||||||
other => self.tcx.sess.fatal(format!(
|
other => self.tcx.sess.fatal(format!(
|
||||||
"scalar_to_backend Primitive::Int not supported on type {}",
|
"scalar_to_backend Primitive::Int not supported on type {}",
|
||||||
@ -426,7 +426,7 @@ impl<'tcx> CodegenCx<'tcx> {
|
|||||||
other => {
|
other => {
|
||||||
self.tcx
|
self.tcx
|
||||||
.sess
|
.sess
|
||||||
.fatal(format!("invalid size for integer: {}", other));
|
.fatal(format!("invalid size for integer: {other}"));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Primitive::Int(integer, int_signedness)
|
Primitive::Int(integer, int_signedness)
|
||||||
@ -437,7 +437,7 @@ impl<'tcx> CodegenCx<'tcx> {
|
|||||||
other => {
|
other => {
|
||||||
self.tcx
|
self.tcx
|
||||||
.sess
|
.sess
|
||||||
.fatal(format!("invalid size for float: {}", other));
|
.fatal(format!("invalid size for float: {other}"));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
SpirvType::Pointer { .. } => Primitive::Pointer,
|
SpirvType::Pointer { .. } => Primitive::Pointer,
|
||||||
|
@ -142,8 +142,7 @@ impl<'tcx> CodegenCx<'tcx> {
|
|||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
self.tcx.sess.err(format!(
|
self.tcx.sess.err(format!(
|
||||||
"missing libm intrinsic {}, which is {}",
|
"missing libm intrinsic {symbol_name}, which is {instance}"
|
||||||
symbol_name, instance
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -215,8 +214,7 @@ impl<'tcx> PreDefineMethods<'tcx> for CodegenCx<'tcx> {
|
|||||||
Linkage::Internal => None,
|
Linkage::Internal => None,
|
||||||
other => {
|
other => {
|
||||||
self.tcx.sess.err(format!(
|
self.tcx.sess.err(format!(
|
||||||
"TODO: Linkage type {:?} not supported yet for static var symbol {}",
|
"TODO: Linkage type {other:?} not supported yet for static var symbol {symbol_name}"
|
||||||
other, symbol_name
|
|
||||||
));
|
));
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
@ -245,8 +243,7 @@ impl<'tcx> PreDefineMethods<'tcx> for CodegenCx<'tcx> {
|
|||||||
Linkage::Internal => None,
|
Linkage::Internal => None,
|
||||||
other => {
|
other => {
|
||||||
self.tcx.sess.err(format!(
|
self.tcx.sess.err(format!(
|
||||||
"TODO: Linkage type {:?} not supported yet for function symbol {}",
|
"TODO: Linkage type {other:?} not supported yet for function symbol {symbol_name}"
|
||||||
other, symbol_name
|
|
||||||
));
|
));
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ impl<'tcx> CodegenCx<'tcx> {
|
|||||||
} else {
|
} else {
|
||||||
self.tcx
|
self.tcx
|
||||||
.sess
|
.sess
|
||||||
.span_err(span, format!("Cannot declare {} as an entry point", name));
|
.span_err(span, format!("Cannot declare {name} as an entry point"));
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let body = self
|
let body = self
|
||||||
@ -253,17 +253,16 @@ impl<'tcx> CodegenCx<'tcx> {
|
|||||||
.struct_span_err(hir_param.span, "storage class mismatch")
|
.struct_span_err(hir_param.span, "storage class mismatch")
|
||||||
.span_label(
|
.span_label(
|
||||||
storage_class_attr.span,
|
storage_class_attr.span,
|
||||||
format!("{:?} specified in attribute", storage_class),
|
format!("{storage_class:?} specified in attribute"),
|
||||||
)
|
)
|
||||||
.span_label(
|
.span_label(
|
||||||
hir_param.ty_span,
|
hir_param.ty_span,
|
||||||
format!("{:?} inferred from type", inferred),
|
format!("{inferred:?} inferred from type"),
|
||||||
)
|
)
|
||||||
.span_help(
|
.span_help(
|
||||||
storage_class_attr.span,
|
storage_class_attr.span,
|
||||||
&format!(
|
&format!(
|
||||||
"remove storage class attribute to use {:?} as storage class",
|
"remove storage class attribute to use {inferred:?} as storage class"
|
||||||
inferred
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
@ -405,8 +404,7 @@ impl<'tcx> CodegenCx<'tcx> {
|
|||||||
self.tcx.sess.span_fatal(
|
self.tcx.sess.span_fatal(
|
||||||
hir_param.ty_span,
|
hir_param.ty_span,
|
||||||
format!(
|
format!(
|
||||||
"unsized types are not supported for storage class {:?}",
|
"unsized types are not supported for storage class {storage_class:?}"
|
||||||
storage_class
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -281,7 +281,7 @@ impl CodegenArgs {
|
|||||||
pub fn from_session(sess: &Session) -> Self {
|
pub fn from_session(sess: &Session) -> Self {
|
||||||
match CodegenArgs::parse(&sess.opts.cg.llvm_args) {
|
match CodegenArgs::parse(&sess.opts.cg.llvm_args) {
|
||||||
Ok(ok) => ok,
|
Ok(ok) => ok,
|
||||||
Err(err) => sess.fatal(format!("Unable to parse llvm-args: {}", err)),
|
Err(err) => sess.fatal(format!("Unable to parse llvm-args: {err}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ impl<'tcx> BaseTypeMethods<'tcx> for CodegenCx<'tcx> {
|
|||||||
other => self
|
other => self
|
||||||
.tcx
|
.tcx
|
||||||
.sess
|
.sess
|
||||||
.fatal(format!("Invalid float width in type_kind: {}", other)),
|
.fatal(format!("Invalid float width in type_kind: {other}")),
|
||||||
},
|
},
|
||||||
SpirvType::Adt { .. } | SpirvType::InterfaceBlock { .. } => {
|
SpirvType::Adt { .. } | SpirvType::InterfaceBlock { .. } => {
|
||||||
TypeKind::Struct
|
TypeKind::Struct
|
||||||
@ -247,8 +247,7 @@ impl<'tcx> BaseTypeMethods<'tcx> for CodegenCx<'tcx> {
|
|||||||
SpirvType::Pointer { pointee } => pointee,
|
SpirvType::Pointer { pointee } => pointee,
|
||||||
SpirvType::Vector { element, .. } => element,
|
SpirvType::Vector { element, .. } => element,
|
||||||
spirv_type => self.tcx.sess.fatal(format!(
|
spirv_type => self.tcx.sess.fatal(format!(
|
||||||
"element_type called on invalid type: {:?}",
|
"element_type called on invalid type: {spirv_type:?}"
|
||||||
spirv_type
|
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -260,7 +259,7 @@ impl<'tcx> BaseTypeMethods<'tcx> for CodegenCx<'tcx> {
|
|||||||
ty => self
|
ty => self
|
||||||
.tcx
|
.tcx
|
||||||
.sess
|
.sess
|
||||||
.fatal(format!("vector_length called on non-vector type: {:?}", ty)),
|
.fatal(format!("vector_length called on non-vector type: {ty:?}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,7 +269,7 @@ impl<'tcx> BaseTypeMethods<'tcx> for CodegenCx<'tcx> {
|
|||||||
ty => self
|
ty => self
|
||||||
.tcx
|
.tcx
|
||||||
.sess
|
.sess
|
||||||
.fatal(format!("float_width called on non-float type: {:?}", ty)),
|
.fatal(format!("float_width called on non-float type: {ty:?}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,7 +280,7 @@ impl<'tcx> BaseTypeMethods<'tcx> for CodegenCx<'tcx> {
|
|||||||
ty => self
|
ty => self
|
||||||
.tcx
|
.tcx
|
||||||
.sess
|
.sess
|
||||||
.fatal(format!("int_width called on non-integer type: {:?}", ty)),
|
.fatal(format!("int_width called on non-integer type: {ty:?}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ pub fn link(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
other => {
|
other => {
|
||||||
sess.err(format!("CrateType {:?} not supported yet", other));
|
sess.err(format!("CrateType {other:?} not supported yet"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -116,8 +116,7 @@ fn link_rlib(sess: &Session, codegen_results: &CodegenResults, out_filename: &Pa
|
|||||||
}
|
}
|
||||||
if let Some(name) = lib.name {
|
if let Some(name) = lib.name {
|
||||||
sess.err(format!(
|
sess.err(format!(
|
||||||
"Adding native library to rlib not supported yet: {}",
|
"Adding native library to rlib not supported yet: {name}"
|
||||||
name
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -264,12 +263,11 @@ fn post_link_single_module(
|
|||||||
} else {
|
} else {
|
||||||
let reason = match (sess.opts.optimize, sess.opts.debuginfo == DebugInfo::None) {
|
let reason = match (sess.opts.optimize, sess.opts.debuginfo == DebugInfo::None) {
|
||||||
(OptLevel::No, true) => "debuginfo=None".to_string(),
|
(OptLevel::No, true) => "debuginfo=None".to_string(),
|
||||||
(optlevel, false) => format!("optlevel={:?}", optlevel),
|
(optlevel, false) => format!("optlevel={optlevel:?}"),
|
||||||
(optlevel, true) => format!("optlevel={:?}, debuginfo=None", optlevel),
|
(optlevel, true) => format!("optlevel={optlevel:?}, debuginfo=None"),
|
||||||
};
|
};
|
||||||
sess.warn(format!(
|
sess.warn(format!(
|
||||||
"`spirv-opt` should have ran ({}) but was disabled by `--no-spirv-opt`",
|
"`spirv-opt` should have ran ({reason}) but was disabled by `--no-spirv-opt`"
|
||||||
reason
|
|
||||||
));
|
));
|
||||||
spv_binary
|
spv_binary
|
||||||
}
|
}
|
||||||
@ -287,7 +285,7 @@ fn post_link_single_module(
|
|||||||
{
|
{
|
||||||
let mut err = sess.struct_err("failed to serialize spirv-binary to disk");
|
let mut err = sess.struct_err("failed to serialize spirv-binary to disk");
|
||||||
err.note(&format!("module `{}`", out_filename.display()));
|
err.note(&format!("module `{}`", out_filename.display()));
|
||||||
err.note(&format!("I/O error: {:#}", e));
|
err.note(&format!("I/O error: {e:#}"));
|
||||||
err.emit();
|
err.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -452,12 +450,10 @@ fn add_upstream_native_libraries(
|
|||||||
}
|
}
|
||||||
match lib.kind {
|
match lib.kind {
|
||||||
NativeLibKind::Dylib { .. } | NativeLibKind::Unspecified => sess.fatal(format!(
|
NativeLibKind::Dylib { .. } | NativeLibKind::Unspecified => sess.fatal(format!(
|
||||||
"TODO: dylib nativelibkind not supported yet: {}",
|
"TODO: dylib nativelibkind not supported yet: {name}"
|
||||||
name
|
|
||||||
)),
|
)),
|
||||||
NativeLibKind::Framework { .. } => sess.fatal(format!(
|
NativeLibKind::Framework { .. } => sess.fatal(format!(
|
||||||
"TODO: framework nativelibkind not supported yet: {}",
|
"TODO: framework nativelibkind not supported yet: {name}"
|
||||||
name
|
|
||||||
)),
|
)),
|
||||||
NativeLibKind::Static {
|
NativeLibKind::Static {
|
||||||
bundle: Some(false),
|
bundle: Some(false),
|
||||||
@ -465,8 +461,7 @@ fn add_upstream_native_libraries(
|
|||||||
} => {
|
} => {
|
||||||
if data[cnum.as_usize() - 1] == Linkage::Static {
|
if data[cnum.as_usize() - 1] == Linkage::Static {
|
||||||
sess.fatal(format!(
|
sess.fatal(format!(
|
||||||
"TODO: staticnobundle nativelibkind not supported yet: {}",
|
"TODO: staticnobundle nativelibkind not supported yet: {name}"
|
||||||
name
|
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -475,11 +470,10 @@ fn add_upstream_native_libraries(
|
|||||||
..
|
..
|
||||||
} => {}
|
} => {}
|
||||||
NativeLibKind::RawDylib => {
|
NativeLibKind::RawDylib => {
|
||||||
sess.fatal(format!("raw_dylib feature not yet implemented: {}", name))
|
sess.fatal(format!("raw_dylib feature not yet implemented: {name}"))
|
||||||
}
|
}
|
||||||
NativeLibKind::LinkArg => sess.fatal(format!(
|
NativeLibKind::LinkArg => sess.fatal(format!(
|
||||||
"TODO: linkarg nativelibkind not supported yet: {}",
|
"TODO: linkarg nativelibkind not supported yet: {name}"
|
||||||
name
|
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ fn find_import_export_pairs_and_killed_params(
|
|||||||
};
|
};
|
||||||
let type_id = *type_map.get(&id).expect("Unexpected op");
|
let type_id = *type_map.get(&id).expect("Unexpected op");
|
||||||
if exports.insert(name, (id, type_id)).is_some() {
|
if exports.insert(name, (id, type_id)).is_some() {
|
||||||
return Err(sess.err(format!("Multiple exports found for {:?}", name)));
|
return Err(sess.err(format!("Multiple exports found for {name:?}")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let mut any_err = None;
|
let mut any_err = None;
|
||||||
@ -68,7 +68,7 @@ fn find_import_export_pairs_and_killed_params(
|
|||||||
};
|
};
|
||||||
let (export_id, export_type) = match exports.get(name) {
|
let (export_id, export_type) = match exports.get(name) {
|
||||||
None => {
|
None => {
|
||||||
any_err = Some(sess.err(format!("Unresolved symbol {:?}", name)));
|
any_err = Some(sess.err(format!("Unresolved symbol {name:?}")));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Some(&x) => x,
|
Some(&x) => x,
|
||||||
@ -165,7 +165,7 @@ fn check_tys_equal(
|
|||||||
Some(def) => {
|
Some(def) => {
|
||||||
write!(buf, "({}", def.class.opname).unwrap();
|
write!(buf, "({}", def.class.opname).unwrap();
|
||||||
if let Some(result_type) = def.result_type {
|
if let Some(result_type) = def.result_type {
|
||||||
write!(buf, " {}", result_type).unwrap();
|
write!(buf, " {result_type}").unwrap();
|
||||||
}
|
}
|
||||||
for op in &def.operands {
|
for op in &def.operands {
|
||||||
if let Some(id) = op.id_ref_any() {
|
if let Some(id) = op.id_ref_any() {
|
||||||
@ -175,7 +175,7 @@ fn check_tys_equal(
|
|||||||
}
|
}
|
||||||
write!(buf, ")").unwrap();
|
write!(buf, ")").unwrap();
|
||||||
}
|
}
|
||||||
None => write!(buf, "{}", ty).unwrap(),
|
None => write!(buf, "{ty}").unwrap(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn format_ty_(ty_defs: &FxHashMap<Word, &Instruction>, ty: Word) -> String {
|
fn format_ty_(ty_defs: &FxHashMap<Word, &Instruction>, ty: Word) -> String {
|
||||||
@ -184,7 +184,7 @@ fn check_tys_equal(
|
|||||||
result
|
result
|
||||||
}
|
}
|
||||||
Err(sess
|
Err(sess
|
||||||
.struct_err(&format!("Types mismatch for {:?}", name))
|
.struct_err(&format!("Types mismatch for {name:?}"))
|
||||||
.note(&format!(
|
.note(&format!(
|
||||||
"import type: {}",
|
"import type: {}",
|
||||||
format_ty_(&ty_defs, import_type)
|
format_ty_(&ty_defs, import_type)
|
||||||
|
@ -125,8 +125,7 @@ fn deny_recursion_in_module(sess: &Session, module: &Module) -> super::Result<()
|
|||||||
let current_name = get_name(&names, module.functions[current].def_id().unwrap());
|
let current_name = get_name(&names, module.functions[current].def_id().unwrap());
|
||||||
let next_name = get_name(&names, module.functions[next].def_id().unwrap());
|
let next_name = get_name(&names, module.functions[next].def_id().unwrap());
|
||||||
*has_recursion = Some(sess.err(format!(
|
*has_recursion = Some(sess.err(format!(
|
||||||
"module has recursion, which is not allowed: `{}` calls `{}`",
|
"module has recursion, which is not allowed: `{current_name}` calls `{next_name}`"
|
||||||
current_name, next_name
|
|
||||||
)));
|
)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ fn get_names(module: &Module) -> FxHashMap<Word, &str> {
|
|||||||
|
|
||||||
fn get_name<'a>(names: &FxHashMap<Word, &'a str>, id: Word) -> Cow<'a, str> {
|
fn get_name<'a>(names: &FxHashMap<Word, &'a str>, id: Word) -> Cow<'a, str> {
|
||||||
names.get(&id).map_or_else(
|
names.get(&id).map_or_else(
|
||||||
|| Cow::Owned(format!("Unnamed function ID %{}", id)),
|
|| Cow::Owned(format!("Unnamed function ID %{id}")),
|
||||||
|&s| Cow::Borrowed(s),
|
|&s| Cow::Borrowed(s),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ pub fn specialize(
|
|||||||
replacements.to_concrete(&[], |instance| expander.alloc_instance_id(instance))
|
replacements.to_concrete(&[], |instance| expander.alloc_instance_id(instance))
|
||||||
{
|
{
|
||||||
if debug {
|
if debug {
|
||||||
eprintln!(" {} -> {:?}", operand, loc);
|
eprintln!(" {operand} -> {loc:?}");
|
||||||
}
|
}
|
||||||
func.index_set(loc, operand.into());
|
func.index_set(loc, operand.into());
|
||||||
}
|
}
|
||||||
@ -259,8 +259,8 @@ impl From<CopyOperand> for Operand {
|
|||||||
impl fmt::Display for CopyOperand {
|
impl fmt::Display for CopyOperand {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
Self::IdRef(id) => write!(f, "%{}", id),
|
Self::IdRef(id) => write!(f, "%{id}"),
|
||||||
Self::StorageClass(s) => write!(f, "{:?}", s),
|
Self::StorageClass(s) => write!(f, "{s:?}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -349,12 +349,12 @@ impl<GA> Instance<GA> {
|
|||||||
} = self;
|
} = self;
|
||||||
let generic_args_iter = f(generic_args);
|
let generic_args_iter = f(generic_args);
|
||||||
FmtBy(move |f| {
|
FmtBy(move |f| {
|
||||||
write!(f, "%{}<", generic_id)?;
|
write!(f, "%{generic_id}<")?;
|
||||||
for (i, arg) in generic_args_iter.clone().enumerate() {
|
for (i, arg) in generic_args_iter.clone().enumerate() {
|
||||||
if i != 0 {
|
if i != 0 {
|
||||||
write!(f, ", ")?;
|
write!(f, ", ")?;
|
||||||
}
|
}
|
||||||
write!(f, "{}", arg)?;
|
write!(f, "{arg}")?;
|
||||||
}
|
}
|
||||||
write!(f, ">")
|
write!(f, ">")
|
||||||
})
|
})
|
||||||
@ -793,18 +793,18 @@ impl InferOperand {
|
|||||||
FmtBy(move |f| {
|
FmtBy(move |f| {
|
||||||
let var_with_value = |v| {
|
let var_with_value = |v| {
|
||||||
FmtBy(move |f| {
|
FmtBy(move |f| {
|
||||||
write!(f, "{}", v)?;
|
write!(f, "{v}")?;
|
||||||
match infer_var_value(v) {
|
match infer_var_value(v) {
|
||||||
Value::Unknown => Ok(()),
|
Value::Unknown => Ok(()),
|
||||||
Value::Known(o) => write!(f, " = {}", o),
|
Value::Known(o) => write!(f, " = {o}"),
|
||||||
Value::SameAs(v) => write!(f, " = {}", v),
|
Value::SameAs(v) => write!(f, " = {v}"),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
match self {
|
match self {
|
||||||
Self::Unknown => write!(f, "_"),
|
Self::Unknown => write!(f, "_"),
|
||||||
Self::Var(v) => write!(f, "{}", var_with_value(*v)),
|
Self::Var(v) => write!(f, "{}", var_with_value(*v)),
|
||||||
Self::Concrete(o) => write!(f, "{}", o),
|
Self::Concrete(o) => write!(f, "{o}"),
|
||||||
Self::Instance(instance) => write!(
|
Self::Instance(instance) => write!(
|
||||||
f,
|
f,
|
||||||
"{}",
|
"{}",
|
||||||
@ -1136,7 +1136,7 @@ impl<'a> Match<'a> {
|
|||||||
let mut found = found.iter().map(display);
|
let mut found = found.iter().map(display);
|
||||||
write!(f, "{}", found.next().unwrap())?;
|
write!(f, "{}", found.next().unwrap())?;
|
||||||
for x in found {
|
for x in found {
|
||||||
write!(f, " = {}", x)?;
|
write!(f, " = {x}")?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
@ -1192,8 +1192,8 @@ impl<'a> Match<'a> {
|
|||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
match maybe_idx {
|
match maybe_idx {
|
||||||
Some(idx) => write!(f, ".{}", idx)?,
|
Some(idx) => write!(f, ".{idx}")?,
|
||||||
None => write!(f, "[{}]", operand)?,
|
None => write!(f, "[{operand}]")?,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
write!(f, " = {}", leaf.display_with_infer_cx(cx))
|
write!(f, " = {}", leaf.display_with_infer_cx(cx))
|
||||||
@ -1503,13 +1503,13 @@ impl InferError {
|
|||||||
// FIXME(eddyb) better error reporting than this.
|
// FIXME(eddyb) better error reporting than this.
|
||||||
match self {
|
match self {
|
||||||
Self::Conflict(a, b) => {
|
Self::Conflict(a, b) => {
|
||||||
eprintln!("inference conflict: {:?} vs {:?}", a, b);
|
eprintln!("inference conflict: {a:?} vs {b:?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
eprint!(" in ");
|
eprint!(" in ");
|
||||||
// FIXME(eddyb) deduplicate this with other instruction printing logic.
|
// FIXME(eddyb) deduplicate this with other instruction printing logic.
|
||||||
if let Some(result_id) = inst.result_id {
|
if let Some(result_id) = inst.result_id {
|
||||||
eprint!("%{} = ", result_id);
|
eprint!("%{result_id} = ");
|
||||||
}
|
}
|
||||||
eprint!("Op{:?}", inst.class.opcode);
|
eprint!("Op{:?}", inst.class.opcode);
|
||||||
for operand in inst
|
for operand in inst
|
||||||
@ -1518,7 +1518,7 @@ impl InferError {
|
|||||||
.iter()
|
.iter()
|
||||||
.chain(inst.operands.iter())
|
.chain(inst.operands.iter())
|
||||||
{
|
{
|
||||||
eprint!(" {}", operand);
|
eprint!(" {operand}");
|
||||||
}
|
}
|
||||||
eprintln!();
|
eprintln!();
|
||||||
|
|
||||||
@ -1950,9 +1950,9 @@ impl<'a, S: Specialization> InferCx<'a, S> {
|
|||||||
if inst_loc != InstructionLocation::Module {
|
if inst_loc != InstructionLocation::Module {
|
||||||
eprint!(" ");
|
eprint!(" ");
|
||||||
}
|
}
|
||||||
eprint!("{}", prefix);
|
eprint!("{prefix}");
|
||||||
if let Some(result_id) = inst.result_id {
|
if let Some(result_id) = inst.result_id {
|
||||||
eprint!("%{} = ", result_id);
|
eprint!("%{result_id} = ");
|
||||||
}
|
}
|
||||||
eprint!("Op{:?}", inst.class.opcode);
|
eprint!("Op{:?}", inst.class.opcode);
|
||||||
for operand in result_type.into_iter().chain(inputs.iter(cx)) {
|
for operand in result_type.into_iter().chain(inputs.iter(cx)) {
|
||||||
@ -2025,9 +2025,9 @@ impl<'a, S: Specialization> InferCx<'a, S> {
|
|||||||
|
|
||||||
if self.specializer.debug {
|
if self.specializer.debug {
|
||||||
eprintln!();
|
eprintln!();
|
||||||
eprint!("specializer::instantiate_function(%{}", func_id);
|
eprint!("specializer::instantiate_function(%{func_id}");
|
||||||
if let Some(name) = self.specializer.debug_names.get(&func_id) {
|
if let Some(name) = self.specializer.debug_names.get(&func_id) {
|
||||||
eprint!(" {}", name);
|
eprint!(" {name}");
|
||||||
}
|
}
|
||||||
eprintln!("):");
|
eprintln!("):");
|
||||||
}
|
}
|
||||||
@ -2482,7 +2482,7 @@ impl<'a, S: Specialization> Expander<'a, S> {
|
|||||||
// FIXME(eddyb) maybe dump (transitive) dependencies? could use a def-use graph.
|
// FIXME(eddyb) maybe dump (transitive) dependencies? could use a def-use graph.
|
||||||
for (&generic_id, generic) in &self.specializer.generics {
|
for (&generic_id, generic) in &self.specializer.generics {
|
||||||
if let Some(name) = self.specializer.debug_names.get(&generic_id) {
|
if let Some(name) = self.specializer.debug_names.get(&generic_id) {
|
||||||
writeln!(w, "; {}", name)?;
|
writeln!(w, "; {name}")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
write!(
|
write!(
|
||||||
@ -2525,7 +2525,7 @@ impl<'a, S: Specialization> Expander<'a, S> {
|
|||||||
} else if needed == 1 {
|
} else if needed == 1 {
|
||||||
write!(w, "{}", params.start)?;
|
write!(w, "{}", params.start)?;
|
||||||
} else {
|
} else {
|
||||||
write!(w, "{}", operand)?;
|
write!(w, "{operand}")?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writeln!(w)?;
|
writeln!(w)?;
|
||||||
@ -2536,8 +2536,8 @@ impl<'a, S: Specialization> Expander<'a, S> {
|
|||||||
let p = Param(i as u32);
|
let p = Param(i as u32);
|
||||||
match v {
|
match v {
|
||||||
Value::Unknown => {}
|
Value::Unknown => {}
|
||||||
Value::Known(o) => write!(w, " {} = {},", p, o)?,
|
Value::Known(o) => write!(w, " {p} = {o},")?,
|
||||||
Value::SameAs(q) => write!(w, " {} = {},", p, q)?,
|
Value::SameAs(q) => write!(w, " {p} = {q},")?,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writeln!(w)?;
|
writeln!(w)?;
|
||||||
|
@ -123,7 +123,7 @@ impl SpirvType<'_> {
|
|||||||
other => cx.zombie_with_span(
|
other => cx.zombie_with_span(
|
||||||
result,
|
result,
|
||||||
def_span,
|
def_span,
|
||||||
&format!("Integer width {} invalid for spir-v", other),
|
&format!("Integer width {other} invalid for spir-v"),
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
result
|
result
|
||||||
@ -141,7 +141,7 @@ impl SpirvType<'_> {
|
|||||||
other => cx.zombie_with_span(
|
other => cx.zombie_with_span(
|
||||||
result,
|
result,
|
||||||
def_span,
|
def_span,
|
||||||
&format!("Float width {} invalid for spir-v", other),
|
&format!("Float width {other} invalid for spir-v"),
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
result
|
result
|
||||||
@ -304,7 +304,7 @@ impl SpirvType<'_> {
|
|||||||
ref other => cx
|
ref other => cx
|
||||||
.tcx
|
.tcx
|
||||||
.sess
|
.sess
|
||||||
.fatal(format!("def_with_id invalid for type {:?}", other)),
|
.fatal(format!("def_with_id invalid for type {other:?}")),
|
||||||
};
|
};
|
||||||
cx.type_cache_def(result, self.tcx_arena_alloc_slices(cx), def_span);
|
cx.type_cache_def(result, self.tcx_arena_alloc_slices(cx), def_span);
|
||||||
result
|
result
|
||||||
@ -648,9 +648,9 @@ impl SpirvTypePrinter<'_, '_> {
|
|||||||
SpirvType::Bool => f.write_str("bool"),
|
SpirvType::Bool => f.write_str("bool"),
|
||||||
SpirvType::Integer(width, signedness) => {
|
SpirvType::Integer(width, signedness) => {
|
||||||
let prefix = if signedness { "i" } else { "u" };
|
let prefix = if signedness { "i" } else { "u" };
|
||||||
write!(f, "{}{}", prefix, width)
|
write!(f, "{prefix}{width}")
|
||||||
}
|
}
|
||||||
SpirvType::Float(width) => write!(f, "f{}", width),
|
SpirvType::Float(width) => write!(f, "f{width}"),
|
||||||
SpirvType::Adt {
|
SpirvType::Adt {
|
||||||
def_id: _,
|
def_id: _,
|
||||||
align: _,
|
align: _,
|
||||||
@ -674,7 +674,7 @@ impl SpirvTypePrinter<'_, '_> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if let Some(name) = first_name {
|
if let Some(name) = first_name {
|
||||||
write!(f, " {}", name)?;
|
write!(f, " {name}")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
f.write_str(" { ")?;
|
f.write_str(" { ")?;
|
||||||
@ -688,20 +688,20 @@ impl SpirvTypePrinter<'_, '_> {
|
|||||||
write!(f, "{}: ", field_names[index])?;
|
write!(f, "{}: ", field_names[index])?;
|
||||||
}
|
}
|
||||||
ty(self.cx, stack, f, field)?;
|
ty(self.cx, stack, f, field)?;
|
||||||
write!(f, "{}", suffix)?;
|
write!(f, "{suffix}")?;
|
||||||
}
|
}
|
||||||
f.write_str(" }")
|
f.write_str(" }")
|
||||||
}
|
}
|
||||||
SpirvType::Vector { element, count } | SpirvType::Matrix { element, count } => {
|
SpirvType::Vector { element, count } | SpirvType::Matrix { element, count } => {
|
||||||
ty(self.cx, stack, f, element)?;
|
ty(self.cx, stack, f, element)?;
|
||||||
write!(f, "x{}", count)
|
write!(f, "x{count}")
|
||||||
}
|
}
|
||||||
SpirvType::Array { element, count } => {
|
SpirvType::Array { element, count } => {
|
||||||
let len = self.cx.builder.lookup_const_u64(count);
|
let len = self.cx.builder.lookup_const_u64(count);
|
||||||
let len = len.expect("Array type has invalid count value");
|
let len = len.expect("Array type has invalid count value");
|
||||||
f.write_str("[")?;
|
f.write_str("[")?;
|
||||||
ty(self.cx, stack, f, element)?;
|
ty(self.cx, stack, f, element)?;
|
||||||
write!(f, "; {}]", len)
|
write!(f, "; {len}]")
|
||||||
}
|
}
|
||||||
SpirvType::RuntimeArray { element } => {
|
SpirvType::RuntimeArray { element } => {
|
||||||
f.write_str("[")?;
|
f.write_str("[")?;
|
||||||
@ -724,7 +724,7 @@ impl SpirvTypePrinter<'_, '_> {
|
|||||||
", "
|
", "
|
||||||
};
|
};
|
||||||
ty(self.cx, stack, f, arg)?;
|
ty(self.cx, stack, f, arg)?;
|
||||||
write!(f, "{}", suffix)?;
|
write!(f, "{suffix}")?;
|
||||||
}
|
}
|
||||||
f.write_str(") -> ")?;
|
f.write_str(") -> ")?;
|
||||||
ty(self.cx, stack, f, return_type)
|
ty(self.cx, stack, f, return_type)
|
||||||
|
@ -16,7 +16,7 @@ impl std::str::FromStr for TargetFeature {
|
|||||||
Ok(Self::Extension(Symbol::intern(input)))
|
Ok(Self::Extension(Symbol::intern(input)))
|
||||||
} else {
|
} else {
|
||||||
Ok(Self::Capability(input.parse().map_err(|_err| {
|
Ok(Self::Capability(input.parse().map_err(|_err| {
|
||||||
format!("Invalid Capability: `{}`", input)
|
format!("Invalid Capability: `{input}`")
|
||||||
})?))
|
})?))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ pub fn read_deps_file(
|
|||||||
f: impl FnMut(RawString, Vec<RawString>) -> Result<(), Error>,
|
f: impl FnMut(RawString, Vec<RawString>) -> Result<(), Error>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let file = File::open(file_name)
|
let file = File::open(file_name)
|
||||||
.map_err(|e| Error::new(e.kind(), format!("Unable to read {:?}: {}", file_name, e)))?;
|
.map_err(|e| Error::new(e.kind(), format!("Unable to read {file_name:?}: {e}")))?;
|
||||||
read_deps_file_from(file, f)
|
read_deps_file_from(file, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@ impl SpirvBuilder {
|
|||||||
match self.print_metadata {
|
match self.print_metadata {
|
||||||
MetadataPrintout::Full | MetadataPrintout::DependencyOnly => {
|
MetadataPrintout::Full | MetadataPrintout::DependencyOnly => {
|
||||||
leaf_deps(&metadata_file, |artifact| {
|
leaf_deps(&metadata_file, |artifact| {
|
||||||
println!("cargo:rerun-if-changed={}", artifact);
|
println!("cargo:rerun-if-changed={artifact}");
|
||||||
})
|
})
|
||||||
// Close enough
|
// Close enough
|
||||||
.map_err(SpirvBuilderError::MetadataFileMissing)?;
|
.map_err(SpirvBuilderError::MetadataFileMissing)?;
|
||||||
@ -488,8 +488,8 @@ fn invoke_rustc(builder: &SpirvBuilder) -> Result<PathBuf, SpirvBuilderError> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut target_features = vec![];
|
let mut target_features = vec![];
|
||||||
target_features.extend(builder.capabilities.iter().map(|cap| format!("+{:?}", cap)));
|
target_features.extend(builder.capabilities.iter().map(|cap| format!("+{cap:?}")));
|
||||||
target_features.extend(builder.extensions.iter().map(|ext| format!("+ext:{}", ext)));
|
target_features.extend(builder.extensions.iter().map(|ext| format!("+ext:{ext}")));
|
||||||
let target_features = join_checking_for_separators(target_features, ",");
|
let target_features = join_checking_for_separators(target_features, ",");
|
||||||
if !target_features.is_empty() {
|
if !target_features.is_empty() {
|
||||||
rustflags.push(["-Ctarget-feature=", &target_features].concat());
|
rustflags.push(["-Ctarget-feature=", &target_features].concat());
|
||||||
@ -600,7 +600,7 @@ fn get_sole_artifact(out: &str) -> Option<PathBuf> {
|
|||||||
Some(line)
|
Some(line)
|
||||||
} else {
|
} else {
|
||||||
// Pass through invalid lines
|
// Pass through invalid lines
|
||||||
println!("{}", line);
|
println!("{line}");
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -38,7 +38,7 @@ impl SpirvBuilder {
|
|||||||
let _ = tx.try_send(());
|
let _ = tx.try_send(());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(e) => println!("notify error: {:?}", e),
|
Err(e) => println!("notify error: {e:?}"),
|
||||||
})
|
})
|
||||||
.expect("Could create watcher");
|
.expect("Could create watcher");
|
||||||
// This is likely to notice changes in the `target` dir, however, given that `cargo watch` doesn't seem to handle that,
|
// This is likely to notice changes in the `target` dir, however, given that `cargo watch` doesn't seem to handle that,
|
||||||
@ -71,7 +71,7 @@ impl SpirvBuilder {
|
|||||||
let _ = tx.try_send(());
|
let _ = tx.try_send(());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(e) => println!("notify error: {:?}", e),
|
Err(e) => println!("notify error: {e:?}"),
|
||||||
})
|
})
|
||||||
.expect("Could create watcher");
|
.expect("Could create watcher");
|
||||||
leaf_deps(&metadata_file, |it| {
|
leaf_deps(&metadata_file, |it| {
|
||||||
|
@ -483,7 +483,7 @@ fn debug_printf_inner(input: DebugPrintfInput) -> TokenStream {
|
|||||||
|
|
||||||
let mut has_precision = false;
|
let mut has_precision = false;
|
||||||
|
|
||||||
while matches!(ch, '0'..='9') {
|
while ch.is_ascii_digit() {
|
||||||
ch = match chars.next() {
|
ch = match chars.next() {
|
||||||
Some(ch) => ch,
|
Some(ch) => ch,
|
||||||
None => {
|
None => {
|
||||||
@ -508,7 +508,7 @@ fn debug_printf_inner(input: DebugPrintfInput) -> TokenStream {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
while matches!(ch, '0'..='9') {
|
while ch.is_ascii_digit() {
|
||||||
ch = match chars.next() {
|
ch = match chars.next() {
|
||||||
Some(ch) => ch,
|
Some(ch) => ch,
|
||||||
None => return parsing_error(
|
None => return parsing_error(
|
||||||
@ -525,7 +525,7 @@ fn debug_printf_inner(input: DebugPrintfInput) -> TokenStream {
|
|||||||
Some('3') => 3,
|
Some('3') => 3,
|
||||||
Some('4') => 4,
|
Some('4') => 4,
|
||||||
Some(ch) => {
|
Some(ch) => {
|
||||||
return parsing_error(&format!("Invalid width for vector: {}", ch), span)
|
return parsing_error(&format!("Invalid width for vector: {ch}"), span)
|
||||||
}
|
}
|
||||||
None => return parsing_error("Missing vector dimensions specifier", span),
|
None => return parsing_error("Missing vector dimensions specifier", span),
|
||||||
};
|
};
|
||||||
@ -539,7 +539,7 @@ fn debug_printf_inner(input: DebugPrintfInput) -> TokenStream {
|
|||||||
Some(ty) => ty,
|
Some(ty) => ty,
|
||||||
_ => {
|
_ => {
|
||||||
return parsing_error(
|
return parsing_error(
|
||||||
&format!("Unrecognised vector type specifier: '{}'", ch),
|
&format!("Unrecognised vector type specifier: '{ch}'"),
|
||||||
span,
|
span,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -551,7 +551,7 @@ fn debug_printf_inner(input: DebugPrintfInput) -> TokenStream {
|
|||||||
Some(ty) => ty,
|
Some(ty) => ty,
|
||||||
_ => {
|
_ => {
|
||||||
return parsing_error(
|
return parsing_error(
|
||||||
&format!("Unrecognised format specifier: '{}'", ch),
|
&format!("Unrecognised format specifier: '{ch}'"),
|
||||||
span,
|
span,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -583,7 +583,7 @@ fn debug_printf_inner(input: DebugPrintfInput) -> TokenStream {
|
|||||||
{
|
{
|
||||||
let ident = quote::format_ident!("_{}", i);
|
let ident = quote::format_ident!("_{}", i);
|
||||||
|
|
||||||
let _ = write!(variable_idents, "%{} ", ident);
|
let _ = write!(variable_idents, "%{ident} ");
|
||||||
|
|
||||||
let assert_fn = match format_argument {
|
let assert_fn = match format_argument {
|
||||||
FormatType::Scalar { ty } => {
|
FormatType::Scalar { ty } => {
|
||||||
@ -598,7 +598,7 @@ fn debug_printf_inner(input: DebugPrintfInput) -> TokenStream {
|
|||||||
#ident = in(reg) &#assert_fn(#variable),
|
#ident = in(reg) &#assert_fn(#variable),
|
||||||
});
|
});
|
||||||
|
|
||||||
let op_load = format!("%{ident} = OpLoad _ {{{ident}}}", ident = ident);
|
let op_load = format!("%{ident} = OpLoad _ {{{ident}}}");
|
||||||
|
|
||||||
op_loads.push(quote::quote! {
|
op_loads.push(quote::quote! {
|
||||||
#op_load,
|
#op_load,
|
||||||
@ -610,7 +610,7 @@ fn debug_printf_inner(input: DebugPrintfInput) -> TokenStream {
|
|||||||
.collect::<proc_macro2::TokenStream>();
|
.collect::<proc_macro2::TokenStream>();
|
||||||
let op_loads = op_loads.into_iter().collect::<proc_macro2::TokenStream>();
|
let op_loads = op_loads.into_iter().collect::<proc_macro2::TokenStream>();
|
||||||
|
|
||||||
let op_string = format!("%string = OpString {:?}", format_string);
|
let op_string = format!("%string = OpString {format_string:?}");
|
||||||
|
|
||||||
let output = quote::quote! {
|
let output = quote::quote! {
|
||||||
::core::arch::asm!(
|
::core::arch::asm!(
|
||||||
|
@ -9,5 +9,5 @@ fn main() {
|
|||||||
.multimodule(true)
|
.multimodule(true)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
println!("{:#?}", result);
|
println!("{result:#?}");
|
||||||
}
|
}
|
||||||
|
@ -4,5 +4,5 @@ fn main() {
|
|||||||
// While OUT_DIR is set for both build.rs and compiling the crate, PROFILE is only set in
|
// While OUT_DIR is set for both build.rs and compiling the crate, PROFILE is only set in
|
||||||
// build.rs. So, export it to crate compilation as well.
|
// build.rs. So, export it to crate compilation as well.
|
||||||
let profile = env::var("PROFILE").unwrap();
|
let profile = env::var("PROFILE").unwrap();
|
||||||
println!("cargo:rustc-env=PROFILE={}", profile);
|
println!("cargo:rustc-env=PROFILE={profile}");
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
// While OUT_DIR is set for both build.rs and compiling the crate, PROFILE is only set in
|
// While OUT_DIR is set for both build.rs and compiling the crate, PROFILE is only set in
|
||||||
// build.rs. So, export it to crate compilation as well.
|
// build.rs. So, export it to crate compilation as well.
|
||||||
let profile = env::var("PROFILE").unwrap();
|
let profile = env::var("PROFILE").unwrap();
|
||||||
println!("cargo:rustc-env=PROFILE={}", profile);
|
println!("cargo:rustc-env=PROFILE={profile}");
|
||||||
if target_os != "android" && target_arch != "wasm32" {
|
if target_os != "android" && target_arch != "wasm32" {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
@ -173,12 +173,12 @@ pub async fn start_internal(
|
|||||||
let mut max = 0;
|
let mut max = 0;
|
||||||
for (src, out) in src_range.zip(result.iter().copied()) {
|
for (src, out) in src_range.zip(result.iter().copied()) {
|
||||||
if out == u32::MAX {
|
if out == u32::MAX {
|
||||||
println!("{}: overflowed", src);
|
println!("{src}: overflowed");
|
||||||
break;
|
break;
|
||||||
} else if out > max {
|
} else if out > max {
|
||||||
max = out;
|
max = out;
|
||||||
// Should produce <https://oeis.org/A006877>
|
// Should produce <https://oeis.org/A006877>
|
||||||
println!("{}: {}", src, out);
|
println!("{src}: {out}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
println!(
|
println!(
|
||||||
|
@ -158,7 +158,7 @@ async fn run(
|
|||||||
let output = match surface.get_current_texture() {
|
let output = match surface.get_current_texture() {
|
||||||
Ok(surface) => surface,
|
Ok(surface) => surface,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("get_current_texture error: {:?}", err);
|
eprintln!("get_current_texture error: {err:?}");
|
||||||
match err {
|
match err {
|
||||||
wgpu::SurfaceError::Lost => {
|
wgpu::SurfaceError::Lost => {
|
||||||
surface.configure(&device, &surface_config);
|
surface.configure(&device, &surface_config);
|
||||||
|
@ -19,14 +19,14 @@ fn main() {
|
|||||||
Some(out) if out > max => {
|
Some(out) if out > max => {
|
||||||
max = out;
|
max = out;
|
||||||
// Should produce <https://oeis.org/A006877>
|
// Should produce <https://oeis.org/A006877>
|
||||||
println!("{}: {}", src, out);
|
println!("{src}: {out}");
|
||||||
}
|
}
|
||||||
Some(_) => (),
|
Some(_) => (),
|
||||||
None => {
|
None => {
|
||||||
println!("{}: overflowed", src);
|
println!("{src}: overflowed");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
println!("Took: {:?}", took);
|
println!("Took: {took:?}");
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ impl DepKind {
|
|||||||
|
|
||||||
fn target_dir_suffix(self, target: &str) -> String {
|
fn target_dir_suffix(self, target: &str) -> String {
|
||||||
match self {
|
match self {
|
||||||
Self::SpirvLib => format!("{}/debug/deps", target),
|
Self::SpirvLib => format!("{target}/debug/deps"),
|
||||||
Self::ProcMacro => "debug/deps".into(),
|
Self::ProcMacro => "debug/deps".into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,7 +136,7 @@ impl Runner {
|
|||||||
// which offer `// only-S` and `// ignore-S` for any stage ID `S`.
|
// which offer `// only-S` and `// ignore-S` for any stage ID `S`.
|
||||||
let stage_id = if spirt { "spirt" } else { "not_spirt" };
|
let stage_id = if spirt { "spirt" } else { "not_spirt" };
|
||||||
|
|
||||||
let target = format!("{}{}", TARGET_PREFIX, env);
|
let target = format!("{TARGET_PREFIX}{env}");
|
||||||
let libs = build_deps(&self.deps_target_dir, &self.codegen_backend_path, &target);
|
let libs = build_deps(&self.deps_target_dir, &self.codegen_backend_path, &target);
|
||||||
let mut flags = test_rustc_flags(
|
let mut flags = test_rustc_flags(
|
||||||
&self.codegen_backend_path,
|
&self.codegen_backend_path,
|
||||||
@ -188,7 +188,7 @@ fn build_deps(deps_target_dir: &Path, codegen_backend_path: &Path, target: &str)
|
|||||||
"compiletests-deps-helper",
|
"compiletests-deps-helper",
|
||||||
"-Zbuild-std=core",
|
"-Zbuild-std=core",
|
||||||
"-Zbuild-std-features=compiler-builtins-mem",
|
"-Zbuild-std-features=compiler-builtins-mem",
|
||||||
&*format!("--target={}", target),
|
&*format!("--target={target}"),
|
||||||
])
|
])
|
||||||
.arg("--target-dir")
|
.arg("--target-dir")
|
||||||
.arg(deps_target_dir)
|
.arg(deps_target_dir)
|
||||||
|
Loading…
Reference in New Issue
Block a user