| OLD | NEW |
| 1 //===- subzero/src/IceCfgNode.cpp - Basic block (node) implementation -----===// | 1 //===- subzero/src/IceCfgNode.cpp - Basic block (node) 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 const auto *Var2 = llvm::dyn_cast<Variable>(Opnd); | 331 const auto *Var2 = llvm::dyn_cast<Variable>(Opnd); |
| 332 if (Var2 == nullptr) | 332 if (Var2 == nullptr) |
| 333 return false; | 333 return false; |
| 334 | 334 |
| 335 // If either operand lacks a register, they cannot be the same. | 335 // If either operand lacks a register, they cannot be the same. |
| 336 if (!Var1->hasReg()) | 336 if (!Var1->hasReg()) |
| 337 return false; | 337 return false; |
| 338 if (!Var2->hasReg()) | 338 if (!Var2->hasReg()) |
| 339 return false; | 339 return false; |
| 340 | 340 |
| 341 int32_t RegNum1 = Var1->getRegNum(); | 341 const auto RegNum1 = Var1->getRegNum(); |
| 342 int32_t RegNum2 = Var2->getRegNum(); | 342 const auto RegNum2 = Var2->getRegNum(); |
| 343 // Quick common-case check. | 343 // Quick common-case check. |
| 344 if (RegNum1 == RegNum2) | 344 if (RegNum1 == RegNum2) |
| 345 return true; | 345 return true; |
| 346 | 346 |
| 347 assert(Target->getAliasesForRegister(RegNum1)[RegNum2] == | 347 assert(Target->getAliasesForRegister(RegNum1)[RegNum2] == |
| 348 Target->getAliasesForRegister(RegNum2)[RegNum1]); | 348 Target->getAliasesForRegister(RegNum2)[RegNum1]); |
| 349 return Target->getAliasesForRegister(RegNum1)[RegNum2]; | 349 return Target->getAliasesForRegister(RegNum1)[RegNum2]; |
| 350 } | 350 } |
| 351 | 351 |
| 352 // Update NumPred for all Phi assignments using Var as their Dest variable. | 352 // Update NumPred for all Phi assignments using Var as their Dest variable. |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 namespace { | 913 namespace { |
| 914 | 914 |
| 915 // Helper functions for emit(). | 915 // Helper functions for emit(). |
| 916 | 916 |
| 917 void emitRegisterUsage(Ostream &Str, const Cfg *Func, const CfgNode *Node, | 917 void emitRegisterUsage(Ostream &Str, const Cfg *Func, const CfgNode *Node, |
| 918 bool IsLiveIn, CfgVector<SizeT> &LiveRegCount) { | 918 bool IsLiveIn, CfgVector<SizeT> &LiveRegCount) { |
| 919 if (!BuildDefs::dump()) | 919 if (!BuildDefs::dump()) |
| 920 return; | 920 return; |
| 921 Liveness *Liveness = Func->getLiveness(); | 921 Liveness *Liveness = Func->getLiveness(); |
| 922 const LivenessBV *Live; | 922 const LivenessBV *Live; |
| 923 const int32_t StackReg = Func->getTarget()->getStackReg(); | 923 const auto StackReg = Func->getTarget()->getStackReg(); |
| 924 const int32_t FrameOrStackReg = Func->getTarget()->getFrameOrStackReg(); | 924 const auto FrameOrStackReg = Func->getTarget()->getFrameOrStackReg(); |
| 925 if (IsLiveIn) { | 925 if (IsLiveIn) { |
| 926 Live = &Liveness->getLiveIn(Node); | 926 Live = &Liveness->getLiveIn(Node); |
| 927 Str << "\t\t\t\t/* LiveIn="; | 927 Str << "\t\t\t\t/* LiveIn="; |
| 928 } else { | 928 } else { |
| 929 Live = &Liveness->getLiveOut(Node); | 929 Live = &Liveness->getLiveOut(Node); |
| 930 Str << "\t\t\t\t/* LiveOut="; | 930 Str << "\t\t\t\t/* LiveOut="; |
| 931 } | 931 } |
| 932 if (!Live->empty()) { | 932 if (!Live->empty()) { |
| 933 CfgVector<Variable *> LiveRegs; | 933 CfgVector<Variable *> LiveRegs; |
| 934 for (SizeT i = 0; i < Live->size(); ++i) { | 934 for (SizeT i = 0; i < Live->size(); ++i) { |
| 935 if (!(*Live)[i]) | 935 if (!(*Live)[i]) |
| 936 continue; | 936 continue; |
| 937 Variable *Var = Liveness->getVariable(i, Node); | 937 Variable *Var = Liveness->getVariable(i, Node); |
| 938 if (!Var->hasReg()) | 938 if (!Var->hasReg()) |
| 939 continue; | 939 continue; |
| 940 const int32_t RegNum = Var->getRegNum(); | 940 const auto RegNum = Var->getRegNum(); |
| 941 if (RegNum == StackReg || RegNum == FrameOrStackReg) | 941 if (RegNum == StackReg || RegNum == FrameOrStackReg) |
| 942 continue; | 942 continue; |
| 943 if (IsLiveIn) | 943 if (IsLiveIn) |
| 944 ++LiveRegCount[RegNum]; | 944 ++LiveRegCount[RegNum]; |
| 945 LiveRegs.push_back(Var); | 945 LiveRegs.push_back(Var); |
| 946 } | 946 } |
| 947 // Sort the variables by regnum so they are always printed in a familiar | 947 // Sort the variables by regnum so they are always printed in a familiar |
| 948 // order. | 948 // order. |
| 949 std::sort(LiveRegs.begin(), LiveRegs.end(), | 949 std::sort(LiveRegs.begin(), LiveRegs.end(), |
| 950 [](const Variable *V1, const Variable *V2) { | 950 [](const Variable *V1, const Variable *V2) { |
| 951 return V1->getRegNum() < V2->getRegNum(); | 951 return unsigned(V1->getRegNum()) < unsigned(V2->getRegNum()); |
| 952 }); | 952 }); |
| 953 bool First = true; | 953 bool First = true; |
| 954 for (Variable *Var : LiveRegs) { | 954 for (Variable *Var : LiveRegs) { |
| 955 if (!First) | 955 if (!First) |
| 956 Str << ","; | 956 Str << ","; |
| 957 First = false; | 957 First = false; |
| 958 Var->emit(Func); | 958 Var->emit(Func); |
| 959 } | 959 } |
| 960 } | 960 } |
| 961 Str << " */\n"; | 961 Str << " */\n"; |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1432 auto *Instr = InstIntrinsicCall::create( | 1432 auto *Instr = InstIntrinsicCall::create( |
| 1433 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info); | 1433 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info); |
| 1434 Instr->addArg(AtomicRMWOp); | 1434 Instr->addArg(AtomicRMWOp); |
| 1435 Instr->addArg(Counter); | 1435 Instr->addArg(Counter); |
| 1436 Instr->addArg(One); | 1436 Instr->addArg(One); |
| 1437 Instr->addArg(OrderAcquireRelease); | 1437 Instr->addArg(OrderAcquireRelease); |
| 1438 Insts.push_front(Instr); | 1438 Insts.push_front(Instr); |
| 1439 } | 1439 } |
| 1440 | 1440 |
| 1441 } // end of namespace Ice | 1441 } // end of namespace Ice |
| OLD | NEW |