diff options
| author | Reid Kleckner <rnk@google.com> | 2016-01-26 23:01:21 +0000 |
|---|---|---|
| committer | Reid Kleckner <rnk@google.com> | 2016-01-26 23:01:21 +0000 |
| commit | 1c93b4cd7b1974c742a5e763c6cd4b25207544c4 (patch) | |
| tree | 93b592a8a8cd6355360a6a591f32706c9b4efa00 /llvm/lib/Target | |
| parent | abae3a44aff87d2a7a1ab6756faedd18f391361e (diff) | |
| download | bcm5719-llvm-1c93b4cd7b1974c742a5e763c6cd4b25207544c4.tar.gz bcm5719-llvm-1c93b4cd7b1974c742a5e763c6cd4b25207544c4.zip | |
[llvm-tblgen] Stop emitting the intrinsic name matching code
The AMDGPU backend was the last user of the old StringMatcher
recognition code. Move it over to the new lookupLLVMIntrinsicName
funciton, which is now improved to handle all of the interesting edge
cases exposed by AMDGPU intrinsic names.
llvm-svn: 258875
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/AMDGPU/AMDGPUIntrinsicInfo.cpp | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUIntrinsicInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPUIntrinsicInfo.cpp index e94bb6013d8..b92dd35a8e8 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUIntrinsicInfo.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUIntrinsicInfo.cpp @@ -27,40 +27,43 @@ using namespace llvm; AMDGPUIntrinsicInfo::AMDGPUIntrinsicInfo() : TargetIntrinsicInfo() {} -std::string AMDGPUIntrinsicInfo::getName(unsigned IntrID, Type **Tys, - unsigned numTys) const { - static const char *const names[] = { +static const char *const IntrinsicNameTable[] = { #define GET_INTRINSIC_NAME_TABLE #include "AMDGPUGenIntrinsics.inc" #undef GET_INTRINSIC_NAME_TABLE - }; +}; +std::string AMDGPUIntrinsicInfo::getName(unsigned IntrID, Type **Tys, + unsigned numTys) const { if (IntrID < Intrinsic::num_intrinsics) { return nullptr; } assert(IntrID < AMDGPUIntrinsic::num_AMDGPU_intrinsics && "Invalid intrinsic ID"); - std::string Result(names[IntrID - Intrinsic::num_intrinsics]); + std::string Result(IntrinsicNameTable[IntrID - Intrinsic::num_intrinsics]); return Result; } -unsigned AMDGPUIntrinsicInfo::lookupName(const char *Name, +unsigned AMDGPUIntrinsicInfo::lookupName(const char *NameData, unsigned Len) const { - if (!StringRef(Name, Len).startswith("llvm.")) + StringRef Name(NameData, Len); + if (!Name.startswith("llvm.")) return 0; // All intrinsics start with 'llvm.' -#define GET_FUNCTION_RECOGNIZER -#include "AMDGPUGenIntrinsics.inc" -#undef GET_FUNCTION_RECOGNIZER - AMDGPUIntrinsic::ID IntrinsicID = - (AMDGPUIntrinsic::ID)Intrinsic::not_intrinsic; - IntrinsicID = getIntrinsicForGCCBuiltin("AMDGPU", Name); - - if (IntrinsicID != (AMDGPUIntrinsic::ID)Intrinsic::not_intrinsic) { - return IntrinsicID; + // Look for a name match in our table. If the intrinsic is not overloaded, + // require an exact match. If it is overloaded, require a prefix match. The + // AMDGPU enum enum starts at Intrinsic::num_intrinsics. + int Idx = Intrinsic::lookupLLVMIntrinsicByName(IntrinsicNameTable, Name); + if (Idx >= 0) { + bool IsPrefixMatch = Name.size() > strlen(IntrinsicNameTable[Idx]); + return IsPrefixMatch == isOverloaded(Idx + 1) + ? Intrinsic::num_intrinsics + Idx + : 0; } - return 0; + + // Fall back on GCC builtin names. + return getIntrinsicForGCCBuiltin("AMDGPU", NameData); } bool AMDGPUIntrinsicInfo::isOverloaded(unsigned id) const { |

