swar-c99-6.5.2.3-union.c
1.32 KB
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
/* -----------------------------------------------------------------------------
* 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.5.2.3-union.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"
// swar only
typedef union swar_union {
su32x1b u1;
ss32x1b s1;
su16x2b u2;
ss16x2b s2;
su10x3b u3;
ss10x3b s3;
su8x4b u4;
ss8x4b s4;
su4x8b u8;
ss4x8b s8;
su2x16b u16;
ss2x16b s16;
} swar_union_t;
// mixed
typedef union mixed_union {
unsigned int ui;
int i;
su10x3b u3;
ss10x3b s3;
} mixed_union_t;
int main(void)
{
swar_union_t u;
mixed_union_t m;
int sz = sizeof(u);
sz += sizeof(m);
m.u3 = (su10x3b) u.s3;
u.s3 = m.s3;
return sz;
}