summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/PowerPC/AsmParser
diff options
context:
space:
mode:
authorUlrich Weigand <ulrich.weigand@de.ibm.com>2013-07-08 14:49:37 +0000
committerUlrich Weigand <ulrich.weigand@de.ibm.com>2013-07-08 14:49:37 +0000
commitc0944b50fe93f69a7170e66349c323ebea2e1939 (patch)
treeb56ac53c4bd05e6bc5a7bafc9a7827a98d1be906 /llvm/lib/Target/PowerPC/AsmParser
parentc9b82d76e27e4b76dc703670c167c4e5f3071250 (diff)
downloadbcm5719-llvm-c0944b50fe93f69a7170e66349c323ebea2e1939.tar.gz
bcm5719-llvm-c0944b50fe93f69a7170e66349c323ebea2e1939.zip
[PowerPC] Support basic compare mnemonics
This adds support for the basic mnemoics (with the L operand) for the fixed-point compare instructions. These are defined as aliases for the already existing CMPW/CMPD patterns, depending on the value of L. This requires use of InstAlias patterns with immediate literal operands. To make this work, we need two further changes: - define a RegisterPrefix, because otherwise literals 0 and 1 would be parsed as literal register names - provide a PPCAsmParser::validateTargetOperandClass routine to recognize immediate literals (like ARM does) llvm-svn: 185826
Diffstat (limited to 'llvm/lib/Target/PowerPC/AsmParser')
-rw-r--r--llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp b/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
index 237ecdc60e4..790a98e06db 100644
--- a/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
+++ b/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
@@ -229,6 +229,8 @@ public:
SmallVectorImpl<MCParsedAsmOperand*> &Operands);
virtual bool ParseDirective(AsmToken DirectiveID);
+
+ unsigned validateTargetOperandClass(MCParsedAsmOperand *Op, unsigned Kind);
};
/// PPCOperand - Instances of this class represent a parsed PowerPC machine
@@ -1232,3 +1234,25 @@ extern "C" void LLVMInitializePowerPCAsmParser() {
#define GET_REGISTER_MATCHER
#define GET_MATCHER_IMPLEMENTATION
#include "PPCGenAsmMatcher.inc"
+
+// Define this matcher function after the auto-generated include so we
+// have the match class enum definitions.
+unsigned PPCAsmParser::validateTargetOperandClass(MCParsedAsmOperand *AsmOp,
+ unsigned Kind) {
+ // If the kind is a token for a literal immediate, check if our asm
+ // operand matches. This is for InstAliases which have a fixed-value
+ // immediate in the syntax.
+ int64_t ImmVal;
+ switch (Kind) {
+ case MCK_0: ImmVal = 0; break;
+ case MCK_1: ImmVal = 1; break;
+ default: return Match_InvalidOperand;
+ }
+
+ PPCOperand *Op = static_cast<PPCOperand*>(AsmOp);
+ if (Op->isImm() && Op->getImm() == ImmVal)
+ return Match_Success;
+
+ return Match_InvalidOperand;
+}
+
OpenPOWER on IntegriCloud