================
@@ -542,6 +542,121 @@ static mlir::Value emitX86vpcom(CIRGenBuilderTy &builder,
mlir::Location loc,
return builder.createVecCompare(loc, pred, op0, op1);
}
+static mlir::Value emitX86Aes(CIRGenBuilderTy &builder, mlir::Location loc,
+ llvm::StringRef intrinsicName, mlir::Type
retType,
+ SmallVectorImpl<mlir::Value> &ops) {
+ // Create return struct type and call intrinsic function.
+ mlir::Type vecType =
+ mlir::cast<cir::PointerType>(ops[0].getType()).getPointee();
+ cir::RecordType rstRecTy = builder.getAnonRecordTy({retType, vecType});
+ mlir::Value rstValueRec = emitIntrinsicCallOp(
+ builder, loc, intrinsicName, rstRecTy, mlir::ValueRange{ops[1], ops[2]});
+
+ // Extract the first return value and truncate it to 1 bit, then cast result
+ // to bool value.
+ mlir::Value flag =
+ cir::ExtractMemberOp::create(builder, loc, rstValueRec, /*index*/ 0);
+ mlir::Value flagBit0 = builder.createCast(loc, cir::CastKind::integral, flag,
+ builder.getUIntNTy(1));
+ mlir::Value succ = builder.createCast(loc, cir::CastKind::int_to_bool,
+ flagBit0, builder.getBoolTy());
+
+ // Extract the second return value, store it to output address if success.
+ mlir::Value out =
+ cir::ExtractMemberOp::create(builder, loc, rstValueRec, /*index*/ 1);
+ Address outAddr(ops[0], /*align*/ CharUnits::fromQuantity(16));
+ cir::IfOp::create(
+ builder, loc, succ, /*withElseRegion=*/true,
+ /*thenBuilder=*/
+ [&](mlir::OpBuilder &b, mlir::Location) {
+ builder.createStore(loc, out, outAddr);
+ builder.createYield(loc);
+ },
+ /*elseBuilder=*/
+ [&](mlir::OpBuilder &b, mlir::Location) {
+ mlir::Value zero = builder.getNullValue(vecType, loc);
+ builder.createStore(loc, zero, outAddr);
+ builder.createYield(loc);
+ });
+
+ return cir::ExtractMemberOp::create(builder, loc, rstValueRec, /*index*/ 0);
+}
+
+static mlir::Value emitX86Aeswide(CIRGenBuilderTy &builder, mlir::Location loc,
+ llvm::StringRef intrinsicName,
+ mlir::Type retType,
+ SmallVectorImpl<mlir::Value> &ops) {
+ mlir::Type vecType =
+ mlir::cast<cir::PointerType>(ops[1].getType()).getPointee();
+
+ // Create struct for return type and load input arguments, then call
+ // intrinsic function.
+ llvm::SmallVector<mlir::Type, 9> rstRec = {retType};
+ llvm::SmallVector<mlir::Value, 9> arguments = {ops[2]};
----------------
andykaylor wrote:
```suggestion
mlir::Type recTypes[9];
mlir::Value arguments[9];
recTypes[0] = retType;
arguments[0] = ops[2];
```
Since the number of elements is known, using a SmallVector here doesn't add
anything.
https://github.com/llvm/llvm-project/pull/175892
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits