tgcpu.pas 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. {
  2. Copyright (C) 2010 by Jonas Maebe
  3. This unit handles the temporary variables for the JVM
  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. {
  18. This unit handles the temporary variables for the JVM.
  19. }
  20. unit tgcpu;
  21. {$i fpcdefs.inc}
  22. interface
  23. uses
  24. globtype,
  25. aasmdata,
  26. symtype,tgobj;
  27. type
  28. { ttgjvm }
  29. ttgjvm = class(ttgobj)
  30. protected
  31. function alloctemp(list: TAsmList; size, alignment: longint; temptype: ttemptype; def: tdef): longint; override;
  32. public
  33. procedure setfirsttemp(l : longint); override;
  34. end;
  35. implementation
  36. uses
  37. verbose;
  38. { ttgjvm }
  39. function ttgjvm.alloctemp(list: TAsmList; size, alignment: longint; temptype: ttemptype; def: tdef): longint;
  40. begin
  41. { the JVM only supports 1 slot (= 4 bytes in FPC) and 2 slot (= 8 bytes in
  42. FPC) temps on the stack. double and int64 are 2 slots, the rest is one slot.
  43. There are no problems with reusing the same slot for a value of a different
  44. type. There are no alignment requirements either. }
  45. if size<4 then
  46. size:=4;
  47. if not(size in [4,8]) then
  48. internalerror(2010121401);
  49. { don't pass on "def", since we don't care if a slot is used again for a
  50. different type }
  51. result:=inherited alloctemp(list, size shr 2, 1, temptype, nil);
  52. end;
  53. procedure ttgjvm.setfirsttemp(l: longint);
  54. begin
  55. firsttemp:=l;
  56. lasttemp:=l;
  57. end;
  58. begin
  59. tgobjclass:=ttgjvm;
  60. end.