n386cal.pas 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. cgbase,
  35. cpubase,paramgr,
  36. aasmtai,aasmcpu,
  37. ncal,nbas,nmem,nld,ncnv,
  38. cga,cgobj,cpuinfo;
  39. {*****************************************************************************
  40. TI386CALLNODE
  41. *****************************************************************************}
  42. procedure ti386callnode.extra_interrupt_code;
  43. begin
  44. emit_none(A_PUSHF,S_L);
  45. emit_reg(A_PUSH,S_L,NR_CS);
  46. end;
  47. procedure ti386callnode.pop_parasize(pop_size:longint);
  48. var
  49. hreg : tregister;
  50. begin
  51. { better than an add on all processors }
  52. if pop_size=4 then
  53. begin
  54. hreg:=cg.getintregister(exprasmlist,OS_INT);
  55. exprasmlist.concat(taicpu.op_reg(A_POP,S_L,hreg));
  56. end
  57. { the pentium has two pipes and pop reg is pairable }
  58. { but the registers must be different! }
  59. else
  60. if (pop_size=8) and
  61. not(cs_littlesize in aktglobalswitches) and
  62. (aktoptprocessor=ClassPentium) then
  63. begin
  64. hreg:=cg.getintregister(exprasmlist,OS_INT);
  65. exprasmlist.concat(taicpu.op_reg(A_POP,S_L,hreg));
  66. hreg:=cg.getintregister(exprasmlist,OS_INT);
  67. exprasmlist.concat(taicpu.op_reg(A_POP,S_L,hreg));
  68. end
  69. else
  70. if pop_size<>0 then
  71. exprasmlist.concat(taicpu.op_const_reg(A_ADD,S_L,pop_size,NR_ESP));
  72. end;
  73. begin
  74. ccallnode:=ti386callnode;
  75. end.
  76. {
  77. $Log$
  78. Revision 1.103 2004-10-31 21:45:03 peter
  79. * generic tlocation
  80. * move tlocation to cgutils
  81. Revision 1.102 2004/09/25 14:23:54 peter
  82. * ungetregister is now only used for cpuregisters, renamed to
  83. ungetcpuregister
  84. * renamed (get|unget)explicitregister(s) to ..cpuregister
  85. * removed location-release/reference_release
  86. Revision 1.101 2004/06/20 08:55:31 florian
  87. * logs truncated
  88. Revision 1.100 2004/06/16 20:07:10 florian
  89. * dwarf branch merged
  90. Revision 1.99.2.1 2004/05/02 12:45:32 peter
  91. * enabled cpuhasfixedstack for x86-64 again
  92. * fixed size of temp allocation for parameters
  93. }