github.com/go-asm/go@v1.21.1-0.20240213172139-40c5ead50c48/cmd/compile/mips/ggen.go (about) 1 // Copyright 2016 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package mips 6 7 import ( 8 "github.com/go-asm/go/cmd/compile/base" 9 "github.com/go-asm/go/cmd/compile/objw" 10 "github.com/go-asm/go/cmd/compile/types" 11 "github.com/go-asm/go/cmd/obj" 12 "github.com/go-asm/go/cmd/obj/mips" 13 ) 14 15 // TODO(mips): implement DUFFZERO 16 func zerorange(pp *objw.Progs, p *obj.Prog, off, cnt int64, _ *uint32) *obj.Prog { 17 18 if cnt == 0 { 19 return p 20 } 21 if cnt < int64(4*types.PtrSize) { 22 for i := int64(0); i < cnt; i += int64(types.PtrSize) { 23 p = pp.Append(p, mips.AMOVW, obj.TYPE_REG, mips.REGZERO, 0, obj.TYPE_MEM, mips.REGSP, base.Ctxt.Arch.FixedFrameSize+off+i) 24 } 25 } else { 26 //fmt.Printf("zerorange frame:%v, lo: %v, hi:%v \n", frame ,lo, hi) 27 // ADD $(FIXED_FRAME+frame+lo-4), SP, r1 28 // ADD $cnt, r1, r2 29 // loop: 30 // MOVW R0, (Widthptr)r1 31 // ADD $Widthptr, r1 32 // BNE r1, r2, loop 33 p = pp.Append(p, mips.AADD, obj.TYPE_CONST, 0, base.Ctxt.Arch.FixedFrameSize+off-4, obj.TYPE_REG, mips.REGRT1, 0) 34 p.Reg = mips.REGSP 35 p = pp.Append(p, mips.AADD, obj.TYPE_CONST, 0, cnt, obj.TYPE_REG, mips.REGRT2, 0) 36 p.Reg = mips.REGRT1 37 p = pp.Append(p, mips.AMOVW, obj.TYPE_REG, mips.REGZERO, 0, obj.TYPE_MEM, mips.REGRT1, int64(types.PtrSize)) 38 p1 := p 39 p = pp.Append(p, mips.AADD, obj.TYPE_CONST, 0, int64(types.PtrSize), obj.TYPE_REG, mips.REGRT1, 0) 40 p = pp.Append(p, mips.ABNE, obj.TYPE_REG, mips.REGRT1, 0, obj.TYPE_BRANCH, 0, 0) 41 p.Reg = mips.REGRT2 42 p.To.SetTarget(p1) 43 } 44 45 return p 46 } 47 48 func ginsnop(pp *objw.Progs) *obj.Prog { 49 p := pp.Prog(mips.ANOOP) 50 return p 51 }