Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
e09039c0
T
Third Party Openssl
项目概览
OpenHarmony
/
Third Party Openssl
12 个月 前同步成功
通知
8
Star
18
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Openssl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e09039c0
编写于
7月 15, 2012
作者:
A
Andy Polyakov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sha256-armv4.pl: 4% performance improvement.
上级
da3bd277
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
87 addition
and
62 deletion
+87
-62
crypto/sha/asm/sha256-armv4.pl
crypto/sha/asm/sha256-armv4.pl
+87
-62
未找到文件。
crypto/sha/asm/sha256-armv4.pl
浏览文件 @
e09039c0
...
@@ -21,15 +21,15 @@
...
@@ -21,15 +21,15 @@
# February 2011.
# February 2011.
#
#
# Profiler-assisted and platform-specific optimization resulted in 16%
# Profiler-assisted and platform-specific optimization resulted in 16%
# improvement on Cortex A8 core and ~1
7
cycles per processed byte.
# improvement on Cortex A8 core and ~1
6.4
cycles per processed byte.
while
((
$output
=
shift
)
&&
(
$output
!~
/^\w[\w\-]*\.\w+$/
))
{}
while
((
$output
=
shift
)
&&
(
$output
!~
/^\w[\w\-]*\.\w+$/
))
{}
open
STDOUT
,"
>
$output
";
open
STDOUT
,"
>
$output
";
$ctx
=
"
r0
";
$t0
=
"
r0
";
$ctx
=
"
r0
";
$t0
=
"
r0
";
$inp
=
"
r1
";
$t
3
=
"
r1
";
$inp
=
"
r1
";
$t
4
=
"
r1
";
$len
=
"
r2
";
$t1
=
"
r2
";
$len
=
"
r2
";
$t1
=
"
r2
";
$T1
=
"
r3
";
$T1
=
"
r3
";
$t3
=
"
r3
";
$A
=
"
r4
";
$A
=
"
r4
";
$B
=
"
r5
";
$B
=
"
r5
";
$C
=
"
r6
";
$C
=
"
r6
";
...
@@ -52,71 +52,90 @@ my ($i,$a,$b,$c,$d,$e,$f,$g,$h) = @_;
...
@@ -52,71 +52,90 @@ my ($i,$a,$b,$c,$d,$e,$f,$g,$h) = @_;
$code
.=<<
___
if
(
$i
<
16
);
$code
.=<<
___
if
(
$i
<
16
);
#if __ARM_ARCH__>=7
#if __ARM_ARCH__>=7
ldr
$T1
,[
$inp
],
#4
@
ldr
$t1
,[
$inp
],
#4 @ $i
# if $i==15
str
$inp
,[
sp
,
#17*4] @ make room for $t4
# endif
mov
$t0
,
$e
,
ror
#$Sigma1[0]
add
$a
,
$a
,
$t2
@
h
+=
Maj
(
a
,
b
,
c
)
from
the
past
rev
$t1
,
$t1
eor
$t0
,
$t0
,
$e
,
ror
#$Sigma1[1]
#else
#else
ldrb
$T1
,[
$inp
,
#3] @ $i
@
ldrb
$t1
,[
$inp
,
#3] @ $i
add
$a
,
$a
,
$t2
@
h
+=
Maj
(
a
,
b
,
c
)
from
the
past
ldrb
$t2
,[
$inp
,
#2]
ldrb
$t2
,[
$inp
,
#2]
ldrb
$t1
,[
$inp
,
#1]
ldrb
$t0
,[
$inp
,
#1]
ldrb
$t0
,[
$inp
],
#4
orr
$t1
,
$t1
,
$t2
,
lsl
#8
orr
$T1
,
$T1
,
$t2
,
lsl
#8
ldrb
$t2
,[
$inp
],
#4
orr
$T1
,
$T1
,
$t1
,
lsl
#16
orr
$t1
,
$t1
,
$t0
,
lsl
#16
orr
$T1
,
$T1
,
$t0
,
lsl
#24
# if $i==15
str
$inp
,[
sp
,
#17*4] @ make room for $t4
# endif
mov
$t0
,
$e
,
ror
#$Sigma1[0]
orr
$t1
,
$t1
,
$t2
,
lsl
#24
eor
$t0
,
$t0
,
$e
,
ror
#$Sigma1[1]
#endif
#endif
___
___
$code
.=
<<___;
$code
.=
<<___;
mov $t0,$e,ror#$Sigma1[0]
ldr $t2,[$Ktbl],#4 @ *K256++
ldr $t2,[$Ktbl],#4 @ *K256++
eor $t0,$t0,$e,ror#$Sigma1[1]
add $h,$h,$t1 @ h+=X[i]
str $t1,[sp,#`$i%16`*4]
eor $t1,$f,$g
eor $t1,$f,$g
#if $i>=16
add $T1,$T1,$t3 @ from BODY_16_xx
#elif __ARM_ARCH__>=7 && defined(__ARMEL__)
rev $T1,$T1
#endif
#if $i==15
str $inp,[sp,#17*4] @ leave room for $t3
#endif
eor $t0,$t0,$e,ror#$Sigma1[2] @ Sigma1(e)
eor $t0,$t0,$e,ror#$Sigma1[2] @ Sigma1(e)
and $t1,$t1,$e
and $t1,$t1,$e
str $T1,[sp,#`$i%16`*4]
add $h,$h,$t0 @ h+=Sigma1(e)
add $T1,$T1,$t0
eor $t1,$t1,$g @ Ch(e,f,g)
eor $t1,$t1,$g @ Ch(e,f,g)
add $T1,$T1,$h
add $h,$h,$t2 @ h+=K256[i]
mov $h,$a,ror#$Sigma0[0]
mov $t0,$a,ror#$Sigma0[0]
add $T1,$T1,$t1
add $h,$h,$t1 @ h+=Ch(e,f,g)
eor $h,$h,$a,ror#$Sigma0[1]
#if $i==31
add $T1,$T1,$t2
and $t2,$t2,#0xff
eor $h,$h,$a,ror#$Sigma0[2] @ Sigma0(a)
cmp $t2,#0xf2 @ done?
#if $i>=15
ldr $t3,[sp,#`($i+2)%16`*4] @ from BODY_16_xx
#endif
#endif
orr $t0,$a,$b
#if $i<15
and $t1,$a,$b
# if __ARM_ARCH__>=7
and $t0,$t0,$c
ldr $t1,[$inp],#4 @ prefetch
add $h,$h,$T1
# else
orr $t0,$t0,$t1 @ Maj(a,b,c)
ldrb $t1,[$inp,#3]
add $d,$d,$T1
# endif
add $h,$h,$t0
eor $t2,$a,$b @ a^b, b^c in next round
#else
ldr $t1,[sp,#`($i+2)%16`*4] @ from future BODY_16_xx
eor $t2,$a,$b @ a^b, b^c in next round
ldr $t4,[sp,#`($i+15)%16`*4] @ from future BODY_16_xx
#endif
eor $t0,$a,ror#$Sigma0[1]
and $t3,$t3,$t2 @ (b^c)&=(a^b)
add $d,$d,$h @ d+=h
eor $t0,$a,ror#$Sigma0[2] @ Sigma0(a)
eor $t3,$t3,$b @ Maj(a,b,c)
add $h,$h,$t0 @ h+=Sigma0(a)
@ add $h,$h,$t3 @ h+=Maj(a,b,c)
___
___
(
$t2
,
$t3
)
=
(
$t3
,
$t2
);
}
}
sub
BODY_16_XX
{
sub
BODY_16_XX
{
my
(
$i
,
$a
,
$b
,
$c
,
$d
,
$e
,
$f
,
$g
,
$h
)
=
@_
;
my
(
$i
,
$a
,
$b
,
$c
,
$d
,
$e
,
$f
,
$g
,
$h
)
=
@_
;
$code
.=
<<___;
$code
.=
<<___;
@ ldr $t3,[sp,#`($i+1)%16`*4] @ $i
@ ldr $t1,[sp,#`($i+1)%16`*4] @ $i
ldr $t2,[sp,#`($i+14)%16`*4]
@ ldr $t4,[sp,#`($i+14)%16`*4]
mov $t0,$t3,ror#$sigma0[0]
mov $t0,$t1,ror#$sigma0[0]
ldr $T1,[sp,#`($i+0)%16`*4]
add $a,$a,$t2 @ h+=Maj(a,b,c) from the past
eor $t0,$t0,$t3,ror#$sigma0[1]
mov $t2,$t4,ror#$sigma1[0]
ldr $t1,[sp,#`($i+9)%16`*4]
eor $t0,$t0,$t1,ror#$sigma0[1]
eor $t0,$t0,$t3,lsr#$sigma0[2] @ sigma0(X[i+1])
eor $t2,$t2,$t4,ror#$sigma1[1]
mov $t3,$t2,ror#$sigma1[0]
eor $t0,$t0,$t1,lsr#$sigma0[2] @ sigma0(X[i+1])
add $T1,$T1,$t0
ldr $t1,[sp,#`($i+0)%16`*4]
eor $t3,$t3,$t2,ror#$sigma1[1]
eor $t2,$t2,$t4,lsr#$sigma1[2] @ sigma1(X[i+14])
add $T1,$T1,$t1
ldr $t4,[sp,#`($i+9)%16`*4]
eor $t3,$t3,$t2,lsr#$sigma1[2] @ sigma1(X[i+14])
@ add $T1,$T1,$t3
add $t2,$t2,$t0
mov $t0,$e,ror#$Sigma1[0] @ from BODY_00_15
add $t1,$t1,$t2
eor $t0,$t0,$e,ror#$Sigma1[1] @ from BODY_00_15
add $t1,$t1,$t4 @ X[i]
___
___
&BODY_00_15
(
@
_
);
&BODY_00_15
(
@
_
);
}
}
...
@@ -158,35 +177,41 @@ sha256_block_data_order:
...
@@ -158,35 +177,41 @@ sha256_block_data_order:
sub $Ktbl,r3,#256 @ K256
sub $Ktbl,r3,#256 @ K256
sub sp,sp,#16*4 @ alloca(X[16])
sub sp,sp,#16*4 @ alloca(X[16])
.Loop:
.Loop:
# if __ARM_ARCH__>=7
ldr $t1,[$inp],#4
# else
ldrb $t1,[$inp,#3]
# endif
eor $t3,$B,$C @ magic
eor $t2,$t2,$t2
___
___
for
(
$i
=
0
;
$i
<
16
;
$i
++
)
{
&BODY_00_15
(
$i
,
@V
);
unshift
(
@V
,
pop
(
@V
));
}
for
(
$i
=
0
;
$i
<
16
;
$i
++
)
{
&BODY_00_15
(
$i
,
@V
);
unshift
(
@V
,
pop
(
@V
));
}
$code
.=
"
.Lrounds_16_xx:
\n
";
$code
.=
"
.Lrounds_16_xx:
\n
";
for
(;
$i
<
32
;
$i
++
)
{
&BODY_16_XX
(
$i
,
@V
);
unshift
(
@V
,
pop
(
@V
));
}
for
(;
$i
<
32
;
$i
++
)
{
&BODY_16_XX
(
$i
,
@V
);
unshift
(
@V
,
pop
(
@V
));
}
$code
.=
<<___;
$code
.=
<<___;
and $t2,$t2,#0xff
ldreq $t3,[sp,#16*4] @ pull ctx
cmp $t2,#0xf2
bne .Lrounds_16_xx
bne .Lrounds_16_xx
ldr $T1,[sp,#16*4] @ pull ctx
add $A,$A,$t2 @ h+=Maj(a,b,c) from the past
ldr $t0,[$
T1
,#0]
ldr $t0,[$
t3
,#0]
ldr $t1,[$
T1
,#4]
ldr $t1,[$
t3
,#4]
ldr $t2,[$
T1
,#8]
ldr $t2,[$
t3
,#8]
add $A,$A,$t0
add $A,$A,$t0
ldr $t0,[$
T1
,#12]
ldr $t0,[$
t3
,#12]
add $B,$B,$t1
add $B,$B,$t1
ldr $t1,[$
T1
,#16]
ldr $t1,[$
t3
,#16]
add $C,$C,$t2
add $C,$C,$t2
ldr $t2,[$
T1
,#20]
ldr $t2,[$
t3
,#20]
add $D,$D,$t0
add $D,$D,$t0
ldr $t0,[$
T1
,#24]
ldr $t0,[$
t3
,#24]
add $E,$E,$t1
add $E,$E,$t1
ldr $t1,[$
T1
,#28]
ldr $t1,[$
t3
,#28]
add $F,$F,$t2
add $F,$F,$t2
ldr $inp,[sp,#17*4] @ pull inp
ldr $inp,[sp,#17*4] @ pull inp
ldr $t2,[sp,#18*4] @ pull inp+len
ldr $t2,[sp,#18*4] @ pull inp+len
add $G,$G,$t0
add $G,$G,$t0
add $H,$H,$t1
add $H,$H,$t1
stmia $
T1
,{$A,$B,$C,$D,$E,$F,$G,$H}
stmia $
t3
,{$A,$B,$C,$D,$E,$F,$G,$H}
cmp $inp,$t2
cmp $inp,$t2
sub $Ktbl,$Ktbl,#256 @ rewind Ktbl
sub $Ktbl,$Ktbl,#256 @ rewind Ktbl
bne .Loop
bne .Loop
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录