| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 { str } \ | 70 { str } \ |
| 71 , | 71 , |
| 72 ICEINSTICMP_TABLE | 72 ICEINSTICMP_TABLE |
| 73 #undef X | 73 #undef X |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 } // end of anonymous namespace | 76 } // end of anonymous namespace |
| 77 | 77 |
| 78 Inst::Inst(Cfg *Func, InstKind Kind, SizeT MaxSrcs, Variable *Dest) | 78 Inst::Inst(Cfg *Func, InstKind Kind, SizeT MaxSrcs, Variable *Dest) |
| 79 : Kind(Kind), Number(Func->newInstNumber()), Dest(Dest), MaxSrcs(MaxSrcs), | 79 : Kind(Kind), Number(Func->newInstNumber()), Dest(Dest), MaxSrcs(MaxSrcs), |
| 80 Srcs(Func->allocateArrayOf<Operand *>(MaxSrcs)), LiveRangesEnded(0) {} | 80 LiveRangesEnded(0) { |
| 81 Srcs.reserve(MaxSrcs); |
| 82 } |
| 81 | 83 |
| 82 const char *Inst::getInstName() const { | 84 const char *Inst::getInstName() const { |
| 83 if (!BuildDefs::dump()) | 85 if (!BuildDefs::dump()) |
| 84 return "???"; | 86 return "???"; |
| 85 | 87 |
| 86 switch (Kind) { | 88 switch (Kind) { |
| 87 #define X(InstrKind, name) \ | 89 #define X(InstrKind, name) \ |
| 88 case InstrKind: \ | 90 case InstrKind: \ |
| 89 return name | 91 return name |
| 90 X(Unreachable, "unreachable"); | 92 X(Unreachable, "unreachable"); |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 addSource(Source3); | 388 addSource(Source3); |
| 387 } | 389 } |
| 388 | 390 |
| 389 InstLoad::InstLoad(Cfg *Func, Variable *Dest, Operand *SourceAddr) | 391 InstLoad::InstLoad(Cfg *Func, Variable *Dest, Operand *SourceAddr) |
| 390 : InstHighLevel(Func, Inst::Load, 1, Dest) { | 392 : InstHighLevel(Func, Inst::Load, 1, Dest) { |
| 391 addSource(SourceAddr); | 393 addSource(SourceAddr); |
| 392 } | 394 } |
| 393 | 395 |
| 394 InstPhi::InstPhi(Cfg *Func, SizeT MaxSrcs, Variable *Dest) | 396 InstPhi::InstPhi(Cfg *Func, SizeT MaxSrcs, Variable *Dest) |
| 395 : InstHighLevel(Func, Phi, MaxSrcs, Dest) { | 397 : InstHighLevel(Func, Phi, MaxSrcs, Dest) { |
| 396 Labels = Func->allocateArrayOf<CfgNode *>(MaxSrcs); | 398 Labels.reserve(MaxSrcs); |
| 397 } | 399 } |
| 398 | 400 |
| 399 // TODO: A Switch instruction (and maybe others) can add duplicate edges. We | 401 // TODO: A Switch instruction (and maybe others) can add duplicate edges. We |
| 400 // may want to de-dup Phis and validate consistency (i.e., the source operands | 402 // may want to de-dup Phis and validate consistency (i.e., the source operands |
| 401 // are the same for duplicate edges), though it seems the current lowering code | 403 // are the same for duplicate edges), though it seems the current lowering code |
| 402 // is OK with this situation. | 404 // is OK with this situation. |
| 403 void InstPhi::addArgument(Operand *Source, CfgNode *Label) { | 405 void InstPhi::addArgument(Operand *Source, CfgNode *Label) { |
| 404 Labels[getSrcSize()] = Label; | 406 assert(Label); |
| 407 Labels.push_back(Label); |
| 405 addSource(Source); | 408 addSource(Source); |
| 406 } | 409 } |
| 407 | 410 |
| 408 // Find the source operand corresponding to the incoming edge for the given | 411 // Find the source operand corresponding to the incoming edge for the given |
| 409 // node. | 412 // node. |
| 410 Operand *InstPhi::getOperandForTarget(CfgNode *Target) const { | 413 Operand *InstPhi::getOperandForTarget(CfgNode *Target) const { |
| 411 for (SizeT I = 0; I < getSrcSize(); ++I) { | 414 for (SizeT I = 0; I < getSrcSize(); ++I) { |
| 412 if (Labels[I] == Target) | 415 if (Labels[I] == Target) |
| 413 return getSrc(I); | 416 return getSrc(I); |
| 414 } | 417 } |
| (...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1091 // upper 32 bits of rax. We need to recognize and preserve these. | 1094 // upper 32 bits of rax. We need to recognize and preserve these. |
| 1092 return true; | 1095 return true; |
| 1093 } | 1096 } |
| 1094 if (!Dest->hasReg() && !SrcVar->hasReg() && | 1097 if (!Dest->hasReg() && !SrcVar->hasReg() && |
| 1095 Dest->getStackOffset() == SrcVar->getStackOffset()) | 1098 Dest->getStackOffset() == SrcVar->getStackOffset()) |
| 1096 return true; | 1099 return true; |
| 1097 return false; | 1100 return false; |
| 1098 } | 1101 } |
| 1099 | 1102 |
| 1100 } // end of namespace Ice | 1103 } // end of namespace Ice |
| OLD | NEW |