[PATCH] D26573: MIRParser: Add support for parsing vreg reg alloc hints

Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 14 16:13:12 PST 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL286911: MIRParser: Add support for parsing vreg reg alloc hints (authored by tstellar).

Changed prior to commit:
  https://reviews.llvm.org/D26573?vs=77706&id=77914#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26573

Files:
  llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
  llvm/trunk/lib/CodeGen/MIRParser/MIParser.h
  llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp
  llvm/trunk/test/CodeGen/MIR/X86/expected-named-register-in-allocation-hint.mir


Index: llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp
+++ llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp
@@ -439,8 +439,9 @@
       if (Info.Kind != VRegInfo::NORMAL)
         return error(VReg.Class.SourceRange.Start,
               Twine("preferred register can only be set for normal vregs"));
-      if (parseNamedRegisterReference(PFS, Info.PreferredReg,
-                                      VReg.PreferredRegister.Value, Error))
+
+      if (parseRegisterReference(PFS, Info.PreferredReg,
+                                 VReg.PreferredRegister.Value, Error))
         return error(Error, VReg.PreferredRegister.SourceRange);
     }
   }
Index: llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
+++ llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
@@ -125,6 +125,7 @@
   bool parseStandaloneMBB(MachineBasicBlock *&MBB);
   bool parseStandaloneNamedRegister(unsigned &Reg);
   bool parseStandaloneVirtualRegister(VRegInfo *&Info);
+  bool parseStandaloneRegister(unsigned &Reg);
   bool parseStandaloneStackObject(int &FI);
   bool parseStandaloneMDNode(MDNode *&Node);
 
@@ -728,6 +729,22 @@
   return false;
 }
 
+bool MIParser::parseStandaloneRegister(unsigned &Reg) {
+  lex();
+  if (Token.isNot(MIToken::NamedRegister) &&
+      Token.isNot(MIToken::VirtualRegister))
+    return error("expected either a named or virtual register");
+
+  VRegInfo *Info;
+  if (parseRegister(Reg, Info))
+    return true;
+
+  lex();
+  if (Token.isNot(MIToken::Eof))
+    return error("expected end of string after the register reference");
+  return false;
+}
+
 bool MIParser::parseStandaloneStackObject(int &FI) {
   lex();
   if (Token.isNot(MIToken::StackObject))
@@ -2230,6 +2247,12 @@
   return MIParser(PFS, Error, Src).parseStandaloneMBB(MBB);
 }
 
+bool llvm::parseRegisterReference(PerFunctionMIParsingState &PFS,
+                                  unsigned &Reg, StringRef Src,
+                                  SMDiagnostic &Error) {
+  return MIParser(PFS, Error, Src).parseStandaloneRegister(Reg);
+}
+
 bool llvm::parseNamedRegisterReference(PerFunctionMIParsingState &PFS,
                                        unsigned &Reg, StringRef Src,
                                        SMDiagnostic &Error) {
Index: llvm/trunk/lib/CodeGen/MIRParser/MIParser.h
===================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIParser.h
+++ llvm/trunk/lib/CodeGen/MIRParser/MIParser.h
@@ -96,6 +96,10 @@
                        MachineBasicBlock *&MBB, StringRef Src,
                        SMDiagnostic &Error);
 
+bool parseRegisterReference(PerFunctionMIParsingState &PFS,
+                            unsigned &Reg, StringRef Src,
+                            SMDiagnostic &Error);
+
 bool parseNamedRegisterReference(PerFunctionMIParsingState &PFS, unsigned &Reg,
                                  StringRef Src, SMDiagnostic &Error);
 
Index: llvm/trunk/test/CodeGen/MIR/X86/expected-named-register-in-allocation-hint.mir
===================================================================
--- llvm/trunk/test/CodeGen/MIR/X86/expected-named-register-in-allocation-hint.mir
+++ llvm/trunk/test/CodeGen/MIR/X86/expected-named-register-in-allocation-hint.mir
@@ -1,4 +1,4 @@
-# RUN: not llc -march=x86-64 -run-pass none -o /dev/null %s 2>&1 | FileCheck %s
+# RUN: llc -march=x86-64 -run-pass none -o - %s 2>&1 | FileCheck %s
 
 --- |
 
@@ -14,7 +14,8 @@
 tracksRegLiveness: true
 registers:
   - { id: 0, class: gr32 }
-  # CHECK: [[@LINE+1]]:48: expected a named register
+  # CHECK: - { id: 1, class: gr32, preferred-register: '%0' }
+  # CHECK: - { id: 2, class: gr32, preferred-register: '%edi' }
   - { id: 1, class: gr32, preferred-register: '%0' }
   - { id: 2, class: gr32, preferred-register: '%edi' }
 body: |


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26573.77914.patch
Type: text/x-patch
Size: 4008 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161115/dc3738ae/attachment.bin>


More information about the llvm-commits mailing list