llvm.org GIT mirror llvm / 91d2cc9
Definition of function getMipsRegisterNumbering. Patch by Jack Carter and Reed Kotler at Mips. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141938 91177308-0d34-0410-b5e6-96231b3b80d8 Akira Hatanaka 9 years ago
1 changed file(s) with 113 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 //===-- MipsBaseInfo.h - Top level definitions for ARM ------- --*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains small standalone helper functions and enum definitions for
10 // the Mips target useful for the compiler back-end and the MC libraries.
11 //
12 //===----------------------------------------------------------------------===//
13 #ifndef MIPSBASEINFO_H
14 #define MIPSBASEINFO_H
15
16 #include "MipsMCTargetDesc.h"
17 #include "llvm/Support/DataTypes.h"
18 #include "llvm/Support/ErrorHandling.h"
19
20 namespace llvm {
21 /// getMipsRegisterNumbering - Given the enum value for some register,
22 /// return the number that it corresponds to.
23 inline static unsigned getMipsRegisterNumbering(unsigned RegEnum)
24 {
25 switch (RegEnum) {
26 case Mips::ZERO: case Mips::ZERO_64: case Mips::F0: case Mips::D0_64:
27 case Mips::D0:
28 return 0;
29 case Mips::AT: case Mips::AT_64: case Mips::F1: case Mips::D1_64:
30 return 1;
31 case Mips::V0: case Mips::V0_64: case Mips::F2: case Mips::D2_64:
32 case Mips::D1:
33 return 2;
34 case Mips::V1: case Mips::V1_64: case Mips::F3: case Mips::D3_64:
35 return 3;
36 case Mips::A0: case Mips::A0_64: case Mips::F4: case Mips::D4_64:
37 case Mips::D2:
38 return 4;
39 case Mips::A1: case Mips::A1_64: case Mips::F5: case Mips::D5_64:
40 return 5;
41 case Mips::A2: case Mips::A2_64: case Mips::F6: case Mips::D6_64:
42 case Mips::D3:
43 return 6;
44 case Mips::A3: case Mips::A3_64: case Mips::F7: case Mips::D7_64:
45 return 7;
46 case Mips::T0: case Mips::T0_64: case Mips::F8: case Mips::D8_64:
47 case Mips::D4:
48 return 8;
49 case Mips::T1: case Mips::T1_64: case Mips::F9: case Mips::D9_64:
50 return 9;
51 case Mips::T2: case Mips::T2_64: case Mips::F10: case Mips::D10_64:
52 case Mips::D5:
53 return 10;
54 case Mips::T3: case Mips::T3_64: case Mips::F11: case Mips::D11_64:
55 return 11;
56 case Mips::T4: case Mips::T4_64: case Mips::F12: case Mips::D12_64:
57 case Mips::D6:
58 return 12;
59 case Mips::T5: case Mips::T5_64: case Mips::F13: case Mips::D13_64:
60 return 13;
61 case Mips::T6: case Mips::T6_64: case Mips::F14: case Mips::D14_64:
62 case Mips::D7:
63 return 14;
64 case Mips::T7: case Mips::T7_64: case Mips::F15: case Mips::D15_64:
65 return 15;
66 case Mips::S0: case Mips::S0_64: case Mips::F16: case Mips::D16_64:
67 case Mips::D8:
68 return 16;
69 case Mips::S1: case Mips::S1_64: case Mips::F17: case Mips::D17_64:
70 return 17;
71 case Mips::S2: case Mips::S2_64: case Mips::F18: case Mips::D18_64:
72 case Mips::D9:
73 return 18;
74 case Mips::S3: case Mips::S3_64: case Mips::F19: case Mips::D19_64:
75 return 19;
76 case Mips::S4: case Mips::S4_64: case Mips::F20: case Mips::D20_64:
77 case Mips::D10:
78 return 20;
79 case Mips::S5: case Mips::S5_64: case Mips::F21: case Mips::D21_64:
80 return 21;
81 case Mips::S6: case Mips::S6_64: case Mips::F22: case Mips::D22_64:
82 case Mips::D11:
83 return 22;
84 case Mips::S7: case Mips::S7_64: case Mips::F23: case Mips::D23_64:
85 return 23;
86 case Mips::T8: case Mips::T8_64: case Mips::F24: case Mips::D24_64:
87 case Mips::D12:
88 return 24;
89 case Mips::T9: case Mips::T9_64: case Mips::F25: case Mips::D25_64:
90 return 25;
91 case Mips::K0: case Mips::K0_64: case Mips::F26: case Mips::D26_64:
92 case Mips::D13:
93 return 26;
94 case Mips::K1: case Mips::K1_64: case Mips::F27: case Mips::D27_64:
95 return 27;
96 case Mips::GP: case Mips::GP_64: case Mips::F28: case Mips::D28_64:
97 case Mips::D14:
98 return 28;
99 case Mips::SP: case Mips::SP_64: case Mips::F29: case Mips::D29_64:
100 return 29;
101 case Mips::FP: case Mips::FP_64: case Mips::F30: case Mips::D30_64:
102 case Mips::D15:
103 return 30;
104 case Mips::RA: case Mips::RA_64: case Mips::F31: case Mips::D31_64:
105 return 31;
106 default: llvm_unreachable("Unknown register number!");
107 }
108 return 0; // Not reached
109 }
110 }
111
112 #endif