Changeset 4138


Ignore:
Timestamp:
Sep 8, 2014, 6:22:08 PM (4 years ago)
Author:
linmengl
Message:

add some more lib files; add tests for long stream addition.

Location:
trunk/lib_ir
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib_ir/CMakeLists.txt

    r4063 r4138  
    9393
    9494add_custom_target (check
    95   COMMAND ${CMAKE_CTEST_COMMAND}
     95  COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
    9696  DEPENDS test_s2p test_link test_pack test_llc xmlwf u8u16)
    9797
  • trunk/lib_ir/gen/llc_func.pytemplate.ll

    r4076 r4138  
    7979
    8080
    81 ; long add/shift
     81; long stream add/shift
     82declare {i128, i1} @llvm.uadd.with.overflow.i128(i128 %a, i128 %b)
     83
     84define void @uadd_with_overflow_i128(<2 x i64> %a, <2 x i64> %b, <2 x i64>* %P, i8* %B) {
     85entry:
     86  %aa = bitcast <2 x i64> %a to i128
     87  %bb = bitcast <2 x i64> %b to i128
     88
     89  %res = call {i128, i1} @llvm.uadd.with.overflow.i128(i128 %aa, i128 %bb)
     90  %sum = extractvalue {i128, i1} %res, 0
     91  %obit = extractvalue {i128, i1} %res, 1
     92  %obit8 = zext i1 %obit to i8
     93
     94  %r = bitcast i128 %sum to <2 x i64>
     95
     96  store <2 x i64> %r, <2 x i64>* %P
     97  store i8 %obit8, i8* %B
     98
     99  ret void
     100}
     101
    82102define <4 x i32> @add_128(<4 x i32> %a, <4 x i32> %b) {
    83103entry:
     
    98118}
    99119
     120define i32 @sign_mask_64(<2 x i64> %a) {
     121entry:
     122  %aa = icmp slt <2 x i64> %a, zeroinitializer
     123  %a1 = bitcast <2 x i1> %aa to i2
     124  %a2 = zext i2 %a1 to i32
     125  ret i32 %a2
     126}
  • trunk/lib_ir/gen/test_llc.pytemplate.cpp

    r4076 r4138  
    66
    77#include "utility.h"
     8#include <ctime>
    89#include <iostream>
    910#include <cstdlib>
     
    2526SIMD_type add_128(SIMD_type a, SIMD_type b);
    2627SIMD_type sll_128(SIMD_type a, SIMD_type b);
     28
     29int sign_mask_64(SIMD_type a);
     30
     31{% for fw in [128]%}
     32void uadd_with_overflow_i{{ fw }}(bitblock{{fw}}_t a, bitblock{{fw}}_t b, bitblock{{fw}}_t *sum, short *obit);
     33{% endfor %}
    2734}
    2835
    2936void fill_random(SIMD_type &a, SIMD_type &b)
    3037{
    31   a = mvmd<32>::fill((int)rand() % 10000);
    32   b = mvmd<32>::fill((int)rand() % 10000);
     38  a = mvmd<8>::fill((int)rand() % (1 << 8));
     39  b = mvmd<8>::fill((int)rand() % (1 << 8));
    3340}
    3441
    3542int main() {
    36   SIMD_type a, b, c, d, f;
     43  SIMD_type a, b, c, d, e, f;
    3744  short x, y;
     45  srand(time(0));
    3846
    3947  for (unsigned i = 0; i < 50; ++i) {
     
    110118      return 1;
    111119    }
     120
     121    //i128 long stream addition
     122    c = mvmd<32>::fill(0);
     123    SIMD_type sum0, obit0, sum1;
     124    short obit1;
     125    adc(a, b, c, obit0, sum0);
     126    uadd_with_overflow_i128(a, b, &sum1, &obit1);
     127    x = 0;
     128    if (Store2String(sum0,1) != Store2String(sum1,1)) {
     129      cout << "uadd_with_overflow_i128, sum error" << endl;
     130      x = 1;
     131    }
     132    if (Store2String(mvmd<128>::fill(obit1),1) != Store2String(obit0,1)) {
     133      cout << "uadd_with_overflow_i128 failed, obit error" << endl;
     134      x = 1;
     135    }
     136    if (x) {
     137      cout << "a =      " << Store2String(a, 1) << endl;
     138      cout << "b =      " << Store2String(b, 1) << endl;
     139      cout << "sum0 =   " << Store2String(sum0, 1) << endl;
     140      cout << "sum1 =   " << Store2String(sum1, 1) << endl;
     141      cout << "obit0 =  " << Store2String(obit0, 1) << endl;
     142      cout << "obit1 =  " << obit1 << endl;
     143      return 1;
     144    }
     145
    112146  }
    113147
Note: See TracChangeset for help on using the changeset viewer.