Added definition of type trait
This commit is contained in:
parent
3e77f2fc4f
commit
5f28e0a0b6
@ -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> {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
pub trait Backend {
|
||||
type Value: Debug + PartialEq;
|
||||
type BasicBlock;
|
||||
type Type;
|
||||
type Type : Debug + PartialEq;
|
||||
type TypeKind;
|
||||
type Context;
|
||||
}
|
||||
|
@ -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;
|
||||
|
43
src/librustc_codegen_llvm/interfaces/type_.rs
Normal file
43
src/librustc_codegen_llvm/interfaces/type_.rs
Normal file
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user