mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
sys/info: add feature detection for Darwin and Linux ARM
This commit is contained in:
+43
-14
@@ -1,26 +1,55 @@
|
||||
//+build arm32, arm64
|
||||
package sysinfo
|
||||
|
||||
// TODO: Set up an enum with the ARM equivalent of the above.
|
||||
CPU_Feature :: enum u64 {}
|
||||
CPU_Feature :: enum u64 {
|
||||
// Advanced SIMD & floating-point capabilities:
|
||||
asimd, // General support for Advanced SIMD instructions/neon.
|
||||
floatingpoint, // General support for floating-point instructions.
|
||||
asimdhp, // Advanced SIMD half-precision conversion instructions.
|
||||
bf16, // Storage and arithmetic instructions of the Brain Floating Point (BFloat16) data type.
|
||||
fcma, // Floating-point complex number instructions.
|
||||
fhm, // Floating-point half-precision multiplication instructions.
|
||||
fp16, // General half-precision floating-point data processing instructions.
|
||||
frint, // Floating-point to integral valued floating-point number rounding instructions.
|
||||
i8mm, // Advanced SIMD int8 matrix multiplication instructions.
|
||||
jscvt, // JavaScript conversion instruction.
|
||||
rdm, // Advanced SIMD rounding double multiply accumulate instructions.
|
||||
|
||||
cpu_features: Maybe(CPU_Feature)
|
||||
cpu_name: Maybe(string)
|
||||
flagm, // Condition flag manipulation instructions.
|
||||
flagm2, // Enhancements to condition flag manipulation instructions.
|
||||
crc32, // CRC32 instructions.
|
||||
|
||||
@(init, private)
|
||||
init_cpu_features :: proc "c" () {
|
||||
lse, // Atomic instructions to support large systems.
|
||||
lse2, // Changes to single-copy atomicity and alignment requirements for loads and stores for large systems.
|
||||
lrcpc, // Load-acquire Release Consistency processor consistent (RCpc) instructions.
|
||||
lrcpc2, // Load-acquire Release Consistency processor consistent (RCpc) instructions version 2.
|
||||
|
||||
aes,
|
||||
pmull,
|
||||
sha1,
|
||||
sha256,
|
||||
sha512,
|
||||
sha3,
|
||||
|
||||
sb, // Barrier instruction to control speculation.
|
||||
ssbs, // Instructions to control speculation of loads and stores.
|
||||
}
|
||||
|
||||
CPU_Features :: distinct bit_set[CPU_Feature; u64]
|
||||
|
||||
cpu_features: Maybe(CPU_Features)
|
||||
cpu_name: Maybe(string)
|
||||
|
||||
@(private)
|
||||
_cpu_name_buf: [72]u8
|
||||
cpu_name_buf: [128]byte
|
||||
|
||||
@(init, private)
|
||||
init_cpu_name :: proc "c" () {
|
||||
when ODIN_ARCH == .arm32 {
|
||||
copy(_cpu_name_buf[:], "ARM")
|
||||
cpu_name = string(_cpu_name_buf[:3])
|
||||
init_cpu_name :: proc "contextless" () {
|
||||
when ODIN_ARCH == .arm64 {
|
||||
copy(cpu_name_buf[:], "ARM64")
|
||||
cpu_name = string(cpu_name_buf[:len("ARM64")])
|
||||
} else {
|
||||
copy(_cpu_name_buf[:], "ARM64")
|
||||
cpu_name = string(_cpu_name_buf[:5])
|
||||
copy(cpu_name_buf[:], "ARM")
|
||||
cpu_name = string(cpu_name_buf[:len("ARM")])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user