radeon/llvm: Inline immediate offset when lowering implicit parameters
authorTom Stellard <thomas.stellard@amd.com>
Wed, 1 Aug 2012 16:20:20 +0000 (16:20 +0000)
committerTom Stellard <thomas.stellard@amd.com>
Tue, 14 Aug 2012 14:06:20 +0000 (14:06 +0000)
src/gallium/drivers/radeon/R600ISelLowering.cpp

index 4d8c928f49bec64def402b106cf980b17cd9e506..7f79359fb2177f3c9d8a579da1300f1e0228f2e5 100644 (file)
@@ -254,18 +254,22 @@ MachineBasicBlock * R600TargetLowering::EmitInstrWithCustomInserter(
 void R600TargetLowering::lowerImplicitParameter(MachineInstr *MI, MachineBasicBlock &BB,
     MachineRegisterInfo & MRI, unsigned dword_offset) const
 {
+  unsigned ByteOffset = dword_offset * 4;
+
+  // We shouldn't be using an offset wider than 16-bits for implicit parameters.
+  assert(isInt<16>(ByteOffset));
+
   MachineBasicBlock::iterator I = *MI;
   unsigned PtrReg = MRI.createVirtualRegister(&AMDGPU::R600_TReg32_XRegClass);
   MRI.setRegClass(MI->getOperand(0).getReg(), &AMDGPU::R600_TReg32_XRegClass);
 
-  BuildMI(BB, I, BB.findDebugLoc(I), TII->get(AMDGPU::MOV), PtrReg)
-          .addReg(AMDGPU::ALU_LITERAL_X)
-          .addImm(dword_offset * 4);
+  BuildMI(BB, I, BB.findDebugLoc(I), TII->get(AMDGPU::COPY), PtrReg)
+          .addReg(AMDGPU::ZERO);
 
   BuildMI(BB, I, BB.findDebugLoc(I), TII->get(AMDGPU::VTX_READ_PARAM_i32_eg))
           .addOperand(MI->getOperand(0))
           .addReg(PtrReg)
-          .addImm(0);
+          .addImm(ByteOffset);
 }
 
 //===----------------------------------------------------------------------===//