File tree Expand file tree Collapse file tree 4 files changed +29
-12
lines changed Expand file tree Collapse file tree 4 files changed +29
-12
lines changed Original file line number Diff line number Diff line change 14
14
#ifndef LLVM_CODEGEN_SELECTIONDAG_H
15
15
#define LLVM_CODEGEN_SELECTIONDAG_H
16
16
17
- #include " llvm/ADT/APFloat.h"
18
- #include " llvm/ADT/APInt.h"
19
17
#include " llvm/ADT/ArrayRef.h"
20
18
#include " llvm/ADT/DenseMap.h"
21
19
#include " llvm/ADT/DenseSet.h"
@@ -1824,16 +1822,7 @@ class SelectionDAG {
1824
1822
// / Returns an APFloat semantics tag appropriate for the given type. If VT is
1825
1823
// / a vector type, the element semantics are returned.
1826
1824
static const fltSemantics &EVTToAPFloatSemantics (EVT VT) {
1827
- switch (VT.getScalarType ().getSimpleVT ().SimpleTy ) {
1828
- default : llvm_unreachable (" Unknown FP format" );
1829
- case MVT::f16 : return APFloat::IEEEhalf ();
1830
- case MVT::bf16 : return APFloat::BFloat ();
1831
- case MVT::f32 : return APFloat::IEEEsingle ();
1832
- case MVT::f64 : return APFloat::IEEEdouble ();
1833
- case MVT::f80: return APFloat::x87DoubleExtended ();
1834
- case MVT::f128 : return APFloat::IEEEquad ();
1835
- case MVT::ppcf128: return APFloat::PPCDoubleDouble ();
1836
- }
1825
+ return VT.getFltSemantics ();
1837
1826
}
1838
1827
1839
1828
// / Add a dbg_value SDNode. If SD is non-null that means the
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ namespace llvm {
27
27
28
28
class LLVMContext ;
29
29
class Type ;
30
+ struct fltSemantics ;
30
31
31
32
// / Extended Value Type. Capable of holding value types which are not native
32
33
// / for any processor (such as the i12345 type), as well as the types an MVT
@@ -512,6 +513,10 @@ namespace llvm {
512
513
}
513
514
};
514
515
516
+ // / Returns an APFloat semantics tag appropriate for the value type. If this
517
+ // / is a vector type, the element semantics are returned.
518
+ const fltSemantics &getFltSemantics () const ;
519
+
515
520
private:
516
521
// Methods for handling the Extended-type case in functions above.
517
522
// These are all out-of-line to prevent users of this header file
Original file line number Diff line number Diff line change 26
26
namespace llvm {
27
27
28
28
class Type ;
29
+ struct fltSemantics ;
29
30
class raw_ostream ;
30
31
31
32
// / Machine Value Type. Every type that is supported natively by some
@@ -476,6 +477,10 @@ namespace llvm {
476
477
// / to a concrete value type.
477
478
static MVT getVT (Type *Ty, bool HandleUnknown = false );
478
479
480
+ // / Returns an APFloat semantics tag appropriate for the value type. If this
481
+ // / is a vector type, the element semantics are returned.
482
+ const fltSemantics &getFltSemantics () const ;
483
+
479
484
public:
480
485
// / SimpleValueType Iteration
481
486
// / @{
Original file line number Diff line number Diff line change 7
7
// ===----------------------------------------------------------------------===//
8
8
9
9
#include " llvm/CodeGen/ValueTypes.h"
10
+ #include " llvm/ADT/APFloat.h"
10
11
#include " llvm/ADT/StringExtras.h"
11
12
#include " llvm/IR/DerivedTypes.h"
12
13
#include " llvm/IR/Type.h"
@@ -289,6 +290,23 @@ EVT EVT::getEVT(Type *Ty, bool HandleUnknown){
289
290
}
290
291
}
291
292
293
+ const fltSemantics &MVT::getFltSemantics () const {
294
+ switch (getScalarType ().SimpleTy ) {
295
+ default : llvm_unreachable (" Unknown FP format" );
296
+ case MVT::f16 : return APFloat::IEEEhalf ();
297
+ case MVT::bf16 : return APFloat::BFloat ();
298
+ case MVT::f32 : return APFloat::IEEEsingle ();
299
+ case MVT::f64 : return APFloat::IEEEdouble ();
300
+ case MVT::f80: return APFloat::x87DoubleExtended ();
301
+ case MVT::f128 : return APFloat::IEEEquad ();
302
+ case MVT::ppcf128: return APFloat::PPCDoubleDouble ();
303
+ }
304
+ }
305
+
306
+ const fltSemantics &EVT::getFltSemantics () const {
307
+ return getScalarType ().getSimpleVT ().getFltSemantics ();
308
+ }
309
+
292
310
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
293
311
void MVT::dump () const {
294
312
print (dbgs ());
You can’t perform that action at this time.
0 commit comments