1 ; Standard RTL functions.
2 ; Copyright (C) 2000, 2009 Red Hat, Inc.
3 ; This file is part of CGEN.
4 ; See file COPYING.CGEN for details.
6 ; THIS FILE CONTAINS ONE BIG FUNCTION: def-rtx-funcs.
8 ; It is ok for this file to use procs "internal" to rtl.scm.
10 ; Each rtx functions has two leading operands: &options, &mode;
11 ; though `&mode' may be spelled differently.
12 ; The "&" prefix is to indicate that the parsing of these operands is handled
13 ; differently. They are optional and are written with leading colons
14 ; (e.g. :SI). The leading ":" is to help the parser - all leading optional
15 ; operands begin with ":". The order of the arguments is &options then &mode
16 ; though there is no imposed order in written RTL.
18 (define (def-rtx-funcs)
20 ; Do not change the indentation here.
23 ; These are defined in rtl.scm.
25 (drsn define-rtx-syntax-node)
26 (dron define-rtx-operand-node)
27 (drmn define-rtx-macro-node)
30 ; The reason for the odd indenting above is so that emacs begins indenting the
31 ; following code at column 1.
34 ; MODE is present for use in situations like non-VOID mode cond's.
36 (drn (error &options &mode message)
37 (OPTIONS ANYMODE STRING) (NA NA NA)
39 (context-error (estate-context *estate*) message)
43 ; Default mode is INT.
45 (drn (enum &options &mode enum-name)
46 (OPTIONS NUMMODE SYMBOL) (NA NA NA)
48 ; When computing a value, return the enum's value.
49 (enum-lookup-val enum-name)
53 ; These are used in the encode/decode specs of other ifields as well as in
54 ; instruction semantics.
55 ; Ifields are normally specified by name, but they are subsequently wrapped
58 (dron (ifield &options &mode ifld-name)
59 (OPTIONS DFLTMODE SYMBOL) (NA NA NA)
61 (let ((f (current-ifld-lookup ifld-name)))
62 (make <operand> ifld-name (string-append ifld-name " used as operand")
63 (atlist-cons (bool-attr-make 'SEM-ONLY #t)
65 (obj:name (ifld-hw-type f))
66 (obj:name (ifld-mode f))
67 (make <hw-index> 'anonymous 'ifield (ifld-mode f) f)
72 ; Operands are normally specified by name, but they are subsequently wrapped
75 (dron (operand &options &mode op-name)
76 (OPTIONS DFLTMODE SYMBOL) (NA NA NA)
78 (current-op-lookup op-name)
81 ; Operand naming/numbering.
82 ; Operands are given names so that the operands as used in the semantics can
83 ; be matched with arguments of function units. With good name choices of
84 ; operands and function unit arguments, this is rarely necessary, but
87 ; ??? This obfuscates the semantic code a fair bit. Another way to do this
88 ; would be to add new elements to <insn> to specify operands outside of
89 ; the semantic code. E.g.
91 ; (inputs (in-gr1 src1) (in-gr2 src2))
92 ; (outputs (out-pc pc) (out-gr dr) (reg-14 (reg WI h-gr 14)))
94 ; The intent here is to continue to allow the semantic code to use names
95 ; of operands, and not overly complicate the input/output description.
97 ; In instructions, operand numbers are recorded as well, to implement
98 ; profiling and result writeback of parallel insns.
100 ; Rename operand VALUE to NEW-NAME.
101 ; VALUE is an expression whose result is an object of type <operand>.
102 ; It can be the name of an existing operand.
103 ; ??? Might also support numbering by allowing NEW-NAME to be a number.
105 (drsn (name &options &mode new-name value)
106 (OPTIONS DFLTMODE SYMBOL RTX) (NA NA NA ANY)
108 (let ((result (object-copy (rtx-get 'DFLT value))))
109 (op:set-sem-name! result new-name)
113 ; Operands are generally compiled to an internal form first.
114 ; There is a fair bit of state associated with them, and it's easier to
115 ; work with an object than source [which might get fairly complicated if
116 ; it expresses all the state].
117 ; Compiled operands are wrapped in this so that they still look like rtx.
119 (dron (xop &options &mode object)
120 (OPTIONS DFLTMODE OBJECT) (NA NA NA)
125 ;(dron (opspec: &options &mode op-name op-num hw-ref attrs)
126 ; (OPTIONS ANYMODE SYMBOL NUMBER RTX ATTRS) (NA NA NA NA ANY NA)
128 ; (let ((opval (rtx-eval-with-estate hw-ref mode *estate*)))
129 ; (assert (operand? opval))
130 ; ; Set the specified mode, ensuring it's ok.
131 ; ; This also makes a copy as we don't want to modify predefined
133 ; (let ((operand (op:new-mode opval mode)))
134 ; (op:set-sem-name! operand op-name)
135 ; (op:set-num! operand op-num)
136 ; (op:set-cond?! operand (attr-value attrs 'COND-REF #f))
140 ; Specify a reference to a local variable.
141 ; Local variables are normally specified by name, but they are subsequently
144 (dron (local &options &mode local-name)
145 (OPTIONS DFLTMODE SYMBOL) (NA NA NA)
147 (rtx-temp-lookup (tstate-env *tstate*) local-name)
150 ; FIXME: This doesn't work. See s-operand.
151 ;(define (s-dup estate op-name)
152 ; (if (not (insn? (estate-owner estate)))
153 ; (error "dup: not processing an insn"))
154 ; (vector-ref (insn:operands (current-current-context))
155 ; (op:lookup-num (insn:operands (estate-owner estate)) op-name))
158 ; ??? Since operands are given names and not numbers this isn't currently used.
160 ;(drsn (dup &options &mode op-name)
161 ; (OPTIONS DFLTMODE SYMBOL) (NA NA NA)
162 ; ;(s-dup *estate* op-name)
164 ; (if (not (insn? (estate-owner *estate*)))
165 ; (error "dup: not processing an insn"))
166 ; (vector-ref (insn:operands (estate-owner *estate*))
167 ; (op:lookup-num (insn:operands (estate-owner *estate*)) op-name)))
171 ; Returns non-zero if operand NAME was referenced (read if input operand
172 ; and written if output operand).
173 ; ??? What about input/output operands.
175 (drsn (ref &options &mode name)
176 (OPTIONS DFLTMODE SYMBOL) (NA NA NA)
181 ; Return the index of an operand.
182 ; For registers this is the register number.
183 ; ??? Mode handling incomplete.
185 (dron (index-of &options &mode op-rtx)
186 (OPTIONS DFLTMODE RTX) (NA NA ANY)
188 (let* ((operand (rtx-eval-with-estate op-rtx 'DFLT *estate*))
189 (f (hw-index:value (op:index operand)))
190 (f-name (obj:name f)))
191 (make <operand> f-name f-name
192 (atlist-cons (bool-attr-make 'SEM-ONLY #t)
194 (obj:name (ifld-hw-type f))
195 (obj:name (ifld-mode f))
196 (make <hw-index> 'anonymous
199 ; (send (op:type op) 'get-index-mode)
204 ; Same as index-of, but improves readability for registers.
212 ; Describe a random hardware object.
213 ; If INDX is missing, assume the element is a scalar. We pass 0 so s-hw
214 ; doesn't have to unpack the list that would be passed if it were defined as
215 ; (hw mode hw-name . indx). This is an internal implementation detail
216 ; and thus harmless to the description language.
217 ; These are implemented as syntax nodes as we must pass INDX to `s-hw'
219 ; ??? Not currently supported. Not sure whether it should be.
220 ;(drsn (hw &options &mode hw-elm . indx-sel)
221 ; (OPTIONS ANYMODE SYMBOL . RTX) (NA NA NA . INT)
223 ; (let ((indx (if (pair? indx-sel) (car indx-sel) 0))
224 ; (selector (if (and (pair? indx-sel) (pair? (cdr indx-sel)))
226 ; hw-selector-default))))
227 ; (s-hw *estate* mode hw-elm indx selector)
231 ; INDX-SEL is an optional index and possible selector.
232 (dron (reg &options &mode hw-elm . indx-sel)
233 (OPTIONS ANYMODE SYMBOL . RTX) (NA NA NA . INT)
235 (let ((indx (if (pair? indx-sel) (car indx-sel) 0))
236 (selector (if (and (pair? indx-sel) (pair? (cdr indx-sel)))
238 hw-selector-default)))
239 (s-hw *estate* mode hw-elm indx selector))
242 ; A raw-reg bypasses the getter/setter stuff. It's usually used in
243 ; getter/setter definitions.
245 (dron (raw-reg &options &mode hw-elm . indx-sel)
246 (OPTIONS ANYMODE SYMBOL . RTX) (NA NA NA . INT)
248 (let ((indx (if (pair? indx-sel) (car indx-sel) 0))
249 (selector (if (and (pair? indx-sel) (pair? (cdr indx-sel)))
251 hw-selector-default)))
252 (let ((result (s-hw *estate* mode hw-elm indx selector)))
253 (obj-cons-attr! result (bool-attr-make 'RAW #t))
258 (dron (mem &options &mode addr . sel)
259 (OPTIONS EXPLNUMMODE RTX . RTX) (NA NA AI . INT)
261 (s-hw *estate* mode 'h-memory addr
262 (if (pair? sel) (car sel) hw-selector-default))
265 ; Instruction execution support.
266 ; There are no jumps, per se. A jump is a set of `pc'.
268 ; The program counter.
269 ; ??? Hmmm... needed? The pc is usually specified as `pc' which is shorthand
271 (dron (pc) () () ARG s-pc)
273 ; Fetch bytes from the instruction stream of size MODE.
274 ; FIXME: Later need to augment this by passing an indicator to the mem-fetch
275 ; routines that we're doing an ifetch.
278 (drmn (ifetch mode pc)
279 (list 'mem mode pc) ; hw-selector-ispace
282 ; NUM is the instruction number. Generally it is zero but if more than one
283 ; insn is decoded at a time, it is non-zero. This is used, for example, to
284 ; index into the scache [as an offset from the first insn].
287 (drmn (decode mode pc insn num)
288 (list 'c-call mode 'EXTRACT pc insn num)
291 ; NUM is the same number passed to `decode'.
294 (drmn (execute mode num)
295 (list 'c-call mode 'EXECUTE num)
298 ; Control Transfer Instructions
300 ; Sets of pc are handled like other sets so there are no branch rtx's.
302 ; Indicate there are N delay slots in the processing of RTX.
303 ; N is a `const' node.
306 (drn (delay &options &mode n rtx)
307 (OPTIONS DFLTMODE RTX RTX) (NA NA INT ANY)
309 #f ; (s-sequence *estate* VOID '() rtx) ; wip!
312 ; Annul the following insn if YES? is non-zero.
313 ; PC is the address of the annuling insn.
314 ; The target is required to define SEM_ANNUL_INSN.
318 ; The pc reference here is hidden in c-code to not generate a spurious
320 (list 'c-call 'VOID "SEM_ANNUL_INSN" (list 'c-code 'IAI "pc") yes?)
323 ; Skip the following insn if YES? is non-zero.
324 ; The target is required to define SEM_SKIP_INSN.
325 ; ??? This is similar to annul. Deletion of one of them defered.
328 (drn (skip &options &mode yes?)
329 (OPTIONS DFLTMODE RTX) (NA NA INT)
336 ; Return a boolean indicating if attribute named ATTR is VALUE in OWNER.
337 ; If VALUE is a list, return "true" if ATTR is any of the listed values.
338 ; ??? Don't yet support !VALUE.
339 ; OWNER is the result of either (current-insn) or (current-mach)
340 ; [note that canonicalization will turn them into
341 ; (current-{insn,mach} () DFLT)].
342 ; The result is always of mode INT.
345 ; This is a syntax node so the args are not pre-evaluated.
346 ; We just want the symbols.
347 ; FIXME: Hmmm... it currently isn't a syntax node.
349 (drn (eq-attr &options &mode owner attr value)
350 (OPTIONS DFLTMODE RTX SYMBOL SYMORNUM) (NA NA ANY NA NA)
352 (let ((atval (if owner
353 (obj-attr-value owner attr)
354 (attr-lookup-default attr #f))))
356 (->bool (memq atval value))
360 ; Get the value of attribute ATTR-NAME.
361 ; OBJ is the result of either (current-insn) or (current-mach)
362 ; [note that canonicalization will turn them into
363 ; (current-{insn,mach} () DFLT)].
366 (drn (attr &options &mode obj attr-name)
367 (OPTIONS DFLTMODE RTX SYMBOL) (NA NA NA NA)
372 ; Same as `quote', for use in attributes cus "quote" sounds too jargonish.
373 ; [Ok, not a strong argument for using "symbol", but so what?]
375 (drsn (symbol &options &mode name)
376 (OPTIONS DFLTMODE SYMBOL) (NA NA NA)
381 ; Return the current instruction.
383 (drn (current-insn &options &mode)
384 (OPTIONS DFLTMODE) (NA NA)
386 (let ((obj (estate-owner *estate*)))
387 (if (not (insn? obj))
388 (error "current context not an insn"))
392 ; Return the currently selected machine.
393 ; This can either be a compile-time or run-time value.
395 (drn (current-mach &options &mode)
396 (OPTIONS DFLTMODE) (NA NA)
403 ; FIXME: Need to consider 64 bit hosts.
404 (drn (const &options &mode c)
405 (OPTIONS NUMMODE NUMBER) (NA NA NA)
407 ; When computing a value, just return the constant unchanged.
411 ; Large mode support.
413 ; Combine smaller modes into a larger one.
414 ; Arguments are specified most significant to least significant.
415 ; ??? May also want an endian dependent argument order. That can be
416 ; implemented on top of or beside this.
417 ; ??? Not all of the combinations are supported in the simulator.
418 ; They'll get added as necessary.
419 (drn (join &options &out-mode in-mode arg1 . arg-rest)
420 (OPTIONS NUMMODE NUMMODE RTX . RTX) (NA NA NA ANY . ANY)
422 ; FIXME: Ensure correct number of args for in/out modes.
423 ; FIXME: Ensure compatible modes.
428 ; Called subword 'cus it's not exactly subreg.
429 ; Word numbering is from most significant (word 0) to least (word N-1).
430 ; ??? May also want an endian dependent word ordering. That can be
431 ; implemented on top of or beside this.
432 ; ??? GCC plans to switch to SUBREG_BYTE. Keep an eye out for the switch
433 ; (which is extensive so probably won't happen anytime soon).
435 ; The mode spec of operand0 use to be OP0, but subword is not a normal rtx.
436 ; The mode of operand0 is not necessarily the same as the mode of the result,
437 ; and code which analyzes it would otherwise use the result mode (specified by
438 ; `&mode') for the mode of operand0.
440 (drn (subword &options &mode value word-num)
441 (OPTIONS NUMMODE RTX RTX) (NA NA ANY INT)
446 ; ??? The split and concat stuff is just an experiment and should not be used.
447 ; What's there now is just "thoughts put down on paper."
449 (drmn (split split-mode in-mode di)
450 ; FIXME: Ensure compatible modes
451 ;(list 'c-raw-call 'BLK (string-append "SPLIT" in-mode split-mode) di)
455 (drmn (concat modes arg1 . arg-rest)
456 ; FIXME: Here might be the place to ensure
457 ; (= (length modes) (length (cons arg1 arg-rest))).
458 ;(cons 'c-raw-call (cons modes (cons "CONCAT" (cons arg1 arg-rest))))
462 ; Support for explicit C code.
463 ; ??? GCC RTL calls this "unspec" which is arguably a more application
466 (drn (c-code &options &mode text)
467 (OPTIONS ANYMODE STRING) (NA NA NA)
472 ; Invoke C functions passing them arguments from the semantic code.
473 ; The arguments are passed as is, no conversion is done here.
475 ; (c-call mode name arg1 arg2 ...)
476 ; which is converted into a C function call:
477 ; name (current_cpu, arg1, arg2, ...)
478 ; Mode is the mode of the result.
479 ; If it is VOID this call is a statement and ';' is appended.
480 ; Otherwise it is part of an expression.
482 (drn (c-call &options &mode name . args)
483 (OPTIONS ANYMODE STRING . RTX) (NA NA NA . ANY)
488 ; Same as c-call but without implicit first arg of `current_cpu'.
490 (drn (c-raw-call &options &mode name . args)
491 (OPTIONS ANYMODE STRING . RTX) (NA NA NA . ANY)
496 ; Set/get/miscellaneous
498 (drn (nop &options &mode)
499 (OPTIONS VOIDMODE) (NA NA)
504 ; Clobber - mark an object as modified without explaining why or how.
506 (drn (clobber &options &mode object)
507 (OPTIONS ANYMODE RTX) (NA NA OP0)
513 ; MODE is the mode of DST. If DFLT, use DST's default mode.
514 ; The mode of the result is always VOID.
516 ; ??? It might be more consistent to rename set -> set-trace, but that's
517 ; too wordy. The `set' rtx is the normal one and we want the normal one to
518 ; be the verbose one (prints result tracing messages). `set-quiet' is the
519 ; atypical one, it doesn't print tracing messages. It may also turn out that
520 ; a different mechanism (rather than the name "set-quiet") is used some day.
521 ; One way would be to record the "quietness" state with the traversal state and
522 ; use something like (with-quiet (set foo bar)) akin to with-output-to-string
525 ; i.e. set -> gen-set-trace
526 ; set-quiet -> gen-set-quiet
528 ; ??? One might want a `!' suffix as in `set!', but methinks that's following
529 ; Scheme too closely.
531 (drn (set &options &mode dst src)
532 (OPTIONS ANYMODE SETRTX RTX) (NA NA OP0 MATCH1)
537 (drn (set-quiet &options &mode dst src)
538 (OPTIONS ANYMODE SETRTX RTX) (NA NA OP0 MATCH1)
543 ; Standard arithmetic operations.
545 ; It's nice emitting macro calls to the actual C operation in that the RTX
546 ; expression is preserved, albeit in C. On the one hand it's one extra thing
547 ; the programmer has to know when looking at the code. But on the other it's
548 ; trivial stuff, and having a layer between RTX and C allows the
549 ; macros/functions to be modified to handle unexpected situations.
551 ; We do emit C directly for cases other than cpu semantics
552 ; (e.g. the assembler).
554 ; The language is defined such that we assume ANSI C semantics while avoiding
555 ; implementation defined areas, with as few exceptions as possible.
557 ; Current exceptions:
558 ; - signed shift right assumes the sign bit is replicated.
560 ; Additional notes [perhaps repeating what's in ANSI C for emphasis]:
561 ; - callers of division and modulus fns must test for 0 beforehand
563 ; - division and modulus fns have unspecified behavior for negative args
564 ; [yes I know the C standard says implementation defined, here its
566 ; - later add versions of div/mod that have an explicit behaviour for -ve args
567 ; - signedness is part of the rtx operation name, and is not determined
568 ; from the arguments [elsewhere is a description of the tradeoffs]
571 (drn (neg &options &mode s1)
572 (OPTIONS ANYMODE RTX) (NA NA OP0)
577 (drn (abs &options &mode s1)
578 (OPTIONS ANYMODE RTX) (NA NA OP0)
583 ; For integer values this is a bitwise operation (each bit inverted).
584 ; For floating point values this produces 1/x.
585 ; ??? Might want different names.
586 (drn (inv &options &mode s1)
587 (OPTIONS ANYMODE RTX) (NA NA OP0)
592 ; This is a boolean operation.
593 ; MODE is the mode of S1. The result always has mode BI.
594 ; ??? Perhaps `mode' shouldn't be here.
595 (drn (not &options &mode s1)
596 (OPTIONS ANYMODE RTX) (NA NA OP0)
601 (drn (add &options &mode s1 s2)
602 (OPTIONS ANYMODE RTX RTX) (NA NA OP0 MATCH1)
606 (drn (sub &options &mode s1 s2)
607 (OPTIONS ANYMODE RTX RTX) (NA NA OP0 MATCH1)
612 ; "OF" for "overflow flag", "CF" for "carry flag",
613 ; "s3" here must have type BI.
614 ; For the *flag rtx's, MODE is the mode of S1,S2; the result always has
616 (drn (addc &options &mode s1 s2 s3)
617 (OPTIONS ANYMODE RTX RTX RTX) (NA NA OP0 MATCH1 BI)
621 (drn (add-cflag &options &mode s1 s2 s3) ; FIXME: rename to addc-cflag
622 (OPTIONS ANYMODE RTX RTX RTX) (NA NA OP0 MATCH1 BI)
626 (drn (add-oflag &options &mode s1 s2 s3) ; FIXME: rename to addc-vflag
627 (OPTIONS ANYMODE RTX RTX RTX) (NA NA OP0 MATCH1 BI)
631 (drn (subc &options &mode s1 s2 s3)
632 (OPTIONS ANYMODE RTX RTX RTX) (NA NA OP0 MATCH1 BI)
636 (drn (sub-cflag &options &mode s1 s2 s3) ; FIXME: rename to subc-cflag
637 (OPTIONS ANYMODE RTX RTX RTX) (NA NA OP0 MATCH1 BI)
641 (drn (sub-oflag &options &mode s1 s2 s3) ; FIXME: rename to subc-vflag
642 (OPTIONS ANYMODE RTX RTX RTX) (NA NA OP0 MATCH1 BI)
647 ; Usurp these names so that we have consistent rtl should a program generator
648 ; ever want to infer more about what the semantics are doing.
649 ; For now these are just macros that expand to real rtl to perform the
652 ; Return bit indicating if VALUE is zero/non-zero.
653 (drmn (zflag arg1 . rest) ; mode value)
654 (if (null? rest) ; mode missing?
655 (list 'eq 'DFLT arg1 0)
656 (list 'eq arg1 (car rest) 0))
659 ; Return bit indicating if VALUE is negative/non-negative.
660 (drmn (nflag arg1 . rest) ; mode value)
661 (if (null? rest) ; mode missing?
662 (list 'lt 'DFLT arg1 0)
663 (list 'lt arg1 (car rest) 0))
668 (drn (mul &options &mode s1 s2)
669 (OPTIONS ANYMODE RTX RTX) (NA NA OP0 MATCH1)
673 ; ??? In non-sim case, ensure s1,s2 is in right C type for right result.
674 ; ??? Need two variants, one that avoids implementation defined situations
675 ; [both host and target], and one that specifies implementation defined
676 ; situations [target].
677 (drn (div &options &mode s1 s2)
678 (OPTIONS ANYMODE RTX RTX) (NA NA OP0 MATCH1)
682 (drn (udiv &options &mode s1 s2)
683 (OPTIONS ANYMODE RTX RTX) (NA NA OP0 MATCH1)
687 (drn (mod &options &mode s1 s2)
688 (OPTIONS ANYMODE RTX RTX) (NA NA OP0 MATCH1)
692 (drn (umod &options &mode s1 s2)
693 (OPTIONS ANYMODE RTX RTX) (NA NA OP0 MATCH1)
698 ; wip: mixed mode mul/div
700 ; various floating point routines
702 (drn (sqrt &options &mode s1)
703 (OPTIONS FLOATMODE RTX) (NA NA OP0)
708 (drn (cos &options &mode s1)
709 (OPTIONS FLOATMODE RTX) (NA NA OP0)
714 (drn (sin &options &mode s1)
715 (OPTIONS FLOATMODE RTX) (NA NA OP0)
722 (drn (min &options &mode s1 s2)
723 (OPTIONS ANYMODE RTX RTX) (NA NA OP0 MATCH1)
728 (drn (max &options &mode s1 s2)
729 (OPTIONS ANYMODE RTX RTX) (NA NA OP0 MATCH1)
734 (drn (umin &options &mode s1 s2)
735 (OPTIONS INTMODE RTX RTX) (NA NA OP0 MATCH1)
740 (drn (umax &options &mode s1 s2)
741 (OPTIONS INTMODE RTX RTX) (NA NA OP0 MATCH1)
746 ; These are bitwise operations.
747 (drn (and &options &mode s1 s2)
748 (OPTIONS ANYMODE RTX RTX) (NA NA OP0 MATCH1)
752 (drn (or &options &mode s1 s2)
753 (OPTIONS ANYMODE RTX RTX) (NA NA OP0 MATCH1)
757 (drn (xor &options &mode s1 s2)
758 (OPTIONS ANYMODE RTX RTX) (NA NA OP0 MATCH1)
765 (drn (sll &options &mode s1 s2)
766 (OPTIONS ANYMODE RTX RTX) (NA NA OP0 INT)
770 (drn (srl &options &mode s1 s2)
771 (OPTIONS ANYMODE RTX RTX) (NA NA OP0 INT)
775 ; ??? In non-sim case, ensure s1 is in right C type for right result.
776 (drn (sra &options &mode s1 s2)
777 (OPTIONS ANYMODE RTX RTX) (NA NA OP0 INT)
781 ; Rotates don't really have a sign, so doesn't matter what we say.
782 (drn (ror &options &mode s1 s2)
783 (OPTIONS ANYMODE RTX RTX) (NA NA OP0 INT)
787 (drn (rol &options &mode s1 s2)
788 (OPTIONS ANYMODE RTX RTX) (NA NA OP0 INT)
792 ; ??? Will also need rotate-with-carry [duh...].
794 ; These are boolean operations (e.g. C &&, ||).
795 ; The result always has mode BI.
796 ; ??? 'twould be more Schemey to take a variable number of args.
797 ; ??? 'twould also simplify several .cpu description entries.
798 ; On the other hand, handling an arbitrary number of args isn't supported by
799 ; ISA's, which the main goal of what we're trying to represent.
800 (drn (andif &options &mode s1 s2)
801 (OPTIONS DFLTMODE RTX RTX) (NA NA ANY ANY)
805 (drn (orif &options &mode s1 s2)
806 (OPTIONS DFLTMODE RTX RTX) (NA NA ANY ANY)
811 ; `bitfield' is an experimental operation.
812 ; It's not really needed but it might help simplify some things.
814 ;(drn (bitfield mode src start length)
821 (drn (ext &options &mode s1)
822 (OPTIONS INTMODE RTX) (NA NA ANY)
826 (drn (zext &options &mode s1)
827 (OPTIONS INTMODE RTX) (NA NA ANY)
831 (drn (trunc &options &mode s1)
832 (OPTIONS INTMODE RTX) (NA NA ANY)
836 (drn (fext &options &mode s1)
837 (OPTIONS FLOATMODE RTX) (NA NA ANY)
841 (drn (ftrunc &options &mode s1)
842 (OPTIONS FLOATMODE RTX) (NA NA ANY)
846 (drn (float &options &mode s1)
847 (OPTIONS FLOATMODE RTX) (NA NA ANY)
851 (drn (ufloat &options &mode s1)
852 (OPTIONS FLOATMODE RTX) (NA NA ANY)
856 (drn (fix &options &mode s1)
857 (OPTIONS INTMODE RTX) (NA NA ANY)
861 (drn (ufix &options &mode s1)
862 (OPTIONS INTMODE RTX) (NA NA ANY)
868 ; MODE is the mode of S1,S2. The result always has mode BI.
870 (drn (eq &options &mode s1 s2)
871 (OPTIONS ANYMODE RTX RTX) (NA NA OP0 MATCH1)
875 (drn (ne &options &mode s1 s2)
876 (OPTIONS ANYMODE RTX RTX) (NA NA OP0 MATCH1)
880 ; ??? In non-sim case, ensure s1,s2 is in right C type for right result.
881 (drn (lt &options &mode s1 s2)
882 (OPTIONS ANYMODE RTX RTX) (NA NA OP0 MATCH1)
886 (drn (le &options &mode s1 s2)
887 (OPTIONS ANYMODE RTX RTX) (NA NA OP0 MATCH1)
891 (drn (gt &options &mode s1 s2)
892 (OPTIONS ANYMODE RTX RTX) (NA NA OP0 MATCH1)
896 (drn (ge &options &mode s1 s2)
897 (OPTIONS ANYMODE RTX RTX) (NA NA OP0 MATCH1)
901 ; ??? In non-sim case, ensure s1,s2 is in right C type for right result.
902 (drn (ltu &options &mode s1 s2)
903 (OPTIONS ANYMODE RTX RTX) (NA NA OP0 MATCH1)
907 (drn (leu &options &mode s1 s2)
908 (OPTIONS ANYMODE RTX RTX) (NA NA OP0 MATCH1)
912 (drn (gtu &options &mode s1 s2)
913 (OPTIONS ANYMODE RTX RTX) (NA NA OP0 MATCH1)
917 (drn (geu &options &mode s1 s2)
918 (OPTIONS ANYMODE RTX RTX) (NA NA OP0 MATCH1)
924 ; Useful in ifield assertions.
926 ; Return a boolean (BI mode) indicating if VALUE is in SET.
927 ; VALUE is any constant rtx. SET is a `number-list' rtx.
929 (drn (member &options &mode value set)
930 (OPTIONS DFLTMODE RTX RTX) (NA NA INT INT)
933 (if (not (rtx-constant? value))
934 (context-error (estate-context *estate*) "value is not a constant" value))
935 (if (not (rtx-kind? 'number-list set))
936 (context-error (estate-context *estate*) "set is not a `number-list' rtx" set))
937 (if (memq (rtx-constant-value value) (rtx-number-list-values set))
942 (drn (number-list &options &mode value-list)
943 (OPTIONS INTMODE NUMBER . NUMBER) (NA NA NA . NA)
948 ; Conditional execution.
950 ; FIXME: make syntax node?
951 (drn (if &options &mode cond then . else)
952 (OPTIONS ANYMODE TESTRTX RTX . RTX) (NA NA ANY OP0 . MATCH2)
954 (apply e-if (append! (list *estate* mode cond then) else))
957 ; ??? The syntax here isn't quite that of Scheme. A condition must be
958 ; followed by a result expression.
959 ; ??? Intermediate expressions (the ones before the last one) needn't have
960 ; the same mode as the result.
961 (drsn (cond &options &mode . cond-code-list)
962 (OPTIONS ANYMODE . CONDRTX) (NA NA . OP0)
967 ; ??? Intermediate expressions (the ones before the last one) needn't have
968 ; the same mode as the result.
969 (drn (case &options &mode test . case-list)
970 (OPTIONS ANYMODE RTX . CASERTX) (NA NA ANY . OP0)
975 ; Parallels and Sequences
977 ; This has to be a syntax node as we don't want EXPRS to be pre-evaluated.
978 ; All semantic ops must have a mode, though here it must be VOID.
979 ; IGNORE is for consistency with sequence. ??? Delete some day.
980 ; ??? There's no real need for mode either.
982 (drsn (parallel &options &mode ignore expr . exprs)
983 (OPTIONS VOIDMODE LOCALS RTX . RTX) (NA NA NA VOID . VOID)
988 ; This has to be a syntax node to handle locals properly: they're not defined
989 ; yet and thus pre-evaluating the expressions doesn't work.
990 ; ??? This should create a closure.
992 (drsn (sequence &options &mode locals expr . exprs)
993 (OPTIONS ANYMODE LOCALS RTX . RTX) (NA NA NA OP0 . OP0)
998 ; Internal rtx to create a closure.
999 ; Internal, so it does not appear in rtl.texi.
1001 (drsn (closure &options &mode expr env)
1002 (OPTIONS DFLTMODE RTX ENV) (NA NA NA NA)
1007 )) ; End of def-rtx-funcs