2007-12-04 22:23:35 +00:00
|
|
|
//===-- SPUISelLowering.h - Cell SPU DAG Lowering Interface -----*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// 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 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 18:42:32 +00:00
|
|
|
FIRST_NUMBER = ISD::BUILTIN_OP_END,
|
2007-12-04 22:23:35 +00:00
|
|
|
|
|
|
|
// Pseudo instructions:
|
|
|
|
RET_FLAG, ///< Return with flag, matched by bi instruction
|
|
|
|
|
|
|
|
Hi, ///< High address component (upper 16)
|
|
|
|
Lo, ///< Low address component (lower 16)
|
|
|
|
PCRelAddr, ///< Program counter relative address
|
2008-01-11 02:53:15 +00:00
|
|
|
AFormAddr, ///< A-form address (local store)
|
2008-01-29 02:16:57 +00:00
|
|
|
IndirectAddr, ///< D-Form "imm($r)" and X-form "$r($r)"
|
2007-12-04 22:23:35 +00:00
|
|
|
|
|
|
|
LDRESULT, ///< Load result (value, chain)
|
|
|
|
CALL, ///< CALL instruction
|
|
|
|
SHUFB, ///< Vector shuffle (permute)
|
|
|
|
INSERT_MASK, ///< Insert element shuffle mask
|
2008-01-30 02:55:46 +00:00
|
|
|
CNTB, ///< Count leading ones in bytes
|
2007-12-04 22:23:35 +00:00
|
|
|
PROMOTE_SCALAR, ///< Promote scalar->vector
|
|
|
|
EXTRACT_ELT0, ///< Extract element 0
|
2008-01-30 02:55:46 +00:00
|
|
|
EXTRACT_ELT0_CHAINED, ///< Extract element 0, with chain
|
2007-12-04 22:23:35 +00:00
|
|
|
EXTRACT_I1_ZEXT, ///< Extract element 0 as i1, zero extend
|
|
|
|
EXTRACT_I1_SEXT, ///< Extract element 0 as i1, sign extend
|
|
|
|
EXTRACT_I8_ZEXT, ///< Extract element 0 as i8, zero extend
|
|
|
|
EXTRACT_I8_SEXT, ///< Extract element 0 as i8, sign extend
|
2008-01-30 02:55:46 +00:00
|
|
|
MPY, ///< 16-bit Multiply (low parts of a 32-bit)
|
|
|
|
MPYU, ///< Multiply Unsigned
|
|
|
|
MPYH, ///< Multiply High
|
|
|
|
MPYHH, ///< Multiply High-High
|
2008-02-23 18:41:37 +00:00
|
|
|
SHLQUAD_L_BITS, ///< Rotate quad left, by bits
|
|
|
|
SHLQUAD_L_BYTES, ///< Rotate quad left, by bytes
|
2008-01-30 02:55:46 +00: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
|
2008-02-23 18:41:37 +00:00
|
|
|
ROTQUAD_RZ_BYTES, ///< Rotate quad right, by bytes, zero fill
|
|
|
|
ROTQUAD_RZ_BITS, ///< Rotate quad right, by bits, zero fill
|
2007-12-04 22:23:35 +00:00
|
|
|
ROTBYTES_RIGHT_S, ///< Vector rotate right, by bytes, sign fill
|
2008-01-30 02:55:46 +00:00
|
|
|
ROTBYTES_LEFT, ///< Rotate bytes (loads -> ROTQBYI)
|
|
|
|
ROTBYTES_LEFT_CHAINED, ///< Rotate bytes (loads -> ROTQBYI), with chain
|
2008-06-02 22:18:03 +00:00
|
|
|
ROTBYTES_LEFT_BITS, ///< Rotate bytes left by bit shift count
|
|
|
|
SELECT_MASK, ///< Select Mask (FSM, FSMB, FSMH, FSMBI)
|
2008-01-30 02:55:46 +00:00
|
|
|
SELB, ///< Select bits -> (b & mask) | (a & ~mask)
|
2008-06-02 22:18:03 +00:00
|
|
|
ADD_EXTENDED, ///< Add extended, with carry
|
|
|
|
CARRY_GENERATE, ///< Carry generate for ADD_EXTENDED
|
|
|
|
SUB_EXTENDED, ///< Subtract extended, with borrow
|
|
|
|
BORROW_GENERATE, ///< Borrow generate for SUB_EXTENDED
|
2007-12-04 22:23:35 +00:00
|
|
|
FPInterp, ///< Floating point interpolate
|
2008-01-30 02:55:46 +00:00
|
|
|
FPRecipEst, ///< Floating point reciprocal estimate
|
|
|
|
SEXT32TO64, ///< Sign-extended 32-bit const -> 64-bits
|
|
|
|
LAST_SPUISD ///< Last user-defined instruction
|
2007-12-04 22:23:35 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Predicates that are used for node matching:
|
|
|
|
namespace SPU {
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue get_vec_u18imm(SDNode *N, SelectionDAG &DAG,
|
2008-06-06 12:08:01 +00:00
|
|
|
MVT ValueType);
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue get_vec_i16imm(SDNode *N, SelectionDAG &DAG,
|
2008-06-06 12:08:01 +00:00
|
|
|
MVT ValueType);
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue get_vec_i10imm(SDNode *N, SelectionDAG &DAG,
|
2008-06-06 12:08:01 +00:00
|
|
|
MVT ValueType);
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue get_vec_i8imm(SDNode *N, SelectionDAG &DAG,
|
2008-06-06 12:08:01 +00:00
|
|
|
MVT ValueType);
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue get_ILHUvec_imm(SDNode *N, SelectionDAG &DAG,
|
2008-06-06 12:08:01 +00:00
|
|
|
MVT ValueType);
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue get_v4i32_imm(SDNode *N, SelectionDAG &DAG);
|
|
|
|
SDValue get_v2i64_imm(SDNode *N, SelectionDAG &DAG);
|
2007-12-04 22:23:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class SPUTargetMachine; // forward dec'l.
|
|
|
|
|
|
|
|
class SPUTargetLowering :
|
|
|
|
public TargetLowering
|
|
|
|
{
|
|
|
|
int VarArgsFrameIndex; // FrameIndex for start of varargs area.
|
|
|
|
int ReturnAddrIndex; // FrameIndex for return slot.
|
|
|
|
SPUTargetMachine &SPUTM;
|
|
|
|
|
|
|
|
public:
|
|
|
|
SPUTargetLowering(SPUTargetMachine &TM);
|
|
|
|
|
|
|
|
/// getTargetNodeName() - This method returns the name of a target specific
|
|
|
|
/// DAG node.
|
|
|
|
virtual const char *getTargetNodeName(unsigned Opcode) const;
|
2008-03-10 15:42:14 +00:00
|
|
|
|
|
|
|
/// getSetCCResultType - Return the ValueType for ISD::SETCC
|
2008-07-27 21:46:04 +00:00
|
|
|
virtual MVT getSetCCResultType(const SDValue &) const;
|
2007-12-04 22:23:35 +00:00
|
|
|
|
|
|
|
/// LowerOperation - Provide custom lowering hooks for some operations.
|
|
|
|
///
|
2008-07-27 21:46:04 +00:00
|
|
|
virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG);
|
2007-12-04 22:23:35 +00:00
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
virtual SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const;
|
2007-12-04 22:23:35 +00:00
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
virtual void computeMaskedBitsForTargetNode(const SDValue Op,
|
2008-02-13 22:28:48 +00:00
|
|
|
const APInt &Mask,
|
2008-02-13 00:35:47 +00:00
|
|
|
APInt &KnownZero,
|
|
|
|
APInt &KnownOne,
|
2007-12-04 22:23:35 +00:00
|
|
|
const SelectionDAG &DAG,
|
|
|
|
unsigned Depth = 0) const;
|
|
|
|
|
|
|
|
ConstraintType getConstraintType(const std::string &ConstraintLetter) const;
|
|
|
|
|
|
|
|
std::pair<unsigned, const TargetRegisterClass*>
|
|
|
|
getRegForInlineAsmConstraint(const std::string &Constraint,
|
2008-06-06 12:08:01 +00:00
|
|
|
MVT VT) const;
|
2007-12-04 22:23:35 +00:00
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
void LowerAsmOperandForConstraint(SDValue Op, char ConstraintLetter,
|
2008-09-24 00:05:32 +00:00
|
|
|
bool hasMemory,
|
2008-07-27 21:46:04 +00:00
|
|
|
std::vector<SDValue> &Ops,
|
2008-04-30 00:30:08 +00:00
|
|
|
SelectionDAG &DAG) const;
|
|
|
|
|
2007-12-04 22:23:35 +00: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;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|