Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(522)

Side by Side Diff: src/a64/simulator-a64.h

Issue 203343003: A64: Have the simulator fpcr_ members return appropriate types. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/a64/constants-a64.h ('k') | src/a64/simulator-a64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 128
129 int32_t SignedBits(int msb, int lsb) const { 129 int32_t SignedBits(int msb, int lsb) const {
130 return signed_bitextract_32(msb, lsb, value_); 130 return signed_bitextract_32(msb, lsb, value_);
131 } 131 }
132 132
133 void SetBits(int msb, int lsb, uint32_t bits); 133 void SetBits(int msb, int lsb, uint32_t bits);
134 134
135 // Default system register values. 135 // Default system register values.
136 static SimSystemRegister DefaultValueFor(SystemRegister id); 136 static SimSystemRegister DefaultValueFor(SystemRegister id);
137 137
138 #define DEFINE_GETTER(Name, HighBit, LowBit, Func) \ 138 #define DEFINE_GETTER(Name, HighBit, LowBit, Func, Type) \
139 uint32_t Name() const { return Func(HighBit, LowBit); } \ 139 Type Name() const { return static_cast<Type>(Func(HighBit, LowBit)); } \
140 void Set##Name(uint32_t bits) { SetBits(HighBit, LowBit, bits); } 140 void Set##Name(Type bits) { \
141 #define DEFINE_WRITE_IGNORE_MASK(Name, Mask) \ 141 SetBits(HighBit, LowBit, static_cast<Type>(bits)); \
142 }
143 #define DEFINE_WRITE_IGNORE_MASK(Name, Mask) \
142 static const uint32_t Name##WriteIgnoreMask = ~static_cast<uint32_t>(Mask); 144 static const uint32_t Name##WriteIgnoreMask = ~static_cast<uint32_t>(Mask);
143
144 SYSTEM_REGISTER_FIELDS_LIST(DEFINE_GETTER, DEFINE_WRITE_IGNORE_MASK) 145 SYSTEM_REGISTER_FIELDS_LIST(DEFINE_GETTER, DEFINE_WRITE_IGNORE_MASK)
145
146 #undef DEFINE_ZERO_BITS 146 #undef DEFINE_ZERO_BITS
147 #undef DEFINE_GETTER 147 #undef DEFINE_GETTER
148 148
149 protected: 149 protected:
150 // Most system registers only implement a few of the bits in the word. Other 150 // Most system registers only implement a few of the bits in the word. Other
151 // bits are "read-as-zero, write-ignored". The write_ignore_mask argument 151 // bits are "read-as-zero, write-ignored". The write_ignore_mask argument
152 // describes the bits which are not modifiable. 152 // describes the bits which are not modifiable.
153 SimSystemRegister(uint32_t value, uint32_t write_ignore_mask) 153 SimSystemRegister(uint32_t value, uint32_t write_ignore_mask)
154 : value_(value), write_ignore_mask_(write_ignore_mask) { } 154 : value_(value), write_ignore_mask_(write_ignore_mask) { }
155 155
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 } 523 }
524 524
525 void set_dreg(unsigned code, double value) { 525 void set_dreg(unsigned code, double value) {
526 set_fpreg(code, value); 526 set_fpreg(code, value);
527 } 527 }
528 528
529 void set_dreg_bits(unsigned code, uint64_t value) { 529 void set_dreg_bits(unsigned code, uint64_t value) {
530 set_fpreg(code, value); 530 set_fpreg(code, value);
531 } 531 }
532 532
533 bool N() { return nzcv_.N() != 0; }
534 bool Z() { return nzcv_.Z() != 0; }
535 bool C() { return nzcv_.C() != 0; }
536 bool V() { return nzcv_.V() != 0; }
537 SimSystemRegister& nzcv() { return nzcv_; } 533 SimSystemRegister& nzcv() { return nzcv_; }
538
539 // TODO(jbramley): Find a way to make the fpcr_ members return the proper
540 // types, so these accessors are not necessary.
541 FPRounding RMode() { return static_cast<FPRounding>(fpcr_.RMode()); }
542 bool DN() { return fpcr_.DN() != 0; }
543 SimSystemRegister& fpcr() { return fpcr_; } 534 SimSystemRegister& fpcr() { return fpcr_; }
544 535
545 // Debug helpers 536 // Debug helpers
546 537
547 // Simulator breakpoints. 538 // Simulator breakpoints.
548 struct Breakpoint { 539 struct Breakpoint {
549 Instruction* location; 540 Instruction* location;
550 bool enabled; 541 bool enabled;
551 }; 542 };
552 std::vector<Breakpoint> breakpoints_; 543 std::vector<Breakpoint> breakpoints_;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 static inline const char* XRegNameForCode(unsigned code, 600 static inline const char* XRegNameForCode(unsigned code,
610 Reg31Mode mode = Reg31IsZeroRegister); 601 Reg31Mode mode = Reg31IsZeroRegister);
611 static inline const char* SRegNameForCode(unsigned code); 602 static inline const char* SRegNameForCode(unsigned code);
612 static inline const char* DRegNameForCode(unsigned code); 603 static inline const char* DRegNameForCode(unsigned code);
613 static inline const char* VRegNameForCode(unsigned code); 604 static inline const char* VRegNameForCode(unsigned code);
614 static inline int CodeFromName(const char* name); 605 static inline int CodeFromName(const char* name);
615 606
616 protected: 607 protected:
617 // Simulation helpers ------------------------------------ 608 // Simulation helpers ------------------------------------
618 bool ConditionPassed(Condition cond) { 609 bool ConditionPassed(Condition cond) {
610 SimSystemRegister& flags = nzcv();
619 switch (cond) { 611 switch (cond) {
620 case eq: 612 case eq:
621 return Z(); 613 return flags.Z();
622 case ne: 614 case ne:
623 return !Z(); 615 return !flags.Z();
624 case hs: 616 case hs:
625 return C(); 617 return flags.C();
626 case lo: 618 case lo:
627 return !C(); 619 return !flags.C();
628 case mi: 620 case mi:
629 return N(); 621 return flags.N();
630 case pl: 622 case pl:
631 return !N(); 623 return !flags.N();
632 case vs: 624 case vs:
633 return V(); 625 return flags.V();
634 case vc: 626 case vc:
635 return !V(); 627 return !flags.V();
636 case hi: 628 case hi:
637 return C() && !Z(); 629 return flags.C() && !flags.Z();
638 case ls: 630 case ls:
639 return !(C() && !Z()); 631 return !(flags.C() && !flags.Z());
640 case ge: 632 case ge:
641 return N() == V(); 633 return flags.N() == flags.V();
642 case lt: 634 case lt:
643 return N() != V(); 635 return flags.N() != flags.V();
644 case gt: 636 case gt:
645 return !Z() && (N() == V()); 637 return !flags.Z() && (flags.N() == flags.V());
646 case le: 638 case le:
647 return !(!Z() && (N() == V())); 639 return !(!flags.Z() && (flags.N() == flags.V()));
648 case nv: // Fall through. 640 case nv: // Fall through.
649 case al: 641 case al:
650 return true; 642 return true;
651 default: 643 default:
652 UNREACHABLE(); 644 UNREACHABLE();
653 return false; 645 return false;
654 } 646 }
655 } 647 }
656 648
657 bool ConditionFailed(Condition cond) { 649 bool ConditionFailed(Condition cond) {
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 static void UnregisterCTryCatch() { 899 static void UnregisterCTryCatch() {
908 Simulator::current(Isolate::Current())->PopAddress(); 900 Simulator::current(Isolate::Current())->PopAddress();
909 } 901 }
910 }; 902 };
911 903
912 #endif // !defined(USE_SIMULATOR) 904 #endif // !defined(USE_SIMULATOR)
913 905
914 } } // namespace v8::internal 906 } } // namespace v8::internal
915 907
916 #endif // V8_A64_SIMULATOR_A64_H_ 908 #endif // V8_A64_SIMULATOR_A64_H_
OLDNEW
« no previous file with comments | « src/a64/constants-a64.h ('k') | src/a64/simulator-a64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698