about summary refs log tree commit diff
path: root/src/librustc
diff options
context:
space:
mode:
authorJake Goulding <jake.goulding@gmail.com>2016-05-06 09:31:11 -0400
committerJake Goulding <jake.goulding@gmail.com>2016-05-19 13:55:13 -0400
commitbc7595c8abbf4e3b737e926d61814686e0ebda77 (patch)
tree3ead763b6c18622639409543dc3a46ba1e6374c1 /src/librustc
parent2fb6f8e2c94a7041877ed8460f2621974c5233f7 (diff)
downloadrust-bc7595c8abbf4e3b737e926d61814686e0ebda77.tar.gz
rust-bc7595c8abbf4e3b737e926d61814686e0ebda77.zip
Support 16-bit pointers as well as i/usize
This is based on the original work of Dylan McKay for the
[avr-rust project][ar].

[ar]: https://github.com/avr-rust/rust
Diffstat (limited to 'src/librustc')
-rw-r--r--src/librustc/session/config.rs1
-rw-r--r--src/librustc/ty/layout.rs2
-rw-r--r--src/librustc/ty/util.rs2
3 files changed, 5 insertions, 0 deletions
diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs
index 7bb96c5ab2b..d455d4afda2 100644
--- a/src/librustc/session/config.rs
+++ b/src/librustc/session/config.rs
@@ -795,6 +795,7 @@ pub fn build_target_config(opts: &Options, sp: &Handler) -> Config {
     };
 
     let (int_type, uint_type) = match &target.target_pointer_width[..] {
+        "16" => (ast::IntTy::I16, ast::UintTy::U16),
         "32" => (ast::IntTy::I32, ast::UintTy::U32),
         "64" => (ast::IntTy::I64, ast::UintTy::U64),
         w    => panic!(sp.fatal(&format!("target specification was invalid: \
diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs
index 82a3b0b8db2..07156c67a22 100644
--- a/src/librustc/ty/layout.rs
+++ b/src/librustc/ty/layout.rs
@@ -170,6 +170,7 @@ impl TargetDataLayout {
     /// address space on 64-bit ARMv8 and x86_64.
     pub fn obj_size_bound(&self) -> u64 {
         match self.pointer_size.bits() {
+            16 => 1 << 15,
             32 => 1 << 31,
             64 => 1 << 47,
             bits => bug!("obj_size_bound: unknown pointer bit size {}", bits)
@@ -178,6 +179,7 @@ impl TargetDataLayout {
 
     pub fn ptr_sized_integer(&self) -> Integer {
         match self.pointer_size.bits() {
+            16 => I16,
             32 => I32,
             64 => I64,
             bits => bug!("ptr_sized_integer: unknown pointer bit size {}", bits)
diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs
index 4f6188ea3c5..a1006aa535a 100644
--- a/src/librustc/ty/util.rs
+++ b/src/librustc/ty/util.rs
@@ -62,6 +62,7 @@ impl IntTypeExt for attr::IntType {
             SignedInt(ast::IntTy::I32)   => ConstInt::I32(0),
             SignedInt(ast::IntTy::I64)   => ConstInt::I64(0),
             SignedInt(ast::IntTy::Is) => match tcx.sess.target.int_type {
+                ast::IntTy::I16 => ConstInt::Isize(ConstIsize::Is16(0)),
                 ast::IntTy::I32 => ConstInt::Isize(ConstIsize::Is32(0)),
                 ast::IntTy::I64 => ConstInt::Isize(ConstIsize::Is64(0)),
                 _ => bug!(),
@@ -71,6 +72,7 @@ impl IntTypeExt for attr::IntType {
             UnsignedInt(ast::UintTy::U32) => ConstInt::U32(0),
             UnsignedInt(ast::UintTy::U64) => ConstInt::U64(0),
             UnsignedInt(ast::UintTy::Us) => match tcx.sess.target.uint_type {
+                ast::UintTy::U16 => ConstInt::Usize(ConstUsize::Us16(0)),
                 ast::UintTy::U32 => ConstInt::Usize(ConstUsize::Us32(0)),
                 ast::UintTy::U64 => ConstInt::Usize(ConstUsize::Us64(0)),
                 _ => bug!(),