Chromium Code Reviews| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 #define X(tag, str) \ | 58 #define X(tag, str) \ |
| 59 { str } \ | 59 { str } \ |
| 60 , | 60 , |
| 61 ICEINSTFCMP_TABLE | 61 ICEINSTFCMP_TABLE |
| 62 #undef X | 62 #undef X |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 // Using non-anonymous struct so that array_lengthof works. | 65 // Using non-anonymous struct so that array_lengthof works. |
| 66 const struct InstIcmpAttributes_ { | 66 const struct InstIcmpAttributes_ { |
| 67 const char *DisplayString; | 67 const char *DisplayString; |
| 68 InstIcmp::ICond Inverse; | |
| 68 } InstIcmpAttributes[] = { | 69 } InstIcmpAttributes[] = { |
| 69 #define X(tag, str) \ | 70 #define X(tag, inverse, str) \ |
| 70 { str } \ | 71 { str, inverse } \ |
| 71 , | 72 , |
| 72 ICEINSTICMP_TABLE | 73 ICEINSTICMP_TABLE |
| 73 #undef X | 74 #undef X |
| 74 }; | 75 }; |
| 75 | 76 |
| 76 } // end of anonymous namespace | 77 } // end of anonymous namespace |
| 77 | 78 |
| 78 Inst::Inst(Cfg *Func, InstKind Kind, SizeT MaxSrcs, Variable *Dest) | 79 Inst::Inst(Cfg *Func, InstKind Kind, SizeT MaxSrcs, Variable *Dest) |
| 79 : Kind(Kind), Number(Func->newInstNumber()), Dest(Dest), MaxSrcs(MaxSrcs), | 80 : Kind(Kind), Number(Func->newInstNumber()), Dest(Dest), MaxSrcs(MaxSrcs), |
| 80 LiveRangesEnded(0) { | 81 LiveRangesEnded(0) { |
| (...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1078 if (!BuildDefs::dump()) | 1079 if (!BuildDefs::dump()) |
| 1079 return; | 1080 return; |
| 1080 Ostream &Str = Func->getContext()->getStrDump(); | 1081 Ostream &Str = Func->getContext()->getStrDump(); |
| 1081 Str << "[TARGET] "; | 1082 Str << "[TARGET] "; |
| 1082 Inst::dump(Func); | 1083 Inst::dump(Func); |
| 1083 } | 1084 } |
| 1084 | 1085 |
| 1085 InstBreakpoint::InstBreakpoint(Cfg *Func) | 1086 InstBreakpoint::InstBreakpoint(Cfg *Func) |
| 1086 : InstHighLevel(Func, Inst::Breakpoint, 0, nullptr) {} | 1087 : InstHighLevel(Func, Inst::Breakpoint, 0, nullptr) {} |
| 1087 | 1088 |
| 1089 void InstIcmp::invertConditionAndSwapOperands() { | |
| 1090 Condition = InstIcmpAttributes[Condition].Inverse; | |
| 1091 auto *TempOp = getSrc(0); | |
|
Jim Stichnoth
2016/07/10 13:25:32
Since Srcs[] is a protected field that you have ac
manasijm
2016/07/11 22:27:04
Done.
| |
| 1092 replaceSource(0, getSrc(1)); | |
| 1093 replaceSource(1, TempOp); | |
| 1094 } | |
| 1088 bool checkForRedundantAssign(const Variable *Dest, const Operand *Source) { | 1095 bool checkForRedundantAssign(const Variable *Dest, const Operand *Source) { |
| 1089 const auto *SrcVar = llvm::dyn_cast<const Variable>(Source); | 1096 const auto *SrcVar = llvm::dyn_cast<const Variable>(Source); |
| 1090 if (!SrcVar) | 1097 if (!SrcVar) |
| 1091 return false; | 1098 return false; |
| 1092 if (Dest->hasReg() && Dest->getRegNum() == SrcVar->getRegNum()) { | 1099 if (Dest->hasReg() && Dest->getRegNum() == SrcVar->getRegNum()) { |
| 1093 // TODO: On x86-64, instructions like "mov eax, eax" are used to clear the | 1100 // TODO: On x86-64, instructions like "mov eax, eax" are used to clear the |
| 1094 // upper 32 bits of rax. We need to recognize and preserve these. | 1101 // upper 32 bits of rax. We need to recognize and preserve these. |
| 1095 return true; | 1102 return true; |
| 1096 } | 1103 } |
| 1097 if (!Dest->hasReg() && !SrcVar->hasReg() && | 1104 if (!Dest->hasReg() && !SrcVar->hasReg() && |
| 1098 Dest->getStackOffset() == SrcVar->getStackOffset()) | 1105 Dest->getStackOffset() == SrcVar->getStackOffset()) |
| 1099 return true; | 1106 return true; |
| 1100 return false; | 1107 return false; |
| 1101 } | 1108 } |
| 1102 | 1109 |
| 1103 } // end of namespace Ice | 1110 } // end of namespace Ice |
| OLD | NEW |