• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

修訂ea3c894d35ea6d875a08c36e273e26b828f54b37 (tree)
時間2016-08-23 17:41:02
作者Richard Sandiford <richard.sandiford@arm....>
CommiterRichard Sandiford

Log Message

[AArch64][SVE 07/32] Replace hard-coded uses of REG_TYPE_R_Z_BHSDQ_V

To remove parsing ambiguities and to avoid register names being
accidentally added to the symbol table, the immediate parsing
routines reject things like:

.equ x0, 0
add v0.4s, v0.4s, x0

An explicit '#' must be used instead:

.equ x0, 0
add v0.4s, v0.4s, #x0

Of course, it wasn't possible to predict what other register
names might be added in future, so this behaviour was restricted
to the register names that were defined at the time. For backwards
compatibility, we should continue to allow things like:

.equ p0, 0
add v0.4s, v0.4s, p0

even though p0 is now an SVE register.

However, it seems reasonable to extend the x0 behaviour above to
SVE registers when parsing SVE instructions, especially since none
of the SVE immediate formats are relocatable. Doing so removes the
same parsing ambiguity for SVE instructions as the x0 behaviour removes
for base AArch64 instructions.

As a prerequisite, we then need to be able to tell the parsing routines
which registers to reject. This patch changes the interface to make
that possible, although the set of rejected registers doesn't change
at this stage.

gas/
* config/tc-aarch64.c (parse_immediate_expression): Add a
reg_type parameter.
(parse_constant_immediate): Likewise, and update calls.
(parse_aarch64_imm_float): Likewise.
(parse_big_immediate): Likewise.
(po_imm_nc_or_fail): Update accordingly, passing down a new
imm_reg_type variable.
(po_imm_of_fail): Likewise.
(parse_operands): Likewise.

Change-Id: I315ee16d17c768d25bb9e0848bb14c4609435ecb

Change Summary

差異

--- a/gas/config/tc-aarch64.c
+++ b/gas/config/tc-aarch64.c
@@ -2004,14 +2004,14 @@ reg_name_p (char *str, aarch64_reg_type reg_type)
20042004
20052005 To prevent the expression parser from pushing a register name
20062006 into the symbol table as an undefined symbol, firstly a check is
2007- done to find out whether STR is a valid register name followed
2008- by a comma or the end of line. Return FALSE if STR is such a
2009- string. */
2007+ done to find out whether STR is a register of type REG_TYPE followed
2008+ by a comma or the end of line. Return FALSE if STR is such a string. */
20102009
20112010 static bfd_boolean
2012-parse_immediate_expression (char **str, expressionS *exp)
2011+parse_immediate_expression (char **str, expressionS *exp,
2012+ aarch64_reg_type reg_type)
20132013 {
2014- if (reg_name_p (*str, REG_TYPE_R_Z_BHSDQ_V))
2014+ if (reg_name_p (*str, reg_type))
20152015 {
20162016 set_recoverable_error (_("immediate operand required"));
20172017 return FALSE;
@@ -2030,16 +2030,17 @@ parse_immediate_expression (char **str, expressionS *exp)
20302030
20312031 /* Constant immediate-value read function for use in insn parsing.
20322032 STR points to the beginning of the immediate (with the optional
2033- leading #); *VAL receives the value.
2033+ leading #); *VAL receives the value. REG_TYPE says which register
2034+ names should be treated as registers rather than as symbolic immediates.
20342035
20352036 Return TRUE on success; otherwise return FALSE. */
20362037
20372038 static bfd_boolean
2038-parse_constant_immediate (char **str, int64_t * val)
2039+parse_constant_immediate (char **str, int64_t *val, aarch64_reg_type reg_type)
20392040 {
20402041 expressionS exp;
20412042
2042- if (! parse_immediate_expression (str, &exp))
2043+ if (! parse_immediate_expression (str, &exp, reg_type))
20432044 return FALSE;
20442045
20452046 if (exp.X_op != O_constant)
@@ -2148,12 +2149,14 @@ aarch64_double_precision_fmovable (uint64_t imm, uint32_t *fpword)
21482149 value in *IMMED in the format of IEEE754 single-precision encoding.
21492150 *CCP points to the start of the string; DP_P is TRUE when the immediate
21502151 is expected to be in double-precision (N.B. this only matters when
2151- hexadecimal representation is involved).
2152+ hexadecimal representation is involved). REG_TYPE says which register
2153+ names should be treated as registers rather than as symbolic immediates.
21522154
21532155 N.B. 0.0 is accepted by this function. */
21542156
21552157 static bfd_boolean
2156-parse_aarch64_imm_float (char **ccp, int *immed, bfd_boolean dp_p)
2158+parse_aarch64_imm_float (char **ccp, int *immed, bfd_boolean dp_p,
2159+ aarch64_reg_type reg_type)
21572160 {
21582161 char *str = *ccp;
21592162 char *fpnum;
@@ -2173,7 +2176,7 @@ parse_aarch64_imm_float (char **ccp, int *immed, bfd_boolean dp_p)
21732176 /* Support the hexadecimal representation of the IEEE754 encoding.
21742177 Double-precision is expected when DP_P is TRUE, otherwise the
21752178 representation should be in single-precision. */
2176- if (! parse_constant_immediate (&str, &val))
2179+ if (! parse_constant_immediate (&str, &val, reg_type))
21772180 goto invalid_fp;
21782181
21792182 if (dp_p)
@@ -2237,15 +2240,15 @@ invalid_fp:
22372240
22382241 To prevent the expression parser from pushing a register name into the
22392242 symbol table as an undefined symbol, a check is firstly done to find
2240- out whether STR is a valid register name followed by a comma or the end
2241- of line. Return FALSE if STR is such a register. */
2243+ out whether STR is a register of type REG_TYPE followed by a comma or
2244+ the end of line. Return FALSE if STR is such a register. */
22422245
22432246 static bfd_boolean
2244-parse_big_immediate (char **str, int64_t *imm)
2247+parse_big_immediate (char **str, int64_t *imm, aarch64_reg_type reg_type)
22452248 {
22462249 char *ptr = *str;
22472250
2248- if (reg_name_p (ptr, REG_TYPE_R_Z_BHSDQ_V))
2251+ if (reg_name_p (ptr, reg_type))
22492252 {
22502253 set_syntax_error (_("immediate operand required"));
22512254 return FALSE;
@@ -3736,12 +3739,12 @@ parse_sys_ins_reg (char **str, struct hash_control *sys_ins_regs)
37363739 } while (0)
37373740
37383741 #define po_imm_nc_or_fail() do { \
3739- if (! parse_constant_immediate (&str, &val)) \
3742+ if (! parse_constant_immediate (&str, &val, imm_reg_type)) \
37403743 goto failure; \
37413744 } while (0)
37423745
37433746 #define po_imm_or_fail(min, max) do { \
3744- if (! parse_constant_immediate (&str, &val)) \
3747+ if (! parse_constant_immediate (&str, &val, imm_reg_type)) \
37453748 goto failure; \
37463749 if (val < min || val > max) \
37473750 { \
@@ -4980,10 +4983,13 @@ parse_operands (char *str, const aarch64_opcode *opcode)
49804983 int i;
49814984 char *backtrack_pos = 0;
49824985 const enum aarch64_opnd *operands = opcode->operands;
4986+ aarch64_reg_type imm_reg_type;
49834987
49844988 clear_error ();
49854989 skip_whitespace (str);
49864990
4991+ imm_reg_type = REG_TYPE_R_Z_BHSDQ_V;
4992+
49874993 for (i = 0; operands[i] != AARCH64_OPND_NIL; i++)
49884994 {
49894995 int64_t val;
@@ -5219,8 +5225,10 @@ parse_operands (char *str, const aarch64_opcode *opcode)
52195225 bfd_boolean res1 = FALSE, res2 = FALSE;
52205226 /* N.B. -0.0 will be rejected; although -0.0 shouldn't be rejected,
52215227 it is probably not worth the effort to support it. */
5222- if (!(res1 = parse_aarch64_imm_float (&str, &qfloat, FALSE))
5223- && !(res2 = parse_constant_immediate (&str, &val)))
5228+ if (!(res1 = parse_aarch64_imm_float (&str, &qfloat, FALSE,
5229+ imm_reg_type))
5230+ && !(res2 = parse_constant_immediate (&str, &val,
5231+ imm_reg_type)))
52245232 goto failure;
52255233 if ((res1 && qfloat == 0) || (res2 && val == 0))
52265234 {
@@ -5253,7 +5261,7 @@ parse_operands (char *str, const aarch64_opcode *opcode)
52535261
52545262 case AARCH64_OPND_SIMD_IMM:
52555263 case AARCH64_OPND_SIMD_IMM_SFT:
5256- if (! parse_big_immediate (&str, &val))
5264+ if (! parse_big_immediate (&str, &val, imm_reg_type))
52575265 goto failure;
52585266 assign_imm_if_const_or_fixup_later (&inst.reloc, info,
52595267 /* addr_off_p */ 0,
@@ -5284,7 +5292,7 @@ parse_operands (char *str, const aarch64_opcode *opcode)
52845292 bfd_boolean dp_p
52855293 = (aarch64_get_qualifier_esize (inst.base.operands[0].qualifier)
52865294 == 8);
5287- if (! parse_aarch64_imm_float (&str, &qfloat, dp_p))
5295+ if (! parse_aarch64_imm_float (&str, &qfloat, dp_p, imm_reg_type))
52885296 goto failure;
52895297 if (qfloat == 0)
52905298 {
@@ -5372,7 +5380,8 @@ parse_operands (char *str, const aarch64_opcode *opcode)
53725380 break;
53735381
53745382 case AARCH64_OPND_EXCEPTION:
5375- po_misc_or_fail (parse_immediate_expression (&str, &inst.reloc.exp));
5383+ po_misc_or_fail (parse_immediate_expression (&str, &inst.reloc.exp,
5384+ imm_reg_type));
53765385 assign_imm_if_const_or_fixup_later (&inst.reloc, info,
53775386 /* addr_off_p */ 0,
53785387 /* need_libopcodes_p */ 0,