Support integers of any size
diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c
index 0aa535e..1a412b5 100644
--- a/gcc/jit/jit-recording.c
+++ b/gcc/jit/jit-recording.c
@@ -23,6 +23,8 @@
 #include "coretypes.h"
 #include "tm.h"
 #include "pretty-print.h"
+#include "tree.h"
+#include "stor-layout.h"
 #include "toplev.h"
 
 #include <pthread.h>
@@ -562,6 +564,8 @@
     m_compound_types (),
     m_globals (),
     m_functions (),
+    m_signed_int_types(),
+    m_unsigned_int_types(),
     m_FILE_type (NULL),
     m_builtins_manager(NULL)
 {
@@ -827,10 +831,47 @@
 		     ? GCC_JIT_TYPE_INT128_T
 		     : GCC_JIT_TYPE_UINT128_T);
 
-  /* Some other size, not corresponding to the C int types.  */
-  /* To be written: support arbitrary other sizes, sharing by
-     memoizing at the recording::context level?  */
-  gcc_unreachable ();
+  // TODO: check in num_bits > 0?
+  tree int_type;
+  if (is_signed)
+  {
+    if (tree type = m_signed_int_types[num_bits])
+    {
+      int_type = type;
+    }
+    else
+    {
+      int_type = make_signed_type(num_bits);
+      m_signed_int_types[num_bits] = int_type;
+    }
+  }
+  else
+  {
+    if (tree type = m_unsigned_int_types[num_bits])
+    {
+      int_type = type;
+    }
+    else
+    {
+      int_type = make_unsigned_type(num_bits);
+      m_unsigned_int_types[num_bits] = int_type;
+    }
+  }
+
+  recording::type *result = new memento_of_make_type (this, int_type, num_bits);
+  record (result);
+  return result;
+}
+
+void
+recording::memento_of_make_type::write_reproducer (reproducer &r)
+{
+  const char *id = r.make_identifier (this, "type");
+  r.write ("  gcc_jit_type *%s = gcc_jit_context_get_int_type (%s, %ld, %d);\n",
+	   id,
+	   r.get_identifier (get_context ()),
+	   m_num_bits,
+	   true); // TODO
 }
 
 /* Create a recording::type instance and add it to this context's list
@@ -2714,6 +2755,24 @@
 	   get_type_enum_strings[m_kind]);
 }
 
+/* Implementation of pure virtual hook recording::memento::replay_into
+   for recording::memento_of_make_type.  */
+
+void
+recording::memento_of_make_type::replay_into (replayer *r)
+{
+  set_playback_obj (this);
+}
+
+recording::string *
+recording::memento_of_make_type::make_debug_string ()
+{
+  char buf[256] = {0};
+  buf[0] = 'i';
+  sprintf(&buf[1], "%ld", m_num_bits);
+  return m_ctxt->new_string (buf);
+}
+
 /* The implementation of class gcc::jit::recording::memento_of_get_pointer.  */
 
 /* Override of default implementation of
diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h
index 36c8fba..c06874e 100644
--- a/gcc/jit/jit-recording.h
+++ b/gcc/jit/jit-recording.h
@@ -368,6 +368,9 @@
   auto_vec<top_level_asm *> m_top_level_asms;
 
   type *m_basic_types[NUM_GCC_JIT_TYPES];
+  /* Map from num_bits to integer types. */
+  tree m_signed_int_types[128];
+  tree m_unsigned_int_types[128];
   type *m_FILE_type;
 
   builtins_manager *m_builtins_manager; // lazily created
@@ -638,6 +641,46 @@
   enum gcc_jit_types m_kind;
 };
 
+/* Result of "gcc_jit_context_get_type" for non power of 2 integers.  */
+class memento_of_make_type : public type
+{
+public:
+  memento_of_make_type (context *ctxt,
+			tree int_type,
+			size_t num_bits)
+  : type (ctxt),
+    m_type (int_type),
+    m_num_bits (num_bits) {}
+
+  type *dereference () FINAL OVERRIDE { return NULL; };
+
+  size_t get_size () FINAL OVERRIDE { return m_num_bits; };
+
+  bool accepts_writes_from (type *rtype) FINAL OVERRIDE
+  {
+    return type::accepts_writes_from (rtype);
+  }
+
+  bool is_int () const FINAL OVERRIDE { return true; };
+  bool is_float () const FINAL OVERRIDE { return false; };
+  bool is_bool () const FINAL OVERRIDE { return false; };
+  type *is_pointer () FINAL OVERRIDE { return NULL; }
+  type *is_array () FINAL OVERRIDE { return NULL; }
+  bool is_void () const FINAL OVERRIDE { return false; }
+
+public:
+  void replay_into (replayer *r) FINAL OVERRIDE;
+
+private:
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
+
+private:
+  tree m_type;
+  size_t m_num_bits;
+};
+
+
 /* Result of "gcc_jit_type_get_pointer".  */
 class memento_of_get_pointer : public type
 {