Skip to content

Commit 61b980b

Browse files
clazissartemiy-volkov
authored andcommitted
Cleanup #1
1 parent c1e84d3 commit 61b980b

File tree

5 files changed

+279
-198
lines changed

5 files changed

+279
-198
lines changed

gcc/config/arc64/arc64-protos.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@
44
extern int arc64_epilogue_uses (int);
55
extern HOST_WIDE_INT arc64_initial_elimination_offset (unsigned, unsigned);
66
extern void arc64_init_expanders (void);
7-
extern rtx arc64_return_addr (int, rtx);
8-
extern HOST_WIDE_INT arc64_regmode_natural_size (machine_mode);
7+
extern void arc64_cpu_cpp_builtins (cpp_reader *);
98

109
#ifdef RTX_CODE
1110

11+
extern rtx arc64_return_addr (int, rtx);
1212
extern machine_mode arc64_select_cc_mode (enum rtx_code, rtx, rtx);
1313
extern bool arc64_check_mov_const (HOST_WIDE_INT );
1414
extern bool arc64_split_mov_const (rtx *);
1515
extern bool arc64_can_use_return_insn_p (void);
16+
extern void arc64_expand_call (rtx, rtx, bool);
17+
extern rtx arc64_gen_compare_reg (enum rtx_code, rtx, rtx);
18+
extern bool arc64_prepare_move_operands (rtx, rtx, machine_mode);
1619

1720
#endif /* RTX_CODE */
1821

gcc/config/arc64/arc64.c

Lines changed: 88 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -64,62 +64,12 @@ const enum reg_class arc64_regno_to_regclass[FIRST_PSEUDO_REGISTER] =
6464
NO_REGS, NO_REGS, NO_REGS,
6565
};
6666

67-
/* Return 1 if the register is used by the epilogue. We need to say the
68-
return register is used, but only after epilogue generation is complete.
69-
Note that in the case of sibcalls, the values "used by the epilogue" are
70-
considered live at the start of the called function. */
71-
72-
int
73-
arc64_epilogue_uses (int regno)
74-
{
75-
if (epilogue_completed)
76-
if (regno == BLINK_REGNUM)
77-
return 1;
78-
79-
return 0;
80-
}
81-
82-
/* Implement INITIAL_ELIMINATION_OFFSET. FROM is either the frame pointer
83-
or argument pointer. TO is either the stack pointer or hard frame
84-
pointer. */
85-
86-
HOST_WIDE_INT
87-
arc64_initial_elimination_offset (unsigned from, unsigned to)
88-
{
89-
return 0;
90-
}
91-
92-
void arc64_init_expanders (void)
93-
{
94-
/* FIXME! Not sure if I need it. */
95-
}
96-
97-
/* Given a comparison code (EQ, NE, etc.) and the first operand of a
98-
COMPARE, return the mode to be used for the comparison. */
99-
100-
machine_mode
101-
arc64_select_cc_mode (enum rtx_code op, rtx x, rtx y)
102-
{
103-
return CC_Cmode;
104-
}
105-
106-
/* Implement RETURN_ADDR_RTX. We do not support moving back to a
107-
previous frame. */
108-
109-
rtx
110-
arc64_return_addr (int count , rtx frame ATTRIBUTE_UNUSED)
67+
/* Emit an insn that's a simple single-set. Both the operands must be
68+
known to be valid. */
69+
inline static rtx_insn *
70+
emit_set_insn (rtx x, rtx y)
11171
{
112-
if (count != 0)
113-
return const0_rtx;
114-
return get_hard_reg_initial_val (Pmode, BLINK_REGNUM);
115-
}
116-
117-
/* Implement REGMODE_NATURAL_SIZE. */
118-
119-
HOST_WIDE_INT
120-
arc64_regmode_natural_size (machine_mode mode)
121-
{
122-
return UNITS_PER_WORD; /*FIXME! do I need it? */
72+
return emit_insn (gen_rtx_SET (x, y));
12373
}
12474

12575
/* Given FROM and TO register numbers, say whether this elimination is allowed.
@@ -140,7 +90,7 @@ arc64_can_eliminate (const int from ATTRIBUTE_UNUSED, const int to)
14090
mode MODE. */
14191

14292
static bool
143-
arc_legitimate_address_p (machine_mode mode, rtx x, bool strict)
93+
arc64_legitimate_address_p (machine_mode mode, rtx x, bool strict)
14494
{
14595
return true;
14696
}
@@ -156,6 +106,26 @@ arc64_legitimate_constant_p (machine_mode mode, rtx x)
156106
return false;
157107
}
158108

109+
/* This is how to output a definition of an internal numbered label where
110+
PREFIX is the class of label and NUM is the number within the class. */
111+
112+
static void arc64_internal_label (FILE *stream, const char *prefix, unsigned long labelno)
113+
{
114+
default_internal_label (stream, prefix, labelno);
115+
}
116+
117+
/* X and Y are two things to compare using CODE. Emit the compare insn and
118+
return the rtx for the cc reg in the proper mode. */
119+
120+
rtx
121+
arc64_gen_compare_reg (enum rtx_code code, rtx x, rtx y)
122+
{
123+
machine_mode mode = SELECT_CC_MODE (code, x, y);
124+
rtx cc_reg = gen_rtx_REG (mode, CC_REGNUM);
125+
126+
emit_set_insn (cc_reg, gen_rtx_COMPARE (mode, x, y));
127+
return cc_reg;
128+
}
159129

160130
/* Prepare operands for move in MODE. Return true iff the move has
161131
been emitted. */
@@ -280,6 +250,7 @@ arc64_check_mov_const (HOST_WIDE_INT ival)
280250

281251
return false;
282252
}
253+
#endif
283254

284255
/* This function is used by the call expanders of the machine description.
285256
RESULT is the register in which the result is returned. It's NULL for
@@ -292,6 +263,7 @@ void
292263
arc64_expand_call (rtx result, rtx mem, bool sibcall)
293264
{
294265
rtx call, callee, tmp;
266+
rtvec vec;
295267
machine_mode mode;
296268

297269
gcc_assert (MEM_P (mem));
@@ -302,10 +274,10 @@ arc64_expand_call (rtx result, rtx mem, bool sibcall)
302274
/* Decide if we should generate indirect calls by loading the
303275
address of the callee into a register before performing the
304276
branch-and-link. */
305-
if (arc64_is_long_call_p (callee) && !REG_P (callee))
306-
XEXP (mem, 0) = force_reg (mode, callee);
277+
// FIXME! if (arc64_is_long_call_p (callee) && !REG_P (callee))
278+
// FIXME! XEXP (mem, 0) = force_reg (mode, callee);
307279

308-
call = gen_rtx_call (VOIDmode, mem, cont0_rtx);
280+
call = gen_rtx_CALL (VOIDmode, mem, const0_rtx);
309281

310282
if (result != NULL_RTX)
311283
call = gen_rtx_SET (result, call);
@@ -320,7 +292,6 @@ arc64_expand_call (rtx result, rtx mem, bool sibcall)
320292

321293
emit_call_insn (call);
322294
}
323-
#endif
324295

325296
/* Return nonzero if this function is known to have a null epilogue.
326297
This allows the optimizer to omit jumps to jumps if no stack
@@ -332,12 +303,63 @@ arc64_can_use_return_insn_p (void)
332303
return (reload_completed); //FIXME!: && cfun->machine->frame.frame_size == 0);
333304
}
334305

335-
/* This is how to output a definition of an internal numbered label where
336-
PREFIX is the class of label and NUM is the number within the class. */
337306

338-
static void arc64_internal_label (FILE *stream, const char *prefix, unsigned long labelno)
307+
/* Return 1 if the register is used by the epilogue. We need to say the
308+
return register is used, but only after epilogue generation is complete.
309+
Note that in the case of sibcalls, the values "used by the epilogue" are
310+
considered live at the start of the called function. */
311+
312+
int
313+
arc64_epilogue_uses (int regno)
339314
{
340-
default_internal_label (stream, prefix, labelno);
315+
if (epilogue_completed)
316+
if (regno == BLINK_REGNUM)
317+
return 1;
318+
319+
return 0;
320+
}
321+
322+
/* Implement INITIAL_ELIMINATION_OFFSET. FROM is either the frame pointer
323+
or argument pointer. TO is either the stack pointer or hard frame
324+
pointer. */
325+
326+
HOST_WIDE_INT
327+
arc64_initial_elimination_offset (unsigned from, unsigned to)
328+
{
329+
return 0;
330+
}
331+
332+
void arc64_init_expanders (void)
333+
{
334+
/* FIXME! Not sure if I need it. */
335+
}
336+
337+
/* Given a comparison code (EQ, NE, etc.) and the first operand of a
338+
COMPARE, return the mode to be used for the comparison. */
339+
340+
machine_mode
341+
arc64_select_cc_mode (enum rtx_code op, rtx x, rtx y)
342+
{
343+
return CC_Cmode;
344+
}
345+
346+
/* Implement RETURN_ADDR_RTX. We do not support moving back to a
347+
previous frame. */
348+
349+
rtx
350+
arc64_return_addr (int count , rtx frame ATTRIBUTE_UNUSED)
351+
{
352+
if (count != 0)
353+
return const0_rtx;
354+
return get_hard_reg_initial_val (Pmode, BLINK_REGNUM);
355+
}
356+
357+
/* Helper for TARGET_CPU_CPP_BUILTINS hook. */
358+
359+
void
360+
arc64_cpu_cpp_builtins (cpp_reader * pfile)
361+
{
362+
//FIXME! builtin_define ("__arc64__");
341363
}
342364

343365
/* Target hooks. */
@@ -358,8 +380,8 @@ static void arc64_internal_label (FILE *stream, const char *prefix, unsigned lon
358380
#undef TARGET_CAN_ELIMINATE
359381
#define TARGET_CAN_ELIMINATE arc64_can_eliminate
360382

361-
//#undef TARGET_LEGITIMATE_ADDRESS_P
362-
//#define TARGET_LEGITIMATE_ADDRESS_P arc64_legitimate_address_p
383+
#undef TARGET_LEGITIMATE_ADDRESS_P
384+
#define TARGET_LEGITIMATE_ADDRESS_P arc64_legitimate_address_p
363385

364386
#undef TARGET_LEGITIMATE_CONSTANT_P
365387
#define TARGET_LEGITIMATE_CONSTANT_P arc64_legitimate_constant_p

0 commit comments

Comments
 (0)