mirror of
https://github.com/corda/corda.git
synced 2025-01-05 20:54:13 +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* 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* fneg(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) {
|
||||
return op > FloatAdd && op <= FloatMin;
|
||||
return op >= FloatAdd && op <= FloatMin;
|
||||
}
|
||||
|
||||
class Operand { };
|
||||
|
@ -2623,54 +2623,6 @@ class MyCompiler: public Compiler {
|
||||
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) {
|
||||
assert(&c, static_cast<Value*>(a)->type == 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* b = frame->popLong();
|
||||
|
||||
frame->pushLong(c->fadd(8, a, b));
|
||||
frame->pushLong(c->binaryOp(lir::FloatAdd, 8, a, b));
|
||||
} break;
|
||||
|
||||
case dcmpg: {
|
||||
@ -4638,14 +4638,14 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
||||
Compiler::Operand* a = frame->popLong();
|
||||
Compiler::Operand* b = frame->popLong();
|
||||
|
||||
frame->pushLong(c->fdiv(8, a, b));
|
||||
frame->pushLong(c->binaryOp(lir::FloatDivide, 8, a, b));
|
||||
} break;
|
||||
|
||||
case dmul: {
|
||||
Compiler::Operand* a = frame->popLong();
|
||||
Compiler::Operand* b = frame->popLong();
|
||||
|
||||
frame->pushLong(c->fmul(8, a, b));
|
||||
frame->pushLong(c->binaryOp(lir::FloatMultiply, 8, a, b));
|
||||
} break;
|
||||
|
||||
case dneg: {
|
||||
@ -4656,14 +4656,14 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
||||
Compiler::Operand* a = frame->popLong();
|
||||
Compiler::Operand* b = frame->popLong();
|
||||
|
||||
frame->pushLong(c->frem(8, a, b));
|
||||
frame->pushLong(c->binaryOp(lir::FloatRemainder, 8, a, b));
|
||||
} break;
|
||||
|
||||
case dsub: {
|
||||
Compiler::Operand* a = frame->popLong();
|
||||
Compiler::Operand* b = frame->popLong();
|
||||
|
||||
frame->pushLong(c->fsub(8, a, b));
|
||||
frame->pushLong(c->binaryOp(lir::FloatSubtract, 8, a, b));
|
||||
} break;
|
||||
|
||||
case dup:
|
||||
@ -4706,7 +4706,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
||||
Compiler::Operand* a = frame->popInt();
|
||||
Compiler::Operand* b = frame->popInt();
|
||||
|
||||
frame->pushInt(c->fadd(4, a, b));
|
||||
frame->pushInt(c->binaryOp(lir::FloatAdd, 4, a, b));
|
||||
} break;
|
||||
|
||||
case fcmpg: {
|
||||
@ -4755,14 +4755,14 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
||||
Compiler::Operand* a = frame->popInt();
|
||||
Compiler::Operand* b = frame->popInt();
|
||||
|
||||
frame->pushInt(c->fdiv(4, a, b));
|
||||
frame->pushInt(c->binaryOp(lir::FloatDivide, 4, a, b));
|
||||
} break;
|
||||
|
||||
case fmul: {
|
||||
Compiler::Operand* a = frame->popInt();
|
||||
Compiler::Operand* b = frame->popInt();
|
||||
|
||||
frame->pushInt(c->fmul(4, a, b));
|
||||
frame->pushInt(c->binaryOp(lir::FloatMultiply, 4, a, b));
|
||||
} break;
|
||||
|
||||
case fneg: {
|
||||
@ -4773,14 +4773,14 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
||||
Compiler::Operand* a = frame->popInt();
|
||||
Compiler::Operand* b = frame->popInt();
|
||||
|
||||
frame->pushInt(c->frem(4, a, b));
|
||||
frame->pushInt(c->binaryOp(lir::FloatRemainder, 4, a, b));
|
||||
} break;
|
||||
|
||||
case fsub: {
|
||||
Compiler::Operand* a = frame->popInt();
|
||||
Compiler::Operand* b = frame->popInt();
|
||||
|
||||
frame->pushInt(c->fsub(4, a, b));
|
||||
frame->pushInt(c->binaryOp(lir::FloatSubtract, 4, a, b));
|
||||
} break;
|
||||
|
||||
case getfield:
|
||||
|
Loading…
Reference in New Issue
Block a user