| ... | @@ -6540,7 +6540,28 @@ fn moveConstant(isel: *Select, dst: Value.Location, init_constant: Constant, ini | ... | @@ -6540,7 +6540,28 @@ fn moveConstant(isel: *Select, dst: Value.Location, init_constant: Constant, ini |
| 6540 | } | 6540 | } |
| 6541 | }, | 6541 | }, |
| 6542 | .enum_tag => |enum_tag| continue :constant_key .{ .int = ip.indexToKey(enum_tag.int).int }, | 6542 | .enum_tag => |enum_tag| continue :constant_key .{ .int = ip.indexToKey(enum_tag.int).int }, |
| 6543 | .float => return isel.fail("float unimplemented", .{}), | 6543 | .float => |float| { |
| | 6544 | if (isel.canUseFprForFloat(ZigType.fromInterned(float.ty).floatBits(isel.target))) { |
| | 6545 | return isel.fail("float unimplemented", .{}); |
| | 6546 | } else { |
| | 6547 | switch (float.ty) { |
| | 6548 | .f16_type => continue :constant_key .{ .int = .{ |
| | 6549 | .ty = .u16_type, |
| | 6550 | .storage = .{ .u64 = @as(u16, @bitCast(float.storage.f16)) }, |
| | 6551 | } }, |
| | 6552 | .f32_type => continue :constant_key .{ .int = .{ |
| | 6553 | .ty = .u32_type, |
| | 6554 | .storage = .{ .u64 = @as(u32, @bitCast(float.storage.f32)) }, |
| | 6555 | } }, |
| | 6556 | .f64_type => continue :constant_key .{ .int = .{ |
| | 6557 | .ty = .u64_type, |
| | 6558 | .storage = .{ .u64 = @as(u64, @bitCast(float.storage.f64)) }, |
| | 6559 | } }, |
| | 6560 | .f80_type, .f128_type => {}, |
| | 6561 | else => unreachable, |
| | 6562 | } |
| | 6563 | } |
| | 6564 | }, |
| 6544 | .ptr => |ptr| { | 6565 | .ptr => |ptr| { |
| 6545 | assert(offset == 0 and size == isel.gprSize()); | 6566 | assert(offset == 0 and size == isel.gprSize()); |
| 6546 | const dst_ra: Register.Alias, const use_tmp_reg = select_tmp: { | 6567 | const dst_ra: Register.Alias, const use_tmp_reg = select_tmp: { |
| ... | @@ -7390,7 +7411,7 @@ fn gprAlignment(isel: *Select) std.mem.Alignment { | ... | @@ -7390,7 +7411,7 @@ fn gprAlignment(isel: *Select) std.mem.Alignment { |
| 7390 | }; | 7411 | }; |
| 7391 | } | 7412 | } |
| 7392 | | 7413 | |
| 7393 | fn fprBits(isel: *Select) u7 { | 7414 | fn targetFprBits(isel: *Select) u7 { |
| 7394 | const cpu = &isel.target.cpu; | 7415 | const cpu = &isel.target.cpu; |
| 7395 | if (cpu.has(.loongarch, .d)) { | 7416 | if (cpu.has(.loongarch, .d)) { |
| 7396 | return 64; | 7417 | return 64; |
| ... | @@ -7408,12 +7429,12 @@ fn vectorBits(isel: *Select) u7 { | ... | @@ -7408,12 +7429,12 @@ fn vectorBits(isel: *Select) u7 { |
| 7408 | } else if (cpu.has(.loongarch, .lsx)) { | 7429 | } else if (cpu.has(.loongarch, .lsx)) { |
| 7409 | return 128; | 7430 | return 128; |
| 7410 | } else { | 7431 | } else { |
| 7411 | return isel.fprBits(); | 7432 | return isel.targetFprBits(); |
| 7412 | } | 7433 | } |
| 7413 | } | 7434 | } |
| 7414 | | 7435 | |
| 7415 | fn canUseFprForFloat(isel: *Select, bits: u16) bool { | 7436 | fn canUseFprForFloat(isel: *Select, bits: u16) bool { |
| 7416 | return bits <= isel.fprBits(); | 7437 | return bits <= isel.targetFprBits(); |
| 7417 | } | 7438 | } |
| 7418 | | 7439 | |
| 7419 | fn typeOfField(isel: *Select, ty: ZigType, offset: u64) ?ZigType { | 7440 | fn typeOfField(isel: *Select, ty: ZigType, offset: u64) ?ZigType { |