Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1114)

Unified Diff: src/interpreter/bytecode-traits.h

Issue 1783483002: [interpreter] Add support for scalable operands. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Operand renaming. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/interpreter/bytecode-traits.h
diff --git a/src/interpreter/bytecode-traits.h b/src/interpreter/bytecode-traits.h
index b8136051bbb20eec6c127b9a21c2891742781eed..525f20cdb27e8e5bd4840849ffc920a557bbc017 100644
--- a/src/interpreter/bytecode-traits.h
+++ b/src/interpreter/bytecode-traits.h
@@ -16,14 +16,25 @@ namespace interpreter {
// Template helpers to deduce the number of operands each bytecode has.
#define OPERAND_TERM OperandType::kNone, OperandType::kNone, OperandType::kNone
+template <OperandTypeTrait t>
+struct OperandTypeInfo {
+ static const bool IsScalable = false;
+};
+
+template <>
+struct OperandTypeInfo<OperandTypeTrait::kScalable> {
+ static const bool IsScalable = true;
+};
+
template <OperandType>
struct OperandTraits {};
-#define DECLARE_OPERAND_SIZE(Name, Size) \
- template <> \
- struct OperandTraits<OperandType::k##Name> { \
- static const OperandSize kSizeType = Size; \
- static const int kSize = static_cast<int>(Size); \
+#define DECLARE_OPERAND_SIZE(Name, Size, TypeTrait) \
+ template <> \
+ struct OperandTraits<OperandType::k##Name> { \
+ static const OperandSize kSizeType = Size; \
+ static const int kSize = static_cast<int>(Size); \
+ static const bool kScalable = OperandTypeInfo<TypeTrait>::IsScalable; \
};
OPERAND_TYPE_LIST(DECLARE_OPERAND_SIZE)
#undef DECLARE_OPERAND_SIZE
@@ -33,7 +44,7 @@ struct RegisterOperandTraits {
static const int kIsRegisterOperand = 0;
};
-#define DECLARE_REGISTER_OPERAND(Name, _) \
+#define DECLARE_REGISTER_OPERAND(Name, _, __) \
template <> \
struct RegisterOperandTraits<OperandType::k##Name> { \
static const int kIsRegisterOperand = 1; \
@@ -55,32 +66,19 @@ struct BytecodeTraits<operand_0, operand_1, operand_2, operand_3,
return kOperands[i];
}
- static inline OperandSize GetOperandSize(int i) {
- DCHECK(0 <= i && i < kOperandCount);
- const OperandSize kOperandSizes[] =
- {OperandTraits<operand_0>::kSizeType,
- OperandTraits<operand_1>::kSizeType,
- OperandTraits<operand_2>::kSizeType,
- OperandTraits<operand_3>::kSizeType};
- return kOperandSizes[i];
- }
-
- static inline int GetOperandOffset(int i) {
- DCHECK(0 <= i && i < kOperandCount);
- const int kOffset0 = 1;
- const int kOffset1 = kOffset0 + OperandTraits<operand_0>::kSize;
- const int kOffset2 = kOffset1 + OperandTraits<operand_1>::kSize;
- const int kOffset3 = kOffset2 + OperandTraits<operand_2>::kSize;
- const int kOperandOffsets[] = {kOffset0, kOffset1, kOffset2, kOffset3};
- return kOperandOffsets[i];
- }
-
template <OperandType ot>
static inline bool HasAnyOperandsOfType() {
return operand_0 == ot || operand_1 == ot || operand_2 == ot ||
operand_3 == ot;
}
+ static inline bool IsScalable() {
+ return (OperandTraits<operand_0>::kScalable |
+ OperandTraits<operand_1>::kScalable |
+ OperandTraits<operand_2>::kScalable |
+ OperandTraits<operand_3>::kScalable);
+ }
+
static const int kOperandCount = 4;
static const int kRegisterOperandCount =
RegisterOperandTraits<operand_0>::kIsRegisterOperand +
@@ -92,9 +90,6 @@ struct BytecodeTraits<operand_0, operand_1, operand_2, operand_3,
(RegisterOperandTraits<operand_1>::kIsRegisterOperand << 1) +
(RegisterOperandTraits<operand_2>::kIsRegisterOperand << 2) +
(RegisterOperandTraits<operand_3>::kIsRegisterOperand << 3);
- static const int kSize =
- 1 + OperandTraits<operand_0>::kSize + OperandTraits<operand_1>::kSize +
- OperandTraits<operand_2>::kSize + OperandTraits<operand_3>::kSize;
};
template <OperandType operand_0, OperandType operand_1, OperandType operand_2>
@@ -105,29 +100,17 @@ struct BytecodeTraits<operand_0, operand_1, operand_2, OPERAND_TERM> {
return kOperands[i];
}
- static inline OperandSize GetOperandSize(int i) {
- DCHECK(0 <= i && i < kOperandCount);
- const OperandSize kOperandSizes[] =
- {OperandTraits<operand_0>::kSizeType,
- OperandTraits<operand_1>::kSizeType,
- OperandTraits<operand_2>::kSizeType};
- return kOperandSizes[i];
- }
-
- static inline int GetOperandOffset(int i) {
- DCHECK(0 <= i && i < kOperandCount);
- const int kOffset0 = 1;
- const int kOffset1 = kOffset0 + OperandTraits<operand_0>::kSize;
- const int kOffset2 = kOffset1 + OperandTraits<operand_1>::kSize;
- const int kOperandOffsets[] = {kOffset0, kOffset1, kOffset2};
- return kOperandOffsets[i];
- }
-
template <OperandType ot>
static inline bool HasAnyOperandsOfType() {
return operand_0 == ot || operand_1 == ot || operand_2 == ot;
}
+ static inline bool IsScalable() {
+ return (OperandTraits<operand_0>::kScalable |
+ OperandTraits<operand_1>::kScalable |
+ OperandTraits<operand_2>::kScalable);
+ }
+
static const int kOperandCount = 3;
static const int kRegisterOperandCount =
RegisterOperandTraits<operand_0>::kIsRegisterOperand +
@@ -137,9 +120,6 @@ struct BytecodeTraits<operand_0, operand_1, operand_2, OPERAND_TERM> {
RegisterOperandTraits<operand_0>::kIsRegisterOperand +
(RegisterOperandTraits<operand_1>::kIsRegisterOperand << 1) +
(RegisterOperandTraits<operand_2>::kIsRegisterOperand << 2);
- static const int kSize =
- 1 + OperandTraits<operand_0>::kSize + OperandTraits<operand_1>::kSize +
- OperandTraits<operand_2>::kSize;
};
template <OperandType operand_0, OperandType operand_1>
@@ -150,27 +130,16 @@ struct BytecodeTraits<operand_0, operand_1, OPERAND_TERM> {
return kOperands[i];
}
- static inline OperandSize GetOperandSize(int i) {
- DCHECK(0 <= i && i < kOperandCount);
- const OperandSize kOperandSizes[] =
- {OperandTraits<operand_0>::kSizeType,
- OperandTraits<operand_1>::kSizeType};
- return kOperandSizes[i];
- }
-
- static inline int GetOperandOffset(int i) {
- DCHECK(0 <= i && i < kOperandCount);
- const int kOffset0 = 1;
- const int kOffset1 = kOffset0 + OperandTraits<operand_0>::kSize;
- const int kOperandOffsets[] = {kOffset0, kOffset1};
- return kOperandOffsets[i];
- }
-
template <OperandType ot>
static inline bool HasAnyOperandsOfType() {
return operand_0 == ot || operand_1 == ot;
}
+ static inline bool IsScalable() {
+ return (OperandTraits<operand_0>::kScalable |
+ OperandTraits<operand_1>::kScalable);
+ }
+
static const int kOperandCount = 2;
static const int kRegisterOperandCount =
RegisterOperandTraits<operand_0>::kIsRegisterOperand +
@@ -178,8 +147,6 @@ struct BytecodeTraits<operand_0, operand_1, OPERAND_TERM> {
static const int kRegisterOperandBitmap =
RegisterOperandTraits<operand_0>::kIsRegisterOperand +
(RegisterOperandTraits<operand_1>::kIsRegisterOperand << 1);
- static const int kSize =
- 1 + OperandTraits<operand_0>::kSize + OperandTraits<operand_1>::kSize;
};
template <OperandType operand_0>
@@ -189,27 +156,20 @@ struct BytecodeTraits<operand_0, OPERAND_TERM> {
return operand_0;
}
- static inline OperandSize GetOperandSize(int i) {
- DCHECK(i == 0);
- return OperandTraits<operand_0>::kSizeType;
- }
-
- static inline int GetOperandOffset(int i) {
- DCHECK(i == 0);
- return 1;
- }
-
template <OperandType ot>
static inline bool HasAnyOperandsOfType() {
return operand_0 == ot;
}
+ static inline bool IsScalable() {
+ return OperandTraits<operand_0>::kScalable;
+ }
+
static const int kOperandCount = 1;
static const int kRegisterOperandCount =
RegisterOperandTraits<operand_0>::kIsRegisterOperand;
static const int kRegisterOperandBitmap =
RegisterOperandTraits<operand_0>::kIsRegisterOperand;
- static const int kSize = 1 + OperandTraits<operand_0>::kSize;
};
template <>
@@ -219,25 +179,16 @@ struct BytecodeTraits<OperandType::kNone, OPERAND_TERM> {
return OperandType::kNone;
}
- static inline OperandSize GetOperandSize(int i) {
- UNREACHABLE();
- return OperandSize::kNone;
- }
-
- static inline int GetOperandOffset(int i) {
- UNREACHABLE();
- return 1;
- }
-
template <OperandType ot>
static inline bool HasAnyOperandsOfType() {
return false;
}
+ static inline bool IsScalable() { return false; }
+
static const int kOperandCount = 0;
static const int kRegisterOperandCount = 0;
static const int kRegisterOperandBitmap = 0;
- static const int kSize = 1 + OperandTraits<OperandType::kNone>::kSize;
};
} // namespace interpreter

Powered by Google App Engine
This is Rietveld 408576698