diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2025-01-30 11:58:32 -0500 |
|---|---|---|
| committer | Jacob Young <jacobly0@users.noreply.github.com> | 2025-01-31 23:00:34 -0500 |
| commit | afa74c6b213efb1ff85b86ce4a9edd5cc03e5a9b (patch) | |
| tree | 6a4d326e31eda55c359ec1e2aef05681bbef0298 /src/codegen/c.zig | |
| parent | 8195b64f575acaed9dbc59e745a98acebb71dc60 (diff) | |
| download | zig-afa74c6b213efb1ff85b86ce4a9edd5cc03e5a9b.tar.gz zig-afa74c6b213efb1ff85b86ce4a9edd5cc03e5a9b.zip | |
Sema: introduce all_vector_instructions backend feature
Sema is arbitrarily scalarizing some operations, which means that when I
try to implement vectorized versions of those operations in a backend,
they are impossible to test due to Sema not producing them. Now, I can
implement them and then temporarily enable the new feature for that
backend in order to test them. Once the backend supports all of them,
the feature can be permanently enabled.
This also deletes the Air instructions `int_from_bool` and
`int_from_ptr`, which are just bitcasts with a fixed result type, since
changing `un_op` to `ty_op` takes up the same amount of memory.
Diffstat (limited to 'src/codegen/c.zig')
| -rw-r--r-- | src/codegen/c.zig | 44 |
1 files changed, 1 insertions, 43 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 241f215875..b9731716f7 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -3325,7 +3325,6 @@ fn genBodyInner(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail, .bitcast => try airBitcast(f, inst), .intcast => try airIntCast(f, inst), .trunc => try airTrunc(f, inst), - .int_from_bool => try airIntFromBool(f, inst), .load => try airLoad(f, inst), .store => try airStore(f, inst, false), .store_safe => try airStore(f, inst, true), @@ -3371,8 +3370,6 @@ fn genBodyInner(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail, .fpext, => try airFloatCast(f, inst), - .int_from_ptr => try airIntFromPtr(f, inst), - .atomic_store_unordered => try airAtomicStore(f, inst, toMemoryOrder(.unordered)), .atomic_store_monotonic => try airAtomicStore(f, inst, toMemoryOrder(.monotonic)), .atomic_store_release => try airAtomicStore(f, inst, toMemoryOrder(.release)), @@ -3983,21 +3980,6 @@ fn airTrunc(f: *Function, inst: Air.Inst.Index) !CValue { return local; } -fn airIntFromBool(f: *Function, inst: Air.Inst.Index) !CValue { - const un_op = f.air.instructions.items(.data)[@intFromEnum(inst)].un_op; - const operand = try f.resolveInst(un_op); - try reap(f, inst, &.{un_op}); - const writer = f.object.writer(); - const inst_ty = f.typeOfIndex(inst); - const local = try f.allocLocal(inst, inst_ty); - const a = try Assignment.start(f, writer, try f.ctypeFromType(inst_ty, .complete)); - try f.writeCValue(writer, local, .Other); - try a.assign(f, writer); - try f.writeCValue(writer, operand, .Other); - try a.end(f, writer); - return local; -} - fn airStore(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue { const pt = f.object.dg.pt; const zcu = pt.zcu; @@ -4970,7 +4952,7 @@ fn bitcast(f: *Function, dest_ty: Type, operand: CValue, operand_ty: Type) !CVal src_info.bits == dest_info.bits) return operand; } - if (dest_ty.isPtrAtRuntime(zcu) and operand_ty.isPtrAtRuntime(zcu)) { + if (dest_ty.isPtrAtRuntime(zcu) or operand_ty.isPtrAtRuntime(zcu)) { const local = try f.allocLocal(null, dest_ty); try f.writeCValue(writer, local, .Other); try writer.writeAll(" = ("); @@ -6455,30 +6437,6 @@ fn airFloatCast(f: *Function, inst: Air.Inst.Index) !CValue { return local; } -fn airIntFromPtr(f: *Function, inst: Air.Inst.Index) !CValue { - const pt = f.object.dg.pt; - const zcu = pt.zcu; - const un_op = f.air.instructions.items(.data)[@intFromEnum(inst)].un_op; - - const operand = try f.resolveInst(un_op); - const operand_ty = f.typeOf(un_op); - try reap(f, inst, &.{un_op}); - const inst_ty = f.typeOfIndex(inst); - const writer = f.object.writer(); - const local = try f.allocLocal(inst, inst_ty); - try f.writeCValue(writer, local, .Other); - - try writer.writeAll(" = ("); - try f.renderType(writer, inst_ty); - try writer.writeByte(')'); - if (operand_ty.isSlice(zcu)) - try f.writeCValueMember(writer, operand, .{ .identifier = "ptr" }) - else - try f.writeCValue(writer, operand, .Other); - try writer.writeAll(";\n"); - return local; -} - fn airUnBuiltinCall( f: *Function, inst: Air.Inst.Index, |
