Skip to content

Commit 6312f51

Browse files
Vasileios KalintirisVasileios Kalintiris
Vasileios Kalintiris
authored and
Vasileios Kalintiris
committed
[mips] Remove trivial header for the MipsOs16 pass. NFC.
llvm-svn: 232258
1 parent 1cd6c66 commit 6312f51

File tree

4 files changed

+72
-93
lines changed

4 files changed

+72
-93
lines changed

llvm/lib/Target/Mips/Mips.h

+3
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@
2020

2121
namespace llvm {
2222
class MipsTargetMachine;
23+
class ModulePass;
2324
class FunctionPass;
2425

26+
ModulePass *createMipsOs16Pass(MipsTargetMachine &TM);
27+
2528
FunctionPass *createMipsOptimizePICCallPass(MipsTargetMachine &TM);
2629
FunctionPass *createMipsDelaySlotFillerPass(MipsTargetMachine &TM);
2730
FunctionPass *createMipsLongBranchPass(MipsTargetMachine &TM);

llvm/lib/Target/Mips/MipsOs16.cpp

+67-67
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
//
1212
//===----------------------------------------------------------------------===//
1313

14-
#include "MipsOs16.h"
1514
#include "llvm/IR/Instructions.h"
1615
#include "llvm/IR/Module.h"
1716
#include "llvm/Support/CommandLine.h"
1817
#include "llvm/Support/Debug.h"
19-
#include "llvm/Support/raw_ostream.h"
18+
#include "Mips.h"
19+
2020
using namespace llvm;
2121

2222
#define DEBUG_TYPE "mips-os16"
@@ -28,82 +28,84 @@ static cl::opt<std::string> Mips32FunctionMask(
2828
cl::Hidden);
2929

3030
namespace {
31+
class MipsOs16 : public ModulePass {
32+
public:
33+
static char ID;
34+
35+
MipsOs16() : ModulePass(ID) {}
36+
37+
const char *getPassName() const override {
38+
return "MIPS Os16 Optimization";
39+
}
40+
41+
bool runOnModule(Module &M) override;
42+
};
43+
44+
char MipsOs16::ID = 0;
45+
}
3146

32-
// Figure out if we need float point based on the function signature.
33-
// We need to move variables in and/or out of floating point
34-
// registers because of the ABI
35-
//
36-
bool needsFPFromSig(Function &F) {
37-
Type* RetType = F.getReturnType();
38-
switch (RetType->getTypeID()) {
47+
// Figure out if we need float point based on the function signature.
48+
// We need to move variables in and/or out of floating point
49+
// registers because of the ABI
50+
//
51+
static bool needsFPFromSig(Function &F) {
52+
Type* RetType = F.getReturnType();
53+
switch (RetType->getTypeID()) {
54+
case Type::FloatTyID:
55+
case Type::DoubleTyID:
56+
return true;
57+
default:
58+
;
59+
}
60+
if (F.arg_size() >=1) {
61+
Argument &Arg = F.getArgumentList().front();
62+
switch (Arg.getType()->getTypeID()) {
3963
case Type::FloatTyID:
4064
case Type::DoubleTyID:
4165
return true;
4266
default:
4367
;
4468
}
45-
if (F.arg_size() >=1) {
46-
Argument &Arg = F.getArgumentList().front();
47-
switch (Arg.getType()->getTypeID()) {
48-
case Type::FloatTyID:
49-
case Type::DoubleTyID:
50-
return true;
51-
default:
52-
;
53-
}
54-
}
55-
return false;
5669
}
70+
return false;
71+
}
5772

58-
// Figure out if the function will need floating point operations
59-
//
60-
bool needsFP(Function &F) {
61-
if (needsFPFromSig(F))
62-
return true;
63-
for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
64-
for (BasicBlock::const_iterator I = BB->begin(), E = BB->end();
73+
// Figure out if the function will need floating point operations
74+
//
75+
static bool needsFP(Function &F) {
76+
if (needsFPFromSig(F))
77+
return true;
78+
for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
79+
for (BasicBlock::const_iterator I = BB->begin(), E = BB->end();
6580
I != E; ++I) {
66-
const Instruction &Inst = *I;
67-
switch (Inst.getOpcode()) {
68-
case Instruction::FAdd:
69-
case Instruction::FSub:
70-
case Instruction::FMul:
71-
case Instruction::FDiv:
72-
case Instruction::FRem:
73-
case Instruction::FPToUI:
74-
case Instruction::FPToSI:
75-
case Instruction::UIToFP:
76-
case Instruction::SIToFP:
77-
case Instruction::FPTrunc:
78-
case Instruction::FPExt:
79-
case Instruction::FCmp:
81+
const Instruction &Inst = *I;
82+
switch (Inst.getOpcode()) {
83+
case Instruction::FAdd:
84+
case Instruction::FSub:
85+
case Instruction::FMul:
86+
case Instruction::FDiv:
87+
case Instruction::FRem:
88+
case Instruction::FPToUI:
89+
case Instruction::FPToSI:
90+
case Instruction::UIToFP:
91+
case Instruction::SIToFP:
92+
case Instruction::FPTrunc:
93+
case Instruction::FPExt:
94+
case Instruction::FCmp:
95+
return true;
96+
default:
97+
;
98+
}
99+
if (const CallInst *CI = dyn_cast<CallInst>(I)) {
100+
DEBUG(dbgs() << "Working on call" << "\n");
101+
Function &F_ = *CI->getCalledFunction();
102+
if (needsFPFromSig(F_))
80103
return true;
81-
default:
82-
;
83-
}
84-
if (const CallInst *CI = dyn_cast<CallInst>(I)) {
85-
DEBUG(dbgs() << "Working on call" << "\n");
86-
Function &F_ = *CI->getCalledFunction();
87-
if (needsFPFromSig(F_))
88-
return true;
89-
}
90104
}
91-
return false;
92-
}
105+
}
106+
return false;
93107
}
94108

95-
namespace {
96-
97-
class MipsOs16 : public ModulePass {
98-
public:
99-
static char ID;
100-
101-
MipsOs16() : ModulePass(ID) {}
102-
103-
const char *getPassName() const override { return "MIPS Os16 Optimization"; }
104-
bool runOnModule(Module &M) override;
105-
};
106-
} // namespace
107109

108110
bool MipsOs16::runOnModule(Module &M) {
109111
bool usingMask = Mips32FunctionMask.length() > 0;
@@ -148,8 +150,6 @@ bool MipsOs16::runOnModule(Module &M) {
148150
return modified;
149151
}
150152

151-
char MipsOs16::ID = 0;
152-
153-
ModulePass *llvm::createMipsOs16(MipsTargetMachine &TM) {
153+
ModulePass *llvm::createMipsOs16Pass(MipsTargetMachine &TM) {
154154
return new MipsOs16;
155155
}

llvm/lib/Target/Mips/MipsOs16.h

-24
This file was deleted.

llvm/lib/Target/Mips/MipsTargetMachine.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "MipsFrameLowering.h"
2222
#include "MipsInstrInfo.h"
2323
#include "MipsModuleISelDAGToDAG.h"
24-
#include "MipsOs16.h"
2524
#include "MipsSEFrameLowering.h"
2625
#include "MipsSEISelDAGToDAG.h"
2726
#include "MipsSEISelLowering.h"
@@ -34,6 +33,7 @@
3433
#include "llvm/Support/TargetRegistry.h"
3534
#include "llvm/Support/raw_ostream.h"
3635
#include "llvm/Transforms/Scalar.h"
36+
3737
using namespace llvm;
3838

3939
#define DEBUG_TYPE "mips"
@@ -213,7 +213,7 @@ void MipsPassConfig::addIRPasses() {
213213
TargetPassConfig::addIRPasses();
214214
addPass(createAtomicExpandPass(&getMipsTargetMachine()));
215215
if (getMipsSubtarget().os16())
216-
addPass(createMipsOs16(getMipsTargetMachine()));
216+
addPass(createMipsOs16Pass(getMipsTargetMachine()));
217217
if (getMipsSubtarget().inMips16HardFloat())
218218
addPass(createMips16HardFloat(getMipsTargetMachine()));
219219
}

0 commit comments

Comments
 (0)