mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Generalized AtomicRmwBinOp for BuilderMethods
This commit is contained in:
parent
1bcb4df166
commit
275589150b
@ -1059,13 +1059,19 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock>
|
|||||||
}
|
}
|
||||||
fn atomic_rmw(
|
fn atomic_rmw(
|
||||||
&self,
|
&self,
|
||||||
op: AtomicRmwBinOp,
|
op: traits::AtomicRmwBinOp,
|
||||||
dst: &'ll Value,
|
dst: &'ll Value,
|
||||||
src: &'ll Value,
|
src: &'ll Value,
|
||||||
order: AtomicOrdering,
|
order: AtomicOrdering,
|
||||||
) -> &'ll Value {
|
) -> &'ll Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMBuildAtomicRMW(self.llbuilder, op, dst, src, order, False)
|
llvm::LLVMBuildAtomicRMW(
|
||||||
|
self.llbuilder,
|
||||||
|
AtomicRmwBinOp::from_generic(op),
|
||||||
|
dst,
|
||||||
|
src,
|
||||||
|
order,
|
||||||
|
False)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ use syntax::symbol::Symbol;
|
|||||||
use builder::Builder;
|
use builder::Builder;
|
||||||
use value::Value;
|
use value::Value;
|
||||||
|
|
||||||
use traits::BuilderMethods;
|
use traits::{BuilderMethods, AtomicRmwBinOp};
|
||||||
|
|
||||||
use rustc::session::Session;
|
use rustc::session::Session;
|
||||||
use syntax_pos::Span;
|
use syntax_pos::Span;
|
||||||
@ -533,17 +533,17 @@ pub fn codegen_intrinsic_call(
|
|||||||
// These are all AtomicRMW ops
|
// These are all AtomicRMW ops
|
||||||
op => {
|
op => {
|
||||||
let atom_op = match op {
|
let atom_op = match op {
|
||||||
"xchg" => llvm::AtomicXchg,
|
"xchg" => AtomicRmwBinOp::AtomicXchg,
|
||||||
"xadd" => llvm::AtomicAdd,
|
"xadd" => AtomicRmwBinOp::AtomicAdd,
|
||||||
"xsub" => llvm::AtomicSub,
|
"xsub" => AtomicRmwBinOp::AtomicSub,
|
||||||
"and" => llvm::AtomicAnd,
|
"and" => AtomicRmwBinOp::AtomicAnd,
|
||||||
"nand" => llvm::AtomicNand,
|
"nand" => AtomicRmwBinOp::AtomicNand,
|
||||||
"or" => llvm::AtomicOr,
|
"or" => AtomicRmwBinOp::AtomicOr,
|
||||||
"xor" => llvm::AtomicXor,
|
"xor" => AtomicRmwBinOp::AtomicXor,
|
||||||
"max" => llvm::AtomicMax,
|
"max" => AtomicRmwBinOp::AtomicMax,
|
||||||
"min" => llvm::AtomicMin,
|
"min" => AtomicRmwBinOp::AtomicMin,
|
||||||
"umax" => llvm::AtomicUMax,
|
"umax" => AtomicRmwBinOp::AtomicUMax,
|
||||||
"umin" => llvm::AtomicUMin,
|
"umin" => AtomicRmwBinOp::AtomicUMin,
|
||||||
_ => cx.sess().fatal("unknown atomic operation")
|
_ => cx.sess().fatal("unknown atomic operation")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -244,6 +244,24 @@ pub enum AtomicRmwBinOp {
|
|||||||
AtomicUMin = 10,
|
AtomicUMin = 10,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl AtomicRmwBinOp {
|
||||||
|
pub fn from_generic(op : traits::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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// LLVMAtomicOrdering
|
/// LLVMAtomicOrdering
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use llvm::{AtomicRmwBinOp, AtomicOrdering, SynchronizationScope, AsmDialect};
|
use llvm::{AtomicOrdering, SynchronizationScope, AsmDialect};
|
||||||
use common::*;
|
use common::*;
|
||||||
use type_::Type;
|
use type_::Type;
|
||||||
use libc::c_char;
|
use libc::c_char;
|
||||||
@ -30,7 +30,7 @@ impl OperandBundleDef<'ll, &'ll Value> {
|
|||||||
pub fn new(name: &'ll str, val: &'ll Value) -> Self {
|
pub fn new(name: &'ll str, val: &'ll Value) -> Self {
|
||||||
OperandBundleDef {
|
OperandBundleDef {
|
||||||
name,
|
name,
|
||||||
val,
|
val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -45,7 +45,7 @@ pub enum IntPredicate {
|
|||||||
IntSGT,
|
IntSGT,
|
||||||
IntSGE,
|
IntSGE,
|
||||||
IntSLT,
|
IntSLT,
|
||||||
IntSLE,
|
IntSLE
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
@ -65,7 +65,21 @@ pub enum RealPredicate {
|
|||||||
RealULT,
|
RealULT,
|
||||||
RealULE,
|
RealULE,
|
||||||
RealUNE,
|
RealUNE,
|
||||||
RealPredicateTrue,
|
RealPredicateTrue
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum AtomicRmwBinOp {
|
||||||
|
AtomicXchg,
|
||||||
|
AtomicAdd,
|
||||||
|
AtomicSub,
|
||||||
|
AtomicAnd,
|
||||||
|
AtomicNand,
|
||||||
|
AtomicOr,
|
||||||
|
AtomicXor,
|
||||||
|
AtomicMax,
|
||||||
|
AtomicMin,
|
||||||
|
AtomicUMax,
|
||||||
|
AtomicUMin
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait BuilderMethods<'a, 'll :'a, 'tcx: 'll,
|
pub trait BuilderMethods<'a, 'll :'a, 'tcx: 'll,
|
||||||
|
Loading…
Reference in New Issue
Block a user