| 593 | |
| 594 | |
| 595 | static void Saturate(LowLevelILFunction& il, uint32_t dest, ExprId to_saturate, ExprId saturate_to, bool is_signed) |
| 596 | { |
| 597 | |
| 598 | LowLevelILLabel trueCode, falseCode, endCode; |
| 599 | LowLevelILLabel trueCode2, falseCode2, endCode2; |
| 600 | |
| 601 | if (is_signed) |
| 602 | { |
| 603 | il.AddInstruction(il.If(il.CompareSignedLessThan(4, to_saturate, il.Neg(4, saturate_to)), trueCode, falseCode)); |
| 604 | il.MarkLabel(trueCode); |
| 605 | il.AddInstruction(il.SetRegister(4, dest, il.Neg(4, saturate_to))); |
| 606 | il.AddInstruction(il.Goto(endCode)); |
| 607 | il.MarkLabel(falseCode); |
| 608 | il.MarkLabel(endCode); |
| 609 | |
| 610 | il.AddInstruction(il.If(il.CompareSignedGreaterThan(4, to_saturate, saturate_to), trueCode2, falseCode2)); |
| 611 | il.MarkLabel(trueCode2); |
| 612 | il.AddInstruction(il.SetRegister(4, dest, saturate_to)); |
| 613 | il.AddInstruction(il.Goto(endCode2)); |
| 614 | il.MarkLabel(falseCode2); |
| 615 | il.AddInstruction(il.SetRegister(4, dest, to_saturate)); |
| 616 | il.MarkLabel(endCode2); |
| 617 | } |
| 618 | else |
| 619 | { |
| 620 | il.AddInstruction(il.If(il.CompareSignedLessThan(4, to_saturate, il.Const(4, 0)), trueCode, falseCode)); |
| 621 | il.MarkLabel(trueCode); |
| 622 | il.AddInstruction(il.SetRegister(4, dest, il.Const(4, 0))); |
| 623 | il.AddInstruction(il.Goto(endCode)); |
| 624 | il.MarkLabel(falseCode); |
| 625 | il.MarkLabel(endCode); |
| 626 | |
| 627 | il.AddInstruction(il.If(il.CompareSignedGreaterThan(4, to_saturate, saturate_to), trueCode2, falseCode2)); |
| 628 | il.MarkLabel(trueCode2); |
| 629 | il.AddInstruction(il.SetRegister(4, dest, saturate_to)); |
| 630 | il.AddInstruction(il.Goto(endCode2)); |
| 631 | il.MarkLabel(falseCode2); |
| 632 | il.AddInstruction(il.SetRegister(4, dest, to_saturate)); |
| 633 | il.MarkLabel(endCode2); |
| 634 | } |
| 635 | } |
| 636 | |
| 637 | |
| 638 | uint32_t GetNumberOfRegs(uint16_t regList) |
no test coverage detected