mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[SIL] Add getIntrinsicID(FuncDecl*), which lazyly looks up the llvm::IntrinsicID for it.
The cache is stored in the SILModule. Add getIntrinsicID() as a member of BuiltinFunctionRefInst. Test by using the new method in the CCP pass. Swift SVN r7311
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "swift/SIL/SILModule.h"
|
||||
#include "swift/AST/Builtins.h"
|
||||
#include "swift/SIL/SILValue.h"
|
||||
#include "llvm/ADT/FoldingSet.h"
|
||||
using namespace swift;
|
||||
@@ -87,3 +88,20 @@ SILTypeList *SILModule::getSILTypeList(ArrayRef<SILType> Types) const {
|
||||
return NewList;
|
||||
}
|
||||
|
||||
llvm::Intrinsic::ID SILModule::getIntrinsicID(const FuncDecl* FD) {
|
||||
if (!IntrinsicIDCache.count(FD)) {
|
||||
// Find the matching ID.
|
||||
SmallVector<Type, 4> Types;
|
||||
StringRef NameRef = getBuiltinBaseName(getASTContext(),
|
||||
FD->getName().str(), Types);
|
||||
llvm::Intrinsic::ID Id =
|
||||
(llvm::Intrinsic::ID)getLLVMIntrinsicID(NameRef, !Types.empty());
|
||||
|
||||
// Store it in the cache.
|
||||
IntrinsicIDCache[FD] = Id;
|
||||
return Id;
|
||||
}
|
||||
return IntrinsicIDCache[FD];
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user