blob: 02d06d6f3d7a4e9edea5d7b559ab6ad7d3ce111b [file] [log] [blame]
Tom Stellardf98f2ce2012-12-11 21:25:42 +00001//===- AMDILIntrinsicInfo.cpp - AMDGPU Intrinsic Information ------*- C++ -*-===//
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
15#include "AMDILIntrinsicInfo.h"
16#include "AMDIL.h"
17#include "AMDGPUSubtarget.h"
18#include "llvm/DerivedTypes.h"
19#include "llvm/Intrinsics.h"
20#include "llvm/Module.h"
21
22using namespace llvm;
23
24#define GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN
25#include "AMDGPUGenIntrinsics.inc"
26#undef GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN
27
28AMDGPUIntrinsicInfo::AMDGPUIntrinsicInfo(TargetMachine *tm)
29 : TargetIntrinsicInfo() {
30}
31
32std::string
33AMDGPUIntrinsicInfo::getName(unsigned int IntrID, Type **Tys,
34 unsigned int numTys) const {
35 static const char* const names[] = {
36#define GET_INTRINSIC_NAME_TABLE
37#include "AMDGPUGenIntrinsics.inc"
38#undef GET_INTRINSIC_NAME_TABLE
39 };
40
41 if (IntrID < Intrinsic::num_intrinsics) {
42 return 0;
43 }
44 assert(IntrID < AMDGPUIntrinsic::num_AMDGPU_intrinsics
45 && "Invalid intrinsic ID");
46
47 std::string Result(names[IntrID - Intrinsic::num_intrinsics]);
48 return Result;
49}
50
51unsigned int
52AMDGPUIntrinsicInfo::lookupName(const char *Name, unsigned int Len) const {
53#define GET_FUNCTION_RECOGNIZER
54#include "AMDGPUGenIntrinsics.inc"
55#undef GET_FUNCTION_RECOGNIZER
56 AMDGPUIntrinsic::ID IntrinsicID
57 = (AMDGPUIntrinsic::ID)Intrinsic::not_intrinsic;
58 IntrinsicID = getIntrinsicForGCCBuiltin("AMDGPU", Name);
59
60 if (IntrinsicID != (AMDGPUIntrinsic::ID)Intrinsic::not_intrinsic) {
61 return IntrinsicID;
62 }
63 return 0;
64}
65
66bool
67AMDGPUIntrinsicInfo::isOverloaded(unsigned id) const {
68 // Overload Table
69#define GET_INTRINSIC_OVERLOAD_TABLE
70#include "AMDGPUGenIntrinsics.inc"
71#undef GET_INTRINSIC_OVERLOAD_TABLE
72}
73
74Function*
75AMDGPUIntrinsicInfo::getDeclaration(Module *M, unsigned IntrID,
76 Type **Tys,
77 unsigned numTys) const {
78 assert(!"Not implemented");
79}