2003-10-13 05:32:08 +02:00
|
|
|
//===-- Function.cpp - Implement the Global object classes ----------------===//
|
2005-04-22 01:48:37 +02:00
|
|
|
//
|
2003-10-20 21:43:21 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 21:36:04 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-22 01:48:37 +02:00
|
|
|
//
|
2003-10-20 21:43:21 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2001-06-06 22:29:01 +02:00
|
|
|
//
|
2007-02-05 21:47:22 +01:00
|
|
|
// This file implements the Function class for the VMCore library.
|
2001-06-06 22:29:01 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/Module.h"
|
2002-09-06 22:46:32 +02:00
|
|
|
#include "llvm/DerivedTypes.h"
|
2004-10-12 06:20:25 +02:00
|
|
|
#include "llvm/IntrinsicInst.h"
|
2007-08-20 21:23:34 +02:00
|
|
|
#include "llvm/CodeGen/ValueTypes.h"
|
2004-09-02 00:55:40 +02:00
|
|
|
#include "llvm/Support/LeakDetector.h"
|
2007-12-10 04:18:06 +01:00
|
|
|
#include "llvm/Support/StringPool.h"
|
2002-06-25 18:13:24 +02:00
|
|
|
#include "SymbolTableListTraitsImpl.h"
|
2007-12-03 21:06:50 +01:00
|
|
|
#include "llvm/ADT/BitVector.h"
|
2007-12-10 04:18:06 +01:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
2004-12-05 07:43:27 +01:00
|
|
|
#include "llvm/ADT/StringExtras.h"
|
2003-11-21 21:23:48 +01:00
|
|
|
using namespace llvm;
|
2003-11-11 23:41:34 +01:00
|
|
|
|
2005-01-30 01:09:23 +01:00
|
|
|
BasicBlock *ilist_traits<BasicBlock>::createSentinel() {
|
2008-04-06 22:25:17 +02:00
|
|
|
BasicBlock *Ret = BasicBlock::Create();
|
2002-09-08 20:59:35 +02:00
|
|
|
// This should not be garbage monitored.
|
|
|
|
LeakDetector::removeGarbageObject(Ret);
|
|
|
|
return Ret;
|
2002-09-06 23:33:15 +02:00
|
|
|
}
|
|
|
|
|
2002-06-25 18:13:24 +02:00
|
|
|
iplist<BasicBlock> &ilist_traits<BasicBlock>::getList(Function *F) {
|
|
|
|
return F->getBasicBlockList();
|
|
|
|
}
|
|
|
|
|
2005-01-30 01:09:23 +01:00
|
|
|
Argument *ilist_traits<Argument>::createSentinel() {
|
2006-12-31 06:26:44 +01:00
|
|
|
Argument *Ret = new Argument(Type::Int32Ty);
|
2002-09-08 20:59:35 +02:00
|
|
|
// This should not be garbage monitored.
|
|
|
|
LeakDetector::removeGarbageObject(Ret);
|
|
|
|
return Ret;
|
2002-06-25 18:13:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
iplist<Argument> &ilist_traits<Argument>::getList(Function *F) {
|
|
|
|
return F->getArgumentList();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Explicit instantiations of SymbolTableListTraits since some of the methods
|
|
|
|
// are not in the public header file...
|
2007-04-17 05:26:42 +02:00
|
|
|
template class SymbolTableListTraits<Argument, Function>;
|
|
|
|
template class SymbolTableListTraits<BasicBlock, Function>;
|
2001-06-06 22:29:01 +02:00
|
|
|
|
2002-04-09 21:39:35 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Argument Implementation
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2005-04-22 01:48:37 +02:00
|
|
|
Argument::Argument(const Type *Ty, const std::string &Name, Function *Par)
|
2007-02-12 06:18:08 +01:00
|
|
|
: Value(Ty, Value::ArgumentVal) {
|
2002-09-06 23:33:15 +02:00
|
|
|
Parent = 0;
|
2002-09-08 20:59:35 +02:00
|
|
|
|
|
|
|
// Make sure that we get added to a function
|
|
|
|
LeakDetector::addGarbageObject(this);
|
|
|
|
|
2002-09-06 23:33:15 +02:00
|
|
|
if (Par)
|
|
|
|
Par->getArgumentList().push_back(this);
|
2007-02-12 06:18:08 +01:00
|
|
|
setName(Name);
|
2002-09-06 23:33:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Argument::setParent(Function *parent) {
|
2002-09-08 20:59:35 +02:00
|
|
|
if (getParent())
|
|
|
|
LeakDetector::addGarbageObject(this);
|
2002-09-06 23:33:15 +02:00
|
|
|
Parent = parent;
|
2002-09-08 20:59:35 +02:00
|
|
|
if (getParent())
|
|
|
|
LeakDetector::removeGarbageObject(this);
|
2002-09-06 23:33:15 +02:00
|
|
|
}
|
|
|
|
|
2008-01-24 18:47:11 +01:00
|
|
|
/// getArgNo - Return the index of this formal argument in its containing
|
|
|
|
/// function. For example in "void foo(int a, float b)" a is 0 and b is 1.
|
|
|
|
unsigned Argument::getArgNo() const {
|
|
|
|
const Function *F = getParent();
|
|
|
|
assert(F && "Argument is not in a function");
|
|
|
|
|
|
|
|
Function::const_arg_iterator AI = F->arg_begin();
|
|
|
|
unsigned ArgIdx = 0;
|
|
|
|
for (; &*AI != this; ++AI)
|
|
|
|
++ArgIdx;
|
|
|
|
|
|
|
|
return ArgIdx;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// hasByValAttr - Return true if this argument has the byval attribute on it
|
|
|
|
/// in its containing function.
|
|
|
|
bool Argument::hasByValAttr() const {
|
|
|
|
if (!isa<PointerType>(getType())) return false;
|
|
|
|
return getParent()->paramHasAttr(getArgNo()+1, ParamAttr::ByVal);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// hasNoAliasAttr - Return true if this argument has the noalias attribute on
|
|
|
|
/// it in its containing function.
|
|
|
|
bool Argument::hasNoAliasAttr() const {
|
|
|
|
if (!isa<PointerType>(getType())) return false;
|
|
|
|
return getParent()->paramHasAttr(getArgNo()+1, ParamAttr::NoAlias);
|
|
|
|
}
|
|
|
|
|
2008-02-18 00:22:28 +01:00
|
|
|
/// hasSRetAttr - Return true if this argument has the sret attribute on
|
|
|
|
/// it in its containing function.
|
|
|
|
bool Argument::hasStructRetAttr() const {
|
|
|
|
if (!isa<PointerType>(getType())) return false;
|
2008-05-15 12:04:30 +02:00
|
|
|
if (this != getParent()->arg_begin())
|
|
|
|
return false; // StructRet param must be first param
|
2008-02-18 05:06:26 +01:00
|
|
|
return getParent()->paramHasAttr(1, ParamAttr::StructRet);
|
2008-02-18 00:22:28 +01:00
|
|
|
}
|
|
|
|
|
2008-04-28 19:37:06 +02:00
|
|
|
/// addAttr - Add a ParamAttr to an argument
|
|
|
|
void Argument::addAttr(ParameterAttributes attr) {
|
|
|
|
getParent()->setParamAttrs(
|
|
|
|
getParent()->getParamAttrs().addAttr(getArgNo() + 1, attr));
|
|
|
|
}
|
|
|
|
|
|
|
|
/// removeAttr - Remove a ParamAttr from an argument
|
|
|
|
void Argument::removeAttr(ParameterAttributes attr) {
|
|
|
|
getParent()->setParamAttrs(
|
|
|
|
getParent()->getParamAttrs().removeAttr(getArgNo() + 1, attr));
|
|
|
|
}
|
2008-01-24 18:47:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2007-04-09 17:01:12 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2008-01-03 00:42:30 +01:00
|
|
|
// Helper Methods in Function
|
2007-04-09 17:01:12 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2008-01-03 00:42:30 +01:00
|
|
|
const FunctionType *Function::getFunctionType() const {
|
|
|
|
return cast<FunctionType>(getType()->getElementType());
|
2007-04-09 17:01:12 +02:00
|
|
|
}
|
|
|
|
|
2008-01-03 00:42:30 +01:00
|
|
|
bool Function::isVarArg() const {
|
|
|
|
return getFunctionType()->isVarArg();
|
2007-04-09 17:01:12 +02:00
|
|
|
}
|
|
|
|
|
2008-01-03 00:42:30 +01:00
|
|
|
const Type *Function::getReturnType() const {
|
|
|
|
return getFunctionType()->getReturnType();
|
2007-11-25 15:10:56 +01:00
|
|
|
}
|
|
|
|
|
2008-01-03 00:42:30 +01:00
|
|
|
void Function::removeFromParent() {
|
|
|
|
getParent()->getFunctionList().remove(this);
|
2007-11-25 15:10:56 +01:00
|
|
|
}
|
|
|
|
|
2008-01-03 00:42:30 +01:00
|
|
|
void Function::eraseFromParent() {
|
|
|
|
getParent()->getFunctionList().erase(this);
|
2007-04-09 17:01:12 +02:00
|
|
|
}
|
|
|
|
|
2001-09-10 09:58:01 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-03-26 19:01:55 +01:00
|
|
|
// Function Implementation
|
2001-09-10 09:58:01 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2003-04-16 22:28:45 +02:00
|
|
|
Function::Function(const FunctionType *Ty, LinkageTypes Linkage,
|
2002-09-06 22:46:32 +02:00
|
|
|
const std::string &name, Module *ParentModule)
|
2007-12-17 02:12:55 +01:00
|
|
|
: GlobalValue(PointerType::getUnqual(Ty),
|
2008-03-12 18:45:29 +01:00
|
|
|
Value::FunctionVal, 0, 0, Linkage, name) {
|
2007-02-05 21:47:22 +01:00
|
|
|
SymTab = new ValueSymbolTable();
|
2002-09-06 22:46:32 +02:00
|
|
|
|
2008-02-20 23:36:03 +01:00
|
|
|
assert((getReturnType()->isFirstClassType() ||getReturnType() == Type::VoidTy
|
2008-02-21 23:24:17 +01:00
|
|
|
|| isa<StructType>(getReturnType()))
|
2003-11-21 23:32:23 +01:00
|
|
|
&& "LLVM functions cannot return aggregate values!");
|
|
|
|
|
2007-08-18 08:14:52 +02:00
|
|
|
// If the function has arguments, mark them as lazily built.
|
|
|
|
if (Ty->getNumParams())
|
|
|
|
SubclassData = 1; // Set the "has lazy arguments" bit.
|
|
|
|
|
2002-09-08 20:59:35 +02:00
|
|
|
// Make sure that we get added to a function
|
|
|
|
LeakDetector::addGarbageObject(this);
|
|
|
|
|
2002-09-06 22:46:32 +02:00
|
|
|
if (ParentModule)
|
|
|
|
ParentModule->getFunctionList().push_back(this);
|
2008-04-07 15:39:11 +02:00
|
|
|
|
|
|
|
// Ensure intrinsics have the right parameter attributes.
|
|
|
|
if (unsigned IID = getIntrinsicID(true))
|
|
|
|
setParamAttrs(Intrinsic::getParamAttrs(Intrinsic::ID(IID)));
|
2001-06-06 22:29:01 +02:00
|
|
|
}
|
|
|
|
|
2007-12-10 03:14:30 +01:00
|
|
|
Function::~Function() {
|
|
|
|
dropAllReferences(); // After this it is safe to delete instructions.
|
2001-06-06 22:29:01 +02:00
|
|
|
|
|
|
|
// Delete all of the method arguments and unlink from symbol table...
|
2007-12-10 03:14:30 +01:00
|
|
|
ArgumentList.clear();
|
|
|
|
delete SymTab;
|
2007-04-22 19:28:03 +02:00
|
|
|
|
2007-12-10 04:18:06 +01:00
|
|
|
// Remove the function from the on-the-side collector table.
|
|
|
|
clearCollector();
|
2001-06-06 22:29:01 +02:00
|
|
|
}
|
|
|
|
|
2007-08-18 08:14:52 +02:00
|
|
|
void Function::BuildLazyArguments() const {
|
|
|
|
// Create the arguments vector, all arguments start out unnamed.
|
|
|
|
const FunctionType *FT = getFunctionType();
|
|
|
|
for (unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
|
|
|
|
assert(FT->getParamType(i) != Type::VoidTy &&
|
|
|
|
"Cannot have void typed arguments!");
|
|
|
|
ArgumentList.push_back(new Argument(FT->getParamType(i)));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clear the lazy arguments bit.
|
|
|
|
const_cast<Function*>(this)->SubclassData &= ~1;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t Function::arg_size() const {
|
|
|
|
return getFunctionType()->getNumParams();
|
|
|
|
}
|
|
|
|
bool Function::arg_empty() const {
|
|
|
|
return getFunctionType()->getNumParams() == 0;
|
|
|
|
}
|
|
|
|
|
2002-03-23 23:51:58 +01:00
|
|
|
void Function::setParent(Module *parent) {
|
2002-09-08 20:59:35 +02:00
|
|
|
if (getParent())
|
|
|
|
LeakDetector::addGarbageObject(this);
|
2001-06-06 22:29:01 +02:00
|
|
|
Parent = parent;
|
2002-09-08 20:59:35 +02:00
|
|
|
if (getParent())
|
|
|
|
LeakDetector::removeGarbageObject(this);
|
2001-06-06 22:29:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// dropAllReferences() - This function causes all the subinstructions to "let
|
|
|
|
// go" of all references that they are maintaining. This allows one to
|
|
|
|
// 'delete' a whole class at a time, even though there may be circular
|
|
|
|
// references... first all references are dropped, and all use counts go to
|
2003-10-10 19:54:14 +02:00
|
|
|
// zero. Then everything is deleted for real. Note that no operations are
|
2005-04-22 01:48:37 +02:00
|
|
|
// valid on an object that has "dropped all references", except operator
|
2001-06-06 22:29:01 +02:00
|
|
|
// delete.
|
|
|
|
//
|
2002-03-23 23:51:58 +01:00
|
|
|
void Function::dropAllReferences() {
|
2002-06-25 18:13:24 +02:00
|
|
|
for (iterator I = begin(), E = end(); I != E; ++I)
|
|
|
|
I->dropAllReferences();
|
2003-09-17 06:58:59 +02:00
|
|
|
BasicBlocks.clear(); // Delete all basic blocks...
|
2001-06-06 22:29:01 +02:00
|
|
|
}
|
2001-09-10 09:58:01 +02:00
|
|
|
|
2008-04-08 09:23:58 +02:00
|
|
|
void Function::setDoesNotThrow(bool doesNotThrow) {
|
|
|
|
PAListPtr PAL = getParamAttrs();
|
|
|
|
if (doesNotThrow)
|
|
|
|
PAL = PAL.addAttr(0, ParamAttr::NoUnwind);
|
|
|
|
else
|
|
|
|
PAL = PAL.removeAttr(0, ParamAttr::NoUnwind);
|
|
|
|
setParamAttrs(PAL);
|
|
|
|
}
|
|
|
|
|
2008-05-16 22:39:43 +02:00
|
|
|
void Function::addParamAttr(unsigned i, ParameterAttributes attr) {
|
|
|
|
PAListPtr PAL = getParamAttrs();
|
|
|
|
PAL = PAL.addAttr(i, attr);
|
|
|
|
setParamAttrs(PAL);
|
|
|
|
}
|
|
|
|
|
2007-12-10 04:18:06 +01:00
|
|
|
// Maintain the collector name for each function in an on-the-side table. This
|
|
|
|
// saves allocating an additional word in Function for programs which do not use
|
|
|
|
// GC (i.e., most programs) at the cost of increased overhead for clients which
|
|
|
|
// do use GC.
|
|
|
|
static DenseMap<const Function*,PooledStringPtr> *CollectorNames;
|
|
|
|
static StringPool *CollectorNamePool;
|
|
|
|
|
|
|
|
bool Function::hasCollector() const {
|
|
|
|
return CollectorNames && CollectorNames->count(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *Function::getCollector() const {
|
|
|
|
assert(hasCollector() && "Function has no collector");
|
|
|
|
return *(*CollectorNames)[this];
|
|
|
|
}
|
|
|
|
|
|
|
|
void Function::setCollector(const char *Str) {
|
|
|
|
if (!CollectorNamePool)
|
|
|
|
CollectorNamePool = new StringPool();
|
|
|
|
if (!CollectorNames)
|
|
|
|
CollectorNames = new DenseMap<const Function*,PooledStringPtr>();
|
|
|
|
(*CollectorNames)[this] = CollectorNamePool->intern(Str);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Function::clearCollector() {
|
|
|
|
if (CollectorNames) {
|
|
|
|
CollectorNames->erase(this);
|
|
|
|
if (CollectorNames->empty()) {
|
|
|
|
delete CollectorNames;
|
|
|
|
CollectorNames = 0;
|
2007-12-10 04:35:18 +01:00
|
|
|
if (CollectorNamePool->empty()) {
|
|
|
|
delete CollectorNamePool;
|
|
|
|
CollectorNamePool = 0;
|
|
|
|
}
|
2007-12-10 04:18:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-26 21:58:59 +02:00
|
|
|
/// copyAttributesFrom - copy all additional attributes (those not needed to
|
|
|
|
/// create a Function) from the Function Src to this one.
|
|
|
|
void Function::copyAttributesFrom(const GlobalValue *Src) {
|
|
|
|
assert(isa<Function>(Src) && "Expected a Function!");
|
|
|
|
GlobalValue::copyAttributesFrom(Src);
|
|
|
|
const Function *SrcF = cast<Function>(Src);
|
|
|
|
setCallingConv(SrcF->getCallingConv());
|
|
|
|
setParamAttrs(SrcF->getParamAttrs());
|
|
|
|
if (SrcF->hasCollector())
|
|
|
|
setCollector(SrcF->getCollector());
|
|
|
|
}
|
|
|
|
|
2003-05-08 05:47:33 +02:00
|
|
|
/// getIntrinsicID - This method returns the ID number of the specified
|
2003-11-11 23:41:34 +01:00
|
|
|
/// function, or Intrinsic::not_intrinsic if the function is not an
|
2003-10-10 19:54:14 +02:00
|
|
|
/// intrinsic, or if the pointer is null. This value is always defined to be
|
2003-05-08 05:47:33 +02:00
|
|
|
/// zero to allow easy checking for whether a function is intrinsic or not. The
|
|
|
|
/// particular intrinsic functions which correspond to this value are defined in
|
|
|
|
/// llvm/Intrinsics.h.
|
|
|
|
///
|
2007-04-16 08:54:34 +02:00
|
|
|
unsigned Function::getIntrinsicID(bool noAssert) const {
|
2007-02-15 20:17:16 +01:00
|
|
|
const ValueName *ValName = this->getValueName();
|
2007-04-16 09:08:44 +02:00
|
|
|
if (!ValName)
|
|
|
|
return 0;
|
2007-02-15 20:17:16 +01:00
|
|
|
unsigned Len = ValName->getKeyLength();
|
|
|
|
const char *Name = ValName->getKeyData();
|
|
|
|
|
2007-04-16 18:56:54 +02:00
|
|
|
if (Len < 5 || Name[4] != '.' || Name[0] != 'l' || Name[1] != 'l'
|
For PR411:
This patch is an incremental step towards supporting a flat symbol table.
It de-overloads the intrinsic functions by providing type-specific intrinsics
and arranging for automatically upgrading from the old overloaded name to
the new non-overloaded name. Specifically:
llvm.isunordered -> llvm.isunordered.f32, llvm.isunordered.f64
llvm.sqrt -> llvm.sqrt.f32, llvm.sqrt.f64
llvm.ctpop -> llvm.ctpop.i8, llvm.ctpop.i16, llvm.ctpop.i32, llvm.ctpop.i64
llvm.ctlz -> llvm.ctlz.i8, llvm.ctlz.i16, llvm.ctlz.i32, llvm.ctlz.i64
llvm.cttz -> llvm.cttz.i8, llvm.cttz.i16, llvm.cttz.i32, llvm.cttz.i64
New code should not use the overloaded intrinsic names. Warnings will be
emitted if they are used.
llvm-svn: 25366
2006-01-16 22:12:35 +01:00
|
|
|
|| Name[2] != 'v' || Name[3] != 'm')
|
2003-05-08 05:47:33 +02:00
|
|
|
return 0; // All intrinsics start with 'llvm.'
|
2003-09-19 21:31:41 +02:00
|
|
|
|
2007-04-16 08:54:34 +02:00
|
|
|
assert((Len != 5 || noAssert) && "'llvm.' is an invalid intrinsic name!");
|
2005-04-22 01:48:37 +02:00
|
|
|
|
2006-03-09 21:35:01 +01:00
|
|
|
#define GET_FUNCTION_RECOGNIZER
|
|
|
|
#include "llvm/Intrinsics.gen"
|
|
|
|
#undef GET_FUNCTION_RECOGNIZER
|
2007-04-16 08:54:34 +02:00
|
|
|
assert(noAssert && "Invalid LLVM intrinsic name");
|
2003-05-08 05:47:33 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-04-01 09:25:33 +02:00
|
|
|
std::string Intrinsic::getName(ID id, const Type **Tys, unsigned numTys) {
|
2006-03-25 07:32:47 +01:00
|
|
|
assert(id < num_intrinsics && "Invalid intrinsic ID!");
|
|
|
|
const char * const Table[] = {
|
|
|
|
"not_intrinsic",
|
|
|
|
#define GET_INTRINSIC_NAME_TABLE
|
|
|
|
#include "llvm/Intrinsics.gen"
|
|
|
|
#undef GET_INTRINSIC_NAME_TABLE
|
|
|
|
};
|
2007-04-01 09:25:33 +02:00
|
|
|
if (numTys == 0)
|
|
|
|
return Table[id];
|
|
|
|
std::string Result(Table[id]);
|
|
|
|
for (unsigned i = 0; i < numTys; ++i)
|
|
|
|
if (Tys[i])
|
2008-06-06 14:08:01 +02:00
|
|
|
Result += "." + MVT::getMVT(Tys[i]).getMVTString();
|
2007-04-01 09:25:33 +02:00
|
|
|
return Result;
|
2006-03-25 07:32:47 +01:00
|
|
|
}
|
|
|
|
|
2007-04-01 09:25:33 +02:00
|
|
|
const FunctionType *Intrinsic::getType(ID id, const Type **Tys,
|
2007-06-06 01:49:06 +02:00
|
|
|
unsigned numTys) {
|
2007-02-07 21:38:26 +01:00
|
|
|
const Type *ResultTy = NULL;
|
|
|
|
std::vector<const Type*> ArgTys;
|
|
|
|
bool IsVarArg = false;
|
|
|
|
|
|
|
|
#define GET_INTRINSIC_GENERATOR
|
|
|
|
#include "llvm/Intrinsics.gen"
|
|
|
|
#undef GET_INTRINSIC_GENERATOR
|
|
|
|
|
2007-04-09 08:11:23 +02:00
|
|
|
return FunctionType::get(ResultTy, ArgTys, IsVarArg);
|
2007-02-07 21:38:26 +01:00
|
|
|
}
|
|
|
|
|
2008-03-12 18:45:29 +01:00
|
|
|
PAListPtr Intrinsic::getParamAttrs(ID id) {
|
2008-02-19 22:38:47 +01:00
|
|
|
ParameterAttributes Attr = ParamAttr::None;
|
2007-12-03 21:06:50 +01:00
|
|
|
|
|
|
|
#define GET_INTRINSIC_ATTRIBUTES
|
|
|
|
#include "llvm/Intrinsics.gen"
|
|
|
|
#undef GET_INTRINSIC_ATTRIBUTES
|
|
|
|
|
|
|
|
// Intrinsics cannot throw exceptions.
|
|
|
|
Attr |= ParamAttr::NoUnwind;
|
|
|
|
|
2008-03-12 18:45:29 +01:00
|
|
|
ParamAttrsWithIndex PAWI = ParamAttrsWithIndex::get(0, Attr);
|
|
|
|
return PAListPtr::get(&PAWI, 1);
|
2007-12-03 21:06:50 +01:00
|
|
|
}
|
|
|
|
|
2007-04-01 09:25:33 +02:00
|
|
|
Function *Intrinsic::getDeclaration(Module *M, ID id, const Type **Tys,
|
|
|
|
unsigned numTys) {
|
2007-12-03 21:06:50 +01:00
|
|
|
// There can never be multiple globals with the same name of different types,
|
|
|
|
// because intrinsics must be a specific type.
|
2008-04-07 15:39:11 +02:00
|
|
|
return
|
2007-12-03 21:06:50 +01:00
|
|
|
cast<Function>(M->getOrInsertFunction(getName(id, Tys, numTys),
|
|
|
|
getType(id, Tys, numTys)));
|
2007-02-07 21:38:26 +01:00
|
|
|
}
|
|
|
|
|
2004-07-18 01:50:19 +02:00
|
|
|
// vim: sw=2 ai
|