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

Side by Side Diff: src/IceInstMIPS32.h

Issue 1993773004: [Subzero][MIPS32] Addition of bool folding machinery and implementation of conditional branches (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Added tests for eq and ne branches and corrected branch target label emission Created 4 years, 7 months 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
OLDNEW
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
11 /// \brief Declares the InstMIPS32 and OperandMIPS32 classes and their 11 /// \brief Declares the InstMIPS32 and OperandMIPS32 classes and their
12 /// subclasses. 12 /// subclasses.
13 /// 13 ///
14 /// This represents the machine instructions and operands used for MIPS32 code 14 /// This represents the machine instructions and operands used for MIPS32 code
15 /// selection. 15 /// selection.
16 /// 16 ///
17 //===----------------------------------------------------------------------===// 17 //===----------------------------------------------------------------------===//
18 18
19 #ifndef SUBZERO_SRC_ICEINSTMIPS32_H 19 #ifndef SUBZERO_SRC_ICEINSTMIPS32_H
20 #define SUBZERO_SRC_ICEINSTMIPS32_H 20 #define SUBZERO_SRC_ICEINSTMIPS32_H
21 21
22 #include "IceConditionCodesMIPS32.h"
22 #include "IceDefs.h" 23 #include "IceDefs.h"
23 #include "IceInst.h" 24 #include "IceInst.h"
24 #include "IceInstMIPS32.def" 25 #include "IceInstMIPS32.def"
25 #include "IceOperand.h" 26 #include "IceOperand.h"
26 27
27 namespace Ice { 28 namespace Ice {
28 namespace MIPS32 { 29 namespace MIPS32 {
29 30
30 class TargetMIPS32; 31 class TargetMIPS32;
31 32
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 InstMIPS32Br() = delete; 334 InstMIPS32Br() = delete;
334 InstMIPS32Br(const InstMIPS32Br &) = delete; 335 InstMIPS32Br(const InstMIPS32Br &) = delete;
335 InstMIPS32Br &operator=(const InstMIPS32Br &) = delete; 336 InstMIPS32Br &operator=(const InstMIPS32Br &) = delete;
336 337
337 public: 338 public:
338 /// Create an unconditional branch to a node. 339 /// Create an unconditional branch to a node.
339 static InstMIPS32Br *create(Cfg *Func, CfgNode *Target) { 340 static InstMIPS32Br *create(Cfg *Func, CfgNode *Target) {
340 constexpr CfgNode *NoCondTarget = nullptr; 341 constexpr CfgNode *NoCondTarget = nullptr;
341 constexpr InstMIPS32Label *NoLabel = nullptr; 342 constexpr InstMIPS32Label *NoLabel = nullptr;
342 return new (Func->allocate<InstMIPS32Br>()) 343 return new (Func->allocate<InstMIPS32Br>())
343 InstMIPS32Br(Func, NoCondTarget, Target, NoLabel); 344 InstMIPS32Br(Func, NoCondTarget, Target, NoLabel, CondMIPS32::AL);
344 } 345 }
346
347 static InstMIPS32Br *create(Cfg *Func, CfgNode *TargetTrue,
348 CfgNode *TargetFalse, Operand *Src0,
349 Operand *Src1, CondMIPS32::Cond Cond) {
350 constexpr InstMIPS32Label *NoLabel = nullptr;
351 return new (Func->allocate<InstMIPS32Br>())
352 InstMIPS32Br(Func, TargetTrue, TargetFalse, Src0, Src1, NoLabel, Cond);
353 }
354
345 const CfgNode *getTargetTrue() const { return TargetTrue; } 355 const CfgNode *getTargetTrue() const { return TargetTrue; }
346 const CfgNode *getTargetFalse() const { return TargetFalse; } 356 const CfgNode *getTargetFalse() const { return TargetFalse; }
347 357
348 bool isUnconditionalBranch() const override { return true; } 358 bool isUnconditionalBranch() const override {
359 return Predicate == CondMIPS32::AL;
360 }
349 bool repointEdges(CfgNode *OldNode, CfgNode *NewNode) override { 361 bool repointEdges(CfgNode *OldNode, CfgNode *NewNode) override {
350 (void)OldNode; 362 (void)OldNode;
351 (void)NewNode; 363 (void)NewNode;
352 return true; 364 return true;
353 }; 365 };
354 void emit(const Cfg *Func) const override; 366 void emit(const Cfg *Func) const override;
355 void emitIAS(const Cfg *Func) const override { (void)Func; }; 367 void emitIAS(const Cfg *Func) const override { (void)Func; };
356 void dump(const Cfg *Func) const override { (void)Func; }; 368 void dump(const Cfg *Func) const override { (void)Func; };
Jim Stichnoth 2016/05/19 15:03:41 Add a proper implementation of dump().
sagar.thakur 2016/05/23 18:30:26 Done.
357 static bool classof(const Inst *Instr) { return isClassof(Instr, Br); } 369 static bool classof(const Inst *Instr) { return isClassof(Instr, Br); }
358 370
359 private: 371 private:
360 InstMIPS32Br(Cfg *Func, const CfgNode *TargetTrue, const CfgNode *TargetFalse, 372 InstMIPS32Br(Cfg *Func, const CfgNode *TargetTrue, const CfgNode *TargetFalse,
361 const InstMIPS32Label *Label); 373 const InstMIPS32Label *Label, const CondMIPS32::Cond Cond);
374
375 InstMIPS32Br(Cfg *Func, const CfgNode *TargetTrue, const CfgNode *TargetFalse,
376 Operand *Src0, Operand *Src1, const InstMIPS32Label *Label,
377 const CondMIPS32::Cond Cond);
362 378
363 const CfgNode *TargetTrue; 379 const CfgNode *TargetTrue;
364 const CfgNode *TargetFalse; 380 const CfgNode *TargetFalse;
365 const InstMIPS32Label *Label; // Intra-block branch target 381 const InstMIPS32Label *Label; // Intra-block branch target
382 const CondMIPS32::Cond Predicate;
366 }; 383 };
367 384
368 class InstMIPS32Call : public InstMIPS32 { 385 class InstMIPS32Call : public InstMIPS32 {
369 InstMIPS32Call() = delete; 386 InstMIPS32Call() = delete;
370 InstMIPS32Call(const InstMIPS32Call &) = delete; 387 InstMIPS32Call(const InstMIPS32Call &) = delete;
371 InstMIPS32Call &operator=(const InstMIPS32Call &) = delete; 388 InstMIPS32Call &operator=(const InstMIPS32Call &) = delete;
372 389
373 public: 390 public:
374 static InstMIPS32Call *create(Cfg *Func, Variable *Dest, 391 static InstMIPS32Call *create(Cfg *Func, Variable *Dest,
375 Operand *CallTarget) { 392 Operand *CallTarget) {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 template <> void InstMIPS32Mfhi::emit(const Cfg *Func) const; 547 template <> void InstMIPS32Mfhi::emit(const Cfg *Func) const;
531 template <> void InstMIPS32Mtlo::emit(const Cfg *Func) const; 548 template <> void InstMIPS32Mtlo::emit(const Cfg *Func) const;
532 template <> void InstMIPS32Mthi::emit(const Cfg *Func) const; 549 template <> void InstMIPS32Mthi::emit(const Cfg *Func) const;
533 template <> void InstMIPS32Mult::emit(const Cfg *Func) const; 550 template <> void InstMIPS32Mult::emit(const Cfg *Func) const;
534 template <> void InstMIPS32Multu::emit(const Cfg *Func) const; 551 template <> void InstMIPS32Multu::emit(const Cfg *Func) const;
535 552
536 } // end of namespace MIPS32 553 } // end of namespace MIPS32
537 } // end of namespace Ice 554 } // end of namespace Ice
538 555
539 #endif // SUBZERO_SRC_ICEINSTMIPS32_H 556 #endif // SUBZERO_SRC_ICEINSTMIPS32_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698