David van Moolenbroek b5e2faaaaf Import sectionify pass from llvm-apps
Change-Id: I3e3ac102b4898ca22ed1d9c25ec309d77bbe32de
2015-09-17 13:57:29 +00:00

38 lines
1.2 KiB
C++

#ifndef SECTIONIFY_PASS_H
#define SECTIONIFY_PASS_H
#define DEBUG_TYPE "sectionify"
#include <pass.h>
using namespace llvm;
namespace llvm {
class SectionifyPass : public ModulePass {
public:
static char ID;
SectionifyPass();
virtual bool runOnModule(Module &M);
private:
std::map<Regex*, std::string> functionRegexMap;
std::vector<Regex*> functionRegexList;
std::map<Regex*, std::string> dataRegexMap;
std::vector<Regex*> dataRegexList;
std::string moduleName;
bool sectionifyFromRegex(GlobalValue *value, Regex *regex, std::string &section);
bool sectionify(GlobalValue *value, std::vector<Regex*> &regexList, std::map<Regex*, std::string> &regexMap);
void parseAndInitRegexMap(cl::list<std::string> &stringListOpt, std::vector<Regex*> &regexList, std::map<Regex*, std::string> &regexMap, std::string regexType);
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);
bool parseStringMapOpt(std::map<std::string, std::string> &map, std::vector<std::string> &keyList, std::vector<std::string> &stringList);
};
}
#endif