@@ -105,47 +105,57 @@ export CompilerConfig
105
105
# the configuration of the compiler
106
106
107
107
"""
108
- CompilerConfig(target, params; kernel=true, entry_abi=:specfunc, always_inline=false)
108
+ CompilerConfig(target, params; kernel=true, entry_abi=:specfunc, entry_name=nothing,
109
+ always_inline=false)
109
110
110
111
Construct a `CompilerConfig` that will be used to drive compilation for the given `target`
111
112
and `params`.
112
113
113
- The `entry_abi` can be either `:specfunc` the default, or `:func`. `:specfunc` expects the
114
- arguments to be passed in registers, simple return values are returned in registers as well,
115
- and complex return values are returned on the stack using `sret`, the calling convention is
116
- `fastcc`. The `:func` abi is simpler with a calling convention of the first argument being
117
- the function itself (to support closures), the second argument being a pointer to a vector
118
- of boxed Julia values and the third argument being the number of values, the return value
119
- will also be boxed. The `:func` abi will internally call the `:specfunc` abi, but is
120
- generally easier to invoke directly.
121
-
122
- `always_inline` specifies if the Julia front-end should inline all functions into one if
123
- possible.
114
+ Several keyword arguments can be used to customize the compilation process:
115
+
116
+ - `kernel`: specifies if the function should be compiled as a kernel, or as a regular
117
+ function. This is used to determine the calling convention and for validation purposes.
118
+ - `entry_abi`: can be either `:specfunc` the default, or `:func`. `:specfunc` expects the
119
+ arguments to be passed in registers, simple return values are returned in registers as
120
+ well, and complex return values are returned on the stack using `sret`, the calling
121
+ convention is `fastcc`. The `:func` abi is simpler with a calling convention of the first
122
+ argument being the function itself (to support closures), the second argument being a
123
+ pointer to a vector of boxed Julia values and the third argument being the number of
124
+ values, the return value will also be boxed. The `:func` abi will internally call the
125
+ `:specfunc` abi, but is generally easier to invoke directly.
126
+ - `entry_name`: the name that will be used for the entrypoint function. If `nothing` (the
127
+ default), the name will be generated automatically.
128
+ - `always_inline` specifies if the Julia front-end should inline all functions into one if
129
+ possible.
124
130
"""
125
131
struct CompilerConfig{T,P}
126
132
target:: T
127
133
params:: P
128
134
129
135
kernel:: Bool
136
+ name:: Union{Nothing,String}
130
137
entry_abi:: Symbol
131
138
always_inline:: Bool
132
139
133
140
function CompilerConfig (target:: AbstractCompilerTarget ,
134
141
params:: AbstractCompilerParams ;
135
- kernel:: Bool = true ,
136
- entry_abi:: Symbol = :specfunc ,
142
+ kernel= true ,
143
+ name= nothing ,
144
+ entry_abi= :specfunc ,
137
145
always_inline= false )
138
146
if entry_abi ∉ (:specfunc , :func )
139
147
error (" Unknown entry_abi=$entry_abi " )
140
148
end
141
- new {typeof(target), typeof(params)} (target, params, kernel, entry_abi, always_inline)
149
+ new {typeof(target), typeof(params)} (target, params, kernel, name, entry_abi,
150
+ always_inline)
142
151
end
143
152
end
144
153
145
154
# copy constructor
146
155
CompilerConfig (cfg:: CompilerConfig ; target= cfg. target, params= cfg. params,
147
- kernel= cfg. kernel, entry_abi= cfg. entry_abi, always_inline= cfg. always_inline) =
148
- CompilerConfig (target, params; kernel, entry_abi, always_inline)
156
+ kernel= cfg. kernel, name= cfg. name, entry_abi= cfg. entry_abi,
157
+ always_inline= cfg. always_inline) =
158
+ CompilerConfig (target, params; kernel, entry_abi, name, always_inline)
149
159
150
160
function Base. show (io:: IO , @nospecialize (cfg:: CompilerConfig{T} )) where {T}
151
161
print (io, " CompilerConfig for " , T)
@@ -156,6 +166,7 @@ function Base.hash(cfg::CompilerConfig, h::UInt)
156
166
h = hash (cfg. params, h)
157
167
158
168
h = hash (cfg. kernel, h)
169
+ h = hash (cfg. name, h)
159
170
h = hash (cfg. entry_abi, h)
160
171
h = hash (cfg. always_inline, h)
161
172
@@ -170,11 +181,11 @@ export CompilerJob
170
181
# a specific invocation of the compiler, bundling everything needed to generate code
171
182
172
183
struct CompilerJob{T,P}
173
- config:: CompilerConfig{T,P}
174
184
source:: FunctionSpec
185
+ config:: CompilerConfig{T,P}
175
186
176
- CompilerJob (cfg:: CompilerConfig{T,P} , src :: FunctionSpec ) where {T,P} =
177
- new {T,P} (cfg, src )
187
+ CompilerJob (src :: FunctionSpec , cfg:: CompilerConfig{T,P} ) where {T,P} =
188
+ new {T,P} (src, cfg )
178
189
end
179
190
180
191
0 commit comments