Skip to content

Commit 628ea6d

Browse files
committed
Simplify MatrixTile[Vector]Operand decoding
1 parent 55d5172 commit 628ea6d

File tree

2 files changed

+53
-46
lines changed

2 files changed

+53
-46
lines changed

llvm/lib/Target/AArch64/AArch64RegisterInfo.td

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1875,16 +1875,15 @@ class MatrixTileAsmOperand<string RC, int EltSize> : AsmOperandClass {
18751875
# EltSize # ", AArch64::" # RC # "RegClassID>";
18761876
}
18771877

1878-
class MatrixTileOperand<int EltSize, int NumBitsForTile, RegisterClass RC>
1878+
class MatrixTileOperand<int EltSize, RegisterClass RC>
18791879
: RegisterOperand<RC> {
18801880
let ParserMatchClass = MatrixTileAsmOperand<!cast<string>(RC), EltSize>;
1881-
let DecoderMethod = "DecodeMatrixTile<" # NumBitsForTile # ">";
18821881
let PrintMethod = "printMatrixTile";
18831882
}
18841883

1885-
def TileOp16 : MatrixTileOperand<16, 1, MPR16>;
1886-
def TileOp32 : MatrixTileOperand<32, 2, MPR32>;
1887-
def TileOp64 : MatrixTileOperand<64, 3, MPR64>;
1884+
def TileOp16 : MatrixTileOperand<16, MPR16>;
1885+
def TileOp32 : MatrixTileOperand<32, MPR32>;
1886+
def TileOp64 : MatrixTileOperand<64, MPR64>;
18881887

18891888
//
18901889
// Tile vectors (horizontal and vertical)
@@ -1902,26 +1901,24 @@ class MatrixTileVectorAsmOperand<string RC, int EltSize, int IsVertical>
19021901
# EltSize # ", AArch64::" # RC # "RegClassID>";
19031902
}
19041903

1905-
class MatrixTileVectorOperand<int EltSize, int NumBitsForTile,
1906-
RegisterClass RC, int IsVertical>
1904+
class MatrixTileVectorOperand<int EltSize, RegisterClass RC, int IsVertical>
19071905
: RegisterOperand<RC> {
19081906
let ParserMatchClass = MatrixTileVectorAsmOperand<!cast<string>(RC), EltSize,
19091907
IsVertical>;
1910-
let DecoderMethod = "DecodeMatrixTile<" # NumBitsForTile # ">";
19111908
let PrintMethod = "printMatrixTileVector<" # IsVertical # ">";
19121909
}
19131910

1914-
def TileVectorOpH8 : MatrixTileVectorOperand< 8, 0, MPR8, 0>;
1915-
def TileVectorOpH16 : MatrixTileVectorOperand< 16, 1, MPR16, 0>;
1916-
def TileVectorOpH32 : MatrixTileVectorOperand< 32, 2, MPR32, 0>;
1917-
def TileVectorOpH64 : MatrixTileVectorOperand< 64, 3, MPR64, 0>;
1918-
def TileVectorOpH128 : MatrixTileVectorOperand<128, 4, MPR128, 0>;
1911+
def TileVectorOpH8 : MatrixTileVectorOperand< 8, MPR8, 0>;
1912+
def TileVectorOpH16 : MatrixTileVectorOperand< 16, MPR16, 0>;
1913+
def TileVectorOpH32 : MatrixTileVectorOperand< 32, MPR32, 0>;
1914+
def TileVectorOpH64 : MatrixTileVectorOperand< 64, MPR64, 0>;
1915+
def TileVectorOpH128 : MatrixTileVectorOperand<128, MPR128, 0>;
19191916

1920-
def TileVectorOpV8 : MatrixTileVectorOperand< 8, 0, MPR8, 1>;
1921-
def TileVectorOpV16 : MatrixTileVectorOperand< 16, 1, MPR16, 1>;
1922-
def TileVectorOpV32 : MatrixTileVectorOperand< 32, 2, MPR32, 1>;
1923-
def TileVectorOpV64 : MatrixTileVectorOperand< 64, 3, MPR64, 1>;
1924-
def TileVectorOpV128 : MatrixTileVectorOperand<128, 4, MPR128, 1>;
1917+
def TileVectorOpV8 : MatrixTileVectorOperand< 8, MPR8, 1>;
1918+
def TileVectorOpV16 : MatrixTileVectorOperand< 16, MPR16, 1>;
1919+
def TileVectorOpV32 : MatrixTileVectorOperand< 32, MPR32, 1>;
1920+
def TileVectorOpV64 : MatrixTileVectorOperand< 64, MPR64, 1>;
1921+
def TileVectorOpV128 : MatrixTileVectorOperand<128, MPR128, 1>;
19251922

19261923
//
19271924
// Accumulator matrix

llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -130,47 +130,57 @@ DecodeMatrixTileListRegisterClass(MCInst &Inst, unsigned RegMask,
130130
return Success;
131131
}
132132

133+
static DecodeStatus DecodeZTRRegisterClass(MCInst &Inst,
134+
const MCDisassembler *Decoder) {
135+
Inst.addOperand(MCOperand::createReg(AArch64::ZT0));
136+
return Success;
137+
}
138+
133139
static DecodeStatus DecodeMPRRegisterClass(MCInst &Inst,
134140
const MCDisassembler *Decoder) {
135141
Inst.addOperand(MCOperand::createReg(AArch64::ZA));
136142
return Success;
137143
}
138144

139-
static DecodeStatus DecodeZTRRegisterClass(MCInst &Inst,
140-
const MCDisassembler *Decoder) {
141-
Inst.addOperand(MCOperand::createReg(AArch64::ZT0));
145+
static DecodeStatus DecodeMPR8RegisterClass(MCInst &Inst,
146+
const MCDisassembler *Decoder) {
147+
Inst.addOperand(MCOperand::createReg(AArch64::ZAB0));
142148
return Success;
143149
}
144150

145-
static const MCPhysReg MatrixZATileDecoderTable[5][16] = {
146-
{AArch64::ZAB0},
147-
{AArch64::ZAH0, AArch64::ZAH1},
148-
{AArch64::ZAS0, AArch64::ZAS1, AArch64::ZAS2, AArch64::ZAS3},
149-
{AArch64::ZAD0, AArch64::ZAD1, AArch64::ZAD2, AArch64::ZAD3, AArch64::ZAD4,
150-
AArch64::ZAD5, AArch64::ZAD6, AArch64::ZAD7},
151-
{AArch64::ZAQ0, AArch64::ZAQ1, AArch64::ZAQ2, AArch64::ZAQ3, AArch64::ZAQ4,
152-
AArch64::ZAQ5, AArch64::ZAQ6, AArch64::ZAQ7, AArch64::ZAQ8, AArch64::ZAQ9,
153-
AArch64::ZAQ10, AArch64::ZAQ11, AArch64::ZAQ12, AArch64::ZAQ13,
154-
AArch64::ZAQ14, AArch64::ZAQ15}};
151+
static DecodeStatus DecodeMPR16RegisterClass(MCInst &Inst, unsigned RegNo,
152+
uint64_t Address,
153+
const MCDisassembler *Decoder) {
154+
MCRegister Reg =
155+
AArch64MCRegisterClasses[AArch64::MPR16RegClassID].getRegister(RegNo);
156+
Inst.addOperand(MCOperand::createReg(Reg));
157+
return Success;
158+
}
155159

156-
template <unsigned NumBitsForTile>
157-
static DecodeStatus DecodeMatrixTile(MCInst &Inst,
158-
const MCDisassembler *Decoder) {
159-
static_assert(NumBitsForTile == 0);
160-
Inst.addOperand(MCOperand::createReg(AArch64::ZAB0));
160+
static DecodeStatus DecodeMPR32RegisterClass(MCInst &Inst, unsigned RegNo,
161+
uint64_t Address,
162+
const MCDisassembler *Decoder) {
163+
MCRegister Reg =
164+
AArch64MCRegisterClasses[AArch64::MPR32RegClassID].getRegister(RegNo);
165+
Inst.addOperand(MCOperand::createReg(Reg));
161166
return Success;
162167
}
163168

164-
template <unsigned NumBitsForTile>
165-
static DecodeStatus DecodeMatrixTile(MCInst &Inst, unsigned RegNo,
166-
uint64_t Address,
167-
const MCDisassembler *Decoder) {
168-
static_assert(NumBitsForTile != 0);
169-
unsigned LastReg = (1 << NumBitsForTile) - 1;
170-
if (RegNo > LastReg)
171-
return Fail;
172-
Inst.addOperand(
173-
MCOperand::createReg(MatrixZATileDecoderTable[NumBitsForTile][RegNo]));
169+
static DecodeStatus DecodeMPR64RegisterClass(MCInst &Inst, unsigned RegNo,
170+
uint64_t Address,
171+
const MCDisassembler *Decoder) {
172+
MCRegister Reg =
173+
AArch64MCRegisterClasses[AArch64::MPR64RegClassID].getRegister(RegNo);
174+
Inst.addOperand(MCOperand::createReg(Reg));
175+
return Success;
176+
}
177+
178+
static DecodeStatus DecodeMPR128RegisterClass(MCInst &Inst, unsigned RegNo,
179+
uint64_t Address,
180+
const MCDisassembler *Decoder) {
181+
MCRegister Reg =
182+
AArch64MCRegisterClasses[AArch64::MPR128RegClassID].getRegister(RegNo);
183+
Inst.addOperand(MCOperand::createReg(Reg));
174184
return Success;
175185
}
176186

0 commit comments

Comments
 (0)