]> git.proxmox.com Git - rustc.git/blame - compiler/rustc_codegen_ssa/src/traits/consts.rs
New upstream version 1.70.0+dfsg1
[rustc.git] / compiler / rustc_codegen_ssa / src / traits / consts.rs
CommitLineData
a1dfa0c6 1use super::BackendTypes;
9fa01778 2use crate::mir::place::PlaceRef;
5e7ed085 3use rustc_middle::mir::interpret::{ConstAllocation, Scalar};
ba9703b0 4use rustc_middle::ty::layout::TyAndLayout;
ba9703b0 5use rustc_target::abi::{self, Size};
a1dfa0c6
XL
6
7pub trait ConstMethods<'tcx>: BackendTypes {
8 // Constant constructors
9 fn const_null(&self, t: Self::Type) -> Self::Value;
10 fn const_undef(&self, t: Self::Type) -> Self::Value;
353b0b11 11 fn const_poison(&self, t: Self::Type) -> Self::Value;
a1dfa0c6
XL
12 fn const_int(&self, t: Self::Type, i: i64) -> Self::Value;
13 fn const_uint(&self, t: Self::Type, i: u64) -> Self::Value;
14 fn const_uint_big(&self, t: Self::Type, u: u128) -> Self::Value;
15 fn const_bool(&self, val: bool) -> Self::Value;
5e7ed085 16 fn const_i16(&self, i: i16) -> Self::Value;
a1dfa0c6
XL
17 fn const_i32(&self, i: i32) -> Self::Value;
18 fn const_u32(&self, i: u32) -> Self::Value;
19 fn const_u64(&self, i: u64) -> Self::Value;
20 fn const_usize(&self, i: u64) -> Self::Value;
21 fn const_u8(&self, i: u8) -> Self::Value;
416331ca 22 fn const_real(&self, t: Self::Type, val: f64) -> Self::Value;
a1dfa0c6 23
064997fb 24 fn const_str(&self, s: &str) -> (Self::Value, Self::Value);
a1dfa0c6 25 fn const_struct(&self, elts: &[Self::Value], packed: bool) -> Self::Value;
a1dfa0c6 26
e74abb32 27 fn const_to_opt_uint(&self, v: Self::Value) -> Option<u64>;
a1dfa0c6
XL
28 fn const_to_opt_u128(&self, v: Self::Value, sign_ext: bool) -> Option<u128>;
29
5e7ed085 30 fn const_data_from_alloc(&self, alloc: ConstAllocation<'tcx>) -> Self::Value;
136023e0 31
c295e0f8 32 fn scalar_to_backend(&self, cv: Scalar, layout: abi::Scalar, llty: Self::Type) -> Self::Value;
a1dfa0c6
XL
33 fn from_const_alloc(
34 &self,
ba9703b0 35 layout: TyAndLayout<'tcx>,
5e7ed085 36 alloc: ConstAllocation<'tcx>,
ba9703b0 37 offset: Size,
a1dfa0c6
XL
38 ) -> PlaceRef<'tcx, Self::Value>;
39
40 fn const_ptrcast(&self, val: Self::Value, ty: Self::Type) -> Self::Value;
41}