05fb13341008522b49dff925dd007d4ebf11068c
[oota-llvm.git] / include / llvm / Transforms / ChangeAllocations.h
1 //===- llvm/Transforms/LowerAllocations.h - Remove Malloc & Free -*- C++ -*--=//
2 //
3 // This file defines the interface to a pass that lowers malloc and free
4 // instructions to calls to %malloc & %free functions.  This transformation is
5 // a target dependant tranformation because we depend on the size of data types
6 // and alignment constraints.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_TRANSFORMS_LOWERALLOCATIONS_H
11 #define LLVM_TRANSFORMS_LOWERALLOCATIONS_H
12
13 #include "llvm/Pass.h"
14 class TargetData;
15
16 class LowerAllocations : public MethodPass {
17   Method *MallocMeth;   // Methods in the module we are processing
18   Method *FreeMeth;     // Initialized by doPassInitializationVirt
19
20   const TargetData &DataLayout;
21 public:
22   inline LowerAllocations(const TargetData &TD) : DataLayout(TD) {
23     MallocMeth = FreeMeth = 0;
24   }
25
26   // doPassInitialization - For the lower allocations pass, this ensures that a
27   // module contains a declaration for a malloc and a free function.
28   //
29   // This function is always successful.
30   //
31   bool doInitialization(Module *M);
32
33   // doPerMethodWork - This method does the actual work of converting
34   // instructions over, assuming that the pass has already been initialized.
35   //
36   bool runOnMethod(Method *M);
37 };
38
39 #endif