mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
strength reduce SILGenModule::getBuiltinInfo/getIntrinsicInfo to
take an identifier instead of a FuncDecl. Swift SVN r10692
This commit is contained in:
@@ -529,10 +529,10 @@ public:
|
|||||||
/// \returns Returns llvm::Intrinsic::not_intrinsic if the function is not an
|
/// \returns Returns llvm::Intrinsic::not_intrinsic if the function is not an
|
||||||
/// intrinsic. The particular intrinsic functions which correspond to the
|
/// intrinsic. The particular intrinsic functions which correspond to the
|
||||||
/// retruned value are defined in llvm/Intrinsics.h.
|
/// retruned value are defined in llvm/Intrinsics.h.
|
||||||
const IntrinsicInfo &getIntrinsicInfo();
|
const IntrinsicInfo &getIntrinsicInfo() const;
|
||||||
|
|
||||||
/// \brief Looks up the lazily cached identification for the builtin function.
|
/// \brief Looks up the lazily cached identification for the builtin function.
|
||||||
const BuiltinInfo &getBuiltinInfo();
|
const BuiltinInfo &getBuiltinInfo() const;
|
||||||
|
|
||||||
ArrayRef<Operand> getAllOperands() const { return {}; }
|
ArrayRef<Operand> getAllOperands() const { return {}; }
|
||||||
MutableArrayRef<Operand> getAllOperands() { return {}; }
|
MutableArrayRef<Operand> getAllOperands() { return {}; }
|
||||||
|
|||||||
@@ -107,10 +107,10 @@ private:
|
|||||||
llvm::SetVector<VarDecl*> globals;
|
llvm::SetVector<VarDecl*> globals;
|
||||||
|
|
||||||
/// This is a cache of intrinsic Function declarations to numeric ID mappings.
|
/// This is a cache of intrinsic Function declarations to numeric ID mappings.
|
||||||
llvm::DenseMap<const FuncDecl*, IntrinsicInfo> IntrinsicIDCache;
|
llvm::DenseMap<Identifier, IntrinsicInfo> IntrinsicIDCache;
|
||||||
|
|
||||||
/// This is a cache of builtin Function declarations to numeric ID mappings.
|
/// This is a cache of builtin Function declarations to numeric ID mappings.
|
||||||
llvm::DenseMap<const FuncDecl*, BuiltinInfo> BuiltinIDCache;
|
llvm::DenseMap<Identifier, BuiltinInfo> BuiltinIDCache;
|
||||||
|
|
||||||
/// This is the set of undef values we've created, for uniquing purposes.
|
/// This is the set of undef values we've created, for uniquing purposes.
|
||||||
llvm::DenseMap<SILType, SILUndef*> UndefValues;
|
llvm::DenseMap<SILType, SILUndef*> UndefValues;
|
||||||
@@ -277,14 +277,14 @@ public:
|
|||||||
///
|
///
|
||||||
/// \returns Returns llvm::Intrinsic::not_intrinsic if the function is not an
|
/// \returns Returns llvm::Intrinsic::not_intrinsic if the function is not an
|
||||||
/// intrinsic. The particular intrinsic functions which correspond to the
|
/// intrinsic. The particular intrinsic functions which correspond to the
|
||||||
/// retruned value are defined in llvm/Intrinsics.h.
|
/// returned value are defined in llvm/Intrinsics.h.
|
||||||
const IntrinsicInfo &getIntrinsicInfo(const FuncDecl* FD);
|
const IntrinsicInfo &getIntrinsicInfo(Identifier ID);
|
||||||
|
|
||||||
/// \brief Looks up the lazily cached identification for the builtin function.
|
/// \brief Looks up the lazily cached identification for the builtin function.
|
||||||
///
|
///
|
||||||
/// \returns Returns builtin info of BuiltinValueKind::None kind if the
|
/// \returns Returns builtin info of BuiltinValueKind::None kind if the
|
||||||
/// decalation is not a builtin.
|
/// declaration is not a builtin.
|
||||||
const BuiltinInfo &getBuiltinInfo(const FuncDecl* FD);
|
const BuiltinInfo &getBuiltinInfo(Identifier ID);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const SILModule &M){
|
inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const SILModule &M){
|
||||||
|
|||||||
@@ -859,7 +859,7 @@ void irgen::emitBuiltinCall(IRGenFunction &IGF, FuncDecl *fn,
|
|||||||
"cannot emit builtin to both explosion and memory");
|
"cannot emit builtin to both explosion and memory");
|
||||||
|
|
||||||
// Decompose the function's name into a builtin name and type list.
|
// Decompose the function's name into a builtin name and type list.
|
||||||
const BuiltinInfo &Builtin = IGF.IGM.SILMod->getBuiltinInfo(fn);
|
const BuiltinInfo &Builtin = IGF.IGM.SILMod->getBuiltinInfo(fn->getName());
|
||||||
|
|
||||||
// These builtins don't care about their argument:
|
// These builtins don't care about their argument:
|
||||||
if (Builtin.ID == BuiltinValueKind::Sizeof) {
|
if (Builtin.ID == BuiltinValueKind::Sizeof) {
|
||||||
@@ -900,7 +900,7 @@ void irgen::emitBuiltinCall(IRGenFunction &IGF, FuncDecl *fn,
|
|||||||
// Everything else cares about the (rvalue) argument.
|
// Everything else cares about the (rvalue) argument.
|
||||||
|
|
||||||
// If this is an LLVM IR intrinsic, lower it to an intrinsic call.
|
// If this is an LLVM IR intrinsic, lower it to an intrinsic call.
|
||||||
const IntrinsicInfo &IInfo = IGF.IGM.SILMod->getIntrinsicInfo(fn);
|
const IntrinsicInfo &IInfo = IGF.IGM.SILMod->getIntrinsicInfo(fn->getName());
|
||||||
llvm::Intrinsic::ID IID = IInfo.ID;
|
llvm::Intrinsic::ID IID = IInfo.ID;
|
||||||
if (IID != llvm::Intrinsic::not_intrinsic) {
|
if (IID != llvm::Intrinsic::not_intrinsic) {
|
||||||
SmallVector<llvm::Type*, 4> ArgTys;
|
SmallVector<llvm::Type*, 4> ArgTys;
|
||||||
|
|||||||
@@ -370,12 +370,12 @@ SILGlobalAddrInst::SILGlobalAddrInst(SILLocation Loc, SILGlobalVariable *Global)
|
|||||||
Global(Global)
|
Global(Global)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
const IntrinsicInfo &BuiltinFunctionRefInst::getIntrinsicInfo() {
|
const IntrinsicInfo &BuiltinFunctionRefInst::getIntrinsicInfo() const {
|
||||||
return getModule().getIntrinsicInfo(Function);
|
return getModule().getIntrinsicInfo(Function->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
const BuiltinInfo &BuiltinFunctionRefInst::getBuiltinInfo() {
|
const BuiltinInfo &BuiltinFunctionRefInst::getBuiltinInfo() const {
|
||||||
return getModule().getBuiltinInfo(Function);
|
return getModule().getBuiltinInfo(Function->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned getWordsForBitWidth(unsigned bits) {
|
static unsigned getWordsForBitWidth(unsigned bits) {
|
||||||
|
|||||||
@@ -94,26 +94,25 @@ SILTypeList *SILModule::getSILTypeList(ArrayRef<SILType> Types) const {
|
|||||||
return NewList;
|
return NewList;
|
||||||
}
|
}
|
||||||
|
|
||||||
const IntrinsicInfo &SILModule::getIntrinsicInfo(const FuncDecl* FD) {
|
const IntrinsicInfo &SILModule::getIntrinsicInfo(Identifier ID) {
|
||||||
unsigned OldSize = IntrinsicIDCache.size();
|
unsigned OldSize = IntrinsicIDCache.size();
|
||||||
IntrinsicInfo &Info = IntrinsicIDCache[FD];
|
IntrinsicInfo &Info = IntrinsicIDCache[ID];
|
||||||
|
|
||||||
// If the element was is in the cache, return it.
|
// If the element was is in the cache, return it.
|
||||||
if (OldSize == IntrinsicIDCache.size())
|
if (OldSize == IntrinsicIDCache.size())
|
||||||
return Info;
|
return Info;
|
||||||
|
|
||||||
// Otherwise, lookup the ID and Type and store them in the map.
|
// Otherwise, lookup the ID and Type and store them in the map.
|
||||||
StringRef NameRef = getBuiltinBaseName(getASTContext(),
|
StringRef NameRef = getBuiltinBaseName(getASTContext(), ID.str(), Info.Types);
|
||||||
FD->getName().str(), Info.Types);
|
|
||||||
Info.ID =
|
Info.ID =
|
||||||
(llvm::Intrinsic::ID)getLLVMIntrinsicID(NameRef, !Info.Types.empty());
|
(llvm::Intrinsic::ID)getLLVMIntrinsicID(NameRef, !Info.Types.empty());
|
||||||
|
|
||||||
return Info;
|
return Info;
|
||||||
}
|
}
|
||||||
|
|
||||||
const BuiltinInfo &SILModule::getBuiltinInfo(const FuncDecl* FD) {
|
const BuiltinInfo &SILModule::getBuiltinInfo(Identifier ID) {
|
||||||
unsigned OldSize = BuiltinIDCache.size();
|
unsigned OldSize = BuiltinIDCache.size();
|
||||||
BuiltinInfo &Info = BuiltinIDCache[FD];
|
BuiltinInfo &Info = BuiltinIDCache[ID];
|
||||||
|
|
||||||
// If the element was is in the cache, return it.
|
// If the element was is in the cache, return it.
|
||||||
if (OldSize == BuiltinIDCache.size())
|
if (OldSize == BuiltinIDCache.size())
|
||||||
@@ -121,9 +120,8 @@ const BuiltinInfo &SILModule::getBuiltinInfo(const FuncDecl* FD) {
|
|||||||
|
|
||||||
// Otherwise, lookup the ID and Type and store them in the map.
|
// Otherwise, lookup the ID and Type and store them in the map.
|
||||||
// Find the matching ID.
|
// Find the matching ID.
|
||||||
StringRef OperationName = getBuiltinBaseName(getASTContext(),
|
StringRef OperationName =
|
||||||
FD->getName().str(),
|
getBuiltinBaseName(getASTContext(), ID.str(), Info.Types);
|
||||||
Info.Types);
|
|
||||||
|
|
||||||
// Several operation names have suffixes and don't match the name from
|
// Several operation names have suffixes and don't match the name from
|
||||||
// Builtins.def, so handle those first.
|
// Builtins.def, so handle those first.
|
||||||
|
|||||||
@@ -2063,7 +2063,7 @@ namespace {
|
|||||||
if (!isa<BuiltinModule>(decl->getDeclContext()))
|
if (!isa<BuiltinModule>(decl->getDeclContext()))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
const BuiltinInfo &Builtin = SILM.getBuiltinInfo(cast<FuncDecl>(decl));
|
const BuiltinInfo &Builtin = SILM.getBuiltinInfo(decl->getName());
|
||||||
|
|
||||||
// Match SIL builtins to their emitters.
|
// Match SIL builtins to their emitters.
|
||||||
#define BUILTIN(Id, Name, Attrs)
|
#define BUILTIN(Id, Name, Attrs)
|
||||||
|
|||||||
Reference in New Issue
Block a user