Skip to content

Commit bc4a65d

Browse files
cg_ssa: remove pointee types and pointercast/bitcast-of-ptr
1 parent 9e58bac commit bc4a65d

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

src/builder.rs

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use rustc_codegen_ssa::traits::{
2727
BaseTypeMethods,
2828
BuilderMethods,
2929
ConstMethods,
30-
DerivedTypeMethods,
3130
LayoutTypeMethods,
3231
HasCodegen,
3332
OverflowOp,

src/common.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ use crate::context::CodegenCx;
1616
use crate::type_of::LayoutGccExt;
1717

1818
impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
19+
pub fn const_ptrcast(&self, val: RValue<'gcc>, ty: Type<'gcc>) -> RValue<'gcc> {
20+
self.context.new_cast(None, val, ty)
21+
}
22+
1923
pub fn const_bytes(&self, bytes: &[u8]) -> RValue<'gcc> {
2024
bytes_in_context(self, bytes)
2125
}
@@ -242,10 +246,6 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
242246
const_alloc_to_gcc(self, alloc)
243247
}
244248

245-
fn const_ptrcast(&self, val: RValue<'gcc>, ty: Type<'gcc>) -> RValue<'gcc> {
246-
self.context.new_cast(None, val, ty)
247-
}
248-
249249
fn const_bitcast(&self, value: RValue<'gcc>, typ: Type<'gcc>) -> RValue<'gcc> {
250250
if value.get_type() == self.bool_type.make_pointer() {
251251
if let Some(pointee) = typ.get_pointee() {

src/intrinsic/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
1212
use rustc_codegen_ssa::mir::place::PlaceRef;
1313
use rustc_codegen_ssa::traits::{ArgAbiMethods, BaseTypeMethods, BuilderMethods, ConstMethods, IntrinsicCallMethods};
1414
#[cfg(feature="master")]
15-
use rustc_codegen_ssa::traits::{DerivedTypeMethods, MiscMethods};
15+
use rustc_codegen_ssa::traits::MiscMethods;
1616
use rustc_codegen_ssa::errors::InvalidMonomorphization;
1717
use rustc_middle::bug;
1818
use rustc_middle::ty::{self, Instance, Ty};

src/type_.rs

+21-5
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,23 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
5454
self.u128_type
5555
}
5656

57+
pub fn type_ptr_to(&self, ty: Type<'gcc>) -> Type<'gcc> {
58+
ty.make_pointer()
59+
}
60+
61+
pub fn type_ptr_to_ext(&self, ty: Type<'gcc>, _address_space: AddressSpace) -> Type<'gcc> {
62+
// TODO(antoyo): use address_space, perhaps with TYPE_ADDR_SPACE?
63+
ty.make_pointer()
64+
}
65+
66+
pub fn type_i8p(&self) -> Type<'gcc> {
67+
self.type_ptr_to(self.type_i8())
68+
}
69+
70+
pub fn type_i8p_ext(&self, address_space: AddressSpace) -> Type<'gcc> {
71+
self.type_ptr_to_ext(self.type_i8(), address_space)
72+
}
73+
5774
pub fn type_pointee_for_align(&self, align: Align) -> Type<'gcc> {
5875
// FIXME(eddyb) We could find a better approximation if ity.align < align.
5976
let ity = Integer::approximate_align(self, align);
@@ -149,13 +166,12 @@ impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
149166
}
150167
}
151168

152-
fn type_ptr_to(&self, ty: Type<'gcc>) -> Type<'gcc> {
153-
ty.make_pointer()
169+
fn type_ptr(&self) -> Type<'gcc> {
170+
self.type_ptr_to(self.type_void())
154171
}
155172

156-
fn type_ptr_to_ext(&self, ty: Type<'gcc>, _address_space: AddressSpace) -> Type<'gcc> {
157-
// TODO(antoyo): use address_space, perhaps with TYPE_ADDR_SPACE?
158-
ty.make_pointer()
173+
fn type_ptr_ext(&self, address_space: AddressSpace) -> Type<'gcc> {
174+
self.type_ptr_to_ext(self.type_void(), address_space)
159175
}
160176

161177
fn element_type(&self, ty: Type<'gcc>) -> Type<'gcc> {

0 commit comments

Comments
 (0)