...

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

Documentation: cmd/compile/internal/arm

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

View as plain text