Deleted Added
full compact
CGBuiltin.cpp (204643) CGBuiltin.cpp (204793)
1//===---- CGBuiltin.cpp - Emit LLVM Code for builtins ---------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 373 unchanged lines hidden (view full) ---

382 Value *Result = getTargetHooks().decodeReturnAddress(*this, Address);
383 return RValue::get(Result);
384 }
385 case Builtin::BI__builtin_frob_return_addr: {
386 Value *Address = EmitScalarExpr(E->getArg(0));
387 Value *Result = getTargetHooks().encodeReturnAddress(*this, Address);
388 return RValue::get(Result);
389 }
1//===---- CGBuiltin.cpp - Emit LLVM Code for builtins ---------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 373 unchanged lines hidden (view full) ---

382 Value *Result = getTargetHooks().decodeReturnAddress(*this, Address);
383 return RValue::get(Result);
384 }
385 case Builtin::BI__builtin_frob_return_addr: {
386 Value *Address = EmitScalarExpr(E->getArg(0));
387 Value *Result = getTargetHooks().encodeReturnAddress(*this, Address);
388 return RValue::get(Result);
389 }
390 case Builtin::BI__builtin_dwarf_sp_column: {
391 const llvm::IntegerType *Ty
392 = cast<llvm::IntegerType>(ConvertType(E->getType()));
393 int Column = getTargetHooks().getDwarfEHStackPointer(CGM);
394 if (Column == -1) {
395 CGM.ErrorUnsupported(E, "__builtin_dwarf_sp_column");
396 return RValue::get(llvm::UndefValue::get(Ty));
397 }
398 return RValue::get(llvm::ConstantInt::get(Ty, Column, true));
399 }
400 case Builtin::BI__builtin_init_dwarf_reg_size_table: {
401 Value *Address = EmitScalarExpr(E->getArg(0));
402 if (getTargetHooks().initDwarfEHRegSizeTable(*this, Address))
403 CGM.ErrorUnsupported(E, "__builtin_init_dwarf_reg_size_table");
404 return RValue::get(llvm::UndefValue::get(ConvertType(E->getType())));
405 }
390 case Builtin::BI__builtin_eh_return: {
391 Value *Int = EmitScalarExpr(E->getArg(0));
392 Value *Ptr = EmitScalarExpr(E->getArg(1));
393
394 const llvm::IntegerType *IntTy = cast<llvm::IntegerType>(Int->getType());
395 assert((IntTy->getBitWidth() == 32 || IntTy->getBitWidth() == 64) &&
396 "LLVM's __builtin_eh_return only supports 32- and 64-bit variants");
397 Value *F = CGM.getIntrinsic(IntTy->getBitWidth() == 32

--- 263 unchanged lines hidden (view full) ---

661 if (!FD->hasAttr<ConstAttr>())
662 break;
663 Value *Base = EmitScalarExpr(E->getArg(0));
664 Value *Exponent = EmitScalarExpr(E->getArg(1));
665 const llvm::Type *ArgType = Base->getType();
666 Value *F = CGM.getIntrinsic(Intrinsic::pow, &ArgType, 1);
667 return RValue::get(Builder.CreateCall2(F, Base, Exponent, "tmp"));
668 }
406 case Builtin::BI__builtin_eh_return: {
407 Value *Int = EmitScalarExpr(E->getArg(0));
408 Value *Ptr = EmitScalarExpr(E->getArg(1));
409
410 const llvm::IntegerType *IntTy = cast<llvm::IntegerType>(Int->getType());
411 assert((IntTy->getBitWidth() == 32 || IntTy->getBitWidth() == 64) &&
412 "LLVM's __builtin_eh_return only supports 32- and 64-bit variants");
413 Value *F = CGM.getIntrinsic(IntTy->getBitWidth() == 32

--- 263 unchanged lines hidden (view full) ---

677 if (!FD->hasAttr<ConstAttr>())
678 break;
679 Value *Base = EmitScalarExpr(E->getArg(0));
680 Value *Exponent = EmitScalarExpr(E->getArg(1));
681 const llvm::Type *ArgType = Base->getType();
682 Value *F = CGM.getIntrinsic(Intrinsic::pow, &ArgType, 1);
683 return RValue::get(Builder.CreateCall2(F, Base, Exponent, "tmp"));
684 }
685
686 case Builtin::BI__builtin_signbit:
687 case Builtin::BI__builtin_signbitf:
688 case Builtin::BI__builtin_signbitl: {
689 LLVMContext &C = CGM.getLLVMContext();
690
691 Value *Arg = EmitScalarExpr(E->getArg(0));
692 const llvm::Type *ArgTy = Arg->getType();
693 if (ArgTy->isPPC_FP128Ty())
694 break; // FIXME: I'm not sure what the right implementation is here.
695 int ArgWidth = ArgTy->getPrimitiveSizeInBits();
696 const llvm::Type *ArgIntTy = llvm::IntegerType::get(C, ArgWidth);
697 Value *BCArg = Builder.CreateBitCast(Arg, ArgIntTy);
698 Value *ZeroCmp = llvm::Constant::getNullValue(ArgIntTy);
699 Value *Result = Builder.CreateICmpSLT(BCArg, ZeroCmp);
700 return RValue::get(Builder.CreateZExt(Result, ConvertType(E->getType())));
669 }
701 }
702 }
670
671 // If this is an alias for a libm function (e.g. __builtin_sin) turn it into
672 // that function.
673 if (getContext().BuiltinInfo.isLibFunction(BuiltinID) ||
674 getContext().BuiltinInfo.isPredefinedLibFunction(BuiltinID))
675 return EmitCall(E->getCallee()->getType(),
676 CGM.getBuiltinLibFunction(FD, BuiltinID),
677 ReturnValueSlot(),

--- 52 unchanged lines hidden (view full) ---

730 if (hasAggregateLLVMType(E->getType()))
731 return RValue::getAggregate(CreateMemTemp(E->getType()));
732 return RValue::get(llvm::UndefValue::get(ConvertType(E->getType())));
733}
734
735Value *CodeGenFunction::EmitTargetBuiltinExpr(unsigned BuiltinID,
736 const CallExpr *E) {
737 switch (Target.getTriple().getArch()) {
703
704 // If this is an alias for a libm function (e.g. __builtin_sin) turn it into
705 // that function.
706 if (getContext().BuiltinInfo.isLibFunction(BuiltinID) ||
707 getContext().BuiltinInfo.isPredefinedLibFunction(BuiltinID))
708 return EmitCall(E->getCallee()->getType(),
709 CGM.getBuiltinLibFunction(FD, BuiltinID),
710 ReturnValueSlot(),

--- 52 unchanged lines hidden (view full) ---

763 if (hasAggregateLLVMType(E->getType()))
764 return RValue::getAggregate(CreateMemTemp(E->getType()));
765 return RValue::get(llvm::UndefValue::get(ConvertType(E->getType())));
766}
767
768Value *CodeGenFunction::EmitTargetBuiltinExpr(unsigned BuiltinID,
769 const CallExpr *E) {
770 switch (Target.getTriple().getArch()) {
771 case llvm::Triple::arm:
772 case llvm::Triple::thumb:
773 return EmitARMBuiltinExpr(BuiltinID, E);
738 case llvm::Triple::x86:
739 case llvm::Triple::x86_64:
740 return EmitX86BuiltinExpr(BuiltinID, E);
741 case llvm::Triple::ppc:
742 case llvm::Triple::ppc64:
743 return EmitPPCBuiltinExpr(BuiltinID, E);
744 default:
745 return 0;
746 }
747}
748
774 case llvm::Triple::x86:
775 case llvm::Triple::x86_64:
776 return EmitX86BuiltinExpr(BuiltinID, E);
777 case llvm::Triple::ppc:
778 case llvm::Triple::ppc64:
779 return EmitPPCBuiltinExpr(BuiltinID, E);
780 default:
781 return 0;
782 }
783}
784
785Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID,
786 const CallExpr *E) {
787 switch (BuiltinID) {
788 default: return 0;
789
790 case ARM::BI__builtin_thread_pointer: {
791 Value *AtomF = CGM.getIntrinsic(Intrinsic::arm_thread_pointer, 0, 0);
792 return Builder.CreateCall(AtomF);
793 }
794 }
795}
796
749Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
750 const CallExpr *E) {
751
752 llvm::SmallVector<Value*, 4> Ops;
753
754 for (unsigned i = 0, e = E->getNumArgs(); i != e; i++)
755 Ops.push_back(EmitScalarExpr(E->getArg(i)));
756

--- 204 unchanged lines hidden ---
797Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
798 const CallExpr *E) {
799
800 llvm::SmallVector<Value*, 4> Ops;
801
802 for (unsigned i = 0, e = E->getNumArgs(); i != e; i++)
803 Ops.push_back(EmitScalarExpr(E->getArg(i)));
804

--- 204 unchanged lines hidden ---