llvm.org GIT mirror llvm / fff0af4
GlobalISel: Move computeValueLLTs Call lowering should use this directly instead of going through the EVT version, but more work is needed to deal with this (mostly the passing of the IR type pointer instead of the relevant properties in ArgInfo). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358111 91177308-0d34-0410-b5e6-96231b3b80d8 Matt Arsenault 1 year, 1 month ago
3 changed file(s) with 43 addition(s) and 30 deletion(s). Raw diff Collapse all Expand all
2424
2525 namespace llvm {
2626 class GlobalValue;
27 class LLT;
2728 class MachineBasicBlock;
2829 class MachineFunction;
2930 class TargetLoweringBase;
7172 SmallVectorImpl &ValueVTs,
7273 SmallVectorImpl *Offsets = nullptr,
7374 uint64_t StartingOffset = 0);
75
76 /// computeValueLLTs - Given an LLVM IR type, compute a sequence of
77 /// LLTs that represent all the individual underlying
78 /// non-aggregate types that comprise it.
79 ///
80 /// If Offsets is non-null, it points to a vector to be filled in
81 /// with the in-memory offsets of each of the individual values.
82 ///
83 void computeValueLLTs(const DataLayout &DL, Type &Ty,
84 SmallVectorImpl &ValueTys,
85 SmallVectorImpl *Offsets = nullptr,
86 uint64_t StartingOffset = 0);
7487
7588 /// ExtractTypeInfo - Returns the type info, possibly bitcast, encoded in V.
7689 GlobalValue *ExtractTypeInfo(Value *V);
110110 ValueVTs.push_back(TLI.getValueType(DL, Ty));
111111 if (Offsets)
112112 Offsets->push_back(StartingOffset);
113 }
114
115 void llvm::computeValueLLTs(const DataLayout &DL, Type &Ty,
116 SmallVectorImpl &ValueTys,
117 SmallVectorImpl *Offsets,
118 uint64_t StartingOffset) {
119 // Given a struct type, recursively traverse the elements.
120 if (StructType *STy = dyn_cast(&Ty)) {
121 const StructLayout *SL = DL.getStructLayout(STy);
122 for (unsigned I = 0, E = STy->getNumElements(); I != E; ++I)
123 computeValueLLTs(DL, *STy->getElementType(I), ValueTys, Offsets,
124 StartingOffset + SL->getElementOffset(I));
125 return;
126 }
127 // Given an array type, recursively traverse the elements.
128 if (ArrayType *ATy = dyn_cast(&Ty)) {
129 Type *EltTy = ATy->getElementType();
130 uint64_t EltSize = DL.getTypeAllocSize(EltTy);
131 for (unsigned i = 0, e = ATy->getNumElements(); i != e; ++i)
132 computeValueLLTs(DL, *EltTy, ValueTys, Offsets,
133 StartingOffset + i * EltSize);
134 return;
135 }
136 // Interpret void as zero return values.
137 if (Ty.isVoidTy())
138 return;
139 // Base case: we can get an LLT for this LLVM IR type.
140 ValueTys.push_back(getLLTForType(Ty, DL));
141 if (Offsets != nullptr)
142 Offsets->push_back(StartingOffset * 8);
113143 }
114144
115145 /// ExtractTypeInfo - Returns the type info, possibly bitcast, encoded in V.
151151 MachineFunctionPass::getAnalysisUsage(AU);
152152 }
153153
154 static void computeValueLLTs(const DataLayout &DL, Type &Ty,
155 SmallVectorImpl &ValueTys,
156 SmallVectorImpl *Offsets = nullptr,
157 uint64_t StartingOffset = 0) {
158 // Given a struct type, recursively traverse the elements.
159 if (StructType *STy = dyn_cast(&Ty)) {
160 const StructLayout *SL = DL.getStructLayout(STy);
161 for (unsigned I = 0, E = STy->getNumElements(); I != E; ++I)
162 computeValueLLTs(DL, *STy->getElementType(I), ValueTys, Offsets,
163 StartingOffset + SL->getElementOffset(I));
164 return;
165 }
166 // Given an array type, recursively traverse the elements.
167 if (ArrayType *ATy = dyn_cast(&Ty)) {
168 Type *EltTy = ATy->getElementType();
169 uint64_t EltSize = DL.getTypeAllocSize(EltTy);
170 for (unsigned i = 0, e = ATy->getNumElements(); i != e; ++i)
171 computeValueLLTs(DL, *EltTy, ValueTys, Offsets,
172 StartingOffset + i * EltSize);
173 return;
174 }
175 // Interpret void as zero return values.
176 if (Ty.isVoidTy())
177 return;
178 // Base case: we can get an LLT for this LLVM IR type.
179 ValueTys.push_back(getLLTForType(Ty, DL));
180 if (Offsets != nullptr)
181 Offsets->push_back(StartingOffset * 8);
182 }
183
184154 IRTranslator::ValueToVRegInfo::VRegListT &
185155 IRTranslator::allocateVRegs(const Value &Val) {
186156 assert(!VMap.contains(Val) && "Value already allocated in VMap");