[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}
This commit is contained in:
parent
0afbd7add0
commit
a60f19220a
@ -16,19 +16,29 @@ namespace internal {
|
||||
// -----------------------------------------------------------------------------
|
||||
// TypeImpl
|
||||
|
||||
template <class Config>
|
||||
template<class Config>
|
||||
typename TypeImpl<Config>::bitset TypeImpl<Config>::BitsetType::SignedSmall() {
|
||||
return i::SmiValuesAre31Bits() ? kSigned31 : kSigned32;
|
||||
}
|
||||
|
||||
|
||||
template <class Config>
|
||||
template<class Config>
|
||||
typename TypeImpl<Config>::bitset
|
||||
TypeImpl<Config>::BitsetType::UnsignedSmall() {
|
||||
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>
|
||||
TypeImpl<Config>* TypeImpl<Config>::cast(typename Config::Base* object) {
|
||||
TypeImpl* t = static_cast<TypeImpl*>(object);
|
||||
|
@ -229,8 +229,7 @@ TypeImpl<Config>::BitsetType::Lub(i::Map* map) {
|
||||
case HEAP_NUMBER_TYPE:
|
||||
return kNumber & kTaggedPointer;
|
||||
case SIMD128_VALUE_TYPE:
|
||||
// TODO(bbudge): Add type bits for SIMD value types.
|
||||
return kAny;
|
||||
return kSimd;
|
||||
case JS_VALUE_TYPE:
|
||||
case JS_DATE_TYPE:
|
||||
case JS_OBJECT_TYPE:
|
||||
|
12
src/types.h
12
src/types.h
@ -207,8 +207,8 @@ namespace internal {
|
||||
V(Symbol, 1u << 12 | REPRESENTATION(kTaggedPointer)) \
|
||||
V(InternalizedString, 1u << 13 | REPRESENTATION(kTaggedPointer)) \
|
||||
V(OtherString, 1u << 14 | REPRESENTATION(kTaggedPointer)) \
|
||||
V(Undetectable, 1u << 15 | REPRESENTATION(kTaggedPointer)) \
|
||||
/* Unused semantic bit 1u << 16 in case you are looking for a bit. */ \
|
||||
V(Simd, 1u << 15 | REPRESENTATION(kTaggedPointer)) \
|
||||
V(Undetectable, 1u << 16 | REPRESENTATION(kTaggedPointer)) \
|
||||
V(OtherObject, 1u << 17 | REPRESENTATION(kTaggedPointer)) \
|
||||
V(Proxy, 1u << 18 | REPRESENTATION(kTaggedPointer)) \
|
||||
V(Internal, 1u << 19 | REPRESENTATION(kTagged | kUntagged)) \
|
||||
@ -231,7 +231,7 @@ namespace internal {
|
||||
V(NumberOrString, kNumber | kString) \
|
||||
V(NumberOrUndefined, kNumber | kUndefined) \
|
||||
V(PlainPrimitive, kNumberOrString | kBoolean | kNullOrUndefined) \
|
||||
V(Primitive, kSymbol | kPlainPrimitive) \
|
||||
V(Primitive, kSymbol | kSimd | kPlainPrimitive) \
|
||||
V(DetectableReceiver, kOtherObject | kProxy) \
|
||||
V(Detectable, kDetectableReceiver | kNumber | kName) \
|
||||
V(Object, kOtherObject | kUndetectable) \
|
||||
@ -277,6 +277,7 @@ namespace internal {
|
||||
// typedef Range;
|
||||
// typedef Region;
|
||||
// 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 handle(T* t); // !is_bitset(t)
|
||||
// template<class T> static Handle<T>::type cast(Handle<Type>::type);
|
||||
@ -423,6 +424,11 @@ class TypeImpl : public Config::Base {
|
||||
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 Intersect(TypeHandle type1, TypeHandle type2, Region* reg);
|
||||
static TypeImpl* Union(TypeImpl* type1, TypeImpl* type2) {
|
||||
|
@ -39,7 +39,7 @@ template<class Type, class TypeHandle, class Region>
|
||||
class Types {
|
||||
public:
|
||||
Types(Region* region, Isolate* isolate, v8::base::RandomNumberGenerator* rng)
|
||||
: region_(region), rng_(rng) {
|
||||
: region_(region), isolate_(isolate), rng_(rng) {
|
||||
#define DECLARE_TYPE(name, value) \
|
||||
name = Type::name(region); \
|
||||
types.push_back(name);
|
||||
@ -304,6 +304,21 @@ class Types {
|
||||
}
|
||||
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
|
||||
int n = rng_->NextInt(10);
|
||||
TypeHandle type = None;
|
||||
@ -321,6 +336,7 @@ class Types {
|
||||
|
||||
private:
|
||||
Region* region_;
|
||||
Isolate* isolate_;
|
||||
v8::base::RandomNumberGenerator* rng_;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user