void applyFuncDeclUDAs(FuncDeclaration *decl, IrFunction *irFunc) { if (!decl->userAttribDecl) return; llvm::Function *func = irFunc->func; assert(func); Expressions *attrs = decl->userAttribDecl->getAttributes(); expandTuples(attrs); for (auto &attr : *attrs) { auto sle = getLdcAttributesStruct(attr); if (!sle) continue; auto name = sle->sd->ident->string; if (name == attr::llvmAttr) { applyAttrLLVMAttr(sle, func); } else if (name == attr::llvmFastMathFlag) { applyAttrLLVMFastMathFlag(sle, irFunc); } else if (name == attr::optStrategy) { applyAttrOptStrategy(sle, irFunc); } else if (name == attr::section) { applyAttrSection(sle, func); } else if (name == attr::target) { applyAttrTarget(sle, func); } else if (name == attr::weak) { // @weak is applied elsewhere } else { sle->warning( "ignoring unrecognized special attribute 'ldc.attributes.%s'", sle->sd->ident->string); } } }
void applyFuncDeclUDAs(FuncDeclaration *decl, IrFunction *irFunc) { if (!decl->userAttribDecl) return; llvm::Function *func = irFunc->getLLVMFunc(); assert(func); Expressions *attrs = decl->userAttribDecl->getAttributes(); expandTuples(attrs); for (auto &attr : *attrs) { auto sle = getLdcAttributesStruct(attr); if (!sle) continue; auto ident = sle->sd->ident; if (ident == Id::udaAllocSize) { applyAttrAllocSize(sle, irFunc); } else if (ident == Id::udaLLVMAttr) { applyAttrLLVMAttr(sle, func); } else if (ident == Id::udaLLVMFastMathFlag) { applyAttrLLVMFastMathFlag(sle, irFunc); } else if (ident == Id::udaOptStrategy) { applyAttrOptStrategy(sle, irFunc); } else if (ident == Id::udaSection) { applyAttrSection(sle, func); } else if (ident == Id::udaTarget) { applyAttrTarget(sle, func, irFunc); } else if (ident == Id::udaAssumeUsed) { applyAttrAssumeUsed(*gIR, sle, func); } else if (ident == Id::udaWeak || ident == Id::udaKernel) { // @weak and @kernel are applied elsewhere } else if (ident == Id::udaDynamicCompile) { irFunc->dynamicCompile = true; } else if (ident == Id::udaDynamicCompileConst) { sle->error( "Special attribute `ldc.attributes.%s` is only valid for variables", ident->toChars()); } else { sle->warning( "Ignoring unrecognized special attribute `ldc.attributes.%s`", ident->toChars()); } } }