[PATCH] D70953: Allow negative offsets in MipsMCInstLower::LowerOperand

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 4 03:39:34 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rG39b534da1880: Allow negative offsets in MipsMCInstLower::LowerOperand (authored by Alex Richardson <Alexander.Richardson at cl.cam.ac.uk>).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70953/new/

https://reviews.llvm.org/D70953

Files:
  llvm/lib/Target/Mips/MipsMCInstLower.cpp
  llvm/lib/Target/Mips/MipsMCInstLower.h


Index: llvm/lib/Target/Mips/MipsMCInstLower.h
===================================================================
--- llvm/lib/Target/Mips/MipsMCInstLower.h
+++ llvm/lib/Target/Mips/MipsMCInstLower.h
@@ -35,11 +35,11 @@
 
   void Initialize(MCContext *C);
   void Lower(const MachineInstr *MI, MCInst &OutMI) const;
-  MCOperand LowerOperand(const MachineOperand& MO, unsigned offset = 0) const;
+  MCOperand LowerOperand(const MachineOperand &MO, int64_t offset = 0) const;
 
 private:
   MCOperand LowerSymbolOperand(const MachineOperand &MO,
-                               MachineOperandType MOTy, unsigned Offset) const;
+                               MachineOperandType MOTy, int64_t Offset) const;
   MCOperand createSub(MachineBasicBlock *BB1, MachineBasicBlock *BB2,
                       MipsMCExpr::MipsExprKind Kind) const;
   void lowerLongBranchLUi(const MachineInstr *MI, MCInst &OutMI) const;
Index: llvm/lib/Target/Mips/MipsMCInstLower.cpp
===================================================================
--- llvm/lib/Target/Mips/MipsMCInstLower.cpp
+++ llvm/lib/Target/Mips/MipsMCInstLower.cpp
@@ -34,7 +34,7 @@
 
 MCOperand MipsMCInstLower::LowerSymbolOperand(const MachineOperand &MO,
                                               MachineOperandType MOTy,
-                                              unsigned Offset) const {
+                                              int64_t Offset) const {
   MCSymbolRefExpr::VariantKind Kind = MCSymbolRefExpr::VK_None;
   MipsMCExpr::MipsExprKind TargetKind = MipsMCExpr::MEK_None;
   bool IsGpOff = false;
@@ -161,9 +161,7 @@
   const MCExpr *Expr = MCSymbolRefExpr::create(Symbol, Kind, *Ctx);
 
   if (Offset) {
-    // Assume offset is never negative.
-    assert(Offset > 0);
-
+    // Note: Offset can also be negative
     Expr = MCBinaryExpr::createAdd(Expr, MCConstantExpr::create(Offset, *Ctx),
                                    *Ctx);
   }
@@ -177,7 +175,7 @@
 }
 
 MCOperand MipsMCInstLower::LowerOperand(const MachineOperand &MO,
-                                        unsigned offset) const {
+                                        int64_t offset) const {
   MachineOperandType MOTy = MO.getType();
 
   switch (MOTy) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70953.232076.patch
Type: text/x-patch
Size: 2211 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191204/ef76d9ef/attachment.bin>


More information about the llvm-commits mailing list