blob: e38b5190dda7830ef73af457eaf62ff31bdd5b76 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
using System;
namespace ARMeilleure.CodeGen.RegisterAllocators
{
unsafe readonly struct LiveRange : IEquatable<LiveRange>
{
private struct Data
{
public int Start;
public int End;
public LiveRange Next;
}
private readonly Data* _data;
public ref int Start => ref _data->Start;
public ref int End => ref _data->End;
public ref LiveRange Next => ref _data->Next;
public LiveRange(int start, int end, LiveRange next = default)
{
_data = Allocators.LiveRanges.Allocate<Data>();
Start = start;
End = end;
Next = next;
}
public bool Overlaps(int start, int end)
{
return Start < end && start < End;
}
public bool Overlaps(LiveRange range)
{
return Start < range.End && range.Start < End;
}
public bool Overlaps(int position)
{
return position >= Start && position < End;
}
public bool Equals(LiveRange range)
{
return range._data == _data;
}
public override bool Equals(object obj)
{
return obj is LiveRange range && Equals(range);
}
public static bool operator ==(LiveRange a, LiveRange b)
{
return a.Equals(b);
}
public static bool operator !=(LiveRange a, LiveRange b)
{
return !a.Equals(b);
}
public override int GetHashCode()
{
return HashCode.Combine((IntPtr)_data);
}
public override string ToString()
{
return $"[{Start}, {End})";
}
}
}
|