forked from swiftlang/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MLIR][LLVM] Add fast-math related function attribute support (llvm#7…
…9812) Adds unsafe-fp-math, no-infs-fp-math, no-nans-fp-math, approx-func-fp-math, and no-signed-zeros-fp-math function attributes. This allows code generators using the LLVMIR dialect to match the codegen of Clang.
- Loading branch information
Showing
6 changed files
with
228 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// RUN: mlir-translate -mlir-to-llvmir -split-input-file %s | FileCheck %s | ||
|
||
// CHECK-LABEL: define void @unsafe_fp_math_func_true() | ||
// CHECK-SAME: #[[ATTRS:[0-9]+]] | ||
llvm.func @unsafe_fp_math_func_true() attributes {unsafe_fp_math = true} { | ||
llvm.return | ||
} | ||
// CHECK: attributes #[[ATTRS]] = { "unsafe-fp-math"="true" } | ||
|
||
// ----- | ||
|
||
// CHECK-LABEL: define void @unsafe_fp_math_func_false() | ||
// CHECK-SAME: #[[ATTRS:[0-9]+]] | ||
llvm.func @unsafe_fp_math_func_false() attributes {unsafe_fp_math = false} { | ||
llvm.return | ||
} | ||
// CHECK: attributes #[[ATTRS]] = { "unsafe-fp-math"="false" } | ||
|
||
// ----- | ||
|
||
// CHECK-LABEL: define void @no_infs_fp_math_func_true() | ||
// CHECK-SAME: #[[ATTRS:[0-9]+]] | ||
llvm.func @no_infs_fp_math_func_true() attributes {no_infs_fp_math = true} { | ||
llvm.return | ||
} | ||
// CHECK: attributes #[[ATTRS]] = { "no-infs-fp-math"="true" } | ||
|
||
// ----- | ||
|
||
// CHECK-LABEL: define void @no_infs_fp_math_func_false() | ||
// CHECK-SAME: #[[ATTRS:[0-9]+]] | ||
llvm.func @no_infs_fp_math_func_false() attributes {no_infs_fp_math = false} { | ||
llvm.return | ||
} | ||
// CHECK: attributes #[[ATTRS]] = { "no-infs-fp-math"="false" } | ||
|
||
// ----- | ||
|
||
// CHECK-LABEL: define void @no_nans_fp_math_func_true() | ||
// CHECK-SAME: #[[ATTRS:[0-9]+]] | ||
llvm.func @no_nans_fp_math_func_true() attributes {no_nans_fp_math = true} { | ||
llvm.return | ||
} | ||
// CHECK: attributes #[[ATTRS]] = { "no-nans-fp-math"="true" } | ||
|
||
// ----- | ||
|
||
// CHECK-LABEL: define void @no_nans_fp_math_func_false() | ||
// CHECK-SAME: #[[ATTRS:[0-9]+]] | ||
llvm.func @no_nans_fp_math_func_false() attributes {no_nans_fp_math = false} { | ||
llvm.return | ||
} | ||
// CHECK: attributes #[[ATTRS]] = { "no-nans-fp-math"="false" } | ||
|
||
// ----- | ||
|
||
// CHECK-LABEL: define void @approx_func_fp_math_func_true() | ||
// CHECK-SAME: #[[ATTRS:[0-9]+]] | ||
llvm.func @approx_func_fp_math_func_true() attributes {approx_func_fp_math = true} { | ||
llvm.return | ||
} | ||
// CHECK: attributes #[[ATTRS]] = { "approx-func-fp-math"="true" } | ||
|
||
// ----- | ||
// | ||
// CHECK-LABEL: define void @approx_func_fp_math_func_false() | ||
// CHECK-SAME: #[[ATTRS:[0-9]+]] | ||
llvm.func @approx_func_fp_math_func_false() attributes {approx_func_fp_math = false} { | ||
llvm.return | ||
} | ||
// CHECK: attributes #[[ATTRS]] = { "approx-func-fp-math"="false" } | ||
|
||
// ----- | ||
|
||
// CHECK-LABEL: define void @no_signed_zeros_fp_math_func_true() | ||
// CHECK-SAME: #[[ATTRS:[0-9]+]] | ||
llvm.func @no_signed_zeros_fp_math_func_true() attributes {no_signed_zeros_fp_math = true} { | ||
llvm.return | ||
} | ||
// CHECK: attributes #[[ATTRS]] = { "no-signed-zeros-fp-math"="true" } | ||
|
||
// ----- | ||
|
||
// CHECK-LABEL: define void @no_signed_zeros_fp_math_func_false() | ||
// CHECK-SAME: #[[ATTRS:[0-9]+]] | ||
llvm.func @no_signed_zeros_fp_math_func_false() attributes {no_signed_zeros_fp_math = false} { | ||
llvm.return | ||
} | ||
// CHECK: attributes #[[ATTRS]] = { "no-signed-zeros-fp-math"="false" } |