mirror of
https://github.com/fail0verflow/switch-coreboot.git
synced 2025-05-04 01:39:18 -04:00
- Small bug fixes to romcc. The deep problems with not inlining functions remain
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@1615 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
parent
596a6674fd
commit
7dea9552d5
2 changed files with 93 additions and 59 deletions
|
@ -7,7 +7,7 @@ makedefine LIBGCC_FILE_NAME := $(shell $(CC) -print-libgcc-file-name)
|
||||||
makedefine GCC_INC_DIR := $(shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
|
makedefine GCC_INC_DIR := $(shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
|
||||||
|
|
||||||
makedefine CPPFLAGS := -I$(TOP)/src/include -I$(TOP)/src/arch/$(ARCH)/include -I$(GCC_INC_DIR) $(CPUFLAGS)
|
makedefine CPPFLAGS := -I$(TOP)/src/include -I$(TOP)/src/arch/$(ARCH)/include -I$(GCC_INC_DIR) $(CPUFLAGS)
|
||||||
makedefine ROMCCPPFLAGS := -D__ROMCC__=0 -D__ROMCC_MINOR__=63
|
makedefine ROMCCPPFLAGS := -D__ROMCC__=0 -D__ROMCC_MINOR__=64
|
||||||
makedefine CFLAGS := $(CPU_OPT) $(CPPFLAGS) -Os -nostdinc -nostdlib -fno-builtin -Wall
|
makedefine CFLAGS := $(CPU_OPT) $(CPPFLAGS) -Os -nostdinc -nostdlib -fno-builtin -Wall
|
||||||
|
|
||||||
makedefine HOSTCFLAGS:= -Os -Wall
|
makedefine HOSTCFLAGS:= -Os -Wall
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
#undef RELEASE_DATE
|
#undef RELEASE_DATE
|
||||||
#undef VERSION
|
#undef VERSION
|
||||||
#define VERSION_MAJOR "0"
|
#define VERSION_MAJOR "0"
|
||||||
#define VERSION_MINOR "63"
|
#define VERSION_MINOR "64"
|
||||||
#define RELEASE_DATE "28 May 2004"
|
#define RELEASE_DATE "28 June 2004"
|
||||||
#define VERSION VERSION_MAJOR "." VERSION_MINOR
|
#define VERSION VERSION_MAJOR "." VERSION_MINOR
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
@ -10014,16 +10014,22 @@ static void simplify_load(struct compile_state *state, struct triple *ins)
|
||||||
(blob->op == OP_BLOBCONST)) {
|
(blob->op == OP_BLOBCONST)) {
|
||||||
unsigned char buffer[SIZEOF_WORD];
|
unsigned char buffer[SIZEOF_WORD];
|
||||||
size_t reg_size, mem_size;
|
size_t reg_size, mem_size;
|
||||||
const char *src;
|
const char *src, *end;
|
||||||
ulong_t val;
|
ulong_t val;
|
||||||
reg_size = reg_size_of(state, ins->type);
|
reg_size = reg_size_of(state, ins->type);
|
||||||
if (reg_size > REG_SIZEOF_REG) {
|
if (reg_size > REG_SIZEOF_REG) {
|
||||||
internal_error(state, ins, "load size greater than register");
|
internal_error(state, ins, "load size greater than register");
|
||||||
}
|
}
|
||||||
mem_size = size_of(state, ins->type);
|
mem_size = size_of(state, ins->type);
|
||||||
|
end = blob->u.blob;
|
||||||
|
end += bits_to_bytes(size_of(state, sdecl->type));
|
||||||
src = blob->u.blob;
|
src = blob->u.blob;
|
||||||
src += addr->u.cval;
|
src += addr->u.cval;
|
||||||
|
|
||||||
|
if (src > end) {
|
||||||
|
error(state, ins, "Load address out of bounds");
|
||||||
|
}
|
||||||
|
|
||||||
memset(buffer, 0, sizeof(buffer));
|
memset(buffer, 0, sizeof(buffer));
|
||||||
memcpy(buffer, src, bits_to_bytes(mem_size));
|
memcpy(buffer, src, bits_to_bytes(mem_size));
|
||||||
|
|
||||||
|
@ -14387,10 +14393,24 @@ static void expand_function_call(
|
||||||
jmp = flatten(state, ret_loc,
|
jmp = flatten(state, ret_loc,
|
||||||
call(state, retvar, ret_addr, func_first, func_last));
|
call(state, retvar, ret_addr, func_first, func_last));
|
||||||
|
|
||||||
|
/* Find the result */
|
||||||
|
if ((rtype->type & TYPE_MASK) != TYPE_VOID) {
|
||||||
|
struct triple * result;
|
||||||
|
result = flatten(state, first,
|
||||||
|
read_expr(state,
|
||||||
|
deref_index(state, fresult(state, func), 1)));
|
||||||
|
|
||||||
|
propogate_use(state, fcall, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Release the original fcall instruction */
|
||||||
|
release_triple(state, fcall);
|
||||||
|
|
||||||
/* Restore the active variables from the result variable */
|
/* Restore the active variables from the result variable */
|
||||||
for(i = 0, set = enclose; set ; set = set->next, i++) {
|
for(i = 0, set = enclose; set ; set = set->next, i++) {
|
||||||
struct triple_set *use, *next;
|
struct triple_set *use, *next;
|
||||||
struct triple *new;
|
struct triple *new;
|
||||||
|
struct basic_blocks bb;
|
||||||
if (!set->member || (set->member == fcall)) {
|
if (!set->member || (set->member == fcall)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -14406,7 +14426,18 @@ static void expand_function_call(
|
||||||
write_expr(state, set->member, new));
|
write_expr(state, set->member, new));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* If the original is a value update the dominated uses */
|
/*
|
||||||
|
* If the original is a value update the dominated uses.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Analyze the basic blocks so I can see who dominates whom */
|
||||||
|
bb.func = me;
|
||||||
|
bb.first = RHS(me, 0);
|
||||||
|
if (!triple_is_ret(state, bb.first->prev)) {
|
||||||
|
bb.func = 0;
|
||||||
|
}
|
||||||
|
analyze_basic_blocks(state, &bb);
|
||||||
|
|
||||||
|
|
||||||
#if DEBUG_EXPLICIT_CLOSURES
|
#if DEBUG_EXPLICIT_CLOSURES
|
||||||
fprintf(state->errout, "Updating domindated uses: %p -> %p\n",
|
fprintf(state->errout, "Updating domindated uses: %p -> %p\n",
|
||||||
|
@ -14424,21 +14455,14 @@ static void expand_function_call(
|
||||||
}
|
}
|
||||||
replace_use(state, set->member, new, use->member);
|
replace_use(state, set->member, new, use->member);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Release the basic blocks, the instructions will be
|
||||||
|
* different next time, and flatten/insert_triple does
|
||||||
|
* not update the block values so I can't cache the analysis.
|
||||||
|
*/
|
||||||
|
free_basic_blocks(state, &bb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find the result */
|
|
||||||
if ((rtype->type & TYPE_MASK) != TYPE_VOID) {
|
|
||||||
struct triple * result;
|
|
||||||
result = flatten(state, first,
|
|
||||||
read_expr(state,
|
|
||||||
deref_index(state, fresult(state, func), 1)));
|
|
||||||
|
|
||||||
propogate_use(state, fcall, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Release the original fcall instruction */
|
|
||||||
release_triple(state, fcall);
|
|
||||||
|
|
||||||
/* Release the closure variable list */
|
/* Release the closure variable list */
|
||||||
free_closure_variables(state, &enclose);
|
free_closure_variables(state, &enclose);
|
||||||
|
|
||||||
|
@ -15008,11 +15032,11 @@ static void find_cf_blocks(struct cf_block *cf, struct block *block)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_control_flow(struct compile_state *state,
|
static void print_control_flow(struct compile_state *state,
|
||||||
struct basic_blocks *bb)
|
FILE *fp, struct basic_blocks *bb)
|
||||||
{
|
{
|
||||||
struct cf_block *cf;
|
struct cf_block *cf;
|
||||||
int i;
|
int i;
|
||||||
printf("\ncontrol flow\n");
|
fprintf(fp, "\ncontrol flow\n");
|
||||||
cf = xcmalloc(sizeof(*cf) * (bb->last_vertex + 1), "cf_block");
|
cf = xcmalloc(sizeof(*cf) * (bb->last_vertex + 1), "cf_block");
|
||||||
find_cf_blocks(cf, bb->first_block);
|
find_cf_blocks(cf, bb->first_block);
|
||||||
|
|
||||||
|
@ -15022,11 +15046,11 @@ static void print_control_flow(struct compile_state *state,
|
||||||
block = cf[i].block;
|
block = cf[i].block;
|
||||||
if (!block)
|
if (!block)
|
||||||
continue;
|
continue;
|
||||||
printf("(%p) %d:", block, block->vertex);
|
fprintf(fp, "(%p) %d:", block, block->vertex);
|
||||||
for(edge = block->edges; edge; edge = edge->next) {
|
for(edge = block->edges; edge; edge = edge->next) {
|
||||||
printf(" %d", edge->member->vertex);
|
fprintf(fp, " %d", edge->member->vertex);
|
||||||
}
|
}
|
||||||
printf("\n");
|
fprintf(fp, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
xfree(cf);
|
xfree(cf);
|
||||||
|
@ -15302,10 +15326,16 @@ static void romcc_print_blocks(struct compile_state *state, FILE *fp)
|
||||||
}
|
}
|
||||||
static void print_blocks(struct compile_state *state, const char *func, FILE *fp)
|
static void print_blocks(struct compile_state *state, const char *func, FILE *fp)
|
||||||
{
|
{
|
||||||
|
static void print_dominators(struct compile_state *state, FILE *fp, struct basic_blocks *bb);
|
||||||
|
static void print_dominance_frontiers(struct compile_state *state, FILE *fp, struct basic_blocks *bb);
|
||||||
if (state->compiler->debug & DEBUG_BASIC_BLOCKS) {
|
if (state->compiler->debug & DEBUG_BASIC_BLOCKS) {
|
||||||
fprintf(fp, "After %s\n", func);
|
fprintf(fp, "After %s\n", func);
|
||||||
romcc_print_blocks(state, fp);
|
romcc_print_blocks(state, fp);
|
||||||
print_control_flow(state, &state->bb);
|
if (state->compiler->debug & DEBUG_FDOMINATORS) {
|
||||||
|
print_dominators(state, fp, &state->bb);
|
||||||
|
print_dominance_frontiers(state, fp, &state->bb);
|
||||||
|
}
|
||||||
|
print_control_flow(state, fp, &state->bb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15885,7 +15915,7 @@ static void print_dominators(struct compile_state *state, FILE *fp, struct basic
|
||||||
|
|
||||||
|
|
||||||
static int print_frontiers(
|
static int print_frontiers(
|
||||||
struct compile_state *state, struct block *block, int vertex)
|
struct compile_state *state, FILE *fp, struct block *block, int vertex)
|
||||||
{
|
{
|
||||||
struct block_set *user, *edge;
|
struct block_set *user, *edge;
|
||||||
|
|
||||||
|
@ -15894,22 +15924,22 @@ static int print_frontiers(
|
||||||
}
|
}
|
||||||
vertex += 1;
|
vertex += 1;
|
||||||
|
|
||||||
printf("%d:", block->vertex);
|
fprintf(fp, "%d:", block->vertex);
|
||||||
for(user = block->domfrontier; user; user = user->next) {
|
for(user = block->domfrontier; user; user = user->next) {
|
||||||
printf(" %d", user->member->vertex);
|
fprintf(fp, " %d", user->member->vertex);
|
||||||
}
|
}
|
||||||
printf("\n");
|
fprintf(fp, "\n");
|
||||||
|
|
||||||
for(edge = block->edges; edge; edge = edge->next) {
|
for(edge = block->edges; edge; edge = edge->next) {
|
||||||
vertex = print_frontiers(state, edge->member, vertex);
|
vertex = print_frontiers(state, fp, edge->member, vertex);
|
||||||
}
|
}
|
||||||
return vertex;
|
return vertex;
|
||||||
}
|
}
|
||||||
static void print_dominance_frontiers(struct compile_state *state,
|
static void print_dominance_frontiers(struct compile_state *state,
|
||||||
struct basic_blocks *bb)
|
FILE *fp, struct basic_blocks *bb)
|
||||||
{
|
{
|
||||||
printf("\ndominance frontiers\n");
|
fprintf(fp, "\ndominance frontiers\n");
|
||||||
print_frontiers(state, bb->first_block, 0);
|
print_frontiers(state, fp, bb->first_block, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15922,8 +15952,8 @@ static void analyze_idominators(struct compile_state *state, struct basic_blocks
|
||||||
/* If debuging print the print what I have just found */
|
/* If debuging print the print what I have just found */
|
||||||
if (state->compiler->debug & DEBUG_FDOMINATORS) {
|
if (state->compiler->debug & DEBUG_FDOMINATORS) {
|
||||||
print_dominators(state, state->dbgout, bb);
|
print_dominators(state, state->dbgout, bb);
|
||||||
print_dominance_frontiers(state, bb);
|
print_dominance_frontiers(state, state->dbgout, bb);
|
||||||
print_control_flow(state, bb);
|
print_control_flow(state, state->dbgout, bb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15952,7 +15982,7 @@ static void print_ipdominators(struct compile_state *state, FILE *fp,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int print_pfrontiers(
|
static int print_pfrontiers(
|
||||||
struct compile_state *state, struct block *block, int vertex)
|
struct compile_state *state, FILE *fp, struct block *block, int vertex)
|
||||||
{
|
{
|
||||||
struct block_set *user;
|
struct block_set *user;
|
||||||
|
|
||||||
|
@ -15961,21 +15991,21 @@ static int print_pfrontiers(
|
||||||
}
|
}
|
||||||
vertex += 1;
|
vertex += 1;
|
||||||
|
|
||||||
printf("%d:", block->vertex);
|
fprintf(fp, "%d:", block->vertex);
|
||||||
for(user = block->ipdomfrontier; user; user = user->next) {
|
for(user = block->ipdomfrontier; user; user = user->next) {
|
||||||
printf(" %d", user->member->vertex);
|
fprintf(fp, " %d", user->member->vertex);
|
||||||
}
|
}
|
||||||
printf("\n");
|
fprintf(fp, "\n");
|
||||||
for(user = block->use; user; user = user->next) {
|
for(user = block->use; user; user = user->next) {
|
||||||
vertex = print_pfrontiers(state, user->member, vertex);
|
vertex = print_pfrontiers(state, fp, user->member, vertex);
|
||||||
}
|
}
|
||||||
return vertex;
|
return vertex;
|
||||||
}
|
}
|
||||||
static void print_ipdominance_frontiers(struct compile_state *state,
|
static void print_ipdominance_frontiers(struct compile_state *state,
|
||||||
struct basic_blocks *bb)
|
FILE *fp, struct basic_blocks *bb)
|
||||||
{
|
{
|
||||||
printf("\nipdominance frontiers\n");
|
fprintf(fp, "\nipdominance frontiers\n");
|
||||||
print_pfrontiers(state, bb->last_block, 0);
|
print_pfrontiers(state, fp, bb->last_block, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15989,8 +16019,8 @@ static void analyze_ipdominators(struct compile_state *state,
|
||||||
/* If debuging print the print what I have just found */
|
/* If debuging print the print what I have just found */
|
||||||
if (state->compiler->debug & DEBUG_RDOMINATORS) {
|
if (state->compiler->debug & DEBUG_RDOMINATORS) {
|
||||||
print_ipdominators(state, state->dbgout, bb);
|
print_ipdominators(state, state->dbgout, bb);
|
||||||
print_ipdominance_frontiers(state, bb);
|
print_ipdominance_frontiers(state, state->dbgout, bb);
|
||||||
print_control_flow(state, bb);
|
print_control_flow(state, state->dbgout, bb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16015,6 +16045,9 @@ static int tdominates(struct compile_state *state,
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
struct triple *ins;
|
struct triple *ins;
|
||||||
|
if (!bdom || !bsub) {
|
||||||
|
internal_error(state, dom, "huh?");
|
||||||
|
}
|
||||||
ins = sub;
|
ins = sub;
|
||||||
while((ins != bsub->first) && (ins != dom)) {
|
while((ins != bsub->first) && (ins != dom)) {
|
||||||
ins = ins->prev;
|
ins = ins->prev;
|
||||||
|
@ -18962,6 +18995,7 @@ static void print_interference_ins(
|
||||||
struct reg_state *rstate = arg;
|
struct reg_state *rstate = arg;
|
||||||
struct live_range *lr;
|
struct live_range *lr;
|
||||||
unsigned id;
|
unsigned id;
|
||||||
|
FILE *fp = state->dbgout;
|
||||||
|
|
||||||
lr = rstate->lrd[ins->id].lr;
|
lr = rstate->lrd[ins->id].lr;
|
||||||
id = ins->id;
|
id = ins->id;
|
||||||
|
@ -18972,38 +19006,38 @@ static void print_interference_ins(
|
||||||
|
|
||||||
if (lr->defs) {
|
if (lr->defs) {
|
||||||
struct live_range_def *lrd;
|
struct live_range_def *lrd;
|
||||||
printf(" range:");
|
fprintf(fp, " range:");
|
||||||
lrd = lr->defs;
|
lrd = lr->defs;
|
||||||
do {
|
do {
|
||||||
printf(" %-10p", lrd->def);
|
fprintf(fp, " %-10p", lrd->def);
|
||||||
lrd = lrd->next;
|
lrd = lrd->next;
|
||||||
} while(lrd != lr->defs);
|
} while(lrd != lr->defs);
|
||||||
printf("\n");
|
fprintf(fp, "\n");
|
||||||
}
|
}
|
||||||
if (live) {
|
if (live) {
|
||||||
struct triple_reg_set *entry;
|
struct triple_reg_set *entry;
|
||||||
printf(" live:");
|
fprintf(fp, " live:");
|
||||||
for(entry = live; entry; entry = entry->next) {
|
for(entry = live; entry; entry = entry->next) {
|
||||||
printf(" %-10p", entry->member);
|
fprintf(fp, " %-10p", entry->member);
|
||||||
}
|
}
|
||||||
printf("\n");
|
fprintf(fp, "\n");
|
||||||
}
|
}
|
||||||
if (lr->edges) {
|
if (lr->edges) {
|
||||||
struct live_range_edge *entry;
|
struct live_range_edge *entry;
|
||||||
printf(" edges:");
|
fprintf(fp, " edges:");
|
||||||
for(entry = lr->edges; entry; entry = entry->next) {
|
for(entry = lr->edges; entry; entry = entry->next) {
|
||||||
struct live_range_def *lrd;
|
struct live_range_def *lrd;
|
||||||
lrd = entry->node->defs;
|
lrd = entry->node->defs;
|
||||||
do {
|
do {
|
||||||
printf(" %-10p", lrd->def);
|
fprintf(fp, " %-10p", lrd->def);
|
||||||
lrd = lrd->next;
|
lrd = lrd->next;
|
||||||
} while(lrd != entry->node->defs);
|
} while(lrd != entry->node->defs);
|
||||||
printf("|");
|
fprintf(fp, "|");
|
||||||
}
|
}
|
||||||
printf("\n");
|
fprintf(fp, "\n");
|
||||||
}
|
}
|
||||||
if (triple_is_branch(state, ins)) {
|
if (triple_is_branch(state, ins)) {
|
||||||
printf("\n");
|
fprintf(fp, "\n");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -19929,7 +19963,7 @@ static void ids_from_rstate(struct compile_state *state,
|
||||||
if (state->compiler->debug & DEBUG_INTERFERENCE) {
|
if (state->compiler->debug & DEBUG_INTERFERENCE) {
|
||||||
FILE *fp = state->dbgout;
|
FILE *fp = state->dbgout;
|
||||||
print_interference_blocks(state, rstate, fp, 0);
|
print_interference_blocks(state, rstate, fp, 0);
|
||||||
print_control_flow(state, &state->bb);
|
print_control_flow(state, fp, &state->bb);
|
||||||
fflush(fp);
|
fflush(fp);
|
||||||
}
|
}
|
||||||
first = state->first;
|
first = state->first;
|
||||||
|
@ -20042,7 +20076,7 @@ static void allocate_registers(struct compile_state *state)
|
||||||
/* Display the interference graph if desired */
|
/* Display the interference graph if desired */
|
||||||
if (state->compiler->debug & DEBUG_INTERFERENCE) {
|
if (state->compiler->debug & DEBUG_INTERFERENCE) {
|
||||||
print_interference_blocks(state, &rstate, state->dbgout, 1);
|
print_interference_blocks(state, &rstate, state->dbgout, 1);
|
||||||
printf("\nlive variables by instruction\n");
|
fprintf(state->dbgout, "\nlive variables by instruction\n");
|
||||||
walk_variable_lifetimes(
|
walk_variable_lifetimes(
|
||||||
state, &state->bb, rstate.blocks,
|
state, &state->bb, rstate.blocks,
|
||||||
print_interference_ins, &rstate);
|
print_interference_ins, &rstate);
|
||||||
|
@ -21293,11 +21327,11 @@ static void verify_domination(struct compile_state *state)
|
||||||
!tdominates(state, ins, use_point)) {
|
!tdominates(state, ins, use_point)) {
|
||||||
if (is_const(ins)) {
|
if (is_const(ins)) {
|
||||||
internal_warning(state, ins,
|
internal_warning(state, ins,
|
||||||
"non dominated rhs use point?");
|
"non dominated rhs use point %p?", use_point);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
internal_error(state, ins,
|
internal_error(state, ins,
|
||||||
"non dominated rhs use point?");
|
"non dominated rhs use point %p?", use_point);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue