Remove overly complex MachineNodeFactory.
R=titzer@chromium.org Review URL: https://codereview.chromium.org/543763002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23702 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
447f2839e7
commit
bb025c1ceb
1
BUILD.gn
1
BUILD.gn
@ -512,7 +512,6 @@ source_set("v8_base") {
|
||||
"src/compiler/linkage-impl.h",
|
||||
"src/compiler/linkage.cc",
|
||||
"src/compiler/linkage.h",
|
||||
"src/compiler/machine-node-factory.h",
|
||||
"src/compiler/machine-operator-reducer.cc",
|
||||
"src/compiler/machine-operator-reducer.h",
|
||||
"src/compiler/machine-operator.h",
|
||||
|
@ -1,374 +0,0 @@
|
||||
// Copyright 2014 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef V8_COMPILER_MACHINE_NODE_FACTORY_H_
|
||||
#define V8_COMPILER_MACHINE_NODE_FACTORY_H_
|
||||
|
||||
#ifdef USE_SIMULATOR
|
||||
#define MACHINE_ASSEMBLER_SUPPORTS_CALL_C 0
|
||||
#else
|
||||
#define MACHINE_ASSEMBLER_SUPPORTS_CALL_C 1
|
||||
#endif
|
||||
|
||||
#include "src/v8.h"
|
||||
|
||||
#include "src/compiler/machine-operator.h"
|
||||
#include "src/compiler/node.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
namespace compiler {
|
||||
|
||||
#define ZONE() static_cast<NodeFactory*>(this)->zone()
|
||||
#define COMMON() static_cast<NodeFactory*>(this)->common()
|
||||
#define MACHINE() static_cast<NodeFactory*>(this)->machine()
|
||||
#define MACHINE_SIG() static_cast<NodeFactory*>(this)->machine_sig()
|
||||
#define NEW_NODE_0(op) static_cast<NodeFactory*>(this)->NewNode(op)
|
||||
#define NEW_NODE_1(op, a) static_cast<NodeFactory*>(this)->NewNode(op, a)
|
||||
#define NEW_NODE_2(op, a, b) static_cast<NodeFactory*>(this)->NewNode(op, a, b)
|
||||
#define NEW_NODE_3(op, a, b, c) \
|
||||
static_cast<NodeFactory*>(this)->NewNode(op, a, b, c)
|
||||
|
||||
template <typename NodeFactory>
|
||||
class MachineNodeFactory {
|
||||
public:
|
||||
// Constants.
|
||||
Node* PointerConstant(void* value) {
|
||||
return IntPtrConstant(reinterpret_cast<intptr_t>(value));
|
||||
}
|
||||
Node* IntPtrConstant(intptr_t value) {
|
||||
// TODO(dcarney): mark generated code as unserializable if value != 0.
|
||||
return kPointerSize == 8 ? Int64Constant(value)
|
||||
: Int32Constant(static_cast<int>(value));
|
||||
}
|
||||
Node* Int32Constant(int32_t value) {
|
||||
return NEW_NODE_0(COMMON()->Int32Constant(value));
|
||||
}
|
||||
Node* Int64Constant(int64_t value) {
|
||||
return NEW_NODE_0(COMMON()->Int64Constant(value));
|
||||
}
|
||||
Node* NumberConstant(double value) {
|
||||
return NEW_NODE_0(COMMON()->NumberConstant(value));
|
||||
}
|
||||
Node* Float64Constant(double value) {
|
||||
return NEW_NODE_0(COMMON()->Float64Constant(value));
|
||||
}
|
||||
Node* HeapConstant(Handle<Object> object) {
|
||||
Unique<Object> val = Unique<Object>::CreateUninitialized(object);
|
||||
return NEW_NODE_0(COMMON()->HeapConstant(val));
|
||||
}
|
||||
|
||||
Node* Projection(int index, Node* a) {
|
||||
return NEW_NODE_1(COMMON()->Projection(index), a);
|
||||
}
|
||||
|
||||
// Memory Operations.
|
||||
Node* Load(MachineType rep, Node* base) {
|
||||
return Load(rep, base, Int32Constant(0));
|
||||
}
|
||||
Node* Load(MachineType rep, Node* base, Node* index) {
|
||||
return NEW_NODE_2(MACHINE()->Load(rep), base, index);
|
||||
}
|
||||
void Store(MachineType rep, Node* base, Node* value) {
|
||||
Store(rep, base, Int32Constant(0), value);
|
||||
}
|
||||
void Store(MachineType rep, Node* base, Node* index, Node* value) {
|
||||
NEW_NODE_3(MACHINE()->Store(rep, kNoWriteBarrier), base, index, value);
|
||||
}
|
||||
// Arithmetic Operations.
|
||||
Node* WordAnd(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->WordAnd(), a, b);
|
||||
}
|
||||
Node* WordOr(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->WordOr(), a, b);
|
||||
}
|
||||
Node* WordXor(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->WordXor(), a, b);
|
||||
}
|
||||
Node* WordShl(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->WordShl(), a, b);
|
||||
}
|
||||
Node* WordShr(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->WordShr(), a, b);
|
||||
}
|
||||
Node* WordSar(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->WordSar(), a, b);
|
||||
}
|
||||
Node* WordRor(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->WordRor(), a, b);
|
||||
}
|
||||
Node* WordEqual(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->WordEqual(), a, b);
|
||||
}
|
||||
Node* WordNotEqual(Node* a, Node* b) {
|
||||
return WordBinaryNot(WordEqual(a, b));
|
||||
}
|
||||
Node* WordNot(Node* a) {
|
||||
if (MACHINE()->is32()) {
|
||||
return Word32Not(a);
|
||||
} else {
|
||||
return Word64Not(a);
|
||||
}
|
||||
}
|
||||
Node* WordBinaryNot(Node* a) {
|
||||
if (MACHINE()->is32()) {
|
||||
return Word32BinaryNot(a);
|
||||
} else {
|
||||
return Word64BinaryNot(a);
|
||||
}
|
||||
}
|
||||
|
||||
Node* Word32And(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Word32And(), a, b);
|
||||
}
|
||||
Node* Word32Or(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Word32Or(), a, b);
|
||||
}
|
||||
Node* Word32Xor(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Word32Xor(), a, b);
|
||||
}
|
||||
Node* Word32Shl(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Word32Shl(), a, b);
|
||||
}
|
||||
Node* Word32Shr(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Word32Shr(), a, b);
|
||||
}
|
||||
Node* Word32Sar(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Word32Sar(), a, b);
|
||||
}
|
||||
Node* Word32Ror(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Word32Ror(), a, b);
|
||||
}
|
||||
Node* Word32Equal(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Word32Equal(), a, b);
|
||||
}
|
||||
Node* Word32NotEqual(Node* a, Node* b) {
|
||||
return Word32BinaryNot(Word32Equal(a, b));
|
||||
}
|
||||
Node* Word32Not(Node* a) { return Word32Xor(a, Int32Constant(-1)); }
|
||||
Node* Word32BinaryNot(Node* a) { return Word32Equal(a, Int32Constant(0)); }
|
||||
|
||||
Node* Word64And(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Word64And(), a, b);
|
||||
}
|
||||
Node* Word64Or(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Word64Or(), a, b);
|
||||
}
|
||||
Node* Word64Xor(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Word64Xor(), a, b);
|
||||
}
|
||||
Node* Word64Shl(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Word64Shl(), a, b);
|
||||
}
|
||||
Node* Word64Shr(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Word64Shr(), a, b);
|
||||
}
|
||||
Node* Word64Sar(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Word64Sar(), a, b);
|
||||
}
|
||||
Node* Word64Ror(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Word64Ror(), a, b);
|
||||
}
|
||||
Node* Word64Equal(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Word64Equal(), a, b);
|
||||
}
|
||||
Node* Word64NotEqual(Node* a, Node* b) {
|
||||
return Word64BinaryNot(Word64Equal(a, b));
|
||||
}
|
||||
Node* Word64Not(Node* a) { return Word64Xor(a, Int64Constant(-1)); }
|
||||
Node* Word64BinaryNot(Node* a) { return Word64Equal(a, Int64Constant(0)); }
|
||||
|
||||
Node* Int32Add(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Int32Add(), a, b);
|
||||
}
|
||||
Node* Int32AddWithOverflow(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Int32AddWithOverflow(), a, b);
|
||||
}
|
||||
Node* Int32Sub(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Int32Sub(), a, b);
|
||||
}
|
||||
Node* Int32SubWithOverflow(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Int32SubWithOverflow(), a, b);
|
||||
}
|
||||
Node* Int32Mul(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Int32Mul(), a, b);
|
||||
}
|
||||
Node* Int32Div(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Int32Div(), a, b);
|
||||
}
|
||||
Node* Int32UDiv(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Int32UDiv(), a, b);
|
||||
}
|
||||
Node* Int32Mod(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Int32Mod(), a, b);
|
||||
}
|
||||
Node* Int32UMod(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Int32UMod(), a, b);
|
||||
}
|
||||
Node* Int32LessThan(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Int32LessThan(), a, b);
|
||||
}
|
||||
Node* Int32LessThanOrEqual(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Int32LessThanOrEqual(), a, b);
|
||||
}
|
||||
Node* Uint32LessThan(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Uint32LessThan(), a, b);
|
||||
}
|
||||
Node* Uint32LessThanOrEqual(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Uint32LessThanOrEqual(), a, b);
|
||||
}
|
||||
Node* Int32GreaterThan(Node* a, Node* b) { return Int32LessThan(b, a); }
|
||||
Node* Int32GreaterThanOrEqual(Node* a, Node* b) {
|
||||
return Int32LessThanOrEqual(b, a);
|
||||
}
|
||||
Node* Int32Neg(Node* a) { return Int32Sub(Int32Constant(0), a); }
|
||||
|
||||
Node* Int64Add(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Int64Add(), a, b);
|
||||
}
|
||||
Node* Int64Sub(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Int64Sub(), a, b);
|
||||
}
|
||||
Node* Int64Mul(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Int64Mul(), a, b);
|
||||
}
|
||||
Node* Int64Div(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Int64Div(), a, b);
|
||||
}
|
||||
Node* Int64UDiv(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Int64UDiv(), a, b);
|
||||
}
|
||||
Node* Int64Mod(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Int64Mod(), a, b);
|
||||
}
|
||||
Node* Int64UMod(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Int64UMod(), a, b);
|
||||
}
|
||||
Node* Int64Neg(Node* a) { return Int64Sub(Int64Constant(0), a); }
|
||||
Node* Int64LessThan(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Int64LessThan(), a, b);
|
||||
}
|
||||
Node* Int64LessThanOrEqual(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Int64LessThanOrEqual(), a, b);
|
||||
}
|
||||
Node* Int64GreaterThan(Node* a, Node* b) { return Int64LessThan(b, a); }
|
||||
Node* Int64GreaterThanOrEqual(Node* a, Node* b) {
|
||||
return Int64LessThanOrEqual(b, a);
|
||||
}
|
||||
|
||||
// TODO(turbofan): What is this used for?
|
||||
Node* ConvertIntPtrToInt32(Node* a) {
|
||||
return kPointerSize == 8 ? NEW_NODE_1(MACHINE()->TruncateInt64ToInt32(), a)
|
||||
: a;
|
||||
}
|
||||
Node* ConvertInt32ToIntPtr(Node* a) {
|
||||
return kPointerSize == 8 ? NEW_NODE_1(MACHINE()->ChangeInt32ToInt64(), a)
|
||||
: a;
|
||||
}
|
||||
|
||||
#define INTPTR_BINOP(prefix, name) \
|
||||
Node* IntPtr##name(Node* a, Node* b) { \
|
||||
return kPointerSize == 8 ? prefix##64##name(a, b) \
|
||||
: prefix##32##name(a, b); \
|
||||
}
|
||||
|
||||
INTPTR_BINOP(Int, Add);
|
||||
INTPTR_BINOP(Int, Sub);
|
||||
INTPTR_BINOP(Int, LessThan);
|
||||
INTPTR_BINOP(Int, LessThanOrEqual);
|
||||
INTPTR_BINOP(Word, Equal);
|
||||
INTPTR_BINOP(Word, NotEqual);
|
||||
INTPTR_BINOP(Int, GreaterThanOrEqual);
|
||||
INTPTR_BINOP(Int, GreaterThan);
|
||||
|
||||
#undef INTPTR_BINOP
|
||||
|
||||
Node* Float64Add(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Float64Add(), a, b);
|
||||
}
|
||||
Node* Float64Sub(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Float64Sub(), a, b);
|
||||
}
|
||||
Node* Float64Mul(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Float64Mul(), a, b);
|
||||
}
|
||||
Node* Float64Div(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Float64Div(), a, b);
|
||||
}
|
||||
Node* Float64Mod(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Float64Mod(), a, b);
|
||||
}
|
||||
Node* Float64Equal(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Float64Equal(), a, b);
|
||||
}
|
||||
Node* Float64NotEqual(Node* a, Node* b) {
|
||||
return WordBinaryNot(Float64Equal(a, b));
|
||||
}
|
||||
Node* Float64LessThan(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Float64LessThan(), a, b);
|
||||
}
|
||||
Node* Float64LessThanOrEqual(Node* a, Node* b) {
|
||||
return NEW_NODE_2(MACHINE()->Float64LessThanOrEqual(), a, b);
|
||||
}
|
||||
Node* Float64GreaterThan(Node* a, Node* b) { return Float64LessThan(b, a); }
|
||||
Node* Float64GreaterThanOrEqual(Node* a, Node* b) {
|
||||
return Float64LessThanOrEqual(b, a);
|
||||
}
|
||||
|
||||
// Conversions.
|
||||
Node* ChangeInt32ToFloat64(Node* a) {
|
||||
return NEW_NODE_1(MACHINE()->ChangeInt32ToFloat64(), a);
|
||||
}
|
||||
Node* ChangeUint32ToFloat64(Node* a) {
|
||||
return NEW_NODE_1(MACHINE()->ChangeUint32ToFloat64(), a);
|
||||
}
|
||||
Node* ChangeFloat64ToInt32(Node* a) {
|
||||
return NEW_NODE_1(MACHINE()->ChangeFloat64ToInt32(), a);
|
||||
}
|
||||
Node* ChangeFloat64ToUint32(Node* a) {
|
||||
return NEW_NODE_1(MACHINE()->ChangeFloat64ToUint32(), a);
|
||||
}
|
||||
Node* ChangeInt32ToInt64(Node* a) {
|
||||
return NEW_NODE_1(MACHINE()->ChangeInt32ToInt64(), a);
|
||||
}
|
||||
Node* ChangeUint32ToUint64(Node* a) {
|
||||
return NEW_NODE_1(MACHINE()->ChangeUint32ToUint64(), a);
|
||||
}
|
||||
Node* TruncateFloat64ToInt32(Node* a) {
|
||||
return NEW_NODE_1(MACHINE()->TruncateFloat64ToInt32(), a);
|
||||
}
|
||||
Node* TruncateInt64ToInt32(Node* a) {
|
||||
return NEW_NODE_1(MACHINE()->TruncateInt64ToInt32(), a);
|
||||
}
|
||||
|
||||
#ifdef MACHINE_ASSEMBLER_SUPPORTS_CALL_C
|
||||
// Call to C.
|
||||
Node* CallC(Node* function_address, MachineType return_type,
|
||||
MachineType* arg_types, Node** args, int n_args) {
|
||||
Zone* zone = ZONE();
|
||||
CallDescriptor* descriptor =
|
||||
Linkage::GetSimplifiedCDescriptor(ZONE(), MACHINE_SIG());
|
||||
Node** passed_args = zone->NewArray<Node*>(n_args + 1);
|
||||
passed_args[0] = function_address;
|
||||
for (int i = 0; i < n_args; ++i) {
|
||||
passed_args[i + 1] = args[i];
|
||||
}
|
||||
return NEW_NODE_2(COMMON()->Call(descriptor), n_args + 1, passed_args);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
#undef NEW_NODE_0
|
||||
#undef NEW_NODE_1
|
||||
#undef NEW_NODE_2
|
||||
#undef NEW_NODE_3
|
||||
#undef MACHINE
|
||||
#undef COMMON
|
||||
#undef ZONE
|
||||
|
||||
} // namespace compiler
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
#endif // V8_COMPILER_MACHINE_NODE_FACTORY_H_
|
@ -5,11 +5,16 @@
|
||||
#ifndef V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_
|
||||
#define V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_
|
||||
|
||||
#ifdef USE_SIMULATOR
|
||||
#define MACHINE_ASSEMBLER_SUPPORTS_CALL_C 0
|
||||
#else
|
||||
#define MACHINE_ASSEMBLER_SUPPORTS_CALL_C 1
|
||||
#endif
|
||||
|
||||
#include "src/v8.h"
|
||||
|
||||
#include "src/compiler/common-operator.h"
|
||||
#include "src/compiler/graph-builder.h"
|
||||
#include "src/compiler/machine-node-factory.h"
|
||||
#include "src/compiler/machine-operator.h"
|
||||
#include "src/compiler/node.h"
|
||||
#include "src/compiler/operator.h"
|
||||
@ -23,8 +28,7 @@ class BasicBlock;
|
||||
class Schedule;
|
||||
|
||||
|
||||
class RawMachineAssembler : public GraphBuilder,
|
||||
public MachineNodeFactory<RawMachineAssembler> {
|
||||
class RawMachineAssembler : public GraphBuilder {
|
||||
public:
|
||||
class Label {
|
||||
public:
|
||||
@ -63,6 +67,327 @@ class RawMachineAssembler : public GraphBuilder,
|
||||
return NewNode(common()->HeapConstant(unique));
|
||||
}
|
||||
|
||||
// Constants.
|
||||
Node* PointerConstant(void* value) {
|
||||
return IntPtrConstant(reinterpret_cast<intptr_t>(value));
|
||||
}
|
||||
Node* IntPtrConstant(intptr_t value) {
|
||||
// TODO(dcarney): mark generated code as unserializable if value != 0.
|
||||
return kPointerSize == 8 ? Int64Constant(value)
|
||||
: Int32Constant(static_cast<int>(value));
|
||||
}
|
||||
Node* Int32Constant(int32_t value) {
|
||||
return NewNode(common()->Int32Constant(value));
|
||||
}
|
||||
Node* Int64Constant(int64_t value) {
|
||||
return NewNode(common()->Int64Constant(value));
|
||||
}
|
||||
Node* NumberConstant(double value) {
|
||||
return NewNode(common()->NumberConstant(value));
|
||||
}
|
||||
Node* Float64Constant(double value) {
|
||||
return NewNode(common()->Float64Constant(value));
|
||||
}
|
||||
Node* HeapConstant(Handle<Object> object) {
|
||||
Unique<Object> val = Unique<Object>::CreateUninitialized(object);
|
||||
return NewNode(common()->HeapConstant(val));
|
||||
}
|
||||
|
||||
Node* Projection(int index, Node* a) {
|
||||
return NewNode(common()->Projection(index), a);
|
||||
}
|
||||
|
||||
// Memory Operations.
|
||||
Node* Load(MachineType rep, Node* base) {
|
||||
return Load(rep, base, Int32Constant(0));
|
||||
}
|
||||
Node* Load(MachineType rep, Node* base, Node* index) {
|
||||
return NewNode(machine()->Load(rep), base, index);
|
||||
}
|
||||
void Store(MachineType rep, Node* base, Node* value) {
|
||||
Store(rep, base, Int32Constant(0), value);
|
||||
}
|
||||
void Store(MachineType rep, Node* base, Node* index, Node* value) {
|
||||
NewNode(machine()->Store(rep, kNoWriteBarrier), base, index, value);
|
||||
}
|
||||
// Arithmetic Operations.
|
||||
Node* WordAnd(Node* a, Node* b) {
|
||||
return NewNode(machine()->WordAnd(), a, b);
|
||||
}
|
||||
Node* WordOr(Node* a, Node* b) { return NewNode(machine()->WordOr(), a, b); }
|
||||
Node* WordXor(Node* a, Node* b) {
|
||||
return NewNode(machine()->WordXor(), a, b);
|
||||
}
|
||||
Node* WordShl(Node* a, Node* b) {
|
||||
return NewNode(machine()->WordShl(), a, b);
|
||||
}
|
||||
Node* WordShr(Node* a, Node* b) {
|
||||
return NewNode(machine()->WordShr(), a, b);
|
||||
}
|
||||
Node* WordSar(Node* a, Node* b) {
|
||||
return NewNode(machine()->WordSar(), a, b);
|
||||
}
|
||||
Node* WordRor(Node* a, Node* b) {
|
||||
return NewNode(machine()->WordRor(), a, b);
|
||||
}
|
||||
Node* WordEqual(Node* a, Node* b) {
|
||||
return NewNode(machine()->WordEqual(), a, b);
|
||||
}
|
||||
Node* WordNotEqual(Node* a, Node* b) {
|
||||
return WordBinaryNot(WordEqual(a, b));
|
||||
}
|
||||
Node* WordNot(Node* a) {
|
||||
if (machine()->is32()) {
|
||||
return Word32Not(a);
|
||||
} else {
|
||||
return Word64Not(a);
|
||||
}
|
||||
}
|
||||
Node* WordBinaryNot(Node* a) {
|
||||
if (machine()->is32()) {
|
||||
return Word32BinaryNot(a);
|
||||
} else {
|
||||
return Word64BinaryNot(a);
|
||||
}
|
||||
}
|
||||
|
||||
Node* Word32And(Node* a, Node* b) {
|
||||
return NewNode(machine()->Word32And(), a, b);
|
||||
}
|
||||
Node* Word32Or(Node* a, Node* b) {
|
||||
return NewNode(machine()->Word32Or(), a, b);
|
||||
}
|
||||
Node* Word32Xor(Node* a, Node* b) {
|
||||
return NewNode(machine()->Word32Xor(), a, b);
|
||||
}
|
||||
Node* Word32Shl(Node* a, Node* b) {
|
||||
return NewNode(machine()->Word32Shl(), a, b);
|
||||
}
|
||||
Node* Word32Shr(Node* a, Node* b) {
|
||||
return NewNode(machine()->Word32Shr(), a, b);
|
||||
}
|
||||
Node* Word32Sar(Node* a, Node* b) {
|
||||
return NewNode(machine()->Word32Sar(), a, b);
|
||||
}
|
||||
Node* Word32Ror(Node* a, Node* b) {
|
||||
return NewNode(machine()->Word32Ror(), a, b);
|
||||
}
|
||||
Node* Word32Equal(Node* a, Node* b) {
|
||||
return NewNode(machine()->Word32Equal(), a, b);
|
||||
}
|
||||
Node* Word32NotEqual(Node* a, Node* b) {
|
||||
return Word32BinaryNot(Word32Equal(a, b));
|
||||
}
|
||||
Node* Word32Not(Node* a) { return Word32Xor(a, Int32Constant(-1)); }
|
||||
Node* Word32BinaryNot(Node* a) { return Word32Equal(a, Int32Constant(0)); }
|
||||
|
||||
Node* Word64And(Node* a, Node* b) {
|
||||
return NewNode(machine()->Word64And(), a, b);
|
||||
}
|
||||
Node* Word64Or(Node* a, Node* b) {
|
||||
return NewNode(machine()->Word64Or(), a, b);
|
||||
}
|
||||
Node* Word64Xor(Node* a, Node* b) {
|
||||
return NewNode(machine()->Word64Xor(), a, b);
|
||||
}
|
||||
Node* Word64Shl(Node* a, Node* b) {
|
||||
return NewNode(machine()->Word64Shl(), a, b);
|
||||
}
|
||||
Node* Word64Shr(Node* a, Node* b) {
|
||||
return NewNode(machine()->Word64Shr(), a, b);
|
||||
}
|
||||
Node* Word64Sar(Node* a, Node* b) {
|
||||
return NewNode(machine()->Word64Sar(), a, b);
|
||||
}
|
||||
Node* Word64Ror(Node* a, Node* b) {
|
||||
return NewNode(machine()->Word64Ror(), a, b);
|
||||
}
|
||||
Node* Word64Equal(Node* a, Node* b) {
|
||||
return NewNode(machine()->Word64Equal(), a, b);
|
||||
}
|
||||
Node* Word64NotEqual(Node* a, Node* b) {
|
||||
return Word64BinaryNot(Word64Equal(a, b));
|
||||
}
|
||||
Node* Word64Not(Node* a) { return Word64Xor(a, Int64Constant(-1)); }
|
||||
Node* Word64BinaryNot(Node* a) { return Word64Equal(a, Int64Constant(0)); }
|
||||
|
||||
Node* Int32Add(Node* a, Node* b) {
|
||||
return NewNode(machine()->Int32Add(), a, b);
|
||||
}
|
||||
Node* Int32AddWithOverflow(Node* a, Node* b) {
|
||||
return NewNode(machine()->Int32AddWithOverflow(), a, b);
|
||||
}
|
||||
Node* Int32Sub(Node* a, Node* b) {
|
||||
return NewNode(machine()->Int32Sub(), a, b);
|
||||
}
|
||||
Node* Int32SubWithOverflow(Node* a, Node* b) {
|
||||
return NewNode(machine()->Int32SubWithOverflow(), a, b);
|
||||
}
|
||||
Node* Int32Mul(Node* a, Node* b) {
|
||||
return NewNode(machine()->Int32Mul(), a, b);
|
||||
}
|
||||
Node* Int32Div(Node* a, Node* b) {
|
||||
return NewNode(machine()->Int32Div(), a, b);
|
||||
}
|
||||
Node* Int32UDiv(Node* a, Node* b) {
|
||||
return NewNode(machine()->Int32UDiv(), a, b);
|
||||
}
|
||||
Node* Int32Mod(Node* a, Node* b) {
|
||||
return NewNode(machine()->Int32Mod(), a, b);
|
||||
}
|
||||
Node* Int32UMod(Node* a, Node* b) {
|
||||
return NewNode(machine()->Int32UMod(), a, b);
|
||||
}
|
||||
Node* Int32LessThan(Node* a, Node* b) {
|
||||
return NewNode(machine()->Int32LessThan(), a, b);
|
||||
}
|
||||
Node* Int32LessThanOrEqual(Node* a, Node* b) {
|
||||
return NewNode(machine()->Int32LessThanOrEqual(), a, b);
|
||||
}
|
||||
Node* Uint32LessThan(Node* a, Node* b) {
|
||||
return NewNode(machine()->Uint32LessThan(), a, b);
|
||||
}
|
||||
Node* Uint32LessThanOrEqual(Node* a, Node* b) {
|
||||
return NewNode(machine()->Uint32LessThanOrEqual(), a, b);
|
||||
}
|
||||
Node* Int32GreaterThan(Node* a, Node* b) { return Int32LessThan(b, a); }
|
||||
Node* Int32GreaterThanOrEqual(Node* a, Node* b) {
|
||||
return Int32LessThanOrEqual(b, a);
|
||||
}
|
||||
Node* Int32Neg(Node* a) { return Int32Sub(Int32Constant(0), a); }
|
||||
|
||||
Node* Int64Add(Node* a, Node* b) {
|
||||
return NewNode(machine()->Int64Add(), a, b);
|
||||
}
|
||||
Node* Int64Sub(Node* a, Node* b) {
|
||||
return NewNode(machine()->Int64Sub(), a, b);
|
||||
}
|
||||
Node* Int64Mul(Node* a, Node* b) {
|
||||
return NewNode(machine()->Int64Mul(), a, b);
|
||||
}
|
||||
Node* Int64Div(Node* a, Node* b) {
|
||||
return NewNode(machine()->Int64Div(), a, b);
|
||||
}
|
||||
Node* Int64UDiv(Node* a, Node* b) {
|
||||
return NewNode(machine()->Int64UDiv(), a, b);
|
||||
}
|
||||
Node* Int64Mod(Node* a, Node* b) {
|
||||
return NewNode(machine()->Int64Mod(), a, b);
|
||||
}
|
||||
Node* Int64UMod(Node* a, Node* b) {
|
||||
return NewNode(machine()->Int64UMod(), a, b);
|
||||
}
|
||||
Node* Int64Neg(Node* a) { return Int64Sub(Int64Constant(0), a); }
|
||||
Node* Int64LessThan(Node* a, Node* b) {
|
||||
return NewNode(machine()->Int64LessThan(), a, b);
|
||||
}
|
||||
Node* Int64LessThanOrEqual(Node* a, Node* b) {
|
||||
return NewNode(machine()->Int64LessThanOrEqual(), a, b);
|
||||
}
|
||||
Node* Int64GreaterThan(Node* a, Node* b) { return Int64LessThan(b, a); }
|
||||
Node* Int64GreaterThanOrEqual(Node* a, Node* b) {
|
||||
return Int64LessThanOrEqual(b, a);
|
||||
}
|
||||
|
||||
// TODO(turbofan): What is this used for?
|
||||
Node* ConvertIntPtrToInt32(Node* a) {
|
||||
return kPointerSize == 8 ? NewNode(machine()->TruncateInt64ToInt32(), a)
|
||||
: a;
|
||||
}
|
||||
Node* ConvertInt32ToIntPtr(Node* a) {
|
||||
return kPointerSize == 8 ? NewNode(machine()->ChangeInt32ToInt64(), a) : a;
|
||||
}
|
||||
|
||||
#define INTPTR_BINOP(prefix, name) \
|
||||
Node* IntPtr##name(Node* a, Node* b) { \
|
||||
return kPointerSize == 8 ? prefix##64##name(a, b) \
|
||||
: prefix##32##name(a, b); \
|
||||
}
|
||||
|
||||
INTPTR_BINOP(Int, Add);
|
||||
INTPTR_BINOP(Int, Sub);
|
||||
INTPTR_BINOP(Int, LessThan);
|
||||
INTPTR_BINOP(Int, LessThanOrEqual);
|
||||
INTPTR_BINOP(Word, Equal);
|
||||
INTPTR_BINOP(Word, NotEqual);
|
||||
INTPTR_BINOP(Int, GreaterThanOrEqual);
|
||||
INTPTR_BINOP(Int, GreaterThan);
|
||||
|
||||
#undef INTPTR_BINOP
|
||||
|
||||
Node* Float64Add(Node* a, Node* b) {
|
||||
return NewNode(machine()->Float64Add(), a, b);
|
||||
}
|
||||
Node* Float64Sub(Node* a, Node* b) {
|
||||
return NewNode(machine()->Float64Sub(), a, b);
|
||||
}
|
||||
Node* Float64Mul(Node* a, Node* b) {
|
||||
return NewNode(machine()->Float64Mul(), a, b);
|
||||
}
|
||||
Node* Float64Div(Node* a, Node* b) {
|
||||
return NewNode(machine()->Float64Div(), a, b);
|
||||
}
|
||||
Node* Float64Mod(Node* a, Node* b) {
|
||||
return NewNode(machine()->Float64Mod(), a, b);
|
||||
}
|
||||
Node* Float64Equal(Node* a, Node* b) {
|
||||
return NewNode(machine()->Float64Equal(), a, b);
|
||||
}
|
||||
Node* Float64NotEqual(Node* a, Node* b) {
|
||||
return WordBinaryNot(Float64Equal(a, b));
|
||||
}
|
||||
Node* Float64LessThan(Node* a, Node* b) {
|
||||
return NewNode(machine()->Float64LessThan(), a, b);
|
||||
}
|
||||
Node* Float64LessThanOrEqual(Node* a, Node* b) {
|
||||
return NewNode(machine()->Float64LessThanOrEqual(), a, b);
|
||||
}
|
||||
Node* Float64GreaterThan(Node* a, Node* b) { return Float64LessThan(b, a); }
|
||||
Node* Float64GreaterThanOrEqual(Node* a, Node* b) {
|
||||
return Float64LessThanOrEqual(b, a);
|
||||
}
|
||||
|
||||
// Conversions.
|
||||
Node* ChangeInt32ToFloat64(Node* a) {
|
||||
return NewNode(machine()->ChangeInt32ToFloat64(), a);
|
||||
}
|
||||
Node* ChangeUint32ToFloat64(Node* a) {
|
||||
return NewNode(machine()->ChangeUint32ToFloat64(), a);
|
||||
}
|
||||
Node* ChangeFloat64ToInt32(Node* a) {
|
||||
return NewNode(machine()->ChangeFloat64ToInt32(), a);
|
||||
}
|
||||
Node* ChangeFloat64ToUint32(Node* a) {
|
||||
return NewNode(machine()->ChangeFloat64ToUint32(), a);
|
||||
}
|
||||
Node* ChangeInt32ToInt64(Node* a) {
|
||||
return NewNode(machine()->ChangeInt32ToInt64(), a);
|
||||
}
|
||||
Node* ChangeUint32ToUint64(Node* a) {
|
||||
return NewNode(machine()->ChangeUint32ToUint64(), a);
|
||||
}
|
||||
Node* TruncateFloat64ToInt32(Node* a) {
|
||||
return NewNode(machine()->TruncateFloat64ToInt32(), a);
|
||||
}
|
||||
Node* TruncateInt64ToInt32(Node* a) {
|
||||
return NewNode(machine()->TruncateInt64ToInt32(), a);
|
||||
}
|
||||
|
||||
#ifdef MACHINE_ASSEMBLER_SUPPORTS_CALL_C
|
||||
// Call to C.
|
||||
Node* CallC(Node* function_address, MachineType return_type,
|
||||
MachineType* arg_types, Node** args, int n_args) {
|
||||
CallDescriptor* descriptor =
|
||||
Linkage::GetSimplifiedCDescriptor(zone(), machine_sig());
|
||||
Node** passed_args = zone()->NewArray<Node*>(n_args + 1);
|
||||
passed_args[0] = function_address;
|
||||
for (int i = 0; i < n_args; ++i) {
|
||||
passed_args[i + 1] = args[i];
|
||||
}
|
||||
return NewNode(common()->Call(descriptor), n_args + 1, passed_args);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Parameters.
|
||||
Node* Parameter(size_t index);
|
||||
|
||||
@ -98,14 +423,14 @@ class RawMachineAssembler : public GraphBuilder,
|
||||
protected:
|
||||
virtual Node* MakeNode(Operator* op, int input_count, Node** inputs);
|
||||
|
||||
bool ScheduleValid() { return schedule_ != NULL; }
|
||||
|
||||
Schedule* schedule() {
|
||||
DCHECK(ScheduleValid());
|
||||
return schedule_;
|
||||
}
|
||||
|
||||
private:
|
||||
bool ScheduleValid() { return schedule_ != NULL; }
|
||||
|
||||
BasicBlock* Use(Label* label);
|
||||
BasicBlock* EnsureBlock(Label* label);
|
||||
BasicBlock* CurrentBlock();
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include "src/compiler/common-operator.h"
|
||||
#include "src/compiler/graph-builder.h"
|
||||
#include "src/compiler/machine-node-factory.h"
|
||||
#include "src/compiler/machine-operator.h"
|
||||
#include "src/compiler/simplified-operator.h"
|
||||
#include "test/cctest/compiler/call-tester.h"
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include "src/compiler/common-operator.h"
|
||||
#include "src/compiler/graph-builder.h"
|
||||
#include "src/compiler/machine-node-factory.h"
|
||||
#include "src/compiler/machine-operator.h"
|
||||
#include "src/compiler/simplified-operator.h"
|
||||
#include "test/cctest/cctest.h"
|
||||
@ -17,9 +16,7 @@ namespace v8 {
|
||||
namespace internal {
|
||||
namespace compiler {
|
||||
|
||||
class SimplifiedGraphBuilder
|
||||
: public GraphBuilder,
|
||||
public MachineNodeFactory<SimplifiedGraphBuilder> {
|
||||
class SimplifiedGraphBuilder : public GraphBuilder {
|
||||
public:
|
||||
SimplifiedGraphBuilder(Graph* graph, CommonOperatorBuilder* common,
|
||||
MachineOperatorBuilder* machine,
|
||||
@ -40,6 +37,19 @@ class SimplifiedGraphBuilder
|
||||
// Close the graph.
|
||||
void End();
|
||||
|
||||
Node* PointerConstant(void* value) {
|
||||
intptr_t intptr_value = reinterpret_cast<intptr_t>(value);
|
||||
return kPointerSize == 8 ? NewNode(common()->Int64Constant(intptr_value))
|
||||
: Int32Constant(static_cast<int>(intptr_value));
|
||||
}
|
||||
Node* Int32Constant(int32_t value) {
|
||||
return NewNode(common()->Int32Constant(value));
|
||||
}
|
||||
Node* HeapConstant(Handle<Object> object) {
|
||||
Unique<Object> val = Unique<Object>::CreateUninitialized(object);
|
||||
return NewNode(common()->HeapConstant(val));
|
||||
}
|
||||
|
||||
Node* BooleanNot(Node* a) { return NewNode(simplified()->BooleanNot(), a); }
|
||||
|
||||
Node* NumberEqual(Node* a, Node* b) {
|
||||
|
@ -18,44 +18,10 @@ void Variable::Set(Node* value) const { smasm_->SetVariable(offset_, value); }
|
||||
|
||||
StructuredMachineAssembler::StructuredMachineAssembler(
|
||||
Graph* graph, MachineSignature* machine_sig, MachineType word)
|
||||
: GraphBuilder(graph),
|
||||
schedule_(new (zone()) Schedule(zone())),
|
||||
machine_(zone(), word),
|
||||
common_(zone()),
|
||||
machine_sig_(machine_sig),
|
||||
call_descriptor_(
|
||||
Linkage::GetSimplifiedCDescriptor(graph->zone(), machine_sig)),
|
||||
parameters_(NULL),
|
||||
: RawMachineAssembler(graph, machine_sig, word),
|
||||
current_environment_(new (zone())
|
||||
Environment(zone(), schedule()->start(), false)),
|
||||
number_of_variables_(0) {
|
||||
int param_count = static_cast<int>(parameter_count());
|
||||
Node* s = graph->NewNode(common_.Start(param_count));
|
||||
graph->SetStart(s);
|
||||
if (parameter_count() == 0) return;
|
||||
parameters_ = zone()->NewArray<Node*>(param_count);
|
||||
for (size_t i = 0; i < parameter_count(); ++i) {
|
||||
parameters_[i] =
|
||||
NewNode(common()->Parameter(static_cast<int>(i)), graph->start());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Schedule* StructuredMachineAssembler::Export() {
|
||||
// Compute the correct codegen order.
|
||||
DCHECK(schedule_->rpo_order()->empty());
|
||||
Scheduler::ComputeSpecialRPO(schedule_);
|
||||
// Invalidate MachineAssembler.
|
||||
Schedule* schedule = schedule_;
|
||||
schedule_ = NULL;
|
||||
return schedule;
|
||||
}
|
||||
|
||||
|
||||
Node* StructuredMachineAssembler::Parameter(size_t index) {
|
||||
DCHECK(index < parameter_count());
|
||||
return parameters_[index];
|
||||
}
|
||||
number_of_variables_(0) {}
|
||||
|
||||
|
||||
Node* StructuredMachineAssembler::MakeNode(Operator* op, int input_count,
|
||||
|
@ -9,10 +9,10 @@
|
||||
|
||||
#include "src/compiler/common-operator.h"
|
||||
#include "src/compiler/graph-builder.h"
|
||||
#include "src/compiler/machine-node-factory.h"
|
||||
#include "src/compiler/machine-operator.h"
|
||||
#include "src/compiler/node.h"
|
||||
#include "src/compiler/operator.h"
|
||||
#include "src/compiler/raw-machine-assembler.h"
|
||||
|
||||
|
||||
namespace v8 {
|
||||
@ -40,9 +40,7 @@ class Variable : public ZoneObject {
|
||||
};
|
||||
|
||||
|
||||
class StructuredMachineAssembler
|
||||
: public GraphBuilder,
|
||||
public MachineNodeFactory<StructuredMachineAssembler> {
|
||||
class StructuredMachineAssembler : public RawMachineAssembler {
|
||||
public:
|
||||
class Environment : public ZoneObject {
|
||||
public:
|
||||
@ -65,35 +63,15 @@ class StructuredMachineAssembler
|
||||
MachineType word = kMachPtr);
|
||||
virtual ~StructuredMachineAssembler() {}
|
||||
|
||||
Isolate* isolate() const { return zone()->isolate(); }
|
||||
Zone* zone() const { return graph()->zone(); }
|
||||
MachineOperatorBuilder* machine() { return &machine_; }
|
||||
CommonOperatorBuilder* common() { return &common_; }
|
||||
CallDescriptor* call_descriptor() const { return call_descriptor_; }
|
||||
size_t parameter_count() const { return machine_sig_->parameter_count(); }
|
||||
MachineSignature* machine_sig() const { return machine_sig_; }
|
||||
|
||||
// Parameters.
|
||||
Node* Parameter(size_t index);
|
||||
// Variables.
|
||||
Variable NewVariable(Node* initial_value);
|
||||
// Control flow.
|
||||
void Return(Node* value);
|
||||
|
||||
// MachineAssembler is invalid after export.
|
||||
Schedule* Export();
|
||||
|
||||
protected:
|
||||
virtual Node* MakeNode(Operator* op, int input_count, Node** inputs);
|
||||
|
||||
Schedule* schedule() {
|
||||
DCHECK(ScheduleValid());
|
||||
return schedule_;
|
||||
}
|
||||
|
||||
private:
|
||||
bool ScheduleValid() { return schedule_ != NULL; }
|
||||
|
||||
typedef ZoneVector<Environment*> EnvironmentVector;
|
||||
|
||||
NodeVector* CurrentVars() { return ¤t_environment_->variables_; }
|
||||
@ -116,12 +94,6 @@ class StructuredMachineAssembler
|
||||
void MergeBackEdgesToLoopHeader(Environment* header,
|
||||
EnvironmentVector* environments);
|
||||
|
||||
Schedule* schedule_;
|
||||
MachineOperatorBuilder machine_;
|
||||
CommonOperatorBuilder common_;
|
||||
MachineSignature* machine_sig_;
|
||||
CallDescriptor* call_descriptor_;
|
||||
Node** parameters_;
|
||||
Environment* current_environment_;
|
||||
int number_of_variables_;
|
||||
|
||||
|
@ -424,7 +424,6 @@
|
||||
'../../src/compiler/linkage-impl.h',
|
||||
'../../src/compiler/linkage.cc',
|
||||
'../../src/compiler/linkage.h',
|
||||
'../../src/compiler/machine-node-factory.h',
|
||||
'../../src/compiler/machine-operator-reducer.cc',
|
||||
'../../src/compiler/machine-operator-reducer.h',
|
||||
'../../src/compiler/machine-operator.h',
|
||||
|
Loading…
Reference in New Issue
Block a user