Turn HARD_REGNO_MODE_OK into a target hook
[official-gcc.git] / gcc / jit / jit-recording.h
blob248765d4b812f2e67b03fdff2303e7df64f32967
1 /* Internals of libgccjit: classes for recording calls made to the JIT API.
2 Copyright (C) 2013-2017 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)
10 any later version.
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"
27 class timer;
29 namespace gcc {
31 namespace jit {
33 class result;
34 class dump;
35 class reproducer;
37 /**********************************************************************
38 Recording.
39 **********************************************************************/
41 namespace recording {
43 playback::location *
44 playback_location (replayer *r, location *loc);
46 const char *
47 playback_string (string *str);
49 playback::block *
50 playback_block (block *b);
52 /* A recording of a call to gcc_jit_context_enable_dump. */
53 struct requested_dump
55 const char *m_dumpname;
56 char **m_out_ptr;
59 /* A JIT-compilation context. */
60 class context : public log_user
62 public:
63 context (context *parent_ctxt);
64 ~context ();
66 builtins_manager *
67 get_builtins_manager ();
69 void record (memento *m);
70 void replay_into (replayer *r);
71 void disassociate_from_playback ();
73 string *
74 new_string (const char *text);
76 location *
77 new_location (const char *filename,
78 int line,
79 int column,
80 bool created_by_user);
82 type *
83 get_type (enum gcc_jit_types type);
85 type *
86 get_int_type (int num_bytes, int is_signed);
88 type *
89 new_array_type (location *loc,
90 type *element_type,
91 int num_elements);
93 field *
94 new_field (location *loc,
95 type *type,
96 const char *name);
98 struct_ *
99 new_struct_type (location *loc,
100 const char *name);
102 union_ *
103 new_union_type (location *loc,
104 const char *name);
106 function_type *
107 new_function_type (type *return_type,
108 int num_params,
109 type **param_types,
110 int is_variadic);
112 type *
113 new_function_ptr_type (location *loc,
114 type *return_type,
115 int num_params,
116 type **param_types,
117 int is_variadic);
119 param *
120 new_param (location *loc,
121 type *type,
122 const char *name);
124 function *
125 new_function (location *loc,
126 enum gcc_jit_function_kind kind,
127 type *return_type,
128 const char *name,
129 int num_params,
130 param **params,
131 int is_variadic,
132 enum built_in_function builtin_id);
134 function *
135 get_builtin_function (const char *name);
137 lvalue *
138 new_global (location *loc,
139 enum gcc_jit_global_kind kind,
140 type *type,
141 const char *name);
143 template <typename HOST_TYPE>
144 rvalue *
145 new_rvalue_from_const (type *type,
146 HOST_TYPE value);
148 rvalue *
149 new_string_literal (const char *value);
151 rvalue *
152 new_unary_op (location *loc,
153 enum gcc_jit_unary_op op,
154 type *result_type,
155 rvalue *a);
157 rvalue *
158 new_binary_op (location *loc,
159 enum gcc_jit_binary_op op,
160 type *result_type,
161 rvalue *a, rvalue *b);
163 rvalue *
164 new_comparison (location *loc,
165 enum gcc_jit_comparison op,
166 rvalue *a, rvalue *b);
168 rvalue *
169 new_call (location *loc,
170 function *func,
171 int numargs, rvalue **args);
173 rvalue *
174 new_call_through_ptr (location *loc,
175 rvalue *fn_ptr,
176 int numargs, rvalue **args);
178 rvalue *
179 new_cast (location *loc,
180 rvalue *expr,
181 type *type_);
183 lvalue *
184 new_array_access (location *loc,
185 rvalue *ptr,
186 rvalue *index);
188 case_ *
189 new_case (rvalue *min_value,
190 rvalue *max_value,
191 block *block);
193 void
194 set_str_option (enum gcc_jit_str_option opt,
195 const char *value);
197 void
198 set_int_option (enum gcc_jit_int_option opt,
199 int value);
201 void
202 set_bool_option (enum gcc_jit_bool_option opt,
203 int value);
205 void
206 set_inner_bool_option (enum inner_bool_option inner_opt,
207 int value);
209 void
210 add_command_line_option (const char *optname);
212 void
213 append_command_line_options (vec <char *> *argvec);
215 void
216 enable_dump (const char *dumpname,
217 char **out_ptr);
219 const char *
220 get_str_option (enum gcc_jit_str_option opt) const
222 return m_str_options[opt];
226 get_int_option (enum gcc_jit_int_option opt) const
228 return m_int_options[opt];
232 get_bool_option (enum gcc_jit_bool_option opt) const
234 return m_bool_options[opt];
238 get_inner_bool_option (enum inner_bool_option opt) const
240 return m_inner_bool_options[opt];
243 result *
244 compile ();
246 void
247 compile_to_file (enum gcc_jit_output_kind output_kind,
248 const char *output_path);
250 void
251 add_error (location *loc, const char *fmt, ...)
252 GNU_PRINTF(3, 4);
254 void
255 add_error_va (location *loc, const char *fmt, va_list ap)
256 GNU_PRINTF(3, 0);
258 const char *
259 get_first_error () const;
261 const char *
262 get_last_error () const;
264 bool errors_occurred () const
266 if (m_parent_ctxt)
267 if (m_parent_ctxt->errors_occurred ())
268 return true;
269 return m_error_count;
272 type *get_opaque_FILE_type ();
274 void dump_to_file (const char *path, bool update_locations);
276 void dump_reproducer_to_file (const char *path);
278 void
279 get_all_requested_dumps (vec <recording::requested_dump> *out);
281 void set_timer (timer *t) { m_timer = t; }
282 timer *get_timer () const { return m_timer; }
284 private:
285 void log_all_options () const;
286 void log_str_option (enum gcc_jit_str_option opt) const;
287 void log_int_option (enum gcc_jit_int_option opt) const;
288 void log_bool_option (enum gcc_jit_bool_option opt) const;
289 void log_inner_bool_option (enum inner_bool_option opt) const;
291 void validate ();
293 private:
294 context *m_parent_ctxt;
296 /* The ultimate ancestor of the contexts within a family tree of
297 contexts. This has itself as its own m_toplevel_ctxt. */
298 context *m_toplevel_ctxt;
300 timer *m_timer;
302 int m_error_count;
304 char *m_first_error_str;
305 bool m_owns_first_error_str;
307 char *m_last_error_str;
308 bool m_owns_last_error_str;
310 char *m_str_options[GCC_JIT_NUM_STR_OPTIONS];
311 int m_int_options[GCC_JIT_NUM_INT_OPTIONS];
312 bool m_bool_options[GCC_JIT_NUM_BOOL_OPTIONS];
313 bool m_inner_bool_options[NUM_INNER_BOOL_OPTIONS];
314 auto_vec <char *> m_command_line_options;
316 /* Dumpfiles that were requested via gcc_jit_context_enable_dump. */
317 auto_vec<requested_dump> m_requested_dumps;
319 /* Recorded API usage. */
320 auto_vec<memento *> m_mementos;
322 /* Specific recordings, for use by dump_to_file. */
323 auto_vec<compound_type *> m_compound_types;
324 auto_vec<global *> m_globals;
325 auto_vec<function *> m_functions;
327 type *m_basic_types[NUM_GCC_JIT_TYPES];
328 type *m_FILE_type;
330 builtins_manager *m_builtins_manager; // lazily created
334 /* An object with lifetime managed by the context i.e.
335 it lives until the context is released, at which
336 point it itself is cleaned up. */
338 class memento
340 public:
341 virtual ~memento () {}
343 /* Hook for replaying this. */
344 virtual void replay_into (replayer *r) = 0;
346 void set_playback_obj (void *obj) { m_playback_obj = obj; }
349 /* Get the context that owns this object.
351 Implements the post-error-checking part of
352 gcc_jit_object_get_context. */
353 context *get_context () { return m_ctxt; }
355 memento *
356 as_object () { return this; }
358 /* Debugging hook, for use in generating error messages etc.
359 Implements the post-error-checking part of
360 gcc_jit_object_get_debug_string. */
361 const char *
362 get_debug_string ();
364 virtual void write_to_dump (dump &d);
365 virtual void write_reproducer (reproducer &r) = 0;
366 virtual location *dyn_cast_location () { return NULL; }
368 protected:
369 memento (context *ctxt)
370 : m_ctxt (ctxt),
371 m_playback_obj (NULL),
372 m_debug_string (NULL)
374 gcc_assert (ctxt);
377 string *new_string (const char *text) { return m_ctxt->new_string (text); }
379 private:
380 virtual string * make_debug_string () = 0;
382 public:
383 context *m_ctxt;
385 protected:
386 void *m_playback_obj;
388 private:
389 string *m_debug_string;
392 /* or just use std::string? */
393 class string : public memento
395 public:
396 string (context *ctxt, const char *text);
397 ~string ();
399 const char *c_str () { return m_buffer; }
401 static string * from_printf (context *ctxt, const char *fmt, ...)
402 GNU_PRINTF(2, 3);
404 void replay_into (replayer *) FINAL OVERRIDE {}
406 private:
407 string * make_debug_string () FINAL OVERRIDE;
408 void write_reproducer (reproducer &r) FINAL OVERRIDE;
410 private:
411 size_t m_len;
412 char *m_buffer;
415 class location : public memento
417 public:
418 location (context *ctxt, string *filename, int line, int column,
419 bool created_by_user)
420 : memento (ctxt),
421 m_filename (filename),
422 m_line (line),
423 m_column (column),
424 m_created_by_user (created_by_user)
427 void replay_into (replayer *r) FINAL OVERRIDE;
429 playback::location *
430 playback_location (replayer *r)
432 /* Normally during playback, we can walk forwards through the list of
433 recording objects, playing them back. The ordering of recording
434 ensures that everything that a recording object refers to has
435 already been played back, so we can simply look up the relevant
436 m_playback_obj.
438 Locations are an exception, due to the "write_to_dump" method of
439 recording::statement. This method can set a new location on a
440 statement after the statement is created, and thus the location
441 appears in the context's memento list *after* the statement that
442 refers to it.
444 In such circumstances, the statement is replayed *before* the location,
445 when the latter doesn't yet have a playback object.
447 Hence we need to ensure that locations have playback objects. */
448 if (!m_playback_obj)
450 replay_into (r);
452 gcc_assert (m_playback_obj);
453 return static_cast <playback::location *> (m_playback_obj);
456 location *dyn_cast_location () FINAL OVERRIDE { return this; }
457 bool created_by_user () const { return m_created_by_user; }
459 private:
460 string * make_debug_string () FINAL OVERRIDE;
461 void write_reproducer (reproducer &r) FINAL OVERRIDE;
463 private:
464 string *m_filename;
465 int m_line;
466 int m_column;
467 bool m_created_by_user;
470 class type : public memento
472 public:
473 type *get_pointer ();
474 type *get_const ();
475 type *get_volatile ();
476 type *get_aligned (size_t alignment_in_bytes);
477 type *get_vector (size_t num_units);
479 /* Get the type obtained when dereferencing this type.
481 This will return NULL if it's not valid to dereference this type.
482 The caller is responsible for setting an error. */
483 virtual type *dereference () = 0;
485 /* Dynamic casts. */
486 virtual function_type *dyn_cast_function_type () { return NULL; }
487 virtual function_type *as_a_function_type() { gcc_unreachable (); return NULL; }
488 virtual struct_ *dyn_cast_struct () { return NULL; }
490 /* Is it typesafe to copy to this type from rtype? */
491 virtual bool accepts_writes_from (type *rtype)
493 gcc_assert (rtype);
494 return this->unqualified () == rtype->unqualified ();
497 /* Strip off "const" etc */
498 virtual type *unqualified ()
500 return this;
503 virtual bool is_int () const = 0;
504 virtual bool is_float () const = 0;
505 virtual bool is_bool () const = 0;
506 virtual type *is_pointer () = 0;
507 virtual type *is_array () = 0;
508 virtual bool is_void () const { return false; }
509 virtual bool has_known_size () const { return true; }
511 bool is_numeric () const
513 return is_int () || is_float () || is_bool ();
516 playback::type *
517 playback_type ()
519 return static_cast <playback::type *> (m_playback_obj);
522 virtual const char *access_as_type (reproducer &r);
524 protected:
525 type (context *ctxt)
526 : memento (ctxt),
527 m_pointer_to_this_type (NULL)
530 private:
531 type *m_pointer_to_this_type;
534 /* Result of "gcc_jit_context_get_type". */
535 class memento_of_get_type : public type
537 public:
538 memento_of_get_type (context *ctxt,
539 enum gcc_jit_types kind)
540 : type (ctxt),
541 m_kind (kind) {}
543 type *dereference () FINAL OVERRIDE;
545 bool accepts_writes_from (type *rtype) FINAL OVERRIDE
547 if (m_kind == GCC_JIT_TYPE_VOID_PTR)
548 if (rtype->is_pointer ())
550 /* LHS (this) is type (void *), and the RHS is a pointer:
551 accept it: */
552 return true;
555 return type::accepts_writes_from (rtype);
558 bool is_int () const FINAL OVERRIDE;
559 bool is_float () const FINAL OVERRIDE;
560 bool is_bool () const FINAL OVERRIDE;
561 type *is_pointer () FINAL OVERRIDE { return dereference (); }
562 type *is_array () FINAL OVERRIDE { return NULL; }
563 bool is_void () const FINAL OVERRIDE { return m_kind == GCC_JIT_TYPE_VOID; }
565 public:
566 void replay_into (replayer *r) FINAL OVERRIDE;
568 private:
569 string * make_debug_string () FINAL OVERRIDE;
570 void write_reproducer (reproducer &r) FINAL OVERRIDE;
572 private:
573 enum gcc_jit_types m_kind;
576 /* Result of "gcc_jit_type_get_pointer". */
577 class memento_of_get_pointer : public type
579 public:
580 memento_of_get_pointer (type *other_type)
581 : type (other_type->m_ctxt),
582 m_other_type (other_type) {}
584 type *dereference () FINAL OVERRIDE { return m_other_type; }
586 bool accepts_writes_from (type *rtype) FINAL OVERRIDE;
588 void replay_into (replayer *r) FINAL OVERRIDE;
590 bool is_int () const FINAL OVERRIDE { return false; }
591 bool is_float () const FINAL OVERRIDE { return false; }
592 bool is_bool () const FINAL OVERRIDE { return false; }
593 type *is_pointer () FINAL OVERRIDE { return m_other_type; }
594 type *is_array () FINAL OVERRIDE { return NULL; }
596 private:
597 string * make_debug_string () FINAL OVERRIDE;
598 void write_reproducer (reproducer &r) FINAL OVERRIDE;
600 private:
601 type *m_other_type;
604 /* A decorated version of a type, for get_const, get_volatile,
605 get_aligned, and get_vector. */
607 class decorated_type : public type
609 public:
610 decorated_type (type *other_type)
611 : type (other_type->m_ctxt),
612 m_other_type (other_type) {}
614 type *dereference () FINAL OVERRIDE { return m_other_type->dereference (); }
616 bool is_int () const FINAL OVERRIDE { return m_other_type->is_int (); }
617 bool is_float () const FINAL OVERRIDE { return m_other_type->is_float (); }
618 bool is_bool () const FINAL OVERRIDE { return m_other_type->is_bool (); }
619 type *is_pointer () FINAL OVERRIDE { return m_other_type->is_pointer (); }
620 type *is_array () FINAL OVERRIDE { return m_other_type->is_array (); }
622 protected:
623 type *m_other_type;
626 /* Result of "gcc_jit_type_get_const". */
627 class memento_of_get_const : public decorated_type
629 public:
630 memento_of_get_const (type *other_type)
631 : decorated_type (other_type) {}
633 bool accepts_writes_from (type */*rtype*/) FINAL OVERRIDE
635 /* Can't write to a "const". */
636 return false;
639 /* Strip off the "const", giving the underlying type. */
640 type *unqualified () FINAL OVERRIDE { return m_other_type; }
642 void replay_into (replayer *) FINAL OVERRIDE;
644 private:
645 string * make_debug_string () FINAL OVERRIDE;
646 void write_reproducer (reproducer &r) FINAL OVERRIDE;
649 /* Result of "gcc_jit_type_get_volatile". */
650 class memento_of_get_volatile : public decorated_type
652 public:
653 memento_of_get_volatile (type *other_type)
654 : decorated_type (other_type) {}
656 /* Strip off the "volatile", giving the underlying type. */
657 type *unqualified () FINAL OVERRIDE { return m_other_type; }
659 void replay_into (replayer *) FINAL OVERRIDE;
661 private:
662 string * make_debug_string () FINAL OVERRIDE;
663 void write_reproducer (reproducer &r) FINAL OVERRIDE;
666 /* Result of "gcc_jit_type_get_aligned". */
667 class memento_of_get_aligned : public decorated_type
669 public:
670 memento_of_get_aligned (type *other_type, size_t alignment_in_bytes)
671 : decorated_type (other_type),
672 m_alignment_in_bytes (alignment_in_bytes) {}
674 /* Strip off the alignment, giving the underlying type. */
675 type *unqualified () FINAL OVERRIDE { return m_other_type; }
677 void replay_into (replayer *) FINAL OVERRIDE;
679 private:
680 string * make_debug_string () FINAL OVERRIDE;
681 void write_reproducer (reproducer &r) FINAL OVERRIDE;
683 private:
684 size_t m_alignment_in_bytes;
687 /* Result of "gcc_jit_type_get_vector". */
688 class memento_of_get_vector : public decorated_type
690 public:
691 memento_of_get_vector (type *other_type, size_t num_units)
692 : decorated_type (other_type),
693 m_num_units (num_units) {}
695 /* Strip off the alignment, giving the underlying type. */
696 type *unqualified () FINAL OVERRIDE { return m_other_type; }
698 void replay_into (replayer *) FINAL OVERRIDE;
700 private:
701 string * make_debug_string () FINAL OVERRIDE;
702 void write_reproducer (reproducer &r) FINAL OVERRIDE;
704 private:
705 size_t m_num_units;
708 class array_type : public type
710 public:
711 array_type (context *ctxt,
712 location *loc,
713 type *element_type,
714 int num_elements)
715 : type (ctxt),
716 m_loc (loc),
717 m_element_type (element_type),
718 m_num_elements (num_elements)
721 type *dereference () FINAL OVERRIDE;
723 bool is_int () const FINAL OVERRIDE { return false; }
724 bool is_float () const FINAL OVERRIDE { return false; }
725 bool is_bool () const FINAL OVERRIDE { return false; }
726 type *is_pointer () FINAL OVERRIDE { return NULL; }
727 type *is_array () FINAL OVERRIDE { return m_element_type; }
729 void replay_into (replayer *) FINAL OVERRIDE;
731 private:
732 string * make_debug_string () FINAL OVERRIDE;
733 void write_reproducer (reproducer &r) FINAL OVERRIDE;
735 private:
736 location *m_loc;
737 type *m_element_type;
738 int m_num_elements;
741 class function_type : public type
743 public:
744 function_type (context *ctxt,
745 type *return_type,
746 int num_params,
747 type **param_types,
748 int is_variadic);
750 type *dereference () FINAL OVERRIDE;
751 function_type *dyn_cast_function_type () FINAL OVERRIDE { return this; }
752 function_type *as_a_function_type () FINAL OVERRIDE { return this; }
754 bool is_int () const FINAL OVERRIDE { return false; }
755 bool is_float () const FINAL OVERRIDE { return false; }
756 bool is_bool () const FINAL OVERRIDE { return false; }
757 type *is_pointer () FINAL OVERRIDE { return NULL; }
758 type *is_array () FINAL OVERRIDE { return NULL; }
760 void replay_into (replayer *) FINAL OVERRIDE;
762 type * get_return_type () const { return m_return_type; }
763 const vec<type *> &get_param_types () const { return m_param_types; }
764 int is_variadic () const { return m_is_variadic; }
766 string * make_debug_string_with_ptr ();
768 void
769 write_deferred_reproducer (reproducer &r,
770 memento *ptr_type);
772 private:
773 string * make_debug_string () FINAL OVERRIDE;
774 string * make_debug_string_with (const char *);
775 void write_reproducer (reproducer &r) FINAL OVERRIDE;
777 private:
778 type *m_return_type;
779 auto_vec<type *> m_param_types;
780 int m_is_variadic;
783 class field : public memento
785 public:
786 field (context *ctxt,
787 location *loc,
788 type *type,
789 string *name)
790 : memento (ctxt),
791 m_loc (loc),
792 m_type (type),
793 m_name (name),
794 m_container (NULL)
797 type * get_type () const { return m_type; }
799 compound_type * get_container () const { return m_container; }
800 void set_container (compound_type *c) { m_container = c; }
802 void replay_into (replayer *) FINAL OVERRIDE;
804 void write_to_dump (dump &d) FINAL OVERRIDE;
806 playback::field *
807 playback_field () const
809 return static_cast <playback::field *> (m_playback_obj);
812 private:
813 string * make_debug_string () FINAL OVERRIDE;
814 void write_reproducer (reproducer &r) FINAL OVERRIDE;
816 private:
817 location *m_loc;
818 type *m_type;
819 string *m_name;
820 compound_type *m_container;
823 /* Base class for struct_ and union_ */
824 class compound_type : public type
826 public:
827 compound_type (context *ctxt,
828 location *loc,
829 string *name);
831 string *get_name () const { return m_name; }
832 location *get_loc () const { return m_loc; }
833 fields * get_fields () { return m_fields; }
835 void
836 set_fields (location *loc,
837 int num_fields,
838 field **fields);
840 type *dereference () FINAL OVERRIDE;
842 bool is_int () const FINAL OVERRIDE { return false; }
843 bool is_float () const FINAL OVERRIDE { return false; }
844 bool is_bool () const FINAL OVERRIDE { return false; }
845 type *is_pointer () FINAL OVERRIDE { return NULL; }
846 type *is_array () FINAL OVERRIDE { return NULL; }
848 bool has_known_size () const FINAL OVERRIDE { return m_fields != NULL; }
850 playback::compound_type *
851 playback_compound_type ()
853 return static_cast <playback::compound_type *> (m_playback_obj);
856 private:
857 location *m_loc;
858 string *m_name;
859 fields *m_fields;
862 class struct_ : public compound_type
864 public:
865 struct_ (context *ctxt,
866 location *loc,
867 string *name);
869 struct_ *dyn_cast_struct () FINAL OVERRIDE { return this; }
871 type *
872 as_type () { return this; }
874 void replay_into (replayer *r) FINAL OVERRIDE;
876 const char *access_as_type (reproducer &r) FINAL OVERRIDE;
878 private:
879 string * make_debug_string () FINAL OVERRIDE;
880 void write_reproducer (reproducer &r) FINAL OVERRIDE;
883 // memento of struct_::set_fields
884 class fields : public memento
886 public:
887 fields (compound_type *struct_or_union,
888 int num_fields,
889 field **fields);
891 void replay_into (replayer *r) FINAL OVERRIDE;
893 void write_to_dump (dump &d) FINAL OVERRIDE;
895 int length () const { return m_fields.length (); }
896 field *get_field (int i) const { return m_fields[i]; }
898 private:
899 string * make_debug_string () FINAL OVERRIDE;
900 void write_reproducer (reproducer &r) FINAL OVERRIDE;
902 private:
903 compound_type *m_struct_or_union;
904 auto_vec<field *> m_fields;
907 class union_ : public compound_type
909 public:
910 union_ (context *ctxt,
911 location *loc,
912 string *name);
914 void replay_into (replayer *r) FINAL OVERRIDE;
916 private:
917 string * make_debug_string () FINAL OVERRIDE;
918 void write_reproducer (reproducer &r) FINAL OVERRIDE;
920 private:
921 location *m_loc;
922 string *m_name;
925 /* An abstract base class for operations that visit all rvalues within an
926 expression tree.
927 Currently the only implementation is class rvalue_usage_validator within
928 jit-recording.c. */
930 class rvalue_visitor
932 public:
933 virtual ~rvalue_visitor () {}
934 virtual void visit (rvalue *rvalue) = 0;
937 /* When generating debug strings for rvalues we mimic C, so we need to
938 mimic C's precedence levels when handling compound expressions.
939 These are in order from strongest precedence to weakest. */
940 enum precedence
942 PRECEDENCE_PRIMARY,
943 PRECEDENCE_POSTFIX,
944 PRECEDENCE_UNARY,
945 PRECEDENCE_CAST,
946 PRECEDENCE_MULTIPLICATIVE,
947 PRECEDENCE_ADDITIVE,
948 PRECEDENCE_SHIFT,
949 PRECEDENCE_RELATIONAL,
950 PRECEDENCE_EQUALITY,
951 PRECEDENCE_BITWISE_AND,
952 PRECEDENCE_BITWISE_XOR,
953 PRECEDENCE_BITWISE_IOR,
954 PRECEDENCE_LOGICAL_AND,
955 PRECEDENCE_LOGICAL_OR
958 class rvalue : public memento
960 public:
961 rvalue (context *ctxt,
962 location *loc,
963 type *type_)
964 : memento (ctxt),
965 m_loc (loc),
966 m_type (type_),
967 m_scope (NULL),
968 m_parenthesized_string (NULL)
970 gcc_assert (type_);
973 location * get_loc () const { return m_loc; }
975 /* Get the recording::type of this rvalue.
977 Implements the post-error-checking part of
978 gcc_jit_rvalue_get_type. */
979 type * get_type () const { return m_type; }
981 playback::rvalue *
982 playback_rvalue () const
984 return static_cast <playback::rvalue *> (m_playback_obj);
986 rvalue *
987 access_field (location *loc,
988 field *field);
990 lvalue *
991 dereference_field (location *loc,
992 field *field);
994 lvalue *
995 dereference (location *loc);
997 void
998 verify_valid_within_stmt (const char *api_funcname, statement *s);
1000 virtual void visit_children (rvalue_visitor *v) = 0;
1002 void set_scope (function *scope);
1003 function *get_scope () const { return m_scope; }
1005 /* Dynamic casts. */
1006 virtual param *dyn_cast_param () { return NULL; }
1007 virtual base_call *dyn_cast_base_call () { return NULL; }
1009 virtual const char *access_as_rvalue (reproducer &r);
1011 /* Get the debug string, wrapped in parentheses. */
1012 const char *
1013 get_debug_string_parens (enum precedence outer_prec);
1015 virtual bool is_constant () const { return false; }
1016 virtual bool get_wide_int (wide_int *) const { return false; }
1018 private:
1019 virtual enum precedence get_precedence () const = 0;
1021 protected:
1022 location *m_loc;
1023 type *m_type;
1025 private:
1026 function *m_scope; /* NULL for globals, non-NULL for locals/params */
1027 string *m_parenthesized_string;
1030 class lvalue : public rvalue
1032 public:
1033 lvalue (context *ctxt,
1034 location *loc,
1035 type *type_)
1036 : rvalue (ctxt, loc, type_)
1039 playback::lvalue *
1040 playback_lvalue () const
1042 return static_cast <playback::lvalue *> (m_playback_obj);
1045 lvalue *
1046 access_field (location *loc,
1047 field *field);
1049 rvalue *
1050 get_address (location *loc);
1052 rvalue *
1053 as_rvalue () { return this; }
1055 const char *access_as_rvalue (reproducer &r) OVERRIDE;
1056 virtual const char *access_as_lvalue (reproducer &r);
1059 class param : public lvalue
1061 public:
1062 param (context *ctxt,
1063 location *loc,
1064 type *type,
1065 string *name)
1066 : lvalue (ctxt, loc, type),
1067 m_name (name) {}
1069 lvalue *
1070 as_lvalue () { return this; }
1072 void replay_into (replayer *r) FINAL OVERRIDE;
1074 void visit_children (rvalue_visitor *) FINAL OVERRIDE {}
1076 playback::param *
1077 playback_param () const
1079 return static_cast <playback::param *> (m_playback_obj);
1082 param *dyn_cast_param () FINAL OVERRIDE { return this; }
1084 const char *access_as_rvalue (reproducer &r) FINAL OVERRIDE;
1085 const char *access_as_lvalue (reproducer &r) FINAL OVERRIDE;
1087 private:
1088 string * make_debug_string () FINAL OVERRIDE { return m_name; }
1089 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1090 enum precedence get_precedence () const FINAL OVERRIDE
1092 return PRECEDENCE_PRIMARY;
1095 private:
1096 string *m_name;
1099 class function : public memento
1101 public:
1102 function (context *ctxt,
1103 location *loc,
1104 enum gcc_jit_function_kind kind,
1105 type *return_type,
1106 string *name,
1107 int num_params,
1108 param **params,
1109 int is_variadic,
1110 enum built_in_function builtin_id);
1112 void replay_into (replayer *r) FINAL OVERRIDE;
1114 playback::function *
1115 playback_function () const
1117 return static_cast <playback::function *> (m_playback_obj);
1120 enum gcc_jit_function_kind get_kind () const { return m_kind; }
1122 lvalue *
1123 new_local (location *loc,
1124 type *type,
1125 const char *name);
1127 block*
1128 new_block (const char *name);
1130 location *get_loc () const { return m_loc; }
1131 type *get_return_type () const { return m_return_type; }
1132 string * get_name () const { return m_name; }
1133 const vec<param *> &get_params () const { return m_params; }
1135 /* Get the given param by index.
1136 Implements the post-error-checking part of
1137 gcc_jit_function_get_param. */
1138 param *get_param (int i) const { return m_params[i]; }
1140 bool is_variadic () const { return m_is_variadic; }
1142 void write_to_dump (dump &d) FINAL OVERRIDE;
1144 void validate ();
1146 void dump_to_dot (const char *path);
1148 private:
1149 string * make_debug_string () FINAL OVERRIDE;
1150 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1152 private:
1153 location *m_loc;
1154 enum gcc_jit_function_kind m_kind;
1155 type *m_return_type;
1156 string *m_name;
1157 auto_vec<param *> m_params;
1158 int m_is_variadic;
1159 enum built_in_function m_builtin_id;
1160 auto_vec<local *> m_locals;
1161 auto_vec<block *> m_blocks;
1164 class block : public memento
1166 public:
1167 block (function *func, int index, string *name)
1168 : memento (func->m_ctxt),
1169 m_func (func),
1170 m_index (index),
1171 m_name (name),
1172 m_statements (),
1173 m_has_been_terminated (false),
1174 m_is_reachable (false)
1178 /* Get the recording::function containing this block.
1179 Implements the post-error-checking part of
1180 gcc_jit_block_get_function. */
1181 function *get_function () { return m_func; }
1183 bool has_been_terminated () { return m_has_been_terminated; }
1184 bool is_reachable () { return m_is_reachable; }
1186 statement *
1187 add_eval (location *loc,
1188 rvalue *rvalue);
1190 statement *
1191 add_assignment (location *loc,
1192 lvalue *lvalue,
1193 rvalue *rvalue);
1195 statement *
1196 add_assignment_op (location *loc,
1197 lvalue *lvalue,
1198 enum gcc_jit_binary_op op,
1199 rvalue *rvalue);
1201 statement *
1202 add_comment (location *loc,
1203 const char *text);
1205 statement *
1206 end_with_conditional (location *loc,
1207 rvalue *boolval,
1208 block *on_true,
1209 block *on_false);
1211 statement *
1212 end_with_jump (location *loc,
1213 block *target);
1215 statement *
1216 end_with_return (location *loc,
1217 rvalue *rvalue);
1219 statement *
1220 end_with_switch (location *loc,
1221 rvalue *expr,
1222 block *default_block,
1223 int num_cases,
1224 case_ **cases);
1226 playback::block *
1227 playback_block () const
1229 return static_cast <playback::block *> (m_playback_obj);
1232 void write_to_dump (dump &d) FINAL OVERRIDE;
1234 bool validate ();
1236 location *get_loc () const;
1238 statement *get_first_statement () const;
1239 statement *get_last_statement () const;
1241 vec <block *> get_successor_blocks () const;
1243 private:
1244 string * make_debug_string () FINAL OVERRIDE;
1245 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1247 void replay_into (replayer *r) FINAL OVERRIDE;
1249 void dump_to_dot (pretty_printer *pp);
1250 void dump_edges_to_dot (pretty_printer *pp);
1252 private:
1253 function *m_func;
1254 int m_index;
1255 string *m_name;
1256 auto_vec<statement *> m_statements;
1257 bool m_has_been_terminated;
1258 bool m_is_reachable;
1260 friend class function;
1263 class global : public lvalue
1265 public:
1266 global (context *ctxt,
1267 location *loc,
1268 enum gcc_jit_global_kind kind,
1269 type *type,
1270 string *name)
1271 : lvalue (ctxt, loc, type),
1272 m_kind (kind),
1273 m_name (name)
1276 void replay_into (replayer *) FINAL OVERRIDE;
1278 void visit_children (rvalue_visitor *) FINAL OVERRIDE {}
1280 void write_to_dump (dump &d) FINAL OVERRIDE;
1282 private:
1283 string * make_debug_string () FINAL OVERRIDE { return m_name; }
1284 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1285 enum precedence get_precedence () const FINAL OVERRIDE
1287 return PRECEDENCE_PRIMARY;
1290 private:
1291 enum gcc_jit_global_kind m_kind;
1292 string *m_name;
1295 template <typename HOST_TYPE>
1296 class memento_of_new_rvalue_from_const : public rvalue
1298 public:
1299 memento_of_new_rvalue_from_const (context *ctxt,
1300 location *loc,
1301 type *type,
1302 HOST_TYPE value)
1303 : rvalue (ctxt, loc, type),
1304 m_value (value) {}
1306 void replay_into (replayer *r) FINAL OVERRIDE;
1308 void visit_children (rvalue_visitor *) FINAL OVERRIDE {}
1310 bool is_constant () const FINAL OVERRIDE { return true; }
1312 bool get_wide_int (wide_int *out) const FINAL OVERRIDE;
1314 private:
1315 string * make_debug_string () FINAL OVERRIDE;
1316 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1317 enum precedence get_precedence () const FINAL OVERRIDE
1319 return PRECEDENCE_PRIMARY;
1322 private:
1323 HOST_TYPE m_value;
1326 class memento_of_new_string_literal : public rvalue
1328 public:
1329 memento_of_new_string_literal (context *ctxt,
1330 location *loc,
1331 string *value)
1332 : rvalue (ctxt, loc, ctxt->get_type (GCC_JIT_TYPE_CONST_CHAR_PTR)),
1333 m_value (value) {}
1335 void replay_into (replayer *r) FINAL OVERRIDE;
1337 void visit_children (rvalue_visitor *) FINAL OVERRIDE {}
1339 private:
1340 string * make_debug_string () FINAL OVERRIDE;
1341 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1342 enum precedence get_precedence () const FINAL OVERRIDE
1344 return PRECEDENCE_PRIMARY;
1347 private:
1348 string *m_value;
1351 class unary_op : public rvalue
1353 public:
1354 unary_op (context *ctxt,
1355 location *loc,
1356 enum gcc_jit_unary_op op,
1357 type *result_type,
1358 rvalue *a)
1359 : rvalue (ctxt, loc, result_type),
1360 m_op (op),
1361 m_a (a)
1364 void replay_into (replayer *r) FINAL OVERRIDE;
1366 void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
1368 private:
1369 string * make_debug_string () FINAL OVERRIDE;
1370 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1371 enum precedence get_precedence () const FINAL OVERRIDE
1373 return PRECEDENCE_UNARY;
1376 private:
1377 enum gcc_jit_unary_op m_op;
1378 rvalue *m_a;
1381 class binary_op : public rvalue
1383 public:
1384 binary_op (context *ctxt,
1385 location *loc,
1386 enum gcc_jit_binary_op op,
1387 type *result_type,
1388 rvalue *a, rvalue *b)
1389 : rvalue (ctxt, loc, result_type),
1390 m_op (op),
1391 m_a (a),
1392 m_b (b) {}
1394 void replay_into (replayer *r) FINAL OVERRIDE;
1396 void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
1398 private:
1399 string * make_debug_string () FINAL OVERRIDE;
1400 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1401 enum precedence get_precedence () const FINAL OVERRIDE;
1403 private:
1404 enum gcc_jit_binary_op m_op;
1405 rvalue *m_a;
1406 rvalue *m_b;
1409 class comparison : public rvalue
1411 public:
1412 comparison (context *ctxt,
1413 location *loc,
1414 enum gcc_jit_comparison op,
1415 rvalue *a, rvalue *b)
1416 : rvalue (ctxt, loc, ctxt->get_type (GCC_JIT_TYPE_BOOL)),
1417 m_op (op),
1418 m_a (a),
1419 m_b (b)
1422 void replay_into (replayer *r) FINAL OVERRIDE;
1424 void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
1426 private:
1427 string * make_debug_string () FINAL OVERRIDE;
1428 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1429 enum precedence get_precedence () const FINAL OVERRIDE;
1431 private:
1432 enum gcc_jit_comparison m_op;
1433 rvalue *m_a;
1434 rvalue *m_b;
1437 class cast : public rvalue
1439 public:
1440 cast (context *ctxt,
1441 location *loc,
1442 rvalue *a,
1443 type *type_)
1444 : rvalue (ctxt, loc, type_),
1445 m_rvalue (a)
1448 void replay_into (replayer *r) FINAL OVERRIDE;
1450 void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
1452 private:
1453 string * make_debug_string () FINAL OVERRIDE;
1454 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1455 enum precedence get_precedence () const FINAL OVERRIDE
1457 return PRECEDENCE_CAST;
1460 private:
1461 rvalue *m_rvalue;
1464 class base_call : public rvalue
1466 public:
1467 base_call (context *ctxt,
1468 location *loc,
1469 type *type_,
1470 int numargs,
1471 rvalue **args);
1473 enum precedence get_precedence () const FINAL OVERRIDE
1475 return PRECEDENCE_POSTFIX;
1478 base_call *dyn_cast_base_call () FINAL OVERRIDE { return this; }
1480 void set_require_tail_call (bool require_tail_call)
1482 m_require_tail_call = require_tail_call;
1485 protected:
1486 void write_reproducer_tail_call (reproducer &r, const char *id);
1488 protected:
1489 auto_vec<rvalue *> m_args;
1490 bool m_require_tail_call;
1493 class call : public base_call
1495 public:
1496 call (context *ctxt,
1497 location *loc,
1498 function *func,
1499 int numargs,
1500 rvalue **args);
1502 void replay_into (replayer *r) FINAL OVERRIDE;
1504 void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
1506 private:
1507 string * make_debug_string () FINAL OVERRIDE;
1508 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1510 private:
1511 function *m_func;
1514 class call_through_ptr : public base_call
1516 public:
1517 call_through_ptr (context *ctxt,
1518 location *loc,
1519 rvalue *fn_ptr,
1520 int numargs,
1521 rvalue **args);
1523 void replay_into (replayer *r) FINAL OVERRIDE;
1525 void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
1527 private:
1528 string * make_debug_string () FINAL OVERRIDE;
1529 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1531 private:
1532 rvalue *m_fn_ptr;
1535 class array_access : public lvalue
1537 public:
1538 array_access (context *ctxt,
1539 location *loc,
1540 rvalue *ptr,
1541 rvalue *index)
1542 : lvalue (ctxt, loc, ptr->get_type ()->dereference ()),
1543 m_ptr (ptr),
1544 m_index (index)
1547 void replay_into (replayer *r) FINAL OVERRIDE;
1549 void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
1551 private:
1552 string * make_debug_string () FINAL OVERRIDE;
1553 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1554 enum precedence get_precedence () const FINAL OVERRIDE
1556 return PRECEDENCE_POSTFIX;
1559 private:
1560 rvalue *m_ptr;
1561 rvalue *m_index;
1564 class access_field_of_lvalue : public lvalue
1566 public:
1567 access_field_of_lvalue (context *ctxt,
1568 location *loc,
1569 lvalue *val,
1570 field *field)
1571 : lvalue (ctxt, loc, field->get_type ()),
1572 m_lvalue (val),
1573 m_field (field)
1576 void replay_into (replayer *r) FINAL OVERRIDE;
1578 void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
1580 private:
1581 string * make_debug_string () FINAL OVERRIDE;
1582 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1583 enum precedence get_precedence () const FINAL OVERRIDE
1585 return PRECEDENCE_POSTFIX;
1588 private:
1589 lvalue *m_lvalue;
1590 field *m_field;
1593 class access_field_rvalue : public rvalue
1595 public:
1596 access_field_rvalue (context *ctxt,
1597 location *loc,
1598 rvalue *val,
1599 field *field)
1600 : rvalue (ctxt, loc, field->get_type ()),
1601 m_rvalue (val),
1602 m_field (field)
1605 void replay_into (replayer *r) FINAL OVERRIDE;
1607 void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
1609 private:
1610 string * make_debug_string () FINAL OVERRIDE;
1611 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1612 enum precedence get_precedence () const FINAL OVERRIDE
1614 return PRECEDENCE_POSTFIX;
1617 private:
1618 rvalue *m_rvalue;
1619 field *m_field;
1622 class dereference_field_rvalue : public lvalue
1624 public:
1625 dereference_field_rvalue (context *ctxt,
1626 location *loc,
1627 rvalue *val,
1628 field *field)
1629 : lvalue (ctxt, loc, field->get_type ()),
1630 m_rvalue (val),
1631 m_field (field)
1634 void replay_into (replayer *r) FINAL OVERRIDE;
1636 void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
1638 private:
1639 string * make_debug_string () FINAL OVERRIDE;
1640 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1641 enum precedence get_precedence () const FINAL OVERRIDE
1643 return PRECEDENCE_POSTFIX;
1646 private:
1647 rvalue *m_rvalue;
1648 field *m_field;
1651 class dereference_rvalue : public lvalue
1653 public:
1654 dereference_rvalue (context *ctxt,
1655 location *loc,
1656 rvalue *val)
1657 : lvalue (ctxt, loc, val->get_type ()->dereference ()),
1658 m_rvalue (val) {}
1660 void replay_into (replayer *r) FINAL OVERRIDE;
1662 void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
1664 private:
1665 string * make_debug_string () FINAL OVERRIDE;
1666 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1667 enum precedence get_precedence () const FINAL OVERRIDE
1669 return PRECEDENCE_UNARY;
1672 private:
1673 rvalue *m_rvalue;
1676 class get_address_of_lvalue : public rvalue
1678 public:
1679 get_address_of_lvalue (context *ctxt,
1680 location *loc,
1681 lvalue *val)
1682 : rvalue (ctxt, loc, val->get_type ()->get_pointer ()),
1683 m_lvalue (val)
1686 void replay_into (replayer *r) FINAL OVERRIDE;
1688 void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
1690 private:
1691 string * make_debug_string () FINAL OVERRIDE;
1692 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1693 enum precedence get_precedence () const FINAL OVERRIDE
1695 return PRECEDENCE_UNARY;
1698 private:
1699 lvalue *m_lvalue;
1702 class local : public lvalue
1704 public:
1705 local (function *func, location *loc, type *type_, string *name)
1706 : lvalue (func->m_ctxt, loc, type_),
1707 m_func (func),
1708 m_name (name)
1710 set_scope (func);
1713 void replay_into (replayer *r) FINAL OVERRIDE;
1715 void visit_children (rvalue_visitor *) FINAL OVERRIDE {}
1717 void write_to_dump (dump &d) FINAL OVERRIDE;
1719 private:
1720 string * make_debug_string () FINAL OVERRIDE { return m_name; }
1721 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1722 enum precedence get_precedence () const FINAL OVERRIDE
1724 return PRECEDENCE_PRIMARY;
1727 private:
1728 function *m_func;
1729 string *m_name;
1732 class statement : public memento
1734 public:
1735 virtual vec <block *> get_successor_blocks () const;
1737 void write_to_dump (dump &d) FINAL OVERRIDE;
1739 block *get_block () const { return m_block; }
1740 location *get_loc () const { return m_loc; }
1742 protected:
1743 statement (block *b, location *loc)
1744 : memento (b->m_ctxt),
1745 m_block (b),
1746 m_loc (loc) {}
1748 playback::location *
1749 playback_location (replayer *r) const
1751 return ::gcc::jit::recording::playback_location (r, m_loc);
1754 private:
1755 block *m_block;
1756 location *m_loc;
1759 class eval : public statement
1761 public:
1762 eval (block *b,
1763 location *loc,
1764 rvalue *rvalue)
1765 : statement (b, loc),
1766 m_rvalue (rvalue) {}
1768 void replay_into (replayer *r) FINAL OVERRIDE;
1770 private:
1771 string * make_debug_string () FINAL OVERRIDE;
1772 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1774 private:
1775 rvalue *m_rvalue;
1778 class assignment : public statement
1780 public:
1781 assignment (block *b,
1782 location *loc,
1783 lvalue *lvalue,
1784 rvalue *rvalue)
1785 : statement (b, loc),
1786 m_lvalue (lvalue),
1787 m_rvalue (rvalue) {}
1789 void replay_into (replayer *r) FINAL OVERRIDE;
1791 private:
1792 string * make_debug_string () FINAL OVERRIDE;
1793 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1795 private:
1796 lvalue *m_lvalue;
1797 rvalue *m_rvalue;
1800 class assignment_op : public statement
1802 public:
1803 assignment_op (block *b,
1804 location *loc,
1805 lvalue *lvalue,
1806 enum gcc_jit_binary_op op,
1807 rvalue *rvalue)
1808 : statement (b, loc),
1809 m_lvalue (lvalue),
1810 m_op (op),
1811 m_rvalue (rvalue) {}
1813 void replay_into (replayer *r) FINAL OVERRIDE;
1815 private:
1816 string * make_debug_string () FINAL OVERRIDE;
1817 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1819 private:
1820 lvalue *m_lvalue;
1821 enum gcc_jit_binary_op m_op;
1822 rvalue *m_rvalue;
1825 class comment : public statement
1827 public:
1828 comment (block *b,
1829 location *loc,
1830 string *text)
1831 : statement (b, loc),
1832 m_text (text) {}
1834 void replay_into (replayer *r) FINAL OVERRIDE;
1836 private:
1837 string * make_debug_string () FINAL OVERRIDE;
1838 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1840 private:
1841 string *m_text;
1844 class conditional : public statement
1846 public:
1847 conditional (block *b,
1848 location *loc,
1849 rvalue *boolval,
1850 block *on_true,
1851 block *on_false)
1852 : statement (b, loc),
1853 m_boolval (boolval),
1854 m_on_true (on_true),
1855 m_on_false (on_false) {}
1857 void replay_into (replayer *r) FINAL OVERRIDE;
1859 vec <block *> get_successor_blocks () const FINAL OVERRIDE;
1861 private:
1862 string * make_debug_string () FINAL OVERRIDE;
1863 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1865 private:
1866 rvalue *m_boolval;
1867 block *m_on_true;
1868 block *m_on_false;
1871 class jump : public statement
1873 public:
1874 jump (block *b,
1875 location *loc,
1876 block *target)
1877 : statement (b, loc),
1878 m_target (target) {}
1880 void replay_into (replayer *r) FINAL OVERRIDE;
1882 vec <block *> get_successor_blocks () const FINAL OVERRIDE;
1884 private:
1885 string * make_debug_string () FINAL OVERRIDE;
1886 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1888 private:
1889 block *m_target;
1892 class return_ : public statement
1894 public:
1895 return_ (block *b,
1896 location *loc,
1897 rvalue *rvalue)
1898 : statement (b, loc),
1899 m_rvalue (rvalue) {}
1901 void replay_into (replayer *r) FINAL OVERRIDE;
1903 vec <block *> get_successor_blocks () const FINAL OVERRIDE;
1905 private:
1906 string * make_debug_string () FINAL OVERRIDE;
1907 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1909 private:
1910 rvalue *m_rvalue;
1913 class case_ : public memento
1915 public:
1916 case_ (context *ctxt,
1917 rvalue *min_value,
1918 rvalue *max_value,
1919 block *dest_block)
1920 : memento (ctxt),
1921 m_min_value (min_value),
1922 m_max_value (max_value),
1923 m_dest_block (dest_block)
1926 rvalue *get_min_value () const { return m_min_value; }
1927 rvalue *get_max_value () const { return m_max_value; }
1928 block *get_dest_block () const { return m_dest_block; }
1930 void replay_into (replayer *) FINAL OVERRIDE { /* empty */ }
1932 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1934 private:
1935 string * make_debug_string () FINAL OVERRIDE;
1937 private:
1938 rvalue *m_min_value;
1939 rvalue *m_max_value;
1940 block *m_dest_block;
1943 class switch_ : public statement
1945 public:
1946 switch_ (block *b,
1947 location *loc,
1948 rvalue *expr,
1949 block *default_block,
1950 int num_cases,
1951 case_ **cases);
1953 void replay_into (replayer *r) FINAL OVERRIDE;
1955 vec <block *> get_successor_blocks () const FINAL OVERRIDE;
1957 private:
1958 string * make_debug_string () FINAL OVERRIDE;
1959 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1961 private:
1962 rvalue *m_expr;
1963 block *m_default_block;
1964 auto_vec <case_ *> m_cases;
1967 } // namespace gcc::jit::recording
1969 /* Create a recording::memento_of_new_rvalue_from_const instance and add
1970 it to this context's list of mementos.
1972 Implements the post-error-checking part of
1973 gcc_jit_context_new_rvalue_from_{int|long|double|ptr}. */
1975 template <typename HOST_TYPE>
1976 recording::rvalue *
1977 recording::context::new_rvalue_from_const (recording::type *type,
1978 HOST_TYPE value)
1980 recording::rvalue *result =
1981 new memento_of_new_rvalue_from_const <HOST_TYPE> (this, NULL, type, value);
1982 record (result);
1983 return result;
1986 } // namespace gcc::jit
1988 } // namespace gcc
1990 #endif /* JIT_RECORDING_H */