From 2d90907990de40ed3f08b472edfccce20ac14a1c Mon Sep 17 00:00:00 2001 From: Erich Keane Date: Fri, 6 Oct 2017 16:40:45 +0000 Subject: [PATCH] Split X86::BI__builtin_cpu_init handling into own function[NFC] The Cpu Init functionality is required for the target attribute, so this patch simply splits it out into its own function, exactly like CpuIs and CpuSupports. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315075 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGBuiltin.cpp | 16 +++++++++------- lib/CodeGen/CodeGenFunction.h | 1 + 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index 113089b435..7ae558f9ae 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -7708,12 +7708,21 @@ Value *CodeGenFunction::EmitX86CpuSupports(ArrayRef FeatureStrs) { return Builder.CreateICmpNE(Bitset, llvm::ConstantInt::get(Int32Ty, 0)); } +Value *CodeGenFunction::EmitX86CpuInit() { + llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, + /*Variadic*/ false); + llvm::Constant *Func = CGM.CreateRuntimeFunction(FTy, "__cpu_indicator_init"); + return Builder.CreateCall(Func); +} + Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, const CallExpr *E) { if (BuiltinID == X86::BI__builtin_cpu_is) return EmitX86CpuIs(E); if (BuiltinID == X86::BI__builtin_cpu_supports) return EmitX86CpuSupports(E); + if (BuiltinID == X86::BI__builtin_cpu_init) + return EmitX86CpuInit(); SmallVector Ops; @@ -7765,13 +7774,6 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, switch (BuiltinID) { default: return nullptr; - case X86::BI__builtin_cpu_init: { - llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, - /*Variadic*/false); - llvm::Constant *Func = CGM.CreateRuntimeFunction(FTy, - "__cpu_indicator_init"); - return Builder.CreateCall(Func); - } case X86::BI_mm_prefetch: { Value *Address = Ops[0]; Value *RW = ConstantInt::get(Int32Ty, 0); diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index 68be87fc5f..3ec3466a48 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -3901,6 +3901,7 @@ private: llvm::Value *EmitX86CpuIs(StringRef CPUStr); llvm::Value *EmitX86CpuSupports(const CallExpr *E); llvm::Value *EmitX86CpuSupports(ArrayRef FeatureStrs); + llvm::Value *EmitX86CpuInit(); }; /// Helper class with most of the code for saving a value for a -- 2.40.0