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; |
| 315 void dump(const Cfg *Func) const override; |
| 316 |
| 317 static bool classof(const Inst *Instr) { return isClassof(Instr, Label); } |
| 318 |
| 319 private: |
| 320 InstMIPS32Label(Cfg *Func, TargetMIPS32 *Target); |
| 321 |
| 322 RelocOffset *OffsetReloc = nullptr; |
| 323 |
| 324 SizeT Number; // used for unique label generation. |
| 325 }; |
| 326 |
| 327 /// Direct branch instruction. |
| 328 class InstMIPS32Br : public InstMIPS32 { |
| 329 InstMIPS32Br() = delete; |
| 330 InstMIPS32Br(const InstMIPS32Br &) = delete; |
| 331 InstMIPS32Br &operator=(const InstMIPS32Br &) = delete; |
| 332 |
| 333 public: |
| 334 /// Create an unconditional branch to a node. |
| 335 static InstMIPS32Br *create(Cfg *Func, CfgNode *Target) { |
| 336 constexpr CfgNode *NoCondTarget = nullptr; |
| 337 constexpr InstMIPS32Label *NoLabel = nullptr; |
| 338 return new (Func->allocate<InstMIPS32Br>()) |
| 339 InstMIPS32Br(Func, NoCondTarget, Target, NoLabel); |
| 340 } |
| 341 const CfgNode *getTargetTrue() const { return TargetTrue; } |
| 342 const CfgNode *getTargetFalse() const { return TargetFalse; } |
| 343 |
| 344 bool isUnconditionalBranch() const override { return true; } |
| 345 bool repointEdges(CfgNode *OldNode, CfgNode *NewNode) override { |
| 346 (void)OldNode; |
| 347 (void)NewNode; |
| 348 return true; |
| 349 }; |
| 350 void emit(const Cfg *Func) const override; |
| 351 void emitIAS(const Cfg *Func) const override { (void)Func; }; |
| 352 void dump(const Cfg *Func) const override { (void)Func; }; |
| 353 static bool classof(const Inst *Instr) { return isClassof(Instr, Br); } |
| 354 |
| 355 private: |
| 356 InstMIPS32Br(Cfg *Func, const CfgNode *TargetTrue, const CfgNode *TargetFalse, |
| 357 const InstMIPS32Label *Label); |
| 358 |
| 359 const CfgNode *TargetTrue; |
| 360 const CfgNode *TargetFalse; |
| 361 const InstMIPS32Label *Label; // Intra-block branch target |
| 362 }; |
| 363 |
295 class InstMIPS32Call : public InstMIPS32 { | 364 class InstMIPS32Call : public InstMIPS32 { |
296 InstMIPS32Call() = delete; | 365 InstMIPS32Call() = delete; |
297 InstMIPS32Call(const InstMIPS32Call &) = delete; | 366 InstMIPS32Call(const InstMIPS32Call &) = delete; |
298 InstMIPS32Call &operator=(const InstMIPS32Call &) = delete; | 367 InstMIPS32Call &operator=(const InstMIPS32Call &) = delete; |
299 | 368 |
300 public: | 369 public: |
301 static InstMIPS32Call *create(Cfg *Func, Variable *Dest, | 370 static InstMIPS32Call *create(Cfg *Func, Variable *Dest, |
302 Operand *CallTarget) { | 371 Operand *CallTarget) { |
303 return new (Func->allocate<InstMIPS32Call>()) | 372 return new (Func->allocate<InstMIPS32Call>()) |
304 InstMIPS32Call(Func, Dest, CallTarget); | 373 InstMIPS32Call(Func, Dest, CallTarget); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 void emitSingleDestMultiSource(const Cfg *Func) const; | 511 void emitSingleDestMultiSource(const Cfg *Func) const; |
443 void emitSingleDestSingleSource(const Cfg *Func) const; | 512 void emitSingleDestSingleSource(const Cfg *Func) const; |
444 | 513 |
445 Variable *DestHi = nullptr; | 514 Variable *DestHi = nullptr; |
446 }; | 515 }; |
447 | 516 |
448 } // end of namespace MIPS32 | 517 } // end of namespace MIPS32 |
449 } // end of namespace Ice | 518 } // end of namespace Ice |
450 | 519 |
451 #endif // SUBZERO_SRC_ICEINSTMIPS32_H | 520 #endif // SUBZERO_SRC_ICEINSTMIPS32_H |
OLD | NEW |