summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2012-03-14 10:44:32 -0400
committerTom Stellard <thomas.stellard@amd.com>2012-03-14 11:41:41 -0400
commitad0d0f90ec1205089711a64ebe907722b44cc5f2 (patch)
treea32e537f7f7e8e26d1994298d52d3ea5b2221eb6 /src
parent3eeaca1ba3418629017afb7b50bdb0375747b537 (diff)
r600/llvm: Add instructions for reading global and local size
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/radeon/R600ISelLowering.cpp32
-rw-r--r--src/gallium/drivers/radeon/R600ISelLowering.h4
-rw-r--r--src/gallium/drivers/radeon/R600Instructions.td14
3 files changed, 41 insertions, 9 deletions
diff --git a/src/gallium/drivers/radeon/R600ISelLowering.cpp b/src/gallium/drivers/radeon/R600ISelLowering.cpp
index 0d45d7a0924..cc44f1a0f47 100644
--- a/src/gallium/drivers/radeon/R600ISelLowering.cpp
+++ b/src/gallium/drivers/radeon/R600ISelLowering.cpp
@@ -66,13 +66,31 @@ MachineBasicBlock * R600TargetLowering::EmitInstrWithCustomInserter(
lowerThreadIDInst(MI, MF, MRI, AMDIL::T0_Z);
break;
case AMDIL::NGROUPS_X:
- lowerNGROUPS(MI, *BB, MRI, 0);
+ lowerImplicitParameter(MI, *BB, MRI, 0);
break;
case AMDIL::NGROUPS_Y:
- lowerNGROUPS(MI, *BB, MRI, 1);
+ lowerImplicitParameter(MI, *BB, MRI, 1);
break;
- case AMDIL::NGROUPS_Z:
- lowerNGROUPS(MI, *BB, MRI, 2);
+ case AMDIL::NGROUPS_Z:
+ lowerImplicitParameter(MI, *BB, MRI, 2);
+ break;
+ case AMDIL::GLOBAL_SIZE_X:
+ lowerImplicitParameter(MI, *BB, MRI, 3);
+ break;
+ case AMDIL::GLOBAL_SIZE_Y:
+ lowerImplicitParameter(MI, *BB, MRI, 4);
+ break;
+ case AMDIL::GLOBAL_SIZE_Z:
+ lowerImplicitParameter(MI, *BB, MRI, 5);
+ break;
+ case AMDIL::LOCAL_SIZE_X:
+ lowerImplicitParameter(MI, *BB, MRI, 6);
+ break;
+ case AMDIL::LOCAL_SIZE_Y:
+ lowerImplicitParameter(MI, *BB, MRI, 7);
+ break;
+ case AMDIL::LOCAL_SIZE_Z:
+ lowerImplicitParameter(MI, *BB, MRI, 8);
break;
}
MI->eraseFromParent();
@@ -88,8 +106,8 @@ void R600TargetLowering::lowerThreadIDInst(MachineInstr * MI,
.addReg(reg);
}
-void R600TargetLowering::lowerNGROUPS(MachineInstr *MI, MachineBasicBlock &BB,
- MachineRegisterInfo & MRI, unsigned dim) const
+void R600TargetLowering::lowerImplicitParameter(MachineInstr *MI, MachineBasicBlock &BB,
+ MachineRegisterInfo & MRI, unsigned dword_offset) const
{
MachineBasicBlock::iterator I = *MI;
unsigned offsetReg = MRI.createVirtualRegister(&AMDIL::R600_TReg32_XRegClass);
@@ -97,7 +115,7 @@ void R600TargetLowering::lowerNGROUPS(MachineInstr *MI, MachineBasicBlock &BB,
BuildMI(BB, I, BB.findDebugLoc(I), TII->get(AMDIL::MOV), offsetReg)
.addReg(AMDIL::ALU_LITERAL_X)
- .addImm(dim * 4);
+ .addImm(dword_offset * 4);
BuildMI(BB, I, BB.findDebugLoc(I), TII->get(AMDIL::VTX_READ_eg))
.addOperand(MI->getOperand(0))
diff --git a/src/gallium/drivers/radeon/R600ISelLowering.h b/src/gallium/drivers/radeon/R600ISelLowering.h
index fcc82027cd7..9ec13edd5ac 100644
--- a/src/gallium/drivers/radeon/R600ISelLowering.h
+++ b/src/gallium/drivers/radeon/R600ISelLowering.h
@@ -46,8 +46,8 @@ private:
void lowerThreadIDInst(MachineInstr * MI, MachineFunction * MF,
MachineRegisterInfo & MRI, unsigned reg) const;
- void lowerNGROUPS(MachineInstr *MI, MachineBasicBlock &BB,
- MachineRegisterInfo & MRI, unsigned dim) const;
+ void lowerImplicitParameter(MachineInstr *MI, MachineBasicBlock &BB,
+ MachineRegisterInfo & MRI, unsigned dword_offset) const;
};
diff --git a/src/gallium/drivers/radeon/R600Instructions.td b/src/gallium/drivers/radeon/R600Instructions.td
index f38bcb8e8de..8c22aaea096 100644
--- a/src/gallium/drivers/radeon/R600Instructions.td
+++ b/src/gallium/drivers/radeon/R600Instructions.td
@@ -897,6 +897,20 @@ def NGROUPS_X : R600PreloadInst <"NGROUPS_X", int_r600_read_ngroups_x>;
def NGROUPS_Y : R600PreloadInst <"NGROUPS_Y", int_r600_read_ngroups_y>;
def NGROUPS_Z : R600PreloadInst <"NGROUPS_Z", int_r600_read_ngroups_z>;
+def GLOBAL_SIZE_X : R600PreloadInst <"GLOBAL_SIZE_X",
+ int_r600_read_global_size_x>;
+def GLOBAL_SIZE_Y : R600PreloadInst <"GLOBAL_SIZE_Y",
+ int_r600_read_global_size_y>;
+def GLOBAL_SIZE_Z : R600PreloadInst <"GLOBAL_SIZE_Z",
+ int_r600_read_global_size_z>;
+
+def LOCAL_SIZE_X : R600PreloadInst <"LOCAL_SIZE_X",
+ int_r600_read_local_size_x>;
+def LOCAL_SIZE_Y : R600PreloadInst <"LOCAL_SIZE_Y",
+ int_r600_read_local_size_y>;
+def LOCAL_SIZE_Z : R600PreloadInst <"LOCAL_SIZE_Z",
+ int_r600_read_local_size_z>;
+
} // End usesCustomInserter = 1, isPseudo = 1
} // End isCodeGenOnly = 1