XCoreTargetMachine.cpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. #include "XCoreTargetAsmInfo.h"
  13. #include "XCoreTargetMachine.h"
  14. #include "XCore.h"
  15. #include "llvm/Module.h"
  16. #include "llvm/PassManager.h"
  17. #include "llvm/Target/TargetMachineRegistry.h"
  18. using namespace llvm;
  19. /// XCoreTargetMachineModule - Note that this is used on hosts that
  20. /// cannot link in a library unless there are references into the
  21. /// library. In particular, it seems that it is not possible to get
  22. /// things to work on Win32 without this. Though it is unused, do not
  23. /// remove it.
  24. extern "C" int XCoreTargetMachineModule;
  25. int XCoreTargetMachineModule = 0;
  26. namespace {
  27. // Register the target.
  28. RegisterTarget<XCoreTargetMachine> X("xcore", "XCore");
  29. }
  30. // Force static initialization.
  31. extern "C" void LLVMInitializeXCoreTarget() { }
  32. const TargetAsmInfo *XCoreTargetMachine::createTargetAsmInfo() const {
  33. return new XCoreTargetAsmInfo(*this);
  34. }
  35. /// XCoreTargetMachine ctor - Create an ILP32 architecture model
  36. ///
  37. XCoreTargetMachine::XCoreTargetMachine(const Module &M, const std::string &FS)
  38. : Subtarget(*this, M, FS),
  39. DataLayout("e-p:32:32:32-a0:0:32-f32:32:32-f64:32:32-i1:8:32-i8:8:32-"
  40. "i16:16:32-i32:32:32-i64:32:32"),
  41. InstrInfo(),
  42. FrameInfo(*this),
  43. TLInfo(*this) {
  44. }
  45. unsigned XCoreTargetMachine::getModuleMatchQuality(const Module &M) {
  46. std::string TT = M.getTargetTriple();
  47. if (TT.size() >= 6 && std::string(TT.begin(), TT.begin()+6) == "xcore-")
  48. return 20;
  49. // Otherwise we don't match.
  50. return 0;
  51. }
  52. bool XCoreTargetMachine::addInstSelector(PassManagerBase &PM,
  53. CodeGenOpt::Level OptLevel) {
  54. PM.add(createXCoreISelDag(*this));
  55. return false;
  56. }
  57. bool XCoreTargetMachine::addAssemblyEmitter(PassManagerBase &PM,
  58. CodeGenOpt::Level OptLevel,
  59. bool Verbose,
  60. raw_ostream &Out) {
  61. // Output assembly language.
  62. PM.add(createXCoreCodePrinterPass(Out, *this, OptLevel, Verbose));
  63. return false;
  64. }