コード例 #1
0
ファイル: Extension.cs プロジェクト: BowsiePup/Ion
        /// <summary>
        /// Create a new LLVM block builder and position
        /// it accordingly.
        /// </summary>
        public static LLVMBuilderRef CreateBuilder(this LLVMBasicBlockRef block, bool positionAtEnd = true)
        {
            // Create a new builder.
            LLVMBuilderRef builder = LLVM.CreateBuilder();

            // Position the builder at the beginning of the block.
            if (!positionAtEnd)
            {
                LLVMValueRef lastInstruction = block.GetLastInstruction();

                // No instructions, position at beginning.
                if (lastInstruction.Pointer == IntPtr.Zero)
                {
                    LLVM.PositionBuilderAtEnd(builder, block);
                }
                // Otherwise, position it before the last instruction.
                else
                {
                    LLVM.PositionBuilderBefore(builder, lastInstruction);
                }
            }
            // Otherwise, at the end of the block.
            else
            {
                LLVM.PositionBuilderAtEnd(builder, block);
            }

            // Return the linked builder.
            return(builder);
        }
コード例 #2
0
ファイル: Extension.cs プロジェクト: ronthecookie/Ion
        /// <summary>
        ///     Create a new LLVM block builder and position
        ///     it accordingly.
        /// </summary>
        public static LLVMBuilderRef CreateBuilder(this LLVMBasicBlockRef block, bool positionAtStart = true)
        {
            // Create a new builder.
            LLVMBuilderRef builder = LLVM.CreateBuilder();

            // Position the builder at the beginning of the block.
            if (positionAtStart)
            {
                LLVM.PositionBuilderBefore(builder, block.GetLastInstruction());
            }
            // Otherwise, at the end of the block.
            else
            {
                LLVM.PositionBuilderAtEnd(builder, block);
            }

            // Return the linked builder.
            return(builder);
        }