//
// The LLVM Compiler Infrastructure
//
-// This file was developed by Roman Samoilov and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
#ifndef MSILWRITER_H
#define MSILWRITER_H
+#include "llvm/CallingConv.h"
#include "llvm/Constants.h"
#include "llvm/Module.h"
#include "llvm/Instructions.h"
#include "llvm/IntrinsicInst.h"
#include "llvm/Pass.h"
#include "llvm/PassManager.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/Analysis/FindUsedTypes.h"
#include "llvm/Analysis/LoopInfo.h"
+#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetMachine.h"
-#include "llvm/Target/TargetMachineRegistry.h"
-#include "llvm/Support/Mangler.h"
-#include <algorithm>
-#include <ios>
-using namespace llvm;
-namespace {
+namespace llvm {
+ extern Target TheMSILTarget;
class MSILModule : public ModulePass {
Module *ModulePtr;
static char ID;
MSILModule(const std::set<const Type *>*& _UsedTypes,
const TargetData*& _TD)
- : ModulePass((intptr_t)&ID), UsedTypes(_UsedTypes), TD(_TD) {}
+ : ModulePass(&ID), UsedTypes(_UsedTypes), TD(_TD) {}
void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<FindUsedTypes>();
};
- class MSILWriter : public FunctionPass {
+ class MSILWriter : public FunctionPass {
struct StaticInitializer {
const Constant* constant;
uint64_t offset;
}
public:
- std::ostream &Out;
+ formatted_raw_ostream &Out;
Module* ModulePtr;
const TargetData* TD;
- Mangler* Mang;
LoopInfo *LInfo;
std::vector<StaticInitializer>* InitListPtr;
std::map<const GlobalVariable*,std::vector<StaticInitializer> >
StaticInitList;
const std::set<const Type *>* UsedTypes;
static char ID;
- MSILWriter(std::ostream &o) : FunctionPass((intptr_t)&ID), Out(o) {
+ DenseMap<const Value*, unsigned> AnonValueNumbers;
+ unsigned NextAnonValueNumber;
+
+ MSILWriter(formatted_raw_ostream &o) : FunctionPass(&ID), Out(o),
+ NextAnonValueNumber(0) {
UniqID = 0;
}
std::string getLabelName(const std::string& Name);
- std::string getConvModopt(unsigned CallingConvID);
+ std::string getConvModopt(CallingConv::ID CallingConvID);
std::string getArrayTypeName(Type::TypeID TyID, const Type* Ty);
void printIndirectSave(const Type* Ty);
void printCastInstruction(unsigned int Op, const Value* V,
- const Type* Ty);
+ const Type* Ty, const Type* SrcTy=0);
void printGepInstruction(const Value* V, gep_type_iterator I,
gep_type_iterator E);
const char* getLibraryName(const GlobalVariable* GV);
- const char* getLibraryForSymbol(const char* Name, bool isFunction,
- unsigned CallingConv);
+ const char* getLibraryForSymbol(const StringRef &Name, bool isFunction,
+ CallingConv::ID CallingConv);
void printExternals();
};
+
}
#endif