cgcpu.pas 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 by Florian Klaempfl
  4. This unit implements the code generator for the Alpha
  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. {
  19. This unit implements the code generator for the Alpha.
  20. }
  21. unit cgcpu;
  22. {$i fpcdefs.inc}
  23. interface
  24. uses
  25. cgbase,cgobj,aasmbase,aasmtai,aasmcpu,cginfo,cpubase,cpuinfo;
  26. type
  27. pcgalpha = ^tcgalpha;
  28. tcgalpha = class(tcg)
  29. procedure a_call_name(list : taasmoutput;const s : string);override;
  30. procedure a_load_const_reg(list : taasmoutput;size : tcgsize;a : aword;register : tregister);override;
  31. procedure a_load_reg_ref(list : taasmoutput;size : tcgsize;register : tregister;const ref : treference);override;
  32. procedure a_load_ref_reg(list : taasmoutput;size : tcgsize;const ref : treference;register : tregister);override;
  33. procedure a_load_reg_reg(list : taasmoutput;fromsize, tosize : tcgsize;reg1,reg2 : tregister);override;
  34. procedure a_cmp_const_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;
  35. reg : tregister; l : tasmlabel);override;
  36. procedure a_cmp_reg_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;reg1,reg2 : tregister;l : tasmlabel);
  37. procedure a_cmp_reg_ref_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;reg : tregister;l : tasmlabel);
  38. procedure a_cmp_ref_const_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;
  39. reg : tregister; l : tasmlabel);
  40. procedure a_loadaddr_ref_reg(list : taasmoutput;const ref : treference;r : tregister);override;
  41. procedure g_stackframe_entry(list : taasmoutput;localsize : longint);override;
  42. procedure g_maybe_loadself(list : taasmoutput);override;
  43. procedure g_restore_frame_pointer(list : taasmoutput);override;
  44. end;
  45. implementation
  46. uses
  47. globtype,globals;
  48. procedure tcgalpha.g_stackframe_entry(list : taasmoutput;localsize : longint);
  49. begin
  50. list.concat(taicpu.op_reg_ref(A_LDGP,Global_pointer,new_reference(R_27,0)));
  51. list.concat(taicpu.op_reg_ref(A_LDA,stack_pointer_reg,new_reference(stack_pointer_reg,-LocalSize)));
  52. If LocalSize<>0 then
  53. list.concat(tai_frame.create(Global_pointer,LocalSize,R_27,0));
  54. { Always generate a frame pointer. }
  55. list.concat(taicpu.op_reg_reg_reg(A_BIS,stack_pointer_reg,stack_pointer_reg,frame_pointer_reg));
  56. end;
  57. procedure g_exitcode(list : taasmoutput;parasize : longint; nostackframe,inlined : boolean);
  58. begin
  59. { Restore stack pointer from frame pointer }
  60. list.Concat (taicpu.op_reg_reg_reg(A_BIS,frame_pointer_reg,frame_pointer_reg,stack_pointer_reg));
  61. { Restore previous stack position}
  62. list.Concat (taicpu.op_reg_const_reg(A_ADDQ,stack_pointer_reg,Parasize,stack_pointer_reg));
  63. { return... }
  64. list.Concat(taicpu.op_reg_ref_const(A_RET,stack_pointer_reg,new_reference(Return_pointer,0),1));
  65. { end directive
  66. Concat (paiend,init(''));
  67. }
  68. end;
  69. procedure tcgalpha.a_call_name(list : taasmoutput;const s : string);
  70. begin
  71. { list^.concat(taicpu,op_sym(A_CALL,S_NO,newasmsymbol(s)))); }
  72. {!!!!!!!!!1 offset is ignored }
  73. abstract;
  74. end;
  75. procedure tcgalpha.a_load_const_reg(list : taasmoutput;size : tcgsize;a : aword;register : tregister);
  76. begin
  77. end;
  78. procedure tcgalpha.a_load_reg_ref(list : taasmoutput;size : tcgsize;register : tregister;const ref : treference);
  79. begin
  80. end;
  81. procedure tcgalpha.a_load_ref_reg(list : taasmoutput;size : tcgsize;const ref : treference;register : tregister);
  82. begin
  83. end;
  84. procedure tcgalpha.a_load_reg_reg(list : taasmoutput;fromsize, tosize : tcgsize;reg1,reg2 : tregister);
  85. begin
  86. end;
  87. procedure tcgalpha.a_cmp_const_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;reg : tregister;
  88. l : tasmlabel);
  89. begin
  90. end;
  91. procedure tcgalpha.a_cmp_reg_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;reg1,reg2 : tregister;l : tasmlabel);
  92. begin
  93. end;
  94. procedure tcgalpha.a_cmp_reg_ref_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;reg : tregister;l : tasmlabel);
  95. begin
  96. end;
  97. procedure tcgalpha.a_cmp_ref_const_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;
  98. reg : tregister; l : tasmlabel);
  99. begin
  100. end;
  101. procedure tcgalpha.a_loadaddr_ref_reg(list : taasmoutput;const ref : treference;r : tregister);
  102. begin
  103. end;
  104. procedure tcgalpha.g_maybe_loadself(list : taasmoutput);
  105. begin
  106. end;
  107. procedure tcgalpha.g_restore_frame_pointer(list : taasmoutput);
  108. begin
  109. end;
  110. end.
  111. {
  112. $Log$
  113. Revision 1.3 2002-09-29 23:42:45 florian
  114. * several fixes to get forward with alpha compilation
  115. Revision 1.2 2002/09/07 15:25:10 peter
  116. * old logs removed and tabs fixed
  117. Revision 1.1 2002/08/18 09:06:54 florian
  118. * alpha files moved compiler/alpha
  119. }