Add XCore backend.
[oota-llvm.git] / lib / Target / XCore / XCoreTargetMachine.cpp
1 //===-- XCoreTargetMachine.cpp - Define TargetMachine for XCore -----------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 //
11 //===----------------------------------------------------------------------===//
12
13 #include "XCoreTargetAsmInfo.h"
14 #include "XCoreTargetMachine.h"
15 #include "XCore.h"
16 #include "llvm/Module.h"
17 #include "llvm/PassManager.h"
18 #include "llvm/Target/TargetMachineRegistry.h"
19 using namespace llvm;
20
21 namespace {
22   // Register the target.
23   RegisterTarget<XCoreTargetMachine> X("xcore", "  XCore");
24 }
25
26 const TargetAsmInfo *XCoreTargetMachine::createTargetAsmInfo() const {
27   return new XCoreTargetAsmInfo(*this);
28 }
29
30 /// XCoreTargetMachine ctor - Create an ILP32 architecture model
31 ///
32 XCoreTargetMachine::XCoreTargetMachine(const Module &M, const std::string &FS)
33   : Subtarget(*this, M, FS),
34     DataLayout("e-p:32:32:32-a0:0:32-f32:32:32-f64:32:32-i1:8:32-i8:8:32-"
35                "i16:16:32-i32:32:32-i64:32:32"),
36     InstrInfo(),
37     FrameInfo(*this),
38     TLInfo(*this) {
39 }
40
41 unsigned XCoreTargetMachine::getModuleMatchQuality(const Module &M) {
42   std::string TT = M.getTargetTriple();
43   if (TT.size() >= 6 && std::string(TT.begin(), TT.begin()+6) == "xcore-")
44     return 20;
45   
46   // Otherwise we don't match.
47   return 0;
48 }
49
50 bool XCoreTargetMachine::addInstSelector(PassManagerBase &PM, bool Fast) {
51   PM.add(createXCoreISelDag(*this));
52   return false;
53 }
54
55 bool XCoreTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast, 
56                                             raw_ostream &Out) {
57   // Output assembly language.
58   PM.add(createXCoreCodePrinterPass(Out, *this));
59   return false;
60 }