-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinst-vfpu-desc.yaml
2246 lines (2047 loc) · 69.2 KB
/
inst-vfpu-desc.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# This file was written by David Guillen Fandos <[email protected]>
#
# The contents are released into the public domain without any license.
# I wave all copyright and related rights to the extent allowed by law.
# You are free to copy, modify, distribute, and perform the work, even for
# commercial purposes, without asking for permission.
#
# I would really appreciate if you kept this header though :)
# Instruction prefixes types: s/t/d (for rs, rt and rd operands)
# Prefix "S" has a special meaning: rs prefixing is allowed but only for swizzle operations
# Prefix "D" has a special meaning: rd prefixing is allowed but only for masking operations
# Possible instruction operands
instruction-operands:
# No input/ouput instructions
vfpu-static:
syntax: "%opcode"
# Prefix operations
vfpu-prefix:
syntax: "%opcode imm24"
# Memory instructions
vfpu-load4:
syntax: "%opcode rd, imm14(rt)"
outputs:
rd: single
vfpu-load16:
syntax: "%opcode rd, imm14(rt)"
outputs:
rd: vector
vfpu-store4:
syntax: "%opcode rs, imm14(rt)"
inputs:
rd: single
vfpu-store16:
syntax: "%opcode rs, imm14(rt)"
inputs:
rd: vector
# Vector-related insts
vector-binary: # An instruction with two arguments: rs and rt, both vectors
syntax: "%opcode rd, rs, rt"
inputs:
rs: vector
rt: vector
outputs:
rd: vector
vfpu-compare:
syntax: "%opcode cond, rs, rt"
inputs:
rs: vector
rt: vector
outputs:
vfpu_cc: vfpucc
immediates:
cond:
minval: 0
maxval: 15
vector-binary-reduce: # Same as above but produces a single value as result
syntax: "%opcode rd, rs, rt"
inputs:
rs: vector
rt: vector
outputs:
rd: single
vector-binary-scale: # Second input is an scalar number instead of a vector
syntax: "%opcode rd, rs, rt"
inputs:
rs: vector
rt: single
outputs:
rd: vector
vector-unary: # An instruction with just an input: rs
syntax: "%opcode rd, rs"
inputs:
rs: vector
outputs:
rd: vector
vector-unary-reduce: # Same as above but result is a single value
syntax: "%opcode rd, rs"
inputs:
rs: vector
outputs:
rd: single
vector-unary-reduce2: # A N to N/2 reduction type (q->p / p->s)
syntax: "%opcode rd, rs"
inputs:
rs: vector
outputs:
rd: vector:H
vector-unary-expand2: # A N to N*2 expansions type (q->p / p->s)
syntax: "%opcode rd, rs"
inputs:
rs: vector
outputs:
rd: vector:D
vector-unary-expand4: # A N to N*4 expansions type (s->q)
syntax: "%opcode rd, rs"
inputs:
rs: vector
outputs:
rd: vector:Q
vector-unary-scale: # Features an extra imm5 field
syntax: "%opcode rd, rs, scale"
inputs:
rs: vector
outputs:
rd: vector
immediates:
imval:
minval: 0
maxval: 31
vector-unary-rot: # rs is always single and has an extra imm5 field
syntax: "%opcode rd, rs, imm5"
inputs:
rs: single
outputs:
rd: vector
immediates:
imval:
minval: 0
maxval: 31
vector-unary-mod: # Features an extra imm8 field
syntax: "%opcode rd, rs, scale"
inputs:
rs: vector
outputs:
rd: vector
immediates:
imval:
minval: 1
maxval: 254
vector-inullary: # An instruction with inputs, no outputs (yeah weird)
syntax: "%opcode rs"
inputs:
rs: vector
vector-nullary: # An instruction with no inputs, just output
syntax: "%opcode rd"
outputs:
rd: vector
vector-nullary-uimm16: # An instruction with a uint16 immediate input
syntax: "%opcode rd, imm16"
immediates:
imval:
minval: 0
maxval: 65535
outputs:
rd: single
vector-nullary-cst: # An instruction with a magic constant as immediate field
syntax: "%opcode rd, imm5"
immediates:
imval:
minval: 1
maxval: 19
outputs:
rd: vector
# Matrix related functions
matrix-binary: # An instruction with two arguments: rs and rt, both matrices
syntax: "%opcode rd, rs, rt"
inputs:
rs: matrix
rt: matrix
outputs:
rd: matrix
matrix-binary-scale: # Second input is an scalar number instead of a matrix
syntax: "%opcode rd, rs, rt"
inputs:
rs: matrix
rt: single
outputs:
rd: matrix
matrix-unary: # An instruction with one arguments, rs, which is a matrix
syntax: "%opcode rd, rs"
inputs:
rs: matrix
outputs:
rd: matrix
matrix-nullary: # An instruction with no inputs, just output (matrix)
syntax: "%opcode rd"
outputs:
rd: matrix
# Mixed instructions (vec-mat)
vector-matrix-transform:
syntax: "%opcode rd, rs, rt"
inputs:
rs: matrix
rt: vector
outputs:
rd: vector
# VFPU Conditional move
vfpu-condmove:
syntax: "%opcode rd, rs, imm3"
inputs:
rs: vector
vfpu_cc: vfpucc
outputs:
rd: vector
immediates:
cc:
minval: 0
maxval: 6
# Branch instructions
vfpu-branch: # An VFPU-CC branch instruction
syntax: "%opcode imm3, offset"
inputs:
imm3: immediate
offset: immediate
# VFPU control access
vfpu-control-gpr:
syntax: "%opcode rt, imm8"
immediates:
regn:
minval: 128
maxval: 143
vfpu-control-read:
syntax: "%opcode rd, imm8"
immediates:
regn:
minval: 128
maxval: 143
vfpu-control-write:
syntax: "%opcode imm8, rs"
immediates:
regn:
minval: 128
maxval: 143
# Instruction encodings described as follows:
encodings:
vfpu-fixedop:
# A control instruction (it's a full 32 bit opcode)
encoding: "oooooooooooooooooooooooooooooooo"
fields:
o: opcode
vfpu-prefix:
# A prefix setting instruction
encoding: "ooooooppiiiiiiiiiiiiiiiiiiiiiiii"
fields:
o: opcode # 6 bit opcode
p: ptype # 2 bit prefix type
i: imm24 # 24 bit prefix operation
vfpu-memory:
# A load/store instruction that loads/stores one element
encoding: "oooooossssstttttiiiiiiiiiiiiiirr"
fields:
o: opcode # 6 bit opcode
s: gpr # GPR register (base address)
t: rtlo # rt input/output VFPU register (5 LSB)
r: rthi # rt input/output VFPU register (2 MSB)
i: offset # 14 bit address offset
vfpu-memory-quad:
# A load/store instruction that loads/stores a quad vector
# Only register numbers in the 0-63 range allowed (due to quad size)
encoding: "oooooossssstttttiiiiiiiiiiiiiipr"
fields:
o: opcode # 6 bit opcode
s: gpr # GPR register (base address)
t: rtlo # rt input/output VFPU register (5 LSB)
r: rthi # rt input/output VFPU register (bit #5)
i: offset # 14 bit address offset
p: partop # Indicates left(0) or right(1)
vfpu-alu:
# A regular VFPU ALU instruction, with two, one or no inputs and one output register.
# Operands can be elements, vectors or matrices, and two bits encode their size.
encoding: "oooooooootttttttisssssssjddddddd"
fields:
o: opcode # 9 bit (6 + 3) opcode
t: rt # rt input register
s: rs # rs input register
d: rd # rd output register
i: sizehi # 1 for t/q flavors
j: sizelo # 1 for p/q flavors
vfpu-alu-m1:
# Same as above but size is encoded differently (p/t/q -> 0/1/2)
encoding: "oooooooootttttttisssssssjddddddd"
fields:
o: opcode # 9 bit (6 + 3) opcode
t: rt # rt input register
s: rs # rs input register
d: rd # rd output register
i: sizehi-m1 # 1 for q flavor
j: sizelo-m1 # 1 for t flavor
vfpu-alu-compare:
# An almost regular VFPU ALU instruction, but writes to an implicit control reg.
# Has a 4 bit encoded immediate where destination register usually lives.
encoding: "oooooooootttttttisssssssj000cccc"
fields:
o: opcode # 9 bit (6 + 3) opcode
t: rt # rt input register
s: rs # rs input register
c: cond # condition immediate
i: sizehi # 1 for t/q flavors
j: sizelo # 1 for p/q flavors
vector-imm5:
# A one source one destination VFPU ALU instruction with a 5 bit immediate.
encoding: "oooooooooppmmmmmisssssssjddddddd"
fields:
o: opcode # 9 bit (6 + 3) opcode
p: opcode2 # 2 bit sub-opcode
m: imval # 5 bit immediate
s: rs # rs input register
d: rd # rd output register
i: sizehi # 1 for t/q flavors
j: sizelo # 1 for p/q flavors
vector-imm8:
# A one source one destination VFPU ALU instruction with a 8 bit immediate.
encoding: "oooooooommmmmmmmisssssssjddddddd"
fields:
o: opcode # 8 bit (6 + 2) opcode
m: imval # 8 bit immediate
s: rs # rs input register
d: rd # rd output register
i: sizehi # 1 for t/q flavors
j: sizelo # 1 for p/q flavors
vector-imm16:
# A one source one destination VFPU ALU instruction with a 5 bit immediate.
encoding: "ooooooootdddddddiiiiiiiiiiiiiiii"
fields:
o: opcode # 8 bit (6 + 2) opcode
t: itype # 1 bit constant type (0 int/1 float)
d: rd # rd output register
i: imval # 16 bit constant immediate
vfpu-condmove:
# A conditional move instruction (uses VFPU CC register as input).
encoding: "oooooooooooocrrrisssssssjddddddd"
fields:
o: opcode # 12 bit (6 + 6) opcode
c: rcond # 1 bit (false/true)
r: cc # VFPU CC bit number
s: rs # rs input register
d: rd # rd output register
i: sizehi # 1 for t/q flavors
j: sizelo # 1 for p/q flavors
vfpu-branch:
# A branch instruction that uses the VFPU CC register as input.
encoding: "ooooooooooorrrlvffffffffffffffff"
fields:
o: opcode # 11 bit (6 + 5) opcode
r: vfpucc # VFPU CC bit number
l: likely # likely bit
v: value # value to branch on
f: offset # pc offset (signed)
vfpu-gpr-control:
# An instruction to read/write VFPU CC registers (to/from CPU GPR regs)
encoding: "01001000d11ggggg00000000rrrrrrrr"
fields:
d: direction # 1 bit (1 write, 0 read)
g: gpr # GPR reg number
r: vfpucc # VFPU CC reg number
vfpu-write-control:
# An instruction to write VFPU CC registers (from a vector reg)
encoding: "11010000010100010sssssssrrrrrrrr"
fields:
s: rs # rs input register
r: vfpucc # VFPU CC reg number
vfpu-read-control:
# An instruction to read VFPU CC registers (to a vector reg)
encoding: "1101000001010000rrrrrrrr0ddddddd"
fields:
d: rd # rd output register
r: vfpucc # VFPU CC reg number
# List of instructions defined in the ISA
instructions:
# Control flow instructions (branch)
bvf:
type: vfpu-branch
encoding: vfpu-branch
perf-class: vfpu-branch
title: "VFPU branch on false"
description: "Branch on VFPU CC register being false"
opcode: "01001001000"
likely: 0
value: 0
bvfl:
type: vfpu-branch
encoding: vfpu-branch
perf-class: vfpu-branch
title: "VFPU likely branch on false"
description: "Branch on VFPU CC register being false (likely)"
opcode: "01001001000"
likely: 1
value: 0
bvt:
type: vfpu-branch
encoding: vfpu-branch
perf-class: vfpu-branch
title: "VFPU branch on true"
description: "Branch on VFPU CC register being true"
opcode: "01001001000"
likely: 0
value: 1
bvtl:
type: vfpu-branch
encoding: vfpu-branch
perf-class: vfpu-branch
title: "VFPU likely branch on true"
description: "Branch on VFPU CC register being true (likely)"
opcode: "01001001000"
likely: 1
value: 1
# CC mangling instructions
mtvc:
type: vfpu-control-gpr
encoding: vfpu-gpr-control
title: "Move GPR to VFPU control register"
description: "Writes the contents of a CPU general purpose register to the specified VFPU control register"
direction: 1
mfvc:
type: vfpu-control-gpr
encoding: vfpu-gpr-control
title: "Move VFPU control register to GPR"
description: "Writes the contents of the specified VPFU control register into a CPU general purpose register"
hazard: >
The instruction does not have interlocks, so the result of a vcmp instruction
is only available one cycle later. You will need to interleave at least one VFPU
instruction between a vcmp and mfvc (ie. a vnop).
direction: 0
vmtvc:
type: vfpu-control-write
encoding: vfpu-write-control
title: "Move vector register to VFPU control register"
description: "Writes the contents of a VFPU vector general to the specified VFPU control register"
vmfvc:
type: vfpu-control-read
encoding: vfpu-read-control
title: "Move VFPU control register to vector register"
description: "Writes the contents of the specified VPFU control register into a VFPU vector register"
hazard: >
The instruction does not have interlocks, so the result of a previous vcmp instruction
is only available one cycle later. You will need to interleave at least one VFPU
instruction between a vcmp and mfvc (ie. a vnop).
# Memory instructions
lv.s:
type: vfpu-load4
encoding: vfpu-memory
title: "Load VFPU element"
description: >
Performs a 4 byte memory load to a VFPU register.
Address must be 4 byte aligned or a fault is generated.
opcode: "110010"
lv.q:
type: vfpu-load16
encoding: vfpu-memory-quad
title: "Load VFPU quad element"
description: >
Performs a 16 byte memory load to a VFPU quad register.
Address must be 16 byte aligned or a fault is generated.
opcode: "110110"
partop: 0
lvl.q:
type: vfpu-load16
encoding: vfpu-memory-quad
title: "Load left VFPU quad element"
description: >
Performs a 16 byte left unaligned memory load to a VFPU quad register.
Instruction ignores the two LSB (forces them to zero), so the address is assumed aligned to 4 bytes.
This instruction is similar to MIPS LWL instruction: loads the most significant elements from the
specified address leaving the other elements unchanged. Users can use `ulv.q` pseudoinstruction
to generate a sequence of `lvl.q` and `lvr.q` instructions in order to load unaligned data.
You can check `psp-tests/manual/memops.c` to see examples on how the instruction behaves.
bugs: >
The instruction has an errata on PSP-1000 models that causes FPU register corruption
(these are the MIPS CPU FPU registers, not the VFPU registers).
The bottom 5 bits of the VFPU destination register determine which FPU register will be corrupted.
A workaround is to assume the side effect (ie. mark the register are clobbered).
opcode: "110101"
partop: 0
lvr.q:
type: vfpu-load16
encoding: vfpu-memory-quad
title: "Load right VFPU quad element"
description: >
Performs a 16 byte right unaligned memory load to a VFPU quad register.
Instruction ignores the two LSB (forces them to zero), so the address is assumed aligned to 4 bytes.
This instruction is similar to MIPS LWR instruction: loads the least significant elements from the
specified address leaving the other elements unchanged. Users can use `ulv.q` pseudoinstruction
to generate a sequence of `lvl.q` and `lvr.q` instructions in order to load unaligned data.
You can check `psp-tests/manual/memops.c` to see examples on how the instruction behaves.
bugs: >
The instruction has an errata on PSP-1000 models that causes FPU register corruption
(these are the MIPS CPU FPU registers, not the VFPU registers).
The bottom 5 bits of the VFPU destination register determine which FPU register will be corrupted.
A workaround is to assume the side effect (ie. mark the register are clobbered).
opcode: "110101"
partop: 1
sv.s:
type: vfpu-store4
encoding: vfpu-memory
title: "Store VFPU element"
description: >
Performs a 4 byte memory store from a VFPU register.
Address must be 4 byte aligned or a fault is generated.
opcode: "111010"
sv.q:
type: vfpu-store16
encoding: vfpu-memory-quad
title: "Store VFPU quad element"
description: >
Performs a 16 byte memory store from a VFPU quad register.
Address must be 16 byte aligned or a fault is generated.
opcode: "111110"
partop: 0
svl.q:
type: vfpu-store16
encoding: vfpu-memory-quad
title: "Store left VFPU quad element"
description: >
Performs a 16 byte left unaligned memory store from a VFPU quad register.
Instruction ignores the two address LSB (forces them to zero), so the address is assumed aligned to 4 bytes.
This instruction is similar to MIPS SWL instruction: stores the most significant part of the elements
to the specified address leaving any other elements unchanged. Users can use `usv.q` pseudoinstruction
to generate a sequence of `svl.q` and `svr.q` instructions in order to store unaligned data.
You can check `psp-tests/manual/memops.c` to see examples on how the instruction behaves.
opcode: "111101"
partop: 0
svr.q:
type: vfpu-store16
encoding: vfpu-memory-quad
title: "Store right VFPU quad element"
description: >
Performs a 16 byte right unaligned memory store from a VFPU quad register.
Instruction ignores the two address LSB (forces them to zero), so the address is assumed aligned to 4 bytes.
This instruction is similar to MIPS SWR instruction: stores the least significant part of the elements
to the specified address leaving any other elements unchanged. Users can use `usv.q` pseudoinstruction
to generate a sequence of `svl.q` and `svr.q` instructions in order to store unaligned data.
You can check `psp-tests/manual/memops.c` to see examples on how the instruction behaves.
opcode: "111101"
partop: 1
# Binary VFPU-vector operations (use rd, rs, rt)
# Encoding is the same for all of them, however rt and rs might be sometimes used as a secondary opcode.
vadd:
type: vector-binary
encoding: vfpu-alu
flavors: sptq
perf-class: arithmetic
title: "Add elements"
description: "Performs element-wise floating point addition"
pcode: "@ rd[{i}] = rs[{i}] + rt[{i}]"
opcode: "011000000"
prefix: std
vsub:
type: vector-binary
encoding: vfpu-alu
flavors: sptq
perf-class: arithmetic
title: "Subtract elements"
description: "Performs element-wise floating point subtraction"
pcode: "@ rd[{i}] = rs[{i}] - rt[{i}]"
opcode: "011000001"
prefix: std
vmul:
type: vector-binary
encoding: vfpu-alu
flavors: sptq
perf-class: arithmetic
title: "Multiply elements"
description: "Performs element-wise floating point multiplication"
pcode: "@ rd[{i}] = rs[{i}] * rt[{i}]"
opcode: "011001000"
prefix: std
vdiv:
type: vector-binary
encoding: vfpu-alu
flavors: sptq
perf-class: division
title: "Divide elements"
description: "Performs element-wise floating point division"
pcode: "@ rd[{i}] = rs[{i}] / rt[{i}]"
opcode: "011000111"
reg-compat: partial-overlap
prefix: s0t0d0
vmin:
type: vector-binary
encoding: vfpu-alu
flavors: sptq
perf-class: arithmetic
title: "Select smallest elements"
description: "Performs element-wise floating point min(rs, rt) operation"
pcode: "@ rd[{i}] = fminf(rs[{i}], rt[{i}])"
opcode: "011011010"
prefix: std
vmax:
type: vector-binary
encoding: vfpu-alu
flavors: sptq
perf-class: arithmetic
title: "Select biggest elements"
description: "Performs element-wise floating point max(rs, rt) operation"
pcode: "@ rd[{i}] = fmaxf(rs[{i}], rt[{i}])"
opcode: "011011011"
prefix: std
vscmp:
type: vector-binary
encoding: vfpu-alu
flavors: sptq
perf-class: arithmetic
title: "Compare and set elements"
description: "Performs element-wise floating point comparison. The result is -1.0f, 0.0f or 1.0f depending on whether the input vs is less that vt, equal, or greater, respectively."
pcode: "@ rd[{i}] = rs[{i}] < rt[{i}] ? -1.0f : rs[{i}] > rt[{i}] ? 1.0f : 0.0f"
opcode: "011011101"
prefix: std
vsge:
type: vector-binary
encoding: vfpu-alu
flavors: sptq
perf-class: arithmetic
title: "Compare greater or equal and set elements"
description: "Performs element-wise floating point bigger-or-equal comparison. The result will be 1.0 if vs is bigger or equal to vt, otherwise will be zero."
pcode: "@ rd[{i}] = rs[{i}] >= rt[{i}] ? 1.0f : 0.0f"
opcode: "011011110"
prefix: std
vslt:
type: vector-binary
encoding: vfpu-alu
flavors: sptq
perf-class: arithmetic
title: "Compare less-than and set elements"
description: "Performs element-wise floating point less-than comparison. The result will be 1.0 if vs less than vt, otherwise will be zero."
pcode: "@ rd[{i}] = rs[{i}] < rt[{i}] ? 1.0f : 0.0f"
opcode: "011011111"
prefix: std
vcrs:
type: vector-binary
encoding: vfpu-alu
flavors: t
perf-class: arithmetic
title: "Partial vector cross product"
description: "Performs a partial cross-product operation"
pcode: "rd[0] = rs[1] * rt[2]; rd[1] = rs[2] * rt[0]; rd[2] = rs[0] * rt[1]"
opcode: "011001101"
prefix: d
vcrsp:
type: vector-binary
encoding: vfpu-alu
flavors: t
perf-class: transform
title: "Vector cross product"
description: "Performs a full cross-product operation"
pcode: >
rd[0] = rs[1] * rt[2] - rs[2] * rt[1];
rd[1] = rs[2] * rt[0] - rs[0] * rt[2];
rd[2] = rs[0] * rt[1] - rs[1] * rt[0]
opcode: "111100101"
reg-compat: no-overlap
vqmul:
type: vector-binary
encoding: vfpu-alu
flavors: q
perf-class: transform
title: "Quaternion multiplication"
description: "Performs a vector-matrix homogeneous transform (matrix-vector product), with a vector result"
pcode: >
rd[0] = rs[3] * rt[0] - rs[2] * rt[1] + rs[1] * rt[2] + rs[0] * rt[3];
rd[1] = rs[3] * rt[1] + rs[2] * rt[0] + rs[1] * rt[3] - rs[0] * rt[2];
rd[2] = rs[3] * rt[2] + rs[2] * rt[3] - rs[1] * rt[0] + rs[0] * rt[1];
rd[3] = rs[3] * rt[3] - rs[2] * rt[2] - rs[1] * rt[1] - rs[0] * rt[0]
opcode: "111100101"
reg-compat: no-overlap
vsbn:
type: vector-binary
encoding: vfpu-alu
flavors: s
perf-class: arithmetic
title: "Change exponent scale"
description: >
Rescales rs operand to have rt as exponent. This would be equivalent to
ldexp(frexp(rs, NULL), rt + 128). If we express the number in its IEEE754
terms, that is, if rs can be expressed as ±m * 2^e, the instruction will
replace "e" with the value of rt + 127 mod 256.
alu-mode: integer
pcode: >
rd[0] = (fpiszero(rs[0]) || fpisnanorinf(rs[0])) ? rs[0] :
(rs[0] & 0x807FFFFF) | (((rt[0] + 127) & 0xFF) << 23)
opcode: "011000010"
prefix: std
# Scaling is a bit special
vscl:
type: vector-binary-scale
encoding: vfpu-alu
flavors: ptq
perf-class: arithmetic
title: "Vector scalar scale"
description: "Scales a vector (element-wise) by an scalar factor"
pcode: "@ rd[{i}] = rs[{i}] * rt[0]"
opcode: "011001010"
prefix: sd
# Reduction instructions, its destination is narrower
vdot:
type: vector-binary-reduce
encoding: vfpu-alu
flavors: ptq
perf-class: arithmetic-reduction
title: "Vector dot product"
description: "Performs vector floating point dot product"
pcode:
- "rd[0] = rs[0] * rt[0] + rs[1] * rt[1]"
- "rd[0] = rs[0] * rt[0] + rs[1] * rt[1] + rs[2] * rt[2]"
- "rd[0] = rs[0] * rt[0] + rs[1] * rt[1] + rs[2] * rt[2] + rs[3] * rt[3]"
opcode: "011001001"
prefix: std
vdet:
type: vector-binary-reduce
encoding: vfpu-alu
flavors: p
perf-class: arithmetic-reduction
title: "2x2 matrix determinant"
description: "Performs a 2x2 matrix determinant between two matrix rows"
pcode: "rd[0] = rs[0] * rt[1] - rs[1] * rt[0]"
opcode: "011001110"
prefix: sd
vhdp:
type: vector-binary-reduce
encoding: vfpu-alu
flavors: ptq
perf-class: arithmetic-reduction
title: "Homogeneous dot product"
description: "Performs vector floating point homegeneous dot product"
pcode:
- "rd[0] = rs[0] * rt[0] + rt[1]"
- "rd[0] = rs[0] * rt[0] + rs[1] * rt[1] + rt[2]"
- "rd[0] = rs[0] * rt[0] + rs[1] * rt[1] + rs[2] * rt[2] + rt[3]"
opcode: "011001100"
prefix: td
# Unary VFPU-vector operations (use rd, rs)
vmov:
type: vector-unary
encoding: vfpu-alu
flavors: sptq
perf-class: bit-manipulation
title: "Vector copy"
description: "Element-wise data copy"
pcode: "@ rd[{i}] = rs[{i}]"
opcode: "110100000"
rt: "0000000"
prefix: sd
vabs:
type: vector-unary
encoding: vfpu-alu
flavors: sptq
perf-class: bit-manipulation
title: "Absolute value"
description: "Performs element-wise floating point absolute value"
pcode: "@ rd[{i}] = fabsf(rs[{i}])"
opcode: "110100000"
rt: "0000001"
prefix: Sd
vneg:
type: vector-unary
encoding: vfpu-alu
flavors: sptq
perf-class: bit-manipulation
title: "Floating point negation"
description: "Performs element-wise floating point negation"
pcode: "@ rd[{i}] = -rs[{i}]"
opcode: "110100000"
rt: "0000010"
prefix: Sd
vsat0:
type: vector-unary
encoding: vfpu-alu
flavors: sptq
perf-class: bit-manipulation
title: "Saturate float to 0..1"
description: "Saturates inputs to the [0.0f ... 1.0f] range"
pcode: "@ rd[{i}] = fminf(fmaxf(rs[{i}], 0.0f), 1.0f)"
opcode: "110100000"
rt: "0000100"
prefix: sD
vsat1:
type: vector-unary
encoding: vfpu-alu
flavors: sptq
perf-class: bit-manipulation
title: "Saturate float to -1..1"
description: "Saturates inputs to the [-1.0f ... 1.0f] range"
pcode: "@ rd[{i}] = fminf(fmaxf(rs[{i}], -1.0f), 1.0f)"
opcode: "110100000"
rt: "0000101"
prefix: sD
vrcp:
type: vector-unary
encoding: vfpu-alu
flavors: sptq
perf-class: transcendental
title: "Reciprocate elements"
description: "Performs element-wise floating point reciprocal"
pcode: "@ rd[{i}] = 1.0f / rs[{i}]"
accuracy:
relative: 6.3e-7
note: >
This function provides an approximate value, with lower accuracy to what
FP32 IEEE754 numbers can represent. The lowest 3.5 mantissa bits seem to
be innacurate. Please refer to psp-tests/accuracy for more details.
opcode: "110100000"
rt: "0010000"
reg-compat: partial-overlap
prefix: s0d0
vrsq:
type: vector-unary
encoding: vfpu-alu
flavors: sptq
perf-class: transcendental
title: "Reciprocal square root"
description: "Performs element-wise floating pointreciprocal square root"
pcode: "@ rd[{i}] = 1.0f / sqrt(rs[{i}])"
accuracy:
relative: 7.3e-7
note: >
This function provides an approximate value, with lower accuracy to what
FP32 IEEE754 numbers can represent. The lowest 3.5 mantissa bits seem to
be innacurate. Please refer to psp-tests/accuracy for more details.
opcode: "110100000"
rt: "0010001"
reg-compat: partial-overlap
prefix: d0s0
vsin:
type: vector-unary
encoding: vfpu-alu
flavors: sptq
perf-class: transcendental
title: "Sine function"
description: "Performs element-wise floating point sin(π/2⋅rs) operation"
pcode: "@ rd[{i}] = sin(rs[{i}] * M_PI_2)"
accuracy:
absolute: 4.8e-7
note: >
This function provides an approximate value, with lower accuracy to what
FP32 IEEE754 numbers can represent. The lowest 3 mantissa bits seem to
be innacurate. Please refer to psp-tests/accuracy for more details.
edgecases:
- operand: rs
input-range: -2^32 <= rs <= 2^32
result: invalid
opcode: "110100000"
rt: "0010010"
reg-compat: partial-overlap
prefix: s0d0
vcos:
type: vector-unary
encoding: vfpu-alu
flavors: sptq
perf-class: transcendental
title: "Cosine function"
description: "Performs element-wise floating point cos(π/2⋅rs) operation"
pcode: "@ rd[{i}] = cos(rs[{i}] * M_PI_2)"
accuracy:
absolute: 4.0e-7
note: >
This function provides an approximate value, with lower accuracy to what
FP32 IEEE754 numbers can represent. The lowest 2.5 mantissa bits seem to
be innacurate. Please refer to psp-tests/accuracy for more details.
edgecases:
- operand: rs
input-range: -2^32 <= rs <= 2^32
result: invalid
opcode: "110100000"
rt: "0010011"
reg-compat: partial-overlap
prefix: s0d0
vexp2:
type: vector-unary
encoding: vfpu-alu
flavors: sptq
perf-class: transcendental
title: "Base-2 exponentiation"
description: "Performs element-wise floating point exp2(rs) operation"
pcode: >
@ rd[{i}] = (rs[{i}] >= 128) ? INFINITY :
(rs[{i}] <= -127) ? 0.0f :
exp2(rs[{i}])
accuracy:
relative: 7.2e-7
note: >
This function provides an approximate value, with lower accuracy to what
FP32 IEEE754 numbers can represent. The lowest 3 mantissa bits seem to
be innacurate. Please refer to psp-tests/accuracy for more details.
Inputs larger than 127 result in overflow (cannot represent over 2^127)
opcode: "110100000"
rt: "0010100"
reg-compat: partial-overlap
prefix: s0d0
vlog2:
type: vector-unary
encoding: vfpu-alu
flavors: sptq
perf-class: transcendental
title: "Base-2 logarithm"
description: "Performs element-wise floating point log2(rs) operation"
pcode: "@ rd[{i}] = log2(rs[{i}])"
accuracy:
absolute: 3.0e-5
note: >
This function provides an approximate value, with lower accuracy to what
FP32 IEEE754 numbers can represent. Accuracy varies greatly depending
on the input value. Please refer to psp-tests/accuracy for more details.
opcode: "110100000"
rt: "0010101"
reg-compat: partial-overlap
prefix: s0d0
vlgb:
type: vector-unary
encoding: vfpu-alu
flavors: s
perf-class: arithmetic
title: "LogB calculation"