//===-- Writer.cpp - Library for converting LLVM code to C ----------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This library converts LLVM code to C code, compilable by GCC.
//
//===----------------------------------------------------------------------===//
#include "llvm/Assembly/CWriter.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
#include "llvm/Instructions.h"
#include "llvm/Pass.h"
#include "llvm/SymbolTable.h"
#include "llvm/Intrinsics.h"
#include "llvm/Analysis/FindUsedTypes.h"
#include "llvm/Analysis/ConstantsScanner.h"
#include "llvm/Support/InstVisitor.h"
#include "llvm/Support/InstIterator.h"
#include "llvm/Support/CallSite.h"
#include "llvm/Support/Mangler.h"
#include "Support/StringExtras.h"
#include "Support/STLExtras.h"
#include "Config/config.h"
#include <algorithm>
#include <sstream>
namespace {
class CWriter : public Pass, public InstVisitor<CWriter> {
std::ostream &Out;
Mangler *Mang;
const Module *TheModule;
FindUsedTypes *FUT;
std::map<const Type *, std::string> TypeNames;
std::set<const Value*> MangledGlobals;
bool needsMalloc, emittedInvoke;
std::map<const ConstantFP *, unsigned> FPConstantMap;
public:
CWriter(std::ostream &o) : Out(o) {}
void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
AU.addRequired<FindUsedTypes>();
}
virtual bool run(Module &M<