[PATCH] D151492: Add fastmath attributes to llvm.call_intrinsic
Lily Orth-Smith via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu May 25 13:44:16 PDT 2023
electriclilies updated this revision to Diff 525779.
electriclilies added a comment.
Remove whitespace
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D151492/new/
https://reviews.llvm.org/D151492
Files:
mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
mlir/test/Dialect/LLVMIR/call-intrin.mlir
Index: mlir/test/Dialect/LLVMIR/call-intrin.mlir
===================================================================
--- mlir/test/Dialect/LLVMIR/call-intrin.mlir
+++ mlir/test/Dialect/LLVMIR/call-intrin.mlir
@@ -11,7 +11,7 @@
llvm.func @round_sse41() -> vector<4xf32> {
%0 = llvm.mlir.constant(1 : i32) : i32
%1 = llvm.mlir.constant(dense<0.2> : vector<4xf32>) : vector<4xf32>
- %res = llvm.call_intrinsic "llvm.x86.sse41.round.ss"(%1, %1, %0) : (vector<4xf32>, vector<4xf32>, i32) -> vector<4xf32> {}
+ %res = llvm.call_intrinsic "llvm.x86.sse41.round.ss"(%1, %1, %0) : (vector<4xf32>, vector<4xf32>, i32) -> vector<4xf32> {fastmathFlags = #llvm.fastmath<reassoc>}
llvm.return %res: vector<4xf32>
}
Index: mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
===================================================================
--- mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
+++ mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
@@ -114,6 +114,9 @@
} else {
fn = llvm::Intrinsic::getDeclaration(module, id, {});
}
+ Operation* op2 = op;
+ if (auto fmf = dyn_cast<FastmathFlagsInterface>(op2))
+ builder.setFastMathFlags(getFastmathFlags(fmf));
auto *inst =
builder.CreateCall(fn, moduleTranslation.lookupValues(op.getOperands()));
Index: mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
===================================================================
--- mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
+++ mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
@@ -867,19 +867,19 @@
// CallIntrinsicOp
//===--------------------------------------------------------------------===//
-def LLVM_CallIntrinsicOp : LLVM_Op<"call_intrinsic"> {
+def LLVM_CallIntrinsicOp : LLVM_Op<"call_intrinsic", [DeclareOpInterfaceMethods<FastmathFlagsInterface>]> {
let summary = "Call to an LLVM intrinsic function.";
let description = [{
Call the specified llvm intrinsic. If the intrinsic is overloaded, use
the MLIR function type of this op to determine which intrinsic to call.
}];
- let arguments = (ins StrAttr:$intrin, Variadic<LLVM_Type>:$args);
+ let arguments = (ins StrAttr:$intrin, Variadic<LLVM_Type>:$args, DefaultValuedAttr<LLVM_FastmathFlagsAttr, "{}">:$fastmathFlags);
let results = (outs Variadic<LLVM_Type>:$results);
let llvmBuilder = [{
return convertCallLLVMIntrinsicOp(op, builder, moduleTranslation);
}];
let assemblyFormat = [{
- $intrin `(` $args `)` `:` functional-type($args, $results) attr-dict
+ $intrin `(` $args `)` `:` functional-type($args, $results) custom<LLVMOpAttrs>(attr-dict)
}];
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151492.525779.patch
Type: text/x-patch
Size: 2677 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230525/1a1e496a/attachment.bin>
More information about the cfe-commits
mailing list