2003-10-13 03:32:08 +00:00
|
|
|
//===-- Function.cpp - Implement the Global object classes ----------------===//
|
2005-04-21 23:48:37 +00:00
|
|
|
//
|
2003-10-20 19:43:21 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
2005-04-21 23:48:37 +00:00
|
|
|
//
|
2003-10-20 19:43:21 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2001-06-06 20:29:01 +00:00
|
|
|
//
|
2002-03-26 18:01:55 +00:00
|
|
|
// This file implements the Function & GlobalVariable classes for the VMCore
|
2001-09-10 07:58:01 +00:00
|
|
|
// library.
|
2001-06-06 20:29:01 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/Module.h"
|
2002-09-06 20:46:32 +00:00
|
|
|
#include "llvm/DerivedTypes.h"
|
2004-10-12 04:20:25 +00:00
|
|
|
#include "llvm/IntrinsicInst.h"
|
2004-09-01 22:55:40 +00:00
|
|
|
#include "llvm/Support/LeakDetector.h"
|
2002-06-25 16:13:24 +00:00
|
|
|
#include "SymbolTableListTraitsImpl.h"
|
2004-12-05 06:43:27 +00:00
|
|
|
#include "llvm/ADT/StringExtras.h"
|
2003-11-21 20:23:48 +00:00
|
|
|
using namespace llvm;
|
2003-11-11 22:41:34 +00:00
|
|
|
|
2005-01-30 00:09:23 +00:00
|
|
|
BasicBlock *ilist_traits<BasicBlock>::createSentinel() {
|
2002-09-08 18:59:35 +00:00
|
|
|
BasicBlock *Ret = new BasicBlock();
|
|
|
|
// This should not be garbage monitored.
|
|
|
|
LeakDetector::removeGarbageObject(Ret);
|
|
|
|
return Ret;
|
2002-09-06 21:33:15 +00:00
|
|
|
}
|
|
|
|
|
2002-06-25 16:13:24 +00:00
|
|
|
iplist<BasicBlock> &ilist_traits<BasicBlock>::getList(Function *F) {
|
|
|
|
return F->getBasicBlockList();
|
|
|
|
}
|
|
|
|
|
2005-01-30 00:09:23 +00:00
|
|
|
Argument *ilist_traits<Argument>::createSentinel() {
|
2002-09-08 18:59:35 +00:00
|
|
|
Argument *Ret = new Argument(Type::IntTy);
|
|
|
|
// This should not be garbage monitored.
|
|
|
|
LeakDetector::removeGarbageObject(Ret);
|
|
|
|
return Ret;
|
2002-06-25 16:13:24 +00: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...
|
2003-11-05 05:15:42 +00:00
|
|
|
template class SymbolTableListTraits<Argument, Function, Function>;
|
|
|
|
template class SymbolTableListTraits<BasicBlock, Function, Function>;
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2002-04-09 19:39:35 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Argument Implementation
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2005-04-21 23:48:37 +00:00
|
|
|
Argument::Argument(const Type *Ty, const std::string &Name, Function *Par)
|
2002-09-06 21:33:15 +00:00
|
|
|
: Value(Ty, Value::ArgumentVal, Name) {
|
|
|
|
Parent = 0;
|
2002-09-08 18:59:35 +00:00
|
|
|
|
|
|
|
// Make sure that we get added to a function
|
|
|
|
LeakDetector::addGarbageObject(this);
|
|
|
|
|
2002-09-06 21:33:15 +00:00
|
|
|
if (Par)
|
|
|
|
Par->getArgumentList().push_back(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Argument::setParent(Function *parent) {
|
2002-09-08 18:59:35 +00:00
|
|
|
if (getParent())
|
|
|
|
LeakDetector::addGarbageObject(this);
|
2002-09-06 21:33:15 +00:00
|
|
|
Parent = parent;
|
2002-09-08 18:59:35 +00:00
|
|
|
if (getParent())
|
|
|
|
LeakDetector::removeGarbageObject(this);
|
2002-09-06 21:33:15 +00:00
|
|
|
}
|
|
|
|
|
2001-09-10 07:58:01 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-03-26 18:01:55 +00:00
|
|
|
// Function Implementation
|
2001-09-10 07:58:01 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2003-04-16 20:28:45 +00:00
|
|
|
Function::Function(const FunctionType *Ty, LinkageTypes Linkage,
|
2002-09-06 20:46:32 +00:00
|
|
|
const std::string &name, Module *ParentModule)
|
2005-01-29 00:35:33 +00:00
|
|
|
: GlobalValue(PointerType::get(Ty), Value::FunctionVal, 0, 0, Linkage, name) {
|
2005-05-06 20:26:43 +00:00
|
|
|
CallingConvention = 0;
|
2002-06-25 16:13:24 +00:00
|
|
|
BasicBlocks.setItemParent(this);
|
|
|
|
BasicBlocks.setParent(this);
|
|
|
|
ArgumentList.setItemParent(this);
|
|
|
|
ArgumentList.setParent(this);
|
2002-11-20 18:07:48 +00:00
|
|
|
SymTab = new SymbolTable();
|
2002-09-06 20:46:32 +00:00
|
|
|
|
2003-11-21 22:32:23 +00:00
|
|
|
assert((getReturnType()->isFirstClassType() ||getReturnType() == Type::VoidTy)
|
|
|
|
&& "LLVM functions cannot return aggregate values!");
|
|
|
|
|
2002-10-13 20:57:00 +00:00
|
|
|
// Create the arguments vector, all arguments start out unnamed.
|
|
|
|
for (unsigned i = 0, e = Ty->getNumParams(); i != e; ++i) {
|
|
|
|
assert(Ty->getParamType(i) != Type::VoidTy &&
|
|
|
|
"Cannot have void typed arguments!");
|
|
|
|
ArgumentList.push_back(new Argument(Ty->getParamType(i)));
|
|
|
|
}
|
|
|
|
|
2002-09-08 18:59:35 +00:00
|
|
|
// Make sure that we get added to a function
|
|
|
|
LeakDetector::addGarbageObject(this);
|
|
|
|
|
2002-09-06 20:46:32 +00:00
|
|
|
if (ParentModule)
|
|
|
|
ParentModule->getFunctionList().push_back(this);
|
2001-06-06 20:29:01 +00:00
|
|
|
}
|
|
|
|
|
2002-03-23 22:51:58 +00:00
|
|
|
Function::~Function() {
|
2001-06-06 20:29:01 +00:00
|
|
|
dropAllReferences(); // After this it is safe to delete instructions.
|
|
|
|
|
|
|
|
// Delete all of the method arguments and unlink from symbol table...
|
2002-06-25 16:13:24 +00:00
|
|
|
ArgumentList.clear();
|
2001-06-06 20:29:01 +00:00
|
|
|
ArgumentList.setParent(0);
|
2002-04-28 04:51:51 +00:00
|
|
|
delete SymTab;
|
2001-06-06 20:29:01 +00:00
|
|
|
}
|
|
|
|
|
2002-03-23 22:51:58 +00:00
|
|
|
void Function::setParent(Module *parent) {
|
2002-09-08 18:59:35 +00:00
|
|
|
if (getParent())
|
|
|
|
LeakDetector::addGarbageObject(this);
|
2001-06-06 20:29:01 +00:00
|
|
|
Parent = parent;
|
2002-09-08 18:59:35 +00:00
|
|
|
if (getParent())
|
|
|
|
LeakDetector::removeGarbageObject(this);
|
2001-06-06 20:29:01 +00:00
|
|
|
}
|
|
|
|
|
2002-03-29 03:44:36 +00:00
|
|
|
const FunctionType *Function::getFunctionType() const {
|
|
|
|
return cast<FunctionType>(getType()->getElementType());
|
2001-10-03 14:53:21 +00:00
|
|
|
}
|
|
|
|
|
2005-01-07 07:40:32 +00:00
|
|
|
bool Function::isVarArg() const {
|
|
|
|
return getFunctionType()->isVarArg();
|
|
|
|
}
|
|
|
|
|
2005-04-21 23:48:37 +00:00
|
|
|
const Type *Function::getReturnType() const {
|
2002-03-29 03:44:36 +00:00
|
|
|
return getFunctionType()->getReturnType();
|
2001-06-06 20:29:01 +00:00
|
|
|
}
|
|
|
|
|
2004-10-11 22:21:39 +00:00
|
|
|
void Function::removeFromParent() {
|
|
|
|
getParent()->getFunctionList().remove(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Function::eraseFromParent() {
|
|
|
|
getParent()->getFunctionList().erase(this);
|
|
|
|
}
|
|
|
|
|
2004-12-05 06:43:27 +00:00
|
|
|
|
|
|
|
/// renameLocalSymbols - This method goes through the Function's symbol table
|
|
|
|
/// and renames any symbols that conflict with symbols at global scope. This is
|
|
|
|
/// required before printing out to a textual form, to ensure that there is no
|
|
|
|
/// ambiguity when parsing.
|
|
|
|
void Function::renameLocalSymbols() {
|
|
|
|
SymbolTable &LST = getSymbolTable(); // Local Symtab
|
|
|
|
SymbolTable &GST = getParent()->getSymbolTable(); // Global Symtab
|
|
|
|
|
|
|
|
for (SymbolTable::plane_iterator LPI = LST.plane_begin(), E = LST.plane_end();
|
|
|
|
LPI != E; ++LPI)
|
|
|
|
// All global symbols are of pointer type, ignore any non-pointer planes.
|
2005-03-05 19:01:49 +00:00
|
|
|
if (const PointerType *CurTy = dyn_cast<PointerType>(LPI->first)) {
|
2004-12-05 06:43:27 +00:00
|
|
|
// Only check if the global plane has any symbols of this type.
|
|
|
|
SymbolTable::plane_iterator GPI = GST.find(LPI->first);
|
|
|
|
if (GPI != GST.plane_end()) {
|
|
|
|
SymbolTable::ValueMap &LVM = LPI->second;
|
|
|
|
const SymbolTable::ValueMap &GVM = GPI->second;
|
|
|
|
|
|
|
|
// Loop over all local symbols, renaming those that are in the global
|
|
|
|
// symbol table already.
|
|
|
|
for (SymbolTable::value_iterator VI = LVM.begin(), E = LVM.end();
|
|
|
|
VI != E;) {
|
|
|
|
Value *V = VI->second;
|
|
|
|
const std::string &Name = VI->first;
|
|
|
|
++VI;
|
|
|
|
if (GVM.count(Name)) {
|
|
|
|
static unsigned UniqueNum = 0;
|
|
|
|
// Find a name that does not conflict!
|
|
|
|
while (GVM.count(Name + "_" + utostr(++UniqueNum)) ||
|
|
|
|
LVM.count(Name + "_" + utostr(UniqueNum)))
|
|
|
|
/* scan for UniqueNum that works */;
|
|
|
|
V->setName(Name + "_" + utostr(UniqueNum));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-06 20:29:01 +00: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 17:54:14 +00:00
|
|
|
// zero. Then everything is deleted for real. Note that no operations are
|
2005-04-21 23:48:37 +00:00
|
|
|
// valid on an object that has "dropped all references", except operator
|
2001-06-06 20:29:01 +00:00
|
|
|
// delete.
|
|
|
|
//
|
2002-03-23 22:51:58 +00:00
|
|
|
void Function::dropAllReferences() {
|
2002-06-25 16:13:24 +00:00
|
|
|
for (iterator I = begin(), E = end(); I != E; ++I)
|
|
|
|
I->dropAllReferences();
|
2003-09-17 04:58:59 +00:00
|
|
|
BasicBlocks.clear(); // Delete all basic blocks...
|
2001-06-06 20:29:01 +00:00
|
|
|
}
|
2001-09-10 07:58:01 +00:00
|
|
|
|
2003-05-08 03:47:33 +00:00
|
|
|
/// getIntrinsicID - This method returns the ID number of the specified
|
2003-11-11 22:41:34 +00:00
|
|
|
/// function, or Intrinsic::not_intrinsic if the function is not an
|
2003-10-10 17:54:14 +00:00
|
|
|
/// intrinsic, or if the pointer is null. This value is always defined to be
|
2003-05-08 03:47:33 +00: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.
|
|
|
|
///
|
|
|
|
unsigned Function::getIntrinsicID() const {
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25366 91177308-0d34-0410-b5e6-96231b3b80d8
2006-01-16 21:12:35 +00:00
|
|
|
const std::string& Name = this->getName();
|
|
|
|
if (Name.size() < 5 || Name[4] != '.' || Name[0] != 'l' || Name[1] != 'l'
|
|
|
|
|| Name[2] != 'v' || Name[3] != 'm')
|
2003-05-08 03:47:33 +00:00
|
|
|
return 0; // All intrinsics start with 'llvm.'
|
2003-09-19 19:31:41 +00:00
|
|
|
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25366 91177308-0d34-0410-b5e6-96231b3b80d8
2006-01-16 21:12:35 +00:00
|
|
|
assert(Name.size() != 5 && "'llvm.' is an invalid intrinsic name!");
|
2005-04-21 23:48:37 +00:00
|
|
|
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25366 91177308-0d34-0410-b5e6-96231b3b80d8
2006-01-16 21:12:35 +00:00
|
|
|
switch (Name[5]) {
|
2006-01-14 01:25:24 +00:00
|
|
|
case 'b':
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25366 91177308-0d34-0410-b5e6-96231b3b80d8
2006-01-16 21:12:35 +00:00
|
|
|
if (Name == "llvm.bswap.i16") return Intrinsic::bswap_i16;
|
|
|
|
if (Name == "llvm.bswap.i32") return Intrinsic::bswap_i32;
|
|
|
|
if (Name == "llvm.bswap.i64") return Intrinsic::bswap_i64;
|
2006-01-14 01:25:24 +00:00
|
|
|
break;
|
2005-05-03 17:19:30 +00:00
|
|
|
case 'c':
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25366 91177308-0d34-0410-b5e6-96231b3b80d8
2006-01-16 21:12:35 +00:00
|
|
|
if (Name == "llvm.ctpop.i8") return Intrinsic::ctpop_i8;
|
|
|
|
if (Name == "llvm.ctpop.i16") return Intrinsic::ctpop_i16;
|
|
|
|
if (Name == "llvm.ctpop.i32") return Intrinsic::ctpop_i32;
|
|
|
|
if (Name == "llvm.ctpop.i64") return Intrinsic::ctpop_i64;
|
|
|
|
if (Name == "llvm.cttz.i8") return Intrinsic::cttz_i8;
|
|
|
|
if (Name == "llvm.cttz.i16") return Intrinsic::cttz_i16;
|
|
|
|
if (Name == "llvm.cttz.i32") return Intrinsic::cttz_i32;
|
|
|
|
if (Name == "llvm.cttz.i64") return Intrinsic::cttz_i64;
|
|
|
|
if (Name == "llvm.ctlz.i8") return Intrinsic::ctlz_i8;
|
|
|
|
if (Name == "llvm.ctlz.i16") return Intrinsic::ctlz_i16;
|
|
|
|
if (Name == "llvm.ctlz.i32") return Intrinsic::ctlz_i32;
|
|
|
|
if (Name == "llvm.ctlz.i64") return Intrinsic::ctlz_i64;
|
2005-05-03 17:19:30 +00:00
|
|
|
break;
|
2004-01-05 05:36:30 +00:00
|
|
|
case 'd':
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25366 91177308-0d34-0410-b5e6-96231b3b80d8
2006-01-16 21:12:35 +00:00
|
|
|
if (Name == "llvm.dbg.stoppoint") return Intrinsic::dbg_stoppoint;
|
|
|
|
if (Name == "llvm.dbg.region.start")return Intrinsic::dbg_region_start;
|
|
|
|
if (Name == "llvm.dbg.region.end") return Intrinsic::dbg_region_end;
|
|
|
|
if (Name == "llvm.dbg.func.start") return Intrinsic::dbg_func_start;
|
2004-01-05 05:36:30 +00:00
|
|
|
break;
|
2004-02-14 02:47:17 +00:00
|
|
|
case 'f':
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25366 91177308-0d34-0410-b5e6-96231b3b80d8
2006-01-16 21:12:35 +00:00
|
|
|
if (Name == "llvm.frameaddress") return Intrinsic::frameaddress;
|
2004-02-14 02:47:17 +00:00
|
|
|
break;
|
2004-05-23 21:16:51 +00:00
|
|
|
case 'g':
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25366 91177308-0d34-0410-b5e6-96231b3b80d8
2006-01-16 21:12:35 +00:00
|
|
|
if (Name == "llvm.gcwrite") return Intrinsic::gcwrite;
|
|
|
|
if (Name == "llvm.gcread") return Intrinsic::gcread;
|
|
|
|
if (Name == "llvm.gcroot") return Intrinsic::gcroot;
|
2004-05-23 21:16:51 +00:00
|
|
|
break;
|
2004-06-11 01:08:18 +00:00
|
|
|
case 'i':
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25366 91177308-0d34-0410-b5e6-96231b3b80d8
2006-01-16 21:12:35 +00:00
|
|
|
if (Name == "llvm.isunordered.f32")
|
|
|
|
return Intrinsic::isunordered_f32;
|
|
|
|
if (Name == "llvm.isunordered.f64")
|
|
|
|
return Intrinsic::isunordered_f64;
|
2004-06-11 01:08:18 +00:00
|
|
|
break;
|
2003-05-17 22:26:33 +00:00
|
|
|
case '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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25366 91177308-0d34-0410-b5e6-96231b3b80d8
2006-01-16 21:12:35 +00:00
|
|
|
if (Name == "llvm.longjmp") return Intrinsic::longjmp;
|
2003-05-17 22:26:33 +00:00
|
|
|
break;
|
2004-02-12 17:01:09 +00:00
|
|
|
case 'm':
|
2006-03-02 23:58:40 +00:00
|
|
|
if (Name == "llvm.memcpy.i32") return Intrinsic::memcpy_i32;
|
|
|
|
if (Name == "llvm.memcpy.i64") return Intrinsic::memcpy_i64;
|
|
|
|
if (Name == "llvm.memmove.i32") return Intrinsic::memmove_i32;
|
|
|
|
if (Name == "llvm.memmove.i64") return Intrinsic::memmove_i64;
|
|
|
|
if (Name == "llvm.memset.i32") return Intrinsic::memset_i32;
|
|
|
|
if (Name == "llvm.memset.i64") return Intrinsic::memset_i64;
|
2004-02-14 02:47:17 +00:00
|
|
|
break;
|
2005-02-28 19:28:00 +00:00
|
|
|
case 'p':
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25366 91177308-0d34-0410-b5e6-96231b3b80d8
2006-01-16 21:12:35 +00:00
|
|
|
if (Name == "llvm.prefetch") return Intrinsic::prefetch;
|
|
|
|
if (Name == "llvm.pcmarker") return Intrinsic::pcmarker;
|
2005-02-28 19:28:00 +00:00
|
|
|
break;
|
2004-02-14 02:47:17 +00:00
|
|
|
case 'r':
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25366 91177308-0d34-0410-b5e6-96231b3b80d8
2006-01-16 21:12:35 +00:00
|
|
|
if (Name == "llvm.returnaddress") return Intrinsic::returnaddress;
|
|
|
|
if (Name == "llvm.readcyclecounter") return Intrinsic::readcyclecounter;
|
2004-02-12 17:01:09 +00:00
|
|
|
break;
|
2003-05-17 22:26:33 +00:00
|
|
|
case 's':
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25366 91177308-0d34-0410-b5e6-96231b3b80d8
2006-01-16 21:12:35 +00:00
|
|
|
if (Name == "llvm.setjmp") return Intrinsic::setjmp;
|
|
|
|
if (Name == "llvm.sigsetjmp") return Intrinsic::sigsetjmp;
|
|
|
|
if (Name == "llvm.siglongjmp") return Intrinsic::siglongjmp;
|
|
|
|
if (Name == "llvm.stackrestore") return Intrinsic::stackrestore;
|
|
|
|
if (Name == "llvm.stacksave") return Intrinsic::stacksave;
|
|
|
|
if (Name == "llvm.sqrt.f32") return Intrinsic::sqrt_f32;
|
|
|
|
if (Name == "llvm.sqrt.f64") return Intrinsic::sqrt_f64;
|
2003-05-17 22:26:33 +00:00
|
|
|
break;
|
2003-05-08 03:47:33 +00:00
|
|
|
case 'v':
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25366 91177308-0d34-0410-b5e6-96231b3b80d8
2006-01-16 21:12:35 +00:00
|
|
|
if (Name == "llvm.va_copy") return Intrinsic::vacopy;
|
|
|
|
if (Name == "llvm.va_end") return Intrinsic::vaend;
|
|
|
|
if (Name == "llvm.va_start") return Intrinsic::vastart;
|
2006-01-15 08:40:16 +00:00
|
|
|
break;
|
2003-05-08 03:47:33 +00:00
|
|
|
}
|
|
|
|
// The "llvm." namespace is reserved!
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25366 91177308-0d34-0410-b5e6-96231b3b80d8
2006-01-16 21:12:35 +00:00
|
|
|
assert(!"Unknown LLVM intrinsic function!");
|
2003-05-08 03:47:33 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-10-12 04:32:37 +00:00
|
|
|
Value *IntrinsicInst::StripPointerCasts(Value *Ptr) {
|
2004-10-12 04:20:25 +00:00
|
|
|
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Ptr)) {
|
|
|
|
if (CE->getOpcode() == Instruction::Cast) {
|
|
|
|
if (isa<PointerType>(CE->getOperand(0)->getType()))
|
|
|
|
return StripPointerCasts(CE->getOperand(0));
|
|
|
|
} else if (CE->getOpcode() == Instruction::GetElementPtr) {
|
|
|
|
for (unsigned i = 1, e = CE->getNumOperands(); i != e; ++i)
|
|
|
|
if (!CE->getOperand(i)->isNullValue())
|
|
|
|
return Ptr;
|
|
|
|
return StripPointerCasts(CE->getOperand(0));
|
|
|
|
}
|
|
|
|
return Ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CastInst *CI = dyn_cast<CastInst>(Ptr)) {
|
|
|
|
if (isa<PointerType>(CI->getOperand(0)->getType()))
|
|
|
|
return StripPointerCasts(CI->getOperand(0));
|
|
|
|
} else if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(Ptr)) {
|
2004-10-12 04:32:37 +00:00
|
|
|
for (unsigned i = 1, e = GEP->getNumOperands(); i != e; ++i)
|
|
|
|
if (!isa<Constant>(GEP->getOperand(i)) ||
|
|
|
|
!cast<Constant>(GEP->getOperand(i))->isNullValue())
|
2004-10-12 04:20:25 +00:00
|
|
|
return Ptr;
|
2004-10-12 04:32:37 +00:00
|
|
|
return StripPointerCasts(GEP->getOperand(0));
|
2004-10-12 04:20:25 +00:00
|
|
|
}
|
|
|
|
return Ptr;
|
|
|
|
}
|
2003-05-08 03:47:33 +00:00
|
|
|
|
2004-07-17 23:50:19 +00:00
|
|
|
// vim: sw=2 ai
|