2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2014-08-05 09:58:52 +02:00
|
|
|
* Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
|
2007-12-01 00:00:00 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
2010-05-27 19:08:38 -07:00
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
2007-12-01 00:00:00 +00:00
|
|
|
*/
|
|
|
|
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "precompiled.hpp"
|
|
|
|
#include "memory/allocation.inline.hpp"
|
|
|
|
#include "opto/connode.hpp"
|
|
|
|
#include "opto/vectornode.hpp"
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
//------------------------------VectorNode--------------------------------------
|
|
|
|
|
|
|
|
// Return the vector operator for the specified scalar operation
|
2012-10-19 14:21:09 -04:00
|
|
|
// and vector length.
|
2012-08-22 11:55:40 -07:00
|
|
|
int VectorNode::opcode(int sopc, BasicType bt) {
|
2007-12-01 00:00:00 +00:00
|
|
|
switch (sopc) {
|
|
|
|
case Op_AddI:
|
|
|
|
switch (bt) {
|
|
|
|
case T_BOOLEAN:
|
|
|
|
case T_BYTE: return Op_AddVB;
|
2012-06-15 01:25:19 -07:00
|
|
|
case T_CHAR:
|
2007-12-01 00:00:00 +00:00
|
|
|
case T_SHORT: return Op_AddVS;
|
|
|
|
case T_INT: return Op_AddVI;
|
|
|
|
}
|
|
|
|
ShouldNotReachHere();
|
|
|
|
case Op_AddL:
|
|
|
|
assert(bt == T_LONG, "must be");
|
|
|
|
return Op_AddVL;
|
|
|
|
case Op_AddF:
|
|
|
|
assert(bt == T_FLOAT, "must be");
|
|
|
|
return Op_AddVF;
|
|
|
|
case Op_AddD:
|
|
|
|
assert(bt == T_DOUBLE, "must be");
|
|
|
|
return Op_AddVD;
|
|
|
|
case Op_SubI:
|
|
|
|
switch (bt) {
|
|
|
|
case T_BOOLEAN:
|
|
|
|
case T_BYTE: return Op_SubVB;
|
2012-06-15 01:25:19 -07:00
|
|
|
case T_CHAR:
|
2007-12-01 00:00:00 +00:00
|
|
|
case T_SHORT: return Op_SubVS;
|
|
|
|
case T_INT: return Op_SubVI;
|
|
|
|
}
|
|
|
|
ShouldNotReachHere();
|
|
|
|
case Op_SubL:
|
|
|
|
assert(bt == T_LONG, "must be");
|
|
|
|
return Op_SubVL;
|
|
|
|
case Op_SubF:
|
|
|
|
assert(bt == T_FLOAT, "must be");
|
|
|
|
return Op_SubVF;
|
|
|
|
case Op_SubD:
|
|
|
|
assert(bt == T_DOUBLE, "must be");
|
|
|
|
return Op_SubVD;
|
2012-08-20 09:07:21 -07:00
|
|
|
case Op_MulI:
|
|
|
|
switch (bt) {
|
|
|
|
case T_BOOLEAN:
|
|
|
|
case T_BYTE: return 0; // Unimplemented
|
|
|
|
case T_CHAR:
|
|
|
|
case T_SHORT: return Op_MulVS;
|
2012-10-19 14:21:09 -04:00
|
|
|
case T_INT: return Op_MulVI;
|
2012-08-20 09:07:21 -07:00
|
|
|
}
|
|
|
|
ShouldNotReachHere();
|
2015-05-08 11:49:20 -07:00
|
|
|
case Op_MulL:
|
|
|
|
assert(bt == T_LONG, "must be");
|
|
|
|
return Op_MulVL;
|
2007-12-01 00:00:00 +00:00
|
|
|
case Op_MulF:
|
|
|
|
assert(bt == T_FLOAT, "must be");
|
|
|
|
return Op_MulVF;
|
|
|
|
case Op_MulD:
|
|
|
|
assert(bt == T_DOUBLE, "must be");
|
|
|
|
return Op_MulVD;
|
|
|
|
case Op_DivF:
|
|
|
|
assert(bt == T_FLOAT, "must be");
|
|
|
|
return Op_DivVF;
|
|
|
|
case Op_DivD:
|
|
|
|
assert(bt == T_DOUBLE, "must be");
|
|
|
|
return Op_DivVD;
|
|
|
|
case Op_LShiftI:
|
|
|
|
switch (bt) {
|
|
|
|
case T_BOOLEAN:
|
|
|
|
case T_BYTE: return Op_LShiftVB;
|
2012-06-15 01:25:19 -07:00
|
|
|
case T_CHAR:
|
2007-12-01 00:00:00 +00:00
|
|
|
case T_SHORT: return Op_LShiftVS;
|
|
|
|
case T_INT: return Op_LShiftVI;
|
|
|
|
}
|
|
|
|
ShouldNotReachHere();
|
2012-08-20 09:07:21 -07:00
|
|
|
case Op_LShiftL:
|
|
|
|
assert(bt == T_LONG, "must be");
|
|
|
|
return Op_LShiftVL;
|
2012-06-15 01:25:19 -07:00
|
|
|
case Op_RShiftI:
|
2007-12-01 00:00:00 +00:00
|
|
|
switch (bt) {
|
2012-10-23 13:06:37 -07:00
|
|
|
case T_BOOLEAN:return Op_URShiftVB; // boolean is unsigned value
|
|
|
|
case T_CHAR: return Op_URShiftVS; // char is unsigned value
|
2012-06-15 01:25:19 -07:00
|
|
|
case T_BYTE: return Op_RShiftVB;
|
|
|
|
case T_SHORT: return Op_RShiftVS;
|
|
|
|
case T_INT: return Op_RShiftVI;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
ShouldNotReachHere();
|
2012-08-20 09:07:21 -07:00
|
|
|
case Op_RShiftL:
|
|
|
|
assert(bt == T_LONG, "must be");
|
|
|
|
return Op_RShiftVL;
|
|
|
|
case Op_URShiftI:
|
|
|
|
switch (bt) {
|
2012-10-23 13:06:37 -07:00
|
|
|
case T_BOOLEAN:return Op_URShiftVB;
|
|
|
|
case T_CHAR: return Op_URShiftVS;
|
|
|
|
case T_BYTE:
|
|
|
|
case T_SHORT: return 0; // Vector logical right shift for signed short
|
|
|
|
// values produces incorrect Java result for
|
|
|
|
// negative data because java code should convert
|
|
|
|
// a short value into int value with sign
|
|
|
|
// extension before a shift.
|
2012-08-20 09:07:21 -07:00
|
|
|
case T_INT: return Op_URShiftVI;
|
|
|
|
}
|
|
|
|
ShouldNotReachHere();
|
|
|
|
case Op_URShiftL:
|
|
|
|
assert(bt == T_LONG, "must be");
|
|
|
|
return Op_URShiftVL;
|
2007-12-01 00:00:00 +00:00
|
|
|
case Op_AndI:
|
|
|
|
case Op_AndL:
|
|
|
|
return Op_AndV;
|
|
|
|
case Op_OrI:
|
|
|
|
case Op_OrL:
|
|
|
|
return Op_OrV;
|
|
|
|
case Op_XorI:
|
|
|
|
case Op_XorL:
|
|
|
|
return Op_XorV;
|
|
|
|
|
|
|
|
case Op_LoadB:
|
2012-06-15 01:25:19 -07:00
|
|
|
case Op_LoadUB:
|
2009-01-26 16:22:12 +01:00
|
|
|
case Op_LoadUS:
|
2007-12-01 00:00:00 +00:00
|
|
|
case Op_LoadS:
|
|
|
|
case Op_LoadI:
|
|
|
|
case Op_LoadL:
|
|
|
|
case Op_LoadF:
|
|
|
|
case Op_LoadD:
|
2012-06-15 01:25:19 -07:00
|
|
|
return Op_LoadVector;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
case Op_StoreB:
|
|
|
|
case Op_StoreC:
|
|
|
|
case Op_StoreI:
|
|
|
|
case Op_StoreL:
|
|
|
|
case Op_StoreF:
|
|
|
|
case Op_StoreD:
|
2012-06-15 01:25:19 -07:00
|
|
|
return Op_StoreVector;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
return 0; // Unimplemented
|
|
|
|
}
|
|
|
|
|
2012-10-19 14:21:09 -04:00
|
|
|
// Also used to check if the code generator
|
|
|
|
// supports the vector operation.
|
2012-06-15 01:25:19 -07:00
|
|
|
bool VectorNode::implemented(int opc, uint vlen, BasicType bt) {
|
|
|
|
if (is_java_primitive(bt) &&
|
|
|
|
(vlen > 1) && is_power_of_2(vlen) &&
|
|
|
|
Matcher::vector_size_supported(bt, vlen)) {
|
2012-08-22 11:55:40 -07:00
|
|
|
int vopc = VectorNode::opcode(opc, bt);
|
2012-10-19 14:21:09 -04:00
|
|
|
return vopc > 0 && Matcher::match_rule_supported(vopc);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2012-06-15 01:25:19 -07:00
|
|
|
return false;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2012-08-20 09:07:21 -07:00
|
|
|
bool VectorNode::is_shift(Node* n) {
|
|
|
|
switch (n->Opcode()) {
|
|
|
|
case Op_LShiftI:
|
|
|
|
case Op_LShiftL:
|
|
|
|
case Op_RShiftI:
|
|
|
|
case Op_RShiftL:
|
|
|
|
case Op_URShiftI:
|
|
|
|
case Op_URShiftL:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-08-21 14:50:02 -07:00
|
|
|
// Check if input is loop invariant vector.
|
2012-08-20 09:07:21 -07:00
|
|
|
bool VectorNode::is_invariant_vector(Node* n) {
|
2012-08-21 14:50:02 -07:00
|
|
|
// Only Replicate vector nodes are loop invariant for now.
|
2012-08-20 09:07:21 -07:00
|
|
|
switch (n->Opcode()) {
|
|
|
|
case Op_ReplicateB:
|
|
|
|
case Op_ReplicateS:
|
|
|
|
case Op_ReplicateI:
|
|
|
|
case Op_ReplicateL:
|
|
|
|
case Op_ReplicateF:
|
|
|
|
case Op_ReplicateD:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-08-22 11:55:40 -07:00
|
|
|
// [Start, end) half-open range defining which operands are vectors
|
|
|
|
void VectorNode::vector_operands(Node* n, uint* start, uint* end) {
|
|
|
|
switch (n->Opcode()) {
|
|
|
|
case Op_LoadB: case Op_LoadUB:
|
|
|
|
case Op_LoadS: case Op_LoadUS:
|
|
|
|
case Op_LoadI: case Op_LoadL:
|
|
|
|
case Op_LoadF: case Op_LoadD:
|
|
|
|
case Op_LoadP: case Op_LoadN:
|
|
|
|
*start = 0;
|
|
|
|
*end = 0; // no vector operands
|
|
|
|
break;
|
|
|
|
case Op_StoreB: case Op_StoreC:
|
|
|
|
case Op_StoreI: case Op_StoreL:
|
|
|
|
case Op_StoreF: case Op_StoreD:
|
|
|
|
case Op_StoreP: case Op_StoreN:
|
|
|
|
*start = MemNode::ValueIn;
|
|
|
|
*end = MemNode::ValueIn + 1; // 1 vector operand
|
|
|
|
break;
|
|
|
|
case Op_LShiftI: case Op_LShiftL:
|
|
|
|
case Op_RShiftI: case Op_RShiftL:
|
|
|
|
case Op_URShiftI: case Op_URShiftL:
|
|
|
|
*start = 1;
|
|
|
|
*end = 2; // 1 vector operand
|
|
|
|
break;
|
|
|
|
case Op_AddI: case Op_AddL: case Op_AddF: case Op_AddD:
|
|
|
|
case Op_SubI: case Op_SubL: case Op_SubF: case Op_SubD:
|
|
|
|
case Op_MulI: case Op_MulL: case Op_MulF: case Op_MulD:
|
|
|
|
case Op_DivF: case Op_DivD:
|
|
|
|
case Op_AndI: case Op_AndL:
|
|
|
|
case Op_OrI: case Op_OrL:
|
|
|
|
case Op_XorI: case Op_XorL:
|
|
|
|
*start = 1;
|
|
|
|
*end = 3; // 2 vector operands
|
|
|
|
break;
|
|
|
|
case Op_CMoveI: case Op_CMoveL: case Op_CMoveF: case Op_CMoveD:
|
|
|
|
*start = 2;
|
|
|
|
*end = n->req();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
*start = 1;
|
|
|
|
*end = n->req(); // default is all operands
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Return the vector version of a scalar operation node.
|
2014-08-05 09:58:52 +02:00
|
|
|
VectorNode* VectorNode::make(int opc, Node* n1, Node* n2, uint vlen, BasicType bt) {
|
2012-06-15 01:25:19 -07:00
|
|
|
const TypeVect* vt = TypeVect::make(bt, vlen);
|
2012-08-22 11:55:40 -07:00
|
|
|
int vopc = VectorNode::opcode(opc, bt);
|
2012-10-02 12:25:13 -07:00
|
|
|
// This method should not be called for unimplemented vectors.
|
|
|
|
guarantee(vopc > 0, err_msg_res("Vector for '%s' is not implemented", NodeClassNames[opc]));
|
2007-12-01 00:00:00 +00:00
|
|
|
switch (vopc) {
|
2014-06-02 08:07:29 +02:00
|
|
|
case Op_AddVB: return new AddVBNode(n1, n2, vt);
|
|
|
|
case Op_AddVS: return new AddVSNode(n1, n2, vt);
|
|
|
|
case Op_AddVI: return new AddVINode(n1, n2, vt);
|
|
|
|
case Op_AddVL: return new AddVLNode(n1, n2, vt);
|
|
|
|
case Op_AddVF: return new AddVFNode(n1, n2, vt);
|
|
|
|
case Op_AddVD: return new AddVDNode(n1, n2, vt);
|
2012-06-15 01:25:19 -07:00
|
|
|
|
2014-06-02 08:07:29 +02:00
|
|
|
case Op_SubVB: return new SubVBNode(n1, n2, vt);
|
|
|
|
case Op_SubVS: return new SubVSNode(n1, n2, vt);
|
|
|
|
case Op_SubVI: return new SubVINode(n1, n2, vt);
|
|
|
|
case Op_SubVL: return new SubVLNode(n1, n2, vt);
|
|
|
|
case Op_SubVF: return new SubVFNode(n1, n2, vt);
|
|
|
|
case Op_SubVD: return new SubVDNode(n1, n2, vt);
|
2012-06-15 01:25:19 -07:00
|
|
|
|
2014-06-02 08:07:29 +02:00
|
|
|
case Op_MulVS: return new MulVSNode(n1, n2, vt);
|
|
|
|
case Op_MulVI: return new MulVINode(n1, n2, vt);
|
2015-05-08 11:49:20 -07:00
|
|
|
case Op_MulVL: return new MulVLNode(n1, n2, vt);
|
2014-06-02 08:07:29 +02:00
|
|
|
case Op_MulVF: return new MulVFNode(n1, n2, vt);
|
|
|
|
case Op_MulVD: return new MulVDNode(n1, n2, vt);
|
2012-06-15 01:25:19 -07:00
|
|
|
|
2014-06-02 08:07:29 +02:00
|
|
|
case Op_DivVF: return new DivVFNode(n1, n2, vt);
|
|
|
|
case Op_DivVD: return new DivVDNode(n1, n2, vt);
|
2012-06-15 01:25:19 -07:00
|
|
|
|
2014-06-02 08:07:29 +02:00
|
|
|
case Op_LShiftVB: return new LShiftVBNode(n1, n2, vt);
|
|
|
|
case Op_LShiftVS: return new LShiftVSNode(n1, n2, vt);
|
|
|
|
case Op_LShiftVI: return new LShiftVINode(n1, n2, vt);
|
|
|
|
case Op_LShiftVL: return new LShiftVLNode(n1, n2, vt);
|
2012-06-15 01:25:19 -07:00
|
|
|
|
2014-06-02 08:07:29 +02:00
|
|
|
case Op_RShiftVB: return new RShiftVBNode(n1, n2, vt);
|
|
|
|
case Op_RShiftVS: return new RShiftVSNode(n1, n2, vt);
|
|
|
|
case Op_RShiftVI: return new RShiftVINode(n1, n2, vt);
|
|
|
|
case Op_RShiftVL: return new RShiftVLNode(n1, n2, vt);
|
2012-08-20 09:07:21 -07:00
|
|
|
|
2014-06-02 08:07:29 +02:00
|
|
|
case Op_URShiftVB: return new URShiftVBNode(n1, n2, vt);
|
|
|
|
case Op_URShiftVS: return new URShiftVSNode(n1, n2, vt);
|
|
|
|
case Op_URShiftVI: return new URShiftVINode(n1, n2, vt);
|
|
|
|
case Op_URShiftVL: return new URShiftVLNode(n1, n2, vt);
|
2012-06-15 01:25:19 -07:00
|
|
|
|
2014-06-02 08:07:29 +02:00
|
|
|
case Op_AndV: return new AndVNode(n1, n2, vt);
|
|
|
|
case Op_OrV: return new OrVNode (n1, n2, vt);
|
|
|
|
case Op_XorV: return new XorVNode(n1, n2, vt);
|
2012-06-15 01:25:19 -07:00
|
|
|
}
|
2012-10-02 12:25:13 -07:00
|
|
|
fatal(err_msg_res("Missed vector creation for '%s'", NodeClassNames[vopc]));
|
2012-06-15 01:25:19 -07:00
|
|
|
return NULL;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2012-06-15 01:25:19 -07:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2012-06-15 01:25:19 -07:00
|
|
|
// Scalar promotion
|
2014-08-05 09:58:52 +02:00
|
|
|
VectorNode* VectorNode::scalar2vector(Node* s, uint vlen, const Type* opd_t) {
|
2012-06-15 01:25:19 -07:00
|
|
|
BasicType bt = opd_t->array_element_basic_type();
|
|
|
|
const TypeVect* vt = opd_t->singleton() ? TypeVect::make(opd_t, vlen)
|
|
|
|
: TypeVect::make(bt, vlen);
|
|
|
|
switch (bt) {
|
|
|
|
case T_BOOLEAN:
|
|
|
|
case T_BYTE:
|
2014-06-02 08:07:29 +02:00
|
|
|
return new ReplicateBNode(s, vt);
|
2012-06-15 01:25:19 -07:00
|
|
|
case T_CHAR:
|
|
|
|
case T_SHORT:
|
2014-06-02 08:07:29 +02:00
|
|
|
return new ReplicateSNode(s, vt);
|
2012-06-15 01:25:19 -07:00
|
|
|
case T_INT:
|
2014-06-02 08:07:29 +02:00
|
|
|
return new ReplicateINode(s, vt);
|
2012-06-15 01:25:19 -07:00
|
|
|
case T_LONG:
|
2014-06-02 08:07:29 +02:00
|
|
|
return new ReplicateLNode(s, vt);
|
2012-06-15 01:25:19 -07:00
|
|
|
case T_FLOAT:
|
2014-06-02 08:07:29 +02:00
|
|
|
return new ReplicateFNode(s, vt);
|
2012-06-15 01:25:19 -07:00
|
|
|
case T_DOUBLE:
|
2014-06-02 08:07:29 +02:00
|
|
|
return new ReplicateDNode(s, vt);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2012-10-02 12:25:13 -07:00
|
|
|
fatal(err_msg_res("Type '%s' is not supported for vectors", type2name(bt)));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-08-05 09:58:52 +02:00
|
|
|
VectorNode* VectorNode::shift_count(Node* shift, Node* cnt, uint vlen, BasicType bt) {
|
2012-10-02 12:25:13 -07:00
|
|
|
assert(VectorNode::is_shift(shift) && !cnt->is_Con(), "only variable shift count");
|
|
|
|
// Match shift count type with shift vector type.
|
|
|
|
const TypeVect* vt = TypeVect::make(bt, vlen);
|
|
|
|
switch (shift->Opcode()) {
|
|
|
|
case Op_LShiftI:
|
|
|
|
case Op_LShiftL:
|
2014-06-02 08:07:29 +02:00
|
|
|
return new LShiftCntVNode(cnt, vt);
|
2012-10-02 12:25:13 -07:00
|
|
|
case Op_RShiftI:
|
|
|
|
case Op_RShiftL:
|
|
|
|
case Op_URShiftI:
|
|
|
|
case Op_URShiftL:
|
2014-06-02 08:07:29 +02:00
|
|
|
return new RShiftCntVNode(cnt, vt);
|
2012-10-02 12:25:13 -07:00
|
|
|
}
|
|
|
|
fatal(err_msg_res("Missed vector creation for '%s'", NodeClassNames[shift->Opcode()]));
|
2007-12-01 00:00:00 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-06-15 01:25:19 -07:00
|
|
|
// Return initial Pack node. Additional operands added with add_opd() calls.
|
2014-08-05 09:58:52 +02:00
|
|
|
PackNode* PackNode::make(Node* s, uint vlen, BasicType bt) {
|
2012-06-15 01:25:19 -07:00
|
|
|
const TypeVect* vt = TypeVect::make(bt, vlen);
|
|
|
|
switch (bt) {
|
|
|
|
case T_BOOLEAN:
|
|
|
|
case T_BYTE:
|
2014-06-02 08:07:29 +02:00
|
|
|
return new PackBNode(s, vt);
|
2012-06-15 01:25:19 -07:00
|
|
|
case T_CHAR:
|
|
|
|
case T_SHORT:
|
2014-06-02 08:07:29 +02:00
|
|
|
return new PackSNode(s, vt);
|
2012-06-15 01:25:19 -07:00
|
|
|
case T_INT:
|
2014-06-02 08:07:29 +02:00
|
|
|
return new PackINode(s, vt);
|
2012-06-15 01:25:19 -07:00
|
|
|
case T_LONG:
|
2014-06-02 08:07:29 +02:00
|
|
|
return new PackLNode(s, vt);
|
2012-06-15 01:25:19 -07:00
|
|
|
case T_FLOAT:
|
2014-06-02 08:07:29 +02:00
|
|
|
return new PackFNode(s, vt);
|
2012-06-15 01:25:19 -07:00
|
|
|
case T_DOUBLE:
|
2014-06-02 08:07:29 +02:00
|
|
|
return new PackDNode(s, vt);
|
2012-06-15 01:25:19 -07:00
|
|
|
}
|
2012-10-02 12:25:13 -07:00
|
|
|
fatal(err_msg_res("Type '%s' is not supported for vectors", type2name(bt)));
|
2012-06-15 01:25:19 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2012-06-15 01:25:19 -07:00
|
|
|
// Create a binary tree form for Packs. [lo, hi) (half-open) range
|
2014-08-05 09:58:52 +02:00
|
|
|
PackNode* PackNode::binary_tree_pack(int lo, int hi) {
|
2012-06-15 01:25:19 -07:00
|
|
|
int ct = hi - lo;
|
|
|
|
assert(is_power_of_2(ct), "power of 2");
|
|
|
|
if (ct == 2) {
|
2014-08-05 09:58:52 +02:00
|
|
|
PackNode* pk = PackNode::make(in(lo), 2, vect_type()->element_basic_type());
|
2012-08-22 11:55:40 -07:00
|
|
|
pk->add_opd(in(lo+1));
|
2012-06-15 01:25:19 -07:00
|
|
|
return pk;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2012-06-15 01:25:19 -07:00
|
|
|
} else {
|
|
|
|
int mid = lo + ct/2;
|
2014-08-05 09:58:52 +02:00
|
|
|
PackNode* n1 = binary_tree_pack(lo, mid);
|
|
|
|
PackNode* n2 = binary_tree_pack(mid, hi );
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2012-08-22 11:55:40 -07:00
|
|
|
BasicType bt = n1->vect_type()->element_basic_type();
|
|
|
|
assert(bt == n2->vect_type()->element_basic_type(), "should be the same");
|
2012-06-15 01:25:19 -07:00
|
|
|
switch (bt) {
|
|
|
|
case T_BOOLEAN:
|
|
|
|
case T_BYTE:
|
2014-06-02 08:07:29 +02:00
|
|
|
return new PackSNode(n1, n2, TypeVect::make(T_SHORT, 2));
|
2012-06-15 01:25:19 -07:00
|
|
|
case T_CHAR:
|
|
|
|
case T_SHORT:
|
2014-06-02 08:07:29 +02:00
|
|
|
return new PackINode(n1, n2, TypeVect::make(T_INT, 2));
|
2012-06-15 01:25:19 -07:00
|
|
|
case T_INT:
|
2014-06-02 08:07:29 +02:00
|
|
|
return new PackLNode(n1, n2, TypeVect::make(T_LONG, 2));
|
2012-06-15 01:25:19 -07:00
|
|
|
case T_LONG:
|
2014-06-02 08:07:29 +02:00
|
|
|
return new Pack2LNode(n1, n2, TypeVect::make(T_LONG, 2));
|
2012-06-15 01:25:19 -07:00
|
|
|
case T_FLOAT:
|
2014-06-02 08:07:29 +02:00
|
|
|
return new PackDNode(n1, n2, TypeVect::make(T_DOUBLE, 2));
|
2012-06-15 01:25:19 -07:00
|
|
|
case T_DOUBLE:
|
2014-06-02 08:07:29 +02:00
|
|
|
return new Pack2DNode(n1, n2, TypeVect::make(T_DOUBLE, 2));
|
2012-06-15 01:25:19 -07:00
|
|
|
}
|
2012-10-02 12:25:13 -07:00
|
|
|
fatal(err_msg_res("Type '%s' is not supported for vectors", type2name(bt)));
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2012-06-15 01:25:19 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return the vector version of a scalar load node.
|
2014-08-05 09:58:52 +02:00
|
|
|
LoadVectorNode* LoadVectorNode::make(int opc, Node* ctl, Node* mem,
|
2015-05-21 13:54:07 +02:00
|
|
|
Node* adr, const TypePtr* atyp,
|
|
|
|
uint vlen, BasicType bt,
|
|
|
|
ControlDependency control_dependency) {
|
2012-06-15 01:25:19 -07:00
|
|
|
const TypeVect* vt = TypeVect::make(bt, vlen);
|
2015-05-21 13:54:07 +02:00
|
|
|
return new LoadVectorNode(ctl, mem, adr, atyp, vt, control_dependency);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Return the vector version of a scalar store node.
|
2014-08-05 09:58:52 +02:00
|
|
|
StoreVectorNode* StoreVectorNode::make(int opc, Node* ctl, Node* mem,
|
2011-07-27 17:28:36 -07:00
|
|
|
Node* adr, const TypePtr* atyp, Node* val,
|
2007-12-01 00:00:00 +00:00
|
|
|
uint vlen) {
|
2014-06-02 08:07:29 +02:00
|
|
|
return new StoreVectorNode(ctl, mem, adr, atyp, val);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Extract a scalar element of vector.
|
2014-08-05 09:58:52 +02:00
|
|
|
Node* ExtractNode::make(Node* v, uint position, BasicType bt) {
|
2012-06-15 01:25:19 -07:00
|
|
|
assert((int)position < Matcher::max_vector_size(bt), "pos in range");
|
2014-08-05 09:58:52 +02:00
|
|
|
ConINode* pos = ConINode::make((int)position);
|
2007-12-01 00:00:00 +00:00
|
|
|
switch (bt) {
|
|
|
|
case T_BOOLEAN:
|
2014-06-02 08:07:29 +02:00
|
|
|
return new ExtractUBNode(v, pos);
|
2007-12-01 00:00:00 +00:00
|
|
|
case T_BYTE:
|
2014-06-02 08:07:29 +02:00
|
|
|
return new ExtractBNode(v, pos);
|
2007-12-01 00:00:00 +00:00
|
|
|
case T_CHAR:
|
2014-06-02 08:07:29 +02:00
|
|
|
return new ExtractCNode(v, pos);
|
2007-12-01 00:00:00 +00:00
|
|
|
case T_SHORT:
|
2014-06-02 08:07:29 +02:00
|
|
|
return new ExtractSNode(v, pos);
|
2007-12-01 00:00:00 +00:00
|
|
|
case T_INT:
|
2014-06-02 08:07:29 +02:00
|
|
|
return new ExtractINode(v, pos);
|
2007-12-01 00:00:00 +00:00
|
|
|
case T_LONG:
|
2014-06-02 08:07:29 +02:00
|
|
|
return new ExtractLNode(v, pos);
|
2007-12-01 00:00:00 +00:00
|
|
|
case T_FLOAT:
|
2014-06-02 08:07:29 +02:00
|
|
|
return new ExtractFNode(v, pos);
|
2007-12-01 00:00:00 +00:00
|
|
|
case T_DOUBLE:
|
2014-06-02 08:07:29 +02:00
|
|
|
return new ExtractDNode(v, pos);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2012-10-02 12:25:13 -07:00
|
|
|
fatal(err_msg_res("Type '%s' is not supported for vectors", type2name(bt)));
|
2007-12-01 00:00:00 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2012-06-15 01:25:19 -07:00
|
|
|
|
2015-04-01 18:07:50 -07:00
|
|
|
int ReductionNode::opcode(int opc, BasicType bt) {
|
|
|
|
int vopc = opc;
|
|
|
|
switch (opc) {
|
|
|
|
case Op_AddI:
|
|
|
|
assert(bt == T_INT, "must be");
|
|
|
|
vopc = Op_AddReductionVI;
|
|
|
|
break;
|
|
|
|
case Op_AddL:
|
|
|
|
assert(bt == T_LONG, "must be");
|
|
|
|
vopc = Op_AddReductionVL;
|
|
|
|
break;
|
|
|
|
case Op_AddF:
|
|
|
|
assert(bt == T_FLOAT, "must be");
|
|
|
|
vopc = Op_AddReductionVF;
|
|
|
|
break;
|
|
|
|
case Op_AddD:
|
|
|
|
assert(bt == T_DOUBLE, "must be");
|
|
|
|
vopc = Op_AddReductionVD;
|
|
|
|
break;
|
|
|
|
case Op_MulI:
|
|
|
|
assert(bt == T_INT, "must be");
|
|
|
|
vopc = Op_MulReductionVI;
|
|
|
|
break;
|
2015-05-08 11:49:20 -07:00
|
|
|
case Op_MulL:
|
|
|
|
assert(bt == T_LONG, "must be");
|
|
|
|
vopc = Op_MulReductionVL;
|
|
|
|
break;
|
2015-04-01 18:07:50 -07:00
|
|
|
case Op_MulF:
|
|
|
|
assert(bt == T_FLOAT, "must be");
|
|
|
|
vopc = Op_MulReductionVF;
|
|
|
|
break;
|
|
|
|
case Op_MulD:
|
|
|
|
assert(bt == T_DOUBLE, "must be");
|
|
|
|
vopc = Op_MulReductionVD;
|
|
|
|
break;
|
|
|
|
// TODO: add MulL for targets that support it
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return vopc;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return the appropriate reduction node.
|
|
|
|
ReductionNode* ReductionNode::make(int opc, Node *ctrl, Node* n1, Node* n2, BasicType bt) {
|
|
|
|
|
|
|
|
int vopc = opcode(opc, bt);
|
|
|
|
|
|
|
|
// This method should not be called for unimplemented vectors.
|
|
|
|
guarantee(vopc != opc, err_msg_res("Vector for '%s' is not implemented", NodeClassNames[opc]));
|
|
|
|
|
|
|
|
switch (vopc) {
|
|
|
|
case Op_AddReductionVI: return new AddReductionVINode(ctrl, n1, n2);
|
|
|
|
case Op_AddReductionVL: return new AddReductionVLNode(ctrl, n1, n2);
|
|
|
|
case Op_AddReductionVF: return new AddReductionVFNode(ctrl, n1, n2);
|
|
|
|
case Op_AddReductionVD: return new AddReductionVDNode(ctrl, n1, n2);
|
|
|
|
case Op_MulReductionVI: return new MulReductionVINode(ctrl, n1, n2);
|
2015-05-08 11:49:20 -07:00
|
|
|
case Op_MulReductionVL: return new MulReductionVLNode(ctrl, n1, n2);
|
2015-04-01 18:07:50 -07:00
|
|
|
case Op_MulReductionVF: return new MulReductionVFNode(ctrl, n1, n2);
|
|
|
|
case Op_MulReductionVD: return new MulReductionVDNode(ctrl, n1, n2);
|
|
|
|
}
|
|
|
|
fatal(err_msg_res("Missed vector creation for '%s'", NodeClassNames[vopc]));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ReductionNode::implemented(int opc, uint vlen, BasicType bt) {
|
|
|
|
if (is_java_primitive(bt) &&
|
|
|
|
(vlen > 1) && is_power_of_2(vlen) &&
|
|
|
|
Matcher::vector_size_supported(bt, vlen)) {
|
|
|
|
int vopc = ReductionNode::opcode(opc, bt);
|
|
|
|
return vopc != opc && Matcher::match_rule_supported(vopc);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|