-Triple::ArchType Triple::getArchTypeForDarwinArchName(StringRef Str) {
- // See arch(3) and llvm-gcc's driver-driver.c. We don't implement support for
- // archs which Darwin doesn't use.
-
- // The matching this routine does is fairly pointless, since it is neither the
- // complete architecture list, nor a reasonable subset. The problem is that
- // historically the driver driver accepts this and also ties its -march=
- // handling to the architecture name, so we need to be careful before removing
- // support for it.
-
- // This code must be kept in sync with Clang's Darwin specific argument
- // translation.
-
- return StringSwitch<ArchType>(Str)
- .Cases("ppc", "ppc601", "ppc603", "ppc604", "ppc604e", Triple::ppc)
- .Cases("ppc750", "ppc7400", "ppc7450", "ppc970", Triple::ppc)
- .Case("ppc64", Triple::ppc64)
- .Cases("i386", "i486", "i486SX", "i586", "i686", Triple::x86)
- .Cases("pentium", "pentpro", "pentIIm3", "pentIIm5", "pentium4",
- Triple::x86)
- .Case("x86_64", Triple::x86_64)
- // This is derived from the driver driver.
- .Cases("arm", "armv4t", "armv5", "armv6", Triple::arm)
- .Cases("armv7", "armv7f", "armv7k", "armv7s", "xscale", Triple::arm)
- .Case("ptx32", Triple::ptx32)
- .Case("ptx64", Triple::ptx64)
+static Triple::ArchType parseARMArch(StringRef ArchName) {
+ size_t offset = StringRef::npos;
+ Triple::ArchType arch = Triple::UnknownArch;
+ bool isThumb = ArchName.startswith("thumb");
+
+ if (ArchName.equals("arm"))
+ return Triple::arm;
+ if (ArchName.equals("armeb"))
+ return Triple::armeb;
+ if (ArchName.equals("thumb"))
+ return Triple::thumb;
+ if (ArchName.equals("thumbeb"))
+ return Triple::thumbeb;
+ if (ArchName.equals("arm64") || ArchName.equals("aarch64"))
+ return Triple::aarch64;
+ if (ArchName.equals("aarch64_be"))
+ return Triple::aarch64_be;
+
+ if (ArchName.startswith("armv")) {
+ offset = 3;
+ arch = Triple::arm;
+ } else if (ArchName.startswith("armebv")) {
+ offset = 5;
+ arch = Triple::armeb;
+ } else if (ArchName.startswith("thumbv")) {
+ offset = 5;
+ arch = Triple::thumb;
+ } else if (ArchName.startswith("thumbebv")) {
+ offset = 7;
+ arch = Triple::thumbeb;
+ }
+ return StringSwitch<Triple::ArchType>(ArchName.substr(offset))
+ .Cases("v2", "v2a", isThumb ? Triple::UnknownArch : arch)
+ .Cases("v3", "v3m", isThumb ? Triple::UnknownArch : arch)
+ .Cases("v4", "v4t", arch)
+ .Cases("v5", "v5e", "v5t", "v5te", "v5tej", arch)
+ .Cases("v6", "v6j", "v6k", "v6m", arch)
+ .Cases("v6t2", "v6z", "v6zk", arch)
+ .Cases("v7", "v7a", "v7em", "v7l", arch)
+ .Cases("v7m", "v7r", "v7s", arch)
+ .Cases("v8", "v8a", arch)
+ .Default(Triple::UnknownArch);
+}
+
+static Triple::ArchType parseArch(StringRef ArchName) {
+ return StringSwitch<Triple::ArchType>(ArchName)
+ .Cases("i386", "i486", "i586", "i686", Triple::x86)
+ // FIXME: Do we need to support these?
+ .Cases("i786", "i886", "i986", Triple::x86)
+ .Cases("amd64", "x86_64", "x86_64h", Triple::x86_64)
+ .Case("powerpc", Triple::ppc)
+ .Cases("powerpc64", "ppu", Triple::ppc64)
+ .Case("powerpc64le", Triple::ppc64le)
+ .Case("xscale", Triple::arm)
+ .StartsWith("arm", parseARMArch(ArchName))
+ .StartsWith("thumb", parseARMArch(ArchName))
+ .StartsWith("aarch64", parseARMArch(ArchName))
+ .Case("msp430", Triple::msp430)
+ .Cases("mips", "mipseb", "mipsallegrex", Triple::mips)
+ .Cases("mipsel", "mipsallegrexel", Triple::mipsel)
+ .Cases("mips64", "mips64eb", Triple::mips64)
+ .Case("mips64el", Triple::mips64el)
+ .Case("r600", Triple::r600)
+ .Case("hexagon", Triple::hexagon)
+ .Case("s390x", Triple::systemz)
+ .Case("sparc", Triple::sparc)
+ .Cases("sparcv9", "sparc64", Triple::sparcv9)
+ .Case("tce", Triple::tce)
+ .Case("xcore", Triple::xcore)
+ .Case("nvptx", Triple::nvptx)
+ .Case("nvptx64", Triple::nvptx64)
+ .Case("le32", Triple::le32)
+ .Case("le64", Triple::le64)