1 //===-- evm/registers.h - Class to represent a single basic block --*- C++ -*-===//
3 // A basicblock contains nodes, and must end in a terminal instruction node.
4 // Nodes can be instructions, constants. Each node may produce more than one
7 //===----------------------------------------------------------------------===//
9 #ifndef _JITCS_SPILLSLOTINFO_H_
10 #define _JITCS_SPILLSLOTINFO_H_
12 #include "jitcs_base.h"
13 #include "jitcs_ids.h"
18 enum NoSpillEnum
{ NO_SPILL
};
20 struct SpillSlotInfo
{
24 SSI_SizeBits
= 3, // spill slots can be at most 2^(2^3-1) = 2^7 = 128 bytes each
25 SSI_SizeMask
= (1 << SSI_SizeBits
) - 1,
28 SpillSlotInfo() = default;
29 SpillSlotInfo(const SpillSlotInfo
&) = default;
30 SpillSlotInfo
& operator =(const SpillSlotInfo
&) = default;
32 static_assert(MMODE_None
== 0, "assumption failed");
33 static_assert(MMODE_SPRel
+ MMODE_FPCount
<= (1 << MMODE_Bits
), "assumption failed");
34 static_assert(MMODE_Bits
+ SSI_SizeBits
< sizeof(aggregateData
) * 8, "assumption failed");
36 SpillSlotInfo(NoSpillEnum
) : aggregateData(0) {}
37 SpillSlotInfo(uint fpmode
, int ofs
, uint logSize
) : aggregateData(0) { place(fpmode
, ofs
, logSize
); }
39 bool isPlaced() const { return aggregateData
!= 0; }
40 bool isMem() const { return isPlaced(); }
42 void unplace() { aggregateData
= 0; }
43 void place(uint fpmode
, int ofs
, uint logSize
) {
44 assert(fpmode
>= MMODE_SPRel
&& fpmode
< MMODE_SPRel
+ MMODE_FPCount
);
45 assert((ofs
<< MMODE_Bits
) >> MMODE_Bits
== ofs
);
46 assert(logSize
< (1 << SSI_SizeBits
));
47 aggregateData
= (ofs
<< (MMODE_Bits
+ SSI_SizeBits
)) | (logSize
<< MMODE_Bits
) | (fpmode
);
49 bool isSPRel() const { return (aggregateData
& MMODE_Mask
) == MMODE_SPRel
; }
50 uint
getFP() const { assert(isPlaced()); return (aggregateData
& MMODE_Mask
) - MMODE_SPRel
; }
51 int getOffset() const { assert(isPlaced()); return aggregateData
>> (MMODE_Bits
+ SSI_SizeBits
); }
52 uint
getLogSize() const { assert(isPlaced()); return (aggregateData
>> MMODE_Bits
) & SSI_SizeMask
; }
53 uint
getSize() const { return 1 << getLogSize(); }
55 void dump(MachineDumper
& o
) const;
58 } // End jitcs namespace
61 // _JITCS_SPILLSLOTINFO_H_