[m-rev.] for review: add builtin 8, 16 and 32 bit integer types -- Part 1

Julien Fischer jfischer at opturion.com
Sat Jul 1 01:13:12 AEST 2017


For review by anyone.

This diff is quite large and mostly not that interesting.  (It's fairly similar
to the initial change that introduced uints.)  There are a couple of points I
would like feedback on: in C grades, we map the new Mercury types directly on
to C99's fixed sized integer types (e.g. int8_t, uint32_t etc) rather than have
Mercury's runtime define 'MR_Integer8' or something along those lines.  One
effect of this is that we now require a C environment that provides the header
stdint.h.  With this change Mercury will no longer compiler in the absence of
that header file.  Are there any objections to either of these things?

----------------

Add builtin 8, 16 and 32 bit integer types -- Part 1.

Add the new builtin types: int8, uint8, int16, uint16, int32 and uint32.
Support for these new types will need to be bootstrapped over several changes.
This is the first such change and does the following:

- Extends the compiler to recognise 'int8', 'uint8', 'int16', 'uint16', 'int32'
   and 'uint32' as builtin types.
- Extends the set of builtin arithmetic, bitwise and relational operators to
   cover the new types.
- Extends all of the code generators to handle new types.  There currently lots
   of limitations and placeholders marked by 'XXX FIXED SIZE INT'.  These will
   be lifted in later changes.
- Extends the runtimes to support the new types.
- Adds new modules to the standard library intended to hold the basic
   operations on the new types.  (These are currently empty and not documented.)

This change does not introduce the two 64-bit types, 'int64' and 'uint64'.
Their implementation is more complicated and is best left to a separate change.

compiler/prog_type.m:
compiler/prog_data.m:
compiler/builtin_lib_types.m:
     Recognise int8, uint8, int16, uint16, int32 and uint32 as builtin types.

     Extend the cons_id/0 type to cover types.

compiler/builtin_ops.m:
     Add builtin relational and arithmetic operations on the new types.

compiler/hlds_data.m:
     Add new tag types for the new types.

compiler/type_ctor_info.m:
     Recognise the new types as builtins.

     Bump the RTTI version number here.

compiler/ctgc.selector.m:
compiler/dead_proc_elim.m:
compiler/export.m:
compiler/foreign.m:
compiler/goal_util.m:
compiler/higher_order.m:
compiler/hlds_code_util.m:
compiler/hlds_dependency_graph.m:
compiler/hlds_out_pred.m:
compiler/hlds_out_util.m:
compiler/hlds_pred.m:
compiler/implementation_defined_literals.m:
compiler/inst_check.m:
compiler/lookup_switch.m:
compiler/mercury_to_mercury.m:
compiler/mode_util.m:
compiler/module_qual.qualify_items.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/parse_tree_out_info.m:
compiler/parse_tree_to_term.m:
compiler/parse_type_name.m:
compiler/polymorphism.m:
compiler/prog_out.m:
compiler/prog_rep.m:
compiler/prog_rep_tables.m:
compiler/prog_util.m:
compiler/rbmm.exection_path.m:
compiler/rtti.m:
compiler/rtti_to_mlds.m:
compiler/switch_gen.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/type_constraints.m:
compiler/type_util.m:
compiler/typecheck.m:
compiler/unify_gen.m:
compiler/unify_proc.m:
compiler/unused_imports.m:
compiler/xml_documentation.m:
     Conform to the above changes to the parse tree and HLDS.

compiler/c_util.m:
     Support generating the builtin operations for the new types.


doc/reference_manual.texi:
      Add the new types to the list of reserved type names.

      Add the mapping from the new types to their target language types.
      These are commented out for now.

compiler/llds.m:
      Add a representations for constants of the new types to the LLDS.

compiler/call_gen.m:
compiler/dupproc.m:
compiler/exprn_aux.m:
compiler/global_data.m:
compiler/jumpopt.m:
compiler/llds_out_data.m:
compiler/llds_out_instr.m:
      Support the new types in the LLDS code generator.

compiler/mlds.m:
      Support constants of the new types in the MLDS.

compiler/ml_accurate_gc.m:
compiler/ml_call_gen.m:
compiler/ml_code_util.m:
compiler/ml_global_data.m:
compiler/ml_simplify_switch.m:
compiler/ml_switch_gen.m:
compiler/ml_tailcall.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/ml_util.m:
compiler/mlds_to_target_util.m:
      Conform to the above changes to the MLDS.

compiler/mlds_to_c.m:
compiler/mlds_to_cs.m:
compiler/mlds_to_java.m:
      Generate the appropriate target code for constants of the new
      types and operations involving them.

compiler/bytecode.m:
compiler/bytecode_gen.m:
     Handle the new types in the bytecode generator; we just abort if we
     encounter them for now.

compiler/elds.m:
compiler/elds_to_erlang.m:
compiler/erl_call_gen.m:
compiler/erl_code_util.m:
compiler/erl_rtti.m:
compiler/erl_unify_gen.m:
     Handle the new types in the Erlang code generator.

library/private_builtin.m:
     Add placeholders for the builtin unify and compare operations for
     the new types.  Since the bootstrapping compiler will not recognise
     the new types we give the polymorphic arguments.  These can be
     replaced after this change has bootstrapped.

     Update the Java list of TypeCtorRep constants.

library/int8.m:
library/int16.m:
library/int32.m:
library/uint8.m:
library/uint16.m:
library/uint32.m:
     New modules that will eventually contain builtin operations
     on the new types.

library/library.m:
library/MODULES_UNDOC:
     Do not include the above modules in the library documentation
     for now.

library/construct.m:
library/erlang_rtti_implementation.m:
library/rtti_implementation.m:
deep_profiler/program_representation_utils.m:
mdbcomp/program_representation.m:
     Handle the new types.

runtime/mercury_dotnet.cs.in:
java/runtime/TypeCtorRep.java:
     Update the list of TypeCtorReps.

runtime/mercury_header.h:
     Bump the binary compatibility version.

configure.ac:
runtime/mercury_conf.h.in:
     Check for the header stdint.h.

runtime/mercury_std.h:
     Include stdint.h; abort if that header is no present.

runtime/mercury_type_info.h:
     Bump the RTTI version number.

runtime/mercury_builtin_types.[ch]:
runtime/mercury_builtin_types_proc_layouts.h:
runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_ml_expand_body.h
runtime/mercury_table_type_body.h:
runtime/mercury_tabling_macros.h:
runtime/mercury_tabling_preds.h:
runtime/mercury_term_size.c:
runtime/mercury_unify_compare_body.h:
      Add the new builtin types and handle them throughout the runtime.

diff --git a/compiler/builtin_lib_types.m b/compiler/builtin_lib_types.m
index 44ab70241..870906983 100644
--- a/compiler/builtin_lib_types.m
+++ b/compiler/builtin_lib_types.m
@@ -26,6 +26,12 @@

  :- func int_type = mer_type.
  :- func uint_type = mer_type.
+:- func int8_type = mer_type.
+:- func uint8_type = mer_type.
+:- func int16_type = mer_type.
+:- func uint16_type = mer_type.
+:- func int32_type = mer_type.
+:- func uint32_type = mer_type.
  :- func float_type = mer_type.
  :- func string_type = mer_type.
  :- func char_type = mer_type.
@@ -60,6 +66,12 @@

  :- func int_type_ctor = type_ctor.
  :- func uint_type_ctor = type_ctor.
+:- func int8_type_ctor = type_ctor.
+:- func uint8_type_ctor = type_ctor.
+:- func int16_type_ctor = type_ctor.
+:- func uint16_type_ctor = type_ctor.
+:- func int32_type_ctor = type_ctor.
+:- func uint32_type_ctor = type_ctor.
  :- func float_type_ctor = type_ctor.
  :- func char_type_ctor = type_ctor.
  :- func string_type_ctor = type_ctor.
@@ -116,6 +128,18 @@ int_type = builtin_type(builtin_type_int).

  uint_type = builtin_type(builtin_type_uint).

+int8_type = builtin_type(builtin_type_int8).
+
+uint8_type = builtin_type(builtin_type_uint8).
+
+int16_type = builtin_type(builtin_type_int16).
+
+uint16_type = builtin_type(builtin_type_uint16).
+
+int32_type = builtin_type(builtin_type_int32).
+
+uint32_type = builtin_type(builtin_type_uint32).
+
  float_type = builtin_type(builtin_type_float).

  string_type = builtin_type(builtin_type_string).
@@ -218,6 +242,18 @@ int_type_ctor = type_ctor(Name, 0) :-
      Name = unqualified("int").
  uint_type_ctor = type_ctor(Name, 0) :-
      Name = unqualified("uint").
+int8_type_ctor = type_ctor(Name, 0) :-
+    Name = unqualified("int8").
+uint8_type_ctor = type_ctor(Name, 0) :-
+    Name = unqualified("uint8").
+int16_type_ctor = type_ctor(Name, 0) :-
+    Name = unqualified("int16").
+uint16_type_ctor = type_ctor(Name, 0) :-
+    Name = unqualified("uint16").
+int32_type_ctor = type_ctor(Name, 0) :-
+    Name = unqualified("int32").
+uint32_type_ctor = type_ctor(Name, 0) :-
+    Name = unqualified("uint32").
  float_type_ctor = type_ctor(Name, 0) :-
      Name = unqualified("float").
  char_type_ctor = type_ctor(Name, 0) :-
diff --git a/compiler/builtin_ops.m b/compiler/builtin_ops.m
index 6b1f40fcf..9617a7c54 100644
--- a/compiler/builtin_ops.m
+++ b/compiler/builtin_ops.m
@@ -38,6 +38,12 @@
      ;       bitwise_complement
      ;       logical_not
      ;       uint_bitwise_complement
+    ;       int8_bitwise_complement
+    ;       uint8_bitwise_complement
+    ;       int16_bitwise_complement
+    ;       uint16_bitwise_complement
+    ;       int32_bitwise_complement
+    ;       uint32_bitwise_complement
      ;       hash_string
      ;       hash_string2
      ;       hash_string3
@@ -114,6 +120,126 @@
      ;       uint_unchecked_left_shift
      ;       uint_unchecked_right_shift

+    ;       int8_eq
+    ;       int8_ne
+    ;       int8_lt
+    ;       int8_gt
+    ;       int8_le
+    ;       int8_ge
+
+    ;       int8_add
+    ;       int8_sub
+    ;       int8_mul
+    ;       int8_div
+    ;       int8_mod
+
+    ;       int8_bitwise_and
+    ;       int8_bitwise_or
+    ;       int8_bitwise_xor
+
+    ;       int8_unchecked_left_shift
+    ;       int8_unchecked_right_shift
+
+    ;       uint8_eq
+    ;       uint8_ne
+    ;       uint8_lt
+    ;       uint8_gt
+    ;       uint8_le
+    ;       uint8_ge
+
+    ;       uint8_add
+    ;       uint8_sub
+    ;       uint8_mul
+    ;       uint8_div
+    ;       uint8_mod
+
+    ;       uint8_bitwise_and
+    ;       uint8_bitwise_or
+    ;       uint8_bitwise_xor
+
+    ;       uint8_unchecked_left_shift
+    ;       uint8_unchecked_right_shift
+
+    ;       int16_eq
+    ;       int16_ne
+    ;       int16_lt
+    ;       int16_gt
+    ;       int16_le
+    ;       int16_ge
+
+    ;       int16_add
+    ;       int16_sub
+    ;       int16_mul
+    ;       int16_div
+    ;       int16_mod
+
+    ;       int16_bitwise_and
+    ;       int16_bitwise_or
+    ;       int16_bitwise_xor
+
+    ;       int16_unchecked_left_shift
+    ;       int16_unchecked_right_shift
+
+    ;       uint16_eq
+    ;       uint16_ne
+    ;       uint16_lt
+    ;       uint16_gt
+    ;       uint16_le
+    ;       uint16_ge
+
+    ;       uint16_add
+    ;       uint16_sub
+    ;       uint16_mul
+    ;       uint16_div
+    ;       uint16_mod
+
+    ;       uint16_bitwise_and
+    ;       uint16_bitwise_or
+    ;       uint16_bitwise_xor
+
+    ;       uint16_unchecked_left_shift
+    ;       uint16_unchecked_right_shift
+
+    ;       int32_eq
+    ;       int32_ne
+    ;       int32_lt
+    ;       int32_gt
+    ;       int32_le
+    ;       int32_ge
+
+    ;       int32_add
+    ;       int32_sub
+    ;       int32_mul
+    ;       int32_div
+    ;       int32_mod
+
+    ;       int32_bitwise_and
+    ;       int32_bitwise_or
+    ;       int32_bitwise_xor
+
+    ;       int32_unchecked_left_shift
+    ;       int32_unchecked_right_shift
+
+    ;       uint32_eq
+    ;       uint32_ne
+    ;       uint32_lt
+    ;       uint32_gt
+    ;       uint32_le
+    ;       uint32_ge
+
+    ;       uint32_add
+    ;       uint32_sub
+    ;       uint32_mul
+    ;       uint32_div
+    ;       uint32_mod
+
+    ;       uint32_bitwise_and
+    ;       uint32_bitwise_or
+    ;       uint32_bitwise_xor
+
+    ;       uint32_unchecked_left_shift
+    ;       uint32_unchecked_right_shift
+
      ;       float_plus      %  XXX the integer versions use different names.
      ;       float_minus     %  E.g add instead of plus etc.
      ;       float_times
@@ -186,6 +312,12 @@
      --->    leaf(T)
      ;       int_const(int)
      ;       uint_const(uint)
+    ;       int8_const(int)     % XXX FIXED SIZE INTS
+    ;       uint8_const(int)    % XXX FIXED SIZE INTS
+    ;       int16_const(int)    % XXX FIXED SIZE INTS
+    ;       uint16_const(int)   % XXX FIXED SIZE INTS
+    ;       int32_const(int)    % XXX FIXED SIZE INTS
+    ;       uint32_const(int)   % XXX FIXED SIZE INTS
      ;       float_const(float)
      ;       unary(unary_op, simple_expr(T))
      ;       binary(binary_op, simple_expr(T), simple_expr(T)).
diff --git a/compiler/bytecode.m b/compiler/bytecode.m
index 5dc8d79b2..6876669bc 100644
--- a/compiler/bytecode.m
+++ b/compiler/bytecode.m
@@ -1092,6 +1092,102 @@ binop_code(uint_bitwise_or,         57).
  binop_code(uint_bitwise_xor,        58).
  binop_code(uint_unchecked_left_shift, 59).
  binop_code(uint_unchecked_right_shift, 60).
+binop_code(int8_eq,                 61).
+binop_code(int8_ne,                 62).
+binop_code(int8_lt,                 63).
+binop_code(int8_gt,                 64).
+binop_code(int8_le,                 65).
+binop_code(int8_ge,                 66).
+binop_code(int8_add,                67).
+binop_code(int8_sub,                68).
+binop_code(int8_mul,                69).
+binop_code(int8_div,                70).
+binop_code(int8_mod,                71).
+binop_code(int8_bitwise_and,        72).
+binop_code(int8_bitwise_or,         73).
+binop_code(int8_bitwise_xor,        74).
+binop_code(int8_unchecked_left_shift, 75).
+binop_code(int8_unchecked_right_shift, 76).
+binop_code(uint8_eq,                 77).
+binop_code(uint8_ne,                 78).
+binop_code(uint8_lt,                 79).
+binop_code(uint8_gt,                 80).
+binop_code(uint8_le,                 81).
+binop_code(uint8_ge,                 82).
+binop_code(uint8_add,                83).
+binop_code(uint8_sub,                84).
+binop_code(uint8_mul,                85).
+binop_code(uint8_div,                86).
+binop_code(uint8_mod,                87).
+binop_code(uint8_bitwise_and,        88).
+binop_code(uint8_bitwise_or,         89).
+binop_code(uint8_bitwise_xor,        90).
+binop_code(uint8_unchecked_left_shift, 91).
+binop_code(uint8_unchecked_right_shift, 92).
+binop_code(int16_eq,                 93).
+binop_code(int16_ne,                 94).
+binop_code(int16_lt,                 95).
+binop_code(int16_gt,                 96).
+binop_code(int16_le,                 97).
+binop_code(int16_ge,                 98).
+binop_code(int16_add,                99).
+binop_code(int16_sub,                100).
+binop_code(int16_mul,                101).
+binop_code(int16_div,                102).
+binop_code(int16_mod,                103).
+binop_code(int16_bitwise_and,        104).
+binop_code(int16_bitwise_or,         105).
+binop_code(int16_bitwise_xor,        106).
+binop_code(int16_unchecked_left_shift, 107).
+binop_code(int16_unchecked_right_shift, 108).
+binop_code(uint16_eq,                 109).
+binop_code(uint16_ne,                 110).
+binop_code(uint16_lt,                 111).
+binop_code(uint16_gt,                 112).
+binop_code(uint16_le,                 113).
+binop_code(uint16_ge,                 114).
+binop_code(uint16_add,                115).
+binop_code(uint16_sub,                116).
+binop_code(uint16_mul,                117).
+binop_code(uint16_div,                118).
+binop_code(uint16_mod,                119).
+binop_code(uint16_bitwise_and,        120).
+binop_code(uint16_bitwise_or,         121).
+binop_code(uint16_bitwise_xor,        122).
+binop_code(uint16_unchecked_left_shift, 123).
+binop_code(uint16_unchecked_right_shift, 124).
+binop_code(int32_eq,                 125).
+binop_code(int32_ne,                 126).
+binop_code(int32_lt,                 127).
+binop_code(int32_gt,                 128).
+binop_code(int32_le,                 129).
+binop_code(int32_ge,                 130).
+binop_code(int32_add,                131).
+binop_code(int32_sub,                132).
+binop_code(int32_mul,                133).
+binop_code(int32_div,                134).
+binop_code(int32_mod,                135).
+binop_code(int32_bitwise_and,        136).
+binop_code(int32_bitwise_or,         137).
+binop_code(int32_bitwise_xor,        138).
+binop_code(int32_unchecked_left_shift, 139).
+binop_code(int32_unchecked_right_shift, 140).
+binop_code(uint32_eq,                 141).
+binop_code(uint32_ne,                 142).
+binop_code(uint32_lt,                 143).
+binop_code(uint32_gt,                 144).
+binop_code(uint32_le,                 145).
+binop_code(uint32_ge,                 146).
+binop_code(uint32_add,                147).
+binop_code(uint32_sub,                148).
+binop_code(uint32_mul,                149).
+binop_code(uint32_div,                150).
+binop_code(uint32_mod,                151).
+binop_code(uint32_bitwise_and,        152).
+binop_code(uint32_bitwise_or,         153).
+binop_code(uint32_bitwise_xor,        154).
+binop_code(uint32_unchecked_left_shift, 155).
+binop_code(uint32_unchecked_right_shift, 156).

  :- pred binop_debug(binary_op::in, string::out) is det.

@@ -1156,6 +1252,102 @@ binop_debug(uint_bitwise_or,        "uint_bitwise_or").
  binop_debug(uint_bitwise_xor,       "uint_bitwise_xor").
  binop_debug(uint_unchecked_left_shift, "uint_unchecked_left_shift").
  binop_debug(uint_unchecked_right_shift, "uint_unchecked_right_shift").
+binop_debug(int8_eq,                "int8_eq").
+binop_debug(int8_ne,                "int8_ne").
+binop_debug(int8_lt,                "int8_lt").
+binop_debug(int8_gt,                "int8_gt").
+binop_debug(int8_le,                "int8_le").
+binop_debug(int8_ge,                "int8_ge").
+binop_debug(int8_add,               "int8_add").
+binop_debug(int8_sub,               "int8_sub").
+binop_debug(int8_mul,               "int8_mul").
+binop_debug(int8_div,               "int8_div").
+binop_debug(int8_mod,               "int8_mod").
+binop_debug(int8_bitwise_and,       "int8_bitwise_and").
+binop_debug(int8_bitwise_or,        "int8_bitwise_or").
+binop_debug(int8_bitwise_xor,       "int8_bitwise_xor").
+binop_debug(int8_unchecked_left_shift, "int8_unchecked_left_shift").
+binop_debug(int8_unchecked_right_shift, "int8_unchecked_right_shift").
+binop_debug(uint8_eq,                "uint8_eq").
+binop_debug(uint8_ne,                "uint8_ne").
+binop_debug(uint8_lt,                "uint8_lt").
+binop_debug(uint8_gt,                "uint8_gt").
+binop_debug(uint8_le,                "uint8_le").
+binop_debug(uint8_ge,                "uint8_ge").
+binop_debug(uint8_add,               "uint8_add").
+binop_debug(uint8_sub,               "uint8_sub").
+binop_debug(uint8_mul,               "uint8_mul").
+binop_debug(uint8_div,               "uint8_div").
+binop_debug(uint8_mod,               "uint8_mod").
+binop_debug(uint8_bitwise_and,       "uint8_bitwise_and").
+binop_debug(uint8_bitwise_or,        "uint8_bitwise_or").
+binop_debug(uint8_bitwise_xor,       "uint8_bitwise_xor").
+binop_debug(uint8_unchecked_left_shift, "uint8_unchecked_left_shift").
+binop_debug(uint8_unchecked_right_shift, "uint8_unchecked_right_shift").
+binop_debug(int16_eq,                "int16_eq").
+binop_debug(int16_ne,                "int16_ne").
+binop_debug(int16_lt,                "int16_lt").
+binop_debug(int16_gt,                "int16_gt").
+binop_debug(int16_le,                "int16_le").
+binop_debug(int16_ge,                "int16_ge").
+binop_debug(int16_add,               "int16_add").
+binop_debug(int16_sub,               "int16_sub").
+binop_debug(int16_mul,               "int16_mul").
+binop_debug(int16_div,               "int16_div").
+binop_debug(int16_mod,               "int16_mod").
+binop_debug(int16_bitwise_and,       "int16_bitwise_and").
+binop_debug(int16_bitwise_or,        "int16_bitwise_or").
+binop_debug(int16_bitwise_xor,       "int16_bitwise_xor").
+binop_debug(int16_unchecked_left_shift, "int16_unchecked_left_shift").
+binop_debug(int16_unchecked_right_shift, "int16_unchecked_right_shift").
+binop_debug(uint16_eq,                "uint16_eq").
+binop_debug(uint16_ne,                "uint16_ne").
+binop_debug(uint16_lt,                "uint16_lt").
+binop_debug(uint16_gt,                "uint16_gt").
+binop_debug(uint16_le,                "uint16_le").
+binop_debug(uint16_ge,                "uint16_ge").
+binop_debug(uint16_add,               "uint16_add").
+binop_debug(uint16_sub,               "uint16_sub").
+binop_debug(uint16_mul,               "uint16_mul").
+binop_debug(uint16_div,               "uint16_div").
+binop_debug(uint16_mod,               "uint16_mod").
+binop_debug(uint16_bitwise_and,       "uint16_bitwise_and").
+binop_debug(uint16_bitwise_or,        "uint16_bitwise_or").
+binop_debug(uint16_bitwise_xor,       "uint16_bitwise_xor").
+binop_debug(uint16_unchecked_left_shift, "uint16_unchecked_left_shift").
+binop_debug(uint16_unchecked_right_shift, "uint16_unchecked_right_shift").
+binop_debug(int32_eq,                "int32_eq").
+binop_debug(int32_ne,                "int32_ne").
+binop_debug(int32_lt,                "int32_lt").
+binop_debug(int32_gt,                "int32_gt").
+binop_debug(int32_le,                "int32_le").
+binop_debug(int32_ge,                "int32_ge").
+binop_debug(int32_add,               "int32_add").
+binop_debug(int32_sub,               "int32_sub").
+binop_debug(int32_mul,               "int32_mul").
+binop_debug(int32_div,               "int32_div").
+binop_debug(int32_mod,               "int32_mod").
+binop_debug(int32_bitwise_and,       "int32_bitwise_and").
+binop_debug(int32_bitwise_or,        "int32_bitwise_or").
+binop_debug(int32_bitwise_xor,       "int32_bitwise_xor").
+binop_debug(int32_unchecked_left_shift, "int32_unchecked_left_shift").
+binop_debug(int32_unchecked_right_shift, "int32_unchecked_right_shift").
+binop_debug(uint32_eq,                "uint32_eq").
+binop_debug(uint32_ne,                "uint32_ne").
+binop_debug(uint32_lt,                "uint32_lt").
+binop_debug(uint32_gt,                "uint32_gt").
+binop_debug(uint32_le,                "uint32_le").
+binop_debug(uint32_ge,                "uint32_ge").
+binop_debug(uint32_add,               "uint32_add").
+binop_debug(uint32_sub,               "uint32_sub").
+binop_debug(uint32_mul,               "uint32_mul").
+binop_debug(uint32_div,               "uint32_div").
+binop_debug(uint32_mod,               "uint32_mod").
+binop_debug(uint32_bitwise_and,       "uint32_bitwise_and").
+binop_debug(uint32_bitwise_or,        "uint32_bitwise_or").
+binop_debug(uint32_bitwise_xor,       "uint32_bitwise_xor").
+binop_debug(uint32_unchecked_left_shift, "uint32_unchecked_left_shift").
+binop_debug(uint32_unchecked_right_shift, "uint32_unchecked_right_shift").

  :- pred unop_code(unary_op::in, int::out) is det.

@@ -1174,6 +1366,12 @@ unop_code(hash_string4,        11).
  unop_code(hash_string5,        12).
  unop_code(hash_string6,        13).
  unop_code(uint_bitwise_complement, 14).
+unop_code(int8_bitwise_complement, 15).
+unop_code(uint8_bitwise_complement, 16).
+unop_code(int16_bitwise_complement, 17).
+unop_code(uint16_bitwise_complement, 18).
+unop_code(int32_bitwise_complement, 19).
+unop_code(uint32_bitwise_complement, 20).

  :- pred unop_debug(unary_op::in, string::out) is det.

@@ -1192,6 +1390,12 @@ unop_debug(hash_string4,        "hash_string4").
  unop_debug(hash_string5,        "hash_string5").
  unop_debug(hash_string6,        "hash_string6").
  unop_debug(uint_bitwise_complement, "uint_bitwise_complement").
+unop_debug(int8_bitwise_complement, "int8_bitwise_complement").
+unop_debug(uint8_bitwise_complement, "uint8_bitwise_complement").
+unop_debug(int16_bitwise_complement, "int16_bitwise_complement").
+unop_debug(uint16_bitwise_complement, "uint16_bitwise_complement").
+unop_debug(int32_bitwise_complement, "int32_bitwise_complement").
+unop_debug(uint32_bitwise_complement, "uint32_bitwise_complement").

  %---------------------------------------------------------------------------%

diff --git a/compiler/bytecode_gen.m b/compiler/bytecode_gen.m
index 9174830a4..d5f6d44bc 100644
--- a/compiler/bytecode_gen.m
+++ b/compiler/bytecode_gen.m
@@ -581,6 +581,24 @@ gen_unify(Unification, ByteInfo, Code) :-
              TypeCategory = ctor_cat_builtin(cat_builtin_uint),
              sorry($module, $pred, "uint")
          ;
+            TypeCategory = ctor_cat_builtin(cat_builtin_int8),
+            sorry($module, $pred, "int8")
+        ;
+            TypeCategory = ctor_cat_builtin(cat_builtin_uint8),
+            sorry($module, $pred, "uint8")
+        ;
+            TypeCategory = ctor_cat_builtin(cat_builtin_int16),
+            sorry($module, $pred, "int16")
+        ;
+            TypeCategory = ctor_cat_builtin(cat_builtin_uint16),
+            sorry($module, $pred, "uint16")
+        ;
+            TypeCategory = ctor_cat_builtin(cat_builtin_int32),
+            sorry($module, $pred, "int32")
+        ;
+            TypeCategory = ctor_cat_builtin(cat_builtin_uint32),
+            sorry($module, $pred, "uint32")
+        ;
              TypeCategory = ctor_cat_builtin(cat_builtin_char),
              TestId = char_test
          ;
@@ -769,6 +787,24 @@ map_cons_id(ByteInfo, ConsId, ByteConsId) :-
          ConsId = uint_const(_),
          unexpected($file, $pred, "uint")
      ;
+        ConsId = int8_const(_),
+        unexpected($file, $pred, "int8")
+    ;
+        ConsId = uint8_const(_),
+        unexpected($file, $pred, "uint8")
+    ;
+        ConsId = int16_const(_),
+        unexpected($file, $pred, "int16")
+    ;
+        ConsId = uint16_const(_),
+        unexpected($file, $pred, "uint16")
+    ;
+        ConsId = int32_const(_),
+        unexpected($file, $pred, "int32")
+    ;
+        ConsId = uint32_const(_),
+        unexpected($file, $pred, "uint32")
+    ;
          ConsId = float_const(FloatVal),
          ByteConsId = byte_float_const(FloatVal)
      ;
@@ -833,6 +869,18 @@ map_cons_tag(string_tag(_), _) :-
  map_cons_tag(int_tag(IntVal), byte_enum_tag(IntVal)).
  map_cons_tag(uint_tag(_), _) :-
      sorry($module, $pred, "bytecode with uints").
+map_cons_tag(int8_tag(_), _) :-
+    sorry($module, $pred, "bytecode with int8s").
+map_cons_tag(uint8_tag(_), _) :-
+    sorry($module, $pred, "bytecode with uint8s").
+map_cons_tag(int16_tag(_), _) :-
+    sorry($module, $pred, "bytecode with int16s").
+map_cons_tag(uint16_tag(_), _) :-
+    sorry($module, $pred, "bytecode with uint16s").
+map_cons_tag(int32_tag(_), _) :-
+    sorry($module, $pred, "bytecode with int32s").
+map_cons_tag(uint32_tag(_), _) :-
+    sorry($module, $pred, "bytecode with uint32s").
  map_cons_tag(foreign_tag(_, _), _) :-
      sorry($module, $pred, "bytecode with foreign tags").
  map_cons_tag(float_tag(_), _) :-
diff --git a/compiler/c_util.m b/compiler/c_util.m
index 4f25295ba..d22e2a93f 100644
--- a/compiler/c_util.m
+++ b/compiler/c_util.m
@@ -225,6 +225,18 @@
      ;       unsigned_compare_binop
      ;       uint_compare_binop
      ;       uint_binary_infix_binop
+    ;       int8_compare_binop
+    ;       int8_binary_infix_binop
+    ;       uint8_compare_binop
+    ;       uint8_binary_infix_binop
+    ;       int16_compare_binop
+    ;       int16_binary_infix_binop
+    ;       uint16_compare_binop
+    ;       uint16_binary_infix_binop
+    ;       int32_compare_binop
+    ;       int32_binary_infix_binop
+    ;       uint32_compare_binop
+    ;       uint32_binary_infix_binop
      ;       float_compare_binop
      ;       float_arith_binop
      ;       int_or_bool_binary_infix_binop
@@ -812,6 +824,12 @@ unary_prefix_op(unmkbody,           "MR_unmkbody").
  unary_prefix_op(bitwise_complement, "~").
  unary_prefix_op(logical_not,        "!").
  unary_prefix_op(uint_bitwise_complement, "~").
+unary_prefix_op(int8_bitwise_complement, "~").
+unary_prefix_op(uint8_bitwise_complement, "~").
+unary_prefix_op(int16_bitwise_complement, "~").
+unary_prefix_op(uint16_bitwise_complement, "~").
+unary_prefix_op(int32_bitwise_complement, "~").
+unary_prefix_op(uint32_bitwise_complement, "~").
  unary_prefix_op(hash_string,        "MR_hash_string").
  unary_prefix_op(hash_string2,       "MR_hash_string2").
  unary_prefix_op(hash_string3,       "MR_hash_string3").
@@ -858,6 +876,114 @@ binop_category_string(uint_bitwise_xor, uint_binary_infix_binop, "^").
  binop_category_string(uint_unchecked_left_shift, uint_binary_infix_binop, "<<").
  binop_category_string(uint_unchecked_right_shift, uint_binary_infix_binop, ">>").

+binop_category_string(int8_eq, int8_compare_binop, "==").
+binop_category_string(int8_ne, int8_compare_binop, "!=").
+binop_category_string(int8_le, int8_compare_binop, "<=").
+binop_category_string(int8_ge, int8_compare_binop, ">=").
+binop_category_string(int8_lt, int8_compare_binop, "<").
+binop_category_string(int8_gt, int8_compare_binop, ">").
+
+binop_category_string(int8_add, int8_binary_infix_binop, "+").
+binop_category_string(int8_sub, int8_binary_infix_binop, "-").
+binop_category_string(int8_mul, int8_binary_infix_binop, "*").
+binop_category_string(int8_div, int8_binary_infix_binop, "/").
+binop_category_string(int8_mod, int8_binary_infix_binop, "%").
+binop_category_string(int8_bitwise_and, int8_binary_infix_binop, "&").
+binop_category_string(int8_bitwise_or, int8_binary_infix_binop, "|").
+binop_category_string(int8_bitwise_xor, int8_binary_infix_binop, "^").
+binop_category_string(int8_unchecked_left_shift, int8_binary_infix_binop, "<<").
+binop_category_string(int8_unchecked_right_shift, int8_binary_infix_binop, ">>").
+
+binop_category_string(uint8_eq, uint8_compare_binop, "==").
+binop_category_string(uint8_ne, uint8_compare_binop, "!=").
+binop_category_string(uint8_le, uint8_compare_binop, "<=").
+binop_category_string(uint8_ge, uint8_compare_binop, ">=").
+binop_category_string(uint8_lt, uint8_compare_binop, "<").
+binop_category_string(uint8_gt, uint8_compare_binop, ">").
+
+binop_category_string(uint8_add, uint8_binary_infix_binop, "+").
+binop_category_string(uint8_sub, uint8_binary_infix_binop, "-").
+binop_category_string(uint8_mul, uint8_binary_infix_binop, "*").
+binop_category_string(uint8_div, uint8_binary_infix_binop, "/").
+binop_category_string(uint8_mod, uint8_binary_infix_binop, "%").
+binop_category_string(uint8_bitwise_and, uint8_binary_infix_binop, "&").
+binop_category_string(uint8_bitwise_or, uint8_binary_infix_binop, "|").
+binop_category_string(uint8_bitwise_xor, uint8_binary_infix_binop, "^").
+binop_category_string(uint8_unchecked_left_shift, uint8_binary_infix_binop, "<<").
+binop_category_string(uint8_unchecked_right_shift, uint8_binary_infix_binop, ">>").
+
+binop_category_string(int16_eq, int16_compare_binop, "==").
+binop_category_string(int16_ne, int16_compare_binop, "!=").
+binop_category_string(int16_le, int16_compare_binop, "<=").
+binop_category_string(int16_ge, int16_compare_binop, ">=").
+binop_category_string(int16_lt, int16_compare_binop, "<").
+binop_category_string(int16_gt, int16_compare_binop, ">").
+
+binop_category_string(int16_add, int16_binary_infix_binop, "+").
+binop_category_string(int16_sub, int16_binary_infix_binop, "-").
+binop_category_string(int16_mul, int16_binary_infix_binop, "*").
+binop_category_string(int16_div, int16_binary_infix_binop, "/").
+binop_category_string(int16_mod, int16_binary_infix_binop, "%").
+binop_category_string(int16_bitwise_and, int16_binary_infix_binop, "&").
+binop_category_string(int16_bitwise_or, int16_binary_infix_binop, "|").
+binop_category_string(int16_bitwise_xor, int16_binary_infix_binop, "^").
+binop_category_string(int16_unchecked_left_shift, int16_binary_infix_binop, "<<").
+binop_category_string(int16_unchecked_right_shift, int16_binary_infix_binop, ">>").
+
+binop_category_string(uint16_eq, uint16_compare_binop, "==").
+binop_category_string(uint16_ne, uint16_compare_binop, "!=").
+binop_category_string(uint16_le, uint16_compare_binop, "<=").
+binop_category_string(uint16_ge, uint16_compare_binop, ">=").
+binop_category_string(uint16_lt, uint16_compare_binop, "<").
+binop_category_string(uint16_gt, uint16_compare_binop, ">").
+
+binop_category_string(uint16_add, uint16_binary_infix_binop, "+").
+binop_category_string(uint16_sub, uint16_binary_infix_binop, "-").
+binop_category_string(uint16_mul, uint16_binary_infix_binop, "*").
+binop_category_string(uint16_div, uint16_binary_infix_binop, "/").
+binop_category_string(uint16_mod, uint16_binary_infix_binop, "%").
+binop_category_string(uint16_bitwise_and, uint16_binary_infix_binop, "&").
+binop_category_string(uint16_bitwise_or, uint16_binary_infix_binop, "|").
+binop_category_string(uint16_bitwise_xor, uint16_binary_infix_binop, "^").
+binop_category_string(uint16_unchecked_left_shift, uint16_binary_infix_binop, "<<").
+binop_category_string(uint16_unchecked_right_shift, uint_binary_infix_binop, ">>").
+
+binop_category_string(int32_eq, int32_compare_binop, "==").
+binop_category_string(int32_ne, int32_compare_binop, "!=").
+binop_category_string(int32_le, int32_compare_binop, "<=").
+binop_category_string(int32_ge, int32_compare_binop, ">=").
+binop_category_string(int32_lt, int32_compare_binop, "<").
+binop_category_string(int32_gt, int32_compare_binop, ">").
+
+binop_category_string(int32_add, int32_binary_infix_binop, "+").
+binop_category_string(int32_sub, int32_binary_infix_binop, "-").
+binop_category_string(int32_mul, int32_binary_infix_binop, "*").
+binop_category_string(int32_div, int32_binary_infix_binop, "/").
+binop_category_string(int32_mod, int32_binary_infix_binop, "%").
+binop_category_string(int32_bitwise_and, int32_binary_infix_binop, "&").
+binop_category_string(int32_bitwise_or, int32_binary_infix_binop, "|").
+binop_category_string(int32_bitwise_xor, int32_binary_infix_binop, "^").
+binop_category_string(int32_unchecked_left_shift, int32_binary_infix_binop, "<<").
+binop_category_string(int32_unchecked_right_shift, int32_binary_infix_binop, ">>").
+
+binop_category_string(uint32_eq, uint32_compare_binop, "==").
+binop_category_string(uint32_ne, uint32_compare_binop, "!=").
+binop_category_string(uint32_le, uint32_compare_binop, "<=").
+binop_category_string(uint32_ge, uint32_compare_binop, ">=").
+binop_category_string(uint32_lt, uint32_compare_binop, "<").
+binop_category_string(uint32_gt, uint32_compare_binop, ">").
+
+binop_category_string(uint32_add, uint32_binary_infix_binop, "+").
+binop_category_string(uint32_sub, uint32_binary_infix_binop, "-").
+binop_category_string(uint32_mul, uint32_binary_infix_binop, "*").
+binop_category_string(uint32_div, uint32_binary_infix_binop, "/").
+binop_category_string(uint32_mod, uint32_binary_infix_binop, "%").
+binop_category_string(uint32_bitwise_and, uint32_binary_infix_binop, "&").
+binop_category_string(uint32_bitwise_or, uint32_binary_infix_binop, "|").
+binop_category_string(uint32_bitwise_xor, uint32_binary_infix_binop, "^").
+binop_category_string(uint32_unchecked_left_shift, uint32_binary_infix_binop, "<<").
+binop_category_string(uint32_unchecked_right_shift, uint32_binary_infix_binop, ">>").
+
  binop_category_string(float_plus, float_arith_binop, "+").
  binop_category_string(float_minus, float_arith_binop, "-").
  binop_category_string(float_times, float_arith_binop, "*").
diff --git a/compiler/call_gen.m b/compiler/call_gen.m
index f43bdcd78..11ad7f0ea 100644
--- a/compiler/call_gen.m
+++ b/compiler/call_gen.m
@@ -747,6 +747,12 @@ generate_assign_builtin(Var, AssignExpr, Code, !CLD) :-
  convert_simple_expr(leaf(Var)) = var(Var).
  convert_simple_expr(int_const(Int)) = const(llconst_int(Int)).
  convert_simple_expr(uint_const(UInt)) = const(llconst_uint(UInt)).
+convert_simple_expr(int8_const(Int8)) = const(llconst_int8(Int8)).
+convert_simple_expr(uint8_const(UInt8)) = const(llconst_uint8(UInt8)).
+convert_simple_expr(int16_const(Int16)) = const(llconst_int16(Int16)).
+convert_simple_expr(uint16_const(UInt16)) = const(llconst_uint16(UInt16)).
+convert_simple_expr(int32_const(Int32)) = const(llconst_int32(Int32)).
+convert_simple_expr(uint32_const(UInt32)) = const(llconst_uint32(UInt32)).
  convert_simple_expr(float_const(Float)) = const(llconst_float(Float)).
  convert_simple_expr(unary(UnOp, Expr)) =
      unop(UnOp, convert_simple_expr(Expr)).
diff --git a/compiler/ctgc.selector.m b/compiler/ctgc.selector.m
index 7f1465e9a..928cf65f9 100644
--- a/compiler/ctgc.selector.m
+++ b/compiler/ctgc.selector.m
@@ -117,6 +117,12 @@ selector_init(ConsId, Index) = [TermSel] :-
          ( ConsId = closure_cons(_, _)
          ; ConsId = int_const(_)
          ; ConsId = uint_const(_)
+        ; ConsId = int8_const(_)
+        ; ConsId = uint8_const(_)
+        ; ConsId = int16_const(_)
+        ; ConsId = uint16_const(_)
+        ; ConsId = int32_const(_)
+        ; ConsId = uint32_const(_)
          ; ConsId = float_const(_)
          ; ConsId = char_const(_)
          ; ConsId = string_const(_)
diff --git a/compiler/dead_proc_elim.m b/compiler/dead_proc_elim.m
index b36fdd8d2..76ba08506 100644
--- a/compiler/dead_proc_elim.m
+++ b/compiler/dead_proc_elim.m
@@ -819,6 +819,12 @@ dead_proc_examine_goal(Goal, CurrProc, !Queue, !Needed) :-
                  ; ConsId = tuple_cons(_)
                  ; ConsId = int_const(_)
                  ; ConsId = uint_const(_)
+                ; ConsId = int8_const(_)
+                ; ConsId = uint8_const(_)
+                ; ConsId = int16_const(_)
+                ; ConsId = uint16_const(_)
+                ; ConsId = int32_const(_)
+                ; ConsId = uint32_const(_)
                  ; ConsId = float_const(_)
                  ; ConsId = char_const(_)
                  ; ConsId = string_const(_)
diff --git a/compiler/dupproc.m b/compiler/dupproc.m
index 483e27a72..db059f175 100644
--- a/compiler/dupproc.m
+++ b/compiler/dupproc.m
@@ -439,6 +439,24 @@ standardize_rval_const(Const, StdConst, DupProcMap) :-
          Const = llconst_uint(_),
          StdConst = Const
      ;
+        Const = llconst_int8(_),
+        StdConst = Const
+    ;
+        Const = llconst_uint8(_),
+        StdConst = Const
+    ;
+        Const = llconst_int16(_),
+        StdConst = Const
+    ;
+        Const = llconst_uint16(_),
+        StdConst = Const
+    ;
+        Const = llconst_int32(_),
+        StdConst = Const
+    ;
+        Const = llconst_uint32(_),
+        StdConst = Const
+    ;
          Const = llconst_foreign(_, _),
          StdConst = Const
      ;
diff --git a/compiler/elds.m b/compiler/elds.m
index 4c84090bb..5248bd6d4 100644
--- a/compiler/elds.m
+++ b/compiler/elds.m
@@ -215,6 +215,12 @@
      --->    elds_char(char)
      ;       elds_int(int)
      ;       elds_uint(uint)
+    ;       elds_int8(int)    % XXX FIXED SIZE INT
+    ;       elds_uint8(int)
+    ;       elds_int16(int)
+    ;       elds_uint16(int)
+    ;       elds_int32(int)
+    ;       elds_uint32(int)
      ;       elds_float(float)

      ;       elds_binary(string)
diff --git a/compiler/elds_to_erlang.m b/compiler/elds_to_erlang.m
index d9abd1dd6..aea5e3552 100644
--- a/compiler/elds_to_erlang.m
+++ b/compiler/elds_to_erlang.m
@@ -782,6 +782,31 @@ output_term(ModuleInfo, VarSet, Indent, Term, !IO) :-
          io.write_uint(UInt, !IO),
          space(!IO)
      ;
+        % XXX FIXED SIZE INT
+        Term = elds_int8(Int8),
+        io.write_int(Int8, !IO),
+        space(!IO)
+    ;
+        Term = elds_uint8(UInt8),
+        io.write_int(UInt8, !IO),
+        space(!IO)
+    ;
+        Term = elds_int16(Int16),
+        io.write_int(Int16, !IO),
+        space(!IO)
+    ;
+        Term = elds_uint16(UInt16),
+        io.write_int(UInt16, !IO),
+        space(!IO)
+    ;
+        Term = elds_int32(Int32),
+        io.write_int(Int32, !IO),
+        space(!IO)
+    ;
+        Term = elds_uint32(UInt32),
+        io.write_int(UInt32, !IO),
+        space(!IO)
+    ;
          Term = elds_float(Float),
          output_float(Float, !IO),
          space(!IO)
diff --git a/compiler/erl_call_gen.m b/compiler/erl_call_gen.m
index 2efea9539..a542555eb 100644
--- a/compiler/erl_call_gen.m
+++ b/compiler/erl_call_gen.m
@@ -447,6 +447,24 @@ erl_gen_simple_expr(ModuleInfo, VarTypes, SimpleExpr) = Expr :-
          SimpleExpr = uint_const(UInt),
          Expr = elds_term(elds_uint(UInt))
      ;
+        SimpleExpr = int8_const(Int8),
+        Expr = elds_term(elds_int8(Int8))
+    ;
+        SimpleExpr = uint8_const(UInt8),
+        Expr = elds_term(elds_uint8(UInt8))
+    ;
+        SimpleExpr = int16_const(Int16),
+        Expr = elds_term(elds_int16(Int16))
+    ;
+        SimpleExpr = uint16_const(UInt16),
+        Expr = elds_term(elds_uint16(UInt16))
+    ;
+        SimpleExpr = int32_const(Int32),
+        Expr = elds_term(elds_int32(Int32))
+    ;
+        SimpleExpr = uint32_const(UInt32),
+        Expr = elds_term(elds_uint32(UInt32))
+    ;
          SimpleExpr = float_const(Float),
          Expr = elds_term(elds_float(Float))
      ;
@@ -495,6 +513,12 @@ std_unop_to_elds(StdUnOp, EldsUnOp) :-
      ;
          ( StdUnOp = bitwise_complement,      EldsUnOp = elds.bnot
          ; StdUnOp = uint_bitwise_complement, EldsUnOp = elds.bnot
+        ; StdUnOp = int8_bitwise_complement, EldsUnOp = elds.bnot
+        ; StdUnOp = uint8_bitwise_complement, EldsUnOp = elds.bnot
+        ; StdUnOp = int16_bitwise_complement, EldsUnOp = elds.bnot
+        ; StdUnOp = uint16_bitwise_complement, EldsUnOp = elds.bnot
+        ; StdUnOp = int32_bitwise_complement, EldsUnOp = elds.bnot
+        ; StdUnOp = uint32_bitwise_complement, EldsUnOp = elds.bnot
          ; StdUnOp = logical_not,             EldsUnOp = elds.logical_not
          )
      ).
@@ -568,6 +592,102 @@ std_binop_to_elds(StdBinOp, EldsBinOp) :-
          ; StdBinOp = uint_bitwise_xor,      EldsBinOp = elds.bxor
          ; StdBinOp = uint_unchecked_left_shift, EldsBinOp = elds.bsl
          ; StdBinOp = uint_unchecked_right_shift, EldsBinOp = elds.bsr
+        ; StdBinOp = int8_eq,               EldsBinOp = elds.(=:=)
+        ; StdBinOp = int8_ne,               EldsBinOp = elds.(=/=)
+        ; StdBinOp = int8_lt,               EldsBinOp = elds.(<)
+        ; StdBinOp = int8_gt,               EldsBinOp = elds.(>)
+        ; StdBinOp = int8_le,               EldsBinOp = elds.(=<)
+        ; StdBinOp = int8_ge,               EldsBinOp = elds.(>=)
+        ; StdBinOp = int8_add,              EldsBinOp = elds.add
+        ; StdBinOp = int8_sub,              EldsBinOp = elds.sub
+        ; StdBinOp = int8_mul,              EldsBinOp = elds.mul
+        ; StdBinOp = int8_div,              EldsBinOp = elds.int_div
+        ; StdBinOp = int8_mod,              EldsBinOp = elds.(rem)
+        ; StdBinOp = int8_bitwise_and,      EldsBinOp = elds.band
+        ; StdBinOp = int8_bitwise_or,       EldsBinOp = elds.bor
+        ; StdBinOp = int8_bitwise_xor,      EldsBinOp = elds.bxor
+        ; StdBinOp = int8_unchecked_left_shift, EldsBinOp = elds.bsl
+        ; StdBinOp = int8_unchecked_right_shift, EldsBinOp = elds.bsr
+        ; StdBinOp = uint8_eq,               EldsBinOp = elds.(=:=)
+        ; StdBinOp = uint8_ne,               EldsBinOp = elds.(=/=)
+        ; StdBinOp = uint8_lt,               EldsBinOp = elds.(<)
+        ; StdBinOp = uint8_gt,               EldsBinOp = elds.(>)
+        ; StdBinOp = uint8_le,               EldsBinOp = elds.(=<)
+        ; StdBinOp = uint8_ge,               EldsBinOp = elds.(>=)
+        ; StdBinOp = uint8_add,              EldsBinOp = elds.add
+        ; StdBinOp = uint8_sub,              EldsBinOp = elds.sub
+        ; StdBinOp = uint8_mul,              EldsBinOp = elds.mul
+        ; StdBinOp = uint8_div,              EldsBinOp = elds.int_div
+        ; StdBinOp = uint8_mod,              EldsBinOp = elds.(rem)
+        ; StdBinOp = uint8_bitwise_and,      EldsBinOp = elds.band
+        ; StdBinOp = uint8_bitwise_or,       EldsBinOp = elds.bor
+        ; StdBinOp = uint8_bitwise_xor,      EldsBinOp = elds.bxor
+        ; StdBinOp = uint8_unchecked_left_shift, EldsBinOp = elds.bsl
+        ; StdBinOp = uint8_unchecked_right_shift, EldsBinOp = elds.bsr
+        ; StdBinOp = int16_eq,               EldsBinOp = elds.(=:=)
+        ; StdBinOp = int16_ne,               EldsBinOp = elds.(=/=)
+        ; StdBinOp = int16_lt,               EldsBinOp = elds.(<)
+        ; StdBinOp = int16_gt,               EldsBinOp = elds.(>)
+        ; StdBinOp = int16_le,               EldsBinOp = elds.(=<)
+        ; StdBinOp = int16_ge,               EldsBinOp = elds.(>=)
+        ; StdBinOp = int16_add,              EldsBinOp = elds.add
+        ; StdBinOp = int16_sub,              EldsBinOp = elds.sub
+        ; StdBinOp = int16_mul,              EldsBinOp = elds.mul
+        ; StdBinOp = int16_div,              EldsBinOp = elds.int_div
+        ; StdBinOp = int16_mod,              EldsBinOp = elds.(rem)
+        ; StdBinOp = int16_bitwise_and,      EldsBinOp = elds.band
+        ; StdBinOp = int16_bitwise_or,       EldsBinOp = elds.bor
+        ; StdBinOp = int16_bitwise_xor,      EldsBinOp = elds.bxor
+        ; StdBinOp = int16_unchecked_left_shift, EldsBinOp = elds.bsl
+        ; StdBinOp = int16_unchecked_right_shift, EldsBinOp = elds.bsr
+        ; StdBinOp = uint16_eq,               EldsBinOp = elds.(=:=)
+        ; StdBinOp = uint16_ne,               EldsBinOp = elds.(=/=)
+        ; StdBinOp = uint16_lt,               EldsBinOp = elds.(<)
+        ; StdBinOp = uint16_gt,               EldsBinOp = elds.(>)
+        ; StdBinOp = uint16_le,               EldsBinOp = elds.(=<)
+        ; StdBinOp = uint16_ge,               EldsBinOp = elds.(>=)
+        ; StdBinOp = uint16_add,              EldsBinOp = elds.add
+        ; StdBinOp = uint16_sub,              EldsBinOp = elds.sub
+        ; StdBinOp = uint16_mul,              EldsBinOp = elds.mul
+        ; StdBinOp = uint16_div,              EldsBinOp = elds.int_div
+        ; StdBinOp = uint16_mod,              EldsBinOp = elds.(rem)
+        ; StdBinOp = uint16_bitwise_and,      EldsBinOp = elds.band
+        ; StdBinOp = uint16_bitwise_or,       EldsBinOp = elds.bor
+        ; StdBinOp = uint16_bitwise_xor,      EldsBinOp = elds.bxor
+        ; StdBinOp = uint16_unchecked_left_shift, EldsBinOp = elds.bsl
+        ; StdBinOp = uint16_unchecked_right_shift, EldsBinOp = elds.bsr
+        ; StdBinOp = int32_eq,               EldsBinOp = elds.(=:=)
+        ; StdBinOp = int32_ne,               EldsBinOp = elds.(=/=)
+        ; StdBinOp = int32_lt,               EldsBinOp = elds.(<)
+        ; StdBinOp = int32_gt,               EldsBinOp = elds.(>)
+        ; StdBinOp = int32_le,               EldsBinOp = elds.(=<)
+        ; StdBinOp = int32_ge,               EldsBinOp = elds.(>=)
+        ; StdBinOp = int32_add,              EldsBinOp = elds.add
+        ; StdBinOp = int32_sub,              EldsBinOp = elds.sub
+        ; StdBinOp = int32_mul,              EldsBinOp = elds.mul
+        ; StdBinOp = int32_div,              EldsBinOp = elds.int_div
+        ; StdBinOp = int32_mod,              EldsBinOp = elds.(rem)
+        ; StdBinOp = int32_bitwise_and,      EldsBinOp = elds.band
+        ; StdBinOp = int32_bitwise_or,       EldsBinOp = elds.bor
+        ; StdBinOp = int32_bitwise_xor,      EldsBinOp = elds.bxor
+        ; StdBinOp = int32_unchecked_left_shift, EldsBinOp = elds.bsl
+        ; StdBinOp = int32_unchecked_right_shift, EldsBinOp = elds.bsr
+        ; StdBinOp = uint32_eq,               EldsBinOp = elds.(=:=)
+        ; StdBinOp = uint32_ne,               EldsBinOp = elds.(=/=)
+        ; StdBinOp = uint32_lt,               EldsBinOp = elds.(<)
+        ; StdBinOp = uint32_gt,               EldsBinOp = elds.(>)
+        ; StdBinOp = uint32_le,               EldsBinOp = elds.(=<)
+        ; StdBinOp = uint32_ge,               EldsBinOp = elds.(>=)
+        ; StdBinOp = uint32_add,              EldsBinOp = elds.add
+        ; StdBinOp = uint32_sub,              EldsBinOp = elds.sub
+        ; StdBinOp = uint32_mul,              EldsBinOp = elds.mul
+        ; StdBinOp = uint32_div,              EldsBinOp = elds.int_div
+        ; StdBinOp = uint32_mod,              EldsBinOp = elds.(rem)
+        ; StdBinOp = uint32_bitwise_and,      EldsBinOp = elds.band
+        ; StdBinOp = uint32_bitwise_or,       EldsBinOp = elds.bor
+        ; StdBinOp = uint32_bitwise_xor,      EldsBinOp = elds.bxor
+        ; StdBinOp = uint32_unchecked_left_shift, EldsBinOp = elds.bsl
+        ; StdBinOp = uint32_unchecked_right_shift, EldsBinOp = elds.bsr
          )
      ).

diff --git a/compiler/erl_code_util.m b/compiler/erl_code_util.m
index d26b5027c..fe896cfb8 100644
--- a/compiler/erl_code_util.m
+++ b/compiler/erl_code_util.m
@@ -514,6 +514,12 @@ non_variable_term(Term) :-
          ( Term = elds_char(_)
          ; Term = elds_int(_)
          ; Term = elds_uint(_)
+        ; Term = elds_int8(_)
+        ; Term = elds_uint8(_)
+        ; Term = elds_int16(_)
+        ; Term = elds_uint16(_)
+        ; Term = elds_int32(_)
+        ; Term = elds_uint32(_)
          ; Term = elds_float(_)
          ; Term = elds_binary(_)
          ; Term = elds_list_of_ints(_)
@@ -662,6 +668,12 @@ erl_rename_vars_in_term(Subn, Term0, Term) :-
      (
          ( Term0 = elds_int(_)
          ; Term0 = elds_uint(_)
+        ; Term0 = elds_int8(_)
+        ; Term0 = elds_uint8(_)
+        ; Term0 = elds_int16(_)
+        ; Term0 = elds_uint16(_)
+        ; Term0 = elds_int32(_)
+        ; Term0 = elds_uint32(_)
          ; Term0 = elds_float(_)
          ; Term0 = elds_binary(_)
          ; Term0 = elds_list_of_ints(_)
@@ -827,6 +839,12 @@ erl_vars_in_term(Term, !Set) :-
      (
          ( Term = elds_int(_)
          ; Term = elds_uint(_)
+        ; Term = elds_int8(_)
+        ; Term = elds_uint8(_)
+        ; Term = elds_int16(_)
+        ; Term = elds_uint16(_)
+        ; Term = elds_int32(_)
+        ; Term = elds_uint32(_)
          ; Term = elds_float(_)
          ; Term = elds_binary(_)
          ; Term = elds_list_of_ints(_)
@@ -966,6 +984,12 @@ erl_term_size(Term) = Size :-
      (
          ( Term = elds_int(_)
          ; Term = elds_uint(_)
+        ; Term = elds_int8(_)
+        ; Term = elds_uint8(_)
+        ; Term = elds_int16(_)
+        ; Term = elds_uint16(_)
+        ; Term = elds_int32(_)
+        ; Term = elds_uint32(_)
          ; Term = elds_float(_)
          ; Term = elds_binary(_)
          ; Term = elds_list_of_ints(_)
diff --git a/compiler/erl_rtti.m b/compiler/erl_rtti.m
index 3dac2c80e..7c5c788e8 100644
--- a/compiler/erl_rtti.m
+++ b/compiler/erl_rtti.m
@@ -610,6 +610,18 @@ erlang_type_ctor_rep(erlang_builtin(builtin_ctor_int)) =
      elds_term(make_enum_alternative("etcr_int")).
  erlang_type_ctor_rep(erlang_builtin(builtin_ctor_uint)) =
      elds_term(make_enum_alternative("etcr_uint")).
+erlang_type_ctor_rep(erlang_builtin(builtin_ctor_int8)) =
+    elds_term(make_enum_alternative("etcr_int8")).
+erlang_type_ctor_rep(erlang_builtin(builtin_ctor_uint8)) =
+    elds_term(make_enum_alternative("etcr_uint8")).
+erlang_type_ctor_rep(erlang_builtin(builtin_ctor_int16)) =
+    elds_term(make_enum_alternative("etcr_int16")).
+erlang_type_ctor_rep(erlang_builtin(builtin_ctor_uint16)) =
+    elds_term(make_enum_alternative("etcr_uint16")).
+erlang_type_ctor_rep(erlang_builtin(builtin_ctor_int32)) =
+    elds_term(make_enum_alternative("etcr_int32")).
+erlang_type_ctor_rep(erlang_builtin(builtin_ctor_uint32)) =
+    elds_term(make_enum_alternative("etcr_uint32")).
  erlang_type_ctor_rep(erlang_builtin(builtin_ctor_float)) =
      elds_term(make_enum_alternative("etcr_float")).
  erlang_type_ctor_rep(erlang_builtin(builtin_ctor_char)) =
diff --git a/compiler/erl_unify_gen.m b/compiler/erl_unify_gen.m
index ae0cdd0c5..56fc7a0e4 100644
--- a/compiler/erl_unify_gen.m
+++ b/compiler/erl_unify_gen.m
@@ -66,6 +66,12 @@
      ;       tuple_cons(ground)
      ;       int_const(ground)
      ;       uint_const(ground)
+    ;       int8_const(ground)
+    ;       uint8_const(ground)
+    ;       int16_const(ground)
+    ;       uint16_const(ground)
+    ;       int32_const(ground)
+    ;       uint32_const(ground)
      ;       float_const(ground)
      ;       char_const(ground)
      ;       string_const(ground).
@@ -282,6 +288,24 @@ cons_id_to_term(ConsId, Args, DummyVarReplacement, Term, !Info) :-
          ConsId = uint_const(UInt),
          Term = elds_uint(UInt)
      ;
+        ConsId = int8_const(Int8),
+        Term = elds_int8(Int8)
+    ;
+        ConsId = uint8_const(UInt8),
+        Term = elds_uint8(UInt8)
+    ;
+        ConsId = int16_const(Int16),
+        Term = elds_int16(Int16)
+    ;
+        ConsId = uint16_const(UInt16),
+        Term = elds_uint16(UInt16)
+    ;
+        ConsId = int32_const(Int32),
+        Term = elds_int32(Int32)
+    ;
+        ConsId = uint32_const(UInt32),
+        Term = elds_uint32(UInt32)
+    ;
          ConsId = float_const(Float),
          Term = elds_float(Float)
      ;
@@ -298,6 +322,12 @@ cons_id_to_expr(ConsId, Args, DummyVarReplacement, Expr, !Info) :-
          ; ConsId = tuple_cons(_)
          ; ConsId = int_const(_)
          ; ConsId = uint_const(_)
+        ; ConsId = int8_const(_)
+        ; ConsId = uint8_const(_)
+        ; ConsId = int16_const(_)
+        ; ConsId = uint16_const(_)
+        ; ConsId = int32_const(_)
+        ; ConsId = uint32_const(_)
          ; ConsId = float_const(_)
          ; ConsId = char_const(_)
          ; ConsId = string_const(_)
diff --git a/compiler/export.m b/compiler/export.m
index 57e503004..ec800875e 100644
--- a/compiler/export.m
+++ b/compiler/export.m
@@ -655,6 +655,12 @@ convert_type_to_mercury(Rval, Type, TargetArgLoc, ConvertedRval) :-
          ;
              ( BuiltinType = builtin_type_int
              ; BuiltinType = builtin_type_uint
+            ; BuiltinType = builtin_type_int8
+            ; BuiltinType = builtin_type_uint8
+            ; BuiltinType = builtin_type_int16
+            ; BuiltinType = builtin_type_uint16
+            ; BuiltinType = builtin_type_int32
+            ; BuiltinType = builtin_type_uint32
              ),
              ConvertedRval = Rval
          )
@@ -687,6 +693,12 @@ convert_type_from_mercury(SourceArgLoc, Rval, Type, ConvertedRval) :-
          ;
              ( BuiltinType = builtin_type_int
              ; BuiltinType = builtin_type_uint
+            ; BuiltinType = builtin_type_int8
+            ; BuiltinType = builtin_type_uint8
+            ; BuiltinType = builtin_type_int16
+            ; BuiltinType = builtin_type_uint16
+            ; BuiltinType = builtin_type_int32
+            ; BuiltinType = builtin_type_uint32
              ; BuiltinType = builtin_type_char
              ),
              ConvertedRval = Rval
@@ -960,6 +972,12 @@ foreign_const_name_and_tag(TypeCtor, Mapping, TagValues, Ctor,
      ;
          ( TagVal = string_tag(_)
          ; TagVal = uint_tag(_)
+        ; TagVal = int8_tag(_)
+        ; TagVal = uint8_tag(_)
+        ; TagVal = int16_tag(_)
+        ; TagVal = uint16_tag(_)
+        ; TagVal = int32_tag(_)
+        ; TagVal = uint32_tag(_)
          ; TagVal = float_tag(_)
          ; TagVal = closure_tag(_, _, _)
          ; TagVal = type_ctor_info_tag(_, _, _)
diff --git a/compiler/exprn_aux.m b/compiler/exprn_aux.m
index f0c860d9a..aeb766733 100644
--- a/compiler/exprn_aux.m
+++ b/compiler/exprn_aux.m
@@ -111,6 +111,12 @@ const_is_constant(Const, ExprnOpts, IsConst) :-
          ; Const = llconst_false
          ; Const = llconst_int(_)
          ; Const = llconst_uint(_)
+        ; Const = llconst_int8(_)
+        ; Const = llconst_uint8(_)
+        ; Const = llconst_int16(_)
+        ; Const = llconst_uint16(_)
+        ; Const = llconst_int32(_)
+        ; Const = llconst_uint32(_)
          ; Const = llconst_foreign(_, _)
          ; Const = llconst_string(_)
          ; Const = llconst_multi_string(_)
diff --git a/compiler/foreign.m b/compiler/foreign.m
index 8cb136fcb..177d9c4a3 100644
--- a/compiler/foreign.m
+++ b/compiler/foreign.m
@@ -300,6 +300,24 @@ exported_builtin_type_to_c_string(BuiltinType) = CTypeName :-
          BuiltinType = builtin_type_uint,
          CTypeName = "MR_Unsigned"
      ;
+        BuiltinType = builtin_type_int8,
+        CTypeName = "int8_t"
+    ;
+        BuiltinType = builtin_type_uint8,
+        CTypeName = "uint8_t"
+    ;
+        BuiltinType = builtin_type_int16,
+        CTypeName = "int16_t"
+    ;
+        BuiltinType = builtin_type_uint16,
+        CTypeName = "uint16_t"
+    ;
+        BuiltinType = builtin_type_int32,
+        CTypeName = "int32_t"
+    ;
+        BuiltinType = builtin_type_uint32,
+        CTypeName = "uint32_t"
+    ;
          BuiltinType = builtin_type_float,
          CTypeName = "MR_Float"
      ;
@@ -318,6 +336,24 @@ exported_builtin_type_to_csharp_string(BuiltinType) = CsharpTypeName :-
          BuiltinType = builtin_type_uint,
          CsharpTypeName = "uint"
      ;
+        BuiltinType = builtin_type_int8,
+        CsharpTypeName = "sbyte"
+    ;
+        BuiltinType = builtin_type_uint8,
+        CsharpTypeName = "byte"
+    ;
+        BuiltinType = builtin_type_int16,
+        CsharpTypeName = "short"
+    ;
+        BuiltinType = builtin_type_uint16,
+        CsharpTypeName = "ushort"
+    ;
+        BuiltinType = builtin_type_int32,
+        CsharpTypeName = "int"
+    ;
+        BuiltinType = builtin_type_uint32,
+        CsharpTypeName = "uint"
+    ;
          BuiltinType = builtin_type_float,
          CsharpTypeName = "double"
      ;
@@ -336,6 +372,24 @@ exported_builtin_type_to_java_string(BuiltinType) = JavaTypeName :-
          BuiltinType = builtin_type_uint,
          JavaTypeName = "int"
      ;
+        BuiltinType = builtin_type_int8,
+        JavaTypeName = "byte"
+    ;
+        BuiltinType = builtin_type_uint8,
+        JavaTypeName = "byte"
+    ;
+        BuiltinType = builtin_type_int16,
+        JavaTypeName = "short"
+    ;
+        BuiltinType = builtin_type_uint16,
+        JavaTypeName = "short"
+    ;
+        BuiltinType = builtin_type_int32,
+        JavaTypeName = "int"
+    ;
+        BuiltinType = builtin_type_uint32,
+        JavaTypeName = "int"
+    ;
          BuiltinType = builtin_type_float,
          JavaTypeName = "double"
      ;
diff --git a/compiler/global_data.m b/compiler/global_data.m
index 56149e627..014e3d414 100644
--- a/compiler/global_data.m
+++ b/compiler/global_data.m
@@ -1346,6 +1346,12 @@ remap_rval_const(Remap, Const0, Const) :-
          ; Const0 = llconst_false
          ; Const0 = llconst_int(_)
          ; Const0 = llconst_uint(_)
+        ; Const0 = llconst_int8(_)
+        ; Const0 = llconst_uint8(_)
+        ; Const0 = llconst_int16(_)
+        ; Const0 = llconst_uint16(_)
+        ; Const0 = llconst_int32(_)
+        ; Const0 = llconst_uint32(_)
          ; Const0 = llconst_foreign(_, _)
          ; Const0 = llconst_float(_)
          ; Const0 = llconst_string(_)
diff --git a/compiler/goal_util.m b/compiler/goal_util.m
index c32bba45a..1aa3e98ca 100644
--- a/compiler/goal_util.m
+++ b/compiler/goal_util.m
@@ -1194,6 +1194,12 @@ cons_id_proc_refs_acc(ConsId, !ReferredToProcs) :-
          ; ConsId = tuple_cons(_)
          ; ConsId = int_const(_)
          ; ConsId = uint_const(_)
+        ; ConsId = int8_const(_)
+        ; ConsId = uint8_const(_)
+        ; ConsId = int16_const(_)
+        ; ConsId = uint16_const(_)
+        ; ConsId = int32_const(_)
+        ; ConsId = uint32_const(_)
          ; ConsId = float_const(_)
          ; ConsId = char_const(_)
          ; ConsId = string_const(_)
diff --git a/compiler/higher_order.m b/compiler/higher_order.m
index 9a1e9453d..e67a570ba 100644
--- a/compiler/higher_order.m
+++ b/compiler/higher_order.m
@@ -915,6 +915,12 @@ is_interesting_cons_id(Params, ConsId) = IsInteresting :-
          ( ConsId = cons(_, _, _)
          ; ConsId = tuple_cons(_)
          ; ConsId = uint_const(_)
+        ; ConsId = int8_const(_)
+        ; ConsId = uint8_const(_)
+        ; ConsId = int16_const(_)
+        ; ConsId = uint16_const(_)
+        ; ConsId = int32_const(_)
+        ; ConsId = uint32_const(_)
          ; ConsId = float_const(_)
          ; ConsId = char_const(_)
          ; ConsId = string_const(_)
diff --git a/compiler/hlds_code_util.m b/compiler/hlds_code_util.m
index ae2b94f57..476f0b2dd 100644
--- a/compiler/hlds_code_util.m
+++ b/compiler/hlds_code_util.m
@@ -93,6 +93,24 @@ cons_id_to_tag(ModuleInfo, ConsId) = Tag:-
          ConsId = uint_const(UInt),
          Tag = uint_tag(UInt)
      ;
+        ConsId = int8_const(Int8),
+        Tag = int8_tag(Int8)
+    ;
+        ConsId = uint8_const(UInt8),
+        Tag = uint8_tag(UInt8)
+    ;
+        ConsId = int16_const(Int16),
+        Tag = int16_tag(Int16)
+    ;
+        ConsId = uint16_const(UInt16),
+        Tag = uint16_tag(UInt16)
+    ;
+        ConsId = int32_const(Int32),
+        Tag = int32_tag(Int32)
+    ;
+        ConsId = uint32_const(UInt32),
+        Tag = uint32_tag(UInt32)
+    ;
          ConsId = float_const(Float),
          Tag = float_tag(Float)
      ;
diff --git a/compiler/hlds_data.m b/compiler/hlds_data.m
index d246f5bb2..f448ae8fd 100644
--- a/compiler/hlds_data.m
+++ b/compiler/hlds_data.m
@@ -602,6 +602,14 @@ cons_table_optimize(!ConsTable) :-
              % the specified unsigned integer value. This is used for uint
              % constants.

+            % XXX FIXED SIZE INT
+    ;       int8_tag(int)
+    ;       uint8_tag(int)
+    ;       int16_tag(int)
+    ;       uint16_tag(int)
+    ;       int32_tag(int)
+    ;       uint32_tag(int)
+
      ;       foreign_tag(foreign_language, string)
              % This means the constant is represented by the string which is
              % embedded directly in the target language. This is used for
@@ -785,6 +793,12 @@ get_primary_tag(Tag) = MaybePrimaryTag :-
          % But it's safe to be conservative...
          ( Tag = int_tag(_)
          ; Tag = uint_tag(_)
+        ; Tag = int8_tag(_)
+        ; Tag = uint8_tag(_)
+        ; Tag = int16_tag(_)
+        ; Tag = uint16_tag(_)
+        ; Tag = int32_tag(_)
+        ; Tag = uint32_tag(_)
          ; Tag = float_tag(_)
          ; Tag = string_tag(_)
          ; Tag = foreign_tag(_, _)
@@ -822,6 +836,12 @@ get_secondary_tag(Tag) = MaybeSecondaryTag :-
      (
          ( Tag = int_tag(_)
          ; Tag = uint_tag(_)
+        ; Tag = int8_tag(_)
+        ; Tag = uint8_tag(_)
+        ; Tag = int16_tag(_)
+        ; Tag = uint16_tag(_)
+        ; Tag = int32_tag(_)
+        ; Tag = uint32_tag(_)
          ; Tag = float_tag(_)
          ; Tag = string_tag(_)
          ; Tag = foreign_tag(_, _)
diff --git a/compiler/hlds_dependency_graph.m b/compiler/hlds_dependency_graph.m
index fefbcca55..5f554b180 100644
--- a/compiler/hlds_dependency_graph.m
+++ b/compiler/hlds_dependency_graph.m
@@ -461,6 +461,12 @@ add_dependency_arcs_in_cons(DepGraph, WhatEdges, Caller, ConsId, !DepArcs) :-
          ; ConsId = tuple_cons(_)
          ; ConsId = int_const(_)
          ; ConsId = uint_const(_)
+        ; ConsId = int8_const(_)
+        ; ConsId = uint8_const(_)
+        ; ConsId = int16_const(_)
+        ; ConsId = uint16_const(_)
+        ; ConsId = int32_const(_)
+        ; ConsId = uint32_const(_)
          ; ConsId = float_const(_)
          ; ConsId = char_const(_)
          ; ConsId = string_const(_)
diff --git a/compiler/hlds_out_pred.m b/compiler/hlds_out_pred.m
index 251507551..c9b98fdf8 100644
--- a/compiler/hlds_out_pred.m
+++ b/compiler/hlds_out_pred.m
@@ -1224,6 +1224,24 @@ table_trie_step_desc(TVarSet, Step) = Str :-
          Step = table_trie_step_uint,
          Str = "uint"
      ;
+        Step = table_trie_step_int8,
+        Str = "int8"
+    ;
+        Step = table_trie_step_uint8,
+        Str = "uint8"
+    ;
+        Step = table_trie_step_int16,
+        Str = "int16"
+    ;
+        Step = table_trie_step_uint16,
+        Str = "uint16"
+    ;
+        Step = table_trie_step_int32,
+        Str = "int32"
+    ;
+        Step = table_trie_step_uint32,
+        Str = "uint32"
+    ;
          Step = table_trie_step_char,
          Str = "char"
      ;
diff --git a/compiler/hlds_out_util.m b/compiler/hlds_out_util.m
index 69acf9d8a..0f303fd64 100644
--- a/compiler/hlds_out_util.m
+++ b/compiler/hlds_out_util.m
@@ -679,6 +679,36 @@ functor_cons_id_to_string(ModuleInfo, VarSet, VarNamePrint, ConsId, ArgVars)
              term.integer(base_10, integer.from_uint(UInt), unsigned, size_word),
              ArgVars)
      ;
+        ConsId = int8_const(Int8),
+        Str = functor_to_string(VarSet, VarNamePrint,
+            term.integer(base_10, integer(Int8), signed, size_8_bit),
+            ArgVars)
+    ;
+        ConsId = uint8_const(UInt8),
+        Str = functor_to_string(VarSet, VarNamePrint,
+            term.integer(base_10, integer(UInt8), unsigned, size_8_bit),
+            ArgVars)
+    ;
+        ConsId = int16_const(Int16),
+        Str = functor_to_string(VarSet, VarNamePrint,
+            term.integer(base_10, integer(Int16), signed, size_16_bit),
+            ArgVars)
+    ;
+        ConsId = uint16_const(UInt16),
+        Str = functor_to_string(VarSet, VarNamePrint,
+            term.integer(base_10, integer(UInt16), unsigned, size_16_bit),
+            ArgVars)
+    ;
+        ConsId = int32_const(Int32),
+        Str = functor_to_string(VarSet, VarNamePrint,
+            term.integer(base_10, integer(Int32), signed, size_32_bit),
+            ArgVars)
+    ;
+        ConsId = uint32_const(UInt32),
+        Str = functor_to_string(VarSet, VarNamePrint,
+            term.integer(base_10, integer(UInt32), unsigned, size_32_bit),
+            ArgVars)
+    ;
          ConsId = float_const(Float),
          Str = functor_to_string(VarSet, VarNamePrint,
              term.float(Float), ArgVars)
@@ -836,6 +866,24 @@ cons_id_and_vars_or_arity_to_string(VarSet, Qual, ConsId, MaybeArgVars)
          ConsId = uint_const(UInt),
          String = uint_to_string(UInt) ++ "u"
      ;
+        ConsId = int8_const(Int8),
+        string.int_to_string(Int8, String)
+    ;
+        ConsId = uint8_const(UInt8),
+        string.int_to_string(UInt8, String)
+    ;
+        ConsId = int16_const(Int16),
+        string.int_to_string(Int16, String)
+    ;
+        ConsId = uint16_const(UInt16),
+        string.int_to_string(UInt16, String)
+    ;
+        ConsId = int32_const(Int32),
+        string.int_to_string(Int32, String)
+    ;
+        ConsId = uint32_const(UInt32),
+        string.int_to_string(UInt32, String)
+    ;
          ConsId = float_const(Float),
          String = float_to_string(Float)
      ;
diff --git a/compiler/hlds_pred.m b/compiler/hlds_pred.m
index 4862eb86b..c1bb1223f 100644
--- a/compiler/hlds_pred.m
+++ b/compiler/hlds_pred.m
@@ -2023,6 +2023,12 @@ attribute_list_to_attributes(Attributes, AttributeSet) :-
      --->    table_trie_step_dummy
      ;       table_trie_step_int
      ;       table_trie_step_uint
+    ;       table_trie_step_int8
+    ;       table_trie_step_uint8
+    ;       table_trie_step_int16
+    ;       table_trie_step_uint16
+    ;       table_trie_step_int32
+    ;       table_trie_step_uint32
      ;       table_trie_step_char
      ;       table_trie_step_string
      ;       table_trie_step_float
@@ -2874,6 +2880,12 @@ table_step_stats_kind(Step) = KindStr :-
      (
          ( Step = table_trie_step_int
          ; Step = table_trie_step_uint
+        ; Step = table_trie_step_int8
+        ; Step = table_trie_step_uint8
+        ; Step = table_trie_step_int16
+        ; Step = table_trie_step_uint16
+        ; Step = table_trie_step_int32
+        ; Step = table_trie_step_uint32
          ; Step = table_trie_step_char
          ; Step = table_trie_step_string
          ; Step = table_trie_step_float
diff --git a/compiler/implementation_defined_literals.m b/compiler/implementation_defined_literals.m
index e13e7a255..3d1ffd290 100644
--- a/compiler/implementation_defined_literals.m
+++ b/compiler/implementation_defined_literals.m
@@ -104,6 +104,12 @@ subst_literals_in_goal(Info, Goal0, Goal) :-
                  ; ConsId = closure_cons(_, _)
                  ; ConsId = int_const(_)
                  ; ConsId = uint_const(_)
+                ; ConsId = int8_const(_)
+                ; ConsId = uint8_const(_)
+                ; ConsId = int16_const(_)
+                ; ConsId = uint16_const(_)
+                ; ConsId = int32_const(_)
+                ; ConsId = uint32_const(_)
                  ; ConsId = float_const(_)
                  ; ConsId = char_const(_)
                  ; ConsId = string_const(_)
diff --git a/compiler/inst_check.m b/compiler/inst_check.m
index 5dcf448ed..e3f6b990f 100644
--- a/compiler/inst_check.m
+++ b/compiler/inst_check.m
@@ -258,6 +258,60 @@ check_inst_defn_has_matching_type(TypeTable, FunctorsToTypesMap, InstId,
                      ForTypeCtor = uint_type_ctor,
                      MaybeForTypeKind = yes(ftk_uint)
                  else if
+                    ( ForTypeCtorName = unqualified("int8")
+                    ; ForTypeCtorName = qualified(unqualified(""), "int8")
+                    ; ForTypeCtorName = qualified(unqualified("int8"), "int8")
+                    ),
+                    ForTypeCtorArity = 0
+                then
+                    ForTypeCtor = int8_type_ctor,
+                    MaybeForTypeKind = yes(ftk_int8)
+                else if
+                    ( ForTypeCtorName = unqualified("uint8")
+                    ; ForTypeCtorName = qualified(unqualified(""), "uint8")
+                    ; ForTypeCtorName = qualified(unqualified("uint8"), "uint8")
+                    ),
+                    ForTypeCtorArity = 0
+                then
+                    ForTypeCtor = uint8_type_ctor,
+                    MaybeForTypeKind = yes(ftk_uint8)
+                else if
+                    ( ForTypeCtorName = unqualified("int16")
+                    ; ForTypeCtorName = qualified(unqualified(""), "int16")
+                    ; ForTypeCtorName = qualified(unqualified("int16"), "int16")
+                    ),
+                    ForTypeCtorArity = 0
+                then
+                    ForTypeCtor = int16_type_ctor,
+                    MaybeForTypeKind = yes(ftk_int16)
+                else if
+                    ( ForTypeCtorName = unqualified("uint16")
+                    ; ForTypeCtorName = qualified(unqualified(""), "uint16")
+                    ; ForTypeCtorName = qualified(unqualified("uint16"), "uint16")
+                    ),
+                    ForTypeCtorArity = 0
+                then
+                    ForTypeCtor = uint16_type_ctor,
+                    MaybeForTypeKind = yes(ftk_uint16)
+                else if
+                    ( ForTypeCtorName = unqualified("int32")
+                    ; ForTypeCtorName = qualified(unqualified(""), "int32")
+                    ; ForTypeCtorName = qualified(unqualified("int32"), "int32")
+                    ),
+                    ForTypeCtorArity = 0
+                then
+                    ForTypeCtor = int32_type_ctor,
+                    MaybeForTypeKind = yes(ftk_int32)
+                else if
+                    ( ForTypeCtorName = unqualified("uint32")
+                    ; ForTypeCtorName = qualified(unqualified(""), "uint32")
+                    ; ForTypeCtorName = qualified(unqualified("uint32"), "uint32")
+                    ),
+                    ForTypeCtorArity = 0
+                then
+                    ForTypeCtor = uint32_type_ctor,
+                    MaybeForTypeKind = yes(ftk_uint32)
+                else if
                      ( ForTypeCtorName = unqualified("float")
                      ; ForTypeCtorName = qualified(unqualified(""), "float")
                      ; ForTypeCtorName = qualified(unqualified("float"),
@@ -389,6 +443,24 @@ type_defn_or_builtin_to_type_ctor(TypeDefnOrBuiltin, TypeCtor) :-
              BuiltinType = builtin_type_uint,
              TypeCtor = type_ctor(unqualified("uint"), 0)
          ;
+            BuiltinType = builtin_type_int8,
+            TypeCtor = type_ctor(unqualified("int8"), 0)
+        ;
+            BuiltinType = builtin_type_uint8,
+            TypeCtor = type_ctor(unqualified("uint8"), 0)
+        ;
+            BuiltinType = builtin_type_int16,
+            TypeCtor = type_ctor(unqualified("int16"), 0)
+        ;
+            BuiltinType = builtin_type_uint16,
+            TypeCtor = type_ctor(unqualified("uint16"), 0)
+        ;
+            BuiltinType = builtin_type_int32,
+            TypeCtor = type_ctor(unqualified("int32"), 0)
+        ;
+            BuiltinType = builtin_type_uint32,
+            TypeCtor = type_ctor(unqualified("uint32"), 0)
+        ;
              BuiltinType = builtin_type_float,
              TypeCtor = type_ctor(unqualified("float"), 0)
          ;
@@ -409,6 +481,12 @@ type_defn_or_builtin_to_type_ctor(TypeDefnOrBuiltin, TypeCtor) :-
      --->    ftk_user(type_ctor, hlds_type_defn)
      ;       ftk_int
      ;       ftk_uint
+    ;       ftk_int8
+    ;       ftk_uint8
+    ;       ftk_int16
+    ;       ftk_uint16
+    ;       ftk_int32
+    ;       ftk_uint32
      ;       ftk_float
      ;       ftk_char
      ;       ftk_string.
@@ -487,6 +565,12 @@ check_for_type_bound_insts(ForTypeKind, [BoundInst | BoundInsts],
          ;
              ( ForTypeKind = ftk_int
              ; ForTypeKind = ftk_uint
+            ; ForTypeKind = ftk_int8
+            ; ForTypeKind = ftk_uint8
+            ; ForTypeKind = ftk_int16
+            ; ForTypeKind = ftk_uint16
+            ; ForTypeKind = ftk_int32
+            ; ForTypeKind = ftk_uint32
              ; ForTypeKind = ftk_float
              ; ForTypeKind = ftk_string
              ),
@@ -499,6 +583,12 @@ check_for_type_bound_insts(ForTypeKind, [BoundInst | BoundInsts],
          ;
              ( ForTypeKind = ftk_user(_, _)
              ; ForTypeKind = ftk_uint
+            ; ForTypeKind = ftk_int8
+            ; ForTypeKind = ftk_uint8
+            ; ForTypeKind = ftk_int16
+            ; ForTypeKind = ftk_uint16
+            ; ForTypeKind = ftk_int32
+            ; ForTypeKind = ftk_uint32
              ; ForTypeKind = ftk_float
              ; ForTypeKind = ftk_char
              ; ForTypeKind = ftk_string
@@ -512,6 +602,126 @@ check_for_type_bound_insts(ForTypeKind, [BoundInst | BoundInsts],
          ;
              ( ForTypeKind = ftk_user(_, _)
              ; ForTypeKind = ftk_int
+            ; ForTypeKind = ftk_int8
+            ; ForTypeKind = ftk_uint8
+            ; ForTypeKind = ftk_int16
+            ; ForTypeKind = ftk_uint16
+            ; ForTypeKind = ftk_int32
+            ; ForTypeKind = ftk_uint32
+            ; ForTypeKind = ftk_float
+            ; ForTypeKind = ftk_char
+            ; ForTypeKind = ftk_string
+            ),
+            !:RevMismatchConsIdStrs = [ConsIdStr | !.RevMismatchConsIdStrs]
+        )
+    ;
+        ConsId = int8_const(_),
+        (
+            ForTypeKind = ftk_int8
+        ;
+            ( ForTypeKind = ftk_user(_, _)
+            ; ForTypeKind = ftk_int
+            ; ForTypeKind = ftk_uint
+            ; ForTypeKind = ftk_uint8
+            ; ForTypeKind = ftk_int16
+            ; ForTypeKind = ftk_uint16
+            ; ForTypeKind = ftk_int32
+            ; ForTypeKind = ftk_uint32
+            ; ForTypeKind = ftk_float
+            ; ForTypeKind = ftk_char
+            ; ForTypeKind = ftk_string
+            ),
+            !:RevMismatchConsIdStrs = [ConsIdStr | !.RevMismatchConsIdStrs]
+        )
+    ;
+        ConsId = uint8_const(_),
+        (
+            ForTypeKind = ftk_uint8
+        ;
+            ( ForTypeKind = ftk_user(_, _)
+            ; ForTypeKind = ftk_int
+            ; ForTypeKind = ftk_uint
+            ; ForTypeKind = ftk_int8
+            ; ForTypeKind = ftk_int16
+            ; ForTypeKind = ftk_uint16
+            ; ForTypeKind = ftk_int32
+            ; ForTypeKind = ftk_uint32
+            ; ForTypeKind = ftk_float
+            ; ForTypeKind = ftk_char
+            ; ForTypeKind = ftk_string
+            ),
+            !:RevMismatchConsIdStrs = [ConsIdStr | !.RevMismatchConsIdStrs]
+        )
+    ;
+        ConsId = int16_const(_),
+        (
+            ForTypeKind = ftk_int16
+        ;
+            ( ForTypeKind = ftk_user(_, _)
+            ; ForTypeKind = ftk_int
+            ; ForTypeKind = ftk_uint
+            ; ForTypeKind = ftk_int8
+            ; ForTypeKind = ftk_uint8
+            ; ForTypeKind = ftk_uint16
+            ; ForTypeKind = ftk_int32
+            ; ForTypeKind = ftk_uint32
+            ; ForTypeKind = ftk_float
+            ; ForTypeKind = ftk_char
+            ; ForTypeKind = ftk_string
+            ),
+            !:RevMismatchConsIdStrs = [ConsIdStr | !.RevMismatchConsIdStrs]
+        )
+    ;
+        ConsId = uint16_const(_),
+        (
+            ForTypeKind = ftk_uint16
+        ;
+            ( ForTypeKind = ftk_user(_, _)
+            ; ForTypeKind = ftk_int
+            ; ForTypeKind = ftk_uint
+            ; ForTypeKind = ftk_int8
+            ; ForTypeKind = ftk_uint8
+            ; ForTypeKind = ftk_int16
+            ; ForTypeKind = ftk_int32
+            ; ForTypeKind = ftk_uint32
+            ; ForTypeKind = ftk_float
+            ; ForTypeKind = ftk_char
+            ; ForTypeKind = ftk_string
+            ),
+            !:RevMismatchConsIdStrs = [ConsIdStr | !.RevMismatchConsIdStrs]
+        )
+    ;
+        ConsId = int32_const(_),
+        (
+            ForTypeKind = ftk_int32
+        ;
+            ( ForTypeKind = ftk_user(_, _)
+            ; ForTypeKind = ftk_int
+            ; ForTypeKind = ftk_uint
+            ; ForTypeKind = ftk_int8
+            ; ForTypeKind = ftk_uint8
+            ; ForTypeKind = ftk_int16
+            ; ForTypeKind = ftk_uint16
+            ; ForTypeKind = ftk_uint32
+            ; ForTypeKind = ftk_float
+            ; ForTypeKind = ftk_char
+            ; ForTypeKind = ftk_string
+            ),
+            !:RevMismatchConsIdStrs = [ConsIdStr | !.RevMismatchConsIdStrs]
+        )
+    ;
+        ConsId = uint32_const(_),
+        (
+            ForTypeKind = ftk_uint32
+        ;
+            ( ForTypeKind = ftk_user(_, _)
+            ; ForTypeKind = ftk_int
+            ; ForTypeKind = ftk_uint
+            ; ForTypeKind = ftk_int8
+            ; ForTypeKind = ftk_uint8
+            ; ForTypeKind = ftk_int16
+            ; ForTypeKind = ftk_uint16
+            ; ForTypeKind = ftk_int32
              ; ForTypeKind = ftk_float
              ; ForTypeKind = ftk_char
              ; ForTypeKind = ftk_string
@@ -526,6 +736,12 @@ check_for_type_bound_insts(ForTypeKind, [BoundInst | BoundInsts],
              ( ForTypeKind = ftk_user(_, _)
              ; ForTypeKind = ftk_int
              ; ForTypeKind = ftk_uint
+            ; ForTypeKind = ftk_int8
+            ; ForTypeKind = ftk_uint8
+            ; ForTypeKind = ftk_int16
+            ; ForTypeKind = ftk_uint16
+            ; ForTypeKind = ftk_int32
+            ; ForTypeKind = ftk_uint32
              ; ForTypeKind = ftk_char
              ; ForTypeKind = ftk_string
              ),
@@ -539,6 +755,12 @@ check_for_type_bound_insts(ForTypeKind, [BoundInst | BoundInsts],
              ( ForTypeKind = ftk_user(_, _)
              ; ForTypeKind = ftk_int
              ; ForTypeKind = ftk_uint
+            ; ForTypeKind = ftk_int8
+            ; ForTypeKind = ftk_uint8
+            ; ForTypeKind = ftk_int16
+            ; ForTypeKind = ftk_uint16
+            ; ForTypeKind = ftk_int32
+            ; ForTypeKind = ftk_uint32
              ; ForTypeKind = ftk_float
              ; ForTypeKind = ftk_string
              ),
@@ -552,6 +774,12 @@ check_for_type_bound_insts(ForTypeKind, [BoundInst | BoundInsts],
              ( ForTypeKind = ftk_user(_, _)
              ; ForTypeKind = ftk_int
              ; ForTypeKind = ftk_uint
+            ; ForTypeKind = ftk_int8
+            ; ForTypeKind = ftk_uint8
+            ; ForTypeKind = ftk_int16
+            ; ForTypeKind = ftk_uint16
+            ; ForTypeKind = ftk_int32
+            ; ForTypeKind = ftk_uint32
              ; ForTypeKind = ftk_float
              ; ForTypeKind = ftk_char
              ),
@@ -656,6 +884,24 @@ get_possible_types_for_bound_inst(FunctorsToTypesMap, BoundInst, MaybeTypes) :-
          ConsId = uint_const(_),
          MaybeTypes = yes([type_builtin(builtin_type_uint)])
      ;
+        ConsId = int8_const(_),
+        MaybeTypes = yes([type_builtin(builtin_type_int8)])
+    ;
+        ConsId = uint8_const(_),
+        MaybeTypes = yes([type_builtin(builtin_type_uint8)])
+    ;
+        ConsId = int16_const(_),
+        MaybeTypes = yes([type_builtin(builtin_type_int16)])
+    ;
+        ConsId = uint16_const(_),
+        MaybeTypes = yes([type_builtin(builtin_type_uint16)])
+    ;
+        ConsId = int32_const(_),
+        MaybeTypes = yes([type_builtin(builtin_type_int32)])
+    ;
+        ConsId = uint32_const(_),
+        MaybeTypes = yes([type_builtin(builtin_type_uint32)])
+    ;
          ConsId = float_const(_),
          MaybeTypes = yes([type_builtin(builtin_type_float)])
      ;
@@ -760,6 +1006,24 @@ maybe_issue_type_match_error(InstId, InstDefn, ForTypeKind, MismatchConsIdStrs,
              ForTypeKind = ftk_uint,
              ForTypeCtor = uint_type_ctor
          ;
+            ForTypeKind = ftk_int8,
+            ForTypeCtor = int8_type_ctor
+        ;
+            ForTypeKind = ftk_uint8,
+            ForTypeCtor = uint8_type_ctor
+        ;
+            ForTypeKind = ftk_int16,
+            ForTypeCtor = int16_type_ctor
+        ;
+            ForTypeKind = ftk_uint16,
+            ForTypeCtor = uint16_type_ctor
+        ;
+            ForTypeKind = ftk_int32,
+            ForTypeCtor = int32_type_ctor
+        ;
+            ForTypeKind = ftk_uint32,
+            ForTypeCtor = uint32_type_ctor
+        ;
              ForTypeKind = ftk_float,
              ForTypeCtor = float_type_ctor
          ;
@@ -1066,6 +1330,48 @@ find_mismatches_from_builtin(ExpectedBuiltinType, CurNum,
              record_mismatch(CurNum, BoundInst, !NumMismatches, !PiecesCord)
          )
      ;
+        ExpectedBuiltinType = builtin_type_int8,
+        ( if ConsId = int8_const(_) then
+            true
+        else
+            record_mismatch(CurNum, BoundInst, !NumMismatches, !PiecesCord)
+        )
+    ;
+        ExpectedBuiltinType = builtin_type_uint8,
+        ( if ConsId = uint8_const(_) then
+            true
+        else
+            record_mismatch(CurNum, BoundInst, !NumMismatches, !PiecesCord)
+        )
+    ;
+        ExpectedBuiltinType = builtin_type_int16,
+        ( if ConsId = int16_const(_) then
+            true
+        else
+            record_mismatch(CurNum, BoundInst, !NumMismatches, !PiecesCord)
+        )
+    ;
+        ExpectedBuiltinType = builtin_type_uint16,
+        ( if ConsId = uint16_const(_) then
+            true
+        else
+            record_mismatch(CurNum, BoundInst, !NumMismatches, !PiecesCord)
+        )
+    ;
+        ExpectedBuiltinType = builtin_type_int32,
+        ( if ConsId = int32_const(_) then
+            true
+        else
+            record_mismatch(CurNum, BoundInst, !NumMismatches, !PiecesCord)
+        )
+    ;
+        ExpectedBuiltinType = builtin_type_uint32,
+        ( if ConsId = uint32_const(_) then
+            true
+        else
+            record_mismatch(CurNum, BoundInst, !NumMismatches, !PiecesCord)
+        )
+    ;
          ExpectedBuiltinType = builtin_type_float,
          ( if ConsId = float_const(_) then
              true
@@ -1227,6 +1533,24 @@ type_defn_or_builtin_to_string(TypeDefnOrBuiltin) = Str :-
              BuiltinType = builtin_type_uint,
              Str = "uint"
          ;
+            BuiltinType = builtin_type_int8,
+            Str = "int8"
+        ;
+            BuiltinType = builtin_type_uint8,
+            Str = "uint8"
+        ;
+            BuiltinType = builtin_type_int16,
+            Str = "int16"
+        ;
+            BuiltinType = builtin_type_uint16,
+            Str = "uint16"
+        ;
+            BuiltinType = builtin_type_int32,
+            Str = "int32"
+        ;
+            BuiltinType = builtin_type_uint32,
+            Str = "uint32"
+        ;
              BuiltinType = builtin_type_float,
              Str = "float"
          ;
diff --git a/compiler/jumpopt.m b/compiler/jumpopt.m
index cdc64b06b..d5b8e4dcb 100644
--- a/compiler/jumpopt.m
+++ b/compiler/jumpopt.m
@@ -1157,6 +1157,12 @@ short_circuit_labels_const(InstrMap, RvalConst0, RvalConst) :-
          ; RvalConst0 = llconst_false
          ; RvalConst0 = llconst_int(_I)
          ; RvalConst0 = llconst_uint(_U)
+        ; RvalConst0 = llconst_int8(_I8)
+        ; RvalConst0 = llconst_uint8(_U8)
+        ; RvalConst0 = llconst_int16(_I16)
+        ; RvalConst0 = llconst_uint16(_U16)
+        ; RvalConst0 = llconst_int32(_I32)
+        ; RvalConst0 = llconst_uint32(_U32)
          ; RvalConst0 = llconst_foreign(_V, _T)
          ; RvalConst0 = llconst_float(_F)
          ; RvalConst0 = llconst_string(_S)
@@ -1179,7 +1185,7 @@ short_circuit_labels_const(InstrMap, RvalConst0, RvalConst) :-
  %
  % :- pred short_circuit_labels_maybe_rvals(instrmap::in, list(maybe(rval))::in,
  %     list(maybe(rval))::out) is det.
-% 
+%
  % short_circuit_labels_maybe_rvals(_, [], []).
  % short_circuit_labels_maybe_rvals(InstrMap, [MaybeRval0 | MaybeRvals0],
  %         [MaybeRval | MaybeRvals]) :-
diff --git a/compiler/llds.m b/compiler/llds.m
index 02df86c23..544d4da4d 100644
--- a/compiler/llds.m
+++ b/compiler/llds.m
@@ -1203,6 +1203,15 @@
      ;       llconst_false
      ;       llconst_int(int)
      ;       llconst_uint(uint)
+
+            % XXX FIXED SIZE INT
+    ;       llconst_int8(int)
+    ;       llconst_uint8(int)
+    ;       llconst_int16(int)
+    ;       llconst_uint16(int)
+    ;       llconst_int32(int)
+    ;       llconst_uint32(int)
+
      ;       llconst_foreign(string, llds_type)
              % A constant in the target language.
              % It may be a #defined constant in C which is why
@@ -1376,6 +1385,13 @@
              % Something whose C type is `MR_Unsigned' (the unsigned equivalent
              % of `MR_Integer').

+    ;       lt_int8
+    ;       lt_uint8
+    ;       lt_int16
+    ;       lt_uint16
+    ;       lt_int32
+    ;       lt_uint32
+
      ;       lt_float
              % A Mercury `float', represented in C as a value of type `MR_Float'
              % (which may be either `float' or `double', but is usually
@@ -1671,6 +1687,13 @@ const_type(llconst_true, lt_bool).
  const_type(llconst_false, lt_bool).
  const_type(llconst_int(_), lt_integer).
  const_type(llconst_uint(_), lt_unsigned).
+% XXX FIXED SIZE INT - fix  lt_integer / lt_unsigned
+const_type(llconst_int8(_), lt_integer).
+const_type(llconst_uint8(_), lt_unsigned).
+const_type(llconst_int16(_), lt_integer).
+const_type(llconst_uint16(_), lt_unsigned).
+const_type(llconst_int32(_), lt_integer).
+const_type(llconst_uint32(_), lt_unsigned).
  const_type(llconst_foreign(_, Type), Type).
  const_type(llconst_float(_), lt_float).
  const_type(llconst_string(_), lt_string).
@@ -1693,6 +1716,12 @@ unop_return_type(hash_string4, lt_integer).
  unop_return_type(hash_string5, lt_integer).
  unop_return_type(hash_string6, lt_integer).
  unop_return_type(uint_bitwise_complement, lt_unsigned).
+unop_return_type(int8_bitwise_complement, lt_int8).
+unop_return_type(uint8_bitwise_complement, lt_uint8).
+unop_return_type(int16_bitwise_complement, lt_int16).
+unop_return_type(uint16_bitwise_complement, lt_uint16).
+unop_return_type(int32_bitwise_complement, lt_int32).
+unop_return_type(uint32_bitwise_complement, lt_uint32).

  unop_arg_type(mktag, lt_word).
  unop_arg_type(tag, lt_word).
@@ -1709,6 +1738,12 @@ unop_arg_type(hash_string4, lt_string).
  unop_arg_type(hash_string5, lt_string).
  unop_arg_type(hash_string6, lt_string).
  unop_arg_type(uint_bitwise_complement, lt_unsigned).
+unop_arg_type(int8_bitwise_complement, lt_int8).
+unop_arg_type(uint8_bitwise_complement, lt_uint8).
+unop_arg_type(int16_bitwise_complement, lt_int16).
+unop_arg_type(uint16_bitwise_complement, lt_uint16).
+unop_arg_type(int32_bitwise_complement, lt_int32).
+unop_arg_type(uint32_bitwise_complement, lt_uint32).

  binop_return_type(int_add, lt_integer).
  binop_return_type(int_sub, lt_integer).
@@ -1771,6 +1806,102 @@ binop_return_type(uint_bitwise_or, lt_unsigned).
  binop_return_type(uint_bitwise_xor, lt_unsigned).
  binop_return_type(uint_unchecked_left_shift, lt_unsigned).
  binop_return_type(uint_unchecked_right_shift, lt_unsigned).
+binop_return_type(int8_eq, lt_bool).
+binop_return_type(int8_ne, lt_bool).
+binop_return_type(int8_lt, lt_bool).
+binop_return_type(int8_gt, lt_bool).
+binop_return_type(int8_le, lt_bool).
+binop_return_type(int8_ge, lt_bool).
+binop_return_type(int8_add, lt_int8).
+binop_return_type(int8_sub, lt_int8).
+binop_return_type(int8_mul, lt_int8).
+binop_return_type(int8_div, lt_int8).
+binop_return_type(int8_mod, lt_int8).
+binop_return_type(int8_bitwise_and, lt_int8).
+binop_return_type(int8_bitwise_or, lt_int8).
+binop_return_type(int8_bitwise_xor, lt_int8).
+binop_return_type(int8_unchecked_left_shift, lt_int8).
+binop_return_type(int8_unchecked_right_shift, lt_int8).
+binop_return_type(uint8_eq, lt_bool).
+binop_return_type(uint8_ne, lt_bool).
+binop_return_type(uint8_lt, lt_bool).
+binop_return_type(uint8_gt, lt_bool).
+binop_return_type(uint8_le, lt_bool).
+binop_return_type(uint8_ge, lt_bool).
+binop_return_type(uint8_add, lt_uint8).
+binop_return_type(uint8_sub, lt_uint8).
+binop_return_type(uint8_mul, lt_uint8).
+binop_return_type(uint8_div, lt_uint8).
+binop_return_type(uint8_mod, lt_uint8).
+binop_return_type(uint8_bitwise_and, lt_uint8).
+binop_return_type(uint8_bitwise_or, lt_uint8).
+binop_return_type(uint8_bitwise_xor, lt_uint8).
+binop_return_type(uint8_unchecked_left_shift, lt_uint8).
+binop_return_type(uint8_unchecked_right_shift, lt_uint8).
+binop_return_type(int16_eq, lt_bool).
+binop_return_type(int16_ne, lt_bool).
+binop_return_type(int16_lt, lt_bool).
+binop_return_type(int16_gt, lt_bool).
+binop_return_type(int16_le, lt_bool).
+binop_return_type(int16_ge, lt_bool).
+binop_return_type(int16_add, lt_int16).
+binop_return_type(int16_sub, lt_int16).
+binop_return_type(int16_mul, lt_int16).
+binop_return_type(int16_div, lt_int16).
+binop_return_type(int16_mod, lt_int16).
+binop_return_type(int16_bitwise_and, lt_int16).
+binop_return_type(int16_bitwise_or, lt_int16).
+binop_return_type(int16_bitwise_xor, lt_int16).
+binop_return_type(int16_unchecked_left_shift, lt_int16).
+binop_return_type(int16_unchecked_right_shift, lt_int16).
+binop_return_type(uint16_eq, lt_bool).
+binop_return_type(uint16_ne, lt_bool).
+binop_return_type(uint16_lt, lt_bool).
+binop_return_type(uint16_gt, lt_bool).
+binop_return_type(uint16_le, lt_bool).
+binop_return_type(uint16_ge, lt_bool).
+binop_return_type(uint16_add, lt_uint16).
+binop_return_type(uint16_sub, lt_uint16).
+binop_return_type(uint16_mul, lt_uint16).
+binop_return_type(uint16_div, lt_uint16).
+binop_return_type(uint16_mod, lt_uint16).
+binop_return_type(uint16_bitwise_and, lt_uint16).
+binop_return_type(uint16_bitwise_or, lt_uint16).
+binop_return_type(uint16_bitwise_xor, lt_uint16).
+binop_return_type(uint16_unchecked_left_shift, lt_uint16).
+binop_return_type(uint16_unchecked_right_shift, lt_uint16).
+binop_return_type(int32_eq, lt_bool).
+binop_return_type(int32_ne, lt_bool).
+binop_return_type(int32_lt, lt_bool).
+binop_return_type(int32_gt, lt_bool).
+binop_return_type(int32_le, lt_bool).
+binop_return_type(int32_ge, lt_bool).
+binop_return_type(int32_add, lt_int32).
+binop_return_type(int32_sub, lt_int32).
+binop_return_type(int32_mul, lt_int32).
+binop_return_type(int32_div, lt_int32).
+binop_return_type(int32_mod, lt_int32).
+binop_return_type(int32_bitwise_and, lt_int32).
+binop_return_type(int32_bitwise_or, lt_int32).
+binop_return_type(int32_bitwise_xor, lt_int32).
+binop_return_type(int32_unchecked_left_shift, lt_int32).
+binop_return_type(int32_unchecked_right_shift, lt_int32).
+binop_return_type(uint32_eq, lt_bool).
+binop_return_type(uint32_ne, lt_bool).
+binop_return_type(uint32_lt, lt_bool).
+binop_return_type(uint32_gt, lt_bool).
+binop_return_type(uint32_le, lt_bool).
+binop_return_type(uint32_ge, lt_bool).
+binop_return_type(uint32_add, lt_uint32).
+binop_return_type(uint32_sub, lt_uint32).
+binop_return_type(uint32_mul, lt_uint32).
+binop_return_type(uint32_div, lt_uint32).
+binop_return_type(uint32_mod, lt_uint32).
+binop_return_type(uint32_bitwise_and, lt_uint32).
+binop_return_type(uint32_bitwise_or, lt_uint32).
+binop_return_type(uint32_bitwise_xor, lt_uint32).
+binop_return_type(uint32_unchecked_left_shift, lt_uint32).
+binop_return_type(uint32_unchecked_right_shift, lt_uint32).

  register_type(reg_r, lt_word).
  register_type(reg_f, lt_float).
diff --git a/compiler/llds_out_data.m b/compiler/llds_out_data.m
index bbcab36f4..1339099ff 100644
--- a/compiler/llds_out_data.m
+++ b/compiler/llds_out_data.m
@@ -579,6 +579,18 @@ output_llds_type(lt_integer, !IO) :-
      io.write_string("MR_Integer", !IO).
  output_llds_type(lt_unsigned, !IO) :-
      io.write_string("MR_Unsigned", !IO).
+output_llds_type(lt_int8, !IO) :-
+    io.write_string("int8_t", !IO).
+output_llds_type(lt_uint8, !IO) :-
+    io.write_string("uint8_t", !IO).
+output_llds_type(lt_int16, !IO) :-
+    io.write_string("int16_t", !IO).
+output_llds_type(lt_uint16, !IO) :-
+    io.write_string("uint16_t", !IO).
+output_llds_type(lt_int32, !IO) :-
+    io.write_string("int32_t", !IO).
+output_llds_type(lt_uint32, !IO) :-
+    io.write_string("uint32_t", !IO).
  output_llds_type(lt_float, !IO) :-
      io.write_string("MR_Float", !IO).
  output_llds_type(lt_word, !IO) :-
@@ -1035,6 +1047,156 @@ output_rval(Info, Rval, !IO) :-
              output_rval_as_type(Info, SubRvalB, lt_unsigned, !IO),
              io.write_string(")", !IO)
          ;
+            ( Op = int8_eq, OpStr = "=="
+            ; Op = int8_ne, OpStr = "!="
+            ; Op = int8_lt, OpStr = "<"
+            ; Op = int8_gt, OpStr = ">"
+            ; Op = int8_le, OpStr = "<="
+            ; Op = int8_ge, OpStr = ">="
+            ; Op = int8_add, OpStr = "+"
+            ; Op = int8_sub, OpStr = "-"
+            ; Op = int8_mul, OpStr = "*"
+            ; Op = int8_div, OpStr = "/"
+            ; Op = int8_mod, OpStr = "%"
+            ; Op = int8_bitwise_and, OpStr = "&"
+            ; Op = int8_bitwise_or, OpStr = "|"
+            ; Op = int8_bitwise_xor, OpStr = "^"
+            ; Op = int8_unchecked_left_shift, OpStr = "<<"
+            ; Op = int8_unchecked_right_shift, OpStr = ">>"
+            ),
+            io.write_string("(", !IO),
+            output_rval_as_type(Info, SubRvalA, lt_int8, !IO),
+            io.write_string(" ", !IO),
+            io.write_string(OpStr, !IO),
+            io.write_string(" ", !IO),
+            output_rval_as_type(Info, SubRvalB, lt_int8, !IO),
+            io.write_string(")", !IO)
+        ;
+            ( Op = uint8_eq, OpStr = "=="
+            ; Op = uint8_ne, OpStr = "!="
+            ; Op = uint8_lt, OpStr = "<"
+            ; Op = uint8_gt, OpStr = ">"
+            ; Op = uint8_le, OpStr = "<="
+            ; Op = uint8_ge, OpStr = ">="
+            ; Op = uint8_add, OpStr = "+"
+            ; Op = uint8_sub, OpStr = "-"
+            ; Op = uint8_mul, OpStr = "*"
+            ; Op = uint8_div, OpStr = "/"
+            ; Op = uint8_mod, OpStr = "%"
+            ; Op = uint8_bitwise_and, OpStr = "&"
+            ; Op = uint8_bitwise_or, OpStr = "|"
+            ; Op = uint8_bitwise_xor, OpStr = "^"
+            ; Op = uint8_unchecked_left_shift, OpStr = "<<"
+            ; Op = uint8_unchecked_right_shift, OpStr = ">>"
+            ),
+            io.write_string("(", !IO),
+            output_rval_as_type(Info, SubRvalA, lt_uint8, !IO),
+            io.write_string(" ", !IO),
+            io.write_string(OpStr, !IO),
+            io.write_string(" ", !IO),
+            output_rval_as_type(Info, SubRvalB, lt_uint8, !IO),
+            io.write_string(")", !IO)
+        ;
+            ( Op = int16_eq, OpStr = "=="
+            ; Op = int16_ne, OpStr = "!="
+            ; Op = int16_lt, OpStr = "<"
+            ; Op = int16_gt, OpStr = ">"
+            ; Op = int16_le, OpStr = "<="
+            ; Op = int16_ge, OpStr = ">="
+            ; Op = int16_add, OpStr = "+"
+            ; Op = int16_sub, OpStr = "-"
+            ; Op = int16_mul, OpStr = "*"
+            ; Op = int16_div, OpStr = "/"
+            ; Op = int16_mod, OpStr = "%"
+            ; Op = int16_bitwise_and, OpStr = "&"
+            ; Op = int16_bitwise_or, OpStr = "|"
+            ; Op = int16_bitwise_xor, OpStr = "^"
+            ; Op = int16_unchecked_left_shift, OpStr = "<<"
+            ; Op = int16_unchecked_right_shift, OpStr = ">>"
+            ),
+            io.write_string("(", !IO),
+            output_rval_as_type(Info, SubRvalA, lt_int16, !IO),
+            io.write_string(" ", !IO),
+            io.write_string(OpStr, !IO),
+            io.write_string(" ", !IO),
+            output_rval_as_type(Info, SubRvalB, lt_int16, !IO),
+            io.write_string(")", !IO)
+        ;
+            ( Op = uint16_eq, OpStr = "=="
+            ; Op = uint16_ne, OpStr = "!="
+            ; Op = uint16_lt, OpStr = "<"
+            ; Op = uint16_gt, OpStr = ">"
+            ; Op = uint16_le, OpStr = "<="
+            ; Op = uint16_ge, OpStr = ">="
+            ; Op = uint16_add, OpStr = "+"
+            ; Op = uint16_sub, OpStr = "-"
+            ; Op = uint16_mul, OpStr = "*"
+            ; Op = uint16_div, OpStr = "/"
+            ; Op = uint16_mod, OpStr = "%"
+            ; Op = uint16_bitwise_and, OpStr = "&"
+            ; Op = uint16_bitwise_or, OpStr = "|"
+            ; Op = uint16_bitwise_xor, OpStr = "^"
+            ; Op = uint16_unchecked_left_shift, OpStr = "<<"
+            ; Op = uint16_unchecked_right_shift, OpStr = ">>"
+            ),
+            io.write_string("(", !IO),
+            output_rval_as_type(Info, SubRvalA, lt_uint16, !IO),
+            io.write_string(" ", !IO),
+            io.write_string(OpStr, !IO),
+            io.write_string(" ", !IO),
+            output_rval_as_type(Info, SubRvalB, lt_uint16, !IO),
+            io.write_string(")", !IO)
+        ;
+            ( Op = int32_eq, OpStr = "=="
+            ; Op = int32_ne, OpStr = "!="
+            ; Op = int32_lt, OpStr = "<"
+            ; Op = int32_gt, OpStr = ">"
+            ; Op = int32_le, OpStr = "<="
+            ; Op = int32_ge, OpStr = ">="
+            ; Op = int32_add, OpStr = "+"
+            ; Op = int32_sub, OpStr = "-"
+            ; Op = int32_mul, OpStr = "*"
+            ; Op = int32_div, OpStr = "/"
+            ; Op = int32_mod, OpStr = "%"
+            ; Op = int32_bitwise_and, OpStr = "&"
+            ; Op = int32_bitwise_or, OpStr = "|"
+            ; Op = int32_bitwise_xor, OpStr = "^"
+            ; Op = int32_unchecked_left_shift, OpStr = "<<"
+            ; Op = int32_unchecked_right_shift, OpStr = ">>"
+            ),
+            io.write_string("(", !IO),
+            output_rval_as_type(Info, SubRvalA, lt_int32, !IO),
+            io.write_string(" ", !IO),
+            io.write_string(OpStr, !IO),
+            io.write_string(" ", !IO),
+            output_rval_as_type(Info, SubRvalB, lt_int32, !IO),
+            io.write_string(")", !IO)
+        ;
+            ( Op = uint32_eq, OpStr = "=="
+            ; Op = uint32_ne, OpStr = "!="
+            ; Op = uint32_lt, OpStr = "<"
+            ; Op = uint32_gt, OpStr = ">"
+            ; Op = uint32_le, OpStr = "<="
+            ; Op = uint32_ge, OpStr = ">="
+            ; Op = uint32_add, OpStr = "+"
+            ; Op = uint32_sub, OpStr = "-"
+            ; Op = uint32_mul, OpStr = "*"
+            ; Op = uint32_div, OpStr = "/"
+            ; Op = uint32_mod, OpStr = "%"
+            ; Op = uint32_bitwise_and, OpStr = "&"
+            ; Op = uint32_bitwise_or, OpStr = "|"
+            ; Op = uint32_bitwise_xor, OpStr = "^"
+            ; Op = uint32_unchecked_left_shift, OpStr = "<<"
+            ; Op = uint32_unchecked_right_shift, OpStr = ">>"
+            ),
+            io.write_string("(", !IO),
+            output_rval_as_type(Info, SubRvalA, lt_uint32, !IO),
+            io.write_string(" ", !IO),
+            io.write_string(OpStr, !IO),
+            io.write_string(" ", !IO),
+            output_rval_as_type(Info, SubRvalB, lt_uint32, !IO),
+            io.write_string(")", !IO)
+        ;
              Op = str_cmp,
              io.write_string("MR_strcmp(", !IO),
              output_rval_as_type(Info, SubRvalA, lt_data_ptr, !IO),
@@ -1203,6 +1365,24 @@ output_rval_const(Info, Const, !IO) :-
          Const = llconst_uint(N),
          c_util.output_uint_expr_cur_stream(N, !IO)
      ;
+        Const = llconst_int8(N),
+        c_util.output_int_expr_cur_stream(N, !IO)
+    ;
+        Const = llconst_uint8(N),
+        c_util.output_int_expr_cur_stream(N, !IO)
+    ;
+        Const = llconst_int16(N),
+        c_util.output_int_expr_cur_stream(N, !IO)
+    ;
+        Const = llconst_uint16(N),
+        c_util.output_int_expr_cur_stream(N, !IO)
+    ;
+        Const = llconst_int32(N),
+        c_util.output_int_expr_cur_stream(N, !IO)
+    ;
+        Const = llconst_uint32(N),
+        c_util.output_int_expr_cur_stream(N, !IO)
+    ;
          Const = llconst_foreign(Value, Type),
          io.write_char('(', !IO),
          output_llds_type_cast(Type, !IO),
@@ -1296,6 +1476,18 @@ output_type_ctor_addr(Module0, Name, Arity, !IO) :-
                  Macro = "MR_INT_CTOR_ADDR"
              else if Name = "uint" then
                  Macro = "MR_UINT_CTOR_ADDR"
+            else if Name = "int8" then
+                Macro = "MR_INT8_CTOR_ADDR"
+            else if Name = "uint8" then
+                Macro = "MR_UINT8_CTOR_ADDR"
+            else if Name = "int16" then
+                Macro = "MR_INT16_CTOR_ADDR"
+            else if Name = "uint16" then
+                Macro = "MR_UINT16_CTOR_ADDR"
+            else if Name = "int32" then
+                Macro = "MR_INT32_CTOR_ADDR"
+            else if Name = "uint32" then
+                Macro = "MR_UINT32_CTOR_ADDR"
              else if Name = "float" then
                  Macro = "MR_FLOAT_CTOR_ADDR"
              else if Name = "string" then
@@ -1643,6 +1835,12 @@ direct_field_int_constant(lt_int_least32) = yes.
  direct_field_int_constant(lt_uint_least32) = yes.
  direct_field_int_constant(lt_integer) = yes.
  direct_field_int_constant(lt_unsigned) = yes.
+direct_field_int_constant(lt_int8) = yes.
+direct_field_int_constant(lt_uint8) = yes.
+direct_field_int_constant(lt_int16) = yes.
+direct_field_int_constant(lt_uint16) = yes.
+direct_field_int_constant(lt_int32) = yes.
+direct_field_int_constant(lt_uint32) = yes.
  direct_field_int_constant(lt_float) = no.
  direct_field_int_constant(lt_string) = no.
  direct_field_int_constant(lt_data_ptr) = no.
diff --git a/compiler/llds_out_instr.m b/compiler/llds_out_instr.m
index 7bc51b5a8..48b629371 100644
--- a/compiler/llds_out_instr.m
+++ b/compiler/llds_out_instr.m
@@ -2098,6 +2098,36 @@ output_foreign_proc_output(Info, Output, !IO) :-
                      output_lval_as_word(Info, Lval, !IO),
                      io.write_string(" = ", !IO),
                      io.write_string(VarName, !IO)
+                ;
+                    BuiltinType = builtin_type_int8,
+                    output_lval_as_word(Info, Lval, !IO),
+                    io.write_string(" = ", !IO),
+                    io.write_string(VarName, !IO)
+                ;
+                    BuiltinType = builtin_type_uint8,
+                    output_lval_as_word(Info, Lval, !IO),
+                    io.write_string(" = ", !IO),
+                    io.write_string(VarName, !IO)
+                ;
+                    BuiltinType = builtin_type_int16,
+                    output_lval_as_word(Info, Lval, !IO),
+                    io.write_string(" = ", !IO),
+                    io.write_string(VarName, !IO)
+                ;
+                    BuiltinType = builtin_type_uint16,
+                    output_lval_as_word(Info, Lval, !IO),
+                    io.write_string(" = ", !IO),
+                    io.write_string(VarName, !IO)
+                ;
+                    BuiltinType = builtin_type_int32,
+                    output_lval_as_word(Info, Lval, !IO),
+                    io.write_string(" = ", !IO),
+                    io.write_string(VarName, !IO)
+                ;
+                    BuiltinType = builtin_type_uint32,
+                    output_lval_as_word(Info, Lval, !IO),
+                    io.write_string(" = ", !IO),
+                    io.write_string(VarName, !IO)
                  )
              else
                  output_lval_as_word(Info, Lval, !IO),
diff --git a/compiler/lookup_switch.m b/compiler/lookup_switch.m
index 7e8c7df7e..21ee3974a 100644
--- a/compiler/lookup_switch.m
+++ b/compiler/lookup_switch.m
@@ -949,7 +949,14 @@ default_value_for_type(lt_uint_least16) = const(llconst_int(0)).
  default_value_for_type(lt_int_least32) = const(llconst_int(0)).
  default_value_for_type(lt_uint_least32) = const(llconst_int(0)).
  default_value_for_type(lt_integer) = const(llconst_int(0)).
-default_value_for_type(lt_unsigned) = const(llconst_int(0)).
+default_value_for_type(lt_unsigned) = const(llconst_uint(0u)).
+% XXX FIXED SIZE INT.
+default_value_for_type(lt_int8) = const(llconst_int8(0)).
+default_value_for_type(lt_uint8) = const(llconst_uint8(0)).
+default_value_for_type(lt_int16) = const(llconst_int16(0)).
+default_value_for_type(lt_uint16) = const(llconst_uint16(0)).
+default_value_for_type(lt_int32) = const(llconst_int32(0)).
+default_value_for_type(lt_uint32) = const(llconst_uint32(0)).
  default_value_for_type(lt_float) = const(llconst_float(0.0)).
  default_value_for_type(lt_string) = const(llconst_string("")).
  default_value_for_type(lt_data_ptr) = const(llconst_int(0)).
diff --git a/compiler/mercury_to_mercury.m b/compiler/mercury_to_mercury.m
index b8ff0f7e6..a88aeb0e1 100644
--- a/compiler/mercury_to_mercury.m
+++ b/compiler/mercury_to_mercury.m
@@ -267,6 +267,24 @@ mercury_format_cons_id(NeedsBrackets, ConsId, !U) :-
          ConsId = uint_const(UInt),
          add_uint(UInt, !U)
      ;
+        ConsId = int8_const(Int8),
+        add_int8(Int8, !U)
+    ;
+        ConsId = uint8_const(UInt8),
+        add_uint8(UInt8, !U)
+    ;
+        ConsId = int16_const(Int16),
+        add_int16(Int16, !U)
+    ;
+        ConsId = uint16_const(UInt16),
+        add_uint16(UInt16, !U)
+    ;
+        ConsId = int32_const(Int32),
+        add_int32(Int32, !U)
+    ;
+        ConsId = uint32_const(UInt32),
+        add_uint32(UInt32, !U)
+    ;
          ConsId = float_const(Float),
          add_float(Float, !U)
      ;
diff --git a/compiler/ml_accurate_gc.m b/compiler/ml_accurate_gc.m
index 554dafa13..fdd136110 100644
--- a/compiler/ml_accurate_gc.m
+++ b/compiler/ml_accurate_gc.m
@@ -254,6 +254,12 @@ ml_type_category_might_contain_pointers(CtorCat) = MayContainPointers :-
      (
          ( CtorCat = ctor_cat_builtin(cat_builtin_int)
          ; CtorCat = ctor_cat_builtin(cat_builtin_uint)
+        ; CtorCat = ctor_cat_builtin(cat_builtin_int8)
+        ; CtorCat = ctor_cat_builtin(cat_builtin_uint8)
+        ; CtorCat = ctor_cat_builtin(cat_builtin_int16)
+        ; CtorCat = ctor_cat_builtin(cat_builtin_uint16)
+        ; CtorCat = ctor_cat_builtin(cat_builtin_int32)
+        ; CtorCat = ctor_cat_builtin(cat_builtin_uint32)
          ; CtorCat = ctor_cat_builtin(cat_builtin_char)
          ; CtorCat = ctor_cat_builtin(cat_builtin_float)
          ; CtorCat = ctor_cat_builtin_dummy
diff --git a/compiler/ml_call_gen.m b/compiler/ml_call_gen.m
index 816b57da9..0adbe9264 100644
--- a/compiler/ml_call_gen.m
+++ b/compiler/ml_call_gen.m
@@ -813,6 +813,12 @@ ml_gen_builtin(PredId, ProcId, ArgVars, CodeModel, Context, Decls, Statements,
  ml_gen_simple_expr(leaf(Lval)) = ml_lval(Lval).
  ml_gen_simple_expr(int_const(Int)) = ml_const(mlconst_int(Int)).
  ml_gen_simple_expr(uint_const(UInt)) = ml_const(mlconst_uint(UInt)).
+ml_gen_simple_expr(int8_const(Int8)) = ml_const(mlconst_int8(Int8)).
+ml_gen_simple_expr(uint8_const(UInt8)) = ml_const(mlconst_uint8(UInt8)).
+ml_gen_simple_expr(int16_const(Int16)) = ml_const(mlconst_int16(Int16)).
+ml_gen_simple_expr(uint16_const(UInt16)) = ml_const(mlconst_uint16(UInt16)).
+ml_gen_simple_expr(int32_const(Int32)) = ml_const(mlconst_int32(Int32)).
+ml_gen_simple_expr(uint32_const(UInt32)) = ml_const(mlconst_uint32(UInt32)).
  ml_gen_simple_expr(float_const(Float)) = ml_const(mlconst_float(Float)).
  ml_gen_simple_expr(unary(Op, Expr)) =
      ml_unop(std_unop(Op), ml_gen_simple_expr(Expr)).
diff --git a/compiler/ml_code_util.m b/compiler/ml_code_util.m
index 98de501ba..075ef039c 100644
--- a/compiler/ml_code_util.m
+++ b/compiler/ml_code_util.m
@@ -1364,6 +1364,12 @@ ml_must_box_field_type_category(CtorCat, UnboxedFloat, Width) = MustBox :-
      (
          ( CtorCat = ctor_cat_builtin(cat_builtin_int)
          ; CtorCat = ctor_cat_builtin(cat_builtin_uint)
+        ; CtorCat = ctor_cat_builtin(cat_builtin_int8)
+        ; CtorCat = ctor_cat_builtin(cat_builtin_uint8)
+        ; CtorCat = ctor_cat_builtin(cat_builtin_int16)
+        ; CtorCat = ctor_cat_builtin(cat_builtin_uint16)
+        ; CtorCat = ctor_cat_builtin(cat_builtin_int32)
+        ; CtorCat = ctor_cat_builtin(cat_builtin_uint32)
          ; CtorCat = ctor_cat_builtin(cat_builtin_string)
          ; CtorCat = ctor_cat_builtin_dummy
          ; CtorCat = ctor_cat_higher_order
diff --git a/compiler/ml_global_data.m b/compiler/ml_global_data.m
index c246c580a..bf526ebd6 100644
--- a/compiler/ml_global_data.m
+++ b/compiler/ml_global_data.m
@@ -605,6 +605,102 @@ ml_specialize_generic_array_binop(Op, IsFloat) :-
          ; Op = uint_bitwise_xor
          ; Op = uint_unchecked_left_shift
          ; Op = uint_unchecked_right_shift
+        ; Op = int8_eq
+        ; Op = int8_ne
+        ; Op = int8_lt
+        ; Op = int8_gt
+        ; Op = int8_le
+        ; Op = int8_ge
+        ; Op = int8_add
+        ; Op = int8_sub
+        ; Op = int8_mul
+        ; Op = int8_div
+        ; Op = int8_mod
+        ; Op = int8_bitwise_and
+        ; Op = int8_bitwise_or
+        ; Op = int8_bitwise_xor
+        ; Op = int8_unchecked_left_shift
+        ; Op = int8_unchecked_right_shift
+        ; Op = uint8_eq
+        ; Op = uint8_ne
+        ; Op = uint8_lt
+        ; Op = uint8_gt
+        ; Op = uint8_le
+        ; Op = uint8_ge
+        ; Op = uint8_add
+        ; Op = uint8_sub
+        ; Op = uint8_mul
+        ; Op = uint8_div
+        ; Op = uint8_mod
+        ; Op = uint8_bitwise_and
+        ; Op = uint8_bitwise_or
+        ; Op = uint8_bitwise_xor
+        ; Op = uint8_unchecked_left_shift
+        ; Op = uint8_unchecked_right_shift
+        ; Op = int16_eq
+        ; Op = int16_ne
+        ; Op = int16_lt
+        ; Op = int16_gt
+        ; Op = int16_le
+        ; Op = int16_ge
+        ; Op = int16_add
+        ; Op = int16_sub
+        ; Op = int16_mul
+        ; Op = int16_div
+        ; Op = int16_mod
+        ; Op = int16_bitwise_and
+        ; Op = int16_bitwise_or
+        ; Op = int16_bitwise_xor
+        ; Op = int16_unchecked_left_shift
+        ; Op = int16_unchecked_right_shift
+        ; Op = uint16_eq
+        ; Op = uint16_ne
+        ; Op = uint16_lt
+        ; Op = uint16_gt
+        ; Op = uint16_le
+        ; Op = uint16_ge
+        ; Op = uint16_add
+        ; Op = uint16_sub
+        ; Op = uint16_mul
+        ; Op = uint16_div
+        ; Op = uint16_mod
+        ; Op = uint16_bitwise_and
+        ; Op = uint16_bitwise_or
+        ; Op = uint16_bitwise_xor
+        ; Op = uint16_unchecked_left_shift
+        ; Op = uint16_unchecked_right_shift
+        ; Op = int32_eq
+        ; Op = int32_ne
+        ; Op = int32_lt
+        ; Op = int32_gt
+        ; Op = int32_le
+        ; Op = int32_ge
+        ; Op = int32_add
+        ; Op = int32_sub
+        ; Op = int32_mul
+        ; Op = int32_div
+        ; Op = int32_mod
+        ; Op = int32_bitwise_and
+        ; Op = int32_bitwise_or
+        ; Op = int32_bitwise_xor
+        ; Op = int32_unchecked_left_shift
+        ; Op = int32_unchecked_right_shift
+        ; Op = uint32_eq
+        ; Op = uint32_ne
+        ; Op = uint32_lt
+        ; Op = uint32_gt
+        ; Op = uint32_le
+        ; Op = uint32_ge
+        ; Op = uint32_add
+        ; Op = uint32_sub
+        ; Op = uint32_mul
+        ; Op = uint32_div
+        ; Op = uint32_mod
+        ; Op = uint32_bitwise_and
+        ; Op = uint32_bitwise_or
+        ; Op = uint32_bitwise_xor
+        ; Op = uint32_unchecked_left_shift
+        ; Op = uint32_unchecked_right_shift
          ; Op = float_eq
          ; Op = float_ne
          ; Op = float_lt
@@ -811,6 +907,12 @@ cons_id_to_alloc_site_string(ConsId) = TypeStr :-
      ;
          ( ConsId = int_const(_)
          ; ConsId = uint_const(_)
+        ; ConsId = int8_const(_)
+        ; ConsId = uint8_const(_)
+        ; ConsId = int16_const(_)
+        ; ConsId = uint16_const(_)
+        ; ConsId = int32_const(_)
+        ; ConsId = uint32_const(_)
          ; ConsId = float_const(_)
          ; ConsId = char_const(_)
          ; ConsId = string_const(_)
diff --git a/compiler/ml_simplify_switch.m b/compiler/ml_simplify_switch.m
index b521515f4..4aef14886 100644
--- a/compiler/ml_simplify_switch.m
+++ b/compiler/ml_simplify_switch.m
@@ -154,6 +154,12 @@ is_integral_type(MLDSType) = IsIntegral :-
          (
              ( CtorCat = ctor_cat_builtin(cat_builtin_int)
              ; CtorCat = ctor_cat_builtin(cat_builtin_uint)
+            ; CtorCat = ctor_cat_builtin(cat_builtin_int8)
+            ; CtorCat = ctor_cat_builtin(cat_builtin_uint8)
+            ; CtorCat = ctor_cat_builtin(cat_builtin_int16)
+            ; CtorCat = ctor_cat_builtin(cat_builtin_uint16)
+            ; CtorCat = ctor_cat_builtin(cat_builtin_int32)
+            ; CtorCat = ctor_cat_builtin(cat_builtin_uint32)
              ; CtorCat = ctor_cat_builtin(cat_builtin_char)
              ; CtorCat = ctor_cat_enum(cat_enum_mercury)
              ),
diff --git a/compiler/ml_switch_gen.m b/compiler/ml_switch_gen.m
index 29f77e547..9e84d3a00 100644
--- a/compiler/ml_switch_gen.m
+++ b/compiler/ml_switch_gen.m
@@ -604,6 +604,24 @@ ml_tagged_cons_id_to_match_cond(MLDS_Type, TaggedConsId, MatchCond) :-
          Tag = uint_tag(UInt),
          Rval = ml_const(mlconst_uint(UInt))
      ;
+        Tag = int8_tag(Int8),
+        Rval = ml_const(mlconst_int8(Int8))
+    ;
+        Tag = uint8_tag(UInt8),
+        Rval = ml_const(mlconst_uint8(UInt8))
+    ;
+        Tag = int16_tag(Int16),
+        Rval = ml_const(mlconst_int16(Int16))
+    ;
+        Tag = uint16_tag(UInt16),
+        Rval = ml_const(mlconst_uint16(UInt16))
+    ;
+        Tag = int32_tag(Int32),
+        Rval = ml_const(mlconst_int32(Int32))
+    ;
+        Tag = uint32_tag(UInt32),
+        Rval = ml_const(mlconst_uint32(UInt32))
+    ;
          Tag = string_tag(String),
          Rval = ml_const(mlconst_string(String))
      ;
diff --git a/compiler/ml_tailcall.m b/compiler/ml_tailcall.m
index e9f0fbda2..bf68d4d77 100644
--- a/compiler/ml_tailcall.m
+++ b/compiler/ml_tailcall.m
@@ -900,6 +900,12 @@ check_const(Const, Locals) = MayYieldDanglingStackRef :-
          ; Const = mlconst_false
          ; Const = mlconst_int(_)
          ; Const = mlconst_uint(_)
+        ; Const = mlconst_int8(_)
+        ; Const = mlconst_uint8(_)
+        ; Const = mlconst_int16(_)
+        ; Const = mlconst_uint16(_)
+        ; Const = mlconst_int32(_)
+        ; Const = mlconst_uint32(_)
          ; Const = mlconst_enum(_, _)
          ; Const = mlconst_char(_)
          ; Const = mlconst_foreign(_, _, _)
diff --git a/compiler/ml_type_gen.m b/compiler/ml_type_gen.m
index bd376e551..94b95c396 100644
--- a/compiler/ml_type_gen.m
+++ b/compiler/ml_type_gen.m
@@ -354,6 +354,12 @@ ml_gen_hld_enum_constant(Context, TypeCtor, ConsTagValues, MLDS_Type, Ctor)
              mlconst_foreign(ForeignLang, ForeignTagValue, MLDS_Type))
      ;
          ( TagVal = uint_tag(_)
+        ; TagVal = int8_tag(_)
+        ; TagVal = uint8_tag(_)
+        ; TagVal = int16_tag(_)
+        ; TagVal = uint16_tag(_)
+        ; TagVal = int32_tag(_)
+        ; TagVal = uint32_tag(_)
          ; TagVal = string_tag(_)
          ; TagVal = float_tag(_)
          ; TagVal = closure_tag(_, _, _)
@@ -1198,6 +1204,12 @@ ml_tag_uses_base_class(Tag) = UsesBaseClass :-
          ; Tag = float_tag(_)
          ; Tag = int_tag(_)
          ; Tag = uint_tag(_)
+        ; Tag = int8_tag(_)
+        ; Tag = uint8_tag(_)
+        ; Tag = int16_tag(_)
+        ; Tag = uint16_tag(_)
+        ; Tag = int32_tag(_)
+        ; Tag = uint32_tag(_)
          ; Tag = foreign_tag(_, _)
          ; Tag = closure_tag(_, _, _)
          ; Tag = type_ctor_info_tag(_, _, _)
@@ -1265,6 +1277,12 @@ generate_foreign_enum_constant(TypeCtor, Mapping, TagValues, MLDS_Type, Ctor,
          ( TagVal = string_tag(_)
          ; TagVal = float_tag(_)
          ; TagVal = uint_tag(_)
+        ; TagVal = int8_tag(_)
+        ; TagVal = uint8_tag(_)
+        ; TagVal = int16_tag(_)
+        ; TagVal = uint16_tag(_)
+        ; TagVal = int32_tag(_)
+        ; TagVal = uint32_tag(_)
          ; TagVal = closure_tag(_, _, _)
          ; TagVal = type_ctor_info_tag(_, _, _)
          ; TagVal = base_typeclass_info_tag(_, _, _)
diff --git a/compiler/ml_unify_gen.m b/compiler/ml_unify_gen.m
index 2d25f8010..05355b371 100644
--- a/compiler/ml_unify_gen.m
+++ b/compiler/ml_unify_gen.m
@@ -405,6 +405,12 @@ ml_gen_construct_tag(Tag, Type, Var, ConsId, Args, ArgModes, TakeAddr,
          % Constants.
          ( Tag = int_tag(_)
          ; Tag = uint_tag(_)
+        ; Tag = int8_tag(_)
+        ; Tag = uint8_tag(_)
+        ; Tag = int16_tag(_)
+        ; Tag = uint16_tag(_)
+        ; Tag = int32_tag(_)
+        ; Tag = uint32_tag(_)
          ; Tag = foreign_tag(_, _)
          ; Tag = float_tag(_)
          ; Tag = string_tag(_)
@@ -458,6 +464,24 @@ ml_gen_constant(Tag, VarType, MLDS_VarType, Rval, !Info) :-
          Tag = uint_tag(UInt),
          Rval = ml_const(mlconst_uint(UInt))
      ;
+        Tag = int8_tag(Int8),
+        Rval = ml_const(mlconst_int8(Int8))
+    ;
+        Tag = uint8_tag(UInt8),
+        Rval = ml_const(mlconst_uint8(UInt8))
+    ;
+        Tag = int16_tag(Int16),
+        Rval = ml_const(mlconst_int16(Int16))
+    ;
+        Tag = uint16_tag(UInt16),
+        Rval = ml_const(mlconst_uint16(UInt16))
+    ;
+        Tag = int32_tag(Int32),
+        Rval = ml_const(mlconst_int32(Int32))
+    ;
+        Tag = uint32_tag(UInt32),
+        Rval = ml_const(mlconst_uint32(UInt32))
+    ;
          Tag = float_tag(Float),
          Rval = ml_const(mlconst_float(Float))
      ;
@@ -1489,6 +1513,12 @@ ml_gen_det_deconstruct_tag(Tag, Type, Var, ConsId, Args, Modes, Context,
          ( Tag = string_tag(_String)
          ; Tag = int_tag(_Int)
          ; Tag = uint_tag(_UInt)
+        ; Tag = int8_tag(_)
+        ; Tag = uint8_tag(_)
+        ; Tag = int16_tag(_)
+        ; Tag = uint16_tag(_)
+        ; Tag = int32_tag(_)
+        ; Tag = uint32_tag(_)
          ; Tag = foreign_tag(_, _)
          ; Tag = float_tag(_Float)
          ; Tag = shared_local_tag(_Bits1, _Num1)
@@ -1594,6 +1624,12 @@ ml_tag_offset_and_argnum(Tag, TagBits, Offset, ArgNum) :-
          ( Tag = string_tag(_String)
          ; Tag = int_tag(_Int)
          ; Tag = uint_tag(_)
+        ; Tag = int8_tag(_)
+        ; Tag = uint8_tag(_)
+        ; Tag = int16_tag(_)
+        ; Tag = uint16_tag(_)
+        ; Tag = int32_tag(_)
+        ; Tag = uint32_tag(_)
          ; Tag = foreign_tag(_, _)
          ; Tag = float_tag(_Float)
          ; Tag = closure_tag(_, _, _)
@@ -2222,6 +2258,24 @@ ml_gen_tag_test_rval(Tag, Type, ModuleInfo, Rval) = TagTestRval :-
          Tag = uint_tag(UInt),
          TagTestRval = ml_binop(uint_eq, Rval, ml_const(mlconst_uint(UInt)))
      ;
+        Tag = int8_tag(Int8),
+        TagTestRval = ml_binop(int8_eq, Rval, ml_const(mlconst_int8(Int8)))
+    ;
+        Tag = uint8_tag(UInt8),
+        TagTestRval = ml_binop(uint8_eq, Rval, ml_const(mlconst_uint8(UInt8)))
+    ;
+        Tag = int16_tag(Int16),
+        TagTestRval = ml_binop(int16_eq, Rval, ml_const(mlconst_int16(Int16)))
+    ;
+        Tag = uint16_tag(UInt16),
+        TagTestRval = ml_binop(uint16_eq, Rval, ml_const(mlconst_uint16(UInt16)))
+    ;
+        Tag = int32_tag(Int32),
+        TagTestRval = ml_binop(int32_eq, Rval, ml_const(mlconst_int32(Int32)))
+    ;
+        Tag = uint32_tag(UInt32),
+        TagTestRval = ml_binop(uint32_eq, Rval, ml_const(mlconst_uint32(UInt32)))
+    ;
          Tag = foreign_tag(ForeignLang, ForeignVal),
          MLDS_Type = mercury_type_to_mlds_type(ModuleInfo, Type),
          Const = ml_const(mlconst_foreign(ForeignLang, ForeignVal, MLDS_Type)),
@@ -2523,6 +2577,24 @@ ml_gen_ground_term_conjunct_tag(ModuleInfo, Target, HighLevelData, VarTypes,
              ConsTag = uint_tag(UInt),
              ConstRval = ml_const(mlconst_uint(UInt))
          ;
+            ConsTag = int8_tag(Int8),
+            ConstRval = ml_const(mlconst_int8(Int8))
+        ;
+            ConsTag = uint8_tag(UInt8),
+            ConstRval = ml_const(mlconst_uint8(UInt8))
+        ;
+            ConsTag = int16_tag(Int16),
+            ConstRval = ml_const(mlconst_int16(Int16))
+        ;
+            ConsTag = uint16_tag(UInt16),
+            ConstRval = ml_const(mlconst_uint16(UInt16))
+        ;
+            ConsTag = int32_tag(Int32),
+            ConstRval = ml_const(mlconst_int32(Int32))
+        ;
+            ConsTag = uint32_tag(UInt32),
+            ConstRval = ml_const(mlconst_uint32(UInt32))
+        ;
              ConsTag = float_tag(Float),
              ConstRval = ml_const(mlconst_float(Float))
          ;
@@ -2917,6 +2989,12 @@ ml_gen_const_struct_tag(Info, ConstNum, Type, MLDS_Type, ConsId, ConsTag,
          % These tags don't build heap cells.
          ( ConsTag = int_tag(_)
          ; ConsTag = uint_tag(_)
+        ; ConsTag = int8_tag(_)
+        ; ConsTag = uint8_tag(_)
+        ; ConsTag = int16_tag(_)
+        ; ConsTag = uint16_tag(_)
+        ; ConsTag = int32_tag(_)
+        ; ConsTag = uint32_tag(_)
          ; ConsTag = float_tag(_)
          ; ConsTag = string_tag(_)
          ; ConsTag = reserved_address_tag(_)
@@ -3097,6 +3175,24 @@ ml_gen_const_struct_arg_tag(ModuleInfo, ConsId, ConsTag, Type, MLDS_Type,
          ConsTag = uint_tag(UInt),
          Rval = ml_const(mlconst_uint(UInt))
      ;
+        ConsTag = int8_tag(Int8),
+        Rval = ml_const(mlconst_int8(Int8))
+    ;
+        ConsTag = uint8_tag(UInt8),
+        Rval = ml_const(mlconst_uint8(UInt8))
+    ;
+        ConsTag = int16_tag(Int16),
+        Rval = ml_const(mlconst_int16(Int16))
+    ;
+        ConsTag = uint16_tag(UInt16),
+        Rval = ml_const(mlconst_uint16(UInt16))
+    ;
+        ConsTag = int32_tag(Int32),
+        Rval = ml_const(mlconst_int32(Int32))
+    ;
+        ConsTag = uint32_tag(UInt32),
+        Rval = ml_const(mlconst_uint32(UInt32))
+    ;
          ConsTag = float_tag(Float),
          Rval = ml_const(mlconst_float(Float))
      ;
diff --git a/compiler/ml_util.m b/compiler/ml_util.m
index 6068c08a6..64aba7cdd 100644
--- a/compiler/ml_util.m
+++ b/compiler/ml_util.m
@@ -923,6 +923,12 @@ rval_contains_var(Rval, DataName) = ContainsVar :-
              ; Const = mlconst_false
              ; Const = mlconst_int(_)
              ; Const = mlconst_uint(_)
+            ; Const = mlconst_int8(_)
+            ; Const = mlconst_uint8(_)
+            ; Const = mlconst_int16(_)
+            ; Const = mlconst_uint16(_)
+            ; Const = mlconst_int32(_)
+            ; Const = mlconst_uint32(_)
              ; Const = mlconst_enum(_, _)
              ; Const = mlconst_char(_)
              ; Const = mlconst_float(_)
@@ -1246,6 +1252,12 @@ method_ptrs_in_rval(Rval, !CodeAddrsInConsts) :-
              ; RvalConst = mlconst_false
              ; RvalConst = mlconst_int(_)
              ; RvalConst = mlconst_uint(_)
+            ; RvalConst = mlconst_int8(_)
+            ; RvalConst = mlconst_uint8(_)
+            ; RvalConst = mlconst_int16(_)
+            ; RvalConst = mlconst_uint16(_)
+            ; RvalConst = mlconst_int32(_)
+            ; RvalConst = mlconst_uint32(_)
              ; RvalConst = mlconst_char(_)
              ; RvalConst = mlconst_enum(_, _)
              ; RvalConst = mlconst_foreign(_, _, _)
diff --git a/compiler/mlds.m b/compiler/mlds.m
index 125e50989..56e6ba217 100644
--- a/compiler/mlds.m
+++ b/compiler/mlds.m
@@ -2093,6 +2093,12 @@
      ;       mlconst_false
      ;       mlconst_int(int)
      ;       mlconst_uint(uint)
+    ;       mlconst_int8(int)
+    ;       mlconst_uint8(int)
+    ;       mlconst_int16(int)
+    ;       mlconst_uint16(int)
+    ;       mlconst_int32(int)
+    ;       mlconst_uint32(int)
      ;       mlconst_enum(int, mlds_type)
      ;       mlconst_char(int)
      ;       mlconst_float(float)
diff --git a/compiler/mlds_to_c.m b/compiler/mlds_to_c.m
index e467be68c..45f8d4a9e 100644
--- a/compiler/mlds_to_c.m
+++ b/compiler/mlds_to_c.m
@@ -2956,6 +2956,24 @@ mlds_output_mercury_type_prefix(Opts, Type, CtorCat, !IO) :-
          CtorCat = ctor_cat_builtin(cat_builtin_uint),
          io.write_string("MR_Unsigned", !IO)
      ;
+        CtorCat = ctor_cat_builtin(cat_builtin_int8),
+        io.write_string("int8_t", !IO)
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_uint8),
+        io.write_string("uint8_t", !IO)
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_int16),
+        io.write_string("int16_t", !IO)
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_uint16),
+        io.write_string("uint16_t", !IO)
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_int32),
+        io.write_string("int32_t", !IO)
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_uint32),
+        io.write_string("uint32_t", !IO)
+    ;
          CtorCat = ctor_cat_builtin(cat_builtin_string),
          io.write_string("MR_String", !IO)
      ;
@@ -4739,6 +4757,156 @@ mlds_output_binop(Opts, Op, X, Y, !IO) :-
          mlds_output_rval_as_op_arg(Opts, Y, !IO),
          io.write_string(")", !IO)
      ;
+        ( Op = int8_eq, OpStr = "=="
+        ; Op = int8_ne, OpStr = "!="
+        ; Op = int8_lt, OpStr = "<"
+        ; Op = int8_gt, OpStr = ">"
+        ; Op = int8_le, OpStr = "<="
+        ; Op = int8_ge, OpStr = ">="
+        ; Op = int8_add, OpStr = "+"
+        ; Op = int8_sub, OpStr = "-"
+        ; Op = int8_mul, OpStr = "*"
+        ; Op = int8_div, OpStr = "/"
+        ; Op = int8_mod, OpStr = "%"
+        ; Op = int8_bitwise_and, OpStr = "&"
+        ; Op = int8_bitwise_or, OpStr = "|"
+        ; Op = int8_bitwise_xor, OpStr = "^"
+        ; Op = int8_unchecked_left_shift, OpStr = "<<"
+        ; Op = int8_unchecked_right_shift, OpStr = ">>"
+        ),
+        io.write_string("(", !IO),
+        mlds_output_rval_as_op_arg(Opts, X, !IO),
+        io.write_string(" ", !IO),
+        io.write_string(OpStr, !IO),
+        io.write_string(" ", !IO),
+        mlds_output_rval_as_op_arg(Opts, Y, !IO),
+        io.write_string(")", !IO)
+    ;
+        ( Op = uint8_eq, OpStr = "=="
+        ; Op = uint8_ne, OpStr = "!="
+        ; Op = uint8_lt, OpStr = "<"
+        ; Op = uint8_gt, OpStr = ">"
+        ; Op = uint8_le, OpStr = "<="
+        ; Op = uint8_ge, OpStr = ">="
+        ; Op = uint8_add, OpStr = "+"
+        ; Op = uint8_sub, OpStr = "-"
+        ; Op = uint8_mul, OpStr = "*"
+        ; Op = uint8_div, OpStr = "/"
+        ; Op = uint8_mod, OpStr = "%"
+        ; Op = uint8_bitwise_and, OpStr = "&"
+        ; Op = uint8_bitwise_or, OpStr = "|"
+        ; Op = uint8_bitwise_xor, OpStr = "^"
+        ; Op = uint8_unchecked_left_shift, OpStr = "<<"
+        ; Op = uint8_unchecked_right_shift, OpStr = ">>"
+        ),
+        io.write_string("(", !IO),
+        mlds_output_rval_as_op_arg(Opts, X, !IO),
+        io.write_string(" ", !IO),
+        io.write_string(OpStr, !IO),
+        io.write_string(" ", !IO),
+        mlds_output_rval_as_op_arg(Opts, Y, !IO),
+        io.write_string(")", !IO)
+    ;
+        ( Op = int16_eq, OpStr = "=="
+        ; Op = int16_ne, OpStr = "!="
+        ; Op = int16_lt, OpStr = "<"
+        ; Op = int16_gt, OpStr = ">"
+        ; Op = int16_le, OpStr = "<="
+        ; Op = int16_ge, OpStr = ">="
+        ; Op = int16_add, OpStr = "+"
+        ; Op = int16_sub, OpStr = "-"
+        ; Op = int16_mul, OpStr = "*"
+        ; Op = int16_div, OpStr = "/"
+        ; Op = int16_mod, OpStr = "%"
+        ; Op = int16_bitwise_and, OpStr = "&"
+        ; Op = int16_bitwise_or, OpStr = "|"
+        ; Op = int16_bitwise_xor, OpStr = "^"
+        ; Op = int16_unchecked_left_shift, OpStr = "<<"
+        ; Op = int16_unchecked_right_shift, OpStr = ">>"
+        ),
+        io.write_string("(", !IO),
+        mlds_output_rval_as_op_arg(Opts, X, !IO),
+        io.write_string(" ", !IO),
+        io.write_string(OpStr, !IO),
+        io.write_string(" ", !IO),
+        mlds_output_rval_as_op_arg(Opts, Y, !IO),
+        io.write_string(")", !IO)
+    ;
+        ( Op = uint16_eq, OpStr = "=="
+        ; Op = uint16_ne, OpStr = "!="
+        ; Op = uint16_lt, OpStr = "<"
+        ; Op = uint16_gt, OpStr = ">"
+        ; Op = uint16_le, OpStr = "<="
+        ; Op = uint16_ge, OpStr = ">="
+        ; Op = uint16_add, OpStr = "+"
+        ; Op = uint16_sub, OpStr = "-"
+        ; Op = uint16_mul, OpStr = "*"
+        ; Op = uint16_div, OpStr = "/"
+        ; Op = uint16_mod, OpStr = "%"
+        ; Op = uint16_bitwise_and, OpStr = "&"
+        ; Op = uint16_bitwise_or, OpStr = "|"
+        ; Op = uint16_bitwise_xor, OpStr = "^"
+        ; Op = uint16_unchecked_left_shift, OpStr = "<<"
+        ; Op = uint16_unchecked_right_shift, OpStr = ">>"
+        ),
+        io.write_string("(", !IO),
+        mlds_output_rval_as_op_arg(Opts, X, !IO),
+        io.write_string(" ", !IO),
+        io.write_string(OpStr, !IO),
+        io.write_string(" ", !IO),
+        mlds_output_rval_as_op_arg(Opts, Y, !IO),
+        io.write_string(")", !IO)
+    ;
+        ( Op = int32_eq, OpStr = "=="
+        ; Op = int32_ne, OpStr = "!="
+        ; Op = int32_lt, OpStr = "<"
+        ; Op = int32_gt, OpStr = ">"
+        ; Op = int32_le, OpStr = "<="
+        ; Op = int32_ge, OpStr = ">="
+        ; Op = int32_add, OpStr = "+"
+        ; Op = int32_sub, OpStr = "-"
+        ; Op = int32_mul, OpStr = "*"
+        ; Op = int32_div, OpStr = "/"
+        ; Op = int32_mod, OpStr = "%"
+        ; Op = int32_bitwise_and, OpStr = "&"
+        ; Op = int32_bitwise_or, OpStr = "|"
+        ; Op = int32_bitwise_xor, OpStr = "^"
+        ; Op = int32_unchecked_left_shift, OpStr = "<<"
+        ; Op = int32_unchecked_right_shift, OpStr = ">>"
+        ),
+        io.write_string("(", !IO),
+        mlds_output_rval_as_op_arg(Opts, X, !IO),
+        io.write_string(" ", !IO),
+        io.write_string(OpStr, !IO),
+        io.write_string(" ", !IO),
+        mlds_output_rval_as_op_arg(Opts, Y, !IO),
+        io.write_string(")", !IO)
+    ;
+        ( Op = uint32_eq, OpStr = "=="
+        ; Op = uint32_ne, OpStr = "!="
+        ; Op = uint32_lt, OpStr = "<"
+        ; Op = uint32_gt, OpStr = ">"
+        ; Op = uint32_le, OpStr = "<="
+        ; Op = uint32_ge, OpStr = ">="
+        ; Op = uint32_add, OpStr = "+"
+        ; Op = uint32_sub, OpStr = "-"
+        ; Op = uint32_mul, OpStr = "*"
+        ; Op = uint32_div, OpStr = "/"
+        ; Op = uint32_mod, OpStr = "%"
+        ; Op = uint32_bitwise_and, OpStr = "&"
+        ; Op = uint32_bitwise_or, OpStr = "|"
+        ; Op = uint32_bitwise_xor, OpStr = "^"
+        ; Op = uint32_unchecked_left_shift, OpStr = "<<"
+        ; Op = uint32_unchecked_right_shift, OpStr = ">>"
+        ),
+        io.write_string("(", !IO),
+        mlds_output_rval_as_op_arg(Opts, X, !IO),
+        io.write_string(" ", !IO),
+        io.write_string(OpStr, !IO),
+        io.write_string(" ", !IO),
+        mlds_output_rval_as_op_arg(Opts, Y, !IO),
+        io.write_string(")", !IO)
+    ;
          Op = str_cmp,
          io.write_string("MR_strcmp(", !IO),
          mlds_output_rval_as_op_arg(Opts, X, !IO),
@@ -4803,6 +4971,24 @@ mlds_output_rval_const(_Opts, Const, !IO) :-
          Const = mlconst_uint(U),
          c_util.output_uint_expr_cur_stream(U, !IO)
      ;
+        Const = mlconst_int8(N),
+        c_util.output_int_expr_cur_stream(N, !IO)
+    ;
+        Const = mlconst_uint8(N),
+        c_util.output_int_expr_cur_stream(N, !IO)
+    ;
+        Const = mlconst_int16(N),
+        c_util.output_int_expr_cur_stream(N, !IO)
+    ;
+        Const = mlconst_uint16(N),
+        c_util.output_int_expr_cur_stream(N, !IO)
+    ;
+        Const = mlconst_int32(N),
+        c_util.output_int_expr_cur_stream(N, !IO)
+    ;
+        Const = mlconst_uint32(N),
+        c_util.output_int_expr_cur_stream(N, !IO)
+    ;
          Const = mlconst_char(C),
          io.write_string("(MR_Char) ", !IO),
          io.write_int(C, !IO)
diff --git a/compiler/mlds_to_cs.m b/compiler/mlds_to_cs.m
index a17b48459..8b4754591 100644
--- a/compiler/mlds_to_cs.m
+++ b/compiler/mlds_to_cs.m
@@ -1068,11 +1068,19 @@ get_type_initializer(Info, Type) = Initializer :-
          Type = mercury_type(_, CtorCat, _),
          (
              ( CtorCat = ctor_cat_builtin(cat_builtin_int)
+            ; CtorCat = ctor_cat_builtin(cat_builtin_int8)
+            ; CtorCat = ctor_cat_builtin(cat_builtin_int16)
+            ; CtorCat = ctor_cat_builtin(cat_builtin_int32)
+            % C# byte and ushort literals don't have a suffix.
+            ; CtorCat = ctor_cat_builtin(cat_builtin_uint8)
+            ; CtorCat = ctor_cat_builtin(cat_builtin_uint16)
              ; CtorCat = ctor_cat_builtin(cat_builtin_float)
              ),
              Initializer = "0"
          ;
-            CtorCat = ctor_cat_builtin(cat_builtin_uint),
+            ( CtorCat = ctor_cat_builtin(cat_builtin_uint)
+            ; CtorCat = ctor_cat_builtin(cat_builtin_uint32)
+            ),
              Initializer = "0U"
          ;
              CtorCat = ctor_cat_builtin(cat_builtin_char),
@@ -1936,6 +1944,30 @@ mercury_type_to_string_for_csharp(Info, Type, CtorCat, String, ArrayDims) :-
          String = "uint",
          ArrayDims = []
      ;
+        CtorCat = ctor_cat_builtin(cat_builtin_int8),
+        String = "sbyte",
+        ArrayDims = []
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_uint8),
+        String = "byte",
+        ArrayDims = []
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_int16),
+        String = "short",
+        ArrayDims = []
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_uint16),
+        String = "ushort",
+        ArrayDims = []
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_int32),
+        String = "int",
+        ArrayDims = []
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_uint32),
+        String = "uint",
+        ArrayDims = []
+    ;
          CtorCat = ctor_cat_builtin(cat_builtin_string),
          String = "string",
          ArrayDims = []
@@ -2207,7 +2239,7 @@ output_per_instance_for_csharp(PerInstance, !IO) :-
      ).

  % :- pred output_virtuality_for_csharp(virtuality::in, io::di, io::uo) is det.
-% 
+%
  % output_virtuality_for_csharp(Virtual, !IO) :-
  %     (
  %         Virtual = virtual,
@@ -2240,7 +2272,7 @@ output_constness_for_csharp(Constness, !IO) :-

  % :- pred output_abstractness_for_csharp(abstractness::in,
  %     io::di, io::uo) is det.
-% 
+%
  % output_abstractness_for_csharp(Abstractness, !IO) :-
  %     (
  %         Abstractness = abstract,
@@ -3208,6 +3240,24 @@ csharp_builtin_type(Type, TargetType) :-
                  BuiltinType = builtin_type_uint,
                  TargetType = "uint"
              ;
+                BuiltinType = builtin_type_int8,
+                TargetType = "sbyte"
+            ;
+                BuiltinType = builtin_type_uint8,
+                TargetType = "byte"
+            ;
+                BuiltinType = builtin_type_int16,
+                TargetType = "short"
+            ;
+                BuiltinType = builtin_type_uint16,
+                TargetType = "ushort"
+            ;
+                BuiltinType = builtin_type_int32,
+                TargetType = "int"
+            ;
+                BuiltinType = builtin_type_uint32,
+                TargetType = "uint"
+            ;
                  BuiltinType = builtin_type_float,
                  TargetType = "double"
              ;
@@ -3291,7 +3341,32 @@ output_std_unop_for_csharp(Info, UnaryOp, Expr, !IO) :-
          ; UnaryOp = hash_string5, UnaryOpStr = "mercury.String.hash5_1_f_0"
          ; UnaryOp = hash_string6, UnaryOpStr = "mercury.String.hash6_1_f_0"
          ; UnaryOp = uint_bitwise_complement, UnaryOpStr = "~"
+        ; UnaryOp = int32_bitwise_complement, UnaryOpStr = "~"
+        ; UnaryOp = uint32_bitwise_complement, UnaryOpStr = "~"
+        ),
+        io.write_string(UnaryOpStr, !IO),
+        io.write_string("(", !IO),
+        output_rval_for_csharp(Info, Expr, !IO),
+        io.write_string(")", !IO)
+    ;
+        (
+            UnaryOp = int8_bitwise_complement,
+            UnaryOpStr = "~",
+            CastStr = "(sbyte)"
+        ;
+            UnaryOp = uint8_bitwise_complement,
+            UnaryOpStr = "~",
+            CastStr = "(byte)"
+        ;
+            UnaryOp = int16_bitwise_complement,
+            UnaryOpStr = "~",
+            CastStr = "(short)"
+        ;
+            UnaryOp = uint16_bitwise_complement,
+            UnaryOpStr = "~",
+            CastStr = "(ushort)"
          ),
+        io.write_string(CastStr, !IO),
          io.write_string(UnaryOpStr, !IO),
          io.write_string("(", !IO),
          output_rval_for_csharp(Info, Expr, !IO),
@@ -3382,6 +3457,38 @@ output_binop_for_csharp(Info, Op, X, Y, !IO) :-
          ; Op = uint_bitwise_xor
          ; Op = uint_unchecked_left_shift
          ; Op = uint_unchecked_right_shift
+        ; Op = int32_eq
+        ; Op = int32_ne
+        ; Op = int32_lt
+        ; Op = int32_gt
+        ; Op = int32_le
+        ; Op = int32_ge
+        ; Op = int32_add
+        ; Op = int32_sub
+        ; Op = int32_mul
+        ; Op = int32_div
+        ; Op = int32_mod
+        ; Op = int32_bitwise_and
+        ; Op = int32_bitwise_or
+        ; Op = int32_bitwise_xor
+        ; Op = int32_unchecked_left_shift
+        ; Op = int32_unchecked_right_shift
+        ; Op = uint32_eq
+        ; Op = uint32_ne
+        ; Op = uint32_lt
+        ; Op = uint32_gt
+        ; Op = uint32_le
+        ; Op = uint32_ge
+        ; Op = uint32_add
+        ; Op = uint32_sub
+        ; Op = uint32_mul
+        ; Op = uint32_div
+        ; Op = uint32_mod
+        ; Op = uint32_bitwise_and
+        ; Op = uint32_bitwise_or
+        ; Op = uint32_bitwise_xor
+        ; Op = uint32_unchecked_left_shift
+        ; Op = uint32_unchecked_right_shift
          ; Op = float_plus
          ; Op = float_minus
          ; Op = float_times
@@ -3404,6 +3511,106 @@ output_binop_for_csharp(Info, Op, X, Y, !IO) :-
          io.write_string(" ", !IO),
          output_rval_for_csharp(Info, Y, !IO),
          io.write_string(")", !IO)
+    ;
+        ( Op = int8_eq
+        ; Op = int8_ne
+        ; Op = int8_lt
+        ; Op = int8_gt
+        ; Op = int8_le
+        ; Op = int8_ge
+        ; Op = int8_add
+        ; Op = int8_sub
+        ; Op = int8_mul
+        ; Op = int8_div
+        ; Op = int8_mod
+        ; Op = int8_bitwise_and
+        ; Op = int8_bitwise_or
+        ; Op = int8_bitwise_xor
+        ; Op = int8_unchecked_left_shift
+        ; Op = int8_unchecked_right_shift
+        ),
+        io.write_string("(sbyte)(", !IO),
+        output_rval_for_csharp(Info, X, !IO),
+        io.write_string(" ", !IO),
+        output_binary_op_for_csharp(Op, !IO),
+        io.write_string(" ", !IO),
+        output_rval_for_csharp(Info, Y, !IO),
+        io.write_string(")", !IO)
+    ;
+        ( Op = uint8_eq
+        ; Op = uint8_ne
+        ; Op = uint8_lt
+        ; Op = uint8_gt
+        ; Op = uint8_le
+        ; Op = uint8_ge
+        ; Op = uint8_add
+        ; Op = uint8_sub
+        ; Op = uint8_mul
+        ; Op = uint8_div
+        ; Op = uint8_mod
+        ; Op = uint8_bitwise_and
+        ; Op = uint8_bitwise_or
+        ; Op = uint8_bitwise_xor
+        ; Op = uint8_unchecked_left_shift
+        ; Op = uint8_unchecked_right_shift
+        ),
+        io.write_string("(byte)(", !IO),
+        output_rval_for_csharp(Info, X, !IO),
+        io.write_string(" ", !IO),
+        output_binary_op_for_csharp(Op, !IO),
+        io.write_string(" ", !IO),
+        output_rval_for_csharp(Info, Y, !IO),
+        io.write_string(")", !IO)
+    ;
+        ( Op = int16_eq
+        ; Op = int16_ne
+        ; Op = int16_lt
+        ; Op = int16_gt
+        ; Op = int16_le
+        ; Op = int16_ge
+        ; Op = int16_add
+        ; Op = int16_sub
+        ; Op = int16_mul
+        ; Op = int16_div
+        ; Op = int16_mod
+        ; Op = int16_bitwise_and
+        ; Op = int16_bitwise_or
+        ; Op = int16_bitwise_xor
+        ; Op = int16_unchecked_left_shift
+        ; Op = int16_unchecked_right_shift
+        ),
+        io.write_string("(short)(", !IO),
+        output_rval_for_csharp(Info, X, !IO),
+        io.write_string(" ", !IO),
+        output_binary_op_for_csharp(Op, !IO),
+        io.write_string(" ", !IO),
+        output_rval_for_csharp(Info, Y, !IO),
+        io.write_string(")", !IO)
+    ;
+        ( Op = uint16_eq
+        ; Op = uint16_ne
+        ; Op = uint16_lt
+        ; Op = uint16_gt
+        ; Op = uint16_le
+        ; Op = uint16_ge
+        ; Op = uint16_add
+        ; Op = uint16_sub
+        ; Op = uint16_mul
+        ; Op = uint16_div
+        ; Op = uint16_mod
+        ; Op = uint16_bitwise_and
+        ; Op = uint16_bitwise_or
+        ; Op = uint16_bitwise_xor
+        ; Op = uint16_unchecked_left_shift
+        ; Op = uint16_unchecked_right_shift
+        ),
+        io.write_string("(ushort)(", !IO),
+        output_rval_for_csharp(Info, X, !IO),
+        io.write_string(" ", !IO),
+        output_binary_op_for_csharp(Op, !IO),
+        io.write_string(" ", !IO),
+        output_rval_for_csharp(Info, Y, !IO),
+        io.write_string(")", !IO)
      ).

  :- pred output_binary_op_for_csharp(binary_op::in, io::di, io::uo) is det.
@@ -3447,6 +3654,114 @@ output_binary_op_for_csharp(Op, !IO) :-
          ; Op = uint_unchecked_left_shift, OpStr = "<<"
          ; Op = uint_unchecked_right_shift, OpStr = ">>"

+        ; Op = int8_eq, OpStr = "=="
+        ; Op = int8_ne, OpStr = "!="
+        ; Op = int8_lt, OpStr = "<"
+        ; Op = int8_gt, OpStr = ">"
+        ; Op = int8_le, OpStr = "<="
+        ; Op = int8_ge, OpStr = ">="
+
+        ; Op = int8_add, OpStr = "+"
+        ; Op = int8_sub, OpStr = "-"
+        ; Op = int8_mul, OpStr = "*"
+        ; Op = int8_div, OpStr = "/"
+        ; Op = int8_mod, OpStr = "%"
+        ; Op = int8_bitwise_and, OpStr = "&"
+        ; Op = int8_bitwise_or, OpStr = "|"
+        ; Op = int8_bitwise_xor, OpStr = "^"
+        ; Op = int8_unchecked_left_shift, OpStr = "<<"
+        ; Op = int8_unchecked_right_shift, OpStr = ">>"
+
+        ; Op = uint8_eq, OpStr = "=="
+        ; Op = uint8_ne, OpStr = "!="
+        ; Op = uint8_lt, OpStr = "<"
+        ; Op = uint8_gt, OpStr = ">"
+        ; Op = uint8_le, OpStr = "<="
+        ; Op = uint8_ge, OpStr = ">="
+
+        ; Op = uint8_add, OpStr = "+"
+        ; Op = uint8_sub, OpStr = "-"
+        ; Op = uint8_mul, OpStr = "*"
+        ; Op = uint8_div, OpStr = "/"
+        ; Op = uint8_mod, OpStr = "%"
+        ; Op = uint8_bitwise_and, OpStr = "&"
+        ; Op = uint8_bitwise_or, OpStr = "|"
+        ; Op = uint8_bitwise_xor, OpStr = "^"
+        ; Op = uint8_unchecked_left_shift, OpStr = "<<"
+        ; Op = uint8_unchecked_right_shift, OpStr = ">>"
+
+        ; Op = int16_eq, OpStr = "=="
+        ; Op = int16_ne, OpStr = "!="
+        ; Op = int16_lt, OpStr = "<"
+        ; Op = int16_gt, OpStr = ">"
+        ; Op = int16_le, OpStr = "<="
+        ; Op = int16_ge, OpStr = ">="
+
+        ; Op = int16_add, OpStr = "+"
+        ; Op = int16_sub, OpStr = "-"
+        ; Op = int16_mul, OpStr = "*"
+        ; Op = int16_div, OpStr = "/"
+        ; Op = int16_mod, OpStr = "%"
+        ; Op = int16_bitwise_and, OpStr = "&"
+        ; Op = int16_bitwise_or, OpStr = "|"
+        ; Op = int16_bitwise_xor, OpStr = "^"
+        ; Op = int16_unchecked_left_shift, OpStr = "<<"
+        ; Op = int16_unchecked_right_shift, OpStr = ">>"
+
+        ; Op = uint16_eq, OpStr = "=="
+        ; Op = uint16_ne, OpStr = "!="
+        ; Op = uint16_lt, OpStr = "<"
+        ; Op = uint16_gt, OpStr = ">"
+        ; Op = uint16_le, OpStr = "<="
+        ; Op = uint16_ge, OpStr = ">="
+
+        ; Op = uint16_add, OpStr = "+"
+        ; Op = uint16_sub, OpStr = "-"
+        ; Op = uint16_mul, OpStr = "*"
+        ; Op = uint16_div, OpStr = "/"
+        ; Op = uint16_mod, OpStr = "%"
+        ; Op = uint16_bitwise_and, OpStr = "&"
+        ; Op = uint16_bitwise_or, OpStr = "|"
+        ; Op = uint16_bitwise_xor, OpStr = "^"
+        ; Op = uint16_unchecked_left_shift, OpStr = "<<"
+        ; Op = uint16_unchecked_right_shift, OpStr = ">>"
+
+        ; Op = int32_eq, OpStr = "=="
+        ; Op = int32_ne, OpStr = "!="
+        ; Op = int32_lt, OpStr = "<"
+        ; Op = int32_gt, OpStr = ">"
+        ; Op = int32_le, OpStr = "<="
+        ; Op = int32_ge, OpStr = ">="
+
+        ; Op = int32_add, OpStr = "+"
+        ; Op = int32_sub, OpStr = "-"
+        ; Op = int32_mul, OpStr = "*"
+        ; Op = int32_div, OpStr = "/"
+        ; Op = int32_mod, OpStr = "%"
+        ; Op = int32_bitwise_and, OpStr = "&"
+        ; Op = int32_bitwise_or, OpStr = "|"
+        ; Op = int32_bitwise_xor, OpStr = "^"
+        ; Op = int32_unchecked_left_shift, OpStr = "<<"
+        ; Op = int32_unchecked_right_shift, OpStr = ">>"
+
+        ; Op = uint32_eq, OpStr = "=="
+        ; Op = uint32_ne, OpStr = "!="
+        ; Op = uint32_lt, OpStr = "<"
+        ; Op = uint32_gt, OpStr = ">"
+        ; Op = uint32_le, OpStr = "<="
+        ; Op = uint32_ge, OpStr = ">="
+
+        ; Op = uint32_add, OpStr = "+"
+        ; Op = uint32_sub, OpStr = "-"
+        ; Op = uint32_mul, OpStr = "*"
+        ; Op = uint32_div, OpStr = "/"
+        ; Op = uint32_mod, OpStr = "%"
+        ; Op = uint32_bitwise_and, OpStr = "&"
+        ; Op = uint32_bitwise_or, OpStr = "|"
+        ; Op = uint32_bitwise_xor, OpStr = "^"
+        ; Op = uint32_unchecked_left_shift, OpStr = "<<"
+        ; Op = uint32_unchecked_right_shift, OpStr = ">>"
+
          ; Op = float_eq, OpStr = "=="
          ; Op = float_ne, OpStr = "!="
          ; Op = float_le, OpStr = "<="
@@ -3499,6 +3814,24 @@ output_rval_const_for_csharp(Info, Const, !IO) :-
          Const = mlconst_uint(U),
          output_uint_const_for_csharp(U, !IO)
      ;
+        Const = mlconst_int8(N),
+        output_int_const_for_csharp(N, !IO)
+    ;
+        Const = mlconst_uint8(N),
+        output_int_const_for_csharp(N, !IO)
+    ;
+        Const = mlconst_int16(N),
+        output_int_const_for_csharp(N, !IO)
+    ;
+        Const = mlconst_uint16(N),
+        output_int_const_for_csharp(N, !IO)
+    ;
+        Const = mlconst_int32(N),
+        output_int_const_for_csharp(N, !IO)
+    ;
+        Const = mlconst_uint32(N),
+        output_int_const_for_csharp(N, !IO)
+    ;
          Const = mlconst_char(N),
          io.write_string("( ", !IO),
          output_int_const_for_csharp(N, !IO),
diff --git a/compiler/mlds_to_java.m b/compiler/mlds_to_java.m
index cf2c875d3..277921f9c 100644
--- a/compiler/mlds_to_java.m
+++ b/compiler/mlds_to_java.m
@@ -1551,6 +1551,12 @@ rename_class_names_rval_const(Renaming, !Const) :-
          ; !.Const = mlconst_false
          ; !.Const = mlconst_int(_)
          ; !.Const = mlconst_uint(_)
+        ; !.Const = mlconst_int8(_)
+        ; !.Const = mlconst_uint8(_)
+        ; !.Const = mlconst_int16(_)
+        ; !.Const = mlconst_uint16(_)
+        ; !.Const = mlconst_int32(_)
+        ; !.Const = mlconst_uint32(_)
          ; !.Const = mlconst_char(_)
          ; !.Const = mlconst_enum(_, _)
          ; !.Const = mlconst_float(_)
@@ -2300,6 +2306,12 @@ get_java_type_initializer(Type) = Initializer :-
          (
              ( CtorCat = ctor_cat_builtin(cat_builtin_int)
              ; CtorCat = ctor_cat_builtin(cat_builtin_uint)
+            ; CtorCat = ctor_cat_builtin(cat_builtin_int8)
+            ; CtorCat = ctor_cat_builtin(cat_builtin_uint8)
+            ; CtorCat = ctor_cat_builtin(cat_builtin_int16)
+            ; CtorCat = ctor_cat_builtin(cat_builtin_uint16)
+            ; CtorCat = ctor_cat_builtin(cat_builtin_int32)
+            ; CtorCat = ctor_cat_builtin(cat_builtin_uint32)
              ; CtorCat = ctor_cat_builtin(cat_builtin_float)
              ),
              Initializer = "0"
@@ -3091,6 +3103,24 @@ mercury_type_to_string_for_java(Info, Type, CtorCat, String, ArrayDims) :-
          String = "int",     % Java has no unsigned types.
          ArrayDims = []
      ;
+        ( CtorCat = ctor_cat_builtin(cat_builtin_int8)
+        ; CtorCat = ctor_cat_builtin(cat_builtin_uint8)
+        ),
+        String = "byte",
+        ArrayDims = []
+    ;
+        ( CtorCat = ctor_cat_builtin(cat_builtin_int16)
+        ; CtorCat = ctor_cat_builtin(cat_builtin_uint16)
+        ),
+        String = "short",
+        ArrayDims = []
+    ;
+        ( CtorCat = ctor_cat_builtin(cat_builtin_int32)
+        ; CtorCat = ctor_cat_builtin(cat_builtin_uint32)
+        ),
+        String = "int",
+        ArrayDims = []
+    ;
          CtorCat = ctor_cat_builtin(cat_builtin_string),
          String = "java.lang.String",
          ArrayDims = []
@@ -4450,11 +4480,27 @@ java_builtin_type(MLDS_Type, JavaUnboxedType, JavaBoxedType, UnboxMethod) :-
                  ( BuiltinType = builtin_type_char
                  ; BuiltinType = builtin_type_int
                  ; BuiltinType = builtin_type_uint
+                ; BuiltinType = builtin_type_int32
+                ; BuiltinType = builtin_type_uint32
                  ),
                  JavaUnboxedType = "int",
                  JavaBoxedType = "java.lang.Integer",
                  UnboxMethod = "intValue"
              ;
+                ( BuiltinType = builtin_type_int8
+                ; BuiltinType = builtin_type_uint8
+                ),
+                JavaUnboxedType = "byte",
+                JavaBoxedType = "java.lang.Byte",
+                UnboxMethod = "byteValue"
+            ;
+                ( BuiltinType = builtin_type_int16
+                ; BuiltinType = builtin_type_uint16
+                ),
+                JavaUnboxedType = "short",
+                JavaBoxedType = "java.lang.Short",
+                UnboxMethod = "shortValue"
+            ;
                  BuiltinType = builtin_type_float,
                  JavaUnboxedType = "double",
                  JavaBoxedType = "java.lang.Double",
@@ -4610,11 +4656,31 @@ output_std_unop_for_java(Info, UnaryOp, Expr, !IO) :-
          ; UnaryOp = hash_string5, UnaryOpStr = "mercury.String.hash5_1_f_0"
          ; UnaryOp = hash_string6, UnaryOpStr = "mercury.String.hash6_1_f_0"
          ; UnaryOp = uint_bitwise_complement, UnaryOpStr = "~"
+        ; UnaryOp = int32_bitwise_complement, UnaryOpStr = "~"
+        ; UnaryOp = uint32_bitwise_complement, UnaryOpStr = "~"
          ),
          io.write_string(UnaryOpStr, !IO),
          io.write_string("(", !IO),
          output_rval_for_java(Info, Expr, !IO),
          io.write_string(")", !IO)
+    ;
+        ( UnaryOp = int8_bitwise_complement, UnaryOpStr = "~"
+        ; UnaryOp = uint8_bitwise_complement, UnaryOpStr = "~"
+        ),
+        io.write_string("(byte)(", !IO),
+        io.write_string(UnaryOpStr, !IO),
+        io.write_string("(", !IO),
+        output_rval_for_java(Info, Expr, !IO),
+        io.write_string("))", !IO)
+    ;
+        ( UnaryOp = int16_bitwise_complement, UnaryOpStr = "~"
+        ; UnaryOp = uint16_bitwise_complement, UnaryOpStr = "~"
+        ),
+        io.write_string("(short)(", !IO),
+        io.write_string(UnaryOpStr, !IO),
+        io.write_string("(", !IO),
+        output_rval_for_java(Info, Expr, !IO),
+        io.write_string("))", !IO)
      ).

  :- pred output_binop_for_java(java_out_info::in, binary_op::in, mlds_rval::in,
@@ -4673,6 +4739,22 @@ output_binop_for_java(Info, Op, X, Y, !IO) :-
          ; Op = bitwise_and
          ; Op = bitwise_or
          ; Op = bitwise_xor
+        ; Op = int32_eq
+        ; Op = int32_ne
+        ; Op = int32_lt
+        ; Op = int32_gt
+        ; Op = int32_le
+        ; Op = int32_ge
+        ; Op = int32_add
+        ; Op = int32_sub
+        ; Op = int32_mul
+        ; Op = int32_div
+        ; Op = int32_mod
+        ; Op = int32_bitwise_and
+        ; Op = int32_bitwise_or
+        ; Op = int32_bitwise_xor
+        ; Op = int32_unchecked_left_shift
+        ; Op = int32_unchecked_right_shift
          ; Op = logical_and
          ; Op = logical_or
          ; Op = eq
@@ -4699,6 +4781,18 @@ output_binop_for_java(Info, Op, X, Y, !IO) :-
          ; Op = float_from_dword
          ; Op = compound_eq
          ; Op = compound_lt
+        ; Op = int8_eq
+        ; Op = int8_ne
+        ; Op = int8_lt
+        ; Op = int8_gt
+        ; Op = int8_le
+        ; Op = int8_ge
+        ; Op = int16_eq
+        ; Op = int16_ne
+        ; Op = int16_lt
+        ; Op = int16_gt
+        ; Op = int16_le
+        ; Op = int16_ge
          ),
          ( if rval_is_enum_object(X) then
              io.write_string("(", !IO),
@@ -4728,6 +4822,16 @@ output_binop_for_java(Info, Op, X, Y, !IO) :-
          ; Op = uint_bitwise_xor
          ; Op = uint_unchecked_left_shift
          ; Op = uint_unchecked_right_shift
+        ; Op = uint32_eq
+        ; Op = uint32_ne
+        ; Op = uint32_add
+        ; Op = uint32_sub
+        ; Op = uint32_mul
+        ; Op = uint32_bitwise_and
+        ; Op = uint32_bitwise_or
+        ; Op = uint32_bitwise_xor
+        ; Op = uint32_unchecked_left_shift
+        ; Op = uint32_unchecked_right_shift
          ),
          io.write_string("(", !IO),
          output_rval_for_java(Info, X, !IO),
@@ -4741,6 +4845,10 @@ output_binop_for_java(Info, Op, X, Y, !IO) :-
          ; Op = uint_gt
          ; Op = uint_le
          ; Op = uint_ge
+        ; Op = uint32_lt
+        ; Op = uint32_gt
+        ; Op = uint32_le
+        ; Op = uint32_ge
          ),
          io.write_string("(((", !IO),
          output_rval_for_java(Info, X, !IO),
@@ -4752,6 +4860,8 @@ output_binop_for_java(Info, Op, X, Y, !IO) :-
      ;
          ( Op = uint_div
          ; Op = uint_mod
+        ; Op = uint32_div
+        ; Op = uint32_mod
          ),
          io.write_string("((int)(((", !IO),
          output_rval_for_java(Info, X, !IO),
@@ -4760,6 +4870,130 @@ output_binop_for_java(Info, Op, X, Y, !IO) :-
          io.write_string(" ((", !IO),
          output_rval_for_java(Info, Y, !IO),
          io.write_string(") & 0xffffffffL)))", !IO)
+    ;
+        ( Op = int8_add
+        ; Op = int8_sub
+        ; Op = int8_mul
+        ; Op = int8_div
+        ; Op = int8_mod
+        ; Op = int8_bitwise_and
+        ; Op = int8_bitwise_or
+        ; Op = int8_bitwise_xor
+        ; Op = int8_unchecked_left_shift
+        ; Op = int8_unchecked_right_shift
+        ),
+        io.write_string("(byte)(", !IO),
+        output_rval_for_java(Info, X, !IO),
+        io.write_string(" ", !IO),
+        output_binary_op_for_java(Op, !IO),
+        io.write_string(" ", !IO),
+        output_rval_for_java(Info, Y, !IO),
+        io.write_string(")", !IO)
+    ;
+        ( Op = uint8_eq
+        ; Op = uint8_ne
+        ; Op = uint8_add
+        ; Op = uint8_sub
+        ; Op = uint8_mul
+        ; Op = uint8_bitwise_and
+        ; Op = uint8_bitwise_or
+        ; Op = uint8_bitwise_xor
+        ; Op = uint8_unchecked_left_shift
+        ; Op = uint8_unchecked_right_shift
+        ),
+        io.write_string("(byte)(", !IO),
+        output_rval_for_java(Info, X, !IO),
+        io.write_string(" ", !IO),
+        output_binary_op_for_java(Op, !IO),
+        io.write_string(" ", !IO),
+        output_rval_for_java(Info, Y, !IO),
+        io.write_string(")", !IO)
+    ;
+        ( Op = uint8_lt
+        ; Op = uint8_gt
+        ; Op = uint8_le
+        ; Op = uint8_ge
+        ),
+        io.write_string("(((", !IO),
+        output_rval_for_java(Info, X, !IO),
+        io.write_string(") & 0xff) ", !IO),
+        output_binary_op_for_java(Op, !IO),
+        io.write_string(" ((", !IO),
+        output_rval_for_java(Info, Y, !IO),
+        io.write_string(") & 0xff))", !IO)
+    ;
+        ( Op = uint8_div
+        ; Op = uint8_mod
+        ),
+        io.write_string("((byte)(((", !IO),
+        output_rval_for_java(Info, X, !IO),
+        io.write_string(") & 0xff) ", !IO),
+        output_binary_op_for_java(Op, !IO),
+        io.write_string(" ((", !IO),
+        output_rval_for_java(Info, Y, !IO),
+        io.write_string(") & 0xff)))", !IO)
+    ;
+        ( Op = int16_add
+        ; Op = int16_sub
+        ; Op = int16_mul
+        ; Op = int16_div
+        ; Op = int16_mod
+        ; Op = int16_bitwise_and
+        ; Op = int16_bitwise_or
+        ; Op = int16_bitwise_xor
+        ; Op = int16_unchecked_left_shift
+        ; Op = int16_unchecked_right_shift
+        ),
+        io.write_string("(short)(", !IO),
+        output_rval_for_java(Info, X, !IO),
+        io.write_string(" ", !IO),
+        output_binary_op_for_java(Op, !IO),
+        io.write_string(" ", !IO),
+        output_rval_for_java(Info, Y, !IO),
+        io.write_string(")", !IO)
+    ;
+        ( Op = uint16_eq
+        ; Op = uint16_ne
+        ; Op = uint16_add
+        ; Op = uint16_sub
+        ; Op = uint16_mul
+        ; Op = uint16_bitwise_and
+        ; Op = uint16_bitwise_or
+        ; Op = uint16_bitwise_xor
+        ; Op = uint16_unchecked_left_shift
+        ; Op = uint16_unchecked_right_shift
+        ),
+        io.write_string("(short)(", !IO),
+        output_rval_for_java(Info, X, !IO),
+        io.write_string(" ", !IO),
+        output_binary_op_for_java(Op, !IO),
+        io.write_string(" ", !IO),
+        output_rval_for_java(Info, Y, !IO),
+        io.write_string(")", !IO)
+    ;
+        ( Op = uint16_lt
+        ; Op = uint16_gt
+        ; Op = uint16_le
+        ; Op = uint16_ge
+        ),
+        io.write_string("(((", !IO),
+        output_rval_for_java(Info, X, !IO),
+        io.write_string(") & 0xffff) ", !IO),
+        output_binary_op_for_java(Op, !IO),
+        io.write_string(" ((", !IO),
+        output_rval_for_java(Info, Y, !IO),
+        io.write_string(") & 0xffff))", !IO)
+    ;
+        ( Op = uint16_div
+        ; Op = uint16_mod
+        ),
+        io.write_string("((short)(((", !IO),
+        output_rval_for_java(Info, X, !IO),
+        io.write_string(") & 0xffff) ", !IO),
+        output_binary_op_for_java(Op, !IO),
+        io.write_string(" ((", !IO),
+        output_rval_for_java(Info, Y, !IO),
+        io.write_string(") & 0xffff)))", !IO)
      ).

      % Output an Rval and if the Rval is an enumeration object append the string
@@ -4831,6 +5065,108 @@ output_binary_op_for_java(Op, !IO) :-
          ; Op = uint_unchecked_left_shift, OpStr = "<<"
          ; Op = uint_unchecked_right_shift, OpStr = ">>>"

+        ; Op = int8_eq, OpStr = "=="
+        ; Op = int8_ne, OpStr = "!="
+        ; Op = int8_lt, OpStr = "<"
+        ; Op = int8_gt, OpStr = ">"
+        ; Op = int8_le, OpStr = "<="
+        ; Op = int8_ge, OpStr = ">="
+        ; Op = int8_add, OpStr = "+"
+        ; Op = int8_sub, OpStr = "-"
+        ; Op = int8_mul, OpStr = "*"
+        ; Op = int8_div, OpStr = "/"
+        ; Op = int8_mod, OpStr = "%"
+        ; Op = int8_bitwise_and, OpStr = "&"
+        ; Op = int8_bitwise_or, OpStr = "|"
+        ; Op = int8_bitwise_xor, OpStr = "^"
+        ; Op = int8_unchecked_left_shift, OpStr = "<<"
+        ; Op = int8_unchecked_right_shift, OpStr = ">>>"
+
+        ; Op = uint8_eq, OpStr = "=="
+        ; Op = uint8_ne, OpStr = "!="
+        ; Op = uint8_lt, OpStr = "<"
+        ; Op = uint8_gt, OpStr = ">"
+        ; Op = uint8_le, OpStr = "<="
+        ; Op = uint8_ge, OpStr = ">="
+        ; Op = uint8_add, OpStr = "+"
+        ; Op = uint8_sub, OpStr = "-"
+        ; Op = uint8_mul, OpStr = "*"
+        ; Op = uint8_div, OpStr = "/"
+        ; Op = uint8_mod, OpStr = "%"
+        ; Op = uint8_bitwise_and, OpStr = "&"
+        ; Op = uint8_bitwise_or, OpStr = "|"
+        ; Op = uint8_bitwise_xor, OpStr = "^"
+        ; Op = uint8_unchecked_left_shift, OpStr = "<<"
+        ; Op = uint8_unchecked_right_shift, OpStr = ">>>"
+
+        ; Op = int16_eq, OpStr = "=="
+        ; Op = int16_ne, OpStr = "!="
+        ; Op = int16_lt, OpStr = "<"
+        ; Op = int16_gt, OpStr = ">"
+        ; Op = int16_le, OpStr = "<="
+        ; Op = int16_ge, OpStr = ">="
+        ; Op = int16_add, OpStr = "+"
+        ; Op = int16_sub, OpStr = "-"
+        ; Op = int16_mul, OpStr = "*"
+        ; Op = int16_div, OpStr = "/"
+        ; Op = int16_mod, OpStr = "%"
+        ; Op = int16_bitwise_and, OpStr = "&"
+        ; Op = int16_bitwise_or, OpStr = "|"
+        ; Op = int16_bitwise_xor, OpStr = "^"
+        ; Op = int16_unchecked_left_shift, OpStr = "<<"
+        ; Op = int16_unchecked_right_shift, OpStr = ">>>"
+
+        ; Op = uint16_eq, OpStr = "=="
+        ; Op = uint16_ne, OpStr = "!="
+        ; Op = uint16_lt, OpStr = "<"
+        ; Op = uint16_gt, OpStr = ">"
+        ; Op = uint16_le, OpStr = "<="
+        ; Op = uint16_ge, OpStr = ">="
+        ; Op = uint16_add, OpStr = "+"
+        ; Op = uint16_sub, OpStr = "-"
+        ; Op = uint16_mul, OpStr = "*"
+        ; Op = uint16_div, OpStr = "/"
+        ; Op = uint16_mod, OpStr = "%"
+        ; Op = uint16_bitwise_and, OpStr = "&"
+        ; Op = uint16_bitwise_or, OpStr = "|"
+        ; Op = uint16_bitwise_xor, OpStr = "^"
+        ; Op = uint16_unchecked_left_shift, OpStr = "<<"
+        ; Op = uint16_unchecked_right_shift, OpStr = ">>>"
+
+        ; Op = int32_eq, OpStr = "=="
+        ; Op = int32_ne, OpStr = "!="
+        ; Op = int32_lt, OpStr = "<"
+        ; Op = int32_gt, OpStr = ">"
+        ; Op = int32_le, OpStr = "<="
+        ; Op = int32_ge, OpStr = ">="
+        ; Op = int32_add, OpStr = "+"
+        ; Op = int32_sub, OpStr = "-"
+        ; Op = int32_mul, OpStr = "*"
+        ; Op = int32_div, OpStr = "/"
+        ; Op = int32_mod, OpStr = "%"
+        ; Op = int32_bitwise_and, OpStr = "&"
+        ; Op = int32_bitwise_or, OpStr = "|"
+        ; Op = int32_bitwise_xor, OpStr = "^"
+        ; Op = int32_unchecked_left_shift, OpStr = "<<"
+        ; Op = int32_unchecked_right_shift, OpStr = ">>>"
+
+        ; Op = uint32_eq, OpStr = "=="
+        ; Op = uint32_ne, OpStr = "!="
+        ; Op = uint32_lt, OpStr = "<"
+        ; Op = uint32_gt, OpStr = ">"
+        ; Op = uint32_le, OpStr = "<="
+        ; Op = uint32_ge, OpStr = ">="
+        ; Op = uint32_add, OpStr = "+"
+        ; Op = uint32_sub, OpStr = "-"
+        ; Op = uint32_mul, OpStr = "*"
+        ; Op = uint32_div, OpStr = "/"
+        ; Op = uint32_mod, OpStr = "%"
+        ; Op = uint32_bitwise_and, OpStr = "&"
+        ; Op = uint32_bitwise_or, OpStr = "|"
+        ; Op = uint32_bitwise_xor, OpStr = "^"
+        ; Op = uint32_unchecked_left_shift, OpStr = "<<"
+        ; Op = uint32_unchecked_right_shift, OpStr = ">>>"
+
          ; Op = float_eq, OpStr = "=="
          ; Op = float_ne, OpStr = "!="
          ; Op = float_le, OpStr = "<="
@@ -4885,6 +5221,24 @@ output_rval_const_for_java(Info, Const, !IO) :-
          % XXX perhaps we should output this in hexadecimal?
          output_int_const_for_java(uint.cast_to_int(U), !IO)
      ;
+        Const = mlconst_int8(I8),
+        output_int_const_for_java(I8, !IO)
+    ;
+        Const = mlconst_uint8(U8),
+        output_int_const_for_java(U8, !IO)
+    ;
+        Const = mlconst_int16(I16),
+        output_int_const_for_java(I16, !IO)
+    ;
+        Const = mlconst_uint16(U16),
+        output_int_const_for_java(U16, !IO)
+    ;
+        Const = mlconst_int32(I32),
+        output_int_const_for_java(I32, !IO)
+    ;
+        Const = mlconst_uint32(U32),
+        output_int_const_for_java(U32, !IO)
+    ;
          Const = mlconst_char(N),
          io.write_string("(", !IO),
          output_int_const_for_java(N, !IO),
diff --git a/compiler/mlds_to_target_util.m b/compiler/mlds_to_target_util.m
index f2ad12999..0a0bb9df9 100644
--- a/compiler/mlds_to_target_util.m
+++ b/compiler/mlds_to_target_util.m
@@ -363,6 +363,12 @@ add_scalar_deps_rval_const(FromScalar, RvalConst, !Graph) :-
          ; RvalConst = mlconst_false
          ; RvalConst = mlconst_int(_)
          ; RvalConst = mlconst_uint(_)
+        ; RvalConst = mlconst_int8(_)
+        ; RvalConst = mlconst_uint8(_)
+        ; RvalConst = mlconst_int16(_)
+        ; RvalConst = mlconst_uint16(_)
+        ; RvalConst = mlconst_int32(_)
+        ; RvalConst = mlconst_uint32(_)
          ; RvalConst = mlconst_enum(_, _)
          ; RvalConst = mlconst_char(_)
          ; RvalConst = mlconst_float(_)
diff --git a/compiler/mode_util.m b/compiler/mode_util.m
index e86b308ac..2ba11a809 100644
--- a/compiler/mode_util.m
+++ b/compiler/mode_util.m
@@ -1894,6 +1894,12 @@ cons_id_to_shared_inst(ModuleInfo, ConsId, NumArgs) = MaybeInst :-
          % we used to handle character constants as user-defined cons_ids.
          ( ConsId = int_const(_)
          ; ConsId = uint_const(_)
+        ; ConsId = int8_const(_)
+        ; ConsId = uint8_const(_)
+        ; ConsId = int16_const(_)
+        ; ConsId = uint16_const(_)
+        ; ConsId = int32_const(_)
+        ; ConsId = uint32_const(_)
          ; ConsId = float_const(_)
          ; ConsId = char_const(_)
          ; ConsId = string_const(_)
diff --git a/compiler/module_qual.qualify_items.m b/compiler/module_qual.qualify_items.m
index 95c045f54..8a7f8b060 100644
--- a/compiler/module_qual.qualify_items.m
+++ b/compiler/module_qual.qualify_items.m
@@ -477,6 +477,24 @@ qualify_type(InInt, ErrorContext, Type0, Type, !Info, !Specs) :-
              BuiltinType = builtin_type_uint,
              mq_info_set_module_used(InInt, unqualified("uint"), !Info)
          ;
+            BuiltinType = builtin_type_int8,
+            mq_info_set_module_used(InInt, unqualified("int8"), !Info)
+        ;
+            BuiltinType = builtin_type_uint8,
+            mq_info_set_module_used(InInt, unqualified("uint8"), !Info)
+        ;
+            BuiltinType = builtin_type_int16,
+            mq_info_set_module_used(InInt, unqualified("int16"), !Info)
+        ;
+            BuiltinType = builtin_type_uint16,
+            mq_info_set_module_used(InInt, unqualified("uint16"), !Info)
+        ;
+            BuiltinType = builtin_type_int32,
+            mq_info_set_module_used(InInt, unqualified("int32"), !Info)
+        ;
+            BuiltinType = builtin_type_uint32,
+            mq_info_set_module_used(InInt, unqualified("uint32"), !Info)
+        ;
              BuiltinType = builtin_type_float,
              mq_info_set_module_used(InInt, unqualified("float"), !Info)
          ;
@@ -719,6 +737,12 @@ qualify_bound_inst(InInt, ErrorContext, BoundInst0, BoundInst,
          ; ConsId = closure_cons(_, _)
          ; ConsId = int_const(_)
          ; ConsId = uint_const(_)
+        ; ConsId = int8_const(_)
+        ; ConsId = uint8_const(_)
+        ; ConsId = int16_const(_)
+        ; ConsId = uint16_const(_)
+        ; ConsId = int32_const(_)
+        ; ConsId = uint32_const(_)
          ; ConsId = float_const(_)
          ; ConsId = char_const(_)
          ; ConsId = string_const(_)
diff --git a/compiler/opt_debug.m b/compiler/opt_debug.m
index 40ee7cab4..e76a4392e 100644
--- a/compiler/opt_debug.m
+++ b/compiler/opt_debug.m
@@ -444,6 +444,24 @@ dump_const(MaybeProcLabel, Const) = Str :-
          Const = llconst_uint(U),
          Str = uint_to_string(U)
      ;
+        Const = llconst_int8(I8),
+        Str = int_to_string(I8)
+    ;
+        Const = llconst_uint8(U8),
+        Str = int_to_string(U8)
+    ;
+        Const = llconst_int16(I16),
+        Str = int_to_string(I16)
+    ;
+        Const = llconst_uint16(U16),
+        Str = int_to_string(U16)
+    ;
+        Const = llconst_int32(I32),
+        Str = int_to_string(I32)
+    ;
+        Const = llconst_uint32(U32),
+        Str = int_to_string(U32)
+    ;
          Const = llconst_foreign(F, _),
          Str = F
      ;
@@ -843,6 +861,12 @@ dump_unop(hash_string4) = "hash_string4".
  dump_unop(hash_string5) = "hash_string5".
  dump_unop(hash_string6) = "hash_string6".
  dump_unop(uint_bitwise_complement) = "uint_bitwise_complement".
+dump_unop(int8_bitwise_complement) = "int8_bitwise_complement".
+dump_unop(uint8_bitwise_complement) = "uint8_bitwise_complement".
+dump_unop(int16_bitwise_complement) = "int16_bitwise_complement".
+dump_unop(uint16_bitwise_complement) = "uint16_bitwise_complement".
+dump_unop(int32_bitwise_complement) = "int32_bitwise_complement".
+dump_unop(uint32_bitwise_complement) = "uint32_bitwise_complement".

  dump_binop(array_index(_)) = "array_index".
  dump_binop(string_unsafe_index_code_unit) = "string_unsafe_index_code_unit".
@@ -872,6 +896,102 @@ dump_binop(uint_bitwise_or) = "uint|".
  dump_binop(uint_bitwise_xor) = "uint^".
  dump_binop(uint_unchecked_left_shift) = "uint_unchecked<<".
  dump_binop(uint_unchecked_right_shift) = "uint_unchecked>>".
+dump_binop(int8_eq) = "int8==".
+dump_binop(int8_ne) = "int8!=".
+dump_binop(int8_lt) = "int8<".
+dump_binop(int8_gt) = "int8>".
+dump_binop(int8_le) = "int8<=".
+dump_binop(int8_ge) = "int8>=".
+dump_binop(int8_add) = "int8+".
+dump_binop(int8_sub) = "int8-".
+dump_binop(int8_mul) = "int8*".
+dump_binop(int8_div) = "int8/".
+dump_binop(int8_mod) = "int8%".
+dump_binop(int8_bitwise_and) = "int8&".
+dump_binop(int8_bitwise_or) = "int8|".
+dump_binop(int8_bitwise_xor) = "int8^".
+dump_binop(int8_unchecked_left_shift) = "int8_unchecked<<".
+dump_binop(int8_unchecked_right_shift) = "int8_unchecked>>".
+dump_binop(uint8_eq) = "uint8==".
+dump_binop(uint8_ne) = "uint8!=".
+dump_binop(uint8_lt) = "uint8<".
+dump_binop(uint8_gt) = "uint8>".
+dump_binop(uint8_le) = "uint8<=".
+dump_binop(uint8_ge) = "uint8>=".
+dump_binop(uint8_add) = "uint8+".
+dump_binop(uint8_sub) = "uint8-".
+dump_binop(uint8_mul) = "uint8*".
+dump_binop(uint8_div) = "uint8/".
+dump_binop(uint8_mod) = "uint8%".
+dump_binop(uint8_bitwise_and) = "uint8&".
+dump_binop(uint8_bitwise_or) = "uint8|".
+dump_binop(uint8_bitwise_xor) = "uint8^".
+dump_binop(uint8_unchecked_left_shift) = "uint8_unchecked<<".
+dump_binop(uint8_unchecked_right_shift) = "uint8_unchecked>>".
+dump_binop(int16_eq) = "int16==".
+dump_binop(int16_ne) = "int16!=".
+dump_binop(int16_lt) = "int16<".
+dump_binop(int16_gt) = "int16>".
+dump_binop(int16_le) = "int16<=".
+dump_binop(int16_ge) = "int16>=".
+dump_binop(int16_add) = "int16+".
+dump_binop(int16_sub) = "int16-".
+dump_binop(int16_mul) = "int16*".
+dump_binop(int16_div) = "int16/".
+dump_binop(int16_mod) = "int16%".
+dump_binop(int16_bitwise_and) = "int16&".
+dump_binop(int16_bitwise_or) = "int16|".
+dump_binop(int16_bitwise_xor) = "int16^".
+dump_binop(int16_unchecked_left_shift) = "int16_unchecked<<".
+dump_binop(int16_unchecked_right_shift) = "int16_unchecked>>".
+dump_binop(uint16_eq) = "uint16==".
+dump_binop(uint16_ne) = "uint16!=".
+dump_binop(uint16_lt) = "uint16<".
+dump_binop(uint16_gt) = "uint16>".
+dump_binop(uint16_le) = "uint16<=".
+dump_binop(uint16_ge) = "uint16>=".
+dump_binop(uint16_add) = "uint16+".
+dump_binop(uint16_sub) = "uint16-".
+dump_binop(uint16_mul) = "uint16*".
+dump_binop(uint16_div) = "uint16/".
+dump_binop(uint16_mod) = "uint16%".
+dump_binop(uint16_bitwise_and) = "uint16&".
+dump_binop(uint16_bitwise_or) = "uint16|".
+dump_binop(uint16_bitwise_xor) = "uint16^".
+dump_binop(uint16_unchecked_left_shift) = "uint16_unchecked<<".
+dump_binop(uint16_unchecked_right_shift) = "uint16_unchecked>>".
+dump_binop(int32_eq) = "int32==".
+dump_binop(int32_ne) = "int32!=".
+dump_binop(int32_lt) = "int32<".
+dump_binop(int32_gt) = "int32>".
+dump_binop(int32_le) = "int32<=".
+dump_binop(int32_ge) = "int32>=".
+dump_binop(int32_add) = "int32+".
+dump_binop(int32_sub) = "int32-".
+dump_binop(int32_mul) = "int32*".
+dump_binop(int32_div) = "int32/".
+dump_binop(int32_mod) = "int32%".
+dump_binop(int32_bitwise_and) = "int32&".
+dump_binop(int32_bitwise_or) = "int32|".
+dump_binop(int32_bitwise_xor) = "int32^".
+dump_binop(int32_unchecked_left_shift) = "int32_unchecked<<".
+dump_binop(int32_unchecked_right_shift) = "int32_unchecked>>".
+dump_binop(uint32_eq) = "uint32==".
+dump_binop(uint32_ne) = "uint32!=".
+dump_binop(uint32_lt) = "uint32<".
+dump_binop(uint32_gt) = "uint32>".
+dump_binop(uint32_le) = "uint32<=".
+dump_binop(uint32_ge) = "uint32>=".
+dump_binop(uint32_add) = "uint32+".
+dump_binop(uint32_sub) = "uint32-".
+dump_binop(uint32_mul) = "uint32*".
+dump_binop(uint32_div) = "uint32/".
+dump_binop(uint32_mod) = "uint32%".
+dump_binop(uint32_bitwise_and) = "uint32&".
+dump_binop(uint32_bitwise_or) = "uint32|".
+dump_binop(uint32_bitwise_xor) = "uint32^".
+dump_binop(uint32_unchecked_left_shift) = "uint32_unchecked<<".
+dump_binop(uint32_unchecked_right_shift) = "uint32_unchecked>>".
  dump_binop(float_plus) = "fl+".
  dump_binop(float_minus) = "fl-".
  dump_binop(float_times) = "fl*".
diff --git a/compiler/opt_util.m b/compiler/opt_util.m
index b8c219d19..a044b969b 100644
--- a/compiler/opt_util.m
+++ b/compiler/opt_util.m
@@ -2616,6 +2616,12 @@ replace_labels_rval_const(Const0, Const, ReplMap) :-
          ; Const0 = llconst_false
          ; Const0 = llconst_int(_)
          ; Const0 = llconst_uint(_)
+        ; Const0 = llconst_int8(_)
+        ; Const0 = llconst_uint8(_)
+        ; Const0 = llconst_int16(_)
+        ; Const0 = llconst_uint16(_)
+        ; Const0 = llconst_int32(_)
+        ; Const0 = llconst_uint32(_)
          ; Const0 = llconst_foreign(_, _)
          ; Const0 = llconst_float(_)
          ; Const0 = llconst_string(_)
diff --git a/compiler/parse_tree_out_info.m b/compiler/parse_tree_out_info.m
index 4634de671..abd088fc4 100644
--- a/compiler/parse_tree_out_info.m
+++ b/compiler/parse_tree_out_info.m
@@ -107,6 +107,13 @@
      pred add_char(char::in, U::di, U::uo) is det,
      pred add_int(int::in, U::di, U::uo) is det,
      pred add_uint(uint::in, U::di, U::uo) is det,
+    % XXX FIXED SIZE INT
+    pred add_int8(int::in, U::di, U::uo) is det,
+    pred add_uint8(int::in, U::di, U::uo) is det,
+    pred add_int16(int::in, U::di, U::uo) is det,
+    pred add_uint16(int::in, U::di, U::uo) is det,
+    pred add_int32(int::in, U::di, U::uo) is det,
+    pred add_uint32(int::in, U::di, U::uo) is det,
      pred add_float(float::in, U::di, U::uo) is det,
      pred add_purity_prefix(purity::in, U::di, U::uo) is det,
      pred add_quoted_atom(string::in, U::di, U::uo) is det,
@@ -192,6 +199,12 @@ maybe_unqualify_sym_name(Info, SymName, OutSymName) :-
      pred(add_char/3) is io.write_char,
      pred(add_int/3) is io.write_int,
      pred(add_uint/3) is write_uint_literal,
+    pred(add_int8/3) is io.write_int,
+    pred(add_uint8/3) is io.write_int,
+    pred(add_int16/3) is io.write_int,
+    pred(add_uint16/3) is io.write_int,
+    pred(add_int32/3) is io.write_int,
+    pred(add_uint32/3) is io.write_int,
      pred(add_float/3) is io.write_float,
      pred(add_purity_prefix/3) is prog_out.write_purity_prefix,
      pred(add_quoted_atom/3) is term_io.quote_atom,
@@ -210,6 +223,12 @@ maybe_unqualify_sym_name(Info, SymName, OutSymName) :-
      pred(add_char/3) is output_char,
      pred(add_int/3) is output_int,
      pred(add_uint/3) is output_uint,
+    pred(add_int8/3) is output_int8,
+    pred(add_uint8/3) is output_uint8,
+    pred(add_int16/3) is output_int16,
+    pred(add_uint16/3) is output_uint16,
+    pred(add_int32/3) is output_int32,
+    pred(add_uint32/3) is output_uint32,
      pred(add_float/3) is output_float,
      pred(add_purity_prefix/3) is output_purity_prefix,
      pred(add_quoted_atom/3) is output_quoted_atom,
@@ -275,6 +294,43 @@ output_uint(U, Str0, Str) :-
      S = uint_to_string(U) ++ "u",
      string.append(Str0, S, Str).

+% XXX FIXED SIZE INT
+:- pred output_int8(int::in, string::di, string::uo) is det.
+
+output_int8(I, Str0, Str) :-
+    string.int_to_string(I, S),
+    string.append(Str0, S, Str).
+
+:- pred output_uint8(int::in, string::di, string::uo) is det.
+
+output_uint8(I, Str0, Str) :-
+    string.int_to_string(I, S),
+    string.append(Str0, S, Str).
+
+:- pred output_int16(int::in, string::di, string::uo) is det.
+
+output_int16(I, Str0, Str) :-
+    string.int_to_string(I, S),
+    string.append(Str0, S, Str).
+
+:- pred output_uint16(int::in, string::di, string::uo) is det.
+
+output_uint16(I, Str0, Str) :-
+    string.int_to_string(I, S),
+    string.append(Str0, S, Str).
+
+:- pred output_int32(int::in, string::di, string::uo) is det.
+
+output_int32(I, Str0, Str) :-
+    string.int_to_string(I, S),
+    string.append(Str0, S, Str).
+
+:- pred output_uint32(int::in, string::di, string::uo) is det.
+
+output_uint32(I, Str0, Str) :-
+    string.int_to_string(I, S),
+    string.append(Str0, S, Str).
+
  :- pred output_float(float::in, string::di, string::uo) is det.

  output_float(F, Str0, Str) :-
diff --git a/compiler/parse_tree_to_term.m b/compiler/parse_tree_to_term.m
index 98dce6735..8cfb45ec7 100644
--- a/compiler/parse_tree_to_term.m
+++ b/compiler/parse_tree_to_term.m
@@ -652,6 +652,30 @@ cons_id_and_args_to_term_full(ConsId, ArgTerms, Term) :-
          term.context_init(Context),
          Term = uint_to_decimal_term(UInt, Context)
      ;
+        ConsId = int8_const(Int8),
+        term.context_init(Context),
+        Term = int_to_decimal_term(Int8, Context)
+    ;
+        ConsId = uint8_const(UInt8),
+        term.context_init(Context),
+        Term = int_to_decimal_term(UInt8, Context)
+    ;
+        ConsId = int16_const(Int16),
+        term.context_init(Context),
+        Term = int_to_decimal_term(Int16, Context)
+    ;
+        ConsId = uint16_const(UInt16),
+        term.context_init(Context),
+        Term = int_to_decimal_term(UInt16, Context)
+    ;
+        ConsId = int32_const(Int32),
+        term.context_init(Context),
+        Term = int_to_decimal_term(Int32, Context)
+    ;
+        ConsId = uint32_const(UInt32),
+        term.context_init(Context),
+        Term = int_to_decimal_term(UInt32, Context)
+    ;
          ConsId = float_const(Float),
          term.context_init(Context),
          Term = term.functor(term.float(Float), [], Context)
diff --git a/compiler/parse_type_name.m b/compiler/parse_type_name.m
index b72728403..67225e9e0 100644
--- a/compiler/parse_type_name.m
+++ b/compiler/parse_type_name.m
@@ -644,6 +644,24 @@ is_known_type_name_args(Name, Args, KnownType) :-
              Name = "uint",
              BuiltinType = builtin_type_uint
          ;
+            Name = "int8",
+            BuiltinType = builtin_type_int8
+        ;
+            Name = "uint8",
+            BuiltinType = builtin_type_uint8
+        ;
+            Name = "int16",
+            BuiltinType = builtin_type_int16
+        ;
+            Name = "uint16",
+            BuiltinType = builtin_type_uint16
+        ;
+            Name = "int32",
+            BuiltinType = builtin_type_int32
+        ;
+            Name = "uint32",
+            BuiltinType = builtin_type_uint32
+        ;
              Name = "float",
              BuiltinType = builtin_type_float
          ;
diff --git a/compiler/polymorphism.m b/compiler/polymorphism.m
index 6d2fa842e..9e8f8ce54 100644
--- a/compiler/polymorphism.m
+++ b/compiler/polymorphism.m
@@ -3593,6 +3593,24 @@ get_category_name(CtorCat) = MaybeName :-
          CtorCat = ctor_cat_builtin(cat_builtin_uint),
          MaybeName = yes("uint")
      ;
+        CtorCat = ctor_cat_builtin(cat_builtin_int8),
+        MaybeName = yes("int8")
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_uint8),
+        MaybeName = yes("uint8")
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_int16),
+        MaybeName = yes("int16")
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_uint16),
+        MaybeName = yes("uint16")
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_int32),
+        MaybeName = yes("int32")
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_uint32),
+        MaybeName = yes("uint32")
+    ;
          CtorCat = ctor_cat_builtin(cat_builtin_char),
          MaybeName = yes("character")
      ;
diff --git a/compiler/prog_data.m b/compiler/prog_data.m
index 8b5846c8c..afe85c740 100644
--- a/compiler/prog_data.m
+++ b/compiler/prog_data.m
@@ -107,6 +107,12 @@

      ;       int_const(int)
      ;       uint_const(uint)
+    ;       int8_const(int)     % XXX FIXED SIZE INT
+    ;       uint8_const(int)    % XXX FIXED SIZE INT
+    ;       int16_const(int)    % XXX FIXED SIZE INT
+    ;       uint16_const(int)   % XXX FIXED SIZE INT
+    ;       int32_const(int)    % XXX FIXED SIZE INT
+    ;       uint32_const(int)   % XXX FIXED SIZE INT
      ;       float_const(float)
      ;       char_const(char)
      ;       string_const(string)
@@ -224,6 +230,12 @@ cons_id_is_const_struct(ConsId, ConstNum) :-
          ; ConsId = closure_cons(_, _)
          ; ConsId = int_const(_)
          ; ConsId = uint_const(_)
+        ; ConsId = int8_const(_)
+        ; ConsId = uint8_const(_)
+        ; ConsId = int16_const(_)
+        ; ConsId = uint16_const(_)
+        ; ConsId = int32_const(_)
+        ; ConsId = uint32_const(_)
          ; ConsId = float_const(_)
          ; ConsId = char_const(_)
          ; ConsId = string_const(_)
@@ -495,6 +507,12 @@ cons_id_is_const_struct(ConsId, ConstNum) :-
  :- type builtin_type
      --->    builtin_type_int
      ;       builtin_type_uint
+    ;       builtin_type_int8
+    ;       builtin_type_uint8
+    ;       builtin_type_int16
+    ;       builtin_type_uint16
+    ;       builtin_type_int32
+    ;       builtin_type_uint32
      ;       builtin_type_float
      ;       builtin_type_string
      ;       builtin_type_char.
@@ -561,6 +579,12 @@ is_builtin_type_name(Name) :-

  builtin_type_to_string(builtin_type_int, "int").
  builtin_type_to_string(builtin_type_uint, "uint").
+builtin_type_to_string(builtin_type_int8, "int8").
+builtin_type_to_string(builtin_type_uint8, "uint8").
+builtin_type_to_string(builtin_type_int16, "int16").
+builtin_type_to_string(builtin_type_uint16, "uint16").
+builtin_type_to_string(builtin_type_int32, "int32").
+builtin_type_to_string(builtin_type_uint32, "uint32").
  builtin_type_to_string(builtin_type_float, "float").
  builtin_type_to_string(builtin_type_string, "string").
  builtin_type_to_string(builtin_type_char, "character").
diff --git a/compiler/prog_out.m b/compiler/prog_out.m
index 3fb778ecc..923ff5908 100644
--- a/compiler/prog_out.m
+++ b/compiler/prog_out.m
@@ -371,6 +371,30 @@ cons_id_and_arity_to_string_maybe_quoted(MangleCons, QuoteCons, ConsId)
          ConsId = uint_const(UInt),
          String = uint_to_string(UInt)
      ;
+        % XXX FIXED SIZE INT
+        ConsId = int8_const(Int8),
+        string.int_to_string(Int8, String)
+    ;
+        % XXX FIXED SIZE INT
+        ConsId = uint8_const(UInt8),
+        string.int_to_string(UInt8, String)
+    ;
+        % XXX FIXED SIZE INT
+        ConsId = int16_const(Int16),
+        string.int_to_string(Int16, String)
+    ;
+        % XXX FIXED SIZE INT
+        ConsId = uint16_const(UInt16),
+        string.int_to_string(UInt16, String)
+    ;
+        % XXX FIXED SIZE INT
+        ConsId = int32_const(Int32),
+        string.int_to_string(Int32, String)
+    ;
+        % XXX FIXED SIZE INT
+        ConsId = uint32_const(UInt32),
+        string.int_to_string(UInt32, String)
+    ;
          ConsId = float_const(Float),
          String = float_to_string(Float)
      ;
diff --git a/compiler/prog_rep.m b/compiler/prog_rep.m
index 266e88b73..46758c9bb 100644
--- a/compiler/prog_rep.m
+++ b/compiler/prog_rep.m
@@ -868,6 +868,12 @@ cons_id_rep(cons(SymName, _, _)) =
  cons_id_rep(tuple_cons(_)) = "{}".
  cons_id_rep(int_const(Int)) = string.int_to_string(Int).
  cons_id_rep(uint_const(UInt)) = string.uint_to_string(UInt).
+cons_id_rep(int8_const(Int8)) = string.int_to_string(Int8).
+cons_id_rep(uint8_const(UInt8)) = string.int_to_string(UInt8).
+cons_id_rep(int16_const(Int16)) = string.int_to_string(Int16).
+cons_id_rep(uint16_const(UInt16)) = string.int_to_string(UInt16).
+cons_id_rep(int32_const(Int32)) = string.int_to_string(Int32).
+cons_id_rep(uint32_const(UInt32)) = string.int_to_string(UInt32).
  cons_id_rep(float_const(Float)) = string.float_to_string(Float).
  cons_id_rep(char_const(Char)) = string.char_to_string(Char).
  cons_id_rep(string_const(String)) = """" ++ String ++ """".
diff --git a/compiler/prog_rep_tables.m b/compiler/prog_rep_tables.m
index 306c9daee..a15370b3f 100644
--- a/compiler/prog_rep_tables.m
+++ b/compiler/prog_rep_tables.m
@@ -333,19 +333,37 @@ add_type_to_table(Type, TypeCode, !StringTable, !TypeTable) :-
              BuiltinType = builtin_type_uint,
              Selector = 6
          ;
-            BuiltinType = builtin_type_float,
+            BuiltinType = builtin_type_int8,
              Selector = 7
          ;
-            BuiltinType = builtin_type_string,
+            BuiltinType = builtin_type_uint8,
              Selector = 8
          ;
-            BuiltinType = builtin_type_char,
+            BuiltinType = builtin_type_int16,
              Selector = 9
+        ;
+            BuiltinType = builtin_type_uint16,
+            Selector = 10
+        ;
+            BuiltinType = builtin_type_int32,
+            Selector = 11
+        ;
+            BuiltinType = builtin_type_uint32,
+            Selector = 12
+        ;
+            BuiltinType = builtin_type_float,
+            Selector = 13
+        ;
+            BuiltinType = builtin_type_string,
+            Selector = 14
+        ;
+            BuiltinType = builtin_type_char,
+            Selector = 15
          ),
          TypeBytesCord = cord.singleton(Selector)
      ;
          Type = tuple_type(ArgTypes, _Kind),
-        Selector = 10,
+        Selector = 16,
          list.map_foldl2(lookup_type_in_table, ArgTypes, ArgTypeCodes,
              !StringTable, !TypeTable),
          encode_arg_type_codes(ArgTypeCodes, ArgTypeBytesCord),
@@ -358,10 +376,10 @@ add_type_to_table(Type, TypeCode, !StringTable, !TypeTable) :-
          encode_arg_type_codes(ArgTypeCodes, ArgTypeBytesCord),
          (
              PorF = pf_predicate,
-            Selector = 11
+            Selector = 17
          ;
              PorF = pf_function,
-            Selector = 12
+            Selector = 18
          ),
          TypeBytesCord = cord.singleton(Selector) ++ ArgTypeBytesCord
      ;
@@ -372,7 +390,7 @@ add_type_to_table(Type, TypeCode, !StringTable, !TypeTable) :-
          unexpected($module, $pred, "kinded_type")
      ;
          Type = type_variable(TVar, _Kind),
-        Selector = 13,
+        Selector = 19,
          var_to_int(TVar, TVarNum),
          encode_num_det(TVarNum, TVarNumBytes),
          TypeBytesCord = cord.singleton(Selector) ++
diff --git a/compiler/prog_type.m b/compiler/prog_type.m
index 1333510be..6d2097b27 100644
--- a/compiler/prog_type.m
+++ b/compiler/prog_type.m
@@ -283,6 +283,12 @@
  :- type type_ctor_cat_builtin
      --->    cat_builtin_int
      ;       cat_builtin_uint
+    ;       cat_builtin_int8
+    ;       cat_builtin_uint8
+    ;       cat_builtin_int16
+    ;       cat_builtin_uint16
+    ;       cat_builtin_int32
+    ;       cat_builtin_uint32
      ;       cat_builtin_float
      ;       cat_builtin_char
      ;       cat_builtin_string.
@@ -788,6 +794,12 @@ get_unconstrained_tvars(Tvars, Constraints, Unconstrained) :-
  builtin_type_ctors_with_no_hlds_type_defn =
      [ type_ctor(qualified(mercury_public_builtin_module, "int"), 0),
        type_ctor(qualified(mercury_public_builtin_module, "uint"), 0),
+      type_ctor(qualified(mercury_public_builtin_module, "int8"), 0),
+      type_ctor(qualified(mercury_public_builtin_module, "uint8"), 0),
+      type_ctor(qualified(mercury_public_builtin_module, "int16"), 0),
+      type_ctor(qualified(mercury_public_builtin_module, "uint16"), 0),
+      type_ctor(qualified(mercury_public_builtin_module, "int32"), 0),
+      type_ctor(qualified(mercury_public_builtin_module, "uint32"), 0),
        type_ctor(qualified(mercury_public_builtin_module, "string"), 0),
        type_ctor(qualified(mercury_public_builtin_module, "character"), 0),
        type_ctor(qualified(mercury_public_builtin_module, "float"), 0),
@@ -920,6 +932,12 @@ qualify_cons_id(Args, ConsId0, ConsId, InstConsId) :-
          ; ConsId0 = closure_cons(_, _)
          ; ConsId0 = int_const(_)
          ; ConsId0 = uint_const(_)
+        ; ConsId0 = int8_const(_)
+        ; ConsId0 = uint8_const(_)
+        ; ConsId0 = int16_const(_)
+        ; ConsId0 = uint16_const(_)
+        ; ConsId0 = int32_const(_)
+        ; ConsId0 = uint32_const(_)
          ; ConsId0 = float_const(_)
          ; ConsId0 = char_const(_)
          ; ConsId0 = string_const(_)
diff --git a/compiler/prog_util.m b/compiler/prog_util.m
index 69edd20f6..ca74d6350 100644
--- a/compiler/prog_util.m
+++ b/compiler/prog_util.m
@@ -665,6 +665,12 @@ cons_id_arity(ConsId) = Arity :-
      ;
          ( ConsId = int_const(_)
          ; ConsId = uint_const(_)
+        ; ConsId = int8_const(_)
+        ; ConsId = uint8_const(_)
+        ; ConsId = int16_const(_)
+        ; ConsId = uint16_const(_)
+        ; ConsId = int32_const(_)
+        ; ConsId = uint32_const(_)
          ; ConsId = float_const(_)
          ; ConsId = char_const(_)
          ; ConsId = string_const(_)
@@ -690,6 +696,12 @@ cons_id_maybe_arity(cons(_, Arity, _)) = yes(Arity).
  cons_id_maybe_arity(tuple_cons(Arity)) = yes(Arity).
  cons_id_maybe_arity(int_const(_)) = yes(0).
  cons_id_maybe_arity(uint_const(_)) = yes(0).
+cons_id_maybe_arity(int8_const(_)) = yes(0).
+cons_id_maybe_arity(uint8_const(_)) = yes(0).
+cons_id_maybe_arity(int16_const(_)) = yes(0).
+cons_id_maybe_arity(uint16_const(_)) = yes(0).
+cons_id_maybe_arity(int32_const(_)) = yes(0).
+cons_id_maybe_arity(uint32_const(_)) = yes(0).
  cons_id_maybe_arity(float_const(_)) = yes(0).
  cons_id_maybe_arity(char_const(_)) = yes(0).
  cons_id_maybe_arity(string_const(_)) = yes(0).
diff --git a/compiler/rbmm.execution_path.m b/compiler/rbmm.execution_path.m
index 84c7782bf..0722da590 100644
--- a/compiler/rbmm.execution_path.m
+++ b/compiler/rbmm.execution_path.m
@@ -230,6 +230,12 @@ execution_paths_covered_cases(ProcInfo, Switch, [Case | Cases], !ExecPaths) :-
      ;
          ( MainConsId = int_const(_Int)
          ; MainConsId = uint_const(_UInt)
+        ; MainConsId = int8_const(_Int8)
+        ; MainConsId = uint8_const(_UInt8)
+        ; MainConsId = int16_const(_Int16)
+        ; MainConsId = uint16_const(_UInt16)
+        ; MainConsId = int32_const(_Int32)
+        ; MainConsId = uint32_const(_UInt32)
          ; MainConsId = float_const(_Float)
          ; MainConsId = char_const(_Char)
          ; MainConsId = string_const(_String)
diff --git a/compiler/rtti.m b/compiler/rtti.m
index 3bebb2db4..549c83d9a 100644
--- a/compiler/rtti.m
+++ b/compiler/rtti.m
@@ -434,6 +434,12 @@
  :- type builtin_ctor
      --->    builtin_ctor_int
      ;       builtin_ctor_uint
+    ;       builtin_ctor_int8
+    ;       builtin_ctor_uint8
+    ;       builtin_ctor_int16
+    ;       builtin_ctor_uint16
+    ;       builtin_ctor_int32
+    ;       builtin_ctor_uint32
      ;       builtin_ctor_float
      ;       builtin_ctor_char
      ;       builtin_ctor_string
@@ -1725,6 +1731,12 @@ type_ctor_rep_to_string(TypeCtorData, RepStr) :-

  builtin_ctor_rep_to_string(builtin_ctor_int, "MR_TYPECTOR_REP_INT").
  builtin_ctor_rep_to_string(builtin_ctor_uint, "MR_TYPECTOR_REP_UINT").
+builtin_ctor_rep_to_string(builtin_ctor_int8, "MR_TYPECTOR_REP_INT8").
+builtin_ctor_rep_to_string(builtin_ctor_uint8, "MR_TYPECTOR_REP_UINT8").
+builtin_ctor_rep_to_string(builtin_ctor_int16, "MR_TYPECTOR_REP_INT16").
+builtin_ctor_rep_to_string(builtin_ctor_uint16, "MR_TYPECTOR_REP_UINT16").
+builtin_ctor_rep_to_string(builtin_ctor_int32, "MR_TYPECTOR_REP_INT32").
+builtin_ctor_rep_to_string(builtin_ctor_uint32, "MR_TYPECTOR_REP_UINT32").
  builtin_ctor_rep_to_string(builtin_ctor_string, "MR_TYPECTOR_REP_STRING").
  builtin_ctor_rep_to_string(builtin_ctor_float, "MR_TYPECTOR_REP_FLOAT").
  builtin_ctor_rep_to_string(builtin_ctor_char, "MR_TYPECTOR_REP_CHAR").
@@ -2365,6 +2377,12 @@ tabling_id_has_array_type(Id) = IsArray :-
  table_trie_step_to_c(table_trie_step_dummy, "MR_TABLE_STEP_DUMMY", no).
  table_trie_step_to_c(table_trie_step_int, "MR_TABLE_STEP_INT", no).
  table_trie_step_to_c(table_trie_step_uint, "MR_TABLE_STEP_UINT", no).
+table_trie_step_to_c(table_trie_step_int8, "MR_TABLE_STEP_INT8", no).
+table_trie_step_to_c(table_trie_step_uint8, "MR_TABLE_STEP_UINT8", no).
+table_trie_step_to_c(table_trie_step_int16, "MR_TABLE_STEP_INT16", no).
+table_trie_step_to_c(table_trie_step_uint16, "MR_TABLE_STEP_UINT16", no).
+table_trie_step_to_c(table_trie_step_int32, "MR_TABLE_STEP_INT32", no).
+table_trie_step_to_c(table_trie_step_uint32, "MR_TABLE_STEP_UINT32", no).
  table_trie_step_to_c(table_trie_step_char, "MR_TABLE_STEP_CHAR", no).
  table_trie_step_to_c(table_trie_step_string, "MR_TABLE_STEP_STRING", no).
  table_trie_step_to_c(table_trie_step_float, "MR_TABLE_STEP_FLOAT", no).
diff --git a/compiler/rtti_to_mlds.m b/compiler/rtti_to_mlds.m
index 55f177b6b..aa0f54422 100644
--- a/compiler/rtti_to_mlds.m
+++ b/compiler/rtti_to_mlds.m
@@ -1874,6 +1874,12 @@ add_rtti_defn_arcs_const(DefnDataName, Const, !Graph) :-
          ; Const = mlconst_false
          ; Const = mlconst_int(_)
          ; Const = mlconst_uint(_)
+        ; Const = mlconst_int8(_)
+        ; Const = mlconst_uint8(_)
+        ; Const = mlconst_int16(_)
+        ; Const = mlconst_uint16(_)
+        ; Const = mlconst_int32(_)
+        ; Const = mlconst_uint32(_)
          ; Const = mlconst_enum(_, _)
          ; Const = mlconst_char(_)
          ; Const = mlconst_foreign(_, _, _)
diff --git a/compiler/switch_gen.m b/compiler/switch_gen.m
index fe10858e2..52c8e58be 100644
--- a/compiler/switch_gen.m
+++ b/compiler/switch_gen.m
@@ -457,6 +457,12 @@ is_reserved_addr_tag(ConsTag) = IsReservedAddr :-
      ;
          ( ConsTag = int_tag(_)
          ; ConsTag = uint_tag(_)
+        ; ConsTag = int8_tag(_)
+        ; ConsTag = uint8_tag(_)
+        ; ConsTag = int16_tag(_)
+        ; ConsTag = uint16_tag(_)
+        ; ConsTag = int32_tag(_)
+        ; ConsTag = uint32_tag(_)
          ; ConsTag = float_tag(_)
          ; ConsTag = string_tag(_)
          ; ConsTag = foreign_tag(_, _)
diff --git a/compiler/switch_util.m b/compiler/switch_util.m
index 730e36910..e03022764 100644
--- a/compiler/switch_util.m
+++ b/compiler/switch_util.m
@@ -508,6 +508,12 @@ type_ctor_cat_to_switch_cat(CtorCat) = SwitchCat :-
          ( CtorCat = ctor_cat_enum(_)
          ; CtorCat = ctor_cat_builtin(cat_builtin_int)
          ; CtorCat = ctor_cat_builtin(cat_builtin_uint)
+        ; CtorCat = ctor_cat_builtin(cat_builtin_int8)
+        ; CtorCat = ctor_cat_builtin(cat_builtin_uint8)
+        ; CtorCat = ctor_cat_builtin(cat_builtin_int16)
+        ; CtorCat = ctor_cat_builtin(cat_builtin_uint16)
+        ; CtorCat = ctor_cat_builtin(cat_builtin_int32)
+        ; CtorCat = ctor_cat_builtin(cat_builtin_uint32)
          ; CtorCat = ctor_cat_builtin(cat_builtin_char)
          ),
          SwitchCat = atomic_switch
@@ -539,6 +545,12 @@ estimate_switch_tag_test_cost(Tag) = Cost :-
      (
          ( Tag = int_tag(_)
          ; Tag = uint_tag(_)
+        ; Tag = int8_tag(_)
+        ; Tag = uint8_tag(_)
+        ; Tag = int16_tag(_)
+        ; Tag = uint16_tag(_)
+        ; Tag = int32_tag(_)
+        ; Tag = uint32_tag(_)
          ; Tag = foreign_tag(_, _)
          ; Tag = reserved_address_tag(_)
          ; Tag = shared_local_tag(_, _)
@@ -1238,6 +1250,12 @@ get_ptag_counts_loop([Tag | Tags], !MaxPrimary, !PtagCountMap) :-
          ; Tag = float_tag(_)
          ; Tag = int_tag(_)
          ; Tag = uint_tag(_)
+        ; Tag = int8_tag(_)
+        ; Tag = uint8_tag(_)
+        ; Tag = int16_tag(_)
+        ; Tag = uint16_tag(_)
+        ; Tag = int32_tag(_)
+        ; Tag = uint32_tag(_)
          ; Tag = foreign_tag(_, _)
          ; Tag = closure_tag(_, _, _)
          ; Tag = type_ctor_info_tag(_, _, _)
@@ -1343,6 +1361,12 @@ group_case_by_ptag(CaseId, CaseRep, TaggedConsId,
          ; Tag = float_tag(_)
          ; Tag = int_tag(_)
          ; Tag = uint_tag(_)
+        ; Tag = int8_tag(_)
+        ; Tag = uint8_tag(_)
+        ; Tag = int16_tag(_)
+        ; Tag = uint16_tag(_)
+        ; Tag = int32_tag(_)
+        ; Tag = uint32_tag(_)
          ; Tag = foreign_tag(_, _)
          ; Tag = closure_tag(_, _, _)
          ; Tag = type_ctor_info_tag(_, _, _)
diff --git a/compiler/table_gen.m b/compiler/table_gen.m
index b2063c2a6..e309655ff 100644
--- a/compiler/table_gen.m
+++ b/compiler/table_gen.m
@@ -2471,6 +2471,12 @@ gen_lookup_call_for_type(ArgTablingMethod0, CtorCat, Type, ArgVar, VarSeqNum,
          ( CtorCat = ctor_cat_enum(_)
          ; CtorCat = ctor_cat_builtin(cat_builtin_int)
          ; CtorCat = ctor_cat_builtin(cat_builtin_uint)
+        ; CtorCat = ctor_cat_builtin(cat_builtin_int8)
+        ; CtorCat = ctor_cat_builtin(cat_builtin_uint8)
+        ; CtorCat = ctor_cat_builtin(cat_builtin_int16)
+        ; CtorCat = ctor_cat_builtin(cat_builtin_uint16)
+        ; CtorCat = ctor_cat_builtin(cat_builtin_int32)
+        ; CtorCat = ctor_cat_builtin(cat_builtin_uint32)
          ; CtorCat = ctor_cat_builtin(cat_builtin_char)
          ; CtorCat = ctor_cat_void
          ),
@@ -2566,6 +2572,30 @@ gen_lookup_call_for_type(ArgTablingMethod0, CtorCat, Type, ArgVar, VarSeqNum,
                  CatString = "uint",
                  Step = table_trie_step_uint
              ;
+                CtorCat = ctor_cat_builtin(cat_builtin_int8),
+                CatString = "int8",
+                Step = table_trie_step_int8
+            ;
+                CtorCat = ctor_cat_builtin(cat_builtin_uint8),
+                CatString = "uint8",
+                Step = table_trie_step_uint8
+            ;
+                CtorCat = ctor_cat_builtin(cat_builtin_int16),
+                CatString = "int16",
+                Step = table_trie_step_int16
+            ;
+                CtorCat = ctor_cat_builtin(cat_builtin_uint16),
+                CatString = "uint16",
+                Step = table_trie_step_uint16
+            ;
+                CtorCat = ctor_cat_builtin(cat_builtin_int32),
+                CatString = "int32",
+                Step = table_trie_step_int32
+            ;
+                CtorCat = ctor_cat_builtin(cat_builtin_uint32),
+                CatString = "uint32",
+                Step = table_trie_step_uint32
+            ;
                  CtorCat = ctor_cat_builtin(cat_builtin_char),
                  CatString = "char",
                  Step = table_trie_step_char
@@ -2626,6 +2656,24 @@ gen_lookup_call_for_type(ArgTablingMethod0, CtorCat, Type, ArgVar, VarSeqNum,
              CtorCat = ctor_cat_builtin(cat_builtin_uint),
              unexpected($module, $pred, "tabling uints by addr")
          ;
+            CtorCat = ctor_cat_builtin(cat_builtin_int8),
+            unexpected($module, $pred, "tabling int8s by addr")
+        ;
+            CtorCat = ctor_cat_builtin(cat_builtin_uint8),
+            unexpected($module, $pred, "tabling uint8s by addr")
+        ;
+            CtorCat = ctor_cat_builtin(cat_builtin_int16),
+            unexpected($module, $pred, "tabling int16s by addr")
+        ;
+            CtorCat = ctor_cat_builtin(cat_builtin_uint16),
+            unexpected($module, $pred, "tabling uint16s by addr")
+        ;
+            CtorCat = ctor_cat_builtin(cat_builtin_int32),
+            unexpected($module, $pred, "tabling int32s by addr")
+        ;
+            CtorCat = ctor_cat_builtin(cat_builtin_uint32),
+            unexpected($module, $pred, "tabling uint32s by addr")
+        ;
              CtorCat = ctor_cat_builtin(cat_builtin_char),
              unexpected($module, $pred, "tabling chars by addr")
          ;
@@ -3658,6 +3706,24 @@ type_save_category(CtorCat, Name) :-
          CtorCat = ctor_cat_builtin(cat_builtin_uint),
          Name = "uint"
      ;
+        CtorCat = ctor_cat_builtin(cat_builtin_int8),
+        Name = "int8"
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_uint8),
+        Name = "uint8"
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_int16),
+        Name = "int16"
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_uint16),
+        Name = "uint16"
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_int32),
+        Name = "int32"
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_uint32),
+        Name = "uint32"
+    ;
          CtorCat = ctor_cat_builtin(cat_builtin_float),
          Name = "float"
      ;
diff --git a/compiler/type_constraints.m b/compiler/type_constraints.m
index fcc90cf32..bb85e7ab8 100644
--- a/compiler/type_constraints.m
+++ b/compiler/type_constraints.m
@@ -2430,6 +2430,24 @@ type_to_string(TVarSet, Type, Name) :-
          Type = builtin_type(builtin_type_uint),
          Name = "uint"
      ;
+        Type = builtin_type(builtin_type_int8),
+        Name = "int8"
+    ;
+        Type = builtin_type(builtin_type_uint8),
+        Name = "uint8"
+    ;
+        Type = builtin_type(builtin_type_int16),
+        Name = "int16"
+    ;
+        Type = builtin_type(builtin_type_uint16),
+        Name = "uint16"
+    ;
+        Type = builtin_type(builtin_type_int32),
+        Name = "int32"
+    ;
+        Type = builtin_type(builtin_type_uint32),
+        Name = "uint32"
+    ;
          Type = builtin_type(builtin_type_float),
          Name = "float"
      ;
diff --git a/compiler/type_ctor_info.m b/compiler/type_ctor_info.m
index 70280f938..1d4c900e9 100644
--- a/compiler/type_ctor_info.m
+++ b/compiler/type_ctor_info.m
@@ -437,6 +437,12 @@ construct_type_ctor_info(TypeCtorGenInfo, ModuleInfo, RttiData) :-
  % to be done there as well.
  builtin_type_ctor("builtin", "int", 0, builtin_ctor_int).
  builtin_type_ctor("builtin", "uint", 0, builtin_ctor_uint).
+builtin_type_ctor("builtin", "int8", 0, builtin_ctor_int8).
+builtin_type_ctor("builtin", "uint8", 0, builtin_ctor_uint8).
+builtin_type_ctor("builtin", "int16", 0, builtin_ctor_int16).
+builtin_type_ctor("builtin", "uint16", 0, builtin_ctor_uint16).
+builtin_type_ctor("builtin", "int32", 0, builtin_ctor_int32).
+builtin_type_ctor("builtin", "uint32", 0, builtin_ctor_uint32).
  builtin_type_ctor("builtin", "string", 0, builtin_ctor_string).
  builtin_type_ctor("builtin", "float", 0, builtin_ctor_float).
  builtin_type_ctor("builtin", "character", 0, builtin_ctor_char).
@@ -490,7 +496,7 @@ impl_type_ctor("table_builtin", "ml_subgoal", 0, impl_ctor_subgoal).
      %
  :- func type_ctor_info_rtti_version = int.

-type_ctor_info_rtti_version = 17.
+type_ctor_info_rtti_version = 18.

  %---------------------------------------------------------------------------%

@@ -654,6 +660,12 @@ make_foreign_enum_functors(TypeCtor, Lang, [Functor | Functors], NextOrdinal,
          ; ConsTag = float_tag(_)
          ; ConsTag = int_tag(_)
          ; ConsTag = uint_tag(_)
+        ; ConsTag = int8_tag(_)
+        ; ConsTag = uint8_tag(_)
+        ; ConsTag = int16_tag(_)
+        ; ConsTag = uint16_tag(_)
+        ; ConsTag = int32_tag(_)
+        ; ConsTag = uint32_tag(_)
          ; ConsTag = closure_tag(_, _, _)
          ; ConsTag = type_ctor_info_tag(_, _, _)
          ; ConsTag = base_typeclass_info_tag(_, _, _)
@@ -836,6 +848,12 @@ get_maybe_reserved_rep(ConsTag, ConsRep) :-
          ; ConsTag = string_tag(_)
          ; ConsTag = int_tag(_)
          ; ConsTag = uint_tag(_)
+        ; ConsTag = int8_tag(_)
+        ; ConsTag = uint8_tag(_)
+        ; ConsTag = int16_tag(_)
+        ; ConsTag = uint16_tag(_)
+        ; ConsTag = int32_tag(_)
+        ; ConsTag = uint32_tag(_)
          ; ConsTag = foreign_tag(_, _)
          ; ConsTag = float_tag(_)
          ; ConsTag = closure_tag(_, _, _)
diff --git a/compiler/type_util.m b/compiler/type_util.m
index 79a71ce13..023c274cf 100644
--- a/compiler/type_util.m
+++ b/compiler/type_util.m
@@ -832,11 +832,29 @@ classify_type_ctor(ModuleInfo, TypeCtor) = TypeCategory :-
              TypeName = "character",
              TypeCategoryPrime = ctor_cat_builtin(cat_builtin_char)
          ;
+            TypeName = "int",
+            TypeCategoryPrime = ctor_cat_builtin(cat_builtin_int)
+        ;
              TypeName = "uint",
              TypeCategoryPrime = ctor_cat_builtin(cat_builtin_uint)
          ;
-            TypeName = "int",
-            TypeCategoryPrime = ctor_cat_builtin(cat_builtin_int)
+            TypeName = "int8",
+            TypeCategoryPrime = ctor_cat_builtin(cat_builtin_int8)
+        ;
+            TypeName = "uint8",
+            TypeCategoryPrime = ctor_cat_builtin(cat_builtin_uint8)
+        ;
+            TypeName = "int16",
+            TypeCategoryPrime = ctor_cat_builtin(cat_builtin_int16)
+        ;
+            TypeName = "uint16",
+            TypeCategoryPrime = ctor_cat_builtin(cat_builtin_uint16)
+        ;
+            TypeName = "int32",
+            TypeCategoryPrime = ctor_cat_builtin(cat_builtin_int32)
+        ;
+            TypeName = "uint32",
+            TypeCategoryPrime = ctor_cat_builtin(cat_builtin_uint32)
          ;
              TypeName = "float",
              TypeCategoryPrime = ctor_cat_builtin(cat_builtin_float)
@@ -958,6 +976,12 @@ type_may_use_atomic_alloc(ModuleInfo, Type) = TypeMayUseAtomic :-
      (
          ( TypeCategory = ctor_cat_builtin(cat_builtin_int)
          ; TypeCategory = ctor_cat_builtin(cat_builtin_uint)
+        ; TypeCategory = ctor_cat_builtin(cat_builtin_int8)
+        ; TypeCategory = ctor_cat_builtin(cat_builtin_uint8)
+        ; TypeCategory = ctor_cat_builtin(cat_builtin_int16)
+        ; TypeCategory = ctor_cat_builtin(cat_builtin_uint16)
+        ; TypeCategory = ctor_cat_builtin(cat_builtin_int32)
+        ; TypeCategory = ctor_cat_builtin(cat_builtin_uint32)
          ; TypeCategory = ctor_cat_builtin(cat_builtin_char)
          ; TypeCategory = ctor_cat_enum(_)
          ; TypeCategory = ctor_cat_builtin_dummy
diff --git a/compiler/typecheck.m b/compiler/typecheck.m
index 5ccd2fccb..bedf22e8e 100644
--- a/compiler/typecheck.m
+++ b/compiler/typecheck.m
@@ -2240,6 +2240,30 @@ cons_id_must_be_builtin_type(ConsId, ConsType, BuiltinTypeName) :-
          BuiltinTypeName = "uint",
          BuiltinType = builtin_type_uint
      ;
+        ConsId = int8_const(_),
+        BuiltinTypeName = "int8",
+        BuiltinType = builtin_type_int8
+    ;
+        ConsId = uint8_const(_),
+        BuiltinTypeName = "uint8",
+        BuiltinType = builtin_type_uint8
+    ;
+        ConsId = int16_const(_),
+        BuiltinTypeName = "int16",
+        BuiltinType = builtin_type_int16
+    ;
+        ConsId = uint16_const(_),
+        BuiltinTypeName = "uint16",
+        BuiltinType = builtin_type_uint16
+    ;
+        ConsId = int32_const(_),
+        BuiltinTypeName = "int32",
+        BuiltinType = builtin_type_int32
+    ;
+        ConsId = uint32_const(_),
+        BuiltinTypeName = "uint32",
+        BuiltinType = builtin_type_uint32
+    ;
          ConsId = float_const(_),
          BuiltinTypeName = "float",
          BuiltinType = builtin_type_float
@@ -2774,6 +2798,12 @@ type_assign_unify_type(X, Y, TypeAssign0, TypeAssign) :-

  builtin_atomic_type(int_const(_), "int").
  builtin_atomic_type(uint_const(_), "uint").
+builtin_atomic_type(int8_const(_), "int8").
+builtin_atomic_type(uint8_const(_), "uint8").
+builtin_atomic_type(int16_const(_), "int16").
+builtin_atomic_type(uint16_const(_), "uint16").
+builtin_atomic_type(int32_const(_), "int32").
+builtin_atomic_type(uint32_const(_), "uint32").
  builtin_atomic_type(float_const(_), "float").
  builtin_atomic_type(char_const(_), "character").
  builtin_atomic_type(string_const(_), "string").
diff --git a/compiler/unify_gen.m b/compiler/unify_gen.m
index 6ec77d931..9397275f3 100644
--- a/compiler/unify_gen.m
+++ b/compiler/unify_gen.m
@@ -423,6 +423,24 @@ raw_tag_test(Rval, ConsTag, TestRval) :-
          ConsTag = uint_tag(UInt),
          TestRval = binop(uint_eq, Rval, const(llconst_uint(UInt)))
      ;
+        ConsTag = int8_tag(Int8),
+        TestRval = binop(int8_eq, Rval, const(llconst_int8(Int8)))
+    ;
+        ConsTag = uint8_tag(UInt8),
+        TestRval = binop(uint8_eq, Rval, const(llconst_uint8(UInt8)))
+    ;
+        ConsTag = int16_tag(Int16),
+        TestRval = binop(int16_eq, Rval, const(llconst_int16(Int16)))
+    ;
+        ConsTag = uint16_tag(UInt16),
+        TestRval = binop(uint16_eq, Rval, const(llconst_uint16(UInt16)))
+    ;
+        ConsTag = int32_tag(Int32),
+        TestRval = binop(int32_eq, Rval, const(llconst_int32(Int32)))
+    ;
+        ConsTag = uint32_tag(UInt32),
+        TestRval = binop(uint32_eq, Rval, const(llconst_uint32(UInt32)))
+    ;
          ConsTag = foreign_tag(ForeignLang, ForeignVal),
          expect(unify(ForeignLang, lang_c), $module, $pred,
              "foreign tag for language other than C"),
@@ -558,6 +576,30 @@ generate_construction_2(ConsTag, LHSVar, RHSVars, ArgModes, ArgWidths,
          assign_const_to_var(LHSVar, const(llconst_uint(UInt)), !.CI, !CLD),
          Code = empty
      ;
+        ConsTag = int8_tag(Int8),
+        assign_const_to_var(LHSVar, const(llconst_int8(Int8)), !.CI, !CLD),
+        Code = empty
+    ;
+        ConsTag = uint8_tag(UInt8),
+        assign_const_to_var(LHSVar, const(llconst_uint8(UInt8)), !.CI, !CLD),
+        Code = empty
+    ;
+        ConsTag = int16_tag(Int16),
+        assign_const_to_var(LHSVar, const(llconst_int16(Int16)), !.CI, !CLD),
+        Code = empty
+    ;
+        ConsTag = uint16_tag(UInt16),
+        assign_const_to_var(LHSVar, const(llconst_uint16(UInt16)), !.CI, !CLD),
+        Code = empty
+    ;
+        ConsTag = int32_tag(Int32),
+        assign_const_to_var(LHSVar, const(llconst_int32(Int32)), !.CI, !CLD),
+        Code = empty
+    ;
+        ConsTag = uint32_tag(UInt32),
+        assign_const_to_var(LHSVar, const(llconst_uint32(UInt32)), !.CI, !CLD),
+        Code = empty
+    ;
          ConsTag = foreign_tag(Lang, Val),
          expect(unify(Lang, lang_c), $module, $pred,
              "foreign_tag for language other than C"),
@@ -1304,6 +1346,12 @@ generate_det_deconstruction_2(Var, Cons, Args, Modes, ArgWidths, Tag,
          ( Tag = string_tag(_String)
          ; Tag = int_tag(_Int)
          ; Tag = uint_tag(_UInt)
+        ; Tag = int8_tag(_Int8)
+        ; Tag = uint8_tag(_UInt8)
+        ; Tag = int16_tag(_Int16)
+        ; Tag = uint16_tag(_UInt16)
+        ; Tag = int32_tag(_Int32)
+        ; Tag = uint32_tag(_UInt32)
          ; Tag = foreign_tag(_, _)
          ; Tag = float_tag(_Float)
          ; Tag = closure_tag(_, _, _)
@@ -1807,6 +1855,12 @@ generate_const_struct_rval(ModuleInfo, UnboxedFloats, ConstStructMap,
          ( ConsTag = string_tag(_)
          ; ConsTag = int_tag(_)
          ; ConsTag = uint_tag(_)
+        ; ConsTag = int8_tag(_)
+        ; ConsTag = uint8_tag(_)
+        ; ConsTag = int16_tag(_)
+        ; ConsTag = uint16_tag(_)
+        ; ConsTag = int32_tag(_)
+        ; ConsTag = uint32_tag(_)
          ; ConsTag = foreign_tag(_, _)
          ; ConsTag = float_tag(_)
          ; ConsTag = shared_local_tag(_, _)
@@ -1869,6 +1923,30 @@ generate_const_struct_arg_tag(ModuleInfo, UnboxedFloats, ConstStructMap,
              Const = llconst_uint(UInt),
              Type = lt_unsigned
          ;
+            ConsTag = int8_tag(Int8),
+            Const = llconst_int8(Int8),
+            Type = lt_int8
+        ;
+            ConsTag = uint8_tag(UInt8),
+            Const = llconst_uint8(UInt8),
+            Type = lt_uint8
+        ;
+            ConsTag = int16_tag(Int16),
+            Const = llconst_int16(Int16),
+            Type = lt_int16
+        ;
+            ConsTag = uint16_tag(UInt16),
+            Const = llconst_uint16(UInt16),
+            Type = lt_uint16
+        ;
+            ConsTag = int32_tag(Int32),
+            Const = llconst_int32(Int32),
+            Type = lt_int32
+        ;
+            ConsTag = uint32_tag(UInt32),
+            Const = llconst_uint32(UInt32),
+            Type = lt_uint32
+        ;
              ConsTag = foreign_tag(Lang, Val),
              expect(unify(Lang, lang_c), $module, $pred,
                  "foreign_tag for language other than C"),
@@ -2050,6 +2128,30 @@ generate_ground_term_conjunct_tag(Var, ConsTag, Args, ConsArgWidths,
              Const = llconst_uint(UInt),
              Type = lt_unsigned
          ;
+            ConsTag = int8_tag(Int8),
+            Const = llconst_int8(Int8),
+            Type = lt_int8
+        ;
+            ConsTag = uint8_tag(UInt8),
+            Const = llconst_uint8(UInt8),
+            Type = lt_uint8
+        ;
+            ConsTag = int16_tag(Int16),
+            Const = llconst_int16(Int16),
+            Type = lt_int16
+        ;
+            ConsTag = uint16_tag(UInt16),
+            Const = llconst_uint16(UInt16),
+            Type = lt_uint16
+        ;
+            ConsTag = int32_tag(Int32),
+            Const = llconst_int32(Int32),
+            Type = lt_int32
+        ;
+            ConsTag = uint32_tag(UInt32),
+            Const = llconst_uint32(UInt32),
+            Type = lt_uint32
+        ;
              ConsTag = foreign_tag(Lang, Val),
              expect(unify(Lang, lang_c), $module, $pred,
                  "foreign_tag for language other than C"),
diff --git a/compiler/unify_proc.m b/compiler/unify_proc.m
index bc4e70806..00f642551 100644
--- a/compiler/unify_proc.m
+++ b/compiler/unify_proc.m
@@ -688,6 +688,24 @@ generate_builtin_unify(CtorCat, X, Y, Context, Clause, !Info) :-
          CtorCat = ctor_cat_builtin(cat_builtin_uint),
          Name = "builtin_unify_uint"
      ;
+        CtorCat = ctor_cat_builtin(cat_builtin_int8),
+        Name = "builtin_unify_int8"
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_uint8),
+        Name = "builtin_unify_uint8"
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_int16),
+        Name = "builtin_unify_int16"
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_uint16),
+        Name = "builtin_unify_uint16"
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_int32),
+        Name = "builtin_unify_int32"
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_uint32),
+        Name = "builtin_unify_uint32"
+    ;
          CtorCat = ctor_cat_builtin(cat_builtin_char),
          Name = "builtin_unify_character"
      ;
@@ -1007,6 +1025,24 @@ generate_builtin_compare(CtorCat, Res, X, Y, Context, Clause, !Info) :-
          CtorCat = ctor_cat_builtin(cat_builtin_uint),
          Name = "builtin_compare_uint"
      ;
+        CtorCat = ctor_cat_builtin(cat_builtin_int8),
+        Name = "builtin_compare_int8"
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_uint8),
+        Name = "builtin_compare_uint8"
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_int16),
+        Name = "builtin_compare_int16"
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_uint16),
+        Name = "builtin_compare_uint16"
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_int32),
+        Name = "builtin_compare_int32"
+    ;
+        CtorCat = ctor_cat_builtin(cat_builtin_uint32),
+        Name = "builtin_compare_uint32"
+    ;
          CtorCat = ctor_cat_builtin(cat_builtin_char),
          Name = "builtin_compare_character"
      ;
diff --git a/compiler/unused_imports.m b/compiler/unused_imports.m
index a13211acf..abafd817d 100644
--- a/compiler/unused_imports.m
+++ b/compiler/unused_imports.m
@@ -802,6 +802,12 @@ cons_id_used_modules(Visibility, ConsId, !UsedModules) :-
          ; ConsId = closure_cons(_, _)
          ; ConsId = int_const(_)
          ; ConsId = uint_const(_)
+        ; ConsId = int8_const(_)
+        ; ConsId = uint8_const(_)
+        ; ConsId = int16_const(_)
+        ; ConsId = uint16_const(_)
+        ; ConsId = int32_const(_)
+        ; ConsId = uint32_const(_)
          ; ConsId = float_const(_)
          ; ConsId = char_const(_)
          ; ConsId = string_const(_)
@@ -834,6 +840,12 @@ mer_type_used_modules(Visibility, Type, !UsedModules) :-
          (
              ( BuiltinType = builtin_type_int
              ; BuiltinType = builtin_type_uint
+            ; BuiltinType = builtin_type_int8
+            ; BuiltinType = builtin_type_uint8
+            ; BuiltinType = builtin_type_int16
+            ; BuiltinType = builtin_type_uint16
+            ; BuiltinType = builtin_type_int32
+            ; BuiltinType = builtin_type_uint32
              ; BuiltinType = builtin_type_float
              ; BuiltinType = builtin_type_string
              )
diff --git a/compiler/xml_documentation.m b/compiler/xml_documentation.m
index f3ea57092..19e047f43 100644
--- a/compiler/xml_documentation.m
+++ b/compiler/xml_documentation.m
@@ -457,6 +457,12 @@ mer_type_to_xml(TVarset, defined_type(TypeName, Args, _)) = Xml :-
      Xml = elem("type", [Ref], [XmlName, XmlArgs]).
  mer_type_to_xml(_, builtin_type(builtin_type_int)) = elem("int", [], []).
  mer_type_to_xml(_, builtin_type(builtin_type_uint)) = elem("uint", [], []).
+mer_type_to_xml(_, builtin_type(builtin_type_int8)) = elem("int8", [], []).
+mer_type_to_xml(_, builtin_type(builtin_type_uint8)) = elem("uint8", [], []).
+mer_type_to_xml(_, builtin_type(builtin_type_int16)) = elem("int16", [], []).
+mer_type_to_xml(_, builtin_type(builtin_type_uint16)) = elem("uint16", [], []).
+mer_type_to_xml(_, builtin_type(builtin_type_int32)) = elem("int32", [], []).
+mer_type_to_xml(_, builtin_type(builtin_type_uint32)) = elem("uint32", [], []).
  mer_type_to_xml(_, builtin_type(builtin_type_float)) = elem("float", [], []).
  mer_type_to_xml(_, builtin_type(builtin_type_string)) = elem("string", [], []).
  mer_type_to_xml(_, builtin_type(builtin_type_char)) =
@@ -688,6 +694,18 @@ cons_id_to_xml(tuple_cons(Arity)) =
  cons_id_to_xml(int_const(I)) = tagged_int("int", I).
  cons_id_to_xml(uint_const(_)) = _ :-
      unexpected($file, $pred, "NYI uint").
+cons_id_to_xml(int8_const(_)) = _ :-
+    unexpected($file, $pred, "NYI int8").
+cons_id_to_xml(uint8_const(_)) = _ :-
+    unexpected($file, $pred, "NYI uint8").
+cons_id_to_xml(int16_const(_)) = _ :-
+    unexpected($file, $pred, "NYI int16").
+cons_id_to_xml(uint16_const(_)) = _ :-
+    unexpected($file, $pred, "NYI uint16").
+cons_id_to_xml(int32_const(_)) = _ :-
+    unexpected($file, $pred, "NYI int32").
+cons_id_to_xml(uint32_const(_)) = _ :-
+    unexpected($file, $pred, "NYI uint32").
  cons_id_to_xml(float_const(F)) = tagged_float("float", F).
  cons_id_to_xml(char_const(C)) = tagged_char("char", C).
  cons_id_to_xml(string_const(S)) = tagged_string("string", S).
diff --git a/configure.ac b/configure.ac
index 4f043572d..e3a9331eb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1388,7 +1388,7 @@ MERCURY_CHECK_FOR_HEADERS( \
          sys/types.h sys/stat.h fcntl.h termios.h sys/ioctl.h \
          sys/resource.h sys/stropts.h windows.h dirent.h getopt.h malloc.h \
          semaphore.h pthread.h time.h spawn.h fenv.h sys/mman.h sys/sem.h \
-        sched.h utmpx.h dispatch/dispatch.h)
+        sched.h utmpx.h dispatch/dispatch.h stdint.h)

  if test "$MR_HAVE_GETOPT_H" = 1; then
      GETOPT_H_AVAILABLE=yes
diff --git a/deep_profiler/program_representation_utils.m b/deep_profiler/program_representation_utils.m
index 848431274..ec17e8816 100644
--- a/deep_profiler/program_representation_utils.m
+++ b/deep_profiler/program_representation_utils.m
@@ -304,6 +304,24 @@ type_rep_to_strings(TypeRep, Cord) :-
              BuiltinTypeRep = builtin_type_uint_rep,
              TypeNameStr = "uint"
          ;
+            BuiltinTypeRep = builtin_type_int8_rep,
+            TypeNameStr = "int8"
+        ;
+            BuiltinTypeRep = builtin_type_uint8_rep,
+            TypeNameStr = "uint8"
+        ;
+            BuiltinTypeRep = builtin_type_int16_rep,
+            TypeNameStr = "int16"
+        ;
+            BuiltinTypeRep = builtin_type_uint16_rep,
+            TypeNameStr = "uint16"
+        ;
+            BuiltinTypeRep = builtin_type_int32_rep,
+            TypeNameStr = "int32"
+        ;
+            BuiltinTypeRep = builtin_type_uint32_rep,
+            TypeNameStr = "uint32"
+        ;
              BuiltinTypeRep = builtin_type_float_rep,
              TypeNameStr = "float"
          ;
diff --git a/doc/reference_manual.texi b/doc/reference_manual.texi
index 751ba728f..e837e9ecd 100644
--- a/doc/reference_manual.texi
+++ b/doc/reference_manual.texi
@@ -2185,7 +2185,13 @@ that have meanings in Mercury.
  The list of reserved type names is
  @example
  int
+int8
+int16
+int32
  uint
+uint8
+uint16
+uint32
  float
  character
  string
@@ -7130,7 +7136,13 @@ The Mercury primitive types are mapped to the following C types:
  @multitable {Mercury_type} {MR_Unsigned}
  @headitem Mercury type @tab C type
    @item @code{int}    @tab @code{MR_Integer}
+ at c  @item @code{int8}   @tab @code{int8_t}
+ at c  @item @code{int16}  @tab @code{int16_t}
+ at c  @item @code{int32}  @tab @code{int32_t}
    @item @code{uint}   @tab @code{MR_Unsigned}
+ at c  @item @code{uint8}   @tab @code{uint8_t}
+ at c  @item @code{uint16}  @tab @code{uint16_t}
+ at c  @item @code{uint32}  @tab @code{uint32_t}
    @item @code{float}  @tab @code{MR_Float}
    @item @code{char}   @tab @code{MR_Char}
    @item @code{string} @tab @code{MR_String}
@@ -7221,7 +7233,13 @@ Infrastructure (CLI) and C# types:
  @multitable {Mercury_type} {System_String} {double}
    @headitem Mercury type @tab CLI type @tab C# type
    @item @code{int}    @tab @code{System.Int32}  @tab @code{int}
+ at c  @item @code{int8}   @tab @code{System.Int8}   @tab @code{sbyte}
+ at c  @item @code{int16}  @tab @code{System.Int16}  @tab @code{short}
+ at c  @item @code{int32}  @tab @code{System.Int32}  @tab @code{int}
    @item @code{uint}   @tab @code{System.UInt32} @tab @code{uint}
+ at c  @item @code{uint8}   @tab @code{System.UInt8}   @tab @code{byte}
+ at c  @item @code{uint16}  @tab @code{System.UInt16}  @tab @code{ushort}
+ at c  @item @code{uint32}  @tab @code{System.UInt32}  @tab @code{uint}
    @item @code{float}  @tab @code{System.Double} @tab @code{double}
    @item @code{char}   @tab @code{System.Int32}  @tab @code{int}
    @item @code{string} @tab @code{System.String} @tab @code{string}
@@ -7344,7 +7362,13 @@ The Mercury primitive types are mapped to the following Java types:
  @multitable {Mercury_type} {java_lang_String}
    @headitem Mercury type @tab Java type
    @item @code{int}    @tab @code{int}
+ at c  @item @code{int8}   @tab @code{byte}
+ at c  @item @code{int16}  @tab @code{short}
+ at c  @item @code{int32}  @tab @code{int}
    @item @code{uint}   @tab @code{int}
+ at c  @item @code{uint8}   @tab @code{byte}
+ at c  @item @code{uint16}  @tab @code{short}
+ at c  @item @code{uint32}  @tab @code{int}
    @item @code{float}  @tab @code{double}
    @item @code{char}   @tab @code{int}
    @item @code{string} @tab @code{java.lang.String}
diff --git a/java/runtime/TypeCtorRep.java b/java/runtime/TypeCtorRep.java
index 5ab0d247e..ca9d7ee5e 100644
--- a/java/runtime/TypeCtorRep.java
+++ b/java/runtime/TypeCtorRep.java
@@ -15,7 +15,7 @@ public class TypeCtorRep implements java.io.Serializable {
  	// should generate references to these constants instead of those in
  	// private_builtin.
  	public static final int MR_TYPECTOR_REP_EQUIV		= 6;
-	public static final int MR_TYPECTOR_REP_EQUIV_GROUND	= 30;
+	public static final int MR_TYPECTOR_REP_EQUIV_GROUND	= 36;

  	// Instance variable for TypeCtorRep objects.

diff --git a/library/MODULES_UNDOC b/library/MODULES_UNDOC
index b1cd56fbc..edc4b9847 100644
--- a/library/MODULES_UNDOC
+++ b/library/MODULES_UNDOC
@@ -1,6 +1,9 @@
  backjump.m
  erlang_builtin.m
  erlang_rtti_implementation.m
+int8.m
+int16.m
+int32.m
  mer_std.m
  mutvar.m
  par_builtin.m
@@ -17,3 +20,6 @@ string.to_string.m
  table_builtin.m
  term_size_prof_builtin.m
  test_bitset.m
+uint8.m
+uint16.m
+uint32.m
diff --git a/library/construct.m b/library/construct.m
index 17566e08a..815c15c56 100644
--- a/library/construct.m
+++ b/library/construct.m
@@ -459,6 +459,12 @@ get_functor_ordinal(TypeDesc, FunctorNumber, Ordinal) :-
          case MR_TYPECTOR_REP_PRED:
          case MR_TYPECTOR_REP_INT:
          case MR_TYPECTOR_REP_UINT:
+        case MR_TYPECTOR_REP_INT8:
+        case MR_TYPECTOR_REP_UINT8:
+        case MR_TYPECTOR_REP_INT16:
+        case MR_TYPECTOR_REP_UINT16:
+        case MR_TYPECTOR_REP_INT32:
+        case MR_TYPECTOR_REP_UINT32:
          case MR_TYPECTOR_REP_FLOAT:
          case MR_TYPECTOR_REP_CHAR:
          case MR_TYPECTOR_REP_STRING:
@@ -900,6 +906,42 @@ find_functor_2(TypeInfo, Functor, Arity, Num0, FunctorNumber, ArgTypes) :-
                  ""cannot construct uint with construct.construct"");
              break;

+        case MR_TYPECTOR_REP_INT8:
+            /* int8s don't have functor ordinals. */
+            MR_fatal_error(
+                ""cannot construct int8 with construct.construct"");
+            break;
+
+        case MR_TYPECTOR_REP_UINT8:
+            /* uint8s don't have functor ordinals. */
+            MR_fatal_error(
+                ""cannot construct uint8 with construct.construct"");
+            break;
+
+        case MR_TYPECTOR_REP_INT16:
+            /* int16s don't have functor ordinals. */
+            MR_fatal_error(
+                ""cannot construct int16 with construct.construct"");
+            break;
+
+        case MR_TYPECTOR_REP_UINT16:
+            /* uint16s don't have functor ordinals. */
+            MR_fatal_error(
+                ""cannot construct uint16 with construct.construct"");
+            break;
+
+        case MR_TYPECTOR_REP_INT32:
+            /* int32s don't have functor ordinals. */
+            MR_fatal_error(
+                ""cannot construct int32 with construct.construct"");
+            break;
+
+        case MR_TYPECTOR_REP_UINT32:
+            /* uint32s don't have functor ordinals. */
+            MR_fatal_error(
+                ""cannot construct uint32 with construct.construct"");
+            break;
+
          case MR_TYPECTOR_REP_FLOAT:
              /* floats don't have functor ordinals. */
              MR_fatal_error(
diff --git a/library/erlang_rtti_implementation.m b/library/erlang_rtti_implementation.m
index 156bd7a83..0910c8474 100644
--- a/library/erlang_rtti_implementation.m
+++ b/library/erlang_rtti_implementation.m
@@ -167,6 +167,12 @@
      ;       etcr_eqv
      ;       etcr_int
      ;       etcr_uint
+    ;       etcr_int8
+    ;       etcr_uint8
+    ;       etcr_int16
+    ;       etcr_uint16
+    ;       etcr_int32
+    ;       etcr_uint32
      ;       etcr_float
      ;       etcr_char
      ;       etcr_string
@@ -832,6 +838,42 @@ deconstruct_2(Term, TypeInfo, TypeCtorInfo, TypeCtorRep, NonCanon,
          Arity = 0,
          Arguments = []
      ;
+        TypeCtorRep = etcr_int8,
+        Functor = "<<int8>>",   % XXX FIXED SIZE INT
+        FunctorNumber = 0,
+        Arity = 0,
+        Arguments = []
+    ;
+        TypeCtorRep = etcr_uint8,
+        Functor = "<<uint8>>",  % XXX FIXED SIZE INT
+        FunctorNumber = 0,
+        Arity = 0,
+        Arguments = []
+    ;
+        TypeCtorRep = etcr_int16,
+        Functor = "<<int16>>",   % XXX FIXED SIZE INT
+        FunctorNumber = 0,
+        Arity = 0,
+        Arguments = []
+    ;
+        TypeCtorRep = etcr_uint16,
+        Functor = "<<uint16>>",  % XXX FIXED SIZE INT
+        FunctorNumber = 0,
+        Arity = 0,
+        Arguments = []
+    ;
+        TypeCtorRep = etcr_int32,
+        Functor = "<<int32>>",   % XXX FIXED SIZE INT
+        FunctorNumber = 0,
+        Arity = 0,
+        Arguments = []
+    ;
+        TypeCtorRep = etcr_uint32,
+        Functor = "<<uint32>>",  % XXX FIXED SIZE INT
+        FunctorNumber = 0,
+        Arity = 0,
+        Arguments = []
+    ;
          TypeCtorRep = etcr_float,
          det_dynamic_cast(Term, Float),
          Functor = float_to_string(Float),
@@ -1193,6 +1235,12 @@ num_functors(TypeInfo, MaybeNumFunctors) :-
          ( TypeCtorRep = etcr_array
          ; TypeCtorRep = etcr_int
          ; TypeCtorRep = etcr_uint
+        ; TypeCtorRep = etcr_int8
+        ; TypeCtorRep = etcr_uint8
+        ; TypeCtorRep = etcr_int16
+        ; TypeCtorRep = etcr_uint16
+        ; TypeCtorRep = etcr_int32
+        ; TypeCtorRep = etcr_uint32
          ; TypeCtorRep = etcr_float
          ; TypeCtorRep = etcr_char
          ; TypeCtorRep = etcr_string
@@ -1311,6 +1359,12 @@ get_functor_with_names(TypeInfo, NumFunctor) = Result :-
          ( TypeCtorRep = etcr_array
          ; TypeCtorRep = etcr_int
          ; TypeCtorRep = etcr_uint
+        ; TypeCtorRep = etcr_int8
+        ; TypeCtorRep = etcr_uint8
+        ; TypeCtorRep = etcr_int16
+        ; TypeCtorRep = etcr_uint16
+        ; TypeCtorRep = etcr_int32
+        ; TypeCtorRep = etcr_uint32
          ; TypeCtorRep = etcr_float
          ; TypeCtorRep = etcr_char
          ; TypeCtorRep = etcr_string
@@ -1464,6 +1518,12 @@ construct(TypeDesc, Index, Args) = Term :-
          ; TypeCtorRep = etcr_eqv
          ; TypeCtorRep = etcr_int
          ; TypeCtorRep = etcr_uint
+        ; TypeCtorRep = etcr_int8
+        ; TypeCtorRep = etcr_uint8
+        ; TypeCtorRep = etcr_int16
+        ; TypeCtorRep = etcr_uint16
+        ; TypeCtorRep = etcr_int32
+        ; TypeCtorRep = etcr_uint32
          ; TypeCtorRep = etcr_float
          ; TypeCtorRep = etcr_char
          ; TypeCtorRep = etcr_string
diff --git a/library/int16.m b/library/int16.m
new file mode 100644
index 000000000..a0e1499f8
--- /dev/null
+++ b/library/int16.m
@@ -0,0 +1,20 @@
+%---------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
+%---------------------------------------------------------------------------%
+% Copyright (C) 2017 The Mercury team.
+% This file may only be copied under the terms of the GNU Library General
+% Public License - see the file COPYING.LIB in the Mercury distribution.
+%---------------------------------------------------------------------------%
+
+:- module int16.
+:- interface.
+
+    % int16s are NYI -- this module is just a placeholder for their
+    % library support.
+    %
+:- type placeholder_int16 ---> placeholder_int16.
+
+%---------------------------------------------------------------------------%
+:- end_module int16.
+%---------------------------------------------------------------------------%
+
diff --git a/library/int32.m b/library/int32.m
new file mode 100644
index 000000000..da40d0290
--- /dev/null
+++ b/library/int32.m
@@ -0,0 +1,20 @@
+%---------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
+%---------------------------------------------------------------------------%
+% Copyright (C) 2017 The Mercury team.
+% This file may only be copied under the terms of the GNU Library General
+% Public License - see the file COPYING.LIB in the Mercury distribution.
+%---------------------------------------------------------------------------%
+
+:- module int32.
+:- interface.
+
+    % int32s are NYI -- this module is just a placeholder for their
+    % library support.
+    %
+:- type placeholder_int32 ---> placeholder_int32.
+
+%---------------------------------------------------------------------------%
+:- end_module int32.
+%---------------------------------------------------------------------------%
+
diff --git a/library/int8.m b/library/int8.m
new file mode 100644
index 000000000..4144652ca
--- /dev/null
+++ b/library/int8.m
@@ -0,0 +1,20 @@
+%---------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
+%---------------------------------------------------------------------------%
+% Copyright (C) 2017 The Mercury team.
+% This file may only be copied under the terms of the GNU Library General
+% Public License - see the file COPYING.LIB in the Mercury distribution.
+%---------------------------------------------------------------------------%
+
+:- module int8.
+:- interface.
+
+    % int8s are NYI -- this module is just a placeholder for their
+    % library support.
+    %
+:- type placeholder_int8 ---> placeholder_int8.
+
+%---------------------------------------------------------------------------%
+:- end_module int8.
+%---------------------------------------------------------------------------%
+
diff --git a/library/library.m b/library/library.m
index 2c42f8e5b..0fa1ca353 100644
--- a/library/library.m
+++ b/library/library.m
@@ -95,6 +95,9 @@
  :- import_module hash_table.
  :- import_module injection.
  :- import_module int.
+:- import_module int8.
+:- import_module int16.
+:- import_module int32.
  :- import_module integer.
  :- import_module io.
  :- import_module lazy.
@@ -149,6 +152,9 @@
  :- import_module tree_bitset.
  :- import_module type_desc.
  :- import_module uint.
+:- import_module uint8.
+:- import_module uint16.
+:- import_module uint32.
  :- import_module unit.
  :- import_module univ.
  :- import_module varset.
@@ -266,6 +272,9 @@ mercury_std_library_module("getopt_io").
  mercury_std_library_module("hash_table").
  mercury_std_library_module("injection").
  mercury_std_library_module("int").
+mercury_std_library_module("int8").
+mercury_std_library_module("int16").
+mercury_std_library_module("int32").
  mercury_std_library_module("integer").
  mercury_std_library_module("io").
  mercury_std_library_module("lazy").
@@ -338,6 +347,9 @@ mercury_std_library_module("tree234").
  mercury_std_library_module("tree_bitset").
  mercury_std_library_module("type_desc").
  mercury_std_library_module("uint").
+mercury_std_library_module("uint8").
+mercury_std_library_module("uint16").
+mercury_std_library_module("uint32").
  mercury_std_library_module("unit").
  mercury_std_library_module("univ").
  mercury_std_library_module("varset").
diff --git a/library/private_builtin.m b/library/private_builtin.m
index d70f60b0e..265fe0a2d 100644
--- a/library/private_builtin.m
+++ b/library/private_builtin.m
@@ -51,6 +51,24 @@
  :- pred builtin_unify_uint(uint::in, uint::in) is semidet.
  :- pred builtin_compare_uint(comparison_result::uo, uint::in, uint::in) is det.

+:- pred builtin_unify_int8(T::in, T::in) is semidet.
+:- pred builtin_compare_int8(comparison_result::uo, T::in, T::in) is det.
+
+:- pred builtin_unify_uint8(T::in, T::in) is semidet.
+:- pred builtin_compare_uint8(comparison_result::uo, T::in, T::in) is det.
+
+:- pred builtin_unify_int16(T::in, T::in) is semidet.
+:- pred builtin_compare_int16(comparison_result::uo, T::in, T::in) is det.
+
+:- pred builtin_unify_uint16(T::in, T::in) is semidet.
+:- pred builtin_compare_uint16(comparison_result::uo, T::in, T::in) is det.
+
+:- pred builtin_unify_int32(T::in, T::in) is semidet.
+:- pred builtin_compare_int32(comparison_result::uo, T::in, T::in) is det.
+
+:- pred builtin_unify_uint32(T::in, T::in) is semidet.
+:- pred builtin_compare_uint32(comparison_result::uo, T::in, T::in) is det.
+
  :- pred builtin_unify_character(character::in, character::in) is semidet.
  :- pred builtin_compare_character(comparison_result::uo, character::in,
      character::in) is det.
@@ -180,6 +198,90 @@ builtin_compare_uint(R, X, Y) :-
          R = (>)
      ).

+builtin_unify_int8(_, _) :-
+    ( if semidet_succeed then
+        sorry("unify for int8")
+    else
+        semidet_succeed
+    ).
+
+builtin_compare_int8(R, _, _) :-
+    ( if semidet_succeed then
+        sorry("compare for int8")
+    else
+        R = (=)
+    ).
+
+builtin_unify_uint8(_, _) :-
+    ( if semidet_succeed then
+        sorry("unify for uint8")
+    else
+        semidet_succeed
+    ).
+
+builtin_compare_uint8(R, _, _) :-
+    ( if semidet_succeed then
+        sorry("compare for uint8")
+    else
+        R = (=)
+    ).
+
+builtin_unify_int16(_, _) :-
+    ( if semidet_succeed then
+        sorry("unify for int16")
+    else
+        semidet_succeed
+    ).
+
+builtin_compare_int16(R, _, _) :-
+    ( if semidet_succeed then
+        sorry("compare for int16")
+    else
+        R = (=)
+    ).
+
+builtin_unify_uint16(_, _) :-
+    ( if semidet_succeed then
+        sorry("unify for uint16")
+    else
+        semidet_succeed
+    ).
+
+builtin_compare_uint16(R, _, _) :-
+    ( if semidet_succeed then
+        sorry("compare for uint16")
+    else
+        R = (=)
+    ).
+
+builtin_unify_int32(_, _) :-
+    ( if semidet_succeed then
+        sorry("unify for int32")
+    else
+        semidet_succeed
+    ).
+
+builtin_compare_int32(R, _, _) :-
+    ( if semidet_succeed then
+        sorry("compare for int32")
+    else
+        R = (=)
+    ).
+
+builtin_unify_uint32(_, _) :-
+    ( if semidet_succeed then
+        sorry("unify for uint32")
+    else
+        semidet_succeed
+    ).
+
+builtin_compare_uint32(R, _, _) :-
+    ( if semidet_succeed then
+        sorry("compare for uint32")
+    else
+        R = (=)
+    ).
+
  builtin_unify_character(C, C).

  builtin_compare_character(R, X, Y) :-
@@ -1724,45 +1826,51 @@ const MR_FA_TypeInfo_Struct1 ML_type_info_for_list_of_pseudo_type_info = {
      public static final int MR_TYPECTOR_REP_FUNC                    = 7;
      public static final int MR_TYPECTOR_REP_INT                     = 8;
      public static final int MR_TYPECTOR_REP_UINT                    = 9;
-    public static final int MR_TYPECTOR_REP_CHAR                    = 10;
-    public static final int MR_TYPECTOR_REP_FLOAT                   = 11;
-    public static final int MR_TYPECTOR_REP_STRING                  = 12;
-    public static final int MR_TYPECTOR_REP_PRED                    = 13;
-    public static final int MR_TYPECTOR_REP_SUBGOAL                 = 14;
-    public static final int MR_TYPECTOR_REP_VOID                    = 15;
-    public static final int MR_TYPECTOR_REP_C_POINTER               = 16;
-    public static final int MR_TYPECTOR_REP_TYPEINFO                = 17;
-    public static final int MR_TYPECTOR_REP_TYPECLASSINFO           = 18;
-    public static final int MR_TYPECTOR_REP_ARRAY                   = 19;
-    public static final int MR_TYPECTOR_REP_SUCCIP                  = 20;
-    public static final int MR_TYPECTOR_REP_HP                      = 21;
-    public static final int MR_TYPECTOR_REP_CURFR                   = 22;
-    public static final int MR_TYPECTOR_REP_MAXFR                   = 23;
-    public static final int MR_TYPECTOR_REP_REDOFR                  = 24;
-    public static final int MR_TYPECTOR_REP_REDOIP                  = 25;
-    public static final int MR_TYPECTOR_REP_TRAIL_PTR               = 26;
-    public static final int MR_TYPECTOR_REP_TICKET                  = 27;
-    public static final int MR_TYPECTOR_REP_NOTAG_GROUND            = 28;
-    public static final int MR_TYPECTOR_REP_NOTAG_GROUND_USEREQ     = 29;
-    public static final int MR_TYPECTOR_REP_EQUIV_GROUND            = 30;
-    public static final int MR_TYPECTOR_REP_TUPLE                   = 31;
-    public static final int MR_TYPECTOR_REP_RESERVED_ADDR           = 32;
-    public static final int MR_TYPECTOR_REP_RESERVED_ADDR_USEREQ    = 33;
-    public static final int MR_TYPECTOR_REP_TYPECTORINFO            = 34;
-    public static final int MR_TYPECTOR_REP_BASETYPECLASSINFO       = 35;
-    public static final int MR_TYPECTOR_REP_TYPEDESC                = 36;
-    public static final int MR_TYPECTOR_REP_TYPECTORDESC            = 37;
-    public static final int MR_TYPECTOR_REP_FOREIGN                 = 38;
-    public static final int MR_TYPECTOR_REP_REFERENCE               = 39;
-    public static final int MR_TYPECTOR_REP_STABLE_C_POINTER        = 40;
-    public static final int MR_TYPECTOR_REP_STABLE_FOREIGN          = 41;
-    public static final int MR_TYPECTOR_REP_PSEUDOTYPEDESC          = 42;
-    public static final int MR_TYPECTOR_REP_DUMMY                   = 43;
-    public static final int MR_TYPECTOR_REP_BITMAP                  = 44;
-    public static final int MR_TYPECTOR_REP_FOREIGN_ENUM            = 45;
-    public static final int MR_TYPECTOR_REP_FOREIGN_ENUM_USEREQ     = 46;
-    public static final int MR_TYPECTOR_REP_UNKNOWN                 = 47;
-    public static final int MR_TYPECTOR_REP_MAX                     = 48;
+    public static final int MR_TYPECTOR_REP_INT8                    = 10;
+    public static final int MR_TYPECTOR_REP_UINT8                   = 11;
+    public static final int MR_TYPECTOR_REP_INT16                   = 12;
+    public static final int MR_TYPECTOR_REP_UINT16                  = 13;
+    public static final int MR_TYPECTOR_REP_INT32                   = 14;
+    public static final int MR_TYPECTOR_REP_UINT32                  = 15;
+    public static final int MR_TYPECTOR_REP_CHAR                    = 16;
+    public static final int MR_TYPECTOR_REP_FLOAT                   = 17;
+    public static final int MR_TYPECTOR_REP_STRING                  = 18;
+    public static final int MR_TYPECTOR_REP_PRED                    = 19;
+    public static final int MR_TYPECTOR_REP_SUBGOAL                 = 20;
+    public static final int MR_TYPECTOR_REP_VOID                    = 21;
+    public static final int MR_TYPECTOR_REP_C_POINTER               = 22;
+    public static final int MR_TYPECTOR_REP_TYPEINFO                = 23;
+    public static final int MR_TYPECTOR_REP_TYPECLASSINFO           = 24;
+    public static final int MR_TYPECTOR_REP_ARRAY                   = 25;
+    public static final int MR_TYPECTOR_REP_SUCCIP                  = 26;
+    public static final int MR_TYPECTOR_REP_HP                      = 27;
+    public static final int MR_TYPECTOR_REP_CURFR                   = 28;
+    public static final int MR_TYPECTOR_REP_MAXFR                   = 29;
+    public static final int MR_TYPECTOR_REP_REDOFR                  = 30;
+    public static final int MR_TYPECTOR_REP_REDOIP                  = 31;
+    public static final int MR_TYPECTOR_REP_TRAIL_PTR               = 32;
+    public static final int MR_TYPECTOR_REP_TICKET                  = 33;
+    public static final int MR_TYPECTOR_REP_NOTAG_GROUND            = 34;
+    public static final int MR_TYPECTOR_REP_NOTAG_GROUND_USEREQ     = 35;
+    public static final int MR_TYPECTOR_REP_EQUIV_GROUND            = 36;
+    public static final int MR_TYPECTOR_REP_TUPLE                   = 37;
+    public static final int MR_TYPECTOR_REP_RESERVED_ADDR           = 38;
+    public static final int MR_TYPECTOR_REP_RESERVED_ADDR_USEREQ    = 39;
+    public static final int MR_TYPECTOR_REP_TYPECTORINFO            = 40;
+    public static final int MR_TYPECTOR_REP_BASETYPECLASSINFO       = 41;
+    public static final int MR_TYPECTOR_REP_TYPEDESC                = 42;
+    public static final int MR_TYPECTOR_REP_TYPECTORDESC            = 43;
+    public static final int MR_TYPECTOR_REP_FOREIGN                 = 44;
+    public static final int MR_TYPECTOR_REP_REFERENCE               = 45;
+    public static final int MR_TYPECTOR_REP_STABLE_C_POINTER        = 46;
+    public static final int MR_TYPECTOR_REP_STABLE_FOREIGN          = 47;
+    public static final int MR_TYPECTOR_REP_PSEUDOTYPEDESC          = 48;
+    public static final int MR_TYPECTOR_REP_DUMMY                   = 49;
+    public static final int MR_TYPECTOR_REP_BITMAP                  = 50;
+    public static final int MR_TYPECTOR_REP_FOREIGN_ENUM            = 51;
+    public static final int MR_TYPECTOR_REP_FOREIGN_ENUM_USEREQ     = 52;
+    public static final int MR_TYPECTOR_REP_UNKNOWN                 = 53;
+    public static final int MR_TYPECTOR_REP_MAX                     = 54;

      public static final int MR_SECTAG_NONE              = 0;
      public static final int MR_SECTAG_NONE_DIRECT_ARG   = 1;
diff --git a/library/rtti_implementation.m b/library/rtti_implementation.m
index b85e3ff71..a3f4b9b4b 100644
--- a/library/rtti_implementation.m
+++ b/library/rtti_implementation.m
@@ -165,6 +165,12 @@
      ;       tcr_func
      ;       tcr_int
      ;       tcr_uint
+    ;       tcr_int8
+    ;       tcr_uint8
+    ;       tcr_int16
+    ;       tcr_uint16
+    ;       tcr_int32
+    ;       tcr_uint32
      ;       tcr_char
      ;       tcr_float
      ;       tcr_string
@@ -890,6 +896,12 @@ type_info_num_functors(TypeInfo, NumFunctors) :-
          ( TypeCtorRep = tcr_subgoal
          ; TypeCtorRep = tcr_int
          ; TypeCtorRep = tcr_uint
+        ; TypeCtorRep = tcr_int8
+        ; TypeCtorRep = tcr_uint8
+        ; TypeCtorRep = tcr_int16
+        ; TypeCtorRep = tcr_uint16
+        ; TypeCtorRep = tcr_int32
+        ; TypeCtorRep = tcr_uint32
          ; TypeCtorRep = tcr_char
          ; TypeCtorRep = tcr_float
          ; TypeCtorRep = tcr_string
@@ -995,6 +1007,12 @@ get_functor_impl(TypeInfo, FunctorNumber,
          ( TypeCtorRep = tcr_subgoal
          ; TypeCtorRep = tcr_int
          ; TypeCtorRep = tcr_uint
+        ; TypeCtorRep = tcr_int8
+        ; TypeCtorRep = tcr_uint8
+        ; TypeCtorRep = tcr_int16
+        ; TypeCtorRep = tcr_uint16
+        ; TypeCtorRep = tcr_int32
+        ; TypeCtorRep = tcr_uint32
          ; TypeCtorRep = tcr_char
          ; TypeCtorRep = tcr_float
          ; TypeCtorRep = tcr_string
@@ -1225,6 +1243,12 @@ type_info_get_functor_ordinal(TypeInfo, FunctorNum, Ordinal) :-
          ; TypeCtorRep = tcr_pred
          ; TypeCtorRep = tcr_int
          ; TypeCtorRep = tcr_uint
+        ; TypeCtorRep = tcr_int8
+        ; TypeCtorRep = tcr_uint8
+        ; TypeCtorRep = tcr_int16
+        ; TypeCtorRep = tcr_uint16
+        ; TypeCtorRep = tcr_int32
+        ; TypeCtorRep = tcr_uint32
          ; TypeCtorRep = tcr_float
          ; TypeCtorRep = tcr_char
          ; TypeCtorRep = tcr_string
@@ -2716,6 +2740,42 @@ deconstruct_2(Term, TypeInfo, TypeCtorInfo, TypeCtorRep, NonCanon,
          Arity = 0,
          Arguments = []
      ;
+        TypeCtorRep = tcr_int8,
+        Functor = "<<int8>>",
+        Ordinal = -1,
+        Arity = 0,
+        Arguments = []
+    ;
+        TypeCtorRep = tcr_uint8,
+        Functor = "<<uint8>>",
+        Ordinal = -1,
+        Arity = 0,
+        Arguments = []
+    ;
+        TypeCtorRep = tcr_int16,
+        Functor = "<<int16>>",
+        Ordinal = -1,
+        Arity = 0,
+        Arguments = []
+    ;
+        TypeCtorRep = tcr_uint16,
+        Functor = "<<uint16>>",
+        Ordinal = -1,
+        Arity = 0,
+        Arguments = []
+    ;
+        TypeCtorRep = tcr_int32,
+        Functor = "<<int32>>",
+        Ordinal = -1,
+        Arity = 0,
+        Arguments = []
+    ;
+        TypeCtorRep = tcr_uint32,
+        Functor = "<<uint32>>",
+        Ordinal = -1,
+        Arity = 0,
+        Arguments = []
+    ;
          TypeCtorRep = tcr_char,
          det_dynamic_cast(Term, Char),
          Functor = string.from_char_list(['\'', Char, '\'']),
@@ -2982,6 +3042,12 @@ univ_named_arg_2(Term, TypeInfo, TypeCtorInfo, TypeCtorRep, NonCanon, Name,
          ; TypeCtorRep = tcr_func
          ; TypeCtorRep = tcr_int
          ; TypeCtorRep = tcr_uint
+        ; TypeCtorRep = tcr_int8
+        ; TypeCtorRep = tcr_uint8
+        ; TypeCtorRep = tcr_int16
+        ; TypeCtorRep = tcr_uint16
+        ; TypeCtorRep = tcr_int32
+        ; TypeCtorRep = tcr_uint32
          ; TypeCtorRep = tcr_char
          ; TypeCtorRep = tcr_float
          ; TypeCtorRep = tcr_string
diff --git a/library/uint16.m b/library/uint16.m
new file mode 100644
index 000000000..703026221
--- /dev/null
+++ b/library/uint16.m
@@ -0,0 +1,20 @@
+%---------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
+%---------------------------------------------------------------------------%
+% Copyright (C) 2017 The Mercury team.
+% This file may only be copied under the terms of the GNU Library General
+% Public License - see the file COPYING.LIB in the Mercury distribution.
+%---------------------------------------------------------------------------%
+
+:- module uint16.
+:- interface.
+
+    % uint16s are NYI -- this module is just a placeholder for their
+    % library support.
+    %
+:- type placeholder_uint16 ---> placeholder_uint16.
+
+%---------------------------------------------------------------------------%
+:- end_module uint16.
+%---------------------------------------------------------------------------%
+
diff --git a/library/uint32.m b/library/uint32.m
new file mode 100644
index 000000000..4409db83a
--- /dev/null
+++ b/library/uint32.m
@@ -0,0 +1,20 @@
+%---------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
+%---------------------------------------------------------------------------%
+% Copyright (C) 2017 The Mercury team.
+% This file may only be copied under the terms of the GNU Library General
+% Public License - see the file COPYING.LIB in the Mercury distribution.
+%---------------------------------------------------------------------------%
+
+:- module uint32.
+:- interface.
+
+    % uint32s are NYI -- this module is just a placeholder for their
+    % library support.
+    %
+:- type placeholder_uint32 ---> placeholder_uint32.
+
+%---------------------------------------------------------------------------%
+:- end_module uint32.
+%---------------------------------------------------------------------------%
+
diff --git a/library/uint8.m b/library/uint8.m
new file mode 100644
index 000000000..d640fb587
--- /dev/null
+++ b/library/uint8.m
@@ -0,0 +1,20 @@
+%---------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
+%---------------------------------------------------------------------------%
+% Copyright (C) 2017 The Mercury team.
+% This file may only be copied under the terms of the GNU Library General
+% Public License - see the file COPYING.LIB in the Mercury distribution.
+%---------------------------------------------------------------------------%
+
+:- module uint8.
+:- interface.
+
+    % uint8s are NYI -- this module is just a placeholder for their
+    % library support.
+    %
+:- type placeholder_uint8 ---> placeholder_uint8.
+
+%---------------------------------------------------------------------------%
+:- end_module uint8.
+%---------------------------------------------------------------------------%
+
diff --git a/mdbcomp/program_representation.m b/mdbcomp/program_representation.m
index 32a595757..bc109474f 100644
--- a/mdbcomp/program_representation.m
+++ b/mdbcomp/program_representation.m
@@ -98,6 +98,12 @@
  :- type builtin_type_rep
      --->    builtin_type_int_rep
      ;       builtin_type_uint_rep
+    ;       builtin_type_int8_rep
+    ;       builtin_type_uint8_rep
+    ;       builtin_type_int16_rep
+    ;       builtin_type_uint16_rep
+    ;       builtin_type_int32_rep
+    ;       builtin_type_uint32_rep
      ;       builtin_type_float_rep
      ;       builtin_type_string_rep
      ;       builtin_type_char_rep.
@@ -1352,27 +1358,45 @@ read_encoded_type(ByteCode, StringTable, TypeTable, TypeRep, !Pos) :-
          TypeRep = builtin_type_rep(builtin_type_uint_rep)
      ;
          Selector = 7,
-        TypeRep = builtin_type_rep(builtin_type_float_rep)
+        TypeRep = builtin_type_rep(builtin_type_int8_rep)
      ;
          Selector = 8,
-        TypeRep = builtin_type_rep(builtin_type_string_rep)
+        TypeRep = builtin_type_rep(builtin_type_uint8_rep)
      ;
          Selector = 9,
-        TypeRep = builtin_type_rep(builtin_type_char_rep)
+        TypeRep = builtin_type_rep(builtin_type_int16_rep)
      ;
          Selector = 10,
+        TypeRep = builtin_type_rep(builtin_type_uint16_rep)
+    ;
+        Selector = 11,
+        TypeRep = builtin_type_rep(builtin_type_int32_rep)
+    ;
+        Selector = 12,
+        TypeRep = builtin_type_rep(builtin_type_uint32_rep)
+    ;
+        Selector = 13,
+        TypeRep = builtin_type_rep(builtin_type_float_rep)
+    ;
+        Selector = 14,
+        TypeRep = builtin_type_rep(builtin_type_string_rep)
+    ;
+        Selector = 15,
+        TypeRep = builtin_type_rep(builtin_type_char_rep)
+    ;
+        Selector = 16,
          read_num(ByteCode, NumArgs, !Pos),
          read_n_items(read_num(ByteCode), NumArgs, TypeNumArgs, !Pos),
          list.map(map.lookup(TypeTable), TypeNumArgs, TypeRepArgs),
          TypeRep = tuple_type_rep(TypeRepArgs)
      ;
-        Selector = 11,
+        Selector = 17,
          read_num(ByteCode, NumArgs, !Pos),
          read_n_items(read_num(ByteCode), NumArgs, TypeNumArgs, !Pos),
          list.map(map.lookup(TypeTable), TypeNumArgs, TypeRepArgs),
          TypeRep = higher_order_type_rep(TypeRepArgs, no)
      ;
-        Selector = 12,
+        Selector = 18,
          read_num(ByteCode, NumArgs, !Pos),
          read_n_items(read_num(ByteCode), NumArgs, TypeNumArgs, !Pos),
          list.map(map.lookup(TypeTable), TypeNumArgs, TypeRepArgs),
@@ -1380,7 +1404,7 @@ read_encoded_type(ByteCode, StringTable, TypeTable, TypeRep, !Pos) :-
          map.lookup(TypeTable, TypeNumReturn, TypeRepReturn),
          TypeRep = higher_order_type_rep(TypeRepArgs, yes(TypeRepReturn))
      ;
-        Selector = 13,
+        Selector = 19,
          read_num(ByteCode, VarNum, !Pos),
          TypeRep = type_var_rep(VarNum)
      ).
diff --git a/runtime/mercury_builtin_types.c b/runtime/mercury_builtin_types.c
index d4fdb6d90..6cbf5eef2 100644
--- a/runtime/mercury_builtin_types.c
+++ b/runtime/mercury_builtin_types.c
@@ -40,6 +40,12 @@

  MR_DEFINE_TYPE_CTOR_INFO(builtin, int, 0, INT);
  MR_DEFINE_TYPE_CTOR_INFO(builtin, uint, 0, UINT);
+MR_DEFINE_TYPE_CTOR_INFO(builtin, int8, 0, INT8);
+MR_DEFINE_TYPE_CTOR_INFO(builtin, uint8, 0, UINT8);
+MR_DEFINE_TYPE_CTOR_INFO(builtin, int16, 0, INT16);
+MR_DEFINE_TYPE_CTOR_INFO(builtin, uint16, 0, UINT16);
+MR_DEFINE_TYPE_CTOR_INFO(builtin, int32, 0, INT32);
+MR_DEFINE_TYPE_CTOR_INFO(builtin, uint32, 0, UINT32);
  MR_DEFINE_TYPE_CTOR_INFO(builtin, character, 0, CHAR);
  MR_DEFINE_TYPE_CTOR_INFO(builtin, string, 0, STRING);
  MR_DEFINE_TYPE_CTOR_INFO(builtin, float, 0, FLOAT);
@@ -114,6 +120,42 @@ mercury__builtin____Unify____uint_0_0(MR_Unsigned x, MR_Unsigned y)
  }

  MR_bool MR_CALL
+mercury__builtin____Unify____int8_0_0(int8_t x, int8_t y)
+{
+    return x == y;
+}
+
+MR_bool MR_CALL
+mercury__builtin____Unify____uint8_0_0(uint8_t x, uint8_t y)
+{
+    return x == y;
+}
+
+MR_bool MR_CALL
+mercury__builtin____Unify____int16_0_0(int16_t x, int16_t y)
+{
+    return x == y;
+}
+
+MR_bool MR_CALL
+mercury__builtin____Unify____uint16_0_0(uint16_t x, uint16_t y)
+{
+    return x == y;
+}
+
+MR_bool MR_CALL
+mercury__builtin____Unify____int32_0_0(int32_t x, int32_t y)
+{
+    return x == y;
+}
+
+MR_bool MR_CALL
+mercury__builtin____Unify____uint32_0_0(uint32_t x, uint32_t y)
+{
+    return x == y;
+}
+
+MR_bool MR_CALL
  mercury__builtin____Unify____string_0_0(MR_String x, MR_String y)
  {
      return strcmp(x, y) == 0;
@@ -265,6 +307,60 @@ mercury__builtin____Compare____uint_0_0(
  }

  void MR_CALL
+mercury__builtin____Compare____int8_0_0(
+    MR_Comparison_Result *result, int8_t x, int8_t y)
+{
+    *result = (x > y ? MR_COMPARE_GREATER :
+          x == y ? MR_COMPARE_EQUAL :
+          MR_COMPARE_LESS);
+}
+
+void MR_CALL
+mercury__builtin____Compare____uint8_0_0(
+    MR_Comparison_Result *result, uint8_t x, uint8_t y)
+{
+    *result = (x > y ? MR_COMPARE_GREATER :
+          x == y ? MR_COMPARE_EQUAL :
+          MR_COMPARE_LESS);
+}
+
+void MR_CALL
+mercury__builtin____Compare____int16_0_0(
+    MR_Comparison_Result *result, int16_t x, int16_t y)
+{
+    *result = (x > y ? MR_COMPARE_GREATER :
+          x == y ? MR_COMPARE_EQUAL :
+          MR_COMPARE_LESS);
+}
+
+void MR_CALL
+mercury__builtin____Compare____uint16_0_0(
+    MR_Comparison_Result *result, uint16_t x, uint16_t y)
+{
+    *result = (x > y ? MR_COMPARE_GREATER :
+          x == y ? MR_COMPARE_EQUAL :
+          MR_COMPARE_LESS);
+}
+
+void MR_CALL
+mercury__builtin____Compare____int32_0_0(
+    MR_Comparison_Result *result, int32_t x, int32_t y)
+{
+    *result = (x > y ? MR_COMPARE_GREATER :
+          x == y ? MR_COMPARE_EQUAL :
+          MR_COMPARE_LESS);
+}
+
+void MR_CALL
+mercury__builtin____Compare____uint32_0_0(
+    MR_Comparison_Result *result, uint32_t x, uint32_t y)
+{
+    *result = (x > y ? MR_COMPARE_GREATER :
+          x == y ? MR_COMPARE_EQUAL :
+          MR_COMPARE_LESS);
+}
+
+void MR_CALL
  mercury__builtin____Compare____string_0_0(MR_Comparison_Result *result,
      MR_String x, MR_String y)
  {
@@ -427,6 +523,48 @@ mercury__builtin__do_unify__uint_0_0(MR_Box x, MR_Box y)
  }

  MR_bool MR_CALL
+mercury__builtin__do_unify__int8_0_0(MR_Box x, MR_Box y)
+{
+    return mercury__builtin____Unify____int8_0_0(
+        (int8_t) x, (int8_t) y);
+}
+
+MR_bool MR_CALL
+mercury__builtin__do_unify__uint8_0_0(MR_Box x, MR_Box y)
+{
+    return mercury__builtin____Unify____uint8_0_0(
+        (uint8_t) x, (uint8_t) y);
+}
+
+MR_bool MR_CALL
+mercury__builtin__do_unify__int16_0_0(MR_Box x, MR_Box y)
+{
+    return mercury__builtin____Unify____int16_0_0(
+        (int16_t) x, (int16_t) y);
+}
+
+MR_bool MR_CALL
+mercury__builtin__do_unify__uint16_0_0(MR_Box x, MR_Box y)
+{
+    return mercury__builtin____Unify____uint16_0_0(
+        (uint16_t) x, (uint16_t) y);
+}
+
+MR_bool MR_CALL
+mercury__builtin__do_unify__int32_0_0(MR_Box x, MR_Box y)
+{
+    return mercury__builtin____Unify____int32_0_0(
+        (int32_t) x, (int32_t) y);
+}
+
+MR_bool MR_CALL
+mercury__builtin__do_unify__uint32_0_0(MR_Box x, MR_Box y)
+{
+    return mercury__builtin____Unify____uint32_0_0(
+        (uint32_t) x, (uint32_t) y);
+}
+
+MR_bool MR_CALL
  mercury__builtin__do_unify__string_0_0(MR_Box x, MR_Box y)
  {
      return mercury__builtin____Unify____string_0_0(
@@ -576,6 +714,54 @@ mercury__builtin__do_compare__uint_0_0(
  }

  void MR_CALL
+mercury__builtin__do_compare__int8_0_0(
+    MR_Comparison_Result *result, MR_Box x, MR_Box y)
+{
+    mercury__builtin____Compare____int8_0_0(result,
+        (int8_t) x, (int8_t) y);
+}
+
+void MR_CALL
+mercury__builtin__do_compare__uint8_0_0(
+    MR_Comparison_Result *result, MR_Box x, MR_Box y)
+{
+    mercury__builtin____Compare____uint8_0_0(result,
+        (uint8_t) x, (uint8_t) y);
+}
+
+void MR_CALL
+mercury__builtin__do_compare__int16_0_0(
+    MR_Comparison_Result *result, MR_Box x, MR_Box y)
+{
+    mercury__builtin____Compare____int16_0_0(result,
+        (int16_t) x, (int16_t) y);
+}
+
+void MR_CALL
+mercury__builtin__do_compare__uint16_0_0(
+    MR_Comparison_Result *result, MR_Box x, MR_Box y)
+{
+    mercury__builtin____Compare____uint16_0_0(result,
+        (uint16_t) x, (uint16_t) y);
+}
+
+void MR_CALL
+mercury__builtin__do_compare__int32_0_0(
+    MR_Comparison_Result *result, MR_Box x, MR_Box y)
+{
+    mercury__builtin____Compare____int32_0_0(result,
+        (int32_t) x, (int32_t) y);
+}
+
+void MR_CALL
+mercury__builtin__do_compare__uint32_0_0(
+    MR_Comparison_Result *result, MR_Box x, MR_Box y)
+{
+    mercury__builtin____Compare____uint32_0_0(result,
+        (uint32_t) x, (uint32_t) y);
+}
+
+void MR_CALL
  mercury__builtin__do_compare__string_0_0(
      MR_Comparison_Result *result, MR_Box x, MR_Box y)
  {
@@ -761,6 +947,12 @@ MR_MODULE_STATIC_OR_EXTERN MR_ModuleFunc mercury_builtin_types;

  MR_UNIFY_COMPARE_REP_DECLS(builtin, int, 0)
  MR_UNIFY_COMPARE_REP_DECLS(builtin, uint, 0)
+MR_UNIFY_COMPARE_REP_DECLS(builtin, int8, 0)
+MR_UNIFY_COMPARE_REP_DECLS(builtin, uint8, 0)
+MR_UNIFY_COMPARE_REP_DECLS(builtin, int16, 0)
+MR_UNIFY_COMPARE_REP_DECLS(builtin, uint16, 0)
+MR_UNIFY_COMPARE_REP_DECLS(builtin, int32, 0)
+MR_UNIFY_COMPARE_REP_DECLS(builtin, uint32, 0)
  MR_UNIFY_COMPARE_REP_DECLS(builtin, string, 0)
  MR_UNIFY_COMPARE_REP_DECLS(builtin, float, 0)
  MR_UNIFY_COMPARE_REP_DECLS(builtin, character, 0)
@@ -791,6 +983,12 @@ MR_UNIFY_COMPARE_REP_DECLS(builtin, dummy, 0);

  MR_UNIFY_COMPARE_REP_DEFNS(builtin, int, 0)
  MR_UNIFY_COMPARE_REP_DEFNS(builtin, uint, 0)
+MR_UNIFY_COMPARE_REP_DEFNS(builtin, int8, 0)
+MR_UNIFY_COMPARE_REP_DEFNS(builtin, uint8, 0)
+MR_UNIFY_COMPARE_REP_DEFNS(builtin, int16, 0)
+MR_UNIFY_COMPARE_REP_DEFNS(builtin, uint16, 0)
+MR_UNIFY_COMPARE_REP_DEFNS(builtin, int32, 0)
+MR_UNIFY_COMPARE_REP_DEFNS(builtin, uint32, 0)
  MR_UNIFY_COMPARE_REP_DEFNS(builtin, string, 0)
  MR_UNIFY_COMPARE_REP_DEFNS(builtin, float, 0)
  MR_UNIFY_COMPARE_REP_DEFNS(builtin, character, 0)
@@ -864,6 +1062,12 @@ MR_UNIFY_COMPARE_REP_DEFNS(builtin, dummy, 0)

  MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, int, 0);
  MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, uint, 0);
+MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, int8, 0);
+MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, uint8, 0);
+MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, int16, 0);
+MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, uint16, 0);
+MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, int32, 0);
+MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, uint32, 0);
  MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, string, 0);
  MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, float, 0);
  MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, character, 0);
@@ -897,6 +1101,12 @@ MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, dummy, 0);
  MR_BEGIN_MODULE(mercury_builtin_types)
      MR_UNIFY_COMPARE_REP_LABELS(builtin, int, 0)
      MR_UNIFY_COMPARE_REP_LABELS(builtin, uint, 0)
+    MR_UNIFY_COMPARE_REP_LABELS(builtin, int8, 0)
+    MR_UNIFY_COMPARE_REP_LABELS(builtin, uint8, 0)
+    MR_UNIFY_COMPARE_REP_LABELS(builtin, int16, 0)
+    MR_UNIFY_COMPARE_REP_LABELS(builtin, uint16, 0)
+    MR_UNIFY_COMPARE_REP_LABELS(builtin, int32, 0)
+    MR_UNIFY_COMPARE_REP_LABELS(builtin, uint32, 0)
      MR_UNIFY_COMPARE_REP_LABELS(builtin, string, 0)
      MR_UNIFY_COMPARE_REP_LABELS(builtin, float, 0)
      MR_UNIFY_COMPARE_REP_LABELS(builtin, character, 0)
@@ -971,6 +1181,132 @@ MR_BEGIN_CODE
  ////////////////////////////////////////////////////////////////////////////

  #define module          builtin
+#define type            int8
+#define arity           0
+#define unify_code      MR_r1 = ((int8_t) MR_r1 == (int8_t) MR_r2);
+#define compare_code    MR_r1 =                                         \
+                            ((int8_t) MR_r1 == (int8_t) MR_r2 ?         \
+                                MR_COMPARE_EQUAL :                      \
+                            (int8_t) MR_r1 < (int8_t) MR_r2 ?           \
+                                MR_COMPARE_LESS :                       \
+                            MR_COMPARE_GREATER);
+
+#include "mercury_hand_unify_compare_body.h"
+
+#undef  module
+#undef  type
+#undef  arity
+#undef  unify_code
+#undef  compare_code
+
+////////////////////////////////////////////////////////////////////////////
+
+#define module          builtin
+#define type            uint8
+#define arity           0
+#define unify_code      MR_r1 = ((uint8_t) MR_r1 == (uint8_t) MR_r2);
+#define compare_code    MR_r1 =                                         \
+                            ((uint8_t) MR_r1 == (uint8_t) MR_r2 ?       \
+                                MR_COMPARE_EQUAL :                      \
+                            (uint8_t) MR_r1 < (uint8_t) MR_r2 ?         \
+                                MR_COMPARE_LESS :                       \
+                            MR_COMPARE_GREATER);
+
+#include "mercury_hand_unify_compare_body.h"
+
+#undef  module
+#undef  type
+#undef  arity
+#undef  unify_code
+#undef  compare_code
+
+////////////////////////////////////////////////////////////////////////////
+
+#define module          builtin
+#define type            int16
+#define arity           0
+#define unify_code      MR_r1 = ((int16_t) MR_r1 == (int16_t) MR_r2);
+#define compare_code    MR_r1 =                                         \
+                            ((int16_t) MR_r1 == (int16_t) MR_r2 ?       \
+                                MR_COMPARE_EQUAL :                      \
+                            (int16_t) MR_r1 < (int16_t) MR_r2 ?         \
+                                MR_COMPARE_LESS :                       \
+                            MR_COMPARE_GREATER);
+
+#include "mercury_hand_unify_compare_body.h"
+
+#undef  module
+#undef  type
+#undef  arity
+#undef  unify_code
+#undef  compare_code
+
+////////////////////////////////////////////////////////////////////////////
+
+#define module          builtin
+#define type            uint16
+#define arity           0
+#define unify_code      MR_r1 = ((uint16_t) MR_r1 == (uint16_t) MR_r2);
+#define compare_code    MR_r1 =                                         \
+                            ((uint16_t) MR_r1 == (uint16_t) MR_r2 ?     \
+                                MR_COMPARE_EQUAL :                      \
+                            (uint16_t) MR_r1 < (uint16_t) MR_r2 ?       \
+                                MR_COMPARE_LESS :                       \
+                            MR_COMPARE_GREATER);
+
+#include "mercury_hand_unify_compare_body.h"
+
+#undef  module
+#undef  type
+#undef  arity
+#undef  unify_code
+#undef  compare_code
+
+////////////////////////////////////////////////////////////////////////////
+
+#define module          builtin
+#define type            int32
+#define arity           0
+#define unify_code      MR_r1 = ((int32_t) MR_r1 == (int32_t) MR_r2);
+#define compare_code    MR_r1 =                                         \
+                            ((int32_t) MR_r1 == (int32_t) MR_r2 ?       \
+                                MR_COMPARE_EQUAL :                      \
+                            (int32_t) MR_r1 < (int32_t) MR_r2 ?         \
+                                MR_COMPARE_LESS :                       \
+                            MR_COMPARE_GREATER);
+
+#include "mercury_hand_unify_compare_body.h"
+
+#undef  module
+#undef  type
+#undef  arity
+#undef  unify_code
+#undef  compare_code
+
+////////////////////////////////////////////////////////////////////////////
+
+#define module          builtin
+#define type            uint32
+#define arity           0
+#define unify_code      MR_r1 = ((uint32_t) MR_r1 == (uint32_t) MR_r2);
+#define compare_code    MR_r1 =                                         \
+                            ((uint32_t) MR_r1 == (uint32_t) MR_r2 ?     \
+                                MR_COMPARE_EQUAL :                      \
+                            (uint32_t) MR_r1 < (uint32_t) MR_r2 ?       \
+                                MR_COMPARE_LESS :                       \
+                            MR_COMPARE_GREATER);
+
+#include "mercury_hand_unify_compare_body.h"
+
+#undef  module
+#undef  type
+#undef  arity
+#undef  unify_code
+#undef  compare_code
+
+////////////////////////////////////////////////////////////////////////////
+
+#define module          builtin
  #define type            string
  #define arity           0
  #define unify_code      MR_r1 = strcmp((char *) MR_r1, (char *) MR_r2) == 0;
@@ -1603,6 +1939,12 @@ mercury_sys_init_mercury_builtin_types_init(void)

      MR_init_entry(mercury__builtin____Unify____int_0_0);
      MR_init_entry(mercury__builtin____Unify____uint_0_0);
+    MR_init_entry(mercury__builtin____Unify____int8_0_0);
+    MR_init_entry(mercury__builtin____Unify____uint8_0_0);
+    MR_init_entry(mercury__builtin____Unify____int16_0_0);
+    MR_init_entry(mercury__builtin____Unify____uint16_0_0);
+    MR_init_entry(mercury__builtin____Unify____int32_0_0);
+    MR_init_entry(mercury__builtin____Unify____uint32_0_0);
      MR_init_entry(mercury__builtin____Unify____string_0_0);
      MR_init_entry(mercury__builtin____Unify____float_0_0);
      MR_init_entry(mercury__builtin____Unify____character_0_0);
@@ -1613,6 +1955,12 @@ mercury_sys_init_mercury_builtin_types_init(void)

      MR_init_entry(mercury__builtin____Compare____int_0_0);
      MR_init_entry(mercury__builtin____Compare____uint_0_0);
+    MR_init_entry(mercury__builtin____Compare____int8_0_0);
+    MR_init_entry(mercury__builtin____Compare____uint8_0_0);
+    MR_init_entry(mercury__builtin____Compare____int16_0_0);
+    MR_init_entry(mercury__builtin____Compare____uint16_0_0);
+    MR_init_entry(mercury__builtin____Compare____int32_0_0);
+    MR_init_entry(mercury__builtin____Compare____uint32_0_0);
      MR_init_entry(mercury__builtin____Compare____float_0_0);
      MR_init_entry(mercury__builtin____Compare____string_0_0);
      MR_init_entry(mercury__builtin____Compare____character_0_0);
@@ -1629,6 +1977,12 @@ mercury_sys_init_mercury_builtin_types_init(void)

      MR_INIT_TYPE_CTOR_INFO_MNA(builtin, int, 0);
      MR_INIT_TYPE_CTOR_INFO_MNA(builtin, uint, 0);
+    MR_INIT_TYPE_CTOR_INFO_MNA(builtin, int8, 0);
+    MR_INIT_TYPE_CTOR_INFO_MNA(builtin, uint8, 0);
+    MR_INIT_TYPE_CTOR_INFO_MNA(builtin, int16, 0);
+    MR_INIT_TYPE_CTOR_INFO_MNA(builtin, uint16, 0);
+    MR_INIT_TYPE_CTOR_INFO_MNA(builtin, int32, 0);
+    MR_INIT_TYPE_CTOR_INFO_MNA(builtin, uint32, 0);
      MR_INIT_TYPE_CTOR_INFO_MNA(builtin, string, 0);
      MR_INIT_TYPE_CTOR_INFO_MNA(builtin, float, 0);
      MR_INIT_TYPE_CTOR_INFO_MNA(builtin, character, 0);
@@ -1663,6 +2017,12 @@ mercury_sys_init_mercury_builtin_types_init_type_tables(void)
  {
      MR_REGISTER_TYPE_CTOR_INFO(builtin, int, 0);
      MR_REGISTER_TYPE_CTOR_INFO(builtin, uint, 0);
+    MR_REGISTER_TYPE_CTOR_INFO(builtin, int8, 0);
+    MR_REGISTER_TYPE_CTOR_INFO(builtin, uint8, 0);
+    MR_REGISTER_TYPE_CTOR_INFO(builtin, int16, 0);
+    MR_REGISTER_TYPE_CTOR_INFO(builtin, uint16, 0);
+    MR_REGISTER_TYPE_CTOR_INFO(builtin, int32, 0);
+    MR_REGISTER_TYPE_CTOR_INFO(builtin, uint32, 0);
      MR_REGISTER_TYPE_CTOR_INFO(builtin, string, 0);
      MR_REGISTER_TYPE_CTOR_INFO(builtin, float, 0);
      MR_REGISTER_TYPE_CTOR_INFO(builtin, character, 0);
@@ -1699,6 +2059,12 @@ mercury_sys_init_mercury_builtin_types_write_out_proc_statics(FILE *deep_fp,
  {
      MR_WRITE_OUT_PROC_STATIC_LAYOUTS(deep_fp, builtin, int, 0);
      MR_WRITE_OUT_PROC_STATIC_LAYOUTS(deep_fp, builtin, uint, 0);
+    MR_WRITE_OUT_PROC_STATIC_LAYOUTS(deep_fp, builtin, int8, 0);
+    MR_WRITE_OUT_PROC_STATIC_LAYOUTS(deep_fp, builtin, uint8, 0);
+    MR_WRITE_OUT_PROC_STATIC_LAYOUTS(deep_fp, builtin, int16, 0);
+    MR_WRITE_OUT_PROC_STATIC_LAYOUTS(deep_fp, builtin, uint16, 0);
+    MR_WRITE_OUT_PROC_STATIC_LAYOUTS(deep_fp, builtin, int32, 0);
+    MR_WRITE_OUT_PROC_STATIC_LAYOUTS(deep_fp, builtin, uint32, 0);
      MR_WRITE_OUT_PROC_STATIC_LAYOUTS(deep_fp, builtin, string, 0);
      MR_WRITE_OUT_PROC_STATIC_LAYOUTS(deep_fp, builtin, float, 0);
      MR_WRITE_OUT_PROC_STATIC_LAYOUTS(deep_fp, builtin, character, 0);
diff --git a/runtime/mercury_builtin_types.h b/runtime/mercury_builtin_types.h
index 0d6e41e9c..6dfe0711f 100644
--- a/runtime/mercury_builtin_types.h
+++ b/runtime/mercury_builtin_types.h
@@ -26,6 +26,18 @@ MR_DECLARE_TYPE_CTOR_INFO_STRUCT(
  MR_DECLARE_TYPE_CTOR_INFO_STRUCT(
      MR_TYPE_CTOR_INFO_NAME(builtin, uint, 0));
  MR_DECLARE_TYPE_CTOR_INFO_STRUCT(
+    MR_TYPE_CTOR_INFO_NAME(builtin, int8, 0));
+MR_DECLARE_TYPE_CTOR_INFO_STRUCT(
+    MR_TYPE_CTOR_INFO_NAME(builtin, uint8, 0));
+MR_DECLARE_TYPE_CTOR_INFO_STRUCT(
+    MR_TYPE_CTOR_INFO_NAME(builtin, int16, 0));
+MR_DECLARE_TYPE_CTOR_INFO_STRUCT(
+    MR_TYPE_CTOR_INFO_NAME(builtin, uint16, 0));
+MR_DECLARE_TYPE_CTOR_INFO_STRUCT(
+    MR_TYPE_CTOR_INFO_NAME(builtin, int32, 0));
+MR_DECLARE_TYPE_CTOR_INFO_STRUCT(
+    MR_TYPE_CTOR_INFO_NAME(builtin, uint32, 0));
+MR_DECLARE_TYPE_CTOR_INFO_STRUCT(
      MR_TYPE_CTOR_INFO_NAME(builtin, string, 0));
  MR_DECLARE_TYPE_CTOR_INFO_STRUCT(
      MR_TYPE_CTOR_INFO_NAME(builtin, float, 0));
@@ -71,6 +83,18 @@ MR_bool MR_CALL mercury__builtin____Unify____int_0_0(MR_Integer x,
                      MR_Integer y);
  MR_bool MR_CALL mercury__builtin____Unify____uint_0_0(MR_Unsigned x,
                      MR_Unsigned y);
+MR_bool MR_CALL mercury__builtin____Unify____int8_0_0(int8_t x,
+                    int8_t y);
+MR_bool MR_CALL mercury__builtin____Unify____uint8_0_0(uint8_t x,
+                    uint8_t y);
+MR_bool MR_CALL mercury__builtin____Unify____int16_0_0(int16_t x,
+                    int16_t y);
+MR_bool MR_CALL mercury__builtin____Unify____uint16_0_0(uint16_t x,
+                    uint16_t y);
+MR_bool MR_CALL mercury__builtin____Unify____int32_0_0(int32_t x,
+                    int32_t y);
+MR_bool MR_CALL mercury__builtin____Unify____uint32_0_0(uint32_t x,
+                    uint32_t y);
  MR_bool MR_CALL mercury__builtin____Unify____string_0_0(MR_String x,
                      MR_String y);
  MR_bool MR_CALL mercury__builtin____Unify____float_0_0(MR_Float x, MR_Float y);
@@ -106,6 +130,18 @@ void MR_CALL    mercury__builtin____Compare____int_0_0(
                      MR_Comparison_Result *result, MR_Integer x, MR_Integer y);
  void MR_CALL    mercury__builtin____Compare____uint_0_0(
                      MR_Comparison_Result *result, MR_Unsigned x, MR_Unsigned y);
+void MR_CALL    mercury__builtin____Compare____int8_0_0(
+                    MR_Comparison_Result *result, int8_t x, int8_t y);
+void MR_CALL    mercury__builtin____Compare____uint8_0_0(
+                    MR_Comparison_Result *result, uint8_t x, uint8_t y);
+void MR_CALL    mercury__builtin____Compare____int16_0_0(
+                    MR_Comparison_Result *result, int16_t x, int16_t y);
+void MR_CALL    mercury__builtin____Compare____uint16_0_0(
+                    MR_Comparison_Result *result, uint16_t x, uint16_t y);
+void MR_CALL    mercury__builtin____Compare____int32_0_0(
+                    MR_Comparison_Result *result, int32_t x, int32_t y);
+void MR_CALL    mercury__builtin____Compare____uint32_0_0(
+                    MR_Comparison_Result *result, uint32_t x, uint32_t y);
  void MR_CALL    mercury__builtin____Compare____string_0_0(
                      MR_Comparison_Result *result, MR_String x, MR_String y);
  void MR_CALL    mercury__builtin____Compare____float_0_0(
diff --git a/runtime/mercury_builtin_types_proc_layouts.h b/runtime/mercury_builtin_types_proc_layouts.h
index 772a16484..3b30bf7ac 100644
--- a/runtime/mercury_builtin_types_proc_layouts.h
+++ b/runtime/mercury_builtin_types_proc_layouts.h
@@ -38,6 +38,12 @@

  MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(builtin, int, 0);
  MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(builtin, uint, 0);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(builtin, int8, 0);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(builtin, uint8, 0);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(builtin, int16, 0);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(builtin, uint16, 0);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(builtin, int32, 0);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(builtin, uint32, 0);
  MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(builtin, string, 0);
  MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(builtin, float, 0);
  MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(builtin, character, 0);
diff --git a/runtime/mercury_conf.h.in b/runtime/mercury_conf.h.in
index 317698749..b59cefc5e 100644
--- a/runtime/mercury_conf.h.in
+++ b/runtime/mercury_conf.h.in
@@ -139,6 +139,7 @@
  //  MR_HAVE_UTMPX_H         we have <utmpx.h>
  //  MR_HAVE_SYS_RESOURCE_H  we have <sys/resource.h>
  //  MR_HAVE_DISPATCH_DISPATCH_H we have <dispatch/dispatch.h>
+//  MR_HAVE_STDINT          we have <stdint.h>

  #undef  MR_HAVE_SYS_SIGINFO_H
  #undef  MR_HAVE_SYS_SIGNAL_H
@@ -172,6 +173,7 @@
  #undef  MR_HAVE_UTMPX_H
  #undef  MR_HAVE_SYS_RESOURCE_H
  #undef  MR_HAVE_DISPATCH_DISPATCH_H
+#undef  MR_HAVE_STDINT_H

  // MR_HAVE_POSIX_TIMES is defined if we have the POSIX
  // `struct tms' struct and times() function.
diff --git a/runtime/mercury_construct.c b/runtime/mercury_construct.c
index 2c62c79a9..b47187f4b 100644
--- a/runtime/mercury_construct.c
+++ b/runtime/mercury_construct.c
@@ -160,6 +160,12 @@ MR_get_functor_info(MR_TypeInfo type_info, int functor_number,

      case MR_TYPECTOR_REP_INT:
      case MR_TYPECTOR_REP_UINT:
+    case MR_TYPECTOR_REP_INT8:
+    case MR_TYPECTOR_REP_UINT8:
+    case MR_TYPECTOR_REP_INT16:
+    case MR_TYPECTOR_REP_UINT16:
+    case MR_TYPECTOR_REP_INT32:
+    case MR_TYPECTOR_REP_UINT32:
      case MR_TYPECTOR_REP_CHAR:
      case MR_TYPECTOR_REP_FLOAT:
      case MR_TYPECTOR_REP_STRING:
@@ -317,6 +323,12 @@ MR_get_num_functors(MR_TypeInfo type_info)

          case MR_TYPECTOR_REP_INT:
          case MR_TYPECTOR_REP_UINT:
+        case MR_TYPECTOR_REP_INT8:
+        case MR_TYPECTOR_REP_UINT8:
+        case MR_TYPECTOR_REP_INT16:
+        case MR_TYPECTOR_REP_UINT16:
+        case MR_TYPECTOR_REP_INT32:
+        case MR_TYPECTOR_REP_UINT32:
          case MR_TYPECTOR_REP_CHAR:
          case MR_TYPECTOR_REP_FLOAT:
          case MR_TYPECTOR_REP_STRING:
diff --git a/runtime/mercury_deconstruct.c b/runtime/mercury_deconstruct.c
index ed3698441..130aa2175 100644
--- a/runtime/mercury_deconstruct.c
+++ b/runtime/mercury_deconstruct.c
@@ -265,6 +265,12 @@ MR_named_arg_num(MR_TypeInfo type_info, MR_Word *term_ptr,
          case MR_TYPECTOR_REP_DUMMY:
          case MR_TYPECTOR_REP_INT:
          case MR_TYPECTOR_REP_UINT:
+        case MR_TYPECTOR_REP_INT8:
+        case MR_TYPECTOR_REP_UINT8:
+        case MR_TYPECTOR_REP_INT16:
+        case MR_TYPECTOR_REP_UINT16:
+        case MR_TYPECTOR_REP_INT32:
+        case MR_TYPECTOR_REP_UINT32:
          case MR_TYPECTOR_REP_FLOAT:
          case MR_TYPECTOR_REP_CHAR:
          case MR_TYPECTOR_REP_STRING:
diff --git a/runtime/mercury_deep_copy_body.h b/runtime/mercury_deep_copy_body.h
index df0aa33bd..1876a431b 100644
--- a/runtime/mercury_deep_copy_body.h
+++ b/runtime/mercury_deep_copy_body.h
@@ -408,6 +408,12 @@ try_again:

      case MR_TYPECTOR_REP_INT:  // fallthru
      case MR_TYPECTOR_REP_UINT: // fallthru
+    case MR_TYPECTOR_REP_INT8:  // fallthru
+    case MR_TYPECTOR_REP_UINT8: // fallthru
+    case MR_TYPECTOR_REP_INT16:  // fallthru
+    case MR_TYPECTOR_REP_UINT16: // fallthru
+    case MR_TYPECTOR_REP_INT32:  // fallthru
+    case MR_TYPECTOR_REP_UINT32: // fallthru
      case MR_TYPECTOR_REP_CHAR:
          return data;

diff --git a/runtime/mercury_dotnet.cs.in b/runtime/mercury_dotnet.cs.in
index 2e3cb1a7a..5767d272e 100644
--- a/runtime/mercury_dotnet.cs.in
+++ b/runtime/mercury_dotnet.cs.in
@@ -301,45 +301,51 @@ public enum TypeCtorRep {
      MR_TYPECTOR_REP_FUNC                    = 7,
      MR_TYPECTOR_REP_INT                     = 8,
      MR_TYPECTOR_REP_UINT                    = 9,
-    MR_TYPECTOR_REP_CHAR                    = 10,
-    MR_TYPECTOR_REP_FLOAT                   = 11,
-    MR_TYPECTOR_REP_STRING                  = 12,
-    MR_TYPECTOR_REP_PRED                    = 13,
-    MR_TYPECTOR_REP_SUBGOAL                 = 14,
-    MR_TYPECTOR_REP_VOID                    = 15,
-    MR_TYPECTOR_REP_C_POINTER               = 16,
-    MR_TYPECTOR_REP_TYPEINFO                = 17,
-    MR_TYPECTOR_REP_TYPECLASSINFO           = 18,
-    MR_TYPECTOR_REP_ARRAY                   = 19,
-    MR_TYPECTOR_REP_SUCCIP                  = 20,
-    MR_TYPECTOR_REP_HP                      = 21,
-    MR_TYPECTOR_REP_CURFR                   = 22,
-    MR_TYPECTOR_REP_MAXFR                   = 23,
-    MR_TYPECTOR_REP_REDOFR                  = 24,
-    MR_TYPECTOR_REP_REDOIP                  = 25,
-    MR_TYPECTOR_REP_TRAIL_PTR               = 26,
-    MR_TYPECTOR_REP_TICKET                  = 27,
-    MR_TYPECTOR_REP_NOTAG_GROUND            = 28,
-    MR_TYPECTOR_REP_NOTAG_GROUND_USEREQ     = 29,
-    MR_TYPECTOR_REP_EQUIV_GROUND            = 30,
-    MR_TYPECTOR_REP_TUPLE                   = 31,
-    MR_TYPECTOR_REP_RESERVED_ADDR           = 32,
-    MR_TYPECTOR_REP_RESERVED_ADDR_USEREQ    = 33,
-    MR_TYPECTOR_REP_TYPECTORINFO            = 34,
-    MR_TYPECTOR_REP_BASETYPECLASSINFO       = 35,
-    MR_TYPECTOR_REP_TYPEDESC                = 36,
-    MR_TYPECTOR_REP_TYPECTORDESC            = 37,
-    MR_TYPECTOR_REP_FOREIGN                 = 38,
-    MR_TYPECTOR_REP_REFERENCE               = 39,
-    MR_TYPECTOR_REP_STABLE_C_POINTER        = 40,
-    MR_TYPECTOR_REP_STABLE_FOREIGN          = 41,
-    MR_TYPECTOR_REP_PSEUDOTYPEDESC          = 42,
-    MR_TYPECTOR_REP_DUMMY                   = 43,
-    MR_TYPECTOR_REP_BITMAP                  = 44,
-    MR_TYPECTOR_REP_FOREIGN_ENUM            = 45,
-    MR_TYPECTOR_REP_FOREIGN_ENUM_USEREQ     = 46,
-    MR_TYPECTOR_REP_UNKNOWN                 = 47,
-    MR_TYPECTOR_REP_MAX                     = 48
+    MR_TYPECTOR_REP_INT8                    = 10,
+    MR_TYPECTOR_REP_UINT8                   = 11,
+    MR_TYPECTOR_REP_INT16                   = 12,
+    MR_TYPECTOR_REP_UINT16                  = 13,
+    MR_TYPECTOR_REP_INT32                   = 14,
+    MR_TYPECTOR_REP_UINT32                  = 15,
+    MR_TYPECTOR_REP_CHAR                    = 16,
+    MR_TYPECTOR_REP_FLOAT                   = 17,
+    MR_TYPECTOR_REP_STRING                  = 18,
+    MR_TYPECTOR_REP_PRED                    = 19,
+    MR_TYPECTOR_REP_SUBGOAL                 = 20,
+    MR_TYPECTOR_REP_VOID                    = 21,
+    MR_TYPECTOR_REP_C_POINTER               = 22,
+    MR_TYPECTOR_REP_TYPEINFO                = 23,
+    MR_TYPECTOR_REP_TYPECLASSINFO           = 24,
+    MR_TYPECTOR_REP_ARRAY                   = 25,
+    MR_TYPECTOR_REP_SUCCIP                  = 26,
+    MR_TYPECTOR_REP_HP                      = 27,
+    MR_TYPECTOR_REP_CURFR                   = 28,
+    MR_TYPECTOR_REP_MAXFR                   = 29,
+    MR_TYPECTOR_REP_REDOFR                  = 30,
+    MR_TYPECTOR_REP_REDOIP                  = 31,
+    MR_TYPECTOR_REP_TRAIL_PTR               = 32,
+    MR_TYPECTOR_REP_TICKET                  = 33,
+    MR_TYPECTOR_REP_NOTAG_GROUND            = 34,
+    MR_TYPECTOR_REP_NOTAG_GROUND_USEREQ     = 35,
+    MR_TYPECTOR_REP_EQUIV_GROUND            = 36,
+    MR_TYPECTOR_REP_TUPLE                   = 37,
+    MR_TYPECTOR_REP_RESERVED_ADDR           = 38,
+    MR_TYPECTOR_REP_RESERVED_ADDR_USEREQ    = 39,
+    MR_TYPECTOR_REP_TYPECTORINFO            = 40,
+    MR_TYPECTOR_REP_BASETYPECLASSINFO       = 41,
+    MR_TYPECTOR_REP_TYPEDESC                = 42,
+    MR_TYPECTOR_REP_TYPECTORDESC            = 43,
+    MR_TYPECTOR_REP_FOREIGN                 = 44,
+    MR_TYPECTOR_REP_REFERENCE               = 45,
+    MR_TYPECTOR_REP_STABLE_C_POINTER        = 46,
+    MR_TYPECTOR_REP_STABLE_FOREIGN          = 47,
+    MR_TYPECTOR_REP_PSEUDOTYPEDESC          = 48,
+    MR_TYPECTOR_REP_DUMMY                   = 49,
+    MR_TYPECTOR_REP_BITMAP                  = 50,
+    MR_TYPECTOR_REP_FOREIGN_ENUM            = 51,
+    MR_TYPECTOR_REP_FOREIGN_ENUM_USEREQ     = 52,
+    MR_TYPECTOR_REP_UNKNOWN                 = 53,
+    MR_TYPECTOR_REP_MAX                     = 54
  }

  public class PseudoTypeInfo {
diff --git a/runtime/mercury_grade.h b/runtime/mercury_grade.h
index 28473aaa2..5560a277c 100644
--- a/runtime/mercury_grade.h
+++ b/runtime/mercury_grade.h
@@ -76,7 +76,7 @@
  // breaks binary backwards compatibility only in debugging, deep profiling
  // and low-level C parallel grades respectively.

-#define MR_GRADE_PART_0 v19_
+#define MR_GRADE_PART_0 v20_
  #define MR_GRADE_EXEC_TRACE_VERSION_NO  12
  #define MR_GRADE_DEEP_PROF_VERSION_NO   4
  #define MR_GRADE_LLC_PAR_VERSION_NO 1
diff --git a/runtime/mercury_ml_expand_body.h b/runtime/mercury_ml_expand_body.h
index e62639b34..656d2b319 100644
--- a/runtime/mercury_ml_expand_body.h
+++ b/runtime/mercury_ml_expand_body.h
@@ -793,6 +793,114 @@ EXPAND_FUNCTION_NAME(MR_TypeInfo type_info, MR_Word *data_word_ptr,
              handle_zero_arity_args();
              return;

+        case MR_TYPECTOR_REP_INT8:
+#ifdef  EXPAND_FUNCTOR_FIELD
+            {
+                MR_Word data_word;
+                char    buf[500];
+                char    *str;
+
+                data_word = *data_word_ptr;
+                sprintf(buf, "%" MR_INTEGER_LENGTH_MODIFIER "di8",
+                    (MR_Integer) data_word);
+                MR_make_aligned_string_copy_saved_hp(str, buf, NULL);
+                expand_info->EXPAND_FUNCTOR_FIELD = str;
+            }
+#endif  // EXPAND_FUNCTOR_FIELD
+
+            handle_zero_arity_args();
+            return;
+
+        case MR_TYPECTOR_REP_UINT8:
+#ifdef  EXPAND_FUNCTOR_FIELD
+            {
+                MR_Word data_word;
+                char    buf[500];
+                char    *str;
+
+                data_word = *data_word_ptr;
+                sprintf(buf, "%" MR_INTEGER_LENGTH_MODIFIER "uu8",
+                    (MR_Unsigned) data_word);
+                MR_make_aligned_string_copy_saved_hp(str, buf, NULL);
+                expand_info->EXPAND_FUNCTOR_FIELD = str;
+            }
+#endif  // EXPAND_FUNCTOR_FIELD
+
+            handle_zero_arity_args();
+            return;
+ 
+        case MR_TYPECTOR_REP_INT16:
+#ifdef  EXPAND_FUNCTOR_FIELD
+            {
+                MR_Word data_word;
+                char    buf[500];
+                char    *str;
+
+                data_word = *data_word_ptr;
+                sprintf(buf, "%" MR_INTEGER_LENGTH_MODIFIER "di16",
+                    (MR_Integer) data_word);
+                MR_make_aligned_string_copy_saved_hp(str, buf, NULL);
+                expand_info->EXPAND_FUNCTOR_FIELD = str;
+            }
+#endif  // EXPAND_FUNCTOR_FIELD
+
+            handle_zero_arity_args();
+            return;
+
+        case MR_TYPECTOR_REP_UINT16:
+#ifdef  EXPAND_FUNCTOR_FIELD
+            {
+                MR_Word data_word;
+                char    buf[500];
+                char    *str;
+
+                data_word = *data_word_ptr;
+                sprintf(buf, "%" MR_INTEGER_LENGTH_MODIFIER "uu16",
+                    (MR_Unsigned) data_word);
+                MR_make_aligned_string_copy_saved_hp(str, buf, NULL);
+                expand_info->EXPAND_FUNCTOR_FIELD = str;
+            }
+#endif  // EXPAND_FUNCTOR_FIELD
+
+            handle_zero_arity_args();
+            return;
+
+        case MR_TYPECTOR_REP_INT32:
+#ifdef  EXPAND_FUNCTOR_FIELD
+            {
+                MR_Word data_word;
+                char    buf[500];
+                char    *str;
+
+                data_word = *data_word_ptr;
+                sprintf(buf, "%" MR_INTEGER_LENGTH_MODIFIER "di32",
+                    (MR_Integer) data_word);
+                MR_make_aligned_string_copy_saved_hp(str, buf, NULL);
+                expand_info->EXPAND_FUNCTOR_FIELD = str;
+            }
+#endif  // EXPAND_FUNCTOR_FIELD
+
+            handle_zero_arity_args();
+            return;
+
+        case MR_TYPECTOR_REP_UINT32:
+#ifdef  EXPAND_FUNCTOR_FIELD
+            {
+                MR_Word data_word;
+                char    buf[500];
+                char    *str;
+
+                data_word = *data_word_ptr;
+                sprintf(buf, "%" MR_INTEGER_LENGTH_MODIFIER "uu32",
+                    (MR_Unsigned) data_word);
+                MR_make_aligned_string_copy_saved_hp(str, buf, NULL);
+                expand_info->EXPAND_FUNCTOR_FIELD = str;
+            }
+#endif  // EXPAND_FUNCTOR_FIELD
+
+            handle_zero_arity_args();
+            return;
+
          case MR_TYPECTOR_REP_CHAR:
  #ifdef  EXPAND_FUNCTOR_FIELD
              {
diff --git a/runtime/mercury_std.h b/runtime/mercury_std.h
index b19034ecf..c8bb661f8 100644
--- a/runtime/mercury_std.h
+++ b/runtime/mercury_std.h
@@ -16,6 +16,12 @@

  #include "mercury_regs.h"

+#if defined(MR_HAVE_STDINT_H)
+    #include <stdint.h>
+#else
+    #error "Mercury requires a system that provides stdint.h"
+#endif
+
  #include <stdlib.h> // for size_t
  #include <assert.h> // for assert()
  #include <errno.h>  // for EINTR
diff --git a/runtime/mercury_table_type_body.h b/runtime/mercury_table_type_body.h
index 1de1e392f..bf1883c24 100644
--- a/runtime/mercury_table_type_body.h
+++ b/runtime/mercury_table_type_body.h
@@ -307,6 +307,36 @@
              table = table_next;
              return table;

+        case MR_TYPECTOR_REP_INT8:
+            MR_TABLE_INT8(STATS, DEBUG, BACK, table_next, table, data);
+            table = table_next;
+            return table;
+
+        case MR_TYPECTOR_REP_UINT8:
+            MR_TABLE_UINT8(STATS, DEBUG, BACK, table_next, table, data);
+            table = table_next;
+            return table;
+
+        case MR_TYPECTOR_REP_INT16:
+            MR_TABLE_INT16(STATS, DEBUG, BACK, table_next, table, data);
+            table = table_next;
+            return table;
+
+        case MR_TYPECTOR_REP_UINT16:
+            MR_TABLE_UINT16(STATS, DEBUG, BACK, table_next, table, data);
+            table = table_next;
+            return table;
+
+        case MR_TYPECTOR_REP_INT32:
+            MR_TABLE_INT32(STATS, DEBUG, BACK, table_next, table, data);
+            table = table_next;
+            return table;
+
+        case MR_TYPECTOR_REP_UINT32:
+            MR_TABLE_UINT32(STATS, DEBUG, BACK, table_next, table, data);
+            table = table_next;
+            return table;
+
          case MR_TYPECTOR_REP_CHAR:
              MR_TABLE_CHAR(STATS, DEBUG, BACK, table_next, table, data);
              table = table_next;
diff --git a/runtime/mercury_tabling_macros.h b/runtime/mercury_tabling_macros.h
index 50ee970b3..2c773e973 100644
--- a/runtime/mercury_tabling_macros.h
+++ b/runtime/mercury_tabling_macros.h
@@ -71,10 +71,46 @@
  #define MR_RAW_TABLE_INT_STATS(stats, table, value)                         \
      MR_int_hash_lookup_or_add_stats((stats), (table), (value));

-#define MR_RAW_TABLE_UINT(table, value)                                      \
+#define MR_RAW_TABLE_UINT(table, value)                                     \
      MR_word_hash_lookup_or_add((table), (value));

-#define MR_RAW_TABLE_UINT_STATS(stats, table, value)                         \
+#define MR_RAW_TABLE_UINT_STATS(stats, table, value)                        \
+    MR_word_hash_lookup_or_add_stats((stats), (table), (value));
+
+#define MR_RAW_TABLE_INT8(table, value)                                     \
+    MR_int_hash_lookup_or_add((table), (value));
+
+#define MR_RAW_TABLE_INT8_STATS(stats, table, value)                        \
+    MR_int_hash_lookup_or_add_stats((stats), (table), (value));
+
+#define MR_RAW_TABLE_UINT8(table, value)                                    \
+    MR_word_hash_lookup_or_add((table), (value));
+
+#define MR_RAW_TABLE_UINT8_STATS(stats, table, value)                       \
+    MR_word_hash_lookup_or_add_stats((stats), (table), (value));
+
+#define MR_RAW_TABLE_INT16(table, value)                                    \
+    MR_int_hash_lookup_or_add((table), (value));
+
+#define MR_RAW_TABLE_INT16_STATS(stats, table, value)                       \
+    MR_int_hash_lookup_or_add_stats((stats), (table), (value));
+
+#define MR_RAW_TABLE_UINT16(table, value)                                   \
+    MR_word_hash_lookup_or_add((table), (value));
+
+#define MR_RAW_TABLE_UINT16_STATS(stats, table, value)                      \
+    MR_word_hash_lookup_or_add_stats((stats), (table), (value));
+
+#define MR_RAW_TABLE_INT32(table, value)                                    \
+    MR_int_hash_lookup_or_add((table), (value));
+
+#define MR_RAW_TABLE_INT32_STATS(stats, table, value)                       \
+    MR_int_hash_lookup_or_add_stats((stats), (table), (value));
+
+#define MR_RAW_TABLE_UINT32(table, value)                                   \
+    MR_word_hash_lookup_or_add((table), (value));
+
+#define MR_RAW_TABLE_UINT32_STATS(stats, table, value)                      \
      MR_word_hash_lookup_or_add_stats((stats), (table), (value));

  #define MR_RAW_TABLE_CHAR(table, value)                                     \
@@ -236,6 +272,85 @@
          }                                                                   \
      } while (0)

+#define MR_TABLE_INT8(stats, debug, back, t, t0, value)                     \
+    do {                                                                    \
+        if (stats != NULL) {                                                \
+            (t) = MR_RAW_TABLE_INT8_STATS((stats), (t0), (value));          \
+        } else {                                                            \
+            (t) = MR_RAW_TABLE_INT8((t0), (value));                         \
+        }                                                                   \
+        if (MR_tabledebug) {                                                \
+            printf("TABLE %p: int8 %ld => %p\n",                            \
+                (t0), (long) (value), (t));                                 \
+        }                                                                   \
+    } while (0)
+
+#define MR_TABLE_UINT8(stats, debug, back, t, t0, value)                    \
+    do {                                                                    \
+        if (stats != NULL) {                                                \
+            (t) = MR_RAW_TABLE_UINT8_STATS((stats), (t0), (value));         \
+        } else {                                                            \
+            (t) = MR_RAW_TABLE_UINT8((t0), (value));                        \
+        }                                                                   \
+        if (MR_tabledebug) {                                                \
+            printf("TABLE %p: uint8 %lu => %p\n",                           \
+                (t0), (unsigned long) (value), (t));                        \
+        }                                                                   \
+    } while (0)
+
+#define MR_TABLE_INT16(stats, debug, back, t, t0, value)                    \
+    do {                                                                    \
+        if (stats != NULL) {                                                \
+            (t) = MR_RAW_TABLE_INT16_STATS((stats), (t0), (value));         \
+        } else {                                                            \
+            (t) = MR_RAW_TABLE_INT16((t0), (value));                        \
+        }                                                                   \
+        if (MR_tabledebug) {                                                \
+            printf("TABLE %p: int16 %ld => %p\n",                           \
+                (t0), (long) (value), (t));                                 \
+        }                                                                   \
+    } while (0)
+
+#define MR_TABLE_UINT16(stats, debug, back, t, t0, value)                   \
+    do {                                                                    \
+        if (stats != NULL) {                                                \
+            (t) = MR_RAW_TABLE_UINT16_STATS((stats), (t0), (value));        \
+        } else {                                                            \
+            (t) = MR_RAW_TABLE_UINT16((t0), (value));                       \
+        }                                                                   \
+        if (MR_tabledebug) {                                                \
+            printf("TABLE %p: uint16 %lu => %p\n",                          \
+                (t0), (unsigned long) (value), (t));                        \
+        }                                                                   \
+    } while (0)
+
+#define MR_TABLE_INT32(stats, debug, back, t, t0, value)                    \
+    do {                                                                    \
+        if (stats != NULL) {                                                \
+            (t) = MR_RAW_TABLE_INT32_STATS((stats), (t0), (value));         \
+        } else {                                                            \
+            (t) = MR_RAW_TABLE_INT32((t0), (value));                        \
+        }                                                                   \
+        if (MR_tabledebug) {                                                \
+            printf("TABLE %p: int32 %ld => %p\n",                           \
+                (t0), (long) (value), (t));                                 \
+        }                                                                   \
+    } while (0)
+
+
+#define MR_TABLE_UINT32(stats, debug, back, t, t0, value)                   \
+    do {                                                                    \
+        if (stats != NULL) {                                                \
+            (t) = MR_RAW_TABLE_UINT32_STATS((stats), (t0), (value));        \
+        } else {                                                            \
+            (t) = MR_RAW_TABLE_UINT32((t0), (value));                       \
+        }                                                                   \
+        if (MR_tabledebug) {                                                \
+            printf("TABLE %p: uint32 %lu => %p\n",                          \
+                (t0), (unsigned long) (value), (t));                        \
+        }                                                                   \
+    } while (0)
+
  #define MR_TABLE_CHAR(stats, debug, back, t, t0, value)                     \
      do {                                                                    \
          if (stats != NULL) {                                                \
diff --git a/runtime/mercury_tabling_preds.h b/runtime/mercury_tabling_preds.h
index 5e8faea6a..e3b8749f2 100644
--- a/runtime/mercury_tabling_preds.h
+++ b/runtime/mercury_tabling_preds.h
@@ -20,6 +20,18 @@
          MR_tbl_lookup_insert_int(NULL, MR_FALSE, MR_FALSE, a, b, c)
  #define MR_table_lookup_insert_uint(a, b, c)                                \
          MR_tbl_lookup_insert_uint(NULL, MR_FALSE, MR_FALSE, a, b, c)
+#define MR_table_lookup_insert_int8(a, b, c)                                \
+        MR_tbl_lookup_insert_int8(NULL, MR_FALSE, MR_FALSE, a, b, c)
+#define MR_table_lookup_insert_uint8(a, b, c)                               \
+        MR_tbl_lookup_insert_uint8(NULL, MR_FALSE, MR_FALSE, a, b, c)
+#define MR_table_lookup_insert_int16(a, b, c)                               \
+        MR_tbl_lookup_insert_int16(NULL, MR_FALSE, MR_FALSE, a, b, c)
+#define MR_table_lookup_insert_uint16(a, b, c)                              \
+        MR_tbl_lookup_insert_uint16(NULL, MR_FALSE, MR_FALSE, a, b, c)
+#define MR_table_lookup_insert_int32(a, b, c)                               \
+        MR_tbl_lookup_insert_int32(NULL, MR_FALSE, MR_FALSE, a, b, c)
+#define MR_table_lookup_insert_uint32(a, b, c)                              \
+        MR_tbl_lookup_insert_uint32(NULL, MR_FALSE, MR_FALSE, a, b, c)
  #define MR_table_lookup_insert_start_int(a, b, c, d)                        \
          MR_tbl_lookup_insert_start_int(NULL, MR_FALSE, MR_FALSE, a, b, c, d)
  #define MR_table_lookup_insert_char(a, b, c)                                \
@@ -49,6 +61,18 @@
          MR_tbl_save_any_answer(MR_FALSE, a, b, c)
  #define MR_table_save_uint_answer(a, b, c)                                  \
          MR_tbl_save_any_answer(MR_FALSE, a, b, c)
+#define MR_table_save_int8_answer(a, b, c)                                  \
+        MR_tbl_save_any_answer(MR_FALSE, a, b, c)
+#define MR_table_save_uint8_answer(a, b, c)                                 \
+        MR_tbl_save_any_answer(MR_FALSE, a, b, c)
+#define MR_table_save_int16_answer(a, b, c)                                 \
+        MR_tbl_save_any_answer(MR_FALSE, a, b, c)
+#define MR_table_save_uint16_answer(a, b, c)                                \
+        MR_tbl_save_any_answer(MR_FALSE, a, b, c)
+#define MR_table_save_int32_answer(a, b, c)                                 \
+        MR_tbl_save_any_answer(MR_FALSE, a, b, c)
+#define MR_table_save_uint32_answer(a, b, c)                                \
+        MR_tbl_save_any_answer(MR_FALSE, a, b, c)
  #define MR_table_save_char_answer(a, b, c)                                  \
          MR_tbl_save_char_answer(MR_FALSE, a, b, c)
  #define MR_table_save_string_answer(a, b, c)                                \
@@ -64,6 +88,18 @@
          MR_tbl_restore_any_answer(MR_FALSE, a, b, c)
  #define MR_table_restore_uint_answer(a, b, c)                               \
          MR_tbl_restore_any_answer(MR_FALSE, a, b, c)
+#define MR_table_restore_int8_answer(a, b, c)                               \
+        MR_tbl_restore_any_answer(MR_FALSE, a, b, c)
+#define MR_table_restore_uint8_answer(a, b, c)                              \
+        MR_tbl_restore_any_answer(MR_FALSE, a, b, c)
+#define MR_table_restore_int16_answer(a, b, c)                              \
+        MR_tbl_restore_any_answer(MR_FALSE, a, b, c)
+#define MR_table_restore_uint16_answer(a, b, c)                             \
+        MR_tbl_restore_any_answer(MR_FALSE, a, b, c)
+#define MR_table_restore_int32_answer(a, b, c)                              \
+        MR_tbl_restore_any_answer(MR_FALSE, a, b, c)
+#define MR_table_restore_uint32_answer(a, b, c)                             \
+        MR_tbl_restore_any_answer(MR_FALSE, a, b, c)
  #define MR_table_restore_char_answer(a, b, c)                               \
          MR_tbl_restore_char_answer(MR_FALSE, a, b, c)
  #define MR_table_restore_string_answer(a, b, c)                             \
@@ -159,6 +195,36 @@
          MR_TABLE_UINT(stats, debug, back, T, T0, (MR_Unsigned) V);          \
      } while (0)

+#define MR_tbl_lookup_insert_int8(stats, debug, back, T0, V, T)             \
+    do {                                                                    \
+        MR_TABLE_INT8(stats, debug, back, T, T0, (MR_Integer) V);           \
+    } while (0)
+
+#define MR_tbl_lookup_insert_uint8(stats, debug, back, T0, V, T)            \
+    do {                                                                    \
+        MR_TABLE_UINT8(stats, debug, back, T, T0, (MR_Unsigned) V);         \
+    } while (0)
+
+#define MR_tbl_lookup_insert_int16(stats, debug, back, T0, V, T)            \
+    do {                                                                    \
+        MR_TABLE_INT16(stats, debug, back, T, T0, (MR_Integer) V);          \
+    } while (0)
+
+#define MR_tbl_lookup_insert_uint16(stats, debug, back, T0, V, T)           \
+    do {                                                                    \
+        MR_TABLE_UINT16(stats, debug, back, T, T0, (MR_Unsigned) V);        \
+    } while (0)
+
+#define MR_tbl_lookup_insert_int32(stats, debug, back, T0, V, T)            \
+    do {                                                                    \
+        MR_TABLE_INT32(stats, debug, back, T, T0, (MR_Integer) V);          \
+    } while (0)
+
+#define MR_tbl_lookup_insert_uint32(stats, debug, back, T0, V, T)           \
+    do {                                                                    \
+        MR_TABLE_UINT32(stats, debug, back, T, T0, (MR_Unsigned) V);        \
+    } while (0)
+
  #define MR_tbl_lookup_insert_start_int(stats, debug, back, T0, S, V, T)     \
      do {                                                                    \
          MR_TABLE_START_INT(stats, debug, back, T, T0,                       \
@@ -238,6 +304,42 @@
              &MR_TYPE_CTOR_INFO_NAME(builtin, uint, 0));                     \
      } while (0)

+#define MR_tbl_save_int8_answer(debug, AB, Offset, V)                       \
+    do {                                                                    \
+        MR_TABLE_SAVE_ANSWER(debug, AB, Offset, V,                          \
+            &MR_TYPE_CTOR_INFO_NAME(builtin, int8, 0));                     \
+    } while (0)
+
+#define MR_tbl_save_uint8_answer(debug, AB, Offset, V)                      \
+    do {                                                                    \
+        MR_TABLE_SAVE_ANSWER(debug, AB, Offset, V,                          \
+            &MR_TYPE_CTOR_INFO_NAME(builtin, uint8, 0));                    \
+    } while (0)
+
+#define MR_tbl_save_int16_answer(debug, AB, Offset, V)                      \
+    do {                                                                    \
+        MR_TABLE_SAVE_ANSWER(debug, AB, Offset, V,                          \
+            &MR_TYPE_CTOR_INFO_NAME(builtin, int16, 0));                    \
+    } while (0)
+
+#define MR_tbl_save_uint16_answer(debug, AB, Offset, V)                     \
+    do {                                                                    \
+        MR_TABLE_SAVE_ANSWER(debug, AB, Offset, V,                          \
+            &MR_TYPE_CTOR_INFO_NAME(builtin, uint16, 0));                   \
+    } while (0)
+
+#define MR_tbl_save_int32_answer(debug, AB, Offset, V)                      \
+    do {                                                                    \
+        MR_TABLE_SAVE_ANSWER(debug, AB, Offset, V,                          \
+            &MR_TYPE_CTOR_INFO_NAME(builtin, int32, 0));                    \
+    } while (0)
+
+#define MR_tbl_save_uint32_answer(debug, AB, Offset, V)                     \
+    do {                                                                    \
+        MR_TABLE_SAVE_ANSWER(debug, AB, Offset, V,                          \
+            &MR_TYPE_CTOR_INFO_NAME(builtin, uint32, 0));                   \
+    } while (0)
+
  #define MR_tbl_save_char_answer(debug, AB, Offset, V)                       \
      do {                                                                    \
          MR_TABLE_SAVE_ANSWER(debug, AB, Offset, V,                          \
@@ -279,6 +381,36 @@
          V = (MR_Unsigned) MR_TABLE_GET_ANSWER(debug, AB, Offset);           \
      } while (0)

+#define MR_tbl_restore_int8_answer(debug, AB, Offset, V)                    \
+    do {                                                                    \
+        V = (int8_t) MR_TABLE_GET_ANSWER(debug, AB, Offset);                \
+    } while (0)
+
+#define MR_tbl_restore_uint8_answer(debug, AB, Offset, V)                   \
+    do {                                                                    \
+        V = (uint8_t) MR_TABLE_GET_ANSWER(debug, AB, Offset);               \
+    } while (0)
+
+#define MR_tbl_restore_int16_answer(debug, AB, Offset, V)                   \
+    do {                                                                    \
+        V = (int16_t) MR_TABLE_GET_ANSWER(debug, AB, Offset);               \
+    } while (0)
+
+#define MR_tbl_restore_uint16_answer(debug, AB, Offset, V)                  \
+    do {                                                                    \
+        V = (uint16_t) MR_TABLE_GET_ANSWER(debug, AB, Offset);              \
+    } while (0)
+
+#define MR_tbl_restore_int32_answer(debug, AB, Offset, V)                   \
+    do {                                                                    \
+        V = (int32_t) MR_TABLE_GET_ANSWER(debug, AB, Offset);               \
+    } while (0)
+
+#define MR_tbl_restore_uint32_answer(debug, AB, Offset, V)                  \
+    do {                                                                    \
+        V = (uint32_t) MR_TABLE_GET_ANSWER(debug, AB, Offset);              \
+    } while (0)
+
  #define MR_tbl_restore_char_answer(debug, AB, Offset, V)                    \
      do {                                                                    \
          V = (MR_Char) MR_TABLE_GET_ANSWER(debug, AB, Offset);               \
diff --git a/runtime/mercury_term_size.c b/runtime/mercury_term_size.c
index 4a8783702..e2115e142 100644
--- a/runtime/mercury_term_size.c
+++ b/runtime/mercury_term_size.c
@@ -262,6 +262,66 @@ try_again:
  #endif
              return 0;

+        case MR_TYPECTOR_REP_INT8:
+#ifdef MR_DEBUG_TERM_SIZES
+            if (MR_heapdebug && MR_lld_print_enabled) {
+                printf(
+                    "MR_term_size: int8 %p %" MR_INTEGER_LENGTH_MODIFIER "d\n",
+                    (void *) term, (MR_Integer) term);
+            }
+#endif
+            return 0;
+
+        case MR_TYPECTOR_REP_UINT8:
+#ifdef MR_DEBUG_TERM_SIZES
+            if (MR_heapdebug && MR_lld_print_enabled) {
+                printf(
+                    "MR_term_size: uint8 %p %" MR_INTEGER_LENGTH_MODIFIER "u\n",
+                    (void *) term, (MR_Unsigned) term);
+            }
+#endif
+            return 0;
+
+        case MR_TYPECTOR_REP_INT16:
+#ifdef MR_DEBUG_TERM_SIZES
+            if (MR_heapdebug && MR_lld_print_enabled) {
+                printf(
+                    "MR_term_size: int16 %p %" MR_INTEGER_LENGTH_MODIFIER "d\n",
+                    (void *) term, (MR_Integer) term);
+            }
+#endif
+            return 0;
+
+        case MR_TYPECTOR_REP_UINT16:
+#ifdef MR_DEBUG_TERM_SIZES
+            if (MR_heapdebug && MR_lld_print_enabled) {
+                printf(
+                    "MR_term_size: uint16 %p %" MR_INTEGER_LENGTH_MODIFIER "u\n",
+                    (void *) term, (MR_Unsigned) term);
+            }
+#endif
+            return 0;
+
+        case MR_TYPECTOR_REP_INT32:
+#ifdef MR_DEBUG_TERM_SIZES
+            if (MR_heapdebug && MR_lld_print_enabled) {
+                printf(
+                    "MR_term_size: int32 %p %" MR_INTEGER_LENGTH_MODIFIER "d\n",
+                    (void *) term, (MR_Integer) term);
+            }
+#endif
+            return 0;
+
+        case MR_TYPECTOR_REP_UINT32:
+#ifdef MR_DEBUG_TERM_SIZES
+            if (MR_heapdebug && MR_lld_print_enabled) {
+                printf(
+                    "MR_term_size: uint32 %p %" MR_INTEGER_LENGTH_MODIFIER "u\n",
+                    (void *) term, (MR_Unsigned) term);
+            }
+#endif
+            return 0;
+
          case MR_TYPECTOR_REP_CHAR:
  #ifdef MR_DEBUG_TERM_SIZES
              if (MR_heapdebug && MR_lld_print_enabled) {
diff --git a/runtime/mercury_type_info.h b/runtime/mercury_type_info.h
index 9c4878af0..d0768d7e3 100644
--- a/runtime/mercury_type_info.h
+++ b/runtime/mercury_type_info.h
@@ -69,7 +69,7 @@
  // This number should be kept in sync with type_ctor_info_rtti_version in
  // compiler/type_ctor_info.m.

-#define MR_RTTI_VERSION                     MR_RTTI_VERSION__UINT
+#define MR_RTTI_VERSION                     MR_RTTI_VERSION__FIXED_SIZE_INTS
  #define MR_RTTI_VERSION__INITIAL            2
  #define MR_RTTI_VERSION__USEREQ             3
  #define MR_RTTI_VERSION__CLEAN_LAYOUT       4
@@ -86,6 +86,7 @@
  #define MR_RTTI_VERSION__ARG_WIDTHS         15
  #define MR_RTTI_VERSION__FUNCTOR_SUBTYPE    16
  #define MR_RTTI_VERSION__UINT               17
+#define MR_RTTI_VERSION__FIXED_SIZE_INTS    18

  // Check that the RTTI version is in a sensible range.
  // The lower bound should be the lowest currently supported version number.
@@ -566,6 +567,12 @@ typedef enum {
      MR_DEFINE_BUILTIN_ENUM_CONST(MR_TYPECTOR_REP_FUNC),
      MR_DEFINE_BUILTIN_ENUM_CONST(MR_TYPECTOR_REP_INT),
      MR_DEFINE_BUILTIN_ENUM_CONST(MR_TYPECTOR_REP_UINT),
+    MR_DEFINE_BUILTIN_ENUM_CONST(MR_TYPECTOR_REP_INT8),
+    MR_DEFINE_BUILTIN_ENUM_CONST(MR_TYPECTOR_REP_UINT8),
+    MR_DEFINE_BUILTIN_ENUM_CONST(MR_TYPECTOR_REP_INT16),
+    MR_DEFINE_BUILTIN_ENUM_CONST(MR_TYPECTOR_REP_UINT16),
+    MR_DEFINE_BUILTIN_ENUM_CONST(MR_TYPECTOR_REP_INT32),
+    MR_DEFINE_BUILTIN_ENUM_CONST(MR_TYPECTOR_REP_UINT32),
      MR_DEFINE_BUILTIN_ENUM_CONST(MR_TYPECTOR_REP_CHAR),
      MR_DEFINE_BUILTIN_ENUM_CONST(MR_TYPECTOR_REP_FLOAT),
      MR_DEFINE_BUILTIN_ENUM_CONST(MR_TYPECTOR_REP_STRING),
@@ -636,6 +643,12 @@ typedef MR_int_least16_t  MR_TypeCtorRepInt;
      "FUNC",                                                             \
      "INT",                                                              \
      "UINT",                                                             \
+    "INT8",                                                             \
+    "UINT8",                                                            \
+    "INT16",                                                            \
+    "UINT16",                                                           \
+    "INT32",                                                            \
+    "UINT32",                                                           \
      "CHAR",                                                             \
      "FLOAT",                                                            \
      "STRING",                                                           \
@@ -1415,6 +1428,24 @@ typedef void MR_CALL MR_CompareFunc_5(MR_Mercury_Type_Info,
    #define MR_UINT_CTOR_ADDR                                               \
        (MR_Word *) &mercury__builtin__builtin__type_ctor_info_uint_0
        // (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(builtin, uint, 0)
+  #define MR_INT8_CTOR_ADDR                                               \
+      (MR_Word *) &mercury__builtin__builtin__type_ctor_info_int8_0
+      // (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(builtin, int8, 0)
+  #define MR_UINT8_CTOR_ADDR                                              \
+      (MR_Word *) &mercury__builtin__builtin__type_ctor_info_uint8_0
+      // (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(builtin, uint8, 0)
+  #define MR_INT16_CTOR_ADDR                                              \
+      (MR_Word *) &mercury__builtin__builtin__type_ctor_info_int16_0
+      // (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(builtin, int16, 0)
+  #define MR_UINT16_CTOR_ADDR                                             \
+      (MR_Word *) &mercury__builtin__builtin__type_ctor_info_uint16_0
+      // (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(builtin, uint16, 0)
+  #define MR_INT32_CTOR_ADDR                                              \
+      (MR_Word *) &mercury__builtin__builtin__type_ctor_info_int32_0
+      // (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(builtin, int32, 0)
+  #define MR_UINT32_CTOR_ADDR                                             \
+      (MR_Word *) &mercury__builtin__builtin__type_ctor_info_uint32_0
+      // (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(builtin, uint32, 0)
    #define MR_FLOAT_CTOR_ADDR                                              \
        (MR_Word *) &mercury__builtin__builtin__type_ctor_info_float_0
        // (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(builtin, float, 0)
@@ -1445,6 +1476,24 @@ typedef void MR_CALL MR_CompareFunc_5(MR_Mercury_Type_Info,
    #define MR_UINT_CTOR_ADDR                                               \
        (MR_Word *) &mercury_data_builtin__type_ctor_info_uint_0
        // (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(builtin, uint, 0)
+  #define MR_INT8_CTOR_ADDR                                               \
+      (MR_Word *) &mercury_data_builtin__type_ctor_info_int8_0
+      // (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(builtin, int8, 0)
+  #define MR_UINT8_CTOR_ADDR                                              \
+      (MR_Word *) &mercury_data_builtin__type_ctor_info_uint8_0
+      // (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(builtin, uint8, 0)
+  #define MR_INT16_CTOR_ADDR                                              \
+      (MR_Word *) &mercury_data_builtin__type_ctor_info_int16_0
+      // (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(builtin, int16, 0)
+  #define MR_UINT16_CTOR_ADDR                                             \
+      (MR_Word *) &mercury_data_builtin__type_ctor_info_uint16_0
+      // (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(builtin, uint16, 0)
+  #define MR_INT32_CTOR_ADDR                                              \
+      (MR_Word *) &mercury_data_builtin__type_ctor_info_int32_0
+      // (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(builtin, int32, 0)
+  #define MR_UINT32_CTOR_ADDR                                             \
+      (MR_Word *) &mercury_data_builtin__type_ctor_info_uint32_0
+      // (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(builtin, uint32, 0)
    #define MR_FLOAT_CTOR_ADDR                                              \
        (MR_Word *) &mercury_data_builtin__type_ctor_info_float_0
        // (MR_Word *) &MR_TYPE_CTOR_INFO_NAME(builtin, float, 0)
diff --git a/runtime/mercury_unify_compare_body.h b/runtime/mercury_unify_compare_body.h
index 1209e0f53..5e96b9443 100644
--- a/runtime/mercury_unify_compare_body.h
+++ b/runtime/mercury_unify_compare_body.h
@@ -616,6 +616,9 @@ start_label:
          case MR_TYPECTOR_REP_ENUM:
          case MR_TYPECTOR_REP_FOREIGN_ENUM:
          case MR_TYPECTOR_REP_INT:
+        case MR_TYPECTOR_REP_INT8:
+        case MR_TYPECTOR_REP_INT16:
+        case MR_TYPECTOR_REP_INT32:
          case MR_TYPECTOR_REP_CHAR:

  #ifdef  select_compare_code
@@ -631,6 +634,9 @@ start_label:
                  (MR_Integer) x == (MR_Integer) y);
  #endif
          case MR_TYPECTOR_REP_UINT:
+        case MR_TYPECTOR_REP_UINT8:
+        case MR_TYPECTOR_REP_UINT16:
+        case MR_TYPECTOR_REP_UINT32:

  #ifdef  select_compare_code
              if ((MR_Unsigned) x == (MR_Unsigned) y) {


More information about the reviews mailing list