xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/2008-03-24-BitField-And-Alloca.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -O2 -emit-llvm %s -o - | not grep alloca
2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple i686-pc-linux-gnu -O2 -emit-llvm %s -o - | not grep store
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc enum {
5*f4a2713aSLionel Sambuc  PP_C,
6*f4a2713aSLionel Sambuc  PP_D,
7*f4a2713aSLionel Sambuc  PP_R,
8*f4a2713aSLionel Sambuc  PP_2D,
9*f4a2713aSLionel Sambuc  PP_1D,
10*f4a2713aSLionel Sambuc  PP_SR,
11*f4a2713aSLionel Sambuc  PP_S2D,
12*f4a2713aSLionel Sambuc  PP_S1D,
13*f4a2713aSLionel Sambuc  PP_SC
14*f4a2713aSLionel Sambuc };
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc enum {
17*f4a2713aSLionel Sambuc  G_VP,
18*f4a2713aSLionel Sambuc  G_FP,
19*f4a2713aSLionel Sambuc  G_VS,
20*f4a2713aSLionel Sambuc  G_GS,
21*f4a2713aSLionel Sambuc  G_FS
22*f4a2713aSLionel Sambuc };
23*f4a2713aSLionel Sambuc 
24*f4a2713aSLionel Sambuc enum {
25*f4a2713aSLionel Sambuc  G_NONE,
26*f4a2713aSLionel Sambuc  G_B,
27*f4a2713aSLionel Sambuc  G_R
28*f4a2713aSLionel Sambuc };
29*f4a2713aSLionel Sambuc 
30*f4a2713aSLionel Sambuc typedef union _Key {
31*f4a2713aSLionel Sambuc  struct {
32*f4a2713aSLionel Sambuc   unsigned int count : 2;
33*f4a2713aSLionel Sambuc   unsigned int Aconst : 1;
34*f4a2713aSLionel Sambuc   unsigned int Bconst : 1;
35*f4a2713aSLionel Sambuc   unsigned int Cconst : 1;
36*f4a2713aSLionel Sambuc   unsigned int Xused : 1;
37*f4a2713aSLionel Sambuc   unsigned int Yused : 1;
38*f4a2713aSLionel Sambuc   unsigned int Zused : 1;
39*f4a2713aSLionel Sambuc   unsigned int Wused : 1;
40*f4a2713aSLionel Sambuc   unsigned int ttype : 3;
41*f4a2713aSLionel Sambuc   unsigned int scalar : 1;
42*f4a2713aSLionel Sambuc   unsigned int AType : 4;
43*f4a2713aSLionel Sambuc   unsigned int BType : 4;
44*f4a2713aSLionel Sambuc   unsigned int CType : 4;
45*f4a2713aSLionel Sambuc   unsigned int RType : 4;
46*f4a2713aSLionel Sambuc   unsigned int Size : 2;
47*f4a2713aSLionel Sambuc   unsigned int prec : 1;
48*f4a2713aSLionel Sambuc 
49*f4a2713aSLionel Sambuc   unsigned int ASize : 2;
50*f4a2713aSLionel Sambuc   unsigned int BSize : 2;
51*f4a2713aSLionel Sambuc   unsigned int CSize : 2;
52*f4a2713aSLionel Sambuc   unsigned int tTex : 4;
53*f4a2713aSLionel Sambuc   unsigned int proj : 1;
54*f4a2713aSLionel Sambuc   unsigned int lod : 2;
55*f4a2713aSLionel Sambuc   unsigned int dvts : 1;
56*f4a2713aSLionel Sambuc   unsigned int uipad : 18;
57*f4a2713aSLionel Sambuc  } key_io;
58*f4a2713aSLionel Sambuc  struct {
59*f4a2713aSLionel Sambuc   unsigned int key0;
60*f4a2713aSLionel Sambuc   unsigned int key1;
61*f4a2713aSLionel Sambuc  } key;
62*f4a2713aSLionel Sambuc  unsigned long long lkey;
63*f4a2713aSLionel Sambuc } Key;
64*f4a2713aSLionel Sambuc 
foo(const Key iospec,int * ret)65*f4a2713aSLionel Sambuc static void foo(const Key iospec, int* ret)
66*f4a2713aSLionel Sambuc {
67*f4a2713aSLionel Sambuc   *ret=0;
68*f4a2713aSLionel Sambuc  if(((iospec.key_io.lod == G_B) &&
69*f4a2713aSLionel Sambuc   (iospec.key_io.ttype != G_VS) &&
70*f4a2713aSLionel Sambuc   (iospec.key_io.ttype != G_GS) &&
71*f4a2713aSLionel Sambuc   (iospec.key_io.ttype != G_FS)) ||
72*f4a2713aSLionel Sambuc 
73*f4a2713aSLionel Sambuc   (((iospec.key_io.tTex == PP_C) ||
74*f4a2713aSLionel Sambuc     (iospec.key_io.tTex == PP_SC)) &&
75*f4a2713aSLionel Sambuc    ((iospec.key_io.tTex == PP_SR) ||
76*f4a2713aSLionel Sambuc     (iospec.key_io.tTex == PP_S2D) ||
77*f4a2713aSLionel Sambuc     (iospec.key_io.tTex == PP_S1D) ||
78*f4a2713aSLionel Sambuc     (iospec.key_io.tTex == PP_SC))))
79*f4a2713aSLionel Sambuc   *ret=1;
80*f4a2713aSLionel Sambuc }
81*f4a2713aSLionel Sambuc 
82*f4a2713aSLionel Sambuc 
bar(unsigned long long key_token2)83*f4a2713aSLionel Sambuc extern int bar(unsigned long long key_token2)
84*f4a2713aSLionel Sambuc {
85*f4a2713aSLionel Sambuc  int ret;
86*f4a2713aSLionel Sambuc  __attribute__ ((unused)) Key iospec = (Key) key_token2;
87*f4a2713aSLionel Sambuc  foo(iospec, &ret);
88*f4a2713aSLionel Sambuc  return ret;
89*f4a2713aSLionel Sambuc }
90