[PATCH] D88386: [MIR][M68K] (Patch 2/8): Changes on Target-independent MIR part

Min-Yih Hsu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 27 17:06:26 PDT 2020


myhsu created this revision.
myhsu added reviewers: ab, fhahn.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
myhsu requested review of this revision.

1. Allow register to be pc-relative. Since many of the pc-relative address modes in M68K involve non-pc registers as operands.
2. Make `MachineBasicBlock::findDebugLoc` to work on reverse_iterator.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88386

Files:
  llvm/include/llvm/CodeGen/MachineBasicBlock.h
  llvm/lib/CodeGen/MachineBasicBlock.cpp
  llvm/lib/CodeGen/MachineVerifier.cpp


Index: llvm/lib/CodeGen/MachineVerifier.cpp
===================================================================
--- llvm/lib/CodeGen/MachineVerifier.cpp
+++ llvm/lib/CodeGen/MachineVerifier.cpp
@@ -1645,8 +1645,7 @@
       if (MCOI.OperandType == MCOI::OPERAND_REGISTER &&
           !MO->isReg() && !MO->isFI())
         report("Expected a register operand.", MO, MONum);
-      if ((MCOI.OperandType == MCOI::OPERAND_IMMEDIATE ||
-           MCOI.OperandType == MCOI::OPERAND_PCREL) && MO->isReg())
+      if (MCOI.OperandType == MCOI::OPERAND_IMMEDIATE && MO->isReg())
         report("Expected a non-register operand.", MO, MONum);
     }
 
Index: llvm/lib/CodeGen/MachineBasicBlock.cpp
===================================================================
--- llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -1335,6 +1335,13 @@
     return MBBI->getDebugLoc();
   return {};
 }
+DebugLoc
+MachineBasicBlock::rfindDebugLoc(reverse_instr_iterator MBBI) {
+  // Skip debug declarations, we don't want a DebugLoc from them.
+  MBBI = skipDebugInstructionsBackward(MBBI, instr_rbegin());
+  if (!MBBI->isDebugInstr()) return MBBI->getDebugLoc();
+  return {};
+}
 
 /// Find the previous valid DebugLoc preceding MBBI, skipping and DBG_VALUE
 /// instructions.  Return UnknownLoc if there is none.
@@ -1345,6 +1352,13 @@
   if (!MBBI->isDebugInstr()) return MBBI->getDebugLoc();
   return {};
 }
+DebugLoc MachineBasicBlock::rfindPrevDebugLoc(reverse_instr_iterator MBBI) {
+  // Skip debug declarations, we don't want a DebugLoc from them.
+  MBBI = skipDebugInstructionsForward(std::prev(MBBI), instr_rend());
+  if (MBBI != instr_rend())
+    return MBBI->getDebugLoc();
+  return {};
+}
 
 /// Find and return the merged DebugLoc of the branch instructions of the block.
 /// Return UnknownLoc if there is none.
Index: llvm/include/llvm/CodeGen/MachineBasicBlock.h
===================================================================
--- llvm/include/llvm/CodeGen/MachineBasicBlock.h
+++ llvm/include/llvm/CodeGen/MachineBasicBlock.h
@@ -837,6 +837,10 @@
   DebugLoc findDebugLoc(iterator MBBI) {
     return findDebugLoc(MBBI.getInstrIterator());
   }
+  DebugLoc rfindDebugLoc(reverse_instr_iterator MBBI);
+  DebugLoc rfindDebugLoc(reverse_iterator MBBI) {
+    return rfindDebugLoc(MBBI.getInstrIterator());
+  }
 
   /// Find the previous valid DebugLoc preceding MBBI, skipping and DBG_VALUE
   /// instructions.  Return UnknownLoc if there is none.
@@ -844,6 +848,10 @@
   DebugLoc findPrevDebugLoc(iterator MBBI) {
     return findPrevDebugLoc(MBBI.getInstrIterator());
   }
+  DebugLoc rfindPrevDebugLoc(reverse_instr_iterator MBBI);
+  DebugLoc rfindPrevDebugLoc(reverse_iterator MBBI) {
+    return rfindPrevDebugLoc(MBBI.getInstrIterator());
+  }
 
   /// Find and return the merged DebugLoc of the branch instructions of the
   /// block. Return UnknownLoc if there is none.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88386.294578.patch
Type: text/x-patch
Size: 2926 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200928/bf7929cc/attachment.bin>


More information about the llvm-commits mailing list