Commit a024f514 by Max Filippov Committed by Max Filippov

xtensa: add -mauto-litpools option

With support from assembler this option allows compiling huge functions,
where single literal pool at the beginning of a function may not be
reachable by L32R instructions at its end.

Currently assembler --auto-litpools option cannot deal with literals
used from multiple locations separated by more than 256 KBytes of code.
Don't turn constants into literals, instead use MOVI instruction to load
them into registers and let the assembler turn them into literals as
necessary.

2015-08-12  Max Filippov  <jcmvbkbc@gmail.com>
gcc/
	* config/xtensa/constraints.md (define_constraint "Y"): New
	constraint.
	* config/xtensa/elf.h (ASM_SPEC): Add m(no-)auto-litpools.
	* config/xtensa/linux.h (ASM_SPEC): Likewise.
	* config/xtensa/predicates.md (move_operand): Match constants
	and symbols in the presence of TARGET_AUTO_LITPOOLS.
	* config/xtensa/xtensa.c (xtensa_valid_move): Don't allow
	immediate references to TLS data.
	(xtensa_emit_move_sequence): Don't force constants to memory in
	the presence of TARGET_AUTO_LITPOOLS.
	(print_operand): Add 'y' format, same as default, but capable of
	printing SF mode constants as well.
	* config/xtensa/xtensa.md (movsi_internal, movhi_internal)
	(movsf_internal): Add movi pattern that loads literal.
	(movsf, movdf): Don't force constants to memory in the presence
	of TARGET_AUTO_LITPOOLS.
	(movdf_internal): Add 'Y' constraint.
	* config/xtensa/xtensa.opt (mauto-litpools): New option.
	* doc/invoke.text (Xtensa options): Document -mauto-litpools.

From-SVN: r226828
parent 4757fa7f
2015-08-12 Max Filippov <jcmvbkbc@gmail.com>
* config/xtensa/constraints.md (define_constraint "Y"): New
constraint.
* config/xtensa/elf.h (ASM_SPEC): Add m(no-)auto-litpools.
* config/xtensa/linux.h (ASM_SPEC): Likewise.
* config/xtensa/predicates.md (move_operand): Match constants
and symbols in the presence of TARGET_AUTO_LITPOOLS.
* config/xtensa/xtensa.c (xtensa_valid_move): Don't allow
immediate references to TLS data.
(xtensa_emit_move_sequence): Don't force constants to memory in
the presence of TARGET_AUTO_LITPOOLS.
(print_operand): Add 'y' format, same as default, but capable of
printing SF mode constants as well.
* config/xtensa/xtensa.md (movsi_internal, movhi_internal)
(movsf_internal): Add movi pattern that loads literal.
(movsf, movdf): Don't force constants to memory in the presence
of TARGET_AUTO_LITPOOLS.
(movdf_internal): Add 'Y' constraint.
* config/xtensa/xtensa.opt (mauto-litpools): New option.
* doc/invoke.text (Xtensa options): Document -mauto-litpools.
2015-08-12 Matthew Wahab <matthew.wahab@arm.com>
* config/arm/arm-fpus.def: Replace booleans with feature flags.
......
......@@ -111,6 +111,11 @@
(and (match_code "const_int")
(match_test "xtensa_mask_immediate (ival)")))
(define_constraint "Y"
"A constant that can be used in relaxed MOVI instructions."
(and (match_code "const_int,const_double,const,symbol_ref,label_ref")
(match_test "TARGET_AUTO_LITPOOLS")))
;; Memory constraints. Do not use define_memory_constraint here. Doing so
;; causes reload to force some constants into the constant pool, but since
;; the Xtensa constant pool can only be accessed with L32R instructions, it
......
......@@ -48,7 +48,9 @@ along with GCC; see the file COPYING3. If not see
%{mtarget-align:--target-align} \
%{mno-target-align:--no-target-align} \
%{mlongcalls:--longcalls} \
%{mno-longcalls:--no-longcalls}"
%{mno-longcalls:--no-longcalls} \
%{mauto-litpools:--auto-litpools} \
%{mno-auto-litpools:--no-auto-litpools}"
#undef LIB_SPEC
#define LIB_SPEC "-lc -lsim -lc -lhandlers-sim -lhal"
......
......@@ -42,7 +42,9 @@ along with GCC; see the file COPYING3. If not see
%{mtarget-align:--target-align} \
%{mno-target-align:--no-target-align} \
%{mlongcalls:--longcalls} \
%{mno-longcalls:--no-longcalls}"
%{mno-longcalls:--no-longcalls} \
%{mauto-litpools:--auto-litpools} \
%{mno-auto-litpools:--no-auto-litpools}"
#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
......
......@@ -142,7 +142,8 @@
(match_test "GET_MODE_CLASS (mode) == MODE_INT
&& xtensa_simm12b (INTVAL (op))"))
(and (match_code "const_int,const_double,const,symbol_ref,label_ref")
(match_test "TARGET_CONST16 && CONSTANT_P (op)
(match_test "(TARGET_CONST16 || TARGET_AUTO_LITPOOLS)
&& CONSTANT_P (op)
&& GET_MODE_SIZE (mode) % UNITS_PER_WORD == 0")))))
;; Accept the floating point constant 1 in the appropriate mode.
......
......@@ -480,6 +480,9 @@ xtensa_valid_move (machine_mode mode, rtx *operands)
{
int dst_regnum = xt_true_regnum (operands[0]);
if (xtensa_tls_referenced_p (operands[1]))
return FALSE;
/* The stack pointer can only be assigned with a MOVSP opcode. */
if (dst_regnum == STACK_POINTER_REGNUM)
return !TARGET_WINDOWED_ABI
......@@ -1048,7 +1051,7 @@ xtensa_emit_move_sequence (rtx *operands, machine_mode mode)
return 1;
}
if (! TARGET_CONST16)
if (! TARGET_AUTO_LITPOOLS && ! TARGET_CONST16)
{
src = force_const_mem (SImode, src);
operands[1] = src;
......@@ -2429,6 +2432,20 @@ print_operand (FILE *file, rtx x, int letter)
}
break;
case 'y':
if (GET_CODE (x) == CONST_DOUBLE &&
GET_MODE (x) == SFmode)
{
REAL_VALUE_TYPE r;
long l;
REAL_VALUE_FROM_CONST_DOUBLE (r, x);
REAL_VALUE_TO_TARGET_SINGLE (r, l);
fprintf (file, "0x%08lx", l);
break;
}
/* fall through */
default:
if (GET_CODE (x) == REG || GET_CODE (x) == SUBREG)
fprintf (file, "%s", reg_names[xt_true_regnum (x)]);
......
......@@ -761,8 +761,8 @@
})
(define_insn "movsi_internal"
[(set (match_operand:SI 0 "nonimmed_operand" "=D,D,D,D,R,R,a,q,a,W,a,a,U,*a,*A")
(match_operand:SI 1 "move_operand" "M,D,d,R,D,d,r,r,I,i,T,U,r,*A,*r"))]
[(set (match_operand:SI 0 "nonimmed_operand" "=D,D,D,D,R,R,a,q,a,a,W,a,a,U,*a,*A")
(match_operand:SI 1 "move_operand" "M,D,d,R,D,d,r,r,I,Y,i,T,U,r,*A,*r"))]
"xtensa_valid_move (SImode, operands)"
"@
movi.n\t%0, %x1
......@@ -774,15 +774,16 @@
mov\t%0, %1
movsp\t%0, %1
movi\t%0, %x1
movi\t%0, %1
const16\t%0, %t1\;const16\t%0, %b1
%v1l32r\t%0, %1
%v1l32i\t%0, %1
%v0s32i\t%1, %0
rsr\t%0, ACCLO
wsr\t%1, ACCLO"
[(set_attr "type" "move,move,move,load,store,store,move,move,move,move,load,load,store,rsr,wsr")
[(set_attr "type" "move,move,move,load,store,store,move,move,move,move,move,load,load,store,rsr,wsr")
(set_attr "mode" "SI")
(set_attr "length" "2,2,2,2,2,2,3,3,3,6,3,3,3,3,3")])
(set_attr "length" "2,2,2,2,2,2,3,3,3,3,6,3,3,3,3,3")])
;; 16-bit Integer moves
......@@ -796,21 +797,22 @@
})
(define_insn "movhi_internal"
[(set (match_operand:HI 0 "nonimmed_operand" "=D,D,a,a,a,U,*a,*A")
(match_operand:HI 1 "move_operand" "M,d,r,I,U,r,*A,*r"))]
[(set (match_operand:HI 0 "nonimmed_operand" "=D,D,a,a,a,a,U,*a,*A")
(match_operand:HI 1 "move_operand" "M,d,r,I,Y,U,r,*A,*r"))]
"xtensa_valid_move (HImode, operands)"
"@
movi.n\t%0, %x1
mov.n\t%0, %1
mov\t%0, %1
movi\t%0, %x1
movi\t%0, %1
%v1l16ui\t%0, %1
%v0s16i\t%1, %0
rsr\t%0, ACCLO
wsr\t%1, ACCLO"
[(set_attr "type" "move,move,move,move,load,store,rsr,wsr")
[(set_attr "type" "move,move,move,move,move,load,store,rsr,wsr")
(set_attr "mode" "HI")
(set_attr "length" "2,2,3,3,3,3,3,3")])
(set_attr "length" "2,2,3,3,3,3,3,3,3")])
;; 8-bit Integer moves
......@@ -881,7 +883,7 @@
(match_operand:SF 1 "general_operand" ""))]
""
{
if (!TARGET_CONST16 && CONSTANT_P (operands[1]))
if (!TARGET_CONST16 && !TARGET_AUTO_LITPOOLS && CONSTANT_P (operands[1]))
operands[1] = force_const_mem (SFmode, operands[1]);
if ((!register_operand (operands[0], SFmode)
......@@ -896,8 +898,8 @@
})
(define_insn "movsf_internal"
[(set (match_operand:SF 0 "nonimmed_operand" "=f,f,U,D,D,R,a,f,a,W,a,a,U")
(match_operand:SF 1 "move_operand" "f,U,f,d,R,d,r,r,f,iF,T,U,r"))]
[(set (match_operand:SF 0 "nonimmed_operand" "=f,f,U,D,D,R,a,f,a,a,W,a,a,U")
(match_operand:SF 1 "move_operand" "f,U,f,d,R,d,r,r,f,Y,iF,T,U,r"))]
"((register_operand (operands[0], SFmode)
|| register_operand (operands[1], SFmode))
&& !(FP_REG_P (xt_true_regnum (operands[0]))
......@@ -912,13 +914,14 @@
mov\t%0, %1
wfr\t%0, %1
rfr\t%0, %1
movi\t%0, %y1
const16\t%0, %t1\;const16\t%0, %b1
%v1l32r\t%0, %1
%v1l32i\t%0, %1
%v0s32i\t%1, %0"
[(set_attr "type" "farith,fload,fstore,move,load,store,move,farith,farith,move,load,load,store")
[(set_attr "type" "farith,fload,fstore,move,load,store,move,farith,farith,move,move,load,load,store")
(set_attr "mode" "SF")
(set_attr "length" "3,3,3,2,2,2,3,3,3,6,3,3,3")])
(set_attr "length" "3,3,3,2,2,2,3,3,3,3,6,3,3,3")])
(define_insn "*lsiu"
[(set (match_operand:SF 0 "register_operand" "=f")
......@@ -991,7 +994,7 @@
(match_operand:DF 1 "general_operand" ""))]
""
{
if (CONSTANT_P (operands[1]) && !TARGET_CONST16)
if (CONSTANT_P (operands[1]) && !TARGET_CONST16 && !TARGET_AUTO_LITPOOLS)
operands[1] = force_const_mem (DFmode, operands[1]);
if (!register_operand (operands[0], DFmode)
......@@ -1002,8 +1005,8 @@
})
(define_insn_and_split "movdf_internal"
[(set (match_operand:DF 0 "nonimmed_operand" "=a,W,a,a,U")
(match_operand:DF 1 "move_operand" "r,iF,T,U,r"))]
[(set (match_operand:DF 0 "nonimmed_operand" "=a,a,W,a,a,U")
(match_operand:DF 1 "move_operand" "r,Y,iF,T,U,r"))]
"register_operand (operands[0], DFmode)
|| register_operand (operands[1], DFmode)"
"#"
......
......@@ -38,6 +38,10 @@ mtext-section-literals
Target
Intersperse literal pools with code in the text section
mauto-litpools
Target Report Mask(AUTO_LITPOOLS)
Relax literals in assembler and place them automatically in the text section
mserialize-volatile
Target Report Mask(SERIALIZE_VOLATILE)
-mno-serialize-volatile Do not serialize volatile memory references with MEMW instructions
......@@ -1120,6 +1120,7 @@ See RS/6000 and PowerPC Options.
-mforce-no-pic @gol
-mserialize-volatile -mno-serialize-volatile @gol
-mtext-section-literals -mno-text-section-literals @gol
-mauto-litpools -mno-auto-litpools @gol
-mtarget-align -mno-target-align @gol
-mlongcalls -mno-longcalls}
......@@ -23605,7 +23606,23 @@ pools from separate object files to remove redundant literals and
improve code size. With @option{-mtext-section-literals}, the literals
are interspersed in the text section in order to keep them as close as
possible to their references. This may be necessary for large assembly
files.
files. Literals for each function are placed right before that function.
@item -mauto-litpools
@itemx -mno-auto-litpools
@opindex mauto-litpools
@opindex mno-auto-litpools
These options control the treatment of literal pools. The default is
@option{-mno-auto-litpools}, which places literals in a separate
section in the output file unless @option{-mtext-section-literals} is
used. With @option{-mauto-litpools} the literals are interspersed in
the text section by the assembler. Compiler does not produce explicit
@code{.literal} directives and loads literals into registers with
@code{MOVI} instructions instead of @code{L32R} to let the assembler
do relaxation and place literals as necessary. This option allows
assembler to create several literal pools per function and assemble
very big functions, which may not be possible with
@option{-mtext-section-literals}.
@item -mtarget-align
@itemx -mno-target-align
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment