[llvm] r194562 - This patch fixes a bug in floating point operands parsing, when instruction alias uses default register operand.
Vladimir Medic
Vladimir.Medic at imgtec.com
Wed Nov 13 01:48:54 PST 2013
Author: vmedic
Date: Wed Nov 13 03:48:53 2013
New Revision: 194562
URL: http://llvm.org/viewvc/llvm-project?rev=194562&view=rev
Log:
This patch fixes a bug in floating point operands parsing, when instruction alias uses default register operand.
Modified:
llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
llvm/trunk/test/MC/Mips/mips-fpu-instructions.s
Modified: llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp?rev=194562&r1=194561&r2=194562&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp Wed Nov 13 03:48:53 2013
@@ -1159,9 +1159,7 @@ MipsAsmParser::ParseOperand(SmallVectorI
return true;
SMLoc E = SMLoc::getFromPointer(Parser.getTok().getLoc().getPointer() - 1);
-
MCSymbol *Sym = getContext().GetOrCreateSymbol("$" + Identifier);
-
// Otherwise create a symbol reference.
const MCExpr *Res =
MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_None, getContext());
@@ -1170,6 +1168,25 @@ MipsAsmParser::ParseOperand(SmallVectorI
return false;
}
case AsmToken::Identifier:
+ // For instruction aliases like "bc1f $Label" dedicated parser will
+ // eat the '$' sign before failing. So in order to look for appropriate
+ // label we must check first if we have already consumed '$'.
+ if (hasConsumedDollar) {
+ hasConsumedDollar = false;
+ SMLoc S = Parser.getTok().getLoc();
+ StringRef Identifier;
+ if (Parser.parseIdentifier(Identifier))
+ return true;
+ SMLoc E =
+ SMLoc::getFromPointer(Parser.getTok().getLoc().getPointer() - 1);
+ MCSymbol *Sym = getContext().GetOrCreateSymbol("$" + Identifier);
+ // Create a symbol reference.
+ const MCExpr *Res =
+ MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_None, getContext());
+
+ Operands.push_back(MipsOperand::CreateImm(Res, S, E));
+ return false;
+ }
// Look for the existing symbol, we should check if
// we need to assigne the propper RegisterKind.
if (searchSymbolAlias(Operands, MipsOperand::Kind_None))
Modified: llvm/trunk/test/MC/Mips/mips-fpu-instructions.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/mips-fpu-instructions.s?rev=194562&r1=194561&r2=194562&view=diff
==============================================================================
--- llvm/trunk/test/MC/Mips/mips-fpu-instructions.s (original)
+++ llvm/trunk/test/MC/Mips/mips-fpu-instructions.s Wed Nov 13 03:48:53 2013
@@ -138,6 +138,8 @@
#------------------------------------------------------------------------------
# FP move instructions
#------------------------------------------------------------------------------
+# CHECK: bc1f $BB_1 # encoding: [A,A,0x00,0x45]
+# CHECK: # fixup A - offset: 0, value: ($BB_1), kind: fixup_Mips_PC16
# CHECK: cfc1 $6, $0 # encoding: [0x00,0x00,0x46,0x44]
# CHECK: ctc1 $10, $31 # encoding: [0x00,0xf8,0xca,0x44]
@@ -173,7 +175,7 @@
# CHECK: sdc2 $4, 16($sp) # encoding: [0x10,0x00,0xa4,0xfb]
# CHECK: lwc2 $11, 12($ra) # encoding: [0x0c,0x00,0xeb,0xcb]
# CHECK: ldc2 $11, 12($ra) # encoding: [0x0c,0x00,0xeb,0xdb]
-
+ bc1f $fcc0, $BB_1
cfc1 $a2,$0
ctc1 $10,$31
mfc1 $a2,$f7
More information about the llvm-commits
mailing list