LLVM: lib/Target/Mips/MipsOs16.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
20
21using namespace llvm;
22
23#define DEBUG_TYPE "mips-os16"
24
26 "mips32-function-mask",
28 cl::desc("Force function to be mips32"),
30
31namespace {
33 public:
34 static char ID;
35
37
38 StringRef getPassName() const override { return "MIPS Os16 Optimization"; }
39
40 bool runOnModule(Module &M) override;
41 };
42
43 char MipsOs16::ID = 0;
44}
45
46
47
48
49
51 Type* RetType = F.getReturnType();
55 return true;
56 default:
57 ;
58 }
59 if (F.arg_size() >=1) {
64 return true;
65 default:
66 ;
67 }
68 }
69 return false;
70}
71
72
73
76 return true;
82 case Instruction::FAdd:
83 case Instruction::FSub:
84 case Instruction::FMul:
85 case Instruction::FDiv:
86 case Instruction::FRem:
87 case Instruction::FPToUI:
88 case Instruction::FPToSI:
89 case Instruction::UIToFP:
90 case Instruction::SIToFP:
91 case Instruction::FPTrunc:
92 case Instruction::FPExt:
93 case Instruction::FCmp:
94 return true;
95 default:
96 ;
97 }
100 << "\n");
101 Function &F_ = *CI->getCalledFunction();
103 return true;
104 }
105 }
106 return false;
107}
108
109
110bool MipsOs16::runOnModule(Module &M) {
112 bool doneUsingMask = false;
113
116 if (usingMask)
118
119 unsigned int functionIndex = 0;
120 bool modified = false;
121
122 for (auto &F : M) {
123 if (F.isDeclaration())
124 continue;
125
126 LLVM_DEBUG(dbgs() << "Working on " << F.getName() << "\n");
127 if (usingMask) {
128 if (!doneUsingMask) {
130 functionIndex = 0;
132 case '1':
133 LLVM_DEBUG(dbgs() << "mask forced mips32: " << F.getName() << "\n");
134 F.addFnAttr("nomips16");
135 break;
136 case '.':
137 doneUsingMask = true;
138 break;
139 default:
140 break;
141 }
142 functionIndex++;
143 }
144 }
145 else {
147 LLVM_DEBUG(dbgs() << "os16 forced mips32: " << F.getName() << "\n");
148 F.addFnAttr("nomips16");
149 }
150 else {
151 LLVM_DEBUG(dbgs() << "os16 forced mips16: " << F.getName() << "\n");
152 F.addFnAttr("mips16");
153 }
154 }
155 }
156
157 return modified;
158}
159
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Module.h This file contains the declarations for the Module class.
Machine Check Debug Module
static cl::opt< std::string > Mips32FunctionMask("mips32-function-mask", cl::init(""), cl::desc("Force function to be mips32"), cl::Hidden)
static bool needsFPFromSig(Function &F)
Definition MipsOs16.cpp:50
static bool needsFP(Function &F)
Definition MipsOs16.cpp:74
This class represents an incoming formal argument to a Function.
InstListType::const_iterator const_iterator
This class represents a function call, abstracting a target machine's calling convention.
BasicBlockListType::const_iterator const_iterator
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
A Module instance is used to store all the information related to an LLVM module.
The instances of the Type class are immutable: once they are created, they are never changed.
@ FloatTyID
32-bit floating point type
@ DoubleTyID
64-bit floating point type
TypeID getTypeID() const
Return the type id for the type.
Type * getType() const
All values are typed, get the type of this value.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
ModulePass * createMipsOs16Pass()
Definition MipsOs16.cpp:160