• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014, VIXL authors
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are met:
6 //
7 //   * Redistributions of source code must retain the above copyright notice,
8 //     this list of conditions and the following disclaimer.
9 //   * Redistributions in binary form must reproduce the above copyright notice,
10 //     this list of conditions and the following disclaimer in the documentation
11 //     and/or other materials provided with the distribution.
12 //   * Neither the name of ARM Limited nor the names of its contributors may be
13 //     used to endorse or promote products derived from this software without
14 //     specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS CONTRIBUTORS "AS IS" AND
17 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
20 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 
27 #ifndef VIXL_EXAMPLES_NON_CONST_VISITOR_H_
28 #define VIXL_EXAMPLES_NON_CONST_VISITOR_H_
29 
30 #include "aarch64/decoder-aarch64.h"
31 #include "aarch64/macro-assembler-aarch64.h"
32 
33 class SwitchAddSubRegisterSources : public vixl::aarch64::DecoderVisitor {
34  public:
SwitchAddSubRegisterSources()35   SwitchAddSubRegisterSources()
36       : vixl::aarch64::DecoderVisitor(kNonConstVisitor) {}
37 
38   // Our visitor switches the register sources for some add and sub instructions
39   // (not all add and sub instructions). Visitors are listed by the macro
40   // `VISITOR_LIST` in aarch64/decoder-aarch64.h.
41 
42   virtual void VisitAddSubShifted(const vixl::aarch64::Instruction* instr)
43       VIXL_OVERRIDE;
44 
45 // Define the remaining visitors to do nothing.
46 #define UNUSED_VISITOR_LIST(V)          \
47   V(PCRelAddressing)                    \
48   V(AddSubImmediate)                    \
49   V(LogicalImmediate)                   \
50   V(MoveWideImmediate)                  \
51   V(Bitfield)                           \
52   V(Extract)                            \
53   V(UnconditionalBranch)                \
54   V(UnconditionalBranchToRegister)      \
55   V(CompareBranch)                      \
56   V(TestBranch)                         \
57   V(ConditionalBranch)                  \
58   V(System)                             \
59   V(Exception)                          \
60   V(RotateRightIntoFlags)               \
61   V(EvaluateIntoFlags)                  \
62   V(LoadStorePAC)                       \
63   V(LoadStorePairPostIndex)             \
64   V(LoadStorePairOffset)                \
65   V(LoadStorePairPreIndex)              \
66   V(LoadStorePairNonTemporal)           \
67   V(LoadStoreRCpcUnscaledOffset)        \
68   V(LoadLiteral)                        \
69   V(LoadStoreUnscaledOffset)            \
70   V(LoadStorePostIndex)                 \
71   V(LoadStorePreIndex)                  \
72   V(LoadStoreRegisterOffset)            \
73   V(LoadStoreUnsignedOffset)            \
74   V(LoadStoreExclusive)                 \
75   V(AtomicMemory)                       \
76   V(LogicalShifted)                     \
77   V(AddSubExtended)                     \
78   V(AddSubWithCarry)                    \
79   V(ConditionalCompareRegister)         \
80   V(ConditionalCompareImmediate)        \
81   V(ConditionalSelect)                  \
82   V(DataProcessing1Source)              \
83   V(DataProcessing2Source)              \
84   V(DataProcessing3Source)              \
85   V(FPCompare)                          \
86   V(FPConditionalCompare)               \
87   V(FPConditionalSelect)                \
88   V(FPImmediate)                        \
89   V(FPDataProcessing1Source)            \
90   V(FPDataProcessing2Source)            \
91   V(FPDataProcessing3Source)            \
92   V(FPIntegerConvert)                   \
93   V(FPFixedPointConvert)                \
94   V(Crypto2RegSHA)                      \
95   V(Crypto3RegSHA)                      \
96   V(CryptoAES)                          \
97   V(NEON2RegMisc)                       \
98   V(NEON2RegMiscFP16)                   \
99   V(NEON3Different)                     \
100   V(NEON3Same)                          \
101   V(NEON3SameFP16)                      \
102   V(NEONAcrossLanes)                    \
103   V(NEONByIndexedElement)               \
104   V(NEONCopy)                           \
105   V(NEONExtract)                        \
106   V(NEONLoadStoreMultiStruct)           \
107   V(NEONLoadStoreMultiStructPostIndex)  \
108   V(NEONLoadStoreSingleStruct)          \
109   V(NEONLoadStoreSingleStructPostIndex) \
110   V(NEONModifiedImmediate)              \
111   V(NEONScalar2RegMisc)                 \
112   V(NEONScalar2RegMiscFP16)             \
113   V(NEONScalar3Diff)                    \
114   V(NEONScalar3Same)                    \
115   V(NEONScalar3SameFP16)                \
116   V(NEONScalar3SameExtra)               \
117   V(NEON3SameExtra)                     \
118   V(NEONScalarByIndexedElement)         \
119   V(NEONScalarCopy)                     \
120   V(NEONScalarPairwise)                 \
121   V(NEONScalarShiftImmediate)           \
122   V(NEONShiftImmediate)                 \
123   V(NEONTable)                          \
124   V(NEONPerm)                           \
125   V(Reserved)                           \
126   V(Unallocated)                        \
127   V(Unimplemented)
128 #define DEFINE_UNUSED_VISITOR(Name)                                  \
129   virtual void Visit##Name(const vixl::aarch64::Instruction* i)      \
130       VIXL_OVERRIDE {                                                \
131     USE(i); /* Prevents compiler warnings about unused variables. */ \
132   }
133   UNUSED_VISITOR_LIST(DEFINE_UNUSED_VISITOR)
134 #undef DEFINE_UNUSED_VISITOR
135 #undef UNUSED_VISITOR_LIST
136 };
137 
138 
139 void GenerateNonConstVisitorTestCode(vixl::aarch64::MacroAssembler* masm);
140 
141 int64_t RunNonConstVisitorTestGeneratedCode(
142     const vixl::aarch64::Instruction* start_instr);
143 
144 void ModifyNonConstVisitorTestGeneratedCode(vixl::aarch64::Instruction* start,
145                                             vixl::aarch64::Instruction* end);
146 
147 
148 #endif
149