sppara.pas 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. Calling conventions for the SPARC
  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. unit sppara;
  17. {$i fpcdefs.inc}
  18. interface
  19. uses
  20. globtype,
  21. cclasses,
  22. aasmtai,aasmdata,
  23. cpubase,cpuinfo,
  24. symconst,symbase,symsym,symtype,symdef,paramgr,parabase,cgbase,cgutils;
  25. type
  26. tsparcparamanager=class(TParaManager)
  27. function get_volatile_registers_int(calloption : tproccalloption):TCpuRegisterSet;override;
  28. function get_volatile_registers_fpu(calloption : tproccalloption):TCpuRegisterSet;override;
  29. function create_paraloc_info(p : TAbstractProcDef; side: tcallercallee):longint;override;
  30. function create_varargs_paraloc_info(p : TAbstractProcDef; varargspara:tvarargsparalist):longint;override;
  31. procedure create_paraloc_info_intern(p : tabstractprocdef; side: tcallercallee; paras: tparalist;
  32. var curintreg: longint; curfloatreg: tsuperregister; var cur_stack_offset: aword);virtual;abstract;
  33. end;
  34. type
  35. tparasupregs = array[0..5] of tsuperregister;
  36. pparasupregs = ^tparasupregs;
  37. const
  38. paraoutsupregs : tparasupregs = (RS_O0,RS_O1,RS_O2,RS_O3,RS_O4,RS_O5);
  39. parainsupregs : tparasupregs = (RS_I0,RS_I1,RS_I2,RS_I3,RS_I4,RS_I5);
  40. implementation
  41. uses
  42. cutils,verbose,systems,
  43. defutil,
  44. cgobj;
  45. function tsparcparamanager.get_volatile_registers_int(calloption : tproccalloption):TCpuRegisterSet;
  46. begin
  47. result:=[RS_G1,RS_O0,RS_O1,RS_O2,RS_O3,RS_O4,RS_O5,RS_O6,RS_O7];
  48. end;
  49. function tsparcparamanager.get_volatile_registers_fpu(calloption : tproccalloption):TCpuRegisterSet;
  50. begin
  51. result:=[RS_F0..RS_F31];
  52. end;
  53. function tsparcparamanager.create_varargs_paraloc_info(p : tabstractprocdef; varargspara:tvarargsparalist):longint;
  54. var
  55. curintreg : LongInt;
  56. curfloatreg : TSuperRegister;
  57. cur_stack_offset : aword;
  58. begin
  59. curintreg:=0;
  60. curfloatreg:=RS_F0;
  61. cur_stack_offset:=0;
  62. { calculate the registers for the normal parameters }
  63. create_paraloc_info_intern(p,callerside,p.paras,curintreg,curfloatreg,cur_stack_offset);
  64. { append the varargs }
  65. create_paraloc_info_intern(p,callerside,varargspara,curintreg,curfloatreg,cur_stack_offset);
  66. result:=cur_stack_offset;
  67. end;
  68. function tsparcparamanager.create_paraloc_info(p : tabstractprocdef; side: tcallercallee):longint;
  69. var
  70. curintreg : LongInt;
  71. curfloatreg : TSuperRegister;
  72. cur_stack_offset : aword;
  73. begin
  74. curintreg:=0;
  75. curfloatreg:=RS_F0;
  76. cur_stack_offset:=0;
  77. create_paraloc_info_intern(p,side,p.paras,curintreg,curfloatreg,cur_stack_offset);
  78. { Create Function result paraloc }
  79. create_funcretloc_info(p,side);
  80. { We need to return the size allocated on the stack }
  81. result:=cur_stack_offset;
  82. end;
  83. end.