return CurDAG->getTargetConstant(Imm, DL, MVT::i32);
}
+ SDValue getExtractVEXTRACTImmediate(SDNode *N, unsigned VecWidth,
+ const SDLoc &DL) {
+ assert((VecWidth == 128 || VecWidth == 256) && "Unexpected vector width");
+ uint64_t Index = N->getConstantOperandVal(1);
+ MVT VecVT = N->getOperand(0).getSimpleValueType();
+ unsigned NumElemsPerChunk = VecWidth / VecVT.getScalarSizeInBits();
+ return getI8Imm(Index / NumElemsPerChunk, DL);
+ }
+
+ SDValue getInsertVINSERTImmediate(SDNode *N, unsigned VecWidth,
+ const SDLoc &DL) {
+ assert((VecWidth == 128 || VecWidth == 256) && "Unexpected vector width");
+ uint64_t Index = N->getConstantOperandVal(2);
+ MVT VecVT = N->getSimpleValueType(0);
+ unsigned NumElemsPerChunk = VecWidth / VecVT.getScalarSizeInBits();
+ return getI8Imm(Index / NumElemsPerChunk, DL);
+ }
+
/// Return an SDNode that returns the value of the global base register.
/// Output instructions required to initialize the global base register,
/// if necessary.
return true;
}
-static unsigned getExtractVEXTRACTImmediate(SDNode *N, unsigned vecWidth) {
- assert((vecWidth == 128 || vecWidth == 256) && "Unsupported vector width");
- assert(isa<ConstantSDNode>(N->getOperand(1).getNode()) &&
- "Illegal extract subvector for VEXTRACT");
-
- uint64_t Index = N->getConstantOperandVal(1);
- MVT VecVT = N->getOperand(0).getSimpleValueType();
- unsigned NumElemsPerChunk = vecWidth / VecVT.getScalarSizeInBits();
- return Index / NumElemsPerChunk;
-}
-
-static unsigned getInsertVINSERTImmediate(SDNode *N, unsigned vecWidth) {
- assert((vecWidth == 128 || vecWidth == 256) && "Unsupported vector width");
- assert(isa<ConstantSDNode>(N->getOperand(2).getNode()) &&
- "Illegal insert subvector for VINSERT");
-
- uint64_t Index = N->getConstantOperandVal(2);
- MVT VecVT = N->getSimpleValueType(0);
- unsigned NumElemsPerChunk = vecWidth / VecVT.getScalarSizeInBits();
- return Index / NumElemsPerChunk;
-}
-
-/// Return the appropriate immediate to extract the specified
-/// EXTRACT_SUBVECTOR index with VEXTRACTF128 and VINSERTI128 instructions.
-unsigned X86::getExtractVEXTRACT128Immediate(SDNode *N) {
- return getExtractVEXTRACTImmediate(N, 128);
-}
-
-/// Return the appropriate immediate to extract the specified
-/// EXTRACT_SUBVECTOR index with VEXTRACTF64x4 and VINSERTI64x4 instructions.
-unsigned X86::getExtractVEXTRACT256Immediate(SDNode *N) {
- return getExtractVEXTRACTImmediate(N, 256);
-}
-
-/// Return the appropriate immediate to insert at the specified
-/// INSERT_SUBVECTOR index with VINSERTF128 and VINSERTI128 instructions.
-unsigned X86::getInsertVINSERT128Immediate(SDNode *N) {
- return getInsertVINSERTImmediate(N, 128);
-}
-
-/// Return the appropriate immediate to insert at the specified
-/// INSERT_SUBVECTOR index with VINSERTF46x4 and VINSERTI64x4 instructions.
-unsigned X86::getInsertVINSERT256Immediate(SDNode *N) {
- return getInsertVINSERTImmediate(N, 256);
-}
-
/// Returns true if Elt is a constant zero or a floating point constant +0.0.
bool X86::isZeroNode(SDValue Elt) {
return isNullConstant(Elt) || isNullFPConstant(Elt);
/// Define some predicates that are used for node matching.
namespace X86 {
- /// Return the appropriate
- /// immediate to extract the specified EXTRACT_SUBVECTOR index
- /// with VEXTRACTF128, VEXTRACTI128 instructions.
- unsigned getExtractVEXTRACT128Immediate(SDNode *N);
-
- /// Return the appropriate
- /// immediate to insert at the specified INSERT_SUBVECTOR index
- /// with VINSERTF128, VINSERT128 instructions.
- unsigned getInsertVINSERT128Immediate(SDNode *N);
-
- /// Return the appropriate
- /// immediate to extract the specified EXTRACT_SUBVECTOR index
- /// with VEXTRACTF64X4, VEXTRACTI64x4 instructions.
- unsigned getExtractVEXTRACT256Immediate(SDNode *N);
-
- /// Return the appropriate
- /// immediate to insert at the specified INSERT_SUBVECTOR index
- /// with VINSERTF64x4, VINSERTI64x4 instructions.
- unsigned getInsertVINSERT256Immediate(SDNode *N);
-
/// Returns true if Elt is a constant zero or floating point constant +0.0.
bool isZeroNode(SDValue Elt);
// EXTRACT_get_vextract128_imm xform function: convert extract_subvector index
// to VEXTRACTF128/VEXTRACTI128 imm.
def EXTRACT_get_vextract128_imm : SDNodeXForm<extract_subvector, [{
- return getI8Imm(X86::getExtractVEXTRACT128Immediate(N), SDLoc(N));
+ return getExtractVEXTRACTImmediate(N, 128, SDLoc(N));
}]>;
// INSERT_get_vinsert128_imm xform function: convert insert_subvector index to
// VINSERTF128/VINSERTI128 imm.
def INSERT_get_vinsert128_imm : SDNodeXForm<insert_subvector, [{
- return getI8Imm(X86::getInsertVINSERT128Immediate(N), SDLoc(N));
+ return getInsertVINSERTImmediate(N, 128, SDLoc(N));
}]>;
// EXTRACT_get_vextract256_imm xform function: convert extract_subvector index
// to VEXTRACTF64x4 imm.
def EXTRACT_get_vextract256_imm : SDNodeXForm<extract_subvector, [{
- return getI8Imm(X86::getExtractVEXTRACT256Immediate(N), SDLoc(N));
+ return getExtractVEXTRACTImmediate(N, 256, SDLoc(N));
}]>;
// INSERT_get_vinsert256_imm xform function: convert insert_subvector index to
// VINSERTF64x4 imm.
def INSERT_get_vinsert256_imm : SDNodeXForm<insert_subvector, [{
- return getI8Imm(X86::getInsertVINSERT256Immediate(N), SDLoc(N));
+ return getInsertVINSERTImmediate(N, 256, SDLoc(N));
}]>;
def vextract128_extract : PatFrag<(ops node:$bigvec, node:$index),