Skip to content

Commit ac0c703

Browse files
committed
Port old change to latest main
1 parent f180b8d commit ac0c703

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

crates/rustc_codegen_spirv/src/builder/builder_methods.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,21 +210,23 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
210210
},
211211
SpirvType::Integer(width, true) => match width {
212212
8 => self
213-
.constant_i8(self.span(), unsafe { std::mem::transmute(fill_byte) })
213+
.constant_i8(self.span(), unsafe {
214+
std::mem::transmute::<u8, i8>(fill_byte)
215+
})
214216
.def(self),
215217
16 => self
216218
.constant_i16(self.span(), unsafe {
217-
std::mem::transmute(memset_fill_u16(fill_byte))
219+
std::mem::transmute::<u16, i16>(memset_fill_u16(fill_byte))
218220
})
219221
.def(self),
220222
32 => self
221223
.constant_i32(self.span(), unsafe {
222-
std::mem::transmute(memset_fill_u32(fill_byte))
224+
std::mem::transmute::<u32, i32>(memset_fill_u32(fill_byte))
223225
})
224226
.def(self),
225227
64 => self
226228
.constant_i64(self.span(), unsafe {
227-
std::mem::transmute(memset_fill_u64(fill_byte))
229+
std::mem::transmute::<u64, i64>(memset_fill_u64(fill_byte))
228230
})
229231
.def(self),
230232
_ => self.fatal(format!(

crates/rustc_codegen_spirv/src/codegen_cx/constant.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ impl<'tcx> CodegenCx<'tcx> {
1818
self.builder.def_constant_cx(ty, val, self)
1919
}
2020

21-
pub fn constant_i8(&self, span: Span, val: i8) -> SpirvValue {
22-
let ty = SpirvType::Integer(8, true).def(span, self);
23-
self.def_constant(ty, SpirvConst::U32(val as u32))
24-
}
25-
2621
pub fn constant_u8(&self, span: Span, val: u8) -> SpirvValue {
2722
self.constant_int_from_native_unsigned(span, val)
2823
}
@@ -47,9 +42,8 @@ impl<'tcx> CodegenCx<'tcx> {
4742
self.constant_int_from_native_unsigned(span, val)
4843
}
4944

50-
pub fn constant_i64(&self, span: Span, val: u64) -> SpirvValue {
51-
let ty = SpirvType::Integer(64, true).def(span, self);
52-
self.def_constant(ty, SpirvConst::U64(val))
45+
pub fn constant_i64(&self, span: Span, val: i64) -> SpirvValue {
46+
self.constant_int_from_native_signed(span, val)
5347
}
5448

5549
pub fn constant_u64(&self, span: Span, val: u64) -> SpirvValue {

0 commit comments

Comments
 (0)