LLVM API Documentation

AMDGPUIntrinsicInfo.cpp
Go to the documentation of this file.
00001 //===- AMDGPUIntrinsicInfo.cpp - AMDGPU Intrinsic Information ---*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //==-----------------------------------------------------------------------===//
00009 //
00010 /// \file
00011 /// \brief AMDGPU Implementation of the IntrinsicInfo class.
00012 //
00013 //===-----------------------------------------------------------------------===//
00014 
00015 #include "AMDGPUIntrinsicInfo.h"
00016 #include "AMDGPUSubtarget.h"
00017 #include "llvm/IR/DerivedTypes.h"
00018 #include "llvm/IR/Intrinsics.h"
00019 #include "llvm/IR/Module.h"
00020 
00021 using namespace llvm;
00022 
00023 #define GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN
00024 #include "AMDGPUGenIntrinsics.inc"
00025 #undef GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN
00026 
00027 AMDGPUIntrinsicInfo::AMDGPUIntrinsicInfo()
00028     : TargetIntrinsicInfo() {}
00029 
00030 std::string AMDGPUIntrinsicInfo::getName(unsigned IntrID, Type **Tys,
00031                                          unsigned numTys) const {
00032   static const char *const names[] = {
00033 #define GET_INTRINSIC_NAME_TABLE
00034 #include "AMDGPUGenIntrinsics.inc"
00035 #undef GET_INTRINSIC_NAME_TABLE
00036   };
00037 
00038   if (IntrID < Intrinsic::num_intrinsics) {
00039     return nullptr;
00040   }
00041   assert(IntrID < AMDGPUIntrinsic::num_AMDGPU_intrinsics &&
00042          "Invalid intrinsic ID");
00043 
00044   std::string Result(names[IntrID - Intrinsic::num_intrinsics]);
00045   return Result;
00046 }
00047 
00048 unsigned AMDGPUIntrinsicInfo::lookupName(const char *Name,
00049                                          unsigned Len) const {
00050   if (!StringRef(Name, Len).startswith("llvm."))
00051     return 0; // All intrinsics start with 'llvm.'
00052 
00053 #define GET_FUNCTION_RECOGNIZER
00054 #include "AMDGPUGenIntrinsics.inc"
00055 #undef GET_FUNCTION_RECOGNIZER
00056   AMDGPUIntrinsic::ID IntrinsicID =
00057       (AMDGPUIntrinsic::ID)Intrinsic::not_intrinsic;
00058   IntrinsicID = getIntrinsicForGCCBuiltin("AMDGPU", Name);
00059 
00060   if (IntrinsicID != (AMDGPUIntrinsic::ID)Intrinsic::not_intrinsic) {
00061     return IntrinsicID;
00062   }
00063   return 0;
00064 }
00065 
00066 bool AMDGPUIntrinsicInfo::isOverloaded(unsigned id) const {
00067 // Overload Table
00068 #define GET_INTRINSIC_OVERLOAD_TABLE
00069 #include "AMDGPUGenIntrinsics.inc"
00070 #undef GET_INTRINSIC_OVERLOAD_TABLE
00071 }
00072 
00073 Function *AMDGPUIntrinsicInfo::getDeclaration(Module *M, unsigned IntrID,
00074                                               Type **Tys,
00075                                               unsigned numTys) const {
00076   llvm_unreachable("Not implemented");
00077 }