1 : /*
2 : * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 : * Use of this source code is governed by a BSD-style license that can be
4 : * found in the LICENSE file.
5 : */
6 :
7 : #include "native_client/src/trusted/validator_arm/model.h"
8 :
9 : namespace nacl_arm_dec {
10 :
11 0 : const char* Register::ToString() const {
12 : static const char* Name[17] = {
13 : "r0",
14 : "r1",
15 : "r2",
16 : "r3",
17 : "r4",
18 : "r5",
19 : "r6",
20 : "r7",
21 : "r8",
22 : "r9",
23 : "r10",
24 : "r11",
25 : "r12",
26 : "sp",
27 : "lr",
28 : "pc",
29 : "APSR.NZCV",
30 : };
31 0 : Number n = number();
32 0 : return (n < NACL_ARRAY_SIZE(Name)) ? Name[n] : "r?";
33 0 : }
34 :
35 0 : const char* Instruction::ToString(Instruction::Condition cond) {
36 : static const char conditions[] =
37 : "eq\0\0ne\0\0cs\0\0cc\0\0mi\0\0pl\0\0vs\0\0vc\0\0"
38 : "hi\0\0ls\0\0ge\0\0lt\0\0gt\0\0le\0\0al";
39 : static const size_t offset_to_null_char = 2;
40 0 : size_t offset = static_cast<size_t>(cond) << 2;
41 0 : return conditions + ((cond <= AL) ? offset : offset_to_null_char);
42 0 : }
43 :
44 0 : Register::Number RegisterList::SmallestGPR() const {
45 0 : if (numGPRs() == 0) return Register::kNone;
46 : return static_cast<Register::Number>(
47 0 : nacl::CountTrailingZeroes(bits_ & Register::kGprMask));
48 0 : }
49 :
50 : } // namespace nacl_arm_dec
|