Index: lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp =================================================================== --- lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp +++ lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp @@ -66,10 +66,12 @@ DECODE_OPERAND(VReg_96) DECODE_OPERAND(VReg_128) +DECODE_OPERAND(SGPR_32) DECODE_OPERAND(SReg_32) DECODE_OPERAND(SReg_64) DECODE_OPERAND(SReg_128) DECODE_OPERAND(SReg_256) +DECODE_OPERAND(SReg_512) #define GET_SUBTARGETINFO_ENUM #include "AMDGPUGenSubtargetInfo.inc" Index: lib/Target/AMDGPU/SIInstrFormats.td =================================================================== --- lib/Target/AMDGPU/SIInstrFormats.td +++ lib/Target/AMDGPU/SIInstrFormats.td @@ -227,9 +227,7 @@ class SMRDe op, bits<1> imm> : Enc32 { bits<7> sdst; bits<7> sbase; - bits<8> offset; - let Inst{7-0} = offset; let Inst{8} = imm; let Inst{14-9} = sbase{6-1}; let Inst{21-15} = sdst; @@ -237,6 +235,18 @@ let Inst{31-27} = 0x18; //encoding } +class SMRD_IMMe op> : SMRDe { + bits<8> offset; + let Inst{7-0} = offset; +} + +class SMRD_SOFFe op> : SMRDe { + bits<8> soff; + let Inst{7-0} = soff; +} + + + class SMRD_IMMe_ci op> : Enc64 { bits<7> sdst; bits<7> sbase; Index: lib/Target/AMDGPU/SIInstrInfo.td =================================================================== --- lib/Target/AMDGPU/SIInstrInfo.td +++ lib/Target/AMDGPU/SIInstrInfo.td @@ -1047,53 +1047,88 @@ let isCodeGenOnly = 1; } -class SMRD_Real_si op, string opName, bit imm, dag outs, dag ins, - string asm> : +class SMRD_IMM_Real_si op, string opName, dag outs, dag ins, + string asm> : + SMRD , + SMRD_IMMe , + SIMCInstr { + let AssemblerPredicates = [isSICI]; + let DecoderNamespace = "SICI"; + let DisableDecoder = DisableSIDecoder; +} + +class SMRD_SOFF_Real_si op, string opName, dag outs, dag ins, + string asm> : SMRD , - SMRDe , + SMRD_SOFFe , SIMCInstr { let AssemblerPredicates = [isSICI]; let DecoderNamespace = "SICI"; let DisableDecoder = DisableSIDecoder; } -class SMRD_Real_vi op, string opName, bit imm, dag outs, dag ins, - string asm, list pattern = []> : + +class SMRD_IMM_Real_vi op, string opName, dag outs, dag ins, + string asm, list pattern = []> : + SMRD , + SMEM_IMMe_vi , + SIMCInstr { + let AssemblerPredicates = [isVI]; + let DecoderNamespace = "VI"; + let DisableDecoder = DisableVIDecoder; +} + +class SMRD_SOFF_Real_vi op, string opName, dag outs, dag ins, + string asm, list pattern = []> : SMRD , - SMEMe_vi , + SMEM_SOFFe_vi , SIMCInstr { let AssemblerPredicates = [isVI]; let DecoderNamespace = "VI"; let DisableDecoder = DisableVIDecoder; } -multiclass SMRD_m pattern> { def "" : SMRD_Pseudo ; - def _si : SMRD_Real_si ; + def _si : SMRD_IMM_Real_si ; + + // glc is only applicable to scalar stores, which are not yet + // implemented. + let glc = 0 in { + def _vi : SMRD_IMM_Real_vi ; + } +} + +multiclass SMRD_SOFF_m pattern> { + + def "" : SMRD_Pseudo ; + + def _si : SMRD_SOFF_Real_si ; // glc is only applicable to scalar stores, which are not yet // implemented. let glc = 0 in { - def _vi : SMRD_Real_vi ; + def _vi : SMRD_SOFF_Real_vi ; } } multiclass SMRD_Special pattern = []> { let hasSideEffects = 1 in { def "" : SMRD_Pseudo ; - let sbase = 0, offset = 0 in { - let sdst = 0 in { - def _si : SMRD_Real_si ; - } + let sbase = 0, soff = 0, sdst = sdst_ in { + def _si : SMRD_SOFF_Real_si ; - let glc = 0, sdata = 0 in { - def _vi : SMRD_Real_vi ; + let glc = 0 in { + def _vi : SMRD_SOFF_Real_vi ; } } } @@ -1102,51 +1137,50 @@ multiclass SMRD_Inval { let mayStore = 1 in { - defm : SMRD_Special; + defm : SMRD_Special; } } class SMEM_Inval op, string opName, SDPatternOperator node> : - SMRD_Real_vi { + SMRD_SOFF_Real_vi { let hasSideEffects = 1; let mayStore = 1; let sbase = 0; - let sdata = 0; + let sdst = 0; let glc = 0; - let offset = 0; + let soff = 0; } class SMEM_Ret op, string opName, SDPatternOperator node> : - SMRD_Real_vi { + SMRD_SOFF_Real_vi { let hasSideEffects = 1; let mayStore = ?; let mayLoad = ?; let sbase = 0; - let sdata = 0; let glc = 0; - let offset = 0; + let soff = 0; } multiclass SMRD_Helper { - defm _IMM : SMRD_m < - op, opName#"_IMM", 1, (outs dstClass:$dst), + defm _IMM : SMRD_IMM_m < + op, opName#"_IMM", (outs dstClass:$sdst), (ins baseClass:$sbase, smrd_offset:$offset), - opName#" $dst, $sbase, $offset", [] + opName#" $sdst, $sbase, $offset", [] >; def _IMM_ci : SMRD < - (outs dstClass:$dst), (ins baseClass:$sbase, smrd_literal_offset:$offset), - opName#" $dst, $sbase, $offset", []>, SMRD_IMMe_ci { + (outs dstClass:$sdst), (ins baseClass:$sbase, smrd_literal_offset:$offset), + opName#" $sdst, $sbase, $offset", []>, SMRD_IMMe_ci { let AssemblerPredicates = [isCIOnly]; let DecoderNamespace = "CI"; } - defm _SGPR : SMRD_m < - op, opName#"_SGPR", 0, (outs dstClass:$dst), + defm _SGPR : SMRD_SOFF_m < + op, opName#"_SGPR", (outs dstClass:$sdst), (ins baseClass:$sbase, SReg_32:$soff), - opName#" $dst, $sbase, $soff", [] + opName#" $sdst, $sbase, $soff", [] >; } Index: lib/Target/AMDGPU/SIInstructions.td =================================================================== --- lib/Target/AMDGPU/SIInstructions.td +++ lib/Target/AMDGPU/SIInstructions.td @@ -94,7 +94,7 @@ // Pat. Each considers the other contradictory. defm S_MEMTIME : SMRD_Special , "s_memtime", - (outs SReg_64:$dst), " $dst", [(set i64:$dst, (int_amdgcn_s_memtime))] + (outs SReg_64:$sdst), ?, " $sdst", [(set i64:$sdst, (int_amdgcn_s_memtime))] >; } Index: lib/Target/AMDGPU/VIInstrFormats.td =================================================================== --- lib/Target/AMDGPU/VIInstrFormats.td +++ lib/Target/AMDGPU/VIInstrFormats.td @@ -91,19 +91,27 @@ class SMEMe_vi op, bit imm> : Enc64 { bits<7> sbase; - bits<7> sdata; + bits<7> sdst; bits<1> glc; - bits<20> offset; let Inst{5-0} = sbase{6-1}; - let Inst{12-6} = sdata; + let Inst{12-6} = sdst; let Inst{16} = glc; let Inst{17} = imm; let Inst{25-18} = op; let Inst{31-26} = 0x30; //encoding +} + +class SMEM_IMMe_vi op> : SMEMe_vi { + bits<20> offset; let Inst{51-32} = offset; } +class SMEM_SOFFe_vi op> : SMEMe_vi { + bits<20> soff; + let Inst{51-32} = soff; +} + class VOP3a_vi op> : Enc64 { bits<2> src0_modifiers; bits<9> src0; Index: test/MC/AMDGPU/smrd.s =================================================================== --- test/MC/AMDGPU/smrd.s +++ test/MC/AMDGPU/smrd.s @@ -1,21 +1,27 @@ // RUN: not llvm-mc -arch=amdgcn -show-encoding %s | FileCheck --check-prefix=GCN --check-prefix=SI %s // RUN: not llvm-mc -arch=amdgcn -mcpu=SI -show-encoding %s | FileCheck --check-prefix=GCN --check-prefix=SI %s // RUN: llvm-mc -arch=amdgcn -mcpu=bonaire -show-encoding %s | FileCheck --check-prefix=GCN --check-prefix=CI %s +// RUN: not llvm-mc -arch=amdgcn -mcpu=fiji -show-encoding %s | FileCheck --check-prefix=VI %s // RUN: not llvm-mc -arch=amdgcn %s 2>&1 | FileCheck %s --check-prefix=NOSI // RUN: not llvm-mc -arch=amdgcn -mcpu=SI %s 2>&1 | FileCheck %s --check-prefix=NOSI +// RUN: not llvm-mc -arch=amdgcn -mcpu=fiji %s 2>&1 | FileCheck %s --check-prefix=NOVI + //===----------------------------------------------------------------------===// // Offset Handling //===----------------------------------------------------------------------===// s_load_dword s1, s[2:3], 0xfc // GCN: s_load_dword s1, s[2:3], 0xfc ; encoding: [0xfc,0x83,0x00,0xc0] +// VI: s_load_dword s1, s[2:3], 0xfc ; encoding: [0x41,0x00,0x02,0xc0,0xfc,0x00,0x00,0x00] s_load_dword s1, s[2:3], 0xff // GCN: s_load_dword s1, s[2:3], 0xff ; encoding: [0xff,0x83,0x00,0xc0] +// VI: s_load_dword s1, s[2:3], 0xff ; encoding: [0x41,0x00,0x02,0xc0,0xff,0x00,0x00,0x00] s_load_dword s1, s[2:3], 0x100 // NOSI: error: instruction not supported on this GPU +// NOVI: error: instruction not supported on this GPU // CI: s_load_dword s1, s[2:3], 0x100 ; encoding: [0xff,0x82,0x00,0xc0,0x00,0x01,0x00,0x00] //===----------------------------------------------------------------------===// @@ -24,49 +30,65 @@ s_load_dword s1, s[2:3], 1 // GCN: s_load_dword s1, s[2:3], 0x1 ; encoding: [0x01,0x83,0x00,0xc0] +// VI: s_load_dword s1, s[2:3], 0x1 ; encoding: [0x41,0x00,0x02,0xc0,0x01,0x00,0x00,0x00] s_load_dword s1, s[2:3], s4 // GCN: s_load_dword s1, s[2:3], s4 ; encoding: [0x04,0x82,0x00,0xc0] +// VI: s_load_dword s1, s[2:3], s4 ; encoding: [0x41,0x00,0x00,0xc0,0x04,0x00,0x00,0x00] s_load_dwordx2 s[2:3], s[2:3], 1 // GCN: s_load_dwordx2 s[2:3], s[2:3], 0x1 ; encoding: [0x01,0x03,0x41,0xc0] +// VI: s_load_dwordx2 s[2:3], s[2:3], 0x1 ; encoding: [0x81,0x00,0x06,0xc0,0x01,0x00,0x00,0x00] s_load_dwordx2 s[2:3], s[2:3], s4 // GCN: s_load_dwordx2 s[2:3], s[2:3], s4 ; encoding: [0x04,0x02,0x41,0xc0] +// VI: s_load_dwordx2 s[2:3], s[2:3], s4 ; encoding: [0x81,0x00,0x04,0xc0,0x04,0x00,0x00,0x00] s_load_dwordx4 s[4:7], s[2:3], 1 // GCN: s_load_dwordx4 s[4:7], s[2:3], 0x1 ; encoding: [0x01,0x03,0x82,0xc0] +// VI: s_load_dwordx4 s[4:7], s[2:3], 0x1 ; encoding: [0x01,0x01,0x0a,0xc0,0x01,0x00,0x00,0x00] s_load_dwordx4 s[4:7], s[2:3], s4 // GCN: s_load_dwordx4 s[4:7], s[2:3], s4 ; encoding: [0x04,0x02,0x82,0xc0] +// VI: s_load_dwordx4 s[4:7], s[2:3], s4 ; encoding: [0x01,0x01,0x08,0xc0,0x04,0x00,0x00,0x00] s_load_dwordx4 s[100:103], s[2:3], s4 // GCN: s_load_dwordx4 s[100:103], s[2:3], s4 ; encoding: [0x04,0x02,0xb2,0xc0] +// NOVI: error: invalid operand for instruction s_load_dwordx8 s[8:15], s[2:3], 1 // GCN: s_load_dwordx8 s[8:15], s[2:3], 0x1 ; encoding: [0x01,0x03,0xc4,0xc0] +// VI: s_load_dwordx8 s[8:15], s[2:3], 0x1 ; encoding: [0x01,0x02,0x0e,0xc0,0x01,0x00,0x00,0x00] s_load_dwordx8 s[8:15], s[2:3], s4 // GCN: s_load_dwordx8 s[8:15], s[2:3], s4 ; encoding: [0x04,0x02,0xc4,0xc0] +// VI: s_load_dwordx8 s[8:15], s[2:3], s4 ; encoding: [0x01,0x02,0x0c,0xc0,0x04,0x00,0x00,0x00] s_load_dwordx8 s[96:103], s[2:3], s4 // GCN: s_load_dwordx8 s[96:103], s[2:3], s4 ; encoding: [0x04,0x02,0xf0,0xc0] +// NOVI: error: invalid operand for instruction s_load_dwordx16 s[16:31], s[2:3], 1 // GCN: s_load_dwordx16 s[16:31], s[2:3], 0x1 ; encoding: [0x01,0x03,0x08,0xc1] +// VI: s_load_dwordx16 s[16:31], s[2:3], 0x1 ; encoding: [0x01,0x04,0x12,0xc0,0x01,0x00,0x00,0x00] s_load_dwordx16 s[16:31], s[2:3], s4 // GCN: s_load_dwordx16 s[16:31], s[2:3], s4 ; encoding: [0x04,0x02,0x08,0xc1] +// VI: s_load_dwordx16 s[16:31], s[2:3], s4 ; encoding: [0x01,0x04,0x10,0xc0,0x04,0x00,0x00,0x00] s_load_dwordx16 s[88:103], s[2:3], s4 // GCN: s_load_dwordx16 s[88:103], s[2:3], s4 ; encoding: [0x04,0x02,0x2c,0xc1] +// NOVI: error: invalid operand for instruction s_dcache_inv // GCN: s_dcache_inv ; encoding: [0x00,0x00,0xc0,0xc7] +// VI: s_dcache_inv ; encoding: [0x00,0x00,0x80,0xc0,0x00,0x00,0x00,0x00] s_dcache_inv_vol // CI: s_dcache_inv_vol ; encoding: [0x00,0x00,0x40,0xc7] // NOSI: error: instruction not supported on this GPU +// VI: s_dcache_inv_vol ; encoding: [0x00,0x00,0x88,0xc0,0x00,0x00,0x00,0x00] s_memtime s[0:1] // GCN: s_memtime s[0:1] ; encoding: [0x00,0x00,0x80,0xc7] +// VI: s_memtime s[0:1] ; encoding: [0x00,0x00,0x90,0xc0,0x00,0x00,0x00,0x00] Index: test/MC/Disassembler/AMDGPU/smrd_vi.txt =================================================================== --- /dev/null +++ test/MC/Disassembler/AMDGPU/smrd_vi.txt @@ -0,0 +1,40 @@ +# RUN: llvm-mc -arch=amdgcn -mcpu=fiji -disassemble -show-encoding < %s | FileCheck %s -check-prefix=VI + +# VI: s_load_dword s1, s[2:3], 0x1 ; encoding: [0x41,0x00,0x02,0xc0,0x01,0x00,0x00,0x00] +0x41 0x00 0x02 0xc0 0x01 0x00 0x00 0x00 + +# VI: s_load_dword s1, s[2:3], s4 ; encoding: [0x41,0x00,0x00,0xc0,0x04,0x00,0x00,0x00] +0x41 0x00 0x00 0xc0 0x04 0x00 0x00 0x00 + +# VI: s_load_dwordx2 s[2:3], s[2:3], 0x1 ; encoding: [0x81,0x00,0x06,0xc0,0x01,0x00,0x00,0x00] +0x81 0x00 0x06 0xc0 0x01 0x00 0x00 0x00 + +# VI: s_load_dwordx2 s[2:3], s[2:3], s4 ; encoding: [0x81,0x00,0x04,0xc0,0x04,0x00,0x00,0x00] +0x81 0x00 0x04 0xc0 0x04 0x00 0x00 0x00 + +# VI: s_load_dwordx4 s[4:7], s[2:3], 0x1 ; encoding: [0x01,0x01,0x0a,0xc0,0x01,0x00,0x00,0x00] +0x01 0x01 0x0a 0xc0 0x01 0x00 0x00 0x00 + +# VI: s_load_dwordx4 s[4:7], s[2:3], s4 ; encoding: [0x01,0x01,0x08,0xc0,0x04,0x00,0x00,0x00] +0x01 0x01 0x08 0xc0 0x04 0x00 0x00 0x00 + +# VI: s_load_dwordx8 s[8:15], s[2:3], 0x1 ; encoding: [0x01,0x02,0x0e,0xc0,0x01,0x00,0x00,0x00] +0x01 0x02 0x0e 0xc0 0x01 0x00 0x00 0x00 + +# VI: s_load_dwordx8 s[8:15], s[2:3], s4 ; encoding: [0x01,0x02,0x0c,0xc0,0x04,0x00,0x00,0x00] +0x01 0x02 0x0c 0xc0 0x04 0x00 0x00 0x00 + +# VI: s_load_dwordx16 s[16:31], s[2:3], 0x1 ; encoding: [0x01,0x04,0x12,0xc0,0x01,0x00,0x00,0x00] +0x01 0x04 0x12 0xc0 0x01 0x00 0x00 0x00 + +# VI: s_load_dwordx16 s[16:31], s[2:3], s4 ; encoding: [0x01,0x04,0x10,0xc0,0x04,0x00,0x00,0x00] +0x01 0x04 0x10 0xc0 0x04 0x00 0x00 0x00 + +# VI: s_dcache_inv ; encoding: [0x00,0x00,0x80,0xc0,0x00,0x00,0x00,0x00] +0x00 0x00 0x80 0xc0 0x00 0x00 0x00 0x00 + +# VI: s_dcache_inv_vol ; encoding: [0x00,0x00,0x88,0xc0,0x00,0x00,0x00,0x00] +0x00 0x00 0x88 0xc0 0x00 0x00 0x00 0x00 + +# VI: s_memtime s[0:1] ; encoding: [0x00,0x00,0x90,0xc0,0x00,0x00,0x00,0x00] +0x00 0x00 0x90 0xc0 0x00 0x00 0x00 0x00