Skip to content

Commit 98e8601

Browse files
committed
Remove const_bitcast from ConstMethods
1 parent 7f44532 commit 98e8601

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

compiler/rustc_codegen_gcc/src/common.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
2828
global
2929
// TODO(antoyo): set linkage.
3030
}
31+
32+
pub fn const_bitcast(&self, value: RValue<'gcc>, typ: Type<'gcc>) -> RValue<'gcc> {
33+
if value.get_type() == self.bool_type.make_pointer() {
34+
if let Some(pointee) = typ.get_pointee() {
35+
if pointee.dyncast_vector().is_some() {
36+
panic!()
37+
}
38+
}
39+
}
40+
// NOTE: since bitcast makes a value non-constant, don't bitcast if not necessary as some
41+
// SIMD builtins require a constant value.
42+
self.bitcast_if_needed(value, typ)
43+
}
3144
}
3245

3346
pub fn bytes_in_context<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, bytes: &[u8]) -> RValue<'gcc> {
@@ -239,19 +252,6 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
239252
const_alloc_to_gcc(self, alloc)
240253
}
241254

242-
fn const_bitcast(&self, value: RValue<'gcc>, typ: Type<'gcc>) -> RValue<'gcc> {
243-
if value.get_type() == self.bool_type.make_pointer() {
244-
if let Some(pointee) = typ.get_pointee() {
245-
if pointee.dyncast_vector().is_some() {
246-
panic!()
247-
}
248-
}
249-
}
250-
// NOTE: since bitcast makes a value non-constant, don't bitcast if not necessary as some
251-
// SIMD builtins require a constant value.
252-
self.bitcast_if_needed(value, typ)
253-
}
254-
255255
fn const_ptr_byte_offset(&self, base_addr: Self::Value, offset: abi::Size) -> Self::Value {
256256
self.context
257257
.new_array_access(None, base_addr, self.const_usize(offset.bytes()))

compiler/rustc_codegen_llvm/src/common.rs

-4
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,6 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
329329
const_alloc_to_llvm(self, alloc, /*static*/ false)
330330
}
331331

332-
fn const_bitcast(&self, val: &'ll Value, ty: &'ll Type) -> &'ll Value {
333-
self.const_bitcast(val, ty)
334-
}
335-
336332
fn const_ptr_byte_offset(&self, base_addr: Self::Value, offset: abi::Size) -> Self::Value {
337333
unsafe {
338334
llvm::LLVMConstInBoundsGEP2(

compiler/rustc_codegen_ssa/src/traits/consts.rs

-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,5 @@ pub trait ConstMethods<'tcx>: BackendTypes {
3737

3838
fn scalar_to_backend(&self, cv: Scalar, layout: abi::Scalar, llty: Self::Type) -> Self::Value;
3939

40-
fn const_bitcast(&self, val: Self::Value, ty: Self::Type) -> Self::Value;
4140
fn const_ptr_byte_offset(&self, val: Self::Value, offset: abi::Size) -> Self::Value;
4241
}

0 commit comments

Comments
 (0)