cginfo.pas 6.3 KB

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