home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / compiler / vbcc / machines / i386 / machine.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-31  |  5.3 KB  |  147 lines

  1. /*  Example of a code-generator for an Intel 386 or higher.         */
  2.  
  3. /*  Here should be routines to emulate the target's data types on   */
  4. /*  the host machine. Currently there are only macros so that the   */
  5. /*  host's arithmetic will be used.                                 */
  6.  
  7. /*  Declaration of the data types of the target machine.            */
  8. /*  zchar, zshort, zint and zlong are the basic signed integers.    */
  9. /*  zuchar, zushort, zuint and zulong are the basic unsigned ints.  */
  10. /*  zfloat and zdouble are float and double, of course.             */
  11. /*  zpointer is a generic pointer. Currently vbcc only supports     */
  12. /*  targets where all pointers have the same representation.        */
  13. typedef signed char zchar;
  14. typedef unsigned char zuchar;
  15. typedef signed short zshort;
  16. typedef unsigned short zushort;
  17. typedef signed int zint;
  18. typedef unsigned int zuint;
  19. typedef signed long zlong;
  20. typedef unsigned long zulong;
  21. typedef float zfloat;
  22. typedef double zdouble;
  23. typedef unsigned long zpointer;
  24.  
  25. /*  These functions convert data types of the target machine.       */
  26. /*  E.g. zl2zul takes a zlong and yields a zulong.                  */
  27. #define zc2zl(x) ((zlong)(x))
  28. #define zs2zl(x) ((zlong)(x))
  29. #define zi2zl(x) ((zlong)(x))
  30. #define zl2zc(x) ((zchar)(x))
  31. #define zl2zs(x) ((zshort)(x))
  32. #define zl2zi(x) ((zint)(x))
  33. #define zl2zul(x) ((zulong)(x))
  34. #define zuc2zul(x) ((zulong)(x))
  35. #define zus2zul(x) ((zulong)(x))
  36. #define zui2zul(x) ((zulong)(x))
  37. #define zul2zuc(x) ((zuchar)(x))
  38. #define zul2zus(x) ((zushort)(x))
  39. #define zul2zui(x) ((zuint)(x))
  40. #define zul2zl(x) ((zlong)(x))
  41. #define zf2zd(x) ((zdouble)(x))
  42. #define zd2zf(x) ((zfloat)(x))
  43. #define zl2zd(x) ((zdouble)(x))
  44. #define zd2zl(x) ((zlong)(x))
  45. #define zul2zd(x) ((zdouble)(x))
  46. #define zd2zul(x) ((zulong)(x))
  47. /*  Note that zul2zp must yield a valid null-pointer on the target  */
  48. /*  machine if the zulong is zero.                                  */
  49. #define zul2zp(x) ((zpointer)(x))
  50. #define zp2zul(x) ((zulong)(x))
  51.  
  52. /*  These functions convert data types of the host machine into     */
  53. /*  data types of the target machine and the other way round.       */
  54. #define l2zl(x) ((zlong)(x))
  55. #define zl2l(x) ((long)(x))
  56. #define ul2zul(x) ((zulong)(x))
  57. #define zul2ul(x) ((unsigned long)(x))
  58. #define d2zd(x) ((zdouble)(x))
  59. #define zd2d(x) ((double)(x))
  60.  
  61. /*  These functions perform arithmetic and logical operations on    */
  62. /*  the data types of the target machine.                           */
  63. #define zlmult(a,b) ((a)*(b))
  64. #define zulmult(a,b) ((a)*(b))
  65. #define zdmult(a,b) ((a)*(b))
  66. #define zldiv(a,b) ((a)/(b))
  67. #define zuldiv(a,b) ((a)/(b))
  68. #define zddiv(a,b) ((a)/(b))
  69. #define zlmod(a,b) ((a)%(b))
  70. #define zulmod(a,b) ((a)%(b))
  71. #define zllshift(a,b) ((a)<<(b))
  72. #define zullshift(a,b) ((a)<<(b))
  73. #define zlrshift(a,b) ((a)>>(b))
  74. #define zulrshift(a,b) ((a)>>(b))
  75. #define zladd(a,b) ((a)+(b))
  76. #define zuladd(a,b) ((a)+(b))
  77. #define zdadd(a,b) ((a)+(b))
  78. #define zlsub(a,b) ((a)-(b))
  79. #define zulsub(a,b) ((a)-(b))
  80. #define zdsub(a,b) ((a)-(b))
  81. #define zlor(a,b)   ((a)|(b))
  82. #define zulor(a,b)   ((a)|(b))
  83. #define zland(a,b)   ((a)&(b))
  84. #define zuland(a,b)   ((a)&(b))
  85. #define zlxor(a,b)   ((a)^(b))
  86. #define zulxor(a,b)   ((a)^(b))
  87. #define zlkompl(a)  (~(a))
  88. #define zulkompl(a)  (~(a))
  89. #define zdkompl(a)  (~(a))
  90.  
  91. /*  Comparison functions. Must return non-zero if equation is true. */
  92. #define zlleq(a,b) ((a)<=(b))
  93. #define zulleq(a,b) ((a)<=(b))
  94. #define zdleq(a,b) ((a)<=(b))
  95. #define zdeqto(a,b)    ((a)==(b))
  96. #define zleqto(a,b) ((a)==(b))
  97. #define zuleqto(a,b) ((a)==(b))
  98. #define zpleq(a,b)     ((a)<=(b))
  99. #define zpeqto(a,b)     ((a)==(b))
  100.  
  101.  
  102. /*  This struct can be used to implement machine-specific           */
  103. /*  addressing-modes.                                               */
  104. /*  Not used in this code-generrator.                               */
  105. struct AddressingMode{
  106.     int never_used;
  107. };
  108.  
  109. /*  The number of registers of the target machine.                  */
  110. #define MAXR 16
  111.  
  112. /*  Number of commandline-options the code-generator accepts.       */
  113. #define MAXGF 10
  114.  
  115. /*  If this is set to zero vbcc will not generate ICs where the     */
  116. /*  target operand is the same as the 2nd source operand.           */
  117. /*  This can sometimes simplify the code-generator, but usually     */
  118. /*  the code is better if the code-generator allows it.             */
  119. #define USEQ2ASZ 0
  120.  
  121. /*  This specifies the smallest integer type that can be added to a */
  122. /*  pointer.                                                        */
  123. #define MINADDI2P INT
  124.  
  125. /*  If the bytes of an integer are ordered most significant byte    */
  126. /*  byte first and then decreasing set BIGENDIAN to 1.              */
  127. #define BIGENDIAN 0
  128.  
  129. /*  If the bytes of an integer are ordered lest significant byte    */
  130. /*  byte first and then increasing set LITTLEENDIAN to 1.           */
  131. #define LITTLEENDIAN 1
  132.  
  133. /*  Note that BIGENDIAN and LITTLEENDIAN are mutually exclusive.    */
  134.  
  135. /*  If switch-statements should be generated as a sequence of       */
  136. /*  SUB,TST,BEQ ICs rather than COMPARE,BEQ ICs set this to 1.      */
  137. /*  This can yield better code on some machines.                    */
  138. #define SWITCHSUBS 0
  139.  
  140. /*  In optimizing compilation certain library memcpy/strcpy-calls   */
  141. /*  with length known at compile-time will be inlined using an      */
  142. /*  ASSIGN-IC if the size is less or equal to INLINEMEMCPY.         */
  143. /*  The type used for the ASSIGN-IC will be UNSIGNED|CHAR.          */
  144. #define INLINEMEMCPY 1024
  145.  
  146.  
  147.