summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2007-03-16 08:43:56 +0000
committerEvan Cheng <evan.cheng@apple.com>2007-03-16 08:43:56 +0000
commit0e34d6af6b2171f111c7d6d178e5e2a9ee372404 (patch)
treeb2c60bc31625a0ad07c6b714fbe013ad3164cd61 /llvm/lib/Target
parenta2a2fd1e55af7a8fb66fd328e9e9746e2a818ea2 (diff)
downloadbcm5719-llvm-0e34d6af6b2171f111c7d6d178e5e2a9ee372404.tar.gz
bcm5719-llvm-0e34d6af6b2171f111c7d6d178e5e2a9ee372404.zip
Added isLegalAddressExpression(). Only allows X +/- C for now.
llvm-svn: 35122
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r--llvm/lib/Target/ARM/ARMISelLowering.cpp15
-rw-r--r--llvm/lib/Target/ARM/ARMISelLowering.h6
2 files changed, 21 insertions, 0 deletions
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp
index f23d8aeb37e..40ede7409ac 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -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.
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.h b/llvm/lib/Target/ARM/ARMISelLowering.h
index 7feb2c3ef7b..47bd4b2f1a4 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.h
+++ b/llvm/lib/Target/ARM/ARMISelLowering.h
@@ -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.
OpenPOWER on IntegriCloud