Hi,
this is my first attempt on improve our td instruction definitions.
- All DS related definitions are moved to the new DSInstructions.td. This is done to reduce the number of definitions we currently have in a single td file.
- Multiclasses that define Pseudo, SI and VI instructions are removed. Instead there is DS_Pseudo instruction that is supposed to handle all CodeGen related things and carry some hint flags for MC layer things. It's counterpart DS_Real copies relevant data from origin DS_Pseudo. So typical definition consist of two stages:
// CodeGen part - DSInstructions.td
DS_INSTRUCTION : DS_PSEUDO<"DS_MNEMONIC", outs, ins, asmString>
// Assembler, disassembler, encoding part
// SIInstructions.td
DS_INSTRUCTION_si : DS_REAL < 0x123 /* SI opcode */, DS_INSTRUCTION /* origin pseudo op*/ >;
// VIInstructions.td
DS_INSTRUCTION_vi : DS_REAL < 0x456 /* VI opcode */, DS_INSTRUCTION /* origin pseudo op*/ >;
Having these things split allows to:
- Simplify codegen related definitions and pseudo ops
- No dummy "real" instructions. Previously if we had to define new VI instruction it created dummy SI instruction with 0 opcode.
- Workaround flags such like DisableSIDecoder/DisableVIDecoder can be removed.
- having all real instructions groupped the same way allows easily diff subtarget td files.
- we can change real instruction naming to prefixing it with subtarget tag (example: DS_INST_SI to SI_DS_INST) so that all subtarget opcodes are groupped together. This would allow to use direct translation table PseudoOp <-> RealOp. Currently there're log N translation map.
- I'm also thinking about the possibility to split subtarget generated tables so that there're no mixed subtarget instructions. This would allow to avoid subtarget predicate checks.
Currently I broke the following tests but I'll fix them tomorrow:
LLVM :: CodeGen/AMDGPU/amdgpu.private-memory.ll LLVM :: CodeGen/AMDGPU/atomic_load_add.ll LLVM :: CodeGen/AMDGPU/atomic_load_sub.ll LLVM :: CodeGen/AMDGPU/extload.ll LLVM :: CodeGen/AMDGPU/lds-oqap-crash.ll LLVM :: CodeGen/AMDGPU/lds-output-queue.ll LLVM :: CodeGen/AMDGPU/load-local-f32.ll LLVM :: CodeGen/AMDGPU/load-local-f64.ll LLVM :: CodeGen/AMDGPU/load-local-i1.ll LLVM :: CodeGen/AMDGPU/load-local-i16.ll LLVM :: CodeGen/AMDGPU/load-local-i32.ll LLVM :: CodeGen/AMDGPU/load-local-i64.ll LLVM :: CodeGen/AMDGPU/load-local-i8.ll LLVM :: CodeGen/AMDGPU/local-atomics.ll LLVM :: CodeGen/AMDGPU/local-memory.r600.ll LLVM :: CodeGen/AMDGPU/private-memory-r600.ll LLVM :: CodeGen/AMDGPU/store.ll
There's a few place like this with lots of extra whitespace that could be cleaned up.