blob: 762ee39e469349022b0ea203b6ddd3672eb86395 [file] [log] [blame]
Tom Stellard75aadc22012-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"
Tom Stellard75aadc22012-12-11 21:25:42 +000016#include "AMDGPUSubtarget.h"
Chandler Carruth9fb823b2013-01-02 11:36:10 +000017#include "llvm/IR/DerivedTypes.h"
18#include "llvm/IR/Intrinsics.h"
19#include "llvm/IR/Module.h"
Tom Stellard75aadc22012-12-11 21:25:42 +000020
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
31std::string
32AMDGPUIntrinsicInfo::getName(unsigned int IntrID, Type **Tys,
33 unsigned int numTys) const {
34 static const char* const names[] = {
35#define GET_INTRINSIC_NAME_TABLE
36#include "AMDGPUGenIntrinsics.inc"
37#undef GET_INTRINSIC_NAME_TABLE
38 };
39
40 if (IntrID < Intrinsic::num_intrinsics) {
41 return 0;
42 }
43 assert(IntrID < AMDGPUIntrinsic::num_AMDGPU_intrinsics
44 && "Invalid intrinsic ID");
45
46 std::string Result(names[IntrID - Intrinsic::num_intrinsics]);
47 return Result;
48}
49
50unsigned int
51AMDGPUIntrinsicInfo::lookupName(const char *Name, unsigned int Len) const {
Rafael Espindolaebd8e382013-05-22 14:57:42 +000052 if (!StringRef(Name, Len).startswith("llvm."))
53 return 0; // All intrinsics start with 'llvm.'
54
Tom Stellard75aadc22012-12-11 21:25:42 +000055#define GET_FUNCTION_RECOGNIZER
56#include "AMDGPUGenIntrinsics.inc"
57#undef GET_FUNCTION_RECOGNIZER
58 AMDGPUIntrinsic::ID IntrinsicID
59 = (AMDGPUIntrinsic::ID)Intrinsic::not_intrinsic;
60 IntrinsicID = getIntrinsicForGCCBuiltin("AMDGPU", Name);
61
62 if (IntrinsicID != (AMDGPUIntrinsic::ID)Intrinsic::not_intrinsic) {
63 return IntrinsicID;
64 }
65 return 0;
66}
67
68bool
69AMDGPUIntrinsicInfo::isOverloaded(unsigned id) const {
70 // Overload Table
71#define GET_INTRINSIC_OVERLOAD_TABLE
72#include "AMDGPUGenIntrinsics.inc"
73#undef GET_INTRINSIC_OVERLOAD_TABLE
74}
75
76Function*
77AMDGPUIntrinsicInfo::getDeclaration(Module *M, unsigned IntrID,
78 Type **Tys,
79 unsigned numTys) const {
Tom Stellard6975d352012-12-13 19:38:52 +000080 llvm_unreachable("Not implemented");
Tom Stellard75aadc22012-12-11 21:25:42 +000081}