Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: src/IceAssemblerMIPS32.h

Issue 2446273003: [SubZero] Generate relocations for MIPS (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Addressed review comments Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/IceAssemblerMIPS32.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceAssemblerMIPS32.h - Assembler for MIPS ----*- C++ -*-===// 1 //===- subzero/src/IceAssemblerMIPS32.h - Assembler for MIPS ----*- C++ -*-===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 /// 9 ///
10 /// \file 10 /// \file
(...skipping 16 matching lines...) Expand all
27 using IValueT = uint32_t; 27 using IValueT = uint32_t;
28 using IOffsetT = int32_t; 28 using IOffsetT = int32_t;
29 29
30 enum FPInstDataFormat { 30 enum FPInstDataFormat {
31 SinglePrecision = 16, 31 SinglePrecision = 16,
32 DoublePrecision = 17, 32 DoublePrecision = 17,
33 Word = 20, 33 Word = 20,
34 Long = 21 34 Long = 21
35 }; 35 };
36 36
37 class MIPS32Fixup final : public AssemblerFixup {
38 MIPS32Fixup &operator=(const MIPS32Fixup &) = delete;
39 MIPS32Fixup(const MIPS32Fixup &) = default;
40
41 public:
42 MIPS32Fixup() = default;
43 size_t emit(GlobalContext *Ctx, const Assembler &Asm) const final;
44 void emitOffset(Assembler *Asm) const;
45 };
46
37 class AssemblerMIPS32 : public Assembler { 47 class AssemblerMIPS32 : public Assembler {
38 AssemblerMIPS32(const AssemblerMIPS32 &) = delete; 48 AssemblerMIPS32(const AssemblerMIPS32 &) = delete;
39 AssemblerMIPS32 &operator=(const AssemblerMIPS32 &) = delete; 49 AssemblerMIPS32 &operator=(const AssemblerMIPS32 &) = delete;
40 50
41 public: 51 public:
42 explicit AssemblerMIPS32(bool use_far_branches = false) 52 explicit AssemblerMIPS32(bool use_far_branches = false)
43 : Assembler(Asm_MIPS32) { 53 : Assembler(Asm_MIPS32) {
44 // This mode is only needed and implemented for MIPS32 and ARM. 54 // This mode is only needed and implemented for MIPS32 and ARM.
45 assert(!use_far_branches); 55 assert(!use_far_branches);
46 (void)use_far_branches; 56 (void)use_far_branches;
47 } 57 }
48 ~AssemblerMIPS32() override { 58 ~AssemblerMIPS32() override {
49 if (BuildDefs::asserts()) { 59 if (BuildDefs::asserts()) {
50 for (const Label *Label : CfgNodeLabels) { 60 for (const Label *Label : CfgNodeLabels) {
51 Label->finalCheck(); 61 Label->finalCheck();
52 } 62 }
53 for (const Label *Label : LocalLabels) { 63 for (const Label *Label : LocalLabels) {
54 Label->finalCheck(); 64 Label->finalCheck();
55 } 65 }
56 } 66 }
57 } 67 }
58 68
69 MIPS32Fixup *createMIPS32Fixup(const RelocOp Reloc, const Constant *RelOp);
70
59 void trap(); 71 void trap();
60 72
61 void nop(); 73 void nop();
62 74
63 void emitRsRt(IValueT Opcode, const Operand *OpRs, const Operand *OpRt, 75 void emitRsRt(IValueT Opcode, const Operand *OpRs, const Operand *OpRt,
64 const char *InsnName); 76 const char *InsnName);
65 77
66 void emitRtRsImm16(IValueT Opcode, const Operand *OpRt, const Operand *OpRs, 78 void emitRtRsImm16(IValueT Opcode, const Operand *OpRt, const Operand *OpRs,
67 uint32_t Imm, const char *InsnName); 79 uint32_t Imm, const char *InsnName);
68 80
81 void emitRtRsImm16Rel(IValueT Opcode, const Operand *OpRt,
82 const Operand *OpRs, const Operand *OpImm,
83 const RelocOp Reloc, const char *InsnName);
84
69 void emitFtRsImm16(IValueT Opcode, const Operand *OpFt, const Operand *OpRs, 85 void emitFtRsImm16(IValueT Opcode, const Operand *OpFt, const Operand *OpRs,
70 uint32_t Imm, const char *InsnName); 86 uint32_t Imm, const char *InsnName);
71 87
72 void emitRdRtSa(IValueT Opcode, const Operand *OpRd, const Operand *OpRt, 88 void emitRdRtSa(IValueT Opcode, const Operand *OpRd, const Operand *OpRt,
73 uint32_t Sa, const char *InsnName); 89 uint32_t Sa, const char *InsnName);
74 90
75 void emitRdRsRt(IValueT Opcode, const Operand *OpRd, const Operand *OpRs, 91 void emitRdRsRt(IValueT Opcode, const Operand *OpRd, const Operand *OpRs,
76 const Operand *OpRt, const char *InsnName); 92 const Operand *OpRt, const char *InsnName);
77 93
78 void emitCOP1Fcmp(IValueT Opcode, FPInstDataFormat Format, 94 void emitCOP1Fcmp(IValueT Opcode, FPInstDataFormat Format,
(...skipping 15 matching lines...) Expand all
94 void emitCOP1MovRtFs(IValueT Opcode, const Operand *OpRt, const Operand *OpFs, 110 void emitCOP1MovRtFs(IValueT Opcode, const Operand *OpRt, const Operand *OpFs,
95 const char *InsnName); 111 const char *InsnName);
96 112
97 void emitBr(const CondMIPS32::Cond Cond, const Operand *OpRs, 113 void emitBr(const CondMIPS32::Cond Cond, const Operand *OpRs,
98 const Operand *OpRt, IOffsetT Offset); 114 const Operand *OpRt, IOffsetT Offset);
99 115
100 void abs_d(const Operand *OpFd, const Operand *OpFs); 116 void abs_d(const Operand *OpFd, const Operand *OpFs);
101 117
102 void abs_s(const Operand *OpFd, const Operand *OpFs); 118 void abs_s(const Operand *OpFd, const Operand *OpFs);
103 119
120 void addi(const Operand *OpRt, const Operand *OpRs, const uint32_t Imm);
121
104 void add_d(const Operand *OpFd, const Operand *OpFs, const Operand *OpFt); 122 void add_d(const Operand *OpFd, const Operand *OpFs, const Operand *OpFt);
105 123
106 void add_s(const Operand *OpFd, const Operand *OpFs, const Operand *OpFt); 124 void add_s(const Operand *OpFd, const Operand *OpFs, const Operand *OpFt);
107 125
108 void addu(const Operand *OpRd, const Operand *OpRs, const Operand *OpRt); 126 void addu(const Operand *OpRd, const Operand *OpRs, const Operand *OpRt);
109 127
110 void addiu(const Operand *OpRt, const Operand *OpRs, const uint32_t Imm); 128 void addiu(const Operand *OpRt, const Operand *OpRs, const uint32_t Imm);
111 129
130 void addiu(const Operand *OpRt, const Operand *OpRs, const Operand *OpImm,
131 const RelocOp Reloc);
132
112 void and_(const Operand *OpRd, const Operand *OpRs, const Operand *OpRt); 133 void and_(const Operand *OpRd, const Operand *OpRs, const Operand *OpRt);
113 134
114 void andi(const Operand *OpRt, const Operand *OpRs, const uint32_t Imm); 135 void andi(const Operand *OpRt, const Operand *OpRs, const uint32_t Imm);
115 136
116 void b(Label *TargetLabel); 137 void b(Label *TargetLabel);
117 138
118 void c_eq_d(const Operand *OpFd, const Operand *OpFs); 139 void c_eq_d(const Operand *OpFd, const Operand *OpFs);
119 140
120 void c_eq_s(const Operand *OpFd, const Operand *OpFs); 141 void c_eq_s(const Operand *OpFd, const Operand *OpFs);
121 142
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 void cvt_s_w(const Operand *OpFd, const Operand *OpFs); 179 void cvt_s_w(const Operand *OpFd, const Operand *OpFs);
159 180
160 void div(const Operand *OpRs, const Operand *OpRt); 181 void div(const Operand *OpRs, const Operand *OpRt);
161 182
162 void div_d(const Operand *OpFd, const Operand *OpFs, const Operand *OpFt); 183 void div_d(const Operand *OpFd, const Operand *OpFs, const Operand *OpFt);
163 184
164 void div_s(const Operand *OpFd, const Operand *OpFs, const Operand *OpFt); 185 void div_s(const Operand *OpFd, const Operand *OpFs, const Operand *OpFt);
165 186
166 void divu(const Operand *OpRs, const Operand *OpRt); 187 void divu(const Operand *OpRs, const Operand *OpRt);
167 188
168 void lui(const Operand *OpRt, const uint16_t Imm); 189 void jal(const ConstantRelocatable *Target);
190
191 void lui(const Operand *OpRt, const Operand *OpImm, const RelocOp Reloc);
192
193 void ldc1(const Operand *OpRt, const Operand *OpBase, const Operand *OpOff,
194 const RelocOp Reloc);
169 195
170 void lw(const Operand *OpRt, const Operand *OpBase, const uint32_t Offset); 196 void lw(const Operand *OpRt, const Operand *OpBase, const uint32_t Offset);
171 197
198 void lwc1(const Operand *OpRt, const Operand *OpBase, const Operand *OpOff,
199 const RelocOp Reloc);
200
172 void mfc1(const Operand *OpRt, const Operand *OpFs); 201 void mfc1(const Operand *OpRt, const Operand *OpFs);
173 202
174 void mfhi(const Operand *OpRd); 203 void mfhi(const Operand *OpRd);
175 204
176 void mflo(const Operand *OpRd); 205 void mflo(const Operand *OpRd);
177 206
178 void mov_d(const Operand *OpFd, const Operand *OpFs); 207 void mov_d(const Operand *OpFd, const Operand *OpFs);
179 208
180 void mov_s(const Operand *OpFd, const Operand *OpFs); 209 void mov_s(const Operand *OpFd, const Operand *OpFs);
181 210
(...skipping 20 matching lines...) Expand all
202 void mthi(const Operand *OpRs); 231 void mthi(const Operand *OpRs);
203 232
204 void mtlo(const Operand *OpRs); 233 void mtlo(const Operand *OpRs);
205 234
206 void mul(const Operand *OpRd, const Operand *OpRs, const Operand *OpRt); 235 void mul(const Operand *OpRd, const Operand *OpRs, const Operand *OpRt);
207 236
208 void mul_d(const Operand *OpFd, const Operand *OpFs, const Operand *OpFt); 237 void mul_d(const Operand *OpFd, const Operand *OpFs, const Operand *OpFt);
209 238
210 void mul_s(const Operand *OpFd, const Operand *OpFs, const Operand *OpFt); 239 void mul_s(const Operand *OpFd, const Operand *OpFs, const Operand *OpFt);
211 240
241 void mult(const Operand *OpRs, const Operand *OpRt);
242
212 void multu(const Operand *OpRs, const Operand *OpRt); 243 void multu(const Operand *OpRs, const Operand *OpRt);
213 244
214 void nor(const Operand *OpRd, const Operand *OpRs, const Operand *OpRt); 245 void nor(const Operand *OpRd, const Operand *OpRs, const Operand *OpRt);
215 246
216 void or_(const Operand *OpRd, const Operand *OpRs, const Operand *OpRt); 247 void or_(const Operand *OpRd, const Operand *OpRs, const Operand *OpRt);
217 248
218 void ori(const Operand *OpRt, const Operand *OpRs, const uint32_t Imm); 249 void ori(const Operand *OpRt, const Operand *OpRs, const uint32_t Imm);
219 250
220 void ret(void); 251 void ret(void);
221 252
(...skipping 20 matching lines...) Expand all
242 void srl(const Operand *OpRd, const Operand *OpRt, const uint32_t Sa); 273 void srl(const Operand *OpRd, const Operand *OpRt, const uint32_t Sa);
243 274
244 void srlv(const Operand *OpRd, const Operand *OpRt, const Operand *OpRs); 275 void srlv(const Operand *OpRd, const Operand *OpRt, const Operand *OpRs);
245 276
246 void sub_d(const Operand *OpFd, const Operand *OpFs, const Operand *OpFt); 277 void sub_d(const Operand *OpFd, const Operand *OpFs, const Operand *OpFt);
247 278
248 void sub_s(const Operand *OpFd, const Operand *OpFs, const Operand *OpFt); 279 void sub_s(const Operand *OpFd, const Operand *OpFs, const Operand *OpFt);
249 280
250 void subu(const Operand *OpRd, const Operand *OpRs, const Operand *OpRt); 281 void subu(const Operand *OpRd, const Operand *OpRs, const Operand *OpRt);
251 282
283 void sdc1(const Operand *OpRt, const Operand *OpBase, const Operand *OpOff,
284 const RelocOp Reloc);
285
252 void sw(const Operand *OpRt, const Operand *OpBase, const uint32_t Offset); 286 void sw(const Operand *OpRt, const Operand *OpBase, const uint32_t Offset);
253 287
288 void swc1(const Operand *OpRt, const Operand *OpBase, const Operand *OpOff,
289 const RelocOp Reloc);
290
254 void teq(const Operand *OpRs, const Operand *OpRt, const uint32_t TrapCode); 291 void teq(const Operand *OpRs, const Operand *OpRt, const uint32_t TrapCode);
255 292
256 void trunc_l_d(const Operand *OpFd, const Operand *OpFs); 293 void trunc_l_d(const Operand *OpFd, const Operand *OpFs);
257 294
258 void trunc_l_s(const Operand *OpFd, const Operand *OpFs); 295 void trunc_l_s(const Operand *OpFd, const Operand *OpFs);
259 296
260 void trunc_w_d(const Operand *OpFd, const Operand *OpFs); 297 void trunc_w_d(const Operand *OpFd, const Operand *OpFs);
261 298
262 void trunc_w_s(const Operand *OpFd, const Operand *OpFs); 299 void trunc_w_s(const Operand *OpFd, const Operand *OpFs);
263 300
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 constexpr SizeT InstSize = 0; 349 constexpr SizeT InstSize = 0;
313 emitTextInst(InstL->getLabelName() + ":", InstSize); 350 emitTextInst(InstL->getLabelName() + ":", InstSize);
314 } 351 }
315 Label *L = getOrCreateLocalLabel(Number); 352 Label *L = getOrCreateLocalLabel(Number);
316 if (!getPreliminary()) 353 if (!getPreliminary())
317 this->bind(L); 354 this->bind(L);
318 } 355 }
319 356
320 bool fixupIsPCRel(FixupKind Kind) const override { 357 bool fixupIsPCRel(FixupKind Kind) const override {
321 (void)Kind; 358 (void)Kind;
322 llvm::report_fatal_error("Not yet implemented."); 359 return false;
323 } 360 }
324 361
325 static bool classof(const Assembler *Asm) { 362 static bool classof(const Assembler *Asm) {
326 return Asm->getKind() == Asm_MIPS32; 363 return Asm->getKind() == Asm_MIPS32;
327 } 364 }
328 365
329 private: 366 private:
330 ENABLE_MAKE_UNIQUE; 367 ENABLE_MAKE_UNIQUE;
331 368
332 using LabelVector = std::vector<Label *>; 369 using LabelVector = std::vector<Label *>;
(...skipping 10 matching lines...) Expand all
343 void emitInst(IValueT Value) { 380 void emitInst(IValueT Value) {
344 AssemblerBuffer::EnsureCapacity _(&Buffer); 381 AssemblerBuffer::EnsureCapacity _(&Buffer);
345 Buffer.emit<IValueT>(Value); 382 Buffer.emit<IValueT>(Value);
346 } 383 }
347 }; 384 };
348 385
349 } // end of namespace MIPS32 386 } // end of namespace MIPS32
350 } // end of namespace Ice 387 } // end of namespace Ice
351 388
352 #endif // SUBZERO_SRC_ICEASSEMBLERMIPS32_H 389 #endif // SUBZERO_SRC_ICEASSEMBLERMIPS32_H
OLDNEW
« no previous file with comments | « no previous file | src/IceAssemblerMIPS32.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698