home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 357_01 / cstar1.exe / ENUM.H < prev    next >
Text File  |  1991-06-18  |  22KB  |  985 lines

  1. /*
  2.     C* -- Header file for all enumerations.
  3.  
  4.     source:  enum.h
  5.     started: June 20, 1986
  6.     version: March 4, 1987
  7.  
  8.     PUBLIC DOMAIN SOFTWARE
  9.  
  10.     The CSTAR program was placed in    the public domain on June 15, 1991,
  11.     by its author and sole owner,
  12.  
  13.         Edward K. Ream
  14.         1617 Monroe Street
  15.         Madison, WI 53711
  16.         (608) 257-0802
  17.  
  18.     CSTAR may be used for any commercial or non-commercial purpose.
  19.  
  20.     See cstar.h or cstar.c for a DISCLAIMER OF WARRANTIES.
  21. */
  22.  
  23. /*
  24.     ----------    PARSING    ----------
  25. */
  26.  
  27. /*
  28.     Define constants used by the parser.
  29. */
  30.  
  31. /* #enum(0, ANY_EXPR, ASSIGN_EXPR, CONST_EXPR, XARITH_EXPR, ARG_EXPR) */
  32.  
  33. #define    ANY_EXPR    0
  34. #define    ASSIGN_EXPR    1
  35. #define    CONST_EXPR    2
  36. #define    XARITH_EXPR    3
  37. #define    ARG_EXPR    4
  38.  
  39. /*
  40.     Enumerate storage classes for st_nodes.
  41.  
  42.     The storage class is attached directly to the
  43.     symbol table node.
  44.  
  45.     Storage class has nothing to do with type, and very 
  46.     little to do with scope, although not all classes are
  47.     permitted in all scopes.
  48. */
  49.  
  50. /* #enum(0, NULL_CLASS,\
  51. FORMAL_CLASS, FORMREG_CLASS, AUTO_CLASS, REGISTER_CLASS, GLOBAL_CLASS,\
  52. EXTERN_CLASS, STATICG_CLASS, STATICL_CLASS, TYPEDEF_CLASS, TAG_CLASS,\
  53. CODE_CLASS, SUE_CLASS, SCODE_CLASS) */
  54.  
  55. #define NULL_CLASS    0
  56. #define    FORMAL_CLASS    1
  57. #define    FORMREG_CLASS    2
  58. #define    AUTO_CLASS    3
  59. #define    REGISTER_CLASS    4
  60. #define    GLOBAL_CLASS    5
  61. #define    EXTERN_CLASS    6
  62. #define    STATICG_CLASS    7
  63. #define    STATICL_CLASS    8
  64. #define    TYPEDEF_CLASS    9
  65.  
  66. #define    TAG_CLASS    10
  67. #define    CODE_CLASS    11
  68. #define    SUE_CLASS    12
  69. #define    SCODE_CLASS    13
  70.  
  71. #define is_rstack(class) (class > NULL_CLASS && class <= REGISTER_CLASS)
  72.  
  73. /*
  74.      Define principal type tokens. these are the header type, except for
  75.        adjectival modifiers (long, short, signed, unsigned, volatile, const)
  76.  
  77.        DELEMENT and CAST are dummy types which allow overloading of the type
  78.        node for use as the spine of a declaration list, and for use in restricting
  79.     the parser within casts, respectively.
  80. */
  81.  
  82. /* #enum(0, NULL_TYPE,\
  83. BOOL_TYPE, INT_TYPE, FLOAT_TYPE,\
  84. VOID_TYPE, POINTER_TYPE, STRUCT_TYPE, UNION_TYPE, DECL_TYPE,\
  85. ARRAY_TYPE, FUNCTION_TYPE, UELEMENT_TYPE, SELEMENT_TYPE, DELEMENT_TYPE,\
  86. CAST_TYPE) */
  87.  
  88. #define NULL_TYPE    0
  89. #define    BOOL_TYPE    1
  90. #define    INT_TYPE    2
  91. #define    FLOAT_TYPE    3
  92. #define    VOID_TYPE    4
  93. #define    POINTER_TYPE    5
  94. #define    STRUCT_TYPE    6
  95. #define    UNION_TYPE    7
  96. #define    DECL_TYPE    8
  97. #define    ARRAY_TYPE    9
  98.  
  99. #define    FUNCTION_TYPE    10
  100. #define    UELEMENT_TYPE    11
  101. #define    SELEMENT_TYPE    12
  102. #define    DELEMENT_TYPE    13
  103. #define    CAST_TYPE    14
  104.  
  105. #define is_element(x) (x >= UELEMENT_TYPE && x <= DELEMENT_TYPE)
  106.  
  107. /*
  108.     Define modifier and miscellaneous bits.
  109.     Explicit_mod indicates that the type node resulted from a keyword.
  110. */
  111.  
  112. /* #enum(0, NULL_MOD,\
  113. CHAR_MOD    = 0x01,\
  114. SHORT_MOD    = 0x02,\
  115. LONG_MOD    = 0x04,\
  116. UNSIGNED_MOD    = 0x08,\
  117. SIZE_MODS    = 0x07,\
  118. ARITH_MODS    = 0x0f,\
  119. \
  120. CONST_MOD    = 0x100,\
  121. VOLATILE_MOD    = 0x200,\
  122. SC_MODS        = 0xf00) */
  123.  
  124. #define    NULL_MOD    0
  125. #define    CHAR_MOD    0x01
  126. #define    SHORT_MOD    0x02
  127. #define    LONG_MOD    0x04
  128. #define    UNSIGNED_MOD    0x08
  129. #define    SIZE_MODS    0x07
  130. #define    ARITH_MODS    0x0f
  131.  
  132. #define    CONST_MOD    0x100
  133. #define    VOLATILE_MOD    0x200
  134. #define    SC_MODS        0xf00
  135.  
  136. /* #enum (0, NULL_DEC, IBSSZB_DEC, ISTRA_DEC, ISTRS_DEC, ITAG_DEC) */
  137.  
  138. #define    NULL_DEC    0
  139. #define    IBSSZB_DEC    1
  140. #define    ISTRA_DEC    2
  141. #define    ISTRS_DEC    3
  142. #define    ITAG_DEC    4
  143.  
  144. /* items for st_misc */
  145. #define    EXPLICIT_SYM 0x1000
  146. #define ST_REG 63
  147.  
  148. /*
  149.     Enumerate the possible values of the "current scope"
  150. */
  151.  
  152. /* #enum(0, NULL_SCOPE, FILE_SCOPE, FNDEF_SCOPE, BLOCK_SCOPE, PROTO_SCOPE) */
  153.  
  154. #define    NULL_SCOPE    0
  155. #define    FILE_SCOPE    1
  156. #define    FNDEF_SCOPE    2
  157. #define    BLOCK_SCOPE    3
  158. #define    PROTO_SCOPE    4
  159.  
  160. /*
  161.     Input Codes and Internal Operator Codes:
  162.     Type fields of parse nodes.
  163.  
  164. */
  165.  
  166. /* #enum(0,\
  167. NULL_TOK,\
  168. \
  169. K_AUTO,  K_CHAR, K_CONST, K_DOUBLE,  K_EXTERN,\
  170. K_FLOAT, K_INT, K_LONG, K_REGISTER, K_SHORT,\
  171. K_STATIC, K_TYPEDEF, K_SIGNED, K_STRUCT, K_UNION,\
  172. K_UNSIGNED, K_VOID, K_VOLATILE,\
  173. \
  174. K_BREAK, K_CASE,\
  175. K_CONTINUE, K_DEFAULT, K_DO, K_ELSE, K_FOR,\
  176. K_GOTO, K_IF, K_RETURN, K_SWITCH, K_WHILE,\
  177. \
  178. K_ENTRY, K_ENUM, K_SIZEOF,\
  179. \
  180. SEPARATOR_TOK, NL_TOK,\
  181. SEMICOLON_TOK, LBRACK_TOK, LCURLY_TOK, LPAREN_TOK, RBRACK_TOK,\
  182. RCURLY_TOK, RPAREN_TOK,\
  183. \
  184. COLON_TOK, QUESTION_TOK,\
  185. \
  186. ARRAY_TOK, ARROW_TOK,\
  187. DOT_TOK, LAND_TOK, LOR_TOK, COMMA_TOK,\
  188. \
  189. ASSN_TOK,\
  190. AND_ASSN_TOK, DIV_ASSN_TOK, LSHIFT_ASSN_TOK, MINUS_ASSN_TOK, MOD_ASSN_TOK,\
  191. OR_ASSN_TOK, PLUS_ASSN_TOK, RSHIFT_ASSN_TOK, STAR_ASSN_TOK, XOR_ASSN_TOK,\
  192. \
  193. AND_TOK, OR_TOK, PLUS_TOK, STAR_TOK, XOR_TOK,\
  194. \
  195. DIV_TOK, LSHIFT_TOK, MINUS_TOK, MOD_TOK, RSHIFT_TOK,\
  196. \
  197. EQUAL_TOK, GE_TOK, GT_TOK, LE_TOK, LT_TOK,\
  198. NE_TOK,\
  199. \
  200. DEC_TOK, INC_TOK, NOT_TOK, TILDE_TOK,\
  201. \
  202. CAST_TOK,\
  203. POST_DEC_TOK, POST_INC_TOK, PRE_DEC_TOK, PRE_INC_TOK,\
  204. \
  205. UAND_TOK, UMINUS_TOK, UPLUS_TOK, USTAR_TOK,\
  206. \
  207. CALL_TOK,\
  208. \
  209. AREG_TOK,\
  210. CC_TOK, CHAR_TOK, DREG_TOK, EOF_TOK, EOP_TOK,\
  211. GREG_TOK, ID_TOK, INT_TOK, LONG_TOK, Z_TOK,\
  212. STRING_TOK, X_TOK,\
  213. \
  214. BOOL_TOK,\
  215. LABEL_TOK) */
  216.  
  217. /*
  218.     Input Codes and Internal Operator Codes:
  219.     Type fields of parse nodes.
  220.  
  221. */
  222.  
  223. #define    NULL_TOK    0
  224.  
  225. /*    start of key subenum.                */
  226. /*    kdecl subenum.                    */
  227.  
  228. #define    K_AUTO        1
  229. #define    K_CHAR        2
  230. #define    K_CONST        3
  231. #define    K_DOUBLE    4
  232. #define    K_EXTERN    5
  233. #define    K_FLOAT        6
  234. #define    K_INT        7
  235. #define    K_LONG        8
  236. #define    K_REGISTER    9
  237.  
  238. #define    K_SHORT        10
  239. #define    K_STATIC    11
  240. #define    K_TYPEDEF    12
  241. #define    K_SIGNED    13
  242. #define    K_STRUCT    14
  243. #define    K_UNION        15
  244. #define    K_UNSIGNED    16
  245. #define    K_VOID        17
  246. #define    K_VOLATILE    18
  247.  
  248. /*    kcontrol subenum.                */
  249.  
  250. #define    K_BREAK        19
  251. #define    K_CASE        20
  252. #define    K_CONTINUE    21
  253. #define    K_DEFAULT    22
  254. #define    K_DO        23
  255. #define    K_ELSE        24
  256. #define    K_FOR        25
  257. #define    K_GOTO        26
  258. #define    K_IF        27
  259. #define    K_RETURN    28
  260. #define    K_SWITCH    29
  261. #define    K_WHILE        30
  262.  
  263. /*    Remainder of key subenum.            */
  264.  
  265. #define    K_ENTRY        31
  266. #define    K_ENUM        32
  267. #define    K_SIZEOF    33
  268.  
  269. /*    Separator and grouping tokens.            */
  270. /*    Start of is_op subenum.                */
  271.  
  272. #define    SEPARATOR_TOK    34
  273. #define    NL_TOK        35
  274. #define    SEMICOLON_TOK    36
  275. #define    LBRACK_TOK    37
  276. #define    LCURLY_TOK    38
  277. #define    LPAREN_TOK    39
  278. #define    RBRACK_TOK    40
  279. #define    RCURLY_TOK    41
  280. #define    RPAREN_TOK    42
  281.  
  282. /*    is_ternop.                    */
  283.  
  284. #define    COLON_TOK    43
  285. #define    QUESTION_TOK    44
  286.  
  287. /*    Start of is_binop enum.                */
  288.  
  289. #define    ARRAY_TOK    45
  290. #define    ARROW_TOK    46
  291. #define    DOT_TOK        47
  292. #define    LAND_TOK    48
  293. #define    LOR_TOK        49
  294. #define    COMMA_TOK    50
  295.  
  296. /*    is_assnop subenum.                */
  297.  
  298. #define    ASSN_TOK    51
  299. #define    AND_ASSN_TOK    52
  300. #define    DIV_ASSN_TOK    53
  301. #define    LSHIFT_ASSN_TOK    54
  302. #define    MINUS_ASSN_TOK    55
  303. #define    MOD_ASSN_TOK    56
  304. #define    OR_ASSN_TOK    57
  305. #define    PLUS_ASSN_TOK    58
  306. #define    RSHIFT_ASSN_TOK    59
  307. #define    STAR_ASSN_TOK    60
  308. #define    XOR_ASSN_TOK    61
  309.  
  310. /*    is_aop, is_abelian  subenum.            */
  311.  
  312. #define    AND_TOK        62
  313. #define    OR_TOK        63
  314. #define    PLUS_TOK    64
  315. #define    STAR_TOK    65
  316. #define    XOR_TOK        66
  317.  
  318. #define    DIV_TOK        67
  319. #define    LSHIFT_TOK    68
  320. #define    MINUS_TOK    69
  321. #define    MOD_TOK        70
  322. #define    RSHIFT_TOK    71
  323.  
  324. /*     end of is_aop.                    */
  325.  
  326. /*    is_relop subenum.                */
  327. /*    Final entries of is_binop subenum.        */
  328.  
  329. #define    EQUAL_TOK    72
  330. #define    GE_TOK        73
  331. #define    GT_TOK        74
  332. #define    LE_TOK        75
  333. #define    LT_TOK        76
  334. #define    NE_TOK        77
  335.  
  336. /*    Unary operators returned by get_token().    */
  337.  
  338. #define    DEC_TOK        78
  339. #define    INC_TOK        79
  340. #define    NOT_TOK        80
  341. #define    TILDE_TOK    81
  342.  
  343. /*    Unary operators created by expr().        */
  344. /*    is_unop subenum.                */
  345.  
  346. #define    CAST_TOK    82
  347. #define    POST_DEC_TOK    83
  348. #define    POST_INC_TOK    84
  349. #define    PRE_DEC_TOK    85
  350. #define    PRE_INC_TOK    86
  351.  
  352. /*    Artificial unary operators; also is_unop    */
  353.  
  354. #define    UAND_TOK    87
  355. #define    UMINUS_TOK    88
  356. #define    UPLUS_TOK    89
  357. #define    USTAR_TOK    90
  358.  
  359. /*    Operators with variable operand count        */
  360. /*    Final entries in is_op subenum.            */
  361.  
  362. #define    CALL_TOK    91
  363.  
  364. /*    Class tokens.                    */
  365.  
  366. #define    AREG_TOK    92
  367. #define    CC_TOK        93
  368. #define    CHAR_TOK    94
  369. #define    DREG_TOK    95
  370. #define    EOF_TOK        96
  371. #define    EOP_TOK        97
  372. #define    GREG_TOK    98
  373. #define    ID_TOK        99
  374. #define    INT_TOK        100
  375.  
  376. #define    LONG_TOK    101
  377. #define    Z_TOK        102
  378. #define    STRING_TOK    103
  379. #define    X_TOK        104
  380.  
  381. /*    Miscellaneous internal tokens            */
  382.  
  383. #define    BOOL_TOK    105
  384. #define    LABEL_TOK    106
  385.  
  386.  
  387. /*
  388.     Most of the unary operators are specials generated in the parser.
  389.     Only NOT_TOK and TILDE_TOK are unambiguously unary.
  390. */
  391. #define is_kdecl(n)    (n >= K_AUTO    && n <= K_VOLATILE)
  392. #define is_kcontrol(n)    (n >= K_BREAK    && n <= K_WHILE)
  393. #define is_key(n)    (n >= K_AUTO    && n <= K_SIZEOF)
  394.  
  395. #define is_op(n)    (n >= SEPARATOR_TOK    && n <= CALL_TOK)
  396. #define is_binop(n)    (n >= ARRAY_TOK    && n <= NE_TOK)
  397. #define is_assnop(n)    (n >= ASSN_TOK    && n <= XOR_ASSN_TOK)
  398. #define is_abelian(n)    (n >= AND_TOK    && n <= XOR_TOK)
  399. #define is_aop(n)    (n >= AND_TOK    && n <= RSHIFT_TOK)
  400. #define is_relop(n)    (n >= EQUAL_TOK    && n <= NE_TOK)
  401. #define is_unop(n)    (n >= NOT_TOK    && n <= USTAR_TOK)
  402. #define is_argop(n)    (n >= COLON_TOK && n <= CALL_TOK)
  403.  
  404. /*
  405.     ----------    CODE GENERATION    ----------
  406. */
  407.  
  408. /*
  409.     Define optimizer flags n_oflags
  410. */
  411. #define OPT_NONEED 1
  412. #define OPT_ZNEED 2
  413. #define OPT_ZFLAG 4
  414.  
  415. /*
  416.     Segments
  417. */
  418.  
  419. /* #enum(0,S_BSS, S_DATA, S_TEXT) */
  420.  
  421. #define    S_BSS    0
  422. #define    S_DATA    1
  423. #define    S_TEXT    2
  424.  
  425. /*
  426.     Output op codes:    type codes in code/loc nodes.
  427.  
  428.     CAUTION: this sequence is keyed to a print table in glb.c and 
  429.     to an existence table in t2.s; these tables constitute implicit
  430.     references to the enumeration, which will not show up by doing
  431.     a find.  Alterations in this enumeration
  432.     must be matched with suitable changes in those tables.
  433.  
  434.     WARNING: the items X_BXX, X_DBXX, and X_SXX need to be removed;
  435.     they imply the existence of subtypes, and since X_TOK's are
  436.     passed as integers, there's no way to pass the implied subtypes.
  437.  
  438.     X_MODS and X_MODU are not really needed, and ought to be removed.
  439.     The code generator does not use them, and the divide instruction
  440.     is so peculiar that a programmer ought to write it out.
  441.  
  442.     Prior to doing any removals, use the find command to make sure
  443.     explicit references have been removed.
  444. */
  445.  
  446. /* #enum(1,\
  447. \
  448. X_ABCD, X_ADD,  X_ADDA, X_ADDI, X_ADDQ,\
  449. X_ADDX, X_AND,  X_ANDI, X_ASL,  X_ASR,\
  450. X_BCHG, X_BCLR, X_BRA,  X_BSET, X_BSR,\
  451. X_BTST, X_BXX,  X_CHK,  X_CLR,  X_CMP,\
  452. X_CMPA, X_CMPI, X_CMPM, X_DBXX, X_DIVS,\
  453. X_DIVU, X_EOR,  X_EORI, X_EXG,  X_EXT,\
  454. X_JMP,  X_JSR,  X_LEA,  X_LINK, X_LSL,\
  455. X_LSR,  X_MOVE, X_MOVEA,X_MOVEM,X_MOVEP,\
  456. X_MOVEQ,X_MULS, X_MULU, X_NBCD, X_NEG,\
  457. X_NEGX, X_NOP,  X_NOT,  X_OR,   X_ORI,\
  458. X_PEA, X_RESET, X_ROL,  X_ROR,  X_ROXL,\
  459. X_ROXR, X_RTE,  X_RTR,  X_RTS,  X_SBCD,\
  460. X_SXX,  X_STOP, X_SUB,  X_SUBA, X_SUBI,\
  461. X_SUBQ, X_SUBX, X_SWAP, X_TAS,  X_TRAP,\
  462. X_TRAPV, X_TST, X_UNLK,\
  463. \
  464. X_MODS, X_MODU,\
  465. \
  466. X_BCC, X_BCS, X_BEQ, X_BGE, X_BGT, X_BHI, X_BLE,\
  467. X_BLS, X_BLT, X_BMI, X_BNE, X_BPL, X_BVC, X_BVS,\
  468. \
  469. X_DBCC, X_DBCS, X_DBEQ, X_DBF , X_DBGE, X_DBGT, X_DBHI, X_DBLE,\
  470. X_DBLS, X_DBLT, X_DBMI, X_DBNE, X_DBPL, X_DBT , X_DBVC, X_DBVS,\
  471. \
  472. X_SCC, X_SCS, X_SEQ, X_SF , X_SGE, X_SGT, X_SHI, X_SLE,\
  473. X_SLS, X_SLT, X_SMI, X_SNE, X_SPL, X_ST , X_SVC, X_SVS,\
  474. \
  475. Z_ADDSP, Z_ADJSP, Z_BASE, Z_BSS, Z_DATA,\
  476. Z_DC, Z_DCB, Z_DCL, Z_DCW, Z_DS, Z_DSB, Z_DSL, Z_DSW,\
  477. Z_NOBASE, Z_ORG, Z_POP, Z_PUSH, Z_SUBSP, Z_TEXT,\
  478. \
  479. O_LABEL, O_ULABEL, O_LITERAL, O_LOCATION, O_LINENUM,\
  480. \
  481. Q_BRN) */
  482.  
  483. /*    Machine instructions.                */
  484. /*    Input code = X_TOK.                */
  485. /*    Start of the is_otok subenum.            */
  486. /*    Start of the is_xtok subenum.            */
  487.  
  488. #define    X_ABCD    1
  489. #define    X_ADD    2
  490. #define    X_ADDA    3
  491. #define    X_ADDI    4
  492. #define    X_ADDQ    5
  493. #define    X_ADDX    6
  494. #define    X_AND    7
  495. #define    X_ANDI    8
  496. #define    X_ASL    9
  497. #define    X_ASR    10
  498.  
  499. #define    X_BCHG    11
  500. #define    X_BCLR    12
  501. #define    X_BRA    13
  502. #define    X_BSET    14
  503. #define    X_BSR    15
  504. #define    X_BTST    16
  505. #define    X_BXX    17
  506. #define    X_CHK    18
  507. #define    X_CLR    19
  508. #define    X_CMP    20
  509.  
  510. #define    X_CMPA    21
  511. #define    X_CMPI    22
  512. #define    X_CMPM    23
  513. #define    X_DBXX    24
  514. #define    X_DIVS    25
  515. #define    X_DIVU    26
  516. #define    X_EOR    27
  517. #define    X_EORI    28
  518. #define    X_EXG    29
  519. #define    X_EXT    30
  520.  
  521. #define    X_JMP    31
  522. #define    X_JSR    32
  523. #define    X_LEA    33
  524. #define    X_LINK    34
  525. #define    X_LSL    35
  526. #define    X_LSR    36
  527. #define    X_MOVE    37
  528. #define    X_MOVEA    38
  529. #define    X_MOVEM    39
  530. #define    X_MOVEP    40
  531.  
  532. #define    X_MOVEQ    41
  533. #define    X_MULS    42
  534. #define    X_MULU    43
  535. #define    X_NBCD    44
  536. #define    X_NEG    45
  537. #define    X_NEGX    46
  538. #define    X_NOP    47
  539. #define    X_NOT    48
  540. #define    X_OR    49
  541. #define    X_ORI    50
  542.  
  543. #define    X_PEA    51
  544. #define    X_RESET    52
  545. #define    X_ROL    53
  546. #define    X_ROR    54
  547. #define    X_ROXL    55
  548. #define    X_ROXR    56
  549. #define    X_RTE    57
  550. #define    X_RTR    58
  551. #define    X_RTS    59
  552. #define    X_SBCD    60
  553.  
  554. #define    X_SXX    61
  555. #define    X_STOP    62
  556. #define    X_SUB    63
  557. #define    X_SUBA    64
  558. #define    X_SUBI    65
  559. #define    X_SUBQ    66
  560. #define    X_SUBX    67
  561. #define    X_SWAP    68
  562. #define    X_TAS    69
  563. #define    X_TRAP    70
  564.  
  565. #define    X_TRAPV    71
  566. #define    X_TST    72
  567. #define    X_UNLK    73
  568.  
  569. /*    NOTE: These are not real machine ops.        */
  570.  
  571. #define    X_MODS    74
  572. #define    X_MODU    75
  573.  
  574. /*    Variations of the Bxx instruction.        */
  575. /*    is_bxx subenum.                    */
  576.  
  577. #define    X_BCC    76
  578. #define    X_BCS    77
  579. #define    X_BEQ    78
  580. #define    X_BGE    79
  581. #define    X_BGT    80
  582.  
  583. #define    X_BHI    81
  584. #define    X_BLE    82
  585. #define    X_BLS    83
  586. #define    X_BLT    84
  587. #define    X_BMI    85
  588. #define    X_BNE    86
  589. #define    X_BPL    87
  590. #define    X_BVC    88
  591. #define    X_BVS    89
  592.  
  593. /*    Variations of the DBxx instruction.        */
  594. /*    is_dbxx subenum.                */
  595.  
  596. #define    X_DBCC    90
  597.  
  598. #define    X_DBCS    91
  599. #define    X_DBEQ    92
  600. #define    X_DBF    93
  601. #define    X_DBGE    94
  602. #define    X_DBGT    95
  603. #define    X_DBHI    96
  604. #define    X_DBLE    97
  605. #define    X_DBLS    98
  606. #define    X_DBLT    99
  607. #define    X_DBMI    100
  608.  
  609. #define    X_DBNE    101
  610. #define    X_DBPL    102
  611. #define    X_DBT    103
  612. #define    X_DBVC    104
  613. #define    X_DBVS    105
  614.  
  615. /*    Variations of the Sxx instruction.        */
  616. /*    Final part of the is_xtok subenum.        */
  617.  
  618. #define    X_SCC    106
  619. #define    X_SCS    107
  620. #define    X_SEQ    108
  621. #define    X_SF    109
  622. #define    X_SGE    110
  623.  
  624. #define    X_SGT    111
  625. #define    X_SHI    112
  626. #define    X_SLE    113
  627. #define    X_SLS    114
  628. #define    X_SLT    115
  629. #define    X_SMI    116
  630. #define    X_SNE    117
  631. #define    X_SPL    118
  632. #define    X_ST    119
  633. #define    X_SVC    120
  634. #define    X_SVS    121
  635.  
  636. /*    Pseudo instructions.                */
  637. /*    Input code = PSEUDO_TOK.            */
  638. /*    is_ztok subenum.                */
  639.  
  640. #define    Z_ADDSP    122
  641. #define    Z_ADJSP    123
  642. #define    Z_BASE    124
  643. #define    Z_BSS    125
  644. #define    Z_DATA    126
  645. #define    Z_DC    127
  646. #define    Z_DCB    128
  647. #define    Z_DCL    129
  648. #define    Z_DCW    130
  649.  
  650. #define    Z_DS    131
  651. #define    Z_DSB    132
  652. #define    Z_DSL    133
  653. #define    Z_DSW    134
  654. #define    Z_NOBASE    135
  655. #define    Z_ORG    136
  656. #define    Z_POP    137
  657. #define    Z_PUSH    138
  658. #define    Z_SUBSP    139
  659. #define    Z_TEXT    140
  660.  
  661. /*    Other code nodes.                */
  662. /*    Final part of the is_otok subenum.        */
  663.  
  664. #define    O_LABEL        141
  665. #define    O_ULABEL    142
  666. #define    O_LITERAL    143
  667. #define    O_LOCATION    144
  668. #define    O_LINENUM    145
  669.  
  670. /*    Pseudo nodes for internal use; these generate no output */
  671.  
  672. #define    Q_BRN    146
  673.  
  674.  
  675. /* Define some common synonyms. */
  676. /* DBRA means branch always; DBCS means branch UNTIL carry is set, i.e.
  677.   if the carry is unset!  See pp. 115-116 in the Book */
  678.  
  679. #define X_BLO  X_BCS
  680. #define X_BHS  X_BCC
  681. #define X_DBRA X_DBF
  682. #define X_DBRN X_DBT
  683. #define X_DBLO X_DBCS
  684. #define X_DBHS X_DBCC
  685. #define X_SLO  X_SCS
  686. #define X_SHS  X_SCC
  687.  
  688. #define is_xtok(n) (n >= X_ABCD     && n <= X_SVS)
  689. #define is_ztok(n) (n >= Z_ADDSP && n <= Z_TEXT)
  690. #define is_otok(n) (n >= 1     && n <= O_LINENUM)
  691. #define is_qtok(n) (n >= Q_BRN)
  692. #define is_bxx(n)  (n >= X_BCC     && n <= X_BVS)
  693. #define is_dbxx(n) (n >= X_DBCC     && n <= X_DBVS)
  694.  
  695. /*
  696.     Variations on op codes.
  697.     Not used when assembly output is generated.
  698. */
  699.  
  700. #ifdef OBJECT_OUT
  701.  
  702. #define XC_ANDI    X_ANDI    /* and to ccr    */
  703. #define XS_ANDI    X_ANDI    /* and to ssr    */
  704.  
  705. #define XM_ASL    X_ASL    /* asl to mem    */
  706. #define XR_ASL    X_ASL    /* asl to reg    */
  707. #define XM_ASR    X_ASR    /* asr to mem    */
  708. #define XR_ASR    X_ASR    /* asr to reg    */
  709.  
  710. #define XD_BCHG    X_BCHG    /* dynamic bchg    */
  711. #define XS_BCHG    X_BCHG    /* static  bchg    */
  712. #define XD_BCLR    X_BCLR    /* dynamic bclr    */
  713. #define XS_BCLR    X_BCLR    /* static  bclr    */
  714. #define XD_BSET    X_BSET    /* dynamic bset    */
  715. #define XS_BSET    X_BSET    /* static  bset    */
  716. #define XD_BTST    X_BTST    /* dynamic btst */
  717. #define XS_BTST    X_BTST    /* static  btst    */
  718.  
  719. #define XC_EORI    X_EORI    /* eori to ccr    */
  720. #define XS_EORI    X_EORI    /* eori to ssr    */
  721.  
  722. #define XA_EXG    X_EXG    /* exg An,An    */
  723. #define XD_EXG    X_EXG    /* exg Dn,Dn    */
  724. #define XM1_EXG    X_EXG    /* exg An,Dn    */
  725. #define XM2_EXG    X_EXG    /* exg Dn,An    */
  726.  
  727. #define XM_LSL    X_LSL    /* lsl to mem    */
  728. #define XR_LSL    X_LSL    /* lsl to reg    */
  729. #define XM_LSR    X_LSR    /* lsr to mem    */
  730. #define XR_LSR    X_LSR    /* lsr to mem    */
  731.  
  732. #define XC_MOV  X_MOVE    /* move ccr    */
  733. #define X2C_MOV X_MOVE    /* move to ccr    */
  734. #define XS_MOV  X_MOVE    /* move ssr    */
  735. #define X2S_MOV X_MOVE    /* move to ssr    */
  736.  
  737. #define XR2M_MOVM X_MOVEM /* movem reglist,ae    */
  738. #define XM2R_MOVM X_MOVEM /* movem ae,reglist    */
  739.  
  740. #define XC_ORI    X_ORI    /* ori to ccr    */
  741. #define XS_ORI    X_ORI    /* ori to ssr    */
  742.  
  743. #define XM_ROL    X_ROL    /* rol to mem    */
  744. #define XR_ROL    X_ROL    /* rol to reg    */
  745. #define XM_ROR    X_ROR    /* ror to mem    */
  746. #define XR_ROR    X_ROR    /* ror to reg    */
  747. #define XM_ROXL    X_ROXL    /* roxl to mem    */
  748. #define XR_ROXL    X_ROXL    /* roxl to reg    */
  749. #define XM_ROXR    X_ROXR    /* roxr to mem    */
  750. #define XR_ROXR    X_ROXR    /* roxr to reg    */
  751.  
  752. #endif /* OBJECT_OUT */
  753.  
  754. /*
  755.     Output operand codes:    type codes in loc_nodes.
  756.  
  757. */
  758.  
  759. /* #enum(1,\
  760. \
  761. R_A0, R_A1, R_A2, R_A3, R_A4, R_A5, R_A6, R_A7,\
  762. \
  763. R_A0W, R_A1W, R_A2W, R_A3W, R_A4W, R_A5W, R_A6W, R_A7W,\
  764. \
  765. R_D0, R_D1, R_D2, R_D3, R_D4, R_D5, R_D6, R_D7,\
  766. R_D0W, R_D1W, R_D2W, R_D3W, R_D4W, R_D5W, R_D6W, R_D7W,\
  767. R_D0B, R_D1B, R_D2B, R_D3B, R_D4B, R_D5B, R_D6B, R_D7B,\
  768. \
  769. R_CCR, R_PC, R_SP, R_SPW, R_SR, R_USP,\
  770. \
  771. CC_CC, CC_CS, CC_EQ, CC_F, CC_GE, CC_GT, CC_HI, CC_LE,\
  772. CC_LS, CC_LT, CC_MI, CC_NE, CC_PL, CC_T, CC_VC, CC_VS) */
  773.  
  774. /*    Address regs.        Input code AREG_TOK.    */
  775. /*    R_A0 through R_A7 may be used in (an) mode.    */
  776. /*    R_A0 through R_RDW are valid index registers.    */
  777. /*    is_areg subenum.                */
  778.  
  779. #define    R_A0    1
  780. #define    R_A1    2
  781. #define    R_A2    3
  782. #define    R_A3    4
  783. #define    R_A4    5
  784. #define    R_A5    6
  785. #define    R_A6    7
  786. #define    R_A7    8
  787.  
  788. /*    NOT part of is_areg subenum.            */
  789.  
  790. #define    R_A0W    9
  791. #define    R_A1W    10
  792. #define    R_A2W    11
  793. #define    R_A3W    12
  794. #define    R_A4W    13
  795. #define    R_A5W    14
  796. #define    R_A6W    15
  797. #define    R_A7W    16
  798.  
  799. /*    Data regs.        Input code DREG_TOK.    */
  800. /*    is_dreg subenum.                */
  801.  
  802. #define    R_D0    17
  803. #define    R_D1    18
  804. #define    R_D2    19
  805. #define    R_D3    20
  806. #define    R_D4    21
  807. #define    R_D5    22
  808. #define    R_D6    23
  809. #define    R_D7    24
  810.  
  811. #define    R_D0W    25
  812. #define    R_D1W    26
  813. #define    R_D2W    27
  814. #define    R_D3W    28
  815. #define    R_D4W    29
  816. #define    R_D5W    30
  817. #define    R_D6W    31
  818. #define    R_D7W    32
  819.  
  820. #define    R_D0B    33
  821. #define    R_D1B    34
  822. #define    R_D2B    35
  823. #define    R_D3B    36
  824. #define    R_D4B    37
  825. #define    R_D5B    38
  826. #define    R_D6B    39
  827. #define    R_D7B    40
  828.  
  829. /*    General regs.        Input code GREG_TOK.    */
  830. /*    is_greg subenum.                */
  831.  
  832. #define    R_CCR    41
  833. #define    R_PC    42
  834. #define    R_SP    43
  835. #define    R_SPW    44
  836. #define    R_SR    45
  837. #define    R_USP    46
  838.  
  839. /*    Condition codes.    Input code CC_TOK.    */
  840. /*    is_cc subenum.                    */
  841.  
  842. #define    CC_CC    47
  843. #define    CC_CS    48
  844. #define    CC_EQ    49
  845. #define    CC_F    50
  846.  
  847. #define    CC_GE    51
  848. #define    CC_GT    52
  849. #define    CC_HI    53
  850. #define    CC_LE    54
  851. #define    CC_LS    55
  852. #define    CC_LT    56
  853. #define    CC_MI    57
  854. #define    CC_NE    58
  855. #define    CC_PL    59
  856. #define    CC_T    60
  857.  
  858. #define    CC_VC    61
  859. #define    CC_VS    62
  860.  
  861. #define CC_LO CC_CS
  862.  
  863. #define is_areg(reg)  (reg >= R_A0  && reg <= R_A7W)
  864. #define is_aregw(reg) (reg >= R_A0W && reg <= R_A7W)
  865. #define is_dreg(reg)  (reg >= R_D0  && reg <= R_D7B)
  866. #define is_xreg(reg)  (reg >= R_A0  && reg <= R_D7B)
  867. #define is_reg(reg)   (reg >= R_A0  && reg <= R_SR)
  868.  
  869. #define is_apreg(reg) (is_areg(reg) || reg == R_PC)
  870. #define is_greg(reg)  (reg >= R_CCR && reg <= R_SR)
  871. #define is_cc(reg)    (reg >= CC_CC && reg <= CC_VS)
  872.  
  873. /* note use of xxx_rtb[] from glb.c */
  874. #define reg_idx(reg) (reg_itb[reg])
  875. #define d_reg(idx) (d_rtb[idx])
  876. #define a_reg(idx) (a_rtb[idx])
  877. #define real_reg(reg) (x_rtb[reg])
  878.  
  879. /*
  880.     Loc_nodes:
  881. */
  882.  
  883. /* Define values in n_mode field. */
  884. /* #enum(0, VALUE_MODE, EA_MODE, EAPRD_MODE, EAPSI_MODE) */
  885.  
  886. #define    VALUE_MODE    0
  887. #define    EA_MODE        1
  888. #define    EAPRD_MODE    2
  889. #define    EAPSI_MODE    3
  890.  
  891. /* VALUE_MODE is to be the default in fresh nodes */
  892. #define is_ea(x) (x >= EA_MODE)
  893. #define has_effect(x) (x >= EAPRD_MODE)
  894.  
  895. /* Define items in n_scflgs field */
  896. /*
  897. #enum(1, X2_WORD, X2_LONG, X2_WSCALE, X2_USCALE, X2_LSCALE, X2_OK, X2_ABSW)
  898. */
  899.  
  900. #define    X2_WORD        1
  901. #define    X2_LONG        2
  902. #define    X2_WSCALE    3
  903. #define    X2_USCALE    4
  904. #define    X2_LSCALE    5
  905. #define    X2_OK        6
  906. #define    X2_ABSW        7
  907.  
  908. /*
  909.     ----------    TABLES for INTERPRETERS    ----------
  910. */
  911.  
  912. /*
  913.     Permissible-length fields, 1=length permissible
  914.     Second and third fields of the entry macro
  915. */
  916.  
  917. /* #enum(0,\
  918. LEN8_AM=1,    LEN16_AM=2,    LEN32_AM=4,\
  919. NOT8_AM=6,    NOT16_AM=5,    NOT32_AM=3, ANY_AM=7,\
  920. AS_1_AM=8, MODE1_AM, MODE2_AM); */
  921.  
  922. #define    LEN8_AM        1
  923. #define    LEN16_AM    2
  924. #define    LEN32_AM    4
  925.  
  926. #define    NOT8_AM        6
  927. #define    NOT16_AM    5
  928. #define    NOT32_AM    3
  929. #define    ANY_AM        7
  930.  
  931. #define    AS_1_AM        8
  932. #define    MODE1_AM    9
  933. #define    MODE2_AM    10
  934.  
  935. /*
  936.     Define addressing modes.
  937.  
  938.     q8bit        -128 through 127
  939.     quick8        1 through 8
  940.     bit31        0 through 31
  941.     trap15        0 through 15
  942.  
  943.     Fourth and fifth fields of the entry macro.
  944. */
  945.  
  946. /* #enum(0,\
  947. NONE_AM,\
  948. GEN_AM=32, MEM_AM, ALT_AM, DALT_AM, MALT_AM, DATA_AM,\
  949. INC_AM, DEC_AM, DISP_AM, CONTROL_AM, REGLIST_AM,\
  950. MOVEM2R_AM, MOVER2M_AM, CCR_AM, SR_AM, AN_AM,\
  951. DN_AM, D_AN_AM, IMM_AM, IMM8_AM, IMM16_AM, Q8BIT_AM,\
  952. QUICK8_AM, BIT31_AM, TRAP15_AM, USP_AM) */
  953.  
  954. #define    NONE_AM        0
  955. #define    GEN_AM        32
  956. #define    MEM_AM        33
  957. #define    ALT_AM        34
  958. #define    DALT_AM        35
  959. #define    MALT_AM        36
  960. #define    DATA_AM        37
  961. #define    INC_AM        38
  962. #define    DEC_AM        39
  963. #define    DISP_AM        40
  964.  
  965. #define    CONTROL_AM    41
  966. #define    REGLIST_AM    42
  967. #define    MOVEM2R_AM    43
  968. #define    MOVER2M_AM    44
  969. #define    CCR_AM        45
  970. #define    SR_AM        46
  971. #define    AN_AM        47
  972. #define    DN_AM        48
  973. #define    D_AN_AM        49
  974. #define    IMM_AM        50
  975.  
  976. #define    IMM8_AM        51
  977. #define    IMM16_AM    52
  978. #define    Q8BIT_AM    53
  979. #define    QUICK8_AM    54
  980. #define    BIT31_AM    55
  981. #define    TRAP15_AM    56
  982. #define    USP_AM        57
  983.  
  984. #define X_T_FRAME 6
  985.