cg_ssa: remove pointee types and pointercast/bitcast-of-ptr

This commit is contained in:
Erik Desjardins 2023-07-28 20:24:33 -04:00
parent b6540777fe
commit 04303cfb3a
16 changed files with 75 additions and 201 deletions

View file

@ -1,6 +1,6 @@
//! Code that is useful in various codegen modules.
use crate::consts::{self, const_alloc_to_llvm};
use crate::consts::const_alloc_to_llvm;
pub use crate::context::CodegenCx;
use crate::llvm::{self, BasicBlock, Bool, ConstantInt, False, OperandBundleDef, True};
use crate::type_::Type;
@ -304,10 +304,6 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
const_alloc_to_llvm(self, alloc)
}
fn const_ptrcast(&self, val: &'ll Value, ty: &'ll Type) -> &'ll Value {
consts::ptrcast(val, ty)
}
fn const_bitcast(&self, val: &'ll Value, ty: &'ll Type) -> &'ll Value {
self.const_bitcast(val, ty)
}

View file

@ -193,10 +193,6 @@ fn check_and_apply_linkage<'ll, 'tcx>(
}
}
pub fn ptrcast<'ll>(val: &'ll Value, ty: &'ll Type) -> &'ll Value {
unsafe { llvm::LLVMConstPointerCast(val, ty) }
}
impl<'ll> CodegenCx<'ll, '_> {
pub(crate) fn const_bitcast(&self, val: &'ll Value, ty: &'ll Type) -> &'ll Value {
unsafe { llvm::LLVMConstBitCast(val, ty) }

View file

@ -69,14 +69,6 @@ impl<'ll> CodegenCx<'ll, '_> {
unsafe { llvm::LLVMVectorType(ty, len as c_uint) }
}
pub(crate) fn type_ptr(&self) -> &'ll Type {
self.type_ptr_ext(AddressSpace::DATA)
}
pub(crate) fn type_ptr_ext(&self, address_space: AddressSpace) -> &'ll Type {
unsafe { llvm::LLVMPointerTypeInContext(self.llcx, address_space.0) }
}
pub(crate) fn func_params_types(&self, ty: &'ll Type) -> Vec<&'ll Type> {
unsafe {
let n_args = llvm::LLVMCountParamTypes(ty) as usize;
@ -191,12 +183,12 @@ impl<'ll, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'ll, 'tcx> {
unsafe { llvm::LLVMRustGetTypeKind(ty).to_generic() }
}
fn type_ptr_to(&self, _ty: &'ll Type) -> &'ll Type {
self.type_ptr()
fn type_ptr(&self) -> &'ll Type {
self.type_ptr_ext(AddressSpace::DATA)
}
fn type_ptr_to_ext(&self, _ty: &'ll Type, address_space: AddressSpace) -> &'ll Type {
self.type_ptr_ext(address_space)
fn type_ptr_ext(&self, address_space: AddressSpace) -> &'ll Type {
unsafe { llvm::LLVMPointerTypeInContext(self.llcx, address_space.0) }
}
fn element_type(&self, ty: &'ll Type) -> &'ll Type {