[llvm] r245527 - MIR Serialization: Use the global value syntax for global value memory operands.

Alex Lorenz via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 19 17:20:03 PDT 2015


Author: arphaman
Date: Wed Aug 19 19:20:03 2015
New Revision: 245527

URL: http://llvm.org/viewvc/llvm-project?rev=245527&view=rev
Log:
MIR Serialization: Use the global value syntax for global value memory operands.

This commit modifies the serialization syntax so that the global IR values in
machine memory operands use the global value '@<name>' syntax instead of the
current '%ir.<name>' syntax.

The unnamed global IR values are handled by this commit as well, as the
existing global value parsing method can parse the unnamed globals already.

Modified:
    llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
    llvm/trunk/lib/CodeGen/MIRPrinter.cpp
    llvm/trunk/test/CodeGen/MIR/AArch64/stack-object-local-offset.mir
    llvm/trunk/test/CodeGen/MIR/X86/frame-info-stack-references.mir
    llvm/trunk/test/CodeGen/MIR/X86/memory-operands.mir

Modified: llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp?rev=245527&r1=245526&r2=245527&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp Wed Aug 19 19:20:03 2015
@@ -1531,9 +1531,6 @@ bool MIParser::parseIRValue(const Value
   switch (Token.kind()) {
   case MIToken::NamedIRValue: {
     V = MF.getFunction()->getValueSymbolTable().lookup(Token.stringValue());
-    if (!V)
-      V = MF.getFunction()->getParent()->getValueSymbolTable().lookup(
-          Token.stringValue());
     break;
   }
   case MIToken::IRValue: {
@@ -1543,6 +1540,14 @@ bool MIParser::parseIRValue(const Value
     V = getIRValue(SlotNumber);
     break;
   }
+  case MIToken::NamedGlobalValue:
+  case MIToken::GlobalValue: {
+    GlobalValue *GV = nullptr;
+    if (parseGlobalValue(GV))
+      return true;
+    V = GV;
+    break;
+  }
   default:
     llvm_unreachable("The current token should be an IR block reference");
   }
@@ -1646,7 +1651,9 @@ bool MIParser::parseMachinePointerInfo(M
     Dest = MachinePointerInfo(PSV, Offset);
     return false;
   }
-  if (Token.isNot(MIToken::NamedIRValue) && Token.isNot(MIToken::IRValue))
+  if (Token.isNot(MIToken::NamedIRValue) && Token.isNot(MIToken::IRValue) &&
+      Token.isNot(MIToken::GlobalValue) &&
+      Token.isNot(MIToken::NamedGlobalValue))
     return error("expected an IR value reference");
   const Value *V = nullptr;
   if (parseIRValue(V))

Modified: llvm/trunk/lib/CodeGen/MIRPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRPrinter.cpp?rev=245527&r1=245526&r2=245527&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRPrinter.cpp Wed Aug 19 19:20:03 2015
@@ -608,7 +608,10 @@ void MIPrinter::printIRBlockReference(co
 }
 
 void MIPrinter::printIRValueReference(const Value &V) {
-  // TODO: Global values should use the '@' syntax.
+  if (isa<GlobalValue>(V)) {
+    V.printAsOperand(OS, /*PrintType=*/false, MST);
+    return;
+  }
   OS << "%ir.";
   if (V.hasName()) {
     printLLVMNameWithoutPrefix(OS, V.getName());

Modified: llvm/trunk/test/CodeGen/MIR/AArch64/stack-object-local-offset.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/AArch64/stack-object-local-offset.mir?rev=245527&r1=245526&r2=245527&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/AArch64/stack-object-local-offset.mir (original)
+++ llvm/trunk/test/CodeGen/MIR/AArch64/stack-object-local-offset.mir Wed Aug 19 19:20:03 2015
@@ -32,10 +32,10 @@ stack:
 body: |
   bb.0.entry:
     %0 = ADRP @var
-    %1 = LDRXui killed %0, @var :: (load 8 from %ir.var)
+    %1 = LDRXui killed %0, @var :: (load 8 from @var)
     STRXui killed %1, %stack.0.local_var, 0 :: (store 8 into %ir.local_var)
     %2 = ADRP @local_addr
     %3 = ADDXri %stack.0.local_var, 0, 0
-    STRXui killed %3, killed %2, @local_addr :: (store 8 into %ir.local_addr)
+    STRXui killed %3, killed %2, @local_addr :: (store 8 into @local_addr)
     RET_ReallyLR
 ...

Modified: llvm/trunk/test/CodeGen/MIR/X86/frame-info-stack-references.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/X86/frame-info-stack-references.mir?rev=245527&r1=245526&r2=245527&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/X86/frame-info-stack-references.mir (original)
+++ llvm/trunk/test/CodeGen/MIR/X86/frame-info-stack-references.mir Wed Aug 19 19:20:03 2015
@@ -57,7 +57,7 @@ body: |
 
     frame-setup PUSH64r killed %rbx, implicit-def %rsp, implicit %rsp
     %rsp = frame-setup SUB64ri8 %rsp, 32, implicit-def dead %eflags
-    %rbx = LOAD_STACK_GUARD :: (invariant load 8 from %ir.__stack_chk_guard)
+    %rbx = LOAD_STACK_GUARD :: (invariant load 8 from @__stack_chk_guard)
     MOV64mr %rsp, 1, _, 24, _, %rbx
     %rsi = LEA64r %rsp, 1, _, 19, _
     MOV64mr %rsp, 1, _, 8, _, %rsi

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=245527&r1=245526&r2=245527&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/X86/memory-operands.mir (original)
+++ llvm/trunk/test/CodeGen/MIR/X86/memory-operands.mir Wed Aug 19 19:20:03 2015
@@ -93,11 +93,15 @@
     ret i32 %b
   }
 
+  @0 = external global i32
+
   define i32 @global_value() {
   entry:
     %a = load i32, i32* @G
     %b = add i32 %a, 1
-    ret i32 %b
+    %c = load i32, i32* @0
+    %d = add i32 %b, %c
+    ret i32 %d
   }
 
   define i32 @jumptable_psv(i32 %in) {
@@ -358,10 +362,13 @@ tracksRegLiveness: true
 body: |
   bb.0.entry:
     %rax = MOV64rm %rip, 1, _, @G, _
-  ; CHECK: name: global_value
-  ; CHECK: %eax = MOV32rm killed %rax, 1, _, 0, _ :: (load 4 from %ir.G)
-    %eax = MOV32rm killed %rax, 1, _, 0, _ :: (load 4 from %ir.G)
-    %eax = INC32r killed %eax, implicit-def dead %eflags
+  ; CHECK-LABEL: name: global_value
+  ; CHECK: %eax = MOV32rm killed %rax, 1, _, 0, _, implicit-def %rax :: (load 4 from @G)
+  ; CHECK: %ecx = MOV32rm killed %rcx, 1, _, 0, _, implicit-def %rcx :: (load 4 from @0)
+    %eax = MOV32rm killed %rax, 1, _, 0, _, implicit-def %rax :: (load 4 from @G)
+    %rcx = MOV64rm %rip, 1, _, @0, _
+    %ecx = MOV32rm killed %rcx, 1, _, 0, _, implicit-def %rcx :: (load 4 from @0)
+    %eax = LEA64_32r killed %rax, 1, killed %rcx, 1, _
     RETQ %eax
 ...
 ---
@@ -421,9 +428,9 @@ body: |
   bb.0.entry:
     %rax = MOV64rm %rip, 1, _, @a, _ :: (load 8 from got)
   ; CHECK-LABEL: name: tbaa_metadata
-  ; CHECK:      %eax = MOV32rm killed %rax, 1, _, 0, _, implicit-def %rax :: (load 4 from %ir.a, !tbaa !2)
+  ; CHECK:      %eax = MOV32rm killed %rax, 1, _, 0, _, implicit-def %rax :: (load 4 from @a, !tbaa !2)
   ; CHECK-NEXT: %eax = MOV32rm killed %rax, 1, _, 0, _ :: (load 4 from %ir.total_len2, !tbaa !6)
-    %eax = MOV32rm killed %rax, 1, _, 0, _, implicit-def %rax :: (load 4 from %ir.a, !tbaa !2)
+    %eax = MOV32rm killed %rax, 1, _, 0, _, implicit-def %rax :: (load 4 from @a, !tbaa !2)
     %eax = MOV32rm killed %rax, 1, _, 0, _ :: (load 4 from %ir.total_len2, !tbaa !6)
     RETQ %eax
 ...




More information about the llvm-commits mailing list