Skip to content

Commit c6affbe

Browse files
committed
Added definition of type trait
1 parent 4963706 commit c6affbe

File tree

7 files changed

+51
-1
lines changed

7 files changed

+51
-1
lines changed

src/librustc_codegen_llvm/back/write.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ impl<'ll> Backend for CodegenContext<'ll> {
430430
type BasicBlock = &'ll BasicBlock;
431431
type Type = &'ll Type;
432432
type Context = &'ll llvm::Context;
433+
type TypeKind = llvm::TypeKind;
433434
}
434435

435436
impl CommonWriteMethods for CodegenContext<'ll> {

src/librustc_codegen_llvm/builder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ impl Backend for Builder<'a, 'll, 'tcx, &'ll Value> {
6060
type Value = &'ll Value;
6161
type BasicBlock = &'ll BasicBlock;
6262
type Type = &'ll type_::Type;
63+
type TypeKind = llvm::TypeKind;
6364
type Context = &'ll llvm::Context;
6465
}
6566

src/librustc_codegen_llvm/common.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ impl Backend for CodegenCx<'ll, 'tcx, &'ll Value> {
199199
type Value = &'ll Value;
200200
type BasicBlock = &'ll BasicBlock;
201201
type Type = &'ll Type;
202+
type TypeKind = llvm::TypeKind;
202203
type Context = &'ll llvm::Context;
203204
}
204205

src/librustc_codegen_llvm/interfaces/backend.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use std::fmt::Debug;
1313
pub trait Backend {
1414
type Value : Debug + PartialEq;
1515
type BasicBlock;
16-
type Type;
16+
type Type : Debug + PartialEq;
17+
type TypeKind;
1718
type Context;
1819
}

src/librustc_codegen_llvm/interfaces/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
mod builder;
1212
mod backend;
1313
mod common;
14+
mod type_;
1415

1516
pub use self::builder::BuilderMethods;
1617
pub use self::backend::Backend;
1718
pub use self::common::{CommonMethods, CommonWriteMethods};
19+
pub use self::type_::TypeMethods;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use super::backend::Backend;
12+
13+
pub trait TypeMethods : Backend {
14+
fn void(&self) -> Self::Type;
15+
fn metadata(&self) -> Self::Type;
16+
fn i1(&self) -> Self::Type;
17+
fn i8(&self) -> Self::Type;
18+
fn i16(&self) -> Self::Type;
19+
fn i32(&self) -> Self::Type;
20+
fn i64(&self) -> Self::Type;
21+
fn i128(&self) -> Self::Type;
22+
fn ix(&self, num_bites: u64) -> Self::Type;
23+
fn f32(&self) -> Self::Type;
24+
fn f64(&self) -> Self::Type;
25+
fn bool(&self) -> Self::Type;
26+
fn char(&self) -> Self::Type;
27+
fn i8p(&self) -> Self::Type;
28+
29+
fn func(&self, args: &[Self::Type], ret: Self::Type) -> Self::Type;
30+
fn variadic_func(&self, args: &[Self::Type]) -> Self::Type;
31+
fn struct_(&self, els: &[Self::Type], packed: bool) -> Self::Type;
32+
fn named_struct(&self, name: &str) -> Self::Type;
33+
fn array(&self, ty: Self::Type, len: u64) -> Self::Type;
34+
fn vector(&self, ty: Self::Type, len: u64) -> Self::Type;
35+
fn kind(&self, ty: Self::Type) -> Self::TypeKind;
36+
fn set_struct_body(&self, els: &[Self::Type], packed: bool);
37+
fn ptr_to(&self, ty: Self::Type) -> Self::Type;
38+
fn element_type(&self, ty: Self::Type) -> Self::Type;
39+
fn vector_length(&self, ty: Self::Type) -> usize;
40+
fn func_params(&self, ty: Self::Type) -> Vec<Self::Type>;
41+
fn float_width(&self, ty: Self::Type) -> usize;
42+
fn int_width(&self, ty: Self::Type) -> usize;
43+
}

src/librustc_codegen_llvm/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ impl<'ll> Backend for ModuleLlvm<'ll> {
347347
type Value = &'ll Value;
348348
type BasicBlock = &'ll llvm::BasicBlock;
349349
type Type = &'ll Type;
350+
type TypeKind = llvm::TypeKind;
350351
type Context = &'ll llvm::Context;
351352
}
352353

0 commit comments

Comments
 (0)