blob: b92e528ff714453e3a08774b919c4f9e7fc549a2 [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 Carruthbe810232013-01-02 10:22:59 +000017#include "AMDIL.h"
Chandler Carruth9fb823b2013-01-02 11:36:10 +000018#include "llvm/IR/DerivedTypes.h"
19#include "llvm/IR/Intrinsics.h"
20#include "llvm/IR/Module.h"
Tom Stellard75aadc22012-12-11 21:25:42 +000021
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 {
Rafael Espindolaebd8e382013-05-22 14:57:42 +000053 if (!StringRef(Name, Len).startswith("llvm."))
54 return 0; // All intrinsics start with 'llvm.'
55
Tom Stellard75aadc22012-12-11 21:25:42 +000056#define GET_FUNCTION_RECOGNIZER
57#include "AMDGPUGenIntrinsics.inc"
58#undef GET_FUNCTION_RECOGNIZER
59 AMDGPUIntrinsic::ID IntrinsicID
60 = (AMDGPUIntrinsic::ID)Intrinsic::not_intrinsic;
61 IntrinsicID = getIntrinsicForGCCBuiltin("AMDGPU", Name);
62
63 if (IntrinsicID != (AMDGPUIntrinsic::ID)Intrinsic::not_intrinsic) {
64 return IntrinsicID;
65 }
66 return 0;
67}
68
69bool
70AMDGPUIntrinsicInfo::isOverloaded(unsigned id) const {
71 // Overload Table
72#define GET_INTRINSIC_OVERLOAD_TABLE
73#include "AMDGPUGenIntrinsics.inc"
74#undef GET_INTRINSIC_OVERLOAD_TABLE
75}
76
77Function*
78AMDGPUIntrinsicInfo::getDeclaration(Module *M, unsigned IntrID,
79 Type **Tys,
80 unsigned numTys) const {
Tom Stellard6975d352012-12-13 19:38:52 +000081 llvm_unreachable("Not implemented");
Tom Stellard75aadc22012-12-11 21:25:42 +000082}