Commit 0c045963 authored by Ng Zhi An's avatar Ng Zhi An Committed by V8 LUCI CQ

[ia32] Create field accessors for Operand's members

With these accessors we can remove Assembler as a friend class.

Drive-by cleanup to change DCHECK(!x || y) to DCHECK_IMPLIES(x, y).

Change-Id: I74b7a23e85b50db93bbfe84fdfcc8563527f14d2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3144374Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#76757}
parent a9ab1c3b
......@@ -3408,27 +3408,27 @@ void Assembler::emit_operand(XMMRegister reg, Operand adr) {
void Assembler::emit_operand(int code, Operand adr) {
// Isolate-independent code may not embed relocatable addresses.
DCHECK(!options().isolate_independent_code ||
adr.rmode_ != RelocInfo::CODE_TARGET);
DCHECK(!options().isolate_independent_code ||
adr.rmode_ != RelocInfo::FULL_EMBEDDED_OBJECT);
DCHECK(!options().isolate_independent_code ||
adr.rmode_ != RelocInfo::EXTERNAL_REFERENCE);
const unsigned length = adr.len_;
DCHECK_IMPLIES(options().isolate_independent_code,
adr.rmode() != RelocInfo::CODE_TARGET);
DCHECK_IMPLIES(options().isolate_independent_code,
adr.rmode() != RelocInfo::FULL_EMBEDDED_OBJECT);
DCHECK_IMPLIES(options().isolate_independent_code,
adr.rmode() != RelocInfo::EXTERNAL_REFERENCE);
const unsigned length = adr.encoded_bytes().length();
DCHECK_GT(length, 0);
// Emit updated ModRM byte containing the given register.
EMIT((adr.buf_[0] & ~0x38) | (code << 3));
EMIT((adr.encoded_bytes()[0] & ~0x38) | (code << 3));
// Emit the rest of the encoded operand.
for (unsigned i = 1; i < length; i++) EMIT(adr.buf_[i]);
for (unsigned i = 1; i < length; i++) EMIT(adr.encoded_bytes()[i]);
// Emit relocation information if necessary.
if (length >= sizeof(int32_t) && !RelocInfo::IsNone(adr.rmode_)) {
if (length >= sizeof(int32_t) && !RelocInfo::IsNone(adr.rmode())) {
pc_ -= sizeof(int32_t); // pc_ must be *at* disp32
RecordRelocInfo(adr.rmode_);
if (adr.rmode_ == RelocInfo::INTERNAL_REFERENCE) { // Fixup for labels
RecordRelocInfo(adr.rmode());
if (adr.rmode() == RelocInfo::INTERNAL_REFERENCE) { // Fixup for labels
emit_label(ReadUnalignedValue<Label*>(reinterpret_cast<Address>(pc_)));
} else {
pc_ += sizeof(int32_t);
......
......@@ -269,6 +269,9 @@ class V8_EXPORT_PRIVATE Operand {
// register.
Register reg() const;
base::Vector<const byte> encoded_bytes() const { return {buf_, len_}; }
RelocInfo::Mode rmode() { return rmode_; }
private:
// Set the ModRM byte without an encoded 'reg' register. The
// register is encoded later as part of the emit_operand operation.
......@@ -298,9 +301,6 @@ class V8_EXPORT_PRIVATE Operand {
uint8_t len_ = 0;
// Only valid if len_ > 4.
RelocInfo::Mode rmode_ = RelocInfo::NONE;
// TODO(clemensb): Get rid of this friendship, or make Operand immutable.
friend class Assembler;
};
ASSERT_TRIVIALLY_COPYABLE(Operand);
static_assert(sizeof(Operand) <= 2 * kSystemPointerSize,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment