summaryrefslogtreecommitdiff
path: root/driver/others/lamch.c
blob: b04450024ee8db76ed4e7c9ce7e962d84f4e6712 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/*********************************************************************/
/* Copyright 2009, 2010 The University of Texas at Austin.           */
/* All rights reserved.                                              */
/*                                                                   */
/* Redistribution and use in source and binary forms, with or        */
/* without modification, are permitted provided that the following   */
/* conditions are met:                                               */
/*                                                                   */
/*   1. Redistributions of source code must retain the above         */
/*      copyright notice, this list of conditions and the following  */
/*      disclaimer.                                                  */
/*                                                                   */
/*   2. Redistributions in binary form must reproduce the above      */
/*      copyright notice, this list of conditions and the following  */
/*      disclaimer in the documentation and/or other materials       */
/*      provided with the distribution.                              */
/*                                                                   */
/*    THIS  SOFTWARE IS PROVIDED  BY THE  UNIVERSITY OF  TEXAS AT    */
/*    AUSTIN  ``AS IS''  AND ANY  EXPRESS OR  IMPLIED WARRANTIES,    */
/*    INCLUDING, BUT  NOT LIMITED  TO, THE IMPLIED  WARRANTIES OF    */
/*    MERCHANTABILITY  AND FITNESS FOR  A PARTICULAR  PURPOSE ARE    */
/*    DISCLAIMED.  IN  NO EVENT SHALL THE UNIVERSITY  OF TEXAS AT    */
/*    AUSTIN OR CONTRIBUTORS BE  LIABLE FOR ANY DIRECT, INDIRECT,    */
/*    INCIDENTAL,  SPECIAL, EXEMPLARY,  OR  CONSEQUENTIAL DAMAGES    */
/*    (INCLUDING, BUT  NOT LIMITED TO,  PROCUREMENT OF SUBSTITUTE    */
/*    GOODS  OR  SERVICES; LOSS  OF  USE,  DATA,  OR PROFITS;  OR    */
/*    BUSINESS INTERRUPTION) HOWEVER CAUSED  AND ON ANY THEORY OF    */
/*    LIABILITY, WHETHER  IN CONTRACT, STRICT  LIABILITY, OR TORT    */
/*    (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING IN ANY WAY OUT    */
/*    OF  THE  USE OF  THIS  SOFTWARE,  EVEN  IF ADVISED  OF  THE    */
/*    POSSIBILITY OF SUCH DAMAGE.                                    */
/*                                                                   */
/* The views and conclusions contained in the software and           */
/* documentation are those of the authors and should not be          */
/* interpreted as representing official policies, either expressed   */
/* or implied, of The University of Texas at Austin.                 */
/*********************************************************************/

#include "common.h"

#if 0
static FLOAT hdata[] __attribute__((aligned(128))) = {
#ifdef XDOUBLE
  +0x1.0000000000000000P-00064L,
  +0x1.0000000000000000P-16382L,
  +0x1.0000000000000000P+00001L,
  +0x1.0000000000000000P-00063L,
  +0x1.0000000000000000P+00006L,
  +0x1.0000000000000000P+00000L,
  -0x1.ffe8000000000000P+00013L,
  +0x1.0000000000000000P-16382L,
  +0x1.0004000000000000P+00014L,
  +0x1.fffffffffffffffeP+16383L,
#elif defined DOUBLE
  +0x1.0000000000000P-0053,
  +0x1.0000000000000P-1022,
  +0x1.0000000000000P+0001,
  +0x1.0000000000000P-0052,
  +0x1.a800000000000P+0005,
  +0x1.0000000000000P+0000,
  -0x1.fe80000000000P+0009,
  +0x1.0000000000000P-1022,
  +0x1.0000000000000P+0010,
  +0x1.fffffffffffffP+1023,
#else
  +0x1.000000P-024f,
  +0x1.000000P-126f,
  +0x1.000000P+001f,
  +0x1.000000P-023f,
  +0x1.800000P+004f,
  +0x1.000000P+000f,
  -0x1.f40000P+006f,
  +0x1.000000P-126f,
  +0x1.000000P+007f,
  +0x1.fffffeP+127f,
#endif
};

#endif

static unsigned int idata[] __attribute__((aligned(128))) = {

#if   defined XDOUBLE
#ifndef __BIG_ENDIAN__
  0x00000000, 0x80000000, 0x00003fbf, 0x00000000,
  0x00000000, 0x80000000, 0x00000001, 0x00000000,
  0x00000000, 0x80000000, 0x00004000, 0x00000000,
  0x00000000, 0x80000000, 0x00003fc0, 0x00000000,
  0x00000000, 0x80000000, 0x00004005, 0x00000000,
  0x00000000, 0x80000000, 0x00003fff, 0x00000000,
  0x00000000, 0xff400000, 0x0000c00c, 0x00000000,
  0x00000000, 0x80000000, 0x00000001, 0x00000000,
  0x00000000, 0x80200000, 0x0000400d, 0x00000000,
  0xffffffff, 0xffffffff, 0x00007ffe, 0x00000000,
#else
  0x00000000, 0x00003fbf, 0x80000000, 0x00000000,
  0x00000000, 0x00000001, 0x80000000, 0x00000000,
  0x00000000, 0x00004000, 0x80000000, 0x00000000,
  0x00000000, 0x00003fc0, 0x80000000, 0x00000000,
  0x00000000, 0x00004005, 0x80000000, 0x00000000,
  0x00000000, 0x00003fff, 0x80000000, 0x00000000,
  0x00000000, 0x0000c00c, 0xff400000, 0x00000000,
  0x00000000, 0x00000001, 0x80000000, 0x00000000,
  0x00000000, 0x0000400d, 0x80200000, 0x00000000,
  0x00000000, 0x00007ffe, 0xffffffff, 0xffffffff,

#endif
#elif defined DOUBLE
#ifndef __BIG_ENDIAN__
  0x00000000, 0x3ca00000,
  0x00000000, 0x00100000,
  0x00000000, 0x40000000,
  0x00000000, 0x3cb00000,
  0x00000000, 0x404a8000,
  0x00000000, 0x3ff00000,
  0x00000000, 0xc08fe800,
  0x00000000, 0x00100000,
  0x00000000, 0x40900000,
  0xffffffff, 0x7fefffff,
#else
  0x3ca00000, 0x00000000,
  0x00100000, 0x00000000,
  0x40000000, 0x00000000,
  0x3cb00000, 0x00000000,
  0x404a8000, 0x00000000,
  0x3ff00000, 0x00000000,
  0xc08fe800, 0x00000000,
  0x00100000, 0x00000000,
  0x40900000, 0x00000000,
  0x7fefffff, 0xffffffff,
#endif
#else

  0x33800000,
  0x00800000,
  0x40000000,
  0x34000000,
  0x41c00000,
  0x3f800000,
  0xc2fa0000,
  0x00800000,
  0x43000000,
  0x7f7fffff,

#endif
};


#ifdef NEED_F2CCONV
double
#else
FLOAT
#endif
NAME(char *P){
  
  char p = *P;
  int pos;
  FLOAT *hdata = (FLOAT *)idata;

  TOUPPER(p);

  switch (p) {
  case 'E':
    pos = 0;
    break;
  case 'S':
    pos = 1;
    break;
  case 'B':
    pos = 2;
    break;
  case 'P':
    pos = 3;
    break;
  case 'N':
    pos = 4;
    break;
  case 'R':
    pos = 5;
    break;
  case 'M':
    pos = 6;
    break;
  case 'U':
    pos = 7;
    break;
  case 'L':
    pos = 8;
    break;
  case 'O':
    pos = 9;
    break;
  default:
    pos = 0;
    break;
  }

 return hdata[pos];

}