LLVM  3.7.0
AMDGPUIntrinsicInfo.cpp
Go to the documentation of this file.
1 //===- AMDGPUIntrinsicInfo.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 "AMDGPUIntrinsicInfo.h"
16 #include "AMDGPUSubtarget.h"
17 #include "llvm/IR/DerivedTypes.h"
18 #include "llvm/IR/Intrinsics.h"
19 #include "llvm/IR/Module.h"
20 
21 using namespace llvm;
22 
23 #define GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN
24 #include "AMDGPUGenIntrinsics.inc"
25 #undef GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN
26 
28  : TargetIntrinsicInfo() {}
29 
30 std::string AMDGPUIntrinsicInfo::getName(unsigned IntrID, Type **Tys,
31  unsigned numTys) const {
32  static const char *const names[] = {
33 #define GET_INTRINSIC_NAME_TABLE
34 #include "AMDGPUGenIntrinsics.inc"
35 #undef GET_INTRINSIC_NAME_TABLE
36  };
37 
38  if (IntrID < Intrinsic::num_intrinsics) {
39  return nullptr;
40  }
42  "Invalid intrinsic ID");
43 
44  std::string Result(names[IntrID - Intrinsic::num_intrinsics]);
45  return Result;
46 }
47 
49  unsigned Len) const {
50  if (!StringRef(Name, Len).startswith("llvm."))
51  return 0; // All intrinsics start with 'llvm.'
52 
53 #define GET_FUNCTION_RECOGNIZER
54 #include "AMDGPUGenIntrinsics.inc"
55 #undef GET_FUNCTION_RECOGNIZER
56  AMDGPUIntrinsic::ID IntrinsicID =
58  IntrinsicID = getIntrinsicForGCCBuiltin("AMDGPU", Name);
59 
60  if (IntrinsicID != (AMDGPUIntrinsic::ID)Intrinsic::not_intrinsic) {
61  return IntrinsicID;
62  }
63  return 0;
64 }
65 
66 bool AMDGPUIntrinsicInfo::isOverloaded(unsigned id) const {
67 // Overload Table
68 #define GET_INTRINSIC_OVERLOAD_TABLE
69 #include "AMDGPUGenIntrinsics.inc"
70 #undef GET_INTRINSIC_OVERLOAD_TABLE
71 }
72 
74  Type **Tys,
75  unsigned numTys) const {
76  llvm_unreachable("Not implemented");
77 }
AMDGPU specific subclass of TargetSubtarget.
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:114
unsigned lookupName(const char *Name, unsigned Len) const override
Look up target intrinsic by name.
bool isOverloaded(unsigned IID) const override
Returns true if the intrinsic can be overloaded.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:98
std::string getName(unsigned IntrId, Type **Tys=nullptr, unsigned numTys=0) const override
Return the name of a target intrinsic, e.g.
ID getIntrinsicForGCCBuiltin(const char *Prefix, const char *BuiltinName)
Map a GCC builtin name to an intrinsic ID.
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
TargetIntrinsicInfo - Interface to description of machine instruction set.
Module.h This file contains the declarations for the Module class.
Interface for the AMDGPU Implementation of the Intrinsic Info class.
Function * getDeclaration(Module *M, unsigned ID, Type **Tys=nullptr, unsigned numTys=0) const override
Create or insert an LLVM Function declaration for an intrinsic, and return it.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:40