* FW: Problem with instruction description
[not found] <SNT142-W25447ECD857E54B6EF0E56A8830@phx.gbl>
@ 2012-01-16 8:37 ` youssef fahmi
0 siblings, 0 replies; only message in thread
From: youssef fahmi @ 2012-01-16 8:37 UTC (permalink / raw)
To: cgen
Hello,
I am working on the porting of binutils to a new architecture.
This processor has an instruction of the form: ld rx,[r1] + imm6 [load the 32 bit word at the address calculated from the contents of r1 plus the 6 bit immediate value (multiplied by 4) ]
In summary: rx <- mem[r1 + imm6 * 4]
I need to generate code for this instruction, but only in the case where the code generator in the compiler generates a standard load, but with an offset appropriate for the imm6 value. That is to say the immediate value would be less than 256 and be a multiple of 4 (word access).
This is the description that I am using at the moment:
(df-f imm6x4 "imm6x4" ()
11 6 UINT
((value pc) (sra WI value (const 2)))
((value pc) (sll WI value (const 2))))
(dnop imm6x4 "imm6x4" () h-uint f-imm6x4)
(dni ldstack-r1-imm6x4 "ldstack r1#imm6x4" () "ld $r1,[r1]+$imm6x4" (+ (f-stack-opcode #05) r1 imm6x4) () ())
However this description causes the "ld rx,[r1] + imm6" to be used whenever the immediate vallue is less than 256, and not JUST when the offset is also a multiple of 4.
How do I alter this description so that it only operates when the immediate value is less than 256 AND ALSO a multiple of 4.
I have already tried.... but this generates code with this instruction in these cases ;;; which are not appropriate.How do I achieve this?
I guess that I'll have to create an attribute to handle this, but I could not get an attribute that suits me. is there a way to create an attribute of type integer, for example, but with only specific integers not necessarily following.
Thanks in advance for your answer.
Youssef
^ permalink raw reply [flat|nested] only message in thread