[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.
This commit is contained in:
Nikita Popov 2021-10-09 11:28:11 +02:00
parent 55b9146848
commit a94002cd64
6 changed files with 46 additions and 34 deletions

View File

@ -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"

View File

@ -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"

View File

@ -48,6 +48,7 @@ typedef unsigned ID;
class AssemblyAnnotationWriter;
class Constant;
struct DenormalMode;
class DISubprogram;
class LLVMContext;
class Module;

View File

@ -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

View File

@ -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)

View File

@ -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"