mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-10 14:52:00 +00:00
* Removed the last of the binary target stuff from lcc (hopefully)
This commit is contained in:
parent
2d2df7682d
commit
2cc87dfc9d
57 changed files with 2 additions and 8264 deletions
|
@ -1,14 +0,0 @@
|
|||
#ifndef __ASSERT
|
||||
#define __ASSERT
|
||||
|
||||
void assert(int);
|
||||
|
||||
#endif /* __ASSERT */
|
||||
|
||||
#undef assert
|
||||
#ifdef NDEBUG
|
||||
#define assert(ignore) ((void)0)
|
||||
#else
|
||||
extern void __assert(char *, char *, unsigned);
|
||||
#define assert(e) ((void)((e)||(__assert(#e, __FILE__, __LINE__),0)))
|
||||
#endif /* NDEBUG */
|
|
@ -1,25 +0,0 @@
|
|||
#ifndef __CTYPE
|
||||
#define __CTYPE
|
||||
|
||||
extern int isalnum(int);
|
||||
extern int isalpha(int);
|
||||
extern int iscntrl(int);
|
||||
extern int isdigit(int);
|
||||
extern int isgraph(int);
|
||||
extern int islower(int);
|
||||
extern int isprint(int);
|
||||
extern int ispunct(int);
|
||||
extern int isspace(int);
|
||||
extern int isupper(int);
|
||||
extern int isxdigit(int);
|
||||
extern int tolower(int);
|
||||
extern int toupper(int);
|
||||
|
||||
#define __U 01
|
||||
#define __L 02
|
||||
#define __N 04
|
||||
#define __S 010
|
||||
#define __P 020
|
||||
#define __C 040
|
||||
|
||||
#endif /* __CTYPE */
|
|
@ -1,8 +0,0 @@
|
|||
#ifndef __ERRNO
|
||||
#define __ERRNO
|
||||
|
||||
#define EDOM 33
|
||||
#define ERANGE 34
|
||||
extern int errno;
|
||||
|
||||
#endif /* __ERRNO */
|
|
@ -1,37 +0,0 @@
|
|||
#ifndef __FLOAT
|
||||
#define __FLOAT
|
||||
|
||||
#define FLT_ROUNDS 1
|
||||
#define FLT_RADIX 2
|
||||
|
||||
#define FLT_DIG 6
|
||||
#define FLT_EPSILON 1.19209289550781250000e-07
|
||||
#define FLT_MANT_DIG 24
|
||||
#define FLT_MAX 3.40282346638528860000e+38
|
||||
#define FLT_MAX_10_EXP 38
|
||||
#define FLT_MAX_EXP 128
|
||||
#define FLT_MIN 1.17549435082228750000e-38
|
||||
#define FLT_MIN_10_EXP -37
|
||||
#define FLT_MIN_EXP -125
|
||||
|
||||
#define DBL_DIG 15
|
||||
#define DBL_EPSILON 2.22044604925031310000e-16
|
||||
#define DBL_MANT_DIG 53
|
||||
#define DBL_MAX 1.79769313486231570000e+308
|
||||
#define DBL_MAX_10_EXP 308
|
||||
#define DBL_MAX_EXP 1024
|
||||
#define DBL_MIN 2.22507385850720140000e-308
|
||||
#define DBL_MIN_10_EXP -307
|
||||
#define DBL_MIN_EXP -1021
|
||||
|
||||
#define LDBL_MANT_DIG DBL_MANT_DIG
|
||||
#define LDBL_EPSILON DBL_EPSILON
|
||||
#define LDBL_DIG DBL_DIG
|
||||
#define LDBL_MIN_EXP DBL_MIN_EXP
|
||||
#define LDBL_MIN DBL_MIN
|
||||
#define LDBL_MIN_10_EXP DBL_MIN_10_EXP
|
||||
#define LDBL_MAX_EXP DBL_MAX_EXP
|
||||
#define LDBL_MAX DBL_MAX
|
||||
#define LDBL_MAX_10_EXP DBL_MAX_10_EXP
|
||||
|
||||
#endif /* __FLOAT */
|
|
@ -1,24 +0,0 @@
|
|||
#ifndef __LIMITS
|
||||
#define __LIMITS
|
||||
|
||||
#define CHAR_BIT 8
|
||||
#define MB_LEN_MAX 1
|
||||
|
||||
#define UCHAR_MAX 0xff
|
||||
#define USHRT_MAX 0xffff
|
||||
#define UINT_MAX (~0U)
|
||||
#define ULONG_MAX (~0UL)
|
||||
|
||||
#define CHAR_MAX SCHAR_MAX
|
||||
#define SCHAR_MAX 0x7f
|
||||
#define SHRT_MAX 0x7fff
|
||||
#define INT_MAX 0x7fffffff
|
||||
#define LONG_MAX 0x7fffffffffffffffL
|
||||
|
||||
#define CHAR_MIN SCHAR_MIN
|
||||
#define SCHAR_MIN (-SCHAR_MAX-1)
|
||||
#define SHRT_MIN (-SHRT_MAX-1)
|
||||
#define INT_MIN (-INT_MAX-1)
|
||||
#define LONG_MIN (-LONG_MAX-1)
|
||||
|
||||
#endif /* __LIMITS */
|
|
@ -1,36 +0,0 @@
|
|||
#ifndef __LOCALE
|
||||
#define __LOCALE
|
||||
|
||||
#define LC_ALL 0
|
||||
#define LC_COLLATE 1
|
||||
#define LC_CTYPE 2
|
||||
#define LC_MONETARY 3
|
||||
#define LC_NUMERIC 4
|
||||
#define LC_TIME 5
|
||||
#define NULL 0
|
||||
|
||||
struct lconv {
|
||||
char *decimal_point;
|
||||
char *thousands_sep;
|
||||
char *grouping;
|
||||
char *int_curr_symbol;
|
||||
char *currency_symbol;
|
||||
char *mon_decimal_point;
|
||||
char *mon_thousands_sep;
|
||||
char *mon_grouping;
|
||||
char *positive_sign;
|
||||
char *negative_sign;
|
||||
char int_frac_digits;
|
||||
char frac_digits;
|
||||
char p_cs_precedes;
|
||||
char p_sep_by_space;
|
||||
char n_cs_precedes;
|
||||
char n_sep_by_space;
|
||||
char p_sign_posn;
|
||||
char n_sign_posn;
|
||||
};
|
||||
|
||||
char *setlocale(int, const char *);
|
||||
struct lconv *localeconv(void);
|
||||
|
||||
#endif /* __LOCALE */
|
|
@ -1,29 +0,0 @@
|
|||
#ifndef __MATH
|
||||
#define __MATH
|
||||
|
||||
#define HUGE_VAL 1.79769313486231570000e+308
|
||||
|
||||
extern double acos(double);
|
||||
extern double asin(double);
|
||||
extern double atan(double);
|
||||
extern double atan2(double, double);
|
||||
extern double cos(double);
|
||||
extern double sin(double);
|
||||
extern double tan(double);
|
||||
extern double cosh(double);
|
||||
extern double sinh(double);
|
||||
extern double tanh(double);
|
||||
extern double exp(double);
|
||||
extern double frexp(double, int *);
|
||||
extern double ldexp(double, int);
|
||||
extern double log(double);
|
||||
extern double log10(double);
|
||||
extern double modf(double, double *);
|
||||
extern double pow(double, double);
|
||||
extern double sqrt(double);
|
||||
extern double ceil(double);
|
||||
extern double fabs(double);
|
||||
extern double floor(double);
|
||||
extern double fmod(double, double);
|
||||
|
||||
#endif /* __MATH */
|
|
@ -1,10 +0,0 @@
|
|||
#ifndef __SETJMP
|
||||
#define __SETJMP
|
||||
|
||||
|
||||
|
||||
typedef int jmp_buf[35+1+48];
|
||||
int setjmp(jmp_buf);
|
||||
void longjmp(jmp_buf, int);
|
||||
|
||||
#endif /* __SETJMP */
|
|
@ -1,20 +0,0 @@
|
|||
#ifndef __SIGNAL
|
||||
#define __SIGNAL
|
||||
|
||||
typedef int sig_atomic_t;
|
||||
|
||||
#define SIG_DFL ((void (*)(int))0)
|
||||
#define SIG_ERR ((void (*)(int))-1)
|
||||
#define SIG_IGN ((void (*)(int))1)
|
||||
|
||||
#define SIGABRT 6
|
||||
#define SIGFPE 8
|
||||
#define SIGILL 4
|
||||
#define SIGINT 2
|
||||
#define SIGSEGV 11
|
||||
#define SIGTERM 15
|
||||
|
||||
void (*signal(int, void (*)(int)))(int);
|
||||
int raise(int);
|
||||
|
||||
#endif /* __SIGNAL */
|
|
@ -1,28 +0,0 @@
|
|||
#ifndef __STDARG
|
||||
#define __STDARG
|
||||
|
||||
#if !defined(_VA_LIST)
|
||||
#define _VA_LIST
|
||||
typedef struct {
|
||||
char *_a0; /* pointer to first homed integer arg */
|
||||
int _offset; /* byte offset of next param */
|
||||
float _tmp;
|
||||
} __va_list;
|
||||
#endif
|
||||
typedef __va_list va_list;
|
||||
|
||||
#define va_start(list, start) ((void)( \
|
||||
(list)._a0 = (__typecode(__firstarg)==1 ? \
|
||||
(char*)&__firstarg+48 : (char *)&__firstarg), \
|
||||
(list)._offset = (__typecode(start)==1 ? \
|
||||
(char*)&start+56 : (char *)&start+8)-(list)._a0))
|
||||
#define va_arg(list, mode) (*(mode *)( \
|
||||
(list)._offset += (int)((sizeof(mode)+7)&~7), \
|
||||
(__typecode(mode)==1 && sizeof(mode)==4) ? \
|
||||
((list)._tmp = (float)*(double *)((list)._a0 + (list)._offset - \
|
||||
((list)._offset <= 48 ? 56 : 8))), (char *)&(list)._tmp : \
|
||||
(__typecode(mode)==1 && (list)._offset <= 48) ? \
|
||||
(list)._a0 + (list)._offset - 56 : \
|
||||
(list)._a0 + (list)._offset - (int)((sizeof(mode)+7)&~7)))
|
||||
#define va_end(list) ((void)0)
|
||||
#endif
|
|
@ -1,22 +0,0 @@
|
|||
#ifndef __STDDEF
|
||||
#define __STDDEF
|
||||
|
||||
|
||||
#define NULL 0
|
||||
#define offsetof(ty,mem) ((size_t)((char*)&((ty*)0)->mem - (char*)0))
|
||||
|
||||
typedef long ptrdiff_t;
|
||||
|
||||
#if !defined(_SIZE_T) && !defined(_SIZE_T_)
|
||||
#define _SIZE_T
|
||||
#define _SIZE_T_
|
||||
typedef unsigned long size_t;
|
||||
#endif
|
||||
|
||||
#if !defined(_WCHAR_T) && !defined(_WCHAR_T_)
|
||||
#define _WCHAR_T
|
||||
#define _WCHAR_T_
|
||||
typedef unsigned short wchar_t;
|
||||
#endif
|
||||
|
||||
#endif /* __STDDEF */
|
|
@ -1,113 +0,0 @@
|
|||
#ifndef __STDIO
|
||||
#define __STDIO
|
||||
|
||||
#define _IOFBF 0
|
||||
#define _IOLBF 0200
|
||||
#define _IONBF 04
|
||||
#define BUFSIZ 8192
|
||||
#define EOF (-1)
|
||||
|
||||
typedef struct _iobuf {
|
||||
int _cnt;
|
||||
unsigned char *_ptr;
|
||||
unsigned char *_base;
|
||||
int _bufsiz;
|
||||
short _flag;
|
||||
short _file;
|
||||
char *__newbase;
|
||||
void *_lock;
|
||||
unsigned char *_bufendp;
|
||||
} FILE;
|
||||
extern FILE _iob[];
|
||||
#define FILENAME_MAX 255
|
||||
#define FOPEN_MAX 64
|
||||
|
||||
#if !defined(_FPOS_T) && !defined(_FPOS_T_)
|
||||
#define _FPOS_T
|
||||
#define _FPOS_T_
|
||||
typedef long fpos_t;
|
||||
#endif
|
||||
|
||||
#define L_tmpnam 21
|
||||
#define NULL 0
|
||||
#define SEEK_CUR 1
|
||||
#define SEEK_END 2
|
||||
#define SEEK_SET 0
|
||||
|
||||
#if !defined(_SIZE_T) && !defined(_SIZE_T_)
|
||||
#define _SIZE_T
|
||||
#define _SIZE_T_
|
||||
typedef unsigned long size_t;
|
||||
#endif
|
||||
|
||||
#if !defined(_VA_LIST)
|
||||
#define _VA_LIST
|
||||
typedef struct {
|
||||
char *_a0; /* pointer to first homed integer arg */
|
||||
int _offset; /* byte offset of next param */
|
||||
float _tmp;
|
||||
} __va_list;
|
||||
#endif
|
||||
|
||||
#define stderr (&_iob[2])
|
||||
#define stdin (&_iob[0])
|
||||
#define stdout (&_iob[1])
|
||||
#define TMP_MAX 16384
|
||||
|
||||
extern int remove(const char *);
|
||||
extern int rename(const char *, const char *);
|
||||
extern FILE *tmpfile(void);
|
||||
extern char *tmpnam(char *);
|
||||
extern int fclose(FILE *);
|
||||
extern int fflush(FILE *);
|
||||
extern FILE *fopen(const char *, const char *);
|
||||
extern FILE *freopen(const char *, const char *, FILE *);
|
||||
extern void setbuf(FILE *, char *);
|
||||
extern int setvbuf(FILE *, char *, int, size_t);
|
||||
extern int fprintf(FILE *, const char *, ...);
|
||||
extern int fscanf(FILE *, const char *, ...);
|
||||
extern int printf(const char *, ...);
|
||||
extern int scanf(const char *, ...);
|
||||
extern int sprintf(char *, const char *, ...);
|
||||
extern int sscanf(const char *, const char *, ...);
|
||||
extern int vfprintf(FILE *, const char *, __va_list);
|
||||
extern int vprintf(const char *, __va_list);
|
||||
extern int vsprintf(char *, const char *, __va_list);
|
||||
extern int fgetc(FILE *);
|
||||
extern char *fgets(char *, int, FILE *);
|
||||
extern int fputc(int, FILE *);
|
||||
extern int fputs(const char *, FILE *);
|
||||
extern int getc(FILE *);
|
||||
extern int getchar(void);
|
||||
extern char *gets(char *);
|
||||
extern int putc(int, FILE *);
|
||||
extern int putchar(int);
|
||||
extern int puts(const char *);
|
||||
extern int ungetc(int, FILE *);
|
||||
extern size_t fread(void *, size_t, size_t, FILE *);
|
||||
extern size_t fwrite(const void *, size_t, size_t, FILE *);
|
||||
extern int fgetpos(FILE *, fpos_t *);
|
||||
extern int fseek(FILE *, long int, int);
|
||||
extern int fsetpos(FILE *, const fpos_t *);
|
||||
extern long int ftell(FILE *);
|
||||
extern void rewind(FILE *);
|
||||
extern void clearerr(FILE *);
|
||||
extern int feof(FILE *);
|
||||
extern int ferror(FILE *);
|
||||
extern void perror(const char *);
|
||||
|
||||
#define _IOEOF 020
|
||||
#define _IOERR 040
|
||||
|
||||
#define getc(p) (--(p)->_cnt < 0 ? _filbuf(p) : (int) *(p)->_ptr++)
|
||||
#define putc(x, p) (--(p)->_cnt < 0 ? \
|
||||
_flsbuf((unsigned char) (x), p) : \
|
||||
(int) (*(p)->_ptr++ = (unsigned char) (x)))
|
||||
extern int _filbuf(FILE *), _flsbuf(unsigned, FILE *);
|
||||
#define feof(p) ((p)->_flag&_IOEOF)
|
||||
#define ferror(p) ((p)->_flag&_IOERR)
|
||||
#define clearerr(p) ((p)->_flag &= ~(_IOERR|_IOEOF))
|
||||
#define getchar() getc(stdin)
|
||||
#define putchar(x) putc((x),stdout)
|
||||
|
||||
#endif /* __STDIO */
|
|
@ -1,54 +0,0 @@
|
|||
#ifndef __STDLIB
|
||||
#define __STDLIB
|
||||
|
||||
#define EXIT_FAILURE 1
|
||||
#define EXIT_SUCCESS 0
|
||||
#define MB_CUR_MAX 1
|
||||
#define NULL 0
|
||||
#define RAND_MAX 32767
|
||||
|
||||
typedef struct { int quot, rem; } div_t;
|
||||
typedef struct { long quot, rem; } ldiv_t;
|
||||
|
||||
#if !defined(_SIZE_T) && !defined(_SIZE_T_)
|
||||
#define _SIZE_T
|
||||
#define _SIZE_T_
|
||||
typedef unsigned long size_t;
|
||||
#endif
|
||||
|
||||
#if !defined(_WCHAR_T) && !defined(_WCHAR_T_)
|
||||
#define _WCHAR_T
|
||||
#define _WCHAR_T_
|
||||
typedef unsigned char wchar_t;
|
||||
#endif
|
||||
|
||||
extern double atof(const char *);
|
||||
extern int atoi(const char *);
|
||||
extern long int atol(const char *);
|
||||
extern double strtod(const char *, char **);
|
||||
extern long int strtol(const char *, char **, int);
|
||||
extern unsigned long int strtoul(const char *, char **, int);
|
||||
extern int rand(void);
|
||||
extern void srand(unsigned int);
|
||||
extern void *calloc(size_t, size_t);
|
||||
extern void free(void *);
|
||||
extern void *malloc(size_t);
|
||||
extern void *realloc(void *, size_t);
|
||||
extern void abort(void);
|
||||
extern int atexit(void (*)(void));
|
||||
extern void exit(int);
|
||||
extern char *getenv(const char *);
|
||||
extern int system(const char *);
|
||||
extern void *bsearch(const void *, const void *, size_t, size_t, int (*)(const void *, const void *));
|
||||
extern void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
|
||||
extern int abs(int);
|
||||
extern div_t div(int, int);
|
||||
extern long int labs(long int);
|
||||
extern ldiv_t ldiv(long int, long int);
|
||||
extern int mblen(const char *, size_t);
|
||||
extern int mbtowc(wchar_t *, const char *, size_t);
|
||||
extern int wctomb(char *, wchar_t);
|
||||
extern size_t mbstowcs(wchar_t *, const char *, size_t);
|
||||
extern size_t wcstombs(char *, const wchar_t *, size_t);
|
||||
|
||||
#endif /* __STDLIB */
|
|
@ -1,35 +0,0 @@
|
|||
#ifndef __STRING
|
||||
#define __STRING
|
||||
|
||||
#define NULL 0
|
||||
|
||||
#if !defined(_SIZE_T) && !defined(_SIZE_T_)
|
||||
#define _SIZE_T
|
||||
#define _SIZE_T_
|
||||
typedef unsigned long size_t;
|
||||
#endif
|
||||
|
||||
void *memcpy(void *, const void *, size_t);
|
||||
void *memmove(void *, const void *, size_t);
|
||||
char *strcpy(char *, const char *);
|
||||
char *strncpy(char *, const char *, size_t);
|
||||
char *strcat(char *, const char *);
|
||||
char *strncat(char *, const char *, size_t);
|
||||
int memcmp(const void *, const void *, size_t);
|
||||
int strcmp(const char *, const char *);
|
||||
int strcoll(const char *, const char *);
|
||||
int strncmp(const char *, const char *, size_t);
|
||||
size_t strxfrm(char *, const char *, size_t);
|
||||
void *memchr(const void *, int, size_t);
|
||||
char *strchr(const char *, int);
|
||||
size_t strcspn(const char *, const char *);
|
||||
char *strpbrk(const char *, const char *);
|
||||
char *strrchr(const char *, int);
|
||||
size_t strspn(const char *, const char *);
|
||||
char *strstr(const char *, const char *);
|
||||
char *strtok(char *, const char *);
|
||||
void *memset(void *, int, size_t);
|
||||
char *strerror(int);
|
||||
size_t strlen(const char *);
|
||||
|
||||
#endif /* __STRING */
|
|
@ -1,50 +0,0 @@
|
|||
#ifndef __TIME
|
||||
#define __TIME
|
||||
|
||||
#define CLOCKS_PER_SEC 1000000
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#if !defined(_CLOCK_T) && !defined(_CLOCK_T_)
|
||||
#define _CLOCK_T
|
||||
#define _CLOCK_T_
|
||||
typedef long clock_t;
|
||||
#endif
|
||||
|
||||
#if !defined(_TIME_T) && !defined(_TIME_T_)
|
||||
#define _TIME_T
|
||||
#define _TIME_T_
|
||||
typedef long time_t;
|
||||
#endif
|
||||
|
||||
#if !defined(_SIZE_T) && !defined(_SIZE_T_)
|
||||
#define _SIZE_T
|
||||
#define _SIZE_T_
|
||||
typedef unsigned long size_t;
|
||||
#endif
|
||||
|
||||
struct tm {
|
||||
int tm_sec;
|
||||
int tm_min;
|
||||
int tm_hour;
|
||||
int tm_mday;
|
||||
int tm_mon;
|
||||
int tm_year;
|
||||
int tm_wday;
|
||||
int tm_yday;
|
||||
int tm_isdst;
|
||||
long __tm_gmtoff;
|
||||
char *__tm_zone;
|
||||
};
|
||||
extern clock_t clock(void);
|
||||
extern double difftime(time_t, time_t);
|
||||
extern time_t mktime(struct tm *);
|
||||
extern time_t time(time_t *);
|
||||
extern char *asctime(const struct tm *);
|
||||
extern char *ctime(const time_t *);
|
||||
extern struct tm *gmtime(const time_t *);
|
||||
extern struct tm *localtime(const time_t *);
|
||||
extern size_t strftime(char *, size_t, const char *, const struct tm *);
|
||||
|
||||
#endif /* __TIME */
|
|
@ -1,14 +0,0 @@
|
|||
#ifndef __ASSERT
|
||||
#define __ASSERT
|
||||
|
||||
void assert(int);
|
||||
|
||||
#endif /* __ASSERT */
|
||||
|
||||
#undef assert
|
||||
#ifdef NDEBUG
|
||||
#define assert(ignore) ((void)0)
|
||||
#else
|
||||
extern int _assert(char *, char *, unsigned);
|
||||
#define assert(e) ((void)((e)||_assert(#e, __FILE__, __LINE__)))
|
||||
#endif /* NDEBUG */
|
|
@ -1,40 +0,0 @@
|
|||
#ifndef __CTYPE
|
||||
#define __CTYPE
|
||||
|
||||
extern int isalnum(int);
|
||||
extern int isalpha(int);
|
||||
extern int iscntrl(int);
|
||||
extern int isdigit(int);
|
||||
extern int isgraph(int);
|
||||
extern int islower(int);
|
||||
extern int isprint(int);
|
||||
extern int ispunct(int);
|
||||
extern int isspace(int);
|
||||
extern int isupper(int);
|
||||
extern int isxdigit(int);
|
||||
extern int tolower(int);
|
||||
extern int toupper(int);
|
||||
|
||||
#define __U 01
|
||||
#define __L 02
|
||||
#define __N 04
|
||||
#define __S 010
|
||||
#define __P 020
|
||||
#define __C 040
|
||||
#define __B 0100
|
||||
#define __X 0200
|
||||
|
||||
extern unsigned char _ctype[];
|
||||
#define isalnum(c) ((_ctype+1)[c]&(__U|__L|__N))
|
||||
#define isalpha(c) ((_ctype+1)[c]&(__U|__L))
|
||||
#define iscntrl(c) ((_ctype+1)[c]&__C)
|
||||
#define isdigit(c) ((_ctype+1)[c]&__N)
|
||||
#define isgraph(c) ((_ctype+1)[c]&(__P|__U|__L|__N))
|
||||
#define islower(c) ((_ctype+1)[c]&__L)
|
||||
#define isprint(c) ((_ctype+1)[c]&(__P|__U|__L|__N|__B))
|
||||
#define ispunct(c) ((_ctype+1)[c]&__P)
|
||||
#define isspace(c) ((_ctype+1)[c]&__S)
|
||||
#define isupper(c) ((_ctype+1)[c]&__U)
|
||||
#define isxdigit(c) ((_ctype+1)[c]&__X)
|
||||
|
||||
#endif /* __CTYPE */
|
|
@ -1,8 +0,0 @@
|
|||
#ifndef __ERRNO
|
||||
#define __ERRNO
|
||||
|
||||
#define EDOM 33
|
||||
#define ERANGE 34
|
||||
extern int errno;
|
||||
|
||||
#endif /* __ERRNO */
|
|
@ -1,37 +0,0 @@
|
|||
#ifndef __FLOAT
|
||||
#define __FLOAT
|
||||
|
||||
#define FLT_ROUNDS 1
|
||||
#define FLT_RADIX 2
|
||||
|
||||
#define FLT_DIG 6
|
||||
#define FLT_EPSILON 1.19209289550781250000e-07
|
||||
#define FLT_MANT_DIG 24
|
||||
#define FLT_MAX 3.40282346638528860000e+38
|
||||
#define FLT_MAX_10_EXP 38
|
||||
#define FLT_MAX_EXP 128
|
||||
#define FLT_MIN 1.17549435082228750000e-38
|
||||
#define FLT_MIN_10_EXP -37
|
||||
#define FLT_MIN_EXP -125
|
||||
|
||||
#define DBL_DIG 15
|
||||
#define DBL_EPSILON 2.22044604925031310000e-16
|
||||
#define DBL_MANT_DIG 53
|
||||
#define DBL_MAX 1.79769313486231570000e+308
|
||||
#define DBL_MAX_10_EXP 308
|
||||
#define DBL_MAX_EXP 1024
|
||||
#define DBL_MIN 2.22507385850720140000e-308
|
||||
#define DBL_MIN_10_EXP -307
|
||||
#define DBL_MIN_EXP -1021
|
||||
|
||||
#define LDBL_MANT_DIG DBL_MANT_DIG
|
||||
#define LDBL_EPSILON DBL_EPSILON
|
||||
#define LDBL_DIG DBL_DIG
|
||||
#define LDBL_MIN_EXP DBL_MIN_EXP
|
||||
#define LDBL_MIN DBL_MIN
|
||||
#define LDBL_MIN_10_EXP DBL_MIN_10_EXP
|
||||
#define LDBL_MAX_EXP DBL_MAX_EXP
|
||||
#define LDBL_MAX DBL_MAX
|
||||
#define LDBL_MAX_10_EXP DBL_MAX_10_EXP
|
||||
|
||||
#endif /* __FLOAT */
|
|
@ -1,24 +0,0 @@
|
|||
#ifndef __LIMITS
|
||||
#define __LIMITS
|
||||
|
||||
#define CHAR_BIT 8
|
||||
#define MB_LEN_MAX 1
|
||||
|
||||
#define UCHAR_MAX 0xff
|
||||
#define USHRT_MAX 0xffff
|
||||
#define UINT_MAX (~0U)
|
||||
#define ULONG_MAX (~0UL)
|
||||
|
||||
#define CHAR_MAX SCHAR_MAX
|
||||
#define SCHAR_MAX 0x7f
|
||||
#define SHRT_MAX 0x7fff
|
||||
#define INT_MAX 0x7fffffff
|
||||
#define LONG_MAX 0x7fffffffL
|
||||
|
||||
#define CHAR_MIN SCHAR_MIN
|
||||
#define SCHAR_MIN (-SCHAR_MAX-1)
|
||||
#define SHRT_MIN (-SHRT_MAX-1)
|
||||
#define INT_MIN (-INT_MAX-1)
|
||||
#define LONG_MIN (-LONG_MAX-1)
|
||||
|
||||
#endif /* __LIMITS */
|
|
@ -1,36 +0,0 @@
|
|||
#ifndef __LOCALE
|
||||
#define __LOCALE
|
||||
|
||||
#define LC_ALL 0
|
||||
#define LC_COLLATE 1
|
||||
#define LC_CTYPE 2
|
||||
#define LC_MONETARY 3
|
||||
#define LC_NUMERIC 4
|
||||
#define LC_TIME 5
|
||||
#define NULL 0
|
||||
|
||||
struct lconv {
|
||||
char *decimal_point;
|
||||
char *thousands_sep;
|
||||
char *grouping;
|
||||
char *int_curr_symbol;
|
||||
char *currency_symbol;
|
||||
char *mon_decimal_point;
|
||||
char *mon_thousands_sep;
|
||||
char *mon_grouping;
|
||||
char *positive_sign;
|
||||
char *negative_sign;
|
||||
char int_frac_digits;
|
||||
char frac_digits;
|
||||
char p_cs_precedes;
|
||||
char p_sep_by_space;
|
||||
char n_cs_precedes;
|
||||
char n_sep_by_space;
|
||||
char p_sign_posn;
|
||||
char n_sign_posn;
|
||||
};
|
||||
|
||||
char *setlocale(int, const char *);
|
||||
struct lconv *localeconv(void);
|
||||
|
||||
#endif /* __LOCALE */
|
|
@ -1,29 +0,0 @@
|
|||
#ifndef __MATH
|
||||
#define __MATH
|
||||
|
||||
#define HUGE_VAL 1.79769313486231570000e+308
|
||||
|
||||
extern double acos(double);
|
||||
extern double asin(double);
|
||||
extern double atan(double);
|
||||
extern double atan2(double, double);
|
||||
extern double cos(double);
|
||||
extern double sin(double);
|
||||
extern double tan(double);
|
||||
extern double cosh(double);
|
||||
extern double sinh(double);
|
||||
extern double tanh(double);
|
||||
extern double exp(double);
|
||||
extern double frexp(double, int *);
|
||||
extern double ldexp(double, int);
|
||||
extern double log(double);
|
||||
extern double log10(double);
|
||||
extern double modf(double, double *);
|
||||
extern double pow(double, double);
|
||||
extern double sqrt(double);
|
||||
extern double ceil(double);
|
||||
extern double fabs(double);
|
||||
extern double floor(double);
|
||||
extern double fmod(double, double);
|
||||
|
||||
#endif /* __MATH */
|
|
@ -1,10 +0,0 @@
|
|||
#ifndef __SETJMP
|
||||
#define __SETJMP
|
||||
|
||||
|
||||
|
||||
typedef int jmp_buf[28];
|
||||
int setjmp(jmp_buf);
|
||||
void longjmp(jmp_buf, int);
|
||||
|
||||
#endif /* __SETJMP */
|
|
@ -1,20 +0,0 @@
|
|||
#ifndef __SIGNAL
|
||||
#define __SIGNAL
|
||||
|
||||
typedef int sig_atomic_t;
|
||||
|
||||
#define SIG_DFL ((void (*)(int))0)
|
||||
#define SIG_ERR ((void (*)(int))-1)
|
||||
#define SIG_IGN ((void (*)(int))1)
|
||||
|
||||
#define SIGABRT 6
|
||||
#define SIGFPE 8
|
||||
#define SIGILL 4
|
||||
#define SIGINT 2
|
||||
#define SIGSEGV 11
|
||||
#define SIGTERM 15
|
||||
|
||||
void (*signal(int, void (*)(int)))(int);
|
||||
int raise(int);
|
||||
|
||||
#endif /* __SIGNAL */
|
|
@ -1,22 +0,0 @@
|
|||
#ifndef __STDARG
|
||||
#define __STDARG
|
||||
|
||||
#if !defined(_VA_LIST)
|
||||
#define _VA_LIST
|
||||
typedef char *__va_list;
|
||||
#endif
|
||||
typedef __va_list va_list;
|
||||
|
||||
#define va_start(list, start) ((void)((list) = (sizeof(start)<4 ? \
|
||||
(char *)((int *)&(start)+1) : (char *)(&(start)+1))))
|
||||
#define __va_arg(list, mode, n) \
|
||||
(*(mode *)(&(list += ((sizeof(mode)+n)&~n))[-(int)((sizeof(mode)+n)&~n)]))
|
||||
#define _bigendian_va_arg(list, mode, n) (\
|
||||
sizeof(mode)==1 ? *(mode *)(&(list += 4)[-1]) : \
|
||||
sizeof(mode)==2 ? *(mode *)(&(list += 4)[-2]) : __va_arg(list, mode, n))
|
||||
#define _littleendian_va_arg(list, mode, n) __va_arg(list, mode, n)
|
||||
#define va_end(list) ((void)0)
|
||||
#define va_arg(list, mode) (sizeof(mode)==8 ? \
|
||||
*(mode *)(&(list = (char*)(((int)list + 15)&~7U))[-8]) : \
|
||||
_bigendian_va_arg(list, mode, 3U))
|
||||
#endif
|
|
@ -1,22 +0,0 @@
|
|||
#ifndef __STDDEF
|
||||
#define __STDDEF
|
||||
|
||||
|
||||
#define NULL 0
|
||||
#define offsetof(ty,mem) ((size_t)((char*)&((ty*)0)->mem - (char*)0))
|
||||
|
||||
typedef long ptrdiff_t;
|
||||
|
||||
#if !defined(_SIZE_T) && !defined(_SIZE_T_)
|
||||
#define _SIZE_T
|
||||
#define _SIZE_T_
|
||||
typedef unsigned long size_t;
|
||||
#endif
|
||||
|
||||
#if !defined(_WCHAR_T) && !defined(_WCHAR_T_)
|
||||
#define _WCHAR_T
|
||||
#define _WCHAR_T_
|
||||
typedef unsigned short wchar_t;
|
||||
#endif
|
||||
|
||||
#endif /* __STDDEF */
|
|
@ -1,103 +0,0 @@
|
|||
#ifndef __STDIO
|
||||
#define __STDIO
|
||||
|
||||
#define _IOFBF 0
|
||||
#define _IOLBF 0100
|
||||
#define _IONBF 04
|
||||
#define BUFSIZ 1024
|
||||
#define EOF (-1)
|
||||
|
||||
extern struct _iobuf {
|
||||
int _cnt;
|
||||
unsigned char *_ptr;
|
||||
unsigned char *_base;
|
||||
char _flag;
|
||||
char _file;
|
||||
} _iob[];
|
||||
#define FILE struct _iobuf
|
||||
#define FILENAME_MAX 256
|
||||
#define FOPEN_MAX 100
|
||||
|
||||
#if !defined(_FPOS_T) && !defined(_FPOS_T_)
|
||||
#define _FPOS_T
|
||||
#define _FPOS_T_
|
||||
typedef long fpos_t;
|
||||
#endif
|
||||
|
||||
#define L_tmpnam 25
|
||||
#define NULL 0
|
||||
#define SEEK_CUR 1
|
||||
#define SEEK_END 2
|
||||
#define SEEK_SET 0
|
||||
|
||||
#if !defined(_SIZE_T) && !defined(_SIZE_T_)
|
||||
#define _SIZE_T
|
||||
#define _SIZE_T_
|
||||
typedef unsigned long size_t;
|
||||
#endif
|
||||
|
||||
#if !defined(_VA_LIST)
|
||||
#define _VA_LIST
|
||||
typedef char *__va_list;
|
||||
#endif
|
||||
|
||||
#define stderr (&_iob[2])
|
||||
#define stdin (&_iob[0])
|
||||
#define stdout (&_iob[1])
|
||||
#define TMP_MAX 17576
|
||||
|
||||
extern int remove(const char *);
|
||||
extern int rename(const char *, const char *);
|
||||
extern FILE *tmpfile(void);
|
||||
extern char *tmpnam(char *);
|
||||
extern int fclose(FILE *);
|
||||
extern int fflush(FILE *);
|
||||
extern FILE *fopen(const char *, const char *);
|
||||
extern FILE *freopen(const char *, const char *, FILE *);
|
||||
extern void setbuf(FILE *, char *);
|
||||
extern int setvbuf(FILE *, char *, int, size_t);
|
||||
extern int fprintf(FILE *, const char *, ...);
|
||||
extern int fscanf(FILE *, const char *, ...);
|
||||
extern int printf(const char *, ...);
|
||||
extern int scanf(const char *, ...);
|
||||
extern int sprintf(char *, const char *, ...);
|
||||
extern int sscanf(const char *, const char *, ...);
|
||||
extern int vfprintf(FILE *, const char *, __va_list);
|
||||
extern int vprintf(const char *, __va_list);
|
||||
extern int vsprintf(char *, const char *, __va_list);
|
||||
extern int fgetc(FILE *);
|
||||
extern char *fgets(char *, int, FILE *);
|
||||
extern int fputc(int, FILE *);
|
||||
extern int fputs(const char *, FILE *);
|
||||
extern int getc(FILE *);
|
||||
extern int getchar(void);
|
||||
extern char *gets(char *);
|
||||
extern int putc(int, FILE *);
|
||||
extern int putchar(int);
|
||||
extern int puts(const char *);
|
||||
extern int ungetc(int, FILE *);
|
||||
extern size_t fread(void *, size_t, size_t, FILE *);
|
||||
extern size_t fwrite(const void *, size_t, size_t, FILE *);
|
||||
extern int fgetpos(FILE *, fpos_t *);
|
||||
extern int fseek(FILE *, long int, int);
|
||||
extern int fsetpos(FILE *, const fpos_t *);
|
||||
extern long int ftell(FILE *);
|
||||
extern void rewind(FILE *);
|
||||
extern void clearerr(FILE *);
|
||||
extern int feof(FILE *);
|
||||
extern int ferror(FILE *);
|
||||
extern void perror(const char *);
|
||||
|
||||
#define _IOEOF 020
|
||||
#define _IOERR 040
|
||||
|
||||
#define getc(p) (--(p)->_cnt < 0 ? _filbuf(p) : (int) *(p)->_ptr++)
|
||||
#define putc(x, p) (--(p)->_cnt < 0 ? _flsbuf((unsigned char) (x), p) : (int) (*(p)->_ptr++ = (unsigned char) (x)))
|
||||
extern int _filbuf(FILE *), _flsbuf(unsigned, FILE *);
|
||||
#define feof(p) ((p)->_flag&_IOEOF)
|
||||
#define ferror(p) ((p)->_flag&_IOERR)
|
||||
#define clearerr(p) ((p)->_flag &= ~(_IOERR|_IOEOF))
|
||||
#define getchar() getc(stdin)
|
||||
#define putchar(x) putc((x),stdout)
|
||||
|
||||
#endif /* __STDIO */
|
|
@ -1,54 +0,0 @@
|
|||
#ifndef __STDLIB
|
||||
#define __STDLIB
|
||||
|
||||
#define EXIT_FAILURE 1
|
||||
#define EXIT_SUCCESS 0
|
||||
#define MB_CUR_MAX 1
|
||||
#define NULL 0
|
||||
#define RAND_MAX 32767
|
||||
|
||||
typedef struct { int quot, rem; } div_t;
|
||||
typedef struct { long quot, rem; } ldiv_t;
|
||||
|
||||
#if !defined(_SIZE_T) && !defined(_SIZE_T_)
|
||||
#define _SIZE_T
|
||||
#define _SIZE_T_
|
||||
typedef unsigned long size_t;
|
||||
#endif
|
||||
|
||||
#if !defined(_WCHAR_T) && !defined(_WCHAR_T_)
|
||||
#define _WCHAR_T
|
||||
#define _WCHAR_T_
|
||||
typedef unsigned char wchar_t;
|
||||
#endif
|
||||
|
||||
extern double atof(const char *);
|
||||
extern int atoi(const char *);
|
||||
extern long int atol(const char *);
|
||||
extern double strtod(const char *, char **);
|
||||
extern long int strtol(const char *, char **, int);
|
||||
extern unsigned long int strtoul(const char *, char **, int);
|
||||
extern int rand(void);
|
||||
extern void srand(unsigned int);
|
||||
extern void *calloc(size_t, size_t);
|
||||
extern void free(void *);
|
||||
extern void *malloc(size_t);
|
||||
extern void *realloc(void *, size_t);
|
||||
extern void abort(void);
|
||||
extern int atexit(void (*)(void));
|
||||
extern void exit(int);
|
||||
extern char *getenv(const char *);
|
||||
extern int system(const char *);
|
||||
extern void *bsearch(const void *, const void *, size_t, size_t, int (*)(const void *, const void *));
|
||||
extern void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
|
||||
extern int abs(int);
|
||||
extern div_t div(int, int);
|
||||
extern long int labs(long int);
|
||||
extern ldiv_t ldiv(long int, long int);
|
||||
extern int mblen(const char *, size_t);
|
||||
extern int mbtowc(wchar_t *, const char *, size_t);
|
||||
extern int wctomb(char *, wchar_t);
|
||||
extern size_t mbstowcs(wchar_t *, const char *, size_t);
|
||||
extern size_t wcstombs(char *, const wchar_t *, size_t);
|
||||
|
||||
#endif /* __STDLIB */
|
|
@ -1,35 +0,0 @@
|
|||
#ifndef __STRING
|
||||
#define __STRING
|
||||
|
||||
#define NULL 0
|
||||
|
||||
#if !defined(_SIZE_T) && !defined(_SIZE_T_)
|
||||
#define _SIZE_T
|
||||
#define _SIZE_T_
|
||||
typedef unsigned long size_t;
|
||||
#endif
|
||||
|
||||
void *memcpy(void *, const void *, size_t);
|
||||
void *memmove(void *, const void *, size_t);
|
||||
char *strcpy(char *, const char *);
|
||||
char *strncpy(char *, const char *, size_t);
|
||||
char *strcat(char *, const char *);
|
||||
char *strncat(char *, const char *, size_t);
|
||||
int memcmp(const void *, const void *, size_t);
|
||||
int strcmp(const char *, const char *);
|
||||
int strcoll(const char *, const char *);
|
||||
int strncmp(const char *, const char *, size_t);
|
||||
size_t strxfrm(char *, const char *, size_t);
|
||||
void *memchr(const void *, int, size_t);
|
||||
char *strchr(const char *, int);
|
||||
size_t strcspn(const char *, const char *);
|
||||
char *strpbrk(const char *, const char *);
|
||||
char *strrchr(const char *, int);
|
||||
size_t strspn(const char *, const char *);
|
||||
char *strstr(const char *, const char *);
|
||||
char *strtok(char *, const char *);
|
||||
void *memset(void *, int, size_t);
|
||||
char *strerror(int);
|
||||
size_t strlen(const char *);
|
||||
|
||||
#endif /* __STRING */
|
|
@ -1,48 +0,0 @@
|
|||
#ifndef __TIME
|
||||
#define __TIME
|
||||
|
||||
#define CLOCKS_PER_SEC 1000000
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#if !defined(_CLOCK_T) && !defined(_CLOCK_T_)
|
||||
#define _CLOCK_T
|
||||
#define _CLOCK_T_
|
||||
typedef long clock_t;
|
||||
#endif
|
||||
|
||||
#if !defined(_TIME_T) && !defined(_TIME_T_)
|
||||
#define _TIME_T
|
||||
#define _TIME_T_
|
||||
typedef long time_t;
|
||||
#endif
|
||||
|
||||
#if !defined(_SIZE_T) && !defined(_SIZE_T_)
|
||||
#define _SIZE_T
|
||||
#define _SIZE_T_
|
||||
typedef unsigned long size_t;
|
||||
#endif
|
||||
|
||||
struct tm {
|
||||
int tm_sec;
|
||||
int tm_min;
|
||||
int tm_hour;
|
||||
int tm_mday;
|
||||
int tm_mon;
|
||||
int tm_year;
|
||||
int tm_wday;
|
||||
int tm_yday;
|
||||
int tm_isdst;
|
||||
};
|
||||
extern clock_t clock(void);
|
||||
extern double difftime(time_t, time_t);
|
||||
extern time_t mktime(struct tm *);
|
||||
extern time_t time(time_t *);
|
||||
extern char *asctime(const struct tm *);
|
||||
extern char *ctime(const time_t *);
|
||||
extern struct tm *gmtime(const time_t *);
|
||||
extern struct tm *localtime(const time_t *);
|
||||
extern size_t strftime(char *, size_t, const char *, const struct tm *);
|
||||
|
||||
#endif /* __TIME */
|
|
@ -1,14 +0,0 @@
|
|||
#ifndef __ASSERT
|
||||
#define __ASSERT
|
||||
|
||||
void assert(int);
|
||||
|
||||
#endif /* __ASSERT */
|
||||
|
||||
#undef assert
|
||||
#ifdef NDEBUG
|
||||
#define assert(ignore) ((void)0)
|
||||
#else
|
||||
extern void __assert(char *, char *, unsigned);
|
||||
#define assert(e) ((void)((e)||(__assert(#e, __FILE__, __LINE__),0)))
|
||||
#endif /* NDEBUG */
|
|
@ -1,46 +0,0 @@
|
|||
#ifndef __CTYPE
|
||||
#define __CTYPE
|
||||
|
||||
extern int isalnum(int);
|
||||
extern int isalpha(int);
|
||||
extern int iscntrl(int);
|
||||
extern int isdigit(int);
|
||||
extern int isgraph(int);
|
||||
extern int islower(int);
|
||||
extern int isprint(int);
|
||||
extern int ispunct(int);
|
||||
extern int isspace(int);
|
||||
extern int isupper(int);
|
||||
extern int isxdigit(int);
|
||||
extern int tolower(int);
|
||||
extern int toupper(int);
|
||||
|
||||
#define __U 01
|
||||
#define __L 02
|
||||
#define __N 04
|
||||
#define __S 010
|
||||
#define __P 020
|
||||
#define __C 040
|
||||
#define _U 01
|
||||
#define _L 02
|
||||
#define _N 04
|
||||
#define _S 010
|
||||
#define _P 020
|
||||
#define _C 040
|
||||
#define _B 0100
|
||||
#define _X 0200
|
||||
|
||||
extern unsigned char __ctype[];
|
||||
#define isalpha(c) ((__ctype + 1)[c] & (_U | _L))
|
||||
#define isupper(c) ((__ctype + 1)[c] & _U)
|
||||
#define islower(c) ((__ctype + 1)[c] & _L)
|
||||
#define isdigit(c) ((__ctype + 1)[c] & _N)
|
||||
#define isxdigit(c) ((__ctype + 1)[c] & _X)
|
||||
#define isalnum(c) ((__ctype + 1)[c] & (_U | _L | _N))
|
||||
#define isspace(c) ((__ctype + 1)[c] & _S)
|
||||
#define ispunct(c) ((__ctype + 1)[c] & _P)
|
||||
#define isprint(c) ((__ctype + 1)[c] & (_P | _U | _L | _N | _B))
|
||||
#define isgraph(c) ((__ctype + 1)[c] & (_P | _U | _L | _N))
|
||||
#define iscntrl(c) ((__ctype + 1)[c] & _C)
|
||||
|
||||
#endif /* __CTYPE */
|
|
@ -1,8 +0,0 @@
|
|||
#ifndef __ERRNO
|
||||
#define __ERRNO
|
||||
|
||||
#define EDOM 33
|
||||
#define ERANGE 34
|
||||
extern int errno;
|
||||
|
||||
#endif /* __ERRNO */
|
|
@ -1,37 +0,0 @@
|
|||
#ifndef __FLOAT
|
||||
#define __FLOAT
|
||||
|
||||
#define FLT_ROUNDS 1
|
||||
#define FLT_RADIX 2
|
||||
|
||||
#define FLT_DIG 6
|
||||
#define FLT_EPSILON 1.19209289550781250000e-07
|
||||
#define FLT_MANT_DIG 24
|
||||
#define FLT_MAX 3.40282346638528860000e+38
|
||||
#define FLT_MAX_10_EXP 38
|
||||
#define FLT_MAX_EXP 128
|
||||
#define FLT_MIN 1.17549435082228750000e-38
|
||||
#define FLT_MIN_10_EXP -37
|
||||
#define FLT_MIN_EXP -125
|
||||
|
||||
#define DBL_DIG 15
|
||||
#define DBL_EPSILON 2.22044604925031310000e-16
|
||||
#define DBL_MANT_DIG 53
|
||||
#define DBL_MAX 1.79769313486231570000e+308
|
||||
#define DBL_MAX_10_EXP 308
|
||||
#define DBL_MAX_EXP 1024
|
||||
#define DBL_MIN 2.22507385850720140000e-308
|
||||
#define DBL_MIN_10_EXP -307
|
||||
#define DBL_MIN_EXP -1021
|
||||
|
||||
#define LDBL_MANT_DIG DBL_MANT_DIG
|
||||
#define LDBL_EPSILON DBL_EPSILON
|
||||
#define LDBL_DIG DBL_DIG
|
||||
#define LDBL_MIN_EXP DBL_MIN_EXP
|
||||
#define LDBL_MIN DBL_MIN
|
||||
#define LDBL_MIN_10_EXP DBL_MIN_10_EXP
|
||||
#define LDBL_MAX_EXP DBL_MAX_EXP
|
||||
#define LDBL_MAX DBL_MAX
|
||||
#define LDBL_MAX_10_EXP DBL_MAX_10_EXP
|
||||
|
||||
#endif /* __FLOAT */
|
|
@ -1,24 +0,0 @@
|
|||
#ifndef __LIMITS
|
||||
#define __LIMITS
|
||||
|
||||
#define CHAR_BIT 8
|
||||
#define MB_LEN_MAX 1
|
||||
|
||||
#define UCHAR_MAX 0xff
|
||||
#define USHRT_MAX 0xffff
|
||||
#define UINT_MAX (~0U)
|
||||
#define ULONG_MAX (~0UL)
|
||||
|
||||
#define CHAR_MAX SCHAR_MAX
|
||||
#define SCHAR_MAX 0x7f
|
||||
#define SHRT_MAX 0x7fff
|
||||
#define INT_MAX 0x7fffffff
|
||||
#define LONG_MAX 0x7fffffffL
|
||||
|
||||
#define CHAR_MIN SCHAR_MIN
|
||||
#define SCHAR_MIN (-SCHAR_MAX-1)
|
||||
#define SHRT_MIN (-SHRT_MAX-1)
|
||||
#define INT_MIN (-INT_MAX-1)
|
||||
#define LONG_MIN (-LONG_MAX-1)
|
||||
|
||||
#endif /* __LIMITS */
|
|
@ -1,36 +0,0 @@
|
|||
#ifndef __LOCALE
|
||||
#define __LOCALE
|
||||
|
||||
#define LC_ALL 0
|
||||
#define LC_COLLATE 1
|
||||
#define LC_CTYPE 2
|
||||
#define LC_MONETARY 3
|
||||
#define LC_NUMERIC 4
|
||||
#define LC_TIME 5
|
||||
#define NULL 0
|
||||
|
||||
struct lconv {
|
||||
char *decimal_point;
|
||||
char *thousands_sep;
|
||||
char *grouping;
|
||||
char *int_curr_symbol;
|
||||
char *currency_symbol;
|
||||
char *mon_decimal_point;
|
||||
char *mon_thousands_sep;
|
||||
char *mon_grouping;
|
||||
char *positive_sign;
|
||||
char *negative_sign;
|
||||
char int_frac_digits;
|
||||
char frac_digits;
|
||||
char p_cs_precedes;
|
||||
char p_sep_by_space;
|
||||
char n_cs_precedes;
|
||||
char n_sep_by_space;
|
||||
char p_sign_posn;
|
||||
char n_sign_posn;
|
||||
};
|
||||
|
||||
char *setlocale(int, const char *);
|
||||
struct lconv *localeconv(void);
|
||||
|
||||
#endif /* __LOCALE */
|
|
@ -1,30 +0,0 @@
|
|||
#ifndef __MATH
|
||||
#define __MATH
|
||||
|
||||
extern double infinity(void);
|
||||
#define HUGE_VAL (infinity())
|
||||
|
||||
extern double acos(double);
|
||||
extern double asin(double);
|
||||
extern double atan(double);
|
||||
extern double atan2(double, double);
|
||||
extern double cos(double);
|
||||
extern double sin(double);
|
||||
extern double tan(double);
|
||||
extern double cosh(double);
|
||||
extern double sinh(double);
|
||||
extern double tanh(double);
|
||||
extern double exp(double);
|
||||
extern double frexp(double, int *);
|
||||
extern double ldexp(double, int);
|
||||
extern double log(double);
|
||||
extern double log10(double);
|
||||
extern double modf(double, double *);
|
||||
extern double pow(double, double);
|
||||
extern double sqrt(double);
|
||||
extern double ceil(double);
|
||||
extern double fabs(double);
|
||||
extern double floor(double);
|
||||
extern double fmod(double, double);
|
||||
|
||||
#endif /* __MATH */
|
|
@ -1,10 +0,0 @@
|
|||
#ifndef __SETJMP
|
||||
#define __SETJMP
|
||||
|
||||
|
||||
|
||||
typedef int jmp_buf[12];
|
||||
int setjmp(jmp_buf);
|
||||
void longjmp(jmp_buf, int);
|
||||
|
||||
#endif /* __SETJMP */
|
|
@ -1,20 +0,0 @@
|
|||
#ifndef __SIGNAL
|
||||
#define __SIGNAL
|
||||
|
||||
typedef int sig_atomic_t;
|
||||
|
||||
#define SIG_DFL ((void (*)(int))0)
|
||||
#define SIG_ERR ((void (*)(int))-1)
|
||||
#define SIG_IGN ((void (*)(int))1)
|
||||
|
||||
#define SIGABRT 6
|
||||
#define SIGFPE 8
|
||||
#define SIGILL 4
|
||||
#define SIGINT 2
|
||||
#define SIGSEGV 11
|
||||
#define SIGTERM 15
|
||||
|
||||
void (*signal(int, void (*)(int)))(int);
|
||||
int raise(int);
|
||||
|
||||
#endif /* __SIGNAL */
|
|
@ -1,22 +0,0 @@
|
|||
#ifndef __STDARG
|
||||
#define __STDARG
|
||||
|
||||
#if !defined(_VA_LIST)
|
||||
#define _VA_LIST
|
||||
typedef char *__va_list;
|
||||
#endif
|
||||
typedef __va_list va_list;
|
||||
|
||||
#define va_start(list, start) ((void)((list) = (sizeof(start)<4 ? \
|
||||
(char *)((int *)&(start)+1) : (char *)(&(start)+1))))
|
||||
#define __va_arg(list, mode, n) \
|
||||
(*(mode *)(&(list += ((sizeof(mode)+n)&~n))[-(int)((sizeof(mode)+n)&~n)]))
|
||||
#define _bigendian_va_arg(list, mode, n) (\
|
||||
sizeof(mode)==1 ? *(mode *)(&(list += 4)[-1]) : \
|
||||
sizeof(mode)==2 ? *(mode *)(&(list += 4)[-2]) : __va_arg(list, mode, n))
|
||||
#define _littleendian_va_arg(list, mode, n) __va_arg(list, mode, n)
|
||||
#define va_end(list) ((void)0)
|
||||
#define va_arg(list, mode) (sizeof(mode)>8 ? \
|
||||
**(mode **)(&(list += 4)[-4]) : \
|
||||
_bigendian_va_arg(list, mode, 3U))
|
||||
#endif
|
|
@ -1,22 +0,0 @@
|
|||
#ifndef __STDDEF
|
||||
#define __STDDEF
|
||||
|
||||
|
||||
#define NULL 0
|
||||
#define offsetof(ty,mem) ((size_t)((char*)&((ty*)0)->mem - (char*)0))
|
||||
|
||||
typedef long ptrdiff_t;
|
||||
|
||||
#if !defined(_SIZE_T) && !defined(_SIZE_T_)
|
||||
#define _SIZE_T
|
||||
#define _SIZE_T_
|
||||
typedef unsigned long size_t;
|
||||
#endif
|
||||
|
||||
#if !defined(_WCHAR_T) && !defined(_WCHAR_T_)
|
||||
#define _WCHAR_T
|
||||
#define _WCHAR_T_
|
||||
typedef unsigned short wchar_t;
|
||||
#endif
|
||||
|
||||
#endif /* __STDDEF */
|
|
@ -1,104 +0,0 @@
|
|||
#ifndef __STDIO
|
||||
#define __STDIO
|
||||
|
||||
#define _IOFBF 0
|
||||
#define _IOLBF 0100
|
||||
#define _IONBF 04
|
||||
#define BUFSIZ 1024
|
||||
#define EOF (-1)
|
||||
|
||||
typedef struct {
|
||||
int _cnt;
|
||||
unsigned char *_ptr;
|
||||
unsigned char *_base;
|
||||
unsigned char _flag;
|
||||
unsigned char _file;
|
||||
} FILE;
|
||||
extern FILE __iob[];
|
||||
#define FILENAME_MAX 1024
|
||||
#define FOPEN_MAX 20
|
||||
|
||||
#if !defined(_FPOS_T) && !defined(_FPOS_T_)
|
||||
#define _FPOS_T
|
||||
#define _FPOS_T_
|
||||
typedef long fpos_t;
|
||||
#endif
|
||||
|
||||
#define L_tmpnam 25
|
||||
#define NULL 0
|
||||
#define SEEK_CUR 1
|
||||
#define SEEK_END 2
|
||||
#define SEEK_SET 0
|
||||
|
||||
#if !defined(_SIZE_T) && !defined(_SIZE_T_)
|
||||
#define _SIZE_T
|
||||
#define _SIZE_T_
|
||||
typedef unsigned long size_t;
|
||||
#endif
|
||||
|
||||
#if !defined(_VA_LIST)
|
||||
#define _VA_LIST
|
||||
typedef char *__va_list;
|
||||
#endif
|
||||
|
||||
#define stderr (&__iob[2])
|
||||
#define stdin (&__iob[0])
|
||||
#define stdout (&__iob[1])
|
||||
#define TMP_MAX 17576
|
||||
|
||||
extern int remove(const char *);
|
||||
extern int rename(const char *, const char *);
|
||||
extern FILE *tmpfile(void);
|
||||
extern char *tmpnam(char *);
|
||||
extern int fclose(FILE *);
|
||||
extern int fflush(FILE *);
|
||||
extern FILE *fopen(const char *, const char *);
|
||||
extern FILE *freopen(const char *, const char *, FILE *);
|
||||
extern void setbuf(FILE *, char *);
|
||||
extern int setvbuf(FILE *, char *, int, size_t);
|
||||
extern int fprintf(FILE *, const char *, ...);
|
||||
extern int fscanf(FILE *, const char *, ...);
|
||||
extern int printf(const char *, ...);
|
||||
extern int scanf(const char *, ...);
|
||||
extern int sprintf(char *, const char *, ...);
|
||||
extern int sscanf(const char *, const char *, ...);
|
||||
extern int vfprintf(FILE *, const char *, __va_list);
|
||||
extern int vprintf(const char *, __va_list);
|
||||
extern int vsprintf(char *, const char *, __va_list);
|
||||
extern int fgetc(FILE *);
|
||||
extern char *fgets(char *, int, FILE *);
|
||||
extern int fputc(int, FILE *);
|
||||
extern int fputs(const char *, FILE *);
|
||||
extern int getc(FILE *);
|
||||
extern int getchar(void);
|
||||
extern char *gets(char *);
|
||||
extern int putc(int, FILE *);
|
||||
extern int putchar(int);
|
||||
extern int puts(const char *);
|
||||
extern int ungetc(int, FILE *);
|
||||
extern size_t fread(void *, size_t, size_t, FILE *);
|
||||
extern size_t fwrite(const void *, size_t, size_t, FILE *);
|
||||
extern int fgetpos(FILE *, fpos_t *);
|
||||
extern int fseek(FILE *, long int, int);
|
||||
extern int fsetpos(FILE *, const fpos_t *);
|
||||
extern long int ftell(FILE *);
|
||||
extern void rewind(FILE *);
|
||||
extern void clearerr(FILE *);
|
||||
extern int feof(FILE *);
|
||||
extern int ferror(FILE *);
|
||||
extern void perror(const char *);
|
||||
|
||||
#define _IOEOF 020
|
||||
#define _IOERR 040
|
||||
|
||||
#define getc(p) (--(p)->_cnt < 0 ? __filbuf(p) : (int)*(p)->_ptr++)
|
||||
#define putc(x, p) (--(p)->_cnt < 0 ? __flsbuf((unsigned char) (x), (p)) \
|
||||
: (int)(*(p)->_ptr++ = (x)))
|
||||
extern int __filbuf(FILE *), __flsbuf(unsigned, FILE *);
|
||||
#define feof(p) ((p)->_flag&_IOEOF)
|
||||
#define ferror(p) ((p)->_flag&_IOERR)
|
||||
#define clearerr(p) ((p)->_flag &= ~(_IOERR|_IOEOF))
|
||||
#define getchar() getc(stdin)
|
||||
#define putchar(x) putc((x),stdout)
|
||||
|
||||
#endif /* __STDIO */
|
|
@ -1,54 +0,0 @@
|
|||
#ifndef __STDLIB
|
||||
#define __STDLIB
|
||||
|
||||
#define EXIT_FAILURE 1
|
||||
#define EXIT_SUCCESS 0
|
||||
#define MB_CUR_MAX 1
|
||||
#define NULL 0
|
||||
#define RAND_MAX 32767
|
||||
|
||||
typedef struct { int quot, rem; } div_t;
|
||||
typedef struct { long quot, rem; } ldiv_t;
|
||||
|
||||
#if !defined(_SIZE_T) && !defined(_SIZE_T_)
|
||||
#define _SIZE_T
|
||||
#define _SIZE_T_
|
||||
typedef unsigned long size_t;
|
||||
#endif
|
||||
|
||||
#if !defined(_WCHAR_T) && !defined(_WCHAR_T_)
|
||||
#define _WCHAR_T
|
||||
#define _WCHAR_T_
|
||||
typedef unsigned char wchar_t;
|
||||
#endif
|
||||
|
||||
extern double atof(const char *);
|
||||
extern int atoi(const char *);
|
||||
extern long int atol(const char *);
|
||||
extern double strtod(const char *, char **);
|
||||
extern long int strtol(const char *, char **, int);
|
||||
extern unsigned long int strtoul(const char *, char **, int);
|
||||
extern int rand(void);
|
||||
extern void srand(unsigned int);
|
||||
extern void *calloc(size_t, size_t);
|
||||
extern void free(void *);
|
||||
extern void *malloc(size_t);
|
||||
extern void *realloc(void *, size_t);
|
||||
extern void abort(void);
|
||||
extern int atexit(void (*)(void));
|
||||
extern void exit(int);
|
||||
extern char *getenv(const char *);
|
||||
extern int system(const char *);
|
||||
extern void *bsearch(const void *, const void *, size_t, size_t, int (*)(const void *, const void *));
|
||||
extern void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
|
||||
extern int abs(int);
|
||||
extern div_t div(int, int);
|
||||
extern long int labs(long int);
|
||||
extern ldiv_t ldiv(long int, long int);
|
||||
extern int mblen(const char *, size_t);
|
||||
extern int mbtowc(wchar_t *, const char *, size_t);
|
||||
extern int wctomb(char *, wchar_t);
|
||||
extern size_t mbstowcs(wchar_t *, const char *, size_t);
|
||||
extern size_t wcstombs(char *, const wchar_t *, size_t);
|
||||
|
||||
#endif /* __STDLIB */
|
|
@ -1,35 +0,0 @@
|
|||
#ifndef __STRING
|
||||
#define __STRING
|
||||
|
||||
#define NULL 0
|
||||
|
||||
#if !defined(_SIZE_T) && !defined(_SIZE_T_)
|
||||
#define _SIZE_T
|
||||
#define _SIZE_T_
|
||||
typedef unsigned long size_t;
|
||||
#endif
|
||||
|
||||
void *memcpy(void *, const void *, size_t);
|
||||
void *memmove(void *, const void *, size_t);
|
||||
char *strcpy(char *, const char *);
|
||||
char *strncpy(char *, const char *, size_t);
|
||||
char *strcat(char *, const char *);
|
||||
char *strncat(char *, const char *, size_t);
|
||||
int memcmp(const void *, const void *, size_t);
|
||||
int strcmp(const char *, const char *);
|
||||
int strcoll(const char *, const char *);
|
||||
int strncmp(const char *, const char *, size_t);
|
||||
size_t strxfrm(char *, const char *, size_t);
|
||||
void *memchr(const void *, int, size_t);
|
||||
char *strchr(const char *, int);
|
||||
size_t strcspn(const char *, const char *);
|
||||
char *strpbrk(const char *, const char *);
|
||||
char *strrchr(const char *, int);
|
||||
size_t strspn(const char *, const char *);
|
||||
char *strstr(const char *, const char *);
|
||||
char *strtok(char *, const char *);
|
||||
void *memset(void *, int, size_t);
|
||||
char *strerror(int);
|
||||
size_t strlen(const char *);
|
||||
|
||||
#endif /* __STRING */
|
|
@ -1,48 +0,0 @@
|
|||
#ifndef __TIME
|
||||
#define __TIME
|
||||
|
||||
#define CLOCKS_PER_SEC 1000000
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#if !defined(_CLOCK_T) && !defined(_CLOCK_T_)
|
||||
#define _CLOCK_T
|
||||
#define _CLOCK_T_
|
||||
typedef long clock_t;
|
||||
#endif
|
||||
|
||||
#if !defined(_TIME_T) && !defined(_TIME_T_)
|
||||
#define _TIME_T
|
||||
#define _TIME_T_
|
||||
typedef long time_t;
|
||||
#endif
|
||||
|
||||
#if !defined(_SIZE_T) && !defined(_SIZE_T_)
|
||||
#define _SIZE_T
|
||||
#define _SIZE_T_
|
||||
typedef unsigned long size_t;
|
||||
#endif
|
||||
|
||||
struct tm {
|
||||
int tm_sec;
|
||||
int tm_min;
|
||||
int tm_hour;
|
||||
int tm_mday;
|
||||
int tm_mon;
|
||||
int tm_year;
|
||||
int tm_wday;
|
||||
int tm_yday;
|
||||
int tm_isdst;
|
||||
};
|
||||
extern clock_t clock(void);
|
||||
extern double difftime(time_t, time_t);
|
||||
extern time_t mktime(struct tm *);
|
||||
extern time_t time(time_t *);
|
||||
extern char *asctime(const struct tm *);
|
||||
extern char *ctime(const time_t *);
|
||||
extern struct tm *gmtime(const time_t *);
|
||||
extern struct tm *localtime(const time_t *);
|
||||
extern size_t strftime(char *, size_t, const char *, const struct tm *);
|
||||
|
||||
#endif /* __TIME */
|
|
@ -1,14 +0,0 @@
|
|||
#ifndef __ASSERT
|
||||
#define __ASSERT
|
||||
|
||||
void assert(int);
|
||||
|
||||
#endif /* __ASSERT */
|
||||
|
||||
#undef assert
|
||||
#ifdef NDEBUG
|
||||
#define assert(ignore) ((void)0)
|
||||
#else
|
||||
extern int _assert(char *, char *, unsigned);
|
||||
#define assert(e) ((void)((e)||_assert(#e, __FILE__, __LINE__)))
|
||||
#endif /* NDEBUG */
|
|
@ -1,37 +0,0 @@
|
|||
#ifndef __FLOAT
|
||||
#define __FLOAT
|
||||
|
||||
#define FLT_ROUNDS (__flt_rounds())
|
||||
#define FLT_RADIX 2
|
||||
|
||||
#define FLT_DIG 6
|
||||
#define FLT_EPSILON 1.19209289550781250000e-07
|
||||
#define FLT_MANT_DIG 24
|
||||
#define FLT_MAX 3.40282346638528860000e+38
|
||||
#define FLT_MAX_10_EXP 38
|
||||
#define FLT_MAX_EXP 128
|
||||
#define FLT_MIN 1.17549435082228750000e-38
|
||||
#define FLT_MIN_10_EXP -37
|
||||
#define FLT_MIN_EXP -125
|
||||
|
||||
#define DBL_DIG 15
|
||||
#define DBL_EPSILON 2.22044604925031310000e-16
|
||||
#define DBL_MANT_DIG 53
|
||||
#define DBL_MAX 1.79769313486231570000e+308
|
||||
#define DBL_MAX_10_EXP 308
|
||||
#define DBL_MAX_EXP 1024
|
||||
#define DBL_MIN 2.22507385850720140000e-308
|
||||
#define DBL_MIN_10_EXP -307
|
||||
#define DBL_MIN_EXP -1021
|
||||
|
||||
#define LDBL_MANT_DIG DBL_MANT_DIG
|
||||
#define LDBL_EPSILON DBL_EPSILON
|
||||
#define LDBL_DIG DBL_DIG
|
||||
#define LDBL_MIN_EXP DBL_MIN_EXP
|
||||
#define LDBL_MIN DBL_MIN
|
||||
#define LDBL_MIN_10_EXP DBL_MIN_10_EXP
|
||||
#define LDBL_MAX_EXP DBL_MAX_EXP
|
||||
#define LDBL_MAX DBL_MAX
|
||||
#define LDBL_MAX_10_EXP DBL_MAX_10_EXP
|
||||
|
||||
#endif /* __FLOAT */
|
|
@ -1,21 +0,0 @@
|
|||
#ifndef __STDARG
|
||||
#define __STDARG
|
||||
|
||||
#if !defined(_VA_LIST)
|
||||
#define _VA_LIST
|
||||
typedef char *__va_list;
|
||||
#endif
|
||||
typedef __va_list va_list;
|
||||
|
||||
#define va_start(list, start) ((void)((list) = (sizeof(start)<4 ? \
|
||||
(char *)((int *)&(start)+1) : (char *)(&(start)+1))))
|
||||
#define __va_arg(list, mode, n) \
|
||||
(*(mode *)(&(list += ((sizeof(mode)+n)&~n))[-(int)((sizeof(mode)+n)&~n)]))
|
||||
#define _bigendian_va_arg(list, mode, n) (\
|
||||
sizeof(mode)==1 ? *(mode *)(&(list += 4)[-1]) : \
|
||||
sizeof(mode)==2 ? *(mode *)(&(list += 4)[-2]) : __va_arg(list, mode, n))
|
||||
#define _littleendian_va_arg(list, mode, n) __va_arg(list, mode, n)
|
||||
#define va_end(list) ((void)0)
|
||||
#define va_arg(list, mode) _littleendian_va_arg(list, mode, 3U)
|
||||
typedef void *__gnuc_va_list;
|
||||
#endif
|
|
@ -120,10 +120,8 @@ $(BD)dagcheck.c: $(BD)lburg$(E) src/dagcheck.md; $(BD)lburg src/dagcheck.md $@
|
|||
$(BD)q3rcc.h: src/rcc.asdl; $(ASDL_HOME)/bin/asdlGen --c -d $(BD) src/rcc.asdl
|
||||
$(BD)q3rcc$(O): $(BD)rcc.h; $(CC) $(LCC_CFLAGS) -c -Isrc -I$(BD) -I$(ASDL_HOME)/include/asdlGen -o $@ $(BD)rcc.c
|
||||
$(BD)asdl$(O): src/asdl.c $(BD)rcc.h src/c.h; $(CC) $(LCC_CFLAGS) -c -Isrc -I$(BD) -I$(ASDL_HOME)/include/asdlGen -o $@ src/asdl.c
|
||||
$(BD)pass2$(O): src/pass2.c $(BD)rcc.h src/c.h; $(CC) $(LCC_CFLAGS) -c -Isrc -I$(BD) -I$(ASDL_HOME)/include/asdlGen -o $@ src/pass2.c
|
||||
$(BD)2html$(O): src/2html.c $(BD)rcc.h src/c.h; $(CC) $(LCC_CFLAGS) -c -Isrc -I$(BD) -I$(ASDL_HOME)/include/asdlGen -o $@ src/2html.c
|
||||
|
||||
$(BD)pass2$(E): $(BD)pass2$(O) $(EXTRAOBJS) $(BD)librcc$(A); $(LD) $(LDFLAGS) -o $@ $(BD)pass2$(O) $(EXTRAOBJS) $(BD)librcc$(A) $(EXTRALIBS)
|
||||
$(BD)2html$(E): $(BD)2html$(O) $(BD)q3rcc$(O); $(LD) $(LDFLAGS) -o $@ $(BD)2html$(O) $(BD)q3rcc$(O) $(EXTRALIBS)
|
||||
|
||||
$(BD)bprint$(E): $(BD)bprint$(O); $(LD) $(LDFLAGS) -o $@ $(BD)bprint$(O)
|
||||
|
@ -188,7 +186,7 @@ clean::
|
|||
$(RM) -r $(BD)
|
||||
|
||||
clobber:: clean
|
||||
$(RM) $(BD)q3rcc$(E) $(BD)2html$(E) $(BD)pass2$(E) $(BD)lburg$(E) $(BD)q3cpp$(E) $(BD)q3lcc$(E) $(BD)bprint$(E) $(BD)*$(A)
|
||||
$(RM) $(BD)q3rcc$(E) $(BD)2html$(E) $(BD)lburg$(E) $(BD)q3cpp$(E) $(BD)q3lcc$(E) $(BD)bprint$(E) $(BD)*$(A)
|
||||
$(RM) $(BD)*.pdb $(BD)*.pch
|
||||
|
||||
RCCSRCS=src/alloc.c \
|
||||
|
@ -220,12 +218,7 @@ RCCSRCS=src/alloc.c \
|
|||
src/bytecode.c \
|
||||
src/gen.c \
|
||||
src/stab.c \
|
||||
$(BD)dagcheck.c \
|
||||
$(BD)alpha.c \
|
||||
$(BD)mips.c \
|
||||
$(BD)sparc.c \
|
||||
$(BD)x86linux.c \
|
||||
$(BD)x86.c
|
||||
$(BD)dagcheck.c
|
||||
|
||||
C=$(BD)q3lcc -A -d0.6 -Wo-lccdir=$(BUILDDIR) -Isrc -I$(BUILDDIR)
|
||||
triple: $(BD)q3rcc$(E) $(BD)q3lcc$(E) $(BD)q3cpp$(E)
|
||||
|
|
|
@ -1,432 +0,0 @@
|
|||
README
|
||||
CPYRIGHT
|
||||
LOG
|
||||
makefile
|
||||
makefile.nt
|
||||
src/2html.c
|
||||
src/alloc.c
|
||||
src/asdl.c
|
||||
src/bind.c
|
||||
src/bytecode.c
|
||||
src/c.h
|
||||
src/config.h
|
||||
src/dag.c
|
||||
src/decl.c
|
||||
src/enode.c
|
||||
src/error.c
|
||||
src/event.c
|
||||
src/expr.c
|
||||
src/gen.c
|
||||
src/init.c
|
||||
src/inits.c
|
||||
src/input.c
|
||||
src/lex.c
|
||||
src/list.c
|
||||
src/main.c
|
||||
src/null.c
|
||||
src/output.c
|
||||
src/pass2.c
|
||||
src/prof.c
|
||||
src/profio.c
|
||||
src/simp.c
|
||||
src/stab.c
|
||||
src/stab.h
|
||||
src/stmt.c
|
||||
src/string.c
|
||||
src/sym.c
|
||||
src/symbolic.c
|
||||
src/token.h
|
||||
src/trace.c
|
||||
src/tree.c
|
||||
src/types.c
|
||||
src/alpha.md
|
||||
src/dagcheck.md
|
||||
src/mips.md
|
||||
src/sparc.md
|
||||
src/x86.md
|
||||
src/x86linux.md
|
||||
src/run.sh
|
||||
src/rcc.asdl
|
||||
lib/assert.c
|
||||
lib/bbexit.c
|
||||
lib/yynull.c
|
||||
tst/8q.0
|
||||
tst/8q.c
|
||||
tst/array.0
|
||||
tst/array.c
|
||||
tst/cf.0
|
||||
tst/cf.c
|
||||
tst/cq.0
|
||||
tst/cq.c
|
||||
tst/cvt.0
|
||||
tst/cvt.c
|
||||
tst/fields.0
|
||||
tst/fields.c
|
||||
tst/front.0
|
||||
tst/front.c
|
||||
tst/incr.0
|
||||
tst/incr.c
|
||||
tst/init.0
|
||||
tst/init.c
|
||||
tst/limits.0
|
||||
tst/limits.c
|
||||
tst/paranoia.0
|
||||
tst/paranoia.c
|
||||
tst/sort.0
|
||||
tst/sort.c
|
||||
tst/spill.0
|
||||
tst/spill.c
|
||||
tst/stdarg.0
|
||||
tst/stdarg.c
|
||||
tst/struct.0
|
||||
tst/struct.c
|
||||
tst/switch.0
|
||||
tst/switch.c
|
||||
tst/wf1.0
|
||||
tst/wf1.c
|
||||
tst/yacc.0
|
||||
tst/yacc.c
|
||||
etc/bprint.c
|
||||
etc/gcc-solaris.c
|
||||
etc/irix.c
|
||||
etc/lcc.c
|
||||
etc/linux.c
|
||||
etc/ops.c
|
||||
etc/osf.c
|
||||
etc/solaris.c
|
||||
etc/win32.c
|
||||
cpp/cpp.c
|
||||
cpp/cpp.h
|
||||
cpp/eval.c
|
||||
cpp/getopt.c
|
||||
cpp/hideset.c
|
||||
cpp/include.c
|
||||
cpp/lex.c
|
||||
cpp/macro.c
|
||||
cpp/nlist.c
|
||||
cpp/tokens.c
|
||||
cpp/unix.c
|
||||
lburg/gram.c
|
||||
lburg/gram.y
|
||||
lburg/lburg.1
|
||||
lburg/lburg.c
|
||||
lburg/lburg.h
|
||||
include/alpha/osf/assert.h
|
||||
include/alpha/osf/ctype.h
|
||||
include/alpha/osf/errno.h
|
||||
include/alpha/osf/float.h
|
||||
include/alpha/osf/limits.h
|
||||
include/alpha/osf/locale.h
|
||||
include/alpha/osf/math.h
|
||||
include/alpha/osf/setjmp.h
|
||||
include/alpha/osf/signal.h
|
||||
include/alpha/osf/stdarg.h
|
||||
include/alpha/osf/stddef.h
|
||||
include/alpha/osf/stdio.h
|
||||
include/alpha/osf/stdlib.h
|
||||
include/alpha/osf/string.h
|
||||
include/alpha/osf/time.h
|
||||
include/sparc/solaris/assert.h
|
||||
include/sparc/solaris/ctype.h
|
||||
include/sparc/solaris/errno.h
|
||||
include/sparc/solaris/float.h
|
||||
include/sparc/solaris/limits.h
|
||||
include/sparc/solaris/locale.h
|
||||
include/sparc/solaris/math.h
|
||||
include/sparc/solaris/setjmp.h
|
||||
include/sparc/solaris/signal.h
|
||||
include/sparc/solaris/stdarg.h
|
||||
include/sparc/solaris/stddef.h
|
||||
include/sparc/solaris/stdio.h
|
||||
include/sparc/solaris/stdlib.h
|
||||
include/sparc/solaris/string.h
|
||||
include/sparc/solaris/time.h
|
||||
include/mips/irix/assert.h
|
||||
include/mips/irix/ctype.h
|
||||
include/mips/irix/errno.h
|
||||
include/mips/irix/float.h
|
||||
include/mips/irix/limits.h
|
||||
include/mips/irix/locale.h
|
||||
include/mips/irix/math.h
|
||||
include/mips/irix/setjmp.h
|
||||
include/mips/irix/signal.h
|
||||
include/mips/irix/stdarg.h
|
||||
include/mips/irix/stddef.h
|
||||
include/mips/irix/stdio.h
|
||||
include/mips/irix/stdlib.h
|
||||
include/mips/irix/string.h
|
||||
include/mips/irix/time.h
|
||||
include/x86/linux/assert.h
|
||||
include/x86/linux/float.h
|
||||
include/x86/linux/stdarg.h
|
||||
doc/4.html
|
||||
doc/install.html
|
||||
doc/bprint.1
|
||||
doc/lcc.1
|
||||
doc/bprint.pdf
|
||||
doc/lcc.pdf
|
||||
alpha/osf/tst/8q.1bk
|
||||
alpha/osf/tst/8q.2bk
|
||||
alpha/osf/tst/8q.sbk
|
||||
alpha/osf/tst/array.1bk
|
||||
alpha/osf/tst/array.2bk
|
||||
alpha/osf/tst/array.sbk
|
||||
alpha/osf/tst/cf.1bk
|
||||
alpha/osf/tst/cf.2bk
|
||||
alpha/osf/tst/cf.sbk
|
||||
alpha/osf/tst/cq.1bk
|
||||
alpha/osf/tst/cq.2bk
|
||||
alpha/osf/tst/cq.sbk
|
||||
alpha/osf/tst/cvt.1bk
|
||||
alpha/osf/tst/cvt.2bk
|
||||
alpha/osf/tst/cvt.sbk
|
||||
alpha/osf/tst/fields.1bk
|
||||
alpha/osf/tst/fields.2bk
|
||||
alpha/osf/tst/fields.sbk
|
||||
alpha/osf/tst/front.2bk
|
||||
alpha/osf/tst/front.sbk
|
||||
alpha/osf/tst/incr.1bk
|
||||
alpha/osf/tst/incr.2bk
|
||||
alpha/osf/tst/incr.sbk
|
||||
alpha/osf/tst/init.1bk
|
||||
alpha/osf/tst/init.2bk
|
||||
alpha/osf/tst/init.sbk
|
||||
alpha/osf/tst/limits.1bk
|
||||
alpha/osf/tst/limits.2bk
|
||||
alpha/osf/tst/limits.sbk
|
||||
alpha/osf/tst/paranoia.1bk
|
||||
alpha/osf/tst/paranoia.2bk
|
||||
alpha/osf/tst/paranoia.sbk
|
||||
alpha/osf/tst/sort.1bk
|
||||
alpha/osf/tst/sort.2bk
|
||||
alpha/osf/tst/sort.sbk
|
||||
alpha/osf/tst/spill.1bk
|
||||
alpha/osf/tst/spill.2bk
|
||||
alpha/osf/tst/spill.sbk
|
||||
alpha/osf/tst/stdarg.1bk
|
||||
alpha/osf/tst/stdarg.2bk
|
||||
alpha/osf/tst/stdarg.sbk
|
||||
alpha/osf/tst/struct.1bk
|
||||
alpha/osf/tst/struct.2bk
|
||||
alpha/osf/tst/struct.sbk
|
||||
alpha/osf/tst/switch.1bk
|
||||
alpha/osf/tst/switch.2bk
|
||||
alpha/osf/tst/switch.sbk
|
||||
alpha/osf/tst/wf1.1bk
|
||||
alpha/osf/tst/wf1.2bk
|
||||
alpha/osf/tst/wf1.sbk
|
||||
alpha/osf/tst/yacc.1bk
|
||||
alpha/osf/tst/yacc.2bk
|
||||
alpha/osf/tst/yacc.sbk
|
||||
sparc/solaris/tst/8q.1bk
|
||||
sparc/solaris/tst/8q.2bk
|
||||
sparc/solaris/tst/8q.sbk
|
||||
sparc/solaris/tst/array.1bk
|
||||
sparc/solaris/tst/array.2bk
|
||||
sparc/solaris/tst/array.sbk
|
||||
sparc/solaris/tst/cf.1bk
|
||||
sparc/solaris/tst/cf.2bk
|
||||
sparc/solaris/tst/cf.sbk
|
||||
sparc/solaris/tst/cq.1bk
|
||||
sparc/solaris/tst/cq.2bk
|
||||
sparc/solaris/tst/cq.sbk
|
||||
sparc/solaris/tst/cvt.1bk
|
||||
sparc/solaris/tst/cvt.2bk
|
||||
sparc/solaris/tst/cvt.sbk
|
||||
sparc/solaris/tst/fields.1bk
|
||||
sparc/solaris/tst/fields.2bk
|
||||
sparc/solaris/tst/fields.sbk
|
||||
sparc/solaris/tst/front.2bk
|
||||
sparc/solaris/tst/front.sbk
|
||||
sparc/solaris/tst/incr.1bk
|
||||
sparc/solaris/tst/incr.2bk
|
||||
sparc/solaris/tst/incr.sbk
|
||||
sparc/solaris/tst/init.1bk
|
||||
sparc/solaris/tst/init.2bk
|
||||
sparc/solaris/tst/init.sbk
|
||||
sparc/solaris/tst/limits.1bk
|
||||
sparc/solaris/tst/limits.2bk
|
||||
sparc/solaris/tst/limits.sbk
|
||||
sparc/solaris/tst/paranoia.1bk
|
||||
sparc/solaris/tst/paranoia.2bk
|
||||
sparc/solaris/tst/paranoia.sbk
|
||||
sparc/solaris/tst/sort.1bk
|
||||
sparc/solaris/tst/sort.2bk
|
||||
sparc/solaris/tst/sort.sbk
|
||||
sparc/solaris/tst/spill.1bk
|
||||
sparc/solaris/tst/spill.2bk
|
||||
sparc/solaris/tst/spill.sbk
|
||||
sparc/solaris/tst/stdarg.1bk
|
||||
sparc/solaris/tst/stdarg.2bk
|
||||
sparc/solaris/tst/stdarg.sbk
|
||||
sparc/solaris/tst/struct.1bk
|
||||
sparc/solaris/tst/struct.2bk
|
||||
sparc/solaris/tst/struct.sbk
|
||||
sparc/solaris/tst/switch.1bk
|
||||
sparc/solaris/tst/switch.2bk
|
||||
sparc/solaris/tst/switch.sbk
|
||||
sparc/solaris/tst/wf1.1bk
|
||||
sparc/solaris/tst/wf1.2bk
|
||||
sparc/solaris/tst/wf1.sbk
|
||||
sparc/solaris/tst/yacc.1bk
|
||||
sparc/solaris/tst/yacc.2bk
|
||||
sparc/solaris/tst/yacc.sbk
|
||||
mips/irix/tst/8q.1bk
|
||||
mips/irix/tst/8q.2bk
|
||||
mips/irix/tst/8q.sbk
|
||||
mips/irix/tst/array.1bk
|
||||
mips/irix/tst/array.2bk
|
||||
mips/irix/tst/array.sbk
|
||||
mips/irix/tst/cf.1bk
|
||||
mips/irix/tst/cf.2bk
|
||||
mips/irix/tst/cf.sbk
|
||||
mips/irix/tst/cq.1bk
|
||||
mips/irix/tst/cq.2bk
|
||||
mips/irix/tst/cq.sbk
|
||||
mips/irix/tst/cvt.1bk
|
||||
mips/irix/tst/cvt.2bk
|
||||
mips/irix/tst/cvt.sbk
|
||||
mips/irix/tst/fields.1bk
|
||||
mips/irix/tst/fields.2bk
|
||||
mips/irix/tst/fields.sbk
|
||||
mips/irix/tst/front.2bk
|
||||
mips/irix/tst/front.sbk
|
||||
mips/irix/tst/incr.2bk
|
||||
mips/irix/tst/incr.sbk
|
||||
mips/irix/tst/init.1bk
|
||||
mips/irix/tst/init.2bk
|
||||
mips/irix/tst/init.sbk
|
||||
mips/irix/tst/limits.1bk
|
||||
mips/irix/tst/limits.2bk
|
||||
mips/irix/tst/limits.sbk
|
||||
mips/irix/tst/paranoia.1bk
|
||||
mips/irix/tst/paranoia.2bk
|
||||
mips/irix/tst/paranoia.sbk
|
||||
mips/irix/tst/sort.1bk
|
||||
mips/irix/tst/sort.2bk
|
||||
mips/irix/tst/sort.sbk
|
||||
mips/irix/tst/spill.2bk
|
||||
mips/irix/tst/spill.sbk
|
||||
mips/irix/tst/stdarg.1bk
|
||||
mips/irix/tst/stdarg.2bk
|
||||
mips/irix/tst/stdarg.sbk
|
||||
mips/irix/tst/struct.1bk
|
||||
mips/irix/tst/struct.2bk
|
||||
mips/irix/tst/struct.sbk
|
||||
mips/irix/tst/switch.1bk
|
||||
mips/irix/tst/switch.2bk
|
||||
mips/irix/tst/switch.sbk
|
||||
mips/irix/tst/wf1.1bk
|
||||
mips/irix/tst/wf1.2bk
|
||||
mips/irix/tst/wf1.sbk
|
||||
mips/irix/tst/yacc.1bk
|
||||
mips/irix/tst/yacc.2bk
|
||||
mips/irix/tst/yacc.sbk
|
||||
x86/linux/tst/8q.1bk
|
||||
x86/linux/tst/8q.2bk
|
||||
x86/linux/tst/8q.sbk
|
||||
x86/linux/tst/array.1bk
|
||||
x86/linux/tst/array.2bk
|
||||
x86/linux/tst/array.sbk
|
||||
x86/linux/tst/cf.1bk
|
||||
x86/linux/tst/cf.2bk
|
||||
x86/linux/tst/cf.sbk
|
||||
x86/linux/tst/cq.1bk
|
||||
x86/linux/tst/cq.2bk
|
||||
x86/linux/tst/cq.sbk
|
||||
x86/linux/tst/cvt.1bk
|
||||
x86/linux/tst/cvt.2bk
|
||||
x86/linux/tst/cvt.sbk
|
||||
x86/linux/tst/fields.1bk
|
||||
x86/linux/tst/fields.2bk
|
||||
x86/linux/tst/fields.sbk
|
||||
x86/linux/tst/front.2bk
|
||||
x86/linux/tst/front.sbk
|
||||
x86/linux/tst/incr.1bk
|
||||
x86/linux/tst/incr.2bk
|
||||
x86/linux/tst/incr.sbk
|
||||
x86/linux/tst/init.1bk
|
||||
x86/linux/tst/init.2bk
|
||||
x86/linux/tst/init.sbk
|
||||
x86/linux/tst/limits.1bk
|
||||
x86/linux/tst/limits.2bk
|
||||
x86/linux/tst/limits.sbk
|
||||
x86/linux/tst/paranoia.1bk
|
||||
x86/linux/tst/paranoia.2bk
|
||||
x86/linux/tst/paranoia.sbk
|
||||
x86/linux/tst/sort.1bk
|
||||
x86/linux/tst/sort.2bk
|
||||
x86/linux/tst/sort.sbk
|
||||
x86/linux/tst/spill.1bk
|
||||
x86/linux/tst/spill.2bk
|
||||
x86/linux/tst/spill.sbk
|
||||
x86/linux/tst/stdarg.1bk
|
||||
x86/linux/tst/stdarg.2bk
|
||||
x86/linux/tst/stdarg.sbk
|
||||
x86/linux/tst/struct.1bk
|
||||
x86/linux/tst/struct.2bk
|
||||
x86/linux/tst/struct.sbk
|
||||
x86/linux/tst/switch.1bk
|
||||
x86/linux/tst/switch.2bk
|
||||
x86/linux/tst/switch.sbk
|
||||
x86/linux/tst/wf1.1bk
|
||||
x86/linux/tst/wf1.2bk
|
||||
x86/linux/tst/wf1.sbk
|
||||
x86/linux/tst/yacc.1bk
|
||||
x86/linux/tst/yacc.2bk
|
||||
x86/linux/tst/yacc.sbk
|
||||
x86/win32/tst/8q.1bk
|
||||
x86/win32/tst/8q.2bk
|
||||
x86/win32/tst/8q.sbk
|
||||
x86/win32/tst/array.1bk
|
||||
x86/win32/tst/array.2bk
|
||||
x86/win32/tst/array.sbk
|
||||
x86/win32/tst/cf.1bk
|
||||
x86/win32/tst/cf.2bk
|
||||
x86/win32/tst/cf.sbk
|
||||
x86/win32/tst/cq.1bk
|
||||
x86/win32/tst/cq.2bk
|
||||
x86/win32/tst/cq.sbk
|
||||
x86/win32/tst/cvt.1bk
|
||||
x86/win32/tst/cvt.2bk
|
||||
x86/win32/tst/cvt.sbk
|
||||
x86/win32/tst/fields.1bk
|
||||
x86/win32/tst/fields.2bk
|
||||
x86/win32/tst/fields.sbk
|
||||
x86/win32/tst/front.2bk
|
||||
x86/win32/tst/front.sbk
|
||||
x86/win32/tst/incr.1bk
|
||||
x86/win32/tst/incr.2bk
|
||||
x86/win32/tst/incr.sbk
|
||||
x86/win32/tst/init.1bk
|
||||
x86/win32/tst/init.2bk
|
||||
x86/win32/tst/init.sbk
|
||||
x86/win32/tst/limits.1bk
|
||||
x86/win32/tst/limits.2bk
|
||||
x86/win32/tst/limits.sbk
|
||||
x86/win32/tst/paranoia.1bk
|
||||
x86/win32/tst/paranoia.2bk
|
||||
x86/win32/tst/paranoia.sbk
|
||||
x86/win32/tst/sort.1bk
|
||||
x86/win32/tst/sort.2bk
|
||||
x86/win32/tst/sort.sbk
|
||||
x86/win32/tst/spill.1bk
|
||||
x86/win32/tst/spill.2bk
|
||||
x86/win32/tst/spill.sbk
|
||||
x86/win32/tst/stdarg.1bk
|
||||
x86/win32/tst/stdarg.2bk
|
||||
x86/win32/tst/stdarg.sbk
|
||||
x86/win32/tst/struct.1bk
|
||||
x86/win32/tst/struct.2bk
|
||||
x86/win32/tst/struct.sbk
|
||||
x86/win32/tst/switch.1bk
|
||||
x86/win32/tst/switch.2bk
|
||||
x86/win32/tst/switch.sbk
|
||||
x86/win32/tst/wf1.1bk
|
||||
x86/win32/tst/wf1.2bk
|
||||
x86/win32/tst/wf1.sbk
|
||||
x86/win32/tst/yacc.1bk
|
||||
x86/win32/tst/yacc.2bk
|
||||
x86/win32/tst/yacc.sbk
|
||||
custom.mk
|
||||
packing.lst
|
File diff suppressed because it is too large
Load diff
|
@ -1,22 +1,7 @@
|
|||
#include "c.h"
|
||||
extern Interface alphaIR;
|
||||
extern Interface mipsebIR, mipselIR;
|
||||
extern Interface sparcIR, solarisIR;
|
||||
extern Interface x86IR, x86linuxIR;
|
||||
extern Interface symbolicIR, symbolic64IR;
|
||||
extern Interface nullIR;
|
||||
extern Interface bytecodeIR;
|
||||
Binding bindings[] = {
|
||||
/*{ "alpha/osf", &alphaIR },*/
|
||||
/*{ "mips/irix", &mipsebIR },*/
|
||||
/*{ "mips/ultrix", &mipselIR },*/
|
||||
/*{ "sparc/sun", &sparcIR },*/
|
||||
/*{ "sparc/solaris", &solarisIR },*/
|
||||
/*{ "x86/win32", &x86IR },*/
|
||||
/*{ "x86/linux", &x86linuxIR },*/
|
||||
{ "symbolic/osf", &symbolic64IR },
|
||||
{ "symbolic/irix", &symbolicIR },
|
||||
{ "symbolic", &symbolicIR },
|
||||
{ "null", &nullIR },
|
||||
{ "bytecode", &bytecodeIR },
|
||||
{ NULL, NULL },
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,665 +0,0 @@
|
|||
#include "c.h"
|
||||
#include "rcc.h"
|
||||
#if WIN32
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
|
||||
Interface *IR = NULL;
|
||||
int Aflag; /* >= 0 if -A specified */
|
||||
int Pflag; /* != 0 if -P specified */
|
||||
int glevel; /* == [0-9] if -g[0-9] specified */
|
||||
int xref; /* != 0 for cross-reference data */
|
||||
Symbol YYnull; /* _YYnull symbol if -n or -nvalidate specified */
|
||||
Symbol YYcheck; /* _YYcheck symbol if -nvalidate,check specified */
|
||||
|
||||
static int verbose = 1;
|
||||
#define VERBOSE(n,arg) (verbose >= n ? (void)(arg):(void)0)
|
||||
static int nuids;
|
||||
static rcc_item_ty *items;
|
||||
static void **itemmap;
|
||||
|
||||
static void *uid2type(int uid) {
|
||||
assert(uid >= 0 && uid < nuids);
|
||||
if (itemmap[uid] == NULL) {
|
||||
Type ty;
|
||||
rcc_type_ty type = (void *)items[uid];
|
||||
assert(items[uid]);
|
||||
assert(items[uid]->uid == uid);
|
||||
assert(items[uid]->kind == rcc_Type_enum);
|
||||
type = items[uid]->v.rcc_Type.type;
|
||||
assert(type);
|
||||
switch (type->kind) {
|
||||
case rcc_INT_enum:
|
||||
ty = btot(INT, type->size);
|
||||
assert(ty->align == type->align);
|
||||
break;
|
||||
case rcc_UNSIGNED_enum:
|
||||
ty = btot(UNSIGNED, type->size);
|
||||
assert(ty->align == type->align);
|
||||
break;
|
||||
case rcc_FLOAT_enum:
|
||||
ty = btot(FLOAT, type->size);
|
||||
assert(ty->align == type->align);
|
||||
break;
|
||||
case rcc_VOID_enum:
|
||||
ty = voidtype;
|
||||
break;
|
||||
case rcc_POINTER_enum:
|
||||
ty = ptr(uid2type(type->v.rcc_POINTER.type));
|
||||
break;
|
||||
case rcc_ARRAY_enum:
|
||||
ty = uid2type(type->v.rcc_ARRAY.type);
|
||||
assert(ty->size > 0);
|
||||
ty = array(ty, type->size/ty->size, 0);
|
||||
break;
|
||||
case rcc_CONST_enum:
|
||||
ty = qual(CONST, uid2type(type->v.rcc_CONST.type));
|
||||
break;
|
||||
case rcc_VOLATILE_enum:
|
||||
ty = qual(VOLATILE, uid2type(type->v.rcc_VOLATILE.type));
|
||||
break;
|
||||
case rcc_ENUM_enum: {
|
||||
int i, n = Seq_length(type->v.rcc_ENUM.ids);
|
||||
ty = newstruct(ENUM, string(type->v.rcc_ENUM.tag));
|
||||
ty->type = inttype;
|
||||
ty->size = ty->type->size;
|
||||
ty->align = ty->type->align;
|
||||
ty->u.sym->u.idlist = newarray(n + 1, sizeof *ty->u.sym->u.idlist, PERM);
|
||||
for (i = 0; i < n; i++) {
|
||||
rcc_enum__ty e = Seq_remlo(type->v.rcc_ENUM.ids);
|
||||
Symbol p = install(e->id, &identifiers, GLOBAL, PERM);
|
||||
p->type = ty;
|
||||
p->sclass = ENUM;
|
||||
p->u.value = e->value;
|
||||
ty->u.sym->u.idlist[i] = p;
|
||||
free(e);
|
||||
}
|
||||
ty->u.sym->u.idlist[i] = NULL;
|
||||
Seq_free(&type->v.rcc_ENUM.ids);
|
||||
break;
|
||||
}
|
||||
case rcc_STRUCT_enum: case rcc_UNION_enum: {
|
||||
int i, n;
|
||||
Field *tail;
|
||||
list_ty fields;
|
||||
if (type->kind == rcc_STRUCT_enum) {
|
||||
ty = newstruct(STRUCT, string(type->v.rcc_STRUCT.tag));
|
||||
fields = type->v.rcc_STRUCT.fields;
|
||||
} else {
|
||||
ty = newstruct(UNION, string(type->v.rcc_UNION.tag));
|
||||
fields = type->v.rcc_UNION.fields;
|
||||
}
|
||||
itemmap[uid] = ty; /* recursive types */
|
||||
ty->size = type->size;
|
||||
ty->align = type->align;
|
||||
tail = &ty->u.sym->u.s.flist;
|
||||
n = Seq_length(fields);
|
||||
for (i = 0; i < n; i++) {
|
||||
rcc_field_ty field = Seq_remlo(fields);
|
||||
NEW0(*tail, PERM);
|
||||
(*tail)->name = (char *)field->id;
|
||||
(*tail)->type = uid2type(field->type);
|
||||
(*tail)->offset = field->offset;
|
||||
(*tail)->bitsize = field->bitsize;
|
||||
(*tail)->lsb = field->lsb;
|
||||
if (isconst((*tail)->type))
|
||||
ty->u.sym->u.s.cfields = 1;
|
||||
if (isvolatile((*tail)->type))
|
||||
ty->u.sym->u.s.vfields = 1;
|
||||
tail = &(*tail)->link;
|
||||
free(field);
|
||||
}
|
||||
Seq_free(&fields);
|
||||
break;
|
||||
}
|
||||
case rcc_FUNCTION_enum: {
|
||||
int n = Seq_length(type->v.rcc_FUNCTION.formals);
|
||||
if (n > 0) {
|
||||
int i;
|
||||
Type *proto = newarray(n + 1, sizeof *proto, PERM);
|
||||
for (i = 0; i < n; i++) {
|
||||
int *formal = Seq_remlo(type->v.rcc_FUNCTION.formals);
|
||||
proto[i] = uid2type(*formal);
|
||||
free(formal);
|
||||
}
|
||||
proto[i] = NULL;
|
||||
ty = func(uid2type(type->v.rcc_FUNCTION.type), proto, 0);
|
||||
} else
|
||||
ty = func(uid2type(type->v.rcc_FUNCTION.type), NULL, 1);
|
||||
Seq_free(&type->v.rcc_FUNCTION.formals);
|
||||
break;
|
||||
}
|
||||
default: assert(0);
|
||||
}
|
||||
if (itemmap[uid] == NULL) {
|
||||
itemmap[uid] = ty;
|
||||
free(type);
|
||||
free(items[uid]);
|
||||
items[uid] = NULL;
|
||||
} else
|
||||
assert(itemmap[uid] == ty);
|
||||
}
|
||||
return itemmap[uid];
|
||||
}
|
||||
|
||||
static Symbol uid2symbol(int uid) {
|
||||
assert(uid >= 0 && uid < nuids);
|
||||
if (itemmap[uid] == NULL) {
|
||||
Symbol p;
|
||||
rcc_symbol_ty symbol;
|
||||
assert(items[uid]);
|
||||
assert(items[uid]->uid == uid);
|
||||
assert(items[uid]->kind == rcc_Symbol_enum);
|
||||
symbol = items[uid]->v.rcc_Symbol.symbol;
|
||||
assert(symbol);
|
||||
NEW0(p, PERM);
|
||||
p->name = (char *)symbol->id;
|
||||
p->scope = symbol->scope;
|
||||
p->sclass = symbol->sclass;
|
||||
p->type = uid2type(symbol->type);
|
||||
#define xx(f,n) p->f = symbol->flags>>n;
|
||||
xx(structarg,0)
|
||||
xx(addressed,1)
|
||||
xx(computed,2)
|
||||
xx(temporary,3)
|
||||
xx(generated,4)
|
||||
#undef xx
|
||||
p->ref = symbol->ref/10000.0;
|
||||
assert(p->scope != CONSTANTS && p->scope != LABELS);
|
||||
if (p->scope == GLOBAL || p->sclass == STATIC || p->sclass == EXTERN)
|
||||
(*IR->defsymbol)(p);
|
||||
itemmap[uid] = p;
|
||||
free(symbol);
|
||||
free(items[uid]);
|
||||
items[uid] = NULL;
|
||||
}
|
||||
return itemmap[uid];
|
||||
}
|
||||
|
||||
#define xx(s) static void do##s(rcc_interface_ty);
|
||||
xx(Export)
|
||||
xx(Import)
|
||||
xx(Global)
|
||||
xx(Local)
|
||||
xx(Address)
|
||||
xx(Segment)
|
||||
xx(Defaddress)
|
||||
xx(Deflabel)
|
||||
xx(Defconst)
|
||||
xx(Defconstf)
|
||||
xx(Defstring)
|
||||
xx(Space)
|
||||
xx(Function)
|
||||
xx(Blockbeg)
|
||||
xx(Blockend)
|
||||
xx(Forest)
|
||||
#undef xx
|
||||
static void (*doX[])(rcc_interface_ty in) = {
|
||||
#define xx(s) 0,
|
||||
xx(Export)
|
||||
xx(Import)
|
||||
xx(Global)
|
||||
xx(Local)
|
||||
xx(Address)
|
||||
xx(Segment)
|
||||
xx(Defaddress)
|
||||
xx(Deflabel)
|
||||
xx(Defconst)
|
||||
xx(Defconstf)
|
||||
xx(Defstring)
|
||||
xx(Space)
|
||||
xx(Function)
|
||||
xx(Blockbeg)
|
||||
xx(Blockend)
|
||||
xx(Forest)
|
||||
0
|
||||
#undef xx
|
||||
};
|
||||
|
||||
static void interface(rcc_interface_ty in) {
|
||||
assert(in);
|
||||
(*doX[in->kind])(in);
|
||||
free(in);
|
||||
}
|
||||
|
||||
static void doExport(rcc_interface_ty in) {
|
||||
(*IR->export)(uid2symbol(in->v.rcc_Export.p));
|
||||
}
|
||||
|
||||
static void doImport(rcc_interface_ty in) {
|
||||
Symbol p = uid2symbol(in->v.rcc_Export.p);
|
||||
|
||||
(*IR->import)(p);
|
||||
p->defined = 1;
|
||||
}
|
||||
|
||||
static void doGlobal(rcc_interface_ty in) {
|
||||
Symbol p = uid2symbol(in->v.rcc_Global.p);
|
||||
|
||||
p->u.seg = in->v.rcc_Global.seg;
|
||||
(*IR->global)(p);
|
||||
p->defined = 1;
|
||||
}
|
||||
|
||||
static void doLocal(rcc_interface_ty in) {
|
||||
int uid = in->v.rcc_Local.uid;
|
||||
|
||||
assert(uid >= 0 && uid < nuids);
|
||||
assert(items[uid] == NULL);
|
||||
items[uid] = rcc_Symbol(uid, in->v.rcc_Local.p);
|
||||
if (in->v.rcc_Local.p->scope >= LOCAL)
|
||||
addlocal(uid2symbol(uid));
|
||||
}
|
||||
|
||||
static void doAddress(rcc_interface_ty in) {
|
||||
int uid = in->v.rcc_Address.uid;
|
||||
Symbol p = uid2symbol(in->v.rcc_Address.p);
|
||||
|
||||
assert(uid >= 0 && uid < nuids);
|
||||
assert(items[uid] == NULL);
|
||||
items[uid] = rcc_Symbol(uid, in->v.rcc_Address.q);
|
||||
if (p->scope == GLOBAL || p->sclass == STATIC || p->sclass == EXTERN)
|
||||
(*IR->address)(uid2symbol(uid), p, in->v.rcc_Address.n);
|
||||
else {
|
||||
Code cp = code(Address);
|
||||
cp->u.addr.sym = uid2symbol(uid);
|
||||
cp->u.addr.base = p;
|
||||
cp->u.addr.offset = in->v.rcc_Address.n;
|
||||
}
|
||||
}
|
||||
|
||||
static void doSegment(rcc_interface_ty in) {
|
||||
(*IR->segment)(in->v.rcc_Segment.seg);
|
||||
}
|
||||
|
||||
static void doDefaddress(rcc_interface_ty in) {
|
||||
(*IR->defaddress)(uid2symbol(in->v.rcc_Defaddress.p));
|
||||
}
|
||||
|
||||
static void doDeflabel(rcc_interface_ty in) {
|
||||
(*IR->defaddress)(findlabel(in->v.rcc_Deflabel.label));
|
||||
}
|
||||
|
||||
static void doDefconst(rcc_interface_ty in) {
|
||||
Value v;
|
||||
|
||||
v.i = in->v.rcc_Defconst.value;
|
||||
(*IR->defconst)(in->v.rcc_Defconst.suffix, in->v.rcc_Defconst.size, v);
|
||||
}
|
||||
|
||||
static void doDefconstf(rcc_interface_ty in) {
|
||||
Value v;
|
||||
unsigned *p = (unsigned *)&v.d;
|
||||
|
||||
p[swap] = in->v.rcc_Defconstf.value->msb;
|
||||
p[1-swap] = in->v.rcc_Defconstf.value->lsb;
|
||||
(*IR->defconst)(F, in->v.rcc_Defconstf.size, v);
|
||||
free(in->v.rcc_Defconstf.value);
|
||||
}
|
||||
|
||||
static void doDefstring(rcc_interface_ty in) {
|
||||
(*IR->defstring)(in->v.rcc_Defstring.s.len, (char *)in->v.rcc_Defstring.s.str);
|
||||
free((char *)in->v.rcc_Defstring.s.str);
|
||||
}
|
||||
|
||||
static void doSpace(rcc_interface_ty in) {
|
||||
(*IR->space)(in->v.rcc_Space.n);
|
||||
}
|
||||
|
||||
static void doFunction(rcc_interface_ty in) {
|
||||
int i, n;
|
||||
Symbol *caller, *callee;
|
||||
|
||||
/*
|
||||
Initialize:
|
||||
define the function symbol,
|
||||
initialize callee and caller arrays.
|
||||
*/
|
||||
cfunc = uid2symbol(in->v.rcc_Function.f);
|
||||
labels = table(NULL, LABELS);
|
||||
enterscope();
|
||||
n = Seq_length(in->v.rcc_Function.caller);
|
||||
caller = newarray(n + 1, sizeof *caller, FUNC);
|
||||
for (i = 0; i < n; i++) {
|
||||
int *uid = Seq_remlo(in->v.rcc_Function.caller);
|
||||
caller[i] = uid2symbol(*uid);
|
||||
free(uid);
|
||||
}
|
||||
caller[i] = NULL;
|
||||
Seq_free(&in->v.rcc_Function.caller);
|
||||
callee = newarray(n + 1, sizeof *callee, FUNC);
|
||||
for (i = 0; i < n; i++) {
|
||||
int *uid = Seq_remlo(in->v.rcc_Function.callee);
|
||||
callee[i] = uid2symbol(*uid);
|
||||
free(uid);
|
||||
}
|
||||
callee[i] = NULL;
|
||||
Seq_free(&in->v.rcc_Function.callee);
|
||||
cfunc->u.f.callee = callee;
|
||||
cfunc->defined = 1;
|
||||
/*
|
||||
Initialize the code list,
|
||||
traverse the interfaces inside the function;
|
||||
each call appends code list entries.
|
||||
*/
|
||||
codelist = &codehead;
|
||||
codelist->next = NULL;
|
||||
n = Seq_length(in->v.rcc_Function.codelist);
|
||||
for (i = 0; i < n; i++)
|
||||
interface(Seq_remlo(in->v.rcc_Function.codelist));
|
||||
Seq_free(&in->v.rcc_Function.codelist);
|
||||
/*
|
||||
Call the back end,
|
||||
Wrap-up.
|
||||
*/
|
||||
exitscope();
|
||||
(*IR->function)(cfunc, caller, callee, in->v.rcc_Function.ncalls);
|
||||
cfunc = NULL;
|
||||
labels = NULL;
|
||||
}
|
||||
|
||||
static struct block {
|
||||
Code begin;
|
||||
struct block *prev;
|
||||
} *blockstack = NULL;
|
||||
|
||||
static void doBlockbeg(rcc_interface_ty in) {
|
||||
struct block *b;
|
||||
Code cp = code(Blockbeg);
|
||||
|
||||
enterscope();
|
||||
cp->u.block.level = level;
|
||||
cp->u.block.locals = newarray(1, sizeof *cp->u.block.locals, FUNC);
|
||||
cp->u.block.locals[0] = NULL;
|
||||
cp->u.block.identifiers = NULL;
|
||||
cp->u.block.types = NULL;
|
||||
NEW(b, FUNC);
|
||||
b->begin = cp;
|
||||
b->prev = blockstack;
|
||||
blockstack = b;
|
||||
}
|
||||
|
||||
static void doBlockend(rcc_interface_ty in) {
|
||||
assert(blockstack);
|
||||
code(Blockend)->u.begin = blockstack->begin;
|
||||
blockstack = blockstack->prev;
|
||||
exitscope();
|
||||
}
|
||||
|
||||
static Node visit(rcc_node_ty node) {
|
||||
int op;
|
||||
Node left = NULL, right = NULL, p = NULL;
|
||||
Symbol sym = NULL;
|
||||
|
||||
switch (node->kind) {
|
||||
#define T(x) rcc_##x##_enum
|
||||
case T(CSE): {
|
||||
Symbol q = uid2symbol(node->v.rcc_CSE.uid);
|
||||
assert(q->temporary);
|
||||
q->u.t.cse = p = visit(node->v.rcc_CSE.node);
|
||||
break;
|
||||
}
|
||||
case T(CNST): {
|
||||
Value v;
|
||||
v.i = node->v.rcc_CNST.value;
|
||||
sym = constant(btot(node->suffix, node->size), v);
|
||||
op = CNST;
|
||||
break;
|
||||
}
|
||||
case T(CNSTF): {
|
||||
Value v;
|
||||
unsigned *p = (unsigned *)&v.d;
|
||||
p[swap] = node->v.rcc_CNSTF.value->msb;
|
||||
p[1-swap] = node->v.rcc_CNSTF.value->lsb;
|
||||
sym = constant(btot(node->suffix, node->size), v);
|
||||
free(node->v.rcc_CNSTF.value);
|
||||
op = CNST;
|
||||
break;
|
||||
}
|
||||
case T(ARG):
|
||||
p = newnode(ARG + node->suffix + sizeop(node->size),
|
||||
visit(node->v.rcc_ARG.left), NULL,
|
||||
intconst(node->v.rcc_ARG.len));
|
||||
p->syms[1] = intconst(node->v.rcc_ARG.align);
|
||||
break;
|
||||
case T(ASGN):
|
||||
p = newnode(ASGN + node->suffix + sizeop(node->size),
|
||||
visit(node->v.rcc_ASGN.left), visit(node->v.rcc_ASGN.right),
|
||||
intconst(node->v.rcc_ASGN.len));
|
||||
p->syms[1] = intconst(node->v.rcc_ASGN.align);
|
||||
break;
|
||||
case T(CVT):
|
||||
op = node->v.rcc_CVT.op;
|
||||
left = visit(node->v.rcc_CVT.left);
|
||||
sym = intconst(node->v.rcc_CVT.fromsize);
|
||||
break;
|
||||
case T(CALL):
|
||||
op = CALL;
|
||||
left = visit(node->v.rcc_CALL.left);
|
||||
NEW0(sym, FUNC);
|
||||
sym->type = uid2type(node->v.rcc_CALL.type);
|
||||
break;
|
||||
case T(CALLB):
|
||||
op = CALL;
|
||||
left = visit(node->v.rcc_CALLB.left);
|
||||
right = visit(node->v.rcc_CALLB.right);
|
||||
NEW0(sym, FUNC);
|
||||
sym->type = uid2type(node->v.rcc_CALLB.type);
|
||||
break;
|
||||
case T(RET):
|
||||
op = RET;
|
||||
break;
|
||||
case T(ADDRG):
|
||||
op = ADDRG;
|
||||
sym = uid2symbol(node->v.rcc_ADDRG.uid);
|
||||
break;
|
||||
case T(ADDRL):
|
||||
op = ADDRL;
|
||||
sym = uid2symbol(node->v.rcc_ADDRG.uid);
|
||||
break;
|
||||
case T(ADDRF):
|
||||
op = ADDRF;
|
||||
sym = uid2symbol(node->v.rcc_ADDRG.uid);
|
||||
break;
|
||||
case T(Unary):
|
||||
op = node->v.rcc_Unary.op;
|
||||
left = visit(node->v.rcc_Unary.left);
|
||||
break;
|
||||
case T(Binary):
|
||||
op = node->v.rcc_Binary.op;
|
||||
left = visit(node->v.rcc_Binary.left);
|
||||
right = visit(node->v.rcc_Binary.right);
|
||||
break;
|
||||
case T(Compare):
|
||||
op = node->v.rcc_Compare.op;
|
||||
left = visit(node->v.rcc_Compare.left);
|
||||
right = visit(node->v.rcc_Compare.right);
|
||||
sym = findlabel(node->v.rcc_Compare.label);
|
||||
break;
|
||||
case T(LABEL):
|
||||
op = LABEL;
|
||||
sym = findlabel(node->v.rcc_LABEL.label);
|
||||
break;
|
||||
case T(BRANCH):
|
||||
op = JUMP;
|
||||
left = newnode(ADDRG+P+sizeop(voidptype->size), NULL, NULL, findlabel(node->v.rcc_BRANCH.label));
|
||||
break;
|
||||
#undef T
|
||||
default: assert(0);
|
||||
}
|
||||
if (p == NULL)
|
||||
p = newnode(op + node->suffix + sizeop(node->size), left, right, sym);
|
||||
free(node);
|
||||
return p;
|
||||
}
|
||||
|
||||
static void doForest(rcc_interface_ty in) {
|
||||
Node *tail = &code(Gen)->u.forest;
|
||||
int i, n = Seq_length(in->v.rcc_Forest.nodes);
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
*tail = visit(Seq_remlo(in->v.rcc_Forest.nodes));
|
||||
assert(*tail);
|
||||
tail = &(*tail)->link;
|
||||
}
|
||||
*tail = NULL;
|
||||
Seq_free(&in->v.rcc_Forest.nodes);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int i, version;
|
||||
float stamp = (assert(strstr(rcsid, ",v")), strtod(strstr(rcsid, ",v")+2, NULL))
|
||||
;
|
||||
char *infile = NULL, *outfile = NULL;
|
||||
rcc_program_ty pickle;
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
if (*argv[i] != '-' || strcmp(argv[i], "-") == 0) {
|
||||
if (infile == NULL)
|
||||
infile = argv[i];
|
||||
else if (outfile == NULL)
|
||||
outfile = argv[i];
|
||||
}
|
||||
if (infile != NULL && strcmp(infile, "-") != 0
|
||||
&& freopen(infile, "rb", stdin) == NULL) {
|
||||
fprint(stderr, "%s: can't read `%s'\n", argv[0], infile);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#if WIN32
|
||||
else
|
||||
_setmode(_fileno(stdin), _O_BINARY);
|
||||
#endif
|
||||
if (outfile != NULL && strcmp(outfile, "-") != 0
|
||||
&& freopen(outfile, "w", stdout) == NULL) {
|
||||
fprint(stderr, "%s: can't write `%s'\n", argv[0], outfile);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
version = read_int(stdin);
|
||||
assert(version/100 == (int)stamp);
|
||||
pickle = rcc_read_program(stdin);
|
||||
argc = pickle->argc;
|
||||
argv = newarray(argc + 1, sizeof *argv, PERM);
|
||||
{
|
||||
for (i = 0; i < argc; i++) {
|
||||
string_ty *arg = Seq_remlo(pickle->argv);
|
||||
argv[i] = (char *)arg->str;
|
||||
free(arg);
|
||||
}
|
||||
argv[i] = NULL;
|
||||
assert(i == argc);
|
||||
Seq_free(&pickle->argv);
|
||||
}
|
||||
for (i = argc - 1; i > 0; i--)
|
||||
if (strncmp(argv[i], "-target=", 8) == 0)
|
||||
break;
|
||||
if (i > 0) {
|
||||
int j;
|
||||
for (j = 0; bindings[j].name && bindings[j].ir; j++)
|
||||
if (strcmp(&argv[i][8], bindings[j].name) == 0) {
|
||||
IR = bindings[j].ir;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!IR) {
|
||||
fprint(stderr, "%s: unknown target", argv[0]);
|
||||
if (i > 0)
|
||||
fprint(stderr, " `%s'", &argv[i][8]);
|
||||
fprint(stderr, "; must specify one of\n");
|
||||
for (i = 0; bindings[i].name; i++)
|
||||
fprint(stderr, "\t-target=%s\n", bindings[i].name);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
IR->wants_dag = 0; /* pickle's hold trees */
|
||||
init(argc, argv);
|
||||
genlabel(pickle->nlabels);
|
||||
level = GLOBAL;
|
||||
{
|
||||
int i, count;
|
||||
nuids = pickle->nuids;
|
||||
items = newarray(nuids, sizeof *items, PERM);
|
||||
itemmap = newarray(nuids, sizeof *items, PERM);
|
||||
for (i = 0; i < nuids; i++) {
|
||||
itemmap[i] = NULL;
|
||||
items[i] = NULL;
|
||||
}
|
||||
(*IR->progbeg)(argc, argv);
|
||||
count = Seq_length(pickle->items);
|
||||
for (i = 0; i < count; i++) {
|
||||
rcc_item_ty item = Seq_remlo(pickle->items);
|
||||
int uid = item->uid;
|
||||
assert(uid >= 0 && uid < nuids);
|
||||
assert(items[uid] == NULL);
|
||||
items[uid] = item;
|
||||
}
|
||||
Seq_free(&pickle->items);
|
||||
#define xx(s) assert(rcc_##s##_enum < sizeof doX/sizeof doX[0] && doX[rcc_##s##_enum]==0); \
|
||||
doX[rcc_##s##_enum] = do##s;
|
||||
xx(Export)
|
||||
xx(Import)
|
||||
xx(Global)
|
||||
xx(Local)
|
||||
xx(Address)
|
||||
xx(Segment)
|
||||
xx(Defaddress)
|
||||
xx(Deflabel)
|
||||
xx(Defconst)
|
||||
xx(Defconstf)
|
||||
xx(Defstring)
|
||||
xx(Space)
|
||||
xx(Function)
|
||||
xx(Blockbeg)
|
||||
xx(Blockend)
|
||||
xx(Forest)
|
||||
#undef xx
|
||||
count = Seq_length(pickle->interfaces);
|
||||
for (i = 0; i < count; i++)
|
||||
interface(Seq_remlo(pickle->interfaces));
|
||||
Seq_free(&pickle->interfaces);
|
||||
free(pickle);
|
||||
(*IR->progend)();
|
||||
}
|
||||
deallocate(PERM);
|
||||
return errcnt > 0;
|
||||
}
|
||||
|
||||
/* main_init - process program arguments */
|
||||
void main_init(int argc, char *argv[]) {
|
||||
int i;
|
||||
static int inited;
|
||||
|
||||
if (inited)
|
||||
return;
|
||||
inited = 1;
|
||||
for (i = 1; i < argc; i++)
|
||||
if (strcmp(argv[i], "-g") == 0 || strcmp(argv[i], "-g2") == 0)
|
||||
glevel = 2;
|
||||
else if (strcmp(argv[i], "-w") == 0)
|
||||
wflag++;
|
||||
else if (strcmp(argv[i], "-v") == 0) {
|
||||
fprint(stderr, "%s %s\n", argv[0], rcsid);
|
||||
verbose++;
|
||||
} else if (strncmp(argv[i], "-errout=", 8) == 0) {
|
||||
FILE *f = fopen(argv[i]+8, "w");
|
||||
if (f == NULL) {
|
||||
fprint(stderr, "%s: can't write errors to `%s'\n", argv[0], argv[i]+8);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
fclose(f);
|
||||
f = freopen(argv[i]+8, "w", stderr);
|
||||
assert(f);
|
||||
} else if (strncmp(argv[i], "-e", 2) == 0) {
|
||||
int x;
|
||||
if ((x = strtol(&argv[i][2], NULL, 0)) > 0)
|
||||
errlimit = x;
|
||||
}
|
||||
}
|
||||
|
||||
void init(int argc, char *argv[]) {
|
||||
{extern void main_init(int, char *[]); main_init(argc, argv);}
|
||||
{extern void prof_init(int, char *[]); prof_init(argc, argv);}
|
||||
{extern void trace_init(int, char *[]); trace_init(argc, argv);}
|
||||
{extern void type_init(int, char *[]); type_init(argc, argv);}
|
||||
{extern void x86linux_init(int, char *[]); x86linux_init(argc, argv);}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,998 +0,0 @@
|
|||
%{
|
||||
enum { EAX=0, ECX=1, EDX=2, EBX=3, ESI=6, EDI=7 };
|
||||
#include "c.h"
|
||||
#define NODEPTR_TYPE Node
|
||||
#define OP_LABEL(p) ((p)->op)
|
||||
#define LEFT_CHILD(p) ((p)->kids[0])
|
||||
#define RIGHT_CHILD(p) ((p)->kids[1])
|
||||
#define STATE_LABEL(p) ((p)->x.state)
|
||||
static void address(Symbol, Symbol, long);
|
||||
static void blkfetch(int, int, int, int);
|
||||
static void blkloop(int, int, int, int, int, int[]);
|
||||
static void blkstore(int, int, int, int);
|
||||
static void defaddress(Symbol);
|
||||
static void defconst(int, int, Value);
|
||||
static void defstring(int, char *);
|
||||
static void defsymbol(Symbol);
|
||||
static void doarg(Node);
|
||||
static void emit2(Node);
|
||||
static void export(Symbol);
|
||||
static void clobber(Node);
|
||||
static void function(Symbol, Symbol [], Symbol [], int);
|
||||
static void global(Symbol);
|
||||
static void import(Symbol);
|
||||
static void local(Symbol);
|
||||
static void progbeg(int, char **);
|
||||
static void progend(void);
|
||||
static void segment(int);
|
||||
static void space(int);
|
||||
static void target(Node);
|
||||
extern int ckstack(Node, int);
|
||||
extern int memop(Node);
|
||||
extern int sametree(Node, Node);
|
||||
static Symbol charreg[32], shortreg[32], intreg[32];
|
||||
static Symbol fltreg[32];
|
||||
|
||||
static Symbol charregw, shortregw, intregw, fltregw;
|
||||
|
||||
static int cseg;
|
||||
|
||||
static Symbol quo, rem;
|
||||
|
||||
%}
|
||||
%start stmt
|
||||
%term CNSTF4=4113
|
||||
%term CNSTF8=8209
|
||||
%term CNSTF16=16401
|
||||
%term CNSTI1=1045
|
||||
%term CNSTI2=2069
|
||||
%term CNSTI4=4117
|
||||
%term CNSTI8=8213
|
||||
%term CNSTP4=4119
|
||||
%term CNSTP8=8215
|
||||
%term CNSTU1=1046
|
||||
%term CNSTU2=2070
|
||||
%term CNSTU4=4118
|
||||
%term CNSTU8=8214
|
||||
|
||||
%term ARGB=41
|
||||
%term ARGF4=4129
|
||||
%term ARGF8=8225
|
||||
%term ARGF16=16417
|
||||
%term ARGI4=4133
|
||||
%term ARGI8=8229
|
||||
%term ARGP4=4135
|
||||
%term ARGP8=8231
|
||||
%term ARGU4=4134
|
||||
%term ARGU8=8230
|
||||
|
||||
%term ASGNB=57
|
||||
%term ASGNF4=4145
|
||||
%term ASGNF8=8241
|
||||
%term ASGNF16=16433
|
||||
%term ASGNI1=1077
|
||||
%term ASGNI2=2101
|
||||
%term ASGNI4=4149
|
||||
%term ASGNI8=8245
|
||||
%term ASGNP4=4151
|
||||
%term ASGNP8=8247
|
||||
%term ASGNU1=1078
|
||||
%term ASGNU2=2102
|
||||
%term ASGNU4=4150
|
||||
%term ASGNU8=8246
|
||||
|
||||
%term INDIRB=73
|
||||
%term INDIRF4=4161
|
||||
%term INDIRF8=8257
|
||||
%term INDIRF16=16449
|
||||
%term INDIRI1=1093
|
||||
%term INDIRI2=2117
|
||||
%term INDIRI4=4165
|
||||
%term INDIRI8=8261
|
||||
%term INDIRP4=4167
|
||||
%term INDIRP8=8263
|
||||
%term INDIRU1=1094
|
||||
%term INDIRU2=2118
|
||||
%term INDIRU4=4166
|
||||
%term INDIRU8=8262
|
||||
|
||||
%term CVFF4=4209
|
||||
%term CVFF8=8305
|
||||
%term CVFF16=16497
|
||||
%term CVFI4=4213
|
||||
%term CVFI8=8309
|
||||
|
||||
%term CVIF4=4225
|
||||
%term CVIF8=8321
|
||||
%term CVIF16=16513
|
||||
%term CVII1=1157
|
||||
%term CVII2=2181
|
||||
%term CVII4=4229
|
||||
%term CVII8=8325
|
||||
%term CVIU1=1158
|
||||
%term CVIU2=2182
|
||||
%term CVIU4=4230
|
||||
%term CVIU8=8326
|
||||
|
||||
%term CVPP4=4247
|
||||
%term CVPP8=8343
|
||||
%term CVPP16=16535
|
||||
%term CVPU4=4246
|
||||
%term CVPU8=8342
|
||||
|
||||
%term CVUI1=1205
|
||||
%term CVUI2=2229
|
||||
%term CVUI4=4277
|
||||
%term CVUI8=8373
|
||||
%term CVUP4=4279
|
||||
%term CVUP8=8375
|
||||
%term CVUP16=16567
|
||||
%term CVUU1=1206
|
||||
%term CVUU2=2230
|
||||
%term CVUU4=4278
|
||||
%term CVUU8=8374
|
||||
|
||||
%term NEGF4=4289
|
||||
%term NEGF8=8385
|
||||
%term NEGF16=16577
|
||||
%term NEGI4=4293
|
||||
%term NEGI8=8389
|
||||
|
||||
%term CALLB=217
|
||||
%term CALLF4=4305
|
||||
%term CALLF8=8401
|
||||
%term CALLF16=16593
|
||||
%term CALLI4=4309
|
||||
%term CALLI8=8405
|
||||
%term CALLP4=4311
|
||||
%term CALLP8=8407
|
||||
%term CALLU4=4310
|
||||
%term CALLU8=8406
|
||||
%term CALLV=216
|
||||
|
||||
%term RETF4=4337
|
||||
%term RETF8=8433
|
||||
%term RETF16=16625
|
||||
%term RETI4=4341
|
||||
%term RETI8=8437
|
||||
%term RETP4=4343
|
||||
%term RETP8=8439
|
||||
%term RETU4=4342
|
||||
%term RETU8=8438
|
||||
%term RETV=248
|
||||
|
||||
%term ADDRGP4=4359
|
||||
%term ADDRGP8=8455
|
||||
|
||||
%term ADDRFP4=4375
|
||||
%term ADDRFP8=8471
|
||||
|
||||
%term ADDRLP4=4391
|
||||
%term ADDRLP8=8487
|
||||
|
||||
%term ADDF4=4401
|
||||
%term ADDF8=8497
|
||||
%term ADDF16=16689
|
||||
%term ADDI4=4405
|
||||
%term ADDI8=8501
|
||||
%term ADDP4=4407
|
||||
%term ADDP8=8503
|
||||
%term ADDU4=4406
|
||||
%term ADDU8=8502
|
||||
|
||||
%term SUBF4=4417
|
||||
%term SUBF8=8513
|
||||
%term SUBF16=16705
|
||||
%term SUBI4=4421
|
||||
%term SUBI8=8517
|
||||
%term SUBP4=4423
|
||||
%term SUBP8=8519
|
||||
%term SUBU4=4422
|
||||
%term SUBU8=8518
|
||||
|
||||
%term LSHI4=4437
|
||||
%term LSHI8=8533
|
||||
%term LSHU4=4438
|
||||
%term LSHU8=8534
|
||||
|
||||
%term MODI4=4453
|
||||
%term MODI8=8549
|
||||
%term MODU4=4454
|
||||
%term MODU8=8550
|
||||
|
||||
%term RSHI4=4469
|
||||
%term RSHI8=8565
|
||||
%term RSHU4=4470
|
||||
%term RSHU8=8566
|
||||
|
||||
%term BANDI4=4485
|
||||
%term BANDI8=8581
|
||||
%term BANDU4=4486
|
||||
%term BANDU8=8582
|
||||
|
||||
%term BCOMI4=4501
|
||||
%term BCOMI8=8597
|
||||
%term BCOMU4=4502
|
||||
%term BCOMU8=8598
|
||||
|
||||
%term BORI4=4517
|
||||
%term BORI8=8613
|
||||
%term BORU4=4518
|
||||
%term BORU8=8614
|
||||
|
||||
%term BXORI4=4533
|
||||
%term BXORI8=8629
|
||||
%term BXORU4=4534
|
||||
%term BXORU8=8630
|
||||
|
||||
%term DIVF4=4545
|
||||
%term DIVF8=8641
|
||||
%term DIVF16=16833
|
||||
%term DIVI4=4549
|
||||
%term DIVI8=8645
|
||||
%term DIVU4=4550
|
||||
%term DIVU8=8646
|
||||
|
||||
%term MULF4=4561
|
||||
%term MULF8=8657
|
||||
%term MULF16=16849
|
||||
%term MULI4=4565
|
||||
%term MULI8=8661
|
||||
%term MULU4=4566
|
||||
%term MULU8=8662
|
||||
|
||||
%term EQF4=4577
|
||||
%term EQF8=8673
|
||||
%term EQF16=16865
|
||||
%term EQI4=4581
|
||||
%term EQI8=8677
|
||||
%term EQU4=4582
|
||||
%term EQU8=8678
|
||||
|
||||
%term GEF4=4593
|
||||
%term GEF8=8689
|
||||
%term GEI4=4597
|
||||
%term GEI8=8693
|
||||
%term GEI16=16885
|
||||
%term GEU4=4598
|
||||
%term GEU8=8694
|
||||
|
||||
%term GTF4=4609
|
||||
%term GTF8=8705
|
||||
%term GTF16=16897
|
||||
%term GTI4=4613
|
||||
%term GTI8=8709
|
||||
%term GTU4=4614
|
||||
%term GTU8=8710
|
||||
|
||||
%term LEF4=4625
|
||||
%term LEF8=8721
|
||||
%term LEF16=16913
|
||||
%term LEI4=4629
|
||||
%term LEI8=8725
|
||||
%term LEU4=4630
|
||||
%term LEU8=8726
|
||||
|
||||
%term LTF4=4641
|
||||
%term LTF8=8737
|
||||
%term LTF16=16929
|
||||
%term LTI4=4645
|
||||
%term LTI8=8741
|
||||
%term LTU4=4646
|
||||
%term LTU8=8742
|
||||
|
||||
%term NEF4=4657
|
||||
%term NEF8=8753
|
||||
%term NEF16=16945
|
||||
%term NEI4=4661
|
||||
%term NEI8=8757
|
||||
%term NEU4=4662
|
||||
%term NEU8=8758
|
||||
|
||||
%term JUMPV=584
|
||||
|
||||
%term LABELV=600
|
||||
|
||||
%term LOADB=233
|
||||
%term LOADF4=4321
|
||||
%term LOADF8=8417
|
||||
%term LOADF16=16609
|
||||
%term LOADI1=1253
|
||||
%term LOADI2=2277
|
||||
%term LOADI4=4325
|
||||
%term LOADI8=8421
|
||||
%term LOADP4=4327
|
||||
%term LOADP8=8423
|
||||
%term LOADU1=1254
|
||||
%term LOADU2=2278
|
||||
%term LOADU4=4326
|
||||
%term LOADU8=8422
|
||||
|
||||
%term VREGP=711
|
||||
%%
|
||||
reg: INDIRI1(VREGP) "# read register\n"
|
||||
reg: INDIRU1(VREGP) "# read register\n"
|
||||
|
||||
reg: INDIRI2(VREGP) "# read register\n"
|
||||
reg: INDIRU2(VREGP) "# read register\n"
|
||||
|
||||
reg: INDIRF4(VREGP) "# read register\n"
|
||||
reg: INDIRI4(VREGP) "# read register\n"
|
||||
reg: INDIRP4(VREGP) "# read register\n"
|
||||
reg: INDIRU4(VREGP) "# read register\n"
|
||||
|
||||
reg: INDIRF8(VREGP) "# read register\n"
|
||||
reg: INDIRI8(VREGP) "# read register\n"
|
||||
reg: INDIRP8(VREGP) "# read register\n"
|
||||
reg: INDIRU8(VREGP) "# read register\n"
|
||||
|
||||
stmt: ASGNI1(VREGP,reg) "# write register\n"
|
||||
stmt: ASGNU1(VREGP,reg) "# write register\n"
|
||||
|
||||
stmt: ASGNI2(VREGP,reg) "# write register\n"
|
||||
stmt: ASGNU2(VREGP,reg) "# write register\n"
|
||||
|
||||
stmt: ASGNF4(VREGP,reg) "# write register\n"
|
||||
stmt: ASGNI4(VREGP,reg) "# write register\n"
|
||||
stmt: ASGNP4(VREGP,reg) "# write register\n"
|
||||
stmt: ASGNU4(VREGP,reg) "# write register\n"
|
||||
|
||||
stmt: ASGNF8(VREGP,reg) "# write register\n"
|
||||
stmt: ASGNI8(VREGP,reg) "# write register\n"
|
||||
stmt: ASGNP8(VREGP,reg) "# write register\n"
|
||||
stmt: ASGNU8(VREGP,reg) "# write register\n"
|
||||
con: CNSTI1 "%a"
|
||||
con: CNSTU1 "%a"
|
||||
|
||||
con: CNSTI2 "%a"
|
||||
con: CNSTU2 "%a"
|
||||
|
||||
con: CNSTI4 "%a"
|
||||
con: CNSTU4 "%a"
|
||||
con: CNSTP4 "%a"
|
||||
|
||||
con: CNSTI8 "%a"
|
||||
con: CNSTU8 "%a"
|
||||
con: CNSTP8 "%a"
|
||||
stmt: reg ""
|
||||
acon: ADDRGP4 "(%a)"
|
||||
acon: con "(%0)"
|
||||
base: ADDRGP4 "(%a)"
|
||||
base: reg "[%0]"
|
||||
base: ADDI4(reg,acon) "%1[%0]"
|
||||
base: ADDP4(reg,acon) "%1[%0]"
|
||||
base: ADDU4(reg,acon) "%1[%0]"
|
||||
base: ADDRFP4 "(%a)[ebp]"
|
||||
base: ADDRLP4 "(%a)[ebp]"
|
||||
index: reg "%0"
|
||||
index: LSHI4(reg,con1) "%0*2"
|
||||
index: LSHI4(reg,con2) "%0*4"
|
||||
index: LSHI4(reg,con3) "%0*8"
|
||||
|
||||
con1: CNSTI4 "1" range(a, 1, 1)
|
||||
con1: CNSTU4 "1" range(a, 1, 1)
|
||||
con2: CNSTI4 "2" range(a, 2, 2)
|
||||
con2: CNSTU4 "2" range(a, 2, 2)
|
||||
con3: CNSTI4 "3" range(a, 3, 3)
|
||||
con3: CNSTU4 "3" range(a, 3, 3)
|
||||
index: LSHU4(reg,con1) "%0*2"
|
||||
index: LSHU4(reg,con2) "%0*4"
|
||||
index: LSHU4(reg,con3) "%0*8"
|
||||
addr: base "%0"
|
||||
addr: ADDI4(index,base) "%1[%0]"
|
||||
addr: ADDP4(index,base) "%1[%0]"
|
||||
addr: ADDU4(index,base) "%1[%0]"
|
||||
addr: index "[%0]"
|
||||
mem: INDIRI1(addr) "byte ptr %0"
|
||||
mem: INDIRI2(addr) "word ptr %0"
|
||||
mem: INDIRI4(addr) "dword ptr %0"
|
||||
mem: INDIRU1(addr) "byte ptr %0"
|
||||
mem: INDIRU2(addr) "word ptr %0"
|
||||
mem: INDIRU4(addr) "dword ptr %0"
|
||||
mem: INDIRP4(addr) "dword ptr %0"
|
||||
rc: reg "%0"
|
||||
rc: con "%0"
|
||||
|
||||
mr: reg "%0"
|
||||
mr: mem "%0"
|
||||
|
||||
mrc0: mem "%0"
|
||||
mrc0: rc "%0"
|
||||
mrc1: mem "%0" 1
|
||||
mrc1: rc "%0"
|
||||
|
||||
mrc3: mem "%0" 3
|
||||
mrc3: rc "%0"
|
||||
reg: addr "lea %c,%0\n" 1
|
||||
reg: mrc0 "mov %c,%0\n" 1
|
||||
reg: LOADI1(reg) "# move\n" 1
|
||||
reg: LOADI2(reg) "# move\n" 1
|
||||
reg: LOADI4(reg) "# move\n" move(a)
|
||||
reg: LOADU1(reg) "# move\n" 1
|
||||
reg: LOADU2(reg) "# move\n" 1
|
||||
reg: LOADU4(reg) "# move\n" move(a)
|
||||
reg: LOADP4(reg) "# move\n" move(a)
|
||||
reg: ADDI4(reg,mrc1) "?mov %c,%0\nadd %c,%1\n" 1
|
||||
reg: ADDP4(reg,mrc1) "?mov %c,%0\nadd %c,%1\n" 1
|
||||
reg: ADDU4(reg,mrc1) "?mov %c,%0\nadd %c,%1\n" 1
|
||||
reg: SUBI4(reg,mrc1) "?mov %c,%0\nsub %c,%1\n" 1
|
||||
reg: SUBP4(reg,mrc1) "?mov %c,%0\nsub %c,%1\n" 1
|
||||
reg: SUBU4(reg,mrc1) "?mov %c,%0\nsub %c,%1\n" 1
|
||||
reg: BANDI4(reg,mrc1) "?mov %c,%0\nand %c,%1\n" 1
|
||||
reg: BORI4(reg,mrc1) "?mov %c,%0\nor %c,%1\n" 1
|
||||
reg: BXORI4(reg,mrc1) "?mov %c,%0\nxor %c,%1\n" 1
|
||||
reg: BANDU4(reg,mrc1) "?mov %c,%0\nand %c,%1\n" 1
|
||||
reg: BORU4(reg,mrc1) "?mov %c,%0\nor %c,%1\n" 1
|
||||
reg: BXORU4(reg,mrc1) "?mov %c,%0\nxor %c,%1\n" 1
|
||||
stmt: ASGNI4(addr,ADDI4(mem,con1)) "inc %1\n" memop(a)
|
||||
stmt: ASGNI4(addr,ADDU4(mem,con1)) "inc %1\n" memop(a)
|
||||
stmt: ASGNP4(addr,ADDP4(mem,con1)) "inc %1\n" memop(a)
|
||||
stmt: ASGNI4(addr,SUBI4(mem,con1)) "dec %1\n" memop(a)
|
||||
stmt: ASGNI4(addr,SUBU4(mem,con1)) "dec %1\n" memop(a)
|
||||
stmt: ASGNP4(addr,SUBP4(mem,con1)) "dec %1\n" memop(a)
|
||||
stmt: ASGNI4(addr,ADDI4(mem,rc)) "add %1,%2\n" memop(a)
|
||||
stmt: ASGNI4(addr,SUBI4(mem,rc)) "sub %1,%2\n" memop(a)
|
||||
stmt: ASGNU4(addr,ADDU4(mem,rc)) "add %1,%2\n" memop(a)
|
||||
stmt: ASGNU4(addr,SUBU4(mem,rc)) "sub %1,%2\n" memop(a)
|
||||
|
||||
stmt: ASGNI4(addr,BANDI4(mem,rc)) "and %1,%2\n" memop(a)
|
||||
stmt: ASGNI4(addr,BORI4(mem,rc)) "or %1,%2\n" memop(a)
|
||||
stmt: ASGNI4(addr,BXORI4(mem,rc)) "xor %1,%2\n" memop(a)
|
||||
stmt: ASGNU4(addr,BANDU4(mem,rc)) "and %1,%2\n" memop(a)
|
||||
stmt: ASGNU4(addr,BORU4(mem,rc)) "or %1,%2\n" memop(a)
|
||||
stmt: ASGNU4(addr,BXORU4(mem,rc)) "xor %1,%2\n" memop(a)
|
||||
reg: BCOMI4(reg) "?mov %c,%0\nnot %c\n" 2
|
||||
reg: BCOMU4(reg) "?mov %c,%0\nnot %c\n" 2
|
||||
reg: NEGI4(reg) "?mov %c,%0\nneg %c\n" 2
|
||||
|
||||
stmt: ASGNI4(addr,BCOMI4(mem)) "not %1\n" memop(a)
|
||||
stmt: ASGNU4(addr,BCOMU4(mem)) "not %1\n" memop(a)
|
||||
stmt: ASGNI4(addr,NEGI4(mem)) "neg %1\n" memop(a)
|
||||
reg: LSHI4(reg,con5) "?mov %c,%0\nsal %c,%1\n" 2
|
||||
reg: LSHU4(reg,con5) "?mov %c,%0\nshl %c,%1\n" 2
|
||||
reg: RSHI4(reg,con5) "?mov %c,%0\nsar %c,%1\n" 2
|
||||
reg: RSHU4(reg,con5) "?mov %c,%0\nshr %c,%1\n" 2
|
||||
|
||||
stmt: ASGNI4(addr,LSHI4(mem,con5)) "sal %1,%2\n" memop(a)
|
||||
stmt: ASGNI4(addr,LSHU4(mem,con5)) "shl %1,%2\n" memop(a)
|
||||
stmt: ASGNI4(addr,RSHI4(mem,con5)) "sar %1,%2\n" memop(a)
|
||||
stmt: ASGNI4(addr,RSHU4(mem,con5)) "shr %1,%2\n" memop(a)
|
||||
|
||||
con5: CNSTI4 "%a" range(a, 0, 31)
|
||||
|
||||
reg: LSHI4(reg,reg) "?mov %c,%0\nmov ecx,%1\nsal %c,cl\n" 3
|
||||
reg: LSHU4(reg,reg) "?mov %c,%0\nmov ecx,%1\nshl %c,cl\n" 2
|
||||
reg: RSHI4(reg,reg) "?mov %c,%0\nmov ecx,%1\nsar %c,cl\n" 2
|
||||
reg: RSHU4(reg,reg) "?mov %c,%0\nmov ecx,%1\nshr %c,cl\n" 2
|
||||
reg: MULI4(reg,mrc3) "?mov %c,%0\nimul %c,%1\n" 14
|
||||
reg: MULI4(con,mr) "imul %c,%1,%0\n" 13
|
||||
reg: MULU4(reg,mr) "mul %1\n" 13
|
||||
reg: DIVU4(reg,reg) "xor edx,edx\ndiv %1\n"
|
||||
reg: MODU4(reg,reg) "xor edx,edx\ndiv %1\n"
|
||||
reg: DIVI4(reg,reg) "cdq\nidiv %1\n"
|
||||
reg: MODI4(reg,reg) "cdq\nidiv %1\n"
|
||||
reg: CVPU4(reg) "mov %c,%0\n" move(a)
|
||||
reg: CVUP4(reg) "mov %c,%0\n" move(a)
|
||||
reg: CVII4(INDIRI1(addr)) "movsx %c,byte ptr %0\n" 3
|
||||
reg: CVII4(INDIRI2(addr)) "movsx %c,word ptr %0\n" 3
|
||||
reg: CVUU4(INDIRU1(addr)) "movzx %c,byte ptr %0\n" 3
|
||||
reg: CVUU4(INDIRU2(addr)) "movzx %c,word ptr %0\n" 3
|
||||
reg: CVII4(reg) "# extend\n" 3
|
||||
reg: CVIU4(reg) "# extend\n" 3
|
||||
reg: CVUI4(reg) "# extend\n" 3
|
||||
reg: CVUU4(reg) "# extend\n" 3
|
||||
|
||||
reg: CVII1(reg) "# truncate\n" 1
|
||||
reg: CVII2(reg) "# truncate\n" 1
|
||||
reg: CVUU1(reg) "# truncate\n" 1
|
||||
reg: CVUU2(reg) "# truncate\n" 1
|
||||
stmt: ASGNI1(addr,rc) "mov byte ptr %0,%1\n" 1
|
||||
stmt: ASGNI2(addr,rc) "mov word ptr %0,%1\n" 1
|
||||
stmt: ASGNI4(addr,rc) "mov dword ptr %0,%1\n" 1
|
||||
stmt: ASGNU1(addr,rc) "mov byte ptr %0,%1\n" 1
|
||||
stmt: ASGNU2(addr,rc) "mov word ptr %0,%1\n" 1
|
||||
stmt: ASGNU4(addr,rc) "mov dword ptr %0,%1\n" 1
|
||||
stmt: ASGNP4(addr,rc) "mov dword ptr %0,%1\n" 1
|
||||
stmt: ARGI4(mrc3) "push %0\n" 1
|
||||
stmt: ARGU4(mrc3) "push %0\n" 1
|
||||
stmt: ARGP4(mrc3) "push %0\n" 1
|
||||
stmt: ASGNB(reg,INDIRB(reg)) "mov ecx,%a\nrep movsb\n"
|
||||
stmt: ARGB(INDIRB(reg)) "sub esp,%a\nmov edi,esp\nmov ecx,%a\nrep movsb\n"
|
||||
|
||||
memf: INDIRF8(addr) "qword ptr %0"
|
||||
memf: INDIRF4(addr) "dword ptr %0"
|
||||
memf: CVFF8(INDIRF4(addr)) "dword ptr %0"
|
||||
reg: memf "fld %0\n" 3
|
||||
stmt: ASGNF8(addr,reg) "fstp qword ptr %0\n" 7
|
||||
stmt: ASGNF4(addr,reg) "fstp dword ptr %0\n" 7
|
||||
stmt: ASGNF4(addr,CVFF4(reg)) "fstp dword ptr %0\n" 7
|
||||
stmt: ARGF8(reg) "sub esp,8\nfstp qword ptr [esp]\n"
|
||||
stmt: ARGF4(reg) "sub esp,4\nfstp dword ptr [esp]\n"
|
||||
reg: NEGF8(reg) "fchs\n"
|
||||
reg: NEGF4(reg) "fchs\n"
|
||||
flt: memf " %0"
|
||||
flt: reg "p st(1),st"
|
||||
reg: ADDF8(reg,flt) "fadd%1\n"
|
||||
reg: ADDF4(reg,flt) "fadd%1\n"
|
||||
reg: DIVF8(reg,flt) "fdiv%1\n"
|
||||
reg: DIVF4(reg,flt) "fdiv%1\n"
|
||||
reg: MULF8(reg,flt) "fmul%1\n"
|
||||
reg: MULF4(reg,flt) "fmul%1\n"
|
||||
reg: SUBF8(reg,flt) "fsub%1\n"
|
||||
reg: SUBF4(reg,flt) "fsub%1\n"
|
||||
reg: CVFF8(reg) "# CVFF8\n"
|
||||
reg: CVFF4(reg) "sub esp,4\nfstp dword ptr 0[esp]\nfld dword ptr 0[esp]\nadd esp,4\n" 12
|
||||
|
||||
reg: CVFI4(reg) "call __ftol\n" 31
|
||||
reg: CVIF8(INDIRI4(addr)) "fild dword ptr %0\n" 10
|
||||
reg: CVIF4(reg) "push %0\nfild dword ptr 0[esp]\nadd esp,4\n" 12
|
||||
|
||||
reg: CVIF8(reg) "push %0\nfild dword ptr 0[esp]\nadd esp,4\n" 12
|
||||
|
||||
addrj: ADDRGP4 "%a"
|
||||
addrj: reg "%0" 2
|
||||
addrj: mem "%0" 2
|
||||
|
||||
stmt: JUMPV(addrj) "jmp %0\n" 3
|
||||
stmt: LABELV "%a:\n"
|
||||
stmt: EQI4(mem,rc) "cmp %0,%1\nje %a\n" 5
|
||||
stmt: GEI4(mem,rc) "cmp %0,%1\njge %a\n" 5
|
||||
stmt: GTI4(mem,rc) "cmp %0,%1\njg %a\n" 5
|
||||
stmt: LEI4(mem,rc) "cmp %0,%1\njle %a\n" 5
|
||||
stmt: LTI4(mem,rc) "cmp %0,%1\njl %a\n" 5
|
||||
stmt: NEI4(mem,rc) "cmp %0,%1\njne %a\n" 5
|
||||
stmt: GEU4(mem,rc) "cmp %0,%1\njae %a\n" 5
|
||||
stmt: GTU4(mem,rc) "cmp %0,%1\nja %a\n" 5
|
||||
stmt: LEU4(mem,rc) "cmp %0,%1\njbe %a\n" 5
|
||||
stmt: LTU4(mem,rc) "cmp %0,%1\njb %a\n" 5
|
||||
stmt: EQI4(reg,mrc1) "cmp %0,%1\nje %a\n" 4
|
||||
stmt: GEI4(reg,mrc1) "cmp %0,%1\njge %a\n" 4
|
||||
stmt: GTI4(reg,mrc1) "cmp %0,%1\njg %a\n" 4
|
||||
stmt: LEI4(reg,mrc1) "cmp %0,%1\njle %a\n" 4
|
||||
stmt: LTI4(reg,mrc1) "cmp %0,%1\njl %a\n" 4
|
||||
stmt: NEI4(reg,mrc1) "cmp %0,%1\njne %a\n" 4
|
||||
|
||||
stmt: EQU4(reg,mrc1) "cmp %0,%1\nje %a\n" 4
|
||||
stmt: GEU4(reg,mrc1) "cmp %0,%1\njae %a\n" 4
|
||||
stmt: GTU4(reg,mrc1) "cmp %0,%1\nja %a\n" 4
|
||||
stmt: LEU4(reg,mrc1) "cmp %0,%1\njbe %a\n" 4
|
||||
stmt: LTU4(reg,mrc1) "cmp %0,%1\njb %a\n" 4
|
||||
stmt: NEU4(reg,mrc1) "cmp %0,%1\njne %a\n" 4
|
||||
cmpf: memf " %0"
|
||||
cmpf: reg "p"
|
||||
stmt: EQF8(cmpf,reg) "fcomp%0\nfstsw ax\nsahf\nje %a\n"
|
||||
stmt: GEF8(cmpf,reg) "fcomp%0\nfstsw ax\nsahf\njbe %a\n"
|
||||
stmt: GTF8(cmpf,reg) "fcomp%0\nfstsw ax\nsahf\njb %a\n"
|
||||
stmt: LEF8(cmpf,reg) "fcomp%0\nfstsw ax\nsahf\njae %a\n"
|
||||
stmt: LTF8(cmpf,reg) "fcomp%0\nfstsw ax\nsahf\nja %a\n"
|
||||
stmt: NEF8(cmpf,reg) "fcomp%0\nfstsw ax\nsahf\njne %a\n"
|
||||
|
||||
stmt: EQF4(cmpf,reg) "fcomp%0\nfstsw ax\nsahf\nje %a\n"
|
||||
stmt: GEF4(cmpf,reg) "fcomp%0\nfstsw ax\nsahf\njbe %a\n"
|
||||
stmt: GTF4(cmpf,reg) "fcomp%0\nfstsw ax\nsahf\njb %a\n"
|
||||
stmt: LEF4(cmpf,reg) "fcomp%0\nfstsw ax\nsahf\njae %a\n"
|
||||
stmt: LTF4(cmpf,reg) "fcomp%0\nfstsw ax\nsahf\nja %a\n"
|
||||
stmt: NEF4(cmpf,reg) "fcomp%0\nfstsw ax\nsahf\njne %a\n"
|
||||
reg: CALLI4(addrj) "call %0\nadd esp,%a\n"
|
||||
reg: CALLU4(addrj) "call %0\nadd esp,%a\n"
|
||||
reg: CALLP4(addrj) "call %0\nadd esp,%a\n"
|
||||
stmt: CALLV(addrj) "call %0\nadd esp,%a\n"
|
||||
reg: CALLF4(addrj) "call %0\nadd esp,%a\n"
|
||||
reg: CALLF8(addrj) "call %0\nadd esp,%a\n"
|
||||
stmt: CALLF4(addrj) "call %0\nadd esp,%a\nfstp\n"
|
||||
stmt: CALLF8(addrj) "call %0\nadd esp,%a\nfstp\n"
|
||||
|
||||
stmt: RETI4(reg) "# ret\n"
|
||||
stmt: RETU4(reg) "# ret\n"
|
||||
stmt: RETP4(reg) "# ret\n"
|
||||
stmt: RETF4(reg) "# ret\n"
|
||||
stmt: RETF8(reg) "# ret\n"
|
||||
%%
|
||||
static void progbeg(int argc, char *argv[]) {
|
||||
int i;
|
||||
|
||||
{
|
||||
union {
|
||||
char c;
|
||||
int i;
|
||||
} u;
|
||||
u.i = 0;
|
||||
u.c = 1;
|
||||
swap = ((int)(u.i == 1)) != IR->little_endian;
|
||||
}
|
||||
parseflags(argc, argv);
|
||||
intreg[EAX] = mkreg("eax", EAX, 1, IREG);
|
||||
intreg[EDX] = mkreg("edx", EDX, 1, IREG);
|
||||
intreg[ECX] = mkreg("ecx", ECX, 1, IREG);
|
||||
intreg[EBX] = mkreg("ebx", EBX, 1, IREG);
|
||||
intreg[ESI] = mkreg("esi", ESI, 1, IREG);
|
||||
intreg[EDI] = mkreg("edi", EDI, 1, IREG);
|
||||
|
||||
shortreg[EAX] = mkreg("ax", EAX, 1, IREG);
|
||||
shortreg[ECX] = mkreg("cx", ECX, 1, IREG);
|
||||
shortreg[EDX] = mkreg("dx", EDX, 1, IREG);
|
||||
shortreg[EBX] = mkreg("bx", EBX, 1, IREG);
|
||||
shortreg[ESI] = mkreg("si", ESI, 1, IREG);
|
||||
shortreg[EDI] = mkreg("di", EDI, 1, IREG);
|
||||
|
||||
charreg[EAX] = mkreg("al", EAX, 1, IREG);
|
||||
charreg[ECX] = mkreg("cl", ECX, 1, IREG);
|
||||
charreg[EDX] = mkreg("dl", EDX, 1, IREG);
|
||||
charreg[EBX] = mkreg("bl", EBX, 1, IREG);
|
||||
for (i = 0; i < 8; i++)
|
||||
fltreg[i] = mkreg("%d", i, 0, FREG);
|
||||
charregw = mkwildcard(charreg);
|
||||
shortregw = mkwildcard(shortreg);
|
||||
intregw = mkwildcard(intreg);
|
||||
fltregw = mkwildcard(fltreg);
|
||||
|
||||
tmask[IREG] = (1<<EDI) | (1<<ESI) | (1<<EBX)
|
||||
| (1<<EDX) | (1<<ECX) | (1<<EAX);
|
||||
vmask[IREG] = 0;
|
||||
tmask[FREG] = 0xff;
|
||||
vmask[FREG] = 0;
|
||||
print(".486\n");
|
||||
print(".model flat\n");
|
||||
print("extrn __fltused:near\n");
|
||||
print("extrn __ftol:near\n");
|
||||
cseg = 0;
|
||||
quo = mkreg("eax", EAX, 1, IREG);
|
||||
quo->x.regnode->mask |= 1<<EDX;
|
||||
rem = mkreg("edx", EDX, 1, IREG);
|
||||
rem->x.regnode->mask |= 1<<EAX;
|
||||
}
|
||||
static Symbol rmap(int opk) {
|
||||
switch (optype(opk)) {
|
||||
case B: case P:
|
||||
return intregw;
|
||||
case I: case U:
|
||||
if (opsize(opk) == 1)
|
||||
return charregw;
|
||||
else if (opsize(opk) == 2)
|
||||
return shortregw;
|
||||
else
|
||||
return intregw;
|
||||
case F:
|
||||
return fltregw;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
static void segment(int n) {
|
||||
if (n == cseg)
|
||||
return;
|
||||
if (cseg == CODE || cseg == LIT)
|
||||
print("_TEXT ends\n");
|
||||
else if (cseg == DATA || cseg == BSS)
|
||||
print("_DATA ends\n");
|
||||
cseg = n;
|
||||
if (cseg == CODE || cseg == LIT)
|
||||
print("_TEXT segment\n");
|
||||
else if (cseg == DATA || cseg == BSS)
|
||||
print("_DATA segment\n");
|
||||
}
|
||||
static void progend(void) {
|
||||
segment(0);
|
||||
print("end\n");
|
||||
}
|
||||
static void target(Node p) {
|
||||
assert(p);
|
||||
switch (specific(p->op)) {
|
||||
case MUL+U:
|
||||
setreg(p, quo);
|
||||
rtarget(p, 0, intreg[EAX]);
|
||||
break;
|
||||
case DIV+I: case DIV+U:
|
||||
setreg(p, quo);
|
||||
rtarget(p, 0, quo);
|
||||
break;
|
||||
case MOD+I: case MOD+U:
|
||||
setreg(p, rem);
|
||||
rtarget(p, 0, quo);
|
||||
break;
|
||||
case ASGN+B:
|
||||
rtarget(p, 0, intreg[EDI]);
|
||||
rtarget(p->kids[1], 0, intreg[ESI]);
|
||||
break;
|
||||
case ARG+B:
|
||||
rtarget(p->kids[0], 0, intreg[ESI]);
|
||||
break;
|
||||
case CVF+I:
|
||||
setreg(p, intreg[EAX]);
|
||||
break;
|
||||
case CALL+I: case CALL+U: case CALL+P: case CALL+V:
|
||||
setreg(p, intreg[EAX]);
|
||||
break;
|
||||
case RET+I: case RET+U: case RET+P:
|
||||
rtarget(p, 0, intreg[EAX]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void clobber(Node p) {
|
||||
static int nstack = 0;
|
||||
|
||||
assert(p);
|
||||
nstack = ckstack(p, nstack);
|
||||
switch (specific(p->op)) {
|
||||
case RSH+I: case RSH+U: case LSH+I: case LSH+U:
|
||||
if (generic(p->kids[1]->op) != CNST
|
||||
&& !( generic(p->kids[1]->op) == INDIR
|
||||
&& specific(p->kids[1]->kids[0]->op) == VREG+P
|
||||
&& p->kids[1]->syms[RX]->u.t.cse
|
||||
&& generic(p->kids[1]->syms[RX]->u.t.cse->op) == CNST
|
||||
)) {
|
||||
spill(1<<ECX, 1, p);
|
||||
}
|
||||
break;
|
||||
case ASGN+B: case ARG+B:
|
||||
spill(1<<ECX | 1<<ESI | 1<<EDI, IREG, p);
|
||||
break;
|
||||
case EQ+F: case LE+F: case GE+F: case LT+F: case GT+F: case NE+F:
|
||||
spill(1<<EAX, IREG, p);
|
||||
break;
|
||||
case CALL+F:
|
||||
spill(1<<EDX | 1<<EAX | 1<<ECX, IREG, p);
|
||||
break;
|
||||
case CALL+I: case CALL+U: case CALL+P: case CALL+V:
|
||||
spill(1<<EDX | 1<<ECX, IREG, p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#define isfp(p) (optype((p)->op)==F)
|
||||
|
||||
int ckstack(Node p, int n) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NELEMS(p->x.kids) && p->x.kids[i]; i++)
|
||||
if (isfp(p->x.kids[i]))
|
||||
n--;
|
||||
if (isfp(p) && p->count > 0)
|
||||
n++;
|
||||
if (n > 8)
|
||||
error("expression too complicated\n");
|
||||
debug(fprint(stderr, "(ckstack(%x)=%d)\n", p, n));
|
||||
assert(n >= 0);
|
||||
return n;
|
||||
}
|
||||
int memop(Node p) {
|
||||
assert(p);
|
||||
assert(generic(p->op) == ASGN);
|
||||
assert(p->kids[0]);
|
||||
assert(p->kids[1]);
|
||||
if (generic(p->kids[1]->kids[0]->op) == INDIR
|
||||
&& sametree(p->kids[0], p->kids[1]->kids[0]->kids[0]))
|
||||
return 3;
|
||||
else
|
||||
return LBURG_MAX;
|
||||
}
|
||||
int sametree(Node p, Node q) {
|
||||
return p == NULL && q == NULL
|
||||
|| p && q && p->op == q->op && p->syms[0] == q->syms[0]
|
||||
&& sametree(p->kids[0], q->kids[0])
|
||||
&& sametree(p->kids[1], q->kids[1]);
|
||||
}
|
||||
static void emit2(Node p) {
|
||||
int op = specific(p->op);
|
||||
#define preg(f) ((f)[getregnum(p->x.kids[0])]->x.name)
|
||||
|
||||
if (op == CVI+I && opsize(p->op) == 4 && opsize(p->x.kids[0]->op) == 1)
|
||||
print("movsx %s,%s\n", p->syms[RX]->x.name
|
||||
, preg(charreg));
|
||||
else if (op == CVI+U && opsize(p->op) == 4 && opsize(p->x.kids[0]->op) == 1)
|
||||
print("movsx %s,%s\n", p->syms[RX]->x.name
|
||||
, preg(charreg));
|
||||
else if (op == CVI+I && opsize(p->op) == 4 && opsize(p->x.kids[0]->op) == 2)
|
||||
print("movsx %s,%s\n", p->syms[RX]->x.name
|
||||
, preg(shortreg));
|
||||
else if (op == CVI+U && opsize(p->op) == 4 && opsize(p->x.kids[0]->op) == 2)
|
||||
print("movsx %s,%s\n", p->syms[RX]->x.name
|
||||
, preg(shortreg));
|
||||
|
||||
else if (op == CVU+I && opsize(p->op) == 4 && opsize(p->x.kids[0]->op) == 1)
|
||||
print("movzx %s,%s\n", p->syms[RX]->x.name
|
||||
, preg(charreg));
|
||||
else if (op == CVU+U && opsize(p->op) == 4 && opsize(p->x.kids[0]->op) == 1)
|
||||
print("movzx %s,%s\n", p->syms[RX]->x.name
|
||||
, preg(charreg));
|
||||
else if (op == CVU+I && opsize(p->op) == 4 && opsize(p->x.kids[0]->op) == 2)
|
||||
print("movzx %s,%s\n", p->syms[RX]->x.name
|
||||
, preg(shortreg));
|
||||
else if (op == CVU+U && opsize(p->op) == 4 && opsize(p->x.kids[0]->op) == 2)
|
||||
print("movzx %s,%s\n", p->syms[RX]->x.name
|
||||
, preg(shortreg));
|
||||
else if (generic(op) == CVI || generic(op) == CVU || generic(op) == LOAD) {
|
||||
char *dst = intreg[getregnum(p)]->x.name;
|
||||
char *src = preg(intreg);
|
||||
assert(opsize(p->op) <= opsize(p->x.kids[0]->op));
|
||||
if (dst != src)
|
||||
print("mov %s,%s\n", dst, src);
|
||||
}
|
||||
}
|
||||
|
||||
static void doarg(Node p) {
|
||||
assert(p && p->syms[0]);
|
||||
mkactual(4, p->syms[0]->u.c.v.i);
|
||||
}
|
||||
static void blkfetch(int k, int off, int reg, int tmp) {}
|
||||
static void blkstore(int k, int off, int reg, int tmp) {}
|
||||
static void blkloop(int dreg, int doff, int sreg, int soff,
|
||||
int size, int tmps[]) {}
|
||||
static void local(Symbol p) {
|
||||
if (isfloat(p->type))
|
||||
p->sclass = AUTO;
|
||||
if (askregvar(p, (*IR->x.rmap)(ttob(p->type))) == 0)
|
||||
mkauto(p);
|
||||
}
|
||||
static void function(Symbol f, Symbol caller[], Symbol callee[], int n) {
|
||||
int i;
|
||||
|
||||
print("%s:\n", f->x.name);
|
||||
print("push ebx\n");
|
||||
print("push esi\n");
|
||||
print("push edi\n");
|
||||
print("push ebp\n");
|
||||
print("mov ebp,esp\n");
|
||||
usedmask[0] = usedmask[1] = 0;
|
||||
freemask[0] = freemask[1] = ~(unsigned)0;
|
||||
offset = 16 + 4;
|
||||
for (i = 0; callee[i]; i++) {
|
||||
Symbol p = callee[i];
|
||||
Symbol q = caller[i];
|
||||
assert(q);
|
||||
p->x.offset = q->x.offset = offset;
|
||||
p->x.name = q->x.name = stringf("%d", p->x.offset);
|
||||
p->sclass = q->sclass = AUTO;
|
||||
offset += roundup(q->type->size, 4);
|
||||
}
|
||||
assert(caller[i] == 0);
|
||||
offset = maxoffset = 0;
|
||||
gencode(caller, callee);
|
||||
framesize = roundup(maxoffset, 4);
|
||||
if (framesize > 0)
|
||||
print("sub esp,%d\n", framesize);
|
||||
emitcode();
|
||||
print("mov esp,ebp\n");
|
||||
print("pop ebp\n");
|
||||
print("pop edi\n");
|
||||
print("pop esi\n");
|
||||
print("pop ebx\n");
|
||||
print("ret\n");
|
||||
}
|
||||
static void defsymbol(Symbol p) {
|
||||
if (p->scope >= LOCAL && p->sclass == STATIC)
|
||||
p->x.name = stringf("L%d", genlabel(1));
|
||||
else if (p->generated)
|
||||
p->x.name = stringf("L%s", p->name);
|
||||
else if (p->scope == GLOBAL || p->sclass == EXTERN)
|
||||
p->x.name = stringf("_%s", p->name);
|
||||
else if (p->scope == CONSTANTS
|
||||
&& (isint(p->type) || isptr(p->type))
|
||||
&& p->name[0] == '0' && p->name[1] == 'x')
|
||||
p->x.name = stringf("0%sH", &p->name[2]);
|
||||
else
|
||||
p->x.name = p->name;
|
||||
}
|
||||
static void address(Symbol q, Symbol p, long n) {
|
||||
if (p->scope == GLOBAL
|
||||
|| p->sclass == STATIC || p->sclass == EXTERN)
|
||||
q->x.name = stringf("%s%s%D",
|
||||
p->x.name, n >= 0 ? "+" : "", n);
|
||||
else {
|
||||
assert(n <= INT_MAX && n >= INT_MIN);
|
||||
q->x.offset = p->x.offset + n;
|
||||
q->x.name = stringd(q->x.offset);
|
||||
}
|
||||
}
|
||||
static void defconst(int suffix, int size, Value v) {
|
||||
if (suffix == I && size == 1)
|
||||
print("db %d\n", v.u);
|
||||
else if (suffix == I && size == 2)
|
||||
print("dw %d\n", v.i);
|
||||
else if (suffix == I && size == 4)
|
||||
print("dd %d\n", v.i);
|
||||
else if (suffix == U && size == 1)
|
||||
print("db 0%xH\n", v.u);
|
||||
else if (suffix == U && size == 2)
|
||||
print("dw 0%xH\n", v.u);
|
||||
else if (suffix == U && size == 4)
|
||||
print("dd 0%xH\n", v.u);
|
||||
else if (suffix == P && size == 4)
|
||||
print("dd 0%xH\n", v.p);
|
||||
else if (suffix == F && size == 4) {
|
||||
float f = v.d;
|
||||
print("dd 0%xH\n", *(unsigned *)&f);
|
||||
}
|
||||
else if (suffix == F && size == 8) {
|
||||
double d = v.d;
|
||||
unsigned *p = (unsigned *)&d;
|
||||
print("dd 0%xH\ndd 0%xH\n", p[swap], p[!swap]);
|
||||
}
|
||||
else assert(0);
|
||||
}
|
||||
static void defaddress(Symbol p) {
|
||||
print("dd %s\n", p->x.name);
|
||||
}
|
||||
static void defstring(int n, char *str) {
|
||||
char *s;
|
||||
|
||||
for (s = str; s < str + n; s++)
|
||||
print("db %d\n", (*s)&0377);
|
||||
}
|
||||
static void export(Symbol p) {
|
||||
print("public %s\n", p->x.name);
|
||||
}
|
||||
static void import(Symbol p) {
|
||||
int oldseg = cseg;
|
||||
|
||||
if (p->ref > 0) {
|
||||
segment(0);
|
||||
print("extrn %s:near\n", p->x.name);
|
||||
segment(oldseg);
|
||||
}
|
||||
}
|
||||
static void global(Symbol p) {
|
||||
print("align %d\n",
|
||||
p->type->align > 4 ? 4 : p->type->align);
|
||||
print("%s label byte\n", p->x.name);
|
||||
if (p->u.seg == BSS)
|
||||
print("db %d dup (0)\n", p->type->size);
|
||||
}
|
||||
static void space(int n) {
|
||||
if (cseg != BSS)
|
||||
print("db %d dup (0)\n", n);
|
||||
}
|
||||
Interface x86IR = {
|
||||
1, 1, 0, /* char */
|
||||
2, 2, 0, /* short */
|
||||
4, 4, 0, /* int */
|
||||
4, 4, 0, /* long */
|
||||
4, 4, 0, /* long long */
|
||||
4, 4, 1, /* float */
|
||||
8, 4, 1, /* double */
|
||||
8, 4, 1, /* long double */
|
||||
4, 4, 0, /* T * */
|
||||
0, 4, 0, /* struct; so that ARGB keeps stack aligned */
|
||||
1, /* little_endian */
|
||||
0, /* mulops_calls */
|
||||
0, /* wants_callb */
|
||||
1, /* wants_argb */
|
||||
0, /* left_to_right */
|
||||
0, /* wants_dag */
|
||||
0, /* unsigned_char */
|
||||
address,
|
||||
blockbeg,
|
||||
blockend,
|
||||
defaddress,
|
||||
defconst,
|
||||
defstring,
|
||||
defsymbol,
|
||||
emit,
|
||||
export,
|
||||
function,
|
||||
gen,
|
||||
global,
|
||||
import,
|
||||
local,
|
||||
progbeg,
|
||||
progend,
|
||||
segment,
|
||||
space,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
{1, rmap,
|
||||
blkfetch, blkstore, blkloop,
|
||||
_label,
|
||||
_rule,
|
||||
_nts,
|
||||
_kids,
|
||||
_string,
|
||||
_templates,
|
||||
_isinstruction,
|
||||
_ntname,
|
||||
emit2,
|
||||
doarg,
|
||||
target,
|
||||
clobber,
|
||||
}
|
||||
};
|
||||
static char rcsid[] = "$Id: x86.md 145 2001-10-17 21:53:10Z timo $";
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue