use llvm_sys::core::LLVMGetOperand;
use llvm_sys::prelude::LLVMValueRef;
use std::marker::PhantomData;
use crate::values::*;
use crate::*;
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
pub struct SelectInstruction<'ctx>(LLVMValueRef, PhantomData<&'ctx ()>);
impl_instr_debug!(SelectInstruction);
impl_as_operand_for_instr!(SelectInstruction);
impl_send_sync!(SelectInstruction);
impl<'ctx> GetType<'ctx> for SelectInstruction<'ctx> {}
impl<'ctx> GetDebugMetadata<'ctx> for SelectInstruction<'ctx> {}
impl<'ctx> InstructionTrait<'ctx> for SelectInstruction<'ctx> {}
impl<'ctx> InstructionDebugLoc for SelectInstruction<'ctx> {}
impl<'ctx> AsInstruction<'ctx> for SelectInstruction<'ctx> {
fn as_instruction(&self) -> Instruction<'ctx> {
Instruction::Select(*self)
}
}
impl<'ctx> ValueOpcode for SelectInstruction<'ctx> {
fn opcode(&self) -> Opcode {
Opcode::Select
}
}
impl<'ctx> SelectInstruction<'ctx> {
pub fn condition(&self) -> Operand<'ctx> {
Operand::from_llvm(unsafe { LLVMGetOperand(self.0, 0) })
}
pub fn true_value(&self) -> Operand<'ctx> {
Operand::from_llvm(unsafe { LLVMGetOperand(self.0, 1) })
}
pub fn false_value(&self) -> Operand<'ctx> {
Operand::from_llvm(unsafe { LLVMGetOperand(self.0, 2) })
}
}
impl_positional_value_ref!(SelectInstruction, 0);
impl_positional_from_llvm_value!(SelectInstruction);