source: trunk/lib_ir/s2p.h @ 3970

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

auto gen test files for i2 ops

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