cgbase.pas 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 by Florian Klaempfl
  4. This units implements some code generator helper routines
  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 cgbase;
  19. interface
  20. type
  21. TOpCg = (OP_ADD,OP_AND,OP_DIV,OP_IDIV,OP_IMUL,OP_MUL,OP_NEG,OP_NOT,
  22. OP_OR,OP_SAR,OP_SHL,OP_SHR,OP_SUB,OP_XOR);
  23. TOpCmp = (OC_NONE,OC_EQ,OC_GT,OC_LT,OC_GTE,OC_LTE,OC_NE,OC_BE,OC_B,
  24. OC_AE,OC_A);
  25. TCgSize = (OS_NO,OS_8,OS_16,OS_32,OS_64);
  26. const
  27. { defines the default address size for a processor }
  28. { and defines the natural int size for a processor }
  29. {$ifdef i386}
  30. OS_ADDR = OS_32;
  31. OS_INT = OS_32;
  32. {$endif i386}
  33. {$ifdef alpha}
  34. OS_ADDR = OS_64;
  35. OS_INT = OS_64;
  36. {$endif alpha}
  37. {$ifdef powerpc}
  38. OS_ADDR = OS_32;
  39. OS_INT = OS_32;
  40. {$endif powercc}
  41. {$ifdef ia64}
  42. OS_ADDR = OS_64;
  43. OS_INT = OS_64;
  44. {$endif ia64}
  45. function inverse_opcmp(opcmp: topcmp): topcmp;
  46. function commutativeop(op: topcg): boolean;
  47. implementation
  48. function inverse_opcmp(opcmp: topcmp): topcmp;
  49. const
  50. list: array[TOpCg] of TOpCmp =
  51. (OC_NONE,OC_NE,OC_LE,OC_GTE,OC_LT,OC_GT,OC_EQ,OC_A,OC_AE,
  52. OC_B,OC_BE);
  53. begin
  54. inverse_opcmp := list[opcmp];
  55. end;
  56. function commutativeop(op: topcg): boolean;
  57. const
  58. list: array[topcg] of boolean =
  59. (true,true,false,false,true,true,false,false,
  60. true,false,false,false,false,true);
  61. begin
  62. commutativeop := list[op];
  63. end;
  64. end.
  65. {
  66. $Log$
  67. Revision 1.3 2001-09-06 15:25:55 jonas
  68. * changed type of tcg from object to class -> abstract methods are now
  69. a lot cleaner :)
  70. + more updates: load_*_loc methods, op_*_* methods, g_flags2reg method
  71. (if possible with geenric implementation and necessary ppc
  72. implementations)
  73. * worked a bit further on cgflw, now working on exitnode
  74. Revision 1.2 2000/11/29 00:30:51 florian
  75. * unused units removed from uses clause
  76. * some changes for widestrings
  77. Revision 1.1 2000/07/13 06:30:07 michael
  78. + Initial import
  79. }