[llvm-dev] TableGen change in LLVM 3.9 allows only prefix instruction notation

Alex Susu via llvm-dev llvm-dev at lists.llvm.org
Fri Jul 15 05:40:20 PDT 2016


   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


More information about the llvm-dev mailing list