vectornode.hpp revision 2292:08eb13460b3a
1/*
2 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24#ifndef SHARE_VM_OPTO_VECTORNODE_HPP
25#define SHARE_VM_OPTO_VECTORNODE_HPP
26
27#include "opto/matcher.hpp"
28#include "opto/memnode.hpp"
29#include "opto/node.hpp"
30#include "opto/opcodes.hpp"
31
32//------------------------------VectorNode--------------------------------------
33// Vector Operation
34class VectorNode : public Node {
35  virtual uint size_of() const { return sizeof(*this); }
36 protected:
37  uint _length; // vector length
38  virtual BasicType elt_basic_type() const = 0; // Vector element basic type
39
40  static const Type* vect_type(BasicType elt_bt, uint len);
41  static const Type* vect_type(const Type* elt_type, uint len) {
42    return vect_type(elt_type->array_element_basic_type(), len);
43  }
44
45 public:
46  friend class VectorLoadNode;  // For vect_type
47  friend class VectorStoreNode; // ditto.
48
49  VectorNode(Node* n1, uint vlen) : Node(NULL, n1), _length(vlen) {
50    init_flags(Flag_is_Vector);
51  }
52  VectorNode(Node* n1, Node* n2, uint vlen) : Node(NULL, n1, n2), _length(vlen) {
53    init_flags(Flag_is_Vector);
54  }
55  virtual int Opcode() const;
56
57  uint length() const { return _length; } // Vector length
58
59  static uint max_vlen(BasicType bt) { // max vector length
60    return (uint)(Matcher::vector_width_in_bytes() / type2aelembytes(bt));
61  }
62
63  // Element and vector type
64  const Type* elt_type()  const { return Type::get_const_basic_type(elt_basic_type()); }
65  const Type* vect_type() const { return vect_type(elt_basic_type(), length()); }
66
67  virtual const Type *bottom_type() const { return vect_type(); }
68  virtual uint        ideal_reg()   const { return Matcher::vector_ideal_reg(); }
69
70  // Vector opcode from scalar opcode
71  static int opcode(int sopc, uint vlen, const Type* opd_t);
72
73  static VectorNode* scalar2vector(Compile* C, Node* s, uint vlen, const Type* opd_t);
74
75  static VectorNode* make(Compile* C, int sopc, Node* n1, Node* n2, uint vlen, const Type* elt_t);
76
77};
78
79//===========================Vector=ALU=Operations====================================
80
81//------------------------------AddVBNode---------------------------------------
82// Vector add byte
83class AddVBNode : public VectorNode {
84 protected:
85  virtual BasicType elt_basic_type() const { return T_BYTE; }
86 public:
87  AddVBNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {}
88  virtual int Opcode() const;
89};
90
91//------------------------------AddVCNode---------------------------------------
92// Vector add char
93class AddVCNode : public VectorNode {
94 protected:
95  virtual BasicType elt_basic_type() const { return T_CHAR; }
96 public:
97  AddVCNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {}
98  virtual int Opcode() const;
99};
100
101//------------------------------AddVSNode---------------------------------------
102// Vector add short
103class AddVSNode : public VectorNode {
104 protected:
105  virtual BasicType elt_basic_type() const { return T_SHORT; }
106 public:
107  AddVSNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {}
108  virtual int Opcode() const;
109};
110
111//------------------------------AddVINode---------------------------------------
112// Vector add int
113class AddVINode : public VectorNode {
114 protected:
115  virtual BasicType elt_basic_type() const { return T_INT; }
116 public:
117  AddVINode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {}
118  virtual int Opcode() const;
119};
120
121//------------------------------AddVLNode---------------------------------------
122// Vector add long
123class AddVLNode : public VectorNode {
124 protected:
125  virtual BasicType elt_basic_type() const { return T_LONG; }
126 public:
127  AddVLNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {}
128  virtual int Opcode() const;
129};
130
131//------------------------------AddVFNode---------------------------------------
132// Vector add float
133class AddVFNode : public VectorNode {
134 protected:
135  virtual BasicType elt_basic_type() const { return T_FLOAT; }
136 public:
137  AddVFNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {}
138  virtual int Opcode() const;
139};
140
141//------------------------------AddVDNode---------------------------------------
142// Vector add double
143class AddVDNode : public VectorNode {
144 protected:
145  virtual BasicType elt_basic_type() const { return T_DOUBLE; }
146 public:
147  AddVDNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {}
148  virtual int Opcode() const;
149};
150
151//------------------------------SubVBNode---------------------------------------
152// Vector subtract byte
153class SubVBNode : public VectorNode {
154 protected:
155  virtual BasicType elt_basic_type() const { return T_BYTE; }
156 public:
157  SubVBNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {}
158  virtual int Opcode() const;
159};
160
161//------------------------------SubVCNode---------------------------------------
162// Vector subtract char
163class SubVCNode : public VectorNode {
164 protected:
165  virtual BasicType elt_basic_type() const { return T_CHAR; }
166 public:
167  SubVCNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {}
168  virtual int Opcode() const;
169};
170
171//------------------------------SubVSNode---------------------------------------
172// Vector subtract short
173class SubVSNode : public VectorNode {
174 protected:
175  virtual BasicType elt_basic_type() const { return T_SHORT; }
176 public:
177  SubVSNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {}
178  virtual int Opcode() const;
179};
180
181//------------------------------SubVINode---------------------------------------
182// Vector subtract int
183class SubVINode : public VectorNode {
184 protected:
185  virtual BasicType elt_basic_type() const { return T_INT; }
186 public:
187  SubVINode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {}
188  virtual int Opcode() const;
189};
190
191//------------------------------SubVLNode---------------------------------------
192// Vector subtract long
193class SubVLNode : public VectorNode {
194 protected:
195  virtual BasicType elt_basic_type() const { return T_LONG; }
196 public:
197  SubVLNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {}
198  virtual int Opcode() const;
199};
200
201//------------------------------SubVFNode---------------------------------------
202// Vector subtract float
203class SubVFNode : public VectorNode {
204 protected:
205  virtual BasicType elt_basic_type() const { return T_FLOAT; }
206 public:
207  SubVFNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {}
208  virtual int Opcode() const;
209};
210
211//------------------------------SubVDNode---------------------------------------
212// Vector subtract double
213class SubVDNode : public VectorNode {
214 protected:
215  virtual BasicType elt_basic_type() const { return T_DOUBLE; }
216 public:
217  SubVDNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {}
218  virtual int Opcode() const;
219};
220
221//------------------------------MulVFNode---------------------------------------
222// Vector multiply float
223class MulVFNode : public VectorNode {
224 protected:
225  virtual BasicType elt_basic_type() const { return T_FLOAT; }
226 public:
227  MulVFNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {}
228  virtual int Opcode() const;
229};
230
231//------------------------------MulVDNode---------------------------------------
232// Vector multiply double
233class MulVDNode : public VectorNode {
234 protected:
235  virtual BasicType elt_basic_type() const { return T_DOUBLE; }
236 public:
237  MulVDNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {}
238  virtual int Opcode() const;
239};
240
241//------------------------------DivVFNode---------------------------------------
242// Vector divide float
243class DivVFNode : public VectorNode {
244 protected:
245  virtual BasicType elt_basic_type() const { return T_FLOAT; }
246 public:
247  DivVFNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {}
248  virtual int Opcode() const;
249};
250
251//------------------------------DivVDNode---------------------------------------
252// Vector Divide double
253class DivVDNode : public VectorNode {
254 protected:
255  virtual BasicType elt_basic_type() const { return T_DOUBLE; }
256 public:
257  DivVDNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {}
258  virtual int Opcode() const;
259};
260
261//------------------------------LShiftVBNode---------------------------------------
262// Vector lshift byte
263class LShiftVBNode : public VectorNode {
264 protected:
265  virtual BasicType elt_basic_type() const { return T_BYTE; }
266 public:
267  LShiftVBNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {}
268  virtual int Opcode() const;
269};
270
271//------------------------------LShiftVCNode---------------------------------------
272// Vector lshift chars
273class LShiftVCNode : public VectorNode {
274 protected:
275  virtual BasicType elt_basic_type() const { return T_CHAR; }
276 public:
277  LShiftVCNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {}
278  virtual int Opcode() const;
279};
280
281//------------------------------LShiftVSNode---------------------------------------
282// Vector lshift shorts
283class LShiftVSNode : public VectorNode {
284 protected:
285  virtual BasicType elt_basic_type() const { return T_SHORT; }
286 public:
287  LShiftVSNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {}
288  virtual int Opcode() const;
289};
290
291//------------------------------LShiftVINode---------------------------------------
292// Vector lshift ints
293class LShiftVINode : public VectorNode {
294 protected:
295  virtual BasicType elt_basic_type() const { return T_INT; }
296 public:
297  LShiftVINode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {}
298  virtual int Opcode() const;
299};
300
301//------------------------------URShiftVBNode---------------------------------------
302// Vector urshift bytes
303class URShiftVBNode : public VectorNode {
304 protected:
305  virtual BasicType elt_basic_type() const { return T_BYTE; }
306 public:
307  URShiftVBNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {}
308  virtual int Opcode() const;
309};
310
311//------------------------------URShiftVCNode---------------------------------------
312// Vector urshift char
313class URShiftVCNode : public VectorNode {
314 protected:
315  virtual BasicType elt_basic_type() const { return T_SHORT; }
316 public:
317  URShiftVCNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {}
318  virtual int Opcode() const;
319};
320
321//------------------------------URShiftVSNode---------------------------------------
322// Vector urshift shorts
323class URShiftVSNode : public VectorNode {
324 protected:
325  virtual BasicType elt_basic_type() const { return T_SHORT; }
326 public:
327  URShiftVSNode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {}
328  virtual int Opcode() const;
329};
330
331//------------------------------URShiftVINode---------------------------------------
332// Vector urshift ints
333class URShiftVINode : public VectorNode {
334 protected:
335  virtual BasicType elt_basic_type() const { return T_INT; }
336 public:
337  URShiftVINode(Node* in1, Node* in2, uint vlen) : VectorNode(in1,in2,vlen) {}
338  virtual int Opcode() const;
339};
340
341//------------------------------AndVNode---------------------------------------
342// Vector and
343class AndVNode : public VectorNode {
344 protected:
345  BasicType _bt;
346  virtual BasicType elt_basic_type() const { return _bt; }
347 public:
348  AndVNode(Node* in1, Node* in2, uint vlen, BasicType bt) : VectorNode(in1,in2,vlen), _bt(bt) {}
349  virtual int Opcode() const;
350};
351
352//------------------------------OrVNode---------------------------------------
353// Vector or
354class OrVNode : public VectorNode {
355 protected:
356  BasicType _bt;
357  virtual BasicType elt_basic_type() const { return _bt; }
358 public:
359  OrVNode(Node* in1, Node* in2, uint vlen, BasicType bt) : VectorNode(in1,in2,vlen), _bt(bt) {}
360  virtual int Opcode() const;
361};
362
363//------------------------------XorVNode---------------------------------------
364// Vector xor
365class XorVNode : public VectorNode {
366 protected:
367  BasicType _bt;
368  virtual BasicType elt_basic_type() const { return _bt; }
369 public:
370  XorVNode(Node* in1, Node* in2, uint vlen, BasicType bt) : VectorNode(in1,in2,vlen), _bt(bt) {}
371  virtual int Opcode() const;
372};
373
374//================================= M E M O R Y ==================================
375
376
377//------------------------------VectorLoadNode--------------------------------------
378// Vector Load from memory
379class VectorLoadNode : public LoadNode {
380  virtual uint size_of() const { return sizeof(*this); }
381
382 protected:
383  virtual BasicType elt_basic_type()  const = 0; // Vector element basic type
384  // For use in constructor
385  static const Type* vect_type(const Type* elt_type, uint len) {
386    return VectorNode::vect_type(elt_type, len);
387  }
388
389 public:
390  VectorLoadNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const Type *rt)
391    : LoadNode(c,mem,adr,at,rt) {
392      init_flags(Flag_is_Vector);
393  }
394  virtual int Opcode() const;
395
396  virtual uint  length() const = 0; // Vector length
397
398  // Element and vector type
399  const Type* elt_type()  const { return Type::get_const_basic_type(elt_basic_type()); }
400  const Type* vect_type() const { return VectorNode::vect_type(elt_basic_type(), length()); }
401
402  virtual uint ideal_reg() const  { return Matcher::vector_ideal_reg(); }
403  virtual BasicType memory_type() const { return T_VOID; }
404  virtual int memory_size() const { return length()*type2aelembytes(elt_basic_type()); }
405
406  // Vector opcode from scalar opcode
407  static int opcode(int sopc, uint vlen);
408
409  static VectorLoadNode* make(Compile* C, int opc, Node* ctl, Node* mem,
410                              Node* adr, const TypePtr* atyp, uint vlen);
411};
412
413//------------------------------Load16BNode--------------------------------------
414// Vector load of 16 bytes (8bits signed) from memory
415class Load16BNode : public VectorLoadNode {
416 protected:
417  virtual BasicType elt_basic_type() const { return T_BYTE; }
418 public:
419  Load16BNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeInt *ti = TypeInt::BYTE)
420    : VectorLoadNode(c,mem,adr,at,vect_type(ti,16)) {}
421  virtual int Opcode() const;
422  virtual int store_Opcode() const { return Op_Store16B; }
423  virtual uint length() const { return 16; }
424};
425
426//------------------------------Load8BNode--------------------------------------
427// Vector load of 8 bytes (8bits signed) from memory
428class Load8BNode : public VectorLoadNode {
429 protected:
430  virtual BasicType elt_basic_type() const { return T_BYTE; }
431 public:
432  Load8BNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeInt *ti = TypeInt::BYTE)
433    : VectorLoadNode(c,mem,adr,at,vect_type(ti,8)) {}
434  virtual int Opcode() const;
435  virtual int store_Opcode() const { return Op_Store8B; }
436  virtual uint length() const { return 8; }
437};
438
439//------------------------------Load4BNode--------------------------------------
440// Vector load of 4 bytes (8bits signed) from memory
441class Load4BNode : public VectorLoadNode {
442 protected:
443  virtual BasicType elt_basic_type() const { return T_BYTE; }
444 public:
445  Load4BNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeInt *ti = TypeInt::BYTE)
446    : VectorLoadNode(c,mem,adr,at,vect_type(ti,4)) {}
447  virtual int Opcode() const;
448  virtual int store_Opcode() const { return Op_Store4B; }
449  virtual uint length() const { return 4; }
450};
451
452//------------------------------Load8CNode--------------------------------------
453// Vector load of 8 chars (16bits unsigned) from memory
454class Load8CNode : public VectorLoadNode {
455 protected:
456  virtual BasicType elt_basic_type() const { return T_CHAR; }
457 public:
458  Load8CNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeInt *ti = TypeInt::CHAR)
459    : VectorLoadNode(c,mem,adr,at,vect_type(ti,8)) {}
460  virtual int Opcode() const;
461  virtual int store_Opcode() const { return Op_Store8C; }
462  virtual uint length() const { return 8; }
463};
464
465//------------------------------Load4CNode--------------------------------------
466// Vector load of 4 chars (16bits unsigned) from memory
467class Load4CNode : public VectorLoadNode {
468 protected:
469  virtual BasicType elt_basic_type() const { return T_CHAR; }
470 public:
471  Load4CNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeInt *ti = TypeInt::CHAR)
472    : VectorLoadNode(c,mem,adr,at,vect_type(ti,4)) {}
473  virtual int Opcode() const;
474  virtual int store_Opcode() const { return Op_Store4C; }
475  virtual uint length() const { return 4; }
476};
477
478//------------------------------Load2CNode--------------------------------------
479// Vector load of 2 chars (16bits unsigned) from memory
480class Load2CNode : public VectorLoadNode {
481 protected:
482  virtual BasicType elt_basic_type() const { return T_CHAR; }
483 public:
484  Load2CNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeInt *ti = TypeInt::CHAR)
485    : VectorLoadNode(c,mem,adr,at,vect_type(ti,2)) {}
486  virtual int Opcode() const;
487  virtual int store_Opcode() const { return Op_Store2C; }
488  virtual uint length() const { return 2; }
489};
490
491//------------------------------Load8SNode--------------------------------------
492// Vector load of 8 shorts (16bits signed) from memory
493class Load8SNode : public VectorLoadNode {
494 protected:
495  virtual BasicType elt_basic_type() const { return T_SHORT; }
496 public:
497  Load8SNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeInt *ti = TypeInt::SHORT)
498    : VectorLoadNode(c,mem,adr,at,vect_type(ti,8)) {}
499  virtual int Opcode() const;
500  virtual int store_Opcode() const { return Op_Store8C; }
501  virtual uint length() const { return 8; }
502};
503
504//------------------------------Load4SNode--------------------------------------
505// Vector load of 4 shorts (16bits signed) from memory
506class Load4SNode : public VectorLoadNode {
507 protected:
508  virtual BasicType elt_basic_type() const { return T_SHORT; }
509 public:
510  Load4SNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeInt *ti = TypeInt::SHORT)
511    : VectorLoadNode(c,mem,adr,at,vect_type(ti,4)) {}
512  virtual int Opcode() const;
513  virtual int store_Opcode() const { return Op_Store4C; }
514  virtual uint length() const { return 4; }
515};
516
517//------------------------------Load2SNode--------------------------------------
518// Vector load of 2 shorts (16bits signed) from memory
519class Load2SNode : public VectorLoadNode {
520 protected:
521  virtual BasicType elt_basic_type() const { return T_SHORT; }
522 public:
523  Load2SNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeInt *ti = TypeInt::SHORT)
524    : VectorLoadNode(c,mem,adr,at,vect_type(ti,2)) {}
525  virtual int Opcode() const;
526  virtual int store_Opcode() const { return Op_Store2C; }
527  virtual uint length() const { return 2; }
528};
529
530//------------------------------Load4INode--------------------------------------
531// Vector load of 4 integers (32bits signed) from memory
532class Load4INode : public VectorLoadNode {
533 protected:
534  virtual BasicType elt_basic_type() const { return T_INT; }
535 public:
536  Load4INode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeInt *ti = TypeInt::INT)
537    : VectorLoadNode(c,mem,adr,at,vect_type(ti,4)) {}
538  virtual int Opcode() const;
539  virtual int store_Opcode() const { return Op_Store4I; }
540  virtual uint length() const { return 4; }
541};
542
543//------------------------------Load2INode--------------------------------------
544// Vector load of 2 integers (32bits signed) from memory
545class Load2INode : public VectorLoadNode {
546 protected:
547  virtual BasicType elt_basic_type() const { return T_INT; }
548 public:
549  Load2INode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeInt *ti = TypeInt::INT)
550    : VectorLoadNode(c,mem,adr,at,vect_type(ti,2)) {}
551  virtual int Opcode() const;
552  virtual int store_Opcode() const { return Op_Store2I; }
553  virtual uint length() const { return 2; }
554};
555
556//------------------------------Load2LNode--------------------------------------
557// Vector load of 2 longs (64bits signed) from memory
558class Load2LNode : public VectorLoadNode {
559 protected:
560  virtual BasicType elt_basic_type() const { return T_LONG; }
561 public:
562  Load2LNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const TypeLong *tl = TypeLong::LONG)
563    : VectorLoadNode(c,mem,adr,at,vect_type(tl,2)) {}
564  virtual int Opcode() const;
565  virtual int store_Opcode() const { return Op_Store2L; }
566  virtual uint length() const { return 2; }
567};
568
569//------------------------------Load4FNode--------------------------------------
570// Vector load of 4 floats (32bits) from memory
571class Load4FNode : public VectorLoadNode {
572 protected:
573  virtual BasicType elt_basic_type() const { return T_FLOAT; }
574 public:
575  Load4FNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const Type *t = Type::FLOAT)
576    : VectorLoadNode(c,mem,adr,at,vect_type(t,4)) {}
577  virtual int Opcode() const;
578  virtual int store_Opcode() const { return Op_Store4F; }
579  virtual uint length() const { return 4; }
580};
581
582//------------------------------Load2FNode--------------------------------------
583// Vector load of 2 floats (32bits) from memory
584class Load2FNode : public VectorLoadNode {
585 protected:
586  virtual BasicType elt_basic_type() const { return T_FLOAT; }
587 public:
588  Load2FNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const Type *t = Type::FLOAT)
589    : VectorLoadNode(c,mem,adr,at,vect_type(t,2)) {}
590  virtual int Opcode() const;
591  virtual int store_Opcode() const { return Op_Store2F; }
592  virtual uint length() const { return 2; }
593};
594
595//------------------------------Load2DNode--------------------------------------
596// Vector load of 2 doubles (64bits) from memory
597class Load2DNode : public VectorLoadNode {
598 protected:
599  virtual BasicType elt_basic_type() const { return T_DOUBLE; }
600 public:
601  Load2DNode(Node* c, Node* mem, Node* adr, const TypePtr* at, const Type *t = Type::DOUBLE)
602    : VectorLoadNode(c,mem,adr,at,vect_type(t,2)) {}
603  virtual int Opcode() const;
604  virtual int store_Opcode() const { return Op_Store2D; }
605  virtual uint length() const { return 2; }
606};
607
608
609//------------------------------VectorStoreNode--------------------------------------
610// Vector Store to memory
611class VectorStoreNode : public StoreNode {
612  virtual uint size_of() const { return sizeof(*this); }
613
614 protected:
615  virtual BasicType elt_basic_type()  const = 0; // Vector element basic type
616
617 public:
618  VectorStoreNode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val)
619    : StoreNode(c,mem,adr,at,val) {
620      init_flags(Flag_is_Vector);
621  }
622  virtual int Opcode() const;
623
624  virtual uint  length() const = 0; // Vector length
625
626  // Element and vector type
627  const Type* elt_type()  const { return Type::get_const_basic_type(elt_basic_type()); }
628  const Type* vect_type() const { return VectorNode::vect_type(elt_basic_type(), length()); }
629
630  virtual uint ideal_reg() const  { return Matcher::vector_ideal_reg(); }
631  virtual BasicType memory_type() const { return T_VOID; }
632  virtual int memory_size() const { return length()*type2aelembytes(elt_basic_type()); }
633
634  // Vector opcode from scalar opcode
635  static int opcode(int sopc, uint vlen);
636
637  static VectorStoreNode* make(Compile* C, int opc, Node* ctl, Node* mem,
638                               Node* adr, const TypePtr* atyp, VectorNode* val,
639                               uint vlen);
640};
641
642//------------------------------Store16BNode--------------------------------------
643// Vector store of 16 bytes (8bits signed) to memory
644class Store16BNode : public VectorStoreNode {
645 protected:
646  virtual BasicType elt_basic_type() const { return T_BYTE; }
647 public:
648  Store16BNode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val)
649    : VectorStoreNode(c,mem,adr,at,val) {}
650  virtual int Opcode() const;
651  virtual uint length() const { return 16; }
652};
653
654//------------------------------Store8BNode--------------------------------------
655// Vector store of 8 bytes (8bits signed) to memory
656class Store8BNode : public VectorStoreNode {
657 protected:
658  virtual BasicType elt_basic_type() const { return T_BYTE; }
659 public:
660  Store8BNode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val)
661    : VectorStoreNode(c,mem,adr,at,val) {}
662  virtual int Opcode() const;
663  virtual uint length() const { return 8; }
664};
665
666//------------------------------Store4BNode--------------------------------------
667// Vector store of 4 bytes (8bits signed) to memory
668class Store4BNode : public VectorStoreNode {
669 protected:
670  virtual BasicType elt_basic_type() const { return T_BYTE; }
671 public:
672  Store4BNode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val)
673    : VectorStoreNode(c,mem,adr,at,val) {}
674  virtual int Opcode() const;
675  virtual uint length() const { return 4; }
676};
677
678//------------------------------Store8CNode--------------------------------------
679// Vector store of 8 chars (16bits signed/unsigned) to memory
680class Store8CNode : public VectorStoreNode {
681 protected:
682  virtual BasicType elt_basic_type() const { return T_CHAR; }
683 public:
684  Store8CNode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val)
685    : VectorStoreNode(c,mem,adr,at,val) {}
686  virtual int Opcode() const;
687  virtual uint length() const { return 8; }
688};
689
690//------------------------------Store4CNode--------------------------------------
691// Vector store of 4 chars (16bits signed/unsigned) to memory
692class Store4CNode : public VectorStoreNode {
693 protected:
694  virtual BasicType elt_basic_type() const { return T_CHAR; }
695 public:
696  Store4CNode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val)
697    : VectorStoreNode(c,mem,adr,at,val) {}
698  virtual int Opcode() const;
699  virtual uint length() const { return 4; }
700};
701
702//------------------------------Store2CNode--------------------------------------
703// Vector store of 2 chars (16bits signed/unsigned) to memory
704class Store2CNode : public VectorStoreNode {
705 protected:
706  virtual BasicType elt_basic_type() const { return T_CHAR; }
707 public:
708  Store2CNode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val)
709    : VectorStoreNode(c,mem,adr,at,val) {}
710  virtual int Opcode() const;
711  virtual uint length() const { return 2; }
712};
713
714//------------------------------Store4INode--------------------------------------
715// Vector store of 4 integers (32bits signed) to memory
716class Store4INode : public VectorStoreNode {
717 protected:
718  virtual BasicType elt_basic_type() const { return T_INT; }
719 public:
720  Store4INode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val)
721    : VectorStoreNode(c,mem,adr,at,val) {}
722  virtual int Opcode() const;
723  virtual uint length() const { return 4; }
724};
725
726//------------------------------Store2INode--------------------------------------
727// Vector store of 2 integers (32bits signed) to memory
728class Store2INode : public VectorStoreNode {
729 protected:
730  virtual BasicType elt_basic_type() const { return T_INT; }
731 public:
732  Store2INode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val)
733    : VectorStoreNode(c,mem,adr,at,val) {}
734  virtual int Opcode() const;
735  virtual uint length() const { return 2; }
736};
737
738//------------------------------Store2LNode--------------------------------------
739// Vector store of 2 longs (64bits signed) to memory
740class Store2LNode : public VectorStoreNode {
741 protected:
742  virtual BasicType elt_basic_type() const { return T_LONG; }
743 public:
744  Store2LNode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val)
745    : VectorStoreNode(c,mem,adr,at,val) {}
746  virtual int Opcode() const;
747  virtual uint length() const { return 2; }
748};
749
750//------------------------------Store4FNode--------------------------------------
751// Vector store of 4 floats (32bits) to memory
752class Store4FNode : public VectorStoreNode {
753 protected:
754  virtual BasicType elt_basic_type() const { return T_FLOAT; }
755 public:
756  Store4FNode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val)
757    : VectorStoreNode(c,mem,adr,at,val) {}
758  virtual int Opcode() const;
759  virtual uint length() const { return 4; }
760};
761
762//------------------------------Store2FNode--------------------------------------
763// Vector store of 2 floats (32bits) to memory
764class Store2FNode : public VectorStoreNode {
765 protected:
766  virtual BasicType elt_basic_type() const { return T_FLOAT; }
767 public:
768  Store2FNode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val)
769    : VectorStoreNode(c,mem,adr,at,val) {}
770  virtual int Opcode() const;
771  virtual uint length() const { return 2; }
772};
773
774//------------------------------Store2DNode--------------------------------------
775// Vector store of 2 doubles (64bits) to memory
776class Store2DNode : public VectorStoreNode {
777 protected:
778  virtual BasicType elt_basic_type() const { return T_DOUBLE; }
779 public:
780  Store2DNode(Node* c, Node* mem, Node* adr, const TypePtr* at, Node* val)
781    : VectorStoreNode(c,mem,adr,at,val) {}
782  virtual int Opcode() const;
783  virtual uint length() const { return 2; }
784};
785
786//=========================Promote_Scalar_to_Vector====================================
787
788//------------------------------Replicate16BNode---------------------------------------
789// Replicate byte scalar to be vector of 16 bytes
790class Replicate16BNode : public VectorNode {
791 protected:
792  virtual BasicType elt_basic_type() const { return T_BYTE; }
793 public:
794  Replicate16BNode(Node* in1) : VectorNode(in1, 16) {}
795  virtual int Opcode() const;
796};
797
798//------------------------------Replicate8BNode---------------------------------------
799// Replicate byte scalar to be vector of 8 bytes
800class Replicate8BNode : public VectorNode {
801 protected:
802  virtual BasicType elt_basic_type() const { return T_BYTE; }
803 public:
804  Replicate8BNode(Node* in1) : VectorNode(in1, 8) {}
805  virtual int Opcode() const;
806};
807
808//------------------------------Replicate4BNode---------------------------------------
809// Replicate byte scalar to be vector of 4 bytes
810class Replicate4BNode : public VectorNode {
811 protected:
812  virtual BasicType elt_basic_type() const { return T_BYTE; }
813 public:
814  Replicate4BNode(Node* in1) : VectorNode(in1, 4) {}
815  virtual int Opcode() const;
816};
817
818//------------------------------Replicate8CNode---------------------------------------
819// Replicate char scalar to be vector of 8 chars
820class Replicate8CNode : public VectorNode {
821 protected:
822  virtual BasicType elt_basic_type() const { return T_CHAR; }
823 public:
824  Replicate8CNode(Node* in1) : VectorNode(in1, 8) {}
825  virtual int Opcode() const;
826};
827
828//------------------------------Replicate4CNode---------------------------------------
829// Replicate char scalar to be vector of 4 chars
830class Replicate4CNode : public VectorNode {
831 protected:
832  virtual BasicType elt_basic_type() const { return T_CHAR; }
833 public:
834  Replicate4CNode(Node* in1) : VectorNode(in1, 4) {}
835  virtual int Opcode() const;
836};
837
838//------------------------------Replicate2CNode---------------------------------------
839// Replicate char scalar to be vector of 2 chars
840class Replicate2CNode : public VectorNode {
841 protected:
842  virtual BasicType elt_basic_type() const { return T_CHAR; }
843 public:
844  Replicate2CNode(Node* in1) : VectorNode(in1, 2) {}
845  virtual int Opcode() const;
846};
847
848//------------------------------Replicate8SNode---------------------------------------
849// Replicate short scalar to be vector of 8 shorts
850class Replicate8SNode : public VectorNode {
851 protected:
852  virtual BasicType elt_basic_type() const { return T_SHORT; }
853 public:
854  Replicate8SNode(Node* in1) : VectorNode(in1, 8) {}
855  virtual int Opcode() const;
856};
857
858//------------------------------Replicate4SNode---------------------------------------
859// Replicate short scalar to be vector of 4 shorts
860class Replicate4SNode : public VectorNode {
861 protected:
862  virtual BasicType elt_basic_type() const { return T_SHORT; }
863 public:
864  Replicate4SNode(Node* in1) : VectorNode(in1, 4) {}
865  virtual int Opcode() const;
866};
867
868//------------------------------Replicate2SNode---------------------------------------
869// Replicate short scalar to be vector of 2 shorts
870class Replicate2SNode : public VectorNode {
871 protected:
872  virtual BasicType elt_basic_type() const { return T_SHORT; }
873 public:
874  Replicate2SNode(Node* in1) : VectorNode(in1, 2) {}
875  virtual int Opcode() const;
876};
877
878//------------------------------Replicate4INode---------------------------------------
879// Replicate int scalar to be vector of 4 ints
880class Replicate4INode : public VectorNode {
881 protected:
882  virtual BasicType elt_basic_type() const { return T_INT; }
883 public:
884  Replicate4INode(Node* in1) : VectorNode(in1, 4) {}
885  virtual int Opcode() const;
886};
887
888//------------------------------Replicate2INode---------------------------------------
889// Replicate int scalar to be vector of 2 ints
890class Replicate2INode : public VectorNode {
891 protected:
892  virtual BasicType elt_basic_type() const { return T_INT; }
893 public:
894  Replicate2INode(Node* in1) : VectorNode(in1, 2) {}
895  virtual int Opcode() const;
896};
897
898//------------------------------Replicate2LNode---------------------------------------
899// Replicate long scalar to be vector of 2 longs
900class Replicate2LNode : public VectorNode {
901 protected:
902  virtual BasicType elt_basic_type() const { return T_LONG; }
903 public:
904  Replicate2LNode(Node* in1) : VectorNode(in1, 2) {}
905  virtual int Opcode() const;
906};
907
908//------------------------------Replicate4FNode---------------------------------------
909// Replicate float scalar to be vector of 4 floats
910class Replicate4FNode : public VectorNode {
911 protected:
912  virtual BasicType elt_basic_type() const { return T_FLOAT; }
913 public:
914  Replicate4FNode(Node* in1) : VectorNode(in1, 4) {}
915  virtual int Opcode() const;
916};
917
918//------------------------------Replicate2FNode---------------------------------------
919// Replicate float scalar to be vector of 2 floats
920class Replicate2FNode : public VectorNode {
921 protected:
922  virtual BasicType elt_basic_type() const { return T_FLOAT; }
923 public:
924  Replicate2FNode(Node* in1) : VectorNode(in1, 2) {}
925  virtual int Opcode() const;
926};
927
928//------------------------------Replicate2DNode---------------------------------------
929// Replicate double scalar to be vector of 2 doubles
930class Replicate2DNode : public VectorNode {
931 protected:
932  virtual BasicType elt_basic_type() const { return T_DOUBLE; }
933 public:
934  Replicate2DNode(Node* in1) : VectorNode(in1, 2) {}
935  virtual int Opcode() const;
936};
937
938//========================Pack_Scalars_into_a_Vector==============================
939
940//------------------------------PackNode---------------------------------------
941// Pack parent class (not for code generation).
942class PackNode : public VectorNode {
943 public:
944  PackNode(Node* in1)  : VectorNode(in1, 1) {}
945  PackNode(Node* in1, Node* n2)  : VectorNode(in1, n2, 2) {}
946  virtual int Opcode() const;
947
948  void add_opd(Node* n) {
949    add_req(n);
950    _length++;
951    assert(_length == req() - 1, "vector length matches edge count");
952  }
953
954  // Create a binary tree form for Packs. [lo, hi) (half-open) range
955  Node* binaryTreePack(Compile* C, int lo, int hi);
956
957  static PackNode* make(Compile* C, Node* s, const Type* elt_t);
958};
959
960//------------------------------PackBNode---------------------------------------
961// Pack byte scalars into vector
962class PackBNode : public PackNode {
963 protected:
964  virtual BasicType elt_basic_type() const { return T_BYTE; }
965 public:
966  PackBNode(Node* in1)  : PackNode(in1) {}
967  virtual int Opcode() const;
968};
969
970//------------------------------PackCNode---------------------------------------
971// Pack char scalars into vector
972class PackCNode : public PackNode {
973 protected:
974  virtual BasicType elt_basic_type() const { return T_CHAR; }
975 public:
976  PackCNode(Node* in1)  : PackNode(in1) {}
977  virtual int Opcode() const;
978};
979
980//------------------------------PackSNode---------------------------------------
981// Pack short scalars into a vector
982class PackSNode : public PackNode {
983 protected:
984  virtual BasicType elt_basic_type() const { return T_SHORT; }
985 public:
986  PackSNode(Node* in1)  : PackNode(in1) {}
987  virtual int Opcode() const;
988};
989
990//------------------------------PackINode---------------------------------------
991// Pack integer scalars into a vector
992class PackINode : public PackNode {
993 protected:
994  virtual BasicType elt_basic_type() const { return T_INT; }
995 public:
996  PackINode(Node* in1)  : PackNode(in1) {}
997  PackINode(Node* in1, Node* in2) : PackNode(in1, in2) {}
998  virtual int Opcode() const;
999};
1000
1001//------------------------------PackLNode---------------------------------------
1002// Pack long scalars into a vector
1003class PackLNode : public PackNode {
1004 protected:
1005  virtual BasicType elt_basic_type() const { return T_LONG; }
1006 public:
1007  PackLNode(Node* in1)  : PackNode(in1) {}
1008  PackLNode(Node* in1, Node* in2) : PackNode(in1, in2) {}
1009  virtual int Opcode() const;
1010};
1011
1012//------------------------------PackFNode---------------------------------------
1013// Pack float scalars into vector
1014class PackFNode : public PackNode {
1015 protected:
1016  virtual BasicType elt_basic_type() const { return T_FLOAT; }
1017 public:
1018  PackFNode(Node* in1)  : PackNode(in1) {}
1019  PackFNode(Node* in1, Node* in2) : PackNode(in1, in2) {}
1020  virtual int Opcode() const;
1021};
1022
1023//------------------------------PackDNode---------------------------------------
1024// Pack double scalars into a vector
1025class PackDNode : public PackNode {
1026 protected:
1027  virtual BasicType elt_basic_type() const { return T_DOUBLE; }
1028 public:
1029  PackDNode(Node* in1)  : PackNode(in1) {}
1030  PackDNode(Node* in1, Node* in2) : PackNode(in1, in2) {}
1031  virtual int Opcode() const;
1032};
1033
1034// The Pack2xN nodes assist code generation.  They are created from
1035// Pack4C, etc. nodes in final_graph_reshape in the form of a
1036// balanced, binary tree.
1037
1038//------------------------------Pack2x1BNode-----------------------------------------
1039// Pack 2 1-byte integers into vector of 2 bytes
1040class Pack2x1BNode : public PackNode {
1041 protected:
1042  virtual BasicType elt_basic_type() const { return T_BYTE; }
1043 public:
1044  Pack2x1BNode(Node *in1, Node* in2) : PackNode(in1, in2) {}
1045  virtual int Opcode() const;
1046  virtual uint ideal_reg() const { return Op_RegI; }
1047};
1048
1049//------------------------------Pack2x2BNode---------------------------------------
1050// Pack 2 2-byte integers into vector of 4 bytes
1051class Pack2x2BNode : public PackNode {
1052 protected:
1053  virtual BasicType elt_basic_type() const { return T_CHAR; }
1054 public:
1055  Pack2x2BNode(Node *in1, Node* in2) : PackNode(in1, in2) {}
1056  virtual int Opcode() const;
1057  virtual uint ideal_reg() const { return Op_RegI; }
1058};
1059
1060//========================Extract_Scalar_from_Vector===============================
1061
1062//------------------------------ExtractNode---------------------------------------
1063// Extract a scalar from a vector at position "pos"
1064class ExtractNode : public Node {
1065 public:
1066  ExtractNode(Node* src, ConINode* pos) : Node(NULL, src, (Node*)pos) {
1067    assert(in(2)->get_int() >= 0, "positive constants");
1068  }
1069  virtual int Opcode() const;
1070  uint  pos() const { return in(2)->get_int(); }
1071
1072  static Node* make(Compile* C, Node* v, uint position, const Type* opd_t);
1073};
1074
1075//------------------------------ExtractBNode---------------------------------------
1076// Extract a byte from a vector at position "pos"
1077class ExtractBNode : public ExtractNode {
1078 public:
1079  ExtractBNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {}
1080  virtual int Opcode() const;
1081  virtual const Type *bottom_type() const { return TypeInt::INT; }
1082  virtual uint ideal_reg() const { return Op_RegI; }
1083};
1084
1085//------------------------------ExtractCNode---------------------------------------
1086// Extract a char from a vector at position "pos"
1087class ExtractCNode : public ExtractNode {
1088 public:
1089  ExtractCNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {}
1090  virtual int Opcode() const;
1091  virtual const Type *bottom_type() const { return TypeInt::INT; }
1092  virtual uint ideal_reg() const { return Op_RegI; }
1093};
1094
1095//------------------------------ExtractSNode---------------------------------------
1096// Extract a short from a vector at position "pos"
1097class ExtractSNode : public ExtractNode {
1098 public:
1099  ExtractSNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {}
1100  virtual int Opcode() const;
1101  virtual const Type *bottom_type() const { return TypeInt::INT; }
1102  virtual uint ideal_reg() const { return Op_RegI; }
1103};
1104
1105//------------------------------ExtractINode---------------------------------------
1106// Extract an int from a vector at position "pos"
1107class ExtractINode : public ExtractNode {
1108 public:
1109  ExtractINode(Node* src, ConINode* pos) : ExtractNode(src, pos) {}
1110  virtual int Opcode() const;
1111  virtual const Type *bottom_type() const { return TypeInt::INT; }
1112  virtual uint ideal_reg() const { return Op_RegI; }
1113};
1114
1115//------------------------------ExtractLNode---------------------------------------
1116// Extract a long from a vector at position "pos"
1117class ExtractLNode : public ExtractNode {
1118 public:
1119  ExtractLNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {}
1120  virtual int Opcode() const;
1121  virtual const Type *bottom_type() const { return TypeLong::LONG; }
1122  virtual uint ideal_reg() const { return Op_RegL; }
1123};
1124
1125//------------------------------ExtractFNode---------------------------------------
1126// Extract a float from a vector at position "pos"
1127class ExtractFNode : public ExtractNode {
1128 public:
1129  ExtractFNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {}
1130  virtual int Opcode() const;
1131  virtual const Type *bottom_type() const { return Type::FLOAT; }
1132  virtual uint ideal_reg() const { return Op_RegF; }
1133};
1134
1135//------------------------------ExtractDNode---------------------------------------
1136// Extract a double from a vector at position "pos"
1137class ExtractDNode : public ExtractNode {
1138 public:
1139  ExtractDNode(Node* src, ConINode* pos) : ExtractNode(src, pos) {}
1140  virtual int Opcode() const;
1141  virtual const Type *bottom_type() const { return Type::DOUBLE; }
1142  virtual uint ideal_reg() const { return Op_RegD; }
1143};
1144
1145#endif // SHARE_VM_OPTO_VECTORNODE_HPP
1146