================
@@ -21,6 +21,48 @@
using namespace clang;
using namespace clang::CIRGen;
+/// Get integer from a mlir::Value that is an int constant or a constant op.
+static int64_t getIntValueFromConstOp(mlir::Value val) {
+ return val.getDefiningOp<cir::ConstantOp>().getIntValue().getSExtValue();
+}
+
+static mlir::Value emitClFlush(CIRGenFunction& cgf,
+ const CallExpr* e,
+ mlir::Value& op) {
+ mlir::Type voidTy = cir::VoidType::get(&cgf.getMLIRContext());
+ mlir::Location location = cgf.getLoc(e->getExprLoc());
+ return cir::LLVMIntrinsicCallOp::create(
+ cgf.getBuilder(), location,
+ cgf.getBuilder().getStringAttr("x86.sse2.clflush"), voidTy, op)
+ .getResult();
+}
+
+static mlir::Value emitPrefetch(CIRGenFunction& cgf,
+ const CallExpr* e,
+ mlir::Value& addr,
+ int64_t hint) {
+ CIRGenBuilderTy& builder = cgf.getBuilder();
+ mlir::Type voidTy = cir::VoidType::get(&cgf.getMLIRContext());
+ mlir::Type sInt32Ty = cir::IntType::get(&cgf.getMLIRContext(), 32, true);
+ mlir::Value address = builder.createPtrBitcast(addr, voidTy);
+ mlir::Location location = cgf.getLoc(e->getExprLoc());
+ mlir::Value rw =
+ cir::ConstantOp::create(builder, location,
+ cir::IntAttr::get(sInt32Ty, (hint >> 2) & 0x1));
+ mlir::Value locality =
+ cir::ConstantOp::create(builder, location,
+ cir::IntAttr::get(sInt32Ty, hint & 0x3));
----------------
andykaylor wrote:
```suggestion
mlir::Value locality = builder.getSignedInt(location, hint & 0x3, 32);
```
https://github.com/llvm/llvm-project/pull/167401
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits