Initial revision

This commit is contained in:
keie 1984-08-23 13:18:14 +00:00
parent 5db647e661
commit 198da9e822
12 changed files with 329 additions and 0 deletions

10
first/em_path.h.src Normal file
View file

@ -0,0 +1,10 @@
#define TMP_DIR "/usr/tmp" /* Intended as a common dir. for */
/* ALL temporary files */
/* The trailing " is intentionally missing ! */
#define EM_HOME "/usr/em
#define EM_DIR EM_HOME" /* The root directory for EM stuff */
#define PEM_PATH EM_HOME/lib/pc_pem"
#define ERR_PATH EM_HOME/etc/pc_errors"
#define RTERR_PATH EM_HOME/etc/pc_rt_errors"
#define ACK_DIR EM_HOME/lib/ack"

7
first/local.h.src Normal file
View file

@ -0,0 +1,7 @@
/* collection of options, selected by including or excluding 'defines' */
/* Version number of the EM object code */
# define VERSION 3 /* 16 bits number */
/* The default machine used by ack, acc, apc */
# define ACKM "pdp"

1
h/as_spec.h Normal file
View file

@ -0,0 +1 @@
#define as_magic (sp_magic|(14<<8))

156
h/cg_pattern.h Normal file
View file

@ -0,0 +1,156 @@
/* offsets of interesting fields in EM-pattern */
#define PO_HASH 0
#define PO_NEXT 1
#define PO_MATCH 3
#define ILLHASH 0177777
/* Escapes in printstrings */
#define PR_TOK '\001'
#define PR_TOKFLD '\002'
#define PR_EMINT '\003'
#define PR_EMSTR '\004'
#define PR_ALLREG '\005'
#define PR_SUBREG '\006'
/*
* In case this list gets longer remember to keep out printable nonprintables
* like \t \n \r and the like.
*/
/* Commands for codegenerator, in low order 5 bits of byte */
#define DO_NEXTEM 0
#define DO_MATCH 1
#define DO_XMATCH 2
#define DO_XXMATCH 3
#define DO_REMOVE 4
#define DO_DEALLOCATE 5
#define DO_REALLOCATE 6
#define DO_ALLOCATE 7
#define DO_LOUTPUT 8
#define DO_ROUTPUT 9
#define DO_MOVE 10
#define DO_ERASE 11
#define DO_TOKREPLACE 12
#define DO_EMREPLACE 13
#define DO_COST 14
#define DO_RETURN 15
#define DO_COERC 16
#define DO_PRETURN 17
#define DO_RREMOVE 18
typedef struct instance {
int in_which;
# define IN_COPY 1
# define IN_RIDENT 2
# define IN_ALLOC 3
# define IN_DESCR 4
# define IN_REGVAR 5
int in_info[TOKENSIZE+1];
} inst_t,*inst_p;
typedef struct {
int c_size; /* index in enode-table */
int c_time; /* dito */
} cost_t,*cost_p;
typedef struct {
int m_set1; /* number of tokenexpr in move: from */
int m_expr1; /* optional expression */
int m_set2; /* number of tokenexpr in move: to */
int m_expr2; /* optional expression */
int m_cindex; /* code index to really do it */
cost_t m_cost; /* associated cost */
} move_t, *move_p;
typedef struct {
int set_size;
short set_val[SETSIZE];
} set_t,*set_p;
struct exprnode {
short ex_operator;
short ex_lnode;
short ex_rnode;
};
typedef struct exprnode node_t;
typedef struct exprnode *node_p;
typedef struct { /* to stack coercions */
int c1_texpno; /* token expression number */
int c1_expr; /* boolean expression */
int c1_prop; /* property of register needed */
int c1_codep; /* code index */
cost_t c1_cost; /* cost involved */
} c1_t,*c1_p;
#ifdef MAXSPLIT
typedef struct { /* splitting coercions */
int c2_texpno; /* token expression number */
int c2_nsplit; /* split factor */
int c2_repl[MAXSPLIT]; /* replacement instances */
int c2_codep; /* code index */
} c2_t,*c2_p;
#endif MAXSPLIT
typedef struct { /* one to one coercions */
int c3_texpno; /* token expression number */
int c3_prop; /* property of register needed */
int c3_repl; /* replacement instance */
int c3_codep; /* code index */
} c3_t,*c3_p;
/*
* contents of .ex_operator
*/
#define EX_TOKFIELD 0
#define EX_ARG 1
#define EX_CON 2
#define EX_ALLREG 3
#define EX_SAMESIGN 4
#define EX_SFIT 5
#define EX_UFIT 6
#define EX_ROM 7
#define EX_NCPEQ 8
#define EX_SCPEQ 9
#define EX_RCPEQ 10
#define EX_NCPNE 11
#define EX_SCPNE 12
#define EX_RCPNE 13
#define EX_NCPGT 14
#define EX_NCPGE 15
#define EX_NCPLT 16
#define EX_NCPLE 17
#define EX_OR2 18
#define EX_AND2 19
#define EX_PLUS 20
#define EX_CAT 21
#define EX_MINUS 22
#define EX_TIMES 23
#define EX_DIVIDE 24
#define EX_MOD 25
#define EX_LSHIFT 26
#define EX_RSHIFT 27
#define EX_NOT 28
#define EX_COMP 29
#define EX_COST 30
#define EX_STRING 31
#define EX_DEFINED 32
#define EX_SUBREG 33
#define EX_TOSTRING 34
#define EX_UMINUS 35
#define EX_REG 36
#define EX_LOWW 37
#define EX_HIGHW 38
#define EX_INREG 39
#define EX_REGVAR 40
#define getint(a,b) \
if ((a=((*(b)++)&BMASK)) >= 128) {\
a = ((a-128)<<BSHIFT) | (*(b)++&BMASK); \
}

30
h/em_abs.h Normal file
View file

@ -0,0 +1,30 @@
#define LINO_AD 0
#define FILN_AD 4
#define LINO (*(int *)(_hol0()+LINO_AD))
#define FILN (*(char **)(_hol0()+FILN_AD))
#define EARRAY 0
#define ERANGE 1
#define ESET 2
#define EIOVFL 3
#define EFOVFL 4
#define EFUNFL 5
#define EIDIVZ 6
#define EFDIVZ 7
#define EIUND 8
#define EFUND 9
#define ECONV 10
#define ESTACK 16
#define EHEAP 17
#define EILLINS 18
#define EODDZ 19
#define ECASE 20
#define EMEMFLT 21
#define EBADPTR 22
#define EBADPC 23
#define EBADLAE 24
#define EBADMON 25
#define EBADLIN 26
#define EBADGTO 27

25
h/em_flag.h Normal file
View file

@ -0,0 +1,25 @@
/* flags */
#define EM_PAR 0017 /* parameter type */
#define EM_FLO 0060 /* flow information */
/* types */
#define PAR_NO 0000 /* no parameter */
#define PAR_C 0001 /* constant */
#define PAR_D 0002 /* double word constant */
#define PAR_N 0003 /* numeric (>=0) */
#define PAR_F 0004 /* address offset */
#define PAR_L 0005 /* addressing locals/parameters */
#define PAR_G 0006 /* addressing globals */
#define PAR_W 0007 /* size: word multiple, fits word, possibly indirect */
#define PAR_S 0010 /* size: word multiple */
#define PAR_Z 0011 /* size: zero or word multiple */
#define PAR_O 0012 /* size: word multiple or word fraction */
#define PAR_P 0013 /* procedure name */
#define PAR_B 0014 /* branch: instruction label */
#define PAR_R 0015 /* register number (0,1,2) */
/* flow */
#define FLO_NO 0000 /* straight on */
#define FLO_C 0020 /* conditional branch */
#define FLO_P 0040 /* procedure: call and return */
#define FLO_T 0060 /* terminate: no return */

20
h/em_mes.h Normal file
View file

@ -0,0 +1,20 @@
/*
* mnemonics for the message numbers in EM
*/
#define ms_err 0 /* Compilation error occurred, ignore rest of module */
#define ms_opt 1 /* Disable optimization please */
#define ms_emx 2 /* Wordsize and pointersize assumed */
#define ms_reg 3 /* Hint for possible register usage from frontend */
#define ms_src 4 /* Number of source lines in this module */
#define ms_flt 5 /* Floating point used */
#define ms_com 6 /* Comment to be retained in compact code */
#define ms_ret 7 /* Reserved */
#define ms_ext 8 /* List of exported symbols from this library module */
#define ms_par 9 /* Number of bytes of parameters accessed */
#define ms_ego 10 /* Hint from EM Global Optimizer */
/*
* for details about ms_reg, see em_reg.h
* for details about ms_ego, see em_ego.h
*/

8
h/em_ptyp.h Normal file
View file

@ -0,0 +1,8 @@
#define ptyp(x) (1<<(x-sp_fspec))
#define cst_ptyp 0000140
#define sym_ptyp 0000034
#define arg_ptyp 0000574
#define con_ptyp 0036000
#define val_ptyp 0037777
#define any_ptyp 0137777

10
h/em_reg.h Normal file
View file

@ -0,0 +1,10 @@
/*
* mes ms_reg,offset,size,type,priority
*
* Here are the defines for type
*/
#define reg_any 0 /* Unspecified type */
#define reg_loop 1 /* loop control variable */
#define reg_pointer 2 /* pointer variable */
#define reg_float 3 /* floating point variable */

22
h/pc_err.h Normal file
View file

@ -0,0 +1,22 @@
#define EARGC 64
#define EEXP 65
#define ELOG 66
#define ESQT 67
#define EASS 68
#define EPACK 69
#define EUNPACK 70
#define EMOD 71
#define EBADF 72
#define EFREE 73
#define EWRITEF 96
#define EREADF 97
#define EEOF 98
#define EFTRUNC 99
#define ERESET 100
#define EREWR 101
#define ECLOSE 102
#define EREAD 103
#define EWRITE 104
#define EDIGIT 105
#define EASCII 106

19
h/pc_file.h Normal file
View file

@ -0,0 +1,19 @@
#define WRBIT 0100000
#define TXTBIT 040000
#define EOFBIT 020000
#define ELNBIT 010000
#define WINDOW 04000
#define MAGIC 0252
struct file {
char *ptr;
unsigned flags;
char *fname;
int ufd;
int size;
int count;
int buflen;
char bufadr[512];
};
#define EXTFL(z) ((struct file *)(_hbase + _extfl[z]))

21
h/pc_size.h Normal file
View file

@ -0,0 +1,21 @@
/* fundamental */
#define sz_byte 1
#define sz_bool 1
#define sz_char 1
/* fixed for the time being */
#define sz_word 2
#define sz_int 2
#define sz_long 4
/* variable (see pc.c) */
#define sz_addr sizes[0]
#define sz_real sizes[1]
#define sz_head sizes[2]
#define sz_buff sizes[3]
#define sz_mset sizes[4]
#define sz_iset sizes[5]
#define sz_last 5
#define sz_proc 2*sz_addr