From fe08d149a281936bd231d2450fb1d1457ad400c0 Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Thu, 2 Jan 2020 14:57:53 +0100 Subject: [PATCH] Separate AsX() in printing. --- reg/types.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/reg/types.go b/reg/types.go index 53531451..2d382010 100644 --- a/reg/types.go +++ b/reg/types.go @@ -144,11 +144,12 @@ func (v virtual) SatisfiedBy(p Physical) bool { func (v virtual) as(s Spec) Register { return virtual{ - id: v.id, - kind: v.kind, - Width: Width(s.Size()), - mask: s.Mask(), - allocAt: v.allocAt, + id: v.id, + kind: v.kind, + Width: Width(s.Size()), + mask: s.Mask(), + // Non-breaking space for sorting. + allocAt: fmt.Sprintf("\u00A0- As%v() %s", s.String(), getFnNameFile(2)), } } @@ -248,6 +249,16 @@ func (s Spec) Size() uint { return (x >> 1) + (x & 1) } +// Size returns the register width in bytes. +func (s Spec) String() string { + switch s { + case S8H: + return "8H" + default: + return fmt.Sprint(s.Size() * 8) + } +} + // AreConflicting returns whether registers conflict with each other. func AreConflicting(x, y Physical) bool { return x.Kind() == y.Kind() && x.PhysicalID() == y.PhysicalID() && (x.Mask()&y.Mask()) != 0