================
@@ -16542,12 +16542,64 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned
BuiltinID,
Intrinsic::ID ID = Intrinsic::not_intrinsic;
+ // The lambda function converts builtin_cpu_is function into directly
+ // returning false or true, or it gets and checks the information from the
+ // kernel variable _system_configuration for AIX OS.
+
+#include "llvm/TargetParser/PPCTargetParser.def"
+ auto ConvBuiltinCpu = [&](unsigned SupportMagic, unsigned FieldIdx,
+ unsigned CompOp, unsigned OpValue) -> Value * {
+ if (SupportMagic == AIX_BUILTIN_PPC_FALSE)
+ return llvm::ConstantInt::getFalse(ConvertType(E->getType()));
+
+ if (SupportMagic == AIX_BUILTIN_PPC_TRUE)
+ return llvm::ConstantInt::getTrue(ConvertType(E->getType()));
+
+ assert(SupportMagic <= SYS_CONF && "Invalid value for SupportMagic.");
+ llvm::Type *STy = llvm::StructType::get(PPC_SYSTEMCONFIG_TYPE);
+
+ llvm::Constant *SysConf =
+ CGM.CreateRuntimeVariable(STy, "_system_configuration");
+
+ // Grab the appropriate field from _system_configuration.
+ llvm::Value *Idxs[] = {ConstantInt::get(Int32Ty, 0),
+ ConstantInt::get(Int32Ty, FieldIdx)};
+
+ llvm::Value *FieldValue = Builder.CreateGEP(STy, SysConf, Idxs);
+ FieldValue = Builder.CreateAlignedLoad(Int32Ty, FieldValue,
+ CharUnits::fromQuantity(4));
+
+ assert((CompOp == COMP_EQ) && "Only equal comparisons are supported!");
----------------
amy-kwan wrote:
I noticed that this does not get set later in this function. Should this be
checked earlier rather than later?
https://github.com/llvm/llvm-project/pull/80069
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits