Skip to content

Commit c79b97a

Browse files
authored
Merge pull request #667 from pq-code-package/asm_no_consts
AArch64: Remove literal pools from native code
2 parents e4ff720 + 7d15fdb commit c79b97a

File tree

9 files changed

+141
-278
lines changed

9 files changed

+141
-278
lines changed

mlkem/native/aarch64/src/intt_clean.S

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149

150150
inp .req x3
151151
count .req x4
152-
xtmp .req x5
152+
wtmp .req w5
153153

154154
data0 .req v8
155155
data1 .req v9
@@ -193,40 +193,20 @@
193193
t3 .req v28
194194

195195
ninv .req v29
196-
q_ninv .req q29
197196
ninv_tw .req v30
198-
q_ninv_tw .req q30
199-
200-
/* Literal pool */
201-
.macro dup8h c
202-
.short \c
203-
.short \c
204-
.short \c
205-
.short \c
206-
.short \c
207-
.short \c
208-
.short \c
209-
.short \c
210-
.endm
211-
212-
.p2align 4
213-
c_consts: .short 3329
214-
.short 20159
215-
.short 0
216-
.short 0
217-
.short 0
218-
.short 0
219-
.short 0
220-
.short 0
221-
c_ninv: dup8h 512
222-
c_ninv_tw: dup8h 5040
223197

224198
MLKEM_ASM_NAMESPACE(intt_asm_clean):
225199
push_stack
226200

227-
ldr q_consts, c_consts
228-
ldr q_ninv, c_ninv
229-
ldr q_ninv_tw, c_ninv_tw
201+
// Setup constants
202+
mov wtmp, #3329
203+
mov consts.h[0], wtmp
204+
mov wtmp, #20159
205+
mov consts.h[1], wtmp
206+
mov wtmp, #512
207+
dup ninv.8h, wtmp
208+
mov wtmp, #5040
209+
dup ninv_tw.8h, wtmp
230210

231211
mov inp, in
232212
mov count, #8
@@ -367,7 +347,7 @@ layer012_start:
367347
.unreq r56_ptr
368348
.unreq inp
369349
.unreq count
370-
.unreq xtmp
350+
.unreq wtmp
371351
.unreq data0
372352
.unreq data1
373353
.unreq data2
@@ -404,8 +384,6 @@ layer012_start:
404384
.unreq t2
405385
.unreq t3
406386
.unreq ninv
407-
.unreq q_ninv
408387
.unreq ninv_tw
409-
.unreq q_ninv_tw
410388

411389
#endif /* MLKEM_NATIVE_ARITH_BACKEND_AARCH64_CLEAN */

mlkem/native/aarch64/src/intt_opt.S

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149

150150
inp .req x3
151151
count .req x4
152-
xtmp .req x5
152+
wtmp .req w5
153153

154154
data0 .req v8
155155
data1 .req v9
@@ -193,40 +193,20 @@
193193
t3 .req v28
194194

195195
ninv .req v29
196-
q_ninv .req q29
197196
ninv_tw .req v30
198-
q_ninv_tw .req q30
199-
200-
/* Literal pool */
201-
.macro dup8h c
202-
.short \c
203-
.short \c
204-
.short \c
205-
.short \c
206-
.short \c
207-
.short \c
208-
.short \c
209-
.short \c
210-
.endm
211-
212-
.p2align 4
213-
c_consts: .short 3329
214-
.short 20159
215-
.short 0
216-
.short 0
217-
.short 0
218-
.short 0
219-
.short 0
220-
.short 0
221-
c_ninv: dup8h 512
222-
c_ninv_tw: dup8h 5040
223197

224198
MLKEM_ASM_NAMESPACE(intt_asm_opt):
225199
push_stack
226200

227-
ldr q_consts, c_consts
228-
ldr q_ninv, c_ninv
229-
ldr q_ninv_tw, c_ninv_tw
201+
// Setup constants
202+
mov wtmp, #3329
203+
mov consts.h[0], wtmp
204+
mov wtmp, #20159
205+
mov consts.h[1], wtmp
206+
mov wtmp, #512
207+
dup ninv.8h, wtmp
208+
mov wtmp, #5040
209+
dup ninv_tw.8h, wtmp
230210

231211
mov inp, in
232212
mov count, #8
@@ -1023,7 +1003,7 @@ layer012_start:
10231003
.unreq r56_ptr
10241004
.unreq inp
10251005
.unreq count
1026-
.unreq xtmp
1006+
.unreq wtmp
10271007
.unreq data0
10281008
.unreq data1
10291009
.unreq data2
@@ -1060,8 +1040,6 @@ layer012_start:
10601040
.unreq t2
10611041
.unreq t3
10621042
.unreq ninv
1063-
.unreq q_ninv
10641043
.unreq ninv_tw
1065-
.unreq q_ninv_tw
10661044

10671045
#endif /* MLKEM_NATIVE_ARITH_BACKEND_AARCH64_OPT */

mlkem/native/aarch64/src/ntt_clean.S

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121

122122
inp .req x3
123123
count .req x4
124-
xtmp .req x5
124+
wtmp .req w5
125125

126126
data0 .req v8
127127
data1 .req v9
@@ -156,7 +156,6 @@
156156
q_root2_tw .req q6
157157

158158
consts .req v7
159-
q_consts .req q7
160159

161160
tmp .req v24
162161
t0 .req v25
@@ -167,21 +166,13 @@
167166
.text
168167
.global MLKEM_ASM_NAMESPACE(ntt_asm_clean)
169168

170-
/* Literal pool */
171-
.p2align 4
172-
c_consts:
173-
.short 3329
174-
.short 20159
175-
.short 0
176-
.short 0
177-
.short 0
178-
.short 0
179-
.short 0
180-
.short 0
181-
182169
MLKEM_ASM_NAMESPACE(ntt_asm_clean):
183170
push_stack
184-
ldr q_consts, c_consts
171+
172+
mov wtmp, #3329
173+
mov consts.h[0], wtmp
174+
mov wtmp, #20159
175+
mov consts.h[1], wtmp
185176

186177
mov inp, in
187178
mov count, #4
@@ -286,7 +277,7 @@ layer3456_start:
286277
.unreq r56_ptr
287278
.unreq inp
288279
.unreq count
289-
.unreq xtmp
280+
.unreq wtmp
290281
.unreq data0
291282
.unreq data1
292283
.unreq data2
@@ -316,7 +307,6 @@ layer3456_start:
316307
.unreq q_root1_tw
317308
.unreq q_root2_tw
318309
.unreq consts
319-
.unreq q_consts
320310
.unreq tmp
321311
.unreq t0
322312
.unreq t1

mlkem/native/aarch64/src/ntt_opt.S

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121

122122
inp .req x3
123123
count .req x4
124-
xtmp .req x5
124+
wtmp .req w5
125125

126126
data0 .req v8
127127
data1 .req v9
@@ -167,21 +167,13 @@
167167
.text
168168
.global MLKEM_ASM_NAMESPACE(ntt_asm_opt)
169169

170-
/* Literal pool */
171-
.p2align 4
172-
c_consts:
173-
.short 3329
174-
.short 20159
175-
.short 0
176-
.short 0
177-
.short 0
178-
.short 0
179-
.short 0
180-
.short 0
181-
182170
MLKEM_ASM_NAMESPACE(ntt_asm_opt):
183171
push_stack
184-
ldr q_consts, c_consts
172+
173+
mov wtmp, #3329
174+
mov consts.h[0], wtmp
175+
mov wtmp, #20159
176+
mov consts.h[1], wtmp
185177

186178
mov inp, in
187179
mov count, #4
@@ -922,7 +914,7 @@ MLKEM_ASM_NAMESPACE(ntt_asm_opt):
922914
.unreq r56_ptr
923915
.unreq inp
924916
.unreq count
925-
.unreq xtmp
917+
.unreq wtmp
926918
.unreq data0
927919
.unreq data1
928920
.unreq data2

0 commit comments

Comments
 (0)