mirror of
https://github.com/RPCS3/llvm.git
synced 2026-07-19 15:13:49 -04:00
[APFloat] Reduce some dispatch boilerplates. NFC.
Summary: This is an attempt to reduce the verbose manual dispatching code in APFloat. This doesn't handle multiple dispatch on single discriminator (e.g. APFloat::add(const APFloat&)), nor handles multiple dispatch on multiple discriminators (e.g. APFloat::convert()). Reviewers: hfinkel, echristo, jlebar Subscribers: mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D29161 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293255 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
+12
-5
@@ -26,6 +26,15 @@
|
||||
#include <cstring>
|
||||
#include <limits.h>
|
||||
|
||||
#define APFLOAT_DISPATCH_ON_SEMANTICS(METHOD_CALL) \
|
||||
do { \
|
||||
if (usesLayout<IEEEFloat>(getSemantics())) \
|
||||
return U.IEEE.METHOD_CALL; \
|
||||
if (usesLayout<DoubleAPFloat>(getSemantics())) \
|
||||
return U.Double.METHOD_CALL; \
|
||||
llvm_unreachable("Unexpected semantics"); \
|
||||
} while (false)
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
/// A macro used to combine two fcCategory enums into one key which can be used
|
||||
@@ -4418,11 +4427,7 @@ APFloat::Storage::Storage(IEEEFloat F, const fltSemantics &Semantics) {
|
||||
}
|
||||
|
||||
APFloat::opStatus APFloat::convertFromString(StringRef Str, roundingMode RM) {
|
||||
if (usesLayout<IEEEFloat>(getSemantics()))
|
||||
return U.IEEE.convertFromString(Str, RM);
|
||||
if (usesLayout<DoubleAPFloat>(getSemantics()))
|
||||
return U.Double.convertFromString(Str, RM);
|
||||
llvm_unreachable("Unexpected semantics");
|
||||
APFLOAT_DISPATCH_ON_SEMANTICS(convertFromString(Str, RM));
|
||||
}
|
||||
|
||||
hash_code hash_value(const APFloat &Arg) {
|
||||
@@ -4512,3 +4517,5 @@ APFloat::opStatus APFloat::convertToInteger(APSInt &result,
|
||||
}
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#undef APFLOAT_DISPATCH_ON_SEMANTICS
|
||||
|
||||
Reference in New Issue
Block a user