================
@@ -1816,6 +1901,103 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl
&gd, unsigned builtinID,
return emitLibraryCall(*this, fd, e,
cgm.getBuiltinLibFunction(fd, builtinID));
+ // See if we have a target specific intrinsic.
+ std::string name = getContext().BuiltinInfo.getName(builtinID);
+ Intrinsic::ID intrinsicID = Intrinsic::not_intrinsic;
+ StringRef prefix =
+ llvm::Triple::getArchTypePrefix(getTarget().getTriple().getArch());
+ if (!prefix.empty()) {
+ intrinsicID = Intrinsic::getIntrinsicForClangBuiltin(prefix.data(), name);
+ // NOTE we don't need to perform a compatibility flag check here since the
+ // intrinsics are declared in Builtins*.def via LANGBUILTIN which filter
the
+ // MS builtins via ALL_MS_LANGUAGES and are filtered earlier.
+ if (intrinsicID == Intrinsic::not_intrinsic)
+ intrinsicID = Intrinsic::getIntrinsicForMSBuiltin(prefix.data(), name);
+ }
+
+ if (intrinsicID != Intrinsic::not_intrinsic) {
+ unsigned iceArguments = 0;
+ ASTContext::GetBuiltinTypeError error;
+ getContext().GetBuiltinType(builtinID, error, &iceArguments);
+ assert(error == ASTContext::GE_None && "Should not codegen an error");
+
+ llvm::StringRef name = llvm::Intrinsic::getName(intrinsicID);
+ // cir::LLVMIntrinsicCallOp expects intrinsic name to not have prefix
+ // "llvm." For example, `llvm.nvvm.barrier0` should be passed as
+ // `nvvm.barrier0`.
+ if (!name.consume_front("llvm."))
+ assert(false && "bad intrinsic name!");
+
+ cir::FuncType intrinsicType =
+ getIntrinsicType(&getMLIRContext(), intrinsicID);
+
+ SmallVector<mlir::Value> args;
+ for (unsigned i = 0; i < e->getNumArgs(); i++) {
----------------
Priyanshu3820 wrote:
I'll remove the current `getIntrinsicArgumentTypeFromAST` and create a
`correctIntegerSignedness` for both argument and return type by passing the
QualType directly.
https://github.com/llvm/llvm-project/pull/179098
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits