diff options
| author | Craig Topper <craig.topper@intel.com> | 2018-06-25 20:27:46 +0000 |
|---|---|---|
| committer | Craig Topper <craig.topper@intel.com> | 2018-06-25 20:27:46 +0000 |
| commit | 913abc8b58c43977f56a06d7b8baac721661e0c9 (patch) | |
| tree | 68d9eed287595ec996127ce2216173dc13155f8f /llvm/lib | |
| parent | 614f1924716f85ba0a08bf8dcb2effa817d761cf (diff) | |
| download | bcm5719-llvm-913abc8b58c43977f56a06d7b8baac721661e0c9.tar.gz bcm5719-llvm-913abc8b58c43977f56a06d7b8baac721661e0c9.zip | |
[X86] Simplify intrinsic table binary search to not require a temporary struct.
std::lower_bound doesn't require the thing to search for to be the same type as the table entries. We just need to define an appropriate comparison function that can take an table entry and an intrinsic number.
llvm-svn: 335518
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/X86/X86IntrinsicsInfo.h | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/llvm/lib/Target/X86/X86IntrinsicsInfo.h b/llvm/lib/Target/X86/X86IntrinsicsInfo.h index 61fac9fcb0b..04c8780fa3b 100644 --- a/llvm/lib/Target/X86/X86IntrinsicsInfo.h +++ b/llvm/lib/Target/X86/X86IntrinsicsInfo.h @@ -20,7 +20,6 @@ namespace llvm { enum IntrinsicType : uint16_t { - INTR_NO_TYPE, GATHER, SCATTER, PREFETCH, RDSEED, RDRAND, RDPMC, RDTSC, XTEST, XGETBV, ADX, FPCLASS, FPCLASSS, INTR_TYPE_1OP, INTR_TYPE_2OP, INTR_TYPE_3OP, INTR_TYPE_4OP, INTR_TYPE_3OP_RM, INTR_TYPE_3OP_IMM8, @@ -53,6 +52,9 @@ struct IntrinsicData { bool operator==(const IntrinsicData &RHS) const { return RHS.Id == Id; } + friend bool operator<(const IntrinsicData &LHS, unsigned Id) { + return LHS.Id < Id; + } }; #define X86_INTRINSIC_DATA(id, type, op0, op1) \ @@ -279,13 +281,11 @@ static const IntrinsicData IntrinsicsWithChain[] = { /* * Find Intrinsic data by intrinsic ID */ -static const IntrinsicData* getIntrinsicWithChain(uint16_t IntNo) { - - IntrinsicData IntrinsicToFind = {IntNo, INTR_NO_TYPE, 0, 0 }; +static const IntrinsicData* getIntrinsicWithChain(unsigned IntNo) { const IntrinsicData *Data = std::lower_bound(std::begin(IntrinsicsWithChain), std::end(IntrinsicsWithChain), - IntrinsicToFind); - if (Data != std::end(IntrinsicsWithChain) && *Data == IntrinsicToFind) + IntNo); + if (Data != std::end(IntrinsicsWithChain) && Data->Id == IntNo) return Data; return nullptr; } @@ -1423,12 +1423,11 @@ static const IntrinsicData IntrinsicsWithoutChain[] = { * Retrieve data for Intrinsic without chain. * Return nullptr if intrinsic is not defined in the table. */ -static const IntrinsicData* getIntrinsicWithoutChain(uint16_t IntNo) { - IntrinsicData IntrinsicToFind = { IntNo, INTR_NO_TYPE, 0, 0 }; +static const IntrinsicData* getIntrinsicWithoutChain(unsigned IntNo) { const IntrinsicData *Data = std::lower_bound(std::begin(IntrinsicsWithoutChain), std::end(IntrinsicsWithoutChain), - IntrinsicToFind); - if (Data != std::end(IntrinsicsWithoutChain) && *Data == IntrinsicToFind) + IntNo); + if (Data != std::end(IntrinsicsWithoutChain) && Data->Id == IntNo) return Data; return nullptr; } |

