Alex Susu via llvm-dev
2016-Jul-15 12:40 UTC
[llvm-dev] TableGen change in LLVM 3.9 allows only prefix instruction notation
Hello. I am curious why did you changed TableGen to allow in principle only writing ASM instructions in prefix notation. I ask because I personally use an assembly notation that is infix (I could use a simple preprocessor that changes prefix to infix). Just to mention: I found the solution to this - the following part of the code is responsible for this from llvm/utils/TableGen/AsmMatcherEmitter.cpp (so it needs to be commented to be disabled): // The first token of the instruction is the mnemonic, which must be a // simple string, not a $foo variable or a singleton register. if (AsmOperands.empty()) PrintFatalError(TheDef->getLoc(), "Instruction '" + TheDef->getName() + "' has no tokens"); assert(!AsmOperands[0].Token.empty()); if (HasMnemonicFirst) { Mnemonic = AsmOperands[0].Token; if (Mnemonic[0] == '$') PrintFatalError(TheDef->getLoc(), "Invalid instruction mnemonic '" + Mnemonic + "'!"); // Remove the first operand, it is tracked in the mnemonic field. AsmOperands.erase(AsmOperands.begin()); } else if (AsmOperands[0].Token[0] != '$') Mnemonic = AsmOperands[0].Token; Thank you, Alex
Tim Northover via llvm-dev
2016-Jul-15 16:12 UTC
[llvm-dev] TableGen change in LLVM 3.9 allows only prefix instruction notation
On 15 July 2016 at 05:40, Alex Susu via llvm-dev <llvm-dev at lists.llvm.org> wrote:> I am curious why did you changed TableGen to allow in principle only > writing ASM instructions in prefix notation. I ask because I personally use > an assembly notation that is infix (I could use a simple preprocessor that > changes prefix to infix).Running "git blame" points at https://github.com/llvm-mirror/llvm/commit/5ef1349, which gives the reasoning and suggests you ought to be able to set "HasMnemonicFirst". Tim.
Alex Susu via llvm-dev
2016-Jul-17 09:14 UTC
[llvm-dev] TableGen change in LLVM 3.9 allows only prefix ASM instruction notation
Hello. Tim, thanks for pointing me out to https://github.com/llvm-mirror/llvm/commit/5ef1349 . I followed the example there and: - left utils/TableGen/AsmMatcherEmitter.cpp unchanged (no more commenting of the lines I said I did comment in the previous email) - following Hexagon.td I added in my MyTarget.td file: def MyTargetAsmParser : AsmParser { bit HasMnemonicFirst = 0; } [...] let AssemblyParsers = [MyTargetAsmParser]; By doing these steps I was (again) able to use infix ASM instruction notation. Thank you, Alex On 7/15/2016 7:12 PM, Tim Northover wrote:> On 15 July 2016 at 05:40, Alex Susu via llvm-dev > <llvm-dev at lists.llvm.org> wrote: >> I am curious why did you changed TableGen to allow in principle only >> writing ASM instructions in prefix notation. I ask because I personally use >> an assembly notation that is infix (I could use a simple preprocessor that >> changes prefix to infix). > > Running "git blame" points at > https://github.com/llvm-mirror/llvm/commit/5ef1349, which gives the > reasoning and suggests you ought to be able to set "HasMnemonicFirst". > > Tim. >