about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDenis Merigoux <denis.merigoux@gmail.com>2018-10-01 18:07:04 +0200
committerEduard-Mihai Burtescu <edy.burt@gmail.com>2018-11-16 14:55:42 +0200
commitc9f26c21551fdbb8156fd86f00e5e8fecc6c1189 (patch)
tree8f0dca5f6a905d25f671dfe526096a0f55313d92
parentb02e5cce169212bd4efe5857bc719d6ed47a53fc (diff)
downloadrust-c9f26c21551fdbb8156fd86f00e5e8fecc6c1189.tar.gz
rust-c9f26c21551fdbb8156fd86f00e5e8fecc6c1189.zip
Beginning of moving all backend-agnostic code to rustc_codegen_ssa
-rw-r--r--src/Cargo.lock5
-rw-r--r--src/librustc_codegen_llvm/Cargo.toml1
-rw-r--r--src/librustc_codegen_llvm/back/lto.rs2
-rw-r--r--src/librustc_codegen_llvm/back/write.rs2
-rw-r--r--src/librustc_codegen_llvm/base.rs4
-rw-r--r--src/librustc_codegen_llvm/builder.rs20
-rw-r--r--src/librustc_codegen_llvm/common.rs2
-rw-r--r--src/librustc_codegen_llvm/glue.rs2
-rw-r--r--src/librustc_codegen_llvm/interfaces/builder.rs2
-rw-r--r--src/librustc_codegen_llvm/interfaces/mod.rs2
-rw-r--r--src/librustc_codegen_llvm/interfaces/type_.rs2
-rw-r--r--src/librustc_codegen_llvm/intrinsic.rs6
-rw-r--r--src/librustc_codegen_llvm/lib.rs3
-rw-r--r--src/librustc_codegen_llvm/llvm/ffi.rs142
-rw-r--r--src/librustc_codegen_llvm/mir/block.rs2
-rw-r--r--src/librustc_codegen_llvm/mir/place.rs2
-rw-r--r--src/librustc_codegen_llvm/mir/rvalue.rs2
-rw-r--r--src/librustc_codegen_llvm/type_.rs10
-rw-r--r--src/librustc_codegen_ssa/Cargo.toml11
-rw-r--r--src/librustc_codegen_ssa/common.rs (renamed from src/librustc_codegen_utils/common.rs)0
-rw-r--r--src/librustc_codegen_ssa/interfaces/backend.rs (renamed from src/librustc_codegen_utils/interfaces/backend.rs)0
-rw-r--r--src/librustc_codegen_ssa/interfaces/mod.rs (renamed from src/librustc_codegen_utils/interfaces/mod.rs)0
-rw-r--r--src/librustc_codegen_ssa/lib.rs113
-rw-r--r--src/librustc_codegen_utils/lib.rs72
24 files changed, 233 insertions, 174 deletions
diff --git a/src/Cargo.lock b/src/Cargo.lock
index a0bb92867ff..031dac88df1 100644
--- a/src/Cargo.lock
+++ b/src/Cargo.lock
@@ -2122,10 +2122,15 @@ 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"
 dependencies = [
diff --git a/src/librustc_codegen_llvm/Cargo.toml b/src/librustc_codegen_llvm/Cargo.toml
index b711502b14b..34017009c28 100644
--- a/src/librustc_codegen_llvm/Cargo.toml
+++ b/src/librustc_codegen_llvm/Cargo.toml
@@ -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"
 
diff --git a/src/librustc_codegen_llvm/back/lto.rs b/src/librustc_codegen_llvm/back/lto.rs
index de69531fa8b..0f62ea6d357 100644
--- a/src/librustc_codegen_llvm/back/lto.rs
+++ b/src/librustc_codegen_llvm/back/lto.rs
@@ -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;
 
diff --git a/src/librustc_codegen_llvm/back/write.rs b/src/librustc_codegen_llvm/back/write.rs
index d96dd93e3e2..60cfe203e40 100644
--- a/src/librustc_codegen_llvm/back/write.rs
+++ b/src/librustc_codegen_llvm/back/write.rs
@@ -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;
diff --git a/src/librustc_codegen_llvm/base.rs b/src/librustc_codegen_llvm/base.rs
index d8f5c25714f..4e69bf8e8b3 100644
--- a/src/librustc_codegen_llvm/base.rs
+++ b/src/librustc_codegen_llvm/base.rs
@@ -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;
diff --git a/src/librustc_codegen_llvm/builder.rs b/src/librustc_codegen_llvm/builder.rs
index ae0d89a5609..efd2e146f35 100644
--- a/src/librustc_codegen_llvm/builder.rs
+++ b/src/librustc_codegen_llvm/builder.rs
@@ -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(
diff --git a/src/librustc_codegen_llvm/common.rs b/src/librustc_codegen_llvm/common.rs
index 13e71b8ab04..7dc4b00f794 100644
--- a/src/librustc_codegen_llvm/common.rs
+++ b/src/librustc_codegen_llvm/common.rs
@@ -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};
 
diff --git a/src/librustc_codegen_llvm/glue.rs b/src/librustc_codegen_llvm/glue.rs
index e641c153023..5e1a03031dd 100644
--- a/src/librustc_codegen_llvm/glue.rs
+++ b/src/librustc_codegen_llvm/glue.rs
@@ -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};
diff --git a/src/librustc_codegen_llvm/interfaces/builder.rs b/src/librustc_codegen_llvm/interfaces/builder.rs
index 74a31975a39..2e1abb12e16 100644
--- a/src/librustc_codegen_llvm/interfaces/builder.rs
+++ b/src/librustc_codegen_llvm/interfaces/builder.rs
@@ -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,
 };
 
diff --git a/src/librustc_codegen_llvm/interfaces/mod.rs b/src/librustc_codegen_llvm/interfaces/mod.rs
index 61aa7e29326..0547ce7ce4c 100644
--- a/src/librustc_codegen_llvm/interfaces/mod.rs
+++ b/src/librustc_codegen_llvm/interfaces/mod.rs
@@ -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>
diff --git a/src/librustc_codegen_llvm/interfaces/type_.rs b/src/librustc_codegen_llvm/interfaces/type_.rs
index 775ca2d2d02..fe4b7a0b852 100644
--- a/src/librustc_codegen_llvm/interfaces/type_.rs
+++ b/src/librustc_codegen_llvm/interfaces/type_.rs
@@ -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;
diff --git a/src/librustc_codegen_llvm/intrinsic.rs b/src/librustc_codegen_llvm/intrinsic.rs
index 07b5017e4c8..c7b36cc5891 100644
--- a/src/librustc_codegen_llvm/intrinsic.rs
+++ b/src/librustc_codegen_llvm/intrinsic.rs
@@ -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();
diff --git a/src/librustc_codegen_llvm/lib.rs b/src/librustc_codegen_llvm/lib.rs
index e8f488ab04c..8d5214ce376 100644
--- a/src/librustc_codegen_llvm/lib.rs
+++ b/src/librustc_codegen_llvm/lib.rs
@@ -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;
 
diff --git a/src/librustc_codegen_llvm/llvm/ffi.rs b/src/librustc_codegen_llvm/llvm/ffi.rs
index 06c60dba2f5..f1a966d7654 100644
--- a/src/librustc_codegen_llvm/llvm/ffi.rs
+++ b/src/librustc_codegen_llvm/llvm/ffi.rs
@@ -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,
         }
     }
diff --git a/src/librustc_codegen_llvm/mir/block.rs b/src/librustc_codegen_llvm/mir/block.rs
index 02d532f8c0d..d72fdb2fb23 100644
--- a/src/librustc_codegen_llvm/mir/block.rs
+++ b/src/librustc_codegen_llvm/mir/block.rs
@@ -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;
 
diff --git a/src/librustc_codegen_llvm/mir/place.rs b/src/librustc_codegen_llvm/mir/place.rs
index 22ba0fda83b..8fa35d3aaf2 100644
--- a/src/librustc_codegen_llvm/mir/place.rs
+++ b/src/librustc_codegen_llvm/mir/place.rs
@@ -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;
 
diff --git a/src/librustc_codegen_llvm/mir/rvalue.rs b/src/librustc_codegen_llvm/mir/rvalue.rs
index f1b07c39178..9870c93a508 100644
--- a/src/librustc_codegen_llvm/mir/rvalue.rs
+++ b/src/librustc_codegen_llvm/mir/rvalue.rs
@@ -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;
 
diff --git a/src/librustc_codegen_llvm/type_.rs b/src/librustc_codegen_llvm/type_.rs
index 56dac0175e5..00dd3be8c9f 100644
--- a/src/librustc_codegen_llvm/type_.rs
+++ b/src/librustc_codegen_llvm/type_.rs
@@ -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 {
diff --git a/src/librustc_codegen_ssa/Cargo.toml b/src/librustc_codegen_ssa/Cargo.toml
new file mode 100644
index 00000000000..ae187c5e3e0
--- /dev/null
+++ b/src/librustc_codegen_ssa/Cargo.toml
@@ -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]
diff --git a/src/librustc_codegen_utils/common.rs b/src/librustc_codegen_ssa/common.rs
index 3f4389913ae..3f4389913ae 100644
--- a/src/librustc_codegen_utils/common.rs
+++ b/src/librustc_codegen_ssa/common.rs
diff --git a/src/librustc_codegen_utils/interfaces/backend.rs b/src/librustc_codegen_ssa/interfaces/backend.rs
index 3cdb1c6a0dd..3cdb1c6a0dd 100644
--- a/src/librustc_codegen_utils/interfaces/backend.rs
+++ b/src/librustc_codegen_ssa/interfaces/backend.rs
diff --git a/src/librustc_codegen_utils/interfaces/mod.rs b/src/librustc_codegen_ssa/interfaces/mod.rs
index f958dbabe68..f958dbabe68 100644
--- a/src/librustc_codegen_utils/interfaces/mod.rs
+++ b/src/librustc_codegen_ssa/interfaces/mod.rs
diff --git a/src/librustc_codegen_ssa/lib.rs b/src/librustc_codegen_ssa/lib.rs
new file mode 100644
index 00000000000..e8e6222f87c
--- /dev/null
+++ b/src/librustc_codegen_ssa/lib.rs
@@ -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 }
diff --git a/src/librustc_codegen_utils/lib.rs b/src/librustc_codegen_utils/lib.rs
index 4fb182e4f05..8d85c6691c2 100644
--- a/src/librustc_codegen_utils/lib.rs
+++ b/src/librustc_codegen_utils/lib.rs
@@ -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