n386cal.pas 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. Generate i386 assembler for in call nodes
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit n386cal;
  19. {$i fpcdefs.inc}
  20. interface
  21. { $define AnsiStrRef}
  22. uses
  23. ncgcal;
  24. type
  25. ti386callnode = class(tcgcallnode)
  26. protected
  27. procedure pop_parasize(pop_size:longint);override;
  28. procedure extra_interrupt_code;override;
  29. end;
  30. implementation
  31. uses
  32. globtype,systems,
  33. cutils,verbose,globals,
  34. {$ifdef GDB}
  35. gdb,
  36. {$endif GDB}
  37. cgbase,
  38. cpubase,paramgr,
  39. aasmtai,aasmcpu,
  40. ncal,nbas,nmem,nld,ncnv,
  41. cga,cgobj,cpuinfo;
  42. {*****************************************************************************
  43. TI386CALLNODE
  44. *****************************************************************************}
  45. procedure ti386callnode.extra_interrupt_code;
  46. begin
  47. emit_none(A_PUSHF,S_L);
  48. emit_reg(A_PUSH,S_L,NR_CS);
  49. end;
  50. procedure ti386callnode.pop_parasize(pop_size:longint);
  51. var
  52. hreg : tregister;
  53. begin
  54. { better than an add on all processors }
  55. if pop_size=4 then
  56. begin
  57. hreg:=cg.getintregister(exprasmlist,OS_INT);
  58. exprasmlist.concat(taicpu.op_reg(A_POP,S_L,hreg));
  59. cg.ungetregister(exprasmlist,hreg);
  60. end
  61. { the pentium has two pipes and pop reg is pairable }
  62. { but the registers must be different! }
  63. else
  64. if (pop_size=8) and
  65. not(cs_littlesize in aktglobalswitches) and
  66. (aktoptprocessor=ClassPentium) then
  67. begin
  68. hreg:=cg.getintregister(exprasmlist,OS_INT);
  69. exprasmlist.concat(taicpu.op_reg(A_POP,S_L,hreg));
  70. cg.ungetregister(exprasmlist,hreg);
  71. hreg:=cg.getintregister(exprasmlist,OS_INT);
  72. exprasmlist.concat(taicpu.op_reg(A_POP,S_L,hreg));
  73. cg.ungetregister(exprasmlist,hreg);
  74. end
  75. else
  76. if pop_size<>0 then
  77. exprasmlist.concat(taicpu.op_const_reg(A_ADD,S_L,pop_size,NR_ESP));
  78. end;
  79. begin
  80. ccallnode:=ti386callnode;
  81. end.
  82. {
  83. $Log$
  84. Revision 1.101 2004-06-20 08:55:31 florian
  85. * logs truncated
  86. Revision 1.100 2004/06/16 20:07:10 florian
  87. * dwarf branch merged
  88. Revision 1.99.2.1 2004/05/02 12:45:32 peter
  89. * enabled cpuhasfixedstack for x86-64 again
  90. * fixed size of temp allocation for parameters
  91. }