Commit 0301534c authored by Ng Zhi An's avatar Ng Zhi An Committed by Commit Bot

Rename LoadKind to MemoryAccessKind

LoadKind is not longer just for load, we use it for stores as well
(starting with https://crrev.com/c/2473383). Rename it to something more
generic.

Bug: v8:10975,v8:10933
Change-Id: I5e5406ea475e06a83eb2eefe22d4824a99029944
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2481822
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70626}
parent 10b847c7
......@@ -669,7 +669,7 @@ void InstructionSelector::VisitLoadTransform(Node* node) {
UNIMPLEMENTED();
}
// ARM64 supports unaligned loads
DCHECK_NE(params.kind, LoadKind::kUnaligned);
DCHECK_NE(params.kind, MemoryAccessKind::kUnaligned);
Arm64OperandGenerator g(this);
Node* base = node->InputAt(0);
......
......@@ -401,9 +401,9 @@ void InstructionSelector::VisitLoadTransform(Node* node) {
}
// IA32 supports unaligned loads.
DCHECK_NE(params.kind, LoadKind::kUnaligned);
DCHECK_NE(params.kind, MemoryAccessKind::kUnaligned);
// Trap handler is not supported on IA32.
DCHECK_NE(params.kind, LoadKind::kProtected);
DCHECK_NE(params.kind, MemoryAccessKind::kProtected);
IA32OperandGenerator g(this);
InstructionOperand outputs[1];
......
......@@ -378,8 +378,8 @@ void InstructionSelector::VisitLoadLane(Node* node) {
DCHECK_GE(5, input_count);
// x64 supports unaligned loads.
DCHECK_NE(params.kind, LoadKind::kUnaligned);
if (params.kind == LoadKind::kProtected) {
DCHECK_NE(params.kind, MemoryAccessKind::kUnaligned);
if (params.kind == MemoryAccessKind::kProtected) {
opcode |= MiscField::encode(kMemoryAccessProtected);
}
Emit(opcode, 1, outputs, input_count, inputs);
......@@ -429,9 +429,9 @@ void InstructionSelector::VisitLoadTransform(Node* node) {
UNREACHABLE();
}
// x64 supports unaligned loads
DCHECK_NE(params.kind, LoadKind::kUnaligned);
DCHECK_NE(params.kind, MemoryAccessKind::kUnaligned);
InstructionCode code = opcode;
if (params.kind == LoadKind::kProtected) {
if (params.kind == MemoryAccessKind::kProtected) {
code |= MiscField::encode(kMemoryAccessProtected);
}
VisitLoad(node, node, code);
......@@ -562,7 +562,7 @@ void InstructionSelector::VisitStoreLane(Node* node) {
g.GetEffectiveAddressMemoryOperand(node, inputs, &input_count);
opcode |= AddressingModeField::encode(addressing_mode);
if (params.kind == LoadKind::kProtected) {
if (params.kind == MemoryAccessKind::kProtected) {
opcode |= MiscField::encode(kMemoryAccessProtected);
}
......
......@@ -32,15 +32,15 @@ std::ostream& operator<<(std::ostream& os, StoreRepresentation rep) {
return os << rep.representation() << ", " << rep.write_barrier_kind();
}
size_t hash_value(LoadKind kind) { return static_cast<size_t>(kind); }
size_t hash_value(MemoryAccessKind kind) { return static_cast<size_t>(kind); }
std::ostream& operator<<(std::ostream& os, LoadKind kind) {
std::ostream& operator<<(std::ostream& os, MemoryAccessKind kind) {
switch (kind) {
case LoadKind::kNormal:
case MemoryAccessKind::kNormal:
return os << "kNormal";
case LoadKind::kUnaligned:
case MemoryAccessKind::kUnaligned:
return os << "kUnaligned";
case LoadKind::kProtected:
case MemoryAccessKind::kProtected:
return os << "kProtected";
}
UNREACHABLE();
......@@ -802,24 +802,24 @@ struct ProtectedLoadOperator : public Operator1<LoadRepresentation> {
1, 1, 1, 1, 0, LoadRepresentation(rep, sem)) {}
};
template <LoadKind kind, LoadTransformation type>
template <MemoryAccessKind kind, LoadTransformation type>
struct LoadTransformOperator : public Operator1<LoadTransformParameters> {
LoadTransformOperator()
: Operator1(IrOpcode::kLoadTransform,
kind == LoadKind::kProtected
kind == MemoryAccessKind::kProtected
? Operator::kNoDeopt | Operator::kNoThrow
: Operator::kEliminatable,
"LoadTransform", 2, 1, 1, 1, 1, 0,
LoadTransformParameters{kind, type}) {}
};
template <LoadKind kind, MachineRepresentation rep, MachineSemantic sem,
template <MemoryAccessKind kind, MachineRepresentation rep, MachineSemantic sem,
uint8_t laneidx>
struct LoadLaneOperator : public Operator1<LoadLaneParameters> {
LoadLaneOperator()
: Operator1(
IrOpcode::kLoadLane,
kind == LoadKind::kProtected
kind == MemoryAccessKind::kProtected
? Operator::kNoDeopt | Operator::kNoThrow
: Operator::kEliminatable,
"LoadLane", 3, 1, 1, 1, 1, 0,
......@@ -852,7 +852,7 @@ struct ProtectedStoreOperator : public Operator1<StoreRepresentation> {
StoreRepresentation(rep, kNoWriteBarrier)) {}
};
template <LoadKind kind, MachineRepresentation rep, uint8_t laneidx>
template <MemoryAccessKind kind, MachineRepresentation rep, uint8_t laneidx>
struct StoreLaneOperator : public Operator1<StoreLaneParameters> {
StoreLaneOperator()
: Operator1(IrOpcode::kStoreLane,
......@@ -1189,11 +1189,12 @@ const Operator* MachineOperatorBuilder::ProtectedLoad(LoadRepresentation rep) {
}
const Operator* MachineOperatorBuilder::LoadTransform(
LoadKind kind, LoadTransformation transform) {
#define LOAD_TRANSFORM_KIND(TYPE, KIND) \
if (kind == LoadKind::k##KIND && transform == LoadTransformation::k##TYPE) { \
return GetCachedOperator<LoadTransformOperator< \
LoadKind::k##KIND, LoadTransformation::k##TYPE>>(); \
MemoryAccessKind kind, LoadTransformation transform) {
#define LOAD_TRANSFORM_KIND(TYPE, KIND) \
if (kind == MemoryAccessKind::k##KIND && \
transform == LoadTransformation::k##TYPE) { \
return GetCachedOperator<LoadTransformOperator< \
MemoryAccessKind::k##KIND, LoadTransformation::k##TYPE>>(); \
}
#define LOAD_TRANSFORM(TYPE) \
LOAD_TRANSFORM_KIND(TYPE, Normal) \
......@@ -1206,15 +1207,15 @@ const Operator* MachineOperatorBuilder::LoadTransform(
UNREACHABLE();
}
const Operator* MachineOperatorBuilder::LoadLane(LoadKind kind,
const Operator* MachineOperatorBuilder::LoadLane(MemoryAccessKind kind,
LoadRepresentation rep,
uint8_t laneidx) {
#define LOAD_LANE_KIND(TYPE, KIND, LANEIDX) \
if (kind == LoadKind::k##KIND && rep == MachineType::TYPE() && \
laneidx == LANEIDX) { \
return GetCachedOperator<LoadLaneOperator< \
LoadKind::k##KIND, MachineType::TYPE().representation(), \
MachineType::TYPE().semantic(), LANEIDX>>(); \
#define LOAD_LANE_KIND(TYPE, KIND, LANEIDX) \
if (kind == MemoryAccessKind::k##KIND && rep == MachineType::TYPE() && \
laneidx == LANEIDX) { \
return GetCachedOperator<LoadLaneOperator< \
MemoryAccessKind::k##KIND, MachineType::TYPE().representation(), \
MachineType::TYPE().semantic(), LANEIDX>>(); \
}
#define LOAD_LANE_T(T, LANE) \
......@@ -1240,14 +1241,14 @@ const Operator* MachineOperatorBuilder::LoadLane(LoadKind kind,
UNREACHABLE();
}
const Operator* MachineOperatorBuilder::StoreLane(LoadKind kind,
const Operator* MachineOperatorBuilder::StoreLane(MemoryAccessKind kind,
MachineRepresentation rep,
uint8_t laneidx) {
#define STORE_LANE_KIND(REP, KIND, LANEIDX) \
if (kind == LoadKind::k##KIND && rep == MachineRepresentation::REP && \
laneidx == LANEIDX) { \
return GetCachedOperator<StoreLaneOperator< \
LoadKind::k##KIND, MachineRepresentation::REP, LANEIDX>>(); \
#define STORE_LANE_KIND(REP, KIND, LANEIDX) \
if (kind == MemoryAccessKind::k##KIND && \
rep == MachineRepresentation::REP && laneidx == LANEIDX) { \
return GetCachedOperator<StoreLaneOperator< \
MemoryAccessKind::k##KIND, MachineRepresentation::REP, LANEIDX>>(); \
}
#define STORE_LANE_T(T, LANE) \
......
......@@ -49,16 +49,15 @@ using LoadRepresentation = MachineType;
V8_EXPORT_PRIVATE LoadRepresentation LoadRepresentationOf(Operator const*)
V8_WARN_UNUSED_RESULT;
// TODO(zhin): This is used by StoreLane too, rename this.
enum class LoadKind {
enum class MemoryAccessKind {
kNormal,
kUnaligned,
kProtected,
};
size_t hash_value(LoadKind);
size_t hash_value(MemoryAccessKind);
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, LoadKind);
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, MemoryAccessKind);
enum class LoadTransformation {
kS128Load8Splat,
......@@ -80,7 +79,7 @@ size_t hash_value(LoadTransformation);
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, LoadTransformation);
struct LoadTransformParameters {
LoadKind kind;
MemoryAccessKind kind;
LoadTransformation transformation;
};
......@@ -93,7 +92,7 @@ V8_EXPORT_PRIVATE LoadTransformParameters const& LoadTransformParametersOf(
Operator const*) V8_WARN_UNUSED_RESULT;
struct LoadLaneParameters {
LoadKind kind;
MemoryAccessKind kind;
LoadRepresentation rep;
uint8_t laneidx;
};
......@@ -137,7 +136,7 @@ UnalignedStoreRepresentation const& UnalignedStoreRepresentationOf(
Operator const*) V8_WARN_UNUSED_RESULT;
struct StoreLaneParameters {
LoadKind kind;
MemoryAccessKind kind;
MachineRepresentation rep;
uint8_t laneidx;
};
......@@ -815,10 +814,11 @@ class V8_EXPORT_PRIVATE MachineOperatorBuilder final
const Operator* PoisonedLoad(LoadRepresentation rep);
const Operator* ProtectedLoad(LoadRepresentation rep);
const Operator* LoadTransform(LoadKind kind, LoadTransformation transform);
const Operator* LoadTransform(MemoryAccessKind kind,
LoadTransformation transform);
// SIMD load: replace a specified lane with [base + index].
const Operator* LoadLane(LoadKind kind, LoadRepresentation rep,
const Operator* LoadLane(MemoryAccessKind kind, LoadRepresentation rep,
uint8_t laneidx);
// store [base + index], value
......@@ -826,7 +826,7 @@ class V8_EXPORT_PRIVATE MachineOperatorBuilder final
const Operator* ProtectedStore(MachineRepresentation rep);
// SIMD store: store a specified lane of value into [base + index].
const Operator* StoreLane(LoadKind kind, MachineRepresentation rep,
const Operator* StoreLane(MemoryAccessKind kind, MachineRepresentation rep,
uint8_t laneidx);
// unaligned load [base + index]
......
......@@ -616,13 +616,13 @@ void SimdScalarLowering::LowerLoadTransformOp(Node* node, SimdType type) {
const Operator* load_op;
switch (params.kind) {
case LoadKind::kNormal:
case MemoryAccessKind::kNormal:
load_op = machine()->Load(load_rep);
break;
case LoadKind::kUnaligned:
case MemoryAccessKind::kUnaligned:
load_op = machine()->UnalignedLoad(load_rep);
break;
case LoadKind::kProtected:
case MemoryAccessKind::kProtected:
load_op = machine()->ProtectedLoad(load_rep);
break;
}
......
......@@ -3894,18 +3894,18 @@ LoadTransformation GetLoadTransformation(
UNREACHABLE();
}
LoadKind GetLoadKind(MachineGraph* mcgraph, MachineType memtype,
bool use_trap_handler) {
MemoryAccessKind GetMemoryAccessKind(MachineGraph* mcgraph, MachineType memtype,
bool use_trap_handler) {
if (memtype.representation() == MachineRepresentation::kWord8 ||
mcgraph->machine()->UnalignedLoadSupported(memtype.representation())) {
if (use_trap_handler) {
return LoadKind::kProtected;
return MemoryAccessKind::kProtected;
}
return LoadKind::kNormal;
return MemoryAccessKind::kNormal;
}
// TODO(eholk): Support unaligned loads with trap handlers.
DCHECK(!use_trap_handler);
return LoadKind::kUnaligned;
return MemoryAccessKind::kUnaligned;
}
} // namespace
......@@ -3994,13 +3994,14 @@ Node* WasmGraphBuilder::LoadLane(MachineType memtype, Node* value, Node* index,
index =
BoundsCheckMem(access_size, index, offset, position, kCanOmitBoundsCheck);
LoadKind load_kind = GetLoadKind(mcgraph(), memtype, use_trap_handler());
MemoryAccessKind load_kind =
GetMemoryAccessKind(mcgraph(), memtype, use_trap_handler());
load = SetEffect(graph()->NewNode(
mcgraph()->machine()->LoadLane(load_kind, memtype, laneidx),
MemBuffer(offset), index, value, effect(), control()));
if (load_kind == LoadKind::kProtected) {
if (load_kind == MemoryAccessKind::kProtected) {
SetSourcePosition(load, position);
}
......@@ -4029,7 +4030,7 @@ Node* WasmGraphBuilder::LoadTransform(wasm::ValueType type, MachineType memtype,
// therefore we divide them into separate "load" and "operation" nodes.
load = LoadTransformBigEndian(type, memtype, transform, index, offset,
alignment, position);
USE(GetLoadKind);
USE(GetMemoryAccessKind);
#else
// Wasm semantics throw on OOB. Introduce explicit bounds check and
// conditioning when not using the trap handler.
......@@ -4042,13 +4043,14 @@ Node* WasmGraphBuilder::LoadTransform(wasm::ValueType type, MachineType memtype,
BoundsCheckMem(access_size, index, offset, position, kCanOmitBoundsCheck);
LoadTransformation transformation = GetLoadTransformation(memtype, transform);
LoadKind load_kind = GetLoadKind(mcgraph(), memtype, use_trap_handler());
MemoryAccessKind load_kind =
GetMemoryAccessKind(mcgraph(), memtype, use_trap_handler());
load = SetEffect(graph()->NewNode(
mcgraph()->machine()->LoadTransform(load_kind, transformation),
MemBuffer(capped_offset), index, effect(), control()));
if (load_kind == LoadKind::kProtected) {
if (load_kind == MemoryAccessKind::kProtected) {
SetSourcePosition(load, position);
}
#endif
......@@ -4122,7 +4124,8 @@ Node* WasmGraphBuilder::StoreLane(MachineRepresentation mem_rep, Node* index,
position, kCanOmitBoundsCheck);
MachineType memtype = MachineType(mem_rep, MachineSemantic::kNone);
LoadKind load_kind = GetLoadKind(mcgraph(), memtype, use_trap_handler());
MemoryAccessKind load_kind =
GetMemoryAccessKind(mcgraph(), memtype, use_trap_handler());
// {offset} is validated to be within uintptr_t range in {BoundsCheckMem}.
uintptr_t capped_offset = static_cast<uintptr_t>(offset);
......@@ -4131,7 +4134,7 @@ Node* WasmGraphBuilder::StoreLane(MachineRepresentation mem_rep, Node* index,
mcgraph()->machine()->StoreLane(load_kind, mem_rep, laneidx),
MemBuffer(capped_offset), index, val, effect(), control()));
if (load_kind == LoadKind::kProtected) {
if (load_kind == MemoryAccessKind::kProtected) {
SetSourcePosition(store, position);
}
......
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