2018-11-24 13:12:15 +00:00
|
|
|
use super::BackendTypes;
|
2019-02-09 14:31:47 +00:00
|
|
|
use crate::mir::place::PlaceRef;
|
2020-03-31 16:16:47 +00:00
|
|
|
use rustc_middle::mir::interpret::{Allocation, Scalar};
|
|
|
|
use rustc_middle::ty::layout::TyAndLayout;
|
2019-12-31 17:15:40 +00:00
|
|
|
use rustc_span::Symbol;
|
2020-03-31 16:16:47 +00:00
|
|
|
use rustc_target::abi::{self, Size};
|
2018-08-28 15:03:46 +00:00
|
|
|
|
2018-11-24 13:12:15 +00:00
|
|
|
pub trait ConstMethods<'tcx>: BackendTypes {
|
2018-08-28 15:03:46 +00:00
|
|
|
// Constant constructors
|
2018-09-06 18:57:42 +00:00
|
|
|
fn const_null(&self, t: Self::Type) -> Self::Value;
|
|
|
|
fn const_undef(&self, t: Self::Type) -> Self::Value;
|
|
|
|
fn const_int(&self, t: Self::Type, i: i64) -> Self::Value;
|
|
|
|
fn const_uint(&self, t: Self::Type, i: u64) -> Self::Value;
|
|
|
|
fn const_uint_big(&self, t: Self::Type, u: u128) -> Self::Value;
|
|
|
|
fn const_bool(&self, val: bool) -> Self::Value;
|
|
|
|
fn const_i32(&self, i: i32) -> Self::Value;
|
|
|
|
fn const_u32(&self, i: u32) -> Self::Value;
|
|
|
|
fn const_u64(&self, i: u64) -> Self::Value;
|
|
|
|
fn const_usize(&self, i: u64) -> Self::Value;
|
|
|
|
fn const_u8(&self, i: u8) -> Self::Value;
|
2019-07-07 17:08:40 +00:00
|
|
|
fn const_real(&self, t: Self::Type, val: f64) -> Self::Value;
|
2018-09-24 15:35:39 +00:00
|
|
|
|
2019-10-09 15:25:41 +00:00
|
|
|
fn const_str(&self, s: Symbol) -> (Self::Value, Self::Value);
|
2018-09-13 12:58:19 +00:00
|
|
|
fn const_struct(&self, elts: &[Self::Value], packed: bool) -> Self::Value;
|
2018-08-28 15:03:46 +00:00
|
|
|
|
2019-08-27 09:51:53 +00:00
|
|
|
fn const_to_opt_uint(&self, v: Self::Value) -> Option<u64>;
|
2018-08-30 13:41:59 +00:00
|
|
|
fn const_to_opt_u128(&self, v: Self::Value, sign_ext: bool) -> Option<u128>;
|
|
|
|
|
2020-03-31 16:16:47 +00:00
|
|
|
fn scalar_to_backend(&self, cv: Scalar, layout: &abi::Scalar, llty: Self::Type) -> Self::Value;
|
2018-09-20 13:47:22 +00:00
|
|
|
fn from_const_alloc(
|
|
|
|
&self,
|
2020-03-31 16:16:47 +00:00
|
|
|
layout: TyAndLayout<'tcx>,
|
2018-09-20 13:47:22 +00:00
|
|
|
alloc: &Allocation,
|
2020-03-31 16:16:47 +00:00
|
|
|
offset: Size,
|
2018-09-20 13:47:22 +00:00
|
|
|
) -> PlaceRef<'tcx, Self::Value>;
|
2018-11-24 16:23:22 +00:00
|
|
|
|
|
|
|
fn const_ptrcast(&self, val: Self::Value, ty: Self::Type) -> Self::Value;
|
2018-08-28 15:03:46 +00:00
|
|
|
}
|