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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 kConstInteger32, | 45 kConstInteger32, |
46 kConstInteger64, | 46 kConstInteger64, |
47 kConstFloat, | 47 kConstFloat, |
48 kConstDouble, | 48 kConstDouble, |
49 kConstRelocatable, | 49 kConstRelocatable, |
50 kConstUndef, | 50 kConstUndef, |
51 kConst_Target, // leave space for target-specific constant kinds | 51 kConst_Target, // leave space for target-specific constant kinds |
52 kConst_Max = kConst_Target + MaxTargetKinds, | 52 kConst_Max = kConst_Target + MaxTargetKinds, |
53 kVariable, | 53 kVariable, |
54 kVariable64On32, | 54 kVariable64On32, |
55 kVariableVecOn32, | |
55 kVariableBoolean, | 56 kVariableBoolean, |
56 kVariable_Target, // leave space for target-specific variable kinds | 57 kVariable_Target, // leave space for target-specific variable kinds |
57 kVariable_Max = kVariable_Target + MaxTargetKinds, | 58 kVariable_Max = kVariable_Target + MaxTargetKinds, |
58 // Target-specific operand classes use kTarget as the starting point for | 59 // Target-specific operand classes use kTarget as the starting point for |
59 // their Kind enum space. Note that the value-spaces are shared across | 60 // their Kind enum space. Note that the value-spaces are shared across |
60 // targets. To avoid confusion over the definition of shared values, an | 61 // targets. To avoid confusion over the definition of shared values, an |
61 // object specific to one target should never be passed to a different | 62 // object specific to one target should never be passed to a different |
62 // target. | 63 // target. |
63 kTarget, | 64 kTarget, |
64 kTarget_Max = std::numeric_limits<uint8_t>::max(), | 65 kTarget_Max = std::numeric_limits<uint8_t>::max(), |
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
955 protected: | 956 protected: |
956 Variable64On32(const Cfg *Func, OperandKind K, Type Ty, SizeT Index) | 957 Variable64On32(const Cfg *Func, OperandKind K, Type Ty, SizeT Index) |
957 : Variable(Func, K, Ty, Index) { | 958 : Variable(Func, K, Ty, Index) { |
958 assert(typeWidthInBytes(Ty) == 8); | 959 assert(typeWidthInBytes(Ty) == 8); |
959 } | 960 } |
960 | 961 |
961 Variable *LoVar = nullptr; | 962 Variable *LoVar = nullptr; |
962 Variable *HiVar = nullptr; | 963 Variable *HiVar = nullptr; |
963 }; | 964 }; |
964 | 965 |
966 // VariableVecOn32 represents a vectory variable on a 32-bit architecture. In | |
Jim Stichnoth
2016/09/29 16:50:25
s/vectory/vector/
jaydeep.patil
2016/09/30 07:02:51
Done.
| |
967 // this situation the variable must be split into 4 containers. | |
968 class VariableVecOn32 : public Variable { | |
969 VariableVecOn32() = delete; | |
970 VariableVecOn32(const VariableVecOn32 &) = delete; | |
971 VariableVecOn32 &operator=(const VariableVecOn32 &) = delete; | |
972 | |
973 public: | |
974 static VariableVecOn32 *create(Cfg *Func, Type Ty, SizeT Index) { | |
975 return new (Func->allocate<VariableVecOn32>()) | |
976 VariableVecOn32(Func, kVariableVecOn32, Ty, Index); | |
977 } | |
978 | |
979 void setName(const Cfg *Func, const std::string &NewName) override { | |
980 Variable::setName(Func, NewName); | |
981 if (Containers.size()) { | |
Jim Stichnoth
2016/09/29 16:50:25
!Containers.empty()
here and below.
empty() shou
jaydeep.patil
2016/09/30 07:02:51
Done.
| |
982 for (size_t I = 0; I < NumContainers; I++) { | |
Jim Stichnoth
2016/09/29 16:50:25
We usually prefer pre-incement (++I), as ugly as t
jaydeep.patil
2016/09/30 07:02:51
Done.
| |
983 Containers[I]->setName(Func, getName() + "__cont" + std::to_string(I)); | |
984 } | |
985 } | |
986 } | |
987 | |
988 void setIsArg(bool Val = true) override { | |
989 Variable::setIsArg(Val); | |
990 if (Containers.size()) { | |
991 for (size_t I = 0; I < NumContainers; I++) { | |
Jim Stichnoth
2016/09/29 16:50:25
for (Variable &Var : Containers) {
Var.setName(.
jaydeep.patil
2016/09/30 07:02:51
Done.
| |
992 Containers[I]->setIsArg(getIsArg()); | |
993 } | |
994 } | |
995 } | |
996 | |
997 Variable *getVecElementAtIndex(uint32_t Index) { | |
998 assert(Index < NumElements); | |
999 if (Containers.size()) { | |
1000 return Containers[Index / (NumElements / NumContainers)]; | |
1001 } | |
1002 return nullptr; | |
1003 } | |
1004 | |
1005 Variable *getContainerAtIndex(uint32_t Index) { | |
1006 assert(Index < NumContainers); | |
1007 if (Containers.size()) { | |
1008 return Containers[Index]; | |
1009 } | |
1010 return nullptr; | |
1011 } | |
1012 | |
1013 size_t getNumContainers() { return NumContainers; } | |
Jim Stichnoth
2016/09/29 16:50:25
mark all these getters as const
jaydeep.patil
2016/09/30 07:02:51
Done.
| |
1014 size_t getNumElements() { return NumElements; } | |
1015 Type getElementType() { return ElementType; } | |
1016 Type getContainerType() { return ContainerType; } | |
1017 | |
1018 void initVecElement(Cfg *Func, Type VecType) { | |
1019 NumElements = typeNumElements(VecType); | |
1020 ElementType = typeElementType(VecType); | |
1021 // Specific to MIPS32R1 | |
1022 ContainerType = IceType_i32; | |
1023 NumContainers = typeWidthInBytes(ContainerType); | |
1024 for (size_t I = 0; I < NumContainers; I++) { | |
1025 Variable *Var = Func->makeVariable(ContainerType); | |
1026 Var->setIsArg(getIsArg()); | |
1027 if (BuildDefs::dump()) { | |
1028 Var->setName(Func, getName() + "__cont" + std::to_string(I)); | |
1029 } | |
1030 Containers.push_back(Var); | |
1031 } | |
1032 } | |
1033 | |
1034 static bool classof(const Operand *Operand) { | |
1035 OperandKind Kind = Operand->getKind(); | |
1036 return Kind == kVariableVecOn32; | |
1037 } | |
1038 | |
1039 protected: | |
1040 VariableVecOn32(const Cfg *Func, OperandKind K, Type Ty, SizeT Index) | |
1041 : Variable(Func, K, Ty, Index) { | |
1042 assert(typeWidthInBytes(Ty) == 16); | |
1043 } | |
1044 | |
1045 // Number of elements in this vector (4 to 16). | |
1046 size_t NumElements = 0; | |
Jim Stichnoth
2016/09/29 16:50:25
In the interest of keeping this data structure sma
jaydeep.patil
2016/09/30 07:02:51
Done.
| |
1047 VarList Containers; | |
1048 Type ElementType; | |
1049 // Number of physical registers used to hold this vector. | |
1050 size_t NumContainers; | |
Jim Stichnoth
2016/09/29 16:50:25
Can you remove this field, since it is redundant w
jaydeep.patil
2016/09/30 07:02:51
Done.
| |
1051 Type ContainerType; | |
1052 }; | |
1053 | |
965 enum MetadataKind { | 1054 enum MetadataKind { |
966 VMK_Uses, /// Track only uses, not defs | 1055 VMK_Uses, /// Track only uses, not defs |
967 VMK_SingleDefs, /// Track uses+defs, but only record single def | 1056 VMK_SingleDefs, /// Track uses+defs, but only record single def |
968 VMK_All /// Track uses+defs, including full def list | 1057 VMK_All /// Track uses+defs, including full def list |
969 }; | 1058 }; |
970 using InstDefList = CfgVector<const Inst *>; | 1059 using InstDefList = CfgVector<const Inst *>; |
971 | 1060 |
972 /// VariableTracking tracks the metadata for a single variable. It is | 1061 /// VariableTracking tracks the metadata for a single variable. It is |
973 /// only meant to be used internally by VariablesMetadata. | 1062 /// only meant to be used internally by VariablesMetadata. |
974 class VariableTracking { | 1063 class VariableTracking { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1103 return Operand->getKind() == kVariableBoolean; | 1192 return Operand->getKind() == kVariableBoolean; |
1104 } | 1193 } |
1105 | 1194 |
1106 private: | 1195 private: |
1107 Variable *BoolSource = nullptr; | 1196 Variable *BoolSource = nullptr; |
1108 }; | 1197 }; |
1109 | 1198 |
1110 } // end of namespace Ice | 1199 } // end of namespace Ice |
1111 | 1200 |
1112 #endif // SUBZERO_SRC_ICEOPERAND_H | 1201 #endif // SUBZERO_SRC_ICEOPERAND_H |
OLD | NEW |