| ... | ... | @@ -1671,6 +1671,7 @@ pub const Value = extern union { |
| 1671 | 1671 | } |
| 1672 | 1672 | |
| 1673 | 1673 | /// Asserts the value is an integer, and the destination type is ComptimeInt or Int. |
| 1674 | /// Vectors are also accepted. Vector results are reduced with AND. |
| 1674 | 1675 | pub fn intFitsInType(self: Value, ty: Type, target: Target) bool { |
| 1675 | 1676 | switch (self.tag()) { |
| 1676 | 1677 | .zero, |
| ... | ... | @@ -1767,6 +1768,16 @@ pub const Value = extern union { |
| 1767 | 1768 | else => unreachable, |
| 1768 | 1769 | }, |
| 1769 | 1770 | |
| 1771 | .aggregate => { |
| 1772 | assert(ty.zigTypeTag() == .Vector); |
| 1773 | for (self.castTag(.aggregate).?.data) |elem| { |
| 1774 | if (!elem.intFitsInType(ty.scalarType(), target)) { |
| 1775 | return false; |
| 1776 | } |
| 1777 | } |
| 1778 | return true; |
| 1779 | }, |
| 1780 | |
| 1770 | 1781 | else => unreachable, |
| 1771 | 1782 | } |
| 1772 | 1783 | } |