Add some more builtins to chibicc

https://justine.lol/cosmopolitan/documentation.html should now contain a
lot of functions that had been missing previously due to not having them
This commit is contained in:
Justine Tunney 2022-04-17 12:25:10 -07:00
parent ab38f0823d
commit f1dfa4bdfa
17 changed files with 417 additions and 201 deletions

View file

@ -1,7 +1,7 @@
/* ANSI-C code produced by gperf version 3.1 */
/* Command-line: gperf kw.gperf */
/* Computed positions: -k'1,4,11,14,$' */
/* clang-format off */
// clang-format off
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
@ -37,51 +37,44 @@
#line 10 "kw.gperf"
struct thatispacked KwSlot { char *name; unsigned char code; };
#define TOTAL_KEYWORDS 109
#define TOTAL_KEYWORDS 114
#define MIN_WORD_LENGTH 1
#define MAX_WORD_LENGTH 28
#define MIN_HASH_VALUE 1
#define MAX_HASH_VALUE 211
/* maximum key range = 211, duplicates = 0 */
#define MAX_HASH_VALUE 201
/* maximum key range = 201, duplicates = 0 */
#ifdef __GNUC__
__inline
#else
#ifdef __cplusplus
inline
#endif
#endif
static unsigned int
static inline unsigned int
hash (register const char *str, register size_t len)
{
static const unsigned char asso_values[] =
{
212, 212, 212, 212, 212, 212, 212, 212, 212, 212,
212, 212, 212, 212, 212, 212, 212, 212, 212, 212,
212, 212, 212, 212, 212, 212, 212, 212, 212, 212,
212, 212, 212, 105, 212, 212, 212, 212, 65, 212,
100, 95, 90, 15, 212, 0, 80, 212, 212, 212,
212, 212, 212, 212, 212, 212, 5, 212, 212, 212,
212, 212, 65, 212, 212, 212, 0, 212, 212, 212,
212, 212, 212, 212, 212, 212, 212, 212, 212, 212,
212, 212, 212, 212, 212, 212, 212, 212, 212, 212,
212, 212, 212, 212, 212, 5, 212, 20, 50, 0,
5, 15, 0, 25, 40, 90, 60, 0, 20, 15,
85, 105, 0, 25, 55, 10, 0, 65, 5, 0,
0, 10, 0, 30, 10, 25, 5, 212, 212, 212,
212, 212, 212, 212, 212, 212, 212, 212, 212, 212,
212, 212, 212, 212, 212, 212, 212, 212, 212, 212,
212, 212, 212, 212, 212, 212, 212, 212, 212, 212,
212, 212, 212, 212, 212, 212, 212, 212, 212, 212,
212, 212, 212, 212, 212, 212, 212, 212, 212, 212,
212, 212, 212, 212, 212, 212, 212, 212, 212, 212,
212, 212, 212, 212, 212, 212, 212, 212, 212, 212,
212, 212, 212, 212, 212, 212, 212, 212, 212, 212,
212, 212, 212, 212, 212, 212, 212, 212, 212, 212,
212, 212, 212, 212, 212, 212, 212, 212, 212, 212,
212, 212, 212, 212, 212, 212, 212, 212, 212, 212,
212, 212, 212, 212, 212, 212, 212, 212, 212, 212,
212, 212, 212, 212, 212, 212, 212
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
202, 202, 202, 100, 202, 202, 202, 202, 65, 202,
95, 90, 85, 15, 202, 0, 75, 202, 202, 202,
0, 202, 202, 202, 202, 202, 10, 202, 202, 202,
202, 202, 55, 202, 202, 202, 0, 202, 202, 202,
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
202, 202, 202, 202, 202, 5, 202, 0, 50, 0,
5, 15, 0, 40, 45, 115, 60, 5, 20, 15,
90, 85, 0, 0, 55, 10, 0, 65, 5, 0,
0, 10, 25, 70, 35, 30, 5, 202, 202, 202,
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
202, 202, 202, 202, 202, 202, 202, 202, 202, 202,
202, 202, 202, 202, 202, 202, 202
};
register unsigned int hval = len;
@ -135,24 +128,23 @@ LookupKw (register const char *str, register size_t len)
{"~", KW_TILDE},
#line 68 "kw.gperf"
{"_Atomic", KW__ATOMIC},
#line 81 "kw.gperf"
{"__typeof", KW_TYPEOF},
{""},
{""}, {""},
#line 78 "kw.gperf"
{"__restrict", KW_RESTRICT},
#line 22 "kw.gperf"
{"sizeof", KW_SIZEOF},
#line 75 "kw.gperf"
{"__asm__", KW___ASM__},
{""},
#line 41 "kw.gperf"
{"asm", KW_ASM},
#line 15 "kw.gperf"
{"case", KW_CASE},
#line 73 "kw.gperf"
{"__VA_OPT__", KW___VA_OPT__},
#line 13 "kw.gperf"
{"struct", KW_STRUCT},
#line 118 "kw.gperf"
{"||", KW_LOGOR},
#line 60 "kw.gperf"
{"strpbrk", KW_STRPBRK},
{""}, {""},
#line 31 "kw.gperf"
{"short", KW_SHORT},
@ -178,22 +170,19 @@ LookupKw (register const char *str, register size_t len)
{"while", KW_WHILE},
#line 85 "kw.gperf"
{"__builtin_compare_and_swap", KW___BUILTIN_COMPARE_AND_SWAP},
#line 101 "kw.gperf"
{"__builtin_strpbrk", KW___BUILTIN_STRPBRK},
#line 41 "kw.gperf"
{"asm", KW_ASM},
#line 82 "kw.gperf"
{"__builtin_add_overflow", KW___BUILTIN_ADD_OVERFLOW},
#line 81 "kw.gperf"
{"__typeof", KW_TYPEOF},
#line 55 "kw.gperf"
{"line", KW_LINE},
#line 86 "kw.gperf"
{"__builtin_constant_p", KW___BUILTIN_CONSTANT_P},
#line 74 "kw.gperf"
{"__alignof__", KW___ALIGNOF__},
#line 60 "kw.gperf"
{"strpbrk", KW_STRPBRK},
{""},
#line 47 "kw.gperf"
{"elif", KW_ELIF},
{""}, {""},
#line 101 "kw.gperf"
{"__builtin_strpbrk", KW___BUILTIN_STRPBRK},
{""}, {""}, {""}, {""},
#line 103 "kw.gperf"
{"__builtin_sub_overflow", KW___BUILTIN_SUB_OVERFLOW},
#line 72 "kw.gperf"
@ -202,8 +191,8 @@ LookupKw (register const char *str, register size_t len)
{"__builtin_popcountl", KW___BUILTIN_POPCOUNTL},
#line 97 "kw.gperf"
{"__builtin_popcountll", KW___BUILTIN_POPCOUNTLL},
#line 108 "kw.gperf"
{"}", KW_RB},
#line 56 "kw.gperf"
{"pragma", KW_PRAGMA},
#line 92 "kw.gperf"
{"__builtin_mul_overflow", KW___BUILTIN_MUL_OVERFLOW},
#line 104 "kw.gperf"
@ -213,15 +202,16 @@ LookupKw (register const char *str, register size_t len)
{"float", KW_FLOAT},
#line 87 "kw.gperf"
{"__builtin_expect", KW___BUILTIN_EXPECT},
#line 82 "kw.gperf"
{"__builtin_add_overflow", KW___BUILTIN_ADD_OVERFLOW},
#line 119 "kw.gperf"
{"->", KW_ARROW},
#line 20 "kw.gperf"
{"for", KW_FOR},
{""},
#line 47 "kw.gperf"
{"elif", KW_ELIF},
#line 91 "kw.gperf"
{"__builtin_fpclassify", KW___BUILTIN_FPCLASSIFY},
#line 107 "kw.gperf"
{"{", KW_LB},
#line 108 "kw.gperf"
{"}", KW_RB},
#line 42 "kw.gperf"
{"default", KW_DEFAULT},
{""},
@ -229,21 +219,19 @@ LookupKw (register const char *str, register size_t len)
{"__builtin_ffsl", KW___BUILTIN_FFSL},
#line 90 "kw.gperf"
{"__builtin_ffsll", KW___BUILTIN_FFSLL},
#line 56 "kw.gperf"
{"pragma", KW_PRAGMA},
#line 119 "kw.gperf"
{"->", KW_ARROW},
{""},
{""}, {""}, {""},
#line 18 "kw.gperf"
{"char", KW_CHAR},
#line 64 "kw.gperf"
{"undef", KW_UNDEF},
#line 61 "kw.gperf"
{"strstr", KW_STRSTR},
{""},
#line 118 "kw.gperf"
{"||", KW_LOGOR},
#line 67 "kw.gperf"
{"_Alignof", KW__ALIGNOF},
{""},
#line 122 "kw.gperf"
{"__sync_lock_test_and_set", KW___SYNC_LOCK_TEST_AND_SET},
#line 49 "kw.gperf"
{"error", KW_ERROR},
#line 58 "kw.gperf"
@ -261,19 +249,53 @@ LookupKw (register const char *str, register size_t len)
{""},
#line 66 "kw.gperf"
{"_Alignas", KW__ALIGNAS},
#line 123 "kw.gperf"
{"__sync_lock_release", KW___SYNC_LOCK_RELEASE},
{""},
#line 84 "kw.gperf"
{"__builtin_atomic_exchange", KW___BUILTIN_ATOMIC_EXCHANGE},
#line 39 "kw.gperf"
{"define", KW_DEFINE},
{""},
#line 35 "kw.gperf"
{"continue", KW_CONTINUE},
#line 24 "kw.gperf"
{"long", KW_LONG},
#line 43 "kw.gperf"
{"auto", KW_AUTO},
{""},
#line 99 "kw.gperf"
{"__builtin_strchr", KW___BUILTIN_STRCHR},
#line 21 "kw.gperf"
{"do", KW_DO},
{""}, {""}, {""}, {""}, {""},
#line 70 "kw.gperf"
{"_Generic", KW__GENERIC},
#line 98 "kw.gperf"
{"__builtin_reg_class", KW___BUILTIN_REG_CLASS},
{""},
#line 102 "kw.gperf"
{"__builtin_strstr", KW___BUILTIN_STRSTR},
#line 84 "kw.gperf"
{"__atomic_exchange", KW___ATOMIC_EXCHANGE},
#line 45 "kw.gperf"
{"__attribute__", KW___ATTRIBUTE__},
#line 83 "kw.gperf"
{"__builtin_assume_aligned", KW___BUILTIN_ASSUME_ALIGNED},
{""},
#line 32 "kw.gperf"
{"signed", KW_SIGNED},
{""},
#line 77 "kw.gperf"
{"__int128", KW___INT128},
#line 24 "kw.gperf"
{"long", KW_LONG},
#line 33 "kw.gperf"
{"break", KW_BREAK},
#line 50 "kw.gperf"
{"extern", KW_EXTERN},
{""},
#line 76 "kw.gperf"
{"__inline", KW_INLINE},
#line 46 "kw.gperf"
{"_Noreturn", KW__NORETURN},
{""}, {""},
#line 12 "kw.gperf"
{"if", KW_IF},
#line 54 "kw.gperf"
@ -281,37 +303,11 @@ LookupKw (register const char *str, register size_t len)
{""},
#line 37 "kw.gperf"
{"ifdef", KW_IFDEF},
{""}, {""}, {""},
#line 98 "kw.gperf"
{"__builtin_reg_class", KW___BUILTIN_REG_CLASS},
{""},
#line 102 "kw.gperf"
{"__builtin_strstr", KW___BUILTIN_STRSTR},
{""},
#line 45 "kw.gperf"
{"__attribute__", KW___ATTRIBUTE__},
{""},
#line 33 "kw.gperf"
{"break", KW_BREAK},
#line 50 "kw.gperf"
{"extern", KW_EXTERN},
{""},
#line 80 "kw.gperf"
{"__thread", KW__THREAD_LOCAL},
#line 46 "kw.gperf"
{"_Noreturn", KW__NORETURN},
{""},
#line 38 "kw.gperf"
{"ifndef", KW_IFNDEF},
#line 21 "kw.gperf"
{"do", KW_DO},
{""}, {""}, {""},
#line 59 "kw.gperf"
{"strlen", KW_STRLEN},
#line 52 "kw.gperf"
{"include_next", KW_INCLUDE_NEXT},
#line 70 "kw.gperf"
{"_Generic", KW__GENERIC},
{""},
#line 94 "kw.gperf"
{"__builtin_offsetof", KW___BUILTIN_OFFSETOF},
#line 34 "kw.gperf"
{"enum", KW_ENUM},
{""},
@ -319,62 +315,65 @@ LookupKw (register const char *str, register size_t len)
{"switch", KW_SWITCH},
#line 93 "kw.gperf"
{"__builtin_neg_overflow", KW___BUILTIN_NEG_OVERFLOW},
#line 77 "kw.gperf"
{"__int128", KW___INT128},
#line 83 "kw.gperf"
{"__builtin_assume_aligned", KW___BUILTIN_ASSUME_ALIGNED},
{""},
#line 32 "kw.gperf"
{"signed", KW_SIGNED},
#line 36 "kw.gperf"
{"include", KW_INCLUDE},
#line 57 "kw.gperf"
{"restrict", KW_RESTRICT},
#line 43 "kw.gperf"
{"auto", KW_AUTO},
#line 51 "kw.gperf"
{"goto", KW_GOTO},
{""},
#line 111 "kw.gperf"
{"&", KW_AMP},
#line 117 "kw.gperf"
{"&&", KW_LOGAND},
#line 76 "kw.gperf"
{"__inline", KW_INLINE},
#line 51 "kw.gperf"
{"goto", KW_GOTO},
{""}, {""}, {""},
#line 80 "kw.gperf"
{"__thread", KW__THREAD_LOCAL},
{""}, {""},
#line 38 "kw.gperf"
{"ifndef", KW_IFNDEF},
{""},
#line 23 "kw.gperf"
{"unsigned", KW_UNSIGNED},
{""}, {""},
#line 107 "kw.gperf"
{"{", KW_LB},
#line 52 "kw.gperf"
{"include_next", KW_INCLUDE_NEXT},
{""}, {""}, {""},
#line 100 "kw.gperf"
{"__builtin_strlen", KW___BUILTIN_STRLEN},
{""},
#line 94 "kw.gperf"
{"__builtin_offsetof", KW___BUILTIN_OFFSETOF},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 124 "kw.gperf"
{"__builtin_ia32_movntdq", KW___BUILTIN_IA32_MOVNTDQ},
{""}, {""}, {""},
#line 120 "kw.gperf"
{".", KW_DOT},
#line 36 "kw.gperf"
{"include", KW_INCLUDE},
{""}, {""}, {""},
#line 14 "kw.gperf"
{"return", KW_RETURN},
{""}, {""}, {""},
#line 26 "kw.gperf"
{"union", KW_UNION},
{""}, {""}, {""}, {""}, {""},
#line 120 "kw.gperf"
{".", KW_DOT},
#line 125 "kw.gperf"
{"__builtin_ia32_pmovmskb128", KW___BUILTIN_IA32_PMOVMSKB128},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 53 "kw.gperf"
{"inline", KW_INLINE},
{""}, {""}, {""}, {""}, {""}, {""},
#line 112 "kw.gperf"
{"*", KW_STAR},
{""},
#line 121 "kw.gperf"
{"__atomic_load", KW___ATOMIC_LOAD},
{""}, {""}, {""}, {""},
#line 44 "kw.gperf"
{"register", KW_REGISTER},
{""}, {""},
#line 112 "kw.gperf"
{"*", KW_STAR},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 106 "kw.gperf"
{")", KW_RP},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 105 "kw.gperf"
{"(", KW_LP},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""}, {""},
#line 53 "kw.gperf"
{"inline", KW_INLINE},
{""}, {""}, {""}, {""},
#line 113 "kw.gperf"
{"!", KW_EXCLAIM}
};