3 # This is a template specification for the Firm-Backend
5 # the cpu architecture (ia32, ia64, mips, sparc, ppc, ...)
10 # the number of additional opcodes you want to register
11 #$additional_opcodes = 0;
13 # The node description is done as a perl hash initializer with the
14 # following structure:
19 # op_flags => "N|L|C|X|I|F|Y|H|c|K",
20 # irn_flags => "R|N|I|S"
21 # arity => "0|1|2|3 ... |variable|dynamic|any",
22 # state => "floats|pinned|mem_pinned|exc_pinned",
24 # { type => "type 1", name => "name 1" },
25 # { type => "type 2", name => "name 2" },
28 # comment => "any comment for constructor",
29 # reg_req => { in => [ "reg_class|register" ], out => [ "reg_class|register|in_rX" ] },
30 # cmp_attr => "c source code for comparing node attributes",
31 # emit => "emit code with templates",
32 # attr => "attitional attribute arguments for constructor"
33 # init_attr => "emit attribute initialization template"
34 # rd_constructor => "c source code which constructs an ir_node"
35 # latency => "latency of this operation (can be float)"
36 # attr_type => "name of the attribute struct",
39 # ... # (all nodes you need to describe)
41 # ); # close the %nodes initializer
43 # op_flags: flags for the operation, OPTIONAL (default is "N")
44 # the op_flags correspond to the firm irop_flags:
47 # C irop_flag_commutative
48 # X irop_flag_cfopcode
49 # I irop_flag_ip_cfopcode
52 # H irop_flag_highlevel
53 # c irop_flag_constlike
56 # irn_flags: special node flags, OPTIONAL (default is 0)
57 # following irn_flags are supported:
60 # I ignore for register allocation
61 # S modifies stack pointer
63 # state: state of the operation, OPTIONAL (default is "floats")
65 # arity: arity of the operation, MUST NOT BE OMITTED
67 # args: the OPTIONAL arguments of the node constructor (debug, irg and block
68 # are always the first 3 arguments and are always autmatically
70 # If this key is missing the following arguments will be created:
71 # for i = 1 .. arity: ir_node *op_i
74 # outs: if a node defines more than one output, the names of the projections
75 # nodes having outs having automatically the mode mode_T
76 # One can also annotate some flags for each out, additional to irn_flags.
77 # They are separated from name with a colon ':', and concatenated by pipe '|'
78 # Only I and S are available at the moment (same meaning as in irn_flags).
79 # example: [ "frame:I", "stack:I|S", "M" ]
81 # comment: OPTIONAL comment for the node constructor
83 # rd_constructor: for every operation there will be a
84 # new_rd_<arch>_<op-name> function with the arguments from above
85 # which creates the ir_node corresponding to the defined operation
86 # you can either put the complete source code of this function here
88 # This key is OPTIONAL. If omitted, the following constructor will
90 # if (!op_<arch>_<op-name>) assert(0);
94 # res = new_ir_node(db, irg, block, op_<arch>_<op-name>, mode, arity, in)
97 # NOTE: rd_constructor and args are only optional if and only if arity is 0,1,2 or 3
99 # latency: the latency of the operation, default is 1
105 $mode_gp = "mode_Iu";
106 $mode_fpa = "mode_E";
109 # 0 - no special type
110 # 1 - caller save (register must be saved by the caller of a function)
111 # 2 - callee save (register must be saved by the called function)
112 # 4 - ignore (do not assign this register)
113 # 8 - emitter can choose an arbitrary register of this class
114 # 16 - the register is a virtual one
115 # 32 - register represents a state
116 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
119 { "name" => "r0", "type" => 1 },
120 { "name" => "r1", "type" => 1 },
121 { "name" => "r2", "type" => 1 },
122 { "name" => "r3", "type" => 1 },
123 { "name" => "r4", "type" => 2 },
124 { "name" => "r5", "type" => 2 },
125 { "name" => "r6", "type" => 2 },
126 { "name" => "r7", "type" => 2 },
127 { "name" => "r8", "type" => 2 },
128 { "name" => "r9", "type" => 2 },
129 { "name" => "r10", "type" => 2 },
130 { "name" => "r11", "type" => 2 },
131 { "name" => "r12", "type" => 4 | 2 }, # reserved for linker
132 { "name" => "sp", "type" => 4 | 2 }, # this is our stack pointer
133 { "name" => "lr", "type" => 2 | 1 }, # this is our return address
134 { "name" => "pc", "type" => 4 | 2 }, # this is our program counter
135 { name => "gp_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
136 { "mode" => $mode_gp }
139 { "name" => "f0", "type" => 1 },
140 { "name" => "f1", "type" => 1 },
141 { "name" => "f2", "type" => 1 },
142 { "name" => "f3", "type" => 1 },
143 { "name" => "f4", "type" => 1 },
144 { "name" => "f5", "type" => 1 },
145 { "name" => "f6", "type" => 1 },
146 { "name" => "f7", "type" => 1 },
147 { name => "fpa_UKNWN", type => 4 | 8 | 16 }, # we need a dummy register for Unknown nodes
148 { "mode" => $mode_fpa }
153 M => "${arch}_emit_mode(node);",
154 X => "${arch}_emit_shift(node);",
155 S0 => "${arch}_emit_source_register(node, 0);",
156 S1 => "${arch}_emit_source_register(node, 1);",
157 S2 => "${arch}_emit_source_register(node, 2);",
158 S3 => "${arch}_emit_source_register(node, 3);",
159 S4 => "${arch}_emit_source_register(node, 4);",
160 D0 => "${arch}_emit_dest_register(node, 0);",
161 D1 => "${arch}_emit_dest_register(node, 1);",
162 D2 => "${arch}_emit_dest_register(node, 2);",
163 C => "${arch}_emit_immediate(node);",
164 O => "${arch}_emit_offset(mode);",
167 #--------------------------------------------------#
170 # _ __ _____ __ _ _ __ ___ _ __ ___ #
171 # | '_ \ / _ \ \ /\ / / | | '__| / _ \| '_ \/ __| #
172 # | | | | __/\ V V / | | | | (_) | |_) \__ \ #
173 # |_| |_|\___| \_/\_/ |_|_| \___/| .__/|___/ #
176 #--------------------------------------------------#
178 $default_attr_type = "arm_attr_t";
179 $default_copy_attr = "arm_copy_attr";
182 arm_attr_t => "\tinit_arm_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);",
183 arm_SymConst_attr_t => "\tinit_arm_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);",
184 arm_CondJmp_attr_t => "\tinit_arm_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);",
185 arm_SwitchJmp_attr_t => "\tinit_arm_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);",
186 arm_fpaConst_attr_t => "\tinit_arm_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);",
190 arm_attr_t => "cmp_attr_arm",
191 arm_SymConst_attr_t => "cmp_attr_arm_SymConst",
192 arm_CondJmp_attr_t => "cmp_attr_arm_CondJmp",
193 arm_SwitchJmp_attr_t => "cmp_attr_arm_SwitchJmp",
194 arm_fpaConst_attr_t => "cmp_attr_arm_fpaConst",
200 # comment => "blup di dup",
202 # emit => ". [%S0]-10",
204 # attr => "tarval *tv",
205 # init_attr => "(void) attri;",
207 # # cmp => "return 1;"
213 # reg_req => { in => [ "gp" ] },
214 # attr => "tarval *tv",
215 # init_attr => "(void) tv;",
221 # reg_req => { in => [ "gp", "gp" ] },
232 reg_req => { out => [ "gp_UKNWN" ] },
241 reg_req => { out => [ "fpa_UKNWN" ] },
246 #-----------------------------------------------------------------#
249 # _ _ __ | |_ ___ __ _ ___ _ __ _ __ ___ __| | ___ ___ #
250 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
251 # | | | | | || __/ (_| | __/ | | | | | (_) | (_| | __/\__ \ #
252 # |_|_| |_|\__\___|\__, |\___|_| |_| |_|\___/ \__,_|\___||___/ #
255 #-----------------------------------------------------------------#
257 # commutative operations
262 comment => "construct Add: Add(a, b) = Add(b, a) = a + b",
263 attr => "arm_shift_modifier mod, long shf",
264 init_attr => 'ARM_SET_SHF_MOD(attr, mod); attr->imm_value = shf;',
265 cmp_attr => 'return (attr_a->instr_fl != attr_b->instr_fl) || (attr_a->imm_value != attr_b->imm_value);',
266 reg_req => { "in" => [ "gp", "gp" ], "out" => [ "gp" ] },
267 emit => '. add %D0, %S0, %S1%X'
272 comment => "construct Add: Add(a, const) = Add(const, a) = a + const",
274 init_attr => 'ARM_SET_SHF_MOD(attr, ARM_SHF_IMM); attr->imm_value = imm;',
275 cmp_attr => 'return attr_a->imm_value != attr_b->imm_value;',
276 reg_req => { "in" => [ "gp" ], "out" => [ "gp" ] },
277 emit => '. add %D0, %S0, %C'
283 comment => "construct Mul: Mul(a, b) = Mul(b, a) = a * b",
284 reg_req => { "in" => [ "gp", "gp" ], "out" => [ "!in_r1" ] },
285 emit =>'. mul %D0, %S0, %S1'
291 comment => "construct signed 64bit Mul: Mul(a, b) = Mul(b, a) = a * b",
292 reg_req => { "in" => [ "gp", "gp" ], "out" => [ "gp", "gp" ] },
293 emit =>'. smull %D0, %D1, %S0, %S1',
294 outs => [ "low", "high" ],
300 comment => "construct unsigned 64bit Mul: Mul(a, b) = Mul(b, a) = a * b",
301 reg_req => { "in" => [ "gp", "gp" ], "out" => [ "gp", "gp" ] },
302 emit =>'. umull %D0, %D1, %S0, %S1',
303 outs => [ "low", "high" ],
309 comment => "construct Mla: Mla(a, b, c) = a * b + c",
310 reg_req => { "in" => [ "gp", "gp", "gp" ], "out" => [ "!in_r1" ] },
311 emit =>'. mla %D0, %S0, %S1, %S2'
317 comment => "construct And: And(a, b) = And(b, a) = a AND b",
318 attr => "arm_shift_modifier mod, long shf",
319 init_attr => 'ARM_SET_SHF_MOD(attr, mod); attr->imm_value = shf;',
320 cmp_attr => 'return (attr_a->instr_fl != attr_b->instr_fl) || (attr_a->imm_value != attr_b->imm_value);',
321 reg_req => { "in" => [ "gp", "gp" ], "out" => [ "gp" ] },
322 emit => '. and %D0, %S0, %S1%X'
327 comment => "construct And: And(a, const) = And(const, a) = a AND const",
329 init_attr => 'ARM_SET_SHF_MOD(attr, ARM_SHF_IMM); attr->imm_value = imm;',
330 reg_req => { "in" => [ "gp" ], "out" => [ "gp" ] },
331 emit => '. and %D0, %S0, %C',
332 cmp_attr => 'return attr_a->imm_value != attr_b->imm_value;'
338 comment => "construct Or: Or(a, b) = Or(b, a) = a OR b",
339 attr => "arm_shift_modifier mod, long shf",
340 init_attr => 'ARM_SET_SHF_MOD(attr, mod); attr->imm_value = shf;',
341 cmp_attr => 'return (attr_a->instr_fl != attr_b->instr_fl) || (attr_a->imm_value != attr_b->imm_value);',
342 reg_req => { "in" => [ "gp", "gp" ], "out" => [ "gp" ] },
343 emit => '. orr %D0, %S0, %S1%X'
348 comment => "construct Or: Or(a, const) = Or(const, a) = a OR const",
350 init_attr => 'ARM_SET_SHF_MOD(attr, ARM_SHF_IMM); attr->imm_value = imm;',
351 reg_req => { "in" => [ "gp" ], "out" => [ "gp" ] },
352 cmp_attr => 'return attr_a->imm_value != attr_b->imm_value;',
353 emit => '. orr %D0, %S0, %C'
359 comment => "construct Eor: Eor(a, b) = Eor(b, a) = a EOR b",
360 attr => "arm_shift_modifier mod, long shf",
361 init_attr => 'ARM_SET_SHF_MOD(attr, mod); attr->imm_value = shf;',
362 cmp_attr => 'return (attr_a->instr_fl != attr_b->instr_fl) || (attr_a->imm_value != attr_b->imm_value);',
363 reg_req => { "in" => [ "gp", "gp" ], "out" => [ "gp" ] },
364 emit => '. eor %D0, %S0, %S1%X'
369 comment => "construct Eor: Eor(a, const) = Eor(const, a) = a EOR const",
371 init_attr => 'ARM_SET_SHF_MOD(attr, ARM_SHF_IMM); attr->imm_value = imm;',
372 reg_req => { "in" => [ "gp" ], "out" => [ "gp" ] },
373 cmp_attr => 'return attr_a->imm_value != attr_b->imm_value;',
374 emit => '. eor %D0, %S0, %C'
377 # not commutative operations
381 comment => "construct Bic: Bic(a, b) = a AND ~b",
382 attr => "arm_shift_modifier mod, long shf",
383 init_attr => 'ARM_SET_SHF_MOD(attr, mod); attr->imm_value = shf;',
384 cmp_attr => 'return (attr_a->instr_fl != attr_b->instr_fl) || (attr_a->imm_value != attr_b->imm_value);',
385 reg_req => { "in" => [ "gp", "gp" ], "out" => [ "gp" ] },
386 emit => '. bic %D0, %S0, %S1%X'
391 comment => "construct Bic: Bic(a, const) = a AND ~const",
393 init_attr => 'ARM_SET_SHF_MOD(attr, ARM_SHF_IMM); attr->imm_value = imm;',
394 reg_req => { "in" => [ "gp" ], "out" => [ "gp" ] },
395 emit => '. bic %D0, %S0, %C',
396 cmp_attr => 'return attr_a->imm_value != attr_b->imm_value;'
401 comment => "construct Sub: Sub(a, b) = a - b",
402 attr => "arm_shift_modifier mod, long shf",
403 init_attr => 'ARM_SET_SHF_MOD(attr, mod); attr->imm_value = shf;',
404 cmp_attr => 'return (attr_a->instr_fl != attr_b->instr_fl) || (attr_a->imm_value != attr_b->imm_value);',
405 reg_req => { "in" => [ "gp", "gp" ], "out" => [ "gp" ] },
406 emit => '. sub %D0, %S0, %S1%X'
411 comment => "construct Sub: Sub(a, const) = a - const",
413 init_attr => 'ARM_SET_SHF_MOD(attr, ARM_SHF_IMM); attr->imm_value = imm;',
414 cmp_attr => 'return attr_a->imm_value != attr_b->imm_value;',
415 reg_req => { "in" => [ "gp" ], "out" => [ "gp" ] },
416 emit => '. sub %D0, %S0, %C',
421 comment => "construct Rsb: Rsb(a, b) = b - a",
422 attr => "arm_shift_modifier mod, long shf",
423 init_attr => 'ARM_SET_SHF_MOD(attr, mod); attr->imm_value = shf;',
424 cmp_attr => 'return (attr_a->instr_fl != attr_b->instr_fl) || (attr_a->imm_value != attr_b->imm_value);',
425 reg_req => { "in" => [ "gp", "gp" ], "out" => [ "gp" ] },
426 emit => '. rsb %D0, %S0, %S1%X'
431 comment => "construct Rsb: Rsb(a, const) = const - a",
433 init_attr => 'ARM_SET_SHF_MOD(attr, ARM_SHF_IMM); attr->imm_value = imm;',
434 reg_req => { "in" => [ "gp" ], "out" => [ "gp" ] },
435 emit => '. rsb %D0, %S0, %C',
436 cmp_attr => 'return attr_a->imm_value != attr_b->imm_value;'
441 comment => "construct Shl: Shl(a, b) = a << b",
442 reg_req => { "in" => [ "gp", "gp" ], "out" => [ "gp" ] },
443 emit => '. mov %D0, %S0, lsl %S1'
448 comment => "construct Shr: Shr(a, b) = a >> b",
449 reg_req => { "in" => [ "gp", "gp" ], "out" => [ "in_r1" ] },
450 emit => '. mov %D0, %S0, lsr %S1'
455 comment => "construct Shrs: Shrs(a, b) = a >> b",
456 reg_req => { "in" => [ "gp", "gp" ], "out" => [ "in_r1" ] },
457 emit => '. mov %D0, %S0, asr %S1'
462 # comment => "construct RotR: RotR(a, b) = a ROTR b",
463 # reg_req => { "in" => [ "gp", "gp" ], "out" => [ "gp" ] },
464 # emit => '. mov %D0, %S0, ror %S1 /* RotR(%S0, %S1) -> %D0, (%A1, %A2) */'
465 ## emit => '. ror %S0, %S1, %D0'
470 # comment => "construct RotL: RotL(a, b) = a ROTL b",
471 # reg_req => { "in" => [ "gp", "gp" ], "out" => [ "gp" ] },
472 # emit => '. rol %S0, %S1, %D0'
477 # comment => "construct RotL: RotL(a, const) = a ROTL const",
478 # reg_req => { "in" => [ "gp" ], "out" => [ "gp" ] },
479 # emit => '. rol %S0, %C, %D0'
484 comment => "construct Mov: a = b",
485 attr => "arm_shift_modifier mod, long shf",
486 init_attr => 'ARM_SET_SHF_MOD(attr, mod); attr->imm_value = shf;',
487 cmp_attr => 'return (attr_a->instr_fl != attr_b->instr_fl) || (attr_a->imm_value != attr_b->imm_value);',
488 reg_req => { "in" => [ "gp" ], "out" => [ "gp" ] },
489 emit => '. mov %D0, %S0%X'
494 comment => "represents an integer constant",
496 init_attr => 'ARM_SET_SHF_MOD(attr, ARM_SHF_IMM); attr->imm_value = imm;',
497 reg_req => { "out" => [ "gp" ] },
498 emit => '. mov %D0, %C',
499 cmp_attr => 'return attr_a->imm_value != attr_b->imm_value;'
504 comment => "construct Not: Not(a) = !a",
505 attr => "arm_shift_modifier mod, long shf",
506 init_attr => 'ARM_SET_SHF_MOD(attr, mod); attr->imm_value = shf;',
507 cmp_attr => 'return (attr_a->instr_fl != attr_b->instr_fl) || (attr_a->imm_value != attr_b->imm_value);',
508 reg_req => { "in" => [ "gp" ], "out" => [ "gp" ] },
509 emit => '. mvn %D0, %S0%X'
514 comment => "represents a negated integer constant",
516 init_attr => 'ARM_SET_SHF_MOD(attr, ARM_SHF_IMM); attr->imm_value = imm;',
517 cmp_attr => 'return attr_a->imm_value != attr_b->imm_value;',
518 reg_req => { "out" => [ "gp" ] },
519 emit => '. mvn %D0, %C',
524 comment => "construct Abs: Abs(a) = |a|",
525 reg_req => { "in" => [ "gp" ], "out" => [ "gp" ] },
528 . rsbmi %D0, %S0, #0'
534 # this node produces ALWAYS an empty (tempary) gp reg and cannot be CSE'd
539 comment => "allocate an empty register for calculations",
540 reg_req => { "out" => [ "gp" ] },
541 emit => '. /* %D0 now available for calculations */',
542 cmp_attr => 'return 1;'
546 comment => "implements a register copy",
547 reg_req => { "in" => [ "gp" ], "out" => [ "gp" ] },
553 comment => "implements a memcopy: CopyB(dst, src, size, mem) == memcpy(dst, src, size)",
555 init_attr => 'attr->imm_value = imm;',
556 cmp_attr => 'return attr_a->imm_value != attr_b->imm_value;',
557 reg_req => { "in" => [ "!sp", "!sp", "gp", "gp", "gp", "none" ], "out" => [ "none" ] },
564 comment => "represents a symbolic constant",
566 init_attr => "\tset_arm_symconst_id(res, id);",
567 reg_req => { "out" => [ "gp" ] },
568 attr_type => "arm_SymConst_attr_t",
574 comment => "construct conditional branch: CMP A, B && JMPxx LABEL",
576 attr => "int proj_num",
577 init_attr => "\tset_arm_CondJmp_proj_num(res, proj_num);",
578 reg_req => { "in" => [ "gp", "gp" ], "out" => [ "none", "none"] },
579 attr_type => "arm_CondJmp_attr_t",
585 comment => "construct switch",
587 attr => "int n_projs, long def_proj_num",
588 init_attr => "\tset_arm_SwitchJmp_n_projs(res, n_projs);\n".
589 "\tset_arm_SwitchJmp_default_proj_num(res, def_proj_num);",
590 reg_req => { "in" => [ "gp" ], "out" => [ "none" ] },
591 attr_type => "arm_SwitchJmp_attr_t",
599 state => "exc_pinned",
600 comment => "construct Load: Load(ptr, mem) = LD ptr -> reg",
601 reg_req => { "in" => [ "gp", "none" ], "out" => [ "gp", "none" ] },
602 emit => '. ldr %D0, [%S0, #0]',
603 outs => [ "res", "M" ],
609 state => "exc_pinned",
610 comment => "construct Load: Load(ptr, mem) = LD ptr -> reg",
611 reg_req => { "in" => [ "gp", "none" ], "out" => [ "gp", "none" ] },
612 emit => '. ldrb %D0, [%S0, #0]',
613 outs => [ "res", "M" ],
619 state => "exc_pinned",
620 comment => "construct Load: Load(ptr, mem) = LD ptr -> reg",
621 reg_req => { "in" => [ "gp", "none" ], "out" => [ "gp", "none" ] },
622 emit => '. ldrsb %D0, [%S0, #0]',
623 outs => [ "res", "M" ],
629 state => "exc_pinned",
630 comment => "construct Load: Load(ptr, mem) = LD ptr -> reg",
631 reg_req => { "in" => [ "gp", "none" ], "out" => [ "gp", "none" ] },
632 emit => '. ldrh %D0, [%S0, #0]',
633 outs => [ "res", "M" ],
639 state => "exc_pinned",
640 comment => "construct Load: Load(ptr, mem) = LD ptr -> reg",
641 reg_req => { "in" => [ "gp", "none" ], "out" => [ "gp", "none" ] },
642 emit => '. ldrsh %D0, [%S0, #0]',
643 outs => [ "res", "M" ],
649 state => "exc_pinned",
650 comment => "construct Store: Store(ptr, val, mem) = ST ptr,val",
651 reg_req => { "in" => [ "gp", "gp", "none" ], "out" => [ "none" ] },
652 emit => '. strb %S1, [%S0, #0]',
659 state => "exc_pinned",
660 comment => "construct Store: Store(ptr, val, mem) = ST ptr,val",
661 reg_req => { "in" => [ "gp", "gp", "none" ], out => [ "none" ] },
662 emit => '. strh %S1, [%S0, #0]',
669 state => "exc_pinned",
670 comment => "construct Store: Store(ptr, val, mem) = ST ptr,val",
671 reg_req => { "in" => [ "gp", "gp", "none" ], out => [ "none" ] },
672 emit => '. str %S1, [%S0, #0]',
679 state => "exc_pinned",
680 comment => "construct Store: Store(ptr, val, mem) = ST ptr,val",
681 reg_req => { "in" => [ "sp", "gp", "gp", "gp", "gp", "none" ], "out" => [ "gp", "none" ] },
682 emit => '. stmfd %S0!, {%S1, %S2, %S3, %S4}',
683 outs => [ "ptr", "M" ],
689 state => "exc_pinned",
690 comment => "construct Load: Load(ptr, mem) = LD ptr -> reg",
691 reg_req => { "in" => [ "sp", "none" ], "out" => [ "gp", "gp", "gp", "none" ] },
692 emit => '. ldmfd %S0, {%D0, %D1, %D2}',
693 outs => [ "res0", "res1", "res2", "M" ],
697 #---------------------------------------------------#
700 # | |_ _ __ __ _ _ __ ___ __| | ___ ___ #
701 # | _| '_ \ / _` | | '_ \ / _ \ / _` |/ _ \/ __| #
702 # | | | |_) | (_| | | | | | (_) | (_| | __/\__ \ #
703 # |_| | .__/ \__,_| |_| |_|\___/ \__,_|\___||___/ #
706 #---------------------------------------------------#
708 # commutative operations
713 comment => "construct FPA Add: Add(a, b) = Add(b, a) = a + b",
714 reg_req => { "in" => [ "fpa", "fpa" ], "out" => [ "fpa" ] },
715 emit => '. adf%M %D0, %S0, %S1',
720 comment => "construct FPA Add: Add(a, b) = Add(b, a) = a + b",
722 init_attr => 'ARM_SET_FPA_IMM(attr); attr->imm_value = imm;',
723 cmp_attr => 'return attr_a->imm_value != attr_b->imm_value;',
724 reg_req => { "in" => [ "fpa" ], "out" => [ "fpa" ] },
725 emit => '. adf%M %D0, %S0, %C',
731 comment => "construct FPA Mul: Mul(a, b) = Mul(b, a) = a * b",
732 reg_req => { "in" => [ "fpa", "fpa" ], "out" => [ "fpa" ] },
733 emit =>'. muf%M %D0, %S0, %S1',
738 comment => "construct FPA Mul: Mul(a, b) = Mul(b, a) = a * b",
740 init_attr => 'ARM_SET_FPA_IMM(attr); attr->imm_value = imm;',
741 cmp_attr => 'return attr_a->imm_value != attr_b->imm_value;',
742 reg_req => { "in" => [ "fpa" ], "out" => [ "fpa" ] },
743 emit => '. muf%M %D0, %S0, %C',
749 comment => "construct FPA Fast Mul: Mul(a, b) = Mul(b, a) = a * b",
750 reg_req => { "in" => [ "fpa", "fpa" ], "out" => [ "fpa" ] },
751 emit =>'. fml%M %D0, %S0, %S1',
757 comment => "construct FPA Max: Max(a, b) = Max(b, a) = a > b ? a : b",
758 reg_req => { "in" => [ "fpa", "fpa" ], "out" => [ "fpa" ] },
759 emit =>'. fmax %S0, %S1, %D0',
765 comment => "construct FPA Min: Min(a, b) = Min(b, a) = a < b ? a : b",
766 reg_req => { "in" => [ "fpa", "fpa" ], "out" => [ "fpa" ] },
767 emit =>'. fmin %S0, %S1, %D0',
770 # not commutative operations
774 comment => "construct FPA Sub: Sub(a, b) = a - b",
775 reg_req => { "in" => [ "fpa", "fpa" ], "out" => [ "fpa" ] },
776 emit => '. suf%M %D0, %S0, %S1'
781 comment => "construct FPA Sub: Sub(a, b) = a - b",
783 init_attr => 'ARM_SET_FPA_IMM(attr); attr->imm_value = imm;',
784 cmp_attr => 'return attr_a->imm_value != attr_b->imm_value;',
785 reg_req => { "in" => [ "fpa" ], "out" => [ "fpa" ] },
786 emit => '. suf%M %D0, %S0, %C'
791 comment => "construct FPA reverse Sub: Sub(a, b) = b - a",
792 reg_req => { "in" => [ "fpa", "fpa" ], "out" => [ "fpa" ] },
793 emit => '. rsf%M %D0, %S0, %S1'
798 comment => "construct FPA reverse Sub: Sub(a, b) = b - a",
800 init_attr => 'ARM_SET_FPA_IMM(attr); attr->imm_value = imm;',
801 cmp_attr => 'return attr_a->imm_value != attr_b->imm_value;',
802 reg_req => { "in" => [ "fpa" ], "out" => [ "fpa" ] },
803 emit => '. rsf%M %D0, %S0, %C'
807 comment => "construct FPA Div: Div(a, b) = a / b",
808 attr => "ir_mode *op_mode",
809 init_attr => "attr->op_mode = op_mode;",
810 reg_req => { "in" => [ "fpa", "fpa" ], "out" => [ "fpa", "none" ] },
811 emit =>'. dvf%M %D0, %S0, %S1',
812 outs => [ "res", "M" ],
816 comment => "construct FPA Div: Div(a, b) = a / b",
817 attr => "ir_mode *op_mode, long imm",
818 init_attr => 'attr->op_mode = op_mode; ARM_SET_FPA_IMM(attr); attr->imm_value = imm;',
819 cmp_attr => 'return attr_a->imm_value != attr_b->imm_value;',
820 reg_req => { "in" => [ "fpa" ], "out" => [ "fpa", "none" ] },
821 emit =>'. dvf%M %D0, %S0, %C',
822 outs => [ "res", "M" ],
826 comment => "construct FPA reverse Div: Div(a, b) = b / a",
827 attr => "ir_mode *op_mode",
828 init_attr => "attr->op_mode = op_mode;",
829 reg_req => { "in" => [ "fpa", "fpa" ], "out" => [ "fpa", "none" ] },
830 emit =>'. rdf%M %D0, %S0, %S1',
831 outs => [ "res", "M" ],
835 comment => "construct FPA reverse Div: Div(a, b) = b / a",
836 attr => "ir_mode *op_mode, long imm",
837 init_attr => 'attr->op_mode = op_mode; ARM_SET_FPA_IMM(attr); attr->imm_value = imm;',
838 cmp_attr => 'return attr_a->imm_value != attr_b->imm_value;',
839 reg_req => { "in" => [ "fpa" ], "out" => [ "fpa", "none" ] },
840 emit =>'. rdf%M %D0, %S0, %S1',
841 outs => [ "res", "M" ],
845 comment => "construct FPA Fast Div: Div(a, b) = a / b",
846 attr => "ir_mode *op_mode",
847 init_attr => "attr->op_mode = op_mode;",
848 reg_req => { "in" => [ "fpa", "fpa" ], "out" => [ "fpa", "none" ] },
849 emit =>'. fdv%M %D0, %S0, %S1',
850 outs => [ "res", "M" ],
854 comment => "construct FPA Fast Div: Div(a, b) = a / b",
855 attr => "ir_mode *op_mode, long imm",
856 init_attr => 'attr->op_mode = op_mode; ARM_SET_FPA_IMM(attr); attr->imm_value = imm;',
857 cmp_attr => 'return attr_a->imm_value != attr_b->imm_value;',
858 reg_req => { "in" => [ "fpa" ], "out" => [ "fpa", "none" ] },
859 emit =>'. fdv%M %D0, %S0, %C',
860 outs => [ "res", "M" ],
864 comment => "construct FPA Fast reverse Div: Div(a, b) = b / a",
865 attr => "ir_mode *op_mode",
866 init_attr => "attr->op_mode = op_mode;",
867 reg_req => { "in" => [ "fpa", "fpa" ], "out" => [ "fpa", "none" ] },
868 emit =>'. frd%M %D0, %S0, %S1',
869 outs => [ "res", "M" ],
873 comment => "construct FPA Fast reverse Div: Div(a, b) = b / a",
874 attr => "ir_mode *op_mode, long imm",
875 init_attr => 'attr->op_mode = op_mode; ARM_SET_FPA_IMM(attr); attr->imm_value = imm;',
876 cmp_attr => 'return attr_a->imm_value != attr_b->imm_value;',
877 reg_req => { "in" => [ "fpa" ], "out" => [ "fpa", "none" ] },
878 emit =>'. frd%M %D0, %S0, %C',
879 outs => [ "res", "M" ],
884 comment => "construct FPA Move: b = a",
885 reg_req => { "in" => [ "fpa" ], "out" => [ "fpa" ] },
886 emit => '. mvf%M %S0, %D0',
891 comment => "represents a float constant",
893 init_attr => 'ARM_SET_FPA_IMM(attr); attr->imm_value = imm;',
894 reg_req => { "out" => [ "fpa" ] },
895 emit => '. mvf%M %D0, %C',
896 cmp_attr => 'return attr_a->imm_value != attr_b->imm_value;'
901 comment => "construct FPA Move Negated: b = -a",
902 reg_req => { "in" => [ "fpa" ], "out" => [ "fpa" ] },
903 emit => '. mnf%M %S0, %D0',
908 comment => "represents a float constant",
910 init_attr => 'ARM_SET_FPA_IMM(attr); attr->imm_value = imm;',
911 reg_req => { "out" => [ "fpa" ] },
912 emit => '. mnf%M %D0, %C',
913 cmp_attr => 'return attr_a->imm_value != attr_b->imm_value;'
918 comment => "construct FPA Absolute value: fAbsd(a) = |a|",
919 reg_req => { "in" => [ "fpa" ], "out" => [ "fpa" ] },
920 emit => '. abs%M %D0, %S0',
927 comment => "construct a FPA integer->float conversion",
928 reg_req => { "in" => ["gp"], "out" => [ "fpa" ] },
929 emit => '. flt%M %D0, %S0',
934 comment => "construct a FPA float->integer conversion",
935 reg_req => { "in" => ["fpa"], "out" => [ "gp" ] },
936 emit => '. fix %D0, %S0',
942 comment => "construct floating point Compare and Branch: CMF A, B && JMPxx LABEL",
944 attr => "int proj_num",
945 init_attr => "\tset_arm_CondJmp_proj_num(res, proj_num);",
946 reg_req => { "in" => [ "fpa", "fpa" ], "out" => [ "none", "none"] },
947 attr_type => "arm_CondJmp_attr_t",
953 comment => "construct floating point Compare negative and Branch: CMF A, -B && JMPxx LABEL",
955 attr => "int proj_num",
956 init_attr => "\tset_arm_CondJmp_proj_num(res, proj_num);",
957 reg_req => { "in" => [ "fpa", "fpa" ], "out" => [ "none", "none"] },
958 attr_type => "arm_CondJmp_attr_t",
964 comment => "construct floating point Compare and Branch: CMF A, -B && JMPxx LABEL",
966 attr => "int proj_num",
967 init_attr => "\tset_arm_CondJmp_proj_num(res, proj_num);",
968 reg_req => { "in" => [ "fpa", "fpa" ], "out" => [ "none", "none"] },
969 attr_type => "arm_CondJmp_attr_t",
975 comment => "construct floating point Compare and Branch: CMF A, -B && JMPxx LABEL",
977 attr => "int proj_num",
978 init_attr => "\tset_arm_CondJmp_proj_num(res, proj_num);",
979 reg_req => { "in" => [ "fpa", "fpa" ], "out" => [ "none", "none"] },
980 attr_type => "arm_CondJmp_attr_t",
988 state => "exc_pinned",
989 comment => "construct FPA Load: Load(ptr, mem) = LD ptr",
990 attr => "ir_mode *op_mode",
991 init_attr => "attr->op_mode = op_mode;",
992 reg_req => { "in" => [ "gp", "none" ], "out" => [ "fpa", "none" ] },
993 emit => '. ldf%M %D0, [%S0]',
994 outs => [ "res", "M" ],
1000 state => "exc_pinned",
1001 comment => "construct Store: Store(ptr, val, mem) = ST ptr,val",
1002 attr => "ir_mode *op_mode",
1003 init_attr => "attr->op_mode = op_mode;",
1004 reg_req => { "in" => [ "gp", "fpa", "none" ], "out" => [ "none" ] },
1005 emit => '. stf%M %S1, [%S0]',
1012 comment => "construct fp double to 2 gp register transfer",
1013 reg_req => { "in" => [ "fpa", "none" ], "out" => [ "gp", "gp", "none" ] },
1014 outs => [ "low", "high", "M" ],
1019 comment => "construct Add to stack pointer",
1020 reg_req => { in => [ "sp", "gp", "none" ], out => [ "in_r1", "none" ] },
1021 emit => '. add %D0, %S0, %S1',
1022 outs => [ "stack:I|S", "M" ],
1027 comment => "construct Sub from stack pointer",
1028 reg_req => { in => [ "sp", "gp", "none" ], out => [ "in_r1", "gp", "none" ] },
1029 ins => [ "stack", "size", "mem" ],
1030 emit => ". sub %D0, %S0, %S1\n".
1032 outs => [ "stack:I|S", "addr", "M" ],
1037 comment => "load the TLS address",
1038 reg_req => { out => [ "gp" ] },
1043 # floating point constants
1048 comment => "construct a floating point constant",
1049 attr => "tarval *tv",
1050 init_attr => "attr->tv = tv;",
1051 mode => "get_tarval_mode(tv)",
1052 reg_req => { "out" => [ "fpa" ] },
1053 attr_type => "arm_fpaConst_attr_t",
1056 #---------------------------------------------------#
1059 # __ _| |_ _ __ _ __ ___ __| | ___ ___ #
1060 # \ \ / / _| '_ \ | '_ \ / _ \ / _` |/ _ \/ __| #
1061 # \ V /| | | |_) | | | | | (_) | (_| | __/\__ \ #
1062 # \_/ |_| | .__/ |_| |_|\___/ \__,_|\___||___/ #
1065 #---------------------------------------------------#