2005-03-17 18:17:03 +00:00
|
|
|
//===-- IA64TargetMachine.cpp - Define TargetMachine for IA64 -------------===//
|
2005-04-21 23:13:11 +00:00
|
|
|
//
|
2005-03-17 18:17:03 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by Duraid Madina and is distributed under the
|
|
|
|
// University of Illinois Open Source License. See LICENSE.TXT for details.
|
2005-04-21 23:13:11 +00:00
|
|
|
//
|
2005-03-17 18:17:03 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2005-04-21 23:13:11 +00:00
|
|
|
//
|
2005-03-17 18:17:03 +00:00
|
|
|
// This file defines the IA64 specific subclass of TargetMachine.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "IA64TargetMachine.h"
|
|
|
|
#include "IA64.h"
|
|
|
|
#include "llvm/Module.h"
|
|
|
|
#include "llvm/PassManager.h"
|
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
|
|
|
#include "llvm/CodeGen/Passes.h"
|
|
|
|
#include "llvm/Target/TargetOptions.h"
|
|
|
|
#include "llvm/Target/TargetMachineRegistry.h"
|
|
|
|
#include "llvm/Transforms/Scalar.h"
|
|
|
|
#include "llvm/Support/CommandLine.h"
|
|
|
|
#include "llvm/ADT/Statistic.h"
|
2006-01-22 23:41:00 +00:00
|
|
|
#include <iostream>
|
2005-03-17 18:17:03 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
/// IA64TargetMachineModule - Note that this is used on hosts that cannot link
|
|
|
|
/// in a library unless there are references into the library. In particular,
|
|
|
|
/// it seems that it is not possible to get things to work on Win32 without
|
|
|
|
/// this. Though it is unused, do not remove it.
|
|
|
|
extern "C" int IA64TargetMachineModule;
|
|
|
|
int IA64TargetMachineModule = 0;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
cl::opt<bool> DisableOutput("disable-ia64-llc-output", cl::Hidden,
|
|
|
|
cl::desc("Disable the IA64 asm printer, for use "
|
|
|
|
"when profiling the code generator."));
|
|
|
|
|
2005-10-28 17:46:35 +00:00
|
|
|
cl::opt<bool> EnableDAGIsel("enable-ia64-dag-isel", cl::Hidden,
|
|
|
|
cl::desc("Enable the IA64 DAG->DAG isel"));
|
|
|
|
|
2005-03-17 18:17:03 +00:00
|
|
|
// Register the target.
|
|
|
|
RegisterTarget<IA64TargetMachine> X("ia64", " IA-64 (Itanium)");
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned IA64TargetMachine::compileTimeMatchQuality() {
|
|
|
|
#if defined(__ia64__) || defined(__IA64__)
|
|
|
|
return 50;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned IA64TargetMachine::getModuleMatchQuality(const Module &M) {
|
|
|
|
// we match [iI][aA]*64
|
|
|
|
bool seenIA64=false;
|
|
|
|
std::string TT = M.getTargetTriple();
|
|
|
|
|
|
|
|
if (TT.size() >= 4) {
|
|
|
|
if( (TT[0]=='i' || TT[0]=='I') &&
|
2005-04-22 17:54:37 +00:00
|
|
|
(TT[1]=='a' || TT[1]=='A') ) {
|
2005-03-17 18:17:03 +00:00
|
|
|
for(unsigned int i=2; i<(TT.size()-1); i++)
|
2005-04-22 17:54:37 +00:00
|
|
|
if(TT[i]=='6' && TT[i+1]=='4')
|
|
|
|
seenIA64=true;
|
2005-03-17 18:17:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(seenIA64)
|
|
|
|
return 50; // strong match
|
|
|
|
}
|
|
|
|
|
|
|
|
return compileTimeMatchQuality()/2;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/// IA64TargetMachine ctor - Create an LP64 architecture model
|
|
|
|
///
|
2006-03-23 05:43:16 +00:00
|
|
|
IA64TargetMachine::IA64TargetMachine(const Module &M, const std::string &FS)
|
2006-06-16 18:22:52 +00:00
|
|
|
: TargetMachine("IA64"), DataLayout("e"),
|
2006-03-13 23:20:37 +00:00
|
|
|
FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0),
|
|
|
|
TLInfo(*this) { // FIXME? check this stuff
|
2005-03-17 18:17:03 +00:00
|
|
|
}
|
|
|
|
|
2005-06-25 02:48:37 +00:00
|
|
|
// addPassesToEmitFile - We currently use all of the same passes as the JIT
|
2005-03-17 18:17:03 +00:00
|
|
|
// does to emit statically compiled machine code.
|
2005-06-25 02:48:37 +00:00
|
|
|
bool IA64TargetMachine::addPassesToEmitFile(PassManager &PM,
|
|
|
|
std::ostream &Out,
|
2005-11-08 02:11:51 +00:00
|
|
|
CodeGenFileType FileType,
|
|
|
|
bool Fast) {
|
2005-06-25 02:48:37 +00:00
|
|
|
if (FileType != TargetMachine::AssemblyFile) return true;
|
|
|
|
|
2005-03-17 18:17:03 +00:00
|
|
|
// FIXME: Implement efficient support for garbage collection intrinsics.
|
|
|
|
PM.add(createLowerGCPass());
|
|
|
|
|
|
|
|
// FIXME: Implement the invoke/unwind instructions!
|
2005-11-06 04:29:30 +00:00
|
|
|
PM.add(createLowerInvokePass(704, 16)); // on ia64 linux, jmpbufs are 704
|
|
|
|
// bytes and must be 16byte aligned
|
2005-03-17 18:17:03 +00:00
|
|
|
|
|
|
|
// Make sure that no unreachable blocks are instruction selected.
|
|
|
|
PM.add(createUnreachableBlockEliminationPass());
|
|
|
|
|
2005-10-28 17:46:35 +00:00
|
|
|
// Add an instruction selector
|
2006-01-19 14:13:11 +00:00
|
|
|
// FIXME: reap this option one day: if(EnableDAGIsel)
|
|
|
|
PM.add(createIA64DAGToDAGInstructionSelector(*this));
|
2006-01-25 02:23:38 +00:00
|
|
|
|
2005-03-17 18:17:03 +00:00
|
|
|
/* XXX not yet. ;)
|
|
|
|
// Run optional SSA-based machine code optimizations next...
|
|
|
|
if (!NoSSAPeephole)
|
|
|
|
PM.add(createIA64SSAPeepholeOptimizerPass());
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Print the instruction selected machine code...
|
|
|
|
if (PrintMachineCode)
|
|
|
|
PM.add(createMachineFunctionPrinterPass(&std::cerr));
|
|
|
|
|
|
|
|
// Perform register allocation to convert to a concrete IA64 representation
|
|
|
|
PM.add(createRegisterAllocator());
|
|
|
|
|
|
|
|
if (PrintMachineCode)
|
|
|
|
PM.add(createMachineFunctionPrinterPass(&std::cerr));
|
|
|
|
|
|
|
|
if (PrintMachineCode)
|
|
|
|
PM.add(createMachineFunctionPrinterPass(&std::cerr));
|
|
|
|
|
|
|
|
// Insert prolog/epilog code. Eliminate abstract frame index references...
|
|
|
|
PM.add(createPrologEpilogCodeInserter());
|
|
|
|
|
|
|
|
/* XXX no, not just yet */
|
|
|
|
// PM.add(createIA64PeepholeOptimizerPass());
|
|
|
|
|
2006-01-25 02:23:38 +00:00
|
|
|
// Make sure everything is bundled happily
|
|
|
|
PM.add(createIA64BundlingPass(*this));
|
|
|
|
|
2005-03-17 18:17:03 +00:00
|
|
|
if (PrintMachineCode) // Print the register-allocated code
|
|
|
|
PM.add(createIA64CodePrinterPass(std::cerr, *this));
|
|
|
|
|
|
|
|
if (!DisableOutput)
|
|
|
|
PM.add(createIA64CodePrinterPass(Out, *this));
|
|
|
|
|
|
|
|
// Delete machine code for this function
|
|
|
|
PM.add(createMachineCodeDeleter());
|
|
|
|
|
|
|
|
return false; // success!
|
|
|
|
}
|
|
|
|
|