2006-05-14 22:18:28 +00:00
|
|
|
//===-- ARMISelDAGToDAG.cpp - A dag to dag inst selector for ARM ----------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:36:04 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2006-05-14 22:18:28 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines an instruction selector for the ARM target.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "ARM.h"
|
2008-12-10 21:54:21 +00:00
|
|
|
#include "ARMAddressingModes.h"
|
|
|
|
#include "ARMConstantPoolValue.h"
|
2007-01-19 07:51:42 +00:00
|
|
|
#include "ARMISelLowering.h"
|
2006-05-14 22:18:28 +00:00
|
|
|
#include "ARMTargetMachine.h"
|
2006-07-16 01:02:57 +00:00
|
|
|
#include "llvm/CallingConv.h"
|
2007-01-19 07:51:42 +00:00
|
|
|
#include "llvm/Constants.h"
|
2006-05-14 22:18:28 +00:00
|
|
|
#include "llvm/DerivedTypes.h"
|
|
|
|
#include "llvm/Function.h"
|
|
|
|
#include "llvm/Intrinsics.h"
|
2009-07-14 23:09:55 +00:00
|
|
|
#include "llvm/LLVMContext.h"
|
2006-05-14 22:18:28 +00:00
|
|
|
#include "llvm/CodeGen/MachineFrameInfo.h"
|
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
|
|
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
|
|
|
#include "llvm/CodeGen/SelectionDAG.h"
|
|
|
|
#include "llvm/CodeGen/SelectionDAGISel.h"
|
|
|
|
#include "llvm/Target/TargetLowering.h"
|
2007-05-03 00:32:00 +00:00
|
|
|
#include "llvm/Target/TargetOptions.h"
|
2008-02-03 05:43:57 +00:00
|
|
|
#include "llvm/Support/Compiler.h"
|
2006-05-14 22:18:28 +00:00
|
|
|
#include "llvm/Support/Debug.h"
|
2009-07-08 20:53:28 +00:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
|
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
|
2006-05-14 22:18:28 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
2009-06-22 23:27:02 +00:00
|
|
|
static const unsigned arm_dsubreg_0 = 5;
|
|
|
|
static const unsigned arm_dsubreg_1 = 6;
|
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
/// ARMDAGToDAGISel - ARM specific code to select ARM machine
|
|
|
|
/// instructions for SelectionDAG operations.
|
|
|
|
///
|
2006-05-14 22:18:28 +00:00
|
|
|
namespace {
|
2007-01-19 07:51:42 +00:00
|
|
|
class ARMDAGToDAGISel : public SelectionDAGISel {
|
2009-06-26 21:28:53 +00:00
|
|
|
ARMBaseTargetMachine &TM;
|
2008-09-18 07:24:33 +00:00
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
/// Subtarget - Keep a pointer to the ARMSubtarget around so that we can
|
|
|
|
/// make the right decision when generating code for different targets.
|
|
|
|
const ARMSubtarget *Subtarget;
|
2006-10-10 12:56:00 +00:00
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
public:
|
2009-06-26 21:28:53 +00:00
|
|
|
explicit ARMDAGToDAGISel(ARMBaseTargetMachine &tm)
|
2009-01-15 19:20:50 +00:00
|
|
|
: SelectionDAGISel(tm), TM(tm),
|
2007-01-19 07:51:42 +00:00
|
|
|
Subtarget(&TM.getSubtarget<ARMSubtarget>()) {
|
2006-07-16 01:02:57 +00:00
|
|
|
}
|
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
virtual const char *getPassName() const {
|
|
|
|
return "ARM Instruction Selection";
|
2009-06-17 18:13:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// getI32Imm - Return a target constant with the specified value, of type i32.
|
|
|
|
inline SDValue getI32Imm(unsigned Imm) {
|
2009-08-10 22:56:29 +00:00
|
|
|
return CurDAG->getTargetConstant(Imm, EVT::i32);
|
2009-06-17 18:13:58 +00:00
|
|
|
}
|
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
SDNode *Select(SDValue Op);
|
2008-08-23 02:25:05 +00:00
|
|
|
virtual void InstructionSelect();
|
2009-06-29 07:51:04 +00:00
|
|
|
bool SelectShifterOperandReg(SDValue Op, SDValue N, SDValue &A,
|
|
|
|
SDValue &B, SDValue &C);
|
2008-07-27 21:46:04 +00:00
|
|
|
bool SelectAddrMode2(SDValue Op, SDValue N, SDValue &Base,
|
|
|
|
SDValue &Offset, SDValue &Opc);
|
|
|
|
bool SelectAddrMode2Offset(SDValue Op, SDValue N,
|
|
|
|
SDValue &Offset, SDValue &Opc);
|
|
|
|
bool SelectAddrMode3(SDValue Op, SDValue N, SDValue &Base,
|
|
|
|
SDValue &Offset, SDValue &Opc);
|
|
|
|
bool SelectAddrMode3Offset(SDValue Op, SDValue N,
|
|
|
|
SDValue &Offset, SDValue &Opc);
|
2009-08-08 13:35:48 +00:00
|
|
|
bool SelectAddrMode4(SDValue Op, SDValue N, SDValue &Addr,
|
|
|
|
SDValue &Mode);
|
2008-07-27 21:46:04 +00:00
|
|
|
bool SelectAddrMode5(SDValue Op, SDValue N, SDValue &Base,
|
|
|
|
SDValue &Offset);
|
2009-07-01 23:16:05 +00:00
|
|
|
bool SelectAddrMode6(SDValue Op, SDValue N, SDValue &Addr, SDValue &Update,
|
|
|
|
SDValue &Opc);
|
2008-07-27 21:46:04 +00:00
|
|
|
|
|
|
|
bool SelectAddrModePC(SDValue Op, SDValue N, SDValue &Offset,
|
2009-07-01 23:16:05 +00:00
|
|
|
SDValue &Label);
|
2008-07-27 21:46:04 +00:00
|
|
|
|
|
|
|
bool SelectThumbAddrModeRR(SDValue Op, SDValue N, SDValue &Base,
|
|
|
|
SDValue &Offset);
|
|
|
|
bool SelectThumbAddrModeRI5(SDValue Op, SDValue N, unsigned Scale,
|
|
|
|
SDValue &Base, SDValue &OffImm,
|
|
|
|
SDValue &Offset);
|
|
|
|
bool SelectThumbAddrModeS1(SDValue Op, SDValue N, SDValue &Base,
|
|
|
|
SDValue &OffImm, SDValue &Offset);
|
|
|
|
bool SelectThumbAddrModeS2(SDValue Op, SDValue N, SDValue &Base,
|
|
|
|
SDValue &OffImm, SDValue &Offset);
|
|
|
|
bool SelectThumbAddrModeS4(SDValue Op, SDValue N, SDValue &Base,
|
|
|
|
SDValue &OffImm, SDValue &Offset);
|
|
|
|
bool SelectThumbAddrModeSP(SDValue Op, SDValue N, SDValue &Base,
|
|
|
|
SDValue &OffImm);
|
|
|
|
|
2009-06-27 02:26:13 +00:00
|
|
|
bool SelectT2ShifterOperandReg(SDValue Op, SDValue N,
|
|
|
|
SDValue &BaseReg, SDValue &Opc);
|
2009-06-29 07:51:04 +00:00
|
|
|
bool SelectT2AddrModeImm12(SDValue Op, SDValue N, SDValue &Base,
|
|
|
|
SDValue &OffImm);
|
|
|
|
bool SelectT2AddrModeImm8(SDValue Op, SDValue N, SDValue &Base,
|
|
|
|
SDValue &OffImm);
|
2009-07-02 07:28:31 +00:00
|
|
|
bool SelectT2AddrModeImm8Offset(SDValue Op, SDValue N,
|
|
|
|
SDValue &OffImm);
|
2009-06-30 22:50:01 +00:00
|
|
|
bool SelectT2AddrModeImm8s4(SDValue Op, SDValue N, SDValue &Base,
|
|
|
|
SDValue &OffImm);
|
2009-06-29 07:51:04 +00:00
|
|
|
bool SelectT2AddrModeSoReg(SDValue Op, SDValue N, SDValue &Base,
|
|
|
|
SDValue &OffReg, SDValue &ShImm);
|
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
// Include the pieces autogenerated from the target description.
|
|
|
|
#include "ARMGenDAGISel.inc"
|
2009-05-19 05:53:42 +00:00
|
|
|
|
|
|
|
private:
|
2009-07-02 07:28:31 +00:00
|
|
|
/// SelectARMIndexedLoad - Indexed (pre/post inc/dec) load matching code for
|
|
|
|
/// ARM.
|
2009-07-02 01:23:32 +00:00
|
|
|
SDNode *SelectARMIndexedLoad(SDValue Op);
|
2009-07-02 07:28:31 +00:00
|
|
|
SDNode *SelectT2IndexedLoad(SDValue Op);
|
|
|
|
|
2009-08-07 00:34:42 +00:00
|
|
|
/// SelectDYN_ALLOC - Select dynamic alloc for Thumb.
|
|
|
|
SDNode *SelectDYN_ALLOC(SDValue Op);
|
2009-07-02 01:23:32 +00:00
|
|
|
|
|
|
|
/// SelectInlineAsmMemoryOperand - Implement addressing mode selection for
|
|
|
|
/// inline asm expressions.
|
|
|
|
virtual bool SelectInlineAsmMemoryOperand(const SDValue &Op,
|
|
|
|
char ConstraintCode,
|
|
|
|
std::vector<SDValue> &OutOps);
|
2007-01-19 07:51:42 +00:00
|
|
|
};
|
2006-08-24 16:13:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-23 02:25:05 +00:00
|
|
|
void ARMDAGToDAGISel::InstructionSelect() {
|
2007-01-19 07:51:42 +00:00
|
|
|
DEBUG(BB->dump());
|
2006-12-05 17:37:31 +00:00
|
|
|
|
2008-10-27 21:56:29 +00:00
|
|
|
SelectRoot(*CurDAG);
|
2008-08-23 02:25:05 +00:00
|
|
|
CurDAG->RemoveDeadNodes();
|
2006-12-05 17:37:31 +00:00
|
|
|
}
|
|
|
|
|
2009-06-29 07:51:04 +00:00
|
|
|
bool ARMDAGToDAGISel::SelectShifterOperandReg(SDValue Op,
|
|
|
|
SDValue N,
|
|
|
|
SDValue &BaseReg,
|
|
|
|
SDValue &ShReg,
|
|
|
|
SDValue &Opc) {
|
|
|
|
ARM_AM::ShiftOpc ShOpcVal = ARM_AM::getShiftOpcForNode(N);
|
|
|
|
|
|
|
|
// Don't match base register only case. That is matched to a separate
|
|
|
|
// lower complexity pattern with explicit register operand.
|
|
|
|
if (ShOpcVal == ARM_AM::no_shift) return false;
|
2009-08-11 15:33:49 +00:00
|
|
|
|
2009-06-29 07:51:04 +00:00
|
|
|
BaseReg = N.getOperand(0);
|
|
|
|
unsigned ShImmVal = 0;
|
|
|
|
if (ConstantSDNode *RHS = dyn_cast<ConstantSDNode>(N.getOperand(1))) {
|
2009-08-10 22:56:29 +00:00
|
|
|
ShReg = CurDAG->getRegister(0, EVT::i32);
|
2009-06-29 07:51:04 +00:00
|
|
|
ShImmVal = RHS->getZExtValue() & 31;
|
|
|
|
} else {
|
|
|
|
ShReg = N.getOperand(1);
|
|
|
|
}
|
|
|
|
Opc = CurDAG->getTargetConstant(ARM_AM::getSORegOpc(ShOpcVal, ShImmVal),
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT::i32);
|
2009-06-29 07:51:04 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
bool ARMDAGToDAGISel::SelectAddrMode2(SDValue Op, SDValue N,
|
|
|
|
SDValue &Base, SDValue &Offset,
|
|
|
|
SDValue &Opc) {
|
2007-03-13 21:05:54 +00:00
|
|
|
if (N.getOpcode() == ISD::MUL) {
|
|
|
|
if (ConstantSDNode *RHS = dyn_cast<ConstantSDNode>(N.getOperand(1))) {
|
|
|
|
// X * [3,5,9] -> X + X * [2,4,8] etc.
|
2008-09-12 16:56:44 +00:00
|
|
|
int RHSC = (int)RHS->getZExtValue();
|
2007-03-13 21:05:54 +00:00
|
|
|
if (RHSC & 1) {
|
|
|
|
RHSC = RHSC & ~1;
|
|
|
|
ARM_AM::AddrOpc AddSub = ARM_AM::add;
|
|
|
|
if (RHSC < 0) {
|
|
|
|
AddSub = ARM_AM::sub;
|
|
|
|
RHSC = - RHSC;
|
|
|
|
}
|
|
|
|
if (isPowerOf2_32(RHSC)) {
|
|
|
|
unsigned ShAmt = Log2_32(RHSC);
|
|
|
|
Base = Offset = N.getOperand(0);
|
|
|
|
Opc = CurDAG->getTargetConstant(ARM_AM::getAM2Opc(AddSub, ShAmt,
|
|
|
|
ARM_AM::lsl),
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT::i32);
|
2007-03-13 21:05:54 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
if (N.getOpcode() != ISD::ADD && N.getOpcode() != ISD::SUB) {
|
|
|
|
Base = N;
|
|
|
|
if (N.getOpcode() == ISD::FrameIndex) {
|
|
|
|
int FI = cast<FrameIndexSDNode>(N)->getIndex();
|
|
|
|
Base = CurDAG->getTargetFrameIndex(FI, TLI.getPointerTy());
|
|
|
|
} else if (N.getOpcode() == ARMISD::Wrapper) {
|
|
|
|
Base = N.getOperand(0);
|
|
|
|
}
|
2009-08-10 22:56:29 +00:00
|
|
|
Offset = CurDAG->getRegister(0, EVT::i32);
|
2007-01-19 07:51:42 +00:00
|
|
|
Opc = CurDAG->getTargetConstant(ARM_AM::getAM2Opc(ARM_AM::add, 0,
|
|
|
|
ARM_AM::no_shift),
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT::i32);
|
2007-01-19 07:51:42 +00:00
|
|
|
return true;
|
2006-07-16 01:02:57 +00:00
|
|
|
}
|
2009-08-11 15:33:49 +00:00
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
// Match simple R +/- imm12 operands.
|
|
|
|
if (N.getOpcode() == ISD::ADD)
|
|
|
|
if (ConstantSDNode *RHS = dyn_cast<ConstantSDNode>(N.getOperand(1))) {
|
2008-09-12 16:56:44 +00:00
|
|
|
int RHSC = (int)RHS->getZExtValue();
|
2007-01-24 02:45:25 +00:00
|
|
|
if ((RHSC >= 0 && RHSC < 0x1000) ||
|
|
|
|
(RHSC < 0 && RHSC > -0x1000)) { // 12 bits.
|
2007-01-19 07:51:42 +00:00
|
|
|
Base = N.getOperand(0);
|
2007-01-24 02:45:25 +00:00
|
|
|
if (Base.getOpcode() == ISD::FrameIndex) {
|
|
|
|
int FI = cast<FrameIndexSDNode>(Base)->getIndex();
|
|
|
|
Base = CurDAG->getTargetFrameIndex(FI, TLI.getPointerTy());
|
|
|
|
}
|
2009-08-10 22:56:29 +00:00
|
|
|
Offset = CurDAG->getRegister(0, EVT::i32);
|
2007-01-24 02:45:25 +00:00
|
|
|
|
|
|
|
ARM_AM::AddrOpc AddSub = ARM_AM::add;
|
|
|
|
if (RHSC < 0) {
|
|
|
|
AddSub = ARM_AM::sub;
|
|
|
|
RHSC = - RHSC;
|
|
|
|
}
|
|
|
|
Opc = CurDAG->getTargetConstant(ARM_AM::getAM2Opc(AddSub, RHSC,
|
2007-01-19 07:51:42 +00:00
|
|
|
ARM_AM::no_shift),
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT::i32);
|
2007-01-19 07:51:42 +00:00
|
|
|
return true;
|
2006-10-05 16:48:49 +00:00
|
|
|
}
|
|
|
|
}
|
2009-08-11 15:33:49 +00:00
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
// Otherwise this is R +/- [possibly shifted] R
|
|
|
|
ARM_AM::AddrOpc AddSub = N.getOpcode() == ISD::ADD ? ARM_AM::add:ARM_AM::sub;
|
|
|
|
ARM_AM::ShiftOpc ShOpcVal = ARM_AM::getShiftOpcForNode(N.getOperand(1));
|
|
|
|
unsigned ShAmt = 0;
|
2009-08-11 15:33:49 +00:00
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
Base = N.getOperand(0);
|
|
|
|
Offset = N.getOperand(1);
|
2009-08-11 15:33:49 +00:00
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
if (ShOpcVal != ARM_AM::no_shift) {
|
|
|
|
// Check to see if the RHS of the shift is a constant, if not, we can't fold
|
|
|
|
// it.
|
|
|
|
if (ConstantSDNode *Sh =
|
|
|
|
dyn_cast<ConstantSDNode>(N.getOperand(1).getOperand(1))) {
|
2008-09-12 16:56:44 +00:00
|
|
|
ShAmt = Sh->getZExtValue();
|
2007-01-19 07:51:42 +00:00
|
|
|
Offset = N.getOperand(1).getOperand(0);
|
2006-10-06 12:50:22 +00:00
|
|
|
} else {
|
2007-01-19 07:51:42 +00:00
|
|
|
ShOpcVal = ARM_AM::no_shift;
|
2006-10-06 12:50:22 +00:00
|
|
|
}
|
2006-10-05 16:48:49 +00:00
|
|
|
}
|
2009-08-11 15:33:49 +00:00
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
// Try matching (R shl C) + (R).
|
|
|
|
if (N.getOpcode() == ISD::ADD && ShOpcVal == ARM_AM::no_shift) {
|
|
|
|
ShOpcVal = ARM_AM::getShiftOpcForNode(N.getOperand(0));
|
|
|
|
if (ShOpcVal != ARM_AM::no_shift) {
|
|
|
|
// Check to see if the RHS of the shift is a constant, if not, we can't
|
|
|
|
// fold it.
|
|
|
|
if (ConstantSDNode *Sh =
|
|
|
|
dyn_cast<ConstantSDNode>(N.getOperand(0).getOperand(1))) {
|
2008-09-12 16:56:44 +00:00
|
|
|
ShAmt = Sh->getZExtValue();
|
2007-01-19 07:51:42 +00:00
|
|
|
Offset = N.getOperand(0).getOperand(0);
|
|
|
|
Base = N.getOperand(1);
|
|
|
|
} else {
|
|
|
|
ShOpcVal = ARM_AM::no_shift;
|
2006-10-13 16:47:22 +00:00
|
|
|
}
|
|
|
|
}
|
2006-07-25 20:17:20 +00:00
|
|
|
}
|
2009-08-11 15:33:49 +00:00
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
Opc = CurDAG->getTargetConstant(ARM_AM::getAM2Opc(AddSub, ShAmt, ShOpcVal),
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT::i32);
|
2007-01-19 07:51:42 +00:00
|
|
|
return true;
|
2006-05-14 22:18:28 +00:00
|
|
|
}
|
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
bool ARMDAGToDAGISel::SelectAddrMode2Offset(SDValue Op, SDValue N,
|
|
|
|
SDValue &Offset, SDValue &Opc) {
|
2007-01-19 07:51:42 +00:00
|
|
|
unsigned Opcode = Op.getOpcode();
|
|
|
|
ISD::MemIndexedMode AM = (Opcode == ISD::LOAD)
|
|
|
|
? cast<LoadSDNode>(Op)->getAddressingMode()
|
|
|
|
: cast<StoreSDNode>(Op)->getAddressingMode();
|
|
|
|
ARM_AM::AddrOpc AddSub = (AM == ISD::PRE_INC || AM == ISD::POST_INC)
|
|
|
|
? ARM_AM::add : ARM_AM::sub;
|
|
|
|
if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(N)) {
|
2008-09-12 16:56:44 +00:00
|
|
|
int Val = (int)C->getZExtValue();
|
2007-01-19 07:51:42 +00:00
|
|
|
if (Val >= 0 && Val < 0x1000) { // 12 bits.
|
2009-08-10 22:56:29 +00:00
|
|
|
Offset = CurDAG->getRegister(0, EVT::i32);
|
2007-01-19 07:51:42 +00:00
|
|
|
Opc = CurDAG->getTargetConstant(ARM_AM::getAM2Opc(AddSub, Val,
|
|
|
|
ARM_AM::no_shift),
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT::i32);
|
2007-01-19 07:51:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
2006-06-05 22:26:14 +00:00
|
|
|
}
|
2006-10-02 19:30:56 +00:00
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
Offset = N;
|
|
|
|
ARM_AM::ShiftOpc ShOpcVal = ARM_AM::getShiftOpcForNode(N);
|
|
|
|
unsigned ShAmt = 0;
|
|
|
|
if (ShOpcVal != ARM_AM::no_shift) {
|
|
|
|
// Check to see if the RHS of the shift is a constant, if not, we can't fold
|
|
|
|
// it.
|
|
|
|
if (ConstantSDNode *Sh = dyn_cast<ConstantSDNode>(N.getOperand(1))) {
|
2008-09-12 16:56:44 +00:00
|
|
|
ShAmt = Sh->getZExtValue();
|
2007-01-19 07:51:42 +00:00
|
|
|
Offset = N.getOperand(0);
|
2006-10-02 19:30:56 +00:00
|
|
|
} else {
|
2007-01-19 07:51:42 +00:00
|
|
|
ShOpcVal = ARM_AM::no_shift;
|
2006-09-04 19:05:01 +00:00
|
|
|
}
|
2006-05-14 22:18:28 +00:00
|
|
|
}
|
2006-06-05 22:26:14 +00:00
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
Opc = CurDAG->getTargetConstant(ARM_AM::getAM2Opc(AddSub, ShAmt, ShOpcVal),
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT::i32);
|
2007-01-19 07:51:42 +00:00
|
|
|
return true;
|
2006-05-14 22:18:28 +00:00
|
|
|
}
|
|
|
|
|
2006-08-01 12:58:43 +00:00
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
bool ARMDAGToDAGISel::SelectAddrMode3(SDValue Op, SDValue N,
|
|
|
|
SDValue &Base, SDValue &Offset,
|
|
|
|
SDValue &Opc) {
|
2007-01-19 07:51:42 +00:00
|
|
|
if (N.getOpcode() == ISD::SUB) {
|
|
|
|
// X - C is canonicalize to X + -C, no need to handle it here.
|
|
|
|
Base = N.getOperand(0);
|
|
|
|
Offset = N.getOperand(1);
|
2009-08-10 22:56:29 +00:00
|
|
|
Opc = CurDAG->getTargetConstant(ARM_AM::getAM3Opc(ARM_AM::sub, 0),EVT::i32);
|
2007-01-19 07:51:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
2009-08-11 15:33:49 +00:00
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
if (N.getOpcode() != ISD::ADD) {
|
|
|
|
Base = N;
|
|
|
|
if (N.getOpcode() == ISD::FrameIndex) {
|
|
|
|
int FI = cast<FrameIndexSDNode>(N)->getIndex();
|
|
|
|
Base = CurDAG->getTargetFrameIndex(FI, TLI.getPointerTy());
|
2007-01-12 20:35:49 +00:00
|
|
|
}
|
2009-08-10 22:56:29 +00:00
|
|
|
Offset = CurDAG->getRegister(0, EVT::i32);
|
|
|
|
Opc = CurDAG->getTargetConstant(ARM_AM::getAM3Opc(ARM_AM::add, 0),EVT::i32);
|
2007-01-19 07:51:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
2009-08-11 15:33:49 +00:00
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
// If the RHS is +/- imm8, fold into addr mode.
|
|
|
|
if (ConstantSDNode *RHS = dyn_cast<ConstantSDNode>(N.getOperand(1))) {
|
2008-09-12 16:56:44 +00:00
|
|
|
int RHSC = (int)RHS->getZExtValue();
|
2007-01-24 02:45:25 +00:00
|
|
|
if ((RHSC >= 0 && RHSC < 256) ||
|
|
|
|
(RHSC < 0 && RHSC > -256)) { // note -256 itself isn't allowed.
|
2007-01-19 07:51:42 +00:00
|
|
|
Base = N.getOperand(0);
|
2007-01-24 02:45:25 +00:00
|
|
|
if (Base.getOpcode() == ISD::FrameIndex) {
|
|
|
|
int FI = cast<FrameIndexSDNode>(Base)->getIndex();
|
|
|
|
Base = CurDAG->getTargetFrameIndex(FI, TLI.getPointerTy());
|
|
|
|
}
|
2009-08-10 22:56:29 +00:00
|
|
|
Offset = CurDAG->getRegister(0, EVT::i32);
|
2007-01-24 02:45:25 +00:00
|
|
|
|
|
|
|
ARM_AM::AddrOpc AddSub = ARM_AM::add;
|
|
|
|
if (RHSC < 0) {
|
|
|
|
AddSub = ARM_AM::sub;
|
|
|
|
RHSC = - RHSC;
|
|
|
|
}
|
2009-08-10 22:56:29 +00:00
|
|
|
Opc = CurDAG->getTargetConstant(ARM_AM::getAM3Opc(AddSub, RHSC),EVT::i32);
|
2007-01-19 07:51:42 +00:00
|
|
|
return true;
|
2007-01-12 20:35:49 +00:00
|
|
|
}
|
|
|
|
}
|
2009-08-11 15:33:49 +00:00
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
Base = N.getOperand(0);
|
|
|
|
Offset = N.getOperand(1);
|
2009-08-10 22:56:29 +00:00
|
|
|
Opc = CurDAG->getTargetConstant(ARM_AM::getAM3Opc(ARM_AM::add, 0), EVT::i32);
|
2007-01-19 07:51:42 +00:00
|
|
|
return true;
|
2007-01-12 20:35:49 +00:00
|
|
|
}
|
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
bool ARMDAGToDAGISel::SelectAddrMode3Offset(SDValue Op, SDValue N,
|
|
|
|
SDValue &Offset, SDValue &Opc) {
|
2007-01-19 07:51:42 +00:00
|
|
|
unsigned Opcode = Op.getOpcode();
|
|
|
|
ISD::MemIndexedMode AM = (Opcode == ISD::LOAD)
|
|
|
|
? cast<LoadSDNode>(Op)->getAddressingMode()
|
|
|
|
: cast<StoreSDNode>(Op)->getAddressingMode();
|
|
|
|
ARM_AM::AddrOpc AddSub = (AM == ISD::PRE_INC || AM == ISD::POST_INC)
|
|
|
|
? ARM_AM::add : ARM_AM::sub;
|
|
|
|
if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(N)) {
|
2008-09-12 16:56:44 +00:00
|
|
|
int Val = (int)C->getZExtValue();
|
2007-01-19 07:51:42 +00:00
|
|
|
if (Val >= 0 && Val < 256) {
|
2009-08-10 22:56:29 +00:00
|
|
|
Offset = CurDAG->getRegister(0, EVT::i32);
|
|
|
|
Opc = CurDAG->getTargetConstant(ARM_AM::getAM3Opc(AddSub, Val), EVT::i32);
|
2007-01-19 07:51:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
2007-01-12 20:35:49 +00:00
|
|
|
}
|
2006-08-01 12:58:43 +00:00
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
Offset = N;
|
2009-08-10 22:56:29 +00:00
|
|
|
Opc = CurDAG->getTargetConstant(ARM_AM::getAM3Opc(AddSub, 0), EVT::i32);
|
2007-01-19 07:51:42 +00:00
|
|
|
return true;
|
2006-08-25 17:55:16 +00:00
|
|
|
}
|
|
|
|
|
2009-08-08 13:35:48 +00:00
|
|
|
bool ARMDAGToDAGISel::SelectAddrMode4(SDValue Op, SDValue N,
|
|
|
|
SDValue &Addr, SDValue &Mode) {
|
|
|
|
Addr = N;
|
2009-08-10 22:56:29 +00:00
|
|
|
Mode = CurDAG->getTargetConstant(0, EVT::i32);
|
2009-08-08 13:35:48 +00:00
|
|
|
return true;
|
|
|
|
}
|
2006-10-05 16:48:49 +00:00
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
bool ARMDAGToDAGISel::SelectAddrMode5(SDValue Op, SDValue N,
|
|
|
|
SDValue &Base, SDValue &Offset) {
|
2007-01-19 07:51:42 +00:00
|
|
|
if (N.getOpcode() != ISD::ADD) {
|
|
|
|
Base = N;
|
|
|
|
if (N.getOpcode() == ISD::FrameIndex) {
|
|
|
|
int FI = cast<FrameIndexSDNode>(N)->getIndex();
|
|
|
|
Base = CurDAG->getTargetFrameIndex(FI, TLI.getPointerTy());
|
|
|
|
} else if (N.getOpcode() == ARMISD::Wrapper) {
|
|
|
|
Base = N.getOperand(0);
|
2006-10-05 16:48:49 +00:00
|
|
|
}
|
2007-01-19 07:51:42 +00:00
|
|
|
Offset = CurDAG->getTargetConstant(ARM_AM::getAM5Opc(ARM_AM::add, 0),
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT::i32);
|
2007-01-19 07:51:42 +00:00
|
|
|
return true;
|
2006-05-23 02:48:20 +00:00
|
|
|
}
|
2009-08-11 15:33:49 +00:00
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
// If the RHS is +/- imm8, fold into addr mode.
|
|
|
|
if (ConstantSDNode *RHS = dyn_cast<ConstantSDNode>(N.getOperand(1))) {
|
2008-09-12 16:56:44 +00:00
|
|
|
int RHSC = (int)RHS->getZExtValue();
|
2007-01-19 07:51:42 +00:00
|
|
|
if ((RHSC & 3) == 0) { // The constant is implicitly multiplied by 4.
|
|
|
|
RHSC >>= 2;
|
2007-01-24 02:45:25 +00:00
|
|
|
if ((RHSC >= 0 && RHSC < 256) ||
|
|
|
|
(RHSC < 0 && RHSC > -256)) { // note -256 itself isn't allowed.
|
2007-01-19 07:51:42 +00:00
|
|
|
Base = N.getOperand(0);
|
2007-01-24 02:45:25 +00:00
|
|
|
if (Base.getOpcode() == ISD::FrameIndex) {
|
|
|
|
int FI = cast<FrameIndexSDNode>(Base)->getIndex();
|
|
|
|
Base = CurDAG->getTargetFrameIndex(FI, TLI.getPointerTy());
|
|
|
|
}
|
|
|
|
|
|
|
|
ARM_AM::AddrOpc AddSub = ARM_AM::add;
|
|
|
|
if (RHSC < 0) {
|
|
|
|
AddSub = ARM_AM::sub;
|
|
|
|
RHSC = - RHSC;
|
|
|
|
}
|
|
|
|
Offset = CurDAG->getTargetConstant(ARM_AM::getAM5Opc(AddSub, RHSC),
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT::i32);
|
2007-01-19 07:51:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
2006-08-25 17:55:16 +00:00
|
|
|
}
|
|
|
|
}
|
2009-08-11 15:33:49 +00:00
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
Base = N;
|
|
|
|
Offset = CurDAG->getTargetConstant(ARM_AM::getAM5Opc(ARM_AM::add, 0),
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT::i32);
|
2007-01-19 07:51:42 +00:00
|
|
|
return true;
|
2006-12-14 18:58:37 +00:00
|
|
|
}
|
|
|
|
|
2009-07-01 23:16:05 +00:00
|
|
|
bool ARMDAGToDAGISel::SelectAddrMode6(SDValue Op, SDValue N,
|
|
|
|
SDValue &Addr, SDValue &Update,
|
|
|
|
SDValue &Opc) {
|
|
|
|
Addr = N;
|
|
|
|
// The optional writeback is handled in ARMLoadStoreOpt.
|
2009-08-10 22:56:29 +00:00
|
|
|
Update = CurDAG->getRegister(0, EVT::i32);
|
|
|
|
Opc = CurDAG->getTargetConstant(ARM_AM::getAM6Opc(false), EVT::i32);
|
2009-07-01 23:16:05 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
bool ARMDAGToDAGISel::SelectAddrModePC(SDValue Op, SDValue N,
|
|
|
|
SDValue &Offset, SDValue &Label) {
|
2007-01-19 07:51:42 +00:00
|
|
|
if (N.getOpcode() == ARMISD::PIC_ADD && N.hasOneUse()) {
|
|
|
|
Offset = N.getOperand(0);
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue N1 = N.getOperand(1);
|
2008-09-12 16:56:44 +00:00
|
|
|
Label = CurDAG->getTargetConstant(cast<ConstantSDNode>(N1)->getZExtValue(),
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT::i32);
|
2007-01-19 07:51:42 +00:00
|
|
|
return true;
|
2006-12-14 18:58:37 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
bool ARMDAGToDAGISel::SelectThumbAddrModeRR(SDValue Op, SDValue N,
|
|
|
|
SDValue &Base, SDValue &Offset){
|
2009-02-06 19:16:40 +00:00
|
|
|
// FIXME dl should come from the parent load or store, not the address
|
|
|
|
DebugLoc dl = Op.getDebugLoc();
|
2007-01-23 22:59:13 +00:00
|
|
|
if (N.getOpcode() != ISD::ADD) {
|
2009-07-11 07:08:13 +00:00
|
|
|
ConstantSDNode *NC = dyn_cast<ConstantSDNode>(N);
|
|
|
|
if (!NC || NC->getZExtValue() != 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
Base = Offset = N;
|
2007-01-23 22:59:13 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
Base = N.getOperand(0);
|
|
|
|
Offset = N.getOperand(1);
|
|
|
|
return true;
|
2006-12-14 18:58:37 +00:00
|
|
|
}
|
|
|
|
|
2007-01-24 02:21:22 +00:00
|
|
|
bool
|
2008-07-27 21:46:04 +00:00
|
|
|
ARMDAGToDAGISel::SelectThumbAddrModeRI5(SDValue Op, SDValue N,
|
|
|
|
unsigned Scale, SDValue &Base,
|
|
|
|
SDValue &OffImm, SDValue &Offset) {
|
2007-01-24 02:21:22 +00:00
|
|
|
if (Scale == 4) {
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue TmpBase, TmpOffImm;
|
2007-01-24 02:21:22 +00:00
|
|
|
if (SelectThumbAddrModeSP(Op, N, TmpBase, TmpOffImm))
|
|
|
|
return false; // We want to select tLDRspi / tSTRspi instead.
|
2007-01-24 08:53:17 +00:00
|
|
|
if (N.getOpcode() == ARMISD::Wrapper &&
|
|
|
|
N.getOperand(0).getOpcode() == ISD::TargetConstantPool)
|
|
|
|
return false; // We want to select tLDRpci instead.
|
2007-01-24 02:21:22 +00:00
|
|
|
}
|
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
if (N.getOpcode() != ISD::ADD) {
|
|
|
|
Base = (N.getOpcode() == ARMISD::Wrapper) ? N.getOperand(0) : N;
|
2009-08-10 22:56:29 +00:00
|
|
|
Offset = CurDAG->getRegister(0, EVT::i32);
|
|
|
|
OffImm = CurDAG->getTargetConstant(0, EVT::i32);
|
2007-01-19 07:51:42 +00:00
|
|
|
return true;
|
2006-12-31 18:52:39 +00:00
|
|
|
}
|
2006-08-21 22:00:32 +00:00
|
|
|
|
2007-02-06 00:22:06 +00:00
|
|
|
// Thumb does not have [sp, r] address mode.
|
|
|
|
RegisterSDNode *LHSR = dyn_cast<RegisterSDNode>(N.getOperand(0));
|
|
|
|
RegisterSDNode *RHSR = dyn_cast<RegisterSDNode>(N.getOperand(1));
|
|
|
|
if ((LHSR && LHSR->getReg() == ARM::SP) ||
|
|
|
|
(RHSR && RHSR->getReg() == ARM::SP)) {
|
|
|
|
Base = N;
|
2009-08-10 22:56:29 +00:00
|
|
|
Offset = CurDAG->getRegister(0, EVT::i32);
|
|
|
|
OffImm = CurDAG->getTargetConstant(0, EVT::i32);
|
2007-02-06 00:22:06 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
// If the RHS is + imm5 * scale, fold into addr mode.
|
|
|
|
if (ConstantSDNode *RHS = dyn_cast<ConstantSDNode>(N.getOperand(1))) {
|
2008-09-12 16:56:44 +00:00
|
|
|
int RHSC = (int)RHS->getZExtValue();
|
2007-01-19 07:51:42 +00:00
|
|
|
if ((RHSC & (Scale-1)) == 0) { // The constant is implicitly multiplied.
|
|
|
|
RHSC /= Scale;
|
|
|
|
if (RHSC >= 0 && RHSC < 32) {
|
|
|
|
Base = N.getOperand(0);
|
2009-08-10 22:56:29 +00:00
|
|
|
Offset = CurDAG->getRegister(0, EVT::i32);
|
|
|
|
OffImm = CurDAG->getTargetConstant(RHSC, EVT::i32);
|
2007-01-19 07:51:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2006-12-31 18:52:39 +00:00
|
|
|
}
|
2006-08-24 13:45:55 +00:00
|
|
|
|
2007-01-23 22:59:13 +00:00
|
|
|
Base = N.getOperand(0);
|
|
|
|
Offset = N.getOperand(1);
|
2009-08-10 22:56:29 +00:00
|
|
|
OffImm = CurDAG->getTargetConstant(0, EVT::i32);
|
2007-01-23 22:59:13 +00:00
|
|
|
return true;
|
2006-05-14 22:18:28 +00:00
|
|
|
}
|
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
bool ARMDAGToDAGISel::SelectThumbAddrModeS1(SDValue Op, SDValue N,
|
|
|
|
SDValue &Base, SDValue &OffImm,
|
|
|
|
SDValue &Offset) {
|
2007-01-30 02:35:32 +00:00
|
|
|
return SelectThumbAddrModeRI5(Op, N, 1, Base, OffImm, Offset);
|
2006-05-14 22:18:28 +00:00
|
|
|
}
|
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
bool ARMDAGToDAGISel::SelectThumbAddrModeS2(SDValue Op, SDValue N,
|
|
|
|
SDValue &Base, SDValue &OffImm,
|
|
|
|
SDValue &Offset) {
|
2007-01-30 02:35:32 +00:00
|
|
|
return SelectThumbAddrModeRI5(Op, N, 2, Base, OffImm, Offset);
|
2006-08-14 19:01:24 +00:00
|
|
|
}
|
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
bool ARMDAGToDAGISel::SelectThumbAddrModeS4(SDValue Op, SDValue N,
|
|
|
|
SDValue &Base, SDValue &OffImm,
|
|
|
|
SDValue &Offset) {
|
2007-01-30 02:35:32 +00:00
|
|
|
return SelectThumbAddrModeRI5(Op, N, 4, Base, OffImm, Offset);
|
2006-08-14 19:01:24 +00:00
|
|
|
}
|
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
bool ARMDAGToDAGISel::SelectThumbAddrModeSP(SDValue Op, SDValue N,
|
|
|
|
SDValue &Base, SDValue &OffImm) {
|
2007-01-19 07:51:42 +00:00
|
|
|
if (N.getOpcode() == ISD::FrameIndex) {
|
|
|
|
int FI = cast<FrameIndexSDNode>(N)->getIndex();
|
|
|
|
Base = CurDAG->getTargetFrameIndex(FI, TLI.getPointerTy());
|
2009-08-10 22:56:29 +00:00
|
|
|
OffImm = CurDAG->getTargetConstant(0, EVT::i32);
|
2006-09-13 12:09:43 +00:00
|
|
|
return true;
|
2006-09-11 17:25:40 +00:00
|
|
|
}
|
2007-01-24 02:21:22 +00:00
|
|
|
|
2007-02-06 00:22:06 +00:00
|
|
|
if (N.getOpcode() != ISD::ADD)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
RegisterSDNode *LHSR = dyn_cast<RegisterSDNode>(N.getOperand(0));
|
2007-02-06 09:11:20 +00:00
|
|
|
if (N.getOperand(0).getOpcode() == ISD::FrameIndex ||
|
|
|
|
(LHSR && LHSR->getReg() == ARM::SP)) {
|
2007-01-24 02:21:22 +00:00
|
|
|
// If the RHS is + imm8 * scale, fold into addr mode.
|
|
|
|
if (ConstantSDNode *RHS = dyn_cast<ConstantSDNode>(N.getOperand(1))) {
|
2008-09-12 16:56:44 +00:00
|
|
|
int RHSC = (int)RHS->getZExtValue();
|
2007-01-24 02:21:22 +00:00
|
|
|
if ((RHSC & 3) == 0) { // The constant is implicitly multiplied.
|
|
|
|
RHSC >>= 2;
|
|
|
|
if (RHSC >= 0 && RHSC < 256) {
|
2007-02-06 00:22:06 +00:00
|
|
|
Base = N.getOperand(0);
|
2007-02-06 09:11:20 +00:00
|
|
|
if (Base.getOpcode() == ISD::FrameIndex) {
|
|
|
|
int FI = cast<FrameIndexSDNode>(Base)->getIndex();
|
|
|
|
Base = CurDAG->getTargetFrameIndex(FI, TLI.getPointerTy());
|
|
|
|
}
|
2009-08-10 22:56:29 +00:00
|
|
|
OffImm = CurDAG->getTargetConstant(RHSC, EVT::i32);
|
2007-01-24 02:21:22 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-08-11 15:33:49 +00:00
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
return false;
|
2006-09-11 17:25:40 +00:00
|
|
|
}
|
|
|
|
|
2009-06-27 02:26:13 +00:00
|
|
|
bool ARMDAGToDAGISel::SelectT2ShifterOperandReg(SDValue Op, SDValue N,
|
|
|
|
SDValue &BaseReg,
|
|
|
|
SDValue &Opc) {
|
|
|
|
ARM_AM::ShiftOpc ShOpcVal = ARM_AM::getShiftOpcForNode(N);
|
|
|
|
|
|
|
|
// Don't match base register only case. That is matched to a separate
|
|
|
|
// lower complexity pattern with explicit register operand.
|
|
|
|
if (ShOpcVal == ARM_AM::no_shift) return false;
|
|
|
|
|
|
|
|
BaseReg = N.getOperand(0);
|
|
|
|
unsigned ShImmVal = 0;
|
|
|
|
if (ConstantSDNode *RHS = dyn_cast<ConstantSDNode>(N.getOperand(1))) {
|
|
|
|
ShImmVal = RHS->getZExtValue() & 31;
|
|
|
|
Opc = getI32Imm(ARM_AM::getSORegOpc(ShOpcVal, ShImmVal));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-06-29 07:51:04 +00:00
|
|
|
bool ARMDAGToDAGISel::SelectT2AddrModeImm12(SDValue Op, SDValue N,
|
|
|
|
SDValue &Base, SDValue &OffImm) {
|
|
|
|
// Match simple R + imm12 operands.
|
2009-07-20 15:55:39 +00:00
|
|
|
|
2009-08-11 08:52:18 +00:00
|
|
|
// Base only.
|
|
|
|
if (N.getOpcode() != ISD::ADD && N.getOpcode() != ISD::SUB) {
|
2009-07-20 15:55:39 +00:00
|
|
|
if (N.getOpcode() == ISD::FrameIndex) {
|
2009-08-11 08:52:18 +00:00
|
|
|
// Match frame index...
|
2009-07-20 15:55:39 +00:00
|
|
|
int FI = cast<FrameIndexSDNode>(N)->getIndex();
|
|
|
|
Base = CurDAG->getTargetFrameIndex(FI, TLI.getPointerTy());
|
2009-08-10 22:56:29 +00:00
|
|
|
OffImm = CurDAG->getTargetConstant(0, EVT::i32);
|
2009-07-20 15:55:39 +00:00
|
|
|
return true;
|
2009-08-11 08:52:18 +00:00
|
|
|
} else if (N.getOpcode() == ARMISD::Wrapper) {
|
|
|
|
Base = N.getOperand(0);
|
|
|
|
if (Base.getOpcode() == ISD::TargetConstantPool)
|
|
|
|
return false; // We want to select t2LDRpci instead.
|
|
|
|
} else
|
|
|
|
Base = N;
|
|
|
|
OffImm = CurDAG->getTargetConstant(0, EVT::i32);
|
|
|
|
return true;
|
2009-07-20 15:55:39 +00:00
|
|
|
}
|
2009-06-29 07:51:04 +00:00
|
|
|
|
|
|
|
if (ConstantSDNode *RHS = dyn_cast<ConstantSDNode>(N.getOperand(1))) {
|
2009-08-11 08:52:18 +00:00
|
|
|
if (SelectT2AddrModeImm8(Op, N, Base, OffImm))
|
|
|
|
// Let t2LDRi8 handle (R - imm8).
|
|
|
|
return false;
|
|
|
|
|
2009-06-29 07:51:04 +00:00
|
|
|
int RHSC = (int)RHS->getZExtValue();
|
2009-07-30 18:56:48 +00:00
|
|
|
if (N.getOpcode() == ISD::SUB)
|
|
|
|
RHSC = -RHSC;
|
|
|
|
|
|
|
|
if (RHSC >= 0 && RHSC < 0x1000) { // 12 bits (unsigned)
|
2009-06-29 07:51:04 +00:00
|
|
|
Base = N.getOperand(0);
|
2009-07-30 18:56:48 +00:00
|
|
|
if (Base.getOpcode() == ISD::FrameIndex) {
|
|
|
|
int FI = cast<FrameIndexSDNode>(Base)->getIndex();
|
|
|
|
Base = CurDAG->getTargetFrameIndex(FI, TLI.getPointerTy());
|
|
|
|
}
|
2009-08-10 22:56:29 +00:00
|
|
|
OffImm = CurDAG->getTargetConstant(RHSC, EVT::i32);
|
2009-06-29 07:51:04 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-11 08:52:18 +00:00
|
|
|
// Base only.
|
|
|
|
Base = N;
|
|
|
|
OffImm = CurDAG->getTargetConstant(0, EVT::i32);
|
|
|
|
return true;
|
2009-06-29 07:51:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ARMDAGToDAGISel::SelectT2AddrModeImm8(SDValue Op, SDValue N,
|
|
|
|
SDValue &Base, SDValue &OffImm) {
|
2009-07-30 18:56:48 +00:00
|
|
|
// Match simple R - imm8 operands.
|
2009-08-11 08:52:18 +00:00
|
|
|
if (N.getOpcode() == ISD::ADD || N.getOpcode() == ISD::SUB) {
|
2009-07-30 22:45:52 +00:00
|
|
|
if (ConstantSDNode *RHS = dyn_cast<ConstantSDNode>(N.getOperand(1))) {
|
|
|
|
int RHSC = (int)RHS->getSExtValue();
|
|
|
|
if (N.getOpcode() == ISD::SUB)
|
|
|
|
RHSC = -RHSC;
|
2009-08-11 15:33:49 +00:00
|
|
|
|
2009-08-11 08:52:18 +00:00
|
|
|
if ((RHSC >= -255) && (RHSC < 0)) { // 8 bits (always negative)
|
|
|
|
Base = N.getOperand(0);
|
2009-07-30 22:45:52 +00:00
|
|
|
if (Base.getOpcode() == ISD::FrameIndex) {
|
|
|
|
int FI = cast<FrameIndexSDNode>(Base)->getIndex();
|
|
|
|
Base = CurDAG->getTargetFrameIndex(FI, TLI.getPointerTy());
|
|
|
|
}
|
2009-08-10 22:56:29 +00:00
|
|
|
OffImm = CurDAG->getTargetConstant(RHSC, EVT::i32);
|
2009-07-30 22:45:52 +00:00
|
|
|
return true;
|
2009-06-29 07:51:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-07-02 07:28:31 +00:00
|
|
|
bool ARMDAGToDAGISel::SelectT2AddrModeImm8Offset(SDValue Op, SDValue N,
|
|
|
|
SDValue &OffImm){
|
|
|
|
unsigned Opcode = Op.getOpcode();
|
|
|
|
ISD::MemIndexedMode AM = (Opcode == ISD::LOAD)
|
|
|
|
? cast<LoadSDNode>(Op)->getAddressingMode()
|
|
|
|
: cast<StoreSDNode>(Op)->getAddressingMode();
|
|
|
|
if (ConstantSDNode *RHS = dyn_cast<ConstantSDNode>(N)) {
|
|
|
|
int RHSC = (int)RHS->getZExtValue();
|
|
|
|
if (RHSC >= 0 && RHSC < 0x100) { // 8 bits.
|
2009-07-14 21:29:29 +00:00
|
|
|
OffImm = ((AM == ISD::PRE_INC) || (AM == ISD::POST_INC))
|
2009-08-10 22:56:29 +00:00
|
|
|
? CurDAG->getTargetConstant(RHSC, EVT::i32)
|
|
|
|
: CurDAG->getTargetConstant(-RHSC, EVT::i32);
|
2009-07-02 07:28:31 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-06-30 22:50:01 +00:00
|
|
|
bool ARMDAGToDAGISel::SelectT2AddrModeImm8s4(SDValue Op, SDValue N,
|
|
|
|
SDValue &Base, SDValue &OffImm) {
|
|
|
|
if (N.getOpcode() == ISD::ADD) {
|
|
|
|
if (ConstantSDNode *RHS = dyn_cast<ConstantSDNode>(N.getOperand(1))) {
|
|
|
|
int RHSC = (int)RHS->getZExtValue();
|
2009-07-09 22:21:59 +00:00
|
|
|
if (((RHSC & 0x3) == 0) &&
|
|
|
|
((RHSC >= 0 && RHSC < 0x400) || (RHSC < 0 && RHSC > -0x400))) { // 8 bits.
|
2009-06-30 22:50:01 +00:00
|
|
|
Base = N.getOperand(0);
|
2009-08-10 22:56:29 +00:00
|
|
|
OffImm = CurDAG->getTargetConstant(RHSC, EVT::i32);
|
2009-06-30 22:50:01 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (N.getOpcode() == ISD::SUB) {
|
|
|
|
if (ConstantSDNode *RHS = dyn_cast<ConstantSDNode>(N.getOperand(1))) {
|
|
|
|
int RHSC = (int)RHS->getZExtValue();
|
|
|
|
if (((RHSC & 0x3) == 0) && (RHSC >= 0 && RHSC < 0x400)) { // 8 bits.
|
|
|
|
Base = N.getOperand(0);
|
2009-08-10 22:56:29 +00:00
|
|
|
OffImm = CurDAG->getTargetConstant(-RHSC, EVT::i32);
|
2009-06-30 22:50:01 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-06-29 07:51:04 +00:00
|
|
|
bool ARMDAGToDAGISel::SelectT2AddrModeSoReg(SDValue Op, SDValue N,
|
|
|
|
SDValue &Base,
|
|
|
|
SDValue &OffReg, SDValue &ShImm) {
|
2009-08-11 08:52:18 +00:00
|
|
|
// (R - imm8) should be handled by t2LDRi8. The rest are handled by t2LDRi12.
|
|
|
|
if (N.getOpcode() != ISD::ADD)
|
|
|
|
return false;
|
2009-06-29 07:51:04 +00:00
|
|
|
|
2009-08-11 08:52:18 +00:00
|
|
|
// Leave (R + imm12) for t2LDRi12, (R - imm8) for t2LDRi8.
|
|
|
|
if (ConstantSDNode *RHS = dyn_cast<ConstantSDNode>(N.getOperand(1))) {
|
|
|
|
int RHSC = (int)RHS->getZExtValue();
|
|
|
|
if (RHSC >= 0 && RHSC < 0x1000) // 12 bits (unsigned)
|
|
|
|
return false;
|
|
|
|
else if (RHSC < 0 && RHSC >= -255) // 8 bits
|
2009-07-30 18:56:48 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-06-29 07:51:04 +00:00
|
|
|
// Look for (R + R) or (R + (R << [1,2,3])).
|
|
|
|
unsigned ShAmt = 0;
|
|
|
|
Base = N.getOperand(0);
|
|
|
|
OffReg = N.getOperand(1);
|
|
|
|
|
|
|
|
// Swap if it is ((R << c) + R).
|
|
|
|
ARM_AM::ShiftOpc ShOpcVal = ARM_AM::getShiftOpcForNode(OffReg);
|
|
|
|
if (ShOpcVal != ARM_AM::lsl) {
|
|
|
|
ShOpcVal = ARM_AM::getShiftOpcForNode(Base);
|
|
|
|
if (ShOpcVal == ARM_AM::lsl)
|
|
|
|
std::swap(Base, OffReg);
|
2009-08-11 15:33:49 +00:00
|
|
|
}
|
|
|
|
|
2009-06-29 07:51:04 +00:00
|
|
|
if (ShOpcVal == ARM_AM::lsl) {
|
|
|
|
// Check to see if the RHS of the shift is a constant, if not, we can't fold
|
|
|
|
// it.
|
|
|
|
if (ConstantSDNode *Sh = dyn_cast<ConstantSDNode>(OffReg.getOperand(1))) {
|
|
|
|
ShAmt = Sh->getZExtValue();
|
|
|
|
if (ShAmt >= 4) {
|
|
|
|
ShAmt = 0;
|
|
|
|
ShOpcVal = ARM_AM::no_shift;
|
|
|
|
} else
|
|
|
|
OffReg = OffReg.getOperand(0);
|
|
|
|
} else {
|
|
|
|
ShOpcVal = ARM_AM::no_shift;
|
|
|
|
}
|
2009-07-15 15:50:19 +00:00
|
|
|
}
|
2009-08-11 15:33:49 +00:00
|
|
|
|
2009-08-10 22:56:29 +00:00
|
|
|
ShImm = CurDAG->getTargetConstant(ShAmt, EVT::i32);
|
2009-06-29 07:51:04 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
|
2007-07-05 07:15:27 +00:00
|
|
|
/// getAL - Returns a ARMCC::AL immediate node.
|
2008-07-27 21:46:04 +00:00
|
|
|
static inline SDValue getAL(SelectionDAG *CurDAG) {
|
2009-08-10 22:56:29 +00:00
|
|
|
return CurDAG->getTargetConstant((uint64_t)ARMCC::AL, EVT::i32);
|
2007-05-15 01:29:07 +00:00
|
|
|
}
|
|
|
|
|
2009-07-02 01:23:32 +00:00
|
|
|
SDNode *ARMDAGToDAGISel::SelectARMIndexedLoad(SDValue Op) {
|
|
|
|
LoadSDNode *LD = cast<LoadSDNode>(Op);
|
|
|
|
ISD::MemIndexedMode AM = LD->getAddressingMode();
|
|
|
|
if (AM == ISD::UNINDEXED)
|
|
|
|
return NULL;
|
|
|
|
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT LoadedVT = LD->getMemoryVT();
|
2009-07-02 01:23:32 +00:00
|
|
|
SDValue Offset, AMOpc;
|
|
|
|
bool isPre = (AM == ISD::PRE_INC) || (AM == ISD::PRE_DEC);
|
|
|
|
unsigned Opcode = 0;
|
|
|
|
bool Match = false;
|
2009-08-10 22:56:29 +00:00
|
|
|
if (LoadedVT == EVT::i32 &&
|
2009-07-02 01:23:32 +00:00
|
|
|
SelectAddrMode2Offset(Op, LD->getOffset(), Offset, AMOpc)) {
|
|
|
|
Opcode = isPre ? ARM::LDR_PRE : ARM::LDR_POST;
|
|
|
|
Match = true;
|
2009-08-10 22:56:29 +00:00
|
|
|
} else if (LoadedVT == EVT::i16 &&
|
2009-07-02 01:23:32 +00:00
|
|
|
SelectAddrMode3Offset(Op, LD->getOffset(), Offset, AMOpc)) {
|
|
|
|
Match = true;
|
|
|
|
Opcode = (LD->getExtensionType() == ISD::SEXTLOAD)
|
|
|
|
? (isPre ? ARM::LDRSH_PRE : ARM::LDRSH_POST)
|
|
|
|
: (isPre ? ARM::LDRH_PRE : ARM::LDRH_POST);
|
2009-08-10 22:56:29 +00:00
|
|
|
} else if (LoadedVT == EVT::i8 || LoadedVT == EVT::i1) {
|
2009-07-02 01:23:32 +00:00
|
|
|
if (LD->getExtensionType() == ISD::SEXTLOAD) {
|
|
|
|
if (SelectAddrMode3Offset(Op, LD->getOffset(), Offset, AMOpc)) {
|
|
|
|
Match = true;
|
|
|
|
Opcode = isPre ? ARM::LDRSB_PRE : ARM::LDRSB_POST;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (SelectAddrMode2Offset(Op, LD->getOffset(), Offset, AMOpc)) {
|
|
|
|
Match = true;
|
|
|
|
Opcode = isPre ? ARM::LDRB_PRE : ARM::LDRB_POST;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Match) {
|
|
|
|
SDValue Chain = LD->getChain();
|
|
|
|
SDValue Base = LD->getBasePtr();
|
|
|
|
SDValue Ops[]= { Base, Offset, AMOpc, getAL(CurDAG),
|
2009-08-10 22:56:29 +00:00
|
|
|
CurDAG->getRegister(0, EVT::i32), Chain };
|
|
|
|
return CurDAG->getTargetNode(Opcode, Op.getDebugLoc(), EVT::i32, EVT::i32,
|
|
|
|
EVT::Other, Ops, 6);
|
2009-07-02 01:23:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-07-02 07:28:31 +00:00
|
|
|
SDNode *ARMDAGToDAGISel::SelectT2IndexedLoad(SDValue Op) {
|
|
|
|
LoadSDNode *LD = cast<LoadSDNode>(Op);
|
|
|
|
ISD::MemIndexedMode AM = LD->getAddressingMode();
|
|
|
|
if (AM == ISD::UNINDEXED)
|
|
|
|
return NULL;
|
|
|
|
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT LoadedVT = LD->getMemoryVT();
|
2009-07-02 23:16:11 +00:00
|
|
|
bool isSExtLd = LD->getExtensionType() == ISD::SEXTLOAD;
|
2009-07-02 07:28:31 +00:00
|
|
|
SDValue Offset;
|
|
|
|
bool isPre = (AM == ISD::PRE_INC) || (AM == ISD::PRE_DEC);
|
|
|
|
unsigned Opcode = 0;
|
|
|
|
bool Match = false;
|
|
|
|
if (SelectT2AddrModeImm8Offset(Op, LD->getOffset(), Offset)) {
|
|
|
|
switch (LoadedVT.getSimpleVT()) {
|
2009-08-10 22:56:29 +00:00
|
|
|
case EVT::i32:
|
2009-07-02 07:28:31 +00:00
|
|
|
Opcode = isPre ? ARM::t2LDR_PRE : ARM::t2LDR_POST;
|
|
|
|
break;
|
2009-08-10 22:56:29 +00:00
|
|
|
case EVT::i16:
|
2009-07-02 23:16:11 +00:00
|
|
|
if (isSExtLd)
|
|
|
|
Opcode = isPre ? ARM::t2LDRSH_PRE : ARM::t2LDRSH_POST;
|
|
|
|
else
|
|
|
|
Opcode = isPre ? ARM::t2LDRH_PRE : ARM::t2LDRH_POST;
|
2009-07-02 07:28:31 +00:00
|
|
|
break;
|
2009-08-10 22:56:29 +00:00
|
|
|
case EVT::i8:
|
|
|
|
case EVT::i1:
|
2009-07-02 23:16:11 +00:00
|
|
|
if (isSExtLd)
|
|
|
|
Opcode = isPre ? ARM::t2LDRSB_PRE : ARM::t2LDRSB_POST;
|
|
|
|
else
|
|
|
|
Opcode = isPre ? ARM::t2LDRB_PRE : ARM::t2LDRB_POST;
|
2009-07-02 07:28:31 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
Match = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Match) {
|
|
|
|
SDValue Chain = LD->getChain();
|
|
|
|
SDValue Base = LD->getBasePtr();
|
|
|
|
SDValue Ops[]= { Base, Offset, getAL(CurDAG),
|
2009-08-10 22:56:29 +00:00
|
|
|
CurDAG->getRegister(0, EVT::i32), Chain };
|
|
|
|
return CurDAG->getTargetNode(Opcode, Op.getDebugLoc(), EVT::i32, EVT::i32,
|
|
|
|
EVT::Other, Ops, 5);
|
2009-07-02 07:28:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-08-07 00:34:42 +00:00
|
|
|
SDNode *ARMDAGToDAGISel::SelectDYN_ALLOC(SDValue Op) {
|
|
|
|
SDNode *N = Op.getNode();
|
|
|
|
DebugLoc dl = N->getDebugLoc();
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT VT = Op.getValueType();
|
2009-08-07 00:34:42 +00:00
|
|
|
SDValue Chain = Op.getOperand(0);
|
|
|
|
SDValue Size = Op.getOperand(1);
|
|
|
|
SDValue Align = Op.getOperand(2);
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue SP = CurDAG->getRegister(ARM::SP, EVT::i32);
|
2009-08-07 00:34:42 +00:00
|
|
|
int32_t AlignVal = cast<ConstantSDNode>(Align)->getSExtValue();
|
|
|
|
if (AlignVal < 0)
|
|
|
|
// We need to align the stack. Use Thumb1 tAND which is the only thumb
|
|
|
|
// instruction that can read and write SP. This matches to a pseudo
|
|
|
|
// instruction that has a chain to ensure the result is written back to
|
|
|
|
// the stack pointer.
|
|
|
|
SP = SDValue(CurDAG->getTargetNode(ARM::tANDsp, dl, VT, SP, Align), 0);
|
|
|
|
|
|
|
|
bool isC = isa<ConstantSDNode>(Size);
|
|
|
|
uint32_t C = isC ? cast<ConstantSDNode>(Size)->getZExtValue() : ~0UL;
|
|
|
|
// Handle the most common case for both Thumb1 and Thumb2:
|
|
|
|
// tSUBspi - immediate is between 0 ... 508 inclusive.
|
|
|
|
if (C <= 508 && ((C & 3) == 0))
|
|
|
|
// FIXME: tSUBspi encode scale 4 implicitly.
|
2009-08-10 22:56:29 +00:00
|
|
|
return CurDAG->SelectNodeTo(N, ARM::tSUBspi_, VT, EVT::Other, SP,
|
|
|
|
CurDAG->getTargetConstant(C/4, EVT::i32),
|
2009-08-07 00:34:42 +00:00
|
|
|
Chain);
|
|
|
|
|
|
|
|
if (Subtarget->isThumb1Only()) {
|
|
|
|
// Use tADDrSPr since Thumb1 does not have a sub r, sp, r. ARMISelLowering
|
|
|
|
// should have negated the size operand already. FIXME: We can't insert
|
|
|
|
// new target independent node at this stage so we are forced to negate
|
2009-08-11 15:33:49 +00:00
|
|
|
// it earlier. Is there a better solution?
|
2009-08-10 22:56:29 +00:00
|
|
|
return CurDAG->SelectNodeTo(N, ARM::tADDspr_, VT, EVT::Other, SP, Size,
|
2009-08-07 00:34:42 +00:00
|
|
|
Chain);
|
|
|
|
} else if (Subtarget->isThumb2()) {
|
|
|
|
if (isC && Predicate_t2_so_imm(Size.getNode())) {
|
|
|
|
// t2SUBrSPi
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue Ops[] = { SP, CurDAG->getTargetConstant(C, EVT::i32), Chain };
|
|
|
|
return CurDAG->SelectNodeTo(N, ARM::t2SUBrSPi_, VT, EVT::Other, Ops, 3);
|
2009-08-07 00:34:42 +00:00
|
|
|
} else if (isC && Predicate_imm0_4095(Size.getNode())) {
|
|
|
|
// t2SUBrSPi12
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue Ops[] = { SP, CurDAG->getTargetConstant(C, EVT::i32), Chain };
|
|
|
|
return CurDAG->SelectNodeTo(N, ARM::t2SUBrSPi12_, VT, EVT::Other, Ops, 3);
|
2009-08-07 00:34:42 +00:00
|
|
|
} else {
|
|
|
|
// t2SUBrSPs
|
|
|
|
SDValue Ops[] = { SP, Size,
|
|
|
|
getI32Imm(ARM_AM::getSORegOpc(ARM_AM::lsl,0)), Chain };
|
2009-08-10 22:56:29 +00:00
|
|
|
return CurDAG->SelectNodeTo(N, ARM::t2SUBrSPs_, VT, EVT::Other, Ops, 4);
|
2009-08-07 00:34:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME: Add ADD / SUB sp instructions for ARM.
|
|
|
|
return 0;
|
|
|
|
}
|
2006-10-17 18:04:53 +00:00
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
SDNode *ARMDAGToDAGISel::Select(SDValue Op) {
|
2008-08-28 21:40:38 +00:00
|
|
|
SDNode *N = Op.getNode();
|
2009-02-06 01:31:28 +00:00
|
|
|
DebugLoc dl = N->getDebugLoc();
|
2007-01-19 07:51:42 +00:00
|
|
|
|
2008-07-17 19:10:17 +00:00
|
|
|
if (N->isMachineOpcode())
|
2007-01-19 07:51:42 +00:00
|
|
|
return NULL; // Already selected.
|
2006-06-12 12:28:08 +00:00
|
|
|
|
|
|
|
switch (N->getOpcode()) {
|
2007-01-19 07:51:42 +00:00
|
|
|
default: break;
|
|
|
|
case ISD::Constant: {
|
2008-09-12 16:56:44 +00:00
|
|
|
unsigned Val = cast<ConstantSDNode>(N)->getZExtValue();
|
2007-01-19 07:51:42 +00:00
|
|
|
bool UseCP = true;
|
2009-06-22 17:29:13 +00:00
|
|
|
if (Subtarget->isThumb()) {
|
|
|
|
if (Subtarget->hasThumb2())
|
|
|
|
// Thumb2 has the MOVT instruction, so all immediates can
|
|
|
|
// be done with MOV + MOVT, at worst.
|
|
|
|
UseCP = 0;
|
|
|
|
else
|
|
|
|
UseCP = (Val > 255 && // MOV
|
|
|
|
~Val > 255 && // MOV + MVN
|
|
|
|
!ARM_AM::isThumbImmShiftedVal(Val)); // MOV + LSL
|
|
|
|
} else
|
2007-01-19 07:51:42 +00:00
|
|
|
UseCP = (ARM_AM::getSOImmVal(Val) == -1 && // MOV
|
|
|
|
ARM_AM::getSOImmVal(~Val) == -1 && // MVN
|
|
|
|
!ARM_AM::isSOImmTwoPartVal(Val)); // two instrs.
|
|
|
|
if (UseCP) {
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue CPIdx =
|
2009-07-24 23:12:02 +00:00
|
|
|
CurDAG->getTargetConstantPool(ConstantInt::get(Type::Int32Ty, Val),
|
2007-01-19 07:51:42 +00:00
|
|
|
TLI.getPointerTy());
|
2007-01-24 08:53:17 +00:00
|
|
|
|
|
|
|
SDNode *ResNode;
|
2009-07-11 06:43:01 +00:00
|
|
|
if (Subtarget->isThumb1Only()) {
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue Pred = CurDAG->getTargetConstant(0xEULL, EVT::i32);
|
|
|
|
SDValue PredReg = CurDAG->getRegister(0, EVT::i32);
|
2009-07-11 06:43:01 +00:00
|
|
|
SDValue Ops[] = { CPIdx, Pred, PredReg, CurDAG->getEntryNode() };
|
2009-08-10 22:56:29 +00:00
|
|
|
ResNode = CurDAG->getTargetNode(ARM::tLDRcp, dl, EVT::i32, EVT::Other,
|
2009-07-11 06:43:01 +00:00
|
|
|
Ops, 4);
|
|
|
|
} else {
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue Ops[] = {
|
2009-08-11 15:33:49 +00:00
|
|
|
CPIdx,
|
2009-08-10 22:56:29 +00:00
|
|
|
CurDAG->getRegister(0, EVT::i32),
|
|
|
|
CurDAG->getTargetConstant(0, EVT::i32),
|
2007-07-05 07:15:27 +00:00
|
|
|
getAL(CurDAG),
|
2009-08-10 22:56:29 +00:00
|
|
|
CurDAG->getRegister(0, EVT::i32),
|
2007-01-24 08:53:17 +00:00
|
|
|
CurDAG->getEntryNode()
|
|
|
|
};
|
2009-08-10 22:56:29 +00:00
|
|
|
ResNode=CurDAG->getTargetNode(ARM::LDRcp, dl, EVT::i32, EVT::Other,
|
2009-02-06 01:31:28 +00:00
|
|
|
Ops, 6);
|
2007-01-24 08:53:17 +00:00
|
|
|
}
|
2008-07-27 21:46:04 +00:00
|
|
|
ReplaceUses(Op, SDValue(ResNode, 0));
|
2007-01-19 07:51:42 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2009-08-11 15:33:49 +00:00
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
// Other cases are autogenerated.
|
2006-06-12 12:28:08 +00:00
|
|
|
break;
|
2007-01-19 07:51:42 +00:00
|
|
|
}
|
2006-11-09 13:58:55 +00:00
|
|
|
case ISD::FrameIndex: {
|
2007-01-19 07:51:42 +00:00
|
|
|
// Selects to ADDri FI, 0 which in turn will become ADDri SP, imm.
|
2006-11-09 13:58:55 +00:00
|
|
|
int FI = cast<FrameIndexSDNode>(N)->getIndex();
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue TFI = CurDAG->getTargetFrameIndex(FI, TLI.getPointerTy());
|
2009-07-08 23:10:31 +00:00
|
|
|
if (Subtarget->isThumb1Only()) {
|
2009-08-10 22:56:29 +00:00
|
|
|
return CurDAG->SelectNodeTo(N, ARM::tADDrSPi, EVT::i32, TFI,
|
|
|
|
CurDAG->getTargetConstant(0, EVT::i32));
|
2009-04-07 20:34:09 +00:00
|
|
|
} else {
|
2009-07-14 18:48:51 +00:00
|
|
|
unsigned Opc = ((Subtarget->isThumb() && Subtarget->hasThumb2()) ?
|
|
|
|
ARM::t2ADDri : ARM::ADDri);
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue Ops[] = { TFI, CurDAG->getTargetConstant(0, EVT::i32),
|
|
|
|
getAL(CurDAG), CurDAG->getRegister(0, EVT::i32),
|
|
|
|
CurDAG->getRegister(0, EVT::i32) };
|
|
|
|
return CurDAG->SelectNodeTo(N, Opc, EVT::i32, Ops, 5);
|
2007-07-05 07:15:27 +00:00
|
|
|
}
|
2007-01-19 07:51:42 +00:00
|
|
|
}
|
2009-08-07 00:34:42 +00:00
|
|
|
case ARMISD::DYN_ALLOC:
|
|
|
|
return SelectDYN_ALLOC(Op);
|
2007-01-19 07:51:42 +00:00
|
|
|
case ISD::MUL:
|
2009-07-07 01:17:28 +00:00
|
|
|
if (Subtarget->isThumb1Only())
|
2007-01-24 02:21:22 +00:00
|
|
|
break;
|
2007-01-19 07:51:42 +00:00
|
|
|
if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(Op.getOperand(1))) {
|
2008-09-12 16:56:44 +00:00
|
|
|
unsigned RHSV = C->getZExtValue();
|
2007-01-19 07:51:42 +00:00
|
|
|
if (!RHSV) break;
|
|
|
|
if (isPowerOf2_32(RHSV-1)) { // 2^n+1?
|
2009-07-21 00:31:12 +00:00
|
|
|
unsigned ShImm = Log2_32(RHSV-1);
|
|
|
|
if (ShImm >= 32)
|
|
|
|
break;
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue V = Op.getOperand(0);
|
2009-07-21 00:31:12 +00:00
|
|
|
ShImm = ARM_AM::getSORegOpc(ARM_AM::lsl, ShImm);
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue ShImmOp = CurDAG->getTargetConstant(ShImm, EVT::i32);
|
|
|
|
SDValue Reg0 = CurDAG->getRegister(0, EVT::i32);
|
2009-07-22 18:08:05 +00:00
|
|
|
if (Subtarget->isThumb()) {
|
2009-07-21 00:31:12 +00:00
|
|
|
SDValue Ops[] = { V, V, ShImmOp, getAL(CurDAG), Reg0, Reg0 };
|
2009-08-10 22:56:29 +00:00
|
|
|
return CurDAG->SelectNodeTo(N, ARM::t2ADDrs, EVT::i32, Ops, 6);
|
2009-07-21 00:31:12 +00:00
|
|
|
} else {
|
|
|
|
SDValue Ops[] = { V, V, Reg0, ShImmOp, getAL(CurDAG), Reg0, Reg0 };
|
2009-08-10 22:56:29 +00:00
|
|
|
return CurDAG->SelectNodeTo(N, ARM::ADDrs, EVT::i32, Ops, 7);
|
2009-07-21 00:31:12 +00:00
|
|
|
}
|
2007-01-19 07:51:42 +00:00
|
|
|
}
|
|
|
|
if (isPowerOf2_32(RHSV+1)) { // 2^n-1?
|
2009-07-21 00:31:12 +00:00
|
|
|
unsigned ShImm = Log2_32(RHSV+1);
|
|
|
|
if (ShImm >= 32)
|
|
|
|
break;
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue V = Op.getOperand(0);
|
2009-07-21 00:31:12 +00:00
|
|
|
ShImm = ARM_AM::getSORegOpc(ARM_AM::lsl, ShImm);
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue ShImmOp = CurDAG->getTargetConstant(ShImm, EVT::i32);
|
|
|
|
SDValue Reg0 = CurDAG->getRegister(0, EVT::i32);
|
2009-07-22 18:08:05 +00:00
|
|
|
if (Subtarget->isThumb()) {
|
2009-07-21 00:31:12 +00:00
|
|
|
SDValue Ops[] = { V, V, ShImmOp, getAL(CurDAG), Reg0 };
|
2009-08-10 22:56:29 +00:00
|
|
|
return CurDAG->SelectNodeTo(N, ARM::t2RSBrs, EVT::i32, Ops, 5);
|
2009-07-21 00:31:12 +00:00
|
|
|
} else {
|
|
|
|
SDValue Ops[] = { V, V, Reg0, ShImmOp, getAL(CurDAG), Reg0, Reg0 };
|
2009-08-10 22:56:29 +00:00
|
|
|
return CurDAG->SelectNodeTo(N, ARM::RSBrs, EVT::i32, Ops, 7);
|
2009-07-21 00:31:12 +00:00
|
|
|
}
|
2007-01-19 07:51:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ARMISD::FMRRD:
|
2009-08-10 22:56:29 +00:00
|
|
|
return CurDAG->getTargetNode(ARM::FMRRD, dl, EVT::i32, EVT::i32,
|
2007-07-05 07:15:27 +00:00
|
|
|
Op.getOperand(0), getAL(CurDAG),
|
2009-08-10 22:56:29 +00:00
|
|
|
CurDAG->getRegister(0, EVT::i32));
|
2007-10-08 18:33:35 +00:00
|
|
|
case ISD::UMUL_LOHI: {
|
2009-07-07 01:17:28 +00:00
|
|
|
if (Subtarget->isThumb1Only())
|
|
|
|
break;
|
|
|
|
if (Subtarget->isThumb()) {
|
|
|
|
SDValue Ops[] = { Op.getOperand(0), Op.getOperand(1),
|
2009-08-10 22:56:29 +00:00
|
|
|
getAL(CurDAG), CurDAG->getRegister(0, EVT::i32),
|
|
|
|
CurDAG->getRegister(0, EVT::i32) };
|
|
|
|
return CurDAG->getTargetNode(ARM::t2UMULL, dl, EVT::i32, EVT::i32, Ops,4);
|
2009-07-07 01:17:28 +00:00
|
|
|
} else {
|
|
|
|
SDValue Ops[] = { Op.getOperand(0), Op.getOperand(1),
|
2009-08-10 22:56:29 +00:00
|
|
|
getAL(CurDAG), CurDAG->getRegister(0, EVT::i32),
|
|
|
|
CurDAG->getRegister(0, EVT::i32) };
|
|
|
|
return CurDAG->getTargetNode(ARM::UMULL, dl, EVT::i32, EVT::i32, Ops, 5);
|
2009-07-07 01:17:28 +00:00
|
|
|
}
|
2007-07-05 07:15:27 +00:00
|
|
|
}
|
2007-10-08 18:33:35 +00:00
|
|
|
case ISD::SMUL_LOHI: {
|
2009-07-07 01:17:28 +00:00
|
|
|
if (Subtarget->isThumb1Only())
|
|
|
|
break;
|
|
|
|
if (Subtarget->isThumb()) {
|
|
|
|
SDValue Ops[] = { Op.getOperand(0), Op.getOperand(1),
|
2009-08-10 22:56:29 +00:00
|
|
|
getAL(CurDAG), CurDAG->getRegister(0, EVT::i32) };
|
|
|
|
return CurDAG->getTargetNode(ARM::t2SMULL, dl, EVT::i32, EVT::i32, Ops,4);
|
2009-07-07 01:17:28 +00:00
|
|
|
} else {
|
|
|
|
SDValue Ops[] = { Op.getOperand(0), Op.getOperand(1),
|
2009-08-10 22:56:29 +00:00
|
|
|
getAL(CurDAG), CurDAG->getRegister(0, EVT::i32),
|
|
|
|
CurDAG->getRegister(0, EVT::i32) };
|
|
|
|
return CurDAG->getTargetNode(ARM::SMULL, dl, EVT::i32, EVT::i32, Ops, 5);
|
2009-07-07 01:17:28 +00:00
|
|
|
}
|
2007-07-05 07:15:27 +00:00
|
|
|
}
|
2007-01-19 07:51:42 +00:00
|
|
|
case ISD::LOAD: {
|
2009-07-02 07:28:31 +00:00
|
|
|
SDNode *ResNode = 0;
|
2009-07-07 01:17:28 +00:00
|
|
|
if (Subtarget->isThumb() && Subtarget->hasThumb2())
|
2009-07-02 07:28:31 +00:00
|
|
|
ResNode = SelectT2IndexedLoad(Op);
|
|
|
|
else
|
|
|
|
ResNode = SelectARMIndexedLoad(Op);
|
2009-07-02 01:23:32 +00:00
|
|
|
if (ResNode)
|
|
|
|
return ResNode;
|
2007-01-19 07:51:42 +00:00
|
|
|
// Other cases are autogenerated.
|
2006-11-09 13:58:55 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-07-05 07:15:27 +00:00
|
|
|
case ARMISD::BRCOND: {
|
|
|
|
// Pattern: (ARMbrcond:void (bb:Other):$dst, (imm:i32):$cc)
|
|
|
|
// Emits: (Bcc:void (bb:Other):$dst, (imm:i32):$cc)
|
|
|
|
// Pattern complexity = 6 cost = 1 size = 0
|
|
|
|
|
|
|
|
// Pattern: (ARMbrcond:void (bb:Other):$dst, (imm:i32):$cc)
|
|
|
|
// Emits: (tBcc:void (bb:Other):$dst, (imm:i32):$cc)
|
|
|
|
// Pattern complexity = 6 cost = 1 size = 0
|
|
|
|
|
2009-06-30 18:04:13 +00:00
|
|
|
// Pattern: (ARMbrcond:void (bb:Other):$dst, (imm:i32):$cc)
|
|
|
|
// Emits: (t2Bcc:void (bb:Other):$dst, (imm:i32):$cc)
|
|
|
|
// Pattern complexity = 6 cost = 1 size = 0
|
|
|
|
|
2009-08-11 15:33:49 +00:00
|
|
|
unsigned Opc = Subtarget->isThumb() ?
|
2009-06-30 18:04:13 +00:00
|
|
|
((Subtarget->hasThumb2()) ? ARM::t2Bcc : ARM::tBcc) : ARM::Bcc;
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue Chain = Op.getOperand(0);
|
|
|
|
SDValue N1 = Op.getOperand(1);
|
|
|
|
SDValue N2 = Op.getOperand(2);
|
|
|
|
SDValue N3 = Op.getOperand(3);
|
|
|
|
SDValue InFlag = Op.getOperand(4);
|
2007-07-05 07:15:27 +00:00
|
|
|
assert(N1.getOpcode() == ISD::BasicBlock);
|
|
|
|
assert(N2.getOpcode() == ISD::Constant);
|
|
|
|
assert(N3.getOpcode() == ISD::Register);
|
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue Tmp2 = CurDAG->getTargetConstant(((unsigned)
|
2008-09-12 16:56:44 +00:00
|
|
|
cast<ConstantSDNode>(N2)->getZExtValue()),
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT::i32);
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue Ops[] = { N1, Tmp2, N3, Chain, InFlag };
|
2009-08-11 15:33:49 +00:00
|
|
|
SDNode *ResNode = CurDAG->getTargetNode(Opc, dl, EVT::Other,
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT::Flag, Ops, 5);
|
2008-07-27 21:46:04 +00:00
|
|
|
Chain = SDValue(ResNode, 0);
|
2008-08-28 21:40:38 +00:00
|
|
|
if (Op.getNode()->getNumValues() == 2) {
|
2008-07-27 21:46:04 +00:00
|
|
|
InFlag = SDValue(ResNode, 1);
|
2008-08-28 21:40:38 +00:00
|
|
|
ReplaceUses(SDValue(Op.getNode(), 1), InFlag);
|
2008-02-03 03:20:59 +00:00
|
|
|
}
|
2008-08-28 21:40:38 +00:00
|
|
|
ReplaceUses(SDValue(Op.getNode(), 0), SDValue(Chain.getNode(), Chain.getResNo()));
|
2007-07-05 07:15:27 +00:00
|
|
|
return NULL;
|
2006-06-12 12:28:08 +00:00
|
|
|
}
|
2007-07-05 07:15:27 +00:00
|
|
|
case ARMISD::CMOV: {
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT VT = Op.getValueType();
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue N0 = Op.getOperand(0);
|
|
|
|
SDValue N1 = Op.getOperand(1);
|
|
|
|
SDValue N2 = Op.getOperand(2);
|
|
|
|
SDValue N3 = Op.getOperand(3);
|
|
|
|
SDValue InFlag = Op.getOperand(4);
|
2007-07-05 07:15:27 +00:00
|
|
|
assert(N2.getOpcode() == ISD::Constant);
|
|
|
|
assert(N3.getOpcode() == ISD::Register);
|
|
|
|
|
2009-08-10 22:56:29 +00:00
|
|
|
if (!Subtarget->isThumb1Only() && VT == EVT::i32) {
|
2009-07-07 20:39:03 +00:00
|
|
|
// Pattern: (ARMcmov:i32 GPR:i32:$false, so_reg:i32:$true, (imm:i32):$cc)
|
|
|
|
// Emits: (MOVCCs:i32 GPR:i32:$false, so_reg:i32:$true, (imm:i32):$cc)
|
|
|
|
// Pattern complexity = 18 cost = 1 size = 0
|
|
|
|
SDValue CPTmp0;
|
|
|
|
SDValue CPTmp1;
|
|
|
|
SDValue CPTmp2;
|
|
|
|
if (Subtarget->isThumb()) {
|
|
|
|
if (SelectT2ShifterOperandReg(Op, N1, CPTmp0, CPTmp1)) {
|
2009-08-01 01:43:45 +00:00
|
|
|
unsigned SOVal = cast<ConstantSDNode>(CPTmp1)->getZExtValue();
|
|
|
|
unsigned SOShOp = ARM_AM::getSORegShOp(SOVal);
|
|
|
|
unsigned Opc = 0;
|
|
|
|
switch (SOShOp) {
|
|
|
|
case ARM_AM::lsl: Opc = ARM::t2MOVCClsl; break;
|
|
|
|
case ARM_AM::lsr: Opc = ARM::t2MOVCClsr; break;
|
|
|
|
case ARM_AM::asr: Opc = ARM::t2MOVCCasr; break;
|
|
|
|
case ARM_AM::ror: Opc = ARM::t2MOVCCror; break;
|
|
|
|
default:
|
|
|
|
llvm_unreachable("Unknown so_reg opcode!");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
SDValue SOShImm =
|
2009-08-10 22:56:29 +00:00
|
|
|
CurDAG->getTargetConstant(ARM_AM::getSORegOffset(SOVal), EVT::i32);
|
2009-07-07 20:39:03 +00:00
|
|
|
SDValue Tmp2 = CurDAG->getTargetConstant(((unsigned)
|
|
|
|
cast<ConstantSDNode>(N2)->getZExtValue()),
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT::i32);
|
2009-08-01 01:43:45 +00:00
|
|
|
SDValue Ops[] = { N0, CPTmp0, SOShImm, Tmp2, N3, InFlag };
|
2009-08-10 22:56:29 +00:00
|
|
|
return CurDAG->SelectNodeTo(Op.getNode(), Opc, EVT::i32,Ops, 6);
|
2009-07-07 20:39:03 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (SelectShifterOperandReg(Op, N1, CPTmp0, CPTmp1, CPTmp2)) {
|
|
|
|
SDValue Tmp2 = CurDAG->getTargetConstant(((unsigned)
|
|
|
|
cast<ConstantSDNode>(N2)->getZExtValue()),
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT::i32);
|
2009-07-07 20:39:03 +00:00
|
|
|
SDValue Ops[] = { N0, CPTmp0, CPTmp1, CPTmp2, Tmp2, N3, InFlag };
|
|
|
|
return CurDAG->SelectNodeTo(Op.getNode(),
|
2009-08-10 22:56:29 +00:00
|
|
|
ARM::MOVCCs, EVT::i32, Ops, 7);
|
2009-07-07 20:39:03 +00:00
|
|
|
}
|
|
|
|
}
|
2007-07-05 07:15:27 +00:00
|
|
|
|
2009-07-07 20:39:03 +00:00
|
|
|
// Pattern: (ARMcmov:i32 GPR:i32:$false,
|
2009-07-08 21:03:57 +00:00
|
|
|
// (imm:i32)<<P:Predicate_so_imm>>:$true,
|
2009-07-07 20:39:03 +00:00
|
|
|
// (imm:i32):$cc)
|
|
|
|
// Emits: (MOVCCi:i32 GPR:i32:$false,
|
2009-07-08 21:03:57 +00:00
|
|
|
// (so_imm:i32 (imm:i32):$true), (imm:i32):$cc)
|
2009-07-07 20:39:03 +00:00
|
|
|
// Pattern complexity = 10 cost = 1 size = 0
|
|
|
|
if (N3.getOpcode() == ISD::Constant) {
|
|
|
|
if (Subtarget->isThumb()) {
|
|
|
|
if (Predicate_t2_so_imm(N3.getNode())) {
|
|
|
|
SDValue Tmp1 = CurDAG->getTargetConstant(((unsigned)
|
|
|
|
cast<ConstantSDNode>(N1)->getZExtValue()),
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT::i32);
|
2009-07-07 20:39:03 +00:00
|
|
|
SDValue Tmp2 = CurDAG->getTargetConstant(((unsigned)
|
|
|
|
cast<ConstantSDNode>(N2)->getZExtValue()),
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT::i32);
|
2009-07-07 20:39:03 +00:00
|
|
|
SDValue Ops[] = { N0, Tmp1, Tmp2, N3, InFlag };
|
|
|
|
return CurDAG->SelectNodeTo(Op.getNode(),
|
2009-08-10 22:56:29 +00:00
|
|
|
ARM::t2MOVCCi, EVT::i32, Ops, 5);
|
2009-07-07 20:39:03 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (Predicate_so_imm(N3.getNode())) {
|
|
|
|
SDValue Tmp1 = CurDAG->getTargetConstant(((unsigned)
|
|
|
|
cast<ConstantSDNode>(N1)->getZExtValue()),
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT::i32);
|
2009-07-07 20:39:03 +00:00
|
|
|
SDValue Tmp2 = CurDAG->getTargetConstant(((unsigned)
|
|
|
|
cast<ConstantSDNode>(N2)->getZExtValue()),
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT::i32);
|
2009-07-07 20:39:03 +00:00
|
|
|
SDValue Ops[] = { N0, Tmp1, Tmp2, N3, InFlag };
|
|
|
|
return CurDAG->SelectNodeTo(Op.getNode(),
|
2009-08-10 22:56:29 +00:00
|
|
|
ARM::MOVCCi, EVT::i32, Ops, 5);
|
2009-07-07 20:39:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-07-05 07:15:27 +00:00
|
|
|
}
|
2006-05-14 22:18:28 +00:00
|
|
|
|
2007-07-05 07:15:27 +00:00
|
|
|
// Pattern: (ARMcmov:i32 GPR:i32:$false, GPR:i32:$true, (imm:i32):$cc)
|
|
|
|
// Emits: (MOVCCr:i32 GPR:i32:$false, GPR:i32:$true, (imm:i32):$cc)
|
|
|
|
// Pattern complexity = 6 cost = 1 size = 0
|
|
|
|
//
|
|
|
|
// Pattern: (ARMcmov:i32 GPR:i32:$false, GPR:i32:$true, (imm:i32):$cc)
|
|
|
|
// Emits: (tMOVCCr:i32 GPR:i32:$false, GPR:i32:$true, (imm:i32):$cc)
|
|
|
|
// Pattern complexity = 6 cost = 11 size = 0
|
|
|
|
//
|
|
|
|
// Also FCPYScc and FCPYDcc.
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue Tmp2 = CurDAG->getTargetConstant(((unsigned)
|
2008-09-12 16:56:44 +00:00
|
|
|
cast<ConstantSDNode>(N2)->getZExtValue()),
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT::i32);
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue Ops[] = { N0, N1, Tmp2, N3, InFlag };
|
2007-07-05 07:15:27 +00:00
|
|
|
unsigned Opc = 0;
|
2008-06-06 12:08:01 +00:00
|
|
|
switch (VT.getSimpleVT()) {
|
2007-07-05 07:15:27 +00:00
|
|
|
default: assert(false && "Illegal conditional move type!");
|
|
|
|
break;
|
2009-08-10 22:56:29 +00:00
|
|
|
case EVT::i32:
|
2009-07-07 20:39:03 +00:00
|
|
|
Opc = Subtarget->isThumb()
|
|
|
|
? (Subtarget->hasThumb2() ? ARM::t2MOVCCr : ARM::tMOVCCr)
|
|
|
|
: ARM::MOVCCr;
|
2007-07-05 07:15:27 +00:00
|
|
|
break;
|
2009-08-10 22:56:29 +00:00
|
|
|
case EVT::f32:
|
2007-07-05 07:15:27 +00:00
|
|
|
Opc = ARM::FCPYScc;
|
|
|
|
break;
|
2009-08-10 22:56:29 +00:00
|
|
|
case EVT::f64:
|
2007-07-05 07:15:27 +00:00
|
|
|
Opc = ARM::FCPYDcc;
|
2009-08-11 15:33:49 +00:00
|
|
|
break;
|
2007-07-05 07:15:27 +00:00
|
|
|
}
|
2008-08-28 21:40:38 +00:00
|
|
|
return CurDAG->SelectNodeTo(Op.getNode(), Opc, VT, Ops, 5);
|
2007-07-05 07:15:27 +00:00
|
|
|
}
|
|
|
|
case ARMISD::CNEG: {
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT VT = Op.getValueType();
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue N0 = Op.getOperand(0);
|
|
|
|
SDValue N1 = Op.getOperand(1);
|
|
|
|
SDValue N2 = Op.getOperand(2);
|
|
|
|
SDValue N3 = Op.getOperand(3);
|
|
|
|
SDValue InFlag = Op.getOperand(4);
|
2007-07-05 07:15:27 +00:00
|
|
|
assert(N2.getOpcode() == ISD::Constant);
|
|
|
|
assert(N3.getOpcode() == ISD::Register);
|
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue Tmp2 = CurDAG->getTargetConstant(((unsigned)
|
2008-09-12 16:56:44 +00:00
|
|
|
cast<ConstantSDNode>(N2)->getZExtValue()),
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT::i32);
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue Ops[] = { N0, N1, Tmp2, N3, InFlag };
|
2007-07-05 07:15:27 +00:00
|
|
|
unsigned Opc = 0;
|
2008-06-06 12:08:01 +00:00
|
|
|
switch (VT.getSimpleVT()) {
|
2007-07-05 07:15:27 +00:00
|
|
|
default: assert(false && "Illegal conditional move type!");
|
|
|
|
break;
|
2009-08-10 22:56:29 +00:00
|
|
|
case EVT::f32:
|
2007-07-05 07:15:27 +00:00
|
|
|
Opc = ARM::FNEGScc;
|
|
|
|
break;
|
2009-08-10 22:56:29 +00:00
|
|
|
case EVT::f64:
|
2007-07-05 07:15:27 +00:00
|
|
|
Opc = ARM::FNEGDcc;
|
2008-12-10 21:54:21 +00:00
|
|
|
break;
|
2007-07-05 07:15:27 +00:00
|
|
|
}
|
2008-08-28 21:40:38 +00:00
|
|
|
return CurDAG->SelectNodeTo(Op.getNode(), Opc, VT, Ops, 5);
|
2007-07-05 07:15:27 +00:00
|
|
|
}
|
2008-12-10 21:54:21 +00:00
|
|
|
|
|
|
|
case ISD::DECLARE: {
|
|
|
|
SDValue Chain = Op.getOperand(0);
|
|
|
|
SDValue N1 = Op.getOperand(1);
|
|
|
|
SDValue N2 = Op.getOperand(2);
|
|
|
|
FrameIndexSDNode *FINode = dyn_cast<FrameIndexSDNode>(N1);
|
2009-02-12 17:38:23 +00:00
|
|
|
// FIXME: handle VLAs.
|
|
|
|
if (!FINode) {
|
|
|
|
ReplaceUses(Op.getValue(0), Chain);
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-12-10 21:54:21 +00:00
|
|
|
if (N2.getOpcode() == ARMISD::PIC_ADD && isa<LoadSDNode>(N2.getOperand(0)))
|
|
|
|
N2 = N2.getOperand(0);
|
|
|
|
LoadSDNode *Ld = dyn_cast<LoadSDNode>(N2);
|
2009-02-12 17:38:23 +00:00
|
|
|
if (!Ld) {
|
|
|
|
ReplaceUses(Op.getValue(0), Chain);
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-12-10 21:54:21 +00:00
|
|
|
SDValue BasePtr = Ld->getBasePtr();
|
|
|
|
assert(BasePtr.getOpcode() == ARMISD::Wrapper &&
|
|
|
|
isa<ConstantPoolSDNode>(BasePtr.getOperand(0)) &&
|
|
|
|
"llvm.dbg.variable should be a constantpool node");
|
|
|
|
ConstantPoolSDNode *CP = cast<ConstantPoolSDNode>(BasePtr.getOperand(0));
|
|
|
|
GlobalValue *GV = 0;
|
|
|
|
if (CP->isMachineConstantPoolEntry()) {
|
|
|
|
ARMConstantPoolValue *ACPV = (ARMConstantPoolValue*)CP->getMachineCPVal();
|
|
|
|
GV = ACPV->getGV();
|
|
|
|
} else
|
|
|
|
GV = dyn_cast<GlobalValue>(CP->getConstVal());
|
2009-02-12 17:38:23 +00:00
|
|
|
if (!GV) {
|
|
|
|
ReplaceUses(Op.getValue(0), Chain);
|
|
|
|
return NULL;
|
2008-12-10 21:54:21 +00:00
|
|
|
}
|
2009-08-11 15:33:49 +00:00
|
|
|
|
2009-02-12 17:38:23 +00:00
|
|
|
SDValue Tmp1 = CurDAG->getTargetFrameIndex(FINode->getIndex(),
|
|
|
|
TLI.getPointerTy());
|
|
|
|
SDValue Tmp2 = CurDAG->getTargetGlobalAddress(GV, TLI.getPointerTy());
|
|
|
|
SDValue Ops[] = { Tmp1, Tmp2, Chain };
|
|
|
|
return CurDAG->getTargetNode(TargetInstrInfo::DECLARE, dl,
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT::Other, Ops, 3);
|
2008-12-10 21:54:21 +00:00
|
|
|
}
|
2009-06-22 23:27:02 +00:00
|
|
|
|
|
|
|
case ISD::VECTOR_SHUFFLE: {
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT VT = Op.getValueType();
|
2009-06-22 23:27:02 +00:00
|
|
|
|
|
|
|
// Match 128-bit splat to VDUPLANEQ. (This could be done with a Pat in
|
|
|
|
// ARMInstrNEON.td but it is awkward because the shuffle mask needs to be
|
|
|
|
// transformed first into a lane number and then to both a subregister
|
|
|
|
// index and an adjusted lane number.) If the source operand is a
|
|
|
|
// SCALAR_TO_VECTOR, leave it so it will be matched later as a VDUP.
|
|
|
|
ShuffleVectorSDNode *SVOp = cast<ShuffleVectorSDNode>(N);
|
|
|
|
if (VT.is128BitVector() && SVOp->isSplat() &&
|
|
|
|
Op.getOperand(0).getOpcode() != ISD::SCALAR_TO_VECTOR &&
|
|
|
|
Op.getOperand(1).getOpcode() == ISD::UNDEF) {
|
|
|
|
unsigned LaneVal = SVOp->getSplatIndex();
|
|
|
|
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT HalfVT;
|
2009-06-22 23:27:02 +00:00
|
|
|
unsigned Opc = 0;
|
|
|
|
switch (VT.getVectorElementType().getSimpleVT()) {
|
2009-08-05 00:49:09 +00:00
|
|
|
default: llvm_unreachable("unhandled VDUP splat type");
|
2009-08-10 22:56:29 +00:00
|
|
|
case EVT::i8: Opc = ARM::VDUPLN8q; HalfVT = EVT::v8i8; break;
|
|
|
|
case EVT::i16: Opc = ARM::VDUPLN16q; HalfVT = EVT::v4i16; break;
|
|
|
|
case EVT::i32: Opc = ARM::VDUPLN32q; HalfVT = EVT::v2i32; break;
|
|
|
|
case EVT::f32: Opc = ARM::VDUPLNfq; HalfVT = EVT::v2f32; break;
|
2009-06-22 23:27:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// The source operand needs to be changed to a subreg of the original
|
|
|
|
// 128-bit operand, and the lane number needs to be adjusted accordingly.
|
|
|
|
unsigned NumElts = VT.getVectorNumElements() / 2;
|
|
|
|
unsigned SRVal = (LaneVal < NumElts ? arm_dsubreg_0 : arm_dsubreg_1);
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue SR = CurDAG->getTargetConstant(SRVal, EVT::i32);
|
|
|
|
SDValue NewLane = CurDAG->getTargetConstant(LaneVal % NumElts, EVT::i32);
|
2009-06-22 23:27:02 +00:00
|
|
|
SDNode *SubReg = CurDAG->getTargetNode(TargetInstrInfo::EXTRACT_SUBREG,
|
|
|
|
dl, HalfVT, N->getOperand(0), SR);
|
|
|
|
return CurDAG->SelectNodeTo(N, Opc, VT, SDValue(SubReg, 0), NewLane);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2009-08-05 00:49:09 +00:00
|
|
|
|
|
|
|
case ARMISD::VLD2D: {
|
|
|
|
SDValue MemAddr, MemUpdate, MemOpc;
|
|
|
|
if (!SelectAddrMode6(Op, N->getOperand(1), MemAddr, MemUpdate, MemOpc))
|
|
|
|
return NULL;
|
2009-08-06 18:47:44 +00:00
|
|
|
unsigned Opc = 0;
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT VT = Op.getValueType();
|
2009-08-05 00:49:09 +00:00
|
|
|
switch (VT.getSimpleVT()) {
|
|
|
|
default: llvm_unreachable("unhandled VLD2D type");
|
2009-08-10 22:56:29 +00:00
|
|
|
case EVT::v8i8: Opc = ARM::VLD2d8; break;
|
|
|
|
case EVT::v4i16: Opc = ARM::VLD2d16; break;
|
|
|
|
case EVT::v2f32:
|
|
|
|
case EVT::v2i32: Opc = ARM::VLD2d32; break;
|
2009-08-05 00:49:09 +00:00
|
|
|
}
|
|
|
|
const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc };
|
2009-08-10 22:56:29 +00:00
|
|
|
return CurDAG->getTargetNode(Opc, dl, VT, VT, EVT::Other, Ops, 3);
|
2009-08-05 00:49:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case ARMISD::VLD3D: {
|
|
|
|
SDValue MemAddr, MemUpdate, MemOpc;
|
|
|
|
if (!SelectAddrMode6(Op, N->getOperand(1), MemAddr, MemUpdate, MemOpc))
|
|
|
|
return NULL;
|
2009-08-06 18:47:44 +00:00
|
|
|
unsigned Opc = 0;
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT VT = Op.getValueType();
|
2009-08-05 00:49:09 +00:00
|
|
|
switch (VT.getSimpleVT()) {
|
|
|
|
default: llvm_unreachable("unhandled VLD3D type");
|
2009-08-10 22:56:29 +00:00
|
|
|
case EVT::v8i8: Opc = ARM::VLD3d8; break;
|
|
|
|
case EVT::v4i16: Opc = ARM::VLD3d16; break;
|
|
|
|
case EVT::v2f32:
|
|
|
|
case EVT::v2i32: Opc = ARM::VLD3d32; break;
|
2009-08-05 00:49:09 +00:00
|
|
|
}
|
|
|
|
const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc };
|
2009-08-10 22:56:29 +00:00
|
|
|
return CurDAG->getTargetNode(Opc, dl, VT, VT, VT, EVT::Other, Ops, 3);
|
2009-08-05 00:49:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case ARMISD::VLD4D: {
|
|
|
|
SDValue MemAddr, MemUpdate, MemOpc;
|
|
|
|
if (!SelectAddrMode6(Op, N->getOperand(1), MemAddr, MemUpdate, MemOpc))
|
|
|
|
return NULL;
|
2009-08-06 18:47:44 +00:00
|
|
|
unsigned Opc = 0;
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT VT = Op.getValueType();
|
2009-08-05 00:49:09 +00:00
|
|
|
switch (VT.getSimpleVT()) {
|
|
|
|
default: llvm_unreachable("unhandled VLD4D type");
|
2009-08-10 22:56:29 +00:00
|
|
|
case EVT::v8i8: Opc = ARM::VLD4d8; break;
|
|
|
|
case EVT::v4i16: Opc = ARM::VLD4d16; break;
|
|
|
|
case EVT::v2f32:
|
|
|
|
case EVT::v2i32: Opc = ARM::VLD4d32; break;
|
2009-08-05 00:49:09 +00:00
|
|
|
}
|
|
|
|
const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc };
|
2009-08-10 22:56:29 +00:00
|
|
|
std::vector<EVT> ResTys(4, VT);
|
|
|
|
ResTys.push_back(EVT::Other);
|
2009-08-05 00:49:09 +00:00
|
|
|
return CurDAG->getTargetNode(Opc, dl, ResTys, Ops, 3);
|
|
|
|
}
|
2009-08-06 18:47:44 +00:00
|
|
|
|
|
|
|
case ARMISD::VST2D: {
|
|
|
|
SDValue MemAddr, MemUpdate, MemOpc;
|
|
|
|
if (!SelectAddrMode6(Op, N->getOperand(1), MemAddr, MemUpdate, MemOpc))
|
|
|
|
return NULL;
|
|
|
|
unsigned Opc = 0;
|
|
|
|
switch (N->getOperand(2).getValueType().getSimpleVT()) {
|
|
|
|
default: llvm_unreachable("unhandled VST2D type");
|
2009-08-10 22:56:29 +00:00
|
|
|
case EVT::v8i8: Opc = ARM::VST2d8; break;
|
|
|
|
case EVT::v4i16: Opc = ARM::VST2d16; break;
|
|
|
|
case EVT::v2f32:
|
|
|
|
case EVT::v2i32: Opc = ARM::VST2d32; break;
|
2009-08-06 18:47:44 +00:00
|
|
|
}
|
|
|
|
const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc,
|
|
|
|
N->getOperand(2), N->getOperand(3) };
|
2009-08-10 22:56:29 +00:00
|
|
|
return CurDAG->getTargetNode(Opc, dl, EVT::Other, Ops, 5);
|
2009-08-06 18:47:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case ARMISD::VST3D: {
|
|
|
|
SDValue MemAddr, MemUpdate, MemOpc;
|
|
|
|
if (!SelectAddrMode6(Op, N->getOperand(1), MemAddr, MemUpdate, MemOpc))
|
|
|
|
return NULL;
|
|
|
|
unsigned Opc = 0;
|
|
|
|
switch (N->getOperand(2).getValueType().getSimpleVT()) {
|
|
|
|
default: llvm_unreachable("unhandled VST3D type");
|
2009-08-10 22:56:29 +00:00
|
|
|
case EVT::v8i8: Opc = ARM::VST3d8; break;
|
|
|
|
case EVT::v4i16: Opc = ARM::VST3d16; break;
|
|
|
|
case EVT::v2f32:
|
|
|
|
case EVT::v2i32: Opc = ARM::VST3d32; break;
|
2009-08-06 18:47:44 +00:00
|
|
|
}
|
|
|
|
const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc,
|
|
|
|
N->getOperand(2), N->getOperand(3),
|
|
|
|
N->getOperand(4) };
|
2009-08-10 22:56:29 +00:00
|
|
|
return CurDAG->getTargetNode(Opc, dl, EVT::Other, Ops, 6);
|
2009-08-06 18:47:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case ARMISD::VST4D: {
|
|
|
|
SDValue MemAddr, MemUpdate, MemOpc;
|
|
|
|
if (!SelectAddrMode6(Op, N->getOperand(1), MemAddr, MemUpdate, MemOpc))
|
|
|
|
return NULL;
|
|
|
|
unsigned Opc = 0;
|
|
|
|
switch (N->getOperand(2).getValueType().getSimpleVT()) {
|
|
|
|
default: llvm_unreachable("unhandled VST4D type");
|
2009-08-10 22:56:29 +00:00
|
|
|
case EVT::v8i8: Opc = ARM::VST4d8; break;
|
|
|
|
case EVT::v4i16: Opc = ARM::VST4d16; break;
|
|
|
|
case EVT::v2f32:
|
|
|
|
case EVT::v2i32: Opc = ARM::VST4d32; break;
|
2009-08-06 18:47:44 +00:00
|
|
|
}
|
|
|
|
const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc,
|
|
|
|
N->getOperand(2), N->getOperand(3),
|
|
|
|
N->getOperand(4), N->getOperand(5) };
|
2009-08-10 22:56:29 +00:00
|
|
|
return CurDAG->getTargetNode(Opc, dl, EVT::Other, Ops, 7);
|
2009-08-06 18:47:44 +00:00
|
|
|
}
|
2009-08-08 05:53:00 +00:00
|
|
|
|
|
|
|
case ISD::INTRINSIC_WO_CHAIN: {
|
|
|
|
unsigned IntNo = cast<ConstantSDNode>(N->getOperand(0))->getZExtValue();
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT VT = N->getValueType(0);
|
2009-08-08 05:53:00 +00:00
|
|
|
unsigned Opc = 0;
|
|
|
|
|
|
|
|
// Match intrinsics that return multiple values.
|
|
|
|
switch (IntNo) {
|
|
|
|
default: break;
|
|
|
|
|
2009-08-11 05:39:44 +00:00
|
|
|
case Intrinsic::arm_neon_vtrn:
|
2009-08-08 05:53:00 +00:00
|
|
|
switch (VT.getSimpleVT()) {
|
|
|
|
default: return NULL;
|
2009-08-10 22:56:29 +00:00
|
|
|
case EVT::v8i8: Opc = ARM::VTRNd8; break;
|
|
|
|
case EVT::v4i16: Opc = ARM::VTRNd16; break;
|
|
|
|
case EVT::v2f32:
|
|
|
|
case EVT::v2i32: Opc = ARM::VTRNd32; break;
|
|
|
|
case EVT::v16i8: Opc = ARM::VTRNq8; break;
|
|
|
|
case EVT::v8i16: Opc = ARM::VTRNq16; break;
|
|
|
|
case EVT::v4f32:
|
|
|
|
case EVT::v4i32: Opc = ARM::VTRNq32; break;
|
2009-08-08 05:53:00 +00:00
|
|
|
}
|
|
|
|
return CurDAG->getTargetNode(Opc, dl, VT, VT, N->getOperand(1),
|
|
|
|
N->getOperand(2));
|
2009-08-08 06:13:25 +00:00
|
|
|
|
2009-08-11 05:39:44 +00:00
|
|
|
case Intrinsic::arm_neon_vuzp:
|
2009-08-08 06:13:25 +00:00
|
|
|
switch (VT.getSimpleVT()) {
|
|
|
|
default: return NULL;
|
2009-08-10 22:56:29 +00:00
|
|
|
case EVT::v8i8: Opc = ARM::VUZPd8; break;
|
|
|
|
case EVT::v4i16: Opc = ARM::VUZPd16; break;
|
|
|
|
case EVT::v2f32:
|
|
|
|
case EVT::v2i32: Opc = ARM::VUZPd32; break;
|
|
|
|
case EVT::v16i8: Opc = ARM::VUZPq8; break;
|
|
|
|
case EVT::v8i16: Opc = ARM::VUZPq16; break;
|
|
|
|
case EVT::v4f32:
|
|
|
|
case EVT::v4i32: Opc = ARM::VUZPq32; break;
|
2009-08-08 06:13:25 +00:00
|
|
|
}
|
|
|
|
return CurDAG->getTargetNode(Opc, dl, VT, VT, N->getOperand(1),
|
|
|
|
N->getOperand(2));
|
|
|
|
|
2009-08-11 05:39:44 +00:00
|
|
|
case Intrinsic::arm_neon_vzip:
|
2009-08-08 06:13:25 +00:00
|
|
|
switch (VT.getSimpleVT()) {
|
|
|
|
default: return NULL;
|
2009-08-10 22:56:29 +00:00
|
|
|
case EVT::v8i8: Opc = ARM::VZIPd8; break;
|
|
|
|
case EVT::v4i16: Opc = ARM::VZIPd16; break;
|
|
|
|
case EVT::v2f32:
|
|
|
|
case EVT::v2i32: Opc = ARM::VZIPd32; break;
|
|
|
|
case EVT::v16i8: Opc = ARM::VZIPq8; break;
|
|
|
|
case EVT::v8i16: Opc = ARM::VZIPq16; break;
|
|
|
|
case EVT::v4f32:
|
|
|
|
case EVT::v4i32: Opc = ARM::VZIPq32; break;
|
2009-08-08 06:13:25 +00:00
|
|
|
}
|
|
|
|
return CurDAG->getTargetNode(Opc, dl, VT, VT, N->getOperand(1),
|
|
|
|
N->getOperand(2));
|
2009-08-08 05:53:00 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2007-07-05 07:15:27 +00:00
|
|
|
}
|
2008-12-10 21:54:21 +00:00
|
|
|
|
2007-01-19 07:51:42 +00:00
|
|
|
return SelectCode(Op);
|
|
|
|
}
|
2006-05-14 22:18:28 +00:00
|
|
|
|
2009-05-19 05:53:42 +00:00
|
|
|
bool ARMDAGToDAGISel::
|
|
|
|
SelectInlineAsmMemoryOperand(const SDValue &Op, char ConstraintCode,
|
|
|
|
std::vector<SDValue> &OutOps) {
|
|
|
|
assert(ConstraintCode == 'm' && "unexpected asm memory constraint");
|
|
|
|
|
|
|
|
SDValue Base, Offset, Opc;
|
|
|
|
if (!SelectAddrMode2(Op, Op, Base, Offset, Opc))
|
|
|
|
return true;
|
2009-08-11 15:33:49 +00:00
|
|
|
|
2009-05-19 05:53:42 +00:00
|
|
|
OutOps.push_back(Base);
|
|
|
|
OutOps.push_back(Offset);
|
|
|
|
OutOps.push_back(Opc);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-05-14 22:18:28 +00:00
|
|
|
/// createARMISelDag - This pass converts a legalized DAG into a
|
|
|
|
/// ARM-specific DAG, ready for instruction scheduling.
|
|
|
|
///
|
2009-06-26 21:28:53 +00:00
|
|
|
FunctionPass *llvm::createARMISelDag(ARMBaseTargetMachine &TM) {
|
2006-05-14 22:18:28 +00:00
|
|
|
return new ARMDAGToDAGISel(TM);
|
|
|
|
}
|