blob: 66c6f8ebdd5472a5856a84af9d64a0324691779a [file] [log] [blame]
Akira Hatanakad9ea7c82011-10-14 03:04:24 +00001//===-- MipsBaseInfo.h - Top level definitions for ARM ------- --*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file contains small standalone helper functions and enum definitions for
11// the Mips target useful for the compiler back-end and the MC libraries.
12//
13//===----------------------------------------------------------------------===//
14#ifndef MIPSBASEINFO_H
15#define MIPSBASEINFO_H
16
17#include "MipsMCTargetDesc.h"
18#include "llvm/Support/DataTypes.h"
19#include "llvm/Support/ErrorHandling.h"
20
21namespace llvm {
Bruno Cardoso Lopesc85e3ff2011-11-11 22:58:42 +000022
23/// MipsII - This namespace holds all of the target specific flags that
24/// instruction info tracks.
25///
26namespace MipsII {
27 /// Target Operand Flag enum.
28 enum TOF {
29 //===------------------------------------------------------------------===//
30 // Mips Specific MachineOperand flags.
31
32 MO_NO_FLAG,
33
34 /// MO_GOT - Represents the offset into the global offset table at which
35 /// the address the relocation entry symbol resides during execution.
36 MO_GOT,
37
38 /// MO_GOT_CALL - Represents the offset into the global offset table at
39 /// which the address of a call site relocation entry symbol resides
40 /// during execution. This is different from the above since this flag
41 /// can only be present in call instructions.
42 MO_GOT_CALL,
43
44 /// MO_GPREL - Represents the offset from the current gp value to be used
45 /// for the relocatable object file being produced.
46 MO_GPREL,
47
48 /// MO_ABS_HI/LO - Represents the hi or low part of an absolute symbol
49 /// address.
50 MO_ABS_HI,
51 MO_ABS_LO,
52
53 /// MO_TLSGD - Represents the offset into the global offset table at which
54 // the module ID and TSL block offset reside during execution (General
55 // Dynamic TLS).
56 MO_TLSGD,
57
58 /// MO_GOTTPREL - Represents the offset from the thread pointer (Initial
59 // Exec TLS).
60 MO_GOTTPREL,
61
62 /// MO_TPREL_HI/LO - Represents the hi and low part of the offset from
63 // the thread pointer (Local Exec TLS).
64 MO_TPREL_HI,
65 MO_TPREL_LO,
66
67 // N32/64 Flags.
68 MO_GPOFF_HI,
69 MO_GPOFF_LO,
70 MO_GOT_DISP,
71 MO_GOT_PAGE,
72 MO_GOT_OFST
73 };
74
75 enum {
76 //===------------------------------------------------------------------===//
77 // Instruction encodings. These are the standard/most common forms for
78 // Mips instructions.
79 //
80
81 // Pseudo - This represents an instruction that is a pseudo instruction
82 // or one that has not been implemented yet. It is illegal to code generate
83 // it, but tolerated for intermediate implementation stages.
84 Pseudo = 0,
85
86 /// FrmR - This form is for instructions of the format R.
87 FrmR = 1,
88 /// FrmI - This form is for instructions of the format I.
89 FrmI = 2,
90 /// FrmJ - This form is for instructions of the format J.
91 FrmJ = 3,
92 /// FrmFR - This form is for instructions of the format FR.
93 FrmFR = 4,
94 /// FrmFI - This form is for instructions of the format FI.
95 FrmFI = 5,
96 /// FrmOther - This form is for instructions that have no specific format.
97 FrmOther = 6,
98
99 FormMask = 15
100 };
101}
102
103
Akira Hatanakad9ea7c82011-10-14 03:04:24 +0000104/// getMipsRegisterNumbering - Given the enum value for some register,
105/// return the number that it corresponds to.
106inline static unsigned getMipsRegisterNumbering(unsigned RegEnum)
107{
108 switch (RegEnum) {
109 case Mips::ZERO: case Mips::ZERO_64: case Mips::F0: case Mips::D0_64:
110 case Mips::D0:
111 return 0;
112 case Mips::AT: case Mips::AT_64: case Mips::F1: case Mips::D1_64:
113 return 1;
114 case Mips::V0: case Mips::V0_64: case Mips::F2: case Mips::D2_64:
115 case Mips::D1:
116 return 2;
117 case Mips::V1: case Mips::V1_64: case Mips::F3: case Mips::D3_64:
118 return 3;
119 case Mips::A0: case Mips::A0_64: case Mips::F4: case Mips::D4_64:
120 case Mips::D2:
121 return 4;
122 case Mips::A1: case Mips::A1_64: case Mips::F5: case Mips::D5_64:
123 return 5;
124 case Mips::A2: case Mips::A2_64: case Mips::F6: case Mips::D6_64:
125 case Mips::D3:
126 return 6;
127 case Mips::A3: case Mips::A3_64: case Mips::F7: case Mips::D7_64:
128 return 7;
129 case Mips::T0: case Mips::T0_64: case Mips::F8: case Mips::D8_64:
130 case Mips::D4:
131 return 8;
132 case Mips::T1: case Mips::T1_64: case Mips::F9: case Mips::D9_64:
133 return 9;
134 case Mips::T2: case Mips::T2_64: case Mips::F10: case Mips::D10_64:
135 case Mips::D5:
136 return 10;
137 case Mips::T3: case Mips::T3_64: case Mips::F11: case Mips::D11_64:
138 return 11;
139 case Mips::T4: case Mips::T4_64: case Mips::F12: case Mips::D12_64:
140 case Mips::D6:
141 return 12;
142 case Mips::T5: case Mips::T5_64: case Mips::F13: case Mips::D13_64:
143 return 13;
144 case Mips::T6: case Mips::T6_64: case Mips::F14: case Mips::D14_64:
145 case Mips::D7:
146 return 14;
147 case Mips::T7: case Mips::T7_64: case Mips::F15: case Mips::D15_64:
148 return 15;
149 case Mips::S0: case Mips::S0_64: case Mips::F16: case Mips::D16_64:
150 case Mips::D8:
151 return 16;
152 case Mips::S1: case Mips::S1_64: case Mips::F17: case Mips::D17_64:
153 return 17;
154 case Mips::S2: case Mips::S2_64: case Mips::F18: case Mips::D18_64:
155 case Mips::D9:
156 return 18;
157 case Mips::S3: case Mips::S3_64: case Mips::F19: case Mips::D19_64:
158 return 19;
159 case Mips::S4: case Mips::S4_64: case Mips::F20: case Mips::D20_64:
160 case Mips::D10:
161 return 20;
162 case Mips::S5: case Mips::S5_64: case Mips::F21: case Mips::D21_64:
163 return 21;
164 case Mips::S6: case Mips::S6_64: case Mips::F22: case Mips::D22_64:
165 case Mips::D11:
166 return 22;
167 case Mips::S7: case Mips::S7_64: case Mips::F23: case Mips::D23_64:
168 return 23;
169 case Mips::T8: case Mips::T8_64: case Mips::F24: case Mips::D24_64:
170 case Mips::D12:
171 return 24;
172 case Mips::T9: case Mips::T9_64: case Mips::F25: case Mips::D25_64:
173 return 25;
174 case Mips::K0: case Mips::K0_64: case Mips::F26: case Mips::D26_64:
175 case Mips::D13:
176 return 26;
177 case Mips::K1: case Mips::K1_64: case Mips::F27: case Mips::D27_64:
178 return 27;
179 case Mips::GP: case Mips::GP_64: case Mips::F28: case Mips::D28_64:
180 case Mips::D14:
181 return 28;
182 case Mips::SP: case Mips::SP_64: case Mips::F29: case Mips::D29_64:
Bruno Cardoso Lopes1b1a1222011-12-06 03:34:36 +0000183 case Mips::HWR29:
Akira Hatanakad9ea7c82011-10-14 03:04:24 +0000184 return 29;
185 case Mips::FP: case Mips::FP_64: case Mips::F30: case Mips::D30_64:
186 case Mips::D15:
187 return 30;
188 case Mips::RA: case Mips::RA_64: case Mips::F31: case Mips::D31_64:
189 return 31;
190 default: llvm_unreachable("Unknown register number!");
191 }
192 return 0; // Not reached
193}
194}
195
196#endif