xref: /aosp_15_r20/art/simulator/code_simulator_arm64.h (revision 795d594fd825385562da6b089ea9b2033f3abf5a)
1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ART_SIMULATOR_CODE_SIMULATOR_ARM64_H_
18 #define ART_SIMULATOR_CODE_SIMULATOR_ARM64_H_
19 
20 #include "memory"
21 
22 // TODO(VIXL): Make VIXL compile cleanly with -Wshadow, -Wdeprecated-declarations.
23 #pragma GCC diagnostic push
24 #pragma GCC diagnostic ignored "-Wshadow"
25 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
26 #include "aarch64/simulator-aarch64.h"
27 #pragma GCC diagnostic pop
28 
29 #include "arch/instruction_set.h"
30 #include "code_simulator.h"
31 
32 namespace art {
33 namespace arm64 {
34 
35 class CodeSimulatorArm64 : public CodeSimulator {
36  public:
37   static CodeSimulatorArm64* CreateCodeSimulatorArm64();
38   virtual ~CodeSimulatorArm64();
39 
40   void RunFrom(intptr_t code_buffer) override;
41 
42   bool GetCReturnBool() const override;
43   int32_t GetCReturnInt32() const override;
44   int64_t GetCReturnInt64() const override;
45 
46  private:
47   CodeSimulatorArm64();
48 
49   vixl::aarch64::Decoder* decoder_;
50   vixl::aarch64::Simulator* simulator_;
51 
52   // TODO: Enable CodeSimulatorArm64 for more host ISAs once Simulator supports them.
53   static constexpr bool kCanSimulate = (kRuntimeISA == InstructionSet::kX86_64);
54 
55   DISALLOW_COPY_AND_ASSIGN(CodeSimulatorArm64);
56 };
57 
58 }  // namespace arm64
59 }  // namespace art
60 
61 #endif  // ART_SIMULATOR_CODE_SIMULATOR_ARM64_H_
62