2007-12-04 23:23:35 +01:00
|
|
|
//===-- SPUISelLowering.h - Cell SPU DAG Lowering Interface -----*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 21:36:04 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-12-04 23:23:35 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines the interfaces that Cell SPU uses to lower LLVM code into
|
|
|
|
// a selection DAG.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef SPU_ISELLOWERING_H
|
|
|
|
#define SPU_ISELLOWERING_H
|
|
|
|
|
|
|
|
#include "llvm/Target/TargetLowering.h"
|
|
|
|
#include "llvm/CodeGen/SelectionDAG.h"
|
|
|
|
#include "SPU.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
namespace SPUISD {
|
|
|
|
enum NodeType {
|
|
|
|
// Start the numbering where the builting ops and target ops leave off.
|
2008-09-23 20:42:32 +02:00
|
|
|
FIRST_NUMBER = ISD::BUILTIN_OP_END,
|
2008-12-31 00:28:25 +01:00
|
|
|
|
2007-12-04 23:23:35 +01:00
|
|
|
// Pseudo instructions:
|
|
|
|
RET_FLAG, ///< Return with flag, matched by bi instruction
|
2008-12-31 00:28:25 +01:00
|
|
|
|
2007-12-04 23:23:35 +01:00
|
|
|
Hi, ///< High address component (upper 16)
|
|
|
|
Lo, ///< Low address component (lower 16)
|
|
|
|
PCRelAddr, ///< Program counter relative address
|
2008-01-11 03:53:15 +01:00
|
|
|
AFormAddr, ///< A-form address (local store)
|
2008-01-29 03:16:57 +01:00
|
|
|
IndirectAddr, ///< D-Form "imm($r)" and X-form "$r($r)"
|
2007-12-04 23:23:35 +01:00
|
|
|
|
|
|
|
LDRESULT, ///< Load result (value, chain)
|
|
|
|
CALL, ///< CALL instruction
|
|
|
|
SHUFB, ///< Vector shuffle (permute)
|
2008-11-23 00:50:42 +01:00
|
|
|
SHUFFLE_MASK, ///< Shuffle mask
|
2008-01-30 03:55:46 +01:00
|
|
|
CNTB, ///< Count leading ones in bytes
|
2008-12-27 05:51:36 +01:00
|
|
|
PREFSLOT2VEC, ///< Promote scalar->vector
|
2008-11-24 18:11:17 +01:00
|
|
|
VEC2PREFSLOT, ///< Extract element 0
|
2008-02-23 19:41:37 +01:00
|
|
|
SHLQUAD_L_BITS, ///< Rotate quad left, by bits
|
|
|
|
SHLQUAD_L_BYTES, ///< Rotate quad left, by bytes
|
2008-01-30 03:55:46 +01:00
|
|
|
VEC_SHL, ///< Vector shift left
|
|
|
|
VEC_SRL, ///< Vector shift right (logical)
|
|
|
|
VEC_SRA, ///< Vector shift right (arithmetic)
|
|
|
|
VEC_ROTL, ///< Vector rotate left
|
|
|
|
VEC_ROTR, ///< Vector rotate right
|
|
|
|
ROTBYTES_LEFT, ///< Rotate bytes (loads -> ROTQBYI)
|
2008-06-03 00:18:03 +02:00
|
|
|
ROTBYTES_LEFT_BITS, ///< Rotate bytes left by bit shift count
|
|
|
|
SELECT_MASK, ///< Select Mask (FSM, FSMB, FSMH, FSMBI)
|
2008-01-30 03:55:46 +01:00
|
|
|
SELB, ///< Select bits -> (b & mask) | (a & ~mask)
|
2009-01-15 05:41:47 +01:00
|
|
|
// Markers: These aren't used to generate target-dependent nodes, but
|
|
|
|
// are used during instruction selection.
|
|
|
|
ADD64_MARKER, ///< i64 addition marker
|
|
|
|
SUB64_MARKER, ///< i64 subtraction marker
|
|
|
|
MUL64_MARKER, ///< i64 multiply marker
|
2008-01-30 03:55:46 +01:00
|
|
|
LAST_SPUISD ///< Last user-defined instruction
|
2007-12-04 23:23:35 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Predicates that are used for node matching:
|
|
|
|
namespace SPU {
|
2008-07-27 23:46:04 +02:00
|
|
|
SDValue get_vec_u18imm(SDNode *N, SelectionDAG &DAG,
|
2008-06-06 14:08:01 +02:00
|
|
|
MVT ValueType);
|
2008-07-27 23:46:04 +02:00
|
|
|
SDValue get_vec_i16imm(SDNode *N, SelectionDAG &DAG,
|
2008-06-06 14:08:01 +02:00
|
|
|
MVT ValueType);
|
2008-07-27 23:46:04 +02:00
|
|
|
SDValue get_vec_i10imm(SDNode *N, SelectionDAG &DAG,
|
2008-06-06 14:08:01 +02:00
|
|
|
MVT ValueType);
|
2008-07-27 23:46:04 +02:00
|
|
|
SDValue get_vec_i8imm(SDNode *N, SelectionDAG &DAG,
|
2008-06-06 14:08:01 +02:00
|
|
|
MVT ValueType);
|
2008-07-27 23:46:04 +02:00
|
|
|
SDValue get_ILHUvec_imm(SDNode *N, SelectionDAG &DAG,
|
2008-06-06 14:08:01 +02:00
|
|
|
MVT ValueType);
|
2008-07-27 23:46:04 +02:00
|
|
|
SDValue get_v4i32_imm(SDNode *N, SelectionDAG &DAG);
|
|
|
|
SDValue get_v2i64_imm(SDNode *N, SelectionDAG &DAG);
|
2009-01-15 05:41:47 +01:00
|
|
|
|
|
|
|
SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG,
|
|
|
|
const SPUTargetMachine &TM);
|
|
|
|
|
|
|
|
SDValue getBorrowGenerateShufMask(SelectionDAG &DAG);
|
|
|
|
SDValue getCarryGenerateShufMask(SelectionDAG &DAG);
|
2007-12-04 23:23:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
class SPUTargetMachine; // forward dec'l.
|
2008-12-31 00:28:25 +01:00
|
|
|
|
2007-12-04 23:23:35 +01:00
|
|
|
class SPUTargetLowering :
|
|
|
|
public TargetLowering
|
|
|
|
{
|
|
|
|
int VarArgsFrameIndex; // FrameIndex for start of varargs area.
|
|
|
|
int ReturnAddrIndex; // FrameIndex for return slot.
|
|
|
|
SPUTargetMachine &SPUTM;
|
|
|
|
|
|
|
|
public:
|
2009-01-15 05:41:47 +01:00
|
|
|
//! The venerable constructor
|
|
|
|
/*!
|
|
|
|
This is where the CellSPU backend sets operation handling (i.e., legal,
|
|
|
|
custom, expand or promote.)
|
|
|
|
*/
|
2007-12-04 23:23:35 +01:00
|
|
|
SPUTargetLowering(SPUTargetMachine &TM);
|
2008-12-31 00:28:25 +01:00
|
|
|
|
2009-01-15 05:41:47 +01:00
|
|
|
//! Get the target machine
|
|
|
|
SPUTargetMachine &getSPUTargetMachine() {
|
|
|
|
return SPUTM;
|
|
|
|
}
|
|
|
|
|
2007-12-04 23:23:35 +01:00
|
|
|
/// getTargetNodeName() - This method returns the name of a target specific
|
|
|
|
/// DAG node.
|
|
|
|
virtual const char *getTargetNodeName(unsigned Opcode) const;
|
2008-03-10 16:42:14 +01:00
|
|
|
|
|
|
|
/// getSetCCResultType - Return the ValueType for ISD::SETCC
|
2009-01-01 16:52:00 +01:00
|
|
|
virtual MVT getSetCCResultType(MVT VT) const;
|
2008-12-31 00:28:25 +01:00
|
|
|
|
2008-11-11 00:43:06 +01:00
|
|
|
//! Custom lowering hooks
|
2008-07-27 23:46:04 +02:00
|
|
|
virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG);
|
2008-11-11 00:43:06 +01:00
|
|
|
|
2008-12-01 12:39:25 +01:00
|
|
|
//! Custom lowering hook for nodes with illegal result types.
|
|
|
|
virtual void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results,
|
|
|
|
SelectionDAG &DAG);
|
|
|
|
|
2008-07-27 23:46:04 +02:00
|
|
|
virtual SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const;
|
2007-12-04 23:23:35 +01:00
|
|
|
|
2008-07-27 23:46:04 +02:00
|
|
|
virtual void computeMaskedBitsForTargetNode(const SDValue Op,
|
2008-02-13 23:28:48 +01:00
|
|
|
const APInt &Mask,
|
2008-12-31 00:28:25 +01:00
|
|
|
APInt &KnownZero,
|
2008-02-13 01:35:47 +01:00
|
|
|
APInt &KnownOne,
|
2007-12-04 23:23:35 +01:00
|
|
|
const SelectionDAG &DAG,
|
|
|
|
unsigned Depth = 0) const;
|
|
|
|
|
2008-12-27 05:51:36 +01:00
|
|
|
virtual unsigned ComputeNumSignBitsForTargetNode(SDValue Op,
|
|
|
|
unsigned Depth = 0) const;
|
|
|
|
|
2007-12-04 23:23:35 +01:00
|
|
|
ConstraintType getConstraintType(const std::string &ConstraintLetter) const;
|
|
|
|
|
2008-12-31 00:28:25 +01:00
|
|
|
std::pair<unsigned, const TargetRegisterClass*>
|
2007-12-04 23:23:35 +01:00
|
|
|
getRegForInlineAsmConstraint(const std::string &Constraint,
|
2008-06-06 14:08:01 +02:00
|
|
|
MVT VT) const;
|
2007-12-04 23:23:35 +01:00
|
|
|
|
2008-07-27 23:46:04 +02:00
|
|
|
void LowerAsmOperandForConstraint(SDValue Op, char ConstraintLetter,
|
2008-12-31 00:28:25 +01:00
|
|
|
bool hasMemory,
|
2008-07-27 23:46:04 +02:00
|
|
|
std::vector<SDValue> &Ops,
|
2008-04-30 02:30:08 +02:00
|
|
|
SelectionDAG &DAG) const;
|
|
|
|
|
2007-12-04 23:23:35 +01:00
|
|
|
/// isLegalAddressImmediate - Return true if the integer value can be used
|
|
|
|
/// as the offset of the target addressing mode.
|
|
|
|
virtual bool isLegalAddressImmediate(int64_t V, const Type *Ty) const;
|
|
|
|
virtual bool isLegalAddressImmediate(GlobalValue *) const;
|
Teach DAGCombine to fold constant offsets into GlobalAddress nodes,
and add a TargetLowering hook for it to use to determine when this
is legal (i.e. not in PIC mode, etc.)
This allows instruction selection to emit folded constant offsets
in more cases, such as the included testcase, eliminating the need
for explicit arithmetic instructions.
This eliminates the need for the C++ code in X86ISelDAGToDAG.cpp
that attempted to achieve the same effect, but wasn't as effective.
Also, fix handling of offsets in GlobalAddressSDNodes in several
places, including changing GlobalAddressSDNode's offset from
int to int64_t.
The Mips, Alpha, Sparc, and CellSPU targets appear to be
unaware of GlobalAddress offsets currently, so set the hook to
false on those targets.
llvm-svn: 57748
2008-10-18 04:06:02 +02:00
|
|
|
|
|
|
|
virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const;
|
2007-12-04 23:23:35 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|