mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-06 20:28:33 +00:00
Remove const_{fat_ptr,array,vector,bytes} from cg_ssa
This commit is contained in:
parent
a0056333f1
commit
a3fa1161d2
@ -93,6 +93,34 @@ impl BackendTypes for CodegenCx<'ll, 'tcx> {
|
|||||||
type DIScope = &'ll llvm::debuginfo::DIScope;
|
type DIScope = &'ll llvm::debuginfo::DIScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl CodegenCx<'ll, 'tcx> {
|
||||||
|
pub fn const_fat_ptr(
|
||||||
|
&self,
|
||||||
|
ptr: &'ll Value,
|
||||||
|
meta: &'ll Value
|
||||||
|
) -> &'ll Value {
|
||||||
|
assert_eq!(abi::FAT_PTR_ADDR, 0);
|
||||||
|
assert_eq!(abi::FAT_PTR_EXTRA, 1);
|
||||||
|
self.const_struct(&[ptr, meta], false)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn const_array(&self, ty: &'ll Type, elts: &[&'ll Value]) -> &'ll Value {
|
||||||
|
unsafe {
|
||||||
|
return llvm::LLVMConstArray(ty, elts.as_ptr(), elts.len() as c_uint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn const_vector(&self, elts: &[&'ll Value]) -> &'ll Value {
|
||||||
|
unsafe {
|
||||||
|
return llvm::LLVMConstVector(elts.as_ptr(), elts.len() as c_uint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn const_bytes(&self, bytes: &[u8]) -> &'ll Value {
|
||||||
|
bytes_in_context(self.llcx, bytes)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||||
fn const_null(&self, t: &'ll Type) -> &'ll Value {
|
fn const_null(&self, t: &'ll Type) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
@ -189,16 +217,6 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||||||
self.const_fat_ptr(cs, self.const_usize(len as u64))
|
self.const_fat_ptr(cs, self.const_usize(len as u64))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn const_fat_ptr(
|
|
||||||
&self,
|
|
||||||
ptr: &'ll Value,
|
|
||||||
meta: &'ll Value
|
|
||||||
) -> &'ll Value {
|
|
||||||
assert_eq!(abi::FAT_PTR_ADDR, 0);
|
|
||||||
assert_eq!(abi::FAT_PTR_EXTRA, 1);
|
|
||||||
self.const_struct(&[ptr, meta], false)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn const_struct(
|
fn const_struct(
|
||||||
&self,
|
&self,
|
||||||
elts: &[&'ll Value],
|
elts: &[&'ll Value],
|
||||||
@ -207,22 +225,6 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||||||
struct_in_context(self.llcx, elts, packed)
|
struct_in_context(self.llcx, elts, packed)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn const_array(&self, ty: &'ll Type, elts: &[&'ll Value]) -> &'ll Value {
|
|
||||||
unsafe {
|
|
||||||
return llvm::LLVMConstArray(ty, elts.as_ptr(), elts.len() as c_uint);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn const_vector(&self, elts: &[&'ll Value]) -> &'ll Value {
|
|
||||||
unsafe {
|
|
||||||
return llvm::LLVMConstVector(elts.as_ptr(), elts.len() as c_uint);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn const_bytes(&self, bytes: &[u8]) -> &'ll Value {
|
|
||||||
bytes_in_context(self.llcx, bytes)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn const_get_elt(&self, v: &'ll Value, idx: u64) -> &'ll Value {
|
fn const_get_elt(&self, v: &'ll Value, idx: u64) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
assert_eq!(idx as c_uint as u64, idx);
|
assert_eq!(idx as c_uint as u64, idx);
|
||||||
|
@ -24,11 +24,7 @@ pub trait ConstMethods<'tcx>: BackendTypes {
|
|||||||
fn const_cstr(&self, s: LocalInternedString, null_terminated: bool) -> Self::Value;
|
fn const_cstr(&self, s: LocalInternedString, null_terminated: bool) -> Self::Value;
|
||||||
|
|
||||||
fn const_str_slice(&self, s: LocalInternedString) -> Self::Value;
|
fn const_str_slice(&self, s: LocalInternedString) -> Self::Value;
|
||||||
fn const_fat_ptr(&self, ptr: Self::Value, meta: Self::Value) -> Self::Value;
|
|
||||||
fn const_struct(&self, elts: &[Self::Value], packed: bool) -> Self::Value;
|
fn const_struct(&self, elts: &[Self::Value], packed: bool) -> Self::Value;
|
||||||
fn const_array(&self, ty: Self::Type, elts: &[Self::Value]) -> Self::Value;
|
|
||||||
fn const_vector(&self, elts: &[Self::Value]) -> Self::Value;
|
|
||||||
fn const_bytes(&self, bytes: &[u8]) -> Self::Value;
|
|
||||||
|
|
||||||
fn const_get_elt(&self, v: Self::Value, idx: u64) -> Self::Value;
|
fn const_get_elt(&self, v: Self::Value, idx: u64) -> Self::Value;
|
||||||
fn const_get_real(&self, v: Self::Value) -> Option<(f64, bool)>;
|
fn const_get_real(&self, v: Self::Value) -> Option<(f64, bool)>;
|
||||||
|
Loading…
Reference in New Issue
Block a user