source: libcfa/prelude/prototypes.awk @ db19e1d

Last change on this file since db19e1d was db19e1d, checked in by Andrew Beach <ajbeach@…>, 2 days ago

Changed the interpritation of () to be no parameters instead of any parameters. This had a lot of little changes because of this and some nearby clean-up. This includes some changes, including changing some generated functions to be fixed-args instead of variable-args, stripping out the place holder void parameter earlier, but it still shows up earlier in some cases that examine the parser directly. Also had to update the function generation tools. Have only tested with one --arch. Hopefully this all works out.

  • Property mode set to 100644
File size: 6.0 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 : Wed Nov  1 20:44:04 2023
13# Update Count     : 37
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 += 1 ) {
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                if ( index( "BT_LAST", prototype ) == 1 ) {
106                        continue
107                } # if
108
109                printf( "#define %s(NAME) FUNC_SIMPLE(", prototype )
110
111                if ( sub( "BT_FN_", "", prototype ) == 0 ) {
112                        printf( "\n********** BAD MACRO NAME \"%s\" **********\n", prototype )
113                        exit 0
114                } # if
115
116                # generate function return type as macro
117                for ( t = 0; t < N; t += 1 ) {                                  # find longest match
118                        type = types[t];
119                        if ( index( prototype, type ) == 1 ) {          # found match
120                                printf( "BT_%s, NAME", type )
121                                sub( type, "", prototype )
122                                break;
123                        } # if
124                } # for
125
126                # generate function parameter types as macro
127                for ( p = 0; length( prototype ) > 0; p += 1 ) { # until all parameters types are removed
128                        sub( "_", "", prototype)                                # remove "_"
129                        printf( ", ", type )
130                        temp = prototype
131                        for ( t = 0; t < N; t += 1 ) {                  # find longest match
132                                type = types[t];
133                                if ( index( prototype, type ) == 1 ) { # found match
134                                        printf( "BT_%s", type )
135                                        sub( type, "", prototype )
136                                        break;
137                                } # if
138                        } # for
139                        if ( temp == prototype ) {                              # no match found for parameter in macro table
140                                printf( "\n********** MISSING TYPE \"%s\" **********\n", prototype )
141                                exit 0
142                        } # if
143                } # for
144                printf( ")\n" )
145        } # for
146
147        # extras
148        printf( "\n#include \"builtins.def\"\n\n" );
149        printf( "\n#include \"sync-builtins.cfa\"\n\n" );
150        printf( "extern const char *__PRETTY_FUNCTION__;\n" );
151        printf( "float _Complex __builtin_complex( float, float );\n" );
152        printf( "double _Complex __builtin_complex( double, double );\n" );
153        printf( "long double _Complex __builtin_complex( long double, long double );\n" );
154} # END
155
156# Local Variables: #
157# tab-width: 4 #
158# mode: awk #
159# compile-command: "make install" #
160# End: #
Note: See TracBrowser for help on using the repository browser.