Index: llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp =================================================================== --- llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp +++ llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp @@ -6255,6 +6255,7 @@ void AMDGPUAsmParser::cvtDSImpl(MCInst &Inst, const OperandVector &Operands, bool IsGdsHardcoded) { OptionalImmIndexMap OptionalIdx; + AMDGPUOperand::ImmTy OffsetType = AMDGPUOperand::ImmTyOffset; for (unsigned i = 1, e = Operands.size(); i != e; ++i) { AMDGPUOperand &Op = ((AMDGPUOperand &)*Operands[i]); @@ -6272,13 +6273,10 @@ // Handle optional arguments OptionalIdx[Op.getImmTy()] = i; - } - AMDGPUOperand::ImmTy OffsetType = - (Inst.getOpcode() == AMDGPU::DS_SWIZZLE_B32_gfx10 || - Inst.getOpcode() == AMDGPU::DS_SWIZZLE_B32_gfx6_gfx7 || - Inst.getOpcode() == AMDGPU::DS_SWIZZLE_B32_vi) ? AMDGPUOperand::ImmTySwizzle : - AMDGPUOperand::ImmTyOffset; + if (Op.getImmTy() == AMDGPUOperand::ImmTySwizzle) + OffsetType = AMDGPUOperand::ImmTySwizzle; + } addOptionalImmOperand(Inst, Operands, OptionalIdx, OffsetType); Index: llvm/test/MC/AMDGPU/gfx11_ds.s =================================================================== --- llvm/test/MC/AMDGPU/gfx11_ds.s +++ llvm/test/MC/AMDGPU/gfx11_ds.s @@ -125,3 +125,30 @@ ds_sub_gs_reg_rtn v[5:6], v255 gds // GFX11: encoding: [0x00,0x00,0xee,0xd9,0x00,0xff,0x00,0x05] + +ds_swizzle_b32 v8, v2 +// GFX11: encoding: [0x00,0x00,0xd4,0xd8,0x02,0x00,0x00,0x08] + +ds_swizzle_b32 v8, v2 offset:0 +// GFX11: encoding: [0x00,0x00,0xd4,0xd8,0x02,0x00,0x00,0x08] + +ds_swizzle_b32 v8, v2 offset:0xFFFF +// GFX11: encoding: [0xff,0xff,0xd4,0xd8,0x02,0x00,0x00,0x08] + +ds_swizzle_b32 v8, v2 offset:swizzle(QUAD_PERM, 0, 1, 2, 3) +// GFX11: encoding: [0xe4,0x80,0xd4,0xd8,0x02,0x00,0x00,0x08] + +ds_swizzle_b32 v8, v2 offset:swizzle(SWAP,16) +// GFX11: encoding: [0x1f,0x40,0xd4,0xd8,0x02,0x00,0x00,0x08] + +ds_swizzle_b32 v8, v2 offset:swizzle(REVERSE,8) +// GFX11: encoding: [0x1f,0x1c,0xd4,0xd8,0x02,0x00,0x00,0x08] + +ds_swizzle_b32 v8, v2 offset:swizzle(BROADCAST,4,1) +// GFX11: encoding: [0x3c,0x00,0xd4,0xd8,0x02,0x00,0x00,0x08] + +ds_swizzle_b32 v8, v2 offset:swizzle(BROADCAST,8,7) +// GFX11: encoding: [0xf8,0x00,0xd4,0xd8,0x02,0x00,0x00,0x08] + +ds_swizzle_b32 v8, v2 offset:swizzle(BITMASK_PERM, "01pip") +// GFX11: encoding: [0x07,0x09,0xd4,0xd8,0x02,0x00,0x00,0x08] Index: llvm/test/MC/Disassembler/AMDGPU/ds_gfx11.txt =================================================================== --- llvm/test/MC/Disassembler/AMDGPU/ds_gfx11.txt +++ llvm/test/MC/Disassembler/AMDGPU/ds_gfx11.txt @@ -3817,6 +3817,18 @@ # GFX11: ds_swizzle_b32 v5, v1 offset:swizzle(BITMASK_PERM,"00p00") ; encoding: [0x04,0x00,0xd4,0xd8,0x01,0x00,0x00,0x05] 0x04,0x00,0xd4,0xd8,0x01,0x00,0x00,0x05 +# GFX11: ds_swizzle_b32 v8, v2 offset:swizzle(QUAD_PERM,0,1,2,3) ; encoding: [0xe4,0x80,0xd4,0xd8,0x02,0x00,0x00,0x08] +0xe4,0x80,0xd4,0xd8,0x02,0x00,0x00,0x08 + +# GFX11: ds_swizzle_b32 v8, v2 offset:swizzle(SWAP,4) ; encoding: [0x1f,0x10,0xd4,0xd8,0x02,0x00,0x00,0x08] +0x1f,0x10,0xd4,0xd8,0x02,0x00,0x00,0x08 + +# GFX11: ds_swizzle_b32 v8, v2 offset:swizzle(REVERSE,16) ; encoding: [0x1f,0x3c,0xd4,0xd8,0x02,0x00,0x00,0x08] +0x1f,0x3c,0xd4,0xd8,0x02,0x00,0x00,0x08 + +# GFX11: ds_swizzle_b32 v8, v2 offset:swizzle(BROADCAST,32,1) ; encoding: [0x20,0x00,0xd4,0xd8,0x02,0x00,0x00,0x08] +0x20,0x00,0xd4,0xd8,0x02,0x00,0x00,0x08 + # GFX11: ds_swizzle_b32 v5, v255 offset:65535 ; encoding: [0xff,0xff,0xd4,0xd8,0xff,0x00,0x00,0x05] 0xff,0xff,0xd4,0xd8,0xff,0x00,0x00,0x05