History

arm-asm: Support immediate values without "#" (Unified Assembly Language)

Danny Milosavljevic committed 5 years ago

Commit 2ac85681 parent 45845751 file · +22 −22Browse files

Unified · Split

arm-asm.c+22−22
@@ -127,31 +127,34 @@ static void parse_operand(TCCState *s1, Operand *op) · 126 unmodified lines
127127 op->type = OP_REGSET32;
128128 op->regset = regset;
129129 }
130− } else if (tok == '#' || tok == '$') {
131− /* constant value */
132− next(); // skip '#' or '$'
133− asm_expr(s1, &e);
134− op->type = OP_IM32;
135− op->e = e;
136− if (!op->e.sym) {
137− if ((int) op->e.v < 0 && (int) op->e.v >= -255)
138− op->type = OP_IM8N;
139− else if (op->e.v == (uint8_t)op->e.v)
140− op->type = OP_IM8;
141− } else
142− expect("constant");
130+ return;
143131 } else if ((reg = asm_parse_regvar(tok)) != -1) {
144132 next(); // skip register name
145133 op->type = OP_REG32;
146134 op->reg = (uint8_t) reg;
135+ return;
147136 } else if ((reg = asm_parse_vfp_regvar(tok, 0)) != -1) {
148137 next(); // skip register name
149138 op->type = OP_VREG32;
150139 op->reg = (uint8_t) reg;
140+ return;
151141 } else if ((reg = asm_parse_vfp_regvar(tok, 1)) != -1) {
152142 next(); // skip register name
153143 op->type = OP_VREG64;
154144 op->reg = (uint8_t) reg;
145+ return;
146+ } else if (tok == '#' || tok == '$') {
147+ /* constant value */
148+ next(); // skip '#' or '$'
149+ }
150+ asm_expr(s1, &e);
151+ op->type = OP_IM32;
152+ op->e = e;
153+ if (!op->e.sym) {
154+ if ((int) op->e.v < 0 && (int) op->e.v >= -255)
155+ op->type = OP_IM8N;
156+ else if (op->e.v == (uint8_t)op->e.v)
157+ op->type = OP_IM8;
155158 } else
156159 expect("operand");
157160 }
@@ -1784,15 +1787,12 @@ static void asm_floating_point_immediate_data_processing_opcode_tail(TCCState *s · 1626 unmodified lines
17841787
17851788 if (tok == '#' || tok == '$') {
17861789 next();
1787− if (tok == '-') {
1788− op_minus = 1;
1789− next();
1790− }
1791− immediate_value = vmov_parse_immediate_value();
1792− } else {
1793− expect("'#'");
1794− return;
17951790 }
1791+ if (tok == '-') {
1792+ op_minus = 1;
1793+ next();
1794+ }
1795+ immediate_value = vmov_parse_immediate_value();
17961796
17971797 opcode1 = 11; // "Other" instruction
17981798 switch (ARM_INSTRUCTION_GROUP(token)) {
@@ -1959,7 +1959,7 @@ static void asm_floating_point_data_processing_opcode(TCCState *s1, int token) { · 160 unmodified lines
19591959
19601960 for (nb_ops = 0; nb_ops < 3; ) {
19611961 // Note: Necessary because parse_operand can't parse decimal numerals.
1962− if (nb_ops == 1 && (tok == '#' || tok == '$')) {
1962+ if (nb_ops == 1 && (tok == '#' || tok == '$' || tok == TOK_PPNUM || tok == '-')) {
19631963 asm_floating_point_immediate_data_processing_opcode_tail(s1, token, coprocessor, ops[0].reg);
19641964 return;
19651965 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t