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. 6package 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 15type ArchFamilyType int 16 17const ( 18 AMD64 ArchFamilyType = iota 19 ARM 20 ARM64 21 I386 22 LOONG64 23 MIPS 24 MIPS64 25 PPC64 26 RISCV64 27 S390X 28 WASM 29) 30 31// PtrSize is the size of a pointer in bytes - unsafe.Sizeof(uintptr(0)) but as an ideal constant. 32// It is also the size of the machine's native word size (that is, 4 on 32-bit systems, 8 on 64-bit). 33const PtrSize = 4 << (^uintptr(0) >> 63) 34 35// ArchFamily is the architecture family (AMD64, ARM, ...) 36const ArchFamily ArchFamilyType = _ArchFamily 37 38// BigEndian reports whether the architecture is big-endian. 39const BigEndian = IsArmbe|IsArm64be|IsMips|IsMips64|IsPpc|IsPpc64|IsS390|IsS390x|IsSparc|IsSparc64 == 1 40 41// DefaultPhysPageSize is the default physical page size. 42const DefaultPhysPageSize = _DefaultPhysPageSize 43 44// PCQuantum is the minimal unit for a program counter (1 on x86, 4 on most other systems). 45// The various PC tables record PC deltas pre-divided by PCQuantum. 46const PCQuantum = _PCQuantum 47 48// Int64Align is the required alignment for a 64-bit integer (4 on 32-bit systems, 8 on 64-bit). 49const Int64Align = PtrSize 50 51// MinFrameSize is the size of the system-reserved words at the bottom 52// of a frame (just above the architectural stack pointer). 53// It is zero on x86 and PtrSize on most non-x86 (LR-based) systems. 54// On PowerPC it is larger, to cover three more reserved words: 55// the compiler word, the link editor word, and the TOC save word. 56const MinFrameSize = _MinFrameSize 57 58// StackAlign is the required alignment of the SP register. 59// The stack must be at least word aligned, but some architectures require more. 60const StackAlign = _StackAlign 61