Beginning of moving all backend-agnostic code to rustc_codegen_ssa
This commit is contained in:
parent
b02e5cce16
commit
c9f26c2155
@ -2122,9 +2122,14 @@ dependencies = [
|
||||
"memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc_codegen_ssa 0.0.0",
|
||||
"rustc_llvm 0.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc_codegen_ssa"
|
||||
version = "0.0.0"
|
||||
|
||||
[[package]]
|
||||
name = "rustc_codegen_utils"
|
||||
version = "0.0.0"
|
||||
|
@ -13,6 +13,7 @@ test = false
|
||||
cc = "1.0.1"
|
||||
num_cpus = "1.0"
|
||||
rustc-demangle = "0.1.4"
|
||||
rustc_codegen_ssa = { path = "../librustc_codegen_ssa" }
|
||||
rustc_llvm = { path = "../librustc_llvm" }
|
||||
memmap = "0.6"
|
||||
|
||||
|
@ -25,7 +25,7 @@ use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_codegen_utils::symbol_export;
|
||||
use time_graph::Timeline;
|
||||
use ModuleLlvm;
|
||||
use rustc_codegen_utils::{ModuleCodegen, ModuleKind};
|
||||
use rustc_codegen_ssa::{ModuleCodegen, ModuleKind};
|
||||
|
||||
use libc;
|
||||
|
||||
|
@ -27,7 +27,7 @@ use time_graph::{self, TimeGraph, Timeline};
|
||||
use llvm::{self, DiagnosticInfo, PassManager, SMDiagnostic};
|
||||
use llvm_util;
|
||||
use {CodegenResults, ModuleLlvm};
|
||||
use rustc_codegen_utils::{ModuleCodegen, ModuleKind, CachedModuleCodegen, CompiledModule};
|
||||
use rustc_codegen_ssa::{ModuleCodegen, ModuleKind, CachedModuleCodegen, CompiledModule};
|
||||
use CrateInfo;
|
||||
use rustc::hir::def_id::{CrateNum, LOCAL_CRATE};
|
||||
use rustc::ty::TyCtxt;
|
||||
|
@ -24,7 +24,7 @@
|
||||
//! int) and rec(x=int, y=int, z=int) will have the same llvm::Type.
|
||||
|
||||
use super::ModuleLlvm;
|
||||
use rustc_codegen_utils::{ModuleCodegen, ModuleKind, CachedModuleCodegen};
|
||||
use rustc_codegen_ssa::{ModuleCodegen, ModuleKind, CachedModuleCodegen};
|
||||
use super::LlvmCodegenBackend;
|
||||
|
||||
use abi;
|
||||
@ -52,7 +52,7 @@ use builder::{Builder, MemFlags};
|
||||
use callee;
|
||||
use rustc_mir::monomorphize::item::DefPathBasedNames;
|
||||
use common;
|
||||
use rustc_codegen_utils::common::{RealPredicate, TypeKind, IntPredicate};
|
||||
use rustc_codegen_ssa::common::{RealPredicate, TypeKind, IntPredicate};
|
||||
use meth;
|
||||
use mir;
|
||||
use context::CodegenCx;
|
||||
|
@ -10,8 +10,8 @@
|
||||
|
||||
use llvm::{AtomicRmwBinOp, AtomicOrdering, SynchronizationScope, AsmDialect};
|
||||
use llvm::{self, False, BasicBlock};
|
||||
use rustc_codegen_utils::common::{IntPredicate, TypeKind, RealPredicate};
|
||||
use rustc_codegen_utils;
|
||||
use rustc_codegen_ssa::common::{IntPredicate, TypeKind, RealPredicate};
|
||||
use rustc_codegen_ssa;
|
||||
use common::Funclet;
|
||||
use context::CodegenCx;
|
||||
use type_::Type;
|
||||
@ -527,7 +527,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
||||
fn atomic_load(
|
||||
&self,
|
||||
ptr: &'ll Value,
|
||||
order: rustc_codegen_utils::common::AtomicOrdering,
|
||||
order: rustc_codegen_ssa::common::AtomicOrdering,
|
||||
size: Size,
|
||||
) -> &'ll Value {
|
||||
self.count_insn("load.atomic");
|
||||
@ -681,7 +681,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
||||
}
|
||||
|
||||
fn atomic_store(&self, val: &'ll Value, ptr: &'ll Value,
|
||||
order: rustc_codegen_utils::common::AtomicOrdering, size: Size) {
|
||||
order: rustc_codegen_ssa::common::AtomicOrdering, size: Size) {
|
||||
debug!("Store {:?} -> {:?}", val, ptr);
|
||||
self.count_insn("store.atomic");
|
||||
let ptr = self.check_store(val, ptr);
|
||||
@ -1204,8 +1204,8 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
||||
dst: &'ll Value,
|
||||
cmp: &'ll Value,
|
||||
src: &'ll Value,
|
||||
order: rustc_codegen_utils::common::AtomicOrdering,
|
||||
failure_order: rustc_codegen_utils::common::AtomicOrdering,
|
||||
order: rustc_codegen_ssa::common::AtomicOrdering,
|
||||
failure_order: rustc_codegen_ssa::common::AtomicOrdering,
|
||||
weak: bool,
|
||||
) -> &'ll Value {
|
||||
let weak = if weak { llvm::True } else { llvm::False };
|
||||
@ -1223,10 +1223,10 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
||||
}
|
||||
fn atomic_rmw(
|
||||
&self,
|
||||
op: rustc_codegen_utils::common::AtomicRmwBinOp,
|
||||
op: rustc_codegen_ssa::common::AtomicRmwBinOp,
|
||||
dst: &'ll Value,
|
||||
src: &'ll Value,
|
||||
order: rustc_codegen_utils::common::AtomicOrdering,
|
||||
order: rustc_codegen_ssa::common::AtomicOrdering,
|
||||
) -> &'ll Value {
|
||||
unsafe {
|
||||
llvm::LLVMBuildAtomicRMW(
|
||||
@ -1241,8 +1241,8 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
||||
|
||||
fn atomic_fence(
|
||||
&self,
|
||||
order: rustc_codegen_utils::common::AtomicOrdering,
|
||||
scope: rustc_codegen_utils::common::SynchronizationScope
|
||||
order: rustc_codegen_ssa::common::AtomicOrdering,
|
||||
scope: rustc_codegen_ssa::common::SynchronizationScope
|
||||
) {
|
||||
unsafe {
|
||||
llvm::LLVMRustBuildAtomicFence(
|
||||
|
@ -29,7 +29,7 @@ use rustc::mir::interpret::{Scalar, AllocType, Allocation};
|
||||
use rustc::hir;
|
||||
use mir::constant::const_alloc_to_llvm;
|
||||
use mir::place::PlaceRef;
|
||||
use rustc_codegen_utils::common::TypeKind;
|
||||
use rustc_codegen_ssa::common::TypeKind;
|
||||
|
||||
use libc::{c_uint, c_char};
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
use std;
|
||||
|
||||
use rustc_codegen_utils::common::IntPredicate;
|
||||
use rustc_codegen_ssa::common::IntPredicate;
|
||||
use meth;
|
||||
use rustc::ty::layout::LayoutOf;
|
||||
use rustc::ty::{self, Ty};
|
||||
|
@ -19,7 +19,7 @@ use libc::c_char;
|
||||
use mir::operand::OperandRef;
|
||||
use mir::place::PlaceRef;
|
||||
use rustc::ty::layout::{Align, Size};
|
||||
use rustc_codegen_utils::common::{
|
||||
use rustc_codegen_ssa::common::{
|
||||
AtomicOrdering, AtomicRmwBinOp, IntPredicate, RealPredicate, SynchronizationScope,
|
||||
};
|
||||
|
||||
|
@ -31,7 +31,7 @@ pub use self::statics::StaticMethods;
|
||||
pub use self::type_::{
|
||||
ArgTypeMethods, BaseTypeMethods, DerivedTypeMethods, LayoutTypeMethods, TypeMethods,
|
||||
};
|
||||
pub use rustc_codegen_utils::interfaces::{Backend, BackendMethods, BackendTypes, CodegenObject};
|
||||
pub use rustc_codegen_ssa::interfaces::{Backend, BackendMethods, BackendTypes, CodegenObject};
|
||||
|
||||
pub trait CodegenMethods<'tcx>:
|
||||
Backend<'tcx>
|
||||
|
@ -15,7 +15,7 @@ use rustc::ty::layout::TyLayout;
|
||||
use rustc::ty::layout::{self, Align, Size};
|
||||
use rustc::ty::Ty;
|
||||
use rustc::util::nodemap::FxHashMap;
|
||||
use rustc_codegen_utils::common::TypeKind;
|
||||
use rustc_codegen_ssa::common::TypeKind;
|
||||
use rustc_target::abi::call::{ArgType, CastTarget, FnType, Reg};
|
||||
use std::cell::RefCell;
|
||||
use syntax::ast;
|
||||
|
@ -24,7 +24,7 @@ use type_::Type;
|
||||
use type_of::LayoutLlvmExt;
|
||||
use rustc::ty::{self, Ty};
|
||||
use rustc::ty::layout::{LayoutOf, HasTyCtxt};
|
||||
use rustc_codegen_utils::common::TypeKind;
|
||||
use rustc_codegen_ssa::common::TypeKind;
|
||||
use rustc::hir;
|
||||
use syntax::ast;
|
||||
use syntax::symbol::Symbol;
|
||||
@ -463,8 +463,8 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
|
||||
// This requires that atomic intrinsics follow a specific naming pattern:
|
||||
// "atomic_<operation>[_<ordering>]", and no ordering means SeqCst
|
||||
name if name.starts_with("atomic_") => {
|
||||
use rustc_codegen_utils::common::AtomicOrdering::*;
|
||||
use rustc_codegen_utils::common::
|
||||
use rustc_codegen_ssa::common::AtomicOrdering::*;
|
||||
use rustc_codegen_ssa::common::
|
||||
{SynchronizationScope, AtomicRmwBinOp};
|
||||
|
||||
let split: Vec<&str> = name.split('_').collect();
|
||||
|
@ -55,6 +55,7 @@ extern crate rustc_incremental;
|
||||
extern crate rustc_llvm;
|
||||
extern crate rustc_platform_intrinsics as intrinsics;
|
||||
extern crate rustc_codegen_utils;
|
||||
extern crate rustc_codegen_ssa;
|
||||
extern crate rustc_fs_util;
|
||||
|
||||
#[macro_use] extern crate log;
|
||||
@ -91,7 +92,7 @@ use rustc::util::time_graph;
|
||||
use rustc::util::nodemap::{FxHashSet, FxHashMap};
|
||||
use rustc::util::profiling::ProfileCategory;
|
||||
use rustc_mir::monomorphize;
|
||||
use rustc_codegen_utils::{ModuleCodegen, CompiledModule};
|
||||
use rustc_codegen_ssa::{ModuleCodegen, CompiledModule};
|
||||
use rustc_codegen_utils::codegen_backend::CodegenBackend;
|
||||
use rustc_data_structures::svh::Svh;
|
||||
|
||||
|
@ -19,8 +19,8 @@ use libc::{c_uint, c_int, size_t, c_char};
|
||||
use libc::{c_ulonglong, c_void};
|
||||
|
||||
use std::marker::PhantomData;
|
||||
use rustc_codegen_utils;
|
||||
use syntax;
|
||||
use rustc_codegen_ssa;
|
||||
|
||||
use super::RustString;
|
||||
|
||||
@ -144,18 +144,18 @@ pub enum IntPredicate {
|
||||
}
|
||||
|
||||
impl IntPredicate {
|
||||
pub fn from_generic(intpre: rustc_codegen_utils::common::IntPredicate) -> Self {
|
||||
pub fn from_generic(intpre: rustc_codegen_ssa::common::IntPredicate) -> Self {
|
||||
match intpre {
|
||||
rustc_codegen_utils::common::IntPredicate::IntEQ => IntPredicate::IntEQ,
|
||||
rustc_codegen_utils::common::IntPredicate::IntNE => IntPredicate::IntNE,
|
||||
rustc_codegen_utils::common::IntPredicate::IntUGT => IntPredicate::IntUGT,
|
||||
rustc_codegen_utils::common::IntPredicate::IntUGE => IntPredicate::IntUGE,
|
||||
rustc_codegen_utils::common::IntPredicate::IntULT => IntPredicate::IntULT,
|
||||
rustc_codegen_utils::common::IntPredicate::IntULE => IntPredicate::IntULE,
|
||||
rustc_codegen_utils::common::IntPredicate::IntSGT => IntPredicate::IntSGT,
|
||||
rustc_codegen_utils::common::IntPredicate::IntSGE => IntPredicate::IntSGE,
|
||||
rustc_codegen_utils::common::IntPredicate::IntSLT => IntPredicate::IntSLT,
|
||||
rustc_codegen_utils::common::IntPredicate::IntSLE => IntPredicate::IntSLE,
|
||||
rustc_codegen_ssa::common::IntPredicate::IntEQ => IntPredicate::IntEQ,
|
||||
rustc_codegen_ssa::common::IntPredicate::IntNE => IntPredicate::IntNE,
|
||||
rustc_codegen_ssa::common::IntPredicate::IntUGT => IntPredicate::IntUGT,
|
||||
rustc_codegen_ssa::common::IntPredicate::IntUGE => IntPredicate::IntUGE,
|
||||
rustc_codegen_ssa::common::IntPredicate::IntULT => IntPredicate::IntULT,
|
||||
rustc_codegen_ssa::common::IntPredicate::IntULE => IntPredicate::IntULE,
|
||||
rustc_codegen_ssa::common::IntPredicate::IntSGT => IntPredicate::IntSGT,
|
||||
rustc_codegen_ssa::common::IntPredicate::IntSGE => IntPredicate::IntSGE,
|
||||
rustc_codegen_ssa::common::IntPredicate::IntSLT => IntPredicate::IntSLT,
|
||||
rustc_codegen_ssa::common::IntPredicate::IntSLE => IntPredicate::IntSLE,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -183,25 +183,25 @@ pub enum RealPredicate {
|
||||
}
|
||||
|
||||
impl RealPredicate {
|
||||
pub fn from_generic(realpred: rustc_codegen_utils::common::RealPredicate) -> Self {
|
||||
pub fn from_generic(realpred: rustc_codegen_ssa::common::RealPredicate) -> Self {
|
||||
match realpred {
|
||||
rustc_codegen_utils::common::RealPredicate::RealPredicateFalse =>
|
||||
rustc_codegen_ssa::common::RealPredicate::RealPredicateFalse =>
|
||||
RealPredicate::RealPredicateFalse,
|
||||
rustc_codegen_utils::common::RealPredicate::RealOEQ => RealPredicate::RealOEQ,
|
||||
rustc_codegen_utils::common::RealPredicate::RealOGT => RealPredicate::RealOGT,
|
||||
rustc_codegen_utils::common::RealPredicate::RealOGE => RealPredicate::RealOGE,
|
||||
rustc_codegen_utils::common::RealPredicate::RealOLT => RealPredicate::RealOLT,
|
||||
rustc_codegen_utils::common::RealPredicate::RealOLE => RealPredicate::RealOLE,
|
||||
rustc_codegen_utils::common::RealPredicate::RealONE => RealPredicate::RealONE,
|
||||
rustc_codegen_utils::common::RealPredicate::RealORD => RealPredicate::RealORD,
|
||||
rustc_codegen_utils::common::RealPredicate::RealUNO => RealPredicate::RealUNO,
|
||||
rustc_codegen_utils::common::RealPredicate::RealUEQ => RealPredicate::RealUEQ,
|
||||
rustc_codegen_utils::common::RealPredicate::RealUGT => RealPredicate::RealUGT,
|
||||
rustc_codegen_utils::common::RealPredicate::RealUGE => RealPredicate::RealUGE,
|
||||
rustc_codegen_utils::common::RealPredicate::RealULT => RealPredicate::RealULT,
|
||||
rustc_codegen_utils::common::RealPredicate::RealULE => RealPredicate::RealULE,
|
||||
rustc_codegen_utils::common::RealPredicate::RealUNE => RealPredicate::RealUNE,
|
||||
rustc_codegen_utils::common::RealPredicate::RealPredicateTrue =>
|
||||
rustc_codegen_ssa::common::RealPredicate::RealOEQ => RealPredicate::RealOEQ,
|
||||
rustc_codegen_ssa::common::RealPredicate::RealOGT => RealPredicate::RealOGT,
|
||||
rustc_codegen_ssa::common::RealPredicate::RealOGE => RealPredicate::RealOGE,
|
||||
rustc_codegen_ssa::common::RealPredicate::RealOLT => RealPredicate::RealOLT,
|
||||
rustc_codegen_ssa::common::RealPredicate::RealOLE => RealPredicate::RealOLE,
|
||||
rustc_codegen_ssa::common::RealPredicate::RealONE => RealPredicate::RealONE,
|
||||
rustc_codegen_ssa::common::RealPredicate::RealORD => RealPredicate::RealORD,
|
||||
rustc_codegen_ssa::common::RealPredicate::RealUNO => RealPredicate::RealUNO,
|
||||
rustc_codegen_ssa::common::RealPredicate::RealUEQ => RealPredicate::RealUEQ,
|
||||
rustc_codegen_ssa::common::RealPredicate::RealUGT => RealPredicate::RealUGT,
|
||||
rustc_codegen_ssa::common::RealPredicate::RealUGE => RealPredicate::RealUGE,
|
||||
rustc_codegen_ssa::common::RealPredicate::RealULT => RealPredicate::RealULT,
|
||||
rustc_codegen_ssa::common::RealPredicate::RealULE => RealPredicate::RealULE,
|
||||
rustc_codegen_ssa::common::RealPredicate::RealUNE => RealPredicate::RealUNE,
|
||||
rustc_codegen_ssa::common::RealPredicate::RealPredicateTrue =>
|
||||
RealPredicate::RealPredicateTrue
|
||||
}
|
||||
}
|
||||
@ -231,25 +231,25 @@ pub enum TypeKind {
|
||||
}
|
||||
|
||||
impl TypeKind {
|
||||
pub fn to_generic(self) -> rustc_codegen_utils::common::TypeKind {
|
||||
pub fn to_generic(self) -> rustc_codegen_ssa::common::TypeKind {
|
||||
match self {
|
||||
TypeKind::Void => rustc_codegen_utils::common::TypeKind::Void,
|
||||
TypeKind::Half => rustc_codegen_utils::common::TypeKind::Half,
|
||||
TypeKind::Float => rustc_codegen_utils::common::TypeKind::Float,
|
||||
TypeKind::Double => rustc_codegen_utils::common::TypeKind::Double,
|
||||
TypeKind::X86_FP80 => rustc_codegen_utils::common::TypeKind::X86_FP80,
|
||||
TypeKind::FP128 => rustc_codegen_utils::common::TypeKind::FP128,
|
||||
TypeKind::PPC_FP128 => rustc_codegen_utils::common::TypeKind::PPC_FP128,
|
||||
TypeKind::Label => rustc_codegen_utils::common::TypeKind::Label,
|
||||
TypeKind::Integer => rustc_codegen_utils::common::TypeKind::Integer,
|
||||
TypeKind::Function => rustc_codegen_utils::common::TypeKind::Function,
|
||||
TypeKind::Struct => rustc_codegen_utils::common::TypeKind::Struct,
|
||||
TypeKind::Array => rustc_codegen_utils::common::TypeKind::Array,
|
||||
TypeKind::Pointer => rustc_codegen_utils::common::TypeKind::Pointer,
|
||||
TypeKind::Vector => rustc_codegen_utils::common::TypeKind::Vector,
|
||||
TypeKind::Metadata => rustc_codegen_utils::common::TypeKind::Metadata,
|
||||
TypeKind::X86_MMX => rustc_codegen_utils::common::TypeKind::X86_MMX,
|
||||
TypeKind::Token => rustc_codegen_utils::common::TypeKind::Token,
|
||||
TypeKind::Void => rustc_codegen_ssa::common::TypeKind::Void,
|
||||
TypeKind::Half => rustc_codegen_ssa::common::TypeKind::Half,
|
||||
TypeKind::Float => rustc_codegen_ssa::common::TypeKind::Float,
|
||||
TypeKind::Double => rustc_codegen_ssa::common::TypeKind::Double,
|
||||
TypeKind::X86_FP80 => rustc_codegen_ssa::common::TypeKind::X86_FP80,
|
||||
TypeKind::FP128 => rustc_codegen_ssa::common::TypeKind::FP128,
|
||||
TypeKind::PPC_FP128 => rustc_codegen_ssa::common::TypeKind::PPC_FP128,
|
||||
TypeKind::Label => rustc_codegen_ssa::common::TypeKind::Label,
|
||||
TypeKind::Integer => rustc_codegen_ssa::common::TypeKind::Integer,
|
||||
TypeKind::Function => rustc_codegen_ssa::common::TypeKind::Function,
|
||||
TypeKind::Struct => rustc_codegen_ssa::common::TypeKind::Struct,
|
||||
TypeKind::Array => rustc_codegen_ssa::common::TypeKind::Array,
|
||||
TypeKind::Pointer => rustc_codegen_ssa::common::TypeKind::Pointer,
|
||||
TypeKind::Vector => rustc_codegen_ssa::common::TypeKind::Vector,
|
||||
TypeKind::Metadata => rustc_codegen_ssa::common::TypeKind::Metadata,
|
||||
TypeKind::X86_MMX => rustc_codegen_ssa::common::TypeKind::X86_MMX,
|
||||
TypeKind::Token => rustc_codegen_ssa::common::TypeKind::Token,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -272,19 +272,19 @@ pub enum AtomicRmwBinOp {
|
||||
}
|
||||
|
||||
impl AtomicRmwBinOp {
|
||||
pub fn from_generic(op: rustc_codegen_utils::common::AtomicRmwBinOp) -> Self {
|
||||
pub fn from_generic(op: rustc_codegen_ssa::common::AtomicRmwBinOp) -> Self {
|
||||
match op {
|
||||
rustc_codegen_utils::common::AtomicRmwBinOp::AtomicXchg => AtomicRmwBinOp::AtomicXchg,
|
||||
rustc_codegen_utils::common::AtomicRmwBinOp::AtomicAdd => AtomicRmwBinOp::AtomicAdd,
|
||||
rustc_codegen_utils::common::AtomicRmwBinOp::AtomicSub => AtomicRmwBinOp::AtomicSub,
|
||||
rustc_codegen_utils::common::AtomicRmwBinOp::AtomicAnd => AtomicRmwBinOp::AtomicAnd,
|
||||
rustc_codegen_utils::common::AtomicRmwBinOp::AtomicNand => AtomicRmwBinOp::AtomicNand,
|
||||
rustc_codegen_utils::common::AtomicRmwBinOp::AtomicOr => AtomicRmwBinOp::AtomicOr,
|
||||
rustc_codegen_utils::common::AtomicRmwBinOp::AtomicXor => AtomicRmwBinOp::AtomicXor,
|
||||
rustc_codegen_utils::common::AtomicRmwBinOp::AtomicMax => AtomicRmwBinOp::AtomicMax,
|
||||
rustc_codegen_utils::common::AtomicRmwBinOp::AtomicMin => AtomicRmwBinOp::AtomicMin,
|
||||
rustc_codegen_utils::common::AtomicRmwBinOp::AtomicUMax => AtomicRmwBinOp::AtomicUMax,
|
||||
rustc_codegen_utils::common::AtomicRmwBinOp::AtomicUMin => AtomicRmwBinOp::AtomicUMin
|
||||
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXchg => AtomicRmwBinOp::AtomicXchg,
|
||||
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAdd => AtomicRmwBinOp::AtomicAdd,
|
||||
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicSub => AtomicRmwBinOp::AtomicSub,
|
||||
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAnd => AtomicRmwBinOp::AtomicAnd,
|
||||
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicNand => AtomicRmwBinOp::AtomicNand,
|
||||
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicOr => AtomicRmwBinOp::AtomicOr,
|
||||
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXor => AtomicRmwBinOp::AtomicXor,
|
||||
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMax => AtomicRmwBinOp::AtomicMax,
|
||||
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMin => AtomicRmwBinOp::AtomicMin,
|
||||
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMax => AtomicRmwBinOp::AtomicUMax,
|
||||
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMin => AtomicRmwBinOp::AtomicUMin
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -305,16 +305,16 @@ pub enum AtomicOrdering {
|
||||
}
|
||||
|
||||
impl AtomicOrdering {
|
||||
pub fn from_generic(ao: rustc_codegen_utils::common::AtomicOrdering) -> Self {
|
||||
pub fn from_generic(ao: rustc_codegen_ssa::common::AtomicOrdering) -> Self {
|
||||
match ao {
|
||||
rustc_codegen_utils::common::AtomicOrdering::NotAtomic => AtomicOrdering::NotAtomic,
|
||||
rustc_codegen_utils::common::AtomicOrdering::Unordered => AtomicOrdering::Unordered,
|
||||
rustc_codegen_utils::common::AtomicOrdering::Monotonic => AtomicOrdering::Monotonic,
|
||||
rustc_codegen_utils::common::AtomicOrdering::Acquire => AtomicOrdering::Acquire,
|
||||
rustc_codegen_utils::common::AtomicOrdering::Release => AtomicOrdering::Release,
|
||||
rustc_codegen_utils::common::AtomicOrdering::AcquireRelease =>
|
||||
rustc_codegen_ssa::common::AtomicOrdering::NotAtomic => AtomicOrdering::NotAtomic,
|
||||
rustc_codegen_ssa::common::AtomicOrdering::Unordered => AtomicOrdering::Unordered,
|
||||
rustc_codegen_ssa::common::AtomicOrdering::Monotonic => AtomicOrdering::Monotonic,
|
||||
rustc_codegen_ssa::common::AtomicOrdering::Acquire => AtomicOrdering::Acquire,
|
||||
rustc_codegen_ssa::common::AtomicOrdering::Release => AtomicOrdering::Release,
|
||||
rustc_codegen_ssa::common::AtomicOrdering::AcquireRelease =>
|
||||
AtomicOrdering::AcquireRelease,
|
||||
rustc_codegen_utils::common::AtomicOrdering::SequentiallyConsistent =>
|
||||
rustc_codegen_ssa::common::AtomicOrdering::SequentiallyConsistent =>
|
||||
AtomicOrdering::SequentiallyConsistent
|
||||
}
|
||||
}
|
||||
@ -333,12 +333,12 @@ pub enum SynchronizationScope {
|
||||
}
|
||||
|
||||
impl SynchronizationScope {
|
||||
pub fn from_generic(sc: rustc_codegen_utils::common::SynchronizationScope) -> Self {
|
||||
pub fn from_generic(sc: rustc_codegen_ssa::common::SynchronizationScope) -> Self {
|
||||
match sc {
|
||||
rustc_codegen_utils::common::SynchronizationScope::Other => SynchronizationScope::Other,
|
||||
rustc_codegen_utils::common::SynchronizationScope::SingleThread =>
|
||||
rustc_codegen_ssa::common::SynchronizationScope::Other => SynchronizationScope::Other,
|
||||
rustc_codegen_ssa::common::SynchronizationScope::SingleThread =>
|
||||
SynchronizationScope::SingleThread,
|
||||
rustc_codegen_utils::common::SynchronizationScope::CrossThread =>
|
||||
rustc_codegen_ssa::common::SynchronizationScope::CrossThread =>
|
||||
SynchronizationScope::CrossThread,
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ use rustc_target::abi::call::ArgType;
|
||||
use base;
|
||||
use builder::MemFlags;
|
||||
use common;
|
||||
use rustc_codegen_utils::common::IntPredicate;
|
||||
use rustc_codegen_ssa::common::IntPredicate;
|
||||
use meth;
|
||||
use monomorphize;
|
||||
|
||||
|
@ -13,7 +13,7 @@ use rustc::ty::layout::{self, Align, TyLayout, LayoutOf, VariantIdx, HasTyCtxt};
|
||||
use rustc::mir;
|
||||
use rustc::mir::tcx::PlaceTy;
|
||||
use builder::MemFlags;
|
||||
use rustc_codegen_utils::common::IntPredicate;
|
||||
use rustc_codegen_ssa::common::IntPredicate;
|
||||
use type_of::LayoutLlvmExt;
|
||||
use glue;
|
||||
|
||||
|
@ -20,7 +20,7 @@ use base;
|
||||
use builder::MemFlags;
|
||||
use callee;
|
||||
use common;
|
||||
use rustc_codegen_utils::common::{RealPredicate, IntPredicate};
|
||||
use rustc_codegen_ssa::common::{RealPredicate, IntPredicate};
|
||||
use monomorphize;
|
||||
use type_of::LayoutLlvmExt;
|
||||
|
||||
|
@ -27,8 +27,8 @@ use rustc::ty::layout::TyLayout;
|
||||
use rustc_target::abi::call::{CastTarget, FnType, Reg};
|
||||
use rustc_data_structures::small_c_str::SmallCStr;
|
||||
use common;
|
||||
use rustc_codegen_utils;
|
||||
use rustc_codegen_utils::common::TypeKind;
|
||||
use rustc_codegen_ssa;
|
||||
use rustc_codegen_ssa::common::TypeKind;
|
||||
use type_of::LayoutLlvmExt;
|
||||
use abi::{LlvmType, FnTypeExt};
|
||||
|
||||
@ -364,15 +364,15 @@ impl DerivedTypeMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||
}
|
||||
|
||||
fn type_needs_drop(&self, ty: Ty<'tcx>) -> bool {
|
||||
rustc_codegen_utils::common::type_needs_drop(self.tcx(), ty)
|
||||
rustc_codegen_ssa::common::type_needs_drop(self.tcx(), ty)
|
||||
}
|
||||
|
||||
fn type_is_sized(&self, ty: Ty<'tcx>) -> bool {
|
||||
rustc_codegen_utils::common::type_is_sized(self.tcx(), ty)
|
||||
rustc_codegen_ssa::common::type_is_sized(self.tcx(), ty)
|
||||
}
|
||||
|
||||
fn type_is_freeze(&self, ty: Ty<'tcx>) -> bool {
|
||||
rustc_codegen_utils::common::type_is_freeze(self.tcx(), ty)
|
||||
rustc_codegen_ssa::common::type_is_freeze(self.tcx(), ty)
|
||||
}
|
||||
|
||||
fn type_has_metadata(&self, ty: Ty<'tcx>) -> bool {
|
||||
|
11
src/librustc_codegen_ssa/Cargo.toml
Normal file
11
src/librustc_codegen_ssa/Cargo.toml
Normal file
@ -0,0 +1,11 @@
|
||||
[package]
|
||||
authors = ["The Rust Project Developers"]
|
||||
name = "rustc_codegen_ssa"
|
||||
version = "0.0.0"
|
||||
|
||||
[lib]
|
||||
name = "rustc_codegen_ssa"
|
||||
path = "lib.rs"
|
||||
test = false
|
||||
|
||||
[dependencies]
|
113
src/librustc_codegen_ssa/lib.rs
Normal file
113
src/librustc_codegen_ssa/lib.rs
Normal file
@ -0,0 +1,113 @@
|
||||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
//! # Note
|
||||
//!
|
||||
//! This API is completely unstable and subject to change.
|
||||
|
||||
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
|
||||
html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
|
||||
#![feature(box_patterns)]
|
||||
#![feature(box_syntax)]
|
||||
#![feature(custom_attribute)]
|
||||
#![feature(nll)]
|
||||
#![allow(unused_attributes)]
|
||||
#![allow(dead_code)]
|
||||
#![feature(quote)]
|
||||
#![feature(rustc_diagnostic_macros)]
|
||||
|
||||
#![recursion_limit="256"]
|
||||
|
||||
extern crate rustc;
|
||||
extern crate rustc_target;
|
||||
extern crate rustc_mir;
|
||||
extern crate syntax;
|
||||
extern crate syntax_pos;
|
||||
extern crate rustc_data_structures;
|
||||
|
||||
use std::path::PathBuf;
|
||||
use rustc::dep_graph::WorkProduct;
|
||||
use rustc::session::config::{OutputFilenames, OutputType};
|
||||
|
||||
pub mod common;
|
||||
pub mod interfaces;
|
||||
|
||||
pub struct ModuleCodegen<M> {
|
||||
/// The name of the module. When the crate may be saved between
|
||||
/// compilations, incremental compilation requires that name be
|
||||
/// unique amongst **all** crates. Therefore, it should contain
|
||||
/// something unique to this crate (e.g., a module path) as well
|
||||
/// as the crate name and disambiguator.
|
||||
/// We currently generate these names via CodegenUnit::build_cgu_name().
|
||||
pub name: String,
|
||||
pub module_llvm: M,
|
||||
pub kind: ModuleKind,
|
||||
}
|
||||
|
||||
pub const RLIB_BYTECODE_EXTENSION: &str = "bc.z";
|
||||
|
||||
impl<M> ModuleCodegen<M> {
|
||||
pub fn into_compiled_module(self,
|
||||
emit_obj: bool,
|
||||
emit_bc: bool,
|
||||
emit_bc_compressed: bool,
|
||||
outputs: &OutputFilenames) -> CompiledModule {
|
||||
let object = if emit_obj {
|
||||
Some(outputs.temp_path(OutputType::Object, Some(&self.name)))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let bytecode = if emit_bc {
|
||||
Some(outputs.temp_path(OutputType::Bitcode, Some(&self.name)))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let bytecode_compressed = if emit_bc_compressed {
|
||||
Some(outputs.temp_path(OutputType::Bitcode, Some(&self.name))
|
||||
.with_extension(RLIB_BYTECODE_EXTENSION))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
CompiledModule {
|
||||
name: self.name.clone(),
|
||||
kind: self.kind,
|
||||
object,
|
||||
bytecode,
|
||||
bytecode_compressed,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct CompiledModule {
|
||||
pub name: String,
|
||||
pub kind: ModuleKind,
|
||||
pub object: Option<PathBuf>,
|
||||
pub bytecode: Option<PathBuf>,
|
||||
pub bytecode_compressed: Option<PathBuf>,
|
||||
}
|
||||
|
||||
pub struct CachedModuleCodegen {
|
||||
pub name: String,
|
||||
pub source: WorkProduct,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
pub enum ModuleKind {
|
||||
Regular,
|
||||
Metadata,
|
||||
Allocator,
|
||||
}
|
||||
|
||||
|
||||
__build_diagnostic_array! { librustc_codegen_ssa, DIAGNOSTICS }
|
@ -47,86 +47,14 @@ use std::path::PathBuf;
|
||||
|
||||
use rustc::session::Session;
|
||||
use rustc::ty::TyCtxt;
|
||||
use rustc::dep_graph::WorkProduct;
|
||||
use rustc::session::config::{OutputFilenames, OutputType};
|
||||
|
||||
pub mod command;
|
||||
pub mod interfaces;
|
||||
pub mod link;
|
||||
pub mod linker;
|
||||
pub mod codegen_backend;
|
||||
pub mod symbol_export;
|
||||
pub mod symbol_names;
|
||||
pub mod symbol_names_test;
|
||||
pub mod common;
|
||||
|
||||
pub struct ModuleCodegen<M> {
|
||||
/// The name of the module. When the crate may be saved between
|
||||
/// compilations, incremental compilation requires that name be
|
||||
/// unique amongst **all** crates. Therefore, it should contain
|
||||
/// something unique to this crate (e.g., a module path) as well
|
||||
/// as the crate name and disambiguator.
|
||||
/// We currently generate these names via CodegenUnit::build_cgu_name().
|
||||
pub name: String,
|
||||
pub module_llvm: M,
|
||||
pub kind: ModuleKind,
|
||||
}
|
||||
|
||||
pub const RLIB_BYTECODE_EXTENSION: &str = "bc.z";
|
||||
|
||||
impl<M> ModuleCodegen<M> {
|
||||
pub fn into_compiled_module(self,
|
||||
emit_obj: bool,
|
||||
emit_bc: bool,
|
||||
emit_bc_compressed: bool,
|
||||
outputs: &OutputFilenames) -> CompiledModule {
|
||||
let object = if emit_obj {
|
||||
Some(outputs.temp_path(OutputType::Object, Some(&self.name)))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let bytecode = if emit_bc {
|
||||
Some(outputs.temp_path(OutputType::Bitcode, Some(&self.name)))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let bytecode_compressed = if emit_bc_compressed {
|
||||
Some(outputs.temp_path(OutputType::Bitcode, Some(&self.name))
|
||||
.with_extension(RLIB_BYTECODE_EXTENSION))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
CompiledModule {
|
||||
name: self.name.clone(),
|
||||
kind: self.kind,
|
||||
object,
|
||||
bytecode,
|
||||
bytecode_compressed,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct CompiledModule {
|
||||
pub name: String,
|
||||
pub kind: ModuleKind,
|
||||
pub object: Option<PathBuf>,
|
||||
pub bytecode: Option<PathBuf>,
|
||||
pub bytecode_compressed: Option<PathBuf>,
|
||||
}
|
||||
|
||||
pub struct CachedModuleCodegen {
|
||||
pub name: String,
|
||||
pub source: WorkProduct,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
pub enum ModuleKind {
|
||||
Regular,
|
||||
Metadata,
|
||||
Allocator,
|
||||
}
|
||||
|
||||
/// check for the #[rustc_error] annotation, which forces an
|
||||
/// error in codegen. This is used to write compile-fail tests
|
||||
|
Loading…
Reference in New Issue
Block a user