XCoreTargetMachine.cpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. const TargetAsmInfo *XCoreTargetMachine::createTargetAsmInfo() const {
  31. return new XCoreTargetAsmInfo(*this);
  32. }
  33. /// XCoreTargetMachine ctor - Create an ILP32 architecture model
  34. ///
  35. XCoreTargetMachine::XCoreTargetMachine(const Module &M, const std::string &FS)
  36. : Subtarget(*this, M, FS),
  37. DataLayout("e-p:32:32:32-a0:0:32-f32:32:32-f64:32:32-i1:8:32-i8:8:32-"
  38. "i16:16:32-i32:32:32-i64:32:32"),
  39. InstrInfo(),
  40. FrameInfo(*this),
  41. TLInfo(*this) {
  42. }
  43. unsigned XCoreTargetMachine::getModuleMatchQuality(const Module &M) {
  44. std::string TT = M.getTargetTriple();
  45. if (TT.size() >= 6 && std::string(TT.begin(), TT.begin()+6) == "xcore-")
  46. return 20;
  47. // Otherwise we don't match.
  48. return 0;
  49. }
  50. bool XCoreTargetMachine::addInstSelector(PassManagerBase &PM, bool Fast) {
  51. PM.add(createXCoreISelDag(*this));
  52. return false;
  53. }
  54. bool XCoreTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
  55. bool Verbose, raw_ostream &Out) {
  56. // Output assembly language.
  57. PM.add(createXCoreCodePrinterPass(Out, *this, Fast, Verbose));
  58. return false;
  59. }