about summary refs log tree commit diff
path: root/src/librustc_codegen_llvm
diff options
context:
space:
mode:
authorDenis Merigoux <denis.merigoux@gmail.com>2018-08-28 11:40:34 +0200
committerEduard-Mihai Burtescu <edy.burt@gmail.com>2018-11-16 14:11:59 +0200
commit3889c2dcfb2968226bad79b4c04b987e031f9c0d (patch)
treeaae77a86cc7de2e6cb38d53a68e1daf7ea509f35 /src/librustc_codegen_llvm
parentd577ec7e5f942a06d9159a5dff4ab8a632ed105d (diff)
downloadrust-3889c2dcfb2968226bad79b4c04b987e031f9c0d.tar.gz
rust-3889c2dcfb2968226bad79b4c04b987e031f9c0d.zip
New Backend trait containing associated types
Diffstat (limited to 'src/librustc_codegen_llvm')
-rw-r--r--src/librustc_codegen_llvm/builder.rs12
-rw-r--r--src/librustc_codegen_llvm/interfaces/backend.rs15
-rw-r--r--src/librustc_codegen_llvm/interfaces/builder.rs6
-rw-r--r--src/librustc_codegen_llvm/interfaces/mod.rs2
4 files changed, 26 insertions, 9 deletions
diff --git a/src/librustc_codegen_llvm/builder.rs b/src/librustc_codegen_llvm/builder.rs
index 6decc185614..28901071339 100644
--- a/src/librustc_codegen_llvm/builder.rs
+++ b/src/librustc_codegen_llvm/builder.rs
@@ -18,7 +18,7 @@ use rustc::ty::TyCtxt;
 use rustc::ty::layout::{Align, Size};
 use rustc::session::{config, Session};
 use rustc_data_structures::small_c_str::SmallCStr;
-use interfaces::BuilderMethods;
+use interfaces::{BuilderMethods, Backend};
 use syntax;
 
 use std::borrow::Cow;
@@ -55,11 +55,13 @@ bitflags! {
     }
 }
 
-impl BuilderMethods<'a, 'll, 'tcx> for Builder<'a, 'll, 'tcx> {
-    type Value = &'ll Value;
-    type BasicBlock = &'ll BasicBlock;
-    type Type = &'ll type_::Type;
+impl Backend for Builder<'a, 'll, 'tcx>  {
+        type Value = &'ll Value;
+        type BasicBlock = &'ll BasicBlock;
+        type Type = &'ll type_::Type;
+}
 
+impl BuilderMethods<'a, 'll, 'tcx> for Builder<'a, 'll, 'tcx> {
     fn new_block<'b>(
         cx: &'a CodegenCx<'ll, 'tcx>,
         llfn: &'ll Value,
diff --git a/src/librustc_codegen_llvm/interfaces/backend.rs b/src/librustc_codegen_llvm/interfaces/backend.rs
new file mode 100644
index 00000000000..b2a6bf2dd8c
--- /dev/null
+++ b/src/librustc_codegen_llvm/interfaces/backend.rs
@@ -0,0 +1,15 @@
+// Copyright 2018 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.
+
+pub trait Backend {
+    type Value;
+    type BasicBlock;
+    type Type;
+}
diff --git a/src/librustc_codegen_llvm/interfaces/builder.rs b/src/librustc_codegen_llvm/interfaces/builder.rs
index 994ddd65d3d..c43e41724ee 100644
--- a/src/librustc_codegen_llvm/interfaces/builder.rs
+++ b/src/librustc_codegen_llvm/interfaces/builder.rs
@@ -14,6 +14,7 @@ use rustc::ty::TyCtxt;
 use rustc::ty::layout::{Align, Size};
 use rustc::session::Session;
 use builder::MemFlags;
+use super::backend::Backend;
 
 use std::borrow::Cow;
 use std::ops::Range;
@@ -21,10 +22,7 @@ use syntax::ast::AsmDialect;
 
 
 
-pub trait BuilderMethods<'a, 'll :'a, 'tcx: 'll> {
-    type Value;
-    type BasicBlock;
-    type Type;
+pub trait BuilderMethods<'a, 'll :'a, 'tcx: 'll> : Backend {
 
     fn new_block<'b>(
         cx: &'a CodegenCx<'ll, 'tcx, Self::Value>,
diff --git a/src/librustc_codegen_llvm/interfaces/mod.rs b/src/librustc_codegen_llvm/interfaces/mod.rs
index d0cd8e6a696..b9a356874ba 100644
--- a/src/librustc_codegen_llvm/interfaces/mod.rs
+++ b/src/librustc_codegen_llvm/interfaces/mod.rs
@@ -9,5 +9,7 @@
 // except according to those terms.
 
 mod builder;
+mod backend;
 
 pub use self::builder::BuilderMethods;
+pub use self::backend::Backend;