-
Notifications
You must be signed in to change notification settings - Fork 0
/
inst_args.go
33 lines (27 loc) · 944 Bytes
/
inst_args.go
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
package ir
//go:generate stringer -type=SlotKind -trimprefix=Slot
type SlotKind uint8
const (
SlotInvalid SlotKind = iota
SlotCallArg
SlotParam
SlotTemp
SlotUniq
SlotDiscard
)
type Slot struct {
ID uint8
Kind SlotKind
}
func NewCallArgSlot(id uint8) Slot { return Slot{ID: id, Kind: SlotCallArg} }
func NewParamSlot(id uint8) Slot { return Slot{ID: id, Kind: SlotParam} }
func NewTempSlot(id uint8) Slot { return Slot{ID: id, Kind: SlotTemp} }
func NewUniqSlot(id uint8) Slot { return Slot{ID: id, Kind: SlotUniq} }
func (s Slot) ToInstArg() InstArg {
return InstArg((uint16(s.ID) << 8) | uint16(s.Kind))
}
func (s Slot) IsInvalid() bool { return s.Kind == SlotInvalid }
func (s Slot) IsCallArg() bool { return s.Kind == SlotCallArg }
func (s Slot) IsParam() bool { return s.Kind == SlotParam }
func (s Slot) IsTemp() bool { return s.Kind == SlotTemp }
func (s Slot) IsUniq() bool { return s.Kind == SlotUniq }