blob: f369f53a3f7888972a2e74ada7d732f4d4a7899b [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===-- IA64TargetMachine.cpp - Define TargetMachine for IA64 -------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the IA64 specific subclass of TargetMachine.
11//
12//===----------------------------------------------------------------------===//
13
14#include "IA64TargetAsmInfo.h"
15#include "IA64TargetMachine.h"
16#include "IA64.h"
17#include "llvm/Module.h"
18#include "llvm/PassManager.h"
19#include "llvm/Target/TargetMachineRegistry.h"
20using namespace llvm;
21
Anton Korobeynikovbab832e2009-06-19 19:36:55 +000022// Register the target
Daniel Dunbar6fa4f572009-07-15 09:22:31 +000023extern Target TheIA64Target;
24static RegisterTarget<IA64TargetMachine> X(TheIA64Target, "ia64",
Chris Lattner3f83d3f2008-10-16 06:16:50 +000025 "IA-64 (Itanium) [experimental]");
Dan Gohmanf17a25c2007-07-18 16:29:46 +000026
Anton Korobeynikovbab832e2009-06-19 19:36:55 +000027// No assembler printer by default
28IA64TargetMachine::AsmPrinterCtorFn IA64TargetMachine::AsmPrinterCtor = 0;
29
Bob Wilsonebbc1c42009-06-23 23:59:40 +000030// Force static initialization.
31extern "C" void LLVMInitializeIA64Target() { }
Douglas Gregor1dc5ff42009-06-16 20:12:29 +000032
Dan Gohmanf17a25c2007-07-18 16:29:46 +000033const TargetAsmInfo *IA64TargetMachine::createTargetAsmInfo() const {
34 return new IA64TargetAsmInfo(*this);
35}
36
37unsigned IA64TargetMachine::getModuleMatchQuality(const Module &M) {
38 // we match [iI][aA]*64
39 bool seenIA64=false;
40 std::string TT = M.getTargetTriple();
41
42 if (TT.size() >= 4) {
43 if( (TT[0]=='i' || TT[0]=='I') &&
44 (TT[1]=='a' || TT[1]=='A') ) {
45 for(unsigned int i=2; i<(TT.size()-1); i++)
46 if(TT[i]=='6' && TT[i+1]=='4')
47 seenIA64=true;
48 }
49
50 if (seenIA64)
51 return 20; // strong match
52 }
53 // If the target triple is something non-ia64, we don't match.
54 if (!TT.empty()) return 0;
55
56#if defined(__ia64__) || defined(__IA64__)
57 return 5;
58#else
59 return 0;
60#endif
61}
62
63/// IA64TargetMachine ctor - Create an LP64 architecture model
64///
Daniel Dunbar8ea70212009-07-15 12:11:05 +000065IA64TargetMachine::IA64TargetMachine(const Target &T, const Module &M,
66 const std::string &FS)
67 : LLVMTargetMachine(T),
68 DataLayout("e-f80:128:128"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000069 FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0),
70 TLInfo(*this) { // FIXME? check this stuff
71}
72
73
74//===----------------------------------------------------------------------===//
75// Pass Pipeline Configuration
76//===----------------------------------------------------------------------===//
77
Bill Wendling5ed22ac2009-04-29 23:29:43 +000078bool IA64TargetMachine::addInstSelector(PassManagerBase &PM,
Daniel Dunbarb10d2222009-07-01 01:48:54 +000079 CodeGenOpt::Level OptLevel) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000080 PM.add(createIA64DAGToDAGInstructionSelector(*this));
81 return false;
82}
83
Bill Wendling5ed22ac2009-04-29 23:29:43 +000084bool IA64TargetMachine::addPreEmitPass(PassManagerBase &PM,
85 CodeGenOpt::Level OptLevel) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000086 // Make sure everything is bundled happily
87 PM.add(createIA64BundlingPass(*this));
88 return true;
89}
Bill Wendling58ed5d22009-04-29 00:15:41 +000090bool IA64TargetMachine::addAssemblyEmitter(PassManagerBase &PM,
Bill Wendling5ed22ac2009-04-29 23:29:43 +000091 CodeGenOpt::Level OptLevel,
Bill Wendling58ed5d22009-04-29 00:15:41 +000092 bool Verbose,
David Greene302008d2009-07-14 20:18:05 +000093 formatted_raw_ostream &Out) {
Anton Korobeynikovbab832e2009-06-19 19:36:55 +000094 // Output assembly language.
95 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
96 if (AsmPrinterCtor)
Daniel Dunbarb10d2222009-07-01 01:48:54 +000097 PM.add(AsmPrinterCtor(Out, *this, Verbose));
Dan Gohmanf17a25c2007-07-18 16:29:46 +000098 return false;
99}
100