2001-10-15 17:31:51 +00:00
|
|
|
//===- llvm/Transforms/LowerAllocations.h - Remove Malloc & Free -*- C++ -*--=//
|
|
|
|
//
|
|
|
|
// This file defines the interface to a pass that lowers malloc and free
|
|
|
|
// instructions to calls to %malloc & %free functions. This transformation is
|
|
|
|
// a target dependant tranformation because we depend on the size of data types
|
|
|
|
// and alignment constraints.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_TRANSFORMS_LOWERALLOCATIONS_H
|
|
|
|
#define LLVM_TRANSFORMS_LOWERALLOCATIONS_H
|
|
|
|
|
2001-10-18 20:19:09 +00:00
|
|
|
#include "llvm/Pass.h"
|
2001-10-15 17:31:51 +00:00
|
|
|
class TargetData;
|
|
|
|
|
2001-10-18 05:22:15 +00:00
|
|
|
class LowerAllocations : public Pass {
|
2001-10-15 17:31:51 +00:00
|
|
|
Method *MallocMeth; // Methods in the module we are processing
|
|
|
|
Method *FreeMeth; // Initialized by doPassInitializationVirt
|
|
|
|
|
|
|
|
const TargetData &DataLayout;
|
|
|
|
public:
|
|
|
|
inline LowerAllocations(const TargetData &TD) : DataLayout(TD) {
|
|
|
|
MallocMeth = FreeMeth = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// doPassInitialization - For the lower allocations pass, this ensures that a
|
|
|
|
// module contains a declaration for a malloc and a free function.
|
|
|
|
//
|
|
|
|
// This function is always successful.
|
|
|
|
//
|
2001-10-18 05:22:15 +00:00
|
|
|
bool doPassInitialization(Module *M);
|
2001-10-15 17:31:51 +00:00
|
|
|
|
|
|
|
// doPerMethodWork - This method does the actual work of converting
|
|
|
|
// instructions over, assuming that the pass has already been initialized.
|
|
|
|
//
|
2001-10-18 05:22:15 +00:00
|
|
|
bool doPerMethodWork(Method *M);
|
2001-10-15 17:31:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|