@@ -773,6 +773,8 @@ bool Compiler<Emitter>::VisitBinaryOperator(const BinaryOperator *BO) {
773
773
RHS->getType ()->isAnyComplexType ()) &&
774
774
BO->isComparisonOp ())
775
775
return this ->emitComplexComparison (LHS, RHS, BO);
776
+ if (LHS->getType ()->isFixedPointType () || RHS->getType ()->isFixedPointType ())
777
+ return this ->VisitFixedPointBinOp (BO);
776
778
777
779
if (BO->isPtrMemOp ()) {
778
780
if (!this ->visit (LHS))
@@ -1469,6 +1471,55 @@ bool Compiler<Emitter>::VisitVectorBinOp(const BinaryOperator *E) {
1469
1471
return true ;
1470
1472
}
1471
1473
1474
+ template <class Emitter >
1475
+ bool Compiler<Emitter>::VisitFixedPointBinOp(const BinaryOperator *E) {
1476
+ const Expr *LHS = E->getLHS ();
1477
+ const Expr *RHS = E->getRHS ();
1478
+
1479
+ assert (LHS->getType ()->isFixedPointType () ||
1480
+ RHS->getType ()->isFixedPointType ());
1481
+
1482
+ if (!this ->visit (LHS))
1483
+ return false ;
1484
+ if (!LHS->getType ()->isFixedPointType ()) {
1485
+ auto Sem = Ctx.getASTContext ().getFixedPointSemantics (LHS->getType ());
1486
+ uint32_t I;
1487
+ std::memcpy (&I, &Sem, sizeof (Sem));
1488
+ if (!this ->emitCastIntegralFixedPoint (classifyPrim (LHS->getType ()), I, E))
1489
+ return false ;
1490
+ }
1491
+ if (!this ->visit (RHS))
1492
+ return false ;
1493
+ if (!RHS->getType ()->isFixedPointType ()) {
1494
+ auto Sem = Ctx.getASTContext ().getFixedPointSemantics (RHS->getType ());
1495
+ uint32_t I;
1496
+ std::memcpy (&I, &Sem, sizeof (Sem));
1497
+ if (!this ->emitCastIntegralFixedPoint (classifyPrim (RHS->getType ()), I, E))
1498
+ return false ;
1499
+ }
1500
+
1501
+ switch (E->getOpcode ()) {
1502
+ case BO_EQ:
1503
+ return this ->emitEQFixedPoint (E);
1504
+ case BO_NE:
1505
+ return this ->emitNEFixedPoint (E);
1506
+ #if 0
1507
+ case BO_LT:
1508
+ return this->emitLTFixedPoint(E);
1509
+ case BO_LE:
1510
+ return this->emitLEFixedPoint(E);
1511
+ case BO_GT:
1512
+ return this->emitGTFixedPoint(E);
1513
+ case BO_GE:
1514
+ return this->emitGEFixedPoint(E);
1515
+ #endif
1516
+ default :
1517
+ return this ->emitInvalid (E);
1518
+ }
1519
+
1520
+ llvm_unreachable (" unhandled binop opcode" );
1521
+ }
1522
+
1472
1523
template <class Emitter >
1473
1524
bool Compiler<Emitter>::VisitImplicitValueInitExpr(
1474
1525
const ImplicitValueInitExpr *E) {
0 commit comments