diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2021-10-09 11:28:11 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2021-10-09 11:29:26 +0200 |
commit | a94002cd6408034b55a027135d705cc1487b25ae (patch) | |
tree | d072351aa0cc316ebb886967d263c832642114c6 | |
parent | 55b9146848c4460beb77ee2928c4a049ab6034c2 (diff) | |
download | llvm-a94002cd6408034b55a027135d705cc1487b25ae.zip llvm-a94002cd6408034b55a027135d705cc1487b25ae.tar.gz llvm-a94002cd6408034b55a027135d705cc1487b25ae.tar.bz2 |
[Type] Avoid APFloat.h include (NFC)
This is only used by a handful of methods working on fltSemantics,
and having these defined inline in the header does not look
particularly important.
-rw-r--r-- | llvm/include/llvm/CodeGen/GlobalISel/Utils.h | 1 | ||||
-rw-r--r-- | llvm/include/llvm/IR/DataLayout.h | 1 | ||||
-rw-r--r-- | llvm/include/llvm/IR/Function.h | 1 | ||||
-rw-r--r-- | llvm/include/llvm/IR/Type.h | 38 | ||||
-rw-r--r-- | llvm/lib/IR/Type.cpp | 38 | ||||
-rw-r--r-- | llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp | 1 |
6 files changed, 46 insertions, 34 deletions
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/Utils.h b/llvm/include/llvm/CodeGen/GlobalISel/Utils.h index 15ca8b2..a9c1da3 100644 --- a/llvm/include/llvm/CodeGen/GlobalISel/Utils.h +++ b/llvm/include/llvm/CodeGen/GlobalISel/Utils.h @@ -16,6 +16,7 @@ #include "GISelWorkList.h" #include "LostDebugLocObserver.h" +#include "llvm/ADT/APFloat.h" #include "llvm/ADT/StringRef.h" #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/CodeGen/Register.h" diff --git a/llvm/include/llvm/IR/DataLayout.h b/llvm/include/llvm/IR/DataLayout.h index 0486b19..e65b128 100644 --- a/llvm/include/llvm/IR/DataLayout.h +++ b/llvm/include/llvm/IR/DataLayout.h @@ -19,6 +19,7 @@ #ifndef LLVM_IR_DATALAYOUT_H #define LLVM_IR_DATALAYOUT_H +#include "llvm/ADT/APInt.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" diff --git a/llvm/include/llvm/IR/Function.h b/llvm/include/llvm/IR/Function.h index f28a1cd..e5c675a 100644 --- a/llvm/include/llvm/IR/Function.h +++ b/llvm/include/llvm/IR/Function.h @@ -48,6 +48,7 @@ typedef unsigned ID; class AssemblyAnnotationWriter; class Constant; +struct DenormalMode; class DISubprogram; class LLVMContext; class Module; diff --git a/llvm/include/llvm/IR/Type.h b/llvm/include/llvm/IR/Type.h index 430bc34..47431ad 100644 --- a/llvm/include/llvm/IR/Type.h +++ b/llvm/include/llvm/IR/Type.h @@ -14,7 +14,6 @@ #ifndef LLVM_IR_TYPE_H #define LLVM_IR_TYPE_H -#include "llvm/ADT/APFloat.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/Support/CBindingWrapping.h" @@ -29,6 +28,7 @@ namespace llvm { class IntegerType; +struct fltSemantics; class LLVMContext; class PointerType; class raw_ostream; @@ -166,18 +166,7 @@ public: getTypeID() == PPC_FP128TyID; } - const fltSemantics &getFltSemantics() const { - switch (getTypeID()) { - case HalfTyID: return APFloat::IEEEhalf(); - case BFloatTyID: return APFloat::BFloat(); - case FloatTyID: return APFloat::IEEEsingle(); - case DoubleTyID: return APFloat::IEEEdouble(); - case X86_FP80TyID: return APFloat::x87DoubleExtended(); - case FP128TyID: return APFloat::IEEEquad(); - case PPC_FP128TyID: return APFloat::PPCDoubleDouble(); - default: llvm_unreachable("Invalid floating type"); - } - } + const fltSemantics &getFltSemantics() const; /// Return true if this is X86 MMX. bool isX86_MMXTy() const { return getTypeID() == X86_MMXTyID; } @@ -312,7 +301,7 @@ public: /// Return whether the type is IEEE compatible, as defined by the eponymous /// method in APFloat. - bool isIEEE() const { return APFloat::getZero(getFltSemantics()).isIEEE(); } + bool isIEEE() const; /// If this is a vector type, return the element type, otherwise return /// 'this'. @@ -443,26 +432,7 @@ public: } llvm_unreachable("Unsupported type in Type::getScalarTy"); } - static Type *getFloatingPointTy(LLVMContext &C, const fltSemantics &S) { - Type *Ty; - if (&S == &APFloat::IEEEhalf()) - Ty = Type::getHalfTy(C); - else if (&S == &APFloat::BFloat()) - Ty = Type::getBFloatTy(C); - else if (&S == &APFloat::IEEEsingle()) - Ty = Type::getFloatTy(C); - else if (&S == &APFloat::IEEEdouble()) - Ty = Type::getDoubleTy(C); - else if (&S == &APFloat::x87DoubleExtended()) - Ty = Type::getX86_FP80Ty(C); - else if (&S == &APFloat::IEEEquad()) - Ty = Type::getFP128Ty(C); - else { - assert(&S == &APFloat::PPCDoubleDouble() && "Unknown FP format"); - Ty = Type::getPPC_FP128Ty(C); - } - return Ty; - } + static Type *getFloatingPointTy(LLVMContext &C, const fltSemantics &S); //===--------------------------------------------------------------------===// // Convenience methods for getting pointer types with one of the above builtin diff --git a/llvm/lib/IR/Type.cpp b/llvm/lib/IR/Type.cpp index 35253a2..0a28a00 100644 --- a/llvm/lib/IR/Type.cpp +++ b/llvm/lib/IR/Type.cpp @@ -66,6 +66,44 @@ bool Type::isOpaquePointerTy() const { return false; } +const fltSemantics &Type::getFltSemantics() const { + switch (getTypeID()) { + case HalfTyID: return APFloat::IEEEhalf(); + case BFloatTyID: return APFloat::BFloat(); + case FloatTyID: return APFloat::IEEEsingle(); + case DoubleTyID: return APFloat::IEEEdouble(); + case X86_FP80TyID: return APFloat::x87DoubleExtended(); + case FP128TyID: return APFloat::IEEEquad(); + case PPC_FP128TyID: return APFloat::PPCDoubleDouble(); + default: llvm_unreachable("Invalid floating type"); + } +} + +bool Type::isIEEE() const { + return APFloat::getZero(getFltSemantics()).isIEEE(); +} + +Type *Type::getFloatingPointTy(LLVMContext &C, const fltSemantics &S) { + Type *Ty; + if (&S == &APFloat::IEEEhalf()) + Ty = Type::getHalfTy(C); + else if (&S == &APFloat::BFloat()) + Ty = Type::getBFloatTy(C); + else if (&S == &APFloat::IEEEsingle()) + Ty = Type::getFloatTy(C); + else if (&S == &APFloat::IEEEdouble()) + Ty = Type::getDoubleTy(C); + else if (&S == &APFloat::x87DoubleExtended()) + Ty = Type::getX86_FP80Ty(C); + else if (&S == &APFloat::IEEEquad()) + Ty = Type::getFP128Ty(C); + else { + assert(&S == &APFloat::PPCDoubleDouble() && "Unknown FP format"); + Ty = Type::getPPC_FP128Ty(C); + } + return Ty; +} + bool Type::canLosslesslyBitCastTo(Type *Ty) const { // Identity cast means no change so return true if (this == Ty) diff --git a/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp b/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp index 961577f..de1634e 100644 --- a/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp +++ b/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp @@ -12,6 +12,7 @@ #include "llvm/ToolDrivers/llvm-dlltool/DlltoolDriver.h" #include "llvm/ADT/Optional.h" +#include "llvm/ADT/StringSwitch.h" #include "llvm/Object/COFF.h" #include "llvm/Object/COFFImportFile.h" #include "llvm/Object/COFFModuleDefinition.h" |