mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 21:08:36 +00:00
stage2: handle vectors in Value.intFitsInType
This commit is contained in:
parent
ca1ab38d3a
commit
6b5c87957b
@ -1671,6 +1671,7 @@ pub const Value = extern union {
|
||||
}
|
||||
|
||||
/// Asserts the value is an integer, and the destination type is ComptimeInt or Int.
|
||||
/// Vectors are also accepted. Vector results are reduced with AND.
|
||||
pub fn intFitsInType(self: Value, ty: Type, target: Target) bool {
|
||||
switch (self.tag()) {
|
||||
.zero,
|
||||
@ -1767,6 +1768,16 @@ pub const Value = extern union {
|
||||
else => unreachable,
|
||||
},
|
||||
|
||||
.aggregate => {
|
||||
assert(ty.zigTypeTag() == .Vector);
|
||||
for (self.castTag(.aggregate).?.data) |elem| {
|
||||
if (!elem.intFitsInType(ty.scalarType(), target)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
else => unreachable,
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user