source: src/prelude/prototypes.awk@ fbcb354

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since fbcb354 was 8d6155e9, checked in by Thierry Delisle <tdelisle@…>, 9 years ago

Updated builtins to gcc-6.3
Cleaned builtin generation code
Added atomic builtins

  • Property mode set to 100644
File size: 6.8 KB
Line 
1#
2# Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
3#
4# The contents of this file are covered under the licence agreement in the
5# file "LICENCE" distributed with Cforall.
6#
7# prototypes.awk --
8#
9# Author : Peter A. Buhr
10# Created On : Sat May 16 07:57:37 2015
11# Last Modified By : Peter A. Buhr
12# Last Modified On : Tue Jul 5 14:32:52 2016
13# Update Count : 32
14#
15
16# http://llvm.org/svn/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def
17
18BEGIN {
19 FS = "[( )]"
20 # order so string search is longest string
21 i=-1
22 types[i+=1] = "BOOL"; vtypes[i] = "_Bool"
23 types[i+=1] = "UINTMAX"; vtypes[i] = "unsigned long int"
24 types[i+=1] = "UINT16"; vtypes[i] = "short int"
25 types[i+=1] = "UINT32"; vtypes[i] = "int"
26 types[i+=1] = "UINT64"; vtypes[i] = "long long int"
27 types[i+=1] = "UINT"; vtypes[i] = "unsigned int"
28 types[i+=1] = "INTMAX"; vtypes[i] = "long int"
29 types[i+=1] = "INTPTR"; vtypes[i] = "int *"
30 types[i+=1] = "WINT"; vtypes[i] = "unsigned int"
31 types[i+=1] = "INT"; vtypes[i] = "int"
32 types[i+=1] = "ULONGLONG"; vtypes[i] = "unsigned long long"
33 types[i+=1] = "ULONG"; vtypes[i] = "unsigned long"
34 types[i+=1] = "UNSIGNED"; vtypes[i] = "unsigned"
35 types[i+=1] = "COMPLEX_LONGDOUBLE"; vtypes[i] = "_Complex long double"
36 types[i+=1] = "COMPLEX_DOUBLE"; vtypes[i] = "_Complex double"
37 types[i+=1] = "COMPLEX_FLOAT"; vtypes[i] = "_Complex float"
38 types[i+=1] = "LONGDOUBLEPTR"; vtypes[i] = "long double *"
39 types[i+=1] = "LONGDOUBLE"; vtypes[i] = "long double"
40 types[i+=1] = "LONGLONG"; vtypes[i] = "long long"
41 types[i+=1] = "LONG"; vtypes[i] = "long"
42 types[i+=1] = "DFLOAT32"; vtypes[i] = "__Unsupported"
43 types[i+=1] = "DFLOAT64"; vtypes[i] = "__Unsupported"
44 types[i+=1] = "DFLOAT128"; vtypes[i] = "__Unsupported"
45 types[i+=1] = "DOUBLEPTR"; vtypes[i] = "double *"
46 types[i+=1] = "DOUBLE"; vtypes[i] = "double"
47 types[i+=1] = "FLOATPTR"; vtypes[i] = "float *"
48 types[i+=1] = "FLOAT128X"; vtypes[i] = "__Unsupported"
49 types[i+=1] = "FLOAT128"; vtypes[i] = "__Unsupported"
50 types[i+=1] = "FLOAT64X"; vtypes[i] = "__Unsupported"
51 types[i+=1] = "FLOAT64"; vtypes[i] = "__Unsupported"
52 types[i+=1] = "FLOAT32X"; vtypes[i] = "__Unsupported"
53 types[i+=1] = "FLOAT32"; vtypes[i] = "__Unsupported"
54 types[i+=1] = "FLOAT16"; vtypes[i] = "__Unsupported"
55 types[i+=1] = "FLOAT"; vtypes[i] = "float"
56 types[i+=1] = "CONST_VPTR"; vtypes[i] = "const volatile void *"
57 types[i+=1] = "CONST_PTR"; vtypes[i] = "const void *"
58 types[i+=1] = "CONST_STRING"; vtypes[i] = "const char *"
59 types[i+=1] = "CONST_TM_PTR"; vtypes[i] = "const struct tm *"
60 types[i+=1] = "PTR_FN_VOID_VAR_PTR_SIZE"; vtypes[i] = ""
61 types[i+=1] = "PTR_CONST_STRING"; vtypes[i] = "char *const"
62 types[i+=1] = "PTRMODE_PTR"; vtypes[i] = ""
63 types[i+=1] = "PTRPTR"; vtypes[i] = "void **"
64 types[i+=1] = "VPTR"; vtypes[i] = "volatile void *"
65 types[i+=1] = "PTR"; vtypes[i] = "void *"
66 types[i+=1] = "VOID"; vtypes[i] = "void"
67 types[i+=1] = "STRING"; vtypes[i] = "char *"
68 types[i+=1] = "FILEPTR"; vtypes[i] = "struct _IO_FILE *"
69 types[i+=1] = "SIZE"; vtypes[i] = "unsigned long"
70 types[i+=1] = "VAR"; vtypes[i] = "..."
71 types[i+=1] = "VALIST_ARG"; vtypes[i] = "__builtin_va_list"
72 types[i+=1] = "VALIST_REF"; vtypes[i] = "__builtin_va_list"
73 types[i+=1] = "UNWINDWORD"; vtypes[i] = "void *"
74 types[i+=1] = "WORD"; vtypes[i] = ""
75 types[i+=1] = "SSIZE"; vtypes[i] = "long int"
76 types[i+=1] = "PID"; vtypes[i] = "int"
77 types[i+=1] = "I16"; vtypes[i] = "__int128"
78 types[i+=1] = "I8"; vtypes[i] = "long long int"
79 types[i+=1] = "I4"; vtypes[i] = "int"
80 types[i+=1] = "I2"; vtypes[i] = "short"
81 types[i+=1] = "I1"; vtypes[i] = "char"
82 N = i + 1
83} # BEGIN
84
85/BT_FN/ {
86 for (i = 1; i <= NF; i++) {
87 if( match($i, "BT_FN") != 0 ) {
88 prototypes[$i] = $i
89 }
90 }
91 }
92
93END {
94 printf( "#define DEF_BUILTIN(ENUM, NAME, CLASS, TYPE, LIBTYPE, BOTH_P, FALLBACK_P, NONANSI_P, ATTRS, IMPLICIT, COND) TYPE(NAME)\n" );
95 printf( "#define FUNC_SIMPLE(RETURN, NAME, ARGS...) RETURN NAME(ARGS);\n" );
96 printf( "#define BT_LAST(NAME) FUNC_SIMPLE(void, NAME)\n\n" );
97
98 # generate C types for macros names
99 for ( i = 0; i < N; i += 1 ) {
100 printf( "#define BT_%s %s\n", types[i], vtypes[i] )
101 } # for
102 printf( "\n" )
103
104 for ( prototype in prototypes ) {
105 # printf( "//\"%s\"\n", prototype )
106 if ( index( "BT_LAST", prototype ) == 1 ) {
107 continue
108 } # if
109
110 printf( "#define %s(NAME) FUNC_SIMPLE(", prototype )
111
112 if ( sub( "BT_FN_", "", prototype ) == 0 ) {
113 printf( "\n********** BAD MACRO NAME \"%s\" **********\n", prototype )
114 exit 0
115 } # if
116
117 # generate function return type as macro
118 for ( t = 0; t < N; t += 1 ) { # find longest match
119 type = types[t];
120 if ( index( prototype, type ) == 1 ) { # found match
121 printf( "BT_%s, NAME", type )
122 sub( type, "", prototype )
123 break;
124 } # if
125 } # for
126
127 # generate function parameter types as macro
128 if ( index( prototype, "VAR" ) != 2 ) { # C-style empty parameters ?
129 for ( p = 0; length( prototype ) > 0; p += 1 ) { # until all parameters types are removed
130 sub( "_", "", prototype) # remove "_"
131 printf( ", ", type )
132 temp = prototype
133 for ( t = 0; t < N; t += 1 ) { # find longest match
134 type = types[t];
135 if ( index( prototype, type ) == 1 ) { # found match
136 printf( "BT_%s", type )
137 sub( type, "", prototype )
138 break;
139 } # if
140 } # for
141 if ( temp == prototype ) { # no match found for parameter in macro table
142 printf( "\n********** MISSING TYPE \"%s\" **********\n", prototype )
143 exit 0
144 } # if
145 } # for
146 } # if
147 printf( ")\n" )
148 } # for
149
150 # extras
151 printf( "\n#include \"builtins.def\"\n\n" );
152 printf( "extern const char *__PRETTY_FUNCTION__;\n" );
153} # END
154
155# Local Variables: #
156# tab-width: 4 #
157# mode: awk #
158# compile-command: "make install" #
159# End: #
Note: See TracBrowser for help on using the repository browser.