Details
- Reviewers
nhaustov • tstellarAMD
Diff Detail
Event Timeline
lib/Target/AMDGPU/SIRegisterInfo.cpp | ||
---|---|---|
15 | Should not be first include. Why is SIRegisterInfo including from the InstPrinter? This seems like a layering violation |
lib/Target/AMDGPU/SIRegisterInfo.cpp | ||
---|---|---|
15 | SIRegisterInfo needs access to AMDGPUInstPrinter::getRegisterName() to obtain AsmNames for registers. This is the only way to get it currently without changing core LLVM. |
Matt's concern about there being a layer violation is valid. We need to resolve this before the patch can be committed.
Is layering violation a strong prohibition for acceptance?
There is formal layering violation that RegisterInfo calls InstPrinter but for me it looks like it is conceptual layering violatoin in LLVM architecture. Assembly is responsibility of MC Layer but inline assembly is responsibility of TargetLowering and RegisterInfo (TargetLowering::getRegForInlineAsmConstraint() and RegisterInfo::getRegAsmName()).
So without code dupplication or major changes in core LLVM I don't see how this violation can be solved.
Possibly we should get used to that we must use names like VGPR13 or rename our Register classes.
It seems strange to me that this is here, instead of someplace like MCAsmInfo. Why was getRegAsmName added to TRI?
getRegAsmName() is used by TargetLowering::getRegForInlineAsmConstraint(). Placing it in MCAsmInfo will introduce layering violation in the same way.
What should I do with this change?
I don't see ways to solve layering violation without changes in core LLVM.
The easiest way to avoid a potential layering violation would be to have TableGen emit AMDGPUInstPrinter::getRegisterName(Reg) as static function rather than an AMDGPUInstPrinter member function.
However, if including the InstPrinter headers from the CodeGen files is a layering violation, all targets are already doing this by including InstrPrinter headers in XXXAsmPrinter. So, this change really isn't doing anything that isn't already being done. I'm fine with this being committed.
Should not be first include.
Why is SIRegisterInfo including from the InstPrinter? This seems like a layering violation