1 /* Internals of libgccjit: classes for recording calls made to the JIT API.
2 Copyright (C) 2013-2021 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GCC is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef JIT_RECORDING_H
22 #define JIT_RECORDING_H
24 #include "jit-common.h"
25 #include "jit-logging.h"
33 extern const char * const unary_op_reproducer_strings
[];
34 extern const char * const binary_op_reproducer_strings
[];
40 /**********************************************************************
42 **********************************************************************/
47 playback_location (replayer
*r
, location
*loc
);
50 playback_string (string
*str
);
53 playback_block (block
*b
);
55 /* A recording of a call to gcc_jit_context_enable_dump. */
58 const char *m_dumpname
;
62 /* A JIT-compilation context. */
63 class context
: public log_user
66 context (context
*parent_ctxt
);
70 get_builtins_manager ();
72 void record (memento
*m
);
73 void replay_into (replayer
*r
);
74 void disassociate_from_playback ();
77 new_string (const char *text
, bool escaped
= false);
80 new_location (const char *filename
,
83 bool created_by_user
);
86 get_type (enum gcc_jit_types type
);
89 get_int_type (int num_bytes
, int is_signed
);
92 new_array_type (location
*loc
,
97 new_field (location
*loc
,
102 new_bitfield (location
*loc
,
108 new_struct_type (location
*loc
,
112 new_union_type (location
*loc
,
116 new_function_type (type
*return_type
,
122 new_function_ptr_type (location
*loc
,
129 new_param (location
*loc
,
134 new_function (location
*loc
,
135 enum gcc_jit_function_kind kind
,
141 enum built_in_function builtin_id
);
144 get_builtin_function (const char *name
);
147 new_global (location
*loc
,
148 enum gcc_jit_global_kind kind
,
152 template <typename HOST_TYPE
>
154 new_rvalue_from_const (type
*type
,
158 new_string_literal (const char *value
);
161 new_rvalue_from_vector (location
*loc
,
166 new_unary_op (location
*loc
,
167 enum gcc_jit_unary_op op
,
172 new_binary_op (location
*loc
,
173 enum gcc_jit_binary_op op
,
175 rvalue
*a
, rvalue
*b
);
178 new_comparison (location
*loc
,
179 enum gcc_jit_comparison op
,
180 rvalue
*a
, rvalue
*b
);
183 new_call (location
*loc
,
185 int numargs
, rvalue
**args
);
188 new_call_through_ptr (location
*loc
,
190 int numargs
, rvalue
**args
);
193 new_cast (location
*loc
,
198 new_array_access (location
*loc
,
203 new_case (rvalue
*min_value
,
208 set_str_option (enum gcc_jit_str_option opt
,
212 set_int_option (enum gcc_jit_int_option opt
,
216 set_bool_option (enum gcc_jit_bool_option opt
,
220 set_inner_bool_option (enum inner_bool_option inner_opt
,
224 add_command_line_option (const char *optname
);
227 append_command_line_options (vec
<char *> *argvec
);
230 add_driver_option (const char *optname
);
233 append_driver_options (auto_string_vec
*argvec
);
236 enable_dump (const char *dumpname
,
240 get_str_option (enum gcc_jit_str_option opt
) const
242 return m_str_options
[opt
];
246 get_int_option (enum gcc_jit_int_option opt
) const
248 return m_int_options
[opt
];
252 get_bool_option (enum gcc_jit_bool_option opt
) const
254 return m_bool_options
[opt
];
258 get_inner_bool_option (enum inner_bool_option opt
) const
260 return m_inner_bool_options
[opt
];
267 compile_to_file (enum gcc_jit_output_kind output_kind
,
268 const char *output_path
);
271 add_error (location
*loc
, const char *fmt
, ...)
275 add_error_va (location
*loc
, const char *fmt
, va_list ap
)
279 get_first_error () const;
282 get_last_error () const;
284 bool errors_occurred () const
287 if (m_parent_ctxt
->errors_occurred ())
289 return m_error_count
;
292 type
*get_opaque_FILE_type ();
294 void dump_to_file (const char *path
, bool update_locations
);
296 void dump_reproducer_to_file (const char *path
);
299 get_all_requested_dumps (vec
<recording::requested_dump
> *out
);
301 void set_timer (timer
*t
) { m_timer
= t
; }
302 timer
*get_timer () const { return m_timer
; }
304 void add_top_level_asm (location
*loc
, const char *asm_stmts
);
307 void log_all_options () const;
308 void log_str_option (enum gcc_jit_str_option opt
) const;
309 void log_int_option (enum gcc_jit_int_option opt
) const;
310 void log_bool_option (enum gcc_jit_bool_option opt
) const;
311 void log_inner_bool_option (enum inner_bool_option opt
) const;
316 context
*m_parent_ctxt
;
318 /* The ultimate ancestor of the contexts within a family tree of
319 contexts. This has itself as its own m_toplevel_ctxt. */
320 context
*m_toplevel_ctxt
;
326 char *m_first_error_str
;
327 bool m_owns_first_error_str
;
329 char *m_last_error_str
;
330 bool m_owns_last_error_str
;
332 char *m_str_options
[GCC_JIT_NUM_STR_OPTIONS
];
333 int m_int_options
[GCC_JIT_NUM_INT_OPTIONS
];
334 bool m_bool_options
[GCC_JIT_NUM_BOOL_OPTIONS
];
335 bool m_inner_bool_options
[NUM_INNER_BOOL_OPTIONS
];
336 auto_vec
<char *> m_command_line_options
;
337 auto_vec
<char *> m_driver_options
;
339 /* Dumpfiles that were requested via gcc_jit_context_enable_dump. */
340 auto_vec
<requested_dump
> m_requested_dumps
;
342 /* Recorded API usage. */
343 auto_vec
<memento
*> m_mementos
;
345 /* Specific recordings, for use by dump_to_file. */
346 auto_vec
<compound_type
*> m_compound_types
;
347 auto_vec
<global
*> m_globals
;
348 auto_vec
<function
*> m_functions
;
349 auto_vec
<top_level_asm
*> m_top_level_asms
;
351 type
*m_basic_types
[NUM_GCC_JIT_TYPES
];
354 builtins_manager
*m_builtins_manager
; // lazily created
358 /* An object with lifetime managed by the context i.e.
359 it lives until the context is released, at which
360 point it itself is cleaned up. */
365 virtual ~memento () {}
367 /* Hook for replaying this. */
368 virtual void replay_into (replayer
*r
) = 0;
370 void set_playback_obj (void *obj
) { m_playback_obj
= obj
; }
373 /* Get the context that owns this object.
375 Implements the post-error-checking part of
376 gcc_jit_object_get_context. */
377 context
*get_context () { return m_ctxt
; }
380 as_object () { return this; }
382 /* Debugging hook, for use in generating error messages etc.
383 Implements the post-error-checking part of
384 gcc_jit_object_get_debug_string. */
388 virtual void write_to_dump (dump
&d
);
389 virtual void write_reproducer (reproducer
&r
) = 0;
390 virtual location
*dyn_cast_location () { return NULL
; }
393 memento (context
*ctxt
)
395 m_playback_obj (NULL
),
396 m_debug_string (NULL
)
401 string
*new_string (const char *text
) { return m_ctxt
->new_string (text
); }
404 virtual string
* make_debug_string () = 0;
410 void *m_playback_obj
;
413 string
*m_debug_string
;
416 /* or just use std::string? */
417 class string
: public memento
420 string (context
*ctxt
, const char *text
, bool escaped
);
423 const char *c_str () { return m_buffer
; }
425 static string
* from_printf (context
*ctxt
, const char *fmt
, ...)
428 void replay_into (replayer
*) FINAL OVERRIDE
{}
431 string
* make_debug_string () FINAL OVERRIDE
;
432 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
438 /* Flag to track if this string is the result of string::make_debug_string,
439 to avoid infinite recursion when logging all mementos: don't re-escape
444 class location
: public memento
447 location (context
*ctxt
, string
*filename
, int line
, int column
,
448 bool created_by_user
)
450 m_filename (filename
),
453 m_created_by_user (created_by_user
)
456 void replay_into (replayer
*r
) FINAL OVERRIDE
;
459 playback_location (replayer
*r
)
461 /* Normally during playback, we can walk forwards through the list of
462 recording objects, playing them back. The ordering of recording
463 ensures that everything that a recording object refers to has
464 already been played back, so we can simply look up the relevant
467 Locations are an exception, due to the "write_to_dump" method of
468 recording::statement. This method can set a new location on a
469 statement after the statement is created, and thus the location
470 appears in the context's memento list *after* the statement that
473 In such circumstances, the statement is replayed *before* the location,
474 when the latter doesn't yet have a playback object.
476 Hence we need to ensure that locations have playback objects. */
481 gcc_assert (m_playback_obj
);
482 return static_cast <playback::location
*> (m_playback_obj
);
485 location
*dyn_cast_location () FINAL OVERRIDE
{ return this; }
486 bool created_by_user () const { return m_created_by_user
; }
489 string
* make_debug_string () FINAL OVERRIDE
;
490 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
496 bool m_created_by_user
;
499 class type
: public memento
502 type
*get_pointer ();
504 type
*get_volatile ();
505 type
*get_aligned (size_t alignment_in_bytes
);
506 type
*get_vector (size_t num_units
);
508 /* Get the type obtained when dereferencing this type.
510 This will return NULL if it's not valid to dereference this type.
511 The caller is responsible for setting an error. */
512 virtual type
*dereference () = 0;
513 /* Get the type size in bytes.
515 This is implemented only for memento_of_get_type and
516 memento_of_get_pointer as it is used for initializing globals of
518 virtual size_t get_size () { gcc_unreachable (); }
521 virtual function_type
*dyn_cast_function_type () { return NULL
; }
522 virtual function_type
*as_a_function_type() { gcc_unreachable (); return NULL
; }
523 virtual struct_
*dyn_cast_struct () { return NULL
; }
524 virtual vector_type
*dyn_cast_vector_type () { return NULL
; }
526 /* Is it typesafe to copy to this type from rtype? */
527 virtual bool accepts_writes_from (type
*rtype
)
530 return this->unqualified ()->is_same_type_as (rtype
->unqualified ());
533 virtual bool is_same_type_as (type
*other
)
535 return this == other
;
538 /* Strip off "const" etc */
539 virtual type
*unqualified ()
544 virtual bool is_int () const = 0;
545 virtual bool is_float () const = 0;
546 virtual bool is_bool () const = 0;
547 virtual type
*is_pointer () = 0;
548 virtual type
*is_volatile () { return NULL
; }
549 virtual type
*is_const () { return NULL
; }
550 virtual type
*is_array () = 0;
551 virtual struct_
*is_struct () { return NULL
; }
552 virtual bool is_void () const { return false; }
553 virtual vector_type
*is_vector () { return NULL
; }
554 virtual bool has_known_size () const { return true; }
556 bool is_numeric () const
558 return is_int () || is_float () || is_bool ();
564 return static_cast <playback::type
*> (m_playback_obj
);
567 virtual const char *access_as_type (reproducer
&r
);
572 m_pointer_to_this_type (NULL
)
576 type
*m_pointer_to_this_type
;
579 /* Result of "gcc_jit_context_get_type". */
580 class memento_of_get_type
: public type
583 memento_of_get_type (context
*ctxt
,
584 enum gcc_jit_types kind
)
588 type
*dereference () FINAL OVERRIDE
;
590 size_t get_size () FINAL OVERRIDE
;
592 bool accepts_writes_from (type
*rtype
) FINAL OVERRIDE
594 if (m_kind
== GCC_JIT_TYPE_VOID_PTR
)
595 if (rtype
->is_pointer ())
597 /* LHS (this) is type (void *), and the RHS is a pointer:
602 return type::accepts_writes_from (rtype
);
605 bool is_int () const FINAL OVERRIDE
;
606 bool is_float () const FINAL OVERRIDE
;
607 bool is_bool () const FINAL OVERRIDE
;
608 type
*is_pointer () FINAL OVERRIDE
{ return dereference (); }
609 type
*is_array () FINAL OVERRIDE
{ return NULL
; }
610 bool is_void () const FINAL OVERRIDE
{ return m_kind
== GCC_JIT_TYPE_VOID
; }
613 void replay_into (replayer
*r
) FINAL OVERRIDE
;
616 string
* make_debug_string () FINAL OVERRIDE
;
617 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
620 enum gcc_jit_types m_kind
;
623 /* Result of "gcc_jit_type_get_pointer". */
624 class memento_of_get_pointer
: public type
627 memento_of_get_pointer (type
*other_type
)
628 : type (other_type
->m_ctxt
),
629 m_other_type (other_type
) {}
631 type
*dereference () FINAL OVERRIDE
{ return m_other_type
; }
633 size_t get_size () FINAL OVERRIDE
;
635 bool accepts_writes_from (type
*rtype
) FINAL OVERRIDE
;
637 void replay_into (replayer
*r
) FINAL OVERRIDE
;
639 bool is_int () const FINAL OVERRIDE
{ return false; }
640 bool is_float () const FINAL OVERRIDE
{ return false; }
641 bool is_bool () const FINAL OVERRIDE
{ return false; }
642 type
*is_pointer () FINAL OVERRIDE
{ return m_other_type
; }
643 type
*is_array () FINAL OVERRIDE
{ return NULL
; }
646 string
* make_debug_string () FINAL OVERRIDE
;
647 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
653 /* A decorated version of a type, for get_const, get_volatile,
654 get_aligned, and get_vector. */
656 class decorated_type
: public type
659 decorated_type (type
*other_type
)
660 : type (other_type
->m_ctxt
),
661 m_other_type (other_type
) {}
663 type
*dereference () FINAL OVERRIDE
{ return m_other_type
->dereference (); }
665 bool is_int () const FINAL OVERRIDE
{ return m_other_type
->is_int (); }
666 bool is_float () const FINAL OVERRIDE
{ return m_other_type
->is_float (); }
667 bool is_bool () const FINAL OVERRIDE
{ return m_other_type
->is_bool (); }
668 type
*is_pointer () FINAL OVERRIDE
{ return m_other_type
->is_pointer (); }
669 type
*is_array () FINAL OVERRIDE
{ return m_other_type
->is_array (); }
670 struct_
*is_struct () FINAL OVERRIDE
{ return m_other_type
->is_struct (); }
676 /* Result of "gcc_jit_type_get_const". */
677 class memento_of_get_const
: public decorated_type
680 memento_of_get_const (type
*other_type
)
681 : decorated_type (other_type
) {}
683 bool accepts_writes_from (type */
*rtype*/
) FINAL OVERRIDE
685 /* Can't write to a "const". */
689 /* Strip off the "const", giving the underlying type. */
690 type
*unqualified () FINAL OVERRIDE
{ return m_other_type
; }
692 virtual bool is_same_type_as (type
*other
)
694 if (!other
->is_const ())
696 return m_other_type
->is_same_type_as (other
->is_const ());
699 virtual type
*is_const () { return m_other_type
; }
701 void replay_into (replayer
*) FINAL OVERRIDE
;
704 string
* make_debug_string () FINAL OVERRIDE
;
705 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
708 /* Result of "gcc_jit_type_get_volatile". */
709 class memento_of_get_volatile
: public decorated_type
712 memento_of_get_volatile (type
*other_type
)
713 : decorated_type (other_type
) {}
715 virtual bool is_same_type_as (type
*other
)
717 if (!other
->is_volatile ())
719 return m_other_type
->is_same_type_as (other
->is_volatile ());
722 /* Strip off the "volatile", giving the underlying type. */
723 type
*unqualified () FINAL OVERRIDE
{ return m_other_type
; }
725 virtual type
*is_volatile () { return m_other_type
; }
727 void replay_into (replayer
*) FINAL OVERRIDE
;
730 string
* make_debug_string () FINAL OVERRIDE
;
731 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
734 /* Result of "gcc_jit_type_get_aligned". */
735 class memento_of_get_aligned
: public decorated_type
738 memento_of_get_aligned (type
*other_type
, size_t alignment_in_bytes
)
739 : decorated_type (other_type
),
740 m_alignment_in_bytes (alignment_in_bytes
) {}
742 /* Strip off the alignment, giving the underlying type. */
743 type
*unqualified () FINAL OVERRIDE
{ return m_other_type
; }
745 void replay_into (replayer
*) FINAL OVERRIDE
;
748 string
* make_debug_string () FINAL OVERRIDE
;
749 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
752 size_t m_alignment_in_bytes
;
755 /* Result of "gcc_jit_type_get_vector". */
756 class vector_type
: public decorated_type
759 vector_type (type
*other_type
, size_t num_units
)
760 : decorated_type (other_type
),
761 m_num_units (num_units
) {}
763 size_t get_num_units () const { return m_num_units
; }
765 vector_type
*dyn_cast_vector_type () FINAL OVERRIDE
{ return this; }
767 type
*get_element_type () { return m_other_type
; }
769 void replay_into (replayer
*) FINAL OVERRIDE
;
771 vector_type
*is_vector () FINAL OVERRIDE
{ return this; }
774 string
* make_debug_string () FINAL OVERRIDE
;
775 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
781 class array_type
: public type
784 array_type (context
*ctxt
,
790 m_element_type (element_type
),
791 m_num_elements (num_elements
)
794 type
*dereference () FINAL OVERRIDE
;
796 bool is_int () const FINAL OVERRIDE
{ return false; }
797 bool is_float () const FINAL OVERRIDE
{ return false; }
798 bool is_bool () const FINAL OVERRIDE
{ return false; }
799 type
*is_pointer () FINAL OVERRIDE
{ return NULL
; }
800 type
*is_array () FINAL OVERRIDE
{ return m_element_type
; }
801 int num_elements () { return m_num_elements
; }
803 void replay_into (replayer
*) FINAL OVERRIDE
;
806 string
* make_debug_string () FINAL OVERRIDE
;
807 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
811 type
*m_element_type
;
815 class function_type
: public type
818 function_type (context
*ctxt
,
824 type
*dereference () FINAL OVERRIDE
;
825 function_type
*dyn_cast_function_type () FINAL OVERRIDE
{ return this; }
826 function_type
*as_a_function_type () FINAL OVERRIDE
{ return this; }
828 bool is_same_type_as (type
*other
) FINAL OVERRIDE
;
830 bool is_int () const FINAL OVERRIDE
{ return false; }
831 bool is_float () const FINAL OVERRIDE
{ return false; }
832 bool is_bool () const FINAL OVERRIDE
{ return false; }
833 type
*is_pointer () FINAL OVERRIDE
{ return NULL
; }
834 type
*is_array () FINAL OVERRIDE
{ return NULL
; }
836 void replay_into (replayer
*) FINAL OVERRIDE
;
838 type
* get_return_type () const { return m_return_type
; }
839 const vec
<type
*> &get_param_types () const { return m_param_types
; }
840 int is_variadic () const { return m_is_variadic
; }
842 string
* make_debug_string_with_ptr ();
845 write_deferred_reproducer (reproducer
&r
,
849 string
* make_debug_string () FINAL OVERRIDE
;
850 string
* make_debug_string_with (const char *);
851 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
855 auto_vec
<type
*> m_param_types
;
859 class field
: public memento
862 field (context
*ctxt
,
873 type
* get_type () const { return m_type
; }
875 compound_type
* get_container () const { return m_container
; }
876 void set_container (compound_type
*c
) { m_container
= c
; }
878 void replay_into (replayer
*) OVERRIDE
;
880 void write_to_dump (dump
&d
) OVERRIDE
;
883 playback_field () const
885 return static_cast <playback::field
*> (m_playback_obj
);
889 string
* make_debug_string () OVERRIDE
;
890 void write_reproducer (reproducer
&r
) OVERRIDE
;
896 compound_type
*m_container
;
900 class bitfield
: public field
903 bitfield (context
*ctxt
,
908 : field (ctxt
, loc
, type
, name
),
912 void replay_into (replayer
*) FINAL OVERRIDE
;
914 void write_to_dump (dump
&d
) FINAL OVERRIDE
;
917 string
* make_debug_string () FINAL OVERRIDE
;
918 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
924 /* Base class for struct_ and union_ */
925 class compound_type
: public type
928 compound_type (context
*ctxt
,
932 string
*get_name () const { return m_name
; }
933 location
*get_loc () const { return m_loc
; }
934 fields
* get_fields () { return m_fields
; }
937 set_fields (location
*loc
,
941 type
*dereference () FINAL OVERRIDE
;
943 bool is_int () const FINAL OVERRIDE
{ return false; }
944 bool is_float () const FINAL OVERRIDE
{ return false; }
945 bool is_bool () const FINAL OVERRIDE
{ return false; }
946 type
*is_pointer () FINAL OVERRIDE
{ return NULL
; }
947 type
*is_array () FINAL OVERRIDE
{ return NULL
; }
949 bool has_known_size () const FINAL OVERRIDE
{ return m_fields
!= NULL
; }
951 playback::compound_type
*
952 playback_compound_type ()
954 return static_cast <playback::compound_type
*> (m_playback_obj
);
963 class struct_
: public compound_type
966 struct_ (context
*ctxt
,
970 struct_
*dyn_cast_struct () FINAL OVERRIDE
{ return this; }
973 as_type () { return this; }
975 void replay_into (replayer
*r
) FINAL OVERRIDE
;
977 const char *access_as_type (reproducer
&r
) FINAL OVERRIDE
;
979 struct_
*is_struct () FINAL OVERRIDE
{ return this; }
982 string
* make_debug_string () FINAL OVERRIDE
;
983 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
986 // memento of struct_::set_fields
987 class fields
: public memento
990 fields (compound_type
*struct_or_union
,
994 void replay_into (replayer
*r
) FINAL OVERRIDE
;
996 void write_to_dump (dump
&d
) FINAL OVERRIDE
;
998 int length () const { return m_fields
.length (); }
999 field
*get_field (int i
) const { return m_fields
[i
]; }
1002 string
* make_debug_string () FINAL OVERRIDE
;
1003 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1006 compound_type
*m_struct_or_union
;
1007 auto_vec
<field
*> m_fields
;
1010 class union_
: public compound_type
1013 union_ (context
*ctxt
,
1017 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1020 string
* make_debug_string () FINAL OVERRIDE
;
1021 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1024 /* An abstract base class for operations that visit all rvalues within an
1026 Currently the only implementation is class rvalue_usage_validator within
1029 class rvalue_visitor
1032 virtual ~rvalue_visitor () {}
1033 virtual void visit (rvalue
*rvalue
) = 0;
1036 /* When generating debug strings for rvalues we mimic C, so we need to
1037 mimic C's precedence levels when handling compound expressions.
1038 These are in order from strongest precedence to weakest. */
1045 PRECEDENCE_MULTIPLICATIVE
,
1046 PRECEDENCE_ADDITIVE
,
1048 PRECEDENCE_RELATIONAL
,
1049 PRECEDENCE_EQUALITY
,
1050 PRECEDENCE_BITWISE_AND
,
1051 PRECEDENCE_BITWISE_XOR
,
1052 PRECEDENCE_BITWISE_IOR
,
1053 PRECEDENCE_LOGICAL_AND
,
1054 PRECEDENCE_LOGICAL_OR
1057 class rvalue
: public memento
1060 rvalue (context
*ctxt
,
1067 m_parenthesized_string (NULL
)
1072 location
* get_loc () const { return m_loc
; }
1074 /* Get the recording::type of this rvalue.
1076 Implements the post-error-checking part of
1077 gcc_jit_rvalue_get_type. */
1078 type
* get_type () const { return m_type
; }
1081 playback_rvalue () const
1083 return static_cast <playback::rvalue
*> (m_playback_obj
);
1086 access_field (location
*loc
,
1090 dereference_field (location
*loc
,
1094 dereference (location
*loc
);
1097 verify_valid_within_stmt (const char *api_funcname
, statement
*s
);
1099 virtual void visit_children (rvalue_visitor
*v
) = 0;
1101 void set_scope (function
*scope
);
1102 function
*get_scope () const { return m_scope
; }
1104 /* Dynamic casts. */
1105 virtual param
*dyn_cast_param () { return NULL
; }
1106 virtual base_call
*dyn_cast_base_call () { return NULL
; }
1108 virtual const char *access_as_rvalue (reproducer
&r
);
1110 /* Get the debug string, wrapped in parentheses. */
1112 get_debug_string_parens (enum precedence outer_prec
);
1114 virtual bool is_constant () const { return false; }
1115 virtual bool get_wide_int (wide_int
*) const { return false; }
1118 virtual enum precedence
get_precedence () const = 0;
1125 function
*m_scope
; /* NULL for globals, non-NULL for locals/params */
1126 string
*m_parenthesized_string
;
1129 class lvalue
: public rvalue
1132 lvalue (context
*ctxt
,
1135 : rvalue (ctxt
, loc
, type_
),
1136 m_tls_model (GCC_JIT_TLS_MODEL_NONE
),
1137 m_link_section (NULL
)
1141 playback_lvalue () const
1143 return static_cast <playback::lvalue
*> (m_playback_obj
);
1147 access_field (location
*loc
,
1151 get_address (location
*loc
);
1154 as_rvalue () { return this; }
1156 const char *access_as_rvalue (reproducer
&r
) OVERRIDE
;
1157 virtual const char *access_as_lvalue (reproducer
&r
);
1158 virtual bool is_global () const { return false; }
1159 void set_tls_model (enum gcc_jit_tls_model model
);
1160 void set_link_section (const char *name
);
1163 enum gcc_jit_tls_model m_tls_model
;
1164 string
*m_link_section
;
1167 class param
: public lvalue
1170 param (context
*ctxt
,
1174 : lvalue (ctxt
, loc
, type
),
1178 as_lvalue () { return this; }
1180 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1182 void visit_children (rvalue_visitor
*) FINAL OVERRIDE
{}
1185 playback_param () const
1187 return static_cast <playback::param
*> (m_playback_obj
);
1190 param
*dyn_cast_param () FINAL OVERRIDE
{ return this; }
1192 const char *access_as_rvalue (reproducer
&r
) FINAL OVERRIDE
;
1193 const char *access_as_lvalue (reproducer
&r
) FINAL OVERRIDE
;
1196 string
* make_debug_string () FINAL OVERRIDE
{ return m_name
; }
1197 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1198 enum precedence
get_precedence () const FINAL OVERRIDE
1200 return PRECEDENCE_PRIMARY
;
1207 class function
: public memento
1210 function (context
*ctxt
,
1212 enum gcc_jit_function_kind kind
,
1218 enum built_in_function builtin_id
);
1220 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1222 playback::function
*
1223 playback_function () const
1225 return static_cast <playback::function
*> (m_playback_obj
);
1228 enum gcc_jit_function_kind
get_kind () const { return m_kind
; }
1231 new_local (location
*loc
,
1236 new_block (const char *name
);
1238 location
*get_loc () const { return m_loc
; }
1239 type
*get_return_type () const { return m_return_type
; }
1240 string
* get_name () const { return m_name
; }
1241 const vec
<param
*> &get_params () const { return m_params
; }
1243 /* Get the given param by index.
1244 Implements the post-error-checking part of
1245 gcc_jit_function_get_param. */
1246 param
*get_param (int i
) const { return m_params
[i
]; }
1248 bool is_variadic () const { return m_is_variadic
; }
1250 void write_to_dump (dump
&d
) FINAL OVERRIDE
;
1254 void dump_to_dot (const char *path
);
1256 rvalue
*get_address (location
*loc
);
1259 string
* make_debug_string () FINAL OVERRIDE
;
1260 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1264 enum gcc_jit_function_kind m_kind
;
1265 type
*m_return_type
;
1267 auto_vec
<param
*> m_params
;
1269 enum built_in_function m_builtin_id
;
1270 auto_vec
<local
*> m_locals
;
1271 auto_vec
<block
*> m_blocks
;
1272 type
*m_fn_ptr_type
;
1275 class block
: public memento
1278 block (function
*func
, int index
, string
*name
)
1279 : memento (func
->m_ctxt
),
1284 m_has_been_terminated (false),
1285 m_is_reachable (false)
1289 /* Get the recording::function containing this block.
1290 Implements the post-error-checking part of
1291 gcc_jit_block_get_function. */
1292 function
*get_function () { return m_func
; }
1294 bool has_been_terminated () { return m_has_been_terminated
; }
1295 bool is_reachable () { return m_is_reachable
; }
1298 add_eval (location
*loc
,
1302 add_assignment (location
*loc
,
1307 add_assignment_op (location
*loc
,
1309 enum gcc_jit_binary_op op
,
1313 add_comment (location
*loc
,
1317 add_extended_asm (location
*loc
,
1318 const char *asm_template
);
1321 end_with_conditional (location
*loc
,
1327 end_with_jump (location
*loc
,
1331 end_with_return (location
*loc
,
1335 end_with_switch (location
*loc
,
1337 block
*default_block
,
1342 end_with_extended_asm_goto (location
*loc
,
1343 const char *asm_template
,
1344 int num_goto_blocks
,
1345 block
**goto_blocks
,
1346 block
*fallthrough_block
);
1349 playback_block () const
1351 return static_cast <playback::block
*> (m_playback_obj
);
1354 void write_to_dump (dump
&d
) FINAL OVERRIDE
;
1358 location
*get_loc () const;
1360 statement
*get_first_statement () const;
1361 statement
*get_last_statement () const;
1363 vec
<block
*> get_successor_blocks () const;
1366 string
* make_debug_string () FINAL OVERRIDE
;
1367 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1369 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1371 void dump_to_dot (pretty_printer
*pp
);
1372 void dump_edges_to_dot (pretty_printer
*pp
);
1378 auto_vec
<statement
*> m_statements
;
1379 bool m_has_been_terminated
;
1380 bool m_is_reachable
;
1382 friend class function
;
1385 class global
: public lvalue
1388 global (context
*ctxt
,
1390 enum gcc_jit_global_kind kind
,
1393 : lvalue (ctxt
, loc
, type
),
1397 m_initializer
= NULL
;
1398 m_initializer_num_bytes
= 0;
1402 free (m_initializer
);
1405 void replay_into (replayer
*) FINAL OVERRIDE
;
1407 void visit_children (rvalue_visitor
*) FINAL OVERRIDE
{}
1409 void write_to_dump (dump
&d
) FINAL OVERRIDE
;
1411 bool is_global () const FINAL OVERRIDE
{ return true; }
1414 set_initializer (const void *initializer
,
1418 free (m_initializer
);
1419 m_initializer
= xmalloc (num_bytes
);
1420 memcpy (m_initializer
, initializer
, num_bytes
);
1421 m_initializer_num_bytes
= num_bytes
;
1425 string
* make_debug_string () FINAL OVERRIDE
{ return m_name
; }
1426 template <typename T
>
1427 void write_initializer_reproducer (const char *id
, reproducer
&r
);
1428 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1429 enum precedence
get_precedence () const FINAL OVERRIDE
1431 return PRECEDENCE_PRIMARY
;
1435 enum gcc_jit_global_kind m_kind
;
1437 void *m_initializer
;
1438 size_t m_initializer_num_bytes
;
1441 template <typename HOST_TYPE
>
1442 class memento_of_new_rvalue_from_const
: public rvalue
1445 memento_of_new_rvalue_from_const (context
*ctxt
,
1449 : rvalue (ctxt
, loc
, type
),
1452 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1454 void visit_children (rvalue_visitor
*) FINAL OVERRIDE
{}
1456 bool is_constant () const FINAL OVERRIDE
{ return true; }
1458 bool get_wide_int (wide_int
*out
) const FINAL OVERRIDE
;
1461 string
* make_debug_string () FINAL OVERRIDE
;
1462 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1463 enum precedence
get_precedence () const FINAL OVERRIDE
1465 return PRECEDENCE_PRIMARY
;
1472 class memento_of_new_string_literal
: public rvalue
1475 memento_of_new_string_literal (context
*ctxt
,
1478 : rvalue (ctxt
, loc
, ctxt
->get_type (GCC_JIT_TYPE_CONST_CHAR_PTR
)),
1481 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1483 void visit_children (rvalue_visitor
*) FINAL OVERRIDE
{}
1486 string
* make_debug_string () FINAL OVERRIDE
;
1487 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1488 enum precedence
get_precedence () const FINAL OVERRIDE
1490 return PRECEDENCE_PRIMARY
;
1497 class memento_of_new_rvalue_from_vector
: public rvalue
1500 memento_of_new_rvalue_from_vector (context
*ctxt
,
1505 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1507 void visit_children (rvalue_visitor
*) FINAL OVERRIDE
;
1510 string
* make_debug_string () FINAL OVERRIDE
;
1511 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1512 enum precedence
get_precedence () const FINAL OVERRIDE
1514 return PRECEDENCE_PRIMARY
;
1518 vector_type
*m_vector_type
;
1519 auto_vec
<rvalue
*> m_elements
;
1522 class unary_op
: public rvalue
1525 unary_op (context
*ctxt
,
1527 enum gcc_jit_unary_op op
,
1530 : rvalue (ctxt
, loc
, result_type
),
1535 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1537 void visit_children (rvalue_visitor
*v
) FINAL OVERRIDE
;
1540 string
* make_debug_string () FINAL OVERRIDE
;
1541 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1542 enum precedence
get_precedence () const FINAL OVERRIDE
1544 return PRECEDENCE_UNARY
;
1548 enum gcc_jit_unary_op m_op
;
1552 class binary_op
: public rvalue
1555 binary_op (context
*ctxt
,
1557 enum gcc_jit_binary_op op
,
1559 rvalue
*a
, rvalue
*b
)
1560 : rvalue (ctxt
, loc
, result_type
),
1565 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1567 void visit_children (rvalue_visitor
*v
) FINAL OVERRIDE
;
1570 string
* make_debug_string () FINAL OVERRIDE
;
1571 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1572 enum precedence
get_precedence () const FINAL OVERRIDE
;
1575 enum gcc_jit_binary_op m_op
;
1580 class comparison
: public rvalue
1583 comparison (context
*ctxt
,
1585 enum gcc_jit_comparison op
,
1586 rvalue
*a
, rvalue
*b
)
1587 : rvalue (ctxt
, loc
, ctxt
->get_type (GCC_JIT_TYPE_BOOL
)),
1593 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1595 void visit_children (rvalue_visitor
*v
) FINAL OVERRIDE
;
1598 string
* make_debug_string () FINAL OVERRIDE
;
1599 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1600 enum precedence
get_precedence () const FINAL OVERRIDE
;
1603 enum gcc_jit_comparison m_op
;
1608 class cast
: public rvalue
1611 cast (context
*ctxt
,
1615 : rvalue (ctxt
, loc
, type_
),
1619 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1621 void visit_children (rvalue_visitor
*v
) FINAL OVERRIDE
;
1624 string
* make_debug_string () FINAL OVERRIDE
;
1625 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1626 enum precedence
get_precedence () const FINAL OVERRIDE
1628 return PRECEDENCE_CAST
;
1635 class base_call
: public rvalue
1638 base_call (context
*ctxt
,
1644 enum precedence
get_precedence () const FINAL OVERRIDE
1646 return PRECEDENCE_POSTFIX
;
1649 base_call
*dyn_cast_base_call () FINAL OVERRIDE
{ return this; }
1651 void set_require_tail_call (bool require_tail_call
)
1653 m_require_tail_call
= require_tail_call
;
1657 void write_reproducer_tail_call (reproducer
&r
, const char *id
);
1660 auto_vec
<rvalue
*> m_args
;
1661 bool m_require_tail_call
;
1664 class call
: public base_call
1667 call (context
*ctxt
,
1673 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1675 void visit_children (rvalue_visitor
*v
) FINAL OVERRIDE
;
1678 string
* make_debug_string () FINAL OVERRIDE
;
1679 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1685 class call_through_ptr
: public base_call
1688 call_through_ptr (context
*ctxt
,
1694 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1696 void visit_children (rvalue_visitor
*v
) FINAL OVERRIDE
;
1699 string
* make_debug_string () FINAL OVERRIDE
;
1700 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1706 class array_access
: public lvalue
1709 array_access (context
*ctxt
,
1713 : lvalue (ctxt
, loc
, ptr
->get_type ()->dereference ()),
1718 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1720 void visit_children (rvalue_visitor
*v
) FINAL OVERRIDE
;
1723 string
* make_debug_string () FINAL OVERRIDE
;
1724 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1725 enum precedence
get_precedence () const FINAL OVERRIDE
1727 return PRECEDENCE_POSTFIX
;
1735 class access_field_of_lvalue
: public lvalue
1738 access_field_of_lvalue (context
*ctxt
,
1742 : lvalue (ctxt
, loc
, field
->get_type ()),
1747 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1749 void visit_children (rvalue_visitor
*v
) FINAL OVERRIDE
;
1752 string
* make_debug_string () FINAL OVERRIDE
;
1753 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1754 enum precedence
get_precedence () const FINAL OVERRIDE
1756 return PRECEDENCE_POSTFIX
;
1764 class access_field_rvalue
: public rvalue
1767 access_field_rvalue (context
*ctxt
,
1771 : rvalue (ctxt
, loc
, field
->get_type ()),
1776 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1778 void visit_children (rvalue_visitor
*v
) FINAL OVERRIDE
;
1781 string
* make_debug_string () FINAL OVERRIDE
;
1782 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1783 enum precedence
get_precedence () const FINAL OVERRIDE
1785 return PRECEDENCE_POSTFIX
;
1793 class dereference_field_rvalue
: public lvalue
1796 dereference_field_rvalue (context
*ctxt
,
1800 : lvalue (ctxt
, loc
, field
->get_type ()),
1805 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1807 void visit_children (rvalue_visitor
*v
) FINAL OVERRIDE
;
1810 string
* make_debug_string () FINAL OVERRIDE
;
1811 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1812 enum precedence
get_precedence () const FINAL OVERRIDE
1814 return PRECEDENCE_POSTFIX
;
1822 class dereference_rvalue
: public lvalue
1825 dereference_rvalue (context
*ctxt
,
1828 : lvalue (ctxt
, loc
, val
->get_type ()->dereference ()),
1831 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1833 void visit_children (rvalue_visitor
*v
) FINAL OVERRIDE
;
1836 string
* make_debug_string () FINAL OVERRIDE
;
1837 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1838 enum precedence
get_precedence () const FINAL OVERRIDE
1840 return PRECEDENCE_UNARY
;
1847 class get_address_of_lvalue
: public rvalue
1850 get_address_of_lvalue (context
*ctxt
,
1853 : rvalue (ctxt
, loc
, val
->get_type ()->get_pointer ()),
1857 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1859 void visit_children (rvalue_visitor
*v
) FINAL OVERRIDE
;
1862 string
* make_debug_string () FINAL OVERRIDE
;
1863 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1864 enum precedence
get_precedence () const FINAL OVERRIDE
1866 return PRECEDENCE_UNARY
;
1873 class function_pointer
: public rvalue
1876 function_pointer (context
*ctxt
,
1880 : rvalue (ctxt
, loc
, type
),
1883 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1885 void visit_children (rvalue_visitor
*v
) FINAL OVERRIDE
;
1888 string
* make_debug_string () FINAL OVERRIDE
;
1889 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1890 enum precedence
get_precedence () const FINAL OVERRIDE
1892 return PRECEDENCE_UNARY
;
1899 class local
: public lvalue
1902 local (function
*func
, location
*loc
, type
*type_
, string
*name
)
1903 : lvalue (func
->m_ctxt
, loc
, type_
),
1910 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1912 void visit_children (rvalue_visitor
*) FINAL OVERRIDE
{}
1914 void write_to_dump (dump
&d
) FINAL OVERRIDE
;
1917 string
* make_debug_string () FINAL OVERRIDE
{ return m_name
; }
1918 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1919 enum precedence
get_precedence () const FINAL OVERRIDE
1921 return PRECEDENCE_PRIMARY
;
1929 class statement
: public memento
1932 virtual vec
<block
*> get_successor_blocks () const;
1934 void write_to_dump (dump
&d
) FINAL OVERRIDE
;
1936 block
*get_block () const { return m_block
; }
1937 location
*get_loc () const { return m_loc
; }
1940 statement (block
*b
, location
*loc
)
1941 : memento (b
->m_ctxt
),
1945 playback::location
*
1946 playback_location (replayer
*r
) const
1948 return ::gcc::jit::recording::playback_location (r
, m_loc
);
1956 class eval
: public statement
1962 : statement (b
, loc
),
1963 m_rvalue (rvalue
) {}
1965 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1968 string
* make_debug_string () FINAL OVERRIDE
;
1969 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1975 class assignment
: public statement
1978 assignment (block
*b
,
1982 : statement (b
, loc
),
1984 m_rvalue (rvalue
) {}
1986 void replay_into (replayer
*r
) FINAL OVERRIDE
;
1989 string
* make_debug_string () FINAL OVERRIDE
;
1990 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
1997 class assignment_op
: public statement
2000 assignment_op (block
*b
,
2003 enum gcc_jit_binary_op op
,
2005 : statement (b
, loc
),
2008 m_rvalue (rvalue
) {}
2010 void replay_into (replayer
*r
) FINAL OVERRIDE
;
2013 string
* make_debug_string () FINAL OVERRIDE
;
2014 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
2018 enum gcc_jit_binary_op m_op
;
2022 class comment
: public statement
2028 : statement (b
, loc
),
2031 void replay_into (replayer
*r
) FINAL OVERRIDE
;
2034 string
* make_debug_string () FINAL OVERRIDE
;
2035 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
2041 class conditional
: public statement
2044 conditional (block
*b
,
2049 : statement (b
, loc
),
2050 m_boolval (boolval
),
2051 m_on_true (on_true
),
2052 m_on_false (on_false
) {}
2054 void replay_into (replayer
*r
) FINAL OVERRIDE
;
2056 vec
<block
*> get_successor_blocks () const FINAL OVERRIDE
;
2059 string
* make_debug_string () FINAL OVERRIDE
;
2060 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
2068 class jump
: public statement
2074 : statement (b
, loc
),
2075 m_target (target
) {}
2077 void replay_into (replayer
*r
) FINAL OVERRIDE
;
2079 vec
<block
*> get_successor_blocks () const FINAL OVERRIDE
;
2082 string
* make_debug_string () FINAL OVERRIDE
;
2083 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
2089 class return_
: public statement
2095 : statement (b
, loc
),
2096 m_rvalue (rvalue
) {}
2098 void replay_into (replayer
*r
) FINAL OVERRIDE
;
2100 vec
<block
*> get_successor_blocks () const FINAL OVERRIDE
;
2103 string
* make_debug_string () FINAL OVERRIDE
;
2104 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
2110 class case_
: public memento
2113 case_ (context
*ctxt
,
2118 m_min_value (min_value
),
2119 m_max_value (max_value
),
2120 m_dest_block (dest_block
)
2123 rvalue
*get_min_value () const { return m_min_value
; }
2124 rvalue
*get_max_value () const { return m_max_value
; }
2125 block
*get_dest_block () const { return m_dest_block
; }
2127 void replay_into (replayer
*) FINAL OVERRIDE
{ /* empty */ }
2129 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
2132 string
* make_debug_string () FINAL OVERRIDE
;
2135 rvalue
*m_min_value
;
2136 rvalue
*m_max_value
;
2137 block
*m_dest_block
;
2140 class switch_
: public statement
2146 block
*default_block
,
2150 void replay_into (replayer
*r
) FINAL OVERRIDE
;
2152 vec
<block
*> get_successor_blocks () const FINAL OVERRIDE
;
2155 string
* make_debug_string () FINAL OVERRIDE
;
2156 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
2160 block
*m_default_block
;
2161 auto_vec
<case_
*> m_cases
;
2164 class asm_operand
: public memento
2167 asm_operand (extended_asm
*ext_asm
,
2168 string
*asm_symbolic_name
,
2169 string
*constraint
);
2171 const char *get_symbolic_name () const
2173 if (m_asm_symbolic_name
)
2174 return m_asm_symbolic_name
->c_str ();
2179 const char *get_constraint () const
2181 return m_constraint
->c_str ();
2184 virtual void print (pretty_printer
*pp
) const;
2187 string
* make_debug_string () FINAL OVERRIDE
;
2190 extended_asm
*m_ext_asm
;
2191 string
*m_asm_symbolic_name
;
2192 string
*m_constraint
;
2195 class output_asm_operand
: public asm_operand
2198 output_asm_operand (extended_asm
*ext_asm
,
2199 string
*asm_symbolic_name
,
2202 : asm_operand (ext_asm
, asm_symbolic_name
, constraint
),
2206 lvalue
*get_lvalue () const { return m_dest
; }
2208 void replay_into (replayer
*) FINAL OVERRIDE
{}
2210 void print (pretty_printer
*pp
) const FINAL OVERRIDE
;
2213 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
2219 class input_asm_operand
: public asm_operand
2222 input_asm_operand (extended_asm
*ext_asm
,
2223 string
*asm_symbolic_name
,
2226 : asm_operand (ext_asm
, asm_symbolic_name
, constraint
),
2230 rvalue
*get_rvalue () const { return m_src
; }
2232 void replay_into (replayer
*) FINAL OVERRIDE
{}
2234 void print (pretty_printer
*pp
) const FINAL OVERRIDE
;
2237 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
2243 /* Abstract base class for extended_asm statements. */
2245 class extended_asm
: public statement
2248 extended_asm (block
*b
,
2250 string
*asm_template
)
2251 : statement (b
, loc
),
2252 m_asm_template (asm_template
),
2253 m_is_volatile (false),
2257 void set_volatile_flag (bool flag
) { m_is_volatile
= flag
; }
2258 void set_inline_flag (bool flag
) { m_is_inline
= flag
; }
2260 void add_output_operand (const char *asm_symbolic_name
,
2261 const char *constraint
,
2263 void add_input_operand (const char *asm_symbolic_name
,
2264 const char *constraint
,
2266 void add_clobber (const char *victim
);
2268 void replay_into (replayer
*r
) OVERRIDE
;
2270 string
*get_asm_template () const { return m_asm_template
; }
2272 virtual bool is_goto () const = 0;
2273 virtual void maybe_print_gotos (pretty_printer
*) const = 0;
2276 void write_flags (reproducer
&r
);
2277 void write_clobbers (reproducer
&r
);
2280 string
* make_debug_string () FINAL OVERRIDE
;
2281 virtual void maybe_populate_playback_blocks
2282 (auto_vec
<playback::block
*> *out
) = 0;
2285 string
*m_asm_template
;
2288 auto_vec
<output_asm_operand
*> m_output_ops
;
2289 auto_vec
<input_asm_operand
*> m_input_ops
;
2290 auto_vec
<string
*> m_clobbers
;
2293 /* An extended_asm that's not a goto, as created by
2294 gcc_jit_block_add_extended_asm. */
2296 class extended_asm_simple
: public extended_asm
2299 extended_asm_simple (block
*b
,
2301 string
*asm_template
)
2302 : extended_asm (b
, loc
, asm_template
)
2305 void write_reproducer (reproducer
&r
) OVERRIDE
;
2306 bool is_goto () const FINAL OVERRIDE
{ return false; }
2307 void maybe_print_gotos (pretty_printer
*) const FINAL OVERRIDE
{}
2310 void maybe_populate_playback_blocks
2311 (auto_vec
<playback::block
*> *) FINAL OVERRIDE
2315 /* An extended_asm that's a asm goto, as created by
2316 gcc_jit_block_end_with_extended_asm_goto. */
2318 class extended_asm_goto
: public extended_asm
2321 extended_asm_goto (block
*b
,
2323 string
*asm_template
,
2324 int num_goto_blocks
,
2325 block
**goto_blocks
,
2326 block
*fallthrough_block
);
2328 void replay_into (replayer
*r
) FINAL OVERRIDE
;
2329 void write_reproducer (reproducer
&r
) OVERRIDE
;
2331 vec
<block
*> get_successor_blocks () const FINAL OVERRIDE
;
2333 bool is_goto () const FINAL OVERRIDE
{ return true; }
2334 void maybe_print_gotos (pretty_printer
*) const FINAL OVERRIDE
;
2337 void maybe_populate_playback_blocks
2338 (auto_vec
<playback::block
*> *out
) FINAL OVERRIDE
;
2341 auto_vec
<block
*> m_goto_blocks
;
2342 block
*m_fallthrough_block
;
2345 /* A group of top-level asm statements, as created by
2346 gcc_jit_context_add_top_level_asm. */
2348 class top_level_asm
: public memento
2351 top_level_asm (context
*ctxt
, location
*loc
, string
*asm_stmts
);
2353 void write_to_dump (dump
&d
) FINAL OVERRIDE
;
2356 void replay_into (replayer
*r
) FINAL OVERRIDE
;
2357 string
* make_debug_string () FINAL OVERRIDE
;
2358 void write_reproducer (reproducer
&r
) FINAL OVERRIDE
;
2362 string
*m_asm_stmts
;
2365 } // namespace gcc::jit::recording
2367 /* Create a recording::memento_of_new_rvalue_from_const instance and add
2368 it to this context's list of mementos.
2370 Implements the post-error-checking part of
2371 gcc_jit_context_new_rvalue_from_{int|long|double|ptr}. */
2373 template <typename HOST_TYPE
>
2375 recording::context::new_rvalue_from_const (recording::type
*type
,
2378 recording::rvalue
*result
=
2379 new memento_of_new_rvalue_from_const
<HOST_TYPE
> (this, NULL
, type
, value
);
2384 } // namespace gcc::jit
2388 #endif /* JIT_RECORDING_H */