[LLVMdev] Instruction categories in the backend

Chris Lattner
Mon, 11 May 2009 17:23:57 -0000

On May 11, 2009, at 8:03 AM, Christian Sayer wrote:

> Dear all,
>
> I would like to classify all target specific instructions in a set
> of categories. The category of each instruction would then be
> available in the backend.
> Just to illustrate what I am trying to do, the first thing I thought
> about how to achieve this was to group instruction definitions in
> InstrInfo.td in the order of categories, and to put pseudo
> instructions in between to mark category boundaries.  However, the
> Target Instruction Enum in GenInstrNames.inc does not follow the
> definition order of the .td, but is in fact ordered alphabetically.

Hi Christian,

This is supported directly: TargetInstrDesc has 32-bits per
instruction that your target can do whatever it wants with (TSFlags).
tblgen has support for populating these directly.  The X86 backend
uses this for various encoding and other purposes.  See X86InstrInfo.h
(the X86II namespace) and related stuff for an example.  tblgen is
informed about the encoding of the 32-bit field with the TSFlagsFields/
TSFlagsShifts entries in X86InstrInfo in X86.td.

-Chris