diff options
author | Reed Kotler <rkotler@mips.com> | 2013-08-20 20:53:09 +0000 |
---|---|---|
committer | Reed Kotler <rkotler@mips.com> | 2013-08-20 20:53:09 +0000 |
commit | 0323d4b169279414862174f38ae04add6b747a60 (patch) | |
tree | 80431ca0053db5c1b0e16dd9e203ce419aaa5dad /lib | |
parent | 93877b3cbcefc0f281b744b135d609d35c3f119c (diff) | |
download | external_llvm-0323d4b169279414862174f38ae04add6b747a60.zip external_llvm-0323d4b169279414862174f38ae04add6b747a60.tar.gz external_llvm-0323d4b169279414862174f38ae04add6b747a60.tar.bz2 |
Add an option which permits the user to specify using a bitmask, that various
functions be compiled as mips32, without having to add attributes. This
is useful in certain situations where you don't want to have to edit the
function attributes in the source. For now it's only an option used for
the compiler developers when debugging the mips16 port.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188826 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Target/Mips/MipsOs16.cpp | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/lib/Target/Mips/MipsOs16.cpp b/lib/Target/Mips/MipsOs16.cpp index 1919077..5f9b60c 100644 --- a/lib/Target/Mips/MipsOs16.cpp +++ b/lib/Target/Mips/MipsOs16.cpp @@ -14,9 +14,17 @@ #define DEBUG_TYPE "mips-os16" #include "MipsOs16.h" #include "llvm/IR/Module.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" + +static cl::opt<std::string> Mips32FunctionMask( + "mips32-function-mask", + cl::init(""), + cl::desc("Force function to be mips32"), + cl::Hidden); + namespace { // Figure out if we need float point based on the function signature. @@ -85,18 +93,32 @@ namespace llvm { bool MipsOs16::runOnModule(Module &M) { - DEBUG(errs() << "Run on Module MipsOs16\n"); + bool usingMask = Mips32FunctionMask.length() > 0; + DEBUG(dbgs() << "Run on Module MipsOs16 \n" << Mips32FunctionMask << "\n"); + if (usingMask) + DEBUG(dbgs() << "using mask \n" << Mips32FunctionMask << "\n"); + unsigned int functionIndex = 0; bool modified = false; for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) { if (F->isDeclaration()) continue; DEBUG(dbgs() << "Working on " << F->getName() << "\n"); - if (needsFP(*F)) { - DEBUG(dbgs() << " need to compile as nomips16 \n"); - F->addFnAttr("nomips16"); + if (usingMask) { + if ((functionIndex < Mips32FunctionMask.length()) && + (Mips32FunctionMask[functionIndex] == '1')) { + DEBUG(dbgs() << "mask forced mips32: " << F->getName() << "\n"); + F->addFnAttr("nomips16"); + } + functionIndex++; } else { - F->addFnAttr("mips16"); - DEBUG(dbgs() << " no need to compile as nomips16 \n"); + if (needsFP(*F)) { + DEBUG(dbgs() << "os16 forced mips32: " << F->getName() << "\n"); + F->addFnAttr("nomips16"); + } + else { + DEBUG(dbgs() << "os16 forced mips16: " << F->getName() << "\n"); + F->addFnAttr("mips16"); + } } } return modified; |