Mercurial > hg > CbC > CbC_gcc
comparison gcc/jit/jit-recording.c @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | 84e7813d76e9 |
children |
comparison
equal
deleted
inserted
replaced
131:84e7813d76e9 | 145:1830386684a0 |
---|---|
1 /* Internals of libgccjit: classes for recording calls made to the JIT API. | 1 /* Internals of libgccjit: classes for recording calls made to the JIT API. |
2 Copyright (C) 2013-2018 Free Software Foundation, Inc. | 2 Copyright (C) 2013-2020 Free Software Foundation, Inc. |
3 Contributed by David Malcolm <dmalcolm@redhat.com>. | 3 Contributed by David Malcolm <dmalcolm@redhat.com>. |
4 | 4 |
5 This file is part of GCC. | 5 This file is part of GCC. |
6 | 6 |
7 GCC is free software; you can redistribute it and/or modify it | 7 GCC is free software; you can redistribute it and/or modify it |
243 | 243 |
244 struct hash_traits : public string_hash | 244 struct hash_traits : public string_hash |
245 { | 245 { |
246 static void remove (const char *) {} | 246 static void remove (const char *) {} |
247 }; | 247 }; |
248 hash_set<const char *, hash_traits> m_set_identifiers; | 248 hash_set<const char *, false, hash_traits> m_set_identifiers; |
249 allocator m_allocator; | 249 allocator m_allocator; |
250 }; | 250 }; |
251 | 251 |
252 /* gcc::jit::reproducer's constructor. */ | 252 /* gcc::jit::reproducer's constructor. */ |
253 | 253 |
614 free (m_str_options[i]); | 614 free (m_str_options[i]); |
615 | 615 |
616 char *optname; | 616 char *optname; |
617 FOR_EACH_VEC_ELT (m_command_line_options, i, optname) | 617 FOR_EACH_VEC_ELT (m_command_line_options, i, optname) |
618 free (optname); | 618 free (optname); |
619 FOR_EACH_VEC_ELT (m_driver_options, i, optname) | |
620 free (optname); | |
619 | 621 |
620 if (m_builtins_manager) | 622 if (m_builtins_manager) |
621 delete m_builtins_manager; | 623 delete m_builtins_manager; |
622 | 624 |
623 if (m_owns_first_error_str) | 625 if (m_owns_first_error_str) |
868 new recording::field (this, loc, type, new_string (name)); | 870 new recording::field (this, loc, type, new_string (name)); |
869 record (result); | 871 record (result); |
870 return result; | 872 return result; |
871 } | 873 } |
872 | 874 |
875 /* Create a recording::bitfield instance and add it to this context's list | |
876 of mementos. | |
877 | |
878 Implements the post-error-checking part of | |
879 gcc_jit_context_new_bitfield. */ | |
880 | |
881 recording::field * | |
882 recording::context::new_bitfield (recording::location *loc, | |
883 recording::type *type, | |
884 int width, | |
885 const char *name) | |
886 { | |
887 recording::field *result = | |
888 new recording::bitfield (this, loc, type, width, new_string (name)); | |
889 record (result); | |
890 return result; | |
891 } | |
892 | |
873 /* Create a recording::struct_ instance and add it to this context's | 893 /* Create a recording::struct_ instance and add it to this context's |
874 list of mementos and list of compound types. | 894 list of mementos and list of compound types. |
875 | 895 |
876 Implements the post-error-checking part of | 896 Implements the post-error-checking part of |
877 gcc_jit_context_new_struct_type. */ | 897 gcc_jit_context_new_struct_type. */ |
1302 m_parent_ctxt->append_command_line_options (argvec); | 1322 m_parent_ctxt->append_command_line_options (argvec); |
1303 | 1323 |
1304 int i; | 1324 int i; |
1305 char *optname; | 1325 char *optname; |
1306 FOR_EACH_VEC_ELT (m_command_line_options, i, optname) | 1326 FOR_EACH_VEC_ELT (m_command_line_options, i, optname) |
1327 argvec->safe_push (xstrdup (optname)); | |
1328 } | |
1329 | |
1330 /* Add the given optname to this context's list of extra driver options. */ | |
1331 | |
1332 void | |
1333 recording::context::add_driver_option (const char *optname) | |
1334 { | |
1335 m_driver_options.safe_push (xstrdup (optname)); | |
1336 } | |
1337 | |
1338 /* Add any user-provided driver options, starting with any from | |
1339 parent contexts. | |
1340 Called by playback::context::invoke_driver. */ | |
1341 | |
1342 void | |
1343 recording::context::append_driver_options (auto_string_vec *argvec) | |
1344 { | |
1345 if (m_parent_ctxt) | |
1346 m_parent_ctxt->append_driver_options (argvec); | |
1347 | |
1348 int i; | |
1349 char *optname; | |
1350 | |
1351 FOR_EACH_VEC_ELT (m_driver_options, i, optname) | |
1307 argvec->safe_push (xstrdup (optname)); | 1352 argvec->safe_push (xstrdup (optname)); |
1308 } | 1353 } |
1309 | 1354 |
1310 /* Add the given dumpname/out_ptr pair to this context's list of requested | 1355 /* Add the given dumpname/out_ptr pair to this context's list of requested |
1311 dumps. | 1356 dumps. |
1797 r.write (" gcc_jit_context_add_command_line_option (%s, \"%s\");\n", | 1842 r.write (" gcc_jit_context_add_command_line_option (%s, \"%s\");\n", |
1798 r.get_identifier (contexts[ctxt_idx]), | 1843 r.get_identifier (contexts[ctxt_idx]), |
1799 optname); | 1844 optname); |
1800 } | 1845 } |
1801 | 1846 |
1847 if (!m_driver_options.is_empty ()) | |
1848 { | |
1849 int i; | |
1850 char *optname; | |
1851 r.write (" /* User-provided driver options. */\n"); | |
1852 FOR_EACH_VEC_ELT (m_driver_options, i, optname) | |
1853 r.write (" gcc_jit_context_add_driver_option (%s, \"%s\");\n", | |
1854 r.get_identifier (contexts[ctxt_idx]), | |
1855 optname); | |
1856 } | |
1857 | |
1802 if (m_requested_dumps.length ()) | 1858 if (m_requested_dumps.length ()) |
1803 { | 1859 { |
1804 r.write (" /* Requested dumps. */\n"); | 1860 r.write (" /* Requested dumps. */\n"); |
1805 /* Dumpfiles that were requested via gcc_jit_context_enable_dump. */ | 1861 /* Dumpfiles that were requested via gcc_jit_context_enable_dump. */ |
1806 for (unsigned i = 0; i < m_requested_dumps.length (); i++) | 1862 for (unsigned i = 0; i < m_requested_dumps.length (); i++) |
2922 | 2978 |
2923 /* Override the default implementation of | 2979 /* Override the default implementation of |
2924 recording::memento::write_to_dump. Dump each field | 2980 recording::memento::write_to_dump. Dump each field |
2925 by dumping a line of the form: | 2981 by dumping a line of the form: |
2926 TYPE NAME; | 2982 TYPE NAME; |
2927 so that we can build up a struct/union field-byfield. */ | 2983 so that we can build up a struct/union field by field. */ |
2928 | 2984 |
2929 void | 2985 void |
2930 recording::field::write_to_dump (dump &d) | 2986 recording::field::write_to_dump (dump &d) |
2931 { | 2987 { |
2932 d.write (" %s %s;\n", | 2988 d.write (" %s %s;\n", |
2957 id, | 3013 id, |
2958 r.get_identifier (get_context ()), | 3014 r.get_identifier (get_context ()), |
2959 r.get_identifier (m_loc), | 3015 r.get_identifier (m_loc), |
2960 r.get_identifier_as_type (m_type), | 3016 r.get_identifier_as_type (m_type), |
2961 m_name->get_debug_string ()); | 3017 m_name->get_debug_string ()); |
3018 } | |
3019 | |
3020 /* The implementation of class gcc::jit::recording::bitfield. */ | |
3021 | |
3022 /* Implementation of pure virtual hook recording::memento::replay_into | |
3023 for recording::bitfield. */ | |
3024 | |
3025 void | |
3026 recording::bitfield::replay_into (replayer *r) | |
3027 { | |
3028 set_playback_obj (r->new_bitfield (playback_location (r, m_loc), | |
3029 m_type->playback_type (), | |
3030 m_width, | |
3031 playback_string (m_name))); | |
3032 } | |
3033 | |
3034 /* Override the default implementation of | |
3035 recording::memento::write_to_dump. Dump each bit field | |
3036 by dumping a line of the form: | |
3037 TYPE NAME:WIDTH; | |
3038 so that we can build up a struct/union field by field. */ | |
3039 | |
3040 void | |
3041 recording::bitfield::write_to_dump (dump &d) | |
3042 { | |
3043 d.write (" %s %s:%d;\n", | |
3044 m_type->get_debug_string (), | |
3045 m_name->c_str (), | |
3046 m_width); | |
3047 } | |
3048 | |
3049 /* Implementation of recording::memento::make_debug_string for | |
3050 results of new_bitfield. */ | |
3051 | |
3052 recording::string * | |
3053 recording::bitfield::make_debug_string () | |
3054 { | |
3055 return string::from_printf (m_ctxt, | |
3056 "%s:%d", | |
3057 m_name->c_str (), m_width); | |
3058 } | |
3059 | |
3060 /* Implementation of recording::memento::write_reproducer for bitfields. */ | |
3061 | |
3062 void | |
3063 recording::bitfield::write_reproducer (reproducer &r) | |
3064 { | |
3065 const char *id = r.make_identifier (this, "bitfield"); | |
3066 r.write (" gcc_jit_field *%s =\n" | |
3067 " gcc_jit_context_new_bitfield (%s,\n" | |
3068 " %s, /* gcc_jit_location *loc */\n" | |
3069 " %s, /* gcc_jit_type *type, */\n" | |
3070 " %d, /* int width, */\n" | |
3071 " %s); /* const char *name */\n", | |
3072 id, | |
3073 r.get_identifier (get_context ()), | |
3074 r.get_identifier (m_loc), | |
3075 r.get_identifier_as_type (m_type), | |
3076 m_width, | |
3077 m_name->get_debug_string ()); | |
2962 } | 3078 } |
2963 | 3079 |
2964 /* The implementation of class gcc::jit::recording::compound_type */ | 3080 /* The implementation of class gcc::jit::recording::compound_type */ |
2965 | 3081 |
2966 /* The constructor for gcc::jit::recording::compound_type. */ | 3082 /* The constructor for gcc::jit::recording::compound_type. */ |
4770 "%s(%s)", | 4886 "%s(%s)", |
4771 unary_op_strings[m_op], | 4887 unary_op_strings[m_op], |
4772 m_a->get_debug_string ()); | 4888 m_a->get_debug_string ()); |
4773 } | 4889 } |
4774 | 4890 |
4775 static const char * const unary_op_reproducer_strings[] = { | 4891 const char * const unary_op_reproducer_strings[] = { |
4776 "GCC_JIT_UNARY_OP_MINUS", | 4892 "GCC_JIT_UNARY_OP_MINUS", |
4777 "GCC_JIT_UNARY_OP_BITWISE_NEGATE", | 4893 "GCC_JIT_UNARY_OP_BITWISE_NEGATE", |
4778 "GCC_JIT_UNARY_OP_LOGICAL_NEGATE", | 4894 "GCC_JIT_UNARY_OP_LOGICAL_NEGATE", |
4779 "GCC_JIT_UNARY_OP_ABS" | 4895 "GCC_JIT_UNARY_OP_ABS" |
4780 }; | 4896 }; |
4850 m_a->get_debug_string_parens (prec), | 4966 m_a->get_debug_string_parens (prec), |
4851 binary_op_strings[m_op], | 4967 binary_op_strings[m_op], |
4852 m_b->get_debug_string_parens (prec)); | 4968 m_b->get_debug_string_parens (prec)); |
4853 } | 4969 } |
4854 | 4970 |
4855 static const char * const binary_op_reproducer_strings[] = { | 4971 const char * const binary_op_reproducer_strings[] = { |
4856 "GCC_JIT_BINARY_OP_PLUS", | 4972 "GCC_JIT_BINARY_OP_PLUS", |
4857 "GCC_JIT_BINARY_OP_MINUS", | 4973 "GCC_JIT_BINARY_OP_MINUS", |
4858 "GCC_JIT_BINARY_OP_MULT", | 4974 "GCC_JIT_BINARY_OP_MULT", |
4859 "GCC_JIT_BINARY_OP_DIVIDE", | 4975 "GCC_JIT_BINARY_OP_DIVIDE", |
4860 "GCC_JIT_BINARY_OP_MODULO", | 4976 "GCC_JIT_BINARY_OP_MODULO", |