| ... | ... | @@ -896,19 +896,22 @@ pub const Object = struct { |
| 896 | 896 | .{ .optimized = comp.root_mod.optimize_mode != .Debug }, |
| 897 | 897 | ); |
| 898 | 898 | |
| 899 | const i32_2 = try builder.intConst(.i32, 2); |
| 900 | const i32_3 = try builder.intConst(.i32, 3); |
| 899 | 901 | const debug_info_version = try builder.debugModuleFlag( |
| 900 | | try builder.debugConstant(try builder.intConst(.i32, 2)), |
| 902 | try builder.debugConstant(i32_2), |
| 901 | 903 | try builder.metadataString("Debug Info Version"), |
| 902 | | try builder.debugConstant(try builder.intConst(.i32, 3)), |
| 904 | try builder.debugConstant(i32_3), |
| 903 | 905 | ); |
| 904 | 906 | |
| 905 | 907 | switch (comp.config.debug_format) { |
| 906 | 908 | .strip => unreachable, |
| 907 | 909 | .dwarf => |f| { |
| 910 | const i32_4 = try builder.intConst(.i32, 4); |
| 908 | 911 | const dwarf_version = try builder.debugModuleFlag( |
| 909 | | try builder.debugConstant(try builder.intConst(.i32, 2)), |
| 912 | try builder.debugConstant(i32_2), |
| 910 | 913 | try builder.metadataString("Dwarf Version"), |
| 911 | | try builder.debugConstant(try builder.intConst(.i32, 4)), |
| 914 | try builder.debugConstant(i32_4), |
| 912 | 915 | ); |
| 913 | 916 | switch (f) { |
| 914 | 917 | .@"32" => { |
| ... | ... | @@ -919,9 +922,9 @@ pub const Object = struct { |
| 919 | 922 | }, |
| 920 | 923 | .@"64" => { |
| 921 | 924 | const dwarf64 = try builder.debugModuleFlag( |
| 922 | | try builder.debugConstant(try builder.intConst(.i32, 2)), |
| 925 | try builder.debugConstant(i32_2), |
| 923 | 926 | try builder.metadataString("DWARF64"), |
| 924 | | try builder.debugConstant(try builder.intConst(.i32, 1)), |
| 927 | try builder.debugConstant(.@"1"), |
| 925 | 928 | ); |
| 926 | 929 | try builder.debugNamed(try builder.metadataString("llvm.module.flags"), &.{ |
| 927 | 930 | debug_info_version, |
| ... | ... | @@ -933,9 +936,9 @@ pub const Object = struct { |
| 933 | 936 | }, |
| 934 | 937 | .code_view => { |
| 935 | 938 | const code_view = try builder.debugModuleFlag( |
| 936 | | try builder.debugConstant(try builder.intConst(.i32, 2)), |
| 939 | try builder.debugConstant(i32_2), |
| 937 | 940 | try builder.metadataString("CodeView"), |
| 938 | | try builder.debugConstant(try builder.intConst(.i32, 1)), |
| 941 | try builder.debugConstant(.@"1"), |
| 939 | 942 | ); |
| 940 | 943 | try builder.debugNamed(try builder.metadataString("llvm.module.flags"), &.{ |
| 941 | 944 | debug_info_version, |
| ... | ... | @@ -4265,7 +4268,7 @@ pub const Object = struct { |
| 4265 | 4268 | const err_align = err_int_ty.abiAlignment(mod); |
| 4266 | 4269 | const index: u32 = if (payload_align.compare(.gt, err_align)) 2 else 1; |
| 4267 | 4270 | return o.builder.gepConst(.inbounds, try o.lowerType(eu_ty), parent_ptr, null, &.{ |
| 4268 | | try o.builder.intConst(.i32, 0), try o.builder.intConst(.i32, index), |
| 4271 | .@"0", try o.builder.intConst(.i32, index), |
| 4269 | 4272 | }); |
| 4270 | 4273 | }, |
| 4271 | 4274 | .opt_payload => |opt_ptr| { |
| ... | ... | @@ -4281,9 +4284,7 @@ pub const Object = struct { |
| 4281 | 4284 | return parent_ptr; |
| 4282 | 4285 | } |
| 4283 | 4286 | |
| 4284 | | return o.builder.gepConst(.inbounds, try o.lowerType(opt_ty), parent_ptr, null, &.{ |
| 4285 | | try o.builder.intConst(.i32, 0), try o.builder.intConst(.i32, 0), |
| 4286 | | }); |
| 4287 | return o.builder.gepConst(.inbounds, try o.lowerType(opt_ty), parent_ptr, null, &.{ .@"0", .@"0" }); |
| 4287 | 4288 | }, |
| 4288 | 4289 | .comptime_field => unreachable, |
| 4289 | 4290 | .elem => |elem_ptr| { |
| ... | ... | @@ -4314,7 +4315,7 @@ pub const Object = struct { |
| 4314 | 4315 | |
| 4315 | 4316 | const parent_llvm_ty = try o.lowerType(parent_ty); |
| 4316 | 4317 | return o.builder.gepConst(.inbounds, parent_llvm_ty, parent_ptr, null, &.{ |
| 4317 | | try o.builder.intConst(.i32, 0), |
| 4318 | .@"0", |
| 4318 | 4319 | try o.builder.intConst(.i32, @intFromBool( |
| 4319 | 4320 | layout.tag_size > 0 and layout.tag_align.compare(.gte, layout.payload_align), |
| 4320 | 4321 | )), |
| ... | ... | @@ -4340,7 +4341,7 @@ pub const Object = struct { |
| 4340 | 4341 | parent_ptr, |
| 4341 | 4342 | null, |
| 4342 | 4343 | if (o.llvmFieldIndex(parent_ty, field_index)) |llvm_field_index| &.{ |
| 4343 | | try o.builder.intConst(.i32, 0), |
| 4344 | .@"0", |
| 4344 | 4345 | try o.builder.intConst(.i32, llvm_field_index), |
| 4345 | 4346 | } else &.{ |
| 4346 | 4347 | try o.builder.intConst(.i32, @intFromBool( |
| ... | ... | @@ -4353,7 +4354,7 @@ pub const Object = struct { |
| 4353 | 4354 | assert(parent_ty.isSlice(mod)); |
| 4354 | 4355 | const parent_llvm_ty = try o.lowerType(parent_ty); |
| 4355 | 4356 | return o.builder.gepConst(.inbounds, parent_llvm_ty, parent_ptr, null, &.{ |
| 4356 | | try o.builder.intConst(.i32, 0), try o.builder.intConst(.i32, field_index), |
| 4357 | .@"0", try o.builder.intConst(.i32, field_index), |
| 4357 | 4358 | }); |
| 4358 | 4359 | }, |
| 4359 | 4360 | else => unreachable, |
| ... | ... | @@ -7842,7 +7843,7 @@ pub const FuncGen = struct { |
| 7842 | 7843 | .none, |
| 7843 | 7844 | if (scalar_ty.isSignedInt(mod)) .@"smul.fix.sat" else .@"umul.fix.sat", |
| 7844 | 7845 | &.{try o.lowerType(inst_ty)}, |
| 7845 | | &.{ lhs, rhs, try o.builder.intValue(.i32, 0) }, |
| 7846 | &.{ lhs, rhs, .@"0" }, |
| 7846 | 7847 | "", |
| 7847 | 7848 | ); |
| 7848 | 7849 | } |
| ... | ... | @@ -8165,7 +8166,6 @@ pub const FuncGen = struct { |
| 8165 | 8166 | |
| 8166 | 8167 | const libc_fn = try self.getLibcFunction(fn_name, &.{ scalar_llvm_ty, scalar_llvm_ty }, .i32); |
| 8167 | 8168 | |
| 8168 | | const zero = try o.builder.intConst(.i32, 0); |
| 8169 | 8169 | const int_cond: Builder.IntegerCondition = switch (pred) { |
| 8170 | 8170 | .eq => .eq, |
| 8171 | 8171 | .neq => .ne, |
| ... | ... | @@ -8182,7 +8182,7 @@ pub const FuncGen = struct { |
| 8182 | 8182 | const init = try o.builder.poisonValue(vector_result_ty); |
| 8183 | 8183 | const result = try self.buildElementwiseCall(libc_fn, &params, init, vec_len); |
| 8184 | 8184 | |
| 8185 | | const zero_vector = try o.builder.splatValue(vector_result_ty, zero); |
| 8185 | const zero_vector = try o.builder.splatValue(vector_result_ty, .@"0"); |
| 8186 | 8186 | return self.wip.icmp(int_cond, result, zero_vector, ""); |
| 8187 | 8187 | } |
| 8188 | 8188 | |
| ... | ... | @@ -8195,7 +8195,7 @@ pub const FuncGen = struct { |
| 8195 | 8195 | &params, |
| 8196 | 8196 | "", |
| 8197 | 8197 | ); |
| 8198 | | return self.wip.icmp(int_cond, result, zero.toValue(), ""); |
| 8198 | return self.wip.icmp(int_cond, result, .@"0", ""); |
| 8199 | 8199 | } |
| 8200 | 8200 | |
| 8201 | 8201 | const FloatOp = enum { |
| ... | ... | @@ -9021,18 +9021,14 @@ pub const FuncGen = struct { |
| 9021 | 9021 | // https://github.com/ziglang/zig/issues/11946 |
| 9022 | 9022 | return o.builder.intValue(llvm_usize, 0); |
| 9023 | 9023 | } |
| 9024 | | const result = try self.wip.callIntrinsic(.normal, .none, .returnaddress, &.{}, &.{ |
| 9025 | | try o.builder.intValue(.i32, 0), |
| 9026 | | }, ""); |
| 9024 | const result = try self.wip.callIntrinsic(.normal, .none, .returnaddress, &.{}, &.{.@"0"}, ""); |
| 9027 | 9025 | return self.wip.cast(.ptrtoint, result, llvm_usize, ""); |
| 9028 | 9026 | } |
| 9029 | 9027 | |
| 9030 | 9028 | fn airFrameAddress(self: *FuncGen, inst: Air.Inst.Index) !Builder.Value { |
| 9031 | 9029 | _ = inst; |
| 9032 | 9030 | const o = self.dg.object; |
| 9033 | | const result = try self.wip.callIntrinsic(.normal, .none, .frameaddress, &.{.ptr}, &.{ |
| 9034 | | try o.builder.intValue(.i32, 0), |
| 9035 | | }, ""); |
| 9031 | const result = try self.wip.callIntrinsic(.normal, .none, .frameaddress, &.{.ptr}, &.{.@"0"}, ""); |
| 9036 | 9032 | return self.wip.cast(.ptrtoint, result, try o.lowerType(Type.usize), ""); |
| 9037 | 9033 | } |
| 9038 | 9034 | |
| ... | ... | @@ -10116,7 +10112,6 @@ pub const FuncGen = struct { |
| 10116 | 10112 | const field_align = mod.unionFieldNormalAlignment(union_obj, extra.field_index); |
| 10117 | 10113 | const llvm_usize = try o.lowerType(Type.usize); |
| 10118 | 10114 | const usize_zero = try o.builder.intValue(llvm_usize, 0); |
| 10119 | | const i32_zero = try o.builder.intValue(.i32, 0); |
| 10120 | 10115 | |
| 10121 | 10116 | const llvm_union_ty = t: { |
| 10122 | 10117 | const payload_ty = p: { |
| ... | ... | @@ -10155,7 +10150,7 @@ pub const FuncGen = struct { |
| 10155 | 10150 | .flags = .{ .alignment = field_align }, |
| 10156 | 10151 | }); |
| 10157 | 10152 | if (layout.tag_size == 0) { |
| 10158 | | const indices = [3]Builder.Value{ usize_zero, i32_zero, i32_zero }; |
| 10153 | const indices = [3]Builder.Value{ usize_zero, .@"0", .@"0" }; |
| 10159 | 10154 | const len: usize = if (field_size == layout.payload_size) 2 else 3; |
| 10160 | 10155 | const field_ptr = |
| 10161 | 10156 | try self.wip.gep(.inbounds, llvm_union_ty, result_ptr, indices[0..len], ""); |
| ... | ... | @@ -10165,11 +10160,9 @@ pub const FuncGen = struct { |
| 10165 | 10160 | |
| 10166 | 10161 | { |
| 10167 | 10162 | const payload_index = @intFromBool(layout.tag_align.compare(.gte, layout.payload_align)); |
| 10168 | | const indices: [3]Builder.Value = |
| 10169 | | .{ usize_zero, try o.builder.intValue(.i32, payload_index), i32_zero }; |
| 10163 | const indices: [3]Builder.Value = .{ usize_zero, try o.builder.intValue(.i32, payload_index), .@"0" }; |
| 10170 | 10164 | const len: usize = if (field_size == layout.payload_size) 2 else 3; |
| 10171 | | const field_ptr = |
| 10172 | | try self.wip.gep(.inbounds, llvm_union_ty, result_ptr, indices[0..len], ""); |
| 10165 | const field_ptr = try self.wip.gep(.inbounds, llvm_union_ty, result_ptr, indices[0..len], ""); |
| 10173 | 10166 | try self.store(field_ptr, field_ptr_ty, llvm_payload, .none); |
| 10174 | 10167 | } |
| 10175 | 10168 | { |
| ... | ... | @@ -10275,7 +10268,7 @@ pub const FuncGen = struct { |
| 10275 | 10268 | |
| 10276 | 10269 | const pl_op = self.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; |
| 10277 | 10270 | const dimension = pl_op.payload; |
| 10278 | | if (dimension >= 3) return o.builder.intValue(.i32, 1); |
| 10271 | if (dimension >= 3) return .@"1"; |
| 10279 | 10272 | |
| 10280 | 10273 | // Fetch the dispatch pointer, which points to this structure: |
| 10281 | 10274 | // https://github.com/RadeonOpenCompute/ROCR-Runtime/blob/adae6c61e10d371f7cbc3d0e94ae2c070cab18a4/src/inc/hsa.h#L2913 |