File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,32 @@ public struct BasicBlock: IRValue {
2323 self . llvm = llvm
2424 }
2525
26+ /// Creates a new basic block without a parent function.
27+ ///
28+ /// The basic block should be inserted into a function or destroyed before
29+ /// the IR builder is finalized.
30+ public init ( context: Context = . global, name: String = " " ) {
31+ self . llvm = LLVMCreateBasicBlockInContext ( context. llvm, name)
32+ }
33+
34+ /// Given that this block and a given block share a parent function, move this
35+ /// block before the given block in that function's basic block list.
36+ ///
37+ /// - Parameter position: The basic block that acts as a position before
38+ /// which this block will be moved.
39+ public func move( before position: BasicBlock ) {
40+ LLVMMoveBasicBlockBefore ( self . asLLVM ( ) , position. asLLVM ( ) )
41+ }
42+
43+ /// Given that this block and a given block share a parent function, move this
44+ /// block after the given block in that function's basic block list.
45+ ///
46+ /// - Parameter position: The basic block that acts as a position after
47+ /// which this block will be moved.
48+ public func move( after position: BasicBlock ) {
49+ LLVMMoveBasicBlockAfter ( self . asLLVM ( ) , position. asLLVM ( ) )
50+ }
51+
2652 /// Retrieves the underlying LLVM value object.
2753 public func asLLVM( ) -> LLVMValueRef {
2854 return llvm
You can’t perform that action at this time.
0 commit comments