about summary refs log tree commit diff
path: root/src/comp/middle
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2011-12-07 21:06:12 +0100
committerMarijn Haverbeke <marijnh@gmail.com>2011-12-07 21:08:28 +0100
commite3eca9174b9dc186de4ad44f80f7537f2e9e4c60 (patch)
treeff9c8c7fd97f0cb8daecc002b1855412846f7757 /src/comp/middle
parent6daa233a73541c4daf135ac5dd9e339289fdfbfd (diff)
downloadrust-e3eca9174b9dc186de4ad44f80f7537f2e9e4c60.tar.gz
rust-e3eca9174b9dc186de4ad44f80f7537f2e9e4c60.zip
Change literal representation to not truncate
Also shuffles around the organization of numeric literals and types,
separating by int/uint/float instead of machine-vs-non-machine types.
This simplifies some code.

Closes #974
Closes #1252
Diffstat (limited to 'src/comp/middle')
-rw-r--r--src/comp/middle/alias.rs5
-rw-r--r--src/comp/middle/gc.rs4
-rw-r--r--src/comp/middle/shape.rs82
-rw-r--r--src/comp/middle/trans.rs75
-rw-r--r--src/comp/middle/trans_common.rs35
-rw-r--r--src/comp/middle/ty.rs271
-rw-r--r--src/comp/middle/typeck.rs44
7 files changed, 167 insertions, 349 deletions
diff --git a/src/comp/middle/alias.rs b/src/comp/middle/alias.rs
index 5cd05a833f4..eb9122bfa7d 100644
--- a/src/comp/middle/alias.rs
+++ b/src/comp/middle/alias.rs
@@ -553,9 +553,8 @@ fn local_id_of_node(cx: ctx, id: node_id) -> uint {
 fn copy_is_expensive(tcx: ty::ctxt, ty: ty::t) -> bool {
     fn score_ty(tcx: ty::ctxt, ty: ty::t) -> uint {
         ret alt ty::struct(tcx, ty) {
-          ty::ty_nil. | ty::ty_bot. | ty::ty_bool. | ty::ty_int. |
-          ty::ty_uint. | ty::ty_float. | ty::ty_machine(_) |
-          ty::ty_char. | ty::ty_type. | ty::ty_native(_) |
+          ty::ty_nil. | ty::ty_bot. | ty::ty_bool. | ty::ty_int(_) |
+          ty::ty_uint(_) | ty::ty_float(_) | ty::ty_type. | ty::ty_native(_) |
           ty::ty_ptr(_) { 1u }
           ty::ty_box(_) { 3u }
           ty::ty_constr(t, _) | ty::ty_res(_, t, _) { score_ty(tcx, t) }
diff --git a/src/comp/middle/gc.rs b/src/comp/middle/gc.rs
index fcdbb8be29f..c14ef93f362 100644
--- a/src/comp/middle/gc.rs
+++ b/src/comp/middle/gc.rs
@@ -102,8 +102,8 @@ fn add_gc_root(cx: @block_ctxt, llval: ValueRef, ty: ty::t) -> @block_ctxt {
 
 fn type_is_gc_relevant(cx: ty::ctxt, ty: ty::t) -> bool {
     alt ty::struct(cx, ty) {
-      ty::ty_nil. | ty::ty_bot. | ty::ty_bool. | ty::ty_int. | ty::ty_float. |
-      ty::ty_uint. | ty::ty_machine(_) | ty::ty_char. | ty::ty_str. |
+      ty::ty_nil. | ty::ty_bot. | ty::ty_bool. | ty::ty_int(_) |
+      ty::ty_float(_) | ty::ty_uint(_) | ty::ty_str. |
       ty::ty_type. | ty::ty_native(_) | ty::ty_ptr(_) | ty::ty_type. |
       ty::ty_native(_) {
         ret false;
diff --git a/src/comp/middle/shape.rs b/src/comp/middle/shape.rs
index f7c06d2a52c..6bf91384cbb 100644
--- a/src/comp/middle/shape.rs
+++ b/src/comp/middle/shape.rs
@@ -299,54 +299,27 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t, ty_param_map: [uint],
     let s = [];
 
     alt ty::struct(ccx.tcx, t) {
-      ty::ty_nil. | ty::ty_bool. | ty::ty_machine(ast::ty_u8.) | ty::ty_bot. {
-        s += [shape_u8];
-      }
-
-
-
-
-
-      ty::ty_int. {
-        s += [s_int(ccx.tcx)];
-      }
-      ty::ty_float. { s += [s_float(ccx.tcx)]; }
-
-
-
-
-
-      ty::ty_uint. | ty::ty_ptr(_) | ty::ty_type. | ty::ty_native(_) {
-        s += [s_uint(ccx.tcx)];
-      }
-
-
-
-
-
-      ty::ty_machine(ast::ty_i8.) {
-        s += [shape_i8];
-      }
-      ty::ty_machine(ast::ty_u16.) { s += [shape_u16]; }
-      ty::ty_machine(ast::ty_i16.) { s += [shape_i16]; }
-      ty::ty_machine(ast::ty_u32.) | ty::ty_char. { s += [shape_u32]; }
-      ty::ty_machine(ast::ty_i32.) { s += [shape_i32]; }
-      ty::ty_machine(ast::ty_u64.) { s += [shape_u64]; }
-      ty::ty_machine(ast::ty_i64.) { s += [shape_i64]; }
-
-      ty::ty_machine(ast::ty_f32.) { s += [shape_f32]; }
-      ty::ty_machine(ast::ty_f64.) { s += [shape_f64]; }
-
+      ty::ty_nil. | ty::ty_bool. | ty::ty_uint(ast::ty_u8.) |
+      ty::ty_bot. { s += [shape_u8]; }
+      ty::ty_int(ast::ty_i.) { s += [s_int(ccx.tcx)]; }
+      ty::ty_float(ast::ty_f.) { s += [s_float(ccx.tcx)]; }
+      ty::ty_uint(ast::ty_u.) | ty::ty_ptr(_) | ty::ty_type. |
+      ty::ty_native(_) { s += [s_uint(ccx.tcx)]; }
+      ty::ty_int(ast::ty_i8.) { s += [shape_i8]; }
+      ty::ty_uint(ast::ty_u16.) { s += [shape_u16]; }
+      ty::ty_int(ast::ty_i16.) { s += [shape_i16]; }
+      ty::ty_uint(ast::ty_u32.) { s += [shape_u32]; }
+      ty::ty_int(ast::ty_i32.) | ty::ty_int(ast::ty_char.) {s += [shape_i32];}
+      ty::ty_uint(ast::ty_u64.) { s += [shape_u64]; }
+      ty::ty_int(ast::ty_i64.) { s += [shape_i64]; }
+      ty::ty_float(ast::ty_f32.) { s += [shape_f32]; }
+      ty::ty_float(ast::ty_f64.) { s += [shape_f64]; }
       ty::ty_str. {
         s += [shape_vec];
         add_bool(s, true); // type is POD
-        let unit_ty = ty::mk_mach(ccx.tcx, ast::ty_u8);
+        let unit_ty = ty::mk_mach_uint(ccx.tcx, ast::ty_u8);
         add_substr(s, shape_of(ccx, unit_ty, ty_param_map, is_obj_body));
       }
-
-
-
-
       ty::ty_tag(did, tps) {
         alt tag_kind(ccx, did) {
           tk_unit. {
@@ -382,11 +355,6 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t, ty_param_map: [uint],
           }
         }
       }
-
-
-
-
-
       ty::ty_box(mt) {
         s += [shape_box];
         add_substr(s, shape_of(ccx, mt.ty, ty_param_map, is_obj_body));
@@ -416,21 +384,11 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t, ty_param_map: [uint],
         }
         add_substr(s, sub);
       }
-
-
-
-
-
       ty::ty_fn(_, _, _, _, _) {
         s += [shape_fn];
       }
       ty::ty_native_fn(_, _) { s += [shape_u32]; }
       ty::ty_obj(_) { s += [shape_obj]; }
-
-
-
-
-
       ty::ty_res(did, raw_subt, tps) {
         let subt = ty::substitute_type_params(ccx.tcx, tps, raw_subt);
         let ri = {did: did, t: subt};
@@ -445,17 +403,9 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t, ty_param_map: [uint],
         add_substr(s, shape_of(ccx, subt, ty_param_map, is_obj_body));
 
       }
-
-
-
-
       ty::ty_var(n) {
         fail "shape_of ty_var";
       }
-
-
-
-
       ty::ty_param(n, _) {
         if is_obj_body {
             // Just write in the parameter number.
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index 107c53cfac3..458266298d4 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -130,20 +130,9 @@ fn type_of_inner(cx: @crate_ctxt, sp: span, t: ty::t)
         T_nil() /* ...I guess? */
       }
       ty::ty_bool. { T_bool() }
-      ty::ty_int. { cx.int_type }
-      ty::ty_float. { cx.float_type }
-      ty::ty_uint. { cx.int_type }
-      ty::ty_machine(tm) {
-        alt tm {
-          ast::ty_i8. | ast::ty_u8. { T_i8() }
-          ast::ty_i16. | ast::ty_u16. { T_i16() }
-          ast::ty_i32. | ast::ty_u32. { T_i32() }
-          ast::ty_i64. | ast::ty_u64. { T_i64() }
-          ast::ty_f32. { T_f32() }
-          ast::ty_f64. { T_f64() }
-        }
-      }
-      ty::ty_char. { T_char() }
+      ty::ty_int(t) { T_int_ty(cx, t) }
+      ty::ty_uint(t) { T_uint_ty(cx, t) }
+      ty::ty_float(t) { T_float_ty(cx, t) }
       ty::ty_str. { T_ptr(T_vec(cx, T_i8())) }
       ty::ty_tag(did, _) { type_of_tag(cx, sp, did, t) }
       ty::ty_box(mt) {
@@ -1516,23 +1505,10 @@ fn compare_scalar_types(cx: @block_ctxt, lhs: ValueRef, rhs: ValueRef,
 
     alt ty::struct(bcx_tcx(cx), t) {
       ty::ty_nil. { ret rslt(cx, f(nil_type)); }
-      ty::ty_bool. | ty::ty_uint. | ty::ty_ptr(_) | ty::ty_char. {
-        ret rslt(cx, f(unsigned_int));
-      }
-      ty::ty_int. { ret rslt(cx, f(signed_int)); }
-      ty::ty_float. { ret rslt(cx, f(floating_point)); }
-      ty::ty_machine(_) {
-        if ty::type_is_fp(bcx_tcx(cx), t) {
-            // Floating point machine types
-            ret rslt(cx, f(floating_point));
-        } else if ty::type_is_signed(bcx_tcx(cx), t) {
-            // Signed, integral machine types
-            ret rslt(cx, f(signed_int));
-        } else {
-            // Unsigned, integral machine types
-            ret rslt(cx, f(unsigned_int));
-        }
-      }
+      ty::ty_bool. | ty::ty_ptr(_) { ret rslt(cx, f(unsigned_int)); }
+      ty::ty_int(_) { ret rslt(cx, f(signed_int)); }
+      ty::ty_uint(_) { ret rslt(cx, f(unsigned_int)); }
+      ty::ty_float(_) { ret rslt(cx, f(floating_point)); }
       ty::ty_type. {
         ret rslt(trans_fail(cx, none,
                             "attempt to compare values of type type"),
@@ -2120,36 +2096,11 @@ fn store_temp_expr(cx: @block_ctxt, action: copy_action, dst: ValueRef,
 
 fn trans_crate_lit(cx: @crate_ctxt, lit: ast::lit) -> ValueRef {
     alt lit.node {
-      ast::lit_int(i) { ret C_int(cx, i); }
-      ast::lit_uint(u) { ret C_uint(cx, u); }
-      ast::lit_mach_int(tm, i) {
-        // FIXME: the entire handling of mach types falls apart
-        // if target int width is larger than host, at the moment;
-        // re-do the mach-int types using 'big' when that works.
-
-        let t = cx.int_type;
-        let s = True;
-        alt tm {
-          ast::ty_u8. { t = T_i8(); s = False; }
-          ast::ty_u16. { t = T_i16(); s = False; }
-          ast::ty_u32. { t = T_i32(); s = False; }
-          ast::ty_u64. { t = T_i64(); s = False; }
-          ast::ty_i8. { t = T_i8(); }
-          ast::ty_i16. { t = T_i16(); }
-          ast::ty_i32. { t = T_i32(); }
-          ast::ty_i64. { t = T_i64(); }
-        }
-        ret C_integral(t, i as u64, s);
-      }
-      ast::lit_float(fs) { ret C_float(cx, fs); }
-      ast::lit_mach_float(tm, s) {
-        let t = cx.float_type;
-        alt tm { ast::ty_f32. { t = T_f32(); } ast::ty_f64. { t = T_f64(); } }
-        ret C_floating(s, t);
-      }
-      ast::lit_char(c) { ret C_integral(T_char(), c as u64, False); }
-      ast::lit_bool(b) { ret C_bool(b); }
-      ast::lit_nil. { ret C_nil(); }
+      ast::lit_int(i, t) { C_integral(T_int_ty(cx, t), i as u64, True) }
+      ast::lit_uint(u, t) { C_integral(T_uint_ty(cx, t), u, False) }
+      ast::lit_float(fs, t) { C_floating(fs, T_float_ty(cx, t)) }
+      ast::lit_bool(b) { C_bool(b) }
+      ast::lit_nil. { C_nil() }
       ast::lit_str(s) {
         cx.sess.span_unimpl(lit.span, "unique string in this context");
       }
@@ -4359,7 +4310,7 @@ fn trans_fail_expr(bcx: @block_ctxt, sp_opt: option::t<span>,
         if ty::type_is_str(tcx, e_ty) {
             let data = tvec::get_dataptr(
                 bcx, expr_res.val, type_of_or_i8(
-                    bcx, ty::mk_mach(tcx, ast::ty_u8)));
+                    bcx, ty::mk_mach_uint(tcx, ast::ty_u8)));
             ret trans_fail_value(bcx, sp_opt, data);
         } else if bcx.unreachable {
             ret bcx;
diff --git a/src/comp/middle/trans_common.rs b/src/comp/middle/trans_common.rs
index 334116b3feb..703aa9fcd77 100644
--- a/src/comp/middle/trans_common.rs
+++ b/src/comp/middle/trans_common.rs
@@ -485,6 +485,35 @@ fn T_int(targ_cfg: @session::config) -> TypeRef {
     };
 }
 
+fn T_int_ty(cx: @crate_ctxt, t: ast::int_ty) -> TypeRef {
+    alt t {
+      ast::ty_i. { cx.int_type }
+      ast::ty_char. { T_char() }
+      ast::ty_i8. { T_i8() }
+      ast::ty_i16. { T_i16() }
+      ast::ty_i32. { T_i32() }
+      ast::ty_i64. { T_i64() }
+    }
+}
+
+fn T_uint_ty(cx: @crate_ctxt, t: ast::uint_ty) -> TypeRef {
+    alt t {
+      ast::ty_u. { cx.int_type }
+      ast::ty_u8. { T_i8() }
+      ast::ty_u16. { T_i16() }
+      ast::ty_u32. { T_i32() }
+      ast::ty_u64. { T_i64() }
+    }
+}
+
+fn T_float_ty(cx: @crate_ctxt, t: ast::float_ty) -> TypeRef {
+    alt t {
+      ast::ty_f. { cx.float_type }
+      ast::ty_f32. { T_f32() }
+      ast::ty_f64. { T_f64() }
+    }
+}
+
 fn T_float(targ_cfg: @session::config) -> TypeRef {
     ret alt targ_cfg.arch {
       session::arch_x86. { T_f64() }
@@ -734,12 +763,6 @@ fn C_integral(t: TypeRef, u: u64, sign_extend: Bool) -> ValueRef {
     ret llvm::LLVMRustConstInt(t, u_hi, u_lo, sign_extend);
 }
 
-fn C_float(cx: @crate_ctxt, s: str) -> ValueRef {
-    ret str::as_buf(s, {|buf|
-        llvm::LLVMConstRealOfString(cx.float_type, buf)
-    });
-}
-
 fn C_floating(s: str, t: TypeRef) -> ValueRef {
     ret str::as_buf(s, {|buf| llvm::LLVMConstRealOfString(t, buf) });
 }
diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs
index 022b249674b..9c2ddedc56b 100644
--- a/src/comp/middle/ty.rs
+++ b/src/comp/middle/ty.rs
@@ -71,7 +71,9 @@ export mk_mut_ptr;
 export mk_int;
 export mk_str;
 export mk_vec;
-export mk_mach;
+export mk_mach_int;
+export mk_mach_uint;
+export mk_mach_float;
 export mk_native;
 export mk_native_fn;
 export mk_nil;
@@ -111,7 +113,6 @@ export ty_native_fn;
 export ty_bool;
 export ty_bot;
 export ty_box;
-export ty_char;
 export ty_constr;
 export ty_constr_arg;
 export ty_float;
@@ -122,7 +123,6 @@ export ty_fn_ret_style;
 export ty_int;
 export ty_str;
 export ty_vec;
-export ty_machine;
 export ty_native;
 export ty_nil;
 export ty_obj;
@@ -249,18 +249,15 @@ type raw_t =
 
 type t = uint;
 
-
 // NB: If you change this, you'll probably want to change the corresponding
 // AST structure in front/ast::rs as well.
 tag sty {
     ty_nil;
     ty_bot;
     ty_bool;
-    ty_int;
-    ty_float;
-    ty_uint;
-    ty_machine(ast::ty_mach);
-    ty_char;
+    ty_int(ast::int_ty);
+    ty_uint(ast::uint_ty);
+    ty_float(ast::float_ty);
     ty_str;
     ty_tag(def_id, [t]);
     ty_box(mt);
@@ -361,20 +358,20 @@ type node_type_table =
 fn populate_type_store(cx: ctxt) {
     intern(cx, ty_nil, none);
     intern(cx, ty_bool, none);
-    intern(cx, ty_int, none);
-    intern(cx, ty_float, none);
-    intern(cx, ty_uint, none);
-    intern(cx, ty_machine(ast::ty_i8), none);
-    intern(cx, ty_machine(ast::ty_i16), none);
-    intern(cx, ty_machine(ast::ty_i32), none);
-    intern(cx, ty_machine(ast::ty_i64), none);
-    intern(cx, ty_machine(ast::ty_u8), none);
-    intern(cx, ty_machine(ast::ty_u16), none);
-    intern(cx, ty_machine(ast::ty_u32), none);
-    intern(cx, ty_machine(ast::ty_u64), none);
-    intern(cx, ty_machine(ast::ty_f32), none);
-    intern(cx, ty_machine(ast::ty_f64), none);
-    intern(cx, ty_char, none);
+    intern(cx, ty_int(ast::ty_i), none);
+    intern(cx, ty_float(ast::ty_f), none);
+    intern(cx, ty_uint(ast::ty_u), none);
+    intern(cx, ty_int(ast::ty_i8), none);
+    intern(cx, ty_int(ast::ty_i16), none);
+    intern(cx, ty_int(ast::ty_i32), none);
+    intern(cx, ty_int(ast::ty_i64), none);
+    intern(cx, ty_uint(ast::ty_u8), none);
+    intern(cx, ty_uint(ast::ty_u16), none);
+    intern(cx, ty_uint(ast::ty_u32), none);
+    intern(cx, ty_uint(ast::ty_u64), none);
+    intern(cx, ty_float(ast::ty_f32), none);
+    intern(cx, ty_float(ast::ty_f64), none);
+    intern(cx, ty_int(ast::ty_char), none);
     intern(cx, ty_str, none);
     intern(cx, ty_type, none);
     intern(cx, ty_bot, none);
@@ -445,17 +442,8 @@ fn mk_raw_ty(cx: ctxt, st: sty, _in_cname: option::t<str>) -> @raw_t {
         derive_flags_t(cx, has_params, has_vars, tt);
     }
     alt st {
-      ty_nil. {/* no-op */ }
-      ty_bot. {/* no-op */ }
-      ty_bool. {/* no-op */ }
-      ty_int. {/* no-op */ }
-      ty_float. {/* no-op */ }
-      ty_uint. {/* no-op */ }
-      ty_machine(_) {/* no-op */ }
-      ty_char. {/* no-op */ }
-      ty_str. {/* no-op */ }
-      ty_type. {/* no-op */ }
-      ty_native(_) {/* no-op */ }
+      ty_nil. | ty_bot. | ty_bool. | ty_int(_) | ty_float(_) | ty_uint(_) |
+      ty_str. | ty_type. | ty_native(_) {/* no-op */ }
       ty_param(_, _) { has_params = true; }
       ty_var(_) { has_vars = true; }
       ty_tag(_, tys) {
@@ -523,21 +511,36 @@ fn mk_float(_cx: ctxt) -> t { ret idx_float; }
 
 fn mk_uint(_cx: ctxt) -> t { ret idx_uint; }
 
-fn mk_mach(_cx: ctxt, tm: ast::ty_mach) -> t {
+fn mk_mach_int(_cx: ctxt, tm: ast::int_ty) -> t {
     alt tm {
-      ast::ty_u8. { ret idx_u8; }
-      ast::ty_u16. { ret idx_u16; }
-      ast::ty_u32. { ret idx_u32; }
-      ast::ty_u64. { ret idx_u64; }
+      ast::ty_i. { ret idx_int; }
+      ast::ty_char. { ret idx_char; }
       ast::ty_i8. { ret idx_i8; }
       ast::ty_i16. { ret idx_i16; }
       ast::ty_i32. { ret idx_i32; }
       ast::ty_i64. { ret idx_i64; }
+    }
+}
+
+fn mk_mach_uint(_cx: ctxt, tm: ast::uint_ty) -> t {
+    alt tm {
+      ast::ty_u. { ret idx_uint; }
+      ast::ty_u8. { ret idx_u8; }
+      ast::ty_u16. { ret idx_u16; }
+      ast::ty_u32. { ret idx_u32; }
+      ast::ty_u64. { ret idx_u64; }
+    }
+}
+
+fn mk_mach_float(_cx: ctxt, tm: ast::float_ty) -> t {
+    alt tm {
+      ast::ty_f. { ret idx_float; }
       ast::ty_f32. { ret idx_f32; }
       ast::ty_f64. { ret idx_f64; }
     }
 }
 
+
 fn mk_char(_cx: ctxt) -> t { ret idx_char; }
 
 fn mk_str(_cx: ctxt) -> t { ret idx_str; }
@@ -614,20 +617,9 @@ type ty_walk = fn@(t);
 
 fn walk_ty(cx: ctxt, walker: ty_walk, ty: t) {
     alt struct(cx, ty) {
-      ty_nil. {/* no-op */ }
-      ty_bot. {/* no-op */ }
-      ty_bool. {/* no-op */ }
-      ty_int. {/* no-op */ }
-      ty_uint. {/* no-op */ }
-      ty_float. {/* no-op */ }
-      ty_machine(_) {/* no-op */ }
-      ty_char. {/* no-op */ }
-      ty_str. {/* no-op */ }
-      ty_type. {/* no-op */ }
-      ty_native(_) {/* no-op */ }
-      ty_box(tm) { walk_ty(cx, walker, tm.ty); }
-      ty_vec(tm) { walk_ty(cx, walker, tm.ty); }
-      ty_ptr(tm) { walk_ty(cx, walker, tm.ty); }
+      ty_nil. | ty_bot. | ty_bool. | ty_int(_) | ty_uint(_) | ty_float(_) |
+      ty_str. | ty_type. | ty_native(_) {/* no-op */ }
+      ty_box(tm) | ty_vec(tm) | ty_ptr(tm) { walk_ty(cx, walker, tm.ty); }
       ty_tag(tid, subtys) {
         for subty: t in subtys { walk_ty(cx, walker, subty); }
       }
@@ -677,17 +669,8 @@ fn fold_ty(cx: ctxt, fld: fold_mode, ty_0: t) -> t {
       fm_general(_) {/* no fast path */ }
     }
     alt struct(cx, ty) {
-      ty_nil. {/* no-op */ }
-      ty_bot. {/* no-op */ }
-      ty_bool. {/* no-op */ }
-      ty_int. {/* no-op */ }
-      ty_uint. {/* no-op */ }
-      ty_float. {/* no-op */ }
-      ty_machine(_) {/* no-op */ }
-      ty_char. {/* no-op */ }
-      ty_str. {/* no-op */ }
-      ty_type. {/* no-op */ }
-      ty_native(_) {/* no-op */ }
+      ty_nil. | ty_bot. | ty_bool. | ty_int(_) | ty_uint(_) | ty_float(_) |
+      ty_str. | ty_type. | ty_native(_) {/* no-op */ }
       ty_box(tm) {
         ty = mk_box(cx, {ty: fold_ty(cx, fld, tm.ty), mut: tm.mut});
       }
@@ -725,10 +708,8 @@ fn fold_ty(cx: ctxt, fld: fold_mode, ty_0: t) -> t {
             let new_ty = fold_ty(cx, fld, a.ty);
             new_args += [{mode: a.mode, ty: new_ty}];
         }
-        ty =
-            copy_cname(cx,
-                       mk_fn(cx, proto, new_args, fold_ty(cx, fld, ret_ty),
-                             cf, constrs), ty);
+        ty = copy_cname(cx, mk_fn(cx, proto, new_args,
+                                  fold_ty(cx, fld, ret_ty), cf, constrs), ty);
       }
       ty_native_fn(args, ret_ty) {
         let new_args: [arg] = [];
@@ -736,10 +717,8 @@ fn fold_ty(cx: ctxt, fld: fold_mode, ty_0: t) -> t {
             let new_ty = fold_ty(cx, fld, a.ty);
             new_args += [{mode: a.mode, ty: new_ty}];
         }
-        ty =
-            copy_cname(cx,
-                       mk_native_fn(cx, new_args,
-                                    fold_ty(cx, fld, ret_ty)), ty);
+        ty = copy_cname(cx, mk_native_fn(cx, new_args,
+                                         fold_ty(cx, fld, ret_ty)), ty);
       }
       ty_obj(methods) {
         let new_methods: [method] = [];
@@ -773,7 +752,6 @@ fn fold_ty(cx: ctxt, fld: fold_mode, ty_0: t) -> t {
       }
     }
 
-
     // If this is a general type fold, then we need to run it now.
     alt fld { fm_general(folder) { ret folder(ty); } _ { ret ty; } }
 }
@@ -842,7 +820,7 @@ fn type_is_str(cx: ctxt, ty: t) -> bool {
 
 fn sequence_element_type(cx: ctxt, ty: t) -> t {
     alt struct(cx, ty) {
-      ty_str. { ret mk_mach(cx, ast::ty_u8); }
+      ty_str. { ret mk_mach_uint(cx, ast::ty_u8); }
       ty_vec(mt) { ret mt.ty; }
       _ { cx.sess.bug("sequence_element_type called on non-sequence value"); }
     }
@@ -917,17 +895,9 @@ pure fn type_is_unique(cx: ctxt, ty: t) -> bool {
 
 pure fn type_is_scalar(cx: ctxt, ty: t) -> bool {
     alt struct(cx, ty) {
-      ty_nil. { ret true; }
-      ty_bool. { ret true; }
-      ty_int. { ret true; }
-      ty_float. { ret true; }
-      ty_uint. { ret true; }
-      ty_machine(_) { ret true; }
-      ty_char. { ret true; }
-      ty_type. { ret true; }
-      ty_native(_) { ret true; }
-      ty_ptr(_) { ret true; }
-      _ { ret false; }
+      ty_nil. | ty_bool. | ty_int(_) | ty_float(_) | ty_uint(_) |
+      ty_type. | ty_native(_) | ty_ptr(_) { true }
+      _ { false }
     }
 }
 
@@ -946,8 +916,8 @@ fn type_needs_drop(cx: ctxt, ty: t) -> bool {
     let accum = false;
     let result = alt struct(cx, ty) {
       // scalar types
-      ty_nil. | ty_bot. | ty_bool. | ty_int. | ty_float. | ty_uint. |
-      ty_machine(_) | ty_char. | ty_type. | ty_native(_) | ty_ptr(_) { false }
+      ty_nil. | ty_bot. | ty_bool. | ty_int(_) | ty_float(_) | ty_uint(_) |
+      ty_type. | ty_native(_) | ty_ptr(_) { false }
       ty_rec(flds) {
         for f in flds { if type_needs_drop(cx, f.mt.ty) { accum = true; } }
         accum
@@ -998,8 +968,8 @@ fn type_kind(cx: ctxt, ty: t) -> ast::kind {
 
     let result = alt struct(cx, ty) {
       // Scalar and unique types are sendable
-      ty_nil. | ty_bot. | ty_bool. | ty_int. | ty_uint. | ty_float. |
-      ty_machine(_) | ty_char. | ty_native(_) | ty_ptr(_) |
+      ty_nil. | ty_bot. | ty_bool. | ty_int(_) | ty_uint(_) | ty_float(_) |
+      ty_native(_) | ty_ptr(_) |
       ty_type. | ty_str. | ty_native_fn(_, _) { ast::kind_sendable }
       // FIXME: obj is broken for now, since we aren't asserting
       // anything about its fields.
@@ -1151,38 +1121,15 @@ fn type_structurally_contains_uniques(cx: ctxt, ty: t) -> bool {
 
 fn type_is_integral(cx: ctxt, ty: t) -> bool {
     alt struct(cx, ty) {
-      ty_int. { ret true; }
-      ty_uint. { ret true; }
-      ty_machine(m) {
-        alt m {
-          ast::ty_i8. { ret true; }
-          ast::ty_i16. { ret true; }
-          ast::ty_i32. { ret true; }
-          ast::ty_i64. { ret true; }
-          ast::ty_u8. { ret true; }
-          ast::ty_u16. { ret true; }
-          ast::ty_u32. { ret true; }
-          ast::ty_u64. { ret true; }
-          _ { ret false; }
-        }
-      }
-      ty_char. { ret true; }
-      ty_bool. { ret true; }
-      _ { ret false; }
+      ty_int(_) | ty_uint(_) | ty_bool. { true }
+      _ { false }
     }
 }
 
 fn type_is_fp(cx: ctxt, ty: t) -> bool {
     alt struct(cx, ty) {
-      ty_machine(tm) {
-        alt tm {
-          ast::ty_f32. { ret true; }
-          ast::ty_f64. { ret true; }
-          _ { ret false; }
-        }
-      }
-      ty_float. { ret true; }
-      _ { ret false; }
+      ty_float(_) { true }
+      _ { false }
     }
 }
 
@@ -1192,17 +1139,8 @@ fn type_is_numeric(cx: ctxt, ty: t) -> bool {
 
 fn type_is_signed(cx: ctxt, ty: t) -> bool {
     alt struct(cx, ty) {
-      ty_int. { ret true; }
-      ty_machine(tm) {
-        alt tm {
-          ast::ty_i8. { ret true; }
-          ast::ty_i16. { ret true; }
-          ast::ty_i32. { ret true; }
-          ast::ty_i64. { ret true; }
-          _ { ret false; }
-        }
-      }
-      _ { ret false; }
+      ty_int(_) { true }
+      _ { false }
     }
 }
 
@@ -1211,10 +1149,8 @@ fn type_is_pod(cx: ctxt, ty: t) -> bool {
     let result = true;
     alt struct(cx, ty) {
       // Scalar types
-      ty_nil. | ty_bot. | ty_bool. | ty_int. | ty_float. | ty_uint. |
-      ty_machine(_) | ty_char. | ty_type. | ty_native(_) | ty_ptr(_) {
-        result = true;
-      }
+      ty_nil. | ty_bot. | ty_bool. | ty_int(_) | ty_float(_) | ty_uint(_) |
+      ty_type. | ty_native(_) | ty_ptr(_) { result = true; }
       // Boxed types
       ty_str. | ty_box(_) | ty_uniq(_) | ty_vec(_) | ty_fn(_, _, _, _, _) |
       ty_native_fn(_, _) | ty_obj(_) {
@@ -1343,26 +1279,22 @@ fn hash_type_structure(st: sty) -> uint {
         ret h;
     }
     alt st {
-      ty_nil. { ret 0u; }
-      ty_bool. { ret 1u; }
-      ty_int. { ret 2u; }
-      ty_float. { ret 3u; }
-      ty_uint. { ret 4u; }
-      ty_machine(tm) {
-        alt tm {
-          ast::ty_i8. { ret 5u; }
-          ast::ty_i16. { ret 6u; }
-          ast::ty_i32. { ret 7u; }
-          ast::ty_i64. { ret 8u; }
-          ast::ty_u8. { ret 9u; }
-          ast::ty_u16. { ret 10u; }
-          ast::ty_u32. { ret 11u; }
-          ast::ty_u64. { ret 12u; }
-          ast::ty_f32. { ret 13u; }
-          ast::ty_f64. { ret 14u; }
+      ty_nil. { 0u } ty_bool. { 1u }
+      ty_int(t) {
+        alt t {
+          ast::ty_i. { 2u } ast::ty_char. { 3u } ast::ty_i8. { 4u }
+          ast::ty_i16. { 5u } ast::ty_i32. { 6u } ast::ty_i64. { 7u }
         }
       }
-      ty_char. { ret 15u; }
+      ty_uint(t) {
+        alt t {
+          ast::ty_u. { 8u } ast::ty_u8. { 9u } ast::ty_u16. { 10u }
+          ast::ty_u32. { 11u } ast::ty_u64. { 12u }
+        }
+      }
+      ty_float(t) {
+        alt t { ast::ty_f. { 13u } ast::ty_f32. { 14u } ast::ty_f64. { 15u } }
+      }
       ty_str. { ret 17u; }
       ty_tag(did, tys) {
         let h = hash_def(18u, did);
@@ -1505,17 +1437,17 @@ fn eq_ty(&&a: t, &&b: t) -> bool { ret a == b; }
 fn ty_to_machine_ty(cx: ctxt, ty: t) -> t {
     fn sub_fn(cx: ctxt, uint_ty: t, int_ty: t, float_ty: t, in: t) -> t {
         alt struct(cx, in) {
-          ty_uint. { ret uint_ty; }
-          ty_int. { ret int_ty; }
-          ty_float. { ret float_ty; }
+          ty_uint(ast::ty_u.) { ret uint_ty; }
+          ty_int(ast::ty_i.) { ret int_ty; }
+          ty_float(ast::ty_f.) { ret float_ty; }
           _ { ret in; }
         }
     }
 
     let cfg      = cx.sess.get_targ_cfg();
-    let uint_ty  = mk_mach(cx, cfg.uint_type);
-    let int_ty   = mk_mach(cx, cfg.int_type);
-    let float_ty = mk_mach(cx, cfg.float_type);
+    let uint_ty  = mk_mach_uint(cx, cfg.uint_type);
+    let int_ty   = mk_mach_int(cx, cfg.int_type);
+    let float_ty = mk_mach_float(cx, cfg.float_type);
     let fold_m   = fm_general(bind sub_fn(cx, uint_ty, int_ty, float_ty, _));
 
     ret fold_ty(cx, fold_m, ty);
@@ -2289,14 +2221,10 @@ mod unify {
           ty::ty_bot. {
             ret ures_ok(actual);
           }
-          ty::ty_bool. { ret struct_cmp(cx, expected, actual); }
-          ty::ty_int. { ret struct_cmp(cx, expected, actual); }
-          ty::ty_uint. { ret struct_cmp(cx, expected, actual); }
-          ty::ty_machine(_) { ret struct_cmp(cx, expected, actual); }
-          ty::ty_float. { ret struct_cmp(cx, expected, actual); }
-          ty::ty_char. { ret struct_cmp(cx, expected, actual); }
-          ty::ty_str. { ret struct_cmp(cx, expected, actual); }
-          ty::ty_type. { ret struct_cmp(cx, expected, actual); }
+          ty::ty_bool. | ty::ty_int(_) | ty_uint(_) | ty_float(_) |
+          ty::ty_str. | ty::ty_type. {
+            ret struct_cmp(cx, expected, actual);
+          }
           ty::ty_native(ex_id) {
             alt struct(cx.tcx, actual) {
               ty_native(act_id) {
@@ -2891,20 +2819,9 @@ fn is_binopable(cx: ctxt, ty: t, op: ast::binop) -> bool {
     fn tycat(cx: ctxt, ty: t) -> int {
         alt struct(cx, ty) {
           ty_bool. { tycat_bool }
-          ty_int. { tycat_int }
-          ty_uint. { tycat_int }
-          ty_machine(ast::ty_i8.) { tycat_int }
-          ty_machine(ast::ty_i16.) { tycat_int }
-          ty_machine(ast::ty_i32.) { tycat_int }
-          ty_machine(ast::ty_i64.) { tycat_int }
-          ty_machine(ast::ty_u8.) { tycat_int }
-          ty_machine(ast::ty_u16.) { tycat_int }
-          ty_machine(ast::ty_u32.) { tycat_int }
-          ty_machine(ast::ty_u64.) { tycat_int }
-          ty_float. { tycat_float }
-          ty_machine(ast::ty_f32.) { tycat_float }
-          ty_machine(ast::ty_f64.) { tycat_float }
-          ty_char. { tycat_int }
+          ty_int(_) { tycat_int }
+          ty_uint(_) { tycat_int }
+          ty_float(_) { tycat_float }
           ty_str. { tycat_str }
           ty_vec(_) { tycat_vec }
           ty_rec(_) { tycat_struct }
diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs
index bb82a959784..e8847b1ebbc 100644
--- a/src/comp/middle/typeck.rs
+++ b/src/comp/middle/typeck.rs
@@ -289,11 +289,9 @@ fn ast_ty_to_ty(tcx: ty::ctxt, getter: ty_getter, &&ast_ty: @ast::ty)
       ast::ty_nil. { typ = ty::mk_nil(tcx); }
       ast::ty_bot. { typ = ty::mk_bot(tcx); }
       ast::ty_bool. { typ = ty::mk_bool(tcx); }
-      ast::ty_int. { typ = ty::mk_int(tcx); }
-      ast::ty_uint. { typ = ty::mk_uint(tcx); }
-      ast::ty_float. { typ = ty::mk_float(tcx); }
-      ast::ty_machine(tm) { typ = ty::mk_mach(tcx, tm); }
-      ast::ty_char. { typ = ty::mk_char(tcx); }
+      ast::ty_int(it) { typ = ty::mk_mach_int(tcx, it); }
+      ast::ty_uint(uit) { typ = ty::mk_mach_uint(tcx, uit); }
+      ast::ty_float(ft) { typ = ty::mk_mach_float(tcx, ft); }
       ast::ty_str. { typ = ty::mk_str(tcx); }
       ast::ty_box(mt) {
         typ = ty::mk_box(tcx, ast_mt_to_mt(tcx, getter, mt));
@@ -1223,32 +1221,12 @@ fn gather_locals(ccx: @crate_ctxt, f: ast::_fn, id: ast::node_id,
 // AST fragment checking
 fn check_lit(ccx: @crate_ctxt, lit: @ast::lit) -> ty::t {
     alt lit.node {
-      ast::lit_str(_) { ret ty::mk_str(ccx.tcx); }
-      ast::lit_char(_) { ret ty::mk_char(ccx.tcx); }
-      ast::lit_int(_) { ret ty::mk_int(ccx.tcx); }
-      ast::lit_float(_) { ret ty::mk_float(ccx.tcx); }
-      ast::lit_mach_float(tm, _) { ret ty::mk_mach(ccx.tcx, tm); }
-      ast::lit_uint(_) { ret ty::mk_uint(ccx.tcx); }
-      ast::lit_mach_int(tm, _) { ret ty::mk_mach(ccx.tcx, tm); }
-      ast::lit_nil. { ret ty::mk_nil(ccx.tcx); }
-      ast::lit_bool(_) { ret ty::mk_bool(ccx.tcx); }
-    }
-}
-
-fn lit_as_uint(l: @ast::lit) -> uint {
-    alt l.node {
-      ast::lit_uint(u) { u }
-      ast::lit_char(c) { c as uint }
-    }
-}
-fn lit_as_int(l: @ast::lit) -> int {
-    alt l.node {
-      ast::lit_int(i) | ast::lit_mach_int(_, i) { i }
-    }
-}
-fn lit_as_float(l: @ast::lit) -> str {
-    alt l.node {
-      ast::lit_float(f) | ast::lit_mach_float(_, f) { f }
+      ast::lit_str(_) { ty::mk_str(ccx.tcx) }
+      ast::lit_int(_, t) { ty::mk_mach_int(ccx.tcx, t) }
+      ast::lit_uint(_, t) { ty::mk_mach_uint(ccx.tcx, t) }
+      ast::lit_float(_, t) { ty::mk_mach_float(ccx.tcx, t) }
+      ast::lit_nil. { ty::mk_nil(ccx.tcx) }
+      ast::lit_bool(_) { ty::mk_bool(ccx.tcx) }
     }
 }
 
@@ -1919,7 +1897,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
         let ety = expr_ty(tcx, seq);
         alt structure_of(fcx, expr.span, ety) {
           ty::ty_vec(vec_elt_ty) { elt_ty = vec_elt_ty.ty; }
-          ty::ty_str. { elt_ty = ty::mk_mach(tcx, ast::ty_u8); }
+          ty::ty_str. { elt_ty = ty::mk_mach_uint(tcx, ast::ty_u8); }
           _ {
             tcx.sess.span_fatal(expr.span,
                                 "mismatched types: expected vector or string "
@@ -2258,7 +2236,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
         alt structure_of(fcx, expr.span, base_t) {
           ty::ty_vec(mt) { write::ty_only_fixup(fcx, id, mt.ty); }
           ty::ty_str. {
-            let typ = ty::mk_mach(tcx, ast::ty_u8);
+            let typ = ty::mk_mach_uint(tcx, ast::ty_u8);
             write::ty_only_fixup(fcx, id, typ);
           }
           _ {