github.com/bir3/gocompiler@v0.9.2202/src/cmd/compile/internal/ppc64/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 ppc64 6 7 import ( 8 "github.com/bir3/gocompiler/src/cmd/compile/internal/base" 9 "github.com/bir3/gocompiler/src/cmd/compile/internal/ir" 10 "github.com/bir3/gocompiler/src/cmd/compile/internal/objw" 11 "github.com/bir3/gocompiler/src/cmd/compile/internal/types" 12 "github.com/bir3/gocompiler/src/cmd/internal/obj" 13 "github.com/bir3/gocompiler/src/cmd/internal/obj/ppc64" 14 ) 15 16 func zerorange(pp *objw.Progs, p *obj.Prog, off, cnt int64, _ *uint32) *obj.Prog { 17 if cnt == 0 { 18 return p 19 } 20 if cnt < int64(4*types.PtrSize) { 21 for i := int64(0); i < cnt; i += int64(types.PtrSize) { 22 p = pp.Append(p, ppc64.AMOVD, obj.TYPE_REG, ppc64.REGZERO, 0, obj.TYPE_MEM, ppc64.REGSP, base.Ctxt.Arch.FixedFrameSize+off+i) 23 } 24 } else if cnt <= int64(128*types.PtrSize) { 25 p = pp.Append(p, ppc64.AADD, obj.TYPE_CONST, 0, base.Ctxt.Arch.FixedFrameSize+off-8, obj.TYPE_REG, ppc64.REGRT1, 0) 26 p.Reg = ppc64.REGSP 27 p = pp.Append(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_MEM, 0, 0) 28 p.To.Name = obj.NAME_EXTERN 29 p.To.Sym = ir.Syms.Duffzero 30 p.To.Offset = 4 * (128 - cnt/int64(types.PtrSize)) 31 } else { 32 p = pp.Append(p, ppc64.AMOVD, obj.TYPE_CONST, 0, base.Ctxt.Arch.FixedFrameSize+off-8, obj.TYPE_REG, ppc64.REGTMP, 0) 33 p = pp.Append(p, ppc64.AADD, obj.TYPE_REG, ppc64.REGTMP, 0, obj.TYPE_REG, ppc64.REGRT1, 0) 34 p.Reg = ppc64.REGSP 35 p = pp.Append(p, ppc64.AMOVD, obj.TYPE_CONST, 0, cnt, obj.TYPE_REG, ppc64.REGTMP, 0) 36 p = pp.Append(p, ppc64.AADD, obj.TYPE_REG, ppc64.REGTMP, 0, obj.TYPE_REG, ppc64.REGRT2, 0) 37 p.Reg = ppc64.REGRT1 38 p = pp.Append(p, ppc64.AMOVDU, obj.TYPE_REG, ppc64.REGZERO, 0, obj.TYPE_MEM, ppc64.REGRT1, int64(types.PtrSize)) 39 p1 := p 40 p = pp.Append(p, ppc64.ACMP, obj.TYPE_REG, ppc64.REGRT1, 0, obj.TYPE_REG, ppc64.REGRT2, 0) 41 p = pp.Append(p, ppc64.ABNE, obj.TYPE_NONE, 0, 0, obj.TYPE_BRANCH, 0, 0) 42 p.To.SetTarget(p1) 43 } 44 45 return p 46 } 47 48 func ginsnop(pp *objw.Progs) *obj.Prog { 49 // Generate the preferred hardware nop: ori 0,0,0 50 p := pp.Prog(ppc64.AOR) 51 p.From = obj.Addr{Type: obj.TYPE_CONST, Offset: 0} 52 p.To = obj.Addr{Type: obj.TYPE_REG, Reg: ppc64.REG_R0} 53 return p 54 }