Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
dart::RegisterSet Class Reference

#include <locations.h>

Inheritance diagram for dart::RegisterSet:
dart::ValueObject

Public Member Functions

 RegisterSet ()
 
 RegisterSet (uintptr_t cpu_register_mask, uintptr_t fpu_register_mask)
 
void AddAllNonReservedRegisters (bool include_fpu_registers)
 
void AddAllGeneralRegisters ()
 
void AddAllArgumentRegisters ()
 
void AddTaggedRegisters (uintptr_t cpu_register_mask, uintptr_t fpu_register_mask)
 
void AddRegister (Register reg, Representation rep=kTagged)
 
void Add (Location loc, Representation rep=kTagged)
 
void Remove (Location loc)
 
bool Contains (Location loc)
 
void DebugPrint ()
 
void MarkUntagged (Location loc)
 
bool HasUntaggedValues () const
 
bool IsTagged (Register reg) const
 
bool ContainsRegister (Register reg) const
 
bool ContainsFpuRegister (FpuRegister fpu_reg) const
 
intptr_t CpuRegisterCount () const
 
intptr_t FpuRegisterCount () const
 
bool IsEmpty () const
 
uintptr_t cpu_registers () const
 
uintptr_t fpu_registers () const
 
void Clear ()
 
void Write (FlowGraphSerializer *s) const
 
 RegisterSet (FlowGraphDeserializer *d)
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Static Public Member Functions

static intptr_t RegisterCount (intptr_t registers)
 
static bool Contains (uintptr_t register_set, intptr_t reg)
 

Detailed Description

Definition at line 669 of file locations.h.

Constructor & Destructor Documentation

◆ RegisterSet() [1/3]

dart::RegisterSet::RegisterSet ( )
inline

Definition at line 671 of file locations.h.

672 : cpu_registers_(), untagged_cpu_registers_(), fpu_registers_() {
675 }
#define ASSERT(E)
constexpr intptr_t kBitsPerByte
Definition: globals.h:463
@ kNumberOfCpuRegisters
Definition: constants_arm.h:98
const int kNumberOfFpuRegisters
constexpr intptr_t kWordSize
Definition: globals.h:509

◆ RegisterSet() [2/3]

dart::RegisterSet::RegisterSet ( uintptr_t  cpu_register_mask,
uintptr_t  fpu_register_mask 
)
inlineexplicit

Definition at line 677 of file locations.h.

678 : RegisterSet() {
679 AddTaggedRegisters(cpu_register_mask, fpu_register_mask);
680 }
void AddTaggedRegisters(uintptr_t cpu_register_mask, uintptr_t fpu_register_mask)
Definition: locations.h:734

◆ RegisterSet() [3/3]

dart::RegisterSet::RegisterSet ( FlowGraphDeserializer d)
explicit

Definition at line 2247 of file il_serializer.cc.

2248 : cpu_registers_(d->Read<uintptr_t>()),
2249 untagged_cpu_registers_(d->Read<uintptr_t>()),
2250 fpu_registers_(d->Read<uintptr_t>()) {}
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition: main.cc:19

Member Function Documentation

◆ Add()

void dart::RegisterSet::Add ( Location  loc,
Representation  rep = kTagged 
)
inline

Definition at line 754 of file locations.h.

754 {
755 if (loc.IsRegister()) {
756 cpu_registers_.Add(loc.reg());
757 if (rep != kTagged) {
758 // CPU register contains an untagged value.
759 MarkUntagged(loc);
760 }
761 } else if (loc.IsFpuRegister()) {
762 fpu_registers_.Add(loc.fpu_reg());
763 }
764 }
void MarkUntagged(Location loc)
Definition: locations.h:787
void Add(T value)
Definition: locations.h:650

◆ AddAllArgumentRegisters()

void dart::RegisterSet::AddAllArgumentRegisters ( )
inline

Definition at line 716 of file locations.h.

716 {
717 // All (native) arguments are passed on the stack in IA32.
718#if !defined(TARGET_ARCH_IA32)
719 for (intptr_t i = 0; i < kNumberOfCpuRegisters; ++i) {
720 const Register reg = static_cast<Register>(i);
721 if (IsArgumentRegister(reg)) {
723 }
724 }
725 for (intptr_t i = 0; i < kNumberOfFpuRegisters; ++i) {
726 const FpuRegister reg = static_cast<FpuRegister>(i);
727 if (IsFpuArgumentRegister(reg)) {
729 }
730 }
731#endif
732 }
static Location FpuRegisterLocation(FpuRegister reg)
Definition: locations.h:410
static Location RegisterLocation(Register reg)
Definition: locations.h:398
void Add(Location loc, Representation rep=kTagged)
Definition: locations.h:754
static constexpr bool IsArgumentRegister(Register reg)
Definition: constants.h:77
static constexpr bool IsFpuArgumentRegister(FpuRegister reg)
Definition: constants.h:81
QRegister FpuRegister

◆ AddAllGeneralRegisters()

void dart::RegisterSet::AddAllGeneralRegisters ( )
inline

Definition at line 697 of file locations.h.

697 {
698 for (intptr_t i = kNumberOfCpuRegisters - 1; i >= 0; --i) {
699 Register reg = static_cast<Register>(i);
700 if (reg == FPREG || reg == SPREG) continue;
701#if defined(TARGET_ARCH_ARM)
702 if (reg == PC) continue;
703#elif defined(TARGET_ARCH_ARM64)
704 if (reg == R31) continue;
705#elif defined(TARGET_ARCH_RISCV32) || defined(TARGET_ARCH_RISCV64)
706 if (reg == ZR || reg == TP || reg == GP) continue;
707#endif
709 }
710
711 for (intptr_t i = kNumberOfFpuRegisters - 1; i >= 0; --i) {
713 }
714 }
const Register FPREG
const Register SPREG

◆ AddAllNonReservedRegisters()

void dart::RegisterSet::AddAllNonReservedRegisters ( bool  include_fpu_registers)
inline

Definition at line 682 of file locations.h.

682 {
683 for (intptr_t i = kNumberOfCpuRegisters - 1; i >= 0; --i) {
684 if ((kReservedCpuRegisters & (1 << i)) != 0u) continue;
686 }
687
688 if (include_fpu_registers) {
689 for (intptr_t i = kNumberOfFpuRegisters - 1; i >= 0; --i) {
691 }
692 }
693 }
const RegList kReservedCpuRegisters

◆ AddRegister()

void dart::RegisterSet::AddRegister ( Register  reg,
Representation  rep = kTagged 
)
inline

Definition at line 750 of file locations.h.

750 {
752 }

◆ AddTaggedRegisters()

void dart::RegisterSet::AddTaggedRegisters ( uintptr_t  cpu_register_mask,
uintptr_t  fpu_register_mask 
)
inline

Definition at line 734 of file locations.h.

735 {
736 for (intptr_t i = 0; i < kNumberOfCpuRegisters; ++i) {
737 if (Utils::TestBit(cpu_register_mask, i)) {
738 const Register reg = static_cast<Register>(i);
740 }
741 }
742 for (intptr_t i = 0; i < kNumberOfFpuRegisters; ++i) {
743 if (Utils::TestBit(fpu_register_mask, i)) {
744 const FpuRegister reg = static_cast<FpuRegister>(i);
746 }
747 }
748 }
static constexpr bool TestBit(T mask, size_t position)
Definition: utils.h:564

◆ Clear()

void dart::RegisterSet::Clear ( )
inline

Definition at line 823 of file locations.h.

823 {
824 cpu_registers_.Clear();
825 fpu_registers_.Clear();
826 untagged_cpu_registers_.Clear();
827 }
void Clear()
Definition: locations.h:656

◆ Contains() [1/2]

bool dart::RegisterSet::Contains ( Location  loc)
inline

Definition at line 774 of file locations.h.

774 {
775 if (loc.IsRegister()) {
776 return ContainsRegister(loc.reg());
777 } else if (loc.IsFpuRegister()) {
778 return ContainsFpuRegister(loc.fpu_reg());
779 } else {
780 UNREACHABLE();
781 return false;
782 }
783 }
#define UNREACHABLE()
Definition: assert.h:248
bool ContainsFpuRegister(FpuRegister fpu_reg) const
Definition: locations.h:804
bool ContainsRegister(Register reg) const
Definition: locations.h:800

◆ Contains() [2/2]

static bool dart::RegisterSet::Contains ( uintptr_t  register_set,
intptr_t  reg 
)
inlinestatic

Definition at line 816 of file locations.h.

816 {
817 return (register_set & (static_cast<uintptr_t>(1) << reg)) != 0;
818 }

◆ ContainsFpuRegister()

bool dart::RegisterSet::ContainsFpuRegister ( FpuRegister  fpu_reg) const
inline

Definition at line 804 of file locations.h.

804 {
805 return fpu_registers_.Contains(fpu_reg);
806 }
bool Contains(T value) const
Definition: locations.h:648

◆ ContainsRegister()

bool dart::RegisterSet::ContainsRegister ( Register  reg) const
inline

Definition at line 800 of file locations.h.

800 {
801 return cpu_registers_.Contains(reg);
802 }

◆ cpu_registers()

uintptr_t dart::RegisterSet::cpu_registers ( ) const
inline

Definition at line 820 of file locations.h.

820{ return cpu_registers_.data(); }
uintptr_t data() const
Definition: locations.h:658

◆ CpuRegisterCount()

intptr_t dart::RegisterSet::CpuRegisterCount ( ) const
inline

Definition at line 808 of file locations.h.

808{ return RegisterCount(cpu_registers()); }
uintptr_t cpu_registers() const
Definition: locations.h:820
static intptr_t RegisterCount(intptr_t registers)
Definition: locations.cc:142

◆ DebugPrint()

void dart::RegisterSet::DebugPrint ( )

Definition at line 153 of file locations.cc.

153 {
154 for (intptr_t i = 0; i < kNumberOfCpuRegisters; i++) {
155 Register r = static_cast<Register>(i);
156 if (ContainsRegister(r)) {
158 IsTagged(r) ? "tagged" : "untagged");
159 }
160 }
161
162 for (intptr_t i = 0; i < kNumberOfFpuRegisters; i++) {
163 FpuRegister r = static_cast<FpuRegister>(i);
164 if (ContainsFpuRegister(r)) {
166 }
167 }
168}
static const char * FpuRegisterName(FpuRegister reg)
Definition: constants.h:54
static const char * RegisterName(Register reg)
Definition: constants.h:46
bool IsTagged(Register reg) const
Definition: locations.h:796
#define THR_Print(format,...)
Definition: log.h:20

◆ fpu_registers()

uintptr_t dart::RegisterSet::fpu_registers ( ) const
inline

Definition at line 821 of file locations.h.

821{ return fpu_registers_.data(); }

◆ FpuRegisterCount()

intptr_t dart::RegisterSet::FpuRegisterCount ( ) const
inline

Definition at line 809 of file locations.h.

809{ return RegisterCount(fpu_registers()); }
uintptr_t fpu_registers() const
Definition: locations.h:821

◆ HasUntaggedValues()

bool dart::RegisterSet::HasUntaggedValues ( ) const
inline

Definition at line 792 of file locations.h.

792 {
793 return !untagged_cpu_registers_.IsEmpty() || !fpu_registers_.IsEmpty();
794 }
bool IsEmpty() const
Definition: locations.h:654

◆ IsEmpty()

bool dart::RegisterSet::IsEmpty ( ) const
inline

Definition at line 811 of file locations.h.

811 {
812 return CpuRegisterCount() == 0 && FpuRegisterCount() == 0;
813 }
intptr_t FpuRegisterCount() const
Definition: locations.h:809
intptr_t CpuRegisterCount() const
Definition: locations.h:808

◆ IsTagged()

bool dart::RegisterSet::IsTagged ( Register  reg) const
inline

Definition at line 796 of file locations.h.

796 {
797 return !untagged_cpu_registers_.Contains(reg);
798 }

◆ MarkUntagged()

void dart::RegisterSet::MarkUntagged ( Location  loc)
inline

Definition at line 787 of file locations.h.

787 {
788 ASSERT(loc.IsRegister());
789 untagged_cpu_registers_.Add(loc.reg());
790 }

◆ RegisterCount()

intptr_t dart::RegisterSet::RegisterCount ( intptr_t  registers)
static

Definition at line 142 of file locations.cc.

142 {
143 // Brian Kernighan's algorithm for counting the bits set.
144 intptr_t count = 0;
145 while (registers != 0) {
146 ++count;
147 // Clear the least significant bit set.
148 registers &= (static_cast<uintptr_t>(registers) - 1);
149 }
150 return count;
151}
int count
Definition: FontMgrTest.cpp:50

◆ Remove()

void dart::RegisterSet::Remove ( Location  loc)
inline

Definition at line 766 of file locations.h.

766 {
767 if (loc.IsRegister()) {
768 cpu_registers_.Remove(loc.reg());
769 } else if (loc.IsFpuRegister()) {
770 fpu_registers_.Remove(loc.fpu_reg());
771 }
772 }
void Remove(T value)
Definition: locations.h:652

◆ Write()

void dart::RegisterSet::Write ( FlowGraphSerializer s) const

Definition at line 2241 of file il_serializer.cc.

2241 {
2242 s->Write<uintptr_t>(cpu_registers_.data());
2243 s->Write<uintptr_t>(untagged_cpu_registers_.data());
2244 s->Write<uintptr_t>(fpu_registers_.data());
2245}
struct MyStruct s

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