Skip to content

Commit a3fa116

Browse files
committed
Remove const_{fat_ptr,array,vector,bytes} from cg_ssa
1 parent a005633 commit a3fa116

File tree

2 files changed

+28
-30
lines changed

2 files changed

+28
-30
lines changed

src/librustc_codegen_llvm/common.rs

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,34 @@ impl BackendTypes for CodegenCx<'ll, 'tcx> {
9393
type DIScope = &'ll llvm::debuginfo::DIScope;
9494
}
9595

96+
impl CodegenCx<'ll, 'tcx> {
97+
pub fn const_fat_ptr(
98+
&self,
99+
ptr: &'ll Value,
100+
meta: &'ll Value
101+
) -> &'ll Value {
102+
assert_eq!(abi::FAT_PTR_ADDR, 0);
103+
assert_eq!(abi::FAT_PTR_EXTRA, 1);
104+
self.const_struct(&[ptr, meta], false)
105+
}
106+
107+
pub fn const_array(&self, ty: &'ll Type, elts: &[&'ll Value]) -> &'ll Value {
108+
unsafe {
109+
return llvm::LLVMConstArray(ty, elts.as_ptr(), elts.len() as c_uint);
110+
}
111+
}
112+
113+
pub fn const_vector(&self, elts: &[&'ll Value]) -> &'ll Value {
114+
unsafe {
115+
return llvm::LLVMConstVector(elts.as_ptr(), elts.len() as c_uint);
116+
}
117+
}
118+
119+
pub fn const_bytes(&self, bytes: &[u8]) -> &'ll Value {
120+
bytes_in_context(self.llcx, bytes)
121+
}
122+
}
123+
96124
impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
97125
fn const_null(&self, t: &'ll Type) -> &'ll Value {
98126
unsafe {
@@ -189,16 +217,6 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
189217
self.const_fat_ptr(cs, self.const_usize(len as u64))
190218
}
191219

192-
fn const_fat_ptr(
193-
&self,
194-
ptr: &'ll Value,
195-
meta: &'ll Value
196-
) -> &'ll Value {
197-
assert_eq!(abi::FAT_PTR_ADDR, 0);
198-
assert_eq!(abi::FAT_PTR_EXTRA, 1);
199-
self.const_struct(&[ptr, meta], false)
200-
}
201-
202220
fn const_struct(
203221
&self,
204222
elts: &[&'ll Value],
@@ -207,22 +225,6 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
207225
struct_in_context(self.llcx, elts, packed)
208226
}
209227

210-
fn const_array(&self, ty: &'ll Type, elts: &[&'ll Value]) -> &'ll Value {
211-
unsafe {
212-
return llvm::LLVMConstArray(ty, elts.as_ptr(), elts.len() as c_uint);
213-
}
214-
}
215-
216-
fn const_vector(&self, elts: &[&'ll Value]) -> &'ll Value {
217-
unsafe {
218-
return llvm::LLVMConstVector(elts.as_ptr(), elts.len() as c_uint);
219-
}
220-
}
221-
222-
fn const_bytes(&self, bytes: &[u8]) -> &'ll Value {
223-
bytes_in_context(self.llcx, bytes)
224-
}
225-
226228
fn const_get_elt(&self, v: &'ll Value, idx: u64) -> &'ll Value {
227229
unsafe {
228230
assert_eq!(idx as c_uint as u64, idx);

src/librustc_codegen_ssa/traits/consts.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ pub trait ConstMethods<'tcx>: BackendTypes {
2424
fn const_cstr(&self, s: LocalInternedString, null_terminated: bool) -> Self::Value;
2525

2626
fn const_str_slice(&self, s: LocalInternedString) -> Self::Value;
27-
fn const_fat_ptr(&self, ptr: Self::Value, meta: Self::Value) -> Self::Value;
2827
fn const_struct(&self, elts: &[Self::Value], packed: bool) -> Self::Value;
29-
fn const_array(&self, ty: Self::Type, elts: &[Self::Value]) -> Self::Value;
30-
fn const_vector(&self, elts: &[Self::Value]) -> Self::Value;
31-
fn const_bytes(&self, bytes: &[u8]) -> Self::Value;
3228

3329
fn const_get_elt(&self, v: Self::Value, idx: u64) -> Self::Value;
3430
fn const_get_real(&self, v: Self::Value) -> Option<(f64, bool)>;

0 commit comments

Comments
 (0)