blob: 459e8ed7a2303594fa5a86c16105a51b94375e03 [file] [log] [blame]
Duraid Madina91ed0a12005-03-17 18:17:03 +00001//===-- IA64TargetMachine.cpp - Define TargetMachine for IA64 -------------===//
Misha Brukman89b8c8d2005-04-21 23:13:11 +00002//
Duraid Madina91ed0a12005-03-17 18:17:03 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Misha Brukman89b8c8d2005-04-21 23:13:11 +00007//
Duraid Madina91ed0a12005-03-17 18:17:03 +00008//===----------------------------------------------------------------------===//
Misha Brukman89b8c8d2005-04-21 23:13:11 +00009//
Chris Lattner12e97302006-09-04 04:14:57 +000010// This file implements the IA64 specific subclass of TargetMachine.
Duraid Madina91ed0a12005-03-17 18:17:03 +000011//
12//===----------------------------------------------------------------------===//
13
Jim Laskeyae92ce82006-09-07 23:39:26 +000014#include "IA64TargetAsmInfo.h"
Duraid Madina91ed0a12005-03-17 18:17:03 +000015#include "IA64TargetMachine.h"
16#include "IA64.h"
17#include "llvm/Module.h"
18#include "llvm/PassManager.h"
Duraid Madina91ed0a12005-03-17 18:17:03 +000019#include "llvm/Target/TargetMachineRegistry.h"
Duraid Madina91ed0a12005-03-17 18:17:03 +000020using 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.
26extern "C" int IA64TargetMachineModule;
27int IA64TargetMachineModule = 0;
28
Chris Lattner122c9b12008-10-16 06:16:50 +000029static RegisterTarget<IA64TargetMachine> X("ia64",
30 "IA-64 (Itanium) [experimental]");
Duraid Madina91ed0a12005-03-17 18:17:03 +000031
Jim Laskeyae92ce82006-09-07 23:39:26 +000032const TargetAsmInfo *IA64TargetMachine::createTargetAsmInfo() const {
33 return new IA64TargetAsmInfo(*this);
34}
35
Duraid Madina91ed0a12005-03-17 18:17:03 +000036unsigned 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') &&
Misha Brukmane73e76d2005-04-22 17:54:37 +000043 (TT[1]=='a' || TT[1]=='A') ) {
Duraid Madina91ed0a12005-03-17 18:17:03 +000044 for(unsigned int i=2; i<(TT.size()-1); i++)
Misha Brukmane73e76d2005-04-22 17:54:37 +000045 if(TT[i]=='6' && TT[i+1]=='4')
46 seenIA64=true;
Duraid Madina91ed0a12005-03-17 18:17:03 +000047 }
48
Chris Lattner4042e872006-08-26 21:33:05 +000049 if (seenIA64)
50 return 20; // strong match
Duraid Madina91ed0a12005-03-17 18:17:03 +000051 }
Chris Lattner517290a2007-07-09 17:25:29 +000052 // If the target triple is something non-ia64, we don't match.
53 if (!TT.empty()) return 0;
Duraid Madina91ed0a12005-03-17 18:17:03 +000054
Chris Lattner4042e872006-08-26 21:33:05 +000055#if defined(__ia64__) || defined(__IA64__)
56 return 5;
57#else
58 return 0;
59#endif
Duraid Madina91ed0a12005-03-17 18:17:03 +000060}
61
62/// IA64TargetMachine ctor - Create an LP64 architecture model
63///
Chris Lattner6f95ab72006-03-23 05:43:16 +000064IA64TargetMachine::IA64TargetMachine(const Module &M, const std::string &FS)
Dale Johannesenc5283ec2007-08-03 20:20:50 +000065 : DataLayout("e-f80:128:128"),
Evan Cheng2dd2c652006-03-13 23:20:37 +000066 FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0),
67 TLInfo(*this) { // FIXME? check this stuff
Duraid Madina91ed0a12005-03-17 18:17:03 +000068}
69
Chris Lattnerf11f48b2005-06-25 02:48:37 +000070
Chris Lattner12e97302006-09-04 04:14:57 +000071//===----------------------------------------------------------------------===//
72// Pass Pipeline Configuration
73//===----------------------------------------------------------------------===//
Duraid Madina91ed0a12005-03-17 18:17:03 +000074
Dan Gohman24570832008-03-11 22:29:46 +000075bool IA64TargetMachine::addInstSelector(PassManagerBase &PM, bool Fast) {
Duraid Madinabcbcfac2006-01-19 14:13:11 +000076 PM.add(createIA64DAGToDAGInstructionSelector(*this));
Chris Lattner12e97302006-09-04 04:14:57 +000077 return false;
78}
Duraid Madina91ed0a12005-03-17 18:17:03 +000079
Dan Gohman24570832008-03-11 22:29:46 +000080bool IA64TargetMachine::addPreEmitPass(PassManagerBase &PM, bool Fast) {
Duraid Madina5ea06a92006-01-25 02:23:38 +000081 // Make sure everything is bundled happily
82 PM.add(createIA64BundlingPass(*this));
Chris Lattner12e97302006-09-04 04:14:57 +000083 return true;
84}
Dan Gohman24570832008-03-11 22:29:46 +000085bool IA64TargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
Owen Anderson93719642008-08-21 00:14:44 +000086 raw_ostream &Out) {
Chris Lattner12e97302006-09-04 04:14:57 +000087 PM.add(createIA64CodePrinterPass(Out, *this));
88 return false;
Duraid Madina91ed0a12005-03-17 18:17:03 +000089}
90