Skip to content

Commit bff009e

Browse files
authored
Merge pull request #23 from pthariensflame/arm32-support
Add Arm AArch32 support
2 parents 35cdee3 + e567d20 commit bff009e

File tree

8 files changed

+203
-215
lines changed

8 files changed

+203
-215
lines changed

src/Random123.jl

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ else
4949
false
5050
end
5151

52-
"True when AArch64 FEAT_AES instructions have been detected."
53-
const R123_USE_AARCH64_FEAT_AES::Bool = if Sys.ARCH :aarch64
52+
"True when Arm AArch64 FEAT_AES instructions have been detected."
53+
const R123_USE_ARM_AARCH64_FEAT_AES::Bool = if Sys.ARCH :aarch64
5454
try
5555
cmd = Base.julia_cmd()
5656
push!(
@@ -72,8 +72,33 @@ else
7272
false
7373
end
7474

75+
"True when Arm AArch32 FEAT_AES instructions have been detected."
76+
const R123_USE_ARM_AARCH32_FEAT_AES::Bool = if Sys.ARCH :aarch64
77+
try
78+
cmd = Base.julia_cmd()
79+
push!(
80+
cmd.exec,
81+
"-e",
82+
"const uint8x16 = NTuple{16, VecElement{UInt8}};" *
83+
"@assert ccall(\"llvm.arm.crypto.aesmc\", " *
84+
"llvmcall, uint8x16, (uint8x16,), " *
85+
"uint8x16((0x4a, 0x68, 0xbd, 0xe1, 0xfe, 0x16, 0x3d, " *
86+
"0xec, 0xde, 0x06, 0x72, 0x86, 0xe3, 0x8c, 0x14, 0xd9))) ≡ " *
87+
"uint8x16((0x70, 0xa7, 0x7b, 0xd2, 0x0c, 0x79, 0xbd, " *
88+
"0xf1, 0x59, 0xc2, 0xad, 0x1a, 0x9f, 0x05, 0x37, 0x0f))",
89+
)
90+
success(cmd)
91+
catch e
92+
false
93+
end
94+
else
95+
false
96+
end
97+
98+
const R123_USE_ARM_FEAT_AES::Bool = R123_USE_ARM_AARCH64_FEAT_AES || R123_USE_ARM_AARCH32_FEAT_AES
99+
75100
"True when AES-acceleration instructions have been detected."
76-
const R123_USE_AESNI::Bool = R123_USE_X86_AES_NI || R123_USE_AARCH64_FEAT_AES
101+
const R123_USE_AESNI::Bool = R123_USE_X86_AES_NI || R123_USE_ARM_FEAT_AES
77102

78103
@static if R123_USE_AESNI
79104
export AESNI1x, AESNI4x, aesni
@@ -86,10 +111,10 @@ end
86111
include("./x86/aesni_common.jl")
87112
include("./x86/aesni.jl")
88113
include("./x86/ars.jl")
89-
elseif R123_USE_AARCH64_FEAT_AES
90-
include("./aarch64/aesni_common.jl")
91-
include("./aarch64/aesni.jl")
92-
include("./aarch64/ars.jl")
114+
elseif R123_USE_ARM_FEAT_AES
115+
include("./arm/aesni_common.jl")
116+
include("./arm/aesni.jl")
117+
include("./arm/ars.jl")
93118
end
94119

95120
end

src/aarch64/aesni_common.jl

Lines changed: 0 additions & 205 deletions
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)