This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
(define_address ...) suggestions needed
- To: gcc at gcc dot gnu dot org
- Subject: (define_address ...) suggestions needed
- From: Denis Chertykov <denisc at overta dot ru>
- Date: Tue, 11 Jan 2000 23:25:12 +0300
I have started work on implement (define_address ...) patterns in md
file.
Following work already done:
* rtl.def: (DEFINE_ADDRESS) new RTL expression added.
/* Definition of a address
1st operand: address mode name
2nd operand: vector of insn patterns to match
3rd operand: C expression that must be true
4th operand: only C code to produce assembler output.
5th operand: optionally, a vector of attributes for this address.
*/
DEF_RTL_EXPR(DEFINE_ADDRESS, "define_address", "sEssV", 'x')
* genrecog.c: generates `recog_address' for (define_address ...)
patterns recognizing.
* genextract.c : generates `address_extract' for a parameters
extracting.
* recog.c: (struct recog_data recog_addr_data) Added.
`genrecog' and `genextract' uses `recog_addr_data' like
`recog' and `insn_extract' uses `recog_data'.
* genattrtab.c: generates special versions of gen_attr_XXXX
which uses `recog_address' instead of `recog_memoized'.
? Any address attribute name must starts with `address'.
* genoutput.c: store information about (define_address ...) to
`insn_data', `insn_operand_data' and to `output_XXX' functions.
? Information about (define_address ...) and (define_insn ...) stored
to same arrays.
* recog.c: (extract_address): new function added.
Like extract_insn but more simple.
* recog.c: (constrain_address_operands) Check the operands of
an address against the address's operand constraints.
Not all constraints can be used. Memory (p,m,V,<,>,o,) and
float (E,F,G,H,g) constrains excluded.
RTL example:
(define_attr "address_cost" "" (const_int 0))
(define_attr "address_mode_dependent" "no,yes" (const_string "no"))
(define_attr "address_direction" "load,store,load_store"
(const_string "load_store"))
(define_address "*immediate"
[(mem (match_operand:HI 0 "immediate_operand" "i"))]
""
"* /* Only C code can be used here
because it's analog of PRINT_OPERAND_ADDRESS */
output_addr_const (asm_out_file, operands[0]);
return \"\";"
[(set_attr "address_cost" "4")])
(define_address "post_inc"
[(mem (post_inc:HI (match_operand:HI 0 "register_operand" "e")))]
""
"*{
switch (REGNO (operands[0]))
{
case REG_X: return \"X+\";
case REG_Y: return \"Y+\";
case REG_Z: return \"Z+\";
default:
fatal (\"Incorrect register as address\");
}
}"
[(set_attr "address_cost" "2")
(set_attr "address_mode_dependent" "yes")])
------------------------------------------------------
I'm use `mem' only for checking mode and because `genrecog' generates
ready code for a address recognizing.
Any predicate which uses `memory_operand' can't be used in
(define_address ...) to avoid infinite loop.
Helper for GO_IF_LEGITIMATE_ADDRESS:
int
legitimate_address_p (mode, x, strict)
enum machine_mode mode;
rtx x;
int strict;
{
struct rtx_def mem_def;
int insn_code_number;
rtx mem = &mem_def;
PUT_CODE (mem, MEM);
PUT_MODE (mem, mode);
XEXP (mem, 0) = x;
insn_code_number = recog_address (mem);
if (strict && insn_code_number >= 0)
{
extract_address (mem, insn_code_number);
return constrain_address_operands ();
}
return insn_code_number >= 0;
}
-------------
IMHO I must put:
- legitimate_address_p to recog.c;
- print_operand_address to final.c;
- address_cost cse.c .
Where (in which file) must I declare a standard versions of
GO_IF_LEGITIMATE_ADDRESS, ADDRESS_COST, HAVE_POST_INCREMENT, ?
PLEASE correct me if I have something wrong.
Denis.