swar-c99-6.8.5.3-for_stmt.c 2.19 KB
/* -----------------------------------------------------------------------------
 *  Copyright (C) 2018-2020 daiteq s.r.o.                http://www.daiteq.com
 *
 *  This program is distributed WITHOUT ANY WARRANTY; without even
 *  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 *  PURPOSE.
 *
 * -----------------------------------------------------------------------------
 *  Filename    : swar-c99-6.8.5.3-for_stmt.c
 *  Authors     : Roman Bartosinski
 *  Description : simple test of clang/LLVM compiler with SWAR extension
 *  Release     :
 *  Version     :
 *  Date        :
 * -----------------------------------------------------------------------------
 */

////A: --has-swar
//C: -daiteq-swar-enable

#define SWAR_USE_UNSIGNED_TYPES
#define SWAR_USE_SIGNED_TYPES
#include "swar-c99.h"

// iteration statements: while, do-while, for
#define ARRAYSIZE 20
su10x3b v3u[ARRAYSIZE] = {
  {0,1,2,3,4,5,6,7,0,1},
  {0,1,2,3,4,0,1,2,3,4},
  {1,1,1,4,4,4,4,7,7,7},
  {7,6,5,4,3,2,1,0,7,6},
  {0,0,0,0,0,0,0,0,0,0},
  {1,1,1,1,1,1,1,1,1,1},
  {2,2,2,2,2,2,2,2,2,2},
  {3,3,3,3,3,3,3,3,3,3},
  {4,4,4,4,4,4,4,4,4,4},
  {5,5,5,5,5,5,5,5,5,5},
  {6,6,6,6,6,6,6,6,6,6},
  {7,7,7,7,7,7,7,7,7,7},
  {0,0,0,0,0,0,0,0,0,0},
  {1,1,1,1,1,1,1,1,1,1},
  {2,2,2,2,2,2,2,2,2,2},
  {3,3,3,3,3,3,3,3,3,3},
  {4,4,4,4,4,4,4,4,4,4},
  {5,5,5,5,5,5,5,5,5,5},
  {6,6,6,6,6,6,6,6,6,6},
  {7,7,7,7,7,7,7,7,7,7},
};

su10x3b accum10x3u = {0};
su10x3b gv10x3u[ARRAYSIZE];
ss32x1b var32x1s;


int uno(void)
{
  int i = 0;
  while(i<ARRAYSIZE) {
    accum10x3u += v3u[i];
    i++;
  }
  
//  int rc = *((int *)&accum10x3u);
  int rc = 0;

  return rc;
}

//int due(void)
//{
  //su10x3b t = v3u[0];
  //int i = 0;
  //int rc = 0;
  //while(i<10) {
////    rc += t[i]; /* not supported in LLVM:IR [i32]=[i32]+[i3] */
    //rc += (int)t[i];  /* allowed */
    //i++;
  //}

  //return rc;
//}

//int tre(void)
//{
  //accum10x3u = 0;
  //for(int i=0;i<ARRAYSIZE;++i) {
    //accum10x3u += v3u[i];
  //}
  //return 0;
//}

//int quattro(void)
//{
  //su10x3b var3b = 0x12345678;
  //for(int i=0;i<ARRAYSIZE;++i)
    //gv10x3u[i] = v3u[i] + var3b;
  //return 0;
//}

int main(void)
{
  uno();
  //due();
  //tre();
  //quattro();
  return 0;
}