[llvm] r244230 - MIR Serialization: Serialize the 'invariant' machine memory operand flag.

Alex Lorenz via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 6 09:55:54 PDT 2015


Author: arphaman
Date: Thu Aug  6 11:55:53 2015
New Revision: 244230

URL: http://llvm.org/viewvc/llvm-project?rev=244230&view=rev
Log:
MIR Serialization: Serialize the 'invariant' machine memory operand flag.

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=244230&r1=244229&r2=244230&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MILexer.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MILexer.cpp Thu Aug  6 11:55:53 2015
@@ -176,6 +176,7 @@ static MIToken::TokenKind getIdentifierK
       .Case("target-flags", MIToken::kw_target_flags)
       .Case("volatile", MIToken::kw_volatile)
       .Case("non-temporal", MIToken::kw_non_temporal)
+      .Case("invariant", MIToken::kw_invariant)
       .Default(MIToken::Identifier);
 }
 

Modified: llvm/trunk/lib/CodeGen/MIRParser/MILexer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MILexer.h?rev=244230&r1=244229&r2=244230&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MILexer.h (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MILexer.h Thu Aug  6 11:55:53 2015
@@ -68,6 +68,7 @@ struct MIToken {
     kw_target_flags,
     kw_volatile,
     kw_non_temporal,
+    kw_invariant,
 
     // Identifier tokens
     Identifier,
@@ -130,7 +131,8 @@ public:
   }
 
   bool isMemoryOperandFlag() const {
-    return Kind == kw_volatile || Kind == kw_non_temporal;
+    return Kind == kw_volatile || Kind == kw_non_temporal ||
+           Kind == kw_invariant;
   }
 
   bool is(TokenKind K) const { return Kind == K; }

Modified: llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp?rev=244230&r1=244229&r2=244230&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp Thu Aug  6 11:55:53 2015
@@ -1066,8 +1066,11 @@ bool MIParser::parseMemoryOperandFlag(un
   case MIToken::kw_non_temporal:
     Flags |= MachineMemOperand::MONonTemporal;
     break;
+  case MIToken::kw_invariant:
+    Flags |= MachineMemOperand::MOInvariant;
+    break;
   // TODO: report an error when we specify the same flag more than once.
-  // TODO: parse the other memory operand flags.
+  // TODO: parse the target specific memory operand flags.
   default:
     llvm_unreachable("The current token should be a memory operand flag");
   }

Modified: llvm/trunk/lib/CodeGen/MIRPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRPrinter.cpp?rev=244230&r1=244229&r2=244230&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRPrinter.cpp Thu Aug  6 11:55:53 2015
@@ -652,11 +652,13 @@ void MIPrinter::print(const MachineOpera
 
 void MIPrinter::print(const MachineMemOperand &Op) {
   OS << '(';
-  // TODO: Print operand's other flags.
+  // TODO: Print operand's target specific flags.
   if (Op.isVolatile())
     OS << "volatile ";
   if (Op.isNonTemporal())
     OS << "non-temporal ";
+  if (Op.isInvariant())
+    OS << "invariant ";
   if (Op.isLoad())
     OS << "load ";
   else {

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=244230&r1=244229&r2=244230&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/X86/memory-operands.mir (original)
+++ llvm/trunk/test/CodeGen/MIR/X86/memory-operands.mir Thu Aug  6 11:55:53 2015
@@ -35,6 +35,14 @@
 
   !0 = !{i32 1}
 
+  define i32 @invariant_load(i32* %x) {
+  entry:
+    %v = load i32, i32* %x, !invariant.load !1
+    ret i32 %v
+  }
+
+  !1 = !{}
+
 ...
 ---
 name:            test
@@ -100,3 +108,18 @@ body:
       - 'MOVNTImr killed %rdi, 1, _, 0, _, killed %esi :: (non-temporal store 4 into %ir.a)'
       - RETQ
 ...
+---
+name:            invariant_load
+tracksRegLiveness: true
+liveins:
+  - { reg: '%rdi' }
+body:
+  - id:          0
+    name:        entry
+    liveins:     [ '%rdi' ]
+    instructions:
+# CHECK: name: invariant_load
+# CHECK: %eax = MOV32rm killed %rdi, 1, _, 0, _ :: (invariant load 4 from %ir.x)
+      - '%eax = MOV32rm killed %rdi, 1, _, 0, _ :: (invariant load 4 from %ir.x)'
+      - 'RETQ %eax'
+...




More information about the llvm-commits mailing list