Skip to content

Commit fce7a7a

Browse files
committed
[AMDGPU][AsmParser] Refine parsing instruction operands.
Eliminates the need for working around optional and token operands being mistakenly parsed as expressions. Reviewed By: dp Differential Revision: https://reviews.llvm.org/D138492
1 parent ec8ede8 commit fce7a7a

21 files changed

+660
-638
lines changed

llvm/include/llvm/Target/Target.td

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,16 @@ class AsmParser {
14791479
// to matching the parsed instruction, so to allow more detailed error
14801480
// messages.
14811481
bit ReportMultipleNearMisses = false;
1482+
1483+
// OperandParserMethod - If non-empty, this is the name of a custom
1484+
// member function of the AsmParser class to call for every instruction
1485+
// operand to be parsed.
1486+
string OperandParserMethod = "";
1487+
1488+
// CallCustomParserForAllOperands - Set to true if the custom parser
1489+
// method shall be called for all operands as opposed to only those
1490+
// that have their own specified custom parsers.
1491+
bit CallCustomParserForAllOperands = false;
14821492
}
14831493
def DefaultAsmParser : AsmParser;
14841494

llvm/lib/Target/AMDGPU/AMDGPU.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,6 +1337,10 @@ def AMDGPUAsmParser : AsmParser {
13371337
// Some of the R600 registers have the same name, so this crashes.
13381338
// For example T0_XYZW and T0_XY both have the asm name T0.
13391339
let ShouldEmitMatchRegisterName = 0;
1340+
1341+
// Call the custom operand parser for all operands.
1342+
let OperandParserMethod = "parseCustomOperand";
1343+
let CallCustomParserForAllOperands = true;
13401344
}
13411345

13421346
def AMDGPUAsmWriter : AsmWriter {

0 commit comments

Comments
 (0)