remove redundant Compiler::memory scale parameter

This commit is contained in:
Joshua Warner 2014-04-30 23:46:26 -06:00 committed by Joshua Warner
parent f9b781149e
commit 9805ff94b4
3 changed files with 66 additions and 101 deletions

View File

@ -69,8 +69,7 @@ class Compiler {
virtual Operand* memory(Operand* base, virtual Operand* memory(Operand* base,
ir::Type type, ir::Type type,
int displacement = 0, int displacement = 0,
Operand* index = 0, Operand* index = 0) = 0;
unsigned scale = 1) = 0;
virtual Operand* threadRegister() = 0; virtual Operand* threadRegister() = 0;

View File

@ -2320,15 +2320,16 @@ class MyCompiler: public Compiler {
virtual Operand* memory(Operand* base, virtual Operand* memory(Operand* base,
ir::Type type, ir::Type type,
int displacement = 0, int displacement = 0,
Operand* index = 0, Operand* index = 0)
unsigned scale = 1)
{ {
assert(&c, index != 0 || scale == 1);
assert(&c, type.size() == scale || index == 0);
Value* result = value(&c, type); Value* result = value(&c, type);
appendMemory(&c, static_cast<Value*>(base), displacement, appendMemory(&c,
static_cast<Value*>(index), scale, result); static_cast<Value*>(base),
displacement,
static_cast<Value*>(index),
index == 0 ? 1 : type.size(),
result);
return result; return result;
} }

View File

@ -3755,8 +3755,8 @@ intrinsic(MyThread* t, Frame* frame, object target)
{ {
Compiler::Operand* address = popLongAddress(frame); Compiler::Operand* address = popLongAddress(frame);
frame->popObject(); frame->popObject();
frame->pushInt(c->load( frame->pushInt(
1, 1, c->memory(address, types.i4, 0, 0, 1), TargetBytesPerWord)); c->load(1, 1, c->memory(address, types.i4), TargetBytesPerWord));
return true; return true;
} else if (MATCH(methodName(t, target), "putByte") } else if (MATCH(methodName(t, target), "putByte")
and MATCH(methodSpec(t, target), "(JB)V")) and MATCH(methodSpec(t, target), "(JB)V"))
@ -3764,10 +3764,7 @@ intrinsic(MyThread* t, Frame* frame, object target)
Compiler::Operand* value = frame->popInt(); Compiler::Operand* value = frame->popInt();
Compiler::Operand* address = popLongAddress(frame); Compiler::Operand* address = popLongAddress(frame);
frame->popObject(); frame->popObject();
c->store(types.address, c->store(types.address, value, types.i1, c->memory(address, types.i4));
value,
types.i1,
c->memory(address, types.i4, 0, 0, 1));
return true; return true;
} else if ((MATCH(methodName(t, target), "getShort") } else if ((MATCH(methodName(t, target), "getShort")
and MATCH(methodSpec(t, target), "(J)S")) and MATCH(methodSpec(t, target), "(J)S"))
@ -3776,8 +3773,8 @@ intrinsic(MyThread* t, Frame* frame, object target)
{ {
Compiler::Operand* address = popLongAddress(frame); Compiler::Operand* address = popLongAddress(frame);
frame->popObject(); frame->popObject();
frame->pushInt(c->load( frame->pushInt(
2, 2, c->memory(address, types.i4, 0, 0, 1), TargetBytesPerWord)); c->load(2, 2, c->memory(address, types.i4), TargetBytesPerWord));
return true; return true;
} else if ((MATCH(methodName(t, target), "putShort") } else if ((MATCH(methodName(t, target), "putShort")
and MATCH(methodSpec(t, target), "(JS)V")) and MATCH(methodSpec(t, target), "(JS)V"))
@ -3787,10 +3784,7 @@ intrinsic(MyThread* t, Frame* frame, object target)
Compiler::Operand* value = frame->popInt(); Compiler::Operand* value = frame->popInt();
Compiler::Operand* address = popLongAddress(frame); Compiler::Operand* address = popLongAddress(frame);
frame->popObject(); frame->popObject();
c->store(types.address, c->store(types.address, value, types.i2, c->memory(address, types.i4));
value,
types.i2,
c->memory(address, types.i4, 0, 0, 1));
return true; return true;
} else if ((MATCH(methodName(t, target), "getInt") } else if ((MATCH(methodName(t, target), "getInt")
and MATCH(methodSpec(t, target), "(J)I")) and MATCH(methodSpec(t, target), "(J)I"))
@ -3804,10 +3798,7 @@ intrinsic(MyThread* t, Frame* frame, object target)
4, 4,
c->memory(address, c->memory(address,
MATCH(methodName(t, target), "getInt") ? types.i4 MATCH(methodName(t, target), "getInt") ? types.i4
: types.f4, : types.f4),
0,
0,
1),
TargetBytesPerWord)); TargetBytesPerWord));
return true; return true;
} else if ((MATCH(methodName(t, target), "putInt") } else if ((MATCH(methodName(t, target), "putInt")
@ -3820,7 +3811,7 @@ intrinsic(MyThread* t, Frame* frame, object target)
frame->popObject(); frame->popObject();
ir::Type type = MATCH(methodName(t, target), "putInt") ? types.i4 ir::Type type = MATCH(methodName(t, target), "putInt") ? types.i4
: types.f4; : types.f4;
c->store(type, value, type, c->memory(address, type, 0, 0, 1)); c->store(type, value, type, c->memory(address, type));
return true; return true;
} else if ((MATCH(methodName(t, target), "getLong") } else if ((MATCH(methodName(t, target), "getLong")
and MATCH(methodSpec(t, target), "(J)J")) and MATCH(methodSpec(t, target), "(J)J"))
@ -3834,10 +3825,7 @@ intrinsic(MyThread* t, Frame* frame, object target)
8, 8,
c->memory(address, c->memory(address,
MATCH(methodName(t, target), "getLong") ? types.i4 MATCH(methodName(t, target), "getLong") ? types.i4
: types.f4, : types.f4),
0,
0,
1),
8)); 8));
return true; return true;
} else if ((MATCH(methodName(t, target), "putLong") } else if ((MATCH(methodName(t, target), "putLong")
@ -3850,7 +3838,7 @@ intrinsic(MyThread* t, Frame* frame, object target)
frame->popObject(); frame->popObject();
ir::Type type = MATCH(methodName(t, target), "putLong") ? types.i8 ir::Type type = MATCH(methodName(t, target), "putLong") ? types.i8
: types.f8; : types.f8;
c->store(type, value, type, c->memory(address, type, 0, 0, 1)); c->store(type, value, type, c->memory(address, type));
return true; return true;
} else if (MATCH(methodName(t, target), "getAddress") } else if (MATCH(methodName(t, target), "getAddress")
and MATCH(methodSpec(t, target), "(J)J")) and MATCH(methodSpec(t, target), "(J)J"))
@ -3859,7 +3847,7 @@ intrinsic(MyThread* t, Frame* frame, object target)
frame->popObject(); frame->popObject();
frame->pushLong(c->load(TargetBytesPerWord, frame->pushLong(c->load(TargetBytesPerWord,
TargetBytesPerWord, TargetBytesPerWord,
c->memory(address, types.address, 0, 0, 1), c->memory(address, types.address),
8)); 8));
return true; return true;
} else if (MATCH(methodName(t, target), "putAddress") } else if (MATCH(methodName(t, target), "putAddress")
@ -3868,10 +3856,8 @@ intrinsic(MyThread* t, Frame* frame, object target)
Compiler::Operand* value = frame->popLong(); Compiler::Operand* value = frame->popLong();
Compiler::Operand* address = popLongAddress(frame); Compiler::Operand* address = popLongAddress(frame);
frame->popObject(); frame->popObject();
c->store(types.i8, c->store(
value, types.i8, value, types.address, c->memory(address, types.address));
types.address,
c->memory(address, types.address, 0, 0, 1));
return true; return true;
} }
} }
@ -4115,13 +4101,10 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
switch (instruction) { switch (instruction) {
case aaload: case aaload:
frame->pushObject(c->load(TargetBytesPerWord, frame->pushObject(
c->load(TargetBytesPerWord,
TargetBytesPerWord, TargetBytesPerWord,
c->memory(array, c->memory(array, types.object, TargetArrayBody, index),
types.object,
TargetArrayBody,
index,
TargetBytesPerWord),
TargetBytesPerWord)); TargetBytesPerWord));
break; break;
@ -4129,7 +4112,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
frame->pushInt( frame->pushInt(
c->load(4, c->load(4,
4, 4,
c->memory(array, types.f4, TargetArrayBody, index, 4), c->memory(array, types.f4, TargetArrayBody, index),
TargetBytesPerWord)); TargetBytesPerWord));
break; break;
@ -4137,7 +4120,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
frame->pushInt( frame->pushInt(
c->load(4, c->load(4,
4, 4,
c->memory(array, types.i4, TargetArrayBody, index, 4), c->memory(array, types.i4, TargetArrayBody, index),
TargetBytesPerWord)); TargetBytesPerWord));
break; break;
@ -4145,7 +4128,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
frame->pushInt( frame->pushInt(
c->load(1, c->load(1,
1, 1,
c->memory(array, types.i1, TargetArrayBody, index, 1), c->memory(array, types.i1, TargetArrayBody, index),
TargetBytesPerWord)); TargetBytesPerWord));
break; break;
@ -4153,25 +4136,25 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
frame->pushInt( frame->pushInt(
c->loadz(2, c->loadz(2,
2, 2,
c->memory(array, types.i2, TargetArrayBody, index, 2), c->memory(array, types.i2, TargetArrayBody, index),
TargetBytesPerWord)); TargetBytesPerWord));
break; break;
case daload: case daload:
frame->pushLong(c->load( frame->pushLong(c->load(
8, 8, c->memory(array, types.f8, TargetArrayBody, index, 8), 8)); 8, 8, c->memory(array, types.f8, TargetArrayBody, index), 8));
break; break;
case laload: case laload:
frame->pushLong(c->load( frame->pushLong(c->load(
8, 8, c->memory(array, types.i8, TargetArrayBody, index, 8), 8)); 8, 8, c->memory(array, types.i8, TargetArrayBody, index), 8));
break; break;
case saload: case saload:
frame->pushInt( frame->pushInt(
c->load(2, c->load(2,
2, 2,
c->memory(array, types.i2, TargetArrayBody, index, 2), c->memory(array, types.i2, TargetArrayBody, index),
TargetBytesPerWord)); TargetBytesPerWord));
break; break;
} }
@ -4231,21 +4214,21 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
c->store(types.f4, c->store(types.f4,
value, value,
types.f4, types.f4,
c->memory(array, types.f4, TargetArrayBody, index, 4)); c->memory(array, types.f4, TargetArrayBody, index));
break; break;
case iastore: case iastore:
c->store(types.address, c->store(types.address,
value, value,
types.i4, types.i4,
c->memory(array, types.i4, TargetArrayBody, index, 4)); c->memory(array, types.i4, TargetArrayBody, index));
break; break;
case bastore: case bastore:
c->store(types.address, c->store(types.address,
value, value,
types.i1, types.i1,
c->memory(array, types.i1, TargetArrayBody, index, 1)); c->memory(array, types.i1, TargetArrayBody, index));
break; break;
case castore: case castore:
@ -4253,21 +4236,21 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
c->store(types.address, c->store(types.address,
value, value,
types.i2, types.i2,
c->memory(array, types.i2, TargetArrayBody, index, 2)); c->memory(array, types.i2, TargetArrayBody, index));
break; break;
case dastore: case dastore:
c->store(types.f8, c->store(types.f8,
value, value,
types.f8, types.f8,
c->memory(array, types.f8, TargetArrayBody, index, 8)); c->memory(array, types.f8, TargetArrayBody, index));
break; break;
case lastore: case lastore:
c->store(types.i8, c->store(types.i8,
value, value,
types.i8, types.i8,
c->memory(array, types.i8, TargetArrayBody, index, 8)); c->memory(array, types.i8, TargetArrayBody, index));
break; break;
} }
} break; } break;
@ -4335,10 +4318,10 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
} goto next; } goto next;
case arraylength: { case arraylength: {
frame->pushInt(c->load( frame->pushInt(
c->load(TargetBytesPerWord,
TargetBytesPerWord, TargetBytesPerWord,
TargetBytesPerWord, c->memory(frame->popObject(), types.i4, TargetArrayLength),
c->memory(frame->popObject(), types.i4, TargetArrayLength, 0, 1),
TargetBytesPerWord)); TargetBytesPerWord));
} break; } break;
@ -4660,8 +4643,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
frame->pushInt(c->load( frame->pushInt(c->load(
1, 1,
1, 1,
c->memory( c->memory(table, types.i4, targetFieldOffset(context, field)),
table, types.i4, targetFieldOffset(context, field), 0, 1),
TargetBytesPerWord)); TargetBytesPerWord));
break; break;
@ -4669,8 +4651,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
frame->pushInt(c->loadz( frame->pushInt(c->loadz(
2, 2,
2, 2,
c->memory( c->memory(table, types.i4, targetFieldOffset(context, field)),
table, types.i4, targetFieldOffset(context, field), 0, 1),
TargetBytesPerWord)); TargetBytesPerWord));
break; break;
@ -4678,8 +4659,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
frame->pushInt(c->load( frame->pushInt(c->load(
2, 2,
2, 2,
c->memory( c->memory(table, types.i4, targetFieldOffset(context, field)),
table, types.i4, targetFieldOffset(context, field), 0, 1),
TargetBytesPerWord)); TargetBytesPerWord));
break; break;
@ -4687,8 +4667,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
frame->pushInt(c->load( frame->pushInt(c->load(
4, 4,
4, 4,
c->memory( c->memory(table, types.f4, targetFieldOffset(context, field)),
table, types.f4, targetFieldOffset(context, field), 0, 1),
TargetBytesPerWord)); TargetBytesPerWord));
break; break;
@ -4696,8 +4675,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
frame->pushInt(c->load( frame->pushInt(c->load(
4, 4,
4, 4,
c->memory( c->memory(table, types.i4, targetFieldOffset(context, field)),
table, types.i4, targetFieldOffset(context, field), 0, 1),
TargetBytesPerWord)); TargetBytesPerWord));
break; break;
@ -4705,8 +4683,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
frame->pushLong(c->load( frame->pushLong(c->load(
8, 8,
8, 8,
c->memory( c->memory(table, types.f8, targetFieldOffset(context, field)),
table, types.f8, targetFieldOffset(context, field), 0, 1),
8)); 8));
break; break;
@ -4714,8 +4691,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
frame->pushLong(c->load( frame->pushLong(c->load(
8, 8,
8, 8,
c->memory( c->memory(table, types.i8, targetFieldOffset(context, field)),
table, types.i8, targetFieldOffset(context, field), 0, 1),
8)); 8));
break; break;
@ -4723,8 +4699,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
frame->pushObject(c->load( frame->pushObject(c->load(
TargetBytesPerWord, TargetBytesPerWord,
TargetBytesPerWord, TargetBytesPerWord,
c->memory( c->memory(table, types.object, targetFieldOffset(context, field)),
table, types.object, targetFieldOffset(context, field), 0, 1),
TargetBytesPerWord)); TargetBytesPerWord));
break; break;
@ -5202,15 +5177,12 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
unsigned rSize = resultSize(t, methodReturnCode(t, target)); unsigned rSize = resultSize(t, methodReturnCode(t, target));
Compiler::Operand* result = c->stackCall( Compiler::Operand* result = c->stackCall(
c->memory( c->memory(c->binaryOp(lir::And,
c->binaryOp(lir::And,
types.address, types.address,
c->constant(TargetPointerMask, types.i4), c->constant(TargetPointerMask, types.i4),
c->memory(instance, types.object, 0, 0, 1)), c->memory(instance, types.object)),
types.object, types.object,
offset, offset),
0,
1),
tailCall ? Compiler::TailJump : 0, tailCall ? Compiler::TailJump : 0,
frame->trace(0, 0), frame->trace(0, 0),
rSize, rSize,
@ -5833,8 +5805,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
types.address, types.address,
value, value,
types.i1, types.i1,
c->memory( c->memory(table, types.i4, targetFieldOffset(context, field)));
table, types.i4, targetFieldOffset(context, field), 0, 1));
break; break;
case CharField: case CharField:
@ -5843,8 +5814,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
types.address, types.address,
value, value,
types.i2, types.i2,
c->memory( c->memory(table, types.i4, targetFieldOffset(context, field)));
table, types.i4, targetFieldOffset(context, field), 0, 1));
break; break;
case FloatField: case FloatField:
@ -5852,8 +5822,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
types.f4, types.f4,
value, value,
types.f4, types.f4,
c->memory( c->memory(table, types.f4, targetFieldOffset(context, field)));
table, types.f4, targetFieldOffset(context, field), 0, 1));
break; break;
case IntField: case IntField:
@ -5861,8 +5830,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
types.address, types.address,
value, value,
types.i4, types.i4,
c->memory( c->memory(table, types.i4, targetFieldOffset(context, field)));
table, types.i4, targetFieldOffset(context, field), 0, 1));
break; break;
case DoubleField: case DoubleField:
@ -5870,8 +5838,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
types.f8, types.f8,
value, value,
types.f8, types.f8,
c->memory( c->memory(table, types.f4, targetFieldOffset(context, field)));
table, types.f4, targetFieldOffset(context, field), 0, 1));
break; break;
case LongField: case LongField:
@ -5879,8 +5846,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
types.i8, types.i8,
value, value,
types.i8, types.i8,
c->memory( c->memory(table, types.i4, targetFieldOffset(context, field)));
table, types.i4, targetFieldOffset(context, field), 0, 1));
break; break;
case ObjectField: case ObjectField:
@ -6222,8 +6188,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
= c->memory(frame->absoluteAddressOperand(s->start), = c->memory(frame->absoluteAddressOperand(s->start),
types.address, types.address,
0, 0,
normalizedKey, normalizedKey);
TargetBytesPerWord);
c->jmp(c->load(TargetBytesPerWord, c->jmp(c->load(TargetBytesPerWord,
TargetBytesPerWord, TargetBytesPerWord,