source: libcfa/prelude/prototypes.awk@ 1a40870

Last change on this file since 1a40870 was 88771d7, checked in by Peter A. Buhr <pabuhr@…>, 7 months ago

second attempt to move builtin types through the system

  • Property mode set to 100644
File size: 6.6 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 : Mon Mar 10 17:52:39 2025
13# Update Count : 73
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 int"
33 types[i+=1] = "ULONG"; vtypes[i] = "unsigned long int"
34 types[i+=1] = "UNSIGNED"; vtypes[i] = "unsigned int"
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 int"
41 types[i+=1] = "LONG"; vtypes[i] = "long int"
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 int"
70 size_t = i;
71 types[i+=1] = "VAR"; vtypes[i] = "..."
72 types[i+=1] = "VALIST_ARG"; vtypes[i] = "__builtin_va_list"
73 types[i+=1] = "VALIST_REF"; vtypes[i] = "__builtin_va_list"
74 types[i+=1] = "UNWINDWORD"; vtypes[i] = "void *"
75 types[i+=1] = "WORD"; vtypes[i] = ""
76 types[i+=1] = "SSIZE"; vtypes[i] = "long int"
77 ssize_t = i;
78 types[i+=1] = "PID"; vtypes[i] = "int"
79 types[i+=1] = "I16"; vtypes[i] = "__int128"
80 types[i+=1] = "I8"; vtypes[i] = "long long int"
81 types[i+=1] = "I4"; vtypes[i] = "int"
82 types[i+=1] = "I2"; vtypes[i] = "short int"
83 types[i+=1] = "I1"; vtypes[i] = "char"
84 N = i + 1
85} # BEGIN
86
87/BT_FN/ {
88 for (i = 1; i <= NF; i += 1 ) {
89 if ( match($i, "BT_FN") != 0 ) {
90 prototypes[$i] = $i
91 }
92 }
93}
94
95END {
96 # variable wordsize passed from Makefile
97 if ( index( wordsize, "-m32" ) != 0 ) { # adjust size_t/ssize_t for 32-bit build
98 vtypes[size_t] = "unsigned int"
99 vtypes[ssize_t] = "signed int"
100 } # if
101
102 printf( "#define DEF_BUILTIN(ENUM, NAME, CLASS, TYPE, LIBTYPE, BOTH_P, FALLBACK_P, NONANSI_P, ATTRS, IMPLICIT, COND) TYPE(NAME)\n" );
103 printf( "#define FUNC_SIMPLE(RETURN, NAME, ARGS...) RETURN NAME(ARGS);\n" );
104 printf( "#define BT_LAST(NAME) FUNC_SIMPLE(void, NAME)\n\n" );
105
106 # generate C types for macros names
107 for ( i = 0; i < N; i += 1 ) {
108 printf( "#define BT_%s %s\n", types[i], vtypes[i] )
109 } # for
110 printf( "\n" )
111
112 for ( prototype in prototypes ) {
113 if ( index( "BT_LAST", prototype ) == 1 ) {
114 continue
115 } # if
116
117 printf( "#define %s(NAME) FUNC_SIMPLE(", prototype )
118
119 if ( sub( "BT_FN_", "", prototype ) == 0 ) {
120 printf( "\n********** BAD MACRO NAME \"%s\" **********\n", prototype )
121 exit 0
122 } # if
123
124 # generate function return type as macro
125 for ( t = 0; t < N; t += 1 ) { # find longest match
126 type = types[t];
127 if ( index( prototype, type ) == 1 ) { # found match
128 printf( "BT_%s, NAME", type )
129 sub( type, "", prototype )
130 break;
131 } # if
132 } # for
133
134 # generate function parameter types as macro
135 for ( p = 0; length( prototype ) > 0; p += 1 ) { # until all parameters types are removed
136 sub( "_", "", prototype) # remove "_"
137 printf( ", ", type )
138 temp = prototype
139 for ( t = 0; t < N; t += 1 ) { # find longest match
140 type = types[t];
141 if ( index( prototype, type ) == 1 ) { # found match
142 printf( "BT_%s", type )
143 sub( type, "", prototype )
144 break;
145 } # if
146 } # for
147 if ( temp == prototype ) { # no match found for parameter in macro table
148 printf( "\n********** MISSING TYPE \"%s\" **********\n", prototype )
149 exit 0
150 } # if
151 } # for
152 printf( ")\n" )
153 } # for
154
155 # extras
156 printf( "\n#include \"builtins.def\"\n\n" );
157 printf( "\n#include \"sync-builtins.cfa\"\n\n" );
158 printf( "extern const char *__PRETTY_FUNCTION__;\n" );
159 printf( "float _Complex __builtin_complex( float, float );\n" );
160 printf( "double _Complex __builtin_complex( double, double );\n" );
161 printf( "long double _Complex __builtin_complex( long double, long double );\n" );
162
163 # assorted gcc builltin types
164 # ARM vector floating-point types, strip off text "__builtin.*__"
165 printf( "struct __builtin__Float32x4_t__ {};\n" );
166 printf( "struct __builtin__Float64x2_t__ {};\n" );
167 printf( "struct __builtin__SVFloat32_t__ {};\n" );
168 printf( "struct __builtin__SVFloat64_t__ {};\n" );
169 printf( "struct __builtin__SVBool_t__ {};\n" );
170} # END
171
172# Local Variables: #
173# tab-width: 4 #
174# mode: awk #
175# compile-command: "make install" #
176# End: #
Note: See TracBrowser for help on using the repository browser.