jit: prevent ICE with type mismatch in gcc_jit_block_add_assignment_op
[platform/upstream/gcc.git] / gcc / jit / jit-playback.h
index 25a4c28..8efd506 100644 (file)
@@ -1,5 +1,5 @@
 /* Internals of libgccjit: classes for playing back recorded API calls.
-   Copyright (C) 2013-2014 Free Software Foundation, Inc.
+   Copyright (C) 2013-2015 Free Software Foundation, Inc.
    Contributed by David Malcolm <dmalcolm@redhat.com>.
 
 This file is part of GCC.
@@ -35,7 +35,7 @@ namespace jit {
 
 namespace playback {
 
-class context
+class context : public log_user
 {
 public:
   context (::gcc::jit::recording::context *ctxt);
@@ -90,20 +90,14 @@ public:
 
   lvalue *
   new_global (location *loc,
+             enum gcc_jit_global_kind kind,
              type *type,
              const char *name);
 
+  template <typename HOST_TYPE>
   rvalue *
-  new_rvalue_from_int (type *type,
-                      int value);
-
-  rvalue *
-  new_rvalue_from_double (type *type,
-                         double value);
-
-  rvalue *
-  new_rvalue_from_ptr (type *type,
-                      void *value);
+  new_rvalue_from_const (type *type,
+                        HOST_TYPE value);
 
   rvalue *
   new_string_literal (const char *value);
@@ -175,6 +169,11 @@ public:
     return m_recording_ctxt->get_bool_option (opt);
   }
 
+  builtins_manager *get_builtins_manager () const
+  {
+    return m_recording_ctxt->get_builtins_manager ();
+  }
+
   result *
   compile ();
 
@@ -208,6 +207,10 @@ public:
     return m_recording_ctxt->errors_occurred ();
   }
 
+  /* For use by jit_langhook_write_globals.  */
+  void write_global_decls_1 ();
+  void write_global_decls_2 ();
+
 private:
   void dump_generated_code ();
 
@@ -226,32 +229,42 @@ private:
 
   void handle_locations ();
 
+  const char * get_path_c_file () const;
+  const char * get_path_s_file () const;
+  const char * get_path_so_file () const;
+
 private:
 
   /* Functions for implementing "compile".  */
 
+  void acquire_mutex ();
+  void release_mutex ();
+
+  void
+  make_fake_args (vec <char *> *argvec,
+                 const char *ctxt_progname,
+                 vec <recording::requested_dump> *requested_dumps);
+
   void
-  make_fake_args (auto_vec <const char *> *argvec,
-                 const char *ctxt_progname);
+  extract_any_requested_dumps
+    (vec <recording::requested_dump> *requested_dumps);
+
+  char *
+  read_dump_file (const char *path);
 
   void
   convert_to_dso (const char *ctxt_progname);
 
+  result *
+  dlopen_built_dso ();
+
 private:
   ::gcc::jit::recording::context *m_recording_ctxt;
 
-  /* Allocated using xmalloc (by xstrdup).  */
-  char *m_path_template;
-
-  /* This either aliases m_path_template, or is NULL.  */
-  char *m_path_tempdir;
-
-  /* The following are allocated using xmalloc.  */
-  char *m_path_c_file;
-  char *m_path_s_file;
-  char *m_path_so_file;
+  tempdir *m_tempdir;
 
   auto_vec<function *> m_functions;
+  auto_vec<tree> m_globals;
   tree m_char_array_type_node;
   tree m_const_char_ptr;