github.com/gagliardetto/golang-go@v0.0.0-20201020153340-53909ea70814/cmd/compile/internal/mips64/ggen.go (about) 1 // Copyright 2009 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 mips64 6 7 import ( 8 "github.com/gagliardetto/golang-go/cmd/compile/internal/gc" 9 "github.com/gagliardetto/golang-go/cmd/internal/obj" 10 "github.com/gagliardetto/golang-go/cmd/internal/obj/mips" 11 ) 12 13 func zerorange(pp *gc.Progs, p *obj.Prog, off, cnt int64, _ *uint32) *obj.Prog { 14 if cnt == 0 { 15 return p 16 } 17 if cnt < int64(4*gc.Widthptr) { 18 for i := int64(0); i < cnt; i += int64(gc.Widthptr) { 19 p = pp.Appendpp(p, mips.AMOVV, obj.TYPE_REG, mips.REGZERO, 0, obj.TYPE_MEM, mips.REGSP, 8+off+i) 20 } 21 } else if cnt <= int64(128*gc.Widthptr) { 22 p = pp.Appendpp(p, mips.AADDV, obj.TYPE_CONST, 0, 8+off-8, obj.TYPE_REG, mips.REGRT1, 0) 23 p.Reg = mips.REGSP 24 p = pp.Appendpp(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_MEM, 0, 0) 25 p.To.Name = obj.NAME_EXTERN 26 p.To.Sym = gc.Duffzero 27 p.To.Offset = 8 * (128 - cnt/int64(gc.Widthptr)) 28 } else { 29 // ADDV $(8+frame+lo-8), SP, r1 30 // ADDV $cnt, r1, r2 31 // loop: 32 // MOVV R0, (Widthptr)r1 33 // ADDV $Widthptr, r1 34 // BNE r1, r2, loop 35 p = pp.Appendpp(p, mips.AADDV, obj.TYPE_CONST, 0, 8+off-8, obj.TYPE_REG, mips.REGRT1, 0) 36 p.Reg = mips.REGSP 37 p = pp.Appendpp(p, mips.AADDV, obj.TYPE_CONST, 0, cnt, obj.TYPE_REG, mips.REGRT2, 0) 38 p.Reg = mips.REGRT1 39 p = pp.Appendpp(p, mips.AMOVV, obj.TYPE_REG, mips.REGZERO, 0, obj.TYPE_MEM, mips.REGRT1, int64(gc.Widthptr)) 40 p1 := p 41 p = pp.Appendpp(p, mips.AADDV, obj.TYPE_CONST, 0, int64(gc.Widthptr), obj.TYPE_REG, mips.REGRT1, 0) 42 p = pp.Appendpp(p, mips.ABNE, obj.TYPE_REG, mips.REGRT1, 0, obj.TYPE_BRANCH, 0, 0) 43 p.Reg = mips.REGRT2 44 gc.Patch(p, p1) 45 } 46 47 return p 48 } 49 50 func ginsnop(pp *gc.Progs) *obj.Prog { 51 p := pp.Prog(mips.ANOR) 52 p.From.Type = obj.TYPE_REG 53 p.From.Reg = mips.REG_R0 54 p.To.Type = obj.TYPE_REG 55 p.To.Reg = mips.REG_R0 56 return p 57 }