Skip to content

Commit e786431

Browse files
committed
Use proper type for getLLVMIntrinsicID
At one point we were probably trying to avoid including llvm/IR/Intrinsics.h in Builtins.h but that ship has sailed. No functionality change.
1 parent 805ae33 commit e786431

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

include/swift/AST/Builtins.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ StringRef getBuiltinBaseName(ASTContext &C, StringRef Name,
8080
SmallVectorImpl<Type> &Types);
8181

8282
/// Given an LLVM IR intrinsic name with argument types remove (e.g. like
83-
/// "bswap") return the LLVM IR IntrinsicID for the intrinsic or 0 if the
84-
/// intrinsic name doesn't match anything.
85-
unsigned getLLVMIntrinsicID(StringRef Name);
83+
/// "bswap") return the LLVM IR IntrinsicID for the intrinsic or not_intrinsic
84+
/// (0) if the intrinsic name doesn't match anything.
85+
llvm::Intrinsic::ID getLLVMIntrinsicID(StringRef Name);
8686

8787
/// Get the LLVM intrinsic ID that corresponds to the given builtin with
8888
/// overflow.

lib/AST/Builtins.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,10 +1225,7 @@ static const char *const IntrinsicNameTable[] = {
12251225
#include "llvm/IR/IntrinsicImpl.inc"
12261226
#undef GET_INTRINSIC_TARGET_DATA
12271227

1228-
/// getLLVMIntrinsicID - Given an LLVM IR intrinsic name with argument types
1229-
/// removed (e.g. like "bswap") return the LLVM IR IntrinsicID for the intrinsic
1230-
/// or 0 if the intrinsic name doesn't match anything.
1231-
unsigned swift::getLLVMIntrinsicID(StringRef InName) {
1228+
llvm::Intrinsic::ID swift::getLLVMIntrinsicID(StringRef InName) {
12321229
using namespace llvm;
12331230

12341231
// Swift intrinsic names start with int_.
@@ -1321,12 +1318,11 @@ static Type DecodeIntrinsicType(ArrayRef<llvm::Intrinsic::IITDescriptor> &Table,
13211318

13221319
/// \returns true on success, false on failure.
13231320
static bool
1324-
getSwiftFunctionTypeForIntrinsic(unsigned iid, ArrayRef<Type> TypeArgs,
1321+
getSwiftFunctionTypeForIntrinsic(llvm::Intrinsic::ID ID,
1322+
ArrayRef<Type> TypeArgs,
13251323
ASTContext &Context,
13261324
SmallVectorImpl<Type> &ArgElts,
13271325
Type &ResultTy, FunctionType::ExtInfo &Info) {
1328-
llvm::Intrinsic::ID ID = (llvm::Intrinsic::ID)iid;
1329-
13301326
typedef llvm::Intrinsic::IITDescriptor IITDescriptor;
13311327
SmallVector<IITDescriptor, 8> Table;
13321328
getIntrinsicInfoTableEntries(ID, Table);
@@ -1439,7 +1435,7 @@ ValueDecl *swift::getBuiltinValueDecl(ASTContext &Context, Identifier Id) {
14391435

14401436
// If this is the name of an LLVM intrinsic, cons up a swift function with a
14411437
// type that matches the IR types.
1442-
if (unsigned ID = getLLVMIntrinsicID(OperationName)) {
1438+
if (llvm::Intrinsic::ID ID = getLLVMIntrinsicID(OperationName)) {
14431439
SmallVector<Type, 8> ArgElts;
14441440
Type ResultTy;
14451441
FunctionType::ExtInfo Info;

lib/SIL/SILModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ const IntrinsicInfo &SILModule::getIntrinsicInfo(Identifier ID) {
275275

276276
// Otherwise, lookup the ID and Type and store them in the map.
277277
StringRef NameRef = getBuiltinBaseName(getASTContext(), ID.str(), Info.Types);
278-
Info.ID = (llvm::Intrinsic::ID)getLLVMIntrinsicID(NameRef);
278+
Info.ID = getLLVMIntrinsicID(NameRef);
279279

280280
return Info;
281281
}

0 commit comments

Comments
 (0)