mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-07-22 07:05:22 +02:00
Add changes for LLVM 3.2
- The Attributes class was changed again - TargetData was renamed to DataLayout Compiles again with LLVm 3.0, 3.1 and trunk(3.2).
This commit is contained in:
@@ -2,7 +2,11 @@
|
||||
#include "gen/cl_helpers.h"
|
||||
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#if LDC_LLVM_VER >= 302
|
||||
#include "llvm/DataLayout.h"
|
||||
#else
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#endif
|
||||
|
||||
#include "gen/logger.h"
|
||||
|
||||
|
||||
@@ -238,7 +238,11 @@ int main(int argc, char** argv)
|
||||
|
||||
// Handle fixed-up arguments!
|
||||
cl::SetVersionPrinter(&printVersion);
|
||||
#if LDC_LLVM_VER >= 302
|
||||
cl::ParseCommandLineOptions(final_args.size(), const_cast<char**>(&final_args[0]), "LLVM-based D Compiler\n");
|
||||
#else
|
||||
cl::ParseCommandLineOptions(final_args.size(), const_cast<char**>(&final_args[0]), "LLVM-based D Compiler\n", true);
|
||||
#endif
|
||||
|
||||
// Print config file path if -v was passed
|
||||
if (global.params.verbose) {
|
||||
@@ -569,11 +573,15 @@ int main(int argc, char** argv)
|
||||
|
||||
gTargetMachine = target;
|
||||
|
||||
gTargetData = target->getTargetData();
|
||||
#if LDC_LLVM_VER >= 302
|
||||
gDataLayout = target->getDataLayout();
|
||||
#else
|
||||
gDataLayout = target->getTargetData();
|
||||
#endif
|
||||
|
||||
global.params.isLE = gTargetData->isLittleEndian();
|
||||
global.params.isLE = gDataLayout->isLittleEndian();
|
||||
// Starting with LLVM 3.1 we could also use global.params.targetTriple.isArch64Bit();
|
||||
global.params.is64bit = gTargetData->getPointerSizeInBits() == 64;
|
||||
global.params.is64bit = gDataLayout->getPointerSizeInBits() == 64;
|
||||
global.params.cpu = static_cast<ARCH>(global.params.targetTriple.getArch());
|
||||
global.params.os = static_cast<OS>(global.params.targetTriple.getOS());
|
||||
|
||||
|
||||
@@ -121,10 +121,17 @@ void emit_file(llvm::TargetMachine &Target, llvm::Module& m, llvm::raw_fd_ostrea
|
||||
// Build up all of the passes that we want to do to the module.
|
||||
FunctionPassManager Passes(&m);
|
||||
|
||||
#if LDC_LLVM_VER >= 302
|
||||
if (const DataLayout *DL = Target.getDataLayout())
|
||||
Passes.add(new DataLayout(*DL));
|
||||
else
|
||||
Passes.add(new DataLayout(&m));
|
||||
#else
|
||||
if (const TargetData *TD = Target.getTargetData())
|
||||
Passes.add(new TargetData(*TD));
|
||||
else
|
||||
Passes.add(new TargetData(&m));
|
||||
#endif
|
||||
|
||||
llvm::formatted_raw_ostream fout(out);
|
||||
if (Target.addPassesToEmitFile(Passes, fout, fileType, codeGenOptLevel()))
|
||||
|
||||
Reference in New Issue
Block a user