118406Sralph /* 2*21317Sdist * Copyright (c) 1983 Regents of the University of California. 3*21317Sdist * All rights reserved. The Berkeley software License Agreement 4*21317Sdist * specifies the terms and conditions for redistribution. 5*21317Sdist * 6*21317Sdist * @(#)pcc.h 5.1 (Berkeley) 05/30/85 7*21317Sdist */ 8*21317Sdist 9*21317Sdist /* 1018406Sralph * This file contains definitions for all the constants and structures 1118406Sralph * needed to use the intermediate code files generated and read by 1218406Sralph * the Portable C Compiler and related compilers. 1318406Sralph * 1418406Sralph * Rules for changing this code: 1518406Sralph * 1) All op values must be integer constants -- this permits us to run 1618406Sralph * a 'sed' script on this file to create %term declarations for yacc. 1718406Sralph * 2) Because the PCC uses fancy ASG and UNARY macros, assignment 1818406Sralph * operators must have values 1 greater than corresponding normal 1918406Sralph * operators, and unary operators must have values 2 greater ditto. 2018406Sralph * 3) Ops used only by f1 must have values >= 150 (PCCF_FORTOPS). 2118406Sralph * 4) Other language-dependent ops must have values >= 200. 2218406Sralph */ 2318406Sralph 2418406Sralph # ifndef PCC_TOKENS 2518406Sralph 2618406Sralph # define PCC_TOKENS 0 2718406Sralph 2818406Sralph # define PCC_ERROR 1 /* an error node */ 2918406Sralph # define PCC_FREE 2 /* an unused node */ 3018406Sralph 3118406Sralph /* 3218406Sralph * Constants. 3318406Sralph */ 3418406Sralph # define PCC_STRING 3 /* a string constant */ 3518406Sralph # define PCC_ICON 4 /* an integer constant */ 3618406Sralph # define PCC_FCON 5 /* a floating point constant */ 3718406Sralph # define PCC_DCON 6 /* a double precision f.p. constant */ 3818406Sralph 3918406Sralph /* 4018406Sralph * Leaf types. 4118406Sralph */ 4218406Sralph # define PCC_NAME 7 /* an identifier */ 4318406Sralph # define PCC_REG 8 /* a register */ 4418406Sralph # define PCC_OREG 9 /* register and offset */ 4518406Sralph # define PCC_CCODES 10 /* condition codes */ 4618406Sralph # define PCC_FLD 11 /* a bit field */ 4718406Sralph 4818406Sralph /* 4918406Sralph * Arithmetic operators. 5018406Sralph */ 5118406Sralph # define PCC_PLUS 12 /* + */ 5218406Sralph # define PCC_PLUSEQ 13 /* += */ 5318406Sralph # define PCC_UPLUS 14 /* unary + (for completeness) */ 5418406Sralph # define PCC_MINUS 15 /* - */ 5518406Sralph # define PCC_MINUSEQ 16 /* -= */ 5618406Sralph # define PCC_UMINUS 17 /* unary - */ 5718406Sralph # define PCC_MUL 18 /* * */ 5818406Sralph # define PCC_MULEQ 19 /* *= */ 5918406Sralph /* Reserve a slot for 'unary *', which is PCC jargon for PCC_DEREF (yech) */ 6018406Sralph # define PCC_DIV 21 /* / */ 6118406Sralph # define PCC_DIVEQ 22 /* /= */ 6218406Sralph # define PCC_MOD 23 /* % */ 6318406Sralph # define PCC_MODEQ 24 /* %= */ 6418406Sralph # define PCC_INCR 25 /* ++ */ 6518406Sralph # define PCC_DECR 26 /* -- */ 6618406Sralph # define PCC_ASSIGN 27 /* = (these last 3 are stretching it) */ 6718406Sralph 6818406Sralph /* 6918406Sralph * Bit operators. 7018406Sralph */ 7118406Sralph # define PCC_AND 28 /* & */ 7218406Sralph # define PCC_ANDEQ 29 /* &= */ 7318406Sralph /* Reserve a slot for 'unary &', jargon for PCC_ADDROF */ 7418406Sralph # define PCC_OR 31 /* | */ 7518406Sralph # define PCC_OREQ 32 /* |= */ 7618406Sralph # define PCC_ER 33 /* ^ */ 7718406Sralph # define PCC_EREQ 34 /* ^= */ 7818406Sralph # define PCC_LS 35 /* << */ 7918406Sralph # define PCC_LSEQ 36 /* <<= */ 8018406Sralph # define PCC_RS 37 /* >> */ 8118406Sralph # define PCC_RSEQ 38 /* >>= */ 8218406Sralph # define PCC_COMPL 39 /* ~ */ 8318406Sralph 8418406Sralph /* 8518406Sralph * Booleans. 8618406Sralph */ 8718406Sralph # define PCC_EQ 40 /* == */ 8818406Sralph # define PCC_NE 41 /* != */ 8918406Sralph # define PCC_LE 42 /* <= */ 9018406Sralph # define PCC_LT 43 /* < */ 9118406Sralph # define PCC_GE 44 /* >= */ 9218406Sralph # define PCC_GT 45 /* > */ 9318406Sralph # define PCC_ULE 46 /* unsigned <= */ 9418406Sralph # define PCC_ULT 47 /* unsigned < */ 9518406Sralph # define PCC_UGE 48 /* unsigned >= */ 9618406Sralph # define PCC_UGT 49 /* unsigned > */ 9718406Sralph # define PCC_QUEST 50 /* ? (for conditional expressions) */ 9818406Sralph # define PCC_COLON 51 /* : (for conditional expressions) */ 9918406Sralph # define PCC_ANDAND 52 /* && */ 10018406Sralph # define PCC_OROR 53 /* || */ 10118406Sralph # define PCC_NOT 54 /* ! */ 10218406Sralph 10318406Sralph /* 10418406Sralph * Function calls. 10518406Sralph */ 10618406Sralph # define PCC_CALL 55 /* call by value */ 10718406Sralph /* no ASG */ 10818406Sralph # define PCC_UCALL 57 /* call with no arguments */ 10918406Sralph # define PCC_FORTCALL 58 /* call by reference? */ 11018406Sralph /* no ASG */ 11118406Sralph # define PCC_UFORTCALL 60 /* ??? */ 11218406Sralph # ifdef INLINE 11318406Sralph # define PCC_INLINE 61 /* inline function */ 11418406Sralph /* no ASG */ 11518406Sralph # define PCC_UINLINE 63 /* inline with no arguments */ 11618406Sralph # endif INLINE 11718406Sralph 11818406Sralph /* 11918406Sralph * Referencing and dereferencing. 12018406Sralph */ 12118406Sralph # define PCC_DEREF 20 /* * */ 12218406Sralph # define PCC_ADDROF 30 /* & */ 12318406Sralph 12418406Sralph /* 12518406Sralph * Special structure operators. 12618406Sralph */ 12718406Sralph # define PCC_DOT 64 /* . */ 12818406Sralph # define PCC_STREF 65 /* -> */ 12918406Sralph # define PCC_STASG 66 /* structure assignment */ 13018406Sralph # define PCC_STARG 67 /* an argument of type structure */ 13118406Sralph # define PCC_STCALL 68 /* a function of type structure */ 13218406Sralph /* no ASG */ 13318406Sralph # define PCC_USTCALL 70 /* unary structure function */ 13418406Sralph 13518406Sralph /* 13618406Sralph * Conversions. 13718406Sralph */ 13818406Sralph # define PCC_SCONV 71 /* scalar conversion */ 13918406Sralph # define PCC_PCONV 72 /* pointer conversion */ 14018406Sralph # define PCC_PMCONV 73 /* pointer multiply conversion */ 14118406Sralph # define PCC_PVCONV 74 /* pointer divide conversion */ 14218406Sralph # define PCC_CAST 75 /* redundant? */ 14318406Sralph 14418406Sralph /* 14518406Sralph * Bracket types. 14618406Sralph */ 14718406Sralph # define PCC_LB 76 /* [ */ 14818406Sralph # define PCC_RB 77 /* ] */ 14918406Sralph 15018406Sralph /* 15118406Sralph * Comma nodes. 15218406Sralph */ 15318406Sralph # define PCC_COMOP 78 /* , (in expressions) */ 15418406Sralph # define PCC_CM 79 /* , (in argument lists) */ 15518406Sralph 15618406Sralph /* 15718406Sralph * Miscellaneous. 15818406Sralph */ 15918406Sralph # define PCC_FORCE 80 /* result of last expression goes in r0 */ 16018406Sralph # define PCC_GOTO 81 /* unconditional goto */ 16118406Sralph # define PCC_CBRANCH 82 /* goto label if !test */ 16218406Sralph # define PCC_RETURN 83 /* return from function */ 16318406Sralph # define PCC_INIT 84 /* initialized data */ 16418406Sralph # define PCC_TYPE 85 /* a type */ 16518406Sralph # define PCC_CLASS 86 /* a storage class */ 16618406Sralph 16718406Sralph # define PCC_MAXOP 86 /* highest numbered PCC op */ 16818406Sralph 16918406Sralph /* 17018406Sralph * Special codes for interfacing to /lib/f1. 17118406Sralph */ 17218406Sralph # define PCCF_FORTOPS 150 17318406Sralph # define PCCF_FTEXT 150 /* pass literal assembler text */ 17418406Sralph # define PCCF_FEXPR 151 /* a statement */ 17518406Sralph # define PCCF_FSWITCH 152 /* not implemented */ 17618406Sralph # define PCCF_FLBRAC 153 /* beginning of subroutine */ 17718406Sralph # define PCCF_FRBRAC 154 /* end of subroutine */ 17818406Sralph # define PCCF_FEOF 155 /* end of file */ 17918406Sralph # define PCCF_FARIF 156 /* not implemented */ 18018406Sralph # define PCCF_FLABEL 157 /* an f77 label */ 18118406Sralph 18218406Sralph # endif PCC_TOKENS 18318406Sralph 18418406Sralph 18518406Sralph /* 18618406Sralph * Types, as encoded in intermediate file cookies. 18718406Sralph */ 18818406Sralph # define PCCT_UNDEF 0 18918406Sralph # define PCCT_FARG 1 /* function argument */ 19018406Sralph # define PCCT_CHAR 2 19118406Sralph # define PCCT_SHORT 3 19218406Sralph # define PCCT_INT 4 19318406Sralph # define PCCT_LONG 5 19418406Sralph # define PCCT_FLOAT 6 19518406Sralph # define PCCT_DOUBLE 7 19618406Sralph # define PCCT_STRTY 8 19718406Sralph # define PCCT_UNIONTY 9 19818406Sralph # define PCCT_ENUMTY 10 19918406Sralph # define PCCT_MOETY 11 /* member of enum */ 20018406Sralph # define PCCT_UCHAR 12 20118406Sralph # define PCCT_USHORT 13 20218406Sralph # define PCCT_UNSIGNED 14 20318406Sralph # define PCCT_ULONG 15 20418406Sralph 20518406Sralph /* 20618406Sralph * Type modifiers. 20718406Sralph */ 20818406Sralph # define PCCTM_PTR 020 20918406Sralph # define PCCTM_FTN 040 21018406Sralph # define PCCTM_ARY 060 21118406Sralph # define PCCTM_BASETYPE 017 21218406Sralph # define PCCTM_TYPESHIFT 2 21318406Sralph 21418406Sralph 21518406Sralph /* 21618406Sralph * Useful macros. 'PCCOM' macros apply to ops. 21718406Sralph */ 21818406Sralph # define PCCOM_ASG 1+ 21918406Sralph # define PCCOM_UNARY 2+ 22018406Sralph # define PCCOM_NOASG (-1)+ 22118406Sralph # define PCCOM_NOUNARY (-2)+ 22218406Sralph 22318406Sralph # define PCCM_TRIPLE(op, var, type) \ 22418406Sralph ((op) | ((var) << 8) | (long) (type) << 16) 22518406Sralph # define PCCM_TEXT(s) \ 22618406Sralph PCCM_TRIPLE(PCCF_FTEXT, (strlen(s) + 3) / 4, 0) 22718406Sralph # define PCCM_ADDTYPE(t, m) \ 22818406Sralph ((((t) &~ PCCTM_BASETYPE) << PCCTM_TYPESHIFT) | \ 22918406Sralph (m) | ((t) & PCCTM_BASETYPE)) 230