[llvm] r245247 - MIR Serialization: Serialize the memory operand's range metadata node.

Alex Lorenz via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 17 15:09:52 PDT 2015


Author: arphaman
Date: Mon Aug 17 17:09:52 2015
New Revision: 245247

URL: http://llvm.org/viewvc/llvm-project?rev=245247&view=rev
Log:
MIR Serialization: Serialize the memory operand's range metadata node.

Modified:
    llvm/trunk/lib/CodeGen/MIRParser/MILexer.cpp
    llvm/trunk/lib/CodeGen/MIRParser/MILexer.h
    llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
    llvm/trunk/lib/CodeGen/MIRPrinter.cpp
    llvm/trunk/test/CodeGen/MIR/X86/memory-operands.mir

Modified: llvm/trunk/lib/CodeGen/MIRParser/MILexer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MILexer.cpp?rev=245247&r1=245246&r2=245247&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MILexer.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MILexer.cpp Mon Aug 17 17:09:52 2015
@@ -447,6 +447,7 @@ static MIToken::TokenKind getMetadataKey
       .Case("!tbaa", MIToken::md_tbaa)
       .Case("!alias.scope", MIToken::md_alias_scope)
       .Case("!noalias", MIToken::md_noalias)
+      .Case("!range", MIToken::md_range)
       .Default(MIToken::Error);
 }
 

Modified: llvm/trunk/lib/CodeGen/MIRParser/MILexer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MILexer.h?rev=245247&r1=245246&r2=245247&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MILexer.h (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MILexer.h Mon Aug 17 17:09:52 2015
@@ -89,6 +89,7 @@ struct MIToken {
     md_tbaa,
     md_alias_scope,
     md_noalias,
+    md_range,
 
     // Identifier tokens
     Identifier,

Modified: llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp?rev=245247&r1=245246&r2=245247&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp Mon Aug 17 17:09:52 2015
@@ -1527,6 +1527,7 @@ bool MIParser::parseMachineMemoryOperand
     return true;
   unsigned BaseAlignment = Size;
   AAMDNodes AAInfo;
+  MDNode *Range = nullptr;
   while (consumeIfPresent(MIToken::comma)) {
     switch (Token.kind()) {
     case MIToken::kw_align:
@@ -1548,16 +1549,21 @@ bool MIParser::parseMachineMemoryOperand
       if (parseMDNode(AAInfo.NoAlias))
         return true;
       break;
-    // TODO: Parse the ranges metadata.
+    case MIToken::md_range:
+      lex();
+      if (parseMDNode(Range))
+        return true;
+      break;
     // TODO: Report an error on duplicate metadata nodes.
     default:
-      return error(
-          "expected 'align' or '!tbaa' or '!alias.scope' or '!noalias'");
+      return error("expected 'align' or '!tbaa' or '!alias.scope' or "
+                   "'!noalias' or '!range'");
     }
   }
   if (expectAndConsume(MIToken::rparen))
     return true;
-  Dest = MF.getMachineMemOperand(Ptr, Flags, Size, BaseAlignment, AAInfo);
+  Dest =
+      MF.getMachineMemOperand(Ptr, Flags, Size, BaseAlignment, AAInfo, Range);
   return false;
 }
 

Modified: llvm/trunk/lib/CodeGen/MIRPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRPrinter.cpp?rev=245247&r1=245246&r2=245247&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRPrinter.cpp Mon Aug 17 17:09:52 2015
@@ -790,7 +790,10 @@ void MIPrinter::print(const MachineMemOp
     OS << ", !noalias ";
     AAInfo.NoAlias->printAsOperand(OS, MST);
   }
-  // TODO: Print the ranges metadata.
+  if (Op.getRanges()) {
+    OS << ", !range ";
+    Op.getRanges()->printAsOperand(OS, MST);
+  }
   OS << ')';
 }
 

Modified: llvm/trunk/test/CodeGen/MIR/X86/memory-operands.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/X86/memory-operands.mir?rev=245247&r1=245246&r2=245247&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/X86/memory-operands.mir (original)
+++ llvm/trunk/test/CodeGen/MIR/X86/memory-operands.mir Mon Aug 17 17:09:52 2015
@@ -148,6 +148,15 @@
   !9 = distinct !{!9, !10, !"some scope"}
   !10 = distinct !{!10, !"some domain"}
 
+  define zeroext i1 @range_metadata(i8* %x) {
+  entry:
+    %0 = load i8, i8* %x, align 1, !range !11
+    %tobool = trunc i8 %0 to i1
+    ret i1 %tobool
+  }
+
+  !11 = !{i8 0, i8 2}
+
 ...
 ---
 name:            test
@@ -406,3 +415,16 @@ body: |
     MOVSSmr killed %rdi, 1, _, 28, _, killed %xmm0 :: (store 4 into %ir.arrayidx)
     RETQ
 ...
+---
+name:            range_metadata
+tracksRegLiveness: true
+liveins:
+  - { reg: '%rdi' }
+body: |
+  bb.0.entry:
+    liveins: %rdi
+  ; CHECK-LABEL: name: range_metadata
+  ; CHECK: %al = MOV8rm killed %rdi, 1, _, 0, _ :: (load 1 from %ir.x, !range !11)
+    %al = MOV8rm killed %rdi, 1, _, 0, _ :: (load 1 from %ir.x, !range !11)
+    RETQ %al
+...




More information about the llvm-commits mailing list