diff options
author | Sergei Barannikov <barannikov88@gmail.com> | 2025-09-05 16:16:49 +0300 |
---|---|---|
committer | Sergei Barannikov <barannikov88@gmail.com> | 2025-09-05 16:22:56 +0300 |
commit | 054fefc54c8e76c005fcf1c0dcb1cb376a2a0ee3 (patch) | |
tree | a9d1b255ae6062cdf2413214006b865dc2097c11 | |
parent | 31a9671e44e10894364bcebebd4d95b97b8f788a (diff) | |
download | llvm-users/s.barannikov/decoder-operands-6-aarch64-rest.zip llvm-users/s.barannikov/decoder-operands-6-aarch64-rest.tar.gz llvm-users/s.barannikov/decoder-operands-6-aarch64-rest.tar.bz2 |
Simplify MatrixTile[Vector]Operand decodingusers/s.barannikov/decoder-operands-6-aarch64-rest
-rw-r--r-- | llvm/lib/Target/AArch64/AArch64RegisterInfo.td | 33 | ||||
-rw-r--r-- | llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp | 66 |
2 files changed, 53 insertions, 46 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64RegisterInfo.td b/llvm/lib/Target/AArch64/AArch64RegisterInfo.td index 1a7609b..7320751 100644 --- a/llvm/lib/Target/AArch64/AArch64RegisterInfo.td +++ b/llvm/lib/Target/AArch64/AArch64RegisterInfo.td @@ -1878,16 +1878,15 @@ class MatrixTileAsmOperand<string RC, int EltSize> : AsmOperandClass { # EltSize # ", AArch64::" # RC # "RegClassID>"; } -class MatrixTileOperand<int EltSize, int NumBitsForTile, RegisterClass RC> +class MatrixTileOperand<int EltSize, RegisterClass RC> : RegisterOperand<RC> { let ParserMatchClass = MatrixTileAsmOperand<!cast<string>(RC), EltSize>; - let DecoderMethod = "DecodeMatrixTile<" # NumBitsForTile # ">"; let PrintMethod = "printMatrixTile"; } -def TileOp16 : MatrixTileOperand<16, 1, MPR16>; -def TileOp32 : MatrixTileOperand<32, 2, MPR32>; -def TileOp64 : MatrixTileOperand<64, 3, MPR64>; +def TileOp16 : MatrixTileOperand<16, MPR16>; +def TileOp32 : MatrixTileOperand<32, MPR32>; +def TileOp64 : MatrixTileOperand<64, MPR64>; // // Tile vectors (horizontal and vertical) @@ -1905,26 +1904,24 @@ class MatrixTileVectorAsmOperand<string RC, int EltSize, int IsVertical> # EltSize # ", AArch64::" # RC # "RegClassID>"; } -class MatrixTileVectorOperand<int EltSize, int NumBitsForTile, - RegisterClass RC, int IsVertical> +class MatrixTileVectorOperand<int EltSize, RegisterClass RC, int IsVertical> : RegisterOperand<RC> { let ParserMatchClass = MatrixTileVectorAsmOperand<!cast<string>(RC), EltSize, IsVertical>; - let DecoderMethod = "DecodeMatrixTile<" # NumBitsForTile # ">"; let PrintMethod = "printMatrixTileVector<" # IsVertical # ">"; } -def TileVectorOpH8 : MatrixTileVectorOperand< 8, 0, MPR8, 0>; -def TileVectorOpH16 : MatrixTileVectorOperand< 16, 1, MPR16, 0>; -def TileVectorOpH32 : MatrixTileVectorOperand< 32, 2, MPR32, 0>; -def TileVectorOpH64 : MatrixTileVectorOperand< 64, 3, MPR64, 0>; -def TileVectorOpH128 : MatrixTileVectorOperand<128, 4, MPR128, 0>; +def TileVectorOpH8 : MatrixTileVectorOperand< 8, MPR8, 0>; +def TileVectorOpH16 : MatrixTileVectorOperand< 16, MPR16, 0>; +def TileVectorOpH32 : MatrixTileVectorOperand< 32, MPR32, 0>; +def TileVectorOpH64 : MatrixTileVectorOperand< 64, MPR64, 0>; +def TileVectorOpH128 : MatrixTileVectorOperand<128, MPR128, 0>; -def TileVectorOpV8 : MatrixTileVectorOperand< 8, 0, MPR8, 1>; -def TileVectorOpV16 : MatrixTileVectorOperand< 16, 1, MPR16, 1>; -def TileVectorOpV32 : MatrixTileVectorOperand< 32, 2, MPR32, 1>; -def TileVectorOpV64 : MatrixTileVectorOperand< 64, 3, MPR64, 1>; -def TileVectorOpV128 : MatrixTileVectorOperand<128, 4, MPR128, 1>; +def TileVectorOpV8 : MatrixTileVectorOperand< 8, MPR8, 1>; +def TileVectorOpV16 : MatrixTileVectorOperand< 16, MPR16, 1>; +def TileVectorOpV32 : MatrixTileVectorOperand< 32, MPR32, 1>; +def TileVectorOpV64 : MatrixTileVectorOperand< 64, MPR64, 1>; +def TileVectorOpV128 : MatrixTileVectorOperand<128, MPR128, 1>; // // Accumulator matrix diff --git a/llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp b/llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp index 647a6a3..d4c883e 100644 --- a/llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp +++ b/llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp @@ -130,47 +130,57 @@ DecodeMatrixTileListRegisterClass(MCInst &Inst, unsigned RegMask, return Success; } +static DecodeStatus DecodeZTRRegisterClass(MCInst &Inst, + const MCDisassembler *Decoder) { + Inst.addOperand(MCOperand::createReg(AArch64::ZT0)); + return Success; +} + static DecodeStatus DecodeMPRRegisterClass(MCInst &Inst, const MCDisassembler *Decoder) { Inst.addOperand(MCOperand::createReg(AArch64::ZA)); return Success; } -static DecodeStatus DecodeZTRRegisterClass(MCInst &Inst, - const MCDisassembler *Decoder) { - Inst.addOperand(MCOperand::createReg(AArch64::ZT0)); +static DecodeStatus DecodeMPR8RegisterClass(MCInst &Inst, + const MCDisassembler *Decoder) { + Inst.addOperand(MCOperand::createReg(AArch64::ZAB0)); return Success; } -static const MCPhysReg MatrixZATileDecoderTable[5][16] = { - {AArch64::ZAB0}, - {AArch64::ZAH0, AArch64::ZAH1}, - {AArch64::ZAS0, AArch64::ZAS1, AArch64::ZAS2, AArch64::ZAS3}, - {AArch64::ZAD0, AArch64::ZAD1, AArch64::ZAD2, AArch64::ZAD3, AArch64::ZAD4, - AArch64::ZAD5, AArch64::ZAD6, AArch64::ZAD7}, - {AArch64::ZAQ0, AArch64::ZAQ1, AArch64::ZAQ2, AArch64::ZAQ3, AArch64::ZAQ4, - AArch64::ZAQ5, AArch64::ZAQ6, AArch64::ZAQ7, AArch64::ZAQ8, AArch64::ZAQ9, - AArch64::ZAQ10, AArch64::ZAQ11, AArch64::ZAQ12, AArch64::ZAQ13, - AArch64::ZAQ14, AArch64::ZAQ15}}; +static DecodeStatus DecodeMPR16RegisterClass(MCInst &Inst, unsigned RegNo, + uint64_t Address, + const MCDisassembler *Decoder) { + MCRegister Reg = + AArch64MCRegisterClasses[AArch64::MPR16RegClassID].getRegister(RegNo); + Inst.addOperand(MCOperand::createReg(Reg)); + return Success; +} -template <unsigned NumBitsForTile> -static DecodeStatus DecodeMatrixTile(MCInst &Inst, - const MCDisassembler *Decoder) { - static_assert(NumBitsForTile == 0); - Inst.addOperand(MCOperand::createReg(AArch64::ZAB0)); +static DecodeStatus DecodeMPR32RegisterClass(MCInst &Inst, unsigned RegNo, + uint64_t Address, + const MCDisassembler *Decoder) { + MCRegister Reg = + AArch64MCRegisterClasses[AArch64::MPR32RegClassID].getRegister(RegNo); + Inst.addOperand(MCOperand::createReg(Reg)); return Success; } -template <unsigned NumBitsForTile> -static DecodeStatus DecodeMatrixTile(MCInst &Inst, unsigned RegNo, - uint64_t Address, - const MCDisassembler *Decoder) { - static_assert(NumBitsForTile != 0); - unsigned LastReg = (1 << NumBitsForTile) - 1; - if (RegNo > LastReg) - return Fail; - Inst.addOperand( - MCOperand::createReg(MatrixZATileDecoderTable[NumBitsForTile][RegNo])); +static DecodeStatus DecodeMPR64RegisterClass(MCInst &Inst, unsigned RegNo, + uint64_t Address, + const MCDisassembler *Decoder) { + MCRegister Reg = + AArch64MCRegisterClasses[AArch64::MPR64RegClassID].getRegister(RegNo); + Inst.addOperand(MCOperand::createReg(Reg)); + return Success; +} + +static DecodeStatus DecodeMPR128RegisterClass(MCInst &Inst, unsigned RegNo, + uint64_t Address, + const MCDisassembler *Decoder) { + MCRegister Reg = + AArch64MCRegisterClasses[AArch64::MPR128RegClassID].getRegister(RegNo); + Inst.addOperand(MCOperand::createReg(Reg)); return Success; } |