2007-12-29 20:36:04 +00:00
|
|
|
//===-- SPUISelDAGToDAG.cpp - CellSPU pattern matching inst selector ------===//
|
2007-12-04 22:23:35 +00:00
|
|
|
//
|
|
|
|
// 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.
|
2007-12-04 22:23:35 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines a pattern matching instruction selector for the Cell SPU,
|
|
|
|
// converting from a legalized dag to a SPU-target dag.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "SPU.h"
|
|
|
|
#include "SPUTargetMachine.h"
|
|
|
|
#include "SPUISelLowering.h"
|
|
|
|
#include "SPUHazardRecognizers.h"
|
|
|
|
#include "SPUFrameInfo.h"
|
2008-04-30 00:30:08 +00:00
|
|
|
#include "SPURegisterNames.h"
|
2007-12-04 22:23:35 +00:00
|
|
|
#include "llvm/CodeGen/MachineConstantPool.h"
|
|
|
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
|
|
|
#include "llvm/CodeGen/SelectionDAG.h"
|
|
|
|
#include "llvm/CodeGen/SelectionDAGISel.h"
|
|
|
|
#include "llvm/Target/TargetOptions.h"
|
|
|
|
#include "llvm/ADT/Statistic.h"
|
|
|
|
#include "llvm/Constants.h"
|
|
|
|
#include "llvm/GlobalValue.h"
|
|
|
|
#include "llvm/Intrinsics.h"
|
|
|
|
#include "llvm/Support/Debug.h"
|
|
|
|
#include "llvm/Support/MathExtras.h"
|
|
|
|
#include "llvm/Support/Compiler.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
//! ConstantSDNode predicate for i32 sign-extended, 10-bit immediates
|
|
|
|
bool
|
|
|
|
isI64IntS10Immediate(ConstantSDNode *CN)
|
|
|
|
{
|
2008-09-26 21:54:37 +00:00
|
|
|
return isS10Constant(CN->getSExtValue());
|
2007-12-04 22:23:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//! ConstantSDNode predicate for i32 sign-extended, 10-bit immediates
|
|
|
|
bool
|
|
|
|
isI32IntS10Immediate(ConstantSDNode *CN)
|
|
|
|
{
|
2008-09-26 21:54:37 +00:00
|
|
|
return isS10Constant(CN->getSExtValue());
|
2007-12-04 22:23:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
//! SDNode predicate for sign-extended, 10-bit immediate values
|
|
|
|
bool
|
|
|
|
isI32IntS10Immediate(SDNode *N)
|
|
|
|
{
|
|
|
|
return (N->getOpcode() == ISD::Constant
|
|
|
|
&& isI32IntS10Immediate(cast<ConstantSDNode>(N)));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-12-17 22:32:34 +00:00
|
|
|
//! ConstantSDNode predicate for i32 unsigned 10-bit immediate values
|
|
|
|
bool
|
|
|
|
isI32IntU10Immediate(ConstantSDNode *CN)
|
|
|
|
{
|
2008-09-26 21:54:37 +00:00
|
|
|
return isU10Constant(CN->getSExtValue());
|
2007-12-17 22:32:34 +00:00
|
|
|
}
|
|
|
|
|
2007-12-04 22:23:35 +00:00
|
|
|
//! ConstantSDNode predicate for i16 sign-extended, 10-bit immediate values
|
|
|
|
bool
|
|
|
|
isI16IntS10Immediate(ConstantSDNode *CN)
|
|
|
|
{
|
2008-09-26 21:54:37 +00:00
|
|
|
return isS10Constant(CN->getSExtValue());
|
2007-12-04 22:23:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//! SDNode predicate for i16 sign-extended, 10-bit immediate values
|
|
|
|
bool
|
|
|
|
isI16IntS10Immediate(SDNode *N)
|
|
|
|
{
|
|
|
|
return (N->getOpcode() == ISD::Constant
|
|
|
|
&& isI16IntS10Immediate(cast<ConstantSDNode>(N)));
|
|
|
|
}
|
|
|
|
|
2007-12-15 00:38:50 +00:00
|
|
|
//! ConstantSDNode predicate for i16 unsigned 10-bit immediate values
|
|
|
|
bool
|
|
|
|
isI16IntU10Immediate(ConstantSDNode *CN)
|
|
|
|
{
|
2008-09-12 16:56:44 +00:00
|
|
|
return isU10Constant((short) CN->getZExtValue());
|
2007-12-15 00:38:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//! SDNode predicate for i16 sign-extended, 10-bit immediate values
|
|
|
|
bool
|
|
|
|
isI16IntU10Immediate(SDNode *N)
|
|
|
|
{
|
|
|
|
return (N->getOpcode() == ISD::Constant
|
|
|
|
&& isI16IntU10Immediate(cast<ConstantSDNode>(N)));
|
|
|
|
}
|
|
|
|
|
2007-12-04 22:23:35 +00:00
|
|
|
//! ConstantSDNode predicate for signed 16-bit values
|
|
|
|
/*!
|
|
|
|
\arg CN The constant SelectionDAG node holding the value
|
|
|
|
\arg Imm The returned 16-bit value, if returning true
|
|
|
|
|
|
|
|
This predicate tests the value in \a CN to see whether it can be
|
|
|
|
represented as a 16-bit, sign-extended quantity. Returns true if
|
|
|
|
this is the case.
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
isIntS16Immediate(ConstantSDNode *CN, short &Imm)
|
|
|
|
{
|
2008-06-06 12:08:01 +00:00
|
|
|
MVT vt = CN->getValueType(0);
|
2008-09-12 16:56:44 +00:00
|
|
|
Imm = (short) CN->getZExtValue();
|
2008-06-08 20:54:56 +00:00
|
|
|
if (vt.getSimpleVT() >= MVT::i1 && vt.getSimpleVT() <= MVT::i16) {
|
2007-12-04 22:23:35 +00:00
|
|
|
return true;
|
|
|
|
} else if (vt == MVT::i32) {
|
2008-09-12 16:56:44 +00:00
|
|
|
int32_t i_val = (int32_t) CN->getZExtValue();
|
2007-12-04 22:23:35 +00:00
|
|
|
short s_val = (short) i_val;
|
|
|
|
return i_val == s_val;
|
|
|
|
} else {
|
2008-09-12 16:56:44 +00:00
|
|
|
int64_t i_val = (int64_t) CN->getZExtValue();
|
2007-12-04 22:23:35 +00:00
|
|
|
short s_val = (short) i_val;
|
|
|
|
return i_val == s_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! SDNode predicate for signed 16-bit values.
|
|
|
|
bool
|
|
|
|
isIntS16Immediate(SDNode *N, short &Imm)
|
|
|
|
{
|
|
|
|
return (N->getOpcode() == ISD::Constant
|
|
|
|
&& isIntS16Immediate(cast<ConstantSDNode>(N), Imm));
|
|
|
|
}
|
|
|
|
|
|
|
|
//! ConstantFPSDNode predicate for representing floats as 16-bit sign ext.
|
|
|
|
static bool
|
|
|
|
isFPS16Immediate(ConstantFPSDNode *FPN, short &Imm)
|
|
|
|
{
|
2008-06-06 12:08:01 +00:00
|
|
|
MVT vt = FPN->getValueType(0);
|
2007-12-04 22:23:35 +00:00
|
|
|
if (vt == MVT::f32) {
|
2007-12-22 22:45:38 +00:00
|
|
|
int val = FloatToBits(FPN->getValueAPF().convertToFloat());
|
2007-12-04 22:23:35 +00:00
|
|
|
int sval = (int) ((val << 16) >> 16);
|
|
|
|
Imm = (short) val;
|
|
|
|
return val == sval;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-01-29 02:16:57 +00:00
|
|
|
bool
|
2008-07-27 21:46:04 +00:00
|
|
|
isHighLow(const SDValue &Op)
|
2008-01-29 02:16:57 +00:00
|
|
|
{
|
|
|
|
return (Op.getOpcode() == SPUISD::IndirectAddr
|
|
|
|
&& ((Op.getOperand(0).getOpcode() == SPUISD::Hi
|
|
|
|
&& Op.getOperand(1).getOpcode() == SPUISD::Lo)
|
|
|
|
|| (Op.getOperand(0).getOpcode() == SPUISD::Lo
|
|
|
|
&& Op.getOperand(1).getOpcode() == SPUISD::Hi)));
|
|
|
|
}
|
|
|
|
|
2007-12-04 22:23:35 +00:00
|
|
|
//===------------------------------------------------------------------===//
|
2008-06-06 12:08:01 +00:00
|
|
|
//! MVT to "useful stuff" mapping structure:
|
2007-12-04 22:23:35 +00:00
|
|
|
|
|
|
|
struct valtype_map_s {
|
2008-06-06 12:08:01 +00:00
|
|
|
MVT VT;
|
2008-01-30 02:55:46 +00:00
|
|
|
unsigned ldresult_ins; /// LDRESULT instruction (0 = undefined)
|
2008-02-23 18:41:37 +00:00
|
|
|
bool ldresult_imm; /// LDRESULT instruction requires immediate?
|
2008-01-30 02:55:46 +00:00
|
|
|
int prefslot_byte; /// Byte offset of the "preferred" slot
|
2007-12-04 22:23:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const valtype_map_s valtype_map[] = {
|
2008-02-23 18:41:37 +00:00
|
|
|
{ MVT::i1, 0, false, 3 },
|
|
|
|
{ MVT::i8, SPU::ORBIr8, true, 3 },
|
|
|
|
{ MVT::i16, SPU::ORHIr16, true, 2 },
|
|
|
|
{ MVT::i32, SPU::ORIr32, true, 0 },
|
|
|
|
{ MVT::i64, SPU::ORr64, false, 0 },
|
|
|
|
{ MVT::f32, SPU::ORf32, false, 0 },
|
|
|
|
{ MVT::f64, SPU::ORf64, false, 0 },
|
2008-01-17 20:38:41 +00:00
|
|
|
// vector types... (sigh!)
|
2008-02-23 18:41:37 +00:00
|
|
|
{ MVT::v16i8, 0, false, 0 },
|
|
|
|
{ MVT::v8i16, 0, false, 0 },
|
|
|
|
{ MVT::v4i32, 0, false, 0 },
|
|
|
|
{ MVT::v2i64, 0, false, 0 },
|
|
|
|
{ MVT::v4f32, 0, false, 0 },
|
|
|
|
{ MVT::v2f64, 0, false, 0 }
|
2007-12-04 22:23:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const size_t n_valtype_map = sizeof(valtype_map) / sizeof(valtype_map[0]);
|
|
|
|
|
2008-06-06 12:08:01 +00:00
|
|
|
const valtype_map_s *getValueTypeMapEntry(MVT VT)
|
2007-12-04 22:23:35 +00:00
|
|
|
{
|
|
|
|
const valtype_map_s *retval = 0;
|
|
|
|
for (size_t i = 0; i < n_valtype_map; ++i) {
|
|
|
|
if (valtype_map[i].VT == VT) {
|
2008-01-30 02:55:46 +00:00
|
|
|
retval = valtype_map + i;
|
|
|
|
break;
|
2007-12-04 22:23:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
if (retval == 0) {
|
|
|
|
cerr << "SPUISelDAGToDAG.cpp: getValueTypeMapEntry returns NULL for "
|
2008-06-06 12:08:01 +00:00
|
|
|
<< VT.getMVTString()
|
2008-01-30 02:55:46 +00:00
|
|
|
<< "\n";
|
2007-12-04 22:23:35 +00:00
|
|
|
abort();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-13 00:00:25 +00:00
|
|
|
namespace {
|
|
|
|
|
2007-12-04 22:23:35 +00:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
/// SPUDAGToDAGISel - Cell SPU-specific code to select SPU machine
|
|
|
|
/// instructions for SelectionDAG operations.
|
|
|
|
///
|
|
|
|
class SPUDAGToDAGISel :
|
|
|
|
public SelectionDAGISel
|
|
|
|
{
|
|
|
|
SPUTargetMachine &TM;
|
|
|
|
SPUTargetLowering &SPUtli;
|
|
|
|
unsigned GlobalBaseReg;
|
|
|
|
|
|
|
|
public:
|
2008-07-07 18:00:37 +00:00
|
|
|
explicit SPUDAGToDAGISel(SPUTargetMachine &tm) :
|
2007-12-04 22:23:35 +00:00
|
|
|
SelectionDAGISel(*tm.getTargetLowering()),
|
|
|
|
TM(tm),
|
|
|
|
SPUtli(*tm.getTargetLowering())
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual bool runOnFunction(Function &Fn) {
|
|
|
|
// Make sure we re-emit a set of the global base reg if necessary
|
|
|
|
GlobalBaseReg = 0;
|
|
|
|
SelectionDAGISel::runOnFunction(Fn);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// getI32Imm - Return a target constant with the specified value, of type
|
|
|
|
/// i32.
|
2008-07-27 21:46:04 +00:00
|
|
|
inline SDValue getI32Imm(uint32_t Imm) {
|
2007-12-04 22:23:35 +00:00
|
|
|
return CurDAG->getTargetConstant(Imm, MVT::i32);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// getI64Imm - Return a target constant with the specified value, of type
|
|
|
|
/// i64.
|
2008-07-27 21:46:04 +00:00
|
|
|
inline SDValue getI64Imm(uint64_t Imm) {
|
2007-12-04 22:23:35 +00:00
|
|
|
return CurDAG->getTargetConstant(Imm, MVT::i64);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// getSmallIPtrImm - Return a target constant of pointer type.
|
2008-07-27 21:46:04 +00:00
|
|
|
inline SDValue getSmallIPtrImm(unsigned Imm) {
|
2007-12-04 22:23:35 +00:00
|
|
|
return CurDAG->getTargetConstant(Imm, SPUtli.getPointerTy());
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Select - Convert the specified operand from a target-independent to a
|
|
|
|
/// target-specific node if it hasn't already been changed.
|
2008-07-27 21:46:04 +00:00
|
|
|
SDNode *Select(SDValue Op);
|
2007-12-04 22:23:35 +00:00
|
|
|
|
|
|
|
//! Returns true if the address N is an A-form (local store) address
|
2008-07-27 21:46:04 +00:00
|
|
|
bool SelectAFormAddr(SDValue Op, SDValue N, SDValue &Base,
|
|
|
|
SDValue &Index);
|
2007-12-04 22:23:35 +00:00
|
|
|
|
|
|
|
//! D-form address predicate
|
2008-07-27 21:46:04 +00:00
|
|
|
bool SelectDFormAddr(SDValue Op, SDValue N, SDValue &Base,
|
|
|
|
SDValue &Index);
|
2008-01-30 02:55:46 +00:00
|
|
|
|
|
|
|
/// Alternate D-form address using i7 offset predicate
|
2008-07-27 21:46:04 +00:00
|
|
|
bool SelectDForm2Addr(SDValue Op, SDValue N, SDValue &Disp,
|
|
|
|
SDValue &Base);
|
2008-01-30 02:55:46 +00:00
|
|
|
|
|
|
|
/// D-form address selection workhorse
|
2008-07-27 21:46:04 +00:00
|
|
|
bool DFormAddressPredicate(SDValue Op, SDValue N, SDValue &Disp,
|
|
|
|
SDValue &Base, int minOffset, int maxOffset);
|
2007-12-04 22:23:35 +00:00
|
|
|
|
|
|
|
//! Address predicate if N can be expressed as an indexed [r+r] operation.
|
2008-07-27 21:46:04 +00:00
|
|
|
bool SelectXFormAddr(SDValue Op, SDValue N, SDValue &Base,
|
|
|
|
SDValue &Index);
|
2007-12-04 22:23:35 +00:00
|
|
|
|
|
|
|
/// SelectInlineAsmMemoryOperand - Implement addressing mode selection for
|
|
|
|
/// inline asm expressions.
|
2008-07-27 21:46:04 +00:00
|
|
|
virtual bool SelectInlineAsmMemoryOperand(const SDValue &Op,
|
2008-01-30 02:55:46 +00:00
|
|
|
char ConstraintCode,
|
2008-08-23 02:25:05 +00:00
|
|
|
std::vector<SDValue> &OutOps) {
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue Op0, Op1;
|
2007-12-04 22:23:35 +00:00
|
|
|
switch (ConstraintCode) {
|
|
|
|
default: return true;
|
|
|
|
case 'm': // memory
|
|
|
|
if (!SelectDFormAddr(Op, Op, Op0, Op1)
|
2008-01-30 02:55:46 +00:00
|
|
|
&& !SelectAFormAddr(Op, Op, Op0, Op1))
|
|
|
|
SelectXFormAddr(Op, Op, Op0, Op1);
|
2007-12-04 22:23:35 +00:00
|
|
|
break;
|
|
|
|
case 'o': // offsetable
|
|
|
|
if (!SelectDFormAddr(Op, Op, Op0, Op1)
|
2008-01-30 02:55:46 +00:00
|
|
|
&& !SelectAFormAddr(Op, Op, Op0, Op1)) {
|
|
|
|
Op0 = Op;
|
|
|
|
Op1 = getSmallIPtrImm(0);
|
2007-12-04 22:23:35 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'v': // not offsetable
|
|
|
|
#if 1
|
|
|
|
assert(0 && "InlineAsmMemoryOperand 'v' constraint not handled.");
|
|
|
|
#else
|
|
|
|
SelectAddrIdxOnly(Op, Op, Op0, Op1);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
OutOps.push_back(Op0);
|
|
|
|
OutOps.push_back(Op1);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-06-30 20:45:06 +00:00
|
|
|
/// InstructionSelect - This callback is invoked by
|
2007-12-04 22:23:35 +00:00
|
|
|
/// SelectionDAGISel when it has created a SelectionDAG for us to codegen.
|
2008-08-23 02:25:05 +00:00
|
|
|
virtual void InstructionSelect();
|
2007-12-04 22:23:35 +00:00
|
|
|
|
|
|
|
virtual const char *getPassName() const {
|
|
|
|
return "Cell SPU DAG->DAG Pattern Instruction Selection";
|
|
|
|
}
|
|
|
|
|
|
|
|
/// CreateTargetHazardRecognizer - Return the hazard recognizer to use for
|
|
|
|
/// this target when scheduling the DAG.
|
|
|
|
virtual HazardRecognizer *CreateTargetHazardRecognizer() {
|
2008-09-04 15:39:15 +00:00
|
|
|
const TargetInstrInfo *II = TM.getInstrInfo();
|
2007-12-04 22:23:35 +00:00
|
|
|
assert(II && "No InstrInfo?");
|
|
|
|
return new SPUHazardRecognizer(*II);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Include the pieces autogenerated from the target description.
|
|
|
|
#include "SPUGenDAGISel.inc"
|
|
|
|
};
|
|
|
|
|
2008-05-13 00:00:25 +00:00
|
|
|
}
|
|
|
|
|
2008-06-30 20:45:06 +00:00
|
|
|
/// InstructionSelect - This callback is invoked by
|
2007-12-04 22:23:35 +00:00
|
|
|
/// SelectionDAGISel when it has created a SelectionDAG for us to codegen.
|
|
|
|
void
|
2008-08-23 02:25:05 +00:00
|
|
|
SPUDAGToDAGISel::InstructionSelect()
|
2007-12-04 22:23:35 +00:00
|
|
|
{
|
|
|
|
DEBUG(BB->dump());
|
|
|
|
|
|
|
|
// Select target instructions for the DAG.
|
2008-10-27 21:56:29 +00:00
|
|
|
SelectRoot(*CurDAG);
|
2008-08-23 02:25:05 +00:00
|
|
|
CurDAG->RemoveDeadNodes();
|
2007-12-04 22:23:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\arg Op The ISD instructio operand
|
|
|
|
\arg N The address to be tested
|
|
|
|
\arg Base The base address
|
|
|
|
\arg Index The base address index
|
|
|
|
*/
|
|
|
|
bool
|
2008-07-27 21:46:04 +00:00
|
|
|
SPUDAGToDAGISel::SelectAFormAddr(SDValue Op, SDValue N, SDValue &Base,
|
|
|
|
SDValue &Index) {
|
2007-12-04 22:23:35 +00:00
|
|
|
// These match the addr256k operand type:
|
2008-06-06 12:08:01 +00:00
|
|
|
MVT OffsVT = MVT::i16;
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue Zero = CurDAG->getTargetConstant(0, OffsVT);
|
2007-12-04 22:23:35 +00:00
|
|
|
|
|
|
|
switch (N.getOpcode()) {
|
|
|
|
case ISD::Constant:
|
2008-01-11 02:53:15 +00:00
|
|
|
case ISD::ConstantPool:
|
|
|
|
case ISD::GlobalAddress:
|
|
|
|
cerr << "SPU SelectAFormAddr: Constant/Pool/Global not lowered.\n";
|
|
|
|
abort();
|
|
|
|
/*NOTREACHED*/
|
|
|
|
|
2008-01-29 02:16:57 +00:00
|
|
|
case ISD::TargetConstant:
|
2008-01-11 02:53:15 +00:00
|
|
|
case ISD::TargetGlobalAddress:
|
2008-01-29 02:16:57 +00:00
|
|
|
case ISD::TargetJumpTable:
|
|
|
|
cerr << "SPUSelectAFormAddr: Target Constant/Pool/Global not wrapped as "
|
|
|
|
<< "A-form address.\n";
|
|
|
|
abort();
|
|
|
|
/*NOTREACHED*/
|
2007-12-04 22:23:35 +00:00
|
|
|
|
2008-01-29 02:16:57 +00:00
|
|
|
case SPUISD::AFormAddr:
|
|
|
|
// Just load from memory if there's only a single use of the location,
|
|
|
|
// otherwise, this will get handled below with D-form offset addresses
|
|
|
|
if (N.hasOneUse()) {
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue Op0 = N.getOperand(0);
|
2008-01-29 02:16:57 +00:00
|
|
|
switch (Op0.getOpcode()) {
|
|
|
|
case ISD::TargetConstantPool:
|
|
|
|
case ISD::TargetJumpTable:
|
|
|
|
Base = Op0;
|
|
|
|
Index = Zero;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case ISD::TargetGlobalAddress: {
|
|
|
|
GlobalAddressSDNode *GSDN = cast<GlobalAddressSDNode>(Op0);
|
|
|
|
GlobalValue *GV = GSDN->getGlobal();
|
|
|
|
if (GV->getAlignment() == 16) {
|
|
|
|
Base = Op0;
|
|
|
|
Index = Zero;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2007-12-04 22:23:35 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-01-30 02:55:46 +00:00
|
|
|
bool
|
2008-07-27 21:46:04 +00:00
|
|
|
SPUDAGToDAGISel::SelectDForm2Addr(SDValue Op, SDValue N, SDValue &Disp,
|
|
|
|
SDValue &Base) {
|
2008-04-30 00:30:08 +00:00
|
|
|
const int minDForm2Offset = -(1 << 7);
|
|
|
|
const int maxDForm2Offset = (1 << 7) - 1;
|
|
|
|
return DFormAddressPredicate(Op, N, Disp, Base, minDForm2Offset,
|
|
|
|
maxDForm2Offset);
|
2008-01-30 02:55:46 +00:00
|
|
|
}
|
|
|
|
|
2007-12-04 22:23:35 +00:00
|
|
|
/*!
|
|
|
|
\arg Op The ISD instruction (ignored)
|
|
|
|
\arg N The address to be tested
|
|
|
|
\arg Base Base address register/pointer
|
|
|
|
\arg Index Base address index
|
|
|
|
|
|
|
|
Examine the input address by a base register plus a signed 10-bit
|
|
|
|
displacement, [r+I10] (D-form address).
|
|
|
|
|
|
|
|
\return true if \a N is a D-form address with \a Base and \a Index set
|
2008-07-27 21:46:04 +00:00
|
|
|
to non-empty SDValue instances.
|
2007-12-04 22:23:35 +00:00
|
|
|
*/
|
|
|
|
bool
|
2008-07-27 21:46:04 +00:00
|
|
|
SPUDAGToDAGISel::SelectDFormAddr(SDValue Op, SDValue N, SDValue &Base,
|
|
|
|
SDValue &Index) {
|
2008-01-30 02:55:46 +00:00
|
|
|
return DFormAddressPredicate(Op, N, Base, Index,
|
2008-11-21 02:56:16 +00:00
|
|
|
SPUFrameInfo::minFrameOffset(),
|
|
|
|
SPUFrameInfo::maxFrameOffset());
|
2008-01-30 02:55:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2008-07-27 21:46:04 +00:00
|
|
|
SPUDAGToDAGISel::DFormAddressPredicate(SDValue Op, SDValue N, SDValue &Base,
|
|
|
|
SDValue &Index, int minOffset,
|
2008-01-30 02:55:46 +00:00
|
|
|
int maxOffset) {
|
2007-12-04 22:23:35 +00:00
|
|
|
unsigned Opc = N.getOpcode();
|
2008-06-06 12:08:01 +00:00
|
|
|
MVT PtrTy = SPUtli.getPointerTy();
|
2007-12-04 22:23:35 +00:00
|
|
|
|
2008-01-29 02:16:57 +00:00
|
|
|
if (Opc == ISD::FrameIndex) {
|
|
|
|
// Stack frame index must be less than 512 (divided by 16):
|
2008-04-30 00:30:08 +00:00
|
|
|
FrameIndexSDNode *FIN = dyn_cast<FrameIndexSDNode>(N);
|
|
|
|
int FI = int(FIN->getIndex());
|
2007-12-04 22:23:35 +00:00
|
|
|
DEBUG(cerr << "SelectDFormAddr: ISD::FrameIndex = "
|
2008-04-30 00:30:08 +00:00
|
|
|
<< FI << "\n");
|
|
|
|
if (SPUFrameInfo::FItoStackOffset(FI) < maxOffset) {
|
2007-12-04 22:23:35 +00:00
|
|
|
Base = CurDAG->getTargetConstant(0, PtrTy);
|
2008-04-30 00:30:08 +00:00
|
|
|
Index = CurDAG->getTargetFrameIndex(FI, PtrTy);
|
2007-12-04 22:23:35 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} else if (Opc == ISD::ADD) {
|
|
|
|
// Generated by getelementptr
|
2008-07-27 21:46:04 +00:00
|
|
|
const SDValue Op0 = N.getOperand(0);
|
|
|
|
const SDValue Op1 = N.getOperand(1);
|
2007-12-04 22:23:35 +00:00
|
|
|
|
2008-01-29 02:16:57 +00:00
|
|
|
if ((Op0.getOpcode() == SPUISD::Hi && Op1.getOpcode() == SPUISD::Lo)
|
|
|
|
|| (Op1.getOpcode() == SPUISD::Hi && Op0.getOpcode() == SPUISD::Lo)) {
|
|
|
|
Base = CurDAG->getTargetConstant(0, PtrTy);
|
|
|
|
Index = N;
|
|
|
|
return true;
|
|
|
|
} else if (Op1.getOpcode() == ISD::Constant
|
|
|
|
|| Op1.getOpcode() == ISD::TargetConstant) {
|
2008-01-11 02:53:15 +00:00
|
|
|
ConstantSDNode *CN = dyn_cast<ConstantSDNode>(Op1);
|
2008-09-26 21:54:37 +00:00
|
|
|
int32_t offset = int32_t(CN->getSExtValue());
|
2007-12-04 22:23:35 +00:00
|
|
|
|
2008-01-29 02:16:57 +00:00
|
|
|
if (Op0.getOpcode() == ISD::FrameIndex) {
|
2008-04-30 00:30:08 +00:00
|
|
|
FrameIndexSDNode *FIN = dyn_cast<FrameIndexSDNode>(Op0);
|
|
|
|
int FI = int(FIN->getIndex());
|
2008-01-11 02:53:15 +00:00
|
|
|
DEBUG(cerr << "SelectDFormAddr: ISD::ADD offset = " << offset
|
2008-04-30 00:30:08 +00:00
|
|
|
<< " frame index = " << FI << "\n");
|
2008-01-11 02:53:15 +00:00
|
|
|
|
2008-04-30 00:30:08 +00:00
|
|
|
if (SPUFrameInfo::FItoStackOffset(FI) < maxOffset) {
|
2008-01-11 02:53:15 +00:00
|
|
|
Base = CurDAG->getTargetConstant(offset, PtrTy);
|
2008-04-30 00:30:08 +00:00
|
|
|
Index = CurDAG->getTargetFrameIndex(FI, PtrTy);
|
2008-01-11 02:53:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
2008-01-30 02:55:46 +00:00
|
|
|
} else if (offset > minOffset && offset < maxOffset) {
|
2008-01-11 02:53:15 +00:00
|
|
|
Base = CurDAG->getTargetConstant(offset, PtrTy);
|
2008-01-29 02:16:57 +00:00
|
|
|
Index = Op0;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} else if (Op0.getOpcode() == ISD::Constant
|
|
|
|
|| Op0.getOpcode() == ISD::TargetConstant) {
|
|
|
|
ConstantSDNode *CN = dyn_cast<ConstantSDNode>(Op0);
|
2008-09-26 21:54:37 +00:00
|
|
|
int32_t offset = int32_t(CN->getSExtValue());
|
2008-01-29 02:16:57 +00:00
|
|
|
|
|
|
|
if (Op1.getOpcode() == ISD::FrameIndex) {
|
2008-04-30 00:30:08 +00:00
|
|
|
FrameIndexSDNode *FIN = dyn_cast<FrameIndexSDNode>(Op1);
|
|
|
|
int FI = int(FIN->getIndex());
|
2008-01-29 02:16:57 +00:00
|
|
|
DEBUG(cerr << "SelectDFormAddr: ISD::ADD offset = " << offset
|
2008-04-30 00:30:08 +00:00
|
|
|
<< " frame index = " << FI << "\n");
|
2008-01-29 02:16:57 +00:00
|
|
|
|
2008-04-30 00:30:08 +00:00
|
|
|
if (SPUFrameInfo::FItoStackOffset(FI) < maxOffset) {
|
2008-01-29 02:16:57 +00:00
|
|
|
Base = CurDAG->getTargetConstant(offset, PtrTy);
|
2008-04-30 00:30:08 +00:00
|
|
|
Index = CurDAG->getTargetFrameIndex(FI, PtrTy);
|
2008-01-11 02:53:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
2008-01-30 02:55:46 +00:00
|
|
|
} else if (offset > minOffset && offset < maxOffset) {
|
2008-01-29 02:16:57 +00:00
|
|
|
Base = CurDAG->getTargetConstant(offset, PtrTy);
|
|
|
|
Index = Op1;
|
|
|
|
return true;
|
2007-12-04 22:23:35 +00:00
|
|
|
}
|
2008-01-11 21:01:19 +00:00
|
|
|
}
|
2008-01-29 02:16:57 +00:00
|
|
|
} else if (Opc == SPUISD::IndirectAddr) {
|
|
|
|
// Indirect with constant offset -> D-Form address
|
2008-07-27 21:46:04 +00:00
|
|
|
const SDValue Op0 = N.getOperand(0);
|
|
|
|
const SDValue Op1 = N.getOperand(1);
|
2008-01-29 02:16:57 +00:00
|
|
|
|
2008-01-30 02:55:46 +00:00
|
|
|
if (Op0.getOpcode() == SPUISD::Hi
|
|
|
|
&& Op1.getOpcode() == SPUISD::Lo) {
|
2008-01-29 02:16:57 +00:00
|
|
|
// (SPUindirect (SPUhi <arg>, 0), (SPUlo <arg>, 0))
|
2008-01-11 02:53:15 +00:00
|
|
|
Base = CurDAG->getTargetConstant(0, PtrTy);
|
2008-01-29 02:16:57 +00:00
|
|
|
Index = N;
|
2008-01-11 02:53:15 +00:00
|
|
|
return true;
|
2008-01-30 02:55:46 +00:00
|
|
|
} else if (isa<ConstantSDNode>(Op0) || isa<ConstantSDNode>(Op1)) {
|
|
|
|
int32_t offset = 0;
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue idxOp;
|
2008-01-30 02:55:46 +00:00
|
|
|
|
|
|
|
if (isa<ConstantSDNode>(Op1)) {
|
|
|
|
ConstantSDNode *CN = cast<ConstantSDNode>(Op1);
|
2008-09-26 21:54:37 +00:00
|
|
|
offset = int32_t(CN->getSExtValue());
|
2008-01-30 02:55:46 +00:00
|
|
|
idxOp = Op0;
|
|
|
|
} else if (isa<ConstantSDNode>(Op0)) {
|
|
|
|
ConstantSDNode *CN = cast<ConstantSDNode>(Op0);
|
2008-09-26 21:54:37 +00:00
|
|
|
offset = int32_t(CN->getSExtValue());
|
2008-01-30 02:55:46 +00:00
|
|
|
idxOp = Op1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (offset >= minOffset && offset <= maxOffset) {
|
|
|
|
Base = CurDAG->getTargetConstant(offset, PtrTy);
|
|
|
|
Index = idxOp;
|
|
|
|
return true;
|
|
|
|
}
|
2008-01-11 02:53:15 +00:00
|
|
|
}
|
2008-01-29 02:16:57 +00:00
|
|
|
} else if (Opc == SPUISD::AFormAddr) {
|
|
|
|
Base = CurDAG->getTargetConstant(0, N.getValueType());
|
|
|
|
Index = N;
|
2008-01-17 20:38:41 +00:00
|
|
|
return true;
|
2008-01-30 02:55:46 +00:00
|
|
|
} else if (Opc == SPUISD::LDRESULT) {
|
|
|
|
Base = CurDAG->getTargetConstant(0, N.getValueType());
|
|
|
|
Index = N;
|
|
|
|
return true;
|
2008-11-21 02:56:16 +00:00
|
|
|
} else if (Opc == ISD::Register || Opc == ISD::CopyFromReg) {
|
|
|
|
unsigned OpOpc = Op.getOpcode();
|
|
|
|
|
|
|
|
if (OpOpc == ISD::STORE || OpOpc == ISD::LOAD) {
|
|
|
|
// Direct load/store without getelementptr
|
|
|
|
SDValue Addr, Offs;
|
|
|
|
|
|
|
|
// Get the register from CopyFromReg
|
|
|
|
if (Opc == ISD::CopyFromReg)
|
|
|
|
Addr = N.getOperand(1);
|
|
|
|
else
|
|
|
|
Addr = N; // Register
|
|
|
|
|
2008-12-10 00:15:19 +00:00
|
|
|
Offs = ((OpOpc == ISD::STORE) ? Op.getOperand(3) : Op.getOperand(2));
|
2008-11-21 02:56:16 +00:00
|
|
|
|
|
|
|
if (Offs.getOpcode() == ISD::Constant || Offs.getOpcode() == ISD::UNDEF) {
|
|
|
|
if (Offs.getOpcode() == ISD::UNDEF)
|
|
|
|
Offs = CurDAG->getTargetConstant(0, Offs.getValueType());
|
|
|
|
|
|
|
|
Base = Offs;
|
|
|
|
Index = Addr;
|
|
|
|
return true;
|
|
|
|
}
|
2008-12-10 00:15:19 +00:00
|
|
|
} else {
|
|
|
|
/* If otherwise unadorned, default to D-form address with 0 offset: */
|
|
|
|
if (Opc == ISD::CopyFromReg) {
|
|
|
|
Index = N.getOperand(1);
|
|
|
|
} else {
|
|
|
|
Index = N;
|
|
|
|
}
|
|
|
|
|
|
|
|
Base = CurDAG->getTargetConstant(0, Index.getValueType());
|
|
|
|
return true;
|
2008-11-21 02:56:16 +00:00
|
|
|
}
|
2007-12-04 22:23:35 +00:00
|
|
|
}
|
2008-11-21 02:56:16 +00:00
|
|
|
|
2007-12-04 22:23:35 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\arg Op The ISD instruction operand
|
|
|
|
\arg N The address operand
|
|
|
|
\arg Base The base pointer operand
|
|
|
|
\arg Index The offset/index operand
|
|
|
|
|
2008-11-21 02:56:16 +00:00
|
|
|
If the address \a N can be expressed as an A-form or D-form address, returns
|
|
|
|
false. Otherwise, creates two operands, Base and Index that will become the
|
|
|
|
(r)(r) X-form address.
|
2007-12-04 22:23:35 +00:00
|
|
|
*/
|
|
|
|
bool
|
2008-07-27 21:46:04 +00:00
|
|
|
SPUDAGToDAGISel::SelectXFormAddr(SDValue Op, SDValue N, SDValue &Base,
|
|
|
|
SDValue &Index) {
|
2008-11-21 02:56:16 +00:00
|
|
|
if (!SelectAFormAddr(Op, N, Base, Index)
|
|
|
|
&& !SelectDFormAddr(Op, N, Base, Index)) {
|
2008-11-25 17:29:43 +00:00
|
|
|
// If the address is neither A-form or D-form, punt and use an X-form
|
|
|
|
// address:
|
2008-12-01 17:56:02 +00:00
|
|
|
Base = N.getOperand(1);
|
|
|
|
Index = N.getOperand(0);
|
2008-11-25 04:03:47 +00:00
|
|
|
return true;
|
2008-11-21 02:56:16 +00:00
|
|
|
}
|
2007-12-04 22:23:35 +00:00
|
|
|
|
2008-11-21 02:56:16 +00:00
|
|
|
return false;
|
2008-01-17 20:38:41 +00:00
|
|
|
}
|
|
|
|
|
2007-12-04 22:23:35 +00:00
|
|
|
//! Convert the operand from a target-independent to a target-specific node
|
|
|
|
/*!
|
|
|
|
*/
|
|
|
|
SDNode *
|
2008-07-27 21:46:04 +00:00
|
|
|
SPUDAGToDAGISel::Select(SDValue Op) {
|
2008-08-28 21:40:38 +00:00
|
|
|
SDNode *N = Op.getNode();
|
2007-12-04 22:23:35 +00:00
|
|
|
unsigned Opc = N->getOpcode();
|
2008-01-17 20:38:41 +00:00
|
|
|
int n_ops = -1;
|
|
|
|
unsigned NewOpc;
|
2008-06-06 12:08:01 +00:00
|
|
|
MVT OpVT = Op.getValueType();
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue Ops[8];
|
2007-12-04 22:23:35 +00:00
|
|
|
|
2008-07-17 19:10:17 +00:00
|
|
|
if (N->isMachineOpcode()) {
|
2007-12-04 22:23:35 +00:00
|
|
|
return NULL; // Already selected.
|
|
|
|
} else if (Opc == ISD::FrameIndex) {
|
2008-04-30 00:30:08 +00:00
|
|
|
// Selects to (add $sp, FI * stackSlotSize)
|
|
|
|
int FI =
|
|
|
|
SPUFrameInfo::FItoStackOffset(cast<FrameIndexSDNode>(N)->getIndex());
|
2008-06-06 12:08:01 +00:00
|
|
|
MVT PtrVT = SPUtli.getPointerTy();
|
2008-04-30 00:30:08 +00:00
|
|
|
|
|
|
|
// Adjust stack slot to actual offset in frame:
|
|
|
|
if (isS10Constant(FI)) {
|
|
|
|
DEBUG(cerr << "SPUDAGToDAGISel: Replacing FrameIndex with AIr32 $sp, "
|
|
|
|
<< FI
|
|
|
|
<< "\n");
|
|
|
|
NewOpc = SPU::AIr32;
|
|
|
|
Ops[0] = CurDAG->getRegister(SPU::R1, PtrVT);
|
|
|
|
Ops[1] = CurDAG->getTargetConstant(FI, PtrVT);
|
|
|
|
n_ops = 2;
|
|
|
|
} else {
|
|
|
|
DEBUG(cerr << "SPUDAGToDAGISel: Replacing FrameIndex with Ar32 $sp, "
|
|
|
|
<< FI
|
|
|
|
<< "\n");
|
|
|
|
NewOpc = SPU::Ar32;
|
|
|
|
Ops[0] = CurDAG->getRegister(SPU::R1, PtrVT);
|
|
|
|
Ops[1] = CurDAG->getConstant(FI, PtrVT);
|
|
|
|
n_ops = 2;
|
|
|
|
}
|
2008-01-17 20:38:41 +00:00
|
|
|
} else if (Opc == ISD::ZERO_EXTEND) {
|
|
|
|
// (zero_extend:i16 (and:i8 <arg>, <const>))
|
2008-07-27 21:46:04 +00:00
|
|
|
const SDValue &Op1 = N->getOperand(0);
|
2008-01-17 20:38:41 +00:00
|
|
|
|
|
|
|
if (Op.getValueType() == MVT::i16 && Op1.getValueType() == MVT::i8) {
|
|
|
|
if (Op1.getOpcode() == ISD::AND) {
|
|
|
|
// Fold this into a single ANDHI. This is often seen in expansions of i1
|
|
|
|
// to i8, then i8 to i16 in logical/branching operations.
|
|
|
|
DEBUG(cerr << "CellSPU: Coalescing (zero_extend:i16 (and:i8 "
|
|
|
|
"<arg>, <const>))\n");
|
2008-02-23 18:41:37 +00:00
|
|
|
NewOpc = SPU::ANDHIi8i16;
|
2008-01-17 20:38:41 +00:00
|
|
|
Ops[0] = Op1.getOperand(0);
|
|
|
|
Ops[1] = Op1.getOperand(1);
|
|
|
|
n_ops = 2;
|
|
|
|
}
|
|
|
|
}
|
2007-12-04 22:23:35 +00:00
|
|
|
} else if (Opc == SPUISD::LDRESULT) {
|
|
|
|
// Custom select instructions for LDRESULT
|
2008-06-06 12:08:01 +00:00
|
|
|
MVT VT = N->getValueType(0);
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue Arg = N->getOperand(0);
|
|
|
|
SDValue Chain = N->getOperand(1);
|
2007-12-04 22:23:35 +00:00
|
|
|
SDNode *Result;
|
2008-02-23 18:41:37 +00:00
|
|
|
const valtype_map_s *vtm = getValueTypeMapEntry(VT);
|
|
|
|
|
|
|
|
if (vtm->ldresult_ins == 0) {
|
|
|
|
cerr << "LDRESULT for unsupported type: "
|
2008-06-06 12:08:01 +00:00
|
|
|
<< VT.getMVTString()
|
2008-02-23 18:41:37 +00:00
|
|
|
<< "\n";
|
|
|
|
abort();
|
|
|
|
}
|
2007-12-04 22:23:35 +00:00
|
|
|
|
2008-02-23 18:41:37 +00:00
|
|
|
Opc = vtm->ldresult_ins;
|
|
|
|
if (vtm->ldresult_imm) {
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue Zero = CurDAG->getTargetConstant(0, VT);
|
2007-12-20 00:44:13 +00:00
|
|
|
|
2008-01-17 20:38:41 +00:00
|
|
|
Result = CurDAG->getTargetNode(Opc, VT, MVT::Other, Arg, Zero, Chain);
|
2007-12-20 00:44:13 +00:00
|
|
|
} else {
|
2008-12-04 03:02:42 +00:00
|
|
|
Result = CurDAG->getTargetNode(Opc, VT, MVT::Other, Arg, Arg, Chain);
|
2007-12-20 00:44:13 +00:00
|
|
|
}
|
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
Chain = SDValue(Result, 1);
|
2007-12-20 00:44:13 +00:00
|
|
|
|
2007-12-04 22:23:35 +00:00
|
|
|
return Result;
|
2008-01-29 02:16:57 +00:00
|
|
|
} else if (Opc == SPUISD::IndirectAddr) {
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue Op0 = Op.getOperand(0);
|
2008-01-30 02:55:46 +00:00
|
|
|
if (Op0.getOpcode() == SPUISD::LDRESULT) {
|
|
|
|
/* || Op0.getOpcode() == SPUISD::AFormAddr) */
|
|
|
|
// (IndirectAddr (LDRESULT, imm))
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue Op1 = Op.getOperand(1);
|
2008-06-06 12:08:01 +00:00
|
|
|
MVT VT = Op.getValueType();
|
2008-01-17 20:38:41 +00:00
|
|
|
|
2008-01-30 02:55:46 +00:00
|
|
|
DEBUG(cerr << "CellSPU: IndirectAddr(LDRESULT, imm):\nOp0 = ");
|
2008-08-28 21:40:38 +00:00
|
|
|
DEBUG(Op.getOperand(0).getNode()->dump(CurDAG));
|
2008-01-17 20:38:41 +00:00
|
|
|
DEBUG(cerr << "\nOp1 = ");
|
2008-08-28 21:40:38 +00:00
|
|
|
DEBUG(Op.getOperand(1).getNode()->dump(CurDAG));
|
2008-01-17 20:38:41 +00:00
|
|
|
DEBUG(cerr << "\n");
|
|
|
|
|
|
|
|
if (Op1.getOpcode() == ISD::Constant) {
|
|
|
|
ConstantSDNode *CN = cast<ConstantSDNode>(Op1);
|
2008-09-12 16:56:44 +00:00
|
|
|
Op1 = CurDAG->getTargetConstant(CN->getZExtValue(), VT);
|
2008-01-30 02:55:46 +00:00
|
|
|
NewOpc = (isI32IntS10Immediate(CN) ? SPU::AIr32 : SPU::Ar32);
|
|
|
|
Ops[0] = Op0;
|
|
|
|
Ops[1] = Op1;
|
|
|
|
n_ops = 2;
|
2008-01-17 20:38:41 +00:00
|
|
|
}
|
|
|
|
}
|
2007-12-04 22:23:35 +00:00
|
|
|
}
|
|
|
|
|
2008-01-17 20:38:41 +00:00
|
|
|
if (n_ops > 0) {
|
|
|
|
if (N->hasOneUse())
|
|
|
|
return CurDAG->SelectNodeTo(N, NewOpc, OpVT, Ops, n_ops);
|
|
|
|
else
|
|
|
|
return CurDAG->getTargetNode(NewOpc, OpVT, Ops, n_ops);
|
|
|
|
} else
|
|
|
|
return SelectCode(Op);
|
2007-12-04 22:23:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// createPPCISelDag - This pass converts a legalized DAG into a
|
|
|
|
/// SPU-specific DAG, ready for instruction scheduling.
|
|
|
|
///
|
|
|
|
FunctionPass *llvm::createSPUISelDag(SPUTargetMachine &TM) {
|
|
|
|
return new SPUDAGToDAGISel(TM);
|
|
|
|
}
|