blob: 6642c66570f7f44f39b73c4f28f6d4a37fe4f4fe [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
Chris Lattner0d5d05b2008-10-16 06:16:50 +000029static RegisterTarget<IA64TargetMachine> X("ia64",
30 "IA-64 (Itanium) [experimental]");
Duraid Madina9b9d45f2005-03-17 18:17:03 +000031
Douglas Gregor1555a232009-06-16 20:12:29 +000032// Force static initialization when called from llvm/InitializeAllTargets.h
33namespace llvm {
34 void InitializeIA64Target() { }
35}
36
Jim Laskeyfde1b3b2006-09-07 23:39:26 +000037const TargetAsmInfo *IA64TargetMachine::createTargetAsmInfo() const {
38 return new IA64TargetAsmInfo(*this);
39}
40
Duraid Madina9b9d45f2005-03-17 18:17:03 +000041unsigned IA64TargetMachine::getModuleMatchQuality(const Module &M) {
42 // we match [iI][aA]*64
43 bool seenIA64=false;
44 std::string TT = M.getTargetTriple();
45
46 if (TT.size() >= 4) {
47 if( (TT[0]=='i' || TT[0]=='I') &&
Misha Brukman7847fca2005-04-22 17:54:37 +000048 (TT[1]=='a' || TT[1]=='A') ) {
Duraid Madina9b9d45f2005-03-17 18:17:03 +000049 for(unsigned int i=2; i<(TT.size()-1); i++)
Misha Brukman7847fca2005-04-22 17:54:37 +000050 if(TT[i]=='6' && TT[i+1]=='4')
51 seenIA64=true;
Duraid Madina9b9d45f2005-03-17 18:17:03 +000052 }
53
Chris Lattner16c7fe52006-08-26 21:33:05 +000054 if (seenIA64)
55 return 20; // strong match
Duraid Madina9b9d45f2005-03-17 18:17:03 +000056 }
Chris Lattner87bdba62007-07-09 17:25:29 +000057 // If the target triple is something non-ia64, we don't match.
58 if (!TT.empty()) return 0;
Duraid Madina9b9d45f2005-03-17 18:17:03 +000059
Chris Lattner16c7fe52006-08-26 21:33:05 +000060#if defined(__ia64__) || defined(__IA64__)
61 return 5;
62#else
63 return 0;
64#endif
Duraid Madina9b9d45f2005-03-17 18:17:03 +000065}
66
67/// IA64TargetMachine ctor - Create an LP64 architecture model
68///
Chris Lattnerbc641b92006-03-23 05:43:16 +000069IA64TargetMachine::IA64TargetMachine(const Module &M, const std::string &FS)
Dale Johannesen8c1e6a12007-08-03 20:20:50 +000070 : DataLayout("e-f80:128:128"),
Evan Chengc4c62572006-03-13 23:20:37 +000071 FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0),
72 TLInfo(*this) { // FIXME? check this stuff
Duraid Madina9b9d45f2005-03-17 18:17:03 +000073}
74
Chris Lattner0431c962005-06-25 02:48:37 +000075
Chris Lattner1911fd42006-09-04 04:14:57 +000076//===----------------------------------------------------------------------===//
77// Pass Pipeline Configuration
78//===----------------------------------------------------------------------===//
Duraid Madina9b9d45f2005-03-17 18:17:03 +000079
Bill Wendling98a366d2009-04-29 23:29:43 +000080bool IA64TargetMachine::addInstSelector(PassManagerBase &PM,
81 CodeGenOpt::Level OptLevel){
Duraid Madinac5f24702006-01-19 14:13:11 +000082 PM.add(createIA64DAGToDAGInstructionSelector(*this));
Chris Lattner1911fd42006-09-04 04:14:57 +000083 return false;
84}
Duraid Madina9b9d45f2005-03-17 18:17:03 +000085
Bill Wendling98a366d2009-04-29 23:29:43 +000086bool IA64TargetMachine::addPreEmitPass(PassManagerBase &PM,
87 CodeGenOpt::Level OptLevel) {
Duraid Madinabadf0d92006-01-25 02:23:38 +000088 // Make sure everything is bundled happily
89 PM.add(createIA64BundlingPass(*this));
Chris Lattner1911fd42006-09-04 04:14:57 +000090 return true;
91}
Bill Wendlingbe8cc2a2009-04-29 00:15:41 +000092bool IA64TargetMachine::addAssemblyEmitter(PassManagerBase &PM,
Bill Wendling98a366d2009-04-29 23:29:43 +000093 CodeGenOpt::Level OptLevel,
Bill Wendlingbe8cc2a2009-04-29 00:15:41 +000094 bool Verbose,
95 raw_ostream &Out) {
96 PM.add(createIA64CodePrinterPass(Out, *this, OptLevel, Verbose));
Chris Lattner1911fd42006-09-04 04:14:57 +000097 return false;
Duraid Madina9b9d45f2005-03-17 18:17:03 +000098}
99