Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 1 | //===-- IA64TargetMachine.cpp - Define TargetMachine for IA64 -------------===// |
Misha Brukman | 4633f1c | 2005-04-21 23:13:11 +0000 | [diff] [blame] | 2 | // |
Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 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. |
Misha Brukman | 4633f1c | 2005-04-21 23:13:11 +0000 | [diff] [blame] | 7 | // |
Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
Misha Brukman | 4633f1c | 2005-04-21 23:13:11 +0000 | [diff] [blame] | 9 | // |
Chris Lattner | 1911fd4 | 2006-09-04 04:14:57 +0000 | [diff] [blame] | 10 | // This file implements the IA64 specific subclass of TargetMachine. |
Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Jim Laskey | fde1b3b | 2006-09-07 23:39:26 +0000 | [diff] [blame] | 14 | #include "IA64TargetAsmInfo.h" |
Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 15 | #include "IA64TargetMachine.h" |
| 16 | #include "IA64.h" |
| 17 | #include "llvm/Module.h" |
| 18 | #include "llvm/PassManager.h" |
Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 19 | #include "llvm/Target/TargetMachineRegistry.h" |
Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 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 | |
Dan Gohman | 844731a | 2008-05-13 00:00:25 +0000 | [diff] [blame] | 29 | static RegisterTarget<IA64TargetMachine> X("ia64", " IA-64 (Itanium)"); |
Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 30 | |
Jim Laskey | fde1b3b | 2006-09-07 23:39:26 +0000 | [diff] [blame] | 31 | const TargetAsmInfo *IA64TargetMachine::createTargetAsmInfo() const { |
| 32 | return new IA64TargetAsmInfo(*this); |
| 33 | } |
| 34 | |
Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 35 | unsigned IA64TargetMachine::getModuleMatchQuality(const Module &M) { |
| 36 | // we match [iI][aA]*64 |
| 37 | bool seenIA64=false; |
| 38 | std::string TT = M.getTargetTriple(); |
| 39 | |
| 40 | if (TT.size() >= 4) { |
| 41 | if( (TT[0]=='i' || TT[0]=='I') && |
Misha Brukman | 7847fca | 2005-04-22 17:54:37 +0000 | [diff] [blame] | 42 | (TT[1]=='a' || TT[1]=='A') ) { |
Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 43 | for(unsigned int i=2; i<(TT.size()-1); i++) |
Misha Brukman | 7847fca | 2005-04-22 17:54:37 +0000 | [diff] [blame] | 44 | if(TT[i]=='6' && TT[i+1]=='4') |
| 45 | seenIA64=true; |
Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 46 | } |
| 47 | |
Chris Lattner | 16c7fe5 | 2006-08-26 21:33:05 +0000 | [diff] [blame] | 48 | if (seenIA64) |
| 49 | return 20; // strong match |
Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 50 | } |
Chris Lattner | 87bdba6 | 2007-07-09 17:25:29 +0000 | [diff] [blame] | 51 | // If the target triple is something non-ia64, we don't match. |
| 52 | if (!TT.empty()) return 0; |
Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 53 | |
Chris Lattner | 16c7fe5 | 2006-08-26 21:33:05 +0000 | [diff] [blame] | 54 | #if defined(__ia64__) || defined(__IA64__) |
| 55 | return 5; |
| 56 | #else |
| 57 | return 0; |
| 58 | #endif |
Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | /// IA64TargetMachine ctor - Create an LP64 architecture model |
| 62 | /// |
Chris Lattner | bc641b9 | 2006-03-23 05:43:16 +0000 | [diff] [blame] | 63 | IA64TargetMachine::IA64TargetMachine(const Module &M, const std::string &FS) |
Dale Johannesen | 8c1e6a1 | 2007-08-03 20:20:50 +0000 | [diff] [blame] | 64 | : DataLayout("e-f80:128:128"), |
Evan Cheng | c4c6257 | 2006-03-13 23:20:37 +0000 | [diff] [blame] | 65 | FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0), |
| 66 | TLInfo(*this) { // FIXME? check this stuff |
Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 67 | } |
| 68 | |
Chris Lattner | 0431c96 | 2005-06-25 02:48:37 +0000 | [diff] [blame] | 69 | |
Chris Lattner | 1911fd4 | 2006-09-04 04:14:57 +0000 | [diff] [blame] | 70 | //===----------------------------------------------------------------------===// |
| 71 | // Pass Pipeline Configuration |
| 72 | //===----------------------------------------------------------------------===// |
Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 73 | |
Dan Gohman | bfae831 | 2008-03-11 22:29:46 +0000 | [diff] [blame] | 74 | bool IA64TargetMachine::addInstSelector(PassManagerBase &PM, bool Fast) { |
Duraid Madina | c5f2470 | 2006-01-19 14:13:11 +0000 | [diff] [blame] | 75 | PM.add(createIA64DAGToDAGInstructionSelector(*this)); |
Chris Lattner | 1911fd4 | 2006-09-04 04:14:57 +0000 | [diff] [blame] | 76 | return false; |
| 77 | } |
Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 78 | |
Dan Gohman | bfae831 | 2008-03-11 22:29:46 +0000 | [diff] [blame] | 79 | bool IA64TargetMachine::addPreEmitPass(PassManagerBase &PM, bool Fast) { |
Duraid Madina | badf0d9 | 2006-01-25 02:23:38 +0000 | [diff] [blame] | 80 | // Make sure everything is bundled happily |
| 81 | PM.add(createIA64BundlingPass(*this)); |
Chris Lattner | 1911fd4 | 2006-09-04 04:14:57 +0000 | [diff] [blame] | 82 | return true; |
| 83 | } |
Dan Gohman | bfae831 | 2008-03-11 22:29:46 +0000 | [diff] [blame] | 84 | bool IA64TargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast, |
Owen Anderson | cb37188 | 2008-08-21 00:14:44 +0000 | [diff] [blame^] | 85 | raw_ostream &Out) { |
Chris Lattner | 1911fd4 | 2006-09-04 04:14:57 +0000 | [diff] [blame] | 86 | PM.add(createIA64CodePrinterPass(Out, *this)); |
| 87 | return false; |
Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 88 | } |
| 89 | |