mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 11:48:30 +00:00
miri: rustc_abi::Abi
=> BackendRepr
This commit is contained in:
parent
0349209901
commit
3059ed8fa6
@ -9,11 +9,11 @@ use std::cell::RefCell;
|
|||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
use std::{cmp, mem};
|
use std::{cmp, mem};
|
||||||
|
|
||||||
|
use rustc_abi::{BackendRepr, Size};
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_middle::mir::{Mutability, RetagKind};
|
use rustc_middle::mir::{Mutability, RetagKind};
|
||||||
use rustc_middle::ty::layout::HasParamEnv;
|
use rustc_middle::ty::layout::HasParamEnv;
|
||||||
use rustc_middle::ty::{self, Ty};
|
use rustc_middle::ty::{self, Ty};
|
||||||
use rustc_target::abi::{Abi, Size};
|
|
||||||
|
|
||||||
use self::diagnostics::{RetagCause, RetagInfo};
|
use self::diagnostics::{RetagCause, RetagInfo};
|
||||||
pub use self::item::{Item, Permission};
|
pub use self::item::{Item, Permission};
|
||||||
@ -972,7 +972,10 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||||||
RetagFields::OnlyScalar => {
|
RetagFields::OnlyScalar => {
|
||||||
// Matching `ArgAbi::new` at the time of writing, only fields of
|
// Matching `ArgAbi::new` at the time of writing, only fields of
|
||||||
// `Scalar` and `ScalarPair` ABI are considered.
|
// `Scalar` and `ScalarPair` ABI are considered.
|
||||||
matches!(place.layout.abi, Abi::Scalar(..) | Abi::ScalarPair(..))
|
matches!(
|
||||||
|
place.layout.backend_repr,
|
||||||
|
BackendRepr::Scalar(..) | BackendRepr::ScalarPair(..)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if recurse {
|
if recurse {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
|
use rustc_abi::{BackendRepr, Size};
|
||||||
use rustc_middle::mir::{Mutability, RetagKind};
|
use rustc_middle::mir::{Mutability, RetagKind};
|
||||||
use rustc_middle::ty::layout::HasParamEnv;
|
use rustc_middle::ty::layout::HasParamEnv;
|
||||||
use rustc_middle::ty::{self, Ty};
|
use rustc_middle::ty::{self, Ty};
|
||||||
use rustc_span::def_id::DefId;
|
use rustc_span::def_id::DefId;
|
||||||
use rustc_target::abi::{Abi, Size};
|
|
||||||
|
|
||||||
use crate::borrow_tracker::{GlobalState, GlobalStateInner, ProtectorKind};
|
use crate::borrow_tracker::{GlobalState, GlobalStateInner, ProtectorKind};
|
||||||
use crate::concurrency::data_race::NaReadType;
|
use crate::concurrency::data_race::NaReadType;
|
||||||
@ -495,7 +495,10 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||||||
RetagFields::OnlyScalar => {
|
RetagFields::OnlyScalar => {
|
||||||
// Matching `ArgAbi::new` at the time of writing, only fields of
|
// Matching `ArgAbi::new` at the time of writing, only fields of
|
||||||
// `Scalar` and `ScalarPair` ABI are considered.
|
// `Scalar` and `ScalarPair` ABI are considered.
|
||||||
matches!(place.layout.abi, Abi::Scalar(..) | Abi::ScalarPair(..))
|
matches!(
|
||||||
|
place.layout.backend_repr,
|
||||||
|
BackendRepr::Scalar(..) | BackendRepr::ScalarPair(..)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if recurse {
|
if recurse {
|
||||||
|
@ -349,8 +349,12 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||||||
i: impl Into<i128>,
|
i: impl Into<i128>,
|
||||||
dest: &impl Writeable<'tcx, Provenance>,
|
dest: &impl Writeable<'tcx, Provenance>,
|
||||||
) -> InterpResult<'tcx> {
|
) -> InterpResult<'tcx> {
|
||||||
assert!(dest.layout().abi.is_scalar(), "write_int on non-scalar type {}", dest.layout().ty);
|
assert!(
|
||||||
let val = if dest.layout().abi.is_signed() {
|
dest.layout().backend_repr.is_scalar(),
|
||||||
|
"write_int on non-scalar type {}",
|
||||||
|
dest.layout().ty
|
||||||
|
);
|
||||||
|
let val = if dest.layout().backend_repr.is_signed() {
|
||||||
Scalar::from_int(i, dest.layout().size)
|
Scalar::from_int(i, dest.layout().size)
|
||||||
} else {
|
} else {
|
||||||
// `unwrap` can only fail here if `i` is negative
|
// `unwrap` can only fail here if `i` is negative
|
||||||
|
@ -55,6 +55,7 @@ extern crate either;
|
|||||||
extern crate tracing;
|
extern crate tracing;
|
||||||
|
|
||||||
// The rustc crates we need
|
// The rustc crates we need
|
||||||
|
extern crate rustc_abi;
|
||||||
extern crate rustc_apfloat;
|
extern crate rustc_apfloat;
|
||||||
extern crate rustc_ast;
|
extern crate rustc_ast;
|
||||||
extern crate rustc_attr;
|
extern crate rustc_attr;
|
||||||
|
@ -23,7 +23,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||||||
|
|
||||||
interp_ok(match bin_op {
|
interp_ok(match bin_op {
|
||||||
Eq | Ne | Lt | Le | Gt | Ge => {
|
Eq | Ne | Lt | Le | Gt | Ge => {
|
||||||
assert_eq!(left.layout.abi, right.layout.abi); // types can differ, e.g. fn ptrs with different `for`
|
assert_eq!(left.layout.backend_repr, right.layout.backend_repr); // types can differ, e.g. fn ptrs with different `for`
|
||||||
let size = this.pointer_size();
|
let size = this.pointer_size();
|
||||||
// Just compare the bits. ScalarPairs are compared lexicographically.
|
// Just compare the bits. ScalarPairs are compared lexicographically.
|
||||||
// We thus always compare pairs and simply fill scalars up with 0.
|
// We thus always compare pairs and simply fill scalars up with 0.
|
||||||
|
@ -5,7 +5,7 @@ use libffi::high::call as ffi;
|
|||||||
use libffi::low::CodePtr;
|
use libffi::low::CodePtr;
|
||||||
use rustc_middle::ty::{self as ty, IntTy, UintTy};
|
use rustc_middle::ty::{self as ty, IntTy, UintTy};
|
||||||
use rustc_span::Symbol;
|
use rustc_span::Symbol;
|
||||||
use rustc_target::abi::{Abi, HasDataLayout};
|
use rustc_abi::{BackendRepr, HasDataLayout};
|
||||||
|
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||||||
// Get the function arguments, and convert them to `libffi`-compatible form.
|
// Get the function arguments, and convert them to `libffi`-compatible form.
|
||||||
let mut libffi_args = Vec::<CArg>::with_capacity(args.len());
|
let mut libffi_args = Vec::<CArg>::with_capacity(args.len());
|
||||||
for arg in args.iter() {
|
for arg in args.iter() {
|
||||||
if !matches!(arg.layout.abi, Abi::Scalar(_)) {
|
if !matches!(arg.layout.backend_repr, BackendRepr::Scalar(_)) {
|
||||||
throw_unsup_format!("only scalar argument types are support for native calls")
|
throw_unsup_format!("only scalar argument types are support for native calls")
|
||||||
}
|
}
|
||||||
libffi_args.push(imm_to_carg(this.read_immediate(arg)?, this)?);
|
libffi_args.push(imm_to_carg(this.read_immediate(arg)?, this)?);
|
||||||
|
Loading…
Reference in New Issue
Block a user