Skip to content

Commit fed567a

Browse files
committed
Removing LLVM content from CommonMethods -> ConstMethods
1 parent 23562c1 commit fed567a

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};
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
@@ -48,7 +48,6 @@ use context::{is_pie_binary, get_reloc_model};
4848
use common;
4949
use jobserver::{Client, Acquired};
5050
use rustc_demangle;
51-
use value::Value;
5251
use std::marker::PhantomData;
5352

5453
use std::any::Any;
@@ -419,24 +418,6 @@ impl CodegenContext<'ll> {
419418
}
420419
}
421420

422-
423-
impl CodegenContext<'ll> {
424-
fn val_ty(&self, v: &'ll Value) -> &'ll Type {
425-
common::val_ty(v)
426-
}
427-
428-
fn const_bytes_in_context(&self, llcx: &'ll llvm::Context, bytes: &[u8]) -> &'ll Value {
429-
common::const_bytes_in_context(llcx, bytes)
430-
}
431-
432-
pub fn type_ptr_to(&self, ty: &'ll Type) -> &'ll Type {
433-
unsafe {
434-
llvm::LLVMPointerType(ty, 0)
435-
}
436-
}
437-
}
438-
439-
440421
pub struct DiagnosticHandlers<'a> {
441422
data: *mut (&'a CodegenContext<'a>, &'a Handler),
442423
llcx: &'a llvm::Context,
@@ -907,10 +888,10 @@ unsafe fn embed_bitcode(cgcx: &CodegenContext,
907888
llcx: &llvm::Context,
908889
llmod: &llvm::Module,
909890
bitcode: Option<&[u8]>) {
910-
let llconst = cgcx.const_bytes_in_context(llcx, bitcode.unwrap_or(&[]));
891+
let llconst = common::bytes_in_context(llcx, bitcode.unwrap_or(&[]));
911892
let llglobal = llvm::LLVMAddGlobal(
912893
llmod,
913-
cgcx.val_ty(llconst),
894+
common::val_ty(llconst),
914895
"rustc.embedded.module\0".as_ptr() as *const _,
915896
);
916897
llvm::LLVMSetInitializer(llglobal, llconst);
@@ -927,10 +908,10 @@ unsafe fn embed_bitcode(cgcx: &CodegenContext,
927908
llvm::LLVMRustSetLinkage(llglobal, llvm::Linkage::PrivateLinkage);
928909
llvm::LLVMSetGlobalConstant(llglobal, llvm::True);
929910

930-
let llconst = cgcx.const_bytes_in_context(llcx, &[]);
911+
let llconst = common::bytes_in_context(llcx, &[]);
931912
let llglobal = llvm::LLVMAddGlobal(
932913
llmod,
933-
cgcx.val_ty(llconst),
914+
common::val_ty(llconst),
934915
"rustc.embedded.cmdline\0".as_ptr() as *const _,
935916
);
936917
llvm::LLVMSetInitializer(llglobal, llconst);
@@ -2561,7 +2542,7 @@ fn create_msvc_imps(cgcx: &CodegenContext, llcx: &llvm::Context, llmod: &llvm::M
25612542
"\x01__imp_"
25622543
};
25632544
unsafe {
2564-
let i8p_ty = Type::i8p_llcx(cgcx, llcx);
2545+
let i8p_ty = Type::i8p_llcx(llcx);
25652546
let globals = base::iter_globals(llmod)
25662547
.filter(|&val| {
25672548
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
@@ -73,7 +73,7 @@ use CrateInfo;
7373
use rustc_data_structures::small_c_str::SmallCStr;
7474
use rustc_data_structures::sync::Lrc;
7575

76-
use interfaces::{BuilderMethods, CommonMethods, CommonWriteMethods, TypeMethods};
76+
use interfaces::{BuilderMethods, ConstMethods, TypeMethods};
7777

7878
use std::any::Any;
7979
use std::ffi::CString;
@@ -654,12 +654,12 @@ fn write_metadata<'a, 'gcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>,
654654
DeflateEncoder::new(&mut compressed, Compression::fast())
655655
.write_all(&metadata.raw_data).unwrap();
656656

657-
let llmeta = llvm_module.const_bytes_in_context(metadata_llcx, &compressed);
658-
let llconst = llvm_module.const_struct_in_context(metadata_llcx, &[llmeta], false);
657+
let llmeta = common::bytes_in_context(metadata_llcx, &compressed);
658+
let llconst = common::struct_in_context(metadata_llcx, &[llmeta], false);
659659
let name = exported_symbols::metadata_symbol_name(tcx);
660660
let buf = CString::new(name).unwrap();
661661
let llglobal = unsafe {
662-
llvm::LLVMAddGlobal(metadata_llmod, llvm_module.val_ty(llconst), buf.as_ptr())
662+
llvm::LLVMAddGlobal(metadata_llmod, common::val_ty(llconst), buf.as_ptr())
663663
};
664664
unsafe {
665665
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};
@@ -203,7 +203,7 @@ impl Backend for CodegenCx<'ll, 'tcx, &'ll Value> {
203203
type Context = &'ll llvm::Context;
204204
}
205205

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

208208
// LLVM constant constructors.
209209
fn const_null(&self, t: &'ll Type) -> &'ll Value {
@@ -321,7 +321,7 @@ impl<'ll, 'tcx : 'll> CommonMethods for CodegenCx<'ll, 'tcx, &'ll Value> {
321321
elts: &[&'ll Value],
322322
packed: bool
323323
) -> &'ll Value {
324-
&self.const_struct_in_context(&self.llcx, elts, packed)
324+
struct_in_context(&self.llcx, elts, packed)
325325
}
326326

327327
fn const_array(&self, ty: &'ll Type, elts: &[&'ll Value]) -> &'ll Value {
@@ -337,7 +337,7 @@ impl<'ll, 'tcx : 'll> CommonMethods for CodegenCx<'ll, 'tcx, &'ll Value> {
337337
}
338338

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

343343
fn const_get_elt(&self, v: &'ll Value, idx: u64) -> &'ll Value {
@@ -408,14 +408,14 @@ pub fn val_ty(v: &'ll Value) -> &'ll Type {
408408
}
409409
}
410410

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

418-
pub fn const_struct_in_context(
418+
pub fn struct_in_context(
419419
llcx: &'a llvm::Context,
420420
elts: &[&'a Value],
421421
packed: bool,
@@ -427,26 +427,6 @@ pub fn const_struct_in_context(
427427
}
428428
}
429429

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