Text file src/runtime/time_windows_arm64.s

     1  // Copyright 2018 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  //go:build !faketime
     6  
     7  #include "go_asm.h"
     8  #include "textflag.h"
     9  #include "time_windows.h"
    10  
    11  TEXT time·now(SB),NOSPLIT|NOFRAME,$0-24
    12  	MOVB    runtime·useQPCTime(SB), R0
    13  	CMP	$0, R0
    14  	BNE	useQPC
    15  
    16  	MOVD	$_INTERRUPT_TIME, R3
    17  	MOVD	time_lo(R3), R0
    18  	MOVD	$100, R1
    19  	MUL	R1, R0
    20  	MOVD	R0, mono+16(FP)
    21  
    22  	MOVD	$_SYSTEM_TIME, R3
    23  	MOVD	time_lo(R3), R0
    24  	// convert to Unix epoch (but still 100ns units)
    25  	#define delta 116444736000000000
    26  	SUB	$delta, R0
    27  	// Convert to nSec
    28  	MOVD	$100, R1
    29  	MUL	R1, R0
    30  
    31  	// Code stolen from compiler output for:
    32  	//
    33  	//	var x uint64
    34  	//	func f() (sec uint64, nsec uint32) { return x / 1000000000, uint32(x % 1000000000) }
    35  	//
    36  	LSR	$1, R0, R1
    37  	MOVD	$-8543223759426509416, R2
    38  	UMULH	R1, R2, R1
    39  	LSR	$28, R1, R1
    40  	MOVD	R1, sec+0(FP)
    41  	MOVD	$1000000000, R2
    42  	MSUB	R1, R0, R2, R0
    43  	MOVW	R0, nsec+8(FP)
    44  	RET
    45  useQPC:
    46  	B	runtime·nowQPC(SB)		// tail call
    47  
    48  

View as plain text