| OLD | NEW |
| 1 //===- subzero/src/IceOperand.h - High-level operands -----------*- C++ -*-===// | 1 //===- subzero/src/IceOperand.h - High-level operands -----------*- 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 kConstInteger32, | 44 kConstInteger32, |
| 45 kConstInteger64, | 45 kConstInteger64, |
| 46 kConstFloat, | 46 kConstFloat, |
| 47 kConstDouble, | 47 kConstDouble, |
| 48 kConstRelocatable, | 48 kConstRelocatable, |
| 49 kConstUndef, | 49 kConstUndef, |
| 50 kConst_Target, // leave space for target-specific constant kinds | 50 kConst_Target, // leave space for target-specific constant kinds |
| 51 kConst_Max = kConst_Target + MaxTargetKinds, | 51 kConst_Max = kConst_Target + MaxTargetKinds, |
| 52 kVariable, | 52 kVariable, |
| 53 kVariable64On32, | 53 kVariable64On32, |
| 54 kVariableBoolean, |
| 54 kVariable_Target, // leave space for target-specific variable kinds | 55 kVariable_Target, // leave space for target-specific variable kinds |
| 55 kVariable_Max = kVariable_Target + MaxTargetKinds, | 56 kVariable_Max = kVariable_Target + MaxTargetKinds, |
| 56 // Target-specific operand classes use kTarget as the starting point for | 57 // Target-specific operand classes use kTarget as the starting point for |
| 57 // their Kind enum space. Note that the value-spaces are shared across | 58 // their Kind enum space. Note that the value-spaces are shared across |
| 58 // targets. To avoid confusion over the definition of shared values, an | 59 // targets. To avoid confusion over the definition of shared values, an |
| 59 // object specific to one target should never be passed to a different | 60 // object specific to one target should never be passed to a different |
| 60 // target. | 61 // target. |
| 61 kTarget, | 62 kTarget, |
| 62 kTarget_Max = std::numeric_limits<uint8_t>::max(), | 63 kTarget_Max = std::numeric_limits<uint8_t>::max(), |
| 63 }; | 64 }; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 88 dump(Func, Func->getContext()->getStrDump()); | 89 dump(Func, Func->getContext()->getStrDump()); |
| 89 } | 90 } |
| 90 void dump(Ostream &Str) const { | 91 void dump(Ostream &Str) const { |
| 91 if (BuildDefs::dump()) | 92 if (BuildDefs::dump()) |
| 92 dump(nullptr, Str); | 93 dump(nullptr, Str); |
| 93 } | 94 } |
| 94 /// @} | 95 /// @} |
| 95 | 96 |
| 96 virtual ~Operand() = default; | 97 virtual ~Operand() = default; |
| 97 | 98 |
| 99 virtual Variable *asBoolean() { return nullptr; } |
| 100 |
| 98 protected: | 101 protected: |
| 99 Operand(OperandKind Kind, Type Ty) : Ty(Ty), Kind(Kind) { | 102 Operand(OperandKind Kind, Type Ty) : Ty(Ty), Kind(Kind) { |
| 100 // It is undefined behavior to have a larger value in the enum | 103 // It is undefined behavior to have a larger value in the enum |
| 101 assert(Kind <= kTarget_Max); | 104 assert(Kind <= kTarget_Max); |
| 102 } | 105 } |
| 103 | 106 |
| 104 const Type Ty; | 107 const Type Ty; |
| 105 const OperandKind Kind; | 108 const OperandKind Kind; |
| 106 /// Vars and NumVars are initialized by the derived class. | 109 /// Vars and NumVars are initialized by the derived class. |
| 107 SizeT NumVars = 0; | 110 SizeT NumVars = 0; |
| (...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 /// loop nest depth factor for each use. | 980 /// loop nest depth factor for each use. |
| 978 RegWeight getUseWeight(const Variable *Var) const; | 981 RegWeight getUseWeight(const Variable *Var) const; |
| 979 | 982 |
| 980 private: | 983 private: |
| 981 const Cfg *Func; | 984 const Cfg *Func; |
| 982 MetadataKind Kind; | 985 MetadataKind Kind; |
| 983 CfgVector<VariableTracking> Metadata; | 986 CfgVector<VariableTracking> Metadata; |
| 984 const static InstDefList NoDefinitions; | 987 const static InstDefList NoDefinitions; |
| 985 }; | 988 }; |
| 986 | 989 |
| 990 /// BooleanVariable represents a variable that was the zero-extended result of a |
| 991 /// comparison. It maintains a pointer to its original i1 source so that the |
| 992 /// WASM frontend can avoid adding needless comparisons. |
| 993 class BooleanVariable : public Variable { |
| 994 BooleanVariable() = delete; |
| 995 BooleanVariable(const BooleanVariable &) = delete; |
| 996 BooleanVariable &operator=(const BooleanVariable &) = delete; |
| 997 |
| 998 BooleanVariable(const Cfg *Func, OperandKind K, Type Ty, SizeT Index) |
| 999 : Variable(Func, K, Ty, Index) {} |
| 1000 |
| 1001 public: |
| 1002 static BooleanVariable *create(Cfg *Func, Type Ty, SizeT Index) { |
| 1003 return new (Func->allocate<BooleanVariable>()) |
| 1004 BooleanVariable(Func, kVariable, Ty, Index); |
| 1005 } |
| 1006 |
| 1007 virtual Variable *asBoolean() { return BoolSource; } |
| 1008 |
| 1009 void setBoolSource(Variable *Src) { BoolSource = Src; } |
| 1010 |
| 1011 static bool classof(const Operand *Operand) { |
| 1012 return Operand->getKind() == kVariableBoolean; |
| 1013 } |
| 1014 |
| 1015 private: |
| 1016 Variable *BoolSource = nullptr; |
| 1017 }; |
| 1018 |
| 987 } // end of namespace Ice | 1019 } // end of namespace Ice |
| 988 | 1020 |
| 989 #endif // SUBZERO_SRC_ICEOPERAND_H | 1021 #endif // SUBZERO_SRC_ICEOPERAND_H |
| OLD | NEW |