| 1 |
// Copyright 2021 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 goarch contains GOARCH-specific constants. |
| 6 |
package goarch |
| 7 |
|
| 8 |
// The next line makes 'go generate' write the zgoarch*.go files with |
| 9 |
// per-arch information, including constants named $GOARCH for every |
| 10 |
// GOARCH. The constant is 1 on the current system, 0 otherwise; multiplying |
| 11 |
// by them is useful for defining GOARCH-specific constants. |
| 12 |
// |
| 13 |
//go:generate go run gengoarch.go |
| 14 |
|
| 15 |
// ArchFamilyType represents a family of one or more related architectures. |
| 16 |
// For example, ppc64 and ppc64le are both members of the PPC64 family. |
| 17 |
type ArchFamilyType int |
| 18 |
|
| 19 |
const ( |
| 20 |
AMD64 ArchFamilyType = iota |
| 21 |
ARM |
| 22 |
ARM64 |
| 23 |
I386 |
| 24 |
LOONG64 |
| 25 |
MIPS |
| 26 |
MIPS64 |
| 27 |
PPC64 |
| 28 |
RISCV64 |
| 29 |
S390X |
| 30 |
WASM |
| 31 |
) |
| 32 |
|
| 33 |
// PtrSize is the size of a pointer in bytes - unsafe.Sizeof(uintptr(0)) but as an ideal constant. |
| 34 |
// It is also the size of the machine's native word size (that is, 4 on 32-bit systems, 8 on 64-bit). |
| 35 |
const PtrSize = 4 << (^uintptr(0) >> 63) |
| 36 |
|
| 37 |
// PtrBits is bit width of a pointer. |
| 38 |
const PtrBits = PtrSize * 8 |
| 39 |
|
| 40 |
// ArchFamily is the architecture family (AMD64, ARM, ...) |
| 41 |
const ArchFamily ArchFamilyType = _ArchFamily |
| 42 |
|
| 43 |
// BigEndian reports whether the architecture is big-endian. |
| 44 |
const BigEndian = IsArmbe|IsArm64be|IsMips|IsMips64|IsPpc|IsPpc64|IsS390|IsS390x|IsSparc|IsSparc64 == 1 |
| 45 |
|
| 46 |
// DefaultPhysPageSize is the default physical page size. |
| 47 |
const DefaultPhysPageSize = _DefaultPhysPageSize |
| 48 |
|
| 49 |
// PCQuantum is the minimal unit for a program counter (1 on x86, 4 on most other systems). |
| 50 |
// The various PC tables record PC deltas pre-divided by PCQuantum. |
| 51 |
const PCQuantum = _PCQuantum |
| 52 |
|
| 53 |
// Int64Align is the required alignment for a 64-bit integer (4 on 32-bit systems, 8 on 64-bit). |
| 54 |
const Int64Align = PtrSize |
| 55 |
|
| 56 |
// MinFrameSize is the size of the system-reserved words at the bottom |
| 57 |
// of a frame (just above the architectural stack pointer). |
| 58 |
// It is zero on x86 and PtrSize on most non-x86 (LR-based) systems. |
| 59 |
// On PowerPC it is larger, to cover three more reserved words: |
| 60 |
// the compiler word, the link editor word, and the TOC save word. |
| 61 |
const MinFrameSize = _MinFrameSize |
| 62 |
|
| 63 |
// StackAlign is the required alignment of the SP register. |
| 64 |
// The stack must be at least word aligned, but some architectures require more. |
| 65 |
const StackAlign = _StackAlign |