Skip to content

Commit 4e9ff6a

Browse files
committed
Removing LLVM content from CommonMethods -> ConstMethods
1 parent 55429fa commit 4e9ff6a

File tree

23 files changed

+49
-119
lines changed

23 files changed

+49
-119
lines changed

src/librustc_codegen_llvm/abi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use type_::Type;
1919
use type_of::{LayoutLlvmExt, PointerKind};
2020
use value::Value;
2121

22-
use interfaces::{BuilderMethods, CommonMethods, TypeMethods};
22+
use interfaces::{BuilderMethods, ConstMethods, TypeMethods};
2323

2424
use rustc_target::abi::{LayoutOf, Size, TyLayout, Abi as LayoutAbi};
2525
use rustc::ty::{self, Ty};

src/librustc_codegen_llvm/asm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use builder::Builder;
1515
use value::Value;
1616

1717
use rustc::hir;
18-
use interfaces::{BuilderMethods, CommonMethods, TypeMethods};
18+
use interfaces::{BuilderMethods, ConstMethods, TypeMethods};
1919

2020
use mir::place::PlaceRef;
2121
use mir::operand::OperandValue;

src/librustc_codegen_llvm/back/write.rs

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ use context::{is_pie_binary, get_reloc_model};
4949
use common;
5050
use jobserver::{Client, Acquired};
5151
use rustc_demangle;
52-
use value::Value;
5352
use std::marker::PhantomData;
5453

5554
use std::any::Any;
@@ -424,24 +423,6 @@ impl CodegenContext<'ll> {
424423
}
425424
}
426425

427-
428-
impl CodegenContext<'ll> {
429-
fn val_ty(&self, v: &'ll Value) -> &'ll Type {
430-
common::val_ty(v)
431-
}
432-
433-
fn const_bytes_in_context(&self, llcx: &'ll llvm::Context, bytes: &[u8]) -> &'ll Value {
434-
common::const_bytes_in_context(llcx, bytes)
435-
}
436-
437-
pub fn type_ptr_to(&self, ty: &'ll Type) -> &'ll Type {
438-
unsafe {
439-
llvm::LLVMPointerType(ty, 0)
440-
}
441-
}
442-
}
443-
444-
445426
pub struct DiagnosticHandlers<'a> {
446427
data: *mut (&'a CodegenContext<'a>, &'a Handler),
447428
llcx: &'a llvm::Context,
@@ -905,10 +886,10 @@ unsafe fn embed_bitcode(cgcx: &CodegenContext,
905886
llcx: &llvm::Context,
906887
llmod: &llvm::Module,
907888
bitcode: Option<&[u8]>) {
908-
let llconst = cgcx.const_bytes_in_context(llcx, bitcode.unwrap_or(&[]));
889+
let llconst = common::bytes_in_context(llcx, bitcode.unwrap_or(&[]));
909890
let llglobal = llvm::LLVMAddGlobal(
910891
llmod,
911-
cgcx.val_ty(llconst),
892+
common::val_ty(llconst),
912893
"rustc.embedded.module\0".as_ptr() as *const _,
913894
);
914895
llvm::LLVMSetInitializer(llglobal, llconst);
@@ -925,10 +906,10 @@ unsafe fn embed_bitcode(cgcx: &CodegenContext,
925906
llvm::LLVMRustSetLinkage(llglobal, llvm::Linkage::PrivateLinkage);
926907
llvm::LLVMSetGlobalConstant(llglobal, llvm::True);
927908

928-
let llconst = cgcx.const_bytes_in_context(llcx, &[]);
909+
let llconst = common::bytes_in_context(llcx, &[]);
929910
let llglobal = llvm::LLVMAddGlobal(
930911
llmod,
931-
cgcx.val_ty(llconst),
912+
common::val_ty(llconst),
932913
"rustc.embedded.cmdline\0".as_ptr() as *const _,
933914
);
934915
llvm::LLVMSetInitializer(llglobal, llconst);
@@ -2600,7 +2581,7 @@ fn create_msvc_imps(cgcx: &CodegenContext, llcx: &llvm::Context, llmod: &llvm::M
26002581
"\x01__imp_"
26012582
};
26022583
unsafe {
2603-
let i8p_ty = Type::i8p_llcx(cgcx, llcx);
2584+
let i8p_ty = Type::i8p_llcx(llcx);
26042585
let globals = base::iter_globals(llmod)
26052586
.filter(|&val| {
26062587
llvm::LLVMRustGetLinkage(val) == llvm::Linkage::ExternalLinkage &&

src/librustc_codegen_llvm/base.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ use CrateInfo;
7474
use rustc_data_structures::small_c_str::SmallCStr;
7575
use rustc_data_structures::sync::Lrc;
7676

77-
use interfaces::{BuilderMethods, CommonMethods, CommonWriteMethods, TypeMethods};
77+
use interfaces::{BuilderMethods, ConstMethods, TypeMethods};
7878

7979
use std::any::Any;
8080
use std::cmp;
@@ -652,12 +652,12 @@ fn write_metadata<'a, 'gcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>,
652652
DeflateEncoder::new(&mut compressed, Compression::fast())
653653
.write_all(&metadata.raw_data).unwrap();
654654

655-
let llmeta = llvm_module.const_bytes_in_context(metadata_llcx, &compressed);
656-
let llconst = llvm_module.const_struct_in_context(metadata_llcx, &[llmeta], false);
655+
let llmeta = common::bytes_in_context(metadata_llcx, &compressed);
656+
let llconst = common::struct_in_context(metadata_llcx, &[llmeta], false);
657657
let name = exported_symbols::metadata_symbol_name(tcx);
658658
let buf = CString::new(name).unwrap();
659659
let llglobal = unsafe {
660-
llvm::LLVMAddGlobal(metadata_llmod, llvm_module.val_ty(llconst), buf.as_ptr())
660+
llvm::LLVMAddGlobal(metadata_llmod, common::val_ty(llconst), buf.as_ptr())
661661
};
662662
unsafe {
663663
llvm::LLVMSetInitializer(llglobal, llconst);

src/librustc_codegen_llvm/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use rustc::ty::TyCtxt;
1919
use rustc::ty::layout::{Align, Size};
2020
use rustc::session::{config, Session};
2121
use rustc_data_structures::small_c_str::SmallCStr;
22-
use interfaces::{BuilderMethods, Backend, CommonMethods, CommonWriteMethods, TypeMethods};
22+
use interfaces::{BuilderMethods, Backend, ConstMethods, TypeMethods};
2323
use syntax;
2424

2525
use std::borrow::Cow;

src/librustc_codegen_llvm/callee.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use llvm;
2222
use monomorphize::Instance;
2323
use type_of::LayoutLlvmExt;
2424
use value::Value;
25-
use interfaces::CommonWriteMethods;
25+
use interfaces::TypeMethods;
2626

2727
use rustc::hir::def_id::DefId;
2828
use rustc::ty::{self, TypeFoldable};

src/librustc_codegen_llvm/common.rs

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use declare;
2424
use type_::Type;
2525
use type_of::LayoutLlvmExt;
2626
use value::Value;
27-
use interfaces::{Backend, CommonMethods, CommonWriteMethods, TypeMethods};
27+
use interfaces::{Backend, ConstMethods, TypeMethods};
2828

2929
use rustc::ty::{self, Ty, TyCtxt};
3030
use rustc::ty::layout::{HasDataLayout, LayoutOf};
@@ -201,7 +201,7 @@ impl Backend for CodegenCx<'ll, 'tcx, &'ll Value> {
201201
type Context = &'ll llvm::Context;
202202
}
203203

204-
impl<'ll, 'tcx : 'll> CommonMethods for CodegenCx<'ll, 'tcx, &'ll Value> {
204+
impl<'ll, 'tcx : 'll> ConstMethods for CodegenCx<'ll, 'tcx, &'ll Value> {
205205

206206
// LLVM constant constructors.
207207
fn const_null(&self, t: &'ll Type) -> &'ll Value {
@@ -319,7 +319,7 @@ impl<'ll, 'tcx : 'll> CommonMethods for CodegenCx<'ll, 'tcx, &'ll Value> {
319319
elts: &[&'ll Value],
320320
packed: bool
321321
) -> &'ll Value {
322-
&self.const_struct_in_context(&self.llcx, elts, packed)
322+
struct_in_context(&self.llcx, elts, packed)
323323
}
324324

325325
fn const_array(&self, ty: &'ll Type, elts: &[&'ll Value]) -> &'ll Value {
@@ -335,7 +335,7 @@ impl<'ll, 'tcx : 'll> CommonMethods for CodegenCx<'ll, 'tcx, &'ll Value> {
335335
}
336336

337337
fn const_bytes(&self, bytes: &[u8]) -> &'ll Value {
338-
&self.const_bytes_in_context(&self.llcx, bytes)
338+
bytes_in_context(&self.llcx, bytes)
339339
}
340340

341341
fn const_get_elt(&self, v: &'ll Value, idx: u64) -> &'ll Value {
@@ -406,14 +406,14 @@ pub fn val_ty(v: &'ll Value) -> &'ll Type {
406406
}
407407
}
408408

409-
pub fn const_bytes_in_context(llcx: &'ll llvm::Context, bytes: &[u8]) -> &'ll Value {
409+
pub fn bytes_in_context(llcx: &'ll llvm::Context, bytes: &[u8]) -> &'ll Value {
410410
unsafe {
411411
let ptr = bytes.as_ptr() as *const c_char;
412412
return llvm::LLVMConstStringInContext(llcx, ptr, bytes.len() as c_uint, True);
413413
}
414414
}
415415

416-
pub fn const_struct_in_context(
416+
pub fn struct_in_context(
417417
llcx: &'a llvm::Context,
418418
elts: &[&'a Value],
419419
packed: bool,
@@ -425,26 +425,6 @@ pub fn const_struct_in_context(
425425
}
426426
}
427427

428-
impl<'ll, 'tcx : 'll> CommonWriteMethods for CodegenCx<'ll, 'tcx, &'ll Value> {
429-
fn val_ty(&self, v: &'ll Value) -> &'ll Type {
430-
val_ty(v)
431-
}
432-
433-
fn const_bytes_in_context(&self, llcx: &'ll llvm::Context, bytes: &[u8]) -> &'ll Value {
434-
const_bytes_in_context(llcx, bytes)
435-
}
436-
437-
fn const_struct_in_context(
438-
&self,
439-
llcx: &'a llvm::Context,
440-
elts: &[&'a Value],
441-
packed: bool,
442-
) -> &'a Value {
443-
const_struct_in_context(llcx, elts, packed)
444-
}
445-
}
446-
447-
448428
#[inline]
449429
fn hi_lo_to_u128(lo: u64, hi: u64) -> u128 {
450430
((hi as u128) << 64) | (lo as u128)

src/librustc_codegen_llvm/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use type_::Type;
2424
use type_of::LayoutLlvmExt;
2525
use value::Value;
2626
use rustc::ty::{self, Ty};
27-
use interfaces::{CommonWriteMethods, TypeMethods};
27+
use interfaces::TypeMethods;
2828

2929
use rustc::ty::layout::{Align, LayoutOf};
3030

src/librustc_codegen_llvm/debuginfo/gdb.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use builder::Builder;
1717
use declare;
1818
use rustc::session::config::DebugInfo;
1919
use value::Value;
20-
use interfaces::{BuilderMethods, CommonMethods, TypeMethods};
20+
use interfaces::{BuilderMethods, ConstMethods, TypeMethods};
2121

2222
use syntax::attr;
2323

src/librustc_codegen_llvm/glue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use meth;
2020
use rustc::ty::layout::LayoutOf;
2121
use rustc::ty::{self, Ty};
2222
use value::Value;
23-
use interfaces::{BuilderMethods, CommonMethods};
23+
use interfaces::{BuilderMethods, ConstMethods};
2424

2525
pub fn size_and_align_of_dst(
2626
bx: &Builder<'_, 'll, 'tcx, &'ll Value>,

0 commit comments

Comments
 (0)