| 6219 | } |
| 6220 | |
| 6221 | void BfIRCodeGen::ApplySimdFeatures() |
| 6222 | { |
| 6223 | Array<std::tuple<llvm::Function*, BfIRSimdType>> functionsToProcess; |
| 6224 | |
| 6225 | for (auto pair : mFunctionsUsingSimd) |
| 6226 | functionsToProcess.Add({ pair.mKey, pair.mValue }); |
| 6227 | |
| 6228 | while (functionsToProcess.Count() > 0) |
| 6229 | { |
| 6230 | auto tuple = functionsToProcess.front(); |
| 6231 | functionsToProcess.RemoveAt(0); |
| 6232 | |
| 6233 | auto function = std::get<0>(tuple); |
| 6234 | auto simdType = std::get<1>(tuple); |
| 6235 | |
| 6236 | auto currentSimdType = GetSimdTypeFromFunction(function); |
| 6237 | simdType = simdType > currentSimdType ? simdType : currentSimdType; |
| 6238 | |
| 6239 | function->addFnAttr("target-features", GetSimdTypeString(simdType).c_str()); |
| 6240 | |
| 6241 | if (function->hasFnAttribute(llvm::Attribute::AlwaysInline)) |
| 6242 | { |
| 6243 | for (auto user : function->users()) |
| 6244 | { |
| 6245 | if (auto call = llvm::dyn_cast<llvm::CallInst>(user)) |
| 6246 | { |
| 6247 | auto func = call->getFunction(); |
| 6248 | functionsToProcess.Add({ func, simdType }); |
| 6249 | } |
| 6250 | } |
| 6251 | } |
| 6252 | } |
| 6253 | } |
| 6254 | |
| 6255 | int BfIRCodeGen::GetIntrinsicId(const StringImpl& name) |
| 6256 | { |