Skip to content

Commit 4e53572

Browse files
committed
Remove JIT.runFunction
MCJIT::runFunction does not support full-featured argument passing.
1 parent 7806e63 commit 4e53572

File tree

1 file changed

+0
-133
lines changed

1 file changed

+0
-133
lines changed

Sources/LLVM/JIT.swift

Lines changed: 0 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -24,123 +24,6 @@ public enum JITError: Error, CustomStringConvertible {
2424
}
2525
}
2626

27-
public final class JITValue {
28-
fileprivate let llvm: LLVMGenericValueRef
29-
fileprivate init(llvm: LLVMGenericValueRef) {
30-
self.llvm = llvm
31-
}
32-
33-
public convenience init?(int value: Int) {
34-
guard
35-
let llvm = LLVMCreateGenericValueOfInt(value.type.asLLVM(),
36-
UInt64(bitPattern: Int64(value)),
37-
/*signed:*/ true.llvm)
38-
else {
39-
return nil
40-
}
41-
self.init(llvm: llvm)
42-
}
43-
44-
public convenience init?(int value: UInt) {
45-
guard
46-
let llvm = LLVMCreateGenericValueOfInt(value.type.asLLVM(),
47-
UInt64(value),
48-
/*signed:*/ false.llvm)
49-
else {
50-
return nil
51-
}
52-
self.init(llvm: llvm)
53-
}
54-
55-
public convenience init?(int value: Float) {
56-
guard
57-
let llvm = LLVMCreateGenericValueOfFloat(FloatType.float.asLLVM(), Double(value))
58-
else {
59-
return nil
60-
}
61-
self.init(llvm: llvm)
62-
}
63-
64-
public convenience init?(int value: Double) {
65-
guard
66-
let llvm = LLVMCreateGenericValueOfFloat(FloatType.double.asLLVM(), value)
67-
else {
68-
return nil
69-
}
70-
self.init(llvm: llvm)
71-
}
72-
73-
74-
public convenience init?(pointer value: UnsafeMutableRawPointer?) {
75-
guard
76-
let llvm = LLVMCreateGenericValueOfPointer(value)
77-
else {
78-
return nil
79-
}
80-
self.init(llvm: llvm)
81-
}
82-
83-
public convenience init?(int value: Constant<Signed>) {
84-
let intValue = LLVMConstIntGetSExtValue(value.asLLVM())
85-
guard
86-
let llvm = LLVMCreateGenericValueOfInt(value.type.asLLVM(),
87-
UInt64(bitPattern: intValue),
88-
/*signed:*/ true.llvm)
89-
else {
90-
return nil
91-
}
92-
self.init(llvm: llvm)
93-
}
94-
95-
public convenience init?(int value: Constant<Unsigned>) {
96-
let intValue = LLVMConstIntGetZExtValue(value.asLLVM())
97-
guard
98-
let llvm = LLVMCreateGenericValueOfInt(value.type.asLLVM(),
99-
intValue, /*signed:*/ false.llvm)
100-
else {
101-
return nil
102-
}
103-
self.init(llvm: llvm)
104-
}
105-
106-
public convenience init?(float value: Constant<Floating>) {
107-
var infoLost: LLVMBool = 0
108-
let floatValue = LLVMConstRealGetDouble(value.asLLVM(), &infoLost)
109-
guard infoLost == 0 else {
110-
return nil
111-
}
112-
guard
113-
let llvm = LLVMCreateGenericValueOfFloat(value.type.asLLVM(), floatValue)
114-
else {
115-
return nil
116-
}
117-
self.init(llvm: llvm)
118-
}
119-
120-
deinit {
121-
LLVMDisposeGenericValue(self.llvm)
122-
}
123-
124-
public var bitwidth: UInt {
125-
let width = LLVMGenericValueIntWidth(self.llvm)
126-
return UInt(width)
127-
}
128-
129-
public var intValue: Int {
130-
let int = LLVMGenericValueToInt(self.llvm, /*signed:*/ true.llvm)
131-
return Int(bitPattern: UInt(int))
132-
}
133-
134-
public var unsignedIntValue: UInt {
135-
let int = LLVMGenericValueToInt(self.llvm, /*signed:*/ false.llvm)
136-
return UInt(int)
137-
}
138-
139-
public var pointerValue: UnsafeMutableRawPointer? {
140-
return LLVMGenericValueToPointer(self.llvm)
141-
}
142-
}
143-
14427
/// A `JIT` is a Just-In-Time compiler that will compile and execute LLVM IR
14528
/// that has been generated in a `Module`. It can execute arbitrary functions
14629
/// and return the value the function generated, allowing you to write
@@ -177,22 +60,6 @@ public final class JIT {
17760
LLVMRunStaticConstructors(self.llvm)
17861
}
17962

180-
/// Runs the specified function with the provided arguments by compiling
181-
/// it to machine code for the target architecture used to initialize this
182-
/// JIT.
183-
///
184-
/// - parameters:
185-
/// - function: The function you wish to execute
186-
/// - args: The arguments you wish to pass to the function
187-
/// - returns: The LLVM value that the function returned
188-
public func runFunction(_ function: Function, args: [JITValue]) -> JITValue {
189-
var irArgs = args.map { $0.llvm as Optional }
190-
return irArgs.withUnsafeMutableBufferPointer { buf in
191-
return JITValue(llvm: LLVMRunFunction(llvm, function.asLLVM(),
192-
UInt32(buf.count), buf.baseAddress))
193-
}
194-
}
195-
19663
/// Retrieves a pointer to the function compiled by this JIT.
19764
/// - parameter name: The name of the function you wish to look up.
19865
/// - returns: A pointer to the result of compiling the specified function.

0 commit comments

Comments
 (0)