diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-06-19 22:36:24 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-19 22:36:24 -0700 |
| commit | a72d634b731952ee227d026c27e83c5702dcea4a (patch) | |
| tree | 8bfc4c9afa75a27ebb1108924589a8e7d5cc89ed /src/codegen/c.zig | |
| parent | c6e2e1ae4b85fc36acc89c9a5e2673834146d628 (diff) | |
| parent | a4d1edac8d65e1aa4b565f6fb11ab78541d97efa (diff) | |
| download | zig-a72d634b731952ee227d026c27e83c5702dcea4a.tar.gz zig-a72d634b731952ee227d026c27e83c5702dcea4a.zip | |
Merge pull request #16046 from BratishkaErik/issue-6128
Renaming `@xtoy` to `@YfromX`
Diffstat (limited to 'src/codegen/c.zig')
| -rw-r--r-- | src/codegen/c.zig | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig index d06f01c2c3..498eca4ce2 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -462,7 +462,7 @@ pub const Function = struct { => |owner_decl| try std.fmt.allocPrint(arena, "zig_{s}_{}__{d}", .{ @tagName(key), fmtIdent(mod.intern_pool.stringToSlice(mod.declPtr(owner_decl).name)), - @enumToInt(owner_decl), + @intFromEnum(owner_decl), }), }, .data = switch (key) { @@ -1865,7 +1865,7 @@ pub const DeclGen = struct { }; try writer.print("{}__{d}", .{ fmtIdent(name_stream.getWritten()), - @enumToInt(decl_index), + @intFromEnum(decl_index), }); } } @@ -1991,7 +1991,7 @@ fn renderTypeName( @tagName(tag)["fwd_".len..], attributes, fmtIdent(mod.intern_pool.stringToSlice(mod.declPtr(owner_decl).name)), - @enumToInt(owner_decl), + @intFromEnum(owner_decl), }); }, } @@ -2100,7 +2100,7 @@ fn renderTypePrefix( .fwd_anon_struct, .fwd_anon_union, => if (decl.unwrap()) |decl_index| - try w.print("anon__{d}_{d}", .{ @enumToInt(decl_index), idx }) + try w.print("anon__{d}_{d}", .{ @intFromEnum(decl_index), idx }) else try renderTypeName(mod, w, idx, cty, ""), @@ -2514,7 +2514,7 @@ pub fn genLazyFn(o: *Object, lazy_fn: LazyFnMap.Entry) !void { const name = mod.intern_pool.stringToSlice(name_ip); const tag_val = try mod.enumValueFieldIndex(enum_ty, index); - const int_val = try tag_val.enumToInt(enum_ty, mod); + const int_val = try tag_val.intFromEnum(enum_ty, mod); const name_ty = try mod.arrayType(.{ .len = name.len, @@ -2943,7 +2943,7 @@ fn genBodyInner(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail, .dbg_stmt => try airDbgStmt(f, inst), .intcast => try airIntCast(f, inst), .trunc => try airTrunc(f, inst), - .bool_to_int => try airBoolToInt(f, inst), + .int_from_bool => try airIntFromBool(f, inst), .load => try airLoad(f, inst), .ret => try airRet(f, inst, false), .ret_load => try airRet(f, inst, true), @@ -3000,13 +3000,13 @@ fn genBodyInner(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail, .call_never_tail => try airCall(f, inst, .never_tail), .call_never_inline => try airCall(f, inst, .never_inline), - .int_to_float, - .float_to_int, + .float_from_int, + .int_from_float, .fptrunc, .fpext, => try airFloatCast(f, inst), - .ptrtoint => try airPtrToInt(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)), @@ -3068,7 +3068,7 @@ fn genBodyInner(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail, .cmp_neq_optimized, .cmp_vector_optimized, .reduce_optimized, - .float_to_int_optimized, + .int_from_float_optimized, => return f.fail("TODO implement optimized float mode", .{}), .is_named_enum_value => return f.fail("TODO: C backend: implement is_named_enum_value", .{}), @@ -3562,7 +3562,7 @@ fn airTrunc(f: *Function, inst: Air.Inst.Index) !CValue { return local; } -fn airBoolToInt(f: *Function, inst: Air.Inst.Index) !CValue { +fn airIntFromBool(f: *Function, inst: Air.Inst.Index) !CValue { const un_op = f.air.instructions.items(.data)[inst].un_op; const operand = try f.resolveInst(un_op); try reap(f, inst, &.{un_op}); @@ -4701,7 +4701,7 @@ fn airSwitchBr(f: *Function, inst: Air.Inst.Index) !CValue { // On the final iteration we do not need to fix any state. This is because, like in the `else` // branch of a `cond_br`, our parent has to do it for this entire body anyway. - const last_case_i = switch_br.data.cases_len - @boolToInt(switch_br.data.else_body_len == 0); + const last_case_i = switch_br.data.cases_len - @intFromBool(switch_br.data.else_body_len == 0); var extra_index: usize = switch_br.end; for (0..switch_br.data.cases_len) |case_i| { @@ -5834,7 +5834,7 @@ fn airFloatCast(f: *Function, inst: Air.Inst.Index) !CValue { return local; } -fn airPtrToInt(f: *Function, inst: Air.Inst.Index) !CValue { +fn airIntFromPtr(f: *Function, inst: Air.Inst.Index) !CValue { const mod = f.object.dg.module; const un_op = f.air.instructions.items(.data)[inst].un_op; @@ -6894,7 +6894,7 @@ fn airUnionInit(f: *Function, inst: Air.Inst.Index) !CValue { const tag_val = try mod.enumValueFieldIndex(tag_ty, field_index); - const int_val = try tag_val.enumToInt(tag_ty, mod); + const int_val = try tag_val.intFromEnum(tag_ty, mod); const a = try Assignment.start(f, writer, tag_ty); try f.writeCValueMember(writer, local, .{ .identifier = "tag" }); @@ -6924,7 +6924,7 @@ fn airPrefetch(f: *Function, inst: Air.Inst.Index) !CValue { .data => { try writer.writeAll("zig_prefetch("); try f.writeCValue(writer, ptr, .FunctionArgument); - try writer.print(", {d}, {d});\n", .{ @enumToInt(prefetch.rw), prefetch.locality }); + try writer.print(", {d}, {d});\n", .{ @intFromEnum(prefetch.rw), prefetch.locality }); }, // The available prefetch intrinsics do not accept a cache argument; only // address, rw, and locality. |
