X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=inline;f=builtins.c;h=4a4215d6dac79c090fa3b2cd8a812a7f117ebed5;hb=86a26fbef4fa611787c8390a54955a9e998559b8;hp=368ab14d7439de3b196ca40ac13c0aa6c9094f4e;hpb=f9e3296bcef96ce8c60c422c17e6fc84f0b991c7;p=cparser diff --git a/builtins.c b/builtins.c index 368ab14..4a4215d 100644 --- a/builtins.c +++ b/builtins.c @@ -30,14 +30,12 @@ static entity_t *create_builtin_function(builtin_kind_t kind, const char *name, type_t *function_type) { - symbol_t *symbol = symbol_table_insert(name); - entity_t *entity = allocate_entity_zero(ENTITY_FUNCTION); + symbol_t *const symbol = symbol_table_insert(name); + entity_t *const entity = allocate_entity_zero(ENTITY_FUNCTION, NAMESPACE_NORMAL, symbol); entity->declaration.storage_class = STORAGE_CLASS_EXTERN; entity->declaration.declared_storage_class = STORAGE_CLASS_EXTERN; entity->declaration.type = function_type; entity->declaration.implicit = true; - entity->base.namespc = NAMESPACE_NORMAL; - entity->base.symbol = symbol; entity->base.source_position = builtin_source_position; entity->function.btk = kind; @@ -65,9 +63,17 @@ void create_gnu_builtins(void) GNU_BUILTIN(return_address, make_function_1_type(type_void_ptr, type_unsigned_int)); GNU_BUILTIN(frame_address, make_function_1_type(type_void_ptr, type_unsigned_int)); GNU_BUILTIN(ffs, make_function_1_type(type_int, type_unsigned_int)); + GNU_BUILTIN(ffsl, make_function_1_type(type_int, type_unsigned_long)); + GNU_BUILTIN(ffsll, make_function_1_type(type_int, type_unsigned_long_long)); GNU_BUILTIN(clz, make_function_1_type(type_int, type_unsigned_int)); + GNU_BUILTIN(clzl, make_function_1_type(type_int, type_unsigned_long)); + GNU_BUILTIN(clzll, make_function_1_type(type_int, type_unsigned_long_long)); GNU_BUILTIN(ctz, make_function_1_type(type_int, type_unsigned_int)); + GNU_BUILTIN(ctzl, make_function_1_type(type_int, type_unsigned_long)); + GNU_BUILTIN(ctzll, make_function_1_type(type_int, type_unsigned_long_long)); GNU_BUILTIN(popcount, make_function_1_type(type_int, type_unsigned_int)); + GNU_BUILTIN(popcountl, make_function_1_type(type_int, type_unsigned_long)); + GNU_BUILTIN(popcountll, make_function_1_type(type_int, type_unsigned_long_long)); GNU_BUILTIN(parity, make_function_1_type(type_int, type_unsigned_int)); GNU_BUILTIN(prefetch, make_function_1_type_variadic(type_float, type_void_ptr)); GNU_BUILTIN(trap, make_function_type(type_void, 0, NULL, DM_NORETURN)); @@ -176,9 +182,8 @@ entity_t *get_builtin_replacement(const entity_t *builtin_entity) if (replacement == NULL) return NULL; - entity_t *entity = allocate_entity_zero(ENTITY_FUNCTION); - entity->base.symbol = symbol_table_insert(replacement); - entity->base.namespc = NAMESPACE_NORMAL; + symbol_t *const symbol = symbol_table_insert(replacement); + entity_t *const entity = allocate_entity_zero(ENTITY_FUNCTION, NAMESPACE_NORMAL, symbol); entity->base.source_position = builtin_source_position; entity->declaration.storage_class = STORAGE_CLASS_EXTERN; entity->declaration.declared_storage_class = STORAGE_CLASS_EXTERN; @@ -221,14 +226,5 @@ void create_microsoft_intrinsics(void) MS_BUILTIN(_BitScanReverse, make_function_2_type(type_unsigned_char, type_unsigned_long_ptr, type_unsigned_long)); MS_BUILTIN(_InterlockedExchange, make_function_2_type(type_long, type_long_ptr, type_long)); MS_BUILTIN(_InterlockedExchange64, make_function_2_type(type_int64, type_int64_ptr, type_int64)); - - if (machine_size <= 32) { - MS_BUILTIN(__readeflags, make_function_0_type(type_unsigned_int)); - MS_BUILTIN(__writeeflags, make_function_1_type(type_void, type_unsigned_int)); - } else { - MS_BUILTIN(__readeflags, make_function_0_type(type_unsigned_int64)); - MS_BUILTIN(__writeeflags, make_function_1_type(type_void, type_unsigned_int64)); - } - #undef MS_BUILTIN }