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 | // |
| 5 | // This file was developed by Duraid Madina and is distributed under the |
| 6 | // University of Illinois Open Source 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 | |
| 14 | #include "IA64TargetMachine.h" |
| 15 | #include "IA64.h" |
| 16 | #include "llvm/Module.h" |
| 17 | #include "llvm/PassManager.h" |
Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 18 | #include "llvm/Target/TargetMachineRegistry.h" |
Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 19 | using namespace llvm; |
| 20 | |
| 21 | /// IA64TargetMachineModule - Note that this is used on hosts that cannot link |
| 22 | /// in a library unless there are references into the library. In particular, |
| 23 | /// it seems that it is not possible to get things to work on Win32 without |
| 24 | /// this. Though it is unused, do not remove it. |
| 25 | extern "C" int IA64TargetMachineModule; |
| 26 | int IA64TargetMachineModule = 0; |
| 27 | |
| 28 | namespace { |
Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 29 | RegisterTarget<IA64TargetMachine> X("ia64", " IA-64 (Itanium)"); |
| 30 | } |
| 31 | |
Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 32 | unsigned IA64TargetMachine::getModuleMatchQuality(const Module &M) { |
| 33 | // we match [iI][aA]*64 |
| 34 | bool seenIA64=false; |
| 35 | std::string TT = M.getTargetTriple(); |
| 36 | |
| 37 | if (TT.size() >= 4) { |
| 38 | if( (TT[0]=='i' || TT[0]=='I') && |
Misha Brukman | 7847fca | 2005-04-22 17:54:37 +0000 | [diff] [blame] | 39 | (TT[1]=='a' || TT[1]=='A') ) { |
Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 40 | for(unsigned int i=2; i<(TT.size()-1); i++) |
Misha Brukman | 7847fca | 2005-04-22 17:54:37 +0000 | [diff] [blame] | 41 | if(TT[i]=='6' && TT[i+1]=='4') |
| 42 | seenIA64=true; |
Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 43 | } |
| 44 | |
Chris Lattner | 16c7fe5 | 2006-08-26 21:33:05 +0000 | [diff] [blame] | 45 | if (seenIA64) |
| 46 | return 20; // strong match |
Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 47 | } |
| 48 | |
Chris Lattner | 16c7fe5 | 2006-08-26 21:33:05 +0000 | [diff] [blame] | 49 | #if defined(__ia64__) || defined(__IA64__) |
| 50 | return 5; |
| 51 | #else |
| 52 | return 0; |
| 53 | #endif |
Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | /// IA64TargetMachine ctor - Create an LP64 architecture model |
| 57 | /// |
Chris Lattner | bc641b9 | 2006-03-23 05:43:16 +0000 | [diff] [blame] | 58 | IA64TargetMachine::IA64TargetMachine(const Module &M, const std::string &FS) |
Chris Lattner | c4fa386 | 2006-09-03 18:44:02 +0000 | [diff] [blame] | 59 | : DataLayout("e"), |
Evan Cheng | c4c6257 | 2006-03-13 23:20:37 +0000 | [diff] [blame] | 60 | FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0), |
| 61 | TLInfo(*this) { // FIXME? check this stuff |
Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 62 | } |
| 63 | |
Chris Lattner | 0431c96 | 2005-06-25 02:48:37 +0000 | [diff] [blame] | 64 | |
Chris Lattner | 1911fd4 | 2006-09-04 04:14:57 +0000 | [diff] [blame] | 65 | //===----------------------------------------------------------------------===// |
| 66 | // Pass Pipeline Configuration |
| 67 | //===----------------------------------------------------------------------===// |
Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 68 | |
Chris Lattner | 1911fd4 | 2006-09-04 04:14:57 +0000 | [diff] [blame] | 69 | bool IA64TargetMachine::addInstSelector(FunctionPassManager &PM, bool Fast) { |
Duraid Madina | c5f2470 | 2006-01-19 14:13:11 +0000 | [diff] [blame] | 70 | PM.add(createIA64DAGToDAGInstructionSelector(*this)); |
Chris Lattner | 1911fd4 | 2006-09-04 04:14:57 +0000 | [diff] [blame] | 71 | return false; |
| 72 | } |
Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 73 | |
Chris Lattner | 1911fd4 | 2006-09-04 04:14:57 +0000 | [diff] [blame] | 74 | bool IA64TargetMachine::addPreEmitPass(FunctionPassManager &PM, bool Fast) { |
Duraid Madina | badf0d9 | 2006-01-25 02:23:38 +0000 | [diff] [blame] | 75 | // Make sure everything is bundled happily |
| 76 | PM.add(createIA64BundlingPass(*this)); |
Chris Lattner | 1911fd4 | 2006-09-04 04:14:57 +0000 | [diff] [blame] | 77 | return true; |
| 78 | } |
| 79 | bool IA64TargetMachine::addAssemblyEmitter(FunctionPassManager &PM, bool Fast, |
| 80 | std::ostream &Out) { |
| 81 | PM.add(createIA64CodePrinterPass(Out, *this)); |
| 82 | return false; |
Duraid Madina | 9b9d45f | 2005-03-17 18:17:03 +0000 | [diff] [blame] | 83 | } |
| 84 | |