rework architecture specific type handling
[cparser] / builtins.h
1 /*
2  * This file is part of cparser.
3  * Copyright (C) 2007-2010 Matthias Braun <matze@braunis.de>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18  * 02111-1307, USA.
19  */
20 #ifndef BUILTINS_H
21 #define BUILTINS_H
22
23 #include <stdbool.h>
24
25 /**
26  * GNU builtin or MS intrinsic functions.
27  */
28 typedef enum builtin_kind_t {
29         bk_none = 0,
30
31         bk_gnu_builtin___memcpy_chk,
32         bk_gnu_builtin___memmove_chk,
33         bk_gnu_builtin___memset_chk,
34         bk_gnu_builtin___snprintf_chk,
35         bk_gnu_builtin___sprintf_chk,
36         bk_gnu_builtin___stpcpy_chk,
37         bk_gnu_builtin___strcat_chk,
38         bk_gnu_builtin___strcpy_chk,
39         bk_gnu_builtin___strncat_chk,
40         bk_gnu_builtin___strncpy_chk,
41         bk_gnu_builtin___vsnprintf_chk,
42         bk_gnu_builtin___vsprintf_chk,
43         bk_gnu_builtin_abort,
44         bk_gnu_builtin_abs,
45         bk_gnu_builtin_alloca,
46         bk_gnu_builtin_clz,
47         bk_gnu_builtin_ctz,
48         bk_gnu_builtin_exit,
49         bk_gnu_builtin_expect,
50         bk_gnu_builtin_ffs,
51         bk_gnu_builtin_frame_address,
52         bk_gnu_builtin_huge_val,
53         bk_gnu_builtin_huge_valf,
54         bk_gnu_builtin_huge_vall,
55         bk_gnu_builtin_inf,
56         bk_gnu_builtin_inff,
57         bk_gnu_builtin_infl,
58         bk_gnu_builtin_labs,
59         bk_gnu_builtin_llabs,
60         bk_gnu_builtin_malloc,
61         bk_gnu_builtin_memcmp,
62         bk_gnu_builtin_memcpy,
63         bk_gnu_builtin_memmove,
64         bk_gnu_builtin_memset,
65         bk_gnu_builtin_nan,
66         bk_gnu_builtin_nanf,
67         bk_gnu_builtin_nanl,
68         bk_gnu_builtin_object_size,
69         bk_gnu_builtin_parity,
70         bk_gnu_builtin_popcount,
71         bk_gnu_builtin_prefetch,
72         bk_gnu_builtin_return_address,
73         bk_gnu_builtin_snprintf,
74         bk_gnu_builtin_sprintf,
75         bk_gnu_builtin_stpcpy,
76         bk_gnu_builtin_strcat,
77         bk_gnu_builtin_strcmp,
78         bk_gnu_builtin_strcpy,
79         bk_gnu_builtin_strlen,
80         bk_gnu_builtin_strncat,
81         bk_gnu_builtin_strncpy,
82         bk_gnu_builtin_trap,
83         bk_gnu_builtin_va_end,
84         bk_gnu_builtin_vsnprintf,
85         bk_gnu_builtin_vsprintf,
86
87         bk_ms_AddressOfReturnAddress,
88         bk_ms_BitScanForward,
89         bk_ms_BitScanReverse,
90         bk_ms_InterlockedExchange,
91         bk_ms_InterlockedExchange64,
92         bk_ms_ReturnAddress,
93         bk_ms__debugbreak,
94         bk_ms__inbyte,
95         bk_ms__indword,
96         bk_ms__inword,
97         bk_ms__outbyte,
98         bk_ms__outdword,
99         bk_ms__outword,
100         bk_ms__popcount,
101         bk_ms__ud2,
102         bk_ms_byteswap_uint64,
103         bk_ms_byteswap_ulong,
104         bk_ms_byteswap_ushort,
105         bk_ms_disable,
106         bk_ms_enable,
107         bk_ms_rotl,
108         bk_ms_rotl64,
109         bk_ms_rotr,
110         bk_ms_rotr64,
111 } builtin_kind_t;
112
113 /**
114  * Create predefined gnu builtins.
115  */
116 void create_gnu_builtins(void);
117
118 /**
119  * Create predefined MS intrinsics.
120  */
121 void create_microsoft_intrinsics(void);
122
123 /**
124  * Some of the gnu builtins are simply more elaborate declarations of
125  * library functions. Return the library function name so we can simply
126  * replace the builtins with these during code generation
127  */
128 entity_t *get_builtin_replacement(const entity_t *builtin_entity);
129
130 int get_builtin_chk_arg_pos(builtin_kind_t kind);
131
132 #endif