cginfo.pas 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. This unit exports some types and constants for the code generation
  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. {# This unit exports some types which are used across the code generator }
  19. unit cginfo;
  20. {$i fpcdefs.inc}
  21. interface
  22. uses cpuinfo,symconst;
  23. type
  24. {# Generic opcodes, which must be supported by all processors
  25. }
  26. topcg =
  27. (
  28. OP_NONE,
  29. OP_ADD, { simple addition }
  30. OP_AND, { simple logical and }
  31. OP_DIV, { simple unsigned division }
  32. OP_IDIV, { simple signed division }
  33. OP_IMUL, { simple signed multiply }
  34. OP_MUL, { simple unsigned multiply }
  35. OP_NEG, { simple negate }
  36. OP_NOT, { simple logical not }
  37. OP_OR, { simple logical or }
  38. OP_SAR, { arithmetic shift-right }
  39. OP_SHL, { logical shift left }
  40. OP_SHR, { logical shift right }
  41. OP_SUB, { simple subtraction }
  42. OP_XOR { simple exclusive or }
  43. );
  44. {# Generic flag values - used for jump locations }
  45. TOpCmp =
  46. (
  47. OC_NONE,
  48. OC_EQ, { equality comparison }
  49. OC_GT, { greater than (signed) }
  50. OC_LT, { less than (signed) }
  51. OC_GTE, { greater or equal than (signed) }
  52. OC_LTE, { less or equal than (signed) }
  53. OC_NE, { not equal }
  54. OC_BE, { less or equal than (unsigned) }
  55. OC_B, { less than (unsigned) }
  56. OC_AE, { greater or equal than (unsigned) }
  57. OC_A { greater than (unsigned) }
  58. );
  59. { OS_NO is also used memory references with large data that can
  60. not be loaded in a register directly }
  61. TCgSize = (OS_NO,
  62. { integer registers }
  63. OS_8,OS_16,OS_32,OS_64,OS_S8,OS_S16,OS_S32,OS_S64,
  64. { single,double,extended,comp }
  65. OS_F32,OS_F64,OS_F80,OS_C64,
  66. { multi-media sizes: split in byte, word, dword, ... }
  67. { entities, then the signed counterparts }
  68. OS_M8,OS_M16,OS_M32,OS_M64,OS_M128,OS_MS8,OS_MS16,OS_MS32,
  69. OS_MS64,OS_MS128);
  70. const
  71. tcgsize2size : Array[tcgsize] of integer =
  72. { integer values }
  73. (0,1,2,4,8,1,2,4,8,
  74. { floating point values }
  75. 4,8,EXTENDED_SIZE,8,
  76. { multimedia values }
  77. 1,2,4,8,16,1,2,4,8,16);
  78. tfloat2tcgsize: array[tfloattype] of tcgsize =
  79. (OS_F32,OS_F64,OS_F80,OS_C64,OS_C64);
  80. tcgsize2tfloat: array[OS_F32..OS_C64] of tfloattype =
  81. (s32real,s64real,s80real,s64comp);
  82. { Table to convert tcgsize variables to the correspondending
  83. unsigned types }
  84. tcgsize2unsigned : array[tcgsize] of tcgsize = (OS_NO,
  85. OS_8,OS_16,OS_32,OS_64,OS_8,OS_16,OS_32,OS_64,
  86. OS_F32,OS_F64,OS_F80,OS_C64,
  87. OS_M8,OS_M16,OS_M32,OS_M64,OS_M128,OS_M8,OS_M16,OS_M32,
  88. OS_M64,OS_M128);
  89. implementation
  90. end.
  91. {
  92. $Log$
  93. Revision 1.16 2002-09-07 15:25:01 peter
  94. * old logs removed and tabs fixed
  95. Revision 1.15 2002/08/05 18:27:48 carl
  96. + more more more documentation
  97. + first version include/exclude (can't test though, not enough scratch for i386 :()...
  98. Revision 1.14 2002/08/04 19:06:41 carl
  99. + added generic exception support (still does not work!)
  100. + more documentation
  101. Revision 1.13 2002/07/07 09:52:32 florian
  102. * powerpc target fixed, very simple units can be compiled
  103. * some basic stuff for better callparanode handling, far from being finished
  104. Revision 1.12 2002/07/01 16:23:52 peter
  105. * cg64 patch
  106. * basics for currency
  107. * asnode updates for class and interface (not finished)
  108. Revision 1.11 2002/05/27 19:16:08 carl
  109. + added comments to virtual comparison flags
  110. Revision 1.10 2002/05/18 13:34:05 peter
  111. * readded missing revisions
  112. Revision 1.9 2002/05/16 19:46:35 carl
  113. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  114. + try to fix temp allocation (still in ifdef)
  115. + generic constructor calls
  116. + start of tassembler / tmodulebase class cleanup
  117. Revision 1.7 2002/05/13 19:54:36 peter
  118. * removed n386ld and n386util units
  119. * maybe_save/maybe_restore added instead of the old maybe_push
  120. Revision 1.6 2002/05/06 19:48:26 carl
  121. + added more patches from Mazen for SPARC port
  122. Revision 1.5 2002/04/21 19:46:52 carl
  123. + added patch for SPARC from Mazen (to move to cpuinfo)
  124. Revision 1.4 2002/04/21 15:26:15 carl
  125. * move stuff to cpuinfo and cpubase
  126. + documented
  127. Revision 1.3 2002/04/20 21:32:23 carl
  128. + generic FPC_CHECKPOINTER
  129. + first parameter offset in stack now portable
  130. * rename some constants
  131. + move some cpu stuff to other units
  132. - remove unused constents
  133. * fix stacksize for some targets
  134. * fix generic size problems which depend now on EXTEND_SIZE constant
  135. Revision 1.2 2002/04/19 15:46:01 peter
  136. * mangledname rewrite, tprocdef.mangledname is now created dynamicly
  137. in most cases and not written to the ppu
  138. * add mangeledname_prefix() routine to generate the prefix of
  139. manglednames depending on the current procedure, object and module
  140. * removed static procprefix since the mangledname is now build only
  141. on demand from tprocdef.mangledname
  142. Revision 1.1 2002/04/02 18:09:47 jonas
  143. + initial implementation (Peter forgot to commit it)
  144. }