Taking argument addresses.
D. Towner
towner@compsci.bristol.ac.uk
Mon Mar 4 07:02:00 GMT 2002
Hi all,
I am currently porting gcc to a new target (16-bit DSP). Suppose I have
the following code:
void fn(int a, int b) {
int* ptr = &b;
}
In order to move the address of `b' into a register, I can use the
following pattern:
(define_insn "*movhi_address"
[(set (match_operand:HI 0 "register_operand" "=r")
(match_operand:HI 1 "address_operand" "r"))]
""
"/* something. */")
However, if I try to take the address of `a' instead, the above pattern
fails (I get an error in instantiate_virtual_regs). I don't understand the
difference between taking the two addresses. Through trial and error, I
have discovered that if I can get around the problem by defining another
pattern:
(define_insn "*movhi_address2"
[(set (match_operand:HI 0 "memory_operand" "=m")
(match_operand:HI 1 "address_operand" "r"))]
""
"/* something. */")
...and everything then works as expected. Whilst I am happy that defining
the pair of patterns (actually combined into a single pattern) does the
job, I would like to understand why there needs to be two?
Thanks,
Dan.
===============================================================================
Dan Towner
dant@picochip.com
picoChip Designs Ltd.
+44 (0) 7786 702589
More information about the Gcc
mailing list