diff options
author | Mon P Wang <wangmp@apple.com> | 2008-07-30 04:36:53 +0000 |
---|---|---|
committer | Mon P Wang <wangmp@apple.com> | 2008-07-30 04:36:53 +0000 |
commit | 2c839d4b1ed5725db8f245f9a277366d67ee2a3c (patch) | |
tree | 475b74aed323d7f7298eee0dff0bd118608ab32f /llvm/lib/VMCore/AutoUpgrade.cpp | |
parent | 4736916aa6e347a57083d19c2371bcd151cca8b3 (diff) | |
download | bcm5719-llvm-2c839d4b1ed5725db8f245f9a277366d67ee2a3c.tar.gz bcm5719-llvm-2c839d4b1ed5725db8f245f9a277366d67ee2a3c.zip |
Added support for overloading intrinsics (atomics) based on pointers
to different address spaces. This alters the naming scheme for those
intrinsics, e.g., atomic.load.add.i32 => atomic.load.add.i32.p0i32
llvm-svn: 54195
Diffstat (limited to 'llvm/lib/VMCore/AutoUpgrade.cpp')
-rw-r--r-- | llvm/lib/VMCore/AutoUpgrade.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/llvm/lib/VMCore/AutoUpgrade.cpp b/llvm/lib/VMCore/AutoUpgrade.cpp index a48fbd2c902..221dc067131 100644 --- a/llvm/lib/VMCore/AutoUpgrade.cpp +++ b/llvm/lib/VMCore/AutoUpgrade.cpp @@ -40,24 +40,38 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) { switch (Name[5]) { default: break; case 'a': - // This upgrades the llvm.atomic.lcs, llvm.atomic.las, and llvm.atomic.lss - // to their new function name - if (Name.compare(5,8,"atomic.l",8) == 0) { + // This upgrades the llvm.atomic.lcs, llvm.atomic.las, llvm.atomic.lss, + // and atomics with default address spaces to their new names to their new + // function name (e.g. llvm.atomic.add.i32 => llvm.atomic.add.i32.p0i32) + if (Name.compare(5,7,"atomic.",7) == 0) { if (Name.compare(12,3,"lcs",3) == 0) { std::string::size_type delim = Name.find('.',12); - F->setName("llvm.atomic.cmp.swap"+Name.substr(delim)); + F->setName("llvm.atomic.cmp.swap" + Name.substr(delim) + + ".p0" + Name.substr(delim+1)); NewFn = F; return true; } else if (Name.compare(12,3,"las",3) == 0) { std::string::size_type delim = Name.find('.',12); - F->setName("llvm.atomic.load.add"+Name.substr(delim)); + F->setName("llvm.atomic.load.add"+Name.substr(delim) + + ".p0" + Name.substr(delim+1)); NewFn = F; return true; } else if (Name.compare(12,3,"lss",3) == 0) { std::string::size_type delim = Name.find('.',12); - F->setName("llvm.atomic.load.sub"+Name.substr(delim)); + F->setName("llvm.atomic.load.sub"+Name.substr(delim) + + ".p0" + Name.substr(delim+1)); + NewFn = F; + return true; + } + else if (Name.rfind(".p") == std::string::npos) { + // We don't have an address space qualifier so this has be upgraded + // to the new name. Copy the type name at the end of the intrinsic + // and add to it + std::string::size_type delim = Name.find_last_of('.'); + assert(delim != std::string::npos && "can not find type"); + F->setName(Name + ".p0" + Name.substr(delim+1)); NewFn = F; return true; } |