From d577ec7e5f942a06d9159a5dff4ab8a632ed105d Mon Sep 17 00:00:00 2001 From: Denis Merigoux Date: Tue, 28 Aug 2018 11:11:01 +0200 Subject: New files and folders for traits Moved common enums to common --- src/librustc_codegen_llvm/abi.rs | 2 +- src/librustc_codegen_llvm/asm.rs | 2 +- src/librustc_codegen_llvm/base.rs | 4 +- src/librustc_codegen_llvm/builder.rs | 26 +- src/librustc_codegen_llvm/common.rs | 83 ++++- src/librustc_codegen_llvm/debuginfo/gdb.rs | 2 +- src/librustc_codegen_llvm/debuginfo/mod.rs | 2 +- src/librustc_codegen_llvm/debuginfo/source_loc.rs | 2 +- src/librustc_codegen_llvm/glue.rs | 2 +- src/librustc_codegen_llvm/interfaces/builder.rs | 285 +++++++++++++++++ src/librustc_codegen_llvm/interfaces/mod.rs | 13 + src/librustc_codegen_llvm/intrinsic.rs | 4 +- src/librustc_codegen_llvm/lib.rs | 2 +- src/librustc_codegen_llvm/llvm/ffi.rs | 106 +++---- src/librustc_codegen_llvm/llvm/mod.rs | 4 +- src/librustc_codegen_llvm/meth.rs | 2 +- src/librustc_codegen_llvm/mir/block.rs | 4 +- src/librustc_codegen_llvm/mir/constant.rs | 2 +- src/librustc_codegen_llvm/mir/mod.rs | 2 +- src/librustc_codegen_llvm/mir/operand.rs | 2 +- src/librustc_codegen_llvm/mir/place.rs | 4 +- src/librustc_codegen_llvm/mir/rvalue.rs | 7 +- src/librustc_codegen_llvm/mir/statement.rs | 2 +- src/librustc_codegen_llvm/traits.rs | 366 ---------------------- 24 files changed, 473 insertions(+), 457 deletions(-) create mode 100644 src/librustc_codegen_llvm/interfaces/builder.rs create mode 100644 src/librustc_codegen_llvm/interfaces/mod.rs delete mode 100644 src/librustc_codegen_llvm/traits.rs (limited to 'src/librustc_codegen_llvm') diff --git a/src/librustc_codegen_llvm/abi.rs b/src/librustc_codegen_llvm/abi.rs index f59fa2f1591..5859446d32e 100644 --- a/src/librustc_codegen_llvm/abi.rs +++ b/src/librustc_codegen_llvm/abi.rs @@ -19,7 +19,7 @@ use type_::Type; use type_of::{LayoutLlvmExt, PointerKind}; use value::Value; -use traits::BuilderMethods; +use interfaces::BuilderMethods; use rustc_target::abi::{HasDataLayout, LayoutOf, Size, TyLayout, Abi as LayoutAbi}; use rustc::ty::{self, Ty}; diff --git a/src/librustc_codegen_llvm/asm.rs b/src/librustc_codegen_llvm/asm.rs index 6eedc6d1c2a..5efa4d547ba 100644 --- a/src/librustc_codegen_llvm/asm.rs +++ b/src/librustc_codegen_llvm/asm.rs @@ -16,7 +16,7 @@ use builder::Builder; use value::Value; use rustc::hir; -use traits::BuilderMethods; +use interfaces::BuilderMethods; use mir::place::PlaceRef; use mir::operand::OperandValue; diff --git a/src/librustc_codegen_llvm/base.rs b/src/librustc_codegen_llvm/base.rs index 6c60f9d0ba0..c0e4fc92139 100644 --- a/src/librustc_codegen_llvm/base.rs +++ b/src/librustc_codegen_llvm/base.rs @@ -55,7 +55,7 @@ use builder::{Builder, MemFlags}; use callee; use common::{C_bool, C_bytes_in_context, C_usize}; use rustc_mir::monomorphize::item::DefPathBasedNames; -use common::{C_struct_in_context, C_array, val_ty}; +use common::{C_struct_in_context, C_array, val_ty, IntPredicate, RealPredicate}; use consts; use context::CodegenCx; use debuginfo; @@ -75,7 +75,7 @@ use rustc_data_structures::small_c_str::SmallCStr; use rustc_data_structures::sync::Lrc; use rustc_data_structures::indexed_vec::Idx; -use traits::{IntPredicate, RealPredicate, BuilderMethods}; +use interfaces::BuilderMethods; use std::any::Any; use std::cmp; diff --git a/src/librustc_codegen_llvm/builder.rs b/src/librustc_codegen_llvm/builder.rs index 35d0bb9e054..6decc185614 100644 --- a/src/librustc_codegen_llvm/builder.rs +++ b/src/librustc_codegen_llvm/builder.rs @@ -10,7 +10,7 @@ use llvm::{AtomicRmwBinOp, AtomicOrdering, SynchronizationScope, AsmDialect}; use llvm::{self, False, OperandBundleDef, BasicBlock}; -use common::*; +use common::{self, *}; use type_; use value::Value; use libc::{c_uint, c_char}; @@ -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 traits::{self, BuilderMethods}; +use interfaces::BuilderMethods; use syntax; use std::borrow::Cow; @@ -194,7 +194,7 @@ impl BuilderMethods<'a, 'll, 'tcx> for Builder<'a, 'll, 'tcx> { args: &[&'ll Value], then: &'ll BasicBlock, catch: &'ll BasicBlock, - bundle: Option<&traits::OperandBundleDef<'ll, &'ll Value>>) -> &'ll Value { + bundle: Option<&common::OperandBundleDef<'ll, &'ll Value>>) -> &'ll Value { self.count_insn("invoke"); debug!("Invoke {:?} with args ({:?})", @@ -495,7 +495,7 @@ impl BuilderMethods<'a, 'll, 'tcx> for Builder<'a, 'll, 'tcx> { fn atomic_load( &self, ptr: &'ll Value, - order: traits::AtomicOrdering, + order: common::AtomicOrdering, size: Size, ) -> &'ll Value { self.count_insn("load.atomic"); @@ -582,7 +582,7 @@ impl BuilderMethods<'a, 'll, 'tcx> for Builder<'a, 'll, 'tcx> { } fn atomic_store(&self, val: &'ll Value, ptr: &'ll Value, - order: traits::AtomicOrdering, size: Size) { + order: common::AtomicOrdering, size: Size) { debug!("Store {:?} -> {:?}", val, ptr); self.count_insn("store.atomic"); let ptr = self.check_store(val, ptr); @@ -708,7 +708,7 @@ impl BuilderMethods<'a, 'll, 'tcx> for Builder<'a, 'll, 'tcx> { } /* Comparisons */ - fn icmp(&self, op: traits::IntPredicate, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn icmp(&self, op: IntPredicate, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { self.count_insn("icmp"); let op = llvm::IntPredicate::from_generic(op); unsafe { @@ -716,7 +716,7 @@ impl BuilderMethods<'a, 'll, 'tcx> for Builder<'a, 'll, 'tcx> { } } - fn fcmp(&self, op: traits::RealPredicate, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn fcmp(&self, op: RealPredicate, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { self.count_insn("fcmp"); unsafe { llvm::LLVMBuildFCmp(self.llbuilder, op as c_uint, lhs, rhs, noname()) @@ -1066,8 +1066,8 @@ impl BuilderMethods<'a, 'll, 'tcx> for Builder<'a, 'll, 'tcx> { dst: &'ll Value, cmp: &'ll Value, src: &'ll Value, - order: traits::AtomicOrdering, - failure_order: traits::AtomicOrdering, + order: common::AtomicOrdering, + failure_order: common::AtomicOrdering, weak: bool, ) -> &'ll Value { let weak = if weak { llvm::True } else { llvm::False }; @@ -1085,10 +1085,10 @@ impl BuilderMethods<'a, 'll, 'tcx> for Builder<'a, 'll, 'tcx> { } fn atomic_rmw( &self, - op: traits::AtomicRmwBinOp, + op: common::AtomicRmwBinOp, dst: &'ll Value, src: &'ll Value, - order: traits::AtomicOrdering, + order: common::AtomicOrdering, ) -> &'ll Value { unsafe { llvm::LLVMBuildAtomicRMW( @@ -1101,7 +1101,7 @@ impl BuilderMethods<'a, 'll, 'tcx> for Builder<'a, 'll, 'tcx> { } } - fn atomic_fence(&self, order: traits::AtomicOrdering, scope: traits::SynchronizationScope) { + fn atomic_fence(&self, order: common::AtomicOrdering, scope: common::SynchronizationScope) { unsafe { llvm::LLVMRustBuildAtomicFence( self.llbuilder, @@ -1227,7 +1227,7 @@ impl BuilderMethods<'a, 'll, 'tcx> for Builder<'a, 'll, 'tcx> { } fn call(&self, llfn: &'ll Value, args: &[&'ll Value], - bundle: Option<&traits::OperandBundleDef<'ll, &'ll Value>>) -> &'ll Value { + bundle: Option<&common::OperandBundleDef<'ll, &'ll Value>>) -> &'ll Value { self.count_insn("call"); debug!("Call {:?} with args ({:?})", diff --git a/src/librustc_codegen_llvm/common.rs b/src/librustc_codegen_llvm/common.rs index 9611c0e54b9..88a8080819c 100644 --- a/src/librustc_codegen_llvm/common.rs +++ b/src/librustc_codegen_llvm/common.rs @@ -28,7 +28,7 @@ use value::Value; use rustc::ty::{self, Ty, TyCtxt}; use rustc::ty::layout::{HasDataLayout, LayoutOf}; use rustc::hir; -use traits::{BuilderMethods, OperandBundleDef}; +use interfaces::BuilderMethods; use libc::{c_uint, c_char}; @@ -49,6 +49,87 @@ pub fn type_is_freeze<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bo ty.is_freeze(tcx, ty::ParamEnv::reveal_all(), DUMMY_SP) } +pub struct OperandBundleDef<'a, Value : 'a> { + pub name: &'a str, + pub val: Value +} + +impl OperandBundleDef<'ll, &'ll Value> { + pub fn new(name: &'ll str, val: &'ll Value) -> Self { + OperandBundleDef { + name, + val + } + } +} + +pub enum IntPredicate { + IntEQ, + IntNE, + IntUGT, + IntUGE, + IntULT, + IntULE, + IntSGT, + IntSGE, + IntSLT, + IntSLE +} + +#[allow(dead_code)] +pub enum RealPredicate { + RealPredicateFalse, + RealOEQ, + RealOGT, + RealOGE, + RealOLT, + RealOLE, + RealONE, + RealORD, + RealUNO, + RealUEQ, + RealUGT, + RealUGE, + RealULT, + RealULE, + RealUNE, + RealPredicateTrue +} + +pub enum AtomicRmwBinOp { + AtomicXchg, + AtomicAdd, + AtomicSub, + AtomicAnd, + AtomicNand, + AtomicOr, + AtomicXor, + AtomicMax, + AtomicMin, + AtomicUMax, + AtomicUMin +} + +pub enum AtomicOrdering { + #[allow(dead_code)] + NotAtomic, + Unordered, + Monotonic, + // Consume, // Not specified yet. + Acquire, + Release, + AcquireRelease, + SequentiallyConsistent, +} + +pub enum SynchronizationScope { + // FIXME: figure out if this variant is needed at all. + #[allow(dead_code)] + Other, + SingleThread, + CrossThread, +} + /* * A note on nomenclature of linking: "extern", "foreign", and "upcall". * diff --git a/src/librustc_codegen_llvm/debuginfo/gdb.rs b/src/librustc_codegen_llvm/debuginfo/gdb.rs index 02d3b66c613..c9652824ddb 100644 --- a/src/librustc_codegen_llvm/debuginfo/gdb.rs +++ b/src/librustc_codegen_llvm/debuginfo/gdb.rs @@ -18,7 +18,7 @@ use declare; use rustc::session::config::DebugInfo; use type_::Type; use value::Value; -use traits::BuilderMethods; +use interfaces::BuilderMethods; use syntax::attr; diff --git a/src/librustc_codegen_llvm/debuginfo/mod.rs b/src/librustc_codegen_llvm/debuginfo/mod.rs index bce722b4b43..b7f70a67491 100644 --- a/src/librustc_codegen_llvm/debuginfo/mod.rs +++ b/src/librustc_codegen_llvm/debuginfo/mod.rs @@ -45,7 +45,7 @@ use syntax_pos::{self, Span, Pos}; use syntax::ast; use syntax::symbol::{Symbol, InternedString}; use rustc::ty::layout::{self, LayoutOf}; -use traits::BuilderMethods; +use interfaces::BuilderMethods; pub mod gdb; mod utils; diff --git a/src/librustc_codegen_llvm/debuginfo/source_loc.rs b/src/librustc_codegen_llvm/debuginfo/source_loc.rs index bd8c165d508..8785ecfa05b 100644 --- a/src/librustc_codegen_llvm/debuginfo/source_loc.rs +++ b/src/librustc_codegen_llvm/debuginfo/source_loc.rs @@ -17,7 +17,7 @@ use super::FunctionDebugContext; use llvm; use llvm::debuginfo::DIScope; use builder::Builder; -use traits::BuilderMethods; +use interfaces::BuilderMethods; use libc::c_uint; use syntax_pos::{Span, Pos}; diff --git a/src/librustc_codegen_llvm/glue.rs b/src/librustc_codegen_llvm/glue.rs index 5a19fd9aa99..5b6dc7f738d 100644 --- a/src/librustc_codegen_llvm/glue.rs +++ b/src/librustc_codegen_llvm/glue.rs @@ -20,7 +20,7 @@ use meth; use rustc::ty::layout::LayoutOf; use rustc::ty::{self, Ty}; use value::Value; -use traits::{IntPredicate,BuilderMethods}; +use interfaces::BuilderMethods; pub fn size_and_align_of_dst( bx: &Builder<'_, 'll, 'tcx>, diff --git a/src/librustc_codegen_llvm/interfaces/builder.rs b/src/librustc_codegen_llvm/interfaces/builder.rs new file mode 100644 index 00000000000..994ddd65d3d --- /dev/null +++ b/src/librustc_codegen_llvm/interfaces/builder.rs @@ -0,0 +1,285 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use common::*; +use libc::c_char; +use rustc::ty::TyCtxt; +use rustc::ty::layout::{Align, Size}; +use rustc::session::Session; +use builder::MemFlags; + +use std::borrow::Cow; +use std::ops::Range; +use syntax::ast::AsmDialect; + + + +pub trait BuilderMethods<'a, 'll :'a, 'tcx: 'll> { + type Value; + type BasicBlock; + type Type; + + fn new_block<'b>( + cx: &'a CodegenCx<'ll, 'tcx, Self::Value>, + llfn: Self::Value, + name: &'b str + ) -> Self; + fn with_cx(cx: &'a CodegenCx<'ll, 'tcx, Self::Value>) -> Self; + fn build_sibling_block<'b>(&self, name: &'b str) -> Self; + fn sess(&self) -> &Session; + fn cx(&self) -> &'a CodegenCx<'ll, 'tcx, Self::Value>; + fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx>; + fn llfn(&self) -> Self::Value; + fn llbb(&self) -> Self::BasicBlock; + fn count_insn(&self, category: &str); + + fn set_value_name(&self, value: Self::Value, name: &str); + fn position_at_end(&self, llbb: Self::BasicBlock); + fn position_at_start(&self, llbb: Self::BasicBlock); + fn ret_void(&self); + fn ret(&self, v: Self::Value); + fn br(&self, dest: Self::BasicBlock); + fn cond_br( + &self, + cond: Self::Value, + then_llbb: Self::BasicBlock, + else_llbb: Self::BasicBlock, + ); + fn switch( + &self, + v: Self::Value, + else_llbb: Self::BasicBlock, + num_cases: usize, + ) -> Self::Value; + fn invoke( + &self, + llfn: Self::Value, + args: &[Self::Value], + then: Self::BasicBlock, + catch: Self::BasicBlock, + bundle: Option<&OperandBundleDef<'ll, Self::Value>> + ) -> Self::Value; + fn unreachable(&self); + fn add(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn fadd(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn fadd_fast(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn sub(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn fsub(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn fsub_fast(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn mul(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn fmul(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn fmul_fast(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn udiv(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn exactudiv(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn sdiv(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn exactsdiv(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn fdiv(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn fdiv_fast(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn urem(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn srem(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn frem(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn frem_fast(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn shl(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn lshr(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn ashr(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn and(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn or(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn xor(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn neg(&self, v: Self::Value) -> Self::Value; + fn fneg(&self, v: Self::Value) -> Self::Value; + fn not(&self, v: Self::Value) -> Self::Value; + + fn alloca(&self, ty: Self::Type, name: &str, align: Align) -> Self::Value; + fn dynamic_alloca(&self, ty: Self::Type, name: &str, align: Align) -> Self::Value; + fn array_alloca( + &self, + ty: Self::Type, + len: Self::Value, + name: &str, + align: Align + ) -> Self::Value; + + fn load(&self, ptr: Self::Value, align: Align) -> Self::Value; + fn volatile_load(&self, ptr: Self::Value) -> Self::Value; + fn atomic_load(&self, ptr: Self::Value, order: AtomicOrdering, size: Size) -> Self::Value; + + fn range_metadata(&self, load: Self::Value, range: Range); + fn nonnull_metadata(&self, load: Self::Value); + + fn store(&self, val: Self::Value, ptr: Self::Value, align: Align) -> Self::Value; + fn store_with_flags( + &self, + val: Self::Value, + ptr: Self::Value, + align: Align, + flags: MemFlags, + ) -> Self::Value; + fn atomic_store( + &self, + val: Self::Value, + ptr: Self::Value, + order: AtomicOrdering, + size: Size + ); + + fn gep(&self, ptr: Self::Value, indices: &[Self::Value]) -> Self::Value; + fn inbounds_gep(&self, ptr: Self::Value, indices: &[Self::Value]) -> Self::Value; + fn struct_gep(&self, ptr: Self::Value, idx: u64) -> Self::Value; + + fn trunc(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; + fn sext(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; + fn fptoui(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; + fn fptosi(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; + fn uitofp(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; + fn sitofp(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; + fn fptrunc(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; + fn fpext(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; + fn ptrtoint(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; + fn inttoptr(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; + fn bitcast(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; + fn intcast(&self, val: Self::Value, dest_ty: Self::Type, is_signed: bool) -> Self::Value; + fn pointercast(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; + + fn icmp(&self, op: IntPredicate, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn fcmp(&self, op: RealPredicate, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + + fn empty_phi(&self, ty: Self::Type) -> Self::Value; + fn phi(&self, ty: Self::Type, vals: &[Self::Value], bbs: &[Self::BasicBlock]) -> Self::Value; + fn inline_asm_call( + &self, + asm: *const c_char, + cons: *const c_char, + inputs: &[Self::Value], + output: Self::Type, + volatile: bool, + alignstack: bool, + dia: AsmDialect + ) -> Option; + + + fn memcpy(&self, dst: Self::Value, dst_align: u64, + src: Self::Value, src_align: u64, + size: Self::Value, is_volatile: bool) -> Self::Value; + fn memmove(&self, dst: Self::Value, dst_align: u64, + src: Self::Value, src_align: u64, + size: Self::Value, is_volatile: bool) -> Self::Value; + + fn minnum(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn maxnum(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn select( + &self, cond: Self::Value, + then_val: Self::Value, + else_val: Self::Value, + ) -> Self::Value; + + fn va_arg(&self, list: Self::Value, ty: Self::Type) -> Self::Value; + fn extract_element(&self, vec: Self::Value, idx: Self::Value) -> Self::Value; + fn insert_element( + &self, vec: Self::Value, + elt: Self::Value, + idx: Self::Value, + ) -> Self::Value; + fn shuffle_vector(&self, v1: Self::Value, v2: Self::Value, mask: Self::Value) -> Self::Value; + fn vector_splat(&self, num_elts: usize, elt: Self::Value) -> Self::Value; + fn vector_reduce_fadd_fast(&self, acc: Self::Value, src: Self::Value) -> Self::Value; + fn vector_reduce_fmul_fast(&self, acc: Self::Value, src: Self::Value) -> Self::Value; + fn vector_reduce_add(&self, src: Self::Value) -> Self::Value; + fn vector_reduce_mul(&self, src: Self::Value) -> Self::Value; + fn vector_reduce_and(&self, src: Self::Value) -> Self::Value; + fn vector_reduce_or(&self, src: Self::Value) -> Self::Value; + fn vector_reduce_xor(&self, src: Self::Value) -> Self::Value; + fn vector_reduce_fmin(&self, src: Self::Value) -> Self::Value; + fn vector_reduce_fmax(&self, src: Self::Value) -> Self::Value; + fn vector_reduce_fmin_fast(&self, src: Self::Value) -> Self::Value; + fn vector_reduce_fmax_fast(&self, src: Self::Value) -> Self::Value; + fn vector_reduce_min(&self, src: Self::Value, is_signed: bool) -> Self::Value; + fn vector_reduce_max(&self, src: Self::Value, is_signed: bool) -> Self::Value; + fn extract_value(&self, agg_val: Self::Value, idx: u64) -> Self::Value; + fn insert_value( + &self, + agg_val: Self::Value, + elt: Self::Value, + idx: u64 + ) -> Self::Value; + + fn landing_pad( + &self, + ty: Self::Type, + pers_fn: Self::Value, + num_clauses: usize + ) -> Self::Value; + fn add_clause(&self, landing_pad: Self::Value, clause: Self::Value); + fn set_cleanup(&self, landing_pad: Self::Value); + fn resume(&self, exn: Self::Value) -> Self::Value; + fn cleanup_pad( + &self, + parent: Option, + args: &[Self::Value] + ) -> Self::Value; + fn cleanup_ret( + &self, cleanup: Self::Value, + unwind: Option, + ) -> Self::Value; + fn catch_pad( + &self, + parent: Self::Value, + args: &[Self::Value] + ) -> Self::Value; + fn catch_ret(&self, pad: Self::Value, unwind: Self::BasicBlock) -> Self::Value; + fn catch_switch( + &self, + parent: Option, + unwind: Option, + num_handlers: usize, + ) -> Self::Value; + fn add_handler(&self, catch_switch: Self::Value, handler: Self::BasicBlock); + fn set_personality_fn(&self, personality: Self::Value); + + fn atomic_cmpxchg( + &self, + dst: Self::Value, + cmp: Self::Value, + src: Self::Value, + order: AtomicOrdering, + failure_order: AtomicOrdering, + weak: bool, + ) -> Self::Value; + fn atomic_rmw( + &self, + op: AtomicRmwBinOp, + dst: Self::Value, + src: Self::Value, + order: AtomicOrdering, + ) -> Self::Value; + fn atomic_fence(&self, order: AtomicOrdering, scope: SynchronizationScope); + fn add_case(&self, s: Self::Value, on_val: Self::Value, dest: Self::BasicBlock); + fn add_incoming_to_phi(&self, phi: Self::Value, val: Self::Value, bb: Self::BasicBlock); + fn set_invariant_load(&self, load: Self::Value); + + fn check_store( + &self, + val: Self::Value, + ptr: Self::Value + ) -> Self::Value; + fn check_call<'b>( + &self, + typ: &str, + llfn: Self::Value, + args: &'b [Self::Value] + ) -> Cow<'b, [Self::Value]> where [Self::Value] : ToOwned; + fn lifetime_start(&self, ptr: Self::Value, size: Size); + fn lifetime_end(&self, ptr: Self::Value, size: Size); + + fn call_lifetime_intrinsic(&self, intrinsic: &str, ptr: Self::Value, size: Size); + + fn call(&self, llfn: Self::Value, args: &[Self::Value], + bundle: Option<&OperandBundleDef<'ll, Self::Value>>) -> Self::Value; + fn zext(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; +} diff --git a/src/librustc_codegen_llvm/interfaces/mod.rs b/src/librustc_codegen_llvm/interfaces/mod.rs new file mode 100644 index 00000000000..d0cd8e6a696 --- /dev/null +++ b/src/librustc_codegen_llvm/interfaces/mod.rs @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod builder; + +pub use self::builder::BuilderMethods; diff --git a/src/librustc_codegen_llvm/intrinsic.rs b/src/librustc_codegen_llvm/intrinsic.rs index 4eb810cf2c0..f75fe0c4c0e 100644 --- a/src/librustc_codegen_llvm/intrinsic.rs +++ b/src/librustc_codegen_llvm/intrinsic.rs @@ -31,7 +31,7 @@ use syntax::symbol::Symbol; use builder::Builder; use value::Value; -use traits::{BuilderMethods, AtomicRmwBinOp, SynchronizationScope}; +use interfaces::BuilderMethods; use rustc::session::Session; use syntax_pos::Span; @@ -439,7 +439,7 @@ pub fn codegen_intrinsic_call( // This requires that atomic intrinsics follow a specific naming pattern: // "atomic_[_]", and no ordering means SeqCst name if name.starts_with("atomic_") => { - use traits::AtomicOrdering::*; + use self::AtomicOrdering::*; let split: Vec<&str> = name.split('_').collect(); diff --git a/src/librustc_codegen_llvm/lib.rs b/src/librustc_codegen_llvm/lib.rs index 1baab9b0c4d..43942b0db85 100644 --- a/src/librustc_codegen_llvm/lib.rs +++ b/src/librustc_codegen_llvm/lib.rs @@ -102,7 +102,7 @@ mod back { pub mod wasm; } -mod traits; +mod interfaces; mod abi; mod allocator; diff --git a/src/librustc_codegen_llvm/llvm/ffi.rs b/src/librustc_codegen_llvm/llvm/ffi.rs index 827948a02a7..2bbb82f3196 100644 --- a/src/librustc_codegen_llvm/llvm/ffi.rs +++ b/src/librustc_codegen_llvm/llvm/ffi.rs @@ -19,7 +19,7 @@ use libc::{c_uint, c_int, size_t, c_char}; use libc::{c_ulonglong, c_void}; use std::marker::PhantomData; -use traits; +use common; use syntax; use super::RustString; @@ -144,18 +144,18 @@ pub enum IntPredicate { } impl IntPredicate { - pub fn from_generic(intpre: traits::IntPredicate) -> Self { + pub fn from_generic(intpre: common::IntPredicate) -> Self { match intpre { - traits::IntPredicate::IntEQ => IntPredicate::IntEQ, - traits::IntPredicate::IntNE => IntPredicate::IntNE, - traits::IntPredicate::IntUGT => IntPredicate::IntUGT, - traits::IntPredicate::IntUGE => IntPredicate::IntUGE, - traits::IntPredicate::IntULT => IntPredicate::IntULT, - traits::IntPredicate::IntULE => IntPredicate::IntULE, - traits::IntPredicate::IntSGT => IntPredicate::IntSGT, - traits::IntPredicate::IntSGE => IntPredicate::IntSGE, - traits::IntPredicate::IntSLT => IntPredicate::IntSLT, - traits::IntPredicate::IntSLE => IntPredicate::IntSLE, + common::IntPredicate::IntEQ => IntPredicate::IntEQ, + common::IntPredicate::IntNE => IntPredicate::IntNE, + common::IntPredicate::IntUGT => IntPredicate::IntUGT, + common::IntPredicate::IntUGE => IntPredicate::IntUGE, + common::IntPredicate::IntULT => IntPredicate::IntULT, + common::IntPredicate::IntULE => IntPredicate::IntULE, + common::IntPredicate::IntSGT => IntPredicate::IntSGT, + common::IntPredicate::IntSGE => IntPredicate::IntSGE, + common::IntPredicate::IntSLT => IntPredicate::IntSLT, + common::IntPredicate::IntSLE => IntPredicate::IntSLE, } } } @@ -183,24 +183,24 @@ pub enum RealPredicate { } impl RealPredicate { - pub fn from_generic(realpred: traits::RealPredicate) -> Self { + pub fn from_generic(realpred: common::RealPredicate) -> Self { match realpred { - traits::RealPredicate::RealPredicateFalse => RealPredicate::RealPredicateFalse, - traits::RealPredicate::RealOEQ => RealPredicate::RealOEQ, - traits::RealPredicate::RealOGT => RealPredicate::RealOGT, - traits::RealPredicate::RealOGE => RealPredicate::RealOGE, - traits::RealPredicate::RealOLT => RealPredicate::RealOLT, - traits::RealPredicate::RealOLE => RealPredicate::RealOLE, - traits::RealPredicate::RealONE => RealPredicate::RealONE, - traits::RealPredicate::RealORD => RealPredicate::RealORD, - traits::RealPredicate::RealUNO => RealPredicate::RealUNO, - traits::RealPredicate::RealUEQ => RealPredicate::RealUEQ, - traits::RealPredicate::RealUGT => RealPredicate::RealUGT, - traits::RealPredicate::RealUGE => RealPredicate::RealUGE, - traits::RealPredicate::RealULT => RealPredicate::RealULT, - traits::RealPredicate::RealULE => RealPredicate::RealULE, - traits::RealPredicate::RealUNE => RealPredicate::RealUNE, - traits::RealPredicate::RealPredicateTrue => RealPredicate::RealPredicateTrue + common::RealPredicate::RealPredicateFalse => RealPredicate::RealPredicateFalse, + common::RealPredicate::RealOEQ => RealPredicate::RealOEQ, + common::RealPredicate::RealOGT => RealPredicate::RealOGT, + common::RealPredicate::RealOGE => RealPredicate::RealOGE, + common::RealPredicate::RealOLT => RealPredicate::RealOLT, + common::RealPredicate::RealOLE => RealPredicate::RealOLE, + common::RealPredicate::RealONE => RealPredicate::RealONE, + common::RealPredicate::RealORD => RealPredicate::RealORD, + common::RealPredicate::RealUNO => RealPredicate::RealUNO, + common::RealPredicate::RealUEQ => RealPredicate::RealUEQ, + common::RealPredicate::RealUGT => RealPredicate::RealUGT, + common::RealPredicate::RealUGE => RealPredicate::RealUGE, + common::RealPredicate::RealULT => RealPredicate::RealULT, + common::RealPredicate::RealULE => RealPredicate::RealULE, + common::RealPredicate::RealUNE => RealPredicate::RealUNE, + common::RealPredicate::RealPredicateTrue => RealPredicate::RealPredicateTrue } } } @@ -246,19 +246,19 @@ pub enum AtomicRmwBinOp { } impl AtomicRmwBinOp { - pub fn from_generic(op : traits::AtomicRmwBinOp) -> Self { + pub fn from_generic(op : common::AtomicRmwBinOp) -> Self { match op { - traits::AtomicRmwBinOp::AtomicXchg => AtomicRmwBinOp::AtomicXchg, - traits::AtomicRmwBinOp::AtomicAdd => AtomicRmwBinOp::AtomicAdd, - traits::AtomicRmwBinOp::AtomicSub => AtomicRmwBinOp::AtomicSub, - traits::AtomicRmwBinOp::AtomicAnd => AtomicRmwBinOp::AtomicAnd, - traits::AtomicRmwBinOp::AtomicNand => AtomicRmwBinOp::AtomicNand, - traits::AtomicRmwBinOp::AtomicOr => AtomicRmwBinOp::AtomicOr, - traits::AtomicRmwBinOp::AtomicXor => AtomicRmwBinOp::AtomicXor, - traits::AtomicRmwBinOp::AtomicMax => AtomicRmwBinOp::AtomicMax, - traits::AtomicRmwBinOp::AtomicMin => AtomicRmwBinOp::AtomicMin, - traits::AtomicRmwBinOp::AtomicUMax => AtomicRmwBinOp::AtomicUMax, - traits::AtomicRmwBinOp::AtomicUMin => AtomicRmwBinOp::AtomicUMin + common::AtomicRmwBinOp::AtomicXchg => AtomicRmwBinOp::AtomicXchg, + common::AtomicRmwBinOp::AtomicAdd => AtomicRmwBinOp::AtomicAdd, + common::AtomicRmwBinOp::AtomicSub => AtomicRmwBinOp::AtomicSub, + common::AtomicRmwBinOp::AtomicAnd => AtomicRmwBinOp::AtomicAnd, + common::AtomicRmwBinOp::AtomicNand => AtomicRmwBinOp::AtomicNand, + common::AtomicRmwBinOp::AtomicOr => AtomicRmwBinOp::AtomicOr, + common::AtomicRmwBinOp::AtomicXor => AtomicRmwBinOp::AtomicXor, + common::AtomicRmwBinOp::AtomicMax => AtomicRmwBinOp::AtomicMax, + common::AtomicRmwBinOp::AtomicMin => AtomicRmwBinOp::AtomicMin, + common::AtomicRmwBinOp::AtomicUMax => AtomicRmwBinOp::AtomicUMax, + common::AtomicRmwBinOp::AtomicUMin => AtomicRmwBinOp::AtomicUMin } } } @@ -279,15 +279,15 @@ pub enum AtomicOrdering { } impl AtomicOrdering { - pub fn from_generic(ao : traits::AtomicOrdering) -> Self { + pub fn from_generic(ao : common::AtomicOrdering) -> Self { match ao { - traits::AtomicOrdering::NotAtomic => AtomicOrdering::NotAtomic, - traits::AtomicOrdering::Unordered => AtomicOrdering::Unordered, - traits::AtomicOrdering::Monotonic => AtomicOrdering::Monotonic, - traits::AtomicOrdering::Acquire => AtomicOrdering::Acquire, - traits::AtomicOrdering::Release => AtomicOrdering::Release, - traits::AtomicOrdering::AcquireRelease => AtomicOrdering::AcquireRelease, - traits::AtomicOrdering::SequentiallyConsistent => + common::AtomicOrdering::NotAtomic => AtomicOrdering::NotAtomic, + common::AtomicOrdering::Unordered => AtomicOrdering::Unordered, + common::AtomicOrdering::Monotonic => AtomicOrdering::Monotonic, + common::AtomicOrdering::Acquire => AtomicOrdering::Acquire, + common::AtomicOrdering::Release => AtomicOrdering::Release, + common::AtomicOrdering::AcquireRelease => AtomicOrdering::AcquireRelease, + common::AtomicOrdering::SequentiallyConsistent => AtomicOrdering::SequentiallyConsistent } } @@ -306,11 +306,11 @@ pub enum SynchronizationScope { } impl SynchronizationScope { - pub fn from_generic(sc : traits::SynchronizationScope) -> Self { + pub fn from_generic(sc : common::SynchronizationScope) -> Self { match sc { - traits::SynchronizationScope::Other => SynchronizationScope::Other, - traits::SynchronizationScope::SingleThread => SynchronizationScope::SingleThread, - traits::SynchronizationScope::CrossThread => SynchronizationScope::CrossThread, + common::SynchronizationScope::Other => SynchronizationScope::Other, + common::SynchronizationScope::SingleThread => SynchronizationScope::SingleThread, + common::SynchronizationScope::CrossThread => SynchronizationScope::CrossThread, } } } diff --git a/src/librustc_codegen_llvm/llvm/mod.rs b/src/librustc_codegen_llvm/llvm/mod.rs index 3b5f0b0f7df..3b85690e878 100644 --- a/src/librustc_codegen_llvm/llvm/mod.rs +++ b/src/librustc_codegen_llvm/llvm/mod.rs @@ -28,7 +28,7 @@ use std::ffi::CStr; use std::cell::RefCell; use libc::{self, c_uint, c_char, size_t}; use rustc_data_structures::small_c_str::SmallCStr; -use traits; +use common; pub mod archive_ro; pub mod diagnostic; @@ -273,7 +273,7 @@ impl OperandBundleDef<'a> { OperandBundleDef { raw: def } } - pub fn from_generic(bundle : &traits::OperandBundleDef<'a, &'a Value>) -> Self { + pub fn from_generic(bundle : &common::OperandBundleDef<'a, &'a Value>) -> Self { Self::new(bundle.name, &[bundle.val]) } } diff --git a/src/librustc_codegen_llvm/meth.rs b/src/librustc_codegen_llvm/meth.rs index e3dbbda3aa4..46508211c5b 100644 --- a/src/librustc_codegen_llvm/meth.rs +++ b/src/librustc_codegen_llvm/meth.rs @@ -17,7 +17,7 @@ use monomorphize; use type_::Type; use value::Value; -use traits::BuilderMethods; +use interfaces::BuilderMethods; use rustc::ty::{self, Ty}; use rustc::ty::layout::HasDataLayout; diff --git a/src/librustc_codegen_llvm/mir/block.rs b/src/librustc_codegen_llvm/mir/block.rs index 61f8c453a6f..a95b0e9001e 100644 --- a/src/librustc_codegen_llvm/mir/block.rs +++ b/src/librustc_codegen_llvm/mir/block.rs @@ -18,7 +18,7 @@ use abi::{Abi, ArgType, ArgTypeExt, FnType, FnTypeExt, LlvmType, PassMode}; use base; use callee; use builder::{Builder, MemFlags}; -use common::{self, C_bool, C_str_slice, C_struct, C_u32, C_uint_big, C_undef}; +use common::{self, C_bool, C_str_slice, C_struct, C_u32, C_uint_big, C_undef, IntPredicate}; use consts; use meth; use monomorphize; @@ -26,7 +26,7 @@ use type_of::LayoutLlvmExt; use type_::Type; use value::Value; -use traits::{IntPredicate,BuilderMethods}; +use interfaces::BuilderMethods; use syntax::symbol::Symbol; use syntax_pos::Pos; diff --git a/src/librustc_codegen_llvm/mir/constant.rs b/src/librustc_codegen_llvm/mir/constant.rs index 62fce894cf7..44cd11bd79e 100644 --- a/src/librustc_codegen_llvm/mir/constant.rs +++ b/src/librustc_codegen_llvm/mir/constant.rs @@ -26,7 +26,7 @@ use type_::Type; use syntax::ast::Mutability; use syntax::source_map::Span; use value::Value; -use traits::BuilderMethods; +use interfaces::BuilderMethods; use super::super::callee; use super::FunctionCx; diff --git a/src/librustc_codegen_llvm/mir/mod.rs b/src/librustc_codegen_llvm/mir/mod.rs index b844b6e1458..783e96d90e3 100644 --- a/src/librustc_codegen_llvm/mir/mod.rs +++ b/src/librustc_codegen_llvm/mir/mod.rs @@ -26,7 +26,7 @@ use monomorphize::Instance; use abi::{ArgTypeExt, FnType, FnTypeExt, PassMode}; use type_::Type; use value::Value; -use traits::BuilderMethods; +use interfaces::BuilderMethods; use syntax_pos::{DUMMY_SP, NO_EXPANSION, BytePos, Span}; use syntax::symbol::keywords; diff --git a/src/librustc_codegen_llvm/mir/operand.rs b/src/librustc_codegen_llvm/mir/operand.rs index b8505ba1281..88b2d07edd1 100644 --- a/src/librustc_codegen_llvm/mir/operand.rs +++ b/src/librustc_codegen_llvm/mir/operand.rs @@ -21,7 +21,7 @@ use type_of::LayoutLlvmExt; use type_::Type; use glue; -use traits::BuilderMethods; +use interfaces::BuilderMethods; use std::fmt; diff --git a/src/librustc_codegen_llvm/mir/place.rs b/src/librustc_codegen_llvm/mir/place.rs index 25d24486d63..cc0ed33d44d 100644 --- a/src/librustc_codegen_llvm/mir/place.rs +++ b/src/librustc_codegen_llvm/mir/place.rs @@ -15,7 +15,7 @@ use rustc::mir; use rustc::mir::tcx::PlaceTy; use base; use builder::Builder; -use common::{CodegenCx, C_undef, C_usize, C_u8, C_u32, C_uint, C_null, C_uint_big}; +use common::{CodegenCx, C_undef, C_usize, C_u8, C_u32, C_uint, C_null, C_uint_big, IntPredicate}; use consts; use type_of::LayoutLlvmExt; use type_::Type; @@ -23,7 +23,7 @@ use value::Value; use glue; use mir::constant::const_alloc_to_llvm; -use traits::{IntPredicate,BuilderMethods}; +use interfaces::BuilderMethods; use super::{FunctionCx, LocalRef}; use super::operand::{OperandRef, OperandValue}; diff --git a/src/librustc_codegen_llvm/mir/rvalue.rs b/src/librustc_codegen_llvm/mir/rvalue.rs index 25af25b8ed6..577d73be2ed 100644 --- a/src/librustc_codegen_llvm/mir/rvalue.rs +++ b/src/librustc_codegen_llvm/mir/rvalue.rs @@ -20,14 +20,17 @@ use base; use builder::Builder; use callee; use common::{self, val_ty}; -use common::{C_bool, C_u8, C_i32, C_u32, C_u64, C_undef, C_null, C_usize, C_uint, C_uint_big}; +use common::{ + C_bool, C_u8, C_i32, C_u32, C_u64, C_undef, C_null, C_usize, + C_uint, C_uint_big, IntPredicate, RealPredicate +}; use consts; use monomorphize; use type_::Type; use type_of::LayoutLlvmExt; use value::Value; -use traits::{IntPredicate, RealPredicate, BuilderMethods}; +use interfaces::BuilderMethods; use super::{FunctionCx, LocalRef}; use super::operand::{OperandRef, OperandValue}; diff --git a/src/librustc_codegen_llvm/mir/statement.rs b/src/librustc_codegen_llvm/mir/statement.rs index a3aea7b9180..dc19e3c5c5b 100644 --- a/src/librustc_codegen_llvm/mir/statement.rs +++ b/src/librustc_codegen_llvm/mir/statement.rs @@ -12,7 +12,7 @@ use rustc::mir; use asm; use builder::Builder; -use traits::BuilderMethods; +use interfaces::BuilderMethods; use super::FunctionCx; use super::LocalRef; diff --git a/src/librustc_codegen_llvm/traits.rs b/src/librustc_codegen_llvm/traits.rs deleted file mode 100644 index 417c900b127..00000000000 --- a/src/librustc_codegen_llvm/traits.rs +++ /dev/null @@ -1,366 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use common::*; -use libc::c_char; -use rustc::ty::TyCtxt; -use rustc::ty::layout::{Align, Size}; -use rustc::session::Session; -use builder::MemFlags; -use value::Value; - -use std::borrow::Cow; -use std::ops::Range; -use syntax::ast::AsmDialect; - -pub struct OperandBundleDef<'a, Value : 'a> { - pub name: &'a str, - pub val: Value -} - -impl OperandBundleDef<'ll, &'ll Value> { - pub fn new(name: &'ll str, val: &'ll Value) -> Self { - OperandBundleDef { - name, - val - } - } -} - -pub enum IntPredicate { - IntEQ, - IntNE, - IntUGT, - IntUGE, - IntULT, - IntULE, - IntSGT, - IntSGE, - IntSLT, - IntSLE -} - -#[allow(dead_code)] -pub enum RealPredicate { - RealPredicateFalse, - RealOEQ, - RealOGT, - RealOGE, - RealOLT, - RealOLE, - RealONE, - RealORD, - RealUNO, - RealUEQ, - RealUGT, - RealUGE, - RealULT, - RealULE, - RealUNE, - RealPredicateTrue -} - -pub enum AtomicRmwBinOp { - AtomicXchg, - AtomicAdd, - AtomicSub, - AtomicAnd, - AtomicNand, - AtomicOr, - AtomicXor, - AtomicMax, - AtomicMin, - AtomicUMax, - AtomicUMin -} - -pub enum AtomicOrdering { - #[allow(dead_code)] - NotAtomic, - Unordered, - Monotonic, - // Consume, // Not specified yet. - Acquire, - Release, - AcquireRelease, - SequentiallyConsistent, -} - -pub enum SynchronizationScope { - // FIXME: figure out if this variant is needed at all. - #[allow(dead_code)] - Other, - SingleThread, - CrossThread, -} - - -pub trait BuilderMethods<'a, 'll :'a, 'tcx: 'll> { - type Value; - type BasicBlock; - type Type; - - fn new_block<'b>( - cx: &'a CodegenCx<'ll, 'tcx, Self::Value>, - llfn: Self::Value, - name: &'b str - ) -> Self; - fn with_cx(cx: &'a CodegenCx<'ll, 'tcx, Self::Value>) -> Self; - fn build_sibling_block<'b>(&self, name: &'b str) -> Self; - fn sess(&self) -> &Session; - fn cx(&self) -> &'a CodegenCx<'ll, 'tcx, Self::Value>; - fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx>; - fn llfn(&self) -> Self::Value; - fn llbb(&self) -> Self::BasicBlock; - fn count_insn(&self, category: &str); - - fn set_value_name(&self, value: Self::Value, name: &str); - fn position_at_end(&self, llbb: Self::BasicBlock); - fn position_at_start(&self, llbb: Self::BasicBlock); - fn ret_void(&self); - fn ret(&self, v: Self::Value); - fn br(&self, dest: Self::BasicBlock); - fn cond_br( - &self, - cond: Self::Value, - then_llbb: Self::BasicBlock, - else_llbb: Self::BasicBlock, - ); - fn switch( - &self, - v: Self::Value, - else_llbb: Self::BasicBlock, - num_cases: usize, - ) -> Self::Value; - fn invoke( - &self, - llfn: Self::Value, - args: &[Self::Value], - then: Self::BasicBlock, - catch: Self::BasicBlock, - bundle: Option<&OperandBundleDef<'ll, Self::Value>> - ) -> Self::Value; - fn unreachable(&self); - fn add(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - fn fadd(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - fn fadd_fast(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - fn sub(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - fn fsub(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - fn fsub_fast(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - fn mul(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - fn fmul(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - fn fmul_fast(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - fn udiv(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - fn exactudiv(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - fn sdiv(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - fn exactsdiv(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - fn fdiv(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - fn fdiv_fast(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - fn urem(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - fn srem(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - fn frem(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - fn frem_fast(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - fn shl(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - fn lshr(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - fn ashr(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - fn and(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - fn or(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - fn xor(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - fn neg(&self, v: Self::Value) -> Self::Value; - fn fneg(&self, v: Self::Value) -> Self::Value; - fn not(&self, v: Self::Value) -> Self::Value; - - fn alloca(&self, ty: Self::Type, name: &str, align: Align) -> Self::Value; - fn dynamic_alloca(&self, ty: Self::Type, name: &str, align: Align) -> Self::Value; - fn array_alloca( - &self, - ty: Self::Type, - len: Self::Value, - name: &str, - align: Align - ) -> Self::Value; - - fn load(&self, ptr: Self::Value, align: Align) -> Self::Value; - fn volatile_load(&self, ptr: Self::Value) -> Self::Value; - fn atomic_load(&self, ptr: Self::Value, order: AtomicOrdering, size: Size) -> Self::Value; - - fn range_metadata(&self, load: Self::Value, range: Range); - fn nonnull_metadata(&self, load: Self::Value); - - fn store(&self, val: Self::Value, ptr: Self::Value, align: Align) -> Self::Value; - fn store_with_flags( - &self, - val: Self::Value, - ptr: Self::Value, - align: Align, - flags: MemFlags, - ) -> Self::Value; - fn atomic_store( - &self, - val: Self::Value, - ptr: Self::Value, - order: AtomicOrdering, - size: Size - ); - - fn gep(&self, ptr: Self::Value, indices: &[Self::Value]) -> Self::Value; - fn inbounds_gep(&self, ptr: Self::Value, indices: &[Self::Value]) -> Self::Value; - fn struct_gep(&self, ptr: Self::Value, idx: u64) -> Self::Value; - - fn trunc(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; - fn sext(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; - fn fptoui(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; - fn fptosi(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; - fn uitofp(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; - fn sitofp(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; - fn fptrunc(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; - fn fpext(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; - fn ptrtoint(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; - fn inttoptr(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; - fn bitcast(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; - fn intcast(&self, val: Self::Value, dest_ty: Self::Type, is_signed: bool) -> Self::Value; - fn pointercast(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; - - fn icmp(&self, op: IntPredicate, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - fn fcmp(&self, op: RealPredicate, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - - fn empty_phi(&self, ty: Self::Type) -> Self::Value; - fn phi(&self, ty: Self::Type, vals: &[Self::Value], bbs: &[Self::BasicBlock]) -> Self::Value; - fn inline_asm_call( - &self, - asm: *const c_char, - cons: *const c_char, - inputs: &[Self::Value], - output: Self::Type, - volatile: bool, - alignstack: bool, - dia: AsmDialect - ) -> Option; - - - fn memcpy(&self, dst: Self::Value, dst_align: u64, - src: Self::Value, src_align: u64, - size: Self::Value, is_volatile: bool) -> Self::Value; - fn memmove(&self, dst: Self::Value, dst_align: u64, - src: Self::Value, src_align: u64, - size: Self::Value, is_volatile: bool) -> Self::Value; - - fn minnum(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - fn maxnum(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - fn select( - &self, cond: Self::Value, - then_val: Self::Value, - else_val: Self::Value, - ) -> Self::Value; - - fn va_arg(&self, list: Self::Value, ty: Self::Type) -> Self::Value; - fn extract_element(&self, vec: Self::Value, idx: Self::Value) -> Self::Value; - fn insert_element( - &self, vec: Self::Value, - elt: Self::Value, - idx: Self::Value, - ) -> Self::Value; - fn shuffle_vector(&self, v1: Self::Value, v2: Self::Value, mask: Self::Value) -> Self::Value; - fn vector_splat(&self, num_elts: usize, elt: Self::Value) -> Self::Value; - fn vector_reduce_fadd_fast(&self, acc: Self::Value, src: Self::Value) -> Self::Value; - fn vector_reduce_fmul_fast(&self, acc: Self::Value, src: Self::Value) -> Self::Value; - fn vector_reduce_add(&self, src: Self::Value) -> Self::Value; - fn vector_reduce_mul(&self, src: Self::Value) -> Self::Value; - fn vector_reduce_and(&self, src: Self::Value) -> Self::Value; - fn vector_reduce_or(&self, src: Self::Value) -> Self::Value; - fn vector_reduce_xor(&self, src: Self::Value) -> Self::Value; - fn vector_reduce_fmin(&self, src: Self::Value) -> Self::Value; - fn vector_reduce_fmax(&self, src: Self::Value) -> Self::Value; - fn vector_reduce_fmin_fast(&self, src: Self::Value) -> Self::Value; - fn vector_reduce_fmax_fast(&self, src: Self::Value) -> Self::Value; - fn vector_reduce_min(&self, src: Self::Value, is_signed: bool) -> Self::Value; - fn vector_reduce_max(&self, src: Self::Value, is_signed: bool) -> Self::Value; - fn extract_value(&self, agg_val: Self::Value, idx: u64) -> Self::Value; - fn insert_value( - &self, - agg_val: Self::Value, - elt: Self::Value, - idx: u64 - ) -> Self::Value; - - fn landing_pad( - &self, - ty: Self::Type, - pers_fn: Self::Value, - num_clauses: usize - ) -> Self::Value; - fn add_clause(&self, landing_pad: Self::Value, clause: Self::Value); - fn set_cleanup(&self, landing_pad: Self::Value); - fn resume(&self, exn: Self::Value) -> Self::Value; - fn cleanup_pad( - &self, - parent: Option, - args: &[Self::Value] - ) -> Self::Value; - fn cleanup_ret( - &self, cleanup: Self::Value, - unwind: Option, - ) -> Self::Value; - fn catch_pad( - &self, - parent: Self::Value, - args: &[Self::Value] - ) -> Self::Value; - fn catch_ret(&self, pad: Self::Value, unwind: Self::BasicBlock) -> Self::Value; - fn catch_switch( - &self, - parent: Option, - unwind: Option, - num_handlers: usize, - ) -> Self::Value; - fn add_handler(&self, catch_switch: Self::Value, handler: Self::BasicBlock); - fn set_personality_fn(&self, personality: Self::Value); - - fn atomic_cmpxchg( - &self, - dst: Self::Value, - cmp: Self::Value, - src: Self::Value, - order: AtomicOrdering, - failure_order: AtomicOrdering, - weak: bool, - ) -> Self::Value; - fn atomic_rmw( - &self, - op: AtomicRmwBinOp, - dst: Self::Value, - src: Self::Value, - order: AtomicOrdering, - ) -> Self::Value; - fn atomic_fence(&self, order: AtomicOrdering, scope: SynchronizationScope); - fn add_case(&self, s: Self::Value, on_val: Self::Value, dest: Self::BasicBlock); - fn add_incoming_to_phi(&self, phi: Self::Value, val: Self::Value, bb: Self::BasicBlock); - fn set_invariant_load(&self, load: Self::Value); - - fn check_store( - &self, - val: Self::Value, - ptr: Self::Value - ) -> Self::Value; - fn check_call<'b>( - &self, - typ: &str, - llfn: Self::Value, - args: &'b [Self::Value] - ) -> Cow<'b, [Self::Value]> where [Self::Value] : ToOwned; - fn lifetime_start(&self, ptr: Self::Value, size: Size); - fn lifetime_end(&self, ptr: Self::Value, size: Size); - - fn call_lifetime_intrinsic(&self, intrinsic: &str, ptr: Self::Value, size: Size); - - fn call(&self, llfn: Self::Value, args: &[Self::Value], - bundle: Option<&OperandBundleDef<'ll, Self::Value>>) -> Self::Value; - fn zext(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; -} -- cgit 1.4.1-3-g733a5