Modified for Solaris 2

This commit is contained in:
ceriel 1993-11-10 12:57:16 +00:00
parent 964bf270ab
commit 91d270eb90
10 changed files with 130 additions and 38 deletions

View file

@ -3,13 +3,22 @@
open_back( filename) open_back( filename)
char *filename; char *filename;
{ {
if ( filename == (char *) 0) if ( filename == (char *) 0) {
codefile= STDOUT; codefile= STDOUT;
else #ifdef __solaris__
#ifndef sys_close fprint(codefile, ".section \".text\"\n");
return( sys_open( filename, OP_WRITE, &codefile));
#else
return (codefile = fopen(filename, "w")) != NULL;
#endif #endif
return 1; return 1;
}
#ifndef sys_close
if ( sys_open( filename, OP_WRITE, &codefile)) {
#else
if ((codefile = fopen(filename, "w")) != NULL) {
#endif
#ifdef __solaris__
fprint(codefile, ".section \".text\"\n");
#endif
return 1;
}
return 0;
} }

View file

@ -2,13 +2,12 @@
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>
#include <alloc.h>
#include "mach.h" #include "mach.h"
#ifdef __STDC__ #ifdef __STDC__
#include <stdlib.h>
#include <string.h> #include <string.h>
#else #else
extern char *malloc();
extern char *strcpy(); extern char *strcpy();
#endif #endif
@ -108,6 +107,12 @@ static struct cache_elt cache[CACHE_SIZE], *tos = 0;
static int c_count = 0; static int c_count = 0;
static const_str_t s; static const_str_t s;
_PROTOTYPE(static void panic, (char*));
_PROTOTYPE(static void dump_cache, (File *stream));
_PROTOTYPE(static int cache_read, (int n, int i));
_PROTOTYPE(static void flush_part_cache, (int c, int r, int f, int d));
_PROTOTYPE(static void subst_reg, (reg_t, reg_t));
static void panic(s) static void panic(s)
char *s; char *s;
{ {
@ -824,8 +829,7 @@ char *s;
char *p; char *p;
enter("push_ext"); enter("push_ext");
p = malloc(strlen(s)+1); p = Malloc(strlen(s)+1);
assert(p);
INC_TOS; INC_TOS;
tos->reg = reg_g0; tos->reg = reg_g0;
@ -1282,7 +1286,7 @@ enter("dup_tos");
*tos = tos[-n]; *tos = tos[-n];
if (tos->ext) if (tos->ext)
{ {
ext= malloc(strlen(tos->ext)+1); ext= Malloc(strlen(tos->ext)+1);
strcpy(ext, tos->ext); strcpy(ext, tos->ext);
tos->ext= ext; tos->ext= ext;
} }

View file

@ -8,7 +8,7 @@ C_mes_end.c
C_pnam.c C_pnam.c
C_rom_scon.c C_rom_scon.c
C_scon.c C_scon.c
C_exp.c C_pro.c
C_exa_dnam.c C_exa_dnam.c
misc.c misc.c
ms_reg.c ms_reg.c

View file

@ -3,6 +3,7 @@
#include "mach.h" #include "mach.h"
#include "back.h" #include "back.h"
void
C_con_scon( s, n) C_con_scon( s, n)
char *s; char *s;
arith n; arith n;

View file

@ -2,6 +2,7 @@
#include <em.h> #include <em.h>
#include "back.h" #include "back.h"
void
C_exa_dnam( s) C_exa_dnam( s)
char *s; char *s;
{ {

View file

@ -0,0 +1,28 @@
#define CODE_EXPANDER
#include <em.h>
#include "back.h"
#include <alloc.h>
extern int B_locals_created;
extern int B_procno;
char *B_procnam;
void
C_pro( s, l)
char *s;
arith l;
{
swtxt();
s = extnd_name(s);
#ifdef __solaris__
fprint(codefile, "\t.type\t%s,#function\n", s);
if (B_procnam) free(B_procnam);
B_procnam = Salloc(s, strlen(s)+1);
#endif
symbol_definition( s);
B_procno++;
C_prolog();
C_locals(l);
B_locals_created = 1;
}

View file

@ -3,6 +3,7 @@
#include "mach.h" #include "mach.h"
#include "back.h" #include "back.h"
void
C_rom_scon( s, n) C_rom_scon( s, n)
char *s; char *s;
arith n; arith n;

View file

@ -34,6 +34,7 @@ static int current_reg_mes[RM_COUNT+4];
static int in_reg_mes = 0; /* boolean */ static int in_reg_mes = 0; /* boolean */
static int reg_mes_nr; static int reg_mes_nr;
static int db_mes = 0; static int db_mes = 0;
static int db_kind = 0;
static int db_str = 0; static int db_str = 0;
static int db_nul = 0; /* boolean */ static int db_nul = 0; /* boolean */
@ -252,18 +253,36 @@ load_float_regs()
} }
void
C_mes_begin( ms) C_mes_begin( ms)
int ms; int ms;
{ {
#ifdef __solaris__
static int inits;
#endif
reg_mes_nr = 0; reg_mes_nr = 0;
in_reg_mes = (ms == ms_reg); in_reg_mes = (ms == ms_reg);
if (ms == ms_gto) if (ms == ms_gto)
fprint(codefile, "ta 3\n"); fprint(codefile, "ta 3\n");
db_mes = (ms == ms_stb || ms == ms_std) ? ms : 0; db_mes = (ms == ms_stb || ms == ms_std) ? ms : 0;
#ifdef __solaris__
if (db_mes && ! inits) {
fprint(codefile, ".pushsection \".text\"\nBtext.text:\n.popsection\n");
fprint(codefile, ".pushsection \".data\"\nBdata.data:\n.popsection\n");
fprint(codefile, ".pushsection \".bss\"\nBbss.bss:\n.popsection\n");
inits = 1;
}
#endif
} }
static dump_reg_tabs(); static dump_reg_tabs();
#ifdef __solaris__
extern char *B_procnam;
#endif
void
C_mes_end() C_mes_end()
{ {
int pos; int pos;
@ -271,10 +290,22 @@ C_mes_end()
if (db_mes) { if (db_mes) {
db_nul = 0; db_nul = 0;
#ifdef __solaris__
if (db_mes == ms_std) {
if (db_str == 2) {
fprint(codefile, ",1f\n1:\n");
}
else {
fprint(codefile, ",1f-%s\n1:\n", B_procnam);
}
}
#else
if (db_mes == ms_std && db_str == 2) fprint(codefile,",1f\n1:\n"); if (db_mes == ms_std && db_str == 2) fprint(codefile,",1f\n1:\n");
#endif
else fprint(codefile, "\n"); else fprint(codefile, "\n");
db_str = 0; db_str = 0;
db_mes = 0; db_mes = 0;
db_kind = 0;
} }
if (!in_reg_mes) /* end of some other mes */ if (!in_reg_mes) /* end of some other mes */
return; return;
@ -326,22 +357,32 @@ C_mes_end()
extern int __gdb_flag; extern int __gdb_flag;
void
C_cst( l) C_cst( l)
arith l; arith l;
{ {
static int correct_offset; static int correct_offset;
if (db_mes) { if (db_mes) {
if (! db_kind) db_kind = l;
if (! db_str) { if (! db_str) {
switchseg( SEGTXT); switchseg( SEGTXT);
if (l == N_SLINE && ! __gdb_flag) { if (l == N_SLINE && ! __gdb_flag) {
flush_cache(); flush_cache();
#ifdef __solaris__
fprint(codefile, "call $__uX_LiB\nnop\n");
#else
fprint(codefile, "call ___uX_LiB\nnop\n"); fprint(codefile, "call ___uX_LiB\nnop\n");
#endif
} }
#ifdef __solaris__
fprint(codefile, ".stabn 0x%lx,0", (long) l);
#else
if (db_mes == ms_std) { if (db_mes == ms_std) {
fprint(codefile, ".stabd 0x%lx,0", (long) l); fprint(codefile, ".stabd 0x%lx,0", (long) l);
} }
else fprint(codefile, ".stabn 0x%lx,0", (long) l); else fprint(codefile, ".stabn 0x%lx,0", (long) l);
#endif
db_str = 1; db_str = 1;
db_nul = 1; db_nul = 1;
} }
@ -364,6 +405,7 @@ arith l;
current_reg_mes[reg_mes_nr++] = l; current_reg_mes[reg_mes_nr++] = l;
} }
void
C_scon(s, l) C_scon(s, l)
register char *s; register char *s;
register arith l; register arith l;
@ -383,6 +425,7 @@ register arith l;
} }
} }
void
C_dlb(l, off) C_dlb(l, off)
label l; label l;
arith off; arith off;
@ -391,9 +434,20 @@ arith off;
fprint(codefile,","); fprint(codefile,",");
fprint(codefile, DLB_FMT, (long) l); fprint(codefile, DLB_FMT, (long) l);
if (off) fprint(codefile,"+%ld", (long) off); if (off) fprint(codefile,"+%ld", (long) off);
#ifdef __solaris__
switch(db_kind) {
case N_LCSYM:
fprint(codefile, "-Bbss.bss");
break;
case N_STSYM:
fprint(codefile, "-Bdata.data");
break;
}
#endif
} }
} }
void
C_dnam(l, off) C_dnam(l, off)
char *l; char *l;
arith off; arith off;
@ -402,26 +456,44 @@ arith off;
fprint(codefile,","); fprint(codefile,",");
fprint(codefile, DNAM_FMT, l); fprint(codefile, DNAM_FMT, l);
if (off) fprint(codefile,"+%ld", (long) off); if (off) fprint(codefile,"+%ld", (long) off);
#ifdef __solaris__
switch(db_kind) {
case N_LCSYM:
fprint(codefile, "-Bbss.bss");
break;
case N_STSYM:
fprint(codefile, "-Bdata.data");
break;
}
#endif
} }
} }
extern int B_procno; extern int B_procno;
void
C_ilb(l) C_ilb(l)
label l; label l;
{ {
if (db_mes) { if (db_mes) {
fprint(codefile,","); fprint(codefile,",");
fprint(codefile, ILB_FMT, B_procno, (long)l); fprint(codefile, ILB_FMT, B_procno, (long)l);
#ifdef __solaris__
fprint(codefile, "-Btext.text");
#endif
} }
} }
void
C_pnam(s) C_pnam(s)
char *s; char *s;
{ {
if (db_mes) { if (db_mes) {
fprint(codefile,","); fprint(codefile,",");
fprint(codefile, NAME_FMT, s); fprint(codefile, NAME_FMT, s);
#ifdef __solaris__
fprint(codefile, "-Btext.text");
#endif
} }
} }

View file

@ -13,19 +13,6 @@ int arg;
} }
#endif #endif
/*
do_open( filename)
char *filename;
{
if ( filename == (char *)0 || !sys_open( filename, OP_WRITE, &codefile))
return( 0);
fprint( codefile, ".sect .text; .sect .rom; .sect .data; .sect .bss\n");
return( 1);
}
*/
#define IEEEFLOAT #define IEEEFLOAT
#define FL_MSL_AT_LOW_ADDRESS 1 #define FL_MSL_AT_LOW_ADDRESS 1
#define FL_MSW_AT_LOW_ADDRESS 1 #define FL_MSW_AT_LOW_ADDRESS 1

View file

@ -34,11 +34,7 @@ extern reg_t reg_f0;
extern reg_t reg_sp, reg_lb, reg_gap; extern reg_t reg_sp, reg_lb, reg_gap;
extern reg_t reg_tmp; extern reg_t reg_tmp;
#ifdef __STDC__ #include "ansi.h"
#define _PROTOTYPE(x,y) x y
#else
#define _PROTOTYPE(x,y) x()
#endif
_PROTOTYPE(int const13, (int)); _PROTOTYPE(int const13, (int));
_PROTOTYPE(void init_cache, (void)); _PROTOTYPE(void init_cache, (void));
@ -54,13 +50,8 @@ _PROTOTYPE(void push_const, (arith));
_PROTOTYPE(void push_reg, (reg_t)); _PROTOTYPE(void push_reg, (reg_t));
_PROTOTYPE(void push_ext, (char *)); _PROTOTYPE(void push_ext, (char *));
_PROTOTYPE(void flush_cache, (void)); _PROTOTYPE(void flush_cache, (void));
static _PROTOTYPE(void flush_part_cache, (int c, int r, int f, int d));
static _PROTOTYPE(void subst_reg, (reg_t, reg_t));
_PROTOTYPE(void cache_need, (int)); _PROTOTYPE(void cache_need, (int));
static _PROTOTYPE(int cache_read, (int n, int i));
static _PROTOTYPE(void dump_cache, (File *stream));
_PROTOTYPE(void pop_nop, (int)); _PROTOTYPE(void pop_nop, (int));
static _PROTOTYPE(void panic, (char*));
_PROTOTYPE(reg_t alloc_reg, (void)); _PROTOTYPE(reg_t alloc_reg, (void));
_PROTOTYPE(reg_t alloc_reg_var, (void)); _PROTOTYPE(reg_t alloc_reg_var, (void));
@ -74,8 +65,6 @@ _PROTOTYPE(reg_t pop_reg_reg, (reg_t*));
_PROTOTYPE(reg_t pop_float, (void)); _PROTOTYPE(reg_t pop_float, (void));
_PROTOTYPE(reg_t pop_double, (reg_t *sub_reg)); _PROTOTYPE(reg_t pop_double, (reg_t *sub_reg));
_PROTOTYPE(void pop_reg_as, (reg_t r)); _PROTOTYPE(void pop_reg_as, (reg_t r));
static _PROTOTYPE(reg_t top_reg, (void));
static _PROTOTYPE(reg_t top_reg_c13, (char*));
_PROTOTYPE(arith pop_const, (char *n_str)); _PROTOTYPE(arith pop_const, (char *n_str));
_PROTOTYPE(arith top_const, (void)); _PROTOTYPE(arith top_const, (void));