* es.po: Update.
[official-gcc.git] / gcc / jit / jit-recording.h
blob0e3511c6a1cf2ae65181019ab0977ca31ce969b1
1 /* Internals of libgccjit: classes for recording calls made to the JIT API.
2 Copyright (C) 2013-2016 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 ();
477 /* Get the type obtained when dereferencing this type.
479 This will return NULL if it's not valid to dereference this type.
480 The caller is responsible for setting an error. */
481 virtual type *dereference () = 0;
483 /* Dynamic casts. */
484 virtual function_type *dyn_cast_function_type () { return NULL; }
485 virtual function_type *as_a_function_type() { gcc_unreachable (); return NULL; }
486 virtual struct_ *dyn_cast_struct () { return NULL; }
488 /* Is it typesafe to copy to this type from rtype? */
489 virtual bool accepts_writes_from (type *rtype)
491 gcc_assert (rtype);
492 return this == rtype->unqualified ();
495 /* Strip off "const" etc */
496 virtual type *unqualified ()
498 return this;
501 virtual bool is_int () const = 0;
502 virtual bool is_float () const = 0;
503 virtual bool is_bool () const = 0;
504 virtual type *is_pointer () = 0;
505 virtual type *is_array () = 0;
506 virtual bool is_void () const { return false; }
507 virtual bool has_known_size () const { return true; }
509 bool is_numeric () const
511 return is_int () || is_float () || is_bool ();
514 playback::type *
515 playback_type ()
517 return static_cast <playback::type *> (m_playback_obj);
520 virtual const char *access_as_type (reproducer &r);
522 protected:
523 type (context *ctxt)
524 : memento (ctxt),
525 m_pointer_to_this_type (NULL)
528 private:
529 type *m_pointer_to_this_type;
532 /* Result of "gcc_jit_context_get_type". */
533 class memento_of_get_type : public type
535 public:
536 memento_of_get_type (context *ctxt,
537 enum gcc_jit_types kind)
538 : type (ctxt),
539 m_kind (kind) {}
541 type *dereference () FINAL OVERRIDE;
543 bool accepts_writes_from (type *rtype) FINAL OVERRIDE
545 if (m_kind == GCC_JIT_TYPE_VOID_PTR)
546 if (rtype->is_pointer ())
548 /* LHS (this) is type (void *), and the RHS is a pointer:
549 accept it: */
550 return true;
553 return type::accepts_writes_from (rtype);
556 bool is_int () const FINAL OVERRIDE;
557 bool is_float () const FINAL OVERRIDE;
558 bool is_bool () const FINAL OVERRIDE;
559 type *is_pointer () FINAL OVERRIDE { return dereference (); }
560 type *is_array () FINAL OVERRIDE { return NULL; }
561 bool is_void () const FINAL OVERRIDE { return m_kind == GCC_JIT_TYPE_VOID; }
563 public:
564 void replay_into (replayer *r) FINAL OVERRIDE;
566 private:
567 string * make_debug_string () FINAL OVERRIDE;
568 void write_reproducer (reproducer &r) FINAL OVERRIDE;
570 private:
571 enum gcc_jit_types m_kind;
574 /* Result of "gcc_jit_type_get_pointer". */
575 class memento_of_get_pointer : public type
577 public:
578 memento_of_get_pointer (type *other_type)
579 : type (other_type->m_ctxt),
580 m_other_type (other_type) {}
582 type *dereference () FINAL OVERRIDE { return m_other_type; }
584 bool accepts_writes_from (type *rtype) FINAL OVERRIDE;
586 void replay_into (replayer *r) FINAL OVERRIDE;
588 bool is_int () const FINAL OVERRIDE { return false; }
589 bool is_float () const FINAL OVERRIDE { return false; }
590 bool is_bool () const FINAL OVERRIDE { return false; }
591 type *is_pointer () FINAL OVERRIDE { return m_other_type; }
592 type *is_array () FINAL OVERRIDE { return NULL; }
594 private:
595 string * make_debug_string () FINAL OVERRIDE;
596 void write_reproducer (reproducer &r) FINAL OVERRIDE;
598 private:
599 type *m_other_type;
602 /* Result of "gcc_jit_type_get_const". */
603 class memento_of_get_const : public type
605 public:
606 memento_of_get_const (type *other_type)
607 : type (other_type->m_ctxt),
608 m_other_type (other_type) {}
610 type *dereference () FINAL OVERRIDE { return m_other_type->dereference (); }
612 bool accepts_writes_from (type */*rtype*/) FINAL OVERRIDE
614 /* Can't write to a "const". */
615 return false;
618 /* Strip off the "const", giving the underlying type. */
619 type *unqualified () FINAL OVERRIDE { return m_other_type; }
621 bool is_int () const FINAL OVERRIDE { return m_other_type->is_int (); }
622 bool is_float () const FINAL OVERRIDE { return m_other_type->is_float (); }
623 bool is_bool () const FINAL OVERRIDE { return m_other_type->is_bool (); }
624 type *is_pointer () FINAL OVERRIDE { return m_other_type->is_pointer (); }
625 type *is_array () FINAL OVERRIDE { return m_other_type->is_array (); }
627 void replay_into (replayer *) FINAL OVERRIDE;
629 private:
630 string * make_debug_string () FINAL OVERRIDE;
631 void write_reproducer (reproducer &r) FINAL OVERRIDE;
633 private:
634 type *m_other_type;
637 /* Result of "gcc_jit_type_get_volatile". */
638 class memento_of_get_volatile : public type
640 public:
641 memento_of_get_volatile (type *other_type)
642 : type (other_type->m_ctxt),
643 m_other_type (other_type) {}
645 type *dereference () FINAL OVERRIDE { return m_other_type->dereference (); }
647 /* Strip off the "volatile", giving the underlying type. */
648 type *unqualified () FINAL OVERRIDE { return m_other_type; }
650 bool is_int () const FINAL OVERRIDE { return m_other_type->is_int (); }
651 bool is_float () const FINAL OVERRIDE { return m_other_type->is_float (); }
652 bool is_bool () const FINAL OVERRIDE { return m_other_type->is_bool (); }
653 type *is_pointer () FINAL OVERRIDE { return m_other_type->is_pointer (); }
654 type *is_array () FINAL OVERRIDE { return m_other_type->is_array (); }
656 void replay_into (replayer *) FINAL OVERRIDE;
658 private:
659 string * make_debug_string () FINAL OVERRIDE;
660 void write_reproducer (reproducer &r) FINAL OVERRIDE;
662 private:
663 type *m_other_type;
666 class array_type : public type
668 public:
669 array_type (context *ctxt,
670 location *loc,
671 type *element_type,
672 int num_elements)
673 : type (ctxt),
674 m_loc (loc),
675 m_element_type (element_type),
676 m_num_elements (num_elements)
679 type *dereference () FINAL OVERRIDE;
681 bool is_int () const FINAL OVERRIDE { return false; }
682 bool is_float () const FINAL OVERRIDE { return false; }
683 bool is_bool () const FINAL OVERRIDE { return false; }
684 type *is_pointer () FINAL OVERRIDE { return NULL; }
685 type *is_array () FINAL OVERRIDE { return m_element_type; }
687 void replay_into (replayer *) FINAL OVERRIDE;
689 private:
690 string * make_debug_string () FINAL OVERRIDE;
691 void write_reproducer (reproducer &r) FINAL OVERRIDE;
693 private:
694 location *m_loc;
695 type *m_element_type;
696 int m_num_elements;
699 class function_type : public type
701 public:
702 function_type (context *ctxt,
703 type *return_type,
704 int num_params,
705 type **param_types,
706 int is_variadic);
708 type *dereference () FINAL OVERRIDE;
709 function_type *dyn_cast_function_type () FINAL OVERRIDE { return this; }
710 function_type *as_a_function_type () FINAL OVERRIDE { return this; }
712 bool is_int () const FINAL OVERRIDE { return false; }
713 bool is_float () const FINAL OVERRIDE { return false; }
714 bool is_bool () const FINAL OVERRIDE { return false; }
715 type *is_pointer () FINAL OVERRIDE { return NULL; }
716 type *is_array () FINAL OVERRIDE { return NULL; }
718 void replay_into (replayer *) FINAL OVERRIDE;
720 type * get_return_type () const { return m_return_type; }
721 const vec<type *> &get_param_types () const { return m_param_types; }
722 int is_variadic () const { return m_is_variadic; }
724 string * make_debug_string_with_ptr ();
726 void
727 write_deferred_reproducer (reproducer &r,
728 memento *ptr_type);
730 private:
731 string * make_debug_string () FINAL OVERRIDE;
732 string * make_debug_string_with (const char *);
733 void write_reproducer (reproducer &r) FINAL OVERRIDE;
735 private:
736 type *m_return_type;
737 auto_vec<type *> m_param_types;
738 int m_is_variadic;
741 class field : public memento
743 public:
744 field (context *ctxt,
745 location *loc,
746 type *type,
747 string *name)
748 : memento (ctxt),
749 m_loc (loc),
750 m_type (type),
751 m_name (name),
752 m_container (NULL)
755 type * get_type () const { return m_type; }
757 compound_type * get_container () const { return m_container; }
758 void set_container (compound_type *c) { m_container = c; }
760 void replay_into (replayer *) FINAL OVERRIDE;
762 void write_to_dump (dump &d) FINAL OVERRIDE;
764 playback::field *
765 playback_field () const
767 return static_cast <playback::field *> (m_playback_obj);
770 private:
771 string * make_debug_string () FINAL OVERRIDE;
772 void write_reproducer (reproducer &r) FINAL OVERRIDE;
774 private:
775 location *m_loc;
776 type *m_type;
777 string *m_name;
778 compound_type *m_container;
781 /* Base class for struct_ and union_ */
782 class compound_type : public type
784 public:
785 compound_type (context *ctxt,
786 location *loc,
787 string *name);
789 string *get_name () const { return m_name; }
790 location *get_loc () const { return m_loc; }
791 fields * get_fields () { return m_fields; }
793 void
794 set_fields (location *loc,
795 int num_fields,
796 field **fields);
798 type *dereference () FINAL OVERRIDE;
800 bool is_int () const FINAL OVERRIDE { return false; }
801 bool is_float () const FINAL OVERRIDE { return false; }
802 bool is_bool () const FINAL OVERRIDE { return false; }
803 type *is_pointer () FINAL OVERRIDE { return NULL; }
804 type *is_array () FINAL OVERRIDE { return NULL; }
806 bool has_known_size () const FINAL OVERRIDE { return m_fields != NULL; }
808 playback::compound_type *
809 playback_compound_type ()
811 return static_cast <playback::compound_type *> (m_playback_obj);
814 private:
815 location *m_loc;
816 string *m_name;
817 fields *m_fields;
820 class struct_ : public compound_type
822 public:
823 struct_ (context *ctxt,
824 location *loc,
825 string *name);
827 struct_ *dyn_cast_struct () FINAL OVERRIDE { return this; }
829 type *
830 as_type () { return this; }
832 void replay_into (replayer *r) FINAL OVERRIDE;
834 const char *access_as_type (reproducer &r) FINAL OVERRIDE;
836 private:
837 string * make_debug_string () FINAL OVERRIDE;
838 void write_reproducer (reproducer &r) FINAL OVERRIDE;
841 // memento of struct_::set_fields
842 class fields : public memento
844 public:
845 fields (compound_type *struct_or_union,
846 int num_fields,
847 field **fields);
849 void replay_into (replayer *r) FINAL OVERRIDE;
851 void write_to_dump (dump &d) FINAL OVERRIDE;
853 int length () const { return m_fields.length (); }
854 field *get_field (int i) const { return m_fields[i]; }
856 private:
857 string * make_debug_string () FINAL OVERRIDE;
858 void write_reproducer (reproducer &r) FINAL OVERRIDE;
860 private:
861 compound_type *m_struct_or_union;
862 auto_vec<field *> m_fields;
865 class union_ : public compound_type
867 public:
868 union_ (context *ctxt,
869 location *loc,
870 string *name);
872 void replay_into (replayer *r) FINAL OVERRIDE;
874 private:
875 string * make_debug_string () FINAL OVERRIDE;
876 void write_reproducer (reproducer &r) FINAL OVERRIDE;
878 private:
879 location *m_loc;
880 string *m_name;
883 /* An abstract base class for operations that visit all rvalues within an
884 expression tree.
885 Currently the only implementation is class rvalue_usage_validator within
886 jit-recording.c. */
888 class rvalue_visitor
890 public:
891 virtual ~rvalue_visitor () {}
892 virtual void visit (rvalue *rvalue) = 0;
895 /* When generating debug strings for rvalues we mimic C, so we need to
896 mimic C's precedence levels when handling compound expressions.
897 These are in order from strongest precedence to weakest. */
898 enum precedence
900 PRECEDENCE_PRIMARY,
901 PRECEDENCE_POSTFIX,
902 PRECEDENCE_UNARY,
903 PRECEDENCE_CAST,
904 PRECEDENCE_MULTIPLICATIVE,
905 PRECEDENCE_ADDITIVE,
906 PRECEDENCE_SHIFT,
907 PRECEDENCE_RELATIONAL,
908 PRECEDENCE_EQUALITY,
909 PRECEDENCE_BITWISE_AND,
910 PRECEDENCE_BITWISE_XOR,
911 PRECEDENCE_BITWISE_IOR,
912 PRECEDENCE_LOGICAL_AND,
913 PRECEDENCE_LOGICAL_OR
916 class rvalue : public memento
918 public:
919 rvalue (context *ctxt,
920 location *loc,
921 type *type_)
922 : memento (ctxt),
923 m_loc (loc),
924 m_type (type_),
925 m_scope (NULL),
926 m_parenthesized_string (NULL)
928 gcc_assert (type_);
931 location * get_loc () const { return m_loc; }
933 /* Get the recording::type of this rvalue.
935 Implements the post-error-checking part of
936 gcc_jit_rvalue_get_type. */
937 type * get_type () const { return m_type; }
939 playback::rvalue *
940 playback_rvalue () const
942 return static_cast <playback::rvalue *> (m_playback_obj);
944 rvalue *
945 access_field (location *loc,
946 field *field);
948 lvalue *
949 dereference_field (location *loc,
950 field *field);
952 lvalue *
953 dereference (location *loc);
955 void
956 verify_valid_within_stmt (const char *api_funcname, statement *s);
958 virtual void visit_children (rvalue_visitor *v) = 0;
960 void set_scope (function *scope);
961 function *get_scope () const { return m_scope; }
963 /* Dynamic casts. */
964 virtual param *dyn_cast_param () { return NULL; }
965 virtual base_call *dyn_cast_base_call () { return NULL; }
967 virtual const char *access_as_rvalue (reproducer &r);
969 /* Get the debug string, wrapped in parentheses. */
970 const char *
971 get_debug_string_parens (enum precedence outer_prec);
973 virtual bool is_constant () const { return false; }
974 virtual bool get_wide_int (wide_int *) const { return false; }
976 private:
977 virtual enum precedence get_precedence () const = 0;
979 protected:
980 location *m_loc;
981 type *m_type;
983 private:
984 function *m_scope; /* NULL for globals, non-NULL for locals/params */
985 string *m_parenthesized_string;
988 class lvalue : public rvalue
990 public:
991 lvalue (context *ctxt,
992 location *loc,
993 type *type_)
994 : rvalue (ctxt, loc, type_)
997 playback::lvalue *
998 playback_lvalue () const
1000 return static_cast <playback::lvalue *> (m_playback_obj);
1003 lvalue *
1004 access_field (location *loc,
1005 field *field);
1007 rvalue *
1008 get_address (location *loc);
1010 rvalue *
1011 as_rvalue () { return this; }
1013 const char *access_as_rvalue (reproducer &r) OVERRIDE;
1014 virtual const char *access_as_lvalue (reproducer &r);
1017 class param : public lvalue
1019 public:
1020 param (context *ctxt,
1021 location *loc,
1022 type *type,
1023 string *name)
1024 : lvalue (ctxt, loc, type),
1025 m_name (name) {}
1027 lvalue *
1028 as_lvalue () { return this; }
1030 void replay_into (replayer *r) FINAL OVERRIDE;
1032 void visit_children (rvalue_visitor *) FINAL OVERRIDE {}
1034 playback::param *
1035 playback_param () const
1037 return static_cast <playback::param *> (m_playback_obj);
1040 param *dyn_cast_param () FINAL OVERRIDE { return this; }
1042 const char *access_as_rvalue (reproducer &r) FINAL OVERRIDE;
1043 const char *access_as_lvalue (reproducer &r) FINAL OVERRIDE;
1045 private:
1046 string * make_debug_string () FINAL OVERRIDE { return m_name; }
1047 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1048 enum precedence get_precedence () const FINAL OVERRIDE
1050 return PRECEDENCE_PRIMARY;
1053 private:
1054 string *m_name;
1057 class function : public memento
1059 public:
1060 function (context *ctxt,
1061 location *loc,
1062 enum gcc_jit_function_kind kind,
1063 type *return_type,
1064 string *name,
1065 int num_params,
1066 param **params,
1067 int is_variadic,
1068 enum built_in_function builtin_id);
1070 void replay_into (replayer *r) FINAL OVERRIDE;
1072 playback::function *
1073 playback_function () const
1075 return static_cast <playback::function *> (m_playback_obj);
1078 enum gcc_jit_function_kind get_kind () const { return m_kind; }
1080 lvalue *
1081 new_local (location *loc,
1082 type *type,
1083 const char *name);
1085 block*
1086 new_block (const char *name);
1088 location *get_loc () const { return m_loc; }
1089 type *get_return_type () const { return m_return_type; }
1090 string * get_name () const { return m_name; }
1091 const vec<param *> &get_params () const { return m_params; }
1093 /* Get the given param by index.
1094 Implements the post-error-checking part of
1095 gcc_jit_function_get_param. */
1096 param *get_param (int i) const { return m_params[i]; }
1098 bool is_variadic () const { return m_is_variadic; }
1100 void write_to_dump (dump &d) FINAL OVERRIDE;
1102 void validate ();
1104 void dump_to_dot (const char *path);
1106 private:
1107 string * make_debug_string () FINAL OVERRIDE;
1108 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1110 private:
1111 location *m_loc;
1112 enum gcc_jit_function_kind m_kind;
1113 type *m_return_type;
1114 string *m_name;
1115 auto_vec<param *> m_params;
1116 int m_is_variadic;
1117 enum built_in_function m_builtin_id;
1118 auto_vec<local *> m_locals;
1119 auto_vec<block *> m_blocks;
1122 class block : public memento
1124 public:
1125 block (function *func, int index, string *name)
1126 : memento (func->m_ctxt),
1127 m_func (func),
1128 m_index (index),
1129 m_name (name),
1130 m_statements (),
1131 m_has_been_terminated (false),
1132 m_is_reachable (false)
1136 /* Get the recording::function containing this block.
1137 Implements the post-error-checking part of
1138 gcc_jit_block_get_function. */
1139 function *get_function () { return m_func; }
1141 bool has_been_terminated () { return m_has_been_terminated; }
1142 bool is_reachable () { return m_is_reachable; }
1144 statement *
1145 add_eval (location *loc,
1146 rvalue *rvalue);
1148 statement *
1149 add_assignment (location *loc,
1150 lvalue *lvalue,
1151 rvalue *rvalue);
1153 statement *
1154 add_assignment_op (location *loc,
1155 lvalue *lvalue,
1156 enum gcc_jit_binary_op op,
1157 rvalue *rvalue);
1159 statement *
1160 add_comment (location *loc,
1161 const char *text);
1163 statement *
1164 end_with_conditional (location *loc,
1165 rvalue *boolval,
1166 block *on_true,
1167 block *on_false);
1169 statement *
1170 end_with_jump (location *loc,
1171 block *target);
1173 statement *
1174 end_with_return (location *loc,
1175 rvalue *rvalue);
1177 statement *
1178 end_with_switch (location *loc,
1179 rvalue *expr,
1180 block *default_block,
1181 int num_cases,
1182 case_ **cases);
1184 playback::block *
1185 playback_block () const
1187 return static_cast <playback::block *> (m_playback_obj);
1190 void write_to_dump (dump &d) FINAL OVERRIDE;
1192 bool validate ();
1194 location *get_loc () const;
1196 statement *get_first_statement () const;
1197 statement *get_last_statement () const;
1199 vec <block *> get_successor_blocks () const;
1201 private:
1202 string * make_debug_string () FINAL OVERRIDE;
1203 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1205 void replay_into (replayer *r) FINAL OVERRIDE;
1207 void dump_to_dot (pretty_printer *pp);
1208 void dump_edges_to_dot (pretty_printer *pp);
1210 private:
1211 function *m_func;
1212 int m_index;
1213 string *m_name;
1214 auto_vec<statement *> m_statements;
1215 bool m_has_been_terminated;
1216 bool m_is_reachable;
1218 friend class function;
1221 class global : public lvalue
1223 public:
1224 global (context *ctxt,
1225 location *loc,
1226 enum gcc_jit_global_kind kind,
1227 type *type,
1228 string *name)
1229 : lvalue (ctxt, loc, type),
1230 m_kind (kind),
1231 m_name (name)
1234 void replay_into (replayer *) FINAL OVERRIDE;
1236 void visit_children (rvalue_visitor *) FINAL OVERRIDE {}
1238 void write_to_dump (dump &d) FINAL OVERRIDE;
1240 private:
1241 string * make_debug_string () FINAL OVERRIDE { return m_name; }
1242 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1243 enum precedence get_precedence () const FINAL OVERRIDE
1245 return PRECEDENCE_PRIMARY;
1248 private:
1249 enum gcc_jit_global_kind m_kind;
1250 string *m_name;
1253 template <typename HOST_TYPE>
1254 class memento_of_new_rvalue_from_const : public rvalue
1256 public:
1257 memento_of_new_rvalue_from_const (context *ctxt,
1258 location *loc,
1259 type *type,
1260 HOST_TYPE value)
1261 : rvalue (ctxt, loc, type),
1262 m_value (value) {}
1264 void replay_into (replayer *r) FINAL OVERRIDE;
1266 void visit_children (rvalue_visitor *) FINAL OVERRIDE {}
1268 bool is_constant () const FINAL OVERRIDE { return true; }
1270 bool get_wide_int (wide_int *out) const FINAL OVERRIDE;
1272 private:
1273 string * make_debug_string () FINAL OVERRIDE;
1274 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1275 enum precedence get_precedence () const FINAL OVERRIDE
1277 return PRECEDENCE_PRIMARY;
1280 private:
1281 HOST_TYPE m_value;
1284 class memento_of_new_string_literal : public rvalue
1286 public:
1287 memento_of_new_string_literal (context *ctxt,
1288 location *loc,
1289 string *value)
1290 : rvalue (ctxt, loc, ctxt->get_type (GCC_JIT_TYPE_CONST_CHAR_PTR)),
1291 m_value (value) {}
1293 void replay_into (replayer *r) FINAL OVERRIDE;
1295 void visit_children (rvalue_visitor *) FINAL OVERRIDE {}
1297 private:
1298 string * make_debug_string () FINAL OVERRIDE;
1299 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1300 enum precedence get_precedence () const FINAL OVERRIDE
1302 return PRECEDENCE_PRIMARY;
1305 private:
1306 string *m_value;
1309 class unary_op : public rvalue
1311 public:
1312 unary_op (context *ctxt,
1313 location *loc,
1314 enum gcc_jit_unary_op op,
1315 type *result_type,
1316 rvalue *a)
1317 : rvalue (ctxt, loc, result_type),
1318 m_op (op),
1319 m_a (a)
1322 void replay_into (replayer *r) FINAL OVERRIDE;
1324 void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
1326 private:
1327 string * make_debug_string () FINAL OVERRIDE;
1328 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1329 enum precedence get_precedence () const FINAL OVERRIDE
1331 return PRECEDENCE_UNARY;
1334 private:
1335 enum gcc_jit_unary_op m_op;
1336 rvalue *m_a;
1339 class binary_op : public rvalue
1341 public:
1342 binary_op (context *ctxt,
1343 location *loc,
1344 enum gcc_jit_binary_op op,
1345 type *result_type,
1346 rvalue *a, rvalue *b)
1347 : rvalue (ctxt, loc, result_type),
1348 m_op (op),
1349 m_a (a),
1350 m_b (b) {}
1352 void replay_into (replayer *r) FINAL OVERRIDE;
1354 void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
1356 private:
1357 string * make_debug_string () FINAL OVERRIDE;
1358 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1359 enum precedence get_precedence () const FINAL OVERRIDE;
1361 private:
1362 enum gcc_jit_binary_op m_op;
1363 rvalue *m_a;
1364 rvalue *m_b;
1367 class comparison : public rvalue
1369 public:
1370 comparison (context *ctxt,
1371 location *loc,
1372 enum gcc_jit_comparison op,
1373 rvalue *a, rvalue *b)
1374 : rvalue (ctxt, loc, ctxt->get_type (GCC_JIT_TYPE_BOOL)),
1375 m_op (op),
1376 m_a (a),
1377 m_b (b)
1380 void replay_into (replayer *r) FINAL OVERRIDE;
1382 void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
1384 private:
1385 string * make_debug_string () FINAL OVERRIDE;
1386 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1387 enum precedence get_precedence () const FINAL OVERRIDE;
1389 private:
1390 enum gcc_jit_comparison m_op;
1391 rvalue *m_a;
1392 rvalue *m_b;
1395 class cast : public rvalue
1397 public:
1398 cast (context *ctxt,
1399 location *loc,
1400 rvalue *a,
1401 type *type_)
1402 : rvalue (ctxt, loc, type_),
1403 m_rvalue (a)
1406 void replay_into (replayer *r) FINAL OVERRIDE;
1408 void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
1410 private:
1411 string * make_debug_string () FINAL OVERRIDE;
1412 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1413 enum precedence get_precedence () const FINAL OVERRIDE
1415 return PRECEDENCE_CAST;
1418 private:
1419 rvalue *m_rvalue;
1422 class base_call : public rvalue
1424 public:
1425 base_call (context *ctxt,
1426 location *loc,
1427 type *type_,
1428 int numargs,
1429 rvalue **args);
1431 enum precedence get_precedence () const FINAL OVERRIDE
1433 return PRECEDENCE_POSTFIX;
1436 base_call *dyn_cast_base_call () FINAL OVERRIDE { return this; }
1438 void set_require_tail_call (bool require_tail_call)
1440 m_require_tail_call = require_tail_call;
1443 protected:
1444 void write_reproducer_tail_call (reproducer &r, const char *id);
1446 protected:
1447 auto_vec<rvalue *> m_args;
1448 bool m_require_tail_call;
1451 class call : public base_call
1453 public:
1454 call (context *ctxt,
1455 location *loc,
1456 function *func,
1457 int numargs,
1458 rvalue **args);
1460 void replay_into (replayer *r) FINAL OVERRIDE;
1462 void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
1464 private:
1465 string * make_debug_string () FINAL OVERRIDE;
1466 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1468 private:
1469 function *m_func;
1472 class call_through_ptr : public base_call
1474 public:
1475 call_through_ptr (context *ctxt,
1476 location *loc,
1477 rvalue *fn_ptr,
1478 int numargs,
1479 rvalue **args);
1481 void replay_into (replayer *r) FINAL OVERRIDE;
1483 void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
1485 private:
1486 string * make_debug_string () FINAL OVERRIDE;
1487 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1489 private:
1490 rvalue *m_fn_ptr;
1493 class array_access : public lvalue
1495 public:
1496 array_access (context *ctxt,
1497 location *loc,
1498 rvalue *ptr,
1499 rvalue *index)
1500 : lvalue (ctxt, loc, ptr->get_type ()->dereference ()),
1501 m_ptr (ptr),
1502 m_index (index)
1505 void replay_into (replayer *r) FINAL OVERRIDE;
1507 void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
1509 private:
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_POSTFIX;
1517 private:
1518 rvalue *m_ptr;
1519 rvalue *m_index;
1522 class access_field_of_lvalue : public lvalue
1524 public:
1525 access_field_of_lvalue (context *ctxt,
1526 location *loc,
1527 lvalue *val,
1528 field *field)
1529 : lvalue (ctxt, loc, field->get_type ()),
1530 m_lvalue (val),
1531 m_field (field)
1534 void replay_into (replayer *r) FINAL OVERRIDE;
1536 void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
1538 private:
1539 string * make_debug_string () FINAL OVERRIDE;
1540 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1541 enum precedence get_precedence () const FINAL OVERRIDE
1543 return PRECEDENCE_POSTFIX;
1546 private:
1547 lvalue *m_lvalue;
1548 field *m_field;
1551 class access_field_rvalue : public rvalue
1553 public:
1554 access_field_rvalue (context *ctxt,
1555 location *loc,
1556 rvalue *val,
1557 field *field)
1558 : rvalue (ctxt, loc, field->get_type ()),
1559 m_rvalue (val),
1560 m_field (field)
1563 void replay_into (replayer *r) FINAL OVERRIDE;
1565 void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
1567 private:
1568 string * make_debug_string () FINAL OVERRIDE;
1569 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1570 enum precedence get_precedence () const FINAL OVERRIDE
1572 return PRECEDENCE_POSTFIX;
1575 private:
1576 rvalue *m_rvalue;
1577 field *m_field;
1580 class dereference_field_rvalue : public lvalue
1582 public:
1583 dereference_field_rvalue (context *ctxt,
1584 location *loc,
1585 rvalue *val,
1586 field *field)
1587 : lvalue (ctxt, loc, field->get_type ()),
1588 m_rvalue (val),
1589 m_field (field)
1592 void replay_into (replayer *r) FINAL OVERRIDE;
1594 void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
1596 private:
1597 string * make_debug_string () FINAL OVERRIDE;
1598 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1599 enum precedence get_precedence () const FINAL OVERRIDE
1601 return PRECEDENCE_POSTFIX;
1604 private:
1605 rvalue *m_rvalue;
1606 field *m_field;
1609 class dereference_rvalue : public lvalue
1611 public:
1612 dereference_rvalue (context *ctxt,
1613 location *loc,
1614 rvalue *val)
1615 : lvalue (ctxt, loc, val->get_type ()->dereference ()),
1616 m_rvalue (val) {}
1618 void replay_into (replayer *r) FINAL OVERRIDE;
1620 void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
1622 private:
1623 string * make_debug_string () FINAL OVERRIDE;
1624 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1625 enum precedence get_precedence () const FINAL OVERRIDE
1627 return PRECEDENCE_UNARY;
1630 private:
1631 rvalue *m_rvalue;
1634 class get_address_of_lvalue : public rvalue
1636 public:
1637 get_address_of_lvalue (context *ctxt,
1638 location *loc,
1639 lvalue *val)
1640 : rvalue (ctxt, loc, val->get_type ()->get_pointer ()),
1641 m_lvalue (val)
1644 void replay_into (replayer *r) FINAL OVERRIDE;
1646 void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
1648 private:
1649 string * make_debug_string () FINAL OVERRIDE;
1650 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1651 enum precedence get_precedence () const FINAL OVERRIDE
1653 return PRECEDENCE_UNARY;
1656 private:
1657 lvalue *m_lvalue;
1660 class local : public lvalue
1662 public:
1663 local (function *func, location *loc, type *type_, string *name)
1664 : lvalue (func->m_ctxt, loc, type_),
1665 m_func (func),
1666 m_name (name)
1668 set_scope (func);
1671 void replay_into (replayer *r) FINAL OVERRIDE;
1673 void visit_children (rvalue_visitor *) FINAL OVERRIDE {}
1675 void write_to_dump (dump &d) FINAL OVERRIDE;
1677 private:
1678 string * make_debug_string () FINAL OVERRIDE { return m_name; }
1679 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1680 enum precedence get_precedence () const FINAL OVERRIDE
1682 return PRECEDENCE_PRIMARY;
1685 private:
1686 function *m_func;
1687 string *m_name;
1690 class statement : public memento
1692 public:
1693 virtual vec <block *> get_successor_blocks () const;
1695 void write_to_dump (dump &d) FINAL OVERRIDE;
1697 block *get_block () const { return m_block; }
1698 location *get_loc () const { return m_loc; }
1700 protected:
1701 statement (block *b, location *loc)
1702 : memento (b->m_ctxt),
1703 m_block (b),
1704 m_loc (loc) {}
1706 playback::location *
1707 playback_location (replayer *r) const
1709 return ::gcc::jit::recording::playback_location (r, m_loc);
1712 private:
1713 block *m_block;
1714 location *m_loc;
1717 class eval : public statement
1719 public:
1720 eval (block *b,
1721 location *loc,
1722 rvalue *rvalue)
1723 : statement (b, loc),
1724 m_rvalue (rvalue) {}
1726 void replay_into (replayer *r) FINAL OVERRIDE;
1728 private:
1729 string * make_debug_string () FINAL OVERRIDE;
1730 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1732 private:
1733 rvalue *m_rvalue;
1736 class assignment : public statement
1738 public:
1739 assignment (block *b,
1740 location *loc,
1741 lvalue *lvalue,
1742 rvalue *rvalue)
1743 : statement (b, loc),
1744 m_lvalue (lvalue),
1745 m_rvalue (rvalue) {}
1747 void replay_into (replayer *r) FINAL OVERRIDE;
1749 private:
1750 string * make_debug_string () FINAL OVERRIDE;
1751 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1753 private:
1754 lvalue *m_lvalue;
1755 rvalue *m_rvalue;
1758 class assignment_op : public statement
1760 public:
1761 assignment_op (block *b,
1762 location *loc,
1763 lvalue *lvalue,
1764 enum gcc_jit_binary_op op,
1765 rvalue *rvalue)
1766 : statement (b, loc),
1767 m_lvalue (lvalue),
1768 m_op (op),
1769 m_rvalue (rvalue) {}
1771 void replay_into (replayer *r) FINAL OVERRIDE;
1773 private:
1774 string * make_debug_string () FINAL OVERRIDE;
1775 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1777 private:
1778 lvalue *m_lvalue;
1779 enum gcc_jit_binary_op m_op;
1780 rvalue *m_rvalue;
1783 class comment : public statement
1785 public:
1786 comment (block *b,
1787 location *loc,
1788 string *text)
1789 : statement (b, loc),
1790 m_text (text) {}
1792 void replay_into (replayer *r) FINAL OVERRIDE;
1794 private:
1795 string * make_debug_string () FINAL OVERRIDE;
1796 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1798 private:
1799 string *m_text;
1802 class conditional : public statement
1804 public:
1805 conditional (block *b,
1806 location *loc,
1807 rvalue *boolval,
1808 block *on_true,
1809 block *on_false)
1810 : statement (b, loc),
1811 m_boolval (boolval),
1812 m_on_true (on_true),
1813 m_on_false (on_false) {}
1815 void replay_into (replayer *r) FINAL OVERRIDE;
1817 vec <block *> get_successor_blocks () const FINAL OVERRIDE;
1819 private:
1820 string * make_debug_string () FINAL OVERRIDE;
1821 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1823 private:
1824 rvalue *m_boolval;
1825 block *m_on_true;
1826 block *m_on_false;
1829 class jump : public statement
1831 public:
1832 jump (block *b,
1833 location *loc,
1834 block *target)
1835 : statement (b, loc),
1836 m_target (target) {}
1838 void replay_into (replayer *r) FINAL OVERRIDE;
1840 vec <block *> get_successor_blocks () const FINAL OVERRIDE;
1842 private:
1843 string * make_debug_string () FINAL OVERRIDE;
1844 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1846 private:
1847 block *m_target;
1850 class return_ : public statement
1852 public:
1853 return_ (block *b,
1854 location *loc,
1855 rvalue *rvalue)
1856 : statement (b, loc),
1857 m_rvalue (rvalue) {}
1859 void replay_into (replayer *r) FINAL OVERRIDE;
1861 vec <block *> get_successor_blocks () const FINAL OVERRIDE;
1863 private:
1864 string * make_debug_string () FINAL OVERRIDE;
1865 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1867 private:
1868 rvalue *m_rvalue;
1871 class case_ : public memento
1873 public:
1874 case_ (context *ctxt,
1875 rvalue *min_value,
1876 rvalue *max_value,
1877 block *dest_block)
1878 : memento (ctxt),
1879 m_min_value (min_value),
1880 m_max_value (max_value),
1881 m_dest_block (dest_block)
1884 rvalue *get_min_value () const { return m_min_value; }
1885 rvalue *get_max_value () const { return m_max_value; }
1886 block *get_dest_block () const { return m_dest_block; }
1888 void replay_into (replayer *) FINAL OVERRIDE { /* empty */ }
1890 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1892 private:
1893 string * make_debug_string () FINAL OVERRIDE;
1895 private:
1896 rvalue *m_min_value;
1897 rvalue *m_max_value;
1898 block *m_dest_block;
1901 class switch_ : public statement
1903 public:
1904 switch_ (block *b,
1905 location *loc,
1906 rvalue *expr,
1907 block *default_block,
1908 int num_cases,
1909 case_ **cases);
1911 void replay_into (replayer *r) FINAL OVERRIDE;
1913 vec <block *> get_successor_blocks () const FINAL OVERRIDE;
1915 private:
1916 string * make_debug_string () FINAL OVERRIDE;
1917 void write_reproducer (reproducer &r) FINAL OVERRIDE;
1919 private:
1920 rvalue *m_expr;
1921 block *m_default_block;
1922 auto_vec <case_ *> m_cases;
1925 } // namespace gcc::jit::recording
1927 /* Create a recording::memento_of_new_rvalue_from_const instance and add
1928 it to this context's list of mementos.
1930 Implements the post-error-checking part of
1931 gcc_jit_context_new_rvalue_from_{int|long|double|ptr}. */
1933 template <typename HOST_TYPE>
1934 recording::rvalue *
1935 recording::context::new_rvalue_from_const (recording::type *type,
1936 HOST_TYPE value)
1938 recording::rvalue *result =
1939 new memento_of_new_rvalue_from_const <HOST_TYPE> (this, NULL, type, value);
1940 record (result);
1941 return result;
1944 } // namespace gcc::jit
1946 } // namespace gcc
1948 #endif /* JIT_RECORDING_H */