// Miscellaneous builtin for checking x86 cpu features.
// TODO: Make this somewhat generic so that other backends
// can use it?
+BUILTIN(__builtin_cpu_init, "v", "n")
BUILTIN(__builtin_cpu_supports, "bcC*", "nc")
BUILTIN(__builtin_cpu_is, "bcC*", "nc")
Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
const CallExpr *E) {
- if (BuiltinID == X86::BI__builtin_cpu_is)
- return EmitX86CpuIs(*this, E);
-
SmallVector<Value*, 4> Ops;
// Find out if any arguments are required to be integer constant expressions.
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__builtin_cpu_is:
+ return EmitX86CpuIs(*this, E);
case X86::BI__builtin_cpu_supports: {
const Expr *FeatureExpr = E->getArg(0)->IgnoreParenCasts();
StringRef FeatureStr = cast<StringLiteral>(FeatureExpr)->getString();