Skip to content

Commit 1379ef5

Browse files
compiler: Factor rustc_target::abi out of cg_llvm
1 parent 839cf1c commit 1379ef5

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

compiler/rustc_codegen_llvm/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ libc = "0.2"
1414
measureme = "11"
1515
object = { version = "0.36.3", default-features = false, features = ["std", "read"] }
1616
rustc-demangle = "0.1.21"
17+
rustc_abi = { path = "../rustc_abi" }
1718
rustc_ast = { path = "../rustc_ast" }
1819
rustc_attr = { path = "../rustc_attr" }
1920
rustc_codegen_ssa = { path = "../rustc_codegen_ssa" }

compiler/rustc_codegen_llvm/src/abi.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
use std::cmp;
22

33
use libc::c_uint;
4+
use rustc_abi as abi;
5+
use rustc_abi::Primitive::Int;
6+
use rustc_abi::{HasDataLayout, Size};
47
use rustc_codegen_ssa::MemFlags;
58
use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
69
use rustc_codegen_ssa::mir::place::{PlaceRef, PlaceValue};
@@ -11,7 +14,6 @@ pub(crate) use rustc_middle::ty::layout::{WIDE_PTR_ADDR, WIDE_PTR_EXTRA};
1114
use rustc_middle::{bug, ty};
1215
use rustc_session::config;
1316
pub(crate) use rustc_target::abi::call::*;
14-
use rustc_target::abi::{self, HasDataLayout, Int, Size};
1517
use rustc_target::spec::SanitizerSet;
1618
pub(crate) use rustc_target::spec::abi::Abi;
1719
use smallvec::SmallVec;

compiler/rustc_codegen_llvm/src/builder.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ use std::ops::Deref;
33
use std::{iter, ptr};
44

55
use libc::{c_char, c_uint};
6+
use rustc_abi as abi;
7+
use rustc_abi::{Align, Size, WrappingRange};
68
use rustc_codegen_ssa::MemFlags;
79
use rustc_codegen_ssa::common::{IntPredicate, RealPredicate, SynchronizationScope, TypeKind};
810
use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
@@ -20,7 +22,6 @@ use rustc_sanitizers::{cfi, kcfi};
2022
use rustc_session::config::OptLevel;
2123
use rustc_span::Span;
2224
use rustc_target::abi::call::FnAbi;
23-
use rustc_target::abi::{self, Align, Size, WrappingRange};
2425
use rustc_target::spec::{HasTargetSpec, SanitizerSet, Target};
2526
use smallvec::SmallVec;
2627
use tracing::{debug, instrument};
@@ -505,12 +506,12 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
505506
}
506507

507508
match scalar.primitive() {
508-
abi::Int(..) => {
509+
abi::Primitive::Int(..) => {
509510
if !scalar.is_always_valid(bx) {
510511
bx.range_metadata(load, scalar.valid_range(bx));
511512
}
512513
}
513-
abi::Pointer(_) => {
514+
abi::Primitive::Pointer(_) => {
514515
if !scalar.valid_range(bx).contains(0) {
515516
bx.nonnull_metadata(load);
516517
}
@@ -521,7 +522,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
521522
}
522523
}
523524
}
524-
abi::Float(_) => {}
525+
abi::Primitive::Float(_) => {}
525526
}
526527
}
527528

compiler/rustc_codegen_llvm/src/common.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
//! Code that is useful in various codegen modules.
22
33
use libc::{c_char, c_uint};
4+
use rustc_abi as abi;
5+
use rustc_abi::Primitive::Pointer;
6+
use rustc_abi::{AddressSpace, HasDataLayout};
47
use rustc_ast::Mutability;
58
use rustc_codegen_ssa::traits::*;
69
use rustc_data_structures::stable_hasher::{Hash128, HashStable, StableHasher};
@@ -9,7 +12,6 @@ use rustc_middle::bug;
912
use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar};
1013
use rustc_middle::ty::TyCtxt;
1114
use rustc_session::cstore::DllImport;
12-
use rustc_target::abi::{self, AddressSpace, HasDataLayout, Pointer};
1315
use tracing::debug;
1416

1517
use crate::consts::const_alloc_to_llvm;

compiler/rustc_codegen_llvm/src/type_of.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
use std::fmt::Write;
22

3+
use rustc_abi::Primitive::{Float, Int, Pointer};
4+
use rustc_abi::{Abi, Align, FieldsShape, Scalar, Size, Variants};
35
use rustc_codegen_ssa::traits::*;
46
use rustc_middle::bug;
57
use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
68
use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths};
79
use rustc_middle::ty::{self, CoroutineArgsExt, Ty, TypeVisitableExt};
8-
use rustc_target::abi::{Abi, Align, FieldsShape, Float, Int, Pointer, Scalar, Size, Variants};
910
use tracing::debug;
1011

1112
use crate::common::*;

0 commit comments

Comments
 (0)