cpupi.pas 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. {
  2. Copyright (c) 2002 by Florian Klaempfl
  3. This unit contains the CPU specific part of tprocinfo
  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. { This unit contains the CPU specific part of tprocinfo. }
  18. unit cpupi;
  19. {$I fpcdefs.inc}
  20. interface
  21. uses
  22. cutils,aasmdata,
  23. globtype, cgutils, cgbase,
  24. procinfo, cpuinfo, psub;
  25. type
  26. tloongarch64procinfo = class(tcgprocinfo)
  27. stackframesize,
  28. floatregstart : aint;
  29. stackpaddingreg: TSuperRegister;
  30. needs_frame_pointer: boolean;
  31. constructor create(aparent: tprocinfo); override;
  32. procedure set_first_temp_offset; override;
  33. function calc_stackframe_size: longint; override;
  34. end;
  35. implementation
  36. uses
  37. globals, systems,
  38. cpubase,
  39. aasmtai,
  40. tgobj,cgobj,
  41. symconst, symsym, paramgr, symutil, symtable,
  42. verbose,
  43. aasmcpu;
  44. constructor tloongarch64procinfo.create(aparent: tprocinfo);
  45. begin
  46. inherited create(aparent);
  47. maxpushedparasize := 0;
  48. { GCC option -fomit-frame-pointer is default. }
  49. framepointer:=NR_STACK_POINTER_REG;
  50. end;
  51. procedure tloongarch64procinfo.set_first_temp_offset;
  52. begin
  53. { TODO framepointer:=NR_STACK_POINTER_REG; Need get backtrace updated. }
  54. { TODO Profile }
  55. if (po_nostackframe in procdef.procoptions) then
  56. begin
  57. tg.setfirsttemp(align(maxpushedparasize,
  58. max(current_settings.alignment.localalignmin,8)));
  59. end
  60. else
  61. begin
  62. tg.setfirsttemp(align(maxpushedparasize,
  63. max(current_settings.alignment.localalignmin,8)));
  64. end;
  65. end;
  66. function tloongarch64procinfo.calc_stackframe_size: longint;
  67. var
  68. firstfloatreg,lastfloatreg,
  69. r : byte;
  70. floatsavesize : aword;
  71. regs: tcpuregisterset;
  72. begin
  73. maxpushedparasize:=align(maxpushedparasize,
  74. max(current_settings.alignment.localalignmin,8));
  75. floatsavesize:=0;
  76. case current_settings.fputype of
  77. fpu_fd:
  78. begin
  79. floatsavesize:=0;
  80. regs:=cg.rg[R_FPUREGISTER].used_in_proc-paramanager.get_volatile_registers_fpu(pocall_stdcall);
  81. for r:=RS_F0 to RS_F31 do
  82. if r in regs then
  83. inc(floatsavesize,8);
  84. end;
  85. else
  86. ;
  87. end;
  88. result:=align(tg.direction*tg.lasttemp,
  89. max(current_settings.alignment.localalignmin,8))
  90. +maxpushedparasize+aint(floatsavesize);
  91. if tg.direction=1 then
  92. floatregstart:=result-aint(floatsavesize)
  93. else
  94. floatregstart:=-result+maxpushedparasize;
  95. end;
  96. begin
  97. cprocinfo := tloongarch64procinfo;
  98. end.