thumb.isa revision 7155
11154SN/A// -*- mode:c++ -*-
21762SN/A
31154SN/A// Copyright (c) 2010 ARM Limited
41154SN/A// All rights reserved
51154SN/A//
61154SN/A// The license below extends only to copyright in the software and shall
71154SN/A// not be construed as granting a license to any other intellectual
81154SN/A// property including but not limited to intellectual property relating
91154SN/A// to a hardware implementation of the functionality of the software
101154SN/A// licensed hereunder.  You may use the software subject to the license
111154SN/A// terms below provided that you ensure that this notice is replicated
121154SN/A// unmodified and in its entirety in all distributions of the software,
131154SN/A// modified or unmodified, in source code or in binary form.
141154SN/A//
151154SN/A// Copyright (c) 2009 The Regents of The University of Michigan
161154SN/A// All rights reserved.
171154SN/A//
181154SN/A// Redistribution and use in source and binary forms, with or without
191154SN/A// modification, are permitted provided that the following conditions are
201154SN/A// met: redistributions of source code must retain the above copyright
211154SN/A// notice, this list of conditions and the following disclaimer;
221154SN/A// redistributions in binary form must reproduce the above copyright
231154SN/A// notice, this list of conditions and the following disclaimer in the
241154SN/A// documentation and/or other materials provided with the distribution;
251154SN/A// neither the name of the copyright holders nor the names of its
261154SN/A// contributors may be used to endorse or promote products derived from
272665SN/A// this software without specific prior written permission.
282665SN/A//
291154SN/A// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
301154SN/A// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3111263Sandreas.sandberg@arm.com// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3211263Sandreas.sandberg@arm.com// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
331154SN/A// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
341154SN/A// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
351154SN/A// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
361154SN/A// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
372186SN/A// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
386227SN/A// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
392186SN/A// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
402186SN/A//
412186SN/A// Authors: Gabe Black
422186SN/A
432186SN/A1: decode BIGTHUMB {
445483SN/A    // 16 bit thumb instructions.
455483SN/A    0: decode TOPCODE_15_13 {
462186SN/A        0x0, 0x1: Thumb16ShiftAddSubMoveCmp::thumb16ShiftAddMoveCmp();
475483SN/A        0x2: decode TOPCODE_12_10 {
485483SN/A            0x0: Thumb16DataProcessing::thumb16DataProcessing();
495483SN/A            0x1: Thumb16SpecDataAndBx::thumb16SpecDataAndBx();
505483SN/A            0x2, 0x3: Thumb16MemLit::thumb16MemLit();
512186SN/A            default: Thumb16MemReg::thumb16MemReg();
522186SN/A        }
535483SN/A        0x3, 0x4: Thumb16MemImm::thumb16MemImm();
542186SN/A        0x5: decode TOPCODE_12_11 {
552186SN/A            0x0: Thumb16Adr::thumb16Adr();
566227SN/A            0x1: Thumb16AddSp::thumb16AddSp(); //sp, immediate
575483SN/A            0x2, 0x3: Thumb16Misc::thumb16Misc();
582186SN/A        }
592186SN/A        0x6: decode TOPCODE_12_11 {
602186SN/A            0x0, 0x1: Thumb16MacroMem::thumb16MacroMem();
615483SN/A            0x2, 0x3: Thumb16CondBranchAndSvc::thumb16CondBranchAndSvc();
622186SN/A        }
632186SN/A        0x7: decode TOPCODE_12_11 {
642186SN/A            0x0: Thumb16UncondBranch::thumb16UncondBranch();
652186SN/A        }
662186SN/A    }
672186SN/A
681154SN/A    // 32 bit thumb instructions.
6910905SN/A    1: decode HTOPCODE_12_11 {
705483SN/A        0x1: decode HTOPCODE_10_9 {
7110905SN/A            0x0: decode HTOPCODE_8_6 {
7210905SN/A                0x0, 0x6: decode HTOPCODE_4 {
7310905SN/A                    0x0: WarnUnimpl::srs();
7410905SN/A                    0x1: WarnUnimpl::rfe();
755483SN/A                }
765483SN/A                0x1: decode HTOPCODE_5_4 {
775483SN/A                    0x0: WarnUnimpl::strex();
7810905SN/A                    0x1: WarnUnimpl::ldrex();
795483SN/A                    0x2: WarnUnimpl::strd(); // immediate
8010469SN/A                    0x3: decode HTRN {
8110905SN/A                        0xf: WarnUnimpl::ldrd(); // literal
8210905SN/A                        default: WarnUnimpl::ldrd(); // immediate
8310905SN/A                    }
8410905SN/A                }
855483SN/A                // This uses the same encoding as regular ARM.
865483SN/A                0x2: ArmMacroMem::armMacroMem();
875483SN/A                0x3: decode HTOPCODE_5_4 {
8810905SN/A                    0x0: decode LTOPCODE_7_4 {
891154SN/A                        0x4: WarnUnimpl::strexb();
9010905SN/A                        0x5: WarnUnimpl::strexh();
9110905SN/A                        0x7: WarnUnimpl::strexd();
9210905SN/A                    }
9310905SN/A                    0x1: decode LTOPCODE_7_4 {
941154SN/A                        0x0: WarnUnimpl::tbb();
951154SN/A                        0x1: WarnUnimpl::tbh();
9610905SN/A                        0x4: WarnUnimpl::ldrexb();
9710905SN/A                        0x5: WarnUnimpl::ldrexh();
981154SN/A                        0x7: WarnUnimpl::ldrexd();
991154SN/A                    }
1001154SN/A                    0x2: WarnUnimpl::strd(); // immediate
10110905SN/A                    0x3: decode HTRN {
1021154SN/A                        0xf: WarnUnimpl::ldrd(); // literal
10310905SN/A                        default: WarnUnimpl::ldrd(); // immediate
10410905SN/A                    }
10510905SN/A                }
1061154SN/A                // This uses the same encoding as regular ARM.
10710905SN/A                0x4: ArmMacroMem::armMacroMem();
1081154SN/A                0x5, 0x7: decode HTOPCODE_4 {
1091154SN/A                    0x0: WarnUnimpl::strd(); // immediate
1101154SN/A                    0x1: decode HTRN {
1111154SN/A                        0xf: WarnUnimpl::ldrd(); // literal
1125483SN/A                        default: WarnUnimpl::ldrd(); // immediate
11310905SN/A                    }
1145483SN/A                }
1151154SN/A            }
1161154SN/A            0x1: Thumb32DataProcShiftReg::thumb32DataProcShiftReg();
117            default: decode HTOPCODE_9_8 {
118                0x2: decode LTOPCODE_4 {
119                    0x0: decode LTCOPROC {
120                        0xa, 0xb: decode OPCODE_23_20 {
121##include "vfp.isa"
122                        }
123                        default: WarnUnimpl::cdp(); // cdp2
124                    }
125                    0x1: decode LTCOPROC {
126                        0xa, 0xb: WarnUnimpl::Core_to_extension_transfer();
127                        default: decode HTOPCODE_4 {
128                            0x0: WarnUnimpl::mcr(); // mcr2
129                            0x1: WarnUnimpl::mrc(); // mrc2
130                        }
131                    }
132                }
133                0x3: WarnUnimpl::Advanced_SIMD();
134                default: decode LTCOPROC {
135                    0xa, 0xb: decode HTOPCODE_9_4 {
136                        0x00: WarnUnimpl::undefined();
137                        0x04: WarnUnimpl::mcrr(); // mcrr2
138                        0x05: WarnUnimpl::mrrc(); // mrrc2
139                        0x02, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10,
140                        0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e:
141                            WarnUnimpl::stc(); // stc2
142                        0x03, 0x07, 0x09, 0x0b, 0x0d, 0x0f, 0x11,
143                        0x13, 0x15, 0x17, 0x19, 0x1b, 0x1d, 0x1f:
144                            decode HTRN {
145                                0xf: WarnUnimpl::ldc(); // ldc2 (literal)
146                                default: WarnUnimpl::ldc(); // ldc2 (immediate)
147                            }
148                    }
149                    default: decode HTOPCODE_9_5 {
150                        0x00: WarnUnimpl::undefined();
151                        0x02: WarnUnimpl::SIMD_VFP_64_bit_core_extension_transfer();
152                        0x01, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
153                        0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f:
154                            WarnUnimpl::Extension_register_load_store_instruction();
155                    }
156                }
157            }
158        }
159        0x2: decode LTOPCODE_15 {
160            0x0: decode HTOPCODE_9 {
161                0x0: Thumb32DataProcModImm::thumb32DataProcModImm();
162                0x1: WarnUnimpl::Data_processing_plain_binary_immediate();
163            }
164            0x1: Thumb32BranchesAndMiscCtrl::thumb32BranchesAndMiscCtrl();
165        }
166        0x3: decode HTOPCODE_10_9 {
167            0x0: decode HTOPCODE_4 {
168                0x0: decode HTOPCODE_8 {
169                    0x0: Thumb32StoreSingle::thumb32StoreSingle();
170                    0x1: WarnUnimpl::Advanced_SIMD_or_structure_load_store();
171                }
172                0x1: decode HTOPCODE_6_5 {
173                    0x0: WarnUnimpl::Load_byte_memory_hints();
174                    0x1: WarnUnimpl::Load_halfword_memory_hints();
175                    0x2: Thumb32LoadWord::thumb32LoadWord();
176                    0x3: WarnUnimpl::undefined();
177                }
178            }
179            0x1: decode HTOPCODE_8_7 {
180                0x2: WarnUnimpl::Multiply_multiply_accumulate_and_absolute_difference();
181                0x3: WarnUnimpl::Long_multiply_long_multiply_accumulate_and_divide();
182                default: WarnUnimpl::Data_processing_register();
183            }
184            default: decode HTOPCODE_9_8 {
185                0x2: decode LTOPCODE_4 {
186                    0x0: decode LTCOPROC {
187                        0xa, 0xb: WarnUnimpl::VFP_Inst();
188                        default: WarnUnimpl::cdp(); // cdp2
189                    }
190                    0x1: decode LTCOPROC {
191                        0xa, 0xb: WarnUnimpl::Core_to_extension_transfer();
192                        default: decode HTOPCODE_4 {
193                            0x0: WarnUnimpl::mcr(); // mcr2
194                            0x1: WarnUnimpl::mrc(); // mrc2
195                        }
196                    }
197                }
198                0x3: WarnUnimpl::Advanced_SIMD();
199                default: decode LTCOPROC {
200                    0xa, 0xb: decode HTOPCODE_9_4 {
201                        0x00: WarnUnimpl::undefined();
202                        0x04: WarnUnimpl::mcrr(); // mcrr2
203                        0x05: WarnUnimpl::mrrc(); // mrrc2
204                        0x02, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10,
205                        0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e:
206                            WarnUnimpl::stc(); // stc2
207                        0x03, 0x07, 0x09, 0x0b, 0x0d, 0x0f, 0x11,
208                        0x13, 0x15, 0x17, 0x19, 0x1b, 0x1d, 0x1f:
209                            decode HTRN {
210                                0xf: WarnUnimpl::ldc(); // ldc2 (literal)
211                                default: WarnUnimpl::ldc(); // ldc2 (immediate)
212                            }
213                    }
214                    default: decode HTOPCODE_9_5 {
215                        0x00: WarnUnimpl::undefined();
216                        0x02: WarnUnimpl::SIMD_VFP_64_bit_core_extension_transfer();
217                        0x01, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
218                        0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f:
219                            WarnUnimpl::Extension_register_load_store_instruction();
220                    }
221                }
222            }
223        }
224    }
225}
226