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

Subversion Repositories eco32

[/] [eco32/] [tags/] [eco32-0.22/] [lcc/] [etc/] [ops.c] - Diff between revs 4 and 21

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 4 Rev 21
#include "c.h"
#include "c.h"
 
 
/* ops [ {csilhfdxp}=n ]...
/* ops [ {csilhfdxp}=n ]...
 * prints lcc dag operator set for a given set of type sizes.
 * prints lcc dag operator set for a given set of type sizes.
 */
 */
 
 
static char rcsid[] = "$Id: ops.c,v 4.1 2002/08/28 23:12:20 drh Exp $";
static char rcsid[] = "$Id: ops.c,v 4.1 2002/08/28 23:12:20 drh Exp $";
 
 
static char list[] = { 'c', 's', 'i', 'l', 'h', 'f', 'd', 'x', 'p', 0 };
static char list[] = { 'c', 's', 'i', 'l', 'h', 'f', 'd', 'x', 'p', 0 };
static int sizes[] = {  1,   2,   4,   4,   8,   4,   8,  16,   8 };
static int sizes[] = {  1,   2,   4,   4,   8,   4,   8,  16,   8 };
 
 
static int doop(int op, int type, const char *sz, const char *opname) {
static int doop(int op, int type, const char *sz, const char *opname) {
        int count = 0;
        int count = 0;
        static int last;
        static int last;
 
 
        if (op == LOAD)
        if (op == LOAD)
                return 0;
                return 0;
        if (last != 0 && last != op)
        if (last != 0 && last != op)
                printf("\n");
                printf("\n");
        last = op;
        last = op;
        if (type == B || type == V) {
        if (type == B || type == V) {
                printf(" %s=%d", opname, op + type);
                printf(" %s=%d", opname, op + type);
                count++;
                count++;
        } else {
        } else {
                int i, done = 0;
                int i, done = 0;
                const char *s;
                const char *s;
                for (i = 0; sz[i] != '\0' && (s = strchr(list, sz[i])) != NULL; i++) {
                for (i = 0; sz[i] != '\0' && (s = strchr(list, sz[i])) != NULL; i++) {
                        int n = sizes[s-list];
                        int n = sizes[s-list];
                        if ((done&(1<<n)) == 0) {
                        if ((done&(1<<n)) == 0) {
                                printf(" %s%d=%d", opname, n, op + type + sizeop(n));
                                printf(" %s%d=%d", opname, n, op + type + sizeop(n));
                                count++;
                                count++;
                        }
                        }
                        done |= 1<<n;
                        done |= 1<<n;
                }
                }
        }
        }
        printf("\n");
        printf("\n");
        return count;
        return count;
}
}
 
 
int main(int argc, char *argv[]) {
int main(int argc, char *argv[]) {
        int i, count = 0;
        int i, count = 0;
 
 
        for (i = 1; i < argc; i++) {
        for (i = 1; i < argc; i++) {
                char c, *s;
                char c, *s;
                int n;
                int n;
                if (sscanf(argv[i], "%c=%d", &c, &n) == 2
                if (sscanf(argv[i], "%c=%d", &c, &n) == 2
                && n > 0 && (s = strchr(list, c)) != NULL)
                && n > 0 && (s = strchr(list, c)) != NULL)
                        sizes[s-list] = n;
                        sizes[s-list] = n;
                else {
                else {
                        fprintf(stderr, "usage: %s [ {csilhfdxp}=n ]...\n", argv[0]);
                        fprintf(stderr, "usage: %s [ {csilhfdxp}=n ]...\n", argv[0]);
                        exit(EXIT_FAILURE);
                        exit(EXIT_FAILURE);
                }
                }
        }
        }
#define gop(x,n)
#define gop(x,n)
#define op(x,t,s) count += doop(x,t,#s,#x #t);
#define op(x,t,s) count += doop(x,t,#s,#x #t);
#include "ops.h"
#include "ops.h"
#undef gop
#undef gop
#undef op
#undef op
        fprintf(stderr, "%d operators\n", count);
        fprintf(stderr, "%d operators\n", count);
        return EXIT_SUCCESS;
        return EXIT_SUCCESS;
}
}
 
 

powered by: WebSVN 2.1.0

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