rustc_codegen_ssa/traits/
consts.rs1use rustc_abi as abi;
2use rustc_middle::mir::interpret::Scalar;
3
4use super::BackendTypes;
5use crate::traits::PacMetadata;
6
7pub trait ConstCodegenMethods: BackendTypes {
8 fn const_null(&self, t: Self::Type) -> Self::Value;
10 fn const_undef(&self, t: Self::Type) -> Self::Value;
13 fn const_poison(&self, t: Self::Type) -> Self::Value;
18
19 fn const_bool(&self, val: bool) -> Self::Value;
20
21 fn const_i8(&self, i: i8) -> Self::Value;
22 fn const_i16(&self, i: i16) -> Self::Value;
23 fn const_i32(&self, i: i32) -> Self::Value;
24 fn const_i64(&self, i: i64) -> Self::Value;
25 fn const_int(&self, t: Self::Type, i: i64) -> Self::Value;
26 fn const_u8(&self, i: u8) -> Self::Value;
27 fn const_u32(&self, i: u32) -> Self::Value;
28 fn const_u64(&self, i: u64) -> Self::Value;
29 fn const_u128(&self, i: u128) -> Self::Value;
30 fn const_usize(&self, i: u64) -> Self::Value;
31 fn const_uint(&self, t: Self::Type, i: u64) -> Self::Value;
32 fn const_uint_big(&self, t: Self::Type, u: u128) -> Self::Value;
33 fn const_real(&self, t: Self::Type, val: f64) -> Self::Value;
34
35 fn const_str(&self, s: &str) -> (Self::Value, Self::Value);
36 fn const_struct(&self, elts: &[Self::Value], packed: bool) -> Self::Value;
37 fn const_vector(&self, elts: &[Self::Value]) -> Self::Value;
38
39 fn const_to_opt_uint(&self, v: Self::Value) -> Option<u64>;
40 fn const_to_opt_u128(&self, v: Self::Value, sign_ext: bool) -> Option<u128>;
41
42 fn scalar_to_backend(&self, cv: Scalar, layout: abi::Scalar, llty: Self::Type) -> Self::Value {
43 self.scalar_to_backend_with_pac(cv, layout, llty, None)
44 }
45 fn scalar_to_backend_with_pac(
46 &self,
47 cv: Scalar,
48 layout: abi::Scalar,
49 llty: Self::Type,
50 pac: Option<PacMetadata>,
51 ) -> Self::Value;
52
53 fn const_ptr_byte_offset(&self, val: Self::Value, offset: abi::Size) -> Self::Value;
54}