OpenCores
URL https://opencores.org/ocsvn/eco32/eco32/trunk

Subversion Repositories eco32

[/] [eco32/] [trunk/] [lcc/] [etc/] [ops.c] - Blame information for rev 130

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 hellwig
#include "c.h"
2
 
3
/* ops [ {csilhfdxp}=n ]...
4
 * prints lcc dag operator set for a given set of type sizes.
5
 */
6
 
7
static char rcsid[] = "$Id: ops.c,v 4.1 2002/08/28 23:12:20 drh Exp $";
8
 
9
static char list[] = { 'c', 's', 'i', 'l', 'h', 'f', 'd', 'x', 'p', 0 };
10
static int sizes[] = {  1,   2,   4,   4,   8,   4,   8,  16,   8 };
11
 
12
static int doop(int op, int type, const char *sz, const char *opname) {
13
        int count = 0;
14
        static int last;
15
 
16
        if (op == LOAD)
17
                return 0;
18
        if (last != 0 && last != op)
19
                printf("\n");
20
        last = op;
21
        if (type == B || type == V) {
22
                printf(" %s=%d", opname, op + type);
23
                count++;
24
        } else {
25
                int i, done = 0;
26
                const char *s;
27
                for (i = 0; sz[i] != '\0' && (s = strchr(list, sz[i])) != NULL; i++) {
28
                        int n = sizes[s-list];
29
                        if ((done&(1<<n)) == 0) {
30
                                printf(" %s%d=%d", opname, n, op + type + sizeop(n));
31
                                count++;
32
                        }
33
                        done |= 1<<n;
34
                }
35
        }
36
        printf("\n");
37
        return count;
38
}
39
 
40
int main(int argc, char *argv[]) {
41
        int i, count = 0;
42
 
43
        for (i = 1; i < argc; i++) {
44
                char c, *s;
45
                int n;
46
                if (sscanf(argv[i], "%c=%d", &c, &n) == 2
47
                && n > 0 && (s = strchr(list, c)) != NULL)
48
                        sizes[s-list] = n;
49
                else {
50
                        fprintf(stderr, "usage: %s [ {csilhfdxp}=n ]...\n", argv[0]);
51
                        exit(EXIT_FAILURE);
52
                }
53
        }
54
#define gop(x,n)
55
#define op(x,t,s) count += doop(x,t,#s,#x #t);
56
#include "ops.h"
57
#undef gop
58
#undef op
59
        fprintf(stderr, "%d operators\n", count);
60
        return EXIT_SUCCESS;
61
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.