navrinl.pas 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. {
  2. Copyright (c) 1998-2017 by Florian Klaempfl
  3. Generates AVR inline nodes
  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 navrinl;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. node,ninl,ncginl;
  22. type
  23. tavrinlinenode = class(tcginlinenode)
  24. function pass_typecheck_cpu:tnode;override;
  25. function first_cpu : tnode;override;
  26. procedure pass_generate_code_cpu;override;
  27. end;
  28. implementation
  29. uses
  30. compinnr,
  31. aasmdata,
  32. aasmcpu,
  33. symdef,
  34. cgbase,
  35. cpubase;
  36. function tavrinlinenode.pass_typecheck_cpu : tnode;
  37. begin
  38. Result:=nil;
  39. case inlinenumber of
  40. in_avr_nop,
  41. in_avr_sleep,
  42. in_avr_sei,
  43. in_avr_wdr,
  44. in_avr_cli:
  45. begin
  46. CheckParameters(0);
  47. resultdef:=voidtype;
  48. end;
  49. else
  50. Result:=inherited pass_typecheck_cpu;
  51. end;
  52. end;
  53. function tavrinlinenode.first_cpu : tnode;
  54. begin
  55. Result:=nil;
  56. case inlinenumber of
  57. in_avr_nop,
  58. in_avr_sleep,
  59. in_avr_sei,
  60. in_avr_wdr,
  61. in_avr_cli:
  62. begin
  63. expectloc:=LOC_VOID;
  64. resultdef:=voidtype;
  65. end;
  66. else
  67. Result:=inherited first_cpu;
  68. end;
  69. end;
  70. procedure tavrinlinenode.pass_generate_code_cpu;
  71. begin
  72. case inlinenumber of
  73. in_avr_nop:
  74. current_asmdata.CurrAsmList.concat(taicpu.op_none(A_NOP));
  75. in_avr_sleep:
  76. current_asmdata.CurrAsmList.concat(taicpu.op_none(A_SLEEP));
  77. in_avr_sei:
  78. current_asmdata.CurrAsmList.concat(taicpu.op_none(A_SEI));
  79. in_avr_wdr:
  80. current_asmdata.CurrAsmList.concat(taicpu.op_none(A_WDR));
  81. in_avr_cli:
  82. current_asmdata.CurrAsmList.concat(taicpu.op_none(A_CLI));
  83. else
  84. inherited pass_generate_code_cpu;
  85. end;
  86. end;
  87. begin
  88. cinlinenode:=tavrinlinenode;
  89. end.