Replace target.target with target and target.ptr_width with target.pointer_width
Preparation for a subsequent change that replaces rustc_target::config::Config with its wrapped Target. On its own, this commit breaks the build. I don't like making build-breaking commits, but in this instance I believe that it makes review easier, as the "real" changes of this PR can be seen much more easily. Result of running: find compiler/ -type f -exec sed -i -e 's/target\.target\([)\.,; ]\)/target\1/g' {} \; find compiler/ -type f -exec sed -i -e 's/target\.target$/target/g' {} \; find compiler/ -type f -exec sed -i -e 's/target.ptr_width/target.pointer_width/g' {} \; ./x.py fmt
This commit is contained in:
parent
0d1aa1e034
commit
4fa5578774
50 changed files with 224 additions and 240 deletions
|
@ -16,7 +16,7 @@ pub(crate) unsafe fn codegen(
|
|||
) {
|
||||
let llcx = &*mods.llcx;
|
||||
let llmod = mods.llmod();
|
||||
let usize = match tcx.sess.target.target.pointer_width {
|
||||
let usize = match tcx.sess.target.pointer_width {
|
||||
16 => llvm::LLVMInt16TypeInContext(llcx),
|
||||
32 => llvm::LLVMInt32TypeInContext(llcx),
|
||||
64 => llvm::LLVMInt64TypeInContext(llcx),
|
||||
|
@ -57,7 +57,7 @@ pub(crate) unsafe fn codegen(
|
|||
let name = format!("__rust_{}", method.name);
|
||||
let llfn = llvm::LLVMRustGetOrInsertFunction(llmod, name.as_ptr().cast(), name.len(), ty);
|
||||
|
||||
if tcx.sess.target.target.options.default_hidden_visibility {
|
||||
if tcx.sess.target.options.default_hidden_visibility {
|
||||
llvm::LLVMRustSetVisibility(llfn, llvm::Visibility::Hidden);
|
||||
}
|
||||
if tcx.sess.must_emit_unwind_tables() {
|
||||
|
@ -98,7 +98,7 @@ pub(crate) unsafe fn codegen(
|
|||
// -> ! DIFlagNoReturn
|
||||
llvm::Attribute::NoReturn.apply_llfn(llvm::AttributePlace::Function, llfn);
|
||||
|
||||
if tcx.sess.target.target.options.default_hidden_visibility {
|
||||
if tcx.sess.target.options.default_hidden_visibility {
|
||||
llvm::LLVMRustSetVisibility(llfn, llvm::Visibility::Hidden);
|
||||
}
|
||||
if tcx.sess.must_emit_unwind_tables() {
|
||||
|
|
|
@ -60,7 +60,7 @@ impl AsmBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
|
|||
|
||||
// Default per-arch clobbers
|
||||
// Basically what clang does
|
||||
let arch_clobbers = match &self.sess().target.target.arch[..] {
|
||||
let arch_clobbers = match &self.sess().target.arch[..] {
|
||||
"x86" | "x86_64" => vec!["~{dirflag}", "~{fpsr}", "~{flags}"],
|
||||
"mips" | "mips64" => vec!["~{$1}"],
|
||||
_ => Vec::new(),
|
||||
|
|
|
@ -31,7 +31,7 @@ fn inline(cx: &CodegenCx<'ll, '_>, val: &'ll Value, inline: InlineAttr) {
|
|||
Hint => Attribute::InlineHint.apply_llfn(Function, val),
|
||||
Always => Attribute::AlwaysInline.apply_llfn(Function, val),
|
||||
Never => {
|
||||
if cx.tcx().sess.target.target.arch != "amdgpu" {
|
||||
if cx.tcx().sess.target.arch != "amdgpu" {
|
||||
Attribute::NoInline.apply_llfn(Function, val);
|
||||
}
|
||||
}
|
||||
|
@ -91,8 +91,7 @@ fn set_instrument_function(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
|
|||
// The function name varies on platforms.
|
||||
// See test/CodeGen/mcount.c in clang.
|
||||
let mcount_name =
|
||||
CString::new(cx.sess().target.target.options.target_mcount.as_str().as_bytes())
|
||||
.unwrap();
|
||||
CString::new(cx.sess().target.options.target_mcount.as_str().as_bytes()).unwrap();
|
||||
|
||||
llvm::AddFunctionAttrStringValue(
|
||||
llfn,
|
||||
|
@ -106,7 +105,7 @@ fn set_instrument_function(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
|
|||
fn set_probestack(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
|
||||
// Only use stack probes if the target specification indicates that we
|
||||
// should be using stack probes
|
||||
if !cx.sess().target.target.options.stack_probes {
|
||||
if !cx.sess().target.options.stack_probes {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -345,7 +344,7 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::
|
|||
// Note that currently the `wasm-import-module` doesn't do anything, but
|
||||
// eventually LLVM 7 should read this and ferry the appropriate import
|
||||
// module to the output file.
|
||||
if cx.tcx.sess.target.target.arch == "wasm32" {
|
||||
if cx.tcx.sess.target.arch == "wasm32" {
|
||||
if let Some(module) = wasm_import_module(cx.tcx, instance.def_id()) {
|
||||
llvm::AddFunctionAttrStringValue(
|
||||
llfn,
|
||||
|
|
|
@ -206,7 +206,7 @@ impl<'a> LlvmArchiveBuilder<'a> {
|
|||
}
|
||||
|
||||
fn llvm_archive_kind(&self) -> Result<ArchiveKind, &str> {
|
||||
let kind = &*self.config.sess.target.target.options.archive_format;
|
||||
let kind = &*self.config.sess.target.options.archive_format;
|
||||
kind.parse().map_err(|_| kind)
|
||||
}
|
||||
|
||||
|
|
|
@ -128,40 +128,40 @@ pub fn target_machine_factory(
|
|||
let (opt_level, _) = to_llvm_opt_settings(optlvl);
|
||||
let use_softfp = sess.opts.cg.soft_float;
|
||||
|
||||
let ffunction_sections = sess.target.target.options.function_sections;
|
||||
let ffunction_sections = sess.target.options.function_sections;
|
||||
let fdata_sections = ffunction_sections;
|
||||
|
||||
let code_model = to_llvm_code_model(sess.code_model());
|
||||
|
||||
let features = attributes::llvm_target_features(sess).collect::<Vec<_>>();
|
||||
let mut singlethread = sess.target.target.options.singlethread;
|
||||
let mut singlethread = sess.target.options.singlethread;
|
||||
|
||||
// On the wasm target once the `atomics` feature is enabled that means that
|
||||
// we're no longer single-threaded, or otherwise we don't want LLVM to
|
||||
// lower atomic operations to single-threaded operations.
|
||||
if singlethread
|
||||
&& sess.target.target.llvm_target.contains("wasm32")
|
||||
&& sess.target.llvm_target.contains("wasm32")
|
||||
&& sess.target_features.contains(&sym::atomics)
|
||||
{
|
||||
singlethread = false;
|
||||
}
|
||||
|
||||
let triple = SmallCStr::new(&sess.target.target.llvm_target);
|
||||
let triple = SmallCStr::new(&sess.target.llvm_target);
|
||||
let cpu = SmallCStr::new(llvm_util::target_cpu(sess));
|
||||
let features = features.join(",");
|
||||
let features = CString::new(features).unwrap();
|
||||
let abi = SmallCStr::new(&sess.target.target.options.llvm_abiname);
|
||||
let trap_unreachable = sess.target.target.options.trap_unreachable;
|
||||
let abi = SmallCStr::new(&sess.target.options.llvm_abiname);
|
||||
let trap_unreachable = sess.target.options.trap_unreachable;
|
||||
let emit_stack_size_section = sess.opts.debugging_opts.emit_stack_sizes;
|
||||
|
||||
let asm_comments = sess.asm_comments();
|
||||
let relax_elf_relocations = sess.target.target.options.relax_elf_relocations;
|
||||
let relax_elf_relocations = sess.target.options.relax_elf_relocations;
|
||||
|
||||
let use_init_array = !sess
|
||||
.opts
|
||||
.debugging_opts
|
||||
.use_ctors_section
|
||||
.unwrap_or(sess.target.target.options.use_ctors_section);
|
||||
.unwrap_or(sess.target.options.use_ctors_section);
|
||||
|
||||
Arc::new(move || {
|
||||
let tm = unsafe {
|
||||
|
|
|
@ -60,7 +60,7 @@ pub fn write_compressed_metadata<'tcx>(
|
|||
unsafe { llvm::LLVMAddGlobal(metadata_llmod, common::val_ty(llconst), buf.as_ptr()) };
|
||||
unsafe {
|
||||
llvm::LLVMSetInitializer(llglobal, llconst);
|
||||
let section_name = metadata::metadata_section_name(&tcx.sess.target.target);
|
||||
let section_name = metadata::metadata_section_name(&tcx.sess.target);
|
||||
let name = SmallCStr::new(section_name);
|
||||
llvm::LLVMSetSection(llglobal, name.as_ptr());
|
||||
|
||||
|
|
|
@ -308,8 +308,8 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
|||
use rustc_middle::ty::{Int, Uint};
|
||||
|
||||
let new_kind = match ty.kind() {
|
||||
Int(t @ Isize) => Int(t.normalize(self.tcx.sess.target.ptr_width)),
|
||||
Uint(t @ Usize) => Uint(t.normalize(self.tcx.sess.target.ptr_width)),
|
||||
Int(t @ Isize) => Int(t.normalize(self.tcx.sess.target.pointer_width)),
|
||||
Uint(t @ Usize) => Uint(t.normalize(self.tcx.sess.target.pointer_width)),
|
||||
t @ (Uint(_) | Int(_)) => t.clone(),
|
||||
_ => panic!("tried to get overflow intrinsic for op applied to non-int type"),
|
||||
};
|
||||
|
@ -541,7 +541,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
|||
}
|
||||
|
||||
fn range_metadata(&mut self, load: &'ll Value, range: Range<u128>) {
|
||||
if self.sess().target.target.arch == "amdgpu" {
|
||||
if self.sess().target.arch == "amdgpu" {
|
||||
// amdgpu/LLVM does something weird and thinks a i64 value is
|
||||
// split into a v2i32, halving the bitwidth LLVM expects,
|
||||
// tripping an assertion. So, for now, just disable this
|
||||
|
@ -671,7 +671,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
|||
// WebAssembly has saturating floating point to integer casts if the
|
||||
// `nontrapping-fptoint` target feature is activated. We'll use those if
|
||||
// they are available.
|
||||
if self.sess().target.target.arch == "wasm32"
|
||||
if self.sess().target.arch == "wasm32"
|
||||
&& self.sess().target_features.contains(&sym::nontrapping_dash_fptoint)
|
||||
{
|
||||
let src_ty = self.cx.val_ty(val);
|
||||
|
@ -696,7 +696,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
|||
// WebAssembly has saturating floating point to integer casts if the
|
||||
// `nontrapping-fptoint` target feature is activated. We'll use those if
|
||||
// they are available.
|
||||
if self.sess().target.target.arch == "wasm32"
|
||||
if self.sess().target.arch == "wasm32"
|
||||
&& self.sess().target_features.contains(&sym::nontrapping_dash_fptoint)
|
||||
{
|
||||
let src_ty = self.cx.val_ty(val);
|
||||
|
@ -1427,7 +1427,7 @@ impl Builder<'a, 'll, 'tcx> {
|
|||
}
|
||||
|
||||
fn wasm_and_missing_nontrapping_fptoint(&self) -> bool {
|
||||
self.sess().target.target.arch == "wasm32"
|
||||
self.sess().target.arch == "wasm32"
|
||||
&& !self.sess().target_features.contains(&sym::nontrapping_dash_fptoint)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -176,7 +176,7 @@ pub fn get_fn(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>) -> &'ll Value
|
|||
// should use dllimport for functions.
|
||||
if cx.use_dll_storage_attrs
|
||||
&& tcx.is_dllimport_foreign_item(instance_def_id)
|
||||
&& tcx.sess.target.target.target_env != "gnu"
|
||||
&& tcx.sess.target.target_env != "gnu"
|
||||
{
|
||||
unsafe {
|
||||
llvm::LLVMSetDLLStorageClass(llfn, llvm::DLLStorageClass::DllImport);
|
||||
|
|
|
@ -92,7 +92,7 @@ fn set_global_alignment(cx: &CodegenCx<'ll, '_>, gv: &'ll Value, mut align: Alig
|
|||
// The target may require greater alignment for globals than the type does.
|
||||
// Note: GCC and Clang also allow `__attribute__((aligned))` on variables,
|
||||
// which can force it to be smaller. Rust doesn't support this yet.
|
||||
if let Some(min) = cx.sess().target.target.options.min_global_align {
|
||||
if let Some(min) = cx.sess().target.options.min_global_align {
|
||||
match Align::from_bits(min) {
|
||||
Ok(min) => align = align.max(min),
|
||||
Err(err) => {
|
||||
|
@ -283,7 +283,7 @@ impl CodegenCx<'ll, 'tcx> {
|
|||
// argument validation.
|
||||
debug_assert!(
|
||||
!(self.tcx.sess.opts.cg.linker_plugin_lto.enabled()
|
||||
&& self.tcx.sess.target.target.options.is_like_windows
|
||||
&& self.tcx.sess.target.options.is_like_windows
|
||||
&& self.tcx.sess.opts.cg.prefer_dynamic)
|
||||
);
|
||||
|
||||
|
@ -437,7 +437,7 @@ impl StaticMethods for CodegenCx<'ll, 'tcx> {
|
|||
// will use load-unaligned instructions instead, and thus avoiding the crash.
|
||||
//
|
||||
// We could remove this hack whenever we decide to drop macOS 10.10 support.
|
||||
if self.tcx.sess.target.target.options.is_like_osx {
|
||||
if self.tcx.sess.target.options.is_like_osx {
|
||||
// The `inspect` method is okay here because we checked relocations, and
|
||||
// because we are doing this access to inspect the final interpreter state
|
||||
// (not as part of the interpreter execution).
|
||||
|
|
|
@ -118,18 +118,18 @@ pub unsafe fn create_module(
|
|||
let mod_name = SmallCStr::new(mod_name);
|
||||
let llmod = llvm::LLVMModuleCreateWithNameInContext(mod_name.as_ptr(), llcx);
|
||||
|
||||
let mut target_data_layout = sess.target.target.data_layout.clone();
|
||||
let mut target_data_layout = sess.target.data_layout.clone();
|
||||
if llvm_util::get_major_version() < 9 {
|
||||
target_data_layout = strip_function_ptr_alignment(target_data_layout);
|
||||
}
|
||||
if llvm_util::get_major_version() < 10 {
|
||||
if sess.target.target.arch == "x86" || sess.target.target.arch == "x86_64" {
|
||||
if sess.target.arch == "x86" || sess.target.arch == "x86_64" {
|
||||
target_data_layout = strip_x86_address_spaces(target_data_layout);
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure the data-layout values hardcoded remain the defaults.
|
||||
if sess.target.target.options.is_builtin {
|
||||
if sess.target.options.is_builtin {
|
||||
let tm = crate::back::write::create_informational_target_machine(tcx.sess);
|
||||
llvm::LLVMRustSetDataLayoutFromTargetMachine(llmod, tm);
|
||||
llvm::LLVMRustDisposeTargetMachine(tm);
|
||||
|
@ -160,7 +160,7 @@ pub unsafe fn create_module(
|
|||
bug!(
|
||||
"data-layout for builtin `{}` target, `{}`, \
|
||||
differs from LLVM default, `{}`",
|
||||
sess.target.target.llvm_target,
|
||||
sess.target.llvm_target,
|
||||
target_data_layout,
|
||||
llvm_data_layout
|
||||
);
|
||||
|
@ -170,7 +170,7 @@ pub unsafe fn create_module(
|
|||
let data_layout = SmallCStr::new(&target_data_layout);
|
||||
llvm::LLVMSetDataLayout(llmod, data_layout.as_ptr());
|
||||
|
||||
let llvm_target = SmallCStr::new(&sess.target.target.llvm_target);
|
||||
let llvm_target = SmallCStr::new(&sess.target.llvm_target);
|
||||
llvm::LLVMRustSetNormalizedTarget(llmod, llvm_target.as_ptr());
|
||||
|
||||
if sess.relocation_model() == RelocModel::Pic {
|
||||
|
@ -190,7 +190,7 @@ pub unsafe fn create_module(
|
|||
}
|
||||
|
||||
// Control Flow Guard is currently only supported by the MSVC linker on Windows.
|
||||
if sess.target.target.options.is_like_msvc {
|
||||
if sess.target.options.is_like_msvc {
|
||||
match sess.opts.cg.control_flow_guard {
|
||||
CFGuard::Disabled => {}
|
||||
CFGuard::NoChecks => {
|
||||
|
@ -265,7 +265,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
|
|||
// linker will take care of everything. Fixing this problem will likely
|
||||
// require adding a few attributes to Rust itself (feature gated at the
|
||||
// start) and then strongly recommending static linkage on Windows!
|
||||
let use_dll_storage_attrs = tcx.sess.target.target.options.is_like_windows;
|
||||
let use_dll_storage_attrs = tcx.sess.target.options.is_like_windows;
|
||||
|
||||
let check_overflow = tcx.sess.overflow_checks();
|
||||
|
||||
|
@ -839,7 +839,7 @@ impl CodegenCx<'b, 'tcx> {
|
|||
return eh_catch_typeinfo;
|
||||
}
|
||||
let tcx = self.tcx;
|
||||
assert!(self.sess().target.target.options.is_like_emscripten);
|
||||
assert!(self.sess().target.options.is_like_emscripten);
|
||||
let eh_catch_typeinfo = match tcx.lang_items().eh_catch_typeinfo() {
|
||||
Some(def_id) => self.get_static(def_id),
|
||||
_ => {
|
||||
|
@ -878,7 +878,7 @@ impl HasDataLayout for CodegenCx<'ll, 'tcx> {
|
|||
|
||||
impl HasTargetSpec for CodegenCx<'ll, 'tcx> {
|
||||
fn target_spec(&self) -> &Target {
|
||||
&self.tcx.sess.target.target
|
||||
&self.tcx.sess.target
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,5 +67,5 @@ pub fn needs_gdb_debug_scripts_section(cx: &CodegenCx<'_, '_>) -> bool {
|
|||
|
||||
!omit_gdb_pretty_printer_section
|
||||
&& cx.sess().opts.debuginfo != DebugInfo::None
|
||||
&& cx.sess().target.target.options.emit_debug_gdb_scripts
|
||||
&& cx.sess().target.options.emit_debug_gdb_scripts
|
||||
}
|
||||
|
|
|
@ -874,7 +874,7 @@ fn basic_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType {
|
|||
|
||||
// When targeting MSVC, emit MSVC style type names for compatibility with
|
||||
// .natvis visualizers (and perhaps other existing native debuggers?)
|
||||
let msvc_like_names = cx.tcx.sess.target.target.options.is_like_msvc;
|
||||
let msvc_like_names = cx.tcx.sess.target.options.is_like_msvc;
|
||||
|
||||
let (name, encoding) = match t.kind() {
|
||||
ty::Never => ("!", DW_ATE_unsigned),
|
||||
|
@ -985,7 +985,7 @@ pub fn compile_unit_metadata(
|
|||
// if multiple object files with the same `DW_AT_name` are linked together.
|
||||
// As a workaround we generate unique names for each object file. Those do
|
||||
// not correspond to an actual source file but that should be harmless.
|
||||
if tcx.sess.target.target.options.is_like_osx {
|
||||
if tcx.sess.target.options.is_like_osx {
|
||||
name_in_debuginfo.push("@");
|
||||
name_in_debuginfo.push(codegen_unit_name);
|
||||
}
|
||||
|
@ -1401,7 +1401,7 @@ fn prepare_union_metadata(
|
|||
/// on MSVC we have to use the fallback mode, because LLVM doesn't
|
||||
/// lower variant parts to PDB.
|
||||
fn use_enum_fallback(cx: &CodegenCx<'_, '_>) -> bool {
|
||||
cx.sess().target.target.options.is_like_msvc
|
||||
cx.sess().target.options.is_like_msvc
|
||||
}
|
||||
|
||||
// FIXME(eddyb) maybe precompute this? Right now it's computed once
|
||||
|
|
|
@ -120,12 +120,12 @@ pub fn finalize(cx: &CodegenCx<'_, '_>) {
|
|||
// for macOS to understand. For more info see #11352
|
||||
// This can be overridden using --llvm-opts -dwarf-version,N.
|
||||
// Android has the same issue (#22398)
|
||||
if let Some(version) = cx.sess().target.target.options.dwarf_version {
|
||||
if let Some(version) = cx.sess().target.options.dwarf_version {
|
||||
llvm::LLVMRustAddModuleFlag(cx.llmod, "Dwarf Version\0".as_ptr().cast(), version)
|
||||
}
|
||||
|
||||
// Indicate that we want CodeView debug information on MSVC
|
||||
if cx.sess().target.target.options.is_like_msvc {
|
||||
if cx.sess().target.options.is_like_msvc {
|
||||
llvm::LLVMRustAddModuleFlag(cx.llmod, "CodeView\0".as_ptr().cast(), 1)
|
||||
}
|
||||
|
||||
|
@ -346,7 +346,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||
});
|
||||
|
||||
// Arguments types
|
||||
if cx.sess().target.target.options.is_like_msvc {
|
||||
if cx.sess().target.options.is_like_msvc {
|
||||
// FIXME(#42800):
|
||||
// There is a bug in MSDIA that leads to a crash when it encounters
|
||||
// a fixed-size array of `u8` or something zero-sized in a
|
||||
|
|
|
@ -38,7 +38,7 @@ impl CodegenCx<'ll, '_> {
|
|||
// For MSVC, omit the column number.
|
||||
// Otherwise, emit it. This mimics clang behaviour.
|
||||
// See discussion in https://github.com/rust-lang/rust/issues/42921
|
||||
if self.sess().target.target.options.is_like_msvc {
|
||||
if self.sess().target.options.is_like_msvc {
|
||||
DebugLoc { file, line, col: None }
|
||||
} else {
|
||||
DebugLoc { file, line, col }
|
||||
|
|
|
@ -42,7 +42,7 @@ fn declare_raw_fn(
|
|||
// be merged.
|
||||
llvm::SetUnnamedAddress(llfn, llvm::UnnamedAddr::Global);
|
||||
|
||||
if cx.tcx.sess.opts.cg.no_redzone.unwrap_or(cx.tcx.sess.target.target.options.disable_redzone) {
|
||||
if cx.tcx.sess.opts.cg.no_redzone.unwrap_or(cx.tcx.sess.target.options.disable_redzone) {
|
||||
llvm::Attribute::NoRedZone.apply_llfn(Function, llfn);
|
||||
}
|
||||
|
||||
|
|
|
@ -367,7 +367,7 @@ fn try_intrinsic(
|
|||
bx.store(bx.const_i32(0), dest, ret_align);
|
||||
} else if wants_msvc_seh(bx.sess()) {
|
||||
codegen_msvc_try(bx, try_func, data, catch_func, dest);
|
||||
} else if bx.sess().target.target.options.is_like_emscripten {
|
||||
} else if bx.sess().target.options.is_like_emscripten {
|
||||
codegen_emcc_try(bx, try_func, data, catch_func, dest);
|
||||
} else {
|
||||
codegen_gnu_try(bx, try_func, data, catch_func, dest);
|
||||
|
@ -1722,10 +1722,10 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#,
|
|||
fn int_type_width_signed(ty: Ty<'_>, cx: &CodegenCx<'_, '_>) -> Option<(u64, bool)> {
|
||||
match ty.kind() {
|
||||
ty::Int(t) => {
|
||||
Some((t.bit_width().unwrap_or(u64::from(cx.tcx.sess.target.ptr_width)), true))
|
||||
Some((t.bit_width().unwrap_or(u64::from(cx.tcx.sess.target.pointer_width)), true))
|
||||
}
|
||||
ty::Uint(t) => {
|
||||
Some((t.bit_width().unwrap_or(u64::from(cx.tcx.sess.target.ptr_width)), false))
|
||||
Some((t.bit_width().unwrap_or(u64::from(cx.tcx.sess.target.pointer_width)), false))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ fn require_inited() {
|
|||
}
|
||||
|
||||
unsafe fn configure_llvm(sess: &Session) {
|
||||
let n_args = sess.opts.cg.llvm_args.len() + sess.target.target.options.llvm_args.len();
|
||||
let n_args = sess.opts.cg.llvm_args.len() + sess.target.options.llvm_args.len();
|
||||
let mut llvm_c_strs = Vec::with_capacity(n_args + 1);
|
||||
let mut llvm_args = Vec::with_capacity(n_args + 1);
|
||||
|
||||
|
@ -57,7 +57,7 @@ unsafe fn configure_llvm(sess: &Session) {
|
|||
}
|
||||
|
||||
let cg_opts = sess.opts.cg.llvm_args.iter();
|
||||
let tg_opts = sess.target.target.options.llvm_args.iter();
|
||||
let tg_opts = sess.target.options.llvm_args.iter();
|
||||
let sess_args = cg_opts.chain(tg_opts);
|
||||
|
||||
let user_specified_args: FxHashSet<_> =
|
||||
|
@ -88,7 +88,7 @@ unsafe fn configure_llvm(sess: &Session) {
|
|||
.opts
|
||||
.debugging_opts
|
||||
.merge_functions
|
||||
.unwrap_or(sess.target.target.options.merge_functions)
|
||||
.unwrap_or(sess.target.options.merge_functions)
|
||||
{
|
||||
MergeFunctions::Disabled | MergeFunctions::Trampolines => {}
|
||||
MergeFunctions::Aliases => {
|
||||
|
@ -96,9 +96,7 @@ unsafe fn configure_llvm(sess: &Session) {
|
|||
}
|
||||
}
|
||||
|
||||
if sess.target.target.target_os == "emscripten"
|
||||
&& sess.panic_strategy() == PanicStrategy::Unwind
|
||||
{
|
||||
if sess.target.target_os == "emscripten" && sess.panic_strategy() == PanicStrategy::Unwind {
|
||||
add("-enable-emscripten-cxx-exceptions", false);
|
||||
}
|
||||
|
||||
|
@ -140,7 +138,7 @@ pub fn time_trace_profiler_finish(file_name: &str) {
|
|||
// to LLVM or the feature detection code will walk past the end of the feature
|
||||
// array, leading to crashes.
|
||||
pub fn to_llvm_feature<'a>(sess: &Session, s: &'a str) -> &'a str {
|
||||
let arch = if sess.target.target.arch == "x86_64" { "x86" } else { &*sess.target.target.arch };
|
||||
let arch = if sess.target.arch == "x86_64" { "x86" } else { &*sess.target.arch };
|
||||
match (arch, s) {
|
||||
("x86", "pclmulqdq") => "pclmul",
|
||||
("x86", "rdrand") => "rdrnd",
|
||||
|
@ -217,7 +215,7 @@ fn handle_native(name: &str) -> &str {
|
|||
pub fn target_cpu(sess: &Session) -> &str {
|
||||
let name = match sess.opts.cg.target_cpu {
|
||||
Some(ref s) => &**s,
|
||||
None => &*sess.target.target.options.cpu,
|
||||
None => &*sess.target.options.cpu,
|
||||
};
|
||||
|
||||
handle_native(name)
|
||||
|
|
|
@ -52,7 +52,7 @@ fn emit_direct_ptr_va_arg(
|
|||
let next = bx.inbounds_gep(addr, &[full_direct_size]);
|
||||
bx.store(next, va_list_addr, bx.tcx().data_layout.pointer_align.abi);
|
||||
|
||||
if size.bytes() < slot_size.bytes() && &*bx.tcx().sess.target.target.target_endian == "big" {
|
||||
if size.bytes() < slot_size.bytes() && &*bx.tcx().sess.target.target_endian == "big" {
|
||||
let adjusted_size = bx.cx().const_i32((slot_size.bytes() - size.bytes()) as i32);
|
||||
let adjusted = bx.inbounds_gep(addr, &[adjusted_size]);
|
||||
(bx.bitcast(adjusted, bx.cx().type_ptr_to(llty)), addr_align)
|
||||
|
@ -105,7 +105,7 @@ fn emit_aapcs_va_arg(
|
|||
let mut end = bx.build_sibling_block("va_arg.end");
|
||||
let zero = bx.const_i32(0);
|
||||
let offset_align = Align::from_bytes(4).unwrap();
|
||||
assert!(&*bx.tcx().sess.target.target.target_endian == "little");
|
||||
assert!(&*bx.tcx().sess.target.target_endian == "little");
|
||||
|
||||
let gr_type = target_ty.is_any_ptr() || target_ty.is_integral();
|
||||
let (reg_off, reg_top_index, slot_size) = if gr_type {
|
||||
|
@ -171,8 +171,8 @@ pub(super) fn emit_va_arg(
|
|||
) -> &'ll Value {
|
||||
// Determine the va_arg implementation to use. The LLVM va_arg instruction
|
||||
// is lacking in some instances, so we should only use it as a fallback.
|
||||
let target = &bx.cx.tcx.sess.target.target;
|
||||
let arch = &bx.cx.tcx.sess.target.target.arch;
|
||||
let target = &bx.cx.tcx.sess.target;
|
||||
let arch = &bx.cx.tcx.sess.target.arch;
|
||||
match (&**arch, target.options.is_like_windows) {
|
||||
// Windows x86
|
||||
("x86", true) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue