MIR Serialization: Serialize the GOT pseudo source values.
authorAlex Lorenz <arphaman@gmail.com>
Wed, 12 Aug 2015 21:00:22 +0000 (21:00 +0000)
committerAlex Lorenz <arphaman@gmail.com>
Wed, 12 Aug 2015 21:00:22 +0000 (21:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244809 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 8a6a1ff817abba5397c7a5c2a97307cc3cec976d..950181bf17d125673820fe8448caf3dcf6952e21 100644 (file)
@@ -202,6 +202,7 @@ static MIToken::TokenKind getIdentifierKind(StringRef Identifier) {
       .Case("invariant", MIToken::kw_invariant)
       .Case("align", MIToken::kw_align)
       .Case("stack", MIToken::kw_stack)
+      .Case("got", MIToken::kw_got)
       .Case("constant-pool", MIToken::kw_constant_pool)
       .Case("liveout", MIToken::kw_liveout)
       .Default(MIToken::Identifier);
index 2c7a32cf508076ec37961b747b17de905ccc0eb1..beb38d0876fe2bdaa8d0bd17ec02f2d989dd6a8d 100644 (file)
@@ -71,6 +71,7 @@ struct MIToken {
     kw_invariant,
     kw_align,
     kw_stack,
+    kw_got,
     kw_constant_pool,
     kw_liveout,
 
index 47a9eaf14c33df1ad96c50530c22a2a5f64987eb..6dae29a58e3b2853a4aab3d4b25103c568b5bf4d 100644 (file)
@@ -1124,6 +1124,9 @@ bool MIParser::parseMemoryPseudoSourceValue(const PseudoSourceValue *&PSV) {
   case MIToken::kw_stack:
     PSV = MF.getPSVManager().getStack();
     break;
+  case MIToken::kw_got:
+    PSV = MF.getPSVManager().getGOT();
+    break;
   case MIToken::kw_constant_pool:
     PSV = MF.getPSVManager().getConstantPool();
     break;
@@ -1136,7 +1139,8 @@ bool MIParser::parseMemoryPseudoSourceValue(const PseudoSourceValue *&PSV) {
 }
 
 bool MIParser::parseMachinePointerInfo(MachinePointerInfo &Dest) {
-  if (Token.is(MIToken::kw_constant_pool) || Token.is(MIToken::kw_stack)) {
+  if (Token.is(MIToken::kw_constant_pool) || Token.is(MIToken::kw_stack) ||
+      Token.is(MIToken::kw_got)) {
     const PseudoSourceValue *PSV = nullptr;
     if (parseMemoryPseudoSourceValue(PSV))
       return true;
index 019383cc7cf03fe53164657f0aa70f82aa689534..83e7b3e5862a899fc097e5d21ddc9ecfb91e5888 100644 (file)
@@ -713,6 +713,9 @@ void MIPrinter::print(const MachineMemOperand &Op) {
     case PseudoSourceValue::Stack:
       OS << "stack";
       break;
+    case PseudoSourceValue::GOT:
+      OS << "got";
+      break;
     case PseudoSourceValue::ConstantPool:
       OS << "constant-pool";
       break;
index 289a5f6267fc2562a3970717a48b38ba20a979de..c95d6d459008bd8fe9854b7183c12f8491c38ff0 100644 (file)
 
   attributes #0 = { readonly }
 
+  @G = external global i32
+
+  define i32 @got_psv() {
+  entry:
+    %a = load i32, i32* @G
+    %b = add i32 %a, 1
+    ret i32 %b
+  }
+
 ...
 ---
 name:            test
@@ -246,3 +255,17 @@ body:
       - '%rsp = ADD64ri8 %rsp, 24, implicit-def dead %eflags'
       - RETQ
 ...
+---
+name:            got_psv
+tracksRegLiveness: true
+body:
+  - id:          0
+    name:        entry
+    instructions:
+# CHECK: name: got_psv
+# CHECK: %rax = MOV64rm %rip, 1, _, @G, _ :: (load 8 from got)
+      - '%rax = MOV64rm %rip, 1, _, @G, _ :: (load 8 from got)'
+      - '%eax = MOV32rm killed %rax, 1, _, 0, _'
+      - '%eax = INC32r killed %eax, implicit-def dead %eflags'
+      - 'RETQ %eax'
+...