mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-13 22:58:50 +00:00
Fix ARM triple parsing
The triple parser should only accept existing architecture names when the triple starts with armv, armebv, thumbv or thumbebv. Patch by Gabor Ballabas. llvm-svn: 222129
This commit is contained in:
parent
b5ae33d9e3
commit
b92ad16856
@ -222,6 +222,50 @@ Triple::ArchType Triple::getArchTypeForLLVMName(StringRef Name) {
|
||||
.Default(UnknownArch);
|
||||
}
|
||||
|
||||
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)
|
||||
@ -231,19 +275,10 @@ static Triple::ArchType parseArch(StringRef ArchName) {
|
||||
.Case("powerpc", Triple::ppc)
|
||||
.Cases("powerpc64", "ppu", Triple::ppc64)
|
||||
.Case("powerpc64le", Triple::ppc64le)
|
||||
.Case("aarch64", Triple::aarch64)
|
||||
.Case("aarch64_be", Triple::aarch64_be)
|
||||
.Case("arm64", Triple::aarch64)
|
||||
.Cases("arm", "xscale", Triple::arm)
|
||||
// FIXME: It would be good to replace these with explicit names for all the
|
||||
// various suffixes supported.
|
||||
.StartsWith("armv", Triple::arm)
|
||||
.Case("armeb", Triple::armeb)
|
||||
.StartsWith("armebv", Triple::armeb)
|
||||
.Case("thumb", Triple::thumb)
|
||||
.StartsWith("thumbv", Triple::thumb)
|
||||
.Case("thumbeb", Triple::thumbeb)
|
||||
.StartsWith("thumbebv", Triple::thumbeb)
|
||||
.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)
|
||||
|
32
test/CodeGen/ARM/invalid-target.ll
Normal file
32
test/CodeGen/ARM/invalid-target.ll
Normal file
@ -0,0 +1,32 @@
|
||||
; RUN: not llc -mtriple armvinvalid-linux-gnueabi %s -o - 2>&1 | \
|
||||
; RUN: FileCheck %s --check-prefix=ARMVINVALID
|
||||
|
||||
; RUN: not llc -mtriple armebvinvalid-linux-gnueabi %s -o - 2>&1 | \
|
||||
; RUN: FileCheck %s --check-prefix=ARMEBVINVALID
|
||||
|
||||
; RUN: not llc -mtriple thumbvinvalid-linux-gnueabi %s -o - 2>&1 | \
|
||||
; RUN: FileCheck %s --check-prefix=THUMBVINVALID
|
||||
|
||||
; RUN: not llc -mtriple thumbebvinvalid-linux-gnueabi %s -o - 2>&1 | \
|
||||
; RUN: FileCheck %s --check-prefix=THUMBEBVINVALID
|
||||
|
||||
; RUN: not llc -mtriple thumbv2-linux-gnueabi %s -o - 2>&1 | \
|
||||
; RUN: FileCheck %s --check-prefix=THUMBV2
|
||||
|
||||
; RUN: not llc -mtriple thumbv3-linux-gnueabi %s -o - 2>&1 | \
|
||||
; RUN: FileCheck %s --check-prefix=THUMBV3
|
||||
|
||||
; RUN: not llc -mtriple arm64invalid-linux-gnu %s -o - 2>&1 | \
|
||||
; RUN: FileCheck %s --check-prefix=ARM64INVALID
|
||||
|
||||
; RUN: not llc -mtriple aarch64invalid-linux-gnu %s -o - 2>&1 | \
|
||||
; RUN: FileCheck %s --check-prefix=AARCH64INVALID
|
||||
|
||||
; ARMVINVALID: error: unable to get target for 'armvinvalid--linux-gnueabi'
|
||||
; ARMEBVINVALID: error: unable to get target for 'armebvinvalid--linux-gnueabi'
|
||||
; THUMBVINVALID: error: unable to get target for 'thumbvinvalid--linux-gnueabi'
|
||||
; THUMBEBVINVALID: error: unable to get target for 'thumbebvinvalid--linux-gnueabi'
|
||||
; THUMBV2: error: unable to get target for 'thumbv2--linux-gnueabi'
|
||||
; THUMBV3: error: unable to get target for 'thumbv3--linux-gnueabi'
|
||||
; ARM64INVALID: error: unable to get target for 'arm64invalid--linux-gnu'
|
||||
; AARCH64INVALID: error: unable to get target for 'aarch64invalid--linux-gnu'
|
Loading…
Reference in New Issue
Block a user