Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
dart::compiler::Operand Class Reference

#include <assembler_arm.h>

Inheritance diagram for dart::compiler::Operand:
dart::ValueObject dart::ValueObject dart::ValueObject dart::ValueObject dart::compiler::Address dart::compiler::Address dart::compiler::FieldAddress dart::compiler::FieldAddress dart::compiler::FieldAddress dart::compiler::FieldAddress dart::compiler::FieldAddress dart::compiler::FieldAddress dart::compiler::FieldAddress dart::compiler::FieldAddress dart::compiler::FieldAddress dart::compiler::FieldAddress

Public Types

enum  OperandType {
  Shifted , Extended , Immediate , BitfieldImm ,
  Unknown
}
 

Public Member Functions

 Operand ()
 
 Operand (const Operand &other)
 
Operandoperator= (const Operand &other)
 
 Operand (uint32_t immediate)
 
 Operand (uint32_t rotate, uint32_t immed8)
 
 Operand (Register rm)
 
 Operand (Register rm, Shift shift, uint32_t shift_imm)
 
 Operand (Register rm, Shift shift, Register rs)
 
 Operand ()
 
 Operand (const Operand &other)
 
Operandoperator= (const Operand &other)
 
 Operand (Register rm)
 
 Operand (Register rm, Shift shift, int32_t imm)
 
 Operand (Register rm, Shift shift, Register r)
 
 Operand (Register rm, Extend extend, int32_t imm)
 
 Operand (Register rm, Extend extend, Register r)
 
 Operand (int32_t imm)
 
 Operand (uint8_t n, int8_t imm_s, int8_t imm_r)
 
uint8_t mod () const
 
Register rm () const
 
ScaleFactor scale () const
 
Register index () const
 
Register base () const
 
int8_t disp8 () const
 
int32_t disp32 () const
 
 Operand (const Operand &other)
 
Operandoperator= (const Operand &other)
 
bool Equals (const Operand &other) const
 
uint8_t rex () const
 
uint8_t mod () const
 
Register rm () const
 
ScaleFactor scale () const
 
Register index () const
 
Register base () const
 
int8_t disp8 () const
 
int32_t disp32 () const
 
 Operand (const Operand &other)
 
Operandoperator= (const Operand &other)
 
bool Equals (const Operand &other) const
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Static Public Member Functions

static bool CanHold (uint32_t immediate, Operand *o)
 
static bool IsImmLogical (uint64_t value, uint8_t width, Operand *imm_op)
 
static OperandType CanHold (int64_t imm, uint8_t sz, Operand *op)
 

Protected Member Functions

 Operand ()
 
void SetModRM (int mod, Register rm)
 
void SetSIB (ScaleFactor scale, Register index, Register base)
 
void SetDisp8 (int8_t disp)
 
void SetDisp32 (int32_t disp)
 
 Operand ()
 
void SetModRM (int mod, Register rm)
 
void SetSIB (ScaleFactor scale, Register index, Register base)
 
void SetDisp8 (int8_t disp)
 
void SetDisp32 (int32_t disp)
 

Friends

class Assembler
 
class Address
 

Detailed Description

Definition at line 129 of file assembler_arm.h.

Member Enumeration Documentation

◆ OperandType

Enumerator
Shifted 
Extended 
Immediate 
BitfieldImm 
Unknown 

Definition at line 349 of file assembler_arm64.h.

Constructor & Destructor Documentation

◆ Operand() [1/20]

dart::compiler::Operand::Operand ( )
inline

Definition at line 132 of file assembler_arm.h.

132: type_(-1), encoding_(-1) {}

◆ Operand() [2/20]

dart::compiler::Operand::Operand ( const Operand other)
inline

Definition at line 135 of file assembler_arm.h.

136 : ValueObject(), type_(other.type_), encoding_(other.encoding_) {}

◆ Operand() [3/20]

dart::compiler::Operand::Operand ( uint32_t  immediate)
inlineexplicit

Definition at line 146 of file assembler_arm.h.

146 {
147 ASSERT(immediate < (1 << kImmed8Bits));
148 type_ = 1;
149 encoding_ = immediate;
150 }
#define ASSERT(E)
@ kImmed8Bits

◆ Operand() [4/20]

dart::compiler::Operand::Operand ( uint32_t  rotate,
uint32_t  immed8 
)
inline

Definition at line 153 of file assembler_arm.h.

153 {
154 ASSERT((rotate < (1 << kRotateBits)) && (immed8 < (1 << kImmed8Bits)));
155 type_ = 1;
156 encoding_ = (rotate << kRotateShift) | (immed8 << kImmed8Shift);
157 }
static bool rotate(const SkDCubic &cubic, int zero, int index, SkDCubic &rotPath)
@ kRotateBits
@ kImmed8Shift
@ kRotateShift

◆ Operand() [5/20]

dart::compiler::Operand::Operand ( Register  rm)
inlineexplicit

Definition at line 160 of file assembler_arm.h.

160 {
161 type_ = 0;
162 encoding_ = static_cast<uint32_t>(rm);
163 }

◆ Operand() [6/20]

dart::compiler::Operand::Operand ( Register  rm,
Shift  shift,
uint32_t  shift_imm 
)
inline

Definition at line 166 of file assembler_arm.h.

166 {
167 ASSERT(shift_imm < (1 << kShiftImmBits));
168 type_ = 0;
169 encoding_ = shift_imm << kShiftImmShift |
170 static_cast<uint32_t>(shift) << kShiftShift |
171 static_cast<uint32_t>(rm);
172 }
@ kShiftImmShift
@ kShiftImmBits
@ kShiftShift

◆ Operand() [7/20]

dart::compiler::Operand::Operand ( Register  rm,
Shift  shift,
Register  rs 
)
inline

Definition at line 175 of file assembler_arm.h.

175 {
176 type_ = 0;
177 encoding_ = static_cast<uint32_t>(rs) << kShiftRegisterShift |
178 static_cast<uint32_t>(shift) << kShiftShift | (1 << 4) |
179 static_cast<uint32_t>(rm);
180 }
@ kShiftRegisterShift

◆ Operand() [8/20]

dart::compiler::Operand::Operand ( )
inline

Definition at line 358 of file assembler_arm64.h.

358: encoding_(-1), type_(Unknown) {}

◆ Operand() [9/20]

dart::compiler::Operand::Operand ( const Operand other)
inline

Definition at line 361 of file assembler_arm64.h.

362 : ValueObject(), encoding_(other.encoding_), type_(other.type_) {}

◆ Operand() [10/20]

dart::compiler::Operand::Operand ( Register  rm)
inlineexplicit

Definition at line 370 of file assembler_arm64.h.

370 {
371 ASSERT((rm != R31) && (rm != CSP));
372 encoding_ = Arm64Encode::Rm(rm);
373 type_ = Shifted;
374 }
static uint32_t Rm(Register rm)

◆ Operand() [11/20]

dart::compiler::Operand::Operand ( Register  rm,
Shift  shift,
int32_t  imm 
)
inline

Definition at line 376 of file assembler_arm64.h.

376 {
377 ASSERT(Utils::IsUint(6, imm));
378 ASSERT((rm != R31) && (rm != CSP));
379 encoding_ = (imm << kImm6Shift) | Arm64Encode::Rm(rm) |
380 (static_cast<int32_t>(shift) << kShiftTypeShift);
381 type_ = Shifted;
382 }
static bool IsUint(intptr_t N, T value)
Definition utils.h:313

◆ Operand() [12/20]

dart::compiler::Operand::Operand ( Register  rm,
Shift  shift,
Register  r 
)

◆ Operand() [13/20]

dart::compiler::Operand::Operand ( Register  rm,
Extend  extend,
int32_t  imm 
)
inline

Definition at line 387 of file assembler_arm64.h.

387 {
388 ASSERT(Utils::IsUint(3, imm));
389 ASSERT((rm != R31) && (rm != CSP));
390 encoding_ = B21 | Arm64Encode::Rm(rm) |
391 (static_cast<int32_t>(extend) << kExtendTypeShift) |
392 ((imm & 0x7) << kImm3Shift);
393 type_ = Extended;
394 }

◆ Operand() [14/20]

dart::compiler::Operand::Operand ( Register  rm,
Extend  extend,
Register  r 
)

◆ Operand() [15/20]

dart::compiler::Operand::Operand ( int32_t  imm)
inlineexplicit

Definition at line 399 of file assembler_arm64.h.

399 {
400 if (Utils::IsUint(12, imm)) {
401 encoding_ = imm << kImm12Shift;
402 } else {
403 // imm only has bits in [12, 24) set.
404 ASSERT(((imm & 0xfff) == 0) && (Utils::IsUint(12, imm >> 12)));
405 encoding_ = B22 | ((imm >> 12) << kImm12Shift);
406 }
407 type_ = Immediate;
408 }

◆ Operand() [16/20]

dart::compiler::Operand::Operand ( uint8_t  n,
int8_t  imm_s,
int8_t  imm_r 
)
inline

Definition at line 415 of file assembler_arm64.h.

415 {
416 ASSERT((n == 1) || (n == 0));
417 ASSERT(Utils::IsUint(6, imm_s) && Utils::IsUint(6, imm_r));
418 type_ = BitfieldImm;
419 encoding_ = (static_cast<int32_t>(n) << kNShift) |
420 (static_cast<int32_t>(imm_s) << kImmSShift) |
421 (static_cast<int32_t>(imm_r) << kImmRShift);
422 }

◆ Operand() [17/20]

dart::compiler::Operand::Operand ( const Operand other)
inline

Definition at line 75 of file assembler_ia32.h.

75 : ValueObject(), length_(other.length_) {
76 memmove(&encoding_[0], &other.encoding_[0], other.length_);
77 }

◆ Operand() [18/20]

dart::compiler::Operand::Operand ( )
inlineprotected

Definition at line 94 of file assembler_ia32.h.

94: length_(0) {} // Needed by subclass Address.

◆ Operand() [19/20]

dart::compiler::Operand::Operand ( const Operand other)
inline

Definition at line 92 of file assembler_x64.h.

93 : ValueObject(), length_(other.length_), rex_(other.rex_) {
94 memmove(&encoding_[0], &other.encoding_[0], other.length_);
95 }

◆ Operand() [20/20]

dart::compiler::Operand::Operand ( )
inlineprotected

Definition at line 114 of file assembler_x64.h.

114: length_(0), rex_(REX_NONE) {} // Needed by subclass Address.

Member Function Documentation

◆ base() [1/2]

Register dart::compiler::Operand::base ( ) const
inline

Definition at line 63 of file assembler_ia32.h.

63{ return static_cast<Register>(encoding_at(1) & 7); }

◆ base() [2/2]

Register dart::compiler::Operand::base ( ) const
inline

Definition at line 77 of file assembler_x64.h.

77 {
78 int base_rex = (rex_ & REX_B) << 3;
79 return static_cast<Register>(base_rex + (encoding_at(1) & 7));
80 }

◆ CanHold() [1/2]

static OperandType dart::compiler::Operand::CanHold ( int64_t  imm,
uint8_t  sz,
Operand op 
)
inlinestatic

Definition at line 438 of file assembler_arm64.h.

438 {
439 ASSERT(op != nullptr);
440 ASSERT((sz == kXRegSizeInBits) || (sz == kWRegSizeInBits));
441 if (Utils::IsUint(12, imm)) {
442 op->encoding_ = imm << kImm12Shift;
443 op->type_ = Immediate;
444 } else if (((imm & 0xfff) == 0) && (Utils::IsUint(12, imm >> 12))) {
445 op->encoding_ = B22 | ((imm >> 12) << kImm12Shift);
446 op->type_ = Immediate;
447 } else if (IsImmLogical(imm, sz, op)) {
448 op->type_ = BitfieldImm;
449 } else {
450 op->encoding_ = 0;
451 op->type_ = Unknown;
452 }
453 return op->type_;
454 }
static bool IsImmLogical(uint64_t value, uint8_t width, Operand *imm_op)
const int kXRegSizeInBits
const int kWRegSizeInBits

◆ CanHold() [2/2]

static bool dart::compiler::Operand::CanHold ( uint32_t  immediate,
Operand o 
)
inlinestatic

Definition at line 182 of file assembler_arm.h.

182 {
183 // Avoid the more expensive test for frequent small immediate values.
184 if (immediate < (1 << kImmed8Bits)) {
185 o->type_ = 1;
186 o->encoding_ = (0 << kRotateShift) | (immediate << kImmed8Shift);
187 return true;
188 }
189 // Note that immediate must be unsigned for the test to work correctly.
190 for (int rot = 0; rot < 16; rot++) {
191 uint32_t imm8 = Utils::RotateLeft(immediate, 2 * rot);
192 if (imm8 < (1 << kImmed8Bits)) {
193 o->type_ = 1;
194 o->encoding_ = (rot << kRotateShift) | (imm8 << kImmed8Shift);
195 return true;
196 }
197 }
198 return false;
199 }
static T RotateLeft(T value, uint8_t rotate)
Definition utils.h:459

◆ disp32() [1/2]

int32_t dart::compiler::Operand::disp32 ( ) const
inline

Definition at line 70 of file assembler_ia32.h.

70 {
71 ASSERT(length_ >= 5);
72 return bit_copy<int32_t>(encoding_[length_ - 4]);
73 }

◆ disp32() [2/2]

int32_t dart::compiler::Operand::disp32 ( ) const
inline

Definition at line 87 of file assembler_x64.h.

87 {
88 ASSERT(length_ >= 5);
89 return bit_copy<int32_t>(encoding_[length_ - 4]);
90 }

◆ disp8() [1/2]

int8_t dart::compiler::Operand::disp8 ( ) const
inline

Definition at line 65 of file assembler_ia32.h.

65 {
66 ASSERT(length_ >= 2);
67 return static_cast<int8_t>(encoding_[length_ - 1]);
68 }

◆ disp8() [2/2]

int8_t dart::compiler::Operand::disp8 ( ) const
inline

Definition at line 82 of file assembler_x64.h.

82 {
83 ASSERT(length_ >= 2);
84 return static_cast<int8_t>(encoding_[length_ - 1]);
85 }

◆ Equals() [1/2]

bool dart::compiler::Operand::Equals ( const Operand other) const
inline

Definition at line 85 of file assembler_ia32.h.

85 {
86 if (length_ != other.length_) return false;
87 for (uint8_t i = 0; i < length_; i++) {
88 if (encoding_[i] != other.encoding_[i]) return false;
89 }
90 return true;
91 }

◆ Equals() [2/2]

bool dart::compiler::Operand::Equals ( const Operand other) const
inline

Definition at line 104 of file assembler_x64.h.

104 {
105 if (length_ != other.length_) return false;
106 if (rex_ != other.rex_) return false;
107 for (uint8_t i = 0; i < length_; i++) {
108 if (encoding_[i] != other.encoding_[i]) return false;
109 }
110 return true;
111 }

◆ index() [1/2]

Register dart::compiler::Operand::index ( ) const
inline

Definition at line 59 of file assembler_ia32.h.

59 {
60 return static_cast<Register>((encoding_at(1) >> 3) & 7);
61 }

◆ index() [2/2]

Register dart::compiler::Operand::index ( ) const
inline

Definition at line 72 of file assembler_x64.h.

72 {
73 int index_rex = (rex_ & REX_X) << 2;
74 return static_cast<Register>(index_rex + ((encoding_at(1) >> 3) & 7));
75 }

◆ IsImmLogical()

static bool dart::compiler::Operand::IsImmLogical ( uint64_t  value,
uint8_t  width,
Operand imm_op 
)
static

◆ mod() [1/2]

uint8_t dart::compiler::Operand::mod ( ) const
inline

Definition at line 51 of file assembler_ia32.h.

51{ return (encoding_at(0) >> 6) & 3; }

◆ mod() [2/2]

uint8_t dart::compiler::Operand::mod ( ) const
inline

Definition at line 61 of file assembler_x64.h.

61{ return (encoding_at(0) >> 6) & 3; }

◆ operator=() [1/4]

Operand & dart::compiler::Operand::operator= ( const Operand other)
inline

Definition at line 139 of file assembler_arm.h.

139 {
140 type_ = other.type_;
141 encoding_ = other.encoding_;
142 return *this;
143 }

◆ operator=() [2/4]

Operand & dart::compiler::Operand::operator= ( const Operand other)
inline

Definition at line 364 of file assembler_arm64.h.

364 {
365 type_ = other.type_;
366 encoding_ = other.encoding_;
367 return *this;
368 }

◆ operator=() [3/4]

Operand & dart::compiler::Operand::operator= ( const Operand other)
inline

Definition at line 79 of file assembler_ia32.h.

79 {
80 length_ = other.length_;
81 memmove(&encoding_[0], &other.encoding_[0], other.length_);
82 return *this;
83 }

◆ operator=() [4/4]

Operand & dart::compiler::Operand::operator= ( const Operand other)
inline

Definition at line 97 of file assembler_x64.h.

97 {
98 length_ = other.length_;
99 rex_ = other.rex_;
100 memmove(&encoding_[0], &other.encoding_[0], other.length_);
101 return *this;
102 }

◆ rex()

uint8_t dart::compiler::Operand::rex ( ) const
inline

Definition at line 59 of file assembler_x64.h.

59{ return rex_; }

◆ rm() [1/2]

Register dart::compiler::Operand::rm ( ) const
inline

Definition at line 53 of file assembler_ia32.h.

53{ return static_cast<Register>(encoding_at(0) & 7); }

◆ rm() [2/2]

Register dart::compiler::Operand::rm ( ) const
inline

Definition at line 63 of file assembler_x64.h.

63 {
64 int rm_rex = (rex_ & REX_B) << 3;
65 return static_cast<Register>(rm_rex + (encoding_at(0) & 7));
66 }

◆ scale() [1/2]

ScaleFactor dart::compiler::Operand::scale ( ) const
inline

Definition at line 55 of file assembler_ia32.h.

55 {
56 return static_cast<ScaleFactor>((encoding_at(1) >> 6) & 3);
57 }

◆ scale() [2/2]

ScaleFactor dart::compiler::Operand::scale ( ) const
inline

Definition at line 68 of file assembler_x64.h.

68 {
69 return static_cast<ScaleFactor>((encoding_at(1) >> 6) & 3);
70 }

◆ SetDisp32() [1/2]

void dart::compiler::Operand::SetDisp32 ( int32_t  disp)
inlineprotected

Definition at line 114 of file assembler_ia32.h.

114 {
115 ASSERT(length_ == 1 || length_ == 2);
116 intptr_t disp_size = sizeof(disp);
117 memmove(&encoding_[length_], &disp, disp_size);
118 length_ += disp_size;
119 }

◆ SetDisp32() [2/2]

void dart::compiler::Operand::SetDisp32 ( int32_t  disp)
inlineprotected

Definition at line 142 of file assembler_x64.h.

142 {
143 ASSERT(length_ == 1 || length_ == 2);
144 memmove(&encoding_[length_], &disp, sizeof(disp));
145 length_ += sizeof(disp);
146 }

◆ SetDisp8() [1/2]

void dart::compiler::Operand::SetDisp8 ( int8_t  disp)
inlineprotected

Definition at line 109 of file assembler_ia32.h.

109 {
110 ASSERT(length_ == 1 || length_ == 2);
111 encoding_[length_++] = static_cast<uint8_t>(disp);
112 }

◆ SetDisp8() [2/2]

void dart::compiler::Operand::SetDisp8 ( int8_t  disp)
inlineprotected

Definition at line 137 of file assembler_x64.h.

137 {
138 ASSERT(length_ == 1 || length_ == 2);
139 encoding_[length_++] = static_cast<uint8_t>(disp);
140 }

◆ SetModRM() [1/2]

void dart::compiler::Operand::SetModRM ( int  mod,
Register  rm 
)
inlineprotected

Definition at line 96 of file assembler_ia32.h.

96 {
97 ASSERT((mod & ~3) == 0);
98 encoding_[0] = (mod << 6) | rm;
99 length_ = 1;
100 }

◆ SetModRM() [2/2]

void dart::compiler::Operand::SetModRM ( int  mod,
Register  rm 
)
inlineprotected

Definition at line 116 of file assembler_x64.h.

116 {
117 ASSERT((mod & ~3) == 0);
118 if ((rm > 7) && !((rm == R12) && (mod != 3))) {
119 rex_ |= REX_B;
120 }
121 encoding_[0] = (mod << 6) | (rm & 7);
122 length_ = 1;
123 }

◆ SetSIB() [1/2]

void dart::compiler::Operand::SetSIB ( ScaleFactor  scale,
Register  index,
Register  base 
)
inlineprotected

Definition at line 102 of file assembler_ia32.h.

102 {
103 ASSERT(length_ == 1);
104 ASSERT((scale & ~3) == 0);
105 encoding_[1] = (scale << 6) | (index << 3) | base;
106 length_ = 2;
107 }
Register base() const
Register index() const
ScaleFactor scale() const

◆ SetSIB() [2/2]

void dart::compiler::Operand::SetSIB ( ScaleFactor  scale,
Register  index,
Register  base 
)
inlineprotected

Definition at line 125 of file assembler_x64.h.

125 {
126 ASSERT(length_ == 1);
127 ASSERT((scale & ~3) == 0);
128 if (base > 7) {
129 ASSERT((rex_ & REX_B) == 0); // Must not have REX.B already set.
130 rex_ |= REX_B;
131 }
132 if (index > 7) rex_ |= REX_X;
133 encoding_[1] = (scale << 6) | ((index & 7) << 3) | (base & 7);
134 length_ = 2;
135 }

Friends And Related Symbol Documentation

◆ Address

friend class Address
friend

Definition at line 218 of file assembler_arm.h.

◆ Assembler

Assembler
friend

Definition at line 217 of file assembler_arm.h.


The documentation for this class was generated from the following files: