gotypes: saving progress (temporarily broken tests)
This commit is contained in:
@@ -31,6 +31,19 @@ type Mem struct {
|
||||
Scale uint8
|
||||
}
|
||||
|
||||
// NewParamAddr is a convenience to build a Mem operand pointing to a function
|
||||
// parameter, which is a named offset from the frame pointer pseudo register.
|
||||
func NewParamAddr(name string, offset int) Mem {
|
||||
return Mem{
|
||||
Symbol: Symbol{
|
||||
Name: name,
|
||||
Static: false,
|
||||
},
|
||||
Disp: offset,
|
||||
Base: reg.FramePointer,
|
||||
}
|
||||
}
|
||||
|
||||
func (m Mem) Asm() string {
|
||||
a := m.Symbol.String()
|
||||
if m.Disp != 0 {
|
||||
|
||||
@@ -41,6 +41,7 @@ func TestMemAsm(t *testing.T) {
|
||||
{Mem{Symbol: Symbol{Name: "foo"}, Base: reg.StaticBase, Disp: 4}, "foo+4(SB)"},
|
||||
{Mem{Symbol: Symbol{Name: "foo"}, Base: reg.StaticBase, Disp: -7}, "foo-7(SB)"},
|
||||
{Mem{Symbol: Symbol{Name: "bar", Static: true}, Base: reg.StaticBase, Disp: 4, Index: reg.R11, Scale: 4}, "bar<>+4(SB)(R11*4)"},
|
||||
{NewParamAddr("param", 16), "param+16(FP)"},
|
||||
}
|
||||
for _, c := range cases {
|
||||
got := c.Mem.Asm()
|
||||
|
||||
Reference in New Issue
Block a user