summaryrefslogtreecommitdiff
path: root/gcc/config/s390/s390-builtins.h
blob: f8f010ddad6565cf4be0af4de8653c9a8826e03a (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
/* Common data structures used for builtin handling on S/390.
   Copyright (C) 2015 Free Software Foundation, Inc.

   Contributed by Andreas Krebbel (Andreas.Krebbel@de.ibm.com).

   This file is part of GCC.

   GCC is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   any later version.

   GCC is distributed in the hope that it will be useful, but WITHOUT
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
   License for more details.

   You should have received a copy of the GNU General Public License
   along with GCC; see the file COPYING3.  If not see
   <http://www.gnu.org/licenses/>.  */

/* This files contains data structure definitions which can be used by
   s390-builtins.c as well as s390-c.c.  Since the latter is
   considered to be part of the front-end we have to be careful not
   to use any of tree and rtx like data structures.  */

/* Builtin types, data and prototypes. */

enum s390_builtin_type_index
{
#undef DEF_TYPE
#undef DEF_POINTER_TYPE
#undef DEF_DISTINCT_TYPE
#undef DEF_VECTOR_TYPE
#undef DEF_OPAQUE_VECTOR_TYPE
#undef DEF_FN_TYPE
#undef DEF_OV_TYPE
#define DEF_TYPE(INDEX, ...) INDEX,
#define DEF_POINTER_TYPE(INDEX, ...) INDEX,
#define DEF_DISTINCT_TYPE(INDEX, ...) INDEX,
#define DEF_VECTOR_TYPE(INDEX, ...) INDEX,
#define DEF_OPAQUE_VECTOR_TYPE(INDEX, ...) INDEX,
#define DEF_FN_TYPE(...)
#define DEF_OV_TYPE(...)
#include "s390-builtin-types.def"
  BT_MAX
};

enum s390_builtin_fn_type_index
{
#undef DEF_TYPE
#undef DEF_POINTER_TYPE
#undef DEF_DISTINCT_TYPE
#undef DEF_VECTOR_TYPE
#undef DEF_OPAQUE_VECTOR_TYPE
#undef DEF_FN_TYPE
#undef DEF_OV_TYPE
#define DEF_TYPE(...)
#define DEF_POINTER_TYPE(...)
#define DEF_DISTINCT_TYPE(...)
#define DEF_VECTOR_TYPE(...)
#define DEF_OPAQUE_VECTOR_TYPE(...)
#define DEF_FN_TYPE(INDEX, ...) INDEX,
#define DEF_OV_TYPE(...)
#include "s390-builtin-types.def"
  BT_FN_MAX
};

enum s390_builtin_ov_type_index
{
#undef DEF_TYPE
#undef DEF_POINTER_TYPE
#undef DEF_DISTINCT_TYPE
#undef DEF_VECTOR_TYPE
#undef DEF_OPAQUE_VECTOR_TYPE
#undef DEF_FN_TYPE
#undef DEF_OV_TYPE
#define DEF_TYPE(...)
#define DEF_POINTER_TYPE(...)
#define DEF_DISTINCT_TYPE(...)
#define DEF_VECTOR_TYPE(...)
#define DEF_OPAQUE_VECTOR_TYPE(...)
#define DEF_FN_TYPE(...)
#define DEF_OV_TYPE(INDEX, ...) INDEX,
#include "s390-builtin-types.def"
  BT_OV_MAX
};

#define MAX_OV_OPERANDS 6

extern tree s390_builtin_types[BT_MAX];
extern tree s390_builtin_fn_types[BT_FN_MAX];

  /* Builtins.  */

enum s390_builtins {
#undef B_DEF
#undef OB_DEF
#undef OB_DEF_VAR
#define B_DEF(NAME, ...) S390_BUILTIN_##NAME,
#define OB_DEF(...)
#define OB_DEF_VAR(...)

#include "s390-builtins.def"
  S390_BUILTIN_MAX
};


/* Generate an enumeration of all overloaded builtins defined with
   OB_DEF in s390-builtins.def.  */
enum s390_overloaded_builtins {
#undef B_DEF
#undef OB_DEF
#undef OB_DEF_VAR
#define B_DEF(...)
#define OB_DEF(NAME, ...) S390_OVERLOADED_BUILTIN_##NAME,
#define OB_DEF_VAR(...)
#include "s390-builtins.def"
S390_OVERLOADED_BUILTIN_MAX
};

/* Generate an enumeration of all variants of overloaded builtins
   defined with OB_DEF_VAR in s390-builtins.def.  */
enum s390_overloaded_builtin_vars {
#undef B_DEF
#undef OB_DEF
#undef OB_DEF_VAR
#define B_DEF(...)
#define OB_DEF(...)
#define OB_DEF_VAR(NAME, ...) S390_OVERLOADED_BUILTIN_VAR_##NAME,
#include "s390-builtins.def"
S390_OVERLOADED_BUILTIN_VAR_MAX
};

#define S390_OVERLOADED_BUILTIN_OFFSET S390_BUILTIN_MAX
#define S390_OVERLOADED_BUILTIN_VAR_OFFSET \
  (S390_BUILTIN_MAX + S390_OVERLOADED_BUILTIN_MAX)
#define S390_ALL_BUILTIN_MAX				\
  (S390_BUILTIN_MAX + S390_OVERLOADED_BUILTIN_MAX +	\
   S390_OVERLOADED_BUILTIN_VAR_MAX)

extern const unsigned int bflags_builtin[S390_BUILTIN_MAX + 1];
extern const unsigned int opflags_builtin[S390_BUILTIN_MAX + 1];

extern const unsigned int
  bflags_overloaded_builtin[S390_OVERLOADED_BUILTIN_MAX + 1];
extern const unsigned int
  opflags_overloaded_builtin_var[S390_OVERLOADED_BUILTIN_VAR_MAX + 1];

static inline unsigned int
bflags_for_builtin (int fcode)
{
  if (fcode >= S390_OVERLOADED_BUILTIN_VAR_OFFSET)
    gcc_unreachable ();
  else if (fcode >= S390_OVERLOADED_BUILTIN_OFFSET)
    return bflags_overloaded_builtin[fcode - S390_BUILTIN_MAX];
  else
    return bflags_builtin[fcode];
}

static inline unsigned int
opflags_for_builtin (int fcode)
{
  if (fcode >= S390_OVERLOADED_BUILTIN_VAR_OFFSET)
    return opflags_overloaded_builtin_var[fcode -
					  S390_OVERLOADED_BUILTIN_VAR_OFFSET];
  else if (fcode >= S390_OVERLOADED_BUILTIN_OFFSET)
    gcc_unreachable ();
  else
    return opflags_builtin[fcode];
}

extern tree s390_builtin_decls[S390_BUILTIN_MAX +
			       S390_OVERLOADED_BUILTIN_MAX +
			       S390_OVERLOADED_BUILTIN_VAR_MAX];