a little more cleanup

This commit is contained in:
Ash Wolf 2023-01-14 13:23:03 +00:00
parent 5f3c8265f2
commit 86a48bfea1
2 changed files with 9 additions and 23 deletions

View File

@ -309,30 +309,24 @@ static int addresspropagatestouse(int candidateID, int useID) {
if (candidate_pcode->block == use_pcode->block && precedes(candidate_pcode, use_pcode)) { if (candidate_pcode->block == use_pcode->block && precedes(candidate_pcode, use_pcode)) {
for (scan = candidate_pcode->nextPCode; scan && scan != use_pcode; scan = scan->nextPCode) { for (scan = candidate_pcode->nextPCode; scan && scan != use_pcode; scan = scan->nextPCode) {
op = scan->args; for (op = scan->args, i = scan->argCount; i--; op++) {
i = scan->argCount;
while (i--) {
if (op->kind == PCOp_REGISTER && if (op->kind == PCOp_REGISTER &&
op->arg == RegClass_GPR && op->arg == RegClass_GPR &&
(op->data.reg.effect & EffectWrite) && (op->data.reg.effect & EffectWrite) &&
op->data.reg.reg == reg) op->data.reg.reg == reg)
return 1; return 1;
op++;
} }
} }
} else { } else {
if (!bitvectorgetbit(candidateID, propinfo[use_pcode->block->blockIndex].vec8)) { if (!bitvectorgetbit(candidateID, propinfo[use_pcode->block->blockIndex].vec8)) {
if (bitvectorgetbit(candidate_pcode->defID, usedefinfo[use_pcode->block->blockIndex].defvec8)) { if (bitvectorgetbit(candidate_pcode->defID, usedefinfo[use_pcode->block->blockIndex].defvec8)) {
for (scan = use_pcode->block->firstPCode; scan && scan != use_pcode; scan = scan->nextPCode) { for (scan = use_pcode->block->firstPCode; scan && scan != use_pcode; scan = scan->nextPCode) {
op = scan->args; for (op = scan->args, i = scan->argCount; i--; op++) {
i = scan->argCount;
while (i--) {
if (op->kind == PCOp_REGISTER && if (op->kind == PCOp_REGISTER &&
op->arg == RegClass_GPR && op->arg == RegClass_GPR &&
(op->data.reg.effect & EffectWrite) && (op->data.reg.effect & EffectWrite) &&
op->data.reg.reg == reg) op->data.reg.reg == reg)
return 1; return 1;
op++;
} }
} }
} else { } else {
@ -343,15 +337,12 @@ static int addresspropagatestouse(int candidateID, int useID) {
for (scan = use_pcode->block->firstPCode; scan; scan = scan->nextPCode) { for (scan = use_pcode->block->firstPCode; scan; scan = scan->nextPCode) {
if (scan == use_pcode) if (scan == use_pcode)
break; break;
op = scan->args; for (op = scan->args, i = scan->argCount; i--; op++) {
i = scan->argCount;
while (i--) {
if (op->kind == PCOp_REGISTER && if (op->kind == PCOp_REGISTER &&
op->arg == RegClass_GPR && op->arg == RegClass_GPR &&
(op->data.reg.effect & EffectWrite) && (op->data.reg.effect & EffectWrite) &&
op->data.reg.reg == reg) op->data.reg.reg == reg)
return 1; return 1;
op++;
} }
} }
} }
@ -538,7 +529,7 @@ void gather_alias_info(void) {
if ( if (
(!(pcode->flags & (fIsWrite | fPCodeFlag40000)) || op != pcode->args) && (!(pcode->flags & (fIsWrite | fPCodeFlag40000)) || op != pcode->args) &&
op->kind == PCOp_REGISTER && op->kind == PCOp_REGISTER &&
(RegClass) op->arg == RegClass_GPR && op->arg == RegClass_GPR &&
(op->data.reg.effect & EffectRead) (op->data.reg.effect & EffectRead)
) { ) {
alias_array[aliases_idx] = NULL; alias_array[aliases_idx] = NULL;

View File

@ -33,16 +33,14 @@ int interferes(UInt32 a, UInt32 b) {
} }
static void buildinterferencematrix(void) { static void buildinterferencematrix(void) {
UInt32 regs; // r31
PCodeBlock *block; // r30 PCodeBlock *block; // r30
PCode *instr; // r29 PCode *instr; // r29
UInt32 *vec; // r28
PCodeArg *op; PCodeArg *op;
int reg; UInt32 *vec; // r28
UInt32 i; UInt32 i;
UInt32 j; UInt32 j;
regs = used_virtual_registers[coloring_class]; UInt32 regs = used_virtual_registers[coloring_class];
interferencematrix = oalloc(4 * ((((regs * regs) / 2) + 31) >> 5)); interferencematrix = oalloc(4 * ((((regs * regs) / 2) + 31) >> 5));
bitvectorinitialize(interferencematrix, (regs * regs) / 2, 0); bitvectorinitialize(interferencematrix, (regs * regs) / 2, 0);
@ -57,7 +55,7 @@ static void buildinterferencematrix(void) {
for (instr = block->lastPCode; instr; instr = instr->prevPCode) { for (instr = block->lastPCode; instr; instr = instr->prevPCode) {
for (op = instr->args, i = instr->argCount; i--; op++) { for (op = instr->args, i = instr->argCount; i--; op++) {
if (PC_OP_IS_WRITE_ANY_REGISTER(op, coloring_class)) { if (PC_OP_IS_WRITE_ANY_REGISTER(op, coloring_class)) {
reg = op->data.reg.reg; int reg = op->data.reg.reg;
bitvectorclearbit(reg, vec); bitvectorclearbit(reg, vec);
for (j = 0; j < regs; j++) { for (j = 0; j < regs; j++) {
if (bitvectorgetbit(j, vec)) { if (bitvectorgetbit(j, vec)) {
@ -75,7 +73,7 @@ static void buildinterferencematrix(void) {
for (op = instr->args, i = instr->argCount; i--; op++) { for (op = instr->args, i = instr->argCount; i--; op++) {
if (PC_OP_IS_READ_ANY_REGISTER(op, coloring_class)) { if (PC_OP_IS_READ_ANY_REGISTER(op, coloring_class)) {
reg = op->data.reg.reg; int reg = op->data.reg.reg;
if (bitvectorgetbit(op->data.reg.reg, vec) == 0) if (bitvectorgetbit(op->data.reg.reg, vec) == 0)
op->data.reg.effect |= Effect4; op->data.reg.effect |= Effect4;
bitvectorsetbit(reg, vec); bitvectorsetbit(reg, vec);
@ -124,14 +122,11 @@ static void buildinterferencematrix(void) {
CError_ASSERT(226, i <= instr->argCount); CError_ASSERT(226, i <= instr->argCount);
} }
op = instr->args + i; for (op = instr->args + i; i < instr->argCount; i++, op++) {
while (i < instr->argCount) {
if (op->kind == PCOp_REGISTER && op->arg == RegClass_GPR) { if (op->kind == PCOp_REGISTER && op->arg == RegClass_GPR) {
for (j = 0; j < n_scratch_registers[coloring_class]; j++) for (j = 0; j < n_scratch_registers[coloring_class]; j++)
makeinterfere(op->data.reg.reg, scratch_registers[coloring_class][j]); makeinterfere(op->data.reg.reg, scratch_registers[coloring_class][j]);
} }
i++;
op++;
} }
} }
} }