MIR Serialization: Serialize the external symbol call entry pseudo source
authorAlex Lorenz <arphaman@gmail.com>
Fri, 14 Aug 2015 21:14:50 +0000 (21:14 +0000)
committerAlex Lorenz <arphaman@gmail.com>
Fri, 14 Aug 2015 21:14:50 +0000 (21:14 +0000)
values.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245098 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/PseudoSourceValue.h
lib/CodeGen/MIRParser/MIParser.cpp
lib/CodeGen/MIRPrinter.cpp
test/CodeGen/MIR/Mips/memory-operands.mir

index e6b95235e414ee37189ef275a0b1e51b1fb83a7b..f67552030db4fb43db7f785848d9e6a510fa3c3e 100644 (file)
@@ -132,6 +132,10 @@ class ExternalSymbolPseudoSourceValue : public CallEntryPseudoSourceValue {
 public:
   ExternalSymbolPseudoSourceValue(const char *ES);
 
+  static inline bool classof(const PseudoSourceValue *V) {
+    return V->kind() == ExternalSymbolCallEntry;
+  }
+
   const char *getSymbol() const { return ES; }
 };
 
index 31046b91cf8ba15dc38d6f7ebf9a1eae00b6b09f..b27a55b705d66051bdc260bfd23d60045c743083 100644 (file)
@@ -1445,7 +1445,10 @@ bool MIParser::parseMemoryPseudoSourceValue(const PseudoSourceValue *&PSV) {
     PSV = MF.getPSVManager().getGlobalValueCallEntry(GV);
     break;
   }
-  // TODO: Parse the other pseudo source values.
+  case MIToken::ExternalSymbol:
+    PSV = MF.getPSVManager().getExternalSymbolCallEntry(
+        MF.createExternalSymbolName(Token.stringValue()));
+    break;
   default:
     llvm_unreachable("The current token should be pseudo source value");
   }
@@ -1457,7 +1460,8 @@ bool MIParser::parseMachinePointerInfo(MachinePointerInfo &Dest) {
   if (Token.is(MIToken::kw_constant_pool) || Token.is(MIToken::kw_stack) ||
       Token.is(MIToken::kw_got) || Token.is(MIToken::kw_jump_table) ||
       Token.is(MIToken::FixedStackObject) || Token.is(MIToken::GlobalValue) ||
-      Token.is(MIToken::NamedGlobalValue)) {
+      Token.is(MIToken::NamedGlobalValue) ||
+      Token.is(MIToken::ExternalSymbol)) {
     const PseudoSourceValue *PSV = nullptr;
     if (parseMemoryPseudoSourceValue(PSV))
       return true;
index 7e546eb845f4c354c70489a00bd32eb757491b31..d70b5c412f167cde8da294344e1076069087f84f 100644 (file)
@@ -767,9 +767,10 @@ void MIPrinter::print(const MachineMemOperand &Op) {
       cast<GlobalValuePseudoSourceValue>(PVal)->getValue()->printAsOperand(
           OS, /*PrintType=*/false, MST);
       break;
-    default:
-      // TODO: Print the other pseudo source values.
-      OS << "<unserializable pseudo value>";
+    case PseudoSourceValue::ExternalSymbolCallEntry:
+      OS << '$';
+      printLLVMNameWithoutPrefix(
+          OS, cast<ExternalSymbolPseudoSourceValue>(PVal)->getSymbol());
       break;
     }
   }
index 9086ac1ff5de5e546e092fcf187e0131b02d8cab..965cda37812067642224960602ff7a7143075192 100644 (file)
   }
 
   declare i32 @foo(i32)
+
+  define float @test2() #0 {
+  entry:
+    %call = tail call float bitcast (float (...)* @g to float ()*)()
+    call void @__mips16_ret_sf(float %call)
+    ret float %call
+  }
+
+  declare float @g(...)
+
+  declare void @__mips16_ret_sf(float) #1
+
+  attributes #0 = { "saveS2" }
+  attributes #1 = { noinline readnone "__Mips16RetHelper" }
 ...
 ---
 name:            test
@@ -45,3 +59,44 @@ body:             |
     %ra = Restore16 24, implicit-def %sp, implicit %sp
     RetRA16 implicit %v0
 ...
+---
+name:            test2
+tracksRegLiveness: true
+frameInfo:
+  stackSize:       32
+  maxAlignment:    4
+  adjustsStack:    true
+  hasCalls:        true
+  maxCallFrameSize: 16
+stack:
+  - { id: 0, type: spill-slot, offset: -4, size: 4, alignment: 4,
+      callee-saved-register: '%ra' }
+  - { id: 1, type: spill-slot, offset: -8, size: 4, alignment: 4,
+      callee-saved-register: '%s2' }
+  - { id: 2, type: spill-slot, offset: -12, size: 4, alignment: 4,
+      callee-saved-register: '%s0' }
+body:             |
+  bb.0.entry:
+    liveins: %ra, %s2, %s0, %ra, %s2, %s0
+
+    SaveX16 %s0, %ra, %s2, 32, implicit-def %sp, implicit %sp
+    CFI_INSTRUCTION .cfi_def_cfa_offset 32
+    CFI_INSTRUCTION .cfi_offset %ra_64, -4
+    CFI_INSTRUCTION .cfi_offset %s2_64, -8
+    CFI_INSTRUCTION .cfi_offset %s0_64, -12
+    %v0, %v1 = GotPrologue16 $_gp_disp, $_gp_disp
+    %v0 = SllX16 killed %v0, 16
+    %s0 = AdduRxRyRz16 killed %v1, killed %v0
+    %v0 = LwRxRyOffMemX16 %s0, @g, 0 :: (load 4 from @g)
+  ; CHECK-LABEL: test2
+  ; CHECK: %v1 = LwRxRyOffMemX16 %s0, $__mips16_call_stub_sf_0, 0 :: (load 4 from $__mips16_call_stub_sf_0)
+    %v1 = LwRxRyOffMemX16 %s0, $__mips16_call_stub_sf_0, 0 :: (load 4 from $__mips16_call_stub_sf_0)
+    %gp = COPY %s0
+    JumpLinkReg16 killed %v1, csr_o32, implicit-def %ra, implicit %v0, implicit killed %gp, implicit-def %sp, implicit-def %v0
+    %v1 = LwRxRyOffMemX16 %s0, @__mips16_ret_sf, 0 :: (load 4 from @__mips16_ret_sf)
+    %t9 = COPY %v1
+    %gp = COPY killed %s0
+    JumpLinkReg16 killed %v1, csr_mips16rethelper, implicit-def %ra, implicit killed %t9, implicit %v0, implicit killed %gp, implicit-def %sp
+    %s0, %ra, %s2 = RestoreX16 32, implicit-def %sp, implicit %sp
+    RetRA16 implicit %v0
+...