]> git.lizzy.rs Git - rust.git/blob - src/librustc_codegen_ssa/traits/consts.rs
Rollup merge of #65293 - tmandry:turbo-expander, r=matthewjasper
[rust.git] / src / librustc_codegen_ssa / traits / consts.rs
1 use super::BackendTypes;
2 use crate::mir::place::PlaceRef;
3 use rustc::mir::interpret::Allocation;
4 use rustc::mir::interpret::Scalar;
5 use rustc::ty::layout;
6
7 pub 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;
11     fn const_int(&self, t: Self::Type, i: i64) -> Self::Value;
12     fn const_uint(&self, t: Self::Type, i: u64) -> Self::Value;
13     fn const_uint_big(&self, t: Self::Type, u: u128) -> Self::Value;
14     fn const_bool(&self, val: bool) -> Self::Value;
15     fn const_i32(&self, i: i32) -> Self::Value;
16     fn const_u32(&self, i: u32) -> Self::Value;
17     fn const_u64(&self, i: u64) -> Self::Value;
18     fn const_usize(&self, i: u64) -> Self::Value;
19     fn const_u8(&self, i: u8) -> Self::Value;
20     fn const_real(&self, t: Self::Type, val: f64) -> Self::Value;
21
22     fn const_struct(&self, elts: &[Self::Value], packed: bool) -> Self::Value;
23
24     fn const_to_opt_uint(&self, v: Self::Value) -> Option<u64>;
25     fn const_to_opt_u128(&self, v: Self::Value, sign_ext: bool) -> Option<u128>;
26
27     fn scalar_to_backend(
28         &self,
29         cv: Scalar,
30         layout: &layout::Scalar,
31         llty: Self::Type,
32     ) -> Self::Value;
33     fn from_const_alloc(
34         &self,
35         layout: layout::TyLayout<'tcx>,
36         alloc: &Allocation,
37         offset: layout::Size,
38     ) -> PlaceRef<'tcx, Self::Value>;
39
40     fn const_ptrcast(&self, val: Self::Value, ty: Self::Type) -> Self::Value;
41 }