1// -*- mode:c++ -*-
2
3// Copyright (c) 2010-2012 ARM Limited
4// All rights reserved
5//
6// The license below extends only to copyright in the software and shall
7// not be construed as granting a license to any other intellectual
8// property including but not limited to intellectual property relating
9// to a hardware implementation of the functionality of the software
10// licensed hereunder.  You may use the software subject to the license
11// terms below provided that you ensure that this notice is replicated
12// unmodified and in its entirety in all distributions of the software,
13// modified or unmodified, in source code or in binary form.
14//
15// Copyright (c) 2009 The Regents of The University of Michigan
16// All rights reserved.
17//
18// Redistribution and use in source and binary forms, with or without
19// modification, are permitted provided that the following conditions are
20// met: redistributions of source code must retain the above copyright
21// notice, this list of conditions and the following disclaimer;
22// redistributions in binary form must reproduce the above copyright
23// notice, this list of conditions and the following disclaimer in the
24// documentation and/or other materials provided with the distribution;
25// neither the name of the copyright holders nor the names of its
26// contributors may be used to endorse or promote products derived from
27// this software without specific prior written permission.
28//
29// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40//
41// Authors: Gabe Black
42
43decode BIGTHUMB {
44    // 16 bit thumb instructions.
45    0: decode TOPCODE_15_13 {
46        0x0, 0x1: Thumb16ShiftAddSubMoveCmp::thumb16ShiftAddMoveCmp();
47        0x2: decode TOPCODE_12_10 {
48            0x0: Thumb16DataProcessing::thumb16DataProcessing();
49            0x1: Thumb16SpecDataAndBx::thumb16SpecDataAndBx();
50            0x2, 0x3: Thumb16MemLit::thumb16MemLit();
51            default: Thumb16MemReg::thumb16MemReg();
52        }
53        0x3, 0x4: Thumb16MemImm::thumb16MemImm();
54        0x5: decode TOPCODE_12_11 {
55            0x0: Thumb16Adr::thumb16Adr();
56            0x1: Thumb16AddSp::thumb16AddSp(); //sp, immediate
57            0x2, 0x3: Thumb16Misc::thumb16Misc();
58        }
59        0x6: decode TOPCODE_12_11 {
60            0x0, 0x1: Thumb16MacroMem::thumb16MacroMem();
61            0x2, 0x3: Thumb16CondBranchAndSvc::thumb16CondBranchAndSvc();
62        }
63        0x7: decode TOPCODE_12_11 {
64            0x0: Thumb16UncondBranch::thumb16UncondBranch();
65        }
66    }
67
68    // 32 bit thumb instructions.
69    1: decode HTOPCODE_12_11 {
70        0x1: decode HTOPCODE_10_9 {
71            0x0: decode HTOPCODE_6 {
72                0x0: decode HTOPCODE_8_7 {
73                    0x0, 0x3: Thumb32SrsRfe::thumb32SrsRfe();
74                    // This uses the same encoding as regular ARM.
75                    default: ArmMacroMem::armMacroMem();
76                }
77                0x1: Thumb32LdrStrDExTbh::thumb32LdrStrDExTbh();
78            }
79            0x1: Thumb32DataProcShiftReg::thumb32DataProcShiftReg();
80            default: decode HTOPCODE_9_8 {
81                0x2: decode LTOPCODE_4 {
82                    0x0: decode LTCOPROC {
83                        0xa, 0xb: VfpData::vfpData();
84                        default: WarnUnimpl::cdp(); // cdp2
85                    }
86                    0x1: decode LTCOPROC {
87                        0x1: M5ops::m5ops();
88                        0xa, 0xb: ShortFpTransfer::shortFpTransfer();
89                        0xe: McrMrc14::mcrMrc14();
90                        0xf: McrMrc15::mcrMrc15();
91                    }
92                }
93                0x3: ThumbNeonData::ThumbNeonData();
94                default: decode LTCOPROC {
95                    0xa, 0xb: ExtensionRegLoadStore::extensionRegLoadStre();
96                    0xf: decode HTOPCODE_9_4 {
97                        0x00: Unknown::undefined();
98                        0x04: decode LTCOPROC {
99                            0xf: Mcrr15::Mcrr15();
100                            default: WarnUnimpl::mcrr(); // mcrr2
101                        }
102                        0x05: decode LTCOPROC {
103                            0xf: Mrrc15::Mrrc15();
104                            default: WarnUnimpl::mrrc(); // mrrc2
105                        }
106                        0x02, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10,
107                        0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e:
108                            WarnUnimpl::stc(); // stc2
109                        0x03, 0x07, 0x09, 0x0b, 0x0d, 0x0f, 0x11,
110                        0x13, 0x15, 0x17, 0x19, 0x1b, 0x1d, 0x1f:
111                            decode HTRN {
112                                0xf: WarnUnimpl::ldc(); // ldc2 (literal)
113                                default: WarnUnimpl::ldc(); // ldc2 (immediate)
114                            }
115                    }
116                }
117            }
118        }
119        0x2: decode LTOPCODE_15 {
120            0x0: decode HTOPCODE_9 {
121                0x0: Thumb32DataProcModImm::thumb32DataProcModImm();
122                0x1: Thumb32DataProcPlainBin::thumb32DataProcPlainBin();
123            }
124            0x1: Thumb32BranchesAndMiscCtrl::thumb32BranchesAndMiscCtrl();
125        }
126        0x3: decode HTOPCODE_10_9 {
127            0x0: decode HTOPCODE_4 {
128                0x0: decode HTOPCODE_8 {
129                    0x0: Thumb32StoreSingle::thumb32StoreSingle();
130                    0x1: ThumbNeonMem::thumbNeonMem();
131                }
132                0x1: decode HTOPCODE_6_5 {
133                    0x0: LoadByteMemoryHints::loadByteMemoryHints();
134                    0x1: LoadHalfwordMemoryHints::loadHalfwordMemoryHints();
135                    0x2: Thumb32LoadWord::thumb32LoadWord();
136                }
137            }
138            0x1: decode HTOPCODE_8_7 {
139                0x2: Thumb32MulMulAccAndAbsDiff::thumb32MulMulAccAndAbsDiff();
140                0x3: Thumb32LongMulMulAccAndDiv::thumb32LongMulMulAccAndDiv();
141                default: Thumb32DataProcReg::thumb32DataProcReg();
142            }
143            default: decode HTOPCODE_9_8 {
144                0x2: decode LTOPCODE_4 {
145                    0x0: decode LTCOPROC {
146                        0xa, 0xb: VfpData::vfpData();
147                        default: WarnUnimpl::cdp(); // cdp2
148                    }
149                    0x1: decode LTCOPROC {
150                        0x1: M5ops::m5ops();
151                        0xa, 0xb: ShortFpTransfer::shortFpTransfer();
152                        0xe: McrMrc14::mcrMrc14();
153                        0xf: McrMrc15::mcrMrc15();
154                    }
155                }
156                0x3: ThumbNeonData::thumbNeonData();
157                default: decode LTCOPROC {
158                    0xa, 0xb: ExtensionRegLoadStore::extensionRegLoadStre();
159                    0xf: decode HTOPCODE_9_4 {
160                        0x00: Unknown::undefined();
161                        0x04: WarnUnimpl::mcrr(); // mcrr2
162                        0x05: WarnUnimpl::mrrc(); // mrrc2
163                        0x02, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10,
164                        0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e:
165                            WarnUnimpl::stc(); // stc2
166                        0x03, 0x07, 0x09, 0x0b, 0x0d, 0x0f, 0x11,
167                        0x13, 0x15, 0x17, 0x19, 0x1b, 0x1d, 0x1f:
168                            decode HTRN {
169                                0xf: WarnUnimpl::ldc(); // ldc2 (literal)
170                                default: WarnUnimpl::ldc(); // ldc2 (immediate)
171                            }
172                    }
173                }
174            }
175        }
176    }
177}
178