Changeset 3919 for trunk


Ignore:
Timestamp:
Jul 21, 2014, 6:12:48 PM (3 years ago)
Author:
linmengl
Message:

adding more unittests

Location:
trunk/lib_ir
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib_ir/s2p.h

    r3918 r3919  
    33
    44#include "idisa.hpp"
     5// use s2p(s0, s1, ..., s7, *p0, *p1, ..., *p7)
     6// choose from s2p_bytepack and s2p_ideal
     7#define s2p s2p_bytepack
     8
    59extern "C" {
    610  void s2p_ideal(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);
     11
     12  void s2p_bytepack(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);
    713
    814  BitBlock packh_16(BitBlock a, BitBlock b);
     
    1420  BitBlock packh_4(BitBlock a, BitBlock b);
    1521  BitBlock packl_4(BitBlock a, BitBlock b);
     22
     23  BitBlock ifh_1(BitBlock a, BitBlock b, BitBlock c);
     24  BitBlock srli_16(BitBlock a, BitBlock shift_mask);
     25  BitBlock slli_16(BitBlock a, BitBlock shift_mask);
    1626}
    1727
  • trunk/lib_ir/s2p.ll

    r3918 r3919  
    1212}
    1313
    14 define <4 x i32> @packh_16(<4 x i32> %a, <4 x i32> %b) {
     14define <4 x i32> @packh_16(<4 x i32> %a, <4 x i32> %b) alwaysinline {
    1515entry:
    1616  %aa = bitcast <4 x i32> %a to <16 x i8>
     
    2222}
    2323
    24 define <4 x i32> @packl_16(<4 x i32> %a, <4 x i32> %b) {
     24define <4 x i32> @packl_16(<4 x i32> %a, <4 x i32> %b) alwaysinline {
    2525entry:
    2626  %aa = bitcast <4 x i32> %a to <16 x i8>
     
    3030  %rr1 = bitcast <16 x i8> %rr to <4 x i32>
    3131  ret <4 x i32> %rr1
     32}
     33
     34define <4 x i32> @ifh_1(<4 x i32> %cond, <4 x i32> %b, <4 x i32> %c) alwaysinline {
     35entry:
     36  %mm = bitcast <4 x i32> %cond to <128 x i1>
     37  %bb = bitcast <4 x i32> %b to <128 x i1>
     38  %cc = bitcast <4 x i32> %c to <128 x i1>
     39
     40  %rr = select <128 x i1> %mm, <128 x i1> %bb, <128 x i1> %cc
     41  %r  = bitcast <128 x i1> %rr to <4 x i32>
     42  ret <4 x i32> %r
     43}
     44
     45define <4 x i32> @srli_16(<4 x i32> %a, <8 x i16> %shift_mask) alwaysinline {
     46entry:
     47  %aa = bitcast <4 x i32> %a to <8 x i16>
     48  %r0 = lshr <8 x i16> %aa, %shift_mask
     49  %rr = bitcast <8 x i16> %r0 to <4 x i32>
     50  ret <4 x i32> %rr
     51}
     52
     53define <4 x i32> @slli_16(<4 x i32> %a, <8 x i16> %shift_mask) alwaysinline {
     54entry:
     55  %aa = bitcast <4 x i32> %a to <8 x i16>
     56  %r0 = shl <8 x i16> %aa, %shift_mask
     57  %rr = bitcast <8 x i16> %r0 to <4 x i32>
     58  ret <4 x i32> %rr
     59}
     60
     61define void @s2p_step(<4 x i32> %s0, <4 x i32> %s1, <4 x i32> %hi_mask, <8 x i16> %shift_mask, <4 x i32>* %p0, <4 x i32>* %p1) alwaysinline {
     62entry:
     63  %t0 = call <4 x i32> @packh_16(<4 x i32> %s0, <4 x i32> %s1)
     64  %t1 = call <4 x i32> @packl_16(<4 x i32> %s0, <4 x i32> %s1)
     65
     66  %t2 = call <4 x i32> @srli_16(<4 x i32> %t1, <8 x i16> %shift_mask)
     67  %q0 = call <4 x i32> @ifh_1(<4 x i32> %hi_mask, <4 x i32> %t0, <4 x i32> %t2)
     68  %t3 = call <4 x i32> @slli_16(<4 x i32> %t0, <8 x i16> %shift_mask)
     69  %q1 = call <4 x i32> @ifh_1(<4 x i32> %hi_mask, <4 x i32> %t3, <4 x i32> %t1)
     70
     71  store <4 x i32> %q0, <4 x i32>* %p0
     72  store <4 x i32> %q1, <4 x i32>* %p1
     73
     74  ret void
    3275}
    3376
     
    137180;}
    138181
    139 ;define void @s2p_bytepack(
    140                   ;<4 x i32> %s0, <4 x i32> %s1, <4 x i32> %s2, <4 x i32> %s3,
    141                   ;<4 x i32> %s4, <4 x i32> %s5, <4 x i32> %s6, <4 x i32> %s7,
    142                   ;<4 x i32>* %p0, <4 x i32>* %p1, <4 x i32>* %p2, <4 x i32>* %p3,
    143                   ;<4 x i32>* %p4, <4 x i32>* %p5, <4 x i32>* %p6, <4 x i32>* %p7) {
    144 ;entry:
    145182
    146   ;ret void
    147 ;}
    148 
  • trunk/lib_ir/test_pack.cpp

    r3918 r3919  
    77int main(int argc, char **argv)
    88{
    9   SIMD_type a, b, c, d;
     9  SIMD_type a, b, c, d, e;
    1010
    1111  //Test packh_16
     
    1818    cout << Store2String(c,1) << endl;
    1919    cout << Store2String(d,1) << endl;
    20     cout << "Matching faild." << endl;
     20    cout << "packh_16 faild." << endl;
    2121    return 1;
    2222  }
     
    3131    cout << Store2String(c,1) << endl;
    3232    cout << Store2String(d,1) << endl;
    33     cout << "Matching faild." << endl;
     33    cout << "packl_16 faild." << endl;
    3434    return 1;
    3535  }
     36
     37  //Test ifh_1
     38  a = mvmd<32>::fill((int)rand() % 10000);
     39  b = mvmd<32>::fill((int)rand() % 1000);
     40  c = mvmd<32>::fill((int)rand() % 1000);
     41  d = ifh_1(a, b, c);
     42  e = simd<1>::ifh(a, b, c);
     43  if (Store2String(d,1) != Store2String(e,1)) {
     44    cout << "ifh_1 faild." << endl;
     45    return 1;
     46  }
     47
     48  //Test srli_16
     49  a = mvmd<32>::fill((int)rand() % 10000);
     50  b = mvmd<16>::fill(1);
     51  c = simd<16>::srli<1>(a);
     52  d = srli_16(a, b);
     53  if (Store2String(d,1) != Store2String(c,1)) {
     54    cout << "srli_16 faild." << endl;
     55    return 1;
     56  }
     57  a = mvmd<32>::fill((int)rand() % 10000);
     58  b = mvmd<16>::fill(2);
     59  c = simd<16>::srli<2>(a);
     60  d = srli_16(a, b);
     61  if (Store2String(d,1) != Store2String(c,1)) {
     62    cout << "srli_16 faild." << endl;
     63    return 1;
     64  }
     65
     66  //Test slli_16
     67  a = mvmd<32>::fill((int)rand() % 10000);
     68  b = mvmd<16>::fill(1);
     69  c = simd<16>::slli<1>(a);
     70  d = slli_16(a, b);
     71  if (Store2String(d,1) != Store2String(c,1)) {
     72    cout << "slli_16 faild." << endl;
     73    return 1;
     74  }
     75  a = mvmd<32>::fill((int)rand() % 10000);
     76  b = mvmd<16>::fill(2);
     77  c = simd<16>::slli<2>(a);
     78  d = slli_16(a, b);
     79  if (Store2String(d,1) != Store2String(c,1)) {
     80    cout << "slli_16 faild." << endl;
     81    return 1;
     82  }
     83
    3684
    3785  cout << "Test passed." << endl;
Note: See TracChangeset for help on using the changeset viewer.