OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [vmx/] [x-05.c] - Blame information for rev 689

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
#include <altivec.h>
2
 
3
static vector unsigned char select2 = {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2};
4
static vector unsigned char select3 = {4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4};
5
static vector unsigned char select4 = {8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8};
6
static vector unsigned char select5 = {16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16};
7
static vector unsigned char select6 = {32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32};
8
static vector unsigned char select7 = {64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64};
9
static vector unsigned char select8 = {128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128};
10
 
11
static vector unsigned char control1
12
  = {15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0};
13
static vector unsigned char control2
14
  = {15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0};
15
static vector unsigned char control3
16
  = {15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0};
17
static vector unsigned char control4
18
  = {15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0};
19
static vector unsigned char control5
20
  = {15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0};
21
static vector unsigned char control6
22
  = {15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0};
23
static vector unsigned char control7
24
  = {15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0};
25
static vector unsigned char control8
26
  = {15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0};
27
static vector unsigned char rotate1 = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
28
static vector unsigned char rotate2 = {3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3};
29
static vector unsigned char rotate3 = {5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5};
30
static vector unsigned char rotate4 = {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7};
31
static vector unsigned char rotate5 = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
32
static vector unsigned char rotate6 = {3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3};
33
static vector unsigned char rotate7 = {5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5};
34
static vector unsigned char rotate8 = {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7};
35
 
36
static vector unsigned char permute_128(vector unsigned char input)
37
{
38
  vector unsigned char result, new_bit;
39
 
40
  /* and now the code */
41
  result = vec_vperm(input, input, control1);
42
  result = vec_rl(result, rotate1);
43
 
44
  new_bit = vec_vperm(input, input, control2);
45
  new_bit = vec_rl(new_bit, rotate2);
46
  result = vec_sel(result, new_bit, select2);
47
 
48
  new_bit = vec_vperm(input, input, control3);
49
  new_bit = vec_rl(new_bit, rotate3);
50
  result = vec_sel(result, new_bit, select3);
51
 
52
  new_bit = vec_vperm(input, input, control4);
53
  new_bit = vec_rl(new_bit, rotate4);
54
  result = vec_sel(result, new_bit, select4);
55
 
56
  new_bit = vec_vperm(input, input, control5);
57
  new_bit = vec_rl(new_bit, rotate5);
58
  result = vec_sel(result, new_bit, select5);
59
 
60
  new_bit = vec_vperm(input, input, control6);
61
  new_bit = vec_rl(new_bit, rotate6);
62
  result = vec_sel(result, new_bit, select6);
63
 
64
  new_bit = vec_vperm(input, input, control7);
65
  new_bit = vec_rl(new_bit, rotate7);
66
  result = vec_sel(result, new_bit, select7);
67
 
68
  new_bit = vec_vperm(input, input, control8);
69
  new_bit = vec_rl(new_bit, rotate8);
70
  result = vec_sel(result, new_bit, select8);
71
 
72
  return result;
73
}
74
 
75
int main()
76
{
77
  vector unsigned char input
78
    = {0,1,2,4,8,16,32,64,128,0,1,2,4,8,16,32};
79
  vector unsigned char result = permute_128(input);
80
  return 0;
81
}
82
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.