Skip to content

Commit 5d2b7ba

Browse files
cg_gcc: adapt for removal of pointee types from cg_ssa
i expected to need to add casts to load/store/memcpy/memmove/memset/etc. but they already pointercast their arguments, so with the (relatively minimal) number of pointer types created in cg_ssa, this should work?
1 parent 837eff9 commit 5d2b7ba

File tree

4 files changed

+21
-13
lines changed

4 files changed

+21
-13
lines changed

compiler/rustc_codegen_gcc/src/builder.rs

Lines changed: 0 additions & 1 deletion
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,

compiler/rustc_codegen_gcc/src/common.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use rustc_codegen_ssa::mir::place::PlaceRef;
44
use rustc_codegen_ssa::traits::{
55
BaseTypeMethods,
66
ConstMethods,
7-
DerivedTypeMethods,
87
MiscMethods,
98
StaticMethods,
109
};
@@ -132,7 +131,9 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
132131
.or_insert_with(|| (s.to_owned(), self.global_string(s)))
133132
.1;
134133
let len = s.len();
135-
let cs = self.const_ptrcast(str_global.get_address(None),
134+
let cs = self.context.new_cast(
135+
None,
136+
str_global.get_address(None),
136137
self.type_ptr_to(self.layout_of(self.tcx.types.str_).gcc_type(self, true)),
137138
);
138139
(cs, self.const_usize(len as u64))
@@ -243,10 +244,6 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
243244
};
244245
PlaceRef::new_sized(value, layout)
245246
}
246-
247-
fn const_ptrcast(&self, val: RValue<'gcc>, ty: Type<'gcc>) -> RValue<'gcc> {
248-
self.context.new_cast(None, val, ty)
249-
}
250247
}
251248

252249
pub trait SignType<'gcc, 'tcx> {

compiler/rustc_codegen_gcc/src/intrinsic/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_codegen_ssa::base::wants_msvc_seh;
77
use rustc_codegen_ssa::common::IntPredicate;
88
use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
99
use rustc_codegen_ssa::mir::place::PlaceRef;
10-
use rustc_codegen_ssa::traits::{ArgAbiMethods, BaseTypeMethods, BuilderMethods, ConstMethods, IntrinsicCallMethods};
10+
use rustc_codegen_ssa::traits::{ArgAbiMethods, BuilderMethods, ConstMethods, IntrinsicCallMethods};
1111
use rustc_middle::bug;
1212
use rustc_middle::ty::{self, Instance, Ty};
1313
use rustc_middle::ty::layout::LayoutOf;

compiler/rustc_codegen_gcc/src/type_.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,19 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
5656
self.u128_type
5757
}
5858

59+
pub fn type_i8p(&self) -> Type<'gcc> {
60+
self.type_ptr_to(self.type_i8())
61+
}
62+
63+
pub fn type_ptr_to(&self, ty: Type<'gcc>) -> Type<'gcc> {
64+
ty.make_pointer()
65+
}
66+
67+
pub fn type_ptr_to_ext(&self, ty: Type<'gcc>, _address_space: AddressSpace) -> Type<'gcc> {
68+
// TODO(antoyo): use address_space, perhaps with TYPE_ADDR_SPACE?
69+
ty.make_pointer()
70+
}
71+
5972
pub fn type_pointee_for_align(&self, align: Align) -> Type<'gcc> {
6073
// FIXME(eddyb) We could find a better approximation if ity.align < align.
6174
let ity = Integer::approximate_align(self, align);
@@ -151,13 +164,12 @@ impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
151164
}
152165
}
153166

154-
fn type_ptr_to(&self, ty: Type<'gcc>) -> Type<'gcc> {
155-
ty.make_pointer()
167+
fn type_ptr(&self) -> Type<'gcc> {
168+
self.type_ptr_to(self.type_i8())
156169
}
157170

158-
fn type_ptr_to_ext(&self, ty: Type<'gcc>, _address_space: AddressSpace) -> Type<'gcc> {
159-
// TODO(antoyo): use address_space, perhaps with TYPE_ADDR_SPACE?
160-
ty.make_pointer()
171+
fn type_ptr_in(&self, address_space: AddressSpace) -> Type<'gcc> {
172+
self.type_ptr_to_ext(self.type_i8(), address_space)
161173
}
162174

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

0 commit comments

Comments
 (0)