2
0

options.pas 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. {
  2. Copyright (C) <avx-testfile-generator> <Torsten Grundke>
  3. This source is free software; you can redistribute it and/or modify it under
  4. the terms of the GNU General Public License as published by the Free
  5. Software Foundation; either version 2 of the License, or (at your option)
  6. any later version.
  7. This code is distributed in the hope that it will be useful, but WITHOUT ANY
  8. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. details.
  11. A copy of the GNU General Public License is available on the World Wide Web
  12. at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing
  13. to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  14. MA 02110-1301, USA.
  15. }
  16. {$mode objfpc}
  17. unit options;
  18. interface
  19. type
  20. { TOptions }
  21. TOptions = class(TObject)
  22. private
  23. FAVX512: boolean;
  24. FHelp: boolean;
  25. FX64: boolean;
  26. FOutputFormat: Char;
  27. FPath: string;
  28. FMemRef: boolean;
  29. public
  30. constructor Create;
  31. procedure LoadParams;
  32. property Help: boolean read FHelp write FHelp;
  33. property OutputFormat: Char read FOutputFormat write FOutputFormat;
  34. property X64: boolean read FX64 write FX64;
  35. property AVX512: boolean read FAVX512 write FAVX512;
  36. property Path: string read FPath write FPath;
  37. property MemRef: boolean read FMemref write FMemRef;
  38. end;
  39. implementation
  40. uses SysUtils;
  41. { TOptions }
  42. constructor TOptions.Create;
  43. begin
  44. FHelp := false;
  45. FX64 := false;
  46. FAVX512 := false;
  47. FOutputFormat := '?';
  48. FPath := '';
  49. FMemRef := false;
  50. end;
  51. procedure TOptions.LoadParams;
  52. var
  53. i: integer;
  54. sParam: Char;
  55. sValue: String;
  56. IsInvalidParam: boolean;
  57. begin
  58. if ParamCount = 0 then FHelp := true
  59. else FHelp := false;
  60. FX64 := false;
  61. FOutputFormat := 'f'; // default = fpc
  62. FPath := IncludeTrailingBackslash(GetCurrentDir);
  63. for i := 1 to ParamCount do
  64. begin
  65. if copy(ParamStr(i), 1, 1) = '-' then
  66. begin
  67. sParam := copy(ParamStr(i) + ' ', 2, 1)[1];
  68. sValue := copy(ParamStr(i), 3, length(ParamStr(i)));
  69. IsInvalidParam := false;
  70. case sParam of
  71. 'h': FHelp := true;
  72. 'f': if sValue = 'fpc' then FOutputFormat := 'f'
  73. else if sValue = 'nasm' then FOutputFormat := 'n'
  74. else if sValue = 'fasm' then FOutputFormat := 'F'
  75. else if sValue = 'fpcinc' then FOutputFormat := 'I'
  76. else if sValue = 'fpcmref' then FOutputFormat := 'm'
  77. else IsInvalidParam := true;
  78. 'p': if sValue = 'x8664' then
  79. begin
  80. Fx64 := true;
  81. end
  82. else IsInvalidParam := true;
  83. 'z': FAVX512 := true;
  84. 'o': if sValue <> '' then
  85. begin
  86. FPath := IncludeTrailingBackslash(sValue);
  87. end
  88. else
  89. begin
  90. FPath := '';
  91. end;
  92. else begin
  93. FHelp := true;
  94. writeln(format('invalid param "%s"', [ParamStr(i)]));
  95. end;
  96. end;
  97. end
  98. else IsInvalidParam := true;
  99. if IsInvalidParam then
  100. begin
  101. FHelp := true;
  102. writeln(format('invalid param "%s"', [ParamStr(i)]));
  103. end;
  104. end;
  105. end;
  106. end.