Black Lives Matter. Support the Equal Justice Initiative.

Text file src/runtime/time_windows_arm64.s

Documentation: runtime

     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  // +build !faketime
     7  
     8  #include "go_asm.h"
     9  #include "textflag.h"
    10  #include "time_windows.h"
    11  
    12  TEXT time·now(SB),NOSPLIT|NOFRAME,$0-24
    13  	MOVB    runtime·useQPCTime(SB), R0
    14  	CMP	$0, R0
    15  	BNE	useQPC
    16  	MOVD	$_INTERRUPT_TIME, R3
    17  loop:
    18  	MOVWU	time_hi1(R3), R1
    19  	MOVWU	time_lo(R3), R0
    20  	MOVWU	time_hi2(R3), R2
    21  	CMP	R1, R2
    22  	BNE	loop
    23  
    24  	// wintime = R1:R0, multiply by 100
    25  	ORR	R1<<32, R0
    26  	MOVD	$100, R1
    27  	MUL	R1, R0
    28  	MOVD	R0, mono+16(FP)
    29  
    30  	MOVD	$_SYSTEM_TIME, R3
    31  wall:
    32  	MOVWU	time_hi1(R3), R1
    33  	MOVWU	time_lo(R3), R0
    34  	MOVWU	time_hi2(R3), R2
    35  	CMP	R1, R2
    36  	BNE	wall
    37  
    38  	// w = R1:R0 in 100ns units
    39  	// convert to Unix epoch (but still 100ns units)
    40  	#define delta 116444736000000000
    41  	ORR	R1<<32, R0
    42  	SUB	$delta, R0
    43  
    44  	// Convert to nSec
    45  	MOVD	$100, R1
    46  	MUL	R1, R0
    47  
    48  	// Code stolen from compiler output for:
    49  	//
    50  	//	var x uint64
    51  	//	func f() (sec uint64, nsec uint32) { return x / 1000000000, uint32(x % 100000000) }
    52  	//
    53  	LSR	$1, R0, R1
    54  	MOVD	$-8543223759426509416, R2
    55  	UMULH	R2, R1, R1
    56  	LSR	$28, R1, R1
    57  	MOVD	R1, sec+0(FP)
    58  	MOVD	$-6067343680855748867, R1
    59  	UMULH	R0, R1, R1
    60  	LSR	$26, R1, R1
    61  	MOVD	$100000000, R2
    62  	MSUB	R1, R0, R2, R0
    63  	MOVW	R0, nsec+8(FP)
    64  	RET
    65  useQPC:
    66  	B	runtime·nowQPC(SB)		// tail call
    67  
    68  

View as plain text