5#ifndef V8_EXECUTION_ARM64_SIMULATOR_ARM64_H_
6#define V8_EXECUTION_ARM64_SIMULATOR_ARM64_H_
11#if defined(USE_SIMULATOR)
44template <
class T,
int ebits,
int mbits>
45T FPRound(int64_t
sign, int64_t exponent, uint64_t mantissa,
47 static_assert((
sizeof(
T) * 8) >= (1 + ebits + mbits),
48 "destination type T not large enough");
49 static_assert(
sizeof(
T) <=
sizeof(uint64_t),
50 "maximum size of destination type T is 64 bits");
51 static_assert(std::is_unsigned<T>::value,
52 "destination type T must be unsigned");
110 const int mantissa_offset = 0;
111 const int exponent_offset = mantissa_offset + mbits;
112 const int sign_offset = exponent_offset + ebits;
113 DCHECK_EQ(sign_offset,
static_cast<int>(
sizeof(T) * 8 - 1));
117 return static_cast<T
>(
sign << sign_offset);
122 const int infinite_exponent = (1 << ebits) - 1;
123 const int max_normal_exponent = infinite_exponent - 1;
127 exponent += max_normal_exponent >> 1;
129 if (exponent > max_normal_exponent) {
133 exponent = infinite_exponent;
139 exponent = max_normal_exponent;
140 mantissa = (UINT64_C(1) << exponent_offset) - 1;
142 return static_cast<T
>((
sign << sign_offset) |
143 (exponent << exponent_offset) |
144 (mantissa << mantissa_offset));
150 int shift = highest_significant_bit - mbits;
157 shift += -exponent + 1;
164 if (shift > (highest_significant_bit + 1)) {
167 return static_cast<T
>(
sign << sign_offset);
173 return static_cast<T
>((
sign << sign_offset) | 1);
182 mantissa &= ~(UINT64_C(1) << highest_significant_bit);
189 uint64_t onebit_mantissa = (mantissa >> (shift)) & 1;
190 uint64_t halfbit_mantissa = (mantissa >> (shift - 1)) & 1;
191 uint64_t adjustment = (halfbit_mantissa & ~onebit_mantissa);
192 uint64_t adjusted = mantissa - adjustment;
193 T halfbit_adjusted = (adjusted >> (shift - 1)) & 1;
196 static_cast<T
>((
sign << sign_offset) | (exponent << exponent_offset) |
197 ((mantissa >> shift) << mantissa_offset));
207 return result + halfbit_adjusted;
212 uint64_t fractional_bits = mantissa & ((UINT64_C(1) << shift) - 1);
213 if (fractional_bits != 0) {
214 mantissa |= UINT64_C(1) << shift;
217 return static_cast<T
>((
sign << sign_offset) |
218 (exponent << exponent_offset) |
219 ((mantissa >> shift) << mantissa_offset));
225 return static_cast<T
>((
sign << sign_offset) |
226 (exponent << exponent_offset) |
227 ((mantissa << -shift) << mantissa_offset));
238 template <
typename T>
239 static T AddressUntag(T address) {
242 uint64_t bits = (uint64_t)address;
243 return (T)(bits & ~kAddressTagMask);
246 template <
typename T,
typename A>
247 static T Read(A address) {
249 address = AddressUntag(address);
250 DCHECK((
sizeof(value) == 1) || (
sizeof(value) == 2) ||
251 (
sizeof(value) == 4) || (
sizeof(value) == 8) ||
252 (
sizeof(value) == 16));
253 memcpy(&value,
reinterpret_cast<const char*
>(address),
sizeof(value));
257 template <
typename T,
typename A>
258 static void Write(A address, T value) {
259 address = AddressUntag(address);
260 DCHECK((
sizeof(value) == 1) || (
sizeof(value) == 2) ||
261 (
sizeof(value) == 4) || (
sizeof(value) == 8) ||
262 (
sizeof(value) == 16));
263 memcpy(
reinterpret_cast<char*
>(address), &value,
sizeof(value));
270class SimSystemRegister {
274 SimSystemRegister() :
value_(0), write_ignore_mask_(0xffffffff) {}
276 uint32_t RawValue()
const {
return value_; }
278 void SetRawValue(uint32_t new_value) {
279 value_ = (
value_ & write_ignore_mask_) | (new_value & ~write_ignore_mask_);
282 uint32_t Bits(
int msb,
int lsb)
const {
286 int32_t SignedBits(
int msb,
int lsb)
const {
290 void SetBits(
int msb,
int lsb, uint32_t bits);
293 static SimSystemRegister DefaultValueFor(SystemRegister
id);
295#define DEFINE_GETTER(Name, HighBit, LowBit, Func, Type) \
296 Type Name() const { return static_cast<Type>(Func(HighBit, LowBit)); } \
297 void Set##Name(Type bits) { \
298 SetBits(HighBit, LowBit, static_cast<Type>(bits)); \
300#define DEFINE_WRITE_IGNORE_MASK(Name, Mask) \
301 static const uint32_t Name##WriteIgnoreMask = ~static_cast<uint32_t>(Mask);
303#undef DEFINE_ZERO_BITS
310 SimSystemRegister(uint32_t value, uint32_t write_ignore_mask)
311 :
value_(value), write_ignore_mask_(write_ignore_mask) {}
314 uint32_t write_ignore_mask_;
318template <
int kSizeInBytes>
319class SimRegisterBase {
321 template <
typename T>
322 void Set(T new_value) {
323 static_assert(
sizeof(new_value) <= kSizeInBytes,
324 "Size of new_value must be <= size of template type.");
325 if (
sizeof(new_value) < kSizeInBytes) {
327 memset(
value_ +
sizeof(new_value), 0, kSizeInBytes -
sizeof(new_value));
329 memcpy(&
value_, &new_value,
sizeof(T));
330 NotifyRegisterWrite();
337 template <
typename T>
338 void Insert(
int lane, T new_value) {
340 DCHECK_LE(
sizeof(new_value) + (lane *
sizeof(new_value)),
341 static_cast<unsigned>(kSizeInBytes));
342 memcpy(&
value_[lane *
sizeof(new_value)], &new_value,
sizeof(new_value));
343 NotifyRegisterWrite();
346 template <
typename T>
347 T
Get(
int lane = 0)
const {
351 static_cast<unsigned>(kSizeInBytes));
359 bool WrittenSinceLastLog()
const {
return written_since_last_log_; }
361 void NotifyRegisterLogged() { written_since_last_log_ =
false; }
364 uint8_t
value_[kSizeInBytes];
367 bool written_since_last_log_;
369 void NotifyRegisterWrite() { written_since_last_log_ =
true; }
372using SimRegister = SimRegisterBase<kXRegSize>;
373using SimVRegister = SimRegisterBase<kQRegSize>;
375using sim_uint128_t = std::pair<uint64_t, uint64_t>;
379class LogicVRegister {
381 inline LogicVRegister(SimVRegister& other)
384 saturated_[
i] = kNotSaturated;
391 int64_t Int(VectorFormat vform,
int index)
const {
395 element = register_.Get<int8_t>(
index);
404 element = register_.Get<int64_t>(
index);
413 uint64_t Uint(VectorFormat vform,
int index)
const {
417 element = register_.Get<uint8_t>(
index);
423 element = register_.Get<uint32_t>(
index);
426 element = register_.Get<uint64_t>(
index);
435 uint64_t UintLeftJustified(VectorFormat vform,
int index)
const {
439 int64_t IntLeftJustified(VectorFormat vform,
int index)
const {
440 uint64_t value = UintLeftJustified(vform, index);
446 void SetInt(VectorFormat vform,
int index, int64_t value)
const {
449 register_.Insert(index,
static_cast<int8_t
>(value));
452 register_.Insert(index,
static_cast<int16_t>(value));
455 register_.Insert(index,
static_cast<int32_t>(value));
458 register_.Insert(index,
static_cast<int64_t
>(value));
466 void SetIntArray(VectorFormat vform,
const int64_t* src)
const {
467 ClearForWrite(vform);
469 SetInt(vform,
i, src[
i]);
473 void SetUint(VectorFormat vform,
int index, uint64_t value)
const {
476 register_.Insert(index,
static_cast<uint8_t
>(value));
479 register_.Insert(index,
static_cast<uint16_t>(value));
482 register_.Insert(index,
static_cast<uint32_t
>(value));
485 register_.Insert(index,
static_cast<uint64_t
>(value));
493 void SetUint(VectorFormat vform,
int index, sim_uint128_t value)
const {
495 SetUint(vform, index, value.second);
498 DCHECK((vform == kFormat1Q) && (index == 0));
499 SetUint(kFormat2D, 0, value.second);
500 SetUint(kFormat2D, 1, value.first);
503 void SetUintArray(VectorFormat vform,
const uint64_t* src)
const {
504 ClearForWrite(vform);
506 SetUint(vform,
i, src[
i]);
510 void ReadUintFromMem(VectorFormat vform,
int index, uint64_t addr)
const;
512 void WriteUintToMem(VectorFormat vform,
int index, uint64_t addr)
const;
514 template <
typename T>
515 T
Float(
int index)
const {
516 return register_.Get<T>(
index);
519 template <
typename T>
520 void SetFloat(
int index, T value)
const {
521 register_.Insert(index, value);
526 void ClearForWrite(VectorFormat vform)
const {
529 SetUint(kFormat16B,
i, 0);
536 kSignedSatPositive = 1 << 0,
537 kSignedSatNegative = 1 << 1,
538 kSignedSatMask = kSignedSatPositive | kSignedSatNegative,
539 kSignedSatUndefined = kSignedSatMask,
540 kUnsignedSatPositive = 1 << 2,
541 kUnsignedSatNegative = 1 << 3,
542 kUnsignedSatMask = kUnsignedSatPositive | kUnsignedSatNegative,
543 kUnsignedSatUndefined = kUnsignedSatMask
547 Saturation GetSignedSaturation(
int index) {
548 return static_cast<Saturation
>(saturated_[
index] & kSignedSatMask);
551 Saturation GetUnsignedSaturation(
int index) {
552 return static_cast<Saturation
>(saturated_[
index] & kUnsignedSatMask);
556 void ClearSat(
int index) { saturated_[
index] = kNotSaturated; }
558 void SetSignedSat(
int index,
bool positive) {
559 SetSatFlag(index, positive ? kSignedSatPositive : kSignedSatNegative);
562 void SetUnsignedSat(
int index,
bool positive) {
563 SetSatFlag(index, positive ? kUnsignedSatPositive : kUnsignedSatNegative);
566 void SetSatFlag(
int index, Saturation sat) {
567 saturated_[
index] =
static_cast<Saturation
>(saturated_[
index] | sat);
568 DCHECK_NE(sat & kUnsignedSatMask, kUnsignedSatUndefined);
569 DCHECK_NE(sat & kSignedSatMask, kSignedSatUndefined);
573 LogicVRegister& SignedSaturate(VectorFormat vform) {
575 Saturation sat = GetSignedSaturation(
i);
576 if (sat == kSignedSatPositive) {
578 }
else if (sat == kSignedSatNegative) {
585 LogicVRegister& UnsignedSaturate(VectorFormat vform) {
587 Saturation sat = GetUnsignedSaturation(
i);
588 if (sat == kUnsignedSatPositive) {
590 }
else if (sat == kUnsignedSatNegative) {
591 SetUint(vform,
i, 0);
598 bool GetRounding(
int index) {
return round_[
index]; }
601 void SetRounding(
int index,
bool round) { round_[
index] = round; }
604 LogicVRegister& Round(VectorFormat vform) {
606 SetUint(vform,
i, Uint(vform,
i) + (GetRounding(
i) ? 1 : 0));
613 LogicVRegister& Uhalve(VectorFormat vform) {
615 uint64_t val = Uint(vform,
i);
616 SetRounding(
i, (val & 1) == 1);
618 if (GetUnsignedSaturation(
i) != kNotSaturated) {
623 SetInt(vform,
i, val);
629 LogicVRegister& Halve(VectorFormat vform) {
631 int64_t val = Int(vform,
i);
632 SetRounding(
i, (val & 1) == 1);
634 if (GetSignedSaturation(
i) != kNotSaturated) {
639 SetInt(vform,
i, val);
644 bool Is(
const LogicVRegister&
r)
const {
return ®ister_ == &
r.register_; }
647 SimVRegister& register_;
659class Simulator :
public DecoderVisitor,
public SimulatorBase {
661 static void SetRedirectInstruction(Instruction* instruction);
662 static bool ICacheMatch(
void*
one,
void* two) {
return false; }
663 static void FlushICache(base::CustomMatcherHashMap* i_cache,
void*
start,
671 Decoder<DispatchingDecoderVisitor>* decoder, Isolate* isolate =
nullptr,
672 FILE* stream = stderr);
686 template <
typename T>
687 explicit CallArgument(T argument) {
689 DCHECK(
sizeof(argument) <=
sizeof(bits_));
690 memcpy(&bits_, &argument,
sizeof(argument));
694 explicit CallArgument(
double argument) {
695 DCHECK(
sizeof(argument) ==
sizeof(bits_));
696 memcpy(&bits_, &argument,
sizeof(argument));
700 explicit CallArgument(
float argument) {
703 DCHECK(
sizeof(kFP64SignallingNaN) ==
sizeof(bits_));
704 memcpy(&bits_, &kFP64SignallingNaN,
sizeof(kFP64SignallingNaN));
706 DCHECK(
sizeof(argument) <=
sizeof(bits_));
707 memcpy(&bits_, &argument,
sizeof(argument));
713 static CallArgument End() {
return CallArgument(); }
715 int64_t bits()
const {
return bits_; }
716 bool IsEnd()
const {
return type_ == NO_ARG; }
717 bool IsX()
const {
return type_ == X_ARG; }
718 bool IsD()
const {
return type_ == D_ARG; }
721 enum CallArgumentType { X_ARG, D_ARG, NO_ARG };
726 CallArgumentType
type_;
728 CallArgument() {
type_ = NO_ARG; }
732 template <
typename Return,
typename... Args>
733 Return Call(Address entry, Args...
args) {
735 CallArgument call_args[] = {CallArgument(
args)..., CallArgument::End()};
736 CallImpl(entry, call_args);
737 return ReadReturn<Return>();
746 bool ExecDebugCommand(ArrayUniquePtr<char> command);
748 bool GetValue(
const char* desc, int64_t* value);
750 bool PrintValue(
const char* desc);
760 uintptr_t StackLimit(uintptr_t c_limit)
const;
761 uintptr_t StackBase()
const;
762 void SetStackLimit(uintptr_t limit);
765 base::Vector<uint8_t> GetCentralStackView()
const;
766 static constexpr int JSStackLimitMargin() {
return kAdditionalStackMargin; }
772 void DoRuntimeCall(Instruction*
instr);
775 static const Instruction* kEndOfSimAddress;
776 void DecodeInstruction();
781 template <
typename T>
782 void set_pc(T new_pc) {
783 static_assert(
sizeof(
T) ==
sizeof(
pc_));
784 memcpy(&
pc_, &new_pc,
sizeof(T));
787 Instruction*
pc() {
return pc_; }
789 void increment_pc() {
794 pc_modified_ =
false;
797 virtual void Decode(Instruction*
instr) { decoder_->Decode(
instr); }
834 BranchFromUnguardedOrToIP = 1,
841 BranchFromGuardedNotToIP = 3
844 BType btype()
const {
return btype_; }
845 void ResetBType() { btype_ = DefaultBType; }
846 void set_btype(BType btype) { btype_ = btype; }
849 BType GetBTypeFromInstruction(
const Instruction*
instr)
const;
851 bool PcIsInGuardedPage()
const {
return guard_pages_; }
852 void SetGuardedPages(
bool guard_pages) { guard_pages_ = guard_pages; }
854 void CheckBTypeForPAuth() {
861 case BranchFromGuardedNotToIP:
866 FATAL(
"Executing PACIBSP with wrong BType.");
867 case BranchFromUnguardedOrToIP:
875 void CheckBTypeForBti() {
877 switch (
pc_->ImmHint()) {
881 DCHECK(btype() != DefaultBType);
882 FATAL(
"Executing BTI with wrong BType (expected 0, got %d).", btype());
886 if (btype() == BranchFromGuardedNotToIP) {
887 FATAL(
"Executing BTI c with wrong BType (3).");
891 if (btype() == BranchAndLink) {
892 FATAL(
"Executing BTI j with wrong BType (2).");
903 if (PcIsInGuardedPage() && (btype() != DefaultBType)) {
904 if (
pc_->IsPAuth()) {
905 CheckBTypeForPAuth();
906 }
else if (
pc_->IsBti()) {
908 }
else if (!
pc_->IsException()) {
909 FATAL(
"Executing non-BTI instruction with wrong BType.");
914 void ExecuteInstruction() {
921 LogAllWrittenRegisters();
926#define DECLARE(A) void Visit##A(Instruction* instr);
929 void VisitNEON3SameFP(NEON3SameOp op, VectorFormat vf, SimVRegister& rd,
930 SimVRegister& rn, SimVRegister& rm);
932 bool IsZeroRegister(
unsigned code, Reg31Mode r31mode)
const {
933 return ((code == 31) && (r31mode == Reg31IsZeroRegister));
940 template <
typename T>
941 T
reg(
unsigned code, Reg31Mode r31mode = Reg31IsZeroRegister)
const {
942 DCHECK_LT(code,
static_cast<unsigned>(kNumberOfRegisters));
943 if (IsZeroRegister(code, r31mode)) {
950 int32_t wreg(
unsigned code, Reg31Mode r31mode = Reg31IsZeroRegister)
const {
954 int64_t xreg(
unsigned code, Reg31Mode r31mode = Reg31IsZeroRegister)
const {
958 enum RegLogMode { LogRegWrites, NoRegLog };
962 template <
typename T>
963 void set_reg(
unsigned code, T value,
964 Reg31Mode r31mode = Reg31IsZeroRegister) {
965 set_reg_no_log(code, value, r31mode);
966 LogRegister(code, r31mode);
970 void set_wreg(
unsigned code, int32_t value,
971 Reg31Mode r31mode = Reg31IsZeroRegister) {
972 set_reg(code, value, r31mode);
975 void set_xreg(
unsigned code, int64_t value,
976 Reg31Mode r31mode = Reg31IsZeroRegister) {
977 set_reg(code, value, r31mode);
981 template <
typename T>
982 void set_reg_no_log(
unsigned code, T value,
983 Reg31Mode r31mode = Reg31IsZeroRegister) {
984 DCHECK_LT(code,
static_cast<unsigned>(kNumberOfRegisters));
985 if (!IsZeroRegister(code, r31mode)) {
990 void set_wreg_no_log(
unsigned code, int32_t value,
991 Reg31Mode r31mode = Reg31IsZeroRegister) {
992 set_reg_no_log(code, value, r31mode);
995 void set_xreg_no_log(
unsigned code, int64_t value,
996 Reg31Mode r31mode = Reg31IsZeroRegister) {
997 set_reg_no_log(code, value, r31mode);
1001 template <
typename T>
1002 void set_lr(T value) {
1003 DCHECK_EQ(
sizeof(T),
static_cast<unsigned>(kSystemPointerSize));
1004 set_reg(kLinkRegCode, value);
1007 template <
typename T>
1008 void set_sp(T value) {
1009 DCHECK_EQ(
sizeof(T),
static_cast<unsigned>(kSystemPointerSize));
1010 set_reg(31, value, Reg31IsStackPointer);
1023 template <
typename T>
1024 T vreg(
unsigned code)
const {
1028 "Template type must match size of register.");
1029 DCHECK_LT(code,
static_cast<unsigned>(kNumberOfVRegisters));
1031 return vregisters_[
code].Get<T>();
1034 inline SimVRegister& vreg(
unsigned code) {
return vregisters_[
code]; }
1036 int64_t
sp() {
return xreg(31, Reg31IsStackPointer); }
1037 int64_t fp() {
return xreg(kFramePointerRegCode, Reg31IsStackPointer); }
1043 uint8_t breg(
unsigned code)
const {
return vreg<uint8_t>(code); }
1045 float hreg(
unsigned code)
const {
return vreg<uint16_t>(code); }
1047 float sreg(
unsigned code)
const {
return vreg<float>(code); }
1049 uint32_t sreg_bits(
unsigned code)
const {
return vreg<uint32_t>(code); }
1051 double dreg(
unsigned code)
const {
return vreg<double>(code); }
1053 uint64_t dreg_bits(
unsigned code)
const {
return vreg<uint64_t>(code); }
1055 qreg_t qreg(
unsigned code)
const {
return vreg<qreg_t>(code); }
1059 template <
typename T>
1060 T vreg(
unsigned size,
unsigned code)
const {
1066 raw = vreg<uint32_t>(code);
1069 raw = vreg<uint64_t>(code);
1075 static_assert(
sizeof(
result) <=
sizeof(raw),
1076 "Template type must be <= 64 bits.");
1084 template <
typename T>
1085 void set_vreg(
unsigned code, T value, RegLogMode log_mode = LogRegWrites) {
1090 "Template type must match size of register.");
1091 DCHECK_LT(code,
static_cast<unsigned>(kNumberOfVRegisters));
1092 vregisters_[
code].Set(value);
1094 if (log_mode == LogRegWrites) {
1095 LogVRegister(code, GetPrintRegisterFormat(value));
1100 void set_breg(
unsigned code, int8_t value,
1101 RegLogMode log_mode = LogRegWrites) {
1102 set_vreg(code, value, log_mode);
1105 void set_hreg(
unsigned code, int16_t value,
1106 RegLogMode log_mode = LogRegWrites) {
1107 set_vreg(code, value, log_mode);
1110 void set_sreg(
unsigned code,
float value,
1111 RegLogMode log_mode = LogRegWrites) {
1112 set_vreg(code, value, log_mode);
1115 void set_sreg_bits(
unsigned code, uint32_t value,
1116 RegLogMode log_mode = LogRegWrites) {
1117 set_vreg(code, value, log_mode);
1120 void set_dreg(
unsigned code,
double value,
1121 RegLogMode log_mode = LogRegWrites) {
1122 set_vreg(code, value, log_mode);
1125 void set_dreg_bits(
unsigned code, uint64_t value,
1126 RegLogMode log_mode = LogRegWrites) {
1127 set_vreg(code, value, log_mode);
1130 void set_qreg(
unsigned code, qreg_t value,
1131 RegLogMode log_mode = LogRegWrites) {
1132 set_vreg(code, value, log_mode);
1136 template <
typename T>
1137 void set_vreg_no_log(
unsigned code, T value) {
1142 DCHECK_LT(code,
static_cast<unsigned>(kNumberOfVRegisters));
1143 vregisters_[
code].Set(value);
1146 void set_breg_no_log(
unsigned code, uint8_t value) {
1147 set_vreg_no_log(code, value);
1150 void set_hreg_no_log(
unsigned code, uint16_t value) {
1151 set_vreg_no_log(code, value);
1154 void set_sreg_no_log(
unsigned code,
float value) {
1155 set_vreg_no_log(code, value);
1158 void set_dreg_no_log(
unsigned code,
double value) {
1159 set_vreg_no_log(code, value);
1162 void set_qreg_no_log(
unsigned code, qreg_t value) {
1163 set_vreg_no_log(code, value);
1166 SimSystemRegister& nzcv() {
return nzcv_; }
1167 SimSystemRegister& fpcr() {
return fpcr_; }
1169 bool DN() {
return fpcr_.DN() != 0; }
1175 Instruction* location;
1178 std::vector<Breakpoint> breakpoints_;
1179 void SetBreakpoint(Instruction* breakpoint);
1180 void ListBreakpoints();
1181 void CheckBreakpoints();
1186 bool break_on_next_;
1189 void CheckBreakNext();
1192 void PrintInstructionsAt(Instruction*
pc, uint64_t count);
1195 void PrintRegisters();
1196 void PrintVRegisters();
1197 void PrintSystemRegisters();
1200 void PrintWrittenRegisters();
1201 void PrintWrittenVRegisters();
1204 void LogWrittenRegisters() {
1205 if (log_parameters() & LOG_REGS) PrintWrittenRegisters();
1207 void LogWrittenVRegisters() {
1208 if (log_parameters() & LOG_VREGS) PrintWrittenVRegisters();
1210 void LogAllWrittenRegisters() {
1211 LogWrittenRegisters();
1212 LogWrittenVRegisters();
1216 enum PrintRegisterFormat {
1218 kPrintRegLaneSizeB = 0 << 0,
1219 kPrintRegLaneSizeH = 1 << 0,
1220 kPrintRegLaneSizeS = 2 << 0,
1221 kPrintRegLaneSizeW = kPrintRegLaneSizeS,
1222 kPrintRegLaneSizeD = 3 << 0,
1223 kPrintRegLaneSizeX = kPrintRegLaneSizeD,
1224 kPrintRegLaneSizeQ = 4 << 0,
1226 kPrintRegLaneSizeOffset = 0,
1227 kPrintRegLaneSizeMask = 7 << 0,
1230 kPrintRegAsScalar = 0,
1231 kPrintRegAsDVector = 1 << 3,
1232 kPrintRegAsQVector = 2 << 3,
1234 kPrintRegAsVectorMask = 3 << 3,
1238 kPrintRegAsFP = 1 << 5,
1242 kPrintXReg = kPrintRegLaneSizeX | kPrintRegAsScalar,
1243 kPrintWReg = kPrintRegLaneSizeW | kPrintRegAsScalar,
1244 kPrintSReg = kPrintRegLaneSizeS | kPrintRegAsScalar | kPrintRegAsFP,
1245 kPrintDReg = kPrintRegLaneSizeD | kPrintRegAsScalar | kPrintRegAsFP,
1247 kPrintReg1B = kPrintRegLaneSizeB | kPrintRegAsScalar,
1248 kPrintReg8B = kPrintRegLaneSizeB | kPrintRegAsDVector,
1249 kPrintReg16B = kPrintRegLaneSizeB | kPrintRegAsQVector,
1250 kPrintReg1H = kPrintRegLaneSizeH | kPrintRegAsScalar,
1251 kPrintReg4H = kPrintRegLaneSizeH | kPrintRegAsDVector,
1252 kPrintReg8H = kPrintRegLaneSizeH | kPrintRegAsQVector,
1253 kPrintReg1S = kPrintRegLaneSizeS | kPrintRegAsScalar,
1254 kPrintReg2S = kPrintRegLaneSizeS | kPrintRegAsDVector,
1255 kPrintReg4S = kPrintRegLaneSizeS | kPrintRegAsQVector,
1256 kPrintReg1SFP = kPrintRegLaneSizeS | kPrintRegAsScalar | kPrintRegAsFP,
1257 kPrintReg2SFP = kPrintRegLaneSizeS | kPrintRegAsDVector | kPrintRegAsFP,
1258 kPrintReg4SFP = kPrintRegLaneSizeS | kPrintRegAsQVector | kPrintRegAsFP,
1259 kPrintReg1D = kPrintRegLaneSizeD | kPrintRegAsScalar,
1260 kPrintReg2D = kPrintRegLaneSizeD | kPrintRegAsQVector,
1261 kPrintReg1DFP = kPrintRegLaneSizeD | kPrintRegAsScalar | kPrintRegAsFP,
1262 kPrintReg2DFP = kPrintRegLaneSizeD | kPrintRegAsQVector | kPrintRegAsFP,
1263 kPrintReg1Q = kPrintRegLaneSizeQ | kPrintRegAsScalar
1266 unsigned GetPrintRegLaneSizeInBytesLog2(PrintRegisterFormat format) {
1267 return (format & kPrintRegLaneSizeMask) >> kPrintRegLaneSizeOffset;
1270 unsigned GetPrintRegLaneSizeInBytes(PrintRegisterFormat format) {
1271 return 1 << GetPrintRegLaneSizeInBytesLog2(format);
1274 unsigned GetPrintRegSizeInBytesLog2(PrintRegisterFormat format) {
1279 return GetPrintRegLaneSizeInBytesLog2(format);
1282 unsigned GetPrintRegSizeInBytes(PrintRegisterFormat format) {
1283 return 1 << GetPrintRegSizeInBytesLog2(format);
1286 unsigned GetPrintRegLaneCount(PrintRegisterFormat format) {
1287 unsigned reg_size_log2 = GetPrintRegSizeInBytesLog2(format);
1288 unsigned lane_size_log2 = GetPrintRegLaneSizeInBytesLog2(format);
1289 DCHECK_GE(reg_size_log2, lane_size_log2);
1290 return 1 << (reg_size_log2 - lane_size_log2);
1293 template <
typename T>
1294 PrintRegisterFormat GetPrintRegisterFormat(T value) {
1295 return GetPrintRegisterFormatForSize(
sizeof(value));
1298 PrintRegisterFormat GetPrintRegisterFormat(
double value) {
1300 "D register must be size of double.");
1301 return GetPrintRegisterFormatForSizeFP(
sizeof(value));
1304 PrintRegisterFormat GetPrintRegisterFormat(
float value) {
1306 "S register must be size of float.");
1307 return GetPrintRegisterFormatForSizeFP(
sizeof(value));
1310 PrintRegisterFormat GetPrintRegisterFormat(VectorFormat vform);
1311 PrintRegisterFormat GetPrintRegisterFormatFP(VectorFormat vform);
1313 PrintRegisterFormat GetPrintRegisterFormatForSize(
size_t reg_size,
1316 PrintRegisterFormat GetPrintRegisterFormatForSize(
size_t size) {
1317 return GetPrintRegisterFormatForSize(size, size);
1320 PrintRegisterFormat GetPrintRegisterFormatForSizeFP(
size_t size) {
1331 PrintRegisterFormat GetPrintRegisterFormatTryFP(PrintRegisterFormat format) {
1332 if ((GetPrintRegLaneSizeInBytes(format) == kSRegSize) ||
1333 (GetPrintRegLaneSizeInBytes(format) == kDRegSize)) {
1334 return static_cast<PrintRegisterFormat
>(format | kPrintRegAsFP);
1340 void PrintRegister(
unsigned code, Reg31Mode r31mode = Reg31IsStackPointer);
1341 void PrintVRegister(
unsigned code, PrintRegisterFormat sizes);
1342 void PrintSystemRegister(SystemRegister
id);
1345 void LogRegister(
unsigned code, Reg31Mode r31mode = Reg31IsStackPointer) {
1346 if (log_parameters() & LOG_REGS) PrintRegister(code, r31mode);
1348 void LogVRegister(
unsigned code, PrintRegisterFormat format) {
1349 if (log_parameters() & LOG_VREGS) PrintVRegister(code, format);
1351 void LogSystemRegister(SystemRegister
id) {
1352 if (log_parameters() & LOG_SYS_REGS) PrintSystemRegister(
id);
1356 void PrintRead(uintptr_t address,
unsigned reg_code,
1357 PrintRegisterFormat format);
1358 void PrintWrite(uintptr_t address,
unsigned reg_code,
1359 PrintRegisterFormat format);
1360 void PrintVRead(uintptr_t address,
unsigned reg_code,
1361 PrintRegisterFormat format,
unsigned lane);
1362 void PrintVWrite(uintptr_t address,
unsigned reg_code,
1363 PrintRegisterFormat format,
unsigned lane);
1366 void LogRead(uintptr_t address,
unsigned reg_code,
1367 PrintRegisterFormat format) {
1368 if (log_parameters() & LOG_REGS) PrintRead(address, reg_code, format);
1370 void LogWrite(uintptr_t address,
unsigned reg_code,
1371 PrintRegisterFormat format) {
1372 if (log_parameters() & LOG_WRITE) PrintWrite(address, reg_code, format);
1374 void LogVRead(uintptr_t address,
unsigned reg_code,
1375 PrintRegisterFormat format,
unsigned lane = 0) {
1376 if (log_parameters() & LOG_VREGS) {
1377 PrintVRead(address, reg_code, format, lane);
1380 void LogVWrite(uintptr_t address,
unsigned reg_code,
1381 PrintRegisterFormat format,
unsigned lane = 0) {
1382 if (log_parameters() & LOG_WRITE) {
1383 PrintVWrite(address, reg_code, format, lane);
1387 int log_parameters() {
return log_parameters_; }
1388 void set_log_parameters(
int new_parameters) {
1389 log_parameters_ = new_parameters;
1391 if (new_parameters & LOG_DISASM) {
1392 PrintF(
"Run --debug-sim to dynamically turn on disassembler\n");
1396 if (new_parameters & LOG_DISASM) {
1397 decoder_->InsertVisitorBefore(print_disasm_,
this);
1399 decoder_->RemoveVisitor(print_disasm_);
1404 void PrintRegisterRawHelper(
unsigned code, Reg31Mode r31mode,
1405 int size_in_bytes = kXRegSize);
1406 void PrintVRegisterRawHelper(
unsigned code,
int bytes = kQRegSize,
1408 void PrintVRegisterFPHelper(
unsigned code,
unsigned lane_size_in_bytes,
1409 int lane_count = 1,
int rightmost_lane = 0);
1411 static inline const char* WRegNameForCode(
1412 unsigned code, Reg31Mode mode = Reg31IsZeroRegister);
1413 static inline const char* XRegNameForCode(
1414 unsigned code, Reg31Mode mode = Reg31IsZeroRegister);
1415 static inline const char* SRegNameForCode(
unsigned code);
1416 static inline const char* DRegNameForCode(
unsigned code);
1417 static inline const char* VRegNameForCode(
unsigned code);
1418 static inline int CodeFromName(
const char* name);
1420 enum PointerType { kDataPointer, kInstructionPointer };
1431 static bool HasTBI(uint64_t ptr, PointerType type) {
1437 static int GetBottomPACBit(uint64_t ptr,
int ttbr) {
1439 DCHECK((ttbr == 0) || (ttbr == 1));
1446 static int GetTopPACBit(uint64_t ptr, PointerType type) {
1447 return HasTBI(ptr, type) ? 55 : 63;
1457 PACKey
key, PointerType type);
1459 PACKey
key, PointerType type);
1464 bool ConditionPassed(Condition cond) {
1465 SimSystemRegister& flags = nzcv();
1484 return flags.C() && !flags.Z();
1486 return !(flags.C() && !flags.Z());
1488 return flags.N() == flags.V();
1490 return flags.N() != flags.V();
1492 return !flags.Z() && (flags.N() == flags.V());
1494 return !(!flags.Z() && (flags.N() == flags.V()));
1503 bool ConditionFailed(Condition cond) {
return !ConditionPassed(cond); }
1505 template <
typename T>
1506 void AddSubHelper(Instruction*
instr, T op2);
1507 template <
typename T>
1508 T AddWithCarry(
bool set_flags, T left, T right,
int carry_in = 0);
1509 template <
typename T>
1510 void AddSubWithCarry(Instruction*
instr);
1511 template <
typename T>
1512 void LogicalHelper(Instruction*
instr, T op2);
1513 template <
typename T>
1514 void ConditionalCompareHelper(Instruction*
instr, T op2);
1515 void LoadStoreHelper(Instruction*
instr, int64_t
offset, AddrMode addrmode);
1516 void LoadStorePairHelper(Instruction*
instr, AddrMode addrmode);
1517 template <
typename T>
1518 void CompareAndSwapHelper(
const Instruction*
instr);
1519 template <
typename T>
1520 void CompareAndSwapPairHelper(
const Instruction*
instr);
1521 template <
typename T>
1522 void AtomicMemorySimpleHelper(
const Instruction*
instr);
1523 template <
typename T>
1524 void AtomicMemorySwapHelper(
const Instruction*
instr);
1525 uintptr_t LoadStoreAddress(
unsigned addr_reg, int64_t
offset,
1527 void LoadStoreWriteBack(
unsigned addr_reg, int64_t
offset, AddrMode addrmode);
1528 void NEONLoadStoreMultiStructHelper(
const Instruction*
instr,
1529 AddrMode addr_mode);
1530 void NEONLoadStoreSingleStructHelper(
const Instruction*
instr,
1531 AddrMode addr_mode);
1532 void CheckMemoryAccess(uintptr_t address, uintptr_t stack);
1544 bool ProbeMemory(uintptr_t address, uintptr_t access_size);
1547 template <
typename T,
typename A>
1548 T MemoryRead(A address) {
1550 static_assert((
sizeof(
value) == 1) || (
sizeof(
value) == 2) ||
1551 (
sizeof(
value) == 4) || (
sizeof(
value) == 8) ||
1552 (
sizeof(
value) == 16));
1553 memcpy(&value,
reinterpret_cast<const void*
>(address),
sizeof(value));
1558 template <
typename T,
typename A>
1559 void MemoryWrite(A address, T value) {
1560 static_assert((
sizeof(
value) == 1) || (
sizeof(
value) == 2) ||
1561 (
sizeof(
value) == 4) || (
sizeof(
value) == 8) ||
1562 (
sizeof(
value) == 16));
1563 memcpy(
reinterpret_cast<void*
>(address), &value,
sizeof(value));
1566 template <
typename T>
1567 T ShiftOperand(T value, Shift shift_type,
unsigned amount);
1568 template <
typename T>
1569 T ExtendValue(T value, Extend extend_type,
unsigned left_shift = 0);
1570 template <
typename T>
1571 void Extract(Instruction*
instr);
1572 template <
typename T>
1573 void DataProcessing2Source(Instruction*
instr);
1574 template <
typename T>
1575 void BitfieldHelper(Instruction*
instr);
1576 uint16_t PolynomialMult(uint8_t op1, uint8_t op2);
1577 sim_uint128_t PolynomialMult128(uint64_t op1, uint64_t op2,
1578 int lane_size_in_bits)
const;
1579 sim_uint128_t Lsl128(sim_uint128_t
x,
unsigned shift)
const;
1580 sim_uint128_t Eor128(sim_uint128_t
x, sim_uint128_t
y)
const;
1582 void ld1(VectorFormat vform, LogicVRegister dst, uint64_t addr);
1583 void ld1(VectorFormat vform, LogicVRegister dst,
int index, uint64_t addr);
1584 void ld1r(VectorFormat vform, LogicVRegister dst, uint64_t addr);
1585 void ld2(VectorFormat vform, LogicVRegister dst1, LogicVRegister dst2,
1587 void ld2(VectorFormat vform, LogicVRegister dst1, LogicVRegister dst2,
1588 int index, uint64_t addr);
1589 void ld2r(VectorFormat vform, LogicVRegister dst1, LogicVRegister dst2,
1591 void ld3(VectorFormat vform, LogicVRegister dst1, LogicVRegister dst2,
1592 LogicVRegister dst3, uint64_t addr);
1593 void ld3(VectorFormat vform, LogicVRegister dst1, LogicVRegister dst2,
1594 LogicVRegister dst3,
int index, uint64_t addr);
1595 void ld3r(VectorFormat vform, LogicVRegister dst1, LogicVRegister dst2,
1596 LogicVRegister dst3, uint64_t addr);
1597 void ld4(VectorFormat vform, LogicVRegister dst1, LogicVRegister dst2,
1598 LogicVRegister dst3, LogicVRegister dst4, uint64_t addr);
1599 void ld4(VectorFormat vform, LogicVRegister dst1, LogicVRegister dst2,
1600 LogicVRegister dst3, LogicVRegister dst4,
int index, uint64_t addr);
1601 void ld4r(VectorFormat vform, LogicVRegister dst1, LogicVRegister dst2,
1602 LogicVRegister dst3, LogicVRegister dst4, uint64_t addr);
1603 void st1(VectorFormat vform, LogicVRegister src, uint64_t addr);
1604 void st1(VectorFormat vform, LogicVRegister src,
int index, uint64_t addr);
1605 void st2(VectorFormat vform, LogicVRegister src, LogicVRegister src2,
1607 void st2(VectorFormat vform, LogicVRegister src, LogicVRegister src2,
1608 int index, uint64_t addr);
1609 void st3(VectorFormat vform, LogicVRegister src, LogicVRegister src2,
1610 LogicVRegister src3, uint64_t addr);
1611 void st3(VectorFormat vform, LogicVRegister src, LogicVRegister src2,
1612 LogicVRegister src3,
int index, uint64_t addr);
1613 void st4(VectorFormat vform, LogicVRegister src, LogicVRegister src2,
1614 LogicVRegister src3, LogicVRegister src4, uint64_t addr);
1615 void st4(VectorFormat vform, LogicVRegister src, LogicVRegister src2,
1616 LogicVRegister src3, LogicVRegister src4,
int index, uint64_t addr);
1617 LogicVRegister cmp(VectorFormat vform, LogicVRegister dst,
1618 const LogicVRegister& src1,
const LogicVRegister& src2,
1620 LogicVRegister cmp(VectorFormat vform, LogicVRegister dst,
1621 const LogicVRegister& src1,
int imm, Condition cond);
1622 LogicVRegister cmptst(VectorFormat vform, LogicVRegister dst,
1623 const LogicVRegister& src1,
const LogicVRegister& src2);
1624 LogicVRegister add(VectorFormat vform, LogicVRegister dst,
1625 const LogicVRegister& src1,
const LogicVRegister& src2);
1626 LogicVRegister addp(VectorFormat vform, LogicVRegister dst,
1627 const LogicVRegister& src1,
const LogicVRegister& src2);
1628 LogicVRegister mla(VectorFormat vform, LogicVRegister dst,
1629 const LogicVRegister& src1,
const LogicVRegister& src2);
1630 LogicVRegister mls(VectorFormat vform, LogicVRegister dst,
1631 const LogicVRegister& src1,
const LogicVRegister& src2);
1632 LogicVRegister mul(VectorFormat vform, LogicVRegister dst,
1633 const LogicVRegister& src1,
const LogicVRegister& src2);
1634 LogicVRegister mul(VectorFormat vform, LogicVRegister dst,
1635 const LogicVRegister& src1,
const LogicVRegister& src2,
1637 LogicVRegister mla(VectorFormat vform, LogicVRegister dst,
1638 const LogicVRegister& src1,
const LogicVRegister& src2,
1640 LogicVRegister mls(VectorFormat vform, LogicVRegister dst,
1641 const LogicVRegister& src1,
const LogicVRegister& src2,
1643 LogicVRegister pmul(VectorFormat vform, LogicVRegister dst,
1644 const LogicVRegister& src1,
const LogicVRegister& src2);
1646 using ByElementOp = LogicVRegister (Simulator::*)(
VectorFormat vform,
1648 const LogicVRegister& src1,
1649 const LogicVRegister& src2,
1651 LogicVRegister fmul(VectorFormat vform, LogicVRegister dst,
1652 const LogicVRegister& src1,
const LogicVRegister& src2,
1654 LogicVRegister fmla(VectorFormat vform, LogicVRegister dst,
1655 const LogicVRegister& src1,
const LogicVRegister& src2,
1657 LogicVRegister fmls(VectorFormat vform, LogicVRegister dst,
1658 const LogicVRegister& src1,
const LogicVRegister& src2,
1660 LogicVRegister fmulx(VectorFormat vform, LogicVRegister dst,
1661 const LogicVRegister& src1,
const LogicVRegister& src2,
1663 LogicVRegister smull(VectorFormat vform, LogicVRegister dst,
1664 const LogicVRegister& src1,
const LogicVRegister& src2,
1666 LogicVRegister smull2(VectorFormat vform, LogicVRegister dst,
1667 const LogicVRegister& src1,
const LogicVRegister& src2,
1669 LogicVRegister umull(VectorFormat vform, LogicVRegister dst,
1670 const LogicVRegister& src1,
const LogicVRegister& src2,
1672 LogicVRegister umull2(VectorFormat vform, LogicVRegister dst,
1673 const LogicVRegister& src1,
const LogicVRegister& src2,
1675 LogicVRegister smlal(VectorFormat vform, LogicVRegister dst,
1676 const LogicVRegister& src1,
const LogicVRegister& src2,
1678 LogicVRegister smlal2(VectorFormat vform, LogicVRegister dst,
1679 const LogicVRegister& src1,
const LogicVRegister& src2,
1681 LogicVRegister umlal(VectorFormat vform, LogicVRegister dst,
1682 const LogicVRegister& src1,
const LogicVRegister& src2,
1684 LogicVRegister umlal2(VectorFormat vform, LogicVRegister dst,
1685 const LogicVRegister& src1,
const LogicVRegister& src2,
1687 LogicVRegister smlsl(VectorFormat vform, LogicVRegister dst,
1688 const LogicVRegister& src1,
const LogicVRegister& src2,
1690 LogicVRegister smlsl2(VectorFormat vform, LogicVRegister dst,
1691 const LogicVRegister& src1,
const LogicVRegister& src2,
1693 LogicVRegister umlsl(VectorFormat vform, LogicVRegister dst,
1694 const LogicVRegister& src1,
const LogicVRegister& src2,
1696 LogicVRegister umlsl2(VectorFormat vform, LogicVRegister dst,
1697 const LogicVRegister& src1,
const LogicVRegister& src2,
1699 LogicVRegister sqdmull(VectorFormat vform, LogicVRegister dst,
1700 const LogicVRegister& src1,
const LogicVRegister& src2,
1702 LogicVRegister sqdmull2(VectorFormat vform, LogicVRegister dst,
1703 const LogicVRegister& src1,
1704 const LogicVRegister& src2,
int index);
1705 LogicVRegister sqdmlal(VectorFormat vform, LogicVRegister dst,
1706 const LogicVRegister& src1,
const LogicVRegister& src2,
1708 LogicVRegister sqdmlal2(VectorFormat vform, LogicVRegister dst,
1709 const LogicVRegister& src1,
1710 const LogicVRegister& src2,
int index);
1711 LogicVRegister sqdmlsl(VectorFormat vform, LogicVRegister dst,
1712 const LogicVRegister& src1,
const LogicVRegister& src2,
1714 LogicVRegister sqdmlsl2(VectorFormat vform, LogicVRegister dst,
1715 const LogicVRegister& src1,
1716 const LogicVRegister& src2,
int index);
1717 LogicVRegister sqdmulh(VectorFormat vform, LogicVRegister dst,
1718 const LogicVRegister& src1,
const LogicVRegister& src2,
1720 LogicVRegister sqrdmulh(VectorFormat vform, LogicVRegister dst,
1721 const LogicVRegister& src1,
1722 const LogicVRegister& src2,
int index);
1723 LogicVRegister sub(VectorFormat vform, LogicVRegister dst,
1724 const LogicVRegister& src1,
const LogicVRegister& src2);
1725 LogicVRegister and_(VectorFormat vform, LogicVRegister dst,
1726 const LogicVRegister& src1,
const LogicVRegister& src2);
1727 LogicVRegister orr(VectorFormat vform, LogicVRegister dst,
1728 const LogicVRegister& src1,
const LogicVRegister& src2);
1729 LogicVRegister orn(VectorFormat vform, LogicVRegister dst,
1730 const LogicVRegister& src1,
const LogicVRegister& src2);
1731 LogicVRegister eor(VectorFormat vform, LogicVRegister dst,
1732 const LogicVRegister& src1,
const LogicVRegister& src2);
1733 LogicVRegister bic(VectorFormat vform, LogicVRegister dst,
1734 const LogicVRegister& src1,
const LogicVRegister& src2);
1735 LogicVRegister bic(VectorFormat vform, LogicVRegister dst,
1736 const LogicVRegister& src, uint64_t imm);
1737 LogicVRegister bif(VectorFormat vform, LogicVRegister dst,
1738 const LogicVRegister& src1,
const LogicVRegister& src2);
1739 LogicVRegister bit(VectorFormat vform, LogicVRegister dst,
1740 const LogicVRegister& src1,
const LogicVRegister& src2);
1741 LogicVRegister bsl(VectorFormat vform, LogicVRegister dst,
1742 const LogicVRegister& src1,
const LogicVRegister& src2);
1743 LogicVRegister cls(VectorFormat vform, LogicVRegister dst,
1744 const LogicVRegister& src);
1745 LogicVRegister clz(VectorFormat vform, LogicVRegister dst,
1746 const LogicVRegister& src);
1747 LogicVRegister cnt(VectorFormat vform, LogicVRegister dst,
1748 const LogicVRegister& src);
1749 LogicVRegister not_(VectorFormat vform, LogicVRegister dst,
1750 const LogicVRegister& src);
1751 LogicVRegister rbit(VectorFormat vform, LogicVRegister dst,
1752 const LogicVRegister& src);
1753 LogicVRegister rev(VectorFormat vform, LogicVRegister dst,
1754 const LogicVRegister& src,
int revSize);
1755 LogicVRegister rev16(VectorFormat vform, LogicVRegister dst,
1756 const LogicVRegister& src);
1757 LogicVRegister rev32(VectorFormat vform, LogicVRegister dst,
1758 const LogicVRegister& src);
1759 LogicVRegister rev64(VectorFormat vform, LogicVRegister dst,
1760 const LogicVRegister& src);
1761 LogicVRegister addlp(VectorFormat vform, LogicVRegister dst,
1762 const LogicVRegister& src,
bool is_signed,
1763 bool do_accumulate);
1764 LogicVRegister saddlp(VectorFormat vform, LogicVRegister dst,
1765 const LogicVRegister& src);
1766 LogicVRegister uaddlp(VectorFormat vform, LogicVRegister dst,
1767 const LogicVRegister& src);
1768 LogicVRegister sadalp(VectorFormat vform, LogicVRegister dst,
1769 const LogicVRegister& src);
1770 LogicVRegister uadalp(VectorFormat vform, LogicVRegister dst,
1771 const LogicVRegister& src);
1772 LogicVRegister ext(VectorFormat vform, LogicVRegister dst,
1773 const LogicVRegister& src1,
const LogicVRegister& src2,
1775 LogicVRegister ins_element(VectorFormat vform, LogicVRegister dst,
1776 int dst_index,
const LogicVRegister& src,
1778 LogicVRegister ins_immediate(VectorFormat vform, LogicVRegister dst,
1779 int dst_index, uint64_t imm);
1780 LogicVRegister dup_element(VectorFormat vform, LogicVRegister dst,
1781 const LogicVRegister& src,
int src_index);
1782 LogicVRegister dup_immediate(VectorFormat vform, LogicVRegister dst,
1784 LogicVRegister movi(VectorFormat vform, LogicVRegister dst, uint64_t imm);
1785 LogicVRegister mvni(VectorFormat vform, LogicVRegister dst, uint64_t imm);
1786 LogicVRegister orr(VectorFormat vform, LogicVRegister dst,
1787 const LogicVRegister& src, uint64_t imm);
1788 LogicVRegister sshl(VectorFormat vform, LogicVRegister dst,
1789 const LogicVRegister& src1,
const LogicVRegister& src2);
1790 LogicVRegister ushl(VectorFormat vform, LogicVRegister dst,
1791 const LogicVRegister& src1,
const LogicVRegister& src2);
1792 LogicVRegister SMinMax(VectorFormat vform, LogicVRegister dst,
1793 const LogicVRegister& src1,
const LogicVRegister& src2,
1795 LogicVRegister smax(VectorFormat vform, LogicVRegister dst,
1796 const LogicVRegister& src1,
const LogicVRegister& src2);
1797 LogicVRegister smin(VectorFormat vform, LogicVRegister dst,
1798 const LogicVRegister& src1,
const LogicVRegister& src2);
1799 LogicVRegister SMinMaxP(VectorFormat vform, LogicVRegister dst,
1800 const LogicVRegister& src1,
1801 const LogicVRegister& src2,
bool max);
1802 LogicVRegister smaxp(VectorFormat vform, LogicVRegister dst,
1803 const LogicVRegister& src1,
const LogicVRegister& src2);
1804 LogicVRegister sminp(VectorFormat vform, LogicVRegister dst,
1805 const LogicVRegister& src1,
const LogicVRegister& src2);
1806 LogicVRegister addp(VectorFormat vform, LogicVRegister dst,
1807 const LogicVRegister& src);
1808 LogicVRegister addv(VectorFormat vform, LogicVRegister dst,
1809 const LogicVRegister& src);
1810 LogicVRegister uaddlv(VectorFormat vform, LogicVRegister dst,
1811 const LogicVRegister& src);
1812 LogicVRegister saddlv(VectorFormat vform, LogicVRegister dst,
1813 const LogicVRegister& src);
1814 LogicVRegister SMinMaxV(VectorFormat vform, LogicVRegister dst,
1815 const LogicVRegister& src,
bool max);
1816 LogicVRegister smaxv(VectorFormat vform, LogicVRegister dst,
1817 const LogicVRegister& src);
1818 LogicVRegister sminv(VectorFormat vform, LogicVRegister dst,
1819 const LogicVRegister& src);
1820 LogicVRegister uxtl(VectorFormat vform, LogicVRegister dst,
1821 const LogicVRegister& src);
1822 LogicVRegister uxtl2(VectorFormat vform, LogicVRegister dst,
1823 const LogicVRegister& src);
1824 LogicVRegister sxtl(VectorFormat vform, LogicVRegister dst,
1825 const LogicVRegister& src);
1826 LogicVRegister sxtl2(VectorFormat vform, LogicVRegister dst,
1827 const LogicVRegister& src);
1828 LogicVRegister Table(VectorFormat vform, LogicVRegister dst,
1829 const LogicVRegister& ind,
bool zero_out_of_bounds,
1830 const LogicVRegister* tab1,
1831 const LogicVRegister* tab2 =
nullptr,
1832 const LogicVRegister* tab3 =
nullptr,
1833 const LogicVRegister* tab4 =
nullptr);
1834 LogicVRegister tbl(VectorFormat vform, LogicVRegister dst,
1835 const LogicVRegister& tab,
const LogicVRegister& ind);
1836 LogicVRegister tbl(VectorFormat vform, LogicVRegister dst,
1837 const LogicVRegister& tab,
const LogicVRegister& tab2,
1838 const LogicVRegister& ind);
1839 LogicVRegister tbl(VectorFormat vform, LogicVRegister dst,
1840 const LogicVRegister& tab,
const LogicVRegister& tab2,
1841 const LogicVRegister& tab3,
const LogicVRegister& ind);
1842 LogicVRegister tbl(VectorFormat vform, LogicVRegister dst,
1843 const LogicVRegister& tab,
const LogicVRegister& tab2,
1844 const LogicVRegister& tab3,
const LogicVRegister& tab4,
1845 const LogicVRegister& ind);
1846 LogicVRegister tbx(VectorFormat vform, LogicVRegister dst,
1847 const LogicVRegister& tab,
const LogicVRegister& ind);
1848 LogicVRegister tbx(VectorFormat vform, LogicVRegister dst,
1849 const LogicVRegister& tab,
const LogicVRegister& tab2,
1850 const LogicVRegister& ind);
1851 LogicVRegister tbx(VectorFormat vform, LogicVRegister dst,
1852 const LogicVRegister& tab,
const LogicVRegister& tab2,
1853 const LogicVRegister& tab3,
const LogicVRegister& ind);
1854 LogicVRegister tbx(VectorFormat vform, LogicVRegister dst,
1855 const LogicVRegister& tab,
const LogicVRegister& tab2,
1856 const LogicVRegister& tab3,
const LogicVRegister& tab4,
1857 const LogicVRegister& ind);
1858 LogicVRegister uaddl(VectorFormat vform, LogicVRegister dst,
1859 const LogicVRegister& src1,
const LogicVRegister& src2);
1860 LogicVRegister uaddl2(VectorFormat vform, LogicVRegister dst,
1861 const LogicVRegister& src1,
const LogicVRegister& src2);
1862 LogicVRegister uaddw(VectorFormat vform, LogicVRegister dst,
1863 const LogicVRegister& src1,
const LogicVRegister& src2);
1864 LogicVRegister uaddw2(VectorFormat vform, LogicVRegister dst,
1865 const LogicVRegister& src1,
const LogicVRegister& src2);
1866 LogicVRegister saddl(VectorFormat vform, LogicVRegister dst,
1867 const LogicVRegister& src1,
const LogicVRegister& src2);
1868 LogicVRegister saddl2(VectorFormat vform, LogicVRegister dst,
1869 const LogicVRegister& src1,
const LogicVRegister& src2);
1870 LogicVRegister saddw(VectorFormat vform, LogicVRegister dst,
1871 const LogicVRegister& src1,
const LogicVRegister& src2);
1872 LogicVRegister saddw2(VectorFormat vform, LogicVRegister dst,
1873 const LogicVRegister& src1,
const LogicVRegister& src2);
1874 LogicVRegister usubl(VectorFormat vform, LogicVRegister dst,
1875 const LogicVRegister& src1,
const LogicVRegister& src2);
1876 LogicVRegister usubl2(VectorFormat vform, LogicVRegister dst,
1877 const LogicVRegister& src1,
const LogicVRegister& src2);
1878 LogicVRegister usubw(VectorFormat vform, LogicVRegister dst,
1879 const LogicVRegister& src1,
const LogicVRegister& src2);
1880 LogicVRegister usubw2(VectorFormat vform, LogicVRegister dst,
1881 const LogicVRegister& src1,
const LogicVRegister& src2);
1882 LogicVRegister ssubl(VectorFormat vform, LogicVRegister dst,
1883 const LogicVRegister& src1,
const LogicVRegister& src2);
1884 LogicVRegister ssubl2(VectorFormat vform, LogicVRegister dst,
1885 const LogicVRegister& src1,
const LogicVRegister& src2);
1886 LogicVRegister ssubw(VectorFormat vform, LogicVRegister dst,
1887 const LogicVRegister& src1,
const LogicVRegister& src2);
1888 LogicVRegister ssubw2(VectorFormat vform, LogicVRegister dst,
1889 const LogicVRegister& src1,
const LogicVRegister& src2);
1890 LogicVRegister UMinMax(VectorFormat vform, LogicVRegister dst,
1891 const LogicVRegister& src1,
const LogicVRegister& src2,
1893 LogicVRegister umax(VectorFormat vform, LogicVRegister dst,
1894 const LogicVRegister& src1,
const LogicVRegister& src2);
1895 LogicVRegister umin(VectorFormat vform, LogicVRegister dst,
1896 const LogicVRegister& src1,
const LogicVRegister& src2);
1897 LogicVRegister UMinMaxP(VectorFormat vform, LogicVRegister dst,
1898 const LogicVRegister& src1,
1899 const LogicVRegister& src2,
bool max);
1900 LogicVRegister umaxp(VectorFormat vform, LogicVRegister dst,
1901 const LogicVRegister& src1,
const LogicVRegister& src2);
1902 LogicVRegister uminp(VectorFormat vform, LogicVRegister dst,
1903 const LogicVRegister& src1,
const LogicVRegister& src2);
1904 LogicVRegister UMinMaxV(VectorFormat vform, LogicVRegister dst,
1905 const LogicVRegister& src,
bool max);
1906 LogicVRegister umaxv(VectorFormat vform, LogicVRegister dst,
1907 const LogicVRegister& src);
1908 LogicVRegister uminv(VectorFormat vform, LogicVRegister dst,
1909 const LogicVRegister& src);
1910 LogicVRegister trn1(VectorFormat vform, LogicVRegister dst,
1911 const LogicVRegister& src1,
const LogicVRegister& src2);
1912 LogicVRegister trn2(VectorFormat vform, LogicVRegister dst,
1913 const LogicVRegister& src1,
const LogicVRegister& src2);
1914 LogicVRegister zip1(VectorFormat vform, LogicVRegister dst,
1915 const LogicVRegister& src1,
const LogicVRegister& src2);
1916 LogicVRegister zip2(VectorFormat vform, LogicVRegister dst,
1917 const LogicVRegister& src1,
const LogicVRegister& src2);
1918 LogicVRegister uzp1(VectorFormat vform, LogicVRegister dst,
1919 const LogicVRegister& src1,
const LogicVRegister& src2);
1920 LogicVRegister uzp2(VectorFormat vform, LogicVRegister dst,
1921 const LogicVRegister& src1,
const LogicVRegister& src2);
1922 LogicVRegister shl(VectorFormat vform, LogicVRegister dst,
1923 const LogicVRegister& src,
int shift);
1924 LogicVRegister scvtf(VectorFormat vform, LogicVRegister dst,
1925 const LogicVRegister& src,
int fbits,
1927 LogicVRegister ucvtf(VectorFormat vform, LogicVRegister dst,
1928 const LogicVRegister& src,
int fbits,
1930 LogicVRegister sshll(VectorFormat vform, LogicVRegister dst,
1931 const LogicVRegister& src,
int shift);
1932 LogicVRegister sshll2(VectorFormat vform, LogicVRegister dst,
1933 const LogicVRegister& src,
int shift);
1934 LogicVRegister shll(VectorFormat vform, LogicVRegister dst,
1935 const LogicVRegister& src);
1936 LogicVRegister shll2(VectorFormat vform, LogicVRegister dst,
1937 const LogicVRegister& src);
1938 LogicVRegister ushll(VectorFormat vform, LogicVRegister dst,
1939 const LogicVRegister& src,
int shift);
1940 LogicVRegister ushll2(VectorFormat vform, LogicVRegister dst,
1941 const LogicVRegister& src,
int shift);
1942 LogicVRegister sli(VectorFormat vform, LogicVRegister dst,
1943 const LogicVRegister& src,
int shift);
1944 LogicVRegister sri(VectorFormat vform, LogicVRegister dst,
1945 const LogicVRegister& src,
int shift);
1946 LogicVRegister sshr(VectorFormat vform, LogicVRegister dst,
1947 const LogicVRegister& src,
int shift);
1948 LogicVRegister ushr(VectorFormat vform, LogicVRegister dst,
1949 const LogicVRegister& src,
int shift);
1950 LogicVRegister ssra(VectorFormat vform, LogicVRegister dst,
1951 const LogicVRegister& src,
int shift);
1952 LogicVRegister usra(VectorFormat vform, LogicVRegister dst,
1953 const LogicVRegister& src,
int shift);
1954 LogicVRegister srsra(VectorFormat vform, LogicVRegister dst,
1955 const LogicVRegister& src,
int shift);
1956 LogicVRegister ursra(VectorFormat vform, LogicVRegister dst,
1957 const LogicVRegister& src,
int shift);
1958 LogicVRegister suqadd(VectorFormat vform, LogicVRegister dst,
1959 const LogicVRegister& src);
1960 LogicVRegister usqadd(VectorFormat vform, LogicVRegister dst,
1961 const LogicVRegister& src);
1962 LogicVRegister sqshl(VectorFormat vform, LogicVRegister dst,
1963 const LogicVRegister& src,
int shift);
1964 LogicVRegister uqshl(VectorFormat vform, LogicVRegister dst,
1965 const LogicVRegister& src,
int shift);
1966 LogicVRegister sqshlu(VectorFormat vform, LogicVRegister dst,
1967 const LogicVRegister& src,
int shift);
1968 LogicVRegister abs(VectorFormat vform, LogicVRegister dst,
1969 const LogicVRegister& src);
1970 LogicVRegister neg(VectorFormat vform, LogicVRegister dst,
1971 const LogicVRegister& src);
1972 LogicVRegister ExtractNarrow(VectorFormat vform, LogicVRegister dst,
1973 bool dstIsSigned,
const LogicVRegister& src,
1975 LogicVRegister xtn(VectorFormat vform, LogicVRegister dst,
1976 const LogicVRegister& src);
1977 LogicVRegister sqxtn(VectorFormat vform, LogicVRegister dst,
1978 const LogicVRegister& src);
1979 LogicVRegister uqxtn(VectorFormat vform, LogicVRegister dst,
1980 const LogicVRegister& src);
1981 LogicVRegister sqxtun(VectorFormat vform, LogicVRegister dst,
1982 const LogicVRegister& src);
1983 LogicVRegister AbsDiff(VectorFormat vform, LogicVRegister dst,
1984 const LogicVRegister& src1,
const LogicVRegister& src2,
1986 LogicVRegister saba(VectorFormat vform, LogicVRegister dst,
1987 const LogicVRegister& src1,
const LogicVRegister& src2);
1988 LogicVRegister uaba(VectorFormat vform, LogicVRegister dst,
1989 const LogicVRegister& src1,
const LogicVRegister& src2);
1990 LogicVRegister shrn(VectorFormat vform, LogicVRegister dst,
1991 const LogicVRegister& src,
int shift);
1992 LogicVRegister shrn2(VectorFormat vform, LogicVRegister dst,
1993 const LogicVRegister& src,
int shift);
1994 LogicVRegister rshrn(VectorFormat vform, LogicVRegister dst,
1995 const LogicVRegister& src,
int shift);
1996 LogicVRegister rshrn2(VectorFormat vform, LogicVRegister dst,
1997 const LogicVRegister& src,
int shift);
1998 LogicVRegister uqshrn(VectorFormat vform, LogicVRegister dst,
1999 const LogicVRegister& src,
int shift);
2000 LogicVRegister uqshrn2(VectorFormat vform, LogicVRegister dst,
2001 const LogicVRegister& src,
int shift);
2002 LogicVRegister uqrshrn(VectorFormat vform, LogicVRegister dst,
2003 const LogicVRegister& src,
int shift);
2004 LogicVRegister uqrshrn2(VectorFormat vform, LogicVRegister dst,
2005 const LogicVRegister& src,
int shift);
2006 LogicVRegister sqshrn(VectorFormat vform, LogicVRegister dst,
2007 const LogicVRegister& src,
int shift);
2008 LogicVRegister sqshrn2(VectorFormat vform, LogicVRegister dst,
2009 const LogicVRegister& src,
int shift);
2010 LogicVRegister sqrshrn(VectorFormat vform, LogicVRegister dst,
2011 const LogicVRegister& src,
int shift);
2012 LogicVRegister sqrshrn2(VectorFormat vform, LogicVRegister dst,
2013 const LogicVRegister& src,
int shift);
2014 LogicVRegister sqshrun(VectorFormat vform, LogicVRegister dst,
2015 const LogicVRegister& src,
int shift);
2016 LogicVRegister sqshrun2(VectorFormat vform, LogicVRegister dst,
2017 const LogicVRegister& src,
int shift);
2018 LogicVRegister sqrshrun(VectorFormat vform, LogicVRegister dst,
2019 const LogicVRegister& src,
int shift);
2020 LogicVRegister sqrshrun2(VectorFormat vform, LogicVRegister dst,
2021 const LogicVRegister& src,
int shift);
2022 LogicVRegister sqrdmulh(VectorFormat vform, LogicVRegister dst,
2023 const LogicVRegister& src1,
2024 const LogicVRegister& src2,
bool round =
true);
2025 LogicVRegister dot(VectorFormat vform, LogicVRegister dst,
2026 const LogicVRegister& src1,
const LogicVRegister& src2,
2027 bool is_src1_signed,
bool is_src2_signed);
2028 LogicVRegister sdot(VectorFormat vform, LogicVRegister dst,
2029 const LogicVRegister& src1,
const LogicVRegister& src2);
2030 LogicVRegister sqdmulh(VectorFormat vform, LogicVRegister dst,
2031 const LogicVRegister& src1,
2032 const LogicVRegister& src2);
2033#define NEON_3VREG_LOGIC_LIST(V) \
2071#define DEFINE_LOGIC_FUNC(FXN) \
2072 LogicVRegister FXN(VectorFormat vform, LogicVRegister dst, \
2073 const LogicVRegister& src1, const LogicVRegister& src2);
2074 NEON_3VREG_LOGIC_LIST(DEFINE_LOGIC_FUNC)
2075#undef DEFINE_LOGIC_FUNC
2077#define NEON_FP3SAME_LIST(V) \
2078 V(fadd, FPAdd, false) \
2079 V(fsub, FPSub, true) \
2080 V(fmul, FPMul, true) \
2081 V(fmulx, FPMulx, true) \
2082 V(fdiv, FPDiv, true) \
2083 V(fmax, FPMax, false) \
2084 V(fmin, FPMin, false) \
2085 V(fmaxnm, FPMaxNM, false) \
2086 V(fminnm, FPMinNM, false)
2088#define DECLARE_NEON_FP_VECTOR_OP(FN, OP, PROCNAN) \
2089 template <typename T> \
2090 LogicVRegister FN(VectorFormat vform, LogicVRegister dst, \
2091 const LogicVRegister& src1, const LogicVRegister& src2); \
2092 LogicVRegister FN(VectorFormat vform, LogicVRegister dst, \
2093 const LogicVRegister& src1, const LogicVRegister& src2);
2094 NEON_FP3SAME_LIST(DECLARE_NEON_FP_VECTOR_OP)
2095#undef DECLARE_NEON_FP_VECTOR_OP
2097#define NEON_FPPAIRWISE_LIST(V) \
2098 V(faddp, fadd, FPAdd) \
2099 V(fmaxp, fmax, FPMax) \
2100 V(fmaxnmp, fmaxnm, FPMaxNM) \
2101 V(fminp, fmin, FPMin) \
2102 V(fminnmp, fminnm, FPMinNM)
2104#define DECLARE_NEON_FP_PAIR_OP(FNP, FN, OP) \
2105 LogicVRegister FNP(VectorFormat vform, LogicVRegister dst, \
2106 const LogicVRegister& src1, const LogicVRegister& src2); \
2107 LogicVRegister FNP(VectorFormat vform, LogicVRegister dst, \
2108 const LogicVRegister& src);
2109 NEON_FPPAIRWISE_LIST(DECLARE_NEON_FP_PAIR_OP)
2110#undef DECLARE_NEON_FP_PAIR_OP
2112 template <
typename T>
2113 LogicVRegister frecps(VectorFormat vform, LogicVRegister dst,
2114 const LogicVRegister& src1,
const LogicVRegister& src2);
2115 LogicVRegister frecps(VectorFormat vform, LogicVRegister dst,
2116 const LogicVRegister& src1,
const LogicVRegister& src2);
2117 template <
typename T>
2118 LogicVRegister frsqrts(VectorFormat vform, LogicVRegister dst,
2119 const LogicVRegister& src1,
2120 const LogicVRegister& src2);
2121 LogicVRegister frsqrts(VectorFormat vform, LogicVRegister dst,
2122 const LogicVRegister& src1,
2123 const LogicVRegister& src2);
2124 template <
typename T>
2125 LogicVRegister fmla(VectorFormat vform, LogicVRegister dst,
2126 const LogicVRegister& src1,
const LogicVRegister& src2);
2127 LogicVRegister fmla(VectorFormat vform, LogicVRegister dst,
2128 const LogicVRegister& src1,
const LogicVRegister& src2);
2129 template <
typename T>
2130 LogicVRegister fmls(VectorFormat vform, LogicVRegister dst,
2131 const LogicVRegister& src1,
const LogicVRegister& src2);
2132 LogicVRegister fmls(VectorFormat vform, LogicVRegister dst,
2133 const LogicVRegister& src1,
const LogicVRegister& src2);
2134 LogicVRegister fnmul(VectorFormat vform, LogicVRegister dst,
2135 const LogicVRegister& src1,
const LogicVRegister& src2);
2137 template <
typename T>
2138 LogicVRegister fcmp(VectorFormat vform, LogicVRegister dst,
2139 const LogicVRegister& src1,
const LogicVRegister& src2,
2141 LogicVRegister fcmp(VectorFormat vform, LogicVRegister dst,
2142 const LogicVRegister& src1,
const LogicVRegister& src2,
2144 LogicVRegister fabscmp(VectorFormat vform, LogicVRegister dst,
2145 const LogicVRegister& src1,
const LogicVRegister& src2,
2147 LogicVRegister fcmp_zero(VectorFormat vform, LogicVRegister dst,
2148 const LogicVRegister& src, Condition cond);
2150 template <
typename T>
2151 LogicVRegister fneg(VectorFormat vform, LogicVRegister dst,
2152 const LogicVRegister& src);
2153 LogicVRegister fneg(VectorFormat vform, LogicVRegister dst,
2154 const LogicVRegister& src);
2155 template <
typename T>
2156 LogicVRegister frecpx(VectorFormat vform, LogicVRegister dst,
2157 const LogicVRegister& src);
2158 LogicVRegister frecpx(VectorFormat vform, LogicVRegister dst,
2159 const LogicVRegister& src);
2160 template <
typename T>
2161 LogicVRegister fabs_(VectorFormat vform, LogicVRegister dst,
2162 const LogicVRegister& src);
2163 LogicVRegister fabs_(VectorFormat vform, LogicVRegister dst,
2164 const LogicVRegister& src);
2165 LogicVRegister fabd(VectorFormat vform, LogicVRegister dst,
2166 const LogicVRegister& src1,
const LogicVRegister& src2);
2167 LogicVRegister frint(VectorFormat vform, LogicVRegister dst,
2169 bool inexact_exception =
false);
2170 LogicVRegister fcvts(VectorFormat vform, LogicVRegister dst,
2173 LogicVRegister fcvtu(VectorFormat vform, LogicVRegister dst,
2176 LogicVRegister fcvtl(VectorFormat vform, LogicVRegister dst,
2177 const LogicVRegister& src);
2178 LogicVRegister fcvtl2(VectorFormat vform, LogicVRegister dst,
2179 const LogicVRegister& src);
2180 LogicVRegister fcvtn(VectorFormat vform, LogicVRegister dst,
2181 const LogicVRegister& src);
2182 LogicVRegister fcvtn2(VectorFormat vform, LogicVRegister dst,
2183 const LogicVRegister& src);
2184 LogicVRegister fcvtxn(VectorFormat vform, LogicVRegister dst,
2185 const LogicVRegister& src);
2186 LogicVRegister fcvtxn2(VectorFormat vform, LogicVRegister dst,
2187 const LogicVRegister& src);
2188 LogicVRegister fsqrt(VectorFormat vform, LogicVRegister dst,
2189 const LogicVRegister& src);
2190 LogicVRegister frsqrte(VectorFormat vform, LogicVRegister dst,
2191 const LogicVRegister& src);
2192 LogicVRegister frecpe(VectorFormat vform, LogicVRegister dst,
2193 const LogicVRegister& src, FPRounding rounding);
2194 LogicVRegister ursqrte(VectorFormat vform, LogicVRegister dst,
2195 const LogicVRegister& src);
2196 LogicVRegister urecpe(VectorFormat vform, LogicVRegister dst,
2197 const LogicVRegister& src);
2199 using FPMinMaxOp = float (Simulator::*)(
float a,
float b);
2201 LogicVRegister FMinMaxV(VectorFormat vform, LogicVRegister dst,
2202 const LogicVRegister& src, FPMinMaxOp Op);
2204 LogicVRegister fminv(VectorFormat vform, LogicVRegister dst,
2205 const LogicVRegister& src);
2206 LogicVRegister fmaxv(VectorFormat vform, LogicVRegister dst,
2207 const LogicVRegister& src);
2208 LogicVRegister fminnmv(VectorFormat vform, LogicVRegister dst,
2209 const LogicVRegister& src);
2210 LogicVRegister fmaxnmv(VectorFormat vform, LogicVRegister dst,
2211 const LogicVRegister& src);
2213 template <
typename T>
2214 T FPRecipSqrtEstimate(T op);
2215 template <
typename T>
2216 T FPRecipEstimate(T op, FPRounding rounding);
2217 template <
typename T,
typename R>
2218 R FPToFixed(T op,
int fbits,
bool is_signed, FPRounding rounding);
2220 void FPCompare(
double val0,
double val1);
2221 double FPRoundInt(
double value, FPRounding round_mode);
2222 double FPToDouble(
float value);
2223 float FPToFloat(
double value, FPRounding round_mode);
2224 float FPToFloat(float16 value);
2225 float16 FPToFloat16(
float value, FPRounding round_mode);
2226 float16 FPToFloat16(
double value, FPRounding round_mode);
2227 double recip_sqrt_estimate(
double a);
2228 double recip_estimate(
double a);
2229 double FPRecipSqrtEstimate(
double a);
2230 double FPRecipEstimate(
double a);
2231 double FixedToDouble(int64_t src,
int fbits, FPRounding round_mode);
2232 double UFixedToDouble(uint64_t src,
int fbits, FPRounding round_mode);
2233 float FixedToFloat(int64_t src,
int fbits, FPRounding round_mode);
2234 float UFixedToFloat(uint64_t src,
int fbits, FPRounding round_mode);
2235 float16 FixedToFloat16(int64_t src,
int fbits, FPRounding round_mode);
2236 float16 UFixedToFloat16(uint64_t src,
int fbits, FPRounding round_mode);
2237 int16_t FPToInt16(
double value, FPRounding rmode);
2238 int32_t FPToInt32(
double value, FPRounding rmode);
2239 int64_t FPToInt64(
double value, FPRounding rmode);
2240 uint16_t FPToUInt16(
double value, FPRounding rmode);
2241 uint32_t FPToUInt32(
double value, FPRounding rmode);
2242 uint64_t FPToUInt64(
double value, FPRounding rmode);
2243 int32_t FPToFixedJS(
double value);
2245 template <
typename T>
2246 T FPAdd(T op1, T op2);
2248 template <
typename T>
2249 T FPDiv(T op1, T op2);
2251 template <
typename T>
2254 template <
typename T>
2255 T FPMaxNM(T a, T b);
2257 template <
typename T>
2260 template <
typename T>
2261 T FPMinNM(T a, T b);
2263 template <
typename T>
2264 T FPMul(T op1, T op2);
2266 template <
typename T>
2267 T FPMulx(T op1, T op2);
2269 template <
typename T>
2270 T FPMulAdd(T a, T op1, T op2);
2272 template <
typename T>
2275 template <
typename T>
2276 T FPSub(T op1, T op2);
2278 template <
typename T>
2279 T FPRecipStepFused(T op1, T op2);
2281 template <
typename T>
2282 T FPRSqrtStepFused(T op1, T op2);
2286 void FPProcessException() {}
2289 bool FPProcessNaNs(Instruction*
instr);
2291 void CheckStackAlignment();
2293 inline void CheckPCSComplianceAndRun();
2298 static const uint64_t kCallerSavedRegisterCorruptionValue =
2299 0xca11edc0de000000UL;
2301 static const uint64_t kCallerSavedVRegisterCorruptionValue =
2302 0x7ff000007f801000UL;
2304 static const uint64_t kDefaultCPURegisterCorruptionValue =
2305 0x7ffbad007f8bad00UL;
2307 void CorruptRegisters(CPURegList* list,
2308 uint64_t value = kDefaultCPURegisterCorruptionValue);
2309 void CorruptAllCallerSavedCPURegisters();
2313 void DoPrintf(Instruction*
instr);
2316 void DoSwitchStackLimit(Instruction*
instr);
2322 PrintDisassembler* print_disasm_;
2329 SimVRegister vregisters_[kNumberOfVRegisters];
2334 SimSystemRegister nzcv_;
2337 SimSystemRegister fpcr_;
2346 void AssertSupportedFPCR() {
2348 DCHECK(fpcr().RMode() == FPTieEven);
2354 template <
typename T>
2355 static int CalcNFlag(T
result) {
2356 return (
result >> (
sizeof(T) * 8 - 1)) & 1;
2359 static int CalcZFlag(uint64_t
result) {
return result == 0; }
2361 static const uint32_t kConditionFlagsMask = 0xf0000000;
2365 static const size_t kStackProtectionSize =
KB;
2367 static size_t AllocatedStackSize() {
2368 return (
v8_flags.sim_stack_size * KB) + (2 * kStackProtectionSize);
2370 static size_t UsableStackSize() {
return v8_flags.sim_stack_size *
KB; }
2373 static const int kAdditionalStackMargin = 4 *
KB;
2375 Decoder<DispatchingDecoderVisitor>* decoder_;
2376 Decoder<DispatchingDecoderVisitor>* disassembler_decoder_;
2390 static const char* xreg_names[];
2391 static const char* wreg_names[];
2392 static const char* sreg_names[];
2393 static const char* dreg_names[];
2394 static const char* vreg_names[];
2397 void set_last_debugger_input(ArrayUniquePtr<char> input) {
2398 last_debugger_input_ = std::move(input);
2400 const char* last_debugger_input() {
return last_debugger_input_.get(); }
2401 ArrayUniquePtr<char> last_debugger_input_;
2405 enum class MonitorAccess {
2410 enum class TransactionSize {
2418 TransactionSize get_transaction_size(
unsigned size);
2422 static const uintptr_t kExclusiveTaggedAddrMask = ~((1 << 11) - 1);
2424 class LocalMonitor {
2433 void NotifyLoadExcl(uintptr_t addr, TransactionSize size);
2435 bool NotifyStoreExcl(uintptr_t addr, TransactionSize size);
2440 MonitorAccess access_state_;
2441 uintptr_t tagged_addr_;
2442 TransactionSize
size_;
2445 class GlobalMonitor {
2447 class SimulatorMutex final {
2449 explicit SimulatorMutex(GlobalMonitor* global_monitor) {
2450 if (!global_monitor->IsSingleThreaded()) {
2451 guard.emplace(global_monitor->mutex_);
2456 std::optional<base::MutexGuard> guard;
2464 friend class GlobalMonitor;
2467 void Clear_Locked();
2468 void NotifyLoadExcl_Locked(uintptr_t addr);
2469 void NotifyStore_Locked(
bool is_requesting_processor);
2470 bool NotifyStoreExcl_Locked(uintptr_t addr,
bool is_requesting_processor);
2472 MonitorAccess access_state_;
2473 uintptr_t tagged_addr_;
2480 static const int kMaxFailureCounter = 5;
2481 int failure_counter_;
2484 void NotifyLoadExcl_Locked(uintptr_t addr, Processor* processor);
2485 void NotifyStore_Locked(Processor* processor);
2486 bool NotifyStoreExcl_Locked(uintptr_t addr, Processor* processor);
2489 void PrependProcessor(Processor* processor);
2491 void RemoveProcessor(Processor* processor);
2493 static GlobalMonitor*
Get();
2496 bool IsSingleThreaded()
const {
return num_processors_ == 1; }
2499 GlobalMonitor() =
default;
2500 friend class base::LeakyObject<GlobalMonitor>;
2502 Processor* head_ =
nullptr;
2503 std::atomic<uint32_t> num_processors_ = 0;
2507 LocalMonitor local_monitor_;
2508 GlobalMonitor::Processor global_monitor_processor_;
2509 GlobalMonitor* global_monitor_;
2512 void Init(FILE* stream);
2516 void CallAnyCTypeFunction(Address target_address,
2517 const EncodedCSignature& signature);
2520 template <
typename T>
2522 requires std::is_floating_point<T>::value
2524 return static_cast<T
>(dreg(0));
2527 template <
typename T>
2529 requires(!std::is_floating_point<T>::value)
2531 return ConvertReturn<T>(xreg(0));
2534 template <
typename T>
2535 static T FPDefaultNaN();
2537 template <
typename T>
2538 T FPProcessNaN(T op) {
2540 return fpcr().DN() ? FPDefaultNaN<T>() :
ToQuietNaN(op);
2543 template <
typename T>
2544 T FPProcessNaNs(T op1, T op2) {
2546 return FPProcessNaN(op1);
2548 return FPProcessNaN(op2);
2549 }
else if (std::isnan(op1)) {
2551 return FPProcessNaN(op1);
2552 }
else if (std::isnan(op2)) {
2554 return FPProcessNaN(op2);
2560 template <
typename T>
2561 T FPProcessNaNs3(T op1, T op2, T op3) {
2563 return FPProcessNaN(op1);
2565 return FPProcessNaN(op2);
2567 return FPProcessNaN(op3);
2568 }
else if (std::isnan(op1)) {
2570 return FPProcessNaN(op1);
2571 }
else if (std::isnan(op2)) {
2573 return FPProcessNaN(op2);
2574 }
else if (std::isnan(op3)) {
2576 return FPProcessNaN(op3);
2582 int log_parameters_;
2584 int icount_for_stop_sim_at_;
2589inline double Simulator::FPDefaultNaN<double>() {
2594inline float Simulator::FPDefaultNaN<float>() {
2599inline float16 Simulator::FPDefaultNaN<float16>() {
#define SYSTEM_REGISTER_FIELDS_LIST(V_, M_)
base::Vector< const DirectHandle< Object > > args
refactor address components for immediate indexing make OptimizeMaglevOnNextCall optimize to turbofan instead of maglev filter for tracing turbofan compilation trace turbo cfg trace TurboFan s graph trimmer trace TurboFan s control equivalence trace TurboFan s register allocator trace stack load store counters for optimized code in run fuzzing &&concurrent_recompilation trace_turbo trace_turbo_scheduled trace_turbo_stack_accesses verify TurboFan machine graph of code stubs enable FixedArray bounds checks print TurboFan statistics of wasm compilations maximum cumulative size of bytecode considered for inlining scale factor of bytecode size used to calculate the inlining budget * KB
#define DEFINE_GETTER(Name, HighBit, LowBit, Func)
std::optional< TNode< JSArray > > a
RoundingMode rounding_mode
ZoneVector< RpoNumber > & result
V8_INLINE const Operation & Get(const Graph &graph, OpIndex index)
UntaggedUnion< Float32, Float64 > Float
UntaggedUnion< Word32, Word64 > Word
V8_INLINE Address AuthPAC(Address pc, Address sp)
bool IsSignallingNaN(double num)
V8_EXPORT_PRIVATE int LaneCountFromFormat(VectorFormat vform)
bool Is(IndirectHandle< U > value)
void PrintF(const char *format,...)
int32_t signed_bitextract_32(int msb, int lsb, uint32_t x)
int64_t MinIntFromFormat(VectorFormat vform)
V8_EXPORT_PRIVATE const double kFP64DefaultNaN
V8_EXPORT_PRIVATE const float kFP32DefaultNaN
uint64_t MaxUintFromFormat(VectorFormat vform)
double ToQuietNaN(double num)
const float16 kFP16DefaultNaN
constexpr int kQRegSizeLog2
int64_t MaxIntFromFormat(VectorFormat vform)
constexpr int kDRegSizeLog2
unsigned LaneSizeInBitsFromFormat(VectorFormat vform)
V8_EXPORT_PRIVATE FlagValues v8_flags
static int CountLeadingZeros(uint64_t value, int width)
unsigned RegisterSizeInBytesFromFormat(VectorFormat vform)
uint32_t unsigned_bitextract_32(int msb, int lsb, uint32_t x)
base::SmallVector< RegisterT, kStaticCapacity > registers_
const uintptr_t stack_limit_
#define PRINTF_FORMAT(format_param, dots_param)
#define DCHECK_LE(v1, v2)
#define DCHECK_NE(v1, v2)
#define DCHECK_GE(v1, v2)
#define DCHECK(condition)
#define DCHECK_LT(v1, v2)
#define DCHECK_EQ(v1, v2)
#define V8_EXPORT_PRIVATE
constexpr bool IsAligned(T value, U alignment)
std::unique_ptr< ValueMirror > value
std::unique_ptr< ValueMirror > key