LCOV - code coverage report
Current view: top level - gcc/rust/backend - rust-builtins.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 94.4 % 143 135
Test Date: 2026-11-14 16:39:50 Functions: 100.0 % 15 15
Legend: Lines:     hit not hit

            Line data    Source code
       1              : // This file is part of GCC.
       2              : 
       3              : // GCC is free software; you can redistribute it and/or modify it under
       4              : // the terms of the GNU General Public License as published by the Free
       5              : // Software Foundation; either version 3, or (at your option) any later
       6              : // version.
       7              : 
       8              : // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
       9              : // WARRANTY; without even the implied warranty of MERCHANTABILITY or
      10              : // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      11              : // for more details.
      12              : 
      13              : // You should have received a copy of the GNU General Public License
      14              : // along with GCC; see the file COPYING3.  If not see
      15              : // <http://www.gnu.org/licenses/>.
      16              : 
      17              : #include "expected.h"
      18              : #include "optional.h"
      19              : #include "rust-diagnostics.h"
      20              : #include "rust-system.h"
      21              : #include "rust-builtins.h"
      22              : 
      23              : #include "target.h"
      24              : #include "stringpool.h"
      25              : #include "rust-intrinsic-values.h"
      26              : 
      27              : namespace Rust {
      28              : namespace Compile {
      29              : 
      30              : BuiltinsContext &
      31     28174196 : BuiltinsContext::get ()
      32              : {
      33     28174196 :   static BuiltinsContext instance;
      34              : 
      35     28174196 :   if (instance.setup_state == SetupState::UNINITIALIZED)
      36         5410 :     instance.setup ();
      37              : 
      38     28174196 :   return instance;
      39              : }
      40              : 
      41              : tl::optional<tree>
      42        12909 : BuiltinsContext::lookup_simple_builtin (const std::string &name)
      43              : {
      44        12909 :   auto *to_search = &name;
      45              : 
      46        12909 :   auto it = rust_intrinsic_to_gcc_builtin.find (name);
      47        12909 :   if (it != rust_intrinsic_to_gcc_builtin.end ())
      48          449 :     to_search = &it->second;
      49              : 
      50        12909 :   return lookup_gcc_builtin (*to_search);
      51              : }
      52              : 
      53              : tl::expected<std::pair<tree, LlvmBuiltinAdapter>, LlvmBuiltinMappingError>
      54            5 : BuiltinsContext::map_llvm_to_gcc_builtin (const std::string &name)
      55              : {
      56            5 :   auto mapping = llvm_to_gcc_builtin.find (name);
      57            5 :   if (mapping == llvm_to_gcc_builtin.end ())
      58            0 :     return tl::make_unexpected (LlvmBuiltinMappingError::NotMapped ());
      59              : 
      60            5 :   if (auto lookup = lookup_gcc_builtin (mapping->second.gcc_name))
      61            5 :     return std::make_pair (*lookup, mapping->second.adapter);
      62              : 
      63            0 :   return tl::make_unexpected (LlvmBuiltinMappingError::TargetUnavailable ());
      64              : }
      65              : 
      66         5410 : BuiltinsContext::BuiltinsContext () : setup_state (SetupState::UNINITIALIZED) {}
      67              : 
      68              : /**
      69              :  * Define a function type according to `builtin-types.def`
      70              :  *
      71              :  * *Heavily* inspired by the D frontend's `def_fn_type` function
      72              :  */
      73              : void
      74      2753690 : BuiltinsContext::define_function_type (Type def_idx, Type ret_idx,
      75              :                                        bool is_variadic, size_t n, ...)
      76              : {
      77      2753690 :   va_list list;
      78      2753690 :   va_start (list, n);
      79              : 
      80      2753690 :   auto args = std::vector<tree> ();
      81              : 
      82      8829120 :   for (size_t i = 0; i < n; i++)
      83              :     {
      84              :       // The argument is an enum Type, but it's promoted to int when passed
      85              :       // though '...'.
      86      6075430 :       auto arg_idx = va_arg (list, int);
      87      6075430 :       auto arg_type = builtin_types[arg_idx];
      88              : 
      89      6075430 :       args.emplace_back (arg_type);
      90              :     }
      91              : 
      92      2753690 :   auto return_type = builtin_types[ret_idx];
      93      2753690 :   if (return_type == error_mark_node)
      94              :     {
      95              :       // Mark the builtin as not available.
      96        70330 :       builtin_types[def_idx] = error_mark_node;
      97        70330 :       va_end (list);
      98        70330 :       return;
      99              :     }
     100              : 
     101      2683360 :   auto fn_type = NULL_TREE;
     102      2683360 :   if (is_variadic)
     103       162300 :     fn_type = build_varargs_function_type_array (return_type, n, args.data ());
     104              :   else
     105      2521060 :     fn_type = build_function_type_array (return_type, n, args.data ());
     106              : 
     107      2683360 :   builtin_types[def_idx] = fn_type;
     108      2683360 :   va_end (list);
     109      2753690 : }
     110              : 
     111              : // Taken directly from the D frontend
     112              : static void
     113         5410 : build_c_type_nodes (void)
     114              : {
     115         5410 :   string_type_node = build_pointer_type (char_type_node);
     116         5410 :   const_string_type_node = build_pointer_type (
     117              :     build_qualified_type (char_type_node, TYPE_QUAL_CONST));
     118              : 
     119         5410 :   if (strcmp (UINTMAX_TYPE, "unsigned int") == 0)
     120              :     {
     121            0 :       intmax_type_node = integer_type_node;
     122            0 :       uintmax_type_node = unsigned_type_node;
     123              :     }
     124         5410 :   else if (strcmp (UINTMAX_TYPE, "long unsigned int") == 0)
     125              :     {
     126         5410 :       intmax_type_node = long_integer_type_node;
     127         5410 :       uintmax_type_node = long_unsigned_type_node;
     128              :     }
     129            0 :   else if (strcmp (UINTMAX_TYPE, "long long unsigned int") == 0)
     130              :     {
     131            0 :       intmax_type_node = long_long_integer_type_node;
     132            0 :       uintmax_type_node = long_long_unsigned_type_node;
     133              :     }
     134              :   else
     135            0 :     gcc_unreachable ();
     136              : 
     137         5410 :   signed_size_type_node = signed_type_for (size_type_node);
     138         5410 :   wint_type_node = unsigned_type_node;
     139         5410 :   pid_type_node = integer_type_node;
     140         5410 : }
     141              : 
     142              : /**
     143              :  * Define all builtin types in the `builtin_types` array
     144              :  */
     145              : void
     146         5410 : BuiltinsContext::define_builtin_types ()
     147              : {
     148              :   // This is taken directly from the D frontend's handling of builtins
     149         5410 :   auto va_list_ref_type_node = build_reference_type (va_list_type_node);
     150         5410 :   auto va_list_arg_type_node = va_list_type_node;
     151              : 
     152         5410 :   build_c_type_nodes ();
     153              : 
     154         5410 :   auto builtin_type_for_size = [] (int size, bool unsignedp) {
     155        27050 :     tree type = lang_hooks.types.type_for_size (size, unsignedp);
     156        27050 :     return type ? type : error_mark_node;
     157              :   };
     158              : 
     159              : #define DEF_PRIMITIVE_TYPE(ENUM, VALUE) builtin_types[ENUM] = VALUE;
     160              : #define DEF_FUNCTION_TYPE_0(ENUM, RETURN)                                      \
     161              :   define_function_type (ENUM, RETURN, 0, 0);
     162              : #define DEF_FUNCTION_TYPE_1(ENUM, RETURN, A1)                                  \
     163              :   define_function_type (ENUM, RETURN, 0, 1, A1);
     164              : #define DEF_FUNCTION_TYPE_2(ENUM, RETURN, A1, A2)                              \
     165              :   define_function_type (ENUM, RETURN, 0, 2, A1, A2);
     166              : #define DEF_FUNCTION_TYPE_3(ENUM, RETURN, A1, A2, A3)                          \
     167              :   define_function_type (ENUM, RETURN, 0, 3, A1, A2, A3);
     168              : #define DEF_FUNCTION_TYPE_4(ENUM, RETURN, A1, A2, A3, A4)                      \
     169              :   define_function_type (ENUM, RETURN, 0, 4, A1, A2, A3, A4);
     170              : #define DEF_FUNCTION_TYPE_5(ENUM, RETURN, A1, A2, A3, A4, A5)                  \
     171              :   define_function_type (ENUM, RETURN, 0, 5, A1, A2, A3, A4, A5);
     172              : #define DEF_FUNCTION_TYPE_6(ENUM, RETURN, A1, A2, A3, A4, A5, A6)              \
     173              :   define_function_type (ENUM, RETURN, 0, 6, A1, A2, A3, A4, A5, A6);
     174              : #define DEF_FUNCTION_TYPE_7(ENUM, RETURN, A1, A2, A3, A4, A5, A6, A7)          \
     175              :   define_function_type (ENUM, RETURN, 0, 7, A1, A2, A3, A4, A5, A6, A7);
     176              : #define DEF_FUNCTION_TYPE_8(ENUM, RETURN, A1, A2, A3, A4, A5, A6, A7, A8)      \
     177              :   define_function_type (ENUM, RETURN, 0, 8, A1, A2, A3, A4, A5, A6, A7, A8);
     178              : #define DEF_FUNCTION_TYPE_9(ENUM, RETURN, A1, A2, A3, A4, A5, A6, A7, A8, A9)  \
     179              :   define_function_type (ENUM, RETURN, 0, 9, A1, A2, A3, A4, A5, A6, A7, A8, A9);
     180              : #define DEF_FUNCTION_TYPE_10(ENUM, RETURN, A1, A2, A3, A4, A5, A6, A7, A8, A9, \
     181              :                              A10)                                              \
     182              :   define_function_type (ENUM, RETURN, 0, 10, A1, A2, A3, A4, A5, A6, A7, A8,   \
     183              :                         A9, A10);
     184              : #define DEF_FUNCTION_TYPE_11(ENUM, RETURN, A1, A2, A3, A4, A5, A6, A7, A8, A9, \
     185              :                              A10, A11)                                         \
     186              :   define_function_type (ENUM, RETURN, 0, 11, A1, A2, A3, A4, A5, A6, A7, A8,   \
     187              :                         A9, A10, A11);
     188              : #define DEF_FUNCTION_TYPE_VAR_0(ENUM, RETURN)                                  \
     189              :   define_function_type (ENUM, RETURN, 1, 0);
     190              : #define DEF_FUNCTION_TYPE_VAR_1(ENUM, RETURN, A1)                              \
     191              :   define_function_type (ENUM, RETURN, 1, 1, A1);
     192              : #define DEF_FUNCTION_TYPE_VAR_2(ENUM, RETURN, A1, A2)                          \
     193              :   define_function_type (ENUM, RETURN, 1, 2, A1, A2);
     194              : #define DEF_FUNCTION_TYPE_VAR_3(ENUM, RETURN, A1, A2, A3)                      \
     195              :   define_function_type (ENUM, RETURN, 1, 3, A1, A2, A3);
     196              : #define DEF_FUNCTION_TYPE_VAR_4(ENUM, RETURN, A1, A2, A3, A4)                  \
     197              :   define_function_type (ENUM, RETURN, 1, 4, A1, A2, A3, A4);
     198              : #define DEF_FUNCTION_TYPE_VAR_5(ENUM, RETURN, A1, A2, A3, A4, A5)              \
     199              :   define_function_type (ENUM, RETURN, 1, 5, A1, A2, A3, A4, A5);
     200              : #define DEF_FUNCTION_TYPE_VAR_6(ENUM, RETURN, A1, A2, A3, A4, A5, A6)          \
     201              :   define_function_type (ENUM, RETURN, 1, 6, A1, A2, A3, A4, A5, A6);
     202              : #define DEF_FUNCTION_TYPE_VAR_7(ENUM, RETURN, A1, A2, A3, A4, A5, A6, A7)      \
     203              :   define_function_type (ENUM, RETURN, 1, 7, A1, A2, A3, A4, A5, A6, A7);
     204              : #define DEF_FUNCTION_TYPE_VAR_11(ENUM, RETURN, A1, A2, A3, A4, A5, A6, A7, A8, \
     205              :                                  A9, A10, A11)                                 \
     206              :   define_function_type (ENUM, RETURN, 1, 11, A1, A2, A3, A4, A5, A6, A7, A8,   \
     207              :                         A9, A10, A11);
     208              : #define DEF_POINTER_TYPE(ENUM, TYPE)                                           \
     209              :   builtin_types[ENUM] = build_pointer_type (builtin_types[TYPE]);
     210              : 
     211              : #include "builtin-types.def"
     212              : 
     213              : #undef DEF_PRIMITIVE_TYPE
     214              : #undef DEF_FUNCTION_TYPE_1
     215              : #undef DEF_FUNCTION_TYPE_2
     216              : #undef DEF_FUNCTION_TYPE_3
     217              : #undef DEF_FUNCTION_TYPE_4
     218              : #undef DEF_FUNCTION_TYPE_5
     219              : #undef DEF_FUNCTION_TYPE_6
     220              : #undef DEF_FUNCTION_TYPE_7
     221              : #undef DEF_FUNCTION_TYPE_8
     222              : #undef DEF_FUNCTION_TYPE_9
     223              : #undef DEF_FUNCTION_TYPE_10
     224              : #undef DEF_FUNCTION_TYPE_11
     225              : #undef DEF_FUNCTION_TYPE_VAR_0
     226              : #undef DEF_FUNCTION_TYPE_VAR_1
     227              : #undef DEF_FUNCTION_TYPE_VAR_2
     228              : #undef DEF_FUNCTION_TYPE_VAR_3
     229              : #undef DEF_FUNCTION_TYPE_VAR_4
     230              : #undef DEF_FUNCTION_TYPE_VAR_5
     231              : #undef DEF_FUNCTION_TYPE_VAR_6
     232              : #undef DEF_FUNCTION_TYPE_VAR_7
     233              : #undef DEF_FUNCTION_TYPE_VAR_11
     234              : #undef DEF_POINTER_TYPE
     235              : 
     236         5410 :   builtin_types[Type::BT_LAST] = NULL_TREE;
     237         5410 : }
     238              : 
     239              : /**
     240              :  * Define all builtin attributes in the `builtin_types` array
     241              :  */
     242              : void
     243         5410 : BuiltinsContext::define_builtin_attributes ()
     244              : 
     245              : {
     246         5410 :   auto *built_in_attributes = builtin_attributes;
     247              : 
     248              : #define DEF_ATTR_NULL_TREE(ENUM) built_in_attributes[(int) ENUM] = NULL_TREE;
     249              : #define DEF_ATTR_INT(ENUM, VALUE)                                              \
     250              :   built_in_attributes[ENUM] = build_int_cst (integer_type_node, VALUE);
     251              : #define DEF_ATTR_STRING(ENUM, VALUE)                                           \
     252              :   built_in_attributes[ENUM] = build_string (strlen (VALUE), VALUE);
     253              : #define DEF_ATTR_IDENT(ENUM, STRING)                                           \
     254              :   built_in_attributes[ENUM] = get_identifier (STRING);
     255              : #define DEF_ATTR_TREE_LIST(ENUM, PURPOSE, VALUE, CHAIN)                        \
     256              :   built_in_attributes[ENUM]                                                    \
     257              :     = tree_cons (built_in_attributes[PURPOSE], built_in_attributes[VALUE],     \
     258              :                  built_in_attributes[CHAIN]);
     259              : #include "builtin-attrs.def"
     260              : #undef DEF_ATTR_NULL_TREE
     261              : #undef DEF_ATTR_INT
     262              : #undef DEF_ATTR_STRING
     263              : #undef DEF_ATTR_IDENT
     264              : #undef DEF_ATTR_TREE_LIST
     265         5410 : }
     266              : 
     267              : /**
     268              :  * Define all builtin functions during the first initialization of the
     269              :  * `BuiltinsContext`.
     270              :  */
     271              : void
     272         5410 : BuiltinsContext::define_builtins ()
     273              : {
     274         5410 :   auto *built_in_attributes = builtin_attributes;
     275      8147460 :   auto build_builtin = [this] (built_in_function fn_code, const char *fn_name,
     276              :                                built_in_class fn_class, tree fn_type, bool both,
     277              :                                bool fallback, tree attributes, bool implicit) {
     278      8142050 :     if (fn_type == error_mark_node)
     279      8142050 :       return;
     280              : 
     281      7703840 :     static auto to_skip = strlen ("__builtin_");
     282              : 
     283      7703840 :     auto libname = fn_name + to_skip;
     284      9992270 :     auto decl = add_builtin_function (fn_name, fn_type, fn_code, fn_class,
     285      7703840 :                                       fallback ? libname : NULL, attributes);
     286              : 
     287      7703840 :     set_builtin_decl (fn_code, decl, implicit);
     288              : 
     289      7703840 :     builtin_functions.insert ({std::string (fn_name), decl});
     290         5410 :   };
     291              : 
     292              : #define DEF_BUILTIN(ENUM, NAME, CLASS, TYPE, LIBTYPE, BOTH_P, FALLBACK_P,      \
     293              :                     NONANSI_P, ATTRS, IMPLICIT, COND)                          \
     294              :   if (NAME && COND)                                                            \
     295              :     build_builtin (ENUM, NAME, CLASS, builtin_types[TYPE], BOTH_P, FALLBACK_P, \
     296              :                    built_in_attributes[ATTRS], IMPLICIT);
     297              : #include "builtins.def"
     298              : #undef DEF_BUILTIN
     299         5410 : }
     300              : 
     301              : /**
     302              :  * Register direct mappings between Rust functions and GCC builtins
     303              :  */
     304              : void
     305         5410 : BuiltinsContext::register_rust_mappings ()
     306              : {
     307         5410 :   rust_intrinsic_to_gcc_builtin = {
     308              :     {Values::Intrinsics::UNREACHABLE, "__builtin_unreachable"},
     309              :     {Values::Intrinsics::ABORT, "__builtin_abort"},
     310              : 
     311              :     // Math intrinsics
     312              :     {Values::Intrinsics::SQRTF32, "__builtin_sqrtf"},
     313              :     {Values::Intrinsics::SQRTF64, "__builtin_sqrt"},
     314              : 
     315              :     {Values::Intrinsics::SINF32, "__builtin_sinf"},
     316              :     {Values::Intrinsics::SINF64, "__builtin_sin"},
     317              : 
     318              :     {Values::Intrinsics::COSF32, "__builtin_cosf"},
     319              :     {Values::Intrinsics::COSF64, "__builtin_cos"},
     320              : 
     321              :     {Values::Intrinsics::POWF32, "__builtin_powf"},
     322              :     {Values::Intrinsics::POWF64, "__builtin_pow"},
     323              : 
     324              :     {Values::Intrinsics::POWIF32, "__builtin_powif"},
     325              :     {Values::Intrinsics::POWIF64, "__builtin_powi"},
     326              : 
     327              :     {Values::Intrinsics::EXPF32, "__builtin_expf"},
     328              :     {Values::Intrinsics::EXPF64, "__builtin_exp"},
     329              : 
     330              :     {Values::Intrinsics::EXP2F32, "__builtin_exp2f"},
     331              :     {Values::Intrinsics::EXP2F64, "__builtin_exp2"},
     332              : 
     333              :     {Values::Intrinsics::LOGF32, "__builtin_logf"},
     334              :     {Values::Intrinsics::LOGF64, "__builtin_log"},
     335              : 
     336              :     {Values::Intrinsics::LOG10F32, "__builtin_log10f"},
     337              :     {Values::Intrinsics::LOG10F64, "__builtin_log10"},
     338              : 
     339              :     {Values::Intrinsics::LOG2F32, "__builtin_log2f"},
     340              :     {Values::Intrinsics::LOG2F64, "__builtin_log2"},
     341              : 
     342              :     {Values::Intrinsics::FMAF32, "__builtin_fmaf"},
     343              :     {Values::Intrinsics::FMAF64, "__builtin_fma"},
     344              : 
     345              :     {Values::Intrinsics::FABSF32, "__builtin_fabsf"},
     346              :     {Values::Intrinsics::FABSF64, "__builtin_fabs"},
     347              : 
     348              :     {Values::Intrinsics::MINNUMF32, "__builtin_fminf"},
     349              :     {Values::Intrinsics::MINNUMF64, "__builtin_fmin"},
     350              : 
     351              :     {Values::Intrinsics::MAXNUMF32, "__builtin_fmaxf"},
     352              :     {Values::Intrinsics::MAXNUMF64, "__builtin_fmax"},
     353              : 
     354              :     {Values::Intrinsics::COPYSIGNF32, "__builtin_copysignf"},
     355              :     {Values::Intrinsics::COPYSIGNF64, "__builtin_copysign"},
     356              : 
     357              :     {Values::Intrinsics::FLOORF32, "__builtin_floorf"},
     358              :     {Values::Intrinsics::FLOORF64, "__builtin_floor"},
     359              : 
     360              :     {Values::Intrinsics::CEILF32, "__builtin_ceilf"},
     361              :     {Values::Intrinsics::CEILF64, "__builtin_ceil"},
     362              : 
     363              :     {Values::Intrinsics::TRUNCF32, "__builtin_truncf"},
     364              :     {Values::Intrinsics::TRUNCF64, "__builtin_trunc"},
     365              : 
     366              :     {Values::Intrinsics::RINTF32, "__builtin_rintf"},
     367              :     {Values::Intrinsics::RINTF64, "__builtin_rint"},
     368              : 
     369              :     {Values::Intrinsics::NEARBYINTF32, "__builtin_nearbyintf"},
     370              :     {Values::Intrinsics::NEARBYINTF64, "__builtin_nearbyint"},
     371              : 
     372              :     {Values::Intrinsics::ROUNDF32, "__builtin_roundf"},
     373              :     {Values::Intrinsics::ROUNDF64, "__builtin_round"},
     374       243450 :   };
     375         5410 : }
     376              : 
     377              : void
     378         5410 : BuiltinsContext::register_llvm_to_gcc_builtin ()
     379              : {
     380         5410 :   llvm_to_gcc_builtin = {
     381         5410 :     {"llvm.x86.rdrand.16",
     382         5410 :      {"__builtin_ia32_rdrand16_step",
     383              :       LlvmBuiltinAdapter::OUTPUT_POINTER_VALUE_STATUS}},
     384        10820 :     {"llvm.x86.rdrand.32",
     385         5410 :      {"__builtin_ia32_rdrand32_step",
     386              :       LlvmBuiltinAdapter::OUTPUT_POINTER_VALUE_STATUS}},
     387        10820 :     {"llvm.x86.rdrand.64",
     388         5410 :      {"__builtin_ia32_rdrand64_step",
     389              :       LlvmBuiltinAdapter::OUTPUT_POINTER_VALUE_STATUS}},
     390        10820 :     {"llvm.x86.rdseed.16",
     391         5410 :      {"__builtin_ia32_rdseed_hi_step",
     392              :       LlvmBuiltinAdapter::OUTPUT_POINTER_VALUE_STATUS}},
     393        10820 :     {"llvm.x86.rdseed.32",
     394         5410 :      {"__builtin_ia32_rdseed_si_step",
     395              :       LlvmBuiltinAdapter::OUTPUT_POINTER_VALUE_STATUS}},
     396        10820 :     {"llvm.x86.rdseed.64",
     397         5410 :      {"__builtin_ia32_rdseed_di_step",
     398              :       LlvmBuiltinAdapter::OUTPUT_POINTER_VALUE_STATUS}},
     399              : 
     400        10820 :     {"llvm.x86.addcarry.32",
     401         5410 :      {"__builtin_ia32_addcarryx_u32",
     402              :       LlvmBuiltinAdapter::OUTPUT_POINTER_STATUS_VALUE}},
     403        10820 :     {"llvm.x86.addcarryx.u32",
     404         5410 :      {"__builtin_ia32_addcarryx_u32", LlvmBuiltinAdapter::FORWARD_ARGUMENTS}},
     405        10820 :     {"llvm.x86.subborrow.32",
     406         5410 :      {"__builtin_ia32_sbb_u32",
     407              :       LlvmBuiltinAdapter::OUTPUT_POINTER_STATUS_VALUE}},
     408        10820 :     {"llvm.x86.addcarry.64",
     409         5410 :      {"__builtin_ia32_addcarryx_u64",
     410              :       LlvmBuiltinAdapter::OUTPUT_POINTER_STATUS_VALUE}},
     411        10820 :     {"llvm.x86.addcarryx.u64",
     412         5410 :      {"__builtin_ia32_addcarryx_u64", LlvmBuiltinAdapter::FORWARD_ARGUMENTS}},
     413        10820 :     {"llvm.x86.subborrow.64",
     414         5410 :      {"__builtin_ia32_sbb_u64",
     415              :       LlvmBuiltinAdapter::OUTPUT_POINTER_STATUS_VALUE}},
     416              : 
     417        10820 :     {"llvm.x86.vcvtph2ps.128",
     418         5410 :      {"__builtin_ia32_vcvtph2ps", LlvmBuiltinAdapter::FORWARD_ARGUMENTS}},
     419        10820 :     {"llvm.x86.vcvtph2ps.256",
     420         5410 :      {"__builtin_ia32_vcvtph2ps256", LlvmBuiltinAdapter::FORWARD_ARGUMENTS}},
     421        10820 :     {"llvm.x86.vcvtps2ph.128",
     422         5410 :      {"__builtin_ia32_vcvtps2ph", LlvmBuiltinAdapter::FORWARD_ARGUMENTS}},
     423        10820 :     {"llvm.x86.vcvtps2ph.256",
     424         5410 :      {"__builtin_ia32_vcvtps2ph256", LlvmBuiltinAdapter::FORWARD_ARGUMENTS}},
     425       259680 :   };
     426         5410 : }
     427              : 
     428              : void
     429     28159050 : BuiltinsContext::register_builtin (tree decl)
     430              : {
     431     28159050 :   rust_assert (TREE_CODE (decl) == FUNCTION_DECL);
     432     28159050 :   rust_assert (DECL_NAME (decl));
     433              : 
     434     28159050 :   const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
     435     28159050 :   builtin_functions.insert ({std::string (name), decl});
     436     28159050 : }
     437              : 
     438              : void
     439         5410 : BuiltinsContext::setup ()
     440              : {
     441         5410 :   rust_assert (setup_state == SetupState::UNINITIALIZED);
     442         5410 :   setup_state = SetupState::INITIALIZING;
     443              : 
     444         5410 :   define_builtin_types ();
     445         5410 :   define_builtin_attributes ();
     446         5410 :   define_builtins ();
     447              : 
     448         5410 :   targetm.init_builtins ();
     449              : 
     450         5410 :   register_rust_mappings ();
     451         5410 :   register_llvm_to_gcc_builtin ();
     452              : 
     453         5410 :   setup_state = SetupState::READY;
     454         5410 : }
     455              : 
     456              : tl::optional<tree>
     457        12914 : BuiltinsContext::lookup_gcc_builtin (const std::string &name)
     458              : {
     459        12914 :   auto it = builtin_functions.find (name);
     460        12914 :   if (it == builtin_functions.end ())
     461         3969 :     return tl::nullopt;
     462              : 
     463         8945 :   return it->second;
     464              : }
     465              : 
     466              : } // namespace Compile
     467              : } // namespace Rust
        

Generated by: LCOV version 2.5.0-beta

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.