cgcpu.pas 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. {
  2. Copyright (c) 2010 by Jonas Maebe
  3. This unit implements the code generator for the Java VM
  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 cgcpu;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. globtype,parabase,
  22. cgbase,cgutils,cgobj,
  23. aasmbase,aasmtai,aasmdata,aasmcpu,
  24. cpubase,cpuinfo,
  25. node,symconst,SymType,symdef,
  26. rgcpu;
  27. type
  28. TCgJvm=class(tcg)
  29. public
  30. procedure init_register_allocators;override;
  31. procedure done_register_allocators;override;
  32. function getfpuregister(list:TAsmList;size:Tcgsize):Tregister;override;
  33. end;
  34. procedure create_codegen;
  35. implementation
  36. uses
  37. globals,verbose,systems,cutils,
  38. paramgr,fmodule,
  39. tgobj,
  40. procinfo,cpupi;
  41. {****************************************************************************
  42. Assembler code
  43. ****************************************************************************}
  44. procedure tcgjvm.init_register_allocators;
  45. begin
  46. inherited init_register_allocators;
  47. {$ifndef cpu64bitaddr}
  48. rg[R_INTREGISTER]:=Trgcpu.create(R_INTREGISTER,R_SUBD,
  49. [RS_R0],first_int_imreg,[]);
  50. {$else not cpu64bitaddr}
  51. rg[R_INTREGISTER]:=Trgcpu.create(R_INTREGISTER,R_SUBQ,
  52. [RS_R0],first_int_imreg,[]);
  53. {$endif not cpu64bitaddr}
  54. rg[R_FPUREGISTER]:=trgcpu.create(R_FPUREGISTER,R_SUBFD,
  55. [RS_R0],first_fpu_imreg,[]);
  56. rg[R_MMREGISTER]:=trgcpu.create(R_MMREGISTER,R_SUBNONE,
  57. [RS_R0],first_mm_imreg,[]);
  58. end;
  59. procedure tcgjvm.done_register_allocators;
  60. begin
  61. rg[R_INTREGISTER].free;
  62. rg[R_FPUREGISTER].free;
  63. rg[R_MMREGISTER].free;
  64. inherited done_register_allocators;
  65. end;
  66. function tcgjvm.getfpuregister(list:TAsmList;size:Tcgsize):Tregister;
  67. begin
  68. if size=OS_F64 then
  69. result:=rg[R_FPUREGISTER].getregister(list,R_SUBFD)
  70. else
  71. result:=rg[R_FPUREGISTER].getregister(list,R_SUBFS);
  72. end;
  73. procedure create_codegen;
  74. begin
  75. cg:=tcgjvm.Create;
  76. end;
  77. end.