From abdf36c87590821230205f354e6e3ce944f4494f Mon Sep 17 00:00:00 2001 From: Bernhard Urban Date: Tue, 18 May 2010 04:45:35 +0200 Subject: [PATCH] codea: schoenerer ansatz bei der registerauswahl --- codea/chelper.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/codea/chelper.c b/codea/chelper.c index 0be9cc3..25893f9 100644 --- a/codea/chelper.c +++ b/codea/chelper.c @@ -8,14 +8,9 @@ #define DDCHELP #endif -#define REGLEN 10 -#if 0 -static char *regs64[] = {"rax", "r10", "r11", "r9", "r8", "rcx", "rdx", "rsi", "rdi"}; -static char *regs8l[] = {"al", "r10b", "r11b", "r9b", "r8b", "cl", "dl", "sil", "dil"}; -#else -static char *regs64[] = {"rax", "r10", "r11", "r9", "rax", "r10", "r11", "rax", "r10", "r11"}; -static char *regs8l[] = {"al", "r10b", "r11b", "r9b", "al", "r10b", "r11b", "al", "r10b", "r11b"}; -#endif +#define REGLEN 4 +static char *regs64[] = {"rax", "r10", "r11", "r9"}; +static char *regs8l[] = {"al", "r10b", "r11b", "r9b"}; void func_header(char *s) { @@ -56,14 +51,13 @@ char *next_reg(char *s, short skip, int params) { int i = 0; if (s != (char*) NULL) { - while(i < REGLEN) { - if(!strcmp(s, regs64[i++])) { - break; - } + while(strcmp(s, regs64[i]) != 0) { + i = (i+1) % REGLEN; } + i = (i+1) % REGLEN; } if(skip) { - i++; + i = (i+1) % REGLEN; } #ifdef DDCHELP fprintf(stderr, "next_reg(): %s (bei %i parameter)\n", regs64[i], params); @@ -83,13 +77,10 @@ char *reg_64to8l(char *s) { int i = 0; if (s != (char*) NULL) { - while(i < REGLEN) { - if(!strcmp(s, regs64[i])) { - return regs8l[i]; - } else { - i++; - } + while(strcmp(s, regs64[i]) != 0) { + i = (i+1) % REGLEN; } + return regs8l[i]; } fprintf(stderr, "reg_64to8l(): sollte nicht passieren\n"); exit(4); -- 2.25.1