Commit 201cd479 authored by jpp's avatar jpp Committed by Commit bot

V8. ASM-2-WASM. Changes the asm-types library.

The modifications were necessary to properly represent asm types:

1) fround is no longer an overloaded function.

2) the constructor for MinMaxTypes now takes a return type.

3) Adds pseudo-types for representing the Load/Store types for fp heap views.
BUG=

Review-Url: https://codereview.chromium.org/2069443002
Cr-Commit-Position: refs/heads/master@{#36980}
parent 2f6be682
...@@ -29,6 +29,7 @@ std::string AsmType::Name() { ...@@ -29,6 +29,7 @@ std::string AsmType::Name() {
UNREACHABLE(); UNREACHABLE();
} }
} }
return this->AsCallableType()->Name(); return this->AsCallableType()->Name();
} }
...@@ -42,6 +43,7 @@ bool AsmType::IsExactly(AsmType* that) { ...@@ -42,6 +43,7 @@ bool AsmType::IsExactly(AsmType* that) {
} }
return avt->Bitset() == tavt->Bitset(); return avt->Bitset() == tavt->Bitset();
} }
// TODO(jpp): is it useful to allow non-value types to be tested with // TODO(jpp): is it useful to allow non-value types to be tested with
// IsExactly? // IsExactly?
return that == this; return that == this;
...@@ -58,6 +60,7 @@ bool AsmType::IsA(AsmType* that) { ...@@ -58,6 +60,7 @@ bool AsmType::IsA(AsmType* that) {
} }
return (avt->Bitset() & tavt->Bitset()) == tavt->Bitset(); return (avt->Bitset() & tavt->Bitset()) == tavt->Bitset();
} }
// TODO(jpp): is it useful to allow non-value types to be tested with IsA? // TODO(jpp): is it useful to allow non-value types to be tested with IsA?
return that == this; return that == this;
} }
...@@ -130,6 +133,10 @@ AsmType* AsmType::StoreType() { ...@@ -130,6 +133,10 @@ AsmType* AsmType::StoreType() {
} }
std::string AsmFunctionType::Name() { std::string AsmFunctionType::Name() {
if (IsFroundType()) {
return "fround";
}
std::string ret; std::string ret;
ret += "("; ret += "(";
for (size_t ii = 0; ii < args_.size(); ++ii) { for (size_t ii = 0; ii < args_.size(); ++ii) {
...@@ -155,19 +162,33 @@ class AsmFroundType final : public AsmFunctionType { ...@@ -155,19 +162,33 @@ class AsmFroundType final : public AsmFunctionType {
private: private:
friend AsmType; friend AsmType;
AsmFroundType(Zone* zone, AsmType* src) explicit AsmFroundType(Zone* zone)
: AsmFunctionType(zone, AsmType::Float()) { : AsmFunctionType(zone, AsmType::Float()) {}
AddArgument(src);
} AsmType* ValidateCall(AsmType* function_type) override;
}; };
} // namespace } // namespace
AsmType* AsmType::FroundType(Zone* zone, AsmType* src) { AsmType* AsmType::FroundType(Zone* zone) {
DCHECK(src->AsValueType() != nullptr); auto* Fround = new (zone) AsmFroundType(zone);
auto* Fround = new (zone) AsmFroundType(zone, src);
return reinterpret_cast<AsmType*>(Fround); return reinterpret_cast<AsmType*>(Fround);
} }
AsmType* AsmFroundType::ValidateCall(AsmType* function_type) {
auto* callable = function_type->AsFunctionType();
if (callable->Arguments().size() != 1) {
return AsmType::None();
}
auto* arg = callable->Arguments()[0];
if (!arg->IsA(AsmType::Floatish()) && !arg->IsA(AsmType::DoubleQ()) &&
!arg->IsA(AsmType::Signed()) && !arg->IsA(AsmType::Unsigned())) {
return AsmType::None();
}
return AsmType::Float();
}
namespace { namespace {
class AsmMinMaxType final : public AsmFunctionType { class AsmMinMaxType final : public AsmFunctionType {
public: public:
...@@ -176,9 +197,10 @@ class AsmMinMaxType final : public AsmFunctionType { ...@@ -176,9 +197,10 @@ class AsmMinMaxType final : public AsmFunctionType {
private: private:
friend AsmType; friend AsmType;
AsmMinMaxType(Zone* zone, AsmType* type) : AsmFunctionType(zone, type) { AsmMinMaxType(Zone* zone, AsmType* dest, AsmType* src)
AddArgument(type); : AsmFunctionType(zone, dest) {
AddArgument(type); AddArgument(src);
AddArgument(src);
} }
AsmType* ValidateCall(AsmType* function_type) override { AsmType* ValidateCall(AsmType* function_type) override {
...@@ -206,9 +228,10 @@ class AsmMinMaxType final : public AsmFunctionType { ...@@ -206,9 +228,10 @@ class AsmMinMaxType final : public AsmFunctionType {
}; };
} // namespace } // namespace
AsmType* AsmType::MinMaxType(Zone* zone, AsmType* type) { AsmType* AsmType::MinMaxType(Zone* zone, AsmType* dest, AsmType* src) {
DCHECK(type->AsValueType() != nullptr); DCHECK(dest->AsValueType() != nullptr);
auto* MinMax = new (zone) AsmMinMaxType(zone, type); DCHECK(src->AsValueType() != nullptr);
auto* MinMax = new (zone) AsmMinMaxType(zone, dest, src);
return reinterpret_cast<AsmType*>(MinMax); return reinterpret_cast<AsmType*>(MinMax);
} }
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#define SRC_WASM_ASM_TYPES_H_ #define SRC_WASM_ASM_TYPES_H_
#include <string> #include <string>
#include <type_traits>
#include "src/base/macros.h" #include "src/base/macros.h"
#include "src/zone-containers.h" #include "src/zone-containers.h"
...@@ -47,8 +46,9 @@ class AsmOverloadedFunctionType; ...@@ -47,8 +46,9 @@ class AsmOverloadedFunctionType;
V(Int32Array, "Int32Array", 19, kAsmHeap) \ V(Int32Array, "Int32Array", 19, kAsmHeap) \
V(Float32Array, "Float32Array", 20, kAsmHeap) \ V(Float32Array, "Float32Array", 20, kAsmHeap) \
V(Float64Array, "Float64Array", 21, kAsmHeap) \ V(Float64Array, "Float64Array", 21, kAsmHeap) \
V(FloatishDoubleQ, "floatish|double?", 22, kAsmFloatish | kAsmDoubleQ) \ /* Pseudo-types used in representing heap access for fp types.*/ \
V(FloatQDoubleQ, "float?|double?", 23, kAsmFloatQ | kAsmDoubleQ) \ V(FloatishDoubleQ, "floatish|double?", 23, kAsmFloatish | kAsmDoubleQ) \
V(FloatQDoubleQ, "float?|double?", 24, kAsmFloatQ | kAsmDoubleQ) \
/* None is used to represent errors in the type checker. */ \ /* None is used to represent errors in the type checker. */ \
V(None, "<none>", 31, 0) V(None, "<none>", 31, 0)
...@@ -200,10 +200,10 @@ class AsmType { ...@@ -200,10 +200,10 @@ class AsmType {
} }
// The type for fround(src). // The type for fround(src).
static AsmType* FroundType(Zone* zone, AsmType* src); static AsmType* FroundType(Zone* zone);
// The (variadic) type for min and max. // The (variadic) type for min and max.
static AsmType* MinMaxType(Zone* zone, AsmType* type); static AsmType* MinMaxType(Zone* zone, AsmType* dest, AsmType* src);
std::string Name(); std::string Name();
// IsExactly returns true if this is the exact same type as that. For // IsExactly returns true if this is the exact same type as that. For
......
This diff is collapsed.
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