MIR Serialization: Change syntax for the call entry pseudo source values.
authorAlex Lorenz <arphaman@gmail.com>
Thu, 20 Aug 2015 00:12:57 +0000 (00:12 +0000)
committerAlex Lorenz <arphaman@gmail.com>
Thu, 20 Aug 2015 00:12:57 +0000 (00:12 +0000)
The global IR values in machine memory operands should use the global value
'@<name>' syntax instead of the current '%ir.<name>' syntax.

However, the global value call entry pseudo source values use the global value
syntax already. Therefore, the syntax for the call entry pseudo source values
has to be changed so that the global values and call entry global value PSVs
can be parsed without ambiguities.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245526 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/Mips/expected-global-value-or-symbol-after-call-entry.mir [new file with mode: 0644]
test/CodeGen/MIR/Mips/memory-operands.mir

index 6094ca996bf6fb7db10ba51bdf3d133f320170d1..8346ff294e466a70811b7246557c4df6cf3ea5e4 100644 (file)
@@ -220,6 +220,7 @@ static MIToken::TokenKind getIdentifierKind(StringRef Identifier) {
       .Case("got", MIToken::kw_got)
       .Case("jump-table", MIToken::kw_jump_table)
       .Case("constant-pool", MIToken::kw_constant_pool)
+      .Case("call-entry", MIToken::kw_call_entry)
       .Case("liveout", MIToken::kw_liveout)
       .Case("address-taken", MIToken::kw_address_taken)
       .Case("landing-pad", MIToken::kw_landing_pad)
index 17ddc4d5c1adfc59ce93b86d9d1935fe12b15ba2..35c526be8120f5138d9ee3b0149c74ad17471be7 100644 (file)
@@ -81,6 +81,7 @@ struct MIToken {
     kw_got,
     kw_jump_table,
     kw_constant_pool,
+    kw_call_entry,
     kw_liveout,
     kw_address_taken,
     kw_landing_pad,
index 80f6a654b97316df43bed18633104a24a162ba04..3260249d95bd1bd474cb8c3317922183c279d18a 100644 (file)
@@ -1605,18 +1605,27 @@ bool MIParser::parseMemoryPseudoSourceValue(const PseudoSourceValue *&PSV) {
     // The token was already consumed, so use return here instead of break.
     return false;
   }
-  case MIToken::GlobalValue:
-  case MIToken::NamedGlobalValue: {
-    GlobalValue *GV = nullptr;
-    if (parseGlobalValue(GV))
-      return true;
-    PSV = MF.getPSVManager().getGlobalValueCallEntry(GV);
+  case MIToken::kw_call_entry: {
+    lex();
+    switch (Token.kind()) {
+    case MIToken::GlobalValue:
+    case MIToken::NamedGlobalValue: {
+      GlobalValue *GV = nullptr;
+      if (parseGlobalValue(GV))
+        return true;
+      PSV = MF.getPSVManager().getGlobalValueCallEntry(GV);
+      break;
+    }
+    case MIToken::ExternalSymbol:
+      PSV = MF.getPSVManager().getExternalSymbolCallEntry(
+          MF.createExternalSymbolName(Token.stringValue()));
+      break;
+    default:
+      return error(
+          "expected a global value or an external symbol after 'call-entry'");
+    }
     break;
   }
-  case MIToken::ExternalSymbol:
-    PSV = MF.getPSVManager().getExternalSymbolCallEntry(
-        MF.createExternalSymbolName(Token.stringValue()));
-    break;
   default:
     llvm_unreachable("The current token should be pseudo source value");
   }
@@ -1627,9 +1636,7 @@ bool MIParser::parseMemoryPseudoSourceValue(const PseudoSourceValue *&PSV) {
 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::ExternalSymbol)) {
+      Token.is(MIToken::FixedStackObject) || Token.is(MIToken::kw_call_entry)) {
     const PseudoSourceValue *PSV = nullptr;
     if (parseMemoryPseudoSourceValue(PSV))
       return true;
index 2440a4103d8f6381ca3207974cb3d32d51a10591..1be845f8b898fd4330942c888ebfa70c7740a392 100644 (file)
@@ -873,11 +873,12 @@ void MIPrinter::print(const MachineMemOperand &Op) {
           cast<FixedStackPseudoSourceValue>(PVal)->getFrameIndex());
       break;
     case PseudoSourceValue::GlobalValueCallEntry:
+      OS << "call-entry ";
       cast<GlobalValuePseudoSourceValue>(PVal)->getValue()->printAsOperand(
           OS, /*PrintType=*/false, MST);
       break;
     case PseudoSourceValue::ExternalSymbolCallEntry:
-      OS << '$';
+      OS << "call-entry $";
       printLLVMNameWithoutPrefix(
           OS, cast<ExternalSymbolPseudoSourceValue>(PVal)->getSymbol());
       break;
diff --git a/test/CodeGen/MIR/Mips/expected-global-value-or-symbol-after-call-entry.mir b/test/CodeGen/MIR/Mips/expected-global-value-or-symbol-after-call-entry.mir
new file mode 100644 (file)
index 0000000..4fba28a
--- /dev/null
@@ -0,0 +1,41 @@
+# RUN: not llc -march=mipsel -mcpu=mips16 -relocation-model=pic -start-after branch-folder -stop-after branch-folder -o /dev/null %s 2>&1 | FileCheck %s
+--- |
+  define i32 @test(i32 %a) {
+  entry:
+    %call = call i32 @foo(i32 %a)
+    ret i32 0
+  }
+
+  declare i32 @foo(i32)
+...
+---
+name:            test
+tracksRegLiveness: true
+liveins:
+  - { reg: '%a0' }
+frameInfo:
+  stackSize:       24
+  maxAlignment:    4
+  adjustsStack:    true
+  hasCalls:        true
+  maxCallFrameSize: 16
+stack:
+  - { id: 0, type: spill-slot, offset: -4, size: 4, alignment: 4,
+      callee-saved-register: '%ra' }
+body: |
+  bb.0.entry:
+    liveins: %a0, %ra
+
+    Save16 %ra, 24, implicit-def %sp, implicit %sp
+    %v0, %v1 = GotPrologue16 $_gp_disp, $_gp_disp
+    %v0 = SllX16 killed %v0, 16
+    %v0 = AdduRxRyRz16 killed %v1, killed %v0
+  ; CHECK: [[@LINE+1]]:67: expected a global value or an external symbol after 'call-entry'
+    %v1 = LwRxRyOffMemX16 %v0, @foo, 0 :: (load 4 from call-entry foo)
+    %t9 = COPY %v1
+    %gp = COPY killed %v0
+    JumpLinkReg16 killed %v1, csr_o32, implicit-def %ra, implicit killed %t9, implicit %a0, implicit killed %gp, implicit-def %sp, implicit-def dead %v0
+    %v0 = LiRxImmX16 0
+    %ra = Restore16 24, implicit-def %sp, implicit %sp
+    RetRA16 implicit %v0
+...
index 965cda37812067642224960602ff7a7143075192..d45b41a9061b5951b82653edb0a638634c50d02f 100644 (file)
@@ -50,8 +50,8 @@ body:             |
     %v0 = SllX16 killed %v0, 16
     %v0 = AdduRxRyRz16 killed %v1, killed %v0
   ; CHECK-LABEL: name: test
-  ; CHECK: %v1 = LwRxRyOffMemX16 %v0, @foo, 0 :: (load 4 from @foo)
-    %v1 = LwRxRyOffMemX16 %v0, @foo, 0 :: (load 4 from @foo)
+  ; CHECK: %v1 = LwRxRyOffMemX16 %v0, @foo, 0 :: (load 4 from call-entry @foo)
+    %v1 = LwRxRyOffMemX16 %v0, @foo, 0 :: (load 4 from call-entry @foo)
     %t9 = COPY %v1
     %gp = COPY killed %v0
     JumpLinkReg16 killed %v1, csr_o32, implicit-def %ra, implicit killed %t9, implicit %a0, implicit killed %gp, implicit-def %sp, implicit-def dead %v0
@@ -87,13 +87,13 @@ body:             |
     %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)
+    %v0 = LwRxRyOffMemX16 %s0, @g, 0 :: (load 4 from call-entry @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)
+  ; CHECK: %v1 = LwRxRyOffMemX16 %s0, $__mips16_call_stub_sf_0, 0 :: (load 4 from call-entry $__mips16_call_stub_sf_0)
+    %v1 = LwRxRyOffMemX16 %s0, $__mips16_call_stub_sf_0, 0 :: (load 4 from call-entry $__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)
+    %v1 = LwRxRyOffMemX16 %s0, @__mips16_ret_sf, 0 :: (load 4 from call-entry @__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