Commit 6fa2cee2 authored by titzer@chromium.org's avatar titzer@chromium.org

Move MachineRepresentation to machine-type.h and rename to MachineType in...

Move MachineRepresentation to machine-type.h and rename to MachineType in preparation for merging it with RepType.

R=bmeurer@chromium.org
BUG=

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23051 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 2097fa59
......@@ -305,7 +305,7 @@ static void VisitBinop(InstructionSelector* selector, Node* node,
void InstructionSelector::VisitLoad(Node* node) {
MachineRepresentation rep = OpParameter<MachineRepresentation>(node);
MachineType rep = OpParameter<MachineType>(node);
ArmOperandGenerator g(this);
Node* base = node->InputAt(0);
Node* index = node->InputAt(1);
......@@ -354,7 +354,7 @@ void InstructionSelector::VisitStore(Node* node) {
Node* value = node->InputAt(2);
StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node);
MachineRepresentation rep = store_rep.rep;
MachineType rep = store_rep.rep;
if (store_rep.write_barrier_kind == kFullWriteBarrier) {
DCHECK(rep == kMachineTagged);
// TODO(dcarney): refactor RecordWrite function to take temp registers
......
......@@ -57,8 +57,8 @@ CallDescriptor* Linkage::GetStubCallDescriptor(
CallDescriptor* Linkage::GetSimplifiedCDescriptor(
Zone* zone, int num_params, MachineRepresentation return_type,
const MachineRepresentation* param_types) {
Zone* zone, int num_params, MachineType return_type,
const MachineType* param_types) {
return LinkageHelper::GetSimplifiedCDescriptor<LinkageHelperTraits>(
zone, num_params, return_type, param_types);
}
......
......@@ -150,7 +150,7 @@ static void VisitBinop(InstructionSelector* selector, Node* node,
void InstructionSelector::VisitLoad(Node* node) {
MachineRepresentation rep = OpParameter<MachineRepresentation>(node);
MachineType rep = OpParameter<MachineType>(node);
Arm64OperandGenerator g(this);
Node* base = node->InputAt(0);
Node* index = node->InputAt(1);
......@@ -201,7 +201,7 @@ void InstructionSelector::VisitStore(Node* node) {
Node* value = node->InputAt(2);
StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node);
MachineRepresentation rep = store_rep.rep;
MachineType rep = store_rep.rep;
if (store_rep.write_barrier_kind == kFullWriteBarrier) {
DCHECK(rep == kMachineTagged);
// TODO(dcarney): refactor RecordWrite function to take temp registers
......
......@@ -57,8 +57,8 @@ CallDescriptor* Linkage::GetStubCallDescriptor(
CallDescriptor* Linkage::GetSimplifiedCDescriptor(
Zone* zone, int num_params, MachineRepresentation return_type,
const MachineRepresentation* param_types) {
Zone* zone, int num_params, MachineType return_type,
const MachineType* param_types) {
return LinkageHelper::GetSimplifiedCDescriptor<LinkageHelperTraits>(
zone, num_params, return_type, param_types);
}
......
......@@ -41,7 +41,7 @@ class IA32OperandGenerator V8_FINAL : public OperandGenerator {
void InstructionSelector::VisitLoad(Node* node) {
MachineRepresentation rep = OpParameter<MachineRepresentation>(node);
MachineType rep = OpParameter<MachineType>(node);
IA32OperandGenerator g(this);
Node* base = node->InputAt(0);
Node* index = node->InputAt(1);
......@@ -94,7 +94,7 @@ void InstructionSelector::VisitStore(Node* node) {
Node* value = node->InputAt(2);
StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node);
MachineRepresentation rep = store_rep.rep;
MachineType rep = store_rep.rep;
if (store_rep.write_barrier_kind == kFullWriteBarrier) {
DCHECK_EQ(kMachineTagged, rep);
// TODO(dcarney): refactor RecordWrite function to take temp registers
......
......@@ -53,8 +53,8 @@ CallDescriptor* Linkage::GetStubCallDescriptor(
CallDescriptor* Linkage::GetSimplifiedCDescriptor(
Zone* zone, int num_params, MachineRepresentation return_type,
const MachineRepresentation* param_types) {
Zone* zone, int num_params, MachineType return_type,
const MachineType* param_types) {
return LinkageHelper::GetSimplifiedCDescriptor<LinkageHelperTraits>(
zone, num_params, return_type, param_types);
}
......
......@@ -230,8 +230,7 @@ void InstructionSelector::MarkAsReference(Node* node) {
}
void InstructionSelector::MarkAsRepresentation(MachineRepresentation rep,
Node* node) {
void InstructionSelector::MarkAsRepresentation(MachineType rep, Node* node) {
DCHECK_NOT_NULL(node);
if (rep == kMachineFloat64) MarkAsDouble(node);
if (rep == kMachineTagged) MarkAsReference(node);
......@@ -467,10 +466,10 @@ void InstructionSelector::VisitNode(Node* node) {
return;
case IrOpcode::kParameter: {
int index = OpParameter<int>(node);
MachineRepresentation rep = linkage()
->GetIncomingDescriptor()
->GetInputLocation(index)
.representation();
MachineType rep = linkage()
->GetIncomingDescriptor()
->GetInputLocation(index)
.representation();
MarkAsRepresentation(rep, node);
return VisitParameter(node);
}
......@@ -494,7 +493,7 @@ void InstructionSelector::VisitNode(Node* node) {
case IrOpcode::kStateValues:
return;
case IrOpcode::kLoad: {
MachineRepresentation load_rep = OpParameter<MachineRepresentation>(node);
MachineType load_rep = OpParameter<MachineType>(node);
MarkAsRepresentation(load_rep, node);
return VisitLoad(node);
}
......
......@@ -130,7 +130,7 @@ class InstructionSelector V8_FINAL {
// Inform the register allocation of the representation of the value produced
// by {node}.
void MarkAsRepresentation(MachineRepresentation rep, Node* node);
void MarkAsRepresentation(MachineType rep, Node* node);
// Initialize the call buffer with the InstructionOperands, nodes, etc,
// corresponding
......
......@@ -25,7 +25,7 @@ class LinkageHelper {
Register::ToAllocationIndex(reg));
}
static LinkageLocation UnconstrainedRegister(MachineRepresentation rep) {
static LinkageLocation UnconstrainedRegister(MachineType rep) {
return LinkageLocation(rep, LinkageLocation::ANY_REGISTER);
}
......@@ -173,8 +173,8 @@ class LinkageHelper {
template <typename LinkageTraits>
static CallDescriptor* GetSimplifiedCDescriptor(
Zone* zone, int num_params, MachineRepresentation return_type,
const MachineRepresentation* param_types) {
Zone* zone, int num_params, MachineType return_type,
const MachineType* param_types) {
LinkageLocation* locations =
zone->NewArray<LinkageLocation>(num_params + 2);
int index = 0;
......
......@@ -138,8 +138,8 @@ CallDescriptor* Linkage::GetStubCallDescriptor(
CallDescriptor* Linkage::GetSimplifiedCDescriptor(
Zone* zone, int num_params, MachineRepresentation return_type,
const MachineRepresentation* param_types) {
Zone* zone, int num_params, MachineType return_type,
const MachineType* param_types) {
UNIMPLEMENTED();
return NULL;
}
......
......@@ -22,17 +22,17 @@ namespace compiler {
// TODO(titzer): replace with Radium locations when they are ready.
class LinkageLocation {
public:
LinkageLocation(MachineRepresentation rep, int location)
LinkageLocation(MachineType rep, int location)
: rep_(rep), location_(location) {}
inline MachineRepresentation representation() const { return rep_; }
inline MachineType representation() const { return rep_; }
static const int16_t ANY_REGISTER = 32767;
private:
friend class CallDescriptor;
friend class OperandGenerator;
MachineRepresentation rep_;
MachineType rep_;
int16_t location_; // >= 0 implies register, otherwise stack slot.
};
......@@ -160,8 +160,8 @@ class Linkage : public ZoneObject {
// integers and pointers of one word size each, i.e. no floating point,
// structs, pointers to members, etc.
static CallDescriptor* GetSimplifiedCDescriptor(
Zone* zone, int num_params, MachineRepresentation return_type,
const MachineRepresentation* param_types);
Zone* zone, int num_params, MachineType return_type,
const MachineType* param_types);
// Get the location of an (incoming) parameter to this function.
LinkageLocation GetParameterLocation(int index) {
......
......@@ -22,17 +22,14 @@ namespace compiler {
class MachineCallDescriptorBuilder : public ZoneObject {
public:
MachineCallDescriptorBuilder(MachineRepresentation return_type,
int parameter_count,
const MachineRepresentation* parameter_types)
MachineCallDescriptorBuilder(MachineType return_type, int parameter_count,
const MachineType* parameter_types)
: return_type_(return_type),
parameter_count_(parameter_count),
parameter_types_(parameter_types) {}
int parameter_count() const { return parameter_count_; }
const MachineRepresentation* parameter_types() const {
return parameter_types_;
}
const MachineType* parameter_types() const { return parameter_types_; }
CallDescriptor* BuildCallDescriptor(Zone* zone) {
return Linkage::GetSimplifiedCDescriptor(zone, parameter_count_,
......@@ -40,9 +37,9 @@ class MachineCallDescriptorBuilder : public ZoneObject {
}
private:
const MachineRepresentation return_type_;
const MachineType return_type_;
const int parameter_count_;
const MachineRepresentation* const parameter_types_;
const MachineType* const parameter_types_;
};
......@@ -90,16 +87,16 @@ class MachineNodeFactory {
}
// Memory Operations.
Node* Load(MachineRepresentation rep, Node* base) {
Node* Load(MachineType rep, Node* base) {
return Load(rep, base, Int32Constant(0));
}
Node* Load(MachineRepresentation rep, Node* base, Node* index) {
Node* Load(MachineType rep, Node* base, Node* index) {
return NEW_NODE_2(MACHINE()->Load(rep), base, index);
}
void Store(MachineRepresentation rep, Node* base, Node* value) {
void Store(MachineType rep, Node* base, Node* value) {
Store(rep, base, Int32Constant(0), value);
}
void Store(MachineRepresentation rep, Node* base, Node* index, Node* value) {
void Store(MachineType rep, Node* base, Node* index, Node* value) {
NEW_NODE_3(MACHINE()->Store(rep, kNoWriteBarrier), base, index, value);
}
// Arithmetic Operations.
......@@ -354,8 +351,8 @@ class MachineNodeFactory {
#ifdef MACHINE_ASSEMBLER_SUPPORTS_CALL_C
// Call to C.
Node* CallC(Node* function_address, MachineRepresentation return_type,
MachineRepresentation* arg_types, Node** args, int n_args) {
Node* CallC(Node* function_address, MachineType return_type,
MachineType* arg_types, Node** args, int n_args) {
CallDescriptor* descriptor = Linkage::GetSimplifiedCDescriptor(
ZONE(), n_args, return_type, arg_types);
Node** passed_args =
......
......@@ -5,6 +5,7 @@
#ifndef V8_COMPILER_MACHINE_OPERATOR_H_
#define V8_COMPILER_MACHINE_OPERATOR_H_
#include "src/compiler/machine-type.h"
#include "src/compiler/opcodes.h"
#include "src/compiler/operator.h"
#include "src/zone.h"
......@@ -13,36 +14,14 @@ namespace v8 {
namespace internal {
namespace compiler {
// An enumeration of the storage representations at the machine level.
// - Words are uninterpreted bits of a given fixed size that can be used
// 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 MachineRepresentation {
kMachineWord8,
kMachineWord16,
kMachineWord32,
kMachineWord64,
kMachineFloat64,
kMachineTagged,
kMachineLast
};
// TODO(turbofan): other write barriers are possible based on type
enum WriteBarrierKind { kNoWriteBarrier, kFullWriteBarrier };
// A Store needs a MachineRepresentation and a WriteBarrierKind
// A Store needs a MachineType and a WriteBarrierKind
// in order to emit the correct write barrier.
struct StoreRepresentation {
MachineRepresentation rep;
MachineType rep;
WriteBarrierKind write_barrier_kind;
};
......@@ -52,8 +31,7 @@ struct StoreRepresentation {
// for generating code to run on architectures such as ia32, x64, arm, etc.
class MachineOperatorBuilder {
public:
explicit MachineOperatorBuilder(Zone* zone,
MachineRepresentation word = pointer_rep())
explicit MachineOperatorBuilder(Zone* zone, MachineType word = pointer_rep())
: zone_(zone), word_(word) {
CHECK(word == kMachineWord32 || word == kMachineWord64);
}
......@@ -83,11 +61,11 @@ class MachineOperatorBuilder {
#define WORD_SIZE(x) return is64() ? Word64##x() : Word32##x()
Operator* Load(MachineRepresentation rep) { // load [base + index]
OP1(Load, MachineRepresentation, rep, Operator::kNoWrite, 2, 1);
Operator* Load(MachineType rep) { // load [base + index]
OP1(Load, MachineType, rep, Operator::kNoWrite, 2, 1);
}
// store [base + index], value
Operator* Store(MachineRepresentation rep, WriteBarrierKind kind) {
Operator* Store(MachineType rep, WriteBarrierKind kind) {
StoreRepresentation store_rep = {rep, kind};
OP1(Store, StoreRepresentation, store_rep, Operator::kNoRead, 3, 0);
}
......@@ -167,9 +145,9 @@ class MachineOperatorBuilder {
inline bool is32() const { return word_ == kMachineWord32; }
inline bool is64() const { return word_ == kMachineWord64; }
inline MachineRepresentation word() const { return word_; }
inline MachineType word() const { return word_; }
static inline MachineRepresentation pointer_rep() {
static inline MachineType pointer_rep() {
return kPointerSize == 8 ? kMachineWord64 : kMachineWord32;
}
......@@ -181,7 +159,7 @@ class MachineOperatorBuilder {
private:
Zone* zone_;
MachineRepresentation word_;
MachineType word_;
};
}
}
......
// 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_TYPE_H_
#define V8_COMPILER_MACHINE_TYPE_H_
namespace v8 {
namespace internal {
namespace compiler {
// An enumeration of the storage representations at the machine level.
// - Words are uninterpreted bits of a given fixed size that can be used
// 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 {
kMachineWord8,
kMachineWord16,
kMachineWord32,
kMachineWord64,
kMachineFloat64,
kMachineTagged,
kMachineLast
};
}
}
} // namespace v8::internal::compiler
#endif // V8_COMPILER_MACHINE_TYPE_H_
......@@ -12,7 +12,7 @@ namespace compiler {
RawMachineAssembler::RawMachineAssembler(
Graph* graph, MachineCallDescriptorBuilder* call_descriptor_builder,
MachineRepresentation word)
MachineType word)
: GraphBuilder(graph),
schedule_(new (zone()) Schedule(zone())),
machine_(zone(), word),
......
......@@ -45,9 +45,9 @@ class RawMachineAssembler : public GraphBuilder,
DISALLOW_COPY_AND_ASSIGN(Label);
};
RawMachineAssembler(
Graph* graph, MachineCallDescriptorBuilder* call_descriptor_builder,
MachineRepresentation word = MachineOperatorBuilder::pointer_rep());
RawMachineAssembler(Graph* graph,
MachineCallDescriptorBuilder* call_descriptor_builder,
MachineType word = MachineOperatorBuilder::pointer_rep());
virtual ~RawMachineAssembler() {}
Isolate* isolate() const { return zone()->isolate(); }
......@@ -60,7 +60,7 @@ class RawMachineAssembler : public GraphBuilder,
int parameter_count() const {
return call_descriptor_builder_->parameter_count();
}
const MachineRepresentation* parameter_types() const {
const MachineType* parameter_types() const {
return call_descriptor_builder_->parameter_types();
}
......@@ -108,8 +108,7 @@ class RawMachineAssembler : public GraphBuilder,
BasicBlock* EnsureBlock(Label* label);
BasicBlock* CurrentBlock();
typedef std::vector<MachineRepresentation,
zone_allocator<MachineRepresentation> >
typedef std::vector<MachineType, zone_allocator<MachineType> >
RepresentationVector;
Schedule* schedule_;
......
......@@ -16,7 +16,7 @@ namespace compiler {
// The types and representations tracked during representation inference
// and change insertion.
// TODO(titzer): First, merge MachineRepresentation and RepType.
// TODO(titzer): First, merge MachineType and RepType.
// TODO(titzer): Second, Use the real type system instead of RepType.
enum RepType {
// Representations.
......@@ -265,8 +265,8 @@ class RepresentationChanger {
return TypeError(node, output_type, rWord64);
}
static RepType TypeForMachineRepresentation(MachineRepresentation rep) {
// TODO(titzer): merge MachineRepresentation and RepType.
static RepType TypeForMachineType(MachineType rep) {
// TODO(titzer): merge MachineType and RepType.
switch (rep) {
case kMachineWord8:
return rWord32;
......@@ -348,13 +348,13 @@ class RepresentationChanger {
RepType TypeForField(const FieldAccess& access) {
RepType tElement = static_cast<RepType>(0); // TODO(titzer)
RepType rElement = TypeForMachineRepresentation(access.representation);
RepType rElement = TypeForMachineType(access.representation);
return static_cast<RepType>(tElement | rElement);
}
RepType TypeForElement(const ElementAccess& access) {
RepType tElement = static_cast<RepType>(0); // TODO(titzer)
RepType rElement = TypeForMachineRepresentation(access.representation);
RepType rElement = TypeForMachineType(access.representation);
return static_cast<RepType>(tElement | rElement);
}
......
......@@ -551,10 +551,10 @@ class RepresentationSelector {
case IrOpcode::kLoad: {
// TODO(titzer): machine loads/stores need to know BaseTaggedness!?
RepType tBase = rTagged;
MachineRepresentation rep = OpParameter<MachineRepresentation>(node);
MachineType rep = OpParameter<MachineType>(node);
ProcessInput(node, 0, tBase); // pointer or object
ProcessInput(node, 1, kInt32); // index
SetOutput(node, changer_->TypeForMachineRepresentation(rep));
SetOutput(node, changer_->TypeForMachineType(rep));
break;
}
case IrOpcode::kStore: {
......@@ -563,7 +563,7 @@ class RepresentationSelector {
StoreRepresentation rep = OpParameter<StoreRepresentation>(node);
ProcessInput(node, 0, tBase); // pointer or object
ProcessInput(node, 1, kInt32); // index
ProcessInput(node, 2, changer_->TypeForMachineRepresentation(rep.rep));
ProcessInput(node, 2, changer_->TypeForMachineType(rep.rep));
SetOutput(node, 0);
break;
}
......@@ -893,9 +893,9 @@ void SimplifiedLowering::DoChangeBitToBool(Node* node, Node* effect,
}
static WriteBarrierKind ComputeWriteBarrierKind(
BaseTaggedness base_is_tagged, MachineRepresentation representation,
Type* type) {
static WriteBarrierKind ComputeWriteBarrierKind(BaseTaggedness base_is_tagged,
MachineType representation,
Type* type) {
// TODO(turbofan): skip write barriers for Smis, etc.
if (base_is_tagged == kTaggedBase && representation == kMachineTagged) {
// Write barriers are only for writes into heap objects (i.e. tagged base).
......
......@@ -23,7 +23,7 @@ struct FieldAccess {
int offset; // offset of the field, without tag.
Handle<Name> name; // debugging only.
Type* type; // type of the field.
MachineRepresentation representation; // machine representation of field.
MachineType representation; // machine representation of field.
int tag() const { return base_is_tagged == kTaggedBase ? kHeapObjectTag : 0; }
};
......@@ -37,7 +37,7 @@ struct ElementAccess {
BaseTaggedness base_is_tagged; // specifies if the base pointer is tagged.
int header_size; // size of the header, without tag.
Type* type; // type of the element.
MachineRepresentation representation; // machine representation of element.
MachineType representation; // machine representation of element.
int tag() const { return base_is_tagged == kTaggedBase ? kHeapObjectTag : 0; }
};
......
......@@ -18,7 +18,7 @@ void Variable::Set(Node* value) const { smasm_->SetVariable(offset_, value); }
StructuredMachineAssembler::StructuredMachineAssembler(
Graph* graph, MachineCallDescriptorBuilder* call_descriptor_builder,
MachineRepresentation word)
MachineType word)
: GraphBuilder(graph),
schedule_(new (zone()) Schedule(zone())),
machine_(zone(), word),
......
......@@ -63,7 +63,7 @@ class StructuredMachineAssembler
StructuredMachineAssembler(
Graph* graph, MachineCallDescriptorBuilder* call_descriptor_builder,
MachineRepresentation word = MachineOperatorBuilder::pointer_rep());
MachineType word = MachineOperatorBuilder::pointer_rep());
virtual ~StructuredMachineAssembler() {}
Isolate* isolate() const { return zone()->isolate(); }
......@@ -76,7 +76,7 @@ class StructuredMachineAssembler
int parameter_count() const {
return call_descriptor_builder_->parameter_count();
}
const MachineRepresentation* parameter_types() const {
const MachineType* parameter_types() const {
return call_descriptor_builder_->parameter_types();
}
......@@ -124,8 +124,7 @@ class StructuredMachineAssembler
void MergeBackEdgesToLoopHeader(Environment* header,
EnvironmentVector* environments);
typedef std::vector<MachineRepresentation,
zone_allocator<MachineRepresentation> >
typedef std::vector<MachineType, zone_allocator<MachineType> >
RepresentationVector;
Schedule* schedule_;
......
......@@ -56,7 +56,7 @@ class X64OperandGenerator V8_FINAL : public OperandGenerator {
void InstructionSelector::VisitLoad(Node* node) {
MachineRepresentation rep = OpParameter<MachineRepresentation>(node);
MachineType rep = OpParameter<MachineType>(node);
X64OperandGenerator g(this);
Node* base = node->InputAt(0);
Node* index = node->InputAt(1);
......@@ -108,7 +108,7 @@ void InstructionSelector::VisitStore(Node* node) {
Node* value = node->InputAt(2);
StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node);
MachineRepresentation rep = store_rep.rep;
MachineType rep = store_rep.rep;
if (store_rep.write_barrier_kind == kFullWriteBarrier) {
DCHECK(rep == kMachineTagged);
// TODO(dcarney): refactor RecordWrite function to take temp registers
......
......@@ -72,8 +72,8 @@ CallDescriptor* Linkage::GetStubCallDescriptor(
CallDescriptor* Linkage::GetSimplifiedCDescriptor(
Zone* zone, int num_params, MachineRepresentation return_type,
const MachineRepresentation* param_types) {
Zone* zone, int num_params, MachineType return_type,
const MachineType* param_types) {
return LinkageHelper::GetSimplifiedCDescriptor<LinkageHelperTraits>(
zone, num_params, return_type, param_types);
}
......
......@@ -26,7 +26,7 @@ namespace compiler {
template <typename R>
struct ReturnValueTraits {
static R Cast(uintptr_t r) { return reinterpret_cast<R>(r); }
static MachineRepresentation Representation() {
static MachineType Representation() {
// TODO(dcarney): detect when R is of a subclass of Object* instead of this
// type check.
while (false) {
......@@ -39,7 +39,7 @@ struct ReturnValueTraits {
template <>
struct ReturnValueTraits<int32_t*> {
static int32_t* Cast(uintptr_t r) { return reinterpret_cast<int32_t*>(r); }
static MachineRepresentation Representation() {
static MachineType Representation() {
return MachineOperatorBuilder::pointer_rep();
}
};
......@@ -47,7 +47,7 @@ struct ReturnValueTraits<int32_t*> {
template <>
struct ReturnValueTraits<void> {
static void Cast(uintptr_t r) {}
static MachineRepresentation Representation() {
static MachineType Representation() {
return MachineOperatorBuilder::pointer_rep();
}
};
......@@ -55,7 +55,7 @@ struct ReturnValueTraits<void> {
template <>
struct ReturnValueTraits<bool> {
static bool Cast(uintptr_t r) { return static_cast<bool>(r); }
static MachineRepresentation Representation() {
static MachineType Representation() {
return MachineOperatorBuilder::pointer_rep();
}
};
......@@ -63,31 +63,31 @@ struct ReturnValueTraits<bool> {
template <>
struct ReturnValueTraits<int32_t> {
static int32_t Cast(uintptr_t r) { return static_cast<int32_t>(r); }
static MachineRepresentation Representation() { return kMachineWord32; }
static MachineType Representation() { return kMachineWord32; }
};
template <>
struct ReturnValueTraits<uint32_t> {
static uint32_t Cast(uintptr_t r) { return static_cast<uint32_t>(r); }
static MachineRepresentation Representation() { return kMachineWord32; }
static MachineType Representation() { return kMachineWord32; }
};
template <>
struct ReturnValueTraits<int64_t> {
static int64_t Cast(uintptr_t r) { return static_cast<int64_t>(r); }
static MachineRepresentation Representation() { return kMachineWord64; }
static MachineType Representation() { return kMachineWord64; }
};
template <>
struct ReturnValueTraits<uint64_t> {
static uint64_t Cast(uintptr_t r) { return static_cast<uint64_t>(r); }
static MachineRepresentation Representation() { return kMachineWord64; }
static MachineType Representation() { return kMachineWord64; }
};
template <>
struct ReturnValueTraits<int16_t> {
static int16_t Cast(uintptr_t r) { return static_cast<int16_t>(r); }
static MachineRepresentation Representation() {
static MachineType Representation() {
return MachineOperatorBuilder::pointer_rep();
}
};
......@@ -95,7 +95,7 @@ struct ReturnValueTraits<int16_t> {
template <>
struct ReturnValueTraits<int8_t> {
static int8_t Cast(uintptr_t r) { return static_cast<int8_t>(r); }
static MachineRepresentation Representation() {
static MachineType Representation() {
return MachineOperatorBuilder::pointer_rep();
}
};
......@@ -106,7 +106,7 @@ struct ReturnValueTraits<double> {
UNREACHABLE();
return 0.0;
}
static MachineRepresentation Representation() { return kMachineFloat64; }
static MachineType Representation() { return kMachineFloat64; }
};
......@@ -131,15 +131,11 @@ class CallHelper {
virtual ~CallHelper() {}
static MachineCallDescriptorBuilder* ToCallDescriptorBuilder(
Zone* zone, MachineRepresentation return_type,
MachineRepresentation p0 = kMachineLast,
MachineRepresentation p1 = kMachineLast,
MachineRepresentation p2 = kMachineLast,
MachineRepresentation p3 = kMachineLast,
MachineRepresentation p4 = kMachineLast) {
Zone* zone, MachineType return_type, MachineType p0 = kMachineLast,
MachineType p1 = kMachineLast, MachineType p2 = kMachineLast,
MachineType p3 = kMachineLast, MachineType p4 = kMachineLast) {
const int kSize = 5;
MachineRepresentation* params =
zone->NewArray<MachineRepresentation>(kSize);
MachineType* params = zone->NewArray<MachineType>(kSize);
params[0] = p0;
params[1] = p1;
params[2] = p2;
......@@ -158,7 +154,7 @@ class CallHelper {
protected:
virtual void VerifyParameters(int parameter_count,
MachineRepresentation* parameters) = 0;
MachineType* parameters) = 0;
virtual byte* Generate() = 0;
private:
......@@ -280,35 +276,31 @@ class CallHelper {
template <typename P1>
void VerifyParameters1() {
MachineRepresentation parameters[] = {
ReturnValueTraits<P1>::Representation()};
MachineType parameters[] = {ReturnValueTraits<P1>::Representation()};
VerifyParameters(ARRAY_SIZE(parameters), parameters);
}
template <typename P1, typename P2>
void VerifyParameters2() {
MachineRepresentation parameters[] = {
ReturnValueTraits<P1>::Representation(),
ReturnValueTraits<P2>::Representation()};
MachineType parameters[] = {ReturnValueTraits<P1>::Representation(),
ReturnValueTraits<P2>::Representation()};
VerifyParameters(ARRAY_SIZE(parameters), parameters);
}
template <typename P1, typename P2, typename P3>
void VerifyParameters3() {
MachineRepresentation parameters[] = {
ReturnValueTraits<P1>::Representation(),
ReturnValueTraits<P2>::Representation(),
ReturnValueTraits<P3>::Representation()};
MachineType parameters[] = {ReturnValueTraits<P1>::Representation(),
ReturnValueTraits<P2>::Representation(),
ReturnValueTraits<P3>::Representation()};
VerifyParameters(ARRAY_SIZE(parameters), parameters);
}
template <typename P1, typename P2, typename P3, typename P4>
void VerifyParameters4() {
MachineRepresentation parameters[] = {
ReturnValueTraits<P1>::Representation(),
ReturnValueTraits<P2>::Representation(),
ReturnValueTraits<P3>::Representation(),
ReturnValueTraits<P4>::Representation()};
MachineType parameters[] = {ReturnValueTraits<P1>::Representation(),
ReturnValueTraits<P2>::Representation(),
ReturnValueTraits<P3>::Representation(),
ReturnValueTraits<P4>::Representation()};
VerifyParameters(ARRAY_SIZE(parameters), parameters);
}
#endif
......
......@@ -22,10 +22,9 @@ class MachineAssemblerTester : public HandleAndZoneScope,
public CallHelper,
public MachineAssembler {
public:
MachineAssemblerTester(MachineRepresentation return_type,
MachineRepresentation p0, MachineRepresentation p1,
MachineRepresentation p2, MachineRepresentation p3,
MachineRepresentation p4)
MachineAssemblerTester(MachineType return_type, MachineType p0,
MachineType p1, MachineType p2, MachineType p3,
MachineType p4)
: HandleAndZoneScope(),
CallHelper(main_isolate()),
MachineAssembler(new (main_zone()) Graph(main_zone()),
......@@ -33,13 +32,12 @@ class MachineAssemblerTester : public HandleAndZoneScope,
p1, p2, p3, p4),
MachineOperatorBuilder::pointer_rep()) {}
Node* LoadFromPointer(void* address, MachineRepresentation rep,
int32_t offset = 0) {
Node* LoadFromPointer(void* address, MachineType rep, int32_t offset = 0) {
return this->Load(rep, this->PointerConstant(address),
this->Int32Constant(offset));
}
void StoreToPointer(void* address, MachineRepresentation rep, Node* node) {
void StoreToPointer(void* address, MachineType rep, Node* node) {
this->Store(rep, this->PointerConstant(address), node);
}
......@@ -62,9 +60,9 @@ class MachineAssemblerTester : public HandleAndZoneScope,
protected:
virtual void VerifyParameters(int parameter_count,
MachineRepresentation* parameter_types) {
MachineType* parameter_types) {
CHECK_EQ(this->parameter_count(), parameter_count);
const MachineRepresentation* expected_types = this->parameter_types();
const MachineType* expected_types = this->parameter_types();
for (int i = 0; i < parameter_count; i++) {
CHECK_EQ(expected_types[i], parameter_types[i]);
}
......@@ -93,11 +91,11 @@ class RawMachineAssemblerTester
: public MachineAssemblerTester<RawMachineAssembler>,
public CallHelper2<ReturnType, RawMachineAssemblerTester<ReturnType> > {
public:
RawMachineAssemblerTester(MachineRepresentation p0 = kMachineLast,
MachineRepresentation p1 = kMachineLast,
MachineRepresentation p2 = kMachineLast,
MachineRepresentation p3 = kMachineLast,
MachineRepresentation p4 = kMachineLast)
RawMachineAssemblerTester(MachineType p0 = kMachineLast,
MachineType p1 = kMachineLast,
MachineType p2 = kMachineLast,
MachineType p3 = kMachineLast,
MachineType p4 = kMachineLast)
: MachineAssemblerTester<RawMachineAssembler>(
ReturnValueTraits<ReturnType>::Representation(), p0, p1, p2, p3,
p4) {}
......@@ -129,11 +127,11 @@ class StructuredMachineAssemblerTester
public CallHelper2<ReturnType,
StructuredMachineAssemblerTester<ReturnType> > {
public:
StructuredMachineAssemblerTester(MachineRepresentation p0 = kMachineLast,
MachineRepresentation p1 = kMachineLast,
MachineRepresentation p2 = kMachineLast,
MachineRepresentation p3 = kMachineLast,
MachineRepresentation p4 = kMachineLast)
StructuredMachineAssemblerTester(MachineType p0 = kMachineLast,
MachineType p1 = kMachineLast,
MachineType p2 = kMachineLast,
MachineType p3 = kMachineLast,
MachineType p4 = kMachineLast)
: MachineAssemblerTester<StructuredMachineAssembler>(
ReturnValueTraits<ReturnType>::Representation(), p0, p1, p2, p3,
p4) {}
......@@ -147,7 +145,7 @@ static const int32_t CHECK_VALUE = 0x99BEEDCE;
// TODO(titzer): use the C-style calling convention, or any register-based
// calling convention for binop tests.
template <typename CType, MachineRepresentation rep, bool use_result_buffer>
template <typename CType, MachineType rep, bool use_result_buffer>
class BinopTester {
public:
explicit BinopTester(RawMachineAssemblerTester<int32_t>* tester)
......
......@@ -42,10 +42,10 @@ byte* MachineCallHelper::Generate() {
}
void MachineCallHelper::VerifyParameters(
int parameter_count, MachineRepresentation* parameter_types) {
void MachineCallHelper::VerifyParameters(int parameter_count,
MachineType* parameter_types) {
CHECK_EQ(this->parameter_count(), parameter_count);
const MachineRepresentation* expected_types =
const MachineType* expected_types =
call_descriptor_builder_->parameter_types();
for (int i = 0; i < parameter_count; i++) {
CHECK_EQ(expected_types[i], parameter_types[i]);
......
......@@ -45,8 +45,7 @@ class MachineCallHelper : public CallHelper {
protected:
virtual byte* Generate();
virtual void VerifyParameters(int parameter_count,
MachineRepresentation* parameters);
virtual void VerifyParameters(int parameter_count, MachineType* parameters);
void InitParameters(GraphBuilder* builder, CommonOperatorBuilder* common);
protected:
......@@ -88,11 +87,11 @@ class GraphBuilderTester
public SimplifiedGraphBuilder,
public CallHelper2<ReturnType, GraphBuilderTester<ReturnType> > {
public:
explicit GraphBuilderTester(MachineRepresentation p0 = kMachineLast,
MachineRepresentation p1 = kMachineLast,
MachineRepresentation p2 = kMachineLast,
MachineRepresentation p3 = kMachineLast,
MachineRepresentation p4 = kMachineLast)
explicit GraphBuilderTester(MachineType p0 = kMachineLast,
MachineType p1 = kMachineLast,
MachineType p2 = kMachineLast,
MachineType p3 = kMachineLast,
MachineType p4 = kMachineLast)
: GraphAndBuilders(main_zone()),
MachineCallHelper(
main_zone(),
......
......@@ -27,9 +27,8 @@ class InstructionSelectorTester : public HandleAndZoneScope,
enum Mode { kTargetMode, kInternalMode };
static const int kParameterCount = 3;
static MachineRepresentation* BuildParameterArray(Zone* zone) {
MachineRepresentation* array =
zone->NewArray<MachineRepresentation>(kParameterCount);
static MachineType* BuildParameterArray(Zone* zone) {
MachineType* array = zone->NewArray<MachineType>(kParameterCount);
for (int i = 0; i < kParameterCount; ++i) {
array[i] = kMachineWord32;
}
......
......@@ -27,7 +27,7 @@ using namespace v8::internal::compiler;
template <typename ReturnType>
class ChangesLoweringTester : public GraphBuilderTester<ReturnType> {
public:
explicit ChangesLoweringTester(MachineRepresentation p0 = kMachineLast)
explicit ChangesLoweringTester(MachineType p0 = kMachineLast)
: GraphBuilderTester<ReturnType>(p0),
typer(this->zone()),
source_positions(this->graph()),
......
......@@ -120,7 +120,7 @@ class TrivialDeoptCodegenTester : public DeoptCodegenTester {
// deopt();
// }
MachineRepresentation parameter_reps[] = {kMachineTagged};
MachineType parameter_reps[] = {kMachineTagged};
MachineCallDescriptorBuilder descriptor_builder(kMachineTagged, 1,
parameter_reps);
......@@ -256,7 +256,7 @@ class TrivialRuntimeDeoptCodegenTester : public DeoptCodegenTester {
// %DeoptimizeFunction(foo);
// }
MachineRepresentation parameter_reps[] = {kMachineTagged};
MachineType parameter_reps[] = {kMachineTagged};
MachineCallDescriptorBuilder descriptor_builder(kMachineTagged, 2,
parameter_reps);
......
......@@ -2493,7 +2493,7 @@ TEST(RunDeadInt32Binops) {
template <typename Type, typename CType>
static void RunLoadImmIndex(MachineRepresentation rep) {
static void RunLoadImmIndex(MachineType rep) {
const int kNumElems = 3;
CType buffer[kNumElems];
......@@ -2532,7 +2532,7 @@ TEST(RunLoadImmIndex) {
template <typename CType>
static void RunLoadStore(MachineRepresentation rep) {
static void RunLoadStore(MachineType rep) {
const int kNumElems = 4;
CType buffer[kNumElems];
......@@ -3351,7 +3351,7 @@ TEST(RunCallSeven) {
RawMachineAssemblerTester<int32_t> m;
Node** args = NULL;
MachineRepresentation* arg_types = NULL;
MachineType* arg_types = NULL;
Node* function =
call_direct ? m.PointerConstant(function_address)
: m.LoadFromPointer(&function_address,
......@@ -3371,7 +3371,7 @@ TEST(RunCallUnaryMinus) {
RawMachineAssemblerTester<int32_t> m(kMachineWord32);
Node* args[] = {m.Parameter(0)};
MachineRepresentation arg_types[] = {kMachineWord32};
MachineType arg_types[] = {kMachineWord32};
Node* function =
call_direct ? m.PointerConstant(function_address)
: m.LoadFromPointer(&function_address,
......@@ -3394,7 +3394,7 @@ TEST(RunCallAPlusTwoB) {
RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32);
Node* args[] = {m.Parameter(0), m.Parameter(1)};
MachineRepresentation arg_types[] = {kMachineWord32, kMachineWord32};
MachineType arg_types[] = {kMachineWord32, kMachineWord32};
Node* function =
call_direct ? m.PointerConstant(function_address)
: m.LoadFromPointer(&function_address,
......@@ -3596,7 +3596,7 @@ TEST(RunFloat64LessThan) {
}
template <typename IntType, MachineRepresentation kRepresentation>
template <typename IntType, MachineType kRepresentation>
static void LoadStoreTruncation() {
IntType input;
......@@ -3867,7 +3867,7 @@ TEST(RunSpillLotsOfThingsWithCall) {
{
void* func = reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&Seven));
Node** args = NULL;
MachineRepresentation* arg_types = NULL;
MachineType* arg_types = NULL;
m.CallC(m.PointerConstant(func), kMachineWord32, arg_types, args, 0);
}
for (int i = 0; i < kInputSize; i++) {
......
......@@ -29,11 +29,11 @@ using namespace v8::internal::compiler;
template <typename ReturnType>
class SimplifiedLoweringTester : public GraphBuilderTester<ReturnType> {
public:
SimplifiedLoweringTester(MachineRepresentation p0 = kMachineLast,
MachineRepresentation p1 = kMachineLast,
MachineRepresentation p2 = kMachineLast,
MachineRepresentation p3 = kMachineLast,
MachineRepresentation p4 = kMachineLast)
SimplifiedLoweringTester(MachineType p0 = kMachineLast,
MachineType p1 = kMachineLast,
MachineType p2 = kMachineLast,
MachineType p3 = kMachineLast,
MachineType p4 = kMachineLast)
: GraphBuilderTester<ReturnType>(p0, p1, p2, p3, p4),
typer(this->zone()),
source_positions(this->graph()),
......@@ -89,7 +89,7 @@ ElementAccess ForFixedArrayElement() {
}
ElementAccess ForBackingStoreElement(MachineRepresentation rep) {
ElementAccess ForBackingStoreElement(MachineType rep) {
ElementAccess access = {kUntaggedBase,
kNonHeapObjectHeaderSize - kHeapObjectTag,
Type::Any(), rep};
......@@ -363,13 +363,13 @@ template <typename E>
class AccessTester : public HandleAndZoneScope {
public:
bool tagged;
MachineRepresentation rep;
MachineType rep;
E* original_elements;
size_t num_elements;
E* untagged_array;
Handle<ByteArray> tagged_array; // TODO(titzer): use FixedArray for tagged.
AccessTester(bool t, MachineRepresentation r, E* orig, size_t num)
AccessTester(bool t, MachineType r, E* orig, size_t num)
: tagged(t),
rep(r),
original_elements(orig),
......@@ -517,8 +517,7 @@ class AccessTester : public HandleAndZoneScope {
template <typename E>
static void RunAccessTest(MachineRepresentation rep, E* original_elements,
size_t num) {
static void RunAccessTest(MachineType rep, E* original_elements, size_t num) {
int num_elements = static_cast<int>(num);
for (int taggedness = 0; taggedness < 2; taggedness++) {
......@@ -1158,9 +1157,9 @@ Node* CheckElementAccessArithmetic(ElementAccess access, Node* load_or_store) {
}
static const MachineRepresentation machine_reps[] = {
kMachineWord8, kMachineWord16, kMachineWord32,
kMachineWord64, kMachineFloat64, kMachineTagged};
static const MachineType machine_reps[] = {kMachineWord8, kMachineWord16,
kMachineWord32, kMachineWord64,
kMachineFloat64, kMachineTagged};
// Representation types corresponding to those above.
......@@ -1188,7 +1187,7 @@ TEST(LowerLoadField_to_load) {
CHECK_EQ(t.p0, load->InputAt(0));
CheckFieldAccessArithmetic(access, load);
MachineRepresentation rep = OpParameter<MachineRepresentation>(load);
MachineType rep = OpParameter<MachineType>(load);
CHECK_EQ(machine_reps[i], rep);
}
}
......@@ -1236,7 +1235,7 @@ TEST(LowerLoadElement_to_load) {
CHECK_EQ(t.p0, load->InputAt(0));
CheckElementAccessArithmetic(access, load);
MachineRepresentation rep = OpParameter<MachineRepresentation>(load);
MachineType rep = OpParameter<MachineType>(load);
CHECK_EQ(machine_reps[i], rep);
}
}
......
......@@ -27,22 +27,18 @@ class InstructionSelectorTest : public CompilerTest {
class StreamBuilder V8_FINAL : public RawMachineAssembler {
public:
StreamBuilder(InstructionSelectorTest* test,
MachineRepresentation return_type)
StreamBuilder(InstructionSelectorTest* test, MachineType return_type)
: RawMachineAssembler(new (test->zone()) Graph(test->zone()),
CallDescriptorBuilder(test->zone(), return_type)),
test_(test) {}
StreamBuilder(InstructionSelectorTest* test,
MachineRepresentation return_type,
MachineRepresentation parameter0_type)
StreamBuilder(InstructionSelectorTest* test, MachineType return_type,
MachineType parameter0_type)
: RawMachineAssembler(new (test->zone()) Graph(test->zone()),
CallDescriptorBuilder(test->zone(), return_type,
parameter0_type)),
test_(test) {}
StreamBuilder(InstructionSelectorTest* test,
MachineRepresentation return_type,
MachineRepresentation parameter0_type,
MachineRepresentation parameter1_type)
StreamBuilder(InstructionSelectorTest* test, MachineType return_type,
MachineType parameter0_type, MachineType parameter1_type)
: RawMachineAssembler(
new (test->zone()) Graph(test->zone()),
CallDescriptorBuilder(test->zone(), return_type, parameter0_type,
......@@ -63,26 +59,22 @@ class InstructionSelectorTest : public CompilerTest {
private:
MachineCallDescriptorBuilder* CallDescriptorBuilder(
Zone* zone, MachineRepresentation return_type) {
Zone* zone, MachineType return_type) {
return new (zone) MachineCallDescriptorBuilder(return_type, 0, NULL);
}
MachineCallDescriptorBuilder* CallDescriptorBuilder(
Zone* zone, MachineRepresentation return_type,
MachineRepresentation parameter0_type) {
MachineRepresentation* parameter_types =
zone->NewArray<MachineRepresentation>(1);
Zone* zone, MachineType return_type, MachineType parameter0_type) {
MachineType* parameter_types = zone->NewArray<MachineType>(1);
parameter_types[0] = parameter0_type;
return new (zone)
MachineCallDescriptorBuilder(return_type, 1, parameter_types);
}
MachineCallDescriptorBuilder* CallDescriptorBuilder(
Zone* zone, MachineRepresentation return_type,
MachineRepresentation parameter0_type,
MachineRepresentation parameter1_type) {
MachineRepresentation* parameter_types =
zone->NewArray<MachineRepresentation>(2);
Zone* zone, MachineType return_type, MachineType parameter0_type,
MachineType parameter1_type) {
MachineType* parameter_types = zone->NewArray<MachineType>(2);
parameter_types[0] = parameter0_type;
parameter_types[1] = parameter1_type;
return new (zone)
......
......@@ -394,6 +394,7 @@
'../../src/compiler/machine-operator-reducer.cc',
'../../src/compiler/machine-operator-reducer.h',
'../../src/compiler/machine-operator.h',
'../../src/compiler/machine-type.h',
'../../src/compiler/node-aux-data-inl.h',
'../../src/compiler/node-aux-data.h',
'../../src/compiler/node-cache.cc',
......
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