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 Reverse; |
68 } InstIcmpAttributes[] = { | 69 } InstIcmpAttributes[] = { |
69 #define X(tag, str) \ | 70 #define X(tag, reverse, str) \ |
70 { str } \ | 71 { str, InstIcmp::ICond::reverse } \ |
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::reverseConditionAndOperands() { |
| 1090 Condition = InstIcmpAttributes[Condition].Reverse; |
| 1091 std::swap(Srcs[0], Srcs[1]); |
| 1092 } |
1088 bool checkForRedundantAssign(const Variable *Dest, const Operand *Source) { | 1093 bool checkForRedundantAssign(const Variable *Dest, const Operand *Source) { |
1089 const auto *SrcVar = llvm::dyn_cast<const Variable>(Source); | 1094 const auto *SrcVar = llvm::dyn_cast<const Variable>(Source); |
1090 if (!SrcVar) | 1095 if (!SrcVar) |
1091 return false; | 1096 return false; |
1092 if (Dest->hasReg() && Dest->getRegNum() == SrcVar->getRegNum()) { | 1097 if (Dest->hasReg() && Dest->getRegNum() == SrcVar->getRegNum()) { |
1093 // TODO: On x86-64, instructions like "mov eax, eax" are used to clear the | 1098 // 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. | 1099 // upper 32 bits of rax. We need to recognize and preserve these. |
1095 return true; | 1100 return true; |
1096 } | 1101 } |
1097 if (!Dest->hasReg() && !SrcVar->hasReg()) { | 1102 if (!Dest->hasReg() && !SrcVar->hasReg()) { |
1098 if (!Dest->hasStackOffset() || !SrcVar->hasStackOffset()) { | 1103 if (!Dest->hasStackOffset() || !SrcVar->hasStackOffset()) { |
1099 return false; | 1104 return false; |
1100 } | 1105 } |
1101 if (Dest->getStackOffset() != SrcVar->getStackOffset()) { | 1106 if (Dest->getStackOffset() != SrcVar->getStackOffset()) { |
1102 return false; | 1107 return false; |
1103 } | 1108 } |
1104 return true; | 1109 return true; |
1105 } | 1110 } |
1106 return false; | 1111 return false; |
1107 } | 1112 } |
1108 | 1113 |
1109 } // end of namespace Ice | 1114 } // end of namespace Ice |
OLD | NEW |