Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions compiler/rustc_codegen_gcc/src/type_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,21 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
pub fn is_two_register_pair_type(&self, typ: Type<'gcc>) -> bool {
self.two_register_pair_type_set.borrow().contains(&typ)
}

#[cfg_attr(feature = "master", expect(unused_mut))]
pub fn type_array(&self, ty: Type<'gcc>, mut len: u64) -> Type<'gcc> {
#[cfg(not(feature = "master"))]
if let Some(struct_type) = ty.is_struct()
&& struct_type.get_field_count() == 0
{
// NOTE: since gccjit only supports i32 for the array size and libcore's tests uses a
// size of usize::MAX in test_binary_search, we workaround this by setting the size to
// zero for ZSTs.
len = 0;
}

new_array_type(self.context, None, ty, len)
}
}

/// An attribute that can be set on a GCC struct type.
Expand Down Expand Up @@ -411,21 +426,6 @@ impl<'gcc, 'tcx> BaseTypeCodegenMethods for CodegenCx<'gcc, 'tcx> {
fn val_ty(&self, value: RValue<'gcc>) -> Type<'gcc> {
value.get_type()
}

#[cfg_attr(feature = "master", expect(unused_mut))]
fn type_array(&self, ty: Type<'gcc>, mut len: u64) -> Type<'gcc> {
#[cfg(not(feature = "master"))]
if let Some(struct_type) = ty.is_struct()
&& struct_type.get_field_count() == 0
{
// NOTE: since gccjit only supports i32 for the array size and libcore's tests uses a
// size of usize::MAX in test_binary_search, we workaround this by setting the size to
// zero for ZSTs.
len = 0;
}

new_array_type(self.context, None, ty, len)
}
}

impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_codegen_llvm/src/type_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ impl<'ll, CX: Borrow<SCx<'ll>>> GenericCx<'ll, CX> {
pub(crate) fn type_bf16(&self) -> &'ll Type {
unsafe { llvm::LLVMBFloatTypeInContext(self.llcx()) }
}

pub(crate) fn type_array(&self, ty: &'ll Type, len: u64) -> &'ll Type {
unsafe { llvm::LLVMArrayType2(ty, len) }
}
}

impl<'ll, CX: Borrow<SCx<'ll>>> BaseTypeCodegenMethods for GenericCx<'ll, CX> {
Expand Down Expand Up @@ -280,10 +284,6 @@ impl<'ll, CX: Borrow<SCx<'ll>>> BaseTypeCodegenMethods for GenericCx<'ll, CX> {
fn val_ty(&self, v: &'ll Value) -> &'ll Type {
common::val_ty(v)
}

fn type_array(&self, ty: &'ll Type, len: u64) -> &'ll Type {
unsafe { llvm::LLVMArrayType2(ty, len) }
}
}

pub(crate) fn llvm_type_ptr(llcx: &llvm::Context) -> &Type {
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_codegen_ssa/src/traits/type_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ pub trait BaseTypeCodegenMethods: BackendTypes {
fn type_f128(&self) -> Self::Type;
fn type_ppcf128(&self) -> Self::Type;

fn type_array(&self, ty: Self::Type, len: u64) -> Self::Type;
fn type_func(&self, args: &[Self::Type], ret: Self::Type) -> Self::FunctionSignature;
fn type_kind(&self, ty: Self::Type) -> TypeKind;
fn type_ptr(&self) -> Self::Type;
Expand Down
Loading