mips.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. from numpy.distutils.cpuinfo import cpu
  2. from numpy.distutils.fcompiler import FCompiler
  3. compilers = ['MIPSFCompiler']
  4. class MIPSFCompiler(FCompiler):
  5. compiler_type = 'mips'
  6. description = 'MIPSpro Fortran Compiler'
  7. version_pattern = r'MIPSpro Compilers: Version (?P<version>[^\s*,]*)'
  8. executables = {
  9. 'version_cmd' : ["<F90>", "-version"],
  10. 'compiler_f77' : ["f77", "-f77"],
  11. 'compiler_fix' : ["f90", "-fixedform"],
  12. 'compiler_f90' : ["f90"],
  13. 'linker_so' : ["f90", "-shared"],
  14. 'archiver' : ["ar", "-cr"],
  15. 'ranlib' : None
  16. }
  17. module_dir_switch = None #XXX: fix me
  18. module_include_switch = None #XXX: fix me
  19. pic_flags = ['-KPIC']
  20. def get_flags(self):
  21. return self.pic_flags + ['-n32']
  22. def get_flags_opt(self):
  23. return ['-O3']
  24. def get_flags_arch(self):
  25. opt = []
  26. for a in '19 20 21 22_4k 22_5k 24 25 26 27 28 30 32_5k 32_10k'.split():
  27. if getattr(cpu, 'is_IP%s'%a)():
  28. opt.append('-TARG:platform=IP%s' % a)
  29. break
  30. return opt
  31. def get_flags_arch_f77(self):
  32. r = None
  33. if cpu.is_r10000(): r = 10000
  34. elif cpu.is_r12000(): r = 12000
  35. elif cpu.is_r8000(): r = 8000
  36. elif cpu.is_r5000(): r = 5000
  37. elif cpu.is_r4000(): r = 4000
  38. if r is not None:
  39. return ['r%s' % (r)]
  40. return []
  41. def get_flags_arch_f90(self):
  42. r = self.get_flags_arch_f77()
  43. if r:
  44. r[0] = '-' + r[0]
  45. return r
  46. if __name__ == '__main__':
  47. from numpy.distutils import customized_fcompiler
  48. print(customized_fcompiler(compiler='mips').get_version())