about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDenis Merigoux <denis.merigoux@gmail.com>2018-08-30 17:50:28 +0200
committerEduard-Mihai Burtescu <edy.burt@gmail.com>2018-11-16 14:11:59 +0200
commit5f28e0a0b627c2e20689906db8475e2e7d133672 (patch)
tree19941cf1df88637f27e0218ce08ffe691f026b4e
parent3e77f2fc4f679792bc9579fb9716c3a72fd1397b (diff)
downloadrust-5f28e0a0b627c2e20689906db8475e2e7d133672.tar.gz
rust-5f28e0a0b627c2e20689906db8475e2e7d133672.zip
Added definition of type trait
-rw-r--r--src/librustc_codegen_llvm/back/write.rs1
-rw-r--r--src/librustc_codegen_llvm/builder.rs1
-rw-r--r--src/librustc_codegen_llvm/common.rs1
-rw-r--r--src/librustc_codegen_llvm/interfaces/backend.rs3
-rw-r--r--src/librustc_codegen_llvm/interfaces/mod.rs2
-rw-r--r--src/librustc_codegen_llvm/interfaces/type_.rs43
-rw-r--r--src/librustc_codegen_llvm/lib.rs1
7 files changed, 51 insertions, 1 deletions
diff --git a/src/librustc_codegen_llvm/back/write.rs b/src/librustc_codegen_llvm/back/write.rs
index 24f58ac59c1..99921ac7eb8 100644
--- a/src/librustc_codegen_llvm/back/write.rs
+++ b/src/librustc_codegen_llvm/back/write.rs
@@ -434,6 +434,7 @@ impl<'ll> Backend for CodegenContext<'ll> {
     type BasicBlock = &'ll BasicBlock;
     type Type = &'ll Type;
     type Context = &'ll llvm::Context;
+    type TypeKind = llvm::TypeKind;
 }
 
 impl CommonWriteMethods for CodegenContext<'ll> {
diff --git a/src/librustc_codegen_llvm/builder.rs b/src/librustc_codegen_llvm/builder.rs
index d74653310e3..0c8ff0c9d92 100644
--- a/src/librustc_codegen_llvm/builder.rs
+++ b/src/librustc_codegen_llvm/builder.rs
@@ -60,6 +60,7 @@ impl Backend for Builder<'a, 'll, 'tcx>  {
         type Value = &'ll Value;
         type BasicBlock = &'ll BasicBlock;
         type Type = &'ll type_::Type;
+        type TypeKind = llvm::TypeKind;
         type Context = &'ll llvm::Context;
 }
 
diff --git a/src/librustc_codegen_llvm/common.rs b/src/librustc_codegen_llvm/common.rs
index 569fbc9f081..dc46d23dd97 100644
--- a/src/librustc_codegen_llvm/common.rs
+++ b/src/librustc_codegen_llvm/common.rs
@@ -197,6 +197,7 @@ impl Backend for CodegenCx<'ll, 'tcx> {
     type Value = &'ll Value;
     type BasicBlock = &'ll BasicBlock;
     type Type = &'ll Type;
+    type TypeKind = llvm::TypeKind;
     type Context = &'ll llvm::Context;
 }
 
diff --git a/src/librustc_codegen_llvm/interfaces/backend.rs b/src/librustc_codegen_llvm/interfaces/backend.rs
index 6db014023e9..a2c80ef82c7 100644
--- a/src/librustc_codegen_llvm/interfaces/backend.rs
+++ b/src/librustc_codegen_llvm/interfaces/backend.rs
@@ -13,6 +13,7 @@ use std::fmt::Debug;
 pub trait Backend {
     type Value: Debug + PartialEq;
     type BasicBlock;
-    type Type;
+    type Type : Debug + PartialEq;
+    type TypeKind;
     type Context;
 }
diff --git a/src/librustc_codegen_llvm/interfaces/mod.rs b/src/librustc_codegen_llvm/interfaces/mod.rs
index e8ece54718e..3e9c7eb881d 100644
--- a/src/librustc_codegen_llvm/interfaces/mod.rs
+++ b/src/librustc_codegen_llvm/interfaces/mod.rs
@@ -11,7 +11,9 @@
 mod builder;
 mod backend;
 mod common;
+mod type_;
 
 pub use self::builder::BuilderMethods;
 pub use self::backend::Backend;
 pub use self::common::{CommonMethods, CommonWriteMethods};
+pub use self::type_::TypeMethods;
diff --git a/src/librustc_codegen_llvm/interfaces/type_.rs b/src/librustc_codegen_llvm/interfaces/type_.rs
new file mode 100644
index 00000000000..2afa85accf9
--- /dev/null
+++ b/src/librustc_codegen_llvm/interfaces/type_.rs
@@ -0,0 +1,43 @@
+// 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.
+
+use super::backend::Backend;
+
+pub trait TypeMethods : Backend {
+    fn void(&self) -> Self::Type;
+    fn metadata(&self) -> Self::Type;
+    fn i1(&self) -> Self::Type;
+    fn i8(&self) -> Self::Type;
+    fn i16(&self) -> Self::Type;
+    fn i32(&self) -> Self::Type;
+    fn i64(&self) -> Self::Type;
+    fn i128(&self) -> Self::Type;
+    fn ix(&self, num_bites: u64) -> Self::Type;
+    fn f32(&self) -> Self::Type;
+    fn f64(&self) -> Self::Type;
+    fn bool(&self) -> Self::Type;
+    fn char(&self) -> Self::Type;
+    fn i8p(&self) -> Self::Type;
+
+    fn func(&self, args: &[Self::Type], ret: Self::Type) -> Self::Type;
+    fn variadic_func(&self, args: &[Self::Type]) -> Self::Type;
+    fn struct_(&self, els: &[Self::Type], packed: bool) -> Self::Type;
+    fn named_struct(&self, name: &str) -> Self::Type;
+    fn array(&self, ty: Self::Type, len: u64) -> Self::Type;
+    fn vector(&self, ty: Self::Type, len: u64) -> Self::Type;
+    fn kind(&self, ty: Self::Type) -> Self::TypeKind;
+    fn set_struct_body(&self, els: &[Self::Type], packed: bool);
+    fn ptr_to(&self, ty: Self::Type) -> Self::Type;
+    fn element_type(&self, ty: Self::Type) -> Self::Type;
+    fn vector_length(&self, ty: Self::Type) -> usize;
+    fn func_params(&self, ty: Self::Type) -> Vec<Self::Type>;
+    fn float_width(&self, ty: Self::Type) -> usize;
+    fn int_width(&self, ty: Self::Type) -> usize;
+}
diff --git a/src/librustc_codegen_llvm/lib.rs b/src/librustc_codegen_llvm/lib.rs
index e228dc044f1..4e80fe0b343 100644
--- a/src/librustc_codegen_llvm/lib.rs
+++ b/src/librustc_codegen_llvm/lib.rs
@@ -330,6 +330,7 @@ impl<'ll> Backend for ModuleLlvm<'ll> {
     type Value = &'ll Value;
     type BasicBlock = &'ll llvm::BasicBlock;
     type Type = &'ll Type;
+    type TypeKind = llvm::TypeKind;
     type Context = &'ll llvm::Context;
 }