Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1 | //===-- IA64TargetMachine.cpp - Define TargetMachine for IA64 -------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 081ce94 | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the IA64 specific subclass of TargetMachine. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "IA64TargetAsmInfo.h" |
| 15 | #include "IA64TargetMachine.h" |
| 16 | #include "IA64.h" |
| 17 | #include "llvm/Module.h" |
| 18 | #include "llvm/PassManager.h" |
| 19 | #include "llvm/Target/TargetMachineRegistry.h" |
| 20 | using namespace llvm; |
| 21 | |
| 22 | /// IA64TargetMachineModule - Note that this is used on hosts that cannot link |
| 23 | /// in a library unless there are references into the library. In particular, |
| 24 | /// it seems that it is not possible to get things to work on Win32 without |
| 25 | /// this. Though it is unused, do not remove it. |
| 26 | extern "C" int IA64TargetMachineModule; |
| 27 | int IA64TargetMachineModule = 0; |
| 28 | |
Chris Lattner | 3f83d3f | 2008-10-16 06:16:50 +0000 | [diff] [blame] | 29 | static RegisterTarget<IA64TargetMachine> X("ia64", |
| 30 | "IA-64 (Itanium) [experimental]"); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 31 | |
| 32 | const TargetAsmInfo *IA64TargetMachine::createTargetAsmInfo() const { |
| 33 | return new IA64TargetAsmInfo(*this); |
| 34 | } |
| 35 | |
| 36 | unsigned IA64TargetMachine::getModuleMatchQuality(const Module &M) { |
| 37 | // we match [iI][aA]*64 |
| 38 | bool seenIA64=false; |
| 39 | std::string TT = M.getTargetTriple(); |
| 40 | |
| 41 | if (TT.size() >= 4) { |
| 42 | if( (TT[0]=='i' || TT[0]=='I') && |
| 43 | (TT[1]=='a' || TT[1]=='A') ) { |
| 44 | for(unsigned int i=2; i<(TT.size()-1); i++) |
| 45 | if(TT[i]=='6' && TT[i+1]=='4') |
| 46 | seenIA64=true; |
| 47 | } |
| 48 | |
| 49 | if (seenIA64) |
| 50 | return 20; // strong match |
| 51 | } |
| 52 | // If the target triple is something non-ia64, we don't match. |
| 53 | if (!TT.empty()) return 0; |
| 54 | |
| 55 | #if defined(__ia64__) || defined(__IA64__) |
| 56 | return 5; |
| 57 | #else |
| 58 | return 0; |
| 59 | #endif |
| 60 | } |
| 61 | |
| 62 | /// IA64TargetMachine ctor - Create an LP64 architecture model |
| 63 | /// |
| 64 | IA64TargetMachine::IA64TargetMachine(const Module &M, const std::string &FS) |
Dale Johannesen | 4c39f71 | 2007-08-03 20:20:50 +0000 | [diff] [blame] | 65 | : DataLayout("e-f80:128:128"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 66 | FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0), |
| 67 | TLInfo(*this) { // FIXME? check this stuff |
| 68 | } |
| 69 | |
| 70 | |
| 71 | //===----------------------------------------------------------------------===// |
| 72 | // Pass Pipeline Configuration |
| 73 | //===----------------------------------------------------------------------===// |
| 74 | |
Bill Wendling | 58ed5d2 | 2009-04-29 00:15:41 +0000 | [diff] [blame] | 75 | bool IA64TargetMachine::addInstSelector(PassManagerBase &PM, unsigned OptLEvel){ |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 76 | PM.add(createIA64DAGToDAGInstructionSelector(*this)); |
| 77 | return false; |
| 78 | } |
| 79 | |
Bill Wendling | 58ed5d2 | 2009-04-29 00:15:41 +0000 | [diff] [blame] | 80 | bool IA64TargetMachine::addPreEmitPass(PassManagerBase &PM, unsigned OptLevel) { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 81 | // Make sure everything is bundled happily |
| 82 | PM.add(createIA64BundlingPass(*this)); |
| 83 | return true; |
| 84 | } |
Bill Wendling | 58ed5d2 | 2009-04-29 00:15:41 +0000 | [diff] [blame] | 85 | bool IA64TargetMachine::addAssemblyEmitter(PassManagerBase &PM, |
| 86 | unsigned OptLevel, |
| 87 | bool Verbose, |
| 88 | raw_ostream &Out) { |
| 89 | PM.add(createIA64CodePrinterPass(Out, *this, OptLevel, Verbose)); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 90 | return false; |
| 91 | } |
| 92 | |