github.com/gagliardetto/golang-go@v0.0.0-20201020153340-53909ea70814/cmd/compile/internal/arm/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 arm
     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/arm"
    11  )
    12  
    13  func zerorange(pp *gc.Progs, p *obj.Prog, off, cnt int64, r0 *uint32) *obj.Prog {
    14  	if cnt == 0 {
    15  		return p
    16  	}
    17  	if *r0 == 0 {
    18  		p = pp.Appendpp(p, arm.AMOVW, obj.TYPE_CONST, 0, 0, obj.TYPE_REG, arm.REG_R0, 0)
    19  		*r0 = 1
    20  	}
    21  
    22  	if cnt < int64(4*gc.Widthptr) {
    23  		for i := int64(0); i < cnt; i += int64(gc.Widthptr) {
    24  			p = pp.Appendpp(p, arm.AMOVW, obj.TYPE_REG, arm.REG_R0, 0, obj.TYPE_MEM, arm.REGSP, 4+off+i)
    25  		}
    26  	} else if cnt <= int64(128*gc.Widthptr) {
    27  		p = pp.Appendpp(p, arm.AADD, obj.TYPE_CONST, 0, 4+off, obj.TYPE_REG, arm.REG_R1, 0)
    28  		p.Reg = arm.REGSP
    29  		p = pp.Appendpp(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_MEM, 0, 0)
    30  		p.To.Name = obj.NAME_EXTERN
    31  		p.To.Sym = gc.Duffzero
    32  		p.To.Offset = 4 * (128 - cnt/int64(gc.Widthptr))
    33  	} else {
    34  		p = pp.Appendpp(p, arm.AADD, obj.TYPE_CONST, 0, 4+off, obj.TYPE_REG, arm.REG_R1, 0)
    35  		p.Reg = arm.REGSP
    36  		p = pp.Appendpp(p, arm.AADD, obj.TYPE_CONST, 0, cnt, obj.TYPE_REG, arm.REG_R2, 0)
    37  		p.Reg = arm.REG_R1
    38  		p = pp.Appendpp(p, arm.AMOVW, obj.TYPE_REG, arm.REG_R0, 0, obj.TYPE_MEM, arm.REG_R1, 4)
    39  		p1 := p
    40  		p.Scond |= arm.C_PBIT
    41  		p = pp.Appendpp(p, arm.ACMP, obj.TYPE_REG, arm.REG_R1, 0, obj.TYPE_NONE, 0, 0)
    42  		p.Reg = arm.REG_R2
    43  		p = pp.Appendpp(p, arm.ABNE, obj.TYPE_NONE, 0, 0, obj.TYPE_BRANCH, 0, 0)
    44  		gc.Patch(p, p1)
    45  	}
    46  
    47  	return p
    48  }
    49  
    50  func ginsnop(pp *gc.Progs) *obj.Prog {
    51  	p := pp.Prog(arm.AAND)
    52  	p.From.Type = obj.TYPE_REG
    53  	p.From.Reg = arm.REG_R0
    54  	p.To.Type = obj.TYPE_REG
    55  	p.To.Reg = arm.REG_R0
    56  	p.Scond = arm.C_SCOND_EQ
    57  	return p
    58  }