@@ -117,17 +117,37 @@ export CompilerJob
117117
118118# a specific invocation of the compiler, bundling everything needed to generate code
119119
120+ """
121+ CompilerJob(target, source, params, entry_abi)
122+
123+ Construct a `CompilerJob` for `source` that will be used to drive compilation for
124+ the given `target` and `params`. The `entry_abi` can be either `:specfunc` the default,
125+ or `:func`. `:specfunc` expects the arguments to be passed in registers, simple
126+ return values are returned in registers as well, and complex return values are returned
127+ on the stack using `sret`, the calling convention is `fastcc`. The `:func` abi is simpler
128+ with a calling convention of the first argument being the function itself (to support closures),
129+ the second argument being a pointer to a vector of boxed Julia values and the third argument
130+ being the number of values, the return value will also be boxed. The `:func` abi
131+ will internally call the `:specfunc` abi, but is generally easier to invoke directly.
132+ """
120133struct CompilerJob{T,P,F}
121134 target:: T
122135 source:: F
123136 params:: P
137+ entry_abi:: Symbol
124138
125- CompilerJob (target:: AbstractCompilerTarget , source:: FunctionSpec , params:: AbstractCompilerParams ) =
126- new {typeof(target), typeof(params), typeof(source)} (target, source, params)
139+ function CompilerJob (target:: AbstractCompilerTarget , source:: FunctionSpec , params:: AbstractCompilerParams , entry_abi:: Symbol )
140+ if entry_abi ∉ (:specfunc , :func )
141+ error (" Unknown entry_abi=$entry_abi " )
142+ end
143+ new {typeof(target), typeof(params), typeof(source)} (target, source, params, entry_abi)
144+ end
127145end
146+ CompilerJob (target:: AbstractCompilerTarget , source:: FunctionSpec , params:: AbstractCompilerParams ; entry_abi= :specfunc ) =
147+ CompilerJob (target, source, params, entry_abi)
128148
129149Base. similar (@nospecialize (job:: CompilerJob ), @nospecialize (source:: FunctionSpec )) =
130- CompilerJob (job. target, source, job. params)
150+ CompilerJob (job. target, source, job. params, job . entry_abi )
131151
132152function Base. show (io:: IO , @nospecialize (job:: CompilerJob{T} )) where {T}
133153 print (io, " CompilerJob of " , job. source, " for " , T)
@@ -137,6 +157,7 @@ function Base.hash(job::CompilerJob, h::UInt)
137157 h = hash (job. target, h)
138158 h = hash (job. source, h)
139159 h = hash (job. params, h)
160+ h = hash (job. entry_abi, h)
140161 h
141162end
142163
0 commit comments