Skip to content

Commit 3831b60

Browse files
committed
Remove inherent methods from llvm::Type
1 parent 0661a3d commit 3831b60

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

compiler/rustc_codegen_llvm/src/back/write.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use crate::errors::{
4444
};
4545
use crate::llvm::diagnostic::OptimizationDiagnosticKind::*;
4646
use crate::llvm::{self, DiagnosticInfo};
47-
use crate::type_::Type;
47+
use crate::type_::llvm_type_ptr;
4848
use crate::{LlvmCodegenBackend, ModuleLlvm, base, common, llvm_util};
4949

5050
pub(crate) fn llvm_err<'a>(dcx: DiagCtxtHandle<'_>, err: LlvmError<'a>) -> ! {
@@ -1160,7 +1160,7 @@ fn create_msvc_imps(
11601160
// underscores added in front).
11611161
let prefix = if cgcx.target_arch == "x86" { "\x01__imp__" } else { "\x01__imp_" };
11621162

1163-
let ptr_ty = Type::ptr_llcx(llcx);
1163+
let ptr_ty = llvm_type_ptr(llcx);
11641164
let globals = base::iter_globals(llmod)
11651165
.filter(|&val| {
11661166
llvm::get_linkage(val) == llvm::Linkage::ExternalLinkage && !llvm::is_declaration(val)

compiler/rustc_codegen_llvm/src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ impl<'ll> SimpleCx<'ll> {
740740
llcx: &'ll llvm::Context,
741741
pointer_size: Size,
742742
) -> Self {
743-
let isize_ty = llvm::Type::ix_llcx(llcx, pointer_size.bits());
743+
let isize_ty = llvm::LLVMIntTypeInContext(llcx, pointer_size.bits() as c_uint);
744744
Self(SCx { llmod, llcx, isize_ty }, PhantomData)
745745
}
746746
}

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ unsafe extern "C" {
954954
pub(crate) fn LLVMInt16TypeInContext(C: &Context) -> &Type;
955955
pub(crate) fn LLVMInt32TypeInContext(C: &Context) -> &Type;
956956
pub(crate) fn LLVMInt64TypeInContext(C: &Context) -> &Type;
957-
pub(crate) fn LLVMIntTypeInContext(C: &Context, NumBits: c_uint) -> &Type;
957+
pub(crate) safe fn LLVMIntTypeInContext(C: &Context, NumBits: c_uint) -> &Type;
958958

959959
pub(crate) fn LLVMGetIntTypeWidth(IntegerTy: &Type) -> c_uint;
960960

@@ -983,7 +983,7 @@ unsafe extern "C" {
983983
) -> &'a Type;
984984

985985
// Operations on array, pointer, and vector types (sequence types)
986-
pub(crate) fn LLVMPointerTypeInContext(C: &Context, AddressSpace: c_uint) -> &Type;
986+
pub(crate) safe fn LLVMPointerTypeInContext(C: &Context, AddressSpace: c_uint) -> &Type;
987987
pub(crate) fn LLVMVectorType(ElementType: &Type, ElementCount: c_uint) -> &Type;
988988

989989
pub(crate) fn LLVMGetElementType(Ty: &Type) -> &Type;

compiler/rustc_codegen_llvm/src/type_.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl<'ll, CX: Borrow<SCx<'ll>>> GenericCx<'ll, CX> {
6363

6464
///x Creates an integer type with the given number of bits, e.g., i24
6565
pub(crate) fn type_ix(&self, num_bits: u64) -> &'ll Type {
66-
unsafe { llvm::LLVMIntTypeInContext(self.llcx(), num_bits as c_uint) }
66+
llvm::LLVMIntTypeInContext(self.llcx(), num_bits as c_uint)
6767
}
6868

6969
pub(crate) fn type_vector(&self, ty: &'ll Type, len: u64) -> &'ll Type {
@@ -178,7 +178,7 @@ impl<'ll, CX: Borrow<SCx<'ll>>> BaseTypeCodegenMethods for GenericCx<'ll, CX> {
178178
}
179179

180180
fn type_i128(&self) -> &'ll Type {
181-
unsafe { llvm::LLVMIntTypeInContext(self.llcx(), 128) }
181+
self.type_ix(128)
182182
}
183183

184184
fn type_isize(&self) -> &'ll Type {
@@ -210,11 +210,11 @@ impl<'ll, CX: Borrow<SCx<'ll>>> BaseTypeCodegenMethods for GenericCx<'ll, CX> {
210210
}
211211

212212
fn type_ptr(&self) -> &'ll Type {
213-
self.type_ptr_ext(AddressSpace::ZERO)
213+
llvm_type_ptr(self.llcx())
214214
}
215215

216216
fn type_ptr_ext(&self, address_space: AddressSpace) -> &'ll Type {
217-
unsafe { llvm::LLVMPointerTypeInContext(self.llcx(), address_space.0) }
217+
llvm_type_ptr_in_address_space(self.llcx(), address_space)
218218
}
219219

220220
fn element_type(&self, ty: &'ll Type) -> &'ll Type {
@@ -253,15 +253,15 @@ impl<'ll, CX: Borrow<SCx<'ll>>> BaseTypeCodegenMethods for GenericCx<'ll, CX> {
253253
}
254254
}
255255

256-
impl Type {
257-
/// Creates an integer type with the given number of bits, e.g., i24
258-
pub(crate) fn ix_llcx(llcx: &llvm::Context, num_bits: u64) -> &Type {
259-
unsafe { llvm::LLVMIntTypeInContext(llcx, num_bits as c_uint) }
260-
}
256+
pub(crate) fn llvm_type_ptr(llcx: &llvm::Context) -> &Type {
257+
llvm_type_ptr_in_address_space(llcx, AddressSpace::ZERO)
258+
}
261259

262-
pub(crate) fn ptr_llcx(llcx: &llvm::Context) -> &Type {
263-
unsafe { llvm::LLVMPointerTypeInContext(llcx, AddressSpace::ZERO.0) }
264-
}
260+
pub(crate) fn llvm_type_ptr_in_address_space<'ll>(
261+
llcx: &'ll llvm::Context,
262+
addr_space: AddressSpace,
263+
) -> &'ll Type {
264+
llvm::LLVMPointerTypeInContext(llcx, addr_space.0)
265265
}
266266

267267
impl<'ll, 'tcx> LayoutTypeCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {

0 commit comments

Comments
 (0)