Mercurial > projects > ldc
comparison gen/main.cpp @ 1544:8863cf7236e6
We need to parse mArch ourselves now
Build fix for LLVM r75890
author | Benjamin Kramer <benny.kra@gmail.com> |
---|---|
date | Fri, 17 Jul 2009 19:23:20 +0200 |
parents | 21d691518d82 |
children | f9660d9cf2ba |
comparison
equal
deleted
inserted
replaced
1543:21d691518d82 | 1544:8863cf7236e6 |
---|---|
10 #include "llvm/LLVMContext.h" | 10 #include "llvm/LLVMContext.h" |
11 #include "llvm/System/Signals.h" | 11 #include "llvm/System/Signals.h" |
12 #include "llvm/Target/SubtargetFeature.h" | 12 #include "llvm/Target/SubtargetFeature.h" |
13 #include "llvm/Target/TargetMachine.h" | 13 #include "llvm/Target/TargetMachine.h" |
14 #include "llvm/Target/TargetOptions.h" | 14 #include "llvm/Target/TargetOptions.h" |
15 #include "llvm/Target/TargetMachineRegistry.h" | 15 #include "llvm/Target/TargetRegistry.h" |
16 #include "llvm/Target/TargetSelect.h" | 16 #include "llvm/Target/TargetSelect.h" |
17 | 17 |
18 #include <stdio.h> | 18 #include <stdio.h> |
19 #include <stdlib.h> | 19 #include <stdlib.h> |
20 #include <assert.h> | 20 #include <assert.h> |
395 Ir ir; | 395 Ir ir; |
396 | 396 |
397 // check -m32/64 sanity | 397 // check -m32/64 sanity |
398 if (m32bits && m64bits) | 398 if (m32bits && m64bits) |
399 error("cannot use both -m32 and -m64 options"); | 399 error("cannot use both -m32 and -m64 options"); |
400 else if ((m32bits || m64bits) && (mArch != 0 || !mTargetTriple.empty())) | 400 else if ((m32bits || m64bits) && (!mArch.empty() || !mTargetTriple.empty())) |
401 error("-m32 and -m64 switches cannot be used together with -march and -mtriple switches"); | 401 error("-m32 and -m64 switches cannot be used together with -march and -mtriple switches"); |
402 if (global.errors) | 402 if (global.errors) |
403 fatal(); | 403 fatal(); |
404 | 404 |
405 llvm::LLVMContext context; | 405 llvm::LLVMContext context; |
413 } | 413 } |
414 | 414 |
415 // did the user override the target triple? | 415 // did the user override the target triple? |
416 if (mTargetTriple.empty()) | 416 if (mTargetTriple.empty()) |
417 { | 417 { |
418 if (mArch != 0) | 418 if (!mArch.empty()) |
419 { | 419 { |
420 error("you must specify a target triple as well with -mtriple when using the -march option"); | 420 error("you must specify a target triple as well with -mtriple when using the -march option"); |
421 fatal(); | 421 fatal(); |
422 } | 422 } |
423 global.params.targetTriple = defaultTriple; | 423 global.params.targetTriple = defaultTriple; |
435 #define LLVM_TARGET(A) LLVMInitialize##A##TargetInfo(); LLVMInitialize##A##Target(); LLVMInitialize##A##AsmPrinter(); | 435 #define LLVM_TARGET(A) LLVMInitialize##A##TargetInfo(); LLVMInitialize##A##Target(); LLVMInitialize##A##AsmPrinter(); |
436 // this is defined to be LLVM_TARGET(target name 1) LLVM_TARGET(target name 2) ... | 436 // this is defined to be LLVM_TARGET(target name 1) LLVM_TARGET(target name 2) ... |
437 LDC_TARGETS | 437 LDC_TARGETS |
438 #undef LLVM_TARGET | 438 #undef LLVM_TARGET |
439 | 439 |
440 const llvm::Target *theTarget; | 440 const llvm::Target *theTarget = NULL; |
441 // Check whether the user has explicitly specified an architecture to compile for. | 441 // Check whether the user has explicitly specified an architecture to compile for. |
442 if (mArch == 0) | 442 if (mArch.empty()) |
443 { | 443 { |
444 std::string Err; | 444 std::string Err; |
445 theTarget = llvm::TargetRegistry::getClosestStaticTargetForModule(mod, Err); | 445 theTarget = llvm::TargetRegistry::getClosestStaticTargetForModule(mod, Err); |
446 if (theTarget == 0) | 446 if (theTarget == 0) |
447 { | 447 { |
449 fatal(); | 449 fatal(); |
450 } | 450 } |
451 } | 451 } |
452 else | 452 else |
453 { | 453 { |
454 theTarget = &mArch->TheTarget; | 454 for (llvm::TargetRegistry::iterator it = llvm::TargetRegistry::begin(), |
455 ie = llvm::TargetRegistry::end(); it != ie; ++it) | |
456 { | |
457 if (mArch == it->getName()) | |
458 { | |
459 theTarget = &*it; | |
460 break; | |
461 } | |
462 } | |
463 | |
464 if (!theTarget) | |
465 { | |
466 error("invalid target '%s'", mArch.c_str()); | |
467 fatal(); | |
468 } | |
455 } | 469 } |
456 | 470 |
457 // Package up features to be passed to target/subtarget | 471 // Package up features to be passed to target/subtarget |
458 std::string FeaturesStr; | 472 std::string FeaturesStr; |
459 if (mCPU.size() || mAttrs.size()) | 473 if (mCPU.size() || mAttrs.size()) |