problems with tablegen and namespaces

I am trying to write a skeleton of an ARM back end. I have declared
the following class

class InstARM<dag ops, string asmstr, list<dag> pattern> : Instruction {
  let Namespace = "ARM";

  dag OperandList = ops;
  let AsmString = asmstr;
  let Pattern = pattern;
}

and defined three instructions (ldr, str, and mov).

The problem is that, in the generated code, the namespace isn't used
everywhere I expected. For example, in
ARMAsmPrinter::printInstruction, the PHI instruction doesn't has an
"ARM::" prepended to it. ldr, str and mov have. An ARM namespace is
also missing in ARMGenInstrNames.inc.

Someone with more experience with tablegen knows why it isn't adding
these namesaces to the generated code?

Thanks,
Rafael

This looks like a tblgen bug. If you look at utils/TableGen/AsmWriterEmitter.cpp:290, it appears to take the namespace from the first instruction in an equivalence class that it comes across. I will fix this bug this afternoon, but in the meantime, if you define an instruction "AAA" which takes no operands, it will work around this.

-Chris

This looks like a tblgen bug. If you look at
utils/TableGen/AsmWriterEmitter.cpp:290, it appears to take the namespace
from the first instruction in an equivalence class that it comes across.
I will fix this bug this afternoon, but in the meantime, if you define an
instruction "AAA" which takes no operands, it will work around this.

Thanks. Defining "AAA" did worked around the problem.

-Chris

Rafael

Okay, if you update from CVS, this problem should be fixed, at least for the AsmPrinter. Please try it out (without AAA), and let me know if you have problems with any other part of the code generator.

Thanks!

-Chris

Okay, if you update from CVS, this problem should be fixed, at least for
the AsmPrinter. Please try it out (without AAA), and let me know if you
have problems with any other part of the code generator.

The behaviour now is:
The TargetInstrInfo namespace is used for the PHI instruction
regardless of the presence of the AAA instruction.
In ARMGenInstrNames.inc, the TargetInstrInfo namespace is used if the
AAA instruction isn't defined and the ARM namespace is used if it is
defined.

Thanks!

-Chris

Best Regards,
Rafael

Okay, if you update from CVS, this problem should be fixed, at least for
the AsmPrinter. Please try it out (without AAA), and let me know if you
have problems with any other part of the code generator.

The behaviour now is:
The TargetInstrInfo namespace is used for the PHI instruction
regardless of the presence of the AAA instruction.

Good, this is expected. TargetInstrInfo::PHI == ARM::PHI.

In ARMGenInstrNames.inc, the TargetInstrInfo namespace is used if the
AAA instruction isn't defined and the ARM namespace is used if it is
defined.

I don't follow here. XXXGenInstrNames.inc shouldn't have namespaces at all. Can you paste a few lines out of the file that you are seeing?

Thanks,

-Chris

> In ARMGenInstrNames.inc, the TargetInstrInfo namespace is used if the
> AAA instruction isn't defined and the ARM namespace is used if it is
> defined.

I don't follow here. XXXGenInstrNames.inc shouldn't have namespaces at
all. Can you paste a few lines out of the file that you are seeing?

Sure:

with AAA defined, ARMGenInstrNames.inc looks like:

Ahhh... that would be bad :slight_smile:

This should be fixed, thanks!

-Chris