blob: 0f7821f5af7053432791f97de75bd3e4b6ba601d [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//
5// This file was developed by Duraid Madina and is distributed under the
6// University of Illinois Open Source 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
14#include "IA64TargetMachine.h"
15#include "IA64.h"
16#include "llvm/Module.h"
17#include "llvm/PassManager.h"
Duraid Madina9b9d45f2005-03-17 18:17:03 +000018#include "llvm/Target/TargetMachineRegistry.h"
Duraid Madina9b9d45f2005-03-17 18:17:03 +000019using namespace llvm;
20
21/// IA64TargetMachineModule - Note that this is used on hosts that cannot link
22/// in a library unless there are references into the library. In particular,
23/// it seems that it is not possible to get things to work on Win32 without
24/// this. Though it is unused, do not remove it.
25extern "C" int IA64TargetMachineModule;
26int IA64TargetMachineModule = 0;
27
28namespace {
Duraid Madina9b9d45f2005-03-17 18:17:03 +000029 RegisterTarget<IA64TargetMachine> X("ia64", " IA-64 (Itanium)");
30}
31
Duraid Madina9b9d45f2005-03-17 18:17:03 +000032unsigned IA64TargetMachine::getModuleMatchQuality(const Module &M) {
33 // we match [iI][aA]*64
34 bool seenIA64=false;
35 std::string TT = M.getTargetTriple();
36
37 if (TT.size() >= 4) {
38 if( (TT[0]=='i' || TT[0]=='I') &&
Misha Brukman7847fca2005-04-22 17:54:37 +000039 (TT[1]=='a' || TT[1]=='A') ) {
Duraid Madina9b9d45f2005-03-17 18:17:03 +000040 for(unsigned int i=2; i<(TT.size()-1); i++)
Misha Brukman7847fca2005-04-22 17:54:37 +000041 if(TT[i]=='6' && TT[i+1]=='4')
42 seenIA64=true;
Duraid Madina9b9d45f2005-03-17 18:17:03 +000043 }
44
Chris Lattner16c7fe52006-08-26 21:33:05 +000045 if (seenIA64)
46 return 20; // strong match
Duraid Madina9b9d45f2005-03-17 18:17:03 +000047 }
48
Chris Lattner16c7fe52006-08-26 21:33:05 +000049#if defined(__ia64__) || defined(__IA64__)
50 return 5;
51#else
52 return 0;
53#endif
Duraid Madina9b9d45f2005-03-17 18:17:03 +000054}
55
56/// IA64TargetMachine ctor - Create an LP64 architecture model
57///
Chris Lattnerbc641b92006-03-23 05:43:16 +000058IA64TargetMachine::IA64TargetMachine(const Module &M, const std::string &FS)
Chris Lattnerc4fa3862006-09-03 18:44:02 +000059 : DataLayout("e"),
Evan Chengc4c62572006-03-13 23:20:37 +000060 FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0),
61 TLInfo(*this) { // FIXME? check this stuff
Duraid Madina9b9d45f2005-03-17 18:17:03 +000062}
63
Chris Lattner0431c962005-06-25 02:48:37 +000064
Chris Lattner1911fd42006-09-04 04:14:57 +000065//===----------------------------------------------------------------------===//
66// Pass Pipeline Configuration
67//===----------------------------------------------------------------------===//
Duraid Madina9b9d45f2005-03-17 18:17:03 +000068
Chris Lattner1911fd42006-09-04 04:14:57 +000069bool IA64TargetMachine::addInstSelector(FunctionPassManager &PM, bool Fast) {
Duraid Madinac5f24702006-01-19 14:13:11 +000070 PM.add(createIA64DAGToDAGInstructionSelector(*this));
Chris Lattner1911fd42006-09-04 04:14:57 +000071 return false;
72}
Duraid Madina9b9d45f2005-03-17 18:17:03 +000073
Chris Lattner1911fd42006-09-04 04:14:57 +000074bool IA64TargetMachine::addPreEmitPass(FunctionPassManager &PM, bool Fast) {
Duraid Madinabadf0d92006-01-25 02:23:38 +000075 // Make sure everything is bundled happily
76 PM.add(createIA64BundlingPass(*this));
Chris Lattner1911fd42006-09-04 04:14:57 +000077 return true;
78}
79bool IA64TargetMachine::addAssemblyEmitter(FunctionPassManager &PM, bool Fast,
80 std::ostream &Out) {
81 PM.add(createIA64CodePrinterPass(Out, *this));
82 return false;
Duraid Madina9b9d45f2005-03-17 18:17:03 +000083}
84