[llvm-commits] CVS: llvm/lib/Target/ARM/ARMISelLowering.cpp ARMISelLowering.h

Evan Cheng evan.cheng at apple.com
Fri Mar 16 01:44:13 PDT 2007



Changes in directory llvm/lib/Target/ARM:

ARMISelLowering.cpp updated: 1.22 -> 1.23
ARMISelLowering.h updated: 1.3 -> 1.4
---
Log message:

Added isLegalAddressExpression(). Only allows X +/- C for now.

---
Diffs of the changes:  (+21 -0)

 ARMISelLowering.cpp |   15 +++++++++++++++
 ARMISelLowering.h   |    6 ++++++
 2 files changed, 21 insertions(+)


Index: llvm/lib/Target/ARM/ARMISelLowering.cpp
diff -u llvm/lib/Target/ARM/ARMISelLowering.cpp:1.22 llvm/lib/Target/ARM/ARMISelLowering.cpp:1.23
--- llvm/lib/Target/ARM/ARMISelLowering.cpp:1.22	Tue Mar 13 15:37:59 2007
+++ llvm/lib/Target/ARM/ARMISelLowering.cpp	Fri Mar 16 03:43:56 2007
@@ -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 @@
 //                           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: llvm/lib/Target/ARM/ARMISelLowering.h
diff -u llvm/lib/Target/ARM/ARMISelLowering.h:1.3 llvm/lib/Target/ARM/ARMISelLowering.h:1.4
--- llvm/lib/Target/ARM/ARMISelLowering.h:1.3	Mon Mar 12 18:30:29 2007
+++ llvm/lib/Target/ARM/ARMISelLowering.h	Fri Mar 16 03:43:56 2007
@@ -80,6 +80,12 @@
     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.






More information about the llvm-commits mailing list