MIR Serialization: Serialize the 'invariant' machine memory operand flag.
authorAlex Lorenz <arphaman@gmail.com>
Thu, 6 Aug 2015 16:55:53 +0000 (16:55 +0000)
committerAlex Lorenz <arphaman@gmail.com>
Thu, 6 Aug 2015 16:55:53 +0000 (16:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244230 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 47e55017f1e24d0b95130a5c3bf322eda72caf59..310ac7b4d7161fab92e910c33d30d963a8297404 100644 (file)
@@ -176,6 +176,7 @@ static MIToken::TokenKind getIdentifierKind(StringRef Identifier) {
       .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);
 }
 
index 1ff7dda1151d7a259af9aa224dd20cdf4f4d21c1..79bcb7fce01d26270824f28ddf1126ad885d7953 100644 (file)
@@ -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; }
index 0c3f5ecce865eb6b71553534b78bf1e3fef9a14e..36460b3f3eb90da0a58552d14e73503060333384 100644 (file)
@@ -1066,8 +1066,11 @@ bool MIParser::parseMemoryOperandFlag(unsigned &Flags) {
   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");
   }
index c84cec9ed2ecc50245f4f4dca5fe5c839ad31845..cc131bc4641ea60c6a511b70873dc7be1aece5da 100644 (file)
@@ -652,11 +652,13 @@ void MIPrinter::print(const MachineOperand &Op, const TargetRegisterInfo *TRI) {
 
 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 {
index 314cc1d287114b9d0b7cc10dd9cc08a06b07e43e..54e9cc47ba0e3b69733bd07ee2d54325602a8ac6 100644 (file)
 
   !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'
+...