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
|
||||
/// intrinsic. The particular intrinsic functions which correspond to the
|
||||
/// 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.
|
||||
const BuiltinInfo &getBuiltinInfo();
|
||||
const BuiltinInfo &getBuiltinInfo() const;
|
||||
|
||||
ArrayRef<Operand> getAllOperands() const { return {}; }
|
||||
MutableArrayRef<Operand> getAllOperands() { return {}; }
|
||||
|
||||
@@ -107,10 +107,10 @@ private:
|
||||
llvm::SetVector<VarDecl*> globals;
|
||||
|
||||
/// 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.
|
||||
llvm::DenseMap<const FuncDecl*, BuiltinInfo> BuiltinIDCache;
|
||||
llvm::DenseMap<Identifier, BuiltinInfo> BuiltinIDCache;
|
||||
|
||||
/// This is the set of undef values we've created, for uniquing purposes.
|
||||
llvm::DenseMap<SILType, SILUndef*> UndefValues;
|
||||
@@ -277,14 +277,14 @@ public:
|
||||
///
|
||||
/// \returns Returns llvm::Intrinsic::not_intrinsic if the function is not an
|
||||
/// intrinsic. The particular intrinsic functions which correspond to the
|
||||
/// retruned value are defined in llvm/Intrinsics.h.
|
||||
const IntrinsicInfo &getIntrinsicInfo(const FuncDecl* FD);
|
||||
/// returned value are defined in llvm/Intrinsics.h.
|
||||
const IntrinsicInfo &getIntrinsicInfo(Identifier ID);
|
||||
|
||||
/// \brief Looks up the lazily cached identification for the builtin function.
|
||||
///
|
||||
/// \returns Returns builtin info of BuiltinValueKind::None kind if the
|
||||
/// decalation is not a builtin.
|
||||
const BuiltinInfo &getBuiltinInfo(const FuncDecl* FD);
|
||||
/// declaration is not a builtin.
|
||||
const BuiltinInfo &getBuiltinInfo(Identifier ID);
|
||||
};
|
||||
|
||||
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");
|
||||
|
||||
// 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:
|
||||
if (Builtin.ID == BuiltinValueKind::Sizeof) {
|
||||
@@ -900,7 +900,7 @@ void irgen::emitBuiltinCall(IRGenFunction &IGF, FuncDecl *fn,
|
||||
// Everything else cares about the (rvalue) argument.
|
||||
|
||||
// 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;
|
||||
if (IID != llvm::Intrinsic::not_intrinsic) {
|
||||
SmallVector<llvm::Type*, 4> ArgTys;
|
||||
|
||||
@@ -370,12 +370,12 @@ SILGlobalAddrInst::SILGlobalAddrInst(SILLocation Loc, SILGlobalVariable *Global)
|
||||
Global(Global)
|
||||
{}
|
||||
|
||||
const IntrinsicInfo &BuiltinFunctionRefInst::getIntrinsicInfo() {
|
||||
return getModule().getIntrinsicInfo(Function);
|
||||
const IntrinsicInfo &BuiltinFunctionRefInst::getIntrinsicInfo() const {
|
||||
return getModule().getIntrinsicInfo(Function->getName());
|
||||
}
|
||||
|
||||
const BuiltinInfo &BuiltinFunctionRefInst::getBuiltinInfo() {
|
||||
return getModule().getBuiltinInfo(Function);
|
||||
const BuiltinInfo &BuiltinFunctionRefInst::getBuiltinInfo() const {
|
||||
return getModule().getBuiltinInfo(Function->getName());
|
||||
}
|
||||
|
||||
static unsigned getWordsForBitWidth(unsigned bits) {
|
||||
|
||||
@@ -94,26 +94,25 @@ SILTypeList *SILModule::getSILTypeList(ArrayRef<SILType> Types) const {
|
||||
return NewList;
|
||||
}
|
||||
|
||||
const IntrinsicInfo &SILModule::getIntrinsicInfo(const FuncDecl* FD) {
|
||||
const IntrinsicInfo &SILModule::getIntrinsicInfo(Identifier ID) {
|
||||
unsigned OldSize = IntrinsicIDCache.size();
|
||||
IntrinsicInfo &Info = IntrinsicIDCache[FD];
|
||||
IntrinsicInfo &Info = IntrinsicIDCache[ID];
|
||||
|
||||
// If the element was is in the cache, return it.
|
||||
if (OldSize == IntrinsicIDCache.size())
|
||||
return Info;
|
||||
|
||||
// Otherwise, lookup the ID and Type and store them in the map.
|
||||
StringRef NameRef = getBuiltinBaseName(getASTContext(),
|
||||
FD->getName().str(), Info.Types);
|
||||
StringRef NameRef = getBuiltinBaseName(getASTContext(), ID.str(), Info.Types);
|
||||
Info.ID =
|
||||
(llvm::Intrinsic::ID)getLLVMIntrinsicID(NameRef, !Info.Types.empty());
|
||||
|
||||
return Info;
|
||||
}
|
||||
|
||||
const BuiltinInfo &SILModule::getBuiltinInfo(const FuncDecl* FD) {
|
||||
const BuiltinInfo &SILModule::getBuiltinInfo(Identifier ID) {
|
||||
unsigned OldSize = BuiltinIDCache.size();
|
||||
BuiltinInfo &Info = BuiltinIDCache[FD];
|
||||
BuiltinInfo &Info = BuiltinIDCache[ID];
|
||||
|
||||
// If the element was is in the cache, return it.
|
||||
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.
|
||||
// Find the matching ID.
|
||||
StringRef OperationName = getBuiltinBaseName(getASTContext(),
|
||||
FD->getName().str(),
|
||||
Info.Types);
|
||||
StringRef OperationName =
|
||||
getBuiltinBaseName(getASTContext(), ID.str(), Info.Types);
|
||||
|
||||
// Several operation names have suffixes and don't match the name from
|
||||
// Builtins.def, so handle those first.
|
||||
|
||||
@@ -2063,7 +2063,7 @@ namespace {
|
||||
if (!isa<BuiltinModule>(decl->getDeclContext()))
|
||||
return nullptr;
|
||||
|
||||
const BuiltinInfo &Builtin = SILM.getBuiltinInfo(cast<FuncDecl>(decl));
|
||||
const BuiltinInfo &Builtin = SILM.getBuiltinInfo(decl->getName());
|
||||
|
||||
// Match SIL builtins to their emitters.
|
||||
#define BUILTIN(Id, Name, Attrs)
|
||||
|
||||
Reference in New Issue
Block a user