================
@@ -43,11 +85,28 @@ mlir::Value CIRGenFunction::emitX86BuiltinExpr(unsigned
builtinID,
// Find out if any arguments are required to be integer constant expressions.
assert(!cir::MissingFeatures::handleBuiltinICEArguments());
+ // The operands of the builtin call
+ llvm::SmallVector<mlir::Value, 4> ops;
+
+ // `ICEArguments` is a bitmap indicating whether the argument at the i-th bit
+ // is required to be a constant integer expression.
+ unsigned ICEArguments = 0;
+ ASTContext::GetBuiltinTypeError error;
+ getContext().GetBuiltinType(builtinID, error, &ICEArguments);
+ assert(error == ASTContext::GE_None && "Error while getting builtin type.");
+
+ const unsigned numArgs = e->getNumArgs();
+ for (unsigned i = 0; i != numArgs; i++) {
+ ops.push_back(emitScalarOrConstFoldImmArg(ICEArguments, i, e));
+ }
+
switch (builtinID) {
default:
return {};
case X86::BI_mm_prefetch:
+ return emitPrefetch(*this, e, ops[0], getIntValueFromConstOp(ops[1]));
----------------
andykaylor wrote:
I'm not sure you're actually hitting this case. The test you added looks like
it would get here, but the check in the test is checking for `cir.prefetch`
being generated rather than `cir.llvm.intrinsic` as the code in this PR would
generate.
I just checked and the prefetch test passes without this PR being applied. This
is because in `xmmintrin.h` the definition of `_mm_prefetch` looks like this:
```
extern __inline void
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_prefetch(const void *__P, enum _mm_hint __I) {
/* Current PowerPC will ignores the hint parameters. */
__builtin_prefetch(__P);
}
```
It's calling the general prefetch builtin rather than the X86-specific builtin.
That's actually what we want. I'm not sure this handler is needed at all.
https://github.com/llvm/llvm-project/pull/167401
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits