OLD | NEW |
---|---|
1 //===- subzero/src/IceInstMIPS32.h - MIPS32 machine instrs --*- C++ -*-=== // | 1 //===- subzero/src/IceInstMIPS32.h - MIPS32 machine instrs --*- 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 InstMIPS32(const InstMIPS32 &) = delete; | 114 InstMIPS32(const InstMIPS32 &) = delete; |
115 InstMIPS32 &operator=(const InstMIPS32 &) = delete; | 115 InstMIPS32 &operator=(const InstMIPS32 &) = delete; |
116 | 116 |
117 public: | 117 public: |
118 enum InstKindMIPS32 { | 118 enum InstKindMIPS32 { |
119 k__Start = Inst::Target, | 119 k__Start = Inst::Target, |
120 Add, | 120 Add, |
121 Addu, | 121 Addu, |
122 And, | 122 And, |
123 Addiu, | 123 Addiu, |
124 Br, | |
124 Call, | 125 Call, |
125 La, | 126 La, |
127 Label, | |
126 Lui, | 128 Lui, |
127 Mfhi, | 129 Mfhi, |
128 Mflo, | 130 Mflo, |
129 Mov, // actually a pseudo op for addi rd, rs, 0 | 131 Mov, // actually a pseudo op for addi rd, rs, 0 |
130 Mthi, | 132 Mthi, |
131 Mtlo, | 133 Mtlo, |
132 Mul, | 134 Mul, |
133 Mult, | 135 Mult, |
134 Multu, | 136 Multu, |
135 Or, | 137 Or, |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
285 InstMIPS32ThreeAddrGPR(Cfg *Func, Variable *Dest, Variable *Src0, | 287 InstMIPS32ThreeAddrGPR(Cfg *Func, Variable *Dest, Variable *Src0, |
286 Variable *Src1) | 288 Variable *Src1) |
287 : InstMIPS32(Func, K, 2, Dest) { | 289 : InstMIPS32(Func, K, 2, Dest) { |
288 addSource(Src0); | 290 addSource(Src0); |
289 addSource(Src1); | 291 addSource(Src1); |
290 } | 292 } |
291 | 293 |
292 static const char *Opcode; | 294 static const char *Opcode; |
293 }; | 295 }; |
294 | 296 |
297 // InstMIPS32Label represents an intra-block label that is the target of an | |
298 // intra-block branch. The offset between the label and the branch must be fit | |
299 // in the instruction immediate (considered "near"). | |
300 class InstMIPS32Label : public InstMIPS32 { | |
301 InstMIPS32Label() = delete; | |
302 InstMIPS32Label(const InstMIPS32Label &) = delete; | |
303 InstMIPS32Label &operator=(const InstMIPS32Label &) = delete; | |
304 | |
305 public: | |
306 static InstMIPS32Label *create(Cfg *Func, TargetMIPS32 *Target) { | |
307 return new (Func->allocate<InstMIPS32Label>()) | |
308 InstMIPS32Label(Func, Target); | |
309 } | |
310 uint32_t getEmitInstCount() const override { return 0; } | |
311 IceString getName(const Cfg *Func) const; | |
312 SizeT getNumber() const { return Number; } | |
313 void emit(const Cfg *Func) const override; | |
314 void emitIAS(const Cfg *Func) const override; | |
Jim Stichnoth
2016/02/23 06:18:51
Missing definitions of emitIAS() and dump().
rkotlerimgtec
2016/02/23 23:17:20
Done.
| |
315 void dump(const Cfg *Func) const override; | |
Jim Stichnoth
2016/02/23 06:18:51
There should probably be a static classof() method
rkotlerimgtec
2016/02/23 23:17:20
Done.
| |
316 | |
317 private: | |
318 InstMIPS32Label(Cfg *Func, TargetMIPS32 *Target); | |
319 | |
320 RelocOffset *OffsetReloc = nullptr; | |
321 | |
322 SizeT Number; // used for unique label generation. | |
323 }; | |
324 | |
325 /// Direct branch instruction. | |
326 class InstMIPS32Br : public InstMIPS32 { | |
327 InstMIPS32Br() = delete; | |
328 InstMIPS32Br(const InstMIPS32Br &) = delete; | |
329 InstMIPS32Br &operator=(const InstMIPS32Br &) = delete; | |
330 | |
331 public: | |
332 /// Create an unconditional branch to a node. | |
333 static InstMIPS32Br *create(Cfg *Func, CfgNode *Target) { | |
334 constexpr CfgNode *NoCondTarget = nullptr; | |
335 constexpr InstMIPS32Label *NoLabel = nullptr; | |
336 return new (Func->allocate<InstMIPS32Br>()) | |
337 InstMIPS32Br(Func, NoCondTarget, Target, NoLabel); | |
338 } | |
339 const CfgNode *getTargetTrue() const { return TargetTrue; } | |
340 const CfgNode *getTargetFalse() const { return TargetFalse; } | |
341 | |
342 bool isUnconditionalBranch() const override { return true; } | |
343 bool repointEdges(CfgNode *OldNode, CfgNode *NewNode) override { | |
344 (void)OldNode; | |
345 (void)NewNode; | |
346 return true; | |
347 }; | |
348 void emit(const Cfg *Func) const override; | |
349 void emitIAS(const Cfg *Func) const override { (void)Func; }; | |
350 void dump(const Cfg *Func) const override { (void)Func; }; | |
351 static bool classof(const Inst *Instr) { return isClassof(Instr, Br); } | |
352 | |
353 private: | |
354 InstMIPS32Br(Cfg *Func, const CfgNode *TargetTrue, const CfgNode *TargetFalse, | |
355 const InstMIPS32Label *Label); | |
356 | |
357 const CfgNode *TargetTrue; | |
358 const CfgNode *TargetFalse; | |
359 const InstMIPS32Label *Label; // Intra-block branch target | |
360 }; | |
361 | |
295 class InstMIPS32Call : public InstMIPS32 { | 362 class InstMIPS32Call : public InstMIPS32 { |
296 InstMIPS32Call() = delete; | 363 InstMIPS32Call() = delete; |
297 InstMIPS32Call(const InstMIPS32Call &) = delete; | 364 InstMIPS32Call(const InstMIPS32Call &) = delete; |
298 InstMIPS32Call &operator=(const InstMIPS32Call &) = delete; | 365 InstMIPS32Call &operator=(const InstMIPS32Call &) = delete; |
299 | 366 |
300 public: | 367 public: |
301 static InstMIPS32Call *create(Cfg *Func, Variable *Dest, | 368 static InstMIPS32Call *create(Cfg *Func, Variable *Dest, |
302 Operand *CallTarget) { | 369 Operand *CallTarget) { |
303 return new (Func->allocate<InstMIPS32Call>()) | 370 return new (Func->allocate<InstMIPS32Call>()) |
304 InstMIPS32Call(Func, Dest, CallTarget); | 371 InstMIPS32Call(Func, Dest, CallTarget); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
442 void emitSingleDestMultiSource(const Cfg *Func) const; | 509 void emitSingleDestMultiSource(const Cfg *Func) const; |
443 void emitSingleDestSingleSource(const Cfg *Func) const; | 510 void emitSingleDestSingleSource(const Cfg *Func) const; |
444 | 511 |
445 Variable *DestHi = nullptr; | 512 Variable *DestHi = nullptr; |
446 }; | 513 }; |
447 | 514 |
448 } // end of namespace MIPS32 | 515 } // end of namespace MIPS32 |
449 } // end of namespace Ice | 516 } // end of namespace Ice |
450 | 517 |
451 #endif // SUBZERO_SRC_ICEINSTMIPS32_H | 518 #endif // SUBZERO_SRC_ICEINSTMIPS32_H |
OLD | NEW |