Matt Arsenault | c791f39 | 2014-06-23 18:00:31 +0000 | [diff] [blame] | 1 | //===- AMDGPUIntrinsicInfo.cpp - AMDGPU Intrinsic Information ---*- C++ -*-===// |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //==-----------------------------------------------------------------------===// |
| 9 | // |
| 10 | /// \file |
| 11 | /// \brief AMDGPU Implementation of the IntrinsicInfo class. |
| 12 | // |
| 13 | //===-----------------------------------------------------------------------===// |
| 14 | |
Matt Arsenault | c791f39 | 2014-06-23 18:00:31 +0000 | [diff] [blame] | 15 | #include "AMDGPUIntrinsicInfo.h" |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 16 | #include "AMDGPUSubtarget.h" |
Chandler Carruth | 9fb823b | 2013-01-02 11:36:10 +0000 | [diff] [blame] | 17 | #include "llvm/IR/DerivedTypes.h" |
| 18 | #include "llvm/IR/Intrinsics.h" |
| 19 | #include "llvm/IR/Module.h" |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 20 | |
| 21 | using namespace llvm; |
| 22 | |
| 23 | #define GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN |
| 24 | #include "AMDGPUGenIntrinsics.inc" |
| 25 | #undef GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN |
| 26 | |
Eric Christopher | ac4b69e | 2014-07-25 22:22:39 +0000 | [diff] [blame] | 27 | AMDGPUIntrinsicInfo::AMDGPUIntrinsicInfo() |
Matt Arsenault | c791f39 | 2014-06-23 18:00:31 +0000 | [diff] [blame] | 28 | : TargetIntrinsicInfo() {} |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 29 | |
Matt Arsenault | c791f39 | 2014-06-23 18:00:31 +0000 | [diff] [blame] | 30 | std::string AMDGPUIntrinsicInfo::getName(unsigned IntrID, Type **Tys, |
| 31 | unsigned numTys) const { |
| 32 | static const char *const names[] = { |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 33 | #define GET_INTRINSIC_NAME_TABLE |
| 34 | #include "AMDGPUGenIntrinsics.inc" |
| 35 | #undef GET_INTRINSIC_NAME_TABLE |
| 36 | }; |
| 37 | |
| 38 | if (IntrID < Intrinsic::num_intrinsics) { |
Craig Topper | 062a2ba | 2014-04-25 05:30:21 +0000 | [diff] [blame] | 39 | return nullptr; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 40 | } |
Matt Arsenault | c791f39 | 2014-06-23 18:00:31 +0000 | [diff] [blame] | 41 | assert(IntrID < AMDGPUIntrinsic::num_AMDGPU_intrinsics && |
| 42 | "Invalid intrinsic ID"); |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 43 | |
| 44 | std::string Result(names[IntrID - Intrinsic::num_intrinsics]); |
| 45 | return Result; |
| 46 | } |
| 47 | |
Matt Arsenault | c791f39 | 2014-06-23 18:00:31 +0000 | [diff] [blame] | 48 | unsigned AMDGPUIntrinsicInfo::lookupName(const char *Name, |
| 49 | unsigned Len) const { |
Rafael Espindola | ebd8e38 | 2013-05-22 14:57:42 +0000 | [diff] [blame] | 50 | if (!StringRef(Name, Len).startswith("llvm.")) |
| 51 | return 0; // All intrinsics start with 'llvm.' |
| 52 | |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 53 | #define GET_FUNCTION_RECOGNIZER |
| 54 | #include "AMDGPUGenIntrinsics.inc" |
| 55 | #undef GET_FUNCTION_RECOGNIZER |
Matt Arsenault | c791f39 | 2014-06-23 18:00:31 +0000 | [diff] [blame] | 56 | AMDGPUIntrinsic::ID IntrinsicID = |
| 57 | (AMDGPUIntrinsic::ID)Intrinsic::not_intrinsic; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 58 | IntrinsicID = getIntrinsicForGCCBuiltin("AMDGPU", Name); |
| 59 | |
| 60 | if (IntrinsicID != (AMDGPUIntrinsic::ID)Intrinsic::not_intrinsic) { |
| 61 | return IntrinsicID; |
| 62 | } |
| 63 | return 0; |
| 64 | } |
| 65 | |
Matt Arsenault | c791f39 | 2014-06-23 18:00:31 +0000 | [diff] [blame] | 66 | bool AMDGPUIntrinsicInfo::isOverloaded(unsigned id) const { |
| 67 | // Overload Table |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 68 | #define GET_INTRINSIC_OVERLOAD_TABLE |
| 69 | #include "AMDGPUGenIntrinsics.inc" |
| 70 | #undef GET_INTRINSIC_OVERLOAD_TABLE |
| 71 | } |
| 72 | |
Matt Arsenault | c791f39 | 2014-06-23 18:00:31 +0000 | [diff] [blame] | 73 | Function *AMDGPUIntrinsicInfo::getDeclaration(Module *M, unsigned IntrID, |
| 74 | Type **Tys, |
| 75 | unsigned numTys) const { |
Tom Stellard | 6975d35 | 2012-12-13 19:38:52 +0000 | [diff] [blame] | 76 | llvm_unreachable("Not implemented"); |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 77 | } |