source: trunk/lib_ir/s2p.h @ 3939

Last change on this file since 3939 was 3939, checked in by linmengl, 5 years ago

test out PEXT with s2p_ideal, put down results

File size: 3.4 KB
Line 
1#ifndef S2P_H
2#define S2P_H
3
4#include "idisa.hpp"
5
6extern "C" {
7
8  BitBlock packh_16(BitBlock a, BitBlock b);
9  BitBlock packl_16(BitBlock a, BitBlock b);
10
11  BitBlock packh_8(BitBlock a, BitBlock b);
12  BitBlock packl_8(BitBlock a, BitBlock b);
13
14  BitBlock packh_4(BitBlock a, BitBlock b);
15  BitBlock packl_4(BitBlock a, BitBlock b);
16
17  BitBlock packh_2(BitBlock a, BitBlock b);
18  BitBlock packl_2(BitBlock a, BitBlock b);
19
20  BitBlock ifh_1(BitBlock a, BitBlock b, BitBlock c);
21  BitBlock srli_16(BitBlock a, BitBlock shift_mask);
22  BitBlock slli_16(BitBlock a, BitBlock shift_mask);
23
24  void s2p_step_ir(BitBlock s0, BitBlock s1, BitBlock hi_mask, BitBlock shift_mask, BitBlock *p0, BitBlock *p1);
25
26  void s2p_bytepack_ir(BitBlock s0, BitBlock s1, BitBlock s2, BitBlock s3, BitBlock s4, BitBlock s5, BitBlock s6, BitBlock s7, BitBlock* p0, BitBlock* p1, BitBlock* p2, BitBlock* p3, BitBlock* p4, BitBlock* p5, BitBlock* p6, BitBlock* p7);
27
28  void s2p_ideal_ir(BitBlock s0, BitBlock s1, BitBlock s2, BitBlock s3, BitBlock s4, BitBlock s5, BitBlock s6, BitBlock s7, BitBlock *p0, BitBlock *p1, BitBlock *p2, BitBlock *p3, BitBlock *p4, BitBlock *p5, BitBlock *p6, BitBlock *p7);
29
30  BitBlock const16_1();
31  BitBlock const16_2();
32  BitBlock const16_4();
33
34  BitBlock himask_2();
35  BitBlock himask_4();
36  BitBlock himask_8();
37}
38
39//S2P_ALGORITHM: s2p_bytepack_inline, written in pure IR in order to use
40//immediate constants in shifting.
41//s2p_ideal: use 3 stage packh2,4,8
42#define S2P_ALGORITHM s2p_ideal
43
44#define s2p_ideal(s0, s1, s2, s3, s4, s5, s6, s7, p0, p1, p2, p3, p4, p5, p6, p7) \
45  s2p_ideal_ir(s0, s1, s2, s3, s4, s5, s6, s7, &p0, &p1, &p2, &p3, &p4, &p5, &p6, &p7)
46
47#define s2p_bytepack_inline(s0, s1, s2, s3, s4, s5, s6, s7, p0, p1, p2, p3, p4, p5, p6, p7) \
48  s2p_bytepack_ir(s0, s1, s2, s3, s4, s5, s6, s7, &p0, &p1, &p2, &p3, &p4, &p5, &p6, &p7)
49
50//This macro is deprecated. Use inline version.
51#define s2p_bytepack(s0, s1, s2, s3, s4, s5, s6, s7, p0, p1, p2, p3, p4, p5, p6, p7) \
52  do {\
53        BitBlock bit00224466_0,bit00224466_1,bit00224466_2,bit00224466_3;\
54        BitBlock bit11335577_0,bit11335577_1,bit11335577_2,bit11335577_3;\
55        BitBlock bit00004444_0,bit22226666_0,bit00004444_1,bit22226666_1;\
56        BitBlock bit11115555_0,bit33337777_0,bit11115555_1,bit33337777_1;\
57        s2p_step_ir(s0,s1,himask_2(),const16_1(),&bit00224466_0,&bit11335577_0);\
58        s2p_step_ir(s2,s3,himask_2(),const16_1(),&bit00224466_1,&bit11335577_1);\
59        s2p_step_ir(s4,s5,himask_2(),const16_1(),&bit00224466_2,&bit11335577_2);\
60        s2p_step_ir(s6,s7,himask_2(),const16_1(),&bit00224466_3,&bit11335577_3);\
61        s2p_step_ir(bit00224466_0,bit00224466_1,himask_4(),const16_2(),&bit00004444_0,&bit22226666_0);\
62        s2p_step_ir(bit00224466_2,bit00224466_3,himask_4(),const16_2(),&bit00004444_1,&bit22226666_1);\
63        s2p_step_ir(bit11335577_0,bit11335577_1,himask_4(),const16_2(),&bit11115555_0,&bit33337777_0);\
64        s2p_step_ir(bit11335577_2,bit11335577_3,himask_4(),const16_2(),&bit11115555_1,&bit33337777_1);\
65        s2p_step_ir(bit00004444_0,bit00004444_1,himask_8(),const16_4(),&p0,&p4);\
66        s2p_step_ir(bit11115555_0,bit11115555_1,himask_8(),const16_4(),&p1,&p5);\
67        s2p_step_ir(bit22226666_0,bit22226666_1,himask_8(),const16_4(),&p2,&p6);\
68        s2p_step_ir(bit33337777_0,bit33337777_1,himask_8(),const16_4(),&p3,&p7);\
69  } while(0)
70
71#define s2p(s0, s1, s2, s3, s4, s5, s6, s7, p0, p1, p2, p3, p4, p5, p6, p7)\
72  S2P_ALGORITHM(s7, s6, s5, s4, s3, s2, s1, s0, p0, p1, p2, p3, p4, p5, p6, p7)
73
74#endif
Note: See TracBrowser for help on using the repository browser.