Commit 9803a724 authored by titzer@chromium.org's avatar titzer@chromium.org

Unify MachineType and RepType.

MachineType now tracks both the representation and the value type of machine quantities and is used uniformly throughout TurboFan.

These types can now express uint8, int8, uint16, and int16, i.e. signed and unsigned smallish integers. Note that currently only uint8 and uint16 are implemented in the TF backends.

R=bmeurer@chromium.org, mstarzinger@chromium.org
BUG=

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23122 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ae7d781d
...@@ -285,28 +285,30 @@ static void VisitBinop(InstructionSelector* selector, Node* node, ...@@ -285,28 +285,30 @@ static void VisitBinop(InstructionSelector* selector, Node* node,
void InstructionSelector::VisitLoad(Node* node) { void InstructionSelector::VisitLoad(Node* node) {
MachineType rep = OpParameter<MachineType>(node); MachineType rep = RepresentationOf(OpParameter<MachineType>(node));
ArmOperandGenerator g(this); ArmOperandGenerator g(this);
Node* base = node->InputAt(0); Node* base = node->InputAt(0);
Node* index = node->InputAt(1); Node* index = node->InputAt(1);
InstructionOperand* result = rep == kMachineFloat64 InstructionOperand* result = rep == kRepFloat64
? g.DefineAsDoubleRegister(node) ? g.DefineAsDoubleRegister(node)
: g.DefineAsRegister(node); : g.DefineAsRegister(node);
ArchOpcode opcode; ArchOpcode opcode;
// TODO(titzer): signed/unsigned small loads
switch (rep) { switch (rep) {
case kMachineFloat64: case kRepFloat64:
opcode = kArmFloat64Load; opcode = kArmFloat64Load;
break; break;
case kMachineWord8: case kRepBit: // Fall through.
case kRepWord8:
opcode = kArmLoadWord8; opcode = kArmLoadWord8;
break; break;
case kMachineWord16: case kRepWord16:
opcode = kArmLoadWord16; opcode = kArmLoadWord16;
break; break;
case kMachineTagged: // Fall through. case kRepTagged: // Fall through.
case kMachineWord32: case kRepWord32:
opcode = kArmLoadWord32; opcode = kArmLoadWord32;
break; break;
default: default:
...@@ -334,9 +336,9 @@ void InstructionSelector::VisitStore(Node* node) { ...@@ -334,9 +336,9 @@ void InstructionSelector::VisitStore(Node* node) {
Node* value = node->InputAt(2); Node* value = node->InputAt(2);
StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node); StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node);
MachineType rep = store_rep.rep; MachineType rep = RepresentationOf(store_rep.machine_type);
if (store_rep.write_barrier_kind == kFullWriteBarrier) { if (store_rep.write_barrier_kind == kFullWriteBarrier) {
DCHECK(rep == kMachineTagged); DCHECK(rep == kRepTagged);
// TODO(dcarney): refactor RecordWrite function to take temp registers // TODO(dcarney): refactor RecordWrite function to take temp registers
// and pass them here instead of using fixed regs // and pass them here instead of using fixed regs
// TODO(dcarney): handle immediate indices. // TODO(dcarney): handle immediate indices.
...@@ -347,22 +349,23 @@ void InstructionSelector::VisitStore(Node* node) { ...@@ -347,22 +349,23 @@ void InstructionSelector::VisitStore(Node* node) {
return; return;
} }
DCHECK_EQ(kNoWriteBarrier, store_rep.write_barrier_kind); DCHECK_EQ(kNoWriteBarrier, store_rep.write_barrier_kind);
InstructionOperand* val = rep == kMachineFloat64 ? g.UseDoubleRegister(value) InstructionOperand* val =
: g.UseRegister(value); rep == kRepFloat64 ? g.UseDoubleRegister(value) : g.UseRegister(value);
ArchOpcode opcode; ArchOpcode opcode;
switch (rep) { switch (rep) {
case kMachineFloat64: case kRepFloat64:
opcode = kArmFloat64Store; opcode = kArmFloat64Store;
break; break;
case kMachineWord8: case kRepBit: // Fall through.
case kRepWord8:
opcode = kArmStoreWord8; opcode = kArmStoreWord8;
break; break;
case kMachineWord16: case kRepWord16:
opcode = kArmStoreWord16; opcode = kArmStoreWord16;
break; break;
case kMachineTagged: // Fall through. case kRepTagged: // Fall through.
case kMachineWord32: case kRepWord32:
opcode = kArmStoreWord32; opcode = kArmStoreWord32;
break; break;
default: default:
......
...@@ -150,31 +150,33 @@ static void VisitBinop(InstructionSelector* selector, Node* node, ...@@ -150,31 +150,33 @@ static void VisitBinop(InstructionSelector* selector, Node* node,
void InstructionSelector::VisitLoad(Node* node) { void InstructionSelector::VisitLoad(Node* node) {
MachineType rep = OpParameter<MachineType>(node); MachineType rep = RepresentationOf(OpParameter<MachineType>(node));
Arm64OperandGenerator g(this); Arm64OperandGenerator g(this);
Node* base = node->InputAt(0); Node* base = node->InputAt(0);
Node* index = node->InputAt(1); Node* index = node->InputAt(1);
InstructionOperand* result = rep == kMachineFloat64 InstructionOperand* result = rep == kRepFloat64
? g.DefineAsDoubleRegister(node) ? g.DefineAsDoubleRegister(node)
: g.DefineAsRegister(node); : g.DefineAsRegister(node);
ArchOpcode opcode; ArchOpcode opcode;
// TODO(titzer): signed/unsigned small loads
switch (rep) { switch (rep) {
case kMachineFloat64: case kRepFloat64:
opcode = kArm64Float64Load; opcode = kArm64Float64Load;
break; break;
case kMachineWord8: case kRepBit: // Fall through.
case kRepWord8:
opcode = kArm64LoadWord8; opcode = kArm64LoadWord8;
break; break;
case kMachineWord16: case kRepWord16:
opcode = kArm64LoadWord16; opcode = kArm64LoadWord16;
break; break;
case kMachineWord32: case kRepWord32:
opcode = kArm64LoadWord32; opcode = kArm64LoadWord32;
break; break;
case kMachineTagged: // Fall through. case kRepTagged: // Fall through.
case kMachineWord64: case kRepWord64:
opcode = kArm64LoadWord64; opcode = kArm64LoadWord64;
break; break;
default: default:
...@@ -201,9 +203,9 @@ void InstructionSelector::VisitStore(Node* node) { ...@@ -201,9 +203,9 @@ void InstructionSelector::VisitStore(Node* node) {
Node* value = node->InputAt(2); Node* value = node->InputAt(2);
StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node); StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node);
MachineType rep = store_rep.rep; MachineType rep = RepresentationOf(store_rep.machine_type);
if (store_rep.write_barrier_kind == kFullWriteBarrier) { if (store_rep.write_barrier_kind == kFullWriteBarrier) {
DCHECK(rep == kMachineTagged); DCHECK(rep == kRepTagged);
// TODO(dcarney): refactor RecordWrite function to take temp registers // TODO(dcarney): refactor RecordWrite function to take temp registers
// and pass them here instead of using fixed regs // and pass them here instead of using fixed regs
// TODO(dcarney): handle immediate indices. // TODO(dcarney): handle immediate indices.
...@@ -215,27 +217,28 @@ void InstructionSelector::VisitStore(Node* node) { ...@@ -215,27 +217,28 @@ void InstructionSelector::VisitStore(Node* node) {
} }
DCHECK_EQ(kNoWriteBarrier, store_rep.write_barrier_kind); DCHECK_EQ(kNoWriteBarrier, store_rep.write_barrier_kind);
InstructionOperand* val; InstructionOperand* val;
if (rep == kMachineFloat64) { if (rep == kRepFloat64) {
val = g.UseDoubleRegister(value); val = g.UseDoubleRegister(value);
} else { } else {
val = g.UseRegister(value); val = g.UseRegister(value);
} }
ArchOpcode opcode; ArchOpcode opcode;
switch (rep) { switch (rep) {
case kMachineFloat64: case kRepFloat64:
opcode = kArm64Float64Store; opcode = kArm64Float64Store;
break; break;
case kMachineWord8: case kRepBit: // Fall through.
case kRepWord8:
opcode = kArm64StoreWord8; opcode = kArm64StoreWord8;
break; break;
case kMachineWord16: case kRepWord16:
opcode = kArm64StoreWord16; opcode = kArm64StoreWord16;
break; break;
case kMachineWord32: case kRepWord32:
opcode = kArm64StoreWord32; opcode = kArm64StoreWord32;
break; break;
case kMachineTagged: // Fall through. case kRepTagged: // Fall through.
case kMachineWord64: case kRepWord64:
opcode = kArm64StoreWord64; opcode = kArm64StoreWord64;
break; break;
default: default:
......
...@@ -173,7 +173,7 @@ Reduction ChangeLowering<4>::ChangeInt32ToTagged(Node* val, Node* effect, ...@@ -173,7 +173,7 @@ Reduction ChangeLowering<4>::ChangeInt32ToTagged(Node* val, Node* effect,
Int32Constant(0), context, effect, if_true); Int32Constant(0), context, effect, if_true);
Node* store = graph()->NewNode( Node* store = graph()->NewNode(
machine()->Store(kMachineFloat64, kNoWriteBarrier), heap_number, machine()->Store(kMachFloat64, kNoWriteBarrier), heap_number,
Int32Constant(HeapNumber::kValueOffset - kHeapObjectTag), number, effect, Int32Constant(HeapNumber::kValueOffset - kHeapObjectTag), number, effect,
heap_number); heap_number);
...@@ -206,7 +206,7 @@ Reduction ChangeLowering<4>::ChangeTaggedToFloat64(Node* val, Node* effect, ...@@ -206,7 +206,7 @@ Reduction ChangeLowering<4>::ChangeTaggedToFloat64(Node* val, Node* effect,
Node* if_true = graph()->NewNode(common()->IfTrue(), branch); Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
Node* load = graph()->NewNode( Node* load = graph()->NewNode(
machine()->Load(kMachineFloat64), val, machine()->Load(kMachFloat64), val,
Int32Constant(HeapNumber::kValueOffset - kHeapObjectTag), if_true); Int32Constant(HeapNumber::kValueOffset - kHeapObjectTag), if_true);
Node* if_false = graph()->NewNode(common()->IfFalse(), branch); Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
...@@ -233,7 +233,7 @@ Reduction ChangeLowering<8>::ChangeTaggedToFloat64(Node* val, Node* effect, ...@@ -233,7 +233,7 @@ Reduction ChangeLowering<8>::ChangeTaggedToFloat64(Node* val, Node* effect,
Node* if_true = graph()->NewNode(common()->IfTrue(), branch); Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
Node* load = graph()->NewNode( Node* load = graph()->NewNode(
machine()->Load(kMachineFloat64), val, machine()->Load(kMachFloat64), val,
Int32Constant(HeapNumber::kValueOffset - kHeapObjectTag), if_true); Int32Constant(HeapNumber::kValueOffset - kHeapObjectTag), if_true);
Node* if_false = graph()->NewNode(common()->IfFalse(), branch); Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
......
...@@ -41,27 +41,29 @@ class IA32OperandGenerator V8_FINAL : public OperandGenerator { ...@@ -41,27 +41,29 @@ class IA32OperandGenerator V8_FINAL : public OperandGenerator {
void InstructionSelector::VisitLoad(Node* node) { void InstructionSelector::VisitLoad(Node* node) {
MachineType rep = OpParameter<MachineType>(node); MachineType rep = RepresentationOf(OpParameter<MachineType>(node));
IA32OperandGenerator g(this); IA32OperandGenerator g(this);
Node* base = node->InputAt(0); Node* base = node->InputAt(0);
Node* index = node->InputAt(1); Node* index = node->InputAt(1);
InstructionOperand* output = rep == kMachineFloat64 InstructionOperand* output = rep == kRepFloat64
? g.DefineAsDoubleRegister(node) ? g.DefineAsDoubleRegister(node)
: g.DefineAsRegister(node); : g.DefineAsRegister(node);
ArchOpcode opcode; ArchOpcode opcode;
// TODO(titzer): signed/unsigned small loads
switch (rep) { switch (rep) {
case kMachineFloat64: case kRepFloat64:
opcode = kSSELoad; opcode = kSSELoad;
break; break;
case kMachineWord8: case kRepBit: // Fall through.
case kRepWord8:
opcode = kIA32LoadWord8; opcode = kIA32LoadWord8;
break; break;
case kMachineWord16: case kRepWord16:
opcode = kIA32LoadWord16; opcode = kIA32LoadWord16;
break; break;
case kMachineTagged: // Fall through. case kRepTagged: // Fall through.
case kMachineWord32: case kRepWord32:
opcode = kIA32LoadWord32; opcode = kIA32LoadWord32;
break; break;
default: default:
...@@ -94,9 +96,9 @@ void InstructionSelector::VisitStore(Node* node) { ...@@ -94,9 +96,9 @@ void InstructionSelector::VisitStore(Node* node) {
Node* value = node->InputAt(2); Node* value = node->InputAt(2);
StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node); StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node);
MachineType rep = store_rep.rep; MachineType rep = RepresentationOf(store_rep.machine_type);
if (store_rep.write_barrier_kind == kFullWriteBarrier) { if (store_rep.write_barrier_kind == kFullWriteBarrier) {
DCHECK_EQ(kMachineTagged, rep); DCHECK_EQ(kRepTagged, rep);
// TODO(dcarney): refactor RecordWrite function to take temp registers // TODO(dcarney): refactor RecordWrite function to take temp registers
// and pass them here instead of using fixed regs // and pass them here instead of using fixed regs
// TODO(dcarney): handle immediate indices. // TODO(dcarney): handle immediate indices.
...@@ -109,13 +111,13 @@ void InstructionSelector::VisitStore(Node* node) { ...@@ -109,13 +111,13 @@ void InstructionSelector::VisitStore(Node* node) {
DCHECK_EQ(kNoWriteBarrier, store_rep.write_barrier_kind); DCHECK_EQ(kNoWriteBarrier, store_rep.write_barrier_kind);
bool is_immediate = false; bool is_immediate = false;
InstructionOperand* val; InstructionOperand* val;
if (rep == kMachineFloat64) { if (rep == kRepFloat64) {
val = g.UseDoubleRegister(value); val = g.UseDoubleRegister(value);
} else { } else {
is_immediate = g.CanBeImmediate(value); is_immediate = g.CanBeImmediate(value);
if (is_immediate) { if (is_immediate) {
val = g.UseImmediate(value); val = g.UseImmediate(value);
} else if (rep == kMachineWord8) { } else if (rep == kRepWord8 || rep == kRepBit) {
val = g.UseByteRegister(value); val = g.UseByteRegister(value);
} else { } else {
val = g.UseRegister(value); val = g.UseRegister(value);
...@@ -123,17 +125,18 @@ void InstructionSelector::VisitStore(Node* node) { ...@@ -123,17 +125,18 @@ void InstructionSelector::VisitStore(Node* node) {
} }
ArchOpcode opcode; ArchOpcode opcode;
switch (rep) { switch (rep) {
case kMachineFloat64: case kRepFloat64:
opcode = kSSEStore; opcode = kSSEStore;
break; break;
case kMachineWord8: case kRepBit: // Fall through.
case kRepWord8:
opcode = is_immediate ? kIA32StoreWord8I : kIA32StoreWord8; opcode = is_immediate ? kIA32StoreWord8I : kIA32StoreWord8;
break; break;
case kMachineWord16: case kRepWord16:
opcode = is_immediate ? kIA32StoreWord16I : kIA32StoreWord16; opcode = is_immediate ? kIA32StoreWord16I : kIA32StoreWord16;
break; break;
case kMachineTagged: // Fall through. case kRepTagged: // Fall through.
case kMachineWord32: case kRepWord32:
opcode = is_immediate ? kIA32StoreWord32I : kIA32StoreWord32; opcode = is_immediate ? kIA32StoreWord32I : kIA32StoreWord32;
break; break;
default: default:
......
...@@ -201,7 +201,7 @@ class OperandGenerator { ...@@ -201,7 +201,7 @@ class OperandGenerator {
return new (zone()) UnallocatedOperand(UnallocatedOperand::FIXED_SLOT, return new (zone()) UnallocatedOperand(UnallocatedOperand::FIXED_SLOT,
location.location_); location.location_);
} }
if (location.rep_ == kMachineFloat64) { if (RepresentationOf(location.rep_) == kRepFloat64) {
return new (zone()) UnallocatedOperand( return new (zone()) UnallocatedOperand(
UnallocatedOperand::FIXED_DOUBLE_REGISTER, location.location_); UnallocatedOperand::FIXED_DOUBLE_REGISTER, location.location_);
} }
......
...@@ -232,8 +232,8 @@ void InstructionSelector::MarkAsReference(Node* node) { ...@@ -232,8 +232,8 @@ void InstructionSelector::MarkAsReference(Node* node) {
void InstructionSelector::MarkAsRepresentation(MachineType rep, Node* node) { void InstructionSelector::MarkAsRepresentation(MachineType rep, Node* node) {
DCHECK_NOT_NULL(node); DCHECK_NOT_NULL(node);
if (rep == kMachineFloat64) MarkAsDouble(node); if (RepresentationOf(rep) == kRepFloat64) MarkAsDouble(node);
if (rep == kMachineTagged) MarkAsReference(node); if (RepresentationOf(rep) == kRepTagged) MarkAsReference(node);
} }
......
...@@ -479,13 +479,13 @@ Node* JSGenericLowering::LowerJSLoadContext(Node* node) { ...@@ -479,13 +479,13 @@ Node* JSGenericLowering::LowerJSLoadContext(Node* node) {
for (int i = 0; i < access.depth(); ++i) { for (int i = 0; i < access.depth(); ++i) {
node->ReplaceInput( node->ReplaceInput(
0, graph()->NewNode( 0, graph()->NewNode(
machine()->Load(kMachineTagged), machine()->Load(kMachAnyTagged),
NodeProperties::GetValueInput(node, 0), NodeProperties::GetValueInput(node, 0),
Int32Constant(Context::SlotOffset(Context::PREVIOUS_INDEX)), Int32Constant(Context::SlotOffset(Context::PREVIOUS_INDEX)),
NodeProperties::GetEffectInput(node))); NodeProperties::GetEffectInput(node)));
} }
node->ReplaceInput(1, Int32Constant(Context::SlotOffset(access.index()))); node->ReplaceInput(1, Int32Constant(Context::SlotOffset(access.index())));
PatchOperator(node, machine()->Load(kMachineTagged)); PatchOperator(node, machine()->Load(kMachAnyTagged));
return node; return node;
} }
...@@ -497,14 +497,14 @@ Node* JSGenericLowering::LowerJSStoreContext(Node* node) { ...@@ -497,14 +497,14 @@ Node* JSGenericLowering::LowerJSStoreContext(Node* node) {
for (int i = 0; i < access.depth(); ++i) { for (int i = 0; i < access.depth(); ++i) {
node->ReplaceInput( node->ReplaceInput(
0, graph()->NewNode( 0, graph()->NewNode(
machine()->Load(kMachineTagged), machine()->Load(kMachAnyTagged),
NodeProperties::GetValueInput(node, 0), NodeProperties::GetValueInput(node, 0),
Int32Constant(Context::SlotOffset(Context::PREVIOUS_INDEX)), Int32Constant(Context::SlotOffset(Context::PREVIOUS_INDEX)),
NodeProperties::GetEffectInput(node))); NodeProperties::GetEffectInput(node)));
} }
node->ReplaceInput(2, NodeProperties::GetValueInput(node, 1)); node->ReplaceInput(2, NodeProperties::GetValueInput(node, 1));
node->ReplaceInput(1, Int32Constant(Context::SlotOffset(access.index()))); node->ReplaceInput(1, Int32Constant(Context::SlotOffset(access.index())));
PatchOperator(node, machine()->Store(kMachineTagged, kFullWriteBarrier)); PatchOperator(node, machine()->Store(kMachAnyTagged, kFullWriteBarrier));
return node; return node;
} }
......
...@@ -13,11 +13,11 @@ class LinkageHelper { ...@@ -13,11 +13,11 @@ class LinkageHelper {
public: public:
static LinkageLocation TaggedStackSlot(int index) { static LinkageLocation TaggedStackSlot(int index) {
DCHECK(index < 0); DCHECK(index < 0);
return LinkageLocation(kMachineTagged, index); return LinkageLocation(kMachAnyTagged, index);
} }
static LinkageLocation TaggedRegisterLocation(Register reg) { static LinkageLocation TaggedRegisterLocation(Register reg) {
return LinkageLocation(kMachineTagged, Register::ToAllocationIndex(reg)); return LinkageLocation(kMachAnyTagged, Register::ToAllocationIndex(reg));
} }
static inline LinkageLocation WordRegisterLocation(Register reg) { static inline LinkageLocation WordRegisterLocation(Register reg) {
...@@ -98,7 +98,7 @@ class LinkageHelper { ...@@ -98,7 +98,7 @@ class LinkageHelper {
DCHECK_LE(return_count, 2); DCHECK_LE(return_count, 2);
locations[index++] = UnconstrainedRegister(kMachineTagged); // CEntryStub locations[index++] = UnconstrainedRegister(kMachAnyTagged); // CEntryStub
for (int i = 0; i < parameter_count; i++) { for (int i = 0; i < parameter_count; i++) {
// All parameters to runtime calls go on the stack. // All parameters to runtime calls go on the stack.
...@@ -143,7 +143,7 @@ class LinkageHelper { ...@@ -143,7 +143,7 @@ class LinkageHelper {
int index = 0; int index = 0;
locations[index++] = locations[index++] =
TaggedRegisterLocation(LinkageTraits::ReturnValueReg()); TaggedRegisterLocation(LinkageTraits::ReturnValueReg());
locations[index++] = UnconstrainedRegister(kMachineTagged); // code locations[index++] = UnconstrainedRegister(kMachAnyTagged); // code
for (int i = 0; i < parameter_count; i++) { for (int i = 0; i < parameter_count; i++) {
if (i < register_parameter_count) { if (i < register_parameter_count) {
// The first parameters to code stub calls go in registers. // The first parameters to code stub calls go in registers.
......
...@@ -21,7 +21,7 @@ enum WriteBarrierKind { kNoWriteBarrier, kFullWriteBarrier }; ...@@ -21,7 +21,7 @@ enum WriteBarrierKind { kNoWriteBarrier, kFullWriteBarrier };
// A Store needs a MachineType and a WriteBarrierKind // A Store needs a MachineType and a WriteBarrierKind
// in order to emit the correct write barrier. // in order to emit the correct write barrier.
struct StoreRepresentation { struct StoreRepresentation {
MachineType rep; MachineType machine_type;
WriteBarrierKind write_barrier_kind; WriteBarrierKind write_barrier_kind;
}; };
...@@ -33,7 +33,7 @@ class MachineOperatorBuilder { ...@@ -33,7 +33,7 @@ class MachineOperatorBuilder {
public: public:
explicit MachineOperatorBuilder(Zone* zone, MachineType word = pointer_rep()) explicit MachineOperatorBuilder(Zone* zone, MachineType word = pointer_rep())
: zone_(zone), word_(word) { : zone_(zone), word_(word) {
CHECK(word == kMachineWord32 || word == kMachineWord64); CHECK(word == kRepWord32 || word == kRepWord64);
} }
#define SIMPLE(name, properties, inputs, outputs) \ #define SIMPLE(name, properties, inputs, outputs) \
...@@ -146,12 +146,12 @@ class MachineOperatorBuilder { ...@@ -146,12 +146,12 @@ class MachineOperatorBuilder {
Operator* Float64LessThan() { BINOP(Float64LessThan); } Operator* Float64LessThan() { BINOP(Float64LessThan); }
Operator* Float64LessThanOrEqual() { BINOP(Float64LessThanOrEqual); } Operator* Float64LessThanOrEqual() { BINOP(Float64LessThanOrEqual); }
inline bool is32() const { return word_ == kMachineWord32; } inline bool is32() const { return word_ == kRepWord32; }
inline bool is64() const { return word_ == kMachineWord64; } inline bool is64() const { return word_ == kRepWord64; }
inline MachineType word() const { return word_; } inline MachineType word() const { return word_; }
static inline MachineType pointer_rep() { static inline MachineType pointer_rep() {
return kPointerSize == 8 ? kMachineWord64 : kMachineWord32; return kPointerSize == 8 ? kRepWord64 : kRepWord32;
} }
#undef WORD_SIZE #undef WORD_SIZE
......
// 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.
#include "src/compiler/machine-type.h"
#include "src/ostreams.h"
namespace v8 {
namespace internal {
namespace compiler {
#define PRINT(bit) \
if (type & bit) { \
if (before) os << "|"; \
os << #bit; \
before = true; \
}
OStream& operator<<(OStream& os, const MachineType& type) {
bool before = false;
PRINT(kRepBit);
PRINT(kRepWord8);
PRINT(kRepWord16);
PRINT(kRepWord32);
PRINT(kRepWord64);
PRINT(kRepFloat64);
PRINT(kRepTagged);
PRINT(kTypeBool);
PRINT(kTypeInt32);
PRINT(kTypeUint32);
PRINT(kTypeInt64);
PRINT(kTypeUint64);
PRINT(kTypeNumber);
PRINT(kTypeAny);
return os;
}
}
}
} // namespace v8::internal::compiler
...@@ -5,30 +5,98 @@ ...@@ -5,30 +5,98 @@
#ifndef V8_COMPILER_MACHINE_TYPE_H_ #ifndef V8_COMPILER_MACHINE_TYPE_H_
#define V8_COMPILER_MACHINE_TYPE_H_ #define V8_COMPILER_MACHINE_TYPE_H_
#include "src/globals.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
class OStream;
namespace compiler { namespace compiler {
// An enumeration of the storage representations at the machine level. // Machine-level types and representations.
// - Words are uninterpreted bits of a given fixed size that can be used // TODO(titzer): Use the real type system instead of MachineType.
// to store integers and pointers. They are normally allocated to general
// purpose registers by the backend and are not tracked for GC.
// - Floats are bits of a given fixed size that are used to store floating
// point numbers. They are normally allocated to the floating point
// registers of the machine and are not tracked for the GC.
// - Tagged values are the size of a reference into the heap and can store
// small words or references into the heap using a language and potentially
// machine-dependent tagging scheme. These values are tracked by the code
// generator for precise GC.
enum MachineType { enum MachineType {
kMachineWord8, // Representations.
kMachineWord16, kRepBit = 1 << 0,
kMachineWord32, kRepWord8 = 1 << 1,
kMachineWord64, kRepWord16 = 1 << 2,
kMachineFloat64, kRepWord32 = 1 << 3,
kMachineTagged, kRepWord64 = 1 << 4,
kMachineLast kRepFloat64 = 1 << 5,
kRepTagged = 1 << 6,
// Types.
kTypeBool = 1 << 7,
kTypeInt32 = 1 << 8,
kTypeUint32 = 1 << 9,
kTypeInt64 = 1 << 10,
kTypeUint64 = 1 << 11,
kTypeNumber = 1 << 12,
kTypeAny = 1 << 13
}; };
OStream& operator<<(OStream& os, const MachineType& type);
typedef uint16_t MachineTypeUnion;
// Globally useful machine types and constants.
const MachineTypeUnion kRepMask = kRepBit | kRepWord8 | kRepWord16 |
kRepWord32 | kRepWord64 | kRepFloat64 |
kRepTagged;
const MachineTypeUnion kTypeMask = kTypeBool | kTypeInt32 | kTypeUint32 |
kTypeInt64 | kTypeUint64 | kTypeNumber |
kTypeAny;
const MachineType kMachNone = static_cast<MachineType>(0);
const MachineType kMachFloat64 =
static_cast<MachineType>(kRepFloat64 | kTypeNumber);
const MachineType kMachInt8 = static_cast<MachineType>(kRepWord8 | kTypeInt32);
const MachineType kMachUint8 =
static_cast<MachineType>(kRepWord8 | kTypeUint32);
const MachineType kMachInt16 =
static_cast<MachineType>(kRepWord16 | kTypeInt32);
const MachineType kMachUint16 =
static_cast<MachineType>(kRepWord16 | kTypeUint32);
const MachineType kMachInt32 =
static_cast<MachineType>(kRepWord32 | kTypeInt32);
const MachineType kMachUint32 =
static_cast<MachineType>(kRepWord32 | kTypeUint32);
const MachineType kMachInt64 =
static_cast<MachineType>(kRepWord64 | kTypeInt64);
const MachineType kMachUint64 =
static_cast<MachineType>(kRepWord64 | kTypeUint64);
const MachineType kMachPtr = kPointerSize == 4 ? kRepWord32 : kRepWord64;
const MachineType kMachAnyTagged =
static_cast<MachineType>(kRepTagged | kTypeAny);
// Gets only the representation of the given type.
inline MachineType RepresentationOf(MachineType machine_type) {
int result = machine_type & kRepMask;
CHECK(IsPowerOf2(result));
return static_cast<MachineType>(result);
}
// Gets the element size in bytes of the machine type.
inline int ElementSizeOf(MachineType machine_type) {
switch (RepresentationOf(machine_type)) {
case kRepBit:
case kRepWord8:
return 1;
case kRepWord16:
return 2;
case kRepWord32:
return 4;
case kRepWord64:
case kRepFloat64:
return 8;
case kRepTagged:
return kPointerSize;
default:
UNREACHABLE();
return kPointerSize;
}
}
} }
} }
} // namespace v8::internal::compiler } // namespace v8::internal::compiler
......
This diff is collapsed.
This diff is collapsed.
...@@ -23,7 +23,7 @@ struct FieldAccess { ...@@ -23,7 +23,7 @@ struct FieldAccess {
int offset; // offset of the field, without tag. int offset; // offset of the field, without tag.
Handle<Name> name; // debugging only. Handle<Name> name; // debugging only.
Type* type; // type of the field. Type* type; // type of the field.
MachineType representation; // machine representation of field. MachineType machine_type; // machine type of the field.
int tag() const { return base_is_tagged == kTaggedBase ? kHeapObjectTag : 0; } int tag() const { return base_is_tagged == kTaggedBase ? kHeapObjectTag : 0; }
}; };
...@@ -37,7 +37,7 @@ struct ElementAccess { ...@@ -37,7 +37,7 @@ struct ElementAccess {
BaseTaggedness base_is_tagged; // specifies if the base pointer is tagged. BaseTaggedness base_is_tagged; // specifies if the base pointer is tagged.
int header_size; // size of the header, without tag. int header_size; // size of the header, without tag.
Type* type; // type of the element. Type* type; // type of the element.
MachineType representation; // machine representation of element. MachineType machine_type; // machine type of the element.
int tag() const { return base_is_tagged == kTaggedBase ? kHeapObjectTag : 0; } int tag() const { return base_is_tagged == kTaggedBase ? kHeapObjectTag : 0; }
}; };
...@@ -54,11 +54,11 @@ struct StaticParameterTraits<const FieldAccess> { ...@@ -54,11 +54,11 @@ struct StaticParameterTraits<const FieldAccess> {
return os << val.offset; return os << val.offset;
} }
static int HashCode(const FieldAccess& val) { static int HashCode(const FieldAccess& val) {
return (val.offset < 16) | (val.representation & 0xffff); return (val.offset < 16) | (val.machine_type & 0xffff);
} }
static bool Equals(const FieldAccess& a, const FieldAccess& b) { static bool Equals(const FieldAccess& a, const FieldAccess& b) {
return a.base_is_tagged == b.base_is_tagged && a.offset == b.offset && return a.base_is_tagged == b.base_is_tagged && a.offset == b.offset &&
a.representation == b.representation && a.type->Is(b.type); a.machine_type == b.machine_type && a.type->Is(b.type);
} }
}; };
...@@ -70,12 +70,12 @@ struct StaticParameterTraits<const ElementAccess> { ...@@ -70,12 +70,12 @@ struct StaticParameterTraits<const ElementAccess> {
return os << val.header_size; return os << val.header_size;
} }
static int HashCode(const ElementAccess& val) { static int HashCode(const ElementAccess& val) {
return (val.header_size < 16) | (val.representation & 0xffff); return (val.header_size < 16) | (val.machine_type & 0xffff);
} }
static bool Equals(const ElementAccess& a, const ElementAccess& b) { static bool Equals(const ElementAccess& a, const ElementAccess& b) {
return a.base_is_tagged == b.base_is_tagged && return a.base_is_tagged == b.base_is_tagged &&
a.header_size == b.header_size && a.header_size == b.header_size && a.machine_type == b.machine_type &&
a.representation == b.representation && a.type->Is(b.type); a.type->Is(b.type);
} }
}; };
......
...@@ -56,30 +56,32 @@ class X64OperandGenerator V8_FINAL : public OperandGenerator { ...@@ -56,30 +56,32 @@ class X64OperandGenerator V8_FINAL : public OperandGenerator {
void InstructionSelector::VisitLoad(Node* node) { void InstructionSelector::VisitLoad(Node* node) {
MachineType rep = OpParameter<MachineType>(node); MachineType rep = RepresentationOf(OpParameter<MachineType>(node));
X64OperandGenerator g(this); X64OperandGenerator g(this);
Node* base = node->InputAt(0); Node* base = node->InputAt(0);
Node* index = node->InputAt(1); Node* index = node->InputAt(1);
InstructionOperand* output = rep == kMachineFloat64 InstructionOperand* output = rep == kRepFloat64
? g.DefineAsDoubleRegister(node) ? g.DefineAsDoubleRegister(node)
: g.DefineAsRegister(node); : g.DefineAsRegister(node);
ArchOpcode opcode; ArchOpcode opcode;
// TODO(titzer): signed/unsigned small loads
switch (rep) { switch (rep) {
case kMachineFloat64: case kRepFloat64:
opcode = kSSELoad; opcode = kSSELoad;
break; break;
case kMachineWord8: case kRepBit: // Fall through.
case kRepWord8:
opcode = kX64LoadWord8; opcode = kX64LoadWord8;
break; break;
case kMachineWord16: case kRepWord16:
opcode = kX64LoadWord16; opcode = kX64LoadWord16;
break; break;
case kMachineWord32: case kRepWord32:
opcode = kX64LoadWord32; opcode = kX64LoadWord32;
break; break;
case kMachineTagged: // Fall through. case kRepTagged: // Fall through.
case kMachineWord64: case kRepWord64:
opcode = kX64LoadWord64; opcode = kX64LoadWord64;
break; break;
default: default:
...@@ -108,9 +110,9 @@ void InstructionSelector::VisitStore(Node* node) { ...@@ -108,9 +110,9 @@ void InstructionSelector::VisitStore(Node* node) {
Node* value = node->InputAt(2); Node* value = node->InputAt(2);
StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node); StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node);
MachineType rep = store_rep.rep; MachineType rep = RepresentationOf(store_rep.machine_type);
if (store_rep.write_barrier_kind == kFullWriteBarrier) { if (store_rep.write_barrier_kind == kFullWriteBarrier) {
DCHECK(rep == kMachineTagged); DCHECK(rep == kRepTagged);
// TODO(dcarney): refactor RecordWrite function to take temp registers // TODO(dcarney): refactor RecordWrite function to take temp registers
// and pass them here instead of using fixed regs // and pass them here instead of using fixed regs
// TODO(dcarney): handle immediate indices. // TODO(dcarney): handle immediate indices.
...@@ -123,13 +125,13 @@ void InstructionSelector::VisitStore(Node* node) { ...@@ -123,13 +125,13 @@ void InstructionSelector::VisitStore(Node* node) {
DCHECK_EQ(kNoWriteBarrier, store_rep.write_barrier_kind); DCHECK_EQ(kNoWriteBarrier, store_rep.write_barrier_kind);
bool is_immediate = false; bool is_immediate = false;
InstructionOperand* val; InstructionOperand* val;
if (rep == kMachineFloat64) { if (rep == kRepFloat64) {
val = g.UseDoubleRegister(value); val = g.UseDoubleRegister(value);
} else { } else {
is_immediate = g.CanBeImmediate(value); is_immediate = g.CanBeImmediate(value);
if (is_immediate) { if (is_immediate) {
val = g.UseImmediate(value); val = g.UseImmediate(value);
} else if (rep == kMachineWord8) { } else if (rep == kRepWord8 || rep == kRepBit) {
val = g.UseByteRegister(value); val = g.UseByteRegister(value);
} else { } else {
val = g.UseRegister(value); val = g.UseRegister(value);
...@@ -137,20 +139,21 @@ void InstructionSelector::VisitStore(Node* node) { ...@@ -137,20 +139,21 @@ void InstructionSelector::VisitStore(Node* node) {
} }
ArchOpcode opcode; ArchOpcode opcode;
switch (rep) { switch (rep) {
case kMachineFloat64: case kRepFloat64:
opcode = kSSEStore; opcode = kSSEStore;
break; break;
case kMachineWord8: case kRepBit: // Fall through.
case kRepWord8:
opcode = is_immediate ? kX64StoreWord8I : kX64StoreWord8; opcode = is_immediate ? kX64StoreWord8I : kX64StoreWord8;
break; break;
case kMachineWord16: case kRepWord16:
opcode = is_immediate ? kX64StoreWord16I : kX64StoreWord16; opcode = is_immediate ? kX64StoreWord16I : kX64StoreWord16;
break; break;
case kMachineWord32: case kRepWord32:
opcode = is_immediate ? kX64StoreWord32I : kX64StoreWord32; opcode = is_immediate ? kX64StoreWord32I : kX64StoreWord32;
break; break;
case kMachineTagged: // Fall through. case kRepTagged: // Fall through.
case kMachineWord64: case kRepWord64:
opcode = is_immediate ? kX64StoreWord64I : kX64StoreWord64; opcode = is_immediate ? kX64StoreWord64I : kX64StoreWord64;
break; break;
default: default:
......
...@@ -23,6 +23,7 @@ namespace v8 { ...@@ -23,6 +23,7 @@ namespace v8 {
namespace internal { namespace internal {
namespace compiler { namespace compiler {
// TODO(titzer): move MachineType selection for C types into machine-type.h
template <typename R> template <typename R>
struct ReturnValueTraits { struct ReturnValueTraits {
static R Cast(uintptr_t r) { return reinterpret_cast<R>(r); } static R Cast(uintptr_t r) { return reinterpret_cast<R>(r); }
...@@ -32,72 +33,62 @@ struct ReturnValueTraits { ...@@ -32,72 +33,62 @@ struct ReturnValueTraits {
while (false) { while (false) {
*(static_cast<Object* volatile*>(0)) = static_cast<R>(0); *(static_cast<Object* volatile*>(0)) = static_cast<R>(0);
} }
return kMachineTagged; return kMachAnyTagged;
} }
}; };
template <> template <>
struct ReturnValueTraits<int32_t*> { struct ReturnValueTraits<int32_t*> {
static int32_t* Cast(uintptr_t r) { return reinterpret_cast<int32_t*>(r); } static int32_t* Cast(uintptr_t r) { return reinterpret_cast<int32_t*>(r); }
static MachineType Representation() { static MachineType Representation() { return kMachPtr; }
return MachineOperatorBuilder::pointer_rep();
}
}; };
template <> template <>
struct ReturnValueTraits<void> { struct ReturnValueTraits<void> {
static void Cast(uintptr_t r) {} static void Cast(uintptr_t r) {}
static MachineType Representation() { static MachineType Representation() { return kMachPtr; }
return MachineOperatorBuilder::pointer_rep();
}
}; };
template <> template <>
struct ReturnValueTraits<bool> { struct ReturnValueTraits<bool> {
static bool Cast(uintptr_t r) { return static_cast<bool>(r); } static bool Cast(uintptr_t r) { return static_cast<bool>(r); }
static MachineType Representation() { static MachineType Representation() { return kRepBit; }
return MachineOperatorBuilder::pointer_rep();
}
}; };
template <> template <>
struct ReturnValueTraits<int32_t> { struct ReturnValueTraits<int32_t> {
static int32_t Cast(uintptr_t r) { return static_cast<int32_t>(r); } static int32_t Cast(uintptr_t r) { return static_cast<int32_t>(r); }
static MachineType Representation() { return kMachineWord32; } static MachineType Representation() { return kMachInt32; }
}; };
template <> template <>
struct ReturnValueTraits<uint32_t> { struct ReturnValueTraits<uint32_t> {
static uint32_t Cast(uintptr_t r) { return static_cast<uint32_t>(r); } static uint32_t Cast(uintptr_t r) { return static_cast<uint32_t>(r); }
static MachineType Representation() { return kMachineWord32; } static MachineType Representation() { return kMachUint32; }
}; };
template <> template <>
struct ReturnValueTraits<int64_t> { struct ReturnValueTraits<int64_t> {
static int64_t Cast(uintptr_t r) { return static_cast<int64_t>(r); } static int64_t Cast(uintptr_t r) { return static_cast<int64_t>(r); }
static MachineType Representation() { return kMachineWord64; } static MachineType Representation() { return kMachInt64; }
}; };
template <> template <>
struct ReturnValueTraits<uint64_t> { struct ReturnValueTraits<uint64_t> {
static uint64_t Cast(uintptr_t r) { return static_cast<uint64_t>(r); } static uint64_t Cast(uintptr_t r) { return static_cast<uint64_t>(r); }
static MachineType Representation() { return kMachineWord64; } static MachineType Representation() { return kMachUint64; }
}; };
template <> template <>
struct ReturnValueTraits<int16_t> { struct ReturnValueTraits<int16_t> {
static int16_t Cast(uintptr_t r) { return static_cast<int16_t>(r); } static int16_t Cast(uintptr_t r) { return static_cast<int16_t>(r); }
static MachineType Representation() { static MachineType Representation() { return kMachInt16; }
return MachineOperatorBuilder::pointer_rep();
}
}; };
template <> template <>
struct ReturnValueTraits<int8_t> { struct ReturnValueTraits<int8_t> {
static int8_t Cast(uintptr_t r) { return static_cast<int8_t>(r); } static int8_t Cast(uintptr_t r) { return static_cast<int8_t>(r); }
static MachineType Representation() { static MachineType Representation() { return kMachInt8; }
return MachineOperatorBuilder::pointer_rep();
}
}; };
template <> template <>
...@@ -106,7 +97,7 @@ struct ReturnValueTraits<double> { ...@@ -106,7 +97,7 @@ struct ReturnValueTraits<double> {
UNREACHABLE(); UNREACHABLE();
return 0.0; return 0.0;
} }
static MachineType Representation() { return kMachineFloat64; } static MachineType Representation() { return kMachFloat64; }
}; };
...@@ -131,9 +122,9 @@ class CallHelper { ...@@ -131,9 +122,9 @@ class CallHelper {
virtual ~CallHelper() {} virtual ~CallHelper() {}
static MachineCallDescriptorBuilder* ToCallDescriptorBuilder( static MachineCallDescriptorBuilder* ToCallDescriptorBuilder(
Zone* zone, MachineType return_type, MachineType p0 = kMachineLast, Zone* zone, MachineType return_type, MachineType p0 = kMachNone,
MachineType p1 = kMachineLast, MachineType p2 = kMachineLast, MachineType p1 = kMachNone, MachineType p2 = kMachNone,
MachineType p3 = kMachineLast, MachineType p4 = kMachineLast) { MachineType p3 = kMachNone, MachineType p4 = kMachNone) {
const int kSize = 5; const int kSize = 5;
MachineType* params = zone->NewArray<MachineType>(kSize); MachineType* params = zone->NewArray<MachineType>(kSize);
params[0] = p0; params[0] = p0;
...@@ -143,7 +134,7 @@ class CallHelper { ...@@ -143,7 +134,7 @@ class CallHelper {
params[4] = p4; params[4] = p4;
int parameter_count = 0; int parameter_count = 0;
for (int i = 0; i < kSize; ++i) { for (int i = 0; i < kSize; ++i) {
if (params[i] == kMachineLast) { if (params[i] == kMachNone) {
break; break;
} }
parameter_count++; parameter_count++;
......
...@@ -293,7 +293,7 @@ void Int32BinopInputShapeTester::TestAllInputShapes() { ...@@ -293,7 +293,7 @@ void Int32BinopInputShapeTester::TestAllInputShapes() {
for (int i = -2; i < num_int_inputs; i++) { // for all left shapes for (int i = -2; i < num_int_inputs; i++) { // for all left shapes
for (int j = -2; j < num_int_inputs; j++) { // for all right shapes for (int j = -2; j < num_int_inputs; j++) { // for all right shapes
if (i >= 0 && j >= 0) break; // No constant/constant combos if (i >= 0 && j >= 0) break; // No constant/constant combos
RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32);
Node* p0 = m.Parameter(0); Node* p0 = m.Parameter(0);
Node* p1 = m.Parameter(1); Node* p1 = m.Parameter(1);
Node* n0; Node* n0;
...@@ -303,7 +303,7 @@ void Int32BinopInputShapeTester::TestAllInputShapes() { ...@@ -303,7 +303,7 @@ void Int32BinopInputShapeTester::TestAllInputShapes() {
if (i == -2) { if (i == -2) {
n0 = p0; n0 = p0;
} else if (i == -1) { } else if (i == -1) {
n0 = m.LoadFromPointer(&input_a, kMachineWord32); n0 = m.LoadFromPointer(&input_a, kMachInt32);
} else { } else {
n0 = m.Int32Constant(inputs[i]); n0 = m.Int32Constant(inputs[i]);
} }
...@@ -312,7 +312,7 @@ void Int32BinopInputShapeTester::TestAllInputShapes() { ...@@ -312,7 +312,7 @@ void Int32BinopInputShapeTester::TestAllInputShapes() {
if (j == -2) { if (j == -2) {
n1 = p1; n1 = p1;
} else if (j == -1) { } else if (j == -1) {
n1 = m.LoadFromPointer(&input_b, kMachineWord32); n1 = m.LoadFromPointer(&input_b, kMachInt32);
} else { } else {
n1 = m.Int32Constant(inputs[j]); n1 = m.Int32Constant(inputs[j]);
} }
...@@ -370,7 +370,7 @@ void Int32BinopInputShapeTester::RunRight( ...@@ -370,7 +370,7 @@ void Int32BinopInputShapeTester::RunRight(
TEST(ParametersEqual) { TEST(ParametersEqual) {
RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32);
Node* p1 = m.Parameter(1); Node* p1 = m.Parameter(1);
CHECK_NE(NULL, p1); CHECK_NE(NULL, p1);
Node* p0 = m.Parameter(0); Node* p0 = m.Parameter(0);
...@@ -486,7 +486,7 @@ TEST(RunHeapNumberConstant) { ...@@ -486,7 +486,7 @@ TEST(RunHeapNumberConstant) {
TEST(RunParam1) { TEST(RunParam1) {
RawMachineAssemblerTester<int32_t> m(kMachineWord32); RawMachineAssemblerTester<int32_t> m(kMachInt32);
m.Return(m.Parameter(0)); m.Return(m.Parameter(0));
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
...@@ -497,7 +497,7 @@ TEST(RunParam1) { ...@@ -497,7 +497,7 @@ TEST(RunParam1) {
TEST(RunParam2_1) { TEST(RunParam2_1) {
RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32);
Node* p0 = m.Parameter(0); Node* p0 = m.Parameter(0);
Node* p1 = m.Parameter(1); Node* p1 = m.Parameter(1);
m.Return(p0); m.Return(p0);
...@@ -511,7 +511,7 @@ TEST(RunParam2_1) { ...@@ -511,7 +511,7 @@ TEST(RunParam2_1) {
TEST(RunParam2_2) { TEST(RunParam2_2) {
RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32);
Node* p0 = m.Parameter(0); Node* p0 = m.Parameter(0);
Node* p1 = m.Parameter(1); Node* p1 = m.Parameter(1);
m.Return(p1); m.Return(p1);
...@@ -526,8 +526,7 @@ TEST(RunParam2_2) { ...@@ -526,8 +526,7 @@ TEST(RunParam2_2) {
TEST(RunParam3) { TEST(RunParam3) {
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32, kMachInt32);
kMachineWord32);
Node* nodes[] = {m.Parameter(0), m.Parameter(1), m.Parameter(2)}; Node* nodes[] = {m.Parameter(0), m.Parameter(1), m.Parameter(2)};
m.Return(nodes[i]); m.Return(nodes[i]);
......
...@@ -91,11 +91,11 @@ class RawMachineAssemblerTester ...@@ -91,11 +91,11 @@ class RawMachineAssemblerTester
: public MachineAssemblerTester<RawMachineAssembler>, : public MachineAssemblerTester<RawMachineAssembler>,
public CallHelper2<ReturnType, RawMachineAssemblerTester<ReturnType> > { public CallHelper2<ReturnType, RawMachineAssemblerTester<ReturnType> > {
public: public:
RawMachineAssemblerTester(MachineType p0 = kMachineLast, RawMachineAssemblerTester(MachineType p0 = kMachNone,
MachineType p1 = kMachineLast, MachineType p1 = kMachNone,
MachineType p2 = kMachineLast, MachineType p2 = kMachNone,
MachineType p3 = kMachineLast, MachineType p3 = kMachNone,
MachineType p4 = kMachineLast) MachineType p4 = kMachNone)
: MachineAssemblerTester<RawMachineAssembler>( : MachineAssemblerTester<RawMachineAssembler>(
ReturnValueTraits<ReturnType>::Representation(), p0, p1, p2, p3, ReturnValueTraits<ReturnType>::Representation(), p0, p1, p2, p3,
p4) {} p4) {}
...@@ -127,11 +127,11 @@ class StructuredMachineAssemblerTester ...@@ -127,11 +127,11 @@ class StructuredMachineAssemblerTester
public CallHelper2<ReturnType, public CallHelper2<ReturnType,
StructuredMachineAssemblerTester<ReturnType> > { StructuredMachineAssemblerTester<ReturnType> > {
public: public:
StructuredMachineAssemblerTester(MachineType p0 = kMachineLast, StructuredMachineAssemblerTester(MachineType p0 = kMachNone,
MachineType p1 = kMachineLast, MachineType p1 = kMachNone,
MachineType p2 = kMachineLast, MachineType p2 = kMachNone,
MachineType p3 = kMachineLast, MachineType p3 = kMachNone,
MachineType p4 = kMachineLast) MachineType p4 = kMachNone)
: MachineAssemblerTester<StructuredMachineAssembler>( : MachineAssemblerTester<StructuredMachineAssembler>(
ReturnValueTraits<ReturnType>::Representation(), p0, p1, p2, p3, ReturnValueTraits<ReturnType>::Representation(), p0, p1, p2, p3,
p4) {} p4) {}
...@@ -201,15 +201,25 @@ class BinopTester { ...@@ -201,15 +201,25 @@ class BinopTester {
// A helper class for testing code sequences that take two int parameters and // A helper class for testing code sequences that take two int parameters and
// return an int value. // return an int value.
class Int32BinopTester class Int32BinopTester
: public BinopTester<int32_t, kMachineWord32, USE_RETURN_REGISTER> { : public BinopTester<int32_t, kMachInt32, USE_RETURN_REGISTER> {
public: public:
explicit Int32BinopTester(RawMachineAssemblerTester<int32_t>* tester) explicit Int32BinopTester(RawMachineAssemblerTester<int32_t>* tester)
: BinopTester<int32_t, kMachineWord32, USE_RETURN_REGISTER>(tester) {} : BinopTester<int32_t, kMachInt32, USE_RETURN_REGISTER>(tester) {}
};
// A helper class for testing code sequences that take two uint parameters and
// return an uint value.
class Uint32BinopTester
: public BinopTester<uint32_t, kMachUint32, USE_RETURN_REGISTER> {
public:
explicit Uint32BinopTester(RawMachineAssemblerTester<int32_t>* tester)
: BinopTester<uint32_t, kMachUint32, USE_RETURN_REGISTER>(tester) {}
int32_t call(uint32_t a0, uint32_t a1) { uint32_t call(uint32_t a0, uint32_t a1) {
p0 = static_cast<int32_t>(a0); p0 = a0;
p1 = static_cast<int32_t>(a1); p1 = a1;
return T->Call(); return static_cast<uint32_t>(T->Call());
} }
}; };
...@@ -218,10 +228,10 @@ class Int32BinopTester ...@@ -218,10 +228,10 @@ class Int32BinopTester
// return a double value. // return a double value.
// TODO(titzer): figure out how to return doubles correctly on ia32. // TODO(titzer): figure out how to return doubles correctly on ia32.
class Float64BinopTester class Float64BinopTester
: public BinopTester<double, kMachineFloat64, USE_RESULT_BUFFER> { : public BinopTester<double, kMachFloat64, USE_RESULT_BUFFER> {
public: public:
explicit Float64BinopTester(RawMachineAssemblerTester<int32_t>* tester) explicit Float64BinopTester(RawMachineAssemblerTester<int32_t>* tester)
: BinopTester<double, kMachineFloat64, USE_RESULT_BUFFER>(tester) {} : BinopTester<double, kMachFloat64, USE_RESULT_BUFFER>(tester) {}
}; };
...@@ -230,10 +240,10 @@ class Float64BinopTester ...@@ -230,10 +240,10 @@ class Float64BinopTester
// TODO(titzer): pick word size of pointers based on V8_TARGET. // TODO(titzer): pick word size of pointers based on V8_TARGET.
template <typename Type> template <typename Type>
class PointerBinopTester class PointerBinopTester
: public BinopTester<Type*, kMachineWord32, USE_RETURN_REGISTER> { : public BinopTester<Type*, kMachPtr, USE_RETURN_REGISTER> {
public: public:
explicit PointerBinopTester(RawMachineAssemblerTester<int32_t>* tester) explicit PointerBinopTester(RawMachineAssemblerTester<int32_t>* tester)
: BinopTester<Type*, kMachineWord32, USE_RETURN_REGISTER>(tester) {} : BinopTester<Type*, kMachPtr, USE_RETURN_REGISTER>(tester) {}
}; };
...@@ -241,10 +251,10 @@ class PointerBinopTester ...@@ -241,10 +251,10 @@ class PointerBinopTester
// return a tagged value. // return a tagged value.
template <typename Type> template <typename Type>
class TaggedBinopTester class TaggedBinopTester
: public BinopTester<Type*, kMachineTagged, USE_RETURN_REGISTER> { : public BinopTester<Type*, kMachAnyTagged, USE_RETURN_REGISTER> {
public: public:
explicit TaggedBinopTester(RawMachineAssemblerTester<int32_t>* tester) explicit TaggedBinopTester(RawMachineAssemblerTester<int32_t>* tester)
: BinopTester<Type*, kMachineTagged, USE_RETURN_REGISTER>(tester) {} : BinopTester<Type*, kMachAnyTagged, USE_RETURN_REGISTER>(tester) {}
}; };
// A helper class for testing compares. Wraps a machine opcode and provides // A helper class for testing compares. Wraps a machine opcode and provides
......
...@@ -87,11 +87,11 @@ class GraphBuilderTester ...@@ -87,11 +87,11 @@ class GraphBuilderTester
public SimplifiedGraphBuilder, public SimplifiedGraphBuilder,
public CallHelper2<ReturnType, GraphBuilderTester<ReturnType> > { public CallHelper2<ReturnType, GraphBuilderTester<ReturnType> > {
public: public:
explicit GraphBuilderTester(MachineType p0 = kMachineLast, explicit GraphBuilderTester(MachineType p0 = kMachNone,
MachineType p1 = kMachineLast, MachineType p1 = kMachNone,
MachineType p2 = kMachineLast, MachineType p2 = kMachNone,
MachineType p3 = kMachineLast, MachineType p3 = kMachNone,
MachineType p4 = kMachineLast) MachineType p4 = kMachNone)
: GraphAndBuilders(main_zone()), : GraphAndBuilders(main_zone()),
MachineCallHelper( MachineCallHelper(
main_zone(), main_zone(),
......
...@@ -30,16 +30,16 @@ class InstructionSelectorTester : public HandleAndZoneScope, ...@@ -30,16 +30,16 @@ class InstructionSelectorTester : public HandleAndZoneScope,
static MachineType* BuildParameterArray(Zone* zone) { static MachineType* BuildParameterArray(Zone* zone) {
MachineType* array = zone->NewArray<MachineType>(kParameterCount); MachineType* array = zone->NewArray<MachineType>(kParameterCount);
for (int i = 0; i < kParameterCount; ++i) { for (int i = 0; i < kParameterCount; ++i) {
array[i] = kMachineWord32; array[i] = kMachInt32;
} }
return array; return array;
} }
InstructionSelectorTester() InstructionSelectorTester()
: RawMachineAssembler( : RawMachineAssembler(
new (main_zone()) Graph(main_zone()), new (main_zone()) new (main_zone()) Graph(main_zone()),
MachineCallDescriptorBuilder(kMachineWord32, kParameterCount, new (main_zone()) MachineCallDescriptorBuilder(
BuildParameterArray(main_zone())), kMachInt32, kParameterCount, BuildParameterArray(main_zone())),
MachineOperatorBuilder::pointer_rep()) {} MachineOperatorBuilder::pointer_rep()) {}
void SelectInstructions(CpuFeature feature) { void SelectInstructions(CpuFeature feature) {
......
...@@ -23,7 +23,7 @@ static IrOpcode::Value int32cmp_opcodes[] = { ...@@ -23,7 +23,7 @@ static IrOpcode::Value int32cmp_opcodes[] = {
TEST(BranchCombineWord32EqualZero_1) { TEST(BranchCombineWord32EqualZero_1) {
// Test combining a branch with x == 0 // Test combining a branch with x == 0
RawMachineAssemblerTester<int32_t> m(kMachineWord32); RawMachineAssemblerTester<int32_t> m(kMachInt32);
int32_t eq_constant = -1033; int32_t eq_constant = -1033;
int32_t ne_constant = 825118; int32_t ne_constant = 825118;
Node* p0 = m.Parameter(0); Node* p0 = m.Parameter(0);
...@@ -49,7 +49,7 @@ TEST(BranchCombineWord32EqualZero_chain) { ...@@ -49,7 +49,7 @@ TEST(BranchCombineWord32EqualZero_chain) {
int32_t ne_constant = 815118; int32_t ne_constant = 815118;
for (int k = 0; k < 6; k++) { for (int k = 0; k < 6; k++) {
RawMachineAssemblerTester<int32_t> m(kMachineWord32); RawMachineAssemblerTester<int32_t> m(kMachInt32);
Node* p0 = m.Parameter(0); Node* p0 = m.Parameter(0);
MLabel blocka, blockb; MLabel blocka, blockb;
Node* cond = p0; Node* cond = p0;
...@@ -74,7 +74,7 @@ TEST(BranchCombineWord32EqualZero_chain) { ...@@ -74,7 +74,7 @@ TEST(BranchCombineWord32EqualZero_chain) {
TEST(BranchCombineInt32LessThanZero_1) { TEST(BranchCombineInt32LessThanZero_1) {
// Test combining a branch with x < 0 // Test combining a branch with x < 0
RawMachineAssemblerTester<int32_t> m(kMachineWord32); RawMachineAssemblerTester<int32_t> m(kMachInt32);
int32_t eq_constant = -1433; int32_t eq_constant = -1433;
int32_t ne_constant = 845118; int32_t ne_constant = 845118;
Node* p0 = m.Parameter(0); Node* p0 = m.Parameter(0);
...@@ -96,7 +96,7 @@ TEST(BranchCombineInt32LessThanZero_1) { ...@@ -96,7 +96,7 @@ TEST(BranchCombineInt32LessThanZero_1) {
TEST(BranchCombineUint32LessThan100_1) { TEST(BranchCombineUint32LessThan100_1) {
// Test combining a branch with x < 100 // Test combining a branch with x < 100
RawMachineAssemblerTester<int32_t> m(kMachineWord32); RawMachineAssemblerTester<int32_t> m(kMachUint32);
int32_t eq_constant = 1471; int32_t eq_constant = 1471;
int32_t ne_constant = 88845718; int32_t ne_constant = 88845718;
Node* p0 = m.Parameter(0); Node* p0 = m.Parameter(0);
...@@ -118,7 +118,7 @@ TEST(BranchCombineUint32LessThan100_1) { ...@@ -118,7 +118,7 @@ TEST(BranchCombineUint32LessThan100_1) {
TEST(BranchCombineUint32LessThanOrEqual100_1) { TEST(BranchCombineUint32LessThanOrEqual100_1) {
// Test combining a branch with x <= 100 // Test combining a branch with x <= 100
RawMachineAssemblerTester<int32_t> m(kMachineWord32); RawMachineAssemblerTester<int32_t> m(kMachUint32);
int32_t eq_constant = 1479; int32_t eq_constant = 1479;
int32_t ne_constant = 77845719; int32_t ne_constant = 77845719;
Node* p0 = m.Parameter(0); Node* p0 = m.Parameter(0);
...@@ -140,7 +140,7 @@ TEST(BranchCombineUint32LessThanOrEqual100_1) { ...@@ -140,7 +140,7 @@ TEST(BranchCombineUint32LessThanOrEqual100_1) {
TEST(BranchCombineZeroLessThanInt32_1) { TEST(BranchCombineZeroLessThanInt32_1) {
// Test combining a branch with 0 < x // Test combining a branch with 0 < x
RawMachineAssemblerTester<int32_t> m(kMachineWord32); RawMachineAssemblerTester<int32_t> m(kMachInt32);
int32_t eq_constant = -2033; int32_t eq_constant = -2033;
int32_t ne_constant = 225118; int32_t ne_constant = 225118;
Node* p0 = m.Parameter(0); Node* p0 = m.Parameter(0);
...@@ -162,7 +162,7 @@ TEST(BranchCombineZeroLessThanInt32_1) { ...@@ -162,7 +162,7 @@ TEST(BranchCombineZeroLessThanInt32_1) {
TEST(BranchCombineInt32GreaterThanZero_1) { TEST(BranchCombineInt32GreaterThanZero_1) {
// Test combining a branch with x > 0 // Test combining a branch with x > 0
RawMachineAssemblerTester<int32_t> m(kMachineWord32); RawMachineAssemblerTester<int32_t> m(kMachInt32);
int32_t eq_constant = -1073; int32_t eq_constant = -1073;
int32_t ne_constant = 825178; int32_t ne_constant = 825178;
Node* p0 = m.Parameter(0); Node* p0 = m.Parameter(0);
...@@ -184,7 +184,7 @@ TEST(BranchCombineInt32GreaterThanZero_1) { ...@@ -184,7 +184,7 @@ TEST(BranchCombineInt32GreaterThanZero_1) {
TEST(BranchCombineWord32EqualP) { TEST(BranchCombineWord32EqualP) {
// Test combining a branch with an Word32Equal. // Test combining a branch with an Word32Equal.
RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32);
int32_t eq_constant = -1035; int32_t eq_constant = -1035;
int32_t ne_constant = 825018; int32_t ne_constant = 825018;
Node* p0 = m.Parameter(0); Node* p0 = m.Parameter(0);
...@@ -214,7 +214,7 @@ TEST(BranchCombineWord32EqualI) { ...@@ -214,7 +214,7 @@ TEST(BranchCombineWord32EqualI) {
for (int left = 0; left < 2; left++) { for (int left = 0; left < 2; left++) {
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
RawMachineAssemblerTester<int32_t> m(kMachineWord32); RawMachineAssemblerTester<int32_t> m(kMachInt32);
int32_t a = *i; int32_t a = *i;
Node* p0 = m.Int32Constant(a); Node* p0 = m.Int32Constant(a);
...@@ -243,7 +243,7 @@ TEST(BranchCombineInt32CmpP) { ...@@ -243,7 +243,7 @@ TEST(BranchCombineInt32CmpP) {
int32_t ne_constant = 725018; int32_t ne_constant = 725018;
for (int op = 0; op < 2; op++) { for (int op = 0; op < 2; op++) {
RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32);
Node* p0 = m.Parameter(0); Node* p0 = m.Parameter(0);
Node* p1 = m.Parameter(1); Node* p1 = m.Parameter(1);
...@@ -275,7 +275,7 @@ TEST(BranchCombineInt32CmpI) { ...@@ -275,7 +275,7 @@ TEST(BranchCombineInt32CmpI) {
for (int op = 0; op < 2; op++) { for (int op = 0; op < 2; op++) {
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
RawMachineAssemblerTester<int32_t> m(kMachineWord32); RawMachineAssemblerTester<int32_t> m(kMachInt32);
int32_t a = *i; int32_t a = *i;
Node* p0 = m.Int32Constant(a); Node* p0 = m.Int32Constant(a);
Node* p1 = m.Parameter(0); Node* p1 = m.Parameter(0);
...@@ -432,8 +432,8 @@ TEST(BranchCombineFloat64Compares) { ...@@ -432,8 +432,8 @@ TEST(BranchCombineFloat64Compares) {
CompareWrapper cmp = cmps[c]; CompareWrapper cmp = cmps[c];
for (int invert = 0; invert < 2; invert++) { for (int invert = 0; invert < 2; invert++) {
RawMachineAssemblerTester<int32_t> m; RawMachineAssemblerTester<int32_t> m;
Node* a = m.LoadFromPointer(&input_a, kMachineFloat64); Node* a = m.LoadFromPointer(&input_a, kMachFloat64);
Node* b = m.LoadFromPointer(&input_b, kMachineFloat64); Node* b = m.LoadFromPointer(&input_b, kMachFloat64);
MLabel blocka, blockb; MLabel blocka, blockb;
Node* cond = cmp.MakeNode(&m, a, b); Node* cond = cmp.MakeNode(&m, a, b);
......
...@@ -27,7 +27,7 @@ using namespace v8::internal::compiler; ...@@ -27,7 +27,7 @@ using namespace v8::internal::compiler;
template <typename ReturnType> template <typename ReturnType>
class ChangesLoweringTester : public GraphBuilderTester<ReturnType> { class ChangesLoweringTester : public GraphBuilderTester<ReturnType> {
public: public:
explicit ChangesLoweringTester(MachineType p0 = kMachineLast) explicit ChangesLoweringTester(MachineType p0 = kMachNone)
: GraphBuilderTester<ReturnType>(p0), : GraphBuilderTester<ReturnType>(p0),
typer(this->zone()), typer(this->zone()),
source_positions(this->graph()), source_positions(this->graph()),
...@@ -77,22 +77,22 @@ class ChangesLoweringTester : public GraphBuilderTester<ReturnType> { ...@@ -77,22 +77,22 @@ class ChangesLoweringTester : public GraphBuilderTester<ReturnType> {
void StoreFloat64(Node* node, double* ptr) { void StoreFloat64(Node* node, double* ptr) {
Node* ptr_node = this->PointerConstant(ptr); Node* ptr_node = this->PointerConstant(ptr);
this->Store(kMachineFloat64, ptr_node, node); this->Store(kMachFloat64, ptr_node, node);
} }
Node* LoadInt32(int32_t* ptr) { Node* LoadInt32(int32_t* ptr) {
Node* ptr_node = this->PointerConstant(ptr); Node* ptr_node = this->PointerConstant(ptr);
return this->Load(kMachineWord32, ptr_node); return this->Load(kMachInt32, ptr_node);
} }
Node* LoadUint32(uint32_t* ptr) { Node* LoadUint32(uint32_t* ptr) {
Node* ptr_node = this->PointerConstant(ptr); Node* ptr_node = this->PointerConstant(ptr);
return this->Load(kMachineWord32, ptr_node); return this->Load(kMachUint32, ptr_node);
} }
Node* LoadFloat64(double* ptr) { Node* LoadFloat64(double* ptr) {
Node* ptr_node = this->PointerConstant(ptr); Node* ptr_node = this->PointerConstant(ptr);
return this->Load(kMachineFloat64, ptr_node); return this->Load(kMachFloat64, ptr_node);
} }
void CheckNumber(double expected, Object* number) { void CheckNumber(double expected, Object* number) {
...@@ -150,7 +150,7 @@ class ChangesLoweringTester : public GraphBuilderTester<ReturnType> { ...@@ -150,7 +150,7 @@ class ChangesLoweringTester : public GraphBuilderTester<ReturnType> {
TEST(RunChangeTaggedToInt32) { TEST(RunChangeTaggedToInt32) {
// Build and lower a graph by hand. // Build and lower a graph by hand.
ChangesLoweringTester<int32_t> t(kMachineTagged); ChangesLoweringTester<int32_t> t(kMachAnyTagged);
t.BuildAndLower(t.simplified()->ChangeTaggedToInt32()); t.BuildAndLower(t.simplified()->ChangeTaggedToInt32());
if (Pipeline::SupportedTarget()) { if (Pipeline::SupportedTarget()) {
...@@ -180,7 +180,7 @@ TEST(RunChangeTaggedToInt32) { ...@@ -180,7 +180,7 @@ TEST(RunChangeTaggedToInt32) {
TEST(RunChangeTaggedToUint32) { TEST(RunChangeTaggedToUint32) {
// Build and lower a graph by hand. // Build and lower a graph by hand.
ChangesLoweringTester<uint32_t> t(kMachineTagged); ChangesLoweringTester<uint32_t> t(kMachAnyTagged);
t.BuildAndLower(t.simplified()->ChangeTaggedToUint32()); t.BuildAndLower(t.simplified()->ChangeTaggedToUint32());
if (Pipeline::SupportedTarget()) { if (Pipeline::SupportedTarget()) {
...@@ -209,11 +209,11 @@ TEST(RunChangeTaggedToUint32) { ...@@ -209,11 +209,11 @@ TEST(RunChangeTaggedToUint32) {
TEST(RunChangeTaggedToFloat64) { TEST(RunChangeTaggedToFloat64) {
ChangesLoweringTester<int32_t> t(kMachineTagged); ChangesLoweringTester<int32_t> t(kMachAnyTagged);
double result; double result;
t.BuildStoreAndLower(t.simplified()->ChangeTaggedToFloat64(), t.BuildStoreAndLower(t.simplified()->ChangeTaggedToFloat64(),
t.machine()->Store(kMachineFloat64, kNoWriteBarrier), t.machine()->Store(kMachFloat64, kNoWriteBarrier),
&result); &result);
if (Pipeline::SupportedTarget()) { if (Pipeline::SupportedTarget()) {
...@@ -259,7 +259,7 @@ TEST(RunChangeTaggedToFloat64) { ...@@ -259,7 +259,7 @@ TEST(RunChangeTaggedToFloat64) {
TEST(RunChangeBoolToBit) { TEST(RunChangeBoolToBit) {
ChangesLoweringTester<int32_t> t(kMachineTagged); ChangesLoweringTester<int32_t> t(kMachAnyTagged);
t.BuildAndLower(t.simplified()->ChangeBoolToBit()); t.BuildAndLower(t.simplified()->ChangeBoolToBit());
if (Pipeline::SupportedTarget()) { if (Pipeline::SupportedTarget()) {
...@@ -277,7 +277,7 @@ TEST(RunChangeBoolToBit) { ...@@ -277,7 +277,7 @@ TEST(RunChangeBoolToBit) {
TEST(RunChangeBitToBool) { TEST(RunChangeBitToBool) {
ChangesLoweringTester<Object*> t(kMachineWord32); ChangesLoweringTester<Object*> t(kMachInt32);
t.BuildAndLower(t.simplified()->ChangeBitToBool()); t.BuildAndLower(t.simplified()->ChangeBitToBool());
if (Pipeline::SupportedTarget()) { if (Pipeline::SupportedTarget()) {
...@@ -312,7 +312,7 @@ TEST(RunChangeInt32ToTagged) { ...@@ -312,7 +312,7 @@ TEST(RunChangeInt32ToTagged) {
ChangesLoweringTester<Object*> t; ChangesLoweringTester<Object*> t;
int32_t input; int32_t input;
t.BuildLoadAndLower(t.simplified()->ChangeInt32ToTagged(), t.BuildLoadAndLower(t.simplified()->ChangeInt32ToTagged(),
t.machine()->Load(kMachineWord32), &input); t.machine()->Load(kMachInt32), &input);
if (Pipeline::SupportedTarget()) { if (Pipeline::SupportedTarget()) {
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
...@@ -341,7 +341,7 @@ TEST(RunChangeUint32ToTagged) { ...@@ -341,7 +341,7 @@ TEST(RunChangeUint32ToTagged) {
ChangesLoweringTester<Object*> t; ChangesLoweringTester<Object*> t;
uint32_t input; uint32_t input;
t.BuildLoadAndLower(t.simplified()->ChangeUint32ToTagged(), t.BuildLoadAndLower(t.simplified()->ChangeUint32ToTagged(),
t.machine()->Load(kMachineWord32), &input); t.machine()->Load(kMachUint32), &input);
if (Pipeline::SupportedTarget()) { if (Pipeline::SupportedTarget()) {
FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(i) {
...@@ -375,7 +375,7 @@ TEST(RunChangeFloat64ToTagged) { ...@@ -375,7 +375,7 @@ TEST(RunChangeFloat64ToTagged) {
ChangesLoweringTester<Object*> t; ChangesLoweringTester<Object*> t;
double input; double input;
t.BuildLoadAndLower(t.simplified()->ChangeFloat64ToTagged(), t.BuildLoadAndLower(t.simplified()->ChangeFloat64ToTagged(),
t.machine()->Load(kMachineFloat64), &input); t.machine()->Load(kMachFloat64), &input);
// TODO(titzer): need inline allocation to change float to tagged. // TODO(titzer): need inline allocation to change float to tagged.
if (TODO_FLOAT64_TO_TAGGED && Pipeline::SupportedTarget()) { if (TODO_FLOAT64_TO_TAGGED && Pipeline::SupportedTarget()) {
......
...@@ -120,8 +120,8 @@ class TrivialDeoptCodegenTester : public DeoptCodegenTester { ...@@ -120,8 +120,8 @@ class TrivialDeoptCodegenTester : public DeoptCodegenTester {
// deopt(); // deopt();
// } // }
MachineType parameter_reps[] = {kMachineTagged}; MachineType parameter_reps[] = {kMachAnyTagged};
MachineCallDescriptorBuilder descriptor_builder(kMachineTagged, 1, MachineCallDescriptorBuilder descriptor_builder(kMachAnyTagged, 1,
parameter_reps); parameter_reps);
RawMachineAssembler m(graph, &descriptor_builder); RawMachineAssembler m(graph, &descriptor_builder);
...@@ -256,8 +256,8 @@ class TrivialRuntimeDeoptCodegenTester : public DeoptCodegenTester { ...@@ -256,8 +256,8 @@ class TrivialRuntimeDeoptCodegenTester : public DeoptCodegenTester {
// %DeoptimizeFunction(foo); // %DeoptimizeFunction(foo);
// } // }
MachineType parameter_reps[] = {kMachineTagged}; MachineType parameter_reps[] = {kMachAnyTagged};
MachineCallDescriptorBuilder descriptor_builder(kMachineTagged, 2, MachineCallDescriptorBuilder descriptor_builder(kMachAnyTagged, 2,
parameter_reps); parameter_reps);
RawMachineAssembler m(graph, &descriptor_builder); RawMachineAssembler m(graph, &descriptor_builder);
......
...@@ -32,7 +32,7 @@ class InstructionTester : public HandleAndZoneScope { ...@@ -32,7 +32,7 @@ class InstructionTester : public HandleAndZoneScope {
info(static_cast<HydrogenCodeStub*>(NULL), main_isolate()), info(static_cast<HydrogenCodeStub*>(NULL), main_isolate()),
linkage(&info), linkage(&info),
common(zone()), common(zone()),
machine(zone(), kMachineWord32), machine(zone()),
code(NULL) {} code(NULL) {}
~InstructionTester() { delete code; } ~InstructionTester() { delete code; }
......
...@@ -630,7 +630,7 @@ TEST(ReduceLoadStore) { ...@@ -630,7 +630,7 @@ TEST(ReduceLoadStore) {
Node* base = R.Constant<int32_t>(11); Node* base = R.Constant<int32_t>(11);
Node* index = R.Constant<int32_t>(4); Node* index = R.Constant<int32_t>(4);
Node* load = R.graph.NewNode(R.machine.Load(kMachineWord32), base, index); Node* load = R.graph.NewNode(R.machine.Load(kMachInt32), base, index);
{ {
MachineOperatorReducer reducer(&R.graph); MachineOperatorReducer reducer(&R.graph);
...@@ -639,8 +639,8 @@ TEST(ReduceLoadStore) { ...@@ -639,8 +639,8 @@ TEST(ReduceLoadStore) {
} }
{ {
Node* store = R.graph.NewNode( Node* store = R.graph.NewNode(R.machine.Store(kMachInt32, kNoWriteBarrier),
R.machine.Store(kMachineWord32, kNoWriteBarrier), base, index, load); base, index, load);
MachineOperatorReducer reducer(&R.graph); MachineOperatorReducer reducer(&R.graph);
Reduction reduction = reducer.Reduce(store); Reduction reduction = reducer.Reduce(store);
CHECK(!reduction.Changed()); // stores should not be reduced. CHECK(!reduction.Changed()); // stores should not be reduced.
......
This diff is collapsed.
...@@ -145,7 +145,7 @@ TEST(BuildMulNodeGraph) { ...@@ -145,7 +145,7 @@ TEST(BuildMulNodeGraph) {
Schedule schedule(scope.main_zone()); Schedule schedule(scope.main_zone());
Graph graph(scope.main_zone()); Graph graph(scope.main_zone());
CommonOperatorBuilder common(scope.main_zone()); CommonOperatorBuilder common(scope.main_zone());
MachineOperatorBuilder machine(scope.main_zone(), kMachineWord32); MachineOperatorBuilder machine(scope.main_zone());
Node* start = graph.NewNode(common.Start(0)); Node* start = graph.NewNode(common.Start(0));
graph.SetStart(start); graph.SetStart(start);
......
...@@ -1536,7 +1536,7 @@ TEST(BuildScheduleSimpleLoopWithCodeMotion) { ...@@ -1536,7 +1536,7 @@ TEST(BuildScheduleSimpleLoopWithCodeMotion) {
Graph graph(scope.main_zone()); Graph graph(scope.main_zone());
CommonOperatorBuilder common_builder(scope.main_zone()); CommonOperatorBuilder common_builder(scope.main_zone());
JSOperatorBuilder js_builder(scope.main_zone()); JSOperatorBuilder js_builder(scope.main_zone());
MachineOperatorBuilder machine_builder(scope.main_zone(), kMachineWord32); MachineOperatorBuilder machine_builder(scope.main_zone());
Operator* op; Operator* op;
Handle<Object> object = Handle<Object> object =
......
...@@ -424,9 +424,9 @@ class IfBuilderGenerator : public StructuredMachineAssemblerTester<int32_t> { ...@@ -424,9 +424,9 @@ class IfBuilderGenerator : public StructuredMachineAssemblerTester<int32_t> {
m_.IfNode(); m_.IfNode();
{ {
Node* offset = Int32Constant(offset_ * 4); Node* offset = Int32Constant(offset_ * 4);
Store(kMachineWord32, Parameter(1), offset, var_.Get()); Store(kMachInt32, Parameter(1), offset, var_.Get());
var_.Set(Int32Add(var_.Get(), Int32Constant(kIfInc))); var_.Set(Int32Add(var_.Get(), Int32Constant(kIfInc)));
c_.If(Load(kMachineWord32, Parameter(0), offset)); c_.If(Load(kMachInt32, Parameter(0), offset));
offset_++; offset_++;
} }
break; break;
......
...@@ -128,7 +128,6 @@ class ValueHelper { ...@@ -128,7 +128,6 @@ class ValueHelper {
#define FOR_UINT32_SHIFTS(var) for (uint32_t var = 0; var < 32; var++) #define FOR_UINT32_SHIFTS(var) for (uint32_t var = 0; var < 32; var++)
} // namespace compiler } // namespace compiler
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
......
...@@ -77,7 +77,7 @@ static const DPI kMulDivInstructions[] = { ...@@ -77,7 +77,7 @@ static const DPI kMulDivInstructions[] = {
// TODO(all): Use TEST_P, see instruction-selector-arm-unittest.cc. // TODO(all): Use TEST_P, see instruction-selector-arm-unittest.cc.
TEST_F(InstructionSelectorTest, LogicalWithParameter) { TEST_F(InstructionSelectorTest, LogicalWithParameter) {
TRACED_FOREACH(DPI, dpi, kLogicalInstructions) { TRACED_FOREACH(DPI, dpi, kLogicalInstructions) {
StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
m.Return((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1))); m.Return((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)));
Stream s = m.Build(); Stream s = m.Build();
ASSERT_EQ(1U, s.size()); ASSERT_EQ(1U, s.size());
...@@ -89,7 +89,7 @@ TEST_F(InstructionSelectorTest, LogicalWithParameter) { ...@@ -89,7 +89,7 @@ TEST_F(InstructionSelectorTest, LogicalWithParameter) {
// TODO(all): Use TEST_P, see instruction-selector-arm-unittest.cc. // TODO(all): Use TEST_P, see instruction-selector-arm-unittest.cc.
TEST_F(InstructionSelectorTest, AddSubWithParameter) { TEST_F(InstructionSelectorTest, AddSubWithParameter) {
TRACED_FOREACH(DPI, dpi, kAddSubInstructions) { TRACED_FOREACH(DPI, dpi, kAddSubInstructions) {
StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
m.Return((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1))); m.Return((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)));
Stream s = m.Build(); Stream s = m.Build();
ASSERT_EQ(1U, s.size()); ASSERT_EQ(1U, s.size());
...@@ -106,7 +106,7 @@ TEST_F(InstructionSelectorTest, AddSubWithImmediate) { ...@@ -106,7 +106,7 @@ TEST_F(InstructionSelectorTest, AddSubWithImmediate) {
j != immediates.end(); ++j) { j != immediates.end(); ++j) {
int32_t imm = *j; int32_t imm = *j;
SCOPED_TRACE(::testing::Message() << "imm = " << imm); SCOPED_TRACE(::testing::Message() << "imm = " << imm);
StreamBuilder m(this, kMachineWord32, kMachineWord32); StreamBuilder m(this, kMachInt32, kMachInt32);
m.Return((m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm))); m.Return((m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm)));
Stream s = m.Build(); Stream s = m.Build();
ASSERT_EQ(1U, s.size()); ASSERT_EQ(1U, s.size());
...@@ -120,7 +120,7 @@ TEST_F(InstructionSelectorTest, AddSubWithImmediate) { ...@@ -120,7 +120,7 @@ TEST_F(InstructionSelectorTest, AddSubWithImmediate) {
// TODO(all): Use TEST_P, see instruction-selector-arm-unittest.cc. // TODO(all): Use TEST_P, see instruction-selector-arm-unittest.cc.
TEST_F(InstructionSelectorTest, MulDivWithParameter) { TEST_F(InstructionSelectorTest, MulDivWithParameter) {
TRACED_FOREACH(DPI, dpi, kMulDivInstructions) { TRACED_FOREACH(DPI, dpi, kMulDivInstructions) {
StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
m.Return((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1))); m.Return((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)));
Stream s = m.Build(); Stream s = m.Build();
ASSERT_EQ(1U, s.size()); ASSERT_EQ(1U, s.size());
......
...@@ -136,7 +136,7 @@ TARGET_TEST_F(ChangeLowering32Test, ChangeInt32ToTagged) { ...@@ -136,7 +136,7 @@ TARGET_TEST_F(ChangeLowering32Test, ChangeInt32ToTagged) {
const int32_t kValueOffset = HeapNumber::kValueOffset - kHeapObjectTag; const int32_t kValueOffset = HeapNumber::kValueOffset - kHeapObjectTag;
EXPECT_THAT(NodeProperties::GetControlInput(merge, 0), EXPECT_THAT(NodeProperties::GetControlInput(merge, 0),
IsStore(kMachineFloat64, kNoWriteBarrier, heap_number, IsStore(kMachFloat64, kNoWriteBarrier, heap_number,
IsInt32Constant(kValueOffset), IsInt32Constant(kValueOffset),
IsChangeInt32ToFloat64(val), _, heap_number)); IsChangeInt32ToFloat64(val), _, heap_number));
...@@ -164,11 +164,11 @@ TARGET_TEST_F(ChangeLowering32Test, ChangeTaggedToFloat64) { ...@@ -164,11 +164,11 @@ TARGET_TEST_F(ChangeLowering32Test, ChangeTaggedToFloat64) {
kSmiTagSize + SmiTagging<kPointerSize>::kSmiShiftSize; kSmiTagSize + SmiTagging<kPointerSize>::kSmiShiftSize;
const int32_t kValueOffset = HeapNumber::kValueOffset - kHeapObjectTag; const int32_t kValueOffset = HeapNumber::kValueOffset - kHeapObjectTag;
Node* phi = reduction.replacement(); Node* phi = reduction.replacement();
ASSERT_THAT( ASSERT_THAT(phi,
phi, IsPhi(IsLoad(kMachineFloat64, val, IsInt32Constant(kValueOffset), _), IsPhi(IsLoad(kMachFloat64, val, IsInt32Constant(kValueOffset), _),
IsChangeInt32ToFloat64( IsChangeInt32ToFloat64(
IsWord32Sar(val, IsInt32Constant(kShiftAmount))), IsWord32Sar(val, IsInt32Constant(kShiftAmount))),
_)); _));
Node* merge = NodeProperties::GetControlInput(phi); Node* merge = NodeProperties::GetControlInput(phi);
ASSERT_EQ(IrOpcode::kMerge, merge->opcode()); ASSERT_EQ(IrOpcode::kMerge, merge->opcode());
...@@ -228,11 +228,11 @@ TARGET_TEST_F(ChangeLowering64Test, ChangeTaggedToFloat64) { ...@@ -228,11 +228,11 @@ TARGET_TEST_F(ChangeLowering64Test, ChangeTaggedToFloat64) {
kSmiTagSize + SmiTagging<kPointerSize>::kSmiShiftSize; kSmiTagSize + SmiTagging<kPointerSize>::kSmiShiftSize;
const int32_t kValueOffset = HeapNumber::kValueOffset - kHeapObjectTag; const int32_t kValueOffset = HeapNumber::kValueOffset - kHeapObjectTag;
Node* phi = reduction.replacement(); Node* phi = reduction.replacement();
ASSERT_THAT( ASSERT_THAT(phi,
phi, IsPhi(IsLoad(kMachineFloat64, val, IsInt32Constant(kValueOffset), _), IsPhi(IsLoad(kMachFloat64, val, IsInt32Constant(kValueOffset), _),
IsChangeInt32ToFloat64(IsConvertInt64ToInt32( IsChangeInt32ToFloat64(IsConvertInt64ToInt32(
IsWord64Sar(val, IsInt32Constant(kShiftAmount)))), IsWord64Sar(val, IsInt32Constant(kShiftAmount)))),
_)); _));
Node* merge = NodeProperties::GetControlInput(phi); Node* merge = NodeProperties::GetControlInput(phi);
ASSERT_EQ(IrOpcode::kMerge, merge->opcode()); ASSERT_EQ(IrOpcode::kMerge, merge->opcode());
......
...@@ -72,7 +72,7 @@ InstructionSelectorTest::Stream InstructionSelectorTest::StreamBuilder::Build( ...@@ -72,7 +72,7 @@ InstructionSelectorTest::Stream InstructionSelectorTest::StreamBuilder::Build(
TARGET_TEST_F(InstructionSelectorTest, ReturnParameter) { TARGET_TEST_F(InstructionSelectorTest, ReturnParameter) {
StreamBuilder m(this, kMachineWord32, kMachineWord32); StreamBuilder m(this, kMachInt32, kMachInt32);
m.Return(m.Parameter(0)); m.Return(m.Parameter(0));
Stream s = m.Build(kAllInstructions); Stream s = m.Build(kAllInstructions);
ASSERT_EQ(2U, s.size()); ASSERT_EQ(2U, s.size());
...@@ -84,7 +84,7 @@ TARGET_TEST_F(InstructionSelectorTest, ReturnParameter) { ...@@ -84,7 +84,7 @@ TARGET_TEST_F(InstructionSelectorTest, ReturnParameter) {
TARGET_TEST_F(InstructionSelectorTest, ReturnZero) { TARGET_TEST_F(InstructionSelectorTest, ReturnZero) {
StreamBuilder m(this, kMachineWord32); StreamBuilder m(this, kMachInt32);
m.Return(m.Int32Constant(0)); m.Return(m.Int32Constant(0));
Stream s = m.Build(kAllInstructions); Stream s = m.Build(kAllInstructions);
ASSERT_EQ(2U, s.size()); ASSERT_EQ(2U, s.size());
......
This diff is collapsed.
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