Skip to content

Commit ea32a6a

Browse files
dcharkesCommit Queue
authored and
Commit Queue
committed
[vm] Support loading unboxed float consts to stack
Split off https://dart-review.googlesource.com/c/sdk/+/284300. Doubles are always loaded to DoubleStackSlots, and should already be covered. TEST=tested in dependent CL. If the code was moved to the assemblers, and the assemblers were given access to `Location`, this could be unit tested in an assembler test. See issue for discussion. Closes: #53900 Change-Id: Iaed2cf1fadebebd1857709cb5d7cc3b41a3d9747 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332761 Reviewed-by: Ryan Macnak <[email protected]> Commit-Queue: Daco Harkes <[email protected]>
1 parent f5983e4 commit ea32a6a

File tree

5 files changed

+30
-2
lines changed

5 files changed

+30
-2
lines changed

runtime/vm/compiler/backend/il_arm.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,12 @@ void ConstantInstr::EmitMoveToLocation(FlowGraphCompiler* compiler,
910910
RELEASE_ASSERT(ok);
911911
__ LoadImmediate(
912912
tmp, pair_index == 0 ? Utils::Low32Bits(v) : Utils::High32Bits(v));
913+
} else if (representation() == kUnboxedFloat) {
914+
int32_t float_bits =
915+
bit_cast<int32_t, float>(Double::Cast(value_).value());
916+
__ LoadImmediate(tmp, float_bits);
913917
} else {
918+
ASSERT(representation() == kTagged);
914919
__ LoadObject(tmp, value_);
915920
}
916921
__ StoreToOffset(tmp, destination.base_reg(), dest_offset);

runtime/vm/compiler/backend/il_arm64.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,7 @@ void ConstantInstr::EmitMoveToLocation(FlowGraphCompiler* compiler,
725725
ASSERT(destination.IsStackSlot());
726726
ASSERT(tmp != kNoRegister);
727727
const intptr_t dest_offset = destination.ToStackSlotOffset();
728+
compiler::OperandSize operand_size = compiler::kWordBytes;
728729
if (representation() == kUnboxedInt32 ||
729730
representation() == kUnboxedUint32 ||
730731
representation() == kUnboxedInt64) {
@@ -734,6 +735,11 @@ void ConstantInstr::EmitMoveToLocation(FlowGraphCompiler* compiler,
734735
} else {
735736
__ LoadImmediate(tmp, value);
736737
}
738+
} else if (representation() == kUnboxedFloat) {
739+
int32_t float_bits =
740+
bit_cast<int32_t, float>(Double::Cast(value_).value());
741+
__ LoadImmediate(tmp, float_bits);
742+
operand_size = compiler::kFourBytes;
737743
} else {
738744
ASSERT(representation() == kTagged);
739745
if (value_.IsNull()) {
@@ -744,7 +750,7 @@ void ConstantInstr::EmitMoveToLocation(FlowGraphCompiler* compiler,
744750
__ LoadObject(tmp, value_);
745751
}
746752
}
747-
__ StoreToOffset(tmp, destination.base_reg(), dest_offset);
753+
__ StoreToOffset(tmp, destination.base_reg(), dest_offset, operand_size);
748754
}
749755
}
750756

runtime/vm/compiler/backend/il_ia32.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,13 @@ void ConstantInstr::EmitMoveToLocation(FlowGraphCompiler* compiler,
507507
__ movl(LocationToStackSlotAddress(destination),
508508
compiler::Immediate(pair_index == 0 ? Utils::Low32Bits(v)
509509
: Utils::High32Bits(v)));
510+
} else if (representation() == kUnboxedFloat) {
511+
int32_t float_bits =
512+
bit_cast<int32_t, float>(Double::Cast(value_).value());
513+
__ movl(LocationToStackSlotAddress(destination),
514+
compiler::Immediate(float_bits));
510515
} else {
516+
ASSERT(representation() == kTagged);
511517
if (compiler::Assembler::IsSafeSmi(value_) || value_.IsNull()) {
512518
__ movl(LocationToStackSlotAddress(destination),
513519
compiler::Immediate(static_cast<int32_t>(value_.ptr())));

runtime/vm/compiler/backend/il_riscv.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,7 @@ void ConstantInstr::EmitMoveToLocation(FlowGraphCompiler* compiler,
799799
ASSERT(destination.IsStackSlot());
800800
ASSERT(tmp != kNoRegister);
801801
const intptr_t dest_offset = destination.ToStackSlotOffset();
802+
compiler::OperandSize operand_size = compiler::kWordBytes;
802803
if (RepresentationUtils::IsUnboxedInteger(representation())) {
803804
int64_t val = Integer::Cast(value_).AsInt64Value();
804805
#if XLEN == 32
@@ -811,6 +812,11 @@ void ConstantInstr::EmitMoveToLocation(FlowGraphCompiler* compiler,
811812
} else {
812813
__ LoadImmediate(tmp, val);
813814
}
815+
} else if (representation() == kUnboxedFloat) {
816+
int32_t float_bits =
817+
bit_cast<int32_t, float>(Double::Cast(value_).value());
818+
__ LoadImmediate(tmp, float_bits);
819+
operand_size = compiler::kFourBytes;
814820
} else {
815821
ASSERT(representation() == kTagged);
816822
if (value_.IsNull()) {
@@ -821,7 +827,7 @@ void ConstantInstr::EmitMoveToLocation(FlowGraphCompiler* compiler,
821827
__ LoadObject(tmp, value_);
822828
}
823829
}
824-
__ StoreToOffset(tmp, destination.base_reg(), dest_offset);
830+
__ StoreToOffset(tmp, destination.base_reg(), dest_offset, operand_size);
825831
}
826832
}
827833

runtime/vm/compiler/backend/il_x64.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,11 @@ void ConstantInstr::EmitMoveToLocation(FlowGraphCompiler* compiler,
659659
const int64_t value = Integer::Cast(value_).AsInt64Value();
660660
__ movq(LocationToStackSlotAddress(destination),
661661
compiler::Immediate(value));
662+
} else if (representation() == kUnboxedFloat) {
663+
int32_t float_bits =
664+
bit_cast<int32_t, float>(Double::Cast(value_).value());
665+
__ movl(LocationToStackSlotAddress(destination),
666+
compiler::Immediate(float_bits));
662667
} else {
663668
ASSERT(representation() == kTagged);
664669
__ StoreObject(LocationToStackSlotAddress(destination), value_);

0 commit comments

Comments
 (0)