forked from OSchip/llvm-project
				
			AMDGPU/GlobalISel: RegBankSelect DS GWS intrinsics
llvm-svn: 373840
This commit is contained in:
		
							parent
							
								
									bcd6b1d209
								
							
						
					
					
						commit
						c0ec72d4f8
					
				| 
						 | 
				
			
			@ -1823,6 +1823,21 @@ void AMDGPURegisterBankInfo::applyMappingImpl(
 | 
			
		|||
      constrainOpWithReadfirstlane(MI, MRI, 2); // M0
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
    case Intrinsic::amdgcn_ds_gws_init:
 | 
			
		||||
    case Intrinsic::amdgcn_ds_gws_barrier:
 | 
			
		||||
    case Intrinsic::amdgcn_ds_gws_sema_br: {
 | 
			
		||||
      // Only the first lane is executes, so readfirstlane is safe.
 | 
			
		||||
      substituteSimpleCopyRegs(OpdMapper, 1);
 | 
			
		||||
      constrainOpWithReadfirstlane(MI, MRI, 2); // M0
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
    case Intrinsic::amdgcn_ds_gws_sema_v:
 | 
			
		||||
    case Intrinsic::amdgcn_ds_gws_sema_p:
 | 
			
		||||
    case Intrinsic::amdgcn_ds_gws_sema_release_all: {
 | 
			
		||||
      // Only the first lane is executes, so readfirstlane is safe.
 | 
			
		||||
      constrainOpWithReadfirstlane(MI, MRI, 1); // M0
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
    case Intrinsic::amdgcn_s_sendmsg:
 | 
			
		||||
    case Intrinsic::amdgcn_s_sendmsghalt: {
 | 
			
		||||
      // FIXME: Should this use a waterfall loop?
 | 
			
		||||
| 
						 | 
				
			
			@ -2843,6 +2858,26 @@ AMDGPURegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
 | 
			
		|||
      OpdsMapping[2] = AMDGPU::getValueMapping(AMDGPU::SGPRRegBankID, Size);
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
    case Intrinsic::amdgcn_ds_gws_init:
 | 
			
		||||
    case Intrinsic::amdgcn_ds_gws_barrier:
 | 
			
		||||
    case Intrinsic::amdgcn_ds_gws_sema_br: {
 | 
			
		||||
      OpdsMapping[1] = AMDGPU::getValueMapping(AMDGPU::VGPRRegBankID, 32);
 | 
			
		||||
 | 
			
		||||
      // This must be an SGPR, but accept a VGPR.
 | 
			
		||||
      unsigned Bank = getRegBankID(MI.getOperand(2).getReg(), MRI, *TRI,
 | 
			
		||||
                                   AMDGPU::SGPRRegBankID);
 | 
			
		||||
      OpdsMapping[2] = AMDGPU::getValueMapping(Bank, 32);
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
    case Intrinsic::amdgcn_ds_gws_sema_v:
 | 
			
		||||
    case Intrinsic::amdgcn_ds_gws_sema_p:
 | 
			
		||||
    case Intrinsic::amdgcn_ds_gws_sema_release_all: {
 | 
			
		||||
      // This must be an SGPR, but accept a VGPR.
 | 
			
		||||
      unsigned Bank = getRegBankID(MI.getOperand(1).getReg(), MRI, *TRI,
 | 
			
		||||
                                   AMDGPU::SGPRRegBankID);
 | 
			
		||||
      OpdsMapping[1] = AMDGPU::getValueMapping(Bank, 32);
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
    default:
 | 
			
		||||
      if (const AMDGPU::RsrcIntrinsic *RSrcIntrin =
 | 
			
		||||
              AMDGPU::lookupRsrcIntrinsic(IntrID)) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,79 @@
 | 
			
		|||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
 | 
			
		||||
# RUN: llc -march=amdgcn -mcpu=fiji -run-pass=regbankselect -regbankselect-fast -verify-machineinstrs -o - %s | FileCheck %s
 | 
			
		||||
# RUN: llc -march=amdgcn -mcpu=fiji -run-pass=regbankselect -regbankselect-greedy -verify-machineinstrs -o - %s | FileCheck %s
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
name: ds_gws_init_s_s
 | 
			
		||||
legalized: true
 | 
			
		||||
tracksRegLiveness: true
 | 
			
		||||
 | 
			
		||||
body: |
 | 
			
		||||
  bb.0:
 | 
			
		||||
    liveins: $sgpr0, $sgpr1
 | 
			
		||||
    ; CHECK-LABEL: name: ds_gws_init_s_s
 | 
			
		||||
    ; CHECK: liveins: $sgpr0, $sgpr1
 | 
			
		||||
    ; CHECK: [[COPY:%[0-9]+]]:sgpr(s32) = COPY $sgpr0
 | 
			
		||||
    ; CHECK: [[COPY1:%[0-9]+]]:sgpr(s32) = COPY $sgpr1
 | 
			
		||||
    ; CHECK: [[COPY2:%[0-9]+]]:vgpr(s32) = COPY [[COPY]](s32)
 | 
			
		||||
    ; CHECK: G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.amdgcn.ds.gws.init), [[COPY2]](s32), [[COPY1]](s32)
 | 
			
		||||
    %0:_(s32) = COPY $sgpr0
 | 
			
		||||
    %1:_(s32) = COPY $sgpr1
 | 
			
		||||
    G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.amdgcn.ds.gws.init), %0, %1
 | 
			
		||||
...
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
name: ds_gws_init_s_v
 | 
			
		||||
legalized: true
 | 
			
		||||
tracksRegLiveness: true
 | 
			
		||||
 | 
			
		||||
body: |
 | 
			
		||||
  bb.0:
 | 
			
		||||
    liveins: $sgpr0, $vgpr0
 | 
			
		||||
    ; CHECK-LABEL: name: ds_gws_init_s_v
 | 
			
		||||
    ; CHECK: liveins: $sgpr0, $vgpr0
 | 
			
		||||
    ; CHECK: [[COPY:%[0-9]+]]:sgpr(s32) = COPY $sgpr0
 | 
			
		||||
    ; CHECK: [[COPY1:%[0-9]+]]:vgpr_32(s32) = COPY $vgpr0
 | 
			
		||||
    ; CHECK: [[COPY2:%[0-9]+]]:vgpr(s32) = COPY [[COPY]](s32)
 | 
			
		||||
    ; CHECK: [[V_READFIRSTLANE_B32_:%[0-9]+]]:sreg_32_xm0 = V_READFIRSTLANE_B32 [[COPY1]](s32), implicit $exec
 | 
			
		||||
    ; CHECK: G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.amdgcn.ds.gws.init), [[COPY2]](s32), [[V_READFIRSTLANE_B32_]]
 | 
			
		||||
    %0:_(s32) = COPY $sgpr0
 | 
			
		||||
    %1:_(s32) = COPY $vgpr0
 | 
			
		||||
    G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.amdgcn.ds.gws.init), %0, %1
 | 
			
		||||
...
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
name: ds_gws_init_v_s
 | 
			
		||||
legalized: true
 | 
			
		||||
tracksRegLiveness: true
 | 
			
		||||
 | 
			
		||||
body: |
 | 
			
		||||
  bb.0:
 | 
			
		||||
    liveins: $vgpr0, $sgpr0
 | 
			
		||||
    ; CHECK-LABEL: name: ds_gws_init_v_s
 | 
			
		||||
    ; CHECK: liveins: $vgpr0, $sgpr0
 | 
			
		||||
    ; CHECK: [[COPY:%[0-9]+]]:vgpr(s32) = COPY $vgpr0
 | 
			
		||||
    ; CHECK: [[COPY1:%[0-9]+]]:sgpr(s32) = COPY $sgpr0
 | 
			
		||||
    ; CHECK: G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.amdgcn.ds.gws.init), [[COPY]](s32), [[COPY1]](s32)
 | 
			
		||||
    %0:_(s32) = COPY $vgpr0
 | 
			
		||||
    %1:_(s32) = COPY $sgpr0
 | 
			
		||||
    G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.amdgcn.ds.gws.init), %0, %1
 | 
			
		||||
...
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
name: ds_gws_init_v_v
 | 
			
		||||
legalized: true
 | 
			
		||||
tracksRegLiveness: true
 | 
			
		||||
 | 
			
		||||
body: |
 | 
			
		||||
  bb.0:
 | 
			
		||||
    liveins: $vgpr0, $vgpr1
 | 
			
		||||
    ; CHECK-LABEL: name: ds_gws_init_v_v
 | 
			
		||||
    ; CHECK: liveins: $vgpr0, $vgpr1
 | 
			
		||||
    ; CHECK: [[COPY:%[0-9]+]]:vgpr(s32) = COPY $vgpr0
 | 
			
		||||
    ; CHECK: [[COPY1:%[0-9]+]]:vgpr_32(s32) = COPY $vgpr1
 | 
			
		||||
    ; CHECK: [[V_READFIRSTLANE_B32_:%[0-9]+]]:sreg_32_xm0 = V_READFIRSTLANE_B32 [[COPY1]](s32), implicit $exec
 | 
			
		||||
    ; CHECK: G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.amdgcn.ds.gws.init), [[COPY]](s32), [[V_READFIRSTLANE_B32_]]
 | 
			
		||||
    %0:_(s32) = COPY $vgpr0
 | 
			
		||||
    %1:_(s32) = COPY $vgpr1
 | 
			
		||||
    G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.amdgcn.ds.gws.init), %0, %1
 | 
			
		||||
...
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,37 @@
 | 
			
		|||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
 | 
			
		||||
# RUN: llc -march=amdgcn -mcpu=fiji -run-pass=regbankselect -regbankselect-fast -verify-machineinstrs -o - %s | FileCheck %s
 | 
			
		||||
# RUN: llc -march=amdgcn -mcpu=fiji -run-pass=regbankselect -regbankselect-greedy -verify-machineinstrs -o - %s | FileCheck %s
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
name: ds_gws_init_s
 | 
			
		||||
legalized: true
 | 
			
		||||
tracksRegLiveness: true
 | 
			
		||||
 | 
			
		||||
body: |
 | 
			
		||||
  bb.0:
 | 
			
		||||
    liveins: $sgpr0
 | 
			
		||||
    ; CHECK-LABEL: name: ds_gws_init_s
 | 
			
		||||
    ; CHECK: liveins: $sgpr0
 | 
			
		||||
    ; CHECK: [[COPY:%[0-9]+]]:sgpr(s32) = COPY $sgpr0
 | 
			
		||||
    ; CHECK: G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.amdgcn.ds.gws.sema.v), [[COPY]](s32)
 | 
			
		||||
    %0:_(s32) = COPY $sgpr0
 | 
			
		||||
    G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.amdgcn.ds.gws.sema.v), %0
 | 
			
		||||
...
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
name: ds_gws_init_v
 | 
			
		||||
legalized: true
 | 
			
		||||
tracksRegLiveness: true
 | 
			
		||||
 | 
			
		||||
body: |
 | 
			
		||||
  bb.0:
 | 
			
		||||
    liveins: $vgpr0
 | 
			
		||||
    ; CHECK-LABEL: name: ds_gws_init_v
 | 
			
		||||
    ; CHECK: liveins: $vgpr0
 | 
			
		||||
    ; CHECK: [[COPY:%[0-9]+]]:vgpr_32(s32) = COPY $vgpr0
 | 
			
		||||
    ; CHECK: [[V_READFIRSTLANE_B32_:%[0-9]+]]:sreg_32_xm0 = V_READFIRSTLANE_B32 [[COPY]](s32), implicit $exec
 | 
			
		||||
    ; CHECK: G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.amdgcn.ds.gws.sema.v), [[V_READFIRSTLANE_B32_]]
 | 
			
		||||
    %0:_(s32) = COPY $vgpr0
 | 
			
		||||
    G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.amdgcn.ds.gws.sema.v), %0
 | 
			
		||||
...
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue