Black Lives Matter. Support the Equal Justice Initiative.

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

Documentation: cmd/compile/internal/mips

     1  // Copyright 2016 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 mips
     6  
     7  import (
     8  	"cmd/compile/internal/gc"
     9  	"cmd/internal/obj"
    10  	"cmd/internal/obj/mips"
    11  )
    12  
    13  // TODO(mips): implement DUFFZERO
    14  func zerorange(pp *gc.Progs, p *obj.Prog, off, cnt int64, _ *uint32) *obj.Prog {
    15  
    16  	if cnt == 0 {
    17  		return p
    18  	}
    19  	if cnt < int64(4*gc.Widthptr) {
    20  		for i := int64(0); i < cnt; i += int64(gc.Widthptr) {
    21  			p = pp.Appendpp(p, mips.AMOVW, obj.TYPE_REG, mips.REGZERO, 0, obj.TYPE_MEM, mips.REGSP, gc.Ctxt.FixedFrameSize()+off+i)
    22  		}
    23  	} else {
    24  		//fmt.Printf("zerorange frame:%v, lo: %v, hi:%v \n", frame ,lo, hi)
    25  		//	ADD 	$(FIXED_FRAME+frame+lo-4), SP, r1
    26  		//	ADD 	$cnt, r1, r2
    27  		// loop:
    28  		//	MOVW	R0, (Widthptr)r1
    29  		//	ADD 	$Widthptr, r1
    30  		//	BNE		r1, r2, loop
    31  		p = pp.Appendpp(p, mips.AADD, obj.TYPE_CONST, 0, gc.Ctxt.FixedFrameSize()+off-4, obj.TYPE_REG, mips.REGRT1, 0)
    32  		p.Reg = mips.REGSP
    33  		p = pp.Appendpp(p, mips.AADD, obj.TYPE_CONST, 0, cnt, obj.TYPE_REG, mips.REGRT2, 0)
    34  		p.Reg = mips.REGRT1
    35  		p = pp.Appendpp(p, mips.AMOVW, obj.TYPE_REG, mips.REGZERO, 0, obj.TYPE_MEM, mips.REGRT1, int64(gc.Widthptr))
    36  		p1 := p
    37  		p = pp.Appendpp(p, mips.AADD, obj.TYPE_CONST, 0, int64(gc.Widthptr), obj.TYPE_REG, mips.REGRT1, 0)
    38  		p = pp.Appendpp(p, mips.ABNE, obj.TYPE_REG, mips.REGRT1, 0, obj.TYPE_BRANCH, 0, 0)
    39  		p.Reg = mips.REGRT2
    40  		gc.Patch(p, p1)
    41  	}
    42  
    43  	return p
    44  }
    45  
    46  func ginsnop(pp *gc.Progs) *obj.Prog {
    47  	p := pp.Prog(mips.ANOR)
    48  	p.From.Type = obj.TYPE_REG
    49  	p.From.Reg = mips.REG_R0
    50  	p.To.Type = obj.TYPE_REG
    51  	p.To.Reg = mips.REG_R0
    52  	return p
    53  }
    54  

View as plain text