[LLVMdev] TSFlagsFields and TSFlagsShifts obsolete?

Chris Lattner clattner at apple.com
Fri Mar 26 15:13:54 PDT 2010


On Mar 25, 2010, at 12:59 PM, Jakob Stoklund Olesen wrote:

> I think we can get rid of the TSFlagsFields and TSFlagsShifts hack in the InstrInfo TableGen class now.

That is really cool!  Please do it, :)

-Chris

> 
> This seems to work just fine:
> 
> class Instruction {
>  bits<32> TSFlags;
> }
> 
> class Domain<bits<2> val> {
>  bits<2> Value = val;
> }
> def GenericDomain   : Domain<0>;
> def SSEPackedInt    : Domain<1>;
> def SSEPackedSingle : Domain<2>;
> def SSEPackedDouble : Domain<3>;
> 
> class X86Instr<bits<8> opcod> : Instruction {
>  Domain ExeDomain = GenericDomain;
>  let TSFlags{0-7} = opcod;
>  let TSFlags{22-23} = ExeDomain.Value;
> }
> 
> class PIInstr<bits<8> opcod> : X86Instr<opcod> {
>  let ExeDomain = SSEPackedInt;
> }
> 
> def i1 : X86Instr<0x12>;
> def i2 : PIInstr<0x34>;
> def i3 : PIInstr<0x34> { let ExeDomain = SSEPackedSingle; }
> 
> 
> Wouldn't it be better to assign TSFlags bits directly in an Instruction subclass, rather than in a magic InstrInfo instance somewhere?
> 
> /jakob
> 
> 
> ------------- Classes -----------------
> class Domain<bits<2> Domain:val = { ?, ? }> {
>  bits<2> Value = { Domain:val{1}, Domain:val{0} };
> }
> class Instruction {
>  bits<32> TSFlags = { ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? };
> }
> class PIInstr<bits<8> PIInstr:opcod = { ?, ?, ?, ?, ?, ?, ?, ? }> {	// Instruction X86Instr
>  bits<32> TSFlags = { ?, ?, ?, ?, ?, ?, ?, ?, ExeDomain.Value{0}, ExeDomain.Value{1}, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, PIInstr:opcod{0}, PIInstr:opcod{1}, PIInstr:opcod{2}, PIInstr:opcod{3}, PIInstr:opcod{4}, PIInstr:opcod{5}, PIInstr:opcod{6}, PIInstr:opcod{7} };
>  Domain ExeDomain = SSEPackedInt;
> }
> class X86Instr<bits<8> X86Instr:opcod = { ?, ?, ?, ?, ?, ?, ?, ? }> {	// Instruction
>  bits<32> TSFlags = { ?, ?, ?, ?, ?, ?, ?, ?, ExeDomain.Value{0}, ExeDomain.Value{1}, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, X86Instr:opcod{0}, X86Instr:opcod{1}, X86Instr:opcod{2}, X86Instr:opcod{3}, X86Instr:opcod{4}, X86Instr:opcod{5}, X86Instr:opcod{6}, X86Instr:opcod{7} };
>  Domain ExeDomain = GenericDomain;
> }
> ------------- Defs -----------------
> def GenericDomain {	// Domain
>  bits<2> Value = { 0, 0 };
> }
> def SSEPackedDouble {	// Domain
>  bits<2> Value = { 1, 1 };
> }
> def SSEPackedInt {	// Domain
>  bits<2> Value = { 0, 1 };
> }
> def SSEPackedSingle {	// Domain
>  bits<2> Value = { 1, 0 };
> }
> def i1 {	// Instruction X86Instr
>  bits<32> TSFlags = { ?, ?, ?, ?, ?, ?, ?, ?, 0, 0, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, 1, 0, 0, 1, 0, 0, 0 };
>  Domain ExeDomain = GenericDomain;
> }
> def i2 {	// Instruction X86Instr PIInstr
>  bits<32> TSFlags = { ?, ?, ?, ?, ?, ?, ?, ?, 1, 0, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, 0, 1, 0, 1, 1, 0, 0 };
>  Domain ExeDomain = SSEPackedInt;
> }
> def i3 {	// Instruction X86Instr PIInstr
>  bits<32> TSFlags = { ?, ?, ?, ?, ?, ?, ?, ?, 0, 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, 0, 1, 0, 1, 1, 0, 0 };
>  Domain ExeDomain = SSEPackedSingle;
> }
> 
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev





More information about the llvm-dev mailing list