Skip to content

Commit 4000703

Browse files
committed
Add aggregate returns
1 parent 22f771b commit 4000703

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Sources/LLVM/IRBuilder.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,20 @@ public class IRBuilder {
910910
return LLVMBuildUnreachable(llvm)
911911
}
912912

913+
/// Build a return from the current function back to the calling function with
914+
/// the given array of values in aggregate.
915+
///
916+
/// - parameter values: The values to insert as members of the returned aggregate.
917+
///
918+
/// - returns: A value representing `void`.
919+
@discardableResult
920+
public func buildRetAggregate(of values: [IRValue]) -> IRValue {
921+
var values = values.map { $0.asLLVM() as Optional }
922+
return values.withUnsafeMutableBufferPointer { buf in
923+
return LLVMBuildAggregateRet(llvm, buf.baseAddress!, UInt32(buf.count))
924+
}
925+
}
926+
913927
/// Build a call to the given function with the given arguments to transfer
914928
/// control to that function.
915929
///

0 commit comments

Comments
 (0)