Source file src/cmd/compile/internal/arm64/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 arm64
     6  
     7  import (
     8  	"cmd/compile/internal/objw"
     9  	"cmd/internal/obj"
    10  	"cmd/internal/obj/arm64"
    11  )
    12  
    13  func padframe(frame int64) int64 {
    14  	// arm64 requires that the frame size (not counting saved FP&LR)
    15  	// be 16 bytes aligned. If not, pad it.
    16  	if frame%16 != 0 {
    17  		frame += 16 - (frame % 16)
    18  	}
    19  	return frame
    20  }
    21  
    22  func zerorange(pp *objw.Progs, p *obj.Prog, off, cnt int64, _ *uint32) *obj.Prog {
    23  	if cnt%8 != 0 {
    24  		panic("zeroed region not aligned")
    25  	}
    26  	off += 8 // return address was ignored in offset calculation
    27  	for cnt >= 16 && off < 512 {
    28  		p = pp.Append(p, arm64.ASTP, obj.TYPE_REGREG, arm64.REGZERO, arm64.REGZERO, obj.TYPE_MEM, arm64.REGSP, off)
    29  		off += 16
    30  		cnt -= 16
    31  	}
    32  	for cnt != 0 {
    33  		p = pp.Append(p, arm64.AMOVD, obj.TYPE_REG, arm64.REGZERO, 0, obj.TYPE_MEM, arm64.REGSP, off)
    34  		off += 8
    35  		cnt -= 8
    36  	}
    37  	return p
    38  }
    39  
    40  func ginsnop(pp *objw.Progs) *obj.Prog {
    41  	p := pp.Prog(arm64.AHINT)
    42  	p.From.Type = obj.TYPE_CONST
    43  	return p
    44  }
    45  

View as plain text