-
Notifications
You must be signed in to change notification settings - Fork 1
Add support for -mdecimal-float-abi option. #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dfp
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -62,6 +62,8 @@ def err_drv_no_cuda_libdevice : Error< | |||||||||
"cannot find libdevice for %0; provide path to different CUDA installation " | ||||||||||
"via '--cuda-path', or pass '-nocudalib' to build without linking with " | ||||||||||
"libdevice">; | ||||||||||
def err_drv_unsupported_decimal_fp_encoding_for_target : Error< | ||||||||||
"unsupported decimal floating-point encoding '%0' for target '%1'">; | ||||||||||
|
||||||||||
def err_drv_no_rocm_device_lib : Error< | ||||||||||
"cannot find ROCm device library%select{| for %1|for ABI version %1}0; provide its path via " | ||||||||||
|
@@ -242,6 +244,8 @@ def err_drv_cannot_read_config_file : Error< | |||||||||
"cannot read configuration file '%0': %1">; | ||||||||||
def err_drv_arg_requires_bitcode_input: Error< | ||||||||||
"option '%0' requires input to be LLVM bitcode">; | ||||||||||
def err_drv_invalid_mdecimal_float_abi_EQ: Error< | ||||||||||
"invalid argument '%0' to -mdecimal-float-abi=; each element must be one of: %1">; | ||||||||||
|
def err_drv_invalid_mdecimal_float_abi_EQ: Error< | |
"invalid argument '%0' to -mdecimal-float-abi=; each element must be one of: %1">; | |
def err_drv_invalid_mdecimal_float_abi_EQ: Error< | |
"invalid argument '%0' to -mdecimal-float-abi=; must be one of: %1">; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,6 +114,8 @@ struct TransferrableTargetInfo { | |
unsigned char DecimalFloat64Width, DecimalFloat64Align; | ||
unsigned char DecimalFloat128Width, DecimalFloat128Align; | ||
|
||
enum DecimalFloat { Libgcc_BID, Libgcc_DPD, Hard } DecimalFloatABI; | ||
|
||
|
||
// Fixed point bit widths | ||
unsigned char ShortAccumWidth, ShortAccumAlign; | ||
unsigned char AccumWidth, AccumAlign; | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -4284,6 +4284,11 @@ def malign_double : Flag<["-"], "malign-double">, Group<m_Group>, | |||||
MarshallingInfoFlag<LangOpts<"AlignDouble">>; | ||||||
let Flags = [TargetSpecific] in { | ||||||
def mfloat_abi_EQ : Joined<["-"], "mfloat-abi=">, Group<m_Group>, Values<"soft,softfp,hard">; | ||||||
def mdecimal_float_abi_EQ : Joined<["-"], "mdecimal-float-abi=">, Group<m_Group>, | ||||||
Visibility<[ClangOption, CC1Option]>, | ||||||
Values<"libgcc:bid,libgcc:dpd,hard">, | ||||||
|
Values<"libgcc:bid,libgcc:dpd,hard">, | |
Values<"hard,libgcc:bid,libgcc:dpd">, |
Perhaps we should allow default
as an explicit opt-in to the target dependent default behavior?
zahiraam marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -382,7 +382,8 @@ bool X86TargetInfo::handleTargetFeatures(std::vector<std::string> &Features, | |
HasX87 = true; | ||
} else if (Feature == "+fullbf16") { | ||
HasFullBFloat16 = true; | ||
} | ||
} else if (Feature == "+bid-encoding") | ||
HasBIDENCODING = true; | ||
|
||
|
||
X86SSEEnum Level = llvm::StringSwitch<X86SSEEnum>(Feature) | ||
.Case("+avx512f", AVX512F) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,6 +165,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public TargetInfo { | |
bool HasUINTR = false; | ||
bool HasCRC32 = false; | ||
bool HasX87 = false; | ||
bool HasBIDENCODING = false; | ||
|
||
|
||
protected: | ||
llvm::X86::CPUKind CPU = llvm::X86::CK_None; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -273,4 +273,44 @@ void x86::getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple, | |
Features.push_back("+prefer-no-gather"); | ||
if (Args.hasArg(options::OPT_mno_scatter)) | ||
Features.push_back("+prefer-no-scatter"); | ||
|
||
// -mdecimal-float-abi | ||
x86::DecimalFloatABI ABI = x86::getX86DecimalFloatABI(D, Triple, Args); | ||
if (ABI == DecimalFloatABI::Invalid) | ||
ABI = x86::getDefaultX86DecimalFloatABI(Triple, Args); | ||
if (ABI != x86::DecimalFloatABI::None && ABI != x86::DecimalFloatABI::Default) | ||
Features.push_back("+bid-encoding"); | ||
} | ||
|
||
x86::DecimalFloatABI | ||
x86::getDefaultX86DecimalFloatABI(const llvm::Triple &Triple, | ||
const ArgList &Args) { | ||
if (const Arg *A = Args.getLastArg(options::OPT_fdecimal_floating_point)) | ||
return DecimalFloatABI::Libgcc_BID; | ||
else | ||
return DecimalFloatABI::None; | ||
} | ||
|
||
// Get the decimal float ABI type from the command line arguments | ||
// -mdecimal-float-abi=. | ||
x86::DecimalFloatABI x86::getX86DecimalFloatABI(const Driver &D, | ||
const llvm::Triple &Triple, | ||
const ArgList &Args) { | ||
x86::DecimalFloatABI ABI = x86::DecimalFloatABI::Invalid; | ||
if (const Arg *A = Args.getLastArg(options::OPT_mdecimal_float_abi_EQ)) { | ||
StringRef Val = A->getValue(); | ||
ABI = llvm::StringSwitch<x86::DecimalFloatABI>(A->getValue()) | ||
.Case("libgcc:bid", DecimalFloatABI::Libgcc_BID) | ||
.Case("libgcc:dpd", DecimalFloatABI::Libgcc_DPD) | ||
.Case("hard", DecimalFloatABI::Hard) | ||
.Default(DecimalFloatABI::None); | ||
if (ABI != x86::DecimalFloatABI::None && | ||
ABI != x86::DecimalFloatABI::Default) { | ||
// X86 targets only allow BID encoding. | ||
if (ABI != x86::DecimalFloatABI::Libgcc_BID) | ||
D.Diag(diag::err_drv_unsupported_decimal_fp_encoding_for_target) | ||
<< Val << "X86"; | ||
} | ||
} | ||
return ABI; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,13 +21,29 @@ namespace driver { | |
namespace tools { | ||
namespace x86 { | ||
|
||
enum class DecimalFloatABI { | ||
Default, // Target-specific default. | ||
None, // No decimal floating-point support. | ||
Libgcc_BID, // libgcc with BID encoding. | ||
Libgcc_DPD, // libgcc with DPD encoding. | ||
Hard, // Target-specific hard ABI. | ||
Invalid | ||
|
||
}; | ||
|
||
std::string getX86TargetCPU(const Driver &D, const llvm::opt::ArgList &Args, | ||
const llvm::Triple &Triple); | ||
|
||
void getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple, | ||
const llvm::opt::ArgList &Args, | ||
std::vector<llvm::StringRef> &Features); | ||
|
||
DecimalFloatABI getX86DecimalFloatABI(const Driver &D, | ||
const llvm::Triple &Triple, | ||
const llvm::opt::ArgList &Args); | ||
|
||
DecimalFloatABI getDefaultX86DecimalFloatABI(const llvm::Triple &Triple, | ||
const llvm::opt::ArgList &Args); | ||
|
||
} // end namespace x86 | ||
} // end namespace target | ||
} // end namespace driver | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// DEFINE: %{common_opts_x86} = -### \ | ||
// DEFINE: -fexperimental-decimal-floating-point | ||
|
||
// X86 | ||
// RUN: %clang %{common_opts_x86} --target=x86_64 \ | ||
// RUN: -mdecimal-float-abi=libgcc:bid %s 2>&1 | FileCheck -check-prefix=BID %s | ||
|
||
// RUN: not %clang %{common_opts_x86} --target=x86_64 \ | ||
// RUN: -mdecimal-float-abi=libgcc:dpd %s 2>&1 \ | ||
// RUN: | FileCheck -check-prefix=ERROR_DPD %s | ||
|
||
// RUN: not %clang %{common_opts_x86} --target=x86_64 \ | ||
// RUN: -mdecimal-float-abi=hard %s 2>&1 \ | ||
// RUN: | FileCheck -check-prefix=ERROR_HARD %s | ||
|
||
// RUN: not %clang %{common_opts_x86} --target=mips64-unknown-linux \ | ||
// RUN: -mdecimal-float-abi=hard %s 2>&1 \ | ||
// RUN: | FileCheck -check-prefix=ERROR_MIPS_TRGT %s | ||
|
||
// BID: "-mdecimal-float-abi=libgcc:bid" {{.*}} "-target-feature" "+bid-encoding" | ||
|
||
// ERROR_DPD: unsupported decimal floating-point encoding 'libgcc:dpd' for target 'X86' | ||
// ERROR_HARD: unsupported decimal floating-point encoding 'hard' for target 'X86' | ||
// ERROR_MIPS_TRGT: unsupported option '-mdecimal-float-abi=' for target 'mips64-unknown-linux' | ||
|
||
// PPC | ||
// S390 | ||
// ARM |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -32,6 +32,14 @@ namespace llvm { | |||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
enum class DecimalFloatABI { | ||||||||||||||||||||||||||||||
Default, // Target-specific. | ||||||||||||||||||||||||||||||
None, // No decimal floating-point support. | ||||||||||||||||||||||||||||||
Libgcc_BID, // libgcc with BID encoding. | ||||||||||||||||||||||||||||||
Libgcc_DPD, // libgcc with DPD encoding. | ||||||||||||||||||||||||||||||
Hard // Hardware with target-specific encoding. | ||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||
|
enum class DecimalFloatABI { | |
Default, // Target-specific. | |
None, // No decimal floating-point support. | |
Libgcc_BID, // libgcc with BID encoding. | |
Libgcc_DPD, // libgcc with DPD encoding. | |
Hard // Hardware with target-specific encoding. | |
}; | |
enum class DecimalFloatABI { | |
Default, // Target-specific. | |
None, // No decimal floating-point support. | |
Hard, // Hardware with target-specific encoding. | |
Libgcc_BID, // libgcc with BID encoding. | |
Libgcc_DPD // libgcc with DPD encoding. | |
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,9 @@ def FeatureXSAVES : SubtargetFeature<"xsaves", "HasXSAVES", "true", | |
"Support xsaves instructions", | ||
[FeatureXSAVE]>; | ||
|
||
def FeatureBIDENCODING : SubtargetFeature<"bid-encoding", "HasBIDENCODING", "true", | ||
"Support BID encoding for decimal floatin-points">; | ||
|
||
|
||
def FeatureSSE1 : SubtargetFeature<"sse", "X86SSELevel", "SSE1", | ||
"Enable SSE instructions">; | ||
def FeatureSSE2 : SubtargetFeature<"sse2", "X86SSELevel", "SSE2", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The option value specifies both the ABI (hardware, libgcc, compiler-rt, etc...) and the encoding. Perhaps: