summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2006-08-17 17:09:40 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2006-08-17 17:09:40 +0000
commitc3ed77e1b91354a0e54936f2a095d6186bff7133 (patch)
tree5b8b95e01a03644f9a31785005b0e3182960a412 /llvm/lib/Target
parent1c3210d08dbb73cf94e9db45c2b8de56208bc63e (diff)
downloadbcm5719-llvm-c3ed77e1b91354a0e54936f2a095d6186bff7133.tar.gz
bcm5719-llvm-c3ed77e1b91354a0e54936f2a095d6186bff7133.zip
add a "load effective address"
llvm-svn: 29748
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r--llvm/lib/Target/ARM/ARMAsmPrinter.cpp24
-rw-r--r--llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp5
-rw-r--r--llvm/lib/Target/ARM/ARMInstrInfo.td8
-rw-r--r--llvm/lib/Target/ARM/ARMRegisterInfo.cpp3
4 files changed, 30 insertions, 10 deletions
diff --git a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp
index d998fdff010..adf444d29a6 100644
--- a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp
+++ b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp
@@ -59,19 +59,27 @@ namespace {
return "ARM Assembly Printer";
}
- void printMemRegImm(const MachineInstr *MI, unsigned OpNo) {
- const MachineOperand &MO1 = MI->getOperand(OpNo);
- const MachineOperand &MO2 = MI->getOperand(OpNo + 1);
+ void printMemRegImm(const MachineInstr *MI, int opNum,
+ const char *Modifier = NULL) {
+ const MachineOperand &MO1 = MI->getOperand(opNum);
+ const MachineOperand &MO2 = MI->getOperand(opNum + 1);
assert(MO1.isImmediate());
+ bool arith = false;
+ if (Modifier != NULL) {
+ assert(strcmp(Modifier, "arith") == 0);
+ arith = true;
+ }
if (MO2.isConstantPoolIndex()) {
- printOperand(MI, OpNo + 1);
+ printOperand(MI, opNum + 1);
} else if (MO2.isRegister()) {
- O << '[';
- printOperand(MI, OpNo + 1);
+ if(!arith)
+ O << '[';
+ printOperand(MI, opNum + 1);
O << ", ";
- printOperand(MI, OpNo);
- O << ']';
+ printOperand(MI, opNum);
+ if(!arith)
+ O << ']';
} else {
assert(0 && "Invalid Operand Type");
}
diff --git a/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp b/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
index 80aaae54dab..56d61165c3c 100644
--- a/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
+++ b/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
@@ -358,6 +358,11 @@ static bool isInt12Immediate(SDOperand Op, short &Imm) {
//register plus/minus 12 bit offset
bool ARMDAGToDAGISel::SelectAddrRegImm(SDOperand N, SDOperand &Offset,
SDOperand &Base) {
+ if (FrameIndexSDNode *FIN = dyn_cast<FrameIndexSDNode>(N)) {
+ Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), MVT::i32);
+ Offset = CurDAG->getTargetConstant(0, MVT::i32);
+ return true;
+ }
if (N.getOpcode() == ISD::ADD) {
short imm = 0;
if (isInt12Immediate(N.getOperand(1), imm)) {
diff --git a/llvm/lib/Target/ARM/ARMInstrInfo.td b/llvm/lib/Target/ARM/ARMInstrInfo.td
index cc6377eabde..8619a80a3b9 100644
--- a/llvm/lib/Target/ARM/ARMInstrInfo.td
+++ b/llvm/lib/Target/ARM/ARMInstrInfo.td
@@ -21,7 +21,7 @@ def memri : Operand<iPTR> {
// Define ARM specific addressing mode.
//register plus/minus 12 bit offset
-def iaddr : ComplexPattern<iPTR, 2, "SelectAddrRegImm", []>;
+def iaddr : ComplexPattern<iPTR, 2, "SelectAddrRegImm", [frameindex]>;
//register plus scaled register
//def raddr : ComplexPattern<iPTR, 2, "SelectAddrRegReg", []>;
@@ -83,6 +83,12 @@ def addri : InstARM<(ops IntRegs:$dst, IntRegs:$a, i32imm:$b),
"add $dst, $a, $b",
[(set IntRegs:$dst, (add IntRegs:$a, imm:$b))]>;
+// "LEA" forms of add
+def lea_addri : InstARM<(ops IntRegs:$dst, memri:$addr),
+ "add $dst, ${addr:arith}",
+ [(set IntRegs:$dst, iaddr:$addr)]>;
+
+
def subri : InstARM<(ops IntRegs:$dst, IntRegs:$a, i32imm:$b),
"sub $dst, $a, $b",
[(set IntRegs:$dst, (sub IntRegs:$a, imm:$b))]>;
diff --git a/llvm/lib/Target/ARM/ARMRegisterInfo.cpp b/llvm/lib/Target/ARM/ARMRegisterInfo.cpp
index a9c30c40c7e..c5eef119520 100644
--- a/llvm/lib/Target/ARM/ARMRegisterInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMRegisterInfo.cpp
@@ -89,7 +89,8 @@ ARMRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II) const {
MachineFunction &MF = *MBB.getParent();
assert (MI.getOpcode() == ARM::ldr ||
- MI.getOpcode() == ARM::str);
+ MI.getOpcode() == ARM::str ||
+ MI.getOpcode() == ARM::lea_addri);
unsigned FrameIdx = 2;
unsigned OffIdx = 1;
OpenPOWER on IntegriCloud