LLVM API Documentation

XCoreTargetMachine.cpp

Go to the documentation of this file.
00001 //===-- XCoreTargetMachine.cpp - Define TargetMachine for XCore -----------===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 //
00011 //===----------------------------------------------------------------------===//
00012 
00013 #include "XCoreTargetAsmInfo.h"
00014 #include "XCoreTargetMachine.h"
00015 #include "XCore.h"
00016 #include "llvm/Module.h"
00017 #include "llvm/PassManager.h"
00018 #include "llvm/Target/TargetMachineRegistry.h"
00019 using namespace llvm;
00020 
00021 /// XCoreTargetMachineModule - Note that this is used on hosts that
00022 /// cannot link in a library unless there are references into the
00023 /// library.  In particular, it seems that it is not possible to get
00024 /// things to work on Win32 without this.  Though it is unused, do not
00025 /// remove it.
00026 extern "C" int XCoreTargetMachineModule;
00027 int XCoreTargetMachineModule = 0;
00028 
00029 namespace {
00030   // Register the target.
00031   RegisterTarget<XCoreTargetMachine> X("xcore", "XCore");
00032 }
00033 
00034 const TargetAsmInfo *XCoreTargetMachine::createTargetAsmInfo() const {
00035   return new XCoreTargetAsmInfo(*this);
00036 }
00037 
00038 /// XCoreTargetMachine ctor - Create an ILP32 architecture model
00039 ///
00040 XCoreTargetMachine::XCoreTargetMachine(const Module &M, const std::string &FS)
00041   : Subtarget(*this, M, FS),
00042     DataLayout("e-p:32:32:32-a0:0:32-f32:32:32-f64:32:32-i1:8:32-i8:8:32-"
00043                "i16:16:32-i32:32:32-i64:32:32"),
00044     InstrInfo(),
00045     FrameInfo(*this),
00046     TLInfo(*this) {
00047 }
00048 
00049 unsigned XCoreTargetMachine::getModuleMatchQuality(const Module &M) {
00050   std::string TT = M.getTargetTriple();
00051   if (TT.size() >= 6 && std::string(TT.begin(), TT.begin()+6) == "xcore-")
00052     return 20;
00053   
00054   // Otherwise we don't match.
00055   return 0;
00056 }
00057 
00058 bool XCoreTargetMachine::addInstSelector(PassManagerBase &PM, bool Fast) {
00059   PM.add(createXCoreISelDag(*this));
00060   return false;
00061 }
00062 
00063 bool XCoreTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast, 
00064                                             raw_ostream &Out) {
00065   // Output assembly language.
00066   PM.add(createXCoreCodePrinterPass(Out, *this));
00067   return false;
00068 }