Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0f1180f

Browse filesBrowse files
committed
migrate avo to asm module
1 parent 6f02425 commit 0f1180f
Copy full SHA for 0f1180f

File tree

Expand file treeCollapse file tree

7 files changed

+38
-36
lines changed
Filter options
Expand file treeCollapse file tree

7 files changed

+38
-36
lines changed

‎sha1cdblock_amd64_asm.go renamed to ‎asm/asm.go

Copy file name to clipboardExpand all lines: asm/asm.go
+17-12Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
1-
//go:build ignore
2-
// +build ignore
3-
41
package main
52

63
import (
74
. "github.com/mmcloughlin/avo/build"
85
"github.com/mmcloughlin/avo/buildtags"
96
. "github.com/mmcloughlin/avo/operand"
107
. "github.com/mmcloughlin/avo/reg"
11-
shared "github.com/pjbgf/sha1cd/internal"
128
)
139

14-
//go:generate go run sha1cdblock_amd64_asm.go -out sha1cdblock_amd64.s
10+
const (
11+
// Constants for the SHA-1 hash function.
12+
RoundConst0 = 0x5A827999
13+
RoundConst1 = 0x6ED9EBA1
14+
RoundConst2 = 0x8F1BBCDC
15+
RoundConst3 = 0xCA62C1D6
16+
17+
// SHA1 processes the input data in chunks. Each chunk contains 64 bytes.
18+
Chunk = 64
19+
)
1520

1621
func main() {
1722
Constraint(buildtags.Not("noasm").ToConstraint())
@@ -61,7 +66,7 @@ func main() {
6166
}
6267

6368
// Store message values on the stack.
64-
w := AllocLocal(shared.Chunk)
69+
w := AllocLocal(Chunk)
6570
W := func(r int) Mem { return w.Offset((r % 16) * 4) }
6671

6772
Comment("len(p) >= chunk")
@@ -161,39 +166,39 @@ func main() {
161166
Commentf("ROUND1(%d)", index)
162167
LOAD(index)
163168
FUNC1(a, b, c, d, e)
164-
MIX(a, b, c, d, e, shared.K0)
169+
MIX(a, b, c, d, e, RoundConst0)
165170
LOADM1(index)
166171
}
167172

168173
ROUND1x := func(a, b, c, d, e GPVirtual, index int) {
169174
Commentf("ROUND1x(%d)", index)
170175
SHUFFLE(index)
171176
FUNC1(a, b, c, d, e)
172-
MIX(a, b, c, d, e, shared.K0)
177+
MIX(a, b, c, d, e, RoundConst0)
173178
LOADM1(index)
174179
}
175180

176181
ROUND2 := func(a, b, c, d, e GPVirtual, index int) {
177182
Commentf("ROUND2(%d)", index)
178183
SHUFFLE(index)
179184
FUNC2(a, b, c, d, e)
180-
MIX(a, b, c, d, e, shared.K1)
185+
MIX(a, b, c, d, e, RoundConst1)
181186
LOADM1(index)
182187
}
183188

184189
ROUND3 := func(a, b, c, d, e GPVirtual, index int) {
185190
Commentf("ROUND3(%d)", index)
186191
SHUFFLE(index)
187192
FUNC3(a, b, c, d, e)
188-
MIX(a, b, c, d, e, shared.K2)
193+
MIX(a, b, c, d, e, RoundConst2)
189194
LOADM1(index)
190195
}
191196

192197
ROUND4 := func(a, b, c, d, e GPVirtual, index int) {
193198
Commentf("ROUND4(%d)", index)
194199
SHUFFLE(index)
195200
FUNC4(a, b, c, d, e)
196-
MIX(a, b, c, d, e, shared.K3)
201+
MIX(a, b, c, d, e, RoundConst3)
197202
LOADM1(index)
198203
}
199204

@@ -297,7 +302,7 @@ func main() {
297302
ADDL(r, hash[i])
298303
}
299304

300-
ADDQ(I8(shared.Chunk), p_base)
305+
ADDQ(I8(Chunk), p_base)
301306
CMPQ(p_base, di64)
302307
JB(LabelRef("loop"))
303308

‎asm/go.mod

Copy file name to clipboard
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module github.com/pjbgf/sha1cd/asm
2+
3+
go 1.23.4
4+
5+
require github.com/mmcloughlin/avo v0.6.0
6+
7+
require (
8+
golang.org/x/mod v0.14.0 // indirect
9+
golang.org/x/tools v0.16.1 // indirect
10+
)

‎asm/go.sum

Copy file name to clipboard
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
github.com/mmcloughlin/avo v0.6.0 h1:QH6FU8SKoTLaVs80GA8TJuLNkUYl4VokHKlPhVDg4YY=
2+
github.com/mmcloughlin/avo v0.6.0/go.mod h1:8CoAGaCSYXtCPR+8y18Y9aB/kxb8JSS6FRI7mSkvD+8=
3+
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
4+
golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
5+
golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
6+
golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
7+
golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA=
8+
golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0=

‎go.mod

Copy file name to clipboard
-8Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
11
module github.com/pjbgf/sha1cd
22

33
go 1.21
4-
5-
require github.com/mmcloughlin/avo v0.6.0
6-
7-
require (
8-
golang.org/x/mod v0.17.0 // indirect
9-
golang.org/x/sync v0.7.0 // indirect
10-
golang.org/x/tools v0.20.0 // indirect
11-
)

‎go.sum

Copy file name to clipboard
-13Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +0,0 @@
1-
github.com/mmcloughlin/avo v0.6.0 h1:QH6FU8SKoTLaVs80GA8TJuLNkUYl4VokHKlPhVDg4YY=
2-
github.com/mmcloughlin/avo v0.6.0/go.mod h1:8CoAGaCSYXtCPR+8y18Y9aB/kxb8JSS6FRI7mSkvD+8=
3-
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
4-
golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
5-
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
6-
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
7-
golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
8-
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
9-
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
10-
golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA=
11-
golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0=
12-
golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY=
13-
golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg=

‎sha1cd.go

Copy file name to clipboardExpand all lines: sha1cd.go
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ import (
1717
"errors"
1818
"hash"
1919

20-
_ "github.com/mmcloughlin/avo/build"
2120
shared "github.com/pjbgf/sha1cd/internal"
2221
)
2322

23+
//go:generate go run -modfile=asm/go.mod asm/asm.go -out sha1cdblock_amd64.s -pkg $PKG
24+
2425
func init() {
2526
crypto.RegisterHash(crypto.SHA1, New)
2627
}

‎sha1cdblock_amd64.s

Copy file name to clipboardExpand all lines: sha1cdblock_amd64.s
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
// Code generated by command: go run sha1cdblock_amd64_asm.go -out sha1cdblock_amd64.s. DO NOT EDIT.
1+
// Code generated by command: go run asm.go -out sha1cdblock_amd64.s -pkg . DO NOT EDIT.
22

33
//go:build !noasm && gc && amd64
4-
// +build !noasm,gc,amd64
54

65
#include "textflag.h"
76

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.