about summary refs log tree commit diff
path: root/src/compiletest/util.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiletest/util.rs')
-rw-r--r--src/compiletest/util.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/compiletest/util.rs b/src/compiletest/util.rs
index 16e2806f72c..2e11cf47d1e 100644
--- a/src/compiletest/util.rs
+++ b/src/compiletest/util.rs
@@ -25,6 +25,23 @@ const OS_TABLE: &'static [(&'static str, &'static str)] = &[
     ("openbsd", "openbsd"),
 ];
 
+const ARCH_TABLE: &'static [(&'static str, &'static str)] = &[
+    ("i386", "x86"),
+    ("i686", "x86"),
+    ("amd64", "x86_64"),
+    ("x86_64", "x86_64"),
+    ("sparc", "sparc"),
+    ("powerpc", "powerpc"),
+    ("arm64", "aarch64"),
+    ("arm", "arm"),
+    ("aarch64", "aarch64"),
+    ("mips", "mips"),
+    ("xcore", "xcore"),
+    ("msp430", "msp430"),
+    ("hexagon", "hexagon"),
+    ("s390x", "systemz"),
+];
+
 pub fn get_os(triple: &str) -> &'static str {
     for &(triple_os, os) in OS_TABLE {
         if triple.contains(triple_os) {
@@ -33,6 +50,14 @@ pub fn get_os(triple: &str) -> &'static str {
     }
     panic!("Cannot determine OS from triple");
 }
+pub fn get_arch(triple: &str) -> &'static str {
+    for &(triple_arch, arch) in ARCH_TABLE {
+        if triple.contains(triple_arch) {
+            return arch
+        }
+    }
+    panic!("Cannot determine Architecture from triple");
+}
 
 pub fn make_new_path(path: &str) -> String {
     assert!(cfg!(windows));