Added isLegalAddressExpression(). Only allows X +/- C for now.
authorEvan Cheng <evan.cheng@apple.com>
Fri, 16 Mar 2007 08:43:56 +0000 (08:43 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Fri, 16 Mar 2007 08:43:56 +0000 (08:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35122 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMISelLowering.cpp
lib/Target/ARM/ARMISelLowering.h

index f23d8aeb37eb447411e85732839e9b4de46e0caf..40ede7409aca8e2b396db11eb19362a2f9e3064c 100644 (file)
@@ -22,6 +22,7 @@
 #include "ARMTargetMachine.h"
 #include "llvm/CallingConv.h"
 #include "llvm/Constants.h"
+#include "llvm/Instruction.h"
 #include "llvm/CodeGen/MachineBasicBlock.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineFunction.h"
@@ -1269,6 +1270,20 @@ ARMTargetLowering::InsertAtEndOfBasicBlock(MachineInstr *MI,
 //                           ARM Optimization Hooks
 //===----------------------------------------------------------------------===//
 
+/// isLegalAddressExpression - Return true if the binary expression made up of
+/// specified opcode, operands, and type can be folded into target addressing
+/// mode for load / store of the given type.
+bool ARMTargetLowering::isLegalAddressExpression(unsigned Opc, Value *Op0,
+                                             Value *Op1, const Type *Ty) const {
+  if (ConstantInt *Op1C = dyn_cast<ConstantInt>(Op1)) {
+    if (Opc == Instruction::Add)
+      return isLegalAddressImmediate(Op1C->getSExtValue(), Ty);
+    if (Opc == Instruction::Sub)
+      return isLegalAddressImmediate(-Op1C->getSExtValue(), Ty);
+  }
+  return false;
+}
+
 /// isLegalAddressImmediate - Return true if the integer value can be used
 /// as the offset of the target addressing mode for load / store of the
 /// given type.
index 7feb2c3ef7b7b7de550f69180f736c9addd19154..47bd4b2f1a42a891d5860a6bf69aaa301d5f4086 100644 (file)
@@ -80,6 +80,12 @@ namespace llvm {
     virtual MachineBasicBlock *InsertAtEndOfBasicBlock(MachineInstr *MI,
                                                        MachineBasicBlock *MBB);
 
+    /// isLegalAddressExpression - Return true if the binary expression made up
+    /// of specified opcode, operands, and type can be folded into target
+    /// addressing mode for load / store of the given type.
+    virtual bool isLegalAddressExpression(unsigned Opc, Value *Op0, Value *Op1,
+                                          const Type *Ty) const;
+
     /// isLegalAddressImmediate - Return true if the integer value can be used
     /// as the offset of the target addressing mode for load / store of the
     /// given type.