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
|
|
|
|
//
|
2007-12-29 20:36:04 +00:00
|
|
|
// This file 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
|
|
|
//
|
2006-09-04 04:14:57 +00:00
|
|
|
// This file implements the IA64 specific subclass of TargetMachine.
|
2005-03-17 18:17:03 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2006-09-07 23:39:26 +00:00
|
|
|
#include "IA64TargetAsmInfo.h"
|
2005-03-17 18:17:03 +00:00
|
|
|
#include "IA64TargetMachine.h"
|
|
|
|
#include "IA64.h"
|
|
|
|
#include "llvm/Module.h"
|
|
|
|
#include "llvm/PassManager.h"
|
|
|
|
#include "llvm/Target/TargetMachineRegistry.h"
|
|
|
|
using namespace llvm;
|
|
|
|
|
2009-06-19 19:36:55 +00:00
|
|
|
// Register the target
|
|
|
|
static RegisterTarget<IA64TargetMachine> X("ia64",
|
2008-10-16 06:16:50 +00:00
|
|
|
"IA-64 (Itanium) [experimental]");
|
2005-03-17 18:17:03 +00:00
|
|
|
|
2009-06-19 19:36:55 +00:00
|
|
|
// No assembler printer by default
|
|
|
|
IA64TargetMachine::AsmPrinterCtorFn IA64TargetMachine::AsmPrinterCtor = 0;
|
|
|
|
|
2009-06-23 23:59:40 +00:00
|
|
|
// Force static initialization.
|
|
|
|
extern "C" void LLVMInitializeIA64Target() { }
|
2009-06-16 20:12:29 +00:00
|
|
|
|
2006-09-07 23:39:26 +00:00
|
|
|
const TargetAsmInfo *IA64TargetMachine::createTargetAsmInfo() const {
|
|
|
|
return new IA64TargetAsmInfo(*this);
|
|
|
|
}
|
|
|
|
|
2005-03-17 18:17:03 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2006-08-26 21:33:05 +00:00
|
|
|
if (seenIA64)
|
|
|
|
return 20; // strong match
|
2005-03-17 18:17:03 +00:00
|
|
|
}
|
2007-07-09 17:25:29 +00:00
|
|
|
// If the target triple is something non-ia64, we don't match.
|
|
|
|
if (!TT.empty()) return 0;
|
2005-03-17 18:17:03 +00:00
|
|
|
|
2006-08-26 21:33:05 +00:00
|
|
|
#if defined(__ia64__) || defined(__IA64__)
|
|
|
|
return 5;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
2005-03-17 18:17:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// IA64TargetMachine ctor - Create an LP64 architecture model
|
|
|
|
///
|
2006-03-23 05:43:16 +00:00
|
|
|
IA64TargetMachine::IA64TargetMachine(const Module &M, const std::string &FS)
|
2007-08-03 20:20:50 +00:00
|
|
|
: DataLayout("e-f80:128:128"),
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-04 04:14:57 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Pass Pipeline Configuration
|
|
|
|
//===----------------------------------------------------------------------===//
|
2005-03-17 18:17:03 +00:00
|
|
|
|
2009-04-29 23:29:43 +00:00
|
|
|
bool IA64TargetMachine::addInstSelector(PassManagerBase &PM,
|
2009-07-01 01:48:54 +00:00
|
|
|
CodeGenOpt::Level OptLevel) {
|
2006-01-19 14:13:11 +00:00
|
|
|
PM.add(createIA64DAGToDAGInstructionSelector(*this));
|
2006-09-04 04:14:57 +00:00
|
|
|
return false;
|
|
|
|
}
|
2005-03-17 18:17:03 +00:00
|
|
|
|
2009-04-29 23:29:43 +00:00
|
|
|
bool IA64TargetMachine::addPreEmitPass(PassManagerBase &PM,
|
|
|
|
CodeGenOpt::Level OptLevel) {
|
2006-01-25 02:23:38 +00:00
|
|
|
// Make sure everything is bundled happily
|
|
|
|
PM.add(createIA64BundlingPass(*this));
|
2006-09-04 04:14:57 +00:00
|
|
|
return true;
|
|
|
|
}
|
2009-04-29 00:15:41 +00:00
|
|
|
bool IA64TargetMachine::addAssemblyEmitter(PassManagerBase &PM,
|
2009-04-29 23:29:43 +00:00
|
|
|
CodeGenOpt::Level OptLevel,
|
2009-04-29 00:15:41 +00:00
|
|
|
bool Verbose,
|
|
|
|
raw_ostream &Out) {
|
2009-06-19 19:36:55 +00:00
|
|
|
// Output assembly language.
|
|
|
|
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
|
|
|
|
if (AsmPrinterCtor)
|
2009-07-01 01:48:54 +00:00
|
|
|
PM.add(AsmPrinterCtor(Out, *this, Verbose));
|
2006-09-04 04:14:57 +00:00
|
|
|
return false;
|
2005-03-17 18:17:03 +00:00
|
|
|
}
|
|
|
|
|