1 | /*! @file Target_aarch64.cc |
---|
2 | * @brief Target_aarch64 Implementation |
---|
3 | * |
---|
4 | * This file contains the implementation of the base class for |
---|
5 | * functions supporting target unique functionallity. |
---|
6 | */ |
---|
7 | |
---|
8 | #include <stdio.h> |
---|
9 | #include <stdlib.h> |
---|
10 | #include <string.h> |
---|
11 | #include <unistd.h> |
---|
12 | |
---|
13 | #include <rld.h> |
---|
14 | |
---|
15 | #include "qemu-traces.h" |
---|
16 | #include "Target_aarch64.h" |
---|
17 | |
---|
18 | namespace Target { |
---|
19 | |
---|
20 | Target_aarch64::Target_aarch64( std::string targetName ): |
---|
21 | TargetBase( targetName ) |
---|
22 | { |
---|
23 | conditionalBranchInstructions.push_back("cbnz"); |
---|
24 | conditionalBranchInstructions.push_back("cbz"); |
---|
25 | conditionalBranchInstructions.push_back("tbnz"); |
---|
26 | conditionalBranchInstructions.push_back("tbz"); |
---|
27 | conditionalBranchInstructions.push_back("b.eq"); |
---|
28 | conditionalBranchInstructions.push_back("b.ne"); |
---|
29 | conditionalBranchInstructions.push_back("b.cs"); |
---|
30 | conditionalBranchInstructions.push_back("b.hs"); |
---|
31 | conditionalBranchInstructions.push_back("b.cc"); |
---|
32 | conditionalBranchInstructions.push_back("b.lo"); |
---|
33 | conditionalBranchInstructions.push_back("b.mi"); |
---|
34 | conditionalBranchInstructions.push_back("b.pl"); |
---|
35 | conditionalBranchInstructions.push_back("b.vs"); |
---|
36 | conditionalBranchInstructions.push_back("b.vc"); |
---|
37 | conditionalBranchInstructions.push_back("b.hi"); |
---|
38 | conditionalBranchInstructions.push_back("b.ls"); |
---|
39 | conditionalBranchInstructions.push_back("b.ge"); |
---|
40 | conditionalBranchInstructions.push_back("b.lt"); |
---|
41 | conditionalBranchInstructions.push_back("b.gt"); |
---|
42 | conditionalBranchInstructions.push_back("b.le"); |
---|
43 | |
---|
44 | conditionalBranchInstructions.sort(); |
---|
45 | } |
---|
46 | |
---|
47 | Target_aarch64::~Target_aarch64() |
---|
48 | { |
---|
49 | } |
---|
50 | |
---|
51 | bool Target_aarch64::isNopLine( |
---|
52 | const std::string& line, |
---|
53 | int& size |
---|
54 | ) |
---|
55 | { |
---|
56 | size_t stringLen = line.length(); |
---|
57 | |
---|
58 | if ( line.substr( stringLen - 3 ) == "nop" ) { |
---|
59 | size = 4; |
---|
60 | return true; |
---|
61 | } |
---|
62 | |
---|
63 | if ( line.substr( stringLen - 6, 3 ) == "udf" ) { |
---|
64 | size = 4; |
---|
65 | return true; |
---|
66 | } |
---|
67 | |
---|
68 | // On ARM, there are literal tables at the end of methods. |
---|
69 | // We need to avoid them. |
---|
70 | if ( line.substr( stringLen - 10, 5 ) == ".byte" ) { |
---|
71 | size = 1; |
---|
72 | return true; |
---|
73 | } |
---|
74 | if ( line.substr( stringLen - 13, 6 ) == ".short" ) { |
---|
75 | size = 2; |
---|
76 | return true; |
---|
77 | } |
---|
78 | if ( line.substr( stringLen - 16, 5 ) == ".word" ) { |
---|
79 | size = 4; |
---|
80 | return true; |
---|
81 | } |
---|
82 | |
---|
83 | return false; |
---|
84 | } |
---|
85 | |
---|
86 | bool Target_aarch64::isBranch( |
---|
87 | const std::string& instruction |
---|
88 | ) |
---|
89 | { |
---|
90 | throw rld::error( |
---|
91 | "DETERMINE BRANCH INSTRUCTIONS FOR THIS ARCHITECTURE! -- fix me", |
---|
92 | "Target_aarch64::isBranch" |
---|
93 | ); |
---|
94 | } |
---|
95 | |
---|
96 | uint8_t Target_aarch64::qemuTakenBit() |
---|
97 | { |
---|
98 | return TRACE_OP_BR1; |
---|
99 | } |
---|
100 | |
---|
101 | uint8_t Target_aarch64::qemuNotTakenBit() |
---|
102 | { |
---|
103 | return TRACE_OP_BR0; |
---|
104 | } |
---|
105 | |
---|
106 | TargetBase *Target_aarch64_Constructor( |
---|
107 | std::string targetName |
---|
108 | ) |
---|
109 | { |
---|
110 | return new Target_aarch64( targetName ); |
---|
111 | } |
---|
112 | |
---|
113 | } |
---|