Lines Matching +full:helper +full:- +full:function +full:- +full:name
1 //===---- Mips16HardFloat.cpp for Mips16 Hard Float --------===//
8 //===----------------------------------------------------------------------===//
12 //===----------------------------------------------------------------------===//
24 #define DEBUG_TYPE "mips16-hard-float"
67 // Determine which FP return type this function has
70 switch (T->getTypeID()) { in whichFPReturnVariant()
76 if (T->getStructNumElements() != 2) in whichFPReturnVariant()
78 if ((T->getContainedType(0)->isFloatTy()) && in whichFPReturnVariant()
79 (T->getContainedType(1)->isFloatTy())) in whichFPReturnVariant()
81 if ((T->getContainedType(0)->isDoubleTy()) && in whichFPReturnVariant()
82 (T->getContainedType(1)->isDoubleTy())) in whichFPReturnVariant()
106 static FPParamVariant whichFPParamVariantNeeded(Function &F) { in whichFPParamVariantNeeded()
111 TypeID ArgTypeID = F.getFunctionType()->getParamType(0)->getTypeID(); in whichFPParamVariantNeeded()
122 TypeID ArgTypeID0 = F.getFunctionType()->getParamType(0)->getTypeID(); in whichFPParamVariantNeeded()
123 TypeID ArgTypeID1 = F.getFunctionType()->getParamType(1)->getTypeID(); in whichFPParamVariantNeeded()
153 // Figure out if we need float point based on the function parameters.
157 static bool needsFPStubFromParams(Function &F) { in needsFPStubFromParams()
159 Type *ArgType = F.getFunctionType()->getParamType(0); in needsFPStubFromParams()
160 switch (ArgType->getTypeID()) { in needsFPStubFromParams()
171 static bool needsFPReturnHelper(Function &F) { in needsFPReturnHelper()
181 static bool needsFPHelperFromSig(Function &F) { in needsFPHelperFromSig()
258 // Make sure that we know we already need a stub for this function.
261 static void assureFPCallStub(Function &F, Module *M, in assureFPCallStub()
266 LLVMContext &Context = M->getContext(); in assureFPCallStub()
268 std::string Name = F.getName(); in assureFPCallStub() local
269 std::string SectionName = ".mips16.call.fp." + Name; in assureFPCallStub()
270 std::string StubName = "__call_stub_fp_" + Name; in assureFPCallStub()
274 Function *FStub = M->getFunction(StubName); in assureFPCallStub()
275 if (FStub && !FStub->isDeclaration()) return; in assureFPCallStub()
276 FStub = Function::Create(F.getFunctionType(), in assureFPCallStub()
277 Function::InternalLinkage, StubName, M); in assureFPCallStub()
278 FStub->addFnAttr("mips16_fp_stub"); in assureFPCallStub()
279 FStub->addFnAttr(llvm::Attribute::Naked); in assureFPCallStub()
280 FStub->addFnAttr(llvm::Attribute::NoInline); in assureFPCallStub()
281 FStub->addFnAttr(llvm::Attribute::NoUnwind); in assureFPCallStub()
282 FStub->addFnAttr("nomips16"); in assureFPCallStub()
283 FStub->setSection(SectionName); in assureFPCallStub()
285 FPReturnVariant RV = whichFPReturnVariant(FStub->getReturnType()); in assureFPCallStub()
293 AsmText += "jal " + Name + "\n"; in assureFPCallStub()
295 AsmText += "lui $$25, %hi(" + Name + ")\n"; in assureFPCallStub()
296 AsmText += "addiu $$25, $$25, %lo(" + Name + ")\n"; in assureFPCallStub()
377 static bool isIntrinsicInline(Function *F) { in isIntrinsicInline()
379 std::end(IntrinsicInline), F->getName()); in isIntrinsicInline()
382 // Returns of float, double and complex need to be handled with a helper
383 // function.
385 static bool fixupFPReturnAndCall(Function &F, Module *M, in fixupFPReturnAndCall()
388 LLVMContext &C = M->getContext(); in fixupFPReturnAndCall()
393 Value *RVal = RI->getReturnValue(); in fixupFPReturnAndCall()
396 // If there is a return value and it needs a helper function, in fixupFPReturnAndCall()
398 // return to this helper. The purpose of the helper is to move in fixupFPReturnAndCall()
402 Type *T = RVal->getType(); in fixupFPReturnAndCall()
405 static const char *const Helper[NoFPRet] = { in fixupFPReturnAndCall() local
409 const char *Name = Helper[RV]; in fixupFPReturnAndCall() local
414 // These helper functions have a different calling ABI so in fixupFPReturnAndCall()
416 // during call setup, the proper call lowering to the helper in fixupFPReturnAndCall()
425 Value *F = (M->getOrInsertFunction(Name, A, MyVoid, T, nullptr)); in fixupFPReturnAndCall()
428 FunctionType *FT = CI->getFunctionType(); in fixupFPReturnAndCall()
429 Function *F_ = CI->getCalledFunction(); in fixupFPReturnAndCall()
437 // helper functions in fixupFPReturnAndCall()
454 static void createFPFnStub(Function *F, Module *M, FPParamVariant PV, in createFPFnStub()
458 LLVMContext &Context = M->getContext(); in createFPFnStub()
459 std::string Name = F->getName(); in createFPFnStub() local
460 std::string SectionName = ".mips16.fn." + Name; in createFPFnStub()
461 std::string StubName = "__fn_stub_" + Name; in createFPFnStub()
462 std::string LocalName = "$$__fn_local_" + Name; in createFPFnStub()
463 Function *FStub = Function::Create in createFPFnStub()
464 (F->getFunctionType(), in createFPFnStub()
465 Function::InternalLinkage, StubName, M); in createFPFnStub()
466 FStub->addFnAttr("mips16_fp_stub"); in createFPFnStub()
467 FStub->addFnAttr(llvm::Attribute::Naked); in createFPFnStub()
468 FStub->addFnAttr(llvm::Attribute::NoUnwind); in createFPFnStub()
469 FStub->addFnAttr(llvm::Attribute::NoInline); in createFPFnStub()
470 FStub->addFnAttr("nomips16"); in createFPFnStub()
471 FStub->setSection(SectionName); in createFPFnStub()
479 AsmText += ".reloc 0, R_MIPS_NONE, " + Name + "\n"; in createFPFnStub()
482 AsmText += "la $$25, " + Name + "\n"; in createFPFnStub()
485 AsmText += LocalName + " = " + Name + "\n"; in createFPFnStub()
488 new UnreachableInst(FStub->getContext(), BB); in createFPFnStub()
492 // remove the use-soft-float attribute
494 static void removeUseSoftFloat(Function &F) { in removeUseSoftFloat()
496 DEBUG(errs() << "removing -use-soft-float\n"); in removeUseSoftFloat()
498 "use-soft-float", "false"); in removeUseSoftFloat()
500 if (F.hasFnAttribute("use-soft-float")) { in removeUseSoftFloat()
501 DEBUG(errs() << "still has -use-soft-float\n"); in removeUseSoftFloat()
513 // by calling a helper function before the actual return.
514 // 2) generate helper functions (stubs) that can be called by mips32
518 // 3) in the case of static relocation, generate helper functions so that
522 // predefined helper functions in libc but this work is currently done
529 if (F->hasFnAttribute("nomips16") && in runOnModule()
530 F->hasFnAttribute("use-soft-float")) { in runOnModule()
534 if (F->isDeclaration() || F->hasFnAttribute("mips16_fp_stub") || in runOnModule()
535 F->hasFnAttribute("nomips16")) continue; in runOnModule()