• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_CODEGEN_REGISTER_H_
6 #define V8_CODEGEN_REGISTER_H_
7 
8 #include "src/codegen/register-arch.h"
9 #include "src/codegen/reglist.h"
10 
11 namespace v8 {
12 namespace internal {
13 
AddArgumentPaddingSlots(int argument_count)14 constexpr int AddArgumentPaddingSlots(int argument_count) {
15   return argument_count + ArgumentPaddingSlots(argument_count);
16 }
17 
ShouldPadArguments(int argument_count)18 constexpr bool ShouldPadArguments(int argument_count) {
19   return ArgumentPaddingSlots(argument_count) != 0;
20 }
21 
22 #ifdef DEBUG
23 template <typename... RegTypes,
24           // All arguments must be either Register or DoubleRegister.
25           typename = typename std::enable_if_t<
26               std::conjunction_v<std::is_same<Register, RegTypes>...> ||
27               std::conjunction_v<std::is_same<DoubleRegister, RegTypes>...>>>
AreAliased(RegTypes...regs)28 inline constexpr bool AreAliased(RegTypes... regs) {
29   using FirstRegType = std::tuple_element_t<0, std::tuple<RegTypes...>>;
30   int num_different_regs = RegListBase<FirstRegType>{regs...}.Count();
31   int num_given_regs = (... + (regs.is_valid() ? 1 : 0));
32   return num_different_regs < num_given_regs;
33 }
34 #endif
35 
36 }  // namespace internal
37 }  // namespace v8
38 
39 #endif  // V8_CODEGEN_REGISTER_H_
40