xref: /minix3/minix/llvm/passes/include/sectionify/SectionifyPass.h (revision b5e2faaaaf60a8b9a02f8d72f64caa56a87eb312)
1*b5e2faaaSDavid van Moolenbroek #ifndef SECTIONIFY_PASS_H
2*b5e2faaaSDavid van Moolenbroek 
3*b5e2faaaSDavid van Moolenbroek #define SECTIONIFY_PASS_H
4*b5e2faaaSDavid van Moolenbroek 
5*b5e2faaaSDavid van Moolenbroek #define DEBUG_TYPE "sectionify"
6*b5e2faaaSDavid van Moolenbroek #include <pass.h>
7*b5e2faaaSDavid van Moolenbroek 
8*b5e2faaaSDavid van Moolenbroek using namespace llvm;
9*b5e2faaaSDavid van Moolenbroek 
10*b5e2faaaSDavid van Moolenbroek namespace llvm {
11*b5e2faaaSDavid van Moolenbroek 
12*b5e2faaaSDavid van Moolenbroek class SectionifyPass : public ModulePass {
13*b5e2faaaSDavid van Moolenbroek 
14*b5e2faaaSDavid van Moolenbroek   public:
15*b5e2faaaSDavid van Moolenbroek       static char ID;
16*b5e2faaaSDavid van Moolenbroek 
17*b5e2faaaSDavid van Moolenbroek       SectionifyPass();
18*b5e2faaaSDavid van Moolenbroek 
19*b5e2faaaSDavid van Moolenbroek       virtual bool runOnModule(Module &M);
20*b5e2faaaSDavid van Moolenbroek 
21*b5e2faaaSDavid van Moolenbroek   private:
22*b5e2faaaSDavid van Moolenbroek       std::map<Regex*, std::string> functionRegexMap;
23*b5e2faaaSDavid van Moolenbroek       std::vector<Regex*> functionRegexList;
24*b5e2faaaSDavid van Moolenbroek       std::map<Regex*, std::string> dataRegexMap;
25*b5e2faaaSDavid van Moolenbroek       std::vector<Regex*> dataRegexList;
26*b5e2faaaSDavid van Moolenbroek       std::string moduleName;
27*b5e2faaaSDavid van Moolenbroek 
28*b5e2faaaSDavid van Moolenbroek       bool sectionifyFromRegex(GlobalValue *value, Regex *regex, std::string &section);
29*b5e2faaaSDavid van Moolenbroek       bool sectionify(GlobalValue *value, std::vector<Regex*> &regexList, std::map<Regex*, std::string> &regexMap);
30*b5e2faaaSDavid van Moolenbroek       void parseAndInitRegexMap(cl::list<std::string> &stringListOpt, std::vector<Regex*> &regexList, std::map<Regex*, std::string> &regexMap, std::string regexType);
31*b5e2faaaSDavid van Moolenbroek       bool initRegexMap(std::map<Regex*, std::string> &regexMap, std::vector<Regex*> &regexList, std::map<std::string, std::string> &stringMap, std::vector<std::string> &stringList, std::string regexType);
32*b5e2faaaSDavid van Moolenbroek       bool parseStringMapOpt(std::map<std::string, std::string> &map, std::vector<std::string> &keyList, std::vector<std::string> &stringList);
33*b5e2faaaSDavid van Moolenbroek };
34*b5e2faaaSDavid van Moolenbroek 
35*b5e2faaaSDavid van Moolenbroek }
36*b5e2faaaSDavid van Moolenbroek 
37*b5e2faaaSDavid van Moolenbroek #endif
38