| 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 // This file implements the Inst class, primarily the various | 10 // This file implements the Inst class, primarily the various |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 const struct InstArithmeticAttributes_ { | 26 const struct InstArithmeticAttributes_ { |
| 27 const char *DisplayString; | 27 const char *DisplayString; |
| 28 bool IsCommutative; | 28 bool IsCommutative; |
| 29 } InstArithmeticAttributes[] = { | 29 } InstArithmeticAttributes[] = { |
| 30 #define X(tag, str, commutative) \ | 30 #define X(tag, str, commutative) \ |
| 31 { str, commutative } \ | 31 { str, commutative } \ |
| 32 , | 32 , |
| 33 ICEINSTARITHMETIC_TABLE | 33 ICEINSTARITHMETIC_TABLE |
| 34 #undef X | 34 #undef X |
| 35 }; | 35 }; |
| 36 const size_t InstArithmeticAttributesSize = | |
| 37 llvm::array_lengthof(InstArithmeticAttributes); | |
| 38 | 36 |
| 39 // Using non-anonymous struct so that array_lengthof works. | 37 // Using non-anonymous struct so that array_lengthof works. |
| 40 const struct InstCastAttributes_ { | 38 const struct InstCastAttributes_ { |
| 41 const char *DisplayString; | 39 const char *DisplayString; |
| 42 } InstCastAttributes[] = { | 40 } InstCastAttributes[] = { |
| 43 #define X(tag, str) \ | 41 #define X(tag, str) \ |
| 44 { str } \ | 42 { str } \ |
| 45 , | 43 , |
| 46 ICEINSTCAST_TABLE | 44 ICEINSTCAST_TABLE |
| 47 #undef X | 45 #undef X |
| 48 }; | 46 }; |
| 49 const size_t InstCastAttributesSize = llvm::array_lengthof(InstCastAttributes); | |
| 50 | 47 |
| 51 // Using non-anonymous struct so that array_lengthof works. | 48 // Using non-anonymous struct so that array_lengthof works. |
| 52 const struct InstFcmpAttributes_ { | 49 const struct InstFcmpAttributes_ { |
| 53 const char *DisplayString; | 50 const char *DisplayString; |
| 54 } InstFcmpAttributes[] = { | 51 } InstFcmpAttributes[] = { |
| 55 #define X(tag, str) \ | 52 #define X(tag, str) \ |
| 56 { str } \ | 53 { str } \ |
| 57 , | 54 , |
| 58 ICEINSTFCMP_TABLE | 55 ICEINSTFCMP_TABLE |
| 59 #undef X | 56 #undef X |
| 60 }; | 57 }; |
| 61 const size_t InstFcmpAttributesSize = llvm::array_lengthof(InstFcmpAttributes); | |
| 62 | 58 |
| 63 // Using non-anonymous struct so that array_lengthof works. | 59 // Using non-anonymous struct so that array_lengthof works. |
| 64 const struct InstIcmpAttributes_ { | 60 const struct InstIcmpAttributes_ { |
| 65 const char *DisplayString; | 61 const char *DisplayString; |
| 66 } InstIcmpAttributes[] = { | 62 } InstIcmpAttributes[] = { |
| 67 #define X(tag, str) \ | 63 #define X(tag, str) \ |
| 68 { str } \ | 64 { str } \ |
| 69 , | 65 , |
| 70 ICEINSTICMP_TABLE | 66 ICEINSTICMP_TABLE |
| 71 #undef X | 67 #undef X |
| 72 }; | 68 }; |
| 73 const size_t InstIcmpAttributesSize = llvm::array_lengthof(InstIcmpAttributes); | |
| 74 | 69 |
| 75 } // end of anonymous namespace | 70 } // end of anonymous namespace |
| 76 | 71 |
| 77 Inst::Inst(Cfg *Func, InstKind Kind, SizeT MaxSrcs, Variable *Dest) | 72 Inst::Inst(Cfg *Func, InstKind Kind, SizeT MaxSrcs, Variable *Dest) |
| 78 : Kind(Kind), Number(Func->newInstNumber()), Deleted(false), Dead(false), | 73 : Kind(Kind), Number(Func->newInstNumber()), Deleted(false), Dead(false), |
| 79 HasSideEffects(false), Dest(Dest), MaxSrcs(MaxSrcs), NumSrcs(0), | 74 HasSideEffects(false), Dest(Dest), MaxSrcs(MaxSrcs), NumSrcs(0), |
| 80 Srcs(Func->allocateArrayOf<Operand *>(MaxSrcs)), LiveRangesEnded(0) {} | 75 Srcs(Func->allocateArrayOf<Operand *>(MaxSrcs)), LiveRangesEnded(0) {} |
| 81 | 76 |
| 82 // Assign the instruction a new number. | 77 // Assign the instruction a new number. |
| 83 void Inst::renumber(Cfg *Func) { | 78 void Inst::renumber(Cfg *Func) { |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 addSource(ByteCount); | 216 addSource(ByteCount); |
| 222 } | 217 } |
| 223 | 218 |
| 224 InstArithmetic::InstArithmetic(Cfg *Func, OpKind Op, Variable *Dest, | 219 InstArithmetic::InstArithmetic(Cfg *Func, OpKind Op, Variable *Dest, |
| 225 Operand *Source1, Operand *Source2) | 220 Operand *Source1, Operand *Source2) |
| 226 : Inst(Func, Inst::Arithmetic, 2, Dest), Op(Op) { | 221 : Inst(Func, Inst::Arithmetic, 2, Dest), Op(Op) { |
| 227 addSource(Source1); | 222 addSource(Source1); |
| 228 addSource(Source2); | 223 addSource(Source2); |
| 229 } | 224 } |
| 230 | 225 |
| 226 const char *InstArithmetic::getOpName(OpKind Op) { |
| 227 size_t OpIndex = static_cast<size_t>(Op); |
| 228 return OpIndex < InstArithmetic::_num |
| 229 ? InstArithmeticAttributes[OpIndex].DisplayString |
| 230 : "???"; |
| 231 } |
| 232 |
| 231 bool InstArithmetic::isCommutative() const { | 233 bool InstArithmetic::isCommutative() const { |
| 232 return InstArithmeticAttributes[getOp()].IsCommutative; | 234 return InstArithmeticAttributes[getOp()].IsCommutative; |
| 233 } | 235 } |
| 234 | 236 |
| 235 InstAssign::InstAssign(Cfg *Func, Variable *Dest, Operand *Source) | 237 InstAssign::InstAssign(Cfg *Func, Variable *Dest, Operand *Source) |
| 236 : Inst(Func, Inst::Assign, 1, Dest) { | 238 : Inst(Func, Inst::Assign, 1, Dest) { |
| 237 addSource(Source); | 239 addSource(Source); |
| 238 } | 240 } |
| 239 | 241 |
| 240 // If TargetTrue==TargetFalse, we turn it into an unconditional | 242 // If TargetTrue==TargetFalse, we turn it into an unconditional |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 | 761 |
| 760 void InstTarget::dump(const Cfg *Func) const { | 762 void InstTarget::dump(const Cfg *Func) const { |
| 761 Ostream &Str = Func->getContext()->getStrDump(); | 763 Ostream &Str = Func->getContext()->getStrDump(); |
| 762 Str << "[TARGET] "; | 764 Str << "[TARGET] "; |
| 763 Inst::dump(Func); | 765 Inst::dump(Func); |
| 764 } | 766 } |
| 765 | 767 |
| 766 void InstTarget::dumpExtras(const Cfg *Func) const { Inst::dumpExtras(Func); } | 768 void InstTarget::dumpExtras(const Cfg *Func) const { Inst::dumpExtras(Func); } |
| 767 | 769 |
| 768 } // end of namespace Ice | 770 } // end of namespace Ice |
| OLD | NEW |