llvm.org GIT mirror llvm / 6279cd8
Now with EVEN FEWER statics! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74143 91177308-0d34-0410-b5e6-96231b3b80d8 Owen Anderson 11 years ago
2 changed file(s) with 38 addition(s) and 29 deletion(s). Raw diff Collapse all Expand all
2424
2525 class IntrinsicLowering {
2626 const TargetData& TD;
27
28 Constant *SetjmpFCache;
29 Constant *LongjmpFCache;
30 Constant *AbortFCache;
31 Constant *MemcpyFCache;
32 Constant *MemmoveFCache;
33 Constant *MemsetFCache;
34 Constant *sqrtFCache;
35 Constant *sqrtDCache;
36 Constant *sqrtLDCache;
37 Constant *logFCache;
38 Constant *logDCache;
39 Constant *logLDCache;
40 Constant *log2FCache;
41 Constant *log2DCache;
42 Constant *log2LDCache;
43 Constant *log10FCache;
44 Constant *log10DCache;
45 Constant *log10LDCache;
46 Constant *expFCache;
47 Constant *expDCache;
48 Constant *expLDCache;
49 Constant *exp2FCache;
50 Constant *exp2DCache;
51 Constant *exp2LDCache;
52 Constant *powFCache;
53 Constant *powDCache;
54 Constant *powLDCache;
55
56 bool Warned;
2757 public:
28 explicit IntrinsicLowering(const TargetData &td) : TD(td) {}
58 explicit IntrinsicLowering(const TargetData &td) :
59 TD(td), SetjmpFCache(0), LongjmpFCache(0), AbortFCache(0),
60 MemcpyFCache(0), MemmoveFCache(0), MemsetFCache(0), sqrtFCache(0),
61 sqrtDCache(0), sqrtLDCache(0), logFCache(0), logDCache(0), logLDCache(0),
62 log2FCache(0), log2DCache(0), log2LDCache(0), log10FCache(0),
63 log10DCache(0), log10LDCache(0), expFCache(0), expDCache(0),
64 expLDCache(0), exp2FCache(0), exp2DCache(0), exp2LDCache(0), powFCache(0),
65 powDCache(0), powLDCache(0), Warned(false) {}
2966
3067 /// AddPrototypes - This method, if called, causes all of the prototypes
3168 /// that might be needed by an intrinsic lowering implementation to be
667667 // by the lowerinvoke pass. In both cases, the right thing to do is to
668668 // convert the call to an explicit setjmp or longjmp call.
669669 case Intrinsic::setjmp: {
670 static Constant *SetjmpFCache = 0;
671670 Value *V = ReplaceCallWith("setjmp", CI, CI->op_begin() + 1, CI->op_end(),
672671 Type::Int32Ty, SetjmpFCache);
673672 if (CI->getType() != Type::VoidTy)
680679 break;
681680
682681 case Intrinsic::longjmp: {
683 static Constant *LongjmpFCache = 0;
684682 ReplaceCallWith("longjmp", CI, CI->op_begin() + 1, CI->op_end(),
685683 Type::VoidTy, LongjmpFCache);
686684 break;
688686
689687 case Intrinsic::siglongjmp: {
690688 // Insert the call to abort
691 static Constant *AbortFCache = 0;
692689 ReplaceCallWith("abort", CI, CI->op_end(), CI->op_end(),
693690 Type::VoidTy, AbortFCache);
694691 break;
727724
728725 case Intrinsic::stacksave:
729726 case Intrinsic::stackrestore: {
730 static bool Warned = false;
731727 if (!Warned)
732728 cerr << "WARNING: this target does not support the llvm.stack"
733729 << (Callee->getIntrinsicID() == Intrinsic::stacksave ?
782778 break; // Strip out annotate intrinsic
783779
784780 case Intrinsic::memcpy: {
785 static Constant *MemcpyFCache = 0;
786781 const IntegerType *IntPtr = TD.getIntPtrType();
787782 Value *Size = Builder.CreateIntCast(CI->getOperand(3), IntPtr,
788783 /* isSigned */ false);
795790 break;
796791 }
797792 case Intrinsic::memmove: {
798 static Constant *MemmoveFCache = 0;
799793 const IntegerType *IntPtr = TD.getIntPtrType();
800794 Value *Size = Builder.CreateIntCast(CI->getOperand(3), IntPtr,
801795 /* isSigned */ false);
808802 break;
809803 }
810804 case Intrinsic::memset: {
811 static Constant *MemsetFCache = 0;
812805 const IntegerType *IntPtr = TD.getIntPtrType();
813806 Value *Size = Builder.CreateIntCast(CI->getOperand(3), IntPtr,
814807 /* isSigned */ false);
823816 break;
824817 }
825818 case Intrinsic::sqrt: {
826 static Constant *sqrtFCache = 0;
827 static Constant *sqrtDCache = 0;
828 static Constant *sqrtLDCache = 0;
829819 ReplaceFPIntrinsicWithCall(CI, sqrtFCache, sqrtDCache, sqrtLDCache,
830820 "sqrtf", "sqrt", "sqrtl");
831821 break;
832822 }
833823 case Intrinsic::log: {
834 static Constant *logFCache = 0;
835 static Constant *logDCache = 0;
836 static Constant *logLDCache = 0;
837824 ReplaceFPIntrinsicWithCall(CI, logFCache, logDCache, logLDCache,
838825 "logf", "log", "logl");
839826 break;
840827 }
841828 case Intrinsic::log2: {
842 static Constant *log2FCache = 0;
843 static Constant *log2DCache = 0;
844 static Constant *log2LDCache = 0;
845829 ReplaceFPIntrinsicWithCall(CI, log2FCache, log2DCache, log2LDCache,
846830 "log2f", "log2", "log2l");
847831 break;
848832 }
849833 case Intrinsic::log10: {
850 static Constant *log10FCache = 0;
851 static Constant *log10DCache = 0;
852 static Constant *log10LDCache = 0;
853834 ReplaceFPIntrinsicWithCall(CI, log10FCache, log10DCache, log10LDCache,
854835 "log10f", "log10", "log10l");
855836 break;
856837 }
857838 case Intrinsic::exp: {
858 static Constant *expFCache = 0;
859 static Constant *expDCache = 0;
860 static Constant *expLDCache = 0;
861839 ReplaceFPIntrinsicWithCall(CI, expFCache, expDCache, expLDCache,
862840 "expf", "exp", "expl");
863841 break;
864842 }
865843 case Intrinsic::exp2: {
866 static Constant *exp2FCache = 0;
867 static Constant *exp2DCache = 0;
868 static Constant *exp2LDCache = 0;
869844 ReplaceFPIntrinsicWithCall(CI, exp2FCache, exp2DCache, exp2LDCache,
870845 "exp2f", "exp2", "exp2l");
871846 break;
872847 }
873848 case Intrinsic::pow: {
874 static Constant *powFCache = 0;
875 static Constant *powDCache = 0;
876 static Constant *powLDCache = 0;
877849 ReplaceFPIntrinsicWithCall(CI, powFCache, powDCache, powLDCache,
878850 "powf", "pow", "powl");
879851 break;