1
Fork 0

Remove crate visibility usage in compiler

This commit is contained in:
Jacob Pratt 2022-05-20 19:51:09 -04:00
parent 536020c5f9
commit 49c82f31a8
No known key found for this signature in database
GPG key ID: B80E19E4662B5AA4
186 changed files with 865 additions and 800 deletions

View file

@ -354,14 +354,14 @@ fn fat_lto(
Ok(LtoModuleCodegen::Fat { module, _serialized_bitcode: serialized_bitcode })
}
crate struct Linker<'a>(&'a mut llvm::Linker<'a>);
pub(crate) struct Linker<'a>(&'a mut llvm::Linker<'a>);
impl<'a> Linker<'a> {
crate fn new(llmod: &'a llvm::Module) -> Self {
pub(crate) fn new(llmod: &'a llvm::Module) -> Self {
unsafe { Linker(llvm::LLVMRustLinkerNew(llmod)) }
}
crate fn add(&mut self, bytecode: &[u8]) -> Result<(), ()> {
pub(crate) fn add(&mut self, bytecode: &[u8]) -> Result<(), ()> {
unsafe {
if llvm::LLVMRustLinkerAdd(
self.0,

View file

@ -1412,7 +1412,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
unsafe { llvm::LLVMBuildVAArg(self.llbuilder, list, ty, UNNAMED) }
}
crate fn call_intrinsic(&mut self, intrinsic: &str, args: &[&'ll Value]) -> &'ll Value {
pub(crate) fn call_intrinsic(&mut self, intrinsic: &str, args: &[&'ll Value]) -> &'ll Value {
let (ty, f) = self.cx.get_intrinsic(intrinsic);
self.call(ty, f, args, None)
}

View file

@ -212,11 +212,11 @@ pub fn ptrcast<'ll>(val: &'ll Value, ty: &'ll Type) -> &'ll Value {
}
impl<'ll> CodegenCx<'ll, '_> {
crate fn const_bitcast(&self, val: &'ll Value, ty: &'ll Type) -> &'ll Value {
pub(crate) fn const_bitcast(&self, val: &'ll Value, ty: &'ll Type) -> &'ll Value {
unsafe { llvm::LLVMConstBitCast(val, ty) }
}
crate fn static_addr_of_mut(
pub(crate) fn static_addr_of_mut(
&self,
cv: &'ll Value,
align: Align,
@ -241,7 +241,7 @@ impl<'ll> CodegenCx<'ll, '_> {
}
}
crate fn get_static(&self, def_id: DefId) -> &'ll Value {
pub(crate) fn get_static(&self, def_id: DefId) -> &'ll Value {
let instance = Instance::mono(self.tcx, def_id);
if let Some(&g) = self.instances.borrow().get(&instance) {
return g;

View file

@ -330,7 +330,7 @@ pub unsafe fn create_module<'ll>(
}
impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
crate fn new(
pub(crate) fn new(
tcx: TyCtxt<'tcx>,
codegen_unit: &'tcx CodegenUnit<'tcx>,
llvm_module: &'ll crate::ModuleLlvm,
@ -447,7 +447,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
}
}
crate fn statics_to_rauw(&self) -> &RefCell<Vec<(&'ll Value, &'ll Value)>> {
pub(crate) fn statics_to_rauw(&self) -> &RefCell<Vec<(&'ll Value, &'ll Value)>> {
&self.statics_to_rauw
}
@ -599,7 +599,7 @@ impl<'ll, 'tcx> MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
}
impl<'ll> CodegenCx<'ll, '_> {
crate fn get_intrinsic(&self, key: &str) -> (&'ll Type, &'ll Value) {
pub(crate) fn get_intrinsic(&self, key: &str) -> (&'ll Type, &'ll Value) {
if let Some(v) = self.intrinsics.borrow().get(key).cloned() {
return v;
}
@ -890,7 +890,7 @@ impl<'ll> CodegenCx<'ll, '_> {
None
}
crate fn eh_catch_typeinfo(&self) -> &'ll Value {
pub(crate) fn eh_catch_typeinfo(&self) -> &'ll Value {
if let Some(eh_catch_typeinfo) = self.eh_catch_typeinfo.get() {
return eh_catch_typeinfo;
}

View file

@ -5,7 +5,6 @@
//! This API is completely unstable and subject to change.
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![feature(crate_visibility_modifier)]
#![feature(let_chains)]
#![feature(let_else)]
#![feature(extern_types)]

View file

@ -775,7 +775,7 @@ pub mod coverageinfo {
}
impl CounterMappingRegion {
crate fn code_region(
pub(crate) fn code_region(
counter: coverage_map::Counter,
file_id: u32,
start_line: u32,
@ -799,7 +799,7 @@ pub mod coverageinfo {
// This function might be used in the future; the LLVM API is still evolving, as is coverage
// support.
#[allow(dead_code)]
crate fn branch_region(
pub(crate) fn branch_region(
counter: coverage_map::Counter,
false_counter: coverage_map::Counter,
file_id: u32,
@ -824,7 +824,7 @@ pub mod coverageinfo {
// This function might be used in the future; the LLVM API is still evolving, as is coverage
// support.
#[allow(dead_code)]
crate fn expansion_region(
pub(crate) fn expansion_region(
file_id: u32,
expanded_file_id: u32,
start_line: u32,
@ -848,7 +848,7 @@ pub mod coverageinfo {
// This function might be used in the future; the LLVM API is still evolving, as is coverage
// support.
#[allow(dead_code)]
crate fn skipped_region(
pub(crate) fn skipped_region(
file_id: u32,
start_line: u32,
start_col: u32,
@ -871,7 +871,7 @@ pub mod coverageinfo {
// This function might be used in the future; the LLVM API is still evolving, as is coverage
// support.
#[allow(dead_code)]
crate fn gap_region(
pub(crate) fn gap_region(
counter: coverage_map::Counter,
file_id: u32,
start_line: u32,

View file

@ -39,33 +39,33 @@ impl fmt::Debug for Type {
}
impl<'ll> CodegenCx<'ll, '_> {
crate fn type_named_struct(&self, name: &str) -> &'ll Type {
pub(crate) fn type_named_struct(&self, name: &str) -> &'ll Type {
let name = SmallCStr::new(name);
unsafe { llvm::LLVMStructCreateNamed(self.llcx, name.as_ptr()) }
}
crate fn set_struct_body(&self, ty: &'ll Type, els: &[&'ll Type], packed: bool) {
pub(crate) fn set_struct_body(&self, ty: &'ll Type, els: &[&'ll Type], packed: bool) {
unsafe { llvm::LLVMStructSetBody(ty, els.as_ptr(), els.len() as c_uint, packed as Bool) }
}
crate fn type_void(&self) -> &'ll Type {
pub(crate) fn type_void(&self) -> &'ll Type {
unsafe { llvm::LLVMVoidTypeInContext(self.llcx) }
}
crate fn type_metadata(&self) -> &'ll Type {
pub(crate) fn type_metadata(&self) -> &'ll Type {
unsafe { llvm::LLVMRustMetadataTypeInContext(self.llcx) }
}
///x Creates an integer type with the given number of bits, e.g., i24
crate fn type_ix(&self, num_bits: u64) -> &'ll Type {
pub(crate) fn type_ix(&self, num_bits: u64) -> &'ll Type {
unsafe { llvm::LLVMIntTypeInContext(self.llcx, num_bits as c_uint) }
}
crate fn type_vector(&self, ty: &'ll Type, len: u64) -> &'ll Type {
pub(crate) fn type_vector(&self, ty: &'ll Type, len: u64) -> &'ll Type {
unsafe { llvm::LLVMVectorType(ty, len as c_uint) }
}
crate fn func_params_types(&self, ty: &'ll Type) -> Vec<&'ll Type> {
pub(crate) fn func_params_types(&self, ty: &'ll Type) -> Vec<&'ll Type> {
unsafe {
let n_args = llvm::LLVMCountParamTypes(ty) as usize;
let mut args = Vec::with_capacity(n_args);
@ -75,11 +75,11 @@ impl<'ll> CodegenCx<'ll, '_> {
}
}
crate fn type_bool(&self) -> &'ll Type {
pub(crate) fn type_bool(&self) -> &'ll Type {
self.type_i8()
}
crate fn type_int_from_ty(&self, t: ty::IntTy) -> &'ll Type {
pub(crate) fn type_int_from_ty(&self, t: ty::IntTy) -> &'ll Type {
match t {
ty::IntTy::Isize => self.type_isize(),
ty::IntTy::I8 => self.type_i8(),
@ -90,7 +90,7 @@ impl<'ll> CodegenCx<'ll, '_> {
}
}
crate fn type_uint_from_ty(&self, t: ty::UintTy) -> &'ll Type {
pub(crate) fn type_uint_from_ty(&self, t: ty::UintTy) -> &'ll Type {
match t {
ty::UintTy::Usize => self.type_isize(),
ty::UintTy::U8 => self.type_i8(),
@ -101,14 +101,14 @@ impl<'ll> CodegenCx<'ll, '_> {
}
}
crate fn type_float_from_ty(&self, t: ty::FloatTy) -> &'ll Type {
pub(crate) fn type_float_from_ty(&self, t: ty::FloatTy) -> &'ll Type {
match t {
ty::FloatTy::F32 => self.type_f32(),
ty::FloatTy::F64 => self.type_f64(),
}
}
crate fn type_pointee_for_align(&self, align: Align) -> &'ll Type {
pub(crate) fn type_pointee_for_align(&self, align: Align) -> &'ll Type {
// FIXME(eddyb) We could find a better approximation if ity.align < align.
let ity = Integer::approximate_align(self, align);
self.type_from_integer(ity)
@ -116,7 +116,7 @@ impl<'ll> CodegenCx<'ll, '_> {
/// Return a LLVM type that has at most the required alignment,
/// and exactly the required size, as a best-effort padding array.
crate fn type_padding_filler(&self, size: Size, align: Align) -> &'ll Type {
pub(crate) fn type_padding_filler(&self, size: Size, align: Align) -> &'ll Type {
let unit = Integer::approximate_align(self, align);
let size = size.bytes();
let unit_size = unit.size().bytes();
@ -124,11 +124,11 @@ impl<'ll> CodegenCx<'ll, '_> {
self.type_array(self.type_from_integer(unit), size / unit_size)
}
crate fn type_variadic_func(&self, args: &[&'ll Type], ret: &'ll Type) -> &'ll Type {
pub(crate) fn type_variadic_func(&self, args: &[&'ll Type], ret: &'ll Type) -> &'ll Type {
unsafe { llvm::LLVMFunctionType(ret, args.as_ptr(), args.len() as c_uint, True) }
}
crate fn type_array(&self, ty: &'ll Type, len: u64) -> &'ll Type {
pub(crate) fn type_array(&self, ty: &'ll Type, len: u64) -> &'ll Type {
unsafe { llvm::LLVMRustArrayType(ty, len) }
}
}