1//===- AMDILIntrinsicInfo.cpp - AMDIL 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// This file contains the AMDIL Implementation of the IntrinsicInfo class.
11//
12//===-----------------------------------------------------------------------===//
13
14#include "AMDILIntrinsicInfo.h"
15#include "AMDIL.h"
16#include "AMDGPUSubtarget.h"
17#include "llvm/DerivedTypes.h"
18#include "llvm/Intrinsics.h"
19#include "llvm/Module.h"
20
21using namespace llvm;
22
23#define GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN
24#include "AMDGPUGenIntrinsics.inc"
25#undef GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN
26
27AMDGPUIntrinsicInfo::AMDGPUIntrinsicInfo(TargetMachine *tm)
28  : TargetIntrinsicInfo()
29{
30}
31
32std::string
33AMDGPUIntrinsicInfo::getName(unsigned int IntrID, Type **Tys,
34    unsigned int numTys) const
35{
36  static const char* const names[] = {
37#define GET_INTRINSIC_NAME_TABLE
38#include "AMDGPUGenIntrinsics.inc"
39#undef GET_INTRINSIC_NAME_TABLE
40  };
41
42  //assert(!isOverloaded(IntrID)
43  //&& "AMDGPU Intrinsics are not overloaded");
44  if (IntrID < Intrinsic::num_intrinsics) {
45    return 0;
46  }
47  assert(IntrID < AMDGPUIntrinsic::num_AMDGPU_intrinsics
48      && "Invalid intrinsic ID");
49
50  std::string Result(names[IntrID - Intrinsic::num_intrinsics]);
51  return Result;
52}
53
54unsigned int
55AMDGPUIntrinsicInfo::lookupName(const char *Name, unsigned int Len) const
56{
57#define GET_FUNCTION_RECOGNIZER
58#include "AMDGPUGenIntrinsics.inc"
59#undef GET_FUNCTION_RECOGNIZER
60  AMDGPUIntrinsic::ID IntrinsicID
61    = (AMDGPUIntrinsic::ID)Intrinsic::not_intrinsic;
62  IntrinsicID = getIntrinsicForGCCBuiltin("AMDIL", Name);
63
64  if (IntrinsicID != (AMDGPUIntrinsic::ID)Intrinsic::not_intrinsic) {
65    return IntrinsicID;
66  }
67  return 0;
68}
69
70bool
71AMDGPUIntrinsicInfo::isOverloaded(unsigned id) const
72{
73  // Overload Table
74#define GET_INTRINSIC_OVERLOAD_TABLE
75#include "AMDGPUGenIntrinsics.inc"
76#undef GET_INTRINSIC_OVERLOAD_TABLE
77}
78
79/// This defines the "getAttributes(ID id)" method.
80#define GET_INTRINSIC_ATTRIBUTES
81#include "AMDGPUGenIntrinsics.inc"
82#undef GET_INTRINSIC_ATTRIBUTES
83
84Function*
85AMDGPUIntrinsicInfo::getDeclaration(Module *M, unsigned IntrID,
86    Type **Tys,
87    unsigned numTys) const
88{
89  //Silence a warning
90  AttrListPtr List = getAttributes((AMDGPUIntrinsic::ID)IntrID);
91  (void)List;
92  assert(!"Not implemented");
93}
94