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() {
UNREACHABLE();
}
}
return this->AsCallableType()->Name();
}
......@@ -42,6 +43,7 @@ bool AsmType::IsExactly(AsmType* that) {
}
return avt->Bitset() == tavt->Bitset();
}
// TODO(jpp): is it useful to allow non-value types to be tested with
// IsExactly?
return that == this;
......@@ -58,6 +60,7 @@ bool AsmType::IsA(AsmType* that) {
}
return (avt->Bitset() & tavt->Bitset()) == tavt->Bitset();
}
// TODO(jpp): is it useful to allow non-value types to be tested with IsA?
return that == this;
}
......@@ -130,6 +133,10 @@ AsmType* AsmType::StoreType() {
}
std::string AsmFunctionType::Name() {
if (IsFroundType()) {
return "fround";
}
std::string ret;
ret += "(";
for (size_t ii = 0; ii < args_.size(); ++ii) {
......@@ -155,19 +162,33 @@ class AsmFroundType final : public AsmFunctionType {
private:
friend AsmType;
AsmFroundType(Zone* zone, AsmType* src)
: AsmFunctionType(zone, AsmType::Float()) {
AddArgument(src);
}
explicit AsmFroundType(Zone* zone)
: AsmFunctionType(zone, AsmType::Float()) {}
AsmType* ValidateCall(AsmType* function_type) override;
};
} // namespace
AsmType* AsmType::FroundType(Zone* zone, AsmType* src) {
DCHECK(src->AsValueType() != nullptr);
auto* Fround = new (zone) AsmFroundType(zone, src);
AsmType* AsmType::FroundType(Zone* zone) {
auto* Fround = new (zone) AsmFroundType(zone);
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 {
class AsmMinMaxType final : public AsmFunctionType {
public:
......@@ -176,9 +197,10 @@ class AsmMinMaxType final : public AsmFunctionType {
private:
friend AsmType;
AsmMinMaxType(Zone* zone, AsmType* type) : AsmFunctionType(zone, type) {
AddArgument(type);
AddArgument(type);
AsmMinMaxType(Zone* zone, AsmType* dest, AsmType* src)
: AsmFunctionType(zone, dest) {
AddArgument(src);
AddArgument(src);
}
AsmType* ValidateCall(AsmType* function_type) override {
......@@ -206,9 +228,10 @@ class AsmMinMaxType final : public AsmFunctionType {
};
} // namespace
AsmType* AsmType::MinMaxType(Zone* zone, AsmType* type) {
DCHECK(type->AsValueType() != nullptr);
auto* MinMax = new (zone) AsmMinMaxType(zone, type);
AsmType* AsmType::MinMaxType(Zone* zone, AsmType* dest, AsmType* src) {
DCHECK(dest->AsValueType() != nullptr);
DCHECK(src->AsValueType() != nullptr);
auto* MinMax = new (zone) AsmMinMaxType(zone, dest, src);
return reinterpret_cast<AsmType*>(MinMax);
}
......
......@@ -6,7 +6,6 @@
#define SRC_WASM_ASM_TYPES_H_
#include <string>
#include <type_traits>
#include "src/base/macros.h"
#include "src/zone-containers.h"
......@@ -47,8 +46,9 @@ class AsmOverloadedFunctionType;
V(Int32Array, "Int32Array", 19, kAsmHeap) \
V(Float32Array, "Float32Array", 20, kAsmHeap) \
V(Float64Array, "Float64Array", 21, kAsmHeap) \
V(FloatishDoubleQ, "floatish|double?", 22, kAsmFloatish | kAsmDoubleQ) \
V(FloatQDoubleQ, "float?|double?", 23, kAsmFloatQ | kAsmDoubleQ) \
/* Pseudo-types used in representing heap access for fp types.*/ \
V(FloatishDoubleQ, "floatish|double?", 23, kAsmFloatish | kAsmDoubleQ) \
V(FloatQDoubleQ, "float?|double?", 24, kAsmFloatQ | kAsmDoubleQ) \
/* None is used to represent errors in the type checker. */ \
V(None, "<none>", 31, 0)
......@@ -200,10 +200,10 @@ class AsmType {
}
// The type for fround(src).
static AsmType* FroundType(Zone* zone, AsmType* src);
static AsmType* FroundType(Zone* zone);
// 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();
// 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