2003-05-08 03:33:54 +00:00
|
|
|
//===-- llvm/Instrinsics.h - LLVM Intrinsic Function Handling ---*- C++ -*-===//
|
2005-04-21 20:19:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 19:59:42 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 20:19:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2003-05-08 03:33:54 +00:00
|
|
|
//
|
|
|
|
// This file defines a set of enums which allow processing of intrinsic
|
|
|
|
// functions. Values of these enum types are returned by
|
|
|
|
// Function::getIntrinsicID.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2013-01-10 00:45:19 +00:00
|
|
|
#ifndef LLVM_IR_INTRINSICS_H
|
|
|
|
#define LLVM_IR_INTRINSICS_H
|
2003-05-08 03:33:54 +00:00
|
|
|
|
2011-07-14 17:45:39 +00:00
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
2008-04-30 04:56:14 +00:00
|
|
|
#include <string>
|
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
namespace llvm {
|
|
|
|
|
2007-04-01 07:26:35 +00:00
|
|
|
class Type;
|
2007-02-07 20:38:26 +00:00
|
|
|
class FunctionType;
|
|
|
|
class Function;
|
2009-08-11 17:45:13 +00:00
|
|
|
class LLVMContext;
|
2007-02-07 20:38:26 +00:00
|
|
|
class Module;
|
2012-12-07 23:16:57 +00:00
|
|
|
class AttributeSet;
|
2007-02-07 20:38:26 +00:00
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
/// Intrinsic Namespace - This namespace contains an enum with a value for
|
2003-06-03 15:30:13 +00:00
|
|
|
/// every intrinsic/builtin function known by LLVM. These enum values are
|
|
|
|
/// returned by Function::getIntrinsicID().
|
|
|
|
///
|
2003-11-11 22:41:34 +00:00
|
|
|
namespace Intrinsic {
|
2003-05-08 03:33:54 +00:00
|
|
|
enum ID {
|
|
|
|
not_intrinsic = 0, // Must be zero
|
2003-05-17 22:26:33 +00:00
|
|
|
|
2006-03-09 20:03:31 +00:00
|
|
|
// Get the intrinsic enums generated from Intrinsics.td
|
|
|
|
#define GET_INTRINSIC_ENUM_VALUES
|
2013-01-02 12:09:16 +00:00
|
|
|
#include "llvm/IR/Intrinsics.gen"
|
2006-03-09 20:03:31 +00:00
|
|
|
#undef GET_INTRINSIC_ENUM_VALUES
|
2006-03-25 06:32:07 +00:00
|
|
|
, num_intrinsics
|
2003-05-08 03:33:54 +00:00
|
|
|
};
|
2006-03-25 06:32:07 +00:00
|
|
|
|
|
|
|
/// Intrinsic::getName(ID) - Return the LLVM name for an intrinsic, such as
|
|
|
|
/// "llvm.ppc.altivec.lvx".
|
2013-05-05 00:40:33 +00:00
|
|
|
std::string getName(ID id, ArrayRef<Type*> Tys = None);
|
|
|
|
|
2007-02-07 20:38:26 +00:00
|
|
|
/// Intrinsic::getType(ID) - Return the function type for an intrinsic.
|
|
|
|
///
|
2011-07-18 04:54:35 +00:00
|
|
|
FunctionType *getType(LLVMContext &Context, ID id,
|
2013-05-05 00:40:33 +00:00
|
|
|
ArrayRef<Type*> Tys = None);
|
2007-02-07 20:38:26 +00:00
|
|
|
|
2009-02-24 23:17:49 +00:00
|
|
|
/// Intrinsic::isOverloaded(ID) - Returns true if the intrinsic can be
|
|
|
|
/// overloaded.
|
|
|
|
bool isOverloaded(ID id);
|
|
|
|
|
2008-09-25 21:00:45 +00:00
|
|
|
/// Intrinsic::getAttributes(ID) - Return the attributes for an intrinsic.
|
2007-12-03 20:06:50 +00:00
|
|
|
///
|
2012-12-07 23:16:57 +00:00
|
|
|
AttributeSet getAttributes(LLVMContext &C, ID id);
|
2007-12-03 20:06:50 +00:00
|
|
|
|
2007-02-07 20:38:26 +00:00
|
|
|
/// Intrinsic::getDeclaration(M, ID) - Create or insert an LLVM Function
|
|
|
|
/// declaration for an intrinsic, and return it.
|
2008-02-20 01:07:51 +00:00
|
|
|
///
|
2013-05-01 07:54:55 +00:00
|
|
|
/// The Tys parameter is for intrinsics with overloaded types (e.g., those
|
|
|
|
/// using iAny, fAny, vAny, or iPTRAny). For a declaration of an overloaded
|
|
|
|
/// intrinsic, Tys must provide exactly one type for each overloaded type in
|
|
|
|
/// the intrinsic.
|
2013-05-05 00:40:33 +00:00
|
|
|
Function *getDeclaration(Module *M, ID id, ArrayRef<Type*> Tys = None);
|
2013-05-01 07:54:55 +00:00
|
|
|
|
2009-02-05 01:49:45 +00:00
|
|
|
/// Map a GCC builtin name to an intrinsic ID.
|
|
|
|
ID getIntrinsicForGCCBuiltin(const char *Prefix, const char *BuiltinName);
|
2007-02-07 20:38:26 +00:00
|
|
|
|
2012-05-27 18:28:35 +00:00
|
|
|
/// IITDescriptor - This is a type descriptor which explains the type
|
|
|
|
/// requirements of an intrinsic. This is returned by
|
|
|
|
/// getIntrinsicInfoTableEntries.
|
|
|
|
struct IITDescriptor {
|
|
|
|
enum IITDescriptorKind {
|
2013-10-31 17:18:11 +00:00
|
|
|
Void, VarArg, MMX, Metadata, Half, Float, Double,
|
2012-05-27 18:28:35 +00:00
|
|
|
Integer, Vector, Pointer, Struct,
|
2014-03-29 07:04:54 +00:00
|
|
|
Argument, ExtendArgument, TruncArgument, HalfVecArgument
|
2012-05-27 18:28:35 +00:00
|
|
|
} Kind;
|
|
|
|
|
|
|
|
union {
|
|
|
|
unsigned Integer_Width;
|
|
|
|
unsigned Float_Width;
|
|
|
|
unsigned Vector_Width;
|
|
|
|
unsigned Pointer_AddressSpace;
|
|
|
|
unsigned Struct_NumElements;
|
|
|
|
unsigned Argument_Info;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ArgKind {
|
|
|
|
AK_AnyInteger,
|
|
|
|
AK_AnyFloat,
|
|
|
|
AK_AnyVector,
|
|
|
|
AK_AnyPointer
|
|
|
|
};
|
|
|
|
unsigned getArgumentNumber() const {
|
2014-03-28 12:31:39 +00:00
|
|
|
assert(Kind == Argument || Kind == ExtendArgument ||
|
2014-03-29 07:04:54 +00:00
|
|
|
Kind == TruncArgument || Kind == HalfVecArgument);
|
2012-05-27 18:28:35 +00:00
|
|
|
return Argument_Info >> 2;
|
|
|
|
}
|
|
|
|
ArgKind getArgumentKind() const {
|
2014-03-28 12:31:39 +00:00
|
|
|
assert(Kind == Argument || Kind == ExtendArgument ||
|
2014-03-29 07:04:54 +00:00
|
|
|
Kind == TruncArgument || Kind == HalfVecArgument);
|
2012-05-27 18:28:35 +00:00
|
|
|
return (ArgKind)(Argument_Info&3);
|
|
|
|
}
|
|
|
|
|
|
|
|
static IITDescriptor get(IITDescriptorKind K, unsigned Field) {
|
|
|
|
IITDescriptor Result = { K, { Field } };
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// getIntrinsicInfoTableEntries - Return the IIT table descriptor for the
|
|
|
|
/// specified intrinsic into an array of IITDescriptors.
|
|
|
|
///
|
|
|
|
void getIntrinsicInfoTableEntries(ID id, SmallVectorImpl<IITDescriptor> &T);
|
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
} // End Intrinsic namespace
|
|
|
|
|
|
|
|
} // End llvm namespace
|
2003-05-08 03:33:54 +00:00
|
|
|
|
|
|
|
#endif
|