home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Harvest C 1.3 / Source Code / CodeGen.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-04  |  5.6 KB  |  237 lines  |  [TEXT/ALFA]

  1. /*
  2.  * Harvest C
  3.  * 
  4.  * Copyright 1991 Eric W. Sink   All rights reserved.
  5.  * 
  6.  * This file defines the interface for code generation.
  7.  * 
  8.  */
  9.  
  10. #ifndef CodeGen_INTERFACE
  11. #define CodeGen_INTERFACE
  12.  
  13. typedef struct LocAM_S          LocAM_t;
  14. typedef LocAM_t P__H           *LocAMVia_t;
  15. typedef struct Inst_S           Inst_t;
  16. typedef Inst_t P__H            *InstVia_t;
  17. typedef struct InstList_S       InstList_t;
  18. typedef InstList_t P__H        *InstListVia_t;
  19. typedef struct SpillSlot_S      SpillSlot_t;
  20. typedef SpillSlot_t P__H       *SpillSlotVia_t;
  21. typedef struct RegisterRecord_S RegisterRecord_t;
  22.  
  23. #include "SymTable.h"
  24. #include "ParseTree.h"
  25. #include "Assem.h"
  26.  
  27. #define FOADD                     0x0000
  28. #define FOSUB                     0x0002
  29. #define FOMUL                     0x0004
  30. #define FODIV                     0x0006
  31. #define FOCMP                     0x0008
  32. #define FOCPX                     0x000A
  33. #define FOREM                     0x000C
  34. #define FOZ2X                     0x000E
  35. #define FOX2Z                     0x0010
  36. #define FOSQRT                     0x0012
  37. #define FORTI                     0x0014
  38. #define FOTTI                     0x0016
  39. #define FOSCALB                  0x0018
  40. #define FOLOGB                     0x001A
  41. #define FOCLASS                  0x001C
  42.  
  43. #define FOSETENV                 0x0001
  44. #define FOGETENV                 0x0003
  45. #define FOSETHV                  0x0005
  46. #define FOGETHV                  0x0007
  47. #define FOD2B                     0x0009
  48. #define FOB2D                     0x000B
  49. #define FONEG                     0x000D
  50. #define FOABS                     0x000F
  51. #define FOCPYSGN                 0x0011
  52. #define FONEXT                     0x0013
  53. #define FOSETXCP                 0x0015
  54. #define FOPROCENTRY              0x0017
  55. #define FOPROCEXIT                 0x0019
  56. #define FOTESTXCP                 0x001B
  57.  
  58. #define FFEXT                     0x0000
  59. #define FFDBL                     0x0800
  60. #define FFSGL                     0x1000
  61. #define FFINT                     0x2000
  62. #define FFLNG                     0x2800
  63. #define FFCOMP                     0x3000
  64.  
  65. #define FCEXT                     0x0000
  66. #define FCDBL                     0x4000
  67. #define FCSGL                     0x8000
  68.  
  69. /* Data structures for 68000 code generation. */
  70.  
  71. /* Addressing modes */
  72.  
  73. enum Size68 {
  74.     M68sz_extended = -3,
  75.     M68sz_double = -2,
  76.     M68sz_single = -1,
  77.     M68sz_byte = 1,
  78.     M68sz_word = 2,
  79.     M68sz_none = 3,        /* There is no data type with a size of 3 */
  80.     M68sz_long = 4
  81.     /*
  82.      * All sizes greater than 4 are structs/unions that need special
  83.      * handling.  Only the sizes given here can be generated directly as
  84.      * assembler, and the negative ones only work with 68881.
  85.      */
  86. };
  87.  
  88. #define NOREG68 100
  89.  
  90. enum Dictation68 {
  91.     M68dict_DReg = 1,
  92.     M68dict_AReg
  93. };
  94.  
  95. enum AddressingMode68 {
  96.     M68am_DReg = 1,
  97.     M68am_ARegDirect,
  98.     M68am_ARegIndirect,
  99.     M68am_ARegPostInc,
  100.     M68am_ARegPreDec,
  101.     M68am_ARegDisplace,
  102.     M68am_ARegDispIndx,
  103.     /* Above 7 are register modes */
  104.     M68am_AbsShort,
  105.     M68am_AbsLong,
  106.     M68am_PCDisplace,
  107.     M68am_PCLabelDisplace,
  108.     M68am_PCDispIndx,
  109.     /* Above 4 are absolute modes, mod=111 */
  110.     M68am_Immediate,
  111.     M68am_MultRegMove,
  112.     M68am_SR,
  113.     M68am_CCR,
  114.     M68am_USP,
  115.     M68am_Label,
  116.     M68am_FReg,
  117.     M68am_FSANEtemp,
  118.     M68am_ARegDisplaceFIELD,
  119.     M68am_ARegLabelDisplace,
  120.     M68am_WhatModeIsThis,
  121.     M68am_LargeGlobal,
  122.     M68am_OtherFormat,
  123.     M68am_CIdentifier,
  124.     M68am_LabelOffset
  125. };
  126.  
  127. enum RegisterState68 {
  128.     M68rs_Available = 1,
  129.     M68rs_Used
  130. };
  131.  
  132. enum OperandState68 {
  133.     M68os_valid = 1,
  134.     M68os_spilled
  135. };
  136.  
  137. enum SpillState68 {
  138.     M68ss_free = 1,
  139.     M68ss_used
  140. };
  141.  
  142. struct Inst_S {
  143.     Opcode_t                        OP;
  144.     LocAM_t P__H                   *left;
  145.     LocAM_t P__H                   *right;
  146.     enum Size68                     SZ;
  147.     struct Inst_S P__H             *prev;
  148.     struct Inst_S P__H             *next;
  149.     long                            Address;
  150.     unsigned char                   Bytes[16];    /* QQQQ What should 16 be ? */
  151.     short                           InstSize;
  152. };
  153.  
  154. struct InstList_S {
  155.     InstVia_t                       head;
  156.     InstVia_t                       tail;
  157.     int                             count;
  158.     LabSYMVia_t                     PendingLabel;
  159. };
  160.  
  161. struct SpillSlot_S {
  162.     LocAM_t P__H                   *SlotLoc;
  163.     short                           local;
  164.     short                           SlotSize;
  165.     enum SpillState68               status;
  166.     struct SpillSlot_S P__H        *next;
  167. };
  168.  
  169. struct RegisterRecord_S {
  170.     enum RegisterState68            status;
  171.     short                           waiting;
  172.     short                           count;
  173.     LocAM_t P__H                   *holder;
  174. };
  175.  
  176. enum AddressingMode68
  177.                                 GetLocAM(LocAMVia_t loc);
  178.  
  179. enum Size68
  180.                                 GetLocSZ(LocAMVia_t loc);
  181.  
  182. enum OperandState68
  183.                                 GetLocStatus(LocAMVia_t loc);
  184.  
  185. SpillSlotVia_t
  186. GetLocSlot(LocAMVia_t loc);
  187.  
  188. char
  189.                                 GetLocAReg(LocAMVia_t loc);
  190.  
  191. char
  192.                                 GetLocDReg(LocAMVia_t loc);
  193.  
  194. char
  195.                                 GetLocFReg(LocAMVia_t loc);
  196.  
  197. LabSYMVia_t
  198. GetLocLabel(LocAMVia_t loc);
  199.  
  200. unsigned long
  201.                                 GetLocConstant(LocAMVia_t loc);
  202.  
  203. int
  204.                                 LocIsFloat(LocAMVia_t loc);
  205.  
  206. void
  207.                                 SetLocAM(LocAMVia_t loc, enum AddressingMode68 AM);
  208.  
  209. void
  210.                                 SetLocSZ(LocAMVia_t loc, enum Size68 SZ);
  211.  
  212. void
  213.                                 SetLocAReg(LocAMVia_t loc, char a);
  214.  
  215. struct TwoShorts
  216.                                 GetLocFieldBits(LocAMVia_t loc);
  217.  
  218. void
  219.                                 SetLocStatus(LocAMVia_t loc, enum OperandState68 s);
  220.  
  221. void
  222.                                 SetLocSlot(LocAMVia_t loc, SpillSlotVia_t s);
  223.  
  224. void
  225.                                 SetLocConstant(LocAMVia_t loc, unsigned long c);
  226.  
  227. void
  228.                                 SetLocIsFloat(LocAMVia_t loc, int val);
  229.  
  230. void
  231.                                 KillSomeLocations(void);
  232.  
  233. void
  234.                                 MakeLocGlobal(LocAMVia_t loc);
  235.  
  236. #endif
  237.