mirror of https://git.wuffs.org/MWCC
more fixes
This commit is contained in:
parent
08d21a052b
commit
7a5280b96b
|
@ -38,7 +38,7 @@ static void buildinterferencematrix(void) {
|
||||||
PCode *instr; // r29
|
PCode *instr; // r29
|
||||||
UInt32 *vec; // r28
|
UInt32 *vec; // r28
|
||||||
PCodeArg *op;
|
PCodeArg *op;
|
||||||
long reg;
|
int reg;
|
||||||
UInt32 i;
|
UInt32 i;
|
||||||
UInt32 j;
|
UInt32 j;
|
||||||
|
|
||||||
|
@ -76,7 +76,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;
|
reg = op->data.reg.reg;
|
||||||
if (bitvectorgetbit(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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1297,7 +1297,6 @@ static void insertlongbranches(SInt32 mask) {
|
||||||
|
|
||||||
SInt32 optimizefinalbranches(SInt32 codesize) {
|
SInt32 optimizefinalbranches(SInt32 codesize) {
|
||||||
PCodeBlock *block;
|
PCodeBlock *block;
|
||||||
PCodeBlock *block2;
|
|
||||||
PCode *instr;
|
PCode *instr;
|
||||||
SInt32 offset;
|
SInt32 offset;
|
||||||
int changed;
|
int changed;
|
||||||
|
@ -1337,9 +1336,9 @@ SInt32 optimizefinalbranches(SInt32 codesize) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((instr->op == PC_BT || instr->op == PC_BF) && instr->args[0].kind == PCOp_LABEL) {
|
if ((instr->op == PC_BT || instr->op == PC_BF) && instr->args[2].kind == PCOp_LABEL) {
|
||||||
block2 = instr->block;
|
PCodeBlock *block2 = instr->block;
|
||||||
label = instr->args[0].data.label.label;
|
label = instr->args[2].data.label.label;
|
||||||
target = targetinstruction(label);
|
target = targetinstruction(label);
|
||||||
|
|
||||||
if (label->block->codeOffset == (offset + 4)) {
|
if (label->block->codeOffset == (offset + 4)) {
|
||||||
|
@ -1414,8 +1413,8 @@ SInt32 optimizefinalbranches(SInt32 codesize) {
|
||||||
!(PCODE_FLAG_SET_T(instr) & (fSideEffects | fLink))
|
!(PCODE_FLAG_SET_T(instr) & (fSideEffects | fLink))
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
block2 = instr->block;
|
PCodeBlock *block2 = instr->block;
|
||||||
label = instr->args[2].data.label.label;
|
label = instr->args[3].data.label.label;
|
||||||
target = targetinstruction(label);
|
target = targetinstruction(label);
|
||||||
|
|
||||||
if (label->block->codeOffset == (offset + 4)) {
|
if (label->block->codeOffset == (offset + 4)) {
|
||||||
|
@ -1449,7 +1448,7 @@ SInt32 optimizefinalbranches(SInt32 codesize) {
|
||||||
) {
|
) {
|
||||||
if ((val & 30) == 4)
|
if ((val & 30) == 4)
|
||||||
instr->args[0].data.imm.value = val | 12;
|
instr->args[0].data.imm.value = val | 12;
|
||||||
else
|
else if ((val & 30) == 12)
|
||||||
instr->args[0].data.imm.value = val & 23;
|
instr->args[0].data.imm.value = val & 23;
|
||||||
instr->op = PC_BCLR;
|
instr->op = PC_BCLR;
|
||||||
instr->argCount = 3;
|
instr->argCount = 3;
|
||||||
|
@ -1470,7 +1469,7 @@ SInt32 optimizefinalbranches(SInt32 codesize) {
|
||||||
) {
|
) {
|
||||||
if ((val & 30) == 4)
|
if ((val & 30) == 4)
|
||||||
instr->args[0].data.imm.value = val | 12;
|
instr->args[0].data.imm.value = val | 12;
|
||||||
else
|
else if ((val & 30) == 12)
|
||||||
instr->args[0].data.imm.value = val & 23;
|
instr->args[0].data.imm.value = val & 23;
|
||||||
instr->op = PC_BCCTR;
|
instr->op = PC_BCCTR;
|
||||||
instr->argCount = 3;
|
instr->argCount = 3;
|
||||||
|
|
|
@ -335,8 +335,9 @@ static void generate_tree(ENode *expr) {
|
||||||
static Object *create_switch_table(void) {
|
static Object *create_switch_table(void) {
|
||||||
Object *obj;
|
Object *obj;
|
||||||
ObjectList *list;
|
ObjectList *list;
|
||||||
CaseRange *currange;
|
|
||||||
UInt32 *outptr;
|
UInt32 *outptr;
|
||||||
|
CaseRange *currange;
|
||||||
|
SInt32 size;
|
||||||
CInt64 value;
|
CInt64 value;
|
||||||
|
|
||||||
obj = galloc(sizeof(Object));
|
obj = galloc(sizeof(Object));
|
||||||
|
@ -357,8 +358,9 @@ static Object *create_switch_table(void) {
|
||||||
createIndirect(obj, 0, 0);
|
createIndirect(obj, 0, 0);
|
||||||
obj->type = TYPE(&void_ptr);
|
obj->type = TYPE(&void_ptr);
|
||||||
|
|
||||||
obj->u.data.u.switchtable.size = CInt64_GetULong(&range) + 1;
|
size = CInt64_GetULong(&range) + 1;
|
||||||
obj->u.data.u.switchtable.data = lalloc(4 * obj->u.data.u.switchtable.size);
|
obj->u.data.u.switchtable.size = size;
|
||||||
|
obj->u.data.u.switchtable.data = lalloc(4 * size);
|
||||||
|
|
||||||
currange = caseranges;
|
currange = caseranges;
|
||||||
outptr = (UInt32 *) obj->u.data.u.switchtable.data;
|
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) {
|
static void generate_table(ENode *expr, SwitchInfo *info) {
|
||||||
Object *table;
|
Object *table;
|
||||||
|
SwitchCase *curcase;
|
||||||
short reg;
|
short reg;
|
||||||
short reg2;
|
short reg2;
|
||||||
short reg3;
|
short reg3;
|
||||||
SwitchCase *curcase;
|
|
||||||
Operand op1;
|
Operand op1;
|
||||||
Operand op2;
|
Operand op2;
|
||||||
|
|
||||||
|
@ -406,14 +408,12 @@ static void generate_table(ENode *expr, SwitchInfo *info) {
|
||||||
reg = op1.reg;
|
reg = op1.reg;
|
||||||
if (CInt64_NotEqual(first, cint64_zero)) {
|
if (CInt64_NotEqual(first, cint64_zero)) {
|
||||||
SInt32 value;
|
SInt32 value;
|
||||||
SInt32 valueext;
|
|
||||||
reg = ALLOC_GPR();
|
reg = ALLOC_GPR();
|
||||||
value = -CInt64_GetULong(&first);
|
value = -CInt64_GetULong(&first);
|
||||||
valueext = (SInt16) value;
|
if (!FITS_IN_SHORT(value)) {
|
||||||
if (value != valueext) {
|
|
||||||
emitpcode(PC_ADDIS, reg, op1.reg, 0, HIGH_PART(value));
|
emitpcode(PC_ADDIS, reg, op1.reg, 0, HIGH_PART(value));
|
||||||
if (value)
|
if (value)
|
||||||
emitpcode(PC_ADDI, reg, reg, 0, valueext);
|
emitpcode(PC_ADDI, reg, reg, 0, LOW_PART(value));
|
||||||
} else {
|
} else {
|
||||||
emitpcode(PC_ADDI, reg, op1.reg, 0, value);
|
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));
|
emitpcode(PC_CMPLI, 0, reg, CInt64_GetULong(&range));
|
||||||
}
|
}
|
||||||
|
|
||||||
branch_conditional(0, EGREATER, 0, defaultlabel);
|
branch_conditional(0, EGREATER, 1, defaultlabel);
|
||||||
if (table->toc) {
|
if (table->toc) {
|
||||||
op2.optype = OpndType_Symbol;
|
op2.optype = OpndType_Symbol;
|
||||||
op2.object = table->toc;
|
op2.object = table->toc;
|
||||||
|
@ -438,8 +438,7 @@ static void generate_table(ENode *expr, SwitchInfo *info) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (op2.optype != OpndType_GPR) {
|
if (op2.optype != OpndType_GPR) {
|
||||||
reg2 = ALLOC_GPR();
|
Coerce_to_register(&op2, TYPE(&void_ptr), reg2 = ALLOC_GPR());
|
||||||
Coerce_to_register(&op2, TYPE(&void_ptr), reg2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (op2.optype != OpndType_GPR) {
|
if (op2.optype != OpndType_GPR) {
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
#define FLAG_SET_T(flags) (((flags) & (fIsBranch | fIsCall)) ? (flags) : 0)
|
#define FLAG_SET_T(flags) (((flags) & (fIsBranch | fIsCall)) ? (flags) : 0)
|
||||||
#define FLAG_SET_F(flags) (((flags) & (fIsBranch | fIsCall)) ? 0 : (flags))
|
#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_T(pcode) ((((PCode *) (pcode))->flags & (fIsBranch | fIsCall)) ? ((PCode *) (pcode))->flags : 0)
|
||||||
#define PCODE_FLAG_SET_F(pcode) (((pcode)->flags & (fIsBranch | fIsCall)) ? 0 : (pcode)->flags)
|
#define PCODE_FLAG_SET_F(pcode) ((((PCode *) (pcode))->flags & (fIsBranch | fIsCall)) ? 0 : ((PCode *) (pcode))->flags)
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
EffectRead = 1,
|
EffectRead = 1,
|
||||||
|
|
Loading…
Reference in New Issue