llvminfo.pas 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. {
  2. Copyright (c) 2010, 2013, 2015 by Jonas Maebe
  3. Basic Processor information for LLVM
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. {$i fpcdefs.inc}
  18. Unit llvminfo;
  19. Interface
  20. uses
  21. globtype;
  22. Type
  23. { possible supported processors for this target }
  24. tllvmversion =
  25. (llvmver_invalid,
  26. { Xcode versions use snapshots of LLVM and don't correspond to released
  27. versions of llvm (they don't ship with the llvm utilities either, but
  28. they do come with Clang, which can be used instead of opt/llc) }
  29. llvmver_xc_10_0,
  30. llvmver_xc_10_1,
  31. llvmver_7_0,
  32. llvmver_7_1,
  33. llvmver_8_0,
  34. llvmver_xc_11,
  35. llvmver_9_0,
  36. llvmver_10_0,
  37. llvmver_11_0
  38. );
  39. type
  40. tllvmversionflag = (
  41. llvmflag_memcpy_indiv_align, { memcpy intrinsic supports separate alignment for source and dest }
  42. llvmflag_null_pointer_valid, { supports "null-pointer-is-valid" attribute, which indicates access to nil should not be optimized as undefined behaviour }
  43. llvmflag_constrained_fptrunc_fpext, { supports constrained fptrunc and fpext intrinsics }
  44. llvmflag_constrained_fptoi_itofp, { supports constrained fptosi/fptoui/uitofp/sitofp instrinsics }
  45. llvmflag_generic_constrained_si64tofp, { supports sitofp for 64 bit signed integers on all targets }
  46. llvmflag_null_pointer_valid_new { new syntax for the null pointer valid attribute: null_pointer_is_valid }
  47. );
  48. tllvmversionflags = set of tllvmversionflag;
  49. Const
  50. llvmversionstr : array[tllvmversion] of string[14] = (
  51. '',
  52. 'Xcode-10.0',
  53. 'Xcode-10.1',
  54. '7.0',
  55. '7.1',
  56. '8.0',
  57. 'Xcode-11.0',
  58. '9.0',
  59. '10.0',
  60. '11.0'
  61. );
  62. llvmversion_properties: array[tllvmversion] of tllvmversionflags =
  63. (
  64. { invalid } [],
  65. { llvmver_xc_10_0 } [],
  66. { llvmver_xc_10_1 } [],
  67. { llvmver_7_0 } [llvmflag_memcpy_indiv_align,llvmflag_null_pointer_valid],
  68. { llvmver_7_1 } [llvmflag_memcpy_indiv_align,llvmflag_null_pointer_valid],
  69. { llvmver_8_0 } [llvmflag_memcpy_indiv_align,llvmflag_null_pointer_valid],
  70. { llvmver_xc_11 } [llvmflag_memcpy_indiv_align,llvmflag_null_pointer_valid],
  71. { llvmver_9_0 } [llvmflag_memcpy_indiv_align,llvmflag_null_pointer_valid,llvmflag_constrained_fptrunc_fpext],
  72. { llvmver_10_0 } [llvmflag_memcpy_indiv_align,llvmflag_null_pointer_valid,llvmflag_constrained_fptrunc_fpext,llvmflag_constrained_fptoi_itofp],
  73. { llvmver_11_0 } [llvmflag_memcpy_indiv_align,llvmflag_null_pointer_valid_new,llvmflag_constrained_fptrunc_fpext,llvmflag_constrained_fptoi_itofp]
  74. );
  75. { Supported optimizations, only used for information }
  76. supported_optimizerswitches = genericlevel1optimizerswitches+
  77. genericlevel2optimizerswitches+
  78. genericlevel3optimizerswitches-
  79. { no need to write info about those }
  80. [cs_opt_level1,cs_opt_level2,cs_opt_level3]+
  81. [cs_opt_loopunroll,cs_opt_stackframe,
  82. cs_opt_nodecse,cs_opt_reorder_fields,cs_opt_fastmath];
  83. level1optimizerswitches = genericlevel1optimizerswitches;
  84. level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches + [cs_opt_nodecse,cs_opt_stackframe];
  85. level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [];
  86. level4optimizerswitches = genericlevel4optimizerswitches + level3optimizerswitches + [];
  87. function llvmversion2enum(const s: string): tllvmversion;
  88. Implementation
  89. function llvmversion2enum(const s: string): tllvmversion;
  90. begin
  91. for result:=succ(low(llvmversionstr)) to high(llvmversionstr) do
  92. begin
  93. if s=llvmversionstr[result] then
  94. exit;
  95. end;
  96. result:=llvmver_invalid;
  97. end;
  98. end.