blob: 0b93ee5c4ae8d0bdd82fae5d490413d9cc03f25c [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
23static RegisterTarget<IA64TargetMachine> X("ia64",
Chris Lattner3f83d3f2008-10-16 06:16:50 +000024 "IA-64 (Itanium) [experimental]");
Dan Gohmanf17a25c2007-07-18 16:29:46 +000025
Anton Korobeynikovbab832e2009-06-19 19:36:55 +000026// No assembler printer by default
27IA64TargetMachine::AsmPrinterCtorFn IA64TargetMachine::AsmPrinterCtor = 0;
28
Douglas Gregor1dc5ff42009-06-16 20:12:29 +000029// Force static initialization when called from llvm/InitializeAllTargets.h
30namespace llvm {
31 void InitializeIA64Target() { }
32}
33
Dan Gohmanf17a25c2007-07-18 16:29:46 +000034const TargetAsmInfo *IA64TargetMachine::createTargetAsmInfo() const {
35 return new IA64TargetAsmInfo(*this);
36}
37
38unsigned IA64TargetMachine::getModuleMatchQuality(const Module &M) {
39 // we match [iI][aA]*64
40 bool seenIA64=false;
41 std::string TT = M.getTargetTriple();
42
43 if (TT.size() >= 4) {
44 if( (TT[0]=='i' || TT[0]=='I') &&
45 (TT[1]=='a' || TT[1]=='A') ) {
46 for(unsigned int i=2; i<(TT.size()-1); i++)
47 if(TT[i]=='6' && TT[i+1]=='4')
48 seenIA64=true;
49 }
50
51 if (seenIA64)
52 return 20; // strong match
53 }
54 // If the target triple is something non-ia64, we don't match.
55 if (!TT.empty()) return 0;
56
57#if defined(__ia64__) || defined(__IA64__)
58 return 5;
59#else
60 return 0;
61#endif
62}
63
64/// IA64TargetMachine ctor - Create an LP64 architecture model
65///
66IA64TargetMachine::IA64TargetMachine(const Module &M, const std::string &FS)
Dale Johannesen4c39f712007-08-03 20:20:50 +000067 : DataLayout("e-f80:128:128"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000068 FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0),
69 TLInfo(*this) { // FIXME? check this stuff
70}
71
72
73//===----------------------------------------------------------------------===//
74// Pass Pipeline Configuration
75//===----------------------------------------------------------------------===//
76
Bill Wendling5ed22ac2009-04-29 23:29:43 +000077bool IA64TargetMachine::addInstSelector(PassManagerBase &PM,
78 CodeGenOpt::Level OptLevel){
Dan Gohmanf17a25c2007-07-18 16:29:46 +000079 PM.add(createIA64DAGToDAGInstructionSelector(*this));
80 return false;
81}
82
Bill Wendling5ed22ac2009-04-29 23:29:43 +000083bool IA64TargetMachine::addPreEmitPass(PassManagerBase &PM,
84 CodeGenOpt::Level OptLevel) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000085 // Make sure everything is bundled happily
86 PM.add(createIA64BundlingPass(*this));
87 return true;
88}
Bill Wendling58ed5d22009-04-29 00:15:41 +000089bool IA64TargetMachine::addAssemblyEmitter(PassManagerBase &PM,
Bill Wendling5ed22ac2009-04-29 23:29:43 +000090 CodeGenOpt::Level OptLevel,
Bill Wendling58ed5d22009-04-29 00:15:41 +000091 bool Verbose,
92 raw_ostream &Out) {
Anton Korobeynikovbab832e2009-06-19 19:36:55 +000093 // Output assembly language.
94 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
95 if (AsmPrinterCtor)
96 PM.add(AsmPrinterCtor(Out, *this, OptLevel, Verbose));
Dan Gohmanf17a25c2007-07-18 16:29:46 +000097 return false;
98}
99