Flutter Engine
The Flutter Engine
locations_helpers_arm.h
Go to the documentation of this file.
1// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5// This file contains few helpful marker types that can be used with
6// MakeLocationSummaryFromEmitter and InvokeEmitter to simplify writing
7// of ARM code.
8
9#ifndef RUNTIME_VM_COMPILER_BACKEND_LOCATIONS_HELPERS_ARM_H_
10#define RUNTIME_VM_COMPILER_BACKEND_LOCATIONS_HELPERS_ARM_H_
11
12#if defined(DART_PRECOMPILED_RUNTIME)
13#error "AOT runtime should not use compiler sources (including header files)"
14#endif // defined(DART_PRECOMPILED_RUNTIME)
15
16namespace dart {
17
18// QRegisterView is a wrapper around QRegister that provides helpers for
19// accessing S and D components.
21 public:
22 explicit QRegisterView(QRegister reg) : reg_(reg) {}
23
24 operator QRegister() const { return reg_; }
25
26 inline DRegister d(intptr_t i) const {
27 ASSERT(0 <= i && i < 2);
28 return static_cast<DRegister>(reg_ * 2 + i);
29 }
30
31 inline SRegister s(intptr_t i) const {
32 ASSERT(0 <= i && i < 4);
33 ASSERT(reg_ <= Q7);
34 return static_cast<SRegister>(reg_ * 4 + i);
35 }
36
37 private:
38 QRegister reg_;
39};
40
41// FixedQRegisterView<r> is a handy replacement for Fixed<QRegister, r> that
42// provides helpers for accessing S and D components.
43//
44// Note: this class is provided because Fixed<QRegisterView, r> is not a valid
45// type.
46template <QRegister reg>
48 public:
49 inline DRegister d(intptr_t i) const {
50 return static_cast<DRegister>(reg * 2 + i);
51 }
52
53 inline SRegister s(intptr_t i) const {
54 return static_cast<SRegister>(reg * 4 + i);
55 }
56
57 operator QRegister() const { return reg; }
58};
59
60template <>
62 static constexpr bool kIsTemp = false;
63
64 static QRegisterView Unwrap(const Location& loc) {
65 return QRegisterView(loc.fpu_reg());
66 }
67
68 template <intptr_t arity, intptr_t index>
70 return Unwrap(locs->in(index));
71 }
72
73 template <intptr_t arity, intptr_t index>
75 locs->set_in(index, ToConstraint());
76 }
77
79};
80
81template <QRegister reg>
83 static constexpr bool kIsTemp = false;
84
88 }
89
90 template <intptr_t arity, intptr_t index>
92 return Unwrap(locs->in(index));
93 }
94
95 template <intptr_t arity, intptr_t index>
97 locs->set_in(index, ToConstraint());
98 }
99
101};
102
103} // namespace dart
104
105#endif // RUNTIME_VM_COMPILER_BACKEND_LOCATIONS_HELPERS_ARM_H_
SRegister s(intptr_t i) const
DRegister d(intptr_t i) const
Location in(intptr_t index) const
Definition: locations.h:866
void set_in(intptr_t index, Location loc)
Definition: locations.cc:205
static Location FpuRegisterLocation(FpuRegister reg)
Definition: locations.h:410
static Location RequiresFpuRegister()
Definition: locations.h:369
FpuRegister fpu_reg() const
Definition: locations.h:416
QRegisterView(QRegister reg)
SRegister s(intptr_t i) const
DRegister d(intptr_t i) const
#define ASSERT(E)
Definition: dart_vm.cc:33
static FixedQRegisterView< reg > Unwrap(const Location &loc)
static FixedQRegisterView< reg > UnwrapInput(LocationSummary *locs)
static void SetInputConstraint(LocationSummary *locs)
static QRegisterView Unwrap(const Location &loc)
static void SetInputConstraint(LocationSummary *locs)
static QRegisterView UnwrapInput(LocationSummary *locs)