|
23 | 23 | ABC_ERROR_MSG = "Translator is an abstract base class, use a derived class." |
24 | 24 | DOUBLE_SET_SOURCE = "Translator.set_source() should only be called once." |
25 | 25 |
|
26 | | -FLANG_COMPILERS = ["mpifort", "mpif90", "mpif77", "flang", "flang-new"] |
27 | | -CLANG_COMPILERS = ["mpic++", "mpicc", "mpiCC", "mpicxx", "clang", "clang++", "acpp"] |
28 | | - |
29 | 26 |
|
30 | 27 | @cython.cclass |
31 | 28 | class Translator: |
@@ -279,19 +276,23 @@ def populate_ccscops(self, options: list[str]): |
279 | 276 | jscop = json.load(fp) |
280 | 277 | self._proc_jscop(jscop) |
281 | 278 |
|
| 279 | + def _compiler_options(self): |
| 280 | + for flang in ["mpifort", "mpif90", "mpif77", "flang", "flang-new"]: |
| 281 | + if flang in self.compiler: |
| 282 | + return ["-O0"] |
| 283 | + for clang in ["mpic++", "mpicc", "mpiCC", "mpicxx", "clang", "clang++", "acpp"]: |
| 284 | + if clang in self.compiler: |
| 285 | + return ["-O0", "-Xclang", "-disable-O0-optnone"] |
| 286 | + raise ValueError(f"Unsupported compiler: {self.compiler}") |
| 287 | + |
282 | 288 | def _get_pre_polly_bc(self, options: list[str]) -> Path: |
283 | 289 | compile_O0_bc = self.cwd / self.source.with_suffix(".pre_polly.bc").name |
284 | 290 | pre_polly_bc = self.cwd / self.source.with_suffix(".pre_polly.bc").name |
285 | 291 | if pre_polly_bc.exists(): |
286 | 292 | return pre_polly_bc |
287 | | - if self.compiler in FLANG_COMPILERS: |
288 | | - compiler_opts = ["-O0"] |
289 | | - elif self.compiler in CLANG_COMPILERS: |
290 | | - compiler_opts = ["-O0", "-Xclang", "-disable-O0-optnone"] |
291 | | - else: |
292 | | - raise ValueError(f"Unsupported compiler: {self.compiler}") |
293 | | - compile_cmd = [self.compiler, *options, "-c", "-emit-llvm", str(self.source)] |
294 | | - compile_cmd += [*compiler_opts, "-o", str(compile_O0_bc)] |
| 293 | + compiler_opts = self._compiler_options() |
| 294 | + compile_cmd = [self.compiler, *compiler_opts, *options, "-c", "-emit-llvm"] |
| 295 | + compile_cmd += [str(self.source), "-o", str(compile_O0_bc)] |
295 | 296 | self._run(compile_cmd, "compiling with O0") |
296 | 297 | opt_cmd = ["opt", f"-passes={self.before_polly_passes}"] |
297 | 298 | opt_cmd += [str(compile_O0_bc), f"-o={str(pre_polly_bc)}"] |
|
0 commit comments