Source file src/cmd/compile/internal/mips64/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 mips64
     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/mips"
    13  )
    14  
    15  func zerorange(pp *objw.Progs, p *obj.Prog, off, cnt int64, _ *uint32) *obj.Prog {
    16  	if cnt == 0 {
    17  		return p
    18  	}
    19  	if cnt < int64(4*types.PtrSize) {
    20  		for i := int64(0); i < cnt; i += int64(types.PtrSize) {
    21  			p = pp.Append(p, mips.AMOVV, obj.TYPE_REG, mips.REGZERO, 0, obj.TYPE_MEM, mips.REGSP, 8+off+i)
    22  		}
    23  	} else if cnt <= int64(128*types.PtrSize) {
    24  		p = pp.Append(p, mips.AADDV, obj.TYPE_CONST, 0, 8+off-8, obj.TYPE_REG, mips.REGRT1, 0)
    25  		p.Reg = mips.REGSP
    26  		p = pp.Append(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_MEM, 0, 0)
    27  		p.To.Name = obj.NAME_EXTERN
    28  		p.To.Sym = ir.Syms.Duffzero
    29  		p.To.Offset = 8 * (128 - cnt/int64(types.PtrSize))
    30  	} else {
    31  		//	ADDV	$(8+frame+lo-8), SP, r1
    32  		//	ADDV	$cnt, r1, r2
    33  		// loop:
    34  		//	MOVV	R0, (Widthptr)r1
    35  		//	ADDV	$Widthptr, r1
    36  		//	BNE		r1, r2, loop
    37  		p = pp.Append(p, mips.AADDV, obj.TYPE_CONST, 0, 8+off-8, obj.TYPE_REG, mips.REGRT1, 0)
    38  		p.Reg = mips.REGSP
    39  		p = pp.Append(p, mips.AADDV, obj.TYPE_CONST, 0, cnt, obj.TYPE_REG, mips.REGRT2, 0)
    40  		p.Reg = mips.REGRT1
    41  		p = pp.Append(p, mips.AMOVV, obj.TYPE_REG, mips.REGZERO, 0, obj.TYPE_MEM, mips.REGRT1, int64(types.PtrSize))
    42  		p1 := p
    43  		p = pp.Append(p, mips.AADDV, obj.TYPE_CONST, 0, int64(types.PtrSize), obj.TYPE_REG, mips.REGRT1, 0)
    44  		p = pp.Append(p, mips.ABNE, obj.TYPE_REG, mips.REGRT1, 0, obj.TYPE_BRANCH, 0, 0)
    45  		p.Reg = mips.REGRT2
    46  		p.To.SetTarget(p1)
    47  	}
    48  
    49  	return p
    50  }
    51  
    52  func ginsnop(pp *objw.Progs) *obj.Prog {
    53  	p := pp.Prog(mips.ANOR)
    54  	p.From.Type = obj.TYPE_REG
    55  	p.From.Reg = mips.REG_R0
    56  	p.To.Type = obj.TYPE_REG
    57  	p.To.Reg = mips.REG_R0
    58  	return p
    59  }
    60  

View as plain text