src/share/vm/opto/type.cpp

changeset 3882
8c92982cbbc4
parent 2658
c7f3d0b4570f
child 3885
765ee2d1674b
     1.1 --- a/src/share/vm/opto/type.cpp	Thu Jun 14 14:59:52 2012 -0700
     1.2 +++ b/src/share/vm/opto/type.cpp	Fri Jun 15 01:25:19 2012 -0700
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -60,6 +60,10 @@
    1.11  
    1.12    T_ILLEGAL,    // Tuple
    1.13    T_ARRAY,      // Array
    1.14 +  T_ILLEGAL,    // VectorS
    1.15 +  T_ILLEGAL,    // VectorD
    1.16 +  T_ILLEGAL,    // VectorX
    1.17 +  T_ILLEGAL,    // VectorY
    1.18  
    1.19    T_ADDRESS,    // AnyPtr   // shows up in factory methods for NULL_PTR
    1.20    T_ADDRESS,    // RawPtr
    1.21 @@ -414,6 +418,24 @@
    1.22    // get_zero_type() should not happen for T_CONFLICT
    1.23    _zero_type[T_CONFLICT]= NULL;
    1.24  
    1.25 +  // Vector predefined types, it needs initialized _const_basic_type[].
    1.26 +  if (Matcher::vector_size_supported(T_BYTE,4)) {
    1.27 +    TypeVect::VECTS = TypeVect::make(T_BYTE,4);
    1.28 +  }
    1.29 +  if (Matcher::vector_size_supported(T_FLOAT,2)) {
    1.30 +    TypeVect::VECTD = TypeVect::make(T_FLOAT,2);
    1.31 +  }
    1.32 +  if (Matcher::vector_size_supported(T_FLOAT,4)) {
    1.33 +    TypeVect::VECTX = TypeVect::make(T_FLOAT,4);
    1.34 +  }
    1.35 +  if (Matcher::vector_size_supported(T_FLOAT,8)) {
    1.36 +    TypeVect::VECTY = TypeVect::make(T_FLOAT,8);
    1.37 +  }
    1.38 +  mreg2type[Op_VecS] = TypeVect::VECTS;
    1.39 +  mreg2type[Op_VecD] = TypeVect::VECTD;
    1.40 +  mreg2type[Op_VecX] = TypeVect::VECTX;
    1.41 +  mreg2type[Op_VecY] = TypeVect::VECTY;
    1.42 +
    1.43    // Restore working type arena.
    1.44    current->set_type_arena(save);
    1.45    current->set_type_dict(NULL);
    1.46 @@ -668,6 +690,10 @@
    1.47  
    1.48    Bad,          // Tuple - handled in v-call
    1.49    Bad,          // Array - handled in v-call
    1.50 +  Bad,          // VectorS - handled in v-call
    1.51 +  Bad,          // VectorD - handled in v-call
    1.52 +  Bad,          // VectorX - handled in v-call
    1.53 +  Bad,          // VectorY - handled in v-call
    1.54  
    1.55    Bad,          // AnyPtr - handled in v-call
    1.56    Bad,          // RawPtr - handled in v-call
    1.57 @@ -728,8 +754,8 @@
    1.58  //------------------------------data-------------------------------------------
    1.59  const char * const Type::msg[Type::lastype] = {
    1.60    "bad","control","top","int:","long:","half", "narrowoop:",
    1.61 -  "tuple:", "aryptr",
    1.62 -  "anyptr:", "rawptr:", "java:", "inst:", "ary:", "klass:",
    1.63 +  "tuple:", "array:", "vectors:", "vectord:", "vectorx:", "vectory:",
    1.64 +  "anyptr:", "rawptr:", "java:", "inst:", "aryptr:", "klass:",
    1.65    "func", "abIO", "return_address", "memory",
    1.66    "float_top", "ftcon:", "float",
    1.67    "double_top", "dblcon:", "double",
    1.68 @@ -790,7 +816,7 @@
    1.69  //------------------------------isa_oop_ptr------------------------------------
    1.70  // Return true if type is an oop pointer type.  False for raw pointers.
    1.71  static char isa_oop_ptr_tbl[Type::lastype] = {
    1.72 -  0,0,0,0,0,0,0/*narrowoop*/,0/*tuple*/, 0/*ary*/,
    1.73 +  0,0,0,0,0,0,0/*narrowoop*/,0/*tuple*/, 0/*array*/, 0, 0, 0, 0/*vector*/,
    1.74    0/*anyptr*/,0/*rawptr*/,1/*OopPtr*/,1/*InstPtr*/,1/*AryPtr*/,1/*KlassPtr*/,
    1.75    0/*func*/,0,0/*return_address*/,0,
    1.76    /*floats*/0,0,0, /*doubles*/0,0,0,
    1.77 @@ -1926,6 +1952,121 @@
    1.78    return false;
    1.79  }
    1.80  
    1.81 +//==============================TypeVect=======================================
    1.82 +// Convenience common pre-built types.
    1.83 +const TypeVect *TypeVect::VECTS = NULL; //  32-bit vectors
    1.84 +const TypeVect *TypeVect::VECTD = NULL; //  64-bit vectors
    1.85 +const TypeVect *TypeVect::VECTX = NULL; // 128-bit vectors
    1.86 +const TypeVect *TypeVect::VECTY = NULL; // 256-bit vectors
    1.87 +
    1.88 +//------------------------------make-------------------------------------------
    1.89 +const TypeVect* TypeVect::make(const Type *elem, uint length) {
    1.90 +  BasicType elem_bt = elem->array_element_basic_type();
    1.91 +  assert(is_java_primitive(elem_bt), "only primitive types in vector");
    1.92 +  assert(length > 1 && is_power_of_2(length), "vector length is power of 2");
    1.93 +  assert(Matcher::vector_size_supported(elem_bt, length), "length in range");
    1.94 +  int size = length * type2aelembytes(elem_bt);
    1.95 +  switch (Matcher::vector_ideal_reg(size)) {
    1.96 +  case Op_VecS:
    1.97 +    return (TypeVect*)(new TypeVectS(elem, length))->hashcons();
    1.98 +  case Op_VecD:
    1.99 +  case Op_RegD:
   1.100 +    return (TypeVect*)(new TypeVectD(elem, length))->hashcons();
   1.101 +  case Op_VecX:
   1.102 +    return (TypeVect*)(new TypeVectX(elem, length))->hashcons();
   1.103 +  case Op_VecY:
   1.104 +    return (TypeVect*)(new TypeVectY(elem, length))->hashcons();
   1.105 +  }
   1.106 + ShouldNotReachHere();
   1.107 +  return NULL;
   1.108 +}
   1.109 +
   1.110 +//------------------------------meet-------------------------------------------
   1.111 +// Compute the MEET of two types.  It returns a new Type object.
   1.112 +const Type *TypeVect::xmeet( const Type *t ) const {
   1.113 +  // Perform a fast test for common case; meeting the same types together.
   1.114 +  if( this == t ) return this;  // Meeting same type-rep?
   1.115 +
   1.116 +  // Current "this->_base" is Vector
   1.117 +  switch (t->base()) {          // switch on original type
   1.118 +
   1.119 +  case Bottom:                  // Ye Olde Default
   1.120 +    return t;
   1.121 +
   1.122 +  default:                      // All else is a mistake
   1.123 +    typerr(t);
   1.124 +
   1.125 +  case VectorS:
   1.126 +  case VectorD:
   1.127 +  case VectorX:
   1.128 +  case VectorY: {                // Meeting 2 vectors?
   1.129 +    const TypeVect* v = t->is_vect();
   1.130 +    assert(  base() == v->base(), "");
   1.131 +    assert(length() == v->length(), "");
   1.132 +    assert(element_basic_type() == v->element_basic_type(), "");
   1.133 +    return TypeVect::make(_elem->xmeet(v->_elem), _length);
   1.134 +  }
   1.135 +  case Top:
   1.136 +    break;
   1.137 +  }
   1.138 +  return this;
   1.139 +}
   1.140 +
   1.141 +//------------------------------xdual------------------------------------------
   1.142 +// Dual: compute field-by-field dual
   1.143 +const Type *TypeVect::xdual() const {
   1.144 +  return new TypeVect(base(), _elem->dual(), _length);
   1.145 +}
   1.146 +
   1.147 +//------------------------------eq---------------------------------------------
   1.148 +// Structural equality check for Type representations
   1.149 +bool TypeVect::eq(const Type *t) const {
   1.150 +  const TypeVect *v = t->is_vect();
   1.151 +  return (_elem == v->_elem) && (_length == v->_length);
   1.152 +}
   1.153 +
   1.154 +//------------------------------hash-------------------------------------------
   1.155 +// Type-specific hashing function.
   1.156 +int TypeVect::hash(void) const {
   1.157 +  return (intptr_t)_elem + (intptr_t)_length;
   1.158 +}
   1.159 +
   1.160 +//------------------------------singleton--------------------------------------
   1.161 +// TRUE if Type is a singleton type, FALSE otherwise.   Singletons are simple
   1.162 +// constants (Ldi nodes).  Vector is singleton if all elements are the same
   1.163 +// constant value (when vector is created with Replicate code).
   1.164 +bool TypeVect::singleton(void) const {
   1.165 +// There is no Con node for vectors yet.
   1.166 +//  return _elem->singleton();
   1.167 +  return false;
   1.168 +}
   1.169 +
   1.170 +bool TypeVect::empty(void) const {
   1.171 +  return _elem->empty();
   1.172 +}
   1.173 +
   1.174 +//------------------------------dump2------------------------------------------
   1.175 +#ifndef PRODUCT
   1.176 +void TypeVect::dump2(Dict &d, uint depth, outputStream *st) const {
   1.177 +  switch (base()) {
   1.178 +  case VectorS:
   1.179 +    st->print("vectors["); break;
   1.180 +  case VectorD:
   1.181 +    st->print("vectord["); break;
   1.182 +  case VectorX:
   1.183 +    st->print("vectorx["); break;
   1.184 +  case VectorY:
   1.185 +    st->print("vectory["); break;
   1.186 +  default:
   1.187 +    ShouldNotReachHere();
   1.188 +  }
   1.189 +  st->print("%d]:{", _length);
   1.190 +  _elem->dump2(d, depth, st);
   1.191 +  st->print("}");
   1.192 +}
   1.193 +#endif
   1.194 +
   1.195 +
   1.196  //=============================================================================
   1.197  // Convenience common pre-built types.
   1.198  const TypePtr *TypePtr::NULL_PTR;
   1.199 @@ -4140,7 +4281,7 @@
   1.200  // Print a 'flattened' signature
   1.201  static const char * const flat_type_msg[Type::lastype] = {
   1.202    "bad","control","top","int","long","_", "narrowoop",
   1.203 -  "tuple:", "array:",
   1.204 +  "tuple:", "array:", "vectors:", "vectord:", "vectorx:", "vectory:",
   1.205    "ptr", "rawptr", "ptr", "ptr", "ptr", "ptr",
   1.206    "func", "abIO", "return_address", "mem",
   1.207    "float_top", "ftcon:", "flt",

mercurial