@@ -152,7 +152,7 @@ def __call__(
152
152
153
153
154
154
@dataclass
155
- class CompilerConfiguration :
155
+ class PreprocessorConfiguration :
156
156
"""
157
157
Represents the configuration for a specific file, including:
158
158
- Macro definitions
@@ -167,7 +167,7 @@ class CompilerConfiguration:
167
167
pass_name : str = "default"
168
168
169
169
170
- class Compiler :
170
+ class ArgumentParser :
171
171
"""
172
172
Represents the behavior of a specific compiler.
173
173
"""
@@ -180,7 +180,7 @@ def __init__(self, path: str):
180
180
if _importcfg is None :
181
181
load_importcfg ()
182
182
183
- def parse_args (self , argv : list [str ]) -> list [CompilerConfiguration ]:
183
+ def parse_args (self , argv : list [str ]) -> list [PreprocessorConfiguration ]:
184
184
"""
185
185
Parameters
186
186
----------
@@ -189,21 +189,21 @@ def parse_args(self, argv: list[str]) -> list[CompilerConfiguration]:
189
189
190
190
Returns
191
191
-------
192
- list[CompilerConfiguration ]
192
+ list[PreprocessorConfiguration ]
193
193
A list of compiler configurations, each representing
194
194
a separate pass, that describe the compiler's behavior
195
195
after parsing `argv`.
196
196
"""
197
197
args = _parse_compiler_args (argv + _importcfg [self .name ])
198
- configuration = CompilerConfiguration (
198
+ configuration = PreprocessorConfiguration (
199
199
args .defines ,
200
200
args .include_paths ,
201
201
args .include_files ,
202
202
)
203
203
return [configuration ]
204
204
205
205
206
- class ClangCompiler ( Compiler ):
206
+ class ClangArgumentParser ( ArgumentParser ):
207
207
"""
208
208
Represents the behavior of Clang-based compilers.
209
209
"""
@@ -216,7 +216,7 @@ class ClangCompiler(Compiler):
216
216
"spir64_fpga" ,
217
217
]
218
218
219
- def parse_args (self , argv : list [str ]) -> list [CompilerConfiguration ]:
219
+ def parse_args (self , argv : list [str ]) -> list [PreprocessorConfiguration ]:
220
220
args = _parse_compiler_args (argv + _importcfg [self .name ])
221
221
222
222
sycl = False
@@ -252,7 +252,7 @@ def parse_args(self, argv: list[str]) -> list[CompilerConfiguration]:
252
252
include_files = args .include_files .copy ()
253
253
include_paths = args .include_paths .copy ()
254
254
255
- if pass_ in ClangCompiler .device_passes :
255
+ if pass_ in ClangArgumentParser .device_passes :
256
256
defines .append ("__SYCL_DEVICE_ONLY__" )
257
257
258
258
if "spir64" in pass_ or pass_ == "x86_64" :
@@ -262,7 +262,7 @@ def parse_args(self, argv: list[str]) -> list[CompilerConfiguration]:
262
262
if pass_ == "default" and omp :
263
263
defines .append ("_OPENMP" )
264
264
265
- configuration = CompilerConfiguration (
265
+ configuration = PreprocessorConfiguration (
266
266
defines ,
267
267
include_paths ,
268
268
include_files ,
@@ -274,30 +274,30 @@ def parse_args(self, argv: list[str]) -> list[CompilerConfiguration]:
274
274
return configurations
275
275
276
276
277
- class GnuCompiler ( Compiler ):
277
+ class GnuArgumentParser ( ArgumentParser ):
278
278
"""
279
279
Represents the behavior of GNU-based compilers.
280
280
"""
281
281
282
- def parse_args (self , argv : list [str ]) -> list [CompilerConfiguration ]:
282
+ def parse_args (self , argv : list [str ]) -> list [PreprocessorConfiguration ]:
283
283
args = _parse_compiler_args (argv + _importcfg [self .name ])
284
284
for arg in argv :
285
285
if arg in ["-fopenmp" ]:
286
286
args .defines .append ("_OPENMP" )
287
- configuration = CompilerConfiguration (
287
+ configuration = PreprocessorConfiguration (
288
288
args .defines ,
289
289
args .include_paths ,
290
290
args .include_files ,
291
291
)
292
292
return [configuration ]
293
293
294
294
295
- class NvccCompiler ( Compiler ):
295
+ class NvccArgumentParser ( ArgumentParser ):
296
296
"""
297
297
Represents the behavior of the NVCC compiler.
298
298
"""
299
299
300
- def parse_args (self , argv : list [str ]) -> list [CompilerConfiguration ]:
300
+ def parse_args (self , argv : list [str ]) -> list [PreprocessorConfiguration ]:
301
301
args = _parse_compiler_args (argv + _importcfg [self .name ])
302
302
303
303
omp = False
@@ -328,7 +328,7 @@ def parse_args(self, argv: list[str]) -> list[CompilerConfiguration]:
328
328
if pass_ == "default" and omp :
329
329
defines .append ("_OPENMP" )
330
330
331
- configuration = CompilerConfiguration (
331
+ configuration = PreprocessorConfiguration (
332
332
defines ,
333
333
include_paths ,
334
334
include_files ,
@@ -343,34 +343,34 @@ def parse_args(self, argv: list[str]) -> list[CompilerConfiguration]:
343
343
_seen_compiler = collections .defaultdict (lambda : False )
344
344
345
345
346
- def recognize_compiler (path : str ) -> Compiler :
346
+ def recognize_compiler (path : str ) -> ArgumentParser :
347
347
"""
348
348
Attempt to recognize the compiler, given a path.
349
- Return a Compiler object.
349
+ Return a ArgumentParser object.
350
350
"""
351
- compiler = None
351
+ parser = None
352
352
compiler_name = os .path .basename (path )
353
353
if compiler_name in ["clang" , "clang++" ]:
354
- compiler = ClangCompiler (path )
354
+ parser = ClangArgumentParser (path )
355
355
elif compiler_name in ["gcc" , "g++" ]:
356
- compiler = GnuCompiler (path )
356
+ parser = GnuArgumentParser (path )
357
357
elif compiler_name in ["icx" , "icpx" , "ifx" ]:
358
- compiler = ClangCompiler (path )
358
+ parser = ClangArgumentParser (path )
359
359
elif compiler_name == "nvcc" :
360
- compiler = NvccCompiler (path )
360
+ parser = NvccArgumentParser (path )
361
361
else :
362
- compiler = Compiler (path )
362
+ parser = ArgumentParser (path )
363
363
364
364
if not _seen_compiler [compiler_name ]:
365
- if compiler :
366
- log .info (f"Recognized compiler: { compiler . name } ." )
365
+ if parser :
366
+ log .info (f"Recognized compiler: { compiler_name } ." )
367
367
else :
368
368
log .warning (
369
369
f"Unrecognized compiler: { compiler_name } . "
370
370
+ "Some implicit behavior may be missed." ,
371
371
)
372
372
_seen_compiler [compiler_name ] = True
373
- return compiler
373
+ return parser
374
374
375
375
376
376
def load_database (dbpath , rootdir ):
@@ -414,13 +414,13 @@ def load_database(dbpath, rootdir):
414
414
415
415
# Parse command-line arguments, emulating compiler-specific behavior.
416
416
compiler_name = os .path .basename (command .arguments [0 ])
417
- compiler = recognize_compiler (compiler_name )
418
- compiler_configs = compiler .parse_args (command .arguments [1 :])
417
+ parser = recognize_compiler (compiler_name )
418
+ preprocessor_configs = parser .parse_args (command .arguments [1 :])
419
419
420
420
# Create a configuration entry for each compiler pass.
421
421
# Each compiler pass may set different defines, etc.
422
- for compiler_config in compiler_configs :
423
- entry = asdict (compiler_config )
422
+ for preprocessor_config in preprocessor_configs :
423
+ entry = asdict (preprocessor_config )
424
424
425
425
entry ["file" ] = path
426
426
0 commit comments