Index: src/a64/simulator-a64.h |
diff --git a/src/a64/simulator-a64.h b/src/a64/simulator-a64.h |
index 959644b773e21bec17eea32c840ebd413fc799c2..acca27c1302dbf935daea99dd471af49def42b0a 100644 |
--- a/src/a64/simulator-a64.h |
+++ b/src/a64/simulator-a64.h |
@@ -166,10 +166,18 @@ class SimRegisterBase { |
void Set(T new_value, unsigned size = sizeof(T)) { |
ASSERT(size <= kSizeInBytes); |
ASSERT(size <= sizeof(new_value)); |
+ STATIC_ASSERT(kXRegSize == kDRegSize); |
+ STATIC_ASSERT(kWRegSize == kSRegSize); |
// All AArch64 registers are zero-extending; Writing a W register clears the |
// top bits of the corresponding X register. |
- memset(value_, 0, kSizeInBytes); |
- memcpy(value_, &new_value, size); |
+ if (size == kXRegSize) { |
+ memcpy(value_, &new_value, kXRegSize); |
+ } else if (size == kWRegSize) { |
+ memset(value_, 0, kSizeInBytes); |
+ memcpy(value_, &new_value, kWRegSize); |
+ } else { |
+ UNREACHABLE(); |
+ } |
} |
// Copy 'size' bytes of the register to the result, and zero-extend to fill |
@@ -178,8 +186,14 @@ class SimRegisterBase { |
T Get(unsigned size = sizeof(T)) const { |
ASSERT(size <= kSizeInBytes); |
T result; |
- memset(&result, 0, sizeof(result)); |
- memcpy(&result, value_, size); |
+ if (size == kXRegSize) { |
+ memcpy(&result, value_, kXRegSize); |
+ } else if (size == kWRegSize) { |
+ memset(&result, 0, sizeof(result)); |
+ memcpy(&result, value_, kWRegSize); |
+ } else { |
+ UNREACHABLE(); |
+ } |
return result; |
} |