| 1 |
package arm |
| 2 |
|
| 3 |
import ( |
| 4 |
"github.com/segmentio/asm/cpu/cpuid" |
| 5 |
. "golang.org/x/sys/cpu" |
| 6 |
) |
| 7 |
|
| 8 |
type CPU cpuid.CPU |
| 9 |
|
| 10 |
func (cpu CPU) Has(feature Feature) bool { |
| 11 |
return cpuid.CPU(cpu).Has(cpuid.Feature(feature)) |
| 12 |
} |
| 13 |
|
| 14 |
func (cpu *CPU) set(feature Feature, enable bool) { |
| 15 |
(*cpuid.CPU)(cpu).Set(cpuid.Feature(feature), enable) |
| 16 |
} |
| 17 |
|
| 18 |
type Feature cpuid.Feature |
| 19 |
|
| 20 |
const ( |
| 21 |
SWP Feature = 1 << iota // SWP instruction support |
| 22 |
HALF // Half-word load and store support |
| 23 |
THUMB // ARM Thumb instruction set |
| 24 |
BIT26 // Address space limited to 26-bits |
| 25 |
FASTMUL // 32-bit operand, 64-bit result multiplication support |
| 26 |
FPA // Floating point arithmetic support |
| 27 |
VFP // Vector floating point support |
| 28 |
EDSP // DSP Extensions support |
| 29 |
JAVA // Java instruction set |
| 30 |
IWMMXT // Intel Wireless MMX technology support |
| 31 |
CRUNCH // MaverickCrunch context switching and handling |
| 32 |
THUMBEE // Thumb EE instruction set |
| 33 |
NEON // NEON instruction set |
| 34 |
VFPv3 // Vector floating point version 3 support |
| 35 |
VFPv3D16 // Vector floating point version 3 D8-D15 |
| 36 |
TLS // Thread local storage support |
| 37 |
VFPv4 // Vector floating point version 4 support |
| 38 |
IDIVA // Integer divide instruction support in ARM mode |
| 39 |
IDIVT // Integer divide instruction support in Thumb mode |
| 40 |
VFPD32 // Vector floating point version 3 D15-D31 |
| 41 |
LPAE // Large Physical Address Extensions |
| 42 |
EVTSTRM // Event stream support |
| 43 |
AES // AES hardware implementation |
| 44 |
PMULL // Polynomial multiplication instruction set |
| 45 |
SHA1 // SHA1 hardware implementation |
| 46 |
SHA2 // SHA2 hardware implementation |
| 47 |
CRC32 // CRC32 hardware implementation |
| 48 |
) |
| 49 |
|
| 50 |
func ABI() CPU { |
| 51 |
cpu := CPU(0) |
| 52 |
cpu.set(SWP, ARM.HasSWP) |
| 53 |
cpu.set(HALF, ARM.HasHALF) |
| 54 |
cpu.set(THUMB, ARM.HasTHUMB) |
| 55 |
cpu.set(BIT26, ARM.Has26BIT) |
| 56 |
cpu.set(FASTMUL, ARM.HasFASTMUL) |
| 57 |
cpu.set(FPA, ARM.HasFPA) |
| 58 |
cpu.set(VFP, ARM.HasVFP) |
| 59 |
cpu.set(EDSP, ARM.HasEDSP) |
| 60 |
cpu.set(JAVA, ARM.HasJAVA) |
| 61 |
cpu.set(IWMMXT, ARM.HasIWMMXT) |
| 62 |
cpu.set(CRUNCH, ARM.HasCRUNCH) |
| 63 |
cpu.set(THUMBEE, ARM.HasTHUMBEE) |
| 64 |
cpu.set(NEON, ARM.HasNEON) |
| 65 |
cpu.set(VFPv3, ARM.HasVFPv3) |
| 66 |
cpu.set(VFPv3D16, ARM.HasVFPv3D16) |
| 67 |
cpu.set(TLS, ARM.HasTLS) |
| 68 |
cpu.set(VFPv4, ARM.HasVFPv4) |
| 69 |
cpu.set(IDIVA, ARM.HasIDIVA) |
| 70 |
cpu.set(IDIVT, ARM.HasIDIVT) |
| 71 |
cpu.set(VFPD32, ARM.HasVFPD32) |
| 72 |
cpu.set(LPAE, ARM.HasLPAE) |
| 73 |
cpu.set(EVTSTRM, ARM.HasEVTSTRM) |
| 74 |
cpu.set(AES, ARM.HasAES) |
| 75 |
cpu.set(PMULL, ARM.HasPMULL) |
| 76 |
cpu.set(SHA1, ARM.HasSHA1) |
| 77 |
cpu.set(SHA2, ARM.HasSHA2) |
| 78 |
cpu.set(CRC32, ARM.HasCRC32) |
| 79 |
return cpu |
| 80 |
} |