[llvm] r188826 - Add an option which permits the user to specify using a bitmask, that various
Reed Kotler
rkotler at mips.com
Tue Aug 20 13:53:09 PDT 2013
Author: rkotler
Date: Tue Aug 20 15:53:09 2013
New Revision: 188826
URL: http://llvm.org/viewvc/llvm-project?rev=188826&view=rev
Log:
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.
Modified:
llvm/trunk/lib/Target/Mips/MipsOs16.cpp
llvm/trunk/test/CodeGen/Mips/fp16instrinsmc.ll
Modified: llvm/trunk/lib/Target/Mips/MipsOs16.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsOs16.cpp?rev=188826&r1=188825&r2=188826&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsOs16.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsOs16.cpp Tue Aug 20 15:53:09 2013
@@ -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;
Modified: llvm/trunk/test/CodeGen/Mips/fp16instrinsmc.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/fp16instrinsmc.ll?rev=188826&r1=188825&r2=188826&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/Mips/fp16instrinsmc.ll (original)
+++ llvm/trunk/test/CodeGen/Mips/fp16instrinsmc.ll Tue Aug 20 15:53:09 2013
@@ -1,4 +1,5 @@
; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mcpu=mips16 -soft-float -mips16-hard-float -relocation-model=pic < %s | FileCheck %s -check-prefix=pic
+; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mcpu=mips16 -soft-float -mips16-hard-float -relocation-model=static -mips32-function-mask=1010111 -mips-os16 < %s | FileCheck %s -check-prefix=fmask
@x = global float 1.500000e+00, align 4
@xn = global float -1.900000e+01, align 4
@@ -13,6 +14,14 @@
; Function Attrs: nounwind
define void @foo1() #0 {
+; fmask: .ent foo1
+; fmask: .set noreorder
+; fmask: .set nomacro
+; fmask: .set noat
+; fmask: .set at
+; fmask: .set macro
+; fmask: .set reorder
+; fmask: .end foo1
entry:
%0 = load float* @x, align 4
%1 = load float* @one, align 4
@@ -26,6 +35,9 @@ declare float @copysignf(float, float) #
; Function Attrs: nounwind
define void @foo2() #0 {
+; fmask: .ent foo2
+; fmask: save {{.*}}
+; fmask: .end foo2
entry:
%0 = load float* @x, align 4
%1 = load float* @negone, align 4
@@ -37,6 +49,14 @@ entry:
; Function Attrs: nounwind
define void @foo3() #0 {
entry:
+; fmask: .ent foo3
+; fmask: .set noreorder
+; fmask: .set nomacro
+; fmask: .set noat
+; fmask: .set at
+; fmask: .set macro
+; fmask: .set reorder
+; fmask: .end foo3
%0 = load double* @xd, align 8
%1 = load float* @oned, align 4
%conv = fpext float %1 to double
@@ -51,6 +71,9 @@ declare double @copysign(double, double)
; Function Attrs: nounwind
define void @foo4() #0 {
entry:
+; fmask: .ent foo4
+; fmask: save {{.*}}
+; fmask: .end foo4
%0 = load double* @xd, align 8
%1 = load double* @negoned, align 8
%call = call double @copysign(double %0, double %1) #2
More information about the llvm-commits
mailing list