more fixes

This commit is contained in:
Ash Wolf 2023-01-13 02:19:29 +00:00
parent 08d21a052b
commit 7a5280b96b
4 changed files with 21 additions and 23 deletions

View File

@ -38,7 +38,7 @@ static void buildinterferencematrix(void) {
PCode *instr; // r29
UInt32 *vec; // r28
PCodeArg *op;
long reg;
int reg;
UInt32 i;
UInt32 j;
@ -76,7 +76,7 @@ static void buildinterferencematrix(void) {
for (op = instr->args, i = instr->argCount; i--; op++) {
if (PC_OP_IS_READ_ANY_REGISTER(op, coloring_class)) {
reg = op->data.reg.reg;
if (bitvectorgetbit(reg, vec) == 0)
if (bitvectorgetbit(op->data.reg.reg, vec) == 0)
op->data.reg.effect |= Effect4;
bitvectorsetbit(reg, vec);
}

View File

@ -1297,7 +1297,6 @@ static void insertlongbranches(SInt32 mask) {
SInt32 optimizefinalbranches(SInt32 codesize) {
PCodeBlock *block;
PCodeBlock *block2;
PCode *instr;
SInt32 offset;
int changed;
@ -1337,9 +1336,9 @@ SInt32 optimizefinalbranches(SInt32 codesize) {
continue;
}
if ((instr->op == PC_BT || instr->op == PC_BF) && instr->args[0].kind == PCOp_LABEL) {
block2 = instr->block;
label = instr->args[0].data.label.label;
if ((instr->op == PC_BT || instr->op == PC_BF) && instr->args[2].kind == PCOp_LABEL) {
PCodeBlock *block2 = instr->block;
label = instr->args[2].data.label.label;
target = targetinstruction(label);
if (label->block->codeOffset == (offset + 4)) {
@ -1414,8 +1413,8 @@ SInt32 optimizefinalbranches(SInt32 codesize) {
!(PCODE_FLAG_SET_T(instr) & (fSideEffects | fLink))
)
{
block2 = instr->block;
label = instr->args[2].data.label.label;
PCodeBlock *block2 = instr->block;
label = instr->args[3].data.label.label;
target = targetinstruction(label);
if (label->block->codeOffset == (offset + 4)) {
@ -1449,7 +1448,7 @@ SInt32 optimizefinalbranches(SInt32 codesize) {
) {
if ((val & 30) == 4)
instr->args[0].data.imm.value = val | 12;
else
else if ((val & 30) == 12)
instr->args[0].data.imm.value = val & 23;
instr->op = PC_BCLR;
instr->argCount = 3;
@ -1470,7 +1469,7 @@ SInt32 optimizefinalbranches(SInt32 codesize) {
) {
if ((val & 30) == 4)
instr->args[0].data.imm.value = val | 12;
else
else if ((val & 30) == 12)
instr->args[0].data.imm.value = val & 23;
instr->op = PC_BCCTR;
instr->argCount = 3;

View File

@ -335,8 +335,9 @@ static void generate_tree(ENode *expr) {
static Object *create_switch_table(void) {
Object *obj;
ObjectList *list;
CaseRange *currange;
UInt32 *outptr;
CaseRange *currange;
SInt32 size;
CInt64 value;
obj = galloc(sizeof(Object));
@ -357,8 +358,9 @@ static Object *create_switch_table(void) {
createIndirect(obj, 0, 0);
obj->type = TYPE(&void_ptr);
obj->u.data.u.switchtable.size = CInt64_GetULong(&range) + 1;
obj->u.data.u.switchtable.data = lalloc(4 * obj->u.data.u.switchtable.size);
size = CInt64_GetULong(&range) + 1;
obj->u.data.u.switchtable.size = size;
obj->u.data.u.switchtable.data = lalloc(4 * size);
currange = caseranges;
outptr = (UInt32 *) obj->u.data.u.switchtable.data;
@ -379,10 +381,10 @@ static Object *create_switch_table(void) {
static void generate_table(ENode *expr, SwitchInfo *info) {
Object *table;
SwitchCase *curcase;
short reg;
short reg2;
short reg3;
SwitchCase *curcase;
Operand op1;
Operand op2;
@ -406,14 +408,12 @@ static void generate_table(ENode *expr, SwitchInfo *info) {
reg = op1.reg;
if (CInt64_NotEqual(first, cint64_zero)) {
SInt32 value;
SInt32 valueext;
reg = ALLOC_GPR();
value = -CInt64_GetULong(&first);
valueext = (SInt16) value;
if (value != valueext) {
if (!FITS_IN_SHORT(value)) {
emitpcode(PC_ADDIS, reg, op1.reg, 0, HIGH_PART(value));
if (value)
emitpcode(PC_ADDI, reg, reg, 0, valueext);
emitpcode(PC_ADDI, reg, reg, 0, LOW_PART(value));
} else {
emitpcode(PC_ADDI, reg, op1.reg, 0, value);
}
@ -427,7 +427,7 @@ static void generate_table(ENode *expr, SwitchInfo *info) {
emitpcode(PC_CMPLI, 0, reg, CInt64_GetULong(&range));
}
branch_conditional(0, EGREATER, 0, defaultlabel);
branch_conditional(0, EGREATER, 1, defaultlabel);
if (table->toc) {
op2.optype = OpndType_Symbol;
op2.object = table->toc;
@ -438,8 +438,7 @@ static void generate_table(ENode *expr, SwitchInfo *info) {
}
if (op2.optype != OpndType_GPR) {
reg2 = ALLOC_GPR();
Coerce_to_register(&op2, TYPE(&void_ptr), reg2);
Coerce_to_register(&op2, TYPE(&void_ptr), reg2 = ALLOC_GPR());
}
if (op2.optype != OpndType_GPR) {

View File

@ -11,8 +11,8 @@
#define FLAG_SET_T(flags) (((flags) & (fIsBranch | fIsCall)) ? (flags) : 0)
#define FLAG_SET_F(flags) (((flags) & (fIsBranch | fIsCall)) ? 0 : (flags))
#define PCODE_FLAG_SET_T(pcode) (((pcode)->flags & (fIsBranch | fIsCall)) ? (pcode)->flags : 0)
#define PCODE_FLAG_SET_F(pcode) (((pcode)->flags & (fIsBranch | fIsCall)) ? 0 : (pcode)->flags)
#define PCODE_FLAG_SET_T(pcode) ((((PCode *) (pcode))->flags & (fIsBranch | fIsCall)) ? ((PCode *) (pcode))->flags : 0)
#define PCODE_FLAG_SET_F(pcode) ((((PCode *) (pcode))->flags & (fIsBranch | fIsCall)) ? 0 : ((PCode *) (pcode))->flags)
enum {
EffectRead = 1,