Disable x86 fastcc from passing args in registers
[oota-llvm.git] / lib / Target / IA64 / IA64TargetMachine.cpp
1 //===-- IA64TargetMachine.cpp - Define TargetMachine for IA64 -------------===//
2 //
3 //                     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.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the IA64 specific subclass of TargetMachine.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "IA64TargetMachine.h"
15 #include "IA64.h"
16 #include "llvm/Module.h"
17 #include "llvm/PassManager.h"
18 #include "llvm/CodeGen/IntrinsicLowering.h"
19 #include "llvm/CodeGen/MachineFunction.h"
20 #include "llvm/CodeGen/Passes.h"
21 #include "llvm/Target/TargetOptions.h"
22 #include "llvm/Target/TargetMachineRegistry.h"
23 #include "llvm/Transforms/Scalar.h"
24 #include "llvm/Support/CommandLine.h"
25 #include "llvm/ADT/Statistic.h"
26 #include <iostream>
27 using namespace llvm;
28
29 /// IA64TargetMachineModule - Note that this is used on hosts that cannot link
30 /// in a library unless there are references into the library.  In particular,
31 /// it seems that it is not possible to get things to work on Win32 without
32 /// this.  Though it is unused, do not remove it.
33 extern "C" int IA64TargetMachineModule;
34 int IA64TargetMachineModule = 0;
35
36 namespace {
37   cl::opt<bool> DisableOutput("disable-ia64-llc-output", cl::Hidden,
38                               cl::desc("Disable the IA64 asm printer, for use "
39                                        "when profiling the code generator."));
40
41   cl::opt<bool> EnableDAGIsel("enable-ia64-dag-isel", cl::Hidden,
42                               cl::desc("Enable the IA64 DAG->DAG isel"));
43
44   // Register the target.
45   RegisterTarget<IA64TargetMachine> X("ia64", "  IA-64 (Itanium)");
46 }
47
48 unsigned IA64TargetMachine::compileTimeMatchQuality() {
49 #if defined(__ia64__) || defined(__IA64__)
50   return 50;
51 #else
52   return 0;
53 #endif
54 }
55
56 unsigned IA64TargetMachine::getModuleMatchQuality(const Module &M) {
57   // we match [iI][aA]*64
58   bool seenIA64=false;
59   std::string TT = M.getTargetTriple();
60
61   if (TT.size() >= 4) {
62     if( (TT[0]=='i' || TT[0]=='I') &&
63         (TT[1]=='a' || TT[1]=='A') ) {
64       for(unsigned int i=2; i<(TT.size()-1); i++)
65         if(TT[i]=='6' && TT[i+1]=='4')
66           seenIA64=true;
67     }
68
69     if(seenIA64)
70       return 50; // strong match
71   }
72
73   return compileTimeMatchQuality()/2;
74
75 }
76
77 /// IA64TargetMachine ctor - Create an LP64 architecture model
78 ///
79 IA64TargetMachine::IA64TargetMachine(const Module &M, IntrinsicLowering *IL,
80                                      const std::string &FS)
81   : TargetMachine("IA64", IL, true),
82     FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0),
83     TLInfo(*this) { // FIXME? check this stuff
84 }
85
86 // addPassesToEmitFile - We currently use all of the same passes as the JIT
87 // does to emit statically compiled machine code.
88 bool IA64TargetMachine::addPassesToEmitFile(PassManager &PM,
89                                             std::ostream &Out,
90                                             CodeGenFileType FileType,
91                                             bool Fast) {
92   if (FileType != TargetMachine::AssemblyFile) return true;
93
94   // FIXME: Implement efficient support for garbage collection intrinsics.
95   PM.add(createLowerGCPass());
96
97   // FIXME: Implement the invoke/unwind instructions!
98   PM.add(createLowerInvokePass(704, 16)); // on ia64 linux, jmpbufs are 704
99                                           // bytes and must be 16byte aligned
100
101   // FIXME: Implement the switch instruction in the instruction selector!
102   PM.add(createLowerSwitchPass());
103
104   // Make sure that no unreachable blocks are instruction selected.
105   PM.add(createUnreachableBlockEliminationPass());
106
107   // Add an instruction selector
108 // FIXME: reap this option one day:  if(EnableDAGIsel)
109   PM.add(createIA64DAGToDAGInstructionSelector(*this));
110   
111 /* XXX not yet. ;)
112   // Run optional SSA-based machine code optimizations next...
113   if (!NoSSAPeephole)
114     PM.add(createIA64SSAPeepholeOptimizerPass());
115 */
116
117   // Print the instruction selected machine code...
118   if (PrintMachineCode)
119     PM.add(createMachineFunctionPrinterPass(&std::cerr));
120
121   // Perform register allocation to convert to a concrete IA64 representation
122   PM.add(createRegisterAllocator());
123
124   if (PrintMachineCode)
125     PM.add(createMachineFunctionPrinterPass(&std::cerr));
126
127   if (PrintMachineCode)
128     PM.add(createMachineFunctionPrinterPass(&std::cerr));
129
130   // Insert prolog/epilog code.  Eliminate abstract frame index references...
131   PM.add(createPrologEpilogCodeInserter());
132
133 /* XXX no, not just yet */
134 //  PM.add(createIA64PeepholeOptimizerPass());
135
136   // Make sure everything is bundled happily
137   PM.add(createIA64BundlingPass(*this));
138
139   if (PrintMachineCode)  // Print the register-allocated code
140     PM.add(createIA64CodePrinterPass(std::cerr, *this));
141
142   if (!DisableOutput)
143     PM.add(createIA64CodePrinterPass(Out, *this));
144
145   // Delete machine code for this function
146   PM.add(createMachineCodeDeleter());
147
148   return false; // success!
149 }
150