blob: 00fdd5e8a65e5341c1074a2035c8dd4421a6bcf8 [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
Stuart Hastings1721b8d2009-07-15 17:27:11 +000023static 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
Bob Wilsonebbc1c42009-06-23 23:59:40 +000029// Force static initialization.
30extern "C" void LLVMInitializeIA64Target() { }
Douglas Gregor1dc5ff42009-06-16 20:12:29 +000031
Dan Gohmanf17a25c2007-07-18 16:29:46 +000032const TargetAsmInfo *IA64TargetMachine::createTargetAsmInfo() const {
33 return new IA64TargetAsmInfo(*this);
34}
35
Stuart Hastings1721b8d2009-07-15 17:27:11 +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') &&
43 (TT[1]=='a' || TT[1]=='A') ) {
44 for(unsigned int i=2; i<(TT.size()-1); i++)
45 if(TT[i]=='6' && TT[i+1]=='4')
46 seenIA64=true;
47 }
48
49 if (seenIA64)
50 return 20; // strong match
51 }
52 // If the target triple is something non-ia64, we don't match.
53 if (!TT.empty()) return 0;
54
55#if defined(__ia64__) || defined(__IA64__)
56 return 5;
57#else
58 return 0;
59#endif
60}
61
Dan Gohmanf17a25c2007-07-18 16:29:46 +000062/// IA64TargetMachine ctor - Create an LP64 architecture model
63///
Stuart Hastings1721b8d2009-07-15 17:27:11 +000064IA64TargetMachine::IA64TargetMachine(const Module &M, const std::string &FS)
65 : DataLayout("e-f80:128:128"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000066 FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0),
67 TLInfo(*this) { // FIXME? check this stuff
68}
69
70
71//===----------------------------------------------------------------------===//
72// Pass Pipeline Configuration
73//===----------------------------------------------------------------------===//
74
Bill Wendling5ed22ac2009-04-29 23:29:43 +000075bool IA64TargetMachine::addInstSelector(PassManagerBase &PM,
Daniel Dunbarb10d2222009-07-01 01:48:54 +000076 CodeGenOpt::Level OptLevel) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000077 PM.add(createIA64DAGToDAGInstructionSelector(*this));
78 return false;
79}
80
Bill Wendling5ed22ac2009-04-29 23:29:43 +000081bool IA64TargetMachine::addPreEmitPass(PassManagerBase &PM,
82 CodeGenOpt::Level OptLevel) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000083 // Make sure everything is bundled happily
84 PM.add(createIA64BundlingPass(*this));
85 return true;
86}
Bill Wendling58ed5d22009-04-29 00:15:41 +000087bool IA64TargetMachine::addAssemblyEmitter(PassManagerBase &PM,
Bill Wendling5ed22ac2009-04-29 23:29:43 +000088 CodeGenOpt::Level OptLevel,
Bill Wendling58ed5d22009-04-29 00:15:41 +000089 bool Verbose,
David Greene302008d2009-07-14 20:18:05 +000090 formatted_raw_ostream &Out) {
Anton Korobeynikovbab832e2009-06-19 19:36:55 +000091 // Output assembly language.
92 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
93 if (AsmPrinterCtor)
Daniel Dunbarb10d2222009-07-01 01:48:54 +000094 PM.add(AsmPrinterCtor(Out, *this, Verbose));
Dan Gohmanf17a25c2007-07-18 16:29:46 +000095 return false;
96}
97