Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

R600ISelLowering.cpp 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. //===-- R600ISelLowering.cpp - TODO: Add brief description -------===//
  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. // TODO: Add full description
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #include "R600ISelLowering.h"
  14. #include "R600InstrInfo.h"
  15. #include "llvm/CodeGen/MachineRegisterInfo.h"
  16. using namespace llvm;
  17. R600TargetLowering::R600TargetLowering(TargetMachine &TM) :
  18. AMDGPUTargetLowering(TM),
  19. TII(static_cast<const R600InstrInfo*>(TM.getInstrInfo()))
  20. {
  21. setOperationAction(ISD::MUL, MVT::i64, Expand);
  22. // setSchedulingPreference(Sched::VLIW);
  23. addRegisterClass(MVT::v4f32, &AMDIL::R600_Reg128RegClass);
  24. addRegisterClass(MVT::f32, &AMDIL::R600_Reg32RegClass);
  25. setOperationAction(ISD::EXTRACT_VECTOR_ELT, MVT::v4f32, Legal);
  26. setOperationAction(ISD::INSERT_VECTOR_ELT, MVT::v4f32, Legal);
  27. }
  28. MachineBasicBlock * R600TargetLowering::EmitInstrWithCustomInserter(
  29. MachineInstr * MI, MachineBasicBlock * BB) const
  30. {
  31. MachineFunction * MF = BB->getParent();
  32. MachineRegisterInfo &MRI = MF->getRegInfo();
  33. switch (MI->getOpcode()) {
  34. default: return AMDGPUTargetLowering::EmitInstrWithCustomInserter(MI, BB);
  35. /* XXX: Use helper function from AMDGPULowerShaderInstructions here */
  36. case AMDIL::TGID_X:
  37. addLiveIn(MI, MF, MRI, TII, AMDIL::T1_X);
  38. break;
  39. case AMDIL::TGID_Y:
  40. addLiveIn(MI, MF, MRI, TII, AMDIL::T1_Y);
  41. break;
  42. case AMDIL::TGID_Z:
  43. addLiveIn(MI, MF, MRI, TII, AMDIL::T1_Z);
  44. break;
  45. case AMDIL::TIDIG_X:
  46. addLiveIn(MI, MF, MRI, TII, AMDIL::T0_X);
  47. break;
  48. case AMDIL::TIDIG_Y:
  49. addLiveIn(MI, MF, MRI, TII, AMDIL::T0_Y);
  50. break;
  51. case AMDIL::TIDIG_Z:
  52. addLiveIn(MI, MF, MRI, TII, AMDIL::T0_Z);
  53. break;
  54. case AMDIL::NGROUPS_X:
  55. lowerImplicitParameter(MI, *BB, MRI, 0);
  56. break;
  57. case AMDIL::NGROUPS_Y:
  58. lowerImplicitParameter(MI, *BB, MRI, 1);
  59. break;
  60. case AMDIL::NGROUPS_Z:
  61. lowerImplicitParameter(MI, *BB, MRI, 2);
  62. break;
  63. case AMDIL::GLOBAL_SIZE_X:
  64. lowerImplicitParameter(MI, *BB, MRI, 3);
  65. break;
  66. case AMDIL::GLOBAL_SIZE_Y:
  67. lowerImplicitParameter(MI, *BB, MRI, 4);
  68. break;
  69. case AMDIL::GLOBAL_SIZE_Z:
  70. lowerImplicitParameter(MI, *BB, MRI, 5);
  71. break;
  72. case AMDIL::LOCAL_SIZE_X:
  73. lowerImplicitParameter(MI, *BB, MRI, 6);
  74. break;
  75. case AMDIL::LOCAL_SIZE_Y:
  76. lowerImplicitParameter(MI, *BB, MRI, 7);
  77. break;
  78. case AMDIL::LOCAL_SIZE_Z:
  79. lowerImplicitParameter(MI, *BB, MRI, 8);
  80. break;
  81. }
  82. MI->eraseFromParent();
  83. return BB;
  84. }
  85. void R600TargetLowering::lowerImplicitParameter(MachineInstr *MI, MachineBasicBlock &BB,
  86. MachineRegisterInfo & MRI, unsigned dword_offset) const
  87. {
  88. MachineBasicBlock::iterator I = *MI;
  89. unsigned offsetReg = MRI.createVirtualRegister(&AMDIL::R600_TReg32_XRegClass);
  90. MRI.setRegClass(MI->getOperand(0).getReg(), &AMDIL::R600_TReg32_XRegClass);
  91. BuildMI(BB, I, BB.findDebugLoc(I), TII->get(AMDIL::MOV), offsetReg)
  92. .addReg(AMDIL::ALU_LITERAL_X)
  93. .addImm(dword_offset * 4);
  94. BuildMI(BB, I, BB.findDebugLoc(I), TII->get(AMDIL::VTX_READ_eg))
  95. .addOperand(MI->getOperand(0))
  96. .addReg(offsetReg)
  97. .addImm(0);
  98. }