mirror of
https://github.com/corda/corda.git
synced 2025-06-01 15:10:54 +00:00
switch Compiler::load* to use ir::Type rather than sizes
This commit is contained in:
parent
9c98986f99
commit
27ea503233
@ -110,10 +110,14 @@ class Compiler {
|
|||||||
virtual void store(ir::Type srcType,
|
virtual void store(ir::Type srcType,
|
||||||
Operand* src,
|
Operand* src,
|
||||||
Operand* dst) = 0;
|
Operand* dst) = 0;
|
||||||
virtual Operand* load(unsigned srcSize, unsigned srcSelectSize, Operand* src,
|
virtual Operand* load(ir::Type srcType,
|
||||||
unsigned dstSize) = 0;
|
ir::Type srcSelectType,
|
||||||
virtual Operand* loadz(unsigned size, unsigned srcSelectSize, Operand* src,
|
Operand* src,
|
||||||
unsigned dstSize) = 0;
|
ir::Type dstType) = 0;
|
||||||
|
virtual Operand* loadz(ir::Type srcType,
|
||||||
|
ir::Type srcSelectType,
|
||||||
|
Operand* src,
|
||||||
|
ir::Type dstType) = 0;
|
||||||
|
|
||||||
virtual void condJump(lir::TernaryOperation op,
|
virtual void condJump(lir::TernaryOperation op,
|
||||||
unsigned size,
|
unsigned size,
|
||||||
|
@ -2626,25 +2626,39 @@ class MyCompiler: public Compiler {
|
|||||||
static_cast<Value*>(dst));
|
static_cast<Value*>(dst));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Operand* load(unsigned srcSize, unsigned srcSelectSize, Operand* src,
|
virtual Operand* load(ir::Type srcType,
|
||||||
unsigned dstSize)
|
ir::Type srcSelectType,
|
||||||
|
Operand* src,
|
||||||
|
ir::Type dstType)
|
||||||
{
|
{
|
||||||
assert(&c, dstSize >= TargetBytesPerWord);
|
assert(&c, dstType.size() >= TargetBytesPerWord);
|
||||||
|
|
||||||
Value* dst = value(&c, static_cast<Value*>(src)->type);
|
Value* dst = value(&c, static_cast<Value*>(src)->type);
|
||||||
appendMove(&c, lir::Move, srcSize, srcSelectSize, static_cast<Value*>(src),
|
appendMove(&c,
|
||||||
dstSize, dst);
|
lir::Move,
|
||||||
|
srcType.size(),
|
||||||
|
srcSelectType.size(),
|
||||||
|
static_cast<Value*>(src),
|
||||||
|
dstType.size(),
|
||||||
|
dst);
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Operand* loadz(unsigned srcSize, unsigned srcSelectSize,
|
virtual Operand* loadz(ir::Type srcType,
|
||||||
Operand* src, unsigned dstSize)
|
ir::Type srcSelectType,
|
||||||
|
Operand* src,
|
||||||
|
ir::Type dstType)
|
||||||
{
|
{
|
||||||
assert(&c, dstSize >= TargetBytesPerWord);
|
assert(&c, dstType.size() >= TargetBytesPerWord);
|
||||||
|
|
||||||
Value* dst = value(&c, static_cast<Value*>(src)->type);
|
Value* dst = value(&c, static_cast<Value*>(src)->type);
|
||||||
appendMove(&c, lir::MoveZ, srcSize, srcSelectSize, static_cast<Value*>(src),
|
appendMove(&c,
|
||||||
dstSize, dst);
|
lir::MoveZ,
|
||||||
|
srcType.size(),
|
||||||
|
srcSelectType.size(),
|
||||||
|
static_cast<Value*>(src),
|
||||||
|
dstType.size(),
|
||||||
|
dst);
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
163
src/compile.cpp
163
src/compile.cpp
@ -3702,8 +3702,11 @@ floatBranch(MyThread* t, Frame* frame, object code, unsigned& ip,
|
|||||||
Compiler::Operand*
|
Compiler::Operand*
|
||||||
popLongAddress(Frame* frame)
|
popLongAddress(Frame* frame)
|
||||||
{
|
{
|
||||||
return TargetBytesPerWord == 8 ? frame->popLong() : frame->c->load
|
ir::Types types(TargetBytesPerWord);
|
||||||
(8, 8, frame->popLong(), TargetBytesPerWord);
|
return TargetBytesPerWord == 8
|
||||||
|
? frame->popLong()
|
||||||
|
: frame->c->load(
|
||||||
|
types.i8, types.i8, frame->popLong(), types.address);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -3744,8 +3747,8 @@ intrinsic(MyThread* t, Frame* frame, object target)
|
|||||||
{
|
{
|
||||||
Compiler::Operand* address = popLongAddress(frame);
|
Compiler::Operand* address = popLongAddress(frame);
|
||||||
frame->popObject();
|
frame->popObject();
|
||||||
frame->pushInt(
|
frame->pushInt(c->load(
|
||||||
c->load(1, 1, c->memory(address, types.i1), TargetBytesPerWord));
|
types.i1, types.i1, c->memory(address, types.i1), types.address));
|
||||||
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"))
|
||||||
@ -3762,8 +3765,8 @@ intrinsic(MyThread* t, Frame* frame, object target)
|
|||||||
{
|
{
|
||||||
Compiler::Operand* address = popLongAddress(frame);
|
Compiler::Operand* address = popLongAddress(frame);
|
||||||
frame->popObject();
|
frame->popObject();
|
||||||
frame->pushInt(
|
frame->pushInt(c->load(
|
||||||
c->load(2, 2, c->memory(address, types.i2), TargetBytesPerWord));
|
types.i2, types.i2, c->memory(address, types.i2), types.address));
|
||||||
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"))
|
||||||
@ -3783,12 +3786,12 @@ intrinsic(MyThread* t, Frame* frame, object target)
|
|||||||
Compiler::Operand* address = popLongAddress(frame);
|
Compiler::Operand* address = popLongAddress(frame);
|
||||||
frame->popObject();
|
frame->popObject();
|
||||||
frame->pushInt(
|
frame->pushInt(
|
||||||
c->load(4,
|
c->load(types.i4,
|
||||||
4,
|
types.i4,
|
||||||
c->memory(address,
|
c->memory(address,
|
||||||
MATCH(methodName(t, target), "getInt") ? types.i4
|
MATCH(methodName(t, target), "getInt") ? types.i4
|
||||||
: types.f4),
|
: types.f4),
|
||||||
TargetBytesPerWord));
|
types.address));
|
||||||
return true;
|
return true;
|
||||||
} else if ((MATCH(methodName(t, target), "putInt")
|
} else if ((MATCH(methodName(t, target), "putInt")
|
||||||
and MATCH(methodSpec(t, target), "(JI)V"))
|
and MATCH(methodSpec(t, target), "(JI)V"))
|
||||||
@ -3810,12 +3813,12 @@ intrinsic(MyThread* t, Frame* frame, object target)
|
|||||||
Compiler::Operand* address = popLongAddress(frame);
|
Compiler::Operand* address = popLongAddress(frame);
|
||||||
frame->popObject();
|
frame->popObject();
|
||||||
frame->pushLong(
|
frame->pushLong(
|
||||||
c->load(8,
|
c->load(types.i8,
|
||||||
8,
|
types.i8,
|
||||||
c->memory(address,
|
c->memory(address,
|
||||||
MATCH(methodName(t, target), "getLong") ? types.i8
|
MATCH(methodName(t, target), "getLong") ? types.i8
|
||||||
: types.f8),
|
: types.f8),
|
||||||
8));
|
types.i8));
|
||||||
return true;
|
return true;
|
||||||
} else if ((MATCH(methodName(t, target), "putLong")
|
} else if ((MATCH(methodName(t, target), "putLong")
|
||||||
and MATCH(methodSpec(t, target), "(JJ)V"))
|
and MATCH(methodSpec(t, target), "(JJ)V"))
|
||||||
@ -3834,10 +3837,10 @@ intrinsic(MyThread* t, Frame* frame, object target)
|
|||||||
{
|
{
|
||||||
Compiler::Operand* address = popLongAddress(frame);
|
Compiler::Operand* address = popLongAddress(frame);
|
||||||
frame->popObject();
|
frame->popObject();
|
||||||
frame->pushLong(c->load(TargetBytesPerWord,
|
frame->pushLong(c->load(types.address,
|
||||||
TargetBytesPerWord,
|
types.address,
|
||||||
c->memory(address, types.address),
|
c->memory(address, types.address),
|
||||||
8));
|
types.i8));
|
||||||
return true;
|
return true;
|
||||||
} else if (MATCH(methodName(t, target), "putAddress")
|
} else if (MATCH(methodName(t, target), "putAddress")
|
||||||
and MATCH(methodSpec(t, target), "(JJ)V"))
|
and MATCH(methodSpec(t, target), "(JJ)V"))
|
||||||
@ -4089,60 +4092,66 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
|||||||
switch (instruction) {
|
switch (instruction) {
|
||||||
case aaload:
|
case aaload:
|
||||||
frame->pushObject(
|
frame->pushObject(
|
||||||
c->load(TargetBytesPerWord,
|
c->load(types.address,
|
||||||
TargetBytesPerWord,
|
types.address,
|
||||||
c->memory(array, types.object, TargetArrayBody, index),
|
c->memory(array, types.object, TargetArrayBody, index),
|
||||||
TargetBytesPerWord));
|
types.address));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case faload:
|
case faload:
|
||||||
frame->pushInt(
|
frame->pushInt(
|
||||||
c->load(4,
|
c->load(types.f4,
|
||||||
4,
|
types.f4,
|
||||||
c->memory(array, types.f4, TargetArrayBody, index),
|
c->memory(array, types.f4, TargetArrayBody, index),
|
||||||
TargetBytesPerWord));
|
types.address));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case iaload:
|
case iaload:
|
||||||
frame->pushInt(
|
frame->pushInt(
|
||||||
c->load(4,
|
c->load(types.i4,
|
||||||
4,
|
types.i4,
|
||||||
c->memory(array, types.i4, TargetArrayBody, index),
|
c->memory(array, types.i4, TargetArrayBody, index),
|
||||||
TargetBytesPerWord));
|
types.address));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case baload:
|
case baload:
|
||||||
frame->pushInt(
|
frame->pushInt(
|
||||||
c->load(1,
|
c->load(types.i1,
|
||||||
1,
|
types.i1,
|
||||||
c->memory(array, types.i1, TargetArrayBody, index),
|
c->memory(array, types.i1, TargetArrayBody, index),
|
||||||
TargetBytesPerWord));
|
types.address));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case caload:
|
case caload:
|
||||||
frame->pushInt(
|
frame->pushInt(
|
||||||
c->loadz(2,
|
c->loadz(types.i2,
|
||||||
2,
|
types.i2,
|
||||||
c->memory(array, types.i2, TargetArrayBody, index),
|
c->memory(array, types.i2, TargetArrayBody, index),
|
||||||
TargetBytesPerWord));
|
types.address));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case daload:
|
case daload:
|
||||||
frame->pushLong(c->load(
|
frame->pushLong(
|
||||||
8, 8, c->memory(array, types.f8, TargetArrayBody, index), 8));
|
c->load(types.f8,
|
||||||
|
types.f8,
|
||||||
|
c->memory(array, types.f8, TargetArrayBody, index),
|
||||||
|
types.f8));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case laload:
|
case laload:
|
||||||
frame->pushLong(c->load(
|
frame->pushLong(
|
||||||
8, 8, c->memory(array, types.i8, TargetArrayBody, index), 8));
|
c->load(types.i8,
|
||||||
|
types.i8,
|
||||||
|
c->memory(array, types.i8, TargetArrayBody, index),
|
||||||
|
types.i8));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case saload:
|
case saload:
|
||||||
frame->pushInt(
|
frame->pushInt(
|
||||||
c->load(2,
|
c->load(types.i2,
|
||||||
2,
|
types.i2,
|
||||||
c->memory(array, types.i2, TargetArrayBody, index),
|
c->memory(array, types.i2, TargetArrayBody, index),
|
||||||
TargetBytesPerWord));
|
types.address));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
@ -4298,10 +4307,10 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
|||||||
|
|
||||||
case arraylength: {
|
case arraylength: {
|
||||||
frame->pushInt(
|
frame->pushInt(
|
||||||
c->load(TargetBytesPerWord,
|
c->load(types.address,
|
||||||
TargetBytesPerWord,
|
types.address,
|
||||||
c->memory(frame->popObject(), types.i4, TargetArrayLength),
|
c->memory(frame->popObject(), types.i4, TargetArrayLength),
|
||||||
TargetBytesPerWord));
|
types.address));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case astore:
|
case astore:
|
||||||
@ -4612,66 +4621,66 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
|||||||
case ByteField:
|
case ByteField:
|
||||||
case BooleanField:
|
case BooleanField:
|
||||||
frame->pushInt(c->load(
|
frame->pushInt(c->load(
|
||||||
1,
|
types.i1,
|
||||||
1,
|
types.i1,
|
||||||
c->memory(table, types.i4, targetFieldOffset(context, field)),
|
c->memory(table, types.i4, targetFieldOffset(context, field)),
|
||||||
TargetBytesPerWord));
|
types.address));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CharField:
|
case CharField:
|
||||||
frame->pushInt(c->loadz(
|
frame->pushInt(c->loadz(
|
||||||
2,
|
types.i2,
|
||||||
2,
|
types.i2,
|
||||||
c->memory(table, types.i4, targetFieldOffset(context, field)),
|
c->memory(table, types.i4, targetFieldOffset(context, field)),
|
||||||
TargetBytesPerWord));
|
types.address));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ShortField:
|
case ShortField:
|
||||||
frame->pushInt(c->load(
|
frame->pushInt(c->load(
|
||||||
2,
|
types.i2,
|
||||||
2,
|
types.i2,
|
||||||
c->memory(table, types.i4, targetFieldOffset(context, field)),
|
c->memory(table, types.i4, targetFieldOffset(context, field)),
|
||||||
TargetBytesPerWord));
|
types.address));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FloatField:
|
case FloatField:
|
||||||
frame->pushInt(c->load(
|
frame->pushInt(c->load(
|
||||||
4,
|
types.f4,
|
||||||
4,
|
types.f4,
|
||||||
c->memory(table, types.f4, targetFieldOffset(context, field)),
|
c->memory(table, types.f4, targetFieldOffset(context, field)),
|
||||||
TargetBytesPerWord));
|
types.address));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IntField:
|
case IntField:
|
||||||
frame->pushInt(c->load(
|
frame->pushInt(c->load(
|
||||||
4,
|
types.i4,
|
||||||
4,
|
types.i4,
|
||||||
c->memory(table, types.i4, targetFieldOffset(context, field)),
|
c->memory(table, types.i4, targetFieldOffset(context, field)),
|
||||||
TargetBytesPerWord));
|
types.address));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DoubleField:
|
case DoubleField:
|
||||||
frame->pushLong(c->load(
|
frame->pushLong(c->load(
|
||||||
8,
|
types.f8,
|
||||||
8,
|
types.f8,
|
||||||
c->memory(table, types.f8, targetFieldOffset(context, field)),
|
c->memory(table, types.f8, targetFieldOffset(context, field)),
|
||||||
8));
|
types.f8));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LongField:
|
case LongField:
|
||||||
frame->pushLong(c->load(
|
frame->pushLong(c->load(
|
||||||
8,
|
types.i8,
|
||||||
8,
|
types.i8,
|
||||||
c->memory(table, types.i8, targetFieldOffset(context, field)),
|
c->memory(table, types.i8, targetFieldOffset(context, field)),
|
||||||
8));
|
types.i8));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ObjectField:
|
case ObjectField:
|
||||||
frame->pushObject(c->load(
|
frame->pushObject(c->load(
|
||||||
TargetBytesPerWord,
|
types.address,
|
||||||
TargetBytesPerWord,
|
types.address,
|
||||||
c->memory(table, types.object, targetFieldOffset(context, field)),
|
c->memory(table, types.object, targetFieldOffset(context, field)),
|
||||||
TargetBytesPerWord));
|
types.address));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -4760,13 +4769,13 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
|||||||
} break;
|
} break;
|
||||||
|
|
||||||
case i2b: {
|
case i2b: {
|
||||||
frame->pushInt
|
frame->pushInt(
|
||||||
(c->load(TargetBytesPerWord, 1, frame->popInt(), TargetBytesPerWord));
|
c->load(types.address, types.i1, frame->popInt(), types.address));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case i2c: {
|
case i2c: {
|
||||||
frame->pushInt
|
frame->pushInt(
|
||||||
(c->loadz(TargetBytesPerWord, 2, frame->popInt(), TargetBytesPerWord));
|
c->loadz(types.address, types.i2, frame->popInt(), types.address));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case i2d: {
|
case i2d: {
|
||||||
@ -4778,12 +4787,13 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
|||||||
} break;
|
} break;
|
||||||
|
|
||||||
case i2l:
|
case i2l:
|
||||||
frame->pushLong(c->load(TargetBytesPerWord, 4, frame->popInt(), 8));
|
frame->pushLong(
|
||||||
|
c->load(types.address, types.i4, frame->popInt(), types.i8));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case i2s: {
|
case i2s: {
|
||||||
frame->pushInt
|
frame->pushInt(
|
||||||
(c->load(TargetBytesPerWord, 2, frame->popInt(), TargetBytesPerWord));
|
c->load(types.address, types.i2, frame->popInt(), types.address));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case iadd:
|
case iadd:
|
||||||
@ -5274,7 +5284,8 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
|||||||
} break;
|
} break;
|
||||||
|
|
||||||
case l2i:
|
case l2i:
|
||||||
frame->pushInt(c->load(8, 8, frame->popLong(), TargetBytesPerWord));
|
frame->pushInt(
|
||||||
|
c->load(types.i8, types.i8, frame->popLong(), types.address));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ladd:
|
case ladd:
|
||||||
@ -6125,8 +6136,8 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
|||||||
0,
|
0,
|
||||||
normalizedKey);
|
normalizedKey);
|
||||||
|
|
||||||
c->jmp(c->load(TargetBytesPerWord,
|
c->jmp(c->load(types.address,
|
||||||
TargetBytesPerWord,
|
types.address,
|
||||||
context->bootContext
|
context->bootContext
|
||||||
? c->binaryOp(lir::Add,
|
? c->binaryOp(lir::Add,
|
||||||
types.address,
|
types.address,
|
||||||
@ -6135,7 +6146,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
|||||||
TARGET_THREAD_CODEIMAGE),
|
TARGET_THREAD_CODEIMAGE),
|
||||||
entry)
|
entry)
|
||||||
: entry,
|
: entry,
|
||||||
TargetBytesPerWord));
|
types.address));
|
||||||
|
|
||||||
s->state = c->saveState();
|
s->state = c->saveState();
|
||||||
} goto switchloop;
|
} goto switchloop;
|
||||||
@ -6143,7 +6154,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
|||||||
case Unswitch: {
|
case Unswitch: {
|
||||||
SwitchState* s = static_cast<SwitchState*>
|
SwitchState* s = static_cast<SwitchState*>
|
||||||
(stack.peek(sizeof(SwitchState)));
|
(stack.peek(sizeof(SwitchState)));
|
||||||
|
|
||||||
frame = s->frame();
|
frame = s->frame();
|
||||||
|
|
||||||
c->restoreState
|
c->restoreState
|
||||||
|
Loading…
x
Reference in New Issue
Block a user