|
32 | 32 | #include "llvm/Transforms/Scalar.h"
|
33 | 33 | #include "llvm/Target/TargetMachineRegistry.h"
|
34 | 34 | #include "llvm/Target/TargetAsmInfo.h"
|
| 35 | +#include "llvm/Target/TargetData.h" |
35 | 36 | #include "llvm/Support/CallSite.h"
|
36 | 37 | #include "llvm/Support/CFG.h"
|
37 | 38 | #include "llvm/Support/GetElementPtrTypeIterator.h"
|
@@ -70,16 +71,18 @@ namespace {
|
70 | 71 | /// module to a C translation unit.
|
71 | 72 | class CWriter : public FunctionPass, public InstVisitor<CWriter> {
|
72 | 73 | std::ostream &Out;
|
73 |
| - IntrinsicLowering IL; |
| 74 | + IntrinsicLowering *IL; |
74 | 75 | Mangler *Mang;
|
75 | 76 | LoopInfo *LI;
|
76 | 77 | const Module *TheModule;
|
77 | 78 | const TargetAsmInfo* TAsm;
|
| 79 | + const TargetData* TD; |
78 | 80 | std::map<const Type *, std::string> TypeNames;
|
79 | 81 |
|
80 | 82 | std::map<const ConstantFP *, unsigned> FPConstantMap;
|
81 | 83 | public:
|
82 |
| - CWriter(std::ostream &o) : Out(o), TAsm(0) {} |
| 84 | + CWriter(std::ostream &o) : Out(o), IL(0), Mang(0), LI(0), TheModule(0), |
| 85 | + TAsm(0), TD(0) {} |
83 | 86 |
|
84 | 87 | virtual const char *getPassName() const { return "C backend"; }
|
85 | 88 |
|
@@ -1416,7 +1419,9 @@ bool CWriter::doInitialization(Module &M) {
|
1416 | 1419 | // Initialize
|
1417 | 1420 | TheModule = &M;
|
1418 | 1421 |
|
1419 |
| - IL.AddPrototypes(M); |
| 1422 | + TD = new TargetData(&M); |
| 1423 | + IL = new IntrinsicLowering(*TD); |
| 1424 | + IL->AddPrototypes(M); |
1420 | 1425 |
|
1421 | 1426 | // Ensure that all structure types have names...
|
1422 | 1427 | Mang = new Mangler(M);
|
@@ -2348,7 +2353,7 @@ void CWriter::lowerIntrinsics(Function &F) {
|
2348 | 2353 | if (CI != &BB->front())
|
2349 | 2354 | Before = prior(BasicBlock::iterator(CI));
|
2350 | 2355 |
|
2351 |
| - IL.LowerIntrinsicCall(CI); |
| 2356 | + IL->LowerIntrinsicCall(CI); |
2352 | 2357 | if (Before) { // Move iterator to instruction after call
|
2353 | 2358 | I = Before; ++I;
|
2354 | 2359 | } else {
|
|
0 commit comments