blob: c789a8649a2e696044bcf503694487831d7a4145 [file] [log] [blame]
Duraid Madina9b9d45f2005-03-17 18:17:03 +00001//===-- IA64TargetMachine.cpp - Define TargetMachine for IA64 -------------===//
Misha Brukman4633f1c2005-04-21 23:13:11 +00002//
Duraid Madina9b9d45f2005-03-17 18:17:03 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-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 Brukman4633f1c2005-04-21 23:13:11 +00007//
Duraid Madina9b9d45f2005-03-17 18:17:03 +00008//===----------------------------------------------------------------------===//
Misha Brukman4633f1c2005-04-21 23:13:11 +00009//
Chris Lattner1911fd42006-09-04 04:14:57 +000010// This file implements the IA64 specific subclass of TargetMachine.
Duraid Madina9b9d45f2005-03-17 18:17:03 +000011//
12//===----------------------------------------------------------------------===//
13
Jim Laskeyfde1b3b2006-09-07 23:39:26 +000014#include "IA64TargetAsmInfo.h"
Duraid Madina9b9d45f2005-03-17 18:17:03 +000015#include "IA64TargetMachine.h"
16#include "IA64.h"
17#include "llvm/Module.h"
18#include "llvm/PassManager.h"
Duraid Madina9b9d45f2005-03-17 18:17:03 +000019#include "llvm/Target/TargetMachineRegistry.h"
Duraid Madina9b9d45f2005-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
Dan Gohman844731a2008-05-13 00:00:25 +000029static RegisterTarget<IA64TargetMachine> X("ia64", " IA-64 (Itanium)");
Duraid Madina9b9d45f2005-03-17 18:17:03 +000030
Jim Laskeyfde1b3b2006-09-07 23:39:26 +000031const TargetAsmInfo *IA64TargetMachine::createTargetAsmInfo() const {
32 return new IA64TargetAsmInfo(*this);
33}
34
Duraid Madina9b9d45f2005-03-17 18:17:03 +000035unsigned 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 Brukman7847fca2005-04-22 17:54:37 +000042 (TT[1]=='a' || TT[1]=='A') ) {
Duraid Madina9b9d45f2005-03-17 18:17:03 +000043 for(unsigned int i=2; i<(TT.size()-1); i++)
Misha Brukman7847fca2005-04-22 17:54:37 +000044 if(TT[i]=='6' && TT[i+1]=='4')
45 seenIA64=true;
Duraid Madina9b9d45f2005-03-17 18:17:03 +000046 }
47
Chris Lattner16c7fe52006-08-26 21:33:05 +000048 if (seenIA64)
49 return 20; // strong match
Duraid Madina9b9d45f2005-03-17 18:17:03 +000050 }
Chris Lattner87bdba62007-07-09 17:25:29 +000051 // If the target triple is something non-ia64, we don't match.
52 if (!TT.empty()) return 0;
Duraid Madina9b9d45f2005-03-17 18:17:03 +000053
Chris Lattner16c7fe52006-08-26 21:33:05 +000054#if defined(__ia64__) || defined(__IA64__)
55 return 5;
56#else
57 return 0;
58#endif
Duraid Madina9b9d45f2005-03-17 18:17:03 +000059}
60
61/// IA64TargetMachine ctor - Create an LP64 architecture model
62///
Chris Lattnerbc641b92006-03-23 05:43:16 +000063IA64TargetMachine::IA64TargetMachine(const Module &M, const std::string &FS)
Dale Johannesen8c1e6a12007-08-03 20:20:50 +000064 : DataLayout("e-f80:128:128"),
Evan Chengc4c62572006-03-13 23:20:37 +000065 FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0),
66 TLInfo(*this) { // FIXME? check this stuff
Duraid Madina9b9d45f2005-03-17 18:17:03 +000067}
68
Chris Lattner0431c962005-06-25 02:48:37 +000069
Chris Lattner1911fd42006-09-04 04:14:57 +000070//===----------------------------------------------------------------------===//
71// Pass Pipeline Configuration
72//===----------------------------------------------------------------------===//
Duraid Madina9b9d45f2005-03-17 18:17:03 +000073
Dan Gohmanbfae8312008-03-11 22:29:46 +000074bool IA64TargetMachine::addInstSelector(PassManagerBase &PM, bool Fast) {
Duraid Madinac5f24702006-01-19 14:13:11 +000075 PM.add(createIA64DAGToDAGInstructionSelector(*this));
Chris Lattner1911fd42006-09-04 04:14:57 +000076 return false;
77}
Duraid Madina9b9d45f2005-03-17 18:17:03 +000078
Dan Gohmanbfae8312008-03-11 22:29:46 +000079bool IA64TargetMachine::addPreEmitPass(PassManagerBase &PM, bool Fast) {
Duraid Madinabadf0d92006-01-25 02:23:38 +000080 // Make sure everything is bundled happily
81 PM.add(createIA64BundlingPass(*this));
Chris Lattner1911fd42006-09-04 04:14:57 +000082 return true;
83}
Dan Gohmanbfae8312008-03-11 22:29:46 +000084bool IA64TargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
Owen Andersoncb371882008-08-21 00:14:44 +000085 raw_ostream &Out) {
Chris Lattner1911fd42006-09-04 04:14:57 +000086 PM.add(createIA64CodePrinterPass(Out, *this));
87 return false;
Duraid Madina9b9d45f2005-03-17 18:17:03 +000088}
89