OLD | NEW |
1 //===-- CBackend.cpp - Library for converting LLVM code to C --------------===// | 1 //===-- CBackend.cpp - Library for converting LLVM code to C --------------===// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // This library converts LLVM code to C code, compilable by GCC and other C | 10 // This library converts LLVM code to C code, compilable by GCC and other C |
(...skipping 2824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2835 case Intrinsic::memory_barrier: | 2835 case Intrinsic::memory_barrier: |
2836 case Intrinsic::vastart: | 2836 case Intrinsic::vastart: |
2837 case Intrinsic::vacopy: | 2837 case Intrinsic::vacopy: |
2838 case Intrinsic::vaend: | 2838 case Intrinsic::vaend: |
2839 case Intrinsic::returnaddress: | 2839 case Intrinsic::returnaddress: |
2840 case Intrinsic::frameaddress: | 2840 case Intrinsic::frameaddress: |
2841 case Intrinsic::setjmp: | 2841 case Intrinsic::setjmp: |
2842 case Intrinsic::longjmp: | 2842 case Intrinsic::longjmp: |
2843 case Intrinsic::prefetch: | 2843 case Intrinsic::prefetch: |
2844 case Intrinsic::powi: | 2844 case Intrinsic::powi: |
| 2845 #if defined(TARGET_ENABLED_X86) |
2845 case Intrinsic::x86_sse_cmp_ss: | 2846 case Intrinsic::x86_sse_cmp_ss: |
2846 case Intrinsic::x86_sse_cmp_ps: | 2847 case Intrinsic::x86_sse_cmp_ps: |
2847 case Intrinsic::x86_sse2_cmp_sd: | 2848 case Intrinsic::x86_sse2_cmp_sd: |
2848 case Intrinsic::x86_sse2_cmp_pd: | 2849 case Intrinsic::x86_sse2_cmp_pd: |
| 2850 #endif // TARGET_ENABLED_X86 |
| 2851 #if defined(TARGET_ENABLED_POWERPC) |
2849 case Intrinsic::ppc_altivec_lvsl: | 2852 case Intrinsic::ppc_altivec_lvsl: |
| 2853 #endif // TARGET_ENABLED_POWERPC |
2850 case Intrinsic::uadd_with_overflow: | 2854 case Intrinsic::uadd_with_overflow: |
2851 case Intrinsic::sadd_with_overflow: | 2855 case Intrinsic::sadd_with_overflow: |
2852 // We directly implement these intrinsics | 2856 // We directly implement these intrinsics |
2853 break; | 2857 break; |
2854 default: | 2858 default: |
2855 // If this is an intrinsic that directly corresponds to a GCC | 2859 // If this is an intrinsic that directly corresponds to a GCC |
2856 // builtin, we handle it. | 2860 // builtin, we handle it. |
2857 const char *BuiltinName = ""; | 2861 const char *BuiltinName = ""; |
2858 #define GET_GCC_BUILTIN_NAME | 2862 #define GET_GCC_BUILTIN_NAME |
2859 #include "llvm/Intrinsics.gen" | 2863 #include "llvm/Intrinsics.gen" |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3093 Out << ", "; | 3097 Out << ", "; |
3094 writeOperand(I.getArgOperand(2)); | 3098 writeOperand(I.getArgOperand(2)); |
3095 Out << ")"; | 3099 Out << ")"; |
3096 return true; | 3100 return true; |
3097 case Intrinsic::stacksave: | 3101 case Intrinsic::stacksave: |
3098 // Emit this as: Val = 0; *((void**)&Val) = __builtin_stack_save() | 3102 // Emit this as: Val = 0; *((void**)&Val) = __builtin_stack_save() |
3099 // to work around GCC bugs (see PR1809). | 3103 // to work around GCC bugs (see PR1809). |
3100 Out << "0; *((void**)&" << GetValueName(&I) | 3104 Out << "0; *((void**)&" << GetValueName(&I) |
3101 << ") = __builtin_stack_save()"; | 3105 << ") = __builtin_stack_save()"; |
3102 return true; | 3106 return true; |
| 3107 #if defined(TARGET_ENABLED_X86) |
3103 case Intrinsic::x86_sse_cmp_ss: | 3108 case Intrinsic::x86_sse_cmp_ss: |
3104 case Intrinsic::x86_sse_cmp_ps: | 3109 case Intrinsic::x86_sse_cmp_ps: |
3105 case Intrinsic::x86_sse2_cmp_sd: | 3110 case Intrinsic::x86_sse2_cmp_sd: |
3106 case Intrinsic::x86_sse2_cmp_pd: | 3111 case Intrinsic::x86_sse2_cmp_pd: |
3107 Out << '('; | 3112 Out << '('; |
3108 printType(Out, I.getType()); | 3113 printType(Out, I.getType()); |
3109 Out << ')'; | 3114 Out << ')'; |
3110 // Multiple GCC builtins multiplex onto this intrinsic. | 3115 // Multiple GCC builtins multiplex onto this intrinsic. |
3111 switch (cast<ConstantInt>(I.getArgOperand(2))->getZExtValue()) { | 3116 switch (cast<ConstantInt>(I.getArgOperand(2))->getZExtValue()) { |
3112 default: llvm_unreachable("Invalid llvm.x86.sse.cmp!"); | 3117 default: llvm_unreachable("Invalid llvm.x86.sse.cmp!"); |
(...skipping 14 matching lines...) Expand all Loading... |
3127 Out << 's'; | 3132 Out << 's'; |
3128 else | 3133 else |
3129 Out << 'd'; | 3134 Out << 'd'; |
3130 | 3135 |
3131 Out << "("; | 3136 Out << "("; |
3132 writeOperand(I.getArgOperand(0)); | 3137 writeOperand(I.getArgOperand(0)); |
3133 Out << ", "; | 3138 Out << ", "; |
3134 writeOperand(I.getArgOperand(1)); | 3139 writeOperand(I.getArgOperand(1)); |
3135 Out << ")"; | 3140 Out << ")"; |
3136 return true; | 3141 return true; |
| 3142 #endif // TARGET_ENABLED_X86 |
| 3143 #if defined(TARGET_ENABLED_POWERPC) |
3137 case Intrinsic::ppc_altivec_lvsl: | 3144 case Intrinsic::ppc_altivec_lvsl: |
3138 Out << '('; | 3145 Out << '('; |
3139 printType(Out, I.getType()); | 3146 printType(Out, I.getType()); |
3140 Out << ')'; | 3147 Out << ')'; |
3141 Out << "__builtin_altivec_lvsl(0, (void*)"; | 3148 Out << "__builtin_altivec_lvsl(0, (void*)"; |
3142 writeOperand(I.getArgOperand(0)); | 3149 writeOperand(I.getArgOperand(0)); |
3143 Out << ")"; | 3150 Out << ")"; |
3144 return true; | 3151 return true; |
| 3152 #endif // TARGET_ENABLED_POWERPC |
3145 case Intrinsic::uadd_with_overflow: | 3153 case Intrinsic::uadd_with_overflow: |
3146 case Intrinsic::sadd_with_overflow: | 3154 case Intrinsic::sadd_with_overflow: |
3147 Out << GetValueName(I.getCalledFunction()) << "("; | 3155 Out << GetValueName(I.getCalledFunction()) << "("; |
3148 writeOperand(I.getArgOperand(0)); | 3156 writeOperand(I.getArgOperand(0)); |
3149 Out << ", "; | 3157 Out << ", "; |
3150 writeOperand(I.getArgOperand(1)); | 3158 writeOperand(I.getArgOperand(1)); |
3151 Out << ")"; | 3159 Out << ")"; |
3152 return true; | 3160 return true; |
3153 } | 3161 } |
3154 } | 3162 } |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3605 bool DisableVerify) { | 3613 bool DisableVerify) { |
3606 if (FileType != TargetMachine::CGFT_AssemblyFile) return true; | 3614 if (FileType != TargetMachine::CGFT_AssemblyFile) return true; |
3607 | 3615 |
3608 PM.add(createGCLoweringPass()); | 3616 PM.add(createGCLoweringPass()); |
3609 PM.add(createLowerInvokePass()); | 3617 PM.add(createLowerInvokePass()); |
3610 PM.add(createCFGSimplificationPass()); // clean up after lower invoke. | 3618 PM.add(createCFGSimplificationPass()); // clean up after lower invoke. |
3611 PM.add(new CWriter(o)); | 3619 PM.add(new CWriter(o)); |
3612 PM.add(createGCInfoDeleter()); | 3620 PM.add(createGCInfoDeleter()); |
3613 return false; | 3621 return false; |
3614 } | 3622 } |
OLD | NEW |