summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
diff options
context:
space:
mode:
authorUlrich Weigand <ulrich.weigand@de.ibm.com>2013-06-24 16:52:04 +0000
committerUlrich Weigand <ulrich.weigand@de.ibm.com>2013-06-24 16:52:04 +0000
commit86247b6e27c37a8693d4d63789a9b2659b181b10 (patch)
treee554641003d6ddf1a4ede05f9121847d7b43e729 /llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
parenta466b9aeb9138cff95bf06889b2d6d31d6b986cf (diff)
downloadbcm5719-llvm-86247b6e27c37a8693d4d63789a9b2659b181b10.tar.gz
bcm5719-llvm-86247b6e27c37a8693d4d63789a9b2659b181b10.zip
[PowerPC] Add predicted forms of branches
This adds support for the predicted forms of branches (+/-). There are three cases to consider: - Branches using a PPC::Predicate code For these, I've added new PPC::Predicate codes corresponding to the BO values for predicted branch forms, and updated insn printing to print them correctly. I've also added new aliases for the asm parser matching the new forms. - bt/bf I've added new aliases matching to gBC etc. - bd(n)z variants I've added new instruction patterns for the predicted forms. In all cases, the new patterns are used for the asm parser only. (The new infrastructure ought to be sufficient to allow use by the compiler too at some point.) llvm-svn: 184754
Diffstat (limited to 'llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp')
-rw-r--r--llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp b/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
index 999c6778248..6803d664bc4 100644
--- a/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
+++ b/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
@@ -747,6 +747,22 @@ bool PPCAsmParser::
ParseInstruction(ParseInstructionInfo &Info, StringRef Name, SMLoc NameLoc,
SmallVectorImpl<MCParsedAsmOperand*> &Operands) {
// The first operand is the token for the instruction name.
+ // If the next character is a '+' or '-', we need to add it to the
+ // instruction name, to match what TableGen is doing.
+ if (getLexer().is(AsmToken::Plus)) {
+ getLexer().Lex();
+ char *NewOpcode = new char[Name.size() + 1];
+ memcpy(NewOpcode, Name.data(), Name.size());
+ NewOpcode[Name.size()] = '+';
+ Name = StringRef(NewOpcode, Name.size() + 1);
+ }
+ if (getLexer().is(AsmToken::Minus)) {
+ getLexer().Lex();
+ char *NewOpcode = new char[Name.size() + 1];
+ memcpy(NewOpcode, Name.data(), Name.size());
+ NewOpcode[Name.size()] = '-';
+ Name = StringRef(NewOpcode, Name.size() + 1);
+ }
// If the instruction ends in a '.', we need to create a separate
// token for it, to match what TableGen is doing.
size_t Dot = Name.find('.');
OpenPOWER on IntegriCloud