Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Could you add a test to check the reported error position? Unfortunately, AsmMatcher often fails to report the location of offending operand. Moving the check to validator may improve diagnostic by using getImmLoc.
llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp | ||
---|---|---|
3280 | I would prefer dynamic_cast, for safe downcasting. |
llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp | ||
---|---|---|
3280 | LLVM is generally built with -fno-rtti so I don't think you can use dynamic_cast (can you?). |
llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp | ||
---|---|---|
3280 | Good point, I don't know if it's available. LLVM dyn_cast may also be an option. |
llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp | ||
---|---|---|
3280 | the llvm pseudo-RTTI doesn't just happen and isn't implemented for AMDGPUOperand |
Could you add a test to check the reported error position? Unfortunately, AsmMatcher often fails to report the location of offending operand. Moving the check to validator may improve diagnostic by using getImmLoc.
The currently reported position is the beginning of the first operand and in the current design there seems to be no way to do better, which looks a somewhat severe problem to me and I'd be happy to improve it, but that feels well beyond the scope of this patch, doesn't it.
llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp | ||
---|---|---|
3280 | I understand dyn_cast<> is normally used where we have to discriminate between several possibilities with static_cast<> being the standard solution when we know the dynamic type. |
Moving the check to validator may improve diagnostic by using getImmLoc.
Sorry, missed that part. Will try it.
The currently reported position is the beginning of the first operand and in the current design there seems to be no way to do better
If AsmMatcher cannot report error position, why do not move the check to AMDGPUAsmParser::validateInstruction then?
If AsmMatcher cannot report error position, why do not move the check to AMDGPUAsmParser::validateInstruction then?
Yes, I think the patch actually misuses checkEarlyTargetMatchPredicate(), which looks more like a mean to exclude unrelated instructions from viable candidates (and that's why there supposed to be no diagnostic output). Here, in contrast, we already know it that the chosen instruction is the right one, but don't want it be used, so validation should be the right point for the check, though that will require introducing another relation table, it seems.
LGTM.
llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp | ||
---|---|---|
4607 | Maybe "is not enabled with" would be better? |
llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp | ||
---|---|---|
4604 | With getImmLoc this loop may be reduced to the following code: auto Loc = getImmLoc(AMDGPUOperand::ImmTyTFE, Operands); if (Loc != getInstLoc(Operands)) { Error(Loc, "..."); return false; } |
I would prefer dynamic_cast, for safe downcasting.