rarvgas.pas 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. {
  2. Copyright (c) 2019 by Jeppe Johansen
  3. Does the parsing for the RISC-V GNU AS styled inline assembler.
  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. unit rarvgas;
  18. {$I fpcdefs.inc}
  19. interface
  20. uses
  21. raatt,
  22. cpubase;
  23. type
  24. trvattreader = class(tattreader)
  25. function is_targetdirective(const s: string): boolean; override;
  26. procedure HandleTargetDirective; override;
  27. end;
  28. implementation
  29. uses
  30. { helpers }
  31. cutils,
  32. { global }
  33. globtype,globals,verbose,
  34. systems,
  35. { aasm }
  36. aasmbase,aasmtai,aasmdata,aasmcpu,
  37. { symtable }
  38. symconst,symsym,symdef,
  39. { parser }
  40. procinfo,
  41. rabase,rautils,
  42. cgbase,cgobj,cgrv
  43. ;
  44. function trvattreader.is_targetdirective(const s: string): boolean;
  45. begin
  46. case s of
  47. '.option':
  48. result:=true
  49. else
  50. Result:=inherited is_targetdirective(s);
  51. end;
  52. end;
  53. procedure trvattreader.HandleTargetDirective;
  54. var
  55. id: string;
  56. begin
  57. case actasmpattern of
  58. '.option':
  59. begin
  60. consume(AS_TARGET_DIRECTIVE);
  61. id:=actasmpattern;
  62. Consume(AS_ID);
  63. curList.concat(tai_directive.create(asd_option, lower(id)));
  64. end
  65. else
  66. inherited HandleTargetDirective;
  67. end;
  68. end;
  69. end.