@@ -66,34 +66,24 @@ struct FunctionSpec
66
66
tt:: Type
67
67
world:: UInt
68
68
69
- kernel:: Bool
70
- name:: Union{Nothing,String}
71
-
72
- FunctionSpec (ft:: Type , tt:: Type , world:: Integer = get_world (ft, tt);
73
- kernel= true , name= nothing ) =
74
- new (ft, tt, world, kernel, name)
69
+ FunctionSpec (ft:: Type , tt:: Type , world:: Integer = get_world (ft, tt)) =
70
+ new (ft, tt, world)
75
71
end
76
72
77
73
# copy constructor
78
- FunctionSpec (spec:: FunctionSpec ; ft= spec. ft, tt= spec. tt, world= spec. world,
79
- kernel= spec. kernel, name= spec. name) =
80
- FunctionSpec (ft, tt, world; kernel, name)
74
+ FunctionSpec (spec:: FunctionSpec ; ft= spec. ft, tt= spec. tt, world= spec. world) =
75
+ FunctionSpec (ft, tt, world)
81
76
82
77
function Base. hash (spec:: FunctionSpec , h:: UInt )
83
78
h = hash (spec. ft, h)
84
79
h = hash (spec. tt, h)
85
80
h = hash (spec. world, h)
86
81
87
- h = hash (spec. kernel, h)
88
- h = hash (spec. name, h)
89
-
90
82
return h
91
83
end
92
84
93
85
function signature (@nospecialize (spec:: FunctionSpec ))
94
- fn = if spec. name != = nothing
95
- spec. name
96
- elseif spec. ft. name. mt == Symbol. name. mt
86
+ fn = if spec. ft. name. mt == Symbol. name. mt
97
87
# uses shared method table, so name is not unique to this function type
98
88
nameof (spec. ft)
99
89
else
@@ -104,22 +94,21 @@ function signature(@nospecialize(spec::FunctionSpec))
104
94
end
105
95
106
96
function Base. show (io:: IO , @nospecialize (spec:: FunctionSpec ))
107
- spec. kernel ? print (io, " kernel " ) : print (io, " function " )
108
97
print (io, signature (spec), " in world " , spec. world)
109
98
end
110
99
111
100
112
- # # job
101
+ # # config
113
102
114
- export CompilerJob
103
+ export CompilerConfig
115
104
116
- # a specific invocation of the compiler, bundling everything needed to generate code
105
+ # the configuration of the compiler
117
106
118
107
"""
119
- CompilerJob(source, target, params; entry_abi=:specfunc, always_inline=false)
108
+ CompilerConfig( target, params; kernel=true, entry_abi=:specfunc, always_inline=false)
120
109
121
- Construct a `CompilerJob` for `source` that will be used to drive compilation for the given
122
- `target` and `params`.
110
+ Construct a `CompilerConfig` that will be used to drive compilation for the given `target`
111
+ and `params`.
123
112
124
113
The `entry_abi` can be either `:specfunc` the default, or `:func`. `:specfunc` expects the
125
114
arguments to be passed in registers, simple return values are returned in registers as well,
@@ -133,46 +122,62 @@ generally easier to invoke directly.
133
122
`always_inline` specifies if the Julia front-end should inline all functions into one if
134
123
possible.
135
124
"""
136
- struct CompilerJob {T,P}
125
+ struct CompilerConfig {T,P}
137
126
target:: T
138
127
params:: P
139
- source:: FunctionSpec
140
128
129
+ kernel:: Bool
141
130
entry_abi:: Symbol
142
131
always_inline:: Bool
143
132
144
- function CompilerJob (source:: FunctionSpec ,
145
- target:: AbstractCompilerTarget ,
146
- params:: AbstractCompilerParams ;
147
- entry_abi:: Symbol = :specfunc , always_inline= false )
133
+ function CompilerConfig (target:: AbstractCompilerTarget ,
134
+ params:: AbstractCompilerParams ;
135
+ kernel:: Bool = true ,
136
+ entry_abi:: Symbol = :specfunc ,
137
+ always_inline= false )
148
138
if entry_abi ∉ (:specfunc , :func )
149
139
error (" Unknown entry_abi=$entry_abi " )
150
140
end
151
- new {typeof(target), typeof(params)} (target, params, source , entry_abi, always_inline)
141
+ new {typeof(target), typeof(params)} (target, params, kernel , entry_abi, always_inline)
152
142
end
153
143
end
154
144
155
145
# copy constructor
156
- CompilerJob (job :: CompilerJob ; source = job . source, target= job . target, params= job . params,
157
- entry_abi= job . entry_abi, always_inline= job . always_inline) =
158
- CompilerJob (source, target, params; entry_abi, always_inline)
146
+ 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)
159
149
160
- function Base. show (io:: IO , @nospecialize (job :: CompilerJob {T} )) where {T}
161
- print (io, " CompilerJob of " , job . source, " for " , T)
150
+ function Base. show (io:: IO , @nospecialize (cfg :: CompilerConfig {T} )) where {T}
151
+ print (io, " CompilerConfig for " , T)
162
152
end
163
153
164
- function Base. hash (job:: CompilerJob , h:: UInt )
165
- h = hash (job. source, h)
166
- h = hash (job. target, h)
167
- h = hash (job. params, h)
154
+ function Base. hash (cfg:: CompilerConfig , h:: UInt )
155
+ h = hash (cfg. target, h)
156
+ h = hash (cfg. params, h)
168
157
169
- h = hash (job. entry_abi, h)
170
- h = hash (job. always_inline, h)
158
+ h = hash (cfg. kernel, h)
159
+ h = hash (cfg. entry_abi, h)
160
+ h = hash (cfg. always_inline, h)
171
161
172
162
return h
173
163
end
174
164
175
165
166
+ # # job
167
+
168
+ export CompilerJob
169
+
170
+ # a specific invocation of the compiler, bundling everything needed to generate code
171
+
172
+ struct CompilerJob{T,P}
173
+ config:: CompilerConfig{T,P}
174
+ source:: FunctionSpec
175
+
176
+ CompilerJob (cfg:: CompilerConfig{T,P} , src:: FunctionSpec ) where {T,P} =
177
+ new {T,P} (cfg, src)
178
+ end
179
+
180
+
176
181
# # contexts
177
182
178
183
if VERSION >= v " 1.9.0-DEV.516"
@@ -233,7 +238,7 @@ function process_entry!(@nospecialize(job::CompilerJob), mod::LLVM.Module,
233
238
entry:: LLVM.Function )
234
239
ctx = context (mod)
235
240
236
- if job. source . kernel && needs_byval (job)
241
+ if job. config . kernel && needs_byval (job)
237
242
# pass all bitstypes by value; by default Julia passes aggregates by reference
238
243
# (this improves performance, and is mandated by certain back-ends like SPIR-V).
239
244
args = classify_arguments (job, eltype (llvmtype (entry)))
@@ -279,7 +284,7 @@ valid_function_pointer(@nospecialize(job::CompilerJob), ptr::Ptr{Cvoid}) = false
279
284
# the codeinfo cache to use
280
285
function ci_cache (@nospecialize (job:: CompilerJob ))
281
286
lock (GLOBAL_CI_CACHES_LOCK) do
282
- cache = get! (GLOBAL_CI_CACHES, (typeof (job. target), inference_params (job), optimization_params (job))) do
287
+ cache = get! (GLOBAL_CI_CACHES, (typeof (job. config . target), inference_params (job), optimization_params (job))) do
283
288
CodeCache ()
284
289
end
285
290
return cache
@@ -302,7 +307,7 @@ function optimization_params(@nospecialize(job::CompilerJob))
302
307
kwargs = (kwargs... , unoptimize_throw_blocks= false )
303
308
end
304
309
305
- if job. always_inline
310
+ if job. config . always_inline
306
311
kwargs = (kwargs... , inline_cost_threshold= typemax (Int))
307
312
end
308
313
0 commit comments