diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2025-05-30 17:12:11 +0100 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2025-06-01 08:24:00 +0100 |
| commit | 4c4dacf81a5da85a1f7d1550ed45f5cb20fd1524 (patch) | |
| tree | dc8ed2db66482c0f8706b5e730ebcddd4f3155b7 /src/Zcu/PerThread.zig | |
| parent | 77e6513030a6258a893c2f11ad9708c9612b7715 (diff) | |
| download | zig-4c4dacf81a5da85a1f7d1550ed45f5cb20fd1524.tar.gz zig-4c4dacf81a5da85a1f7d1550ed45f5cb20fd1524.zip | |
Legalize: replace `safety_checked_instructions`
This adds 4 `Legalize.Feature`s:
* `expand_intcast_safe`
* `expand_add_safe`
* `expand_sub_safe`
* `expand_mul_safe`
These do pretty much what they say on the tin. This logic was previously
in Sema, used when `Zcu.Feature.safety_checked_instructions` was not
supported by the backend. That `Zcu.Feature` has been removed in favour
of this legalization.
Diffstat (limited to 'src/Zcu/PerThread.zig')
| -rw-r--r-- | src/Zcu/PerThread.zig | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/Zcu/PerThread.zig b/src/Zcu/PerThread.zig index a67d4dcc05..f8ae173b75 100644 --- a/src/Zcu/PerThread.zig +++ b/src/Zcu/PerThread.zig @@ -3844,6 +3844,21 @@ pub fn nullValue(pt: Zcu.PerThread, opt_ty: Type) Allocator.Error!Value { } })); } +/// `ty` is an integer or a vector of integers. +pub fn overflowArithmeticTupleType(pt: Zcu.PerThread, ty: Type) !Type { + const zcu = pt.zcu; + const ip = &zcu.intern_pool; + const ov_ty: Type = if (ty.zigTypeTag(zcu) == .vector) try pt.vectorType(.{ + .len = ty.vectorLen(zcu), + .child = .u1_type, + }) else .u1; + const tuple_ty = try ip.getTupleType(zcu.gpa, pt.tid, .{ + .types = &.{ ty.toIntern(), ov_ty.toIntern() }, + .values = &.{ .none, .none }, + }); + return .fromInterned(tuple_ty); +} + pub fn smallestUnsignedInt(pt: Zcu.PerThread, max: u64) Allocator.Error!Type { return pt.intType(.unsigned, Type.smallestUnsignedBits(max)); } |
