summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2011-01-10 12:24:52 +0000
committerDaniel Dunbar <daniel@zuster.org>2011-01-10 12:24:52 +0000
commitbadbd2fde9b8debd6265e8ece511fb01123d1d5f (patch)
tree7c836a2d958c3f81ac741027f8febc7126e3249e
parentf4db877cff62340aaf9f29d3994562ae1cee8d72 (diff)
downloadllvm-badbd2fde9b8debd6265e8ece511fb01123d1d5f.tar.gz
llvm-badbd2fde9b8debd6265e8ece511fb01123d1d5f.tar.bz2
llvm-badbd2fde9b8debd6265e8ece511fb01123d1d5f.tar.xz
MC/ARM/AsmParser: Split out SplitMnemonicAndCC().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123169 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/ARM/AsmParser/ARMAsmParser.cpp46
1 files changed, 29 insertions, 17 deletions
diff --git a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
index 8322d70ced..ed664e9554 100644
--- a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -866,19 +866,20 @@ bool ARMAsmParser::ParseOperand(SmallVectorImpl<MCParsedAsmOperand*> &Operands){
}
}
-/// Parse an arm instruction mnemonic followed by its operands.
-bool ARMAsmParser::ParseInstruction(StringRef Name, SMLoc NameLoc,
- SmallVectorImpl<MCParsedAsmOperand*> &Operands) {
- // Create the leading tokens for the mnemonic, split by '.' characters.
- size_t Start = 0, Next = Name.find('.');
- StringRef Head = Name.slice(Start, Next);
-
- // Determine the predicate, if any.
+// FIXME: Would be nice to autogen this.
+static unsigned SplitMnemonicAndCC(StringRef &Mnemonic) {
+ // Ignore some mnemonics we know aren't predicated forms.
+ if (Mnemonic == "movs" ||
+ Mnemonic == "vmls" ||
+ Mnemonic == "vnmls")
+ return ARMCC::AL;
+
+ // Otherwise, determine the predicate.
//
// FIXME: We need a way to check whether a prefix supports predication,
// otherwise we will end up with an ambiguity for instructions that happen to
// end with a predicate name.
- unsigned CC = StringSwitch<unsigned>(Head.substr(Head.size()-2))
+ unsigned CC = StringSwitch<unsigned>(Mnemonic.substr(Mnemonic.size()-2))
.Case("eq", ARMCC::EQ)
.Case("ne", ARMCC::NE)
.Case("hs", ARMCC::HS)
@@ -895,20 +896,31 @@ bool ARMAsmParser::ParseInstruction(StringRef Name, SMLoc NameLoc,
.Case("le", ARMCC::LE)
.Case("al", ARMCC::AL)
.Default(~0U);
-
- if (CC == ~0U ||
- (CC == ARMCC::LS && (Head == "vmls" || Head == "vnmls"))) {
- CC = ARMCC::AL;
- } else {
- Head = Head.slice(0, Head.size() - 2);
+ if (CC != ~0U) {
+ Mnemonic = Mnemonic.slice(0, Mnemonic.size() - 2);
+ return CC;
}
+ return ARMCC::AL;
+}
+
+/// Parse an arm instruction mnemonic followed by its operands.
+bool ARMAsmParser::ParseInstruction(StringRef Name, SMLoc NameLoc,
+ SmallVectorImpl<MCParsedAsmOperand*> &Operands) {
+ // Create the leading tokens for the mnemonic, split by '.' characters.
+ size_t Start = 0, Next = Name.find('.');
+ StringRef Head = Name.slice(Start, Next);
+
+ // Determine the predicate, if any.
+ unsigned CC = SplitMnemonicAndCC(Head);
+
Operands.push_back(ARMOperand::CreateToken(Head, NameLoc));
- if (Head != "trap")
- // FIXME: Should only add this operand for predicated instructions
+ // FIXME: Should only add this operand for predicated instructions
+ if (Head != "trap") {
Operands.push_back(ARMOperand::CreateCondCode(ARMCC::CondCodes(CC),
NameLoc));
+ }
// Add the remaining tokens in the mnemonic.
while (Next != StringRef::npos) {