...

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

Documentation: cmd/compile/internal/x86

     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 x86
     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/x86"
    13  )
    14  
    15  func zerorange(pp *objw.Progs, p *obj.Prog, off, cnt int64, ax *uint32) *obj.Prog {
    16  	if cnt == 0 {
    17  		return p
    18  	}
    19  	if *ax == 0 {
    20  		p = pp.Append(p, x86.AMOVL, obj.TYPE_CONST, 0, 0, obj.TYPE_REG, x86.REG_AX, 0)
    21  		*ax = 1
    22  	}
    23  
    24  	if cnt <= int64(4*types.RegSize) {
    25  		for i := int64(0); i < cnt; i += int64(types.RegSize) {
    26  			p = pp.Append(p, x86.AMOVL, obj.TYPE_REG, x86.REG_AX, 0, obj.TYPE_MEM, x86.REG_SP, off+i)
    27  		}
    28  	} else if cnt <= int64(128*types.RegSize) {
    29  		p = pp.Append(p, x86.ALEAL, obj.TYPE_MEM, x86.REG_SP, off, obj.TYPE_REG, x86.REG_DI, 0)
    30  		p = pp.Append(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_ADDR, 0, 1*(128-cnt/int64(types.RegSize)))
    31  		p.To.Sym = ir.Syms.Duffzero
    32  	} else {
    33  		p = pp.Append(p, x86.AMOVL, obj.TYPE_CONST, 0, cnt/int64(types.RegSize), obj.TYPE_REG, x86.REG_CX, 0)
    34  		p = pp.Append(p, x86.ALEAL, obj.TYPE_MEM, x86.REG_SP, off, obj.TYPE_REG, x86.REG_DI, 0)
    35  		p = pp.Append(p, x86.AREP, obj.TYPE_NONE, 0, 0, obj.TYPE_NONE, 0, 0)
    36  		p = pp.Append(p, x86.ASTOSL, obj.TYPE_NONE, 0, 0, obj.TYPE_NONE, 0, 0)
    37  	}
    38  
    39  	return p
    40  }
    41  
    42  func ginsnop(pp *objw.Progs) *obj.Prog {
    43  	// See comment in ../amd64/ggen.go.
    44  	p := pp.Prog(x86.AXCHGL)
    45  	p.From.Type = obj.TYPE_REG
    46  	p.From.Reg = x86.REG_AX
    47  	p.To.Type = obj.TYPE_REG
    48  	p.To.Reg = x86.REG_AX
    49  	return p
    50  }
    51  

View as plain text