mirror of
https://github.com/corda/corda.git
synced 2025-01-07 13:38:47 +00:00
Remove boilerplate code (float binaryOp methods in Compiler)
This commit is contained in:
parent
d5c1a094ca
commit
07d0f1172f
@ -132,12 +132,6 @@ class Compiler {
|
|||||||
|
|
||||||
virtual Operand* binaryOp(lir::TernaryOperation type, unsigned size, Operand* a, Operand* b) = 0;
|
virtual Operand* binaryOp(lir::TernaryOperation type, unsigned size, Operand* a, Operand* b) = 0;
|
||||||
|
|
||||||
virtual Operand* fadd(unsigned size, Operand* a, Operand* b) = 0;
|
|
||||||
virtual Operand* fsub(unsigned size, Operand* a, Operand* b) = 0;
|
|
||||||
virtual Operand* fmul(unsigned size, Operand* a, Operand* b) = 0;
|
|
||||||
virtual Operand* fdiv(unsigned size, Operand* a, Operand* b) = 0;
|
|
||||||
virtual Operand* frem(unsigned size, Operand* a, Operand* b) = 0;
|
|
||||||
|
|
||||||
virtual Operand* neg(unsigned size, Operand* a) = 0;
|
virtual Operand* neg(unsigned size, Operand* a) = 0;
|
||||||
virtual Operand* fneg(unsigned size, Operand* a) = 0;
|
virtual Operand* fneg(unsigned size, Operand* a) = 0;
|
||||||
virtual Operand* abs(unsigned size, Operand* a) = 0;
|
virtual Operand* abs(unsigned size, Operand* a) = 0;
|
||||||
|
@ -117,7 +117,7 @@ inline bool isGeneralBinaryOp(lir::TernaryOperation op) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline bool isFloatBinaryOp(lir::TernaryOperation op) {
|
inline bool isFloatBinaryOp(lir::TernaryOperation op) {
|
||||||
return op > FloatAdd && op <= FloatMin;
|
return op >= FloatAdd && op <= FloatMin;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Operand { };
|
class Operand { };
|
||||||
|
@ -2623,54 +2623,6 @@ class MyCompiler: public Compiler {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Operand* fadd(unsigned size, Operand* a, Operand* b) {
|
|
||||||
assert(&c, static_cast<Value*>(a)->type == lir::ValueFloat
|
|
||||||
and static_cast<Value*>(b)->type == lir::ValueFloat);
|
|
||||||
Value* result = value(&c, lir::ValueFloat);
|
|
||||||
static_cast<Value*>(a)->type = static_cast<Value*>(b)->type = lir::ValueFloat;
|
|
||||||
appendCombine(&c, lir::FloatAdd, size, static_cast<Value*>(a),
|
|
||||||
size, static_cast<Value*>(b), size, result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual Operand* fsub(unsigned size, Operand* a, Operand* b) {
|
|
||||||
assert(&c, static_cast<Value*>(a)->type == lir::ValueFloat
|
|
||||||
and static_cast<Value*>(b)->type == lir::ValueFloat);
|
|
||||||
Value* result = value(&c, lir::ValueFloat);
|
|
||||||
static_cast<Value*>(a)->type = static_cast<Value*>(b)->type = lir::ValueFloat;
|
|
||||||
appendCombine(&c, lir::FloatSubtract, size, static_cast<Value*>(a),
|
|
||||||
size, static_cast<Value*>(b), size, result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual Operand* fmul(unsigned size, Operand* a, Operand* b) {
|
|
||||||
assert(&c, static_cast<Value*>(a)->type == lir::ValueFloat
|
|
||||||
and static_cast<Value*>(b)->type == lir::ValueFloat);
|
|
||||||
Value* result = value(&c, lir::ValueFloat);
|
|
||||||
static_cast<Value*>(a)->type = static_cast<Value*>(b)->type = lir::ValueFloat;
|
|
||||||
appendCombine(&c, lir::FloatMultiply, size, static_cast<Value*>(a),
|
|
||||||
size, static_cast<Value*>(b), size, result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual Operand* fdiv(unsigned size, Operand* a, Operand* b) {
|
|
||||||
assert(&c, static_cast<Value*>(a)->type == lir::ValueFloat
|
|
||||||
and static_cast<Value*>(b)->type == lir::ValueFloat);
|
|
||||||
Value* result = value(&c, lir::ValueFloat);
|
|
||||||
appendCombine(&c, lir::FloatDivide, size, static_cast<Value*>(a),
|
|
||||||
size, static_cast<Value*>(b), size, result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual Operand* frem(unsigned size, Operand* a, Operand* b) {
|
|
||||||
assert(&c, static_cast<Value*>(a)->type == lir::ValueFloat
|
|
||||||
and static_cast<Value*>(b)->type == lir::ValueFloat);
|
|
||||||
Value* result = value(&c, lir::ValueFloat);
|
|
||||||
appendCombine(&c, lir::FloatRemainder, size, static_cast<Value*>(a),
|
|
||||||
size, static_cast<Value*>(b), size, result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual Operand* neg(unsigned size, Operand* a) {
|
virtual Operand* neg(unsigned size, Operand* a) {
|
||||||
assert(&c, static_cast<Value*>(a)->type == lir::ValueGeneral);
|
assert(&c, static_cast<Value*>(a)->type == lir::ValueGeneral);
|
||||||
Value* result = value(&c, lir::ValueGeneral);
|
Value* result = value(&c, lir::ValueGeneral);
|
||||||
|
@ -4589,7 +4589,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
|||||||
Compiler::Operand* a = frame->popLong();
|
Compiler::Operand* a = frame->popLong();
|
||||||
Compiler::Operand* b = frame->popLong();
|
Compiler::Operand* b = frame->popLong();
|
||||||
|
|
||||||
frame->pushLong(c->fadd(8, a, b));
|
frame->pushLong(c->binaryOp(lir::FloatAdd, 8, a, b));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dcmpg: {
|
case dcmpg: {
|
||||||
@ -4638,14 +4638,14 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
|||||||
Compiler::Operand* a = frame->popLong();
|
Compiler::Operand* a = frame->popLong();
|
||||||
Compiler::Operand* b = frame->popLong();
|
Compiler::Operand* b = frame->popLong();
|
||||||
|
|
||||||
frame->pushLong(c->fdiv(8, a, b));
|
frame->pushLong(c->binaryOp(lir::FloatDivide, 8, a, b));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dmul: {
|
case dmul: {
|
||||||
Compiler::Operand* a = frame->popLong();
|
Compiler::Operand* a = frame->popLong();
|
||||||
Compiler::Operand* b = frame->popLong();
|
Compiler::Operand* b = frame->popLong();
|
||||||
|
|
||||||
frame->pushLong(c->fmul(8, a, b));
|
frame->pushLong(c->binaryOp(lir::FloatMultiply, 8, a, b));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dneg: {
|
case dneg: {
|
||||||
@ -4656,14 +4656,14 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
|||||||
Compiler::Operand* a = frame->popLong();
|
Compiler::Operand* a = frame->popLong();
|
||||||
Compiler::Operand* b = frame->popLong();
|
Compiler::Operand* b = frame->popLong();
|
||||||
|
|
||||||
frame->pushLong(c->frem(8, a, b));
|
frame->pushLong(c->binaryOp(lir::FloatRemainder, 8, a, b));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dsub: {
|
case dsub: {
|
||||||
Compiler::Operand* a = frame->popLong();
|
Compiler::Operand* a = frame->popLong();
|
||||||
Compiler::Operand* b = frame->popLong();
|
Compiler::Operand* b = frame->popLong();
|
||||||
|
|
||||||
frame->pushLong(c->fsub(8, a, b));
|
frame->pushLong(c->binaryOp(lir::FloatSubtract, 8, a, b));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dup:
|
case dup:
|
||||||
@ -4706,7 +4706,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
|||||||
Compiler::Operand* a = frame->popInt();
|
Compiler::Operand* a = frame->popInt();
|
||||||
Compiler::Operand* b = frame->popInt();
|
Compiler::Operand* b = frame->popInt();
|
||||||
|
|
||||||
frame->pushInt(c->fadd(4, a, b));
|
frame->pushInt(c->binaryOp(lir::FloatAdd, 4, a, b));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case fcmpg: {
|
case fcmpg: {
|
||||||
@ -4755,14 +4755,14 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
|||||||
Compiler::Operand* a = frame->popInt();
|
Compiler::Operand* a = frame->popInt();
|
||||||
Compiler::Operand* b = frame->popInt();
|
Compiler::Operand* b = frame->popInt();
|
||||||
|
|
||||||
frame->pushInt(c->fdiv(4, a, b));
|
frame->pushInt(c->binaryOp(lir::FloatDivide, 4, a, b));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case fmul: {
|
case fmul: {
|
||||||
Compiler::Operand* a = frame->popInt();
|
Compiler::Operand* a = frame->popInt();
|
||||||
Compiler::Operand* b = frame->popInt();
|
Compiler::Operand* b = frame->popInt();
|
||||||
|
|
||||||
frame->pushInt(c->fmul(4, a, b));
|
frame->pushInt(c->binaryOp(lir::FloatMultiply, 4, a, b));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case fneg: {
|
case fneg: {
|
||||||
@ -4773,14 +4773,14 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
|||||||
Compiler::Operand* a = frame->popInt();
|
Compiler::Operand* a = frame->popInt();
|
||||||
Compiler::Operand* b = frame->popInt();
|
Compiler::Operand* b = frame->popInt();
|
||||||
|
|
||||||
frame->pushInt(c->frem(4, a, b));
|
frame->pushInt(c->binaryOp(lir::FloatRemainder, 4, a, b));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case fsub: {
|
case fsub: {
|
||||||
Compiler::Operand* a = frame->popInt();
|
Compiler::Operand* a = frame->popInt();
|
||||||
Compiler::Operand* b = frame->popInt();
|
Compiler::Operand* b = frame->popInt();
|
||||||
|
|
||||||
frame->pushInt(c->fsub(4, a, b));
|
frame->pushInt(c->binaryOp(lir::FloatSubtract, 4, a, b));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case getfield:
|
case getfield:
|
||||||
|
Loading…
Reference in New Issue
Block a user