/// <summary>
        /// Builds an instruction that computes the new value of a destination
        /// address after applying an RMW operator.
        /// </summary>
        /// <param name="Builder">A basic block builder.</param>
        /// <param name="Operator">The RMW binary operator to apply.</param>
        /// <param name="Left">The value in the destination.</param>
        /// <param name="Right">The second operand value.</param>
        /// <returns>The new value of the destination address.</returns>
        public static LLVMValueRef BuildRMWResult(
            LLVMBuilderRef Builder,
            LLVMAtomicRMWBinOp Operator,
            LLVMValueRef Left, LLVMValueRef Right)
        {
            switch (Operator)
            {
            case LLVMAtomicRMWBinOp.LLVMAtomicRMWBinOpAdd:
                return(BuildAdd(Builder, Left, Right, "rmw_result"));

            case LLVMAtomicRMWBinOp.LLVMAtomicRMWBinOpAnd:
                return(BuildAnd(Builder, Left, Right, "rmw_result"));

            case LLVMAtomicRMWBinOp.LLVMAtomicRMWBinOpOr:
                return(BuildOr(Builder, Left, Right, "rmw_result"));

            case LLVMAtomicRMWBinOp.LLVMAtomicRMWBinOpSub:
                return(BuildSub(Builder, Left, Right, "rmw_result"));

            case LLVMAtomicRMWBinOp.LLVMAtomicRMWBinOpXchg:
                return(Left);

            case LLVMAtomicRMWBinOp.LLVMAtomicRMWBinOpXor:
                return(BuildXor(Builder, Left, Right, "rmw_result"));

            default:
                throw new NotSupportedException("Unsupported RMW operator: " + Operator);
            }
        }
 public ReadModifyWriteBlock(
     CodeBlock DestinationAddress,
     CodeBlock Value,
     LLVMAtomicRMWBinOp Op,
     LLVMCodeGenerator CodeGenerator)
 {
     this.DestinationAddress = DestinationAddress;
     this.Value   = Value;
     this.Op      = Op;
     this.codeGen = CodeGenerator;
 }
 private void ImplementWithAtomic(LLVMValueRef function, LLVMAtomicRMWBinOp op, LLVMValueRef rhs, ModuleBuilder module)
 {
     ImplementWithInstruction(
         function,
         module,
         builder => builder.CreateAtomicRMW(
             op,
             function.GetParam(0),
             rhs,
             LLVMAtomicOrdering.LLVMAtomicOrderingAcquireRelease,
             false));
 }
Example #4
0
 public static extern LLVMValueRef BuildAtomicRMW(LLVMBuilderRef @B, LLVMAtomicRMWBinOp @op, LLVMValueRef @PTR, LLVMValueRef @Val, LLVMAtomicOrdering @ordering, LLVMBool @singleThread);
Example #5
0
 public LLVMValueRef CreateAtomicRMW(LLVMAtomicRMWBinOp @op, LLVMValueRef @PTR, LLVMValueRef @Val, LLVMAtomicOrdering @ordering, bool @singleThread)
 {
     return LLVM.BuildAtomicRMW(this.instance, @op, @PTR, @Val, @ordering, @singleThread);
 }
Example #6
0
 public static AtomicRMWBinOp Wrap(this LLVMAtomicRMWBinOp handle) => (AtomicRMWBinOp)(int)handle;
Example #7
0
 public LLVMValueRef CreateAtomicRMW(LLVMAtomicRMWBinOp @op, LLVMValueRef @PTR, LLVMValueRef @Val, LLVMAtomicOrdering @ordering, bool @singleThread)
 {
     return(LLVM.BuildAtomicRMW(this.instance, @op, @PTR, @Val, @ordering, @singleThread));
 }