Commit a60f1922 authored by rossberg's avatar rossberg Committed by Commit bot

[simd] Introduce SIMD types (as classes)

- Introduce a proper bit for SIMD primitive values.
- Introduce constructors for individual SIMD types. These are currently just classes, which seems good enough for now, given that we always have exactly one global map per SIMD type.

The only problem with using class types for SIMD is that a SIMD constant won't be a subtype of its specific type, only of the general SIMD type. But until we actually introduce SIMD constants into the compiler that shouldn't matter.

R=jarin@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1303863002

Cr-Commit-Position: refs/heads/master@{#30294}
parent 0afbd7ad
...@@ -16,19 +16,29 @@ namespace internal { ...@@ -16,19 +16,29 @@ namespace internal {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// TypeImpl // TypeImpl
template <class Config> template<class Config>
typename TypeImpl<Config>::bitset TypeImpl<Config>::BitsetType::SignedSmall() { typename TypeImpl<Config>::bitset TypeImpl<Config>::BitsetType::SignedSmall() {
return i::SmiValuesAre31Bits() ? kSigned31 : kSigned32; return i::SmiValuesAre31Bits() ? kSigned31 : kSigned32;
} }
template <class Config> template<class Config>
typename TypeImpl<Config>::bitset typename TypeImpl<Config>::bitset
TypeImpl<Config>::BitsetType::UnsignedSmall() { TypeImpl<Config>::BitsetType::UnsignedSmall() {
return i::SmiValuesAre31Bits() ? kUnsigned30 : kUnsigned31; return i::SmiValuesAre31Bits() ? kUnsigned30 : kUnsigned31;
} }
#define CONSTRUCT_SIMD_TYPE(NAME, Name, name, lane_count, lane_type) \
template<class Config> \
typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Name( \
Isolate* isolate, Region* region) { \
return Class(i::handle(isolate->heap()->name##_map()), region); \
}
SIMD128_TYPES(CONSTRUCT_SIMD_TYPE)
#undef CONSTRUCT_SIMD_TYPE
template<class Config> template<class Config>
TypeImpl<Config>* TypeImpl<Config>::cast(typename Config::Base* object) { TypeImpl<Config>* TypeImpl<Config>::cast(typename Config::Base* object) {
TypeImpl* t = static_cast<TypeImpl*>(object); TypeImpl* t = static_cast<TypeImpl*>(object);
......
...@@ -229,8 +229,7 @@ TypeImpl<Config>::BitsetType::Lub(i::Map* map) { ...@@ -229,8 +229,7 @@ TypeImpl<Config>::BitsetType::Lub(i::Map* map) {
case HEAP_NUMBER_TYPE: case HEAP_NUMBER_TYPE:
return kNumber & kTaggedPointer; return kNumber & kTaggedPointer;
case SIMD128_VALUE_TYPE: case SIMD128_VALUE_TYPE:
// TODO(bbudge): Add type bits for SIMD value types. return kSimd;
return kAny;
case JS_VALUE_TYPE: case JS_VALUE_TYPE:
case JS_DATE_TYPE: case JS_DATE_TYPE:
case JS_OBJECT_TYPE: case JS_OBJECT_TYPE:
......
...@@ -207,8 +207,8 @@ namespace internal { ...@@ -207,8 +207,8 @@ namespace internal {
V(Symbol, 1u << 12 | REPRESENTATION(kTaggedPointer)) \ V(Symbol, 1u << 12 | REPRESENTATION(kTaggedPointer)) \
V(InternalizedString, 1u << 13 | REPRESENTATION(kTaggedPointer)) \ V(InternalizedString, 1u << 13 | REPRESENTATION(kTaggedPointer)) \
V(OtherString, 1u << 14 | REPRESENTATION(kTaggedPointer)) \ V(OtherString, 1u << 14 | REPRESENTATION(kTaggedPointer)) \
V(Undetectable, 1u << 15 | REPRESENTATION(kTaggedPointer)) \ V(Simd, 1u << 15 | REPRESENTATION(kTaggedPointer)) \
/* Unused semantic bit 1u << 16 in case you are looking for a bit. */ \ V(Undetectable, 1u << 16 | REPRESENTATION(kTaggedPointer)) \
V(OtherObject, 1u << 17 | REPRESENTATION(kTaggedPointer)) \ V(OtherObject, 1u << 17 | REPRESENTATION(kTaggedPointer)) \
V(Proxy, 1u << 18 | REPRESENTATION(kTaggedPointer)) \ V(Proxy, 1u << 18 | REPRESENTATION(kTaggedPointer)) \
V(Internal, 1u << 19 | REPRESENTATION(kTagged | kUntagged)) \ V(Internal, 1u << 19 | REPRESENTATION(kTagged | kUntagged)) \
...@@ -231,7 +231,7 @@ namespace internal { ...@@ -231,7 +231,7 @@ namespace internal {
V(NumberOrString, kNumber | kString) \ V(NumberOrString, kNumber | kString) \
V(NumberOrUndefined, kNumber | kUndefined) \ V(NumberOrUndefined, kNumber | kUndefined) \
V(PlainPrimitive, kNumberOrString | kBoolean | kNullOrUndefined) \ V(PlainPrimitive, kNumberOrString | kBoolean | kNullOrUndefined) \
V(Primitive, kSymbol | kPlainPrimitive) \ V(Primitive, kSymbol | kSimd | kPlainPrimitive) \
V(DetectableReceiver, kOtherObject | kProxy) \ V(DetectableReceiver, kOtherObject | kProxy) \
V(Detectable, kDetectableReceiver | kNumber | kName) \ V(Detectable, kDetectableReceiver | kNumber | kName) \
V(Object, kOtherObject | kUndetectable) \ V(Object, kOtherObject | kUndetectable) \
...@@ -277,6 +277,7 @@ namespace internal { ...@@ -277,6 +277,7 @@ namespace internal {
// typedef Range; // typedef Range;
// typedef Region; // typedef Region;
// template<class> struct Handle { typedef type; } // No template typedefs... // template<class> struct Handle { typedef type; } // No template typedefs...
//
// template<class T> static Handle<T>::type null_handle(); // template<class T> static Handle<T>::type null_handle();
// template<class T> static Handle<T>::type handle(T* t); // !is_bitset(t) // template<class T> static Handle<T>::type handle(T* t); // !is_bitset(t)
// template<class T> static Handle<T>::type cast(Handle<Type>::type); // template<class T> static Handle<T>::type cast(Handle<Type>::type);
...@@ -423,6 +424,11 @@ class TypeImpl : public Config::Base { ...@@ -423,6 +424,11 @@ class TypeImpl : public Config::Base {
return function; return function;
} }
#define CONSTRUCT_SIMD_TYPE(NAME, Name, name, lane_count, lane_type) \
static TypeHandle Name(Isolate* isolate, Region* region);
SIMD128_TYPES(CONSTRUCT_SIMD_TYPE)
#undef CONSTRUCT_SIMD_TYPE
static TypeHandle Union(TypeHandle type1, TypeHandle type2, Region* reg); static TypeHandle Union(TypeHandle type1, TypeHandle type2, Region* reg);
static TypeHandle Intersect(TypeHandle type1, TypeHandle type2, Region* reg); static TypeHandle Intersect(TypeHandle type1, TypeHandle type2, Region* reg);
static TypeImpl* Union(TypeImpl* type1, TypeImpl* type2) { static TypeImpl* Union(TypeImpl* type1, TypeImpl* type2) {
......
...@@ -39,7 +39,7 @@ template<class Type, class TypeHandle, class Region> ...@@ -39,7 +39,7 @@ template<class Type, class TypeHandle, class Region>
class Types { class Types {
public: public:
Types(Region* region, Isolate* isolate, v8::base::RandomNumberGenerator* rng) Types(Region* region, Isolate* isolate, v8::base::RandomNumberGenerator* rng)
: region_(region), rng_(rng) { : region_(region), isolate_(isolate), rng_(rng) {
#define DECLARE_TYPE(name, value) \ #define DECLARE_TYPE(name, value) \
name = Type::name(region); \ name = Type::name(region); \
types.push_back(name); types.push_back(name);
...@@ -304,6 +304,21 @@ class Types { ...@@ -304,6 +304,21 @@ class Types {
} }
return type; return type;
} }
case 8: { // simd
static const int num_simd_types =
#define COUNT_SIMD_TYPE(NAME, Name, name, lane_count, lane_type) +1
SIMD128_TYPES(COUNT_SIMD_TYPE)
#undef COUNT_SIMD_TYPE
;
TypeHandle (*simd_constructors[num_simd_types])(Isolate*, Region*) = {
#define COUNT_SIMD_TYPE(NAME, Name, name, lane_count, lane_type) \
&Type::Name,
SIMD128_TYPES(COUNT_SIMD_TYPE)
#undef COUNT_SIMD_TYPE
};
return simd_constructors[rng_->NextInt(num_simd_types)](
isolate_, region_);
}
default: { // union default: { // union
int n = rng_->NextInt(10); int n = rng_->NextInt(10);
TypeHandle type = None; TypeHandle type = None;
...@@ -321,6 +336,7 @@ class Types { ...@@ -321,6 +336,7 @@ class Types {
private: private:
Region* region_; Region* region_;
Isolate* isolate_;
v8::base::RandomNumberGenerator* rng_; v8::base::RandomNumberGenerator* rng_;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment