open_back( filename)
char *filename;
{
- if ( filename == (char *) 0)
+ if ( filename == (char *) 0) {
codefile= STDOUT;
- else
+#ifdef __solaris__
+ fprint(codefile, ".section \".text\"\n");
+#endif
+ return 1;
+ }
#ifndef sys_close
- return( sys_open( filename, OP_WRITE, &codefile));
+ if ( sys_open( filename, OP_WRITE, &codefile)) {
#else
- return (codefile = fopen(filename, "w")) != NULL;
+ if ((codefile = fopen(filename, "w")) != NULL) {
+#endif
+#ifdef __solaris__
+ fprint(codefile, ".section \".text\"\n");
#endif
- return 1;
+ return 1;
+ }
+ return 0;
}
#include <stdio.h>
#include <assert.h>
+#include <alloc.h>
#include "mach.h"
#ifdef __STDC__
-#include <stdlib.h>
#include <string.h>
#else
-extern char *malloc();
extern char *strcpy();
#endif
static int c_count = 0;
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)
char *s;
{
char *p;
enter("push_ext");
- p = malloc(strlen(s)+1);
- assert(p);
+ p = Malloc(strlen(s)+1);
INC_TOS;
tos->reg = reg_g0;
*tos = tos[-n];
if (tos->ext)
{
- ext= malloc(strlen(tos->ext)+1);
+ ext= Malloc(strlen(tos->ext)+1);
strcpy(ext, tos->ext);
tos->ext= ext;
}
C_pnam.c
C_rom_scon.c
C_scon.c
-C_exp.c
+C_pro.c
C_exa_dnam.c
misc.c
ms_reg.c
#include "mach.h"
#include "back.h"
+void
C_con_scon( s, n)
char *s;
arith n;
#include <em.h>
#include "back.h"
+void
C_exa_dnam( s)
char *s;
{
--- /dev/null
+#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;
+}
#include "mach.h"
#include "back.h"
+void
C_rom_scon( s, n)
char *s;
arith n;
static int in_reg_mes = 0; /* boolean */
static int reg_mes_nr;
static int db_mes = 0;
+static int db_kind = 0;
static int db_str = 0;
static int db_nul = 0; /* boolean */
}
+void
C_mes_begin( ms)
int ms;
{
+#ifdef __solaris__
+ static int inits;
+#endif
+
reg_mes_nr = 0;
in_reg_mes = (ms == ms_reg);
if (ms == ms_gto)
fprint(codefile, "ta 3\n");
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();
+#ifdef __solaris__
+extern char *B_procnam;
+#endif
+
+void
C_mes_end()
{
int pos;
if (db_mes) {
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");
+#endif
else fprint(codefile, "\n");
db_str = 0;
db_mes = 0;
+ db_kind = 0;
}
if (!in_reg_mes) /* end of some other mes */
return;
extern int __gdb_flag;
+void
C_cst( l)
arith l;
{
static int correct_offset;
if (db_mes) {
+ if (! db_kind) db_kind = l;
if (! db_str) {
switchseg( SEGTXT);
if (l == N_SLINE && ! __gdb_flag) {
flush_cache();
+#ifdef __solaris__
+ fprint(codefile, "call $__uX_LiB\nnop\n");
+#else
fprint(codefile, "call ___uX_LiB\nnop\n");
+#endif
}
+#ifdef __solaris__
+ fprint(codefile, ".stabn 0x%lx,0", (long) l);
+#else
if (db_mes == ms_std) {
fprint(codefile, ".stabd 0x%lx,0", (long) l);
}
else fprint(codefile, ".stabn 0x%lx,0", (long) l);
+#endif
db_str = 1;
db_nul = 1;
}
current_reg_mes[reg_mes_nr++] = l;
}
+void
C_scon(s, l)
register char *s;
register arith l;
}
}
+void
C_dlb(l, off)
label l;
arith off;
fprint(codefile,",");
fprint(codefile, DLB_FMT, (long) l);
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)
char *l;
arith off;
fprint(codefile,",");
fprint(codefile, DNAM_FMT, l);
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;
+void
C_ilb(l)
label l;
{
if (db_mes) {
fprint(codefile,",");
fprint(codefile, ILB_FMT, B_procno, (long)l);
+#ifdef __solaris__
+ fprint(codefile, "-Btext.text");
+#endif
}
}
+void
C_pnam(s)
char *s;
{
if (db_mes) {
fprint(codefile,",");
fprint(codefile, NAME_FMT, s);
+#ifdef __solaris__
+ fprint(codefile, "-Btext.text");
+#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 FL_MSL_AT_LOW_ADDRESS 1
#define FL_MSW_AT_LOW_ADDRESS 1
extern reg_t reg_sp, reg_lb, reg_gap;
extern reg_t reg_tmp;
-#ifdef __STDC__
-#define _PROTOTYPE(x,y) x y
-#else
-#define _PROTOTYPE(x,y) x()
-#endif
+#include "ansi.h"
_PROTOTYPE(int const13, (int));
_PROTOTYPE(void init_cache, (void));
_PROTOTYPE(void push_reg, (reg_t));
_PROTOTYPE(void push_ext, (char *));
_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));
-static _PROTOTYPE(int cache_read, (int n, int i));
-static _PROTOTYPE(void dump_cache, (File *stream));
_PROTOTYPE(void pop_nop, (int));
-static _PROTOTYPE(void panic, (char*));
_PROTOTYPE(reg_t alloc_reg, (void));
_PROTOTYPE(reg_t alloc_reg_var, (void));
_PROTOTYPE(reg_t pop_float, (void));
_PROTOTYPE(reg_t pop_double, (reg_t *sub_reg));
_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 top_const, (void));