Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //===- subzero/src/IceInst.h - High-level instructions ----------*- C++ -*-===// | 1 //===- subzero/src/IceInst.h - High-level instructions ----------*- C++ -*-===// |
| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 JumpTable, // not part of LLVM/PNaCl bitcode | 69 JumpTable, // not part of LLVM/PNaCl bitcode |
| 70 // Anything >= Target is an InstTarget subclass. Note that the value-spaces | 70 // Anything >= Target is an InstTarget subclass. Note that the value-spaces |
| 71 // are shared across targets. To avoid confusion over the definition of | 71 // are shared across targets. To avoid confusion over the definition of |
| 72 // shared values, an object specific to one target should never be passed | 72 // shared values, an object specific to one target should never be passed |
| 73 // to a different target. | 73 // to a different target. |
| 74 Target, | 74 Target, |
| 75 Target_Max = std::numeric_limits<uint8_t>::max(), | 75 Target_Max = std::numeric_limits<uint8_t>::max(), |
| 76 }; | 76 }; |
| 77 static_assert(Target <= Target_Max, "Must not be above max."); | 77 static_assert(Target <= Target_Max, "Must not be above max."); |
| 78 InstKind getKind() const { return Kind; } | 78 InstKind getKind() const { return Kind; } |
| 79 IceString getInstName() const { | |
|
John
2016/01/26 19:07:17
Can you move the method to IceInst.cpp?
John
2016/01/26 19:07:17
this is really useful, but does not belong in this
Jim Stichnoth
2016/01/26 19:13:10
Could you also change the dump() methods in IceIns
Jim Stichnoth
2016/01/26 19:13:10
Add the following to the beginning of this method:
Eric Holk
2016/01/26 22:49:24
Sure.
Eric Holk
2016/01/26 22:49:24
Yup, I'm working on that now.
Eric Holk
2016/01/26 22:49:24
I made some of the obvious changes, but it looks l
| |
| 80 switch (Kind) { | |
| 81 case Unreachable: | |
|
John
2016/01/26 19:07:17
I would suggest the following:
switch (Kind) {
#d
| |
| 82 return "Unreachable"; | |
| 83 case Alloca: | |
| 84 return "Alloca"; | |
| 85 case Arithmetic: | |
| 86 return "Arithmetic"; | |
| 87 case Br: | |
| 88 return "Br"; | |
| 89 case Call: | |
| 90 return "Call"; | |
| 91 case Cast: | |
| 92 return "Cast"; | |
| 93 case ExtractElement: | |
| 94 return "ExtractElement"; | |
| 95 case Fcmp: | |
| 96 return "Fcmp"; | |
| 97 case Icmp: | |
| 98 return "Icmp"; | |
| 99 case IntrinsicCall: | |
| 100 return "IntrinsicCall"; | |
| 101 case InsertElement: | |
| 102 return "InsertElement"; | |
| 103 case Load: | |
| 104 return "Load"; | |
| 105 case Phi: | |
| 106 return "Phi"; | |
| 107 case Ret: | |
| 108 return "Ret"; | |
| 109 case Select: | |
| 110 return "Select"; | |
| 111 case Store: | |
| 112 return "Store"; | |
| 113 case Switch: | |
| 114 return "Switch"; | |
| 115 case Assign: | |
| 116 return "Assign"; | |
| 117 case BundleLock: | |
| 118 return "BundleLock"; | |
| 119 case BundleUnlock: | |
| 120 return "BundleUnlock"; | |
| 121 case FakeDef: | |
| 122 return "FakeDef"; | |
| 123 case FakeUse: | |
| 124 return "FakeUse"; | |
| 125 case FakeKill: | |
| 126 return "FakeKill"; | |
| 127 case JumpTable: | |
| 128 return "JumpTable"; | |
| 129 default: | |
| 130 return "Target"; | |
|
Jim Stichnoth
2016/01/26 19:13:10
Add an assert:
assert(Kind >= Target);
just to m
Eric Holk
2016/01/26 22:49:24
Okay.
| |
| 131 } | |
| 132 } | |
| 79 | 133 |
| 80 InstNumberT getNumber() const { return Number; } | 134 InstNumberT getNumber() const { return Number; } |
| 81 void renumber(Cfg *Func); | 135 void renumber(Cfg *Func); |
| 82 enum { | 136 enum { |
| 83 NumberDeleted = -1, | 137 NumberDeleted = -1, |
| 84 NumberSentinel = 0, | 138 NumberSentinel = 0, |
| 85 NumberInitial = 2, | 139 NumberInitial = 2, |
| 86 NumberExtended = NumberInitial - 1 | 140 NumberExtended = NumberInitial - 1 |
| 87 }; | 141 }; |
| 88 | 142 |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 #undef X | 335 #undef X |
| 282 _num | 336 _num |
| 283 }; | 337 }; |
| 284 | 338 |
| 285 static InstArithmetic *create(Cfg *Func, OpKind Op, Variable *Dest, | 339 static InstArithmetic *create(Cfg *Func, OpKind Op, Variable *Dest, |
| 286 Operand *Source1, Operand *Source2) { | 340 Operand *Source1, Operand *Source2) { |
| 287 return new (Func->allocate<InstArithmetic>()) | 341 return new (Func->allocate<InstArithmetic>()) |
| 288 InstArithmetic(Func, Op, Dest, Source1, Source2); | 342 InstArithmetic(Func, Op, Dest, Source1, Source2); |
| 289 } | 343 } |
| 290 OpKind getOp() const { return Op; } | 344 OpKind getOp() const { return Op; } |
| 345 | |
| 346 IceString getInstName() const { | |
|
John
2016/01/26 19:07:17
add the
if (!BuildDefs::dump()) return "";
and m
Jim Stichnoth
2016/01/26 19:13:10
Are you shadowing a nonvirtual method name in a ba
Eric Holk
2016/01/26 22:49:24
Okay.
Eric Holk
2016/01/26 22:49:24
I was thinking the same thing. I made it virtual.
| |
| 347 switch (Op) { | |
| 348 #define X(tag, str, commutative) \ | |
| 349 case tag: \ | |
| 350 return str; | |
| 351 ICEINSTARITHMETIC_TABLE | |
| 352 #undef X | |
| 353 default: | |
| 354 return "Unknown"; | |
| 355 } | |
| 356 } | |
| 357 | |
| 291 static const char *getOpName(OpKind Op); | 358 static const char *getOpName(OpKind Op); |
| 292 bool isCommutative() const; | 359 bool isCommutative() const; |
| 293 void dump(const Cfg *Func) const override; | 360 void dump(const Cfg *Func) const override; |
| 294 static bool classof(const Inst *Inst) { | 361 static bool classof(const Inst *Inst) { |
| 295 return Inst->getKind() == Arithmetic; | 362 return Inst->getKind() == Arithmetic; |
| 296 } | 363 } |
| 297 | 364 |
| 298 private: | 365 private: |
| 299 InstArithmetic(Cfg *Func, OpKind Op, Variable *Dest, Operand *Source1, | 366 InstArithmetic(Cfg *Func, OpKind Op, Variable *Dest, Operand *Source1, |
| 300 Operand *Source2); | 367 Operand *Source2); |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 989 static void noteHead(Ice::Inst *, Ice::Inst *) {} | 1056 static void noteHead(Ice::Inst *, Ice::Inst *) {} |
| 990 void deleteNode(Ice::Inst *) {} | 1057 void deleteNode(Ice::Inst *) {} |
| 991 | 1058 |
| 992 private: | 1059 private: |
| 993 mutable ilist_half_node<Ice::Inst> Sentinel; | 1060 mutable ilist_half_node<Ice::Inst> Sentinel; |
| 994 }; | 1061 }; |
| 995 | 1062 |
| 996 } // end of namespace llvm | 1063 } // end of namespace llvm |
| 997 | 1064 |
| 998 #endif // SUBZERO_SRC_ICEINST_H | 1065 #endif // SUBZERO_SRC_ICEINST_H |
| OLD | NEW |