[llvm] r243553 - MIR Parser: Parse multiple LHS register machine operands.

Alex Lorenz arphaman at gmail.com
Wed Jul 29 11:51:21 PDT 2015


Author: arphaman
Date: Wed Jul 29 13:51:21 2015
New Revision: 243553

URL: http://llvm.org/viewvc/llvm-project?rev=243553&view=rev
Log:
MIR Parser: Parse multiple LHS register machine operands.

Added:
    llvm/trunk/test/CodeGen/MIR/AArch64/
    llvm/trunk/test/CodeGen/MIR/AArch64/lit.local.cfg
    llvm/trunk/test/CodeGen/MIR/AArch64/multiple-lhs-operands.mir
Modified:
    llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp

Modified: llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp?rev=243553&r1=243552&r2=243553&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp Wed Jul 29 13:51:21 2015
@@ -214,6 +214,8 @@ static const char *toString(MIToken::Tok
   switch (TokenKind) {
   case MIToken::comma:
     return "','";
+  case MIToken::equal:
+    return "'='";
   case MIToken::lparen:
     return "'('";
   case MIToken::rparen:
@@ -234,18 +236,19 @@ bool MIParser::parse(MachineInstr *&MI)
   lex();
 
   // Parse any register operands before '='
-  // TODO: Allow parsing of multiple operands before '='
   MachineOperand MO = MachineOperand::CreateImm(0);
   SmallVector<MachineOperandWithLocation, 8> Operands;
-  if (Token.isRegister() || Token.isRegisterFlag()) {
+  while (Token.isRegister() || Token.isRegisterFlag()) {
     auto Loc = Token.location();
     if (parseRegisterOperand(MO, /*IsDef=*/true))
       return true;
     Operands.push_back(MachineOperandWithLocation(MO, Loc, Token.location()));
-    if (Token.isNot(MIToken::equal))
-      return error("expected '='");
+    if (Token.isNot(MIToken::comma))
+      break;
     lex();
   }
+  if (!Operands.empty() && expectAndConsume(MIToken::equal))
+    return true;
 
   unsigned OpCode, Flags = 0;
   if (Token.isError() || parseInstruction(OpCode, Flags))

Added: llvm/trunk/test/CodeGen/MIR/AArch64/lit.local.cfg
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/AArch64/lit.local.cfg?rev=243553&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/AArch64/lit.local.cfg (added)
+++ llvm/trunk/test/CodeGen/MIR/AArch64/lit.local.cfg Wed Jul 29 13:51:21 2015
@@ -0,0 +1,8 @@
+import re
+
+if not 'AArch64' in config.root.targets:
+    config.unsupported = True
+
+# For now we don't test arm64-win32.
+if re.search(r'cygwin|mingw32|win32|windows-gnu|windows-msvc', config.target_triple):
+    config.unsupported = True

Added: llvm/trunk/test/CodeGen/MIR/AArch64/multiple-lhs-operands.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/AArch64/multiple-lhs-operands.mir?rev=243553&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/AArch64/multiple-lhs-operands.mir (added)
+++ llvm/trunk/test/CodeGen/MIR/AArch64/multiple-lhs-operands.mir Wed Jul 29 13:51:21 2015
@@ -0,0 +1,29 @@
+# RUN: llc -mtriple=aarch64-none-linux-gnu -start-after branch-folder -stop-after branch-folder -o /dev/null %s | FileCheck %s
+# This test ensures that the MIR parser can parse multiple register machine
+# operands before '='.
+
+--- |
+
+  declare void @foo()
+
+  define void @trivial_fp_func() {
+  entry:
+    call void @foo()
+    ret void
+  }
+
+...
+---
+name:            trivial_fp_func
+body:
+  - id:          0
+    name:        entry
+    liveins:     [ '%lr', '%fp', '%lr', '%fp' ]
+    instructions:
+      - '%sp = frame-setup STPXpre killed %fp, killed %lr, %sp, -2'
+      - '%fp = frame-setup ADDXri %sp, 0, 0'
+      - 'BL @foo, csr_aarch64_aapcs, implicit-def dead %lr, implicit %sp, implicit-def %sp'
+# CHECK: %sp, %fp, %lr = LDPXpost %sp, 2
+      - '%sp, %fp, %lr = LDPXpost %sp, 2'
+      - RET_ReallyLR
+...





More information about the llvm-commits mailing list