aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/export_debug_regabiargs_on_test.go
blob: 7d1ab6888e63e83fb3376fb0ae252a23567d360c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build amd64 && linux && goexperiment.regabiargs

package runtime

import "internal/abi"

// storeRegArgs sets up argument registers in the signal
// context state from an abi.RegArgs.
//
// Both src and dst must be non-nil.
func storeRegArgs(dst *sigcontext, src *abi.RegArgs) {
	dst.rax = uint64(src.Ints[0])
	dst.rbx = uint64(src.Ints[1])
	dst.rcx = uint64(src.Ints[2])
	dst.rdi = uint64(src.Ints[3])
	dst.rsi = uint64(src.Ints[4])
	dst.r8 = uint64(src.Ints[5])
	dst.r9 = uint64(src.Ints[6])
	dst.r10 = uint64(src.Ints[7])
	dst.r11 = uint64(src.Ints[8])
	for i := range src.Floats {
		dst.fpstate._xmm[i].element[0] = uint32(src.Floats[i] >> 0)
		dst.fpstate._xmm[i].element[1] = uint32(src.Floats[i] >> 32)
	}
}

func loadRegArgs(dst *abi.RegArgs, src *sigcontext) {
	dst.Ints[0] = uintptr(src.rax)
	dst.Ints[1] = uintptr(src.rbx)
	dst.Ints[2] = uintptr(src.rcx)
	dst.Ints[3] = uintptr(src.rdi)
	dst.Ints[4] = uintptr(src.rsi)
	dst.Ints[5] = uintptr(src.r8)
	dst.Ints[6] = uintptr(src.r9)
	dst.Ints[7] = uintptr(src.r10)
	dst.Ints[8] = uintptr(src.r11)
	for i := range dst.Floats {
		dst.Floats[i] = uint64(src.fpstate._xmm[i].element[0]) << 0
		dst.Floats[i] |= uint64(src.fpstate._xmm[i].element[1]) << 32
	}
}