3 # This is a template specification for the Firm-Backend
5 # the cpu architecture (ia32, ia64, mips, sparc, ppc32, ...)
9 # this strings mark the beginning and the end of a comment in emit
10 $comment_string = "/*";
11 $comment_string_end = "*/";
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"
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 # "rd_constructor" => "c source code which constructs an ir_node"
35 # ... # (all nodes you need to describe)
37 # ); # close the %nodes initializer
39 # op_flags: flags for the operation, OPTIONAL (default is "N")
40 # the op_flags correspond to the firm irop_flags:
43 # C irop_flag_commutative
44 # X irop_flag_cfopcode
45 # I irop_flag_ip_cfopcode
48 # H irop_flag_highlevel
49 # c irop_flag_constlike
52 # irn_flags: special node flags, OPTIONAL (default is 0)
53 # following irn_flags are supported:
56 # I ignore for register allocation
58 # state: state of the operation, OPTIONAL (default is "floats")
60 # arity: arity of the operation, MUST NOT BE OMITTED
62 # args: the OPTIONAL arguments of the node constructor (debug, irg and block
63 # are always the first 3 arguments and are always autmatically
65 # If this key is missing the following arguments will be created:
66 # for i = 1 .. arity: ir_node *op_i
69 # outs: if a node defines more than one output, the names of the projections
70 # nodes having outs having automatically the mode mode_T
72 # comment: OPTIONAL comment for the node constructor
74 # rd_constructor: for every operation there will be a
75 # new_rd_<arch>_<op-name> function with the arguments from above
76 # which creates the ir_node corresponding to the defined operation
77 # you can either put the complete source code of this function here
79 # This key is OPTIONAL. If omitted, the following constructor will
81 # if (!op_<arch>_<op-name>) assert(0);
85 # res = new_ir_node(db, irg, block, op_<arch>_<op-name>, mode, arity, in)
88 # NOTE: rd_constructor and args are only optional if and only if arity is 0,1,2 or 3
92 # 1 - caller save (register must be saved by the caller of a function)
93 # 2 - callee save (register must be saved by the called function)
94 # 4 - ignore (do not assign this register)
95 # NOTE: Last entry of each class is the largest Firm-Mode a register can hold
98 { "name" => "r0", "type" => 1 },
99 { "name" => "r2", "type" => 1 },
100 { "name" => "r3", "type" => 1 },
101 { "name" => "r4", "type" => 1 },
102 { "name" => "r5", "type" => 1 },
103 { "name" => "r6", "type" => 1 },
104 { "name" => "r7", "type" => 1 },
105 { "name" => "r8", "type" => 1 },
106 { "name" => "r9", "type" => 1 },
107 { "name" => "r10", "type" => 1 },
108 # { "name" => "r11", "type" => 1 },
109 # { "name" => "r12", "type" => 1 },
110 { "name" => "r13", "type" => 2 },
111 { "name" => "r14", "type" => 2 },
112 { "name" => "r15", "type" => 2 },
113 # { "name" => "r16", "type" => 2 },
114 # { "name" => "r17", "type" => 2 },
115 # { "name" => "r18", "type" => 2 },
116 # { "name" => "r19", "type" => 2 },
117 # { "name" => "r20", "type" => 2 },
118 # { "name" => "r21", "type" => 2 },
119 # { "name" => "r22", "type" => 2 },
120 # { "name" => "r23", "type" => 2 },
121 # { "name" => "r24", "type" => 2 },
122 # { "name" => "r25", "type" => 2 },
123 # { "name" => "r26", "type" => 2 },
124 # { "name" => "r27", "type" => 2 },
125 # { "name" => "r28", "type" => 2 },
126 # { "name" => "r29", "type" => 2 },
127 # { "name" => "r30", "type" => 2 },
128 { "name" => "r31", "type" => 2 },
129 { "name" => "r1", "type" => 6 }, # this is our stackpointer
130 { "mode" => "mode_P" }
133 # { "name" => "f0", "type" => 1 }, # => reserved for FP Perm
134 { "name" => "f1", "type" => 1 },
135 { "name" => "f2", "type" => 1 },
136 { "name" => "f3", "type" => 1 },
137 { "name" => "f4", "type" => 1 },
138 { "name" => "f5", "type" => 1 },
139 { "name" => "f6", "type" => 1 },
140 { "name" => "f7", "type" => 1 },
141 { "name" => "f8", "type" => 1 },
142 { "name" => "f9", "type" => 1 },
143 { "name" => "f10", "type" => 1 },
144 { "name" => "f11", "type" => 1 },
145 { "name" => "f12", "type" => 1 },
146 { "name" => "f13", "type" => 1 },
147 { "name" => "f14", "type" => 2 },
148 { "name" => "f15", "type" => 2 },
149 { "name" => "f16", "type" => 2 },
150 # { "name" => "f17", "type" => 2 },
151 # { "name" => "f18", "type" => 2 },
152 # { "name" => "f19", "type" => 2 },
153 # { "name" => "f20", "type" => 2 },
154 # { "name" => "f21", "type" => 2 },
155 # { "name" => "f22", "type" => 2 },
156 # { "name" => "f23", "type" => 2 },
157 # { "name" => "f24", "type" => 2 },
158 # { "name" => "f25", "type" => 2 },
159 # { "name" => "f26", "type" => 2 },
160 # { "name" => "f27", "type" => 2 },
161 # { "name" => "f28", "type" => 2 },
162 # { "name" => "f29", "type" => 2 },
163 # { "name" => "f30", "type" => 2 },
164 # { "name" => "f31", "type" => 2 },
165 { "mode" => "mode_D" }
168 { "name" => "cr0", "type" => 1 },
169 { "name" => "cr1", "type" => 1 },
170 { "name" => "cr2", "type" => 2 },
171 { "name" => "cr3", "type" => 2 },
172 { "name" => "cr4", "type" => 2 },
173 { "name" => "cr5", "type" => 1 },
174 { "name" => "cr6", "type" => 1 },
175 # { "name" => "cr7", "type" => 1 }, # => reserved for Condition Perm
176 { "mode" => "mode_P" } # real mode is 4 bit, but doesn't matter ...
179 { "name" => "lr", "type" => 4 }, # 3
180 { "mode" => "mode_P" }
183 { "name" => "ctr", "type" => 1 },
184 { "mode" => "mode_P" }
188 #--------------------------------------------------#
191 # _ __ _____ __ _ _ __ ___ _ __ ___ #
192 # | '_ \ / _ \ \ /\ / / | | '__| / _ \| '_ \/ __| #
193 # | | | | __/\ V V / | | | | (_) | |_) \__ \ #
194 # |_| |_|\___| \_/\_/ |_|_| \___/| .__/|___/ #
197 #--------------------------------------------------#
201 #-----------------------------------------------------------------#
204 # _ _ __ | |_ ___ __ _ ___ _ __ _ __ ___ __| | ___ ___ #
205 # | | '_ \| __/ _ \/ _` |/ _ \ '__| | '_ \ / _ \ / _` |/ _ \/ __| #
206 # | | | | | || __/ (_| | __/ | | | | | (_) | (_| | __/\__ \ #
207 # |_|_| |_|\__\___|\__, |\___|_| |_| |_|\___/ \__,_|\___||___/ #
210 #-----------------------------------------------------------------#
212 # commutative operations
217 "comment" => "construct Add: Add(a, b) = Add(b, a) = a + b",
218 "reg_req" => { "in" => [ "gp", "gp" ], "out" => [ "gp" ] },
219 "emit" => '. add %D1, %S1, %S2 /* Add(%S1, %S2) -> %D1, (%A1, %A2) */',
225 "comment" => "construct Add: Addi(a, const) = Addi(const, a) = a + const",
226 "reg_req" => { "in" => [ "!r0" ], "out" => [ "gp" ] },
227 # "reg_req" => { "in" => [ "gp" ], "out" => [ "gp" ] },
228 "emit" => '. addi %D1, %S1, %C /* Addi(%S1, %C) -> %D1, (%A1, const) */',
231 return (attr_a->data.constant_tarval != attr_b->data.constant_tarval);
239 "comment" => "construct Mul: Mullw(a, b) = Mullw(b, a) = lo32(a * b)",
240 "reg_req" => { "in" => [ "gp", "gp" ], "out" => [ "gp" ] },
241 "emit" => '. mullw %D1, %S1, %S2 /* Mullw(%S1, %S2) -> %D1, (%A1, %A2) */',
247 "comment" => "construct Mul: Mulhw(a, b) = Mulhw(b, a) = hi32(a * b)",
248 "reg_req" => { "in" => [ "gp", "gp" ], "out" => [ "gp" ] },
249 "emit" => '. mulhw %D1, %S1, %S2 /* Mulhw(%S1, %S2) -> %D1, (%A1, %A2) */',
255 "comment" => "construct Mul: Mulhwu(a, b) = Mulhwu(b, a) = hi32(a * b)",
256 "reg_req" => { "in" => [ "gp", "gp" ], "out" => [ "gp" ] },
257 "emit" => '. mulhwu %D1, %S1, %S2 /* Mulhwu(%S1, %S2) -> %D1, (%A1, %A2) */',
261 # "irn_flags" => "R",
262 # "comment" => "construct Mul: Mul(a, const) = Mul(const, a) = a * const",
263 # "reg_req" => { "in" => [ "gp" ], "out" => [ "gp" ] },
264 # "emit" => '. mul %S1, %C, %D1 /* signed Mul(%C, %S1) -> %D1, (%A1, const) */',
270 "comment" => "construct And: And(a, b) = And(b, a) = a AND b",
271 "reg_req" => { "in" => [ "gp", "gp" ], "out" => [ "gp" ] },
272 "emit" => '. and %D1, %S1, %S2 /* And(%S1, %S2) -> %D1, (%A1, %A2) */',
276 # "irn_flags" => "R",
277 # "comment" => "construct And: And(a, const) = And(const, a) = a AND const",
278 # "reg_req" => { "in" => [ "gp" ], "out" => [ "gp" ] },
279 # "emit" => '. and %S1, %C, %D1 /* And(%C, %S1) -> %D1, (%A1, const) */',
285 "comment" => "construct Or: Or(a, b) = Or(b, a) = a OR b",
286 "reg_req" => { "in" => [ "gp", "gp" ], "out" => [ "gp" ] },
287 "emit" => '. or %D1, %S1, %S2 /* Or(%S1, %S2) -> %D1, (%A1, %A2) */',
292 # "irn_flags" => "R",
293 # "comment" => "construct Or: Or(a, const) = Or(const, a) = a OR const",
294 # "reg_req" => { "in" => [ "gp" ], "out" => [ "gp" ] },
295 # "emit" => '. or %S1, %C, %D1 /* Or(%C, %S1) -> %D1, (%A1, const) */',
301 "comment" => "construct Xor: Xor(a, b) = Xor(b, a) = a XOR b",
302 "reg_req" => { "in" => [ "gp", "gp" ], "out" => [ "gp" ] },
303 "emit" => '. xor %D1, %S1, %S2 /* Xor(%S1, %S2) -> %D1, (%A1, %A2) */',
307 # "irn_flags" => "R",
308 # "comment" => "construct Xor: Xor(a, const) = Xor(const, a) = a EOR const",
309 # "reg_req" => { "in" => [ "gp" ], "out" => [ "gp" ] },
310 # "emit" => '. xor %S1, %C, %D1 /* Xor(%C, %S1) -> %D1, (%A1, const) */',
313 # not commutative operations
317 "comment" => "construct Sub: Sub(a, b) = a - b",
318 "reg_req" => { "in" => [ "gp", "gp" ], "out" => [ "gp" ] },
319 "emit" => '. sub %D1, %S1, %S2 /* Sub(%S1, %S2) -> %D1, (%A1, %A2) */',
323 # "irn_flags" => "R",
324 # "comment" => "construct Sub: Sub(a, const) = a - const",
325 # "reg_req" => { "in" => [ "gp" ], "out" => [ "gp" ] },
326 # "emit" => '. subl %S1, %C, %D1 /* Sub(%S1, %C) -> %D1, (%A1, const) */',
331 "comment" => "construct Shl: Shl(a, b) = a << b",
332 "reg_req" => { "in" => [ "gp", "gp" ], "out" => [ "gp" ] },
333 "emit" => '. slw %D1, %S1, %S2 /* Shl(%S1, %S2) -> %D1, (%A1, %A2) */',
337 # "irn_flags" => "R",
338 # "comment" => "construct Shl: Shl(a, const) = a << const",
339 # "reg_req" => { "in" => [ "gp" ], "out" => [ "gp" ] },
340 # "emit" => '. shl %S1, %C, %D1 /* Shl(%S1, %C) -> %D1, (%A1, const) */',
345 "comment" => "construct Shr: Srw(a, b): c = a >> b",
346 "reg_req" => { "in" => [ "gp", "gp" ], "out" => [ "gp" ] },
347 "emit" => '. srw %D1, %S1, %S2 /* Srw(%S1, %S2) -> %D1, (%A1, %A2) */',
351 # "irn_flags" => "R",
352 # "comment" => "construct Shr: Shr(a, const) = a >> const",
353 # "reg_req" => { "in" => [ "gp" ], "out" => [ "gp" ] },
354 # "emit" => '. shr %S1, %C, %D1 /* Shr(%S1, %C) -> %D1, (%A1, const) */',
359 "comment" => "construct Shrs: Sraw(a, b): c = a >> b",
360 "reg_req" => { "in" => [ "gp", "gp" ], "out" => [ "gp" ] },
361 "emit" => '. sraw %D1, %S1, %S2 /* Sraw(%S1, %S2) -> %D1, (%A1, %A2) */',
366 "comment" => "construct Shrs: Srawi(a, const): c = a >> const",
367 "reg_req" => { "in" => [ "gp" ], "out" => [ "gp" ] },
368 "emit" => '. sraw %D1, %S1, %C /* Sraw(%S1, %C) -> %D1, (%A1, const) */',
371 return (attr_a->data.constant_tarval != attr_b->data.constant_tarval);
378 "comment" => "construct ???: Rlwnm(a, b): c = a ROTL b",
379 "reg_req" => { "in" => [ "gp", "gp" ], "out" => [ "gp" ] },
380 "emit" => '. rlwnm %D1, %S1, %S2 /* Rlwnm(%S1, %S2) -> %D1, (%A1, %A2) */',
385 "comment" => "construct ???: Rlwinm(a, b_const, c_const, d_const): (m = MASK(c, d)) e = (a ROTL b) & m",
386 "reg_req" => { "in" => [ "gp" ], "out" => [ "gp" ] },
387 "emit" => '. rlwinm %D1, %S1, %ppc32_rlwimi_emit_helper /* Rlwinm(%S1, %ppc32_rlwimi_emit_helper) -> %D1, (%A1) */',
390 return (attr_a->data.constant_tarval != attr_b->data.constant_tarval);
397 "comment" => "construct Minus: Neg(a) = -a",
398 "reg_req" => { "in" => [ "gp" ], "out" => [ "gp" ] },
399 "emit" => '. neg %D1, %S1 /* Neg(%S1) -> %D1, (%A1) */',
404 "comment" => "construct Not: Not(a) = !a",
405 "reg_req" => { "in" => [ "gp" ], "out" => [ "gp" ] },
406 "emit" => '. nor %D1, %S1, %S1 /* Not(%S1) -> %D1, (%A1) */',
411 "comment" => "construct Sign extension of byte: Extsb(char a) = (int) a",
412 "reg_req" => { "in" => [ "gp" ], "out" => [ "gp" ] },
413 "emit" => '. extsb %D1, %S1 /* Extsb(%S1) -> %D1, (%A1) */',
418 "comment" => "construct Sign extension of halfword: Extsh(char a) = (short) a",
419 "reg_req" => { "in" => [ "gp" ], "out" => [ "gp" ] },
420 "emit" => '. extsh %D1, %S1 /* Extsh(%S1) -> %D1, (%A1) */',
425 "comment" => "construct Div (signed): Div(a, b) = a div b",
426 "reg_req" => { "in" => [ "gp", "gp" ], "out" => [ "gp" ] },
427 "emit" => '. divw %D1, %S1, %S2 /* Div(%S1, %S2) -> %D1, (%A1, %A2) */',
432 "comment" => "construct Div (unsigned): Div(a, b) = a div b",
433 "reg_req" => { "in" => [ "gp", "gp" ], "out" => [ "gp" ] },
434 "emit" => '. divwu %D1, %S1, %S2 /* Div(%S1, %S2) -> %D1, (%A1, %A2) */',
439 "comment" => "construct Mtctr: Ctr = a",
440 "reg_req" => { "in" => [ "gp" ], "out" => [ "count" ] },
441 "emit" => '. mtctr %S1 /* Mtctr(%S1) -> %D1, (%A1) */',
450 "comment" => "Const (high-level node)",
451 "reg_req" => { "out" => [ "gp" ] },
454 return attr_a->data.constant_tarval != attr_b->data.constant_tarval;
461 "comment" => "float Const (high-level node)",
462 "reg_req" => { "out" => [ "fp" ] },
465 return attr_a->data.constant_tarval != attr_b->data.constant_tarval;
472 "comment" => "SymConst (high-level node)",
473 "reg_req" => { "out" => [ "gp" ] },
476 return attr_a->data.constant_tarval != attr_b->data.constant_tarval;
483 "comment" => "construct unknown register",
484 "reg_req" => { "out" => [ "gp" ] },
485 "emit" => '. \t\t /* use %D1 as uninitialized value */',
495 "comment" => "construct unknown float register",
496 "reg_req" => { "out" => [ "fp" ] },
497 "emit" => '. \t\t /* use %D1 as uninitialized value */',
507 "comment" => "construct unknown condition register",
508 "reg_req" => { "out" => [ "condition" ] },
509 "emit" => '. \t\t /* use %D1 as uninitialized value */',
519 "comment" => "load constant (16bit with sign extension)",
520 "reg_req" => { "out" => [ "gp" ] },
521 "emit" => '. addi %D1, 0, %C /* lower 16 bit of %C (sign extended) -> %D1 */',
524 return (attr_a->data.constant_tarval != attr_b->data.constant_tarval);
529 "op_flags" => "L|X|Y",
530 "comment" => "branch somewhere",
531 "reg_req" => { "in" => [ "condition" ], "out" => [ "none", "none" ] },
534 return (attr_a->data.constant_tarval != attr_b->data.constant_tarval);
540 "comment" => "construct LoopCopy(src, dest, count, mem): Copy count words from src to dest",
541 "reg_req" => { "in" => [ "gp", "gp", "count", "none" ], "out" => [ "none", "in_r1", "in_r2", "in_r3", "gp" ] },
545 "op_flags" => "L|X|Y",
546 "comment" => "construct Switch(selector): Jump to whatever",
547 "reg_req" => { "in" => [ "gp", "gp", "condition" ], "out" => [ "none" ] },
550 return (attr_a->data.constant_tarval != attr_b->data.constant_tarval);
557 "comment" => "load the constant to higher 16 bit of register",
558 "reg_req" => { "out" => [ "gp" ] },
559 "emit" => '. addis %D1, 0, %C /* %C << 16 -> %D1 */',
560 "attr" => "ppc32_attr_offset_mode om, tarval *tv, ident *id",
563 attr->offset_mode = om;
565 attr->content_type = ppc32_ac_Const;
566 attr->data.constant_tarval = tv;
569 attr->content_type = ppc32_ac_SymConst;
570 attr->data.symconst_ident = id;
575 return (attr_a->data.constant_tarval != attr_b->data.constant_tarval);
582 "comment" => "ors constant with register",
583 "reg_req" => { "in" => [ "gp"], "out" => [ "gp" ] },
584 "emit" => '. ori %D1, %S1, %C /* Ori(%S1,%C) -> %D1 */',
587 return (attr_a->data.constant_tarval != attr_b->data.constant_tarval);
594 "comment" => "ands constant with register with cr0 update",
595 "reg_req" => { "in" => [ "gp"], "out" => [ "gp", "cr0" ] },
596 "emit" => '. andi. %D1, %S1,%C /* Andi(%S1,%C) -> %D1 (%D2 changed) */',
599 return (attr_a->data.constant_tarval != attr_b->data.constant_tarval);
605 "comment" => "construct Cmp: Cmp(a, b) = Flags in crX",
606 "reg_req" => { "in" => [ "gp", "gp" ], "out" => [ "condition" ] },
607 "emit" => '. cmp %D1, 0, %S1, %S2 /* Cmp(%S1, %S2) -> %D1, (%A1, %A2) */',
612 "comment" => "construct Cmp immediate: Cmpi(a, const) = Flags in crX",
613 "reg_req" => { "in" => [ "gp" ], "out" => [ "condition" ] },
614 "emit" => '. cmpi %D1, 0, %S1, %C /* Cmpi(%S1, %C) -> %D1, (%A1) */',
617 return (attr_a->data.constant_tarval != attr_b->data.constant_tarval);
624 "comment" => "construct Cmp logical: Cmpl(a, b) = Flags in crX",
625 "reg_req" => { "in" => [ "gp", "gp" ], "out" => [ "condition" ] },
626 "emit" => '. cmpl %D1, 0, %S1, %S2 /* Cmpl(%S1, %S2) -> %D1, (%A1, %A2) */',
631 "comment" => "construct Cmp logical immediate: Cmpli(a, const) = Flags in crX",
632 "reg_req" => { "in" => [ "gp" ], "out" => [ "condition" ] },
633 "emit" => '. cmpli %D1, 0, %S1, %C /* Cmpli(%S1, %C) -> %D1, (%A1) */',
636 return (attr_a->data.constant_tarval != attr_b->data.constant_tarval);
646 "state" => "exc_pinned",
647 "comment" => "construct Load (byte unsigned): Load(ptr, mem) = LD ptr -> reg",
648 "reg_req" => { "in" => [ "!r0", "none" ], "out" => [ "gp", "none" ] },
649 "emit" => '. lbz %D1, %O(%S1) /* Load(%O(%S1)) -> %D1, (%A1) */',
652 return (attr_a->data.constant_tarval != attr_b->data.constant_tarval);
654 "outs" => [ "res", "M" ],
660 "state" => "exc_pinned",
661 "comment" => "construct Load (halfword unsigned): Load(ptr, mem) = LD ptr -> reg",
662 "reg_req" => { "in" => [ "!r0", "none" ], "out" => [ "gp", "none" ] },
663 "emit" => '. lhz %D1, %O(%S1) /* Load(%O(%S1)) -> %D1, (%A1) */',
666 return (attr_a->data.constant_tarval != attr_b->data.constant_tarval);
668 "outs" => [ "res", "M" ],
674 "state" => "exc_pinned",
675 "comment" => "construct Load (halfword signed): Load(ptr, mem) = LD ptr -> reg",
676 "reg_req" => { "in" => [ "!r0", "none" ], "out" => [ "gp", "none" ] },
677 "emit" => '. lha %D1, %O(%S1) /* Load(%O(%S1)) -> %D1, (%A1) */',
680 return (attr_a->data.constant_tarval != attr_b->data.constant_tarval);
682 "outs" => [ "res", "M" ],
688 "state" => "exc_pinned",
689 "comment" => "construct Load (word): Load(ptr, mem) = LD ptr -> reg",
690 "reg_req" => { "in" => [ "!r0", "none" ], "out" => [ "gp", "none" ] },
691 "emit" => '. lwz %D1, %O(%S1) /* Load(%O(%S1)) -> %D1, (%A1) */',
694 return (attr_a->data.constant_tarval != attr_b->data.constant_tarval);
696 "outs" => [ "res", "M" ],
702 "state" => "exc_pinned",
703 "comment" => "construct Load with update (word): Load(ptr, mem) = LD ptr -> reg",
704 "reg_req" => { "in" => [ "!r0", "none" ], "out" => [ "gp", "in_r1", "none"] },
705 "emit" => '. lwzu %D1, %O(%S1) /* Load(%O(%S1)) -> %D1, %S1 += %O, (%A1) */',
708 return (attr_a->data.constant_tarval != attr_b->data.constant_tarval);
710 "outs" => [ "res", "ptr", "M" ],
715 "state" => "exc_pinned",
716 "comment" => "construct Store: Store (byte) (ptr, val, mem) = ST ptr,val",
717 "reg_req" => { "in" => [ "!r0", "gp", "none" ] },
718 "emit" => '. stb %S2, %O(%S1) /* Store(%S2) -> (%S1), (%A1, %A2) */',
721 return (attr_a->data.constant_tarval != attr_b->data.constant_tarval);
728 "state" => "exc_pinned",
729 "comment" => "construct Store: Store (halfword) (ptr, val, mem) = ST ptr,val",
730 "reg_req" => { "in" => [ "!r0", "gp", "none" ] },
731 "emit" => '. sth %S2, %O(%S1) /* Store(%S2) -> (%S1), (%A1, %A2) */',
734 return (attr_a->data.constant_tarval != attr_b->data.constant_tarval);
741 "state" => "exc_pinned",
742 "comment" => "construct Store: Store (word) (ptr, val, mem) = ST ptr,val",
743 "reg_req" => { "in" => [ "!r0", "gp", "none" ] },
744 "emit" => '. stw %S2, %O(%S1) /* Store(%S2) -> (%S1), (%A1, %A2) */',
747 return (attr_a->data.constant_tarval != attr_b->data.constant_tarval);
752 #--------------------------------------------------------#
755 # | |_| | ___ __ _| |_ _ __ ___ __| | ___ ___ #
756 # | _| |/ _ \ / _` | __| | '_ \ / _ \ / _` |/ _ \/ __| #
757 # | | | | (_) | (_| | |_ | | | | (_) | (_| | __/\__ \ #
758 # |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ #
759 #--------------------------------------------------------#
761 # commutative operations
766 "comment" => "construct FP Add: Add(a, b) = Add(b, a) = a + b",
767 "reg_req" => { "in" => [ "fp", "fp" ], "out" => [ "fp" ] },
768 "emit" => '. fadd %D1, %S1, %S2 /* FP Add(%S1, %S2) -> %D1 */',
774 "comment" => "construct FP Add (single): Add(a, b) = Add(b, a) = a + b",
775 "reg_req" => { "in" => [ "fp", "fp" ], "out" => [ "fp" ] },
776 "emit" => '. fadds %D1, %S1, %S2 /* FP Add(%S1, %S2) -> %D1 */',
781 "comment" => "construct FP Mul: Mul(a, b) = Mul(b, a) = a * b",
782 "reg_req" => { "in" => [ "fp", "fp" ], "out" => [ "fp" ] },
783 "emit" => '. fmul %D1, %S1, %S2 /* FP Mul(%S1, %S2) -> %D1 */',
788 "comment" => "construct FP Mul (single): Mul(a, b) = Mul(b, a) = a * b",
789 "reg_req" => { "in" => [ "fp", "fp" ], "out" => [ "fp" ] },
790 "emit" => '. fmuls %D1, %S1, %S2 /* FP Mul(%S1, %S2) -> %D1 */',
794 "comment" => "construct FP Negation: fNeg(a) = -a",
795 "reg_req" => { "in" => [ "fp" ], "out" => [ "fp" ] },
796 "emit" => '. fneg %D1, %S1 /* FP fNeg(%S1) -> %D1 */',
803 "comment" => "construct FP Max: Max(a, b) = Max(b, a) = a > b ? a : b",
804 "reg_req" => { "in" => [ "fp", "fp" ], "out" => [ "fp" ] },
805 "emit" => '. fmax %S1, %S2, %D1 /* FP Max(%S1, %S2) -> %D1 */',
811 "comment" => "construct FP Min: Min(a, b) = Min(b, a) = a < b ? a : b",
812 "reg_req" => { "in" => [ "fp", "fp" ], "out" => [ "fp" ] },
813 "emit" => '. fmin %S1, %S2, %D1 /* FP Min(%S1, %S2) -> %D1 */',
816 # not commutative operations
820 "comment" => "construct FP Sub: Sub(a, b) = a - b",
821 "reg_req" => { "in" => [ "fp", "fp" ], "out" => [ "fp" ] },
822 "emit" => '. fsub %D1, %S1, %S2 /* FP Sub(%S1, %S2) -> %D1 */',
827 "comment" => "construct FP Sub (single): Sub(a, b) = a - b",
828 "reg_req" => { "in" => [ "fp", "fp" ], "out" => [ "fp" ] },
829 "emit" => '. fsub %D1, %S1, %S2 /* FP Sub(%S1, %S2) -> %D1 */',
833 "comment" => "construct FP Div: Div(a, b) = a / b",
834 "reg_req" => { "in" => [ "fp", "fp" ], "out" => [ "fp" ] },
835 "emit" => '. fdiv %D1, %S1, %S2 /* FP Div(%S1, %S2) -> %D1 */',
839 "comment" => "construct FP Div (single): Div(a, b) = a / b",
840 "reg_req" => { "in" => [ "fp", "fp" ], "out" => [ "fp" ] },
841 "emit" => '. fdivs %D1, %S1, %S2 /* FP Div(%S1, %S2) -> %D1 */',
846 "comment" => "construct FP Minus: fMinus(a) = -a",
847 "reg_req" => { "in" => [ "fp" ], "out" => [ "fp" ] },
848 "emit" => '. fneg %D1, %S1 /* FP fMinus(%S1) -> %D1 */',
853 "comment" => "construct FP Convert to integer word: fCtiw(a) = (int) a",
854 "reg_req" => { "in" => [ "fp" ], "out" => [ "fp" ] },
855 "emit" => '. fctiw %D1, %S1 /* FP fCtiw(%S1) -> %D1 */',
860 "comment" => "construct FP Round to single: fRsp(a) = (float) a",
861 "reg_req" => { "in" => [ "fp" ], "out" => [ "fp" ] },
862 "emit" => '. frsp %D1, %S1 /* FP fRsp(%S1) -> %D1 */',
867 "comment" => "construct FP Abs: fAbs(a) = |a|",
868 "reg_req" => { "in" => [ "fp" ], "out" => [ "fp" ] },
869 "emit" => '. fabs %D1, %S1 /* FP fAbs(%S1) -> %D1 */',
874 "comment" => "construct FP Cmp unordered: fCmpu(a, b) = a ? b",
875 "reg_req" => { "in" => [ "fp", "fp" ], "out" => [ "condition" ] },
876 "emit" => '. fcmpu %D1, %S1, %S2 /* FP fCmpu(%S1, %S2) -> %D1 */',
883 # "irn_flags" => "R",
884 # "comment" => "represents a FP constant",
885 # "reg_req" => { "out" => [ "fp" ] },
886 # "emit" => '. fmov %C, %D1 /* Mov fConst into register */',
889 # /* TODO: compare fConst attributes */
897 "comment" => "construct unknown floating point register",
898 "reg_req" => { "out" => [ "fp" ] },
899 "emit" => '. \t\t /* use %D1 as uninitialized value */',
911 "state" => "exc_pinned",
912 "comment" => "construct FP Load (double): Load(ptr, mem) = LD ptr",
913 "reg_req" => { "in" => [ "!r0", "none" ], "out" => [ "fp", "none" ] },
914 "emit" => '. lfd %D1, %O(%S1) /* Load(%O(%S1)) -> %D1 */',
917 return (attr_a->data.constant_tarval != attr_b->data.constant_tarval);
919 "outs" => [ "res", "M" ],
925 "state" => "exc_pinned",
926 "comment" => "construct FP Load (single): Load(ptr, mem) = LD ptr",
927 "reg_req" => { "in" => [ "!r0", "none" ], "out" => [ "fp","none" ] },
928 "emit" => '. lfs %D1, %O(%S1) /* Load(%O(%S1)) -> %D1 */',
931 return (attr_a->data.constant_tarval != attr_b->data.constant_tarval);
933 "outs" => [ "res", "M" ],
938 "state" => "exc_pinned",
939 "comment" => "construct Store (double): Store(ptr, val, mem) = ST ptr,val",
940 "reg_req" => { "in" => [ "!r0", "fp", "none" ] },
941 "emit" => '. stfd %S2, %O(%S1) /* Store(%S2) -> (%S1), (%A1, %A2) */',
944 return (attr_a->data.constant_tarval != attr_b->data.constant_tarval);
951 "state" => "exc_pinned",
952 "comment" => "construct Store (single): Store(ptr, val, mem) = ST ptr,val",
953 "reg_req" => { "in" => [ "!r0", "fp", "none" ] },
954 "emit" => '. stfs %S2, %O(%S1) /* Store(%S2) -> (%S1), (%A1, %A2) */',
957 return (attr_a->data.constant_tarval != attr_b->data.constant_tarval);