More properly keep track of register classes.
This commit is contained in:
parent
b27758b7de
commit
b32883b013
|
@ -3,6 +3,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include "iburg.h"
|
#include "iburg.h"
|
||||||
|
|
||||||
|
|
|
@ -289,6 +289,8 @@ void addregclass(struct reg* reg, const char* id)
|
||||||
p->link = *q;
|
p->link = *q;
|
||||||
*q = p;
|
*q = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reg->classes |= 1<<(p->number);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct regclass* getregclass(const char* id)
|
struct regclass* getregclass(const char* id)
|
||||||
|
@ -437,12 +439,19 @@ static void print(char* fmt, ...)
|
||||||
case 'd':
|
case 'd':
|
||||||
fprintf(outfp, "%d", va_arg(ap, int));
|
fprintf(outfp, "%d", va_arg(ap, int));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'x':
|
||||||
|
fprintf(outfp, "%x", va_arg(ap, uint32_t));
|
||||||
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
fputs(va_arg(ap, char*), outfp);
|
fputs(va_arg(ap, char*), outfp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'P':
|
case 'P':
|
||||||
fprintf(outfp, "%s_", prefix);
|
fprintf(outfp, "%s_", prefix);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'T':
|
case 'T':
|
||||||
{
|
{
|
||||||
Tree t = va_arg(ap, Tree);
|
Tree t = va_arg(ap, Tree);
|
||||||
|
@ -453,15 +462,18 @@ static void print(char* fmt, ...)
|
||||||
print("(%T)", t->left);
|
print("(%T)", t->left);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'R':
|
case 'R':
|
||||||
{
|
{
|
||||||
Rule r = va_arg(ap, Rule);
|
Rule r = va_arg(ap, Rule);
|
||||||
print("%S: %T", r->lhs, r->pattern);
|
print("%S: %T", r->lhs, r->pattern);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'S':
|
case 'S':
|
||||||
fputs(va_arg(ap, Term)->name, outfp);
|
fputs(va_arg(ap, Term)->name, outfp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '1':
|
case '1':
|
||||||
case '2':
|
case '2':
|
||||||
case '3':
|
case '3':
|
||||||
|
@ -473,6 +485,7 @@ static void print(char* fmt, ...)
|
||||||
putc('\t', outfp);
|
putc('\t', outfp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
putc(*fmt, outfp);
|
putc(*fmt, outfp);
|
||||||
break;
|
break;
|
||||||
|
@ -530,14 +543,14 @@ static void emitregisterclasses(struct regclass* rc)
|
||||||
static void emitregisters(struct reg* r)
|
static void emitregisters(struct reg* r)
|
||||||
{
|
{
|
||||||
int k = 0;
|
int k = 0;
|
||||||
print("const char* %Pregister_names[] = {\n");
|
print("const struct %Pregister_data %Pregister_data[] = {\n");
|
||||||
while (r)
|
while (r)
|
||||||
{
|
{
|
||||||
for (; k < r->number; k++)
|
for (; k < r->number; k++)
|
||||||
print("%1NULL,\n");
|
print("%1{ 0 },\n");
|
||||||
k++;
|
k++;
|
||||||
|
|
||||||
print("%1\"%s\",\n", r->name);
|
print("%1{ \"%s\", %d },\n", r->name, r->classes);
|
||||||
r = r->link;
|
r = r->link;
|
||||||
}
|
}
|
||||||
print("};\n\n");
|
print("};\n\n");
|
||||||
|
@ -659,7 +672,7 @@ static void emitdefs(Nonterm nts, int ntnumber)
|
||||||
|
|
||||||
for (p = nts; p; p = p->link)
|
for (p = nts; p; p = p->link)
|
||||||
print("#define %P%S_NT %d\n", p, p->number);
|
print("#define %P%S_NT %d\n", p, p->number);
|
||||||
print("static const int %Pmax_nt = %d;\n\n", ntnumber);
|
print("#define %Pmax_nt %d\n\n", ntnumber);
|
||||||
print("const char *%Pntname[] = {\n%10,\n");
|
print("const char *%Pntname[] = {\n%10,\n");
|
||||||
for (p = nts; p; p = p->link)
|
for (p = nts; p; p = p->link)
|
||||||
print("%1\"%S\",\n", p);
|
print("%1\"%S\",\n", p);
|
||||||
|
|
|
@ -20,6 +20,7 @@ struct reg
|
||||||
const char* name; /* register name */
|
const char* name; /* register name */
|
||||||
Kind kind; /* REG */
|
Kind kind; /* REG */
|
||||||
int number; /* identifying number */
|
int number; /* identifying number */
|
||||||
|
uint32_t classes; // bitfield of classes */
|
||||||
struct reg* link; /* next in list */
|
struct reg* link; /* next in list */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,14 @@ struct burm_instruction_data
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const struct burm_instruction_data burm_instruction_data[];
|
extern const struct burm_instruction_data burm_instruction_data[];
|
||||||
|
|
||||||
|
struct burm_register_data
|
||||||
|
{
|
||||||
|
const char* name;
|
||||||
|
uint32_t classes;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern const struct burm_register_data burm_register_data[];
|
||||||
extern const char* burm_register_class_names[];
|
extern const char* burm_register_class_names[];
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue