Skip to content

Commit 537e64d

Browse files
committed
mux inst
1 parent c9333d6 commit 537e64d

File tree

7 files changed

+104
-80
lines changed

7 files changed

+104
-80
lines changed

New_DSP_Instructions.md

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,24 @@
5656

5757
## select instructions
5858

59-
|31 - 26|25 - 21|20 - 16|15 - 11|10 - 8|7|6|5|4|3|2|1|0|
60-
|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
61-
|0x3F|D|A|B|res.|0|1|0|1|OP|U|OP|S|
59+
|31 - 26|25 - 21|20 - 16|15 - 11|10 - 8|7|6|5|4|3 - 1|0|
60+
|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
61+
|0x3F|D|A|B|res.|0|1|0|1|OP|S|
6262

6363
- OP : operation codes
64-
0. average : make average of A and B for each operation size
65-
1. min : select min between A and B for each operation size
66-
2. merge : make merge using A and B, {A,B} or {A,B,A,B}
67-
3. max : select max between A and B for each operation size
64+
0. average signed : make average of A and B for each operation size
65+
1. min signed : select min between A and B for each operation size
66+
2. average unsigned : make average of A and B for each operation size
67+
3. min unsigned : select min between A and B for each operation size
68+
4. mux if ge : select A if ge for each operation size
69+
5. max signed : select max between A and B for each operation size
70+
6. mux if ov : select A if ge for each operation size
71+
7. max unsigned : select max between A and B for each operation size
6872

6973
- S : operation size
7074
0. byte
7175
1. half word
7276

73-
- U : sign
74-
0. signed
75-
1. unsigned
76-
7777
## pack/unpack instructions
7878

7979
|31 - 26|25 - 21|20 - 16|15 - 11|10 - 8|7|6|5|4|3|2 - 1|0|
@@ -118,13 +118,6 @@
118118
2. reserved
119119
3. reserved
120120

121-
122-
## permutation instruction
123-
124-
|31 - 26|25 - 21|20 - 16|15 - 11|10 - 8|7 - 0|
125-
|:-:|:-:|:-:|:-:|:-:|:-:|
126-
|0x3F|D|A|B|res.|0x7E|
127-
128121
## basic multiplication instructions
129122

130123
|31 - 26|25 - 21|20 - 16|15 - 11|10 - 8|7|6|5|4|3|2|1 - 0|
@@ -143,31 +136,35 @@
143136

144137
## half word multiplication instructions
145138

146-
|31 - 26|25 - 21|20 - 16|15 - 11|10 - 8|7|6|5|4|3|2|1 - 0|
147-
|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
148-
|0x3F|D|A|B|res.|1|0|0|0|1|U|OP|
139+
|31 - 26|25 - 21|20 - 16|15 - 11|10 - 8|7|6|5|4|3|2|1|0|
140+
|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
141+
|0x3F|D|A|B|res.|1|0|0|0|1|U|X|Y|
149142

150-
- OP : operation codes
151-
0. multiply lower half word of A and lower half word of B
152-
1. multiply lower half word of A and higher half word of B
153-
2. multiply higher half word of A and lower half word of B
154-
3. multiply higher half word of A and higher half word of B
143+
- X : selection of A
144+
0. use higher half word of A
145+
1. use lower half word of A
146+
147+
- Y : selection of B
148+
0. use higher half word of B
149+
1. use lower half word of B
155150

156151
- U : signed/unsigned
157152
0. signed
158153
1. unsigned
159154

160155
## word and half word multiplication instructions
161156

162-
|31 - 26|25 - 21|20 - 16|15 - 11|10 - 8|7|6|5|4|3|2|1 - 0|
163-
|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
164-
|0x3F|D|A|B|res.|1|0|0|1|0|U|OP|
157+
|31 - 26|25 - 21|20 - 16|15 - 11|10 - 8|7|6|5|4|3|2|1|0|
158+
|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
159+
|0x3F|D|A|B|res.|1|0|0|1|0|U|H|Y|
165160

166-
- OP : operation codes
167-
0. multiply A and lower half word of B and get lower word saturated
168-
1. multiply A and higher half word of B and get lower word saturated
169-
2. multiply A and lower half word of B and get higher word
170-
3. multiply A and higher half word of B and get higher word
161+
- Y : selection of B
162+
0. use higher half word of B
163+
1. use lower half word of B
164+
165+
- H : output mux
166+
0. get saturated lower 32bit of result
167+
1. get higher 32bit of result
171168

172169
- U : signed/unsigned
173170
0. signed

cpu/or1korbis.cpu

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,20 +1367,22 @@
13671367
(define-normal-insn-enum insn-opcode-sel
13681368
"select insn opcode enums" ((MACH ORBIS-MACHS))
13691369
OPC_DSP_SEL_ f-op-3-4
1370-
(("AVG_B" #x0) ;; average
1371-
("AVG_H" #x1) ;;
1372-
("MIN_B" #x2) ;; min
1373-
("MIN_H" #x3) ;;
1374-
("AVGU_B" #x4) ;; average unsigned
1375-
("AVGU_H" #x5) ;;
1376-
("MINU_B" #x6) ;; min unsigned
1377-
("MINU_H" #x7) ;;
1378-
("MERGE_B" #x8) ;; merge
1379-
("MERGE_H" #x9) ;;
1380-
("MAX_B" #xA) ;; max
1381-
("MAX_H" #xB) ;;
1382-
("MAXU_B" #xE) ;; max unsigned
1383-
("MAXU_H" #xF) ;;
1370+
(("AVG_B" #x0) ;; average
1371+
("AVG_H" #x1) ;;
1372+
("MIN_B" #x2) ;; min
1373+
("MIN_H" #x3) ;;
1374+
("AVGU_B" #x4) ;; average unsigned
1375+
("AVGU_H" #x5) ;;
1376+
("MINU_B" #x6) ;; min unsigned
1377+
("MINU_H" #x7) ;;
1378+
("MUX_GE_B" #x8) ;; mux
1379+
("MUX_GE_H" #x9) ;;
1380+
("MAX_B" #xA) ;; max
1381+
("MAX_H" #xB) ;;
1382+
("MUX_OV_B" #xC) ;; mux
1383+
("MUX_OV_H" #xD) ;;
1384+
("MAXU_B" #xE) ;; max unsigned
1385+
("MAXU_H" #xF) ;;
13841386
)
13851387
)
13861388

@@ -1895,7 +1897,7 @@
18951897
(dsp-sel-min-insn le "min")
18961898
(dsp-sel-min-insn ge "max")
18971899

1898-
(define-pmacro (dsp-sel-merge-insn op_str)
1900+
(define-pmacro (dsp-sel-mux-insn op_str)
18991901
(begin
19001902
(dni(.sym ld- op_str -b)
19011903
(.str "ld." op_str ".b reg/reg/reg")
@@ -1916,7 +1918,8 @@
19161918
)
19171919
)
19181920

1919-
(dsp-sel-merge-insn "merge")
1921+
(dsp-sel-mux-insn "mux_ge")
1922+
(dsp-sel-mux-insn "mux_ov")
19201923

19211924
(define-pmacro (dsp-pack-insn size op_str op2)
19221925
(begin

opcodes/or1k-desc.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2188,14 +2188,24 @@ static const CGEN_IBASE or1k_cgen_insn_table[MAX_INSNS] =
21882188
OR1K_INSN_LD_MAXU_H, "ld-maxu-h", "ld.maxu.h", 32,
21892189
{ 0, { { { (1<<MACH_OR32)|(1<<MACH_OR32ND)|(1<<MACH_OR64)|(1<<MACH_OR64ND), 0 } } } }
21902190
},
2191-
/* ld.merge.b $rD,$rA,$rB */
2191+
/* ld.mux_ge.b $rD,$rA,$rB */
21922192
{
2193-
OR1K_INSN_LD_MERGE_B, "ld-merge-b", "ld.merge.b", 32,
2193+
OR1K_INSN_LD_MUX_GE_B, "ld-mux_ge-b", "ld.mux_ge.b", 32,
21942194
{ 0, { { { (1<<MACH_OR32)|(1<<MACH_OR32ND)|(1<<MACH_OR64)|(1<<MACH_OR64ND), 0 } } } }
21952195
},
2196-
/* ld.merge.h $rD,$rA,$rB */
2196+
/* ld.mux_ge.h $rD,$rA,$rB */
21972197
{
2198-
OR1K_INSN_LD_MERGE_H, "ld-merge-h", "ld.merge.h", 32,
2198+
OR1K_INSN_LD_MUX_GE_H, "ld-mux_ge-h", "ld.mux_ge.h", 32,
2199+
{ 0, { { { (1<<MACH_OR32)|(1<<MACH_OR32ND)|(1<<MACH_OR64)|(1<<MACH_OR64ND), 0 } } } }
2200+
},
2201+
/* ld.mux_ov.b $rD,$rA,$rB */
2202+
{
2203+
OR1K_INSN_LD_MUX_OV_B, "ld-mux_ov-b", "ld.mux_ov.b", 32,
2204+
{ 0, { { { (1<<MACH_OR32)|(1<<MACH_OR32ND)|(1<<MACH_OR64)|(1<<MACH_OR64ND), 0 } } } }
2205+
},
2206+
/* ld.mux_ov.h $rD,$rA,$rB */
2207+
{
2208+
OR1K_INSN_LD_MUX_OV_H, "ld-mux_ov-h", "ld.mux_ov.h", 32,
21992209
{ 0, { { { (1<<MACH_OR32)|(1<<MACH_OR32ND)|(1<<MACH_OR64)|(1<<MACH_OR64ND), 0 } } } }
22002210
},
22012211
/* ld.pack.b $rD,$rA,$rB */

opcodes/or1k-desc.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,10 +382,10 @@ typedef enum insn_opcode_addsub {
382382

383383
/* Enum declaration for select insn opcode enums. */
384384
typedef enum insn_opcode_sel {
385-
OPC_DSP_SEL_AVG_B = 0, OPC_DSP_SEL_AVG_H = 1, OPC_DSP_SEL_MIN_B = 2, OPC_DSP_SEL_MIN_H = 3
386-
, OPC_DSP_SEL_AVGU_B = 4, OPC_DSP_SEL_AVGU_H = 5, OPC_DSP_SEL_MINU_B = 6, OPC_DSP_SEL_MINU_H = 7
387-
, OPC_DSP_SEL_MERGE_B = 8, OPC_DSP_SEL_MERGE_H = 9, OPC_DSP_SEL_MAX_B = 10, OPC_DSP_SEL_MAX_H = 11
388-
, OPC_DSP_SEL_MAXU_B = 14, OPC_DSP_SEL_MAXU_H = 15
385+
OPC_DSP_SEL_AVG_B, OPC_DSP_SEL_AVG_H, OPC_DSP_SEL_MIN_B, OPC_DSP_SEL_MIN_H
386+
, OPC_DSP_SEL_AVGU_B, OPC_DSP_SEL_AVGU_H, OPC_DSP_SEL_MINU_B, OPC_DSP_SEL_MINU_H
387+
, OPC_DSP_SEL_MUX_GE_B, OPC_DSP_SEL_MUX_GE_H, OPC_DSP_SEL_MAX_B, OPC_DSP_SEL_MAX_H
388+
, OPC_DSP_SEL_MUX_OV_B, OPC_DSP_SEL_MUX_OV_H, OPC_DSP_SEL_MAXU_B, OPC_DSP_SEL_MAXU_H
389389
} INSN_OPCODE_SEL;
390390

391391
/* Enum declaration for pack/shift insn opcode enums. */

opcodes/or1k-opc.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,18 +1409,30 @@ static const CGEN_OPCODE or1k_cgen_insn_opcode_table[MAX_INSNS] =
14091409
{ { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
14101410
& ifmt_ld_add_b, { 0xfc00005f }
14111411
},
1412-
/* ld.merge.b $rD,$rA,$rB */
1412+
/* ld.mux_ge.b $rD,$rA,$rB */
14131413
{
14141414
{ 0, 0, 0, 0 },
14151415
{ { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
14161416
& ifmt_ld_add_b, { 0xfc000058 }
14171417
},
1418-
/* ld.merge.h $rD,$rA,$rB */
1418+
/* ld.mux_ge.h $rD,$rA,$rB */
14191419
{
14201420
{ 0, 0, 0, 0 },
14211421
{ { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
14221422
& ifmt_ld_add_b, { 0xfc000059 }
14231423
},
1424+
/* ld.mux_ov.b $rD,$rA,$rB */
1425+
{
1426+
{ 0, 0, 0, 0 },
1427+
{ { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
1428+
& ifmt_ld_add_b, { 0xfc00005c }
1429+
},
1430+
/* ld.mux_ov.h $rD,$rA,$rB */
1431+
{
1432+
{ 0, 0, 0, 0 },
1433+
{ { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
1434+
& ifmt_ld_add_b, { 0xfc00005d }
1435+
},
14241436
/* ld.pack.b $rD,$rA,$rB */
14251437
{
14261438
{ 0, 0, 0, 0 },

opcodes/or1k-opc.h

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -89,26 +89,26 @@ typedef enum cgen_insn_type {
8989
, OR1K_INSN_LD_SUBUS_B, OR1K_INSN_LD_SUBUS_H, OR1K_INSN_LD_AVG_B, OR1K_INSN_LD_AVG_H
9090
, OR1K_INSN_LD_AVGU_B, OR1K_INSN_LD_AVGU_H, OR1K_INSN_LD_MIN_B, OR1K_INSN_LD_MIN_H
9191
, OR1K_INSN_LD_MINU_B, OR1K_INSN_LD_MINU_H, OR1K_INSN_LD_MAX_B, OR1K_INSN_LD_MAX_H
92-
, OR1K_INSN_LD_MAXU_B, OR1K_INSN_LD_MAXU_H, OR1K_INSN_LD_MERGE_B, OR1K_INSN_LD_MERGE_H
93-
, OR1K_INSN_LD_PACK_B, OR1K_INSN_LD_PACK_H, OR1K_INSN_LD_PACKS_B, OR1K_INSN_LD_PACKS_H
94-
, OR1K_INSN_LD_PACKUS_B, OR1K_INSN_LD_PACKUS_H, OR1K_INSN_LD_UNPACK_B, OR1K_INSN_LD_UNPACK_H
95-
, OR1K_INSN_LD_RL_B, OR1K_INSN_LD_RL_H, OR1K_INSN_LD_SLL_B, OR1K_INSN_LD_SLL_H
96-
, OR1K_INSN_LD_SRA_B, OR1K_INSN_LD_SRA_H, OR1K_INSN_LD_SRL_B, OR1K_INSN_LD_SRL_H
97-
, OR1K_INSN_LD_NAND, OR1K_INSN_LD_NOR, OR1K_INSN_LD_MADDS_H, OR1K_INSN_LD_MADDUS_H
98-
, OR1K_INSN_LD_MSUBS_H, OR1K_INSN_LD_MSUBUS_H, OR1K_INSN_LD_MULS_H, OR1K_INSN_LD_MULUS_H
99-
, OR1K_INSN_LD_MULH_H, OR1K_INSN_LD_MULUH_H, OR1K_INSN_LD_MUL, OR1K_INSN_LD_MULU
100-
, OR1K_INSN_LD_MULS, OR1K_INSN_LD_MULH, OR1K_INSN_LD_MULUS, OR1K_INSN_LD_MULUH
101-
, OR1K_INSN_LD_MOVE_B, OR1K_INSN_LD_MOVE_H, OR1K_INSN_LD_EXTBH, OR1K_INSN_LD_EXTBW
102-
, OR1K_INSN_LD_EXTHW, OR1K_INSN_LD_EXTUBH, OR1K_INSN_LD_EXTUBW, OR1K_INSN_LD_EXTUHW
103-
, OR1K_INSN_LD_REVH, OR1K_INSN_LD_REV, OR1K_INSN_LD_REVBH, OR1K_INSN_LD_REVB
104-
, OR1K_INSN_LF_ADD_S, OR1K_INSN_LF_ADD_D, OR1K_INSN_LF_SUB_S, OR1K_INSN_LF_SUB_D
105-
, OR1K_INSN_LF_MUL_S, OR1K_INSN_LF_MUL_D, OR1K_INSN_LF_DIV_S, OR1K_INSN_LF_DIV_D
106-
, OR1K_INSN_LF_REM_S, OR1K_INSN_LF_REM_D, OR1K_INSN_LF_ITOF_S, OR1K_INSN_LF_ITOF_D
107-
, OR1K_INSN_LF_FTOI_S, OR1K_INSN_LF_FTOI_D, OR1K_INSN_LF_EQ_S, OR1K_INSN_LF_EQ_D
108-
, OR1K_INSN_LF_NE_S, OR1K_INSN_LF_NE_D, OR1K_INSN_LF_GE_S, OR1K_INSN_LF_GE_D
109-
, OR1K_INSN_LF_GT_S, OR1K_INSN_LF_GT_D, OR1K_INSN_LF_LT_S, OR1K_INSN_LF_LT_D
110-
, OR1K_INSN_LF_LE_S, OR1K_INSN_LF_LE_D, OR1K_INSN_LF_MADD_S, OR1K_INSN_LF_MADD_D
111-
, OR1K_INSN_LF_CUST1_S, OR1K_INSN_LF_CUST1_D
92+
, OR1K_INSN_LD_MAXU_B, OR1K_INSN_LD_MAXU_H, OR1K_INSN_LD_MUX_GE_B, OR1K_INSN_LD_MUX_GE_H
93+
, OR1K_INSN_LD_MUX_OV_B, OR1K_INSN_LD_MUX_OV_H, OR1K_INSN_LD_PACK_B, OR1K_INSN_LD_PACK_H
94+
, OR1K_INSN_LD_PACKS_B, OR1K_INSN_LD_PACKS_H, OR1K_INSN_LD_PACKUS_B, OR1K_INSN_LD_PACKUS_H
95+
, OR1K_INSN_LD_UNPACK_B, OR1K_INSN_LD_UNPACK_H, OR1K_INSN_LD_RL_B, OR1K_INSN_LD_RL_H
96+
, OR1K_INSN_LD_SLL_B, OR1K_INSN_LD_SLL_H, OR1K_INSN_LD_SRA_B, OR1K_INSN_LD_SRA_H
97+
, OR1K_INSN_LD_SRL_B, OR1K_INSN_LD_SRL_H, OR1K_INSN_LD_NAND, OR1K_INSN_LD_NOR
98+
, OR1K_INSN_LD_MADDS_H, OR1K_INSN_LD_MADDUS_H, OR1K_INSN_LD_MSUBS_H, OR1K_INSN_LD_MSUBUS_H
99+
, OR1K_INSN_LD_MULS_H, OR1K_INSN_LD_MULUS_H, OR1K_INSN_LD_MULH_H, OR1K_INSN_LD_MULUH_H
100+
, OR1K_INSN_LD_MUL, OR1K_INSN_LD_MULU, OR1K_INSN_LD_MULS, OR1K_INSN_LD_MULH
101+
, OR1K_INSN_LD_MULUS, OR1K_INSN_LD_MULUH, OR1K_INSN_LD_MOVE_B, OR1K_INSN_LD_MOVE_H
102+
, OR1K_INSN_LD_EXTBH, OR1K_INSN_LD_EXTBW, OR1K_INSN_LD_EXTHW, OR1K_INSN_LD_EXTUBH
103+
, OR1K_INSN_LD_EXTUBW, OR1K_INSN_LD_EXTUHW, OR1K_INSN_LD_REVH, OR1K_INSN_LD_REV
104+
, OR1K_INSN_LD_REVBH, OR1K_INSN_LD_REVB, OR1K_INSN_LF_ADD_S, OR1K_INSN_LF_ADD_D
105+
, OR1K_INSN_LF_SUB_S, OR1K_INSN_LF_SUB_D, OR1K_INSN_LF_MUL_S, OR1K_INSN_LF_MUL_D
106+
, OR1K_INSN_LF_DIV_S, OR1K_INSN_LF_DIV_D, OR1K_INSN_LF_REM_S, OR1K_INSN_LF_REM_D
107+
, OR1K_INSN_LF_ITOF_S, OR1K_INSN_LF_ITOF_D, OR1K_INSN_LF_FTOI_S, OR1K_INSN_LF_FTOI_D
108+
, OR1K_INSN_LF_EQ_S, OR1K_INSN_LF_EQ_D, OR1K_INSN_LF_NE_S, OR1K_INSN_LF_NE_D
109+
, OR1K_INSN_LF_GE_S, OR1K_INSN_LF_GE_D, OR1K_INSN_LF_GT_S, OR1K_INSN_LF_GT_D
110+
, OR1K_INSN_LF_LT_S, OR1K_INSN_LF_LT_D, OR1K_INSN_LF_LE_S, OR1K_INSN_LF_LE_D
111+
, OR1K_INSN_LF_MADD_S, OR1K_INSN_LF_MADD_D, OR1K_INSN_LF_CUST1_S, OR1K_INSN_LF_CUST1_D
112112
} CGEN_INSN_TYPE;
113113

114114
/* Index of `invalid' insn place holder. */

opcodes/or1k-opinst.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,8 @@ static const CGEN_OPINST *or1k_cgen_opinst_table[MAX_INSNS] = {
813813
& sfmt_ld_add_b_ops[0],
814814
& sfmt_ld_add_b_ops[0],
815815
& sfmt_ld_add_b_ops[0],
816+
& sfmt_ld_add_b_ops[0],
817+
& sfmt_ld_add_b_ops[0],
816818
& sfmt_ld_unpack_b_ops[0],
817819
& sfmt_ld_unpack_b_ops[0],
818820
& sfmt_ld_add_b_ops[0],

0 commit comments

Comments
 (0)