Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //===- subzero/src/IceInstMips32.cpp - Mips32 instruction implementation --===// | 1 //===- subzero/src/IceInstMips32.cpp - Mips32 instruction implementation --===// |
| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 InstMIPS32Br::InstMIPS32Br(Cfg *Func, const CfgNode *TargetTrue, | 193 InstMIPS32Br::InstMIPS32Br(Cfg *Func, const CfgNode *TargetTrue, |
| 194 const CfgNode *TargetFalse, Operand *Src0, | 194 const CfgNode *TargetFalse, Operand *Src0, |
| 195 Operand *Src1, const InstMIPS32Label *Label, | 195 Operand *Src1, const InstMIPS32Label *Label, |
| 196 CondMIPS32::Cond Cond) | 196 CondMIPS32::Cond Cond) |
| 197 : InstMIPS32(Func, InstMIPS32::Br, 2, nullptr), TargetTrue(TargetTrue), | 197 : InstMIPS32(Func, InstMIPS32::Br, 2, nullptr), TargetTrue(TargetTrue), |
| 198 TargetFalse(TargetFalse), Label(Label), Predicate(Cond) { | 198 TargetFalse(TargetFalse), Label(Label), Predicate(Cond) { |
| 199 addSource(Src0); | 199 addSource(Src0); |
| 200 addSource(Src1); | 200 addSource(Src1); |
| 201 } | 201 } |
| 202 | 202 |
| 203 CondMIPS32::Cond InstMIPS32::getOppositeCondition(CondMIPS32::Cond Cond) { | |
| 204 return InstMIPS32CondAttributes[Cond].Opposite; | |
| 205 } | |
| 206 | |
| 207 bool InstMIPS32Br::optimizeBranch(const CfgNode *NextNode) { | |
| 208 // If there is no next block, then there can be no fallthrough to optimize. | |
| 209 if (NextNode == nullptr) | |
| 210 return false; | |
| 211 // Intra-block conditional branches can't be optimized. | |
| 212 if (Label) | |
|
Jim Stichnoth
2016/08/24 15:51:32
if (Label != nullptr)
jaydeep.patil
2016/08/26 10:15:00
Done.
| |
| 213 return false; | |
| 214 // If there is no fallthrough node, such as a non-default case label for a | |
| 215 // switch instruction, then there is no opportunity to optimize. | |
| 216 if (getTargetFalse() == nullptr) | |
| 217 return false; | |
| 218 // Unconditional branch to the next node can be removed. | |
| 219 if (isUnconditionalBranch() && getTargetFalse() == NextNode) { | |
| 220 assert(getTargetTrue() == nullptr); | |
| 221 setDeleted(); | |
| 222 return true; | |
| 223 } | |
| 224 return false; | |
| 225 } | |
| 226 | |
| 203 bool InstMIPS32Br::repointEdges(CfgNode *OldNode, CfgNode *NewNode) { | 227 bool InstMIPS32Br::repointEdges(CfgNode *OldNode, CfgNode *NewNode) { |
| 204 bool Found = false; | 228 bool Found = false; |
| 205 if (TargetFalse == OldNode) { | 229 if (TargetFalse == OldNode) { |
| 206 TargetFalse = NewNode; | 230 TargetFalse = NewNode; |
| 207 Found = true; | 231 Found = true; |
| 208 } | 232 } |
| 209 if (TargetTrue == OldNode) { | 233 if (TargetTrue == OldNode) { |
| 210 TargetTrue = NewNode; | 234 TargetTrue = NewNode; |
| 211 Found = true; | 235 Found = true; |
| 212 } | 236 } |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 688 getSrc(0)->emit(Func); | 712 getSrc(0)->emit(Func); |
| 689 return; | 713 return; |
| 690 } | 714 } |
| 691 | 715 |
| 692 // stack to stack | 716 // stack to stack |
| 693 llvm::report_fatal_error("mov cant copy stack to stack."); | 717 llvm::report_fatal_error("mov cant copy stack to stack."); |
| 694 } | 718 } |
| 695 | 719 |
| 696 } // end of namespace MIPS32 | 720 } // end of namespace MIPS32 |
| 697 } // end of namespace Ice | 721 } // end of namespace Ice |
| OLD | NEW |