Source file src/internal/goarch/goarch.go
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 // ArchFamily is the architecture family (AMD64, ARM, ...) 38 const ArchFamily ArchFamilyType = _ArchFamily 39 40 // BigEndian reports whether the architecture is big-endian. 41 const BigEndian = IsArmbe|IsArm64be|IsMips|IsMips64|IsPpc|IsPpc64|IsS390|IsS390x|IsSparc|IsSparc64 == 1 42 43 // DefaultPhysPageSize is the default physical page size. 44 const DefaultPhysPageSize = _DefaultPhysPageSize 45 46 // PCQuantum is the minimal unit for a program counter (1 on x86, 4 on most other systems). 47 // The various PC tables record PC deltas pre-divided by PCQuantum. 48 const PCQuantum = _PCQuantum 49 50 // Int64Align is the required alignment for a 64-bit integer (4 on 32-bit systems, 8 on 64-bit). 51 const Int64Align = PtrSize 52 53 // MinFrameSize is the size of the system-reserved words at the bottom 54 // of a frame (just above the architectural stack pointer). 55 // It is zero on x86 and PtrSize on most non-x86 (LR-based) systems. 56 // On PowerPC it is larger, to cover three more reserved words: 57 // the compiler word, the link editor word, and the TOC save word. 58 const MinFrameSize = _MinFrameSize 59 60 // StackAlign is the required alignment of the SP register. 61 // The stack must be at least word aligned, but some architectures require more. 62 const StackAlign = _StackAlign 63