Skip to content

Commit cbd0a58

Browse files
author
Alex Voicu
committed
Fix mismatch with upstream, where target BIs got moved out of the main CGBuiltin file.
1 parent ab04be0 commit cbd0a58

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16496,7 +16496,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
1649616496
return Builder.CreateCall(CGM.getIntrinsic(IID), Ops);
1649716497
}
1649816498
case X86::BI__builtin_ia32_cvtsbf162ss_32:
16499-
return Builder.CreateFPExt(Ops[0], Builder.getFloatTy());
16499+
return Builder.CreateFPExt(Ops[0], Builder.getFloatTy());
1650016500

1650116501
case X86::BI__builtin_ia32_cvtneps2bf16_256_mask:
1650216502
case X86::BI__builtin_ia32_cvtneps2bf16_512_mask: {
@@ -18542,6 +18542,18 @@ void CodeGenFunction::AddAMDGPUFenceAddressSpaceMMRA(llvm::Instruction *Inst,
1854218542
Inst->setMetadata(LLVMContext::MD_mmra, MMRAMetadata::getMD(Ctx, MMRAs));
1854318543
}
1854418544

18545+
static Value *GetOrInsertAMDGPUPredicate(CodeGenFunction &CGF, Twine Name) {
18546+
auto PTy = IntegerType::getInt1Ty(CGF.getLLVMContext());
18547+
18548+
auto *P = cast<GlobalVariable>(
18549+
CGF.CGM.getModule().getOrInsertGlobal(Name.str(), PTy));
18550+
P->setConstant(true);
18551+
P->setExternallyInitialized(true);
18552+
18553+
return CGF.Builder.CreateLoad(
18554+
RawAddress(P, PTy, CharUnits::One(), KnownNonNull));
18555+
}
18556+
1854518557
Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID,
1854618558
const CallExpr *E) {
1854718559
llvm::AtomicOrdering AO = llvm::AtomicOrdering::SequentiallyConsistent;
@@ -18894,6 +18906,23 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID,
1889418906
llvm::Value *Env = EmitScalarExpr(E->getArg(0));
1889518907
return Builder.CreateCall(F, {Env});
1889618908
}
18909+
case AMDGPU::BI__builtin_amdgcn_processor_is: {
18910+
assert(CGM.getTriple().isSPIRV() &&
18911+
"__builtin_amdgcn_processor_is should never reach CodeGen for "
18912+
"concrete targets!");
18913+
StringRef Proc = cast<clang::StringLiteral>(E->getArg(0))->getString();
18914+
return GetOrInsertAMDGPUPredicate(*this, "llvm.amdgcn.is." + Proc);
18915+
}
18916+
case AMDGPU::BI__builtin_amdgcn_is_invocable: {
18917+
assert(CGM.getTriple().isSPIRV() &&
18918+
"__builtin_amdgcn_is_invocable should never reach CodeGen for "
18919+
"concrete targets!");
18920+
auto *FD = cast<FunctionDecl>(
18921+
cast<DeclRefExpr>(E->getArg(0))->getReferencedDeclOfCallee());
18922+
StringRef RF =
18923+
getContext().BuiltinInfo.getRequiredFeatures(FD->getBuiltinID());
18924+
return GetOrInsertAMDGPUPredicate(*this, "llvm.amdgcn.has." + RF);
18925+
}
1889718926
case AMDGPU::BI__builtin_amdgcn_read_exec:
1889818927
return EmitAMDGCNBallotForExec(*this, E, Int64Ty, Int64Ty, false);
1889918928
case AMDGPU::BI__builtin_amdgcn_read_exec_lo:

0 commit comments

Comments
 (0)