cg386.pas 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. {
  2. $Id$
  3. Copyright (c) 1993-98 by Florian Klaempfl
  4. This unit implements the code generator for the i386
  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 cg386;
  19. interface
  20. uses
  21. cgobj,aasm
  22. {$i cpuunit.inc}
  23. ;
  24. type
  25. pcg386 = ^tcg386;
  26. tcg386 = object(tcg)
  27. procedure a_push_reg(list : paasmoutput;r : tregister);virtual;
  28. procedure a_call_name(list : paasmoutput;const s : string;
  29. offset : longint);virtual;
  30. procedure a_load_const8_ref(list : paasmoutput;b : byte;const ref : treference);virtual;
  31. procedure a_load_const16_ref(list : paasmoutput;w : word;const ref : treference);virtual;
  32. procedure a_load_const32_ref(list : paasmoutput;l : longint;const ref : treference);virtual;
  33. procedure a_load_const64_ref(list : paasmoutput;q : qword;const ref : treference);virtual;
  34. procedure g_stackframe_entry(list : paasmoutput;localsize : longint);virtual;
  35. constructor init;
  36. end;
  37. implementation
  38. uses
  39. globtype,globals;
  40. constructor tcg386.init;
  41. begin
  42. inherited init;
  43. end;
  44. procedure tcg386.g_stackframe_entry(list : paasmoutput;localsize : longint);
  45. begin
  46. if localsize<>0 then
  47. begin
  48. if (cs_littlesize in aktglobalswitches) and (localsize<=65535) then
  49. list^.insert(new(pai386,op_const_const(A_ENTER,S_NO,localsize,0)))
  50. else
  51. begin
  52. list^.concat(new(pai386,op_reg(A_PUSH,S_L,R_EBP)));
  53. list^.concat(new(pai386,op_reg_reg(A_MOV,S_L,R_ESP,R_EBP)));
  54. list^.concat(new(pai386,op_const_reg(A_SUB,S_L,localsize,R_ESP)));
  55. end;
  56. end
  57. else
  58. begin
  59. list^.concat(new(pai386,op_reg(A_PUSH,S_L,R_EBP)));
  60. list^.concat(new(pai386,op_reg_reg(A_MOV,S_L,R_ESP,R_EBP)));
  61. end;
  62. end;
  63. procedure tcg386.a_call_name(list : paasmoutput;const s : string;
  64. offset : longint);
  65. begin
  66. list^.concat(new(pai386,op_csymbol(A_CALL,S_NO,newcsymbol(s,offset))));
  67. end;
  68. procedure tcg386.a_push_reg(list : paasmoutput;r : tregister);
  69. begin
  70. list^.concat(new(pai386,op_reg(A_PUSH,regsize(r),r)));
  71. end;
  72. procedure tcg386.a_load_const8_ref(list : paasmoutput;b : byte;const ref : treference);
  73. begin
  74. abstract;
  75. end;
  76. procedure tcg386.a_load_const16_ref(list : paasmoutput;w : word;const ref : treference);
  77. begin
  78. abstract;
  79. end;
  80. procedure tcg386.a_load_const32_ref(list : paasmoutput;l : longint;const ref : treference);
  81. begin
  82. abstract;
  83. end;
  84. procedure tcg386.a_load_const64_ref(list : paasmoutput;q : qword;const ref : treference);
  85. begin
  86. abstract;
  87. end;
  88. end.
  89. {
  90. $Log$
  91. Revision 1.2 1999-01-23 23:29:43 florian
  92. * first running version of the new code generator
  93. * when compiling exceptions under Linux fixed
  94. Revision 1.1 1998/12/15 22:17:02 florian
  95. * first version
  96. }