Source file src/cmd/compile/internal/ppc64/ggen.go

     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  	"cmd/compile/internal/base"
     9  	"cmd/compile/internal/ir"
    10  	"cmd/compile/internal/objw"
    11  	"cmd/compile/internal/types"
    12  	"cmd/internal/obj"
    13  	"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.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.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.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  	p := pp.Prog(ppc64.AOR)
    50  	p.From.Type = obj.TYPE_REG
    51  	p.From.Reg = ppc64.REG_R0
    52  	p.To.Type = obj.TYPE_REG
    53  	p.To.Reg = ppc64.REG_R0
    54  	return p
    55  }
    56  

View as plain text