| OLD | NEW |
| 1 //===- subzero/src/IceInst.cpp - High-level instruction implementation ----===// | 1 //===- subzero/src/IceInst.cpp - High-level 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 X(Icmp, "icmp"); | 98 X(Icmp, "icmp"); |
| 99 X(IntrinsicCall, "intrinsiccall"); | 99 X(IntrinsicCall, "intrinsiccall"); |
| 100 X(InsertElement, "insertelement"); | 100 X(InsertElement, "insertelement"); |
| 101 X(Load, "load"); | 101 X(Load, "load"); |
| 102 X(Phi, "phi"); | 102 X(Phi, "phi"); |
| 103 X(Ret, "ret"); | 103 X(Ret, "ret"); |
| 104 X(Select, "select"); | 104 X(Select, "select"); |
| 105 X(Store, "store"); | 105 X(Store, "store"); |
| 106 X(Switch, "switch"); | 106 X(Switch, "switch"); |
| 107 X(Assign, "assign"); | 107 X(Assign, "assign"); |
| 108 X(Breakpoint, "break"); |
| 108 X(BundleLock, "bundlelock"); | 109 X(BundleLock, "bundlelock"); |
| 109 X(BundleUnlock, "bundleunlock"); | 110 X(BundleUnlock, "bundleunlock"); |
| 110 X(FakeDef, "fakedef"); | 111 X(FakeDef, "fakedef"); |
| 111 X(FakeUse, "fakeuse"); | 112 X(FakeUse, "fakeuse"); |
| 112 X(FakeKill, "fakekill"); | 113 X(FakeKill, "fakekill"); |
| 113 X(JumpTable, "jumptable"); | 114 X(JumpTable, "jumptable"); |
| 114 #undef X | 115 #undef X |
| 115 default: | 116 default: |
| 116 assert(Kind >= Target); | 117 assert(Kind >= Target); |
| 117 return "target"; | 118 return "target"; |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 | 510 |
| 510 void InstSwitch::addBranch(SizeT CaseIndex, uint64_t Value, CfgNode *Label) { | 511 void InstSwitch::addBranch(SizeT CaseIndex, uint64_t Value, CfgNode *Label) { |
| 511 assert(CaseIndex < NumCases); | 512 assert(CaseIndex < NumCases); |
| 512 Values[CaseIndex] = Value; | 513 Values[CaseIndex] = Value; |
| 513 Labels[CaseIndex] = Label; | 514 Labels[CaseIndex] = Label; |
| 514 } | 515 } |
| 515 | 516 |
| 516 NodeList InstSwitch::getTerminatorEdges() const { | 517 NodeList InstSwitch::getTerminatorEdges() const { |
| 517 NodeList OutEdges; | 518 NodeList OutEdges; |
| 518 OutEdges.reserve(NumCases + 1); | 519 OutEdges.reserve(NumCases + 1); |
| 520 assert(LabelDefault); |
| 519 OutEdges.push_back(LabelDefault); | 521 OutEdges.push_back(LabelDefault); |
| 520 for (SizeT I = 0; I < NumCases; ++I) { | 522 for (SizeT I = 0; I < NumCases; ++I) { |
| 523 assert(Labels[I]); |
| 521 OutEdges.push_back(Labels[I]); | 524 OutEdges.push_back(Labels[I]); |
| 522 } | 525 } |
| 523 std::sort(OutEdges.begin(), OutEdges.end(), | 526 std::sort(OutEdges.begin(), OutEdges.end(), |
| 524 [](const CfgNode *x, const CfgNode *y) { | 527 [](const CfgNode *x, const CfgNode *y) { |
| 525 return x->getIndex() < y->getIndex(); | 528 return x->getIndex() < y->getIndex(); |
| 526 }); | 529 }); |
| 527 auto Last = std::unique(OutEdges.begin(), OutEdges.end()); | 530 auto Last = std::unique(OutEdges.begin(), OutEdges.end()); |
| 528 OutEdges.erase(Last, OutEdges.end()); | 531 OutEdges.erase(Last, OutEdges.end()); |
| 529 return OutEdges; | 532 return OutEdges; |
| 530 } | 533 } |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 } | 1043 } |
| 1041 | 1044 |
| 1042 void InstTarget::dump(const Cfg *Func) const { | 1045 void InstTarget::dump(const Cfg *Func) const { |
| 1043 if (!BuildDefs::dump()) | 1046 if (!BuildDefs::dump()) |
| 1044 return; | 1047 return; |
| 1045 Ostream &Str = Func->getContext()->getStrDump(); | 1048 Ostream &Str = Func->getContext()->getStrDump(); |
| 1046 Str << "[TARGET] "; | 1049 Str << "[TARGET] "; |
| 1047 Inst::dump(Func); | 1050 Inst::dump(Func); |
| 1048 } | 1051 } |
| 1049 | 1052 |
| 1053 InstBreakpoint::InstBreakpoint(Cfg *Func) |
| 1054 : InstHighLevel(Func, Inst::Breakpoint, 0, nullptr) {} |
| 1055 |
| 1050 bool checkForRedundantAssign(const Variable *Dest, const Operand *Source) { | 1056 bool checkForRedundantAssign(const Variable *Dest, const Operand *Source) { |
| 1051 const auto *SrcVar = llvm::dyn_cast<const Variable>(Source); | 1057 const auto *SrcVar = llvm::dyn_cast<const Variable>(Source); |
| 1052 if (!SrcVar) | 1058 if (!SrcVar) |
| 1053 return false; | 1059 return false; |
| 1054 if (Dest->hasReg() && Dest->getRegNum() == SrcVar->getRegNum()) { | 1060 if (Dest->hasReg() && Dest->getRegNum() == SrcVar->getRegNum()) { |
| 1055 // TODO: On x86-64, instructions like "mov eax, eax" are used to clear the | 1061 // TODO: On x86-64, instructions like "mov eax, eax" are used to clear the |
| 1056 // upper 32 bits of rax. We need to recognize and preserve these. | 1062 // upper 32 bits of rax. We need to recognize and preserve these. |
| 1057 return true; | 1063 return true; |
| 1058 } | 1064 } |
| 1059 if (!Dest->hasReg() && !SrcVar->hasReg() && | 1065 if (!Dest->hasReg() && !SrcVar->hasReg() && |
| 1060 Dest->getStackOffset() == SrcVar->getStackOffset()) | 1066 Dest->getStackOffset() == SrcVar->getStackOffset()) |
| 1061 return true; | 1067 return true; |
| 1062 return false; | 1068 return false; |
| 1063 } | 1069 } |
| 1064 | 1070 |
| 1065 } // end of namespace Ice | 1071 } // end of namespace Ice |
| OLD | NEW |